From 4516520cf20122c4001b698372de45cf416ce226 Mon Sep 17 00:00:00 2001 From: Ahmed Mokhtar Date: Wed, 17 Sep 2014 04:15:34 +0300 Subject: [PATCH 1/3] Fix virtual drive auto-renaming In some Linux distributions (e.g. Ubuntu, Debian), udev automatically renames any device with its name prefix is "eth*", "wlan*",... as declared in "/lib/udev/rules.d/75-persistent-net-generator.rules". This made a problem when creating a virtual device on these distributions declaring that device not found. Solution was to change virtual device's name prefix to "ap*" to avoid this collision. --- create_ap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_ap b/create_ap index 947f2b7..61e1c86 100755 --- a/create_ap +++ b/create_ap @@ -654,7 +654,7 @@ CONFDIR=$(mktemp -d /tmp/create_ap.${WIFI_IFACE}.conf.XXXXXXXX) echo "Config dir: $CONFDIR" if [[ $NO_VIRT -eq 0 ]]; then - VWIFI_IFACE=${WIFI_IFACE}ap + VWIFI_IFACE=ap${WIFI_IFACE} # in NetworkManager 0.9.10 and above we can set the interface as unmanaged without # the need of MAC address, so we set it before we create the virtual interface. From f589df0565b6373a00018648d6f330d4d8c30be2 Mon Sep 17 00:00:00 2001 From: Ahmed Mokhtar Date: Wed, 17 Sep 2014 16:52:37 +0300 Subject: [PATCH 2/3] Using virtual interface names "ap*" --- create_ap | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/create_ap b/create_ap index 61e1c86..d223ab7 100755 --- a/create_ap +++ b/create_ap @@ -654,7 +654,14 @@ CONFDIR=$(mktemp -d /tmp/create_ap.${WIFI_IFACE}.conf.XXXXXXXX) echo "Config dir: $CONFDIR" if [[ $NO_VIRT -eq 0 ]]; then - VWIFI_IFACE=ap${WIFI_IFACE} + i=0 + while :; do + if [[ ! -d /sys/class/net/ap${i} ]]; then + VWIFI_IFACE=ap${i} + break + fi + i=$((i+1)) + done # in NetworkManager 0.9.10 and above we can set the interface as unmanaged without # the need of MAC address, so we set it before we create the virtual interface. From 04c5695c8ee9710dbd34153e666b0285ce63f27e Mon Sep 17 00:00:00 2001 From: Ahmed Mokhtar Date: Thu, 18 Sep 2014 01:54:27 +0300 Subject: [PATCH 3/3] Update create_ap --- create_ap | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/create_ap b/create_ap index d223ab7..8143347 100755 --- a/create_ap +++ b/create_ap @@ -196,6 +196,17 @@ get_avail_bridge() { done } +get_virt_iface_name() { + i=0 + while :; do + if [[ ! -d /sys/class/net/ap${i} ]]; then + echo ap${i} + break + fi + i=$((i+1)) + done +} + get_new_macaddr() { OLDMAC=$(get_macaddr "$1") for i in {20..255}; do @@ -654,14 +665,7 @@ CONFDIR=$(mktemp -d /tmp/create_ap.${WIFI_IFACE}.conf.XXXXXXXX) echo "Config dir: $CONFDIR" if [[ $NO_VIRT -eq 0 ]]; then - i=0 - while :; do - if [[ ! -d /sys/class/net/ap${i} ]]; then - VWIFI_IFACE=ap${i} - break - fi - i=$((i+1)) - done + VWIFI_IFACE=$(get_virt_iface_name) # in NetworkManager 0.9.10 and above we can set the interface as unmanaged without # the need of MAC address, so we set it before we create the virtual interface.