summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/kroute.c
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2003-12-26 23:46:52 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2003-12-26 23:46:52 +0000
commit759d1e70322e6743d03b9f2f66fc2265c1ca4ef4 (patch)
treef0c57c80f56c30db29473a6bfe5924a9e62c6493 /usr.sbin/bgpd/kroute.c
parent4243207adc74616c4866665cc12ed39907596bf0 (diff)
detect when a newly added kernel route (non-bgp of course) matches a nexthop
that is flagged invalid yet and make it valid, notify RDE etc
Diffstat (limited to 'usr.sbin/bgpd/kroute.c')
-rw-r--r--usr.sbin/bgpd/kroute.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index 39b19cc8305..325f71be115 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.35 2003/12/26 23:22:27 henning Exp $ */
+/* $OpenBSD: kroute.c,v 1.36 2003/12/26 23:46:51 henning Exp $ */
/*
* Copyright (c) 2003 Henning Brauer <henning@openbsd.org>
@@ -227,12 +227,34 @@ kroute_change(int fd, struct kroute *kroute)
int
kroute_insert(struct kroute_node *kr)
{
+ struct knexthop_node *h;
+ struct kroute_nexthop nh;
+ in_addr_t mask, ina;
+
if (RB_INSERT(kroute_tree, &krt, kr) != NULL) {
logit(LOG_CRIT, "kroute_tree insert failed for %s/%u",
log_ntoa(kr->r.prefix), kr->r.prefixlen);
return (-1);
}
+ if (kr->flags & F_KERNEL) {
+ mask = 0xffffffff << (32 - kr->r.prefixlen);
+ ina = ntohl(kr->r.prefix);
+ RB_FOREACH(h, knexthop_tree, &knt) {
+ if ((ntohl(h->nexthop) & mask) == ina) {
+ if (h->kroute != NULL)
+ continue; /* XXX */
+ h->kroute = kr;
+ kr->flags |= F_NEXTHOP;
+ bzero(&nh, sizeof(nh));
+ nh.nexthop = h->nexthop;
+ nh.valid = 1;
+ nh.connected = kr->flags & F_CONNECTED;
+ nh.gateway = kr->r.nexthop;
+ send_nexthop_update(&nh);
+ }
+ }
+ }
return (0);
}