[Bug 194314] [ixgbe] driver makes some dangerous assumptions with struct mbuf sizing with IXGBE_RX_COPY_LEN

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Jan 29 22:12:53 UTC 2015


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194314

Garrett Cooper,425-314-3911 <ngie at FreeBSD.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rrs at FreeBSD.org

--- Comment #15 from Garrett Cooper,425-314-3911 <ngie at FreeBSD.org> ---
(In reply to Garrett Cooper,425-314-3911 from comment #14)

Hi Eric!

I confirmed that the fix you provided worked for our environment. Unfortunately
struct mbuf lacks some of the fields we have in it so it doesn't work with
FreeBSD proper. I believe this patch would work for CURRENT, based on my basic
C program:

$ clang -Wall -Wno-c++1z-extensions -std=c11 -o ~/test_ixgbe_defines
~/test_ixgbe_defines.c
$ cat ~/test_ixgbe_defines.c 
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/mbuf.h>
#include <assert.h>

#ifndef offsetof
#define offsetof        __offsetof
#endif

#define IXGBE_RX_COPY_HDR_PADDED        ((((MPKTHSIZE - 1) / 32) + 1) * 32)
#define IXGBE_RX_COPY_LEN       (MSIZE - IXGBE_RX_COPY_HDR_PADDED)
#define IXGBE_RX_COPY_ALIGN     (IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE)

static_assert(IXGBE_RX_COPY_LEN == 160);
static_assert(IXGBE_RX_COPY_ALIGN == (MHLEN - IXGBE_RX_COPY_LEN));

int
main(void)
{

        return (0);
}

I'm going to try this out internally, but could you and Adrian (or Randall,
because Netflix runs CURRENT-ish and I believe uses ixgbe in some cases) please
look at this as well to make sure that it works accordingly?

diff --git a/sys/dev/ixgbe/ixgbe.h b/sys/dev/ixgbe/ixgbe.h
index f7e9efa..1ddeebb 100644
--- a/sys/dev/ixgbe/ixgbe.h
+++ b/sys/dev/ixgbe/ixgbe.h
@@ -162,8 +162,10 @@
  * modern Intel CPUs, results in 40 bytes wasted and a significant drop
  * in observed efficiency of the optimization, 97.9% -> 81.8%.
  */
-#define IXGBE_RX_COPY_LEN      160
-#define IXGBE_RX_COPY_ALIGN    (MHLEN - IXGBE_RX_COPY_LEN)
+
+#define        IXGBE_RX_COPY_HDR_PADDED ((((MPKTHSIZE - 1) / 32) + 1) * 32)
+#define        IXGBE_RX_COPY_LEN       (MSIZE - IXGBE_RX_COPY_HDR_PADDED)
+#define        IXGBE_RX_COPY_ALIGN     (IXGBE_RX_COPY_HDR_PADDED - MPKTHSIZE)

 /* Keep older OS drivers building... */
 #if !defined(SYSCTL_ADD_UQUAD)

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-net mailing list