xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <paul.durrant@citrix.com>
To: xen-devel@lists.xen.org
Cc: Paul Durrant <paul.durrant@citrix.com>
Subject: [RFC PATCH net-next 3/3] xen-netfront: use new core skb_checksum_setup function
Date: Tue, 10 Dec 2013 15:39:52 +0000	[thread overview]
Message-ID: <1386689992-45593-4-git-send-email-paul.durrant@citrix.com> (raw)
In-Reply-To: <1386689992-45593-1-git-send-email-paul.durrant@citrix.com>

This patch removes the private implementation of partial checksum setup
in favour of the core implementation.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
 drivers/net/xen-netfront.c |   44 +-------------------------------------------
 1 file changed, 1 insertion(+), 43 deletions(-)

diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index e59acb1..70f9808 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -859,8 +859,6 @@ static RING_IDX xennet_fill_frags(struct netfront_info *np,
 
 static int checksum_setup(struct net_device *dev, struct sk_buff *skb)
 {
-	struct iphdr *iph;
-	int err = -EPROTO;
 	int recalculate_partial_csum = 0;
 
 	/*
@@ -880,47 +878,7 @@ static int checksum_setup(struct net_device *dev, struct sk_buff *skb)
 	if (skb->ip_summed != CHECKSUM_PARTIAL)
 		return 0;
 
-	if (skb->protocol != htons(ETH_P_IP))
-		goto out;
-
-	iph = (void *)skb->data;
-
-	switch (iph->protocol) {
-	case IPPROTO_TCP:
-		if (!skb_partial_csum_set(skb, 4 * iph->ihl,
-					  offsetof(struct tcphdr, check)))
-			goto out;
-
-		if (recalculate_partial_csum) {
-			struct tcphdr *tcph = tcp_hdr(skb);
-			tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
-							 skb->len - iph->ihl*4,
-							 IPPROTO_TCP, 0);
-		}
-		break;
-	case IPPROTO_UDP:
-		if (!skb_partial_csum_set(skb, 4 * iph->ihl,
-					  offsetof(struct udphdr, check)))
-			goto out;
-
-		if (recalculate_partial_csum) {
-			struct udphdr *udph = udp_hdr(skb);
-			udph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr,
-							 skb->len - iph->ihl*4,
-							 IPPROTO_UDP, 0);
-		}
-		break;
-	default:
-		if (net_ratelimit())
-			pr_err("Attempting to checksum a non-TCP/UDP packet, dropping a protocol %d packet\n",
-			       iph->protocol);
-		goto out;
-	}
-
-	err = 0;
-
-out:
-	return err;
+	return skb_checksum_setup(skb, recalculate_partial_csum);
 }
 
 static int handle_incoming_queue(struct net_device *dev,
-- 
1.7.10.4

  parent reply	other threads:[~2013-12-10 15:39 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-10 15:39 [RFC PATCH net-next 0/3] unify netfront and netback checksum setup code Paul Durrant
2013-12-10 15:39 ` [RFC PATCH net-next 1/3] net: add skb checksum setup functions for TCP and UDP Paul Durrant
2013-12-12 12:48   ` Ian Campbell
2013-12-10 15:39 ` [RFC PATCH net-next 2/3] xen-netback: use new core skb_checksum_setup function Paul Durrant
2013-12-12 12:49   ` Ian Campbell
2013-12-10 15:39 ` Paul Durrant [this message]
2013-12-10 18:09 ` [RFC PATCH net-next 0/3] unify netfront and netback checksum setup code Wei Liu
2013-12-11 10:32   ` Paul Durrant
2013-12-12 12:50     ` Ian Campbell

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=1386689992-45593-4-git-send-email-paul.durrant@citrix.com \
    --to=paul.durrant@citrix.com \
    --cc=xen-devel@lists.xen.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).