@@ -428,16 +428,15 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
428
428
429
429
string alias (keys[0 ]);
430
430
string vlanId;
431
- string subIntfAlias ;
431
+ string parentAlias ;
432
432
size_t found = alias.find (VLAN_SUB_INTERFACE_SEPARATOR);
433
433
if (found != string::npos)
434
434
{
435
435
// This is a sub interface
436
- // subIntfAlias holds the complete sub interface name
437
- // while alias becomes the parent interface
438
- subIntfAlias = alias;
436
+ // alias holds the complete sub interface name
437
+ // while parentAlias holds the parent port name
439
438
vlanId = alias.substr (found + 1 );
440
- alias = alias.substr (0 , found);
439
+ parentAlias = alias.substr (0 , found);
441
440
}
442
441
bool is_lo = !alias.compare (0 , strlen (LOOPBACK_PREFIX), LOOPBACK_PREFIX);
443
442
string mac = " " ;
@@ -482,7 +481,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
482
481
483
482
if (op == SET_COMMAND)
484
483
{
485
- if (!isIntfStateOk (alias))
484
+ if (!isIntfStateOk (parentAlias. empty () ? alias : parentAlias ))
486
485
{
487
486
SWSS_LOG_DEBUG (" Interface is not ready, skipping %s" , alias.c_str ());
488
487
return false ;
@@ -520,74 +519,28 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
520
519
}
521
520
}
522
521
523
- if (!vrf_name.empty ())
524
- {
525
- setIntfVrf (alias, vrf_name);
526
- }
527
-
528
- /* Set the mac of interface*/
529
- if (!mac.empty ())
530
- {
531
- setIntfMac (alias, mac);
532
- }
533
- else
534
- {
535
- FieldValueTuple fvTuple (" mac_addr" , MacAddress ().to_string ());
536
- data.push_back (fvTuple);
537
- }
538
-
539
- if (!proxy_arp.empty ())
522
+ if (!parentAlias.empty ())
540
523
{
541
- if (!setIntfProxyArp (alias, proxy_arp))
542
- {
543
- SWSS_LOG_ERROR (" Failed to set proxy ARP to \" %s\" state for the \" %s\" interface" , proxy_arp.c_str (), alias.c_str ());
544
- return false ;
545
- }
546
-
547
- if (!alias.compare (0 , strlen (VLAN_PREFIX), VLAN_PREFIX))
548
- {
549
- FieldValueTuple fvTuple (" proxy_arp" , proxy_arp);
550
- data.push_back (fvTuple);
551
- }
552
- }
553
-
554
- if (!grat_arp.empty ())
555
- {
556
- if (!setIntfGratArp (alias, grat_arp))
557
- {
558
- SWSS_LOG_ERROR (" Failed to set ARP accept to \" %s\" state for the \" %s\" interface" , grat_arp.c_str (), alias.c_str ());
559
- return false ;
560
- }
561
-
562
- if (!alias.compare (0 , strlen (VLAN_PREFIX), VLAN_PREFIX))
563
- {
564
- FieldValueTuple fvTuple (" grat_arp" , grat_arp);
565
- data.push_back (fvTuple);
566
- }
567
- }
568
-
569
- if (!subIntfAlias.empty ())
570
- {
571
- if (m_subIntfList.find (subIntfAlias) == m_subIntfList.end ())
524
+ if (m_subIntfList.find (alias) == m_subIntfList.end ())
572
525
{
573
526
try
574
527
{
575
- addHostSubIntf (alias, subIntfAlias , vlanId);
528
+ addHostSubIntf (parentAlias, alias , vlanId);
576
529
}
577
530
catch (const std::runtime_error &e)
578
531
{
579
532
SWSS_LOG_NOTICE (" Sub interface ip link add failure. Runtime error: %s" , e.what ());
580
533
return false ;
581
534
}
582
535
583
- m_subIntfList.insert (subIntfAlias );
536
+ m_subIntfList.insert (alias );
584
537
}
585
538
586
539
if (!mtu.empty ())
587
540
{
588
541
try
589
542
{
590
- setHostSubIntfMtu (subIntfAlias , mtu);
543
+ setHostSubIntfMtu (alias , mtu);
591
544
}
592
545
catch (const std::runtime_error &e)
593
546
{
@@ -609,7 +562,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
609
562
}
610
563
try
611
564
{
612
- setHostSubIntfAdminStatus (subIntfAlias , adminStatus);
565
+ setHostSubIntfAdminStatus (alias , adminStatus);
613
566
}
614
567
catch (const std::runtime_error &e)
615
568
{
@@ -618,10 +571,57 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
618
571
}
619
572
620
573
// set STATE_DB port state
621
- setSubIntfStateOk (subIntfAlias );
574
+ setSubIntfStateOk (alias );
622
575
}
623
- m_appIntfTableProducer.set (subIntfAlias.empty () ? alias : subIntfAlias, data);
624
- m_stateIntfTable.hset (subIntfAlias.empty () ? alias : subIntfAlias, " vrf" , vrf_name);
576
+
577
+ if (!vrf_name.empty ())
578
+ {
579
+ setIntfVrf (alias, vrf_name);
580
+ }
581
+
582
+ /* Set the mac of interface*/
583
+ if (!mac.empty ())
584
+ {
585
+ setIntfMac (alias, mac);
586
+ }
587
+ else
588
+ {
589
+ FieldValueTuple fvTuple (" mac_addr" , MacAddress ().to_string ());
590
+ data.push_back (fvTuple);
591
+ }
592
+
593
+ if (!proxy_arp.empty ())
594
+ {
595
+ if (!setIntfProxyArp (alias, proxy_arp))
596
+ {
597
+ SWSS_LOG_ERROR (" Failed to set proxy ARP to \" %s\" state for the \" %s\" interface" , proxy_arp.c_str (), alias.c_str ());
598
+ return false ;
599
+ }
600
+
601
+ if (!alias.compare (0 , strlen (VLAN_PREFIX), VLAN_PREFIX))
602
+ {
603
+ FieldValueTuple fvTuple (" proxy_arp" , proxy_arp);
604
+ data.push_back (fvTuple);
605
+ }
606
+ }
607
+
608
+ if (!grat_arp.empty ())
609
+ {
610
+ if (!setIntfGratArp (alias, grat_arp))
611
+ {
612
+ SWSS_LOG_ERROR (" Failed to set ARP accept to \" %s\" state for the \" %s\" interface" , grat_arp.c_str (), alias.c_str ());
613
+ return false ;
614
+ }
615
+
616
+ if (!alias.compare (0 , strlen (VLAN_PREFIX), VLAN_PREFIX))
617
+ {
618
+ FieldValueTuple fvTuple (" grat_arp" , grat_arp);
619
+ data.push_back (fvTuple);
620
+ }
621
+ }
622
+
623
+ m_appIntfTableProducer.set (alias, data);
624
+ m_stateIntfTable.hset (alias, " vrf" , vrf_name);
625
625
}
626
626
else if (op == DEL_COMMAND)
627
627
{
@@ -640,16 +640,16 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
640
640
m_loopbackIntfList.erase (alias);
641
641
}
642
642
643
- if (!subIntfAlias .empty ())
643
+ if (!parentAlias .empty ())
644
644
{
645
- removeHostSubIntf (subIntfAlias );
646
- m_subIntfList.erase (subIntfAlias );
645
+ removeHostSubIntf (alias );
646
+ m_subIntfList.erase (alias );
647
647
648
- removeSubIntfState (subIntfAlias );
648
+ removeSubIntfState (alias );
649
649
}
650
650
651
- m_appIntfTableProducer.del (subIntfAlias. empty () ? alias : subIntfAlias );
652
- m_stateIntfTable.del (subIntfAlias. empty () ? alias : subIntfAlias );
651
+ m_appIntfTableProducer.del (alias);
652
+ m_stateIntfTable.del (alias);
653
653
}
654
654
else
655
655
{
0 commit comments