linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	kernel-team@lists.ubuntu.com
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	"David S . Miller" <davem@davemloft.net>,
	Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 4.2.y-ckt 37/53] net: use skb_postpush_rcsum instead of own implementations
Date: Tue, 24 May 2016 10:55:07 -0700	[thread overview]
Message-ID: <1464112523-3701-38-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1464112523-3701-1-git-send-email-kamal@canonical.com>

4.2.8-ckt11 -stable review patch.  If anyone has any objections, please let me know.

---8<------------------------------------------------------------

From: Daniel Borkmann <daniel@iogearbox.net>

[ Upstream commit 6b83d28a55a891a9d70fc61ccb1c138e47dcbe74,
  skb_postpush_rcsum() added from commit
  f8ffad69c9f8b8dfb0b633425d4ef4d2493ba61a ]

Replace individual implementations with the recently introduced
skb_postpush_rcsum() helper.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Tom Herbert <tom@herbertland.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
 include/linux/skbuff.h         | 17 +++++++++++++++++
 net/core/skbuff.c              |  4 +---
 net/ipv6/reassembly.c          |  6 ++----
 net/openvswitch/actions.c      |  6 ++----
 net/openvswitch/vport-netdev.c |  2 +-
 net/openvswitch/vport.h        |  7 -------
 6 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 365a771..30616d5 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2633,6 +2633,23 @@ static inline void skb_postpull_rcsum(struct sk_buff *skb,
 
 unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);
 
+static inline void skb_postpush_rcsum(struct sk_buff *skb,
+				      const void *start, unsigned int len)
+{
+	/* For performing the reverse operation to skb_postpull_rcsum(),
+	 * we can instead of ...
+	 *
+	 *   skb->csum = csum_add(skb->csum, csum_partial(start, len, 0));
+	 *
+	 * ... just use this equivalent version here to save a few
+	 * instructions. Feeding csum of 0 in csum_partial() and later
+	 * on adding skb->csum is equivalent to feed skb->csum in the
+	 * first place.
+	 */
+	if (skb->ip_summed == CHECKSUM_COMPLETE)
+		skb->csum = csum_partial(start, len, skb->csum);
+}
+
 /**
  *	pskb_trim_rcsum - trim received skb and update checksum
  *	@skb: buffer to trim
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index ae0b23f..c412278 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -4415,9 +4415,7 @@ int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
 		skb->mac_len += VLAN_HLEN;
 		__skb_pull(skb, offset);
 
-		if (skb->ip_summed == CHECKSUM_COMPLETE)
-			skb->csum = csum_add(skb->csum, csum_partial(skb->data
-					+ (2 * ETH_ALEN), VLAN_HLEN, 0));
+		skb_postpush_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
 	}
 	__vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
 	return 0;
diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
index 45f5ae5..a234552 100644
--- a/net/ipv6/reassembly.c
+++ b/net/ipv6/reassembly.c
@@ -496,10 +496,8 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff *prev,
 	IP6CB(head)->flags |= IP6SKB_FRAGMENTED;
 
 	/* Yes, and fold redundant checksum back. 8) */
-	if (head->ip_summed == CHECKSUM_COMPLETE)
-		head->csum = csum_partial(skb_network_header(head),
-					  skb_network_header_len(head),
-					  head->csum);
+	skb_postpush_rcsum(head, skb_network_header(head),
+			   skb_network_header_len(head));
 
 	rcu_read_lock();
 	IP6_INC_STATS_BH(net, __in6_dev_get(dev), IPSTATS_MIB_REASMOKS);
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index c97ddc8..791c261 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -140,9 +140,7 @@ static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
 	new_mpls_lse = (__be32 *)skb_mpls_header(skb);
 	*new_mpls_lse = mpls->mpls_lse;
 
-	if (skb->ip_summed == CHECKSUM_COMPLETE)
-		skb->csum = csum_add(skb->csum, csum_partial(new_mpls_lse,
-							     MPLS_HLEN, 0));
+	skb_postpush_rcsum(skb, new_mpls_lse, MPLS_HLEN);
 
 	hdr = eth_hdr(skb);
 	hdr->h_proto = mpls->mpls_ethertype;
