Changeset View
Changeset View
Standalone View
Standalone View
sys/net/rtsock.c
Show First 20 Lines • Show All 1,547 Lines • ▼ Show 20 Lines | |||||
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; | ||||
int error = 0, size; | int error = 0, size; | ||||
struct rt_addrinfo info; | struct rt_addrinfo info; | ||||
struct sockaddr_storage ss; | struct sockaddr_storage ss; | ||||
bz: Do you want to assert that the locks are held as expected in here? | |||||
aeAuthorUnsubmitted Done Inline ActionsI can add IFNET_RLOCK_NOSLEEP_ASSERT() here, but adding of RIB_LOCK_ASSERT() needs more intrusive change. ae: I can add IFNET_RLOCK_NOSLEEP_ASSERT() here, but adding of RIB_LOCK_ASSERT() needs more… | |||||
if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg)) | if (w->w_op == NET_RT_FLAGS && !(rt->rt_flags & w->w_arg)) | ||||
return 0; | return 0; | ||||
if ((rt->rt_flags & RTF_HOST) == 0 | if ((rt->rt_flags & RTF_HOST) == 0 | ||||
? jailed_without_vnet(w->w_req->td->td_ucred) | ? jailed_without_vnet(w->w_req->td->td_ucred) | ||||
: prison_if(w->w_req->td->td_ucred, rt_key(rt)) != 0) | : prison_if(w->w_req->td->td_ucred, rt_key(rt)) != 0) | ||||
return (0); | return (0); | ||||
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] = rt->rt_gateway; | info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; | ||||
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 (rt->rt_ifp) { | if (rt->rt_ifp && !(rt->rt_ifp->if_flags & IFF_DYING)) { | ||||
info.rti_info[RTAX_IFP] = rt->rt_ifp->if_addr->ifa_addr; | info.rti_info[RTAX_IFP] = rt->rt_ifp->if_addr->ifa_addr; | ||||
info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; | info.rti_info[RTAX_IFA] = rt->rt_ifa->ifa_addr; | ||||
if (rt->rt_ifp->if_flags & IFF_POINTOPOINT) | if (rt->rt_ifp->if_flags & IFF_POINTOPOINT) | ||||
info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; | info.rti_info[RTAX_BRD] = rt->rt_ifa->ifa_dstaddr; | ||||
} | } | ||||
if ((error = rtsock_msg_buffer(RTM_GET, &info, w, &size)) != 0) | if ((error = rtsock_msg_buffer(RTM_GET, &info, w, &size)) != 0) | ||||
return (error); | return (error); | ||||
if (w->w_req && w->w_tmem) { | if (w->w_req && w->w_tmem) { | ||||
▲ Show 20 Lines • Show All 338 Lines • ▼ Show 20 Lines | if (w.w_op == NET_RT_FLAGS && | ||||
break; | break; | ||||
} | } | ||||
/* | /* | ||||
* take care of routing entries | * take care of routing entries | ||||
*/ | */ | ||||
for (error = 0; error == 0 && i <= lim; i++) { | for (error = 0; error == 0 && i <= lim; i++) { | ||||
rnh = rt_tables_get_rnh(fib, i); | rnh = rt_tables_get_rnh(fib, i); | ||||
if (rnh != NULL) { | if (rnh != NULL) { | ||||
RIB_RLOCK(rnh); | RIB_RLOCK(rnh); | ||||
bzUnsubmitted Done Inline ActionsCan you please commit the whitespace changes separately? bz: Can you please commit the whitespace changes separately? | |||||
IFNET_RLOCK_NOSLEEP(); | |||||
error = rnh->rnh_walktree(&rnh->head, | error = rnh->rnh_walktree(&rnh->head, | ||||
sysctl_dumpentry, &w); | sysctl_dumpentry, &w); | ||||
IFNET_RLOCK_NOSLEEP(); | |||||
RIB_RUNLOCK(rnh); | RIB_RUNLOCK(rnh); | ||||
} else if (af != 0) | } else if (af != 0) | ||||
error = EAFNOSUPPORT; | error = EAFNOSUPPORT; | ||||
} | } | ||||
break; | break; | ||||
case NET_RT_IFLIST: | case NET_RT_IFLIST: | ||||
case NET_RT_IFLISTL: | case NET_RT_IFLISTL: | ||||
Show All 40 Lines |
Do you want to assert that the locks are held as expected in here?