netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: af_packet: Don't initialize vnet_hdr
@ 2011-05-12 20:36 Joe Perches
  2011-05-12 21:26 ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Joe Perches @ 2011-05-12 20:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: David S. Miller, netdev

Save a memset, initialize only the portion necessary.

packet_snd either gets this structure completely from
memcpy_fromiovec or uses only the hdr_len set to 0,
so don't always initialize the structure to 0.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/packet/af_packet.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 549527b..ac88df9 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -1123,7 +1123,7 @@ static int packet_snd(struct socket *sock,
 	__be16 proto;
 	unsigned char *addr;
 	int ifindex, err, reserve = 0;
-	struct virtio_net_hdr vnet_hdr = { 0 };
+	struct virtio_net_hdr vnet_hdr;
 	int offset = 0;
 	int vnet_hdr_len;
 	struct packet_sock *po = pkt_sk(sk);
@@ -1206,7 +1206,9 @@ static int packet_snd(struct socket *sock,
 				goto out_unlock;
 
 		}
-	}
+	} else
+		vnet_hdr.hdr_len = 0;
+
 
 	err = -EMSGSIZE;
 	if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN))
-- 
1.7.5.rc3.dirty

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-05-13  5:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-12 20:36 [PATCH] net: af_packet: Don't initialize vnet_hdr Joe Perches
2011-05-12 21:26 ` David Miller
2011-05-12 21:33   ` Joe Perches
2011-05-12 21:36     ` David Miller
2011-05-12 21:55       ` Joe Perches
2011-05-12 21:59         ` David Miller
2011-05-12 23:25           ` [PATCH net-next V3] net: af_packet: Untangle packet_snd by adding vpacket_snd Joe Perches
2011-05-13  5:11             ` Eric Dumazet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).