Skip to contentSkip to conversation

ipv6: Initialize the neighbour pointer of rt6_info on allocation

PATCH Applied Steffen Klassert 3 participants 5 messages Jul 5, 2012 – Jul 6, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipv6: Initialize the neighbour pointer of rt6_info on allocation

git commit 97cac082 (ipv6: Store route neighbour in rt6_info struct) added a neighbour pointer to rt6_info. Currently we don't initialize this pointer at allocation time. We assume this pointer to be valid if it is not a null pointer, so initialize it on allocation.

---
 net/ipv6/route.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv6/route.c +1 -1
index ceff71d..6cc6c88 100644
@@ -273,7 +273,7 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net,
 					0, 0, flags);
 
 	if (rt) {
-		memset(&rt->rt6i_table, 0,
+		memset(&rt->n, 0,
 		       sizeof(*rt) - sizeof(struct dst_entry));
 		rt6_init_peer(rt, table ? &table->tb6_peers : net->ipv6.peers);
 	}
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 15 lines · Steffen Klassert

git commit 97cac082 (ipv6: Store route neighbour in rt6_info struct) added a neighbour pointer to rt6_info. Currently we don't initialize this pointer at allocation time. We assume this pointer to be valid if it is not a null pointer, so initialize it on allocation.

---
 net/ipv6/route.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/ipv6/route.c +0 -0
index ceff71d..6cc6c88 100644

net/ipv6/route.c static inline struct rt6_info *ip6_dst_alloc(struct net *net, · line 279

Quoted 8 lines
net/ipv6/route.c +1 -1
@@ -273,7 +273,7 @@ static inline struct rt6_info *ip6_dst_alloc(struct net *net,
 					0, 0, flags);
 
 	if (rt) {
-		memset(&rt->rt6i_table, 0,
+		memset(&rt->n, 0,
 		       sizeof(*rt) - sizeof(struct dst_entry));
 		rt6_init_peer(rt, table ? &table->tb6_peers : net->ipv6.peers);
 	}

Hmm, could we find a way to avoid this for future changes ?

We know dst_entry is the first field, so maybe :

if (rt) {
	struct dst_entry *dst = (struct dst_entry *)rt;

	memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));
maintainer Applied
#4 lore raw
In reply to Steffen Klassert

From: Steffen Klassert <[email protected]>
Date: Thu, 5 Jul 2012 15:18:28 +0200

Quoted 6 lines

git commit 97cac082 (ipv6: Store route neighbour in rt6_info struct) added a neighbour pointer to rt6_info. Currently we don't initialize this pointer at allocation time. We assume this pointer to be valid if it is not a null pointer, so initialize it on allocation.

Applied, but as Eric said we need to find a way to avoid having to make changes like this every time we simply want to add a struct member to rt6_info.

#2 lore raw
In reply to Eric Dumazet
Quoted 11 lines · Eric Dumazet

net/ipv6/route.c static inline struct rt6_info *ip6_dst_alloc(struct net *net, · line 279

Quoted 7 lines · Steffen Klassert
net/ipv6/route.c +1 -1
 	if (rt) {
-		memset(&rt->rt6i_table, 0,
+		memset(&rt->n, 0,
 		       sizeof(*rt) - sizeof(struct dst_entry));
 		rt6_init_peer(rt, table ? &table->tb6_peers : net->ipv6.peers);
 	}

Hmm, could we find a way to avoid this for future changes ?

Quoted 7 lines

We know dst_entry is the first field, so maybe :

if (rt) {
	struct dst_entry *dst = (struct dst_entry *)rt;

	memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));

Yes, I think we need to do something like this.

I've just noticed that ip6_blackhole_route, xfrm_alloc_dst, dn_route_output_slow and dn_route_input_slow have the same issue.

#3 lore raw
Quoted 9 lines · Steffen Klassert
Quoted 8 lines · Eric Dumazet

Hmm, could we find a way to avoid this for future changes ?

We know dst_entry is the first field, so maybe :

if (rt) {
	struct dst_entry *dst = (struct dst_entry *)rt;
Quoted 7 lines
Quoted 2 lines
	memset(dst + 1, 0, sizeof(*rt) - sizeof(*dst));

Yes, I think we need to do something like this.

I've just noticed that ip6_blackhole_route, xfrm_alloc_dst, dn_route_output_slow and dn_route_input_slow have the same issue.

Actually, decnet is ok. So I'll send patches with the change you suggested for ipv6 and xfrm.