Skip to content

Commit 0115552

Browse files
jahurleydavem330
authored andcommitted
nfp: remove false positive offloads in flower vxlan
Pass information to the match offload on whether or not the repr is the ingress or egress dev. Only accept tunnel matches if repr is the egress dev. This means rules such as the following are successfully offloaded: tc .. add dev vxlan0 .. enc_dst_port 4789 .. action redirect dev nfp_p0 While rules such as the following are rejected: tc .. add dev nfp_p0 .. enc_dst_port 4789 .. action redirect dev vxlan0 Also reject non tunnel flows that are offloaded to an egress dev. Non tunnel matches assume that the offload dev is the ingress port and offload a match accordingly. Fixes: 611aec1 ("nfp: compile flower vxlan tunnel metadata match fields") Signed-off-by: John Hurley <[email protected]> Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a24d4f commit 0115552

File tree

1 file changed

+25
-7
lines changed
  • drivers/net/ethernet/netronome/nfp/flower

1 file changed

+25
-7
lines changed

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ static bool nfp_flower_check_higher_than_mac(struct tc_cls_flower_offload *f)
131131

132132
static int
133133
nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
134-
struct tc_cls_flower_offload *flow)
134+
struct tc_cls_flower_offload *flow,
135+
bool egress)
135136
{
136137
struct flow_dissector_key_basic *mask_basic = NULL;
137138
struct flow_dissector_key_basic *key_basic = NULL;
@@ -167,6 +168,9 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
167168
skb_flow_dissector_target(flow->dissector,
168169
FLOW_DISSECTOR_KEY_ENC_CONTROL,
169170
flow->key);
171+
if (!egress)
172+
return -EOPNOTSUPP;
173+
170174
if (mask_enc_ctl->addr_type != 0xffff ||
171175
enc_ctl->addr_type != FLOW_DISSECTOR_KEY_IPV4_ADDRS)
172176
return -EOPNOTSUPP;
@@ -194,6 +198,9 @@ nfp_flower_calculate_key_layers(struct nfp_fl_key_ls *ret_key_ls,
194198

195199
key_layer |= NFP_FLOWER_LAYER_VXLAN;
196200
key_size += sizeof(struct nfp_flower_vxlan);
201+
} else if (egress) {
202+
/* Reject non tunnel matches offloaded to egress repr. */
203+
return -EOPNOTSUPP;
197204
}
198205

199206
if (dissector_uses_key(flow->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
@@ -315,7 +322,7 @@ nfp_flower_allocate_new(struct nfp_fl_key_ls *key_layer)
315322
*/
316323
static int
317324
nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev,
318-
struct tc_cls_flower_offload *flow)
325+
struct tc_cls_flower_offload *flow, bool egress)
319326
{
320327
struct nfp_flower_priv *priv = app->priv;
321328
struct nfp_fl_payload *flow_pay;
@@ -326,7 +333,7 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev,
326333
if (!key_layer)
327334
return -ENOMEM;
328335

329-
err = nfp_flower_calculate_key_layers(key_layer, flow);
336+
err = nfp_flower_calculate_key_layers(key_layer, flow, egress);
330337
if (err)
331338
goto err_free_key_ls;
332339

@@ -447,15 +454,15 @@ nfp_flower_get_stats(struct nfp_app *app, struct tc_cls_flower_offload *flow)
447454

448455
static int
449456
nfp_flower_repr_offload(struct nfp_app *app, struct net_device *netdev,
450-
struct tc_cls_flower_offload *flower)
457+
struct tc_cls_flower_offload *flower, bool egress)
451458
{
452459
if (!eth_proto_is_802_3(flower->common.protocol) ||
453460
flower->common.chain_index)
454461
return -EOPNOTSUPP;
455462

456463
switch (flower->command) {
457464
case TC_CLSFLOWER_REPLACE:
458-
return nfp_flower_add_offload(app, netdev, flower);
465+
return nfp_flower_add_offload(app, netdev, flower, egress);
459466
case TC_CLSFLOWER_DESTROY:
460467
return nfp_flower_del_offload(app, netdev, flower);
461468
case TC_CLSFLOWER_STATS:
@@ -468,7 +475,18 @@ nfp_flower_repr_offload(struct nfp_app *app, struct net_device *netdev,
468475
int nfp_flower_setup_tc_egress_cb(enum tc_setup_type type, void *type_data,
469476
void *cb_priv)
470477
{
471-
return -EINVAL;
478+
struct nfp_repr *repr = cb_priv;
479+
480+
if (!tc_can_offload(repr->netdev))
481+
return -EOPNOTSUPP;
482+
483+
switch (type) {
484+
case TC_SETUP_CLSFLOWER:
485+
return nfp_flower_repr_offload(repr->app, repr->netdev,
486+
type_data, true);
487+
default:
488+
return -EOPNOTSUPP;
489+
}
472490
}
473491

474492
static int nfp_flower_setup_tc_block_cb(enum tc_setup_type type,
@@ -482,7 +500,7 @@ static int nfp_flower_setup_tc_block_cb(enum tc_setup_type type,
482500
switch (type) {
483501
case TC_SETUP_CLSFLOWER:
484502
return nfp_flower_repr_offload(repr->app, repr->netdev,
485-
type_data);
503+
type_data, false);
486504
default:
487505
return -EOPNOTSUPP;
488506
}

0 commit comments

Comments
 (0)