netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 net-next 1/2] net: introduce skb_postpush_rcsum() helper
@ 2015-04-08 23:26 Alexei Starovoitov
  2015-04-08 23:26 ` [PATCH v3 net-next 2/2] tc: add 'needs_l2' flag to ingress qdisc Alexei Starovoitov
  0 siblings, 1 reply; 20+ messages in thread
From: Alexei Starovoitov @ 2015-04-08 23:26 UTC (permalink / raw)
  To: David S. Miller
  Cc: Daniel Borkmann, Thomas Graf, Jiri Pirko, Jamal Hadi Salim,
	netdev

similar to skb_postpull_rcsum() introduce skb_postpush_rcsum() helper

Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
---

next patch is also using skb_postpush_rcsum()

 include/linux/skbuff.h |   13 +++++++++++++
 net/core/filter.c      |    4 ++--
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 36f3f43c0117..b7a313d13d7b 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2586,6 +2586,19 @@ static inline void skb_postpull_rcsum(struct sk_buff *skb,
 		skb->csum = csum_sub(skb->csum, csum_partial(start, len, 0));
 }
 
+/**
+ *	skb_postpush_rcsum - update checksum for skb after push
+ *	@skb: buffer to update
+ *	@start: start of data after push
+ *	@len: length of data pushed
+ */
+static inline void 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));
+}
+
 unsigned char *skb_pull_rcsum(struct sk_buff *skb, unsigned int len);
 
 /**
diff --git a/net/core/filter.c b/net/core/filter.c
index b669e75d2b36..e5872704c28b 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -1213,8 +1213,8 @@ static u64 bpf_skb_store_bytes(u64 r1, u64 r2, u64 r3, u64 r4, u64 flags)
 		/* skb_store_bits cannot return -EFAULT here */
 		skb_store_bits(skb, offset, ptr, len);
 
-	if (BPF_RECOMPUTE_CSUM(flags) && skb->ip_summed == CHECKSUM_COMPLETE)
-		skb->csum = csum_add(skb->csum, csum_partial(ptr, len, 0));
+	if (BPF_RECOMPUTE_CSUM(flags))
+		skb_postpush_rcsum(skb, ptr, len);
 	return 0;
 }
 
-- 
1.7.9.5

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

end of thread, other threads:[~2015-04-13 16:13 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-08 23:26 [PATCH v3 net-next 1/2] net: introduce skb_postpush_rcsum() helper Alexei Starovoitov
2015-04-08 23:26 ` [PATCH v3 net-next 2/2] tc: add 'needs_l2' flag to ingress qdisc Alexei Starovoitov
2015-04-09  2:44   ` David Miller
2015-04-09  3:05     ` Alexei Starovoitov
2015-04-09  3:14       ` David Miller
2015-04-09  3:39         ` Alexei Starovoitov
2015-04-09  5:20           ` Alexei Starovoitov
2015-04-09  5:25             ` David Miller
2015-04-09 15:15             ` Daniel Borkmann
2015-04-09 15:36               ` Eric Dumazet
2015-04-09 17:20                 ` Alexei Starovoitov
2015-04-09 10:49       ` Jamal Hadi Salim
2015-04-09 11:02         ` Jamal Hadi Salim
2015-04-09 15:38         ` Daniel Borkmann
2015-04-10 11:49           ` Jamal Hadi Salim
2015-04-09 17:03         ` Alexei Starovoitov
2015-04-10 12:48           ` Jamal Hadi Salim
2015-04-10 22:35             ` Alexei Starovoitov
2015-04-13 14:28               ` Jamal Hadi Salim
2015-04-13 16:13                 ` Alexei Starovoitov

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