Source-Changes-HG archive

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

[src/netbsd-8]: src/sys Pull up following revision(s) (requested by knakahara...



details:   https://anonhg.NetBSD.org/src/rev/c2103b7d5ca3
branches:  netbsd-8
changeset: 435255:c2103b7d5ca3
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Sep 10 15:58:47 2018 +0000

description:
Pull up following revision(s) (requested by knakahara in ticket #1018):

        sys/netinet6/in6_l2tp.c: revision 1.17
        sys/netinet/in_l2tp.c: revision 1.16

fix: l2tp(4) cannot receive packets after reset session without reset tunnel. Pointed out by k-goda@IIJ

When the following operations are done after established session, the l2tp0
cannot receive packets until done deletetunnel && tunnel "src" "dst".

====================
ifconfig l2tp0 deletesession
ifconfig l2tp0 deletecookie
ifconfig l2tp0 session 200 100
====================

XXX pullup-8

diffstat:

 sys/netinet/in_l2tp.c   |  34 +++++++++++++++++++++++++---------
 sys/netinet6/in6_l2tp.c |  34 +++++++++++++++++++++++++---------
 2 files changed, 50 insertions(+), 18 deletions(-)

diffs (156 lines):

diff -r 26c85bee45f5 -r c2103b7d5ca3 sys/netinet/in_l2tp.c
--- a/sys/netinet/in_l2tp.c     Mon Sep 10 15:52:36 2018 +0000
+++ b/sys/netinet/in_l2tp.c     Mon Sep 10 15:58:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in_l2tp.c,v 1.2.8.6 2018/07/13 14:26:47 martin Exp $   */
+/*     $NetBSD: in_l2tp.c,v 1.2.8.7 2018/09/10 15:58:47 martin 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.2.8.6 2018/07/13 14:26:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in_l2tp.c,v 1.2.8.7 2018/09/10 15:58:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -368,16 +368,25 @@
 static int
 in_l2tp_match(struct mbuf *m, int off, int proto, void *arg)
 {
-       struct l2tp_variant *var = arg;
+       struct l2tp_softc *sc = arg;
+       struct l2tp_variant *var;
+       struct psref psref;
        uint32_t sess_id;
+       int rv = 0;
 
        KASSERT(proto == IPPROTO_L2TP);
 
+       var = l2tp_getref_variant(sc, &psref);
+       if (__predict_false(var == NULL))
+               return rv;
+
        /*
         * If the packet contains no session ID it cannot match
         */
-       if (m_length(m) < off + sizeof(uint32_t))
-               return 0;
+       if (m_length(m) < off + sizeof(uint32_t)) {
+               rv = 0;
+               goto out;
+       }
 
        /* get L2TP session ID */
        m_copydata(m, off, sizeof(uint32_t), (void *)&sess_id);
@@ -387,19 +396,26 @@
                 * L2TPv3 control packet received.
                 * userland daemon(l2tpd?) should process.
                 */
-               return 32 * 2;
+               rv = 32 * 2;
        } else if (sess_id == var->lv_my_sess_id)
-               return 32 * 2;
+               rv = 32 * 2;
        else
-               return 0;
+               rv = 0;
+
+out:
+       l2tp_putref_variant(var, &psref);
+       return rv;
 }
 
 int
 in_l2tp_attach(struct l2tp_variant *var)
 {
+       struct l2tp_softc *sc = var->lv_softc;
 
+       if (sc == NULL)
+               return EINVAL;
        var->lv_encap_cookie = encap_attach_func(AF_INET, IPPROTO_L2TP,
-           in_l2tp_match, &in_l2tp_encapsw, var);
+           in_l2tp_match, &in_l2tp_encapsw, sc);
        if (var->lv_encap_cookie == NULL)
                return EEXIST;
 
diff -r 26c85bee45f5 -r c2103b7d5ca3 sys/netinet6/in6_l2tp.c
--- a/sys/netinet6/in6_l2tp.c   Mon Sep 10 15:52:36 2018 +0000
+++ b/sys/netinet6/in6_l2tp.c   Mon Sep 10 15:58:47 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: in6_l2tp.c,v 1.5.8.6 2018/07/13 14:26:47 martin Exp $  */
+/*     $NetBSD: in6_l2tp.c,v 1.5.8.7 2018/09/10 15:58:47 martin Exp $  */
 
 /*
  * Copyright (c) 2017 Internet Initiative Japan Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5.8.6 2018/07/13 14:26:47 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: in6_l2tp.c,v 1.5.8.7 2018/09/10 15:58:47 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_l2tp.h"
@@ -361,16 +361,25 @@
 static int
 in6_l2tp_match(struct mbuf *m, int off, int proto, void *arg)
 {
-       struct l2tp_variant *var = arg;
+       struct l2tp_softc *sc = arg;
+       struct l2tp_variant *var;
+       struct psref psref;
        uint32_t sess_id;
+       int rv = 0;
 
        KASSERT(proto == IPPROTO_L2TP);
 
+       var = l2tp_getref_variant(sc, &psref);
+       if (__predict_false(var == NULL))
+               return rv;
+
        /*
         * If the packet contains no session ID it cannot match
         */
-       if (m_length(m) < off + sizeof(uint32_t))
-               return 0;
+       if (m_length(m) < off + sizeof(uint32_t)) {
+               rv = 0 ;
+               goto out;
+       }
 
        /* get L2TP session ID */
        m_copydata(m, off, sizeof(uint32_t), (void *)&sess_id);
@@ -380,19 +389,26 @@
                 * L2TPv3 control packet received.
                 * userland daemon(l2tpd?) should process.
                 */
-               return 128 * 2;
+               rv = 128 * 2;
        } else if (sess_id == var->lv_my_sess_id)
-               return 128 * 2;
+               rv = 128 * 2;
        else
-               return 0;
+               rv = 0;
+
+out:
+       l2tp_putref_variant(var, &psref);
+       return rv;
 }
 
 int
 in6_l2tp_attach(struct l2tp_variant *var)
 {
+       struct l2tp_softc *sc = var->lv_softc;
 
+       if (sc == NULL)
+               return EINVAL;
        var->lv_encap_cookie = encap_attach_func(AF_INET6, IPPROTO_L2TP,
-           in6_l2tp_match, &in6_l2tp_encapsw, var);
+           in6_l2tp_match, &in6_l2tp_encapsw, sc);
        if (var->lv_encap_cookie == NULL)
                return EEXIST;
 



Home | Main Index | Thread Index | Old Index