netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info behind the dst_enty field
@ 2012-07-06  9:37 Steffen Klassert
  2012-07-06  9:39 ` [PATCH net-next 2/2] xfrm: Initialize the struct xfrm_dst " Steffen Klassert
  2012-07-06 10:57 ` [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info " David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Steffen Klassert @ 2012-07-06  9:37 UTC (permalink / raw)
  To: David Miller, Eric Dumazet; +Cc: netdev

We start initializing the struct rt6_info at the first field
behind the struct dst_enty. This is error prone because it
might leave a new field uninitialized. So start initializing
the struct rt6_info right behind the dst_entry.

Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv6/route.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6cc6c88..1d8459b 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -273,8 +273,9 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net,
 					0, 0, flags);
 
 	if (rt) {
-		memset(&rt->n, 0,
-		       sizeof(*rt) - sizeof(struct dst_entry));
+		struct dst_entry *dst = (struct dst_entry *)rt;
+
+		memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
 		rt6_init_peer(rt, table ? &table->tb6_peers : net->ipv6.peers);
 	}
 	return rt;
@@ -975,10 +976,10 @@ struct dst_entry *ip6_blackhole_route(struct net *net, struct dst_entry *dst_ori
 
 	rt = dst_alloc(&ip6_dst_blackhole_ops, ort->dst.dev, 1, 0, 0);
 	if (rt) {
-		memset(&rt->rt6i_table, 0, sizeof(*rt) - sizeof(struct dst_entry));
-		rt6_init_peer(rt, net->ipv6.peers);
+		new = (struct dst_entry *)rt;
 
-		new = &rt->dst;
+		memset(new + 1, 0, sizeof(*rt) - sizeof(*new));
+		rt6_init_peer(rt, net->ipv6.peers);
 
 		new->__use = 1;
 		new->input = dst_discard;
-- 
1.7.0.4

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

end of thread, other threads:[~2012-07-06 10:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-06  9:37 [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info behind the dst_enty field Steffen Klassert
2012-07-06  9:39 ` [PATCH net-next 2/2] xfrm: Initialize the struct xfrm_dst " Steffen Klassert
2012-07-06 10:57 ` [PATCH net-next 1/2] ipv6: Initialize the struct rt6_info " David Miller

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).