P2P: Rename the group interface name to use p2p- prefix
authorJouni Malinen <jouni.malinen@atheros.com>
Fri, 26 Nov 2010 13:50:22 +0000 (15:50 +0200)
committerJouni Malinen <j@w1.fi>
Fri, 26 Nov 2010 13:50:22 +0000 (15:50 +0200)
This may make it less likely for udev to rename the interface that
would previously have been called wlan0-p2p-# (now: p2p-wlan0-#).
In addition, add some workaround code to handle the case where the
main interface name is close to the IFNAMSIZ length limit to
avoid going over that for the P2P group interface.

wpa_supplicant/p2p_supplicant.c

index a641858..0177449 100644 (file)
@@ -928,8 +928,14 @@ static int wpas_p2p_add_group_interface(struct wpa_supplicant *wpa_s,
                return 0;
        }
 
-       os_snprintf(ifname, sizeof(ifname), "%s-p2p-%d", wpa_s->ifname,
+       os_snprintf(ifname, sizeof(ifname), "p2p-%s-%d", wpa_s->ifname,
                    wpa_s->p2p_group_idx);
+       if (os_strlen(ifname) >= IFNAMSIZ &&
+           os_strlen(wpa_s->ifname) < IFNAMSIZ) {
+               /* Try to avoid going over the IFNAMSIZ length limit */
+               os_snprintf(ifname, sizeof(ifname), "p2p-%d",
+                           wpa_s->p2p_group_idx);
+       }
        force_ifname[0] = '\0';
 
        wpa_printf(MSG_DEBUG, "P2P: Create a new interface %s for the group",