Package: ifupdown-scripts-zg2 / 0.6-1

debian-changes Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 ifupdown-scripts-zg2 (0.6-1) unstable; urgency=low
 .
   * add IPv6 support for addresses and routes
Author: Marc Haber <mh+debian-packages@zugschlus.de>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: http://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- ifupdown-scripts-zg2-0.6.orig/scripts/ifupdown-scripts-zg2.d/common-functions
+++ ifupdown-scripts-zg2-0.6/scripts/ifupdown-scripts-zg2.d/common-functions
@@ -16,7 +16,10 @@ me="$0"
 [ ${IF_DEBUG:-} ] && echo "$me $IFACE $MODE debug"
 
 [ "$METHOD" = "manual" ] || exit 0
-[ "$ADDRFAM" = "inet" ] || exit 0
+
+if [ "$ADDRFAM" != "inet" ] && [ "$ADDRFAM" != "inet6" ]; then
+  exit 0
+fi
 
 # common functions for interface scripts
 
@@ -277,10 +280,10 @@ get_if_mac()
 addrtype()
 {
   ADDR="$1"
-  if echo $ADDR | grep -q '^[0-9\.]\+$'; then
+  if echo $ADDR | grep -q '^[0-9\./]\+$'; then
     echo "v4"
     return 0
-  elif echo $ADDR | grep -q '^[0-9a-fA-F\:]\+$'; then
+  elif echo $ADDR | grep -q '^[0-9a-fA-F\:/]\+$'; then
     echo "v6"
     return 0
   else
--- ifupdown-scripts-zg2-0.6.orig/scripts/ifupdown-scripts-zg2.d/address
+++ ifupdown-scripts-zg2-0.6/scripts/ifupdown-scripts-zg2.d/address
@@ -10,18 +10,43 @@
 # IF_BRD     = broadcast address (all1 default, all0/none allowed)
 # IF_FLAGS   = "secondary"
 # IF_LABEL   = set label (1 default)
+# IF_FORCE_IPV6_RD  = force IPv6 Router Discovery before initializing
 # IF_WAIT_TENTATIVE = wait for non-tentative IP addresses (1 default)
 # IF_PREFLFT = preferred lifetime
 
 . /etc/network/ifupdown-scripts-zg2.d/common-functions
 
 # check that an address has been configured for this interface
-# TODO: Maybe check if it actually looks like an IP address?
 [ -z "${IF_ADDRESS:-}" ] && exit 0
+ADDRTYPE="$(addrtype $IF_ADDRESS)"
+if [ "$ADDRTYPE" != "v4" ] && [ "$ADDRTYPE" != "v6" ]; then
+  abort "address $IF_ADDRESS does not look like an IP address"
+fi
 
 case "$MODE" in
   start)
-  
+
+    # send IPv6 router discovery, making sure that we learn addresses
+    if [ "${IF_FORCE_IPV6_RD:-0}" = "1" ]; then
+      if command -v rdisc6 > /dev/null; then
+        loop=2
+        while ! rdisc6 --retry 1 --wait 2000 --single --quiet $IF_DEVICE >/dev/null 2>/dev/null; do
+	  if [ $loop -eq 2 ]; then
+            verbose "retrying IPv6 RD"
+          fi
+          if [ $loop -eq 0 ]; then
+            verbose "giving up on IPv6 RD"
+	    rdisc6 --retry 1 --wait 2000 --single $IF_DEVICE 
+	    break
+          fi
+          sleep 1
+          loop=$(($loop-1))
+        done
+      else
+        abort "force-ipv6-rd needs the ndisc6 package"
+      fi
+    fi
+
     # build address parameters, parse flags
   
     ADDRPARM="dev $IF_DEVICE"