Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if.c
Show First 20 Lines • Show All 2,462 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct ifreq *ifr; | struct ifreq *ifr; | ||||
int error = 0, do_ifup = 0; | int error = 0, do_ifup = 0; | ||||
int new_flags, temp_flags; | int new_flags, temp_flags; | ||||
size_t namelen, onamelen; | size_t namelen, onamelen; | ||||
size_t descrlen; | size_t descrlen; | ||||
char *descrbuf, *odescrbuf; | char *descrbuf, *odescrbuf; | ||||
char new_name[IFNAMSIZ]; | char new_name[IFNAMSIZ]; | ||||
char old_name[IFNAMSIZ], strbuf[IFNAMSIZ + 8]; | |||||
struct ifaddr *ifa; | struct ifaddr *ifa; | ||||
struct sockaddr_dl *sdl; | struct sockaddr_dl *sdl; | ||||
ifr = (struct ifreq *)data; | ifr = (struct ifreq *)data; | ||||
switch (cmd) { | switch (cmd) { | ||||
case SIOCGIFINDEX: | case SIOCGIFINDEX: | ||||
ifr->ifr_index = ifp->if_index; | ifr->ifr_index = ifp->if_index; | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 189 Lines • ▼ Show 20 Lines | case SIOCSIFNAME: | ||||
/* Announce the departure of the interface. */ | /* Announce the departure of the interface. */ | ||||
rt_ifannouncemsg(ifp, IFAN_DEPARTURE); | rt_ifannouncemsg(ifp, IFAN_DEPARTURE); | ||||
EVENTHANDLER_INVOKE(ifnet_departure_event, ifp); | EVENTHANDLER_INVOKE(ifnet_departure_event, ifp); | ||||
if_printf(ifp, "changing name to '%s'\n", new_name); | if_printf(ifp, "changing name to '%s'\n", new_name); | ||||
IF_ADDR_WLOCK(ifp); | IF_ADDR_WLOCK(ifp); | ||||
strlcpy(old_name, ifp->if_xname, sizeof(old_name)); | |||||
asomers: I think you're sending the notification too early. It looks to me like it would be possible… | |||||
strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname)); | strlcpy(ifp->if_xname, new_name, sizeof(ifp->if_xname)); | ||||
ifa = ifp->if_addr; | ifa = ifp->if_addr; | ||||
sdl = (struct sockaddr_dl *)ifa->ifa_addr; | sdl = (struct sockaddr_dl *)ifa->ifa_addr; | ||||
namelen = strlen(new_name); | namelen = strlen(new_name); | ||||
onamelen = sdl->sdl_nlen; | onamelen = sdl->sdl_nlen; | ||||
/* | /* | ||||
* Move the address if needed. This is safe because we | * Move the address if needed. This is safe because we | ||||
* allocate space for a name of length IFNAMSIZ when we | * allocate space for a name of length IFNAMSIZ when we | ||||
Show All 11 Lines | while (namelen != 0) | ||||
sdl->sdl_data[--namelen] = 0xff; | sdl->sdl_data[--namelen] = 0xff; | ||||
IF_ADDR_WUNLOCK(ifp); | IF_ADDR_WUNLOCK(ifp); | ||||
EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); | EVENTHANDLER_INVOKE(ifnet_arrival_event, ifp); | ||||
/* Announce the return of the interface. */ | /* Announce the return of the interface. */ | ||||
rt_ifannouncemsg(ifp, IFAN_ARRIVAL); | rt_ifannouncemsg(ifp, IFAN_ARRIVAL); | ||||
ifp->if_flags &= ~IFF_RENAMING; | ifp->if_flags &= ~IFF_RENAMING; | ||||
snprintf(strbuf, sizeof(strbuf), "name=%s", new_name); | |||||
devctl_notify("IFNET", old_name, "RENAME", strbuf); | |||||
break; | break; | ||||
#ifdef VIMAGE | #ifdef VIMAGE | ||||
case SIOCSIFVNET: | case SIOCSIFVNET: | ||||
error = priv_check(td, PRIV_NET_SETIFVNET); | error = priv_check(td, PRIV_NET_SETIFVNET); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
error = if_vmove_loan(td, ifp, ifr->ifr_name, ifr->ifr_jid); | error = if_vmove_loan(td, ifp, ifr->ifr_name, ifr->ifr_jid); | ||||
▲ Show 20 Lines • Show All 1,895 Lines • Show Last 20 Lines |
I think you're sending the notification too early. It looks to me like it would be possible for userspace to see the notification before the interface has its new name.