@@ -1206,7 +1206,6 @@ mlxsw_sp_ipip_entry_get(struct mlxsw_sp *mlxsw_sp,
1206
1206
{
1207
1207
u32 ul_tb_id = mlxsw_sp_ipip_dev_ul_tb_id (ol_dev );
1208
1208
struct mlxsw_sp_router * router = mlxsw_sp -> router ;
1209
- struct mlxsw_sp_fib_entry * decap_fib_entry ;
1210
1209
struct mlxsw_sp_ipip_entry * ipip_entry ;
1211
1210
enum mlxsw_sp_l3proto ul_proto ;
1212
1211
union mlxsw_sp_l3addr saddr ;
@@ -1231,11 +1230,6 @@ mlxsw_sp_ipip_entry_get(struct mlxsw_sp *mlxsw_sp,
1231
1230
if (IS_ERR (ipip_entry ))
1232
1231
return ipip_entry ;
1233
1232
1234
- decap_fib_entry = mlxsw_sp_ipip_entry_find_decap (mlxsw_sp , ipip_entry );
1235
- if (decap_fib_entry )
1236
- mlxsw_sp_ipip_entry_promote_decap (mlxsw_sp , ipip_entry ,
1237
- decap_fib_entry );
1238
-
1239
1233
list_add_tail (& ipip_entry -> ipip_list_node ,
1240
1234
& mlxsw_sp -> router -> ipip_list );
1241
1235
@@ -1250,8 +1244,6 @@ mlxsw_sp_ipip_entry_put(struct mlxsw_sp *mlxsw_sp,
1250
1244
{
1251
1245
if (-- ipip_entry -> ref_count == 0 ) {
1252
1246
list_del (& ipip_entry -> ipip_list_node );
1253
- if (ipip_entry -> decap_fib_entry )
1254
- mlxsw_sp_ipip_entry_demote_decap (mlxsw_sp , ipip_entry );
1255
1247
mlxsw_sp_ipip_entry_destroy (ipip_entry );
1256
1248
}
1257
1249
}
@@ -1314,6 +1306,103 @@ static bool mlxsw_sp_netdev_ipip_type(const struct mlxsw_sp *mlxsw_sp,
1314
1306
return false;
1315
1307
}
1316
1308
1309
+ bool mlxsw_sp_netdev_is_ipip (const struct mlxsw_sp * mlxsw_sp ,
1310
+ const struct net_device * dev )
1311
+ {
1312
+ return mlxsw_sp_netdev_ipip_type (mlxsw_sp , dev , NULL );
1313
+ }
1314
+
1315
+ static struct mlxsw_sp_ipip_entry *
1316
+ mlxsw_sp_ipip_entry_find_by_ol_dev (struct mlxsw_sp * mlxsw_sp ,
1317
+ const struct net_device * ol_dev )
1318
+ {
1319
+ struct mlxsw_sp_ipip_entry * ipip_entry ;
1320
+
1321
+ list_for_each_entry (ipip_entry , & mlxsw_sp -> router -> ipip_list ,
1322
+ ipip_list_node )
1323
+ if (ipip_entry -> ol_dev == ol_dev )
1324
+ return ipip_entry ;
1325
+
1326
+ return NULL ;
1327
+ }
1328
+
1329
+ static int mlxsw_sp_netdevice_ipip_reg_event (struct mlxsw_sp * mlxsw_sp ,
1330
+ struct net_device * ol_dev )
1331
+ {
1332
+ struct mlxsw_sp_router * router = mlxsw_sp -> router ;
1333
+ struct mlxsw_sp_ipip_entry * ipip_entry ;
1334
+ enum mlxsw_sp_ipip_type ipipt ;
1335
+
1336
+ mlxsw_sp_netdev_ipip_type (mlxsw_sp , ol_dev , & ipipt );
1337
+ if (router -> ipip_ops_arr [ipipt ]-> can_offload (mlxsw_sp , ol_dev ,
1338
+ MLXSW_SP_L3_PROTO_IPV4 ) ||
1339
+ router -> ipip_ops_arr [ipipt ]-> can_offload (mlxsw_sp , ol_dev ,
1340
+ MLXSW_SP_L3_PROTO_IPV6 )) {
1341
+ ipip_entry = mlxsw_sp_ipip_entry_get (mlxsw_sp , ipipt , ol_dev );
1342
+ if (IS_ERR (ipip_entry ))
1343
+ return PTR_ERR (ipip_entry );
1344
+ }
1345
+
1346
+ return 0 ;
1347
+ }
1348
+
1349
+ static void mlxsw_sp_netdevice_ipip_unreg_event (struct mlxsw_sp * mlxsw_sp ,
1350
+ struct net_device * ol_dev )
1351
+ {
1352
+ struct mlxsw_sp_ipip_entry * ipip_entry ;
1353
+
1354
+ ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev (mlxsw_sp , ol_dev );
1355
+ if (ipip_entry )
1356
+ mlxsw_sp_ipip_entry_put (mlxsw_sp , ipip_entry );
1357
+ }
1358
+
1359
+ static int mlxsw_sp_netdevice_ipip_up_event (struct mlxsw_sp * mlxsw_sp ,
1360
+ struct net_device * ol_dev )
1361
+ {
1362
+ struct mlxsw_sp_fib_entry * decap_fib_entry ;
1363
+ struct mlxsw_sp_ipip_entry * ipip_entry ;
1364
+
1365
+ ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev (mlxsw_sp , ol_dev );
1366
+ if (ipip_entry ) {
1367
+ decap_fib_entry = mlxsw_sp_ipip_entry_find_decap (mlxsw_sp ,
1368
+ ipip_entry );
1369
+ if (decap_fib_entry )
1370
+ mlxsw_sp_ipip_entry_promote_decap (mlxsw_sp , ipip_entry ,
1371
+ decap_fib_entry );
1372
+ }
1373
+
1374
+ return 0 ;
1375
+ }
1376
+
1377
+ static void mlxsw_sp_netdevice_ipip_down_event (struct mlxsw_sp * mlxsw_sp ,
1378
+ struct net_device * ol_dev )
1379
+ {
1380
+ struct mlxsw_sp_ipip_entry * ipip_entry ;
1381
+
1382
+ ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev (mlxsw_sp , ol_dev );
1383
+ if (ipip_entry && ipip_entry -> decap_fib_entry )
1384
+ mlxsw_sp_ipip_entry_demote_decap (mlxsw_sp , ipip_entry );
1385
+ }
1386
+
1387
+ int mlxsw_sp_netdevice_ipip_event (struct mlxsw_sp * mlxsw_sp ,
1388
+ struct net_device * ol_dev ,
1389
+ unsigned long event )
1390
+ {
1391
+ switch (event ) {
1392
+ case NETDEV_REGISTER :
1393
+ return mlxsw_sp_netdevice_ipip_reg_event (mlxsw_sp , ol_dev );
1394
+ case NETDEV_UNREGISTER :
1395
+ mlxsw_sp_netdevice_ipip_unreg_event (mlxsw_sp , ol_dev );
1396
+ return 0 ;
1397
+ case NETDEV_UP :
1398
+ return mlxsw_sp_netdevice_ipip_up_event (mlxsw_sp , ol_dev );
1399
+ case NETDEV_DOWN :
1400
+ mlxsw_sp_netdevice_ipip_down_event (mlxsw_sp , ol_dev );
1401
+ return 0 ;
1402
+ }
1403
+ return 0 ;
1404
+ }
1405
+
1317
1406
struct mlxsw_sp_neigh_key {
1318
1407
struct neighbour * n ;
1319
1408
};
0 commit comments