Skip to content

Commit d833683

Browse files
committed
Merge branch 'nfp-flower-a-few-small-conntrack-offload-fixes'
Louis Peens says: ==================== nfp: flower: a few small conntrack offload fixes This small series addresses two bugs in the nfp conntrack offloading code. The first patch is a check to prevent offloading for a case which is currently not supported by the nfp. The second patch fixes up parsing of layer4 mangling code so it can be correctly offloaded. Since the masks are an inverse mask and we are shifting it so it can be packed together with the destination we effectively need to 'clear' the lower bits of the mask by setting it to 0xFFFF. ==================== Link: https://lore.kernel.org/r/20240124151909.31603-1-louis.peens@corigine.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 5343267 + 3a007b8 commit d833683

File tree

1 file changed

+43
-3
lines changed

1 file changed

+43
-3
lines changed

drivers/net/ethernet/netronome/nfp/flower/conntrack.c

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1424,10 +1424,30 @@ static void nfp_nft_ct_translate_mangle_action(struct flow_action_entry *mangle_
14241424
mangle_action->mangle.mask = (__force u32)cpu_to_be32(mangle_action->mangle.mask);
14251425
return;
14261426

1427+
/* Both struct tcphdr and struct udphdr start with
1428+
* __be16 source;
1429+
* __be16 dest;
1430+
* so we can use the same code for both.
1431+
*/
14271432
case FLOW_ACT_MANGLE_HDR_TYPE_TCP:
14281433
case FLOW_ACT_MANGLE_HDR_TYPE_UDP:
1429-
mangle_action->mangle.val = (__force u16)cpu_to_be16(mangle_action->mangle.val);
1430-
mangle_action->mangle.mask = (__force u16)cpu_to_be16(mangle_action->mangle.mask);
1434+
if (mangle_action->mangle.offset == offsetof(struct tcphdr, source)) {
1435+
mangle_action->mangle.val =
1436+
(__force u32)cpu_to_be32(mangle_action->mangle.val << 16);
1437+
/* The mask of mangle action is inverse mask,
1438+
* so clear the dest tp port with 0xFFFF to
1439+
* instead of rotate-left operation.
1440+
*/
1441+
mangle_action->mangle.mask =
1442+
(__force u32)cpu_to_be32(mangle_action->mangle.mask << 16 | 0xFFFF);
1443+
}
1444+
if (mangle_action->mangle.offset == offsetof(struct tcphdr, dest)) {
1445+
mangle_action->mangle.offset = 0;
1446+
mangle_action->mangle.val =
1447+
(__force u32)cpu_to_be32(mangle_action->mangle.val);
1448+
mangle_action->mangle.mask =
1449+
(__force u32)cpu_to_be32(mangle_action->mangle.mask);
1450+
}
14311451
return;
14321452

14331453
default:
@@ -1864,10 +1884,30 @@ int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv,
18641884
{
18651885
struct flow_rule *rule = flow_cls_offload_flow_rule(flow);
18661886
struct nfp_fl_ct_flow_entry *ct_entry;
1887+
struct flow_action_entry *ct_goto;
18671888
struct nfp_fl_ct_zone_entry *zt;
1889+
struct flow_action_entry *act;
18681890
bool wildcarded = false;
18691891
struct flow_match_ct ct;
1870-
struct flow_action_entry *ct_goto;
1892+
int i;
1893+
1894+
flow_action_for_each(i, act, &rule->action) {
1895+
switch (act->id) {
1896+
case FLOW_ACTION_REDIRECT:
1897+
case FLOW_ACTION_REDIRECT_INGRESS:
1898+
case FLOW_ACTION_MIRRED:
1899+
case FLOW_ACTION_MIRRED_INGRESS:
1900+
if (act->dev->rtnl_link_ops &&
1901+
!strcmp(act->dev->rtnl_link_ops->kind, "openvswitch")) {
1902+
NL_SET_ERR_MSG_MOD(extack,
1903+
"unsupported offload: out port is openvswitch internal port");
1904+
return -EOPNOTSUPP;
1905+
}
1906+
break;
1907+
default:
1908+
break;
1909+
}
1910+
}
18711911

18721912
flow_rule_match_ct(rule, &ct);
18731913
if (!ct.mask->ct_zone) {

0 commit comments

Comments
 (0)