summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44-ed
diff options
context:
space:
mode:
authorAndrew Yourtchenko <ayourtch@gmail.com>2021-09-09 21:12:33 +0200
committerFlorin Coras <florin.coras@gmail.com>2021-09-09 20:19:53 +0000
commit2ac5c11cd32795ec917ff038262aee113d9e792a (patch)
tree91ce0f50ad7a6d7603cba8e932278711df9f8a3a /src/plugins/nat/nat44-ed
parent2abbdecc9b27f3c2c3aafe0b58b34fad8063b461 (diff)
nat: Revert "nat: nat44-ed add session timing out indicator in api"
This reverts commit f059a3452c285ec57a75c7b1ede5052244be4e5d, which broke the build. https://s3-logs.fd.io/logs/production/vex-yul-rot-jenkins-1/vpp-merge-master-debian10-x86_64/1344/console.log.gz Change-Id: I16fece8128fa9973495c587d105a8db57738e8f2 Type: fix Signed-off-by: Andrew Yourtchenko <ayourtch@gmail.com>
Diffstat (limited to 'src/plugins/nat/nat44-ed')
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.api58
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed_api.c93
2 files changed, 1 insertions, 150 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.api b/src/plugins/nat/nat44-ed/nat44_ed.api
index bff00b809e0..c65b7a81166 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.api
+++ b/src/plugins/nat/nat44-ed/nat44_ed.api
@@ -13,7 +13,7 @@
* limitations under the License.
*/
-option version = "5.4.0";
+option version = "5.3.0";
import "vnet/ip/ip_types.api";
import "vnet/interface_types.api";
import "plugins/nat/lib/nat_types.api";
@@ -1040,62 +1040,6 @@ define nat44_user_session_details {
u16 ext_host_nat_port;
};
-/** \brief NAT44 user's sessions
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param ip_address - IPv4 address of the user to dump
- @param vrf_id - VRF_ID
-*/
-define nat44_user_session_v2_dump {
- option in_progress;
- u32 client_index;
- u32 context;
- vl_api_ip4_address_t ip_address;
- u32 vrf_id;
-};
-
-/** \brief NAT44 user's sessions response
- @param context - sender context, to match reply w/ request
- @param outside_ip_address - outside IPv4 address
- @param outside_port - outside port
- @param inside_ip_address - inside IPv4 address
- @param inside_port - inside port
- @param protocol - protocol
- @param flags - flag NAT_IS_STATIC if session is static,
- flag NAT_IS_TWICE_NAT if session is twice-nat,
- flag NAT_IS_EXT_HOST_VALID if external host address
- and port are valid
- @param last_heard - last heard timer
- @param total_bytes - count of bytes sent through session
- @param total_pkts - count of pakets sent through session
- @param ext_host_address - external host IPv4 address
- @param ext_host_port - external host port
- @param ext_host_nat_address - post-NAT external host IPv4 address (valid
- only if twice-nat session)
- @param ext_host_nat_port - post-NAT external host port (valid only if
- twice-nat session)
- @param is_timed_out - true, if session is timed out, and false, if session
- is active
-*/
-define nat44_user_session_v2_details {
- option in_progress;
- u32 context;
- vl_api_ip4_address_t outside_ip_address;
- u16 outside_port;
- vl_api_ip4_address_t inside_ip_address;
- u16 inside_port;
- u16 protocol;
- vl_api_nat_config_flags_t flags;
- u64 last_heard;
- u64 total_bytes;
- u32 total_pkts;
- vl_api_ip4_address_t ext_host_address;
- u16 ext_host_port;
- vl_api_ip4_address_t ext_host_nat_address;
- u16 ext_host_nat_port;
- bool is_timed_out;
-};
-
/** \brief NAT44 load-balancing address and port pair
@param addr - IPv4 address of the internal node
@param port - L4 port number of the internal node
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_api.c b/src/plugins/nat/nat44-ed/nat44_ed_api.c
index e9c11c0ea5b..64946c7b640 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed_api.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed_api.c
@@ -1676,99 +1676,6 @@ vl_api_nat44_user_session_dump_t_handler (vl_api_nat44_user_session_dump_t *
}
}
-static void
-send_nat44_user_session_v2_details (snat_session_t *s,
- vl_api_registration_t *reg, u32 context)
-{
- vl_api_nat44_user_session_v2_details_t *rmp;
- snat_main_t *sm = &snat_main;
- u64 now = vlib_time_now (sm->vnet_main->vlib_main);
- u64 sess_timeout_time = 0;
-
- rmp = vl_msg_api_alloc (sizeof (*rmp));
- clib_memset (rmp, 0, sizeof (*rmp));
- rmp->_vl_msg_id =
- ntohs (VL_API_NAT44_USER_SESSION_V2_DETAILS + sm->msg_id_base);
- clib_memcpy (rmp->outside_ip_address, (&s->out2in.addr), 4);
- clib_memcpy (rmp->inside_ip_address, (&s->in2out.addr), 4);
-
- if (snat_is_session_static (s))
- rmp->flags |= NAT_API_IS_STATIC;
-
- if (is_twice_nat_session (s))
- rmp->flags |= NAT_API_IS_TWICE_NAT;
-
- if (is_ed_session (s) || is_fwd_bypass_session (s))
- rmp->flags |= NAT_API_IS_EXT_HOST_VALID;
-
- rmp->last_heard = clib_host_to_net_u64 ((u64) s->last_heard);
- rmp->total_bytes = clib_host_to_net_u64 (s->total_bytes);
- rmp->total_pkts = ntohl (s->total_pkts);
- rmp->context = context;
- if (snat_is_unk_proto_session (s))
- {
- rmp->outside_port = 0;
- rmp->inside_port = 0;
- rmp->protocol = ntohs (s->in2out.port);
- }
- else
- {
- rmp->outside_port = s->out2in.port;
- rmp->inside_port = s->in2out.port;
- rmp->protocol = ntohs (nat_proto_to_ip_proto (s->nat_proto));
- }
- if (is_ed_session (s) || is_fwd_bypass_session (s))
- {
- clib_memcpy (rmp->ext_host_address, &s->ext_host_addr, 4);
- rmp->ext_host_port = s->ext_host_port;
- if (is_twice_nat_session (s))
- {
- clib_memcpy (rmp->ext_host_nat_address, &s->ext_host_nat_addr, 4);
- rmp->ext_host_nat_port = s->ext_host_nat_port;
- }
- }
-
- sess_timeout_time = s->last_heard + (f64) nat_session_get_timeout (
- &sm->timeouts, s->nat_proto, s->state);
- rmp->is_timed_out = (now >= sess_timeout_time);
-
- vl_api_send_msg (reg, (u8 *) rmp);
-}
-
-static void
-vl_api_nat44_user_session_v2_dump_t_handler (
- vl_api_nat44_user_session_v2_dump_t *mp)
-{
- snat_main_per_thread_data_t *tsm;
- snat_main_t *sm = &snat_main;
- vl_api_registration_t *reg;
- snat_user_key_t ukey;
- snat_session_t *s;
- ip4_header_t ip;
-
- reg = vl_api_client_index_to_registration (mp->client_index);
- if (!reg)
- return;
-
- clib_memcpy (&ukey.addr, mp->ip_address, 4);
- ip.src_address.as_u32 = ukey.addr.as_u32;
- ukey.fib_index = fib_table_find (FIB_PROTOCOL_IP4, ntohl (mp->vrf_id));
- if (sm->num_workers > 1)
- tsm = vec_elt_at_index (
- sm->per_thread_data,
- nat44_ed_get_in2out_worker_index (0, &ip, ukey.fib_index, 0));
- else
- tsm = vec_elt_at_index (sm->per_thread_data, sm->num_workers);
-
- pool_foreach (s, tsm->sessions)
- {
- if (s->in2out.addr.as_u32 == ukey.addr.as_u32)
- {
- send_nat44_user_session_v2_details (s, reg, mp->context);
- }
- }
-}
-
/* API definitions */
#include <vnet/format_fns.h>
#include <nat/nat44-ed/nat44_ed.api.c>
*/ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright (c) 2015 Cisco and/or its affiliates.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at:
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * init.h: mechanism for functions to be called at init/exit.
 *
 * Copyright (c) 2008 Eliot Dresselhaus
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 *  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 *  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 *  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef included_vlib_init_h
#define included_vlib_init_h

