From 0d00efc6f2938919ea8f5803a6fe2b4a1c332cd1 Mon Sep 17 00:00:00 2001 From: Daniel Borkmann Date: Wed, 28 Nov 2012 15:23:37 +0100 Subject: [PATCH] ring: fix sll packet alignment Signed-off-by: Daniel Borkmann --- TODO | 3 --- src/built_in.h | 4 ++++ src/dissector.h | 4 ++-- src/ring.h | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/TODO b/TODO index c35c8020..1fddd6bf 100644 --- a/TODO +++ b/TODO @@ -73,9 +73,6 @@ submit your contributions, items marked with '!' are of high importance): 42) Flowtop: add interesting things from socket diag (e.g. socket states, ...)? -45! fix sll struct / hdr->s_ll.sll_ifindex in TPACKETv2 (provides - wrong information in dissector output) - 46) QoS for curvetun. 47) ifpps show timestamps in CSV file. diff --git a/src/built_in.h b/src/built_in.h index f3b4cbfc..1cfa8b1e 100644 --- a/src/built_in.h +++ b/src/built_in.h @@ -75,6 +75,10 @@ typedef uint8_t u8; # define __aligned_tpacket __attribute__((aligned(TPACKET_ALIGNMENT))) #endif +#ifndef __align_tpacket +# define __align_tpacket(x) __attribute__((aligned(TPACKET_ALIGN(x)))) +#endif + #ifndef __check_format_printf # define __check_format_printf(pos_fmtstr, pos_fmtargs) \ __attribute__ ((format (printf, (pos_fmtstr), (pos_fmtargs)))) diff --git a/src/dissector.h b/src/dissector.h index 9f07c615..df4f11df 100644 --- a/src/dissector.h +++ b/src/dissector.h @@ -57,7 +57,7 @@ static inline void show_frame_hdr(struct frame_map *hdr, int mode, switch (mode) { case FNTTYPE_PRINT_LESS: if (rmode == RING_MODE_INGRESS) { - tprintf("%s %u %u", + tprintf("%s %d %u", packet_types[hdr->s_ll.sll_pkttype], hdr->s_ll.sll_ifindex, hdr->tp_h.tp_len); } else { @@ -70,7 +70,7 @@ static inline void show_frame_hdr(struct frame_map *hdr, int mode, case FNTTYPE_PRINT_HEX_ASCII: default: if (rmode == RING_MODE_INGRESS) { - tprintf("%s %u %u %us.%uns\n", + tprintf("%s %d %u %us.%uns\n", packet_types[hdr->s_ll.sll_pkttype], hdr->s_ll.sll_ifindex, hdr->tp_h.tp_len, hdr->tp_h.tp_sec, hdr->tp_h.tp_nsec); diff --git a/src/ring.h b/src/ring.h index a66c684a..17ef8cfd 100644 --- a/src/ring.h +++ b/src/ring.h @@ -37,7 +37,7 @@ struct frame_map { struct tpacket2_hdr tp_h __aligned_tpacket; - struct sockaddr_ll s_ll; + struct sockaddr_ll s_ll __align_tpacket(sizeof(struct tpacket2_hdr)); }; struct ring { -- 2.11.4.GIT