odhcp6c: switch to userspace RA-handling and offload address assignment to netifd
authorSteven Barth <cyrus@openwrt.org>
Fri, 1 Feb 2013 12:28:39 +0000 (12:28 +0000)
committerSteven Barth <cyrus@openwrt.org>
Fri, 1 Feb 2013 12:28:39 +0000 (12:28 +0000)
SVN-Revision: 35419

package/network/ipv6/odhcp6c/Makefile
package/network/ipv6/odhcp6c/files/dhcpv6.script
package/network/ipv6/odhcp6c/files/dhcpv6.sh

index 6ac2c67f72289f8632a06ced78974bbae4ad5be7..7b616c9c91c1706d51c9755dee53adb9ca63e32a 100644 (file)
@@ -8,14 +8,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=odhcp6c
-PKG_VERSION:=2013-01-29
+PKG_VERSION:=2013-02-01
 PKG_RELEASE=$(PKG_SOURCE_VERSION)
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
 PKG_SOURCE_URL:=git://github.com/sbyx/odhcp6c.git
 PKG_SOURCE_PROTO:=git
-PKG_SOURCE_VERSION:=770741e98f2569ec0b00251ba9bf17a92e89221e
+PKG_SOURCE_VERSION:=7b3e29a4ff20f1b1e91fa65b5a0631462dbee06d
 PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
 
 include $(INCLUDE_DIR)/package.mk
index be91d164227845ee459eec990553e9012e45ce05..1f019353d5011c6dfa99cc019c82b86d73503707 100755 (executable)
@@ -3,33 +3,19 @@
 . /lib/functions.sh
 . /lib/netifd/netifd-proto.sh
 
-ipv6_conf() {
-       echo "$3" > "/proc/sys/net/ipv6/conf/$1/$2"
-}
-
-prepare_interface() {
-       local device="$1"
-       ipv6_conf "$device" accept_ra 2
-
-       # Send RS
-       if [ -x /usr/sbin/6relayd ]; then
-               sleep 1
-               /usr/sbin/6relayd -s "$device"
-               sleep 4
-               /usr/sbin/6relayd -s "$device"
-       fi
-
-}
-
-cleanup_interface() {
-       local device="$1"
-       ipv6_conf "$device" accept_ra 0
-}
-
 setup_interface () {
        local device="$1"
        proto_init_update "*" 1
 
+       # Merge RA-DNS
+       for radns in $RA_DNS; do
+               local duplicate=0
+               for dns in $RDNSS; do
+                       [ "$radns" = "$dns" ] && duplicate=1
+               done
+               [ "$duplicate" = 0 ] && RDNSS="$RDNSS $radns"
+       done
+
        for dns in $RDNSS; do
                proto_add_dns_server "$dns"
        done
@@ -42,6 +28,43 @@ setup_interface () {
                proto_add_ipv6_prefix "$prefix"
        done
 
+       # Merge addresses
+       for entry in $RA_ADDRESSES; do
+               local duplicate=0
+               local addr="${entry%%/*}"
+               for dentry in $ADDRESSES; do
+                       local daddr="${dentry%%/*}"
+                       [ "$addr" = "$daddr" ] && duplicate=1
+               done
+               [ "$duplicate" = "0" ] && ADDRESSES="$ADDRESSES $entry"
+       done
+
+       for entry in $ADDRESSES; do
+               local addr="${entry%%/*}"
+               entry="${entry#*/}"
+               local mask="${entry%%,*}"
+               entry="${entry#*,}"
+               local preferred="${entry%%,*}"
+               entry="${entry#*,}"
+               local valid="${entry%%,*}"
+
+               proto_add_ipv6_address "$addr" "$mask" "$preferred" "$valid" 1
+       done
+
+       for entry in $RA_ROUTES; do
+               local addr="${entry%%/*}"
+               entry="${entry#*/}"
+               local mask="${entry%%,*}"
+               entry="${entry#*,}"
+               local gw="${entry%%,*}"
+               entry="${entry#*,}"
+               local valid="${entry%%,*}"
+               entry="${entry#*,}"
+               local metric="${entry%%,*}"
+
+               proto_add_ipv6_route "$addr" "$mask" "$gw" "$metric" "$valid"
+       done
+
        proto_send_update "$INTERFACE"
 
        # TODO: $SNTP_IP $SIP_IP $SNTP_FQDN $SIP_DOMAIN
@@ -53,12 +76,10 @@ teardown_interface() {
 }
 
 case "$2" in
-       informed|bound|updated|rebound)
+       informed|bound|updated|rebound|ra-updated)
                setup_interface "$1"
-               prepare_interface "$1"
        ;;
        started|stopped|unbound)
-               cleanup_interface "$1"
                teardown_interface "$1"
        ;;
 esac
index 14b6fb63b44588ea4707ec8bf1c641761d48e6c9..99867cd99dcbedb6514fa7ccbbaf4a7878dfa340 100755 (executable)
@@ -9,14 +9,15 @@ proto_dhcpv6_init_config() {
        proto_config_add_string "reqprefix"
        proto_config_add_string "clientid"
        proto_config_add_string "reqopts"
+       proto_config_add_string "allow_slaaconly"
 }
 
 proto_dhcpv6_setup() {
        local config="$1"
        local iface="$2"
 
-       local reqaddress reqprefix clientid reqopts
-       json_get_vars reqaddress reqprefix clientid reqopts
+       local reqaddress reqprefix clientid reqopts allow_slaaconly
+       json_get_vars reqaddress reqprefix clientid reqopts allow_slaaconly
 
 
        # Configure
@@ -28,6 +29,8 @@ proto_dhcpv6_setup() {
 
        [ -n "$clientid" ] && append opts "-c$clientid"
 
+       [ "$allow_slaaconly" = "1" ] && append opts "-S"
+
        for opt in $reqopts; do
                append opts "-r$opt"
        done