16
16
#include " bufferorch.h"
17
17
#include " directory.h"
18
18
#include " vnetorch.h"
19
+ #include " subscriberstatetable.h"
19
20
20
21
extern sai_object_id_t gVirtualRouterId ;
21
22
extern Directory<Orch*> gDirectory ;
@@ -32,6 +33,7 @@ extern RouteOrch *gRouteOrch;
32
33
extern CrmOrch *gCrmOrch ;
33
34
extern BufferOrch *gBufferOrch ;
34
35
extern bool gIsNatSupported ;
36
+ extern NeighOrch *gNeighOrch ;
35
37
36
38
const int intfsorch_pri = 35 ;
37
39
@@ -52,8 +54,9 @@ static const vector<sai_router_interface_stat_t> rifStatIds =
52
54
SAI_ROUTER_INTERFACE_STAT_OUT_ERROR_OCTETS,
53
55
};
54
56
55
- IntfsOrch::IntfsOrch (DBConnector *db, string tableName, VRFOrch *vrf_orch) :
56
- Orch(db, tableName, intfsorch_pri), m_vrfOrch(vrf_orch)
57
+ IntfsOrch::IntfsOrch (DBConnector *db, string tableName, VRFOrch *vrf_orch, DBConnector *voqDb) :
58
+ Orch(db, tableName, intfsorch_pri), m_vrfOrch(vrf_orch),
59
+ m_tableVoqSystemInterfaceTable(voqDb, VOQ_SYSTEM_INTERFACE_TABLE_NAME)
57
60
{
58
61
SWSS_LOG_ENTER ();
59
62
@@ -96,6 +99,11 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, VRFOrch *vrf_orch) :
96
99
{
97
100
SWSS_LOG_WARN (" RIF flex counter group plugins was not set successfully: %s" , e.what ());
98
101
}
102
+
103
+ // Add subscriber to process VOQ system interface
104
+ tableName = VOQ_SYSTEM_INTERFACE_TABLE_NAME;
105
+ Orch::addExecutor (new Consumer (new SubscriberStateTable (voqDb, tableName, TableConsumable::DEFAULT_POP_BATCH_SIZE, 0 ), this , tableName));
106
+
99
107
}
100
108
101
109
sai_object_id_t IntfsOrch::getRouterIntfsId (const string &alias)
@@ -430,6 +438,15 @@ bool IntfsOrch::setIntf(const string& alias, sai_object_id_t vrf_id, const IpPre
430
438
431
439
addIp2MeRoute (port.m_vr_id , *ip_prefix);
432
440
441
+ if (alias == gPortsOrch ->m_inbandPortName )
442
+ {
443
+ gNeighOrch ->addInbandNeighbor (alias, ip_prefix->getIp ());
444
+
445
+ // There is no config to bring inband host if admin up. So bring the
446
+ // admin up here after setting the Ip2me route for inband host if ip
447
+ gPortsOrch ->setSystemPortHostIfAdminUp (alias);
448
+ }
449
+
433
450
if (port.m_type == Port::VLAN)
434
451
{
435
452
addDirectedBroadcast (port, *ip_prefix);
@@ -453,6 +470,11 @@ bool IntfsOrch::removeIntf(const string& alias, sai_object_id_t vrf_id, const Ip
453
470
{
454
471
removeIp2MeRoute (port.m_vr_id , *ip_prefix);
455
472
473
+ if (alias == gPortsOrch ->m_inbandPortName )
474
+ {
475
+ gNeighOrch ->delInbandNeighbor (alias, ip_prefix->getIp ());
476
+ }
477
+
456
478
if (port.m_type == Port::VLAN)
457
479
{
458
480
removeDirectedBroadcast (port, *ip_prefix);
@@ -497,6 +519,8 @@ void IntfsOrch::doTask(Consumer &consumer)
497
519
return ;
498
520
}
499
521
522
+ string table_name = consumer.getTableName ();
523
+
500
524
auto it = consumer.m_toSync .begin ();
501
525
while (it != consumer.m_toSync .end ())
502
526
{
@@ -521,6 +545,16 @@ void IntfsOrch::doTask(Consumer &consumer)
521
545
ip_prefix_in_key = true ;
522
546
}
523
547
548
+ if (table_name == VOQ_SYSTEM_INTERFACE_TABLE_NAME)
549
+ {
550
+ if (!isRemoteSystemPortIntf (alias))
551
+ {
552
+ // Synced local interface. Skip
553
+ it = consumer.m_toSync .erase (it);
554
+ continue ;
555
+ }
556
+ }
557
+
524
558
const vector<FieldValueTuple>& data = kfvFieldsValues (t);
525
559
string vrf_name = " " , vnet_name = " " , nat_zone = " " ;
526
560
MacAddress mac;
@@ -529,6 +563,7 @@ void IntfsOrch::doTask(Consumer &consumer)
529
563
bool adminUp;
530
564
uint32_t nat_zone_id = 0 ;
531
565
string proxy_arp = " " ;
566
+ string inband_type = " " ;
532
567
533
568
for (auto idx : data)
534
569
{
@@ -608,6 +643,10 @@ void IntfsOrch::doTask(Consumer &consumer)
608
643
{
609
644
proxy_arp = value;
610
645
}
646
+ else if (field == " inband_type" )
647
+ {
648
+ inband_type = value;
649
+ }
611
650
}
612
651
613
652
if (alias == " eth0" || alias == " docker0" )
@@ -680,6 +719,11 @@ void IntfsOrch::doTask(Consumer &consumer)
680
719
}
681
720
}
682
721
722
+ if (inband_type == " port" )
723
+ {
724
+ gPortsOrch ->voqAddInbandHostIf (alias, port);
725
+ }
726
+
683
727
if (m_vnetInfses.find (alias) != m_vnetInfses.end ())
684
728
{
685
729
vnet_name = m_vnetInfses.at (alias);
@@ -892,6 +936,7 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port)
892
936
{
893
937
case Port::PHY:
894
938
case Port::LAG:
939
+ case Port::SYSTEM:
895
940
attr.value .s32 = SAI_ROUTER_INTERFACE_TYPE_PORT;
896
941
attrs.push_back (attr);
897
942
break ;
@@ -911,6 +956,7 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port)
911
956
switch (port.m_type )
912
957
{
913
958
case Port::PHY:
959
+ case Port::SYSTEM:
914
960
attr.id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID;
915
961
attr.value .oid = port.m_port_id ;
916
962
attrs.push_back (attr);
@@ -975,6 +1021,9 @@ bool IntfsOrch::addRouterIntfs(sai_object_id_t vrf_id, Port &port)
975
1021
976
1022
SWSS_LOG_NOTICE (" Create router interface %s MTU %u" , port.m_alias .c_str (), port.m_mtu );
977
1023
1024
+ // Sync the interface to add to the SYSTEM_INTERFACE table of VOQ DB
1025
+ voqSyncAddIntf (port.m_alias , port.m_rif_id );
1026
+
978
1027
return true ;
979
1028
}
980
1029
@@ -1005,6 +1054,9 @@ bool IntfsOrch::removeRouterIntfs(Port &port)
1005
1054
1006
1055
SWSS_LOG_NOTICE (" Remove router interface for port %s" , port.m_alias .c_str ());
1007
1056
1057
+ // Sync the interface to del from the SYSTEM_INTERFACE table of VOQ DB
1058
+ voqSyncDelIntf (port.m_alias );
1059
+
1008
1060
return true ;
1009
1061
}
1010
1062
@@ -1227,6 +1279,7 @@ void IntfsOrch::doTask(SelectableTimer &timer)
1227
1279
{
1228
1280
case Port::PHY:
1229
1281
case Port::LAG:
1282
+ case Port::SYSTEM:
1230
1283
type = " SAI_ROUTER_INTERFACE_TYPE_PORT" ;
1231
1284
break ;
1232
1285
case Port::VLAN:
@@ -1252,3 +1305,78 @@ void IntfsOrch::doTask(SelectableTimer &timer)
1252
1305
}
1253
1306
}
1254
1307
}
1308
+
1309
+ bool IntfsOrch::isRemoteSystemPortIntf (string alias)
1310
+ {
1311
+ Port port;
1312
+ if (gPortsOrch ->getPort (alias, port))
1313
+ {
1314
+ return (port.m_system_port_info .type == SAI_SYSTEM_PORT_TYPE_REMOTE);
1315
+ }
1316
+ // Given alias is system port alias of the local port
1317
+ return false ;
1318
+ }
1319
+
1320
+ bool IntfsOrch::voqSyncAddIntf (string &alias, sai_object_id_t &rif_id)
1321
+ {
1322
+ // Sync only local interface. Confirm for the local interface and
1323
+ // get the system port alias for key for syncing
1324
+ Port port;
1325
+ if (gPortsOrch ->getPort (alias, port))
1326
+ {
1327
+ if (port.m_system_port_info .type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1328
+ {
1329
+ return true ;
1330
+ }
1331
+ }
1332
+ alias = port.m_system_port_info .alias ;
1333
+
1334
+ // Get router interface to make sure it exists
1335
+ sai_attribute_t attr;
1336
+ sai_status_t status;
1337
+
1338
+ attr.id = SAI_ROUTER_INTERFACE_ATTR_PORT_ID;
1339
+
1340
+ status = sai_router_intfs_api->get_router_interface_attribute (rif_id, 1 , &attr);
1341
+ if (status != SAI_STATUS_SUCCESS)
1342
+ {
1343
+ SWSS_LOG_ERROR (" Failed to get rif for %s:0x%lx, rv:%d" , alias.c_str (), rif_id, status);
1344
+ return false ;
1345
+ }
1346
+
1347
+ // Get the Real ID of the RIF ID
1348
+ string value;
1349
+ const auto id = sai_serialize_object_id (rif_id);
1350
+
1351
+ if (m_vidToRidTable->hget (" " , id, value))
1352
+ {
1353
+ FieldValueTuple rifIdFv (" rif_id" , value);
1354
+ vector<FieldValueTuple> attrs;
1355
+ attrs.push_back (rifIdFv);
1356
+
1357
+ m_tableVoqSystemInterfaceTable.set (alias, attrs);
1358
+ return true ;
1359
+ }
1360
+ SWSS_LOG_ERROR (" Failed to get real ID from ASIC DB for RIF id 0x%lx of %s" , rif_id, alias.c_str ());
1361
+ return false ;
1362
+ }
1363
+
1364
+ bool IntfsOrch::voqSyncDelIntf (string &alias)
1365
+ {
1366
+ // Sync only local interface. Confirm for the local interface and
1367
+ // get the system port alias for key for syncing to global VOQ DB
1368
+ Port port;
1369
+ if (gPortsOrch ->getPort (alias, port))
1370
+ {
1371
+ if (port.m_system_port_info .type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1372
+ {
1373
+ return true ;
1374
+ }
1375
+ }
1376
+ alias = port.m_system_port_info .alias ;
1377
+
1378
+ m_tableVoqSystemInterfaceTable.del (alias);
1379
+
1380
+ return true ;
1381
+ }
1382
+
0 commit comments