Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/radix_mpath.c
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | |||||
#include <sys/domain.h> | #include <sys/domain.h> | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#include <sys/syslog.h> | #include <sys/syslog.h> | ||||
#include <net/radix.h> | #include <net/radix.h> | ||||
#include <net/radix_mpath.h> | #include <net/radix_mpath.h> | ||||
#include <sys/rmlock.h> | #include <sys/rmlock.h> | ||||
#include <net/route.h> | #include <net/route.h> | ||||
#include <net/route_var.h> | #include <net/route_var.h> | ||||
#include <net/route/nhop.h> | |||||
#include <net/if.h> | #include <net/if.h> | ||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
/* | /* | ||||
* give some jitter to hash, to avoid synchronization between routers | * give some jitter to hash, to avoid synchronization between routers | ||||
*/ | */ | ||||
static uint32_t hashjitter; | static uint32_t hashjitter; | ||||
Show All 38 Lines | rn_mpath_count(struct radix_node *rn) | ||||
} | } | ||||
return (i); | return (i); | ||||
} | } | ||||
struct rtentry * | struct rtentry * | ||||
rt_mpath_matchgate(struct rtentry *rt, struct sockaddr *gate) | rt_mpath_matchgate(struct rtentry *rt, struct sockaddr *gate) | ||||
{ | { | ||||
struct radix_node *rn; | struct radix_node *rn; | ||||
struct nhop_object *nh; | |||||
if (!gate || !rt->rt_gateway) | if (gate == NULL) | ||||
return NULL; | return (NULL); | ||||
/* beyond here, we use rn as the master copy */ | /* beyond here, we use rn as the master copy */ | ||||
rn = (struct radix_node *)rt; | rn = (struct radix_node *)rt; | ||||
do { | do { | ||||
rt = (struct rtentry *)rn; | rt = (struct rtentry *)rn; | ||||
nh = rt->rt_nhop; | |||||
/* | /* | ||||
* we are removing an address alias that has | * we are removing an address alias that has | ||||
* the same prefix as another address | * the same prefix as another address | ||||
* we need to compare the interface address because | * we need to compare the interface address because | ||||
* rt_gateway is a special sockadd_dl structure | * gateway is a special sockaddr_dl structure | ||||
*/ | */ | ||||
if (rt->rt_gateway->sa_family == AF_LINK) { | if (nh->gw_sa.sa_family == AF_LINK) { | ||||
if (!memcmp(rt->rt_ifa->ifa_addr, gate, gate->sa_len)) | if (!memcmp(nh->nh_ifa->ifa_addr, gate, gate->sa_len)) | ||||
break; | break; | ||||
} | } | ||||
/* | /* | ||||
* Check for other options: | * Check for other options: | ||||
* 1) Routes with 'real' IPv4/IPv6 gateway | * 1) Routes with 'real' IPv4/IPv6 gateway | ||||
* 2) Loopback host routes (another AF_LINK/sockadd_dl check) | * 2) Loopback host routes (another AF_LINK/sockadd_dl check) | ||||
* */ | * */ | ||||
if (rt->rt_gateway->sa_len == gate->sa_len && | if (nh->gw_sa.sa_len == gate->sa_len && | ||||
!memcmp(rt->rt_gateway, gate, gate->sa_len)) | !memcmp(&nh->gw_sa, gate, gate->sa_len)) | ||||
break; | break; | ||||
} while ((rn = rn_mpath_next(rn)) != NULL); | } while ((rn = rn_mpath_next(rn)) != NULL); | ||||
return (struct rtentry *)rn; | return (struct rtentry *)rn; | ||||
} | } | ||||
/* | /* | ||||
* go through the chain and unlink "rt" from the list | * go through the chain and unlink "rt" from the list | ||||
▲ Show 20 Lines • Show All 165 Lines • Show Last 20 Lines |