Commit f13e4415 authored by David S. Miller's avatar David S. Miller

Merge branch 'mlxsw-Implement-ACL-dropped-packets-identification'

Jiri Pirko says:

====================
mlxsw: Implement ACL-dropped packets identification

mlxsw hardware allows to insert a ACL-drop action with a value defined
by user that would be later on passed with a dropped packet.

To implement this, use the existing TC action cookie and pass it to the
driver. As the cookie format coming down from TC and the mlxsw HW cookie
format is different, do the mapping of these two using idr and rhashtable.

The cookie is passed up from the HW through devlink_trap_report() to
drop_monitor code. A new metadata type is used for that.

Example:
$ tc qdisc add dev enp0s16np1 clsact
$ tc filter add dev enp0s16np1 ingress protocol ip pref 10 flower skip_sw dst_ip 192.168.1.2 action drop cookie 3b45fa38c8
                                                                                                                ^^^^^^^^^^
$ devlink trap set pci/0000:00:10.0 trap acl action trap
$ dropwatch
Initializing null lookup method
dropwatch> set hw true
setting hardware drops monitoring to 1
dropwatch> set alertmode packet
Setting alert mode
Alert mode successfully set
dropwatch> start
Enabling monitoring...
Kernel monitoring activated.
Issue Ctrl-C to stop monitoring
drop at: ingress_flow_action_drop (acl_drops)
origin: hardware
input port ifindex: 30
input port name: enp0s16np1
cookie: 3b45fa38c8    <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
timestamp: Fri Jan 24 17:10:53 2020 715387671 nsec
protocol: 0x800
length: 98
original length: 98

