summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhenning <henning@openbsd.org>2007-03-28 12:33:32 +0000
committerhenning <henning@openbsd.org>2007-03-28 12:33:32 +0000
commit9747982e99e919b91cbb25f0fcd1a4c6c044016c (patch)
tree5f25b99a35caa3e9c76210fbe43c17bf9ab2e0e6
parentadd machines supported by the mesh(4) driver and HISTORY section. (diff)
downloadwireguard-openbsd-9747982e99e919b91cbb25f0fcd1a4c6c044016c.tar.xz
wireguard-openbsd-9747982e99e919b91cbb25f0fcd1a4c6c044016c.zip
add IMSG_CTL_SHOW_RIB_COMMUNITY, rib by given community
mostly from rivo nurges <rix@estpak.ee>, ok claudio
-rw-r--r--usr.sbin/bgpd/bgpd.h14
-rw-r--r--usr.sbin/bgpd/control.c4
-rw-r--r--usr.sbin/bgpd/rde.c34
3 files changed, 44 insertions, 8 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 2393fed0a7d..e9351078a2d 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.214 2007/03/16 14:06:57 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.215 2007/03/28 12:33:32 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -339,6 +339,7 @@ enum imsg_type {
IMSG_CTL_SHOW_RIB_AS,
IMSG_CTL_SHOW_RIB_PREFIX,
IMSG_CTL_SHOW_RIB_ATTR,
+ IMSG_CTL_SHOW_RIB_COMMUNITY,
IMSG_CTL_SHOW_NETWORK,
IMSG_CTL_SHOW_NETWORK6,
IMSG_CTL_SHOW_RIB_MEM,
@@ -533,10 +534,16 @@ struct filter_as {
u_int16_t as;
};
+struct filter_community {
+ int as;
+ int type;
+};
+
struct ctl_show_rib_request {
struct ctl_neighbor neighbor;
struct bgpd_addr prefix;
struct filter_as as;
+ struct filter_community community;
u_int32_t peerid;
pid_t pid;
u_int16_t flags;
@@ -602,11 +609,6 @@ struct filter_prefixlen {
u_int8_t len_max;
};
-struct filter_community {
- int as;
- int type;
-};
-
struct filter_match {
struct filter_prefix prefix;
struct filter_prefixlen prefixlen;
diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c
index e546402cfb6..e8a515f2dfc 100644
--- a/usr.sbin/bgpd/control.c
+++ b/usr.sbin/bgpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.54 2007/03/19 10:03:25 henning Exp $ */
+/* $OpenBSD: control.c,v 1.55 2007/03/28 12:33:32 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -232,6 +232,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt)
case IMSG_CTL_SHOW_RIB_AS:
case IMSG_CTL_SHOW_RIB_PREFIX:
case IMSG_CTL_SHOW_RIB_MEM:
+ case IMSG_CTL_SHOW_RIB_COMMUNITY:
case IMSG_CTL_SHOW_NETWORK:
case IMSG_CTL_SHOW_TERSE:
break;
@@ -373,6 +374,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt)
"wrong length");
break;
case IMSG_CTL_SHOW_RIB_MEM:
+ case IMSG_CTL_SHOW_RIB_COMMUNITY:
case IMSG_CTL_SHOW_NETWORK:
c->ibuf.pid = imsg.hdr.pid;
imsg_compose_rde(imsg.hdr.type, imsg.hdr.pid,
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 783a6c25012..f0834cfd10e 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.222 2007/03/16 14:06:57 claudio Exp $ */
+/* $OpenBSD: rde.c,v 1.223 2007/03/28 12:33:32 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -70,6 +70,7 @@ void rde_dump_upcall(struct pt_entry *, void *);
void rde_dump_as(struct ctl_show_rib_request *);
void rde_dump_prefix_upcall(struct pt_entry *, void *);
void rde_dump_prefix(struct ctl_show_rib_request *);
+void rde_dump_community(struct ctl_show_rib_request *);
void rde_dump_ctx_new(struct ctl_show_rib_request *, pid_t,
enum imsg_type);
void rde_dump_runner(void);
@@ -497,6 +498,17 @@ badnet:
imsg_compose(ibuf_se_ctl, IMSG_CTL_END, 0, req.pid, -1,
NULL, 0);
break;
+ case IMSG_CTL_SHOW_RIB_COMMUNITY:
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(req)) {
+ log_warnx("rde_dispatch: wrong imsg len");
+ break;
+ }
+ memcpy(&req, imsg.data, sizeof(req));
+ req.pid = imsg.hdr.pid;
+ rde_dump_community(&req);
+ imsg_compose(ibuf_se_ctl, IMSG_CTL_END, 0, req.pid, -1,
+ NULL, 0);
+ break;
case IMSG_CTL_SHOW_NEIGHBOR:
if (imsg.hdr.len - IMSG_HEADER_SIZE !=
sizeof(struct peer)) {
@@ -1743,6 +1755,26 @@ rde_dump_prefix(struct ctl_show_rib_request *req)
}
void
+rde_dump_community(struct ctl_show_rib_request *req)
+{
+ extern struct path_table pathtable;
+ struct rde_aspath *asp;
+ struct prefix *p;
+ u_int32_t i;
+
+ for (i = 0; i <= pathtable.path_hashmask; i++) {
+ LIST_FOREACH(asp, &pathtable.path_hashtbl[i], path_l) {
+ if (!rde_filter_community(asp, req->community.as,
+ req->community.type))
+ continue;
+ /* match found */
+ LIST_FOREACH(p, &asp->prefix_h, path_l)
+ rde_dump_filter(p, req);
+ }
+ }
+}
+
+void
rde_dump_ctx_new(struct ctl_show_rib_request *req, pid_t pid,
enum imsg_type type)
{