Module Name:    src
Committed By:   ozaki-r
Date:           Fri Apr 15 01:31:29 UTC 2016

Modified Files:
        src/sys/net: if_ethersubr.c if_pppoe.c if_pppoe.h

Log Message:
Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

>From s-yamaguchi@IIJ


To generate a diff of this commit:
cvs rdiff -u -r1.217 -r1.218 src/sys/net/if_ethersubr.c
cvs rdiff -u -r1.104 -r1.105 src/sys/net/if_pppoe.c
cvs rdiff -u -r1.12 -r1.13 src/sys/net/if_pppoe.h

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_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.217 src/sys/net/if_ethersubr.c:1.218
--- src/sys/net/if_ethersubr.c:1.217	Thu Apr  7 03:22:15 2016
+++ src/sys/net/if_ethersubr.c	Fri Apr 15 01:31:29 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.217 2016/04/07 03:22:15 christos Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.218 2016/04/15 01:31:29 ozaki-r Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.217 2016/04/07 03:22:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.218 2016/04/15 01:31:29 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -696,29 +696,10 @@ ether_input(struct ifnet *ifp, struct mb
 	}
 #if NPPPOE > 0
 	case ETHERTYPE_PPPOEDISC:
+		pppoedisc_input(ifp, m);
+		return;
 	case ETHERTYPE_PPPOE:
-		if (m->m_flags & M_PROMISC) {
-			m_freem(m);
-			return;
-		}
-#ifndef PPPOE_SERVER
-		if (m->m_flags & (M_MCAST | M_BCAST)) {
-			m_freem(m);
-			return;
-		}
-#endif
-
-		if (etype == ETHERTYPE_PPPOEDISC)
-			inq = &ppoediscinq;
-		else
-			inq = &ppoeinq;
-		if (IF_QFULL(inq)) {
-			IF_DROP(inq);
-			m_freem(m);
-		} else {
-			IF_ENQUEUE(inq, m);
-			softint_schedule(pppoe_softintr);
-		}
+		pppoe_input(ifp, m);
 		return;
 #endif /* NPPPOE > 0 */
 	case ETHERTYPE_SLOWPROTOCOLS: {

Index: src/sys/net/if_pppoe.c
diff -u src/sys/net/if_pppoe.c:1.104 src/sys/net/if_pppoe.c:1.105
--- src/sys/net/if_pppoe.c:1.104	Mon Aug 24 22:21:26 2015
+++ src/sys/net/if_pppoe.c	Fri Apr 15 01:31:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.104 2015/08/24 22:21:26 pooka Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.105 2016/04/15 01:31:29 ozaki-r 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.104 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.105 2016/04/15 01:31:29 ozaki-r Exp $");
 
 #include "pppoe.h"
 
@@ -160,10 +160,11 @@ static void pppoe_softintr_handler(void 
 extern int sppp_ioctl(struct ifnet *, unsigned long, void *);
 
 /* input routines */
-static void pppoe_input(void);
+static void pppoeintr(void);
 static void pppoe_disc_input(struct mbuf *);
 static void pppoe_dispatch_disc_pkt(struct mbuf *, int);
 static void pppoe_data_input(struct mbuf *);
+static void pppoe_enqueue(struct ifqueue *, struct mbuf *);
 
 /* management routines */
 static int pppoe_connect(struct pppoe_softc *);
@@ -349,13 +350,13 @@ pppoe_softintr_handler(void *dummy)
 {
 	/* called at splsoftnet() */
 	mutex_enter(softnet_lock);
-	pppoe_input();
+	pppoeintr();
 	mutex_exit(softnet_lock);
 }
 
 /* called at appropriate protection level */
 static void
-pppoe_input(void)
+pppoeintr(void)
 {
 	struct mbuf *m;
 	int s, disc_done, data_done;
@@ -1564,3 +1565,42 @@ pppoe_clear_softc(struct pppoe_softc *sc
 	sc->sc_ac_cookie_len = 0;
 	sc->sc_session = 0;
 }
+
+static void
+pppoe_enqueue(struct ifqueue *inq, struct mbuf *m)
+{
+	if (m->m_flags & M_PROMISC) {
+		m_free(m);
+		return;
+	}
+
+#ifndef PPPOE_SERVER
+	if (m->m_flags & (M_MCAST | M_BCAST)) {
+		m_free(m);
+		return;
+	}
+#endif
+
+	if (IF_QFULL(inq)) {
+		IF_DROP(inq);
+		m_freem(m);
+	} else {
+		IF_ENQUEUE(inq, m);
+		softint_schedule(pppoe_softintr);
+	}
+	return;
+}
+
+void
+pppoe_input(struct ifnet *ifp, struct mbuf *m)
+{
+	pppoe_enqueue(&ppoeinq, m);
+	return;
+}
+
+void
+pppoedisc_input(struct ifnet *ifp, struct mbuf *m)
+{
+	pppoe_enqueue(&ppoediscinq, m);
+	return;
+}

Index: src/sys/net/if_pppoe.h
diff -u src/sys/net/if_pppoe.h:1.12 src/sys/net/if_pppoe.h:1.13
--- src/sys/net/if_pppoe.h:1.12	Sun Sep  6 06:01:01 2015
+++ src/sys/net/if_pppoe.h	Fri Apr 15 01:31:29 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.h,v 1.12 2015/09/06 06:01:01 dholland Exp $ */
+/* $NetBSD: if_pppoe.h,v 1.13 2016/04/15 01:31:29 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -66,11 +66,8 @@ struct pppoeconnectionstate {
 
 #ifdef _KERNEL
 
-extern struct ifqueue ppoediscinq;
-extern struct ifqueue ppoeinq;
-
-extern void *pppoe_softintr;			/* softinterrupt cookie */
-
+void pppoe_input(struct ifnet *, struct mbuf *);
+void pppoedisc_input(struct ifnet *, struct mbuf *);
 #endif /* _KERNEL */
 #endif /* !_NET_IF_PPPOE_H_ */
 

Reply via email to