linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 4.18 19/33] nfp: flower: use offsets provided by pedit instead of index for ipv6
Date: Tue, 30 Oct 2018 09:26:43 -0400	[thread overview]
Message-ID: <20181030132657.217970-19-sashal@kernel.org> (raw)
In-Reply-To: <20181030132657.217970-1-sashal@kernel.org>

From: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>

[ Upstream commit 140b6abac26d799f75d772ab5e969b34ad8d68f1 ]

Previously when populating the set ipv6 address action, we incorrectly
made use of pedit's key index to determine which 32bit word should be
set. We now calculate which word has been selected based on the offset
provided by the pedit action.

Fixes: 354b82bb320e ("nfp: add set ipv6 source and destination address")
Signed-off-by: Pieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 .../ethernet/netronome/nfp/flower/action.c    | 26 +++++++++++--------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/flower/action.c b/drivers/net/ethernet/netronome/nfp/flower/action.c
index 35f294bf0cd4..417fbcc64f00 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/action.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/action.c
@@ -335,12 +335,12 @@ nfp_fl_set_ip4(const struct tc_action *action, int idx, u32 off,
 }
 
 static void
-nfp_fl_set_ip6_helper(int opcode_tag, int idx, __be32 exact, __be32 mask,
+nfp_fl_set_ip6_helper(int opcode_tag, u8 word, __be32 exact, __be32 mask,
 		      struct nfp_fl_set_ipv6_addr *ip6)
 {
-	ip6->ipv6[idx % 4].mask |= mask;
-	ip6->ipv6[idx % 4].exact &= ~mask;
-	ip6->ipv6[idx % 4].exact |= exact & mask;
+	ip6->ipv6[word].mask |= mask;
+	ip6->ipv6[word].exact &= ~mask;
+	ip6->ipv6[word].exact |= exact & mask;
 
 	ip6->reserved = cpu_to_be16(0);
 	ip6->head.jump_id = opcode_tag;
@@ -353,6 +353,7 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off,
 	       struct nfp_fl_set_ipv6_addr *ip_src)
 {
 	__be32 exact, mask;
+	u8 word;
 
 	/* We are expecting tcf_pedit to return a big endian value */
 	mask = (__force __be32)~tcf_pedit_mask(action, idx);
@@ -361,17 +362,20 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off,
 	if (exact & ~mask)
 		return -EOPNOTSUPP;
 
-	if (off < offsetof(struct ipv6hdr, saddr))
+	if (off < offsetof(struct ipv6hdr, saddr)) {
 		return -EOPNOTSUPP;
-	else if (off < offsetof(struct ipv6hdr, daddr))
-		nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_SRC, idx,
+	} else if (off < offsetof(struct ipv6hdr, daddr)) {
+		word = (off - offsetof(struct ipv6hdr, saddr)) / sizeof(exact);
+		nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_SRC, word,
 				      exact, mask, ip_src);
-	else if (off < offsetof(struct ipv6hdr, daddr) +
-		       sizeof(struct in6_addr))
-		nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_DST, idx,
+	} else if (off < offsetof(struct ipv6hdr, daddr) +
+		       sizeof(struct in6_addr)) {
+		word = (off - offsetof(struct ipv6hdr, daddr)) / sizeof(exact);
+		nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_DST, word,
 				      exact, mask, ip_dst);
-	else
+	} else {
 		return -EOPNOTSUPP;
+	}
 
 	return 0;
 }
-- 
2.17.1


  parent reply	other threads:[~2018-10-30 13:27 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-30 13:26 [PATCH AUTOSEL 4.18 01/33] drm: fix use of freed memory in drm_mode_setcrtc Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 02/33] bpf: do not blindly change rlimit in reuseport net selftest Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 03/33] nvme: remove ns sibling before clearing path Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 04/33] Revert "perf tools: Fix PMU term format max value calculation" Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 05/33] selftests: usbip: add wait after attach and before checking port status Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 06/33] net/mlx5: Fix memory leak when setting fpga ipsec caps Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 07/33] net/mlx5: Take only bit 24-26 of wqe.pftype_wq for page fault type Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 08/33] net/mlx5: WQ, fixes for fragmented WQ buffers API Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 09/33] xsk: do not call synchronize_net() under RCU read lock Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 10/33] xfrm: policy: use hlist rcu variants on insert Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 11/33] perf vendor events intel: Fix wrong filter_band* values for uncore events Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 12/33] sparc: Fix single-pcr perf event counter management Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 13/33] sparc: Throttle perf events properly Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 14/33] sparc64: Make proc_id signed Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 15/33] r8169: Enable MSI-X on RTL8106e Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 16/33] net: bcmgenet: Poll internal PHY for GENETv5 Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 17/33] net: fec: don't dump RX FIFO register when not available Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 18/33] nfp: flower: fix pedit set actions for multiple partial masks Sasha Levin
2018-10-30 13:26 ` Sasha Levin [this message]
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 20/33] sched/fair: Fix the min_vruntime update logic in dequeue_entity() Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 21/33] perf evsel: Store ids for events with their own cpus perf_event__synthesize_event_update_cpus Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 22/33] perf tools: Fix use of alternatives to find JDIR Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 23/33] perf cpu_map: Align cpu map synthesized events properly Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 24/33] perf report: Don't crash on invalid inline debug information Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 25/33] x86/fpu: Remove second definition of fpu in __fpu__restore_sig() Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 26/33] net: qla3xxx: Remove overflowing shift statement Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 27/33] r8169: re-enable MSI-X on RTL8168g Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 28/33] virtio_net: avoid using netif_tx_disable() for serializing tx routine Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 29/33] drm: Get ref on CRTC commit object when waiting for flip_done Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 30/33] r8169: fix NAPI handling under high load Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 31/33] selftests: ftrace: Add synthetic event syntax testcase Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 32/33] net: fix pskb_trim_rcsum_slow() with odd trim offset Sasha Levin
2018-10-30 13:26 ` [PATCH AUTOSEL 4.18 33/33] i2c: rcar: cleanup DMA for all kinds of failure Sasha Levin

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=20181030132657.217970-19-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pieter.jansenvanvuuren@netronome.com \
    --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).