From owner-freebsd-bugs Wed Feb 12 6:50: 9 2003 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D2D737B401 for ; Wed, 12 Feb 2003 06:50:06 -0800 (PST) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 04B4D43F75 for ; Wed, 12 Feb 2003 06:50:06 -0800 (PST) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.6/8.12.6) with ESMTP id h1CEo5NS094248 for ; Wed, 12 Feb 2003 06:50:05 -0800 (PST) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.6/8.12.6/Submit) id h1CEo5X0094247; Wed, 12 Feb 2003 06:50:05 -0800 (PST) Date: Wed, 12 Feb 2003 06:50:05 -0800 (PST) Message-Id: <200302121450.h1CEo5X0094247@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Gleb Smirnoff Subject: Re: kern/47920: if ng_pppoe switches to nonstandard mode it stays in it forever Reply-To: Gleb Smirnoff Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/47920; it has been noted by GNATS. From: Gleb Smirnoff To: freebsd-bugs@FreeBSD.ORG, FreeBSD-gnats-submit@FreeBSD.ORG Cc: Subject: Re: kern/47920: if ng_pppoe switches to nonstandard mode it stays in it forever Date: Wed, 12 Feb 2003 17:43:37 +0300 This one is even better. It logs source MAC address of nonstandard packet. -- Totus tuus, Glebius. GLEBIUS-RIPN GLEB-RIPE --- ng_pppoe.c.orig Mon Feb 10 15:16:04 2003 +++ ng_pppoe.c Wed Feb 12 17:21:20 2003 @@ -54,6 +54,7 @@ #include #include #include +#include #include #include @@ -166,6 +167,9 @@ ETHERTYPE_PPPOE_DISC}; static int nonstandard; +#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) { @@ -176,12 +180,19 @@ 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: + nonstandard = PPPOE_NONSTANDARD; eh_prototype.ether_type = ETHERTYPE_PPPOE_STUPID_DISC; - } else { - nonstandard = 0; + break; + case PPPOE_STANDARD: + nonstandard = PPPOE_STANDARD; eh_prototype.ether_type = ETHERTYPE_PPPOE_DISC; + break; + case PPPOE_KEEPSTANDARD: + nonstandard = 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 (nonstandard > PPPOE_KEEPSTANDARD) { + nonstandard = 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 (nonstandard == 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 (nonstandard == 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 (nonstandard == PPPOE_NONSTANDARD) wh->eh.ether_type = ETHERTYPE_PPPOE_STUPID_DISC; else wh->eh.ether_type = ETHERTYPE_PPPOE_DISC; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message