From owner-freebsd-bugs@FreeBSD.ORG Tue Dec 9 07:21:00 2003 Return-Path: Delivered-To: freebsd-bugs@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 54F0616A4CE; Tue, 9 Dec 2003 07:21:00 -0800 (PST) Received: from cell.sick.ru (cell.sick.ru [217.72.144.68]) by mx1.FreeBSD.org (Postfix) with ESMTP id DABF943D2C; Tue, 9 Dec 2003 07:20:57 -0800 (PST) (envelope-from glebius@cell.sick.ru) Received: from cell.sick.ru (glebius@localhost [127.0.0.1]) by cell.sick.ru (8.12.9/8.12.8) with ESMTP id hB9FKtAB030551 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 9 Dec 2003 18:20:55 +0300 (MSK) (envelope-from glebius@cell.sick.ru) Received: (from glebius@localhost) by cell.sick.ru (8.12.9/8.12.6/Submit) id hB9FKtYW030550; Tue, 9 Dec 2003 18:20:55 +0300 (MSK) Date: Tue, 9 Dec 2003 18:20:54 +0300 From: Gleb Smirnoff To: Yar Tikhiy Message-ID: <20031209152054.GD29997@cell.sick.ru> Mail-Followup-To: Gleb Smirnoff , Yar Tikhiy , FreeBSD-gnats-submit@FreeBSD.ORG, freebsd-bugs@FreeBSD.ORG References: <200302042232.h14MWLGj005760@virgin.v.gz.ru> <20031209090837.GE28861@cell.sick.ru> <20031209131441.GB95449@comp.chem.msu.su> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="dDRMvlgZJXvWKvBx" Content-Disposition: inline In-Reply-To: <20031209131441.GB95449@comp.chem.msu.su> User-Agent: Mutt/1.5.4i cc: freebsd-bugs@FreeBSD.ORG cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: kern/47920: if ng_pppoe switches to nonstandard mode it stays in it forever X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Dec 2003 15:21:00 -0000 --dDRMvlgZJXvWKvBx Content-Type: text/plain; charset=koi8-r Content-Disposition: inline On Tue, Dec 09, 2003 at 04:14:41PM +0300, Yar Tikhiy wrote: Y> I would rather change the name of the variable "nonstandard" Y> to "pppoe_mode", not "standard", because lines like this one: Y> Y> standard = PPPOE_NONSTANDARD; Y> Y> give me a schizoid feeling :-) Here it is. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE --dDRMvlgZJXvWKvBx 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 #include #include +#include #include #include @@ -165,23 +166,33 @@ {0x00,0x00,0x00,0x00,0x00,0x00}, ETHERTYPE_PPPOE_DISC}; -static int nonstandard; +static int pppoe_mode; +#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 = pppoe_mode; 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: + pppoe_mode = PPPOE_NONSTANDARD; eh_prototype.ether_type = ETHERTYPE_PPPOE_STUPID_DISC; - } else { - nonstandard = 0; + break; + case PPPOE_STANDARD: + pppoe_mode = PPPOE_STANDARD; eh_prototype.ether_type = ETHERTYPE_PPPOE_DISC; + break; + case PPPOE_KEEPSTANDARD: + pppoe_mode = 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 (pppoe_mode != PPPOE_KEEPSTANDARD) { + pppoe_mode = 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 (pppoe_mode == 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 (pppoe_mode == 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 (pppoe_mode == PPPOE_NONSTANDARD) wh->eh.ether_type = ETHERTYPE_PPPOE_STUPID_DISC; else wh->eh.ether_type = ETHERTYPE_PPPOE_DISC; --dDRMvlgZJXvWKvBx--