Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/in.c
Show First 20 Lines • Show All 236 Lines • ▼ Show 20 Lines | default: | ||||
return ((*ifp->if_ioctl)(ifp, cmd, data)); | return ((*ifp->if_ioctl)(ifp, cmd, data)); | ||||
} | } | ||||
if (addr->sin_addr.s_addr != INADDR_ANY && | if (addr->sin_addr.s_addr != INADDR_ANY && | ||||
prison_check_ip4(td->td_ucred, &addr->sin_addr) != 0) | prison_check_ip4(td->td_ucred, &addr->sin_addr) != 0) | ||||
return (EADDRNOTAVAIL); | return (EADDRNOTAVAIL); | ||||
/* | /* | ||||
* For SIOCGIFADDR, pick the first address. For the rest of | * Find address for this interface, if it exists. If an | ||||
* ioctls, try to find specified address. | * address was specified, find that one instead of the | ||||
* first one on the interface, if possible. | |||||
*/ | */ | ||||
IF_ADDR_RLOCK(ifp); | IF_ADDR_RLOCK(ifp); | ||||
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { | TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) { | ||||
if (ifa->ifa_addr->sa_family != AF_INET) | if (ifa->ifa_addr->sa_family != AF_INET) | ||||
continue; | continue; | ||||
ia = (struct in_ifaddr *)ifa; | ia = (struct in_ifaddr *)ifa; | ||||
if (cmd == SIOCGIFADDR || addr->sin_addr.s_addr == INADDR_ANY) | |||||
break; | |||||
if (ia->ia_addr.sin_addr.s_addr == addr->sin_addr.s_addr) | if (ia->ia_addr.sin_addr.s_addr == addr->sin_addr.s_addr) | ||||
break; | |||||
} | |||||
if (ifa == NULL) | |||||
TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) | |||||
if (ifa->ifa_addr->sa_family == AF_INET) { | |||||
ia = (struct in_ifaddr *)ifa; | |||||
if (prison_check_ip4(td->td_ucred, | |||||
&ia->ia_addr.sin_addr) == 0) | |||||
break; | break; | ||||
} | } | ||||
if (ifa == NULL) { | if (ifa == NULL) { | ||||
IF_ADDR_RUNLOCK(ifp); | IF_ADDR_RUNLOCK(ifp); | ||||
return (EADDRNOTAVAIL); | return (EADDRNOTAVAIL); | ||||
} | } | ||||
error = 0; | error = 0; | ||||
switch (cmd) { | switch (cmd) { | ||||
▲ Show 20 Lines • Show All 997 Lines • Show Last 20 Lines |