@@ -212,11 +212,39 @@ static int mlxsw_sp_flower_parse_tcp(struct mlxsw_sp *mlxsw_sp,
212
212
return 0 ;
213
213
}
214
214
215
+ static int mlxsw_sp_flower_parse_ip (struct mlxsw_sp * mlxsw_sp ,
216
+ struct mlxsw_sp_acl_rule_info * rulei ,
217
+ struct tc_cls_flower_offload * f ,
218
+ u16 n_proto )
219
+ {
220
+ struct flow_dissector_key_ip * key , * mask ;
221
+
222
+ if (!dissector_uses_key (f -> dissector , FLOW_DISSECTOR_KEY_IP ))
223
+ return 0 ;
224
+
225
+ if (n_proto != ETH_P_IP && n_proto != ETH_P_IPV6 ) {
226
+ dev_err (mlxsw_sp -> bus_info -> dev , "IP keys supported only for IPv4/6\n" );
227
+ return - EINVAL ;
228
+ }
229
+
230
+ key = skb_flow_dissector_target (f -> dissector ,
231
+ FLOW_DISSECTOR_KEY_IP ,
232
+ f -> key );
233
+ mask = skb_flow_dissector_target (f -> dissector ,
234
+ FLOW_DISSECTOR_KEY_IP ,
235
+ f -> mask );
236
+ mlxsw_sp_acl_rulei_keymask_u32 (rulei , MLXSW_AFK_ELEMENT_IP_TTL_ ,
237
+ key -> ttl , mask -> ttl );
238
+ return 0 ;
239
+ }
240
+
215
241
static int mlxsw_sp_flower_parse (struct mlxsw_sp * mlxsw_sp ,
216
242
struct net_device * dev ,
217
243
struct mlxsw_sp_acl_rule_info * rulei ,
218
244
struct tc_cls_flower_offload * f )
219
245
{
246
+ u16 n_proto_mask = 0 ;
247
+ u16 n_proto_key = 0 ;
220
248
u16 addr_type = 0 ;
221
249
u8 ip_proto = 0 ;
222
250
int err ;
@@ -229,6 +257,7 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,
229
257
BIT (FLOW_DISSECTOR_KEY_IPV6_ADDRS ) |
230
258
BIT (FLOW_DISSECTOR_KEY_PORTS ) |
231
259
BIT (FLOW_DISSECTOR_KEY_TCP ) |
260
+ BIT (FLOW_DISSECTOR_KEY_IP ) |
232
261
BIT (FLOW_DISSECTOR_KEY_VLAN ))) {
233
262
dev_err (mlxsw_sp -> bus_info -> dev , "Unsupported key\n" );
234
263
return - EOPNOTSUPP ;
@@ -253,8 +282,8 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,
253
282
skb_flow_dissector_target (f -> dissector ,
254
283
FLOW_DISSECTOR_KEY_BASIC ,
255
284
f -> mask );
256
- u16 n_proto_key = ntohs (key -> n_proto );
257
- u16 n_proto_mask = ntohs (mask -> n_proto );
285
+ n_proto_key = ntohs (key -> n_proto );
286
+ n_proto_mask = ntohs (mask -> n_proto );
258
287
259
288
if (n_proto_key == ETH_P_ALL ) {
260
289
n_proto_key = 0 ;
@@ -324,6 +353,10 @@ static int mlxsw_sp_flower_parse(struct mlxsw_sp *mlxsw_sp,
324
353
if (err )
325
354
return err ;
326
355
356
+ err = mlxsw_sp_flower_parse_ip (mlxsw_sp , rulei , f , n_proto_key & n_proto_mask );
357
+ if (err )
358
+ return err ;
359
+
327
360
return mlxsw_sp_flower_parse_actions (mlxsw_sp , dev , rulei , f -> exts );
328
361
}
329
362
0 commit comments