Commit e43d940f authored by Yinjun Zhang's avatar Yinjun Zhang Committed by Paolo Abeni

nfp: flower: support ct merging when mangle action exists

Current implementation of ct merging doesn't support the case
that the fields mangling in pre_ct rules are matched in post_ct
rules.

This change is to support merging when mangling mac address,
ip address, tos, ttl and l4 port. VLAN and MPLS mangling is
not involved yet.
Signed-off-by: default avatarYinjun Zhang <yinjun.zhang@corigine.com>
Signed-off-by: default avatarLouis Peens <louis.peens@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/20220518075055.130649-1-simon.horman@corigine.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent b885aab3
...@@ -98,16 +98,18 @@ nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext, ...@@ -98,16 +98,18 @@ nfp_flower_compile_mac(struct nfp_flower_mac_mpls *ext,
{ {
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
struct flow_match_eth_addrs match; struct flow_match_eth_addrs match;
u8 tmp;
int i; int i;
flow_rule_match_eth_addrs(rule, &match); flow_rule_match_eth_addrs(rule, &match);
/* Populate mac frame. */ /* Populate mac frame. */
for (i = 0; i < ETH_ALEN; i++) { for (i = 0; i < ETH_ALEN; i++) {
ext->mac_dst[i] |= match.key->dst[i] & tmp = match.key->dst[i] & match.mask->dst[i];
match.mask->dst[i]; ext->mac_dst[i] |= tmp & (~msk->mac_dst[i]);
msk->mac_dst[i] |= match.mask->dst[i]; msk->mac_dst[i] |= match.mask->dst[i];
ext->mac_src[i] |= match.key->src[i] &
match.mask->src[i]; tmp = match.key->src[i] & match.mask->src[i];
ext->mac_src[i] |= tmp & (~msk->mac_src[i]);
msk->mac_src[i] |= match.mask->src[i]; msk->mac_src[i] |= match.mask->src[i];
} }
} }
...@@ -189,11 +191,16 @@ nfp_flower_compile_tport(struct nfp_flower_tp_ports *ext, ...@@ -189,11 +191,16 @@ nfp_flower_compile_tport(struct nfp_flower_tp_ports *ext,
{ {
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_PORTS)) {
struct flow_match_ports match; struct flow_match_ports match;
__be16 tmp;
flow_rule_match_ports(rule, &match); flow_rule_match_ports(rule, &match);
ext->port_src |= match.key->src & match.mask->src;
ext->port_dst |= match.key->dst & match.mask->dst; tmp = match.key->src & match.mask->src;
ext->port_src |= tmp & (~msk->port_src);
msk->port_src |= match.mask->src; msk->port_src |= match.mask->src;
tmp = match.key->dst & match.mask->dst;
ext->port_dst |= tmp & (~msk->port_dst);
msk->port_dst |= match.mask->dst; msk->port_dst |= match.mask->dst;
} }
} }
...@@ -212,11 +219,16 @@ nfp_flower_compile_ip_ext(struct nfp_flower_ip_ext *ext, ...@@ -212,11 +219,16 @@ nfp_flower_compile_ip_ext(struct nfp_flower_ip_ext *ext,
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IP)) { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IP)) {
struct flow_match_ip match; struct flow_match_ip match;
u8 tmp;
flow_rule_match_ip(rule, &match); flow_rule_match_ip(rule, &match);
ext->tos |= match.key->tos & match.mask->tos;
ext->ttl |= match.key->ttl & match.mask->ttl; tmp = match.key->tos & match.mask->tos;
ext->tos |= tmp & (~msk->tos);
msk->tos |= match.mask->tos; msk->tos |= match.mask->tos;
tmp = match.key->ttl & match.mask->ttl;
ext->ttl |= tmp & (~msk->ttl);
msk->ttl |= match.mask->ttl; msk->ttl |= match.mask->ttl;
} }
...@@ -325,11 +337,16 @@ nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *ext, ...@@ -325,11 +337,16 @@ nfp_flower_compile_ipv4(struct nfp_flower_ipv4 *ext,
{ {
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV4_ADDRS)) {
struct flow_match_ipv4_addrs match; struct flow_match_ipv4_addrs match;
__be32 tmp;
flow_rule_match_ipv4_addrs(rule, &match); flow_rule_match_ipv4_addrs(rule, &match);
ext->ipv4_src |= match.key->src & match.mask->src;
ext->ipv4_dst |= match.key->dst & match.mask->dst; tmp = match.key->src & match.mask->src;
ext->ipv4_src |= tmp & (~msk->ipv4_src);
msk->ipv4_src |= match.mask->src; msk->ipv4_src |= match.mask->src;
tmp = match.key->dst & match.mask->dst;
ext->ipv4_dst |= tmp & (~msk->ipv4_dst);
msk->ipv4_dst |= match.mask->dst; msk->ipv4_dst |= match.mask->dst;
} }
...@@ -342,15 +359,21 @@ nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *ext, ...@@ -342,15 +359,21 @@ nfp_flower_compile_ipv6(struct nfp_flower_ipv6 *ext,
{ {
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS)) { if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_IPV6_ADDRS)) {
struct flow_match_ipv6_addrs match; struct flow_match_ipv6_addrs match;
u8 tmp;
int i; int i;
flow_rule_match_ipv6_addrs(rule, &match); flow_rule_match_ipv6_addrs(rule, &match);
for (i = 0; i < sizeof(ext->ipv6_src); i++) { for (i = 0; i < sizeof(ext->ipv6_src); i++) {
ext->ipv6_src.s6_addr[i] |= match.key->src.s6_addr[i] & tmp = match.key->src.s6_addr[i] &
match.mask->src.s6_addr[i]; match.mask->src.s6_addr[i];
ext->ipv6_dst.s6_addr[i] |= match.key->dst.s6_addr[i] & ext->ipv6_src.s6_addr[i] |= tmp &
match.mask->dst.s6_addr[i]; (~msk->ipv6_src.s6_addr[i]);
msk->ipv6_src.s6_addr[i] |= match.mask->src.s6_addr[i]; msk->ipv6_src.s6_addr[i] |= match.mask->src.s6_addr[i];
tmp = match.key->dst.s6_addr[i] &
match.mask->dst.s6_addr[i];
ext->ipv6_dst.s6_addr[i] |= tmp &
(~msk->ipv6_dst.s6_addr[i]);
msk->ipv6_dst.s6_addr[i] |= match.mask->dst.s6_addr[i]; msk->ipv6_dst.s6_addr[i] |= match.mask->dst.s6_addr[i];
} }
} }
......
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