Changeset View
Changeset View
Standalone View
Standalone View
sys/net/rtsock.c
Show First 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | |||||
static void rts_input(struct mbuf *m); | static void rts_input(struct mbuf *m); | ||||
static struct mbuf *rtsock_msg_mbuf(int type, struct rt_addrinfo *rtinfo); | static struct mbuf *rtsock_msg_mbuf(int type, struct rt_addrinfo *rtinfo); | ||||
static int rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, | static int rtsock_msg_buffer(int type, struct rt_addrinfo *rtinfo, | ||||
struct walkarg *w, int *plen); | struct walkarg *w, int *plen); | ||||
static int rt_xaddrs(caddr_t cp, caddr_t cplim, | static int rt_xaddrs(caddr_t cp, caddr_t cplim, | ||||
struct rt_addrinfo *rtinfo); | struct rt_addrinfo *rtinfo); | ||||
static int sysctl_dumpentry(struct radix_node *rn, void *vw); | static int sysctl_dumpentry(struct radix_node *rn, void *vw); | ||||
static int sysctl_dumpnhop(struct rtentry *rt, struct nhop_object *nh, | |||||
uint32_t weight, struct walkarg *w); | |||||
static int sysctl_iflist(int af, struct walkarg *w); | static int sysctl_iflist(int af, struct walkarg *w); | ||||
static int sysctl_ifmalist(int af, struct walkarg *w); | static int sysctl_ifmalist(int af, struct walkarg *w); | ||||
static int route_output(struct mbuf *m, struct socket *so, ...); | static int route_output(struct mbuf *m, struct socket *so, ...); | ||||
static void rt_getmetrics(const struct rtentry *rt, | static void rt_getmetrics(const struct rtentry *rt, | ||||
const struct nhop_object *nh, struct rt_metrics *out); | const struct nhop_object *nh, struct rt_metrics *out); | ||||
static void rt_dispatch(struct mbuf *, sa_family_t); | static void rt_dispatch(struct mbuf *, sa_family_t); | ||||
static int handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, | static int handle_rtm_get(struct rt_addrinfo *info, u_int fibnum, | ||||
struct rt_msghdr *rtm, struct rib_cmd_info *rc); | struct rt_msghdr *rtm, struct rib_cmd_info *rc); | ||||
▲ Show 20 Lines • Show All 549 Lines • ▼ Show 20 Lines | if (rtm->rtm_flags & RTF_ANNOUNCE) { | ||||
rc->rc_rt = (struct rtentry *)rnh->rnh_matchaddr(&laddr, | rc->rc_rt = (struct rtentry *)rnh->rnh_matchaddr(&laddr, | ||||
&rnh->head); | &rnh->head); | ||||
if (rc->rc_rt == NULL) { | if (rc->rc_rt == NULL) { | ||||
RIB_RUNLOCK(rnh); | RIB_RUNLOCK(rnh); | ||||
return (ESRCH); | return (ESRCH); | ||||
} | } | ||||
} | } | ||||
rc->rc_nh_new = rc->rc_rt->rt_nhop; | rc->rc_nh_new = rc->rc_rt->rt_nhop; | ||||
rc->rc_nh_weight = rc->rc_rt->rt_weight; | |||||
RIB_RUNLOCK(rnh); | RIB_RUNLOCK(rnh); | ||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Update sockaddrs, flags, etc in @prtm based on @rc data. | * Update sockaddrs, flags, etc in @prtm based on @rc data. | ||||
* rtm can be reallocated. | * rtm can be reallocated. | ||||
▲ Show 20 Lines • Show All 940 Lines • ▼ Show 20 Lines | |||||
* This is used in dumping the kernel table via sysctl(). | * This is used in dumping the kernel table via sysctl(). | ||||
*/ | */ | ||||
static int | static int | ||||
sysctl_dumpentry(struct radix_node *rn, void *vw) | sysctl_dumpentry(struct radix_node *rn, void *vw) | ||||
{ | { | ||||
struct walkarg *w = vw; | struct walkarg *w = vw; | ||||
struct rtentry *rt = (struct rtentry *)rn; | struct rtentry *rt = (struct rtentry *)rn; | ||||
struct nhop_object *nh; | struct nhop_object *nh; | ||||
int error = 0, size; | int error = 0; | ||||
struct rt_addrinfo info; | |||||
struct sockaddr_storage ss; | |||||
NET_EPOCH_ASSERT(); | NET_EPOCH_ASSERT(); | ||||
if (w->w_op == NET_RT_FLAGS && !(rt->rte_flags & w->w_arg)) | if (w->w_op == NET_RT_FLAGS && !(rt->rte_flags & w->w_arg)) | ||||
return 0; | return 0; | ||||
if (!can_export_rte(w->w_req->td->td_ucred, rt)) | if (!can_export_rte(w->w_req->td->td_ucred, rt)) | ||||
return (0); | return (0); | ||||
nh = rt->rt_nhop; | nh = rt->rt_nhop; | ||||
error = sysctl_dumpnhop(rt, nh, rt->rt_weight, w); | |||||
return (0); | |||||
} | |||||
static int | |||||
sysctl_dumpnhop(struct rtentry *rt, struct nhop_object *nh, uint32_t weight, | |||||
struct walkarg *w) | |||||
{ | |||||
struct rt_addrinfo info; | |||||
int error = 0, size; | |||||
struct sockaddr_storage ss; | |||||
bzero((caddr_t)&info, sizeof(info)); | bzero((caddr_t)&info, sizeof(info)); | ||||
info.rti_info[RTAX_DST] = rt_key(rt); | info.rti_info[RTAX_DST] = rt_key(rt); | ||||
info.rti_info[RTAX_GATEWAY] = &nh->gw_sa; | info.rti_info[RTAX_GATEWAY] = &nh->gw_sa; | ||||
info.rti_info[RTAX_NETMASK] = rtsock_fix_netmask(rt_key(rt), | info.rti_info[RTAX_NETMASK] = rtsock_fix_netmask(rt_key(rt), | ||||
rt_mask(rt), &ss); | rt_mask(rt), &ss); | ||||
info.rti_info[RTAX_GENMASK] = 0; | info.rti_info[RTAX_GENMASK] = 0; | ||||
if (nh->nh_ifp && !(nh->nh_ifp->if_flags & IFF_DYING)) { | if (nh->nh_ifp && !(nh->nh_ifp->if_flags & IFF_DYING)) { | ||||
info.rti_info[RTAX_IFP] = nh->nh_ifp->if_addr->ifa_addr; | info.rti_info[RTAX_IFP] = nh->nh_ifp->if_addr->ifa_addr; | ||||
Show All 10 Lines | bzero(&rtm->rtm_index, | ||||
sizeof(*rtm) - offsetof(struct rt_msghdr, rtm_index)); | sizeof(*rtm) - offsetof(struct rt_msghdr, rtm_index)); | ||||
if (rt->rte_flags & RTF_GWFLAG_COMPAT) | if (rt->rte_flags & RTF_GWFLAG_COMPAT) | ||||
rtm->rtm_flags = RTF_GATEWAY | | rtm->rtm_flags = RTF_GATEWAY | | ||||
(rt->rte_flags & ~RTF_GWFLAG_COMPAT); | (rt->rte_flags & ~RTF_GWFLAG_COMPAT); | ||||
else | else | ||||
rtm->rtm_flags = rt->rte_flags; | rtm->rtm_flags = rt->rte_flags; | ||||
rtm->rtm_flags |= nhop_get_rtflags(nh); | rtm->rtm_flags |= nhop_get_rtflags(nh); | ||||
rt_getmetrics(rt, nh, &rtm->rtm_rmx); | rt_getmetrics(rt, nh, &rtm->rtm_rmx); | ||||
rtm->rtm_rmx.rmx_weight = weight; | |||||
rtm->rtm_index = nh->nh_ifp->if_index; | rtm->rtm_index = nh->nh_ifp->if_index; | ||||
rtm->rtm_addrs = info.rti_addrs; | rtm->rtm_addrs = info.rti_addrs; | ||||
error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size); | error = SYSCTL_OUT(w->w_req, (caddr_t)rtm, size); | ||||
return (error); | return (error); | ||||
} | } | ||||
return (error); | return (error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 402 Lines • Show Last 20 Lines |