From: Stephen Hemminger <shemminger@osdl.org>
To: Ingo Oeser <netdev@axxeo.de>, "David S. Miller" <davem@davemloft.net>
Cc: Ingo Oeser <ioe-lkml@rameria.de>, netdev@vger.kernel.org
Subject: [PATCH] expose simplified skb_checksum_recalc
Date: Thu, 11 May 2006 11:28:43 -0700 [thread overview]
Message-ID: <20060511112843.6532bddd@localhost.localdomain> (raw)
In-Reply-To: <200605111924.33125.netdev@axxeo.de>
Many users of skb_checksum_help() are just using it to recalculate
outbound checksum, so why not expose the interface in a more useful
way. Suggested by Ingo Oeser.
Signed-off-by: Stephen Hemminger <shemminger@osdl.org>
--- linux-2.6.orig/include/linux/skbuff.h 2006-04-27 11:12:53.000000000 -0700
+++ linux-2.6/include/linux/skbuff.h 2006-05-11 11:17:39.000000000 -0700
@@ -1343,6 +1343,24 @@
__skb_checksum_complete(skb);
}
+extern int skb_checksum_recalc(struct sk_buff *skb);
+/**
+ * skb_checksum_help - recalculate checksum of packet
+ * @skb: packet to process
+ * @inward: direction of flow, zero is receiving
+ *
+ * Invalidate hardware checksum when packet is to be mangled on
+ * receive and complete checksum manually on outgoing path.
+ */
+static inline int skb_checksum_help(struct sk_buff *skb, int inward)
+{
+ if (inward) {
+ skb->ip_summed = CHECKSUM_NONE;
+ return 0;
+ }
+ return skb_checksum_recalc(skb);
+}
+
#ifdef CONFIG_NETFILTER
static inline void nf_conntrack_put(struct nf_conntrack *nfct)
{
--- sky2.orig/net/core/dev.c 2006-05-10 10:17:51.000000000 -0700
+++ sky2/net/core/dev.c 2006-05-11 11:22:27.000000000 -0700
@@ -1144,39 +1144,6 @@
EXPORT_SYMBOL(netif_device_attach);
-/*
- * Invalidate hardware checksum when packet is to be mangled, and
- * complete checksum manually on outgoing path.
- */
-int skb_checksum_help(struct sk_buff *skb, int inward)
-{
- unsigned int csum;
- int ret = 0, offset = skb->h.raw - skb->data;
-
- if (inward) {
- skb->ip_summed = CHECKSUM_NONE;
- goto out;
- }
-
- if (skb_cloned(skb)) {
- ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
- if (ret)
- goto out;
- }
-
- BUG_ON(offset > (int)skb->len);
- csum = skb_checksum(skb, offset, skb->len-offset, 0);
-
- offset = skb->tail - skb->h.raw;
- BUG_ON(offset <= 0);
- BUG_ON(skb->csum + 2 > offset);
-
- *(u16*)(skb->h.raw + skb->csum) = csum_fold(csum);
- skb->ip_summed = CHECKSUM_NONE;
-out:
- return ret;
-}
-
/* Take action when hardware reception checksum errors are detected. */
#ifdef CONFIG_BUG
void netdev_rx_csum_fault(struct net_device *dev)
@@ -3403,7 +3370,6 @@
EXPORT_SYMBOL(register_gifconf);
EXPORT_SYMBOL(register_netdevice);
EXPORT_SYMBOL(register_netdevice_notifier);
-EXPORT_SYMBOL(skb_checksum_help);
EXPORT_SYMBOL(synchronize_net);
EXPORT_SYMBOL(unregister_netdevice);
EXPORT_SYMBOL(unregister_netdevice_notifier);
--- sky2.orig/net/core/skbuff.c 2006-04-27 11:12:54.000000000 -0700
+++ sky2/net/core/skbuff.c 2006-05-11 11:23:13.000000000 -0700
@@ -1334,6 +1334,36 @@
}
/**
+ * skb_checksum_recalc - force software checksum
+ * @skb: skb to process
+ * Force complete checksum, this is used to force a software checksum
+ * on the outgoing path.
+ */
+int skb_checksum_recalc(struct sk_buff *skb)
+{
+ unsigned int csum;
+ int ret = 0, offset = skb->h.raw - skb->data;
+
+ if (skb_cloned(skb)) {
+ ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
+ if (ret)
+ goto out;
+ }
+
+ BUG_ON(offset > (int)skb->len);
+ csum = skb_checksum(skb, offset, skb->len-offset, 0);
+
+ offset = skb->tail - skb->h.raw;
+ BUG_ON(offset <= 0);
+ BUG_ON(skb->csum + 2 > offset);
+
+ *(u16*)(skb->h.raw + skb->csum) = csum_fold(csum);
+ skb->ip_summed = CHECKSUM_NONE;
+out:
+ return ret;
+}
+
+/**
* skb_dequeue - remove from the head of the queue
* @list: list to dequeue from
*
@@ -1854,6 +1884,7 @@
EXPORT_SYMBOL(pskb_copy);
EXPORT_SYMBOL(pskb_expand_head);
EXPORT_SYMBOL(skb_checksum);
+EXPORT_SYMBOL(skb_checksum_recalc);
EXPORT_SYMBOL(skb_clone);
EXPORT_SYMBOL(skb_clone_fraglist);
EXPORT_SYMBOL(skb_copy);
next prev parent reply other threads:[~2006-05-11 18:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-10 21:22 [PATCH 0/6] myri10ge - Myri-10G Ethernet driver Brice Goglin
2006-05-10 21:34 ` [PATCH 1/6] myri10ge - Revive pci_find_ext_capability Brice Goglin
2006-05-10 21:35 ` [PATCH 2/6] myri10ge - Add missing PCI IDs Brice Goglin
2006-05-10 21:52 ` Andi Kleen
2006-05-10 21:36 ` [PATCH 3/6] myri10ge - Driver header files Brice Goglin
2006-05-10 21:57 ` Roland Dreier
2006-05-10 22:00 ` Stephen Hemminger
2006-05-10 22:02 ` Francois Romieu
2006-05-10 21:40 ` [PATCH 4/6] myri10ge - First half of the driver Brice Goglin
2006-05-10 22:01 ` Stephen Hemminger
2006-05-10 22:06 ` Roland Dreier
2006-05-10 22:04 ` Roland Dreier
2006-05-11 23:53 ` Brice Goglin
2006-05-10 23:13 ` Francois Romieu
2006-05-11 23:53 ` Brice Goglin
2006-05-12 6:47 ` Evgeniy Polyakov
2006-05-12 17:40 ` David S. Miller
2006-05-13 16:13 ` Francois Romieu
2006-05-15 17:02 ` Lee Revell
2006-05-15 17:39 ` Brice Goglin
2006-05-10 21:42 ` [PATCH 5/6] myri10ge - Second " Brice Goglin
2006-05-10 22:22 ` Stephen Hemminger
[not found] ` <200605111924.33125.netdev@axxeo.de>
2006-05-11 18:28 ` Stephen Hemminger [this message]
2006-05-11 18:40 ` [PATCH] expose simplified skb_checksum_recalc Ingo Oeser
2006-05-12 19:52 ` David S. Miller
2006-05-11 23:53 ` [PATCH 5/6] myri10ge - Second half of the driver Brice Goglin
2006-05-12 0:31 ` Herbert Xu
2006-05-10 21:43 ` [PATCH 6/6] myri10ge - Kconfig and Makefile Brice Goglin
2006-05-13 18:51 ` Adrian Bunk
2006-05-13 18:56 ` Brice Goglin
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=20060511112843.6532bddd@localhost.localdomain \
--to=shemminger@osdl.org \
--cc=davem@davemloft.net \
--cc=ioe-lkml@rameria.de \
--cc=netdev@axxeo.de \
--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).