Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Mar 2008 14:40:39 +1100 (EST)
From:      Mark Andrews <marka@isc.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/121895: rtsol/rtsold doesn't handle managed networks [patch]
Message-ID:  <200803200340.m2K3ed85014227@drugs.dv.isc.org>
Resent-Message-ID: <200803200350.m2K3o1Y6088559@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         121895
>Category:       bin
>Synopsis:       rtsol/rtsold doesn't handle managed networks [patch]
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 20 03:50:00 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Mark Andrews
>Release:        FreeBSD 6.3-PRERELEASE i386
>Organization:
ISC
>Environment:
System: FreeBSD drugs.dv.isc.org 6.3-PRERELEASE FreeBSD 6.3-PRERELEASE #18: Mon Dec 10 14:45:13 EST 2007 marka@drugs.dv.isc.org:/usr/obj/usr/src/sys/DRUGS i386


>Description:

	rtsol/rtsold doesn't handle managed networks

>How-To-Repeat:

>Fix:

Index: dump.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/rtsold/dump.c,v
retrieving revision 1.9
diff -u -r1.9 dump.c
--- dump.c	14 Jan 2004 17:16:19 -0000	1.9
+++ dump.c	20 Mar 2008 03:09:04 -0000
@@ -77,6 +77,8 @@
 		    ifinfo->active > 0 ? "active" : "inactive");
 		fprintf(fp, "  other config: %s\n",
 		    ifinfo->otherconfig ? "on" : "off");
+		fprintf(fp, "  managed config: %s\n",
+		    ifinfo->managedconfig ? "on" : "off");
 		fprintf(fp, "  rtsold status: %s\n", ifstatstr[ifinfo->state]);
 		fprintf(fp, "  carrier detection: %s\n",
 		    ifinfo->mediareqok ? "available" : "unavailable");
Index: rtsol.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/rtsold/rtsol.c,v
retrieving revision 1.11
diff -u -r1.11 rtsol.c
--- rtsol.c	14 Jan 2004 17:16:19 -0000	1.11
+++ rtsol.c	20 Mar 2008 03:35:38 -0000
@@ -339,6 +339,19 @@
 
 	nd_ra = (struct nd_router_advert *)icp;
 
+#define RABOTH (ND_RA_FLAG_OTHER|ND_RA_FLAG_MANAGED)
+	/*
+	 * Having both O and M set is undefined.
+	 */
+	if ((nd_ra->nd_ra_flags_reserved & RABOTH) == RABOTH) {
+		warnmsg(LOG_INFO, __func__,
+		    "received RA from %s on IF(%s) with O and M set",
+		    inet_ntop(AF_INET6, &from.sin6_addr, ntopbuf,
+		    INET6_ADDRSTRLEN),
+		    if_indextoname(pi->ipi6_ifindex, ifnamebuf));
+		return;
+	}
+
 	/*
 	 * Process the "O bit."
 	 * If the value of OtherConfigFlag changes from FALSE to TRUE, the
@@ -346,12 +359,35 @@
 	 * requesting information.
 	 * [RFC 2462 Section 5.5.3]
 	 */
