summaryrefslogtreecommitdiff
path: root/package/network/ipv6/odhcp6c/files
diff options
context:
space:
mode:
authorcyrus <cyrus@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-02-01 12:28:39 +0000
committercyrus <cyrus@3c298f89-4303-0410-b956-a3cf2f4a3e73>2013-02-01 12:28:39 +0000
commit992bb055a66b9de1597af6f0af26ae2bdda02518 (patch)
tree68410b5f5fa621036a1c3395cb38acf4a3fdae6d /package/network/ipv6/odhcp6c/files
parenta79dba6d87d97b80fbb06bcefd3f6f826dcc6b9a (diff)
odhcp6c: switch to userspace RA-handling and offload address assignment to netifd
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@35419 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network/ipv6/odhcp6c/files')
-rwxr-xr-xpackage/network/ipv6/odhcp6c/files/dhcpv6.script73
-rwxr-xr-xpackage/network/ipv6/odhcp6c/files/dhcpv6.sh7
2 files changed, 52 insertions, 28 deletions
diff --git a/package/network/ipv6/odhcp6c/files/dhcpv6.script b/package/network/ipv6/odhcp6c/files/dhcpv6.script
index be91d16422..1f019353d5 100755
--- a/package/network/ipv6/odhcp6c/files/dhcpv6.script
+++ b/package/network/ipv6/odhcp6c/files/dhcpv6.script
@@ -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
diff --git a/package/network/ipv6/odhcp6c/files/dhcpv6.sh b/package/network/ipv6/odhcp6c/files/dhcpv6.sh
index 14b6fb63b4..99867cd99d 100755
--- a/package/network/ipv6/odhcp6c/files/dhcpv6.sh
+++ b/package/network/ipv6/odhcp6c/files/dhcpv6.sh
@@ -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