diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-26 00:49:53 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-26 00:49:53 +0000 |
commit | 34b37d0c127d40c365586594160294844ca98074 (patch) | |
tree | 1fddc58bcfaa0b0857ebe243e51eec342e5bd819 /usr.sbin/bgpd | |
parent | a7d6f4d5ddac2334d4168baac2d984912c7a6552 (diff) |
handle IMSG_NEXTHOP_DELETE as well
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 28 |
3 files changed, 31 insertions, 5 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 68ecfcc7eed..5dae0140f7c 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.31 2003/12/26 00:27:23 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.32 2003/12/26 00:49:52 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -366,8 +366,7 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_config *conf) if (idx != PFD_PIPE_ROUTE) fatal("nexthop request not from RDE", 0); memcpy(&ina, imsg.data, sizeof(ina)); - /* XXX */ - /* kroute_nexthop_delete(ina); */ + kroute_nexthop_delete(ina); break; default: break; diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index 7343bd41e24..b878cf9f433 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.30 2003/12/26 00:27:23 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.31 2003/12/26 00:49:52 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -317,5 +317,6 @@ int kroute_delete(int, struct kroute *); void kroute_shutdown(int); void kroute_dispatch_msg(int); void kroute_nexthop_add(in_addr_t); +void kroute_nexthop_delete(in_addr_t); #endif /* __BGPD_H__ */ diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 92417cb6959..09472332fc8 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.26 2003/12/26 00:27:23 henning Exp $ */ +/* $OpenBSD: kroute.c,v 1.27 2003/12/26 00:49:52 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -514,10 +514,36 @@ kroute_nexthop_add(in_addr_t key) } } else kroute_nexthop_insert(key, &nh); + send_nexthop_update(&nh); } void +kroute_nexthop_delete(in_addr_t key) +{ + struct knexthop_node *a, *b, s; + + s.nexthop = key; + + if ((a = RB_FIND(knexthop_tree, &knt, &s)) == NULL) + return; + + /* + * check wether there's another nexthop depending on this kroute + * if not remove the flag + */ + + for (b = RB_MIN(knexthop_tree, &knt); b != NULL && + b->kroute != a->kroute; b = RB_NEXT(knexthop_tree, &knt, b)) + ; /* nothing */ + + if (b == NULL) + a->kroute->flags &= ~F_NEXTHOP; + + RB_REMOVE(knexthop_tree, &knt, a); +} + +void kroute_nexthop_insert(in_addr_t key, struct kroute_nexthop *nh) { struct kroute_node *kr; |