summaryrefslogtreecommitdiff
path: root/zebra/kernel_socket.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2017-08-28 01:30:16 +0200
committerDavid Lamparter <equinox@opensourcerouting.org>2017-08-28 04:17:22 +0200
commitfd36be7e15ee49d12500a5ec4d9597d1597715a7 (patch)
tree21a2571090c15a04096f575da00f38629f5dafda /zebra/kernel_socket.c
parent09a484dd1d27580d98c4b94d3ed77e47d7aac0b5 (diff)
zebra: rib: use nexthop ptr in rib_add/delete
This simplifies the API for the following blackhole rework. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'zebra/kernel_socket.c')
-rw-r--r--zebra/kernel_socket.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c
index e2a1deb9ac..ee21e61fe7 100644
--- a/zebra/kernel_socket.c
+++ b/zebra/kernel_socket.c
@@ -849,6 +849,7 @@ void rtm_read(struct rt_msghdr *rtm)
union sockunion dest, mask, gate;
char ifname[INTERFACE_NAMSIZ + 1];
short ifnlen = 0;
+ struct nexthop nh;
zebra_flags = 0;
@@ -1015,19 +1016,22 @@ 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,
- NULL, 0, 0, 0);
+ ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p,
+ NULL, 0, 0);
+
+ memset(&nh, 0, sizeof(nh));
+ nh.type = NEXTHOP_TYPE_IPV4;
+ nh.gate.ipv4 = gate.sin;
- union g_addr ggate = {.ipv4 = gate.sin.sin_addr};
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
rib_add(AFI_IP, SAFI_UNICAST, VRF_DEFAULT,
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
- &ggate, NULL, 0, 0, 0, 0, 0);
+ &nh, 0, 0, 0, 0);
else
rib_delete(AFI_IP, SAFI_UNICAST, VRF_DEFAULT,
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
- &ggate, 0, 0, 0);
+ &nh, 0, 0);
}
if (dest.sa.sa_family == AF_INET6) {
/* One day we might have a debug section here like one in the
@@ -1057,19 +1061,24 @@ void rtm_read(struct rt_msghdr *rtm)
*/
if (rtm->rtm_type == RTM_CHANGE)
rib_delete(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT,
- ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
- NULL, 0, 0, 0);
+ 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;
- union g_addr ggate = {.ipv6 = gate.sin6.sin6_addr};
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|| rtm->rtm_type == RTM_CHANGE)
rib_add(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT,
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
- &ggate, NULL, ifindex, 0, 0, 0, 0);
+ &nh, 0, 0, 0, 0);
else
rib_delete(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT,
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
- &ggate, ifindex, 0, 0);
+ &nh, 0, 0);
}
}