diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 32 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.h | 11 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_decide.c | 6 |
3 files changed, 42 insertions, 7 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 1531043177c..4580791503e 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.18 2003/12/21 23:28:39 henning Exp $ */ +/* $OpenBSD: rde.c,v 1.19 2003/12/23 15:59:02 claudio Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -506,6 +506,36 @@ rde_update_err(u_int32_t peerid, enum suberr_update errorcode) &errcode, sizeof(errcode)); } +/* + * kroute specific functions + */ +void +rde_send_kroute(struct prefix *new, struct prefix *old) +{ + struct kroute kr; + struct prefix *p; + enum imsg_type type; + + if (old == NULL && new == NULL) + return; + + if (old == NULL) { + type = IMSG_KROUTE_ADD; + p = new; + } else if (new == NULL || new->aspath->state == NEXTHOP_UNREACH) { + type = IMSG_KROUTE_DELETE; + p = old; + } else { + type = IMSG_KROUTE_CHANGE; + p = new; + } + + kr.prefix = p->prefix->prefix.s_addr; + kr.prefixlen = p->prefix->prefixlen; + kr.nexthop = p->aspath->flags.nexthop.s_addr; + + imsg_compose(&ibuf_main, type, 0, &kr, sizeof(kr)); +} /* * peer functions diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index fc9823d340f..d76de99698f 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,7 +1,7 @@ -/* $OpenBSD: rde.h,v 1.5 2003/12/21 22:16:53 henning Exp $ */ +/* $OpenBSD: rde.h,v 1.6 2003/12/23 15:59:02 claudio Exp $ */ /* - * Copyright (c) 2003 Claudio Jeker <cjeker@diehard.n-r-g.com> and + * Copyright (c) 2003 Claudio Jeker <claudio@openbsd.org> and * Andre Oppermann <oppermann@pipeline.ch> * * Permission to use, copy, modify, and distribute this software for any @@ -191,6 +191,9 @@ struct prefix { }; /* prototypes */ +/* rde.c */ +void rde_send_kroute(struct prefix *, struct prefix *); + /* rde_rib.c */ int attr_equal(struct attr_flags *, struct attr_flags *); void attr_copy(struct attr_flags *, struct attr_flags *); @@ -234,10 +237,10 @@ void nexthop_remove(struct rde_aspath *); void nexthop_invalidate(struct in_addr, int); void nexthop_validate(struct in_addr, int); -/* rde_de.c */ +/* rde_decide.c */ void prefix_evaluate(struct prefix *, struct pt_entry *); -/* rde_pt.c */ +/* rde_prefix.c */ void pt_init(void); int pt_empty(struct pt_entry *); struct pt_entry *pt_get(struct in_addr, int); diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c index 9f9d5472e8f..53b629a2126 100644 --- a/usr.sbin/bgpd/rde_decide.c +++ b/usr.sbin/bgpd/rde_decide.c @@ -1,7 +1,7 @@ -/* $OpenBSD: rde_decide.c,v 1.1 2003/12/17 11:46:54 henning Exp $ */ +/* $OpenBSD: rde_decide.c,v 1.2 2003/12/23 15:59:02 claudio Exp $ */ /* - * Copyright (c) 2003 Claudio Jeker <cjeker@diehard.n-r-g.com> + * Copyright (c) 2003 Claudio Jeker <claudio@openbsd.org> * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> * * Permission to use, copy, modify, and distribute this software for any @@ -200,6 +200,7 @@ prefix_evaluate(struct prefix *p, struct pt_entry *pte) if (pte->active != xp) { /* need to generate an update */ if (pte->active != NULL) { + ENSURE(pte->active->aspath != NULL); ENSURE(pte->active->aspath->active_cnt > 0); pte->active->aspath->active_cnt--; } @@ -208,6 +209,7 @@ prefix_evaluate(struct prefix *p, struct pt_entry *pte) * XXX send update with remove for pte->active and add for xp * but remember that xp may be ineligible or NULL. */ + rde_send_kroute(xp, pte->active); if (xp != NULL || xp->aspath->state == NEXTHOP_UNREACH) pte->active = NULL; |