ip: Replace Sematics for Interface IP addresses
[vpp.git] / src / plugins / gbp / gbp_endpoint.h
index d56e91d..3155e7b 100644 (file)
@@ -17,6 +17,7 @@
 #define __GBP_ENDPOINT_H__
 
 #include <plugins/gbp/gbp_types.h>
+#include <plugins/gbp/gbp_itf.h>
 #include <vnet/ip/ip.h>
 #include <vnet/ethernet/mac_address.h>
 
@@ -32,8 +33,9 @@ typedef enum gbp_endpoint_attr_t_
 {
   GBP_ENDPOINT_ATTR_FIRST = 0,
   GBP_ENDPOINT_ATTR_BOUNCE = GBP_ENDPOINT_ATTR_FIRST,
-  GBP_ENDPOINT_ATTR_REMOTE = 1,
-  GBP_ENDPOINT_ATTR_LEARNT = 2,
+  GBP_ENDPOINT_ATTR_REMOTE,
+  GBP_ENDPOINT_ATTR_LEARNT,
+  GBP_ENDPOINT_ATTR_EXTERNAL,
   GBP_ENDPOINT_ATTR_LAST,
 } gbp_endpoint_attr_t;
 
@@ -43,23 +45,27 @@ typedef enum gbp_endpoint_flags_t_
   GBP_ENDPOINT_FLAG_BOUNCE = (1 << GBP_ENDPOINT_ATTR_BOUNCE),
   GBP_ENDPOINT_FLAG_REMOTE = (1 << GBP_ENDPOINT_ATTR_REMOTE),
   GBP_ENDPOINT_FLAG_LEARNT = (1 << GBP_ENDPOINT_ATTR_LEARNT),
+  GBP_ENDPOINT_FLAG_EXTERNAL = (1 << GBP_ENDPOINT_ATTR_EXTERNAL),
 } gbp_endpoint_flags_t;
 
 #define GBP_ENDPOINT_ATTR_NAMES {                 \
     [GBP_ENDPOINT_ATTR_BOUNCE] = "bounce",        \
     [GBP_ENDPOINT_ATTR_REMOTE] = "remote",        \
     [GBP_ENDPOINT_ATTR_LEARNT] = "learnt",        \
+    [GBP_ENDPOINT_ATTR_EXTERNAL] = "external",    \
 }
 
 extern u8 *format_gbp_endpoint_flags (u8 * s, va_list * args);
 
 /**
  * Sources of Endpoints in priority order. The best (lowest value) source
- * provides the forwarding information
+ * provides the forwarding information.
+ * Data-plane takes preference because the CP data is not always complete,
+ * it may not have the sclass.
  */
 #define foreach_gbp_endpoint_src    \
-  _(CP, "control-plane")            \
   _(DP, "data-plane")               \
+  _(CP, "control-plane")            \
   _(RR, "recursive-resolution")
 
 typedef enum gbp_endpoint_src_t_
@@ -117,7 +123,7 @@ typedef struct gbp_endpoint_loc_t_
   /**
    * The interface on which the EP is connected
    */
-  u32 gel_sw_if_index;
+  gbp_itf_hdl_t gel_itf;
 
   /**
    * Endpoint flags
@@ -153,7 +159,7 @@ typedef struct gbp_endpoint_fwd_t_
   /**
    * The interface on which the EP is connected
    */
-  index_t gef_itf;
+  gbp_itf_hdl_t gef_itf;
 
   /**
    * The L3 adj, if created
@@ -161,9 +167,14 @@ typedef struct gbp_endpoint_fwd_t_
   index_t *gef_adjs;
 
   /**
-   * Endpoint Group's ID. cached for fast DP access.
+   * Endpoint Group's sclass. cached for fast DP access.
+   */
+  sclass_t gef_sclass;
+
+  /**
+   * FIB index the EP is in
    */
-  epg_id_t gef_epg_id;
+  u32 gef_fib_index;
 
   gbp_endpoint_flags_t gef_flags;
 } gbp_endpoint_fwd_t;
@@ -219,7 +230,7 @@ extern int gbp_endpoint_update_and_lock (gbp_endpoint_src_t src,
                                         const ip46_address_t * ip,
                                         const mac_address_t * mac,
                                         index_t gbd, index_t grd,
-                                        epg_id_t epg_id,
+                                        sclass_t sclass,
                                         gbp_endpoint_flags_t flags,
                                         const ip46_address_t * tun_src,
                                         const ip46_address_t * tun_dst,
@@ -233,8 +244,9 @@ extern void gbp_endpoint_child_remove (index_t gei, u32 sibling);
 typedef walk_rc_t (*gbp_endpoint_cb_t) (index_t gbpei, void *ctx);
 extern void gbp_endpoint_walk (gbp_endpoint_cb_t cb, void *ctx);
 extern void gbp_endpoint_scan (vlib_main_t * vm);
-extern f64 gbp_endpoint_scan_threshold (void);
 extern int gbp_endpoint_is_remote (const gbp_endpoint_t * ge);
+extern int gbp_endpoint_is_local (const gbp_endpoint_t * ge);
+extern int gbp_endpoint_is_external (const gbp_endpoint_t * ge);
 extern int gbp_endpoint_is_learnt (const gbp_endpoint_t * ge);