Subject: Re: Allowing large PPPoE frames
To: Manuel Bouyer <bouyer@antioche.lip6.fr>
From: Quentin Garnier <netbsd@quatriemek.com>
List: tech-net
Date: 08/04/2003 22:30:09
This is a multi-part message in MIME format.

--Multipart_Mon__4_Aug_2003_22:30:09_+0200_08c4d200
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

Le Mon, 4 Aug 2003 12:51:42 +0200
Manuel Bouyer a ecrit :
> > > > But anyway, we don't have to check if the NIC can receive the
> > > > frame at that time, because obviously it could.
> > > 
> > > ec_capenable ETHERCAP_VLAN_MTU is there to have the driver allow the
> > > nic to receive such frames. 
> > 
> > I'll do that then.
> 
> Thanks.

I tested this with sip(4). I added the necessary bit to tlp(4), but I
didn't have the time to test it yet. I'll have a closer look at all the
other cards I have here (ne, rtk, ep, iy). None of them declare the
ETHERCAP_VLAN_MTU. My guess is that there is no documentation and/or no
way to disallow or permit reception of large frames.

I know for sure that one of my ne(4), a rtk8029, handles large frames
fine.

-- 
Quentin Garnier - cube@cubidou.net
"Feels like I'm fiddling while Rome is burning down.
Should I lay my fiddle down and take a rifle from the ground ?"
Leigh Nash/Sixpence None The Richer, Paralyzed, Divine Discontents, 2002.

--Multipart_Mon__4_Aug_2003_22:30:09_+0200_08c4d200
Content-Type: text/plain;
 name="pppoe_large_frames.diff"
Content-Disposition: attachment;
 filename="pppoe_large_frames.diff"
Content-Transfer-Encoding: 7bit

Index: sys/net/if_ether.h
===================================================================
RCS file: /cvsroot/src/sys/net/if_ether.h,v
retrieving revision 1.33
diff -u -r1.33 if_ether.h
--- sys/net/if_ether.h	2003/06/26 08:22:06	1.33
+++ sys/net/if_ether.h	2003/08/04 15:37:44
@@ -60,6 +60,9 @@
  * Some Ethernet extensions.
  */
 #define	ETHER_VLAN_ENCAP_LEN 4	/* length of 802.1Q VLAN encapsulation */
+#ifdef PPPOE_ACCEPT_LARGE_FRAMES
+#define	ETHER_PPPOE_ENCAP_LEN 8
+#endif
 
 /*
  * Ethernet address - 6 octets
@@ -90,10 +93,18 @@
  * Compute the maximum frame size based on ethertype (i.e. possible
  * encapsulation) and whether or not an FCS is present.
  */
+#ifdef PPPOE_ACCEPT_LARGE_FRAMES
 #define	ETHER_MAX_FRAME(ifp, etype, hasfcs)				\
 	((ifp)->if_mtu + ETHER_HDR_LEN +				\
 	 ((hasfcs) ? ETHER_CRC_LEN : 0) +				\
+	 (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0) +	\
+	 (((etype) == ETHERTYPE_PPPOE) ? ETHER_PPPOE_ENCAP_LEN : 0))
+#else
+#define ETHER_MAX_FRAME(ifp, etype, hasfcs)				\
+	((ifp)->if_mtu + ETHER_HDR_LEN +				\
+	 ((hasfcs) ? ETHER_CRC_LEN : 0) +				\
 	 (((etype) == ETHERTYPE_VLAN) ? ETHER_VLAN_ENCAP_LEN : 0))
+#endif
 
 /*
  * Ethernet CRC32 polynomials (big- and little-endian verions).
@@ -170,6 +181,9 @@
 #define	ETHERCAP_VLAN_MTU	0x00000001	/* VLAN-compatible MTU */
 #define	ETHERCAP_VLAN_HWTAGGING	0x00000002	/* hardware VLAN tag support */
 #define	ETHERCAP_JUMBO_MTU	0x00000004	/* 9000 byte MTU supported */
+#ifdef PPPOE_ACCEPT_LARGE_FRAMES
+#define	ETHERCAP_PPPOE_MTU	0x00000008	/* 1508 byte MTU supported */
+#endif
 
 #ifdef	_KERNEL
 extern u_int8_t etherbroadcastaddr[ETHER_ADDR_LEN];
