@@ -106,6 +106,16 @@ create_tunnel_map(MAP_T map_t)
106
106
return tunnel_map_id;
107
107
}
108
108
109
+ void
110
+ remove_tunnel_map (sai_object_id_t tunnel_map_id)
111
+ {
112
+ sai_status_t status = sai_tunnel_api->remove_tunnel_map (tunnel_map_id);
113
+ if (status != SAI_STATUS_SUCCESS)
114
+ {
115
+ throw std::runtime_error (" Can't remove a tunnel map object" );
116
+ }
117
+ }
118
+
109
119
static sai_object_id_t create_tunnel_map_entry (
110
120
MAP_T map_t ,
111
121
sai_object_id_t tunnel_map_id,
@@ -269,6 +279,16 @@ create_tunnel(
269
279
return tunnel_id;
270
280
}
271
281
282
+ void
283
+ remove_tunnel (sai_object_id_t tunnel_id)
284
+ {
285
+ sai_status_t status = sai_tunnel_api->remove_tunnel (tunnel_id);
286
+ if (status != SAI_STATUS_SUCCESS)
287
+ {
288
+ throw std::runtime_error (" Can't remove a tunnel object" );
289
+ }
290
+ }
291
+
272
292
// Create tunnel termination
273
293
static sai_object_id_t
274
294
create_tunnel_termination (
@@ -328,6 +348,16 @@ create_tunnel_termination(
328
348
return term_table_id;
329
349
}
330
350
351
+ void
352
+ remove_tunnel_termination (sai_object_id_t term_table_id)
353
+ {
354
+ sai_status_t status = sai_tunnel_api->remove_tunnel_term_table_entry (term_table_id);
355
+ if (status != SAI_STATUS_SUCCESS)
356
+ {
357
+ throw std::runtime_error (" Can't remove a tunnel term table object" );
358
+ }
359
+ }
360
+
331
361
bool VxlanTunnel::createTunnel (MAP_T encap, MAP_T decap)
332
362
{
333
363
try
@@ -368,7 +398,7 @@ bool VxlanTunnel::createTunnel(MAP_T encap, MAP_T decap)
368
398
return false ;
369
399
}
370
400
371
- SWSS_LOG_INFO (" Vxlan tunnel '%s' was created" , tunnel_name_.c_str ());
401
+ SWSS_LOG_NOTICE (" Vxlan tunnel '%s' was created" , tunnel_name_.c_str ());
372
402
return true ;
373
403
}
374
404
@@ -658,15 +688,47 @@ bool VxlanTunnelOrch::addOperation(const Request& request)
658
688
659
689
vxlan_tunnel_table_[tunnel_name] = std::unique_ptr<VxlanTunnel>(new VxlanTunnel (tunnel_name, src_ip, dst_ip));
660
690
661
- SWSS_LOG_INFO (" Vxlan tunnel '%s' was added" , tunnel_name.c_str ());
691
+ SWSS_LOG_NOTICE (" Vxlan tunnel '%s' was added" , tunnel_name.c_str ());
662
692
return true ;
663
693
}
664
694
665
695
bool VxlanTunnelOrch::delOperation (const Request& request)
666
696
{
667
697
SWSS_LOG_ENTER ();
668
698
669
- SWSS_LOG_ERROR (" DEL operation is not implemented" );
699
+ const auto & tunnel_name = request.getKeyString (0 );
700
+
701
+ if (!isTunnelExists (tunnel_name))
702
+ {
703
+ SWSS_LOG_ERROR (" Vxlan tunnel '%s' doesn't exist" , tunnel_name.c_str ());
704
+ return true ;
705
+ }
706
+
707
+ auto tunnel_term_id = vxlan_tunnel_table_[tunnel_name].get ()->getTunnelTermId ();
708
+ try
709
+ {
710
+ remove_tunnel_termination (tunnel_term_id);
711
+ }
712
+ catch (const std::runtime_error& error)
713
+ {
714
+ SWSS_LOG_ERROR (" Error removing tunnel term entry. Tunnel: %s. Error: %s" , tunnel_name.c_str (), error.what ());
715
+ return false ;
716
+ }
717
+
718
+ auto tunnel_id = vxlan_tunnel_table_[tunnel_name].get ()->getTunnelId ();
719
+ try
720
+ {
721
+ remove_tunnel (tunnel_id);
722
+ }
723
+ catch (const std::runtime_error& error)
724
+ {
725
+ SWSS_LOG_ERROR (" Error removing tunnel entry. Tunnel: %s. Error: %s" , tunnel_name.c_str (), error.what ());
726
+ return false ;
727
+ }
728
+
729
+ vxlan_tunnel_table_.erase (tunnel_name);
730
+
731
+ SWSS_LOG_NOTICE (" Vxlan tunnel '%s' was removed" , tunnel_name.c_str ());
670
732
671
733
return true ;
672
734
}
@@ -738,7 +800,32 @@ bool VxlanTunnelMapOrch::delOperation(const Request& request)
738
800
{
739
801
SWSS_LOG_ENTER ();
740
802
741
- SWSS_LOG_ERROR (" DEL operation is not implemented" );
803
+ const auto & tunnel_name = request.getKeyString (0 );
804
+ const auto & tunnel_map_entry_name = request.getKeyString (1 );
805
+ const auto & full_tunnel_map_entry_name = request.getFullKey ();
806
+
807
+
808
+ if (!isTunnelMapExists (full_tunnel_map_entry_name))
809
+ {
810
+ SWSS_LOG_WARN (" Vxlan tunnel map '%s' doesn't exist" , full_tunnel_map_entry_name.c_str ());
811
+ return true ;
812
+ }
813
+
814
+ auto tunnel_map_entry_id = vxlan_tunnel_map_table_[full_tunnel_map_entry_name];
815
+ try
816
+ {
817
+ remove_tunnel_map_entry (tunnel_map_entry_id);
818
+ }
819
+ catch (const std::runtime_error& error)
820
+ {
821
+ SWSS_LOG_ERROR (" Error removing tunnel map %s: %s" , full_tunnel_map_entry_name.c_str (), error.what ());
822
+ return false ;
823
+ }
824
+
825
+ vxlan_tunnel_map_table_.erase (full_tunnel_map_entry_name);
826
+
827
+ SWSS_LOG_NOTICE (" Vxlan tunnel map entry '%s' for tunnel '%s' was removed" ,
828
+ tunnel_map_entry_name.c_str (), tunnel_name.c_str ());
742
829
743
830
return true ;
744
831
}
0 commit comments