Skip to content

Commit 103b7c2

Browse files
jahurleydavem330
authored andcommitted
nfp: flower: ensure ip protocol is specified for L4 matches
Flower rules on the NFP firmware are able to match on an IP protocol field. When parsing rules in the driver, unknown IP protocols are only rejected when further matches are to be carried out on layer 4 fields, as the firmware will not be able to extract such fields from packets. L4 protocol dissectors such as FLOW_DISSECTOR_KEY_PORTS are only parsed if an IP protocol is specified. This leaves a loophole whereby a rule that attempts to match on transport layer information such as port numbers but does not explicitly give an IP protocol type can be incorrectly offloaded (in this case with wildcard port numbers matches). Fix this by rejecting the offload of flows that attempt to match on L4 information, not only when matching on an unknown IP protocol type, but also when the protocol is wildcarded. Fixes: 2a04784 ("nfp: flower: check L4 matches on unknown IP protocols") Signed-off-by: John Hurley <john.hurley@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fd262a6 commit 103b7c2

File tree

1 file changed

+6
-9
lines changed
  • drivers/net/ethernet/netronome/nfp/flower

1 file changed

+6
-9
lines changed

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -386,18 +386,15 @@ nfp_flower_calculate_key_layers(struct nfp_app *app,
386386
key_layer |= NFP_FLOWER_LAYER_TP;
387387
key_size += sizeof(struct nfp_flower_tp_ports);
388388
break;
389-
default:
390-
/* Other ip proto - we need check the masks for the
391-
* remainder of the key to ensure we can offload.
392-
*/
393-
if (nfp_flower_check_higher_than_l3(flow)) {
394-
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: unknown IP protocol with L4 matches not supported");
395-
return -EOPNOTSUPP;
396-
}
397-
break;
398389
}
399390
}
400391

392+
if (!(key_layer & NFP_FLOWER_LAYER_TP) &&
393+
nfp_flower_check_higher_than_l3(flow)) {
394+
NL_SET_ERR_MSG_MOD(extack, "unsupported offload: cannot match on L4 information without specified IP protocol type");
395+
return -EOPNOTSUPP;
396+
}
397+
401398
if (flow_rule_match_key(rule, FLOW_DISSECTOR_KEY_TCP)) {
402399
struct flow_match_tcp tcp;
403400
u32 tcp_flags;

0 commit comments

Comments
 (0)