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 ozaki-r i...



details:   https://anonhg.NetBSD.org/src/rev/3b9d5a163ee9
branches:  netbsd-8
changeset: 434607:3b9d5a163ee9
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Feb 05 14:55:15 2018 +0000

description:
Pull up following revision(s) (requested by ozaki-r in ticket #528):
        sys/net/agr/if_agr.c: revision 1.42
        sys/netinet6/nd6_rtr.c: revision 1.137
        sys/netinet6/nd6_rtr.c: revision 1.138
        sys/net/agr/if_agr.c: revision 1.46
        sys/net/route.c: revision 1.206
        sys/net/if.c: revision 1.419
        sys/net/agr/if_agrether.c: revision 1.10
        sys/netinet6/nd6.c: revision 1.241
        sys/netinet6/nd6.c: revision 1.242
        sys/netinet6/nd6.c: revision 1.243
        sys/netinet6/nd6.c: revision 1.244
        sys/netinet6/nd6.c: revision 1.245
        sys/netipsec/ipsec_input.c: revision 1.52
        sys/netipsec/ipsec_input.c: revision 1.53
        sys/net/agr/if_agrsubr.h: revision 1.5
        sys/kern/subr_workqueue.c: revision 1.35
        sys/netipsec/ipsec.c: revision 1.124
        sys/net/agr/if_agrsubr.c: revision 1.11
        sys/net/agr/if_agrsubr.c: revision 1.12
Simplify; share agr_vlan_add and agr_vlan_del (NFCI)
Fix late NULL-checking (CID 1427782: Null pointer dereferences (REVERSE_INULL))
KNF: replace soft tabs with hard tabs
Add missing NULL-checking for m_pullup (CID 1427770: Null pointer dereferences (NULL_RETURNS))
Add locking.
Revert "Get rid of unnecessary splsoftnet" (v1.133)
It's not always true that softnet_lock is held these places.
See PR kern/52947.
Get rid of unnecessary splsoftnet (redo)
Unless NET_MPSAFE, splsoftnet is still needed for rt_* functions.
Use existing fill_[pd]rlist() functions to calculate size of buffer to
allocate, rather than relying on an arbitrary length passed in from
userland.
Allow copyout() of partial results if the user buffer is too small, to
be consistent with the way sysctl(3) is documented.
Garbage-collect now-unused third parrameter in the fill_[pd]rlist()
functions.
As discussed on IRC.
OK kamil@ and christos@
XXX Needs pull-up to netbsd-8 branch.
Simplify, from christos@
More simplification, this time from ozaki-r@
No need to break after return.
One more from christos@
No need to initialize fill_func
more cleanup (don't allow oldlenp == NULL)
Destroy ifq_lock at the end of if_detach
It still can be used in if_detach.
Prevent rt_free_global.wk from being enqueued to workqueue doubly
Check if a queued work is tried to be enqueued again, which is not allowed

diffstat:

 sys/kern/subr_workqueue.c  |  20 +++++++++-
 sys/net/agr/if_agr.c       |  65 +++-------------------------------
 sys/net/agr/if_agrether.c  |  36 ++++--------------
 sys/net/agr/if_agrsubr.c   |  71 ++++++++++++++++++++++++++++++++++++-
 sys/net/agr/if_agrsubr.h   |   5 ++-
 sys/net/if.c               |   7 +--
 sys/net/route.c            |  12 ++++-
 sys/netinet6/nd6.c         |  79 +++++++++++++++++++----------------------
 sys/netinet6/nd6_rtr.c     |  23 ++++++++---
 sys/netipsec/ipsec.c       |   9 ++--
 sys/netipsec/ipsec_input.c |  87 +++++++++++++++++++++++----------------------
 11 files changed, 219 insertions(+), 195 deletions(-)

diffs (truncated from 779 to 300 lines):

diff -r ba77a6894902 -r 3b9d5a163ee9 sys/kern/subr_workqueue.c
--- a/sys/kern/subr_workqueue.c Mon Feb 05 14:18:00 2018 +0000
+++ b/sys/kern/subr_workqueue.c Mon Feb 05 14:55:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_workqueue.c,v 1.33.30.1 2018/01/16 13:01:10 martin Exp $  */
+/*     $NetBSD: subr_workqueue.c,v 1.33.30.2 2018/02/05 14:55:16 martin Exp $  */
 
 /*-
  * Copyright (c)2002, 2005, 2006, 2007 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.33.30.1 2018/01/16 13:01:10 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_workqueue.c,v 1.33.30.2 2018/02/05 14:55:16 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/cpu.h>
@@ -354,6 +354,19 @@
        kmem_free(wq->wq_ptr, workqueue_size(wq->wq_flags));
 }
 
+#ifdef DEBUG
+static void
+workqueue_check_duplication(struct workqueue_queue *q, work_impl_t *wk)
+{
+       work_impl_t *_wk;
+
+       SIMPLEQ_FOREACH(_wk, &q->q_queue_pending, wk_entry) {
+               if (_wk == wk)
+                       panic("%s: tried to enqueue a queued work", __func__);
+       }
+}
+#endif
+
 void
 workqueue_enqueue(struct workqueue *wq, struct work *wk0, struct cpu_info *ci)
 {
@@ -365,6 +378,9 @@
 
        mutex_enter(&q->q_mutex);
        KASSERT(q->q_waiter == NULL);
+#ifdef DEBUG
+       workqueue_check_duplication(q, wk);
+#endif
        SIMPLEQ_INSERT_TAIL(&q->q_queue_pending, wk, wk_entry);
        cv_signal(&q->q_cv);
        mutex_exit(&q->q_mutex);
diff -r ba77a6894902 -r 3b9d5a163ee9 sys/net/agr/if_agr.c
--- a/sys/net/agr/if_agr.c      Mon Feb 05 14:18:00 2018 +0000
+++ b/sys/net/agr/if_agr.c      Mon Feb 05 14:55:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_agr.c,v 1.41.6.1 2018/01/02 10:20:33 snj Exp $      */
+/*     $NetBSD: if_agr.c,v 1.41.6.2 2018/02/05 14:55:15 martin Exp $   */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.41.6.1 2018/01/02 10:20:33 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.41.6.2 2018/02/05 14:55:15 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -254,62 +254,6 @@
 /*
  * INTERNAL FUNCTIONS
  */
-
-/*
- * Enable vlan hardware assist for the specified port.
- */
-static int
-agr_vlan_add(struct agr_port *port, void *arg)
-{
-       struct ifnet *ifp = port->port_ifp;
-       struct ethercom *ec_port = (void *)ifp;
-       int error=0;
-
-       if (ec_port->ec_nvlans++ == 0 &&
-           (ec_port->ec_capabilities & ETHERCAP_VLAN_MTU) != 0) {
-               struct ifnet *p = port->port_ifp;
-               /*
-                * Enable Tx/Rx of VLAN-sized frames.
-                */
-               ec_port->ec_capenable |= ETHERCAP_VLAN_MTU;
-               if (p->if_flags & IFF_UP) {
-                       error = if_flags_set(p, p->if_flags);
-                       if (error) {
-                               if (ec_port->ec_nvlans-- == 1)
-                                       ec_port->ec_capenable &=
-                                           ~ETHERCAP_VLAN_MTU;
-                               return (error);
-                       }
-               }
-       }
-
-       return error;
-}
-
-/*
- * Disable vlan hardware assist for the specified port.
- */
-static int
-agr_vlan_del(struct agr_port *port, void *arg)
-{
-       struct ethercom *ec_port = (void *)port->port_ifp;
-
-       /* Disable vlan support */
-       if (ec_port->ec_nvlans-- == 1) {
-               /*
-                * Disable Tx/Rx of VLAN-sized frames.
-                */
-               ec_port->ec_capenable &= ~ETHERCAP_VLAN_MTU;
-               if (port->port_ifp->if_flags & IFF_UP) {
-                       (void)if_flags_set(port->port_ifp,
-                           port->port_ifp->if_flags);
-               }
-       }
-
-       return 0;
-}
-
-
 /*
  * Check for vlan attach/detach.
  * ec->ec_nvlans is directly modified by the vlan driver.
@@ -332,8 +276,9 @@
                agr_port_foreach(sc, agr_vlan_add, NULL);
                sc->sc_nvlans = ec->ec_nvlans;
        } else if (ec->ec_nvlans == 0) {
+               bool force_zero = false;
                /* vlan removed */
-               agr_port_foreach(sc, agr_vlan_del, NULL);
+               agr_port_foreach(sc, agr_vlan_del, &force_zero);
                sc->sc_nvlans = 0;
        }
 }
