Module Name:    src
Committed By:   rjs
Date:           Mon Sep  5 12:19:09 UTC 2011

Modified Files:
        src/sys/net: if_pppoe.c if_spppsubr.c

Log Message:
Add support for RFC 4638 to pppoe(4).

The change to if_spppsubr.c moves the test for whether LCP should
request a mru change until after the pppoe device has picked up the
mtu of the underlying ethernet device.


To generate a diff of this commit:
cvs rdiff -u -r1.97 -r1.98 src/sys/net/if_pppoe.c
cvs rdiff -u -r1.121 -r1.122 src/sys/net/if_spppsubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.97 src/sys/net/if_pppoe.c:1.98
--- src/sys/net/if_pppoe.c:1.97	Tue Aug 30 22:23:06 2011
+++ src/sys/net/if_pppoe.c	Mon Sep  5 12:19:09 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.97 2011/08/30 22:23:06 rjs Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.98 2011/09/05 12:19:09 rjs Exp $ */
 
 /*-
  * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.97 2011/08/30 22:23:06 rjs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.98 2011/09/05 12:19:09 rjs Exp $");
 
 #include "pppoe.h"
 #include "opt_pfil_hooks.h"
@@ -85,6 +85,7 @@
 #define	PPPOE_TAG_ACCOOKIE	0x0104		/* AC cookie */
 #define	PPPOE_TAG_VENDOR	0x0105		/* vendor specific */
 #define	PPPOE_TAG_RELAYSID	0x0110		/* relay session id */
+#define	PPPOE_TAG_MAX_PAYLOAD	0x0120		/* max payload */
 #define	PPPOE_TAG_SNAME_ERR	0x0201		/* service name error */
 #define	PPPOE_TAG_ACSYS_ERR	0x0202		/* AC system error */
 #define	PPPOE_TAG_GENERIC_ERR	0x0203		/* generic error */
@@ -895,7 +896,7 @@
 				return ENXIO;
 			}
 
-			if (sc->sc_sppp.pp_if.if_mtu >
+			if (sc->sc_sppp.pp_if.if_mtu !=
 			    eth_if->if_mtu - PPPOE_OVERHEAD) {
 				sc->sc_sppp.pp_if.if_mtu = eth_if->if_mtu -
 				    PPPOE_OVERHEAD;
@@ -1041,6 +1042,9 @@
 		l2 = strlen(sc->sc_concentrator_name);
 		len += 2 + 2 + l2;
 	}
+	if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MAXMTU) {
+		len += 2 + 2 + 2;
+	}
 
 	/* allocate a buffer */
 	m0 = pppoe_get_mbuf(len + PPPOE_HEADERLEN);	/* header len + payload len */
@@ -1067,6 +1071,13 @@
 	PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
 	PPPOE_ADD_16(p, sizeof(sc));
 	memcpy(p, &sc, sizeof sc);
+	p += sizeof(sc);
+
+	if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MAXMTU) {
+		PPPOE_ADD_16(p, PPPOE_TAG_MAX_PAYLOAD);
+		PPPOE_ADD_16(p, 2);
+		PPPOE_ADD_16(p, (uint16_t)sc->sc_sppp.pp_if.if_mtu);
+	}
 
 #ifdef PPPOE_DEBUG
 	p += sizeof sc;
@@ -1283,6 +1294,9 @@
 		len += 2 + 2 + sc->sc_ac_cookie_len;	/* AC cookie */
 	if (sc->sc_relay_sid_len > 0)
 		len += 2 + 2 + sc->sc_relay_sid_len;	/* Relay SID */
+	if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MAXMTU) {
+		len += 2 + 2 + 2;
+	}
 	m0 = pppoe_get_mbuf(len + PPPOE_HEADERLEN);
 	if (!m0)
 		return ENOBUFS;
@@ -1311,6 +1325,13 @@
 	PPPOE_ADD_16(p, PPPOE_TAG_HUNIQUE);
 	PPPOE_ADD_16(p, sizeof(sc));
 	memcpy(p, &sc, sizeof sc);
+	p += sizeof(sc);
+
+	if (sc->sc_sppp.pp_if.if_mtu > PPPOE_MAXMTU) {
+		PPPOE_ADD_16(p, PPPOE_TAG_MAX_PAYLOAD);
+		PPPOE_ADD_16(p, 2);
+		PPPOE_ADD_16(p, (uint16_t)sc->sc_sppp.pp_if.if_mtu);
+	}
 
 #ifdef PPPOE_DEBUG
 	p += sizeof sc;

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.121 src/sys/net/if_spppsubr.c:1.122
--- src/sys/net/if_spppsubr.c:1.121	Sun Jul 17 20:54:52 2011
+++ src/sys/net/if_spppsubr.c	Mon Sep  5 12:19:09 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.121 2011/07/17 20:54:52 joerg Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.122 2011/09/05 12:19:09 rjs Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.121 2011/07/17 20:54:52 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.122 2011/09/05 12:19:09 rjs Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -2000,12 +2000,6 @@
 	sp->pp_seq[IDX_LCP] = 0;
 	sp->pp_rseq[IDX_LCP] = 0;
 	sp->lcp.protos = 0;
-	if (sp->pp_if.if_mtu < PP_MTU) {
-		sp->lcp.mru = sp->pp_if.if_mtu;
-		sp->lcp.opts |= (1 << LCP_OPT_MRU);
-	} else
-		sp->lcp.mru = PP_MTU;
-	sp->lcp.their_mru = PP_MTU;
 
 	/*
 	 * Initialize counters and timeout values.  Note that we don't
@@ -2090,6 +2084,13 @@
 static void
 sppp_lcp_open(struct sppp *sp)
 {
+	if (sp->pp_if.if_mtu < PP_MTU) {
+		sp->lcp.mru = sp->pp_if.if_mtu;
+		sp->lcp.opts |= (1 << LCP_OPT_MRU);
+	} else
+		sp->lcp.mru = PP_MTU;
+	sp->lcp.their_mru = PP_MTU;
+
 	/*
 	 * If we are authenticator, negotiate LCP_AUTH
 	 */

Reply via email to