@@ -266,7 +264,7 @@ static int set_eth_addr(struct sk_buff *skb, struct sw_flow_key *flow_key,
 	ether_addr_copy_masked(eth_hdr(skb)->h_dest, key->eth_dst,
 			       mask->eth_dst);
 
-	ovs_skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
+	skb_postpush_rcsum(skb, eth_hdr(skb), ETH_ALEN * 2);
 
 	ether_addr_copy(flow_key->eth.src, eth_hdr(skb)->h_source);
 	ether_addr_copy(flow_key->eth.dst, eth_hdr(skb)->h_dest);
diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c
index 33e6d6e..eece71d 100644
--- a/net/openvswitch/vport-netdev.c
+++ b/net/openvswitch/vport-netdev.c
@@ -52,7 +52,7 @@ static void netdev_port_receive(struct vport *vport, struct sk_buff *skb)
 		return;
 
 	skb_push(skb, ETH_HLEN);
-	ovs_skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
+	skb_postpush_rcsum(skb, skb->data, ETH_HLEN);
 
 	ovs_vport_receive(vport, skb, NULL);
 	return;
diff --git a/net/openvswitch/vport.h b/net/openvswitch/vport.h
index bc85331..cb4cd12 100644
--- a/net/openvswitch/vport.h
+++ b/net/openvswitch/vport.h
@@ -228,13 +228,6 @@ static inline struct vport *vport_from_priv(void *priv)
 void ovs_vport_receive(struct vport *, struct sk_buff *,
 		       const struct ovs_tunnel_info *);
 
-static inline void ovs_skb_postpush_rcsum(struct sk_buff *skb,
-				      const void *start, unsigned int len)
-{
-	if (skb->ip_summed == CHECKSUM_COMPLETE)
-		skb->csum = csum_add(skb->csum, csum_partial(start, len, 0));
-}
-
 int ovs_vport_ops_register(struct vport_ops *ops);
 void ovs_vport_ops_unregister(struct vport_ops *ops);
 
-- 
2.7.4

  parent reply	other threads:[~2016-05-24 18:02 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24 17:54 [4.2.y-ckt stable] Linux 4.2.8-ckt11 stable review Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 01/53] [4.2-stable only] fix backport "IB/security: restrict use of the write() interface" Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 02/53] Revert "usb: hub: do not clear BOS field during reset device" Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 03/53] regulator: s2mps11: Fix invalid selector mask and voltages for buck9 Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 04/53] regmap: spmi: Fix regmap_spmi_ext_read in multi-byte case Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 05/53] ALSA: usb-audio: Quirk for yet another Phoenix Audio devices (v2) Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 06/53] atomic_open(): fix the handling of create_error Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 07/53] drm/i915/bdw: Add missing delay during L3 SQC credit programming Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 08/53] crypto: hash - Fix page length clamping in hash walk Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 09/53] drm/radeon: fix DP link training issue with second 4K monitor Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 10/53] drm/radeon: fix PLL sharing on DCE6.1 (v2) Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 11/53] get_rock_ridge_filename(): handle malformed NM entries Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 12/53] ALSA: hda - Fix white noise on Asus UX501VW headset Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 13/53] Input: max8997-haptic - fix NULL pointer dereference Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 14/53] drm/i915: Bail out of pipe config compute loop on LPT Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 15/53] ALSA: hda - Fix broken reconfig Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 16/53] ALSA: hda - Fix subwoofer pin on ASUS N751 and N551 Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 17/53] vfs: add vfs_select_inode() helper Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 18/53] vfs: rename: check backing inode being equal Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 19/53] ALSA: usb-audio: Yet another Phoneix Audio device quirk Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 20/53] perf/x86: Fix undefined shift on 32-bit kernels Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 21/53] perf/x86/intel/pt: Generate PMI in the STOP region as well Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 22/53] perf/core: Disable the event on a truncated AUX record Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 23/53] tools lib traceevent: Do not reassign parg after collapse_tree() Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 24/53] workqueue: fix rebind bound workers warning Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 25/53] ocfs2: fix posix_acl_create deadlock Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 26/53] nf_conntrack: avoid kernel pointer value leak in slab name Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 27/53] macvtap: segmented packet is consumed Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 28/53] regulator: axp20x: Fix axp22x ldo_io voltage ranges Kamal Mostafa
2016-05-24 17:54 ` [PATCH 4.2.y-ckt 29/53] arm64: bpf: jit JMP_JSET_{X,K} Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 30/53] bridge: fix igmp / mld query parsing Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 31/53] net/mlx4_en: Fix endianness bug in IPV6 csum calculation Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 32/53] net: fec: only clear a queue's work bit if the queue was emptied Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 33/53] tcp: refresh skb timestamp at retransmit time Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 34/53] net/route: enforce hoplimit max value Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 35/53] decnet: Do not build routes to devices without decnet private data Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 36/53] route: do not cache fib route info on local routes with oif Kamal Mostafa
2016-05-24 17:55 ` Kamal Mostafa [this message]
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 38/53] vlan: pull on __vlan_insert_tag error path and fix csum correction Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 39/53] ipv4/fib: don't warn when primary address is missing if in_dev is dead Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 40/53] bpf: fix double-fdput in replace_map_fd_with_map_ptr() Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 41/53] net_sched: introduce qdisc_replace() helper Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 42/53] net_sched: update hierarchical backlog too Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 43/53] sch_htb: update backlog as well Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 44/53] sch_dsmark: " Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 45/53] netem: Segment GSO packets on enqueue Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 46/53] net: fix infoleak in llc Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 47/53] net: fix infoleak in rtnetlink Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 48/53] VSOCK: do not disconnect socket when peer has shutdown SEND only Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 49/53] net: bridge: fix old ioctl unlocked net device walk Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 50/53] net: fix a kernel infoleak in x25 module Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 51/53] cdc_mbim: apply "NDP to end" quirk to all Huawei devices Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 52/53] soreuseport: fix ordering for mixed v4/v6 sockets Kamal Mostafa
2016-05-24 17:55 ` [PATCH 4.2.y-ckt 53/53] uapi glibc compat: fix compile errors when glibc net/if.h included before linux/if.h Kamal Mostafa
2016-05-25  7:22   ` Mikko Rapeli

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=1464112523-3701-38-git-send-email-kamal@canonical.com \
    --to=kamal@canonical.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=kernel-team@lists.ubuntu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@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).