Source-Changes-HG archive

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

[src/trunk]: src/sys Add argument to encapsw->pr_input() instead of m_tag.



details:   https://anonhg.NetBSD.org/src/rev/93edfd3e3806
branches:  trunk
changeset: 827868:93edfd3e3806
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Wed Nov 15 10:42:41 2017 +0000

description:
Add argument to encapsw->pr_input() instead of m_tag.

diffstat:

 sys/net/if_stf.c          |  14 +++++++-------
 sys/net/if_stf.h          |   4 ++--
 sys/netinet/in_gif.c      |  15 +++++++--------
 sys/netinet/in_gif.h      |   4 ++--
 sys/netinet/in_l2tp.c     |   8 ++++----
 sys/netinet/ip_encap.c    |  39 +++++----------------------------------
 sys/netinet/ip_encap.h    |   7 +++----
 sys/netinet/ip_mroute.c   |  17 +++++++++--------
 sys/netinet6/in6_gif.c    |  15 +++++++--------
 sys/netinet6/in6_gif.h    |   4 ++--
 sys/netinet6/in6_l2tp.c   |   8 ++++----
 sys/netipsec/xform.h      |   6 +++---
 sys/netipsec/xform_ipip.c |   8 ++++----
 13 files changed, 59 insertions(+), 90 deletions(-)

diffs (truncated from 478 to 300 lines):

diff -r bf3e2350cf2a -r 93edfd3e3806 sys/net/if_stf.c
--- a/sys/net/if_stf.c  Wed Nov 15 10:13:11 2017 +0000
+++ b/sys/net/if_stf.c  Wed Nov 15 10:42:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_stf.c,v 1.102 2017/10/23 09:32:55 msaitoh Exp $     */
+/*     $NetBSD: if_stf.c,v 1.103 2017/11/15 10:42:41 knakahara Exp $   */
 /*     $KAME: if_stf.c,v 1.62 2001/06/07 22:32:16 itojun Exp $ */
 
 /*
@@ -75,7 +75,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.102 2017/10/23 09:32:55 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stf.c,v 1.103 2017/11/15 10:42:41 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -591,16 +591,18 @@
 }
 
 void
-in_stf_input(struct mbuf *m, int off, int proto)
+in_stf_input(struct mbuf *m, int off, int proto, void *eparg)
 {
        int s;
-       struct stf_softc *sc;
+       struct stf_softc *sc = eparg;
        struct ip *ip;
        struct ip6_hdr *ip6;
        uint8_t otos, itos;
        struct ifnet *ifp;
        size_t pktlen;
 
+       KASSERT(sc != NULL);
+
        if (proto != IPPROTO_IPV6) {
                m_freem(m);
                return;
@@ -608,9 +610,7 @@
 
        ip = mtod(m, struct ip *);
 
-       sc = (struct stf_softc *)encap_getarg(m);
-
-       if (sc == NULL || (sc->sc_if.if_flags & IFF_UP) == 0) {
+       if ((sc->sc_if.if_flags & IFF_UP) == 0) {
                m_freem(m);
                return;
        }
diff -r bf3e2350cf2a -r 93edfd3e3806 sys/net/if_stf.h
--- a/sys/net/if_stf.h  Wed Nov 15 10:13:11 2017 +0000
+++ b/sys/net/if_stf.h  Wed Nov 15 10:42:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_stf.h,v 1.7 2016/08/18 11:38:58 knakahara Exp $     */
+/*     $NetBSD: if_stf.h,v 1.8 2017/11/15 10:42:41 knakahara Exp $     */
 /*     $KAME: if_stf.h,v 1.3 2000/03/25 07:23:33 sumikawa Exp $        */
 
 /*
@@ -39,6 +39,6 @@
 #define        STF_MTU_MIN     (1280)  /* Minimum MTU */
 #define        STF_MTU_MAX     (8192)  /* Maximum MTU */
 
-void   in_stf_input(struct mbuf *, int, int);
+void   in_stf_input(struct mbuf *, int, int, void *);
 
 #endif /* !_NET_IF_STF_H_ */
diff -r bf3e2350cf2a -r 93edfd3e3806 sys/netinet/in_gif.c
--- a/sys/netinet/in_gif.c      Wed Nov 15 10:13:11 2017 +0000
+++ b/sys/netinet/in_gif.c      Wed Nov 15 10:42:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_gif.c,v 1.88 2017/09/21 09:42:03 knakahara Exp $    */
+/*     $NetBSD: in_gif.c,v 1.89 2017/11/15 10:42:41 knakahara Exp $    */
 /*     $KAME: in_gif.c,v 1.66 2001/07/29 04:46:09 itojun Exp $ */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.88 2017/09/21 09:42:03 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_gif.c,v 1.89 2017/11/15 10:42:41 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -195,19 +195,18 @@
 }
 
 void
