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:
parent
6d930a1eef
commit
40e7639600
1 changed files with 18 additions and 6 deletions
|
@ -740,7 +740,7 @@ static int wpa_driver_nl80211_get_ssid(void *priv, u8 *ssid)
|
||||||
|
|
||||||
|
|
||||||
static void wpa_driver_nl80211_event_newlink(
|
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;
|
union wpa_event_data event;
|
||||||
|
|
||||||
|
@ -766,7 +766,7 @@ static void wpa_driver_nl80211_event_newlink(
|
||||||
|
|
||||||
|
|
||||||
static void wpa_driver_nl80211_event_dellink(
|
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;
|
union wpa_event_data event;
|
||||||
|
|
||||||
|
@ -1008,7 +1008,12 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
|
||||||
struct i802_bss *bss;
|
struct i802_bss *bss;
|
||||||
|
|
||||||
/* device has been added to bridge */
|
/* 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",
|
wpa_printf(MSG_DEBUG, "nl80211: Add ifindex %u for bridge %s",
|
||||||
brid, namebuf);
|
brid, namebuf);
|
||||||
add_ifidx(drv, brid);
|
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) {
|
if (ifi->ifi_family == AF_BRIDGE && brid) {
|
||||||
/* device has been removed from bridge */
|
/* device has been removed from bridge */
|
||||||
char namebuf[IFNAMSIZ];
|
char namebuf[IFNAMSIZ];
|
||||||
if_indextoname(brid, namebuf);
|
|
||||||
wpa_printf(MSG_DEBUG, "nl80211: Remove ifindex %u for bridge "
|
if (!if_indextoname(brid, namebuf)) {
|
||||||
"%s", 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);
|
del_ifidx(drv, brid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue