Fix endian issue in ARP Event Reply 58/5658/3
authorWojciech Dec <wdec@cisco.com>
Tue, 7 Mar 2017 18:30:39 +0000 (19:30 +0100)
committerJohn Lo <loj@cisco.com>
Tue, 7 Mar 2017 20:50:03 +0000 (20:50 +0000)
ARP Event reply sw_if_index was getting passed in host byte order.

Change-Id: Ifae8673906ac2c4233f146786a3d02c38280809b
Signed-off-by: Wojciech Dec <wdec@cisco.com>
src/vat/api_format.c
src/vpp/api/api.c

index 53e9ca1..0b60b91 100644 (file)
@@ -1254,10 +1254,11 @@ static void vl_api_show_version_reply_t_handler_json
 static void
 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
 {
+  u32 sw_if_index = ntohl (mp->sw_if_index);
   errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
          mp->mac_ip ? "mac/ip binding" : "address resolution",
          format_ip4_address, &mp->address,
-         format_ethernet_address, mp->new_mac, mp->sw_if_index);
+         format_ethernet_address, mp->new_mac, sw_if_index);
 }
 
 static void
@@ -1269,10 +1270,11 @@ vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
 static void
 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
 {
+  u32 sw_if_index = ntohl (mp->sw_if_index);
   errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
          mp->mac_ip ? "mac/ip binding" : "address resolution",
          format_ip6_address, mp->address,
-         format_ethernet_address, mp->new_mac, mp->sw_if_index);
+         format_ethernet_address, mp->new_mac, sw_if_index);
 }
 
 static void
index f06894e..828394e 100644 (file)
@@ -1493,7 +1493,7 @@ arp_change_data_callback (u32 pool_index, u8 * new_mac,
     }
   else
     {                          /* same mac */
-      if (sw_if_index == event->sw_if_index &&
+      if (sw_if_index == ntohl(event->sw_if_index) &&
          (!event->mac_ip ||
           /* for BD case, also check IP address with 10 sec timeout */
           (address == event->address &&
@@ -1503,7 +1503,7 @@ arp_change_data_callback (u32 pool_index, u8 * new_mac,
   /* *INDENT-ON* */
 
   arp_event_last_time = now;
-  event->sw_if_index = sw_if_index;
+  event->sw_if_index = htonl (sw_if_index);
   if (event->mac_ip)
     event->address = address;
   return 0;
@@ -1531,7 +1531,7 @@ nd_change_data_callback (u32 pool_index, u8 * new_mac,
     }
   else
     {                          /* same mac */
-      if (sw_if_index == event->sw_if_index &&
+      if (sw_if_index == ntohl(event->sw_if_index) &&
          (!event->mac_ip ||
           /* for BD case, also check IP address with 10 sec timeout */
           (ip6_address_is_equal (address,
@@ -1542,7 +1542,7 @@ nd_change_data_callback (u32 pool_index, u8 * new_mac,
   /* *INDENT-ON* */
 
   nd_event_last_time = now;
-  event->sw_if_index = sw_if_index;
+  event->sw_if_index = htonl (sw_if_index);
   if (event->mac_ip)
     clib_memcpy (event->address, address, sizeof (event->address));
   return 0;