@@ -1903,6 +1903,7 @@ bool VxlanTunnelMapOrch::addOperation(const Request& request)
1903
1903
1904
1904
sai_vlan_id_t vlan_id = (sai_vlan_id_t )request.getAttrVlan (" vlan" );
1905
1905
Port tempPort;
1906
+ bool isL3Vni = false ;
1906
1907
1907
1908
const auto full_tunnel_map_entry_name = request.getFullKey ();
1908
1909
SWSS_LOG_INFO (" Full name = %s" ,full_tunnel_map_entry_name.c_str ());
@@ -1974,11 +1975,21 @@ bool VxlanTunnelMapOrch::addOperation(const Request& request)
1974
1975
tunnel_obj->vlan_vrf_vni_count ++;
1975
1976
SWSS_LOG_INFO (" vni count increased to %d" ,tunnel_obj->vlan_vrf_vni_count );
1976
1977
1978
+ VRFOrch* vrf_orch = gDirectory .get <VRFOrch*>();
1979
+ isL3Vni = vrf_orch->isL3VniVlan (vni_id);
1980
+
1977
1981
try
1978
1982
{
1979
- auto tunnel_map_entry_id = create_tunnel_map_entry (MAP_T::VNI_TO_VLAN_ID,
1980
- tunnel_map_id, vni_id, vlan_id);
1981
- vxlan_tunnel_map_table_[full_tunnel_map_entry_name].map_entry_id = tunnel_map_entry_id;
1983
+ if (isL3Vni == false )
1984
+ {
1985
+ auto tunnel_map_entry_id = create_tunnel_map_entry (MAP_T::VNI_TO_VLAN_ID,
1986
+ tunnel_map_id, vni_id, vlan_id);
1987
+ vxlan_tunnel_map_table_[full_tunnel_map_entry_name].map_entry_id = tunnel_map_entry_id;
1988
+ }
1989
+ else
1990
+ {
1991
+ vxlan_tunnel_map_table_[full_tunnel_map_entry_name].map_entry_id = SAI_NULL_OBJECT_ID;
1992
+ }
1982
1993
vxlan_tunnel_map_table_[full_tunnel_map_entry_name].vlan_id = vlan_id;
1983
1994
vxlan_tunnel_map_table_[full_tunnel_map_entry_name].vni_id = vni_id;
1984
1995
}
@@ -2124,9 +2135,13 @@ bool VxlanTunnelMapOrch::delOperation(const Request& request)
2124
2135
bool VxlanVrfMapOrch::addOperation (const Request& request)
2125
2136
{
2126
2137
SWSS_LOG_ENTER ();
2138
+ std::string vniVlanMapName;
2139
+ uint32_t vlan_id = 0 ;
2140
+ sai_object_id_t tnl_map_entry_id = SAI_NULL_OBJECT_ID;
2127
2141
2128
2142
auto tunnel_name = request.getKeyString (0 );
2129
2143
VxlanTunnelOrch* tunnel_orch = gDirectory .get <VxlanTunnelOrch*>();
2144
+ VxlanTunnelMapOrch* vxlan_tun_map_orch = gDirectory .get <VxlanTunnelMapOrch*>();
2130
2145
if (!tunnel_orch->isTunnelExists (tunnel_name))
2131
2146
{
2132
2147
SWSS_LOG_WARN (" Vxlan tunnel '%s' doesn't exist" , tunnel_name.c_str ());
@@ -2188,6 +2203,15 @@ bool VxlanVrfMapOrch::addOperation(const Request& request)
2188
2203
vrf_map_entry_t entry;
2189
2204
try
2190
2205
{
2206
+ entry.isL2Vni = vxlan_tun_map_orch->isVniVlanMapExists (vni_id, vniVlanMapName, &tnl_map_entry_id, &vlan_id);
2207
+ if (entry.isL2Vni )
2208
+ {
2209
+ entry.vniVlanMapName = vniVlanMapName;
2210
+ entry.vlan_id = vlan_id;
2211
+ entry.vni_id = vni_id;
2212
+ remove_tunnel_map_entry (tnl_map_entry_id);
2213
+ SWSS_LOG_DEBUG (" remove_tunnel_map_entry name %s, vlan %d, vni %d\n " , entry.vniVlanMapName .c_str (), entry.vlan_id , entry.vni_id );
2214
+ }
2191
2215
/*
2192
2216
* Create encap and decap mapper
2193
2217
*/
@@ -2219,6 +2243,8 @@ bool VxlanVrfMapOrch::delOperation(const Request& request)
2219
2243
SWSS_LOG_ENTER ();
2220
2244
2221
2245
VRFOrch* vrf_orch = gDirectory .get <VRFOrch*>();
2246
+ VxlanTunnelOrch* tunnel_orch = gDirectory .get <VxlanTunnelOrch*>();
2247
+ VxlanTunnelMapOrch* vxlan_tun_map_orch = gDirectory .get <VxlanTunnelMapOrch*>();
2222
2248
const auto full_map_entry_name = request.getFullKey ();
2223
2249
2224
2250
if (!isVrfMapExists (full_map_entry_name))
@@ -2241,6 +2267,9 @@ bool VxlanVrfMapOrch::delOperation(const Request& request)
2241
2267
return false ;
2242
2268
}
2243
2269
SWSS_LOG_NOTICE (" VxlanVrfMapOrch VRF VNI mapping '%s' remove vrf %s" , full_map_entry_name.c_str (), vrf_name.c_str ());
2270
+ auto tunnel_name = request.getKeyString (0 );
2271
+ auto tunnel_obj = tunnel_orch->getVxlanTunnel (tunnel_name);
2272
+
2244
2273
vrf_map_entry_t entry;
2245
2274
try
2246
2275
{
@@ -2256,6 +2285,20 @@ bool VxlanVrfMapOrch::delOperation(const Request& request)
2256
2285
vrf_orch->decreaseVrfRefCount (vrf_name);
2257
2286
remove_tunnel_map_entry (entry.decap_id );
2258
2287
vrf_orch->decreaseVrfRefCount (vrf_name);
2288
+
2289
+ if (entry.isL2Vni )
2290
+ {
2291
+ const auto tunnel_map_id = tunnel_obj->getDecapMapId (TUNNEL_MAP_T_VLAN);
2292
+ SWSS_LOG_NOTICE (" Adding tunnel map entry. Tunnel: %s %s" ,tunnel_name.c_str (),entry.vniVlanMapName .c_str ());
2293
+
2294
+ SWSS_LOG_DEBUG (" create_tunnel_map_entry vni %d, vlan %d\n " , entry.vni_id , entry.vlan_id );
2295
+ auto tunnel_map_entry_id = create_tunnel_map_entry (MAP_T::VNI_TO_VLAN_ID,
2296
+ tunnel_map_id, entry.vni_id , (uint16_t )entry.vlan_id );
2297
+ SWSS_LOG_DEBUG (" updateTnlMapId name %s\n " , entry.vniVlanMapName .c_str ());
2298
+
2299
+ vxlan_tun_map_orch->updateTnlMapId (entry.vniVlanMapName , tunnel_map_entry_id);
2300
+ }
2301
+
2259
2302
vxlan_vrf_table_.erase (full_map_entry_name);
2260
2303
vxlan_vrf_tunnel_.erase (vrf_name);
2261
2304
}
@@ -2599,3 +2642,35 @@ bool EvpnNvoOrch::delOperation(const Request& request)
2599
2642
2600
2643
return true ;
2601
2644
}
2645
+
2646
+ bool VxlanTunnelMapOrch::isVniVlanMapExists (uint32_t vni_id, std::string& vniVlanMapName, sai_object_id_t *tnl_map_entry_id, uint32_t *vlan_id)
2647
+ {
2648
+ SWSS_LOG_ENTER ();
2649
+ bool map_entry_exists = false ;
2650
+ std::map<std::string, tunnel_map_entry_t >::iterator it;
2651
+ for (it = vxlan_tunnel_map_table_.begin (); it != vxlan_tunnel_map_table_.end (); it++)
2652
+ {
2653
+ auto full_tunnel_map_entry_name = it->first ;
2654
+ tunnel_map_entry_t tunnel_map_entry = it->second ;
2655
+
2656
+ if (vni_id == tunnel_map_entry.vni_id )
2657
+ {
2658
+ vniVlanMapName = full_tunnel_map_entry_name;
2659
+ *tnl_map_entry_id = tunnel_map_entry.map_entry_id ;
2660
+ *vlan_id = tunnel_map_entry.vlan_id ;
2661
+ map_entry_exists = true ;
2662
+ SWSS_LOG_NOTICE (" vniVlanMapName %s, vlan %d\n " , vniVlanMapName.c_str (), *vlan_id);
2663
+ break ;
2664
+ }
2665
+ }
2666
+
2667
+ return map_entry_exists;
2668
+ }
2669
+
2670
+ void VxlanTunnelMapOrch::updateTnlMapId (std::string vniVlanMapName, sai_object_id_t tunnel_map_id)
2671
+ {
2672
+ SWSS_LOG_ENTER ();
2673
+ SWSS_LOG_NOTICE (" name %s\n " , vniVlanMapName.c_str ());
2674
+ vxlan_tunnel_map_table_[vniVlanMapName].map_entry_id = tunnel_map_id;
2675
+ }
2676
+
0 commit comments