Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/radix_mpath.c
Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | |||||
* check if we have the same key/mask/gateway on the table already. | * check if we have the same key/mask/gateway on the table already. | ||||
* Assume @rt rt_key host bits are cleared according to @netmask | * Assume @rt rt_key host bits are cleared according to @netmask | ||||
*/ | */ | ||||
int | int | ||||
rt_mpath_conflict(struct rib_head *rnh, struct rtentry *rt, | rt_mpath_conflict(struct rib_head *rnh, struct rtentry *rt, | ||||
struct sockaddr *netmask) | struct sockaddr *netmask) | ||||
{ | { | ||||
struct radix_node *rn, *rn1; | struct radix_node *rn, *rn1; | ||||
struct nhop_object *nh, *nh1; | |||||
struct rtentry *rt1; | struct rtentry *rt1; | ||||
rn = (struct radix_node *)rt; | rn = (struct radix_node *)rt; | ||||
rn1 = rnh->rnh_lookup(rt_key(rt), netmask, &rnh->head); | rn1 = rnh->rnh_lookup(rt_key(rt), netmask, &rnh->head); | ||||
if (!rn1 || rn1->rn_flags & RNF_ROOT) | if (!rn1 || rn1->rn_flags & RNF_ROOT) | ||||
return (0); | return (0); | ||||
/* key/mask are the same. compare gateway for all multipaths */ | /* key/mask are the same. compare gateway for all multipaths */ | ||||
do { | do { | ||||
rt1 = (struct rtentry *)rn1; | rt1 = (struct rtentry *)rn1; | ||||
/* sanity: no use in comparing the same thing */ | /* sanity: no use in comparing the same thing */ | ||||
if (rn1 == rn) | if (rn1 == rn) | ||||
continue; | continue; | ||||
if (rt1->rt_gateway->sa_family == AF_LINK) { | nh = rt->rt_nhop; | ||||
if (rt1->rt_ifa->ifa_addr->sa_len != rt->rt_ifa->ifa_addr->sa_len || | nh1 = rt1->rt_nhop; | ||||
bcmp(rt1->rt_ifa->ifa_addr, rt->rt_ifa->ifa_addr, | |||||
rt1->rt_ifa->ifa_addr->sa_len)) | if (nh1->gw_sa.sa_family == AF_LINK) { | ||||
if (nh1->nh_ifa->ifa_addr->sa_len != nh->nh_ifa->ifa_addr->sa_len || | |||||
bcmp(nh1->nh_ifa->ifa_addr, nh->nh_ifa->ifa_addr, | |||||
nh1->nh_ifa->ifa_addr->sa_len)) | |||||
continue; | continue; | ||||
} else { | } else { | ||||
if (rt1->rt_gateway->sa_len != rt->rt_gateway->sa_len || | if (nh1->gw_sa.sa_len != nh->gw_sa.sa_len || | ||||
bcmp(rt1->rt_gateway, rt->rt_gateway, | bcmp(&nh1->gw_sa, &nh->gw_sa, nh1->gw_sa.sa_len)) | ||||
rt1->rt_gateway->sa_len)) | |||||
continue; | continue; | ||||
} | } | ||||
/* all key/mask/gateway are the same. conflicting entry. */ | /* all key/mask/gateway are the same. conflicting entry. */ | ||||
return (EEXIST); | return (EEXIST); | ||||
} while ((rn1 = rn_mpath_next(rn1)) != NULL); | } while ((rn1 = rn_mpath_next(rn1)) != NULL); | ||||
return (0); | return (0); | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |