Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Dec 2003 12:08:37 +0300
From:      Gleb Smirnoff <glebius@cell.sick.ru>
To:        freebsd-bugs@FreeBSD.ORG, yar@snark.rinet.ru
Subject:   Re: kern/47920: if ng_pppoe switches to nonstandard mode it stays in it forever
Message-ID:  <20031209090837.GE28861@cell.sick.ru>
In-Reply-To: <200302042232.h14MWLGj005760@virgin.v.gz.ru>
References:  <200302042232.h14MWLGj005760@virgin.v.gz.ru>

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

--gKMricLos+KVdGMg
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline

 Hi!

yar@ asked me for new patch. Here it is, attached.

-- 
Totus tuus, Glebius.
GLEBIUS-RIPN GLEB-RIPE

--gKMricLos+KVdGMg
Content-Type: text/plain; charset=koi8-r
Content-Disposition: attachment; filename="ng_pppoe.c.diff"

--- /usr/src/sys/netgraph/ng_pppoe.c	Wed Jul  3 02:17:18 2002
+++ ng_pppoe.c	Tue Dec  9 11:57:25 2003
@@ -54,6 +54,7 @@
 #include <sys/malloc.h>
 #include <sys/errno.h>
 #include <sys/sysctl.h>
+#include <sys/syslog.h>
 #include <net/ethernet.h>
 
 #include <netgraph/ng_message.h>
@@ -165,23 +166,33 @@
 	 {0x00,0x00,0x00,0x00,0x00,0x00},
 	 ETHERTYPE_PPPOE_DISC};
 
-static int nonstandard;
+static int standard;
+#define PPPOE_STANDARD		0	/* try standard */
+#define PPPOE_NONSTANDARD	1	/* be nonstandard */
+#define PPPOE_KEEPSTANDARD	-1	/* never switch to nonstandard mode */
 static int
 ngpppoe_set_ethertype(SYSCTL_HANDLER_ARGS)
 {
 	int error;
 	int val;
 
-	val = nonstandard;
+	val = standard;
 	error = sysctl_handle_int(oidp, &val, sizeof(int), req);
 	if (error != 0 || req->newptr == NULL)
 		return (error);
-	if (val == 1) {
-		nonstandard = 1;
+	switch (val) {
+	case PPPOE_NONSTANDARD:
+		standard = PPPOE_NONSTANDARD;
 		eh_prototype.ether_type = ETHERTYPE_PPPOE_STUPID_DISC;
-	} else {
-		nonstandard = 0;
+		break;
+	case PPPOE_STANDARD:
+		standard = PPPOE_STANDARD;
 		eh_prototype.ether_type = ETHERTYPE_PPPOE_DISC;
+		break;
+	case PPPOE_KEEPSTANDARD:
+		standard = PPPOE_KEEPSTANDARD;
+		eh_prototype.ether_type = ETHERTYPE_PPPOE_DISC;
+		break;
 	}
 	return (0);
 }
@@ -913,8 +924,16 @@
 		code = wh->ph.code; 
 		switch(wh->eh.ether_type) {
 		case	ETHERTYPE_PPPOE_STUPID_DISC:
-			nonstandard = 1;
-			eh_prototype.ether_type = ETHERTYPE_PPPOE_STUPID_DISC;
+			if (standard != PPPOE_KEEPSTANDARD) {
+			  standard = PPPOE_NONSTANDARD;
+			  eh_prototype.ether_type = ETHERTYPE_PPPOE_STUPID_DISC;
+			  log(LOG_NOTICE,
+				"Switched to nonstandard PPPoE (packet from %*D)\n",
+				sizeof(wh->eh.ether_shost), wh->eh.ether_shost,":");
+			} else
+			  log(LOG_NOTICE,
+				"Ignored nonstandard PPPoE packet from %*D\n",
+				sizeof(wh->eh.ether_shost), wh->eh.ether_shost,":");
 			/* fall through */
 		case	ETHERTYPE_PPPOE_DISC:
 			/*
@@ -1098,7 +1117,7 @@
 				 * from NEWCONNECTED to CONNECTED
 				 */
 				sp->pkt_hdr = neg->pkt->pkt_header;
-				if (nonstandard)
+				if (standard == PPPOE_NONSTANDARD)
 					sp->pkt_hdr.eh.ether_type
 						= ETHERTYPE_PPPOE_STUPID_SESS;
 				else
@@ -1150,7 +1169,7 @@
 				 * Keep a copy of the header we will be using.
 				 */
 				sp->pkt_hdr = neg->pkt->pkt_header;
-				if (nonstandard)
+				if (standard == PPPOE_NONSTANDARD)
 					sp->pkt_hdr.eh.ether_type
 						= ETHERTYPE_PPPOE_STUPID_SESS;
 				else
@@ -1434,7 +1453,7 @@
 			/* revert the stored header to DISC/PADT mode */
 		 	wh = &sp->pkt_hdr;
 			wh->ph.code = PADT_CODE;
-			if (nonstandard)
+			if (standard == PPPOE_NONSTANDARD)
 				wh->eh.ether_type = ETHERTYPE_PPPOE_STUPID_DISC;
 			else
 				wh->eh.ether_type = ETHERTYPE_PPPOE_DISC;

--gKMricLos+KVdGMg--



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