NAT: Rename snat plugin to nat (VPP-955)

Change-Id: I30a7e3da7a4efc6038a91e27b48045d4b07e2764
Signed-off-by: Matus Fabian <matfabia@cisco.com>
This commit is contained in:
Matus Fabian
2017-08-21 07:05:03 -07:00
committed by Ole Trøan
parent cfc997ef3d
commit 2ba92e32e0
38 changed files with 2858 additions and 968 deletions

@ -169,7 +169,7 @@ PLUGIN_ENABLED(lb)
PLUGIN_ENABLED(memif)
PLUGIN_ENABLED(pppoe)
PLUGIN_ENABLED(sixrd)
PLUGIN_ENABLED(snat)
PLUGIN_ENABLED(nat)
###############################################################################
# Dependency checks

@ -29,7 +29,7 @@ Now run VPP and make sure the plugin is loaded.
...
load_one_plugin:184: Loaded plugin: memif_plugin.so (Packet Memory Interface (experimetal))
load_one_plugin:184: Loaded plugin: sample_plugin.so (Sample of VPP Plugin)
load_one_plugin:184: Loaded plugin: snat_plugin.so (Network Address Translation)
load_one_plugin:184: Loaded plugin: nat_plugin.so (Network Address Translation)
...
DBGvpp#

@ -74,8 +74,8 @@ if ENABLE_SIXRD_PLUGIN
include sixrd.am
endif
if ENABLE_SNAT_PLUGIN
include snat.am
if ENABLE_NAT_PLUGIN
include nat.am
endif
include ../suffix-rules.mk

41
src/plugins/nat.am Normal file

