Skip to content

Commit 86cb13e

Browse files
idoschdavem330
authored andcommitted
mlxsw: spectrum: Fix compilation error when CLS_ACT isn't set
When CONFIG_NET_CLS_ACT isn't set 'struct tcf_exts' has no member named 'actions' and we therefore must not access it. Otherwise compilation fails. Fix this by introducing a new macro similar to tc_no_actions(), which always returns 'false' if CONFIG_NET_CLS_ACT isn't set. Fixes: 763b4b7 ("mlxsw: spectrum: Add support in matchall mirror TC offloading") Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3568bdf commit 86cb13e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

drivers/net/ethernet/mellanox/mlxsw/spectrum.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,23 +1148,22 @@ static int mlxsw_sp_port_add_cls_matchall(struct mlxsw_sp_port *mlxsw_sp_port,
11481148
struct tc_cls_matchall_offload *cls,
11491149
bool ingress)
11501150
{
1151-
struct tcf_exts *exts = cls->exts;
11521151
const struct tc_action *a;
11531152
int err;
11541153

1155-
if (!list_is_singular(&exts->actions)) {
1154+
if (!tc_single_action(cls->exts)) {
11561155
netdev_err(mlxsw_sp_port->dev, "only singular actions are supported\n");
11571156
return -ENOTSUPP;
11581157
}
11591158

1160-
a = list_first_entry(&exts->actions, struct tc_action, list);
1161-
if (is_tcf_mirred_mirror(a) && protocol == htons(ETH_P_ALL)) {
1159+
tc_for_each_action(a, cls->exts) {
1160+
if (!is_tcf_mirred_mirror(a) || protocol != htons(ETH_P_ALL))
1161+
return -ENOTSUPP;
1162+
11621163
err = mlxsw_sp_port_add_cls_matchall_mirror(mlxsw_sp_port, cls,
11631164
a, ingress);
11641165
if (err)
11651166
return err;
1166-
} else {
1167-
return -ENOTSUPP;
11681167
}
11691168

11701169
return 0;

include/net/act_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ int tcf_action_copy_stats(struct sk_buff *, struct tc_action *, int);
192192
#define tc_for_each_action(_a, _exts) \
193193
list_for_each_entry(a, &(_exts)->actions, list)
194194

195+
#define tc_single_action(_exts) \
196+
(list_is_singular(&(_exts)->actions))
197+
195198
static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes,
196199
u64 packets, u64 lastuse)
197200
{
@@ -205,6 +208,7 @@ static inline void tcf_action_stats_update(struct tc_action *a, u64 bytes,
205208

206209
#define tc_no_actions(_exts) true
207210
#define tc_for_each_action(_a, _exts) while ((void)(_a), 0)
211+
#define tc_single_action(_exts) false
208212
#define tcf_action_stats_update(a, bytes, packets, lastuse)
209213

210214
#endif /* CONFIG_NET_CLS_ACT */

0 commit comments

Comments
 (0)