Subject: Re: [PATCH] net/sched: add ACT_CSUM action to update packets checksums

From: jamal <[email-masked]>
Date: Tue, 17 Aug 2010 08:36:42 -0400

On Tue, 2010-08-17 at 01:02 +0200, Grégoire Baron wrote:

> You're rigth. I will correct that, maybe using a macro which is
> specialised to get the protocol structure ...
> However, this macro could call a 'goto' instruction. Is it really a good
> idea? Tell me. Are you sure a function is appropriate?

Do you even need the goto fail? It seems you could short-circuit and
return 0 (at least thats what the goto seems to do)

But i really dont want to complicate this; 
In the minimal i think you can make code like this

====
       struct icmphdr *icmph;
+       int hl;
+       int ntkoff;
+
+       ntkoff = skb_network_offset(skb);
+
+       hl = ihl + sizeof(*icmph);
+
+       if (!pskb_may_pull(skb, ipl + ntkoff) || (ipl < hl) ||
+           (skb_cloned(skb) &&
+            !skb_clone_writable(skb, hl + ntkoff) &&
+            pskb_expand_head(skb, 0, 0, GFP_ATOMIC)))
+               goto fail;
===

reusable - return 0 if fail else return 1 etc etc

BTW, another comment: icmp and igmp have unused parameter iph
passed to them - probably cut and paste.

cheers,
jamal