@@ -673,7 +618,9 @@
         * of each port to that of the first port. No need for arps 
         * since there are no inet addresses assigned to the ports.
         */
+       IFNET_LOCK(ifp_port);
        error = if_addr_init(ifp_port, ifp->if_dl, true);
+       IFNET_UNLOCK(ifp_port);
 
        if (error) {
                printf("%s: if_addr_init error %d\n", __func__, error);
diff -r ba77a6894902 -r 3b9d5a163ee9 sys/net/agr/if_agrether.c
--- a/sys/net/agr/if_agrether.c Mon Feb 05 14:18:00 2018 +0000
+++ b/sys/net/agr/if_agrether.c Mon Feb 05 14:55:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_agrether.c,v 1.9 2011/10/19 01:49:50 dyoung Exp $   */
+/*     $NetBSD: if_agrether.c,v 1.9.46.1 2018/02/05 14:55:15 martin Exp $      */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agrether.c,v 1.9 2011/10/19 01:49:50 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agrether.c,v 1.9.46.1 2018/02/05 14:55:15 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/callout.h>
@@ -166,23 +166,10 @@
        }
 
        /* Enable vlan support */
-       if ((ec->ec_nvlans > 0) && 
-            ec_port->ec_nvlans++ == 0 &&
-           (ec_port->ec_capabilities & ETHERCAP_VLAN_MTU) != 0) {
-               struct ifnet *p = port->port_ifp;
-               /*
-                * Enable Tx/Rx of VLAN-sized frames.
-                */
-               ec_port->ec_capenable |= ETHERCAP_VLAN_MTU;
-               if (p->if_flags & IFF_UP) {
-                       error = if_flags_set(p, p->if_flags);
-                       if (error) {
-                               if (ec_port->ec_nvlans-- == 1)
-                                       ec_port->ec_capenable &=
-                                           ~ETHERCAP_VLAN_MTU;
-                               return (error);
-                       }
-               }
+       if (ec->ec_nvlans > 0) {
+               error = agr_vlan_add(port, NULL);
+               if (error != 0)
+                       return error;
        }
        /* XXX ETHERCAP_JUMBO_MTU */
 
@@ -225,16 +212,9 @@
        }
 
        if (ec_port->ec_nvlans > 0) {
+               bool force = true;
                /* Disable vlan support */
-               ec_port->ec_nvlans = 0;
-               /*
-                * Disable Tx/Rx of VLAN-sized frames.
-                */
-               ec_port->ec_capenable &= ~ETHERCAP_VLAN_MTU;
-               if (port->port_ifp->if_flags & IFF_UP) {
-                       (void)if_flags_set(port->port_ifp,
-                           port->port_ifp->if_flags);
-               }
+               agr_vlan_del(port, &force);
        }
 
        memset(&ifr, 0, sizeof(ifr));
