@@ -952,288 +952,6 @@ bool NeighOrch::removeTunnelNextHop(const NextHopKey& nh)
952
952
return true ;
953
953
}
954
954
955
- void NeighOrch::doVoqSystemNeighTask (Consumer &consumer)
956
- {
957
- SWSS_LOG_ENTER ();
958
-
959
- // Local inband port as the outgoing interface of the static neighbor and static route
960
- Port ibif;
961
- if (!gPortsOrch ->getInbandPort (ibif))
962
- {
963
- // Inband port is not ready yet.
964
- return ;
965
- }
966
-
967
- auto it = consumer.m_toSync .begin ();
968
- while (it != consumer.m_toSync .end ())
969
- {
970
- KeyOpFieldsValuesTuple t = it->second ;
971
- string key = kfvKey (t);
972
- string op = kfvOp (t);
973
-
974
- size_t found = key.find_last_of (consumer.getConsumerTable ()->getTableNameSeparator ().c_str ());
975
- if (found == string::npos)
976
- {
977
- SWSS_LOG_ERROR (" Failed to parse key %s" , key.c_str ());
978
- it = consumer.m_toSync .erase (it);
979
- continue ;
980
- }
981
-
982
- string alias = key.substr (0 , found);
983
-
984
- if (!gIntfsOrch ->isRemoteSystemPortIntf (alias))
985
- {
986
- // Synced local neighbor. Skip
987
- it = consumer.m_toSync .erase (it);
988
- continue ;
989
- }
990
-
991
- IpAddress ip_address (key.substr (found+1 ));
992
-
993
- NeighborEntry neighbor_entry = { ip_address, alias };
994
-
995
- string state_key = alias + state_db_key_delimiter + ip_address.to_string ();
996
-
997
- if (op == SET_COMMAND)
998
- {
999
- Port p;
1000
- if (!gPortsOrch ->getPort (alias, p))
1001
- {
1002
- SWSS_LOG_INFO (" Port %s doesn't exist" , alias.c_str ());
1003
- it++;
1004
- continue ;
1005
- }
1006
-
1007
- if (!p.m_rif_id )
1008
- {
1009
- SWSS_LOG_INFO (" Router interface doesn't exist on %s" , alias.c_str ());
1010
- it++;
1011
- continue ;
1012
- }
1013
-
1014
- MacAddress mac_address;
1015
- uint32_t encap_index = 0 ;
1016
- for (auto i = kfvFieldsValues (t).begin ();
1017
- i != kfvFieldsValues (t).end (); i++)
1018
- {
1019
- if (fvField (*i) == " neigh" )
1020
- mac_address = MacAddress (fvValue (*i));
1021
-
1022
- if (fvField (*i) == " encap_index" )
1023
- {
1024
- encap_index = (uint32_t )stoul (fvValue (*i));
1025
- }
1026
- }
1027
-
1028
- if (!encap_index)
1029
- {
1030
- // Encap index is not available yet. Since this is remote neighbor, we need to wait till
1031
- // Encap index is made available either by dynamic syncing or by static config
1032
- it++;
1033
- continue ;
1034
- }
1035
-
1036
- if (m_syncdNeighbors.find (neighbor_entry) == m_syncdNeighbors.end () ||
1037
- m_syncdNeighbors[neighbor_entry].mac != mac_address)
1038
- {
1039
- // Add neigh to SAI
1040
- if (addNeighbor (neighbor_entry, mac_address))
1041
- {
1042
- // neigh successfully added to SAI. Set STATE DB to signal kernel programming by neighbor manager
1043
-
1044
- // If the inband interface type is not VLAN, same MAC can be used for the inband interface for
1045
- // kernel programming.
1046
- if (ibif.m_type != Port::VLAN)
1047
- {
1048
- mac_address = gMacAddress ;
1049
- }
1050
- vector<FieldValueTuple> fvVector;
1051
- FieldValueTuple mac (" neigh" , mac_address.to_string ());
1052
- fvVector.push_back (mac);
1053
- m_stateSystemNeighTable->set (state_key, fvVector);
1054
-
1055
- it = consumer.m_toSync .erase (it);
1056
- }
1057
- else
1058
- {
1059
- SWSS_LOG_ERROR (" Failed to add voq neighbor %s to SAI" , kfvKey (t).c_str ());
1060
- it++;
1061
- }
1062
- }
1063
- else
1064
- {
1065
- /* Duplicate entry */
1066
- SWSS_LOG_INFO (" System neighbor %s already exists" , kfvKey (t).c_str ());
1067
- it = consumer.m_toSync .erase (it);
1068
- }
1069
- }
1070
- else if (op == DEL_COMMAND)
1071
- {
1072
- if (m_syncdNeighbors.find (neighbor_entry) != m_syncdNeighbors.end ())
1073
- {
1074
- // Remove neigh from SAI
1075
- if (removeNeighbor (neighbor_entry))
1076
- {
1077
- // neigh successfully deleted from SAI. Set STATE DB to signal to remove entries from kernel
1078
- m_stateSystemNeighTable->del (state_key);
1079
-
1080
- it = consumer.m_toSync .erase (it);
1081
- }
1082
- else
1083
- {
1084
- SWSS_LOG_ERROR (" Failed to remove voq neighbor %s from SAI" , kfvKey (t).c_str ());
1085
- it++;
1086
- }
1087
- }
1088
- else
1089
- /* Cannot locate the neighbor */
1090
- it = consumer.m_toSync .erase (it);
1091
- }
1092
- else
1093
- {
1094
- SWSS_LOG_ERROR (" Unknown operation type %s" , op.c_str ());
1095
- it = consumer.m_toSync .erase (it);
1096
- }
1097
- }
1098
- }
1099
-
1100
- bool NeighOrch::addInbandNeighbor (string alias, IpAddress ip_address)
1101
- {
1102
- // For "port" type inband, the inband reachability info syncing can be done through static
1103
- // configureation or CHASSIS_APP_DB sync (this function)
1104
-
1105
- // For "vlan" type inband, the inband reachability info syncinng can be ARP learning of other
1106
- // asics inband or static configuration or through CHASSIS_APP_DB sync (this function)
1107
-
1108
- // May implement inband rechability info syncing through CHASSIS_APP_DB sync here
1109
-
1110
- return true ;
1111
- }
1112
-
1113
- bool NeighOrch::delInbandNeighbor (string alias, IpAddress ip_address)
1114
- {
1115
- // Remove inband rechability info sync
1116
-
1117
- return true ;
1118
- }
1119
-
1120
- bool NeighOrch::getSystemPortNeighEncapIndex (string &alias, IpAddress &ip, uint32_t &encap_index)
1121
- {
1122
- string value;
1123
- string key = alias + m_tableVoqSystemNeighTable->getTableNameSeparator ().c_str () + ip.to_string ();
1124
-
1125
- if (m_tableVoqSystemNeighTable->hget (key, " encap_index" , value))
1126
- {
1127
- encap_index = (uint32_t ) stoul (value);
1128
- return true ;
1129
- }
1130
- return false ;
1131
- }
1132
-
1133
- bool NeighOrch::addVoqEncapIndex (string &alias, IpAddress &ip, vector<sai_attribute_t > &neighbor_attrs)
1134
- {
1135
- sai_attribute_t attr;
1136
- uint32_t encap_index = 0 ;
1137
-
1138
- if (gIntfsOrch ->isRemoteSystemPortIntf (alias))
1139
- {
1140
- if (getSystemPortNeighEncapIndex (alias, ip, encap_index))
1141
- {
1142
- attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX;
1143
- attr.value .u32 = encap_index;
1144
- neighbor_attrs.push_back (attr);
1145
-
1146
- attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_IMPOSE_INDEX;
1147
- attr.value .booldata = true ;
1148
- neighbor_attrs.push_back (attr);
1149
-
1150
- attr.id = SAI_NEIGHBOR_ENTRY_ATTR_IS_LOCAL;
1151
- attr.value .booldata = false ;
1152
- neighbor_attrs.push_back (attr);
1153
- }
1154
- else
1155
- {
1156
- // Encap index not available and the interface is remote. Return false to re-try
1157
- SWSS_LOG_NOTICE (" System port neigh encap index not available for %s|%s!" , alias.c_str (), ip.to_string ().c_str ());
1158
- return false ;
1159
- }
1160
- }
1161
-
1162
- return true ;
1163
- }
1164
-
1165
- void NeighOrch::voqSyncAddNeigh (string &alias, IpAddress &ip_address, const MacAddress &mac, sai_neighbor_entry_t &neighbor_entry)
1166
- {
1167
- sai_attribute_t attr;
1168
- sai_status_t status;
1169
-
1170
- // Sync only local neigh. Confirm for the local neigh and
1171
- // get the system port alias for key for syncing to CHASSIS_APP_DB
1172
- Port port;
1173
- if (gPortsOrch ->getPort (alias, port))
1174
- {
1175
- if (port.m_system_port_info .type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1176
- {
1177
- return ;
1178
- }
1179
- alias = port.m_system_port_info .alias ;
1180
- }
1181
- else
1182
- {
1183
- SWSS_LOG_ERROR (" Port does not exist for %s!" , alias.c_str ());
1184
- return ;
1185
- }
1186
-
1187
- attr.id = SAI_NEIGHBOR_ENTRY_ATTR_ENCAP_INDEX;
1188
-
1189
- status = sai_neighbor_api->get_neighbor_entry_attribute (&neighbor_entry, 1 , &attr);
1190
- if (status != SAI_STATUS_SUCCESS)
1191
- {
1192
- SWSS_LOG_ERROR (" Failed to get neighbor attribute for %s on %s, rv:%d" , ip_address.to_string ().c_str (), alias.c_str (), status);
1193
- return ;
1194
- }
1195
-
1196
- if (!attr.value .u32 )
1197
- {
1198
- SWSS_LOG_ERROR (" Invalid neighbor encap_index for %s on %s" , ip_address.to_string ().c_str (), alias.c_str ());
1199
- return ;
1200
- }
1201
-
1202
- vector<FieldValueTuple> attrs;
1203
-
1204
- FieldValueTuple eiFv (" encap_index" , to_string (attr.value .u32 ));
1205
- attrs.push_back (eiFv);
1206
-
1207
- FieldValueTuple macFv (" neigh" , mac.to_string ());
1208
- attrs.push_back (macFv);
1209
-
1210
- string key = alias + m_tableVoqSystemNeighTable->getTableNameSeparator ().c_str () + ip_address.to_string ();
1211
- m_tableVoqSystemNeighTable->set (key, attrs);
1212
- }
1213
-
1214
- void NeighOrch::voqSyncDelNeigh (string &alias, IpAddress &ip_address)
1215
- {
1216
- // Sync only local neigh. Confirm for the local neigh and
1217
- // get the system port alias for key for syncing to CHASSIS_APP_DB
1218
- Port port;
1219
- if (gPortsOrch ->getPort (alias, port))
1220
- {
1221
- if (port.m_system_port_info .type == SAI_SYSTEM_PORT_TYPE_REMOTE)
1222
- {
1223
- return ;
1224
- }
1225
- alias = port.m_system_port_info .alias ;
1226
- }
1227
- else
1228
- {
1229
- SWSS_LOG_ERROR (" Port does not exist for %s!" , alias.c_str ());
1230
- return ;
1231
- }
1232
-
1233
- string key = alias + m_tableVoqSystemNeighTable->getTableNameSeparator ().c_str () + ip_address.to_string ();
1234
- m_tableVoqSystemNeighTable->del (key);
1235
- }
1236
-
1237
955
void NeighOrch::doVoqSystemNeighTask (Consumer &consumer)
1238
956
{
1239
957
SWSS_LOG_ENTER ();
@@ -1325,7 +1043,8 @@ void NeighOrch::doVoqSystemNeighTask(Consumer &consumer)
1325
1043
continue ;
1326
1044
}
1327
1045
1328
- if (m_syncdNeighbors.find (neighbor_entry) == m_syncdNeighbors.end () || m_syncdNeighbors[neighbor_entry] != mac_address)
1046
+ if (m_syncdNeighbors.find (neighbor_entry) == m_syncdNeighbors.end () ||
1047
+ m_syncdNeighbors[neighbor_entry].mac != mac_address)
1329
1048
{
1330
1049
// Add neigh to SAI
1331
1050
if (addNeighbor (neighbor_entry, mac_address))
0 commit comments