Skip to content

Commit 47327c9

Browse files
Guangbin Huangdavem330
authored andcommitted
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: d93ed94 ("net: hns3: add aRFS support for PF") Signed-off-by: Guangbin Huang <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 19eb112 commit 47327c9

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6113,6 +6113,9 @@ static int hclge_get_all_rules(struct hnae3_handle *handle,
61136113
static void hclge_fd_get_flow_tuples(const struct flow_keys *fkeys,
61146114
struct hclge_fd_rule_tuples *tuples)
61156115
{
6116+
#define flow_ip6_src fkeys->addrs.v6addrs.src.in6_u.u6_addr32
6117+
#define flow_ip6_dst fkeys->addrs.v6addrs.dst.in6_u.u6_addr32
6118+
61166119
tuples->ether_proto = be16_to_cpu(fkeys->basic.n_proto);
61176120
tuples->ip_proto = fkeys->basic.ip_proto;
61186121
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,
61216124
tuples->src_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.src);
61226125
tuples->dst_ip[3] = be32_to_cpu(fkeys->addrs.v4addrs.dst);
61236126
} else {
6124-
memcpy(tuples->src_ip,
6125-
fkeys->addrs.v6addrs.src.in6_u.u6_addr32,
6126-
sizeof(tuples->src_ip));
6127-
memcpy(tuples->dst_ip,
6128-
fkeys->addrs.v6addrs.dst.in6_u.u6_addr32,
6129-
sizeof(tuples->dst_ip));
6127+
int i;
6128+
6129+
for (i = 0; i < IPV6_SIZE; i++) {
6130+
tuples->src_ip[i] = be32_to_cpu(flow_ip6_src[i]);
6131+
tuples->dst_ip[i] = be32_to_cpu(flow_ip6_dst[i]);
6132+
}
61306133
}
61316134
}
61326135

0 commit comments

Comments
 (0)