diff -r ba77a6894902 -r 3b9d5a163ee9 sys/net/agr/if_agrsubr.c
--- a/sys/net/agr/if_agrsubr.c  Mon Feb 05 14:18:00 2018 +0000
+++ b/sys/net/agr/if_agrsubr.c  Mon Feb 05 14:55:15 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_agrsubr.c,v 1.10 2015/08/24 22:21:26 pooka Exp $    */
+/*     $NetBSD: if_agrsubr.c,v 1.10.10.1 2018/02/05 14:55:15 martin Exp $      */
 
 /*-
  * Copyright (c)2005 YAMAMOTO Takashi,
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_agrsubr.c,v 1.10 2015/08/24 22:21:26 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_agrsubr.c,v 1.10.10.1 2018/02/05 14:55:15 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -42,6 +42,7 @@
 #include <sys/sockio.h>
 
 #include <net/if.h>
+#include <net/if_ether.h>
 
 #include <net/agr/if_agrvar_impl.h>
 #include <net/agr/if_agrsubr.h>
@@ -272,3 +273,69 @@
 
        return error;
 }
+
+/* ==================== */
+
+/*
+ * Enable vlan hardware assist for the specified port.
+ */
+int
+agr_vlan_add(struct agr_port *port, void *arg)
+{
+       struct ifnet *ifp = port->port_ifp;
+       struct ethercom *ec_port = (void *)ifp;
+       int error=0;
+
+       if (ec_port->ec_nvlans++ == 0 &&
+           (ec_port->ec_capabilities & ETHERCAP_VLAN_MTU) != 0) {
+               struct ifnet *p = port->port_ifp;
+               /*
+                * Enable Tx/Rx of VLAN-sized frames.
+                */
+               ec_port->ec_capenable |= ETHERCAP_VLAN_MTU;
+               if (p->if_flags & IFF_UP) {
+                       IFNET_LOCK(p);
+                       error = if_flags_set(p, p->if_flags);
+                       IFNET_UNLOCK(p);
+                       if (error) {
+                               if (ec_port->ec_nvlans-- == 1)
+                                       ec_port->ec_capenable &=
+                                           ~ETHERCAP_VLAN_MTU;
+                               return (error);
+                       }
+               }
+       }
+
+       return error;
+}
+
+/*
+ * Disable vlan hardware assist for the specified port.
+ */
+int
+agr_vlan_del(struct agr_port *port, void *arg)
+{
+       struct ethercom *ec_port = (void *)port->port_ifp;
+       bool *force_zero = (bool *)arg;
+
+       KASSERT(force_zero != NULL);
+
+       /* Disable vlan support */
+       if ((*force_zero && ec_port->ec_nvlans > 0) ||
+           ec_port->ec_nvlans-- == 1) {
+               struct ifnet *p = port->port_ifp;
+               if (*force_zero)
+                       ec_port->ec_nvlans = 0;
+               /*
+                * Disable Tx/Rx of VLAN-sized frames.



Home | Main Index | Thread Index | Old Index