diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-27 01:30:01 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2003-12-27 01:30:01 +0000 |
commit | 3c9445f6671a8183e4518dd7a8594d6be2886c72 (patch) | |
tree | 0c7a3bf1045313291013af90275bbdb4eb415ad9 /usr.sbin/bgpd | |
parent | eca79f2ae4a115fa1d76a6126888dffea99102ef (diff) |
provide kroute_fib_couple and _decouple, pumping all bgp routes from the
internal view to the kernel routing table respectively removing them all from
the kernel routing table
kroute_shutdown is now a simple wrapper to kroute_fib_decouple
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 24 |
2 files changed, 25 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index fe69ea7b552..56ee2801280 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.41 2003/12/27 00:53:51 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.42 2003/12/27 01:30:00 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -319,6 +319,8 @@ int kroute_init(int); int kroute_change(int, struct kroute *); int kroute_delete(int, struct kroute *); void kroute_shutdown(int); +void kroute_fib_couple(int); +void kroute_fib_decouple(int); int kroute_dispatch_msg(int); int kroute_nexthop_add(in_addr_t); void kroute_nexthop_delete(in_addr_t); diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 1ddb6b70569..cb082180d43 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.38 2003/12/27 00:53:51 henning Exp $ */ +/* $OpenBSD: kroute.c,v 1.39 2003/12/27 01:30:00 henning Exp $ */ /* * Copyright (c) 2003 Henning Brauer <henning@openbsd.org> @@ -141,7 +141,7 @@ kroute_msg(int fd, int action, struct kroute *kroute) } r; ssize_t n; - if (!fib_sync) + if (fib_sync == 0) return (0); bzero(&r, sizeof(r)); @@ -305,11 +305,31 @@ kroute_compare(struct kroute_node *a, struct kroute_node *b) void kroute_shutdown(int fd) { + kroute_fib_decouple(fd); +} + +void +kroute_fib_couple(int fd) +{ + struct kroute_node *kr; + + fib_sync = 1; + + RB_FOREACH(kr, kroute_tree, &krt) + if ((kr->flags & F_BGPD_INSERTED)) + kroute_msg(fd, RTM_ADD, &kr->r); +} + +void +kroute_fib_decouple(int fd) +{ struct kroute_node *kr; RB_FOREACH(kr, kroute_tree, &krt) if ((kr->flags & F_BGPD_INSERTED)) kroute_msg(fd, RTM_DELETE, &kr->r); + + fib_sync = 0; } #define ROUNDUP(a, size) \ |