Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve m_pullup2() lookalike in loopback output.

  • Loading branch information...
commit ed8d6521e31cf3d1731600d7770019910220bdef 1 parent c063112
itojun authored
Showing with 30 additions and 16 deletions.
  1. +30 −16 openbsd/sys/net/if_loop.c
View
46 openbsd/sys/net/if_loop.c
@@ -218,38 +218,52 @@ looutput(ifp, m, dst, rt)
rt->rt_flags & RTF_HOST ? EHOSTUNREACH : ENETUNREACH);
}
+#ifndef PULLDOWN_TEST
/*
* KAME requires that the packet to be contiguous on the
* mbuf. We need to make that sure.
* this kind of code should be avoided.
- * XXX: fails to join if interface MTU > MCLBYTES. jumbogram?
+ * XXX other conditions to avoid running this part?
*/
- if (m && m->m_next != NULL && m->m_pkthdr.len < MCLBYTES) {
+ if (m && m->m_next != NULL) {
struct mbuf *n;
MGETHDR(n, M_DONTWAIT, MT_HEADER);
- if (!n)
- goto contiguousfail;
- MCLGET(n, M_DONTWAIT);
- if (! (n->m_flags & M_EXT)) {
- m_freem(n);
- goto contiguousfail;
+ if (n) {
+ MCLGET(n, M_DONTWAIT);
+ if ((n->m_flags & M_EXT) == 0) {
+ m_free(n);
+ n = NULL;
+ }
+ }
+ if (!n) {
+ printf("looutput: mbuf allocation failed\n");
+ m_freem(m);
+ return ENOBUFS;
}
- m_copydata(m, 0, m->m_pkthdr.len, mtod(n, caddr_t));
n->m_pkthdr.rcvif = m->m_pkthdr.rcvif;
n->m_pkthdr.len = m->m_pkthdr.len;
- n->m_len = m->m_pkthdr.len;
- m_freem(m);
+ if (m->m_pkthdr.len <= MCLBYTES) {
+ m_copydata(m, 0, m->m_pkthdr.len, mtod(n, caddr_t));
+ n->m_len = m->m_pkthdr.len;
+ m_freem(m);
+ } else {
+ m_copydata(m, 0, MCLBYTES, mtod(n, caddr_t));
+ m_adj(m, MCLBYTES);
+ n->m_len = MCLBYTES;
+ n->m_next = m;
+ m->m_flags &= ~M_PKTHDR;
+ }
m = n;
}
- if (0) {
-contiguousfail:
- printf("looutput: mbuf allocation failed\n");
- }
#if 0
- if (m && m->m_next != NULL)
+ if (m && m->m_next != NULL) {
printf("loop: not contiguous...\n");
+ m_freem(m);
+ return ENOBUFS;
+ }
+#endif
#endif
ifp->if_opackets++;
Please sign in to comment.
Something went wrong with that request. Please try again.