diff options
| author | David Lamparter <equinox@diac24.net> | 2010-02-05 04:31:56 +0100 |
|---|---|---|
| committer | David Lamparter <equinox@opensourcerouting.org> | 2017-08-28 05:07:51 +0200 |
| commit | a830942228110cbec0e857d0877d624206627f81 (patch) | |
| tree | 6823772eab9415dadaeb0722cd8c1114197fa8a1 /zebra/kernel_socket.c | |
| parent | fd36be7e15ee49d12500a5ec4d9597d1597715a7 (diff) | |
zebra: cleanup blackhole support
blackhole support was horribly broken. cleanup by removing blackhole
stuff from ZEBRA_FLAG_*
introduces support for "prohibit" routes (Linux/netlink only)
also clean up blackhole options on "ip route" vty commands.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra/kernel_socket.c')
| -rw-r--r-- | zebra/kernel_socket.c | 47 |
1 files changed, 29 insertions, 18 deletions
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index ee21e61fe7..7802a9d207 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -887,11 +887,15 @@ void rtm_read(struct rt_msghdr *rtm) if (flags & RTF_STATIC) SET_FLAG(zebra_flags, ZEBRA_FLAG_STATIC); + memset(&nh, 0, sizeof(nh)); /* This is a reject or blackhole route */ - if (flags & RTF_REJECT) - SET_FLAG(zebra_flags, ZEBRA_FLAG_REJECT); - if (flags & RTF_BLACKHOLE) - SET_FLAG(zebra_flags, ZEBRA_FLAG_BLACKHOLE); + if (flags & RTF_REJECT) { + nh.type = NEXTHOP_TYPE_BLACKHOLE; + nh.bh_type = BLACKHOLE_REJECT; + } else if (flags & RTF_BLACKHOLE) { + nh.type = NEXTHOP_TYPE_BLACKHOLE; + nh.bh_type = BLACKHOLE_NULL; + } if (dest.sa.sa_family == AF_INET) { struct prefix p; @@ -1017,11 +1021,12 @@ void rtm_read(struct rt_msghdr *rtm) if (rtm->rtm_type == RTM_CHANGE) rib_delete(AFI_IP, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, - NULL, 0, 0); + NULL, NULL, 0, 0); - memset(&nh, 0, sizeof(nh)); - nh.type = NEXTHOP_TYPE_IPV4; - nh.gate.ipv4 = gate.sin; + if (!nh.type) { + nh.type = NEXTHOP_TYPE_IPV4; + nh.gate.ipv4 = gate.sin.sin_addr; + } if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD || rtm->rtm_type == RTM_CHANGE) @@ -1064,11 +1069,12 @@ void rtm_read(struct rt_msghdr *rtm) ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL, NULL, 0, 0); - memset(&nh, 0, sizeof(nh)); - nh.type = ifindex ? NEXTHOP_TYPE_IPV6_IFINDEX - : NEXTHOP_TYPE_IPV6; - nh.gate.ipv6 = gate.sin6; - nh.ifindex = ifindex; + if (!nh.type) { + nh.type = ifindex ? NEXTHOP_TYPE_IPV6_IFINDEX + : NEXTHOP_TYPE_IPV6; + nh.gate.ipv6 = gate.sin6.sin6_addr; + nh.ifindex = ifindex; + } if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD || rtm->rtm_type == RTM_CHANGE) @@ -1088,7 +1094,7 @@ void rtm_read(struct rt_msghdr *rtm) */ int rtm_write(int message, union sockunion *dest, union sockunion *mask, union sockunion *gate, union sockunion *mpls, unsigned int index, - int zebra_flags, int metric) + enum blackhole_type bh_type, int metric) { int ret; caddr_t pnt; @@ -1178,11 +1184,16 @@ int rtm_write(int message, union sockunion *dest, union sockunion *mask, /* Tagging route with flags */ msg.rtm.rtm_flags |= (RTF_PROTO1); - /* Additional flags. */ - if (zebra_flags & ZEBRA_FLAG_BLACKHOLE) - msg.rtm.rtm_flags |= RTF_BLACKHOLE; - if (zebra_flags & ZEBRA_FLAG_REJECT) + switch (bh_type) { + case BLACKHOLE_UNSPEC: + break; + case BLACKHOLE_REJECT: msg.rtm.rtm_flags |= RTF_REJECT; + break; + default: + msg.rtm.rtm_flags |= RTF_BLACKHOLE; + break; + } #define SOCKADDRSET(X, R) \ |
