odhcp6c: support multiple additional user prefixes
authorJo-Philipp Wich <jo@mein.io>
Wed, 14 Feb 2018 13:58:07 +0000 (14:58 +0100)
committerHans Dedecker <dedeckeh@gmail.com>
Sat, 24 Feb 2018 20:03:31 +0000 (21:03 +0100)
Support configuration in the form...

    list ip6prefix 2001:db8:1234::/64
    list ip6prefix 2001:db8:5678::/64

... to allow specifying multiple additional IPv6 prefixes.

Implements feature request FS#1361.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
package/network/ipv6/odhcp6c/Makefile
package/network/ipv6/odhcp6c/files/dhcpv6.script
package/network/ipv6/odhcp6c/files/dhcpv6.sh

index 9989f80f1a64ac2625370e460019be8aaba7d3f8..8abb63317fa750589c30b4809f741cde8cb9506e 100644 (file)
@@ -8,7 +8,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=odhcp6c
-PKG_RELEASE:=8
+PKG_RELEASE:=9
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL=$(PROJECT_GIT)/project/odhcp6c.git
index 03efaf7211bf07bd9e44a020b790dcbd83aec7fd..31710139665ae97b37e7cb540a888a22895a86a0 100755 (executable)
@@ -48,7 +48,9 @@ setup_interface () {
                fi
        done
 
-       [ -n "$USERPREFIX" ] && proto_add_ipv6_prefix "$USERPREFIX"
+       for prefix in $USERPREFIX; do
+               proto_add_ipv6_prefix "$prefix"
+       done
 
        # Merge addresses
        for entry in $RA_ADDRESSES; do
index 5c2ee6b988ca085337201a97ad8a80a1c9bb38e8..54e51065f65a79382d605999725fe6f26aa17095 100755 (executable)
@@ -16,7 +16,7 @@ proto_dhcpv6_init_config() {
        proto_config_add_string 'forceprefix:bool'
        proto_config_add_string 'extendprefix:bool'
        proto_config_add_string 'norelease:bool'
-       proto_config_add_string 'ip6prefix:ip6addr'
+       proto_config_add_array 'ip6prefix:list(ip6addr)'
        proto_config_add_string iface_dslite
        proto_config_add_string zone_dslite
        proto_config_add_string iface_map
@@ -36,12 +36,17 @@ proto_dhcpv6_init_config() {
        proto_config_add_int "ra_holdoff"
 }
 
+proto_dhcpv6_add_prefix() {
+       append "$3" "$1"
+}
+
 proto_dhcpv6_setup() {
        local config="$1"
        local iface="$2"
 
-       local reqaddress reqprefix clientid reqopts defaultreqopts noslaaconly forceprefix extendprefix norelease ip6prefix iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass sendopts delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter keep_ra_dnslifetime ra_holdoff
-       json_get_vars reqaddress reqprefix clientid reqopts defaultreqopts noslaaconly forceprefix extendprefix norelease ip6prefix iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter keep_ra_dnslifetime ra_holdoff
+       local reqaddress reqprefix clientid reqopts defaultreqopts noslaaconly forceprefix extendprefix norelease ip6prefix ip6prefixes iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass sendopts delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter keep_ra_dnslifetime ra_holdoff
+       json_get_vars reqaddress reqprefix clientid reqopts defaultreqopts noslaaconly forceprefix extendprefix norelease iface_dslite iface_map iface_464xlat ifaceid userclass vendorclass delegate zone_dslite zone_map zone_464xlat zone soltimeout fakeroutes sourcefilter keep_ra_dnslifetime ra_holdoff
+       json_for_each_item proto_dhcpv6_add_prefix ip6prefix ip6prefixes
 
        # Configure
        local opts=""
@@ -84,7 +89,7 @@ proto_dhcpv6_setup() {
 
        append opts "-t${soltimeout:-120}"
 
-       [ -n "$ip6prefix" ] && proto_export "USERPREFIX=$ip6prefix"
+       [ -n "$ip6prefixes" ] && proto_export "USERPREFIX=$ip6prefixes"
        [ -n "$iface_dslite" ] && proto_export "IFACE_DSLITE=$iface_dslite"
        [ -n "$iface_map" ] && proto_export "IFACE_MAP=$iface_map"
        [ -n "$iface_464xlat" ] && proto_export "IFACE_464XLAT=$iface_464xlat"