nl80211: Check if_indextoname() return value for bridge events

It would be at least theoretically possible for the bridge netdev to
have disappeared at the time hostapd processes the RTM newlink/dellink
message. As such, it is better to verify that if_indextoname() actually
returned success before printing the bridge ifname in debug. In
addition, there is not much point trying to add the bridge ifindex into
the list of own ifindexes in case the interface has already been
removed, so skip that part as well.

Signed-off-by: Jouni Malinen <j@w1.fi>
This commit is contained in:
Jouni Malinen 2014-12-23 19:35:34 +02:00
parent 6d930a1eef
commit 40e7639600

View file

@ -740,7 +740,7 @@ static int wpa_driver_nl80211_get_ssid(void *priv, u8 *ssid)
static void wpa_driver_nl80211_event_newlink(
struct wpa_driver_nl80211_data *drv, char *ifname)
struct wpa_driver_nl80211_data *drv, const char *ifname)
{
union wpa_event_data event;
@ -766,7 +766,7 @@ static void wpa_driver_nl80211_event_newlink(
static void wpa_driver_nl80211_event_dellink(
struct wpa_driver_nl80211_data *drv, char *ifname)
struct wpa_driver_nl80211_data *drv, const char *ifname)
{
union wpa_event_data event;
@ -1008,7 +1008,12 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
struct i802_bss *bss;
/* device has been added to bridge */
if_indextoname(brid, namebuf);
if (!if_indextoname(brid, namebuf)) {
wpa_printf(MSG_DEBUG,
"nl80211: Could not find bridge ifname for ifindex %u",
brid);
return;
}
wpa_printf(MSG_DEBUG, "nl80211: Add ifindex %u for bridge %s",
brid, namebuf);
add_ifidx(drv, brid);
@ -1088,9 +1093,16 @@ static void wpa_driver_nl80211_event_rtm_dellink(void *ctx,
if (ifi->ifi_family == AF_BRIDGE && brid) {
/* device has been removed from bridge */
char namebuf[IFNAMSIZ];
if_indextoname(brid, namebuf);
wpa_printf(MSG_DEBUG, "nl80211: Remove ifindex %u for bridge "
"%s", brid, namebuf);
if (!if_indextoname(brid, namebuf)) {
wpa_printf(MSG_DEBUG,
"nl80211: Could not find bridge ifname for ifindex %u",
brid);
} else {
wpa_printf(MSG_DEBUG,
"nl80211: Remove ifindex %u for bridge %s",
brid, namebuf);
}
del_ifidx(drv, brid);
}
}