-	if (((nd_ra->nd_ra_flags_reserved) & ND_RA_FLAG_OTHER) &&
-	    !ifi->otherconfig) {
-		warnmsg(LOG_DEBUG, __func__,
-		    "OtherConfigFlag on %s is turned on", ifi->ifname);
-		ifi->otherconfig = 1;
-		call_script(otherconf_script, ifi->ifname);
+	if ((nd_ra->nd_ra_flags_reserved) & ND_RA_FLAG_OTHER) {
+		if (ifi->managedconfig)
+			warnmsg(LOG_DEBUG, __func__,
+			    "ManagedConfigFlag on %s already turned on",
+			     ifi->ifname);
+		else if (!ifi->otherconfig) {
+			warnmsg(LOG_DEBUG, __func__,
+			    "OtherConfigFlag on %s is turned on",
+			    ifi->ifname);
+			ifi->otherconfig = 1;
+			call_script(otherconf_script, ifi->ifname);
+		}
+	}
+
+	/*
+	 * Process the "M bit."
+	 */
+	if (nd_ra->nd_ra_flags_reserved & ND_RA_FLAG_MANAGED) {
+		if (ifi->otherconfig)
+			warnmsg(LOG_DEBUG, __func__,
+			    "OtherConfigFlag on %s already turned on",
+			     ifi->ifname);
+		else if (!ifi->managedconfig) {
+			warnmsg(LOG_DEBUG, __func__,
+			    "ManagedConfigFlag on %s is turned on",
+			    ifi->ifname);
+			ifi->managedconfig = 1;
+			call_script(managed_script, ifi->ifname);
+		}
 	}
 
 	ifi->racnt++;
Index: rtsold.8
===================================================================
RCS file: /home/ncvs/src/usr.sbin/rtsold/rtsold.8,v
retrieving revision 1.15
diff -u -r1.15 rtsold.8
--- rtsold.8	9 Feb 2005 18:04:42 -0000	1.15
+++ rtsold.8	20 Mar 2008 03:12:17 -0000
@@ -40,6 +40,7 @@
 .Sh SYNOPSIS
 .Nm
 .Op Fl dDfFm1
+.Op Fl M Ar script-name
 .Op Fl O Ar script-name
 .Ar interface ...
 .Nm
@@ -48,6 +49,7 @@
 .Fl a
 .Nm rtsol
 .Op Fl dDF
+.Op Fl M Ar script-name
 .Op Fl O Ar script-name
 .Ar interface ...
 .Nm rtsol
@@ -206,6 +208,20 @@
 Advertisement packet has arrived on each
 .Ar interface ,
 then exit.
+.It Fl M Ar script-name
+Specifies a supplement script file to handle the Managed Configuration
+flag of the router advertisement.
+When the flag changes from FALSE to TRUE,
+.Nm
+will invoke
+.Ar script-name
+with a single argument of the receiving interface name,
+expecting the script will then start a protocol for the other
+configuration.
+.Ar script-name
+must be the absolute path from root to the script file, be a regular
+file, and be created by the same owner who runs
+.Nm .
 .It Fl O Ar script-name
 Specifies a supplement script file to handle the Other Configuration
 flag of the router advertisement.
Index: rtsold.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/rtsold/rtsold.c,v
retrieving revision 1.21
diff -u -r1.21 rtsold.c
--- rtsold.c	9 Jun 2005 09:28:35 -0000	1.21
+++ rtsold.c	20 Mar 2008 02:59:03 -0000
@@ -68,6 +68,7 @@
 int dflag = 0;
 
 char *otherconf_script;
+char *managed_script;
 
 /* protocol constants */
 #define MAX_RTR_SOLICITATION_DELAY	1 /* second */
@@ -127,9 +128,9 @@
 	if (argv0 && argv0[strlen(argv0) - 1] != 'd') {
 		fflag = 1;
 		once = 1;
-		opts = "adDFO:";
+		opts = "adDFM:O:";
 	} else
-		opts = "adDfFm1O:";
+		opts = "adDfFm1M:O:";
 
 	while ((ch = getopt(argc, argv, opts)) != -1) {
 		switch (ch) {
@@ -157,6 +158,9 @@
 		case 'O':
 			otherconf_script = optarg;
 			break;
+		case 'M':
+			managed_script = optarg;
+			break;
 		default:
 			usage(argv0);
 			/*NOTREACHED*/
@@ -191,6 +195,11 @@
 		    otherconf_script);
 	}
 
+	if (managed_script && *managed_script != '/') {
+		errx(1, "configuration script (%s) must be an absolute path",
+		    managed_script);
+	}
+
 #ifndef HAVE_ARC4RANDOM
 	/* random value initialization */
 	srandom((u_long)time(NULL));
Index: rtsold.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/rtsold/rtsold.h,v
retrieving revision 1.8
diff -u -r1.8 rtsold.h
--- rtsold.h	14 Jan 2004 17:42:03 -0000	1.8
+++ rtsold.h	20 Mar 2008 03:07:39 -0000
@@ -43,6 +43,8 @@
 	int mediareqok;		/* wheter the IF supports SIOCGIFMEDIA */
 	int otherconfig;	/* need a separate protocol for the "other"
 				 * configuration */
+	int managedconfig;	/* need a separate protocol for the "managed"
+				 * configuration */
 	int state;
 	int probes;
 	int dadcount;
@@ -68,6 +70,7 @@
 extern int dflag;
 extern int aflag;
 extern char *otherconf_script;
+extern char *managed_script;
 extern int ifconfig __P((char *));
 extern void iflist_init __P((void));
 struct ifinfo *find_ifinfo __P((int));

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803200340.m2K3ed85014227>