if_transmit_lock() and if_enqueue() are equivalent. if_enqueue() is
a better name, so collapse everything down to that and garbage-collect if_transmit_lock().
This commit is contained in:
parent
0471c799cc
commit
2270ec1fa8
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_umb.c,v 1.25.8.1 2023/11/16 04:30:21 thorpej Exp $ */
|
||||
/* $NetBSD: if_umb.c,v 1.25.8.2 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
/* $OpenBSD: if_umb.c,v 1.20 2018/09/10 17:00:45 gerhard Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -26,7 +26,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.25.8.1 2023/11/16 04:30:21 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_umb.c,v 1.25.8.2 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -879,7 +879,7 @@ umb_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
|
|||
* Queue message on interface, and start output if interface
|
||||
* not yet active.
|
||||
*/
|
||||
error = if_transmit_lock(ifp, m);
|
||||
error = if_enqueue(ifp, m);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_upl.c,v 1.77.8.1 2023/11/16 04:30:21 thorpej Exp $ */
|
||||
/* $NetBSD: if_upl.c,v 1.77.8.2 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.77.8.1 2023/11/16 04:30:21 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_upl.c,v 1.77.8.2 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -276,7 +276,7 @@ upl_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
|
|||
* Queue message on interface, and start output if interface
|
||||
* not yet active.
|
||||
*/
|
||||
return if_transmit_lock(ifp, m);
|
||||
return if_enqueue(ifp, m);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
69
sys/net/if.c
69
sys/net/if.c
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if.c,v 1.529.2.1.2.3 2023/11/15 02:19:00 thorpej Exp $ */
|
||||
/* $NetBSD: if.c,v 1.529.2.1.2.4 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2008, 2023 The NetBSD Foundation, Inc.
|
||||
|
@ -90,7 +90,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.529.2.1.2.3 2023/11/15 02:19:00 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.529.2.1.2.4 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_inet.h"
|
||||
|
@ -3796,31 +3796,6 @@ out:
|
|||
return error;
|
||||
}
|
||||
|
||||
int
|
||||
if_transmit_lock(struct ifnet *ifp, struct mbuf *m)
|
||||
{
|
||||
int error;
|
||||
|
||||
kmsan_check_mbuf(m);
|
||||
|
||||
#ifdef ALTQ
|
||||
KERNEL_LOCK(1, NULL);
|
||||
if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
|
||||
error = if_transmit(ifp, m);
|
||||
KERNEL_UNLOCK_ONE(NULL);
|
||||
} else {
|
||||
KERNEL_UNLOCK_ONE(NULL);
|
||||
error = (*ifp->if_transmit)(ifp, m);
|
||||
/* mbuf is already freed */
|
||||
}
|
||||
#else /* !ALTQ */
|
||||
error = (*ifp->if_transmit)(ifp, m);
|
||||
/* mbuf is already freed */
|
||||
#endif /* !ALTQ */
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* ifq_init --
|
||||
*
|
||||
|
@ -4426,17 +4401,6 @@ ifq_classify_packet(struct ifqueue * const ifq, struct mbuf * const m,
|
|||
#endif /* ALTQ */
|
||||
}
|
||||
|
||||
/*
|
||||
* Queue message on interface, and start output if interface
|
||||
* not yet active.
|
||||
*/
|
||||
int
|
||||
if_enqueue(struct ifnet *ifp, struct mbuf *m)
|
||||
{
|
||||
|
||||
return if_transmit_lock(ifp, m);
|
||||
}
|
||||
|
||||
#ifdef ALTQ
|
||||
static void
|
||||
ifq_lock2(struct ifqueue * const ifq0, struct ifqueue * const ifq1)
|
||||
|
@ -4452,6 +4416,35 @@ ifq_lock2(struct ifqueue * const ifq0, struct ifqueue * const ifq1)
|
|||
}
|
||||
#endif /* ALTQ */
|
||||
|
||||
/*
|
||||
* Queue message on interface, and start output if interface
|
||||
* not yet active.
|
||||
*/
|
||||
int
|
||||
if_enqueue(struct ifnet *ifp, struct mbuf *m)
|
||||
{
|
||||
int error;
|
||||
|
||||
kmsan_check_mbuf(m);
|
||||
|
||||
#ifdef ALTQ
|
||||
KERNEL_LOCK(1, NULL);
|
||||
if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
|
||||
error = if_transmit(ifp, m);
|
||||
KERNEL_UNLOCK_ONE(NULL);
|
||||
} else {
|
||||
KERNEL_UNLOCK_ONE(NULL);
|
||||
error = (*ifp->if_transmit)(ifp, m);
|
||||
/* mbuf is already freed */
|
||||
}
|
||||
#else /* !ALTQ */
|
||||
error = (*ifp->if_transmit)(ifp, m);
|
||||
/* mbuf is already freed */
|
||||
#endif /* !ALTQ */
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Queue message on interface, possibly using a second fast queue
|
||||
*
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if.h,v 1.305.2.1.2.4 2023/11/16 04:30:22 thorpej Exp $ */
|
||||
/* $NetBSD: if.h,v 1.305.2.1.2.5 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1999, 2000, 2001, 2023 The NetBSD Foundation, Inc.
|
||||
|
@ -1338,8 +1338,6 @@ void p2p_rtrequest(int, struct rtentry *, const struct rt_addrinfo *);
|
|||
void if_clone_attach(struct if_clone *);
|
||||
void if_clone_detach(struct if_clone *);
|
||||
|
||||
int if_transmit_lock(struct ifnet *, struct mbuf *);
|
||||
|
||||
int if_enqueue(struct ifnet *, struct mbuf *);
|
||||
int if_enqueue2(struct ifnet *, struct ifqueue *, struct mbuf *);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_bridge.c,v 1.189.6.1.2.1 2023/11/16 05:02:23 thorpej Exp $ */
|
||||
/* $NetBSD: if_bridge.c,v 1.189.6.1.2.2 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2001 Wasabi Systems, Inc.
|
||||
|
@ -80,7 +80,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.189.6.1.2.1 2023/11/16 05:02:23 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_bridge.c,v 1.189.6.1.2.2 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -1515,7 +1515,7 @@ bridge_enqueue(struct bridge_softc *sc, struct ifnet *dst_ifp, struct mbuf *m,
|
|||
len = m->m_pkthdr.len;
|
||||
mflags = m->m_flags;
|
||||
|
||||
error = if_transmit_lock(dst_ifp, m);
|
||||
error = if_enqueue(dst_ifp, m);
|
||||
if (error) {
|
||||
/* mbuf is already freed */
|
||||
if_statinc(&sc->sc_if, if_oerrors);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_gif.c,v 1.157.8.1 2023/11/16 04:30:22 thorpej Exp $ */
|
||||
/* $NetBSD: if_gif.c,v 1.157.8.2 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
/* $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $ */
|
||||
|
||||
/*
|
||||
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.157.8.1 2023/11/16 04:30:22 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.157.8.2 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -572,7 +572,7 @@ gif_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
|
|||
m->m_pkthdr.csum_flags = 0;
|
||||
m->m_pkthdr.csum_data = 0;
|
||||
|
||||
error = if_transmit_lock(ifp, m);
|
||||
error = if_enqueue(ifp, m);
|
||||
|
||||
end:
|
||||
if (var != NULL)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_ieee1394subr.c,v 1.69.8.1 2023/11/16 04:30:22 thorpej Exp $ */
|
||||
/* $NetBSD: if_ieee1394subr.c,v 1.69.8.2 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000 The NetBSD Foundation, Inc.
|
||||
|
@ -30,7 +30,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.69.8.1 2023/11/16 04:30:22 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_ieee1394subr.c,v 1.69.8.2 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -230,7 +230,7 @@ ieee1394_output(struct ifnet *ifp, struct mbuf *m0, const struct sockaddr *dst,
|
|||
while ((m = m0) != NULL) {
|
||||
m0 = m->m_nextpkt;
|
||||
|
||||
error = if_transmit_lock(ifp, m);
|
||||
error = if_enqueue(ifp, m);
|
||||
if (error) {
|
||||
/* mbuf is already freed */
|
||||
goto bad;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_loop.c,v 1.118.8.1 2023/11/16 04:30:22 thorpej Exp $ */
|
||||
/* $NetBSD: if_loop.c,v 1.118.8.2 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
|
||||
|
@ -65,7 +65,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.118.8.1 2023/11/16 04:30:22 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_loop.c,v 1.118.8.2 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -289,7 +289,7 @@ looutput(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst,
|
|||
}
|
||||
*(mtod(m, uint32_t *)) = dst->sa_family;
|
||||
|
||||
error = if_transmit_lock(ifp, m);
|
||||
error = if_enqueue(ifp, m);
|
||||
goto out;
|
||||
}
|
||||
#endif /* ALTQ */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_spppsubr.c,v 1.267.4.2 2023/11/16 04:30:22 thorpej Exp $ */
|
||||
/* $NetBSD: if_spppsubr.c,v 1.267.4.3 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Synchronous PPP/Cisco link level subroutines.
|
||||
|
@ -41,7 +41,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.267.4.2 2023/11/16 04:30:22 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.267.4.3 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#if defined(_KERNEL_OPT)
|
||||
#include "opt_inet.h"
|
||||
|
@ -1018,7 +1018,7 @@ sppp_output(struct ifnet *ifp, struct mbuf *m,
|
|||
pktlen = m->m_pkthdr.len;
|
||||
#ifdef SPPPSUBR_MPSAFE
|
||||
SPPP_UNLOCK(sp);
|
||||
error = if_transmit_lock(ifp, m);
|
||||
error = if_enqueue(ifp, m);
|
||||
SPPP_LOCK(sp, RW_READER);
|
||||
if (error == 0)
|
||||
if_statadd(ifp, if_obytes, pktlen + sp->pp_framebytes);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_vlan.c,v 1.171.2.1.2.1 2023/11/16 05:02:23 thorpej Exp $ */
|
||||
/* $NetBSD: if_vlan.c,v 1.171.2.1.2.2 2023/11/16 05:13:13 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
|
||||
|
@ -78,7 +78,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.171.2.1.2.1 2023/11/16 05:02:23 thorpej Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: if_vlan.c,v 1.171.2.1.2.2 2023/11/16 05:13:13 thorpej Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_inet.h"
|
||||
|
@ -1318,7 +1318,7 @@ vlan_start(struct ifnet *ifp)
|
|||
continue;
|
||||
}
|
||||
|
||||
error = if_transmit_lock(p, m);
|
||||
error = if_enqueue(p, m);
|
||||
if (error) {
|
||||
/* mbuf is already freed */
|
||||
if_statinc(ifp, if_oerrors);
|
||||
|
@ -1416,7 +1416,7 @@ vlan_transmit(struct ifnet *ifp, struct mbuf *m)
|
|||
goto out;
|
||||
}
|
||||
|
||||
error = if_transmit_lock(p, m);
|
||||
error = if_enqueue(p, m);
|
||||
net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
|
||||
if (error) {
|
||||
/* mbuf is already freed */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: if_laggproto.h,v 1.18 2022/06/26 17:55:24 riastradh Exp $ */
|
||||
/* $NetBSD: if_laggproto.h,v 1.18.8.1 2023/11/16 05:13:14 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2021 Internet Initiative Japan Inc.
|
||||
|
@ -245,7 +245,7 @@ static inline int
|
|||
lagg_port_xmit(struct lagg_port *lp, struct mbuf *m)
|
||||
{
|
||||
|
||||
return if_transmit_lock(lp->lp_ifp, m);
|
||||
return if_enqueue(lp->lp_ifp, m);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
|
|
Loading…
Reference in New Issue