Wed Jan 29 04:30:42 2020 UTC ()
Adopt <net/if_stats.h>.


(thorpej)
diff -r1.10 -r1.11 src/sys/net/agr/ieee8023ad_lacp.c
diff -r1.50 -r1.51 src/sys/net/agr/if_agr.c
diff -r1.15 -r1.16 src/sys/net/npf/npf_ext_log.c

cvs diff -r1.10 -r1.11 src/sys/net/agr/ieee8023ad_lacp.c (expand / switch to unified diff)

--- src/sys/net/agr/ieee8023ad_lacp.c 2011/07/01 02:46:24 1.10
+++ src/sys/net/agr/ieee8023ad_lacp.c 2020/01/29 04:30:41 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ieee8023ad_lacp.c,v 1.10 2011/07/01 02:46:24 joerg Exp $ */ 1/* $NetBSD: ieee8023ad_lacp.c,v 1.11 2020/01/29 04:30:41 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c)2005 YAMAMOTO Takashi, 4 * Copyright (c)2005 YAMAMOTO Takashi,
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_lacp.c,v 1.10 2011/07/01 02:46:24 joerg Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: ieee8023ad_lacp.c,v 1.11 2020/01/29 04:30:41 thorpej Exp $");
31 31
32#include <sys/param.h> 32#include <sys/param.h>
33#include <sys/callout.h> 33#include <sys/callout.h>
34#include <sys/mbuf.h> 34#include <sys/mbuf.h>
35#include <sys/systm.h> 35#include <sys/systm.h>
36#include <sys/malloc.h> 36#include <sys/malloc.h>
37#include <sys/kernel.h> /* hz */ 37#include <sys/kernel.h> /* hz */
38 38
39#include <net/if.h> 39#include <net/if.h>
40#include <net/if_dl.h> 40#include <net/if_dl.h>
41#include <net/if_ether.h> 41#include <net/if_ether.h>
42#include <net/if_media.h> 42#include <net/if_media.h>
43 43
@@ -493,27 +493,27 @@ ieee8023ad_dtor(struct agr_softc *sc) @@ -493,27 +493,27 @@ ieee8023ad_dtor(struct agr_softc *sc)
493 493
494struct agr_port * 494struct agr_port *
495ieee8023ad_select_tx_port(struct agr_softc *sc, struct mbuf *m) 495ieee8023ad_select_tx_port(struct agr_softc *sc, struct mbuf *m)
496{ 496{
497 const struct lacp_softc *lsc = LACP_SOFTC(sc); 497 const struct lacp_softc *lsc = LACP_SOFTC(sc);
498 const struct lacp_aggregator *la; 498 const struct lacp_aggregator *la;
499 const struct lacp_port *lp; 499 const struct lacp_port *lp;
500 uint32_t hash; 500 uint32_t hash;
501 int nports; 501 int nports;
502 502
503 if (__predict_false(lsc->lsc_suppress_distributing && 503 if (__predict_false(lsc->lsc_suppress_distributing &&
504 !AGR_ROUNDROBIN(sc))) { 504 !AGR_ROUNDROBIN(sc))) {
505 LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__)); 505 LACP_DPRINTF((NULL, "%s: waiting transit\n", __func__));
506 sc->sc_if.if_collisions++; /* XXX abuse */ 506 if_statinc(&sc->sc_if, if_collisions); /* XXX abuse */
507 return NULL; 507 return NULL;
508 } 508 }
509 509
510 la = lsc->lsc_active_aggregator; 510 la = lsc->lsc_active_aggregator;
511 if (__predict_false(la == NULL)) { 511 if (__predict_false(la == NULL)) {
512 LACP_DPRINTF((NULL, "%s: no active aggregator\n", __func__)); 512 LACP_DPRINTF((NULL, "%s: no active aggregator\n", __func__));
513 return NULL; 513 return NULL;
514 } 514 }
515 515
516 nports = la->la_nports; 516 nports = la->la_nports;
517 KASSERT(nports > 0); 517 KASSERT(nports > 0);
518 518
519 if (AGR_ROUNDROBIN(sc)) { 519 if (AGR_ROUNDROBIN(sc)) {

cvs diff -r1.50 -r1.51 src/sys/net/agr/if_agr.c (expand / switch to unified diff)

--- src/sys/net/agr/if_agr.c 2019/10/06 15:11:17 1.50
+++ src/sys/net/agr/if_agr.c 2020/01/29 04:30:41 1.51
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_agr.c,v 1.50 2019/10/06 15:11:17 uwe Exp $ */ 1/* $NetBSD: if_agr.c,v 1.51 2020/01/29 04:30:41 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c)2005 YAMAMOTO Takashi, 4 * Copyright (c)2005 YAMAMOTO Takashi,
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -17,27 +17,27 @@ @@ -17,27 +17,27 @@
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE. 26 * SUCH DAMAGE.
27 */ 27 */
28 28
29#include <sys/cdefs.h> 29#include <sys/cdefs.h>
30__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.50 2019/10/06 15:11:17 uwe Exp $"); 30__KERNEL_RCSID(0, "$NetBSD: if_agr.c,v 1.51 2020/01/29 04:30:41 thorpej Exp $");
31 31
32#ifdef _KERNEL_OPT 32#ifdef _KERNEL_OPT
33#include "opt_inet.h" 33#include "opt_inet.h"
34#endif 34#endif
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/callout.h> 37#include <sys/callout.h>
38#include <sys/malloc.h> 38#include <sys/malloc.h>
39#include <sys/mbuf.h> 39#include <sys/mbuf.h>
40#include <sys/systm.h> 40#include <sys/systm.h>
41#include <sys/types.h> 41#include <sys/types.h>
42#include <sys/queue.h> 42#include <sys/queue.h>
43#include <sys/sockio.h> 43#include <sys/sockio.h>
@@ -146,27 +146,27 @@ agrdetach(void) @@ -146,27 +146,27 @@ agrdetach(void)
146 146
147void 147void
148agr_input(struct ifnet *ifp_port, struct mbuf *m) 148agr_input(struct ifnet *ifp_port, struct mbuf *m)
149{ 149{
150 struct ethercom *ec = (struct ethercom *)ifp_port; 150 struct ethercom *ec = (struct ethercom *)ifp_port;
151 struct agr_port *port; 151 struct agr_port *port;
152 struct ifnet *ifp; 152 struct ifnet *ifp;
153 153
154 port = ifp_port->if_agrprivate; 154 port = ifp_port->if_agrprivate;
155 KASSERT(port); 155 KASSERT(port);
156 ifp = port->port_agrifp; 156 ifp = port->port_agrifp;
157 if ((port->port_flags & AGRPORT_COLLECTING) == 0) { 157 if ((port->port_flags & AGRPORT_COLLECTING) == 0) {
158 m_freem(m); 158 m_freem(m);
159 ifp->if_ierrors++; 159 if_statinc(ifp, if_ierrors);
160 return; 160 return;
161 } 161 }
162 162
163 m_set_rcvif(m, ifp); 163 m_set_rcvif(m, ifp);
164 164
165 /* 165 /*
166 * If VLANs are configured on the interface, check to 166 * If VLANs are configured on the interface, check to
167 * see if the device performed the decapsulation and 167 * see if the device performed the decapsulation and
168 * provided us with the tag. 168 * provided us with the tag.
169 */ 169 */
170 if (ec->ec_nvlans && vlan_has_tag(m)) { 170 if (ec->ec_nvlans && vlan_has_tag(m)) {
171 MODULE_HOOK_CALL_VOID(if_vlan_vlan_input_hook, (ifp, m), 171 MODULE_HOOK_CALL_VOID(if_vlan_vlan_input_hook, (ifp, m),
172 m_freem(m)); 172 m_freem(m));
@@ -380,39 +380,41 @@ agr_start(struct ifnet *ifp) @@ -380,39 +380,41 @@ agr_start(struct ifnet *ifp)
380 struct mbuf *m; 380 struct mbuf *m;
381 381
382 AGR_LOCK(sc); 382 AGR_LOCK(sc);
383 383
384 while (/* CONSTCOND */ 1) { 384 while (/* CONSTCOND */ 1) {
385 struct agr_port *port; 385 struct agr_port *port;
386 386
387 IFQ_DEQUEUE(&ifp->if_snd, m); 387 IFQ_DEQUEUE(&ifp->if_snd, m);
388 if (m == NULL) { 388 if (m == NULL) {
389 break; 389 break;
390 } 390 }
391 bpf_mtap(ifp, m, BPF_D_OUT); 391 bpf_mtap(ifp, m, BPF_D_OUT);
392 port = agr_select_tx_port(sc, m); 392 port = agr_select_tx_port(sc, m);
 393 net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
393 if (port) { 394 if (port) {
394 int error; 395 int error;
395 396
396 error = agr_xmit_frame(port->port_ifp, m); 397 error = agr_xmit_frame(port->port_ifp, m);
397 if (error) { 398 if (error) {
398 ifp->if_oerrors++; 399 if_statinc_ref(nsr, if_oerrors);
399 } else { 400 } else {
400 ifp->if_opackets++; 401 if_statinc_ref(nsr, if_opackets);
401 } 402 }
402 } else { 403 } else {
403 m_freem(m); 404 m_freem(m);
404 ifp->if_oerrors++; 405 if_statinc_ref(nsr, if_oerrors);
405 } 406 }
 407 IF_STAT_PUTREF(ifp);
406 } 408 }
407 409
408 AGR_UNLOCK(sc); 410 AGR_UNLOCK(sc);
409 411
410 ifp->if_flags &= ~IFF_OACTIVE; 412 ifp->if_flags &= ~IFF_OACTIVE;
411} 413}
412 414
413static int 415static int
414agr_setconfig(struct agr_softc *sc, const struct agrreq *ar) 416agr_setconfig(struct agr_softc *sc, const struct agrreq *ar)
415{ 417{
416 struct ifnet *ifp = &sc->sc_if; 418 struct ifnet *ifp = &sc->sc_if;
417 int cmd = ar->ar_cmd; 419 int cmd = ar->ar_cmd;
418 struct ifnet *ifp_port; 420 struct ifnet *ifp_port;

cvs diff -r1.15 -r1.16 src/sys/net/npf/npf_ext_log.c (expand / switch to unified diff)

--- src/sys/net/npf/npf_ext_log.c 2018/09/29 14:41:36 1.15
+++ src/sys/net/npf/npf_ext_log.c 2020/01/29 04:30:41 1.16
@@ -23,27 +23,27 @@ @@ -23,27 +23,27 @@
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE. 27 * POSSIBILITY OF SUCH DAMAGE.
28 */ 28 */
29 29
30/* 30/*
31 * NPF logging extension. 31 * NPF logging extension.
32 */ 32 */
33 33
34#ifdef _KERNEL 34#ifdef _KERNEL
35#include <sys/cdefs.h> 35#include <sys/cdefs.h>
36__KERNEL_RCSID(0, "$NetBSD: npf_ext_log.c,v 1.15 2018/09/29 14:41:36 rmind Exp $"); 36__KERNEL_RCSID(0, "$NetBSD: npf_ext_log.c,v 1.16 2020/01/29 04:30:41 thorpej Exp $");
37 37
38#include <sys/types.h> 38#include <sys/types.h>
39#include <sys/module.h> 39#include <sys/module.h>
40 40
41#include <sys/conf.h> 41#include <sys/conf.h>
42#include <sys/kmem.h> 42#include <sys/kmem.h>
43#include <sys/mbuf.h> 43#include <sys/mbuf.h>
44#include <sys/mutex.h> 44#include <sys/mutex.h>
45#include <sys/queue.h> 45#include <sys/queue.h>
46 46
47#include <net/if.h> 47#include <net/if.h>
48#include <net/if_types.h> 48#include <net/if_types.h>
49#include <net/bpf.h> 49#include <net/bpf.h>
@@ -130,28 +130,27 @@ npf_log(npf_cache_t *npc, void *meta, co @@ -130,28 +130,27 @@ npf_log(npf_cache_t *npc, void *meta, co
130 } 130 }
131 131
132 KERNEL_LOCK(1, NULL); 132 KERNEL_LOCK(1, NULL);
133 133
134 /* Find a pseudo-interface to log. */ 134 /* Find a pseudo-interface to log. */
135 ifp = if_get_byindex(log->if_idx, &psref); 135 ifp = if_get_byindex(log->if_idx, &psref);
136 if (ifp == NULL) { 136 if (ifp == NULL) {
137 /* No interface. */ 137 /* No interface. */
138 KERNEL_UNLOCK_ONE(NULL); 138 KERNEL_UNLOCK_ONE(NULL);
139 return true; 139 return true;
140 } 140 }
141 141
142 /* Pass through BPF. */ 142 /* Pass through BPF. */
143 ifp->if_opackets++; 143 if_statadd2(ifp, if_opackets, 1, if_obytes, m->m_pkthdr.len);
144 ifp->if_obytes += m->m_pkthdr.len; 
145 if (ifp->if_bpf) { 144 if (ifp->if_bpf) {
146 bpf_mtap2(ifp->if_bpf, &hdr, NPFLOG_HDRLEN, m, BPF_D_OUT); 145 bpf_mtap2(ifp->if_bpf, &hdr, NPFLOG_HDRLEN, m, BPF_D_OUT);
147 } 146 }
148 if_put(ifp, &psref); 147 if_put(ifp, &psref);
149 148
150 KERNEL_UNLOCK_ONE(NULL); 149 KERNEL_UNLOCK_ONE(NULL);
151 150
152 return true; 151 return true;
153} 152}
154 153
155/* 154/*
156 * Module interface. 155 * Module interface.
157 */ 156 */