#include <vppinfra/error.h>
#include <vppinfra/format.h>
#include <vppinfra/hash.h>

/* Init/exit functions: called at start/end of main routine.  Init
   functions are typically used to register and setup packet
   processing nodes.  */

typedef clib_error_t *(vlib_init_function_t) (struct vlib_main_t * vm);

typedef struct _vlib_init_function_list_elt
{
  struct _vlib_init_function_list_elt *next_init_function;
  vlib_init_function_t *f;
} _vlib_init_function_list_elt_t;

/* Configuration functions: called with configuration input just before
   main polling loop starts. */
typedef clib_error_t *(vlib_config_function_t) (struct vlib_main_t * vm,
						unformat_input_t * input);

typedef struct vlib_config_function_runtime_t
{
  /* Function to call.  Set to null once function has already been called. */
  vlib_config_function_t *function;

  /* Input for function. */
  unformat_input_t input;

  /* next config function registration */
  struct vlib_config_function_runtime_t *next_registration;

  /* To be invoked as soon as the clib heap is available */
  u8 is_early;

  /* Name used to distinguish input on command line. */
  char name[32];
} vlib_config_function_runtime_t;

#define _VLIB_INIT_FUNCTION_SYMBOL(x, type)	\
  _vlib_##type##_function_##x

