Commit 47327c93 authored by Guangbin Huang's avatar Guangbin Huang Committed by David S. Miller

net: hns3: fix a copying IPv6 address error in hclge_fd_get_flow_tuples()

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: d93ed94f ("net: hns3: add aRFS support for PF")
Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 19eb1123
...@@ -6113,6 +6113,9 @@ static int hclge_get_all_rules(struct hnae3_handle *handle, ...@@ -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, static void hclge_fd_get_flow_tuples(const struct flow_keys *fkeys,
struct hclge_fd_rule_tuples *tuples) 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->ether_proto = be16_to_cpu(fkeys->basic.n_proto);
tuples->ip_proto = fkeys->basic.ip_proto; tuples->ip_proto = fkeys->basic.ip_proto;
tuples->dst_port = be16_to_cpu(fkeys->ports.dst); 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, ...@@ -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->src_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.src);
tuples->dst_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.dst); tuples->dst_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.dst);
} else { } else {
memcpy(tuples->src_ip, int i;
fkeys->addrs.v6addrs.src.in6_u.u6_addr32,
sizeof(tuples->src_ip)); for (i = 0; i < IPV6_SIZE; i++) {
memcpy(tuples->dst_ip, tuples->src_ip[i] = be32_to_cpu(flow_ip6_src[i]);
fkeys->addrs.v6addrs.dst.in6_u.u6_addr32, tuples->dst_ip[i] = be32_to_cpu(flow_ip6_dst[i]);
sizeof(tuples->dst_ip)); }
} }
} }
......
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