From c89c6f70e3c64deee709585c3e801b51b3036588 Mon Sep 17 00:00:00 2001 From: Bojun-Feng Date: Tue, 5 May 2026 08:05:43 -0500 Subject: [PATCH 1/4] [vpp]: Fix LAG subinterface creation using wrong VPP hwif name * Resolve PortChannel parent to BondEthernetX directly instead of calling tap_to_hwif_name() which only maps physical Ethernet interfaces * Apply same fix to the remove path for symmetry Signed-off-by: Bojun-Feng --- vslib/vpp/SwitchVppRif.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/vslib/vpp/SwitchVppRif.cpp b/vslib/vpp/SwitchVppRif.cpp index 42cef65789..550018c15f 100644 --- a/vslib/vpp/SwitchVppRif.cpp +++ b/vslib/vpp/SwitchVppRif.cpp @@ -1583,7 +1583,15 @@ sai_status_t SwitchVpp::vpp_create_router_interface( snprintf(host_subifname, sizeof(host_subifname), "%s.%u", dev, vlan_id); /* The host(tap) subinterface is also created as part of the vpp subinterface creation */ - create_sub_interface(tap_to_hwif_name(dev), vlan_id, vlan_id); + const char *parent_hwif; + char hw_subif_parent[32]; + if (ot == SAI_OBJECT_TYPE_LAG) { + snprintf(hw_subif_parent, sizeof(hw_subif_parent), "%s%d", BONDETHERNET_PREFIX, bond_info.id); + parent_hwif = hw_subif_parent; + } else { + parent_hwif = tap_to_hwif_name(dev); + } + create_sub_interface(parent_hwif, vlan_id, vlan_id); /* Get new list of physical interfaces from VS */ refresh_interfaces_list(); @@ -1869,7 +1877,18 @@ sai_status_t SwitchVpp::vpp_remove_router_interface(sai_object_id_t rif_id) uint16_t vlan_id = attr.value.u16; std::string if_name; - bool found = getTapNameFromPortId(obj_id, if_name); + platform_bond_info_t bond_info; + bool found; + if (ot == SAI_OBJECT_TYPE_LAG) { + status = get_lag_bond_info(obj_id, bond_info); + if (status != SAI_STATUS_SUCCESS) { + return status; + } + if_name = std::string(PORTCHANNEL_PREFIX) + std::to_string(bond_info.id); + found = true; + } else { + found = getTapNameFromPortId(obj_id, if_name); + } if (found == false) { SWSS_LOG_ERROR("host interface for port id %s not found", sai_serialize_object_id(obj_id).c_str()); @@ -1878,7 +1897,15 @@ sai_status_t SwitchVpp::vpp_remove_router_interface(sai_object_id_t rif_id) const char *dev = if_name.c_str(); - delete_sub_interface(tap_to_hwif_name(dev), vlan_id); + const char *parent_hwif; + char hw_del_parent[32]; + if (ot == SAI_OBJECT_TYPE_LAG) { + snprintf(hw_del_parent, sizeof(hw_del_parent), "%s%d", BONDETHERNET_PREFIX, bond_info.id); + parent_hwif = hw_del_parent; + } else { + parent_hwif = tap_to_hwif_name(dev); + } + delete_sub_interface(parent_hwif, vlan_id); /* Get new list of physical interfaces from VS */ refresh_interfaces_list(); From 582a8af608d97d9cfe626234981b42e7ae73104b Mon Sep 17 00:00:00 2001 From: Bojun-Feng Date: Tue, 5 May 2026 10:05:22 -0500 Subject: [PATCH 2/4] [vpp]: Fix vpp_get_hwif_name returning parent name for LAG subinterfaces * Allow LAG branch to fall through to vlan_id append logic instead of returning early without the subinterface suffix Signed-off-by: Bojun-Feng --- vslib/vpp/SwitchVppRif.cpp | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/vslib/vpp/SwitchVppRif.cpp b/vslib/vpp/SwitchVppRif.cpp index 550018c15f..77a80582d4 100644 --- a/vslib/vpp/SwitchVppRif.cpp +++ b/vslib/vpp/SwitchVppRif.cpp @@ -343,6 +343,9 @@ bool SwitchVpp::vpp_get_hwif_name ( { SWSS_LOG_ENTER(); + const char *hwifname; + char hw_bondifname[32]; + if (objectTypeQuery(object_id) == SAI_OBJECT_TYPE_LAG) { platform_bond_info_t bond_info; sai_status_t status = get_lag_bond_info(object_id, bond_info); @@ -350,21 +353,22 @@ bool SwitchVpp::vpp_get_hwif_name ( { return false; } - ifname = std::string(BONDETHERNET_PREFIX) + std::to_string(bond_info.id); - return true; - } - - std::string if_name; - bool found = getTapNameFromPortId(object_id, if_name); + snprintf(hw_bondifname, sizeof(hw_bondifname), "%s%d", BONDETHERNET_PREFIX, bond_info.id); + hwifname = hw_bondifname; + } else { + std::string if_name; + bool found = getTapNameFromPortId(object_id, if_name); - if (found == false) - { - SWSS_LOG_NOTICE("host interface for port id %s not found", sai_serialize_object_id(object_id).c_str()); - return false; + if (found == false) + { + SWSS_LOG_ERROR("host interface for port id %s not found", sai_serialize_object_id(object_id).c_str()); + return false; + } + hwifname = tap_to_hwif_name(if_name.c_str()); } - const char *hwifname = tap_to_hwif_name(if_name.c_str()); - char hw_subifname[32]; + + char hw_subifname[64]; const char *hw_ifname; if (vlan_id) { From f73cb01ab620a7858ec51b96ea1b155961729d1f Mon Sep 17 00:00:00 2001 From: Bojun-Feng Date: Tue, 26 May 2026 14:07:58 -0500 Subject: [PATCH 3/4] [vpp] Use %u format specifier for uint32_t bond_info.id Signed-off-by: Bojun-Feng --- vslib/vpp/SwitchVppRif.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vslib/vpp/SwitchVppRif.cpp b/vslib/vpp/SwitchVppRif.cpp index 77a80582d4..a1ed7a75f2 100644 --- a/vslib/vpp/SwitchVppRif.cpp +++ b/vslib/vpp/SwitchVppRif.cpp @@ -353,7 +353,7 @@ bool SwitchVpp::vpp_get_hwif_name ( { return false; } - snprintf(hw_bondifname, sizeof(hw_bondifname), "%s%d", BONDETHERNET_PREFIX, bond_info.id); + snprintf(hw_bondifname, sizeof(hw_bondifname), "%s%u", BONDETHERNET_PREFIX, bond_info.id); hwifname = hw_bondifname; } else { std::string if_name; @@ -1590,7 +1590,7 @@ sai_status_t SwitchVpp::vpp_create_router_interface( const char *parent_hwif; char hw_subif_parent[32]; if (ot == SAI_OBJECT_TYPE_LAG) { - snprintf(hw_subif_parent, sizeof(hw_subif_parent), "%s%d", BONDETHERNET_PREFIX, bond_info.id); + snprintf(hw_subif_parent, sizeof(hw_subif_parent), "%s%u", BONDETHERNET_PREFIX, bond_info.id); parent_hwif = hw_subif_parent; } else { parent_hwif = tap_to_hwif_name(dev); @@ -1904,7 +1904,7 @@ sai_status_t SwitchVpp::vpp_remove_router_interface(sai_object_id_t rif_id) const char *parent_hwif; char hw_del_parent[32]; if (ot == SAI_OBJECT_TYPE_LAG) { - snprintf(hw_del_parent, sizeof(hw_del_parent), "%s%d", BONDETHERNET_PREFIX, bond_info.id); + snprintf(hw_del_parent, sizeof(hw_del_parent), "%s%u", BONDETHERNET_PREFIX, bond_info.id); parent_hwif = hw_del_parent; } else { parent_hwif = tap_to_hwif_name(dev); From a146bc3528c8cc57640b7e4ada76a19ca322f126 Mon Sep 17 00:00:00 2001 From: Bojun-Feng Date: Sat, 6 Jun 2026 07:40:53 -0500 Subject: [PATCH 4/4] [vpp]: Address review comments on LAG subinterface hwif fix * Initialize hwifname to nullptr with null-check guard in vpp_get_hwif_name * Use BONDETHERNET_PREFIX in remove path for consistency with create path Signed-off-by: Bojun-Feng --- vslib/vpp/SwitchVppRif.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/vslib/vpp/SwitchVppRif.cpp b/vslib/vpp/SwitchVppRif.cpp index a1ed7a75f2..9a2018d1bd 100644 --- a/vslib/vpp/SwitchVppRif.cpp +++ b/vslib/vpp/SwitchVppRif.cpp @@ -343,7 +343,7 @@ bool SwitchVpp::vpp_get_hwif_name ( { SWSS_LOG_ENTER(); - const char *hwifname; + const char *hwifname = nullptr; char hw_bondifname[32]; if (objectTypeQuery(object_id) == SAI_OBJECT_TYPE_LAG) { @@ -367,6 +367,7 @@ bool SwitchVpp::vpp_get_hwif_name ( hwifname = tap_to_hwif_name(if_name.c_str()); } + if (!hwifname) return false; char hw_subifname[64]; const char *hw_ifname; @@ -1888,7 +1889,7 @@ sai_status_t SwitchVpp::vpp_remove_router_interface(sai_object_id_t rif_id) if (status != SAI_STATUS_SUCCESS) { return status; } - if_name = std::string(PORTCHANNEL_PREFIX) + std::to_string(bond_info.id); + if_name = std::string(BONDETHERNET_PREFIX) + std::to_string(bond_info.id); found = true; } else { found = getTapNameFromPortId(obj_id, if_name);