@@ -1411,6 +1411,95 @@ static int restore_one_macvlan(struct ns_id *ns, struct net_link *link, int nlsk
1411
1411
return ret ;
1412
1412
}
1413
1413
1414
+ static int sit_link_info (struct ns_id * ns , struct net_link * link , struct newlink_req * req )
1415
+ {
1416
+ struct rtattr * sit_data ;
1417
+ NetDeviceEntry * nde = link -> nde ;
1418
+ SitEntry * se = nde -> sit ;
1419
+
1420
+ if (!se ) {
1421
+ pr_err ("Missing sit entry %d\n" , nde -> ifindex );
1422
+ return -1 ;
1423
+ }
1424
+
1425
+ addattr_l (& req -> h , sizeof (* req ), IFLA_INFO_KIND , "sit" , 3 );
1426
+ sit_data = NLMSG_TAIL (& req -> h );
1427
+ addattr_l (& req -> h , sizeof (* req ), IFLA_INFO_DATA , NULL , 0 );
1428
+
1429
+ #define DECODE_ENTRY (__type , __ifla , __proto ) do { \
1430
+ __type aux; \
1431
+ if (se->has_##__proto) { \
1432
+ aux = se->__proto; \
1433
+ addattr_l(&req->h, sizeof(*req), __ifla, \
1434
+ &aux, sizeof(__type)); \
1435
+ } \
1436
+ } while (0)
1437
+
1438
+ if (se -> n_local ) {
1439
+ if (se -> n_local != 1 ) {
1440
+ pr_err ("Too long local addr for sit\n" );
1441
+ return -1 ;
1442
+ }
1443
+ addattr_l (& req -> h , sizeof (* req ), IFLA_IPTUN_LOCAL , se -> local , sizeof (u32 ));
1444
+ }
1445
+
1446
+ if (se -> n_remote ) {
1447
+ if (se -> n_remote != 1 ) {
1448
+ pr_err ("Too long remote addr for sit\n" );
1449
+ return -1 ;
1450
+ }
1451
+ addattr_l (& req -> h , sizeof (* req ), IFLA_IPTUN_REMOTE , se -> remote , sizeof (u32 ));
1452
+ }
1453
+
1454
+ DECODE_ENTRY (u32 , IFLA_IPTUN_LINK , link );
1455
+ DECODE_ENTRY (u8 , IFLA_IPTUN_TTL , ttl );
1456
+ DECODE_ENTRY (u8 , IFLA_IPTUN_TOS , tos );
1457
+ DECODE_ENTRY (u16 , IFLA_IPTUN_FLAGS , flags );
1458
+ DECODE_ENTRY (u8 , IFLA_IPTUN_PROTO , proto );
1459
+
1460
+ if (se -> has_pmtudisc && se -> pmtudisc ) {
1461
+ u8 aux = 1 ;
1462
+ addattr_l (& req -> h , sizeof (* req ), IFLA_IPTUN_PMTUDISC , & aux , sizeof (u8 ));
1463
+ }
1464
+
1465
+ DECODE_ENTRY (u16 , IFLA_IPTUN_ENCAP_TYPE , encap_type );
1466
+ DECODE_ENTRY (u16 , IFLA_IPTUN_ENCAP_FLAGS , encap_flags );
1467
+ DECODE_ENTRY (u16 , IFLA_IPTUN_ENCAP_SPORT , encap_sport );
1468
+ DECODE_ENTRY (u16 , IFLA_IPTUN_ENCAP_DPORT , encap_dport );
1469
+
1470
+ if (!se -> has_rd_prefixlen ) {
1471
+ u16 aux ;
1472
+
1473
+ if (se -> n_rd_prefix != 4 ) {
1474
+ pr_err ("Bad 6rd prefixlen for sit\n" );
1475
+ return -1 ;
1476
+ }
1477
+
1478
+ aux = se -> rd_prefixlen ;
1479
+ addattr_l (& req -> h , sizeof (* req ), IFLA_IPTUN_6RD_PREFIXLEN , & aux , sizeof (u16 ));
1480
+ addattr_l (& req -> h , sizeof (* req ), IFLA_IPTUN_6RD_PREFIX , se -> rd_prefix , 4 * sizeof (u32 ));
1481
+
1482
+ if (!se -> has_relay_prefixlen )
1483
+ goto skip ;
1484
+
1485
+ if (se -> n_relay_prefix != 1 ) {
1486
+ pr_err ("Bad 6rd relay prefixlen for sit\n" );
1487
+ return -1 ;
1488
+ }
1489
+
1490
+ aux = se -> relay_prefixlen ;
1491
+ addattr_l (& req -> h , sizeof (* req ), IFLA_IPTUN_6RD_RELAY_PREFIXLEN , & aux , sizeof (u16 ));
1492
+ addattr_l (& req -> h , sizeof (* req ), IFLA_IPTUN_6RD_RELAY_PREFIX , se -> relay_prefix , sizeof (u32 ));
1493
+ skip :;
1494
+ }
1495
+
1496
+ #undef DECODE_ENTRY
1497
+
1498
+ sit_data -> rta_len = (void * )NLMSG_TAIL (& req -> h ) - (void * )sit_data ;
1499
+
1500
+ return 0 ;
1501
+ }
1502
+
1414
1503
static int __restore_link (struct ns_id * ns , struct net_link * link , int nlsk )
1415
1504
{
1416
1505
NetDeviceEntry * nde = link -> nde ;
@@ -1431,6 +1520,8 @@ static int __restore_link(struct ns_id *ns, struct net_link *link, int nlsk)
1431
1520
return restore_one_link (ns , link , nlsk , bridge_link_info , NULL );
1432
1521
case ND_TYPE__MACVLAN :
1433
1522
return restore_one_macvlan (ns , link , nlsk );
1523
+ case ND_TYPE__SIT :
1524
+ return restore_one_link (ns , link , nlsk , sit_link_info , NULL );
1434
1525
default :
1435
1526
pr_err ("Unsupported link type %d\n" , link -> nde -> type );
1436
1527
break ;
0 commit comments