void swss::NotificationConsumer::processReply(redisReply *reply) { SWSS_LOG_ENTER(); if (reply->type != REDIS_REPLY_ARRAY) { SWSS_LOG_ERROR("expected ARRAY redis reply on channel %s, got: %d", m_channel.c_str(), reply->type); throw std::runtime_error("getRedisReply operation failed"); } if (reply->elements != REDIS_PUBLISH_MESSAGE_ELEMNTS) { SWSS_LOG_ERROR("expected %d elements in redis reply on channel %s, got: %zu", REDIS_PUBLISH_MESSAGE_ELEMNTS, m_channel.c_str(), reply->elements); throw std::runtime_error("getRedisReply operation failed"); } std::string msg = std::string(reply->element[REDIS_PUBLISH_MESSAGE_INDEX]->str); SWSS_LOG_DEBUG("got message: %s", msg.c_str()); m_queue.push(msg); }
bool check_ifname( _In_ const std::string& name) { SWSS_LOG_ENTER(); size_t size = name.size(); if (size == 0 || size > IFNAMSIZ) { SWSS_LOG_ERROR("invalid interface name %s length: %zu", name.c_str(), size); return false; } for (size_t i = 0; i < size; i++) { char c = name[i]; if (c >= '0' && c <= '9') continue; if (c >= 'a' && c <= 'z') continue; if (c >= 'A' && c <= 'Z') continue; SWSS_LOG_ERROR("invalid character '%c' in interface name %s", c, name.c_str()); return false; } // interface name is valid return true; }
void notifySyncd(swss::NotificationConsumer &consumer) { std::lock_guard<std::mutex> lock(g_mutex); SWSS_LOG_ENTER(); std::string op; std::string data; std::vector<swss::FieldValueTuple> values; consumer.pop(op, data, values); if (g_veryFirstRun) { SWSS_LOG_NOTICE("very first run is TRUE, op = %s", op.c_str()); // on the very first start of syncd, "compile" view is directly // applied on device, since it will make it easier to switch // to new asic state later on when we restart orch agent if (op == NOTIFY_SAI_APPLY_VIEW) { g_veryFirstRun = false; SWSS_LOG_NOTICE("setting very first run to FALSE, op = %s", op.c_str()); } sendResponse(SAI_STATUS_SUCCESS); return; } sai_status_t status = SAI_STATUS_FAILURE; if (op == NOTIFY_SAI_INIT_VIEW) { // TODO SWSS_LOG_ERROR("op = %s - not implemented", op.c_str()); status = SAI_STATUS_NOT_IMPLEMENTED; } if (op == NOTIFY_SAI_APPLY_VIEW) { // TODO SWSS_LOG_ERROR("op = %s - not implemented", op.c_str()); status = SAI_STATUS_NOT_IMPLEMENTED; } else { SWSS_LOG_ERROR("unknown operation: %s", op.c_str()); } sendResponse(status); }
void redisSetDummyAsicStateForRealObjectId(sai_object_id_t rid) { SWSS_LOG_ENTER(); sai_object_type_t objectType = sai_object_type_query(rid); if (objectType == SAI_OBJECT_TYPE_NULL) { SWSS_LOG_ERROR("sai_object_type_query returned NULL type for RID %llx", rid); exit(EXIT_FAILURE); } std::string strObjectType; sai_serialize_primitive(objectType, strObjectType); sai_object_id_t vid = redis_create_virtual_object_id(objectType); std::string strVid; sai_serialize_primitive(vid, strVid); std::string strKey = "ASIC_STATE:" + strObjectType + ":" + strVid; g_redisClient->hset(strKey, "NULL", "NULL"); redisCreateRidAndVidMapping(rid, vid); }
sai_status_t handle_vlan( _In_ std::string &str_object_id, _In_ sai_common_api_t api, _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list) { SWSS_LOG_ENTER(); int index = 0; sai_vlan_id_t vlan_id; sai_deserialize_primitive(str_object_id, index, vlan_id); switch(api) { case SAI_COMMON_API_CREATE: return sai_vlan_api->create_vlan(vlan_id); case SAI_COMMON_API_REMOVE: return sai_vlan_api->remove_vlan(vlan_id); case SAI_COMMON_API_SET: return sai_vlan_api->set_vlan_attribute(vlan_id, attr_list); case SAI_COMMON_API_GET: return sai_vlan_api->get_vlan_attribute(vlan_id, attr_count, attr_list); default: SWSS_LOG_ERROR("vlan other apis not implemented"); exit(EXIT_FAILURE); } }
/** * Function Description: * @brief remove decap tunnel * * Arguments: * @param[in] key - key of the tunnel from APP_DB * * Return Values: * @return true on success and false if there's an error */ bool TunnelDecapOrch::removeDecapTunnel(string key) { sai_status_t status; TunnelEntry *tunnel_info = &tunnelTable.find(key)->second; // loop through the tunnel entry ids related to the tunnel and remove them before removing the tunnel for (auto it = tunnel_info->tunnel_term_info.begin(); it != tunnel_info->tunnel_term_info.end(); ++it) { TunnelTermEntry tunnel_entry_info = *it; if (!removeDecapTunnelTermEntry(tunnel_entry_info.tunnel_term_id, tunnel_entry_info.ip_address)) { return false; } } tunnel_info->tunnel_term_info = {}; status = sai_tunnel_api->remove_tunnel(tunnel_info->tunnel_id); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to remove tunnel: %lu", tunnel_info->tunnel_id); return false; } tunnelTable.erase(key); return true; }
sai_status_t handle_trap( _In_ std::string &str_object_id, _In_ sai_common_api_t api, _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list) { SWSS_LOG_ENTER(); int index = 0; sai_object_id_t dummy_id; sai_deserialize_primitive(str_object_id, index, dummy_id); sai_hostif_trap_id_t trap_id = (sai_hostif_trap_id_t)dummy_id; switch(api) { case SAI_COMMON_API_SET: return sai_hostif_api->set_trap_attribute(trap_id, attr_list); case SAI_COMMON_API_GET: return sai_hostif_api->get_trap_attribute(trap_id, attr_count, attr_list); default: SWSS_LOG_ERROR("trap other apis not implemented"); exit(EXIT_FAILURE); } }
sai_status_t sai_api_uninitialize(void) { MUTEX(); SWSS_LOG_ENTER(); if (!g_api_initialized) { SWSS_LOG_ERROR("api not initialized"); return SAI_STATUS_FAILURE; } clear_local_state(); g_unittestChannelRun = false; //// notify thread that it should end g_unittestChannelThreadEvent.notify(); g_unittestChannelThread->join(); g_fdbAgingThreadRun = false; g_fdbAgingThread->join(); g_api_initialized = false; return SAI_STATUS_SUCCESS; }
sai_status_t handle_switch( _In_ std::string &str_object_id, _In_ sai_common_api_t api, _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list) { SWSS_LOG_ENTER(); switch(api) { case SAI_COMMON_API_CREATE: return SAI_STATUS_NOT_SUPPORTED; case SAI_COMMON_API_REMOVE: return SAI_STATUS_NOT_SUPPORTED; case SAI_COMMON_API_SET: return sai_switch_api->set_switch_attribute(attr_list); case SAI_COMMON_API_GET: return sai_switch_api->get_switch_attribute(attr_count, attr_list); default: SWSS_LOG_ERROR("switch other apis not implemented"); exit(EXIT_FAILURE); } }
int main() { swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG); SWSS_LOG_ENTER(); // swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_INFO); try { test_sai_initialize(); test_enable_recording(); test_bulk_next_hop_group_member_create(); test_bulk_fdb_create(); test_bulk_route_set(); sai_api_uninitialize(); printf("\n[ %s ]\n\n", sai_serialize_status(SAI_STATUS_SUCCESS).c_str()); } catch (const std::exception &e) { SWSS_LOG_ERROR("exception: %s", e.what()); printf("\n[ %s ]\n\n%s\n\n", sai_serialize_status(SAI_STATUS_FAILURE).c_str(), e.what()); exit(EXIT_FAILURE); } return 0; }
sai_status_t is_header_version_ok( _In_ uint32_t attr_count, _In_ const sai_attribute_t *attr_list) { const sai_attribute_t* attr_iphdr_version = get_attribute_by_id(SAI_MIRROR_SESSION_ATTR_IPHDR_VERSION, attr_count, attr_list); if (attr_iphdr_version != NULL) { uint8_t iphdr_version = attr_iphdr_version->value.u8; switch (iphdr_version) { case 4: case 6: // ok break; default: SWSS_LOG_ERROR("invalid ip header version value: %u", iphdr_version); return SAI_STATUS_INVALID_PARAMETER; } } return SAI_STATUS_SUCCESS; }
int swss::NotificationConsumer::readCache() { SWSS_LOG_ENTER(); if (m_queue.size() > 0) { return Selectable::DATA; } redisReply *reply = NULL; if (redisGetReplyFromReader(m_subscribe->getContext(), (void**)&reply) != REDIS_OK) { SWSS_LOG_ERROR("failed to read redis reply on channel %s", m_channel.c_str()); return Selectable::ERROR; } else if (reply != NULL) { RedisReply r(reply); processReply(reply); return Selectable::DATA; } return Selectable::NODATA; }
std::vector<sai_object_id_t> saiGetPortList() { SWSS_LOG_ENTER(); uint32_t portCount = saiGetPortCount(); std::vector<sai_object_id_t> portList; portList.resize(portCount); sai_attribute_t attr; attr.id = SAI_SWITCH_ATTR_PORT_LIST; attr.value.objlist.count = portCount; attr.value.objlist.list = portList.data(); sai_status_t status = sai_switch_api->get_switch_attribute(1, &attr); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("failed to get port list: %d", status); exit(EXIT_FAILURE); } return portList; }
void helperCheckCpuId() { SWSS_LOG_ENTER(); sai_object_id_t cpuId = saiGetCpuId(); sai_object_id_t redisCpuId = redisGetCpuId(); if (redisCpuId == SAI_NULL_OBJECT_ID) { redisSetDummyAsicStateForRealObjectId(cpuId); SWSS_LOG_INFO("redis cpu id is not defined yet"); redisSetCpuId(cpuId); redisCpuId = cpuId; } if (cpuId != redisCpuId) { // if this happens, we need to remap VIDTORID and RIDTOVID SWSS_LOG_ERROR("FIXME: cpu id differs: %llx vs %llx, ids must be remapped", cpuId, redisCpuId); exit(EXIT_FAILURE); } }
void helperCheckVirtualRouterId() { SWSS_LOG_ENTER(); sai_object_id_t vrId = saiGetDefaultVirtualRouter(); sai_object_id_t redisVrId = redisGetDefaultVirtualRouterId(); if (redisVrId == SAI_NULL_OBJECT_ID) { redisSetDummyAsicStateForRealObjectId(vrId); SWSS_LOG_INFO("redis default virtual router id is not defined yet"); redisSetDefaultVirtualRouterId(vrId); redisVrId = vrId; } if (vrId != redisVrId) { // if this happens, we need to remap VIDTORID and RIDTOVID SWSS_LOG_ERROR("FIXME: default virtual router id differs: %llx vs %llx, ids must be remapped", vrId, redisVrId); exit(EXIT_FAILURE); } }
sai_status_t handle_route( _In_ std::string &str_object_id, _In_ sai_common_api_t api, _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list) { SWSS_LOG_ENTER(); int index = 0; sai_unicast_route_entry_t route_entry; sai_deserialize_route_entry(str_object_id, index, route_entry); route_entry.vr_id = translate_vid_to_rid(route_entry.vr_id); SWSS_LOG_DEBUG("route: %s", str_object_id.c_str()); switch(api) { case SAI_COMMON_API_CREATE: return sai_route_api->create_route(&route_entry, attr_count, attr_list); case SAI_COMMON_API_REMOVE: return sai_route_api->remove_route(&route_entry); case SAI_COMMON_API_SET: return sai_route_api->set_route_attribute(&route_entry, attr_list); case SAI_COMMON_API_GET: return sai_route_api->get_route_attribute(&route_entry, attr_count, attr_list); default: SWSS_LOG_ERROR("route other apis not implemented"); exit(EXIT_FAILURE); } }
sai_status_t handle_neighbor( _In_ std::string &str_object_id, _In_ sai_common_api_t api, _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list) { SWSS_LOG_ENTER(); int index = 0; sai_neighbor_entry_t neighbor_entry; sai_deserialize_neighbor_entry(str_object_id, index, neighbor_entry); neighbor_entry.rif_id = translate_vid_to_rid(neighbor_entry.rif_id); switch(api) { case SAI_COMMON_API_CREATE: return sai_neighbor_api->create_neighbor_entry(&neighbor_entry, attr_count, attr_list); case SAI_COMMON_API_REMOVE: return sai_neighbor_api->remove_neighbor_entry(&neighbor_entry); case SAI_COMMON_API_SET: return sai_neighbor_api->set_neighbor_attribute(&neighbor_entry, attr_list); case SAI_COMMON_API_GET: return sai_neighbor_api->get_neighbor_attribute(&neighbor_entry, attr_count, attr_list); default: SWSS_LOG_ERROR("neighbor other apis not implemented"); exit(EXIT_FAILURE); } }
void on_switch_shutdown_request_notification( _In_ sai_object_id_t switch_id) { SWSS_LOG_ENTER(); SWSS_LOG_ERROR("got shutdown request, syncd failed!"); exit(EXIT_FAILURE); }
void helperCheckLaneMap() { SWSS_LOG_ENTER(); auto redisLaneMap = redisGetLaneMap(); auto laneMap = saiGetHardwareLaneMap(); if (redisLaneMap.size() == 0) { SWSS_LOG_INFO("no lanes defined in redis, seems like it is first syncd start"); // TODO put ports to db ? redisSaveLaneMap(laneMap); redisLaneMap = laneMap; // copy } if (laneMap.size() != redisLaneMap.size()) { SWSS_LOG_ERROR("lanes map size differ: %lu vs %lu", laneMap.size(), redisLaneMap.size()); exit(EXIT_FAILURE); } for (auto kv: laneMap) { sai_uint32_t lane = kv.first; sai_object_id_t portId = kv.second; if (redisLaneMap.find(lane) == redisLaneMap.end()) { SWSS_LOG_ERROR("lane %u not found in redis", lane); exit(EXIT_FAILURE); } if (redisLaneMap[lane] != portId) { // if this happens, we need to remap VIDTORID and RIDTOVID SWSS_LOG_ERROR("FIXME: lane port id differs: %llx vs %llx, port ids must be remapped", portId, redisLaneMap[lane]); exit(EXIT_FAILURE); } } }
void translate_vid_to_rid_list( _In_ sai_object_type_t object_type, _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list) { SWSS_LOG_ENTER(); // all id's reseived from sairedis should be virtual, so // lets translate them to real id's for (uint32_t i = 0; i < attr_count; i++) { sai_attribute_t &attr = attr_list[i]; sai_attr_serialization_type_t serialization_type; sai_status_t status = sai_get_serialization_type(object_type, attr.id, serialization_type); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("unable to find serialization type for object type %x, attribute %x", object_type, attr.id); exit(EXIT_FAILURE); } switch (serialization_type) { case SAI_SERIALIZATION_TYPE_OBJECT_ID: attr.value.oid = translate_vid_to_rid(attr.value.oid); break; case SAI_SERIALIZATION_TYPE_OBJECT_LIST: translate_list_vid_to_rid(attr.value.objlist); break; case SAI_SERIALIZATION_TYPE_ACL_FIELD_DATA_OBJECT_ID: attr.value.aclfield.data.oid = translate_vid_to_rid(attr.value.aclfield.data.oid); break; case SAI_SERIALIZATION_TYPE_ACL_FIELD_DATA_OBJECT_LIST: translate_list_vid_to_rid(attr.value.aclfield.data.objlist); break; case SAI_SERIALIZATION_TYPE_ACL_ACTION_DATA_OBJECT_ID: attr.value.aclaction.parameter.oid = translate_vid_to_rid(attr.value.aclaction.parameter.oid); break; case SAI_SERIALIZATION_TYPE_ACL_ACTION_DATA_OBJECT_LIST: translate_list_vid_to_rid(attr.value.aclaction.parameter.objlist); break; case SAI_SERIALIZATION_TYPE_PORT_BREAKOUT: translate_list_vid_to_rid(attr.value.portbreakout.port_list); default: break; } } }
void translate_rid_to_vid_list( _In_ sai_object_type_t object_type, _In_ uint32_t attr_count, _In_ sai_attribute_t *attr_list) { SWSS_LOG_ENTER(); // we receive real id's here, if they are new then create new id // for them and put in db, if entry exists in db, use it for (uint32_t i = 0; i < attr_count; i++) { sai_attribute_t &attr = attr_list[i]; sai_attr_serialization_type_t serialization_type; sai_status_t status = sai_get_serialization_type(object_type, attr.id, serialization_type); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("unable to find serialization type for object type %x, attribute %x", object_type, attr.id); exit(EXIT_FAILURE); } switch (serialization_type) { case SAI_SERIALIZATION_TYPE_OBJECT_ID: attr.value.oid = translate_rid_to_vid(attr.value.oid); break; case SAI_SERIALIZATION_TYPE_OBJECT_LIST: translate_list_rid_to_vid(attr.value.objlist); break; case SAI_SERIALIZATION_TYPE_ACL_FIELD_DATA_OBJECT_ID: attr.value.aclfield.data.oid = translate_rid_to_vid(attr.value.aclfield.data.oid); break; case SAI_SERIALIZATION_TYPE_ACL_FIELD_DATA_OBJECT_LIST: translate_list_rid_to_vid(attr.value.aclfield.data.objlist); break; case SAI_SERIALIZATION_TYPE_ACL_ACTION_DATA_OBJECT_ID: attr.value.aclaction.parameter.oid = translate_rid_to_vid(attr.value.aclaction.parameter.oid); break; case SAI_SERIALIZATION_TYPE_ACL_ACTION_DATA_OBJECT_LIST: translate_list_rid_to_vid(attr.value.aclaction.parameter.objlist); break; case SAI_SERIALIZATION_TYPE_PORT_BREAKOUT: translate_list_rid_to_vid(attr.value.portbreakout.port_list); default: break; } } }
void on_switch_shutdown_request() { SWSS_LOG_ENTER(); /* TODO: Later a better restart story will be told here */ SWSS_LOG_ERROR("Syncd stopped"); exit(EXIT_FAILURE); }
/** * Function Description: * @brief sets attributes for a tunnel * * Arguments: * @param[in] field - field to set the attribute for * @param[in] value - value to set the attribute to * @param[in] existing_tunnel_id - the id of the tunnel you want to set the attribute for * * Return Values: * @return true on success and false if there's an error */ bool TunnelDecapOrch::setTunnelAttribute(string field, string value, sai_object_id_t existing_tunnel_id) { sai_attribute_t attr; if (field == "ecn_mode") { // decap ecn mode (copy from outer/standard) attr.id = SAI_TUNNEL_ATTR_DECAP_ECN_MODE; if (value == "copy_from_outer") { attr.value.s32 = SAI_TUNNEL_DECAP_ECN_MODE_COPY_FROM_OUTER; } else if (value == "standard") { attr.value.s32 = SAI_TUNNEL_DECAP_ECN_MODE_STANDARD; } } if (field == "ttl_mode") { // ttl mode (uniform/pipe) attr.id = SAI_TUNNEL_ATTR_DECAP_TTL_MODE; if (value == "uniform") { attr.value.s32 = SAI_TUNNEL_TTL_MODE_UNIFORM_MODEL; } else if (value == "pipe") { attr.value.s32 = SAI_TUNNEL_TTL_MODE_PIPE_MODEL; } } if (field == "dscp_mode") { // dscp mode (uniform/pipe) attr.id = SAI_TUNNEL_ATTR_DECAP_DSCP_MODE; if (value == "uniform") { attr.value.s32 = SAI_TUNNEL_DSCP_MODE_UNIFORM_MODEL; } else if (value == "pipe") { attr.value.s32 = SAI_TUNNEL_DSCP_MODE_PIPE_MODEL; } } sai_status_t status = sai_tunnel_api->set_tunnel_attribute(existing_tunnel_id, &attr); if (status != SAI_STATUS_SUCCESS) { SWSS_LOG_ERROR("Failed to set attribute %s with value %s\n", field.c_str(), value.c_str()); return false; } SWSS_LOG_NOTICE("Set attribute %s with value %s\n", field.c_str(), value.c_str()); return true; }
sai_object_id_t translate_rid_to_vid( _In_ sai_object_id_t rid) { SWSS_LOG_ENTER(); if (rid == SAI_NULL_OBJECT_ID) { SWSS_LOG_DEBUG("translated RID null to VID null"); return SAI_NULL_OBJECT_ID; } sai_object_id_t vid; std::string str_rid; std::string str_vid; sai_serialize_primitive(rid, str_rid); auto pvid = g_redisClient->hget(RIDTOVID, str_rid); if (pvid != NULL) { // object exists str_vid = *pvid; int index = 0; sai_deserialize_primitive(str_vid, index, vid); SWSS_LOG_DEBUG("translated RID %llx to VID %llx", rid, vid); return vid; } SWSS_LOG_INFO("spotted new RID %llx", rid); sai_object_type_t object_type = sai_object_type_query(rid); if (object_type == SAI_OBJECT_TYPE_NULL) { SWSS_LOG_ERROR("sai_object_type_query returned NULL type for RID %llx", rid); exit(EXIT_FAILURE); } vid = redis_create_virtual_object_id(object_type); SWSS_LOG_DEBUG("translated RID %llx to VID %llx", rid, vid); sai_serialize_primitive(vid, str_vid); g_redisClient->hset(RIDTOVID, str_rid, str_vid); g_redisClient->hset(VIDTORID, str_vid, str_rid); return vid; }
void RedisReply::checkStatus(char *status) { if (strcmp(m_reply->str, status) != 0) { SWSS_LOG_ERROR("Redis reply %s != %s", m_reply->str, status); throw system_error(make_error_code(errc::io_error), "Invalid return code"); } }
void update_notifications_pointers( _In_ uint32_t attr_count, _Inout_ sai_attribute_t *attr_list) { SWSS_LOG_ENTER(); /* * Sairedis is updating notifications pointers based on attribute, so when * we will do replay it will have invalid pointers from orchagent, so we * need to override them after create, and after set. * * NOTE: This needs to be updated every time new pointer will be added. */ for (uint32_t index = 0; index < attr_count; ++index) { sai_attribute_t &attr = attr_list[index]; auto meta = sai_metadata_get_attr_metadata(SAI_OBJECT_TYPE_SWITCH, attr.id); if (meta->attrvaluetype != SAI_ATTR_VALUE_TYPE_POINTER) { continue; } switch (attr.id) { case SAI_SWITCH_ATTR_SWITCH_STATE_CHANGE_NOTIFY: attr.value.ptr = (void*)&on_switch_state_change; break; case SAI_SWITCH_ATTR_SHUTDOWN_REQUEST_NOTIFY: attr.value.ptr = (void*)&on_switch_shutdown_request_notification; break; case SAI_SWITCH_ATTR_FDB_EVENT_NOTIFY: attr.value.ptr = (void*)&on_fdb_event; break; case SAI_SWITCH_ATTR_PORT_STATE_CHANGE_NOTIFY: attr.value.ptr = (void*)&on_port_state_change; break; case SAI_SWITCH_ATTR_PACKET_EVENT_NOTIFY: attr.value.ptr = (void*)&on_packet_event; break; default: SWSS_LOG_ERROR("pointer for %s is not handled, FIXME!", meta->attridname); break; } } }
void handleCmdLine(int argc, char **argv) { SWSS_LOG_ENTER(); while(true) { static struct option long_options[] = { { "useTempView", no_argument, 0, 'u' }, { "help", no_argument, 0, 'h' }, { "skipNotifySyncd", no_argument, 0, 'C' }, { "enableDebug", no_argument, 0, 'd' }, { 0, 0, 0, 0 } }; const char* const optstring = "hCdu"; int option_index; int c = getopt_long(argc, argv, optstring, long_options, &option_index); if (c == -1) break; switch (c) { case 'd': swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG); break; case 'u': g_useTempView = false; break; case 'C': g_notifySyncd = false; break; case 'h': printUsage(); exit(EXIT_SUCCESS); case '?': SWSS_LOG_WARN("unknown option %c", optopt); printUsage(); exit(EXIT_FAILURE); default: SWSS_LOG_ERROR("getopt_long failure"); exit(EXIT_FAILURE); } } }
void SelectableEvent::readMe() { uint64_t r; ssize_t s = read(m_efd, &r, sizeof(uint64_t)); if (s != sizeof(uint64_t)) { SWSS_LOG_ERROR("read failed, errno: %s", strerror(errno)); throw std::runtime_error("read failed"); } }
SelectableEvent::SelectableEvent() : m_efd(0) { m_efd = eventfd(0, 0); if (m_efd == -1) { SWSS_LOG_ERROR("failed to create eventfd, errno: %s", strerror(errno)); throw std::runtime_error("failed to create eventfd"); } }
sai_status_t vs_set_user_defined_trap_attribute( _In_ sai_hostif_user_defined_trap_id_t hostif_user_defined_trapid, _In_ const sai_attribute_t *attr) { std::lock_guard<std::recursive_mutex> lock(g_recursive_mutex); SWSS_LOG_ENTER(); SWSS_LOG_ERROR("not implemented"); return SAI_STATUS_NOT_IMPLEMENTED; }