This way the user may insert multiple drop rules and monitor the dropped
packets with the information of which action caused the drop.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3b3e808c 7a3c3f44
...@@ -473,7 +473,10 @@ enum mlxsw_devlink_param_id { ...@@ -473,7 +473,10 @@ enum mlxsw_devlink_param_id {
}; };
struct mlxsw_skb_cb { struct mlxsw_skb_cb {
union {
struct mlxsw_tx_info tx_info; struct mlxsw_tx_info tx_info;
u32 cookie_index; /* Only used during receive */
};
}; };
static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb) static inline struct mlxsw_skb_cb *mlxsw_skb_cb(struct sk_buff *skb)
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <net/flow_offload.h>
struct mlxsw_afa; struct mlxsw_afa;
struct mlxsw_afa_block; struct mlxsw_afa_block;
...@@ -42,7 +43,11 @@ int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity); ...@@ -42,7 +43,11 @@ int mlxsw_afa_block_activity_get(struct mlxsw_afa_block *block, bool *activity);
int mlxsw_afa_block_continue(struct mlxsw_afa_block *block); int mlxsw_afa_block_continue(struct mlxsw_afa_block *block);
int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id); int mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id);
int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block); int mlxsw_afa_block_terminate(struct mlxsw_afa_block *block);
int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block, bool ingress); const struct flow_action_cookie *
mlxsw_afa_cookie_lookup(struct mlxsw_afa *mlxsw_afa, u32 cookie_index);
int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block, bool ingress,
const struct flow_action_cookie *fa_cookie,
struct netlink_ext_ack *extack);
int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id); int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block, u16 trap_id);
int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block, int mlxsw_afa_block_append_trap_and_forward(struct mlxsw_afa_block *block,
u16 trap_id); u16 trap_id);
......
...@@ -575,6 +575,15 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci, ...@@ -575,6 +575,15 @@ static void mlxsw_pci_cqe_rdq_handle(struct mlxsw_pci *mlxsw_pci,
rx_info.trap_id = mlxsw_pci_cqe_trap_id_get(cqe); rx_info.trap_id = mlxsw_pci_cqe_trap_id_get(cqe);
if (rx_info.trap_id == MLXSW_TRAP_ID_DISCARD_INGRESS_ACL ||
rx_info.trap_id == MLXSW_TRAP_ID_DISCARD_EGRESS_ACL) {
u32 cookie_index = 0;
if (mlxsw_pci->max_cqe_ver >= MLXSW_PCI_CQE_V2)
cookie_index = mlxsw_pci_cqe2_user_def_val_orig_pkt_len_get(cqe);
mlxsw_skb_cb(skb)->cookie_index = cookie_index;
}
byte_count = mlxsw_pci_cqe_byte_count_get(cqe); byte_count = mlxsw_pci_cqe_byte_count_get(cqe);
if (mlxsw_pci_cqe_crc_get(cqe_v, cqe)) if (mlxsw_pci_cqe_crc_get(cqe_v, cqe))
byte_count -= ETH_FCS_LEN; byte_count -= ETH_FCS_LEN;
......
...@@ -208,6 +208,11 @@ MLXSW_ITEM32(pci, cqe0, dqn, 0x0C, 1, 5); ...@@ -208,6 +208,11 @@ MLXSW_ITEM32(pci, cqe0, dqn, 0x0C, 1, 5);
MLXSW_ITEM32(pci, cqe12, dqn, 0x0C, 1, 6); MLXSW_ITEM32(pci, cqe12, dqn, 0x0C, 1, 6);
mlxsw_pci_cqe_item_helpers(dqn, 0, 12, 12); mlxsw_pci_cqe_item_helpers(dqn, 0, 12, 12);
/* pci_cqe_user_def_val_orig_pkt_len
* When trap_id is an ACL: User defined value from policy engine action.
*/
MLXSW_ITEM32(pci, cqe2, user_def_val_orig_pkt_len, 0x14, 0, 20);
/* pci_cqe_owner /* pci_cqe_owner
* Ownership bit. * Ownership bit.
*/ */
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
#include <net/red.h> #include <net/red.h>
#include <net/vxlan.h> #include <net/vxlan.h>
#include <net/flow_offload.h>
#include "port.h" #include "port.h"
#include "core.h" #include "core.h"
...@@ -726,7 +727,9 @@ int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei, ...@@ -726,7 +727,9 @@ int mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
u16 group_id); u16 group_id);
int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei); int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei);
int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei, int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei,
bool ingress); bool ingress,
const struct flow_action_cookie *fa_cookie,
struct netlink_ext_ack *extack);
int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei); int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp, int mlxsw_sp_acl_rulei_act_mirror(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_acl_rule_info *rulei, struct mlxsw_sp_acl_rule_info *rulei,
...@@ -777,6 +780,12 @@ int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp, ...@@ -777,6 +780,12 @@ int mlxsw_sp_acl_rule_get_stats(struct mlxsw_sp *mlxsw_sp,
struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp); struct mlxsw_sp_fid *mlxsw_sp_acl_dummy_fid(struct mlxsw_sp *mlxsw_sp);
static inline const struct flow_action_cookie *
mlxsw_sp_acl_act_cookie_lookup(struct mlxsw_sp *mlxsw_sp, u32 cookie_index)
{
return mlxsw_afa_cookie_lookup(mlxsw_sp->afa, cookie_index);
}
int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp); int mlxsw_sp_acl_init(struct mlxsw_sp *mlxsw_sp);
void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp); void mlxsw_sp_acl_fini(struct mlxsw_sp *mlxsw_sp);
u32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp); u32 mlxsw_sp_acl_region_rehash_intrvl_get(struct mlxsw_sp *mlxsw_sp);
......
...@@ -536,9 +536,12 @@ int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei) ...@@ -536,9 +536,12 @@ int mlxsw_sp_acl_rulei_act_terminate(struct mlxsw_sp_acl_rule_info *rulei)
} }
int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei, int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei,
bool ingress) bool ingress,
const struct flow_action_cookie *fa_cookie,
struct netlink_ext_ack *extack)
{ {
return mlxsw_afa_block_append_drop(rulei->act_block, ingress); return mlxsw_afa_block_append_drop(rulei->act_block, ingress,
fa_cookie, extack);
} }
int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei) int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei)
......
...@@ -49,7 +49,8 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp, ...@@ -49,7 +49,8 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
ingress = mlxsw_sp_acl_block_is_ingress_bound(block); ingress = mlxsw_sp_acl_block_is_ingress_bound(block);
err = mlxsw_sp_acl_rulei_act_drop(rulei, ingress); err = mlxsw_sp_acl_rulei_act_drop(rulei, ingress,
act->cookie, extack);
if (err) { if (err) {
NL_SET_ERR_MSG_MOD(extack, "Cannot append drop action"); NL_SET_ERR_MSG_MOD(extack, "Cannot append drop action");
return err; return err;
......
...@@ -71,7 +71,36 @@ static void mlxsw_sp_rx_drop_listener(struct sk_buff *skb, u8 local_port, ...@@ -71,7 +71,36 @@ static void mlxsw_sp_rx_drop_listener(struct sk_buff *skb, u8 local_port,
in_devlink_port = mlxsw_core_port_devlink_port_get(mlxsw_sp->core, in_devlink_port = mlxsw_core_port_devlink_port_get(mlxsw_sp->core,
local_port); local_port);
skb_push(skb, ETH_HLEN); skb_push(skb, ETH_HLEN);
devlink_trap_report(devlink, skb, trap_ctx, in_devlink_port); devlink_trap_report(devlink, skb, trap_ctx, in_devlink_port, NULL);
consume_skb(skb);
}
static void mlxsw_sp_rx_acl_drop_listener(struct sk_buff *skb, u8 local_port,
void *trap_ctx)
{
u32 cookie_index = mlxsw_skb_cb(skb)->cookie_index;
const struct flow_action_cookie *fa_cookie;
struct devlink_port *in_devlink_port;
struct mlxsw_sp_port *mlxsw_sp_port;
struct mlxsw_sp *mlxsw_sp;
struct devlink *devlink;
int err;
mlxsw_sp = devlink_trap_ctx_priv(trap_ctx);
mlxsw_sp_port = mlxsw_sp->ports[local_port];
err = mlxsw_sp_rx_listener(mlxsw_sp, skb, local_port, mlxsw_sp_port);
if (err)
return;
devlink = priv_to_devlink(mlxsw_sp->core);
in_devlink_port = mlxsw_core_port_devlink_port_get(mlxsw_sp->core,
local_port);
skb_push(skb, ETH_HLEN);
rcu_read_lock();
fa_cookie = mlxsw_sp_acl_act_cookie_lookup(mlxsw_sp, cookie_index);
devlink_trap_report(devlink, skb, trap_ctx, in_devlink_port, fa_cookie);
rcu_read_unlock();
consume_skb(skb); consume_skb(skb);
} }
...@@ -95,7 +124,7 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port, ...@@ -95,7 +124,7 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port,
in_devlink_port = mlxsw_core_port_devlink_port_get(mlxsw_sp->core, in_devlink_port = mlxsw_core_port_devlink_port_get(mlxsw_sp->core,
local_port); local_port);
skb_push(skb, ETH_HLEN); skb_push(skb, ETH_HLEN);
devlink_trap_report(devlink, skb, trap_ctx, in_devlink_port); devlink_trap_report(devlink, skb, trap_ctx, in_devlink_port, NULL);
skb_pull(skb, ETH_HLEN); skb_pull(skb, ETH_HLEN);
skb->offload_fwd_mark = 1; skb->offload_fwd_mark = 1;
netif_receive_skb(skb); netif_receive_skb(skb);
...@@ -106,6 +135,11 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port, ...@@ -106,6 +135,11 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port,
DEVLINK_TRAP_GROUP_GENERIC(_group_id), \ DEVLINK_TRAP_GROUP_GENERIC(_group_id), \
MLXSW_SP_TRAP_METADATA) MLXSW_SP_TRAP_METADATA)
#define MLXSW_SP_TRAP_DROP_EXT(_id, _group_id, _metadata) \
DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \
DEVLINK_TRAP_GROUP_GENERIC(_group_id), \
MLXSW_SP_TRAP_METADATA | (_metadata))
#define MLXSW_SP_TRAP_DRIVER_DROP(_id, _group_id) \ #define MLXSW_SP_TRAP_DRIVER_DROP(_id, _group_id) \
DEVLINK_TRAP_DRIVER(DROP, DROP, DEVLINK_MLXSW_TRAP_ID_##_id, \ DEVLINK_TRAP_DRIVER(DROP, DROP, DEVLINK_MLXSW_TRAP_ID_##_id, \
DEVLINK_MLXSW_TRAP_NAME_##_id, \ DEVLINK_MLXSW_TRAP_NAME_##_id, \
...@@ -123,7 +157,7 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port, ...@@ -123,7 +157,7 @@ static void mlxsw_sp_rx_exception_listener(struct sk_buff *skb, u8 local_port,
SET_FW_DEFAULT, SP_##_group_id) SET_FW_DEFAULT, SP_##_group_id)
#define MLXSW_SP_RXL_ACL_DISCARD(_id, _en_group_id, _dis_group_id) \ #define MLXSW_SP_RXL_ACL_DISCARD(_id, _en_group_id, _dis_group_id) \
MLXSW_RXL_DIS(mlxsw_sp_rx_drop_listener, DISCARD_##_id, \ MLXSW_RXL_DIS(mlxsw_sp_rx_acl_drop_listener, DISCARD_##_id, \
TRAP_EXCEPTION_TO_CPU, false, SP_##_en_group_id, \ TRAP_EXCEPTION_TO_CPU, false, SP_##_en_group_id, \
SET_FW_DEFAULT, SP_##_dis_group_id) SET_FW_DEFAULT, SP_##_dis_group_id)
...@@ -160,8 +194,10 @@ static const struct devlink_trap mlxsw_sp_traps_arr[] = { ...@@ -160,8 +194,10 @@ static const struct devlink_trap mlxsw_sp_traps_arr[] = {
MLXSW_SP_TRAP_DROP(NON_ROUTABLE, L3_DROPS), MLXSW_SP_TRAP_DROP(NON_ROUTABLE, L3_DROPS),
MLXSW_SP_TRAP_EXCEPTION(DECAP_ERROR, TUNNEL_DROPS), MLXSW_SP_TRAP_EXCEPTION(DECAP_ERROR, TUNNEL_DROPS),
MLXSW_SP_TRAP_DROP(OVERLAY_SMAC_MC, TUNNEL_DROPS), MLXSW_SP_TRAP_DROP(OVERLAY_SMAC_MC, TUNNEL_DROPS),
MLXSW_SP_TRAP_DROP(INGRESS_FLOW_ACTION_DROP, ACL_DROPS), MLXSW_SP_TRAP_DROP_EXT(INGRESS_FLOW_ACTION_DROP, ACL_DROPS,
MLXSW_SP_TRAP_DROP(EGRESS_FLOW_ACTION_DROP, ACL_DROPS), DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE),
MLXSW_SP_TRAP_DROP_EXT(EGRESS_FLOW_ACTION_DROP, ACL_DROPS,
DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE),
}; };
static const struct mlxsw_listener mlxsw_sp_listeners_arr[] = { static const struct mlxsw_listener mlxsw_sp_listeners_arr[] = {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <net/devlink.h> #include <net/devlink.h>
#include <net/ip.h> #include <net/ip.h>
#include <net/flow_offload.h>
#include <uapi/linux/devlink.h> #include <uapi/linux/devlink.h>
#include <uapi/linux/ip.h> #include <uapi/linux/ip.h>
#include <uapi/linux/udp.h> #include <uapi/linux/udp.h>
...@@ -71,6 +72,98 @@ static const struct file_operations nsim_dev_take_snapshot_fops = { ...@@ -71,6 +72,98 @@ static const struct file_operations nsim_dev_take_snapshot_fops = {
.llseek = generic_file_llseek, .llseek = generic_file_llseek,
}; };
static ssize_t nsim_dev_trap_fa_cookie_read(struct file *file,
char __user *data,
size_t count, loff_t *ppos)
{
struct nsim_dev *nsim_dev = file->private_data;
struct flow_action_cookie *fa_cookie;
unsigned int buf_len;
ssize_t ret;
char *buf;
spin_lock(&nsim_dev->fa_cookie_lock);
fa_cookie = nsim_dev->fa_cookie;
if (!fa_cookie) {
ret = -EINVAL;
goto errout;
}
buf_len = fa_cookie->cookie_len * 2;
buf = kmalloc(buf_len, GFP_ATOMIC);
if (!buf) {
ret = -ENOMEM;
goto errout;
}
bin2hex(buf, fa_cookie->cookie, fa_cookie->cookie_len);
spin_unlock(&nsim_dev->fa_cookie_lock);
ret = simple_read_from_buffer(data, count, ppos, buf, buf_len);
kfree(buf);
return ret;
errout:
spin_unlock(&nsim_dev->fa_cookie_lock);
return ret;
}
static ssize_t nsim_dev_trap_fa_cookie_write(struct file *file,
const char __user *data,
size_t count, loff_t *ppos)
{
struct nsim_dev *nsim_dev = file->private_data;
struct flow_action_cookie *fa_cookie;
size_t cookie_len;
ssize_t ret;
char *buf;
if (*ppos != 0)
return -EINVAL;
cookie_len = (count - 1) / 2;
if ((count - 1) % 2)
return -EINVAL;
buf = kmalloc(count, GFP_KERNEL | __GFP_NOWARN);
if (!buf)
return -ENOMEM;
ret = simple_write_to_buffer(buf, count, ppos, data, count);
if (ret < 0)
goto free_buf;
fa_cookie = kmalloc(sizeof(*fa_cookie) + cookie_len,
GFP_KERNEL | __GFP_NOWARN);
if (!fa_cookie) {
ret = -ENOMEM;
goto free_buf;
}
fa_cookie->cookie_len = cookie_len;
ret = hex2bin(fa_cookie->cookie, buf, cookie_len);
if (ret)
goto free_fa_cookie;
kfree(buf);
spin_lock(&nsim_dev->fa_cookie_lock);
kfree(nsim_dev->fa_cookie);
nsim_dev->fa_cookie = fa_cookie;
spin_unlock(&nsim_dev->fa_cookie_lock);
return count;
free_fa_cookie:
kfree(fa_cookie);
free_buf:
kfree(buf);
return ret;
}
static const struct file_operations nsim_dev_trap_fa_cookie_fops = {
.open = simple_open,
.read = nsim_dev_trap_fa_cookie_read,
.write = nsim_dev_trap_fa_cookie_write,
.llseek = generic_file_llseek,
};
static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev) static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
{ {
char dev_ddir_name[sizeof(DRV_NAME) + 10]; char dev_ddir_name[sizeof(DRV_NAME) + 10];
...@@ -97,6 +190,8 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev) ...@@ -97,6 +190,8 @@ static int nsim_dev_debugfs_init(struct nsim_dev *nsim_dev)
&nsim_dev->dont_allow_reload); &nsim_dev->dont_allow_reload);
debugfs_create_bool("fail_reload", 0600, nsim_dev->ddir, debugfs_create_bool("fail_reload", 0600, nsim_dev->ddir,
&nsim_dev->fail_reload); &nsim_dev->fail_reload);
debugfs_create_file("trap_flow_action_cookie", 0600, nsim_dev->ddir,
nsim_dev, &nsim_dev_trap_fa_cookie_fops);
return 0; return 0;
} }
...@@ -288,6 +383,10 @@ enum { ...@@ -288,6 +383,10 @@ enum {
DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \ DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \
DEVLINK_TRAP_GROUP_GENERIC(_group_id), \ DEVLINK_TRAP_GROUP_GENERIC(_group_id), \
NSIM_TRAP_METADATA) NSIM_TRAP_METADATA)
#define NSIM_TRAP_DROP_EXT(_id, _group_id, _metadata) \
DEVLINK_TRAP_GENERIC(DROP, DROP, _id, \
DEVLINK_TRAP_GROUP_GENERIC(_group_id), \
NSIM_TRAP_METADATA | (_metadata))
#define NSIM_TRAP_EXCEPTION(_id, _group_id) \ #define NSIM_TRAP_EXCEPTION(_id, _group_id) \
DEVLINK_TRAP_GENERIC(EXCEPTION, TRAP, _id, \ DEVLINK_TRAP_GENERIC(EXCEPTION, TRAP, _id, \
DEVLINK_TRAP_GROUP_GENERIC(_group_id), \ DEVLINK_TRAP_GROUP_GENERIC(_group_id), \
...@@ -309,6 +408,10 @@ static const struct devlink_trap nsim_traps_arr[] = { ...@@ -309,6 +408,10 @@ static const struct devlink_trap nsim_traps_arr[] = {
NSIM_TRAP_DROP(BLACKHOLE_ROUTE, L3_DROPS), NSIM_TRAP_DROP(BLACKHOLE_ROUTE, L3_DROPS),
NSIM_TRAP_EXCEPTION(TTL_ERROR, L3_DROPS), NSIM_TRAP_EXCEPTION(TTL_ERROR, L3_DROPS),
NSIM_TRAP_DROP(TAIL_DROP, BUFFER_DROPS), NSIM_TRAP_DROP(TAIL_DROP, BUFFER_DROPS),
NSIM_TRAP_DROP_EXT(INGRESS_FLOW_ACTION_DROP, ACL_DROPS,
DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE),
NSIM_TRAP_DROP_EXT(EGRESS_FLOW_ACTION_DROP, ACL_DROPS,
DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE),
}; };
#define NSIM_TRAP_L4_DATA_LEN 100 #define NSIM_TRAP_L4_DATA_LEN 100
...@@ -366,8 +469,13 @@ static void nsim_dev_trap_report(struct nsim_dev_port *nsim_dev_port) ...@@ -366,8 +469,13 @@ static void nsim_dev_trap_report(struct nsim_dev_port *nsim_dev_port)
spin_lock(&nsim_trap_data->trap_lock); spin_lock(&nsim_trap_data->trap_lock);
for (i = 0; i < ARRAY_SIZE(nsim_traps_arr); i++) { for (i = 0; i < ARRAY_SIZE(nsim_traps_arr); i++) {
struct flow_action_cookie *fa_cookie = NULL;
struct nsim_trap_item *nsim_trap_item; struct nsim_trap_item *nsim_trap_item;
struct sk_buff *skb; struct sk_buff *skb;
bool has_fa_cookie;
has_fa_cookie = nsim_traps_arr[i].metadata_cap &
DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE;
nsim_trap_item = &nsim_trap_data->trap_items_arr[i]; nsim_trap_item = &nsim_trap_data->trap_items_arr[i];
if (nsim_trap_item->action == DEVLINK_TRAP_ACTION_DROP) if (nsim_trap_item->action == DEVLINK_TRAP_ACTION_DROP)
...@@ -383,10 +491,12 @@ static void nsim_dev_trap_report(struct nsim_dev_port *nsim_dev_port) ...@@ -383,10 +491,12 @@ static void nsim_dev_trap_report(struct nsim_dev_port *nsim_dev_port)
* softIRQs to prevent lockdep from complaining about * softIRQs to prevent lockdep from complaining about
* "incosistent lock state". * "incosistent lock state".
*/ */
local_bh_disable();
spin_lock_bh(&nsim_dev->fa_cookie_lock);
fa_cookie = has_fa_cookie ? nsim_dev->fa_cookie : NULL;
devlink_trap_report(devlink, skb, nsim_trap_item->trap_ctx, devlink_trap_report(devlink, skb, nsim_trap_item->trap_ctx,
&nsim_dev_port->devlink_port); &nsim_dev_port->devlink_port, fa_cookie);
local_bh_enable(); spin_unlock_bh(&nsim_dev->fa_cookie_lock);
consume_skb(skb); consume_skb(skb);
} }
spin_unlock(&nsim_trap_data->trap_lock); spin_unlock(&nsim_trap_data->trap_lock);
...@@ -780,6 +890,7 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev) ...@@ -780,6 +890,7 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev)
nsim_dev->fw_update_status = true; nsim_dev->fw_update_status = true;
nsim_dev->max_macs = NSIM_DEV_MAX_MACS_DEFAULT; nsim_dev->max_macs = NSIM_DEV_MAX_MACS_DEFAULT;
nsim_dev->test1 = NSIM_DEV_TEST1_DEFAULT; nsim_dev->test1 = NSIM_DEV_TEST1_DEFAULT;
spin_lock_init(&nsim_dev->fa_cookie_lock);
dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev); dev_set_drvdata(&nsim_bus_dev->dev, nsim_dev);
......
...@@ -178,6 +178,8 @@ struct nsim_dev { ...@@ -178,6 +178,8 @@ struct nsim_dev {
bool fail_reload; bool fail_reload;
struct devlink_region *dummy_region; struct devlink_region *dummy_region;
struct nsim_dev_health health; struct nsim_dev_health health;
struct flow_action_cookie *fa_cookie;
spinlock_t fa_cookie_lock; /* protects fa_cookie */
}; };
static inline struct net *nsim_dev_net(struct nsim_dev *nsim_dev) static inline struct net *nsim_dev_net(struct nsim_dev *nsim_dev)
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/flow_offload.h>
#include <uapi/linux/devlink.h> #include <uapi/linux/devlink.h>
struct devlink_ops; struct devlink_ops;
...@@ -541,6 +542,7 @@ struct devlink_trap_group { ...@@ -541,6 +542,7 @@ struct devlink_trap_group {
}; };
#define DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT BIT(0) #define DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT BIT(0)
#define DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE BIT(1)
/** /**
* struct devlink_trap - Immutable packet trap attributes. * struct devlink_trap - Immutable packet trap attributes.
...@@ -1049,9 +1051,9 @@ int devlink_traps_register(struct devlink *devlink, ...@@ -1049,9 +1051,9 @@ int devlink_traps_register(struct devlink *devlink,
void devlink_traps_unregister(struct devlink *devlink, void devlink_traps_unregister(struct devlink *devlink,
const struct devlink_trap *traps, const struct devlink_trap *traps,
size_t traps_count); size_t traps_count);
void devlink_trap_report(struct devlink *devlink, void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb,
struct sk_buff *skb, void *trap_ctx, void *trap_ctx, struct devlink_port *in_devlink_port,
struct devlink_port *in_devlink_port); const struct flow_action_cookie *fa_cookie);
void *devlink_trap_ctx_priv(void *trap_ctx); void *devlink_trap_ctx_priv(void *trap_ctx);
#if IS_ENABLED(CONFIG_NET_DEVLINK) #if IS_ENABLED(CONFIG_NET_DEVLINK)
......
...@@ -6,17 +6,20 @@ ...@@ -6,17 +6,20 @@
#include <linux/ktime.h> #include <linux/ktime.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/skbuff.h> #include <linux/skbuff.h>
#include <net/flow_offload.h>
/** /**
* struct net_dm_hw_metadata - Hardware-supplied packet metadata. * struct net_dm_hw_metadata - Hardware-supplied packet metadata.
* @trap_group_name: Hardware trap group name. * @trap_group_name: Hardware trap group name.
* @trap_name: Hardware trap name. * @trap_name: Hardware trap name.
* @input_dev: Input netdevice. * @input_dev: Input netdevice.
* @fa_cookie: Flow action user cookie.
*/ */
struct net_dm_hw_metadata { struct net_dm_hw_metadata {
const char *trap_group_name; const char *trap_group_name;
const char *trap_name; const char *trap_name;
struct net_device *input_dev; struct net_device *input_dev;
const struct flow_action_cookie *fa_cookie;
}; };
#if IS_ENABLED(CONFIG_NET_DROP_MONITOR) #if IS_ENABLED(CONFIG_NET_DROP_MONITOR)
......
...@@ -156,6 +156,16 @@ enum flow_action_mangle_base { ...@@ -156,6 +156,16 @@ enum flow_action_mangle_base {
typedef void (*action_destr)(void *priv); typedef void (*action_destr)(void *priv);
struct flow_action_cookie {
u32 cookie_len;
u8 cookie[];
};
struct flow_action_cookie *flow_action_cookie_create(void *data,
unsigned int len,
gfp_t gfp);
void flow_action_cookie_destroy(struct flow_action_cookie *cookie);
struct flow_action_entry { struct flow_action_entry {
enum flow_action_id id; enum flow_action_id id;
action_destr destructor; action_destr destructor;
...@@ -214,6 +224,7 @@ struct flow_action_entry { ...@@ -214,6 +224,7 @@ struct flow_action_entry {
u8 ttl; u8 ttl;
} mpls_mangle; } mpls_mangle;
}; };
struct flow_action_cookie *cookie; /* user defined action cookie */
}; };
struct flow_action { struct flow_action {
......
...@@ -252,6 +252,8 @@ enum devlink_trap_type { ...@@ -252,6 +252,8 @@ enum devlink_trap_type {
enum { enum {
/* Trap can report input port as metadata */ /* Trap can report input port as metadata */
DEVLINK_ATTR_TRAP_METADATA_TYPE_IN_PORT, DEVLINK_ATTR_TRAP_METADATA_TYPE_IN_PORT,
/* Trap can report flow action cookie as metadata */
DEVLINK_ATTR_TRAP_METADATA_TYPE_FA_COOKIE,
}; };
enum devlink_attr { enum devlink_attr {
......
...@@ -92,6 +92,7 @@ enum net_dm_attr { ...@@ -92,6 +92,7 @@ enum net_dm_attr {
NET_DM_ATTR_HW_TRAP_COUNT, /* u32 */ NET_DM_ATTR_HW_TRAP_COUNT, /* u32 */
NET_DM_ATTR_SW_DROPS, /* flag */ NET_DM_ATTR_SW_DROPS, /* flag */
NET_DM_ATTR_HW_DROPS, /* flag */ NET_DM_ATTR_HW_DROPS, /* flag */
NET_DM_ATTR_FLOW_ACTION_COOKIE, /* binary */
__NET_DM_ATTR_MAX, __NET_DM_ATTR_MAX,
NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1 NET_DM_ATTR_MAX = __NET_DM_ATTR_MAX - 1
......
...@@ -5540,6 +5540,9 @@ static int devlink_trap_metadata_put(struct sk_buff *msg, ...@@ -5540,6 +5540,9 @@ static int devlink_trap_metadata_put(struct sk_buff *msg,
if ((trap->metadata_cap & DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT) && if ((trap->metadata_cap & DEVLINK_TRAP_METADATA_TYPE_F_IN_PORT) &&
nla_put_flag(msg, DEVLINK_ATTR_TRAP_METADATA_TYPE_IN_PORT)) nla_put_flag(msg, DEVLINK_ATTR_TRAP_METADATA_TYPE_IN_PORT))
goto nla_put_failure; goto nla_put_failure;
if ((trap->metadata_cap & DEVLINK_TRAP_METADATA_TYPE_F_FA_COOKIE) &&
nla_put_flag(msg, DEVLINK_ATTR_TRAP_METADATA_TYPE_FA_COOKIE))
goto nla_put_failure;
nla_nest_end(msg, attr); nla_nest_end(msg, attr);
...@@ -8202,12 +8205,14 @@ devlink_trap_stats_update(struct devlink_stats __percpu *trap_stats, ...@@ -8202,12 +8205,14 @@ devlink_trap_stats_update(struct devlink_stats __percpu *trap_stats,
static void static void
devlink_trap_report_metadata_fill(struct net_dm_hw_metadata *hw_metadata, devlink_trap_report_metadata_fill(struct net_dm_hw_metadata *hw_metadata,
const struct devlink_trap_item *trap_item, const struct devlink_trap_item *trap_item,
struct devlink_port *in_devlink_port) struct devlink_port *in_devlink_port,
const struct flow_action_cookie *fa_cookie)
{ {
struct devlink_trap_group_item *group_item = trap_item->group_item; struct devlink_trap_group_item *group_item = trap_item->group_item;
hw_metadata->trap_group_name = group_item->group->name; hw_metadata->trap_group_name = group_item->group->name;
hw_metadata->trap_name = trap_item->trap->name; hw_metadata->trap_name = trap_item->trap->name;
hw_metadata->fa_cookie = fa_cookie;
spin_lock(&in_devlink_port->type_lock); spin_lock(&in_devlink_port->type_lock);
if (in_devlink_port->type == DEVLINK_PORT_TYPE_ETH) if (in_devlink_port->type == DEVLINK_PORT_TYPE_ETH)
...@@ -8221,9 +8226,12 @@ devlink_trap_report_metadata_fill(struct net_dm_hw_metadata *hw_metadata, ...@@ -8221,9 +8226,12 @@ devlink_trap_report_metadata_fill(struct net_dm_hw_metadata *hw_metadata,
* @skb: Trapped packet. * @skb: Trapped packet.
* @trap_ctx: Trap context. * @trap_ctx: Trap context.
* @in_devlink_port: Input devlink port. * @in_devlink_port: Input devlink port.
* @fa_cookie: Flow action cookie. Could be NULL.
*/ */
void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb, void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb,
void *trap_ctx, struct devlink_port *in_devlink_port) void *trap_ctx, struct devlink_port *in_devlink_port,
const struct flow_action_cookie *fa_cookie)
{ {
struct devlink_trap_item *trap_item = trap_ctx; struct devlink_trap_item *trap_item = trap_ctx;
struct net_dm_hw_metadata hw_metadata = {}; struct net_dm_hw_metadata hw_metadata = {};
...@@ -8232,7 +8240,7 @@ void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb, ...@@ -8232,7 +8240,7 @@ void devlink_trap_report(struct devlink *devlink, struct sk_buff *skb,
devlink_trap_stats_update(trap_item->group_item->stats, skb->len); devlink_trap_stats_update(trap_item->group_item->stats, skb->len);
devlink_trap_report_metadata_fill(&hw_metadata, trap_item, devlink_trap_report_metadata_fill(&hw_metadata, trap_item,
in_devlink_port); in_devlink_port, fa_cookie);
net_dm_hw_report(skb, &hw_metadata); net_dm_hw_report(skb, &hw_metadata);
} }
EXPORT_SYMBOL_GPL(devlink_trap_report); EXPORT_SYMBOL_GPL(devlink_trap_report);
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <net/drop_monitor.h> #include <net/drop_monitor.h>
#include <net/genetlink.h> #include <net/genetlink.h>
#include <net/netevent.h> #include <net/netevent.h>
#include <net/flow_offload.h>
#include <trace/events/skb.h> #include <trace/events/skb.h>
#include <trace/events/napi.h> #include <trace/events/napi.h>
...@@ -700,6 +701,13 @@ static void net_dm_packet_work(struct work_struct *work) ...@@ -700,6 +701,13 @@ static void net_dm_packet_work(struct work_struct *work)
net_dm_packet_report(skb); net_dm_packet_report(skb);
} }
static size_t
net_dm_flow_action_cookie_size(const struct net_dm_hw_metadata *hw_metadata)
{
return hw_metadata->fa_cookie ?
nla_total_size(hw_metadata->fa_cookie->cookie_len) : 0;
}
static size_t static size_t
net_dm_hw_packet_report_size(size_t payload_len, net_dm_hw_packet_report_size(size_t payload_len,
const struct net_dm_hw_metadata *hw_metadata) const struct net_dm_hw_metadata *hw_metadata)
...@@ -717,6 +725,8 @@ net_dm_hw_packet_report_size(size_t payload_len, ...@@ -717,6 +725,8 @@ net_dm_hw_packet_report_size(size_t payload_len,
nla_total_size(strlen(hw_metadata->trap_name) + 1) + nla_total_size(strlen(hw_metadata->trap_name) + 1) +
/* NET_DM_ATTR_IN_PORT */ /* NET_DM_ATTR_IN_PORT */
net_dm_in_port_size() + net_dm_in_port_size() +
/* NET_DM_ATTR_FLOW_ACTION_COOKIE */
net_dm_flow_action_cookie_size(hw_metadata) +
/* NET_DM_ATTR_TIMESTAMP */ /* NET_DM_ATTR_TIMESTAMP */
nla_total_size(sizeof(u64)) + nla_total_size(sizeof(u64)) +
/* NET_DM_ATTR_ORIG_LEN */ /* NET_DM_ATTR_ORIG_LEN */
...@@ -762,6 +772,12 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg, ...@@ -762,6 +772,12 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg,
goto nla_put_failure; goto nla_put_failure;
} }
if (hw_metadata->fa_cookie &&
nla_put(msg, NET_DM_ATTR_FLOW_ACTION_COOKIE,
hw_metadata->fa_cookie->cookie_len,
hw_metadata->fa_cookie->cookie))
goto nla_put_failure;
if (nla_put_u64_64bit(msg, NET_DM_ATTR_TIMESTAMP, if (nla_put_u64_64bit(msg, NET_DM_ATTR_TIMESTAMP,
ktime_to_ns(skb->tstamp), NET_DM_ATTR_PAD)) ktime_to_ns(skb->tstamp), NET_DM_ATTR_PAD))
goto nla_put_failure; goto nla_put_failure;
...@@ -794,11 +810,12 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg, ...@@ -794,11 +810,12 @@ static int net_dm_hw_packet_report_fill(struct sk_buff *msg,
static struct net_dm_hw_metadata * static struct net_dm_hw_metadata *
net_dm_hw_metadata_clone(const struct net_dm_hw_metadata *hw_metadata) net_dm_hw_metadata_clone(const struct net_dm_hw_metadata *hw_metadata)
{ {
const struct flow_action_cookie *fa_cookie;
struct net_dm_hw_metadata *n_hw_metadata; struct net_dm_hw_metadata *n_hw_metadata;
const char *trap_group_name; const char *trap_group_name;
const char *trap_name; const char *trap_name;
n_hw_metadata = kmalloc(sizeof(*hw_metadata), GFP_ATOMIC); n_hw_metadata = kzalloc(sizeof(*hw_metadata), GFP_ATOMIC);
if (!n_hw_metadata) if (!n_hw_metadata)
return NULL; return NULL;
...@@ -812,12 +829,25 @@ net_dm_hw_metadata_clone(const struct net_dm_hw_metadata *hw_metadata) ...@@ -812,12 +829,25 @@ net_dm_hw_metadata_clone(const struct net_dm_hw_metadata *hw_metadata)
goto free_trap_group; goto free_trap_group;
n_hw_metadata->trap_name = trap_name; n_hw_metadata->trap_name = trap_name;
if (hw_metadata->fa_cookie) {
size_t cookie_size = sizeof(*fa_cookie) +
hw_metadata->fa_cookie->cookie_len;
fa_cookie = kmemdup(hw_metadata->fa_cookie, cookie_size,
GFP_ATOMIC);
if (!fa_cookie)
goto free_trap_name;
n_hw_metadata->fa_cookie = fa_cookie;
}
n_hw_metadata->input_dev = hw_metadata->input_dev; n_hw_metadata->input_dev = hw_metadata->input_dev;
if (n_hw_metadata->input_dev) if (n_hw_metadata->input_dev)
dev_hold(n_hw_metadata->input_dev); dev_hold(n_hw_metadata->input_dev);
return n_hw_metadata; return n_hw_metadata;
free_trap_name:
kfree(trap_name);
free_trap_group: free_trap_group:
kfree(trap_group_name); kfree(trap_group_name);
free_hw_metadata: free_hw_metadata:
...@@ -830,6 +860,7 @@ net_dm_hw_metadata_free(const struct net_dm_hw_metadata *hw_metadata) ...@@ -830,6 +860,7 @@ net_dm_hw_metadata_free(const struct net_dm_hw_metadata *hw_metadata)
{ {
if (hw_metadata->input_dev) if (hw_metadata->input_dev)
dev_put(hw_metadata->input_dev); dev_put(hw_metadata->input_dev);
kfree(hw_metadata->fa_cookie);
kfree(hw_metadata->trap_name); kfree(hw_metadata->trap_name);
kfree(hw_metadata->trap_group_name); kfree(hw_metadata->trap_group_name);
kfree(hw_metadata); kfree(hw_metadata);
......
...@@ -167,6 +167,27 @@ void flow_rule_match_enc_opts(const struct flow_rule *rule, ...@@ -167,6 +167,27 @@ void flow_rule_match_enc_opts(const struct flow_rule *rule,
} }
EXPORT_SYMBOL(flow_rule_match_enc_opts); EXPORT_SYMBOL(flow_rule_match_enc_opts);
struct flow_action_cookie *flow_action_cookie_create(void *data,
unsigned int len,
gfp_t gfp)
{
struct flow_action_cookie *cookie;
cookie = kmalloc(sizeof(*cookie) + len, gfp);
if (!cookie)
return NULL;
cookie->cookie_len = len;
memcpy(cookie->cookie, data, len);
return cookie;
}
EXPORT_SYMBOL(flow_action_cookie_create);
void flow_action_cookie_destroy(struct flow_action_cookie *cookie)
{
kfree(cookie);
}
EXPORT_SYMBOL(flow_action_cookie_destroy);
struct flow_block_cb *flow_block_cb_alloc(flow_setup_cb_t *cb, struct flow_block_cb *flow_block_cb_alloc(flow_setup_cb_t *cb,
void *cb_ident, void *cb_priv, void *cb_ident, void *cb_priv,
void (*release)(void *cb_priv)) void (*release)(void *cb_priv))
......
...@@ -3382,14 +3382,40 @@ int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp, ...@@ -3382,14 +3382,40 @@ int tc_setup_cb_reoffload(struct tcf_block *block, struct tcf_proto *tp,
} }
EXPORT_SYMBOL(tc_setup_cb_reoffload); EXPORT_SYMBOL(tc_setup_cb_reoffload);
static int tcf_act_get_cookie(struct flow_action_entry *entry,
const struct tc_action *act)
{
struct tc_cookie *cookie;
int err = 0;
rcu_read_lock();
cookie = rcu_dereference(act->act_cookie);
if (cookie) {
entry->cookie = flow_action_cookie_create(cookie->data,
cookie->len,
GFP_ATOMIC);
if (!entry->cookie)
err = -ENOMEM;
}
rcu_read_unlock();
return err;
}
static void tcf_act_put_cookie(struct flow_action_entry *entry)
{
flow_action_cookie_destroy(entry->cookie);
}
void tc_cleanup_flow_action(struct flow_action *flow_action) void tc_cleanup_flow_action(struct flow_action *flow_action)
{ {
struct flow_action_entry *entry; struct flow_action_entry *entry;
int i; int i;
flow_action_for_each(i, entry, flow_action) flow_action_for_each(i, entry, flow_action) {
tcf_act_put_cookie(entry);
if (entry->destructor) if (entry->destructor)
entry->destructor(entry->destructor_priv); entry->destructor(entry->destructor_priv);
}
} }
EXPORT_SYMBOL(tc_cleanup_flow_action); EXPORT_SYMBOL(tc_cleanup_flow_action);
...@@ -3447,6 +3473,9 @@ int tc_setup_flow_action(struct flow_action *flow_action, ...@@ -3447,6 +3473,9 @@ int tc_setup_flow_action(struct flow_action *flow_action,
entry = &flow_action->entries[j]; entry = &flow_action->entries[j];
spin_lock_bh(&act->tcfa_lock); spin_lock_bh(&act->tcfa_lock);
err = tcf_act_get_cookie(entry, act);
if (err)
goto err_out_locked;
if (is_tcf_gact_ok(act)) { if (is_tcf_gact_ok(act)) {
entry->id = FLOW_ACTION_ACCEPT; entry->id = FLOW_ACTION_ACCEPT;
} else if (is_tcf_gact_shot(act)) { } else if (is_tcf_gact_shot(act)) {
......
...@@ -103,6 +103,11 @@ trap_metadata_test() ...@@ -103,6 +103,11 @@ trap_metadata_test()
for trap_name in $(devlink_traps_get); do for trap_name in $(devlink_traps_get); do
devlink_trap_metadata_test $trap_name "input_port" devlink_trap_metadata_test $trap_name "input_port"
check_err $? "Input port not reported as metadata of trap $trap_name" check_err $? "Input port not reported as metadata of trap $trap_name"
if [ $trap_name == "ingress_flow_action_drop" ] ||
[ $trap_name == "egress_flow_action_drop" ]; then
devlink_trap_metadata_test $trap_name "flow_action_cookie"
check_err $? "Flow action cookie not reported as metadata of trap $trap_name"
fi
done done
log_test "Trap metadata" log_test "Trap metadata"
......
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