All of lore.kernel.org
 help / color / mirror / Atom feed
From: jamal <hadi@cyberus.ca>
To: "Grégoire Baron" <baronchon@n7mm.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] net/sched: add ACT_CSUM action to update packets checksums
Date: Tue, 17 Aug 2010 08:36:42 -0400	[thread overview]
Message-ID: <1282048602.5765.752.camel@bigi> (raw)
In-Reply-To: <20100816230217.GA24125@n7mm.org>

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


  reply	other threads:[~2010-08-17 12:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-16 21:15 [PATCH] net/sched: add ACT_CSUM action to update packets checksums Grégoire Baron
2010-08-16 22:00 ` jamal
2010-08-16 23:02   ` Grégoire Baron
2010-08-17 12:36     ` jamal [this message]
2010-08-18  0:04       ` Grégoire Baron
2010-08-18 10:42         ` jamal
2010-08-17  5:19 ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1282048602.5765.752.camel@bigi \
    --to=hadi@cyberus.ca \
    --cc=baronchon@n7mm.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.