[radvd-devel-l] RemoveRoute option

Mark Smith radvd at 02a76c927861ca7413a122f2a73a0d37.nosense.org
Mon Mar 21 02:17:19 EDT 2011


Hi,

Following up from the DeprecatePrefix option, here is the equivalent
for Route Information Options. Here's the manual page text -

       RemoveRoute on|off

              Upon shutdown, announce this route with a zero second
              lifetime. This  should  cause the route to be immediately
              removed from the receiving end-nodes' route table.

              Default: on


It defaults to on as RFC4191 says the following in "4. Router
Configuration" - 

"
                                When ceasing to be an advertising
   interface and sending Router Advertisements with a Router Lifetime of
   zero, the Router Advertisement SHOULD also set the Route Lifetime to
   zero in all Route Information Options"


Patch against CVS revision 1.114. Attached as a file and shown below.

Regards,
Mark.

diff --git a/defaults.h b/defaults.h
index 0bf357b..d6fcdfe 100644
--- a/defaults.h
+++ b/defaults.h
@@ -62,6 +62,7 @@
 #define DFLT_AdvRouteLifetime(iface)	(3 * (iface)->MaxRtrAdvInterval)
 
 #define DFLT_AdvRoutePreference		0 /* medium*/
+#define DFLT_RemoveRouteFlag		1
 
 /* RDNSS */
 #define DFLT_AdvRDNSSLifetime(iface)			(iface)->MaxRtrAdvInterval
diff --git a/gram.y b/gram.y
index 2d13800..13a8887 100644
--- a/gram.y
+++ b/gram.y
@@ -111,6 +111,7 @@ static struct in6_addr get_prefix6(struct in6_addr const *addr, struct in6_addr
 
 %token		T_AdvRoutePreference
 %token		T_AdvRouteLifetime
+%token		T_RemoveRoute
 
 %token		T_AdvRDNSSPreference
 %token		T_AdvRDNSSOpenFlag
@@ -704,6 +705,10 @@ routeparms	: T_AdvRoutePreference SIGNEDNUMBER ';'
 		{
 			route->AdvRouteLifetime = $2;
 		}
+		| T_RemoveRoute SWITCH ';'
+		{
+			route->RemoveRouteFlag = $2;
+		}
 		;
 
 rdnssdef	: rdnsshead '{' optional_rdnssplist '}' ';'
diff --git a/interface.c b/interface.c
index 072f548..d7c0258 100644
--- a/interface.c
+++ b/interface.c
@@ -69,6 +69,7 @@ route_init_defaults(struct AdvRoute *route, struct Interface *iface)
 
 	route->AdvRouteLifetime = DFLT_AdvRouteLifetime(iface);
 	route->AdvRoutePreference = DFLT_AdvRoutePreference;
+	route->RemoveRouteFlag = DFLT_RemoveRouteFlag;
 }
 
 void
diff --git a/radvd.conf.5.man b/radvd.conf.5.man
index dcc4314..acd26ae 100644
--- a/radvd.conf.5.man
+++ b/radvd.conf.5.man
@@ -495,6 +495,13 @@ The preference associated with the default router, as either "low",
 
 Default: medium
 
+.TP
+.BR RemoveRoute " " on | off 
+
+Upon shutdown, announce this route with a zero second lifetime. This should cause the route to be immediately removed from the receiving end-nodes' route table.
+
+Default: on
+
 .SH RDNSS SPECIFIC OPTIONS
 
 .TP
diff --git a/radvd.h b/radvd.h
index 3b8b0e5..cdd679f 100644
--- a/radvd.h
+++ b/radvd.h
@@ -126,6 +126,7 @@ struct AdvRoute {
 
 	int			AdvRoutePreference;
 	uint32_t		AdvRouteLifetime;
+	int			RemoveRouteFlag;
 
 	struct AdvRoute		*next;
 };
diff --git a/scanner.l b/scanner.l
index b6ca361..01ea6d8 100644
--- a/scanner.l
+++ b/scanner.l
@@ -85,6 +85,7 @@ HomeAgentLifetime	{ return T_HomeAgentLifetime; }
 
 AdvRoutePreference	{ return T_AdvRoutePreference; }
 AdvRouteLifetime	{ return T_AdvRouteLifetime; }
+RemoveRoute		{ return T_RemoveRoute; }
 
 AdvRDNSSPreference 	{ return T_AdvRDNSSPreference; }
 AdvRDNSSOpen		{ return T_AdvRDNSSOpenFlag; }
diff --git a/send.c b/send.c
index cd8ef9f..46a9c92 100644
--- a/send.c
+++ b/send.c
@@ -234,7 +234,11 @@ send_ra(struct Interface *iface, struct in6_addr *dest)
 
 		rinfo->nd_opt_ri_flags_reserved  =
 			(route->AdvRoutePreference << ND_OPT_RI_PRF_SHIFT) & ND_OPT_RI_PRF_MASK;
-		rinfo->nd_opt_ri_lifetime	= htonl(route->AdvRouteLifetime);
+		if (iface->cease_adv && route->RemoveRouteFlag) {
+			rinfo->nd_opt_ri_lifetime	= 0;
+		} else {
+			rinfo->nd_opt_ri_lifetime	= htonl(route->AdvRouteLifetime);
+		}
 
 		memcpy(&rinfo->nd_opt_ri_prefix, &route->Prefix,
 		       sizeof(struct in6_addr));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: removeroute.diff
Type: text/x-patch
Size: 3043 bytes
Desc: not available
URL: <http://lists.litech.org/pipermail/radvd-devel-l/attachments/20110321/b9688250/attachment.bin>


More information about the radvd-devel-l mailing list