netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] openvswitch: update checksum in {push,pop}_mpls
@ 2016-05-30  5:04 Simon Horman
  2016-05-31 19:28 ` pravin shelar
  2016-05-31 20:52 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Simon Horman @ 2016-05-30  5:04 UTC (permalink / raw)
  To: pravin shelar; +Cc: netdev, Simon Horman, Pravin Shelar

In the case of CHECKSUM_COMPLETE the skb checksum should be updated in
{push,pop}_mpls() as they the type in the ethernet header.

As suggested by Pravin Shelar.

Cc: Pravin Shelar <pshelar@nicira.com>
Fixes: 25cd9ba0abc0 ("openvswitch: Add basic MPLS support to kernel")
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
v2
* Use helper to reduce duplicated code.
---
 net/openvswitch/actions.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 879185fe183f..9a3eb7a0ebf4 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -137,11 +137,23 @@ static bool is_flow_key_valid(const struct sw_flow_key *key)
 	return !!key->eth.type;
 }
 
+static void update_ethertype(struct sk_buff *skb, struct ethhdr *hdr,
+			     __be16 ethertype)
+{
+	if (skb->ip_summed == CHECKSUM_COMPLETE) {
+		__be16 diff[] = { ~(hdr->h_proto), ethertype };
+
+		skb->csum = ~csum_partial((char *)diff, sizeof(diff),
+					~skb->csum);
+	}
+
+	hdr->h_proto = ethertype;
+}
+
 static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
 		     const struct ovs_action_push_mpls *mpls)
 {
 	__be32 *new_mpls_lse;
-	struct ethhdr *hdr;
 
 	/* Networking stack do not allow simultaneous Tunnel and MPLS GSO. */
 	if (skb->encapsulation)
@@ -160,9 +172,7 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
 
 	skb_postpush_rcsum(skb, new_mpls_lse, MPLS_HLEN);
 
-	hdr = eth_hdr(skb);
-	hdr->h_proto = mpls->mpls_ethertype;
-
+	update_ethertype(skb, eth_hdr(skb), mpls->mpls_ethertype);
 	if (!skb->inner_protocol)
 		skb_set_inner_protocol(skb, skb->protocol);
 	skb->protocol = mpls->mpls_ethertype;
@@ -193,7 +203,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
 	 * field correctly in the presence of VLAN tags.
 	 */
 	hdr = (struct ethhdr *)(skb_mpls_header(skb) - ETH_HLEN);
-	hdr->h_proto = ethertype;
+	update_ethertype(skb, hdr, ethertype);
 	if (eth_p_mpls(skb->protocol))
 		skb->protocol = ethertype;
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] openvswitch: update checksum in {push,pop}_mpls
  2016-05-30  5:04 [PATCH net v2] openvswitch: update checksum in {push,pop}_mpls Simon Horman
@ 2016-05-31 19:28 ` pravin shelar
  2016-05-31 20:52 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: pravin shelar @ 2016-05-31 19:28 UTC (permalink / raw)
  To: Simon Horman; +Cc: Linux Kernel Network Developers, Pravin Shelar

On Sun, May 29, 2016 at 10:04 PM, Simon Horman
<simon.horman@netronome.com> wrote:
> In the case of CHECKSUM_COMPLETE the skb checksum should be updated in
> {push,pop}_mpls() as they the type in the ethernet header.
>
> As suggested by Pravin Shelar.
>
> Cc: Pravin Shelar <pshelar@nicira.com>
> Fixes: 25cd9ba0abc0 ("openvswitch: Add basic MPLS support to kernel")
> Signed-off-by: Simon Horman <simon.horman@netronome.com>

Looks good to me.

Acked-by: Pravin B Shelar <pshelar@ovn.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] openvswitch: update checksum in {push,pop}_mpls
  2016-05-30  5:04 [PATCH net v2] openvswitch: update checksum in {push,pop}_mpls Simon Horman
  2016-05-31 19:28 ` pravin shelar
@ 2016-05-31 20:52 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-05-31 20:52 UTC (permalink / raw)
  To: simon.horman; +Cc: pshelar, netdev, pshelar

From: Simon Horman <simon.horman@netronome.com>
Date: Mon, 30 May 2016 14:04:25 +0900

> In the case of CHECKSUM_COMPLETE the skb checksum should be updated in
> {push,pop}_mpls() as they the type in the ethernet header.
> 
> As suggested by Pravin Shelar.
> 
> Cc: Pravin Shelar <pshelar@nicira.com>
> Fixes: 25cd9ba0abc0 ("openvswitch: Add basic MPLS support to kernel")
> Signed-off-by: Simon Horman <simon.horman@netronome.com>
> ---
> v2
> * Use helper to reduce duplicated code.

Applied, thanks Simon.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-05-31 20:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-30  5:04 [PATCH net v2] openvswitch: update checksum in {push,pop}_mpls Simon Horman
2016-05-31 19:28 ` pravin shelar
2016-05-31 20:52 ` David Miller

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).