summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-25 02:04:47 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-25 02:04:47 +0000
commitaff4e946780ebe3758791b22e15c5cb3dd94d38d (patch)
tree94d523343ab3049bbf5d7b1ebba688a162177dce /usr.sbin
parent3edad2d30cdeb50ca9e1ebc106b28de1d0833ed1 (diff)
kroute_change is obsolete, long live kroute_add
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.c50
3 files changed, 18 insertions, 39 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c
index 31d60e0bac3..36787a3334b 100644
--- a/usr.sbin/bgpd/bgpd.c
+++ b/usr.sbin/bgpd/bgpd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.c,v 1.25 2003/12/24 20:09:56 henning Exp $ */
+/* $OpenBSD: bgpd.c,v 1.26 2003/12/25 02:04:46 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -344,7 +344,7 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_config *conf)
case IMSG_KROUTE_CHANGE:
if (idx != PFD_PIPE_ROUTE)
fatal("route request not from RDE", 0);
- if (kroute_change(rfd, imsg.data))
+ if (kroute_add(rfd, imsg.data))
fatal("kroute_change error", errno);
case IMSG_KROUTE_DELETE:
if (idx != PFD_PIPE_ROUTE)
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index 00db245eaa8..a8cf5707af3 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.20 2003/12/24 23:14:23 henning Exp $ */
+/* $OpenBSD: bgpd.h,v 1.21 2003/12/25 02:04:46 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -299,7 +299,6 @@ int mrt_mergeconfig(struct mrt_config *, struct mrt_config *);
/* kroute.c */
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);
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index 015b1b7b29d..c0026545abd 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.12 2003/12/25 01:59:34 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.13 2003/12/25 02:04:46 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -144,49 +144,29 @@ kroute_add(int fd, struct kroute *kroute)
return (0);
}
- if ((n = kroute_msg(fd, RTM_ADD, kroute)) == -1)
+ if ((n = kroute_msg(fd, action, kroute)) == -1)
return (-1);
- if ((kr = calloc(1, sizeof(struct kroute_node))) == NULL)
- fatal(NULL, errno);
+ if (action == RTM_ADD) {
+ if ((kr = calloc(1, sizeof(struct kroute_node))) == NULL)
+ fatal(NULL, errno);
- kr->r.prefix = kroute->prefix;
- kr->r.prefixlen = kroute->prefixlen;
- kr->r.nexthop = kroute->nexthop;
- kr->flags = F_BGPD_INSERTED;
+ kr->r.prefix = kroute->prefix;
+ kr->r.prefixlen = kroute->prefixlen;
+ kr->r.nexthop = kroute->nexthop;
+ kr->flags = F_BGPD_INSERTED;
- if (RB_INSERT(kroute_tree, &krt, kr) != NULL) {
- logit(LOG_CRIT, "RB_INSERT failed!");
- return (-1);
- }
+ if (RB_INSERT(kroute_tree, &krt, kr) != NULL) {
+ logit(LOG_CRIT, "RB_INSERT failed!");
+ return (-1);
+ }
+ } else
+ kr->r.nexthop = kroute->nexthop;
return (n);
}
int
-kroute_change(int fd, struct kroute *kroute)
-{
- struct kroute_node *kr, s;
-
- s.r.prefix = kroute->prefix;
- s.r.prefixlen = kroute->prefixlen;
-
- if ((kr = RB_FIND(kroute_tree, &krt, &s)) == NULL) {
- log_kroute(LOG_CRIT, "kroute_change: no match for", kroute);
- return (-1);
- }
-
- if (!(kr->flags & F_BGPD_INSERTED)) {
- logit(LOG_CRIT, "trying to change route not inserted by bgpd");
- return (0);
- }
-
- kr->r.nexthop = kroute->nexthop;
-
- return (kroute_msg(fd, RTM_CHANGE, kroute));
-}
-
-int
kroute_delete(int fd, struct kroute *kroute)
{
struct kroute_node *kr, s;