From: renato Date: Tue, 27 Oct 2015 03:27:35 +0000 (+0000) Subject: Whenever a summary route is activated, install a respective blackhole X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7c245af932a5734a75ff3efefefdfd8adcc66769;p=openbsd Whenever a summary route is activated, install a respective blackhole route in the FIB. --- diff --git a/usr.sbin/eigrpd/kroute.c b/usr.sbin/eigrpd/kroute.c index 2de5ad567d0..7b83c96257c 100644 --- a/usr.sbin/eigrpd/kroute.c +++ b/usr.sbin/eigrpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.5 2015/10/25 00:43:35 renato Exp $ */ +/* $OpenBSD: kroute.c,v 1.6 2015/10/27 03:27:35 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -1107,6 +1107,8 @@ send_rtmsg_v4(int fd, int action, struct kroute *kr) hdr.rtm_fmask = RTF_REJECT|RTF_BLACKHOLE; else hdr.rtm_flags = RTF_MPATH; + if (kr->flags & F_BLACKHOLE) + hdr.rtm_flags |= RTF_BLACKHOLE; hdr.rtm_seq = kr_state.rtseq++; /* overflow doesn't matter */ hdr.rtm_msglen = sizeof(hdr); /* adjust iovec */ diff --git a/usr.sbin/eigrpd/rde.c b/usr.sbin/eigrpd/rde.c index c9dbdd97822..441d2d8ad01 100644 --- a/usr.sbin/eigrpd/rde.c +++ b/usr.sbin/eigrpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.6 2015/10/21 03:52:12 renato Exp $ */ +/* $OpenBSD: rde.c,v 1.7 2015/10/27 03:27:35 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -501,11 +501,30 @@ rde_send_change_kroute(struct rt_node *rn, struct eigrp_route *route) memcpy(&kr.nexthop, &route->nexthop, sizeof(kr.nexthop)); else memcpy(&kr.nexthop, &route->nbr->addr, sizeof(kr.nexthop)); - kr.ifindex = route->nbr->ei->iface->ifindex; + if (route->nbr->ei) + kr.ifindex = route->nbr->ei->iface->ifindex; + else { + switch (eigrp->af) { + case AF_INET: + inet_pton(AF_INET, "127.0.0.1", &kr.nexthop.v4); + break; + case AF_INET6: + inet_pton(AF_INET, "::1", &kr.nexthop.v6); + break; + default: + fatalx("rde_send_delete_kroute: unknown af"); + break; + } + kr.flags = F_BLACKHOLE; + } if (route->type == EIGRP_ROUTE_EXTERNAL) kr.priority = rdeconf->fib_priority_external; - else - kr.priority = rdeconf->fib_priority_internal; + else { + if (route->nbr->flags & F_RDE_NBR_SUMMARY) + kr.priority = rdeconf->fib_priority_summary; + else + kr.priority = rdeconf->fib_priority_internal; + } rde_imsg_compose_parent(IMSG_KROUTE_CHANGE, 0, &kr, sizeof(kr)); @@ -529,11 +548,30 @@ rde_send_delete_kroute(struct rt_node *rn, struct eigrp_route *route) memcpy(&kr.nexthop, &route->nexthop, sizeof(kr.nexthop)); else memcpy(&kr.nexthop, &route->nbr->addr, sizeof(kr.nexthop)); - kr.ifindex = route->nbr->ei->iface->ifindex; + if (route->nbr->ei) + kr.ifindex = route->nbr->ei->iface->ifindex; + else { + switch (eigrp->af) { + case AF_INET: + inet_pton(AF_INET, "127.0.0.1", &kr.nexthop.v4); + break; + case AF_INET6: + inet_pton(AF_INET, "::1", &kr.nexthop.v6); + break; + default: + fatalx("rde_send_delete_kroute: unknown af"); + break; + } + kr.flags = F_BLACKHOLE; + } if (route->type == EIGRP_ROUTE_EXTERNAL) kr.priority = rdeconf->fib_priority_external; - else - kr.priority = rdeconf->fib_priority_internal; + else { + if (route->nbr->flags & F_RDE_NBR_SUMMARY) + kr.priority = rdeconf->fib_priority_summary; + else + kr.priority = rdeconf->fib_priority_internal; + } rde_imsg_compose_parent(IMSG_KROUTE_DELETE, 0, &kr, sizeof(kr));