-in_gif_input(struct mbuf *m, int off, int proto)
+in_gif_input(struct mbuf *m, int off, int proto, void *eparg)
 {
-       struct ifnet *gifp = NULL;
+       struct ifnet *gifp = eparg;
        const struct ip *ip;
        int af;
        u_int8_t otos;
 
+       KASSERT(gifp != NULL);
+
        ip = mtod(m, const struct ip *);
 
-       gifp = (struct ifnet *)encap_getarg(m);
-
-       if (gifp == NULL || (gifp->if_flags & (IFF_UP|IFF_RUNNING))
-               != (IFF_UP|IFF_RUNNING)) {
+       if ((gifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING)) {
                m_freem(m);
                ip_statinc(IP_STAT_NOGIF);
                return;
diff -r bf3e2350cf2a -r 93edfd3e3806 sys/netinet/in_gif.h
--- a/sys/netinet/in_gif.h      Wed Nov 15 10:13:11 2017 +0000
+++ b/sys/netinet/in_gif.h      Wed Nov 15 10:42:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_gif.h,v 1.16 2016/07/04 04:22:47 knakahara Exp $    */
+/*     $NetBSD: in_gif.h,v 1.17 2017/11/15 10:42:41 knakahara Exp $    */
 /*     $KAME: in_gif.h,v 1.6 2001/07/25 00:55:48 itojun Exp $  */
 
 /*
@@ -38,7 +38,7 @@
 extern int ip_gif_ttl;
 
 struct gif_softc;
-void in_gif_input(struct mbuf *, int, int);
+void in_gif_input(struct mbuf *, int, int, void *);
 int in_gif_output(struct ifnet *, int, struct mbuf *);
 #ifdef GIF_ENCAPCHECK
 int gif_encapcheck4(struct mbuf *, int, int, void *);
diff -r bf3e2350cf2a -r 93edfd3e3806 sys/netinet/in_l2tp.c
--- a/sys/netinet/in_l2tp.c     Wed Nov 15 10:13:11 2017 +0000
+++ b/sys/netinet/in_l2tp.c     Wed Nov 15 10:42:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_l2tp.c,v 1.3 2017/07/11 05:03:45 knakahara Exp $    */
+/*     $NetBSD: in_l2tp.c,v 1.4 2017/11/15 10:42:41 knakahara Exp $    */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.3 2017/07/11 05:03:45 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.4 2017/11/15 10:42:41 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -72,7 +72,7 @@
 
 int ip_l2tp_ttl = L2TP_TTL;
 
-static void in_l2tp_input(struct mbuf *, int, int);
+static void in_l2tp_input(struct mbuf *, int, int, void *);
 
 static const struct encapsw in_l2tp_encapsw = {
        .encapsw4 = {
@@ -250,7 +250,7 @@
 }
 
 static void
-in_l2tp_input(struct mbuf *m, int off, int proto)
+in_l2tp_input(struct mbuf *m, int off, int proto, void *eparg __unused)
 {
        struct ifnet *l2tpp = NULL;
        struct l2tp_softc *sc;
diff -r bf3e2350cf2a -r 93edfd3e3806 sys/netinet/ip_encap.c
--- a/sys/netinet/ip_encap.c    Wed Nov 15 10:13:11 2017 +0000
+++ b/sys/netinet/ip_encap.c    Wed Nov 15 10:42:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_encap.c,v 1.65 2017/06/01 02:45:14 chs Exp $        */
+/*     $NetBSD: ip_encap.c,v 1.66 2017/11/15 10:42:41 knakahara Exp $  */
 /*     $KAME: ip_encap.c,v 1.73 2001/10/02 08:30:58 itojun Exp $       */
 
 /*
@@ -68,7 +68,7 @@
 #define USE_RADIX
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.65 2017/06/01 02:45:14 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_encap.c,v 1.66 2017/11/15 10:42:41 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_mrouting.h"
@@ -135,7 +135,6 @@
 static int mask_match(const struct encaptab *, const struct sockaddr *,
                const struct sockaddr *);
 #endif
-static void encap_fillarg(struct mbuf *, const struct encaptab *);
 
 /*
  * In encap[46]_lookup(), ep->func can sleep(e.g. rtalloc1) while walking
@@ -363,8 +362,7 @@
                /* found a match, "match" has the best one */
                esw = match->esw;
                if (esw && esw->encapsw4.pr_input) {
-                       encap_fillarg(m, match);
-                       (*esw->encapsw4.pr_input)(m, off, proto);
+                       (*esw->encapsw4.pr_input)(m, off, proto, match->arg);
                        psref_release(&match_psref, &match->psref,
                            encaptab.elem_class);
                } else {
@@ -506,8 +504,8 @@
                esw = match->esw;
                if (esw && esw->encapsw6.pr_input) {
                        int ret;
-                       encap_fillarg(m, match);
-                       ret = (*esw->encapsw6.pr_input)(mp, offp, proto);
+                       ret = (*esw->encapsw6.pr_input)(mp, offp, proto,
+                           match->arg);
                        psref_release(&match_psref, &match->psref,
                            encaptab.elem_class);
                        return ret;
@@ -1064,33 +1062,6 @@
 }
 #endif
 
-static void
-encap_fillarg(struct mbuf *m, const struct encaptab *ep)
-{
-       struct m_tag *mtag;
-
-       mtag = m_tag_get(PACKET_TAG_ENCAP, sizeof(void *), M_NOWAIT);
-       if (mtag) {
-               *(void **)(mtag + 1) = ep->arg;
-               m_tag_prepend(m, mtag);
-       }
-}
-
-void *
-encap_getarg(struct mbuf *m)
-{
-       void *p;
-       struct m_tag *mtag;
-
-       p = NULL;
-       mtag = m_tag_find(m, PACKET_TAG_ENCAP, NULL);
-       if (mtag != NULL) {
-               p = *(void **)(mtag + 1);
-               m_tag_delete(m, mtag);
-       }
-       return p;
-}
-
 int
 encap_lock_enter(void)
 {
diff -r bf3e2350cf2a -r 93edfd3e3806 sys/netinet/ip_encap.h
--- a/sys/netinet/ip_encap.h    Wed Nov 15 10:13:11 2017 +0000
+++ b/sys/netinet/ip_encap.h    Wed Nov 15 10:42:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_encap.h,v 1.22 2016/07/04 04:35:09 knakahara Exp $  */
+/*     $NetBSD: ip_encap.h,v 1.23 2017/11/15 10:42:41 knakahara Exp $  */
 /*     $KAME: ip_encap.h,v 1.7 2000/03/25 07:23:37 sumikawa Exp $      */
 
 /*
@@ -46,13 +46,13 @@
        union {
                struct encapsw4 {
                        void    (*pr_input)     /* input to protocol (from below) */
-                               (struct mbuf *, int, int);
+                               (struct mbuf *, int, int, void *);
                        void    *(*pr_ctlinput)         /* control input (from below) */
                                (int, const struct sockaddr *, void *, void *);
                } _encapsw4;
                struct encapsw6 {
                        int     (*pr_input)     /* input to protocol (from below) */
-                               (struct mbuf **, int *, int);
+                               (struct mbuf **, int *, int, void *);
                        void    *(*pr_ctlinput)         /* control input (from below) */
                                (int, const struct sockaddr *, void *, void *);
                } _encapsw6;
@@ -110,7 +110,6 @@
        const struct encapsw *, void *);
 void   *encap6_ctlinput(int, const struct sockaddr *, void *);
 int    encap_detach(const struct encaptab *);
-void   *encap_getarg(struct mbuf *);
 
 int    encap_lock_enter(void);
 void   encap_lock_exit(void);
diff -r bf3e2350cf2a -r 93edfd3e3806 sys/netinet/ip_mroute.c
--- a/sys/netinet/ip_mroute.c   Wed Nov 15 10:13:11 2017 +0000
+++ b/sys/netinet/ip_mroute.c   Wed Nov 15 10:42:41 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ip_mroute.c,v 1.147 2017/07/23 10:55:00 para Exp $     */
+/*     $NetBSD: ip_mroute.c,v 1.148 2017/11/15 10:42:41 knakahara Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -93,7 +93,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.147 2017/07/23 10:55:00 para Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ip_mroute.c,v 1.148 2017/11/15 10:42:41 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -188,7 +188,7 @@
 #endif /* RSVP_ISI */
 
 /* vif attachment using sys/netinet/ip_encap.c */



Home | Main Index | Thread Index | Old Index