server/admin.c: Remove spurious `ping' in usage message.
[tripe] / svc / tripe-ifup.in
index e92c0fd..63b5b2d 100644 (file)
@@ -46,11 +46,16 @@ fi
 peer=$1 ifname=$2 family=$3; shift 3
 
 ## Parse the address family.
+case "$family" in
+  INET) ipsz=20 ;;
+  INET6) ipsz=40 ;;
+  *) echo >&2 "$0: unknown address family $family"; exit 1 ;;
+esac
 case "$family,$#" in
-  INET,1) addr=$1 port=4070 ;;
-  INET,2) addr=$1 port=$2 ;;
-  INET,*) echo >&2 "$0: bad INET address"; exit 1 ;;
-  *)      echo >&2 "$0: unknown address family $family"; exit 1 ;;
+  INET,1 | INET6,1) addr=$1 port=4070 ;;
+  INET,2 | INET6,2) addr=$1 port=$2 ;;
+  INET,* | INET6,*) echo >&2 "$0: bad $family address"; exit 1 ;;
+  *) echo >&2 "$0: unknown address family $family"; exit 1 ;;
 esac
 
 ###--------------------------------------------------------------------------
@@ -108,13 +113,17 @@ haveaddr6=nil
 set -- $l6addr
 case $have6,$# in
   t,[1-9]*)
+
+    ## If we're configured to set IPv6 addresses then we should ensure that
+    ## they're going to work, even if the default setting for new interfaces
+    ## is to disable IPv6.
+    try sysctl -q net.ipv6.conf."$ifname".disable_ipv6=0
+
+    ## Now add the source and destination addresses.
     for a in "$@"; do
       try ip addr add "$a" dev "$ifname"
       haveaddr6=t
     done
-    case ${r6addr+set} in
-      set) try ip route add $r6addr proto static dev "$ifname" ;;
-    esac
     ;;
 esac
 
@@ -130,7 +139,7 @@ case $haveaddr4,$haveaddr6 in
        mtu=$P_MTU;;
       *)
        pathmtu=$(pathmtu "$addr")
-       mtu=$(expr "$pathmtu" - 29 - $A_BULK_OVERHEAD)
+       mtu=$(( $pathmtu - $ipsz - 9 - $A_BULK_OVERHEAD ))
        ;;
     esac
     try ip link set dev "$ifname" up mtu "$mtu"
@@ -138,6 +147,18 @@ case $haveaddr4,$haveaddr6 in
 esac
 
 ###--------------------------------------------------------------------------
+### Set the peer IPv6 address if any.
+
+## IPv6 point-to-point links seem broken in Linux.  Attach the local and
+## remote addresses by hand.
+set -- $l6addr
+case $have6,$#,${r6addr+set} in
+  t,[1-9]*,set)
+    try ip route add $r6addr proto static dev "$ifname"
+    ;;
+esac
+
+###--------------------------------------------------------------------------
 ### Set up routing.
 
 ## Split the routes into v4 and v6 lists.