From c6eea2102020a426e589125e5a50e41978924cf5 Mon Sep 17 00:00:00 2001 From: oblique Date: Thu, 28 Aug 2014 21:28:36 +0300 Subject: [PATCH] Change MAC address only if needed Some virtual interfaces have a different MAC address from their real interfaces and their drivers disallow us to change it. In this case we don't need to change the MAC address anyway. With this we can avoid errors like 'RTNETLINK answers: Invalid argument'. --- create_ap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/create_ap b/create_ap index 8d9c062..11a8bae 100755 --- a/create_ap +++ b/create_ap @@ -488,7 +488,7 @@ if [[ $NO_VIRT -eq 0 ]]; then die "$VIRTDIEMSG" fi OLD_MACADDR=$(get_macaddr ${VWIFI_IFACE}) - NEW_MACADDR=$(get_new_macaddr ${VWIFI_IFACE}) + [[ ${OLD_MACADDR} == $(get_macaddr ${WIFI_IFACE}) ]] && NEW_MACADDR=$(get_new_macaddr ${VWIFI_IFACE}) WIFI_IFACE=${VWIFI_IFACE} else [[ "$WIFI_IFACE" == "$INTERNET_IFACE" ]] && die "You can not share your connection from the same interface if you are using --no-virt option." @@ -553,7 +553,7 @@ EOF fi # initialize WiFi interface -if [[ $NO_VIRT -eq 0 ]]; then +if [[ $NO_VIRT -eq 0 && -n "$NEW_MACADDR" ]]; then ip link set dev ${WIFI_IFACE} address ${NEW_MACADDR} || die "$VIRTDIEMSG" fi ip link set down dev ${WIFI_IFACE} || die "$VIRTDIEMSG"