odhcp6c: add route-workaround for broken IPv6-ISPs
authorSteven Barth <cyrus@openwrt.org>
Wed, 8 Oct 2014 10:00:36 +0000 (10:00 +0000)
committerSteven Barth <cyrus@openwrt.org>
Wed, 8 Oct 2014 10:00:36 +0000 (10:00 +0000)
Some ISP seem to only do stateful DHCPv6 and not sending RAs.
This is technically broken because plain DHCPv6 doesn't carry routes.

We work around here by faking a default route to the DHCPv6 server
if we do not receive a useful RA from the ISP.

This workaround can be turned off with: option fakeroutes 0

Signed-off-by: Steven Barth <steven@midlink.org>
SVN-Revision: 42842

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

index be9c4df6fba18b230e64934e32608a179350cf9c..c7b16319c35879dd7b1a75c4298eae7d25e212cb 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2012 OpenWrt.org
+# Copyright (C) 2012-2014 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -8,14 +8,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=odhcp6c
-PKG_VERSION:=2014-09-27
+PKG_VERSION:=2014-10-06
 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:=3e52a1448eee0fbf7ff67c123265bedcbc9c26d0
+PKG_SOURCE_VERSION:=d6fe99f6d03873e7a670c9b6f26fa03b219422f5
 PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
 
 include $(INCLUDE_DIR)/package.mk
index 5ab9a1eb639573ba3dac96f44ce3e96fa59b468a..37e67bfe522b1dbfdd5c891de69589a8712bdc3d 100755 (executable)
@@ -26,6 +26,15 @@ setup_interface () {
 
        for prefix in $PREFIXES; do
                proto_add_ipv6_prefix "$prefix"
+                local entry="${prefix#*/}"
+                entry="${entry#*,}"
+                entry="${entry#*,}"
+                local valid="${entry%%,*}"
+
+               if [ -z "$RA_ADDRESSES" -a -z "$RA_ROUTES" -a \
+                               -z "$RA_DNS" -a "$FAKE_ROUTES" = 1 ]; then
+                       RA_ROUTES="::/0,$SERVER,$valid,4096"
+               fi
        done
 
        [ -n "$USERPREFIX" ] && proto_add_ipv6_prefix "$USERPREFIX"
@@ -51,6 +60,11 @@ setup_interface () {
                local valid="${entry%%,*}"
 
                proto_add_ipv6_address "$addr" "$mask" "$preferred" "$valid" 1
+
+                if [ -z "$RA_ADDRESSES" -a -z "$RA_ROUTES" -a \
+                                -z "$RA_DNS" -a "$FAKE_ROUTES" = 1 ]; then
+                        RA_ROUTES="::/0,$SERVER,$valid,4096"
+                fi
        done
 
        for entry in $RA_ROUTES; do
index 0690bd15e50b63c956b77a3b318bcb26ee47fa13..5914abe0bb61632b528336b77b0c0899b72301af 100755 (executable)
@@ -26,14 +26,15 @@ proto_dhcpv6_init_config() {
        proto_config_add_string "vendorclass"
        proto_config_add_boolean delegate
        proto_config_add_int "soltimeout"
+       proto_config_add_boolean fakeroutes
 }
 
 proto_dhcpv6_setup() {
        local config="$1"
        local iface="$2"
 
-       local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout
-       json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout
+       local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout fakeroutes
+       json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout fakeroutes
 
 
        # Configure
@@ -72,6 +73,7 @@ proto_dhcpv6_setup() {
        [ -n "$zone_dslite" ] && proto_export "ZONE_DSLITE=$zone_dslite"
        [ -n "$zone_map" ] && proto_export "ZONE_MAP=$zone_map"
        [ -n "$zone" ] && proto_export "ZONE=$zone"
+       [ "$fakeroutes" != "0" ] && proto_export "FAKE_ROUTES=1"
 
        proto_export "INTERFACE=$config"
        proto_run_command "$config" odhcp6c \