]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: hns3: fix a copying IPv6 address error in hclge_fd_get_flow_tuples()
authorGuangbin Huang <huangguangbin2@huawei.com>
Fri, 14 Feb 2020 01:53:43 +0000 (09:53 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 14 Feb 2020 15:05:17 +0000 (07:05 -0800)
The IPv6 address defined in struct in6_addr is specified as
big endian, but there is no specified endian in struct
hclge_fd_rule_tuples, so it  will cause a problem if directly
use memcpy() to copy ipv6 address between these two structures
since this field in struct hclge_fd_rule_tuples is little endian.

This patch fixes this problem by using be32_to_cpu() to convert
endian of IPv6 address of struct in6_addr before copying.

Fixes: d93ed94fbeaf ("net: hns3: add aRFS support for PF")
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: Huazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

index 25ac573251294255ed74236fcbe581945342a8e2..492bc944646372bea3db8212884e9d3914dd2a5e 100644 (file)
@@ -6113,6 +6113,9 @@ static int hclge_get_all_rules(struct hnae3_handle *handle,
 static void hclge_fd_get_flow_tuples(const struct flow_keys *fkeys,
                                     struct hclge_fd_rule_tuples *tuples)
 {
+#define flow_ip6_src fkeys->addrs.v6addrs.src.in6_u.u6_addr32
+#define flow_ip6_dst fkeys->addrs.v6addrs.dst.in6_u.u6_addr32
+
        tuples->ether_proto = be16_to_cpu(fkeys->basic.n_proto);
        tuples->ip_proto = fkeys->basic.ip_proto;
        tuples->dst_port = be16_to_cpu(fkeys->ports.dst);
@@ -6121,12 +6124,12 @@ static void hclge_fd_get_flow_tuples(const struct flow_keys *fkeys,
                tuples->src_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.src);
                tuples->dst_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.dst);
        } else {
-               memcpy(tuples->src_ip,
-                      fkeys->addrs.v6addrs.src.in6_u.u6_addr32,
-                      sizeof(tuples->src_ip));
-               memcpy(tuples->dst_ip,
-                      fkeys->addrs.v6addrs.dst.in6_u.u6_addr32,
-                      sizeof(tuples->dst_ip));
+               int i;
+
+               for (i = 0; i < IPV6_SIZE; i++) {
+                       tuples->src_ip[i] = be32_to_cpu(flow_ip6_src[i]);
+                       tuples->dst_ip[i] = be32_to_cpu(flow_ip6_dst[i]);
+               }
        }
 }