This commit is contained in:
purplerain 2023-05-13 14:25:18 +00:00
parent f609457dcf
commit 62073e0295
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
318 changed files with 8112 additions and 4346 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: if.c,v 1.694 2023/04/26 19:54:35 mvs Exp $ */
/* $OpenBSD: if.c,v 1.695 2023/05/07 16:23:23 bluhm Exp $ */
/* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */
/*
@ -761,27 +761,6 @@ if_enqueue_ifq(struct ifnet *ifp, struct mbuf *m)
return (0);
}
void
if_mqoutput(struct ifnet *ifp, struct mbuf_queue *mq, unsigned int *total,
struct sockaddr *dst, struct rtentry *rt)
{
struct mbuf_list ml;
struct mbuf *m;
unsigned int len;
mq_delist(mq, &ml);
len = ml_len(&ml);
while ((m = ml_dequeue(&ml)) != NULL)
ifp->if_output(ifp, m, rt_key(rt), rt);
/* XXXSMP we also discard if other CPU enqueues */
if (mq_len(mq) > 0) {
/* mbuf is back in queue. Discard. */
atomic_sub_int(total, len + mq_purge(mq));
} else
atomic_sub_int(total, len);
}
void
if_input(struct ifnet *ifp, struct mbuf_list *ml)
{
@ -843,6 +822,46 @@ if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af)
return (0);
}
int
if_output_ml(struct ifnet *ifp, struct mbuf_list *ml,
struct sockaddr *dst, struct rtentry *rt)
{
struct mbuf *m;
int error = 0;
while ((m = ml_dequeue(ml)) != NULL) {
error = ifp->if_output(ifp, m, dst, rt);
if (error)
break;
}
if (error)
ml_purge(ml);
return error;
}
int
if_output_mq(struct ifnet *ifp, struct mbuf_queue *mq, unsigned int *total,
struct sockaddr *dst, struct rtentry *rt)
{
struct mbuf_list ml;
unsigned int len;
int error;
mq_delist(mq, &ml);
len = ml_len(&ml);
error = if_output_ml(ifp, &ml, dst, rt);
/* XXXSMP we also discard if other CPU enqueues */
if (mq_len(mq) > 0) {
/* mbuf is back in queue. Discard. */
atomic_sub_int(total, len + mq_purge(mq));
} else
atomic_sub_int(total, len);
return error;
}
int
if_output_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af)
{