Procházet zdrojové kódy

tayga: allow more flexible routing

In some scenarios (e.g. 464xlat) it is desirable to not route the mapped
prefix to tayga's interface. This adds an option 'noroutes' which, when
set to 1, will prevent such routes from being added.

Signed-off-by: Nils Schneider <nils@nilsschneider.net>
Nils Schneider před 10 roky
rodič
revize
7d153edb7d
1 změnil soubory, kde provedl 16 přidání a 12 odebrání
  1. 16
    12
      ipv6/tayga/files/tayga-proto.sh

+ 16
- 12
ipv6/tayga/files/tayga-proto.sh Zobrazit soubor

@@ -14,8 +14,8 @@ proto_tayga_setup() {
14 14
 	local iface="$2"
15 15
 	local link="tayga-$cfg"
16 16
 
17
-	local ipv4_addr ipv6_addr prefix dynamic_pool ipaddr ip6addr
18
-	json_get_vars ipv4_addr ipv6_addr prefix dynamic_pool ipaddr ip6addr
17
+	local ipv4_addr ipv6_addr prefix dynamic_pool ipaddr ip6addr noroutes
18
+	json_get_vars ipv4_addr ipv6_addr prefix dynamic_pool ipaddr ip6addr noroutes
19 19
 	[ -z "$ipv4_addr" -o -z "$prefix" ] && {
20 20
 		proto_notify_error "$cfg" "REQUIRED_PARAMETERS_MISSING"
21 21
 		proto_block_restart "$cfg"
@@ -49,16 +49,19 @@ proto_tayga_setup() {
49 49
 
50 50
 	[ -n "$ipaddr" ]  && proto_add_ipv4_address "$ipaddr" "255.255.255.255"
51 51
 	[ -n "$ip6addr" ] && proto_add_ipv6_address "$ip6addr" "128"
52
-	[ -n "$ipv6_addr" ] && proto_add_ipv6_route "$ipv6_addr" "128"
53
-	[ -n "$dynamic_pool" ] && {
54
-		local pool="${dynamic_pool%%/*}"
55
-		local mask="${dynamic_pool##*/}"
56
-		proto_add_ipv4_route "$pool" "$mask"
57
-	}
58
-	[ -n "$prefix" ] && {
59
-		local prefix6="${prefix%%/*}"
60
-		local mask6="${prefix##*/}"
61
-		proto_add_ipv6_route "$prefix6" "$mask6"
52
+
53
+	[ "$noroutes" != 1 ] && {
54
+		[ -n "$ipv6_addr" ] && proto_add_ipv6_route "$ipv6_addr" "128"
55
+		[ -n "$dynamic_pool" ] && {
56
+			local pool="${dynamic_pool%%/*}"
57
+			local mask="${dynamic_pool##*/}"
58
+			proto_add_ipv4_route "$pool" "$mask"
59
+		}
60
+		[ -n "$prefix" ] && {
61
+			local prefix6="${prefix%%/*}"
62
+			local mask6="${prefix##*/}"
63
+			proto_add_ipv6_route "$prefix6" "$mask6"
64
+		}
62 65
 	}
63 66
 
64 67
 	proto_send_update "$cfg"
@@ -85,6 +88,7 @@ proto_tayga_init_config() {
85 88
 	proto_config_add_string "dynamic_pool"
86 89
 	proto_config_add_string "ipaddr"
87 90
 	proto_config_add_string "ip6addr:ip6addr"
91
+	proto_config_add_boolean "noroutes"
88 92
 }
89 93
 
90 94
 [ -n "$INCLUDE_ONLY" ] || {