diff options
author | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-08-24 07:39:08 +0200 |
---|---|---|
committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2016-09-01 13:20:18 +0200 |
commit | 616368ed1ea8165beb2b1ba137b474ee794046d5 (patch) | |
tree | ed1720a8267e00bee3bec9f093047b8e55e8300b /zebra/rt_netlink.c | |
parent | zebra: Refactor rib_match_ipv[4|6] (diff) | |
download | frr-616368ed1ea8165beb2b1ba137b474ee794046d5.tar.xz frr-616368ed1ea8165beb2b1ba137b474ee794046d5.zip |
zebra: Refactor rib_delete_ipv[4|6]
These two functions are essentially the same.
Refactor.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/rt_netlink.c')
-rw-r--r-- | zebra/rt_netlink.c | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index 49dcd1e6d..dc3aa2f6b 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -1059,7 +1059,8 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h, struct rtmsg *rtm; struct rtattr *tb[RTA_MAX + 1]; u_char zebra_flags = 0; - + struct prefix p; + char anyaddr[16] = { 0 }; int index; @@ -1177,9 +1178,8 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h, if (rtm->rtm_family == AF_INET) { - struct prefix_ipv4 p; p.family = AF_INET; - memcpy (&p.prefix, dest, 4); + memcpy (&p.u.prefix4, dest, 4); p.prefixlen = rtm->rtm_dst_len; if (IS_ZEBRA_DEBUG_KERNEL) @@ -1193,7 +1193,7 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h, if (h->nlmsg_type == RTM_NEWROUTE) { if (!tb[RTA_MULTIPATH]) - rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, 0, &p, gate, src, index, vrf_id, + rib_add_ipv4 (ZEBRA_ROUTE_KERNEL, 0, 0, (struct prefix_ipv4 *)&p, gate, src, index, vrf_id, table, metric, mtu, 0, SAFI_UNICAST); else { @@ -1252,21 +1252,20 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h, if (rib->nexthop_num == 0) XFREE (MTYPE_RIB, rib); else - rib_add_ipv4_multipath (&p, rib, SAFI_UNICAST); + rib_add_ipv4_multipath ((struct prefix_ipv4 *)&p, rib, SAFI_UNICAST); } } else - rib_delete_ipv4 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, gate, index, - vrf_id, table, SAFI_UNICAST); + rib_delete (AFI_IP, SAFI_UNICAST, vrf_id, ZEBRA_ROUTE_KERNEL, 0, zebra_flags, + &p, gate, index, table); } -#ifdef HAVE_IPV6 if (rtm->rtm_family == AF_INET6) { - struct prefix_ipv6 p; + struct prefix p; p.family = AF_INET6; - memcpy (&p.prefix, dest, 16); + memcpy (&p.u.prefix6, dest, 16); p.prefixlen = rtm->rtm_dst_len; if (IS_ZEBRA_DEBUG_KERNEL) @@ -1278,13 +1277,12 @@ netlink_route_change (struct sockaddr_nl *snl, struct nlmsghdr *h, } if (h->nlmsg_type == RTM_NEWROUTE) - rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, 0, 0, &p, gate, index, vrf_id, + rib_add_ipv6 (ZEBRA_ROUTE_KERNEL, 0, 0, (struct prefix_ipv6 *)&p, gate, index, vrf_id, table, metric, mtu, 0, SAFI_UNICAST); else - rib_delete_ipv6 (ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, gate, index, - vrf_id, table, SAFI_UNICAST); + rib_delete (AFI_IP6, SAFI_UNICAST, vrf_id, ZEBRA_ROUTE_KERNEL, + 0, zebra_flags, &p, gate, index, table); } -#endif /* HAVE_IPV6 */ return 0; } |