#define VLIB_INIT_FUNCTION_SYMBOL(x)		\
  _VLIB_INIT_FUNCTION_SYMBOL(x, init)
#define VLIB_MAIN_LOOP_ENTER_FUNCTION_SYMBOL(x)		\
  _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_enter)
#define VLIB_MAIN_LOOP_EXIT_FUNCTION_SYMBOL(x)	\
  _VLIB_INIT_FUNCTION_SYMBOL(x, main_loop_exit)
#define VLIB_CONFIG_FUNCTION_SYMBOL(x)		\
  _VLIB_INIT_FUNCTION_SYMBOL(x, config)

/* Declaration is global (e.g. not static) so that init functions can
   be called from other modules to resolve init function depend. */

#define VLIB_DECLARE_INIT_FUNCTION(x, tag)                      \
vlib_init_function_t * _VLIB_INIT_FUNCTION_SYMBOL (x, tag) = x; \
static void __vlib_add_##tag##_function_##x (void)              \
    __attribute__((__constructor__)) ;                          \
static void __vlib_add_##tag##_function_##x (void)              \
{                                                               \
 vlib_main_t * vm = vlib_get_main();                            \
 static _vlib_init_function_list_elt_t _vlib_init_function;     \
 _vlib_init_function.next_init_function                         \
    = vm->tag##_function_registrations;                         \
  vm->tag##_function_registrations = &_vlib_init_function;      \
 _vlib_init_function.f = &x;                                    \
}

#define VLIB_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,init)
#define VLIB_WORKER_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,worker_init)

#define VLIB_MAIN_LOOP_ENTER_FUNCTION(x) \
  VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter)
#define VLIB_MAIN_LOOP_EXIT_FUNCTION(x) \
VLIB_DECLARE_INIT_FUNCTION(x,main_loop_exit)

#define VLIB_CONFIG_FUNCTION(x,n,...)                           \
    __VA_ARGS__ vlib_config_function_runtime_t                  \
    VLIB_CONFIG_FUNCTION_SYMBOL(x);                             \
static void __vlib_add_config_function_##x (void)               \
    __attribute__((__constructor__)) ;                          \
static void __vlib_add_config_function_##x (void)               \
{                                                               \
    vlib_main_t * vm = vlib_get_main();                         \
    VLIB_CONFIG_FUNCTION_SYMBOL(x).next_registration            \
       = vm->config_function_registrations;                     \
    vm->config_function_registrations                           \
       = &VLIB_CONFIG_FUNCTION_SYMBOL(x);                       \
}                                                               \
  vlib_config_function_runtime_t                                \
    VLIB_CONFIG_FUNCTION_SYMBOL (x)                             \
  = {                                                           \
    .name = n,                                                  \
    .function = x,                                              \
    .is_early = 0,						\
  }

