Changeset View
Changeset View
Standalone View
Standalone View
sys/net/rtsock.c
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | |||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <netinet/if_ether.h> | #include <netinet/if_ether.h> | ||||
#include <netinet/ip_carp.h> | #include <netinet/ip_carp.h> | ||||
#ifdef INET6 | #ifdef INET6 | ||||
#include <netinet6/ip6_var.h> | #include <netinet6/ip6_var.h> | ||||
#include <netinet6/scope6_var.h> | #include <netinet6/scope6_var.h> | ||||
#endif | #endif | ||||
#include <net/route/nhop.h> | |||||
#ifdef COMPAT_FREEBSD32 | #ifdef COMPAT_FREEBSD32 | ||||
#include <sys/mount.h> | #include <sys/mount.h> | ||||
#include <compat/freebsd32/freebsd32.h> | #include <compat/freebsd32/freebsd32.h> | ||||
struct if_msghdr32 { | struct if_msghdr32 { | ||||
uint16_t ifm_msglen; | uint16_t ifm_msglen; | ||||
uint8_t ifm_version; | uint8_t ifm_version; | ||||
▲ Show 20 Lines • Show All 983 Lines • ▼ Show 20 Lines | |||||
static void | static void | ||||
rt_getmetrics(const struct rtentry *rt, struct rt_metrics *out) | rt_getmetrics(const struct rtentry *rt, struct rt_metrics *out) | ||||
{ | { | ||||
bzero(out, sizeof(*out)); | bzero(out, sizeof(*out)); | ||||
out->rmx_mtu = rt->rt_mtu; | out->rmx_mtu = rt->rt_mtu; | ||||
out->rmx_weight = rt->rt_weight; | out->rmx_weight = rt->rt_weight; | ||||
out->rmx_pksent = counter_u64_fetch(rt->rt_pksent); | out->rmx_pksent = counter_u64_fetch(rt->rt_pksent); | ||||
out->rmx_nhidx = nhop_get_idx(rt->rt_nhop); | |||||
/* Kernel -> userland timebase conversion. */ | /* Kernel -> userland timebase conversion. */ | ||||
out->rmx_expire = rt->rt_expire ? | out->rmx_expire = rt->rt_expire ? | ||||
rt->rt_expire - time_uptime + time_second : 0; | rt->rt_expire - time_uptime + time_second : 0; | ||||
} | } | ||||
/* | /* | ||||
* Extract the addresses of the passed sockaddrs. | * Extract the addresses of the passed sockaddrs. | ||||
* Do a little sanity checking so as to avoid bad memory references. | * Do a little sanity checking so as to avoid bad memory references. | ||||
▲ Show 20 Lines • Show All 933 Lines • ▼ Show 20 Lines | sysctl_rtsock(SYSCTL_HANDLER_ARGS) | ||||
int fib = 0; | int fib = 0; | ||||
u_char af; | u_char af; | ||||
struct walkarg w; | struct walkarg w; | ||||
name ++; | name ++; | ||||
namelen--; | namelen--; | ||||
if (req->newptr) | if (req->newptr) | ||||
return (EPERM); | return (EPERM); | ||||
if (name[1] == NET_RT_DUMP) { | if (name[1] == NET_RT_DUMP || name[1] == NET_RT_NHOP) { | ||||
if (namelen == 3) | if (namelen == 3) | ||||
fib = req->td->td_proc->p_fibnum; | fib = req->td->td_proc->p_fibnum; | ||||
else if (namelen == 4) | else if (namelen == 4) | ||||
fib = (name[3] == RT_ALL_FIBS) ? | fib = (name[3] == RT_ALL_FIBS) ? | ||||
req->td->td_proc->p_fibnum : name[3]; | req->td->td_proc->p_fibnum : name[3]; | ||||
else | else | ||||
return ((namelen < 3) ? EISDIR : ENOTDIR); | return ((namelen < 3) ? EISDIR : ENOTDIR); | ||||
if (fib < 0 || fib >= rt_numfibs) | if (fib < 0 || fib >= rt_numfibs) | ||||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | for (error = 0; error == 0 && i <= lim; i++) { | ||||
RIB_RLOCK(rnh); | RIB_RLOCK(rnh); | ||||
error = rnh->rnh_walktree(&rnh->head, | error = rnh->rnh_walktree(&rnh->head, | ||||
sysctl_dumpentry, &w); | sysctl_dumpentry, &w); | ||||
RIB_RUNLOCK(rnh); | RIB_RUNLOCK(rnh); | ||||
} else if (af != 0) | } else if (af != 0) | ||||
error = EAFNOSUPPORT; | error = EAFNOSUPPORT; | ||||
} | } | ||||
break; | break; | ||||
case NET_RT_NHOP: | |||||
/* Allow dumping one specific af/fib at a time */ | |||||
if (namelen < 4) { | |||||
error = EINVAL; | |||||
break; | |||||
} | |||||
fib = name[3]; | |||||
if (fib < 0 || fib > rt_numfibs) { | |||||
error = EINVAL; | |||||
break; | |||||
} | |||||
rnh = rt_tables_get_rnh(fib, af); | |||||
if (rnh == NULL) { | |||||
error = EAFNOSUPPORT; | |||||
break; | |||||
} | |||||
if (w.w_op == NET_RT_NHOP) | |||||
error = nhops_dump_sysctl(rnh, w.w_req); | |||||
break; | |||||
case NET_RT_IFLIST: | case NET_RT_IFLIST: | ||||
case NET_RT_IFLISTL: | case NET_RT_IFLISTL: | ||||
error = sysctl_iflist(af, &w); | error = sysctl_iflist(af, &w); | ||||
break; | break; | ||||
case NET_RT_IFMALIST: | case NET_RT_IFMALIST: | ||||
error = sysctl_ifmalist(af, &w); | error = sysctl_ifmalist(af, &w); | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 441 Lines • Show Last 20 Lines |