mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-15 16:54:30 +00:00
zebra: Make v4 and v6 code paths for rib_XXX calls in kernel_socket the same
Make the v4 and v6 code paths for rib_XXX calls in kernel_socket as similiar as we can possibly make them. There is no need for code duplication at this point in time. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
c626d369fd
commit
026745a258
@ -918,6 +918,9 @@ void rtm_read(struct rt_msghdr *rtm)
|
|||||||
char ifname[INTERFACE_NAMSIZ + 1];
|
char ifname[INTERFACE_NAMSIZ + 1];
|
||||||
short ifnlen = 0;
|
short ifnlen = 0;
|
||||||
struct nexthop nh;
|
struct nexthop nh;
|
||||||
|
struct prefix p;
|
||||||
|
ifindex_t ifindex = 0;
|
||||||
|
afi_t afi;
|
||||||
|
|
||||||
zebra_flags = 0;
|
zebra_flags = 0;
|
||||||
|
|
||||||
@ -974,8 +977,7 @@ void rtm_read(struct rt_msghdr *rtm)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (dest.sa.sa_family == AF_INET) {
|
if (dest.sa.sa_family == AF_INET) {
|
||||||
struct prefix p;
|
afi = AFI_IP;
|
||||||
|
|
||||||
p.family = AF_INET;
|
p.family = AF_INET;
|
||||||
p.u.prefix4 = dest.sin.sin_addr;
|
p.u.prefix4 = dest.sin.sin_addr;
|
||||||
if (flags & RTF_HOST)
|
if (flags & RTF_HOST)
|
||||||
@ -983,33 +985,12 @@ void rtm_read(struct rt_msghdr *rtm)
|
|||||||
else
|
else
|
||||||
p.prefixlen = ip_masklen(mask.sin.sin_addr);
|
p.prefixlen = ip_masklen(mask.sin.sin_addr);
|
||||||
|
|
||||||
/* Change, delete the old prefix, we have no further information
|
|
||||||
* to specify the route really
|
|
||||||
*/
|
|
||||||
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, true);
|
|
||||||
|
|
||||||
if (!nh.type) {
|
if (!nh.type) {
|
||||||
nh.type = NEXTHOP_TYPE_IPV4;
|
nh.type = NEXTHOP_TYPE_IPV4;
|
||||||
nh.gate.ipv4 = gate.sin.sin_addr;
|
nh.gate.ipv4 = gate.sin.sin_addr;
|
||||||
}
|
}
|
||||||
|
} else if (dest.sa.sa_family == AF_INET6) {
|
||||||
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|
afi = AFI_IP6;
|
||||||
|| rtm->rtm_type == RTM_CHANGE)
|
|
||||||
rib_add(AFI_IP, SAFI_UNICAST, VRF_DEFAULT,
|
|
||||||
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
|
|
||||||
&nh, 0, 0, 0, 0, 0);
|
|
||||||
else
|
|
||||||
rib_delete(AFI_IP, SAFI_UNICAST, VRF_DEFAULT,
|
|
||||||
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
|
|
||||||
&nh, 0, 0, 0, true);
|
|
||||||
}
|
|
||||||
if (dest.sa.sa_family == AF_INET6) {
|
|
||||||
struct prefix p;
|
|
||||||
ifindex_t ifindex = 0;
|
|
||||||
|
|
||||||
p.family = AF_INET6;
|
p.family = AF_INET6;
|
||||||
p.u.prefix6 = dest.sin6.sin6_addr;
|
p.u.prefix6 = dest.sin6.sin6_addr;
|
||||||
if (flags & RTF_HOST)
|
if (flags & RTF_HOST)
|
||||||
@ -1024,31 +1005,29 @@ void rtm_read(struct rt_msghdr *rtm)
|
|||||||
}
|
}
|
||||||
#endif /* KAME */
|
#endif /* KAME */
|
||||||
|
|
||||||
/* CHANGE: delete the old prefix, we have no further information
|
|
||||||
* to specify the route really
|
|
||||||
*/
|
|
||||||
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, true);
|
|
||||||
|
|
||||||
if (!nh.type) {
|
if (!nh.type) {
|
||||||
nh.type = ifindex ? NEXTHOP_TYPE_IPV6_IFINDEX
|
nh.type = ifindex ? NEXTHOP_TYPE_IPV6_IFINDEX
|
||||||
: NEXTHOP_TYPE_IPV6;
|
: NEXTHOP_TYPE_IPV6;
|
||||||
nh.gate.ipv6 = gate.sin6.sin6_addr;
|
nh.gate.ipv6 = gate.sin6.sin6_addr;
|
||||||
nh.ifindex = ifindex;
|
nh.ifindex = ifindex;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
return;
|
||||||
|
|
||||||
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|
/*
|
||||||
|| rtm->rtm_type == RTM_CHANGE)
|
* CHANGE: delete the old prefix, we have no further information
|
||||||
rib_add(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT,
|
* to specify the route really
|
||||||
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
|
*/
|
||||||
&nh, 0, 0, 0, 0, 0);
|
if (rtm->rtm_type == RTM_CHANGE)
|
||||||
else
|
rib_delete(afi, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL,
|
||||||
rib_delete(AFI_IP6, SAFI_UNICAST, VRF_DEFAULT,
|
0, zebra_flags, &p, NULL, NULL, 0, 0, 0, true);
|
||||||
ZEBRA_ROUTE_KERNEL, 0, zebra_flags, &p, NULL,
|
if (rtm->rtm_type == RTM_GET || rtm->rtm_type == RTM_ADD
|
||||||
&nh, 0, 0, 0, true);
|
|| rtm->rtm_type == RTM_CHANGE)
|
||||||
}
|
rib_add(afi, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL, 0,
|
||||||
|
zebra_flags, &p, NULL, &nh, 0, 0, 0, 0, 0);
|
||||||
|
else
|
||||||
|
rib_delete(afi, SAFI_UNICAST, VRF_DEFAULT, ZEBRA_ROUTE_KERNEL,
|
||||||
|
0, zebra_flags, &p, NULL, &nh, 0, 0, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Interface function for the kernel routing table updates. Support
|
/* Interface function for the kernel routing table updates. Support
|
||||||
|
Loading…
Reference in New Issue
Block a user