Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Hide PPPoE variables from if_ethersubr.c



details:   https://anonhg.NetBSD.org/src/rev/3b9b91be6225
branches:  trunk
changeset: 344749:3b9b91be6225
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Fri Apr 15 01:31:29 2016 +0000

description:
Hide PPPoE variables from if_ethersubr.c

This improves modularity of if_pppoe.

>From s-yamaguchi@IIJ

diffstat:

 sys/net/if_ethersubr.c |  29 +++++------------------------
 sys/net/if_pppoe.c     |  50 +++++++++++++++++++++++++++++++++++++++++++++-----
 sys/net/if_pppoe.h     |   9 +++------
 3 files changed, 53 insertions(+), 35 deletions(-)

diffs (164 lines):

diff -r 4362e7258cc5 -r 3b9b91be6225 sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Thu Apr 14 21:16:18 2016 +0000
+++ b/sys/net/if_ethersubr.c    Fri Apr 15 01:31:29 2016 +0000
@@ -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 @@
        }
 #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: {
diff -r 4362e7258cc5 -r 3b9b91be6225 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c        Thu Apr 14 21:16:18 2016 +0000
+++ b/sys/net/if_pppoe.c        Fri Apr 15 01:31:29 2016 +0000
@@ -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 @@
 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 @@
 {
        /* 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 @@
        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;
+}
diff -r 4362e7258cc5 -r 3b9b91be6225 sys/net/if_pppoe.h
--- a/sys/net/if_pppoe.h        Thu Apr 14 21:16:18 2016 +0000
+++ b/sys/net/if_pppoe.h        Fri Apr 15 01:31:29 2016 +0000
@@ -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 @@
 
 #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_ */
 



Home | Main Index | Thread Index | Old Index