summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorSebastian Benoit <benno@cvs.openbsd.org>2014-01-23 23:26:57 +0000
committerSebastian Benoit <benno@cvs.openbsd.org>2014-01-23 23:26:57 +0000
commit203ed5446f60ae8e592c4fbd37a555be0a647b8a (patch)
tree8fa052796160cfc47115adcc76ce93f16836f919 /usr.sbin
parent458add76b954d0f4fc1001bcc1e569c32c24982d (diff)
allow the somewhat special case
match ... set nexthop ( 127.0.0.1 | ::1 ) match ... set nexthop blackhole to make a route valid before setting the blackhole flag on it. ok florian, claudio
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/kroute.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c
index 68baffd074d..5847f431ea8 100644
--- a/usr.sbin/bgpd/kroute.c
+++ b/usr.sbin/bgpd/kroute.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kroute.c,v 1.196 2013/11/13 09:14:48 florian Exp $ */
+/* $OpenBSD: kroute.c,v 1.197 2014/01/23 23:26:56 benno Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -487,17 +487,16 @@ kr4_change(struct ktable *kt, struct kroute_full *kl, u_int8_t fib_prio)
fib_prio)) != NULL)
action = RTM_CHANGE;
+ /* for blackhole and reject routes nexthop needs to be 127.0.0.1 */
+ if (kl->flags & (F_BLACKHOLE|F_REJECT))
+ kl->nexthop.v4.s_addr = htonl(INADDR_LOOPBACK);
/* nexthop within 127/8 -> ignore silently */
- if ((kl->nexthop.v4.s_addr & htonl(IN_CLASSA_NET)) ==
+ else if ((kl->nexthop.v4.s_addr & htonl(IN_CLASSA_NET)) ==
htonl(INADDR_LOOPBACK & IN_CLASSA_NET))
return (0);
labelid = rtlabel_name2id(kl->label);
- /* for blackhole and reject routes nexthop needs to be 127.0.0.1 */
- if (kl->flags & (F_BLACKHOLE|F_REJECT))
- kl->nexthop.v4.s_addr = htonl(INADDR_LOOPBACK);
-
if (action == RTM_ADD) {
if ((kr = calloc(1, sizeof(struct kroute_node))) == NULL) {
log_warn("kr_change");
@@ -546,16 +545,15 @@ kr6_change(struct ktable *kt, struct kroute_full *kl, u_int8_t fib_prio)
NULL)
action = RTM_CHANGE;
+ /* for blackhole and reject routes nexthop needs to be ::1 */
+ if (kl->flags & (F_BLACKHOLE|F_REJECT))
+ bcopy(&lo6, &kl->nexthop.v6, sizeof(kl->nexthop.v6));
/* nexthop to loopback -> ignore silently */
- if (IN6_IS_ADDR_LOOPBACK(&kl->nexthop.v6))
+ else if (IN6_IS_ADDR_LOOPBACK(&kl->nexthop.v6))
return (0);
labelid = rtlabel_name2id(kl->label);
- /* for blackhole and reject routes nexthop needs to be ::1 */
- if (kl->flags & (F_BLACKHOLE|F_REJECT))
- bcopy(&lo6, &kl->nexthop.v6, sizeof(kl->nexthop.v6));
-
if (action == RTM_ADD) {
if ((kr6 = calloc(1, sizeof(struct kroute6_node))) == NULL) {
log_warn("kr_change");