diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-11-23 13:07:02 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-11-23 13:07:02 +0000 |
commit | 3ecbd19bc3b00d71c40c04d62543e55cbef5df7e (patch) | |
tree | c4553ea4ef5dde0286f17884869a17d09fbf697a /usr.sbin/bgpd/session.c | |
parent | 9daf609d794b2746f640fc119c62a2d55b43344f (diff) |
Switch from a single filter_set to a linked list of sets. With this change
it is possible to specify multiple communities. This is also the first step
to better bgpd filters. OK henning@
Diffstat (limited to 'usr.sbin/bgpd/session.c')
-rw-r--r-- | usr.sbin/bgpd/session.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 0035524c91d..80a6ad2ba67 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.207 2004/11/18 17:17:56 henning Exp $ */ +/* $OpenBSD: session.c,v 1.208 2004/11/23 13:07:01 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2040,6 +2040,8 @@ parse_capabilities(struct peer *peer, u_char *d, u_int16_t dlen) return (0); } +struct filter_set_head *session_set; + void session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt) { @@ -2050,6 +2052,7 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt) struct peer *p, *next; struct listen_addr *la, *nla; struct kif *kif; + struct filter_set *s; u_char *data; enum reconf_action reconf; int n, depend_ok; @@ -2101,6 +2104,8 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt) reconf = RECONF_KEEP; memcpy(&p->conf, pconf, sizeof(struct peer_config)); + SIMPLEQ_INIT(&p->conf.attrset); + session_set = &p->conf.attrset; p->conf.reconf_action = reconf; break; case IMSG_RECONF_LISTENER: @@ -2189,9 +2194,22 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt) free(nconf->listen_addrs); free(nconf); nconf = NULL; + session_set = NULL; pending_reconf = 0; log_info("SE reconfigured"); break; + case IMSG_FILTER_SET: + if (idx != PFD_PIPE_MAIN) + fatalx("reconf request not from parent"); + if (session_set == NULL) { + log_warnx("IMSG_FILTER_SET unexpected"); + break; + } + if ((s = malloc(sizeof(struct filter_set))) == NULL) + fatal(NULL); + memcpy(s, imsg.data, sizeof(struct filter_set)); + SIMPLEQ_INSERT_TAIL(session_set, s, entry); + break; case IMSG_IFINFO: if (idx != PFD_PIPE_MAIN) fatalx("IFINFO message not from parent"); @@ -2499,9 +2517,18 @@ session_down(struct peer *peer) void session_up(struct peer *p) { - struct session_up sup; + struct session_up sup; + struct filter_set *s; - sup.remote_bgpid = p->remote_bgpid; + if (imsg_compose(ibuf_rde, IMSG_SESSION_ADD, p->conf.id, 0, -1, + &p->conf, sizeof(p->conf)) == -1) + fatalx("imsg_compose error"); + + SIMPLEQ_FOREACH(s, &p->conf.attrset, entry) { + if (imsg_compose(ibuf_rde, IMSG_FILTER_SET, p->conf.id, 0, -1, + s, sizeof(struct filter_set)) == -1) + fatalx("imsg_compose error"); + } switch (p->sa_local.ss_family) { case AF_INET: @@ -2528,7 +2555,7 @@ session_up(struct peer *p) fatalx("session_up: unsupported address family"); } - memcpy(&sup.conf, &p->conf, sizeof(sup.conf)); + sup.remote_bgpid = p->remote_bgpid; memcpy(&sup.capa_announced, &p->capa.ann, sizeof(sup.capa_announced)); memcpy(&sup.capa_received, &p->capa.peer, sizeof(sup.capa_received)); p->stats.last_updown = time(NULL); |