Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/in_rmx.c
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/in_var.h> | #include <netinet/in_var.h> | ||||
#include <netinet/ip.h> | #include <netinet/ip.h> | ||||
#include <netinet/ip_icmp.h> | #include <netinet/ip_icmp.h> | ||||
#include <netinet/ip_var.h> | #include <netinet/ip_var.h> | ||||
extern int in_inithead(void **head, int off, u_int fibnum); | |||||
#ifdef VIMAGE | |||||
extern int in_detachhead(void **head, int off); | |||||
#endif | |||||
static int | static int | ||||
rib4_preadd(u_int fibnum, const struct sockaddr *addr, const struct sockaddr *mask, | rib4_preadd(u_int fibnum, const struct sockaddr *addr, const struct sockaddr *mask, | ||||
struct nhop_object *nh) | struct nhop_object *nh) | ||||
{ | { | ||||
const struct sockaddr_in *addr4 = (const struct sockaddr_in *)addr; | const struct sockaddr_in *addr4 = (const struct sockaddr_in *)addr; | ||||
uint16_t nh_type; | uint16_t nh_type; | ||||
int rt_flags; | int rt_flags; | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | else | ||||
nh_type = NH_TYPE_IPV4_ETHER_RSLV; | nh_type = NH_TYPE_IPV4_ETHER_RSLV; | ||||
nhop_set_type(nh, nh_type); | nhop_set_type(nh, nh_type); | ||||
} | } | ||||
return (0); | return (0); | ||||
} | } | ||||
static int _in_rt_was_here; | |||||
/* | /* | ||||
* Initialize our routing tree. | * Initialize our routing tree. | ||||
*/ | */ | ||||
int | struct rib_head * | ||||
in_inithead(void **head, int off, u_int fibnum) | in_inithead(uint32_t fibnum) | ||||
{ | { | ||||
struct rib_head *rh; | struct rib_head *rh; | ||||
rh = rt_table_init(32, AF_INET, fibnum); | rh = rt_table_init(32, AF_INET, fibnum); | ||||
if (rh == NULL) | if (rh == NULL) | ||||
return (0); | return (NULL); | ||||
rh->rnh_preadd = rib4_preadd; | rh->rnh_preadd = rib4_preadd; | ||||
#ifdef RADIX_MPATH | #ifdef RADIX_MPATH | ||||
rt_mpath_init_rnh(rh); | rt_mpath_init_rnh(rh); | ||||
#endif | #endif | ||||
*head = (void *)rh; | |||||
if (_in_rt_was_here == 0 ) { | return (rh); | ||||
_in_rt_was_here = 1; | |||||
} | } | ||||
return 1; | |||||
} | |||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
int | void | ||||
in_detachhead(void **head, int off) | in_detachhead(struct rib_head *rh) | ||||
{ | { | ||||
rt_table_destroy((struct rib_head *)(*head)); | rt_table_destroy(rh); | ||||
return (1); | |||||
} | } | ||||
#endif | #endif | ||||
/* | /* | ||||
* This zaps old routes when the interface goes down or interface | * This zaps old routes when the interface goes down or interface | ||||
* address is deleted. In the latter case, it deletes static routes | * address is deleted. In the latter case, it deletes static routes | ||||
* that point to this address. If we don't do this, we may end up | * that point to this address. If we don't do this, we may end up | ||||
* using the old address in the future. The ones we always want to | * using the old address in the future. The ones we always want to | ||||
Show All 39 Lines |