[Glibc-bsd-commits] r3271 - in trunk/freebsd-utils/debian: . scripts/sbin

Petr Salinger ps-guest at alioth.debian.org
Sat Feb 19 17:54:15 UTC 2011


Author: ps-guest
Date: 2011-02-19 17:54:12 +0000 (Sat, 19 Feb 2011)
New Revision: 3271

Modified:
   trunk/freebsd-utils/debian/changelog
   trunk/freebsd-utils/debian/scripts/sbin/route
Log:
Add IPv6 support into route wrapper, provided by Mats Erik Andersson.                     



Modified: trunk/freebsd-utils/debian/changelog
===================================================================
--- trunk/freebsd-utils/debian/changelog	2011-02-17 10:05:33 UTC (rev 3270)
+++ trunk/freebsd-utils/debian/changelog	2011-02-19 17:54:12 UTC (rev 3271)
@@ -2,6 +2,8 @@
 
   [ Petr Salinger ]
   * Based on FreeBSD 8.2.
+  * Add IPv6 support into route wrapper, provided by Mats Erik Andersson.
+    Closes: #605723.
 
   [ Robert Millan ]
   * Require kfreebsd-kernel-headers >= 0.54.

Modified: trunk/freebsd-utils/debian/scripts/sbin/route
===================================================================
--- trunk/freebsd-utils/debian/scripts/sbin/route	2011-02-17 10:05:33 UTC (rev 3270)
+++ trunk/freebsd-utils/debian/scripts/sbin/route	2011-02-19 17:54:12 UTC (rev 3271)
@@ -1,32 +1,109 @@
 #!/bin/sh
+#
+# /sbin/route
+#
+# Wrapper script around /lib/freebsd/route
+# crafted to catch the routing commands issued
+# by /sbin/ifup and /sbin/ifdown, translating
+# them into valid FreeBSD commands, at the same
+# time preserving all BSD native routing input.
+#
+# Authors: Axel Beckert, Mats Erik Andersson
+
 set -e
 
 if [ $# = 0 ] ; then
+  # Issue usage info
   /lib/freebsd/route
 fi
 
 args=""
 
-cmd="$1"
-shift
+# Capture all options first. Save them for later.
+# One Debian endemic addition: -A family.
+# Typically: -A inet6
+#
+opts=""
+af=""
 
 while [ $# -gt 0 ]; do
   case "$1" in
-    default)
+    -*)
+      # One Debian addition.
+      if [ "$1" = "-A" ] ; then
+        shift
+        if [ -n "$1" ] ; then
+          af="-$1"
+          shift
+          continue
+        fi
+        # Incorrect usage, call for help
+        /lib/freebsd/route
+      fi
+      # A native option remains
+      opts="${opts} $1"
       shift
-      if [ "$1" = "gw" ] ; then shift ; fi
-      args="${args} -net 0.0.0.0 $1"
-    ;;
-    *.*.*.*) args="${args} $1" ;;
-    *[0-9]) ;;
-    *) args="${args} $1" ;;
+      ;;
+    *)
+     # Must be the beginning of a command mode line.
+     break ;;
   esac
-  shift
 done
 
-if [ ${cmd} = "del" ] ; then
-  cmd=""
-  args="-q flush"
+cmd="$1"
+test $# -gt 0  &&  shift
+
+# Commands originating from ifupdown can only be
+# stated either for "add" or for "del".
+#
+# The commands from "ifupdown" are acceptable
+# as long as they do not contain the keyword "gw".
+# In case the command does so, then the very last
+# command line argument is the name of the interface.
+# We ignore it for now, since an interface specification
+# do not carry the same connotation in FreeBSD as it
+# does in GNU/Linux.
+#
+# The keyword "metric" seems unknown for FreeBSD,
+# so it is filtered off.
+
+if [ "$cmd" = "add" -o "$cmd" = "del" ] ; then
+  # Our simple state machine
+  HAVE_SEEN_GW=""
+
+  while [ $# -gt 0 ]; do
+    if [ -n "$HAVE_SEEN_GW" ] ; then
+      if [ $# -eq 1 ] ; then
+        # We have reached the end. An interface name
+        # appears as last argument, since we are in
+        # a state caused by a call from ifupdown.
+        # We simply discard the interface name.
+        break
+      fi
+      if [ "$1" = "metric" ] ; then
+        # Ignored, together with its argument
+        shift
+      else
+        args="${args} $1"
+      fi
+    else
+      # Ifup and ifdown use "gw" only in two forms.
+      if [ "$1" = "gw" -a \( $# -eq 3 -o \( $# -eq 5 -a "$3" = "metric" \) \) ]
+      then
+        # Change state and discard "gw",
+        # hoping that no administrator ever
+        # names a host or a network as "gw".
+        HAVE_SEEN_GW="YES"
+      else
+        # This ingredient is important. Add it.
+        args="${args} $1"
+      fi
+    fi
+    test $# -gt 0  &&  shift
+  done
+else
+  # Must have a native command, whatever the content.
+  args="$@"
 fi
 
-exec /lib/freebsd/route ${cmd} ${args} > /dev/null
+exec /lib/freebsd/route ${opts} ${cmd} ${af} ${args}




More information about the Glibc-bsd-commits mailing list