Browse Source

gluon-next-node: mark local-node ip6 as deprecated

Prevent the local-node ip6 from being eligible for source address
selection. This is highly undesireable in a layer 3 mesh.
Nils Schneider 8 years ago
parent
commit
872d0690cd

+ 1 - 0
docs/index.rst

@@ -54,6 +54,7 @@ Packages
    package/gluon-config-mode-geo-location
    package/gluon-ebtables-filter-multicast
    package/gluon-ebtables-filter-ra-dhcp
+   package/gluon-next-node
 
 Releases
 --------

+ 21 - 0
docs/package/gluon-next-node.rst

@@ -0,0 +1,21 @@
+gluon-next-node
+===============
+
+This package provides a virtual interface (tied to *br-client*) called *local-node*
+using the same MAC, IP4 and IP6 across all nodes in a mesh. Thus, the node that
+the client is currently connected to, can always be reached under a known address.
+
+The IP6 is marked es deprecated to prevent it from being used as a source
+address for packages originating from a node.
+
+site.conf
+---------
+
+next_node.mac
+    MAC to be set on the interface.
+
+next_node.ip4
+    IP4 to be set on the interface.
+
+next_node.ip6
+    IP6 to be set on the interface.

+ 17 - 8
package/gluon-next-node/files/lib/gluon/upgrade/400-next-node

@@ -19,14 +19,23 @@ c:section('network', 'device', 'local_node_dev',
 
 local prefix4 = ip.IPv4(site.prefix4)
 c:delete('network', 'local_node')
-c:section('network', 'interface', 'local_node',
-	  {
-		  ifname = 'local-node',
-		  proto = 'static',
-		  ipaddr = site.next_node.ip4,
-		  netmask = prefix4:mask():string(),
-		  ip6addr = site.next_node.ip6 .. '/128',
-	  }
+c:delete('network', 'local_node4')
+c:delete('network', 'local_node6')
+
+c:section('network', 'interface', 'local_node4',
+         {
+           ifname = 'local-node',
+           proto = 'static',
+           ipaddr = site.next_node.ip4 .. '/32',
+         }
+)
+
+c:section('network', 'interface', 'local_node6',
+         {
+           ifname = 'local-node',
+           proto = 'static_deprecated',
+           ip6addr = site.next_node.ip6,
+         }
 )
 
 c:delete('network', 'local_node_route6')

+ 30 - 0
package/gluon-next-node/files/lib/netifd/proto/static_deprecated.sh

@@ -0,0 +1,30 @@
+#!/bin/sh
+
+. /lib/functions.sh
+. ../netifd-proto.sh
+init_proto "$@"
+
+proto_static_deprecated_init_config() {
+	renew_handler=1
+
+	proto_config_add_string 'ip6addr:ip6addr'
+}
+
+proto_static_deprecated_setup() {
+	local config="$1"
+	local iface="$2"
+
+	local ip6addr
+	json_get_vars ip6addr
+
+	proto_init_update "*" 1
+	proto_add_ipv6_address "$ip6addr" "" "0"
+	proto_send_update "$config"
+}
+
+proto_static_deprecated_teardown() {
+	local config="$1"
+}
+
+add_protocol static_deprecated
+