X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fcnat%2Fcnat_session.h;h=072bb10f96f9e41a428278fdd9e02d09641e8c55;hb=2430bad8951a321e0fcb50eafb562ecbdbecbb5b;hp=9e1e89342a83c4b24360789acf4afec0999e4cfb;hpb=29f3c7d2ecac2f9d80bb33e91bd5d1f9d434768a;p=vpp.git diff --git a/src/plugins/cnat/cnat_session.h b/src/plugins/cnat/cnat_session.h index 9e1e89342a8..072bb10f96f 100644 --- a/src/plugins/cnat/cnat_session.h +++ b/src/plugins/cnat/cnat_session.h @@ -16,12 +16,11 @@ #ifndef __CNAT_SESSION_H__ #define __CNAT_SESSION_H__ -#include +#include #include #include -#include - +#include /** * A session represents the memory of a translation. @@ -63,9 +62,11 @@ typedef struct cnat_session_t_ u8 cs_af; /** - * spare space + * input / output / fib session */ - u8 __cs_pad[2]; + u8 cs_loc; + + u8 __cs_pad; } key; /** * this value sits in the same memory location a 'value' in the bihash kvp @@ -87,43 +88,74 @@ typedef struct cnat_session_t_ */ index_t cs_lbi; + /** + * Persist translation->ct_lb.dpoi_next_node + */ + u32 dpoi_next_node; + /** * Timestamp index this session was last used */ u32 cs_ts_index; + /** - * Indicates a return path session that was source NATed - * on the way in. + * session flags */ u32 flags; + + u32 __pad; } value; } cnat_session_t; typedef enum cnat_session_flag_t_ { + /** + * Indicates a return path session that was source NATed + * on the way in. + */ CNAT_SESSION_FLAG_HAS_SNAT = (1 << 0), + /** + * This session source port was allocated, free it on cleanup + */ CNAT_SESSION_FLAG_ALLOC_PORT = (1 << 1), + /** + * This session doesn't have a client, do not attempt to free it + */ CNAT_SESSION_FLAG_NO_CLIENT = (1 << 2), + + /* Do not actually translate the packet but still forward it + * Used for Maglev, with an encap */ + CNAT_SESSION_FLAG_NO_NAT = (1 << 3), + + /* Debug flag marking return sessions */ + CNAT_SESSION_IS_RETURN = (1 << 4), } cnat_session_flag_t; +typedef enum cnat_session_location_t_ +{ + CNAT_LOCATION_INPUT = 0, + CNAT_LOCATION_OUTPUT = 1, + CNAT_LOCATION_FIB = 0xff, +} cnat_session_location_t; + extern u8 *format_cnat_session (u8 * s, va_list * args); /** * Ensure the session object correctly overlays the bihash key/value pair */ STATIC_ASSERT (STRUCT_OFFSET_OF (cnat_session_t, key) == - STRUCT_OFFSET_OF (clib_bihash_kv_40_48_t, key), + STRUCT_OFFSET_OF (cnat_bihash_kv_t, key), "key overlaps"); STATIC_ASSERT (STRUCT_OFFSET_OF (cnat_session_t, value) == - STRUCT_OFFSET_OF (clib_bihash_kv_40_48_t, value), + STRUCT_OFFSET_OF (cnat_bihash_kv_t, value), "value overlaps"); -STATIC_ASSERT (sizeof (cnat_session_t) == sizeof (clib_bihash_kv_40_48_t), +STATIC_ASSERT (sizeof (cnat_session_t) == sizeof (cnat_bihash_kv_t), "session kvp"); /** * The DB of sessions */ -extern clib_bihash_40_48_t cnat_session_db; +extern cnat_bihash_t cnat_session_db; /** * Callback function invoked during a walk of all translations @@ -146,6 +178,16 @@ extern u64 cnat_session_scan (vlib_main_t * vm, f64 start_time, int i); */ extern int cnat_session_purge (void); +/** + * Free a session & update refcounts + */ +extern void cnat_session_free (cnat_session_t * session); + +/** + * Port cleanup callback + */ +extern void (*cnat_free_port_cb) (u16 port, ip_protocol_t iproto); + /* * fd.io coding-style-patch-verification: ON *