diff options
-rw-r--r-- | docs/netcfg-profiles.5.txt | 7 | ||||
-rwxr-xr-x | scripts/wifi-menu | 2 | ||||
-rw-r--r-- | src/connections/ethernet | 58 |
3 files changed, 41 insertions, 26 deletions
diff --git a/docs/netcfg-profiles.5.txt b/docs/netcfg-profiles.5.txt index c9a3380..daf2eb8 100644 --- a/docs/netcfg-profiles.5.txt +++ b/docs/netcfg-profiles.5.txt @@ -78,11 +78,11 @@ gain an IP address. IPv4 options ~~~~~~~~~~~~ +ADDR+ (requires +IP+ of `static'):: - A single IP address to configure a static IP. For example: + A single IP address to configure a static IP. +GATEWAY+ (requires +IP+ of `static'):: Set specified gateway +NETMASK+ (requires +IP+ of `static'):: - Set specified netmask. Defaults to 24 + Set specified netmask. Defaults to 24. +ROUTES+:: An array of custom routes (of the form _address range_ via _gateway_) @@ -98,6 +98,9 @@ IPv6 options The gateway address for IPv6 routing. +ROUTES6+:: An array of custom routes (of the form _address range_ via _gateway_) ++DAD_TIMEOUT+:: + Time to wait for Duplicate Address Detection to succeed. Defaults to + 3 seconds. DNS configuration ^^^^^^^^^^^^^^^^^ diff --git a/scripts/wifi-menu b/scripts/wifi-menu index 75bfede..96f6de1 100755 --- a/scripts/wifi-menu +++ b/scripts/wifi-menu @@ -203,7 +203,7 @@ fi cd / # We do not want to spawn anything that can block unmounting is_interface "$INTERFACE" || exit_fail "No such interface: $INTERFACE" -if [[ -z "$(ip link show up dev "$INTERFACE" 2> /dev/null)" ]]; then +if [[ -z "$(ip link show dev "$INTERFACE" up 2> /dev/null)" ]]; then [[ -f "$IFACE_DIR/$INTERFACE" ]] && . "$IFACE_DIR/$INTERFACE" bring_interface up "$INTERFACE" || exit_fail "Interface unavailable" SPAWNED_INTERFACE=1 diff --git a/src/connections/ethernet b/src/connections/ethernet index 41d0274..97875f8 100644 --- a/src/connections/ethernet +++ b/src/connections/ethernet @@ -14,6 +14,8 @@ report_iproute() } ethernet_up() { + local dad_timeout="${DAD_TIMEOUT:-3}" + load_profile "$1" SYSCTL_INTERFACE="${INTERFACE/.//}" @@ -23,7 +25,7 @@ ethernet_up() { fi fi - # Disable IPv6 before the interface to prevent SLAAC + # Disable IPv6 before bringing the interface up to prevent SLAAC if [[ "$IP6" == "no" ]]; then sysctl -q -w "net.ipv6.conf.$SYSCTL_INTERFACE.disable_ipv6=1" fi @@ -101,14 +103,6 @@ ethernet_up() { report_iproute "Could not configure interface" fi fi - if [[ -n "$ROUTES" ]]; then - for route in "${ROUTES[@]}"; do - report_debug ethernet_up ip route add $route dev "$INTERFACE" - if ! ip route add $route dev "$INTERFACE" ; then - report_iproute "Adding route '$route' failed" - fi - done - fi if [[ -n "$GATEWAY" ]]; then report_debug ethernet_up ip route add default via "$GATEWAY" dev "$INTERFACE" if ! ip route add default via "$GATEWAY" dev "$INTERFACE"; then @@ -123,12 +117,11 @@ ethernet_up() { ;; esac - if [[ -n "$IPCFG" ]]; then - for line in "${IPCFG[@]}"; do - - report_debug ethernet_up ip "$line" - if ! ip $line; then - report_iproute "Could not configure interface ($line)." + if [[ -n "$IP" && -n "$ROUTES" ]]; then + for route in "${ROUTES[@]}"; do + report_debug ethernet_up ip route add $route dev "$INTERFACE" + if ! ip route add $route dev "$INTERFACE"; then + report_iproute "Adding route '$route' failed" fi done fi @@ -175,9 +168,9 @@ ethernet_up() { sysctl -q -w "net.ipv6.conf.$SYSCTL_INTERFACE.accept_ra=0" if [[ -n "$ADDR6" ]]; then for addr in "${ADDR6[@]}"; do - report_debug ethernet_up ip -6 addr add "$addr" dev "$INTERFACE" - if ! ip -6 addr add "$addr" dev "$INTERFACE"; then - report_iproute "Could not add address $addr to interface" + report_debug ethernet_up ip -6 addr add $addr dev "$INTERFACE" + if ! ip -6 addr add $addr dev "$INTERFACE"; then + report_iproute "Could not add address '$addr' to interface" fi done fi @@ -187,18 +180,38 @@ ethernet_up() { report_iproute "Adding gateway $GATEWAY6 failed" fi fi + ;; + esac + + if [[ -n "$IP6" ]]; then + # Wait for DAD to finish (FS#28887) + report_debug ethernet_up ip -6 addr show dev "$INTERFACE" tentative + while [[ -n "$(ip -6 addr show dev "$INTERFACE" tentative)" ]]; do + if (( dad_timeout-- <= 0 )); then + report_iproute "Duplicate Address Detection is taking too long" + fi + sleep 1 + done # Add static IPv6 routes if [[ -n "$ROUTES6" ]]; then for route in "${ROUTES6[@]}"; do - report_debug ethernet_up ip -6 route add "$route" dev "$INTERFACE" - if ! ip -6 route add "$route" dev "$INTERFACE"; then + report_debug ethernet_up ip -6 route add $route dev "$INTERFACE" + if ! ip -6 route add $route dev "$INTERFACE"; then report_iproute "Adding route '$route' failed" fi done fi - ;; - esac + fi + + if [[ -n "$IPCFG" ]]; then + for line in "${IPCFG[@]}"; do + report_debug ethernet_up ip "$line" + if ! ip $line; then + report_iproute "Could not configure interface ($line)." + fi + done + fi # Set hostname if [[ -n "$HOSTNAME" ]]; then @@ -277,4 +290,3 @@ stop_80211x() { ethernet_$1 "$2" exit $? # vim: set ts=4 et sw=4: - |