X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fcnat%2Fcnat_translation.h;h=3b6e694a845754619e3577073cb69595f5049290;hb=3fd77f7de;hp=a4ae1ece71804ceabfb52ff3ab292b3cf281b16b;hpb=2082835fea3ccd85e7368327d5baa749be01b537;p=vpp.git diff --git a/src/plugins/cnat/cnat_translation.h b/src/plugins/cnat/cnat_translation.h index a4ae1ece718..3b6e694a845 100644 --- a/src/plugins/cnat/cnat_translation.h +++ b/src/plugins/cnat/cnat_translation.h @@ -25,6 +25,12 @@ */ extern vlib_combined_counter_main_t cnat_translation_counters; +typedef enum cnat_trk_flag_t_ +{ + CNAT_TRK_ACTIVE = (1 << 0), + CNAT_TRK_FLAG_NO_NAT = (1 << 1), +} cnat_trk_flag_t; + /** * Data used to track an EP in the FIB */ @@ -53,7 +59,7 @@ typedef struct cnat_ep_trk_t_ /** * Allows to disable if not resolved yet */ - u8 is_active; + u8 ct_flags; /* cnat_trk_flag_t */ } cnat_ep_trk_t; typedef enum cnat_translation_flag_t_ @@ -75,6 +81,12 @@ typedef enum CNAT_ADDR_N_RESOLUTIONS, } cnat_addr_resol_type_t; +typedef enum __attribute__ ((__packed__)) +{ + CNAT_LB_DEFAULT, + CNAT_LB_MAGLEV, +} cnat_lb_type_t; + /** * Entry used to account for a translation's backend * waiting for address resolution @@ -129,6 +141,11 @@ typedef struct cnat_translation_t_ */ cnat_ep_trk_t *ct_paths; + /** + * The vector of active tracked back-ends + */ + cnat_ep_trk_t *ct_active_paths; + /** * The ip protocol for the translation */ @@ -149,6 +166,16 @@ typedef struct cnat_translation_t_ * Translation flags */ u8 flags; + + /** + * Type of load balancing + */ + cnat_lb_type_t lb_type; + + union + { + u32 *lb_maglev; + }; } cnat_translation_t; extern cnat_translation_t *cnat_translation_pool; @@ -164,10 +191,10 @@ extern u8 *format_cnat_translation (u8 * s, va_list * args); * * @return the ID of the translation. used to delete and gather stats */ -extern u32 cnat_translation_update (cnat_endpoint_t * vip, +extern u32 cnat_translation_update (cnat_endpoint_t *vip, ip_protocol_t ip_proto, - cnat_endpoint_tuple_t * - backends, u8 flags); + cnat_endpoint_tuple_t *backends, u8 flags, + cnat_lb_type_t lb_type); /** * Delete a translation @@ -204,6 +231,15 @@ extern void cnat_translation_watch_addr (index_t cti, u64 opaque, extern void cnat_translation_unwatch_addr (u32 cti, cnat_addr_resol_type_t type); +/** + * Register a call back for endpoint->address resolution + */ +typedef void (*cnat_if_addr_add_cb_t) (addr_resolution_t *ar, + ip_address_t *address, u8 is_del); + +extern void cnat_translation_register_addr_add_cb (cnat_addr_resol_type_t typ, + cnat_if_addr_add_cb_t fn); + /* * Data plane functions */ @@ -222,7 +258,7 @@ cnat_find_translation (index_t cti, u16 port, ip_protocol_t proto) u64 key; int rv; - key = (proto << 24) | port; + key = ((u64) proto << 24) | port; key = key << 32 | (u32) cti; bkey.key = key;