diff options
| author | Atzm Watanabe <atzm@stratosphere.co.jp> | 2013-12-17 08:53:36 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-12-18 00:36:16 -0500 |
| commit | e4d26f4b080f55e9577b45e6b51a04971eb459e9 (patch) | |
| tree | e7caf4bc1439ce04ac392d94dd71c13aaf90f0e4 | |
| parent | 51846355bc239b7d229ed7a1ea7b0333cbd23f01 (diff) | |
packet: fill the gap of TPACKET_ALIGNMENT with zeros
struct tpacket{2,3}_hdr is aligned to a multiple of TPACKET_ALIGNMENT.
Explicitly defining and zeroing the gap of this makes additional changes
easier.
Signed-off-by: Atzm Watanabe <atzm@stratosphere.co.jp>
Acked-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | include/uapi/linux/if_packet.h | 3 | ||||
| -rw-r--r-- | net/packet/af_packet.c | 3 |
2 files changed, 4 insertions, 2 deletions
diff --git a/include/uapi/linux/if_packet.h b/include/uapi/linux/if_packet.h index 1e24aa701cbd..9185dc9a4485 100644 --- a/include/uapi/linux/if_packet.h +++ b/include/uapi/linux/if_packet.h | |||
| @@ -133,7 +133,7 @@ struct tpacket2_hdr { | |||
| 133 | __u32 tp_sec; | 133 | __u32 tp_sec; |
| 134 | __u32 tp_nsec; | 134 | __u32 tp_nsec; |
| 135 | __u16 tp_vlan_tci; | 135 | __u16 tp_vlan_tci; |
| 136 | __u16 tp_padding; | 136 | __u8 tp_padding[6]; |
| 137 | }; | 137 | }; |
| 138 | 138 | ||
| 139 | struct tpacket_hdr_variant1 { | 139 | struct tpacket_hdr_variant1 { |
| @@ -154,6 +154,7 @@ struct tpacket3_hdr { | |||
| 154 | union { | 154 | union { |
| 155 | struct tpacket_hdr_variant1 hv1; | 155 | struct tpacket_hdr_variant1 hv1; |
| 156 | }; | 156 | }; |
| 157 | __u8 tp_padding[12]; | ||
| 157 | }; | 158 | }; |
| 158 | 159 | ||
| 159 | struct tpacket_bd_ts { | 160 | struct tpacket_bd_ts { |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 4fd52181b6ce..f281999ba92e 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
| @@ -1929,7 +1929,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 1929 | } else { | 1929 | } else { |
| 1930 | h.h2->tp_vlan_tci = 0; | 1930 | h.h2->tp_vlan_tci = 0; |
| 1931 | } | 1931 | } |
| 1932 | h.h2->tp_padding = 0; | 1932 | memset(h.h2->tp_padding, 0, sizeof(h.h2->tp_padding)); |
| 1933 | hdrlen = sizeof(*h.h2); | 1933 | hdrlen = sizeof(*h.h2); |
| 1934 | break; | 1934 | break; |
| 1935 | case TPACKET_V3: | 1935 | case TPACKET_V3: |
| @@ -1943,6 +1943,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 1943 | h.h3->tp_net = netoff; | 1943 | h.h3->tp_net = netoff; |
| 1944 | h.h3->tp_sec = ts.tv_sec; | 1944 | h.h3->tp_sec = ts.tv_sec; |
| 1945 | h.h3->tp_nsec = ts.tv_nsec; | 1945 | h.h3->tp_nsec = ts.tv_nsec; |
| 1946 | memset(h.h3->tp_padding, 0, sizeof(h.h3->tp_padding)); | ||
| 1946 | hdrlen = sizeof(*h.h3); | 1947 | hdrlen = sizeof(*h.h3); |
| 1947 | break; | 1948 | break; |
| 1948 | default: | 1949 | default: |
