[PATCH] interface name size limit for Monitor interface

Jouni Malinen j
Wed Oct 12 13:40:09 PDT 2011


On Mon, Oct 10, 2011 at 10:29:53AM +0530, JJ wrote:
> Currently the P2P Interface name[p2p-%s-%d] is reset when the P2P Interface
> name reaches the "IFNAMSIZ" limit. Monitor interface name is derived from
> p2p interface name with the addition of few characters [mon.p2p-%s-%d] and
> hence Monitor interface name hits IFNAMSIZ limit before P2P Interface name.
> So we need to reset p2p interface name early enough to take care of extra
> characters in monitor interface name. This will make sure that "%d"
> enumeration is in sync for p2p and monitor interface. This patch also
> reduces the monitor interface name length to increase the reset window
> ["mon." to "m."].

Are you really hitting IFNAMSIZ (16) size limit? May I ask what's the base
interface name is in this case? ;-)

> diff --git a/src/drivers/driver.h b/src/drivers/driver.h
> @@ -35,6 +35,8 @@
>  #define HOSTAPD_CHAN_HT40MINUS 0x00000020
>  #define HOSTAPD_CHAN_HT40 0x00000040
> 
> +#define WPA_MONITOR_IFNAME_PREFIX      "m."

The monitor interface is specific to nl80211 and this does not belong in
driver.h.

> diff --git a/wpa_supplicant/p2p_supplicant.c
> @@ -803,7 +803,7 @@ static int wpas_p2p_add_group_interface(struct
> wpa_supplicant *wpa_s,
> 
>         os_snprintf(ifname, sizeof(ifname), "p2p-%s-%d", wpa_s->ifname,
>                     wpa_s->p2p_group_idx);
> -       if (os_strlen(ifname) >= IFNAMSIZ &&
> +       if (os_strlen(ifname) + os_strlen(WPA_MONITOR_IFNAME_PREFIX)  >=
> IFNAMSIZ &&
>             os_strlen(wpa_s->ifname) < IFNAMSIZ) {

This code needs to be generic, i.e., it cannot depend on any specific
driver wrapper like driver_nl80211.c (which is where that
WPA_MONITOR_IFNAME_PREFIX belongs to). As such, if there is really need
for doing this, the driver wrapper API would need to be extended to
provide a capability information in struct wpa_driver_capa to indicate
maximum length of the interface name.

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the Hostap mailing list