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: Mon, 16 Aug 2010 18:00:19 -0400 [thread overview]
Message-ID: <1281996019.5765.6.camel@bigi> (raw)
In-Reply-To: <20100816211542.GA21083@n7mm.org>
On Mon, 2010-08-16 at 23:15 +0200, Grégoire Baron wrote:
> net/sched: add ACT_CSUM action to update packets checksums
>
> ACT_CSUM can be called just after ACT_PEDIT in order to re-compute some
> altered checksums in IPv4 and IPv6 packets. The following checksums are
> supported by this patch:
> - IPv4: IPv4 header, ICMP, IGMP, TCP, UDP & UDPLite
> - IPv6: ICMPv6, TCP, UDP & UDPLite
> It's possible to request in the same action to update different kind of
> checksums, if the packets flow mix TCP, UDP and UDPLite, ...
>
> An example of usage is done in the associated iproute2 patch.
>
> Signed-off-by: Gregoire Baron <baronchon@n7mm.org>
Excellent work! Ive always wanted to do this albeit slightly
differently.
I think it would be nice to factor a lot of the code repeated
everywhere into some boilerplate function that gets invoked by all;
users. Example, code such as:
+ 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;
+
+ icmph = (void *)(skb_network_header(skb) + ihl);
+
+ icmph->checksum = 0;
cheers,
jamal
next prev parent reply other threads:[~2010-08-16 22:00 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 [this message]
2010-08-16 23:02 ` Grégoire Baron
2010-08-17 12:36 ` jamal
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=1281996019.5765.6.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 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).