]> Git Repo - linux.git/commitdiff
nfp: flower: use offsets provided by pedit instead of index for ipv6
authorPieter Jansen van Vuuren <[email protected]>
Mon, 15 Oct 2018 23:52:25 +0000 (16:52 -0700)
committerDavid S. Miller <[email protected]>
Tue, 16 Oct 2018 06:17:25 +0000 (23:17 -0700)
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 <[email protected]>
Reviewed-by: Jakub Kicinski <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
drivers/net/ethernet/netronome/nfp/flower/action.c

index c39d7fdf73e617913e1682842a1e26959b8782ff..7a1e9cd9cc62cd539c3833866750efe4bdea0ad4 100644 (file)
@@ -450,12 +450,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;
@@ -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)
 {
        __be32 exact, mask;
+       u8 word;
 
        /* We are expecting tcf_pedit to return a big endian value */
        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,
        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;
 }
This page took 0.05692 seconds and 4 git commands to generate.