@ -0,0 +1,41 @@
# Copyright (c) <current-year> <your-organization>
# 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.
vppapitestplugins_LTLIBRARIES += nat_test_plugin.la
vppplugins_LTLIBRARIES += nat_plugin.la
nat_plugin_la_SOURCES = nat/nat.c \
nat/nat_api.c \
nat/in2out.c \
nat/out2in.c \
nat/nat_plugin.api.h \
nat/nat_ipfix_logging.c \
nat/nat_det.c \
nat/nat64.c \
nat/nat64_cli.c \
nat/nat64_in2out.c \
nat/nat64_out2in.c \
nat/nat64_db.c
API_FILES += nat/nat.api
nobase_apiinclude_HEADERS += \
nat/nat_all_api_h.h \
nat/nat_msg_enum.h \
nat/nat.api.h
nat_test_plugin_la_SOURCES = \
nat/nat_test.c nat/nat_plugin.api.h
# vi:syntax=automake

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
/*
* snat.h - simple nat definitions
* nat.h - NAT plugin definitions
*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -15,8 +15,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __included_snat_h__
#define __included_snat_h__
#ifndef __included_nat_h__
#define __included_nat_h__
#include <vnet/vnet.h>
#include <vnet/ip/ip.h>
@ -41,9 +41,9 @@
/* Key */
typedef struct {
union
union
{
struct
struct
{
ip4_address_t addr;
u16 port;
@ -156,7 +156,7 @@ typedef CLIB_PACKED(struct {
f64 last_heard; /* 44-51 */
u64 total_bytes; /* 52-59 */
u32 total_pkts; /* 60-63 */
/* Outside address */
@ -418,12 +418,12 @@ typedef struct {
*/
#define snat_is_unk_proto_session(s) s->flags & SNAT_SESSION_FLAG_UNKNOWN_PROTO
/*
/*
* Why is this here? Because we don't need to touch this layer to
* simply reply to an icmp. We need to change id to a unique
* value to NAT an echo request/reply.
*/
typedef struct {
u16 identifier;
u16 sequence;
@ -538,4 +538,4 @@ is_interface_addr(snat_main_t *sm, vlib_node_runtime_t *node, u32 sw_if_index0,
return 0;
}
#endif /* __included_snat_h__ */
#endif /* __included_nat_h__ */

@ -17,8 +17,8 @@
* @brief NAT64 implementation
*/
#include <snat/nat64.h>
#include <snat/nat64_db.h>
#include <nat/nat64.h>
#include <nat/nat64_db.h>
#include <vnet/fib/ip4_fib.h>

@ -19,8 +19,8 @@
#ifndef __included_nat64_h__
#define __included_nat64_h__
#include <snat/snat.h>
#include <snat/nat64_db.h>
#include <nat/nat.h>
#include <nat/nat64_db.h>
#define foreach_nat64_tcp_ses_state \
_(0, CLOSED, "closed") \

@ -17,8 +17,8 @@
* @brief NAT64 CLI
*/
#include <snat/nat64.h>
#include <snat/snat.h>
#include <nat/nat64.h>
#include <nat/nat.h>
#include <vnet/fib/fib_table.h>
static clib_error_t *

@ -16,7 +16,7 @@
* @file
* @brief NAT64 DB
*/
#include <snat/nat64_db.h>
#include <nat/nat64_db.h>
int
nat64_db_init (nat64_db_t * db)

@ -21,7 +21,7 @@
#include <vppinfra/bihash_24_8.h>
#include <vppinfra/bihash_48_8.h>
#include <snat/snat.h>
#include <nat/nat.h>
typedef struct

@ -17,7 +17,7 @@
* @brief NAT64 IPv6 to IPv4 translation (inside to outside network)
*/
#include <snat/nat64.h>
#include <nat/nat64.h>
#include <vnet/ip/ip6_to_ip4.h>
#include <vnet/fib/fib_table.h>

@ -17,7 +17,7 @@
* @brief NAT64 IPv4 to IPv6 translation (otside to inside network)
*/
#include <snat/nat64.h>
#include <nat/nat64.h>
#include <vnet/ip/ip4_to_ip6.h>
#include <vnet/fib/ip4_fib.h>

@ -1,6 +1,6 @@
/*
* snat_all_api_h.h - skeleton vpp engine plug-in api #include file
* nat_all_api_h.h - skeleton vpp engine plug-in api #include file
*
* Copyright (c) <current-year> <your-organization>
* Licensed under the Apache License, Version 2.0 (the "License");
@ -16,4 +16,4 @@
* limitations under the License.
*/
/* Include the generated file, see BUILT_SOURCES in Makefile.am */
#include <snat/snat.api.h>
#include <nat/nat.api.h>

File diff suppressed because it is too large Load Diff

@ -19,7 +19,7 @@
* @brief deterministic NAT
*/
#include <snat/snat_det.h>
#include <nat/nat_det.h>
/**
@ -105,7 +105,7 @@ snat_det_add_map (snat_main_t * sm, ip4_address_t * in_addr, u8 in_plen,
}
/**
* @brief The 'snat-det-expire-walk' process's main loop.
* @brief The 'nat-det-expire-walk' process's main loop.
*
* Check expire time for active sessions.
*/
@ -145,7 +145,7 @@ VLIB_REGISTER_NODE (snat_det_expire_walk_node, static) = {
.function = snat_det_expire_walk_fn,
.type = VLIB_NODE_TYPE_PROCESS,
.name =
"snat-det-expire-walk",
"nat-det-expire-walk",
};
/* *INDENT-ON* */

@ -1,5 +1,5 @@
/*
* snat_det.h - deterministic nat definitions
* snat_det.h - deterministic NAT definitions
*
* Copyright (c) 2017 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -19,12 +19,12 @@
* @brief deterministic NAT definitions
*/
#ifndef __included_snat_det_h__
#define __included_snat_det_h__
#ifndef __included_nat_det_h__
#define __included_nat_det_h__
#include <vnet/ip/ip.h>
#include <snat/snat.h>
#include <snat/snat_ipfix_logging.h>
#include <nat/nat.h>
#include <nat/nat_ipfix_logging.h>
#define SNAT_DET_SES_PER_USER 1000
@ -185,7 +185,7 @@ snat_det_ses_close (snat_det_map_t * dm, snat_det_session_t * ses)
}
}
#endif /* __included_snat_det_h__ */
#endif /* __included_nat_det_h__ */
/*
* fd.io coding-style-patch-verification: ON

@ -1,5 +1,5 @@
/*
* snat_ipfix_logging.c - NAT Events IPFIX logging
* nat_ipfix_logging.c - NAT Events IPFIX logging
*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -17,8 +17,8 @@
#include <vnet/flow/flow_report.h>
#include <vlibmemory/api.h>
#include <snat/snat.h>
#include <snat/snat_ipfix_logging.h>
#include <nat/nat.h>
#include <nat/nat_ipfix_logging.h>
snat_ipfix_logging_main_t snat_ipfix_logging_main;
@ -610,7 +610,7 @@ snat_ipfix_logging_nat44_ses_rpc_cb (snat_ipfix_logging_nat44_ses_args_t *a)
*
* @param src_ip source IPv4 address
* @param nat_src_ip transaltes source IPv4 address
* @param snat_proto SNAT transport protocol
* @param snat_proto NAT transport protocol
* @param src_port source port
* @param nat_src_port translated source port
* @param vrf_id VRF ID
@ -642,7 +642,7 @@ snat_ipfix_logging_nat44_ses_create (u32 src_ip,
*
* @param src_ip source IPv4 address
* @param nat_src_ip transaltes source IPv4 address
* @param snat_proto SNAT transport protocol
* @param snat_proto NAT transport protocol
* @param src_port source port
* @param nat_src_port translated source port
* @param vrf_id VRF ID
@ -751,7 +751,7 @@ snat_data_callback_max_entries_per_usr (flow_report_main_t * frm,
}
/**
* @brief Enable/disable SNAT IPFIX logging
* @brief Enable/disable NAT plugin IPFIX logging
*
* @param enable 1 if enable, 0 if disable
* @param domain_id observation domain ID
@ -818,7 +818,7 @@ snat_ipfix_logging_enable_disable (int enable, u32 domain_id, u16 src_port)
}
/**
* @brief Initialize SNAT IPFIX logging
* @brief Initialize NAT plugin IPFIX logging
*
* @param vm vlib main
*/

@ -1,5 +1,5 @@
/*
* snat_ipfix_logging.h - NAT Events IPFIX logging
* nat_ipfix_logging.h - NAT Events IPFIX logging
*
* Copyright (c) 2016 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __included_snat_ipfix_logging_h__
#define __included_snat_ipfix_logging_h__
#ifndef __included_nat_ipfix_logging_h__
#define __included_nat_ipfix_logging_h__
typedef enum {
NAT_ADDRESSES_EXHAUTED = 3,
@ -30,7 +30,7 @@ typedef enum {
} quota_exceed_event_t;
typedef struct {
/** S-NAT IPFIX logging enabled */
/** NAT plugin IPFIX logging enabled */
u8 enabled;
/** ipfix buffers under construction */
@ -76,4 +76,4 @@ void snat_ipfix_logging_nat44_ses_delete (u32 src_ip, u32 nat_src_ip,
void snat_ipfix_logging_addresses_exhausted(u32 pool_id);
void snat_ipfix_logging_max_entries_per_user(u32 src_ip);
#endif /* __included_snat_ipfix_logging_h__ */
#endif /* __included_nat_ipfix_logging_h__ */

@ -1,6 +1,6 @@
/*
* snat_msg_enum.h - skeleton vpp engine plug-in message enumeration
* nat_msg_enum.h - skeleton vpp engine plug-in message enumeration
*
* Copyright (c) <current-year> <your-organization>
* Licensed under the Apache License, Version 2.0 (the "License");
@ -15,17 +15,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef included_snat_msg_enum_h
#define included_snat_msg_enum_h
#ifndef included_nat_msg_enum_h
#define included_nat_msg_enum_h
#include <vppinfra/byte_order.h>
#define vl_msg_id(n,h) n,
typedef enum {
#include <snat/snat_all_api_h.h>
#include <nat/nat_all_api_h.h>
/* We'll want to know how many messages IDs we need... */
VL_MSG_FIRST_AVAILABLE,
} vl_msg_id_t;
#undef vl_msg_id
#endif /* included_snat_msg_enum_h */
#endif /* included_nat_msg_enum_h */

@ -1,6 +1,6 @@
/*
* snat.c - skeleton vpp-api-test plug-in
* nat.c - skeleton vpp-api-test plug-in
*
* Copyright (c) <current-year> <your-organization>
* Licensed under the Apache License, Version 2.0 (the "License");
@ -21,7 +21,7 @@
#include <vlibsocket/api.h>
#include <vppinfra/error.h>
#include <vnet/ip/ip.h>
#include <snat/snat.h>
#include <nat/nat.h>
#define __plugin_msg_base snat_test_main.msg_id_base
#include <vlibapi/vat_helper_macros.h>
@ -29,28 +29,28 @@
uword unformat_sw_if_index (unformat_input_t * input, va_list * args);
/* Declare message IDs */
#include <snat/snat_msg_enum.h>
#include <nat/nat_msg_enum.h>
/* define message structures */
#define vl_typedefs
#include <snat/snat_all_api_h.h>
#include <nat/nat_all_api_h.h>
#undef vl_typedefs
/* declare message handlers for each api */
#define vl_endianfun /* define message structures */
#include <snat/snat_all_api_h.h>
#include <nat/nat_all_api_h.h>
#undef vl_endianfun
/* instantiate all the print functions we know about */
#define vl_print(handle, ...)
#define vl_printfun
#include <snat/snat_all_api_h.h>
#include <nat/nat_all_api_h.h>
#undef vl_printfun
/* Get the API version number. */
#define vl_api_version(n,v) static u32 api_version=(v);
#include <snat/snat_all_api_h.h>
#include <nat/nat_all_api_h.h>
#undef vl_api_version
typedef struct {

File diff suppressed because it is too large Load Diff

@ -1,41 +0,0 @@
# Copyright (c) <current-year> <your-organization>
# 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.
vppapitestplugins_LTLIBRARIES += snat_test_plugin.la
vppplugins_LTLIBRARIES += snat_plugin.la
snat_plugin_la_SOURCES = snat/snat.c \
snat/snat_api.c \
snat/in2out.c \
snat/out2in.c \
snat/snat_plugin.api.h \
snat/snat_ipfix_logging.c \
snat/snat_det.c \
snat/nat64.c \
snat/nat64_cli.c \
snat/nat64_in2out.c \
snat/nat64_out2in.c \
snat/nat64_db.c
API_FILES += snat/snat.api
nobase_apiinclude_HEADERS += \
snat/snat_all_api_h.h \
snat/snat_msg_enum.h \
snat/snat.api.h
snat_test_plugin_la_SOURCES = \
snat/snat_test.c snat/snat_plugin.api.h
# vi:syntax=automake

@ -30,7 +30,7 @@ packet-generator new {
}
}
snat add address 172.16.1.3
nat44 add address 172.16.1.3
set int ip address pg0 10.0.0.1/24
set int ip address pg1 172.16.1.1/24
set int state pg0 up
@ -38,4 +38,4 @@ set int state pg1 up
set ip arp static pg0 10.0.0.3 abcd.abcd.abcd
set ip arp static pg0 10.0.0.4 abcd.abcd.abcd
set ip arp static pg1 172.16.1.2 cdef.abcd.abcd
set int snat in pg0 out pg1
set int nat44 in pg0 out pg1

@ -96,7 +96,7 @@ packet-generator new {
}
}
snat deterministic add in 10.0.0.0/21 out 1.1.1.2/32
nat44 deterministic add in 10.0.0.0/21 out 1.1.1.2/32
set int ip address pg0 10.0.0.1/24
set int ip address pg1 172.16.1.1/24
set int state pg0 up
@ -104,5 +104,5 @@ set int state pg1 up
set ip arp static pg0 10.0.0.3 abcd.abcd.abcd
set ip arp static pg0 10.0.0.4 abcd.abcd.abcd
set ip arp static pg1 172.16.1.2 cdef.abcd.abcd
set int snat in pg0 out pg1
set int nat44 in pg0 out pg1
trace add pg-input 10

@ -32,13 +32,13 @@ packet-generator new {
}
}
snat add address 172.16.1.3
snat add static mapping local 10.0.0.3 external 172.16.1.3
nat44 add address 172.16.1.3
nat44 add static mapping local 10.0.0.3 external 172.16.1.3
set int ip address pg0 10.0.0.1/24
set int ip address pg1 172.16.1.1/24
set int state pg0 up
set int state pg1 up
set ip arp static pg0 10.0.0.3 abcd.abcd.abcd
set ip arp static pg1 172.16.1.2 cdef.abcd.abcd
set int snat in pg0 out pg1
set int nat44 in pg0 out pg1
trace add pg-input 10

@ -32,13 +32,13 @@ packet-generator new {
}
}
snat add address 172.16.1.3
snat add static mapping local 10.0.0.3 3000 external 172.16.1.3 3000
nat44 add address 172.16.1.3
nat44 add static mapping local 10.0.0.3 3000 external 172.16.1.3 3000
set int ip address pg0 10.0.0.1/24
set int ip address pg1 172.16.1.1/24
set int state pg0 up
set int state pg1 up
set ip arp static pg0 10.0.0.3 abcd.abcd.abcd
set ip arp static pg1 172.16.1.2 cdef.abcd.abcd
set int snat in pg0 out pg1
set int nat44 in pg0 out pg1
trace add pg-input 10

Some files were not shown because too many files have changed in this diff Show More