Skip to contentSkip to conversation

Evict tmp variable from the stack in ip6_evictor

PATCH In review Pavel Emelyanov 3 participants 5 messages Oct 10, 2007

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

PATCH 1/1 Evict tmp variable from the stack in ip6_evictor

The list_head *tmp is used to help getting the first entry in the ip6_frag_lru_list list. There is a simpler way to do it.

---

net/ipv6/reassembly.c +3 -3
index 31601c9..8fad98b 100644
@@ -261,7 +261,6 @@ static __inline__ void fq_kill(struct fr
 static void ip6_evictor(struct inet6_dev *idev)
 {
 	struct frag_queue *fq;
-	struct list_head *tmp;
 	int work;
 
 	work = atomic_read(&ip6_frag_mem) - sysctl_ip6frag_low_thresh;
@@ -274,8 +273,9 @@ static void ip6_evictor(struct inet6_dev
 			read_unlock(&ip6_frag_lock);
 			return;
 		}
-		tmp = ip6_frag_lru_list.next;
-		fq = list_entry(tmp, struct frag_queue, lru_list);
+
+		fq = list_first_entry(&ip6_frag_lru_list,
+				struct frag_queue, lru_list);
 		atomic_inc(&fq->refcnt);
 		read_unlock(&ip6_frag_lock);
 
#1 lore raw
Quoted 2 lines · Pavel Emelyanov

The list_head *tmp is used to help getting the first entry in the ip6_frag_lru_list list. There is a simpler way to do it

The exact same code exists in ip_fragment.c and nf_conntrack_reasm.c, please also change it there.

#2 lore raw
Quoted 7 lines · Patrick McHardy
Quoted 2 lines · Pavel Emelyanov

The list_head *tmp is used to help getting the first entry in the ip6_frag_lru_list list. There is a simpler way to do it

The exact same code exists in ip_fragment.c and nf_conntrack_reasm.c, please also change it there.

Hm, indeed. But I see that the structs frag_queue in reassembly.c, ipq in ip_fragment.c and nf_ct_frag6_queue in nf code looks VERY similar and very much of code (like link/unlink or evict) looks the same too.

Maybe it's worth creating something like struct skb_fragment and consolidate all the common stuff into some net/core/lib_frag.c? Or is there some hidden reason for keeping this code splitted?

Thanks,
Pavel

#3 lore raw
Quoted 5 lines · Pavel Emelyanov
Quoted 4 lines · Patrick McHardy
Quoted 2 lines · Pavel Emelyanov

The list_head *tmp is used to help getting the first entry in the ip6_frag_lru_list list. There is a simpler way to do it

Quoted 8 lines
Quoted 2 lines

The exact same code exists in ip_fragment.c and nf_conntrack_reasm.c, please also change it there.

Hm, indeed. But I see that the structs frag_queue in reassembly.c, ipq in ip_fragment.c and nf_ct_frag6_queue in nf code looks VERY similar and very much of code (like link/unlink or evict) looks the same too.

Maybe it's worth creating something like struct skb_fragment and consolidate all the common stuff into some net/core/lib_frag.c? Or is there some hidden reason for keeping this code splitted?

I'm not sure if its possible between IPv4 and IPv6, but sharing code between IPv6 reassembly and netfilter/ipv6 would be nice.

maintainer
#4 lore raw

From: Patrick McHardy <[email protected]>
Date: Wed, 10 Oct 2007 17:06:07 +0200

Quoted 13 lines
Quoted 12 lines · Pavel Emelyanov
Quoted 6 lines · Patrick McHardy
Quoted 2 lines · Pavel Emelyanov

The list_head *tmp is used to help getting the first entry in the ip6_frag_lru_list list. There is a simpler way to do it

The exact same code exists in ip_fragment.c and nf_conntrack_reasm.c, please also change it there.

Hm, indeed. But I see that the structs frag_queue in reassembly.c, ipq in ip_fragment.c and nf_ct_frag6_queue in nf code looks VERY similar and very much of code (like link/unlink or evict) looks the same too.

Quoted 6 lines
Quoted 3 lines

Maybe it's worth creating something like struct skb_fragment and consolidate all the common stuff into some net/core/lib_frag.c? Or is there some hidden reason for keeping this code splitted?

I'm not sure if its possible between IPv4 and IPv6, but sharing code between IPv6 reassembly and netfilter/ipv6 would be nice.

And besides I think it's an independant change to this tmp variable removal, so let's just do that first.