Skip to content

Commit ba4bbd8

Browse files
authored
vpp: fix bogus errors (#1642)
* Fix vpp error messages logged incorrectly * More bogus error message during syncd start
1 parent bd820a0 commit ba4bbd8

File tree

6 files changed

+96
-12
lines changed

6 files changed

+96
-12
lines changed

vslib/vpp/SaiObjectDB.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ SaiObjectDB::get(
282282
// check if the object exists
283283
status = m_switch_db->get(object_type, id, 0, &attr);
284284
if (status != SAI_STATUS_SUCCESS) {
285-
SWSS_LOG_WARN("Object is not found in SwitchVpp %s:%s", sai_serialize_object_type(object_type).c_str(), id.c_str());
285+
SWSS_LOG_NOTICE("Object is not found in SwitchVpp %s:%s", sai_serialize_object_type(object_type).c_str(), id.c_str());
286286
return std::shared_ptr<SaiDBObject>();
287287
}
288288
/*
@@ -306,9 +306,16 @@ SaiObject::get_linked_object(
306306
attr.id = link_attr_id;
307307
status = get_attr(attr);
308308
if (status != SAI_STATUS_SUCCESS) {
309-
SWSS_LOG_ERROR("Failed to get attribute %d from object %s", link_attr_id, m_id.c_str());
309+
SWSS_LOG_NOTICE("Attribute %d not found in object %s", link_attr_id, m_id.c_str());
310310
return std::shared_ptr<SaiDBObject>();
311311
}
312+
313+
if (RealObjectIdManager::objectTypeQuery(attr.value.oid) != linked_object_type) {
314+
SWSS_LOG_INFO("Linked object type mismatch: expected %d, got %d. Will return empty object.",
315+
linked_object_type, RealObjectIdManager::objectTypeQuery(attr.value.oid));
316+
return std::shared_ptr<SaiDBObject>();
317+
}
318+
312319
linked_obj_id = sai_serialize_object_id(attr.value.oid);
313320

314321
return m_switch_db->get_sai_object(linked_object_type, linked_obj_id);

vslib/vpp/SwitchVpp.cpp

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
#include "vppxlate/SaiIntfStats.h"
88

9+
#include "SwitchVppUtils.h"
10+
11+
#include <vector>
12+
913
using namespace saivs;
1014

1115
// TODO init vpp
@@ -1038,7 +1042,26 @@ sai_status_t SwitchVpp::createPort(
10381042

10391043
auto sid = sai_serialize_object_id(object_id);
10401044

1041-
CHECK_STATUS(create_internal(SAI_OBJECT_TYPE_PORT, sid, switch_id, attr_count, attr_list));
1045+
const sai_attribute_value_t *oper_status;
1046+
uint32_t attr_index;
1047+
sai_status_t status = find_attrib_in_list(attr_count, attr_list,
1048+
SAI_PORT_ATTR_OPER_STATUS, &oper_status, &attr_index);
1049+
1050+
if (status == SAI_STATUS_ITEM_NOT_FOUND) {
1051+
// SAI_PORT_ATTR_OPER_STATUS not found, create a copy of attr_list and add it
1052+
std::vector<sai_attribute_t> modified_attr_list(attr_list, attr_list + attr_count);
1053+
1054+
// Add the missing SAI_PORT_ATTR_OPER_STATUS attribute
1055+
sai_attribute_t oper_status_attr;
1056+
oper_status_attr.id = SAI_PORT_ATTR_OPER_STATUS;
1057+
oper_status_attr.value.s32 = SAI_PORT_OPER_STATUS_UNKNOWN;
1058+
modified_attr_list.push_back(oper_status_attr);
1059+
1060+
CHECK_STATUS(create_internal(SAI_OBJECT_TYPE_PORT, sid, switch_id,
1061+
static_cast<uint32_t>(modified_attr_list.size()), modified_attr_list.data()));
1062+
} else {
1063+
CHECK_STATUS(create_internal(SAI_OBJECT_TYPE_PORT, sid, switch_id, attr_count, attr_list));
1064+
}
10421065

10431066
return create_port_dependencies(object_id);
10441067
}
@@ -1436,7 +1459,7 @@ sai_status_t SwitchVpp::get(
14361459

14371460
if (it == objectHash.end())
14381461
{
1439-
SWSS_LOG_ERROR("not found %s:%s",
1462+
SWSS_LOG_INFO("not found %s:%s",
14401463
sai_serialize_object_type(objectType).c_str(),
14411464
serializedObjectId.c_str());
14421465

@@ -1815,3 +1838,28 @@ sai_status_t SwitchVpp::querySwitchHashAlgorithmCapability(
18151838

18161839
return SAI_STATUS_SUCCESS;
18171840
}
1841+
1842+
sai_status_t SwitchVpp::refresh_read_only(
1843+
_In_ const sai_attr_metadata_t *meta,
1844+
_In_ sai_object_id_t object_id)
1845+
{
1846+
SWSS_LOG_ENTER();
1847+
1848+
// Handle VPP-specific refresh read-only logic first
1849+
if (meta->objecttype == SAI_OBJECT_TYPE_BFD_SESSION)
1850+
{
1851+
switch (meta->attrid)
1852+
{
1853+
case SAI_BFD_SESSION_ATTR_STATE:
1854+
// VPP stores BFD session state in m_objectHash and will update it
1855+
// when BFD state changed. So we don't need to refresh.
1856+
return SAI_STATUS_SUCCESS;
1857+
1858+
default:
1859+
break;
1860+
}
1861+
}
1862+
1863+
// For all other cases, delegate to the base class implementation
1864+
return SwitchStateBase::refresh_read_only(meta, object_id);
1865+
}

vslib/vpp/SwitchVpp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ namespace saivs
7373
virtual sai_status_t create_port_serdes_per_port(
7474
_In_ sai_object_id_t port_id) override;
7575

76+
virtual sai_status_t refresh_read_only(
77+
_In_ const sai_attr_metadata_t *meta,
78+
_In_ sai_object_id_t object_id) override;
79+
7680
private: // from vpp VirtualSwitchSaiInterface
7781

7882
void setPortStats(

vslib/vpp/SwitchVppHostif.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ const char* SwitchVpp::hwif_to_tap_name(
591591

592592
if (it == m_hwif_hostif_map.end())
593593
{
594-
SWSS_LOG_ERROR("failed to find hostif info entry for hwif device: %s", tap_name.c_str());
594+
// not all hwif are mapped to hostif, e.g. vxlan tunnel interface, bvi interface.
595+
SWSS_LOG_NOTICE("failed to find hostif info entry for hwif device: %s", tap_name.c_str());
595596

596597
return "Unknown";
597598
}

vslib/vpp/SwitchVppRif.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ std::string get_intf_name_for_prefix (
154154
is_v6 = (route_entry.destination.addr_family == SAI_IP_ADDR_FAMILY_IPV6) ? true : false;
155155

156156
std::string full_if_name = "";
157-
bool found = vpp_get_intf_name_for_prefix(route_entry.destination, is_v6, full_if_name);
158-
if (found == false)
159-
{
157+
bool found = vpp_get_intf_name_for_prefix(route_entry.destination, is_v6, full_if_name);
158+
if (found == false)
159+
{
160160
auto prefix_str = sai_serialize_ip_prefix(route_entry.destination);
161-
SWSS_LOG_ERROR("host interface for prefix not found: %s", prefix_str.c_str());
161+
SWSS_LOG_INFO("host interface for prefix not found: %s", prefix_str.c_str());
162162
}
163163
return full_if_name;
164164

@@ -359,7 +359,7 @@ bool SwitchVpp::vpp_get_hwif_name (
359359

360360
if (found == false)
361361
{
362-
SWSS_LOG_ERROR("host interface for port id %s not found", sai_serialize_object_id(object_id).c_str());
362+
SWSS_LOG_NOTICE("host interface for port id %s not found", sai_serialize_object_id(object_id).c_str());
363363
return false;
364364
}
365365

@@ -486,7 +486,7 @@ sai_status_t SwitchVpp::asyncIntfStateUpdate(const char *hwif_name, bool link_up
486486
auto port_oid = getPortIdFromIfName(std::string(tap));
487487

488488
if (port_oid == SAI_NULL_OBJECT_ID) {
489-
SWSS_LOG_NOTICE("Failed find port oid for tap interface %s", tap);
489+
SWSS_LOG_NOTICE("Failed find port oid for tap interface %s. Ignore the update.", tap);
490490
return SAI_STATUS_SUCCESS;
491491
}
492492

@@ -884,6 +884,16 @@ sai_status_t SwitchVpp::vpp_add_del_intf_ip_addr_norif (
884884

885885
is_v6 = (route_entry.destination.addr_family == SAI_IP_ADDR_FAMILY_IPV6) ? true : false;
886886

887+
// Check if this is an IPv6 link-local address (fe80::/10)
888+
if (is_v6) {
889+
const uint8_t* addr = route_entry.destination.addr.ip6;
890+
// Link-local addresses start with fe80::/10, so first byte is 0xfe and second byte is 0x80-0xbf
891+
if (addr[0] == 0xfe && (addr[1] & 0xc0) == 0x80) {
892+
SWSS_LOG_INFO("Skipping configuring interface IP: IPv6 link-local address");
893+
return SAI_STATUS_SUCCESS;
894+
}
895+
}
896+
887897
std::string full_if_name;
888898
std::string ip_prefix_str;
889899

vslib/vpp/SwitchVppRoute.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void create_vpp_nexthop_entry (
103103

104104
sai_status_t SwitchVpp::IpRouteAddRemove(
105105
_In_ const SaiObject* route_obj,
106-
_In_ bool is_add)
106+
_In_ bool is_add)
107107
{
108108
SWSS_LOG_ENTER();
109109

@@ -112,6 +112,20 @@ sai_status_t SwitchVpp::IpRouteAddRemove(
112112
sai_object_id_t next_hop_oid;
113113
sai_attribute_t attr;
114114
std::string serializedObjectId = route_obj->get_id();
115+
int packet_action = SAI_PACKET_ACTION_FORWARD;
116+
117+
attr.id = SAI_ROUTE_ENTRY_ATTR_PACKET_ACTION;
118+
status = route_obj->get_attr(attr);
119+
if (status == SAI_STATUS_SUCCESS) {
120+
packet_action = attr.value.s32;
121+
}
122+
123+
// We should program drop routes
124+
if (packet_action != SAI_PACKET_ACTION_FORWARD) {
125+
SWSS_LOG_NOTICE("Ignoring ip route %s: action is not forward: %d",
126+
serializedObjectId.c_str(), packet_action);
127+
return SAI_STATUS_SUCCESS;
128+
}
115129

116130
attr.id = SAI_ROUTE_ENTRY_ATTR_NEXT_HOP_ID;
117131
CHECK_STATUS_QUIET(route_obj->get_mandatory_attr(attr));

0 commit comments

Comments
 (0)