Re: [PATCH] Packet mmap : allow the user to choose the offset of the tx payload.
flat view
From: Daniel Borkmann <hidden>
Date: 2012-10-05 19:38:07
On Fri, Oct 5, 2012 at 9:21 PM, pchavent [off-list ref] wrote:
On Fri, 5 Oct 2012 16:17:12 +0200, Daniel Borkmann wrote:quoted
On Fri, Oct 5, 2012 at 3:10 PM, Paul Chavent [off-list ref] wrote:quoted
The tx offset of packet mmap tx ring used to be : (TPACKET2_HDRLEN - sizeof(struct sockaddr_ll)) The problem is that depending on the usage of SOCK_DGRAM or SOCK_RAW, the payload could be aligned or not. This patch allow to let the user give an offset for it's tx payload if he desires. Signed-off-by: Paul Chavent <redacted>Can you provide an example when it doesn't hit TPACKET_ALIGNMENT?When we use tx ring, the user have to write at (TPACKET_HDRLEN - sizeof(struct sockaddr_ll)) This adress is aligned on TPACKET_ALIGNMENT since TPACKET_HDRLEN = (TPACKET_ALIGN(sizeof(struct tpacket_hdr)) + sizeof(struct sockaddr_ll)) When we use the tx ring with SOCK_RAW option, the mac header is aligned on TPACKET_ALIGNMENT, but not the payload (14 bytes away).
Okay, I'm confused about your intentions, maybe I'm missing something. The man-page of packet(7) clearly says: The socket_type is either SOCK_RAW for raw packets *including* the link level header or SOCK_DGRAM for cooked packets with the link level header *removed*. So this is perfectly intended behavior of PF_PACKET. Cheers, Daniel