net/sched: cls_flower: Add support for matching on ct_state reply flag
Subsystems (4)
cover net/sched: cls_flower: Add support for matching on ct_state reply flag
This patchset adds software match support and offload of flower match ct_state reply flag (+/-rpl).
The first patch adds the definition for the flag and match to flower.
Second patch gives the direction of the connection to the offloading drivers via ct_metadata flow offload action.
The last patch does offload of this new ct_state by using the supplied connection's direction.
Paul Blakey (3):
net/sched: cls_flower: Add match on the ct_state reply flag
net: flow_offload: Add original direction flag to ct_metadata net/mlx5: CT: Add support for matching on ct_state reply flag
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 13 ++++++++++--- include/net/flow_offload.h | 1 + include/uapi/linux/pkt_cls.h | 1 + net/sched/act_ct.c | 1 + net/sched/cls_flower.c | 6 ++++-- 5 files changed, 17 insertions(+), 5 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/3 net/sched: cls_flower: Add match on the ct_state reply flag
Add match on the ct_state reply flag.
Example:
$ tc filter add dev ens1f0_0 ingress prio 1 chain 1 proto ip flower \ ct_state +trk+est+rpl \ action mirred egress redirect dev ens1f0_1 $ tc filter add dev ens1f0_1 ingress prio 1 chain 1 proto ip flower \ ct_state +trk+est-rpl \ action mirred egress redirect dev ens1f0_0
--- include/uapi/linux/pkt_cls.h | 1 + net/sched/cls_flower.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
include/uapi/linux/pkt_cls.h +1 -0
@@ -592,6 +592,7 @@ enum {TCA_FLOWER_KEY_CT_FLAGS_RELATED =1 <<2 ,/* Related to an established connection. */ TCA_FLOWER_KEY_CT_FLAGS_TRACKED =1 <<3 ,/* Conntrack has occurred. */ TCA_FLOWER_KEY_CT_FLAGS_INVALID =1 <<4 ,/* Conntrack is invalid. */ + TCA_FLOWER_KEY_CT_FLAGS_REPLY = 1 << 5, /* Packet is in the reply direction. */ }; enum {
net/sched/cls_flower.c +4 -2
@@ -291,9 +291,11 @@ struct cls_fl_filter *fl_mask_lookup(struct fl_flow_mask *mask, struct fl_flow_k [IP_CT_RELATED ] =TCA_FLOWER_KEY_CT_FLAGS_TRACKED | TCA_FLOWER_KEY_CT_FLAGS_RELATED, [IP_CT_ESTABLISHED_REPLY ] =TCA_FLOWER_KEY_CT_FLAGS_TRACKED | - TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED, +TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED | + TCA_FLOWER_KEY_CT_FLAGS_REPLY, [IP_CT_RELATED_REPLY ] =TCA_FLOWER_KEY_CT_FLAGS_TRACKED | - TCA_FLOWER_KEY_CT_FLAGS_RELATED, +TCA_FLOWER_KEY_CT_FLAGS_RELATED | + TCA_FLOWER_KEY_CT_FLAGS_REPLY, [IP_CT_NEW ] =TCA_FLOWER_KEY_CT_FLAGS_TRACKED | TCA_FLOWER_KEY_CT_FLAGS_NEW, };
Signature · 1 line
1.8.3.1
PATCH 2/3 net: flow_offload: Add original direction flag to ct_metadata
In reply to Paul BlakeyGive offloading drivers the direction of the offloaded ct flow, this will be used for matches on direction (ct_state +/-rpl).
--- include/net/flow_offload.h | 1 + net/sched/act_ct.c | 1 + 2 files changed, 2 insertions(+)
include/net/flow_offload.h +1 -0
@@ -245,6 +245,7 @@ struct flow_action_entry {unsigned long cookie;u32 mark;u32 labels[4 ]; +bool orig_dir; } ct_metadata;struct {/* FLOW_ACTION_MPLS_PUSH */ u32 label;
net/sched/act_ct.c +1 -0
@@ -183,6 +183,7 @@ static void tcf_ct_flow_table_add_action_meta(struct nf_conn *ct,IP_CT_ESTABLISHED_REPLY ;/* aligns with the CT reference on the SKB nf_ct_set */ entry->ct_metadata.cookie = (unsigned long )ct | ctinfo; + entry->ct_metadata.orig_dir = dir ==IP_CT_DIR_ORIGINAL ; act_ct_labels = entry->ct_metadata.labels; ct_labels =nf_ct_labels_find (ct);
Signature · 1 line
1.8.3.1
PATCH 3/3 net/mlx5: CT: Add support for matching on ct_state reply flag
In reply to Paul BlakeyAdd support for matching on ct_state reply flag.
Example:
$ tc filter add dev ens1f0_0 ingress prio 1 chain 1 proto ip flower \ ct_state +trk+est+rpl \ action mirred egress redirect dev ens1f0_1 $ tc filter add dev ens1f0_1 ingress prio 1 chain 1 proto ip flower \ ct_state +trk+est-rpl \ action mirred egress redirect dev ens1f0_0
--- drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c +10 -3
@@ -27,6 +27,7 @@#define MLX5_CT_STATE_ESTABLISHED_BIT BIT(1)#define MLX5_CT_STATE_TRK_BIT BIT(2)#define MLX5_CT_STATE_NAT_BIT BIT(3) +#define MLX5_CT_STATE_REPLY_BIT BIT(4)#define MLX5_FTE_ID_BITS (mlx5e_tc_attr_to_reg_mappings[FTEID_TO_REG].mlen * 8)#define MLX5_FTE_ID_MAX GENMASK(MLX5_FTE_ID_BITS - 1, 0)
@@ -635,6 +636,7 @@ struct mlx5_ct_entry { } ct_state |=MLX5_CT_STATE_ESTABLISHED_BIT |MLX5_CT_STATE_TRK_BIT ; + ct_state |= meta->ct_metadata.orig_dir ?0 :MLX5_CT_STATE_REPLY_BIT ; err = mlx5_tc_ct_entry_set_registers(ct_priv, &mod_acts, ct_state, meta->ct_metadata.mark,
@@ -1080,8 +1082,8 @@ void mlx5_tc_ct_match_del(struct mlx5_tc_ct_priv *priv, struct mlx5_ct_attr *ct_ struct netlink_ext_ack *extack) {struct flow_rule *rule =flow_cls_offload_flow_rule (f); +bool trk, est, untrk, unest, new, rpl, unrpl;struct flow_dissector_key_ct *mask, *key; -bool trk, est, untrk, unest, new;u32 ctstate =0 , ctstate_mask =0 ;u16 ct_state_on, ct_state_off;u16 ct_state, ct_state_mask;
@@ -1107,9 +1109,10 @@ void mlx5_tc_ct_match_del(struct mlx5_tc_ct_priv *priv, struct mlx5_ct_attr *ct_if (ct_state_mask & ~(TCA_FLOWER_KEY_CT_FLAGS_TRACKED |TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED | -TCA_FLOWER_KEY_CT_FLAGS_NEW )) { +TCA_FLOWER_KEY_CT_FLAGS_NEW | +TCA_FLOWER_KEY_CT_FLAGS_REPLY )) {NL_SET_ERR_MSG_MOD (extack, -"only ct_state trk, est and new are supported for offload" ); +"only ct_state trk, est, new and rpl are supported for offload" );return -EOPNOTSUPP ; }
@@ -1118,13 +1121,17 @@ void mlx5_tc_ct_match_del(struct mlx5_tc_ct_priv *priv, struct mlx5_ct_attr *ct_ trk = ct_state_on &TCA_FLOWER_KEY_CT_FLAGS_TRACKED ; new = ct_state_on &TCA_FLOWER_KEY_CT_FLAGS_NEW ; est = ct_state_on &TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED ; + rpl = ct_state_on &TCA_FLOWER_KEY_CT_FLAGS_REPLY ; untrk = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_TRACKED ; unest = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED ; + unrpl = ct_state_off &TCA_FLOWER_KEY_CT_FLAGS_REPLY ; ctstate |= trk ?MLX5_CT_STATE_TRK_BIT :0 ; ctstate |= est ?MLX5_CT_STATE_ESTABLISHED_BIT :0 ; + ctstate |= rpl ?MLX5_CT_STATE_REPLY_BIT :0 ; ctstate_mask |= (untrk || trk) ?MLX5_CT_STATE_TRK_BIT :0 ; ctstate_mask |= (unest || est) ?MLX5_CT_STATE_ESTABLISHED_BIT :0 ; + ctstate_mask |= (unrpl || rpl) ?MLX5_CT_STATE_REPLY_BIT :0 ;if (new) { NL_SET_ERR_MSG_MOD(extack,
Signature · 1 line
1.8.3.1
Re: [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag
Quoted 1 line · Paul Blakey
Add support for matching on
ct_statereply flag.
Sorry for the late reply, missed the patchset here. (just noticed because of the iproute2 patch, thanks for the Cc in there)
Only one question though. Is it safe to assume that this will require a firmware update as well?
Thanks,
Marcelo
Re: [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag
Quoted 8 lines · Marcelo Ricardo Leitner
Quoted 1 line · Paul Blakey
Add support for matching on
ct_statereply flag.Sorry for the late reply, missed the patchset here. (just noticed because of the iproute2 patch, thanks for the Cc in there)
Only one question though. Is it safe to assume that this will require a firmware update as well?
No, it will not, there was room for this flag in the register before (as long as you had a firmware recent enough that supported CT feature itself ofc).
Paul.
Quoted 4 lines
Thanks,
Marcelo
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 9 lines · On Wed, 27 Jan 2021 16:32:44 +0200 you wrote:
This patchset adds software match support and offload of flower match
ct_statereply flag (+/-rpl).The first patch adds the definition for the flag and match to flower.
Second patch gives the direction of the connection to the offloading drivers via
ct_metadataflow offload action.[...]
Here is the summary with links:
- [net-next,1/3] net/sched: cls_flower: Add match on the ct_state reply flag
https://git.kernel.org/netdev/net-next/c/8c85d18ce647 - [net-next,2/3] net: flow_offload: Add original direction flag to ct_metadata https://git.kernel.org/netdev/net-next/c/941eff5aea5d - [net-next,3/3] net/mlx5: CT: Add support for matching on ct_state reply flag https://git.kernel.org/netdev/net-next/c/6895cb3a95c9
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html