[PATCH] interface name size limit for Monitor interface

JJ mails4jj
Sun Oct 9 21:59:53 PDT 2011


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."].

---
 src/drivers/driver.h            |    2 ++
 src/drivers/driver_nl80211.c    |    2 +-
 wpa_supplicant/p2p_supplicant.c |    2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/drivers/driver.h b/src/drivers/driver.h
index f51df4e..c52cae4 100644
--- 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."
+
 /**
  * struct hostapd_channel_data - Channel information
  */
diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 6dfad0a..031b40b 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -4698,7 +4698,7 @@ nl80211_create_monitor_interface(struct
wpa_driver_nl80211_data *drv)
        int optval;
        socklen_t optlen;

-       snprintf(buf, IFNAMSIZ, "mon.%s", drv->first_bss.ifname);
+       snprintf(buf, IFNAMSIZ, "%s%s", WPA_MONITOR_IFNAME_PREFIX,
drv->first_bss.ifname);
        buf[IFNAMSIZ - 1] = '\0';

        drv->monitor_ifidx =
diff --git a/wpa_supplicant/p2p_supplicant.c
b/wpa_supplicant/p2p_supplicant.c
index 92bfc41..fa18d64 100644
--- a/wpa_supplicant/p2p_supplicant.c
+++ b/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) {
                /* Try to avoid going over the IFNAMSIZ length limit */
                os_snprintf(ifname, sizeof(ifname), "p2p-%d",
-- 
1.7.4.1



- Jithu Jance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.shmoo.com/pipermail/hostap/attachments/20111010/c6e6dab6/attachment.htm 



More information about the Hostap mailing list