@@ -266,6 +266,12 @@ static char* hostif_vlan_tag[] = {
266
266
[SAI_HOSTIF_VLAN_TAG_KEEP] = " SAI_HOSTIF_VLAN_TAG_KEEP" ,
267
267
[SAI_HOSTIF_VLAN_TAG_ORIGINAL] = " SAI_HOSTIF_VLAN_TAG_ORIGINAL"
268
268
};
269
+
270
+ static bool isValidPortTypeForLagMember (const Port& port)
271
+ {
272
+ return (port.m_type == Port::Type::PHY || port.m_type == Port::Type::SYSTEM);
273
+ }
274
+
269
275
/*
270
276
* Initialize PortsOrch
271
277
* 0) If Gearbox is enabled, then initialize the external PHYs as defined in
@@ -1758,7 +1764,7 @@ void PortsOrch::getPortSupportedSpeeds(const std::string& alias, sai_object_id_t
1758
1764
}
1759
1765
1760
1766
// if our guess was wrong, retry with the correct value
1761
- speeds.resize (attr.value .u32list .count );
1767
+ speeds.resize (attr.value .u32list .count );
1762
1768
}
1763
1769
1764
1770
if (status == SAI_STATUS_SUCCESS)
@@ -2243,7 +2249,7 @@ sai_status_t PortsOrch::removePort(sai_object_id_t port_id)
2243
2249
2244
2250
Port port;
2245
2251
2246
- /*
2252
+ /*
2247
2253
* Make sure to bring down admin state.
2248
2254
* SET would have replaced with DEL
2249
2255
*/
@@ -2812,7 +2818,7 @@ void PortsOrch::doPortTask(Consumer &consumer)
2812
2818
it = consumer.m_toSync .erase (it);
2813
2819
continue ;
2814
2820
}
2815
-
2821
+
2816
2822
an = autoneg_mode_map[an_str];
2817
2823
if (an != p.m_autoneg )
2818
2824
{
@@ -2878,7 +2884,7 @@ void PortsOrch::doPortTask(Consumer &consumer)
2878
2884
it++;
2879
2885
continue ;
2880
2886
}
2881
-
2887
+
2882
2888
SWSS_LOG_NOTICE (" Set port %s speed from %u to %u" , alias.c_str (), p.m_speed , speed);
2883
2889
p.m_speed = speed;
2884
2890
m_portList[alias] = p;
@@ -2919,7 +2925,7 @@ void PortsOrch::doPortTask(Consumer &consumer)
2919
2925
auto ori_adv_speeds = swss::join (' ,' , p.m_adv_speeds .begin (), p.m_adv_speeds .end ());
2920
2926
if (!setPortAdvSpeeds (p.m_port_id , adv_speeds))
2921
2927
{
2922
-
2928
+
2923
2929
SWSS_LOG_ERROR (" Failed to set port %s advertised speed from %s to %s" , alias.c_str (),
2924
2930
ori_adv_speeds.c_str (),
2925
2931
adv_speeds_str.c_str ());
@@ -3713,6 +3719,15 @@ void PortsOrch::doLagMemberTask(Consumer &consumer)
3713
3719
continue ;
3714
3720
}
3715
3721
3722
+ /* Fail if a port type is not a valid type for being a LAG member port.
3723
+ * Erase invalid entry, no need to retry in this case. */
3724
+ if (!isValidPortTypeForLagMember (port))
3725
+ {
3726
+ SWSS_LOG_ERROR (" LAG member port has to be of type PHY or SYSTEM" );
3727
+ it = consumer.m_toSync .erase (it);
3728
+ continue ;
3729
+ }
3730
+
3716
3731
if (table_name == CHASSIS_APP_LAG_MEMBER_TABLE_NAME)
3717
3732
{
3718
3733
int32_t lag_switch_id = lag.m_system_lag_info .switch_id ;
@@ -3746,8 +3761,12 @@ void PortsOrch::doLagMemberTask(Consumer &consumer)
3746
3761
3747
3762
if (lag.m_members .find (port_alias) == lag.m_members .end ())
3748
3763
{
3749
- /* Assert the port doesn't belong to any LAG already */
3750
- assert (!port.m_lag_id && !port.m_lag_member_id );
3764
+ if (port.m_lag_member_id != SAI_NULL_OBJECT_ID)
3765
+ {
3766
+ SWSS_LOG_INFO (" Port %s is already a LAG member" , port.m_alias .c_str ());
3767
+ it++;
3768
+ continue ;
3769
+ }
3751
3770
3752
3771
if (!addLagMember (lag, port, (status == " enabled" )))
3753
3772
{
@@ -5567,7 +5586,7 @@ void PortsOrch::getPortSerdesVal(const std::string& val_str,
5567
5586
}
5568
5587
}
5569
5588
5570
- bool PortsOrch::getPortAdvSpeedsVal (const std::string &val_str,
5589
+ bool PortsOrch::getPortAdvSpeedsVal (const std::string &val_str,
5571
5590
std::vector<uint32_t > &speed_values)
5572
5591
{
5573
5592
SWSS_LOG_ENTER ();
@@ -5581,7 +5600,7 @@ bool PortsOrch::getPortAdvSpeedsVal(const std::string &val_str,
5581
5600
std::string speed_str;
5582
5601
std::istringstream iss (val_str);
5583
5602
5584
- try
5603
+ try
5585
5604
{
5586
5605
while (std::getline (iss, speed_str, ' ,' ))
5587
5606
{
@@ -5598,31 +5617,31 @@ bool PortsOrch::getPortAdvSpeedsVal(const std::string &val_str,
5598
5617
return true ;
5599
5618
}
5600
5619
5601
- bool PortsOrch::getPortInterfaceTypeVal (const std::string &s,
5620
+ bool PortsOrch::getPortInterfaceTypeVal (const std::string &s,
5602
5621
sai_port_interface_type_t &interface_type)
5603
5622
{
5604
5623
SWSS_LOG_ENTER ();
5605
5624
5606
5625
auto iter = interface_type_map_for_an.find (s);
5607
- if (iter != interface_type_map_for_an.end ())
5626
+ if (iter != interface_type_map_for_an.end ())
5608
5627
{
5609
5628
interface_type = interface_type_map_for_an[s];
5610
5629
return true ;
5611
5630
}
5612
- else
5631
+ else
5613
5632
{
5614
5633
const std::string &validInterfaceTypes = getValidInterfaceTypes ();
5615
- SWSS_LOG_ERROR (" Failed to parse interface_type value %s, valid interface type includes: %s" ,
5634
+ SWSS_LOG_ERROR (" Failed to parse interface_type value %s, valid interface type includes: %s" ,
5616
5635
s.c_str (), validInterfaceTypes.c_str ());
5617
5636
return false ;
5618
5637
}
5619
5638
}
5620
5639
5621
- bool PortsOrch::getPortAdvInterfaceTypesVal (const std::string &val_str,
5640
+ bool PortsOrch::getPortAdvInterfaceTypesVal (const std::string &val_str,
5622
5641
std::vector<uint32_t > &type_values)
5623
5642
{
5624
5643
SWSS_LOG_ENTER ();
5625
- if (val_str == " all" )
5644
+ if (val_str == " all" )
5626
5645
{
5627
5646
return true ;
5628
5647
}
@@ -5637,7 +5656,7 @@ bool PortsOrch::getPortAdvInterfaceTypesVal(const std::string &val_str,
5637
5656
valid = getPortInterfaceTypeVal (type_str, interface_type);
5638
5657
if (!valid) {
5639
5658
const std::string &validInterfaceTypes = getValidInterfaceTypes ();
5640
- SWSS_LOG_ERROR (" Failed to parse adv_interface_types value %s, valid interface type includes: %s" ,
5659
+ SWSS_LOG_ERROR (" Failed to parse adv_interface_types value %s, valid interface type includes: %s" ,
5641
5660
val_str.c_str (), validInterfaceTypes.c_str ());
5642
5661
return false ;
5643
5662
}
0 commit comments