#define VLIB_EARLY_CONFIG_FUNCTION(x,n,...)                     \
    __VA_ARGS__ vlib_config_function_runtime_t                  \
    VLIB_CONFIG_FUNCTION_SYMBOL(x);                             \
static void __vlib_add_config_function_##x (void)               \
    __attribute__((__constructor__)) ;                          \
static void __vlib_add_config_function_##x (void)               \
{                                                               \
    vlib_main_t * vm = vlib_get_main();                         \
    VLIB_CONFIG_FUNCTION_SYMBOL(x).next_registration            \
       = vm->config_function_registrations;                     \
    vm->config_function_registrations                           \
       = &VLIB_CONFIG_FUNCTION_SYMBOL(x);                       \
}                                                               \
  vlib_config_function_runtime_t                                \
    VLIB_CONFIG_FUNCTION_SYMBOL (x)                             \
  = {                                                           \
    .name = n,                                                  \
    .function = x,                                              \
    .is_early = 1,						\
  }

/* Call given init function: used for init function dependencies. */
#define vlib_call_init_function(vm, x)					\
  ({									\
    extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (x);	\
    vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (x);		\
    clib_error_t * _error = 0;						\
    if (! hash_get (vm->init_functions_called, _f))			\
      {									\
	hash_set1 (vm->init_functions_called, _f);			\
	_error = _f (vm);						\
      }									\
    _error;								\
  })

/* Don't call given init function: used to suppress parts of the netstack */
#define vlib_mark_init_function_complete(vm, x)				\
  ({									\
    extern vlib_init_function_t * VLIB_INIT_FUNCTION_SYMBOL (x);	\
    vlib_init_function_t * _f = VLIB_INIT_FUNCTION_SYMBOL (x);		\
    hash_set1 (vm->init_functions_called, _f);				\
  })

#define vlib_call_post_graph_init_function(vm, x)			\
  ({									\
    extern vlib_init_function_t * VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \
    vlib_init_function_t * _f = VLIB_POST_GRAPH_INIT_FUNCTION_SYMBOL (x); \
    clib_error_t * _error = 0;						\
    if (! hash_get (vm->init_functions_called, _f))			\
      {									\
	hash_set1 (vm->init_functions_called, _f);			\
	_error = _f (vm);						\
      }									\
    _error;								\
  })

#define vlib_call_config_function(vm, x)			\
  ({								\
    vlib_config_function_runtime_t * _r;			\
    clib_error_t * _error = 0;					\
    extern vlib_config_function_runtime_t			\
      VLIB_CONFIG_FUNCTION_SYMBOL (x);				\
								\
    _r = &VLIB_CONFIG_FUNCTION_SYMBOL (x);			\
    if (! hash_get (vm->init_functions_called, _r->function))	\
      {								\
        hash_set1 (vm->init_functions_called, _r->function);	\
	_error = _r->function (vm, &_r->input);			\
      }								\
    _error;							\
  })

/* External functions. */
clib_error_t *vlib_call_all_init_functions (struct vlib_main_t *vm);
clib_error_t *vlib_call_all_config_functions (struct vlib_main_t *vm,
					      unformat_input_t * input,
					      int is_early);
clib_error_t *vlib_call_all_main_loop_enter_functions (struct vlib_main_t
						       *vm);
clib_error_t *vlib_call_all_main_loop_exit_functions (struct vlib_main_t *vm);
clib_error_t *vlib_call_init_exit_functions (struct vlib_main_t *vm,
					     _vlib_init_function_list_elt_t *
					     head, int call_once);

#define foreach_vlib_module_reference		\
  _ (node_cli)					\
  _ (trace_cli)

/* Dummy function to get node_cli.c linked in. */
#define _(x) void vlib_##x##_reference (void);
foreach_vlib_module_reference
#undef _
#endif /* included_vlib_init_h */
/*
 * fd.io coding-style-patch-verification: ON
 *
 * Local Variables:
 * eval: (c-set-style "gnu")
 * End:
 */