Changeset View
Changeset View
Standalone View
Standalone View
head/sys/net/route.c
Show First 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
#include <net/if_var.h> | #include <net/if_var.h> | ||||
#include <net/if_dl.h> | #include <net/if_dl.h> | ||||
#include <net/route.h> | #include <net/route.h> | ||||
#include <net/route/route_ctl.h> | #include <net/route/route_ctl.h> | ||||
#include <net/route/route_var.h> | #include <net/route/route_var.h> | ||||
#include <net/route/nhop.h> | #include <net/route/nhop.h> | ||||
#include <net/vnet.h> | #include <net/vnet.h> | ||||
#ifdef RADIX_MPATH | |||||
#include <net/radix_mpath.h> | |||||
#endif | |||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/ip_mroute.h> | #include <netinet/ip_mroute.h> | ||||
VNET_PCPUSTAT_DEFINE(struct rtstat, rtstat); | VNET_PCPUSTAT_DEFINE(struct rtstat, rtstat); | ||||
VNET_PCPUSTAT_SYSINIT(rtstat); | VNET_PCPUSTAT_SYSINIT(rtstat); | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
VNET_PCPUSTAT_SYSUNINIT(rtstat); | VNET_PCPUSTAT_SYSUNINIT(rtstat); | ||||
▲ Show 20 Lines • Show All 589 Lines • ▼ Show 20 Lines | rt_print(char *buf, int buflen, struct rtentry *rt) | ||||
} | } | ||||
if (rt->rt_flags & RTF_GATEWAY) { | if (rt->rt_flags & RTF_GATEWAY) { | ||||
buf[i++] = '>'; | buf[i++] = '>'; | ||||
i += p_sockaddr(buf + i, buflen - i, &rt->rt_nhop->gw_sa); | i += p_sockaddr(buf + i, buflen - i, &rt->rt_nhop->gw_sa); | ||||
} | } | ||||
return (i); | return (i); | ||||
} | |||||
#endif | |||||
#ifdef RADIX_MPATH | |||||
/* | |||||
* Deletes key for single-path routes, unlinks rtentry with | |||||
* gateway specified in @info from multi-path routes. | |||||
* | |||||
* Returnes unlinked entry. In case of failure, returns NULL | |||||
* and sets @perror to ESRCH. | |||||
*/ | |||||
struct radix_node * | |||||
rt_mpath_unlink(struct rib_head *rnh, struct rt_addrinfo *info, | |||||
struct rtentry *rto, int *perror) | |||||
{ | |||||
/* | |||||
* if we got multipath routes, we require users to specify | |||||
* a matching RTAX_GATEWAY. | |||||
*/ | |||||
struct rtentry *rt; // *rto = NULL; | |||||
struct radix_node *rn; | |||||
struct sockaddr *gw; | |||||
gw = info->rti_info[RTAX_GATEWAY]; | |||||
rt = rt_mpath_matchgate(rto, gw); | |||||
if (rt == NULL) { | |||||
*perror = ESRCH; | |||||
return (NULL); | |||||
} | |||||
/* | |||||
* this is the first entry in the chain | |||||
*/ | |||||
if (rto == rt) { | |||||
rn = rn_mpath_next((struct radix_node *)rt); | |||||
/* | |||||
* there is another entry, now it's active | |||||
*/ | |||||
if (rn) { | |||||
rto = RNTORT(rn); | |||||
rto->rte_flags |= RTF_UP; | |||||
} else if (rt->rte_flags & RTF_GATEWAY) { | |||||
/* | |||||
* For gateway routes, we need to | |||||
* make sure that we we are deleting | |||||
* the correct gateway. | |||||
* rt_mpath_matchgate() does not | |||||
* check the case when there is only | |||||
* one route in the chain. | |||||
*/ | |||||
if (gw && | |||||
(rt->rt_nhop->gw_sa.sa_len != gw->sa_len || | |||||
memcmp(&rt->rt_nhop->gw_sa, gw, gw->sa_len))) { | |||||
*perror = ESRCH; | |||||
return (NULL); | |||||
} | |||||
} | |||||
/* | |||||
* use the normal delete code to remove | |||||
* the first entry | |||||
*/ | |||||
rn = rnh->rnh_deladdr(info->rti_info[RTAX_DST], | |||||
info->rti_info[RTAX_NETMASK], | |||||
&rnh->head); | |||||
if (rn != NULL) { | |||||
*perror = 0; | |||||
} else { | |||||
*perror = ESRCH; | |||||
} | |||||
return (rn); | |||||
} | |||||
/* | |||||
* if the entry is 2nd and on up | |||||
*/ | |||||
if (rt_mpath_deldup(rto, rt) == 0) | |||||
panic ("rtrequest1: rt_mpath_deldup"); | |||||
*perror = 0; | |||||
rn = (struct radix_node *)rt; | |||||
return (rn); | |||||
} | } | ||||
#endif | #endif | ||||
void | void | ||||
rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst, struct sockaddr *netmask) | rt_maskedcopy(struct sockaddr *src, struct sockaddr *dst, struct sockaddr *netmask) | ||||
{ | { | ||||
u_char *cp1 = (u_char *)src; | u_char *cp1 = (u_char *)src; | ||||
u_char *cp2 = (u_char *)dst; | u_char *cp2 = (u_char *)dst; | ||||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |