Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F166970472
D58843.id184043.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D58843.id184043.diff
View Options
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -3262,13 +3262,12 @@
*pullups = 0;
m = *mp;
if (!M_WRITABLE(m)) {
- if ((m = m_dup(m, M_NOWAIT)) == NULL) {
+ m = m_dup(m, M_NOWAIT);
+ m_freem(*mp);
+ DBG_COUNTER_INC(tx_frees);
+ *mp = m;
+ if (m == NULL)
return (ENOMEM);
- } else {
- m_freem(*mp);
- DBG_COUNTER_INC(tx_frees);
- *mp = m;
- }
}
/* Fills out pi->ipi_etype */
@@ -3364,13 +3363,12 @@
m = *mp;
if ((sctx->isc_flags & IFLIB_NEED_SCRATCH) &&
M_WRITABLE(m) == 0) {
- if ((m = m_dup(m, M_NOWAIT)) == NULL) {
+ m = m_dup(m, M_NOWAIT);
+ m_freem(*mp);
+ DBG_COUNTER_INC(tx_frees);
+ *mp = m;
+ if (m == NULL)
return (ENOMEM);
- } else {
- m_freem(*mp);
- DBG_COUNTER_INC(tx_frees);
- *mp = m;
- }
}
/* Fills out pi->ipi_etype */
@@ -3405,6 +3403,9 @@
txq->ift_pullups++;
if ((m = m_pullup(m, hlen)) == NULL)
return (ENOMEM);
+ /* reset pointers after pullup */
+ ip = (struct ip *)(m->m_data + pi->ipi_ehdrlen);
+ th = (struct tcphdr *)((char *)ip + (ip->ip_hl << 2));
}
pi->ipi_ip_hlen = ip->ip_hl << 2;
pi->ipi_ipproto = ip->ip_p;
@@ -3419,8 +3420,7 @@
pi->ipi_tcp_seq = th->th_seq;
}
if (IS_TSO4(pi)) {
- if (__predict_false(ip->ip_p != IPPROTO_TCP))
- return (ENXIO);
+ MPASS(ip->ip_p == IPPROTO_TCP);
/*
* TSO always requires hardware checksum offload.
*/
@@ -3451,6 +3451,8 @@
txq->ift_pullups++;
if (__predict_false((m = m_pullup(m, pi->ipi_ehdrlen + sizeof(struct ip6_hdr))) == NULL))
return (ENOMEM);
+ /* reset pointers after pullup */
+ ip6 = (struct ip6_hdr *)(m->m_data + pi->ipi_ehdrlen);
}
th = (struct tcphdr *)((caddr_t)ip6 + pi->ipi_ip_hlen);
@@ -3466,14 +3468,16 @@
txq->ift_pullups++;
if (__predict_false((m = m_pullup(m, pi->ipi_ehdrlen + sizeof(struct ip6_hdr) + sizeof(struct tcphdr))) == NULL))
return (ENOMEM);
+ /* reset pointers after pullup */
+ ip6 = (struct ip6_hdr *)(m->m_data + pi->ipi_ehdrlen);
+ th = (struct tcphdr *)((caddr_t)ip6 + pi->ipi_ip_hlen);
}
pi->ipi_tcp_hflags = tcp_get_flags(th);
pi->ipi_tcp_hlen = th->th_off << 2;
pi->ipi_tcp_seq = th->th_seq;
}
if (IS_TSO6(pi)) {
- if (__predict_false(ip6->ip6_nxt != IPPROTO_TCP))
- return (ENXIO);
+ MPASS(ip6->ip6_nxt == IPPROTO_TCP);
/*
* TSO always requires hardware checksum offload.
*/
@@ -3539,15 +3543,14 @@
if (!M_WRITABLE(*m_head)) {
new_head = m_dup(*m_head, M_NOWAIT);
+ m_freem(*m_head);
+ *m_head = new_head;
if (new_head == NULL) {
- m_freem(*m_head);
device_printf(dev, "cannot pad short frame, m_dup() failed");
DBG_COUNTER_INC(encap_pad_mbuf_fail);
DBG_COUNTER_INC(tx_frees);
return (ENOMEM);
}
- m_freem(*m_head);
- *m_head = new_head;
}
for (n = min_frame_size - (*m_head)->m_pkthdr.len;
@@ -3560,7 +3563,7 @@
device_printf(dev, "cannot pad short frame\n");
DBG_COUNTER_INC(encap_pad_mbuf_fail);
DBG_COUNTER_INC(tx_frees);
- return (ENOBUFS);
+ return (ENOMEM);
}
return (0);
@@ -3665,8 +3668,7 @@
goto retry;
break;
case ENOMEM:
- txq->ift_no_tx_dma_setup++;
- break;
+ /* FALLTHROUGH */
default:
txq->ift_no_tx_dma_setup++;
m_freem(*m_headp);
@@ -3776,6 +3778,9 @@
}
goto defrag_failed;
}
+ /* mp_ring assumes ENOBUFS means we didn't consume the mbuf */
+ if (err == ENOBUFS && !ctx->ifc_sysctl_simple_tx)
+ err = ENOMEM;
goto out_with_error;
}
/*
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 6:47 AM (8 h, 25 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
36781592
Default Alt Text
D58843.id184043.diff (3 KB)
Attached To
Mode
D58843: iflib: Fix several memory handling issues around iflib_encap()
Attached
Detach File
Event Timeline
Log In to Comment