Date: Thu, 29 Jan 2015 22:12:53 +0000 From: bugzilla-noreply@freebsd.org To: freebsd-net@FreeBSD.org Subject: [Bug 194314] [ixgbe] driver makes some dangerous assumptions with struct mbuf sizing with IXGBE_RX_COPY_LEN Message-ID: <bug-194314-2472-H1hg5ue8ZG@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-194314-2472@https.bugs.freebsd.org/bugzilla/> References: <bug-194314-2472@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194314 Garrett Cooper,425-314-3911 <ngie@FreeBSD.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rrs@FreeBSD.org --- Comment #15 from Garrett Cooper,425-314-3911 <ngie@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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-194314-2472-H1hg5ue8ZG>