Index: sys/net/if_pppoe.c
===================================================================
RCS file: /cvsroot/src/sys/net/if_pppoe.c,v
retrieving revision 1.44
diff -u -r1.44 if_pppoe.c
--- sys/net/if_pppoe.c	2003/06/27 16:24:32	1.44
+++ sys/net/if_pppoe.c	2003/08/04 15:37:45
@@ -830,6 +830,14 @@
 			sc->sc_eth_if = ifunit(parms->eth_ifname);
 			if (sc->sc_eth_if == NULL)
 				return ENXIO;
+#ifdef PPPOE_ACCEPT_LARGE_FRAMES
+			if (sc->sc_eth_if->if_type == IFT_ETHER) {
+				/* It shouldn't be anything else anyway */
+				struct ethercom *ec = (struct ethercom *)sc->sc_eth_if;
+				if ((ec->ec_capabilities & ETHERCAP_PPPOE_MTU))
+					ec->ec_capenable |= ETHERCAP_PPPOE_MTU;
+			}
+#endif
 		}
 		if (parms->ac_name) {
 			size_t s;
Index: sys/dev/pci/if_sip.c
===================================================================
RCS file: /cvsroot/src/sys/dev/pci/if_sip.c,v
retrieving revision 1.78
diff -u -r1.78 if_sip.c
--- sys/dev/pci/if_sip.c	2003/03/23 00:56:15	1.78
+++ sys/dev/pci/if_sip.c	2003/08/04 15:37:48
@@ -968,6 +968,13 @@
 	 * We can support 802.1Q VLAN-sized frames.
 	 */
 	sc->sc_ethercom.ec_capabilities |= ETHERCAP_VLAN_MTU;
+#ifdef PPPOE_ACCEPT_LARGE_FRAMES
+	/*
+	 * We can support very long frames for broken PPPoE
+	 * implementations.
+	 */
+	sc->sc_ethercom.ec_capabilities |= ETHERCAP_PPPOE_MTU;
+#endif
 
 #ifdef DP83820
 	/*
@@ -2314,6 +2321,11 @@
 	 * Initialize the prototype RXCFG register.
 	 */
 	sc->sc_rxcfg |= (sc->sc_rx_drain_thresh << RXCFG_DRTH_SHIFT);
+#ifdef PPPOE_ACCEPT_LARGE_FRAMES
+	/* Prevent the chip from cutting very large PPPoE frames */
+	if (sc->sc_ethercom.ec_capenable & ETHERCAP_PPPOE_MTU)
+		sc->sc_rxcfg |= RXCFG_AJAB;
+#endif
 	bus_space_write_4(st, sh, SIP_RXCFG, sc->sc_rxcfg);
 
 #ifdef DP83820
Index: share/man/man4/pppoe.4
===================================================================
RCS file: /cvsroot/src/share/man/man4/pppoe.4,v
retrieving revision 1.24
diff -u -r1.24 pppoe.4
--- share/man/man4/pppoe.4	2003/07/04 12:54:14	1.24
+++ share/man/man4/pppoe.4	2003/08/04 15:37:49
@@ -288,6 +288,41 @@
 packet (request to terminate the session).
 The peer will immediately disconnect
 the orphaned session and allow a new one to be established.
+.Pp
+Under certain circumstances, depending on the
+.Nm PPPoE
+modem, the ISP and the telephony operator, the MTU of the link on the ISP
+side will be of 1500.
+If the telephony operator relays the packet, your modem transmits it and
+you network card is able to receive the frame, you can have an effective
+MRU of 1500 bytes, thus avoiding all MTU-related issues of
+.Nm PPPoE .
+The MSS clamping option, which is effective only for TCP connection, is
+then not needed anymore.
+.Pp
+However, this is a
+.Em violation
+of the standard and must only be seen as a convenience, not as a solution
+to the issue.
+.Pp
+Adding
+.Pp
+.Nm options
+.Ar PPPOE_ACCEPT_LARGE_FRAMES
+.Pp
+to your kernel config file will make NetBSD accept and process unusually
+large
+.Nm PPPoE
+frames, but beware that the network card also has to able to actually
+receive such frames, which is not always the case.
+Currently, the
+.Xr sip 4
+driver supports that functionnality.
+.Xr gsip 4 ,
+.Xr tlp 4
+should support it too, but are unstested yet.
+There are a lot of network cards, such as NE2000 clones that might work
+out of the box.
 .Sh SEE ALSO
 .Xr ifwatchd 8 ,
 .Xr pppoectl 8

--Multipart_Mon__4_Aug_2003_22:30:09_+0200_08c4d200--