FIB: Consolidate several copies of fib_ip_proto() into one. 79/10379/2
authorJon Loeliger <jdl@netgate.com>
Thu, 1 Feb 2018 17:19:29 +0000 (11:19 -0600)
committerNeale Ranns <nranns@cisco.com>
Thu, 1 Feb 2018 19:23:49 +0000 (19:23 +0000)
Rather than having multiple copies of the same function
scattered around, promote the function into the FIB
PROTOCOL definitions in fib_types.h.

Change-Id: I11c4d85931167d3a5f3dc1278afecc8845b23cd7
Signed-off-by: Jon Loeliger <jdl@netgate.com>
src/plugins/gtpu/gtpu.c [changed mode: 0755->0644]
src/vnet/fib/fib_types.h
src/vnet/geneve/geneve.c
src/vnet/vxlan-gpe/vxlan_gpe.c
src/vnet/vxlan/vxlan.c

old mode 100755 (executable)
new mode 100644 (file)
index eba0fa0..e5032b4
@@ -356,12 +356,6 @@ mcast_shared_remove (ip46_address_t * dst)
   hash_unset_mem_free (&gtpu_main.mcast_shared, dst);
 }
 
-static inline fib_protocol_t
-fib_ip_proto (bool is_ip6)
-{
-  return (is_ip6) ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4;
-}
-
 int vnet_gtpu_add_del_tunnel
   (vnet_gtpu_add_del_tunnel_args_t * a, u32 * sw_if_indexp)
 {
index e3aef7a..75ed779 100644 (file)
@@ -16,6 +16,7 @@
 #ifndef __FIB_TYPES_H__
 #define __FIB_TYPES_H__
 
+#include <stdbool.h>
 #include <vlib/vlib.h>
 #include <vnet/ip/ip6_packet.h>
 #include <vnet/mpls/packet.h>
@@ -71,6 +72,16 @@ typedef enum fib_protocol_t_ {
         _item <= FIB_PROTOCOL_IP6;        \
         _item++)
 
+/**
+ * @brief Convert from boolean is_ip6 to FIB protocol.
+ * Drop MPLS on the floor in favor of IPv4.
+ */
+static inline fib_protocol_t
+fib_ip_proto(bool is_ip6)
+{
+  return (is_ip6) ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4;
+}
+
 /**
  * @brief Convert from a protocol to a link type
  */
index 1fe73e4..2cc43ed 100644 (file)
@@ -351,12 +351,6 @@ mcast_shared_remove (ip46_address_t * remote)
   hash_unset_mem_free (&geneve_main.mcast_shared, remote);
 }
 
-static inline fib_protocol_t
-fib_ip_proto (bool is_ip6)
-{
-  return (is_ip6) ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4;
-}
-
 int vnet_geneve_add_del_tunnel
   (vnet_geneve_add_del_tunnel_args_t * a, u32 * sw_if_indexp)
 {
index af5dd19..ceec252 100644 (file)
@@ -456,12 +456,6 @@ mcast_shared_remove (ip46_address_t * remote)
   hash_unset_mem_free (&vxlan_gpe_main.mcast_shared, remote);
 }
 
-static inline fib_protocol_t
-fib_ip_proto (bool is_ip6)
-{
-  return (is_ip6) ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4;
-}
-
 /**
  * @brief Add or Del a VXLAN GPE tunnel
  *
index b0a186e..64936c0 100644 (file)
@@ -322,12 +322,6 @@ mcast_shared_remove(ip46_address_t *dst)
     hash_unset_mem_free (&vxlan_main.mcast_shared, dst);
 }
 
-static inline fib_protocol_t
-fib_ip_proto(bool is_ip6)
-{
-  return (is_ip6) ? FIB_PROTOCOL_IP6 : FIB_PROTOCOL_IP4;
-}
-
 int vnet_vxlan_add_del_tunnel 
 (vnet_vxlan_add_del_tunnel_args_t *a, u32 * sw_if_indexp)
 {