FreeBSD Bugzilla – Attachment 232471 Details for
Bug 262571
epair(4) interfaces stop forwarding traffic on moderate load
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch that works around the problem
epair.patch (text/plain), 3.04 KB, created by
Michael Gmelin
on 2022-03-15 14:08:19 UTC
(
hide
)
Description:
Patch that works around the problem
Filename:
MIME Type:
Creator:
Michael Gmelin
Created:
2022-03-15 14:08:19 UTC
Size:
3.04 KB
patch
obsolete
>diff --git a/sys/net/if_epair.c b/sys/net/if_epair.c >index 818f25f0c..36c37b84f 100644 >--- a/sys/net/if_epair.c >+++ b/sys/net/if_epair.c >@@ -98,11 +98,15 @@ static unsigned int next_index = 0; > #define EPAIR_LOCK() mtx_lock(&epair_n_index_mtx) > #define EPAIR_UNLOCK() mtx_unlock(&epair_n_index_mtx) > >+#define BIT_QUEUE_TASK 0 >+#define BIT_MBUF_QUEUED 1 >+ > struct epair_softc; > struct epair_queue { > int id; > struct buf_ring *rxring[2]; > volatile int ridx; /* 0 || 1 */ >+ volatile int state; /* queue state */ > struct task tx_task; > struct epair_softc *sc; > }; >@@ -171,7 +175,8 @@ epair_tx_start_deferred(void *arg, int pending) > } while (!atomic_fcmpset_int(&q->ridx, &ridx, nidx)); > epair_if_input(sc, q, ridx); > >- if (! buf_ring_empty(q->rxring[nidx])) >+ atomic_clear_int(&q->state, (1 << BIT_QUEUE_TASK)); >+ if (atomic_testandclear_int(&q->state, BIT_MBUF_QUEUED)) > taskqueue_enqueue(epair_tasks.tq[q->id], &q->tx_task); > > if_rele(sc->ifp); >@@ -186,7 +191,6 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) > short mflags; > struct epair_queue *q = NULL; > uint32_t bucket; >- bool was_empty; > #ifdef RSS > struct ether_header *eh; > #endif >@@ -234,8 +238,8 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) > #endif > q = &osc->queues[bucket]; > >+ atomic_set_int(&q->state, (1 << BIT_MBUF_QUEUED)); > ridx = atomic_load_int(&q->ridx); >- was_empty = buf_ring_empty(q->rxring[ridx]); > ret = buf_ring_enqueue(q->rxring[ridx], m); > if (ret != 0) { > /* Ring is full. */ >@@ -256,10 +260,11 @@ epair_menq(struct mbuf *m, struct epair_softc *osc) > /* Someone else received the packet. */ > if_inc_counter(oifp, IFCOUNTER_IPACKETS, 1); > >-done: >- if (was_empty) >+ if (!atomic_testandset_int(&q->state, BIT_QUEUE_TASK)) { > taskqueue_enqueue(epair_tasks.tq[bucket], &q->tx_task); >+ } > >+done: > return (0); > } > >@@ -304,9 +309,11 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) > { > struct epair_softc *sc; > struct ifnet *oifp; >- int error, len; >+ int error; >+#ifdef ALTQ >+ int len; > short mflags; >- >+#endif > if (m == NULL) > return (0); > M_ASSERTPKTHDR(m); >@@ -342,10 +349,11 @@ epair_transmit(struct ifnet *ifp, struct mbuf *m) > m_freem(m); > return (0); > } >+ >+#ifdef ALTQ > len = m->m_pkthdr.len; > mflags = m->m_flags; > >-#ifdef ALTQ > /* Support ALTQ via the classic if_start() path. */ > IF_LOCK(&ifp->if_snd); > if (ALTQ_IS_ENABLED(&ifp->if_snd)) { >@@ -538,6 +546,7 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) > q->rxring[0] = buf_ring_alloc(RXRSIZE, M_EPAIR, M_WAITOK, NULL); > q->rxring[1] = buf_ring_alloc(RXRSIZE, M_EPAIR, M_WAITOK, NULL); > q->ridx = 0; >+ q->state = 0; > q->sc = sca; > NET_TASK_INIT(&q->tx_task, 0, epair_tx_start_deferred, q); > } >@@ -560,6 +569,7 @@ epair_clone_create(struct if_clone *ifc, char *name, size_t len, caddr_t params) > q->rxring[0] = buf_ring_alloc(RXRSIZE, M_EPAIR, M_WAITOK, NULL); > q->rxring[1] = buf_ring_alloc(RXRSIZE, M_EPAIR, M_WAITOK, NULL); > q->ridx = 0; >+ q->state = 0; > q->sc = scb; > NET_TASK_INIT(&q->tx_task, 0, epair_tx_start_deferred, q); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 262571
: 232471