Changeset View
Changeset View
Standalone View
Standalone View
usr.sbin/rtadvd/if.c
Show First 20 Lines • Show All 464 Lines • ▼ Show 20 Lines | if (ifm->ifm_type == RTM_IFINFO) { | ||||
"ifm_index = %d, ifindex = %d", | "ifm_index = %d, ifindex = %d", | ||||
__func__, ifm->ifm_index, ifindex); | __func__, ifm->ifm_index, ifindex); | ||||
/* when ifindex is specified */ | /* when ifindex is specified */ | ||||
if (ifindex != UPDATE_IFINFO_ALL && | if (ifindex != UPDATE_IFINFO_ALL && | ||||
ifindex != ifm->ifm_index) | ifindex != ifm->ifm_index) | ||||
continue; | continue; | ||||
/* ifname */ | |||||
if (if_indextoname(ifm->ifm_index, ifname) == NULL) { | |||||
syslog(LOG_WARNING, | |||||
"<%s> ifname not found (idx=%d)", | |||||
__func__, ifm->ifm_index); | |||||
continue; | |||||
} | |||||
/* lookup an entry with the same ifindex */ | /* lookup an entry with the same ifindex */ | ||||
TAILQ_FOREACH(ifi, ifi_head, ifi_next) { | TAILQ_FOREACH(ifi, ifi_head, ifi_next) { | ||||
if (ifm->ifm_index == ifi->ifi_ifindex) | if (ifm->ifm_index == ifi->ifi_ifindex) | ||||
break; | break; | ||||
if_indextoname(ifm->ifm_index, ifname); | |||||
if (strncmp(ifname, ifi->ifi_ifname, | if (strncmp(ifname, ifi->ifi_ifname, | ||||
sizeof(ifname)) == 0) | sizeof(ifname)) == 0) | ||||
break; | break; | ||||
} | } | ||||
if (ifi == NULL) { | if (ifi == NULL) { | ||||
syslog(LOG_DEBUG, | syslog(LOG_DEBUG, | ||||
"<%s> new entry for idx=%d", | "<%s> new entry for idx=%d", | ||||
__func__, ifm->ifm_index); | __func__, ifm->ifm_index); | ||||
ELM_MALLOC(ifi, exit(1)); | ELM_MALLOC(ifi, exit(1)); | ||||
ifi->ifi_rainfo = NULL; | ifi->ifi_rainfo = NULL; | ||||
ifi->ifi_state = IFI_STATE_UNCONFIGURED; | ifi->ifi_state = IFI_STATE_UNCONFIGURED; | ||||
ifi->ifi_persist = 0; | ifi->ifi_persist = 0; | ||||
ifi_new = 1; | ifi_new = 1; | ||||
} | } | ||||
/* ifindex */ | /* ifindex */ | ||||
ifi->ifi_ifindex = ifm->ifm_index; | ifi->ifi_ifindex = ifm->ifm_index; | ||||
/* ifname */ | /* ifname */ | ||||
if_indextoname(ifm->ifm_index, ifi->ifi_ifname); | strlcpy(ifi->ifi_ifname, ifname, IFNAMSIZ); | ||||
if (ifi->ifi_ifname == NULL) { | |||||
cem: This check was completely bogus, ugh. `ifi_ifname` is an array. | |||||
syslog(LOG_WARNING, | |||||
"<%s> ifname not found (idx=%d)", | |||||
__func__, ifm->ifm_index); | |||||
if (ifi_new) | |||||
free(ifi); | |||||
continue; | |||||
} | |||||
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { | if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { | ||||
syslog(LOG_ERR, | syslog(LOG_ERR, | ||||
"<%s> socket() failed.", __func__); | "<%s> socket() failed.", __func__); | ||||
if (ifi_new) | if (ifi_new) | ||||
free(ifi); | free(ifi); | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |
This check was completely bogus, ugh. ifi_ifname is an array.