Commit 140b6aba authored by Pieter Jansen van Vuuren's avatar Pieter Jansen van Vuuren Committed by David S. Miller

nfp: flower: use offsets provided by pedit instead of index for ipv6

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: 354b82bb ("nfp: add set ipv6 source and destination address")
Signed-off-by: default avatarPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d08c9e58
...@@ -450,12 +450,12 @@ nfp_fl_set_ip4(const struct tc_action *action, int idx, u32 off, ...@@ -450,12 +450,12 @@ nfp_fl_set_ip4(const struct tc_action *action, int idx, u32 off,
} }
static void 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) struct nfp_fl_set_ipv6_addr *ip6)
{ {
ip6->ipv6[idx % 4].mask |= mask; ip6->ipv6[word].mask |= mask;
ip6->ipv6[idx % 4].exact &= ~mask; ip6->ipv6[word].exact &= ~mask;
ip6->ipv6[idx % 4].exact |= exact & mask; ip6->ipv6[word].exact |= exact & mask;
ip6->reserved = cpu_to_be16(0); ip6->reserved = cpu_to_be16(0);
ip6->head.jump_id = opcode_tag; ip6->head.jump_id = opcode_tag;
...@@ -468,6 +468,7 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off, ...@@ -468,6 +468,7 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off,
struct nfp_fl_set_ipv6_addr *ip_src) struct nfp_fl_set_ipv6_addr *ip_src)
{ {
__be32 exact, mask; __be32 exact, mask;
u8 word;
/* We are expecting tcf_pedit to return a big endian value */ /* We are expecting tcf_pedit to return a big endian value */
mask = (__force __be32)~tcf_pedit_mask(action, idx); mask = (__force __be32)~tcf_pedit_mask(action, idx);
...@@ -476,17 +477,20 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off, ...@@ -476,17 +477,20 @@ nfp_fl_set_ip6(const struct tc_action *action, int idx, u32 off,
if (exact & ~mask) if (exact & ~mask)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (off < offsetof(struct ipv6hdr, saddr)) if (off < offsetof(struct ipv6hdr, saddr)) {
return -EOPNOTSUPP; return -EOPNOTSUPP;
else if (off < offsetof(struct ipv6hdr, daddr)) } else if (off < offsetof(struct ipv6hdr, daddr)) {
nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_SRC, idx, 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); exact, mask, ip_src);
else if (off < offsetof(struct ipv6hdr, daddr) + } else if (off < offsetof(struct ipv6hdr, daddr) +
sizeof(struct in6_addr)) sizeof(struct in6_addr)) {
nfp_fl_set_ip6_helper(NFP_FL_ACTION_OPCODE_SET_IPV6_DST, idx, 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); exact, mask, ip_dst);
else } else {
return -EOPNOTSUPP; return -EOPNOTSUPP;
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment