vpp-swan: fix incorrect msg ID in register_event

This patch addresses the issue where the message ID registration
in the register_event function is incorrect. Due to this incorrect
registration, the lookup for the corresponding callback on received
messages fails, eventually leading to a segmentation fault
and double-free memory space.

Type: fix
Signed-off-by: Gabriel Oginski <gabrielx.oginski@intel.com>
Change-Id: If95182f972f64adb44d514e18c831cc9627d8f0f
diff --git a/extras/strongswan/vpp_sswan/kernel_vpp_net.c b/extras/strongswan/vpp_sswan/kernel_vpp_net.c
index 1ed5843..85e2768 100644
--- a/extras/strongswan/vpp_sswan/kernel_vpp_net.c
+++ b/extras/strongswan/vpp_sswan/kernel_vpp_net.c
@@ -613,6 +613,7 @@
 {
   private_kernel_vpp_net_t *this = ctx;
   vl_api_sw_interface_event_t *event;
+  vl_api_if_status_flags_t flags;
   iface_t *entry;
   enumerator_t *enumerator;
 
@@ -623,6 +624,7 @@
     {
       if (entry->index == ntohl (event->sw_if_index))
 	{
+	  flags = ntohl (event->flags);
 	  if (event->deleted)
 	    {
 	      this->ifaces->remove_at (this->ifaces, enumerator);
@@ -630,10 +632,9 @@
 		    entry->if_name);
 	      iface_destroy (entry);
 	    }
-	  else if (entry->up != (event->flags & IF_STATUS_API_FLAG_LINK_UP))
+	  else if (entry->up != (flags & IF_STATUS_API_FLAG_LINK_UP))
 	    {
-	      entry->up =
-		(event->flags & IF_STATUS_API_FLAG_LINK_UP) ? TRUE : FALSE;
+	      entry->up = (flags & IF_STATUS_API_FLAG_LINK_UP) ? TRUE : FALSE;
 	      DBG2 (DBG_NET, "interface state changed %u %s %s", entry->index,
 		    entry->if_name, entry->up ? "UP" : "DOWN");
 	    }
@@ -642,7 +643,6 @@
     }
   enumerator->destroy (enumerator);
   this->mutex->unlock (this->mutex);
-  free (data);
 }
 
 /**
@@ -718,8 +718,10 @@
 	  emp->_vl_msg_id = ntohs (msg_id);
 	  emp->enable_disable = 1;
 	  emp->pid = ntohl (am->our_pid);
+	  u16 msg_id_sw_interface_event =
+	    vl_msg_api_get_msg_index ((u8 *) "sw_interface_event_2d3d95a7");
 	  rv = vac->register_event (vac, (char *) emp, sizeof (*emp), event_cb,
-				    VL_API_SW_INTERFACE_EVENT, this);
+				    msg_id_sw_interface_event, this);
 	  if (!rv)
 	    this->events_on = TRUE;
 	}