summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-24 19:59:25 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-24 19:59:25 +0000
commit773b2797d0667b7493ddae968f2d78e5b54c673d (patch)
tree1ae1c8a3de5b2be384c0dac0550cadc6dd8d3190 /usr.sbin
parent57a2ceca5c5933da9b07fcc2cc03aa5d52102f02 (diff)
now that we keep track of the routes we added to the kernel we can remove
them easily on shutdown without the RDE's help
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/bgpd.c4
-rw-r--r--usr.sbin/bgpd/bgpd.h3
-rw-r--r--usr.sbin/bgpd/kroute.c12
-rw-r--r--usr.sbin/bgpd/rde.c13
4 files changed, 17 insertions, 15 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 61278231d9b..4ee58c247e9 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.23 2003/12/24 19:22:00 henning Exp $ */
+/* $OpenBSD: bgpd.c,v 1.24 2003/12/24 19:59:24 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -282,6 +282,8 @@ main(int argc, char *argv[])
i = waitpid(-1, NULL, WNOHANG);
} while (i > 0 || (i == -1 && errno == EINTR));
+ kroute_shutdown(rfd);
+
logit(LOG_CRIT, "Terminating");
return (0);
}
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 890cba6752d..e769662c8a8 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.17 2003/12/24 19:21:20 henning Exp $ */
+/* $OpenBSD: bgpd.h,v 1.18 2003/12/24 19:59:24 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -305,5 +305,6 @@ int kroute_init(void);
int kroute_add(int, struct kroute *);
int kroute_change(int, struct kroute *);
int kroute_delete(int, struct kroute *);
+void kroute_shutdown(int);
#endif /* __BGPD_H__ */
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index 77de2cf9255..1359ff9614c 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.6 2003/12/24 19:23:26 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.7 2003/12/24 19:59:24 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -214,3 +214,13 @@ kroute_compare(struct kroute_node *a, struct kroute_node *b)
return (1);
return (0);
}
+
+void
+kroute_shutdown(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);
+}
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 0aa56bd147c..db7aa6d758a 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.25 2003/12/24 13:49:21 henning Exp $ */
+/* $OpenBSD: rde.c,v 1.26 2003/12/24 19:59:24 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -42,8 +42,6 @@ void init_attr_flags(struct attr_flags *);
int rde_update_get_attr(u_char *, u_int16_t, struct attr_flags *);
void rde_update_err(u_int32_t, enum suberr_update);
-void rde_dump_kroute(struct pt_entry *pt, void *ptr);
-
void peer_init(struct bgpd_config *, u_long);
struct rde_peer *peer_add(u_int32_t, struct peer_config *);
void peer_remove(struct rde_peer *);
@@ -255,7 +253,6 @@ rde_dispatch_imsg(struct imsgbuf *ibuf, int idx)
imsg.hdr.peerid, NULL, 0);
break;
case IMSG_SHUTDOWN_REQUEST:
- pt_dump(rde_dump_kroute, NULL);
imsg_compose(&ibuf_main, IMSG_SHUTDOWN_DONE, 0,
NULL, 0);
break;
@@ -540,14 +537,6 @@ rde_send_kroute(struct prefix *new, struct prefix *old)
imsg_compose(&ibuf_main, type, 0, &kr, sizeof(kr));
}
-void
-rde_dump_kroute(struct pt_entry *pt, void *ptr)
-{
- if (pt->active == NULL)
- return;
- rde_send_kroute(NULL, pt->active);
-}
-
/*
* peer functions
*/