Compare commits

...

14 Commits

Author SHA1 Message Date
Filip Tehlar
08377f8ff7 VPP-365: Fix sending of bd_index in lisp_eid_table_add_del_map
Change-Id: I1f8fd65fa33b0bc7ee07aa0eeb5f794a7ede9537
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
(cherry picked from commit 5a4e2dde94262a6f93c0c87be81a10317f2ae426)
2016-08-30 19:28:58 +00:00
John Lo
2544ca81c3 VPP-361: Memory leak on delete of VXLAN over IPv6 tunnel
The key for VXLAN over IPv6 tunnel is allocated on create and should
be freed on delete.

Change-Id: I11bdd9465030fed57cc4bbd28dbccdf952633b34
Signed-off-by: John Lo <loj@cisco.com>
2016-08-30 00:10:09 -04:00
Steve Shin
eb5cad76ea vhost-user: unmap previously configured memory if necessary
If there's any memory-mapped region configued previously,
it should be unmapped before setting up a new vhost memory table.
Otherwise, huge page leakage will happen.

Change-Id: I375f603ea303919f1502df44a26a7384ab2ea00e
Signed-off-by: Steve Shin <jonshin@cisco.com>
(cherry picked from commit 5e15c91b6c2b5fbd7f989c5dc4edde506d254926)
2016-08-30 03:07:00 +00:00
Steve Shin
d7935e8c42 tuntap_rx modification to handle jumbo packets ( > 2K bytes)
Change-Id: Iebe30b87457741ac268b24c96fa7ea8ad1e101a6
Signed-off-by: Steve Shin <jonshin@cisco.com>
(cherry picked from commit 82a7af95e7553747dcebdb865a9c9a67826745d4)
2016-08-30 01:47:57 +00:00
Filip Tehlar
94195c85fe VPP-356: Fix wrong byte order in LISP API
Change-Id: Ib2284025b8394a87f1d5765713adb7070b450cba
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
(cherry picked from commit e3552c45f38d1f101cf512c9046647201d6c121b)
2016-08-27 10:40:26 +00:00
Florin Coras
ab4e86cb95 VPP-357 Fix vni for LISP fwd entry removals
Change-Id: I5d20c1939f7a5a142bf696b34143f7ebca6afbcb
Signed-off-by: Florin Coras <fcoras@cisco.com>
2016-08-26 16:46:52 +00:00
Sean Chandler
ea60221218 VPP-345: pull in upstream checksum patch for ICMP packets
http://www.dpdk.org/dev/patchwork/patch/15216/

Change-Id: I91b67f3e5c0abff52626e504e2707814ae0c3ed0
Signed-off-by: Sean Chandler <seandchandler@gmail.com>
(cherry picked from commit dc731bd4b1ad6ea588334c681d1409cbdec9ce67)
2016-08-26 12:39:33 +00:00
Keith Burns (alagalah)
217872424d VPP-305: Documentation for vnet/vnet/unix
Change-Id: I3f1a225033ecebe0cedfc3466b552176461b76ab
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
2016-08-26 12:38:42 +00:00
Keith Burns (alagalah)
aa4338556e VPP-307: Documentation for vnet/vnet/vxlan-gpe
Change-Id: Iaab6f4b63ed0d986be1ac0636c692b46098ad54d
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
2016-08-25 13:56:13 -07:00
Filip Tehlar
52ecf85946 VPP-321: Fix param order of unformat_lisp_eid_api
Change-Id: Ib00ca0f0dab4784a3fb34ffd91c18a3940e9a5d5
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
(cherry picked from commit 251aec436b9e3be15f92a464fa4559396b115b2a)
2016-08-25 12:14:47 +00:00
Damjan Marion
78c7daaf6d Fix issues with vhost-user when dpdk vhost-user is disabled, fixes VPP-347, VPP-349
Change-Id: I774bab98e43d55678a67a7708ca50edbbd4cbb06
Signed-off-by: Damjan Marion <damarion@cisco.com>
2016-08-25 07:42:37 +00:00
Ole Troan
8b66c77920 VPP-340: MAP-T wrong destination address
The bug was in VAT MAP code parsing a 32 bit integer into a 8 bit
type.  Perhaps we should try to build some defences in
unformat_chech_input() to avoid these errors.

Rebuild.

Change-Id: Iae4959f7e04d889da2e9650a4201c4db15d74201
Signed-off-by: Ole Troan <ot@cisco.com>
2016-08-24 18:50:12 +02:00
Filip Tehlar
a20d317e63 VPP-342: Don't allow remote mapping to overwrite local or static mapping
Change-Id: I9888d7c087da538b81a6a1967edbdf1103cc095a
Signed-off-by: Filip Tehlar <ftehlar@cisco.com>
(cherry picked from commit 3cd9e730f9db0d998e5e8a27ddff1da5a123625b)
2016-08-23 13:27:23 +00:00
Dave Barach
dbc6e3f0bb Change default branch in .gitreview
Change-Id: Ia39cdfd2b3d6c9dbe252dff0bcea3ba0adabdaaf
Signed-off-by: Dave Barach <dave@barachs.net>
2016-08-17 20:26:03 -04:00
27 changed files with 1191 additions and 260 deletions

View File

@ -2,3 +2,4 @@
host=gerrit.fd.io
port=29418
project=vpp
defaultbranch=stable/1609

View File

@ -0,0 +1,18 @@
diff --git a/drivers/net/enic/enic_rxtx.c b/drivers/net/enic/enic_rxtx.c
index 50f0b28..ad59613 100644
--- a/drivers/net/enic/enic_rxtx.c
+++ b/drivers/net/enic/enic_rxtx.c
@@ -212,9 +212,12 @@ enic_cq_rx_to_pkt_flags(struct cq_desc *cqd, struct rte_mbuf *mbuf)
/* checksum flags */
if (!enic_cq_rx_desc_csum_not_calc(cqrd) &&
(mbuf->packet_type & RTE_PTYPE_L3_IPV4)) {
+ uint32_t l4_flags = mbuf->packet_type & RTE_PTYPE_L4_MASK;
+
if (unlikely(!enic_cq_rx_desc_ipv4_csum_ok(cqrd)))
pkt_flags |= PKT_RX_IP_CKSUM_BAD;
- if (mbuf->packet_type & (RTE_PTYPE_L4_UDP | RTE_PTYPE_L4_TCP)) {
+ if (l4_flags == RTE_PTYPE_L4_UDP ||
+ l4_flags == RTE_PTYPE_L4_TCP) {
if (unlikely(!enic_cq_rx_desc_tcp_udp_csum_ok(cqrd)))
pkt_flags |= PKT_RX_L4_CKSUM_BAD;
}

View File

@ -626,13 +626,11 @@ endif
# virtio
########################################
if WITH_DPDK
libvnet_la_SOURCES += \
vnet/devices/virtio/vhost-user.c
nobase_include_HEADERS += \
vnet/devices/virtio/vhost-user.h
endif WITH_DPDK
########################################
# ssvm ethernet

View File

@ -1130,6 +1130,9 @@ dpdk_vhost_user_socket_read (unix_file_t * uf)
goto close_socket;
}
/* Unmap previously configured memory if necessary */
dpdk_unmap_all_mem_regions (xd);
dpdk_vhost_user_set_mem_table (xd->vlib_hw_if_index, &msg.memory, fds);
break;
@ -1787,6 +1790,7 @@ dpdk_vhost_user_process_if (vlib_main_t * vm, dpdk_device_t * xd, void *ctx)
}
return 0;
}
#endif
/*
* CLI functions
@ -1797,6 +1801,7 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
#if DPDK_VHOST_USER
dpdk_main_t *dm = &dpdk_main;
unformat_input_t _line_input, *line_input = &_line_input;
u8 *sock_filename = NULL;
@ -1810,7 +1815,9 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
if (dm->conf->use_virtio_vhost)
{
#endif
return vhost_user_connect_command_fn (vm, input, cmd);
#if DPDK_VHOST_USER
}
/* Get a line of input. */
@ -1851,6 +1858,7 @@ dpdk_vhost_user_connect_command_fn (vlib_main_t * vm,
vlib_cli_output (vm, "%U\n", format_vnet_sw_if_index_name, vnet_get_main (),
sw_if_index);
return 0;
#endif
}
/* *INDENT-OFF* */
@ -1899,7 +1907,11 @@ dpdk_vhost_user_delete_command_fn (vlib_main_t * vm,
vnet_main_t *vnm = vnet_get_main ();
#if DPDK_VHOST_USER
dpdk_vhost_user_delete_if (vnm, vm, sw_if_index);
#else
vhost_user_delete_if (vnm, vm, sw_if_index);
#endif
return 0;
}
@ -1922,6 +1934,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
#if DPDK_VHOST_USER
clib_error_t *error = 0;
dpdk_main_t *dm = &dpdk_main;
vnet_main_t *vnm = vnet_get_main ();
@ -1949,7 +1962,9 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
if (dm->conf->use_virtio_vhost)
{
#endif
return show_vhost_user_command_fn (vm, input, cmd);
#if DPDK_VHOST_USER
}
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
@ -2086,6 +2101,7 @@ show_dpdk_vhost_user_command_fn (vlib_main_t * vm,
done:
vec_free (hw_if_indices);
return error;
#endif
}
/* *INDENT-OFF* */
@ -2095,7 +2111,6 @@ VLIB_CLI_COMMAND (show_vhost_user_command, static) = {
.function = show_dpdk_vhost_user_command_fn,
};
/* *INDENT-ON* */
#endif
/*
* fd.io coding-style-patch-verification: ON

View File

@ -293,7 +293,7 @@ vhost_user_log_dirty_pages (vhost_user_intf_t * vui, u64 addr, u64 len)
#define vhost_user_log_dirty_ring(vui, vq, member) \
if (PREDICT_FALSE(vq->log_used)) { \
vhost_user_log_dirty_pages(vui, vq->log_guest_addr + offsetof(vring_used_t, member), \
vhost_user_log_dirty_pages(vui, vq->log_guest_addr + STRUCT_OFFSET_OF(vring_used_t, member), \
sizeof(vq->used->member)); \
}
@ -1210,19 +1210,25 @@ vhost_user_input (vlib_main_t * vm,
vlib_node_runtime_t * node, vlib_frame_t * f)
{
vhost_user_main_t *vum = &vhost_user_main;
#if DPDK > 0
dpdk_main_t *dm = &dpdk_main;
u32 cpu_index = os_get_cpu_number ();
#endif
vhost_user_intf_t *vui;
uword n_rx_packets = 0;
u32 cpu_index = os_get_cpu_number ();
int i;
for (i = 0; i < vec_len (vum->vhost_user_interfaces); i++)
{
vui = vec_elt_at_index (vum->vhost_user_interfaces, i);
if (vui->is_up &&
(i % dm->input_cpu_count) ==
(cpu_index - dm->input_cpu_first_index))
n_rx_packets += vhost_user_if_input (vm, vum, vui, node);
if (vui->is_up)
{
#if DPDK > 0
if ((i % dm->input_cpu_count) ==
(cpu_index - dm->input_cpu_first_index))
#endif
n_rx_packets += vhost_user_if_input (vm, vum, vui, node);
}
}
return n_rx_packets;
}
@ -1813,9 +1819,11 @@ static void
vhost_user_vui_register (vlib_main_t * vm, vhost_user_intf_t * vui)
{
vhost_user_main_t *vum = &vhost_user_main;
#if DPDK > 0
dpdk_main_t *dm = &dpdk_main;
int cpu_index;
vlib_thread_main_t *tm = vlib_get_thread_main ();
#endif
hash_set (vum->vhost_user_interface_index_by_listener_fd, vui->unix_fd,
vui - vum->vhost_user_interfaces);
@ -1823,15 +1831,19 @@ vhost_user_vui_register (vlib_main_t * vm, vhost_user_intf_t * vui)
vui - vum->vhost_user_interfaces);
/* start polling */
#if DPDK > 0
cpu_index = dm->input_cpu_first_index +
(vui - vum->vhost_user_interfaces) % dm->input_cpu_count;
if (tm->n_vlib_mains == 1)
#endif
vlib_node_set_state (vm, vhost_user_input_node.index,
VLIB_NODE_STATE_POLLING);
#if DPDK > 0
else
vlib_node_set_state (vlib_mains[cpu_index], vhost_user_input_node.index,
VLIB_NODE_STATE_POLLING);
#endif
/* tell process to start polling for sockets */
vlib_process_signal_event (vm, vhost_user_process_node.index, 0, 0);
@ -2221,6 +2233,32 @@ done:
return error;
}
/*
* CLI functions
*/
#if DPDK == 0
/* *INDENT-OFF* */
VLIB_CLI_COMMAND (vhost_user_connect_command, static) = {
.path = "create vhost-user",
.short_help = "create vhost-user socket <socket-filename> [server] [feature-mask <hex>] [renumber <dev_instance>]",
.function = vhost_user_connect_command_fn,
};
VLIB_CLI_COMMAND (vhost_user_delete_command, static) = {
.path = "delete vhost-user",
.short_help = "delete vhost-user sw_if_index <nn>",
.function = vhost_user_delete_command_fn,
};
VLIB_CLI_COMMAND (show_vhost_user_command, static) = {
.path = "show vhost-user",
.short_help = "show vhost-user interface",
.function = show_vhost_user_command_fn,
};
/* *INDENT-ON* */
#endif
static clib_error_t *
vhost_user_config (vlib_main_t * vm, unformat_input_t * input)
{

View File

@ -31,6 +31,10 @@
#define VHOST_VRING_F_LOG 0
#define VHOST_USER_F_PROTOCOL_FEATURES 30
#if DPDK == 0
#define RTE_VERSION_NUM(a,b,c,d) 1
#define RTE_VERSION 0
#endif
#if RTE_VERSION >= RTE_VERSION_NUM(16, 4, 0, 0)
#define VHOST_USER_PROTOCOL_FEATURES ((1ULL << VHOST_USER_PROTOCOL_F_MQ) | \
(1ULL << VHOST_USER_PROTOCOL_F_LOG_SHMFD))

View File

@ -235,7 +235,7 @@ dp_del_fwd_entry (lisp_cp_main_t * lcm, u32 src_map_index, u32 dst_map_index)
u32 sw_if_index;
a->is_add = 0;
a->locator_pairs = fe->locator_pairs;
a->vni = gid_address_vni (&a->rmt_eid);
a->vni = gid_address_vni (&fe->deid);
gid_address_copy (&a->rmt_eid, &fe->deid);
vnet_lisp_gpe_add_del_fwd_entry (a, &sw_if_index);
@ -445,6 +445,7 @@ vnet_lisp_map_cache_add_del (vnet_lisp_add_del_mapping_args_t * a,
m->ttl = a->ttl;
m->action = a->action;
m->local = a->local;
m->is_static = a->is_static;
map_index = m - lcm->mapping_pool;
gid_dictionary_add_del (&lcm->mapping_index_by_gid, &a->eid, map_index,
@ -767,11 +768,13 @@ compare_locators (lisp_cp_main_t * lcm, u32 * old_ls_indexes,
* @param is_add add mapping if non-zero, delete otherwise
* @param res_map_index the map-index that was created/updated/removed. It is
* set to ~0 if no action is taken.
* @param is_static used for distinguishing between statically learned
remote mappings and mappings obtained from MR
* @return return code
*/
int
vnet_lisp_add_del_mapping (gid_address_t * eid, locator_t * rlocs, u8 action,
u8 authoritative, u32 ttl, u8 is_add,
u8 authoritative, u32 ttl, u8 is_add, u8 is_static,
u32 * res_map_index)
{
vnet_lisp_add_del_mapping_args_t _m_args, *m_args = &_m_args;
@ -803,6 +806,15 @@ vnet_lisp_add_del_mapping (gid_address_t * eid, locator_t * rlocs, u8 action,
* updated and be done */
if (old_map && gid_address_cmp (&old_map->eid, eid) == 0)
{
if (!is_static && (old_map->is_static || old_map->local))
{
/* do not overwrite local or static remote mappings */
clib_warning ("mapping %U rejected due to collision with local "
"or static remote mapping!", format_gid_address,
&eid);
return 0;
}
locator_set_t *old_ls;
/* update mapping attributes */
@ -836,6 +848,7 @@ vnet_lisp_add_del_mapping (gid_address_t * eid, locator_t * rlocs, u8 action,
m_args->is_add = 1;
m_args->action = action;
m_args->locator_set_index = ls_index;
m_args->is_static = is_static;
vnet_lisp_map_cache_add_del (m_args, &dst_map_index);
if (res_map_index)
@ -1084,7 +1097,8 @@ lisp_add_del_remote_mapping_command_fn (vlib_main_t * vm,
/* add as static remote mapping, i.e., not authoritative and infinite
* ttl */
rv = vnet_lisp_add_del_mapping (&eid, rlocs, action, 0, ~0, is_add, 0);
rv = vnet_lisp_add_del_mapping (&eid, rlocs, action, 0, ~0, is_add,
1 /* is_static */ , 0);
if (rv)
clib_warning ("failed to %s remote mapping!", is_add ? "add" : "delete");
@ -3141,7 +3155,7 @@ process_map_reply (void *arg)
/* insert/update mappings cache */
vnet_lisp_add_del_mapping (&deid, locators, action, authoritative, ttl,
1, &dst_map_index);
1, 0 /* is_static */ , &dst_map_index);
/* try to program forwarding only if mapping saved or updated */
if ((u32) ~ 0 != dst_map_index)

View File

@ -189,6 +189,7 @@ typedef struct
u8 authoritative;
u8 local;
u8 is_static;
} vnet_lisp_add_del_mapping_args_t;
int
@ -200,7 +201,7 @@ vnet_lisp_add_del_local_mapping (vnet_lisp_add_del_mapping_args_t * a,
int
vnet_lisp_add_del_mapping (gid_address_t * deid, locator_t * dlocs, u8 action,
u8 authoritative, u32 ttl, u8 is_add,
u8 authoritative, u32 ttl, u8 is_add, u8 is_static,
u32 * res_map_index);
typedef struct

View File

@ -287,6 +287,8 @@ typedef struct
u8 authoritative;
u8 local;
/* valid only for remote mappings */
u8 is_static;
} mapping_t;
uword

View File

@ -12,33 +12,73 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief Host utility functions
*/
#include <vppinfra/format.h>
#include <vlib/vlib.h>
#include <vlib/threads.h>
/* Functions to call from gdb */
/**
* @brief GDB callable function: vl - Return vector length of vector
*
* @param *p - void - address of vector
*
* @return length - u32
*
*/
u32 vl(void *p)
{
return vec_len (p);
}
/**
* @brief GDB callable function: pe - call pool_elts - number of elements in a pool
*
* @param *v - void - address of pool
*
* @return number - uword
*
*/
uword pe (void *v)
{
return (pool_elts(v));
}
/**
* @brief GDB callable function: pifi - call pool_is_free_index - is passed index free?
*
* @param *p - void - address of pool
* @param *index - u32
*
* @return 0|1 - int
*
*/
int pifi (void *p, u32 index)
{
return pool_is_free_index (p, index);
}
/**
* @brief GDB callable function: debug_hex_bytes - return formatted hex string
*
* @param *s - u8
* @param n - u32 - number of bytes to format
*
*/
void debug_hex_bytes (u8 *s, u32 n)
{
fformat (stderr, "%U\n", format_hex_bytes, s, n);
}
/**
* @brief GDB callable function: vlib_dump_frame_ownership
*
*/
void vlib_dump_frame_ownership (void)
{
vlib_main_t * vm = vlib_get_main();
@ -47,7 +87,7 @@ void vlib_dump_frame_ownership (void)
vlib_next_frame_t * nf;
u32 first_nf_index;
u32 index;
vec_foreach(this_node_runtime, nm->nodes_by_type[VLIB_NODE_TYPE_INTERNAL])
{
first_nf_index = this_node_runtime->next_frame_index;
@ -74,11 +114,18 @@ void vlib_dump_frame_ownership (void)
}
}
/**
* @brief GDB callable function: vlib_runtime_index_to_node_name
*
* Takes node index and will return the node name.
*
* @param index - u32
*/
void vlib_runtime_index_to_node_name (u32 index)
{
vlib_main_t * vm = vlib_get_main();
vlib_node_main_t * nm = &vm->node_main;
if (index > vec_len (nm->nodes))
{
fformat(stderr, "%d out of range, max %d\n", vec_len(nm->nodes));
@ -89,6 +136,13 @@ void vlib_runtime_index_to_node_name (u32 index)
}
/**
* @brief GDB callable function: show_gdb_command_fn - show gdb
*
* Shows list of functions for VPP available in GDB
*
* @return error - clib_error_t
*/
static clib_error_t *
show_gdb_command_fn (vlib_main_t * vm,
unformat_input_t * input,

View File

@ -40,24 +40,33 @@
#include <vnet/unix/pcap.h>
#include <sys/fcntl.h>
/* Usage
#include <vnet/unix/pcap.h>
static pcap_main_t pcap = {
.file_name = "/tmp/ip4",
.n_packets_to_capture = 2,
.packet_type = PCAP_PACKET_TYPE_ip,
};
To add a buffer:
pcap_add_buffer (&pcap, vm, pi0, 128);
file will be written after n_packets_to_capture or call to pcap_write (&pcap).
/**
* @file
* @brief PCAP function.
* Usage
*
* #include <vnet/unix/pcap.h>
*
* static pcap_main_t pcap = {
* .file_name = "/tmp/ip4",
* .n_packets_to_capture = 2,
* .packet_type = PCAP_PACKET_TYPE_ip,
* };
*
* To add a buffer:
*
* pcap_add_buffer (&pcap, vm, pi0, 128);
*
* File will be written after n_packets_to_capture or call to pcap_write (&pcap).
*
*/
/**
* @brief Close PCAP file
*
* @return rc - clib_error_t
*
*/
clib_error_t *
pcap_close (pcap_main_t * pm)
{
@ -67,6 +76,12 @@ pcap_close (pcap_main_t * pm)
return 0;
}
/**
* @brief Write PCAP file
*
* @return rc - clib_error_t
*
*/
clib_error_t *
pcap_write (pcap_main_t * pm)
{
@ -143,6 +158,12 @@ pcap_write (pcap_main_t * pm)
return error;
}
/**
* @brief Read PCAP file
*
* @return rc - clib_error_t
*
*/
clib_error_t * pcap_read (pcap_main_t * pm)
{
clib_error_t * error = 0;
@ -197,7 +218,7 @@ clib_error_t * pcap_read (pcap_main_t * pm)
error = clib_error_return (0, "short read `%s'", pm->file_name);
goto done;
}
if (vec_len (pm->packets_read) == 0)
pm->min_packet_bytes = pm->max_packet_bytes = ph.n_bytes_in_packet;
else
@ -205,7 +226,7 @@ clib_error_t * pcap_read (pcap_main_t * pm)
pm->min_packet_bytes = clib_min (pm->min_packet_bytes, ph.n_bytes_in_packet);
pm->max_packet_bytes = clib_max (pm->max_packet_bytes, ph.n_bytes_in_packet);
}
vec_add1 (pm->packets_read, data);
}
@ -213,5 +234,5 @@ clib_error_t * pcap_read (pcap_main_t * pm)
if (fd >= 0)
close (fd);
return error;
}

View File

@ -36,13 +36,25 @@
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
* @file
* @brief PCAP utility definitions
*/
#ifndef included_vnet_pcap_h
#define included_vnet_pcap_h
#include <vlib/vlib.h>
#define foreach_vnet_pcap_packet_type \
/**
* @brief Packet types supported by PCAP
*
* null 0
* ethernet 1
* ppp 9
* ip 12
* hdlc 104
*/
#define foreach_vnet_pcap_packet_type \
_ (null, 0) \
_ (ethernet, 1) \
_ (ppp, 9) \
@ -56,27 +68,27 @@ typedef enum {
} pcap_packet_type_t;
#define foreach_pcap_file_header \
/* 0xa1b2c3d4 host byte order. \
/** 0xa1b2c3d4 host byte order. \
0xd4c3b2a1 => need to byte swap everything. */ \
_ (u32, magic) \
\
/* Currently major 2 minor 4. */ \
/** Currently major 2 minor 4. */ \
_ (u16, major_version) \
_ (u16, minor_version) \
\
/* 0 for GMT. */ \
/** 0 for GMT. */ \
_ (u32, time_zone) \
\
/* Accuracy of timestamps. Typically set to 0. */ \
/** Accuracy of timestamps. Typically set to 0. */ \
_ (u32, sigfigs) \
\
/* Size of largest packet in file. */ \
/** Size of largest packet in file. */ \
_ (u32, max_packet_size_in_bytes) \
\
/* One of vnet_pcap_packet_type_t. */ \
/** One of vnet_pcap_packet_type_t. */ \
_ (u32, packet_type)
/* File header. */
/** File header struct */
typedef struct {
#define _(t, f) t f;
foreach_pcap_file_header
@ -84,58 +96,79 @@ typedef struct {
} pcap_file_header_t;
#define foreach_pcap_packet_header \
/* Time stamp in seconds and microseconds. */ \
/** Time stamp in seconds */ \
_ (u32, time_in_sec) \
/** Time stamp in microseconds. */ \
_ (u32, time_in_usec) \
\
/* Number of bytes stored in file and size of actual packet. */ \
/** Number of bytes stored in file. */ \
_ (u32, n_packet_bytes_stored_in_file) \
/** Number of bytes in actual packet. */ \
_ (u32, n_bytes_in_packet)
/* Packet header. */
/** Packet header. */
typedef struct {
#define _(t, f) t f;
foreach_pcap_packet_header
#undef _
/* Packet data follows. */
/** Packet data follows. */
u8 data[0];
} pcap_packet_header_t;
/**
* @brief PCAP main state data structure
*/
typedef struct {
/* File name of pcap output. */
/** File name of pcap output. */
char * file_name;
/* Number of packets to capture. */
/** Number of packets to capture. */
u32 n_packets_to_capture;
/** Packet type */
pcap_packet_type_t packet_type;
/* Number of packets currently captured. */
/** Number of packets currently captured. */
u32 n_packets_captured;
/** flags */
u32 flags;
#define PCAP_MAIN_INIT_DONE (1 << 0)
/* File descriptor for reading/writing. */
/** File descriptor for reading/writing. */
int file_descriptor;
/** Bytes written */
u32 n_pcap_data_written;
/* Vector of pcap data. */
/** Vector of pcap data. */
u8 * pcap_data;
/* Packets read from file. */
/** Packets read from file. */
u8 ** packets_read;
/** Min/Max Packet bytes */
u32 min_packet_bytes, max_packet_bytes;
} pcap_main_t;
/* Write out data to output file. */
/** Write out data to output file. */
clib_error_t * pcap_write (pcap_main_t * pm);
/** Read data from file. */
clib_error_t * pcap_read (pcap_main_t * pm);
/**
* @brief Add packet
*
* @param *pm - pcap_main_t
* @param time_now - f64
* @param n_bytes_in_trace - u32
* @param n_bytes_in_packet - u32
*
* @return Packet Data
*
*/
static inline void *
pcap_add_packet (pcap_main_t * pm,
f64 time_now,
@ -155,6 +188,15 @@ pcap_add_packet (pcap_main_t * pm,
return h->data;
}
/**
* @brief Add buffer (vlib_buffer_t) to the trace
*
* @param *pm - pcap_main_t
* @param *vm - vlib_main_t
* @param buffer_index - u32
* @param n_bytes_in_trace - u32
*
*/
static inline void
pcap_add_buffer (pcap_main_t * pm,
vlib_main_t * vm, u32 buffer_index,
@ -179,7 +221,7 @@ pcap_add_buffer (pcap_main_t * pm,
b = vlib_get_buffer (vm, b->next_buffer);
}
/* Flush output vector. */
/** Flush output vector. */
if (vec_len (pm->pcap_data) >= 64*1024
|| pm->n_packets_captured >= pm->n_packets_to_capture)
pcap_write (pm);

View File

@ -14,14 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief Functions to convert PCAP file format to VPP PG (Packet Generator)
*
*/
#include <vnet/unix/pcap.h>
#include <vnet/ethernet/packet.h>
#include <stdio.h>
pcap_main_t pcap_main;
static char * pg_fmt =
/**
* @brief char * to seed a PG file
*/
static char * pg_fmt =
"packet-generator new {\n"
" name s%d\n"
" limit 1\n"
@ -29,16 +36,32 @@ static char * pg_fmt =
" node ethernet-input\n";
/**
* @brief Packet Generator Stream boilerplate
*
* @param *ofp - FILE
* @param i - int
* @param *pkt - u8
*/
void stream_boilerplate (FILE *ofp, int i, u8 * pkt)
{
fformat(ofp, pg_fmt, i, vec_len(pkt), vec_len(pkt));
}
/**
* @brief Conversion of PCAP file to PG file format
*
* @param *pm - pcap_main_t
* @param *ofp - FILE
*
* @return rc - int
*
*/
int pcap2pg (pcap_main_t * pm, FILE *ofp)
{
int i, j;
u8 *pkt;
for (i = 0; i < vec_len (pm->packets_read); i++)
{
int offset;
@ -51,13 +74,13 @@ int pcap2pg (pcap_main_t * pm, FILE *ofp)
stream_boilerplate (ofp, i, pkt);
fformat (ofp, " data {\n");
ethertype = clib_net_to_host_u16 (h->type);
/*
/**
* In vnet terms, packet generator interfaces are not ethernets.
* They don't have vlan tables.
* This dance transforms captured 802.1q VLAN packets into
* This transforms captured 802.1q VLAN packets into
* regular Ethernet packets.
*/
if (ethertype == 0x8100 /* 802.1q vlan */)
@ -69,7 +92,7 @@ int pcap2pg (pcap_main_t * pm, FILE *ofp)
else
offset = 14;
fformat (ofp,
fformat (ofp,
" 0x%04x: %02x%02x.%02x%02x.%02x%02x"
" -> %02x%02x.%02x%02x.%02x%02x\n",
ethertype,
@ -97,6 +120,10 @@ int pcap2pg (pcap_main_t * pm, FILE *ofp)
return 0;
}
/**
* @brief pcap2pg.
* usage: pcap2pg -i <input-file> [-o <output-file>]
*/
int main (int argc, char **argv)
{
unformat_input_t input;

File diff suppressed because it is too large Load Diff

View File

@ -14,11 +14,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief TAPCLI definitions
*/
#ifndef __included_tapcli_h__
#define __included_tapcli_h__
#define foreach_tapcli_error \
/** TAP CLI errors */
#define foreach_tapcli_error \
/* Must be first. */ \
_(NONE, "no error") \
_(READ, "read error") \
@ -32,6 +37,7 @@ typedef enum {
TAPCLI_N_ERROR,
} tapcli_error_t;
/** TAP CLI interface details struct */
typedef struct {
u32 sw_if_index;
u8 dev_name[64];

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/*
/*
*------------------------------------------------------------------
* tuntap.h - kernel stack (reverse) punt/inject path
*
@ -16,10 +16,9 @@
* limitations under the License.
*------------------------------------------------------------------
*/
/*
* Call from some VLIB_INIT_FUNCTION to set the Linux kernel
* inject node name.
/**
* @file
* @brief Call from VLIB_INIT_FUNCTION to set the Linux kernel inject node name.
*/
void register_tuntap_inject_node_name (char *name);

View File

@ -14,6 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief Functions for decapsulating VXLAN GPE tunnels
*
*/
#include <vlib/vlib.h>
#include <vnet/pg/pg.h>
@ -21,12 +26,25 @@
vlib_node_registration_t vxlan_gpe_input_node;
/**
* @brief Struct for VXLAN GPE decap packet tracing
*
*/
typedef struct {
u32 next_index;
u32 tunnel_index;
u32 error;
} vxlan_gpe_rx_trace_t;
/**
* @brief Tracing function for VXLAN GPE packet decapsulation
*
* @param *s - u8 - format string
* @param *args - va_list - arguments to display
*
* @return *s u8 - formatted trace output
*
*/
static u8 * format_vxlan_gpe_rx_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
@ -46,7 +64,15 @@ static u8 * format_vxlan_gpe_rx_trace (u8 * s, va_list * args)
return s;
}
/**
* @brief Tracing function for VXLAN GPE packet decapsulation including length
*
* @param *s - u8 - format string
* @param *args - va_list - arguments to display
*
* @return *s u8 - formatted trace output
*
*/
static u8 * format_vxlan_gpe_with_length (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
@ -56,6 +82,25 @@ static u8 * format_vxlan_gpe_with_length (u8 * s, va_list * args)
return s;
}
/**
* @brief Common processing for IPv4 and IPv6 VXLAN GPE decap dispatch functions
*
* It is worth noting that other than trivial UDP forwarding (transit), VXLAN GPE
* tunnels are "terminate local". This means that there is no "TX" interface for this
* decap case, so that field in the buffer_metadata can be "used for something else".
* The something else in this case is, for the IPv4/IPv6 inner-packet type case, the
* FIB index used to look up the inner-packet's adjacency.
*
* vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
*
* @param *vm - vlib_main_t
* @param *node - vlib_node_runtime_t
* @param *from_frame - vlib_frame_t
* @param ip_ip4 - u8
*
* @return from_frame->n_vectors - uword
*
*/
always_inline uword
vxlan_gpe_input (vlib_main_t * vm,
vlib_node_runtime_t * node,
@ -250,7 +295,7 @@ vxlan_gpe_input (vlib_main_t * vm,
/* Required to make the l2 tag push / pop code work on l2 subifs */
vnet_update_l2_len (b0);
/*
/**
* ip[46] lookup in the configured FIB
*/
vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->decap_fib_index;
@ -545,6 +590,17 @@ vxlan_gpe_input (vlib_main_t * vm,
return from_frame->n_vectors;
}
/**
* @brief Graph processing dispatch function for IPv4 VXLAN GPE
*
* @node vxlan4-gpe-input
* @param *vm - vlib_main_t
* @param *node - vlib_node_runtime_t
* @param *from_frame - vlib_frame_t
*
* @return from_frame->n_vectors - uword
*
*/
static uword
vxlan4_gpe_input (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame)
@ -552,6 +608,17 @@ vxlan4_gpe_input (vlib_main_t * vm, vlib_node_runtime_t * node,
return vxlan_gpe_input (vm, node, from_frame, /* is_ip4 */1);
}
/**
* @brief Graph processing dispatch function for IPv6 VXLAN GPE
*
* @node vxlan6-gpe-input
* @param *vm - vlib_main_t
* @param *node - vlib_node_runtime_t
* @param *from_frame - vlib_frame_t
*
* @return from_frame->n_vectors - uword
*
*/
static uword
vxlan6_gpe_input (vlib_main_t * vm, vlib_node_runtime_t * node,
vlib_frame_t * from_frame)
@ -559,6 +626,9 @@ vxlan6_gpe_input (vlib_main_t * vm, vlib_node_runtime_t * node,
return vxlan_gpe_input (vm, node, from_frame, /* is_ip4 */0);
}
/**
* @brief VXLAN GPE error strings
*/
static char * vxlan_gpe_error_strings[] = {
#define vxlan_gpe_error(n,s) s,
#include <vnet/vxlan-gpe/vxlan_gpe_error.def>
@ -587,7 +657,7 @@ VLIB_REGISTER_NODE (vxlan4_gpe_input_node) = {
// $$$$ .unformat_buffer = unformat_vxlan_gpe_header,
};
VLIB_NODE_FUNCTION_MULTIARCH (vxlan4_gpe_input_node, vxlan4_gpe_input)
VLIB_NODE_FUNCTION_MULTIARCH (vxlan4_gpe_input_node, vxlan4_gpe_input);
VLIB_REGISTER_NODE (vxlan6_gpe_input_node) = {
.function = vxlan6_gpe_input,
@ -610,4 +680,4 @@ VLIB_REGISTER_NODE (vxlan6_gpe_input_node) = {
// $$$$ .unformat_buffer = unformat_vxlan_gpe_header,
};
VLIB_NODE_FUNCTION_MULTIARCH (vxlan6_gpe_input_node, vxlan6_gpe_input)
VLIB_NODE_FUNCTION_MULTIARCH (vxlan6_gpe_input_node, vxlan6_gpe_input);

View File

@ -0,0 +1,32 @@
/*
*
* Copyright (c) 2013 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.
*/
/**
@dir
@brief VXLAN GPE
Based on IETF: draft-quinn-vxlan-gpe-03.txt
Abstract
This draft describes extending Virtual eXtensible Local Area Network
(VXLAN), via changes to the VXLAN header, with three new
capabilities: support for multi-protocol encapsulation, operations,
administration and management (OAM) signaling and explicit
versioning.
See file: vxlan-gpe-rfc.txt
*/

View File

@ -12,6 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief Functions for encapsulating VXLAN GPE tunnels
*
*/
#include <vppinfra/error.h>
#include <vppinfra/hash.h>
#include <vnet/vnet.h>
@ -19,16 +24,22 @@
#include <vnet/ethernet/ethernet.h>
#include <vnet/vxlan-gpe/vxlan_gpe.h>
/* Statistics (not really errors) */
/** Statistics (not really errors) */
#define foreach_vxlan_gpe_encap_error \
_(ENCAPSULATED, "good packets encapsulated")
/**
* @brief VXLAN GPE encap error strings
*/
static char * vxlan_gpe_encap_error_strings[] = {
#define _(sym,string) string,
foreach_vxlan_gpe_encap_error
#undef _
};
/**
* @brief Struct for VXLAN GPE errors/counters
*/
typedef enum {
#define _(sym,str) VXLAN_GPE_ENCAP_ERROR_##sym,
foreach_vxlan_gpe_encap_error
@ -36,6 +47,9 @@ typedef enum {
VXLAN_GPE_ENCAP_N_ERROR,
} vxlan_gpe_encap_error_t;
/**
* @brief Struct for defining VXLAN GPE next nodes
*/
typedef enum {
VXLAN_GPE_ENCAP_NEXT_IP4_LOOKUP,
VXLAN_GPE_ENCAP_NEXT_IP6_LOOKUP,
@ -43,22 +57,43 @@ typedef enum {
VXLAN_GPE_ENCAP_N_NEXT
} vxlan_gpe_encap_next_t;
/**
* @brief Struct for tracing VXLAN GPE encapsulated packets
*/
typedef struct {
u32 tunnel_index;
} vxlan_gpe_encap_trace_t;
/**
* @brief Trace of packets encapsulated in VXLAN GPE
*
* @param *s - u8 - formatted string
* @param *args - va_list
*
* @return *s - u8 - formatted string
*
*/
u8 * format_vxlan_gpe_encap_trace (u8 * s, va_list * args)
{
CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
vxlan_gpe_encap_trace_t * t
vxlan_gpe_encap_trace_t * t
= va_arg (*args, vxlan_gpe_encap_trace_t *);
s = format (s, "VXLAN-GPE-ENCAP: tunnel %d", t->tunnel_index);
return s;
}
/**
* @brief Instantiates UDP + VXLAN-GPE header then set next node to IP4|6 lookup
*
* @param *ngm - vxlan_gpe_maint_t
* @param *b0 - vlib_buffer_t
* @param *t0 - vxlan_gpe_tunnel_t - contains rewrite header
* @param *next0 - u32 - relative index of next dispatch function (next node)
* @param is_v4 - u8 - Is this IPv4? (or IPv6)
*
*/
always_inline void
vxlan_gpe_encap_one_inline (vxlan_gpe_main_t * ngm, vlib_buffer_t * b0,
vxlan_gpe_tunnel_t * t0, u32 * next0, u8 is_v4)
@ -79,6 +114,19 @@ vxlan_gpe_encap_one_inline (vxlan_gpe_main_t * ngm, vlib_buffer_t * b0,
}
}
/**
* @brief Instantiates UDP + VXLAN-GPE header then set next node to IP4|6 lookup for two packets
*
* @param *ngm - vxlan_gpe_maint_t
* @param *b0 - vlib_buffer_t - Packet0
* @param *b1 - vlib_buffer_t - Packet1
* @param *t0 - vxlan_gpe_tunnel_t - contains rewrite header for Packet0
* @param *t1 - vxlan_gpe_tunnel_t - contains rewrite header for Packet1
* @param *next0 - u32 - relative index of next dispatch function (next node) for Packet0
* @param *next1 - u32 - relative index of next dispatch function (next node) for Packet1
* @param is_v4 - u8 - Is this IPv4? (or IPv6)
*
*/
always_inline void
vxlan_gpe_encap_two_inline (vxlan_gpe_main_t * ngm, vlib_buffer_t * b0, vlib_buffer_t * b1,
vxlan_gpe_tunnel_t * t0, vxlan_gpe_tunnel_t * t1, u32 * next0,
@ -101,6 +149,24 @@ vxlan_gpe_encap_two_inline (vxlan_gpe_main_t * ngm, vlib_buffer_t * b0, vlib_buf
}
}
/**
* @brief Common processing for IPv4 and IPv6 VXLAN GPE encap dispatch functions
*
* It is worth noting that other than trivial UDP forwarding (transit), VXLAN GPE
* tunnels are "establish local". This means that we don't have a TX interface as yet
* as we need to look up where the outer-header dest is. By setting the TX index in the
* buffer metadata to the encap FIB, we can do a lookup to get the adjacency and real TX.
*
* vnet_buffer(b0)->sw_if_index[VLIB_TX] = t0->encap_fib_index;
*
* @node vxlan-gpe-input
* @param *vm - vlib_main_t
* @param *node - vlib_node_runtime_t
* @param *from_frame - vlib_frame_t
*
* @return from_frame->n_vectors - uword
*
*/
static uword
vxlan_gpe_encap (vlib_main_t * vm,
vlib_node_runtime_t * node,

View File

@ -12,11 +12,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief Common utility functions for IPv4 and IPv6 VXLAN GPE tunnels
*
*/
#include <vnet/vxlan-gpe/vxlan_gpe.h>
#include <vnet/ip/format.h>
vxlan_gpe_main_t vxlan_gpe_main;
/**
* @brief Tracing function for VXLAN GPE tunnel packets
*
* @param *s - u8 - formatting string
* @param *args - va_list
*
* @return *s - u8 - formmatted string
*
*/
u8 * format_vxlan_gpe_tunnel (u8 * s, va_list * args)
{
vxlan_gpe_tunnel_t * t = va_arg (*args, vxlan_gpe_tunnel_t *);
@ -54,13 +68,21 @@ u8 * format_vxlan_gpe_tunnel (u8 * s, va_list * args)
return s;
}
/**
* @brief Naming for VXLAN GPE tunnel
*
* @param *s - u8 - formatting string
* @param *args - va_list
*
* @return *s - u8 - formatted string
*
*/
static u8 * format_vxlan_gpe_name (u8 * s, va_list * args)
{
u32 dev_instance = va_arg (*args, u32);
return format (s, "vxlan_gpe_tunnel%d", dev_instance);
}
static uword dummy_interface_tx (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
@ -68,6 +90,17 @@ static uword dummy_interface_tx (vlib_main_t * vm,
clib_warning ("you shouldn't be here, leaking buffers...");
return frame->n_vectors;
}
/**
* @brief CLI function for VXLAN GPE admin up/down
*
* @param *vnm - vnet_main_t
* @param hw_if_index - u32
* @param flags - u32
*
* @return *rc - clib_error_t
*
*/
static clib_error_t *
vxlan_gpe_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
{
@ -98,6 +131,15 @@ static uword dummy_set_rewrite (vnet_main_t * vnm,
}
/**
* @brief Formatting function for tracing VXLAN GPE with length
*
* @param *s - u8 - formatting string
* @param *args - va_list
*
* @return *s - formatted string
*
*/
static u8 * format_vxlan_gpe_header_with_length (u8 * s, va_list * args)
{
u32 dev_instance = va_arg (*args, u32);
@ -131,6 +173,14 @@ _(decap_fib_index)
}
/**
* @brief Calculate IPv4 VXLAN GPE rewrite header
*
* @param *t - vxlan_gpe_tunnel_t
*
* @return rc - int
*
*/
static int vxlan4_gpe_rewrite (vxlan_gpe_tunnel_t * t)
{
u8 *rw = 0;
@ -169,6 +219,14 @@ static int vxlan4_gpe_rewrite (vxlan_gpe_tunnel_t * t)
return (0);
}
/**
* @brief Calculate IPv6 VXLAN GPE rewrite header
*
* @param *t - vxlan_gpe_tunnel_t
*
* @return rc - int
*
*/
static int vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t)
{
u8 *rw = 0;
@ -207,6 +265,15 @@ static int vxlan6_gpe_rewrite (vxlan_gpe_tunnel_t * t)
return (0);
}
/**
* @brief Add or Del a VXLAN GPE tunnel
*
* @param *a - vnet_vxlan_gpe_add_del_tunnel_args_t
* @param *sw_if_index - u32
*
* @return rc - int
*
*/
int vnet_vxlan_gpe_add_del_tunnel
(vnet_vxlan_gpe_add_del_tunnel_args_t *a, u32 * sw_if_indexp)
{
@ -352,6 +419,14 @@ int vnet_vxlan_gpe_add_del_tunnel
return 0;
}
/**
* @brief Find the IPv4 FIB index from the FIB ID
*
* @param fib_id - u32
*
* @return fib_index - u32
*
*/
static u32 fib4_index_from_fib_id (u32 fib_id)
{
ip4_main_t * im = &ip4_main;
@ -364,6 +439,14 @@ static u32 fib4_index_from_fib_id (u32 fib_id)
return p[0];
}
/**
* @brief Find the IPv4 FIB index from the FIB ID
*
* @param fib_id - u32
*
* @return fib_index - u32
*
*/
static u32 fib6_index_from_fib_id (u32 fib_id)
{
ip6_main_t * im = &ip6_main;
@ -376,6 +459,16 @@ static u32 fib6_index_from_fib_id (u32 fib_id)
return p[0];
}
/**
* @brief CLI function for Add/Del of IPv4/IPv6 VXLAN GPE tunnel
*
* @param *vm - vlib_main_t
* @param *input - unformat_input_t
* @param *cmd - vlib_cli_command_t
*
* @return error - clib_error_t
*
*/
static clib_error_t *
vxlan_gpe_add_del_tunnel_command_fn (vlib_main_t * vm,
unformat_input_t * input,
@ -528,6 +621,16 @@ VLIB_CLI_COMMAND (create_vxlan_gpe_tunnel_command, static) = {
.function = vxlan_gpe_add_del_tunnel_command_fn,
};
/**
* @brief CLI function for showing VXLAN GPE tunnels
*
* @param *vm - vlib_main_t
* @param *input - unformat_input_t
* @param *cmd - vlib_cli_command_t
*
* @return error - clib_error_t
*
*/
static clib_error_t *
show_vxlan_gpe_tunnel_command_fn (vlib_main_t * vm,
unformat_input_t * input,
@ -552,6 +655,14 @@ VLIB_CLI_COMMAND (show_vxlan_gpe_tunnel_command, static) = {
.function = show_vxlan_gpe_tunnel_command_fn,
};
/**
* @brief Feature init function for VXLAN GPE
*
* @param *vm - vlib_main_t
*
* @return error - clib_error_t
*
*/
clib_error_t *vxlan_gpe_init (vlib_main_t *vm)
{
vxlan_gpe_main_t *gm = &vxlan_gpe_main;

View File

@ -12,6 +12,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief VXLAN GPE definitions
*
*/
#ifndef included_vnet_vxlan_gpe_h
#define included_vnet_vxlan_gpe_h
@ -26,80 +31,102 @@
#include <vnet/ip/ip6_packet.h>
#include <vnet/ip/udp.h>
/**
* @brief VXLAN GPE header struct
*
*/
typedef CLIB_PACKED (struct {
ip4_header_t ip4; /* 20 bytes */
udp_header_t udp; /* 8 bytes */
vxlan_gpe_header_t vxlan; /* 8 bytes */
/** 20 bytes */
ip4_header_t ip4;
/** 8 bytes */
udp_header_t udp;
/** 8 bytes */
vxlan_gpe_header_t vxlan;
}) ip4_vxlan_gpe_header_t;
typedef CLIB_PACKED (struct {
ip6_header_t ip6; /* 40 bytes */
udp_header_t udp; /* 8 bytes */
vxlan_gpe_header_t vxlan; /* 8 bytes */
/** 40 bytes */
ip6_header_t ip6;
/** 8 bytes */
udp_header_t udp;
/** 8 bytes */
vxlan_gpe_header_t vxlan;
}) ip6_vxlan_gpe_header_t;
/**
* @brief Key struct for IPv4 VXLAN GPE tunnel.
* Key fields: local remote, vni
* all fields in NET byte order
* VNI shifted 8 bits
*/
typedef CLIB_PACKED(struct {
/*
* Key fields: local remote, vni
* all fields in NET byte order
*/
union {
struct {
u32 local;
u32 remote;
u32 vni; /* shifted 8 bits */
u32 vni;
u32 pad;
};
u64 as_u64[2];
};
}) vxlan4_gpe_tunnel_key_t;
/**
* @brief Key struct for IPv6 VXLAN GPE tunnel.
* Key fields: local remote, vni
* all fields in NET byte order
* VNI shifted 8 bits
*/
typedef CLIB_PACKED(struct {
/*
* Key fields: local remote, vni
* all fields in NET byte order
*/
ip6_address_t local;
ip6_address_t remote;
u32 vni; /* shifted 8 bits */
u32 vni;
}) vxlan6_gpe_tunnel_key_t;
/**
* @brief Struct for VXLAN GPE tunnel
*/
typedef struct {
/* Rewrite string. $$$$ embed vnet_rewrite header */
/** Rewrite string. $$$$ embed vnet_rewrite header */
u8 * rewrite;
/* encapsulated protocol */
/** encapsulated protocol */
u8 protocol;
/* tunnel src and dst addresses */
/** tunnel local address */
ip46_address_t local;
/** tunnel remote address */
ip46_address_t remote;
/* FIB indices */
u32 encap_fib_index; /* tunnel partner lookup here */
u32 decap_fib_index; /* inner IP lookup here */
/** FIB indices - tunnel partner lookup here */
u32 encap_fib_index;
/** FIB indices - inner IP packet lookup here */
u32 decap_fib_index;
/* vxlan VNI in HOST byte order, shifted left 8 bits */
/** VXLAN GPE VNI in HOST byte order, shifted left 8 bits */
u32 vni;
/* vnet intfc hw/sw_if_index */
/** vnet intfc hw_if_index */
u32 hw_if_index;
/** vnet intfc sw_if_index */
u32 sw_if_index;
/* flags */
/** flags */
u32 flags;
} vxlan_gpe_tunnel_t;
/* Flags for vxlan_gpe_tunnel_t.flags */
/** Flags for vxlan_gpe_tunnel_t */
#define VXLAN_GPE_TUNNEL_IS_IPV4 1
/** next nodes for VXLAN GPE input */
#define foreach_vxlan_gpe_input_next \
_(DROP, "error-drop") \
_(IP4_INPUT, "ip4-input") \
_(IP6_INPUT, "ip6-input") \
_(ETHERNET_INPUT, "ethernet-input")
/** struct for next nodes for VXLAN GPE input */
typedef enum {
#define _(s,n) VXLAN_GPE_INPUT_NEXT_##s,
foreach_vxlan_gpe_input_next
@ -107,6 +134,7 @@ typedef enum {
VXLAN_GPE_INPUT_N_NEXT,
} vxlan_gpe_input_next_t;
/** struct for VXLAN GPE errors */
typedef enum {
#define vxlan_gpe_error(n,s) VXLAN_GPE_ERROR_##n,
#include <vnet/vxlan-gpe/vxlan_gpe_error.def>
@ -114,22 +142,25 @@ typedef enum {
VXLAN_GPE_N_ERROR,
} vxlan_gpe_input_error_t;
/** Struct for VXLAN GPE node state */
typedef struct {
/* vector of encap tunnel instances */
/** vector of encap tunnel instances */
vxlan_gpe_tunnel_t *tunnels;
/* lookup tunnel by key */
/** lookup IPv4 VXLAN GPE tunnel by key */
uword * vxlan4_gpe_tunnel_by_key;
/** lookup IPv6 VXLAN GPE tunnel by key */
uword * vxlan6_gpe_tunnel_by_key;
/* Free vlib hw_if_indices */
/** Free vlib hw_if_indices */
u32 * free_vxlan_gpe_tunnel_hw_if_indices;
/* Mapping from sw_if_index to tunnel index */
/** Mapping from sw_if_index to tunnel index */
u32 * tunnel_index_by_sw_if_index;
/* convenience */
/** State convenience vlib_main_t */
vlib_main_t * vlib_main;
/** State convenience vnet_main_t */
vnet_main_t * vnet_main;
} vxlan_gpe_main_t;
@ -141,6 +172,7 @@ extern vlib_node_registration_t vxlan6_gpe_input_node;
u8 * format_vxlan_gpe_encap_trace (u8 * s, va_list * args);
/** Struct for VXLAN GPE add/del args */
typedef struct {
u8 is_add;
u8 is_ip6;

View File

@ -12,10 +12,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @file
* @brief VXLAN GPE packet header structure
*
*/
#ifndef included_vxlan_gpe_packet_h
#define included_vxlan_gpe_packet_h
/*
/**
* From draft-quinn-vxlan-gpe-03.txt
*
* 0 1 2 3
@ -52,25 +57,45 @@
* 0x4 : Network Service Header [NSH]
*/
#define foreach_vxlan_gpe_protocol \
/**
* @brief VXLAN GPE support inner protocol definition.
* 1 - IP4
* 2 - IP6
* 3 - ETHERNET
* 4 - NSH
*/
#define foreach_vxlan_gpe_protocol \
_ (0x01, IP4) \
_ (0x02, IP6) \
_ (0x03, ETHERNET) \
_ (0x04, NSH)
_ (0x04, NSH)
/**
* @brief Struct for VXLAN GPE support inner protocol definition.
* 1 - IP4
* 2 - IP6
* 3 - ETHERNET
* 4 - NSH
*/
typedef enum {
#define _(n,f) VXLAN_GPE_PROTOCOL_##f = n,
foreach_vxlan_gpe_protocol
#undef _
} vxlan_gpe_protocol_t;
/**
* @brief VXLAN GPE Header definition
*/
typedef struct {
u8 flags;
/** Version and Reserved */
u8 ver_res;
/** Reserved */
u8 res;
/* see vxlan_gpe_protocol_t */
/** see vxlan_gpe_protocol_t */
u8 protocol;
/** VNI and Reserved */
u32 vni_res;
} vxlan_gpe_header_t;

View File

@ -360,7 +360,10 @@ int vnet_vxlan_add_del_tunnel
if (!a->is_ip6)
hash_unset (vxm->vxlan4_tunnel_by_key, key4.as_u64);
else
hash_unset_mem (vxm->vxlan6_tunnel_by_key, t->key6);
{
hash_unset_mem (vxm->vxlan6_tunnel_by_key, t->key6);
clib_mem_free (t->key6);
}
vec_free (t->rewrite);
pool_put (vxm->tunnels, t);

View File

@ -11130,7 +11130,7 @@ api_map_add_domain (vat_main_t * vam)
0, psid_length = 0;
u8 is_translation = 0;
u32 mtu = 0;
u8 ip6_src_len = 128;
u32 ip6_src_len = 128;
while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
{
@ -11653,7 +11653,7 @@ api_lisp_add_del_locator_set (vat_main_t * vam)
vec_len (locator_set_name));
vec_free (locator_set_name);
mp->locator_num = vec_len (locators);
mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
if (locators)
clib_memcpy (mp->locators, locators,
(sizeof (ls_locator_t) * vec_len (locators)));
@ -12273,11 +12273,17 @@ api_lisp_eid_table_add_del_map (vat_main_t * vam)
return -99;
}
if (vrf_set && bd_index_set)
{
errmsg ("error: both vrf and bd entered!");
return -99;
}
M (LISP_EID_TABLE_ADD_DEL_MAP, lisp_eid_table_add_del_map);
mp->is_add = is_add;
mp->vni = htonl (vni);
mp->dp_table = htonl (vrf);
mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
mp->is_l2 = bd_index_set;
/* send */
@ -12397,7 +12403,7 @@ api_lisp_add_del_remote_mapping (vat_main_t * vam)
mp->eid_type = eid->type;
lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
mp->rloc_num = vec_len (rlocs);
mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
clib_memcpy (mp->rlocs, rlocs, (sizeof (rloc_t) * vec_len (rlocs)));
vec_free (rlocs);

View File

@ -92,9 +92,7 @@
#include <vnet/ipsec/ipsec.h>
#include <vnet/ipsec/ikev2.h>
#endif /* IPSEC */
#if DPDK > 0
#include <vnet/devices/virtio/vhost-user.h>
#endif
#include <stats/stats.h>
#include <oam/oam.h>
@ -4023,16 +4021,20 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
{
int rv = 0;
vl_api_create_vhost_user_if_reply_t *rmp;
#if DPDK > 0
u32 sw_if_index = (u32) ~ 0;
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
rv = vhost_user_create_if (vnm, vm, (char *) mp->sock_filename,
mp->is_server, &sw_if_index, (u64) ~ 0,
mp->renumber, ntohl (mp->custom_dev_instance),
(mp->use_custom_mac) ? mp->mac_address : NULL);
#if DPDK > 0 && DPDK_VHOST_USER
rv = dpdk_vhost_user_create_if (
#else
rv = vhost_user_create_if (
#endif
vnm, vm, (char *) mp->sock_filename,
mp->is_server, &sw_if_index, (u64) ~ 0,
mp->renumber, ntohl (mp->custom_dev_instance),
(mp->use_custom_mac) ? mp->mac_address : NULL);
/* *INDENT-OFF* */
REPLY_MACRO2(VL_API_CREATE_VHOST_USER_IF_REPLY,
@ -4040,10 +4042,6 @@ vl_api_create_vhost_user_if_t_handler (vl_api_create_vhost_user_if_t * mp)
rmp->sw_if_index = ntohl (sw_if_index);
}));
/* *INDENT-ON* */
#else
rv = VNET_API_ERROR_UNIMPLEMENTED;
REPLY_MACRO (VL_API_CREATE_VHOST_USER_IF_REPLY);
#endif
}
static void
@ -4051,19 +4049,19 @@ vl_api_modify_vhost_user_if_t_handler (vl_api_modify_vhost_user_if_t * mp)
{
int rv = 0;
vl_api_modify_vhost_user_if_reply_t *rmp;
#if DPDK > 0 && DPDK_VHOST_USER
u32 sw_if_index = ntohl (mp->sw_if_index);
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
rv = dpdk_vhost_user_modify_if (vnm, vm, (char *) mp->sock_filename,
mp->is_server, sw_if_index, (u64) ~ 0,
mp->renumber,
ntohl (mp->custom_dev_instance));
#if DPDK > 0 && DPDK_VHOST_USER
rv = dpdk_vhost_user_modify_if (
#else
rv = VNET_API_ERROR_UNIMPLEMENTED;
rv = vhost_user_modify_if (
#endif
vnm, vm, (char *) mp->sock_filename,
mp->is_server, sw_if_index, (u64) ~ 0,
mp->renumber, ntohl (mp->custom_dev_instance));
REPLY_MACRO (VL_API_MODIFY_VHOST_USER_IF_REPLY);
}
@ -4072,14 +4070,17 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp)
{
int rv = 0;
vl_api_delete_vhost_user_if_reply_t *rmp;
#if DPDK > 0 && DPDK_VHOST_USER
vpe_api_main_t *vam = &vpe_api_main;
u32 sw_if_index = ntohl (mp->sw_if_index);
vnet_main_t *vnm = vnet_get_main ();
vlib_main_t *vm = vlib_get_main ();
#if DPDK > 0 && DPDK_VHOST_USER
rv = dpdk_vhost_user_delete_if (vnm, vm, sw_if_index);
#else
rv = vhost_user_delete_if (vnm, vm, sw_if_index);
#endif
REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY);
if (!rv)
@ -4091,10 +4092,6 @@ vl_api_delete_vhost_user_if_t_handler (vl_api_delete_vhost_user_if_t * mp)
send_sw_interface_flags_deleted (vam, q, sw_if_index);
}
#else
rv = VNET_API_ERROR_UNIMPLEMENTED;
REPLY_MACRO (VL_API_DELETE_VHOST_USER_IF_REPLY);
#endif
}
static void
@ -4104,7 +4101,6 @@ static void
clib_warning ("BUG");
}
#if DPDK > 0 && DPDK_VHOST_USER
static void
send_sw_interface_vhost_user_details (vpe_api_main_t * am,
unix_shared_memory_queue_t * q,
@ -4131,13 +4127,11 @@ send_sw_interface_vhost_user_details (vpe_api_main_t * am,
vl_msg_api_send_shmem (q, (u8 *) & mp);
}
#endif
static void
vl_api_sw_interface_vhost_user_dump_t_handler
(vl_api_sw_interface_vhost_user_dump_t * mp)
{
#if DPDK > 0 && DPDK_VHOST_USER
int rv = 0;
vpe_api_main_t *am = &vpe_api_main;
vnet_main_t *vnm = vnet_get_main ();
@ -4150,7 +4144,11 @@ static void
if (q == 0)
return;
#if DPDK > 0 && DPDK_VHOST_USER
rv = dpdk_vhost_user_dump_ifs (vnm, vm, &ifaces);
#else
rv = vhost_user_dump_ifs (vnm, vm, &ifaces);
#endif
if (rv)
return;
@ -4159,7 +4157,6 @@ static void
send_sw_interface_vhost_user_details (am, q, vuid, mp->context);
}
vec_free (ifaces);
#endif
}
static void
@ -5124,7 +5121,7 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
vnet_lisp_add_del_locator_set_args_t _a, *a = &_a;
locator_t locator;
ls_locator_t *ls_loc;
u32 ls_index = ~0;
u32 ls_index = ~0, locator_num;
u8 *locator_name = NULL;
int i;
@ -5135,9 +5132,10 @@ vl_api_lisp_add_del_locator_set_t_handler (vl_api_lisp_add_del_locator_set_t *
a->name = locator_name;
a->is_add = mp->is_add;
a->local = 1;
locator_num = clib_net_to_host_u32 (mp->locator_num);
memset (&locator, 0, sizeof (locator));
for (i = 0; i < mp->locator_num; i++)
for (i = 0; i < locator_num; i++)
{
ls_loc = &((ls_locator_t *) mp->locators)[i];
VALIDATE_SW_IF_INDEX (ls_loc);
@ -5480,7 +5478,7 @@ static void
if (rv)
goto send_reply;
rlocs = unformat_lisp_locs (mp->rlocs, mp->rloc_num);
rlocs = unformat_lisp_locs (mp->rlocs, clib_net_to_host_u32 (mp->rloc_num));
if (0 == rlocs)
goto send_reply;
@ -5499,7 +5497,7 @@ static void
/* NOTE: for now this works as a static remote mapping, i.e.,
* not authoritative and ttl infinite. */
rv = vnet_lisp_add_del_mapping (eid, rlocs, mp->action, 0, ~0,
mp->is_add, 0);
mp->is_add, 1 /* is_static */ , 0);
if (mp->del_all)
vnet_lisp_clear_all_remote_adjacencies ();
@ -5747,9 +5745,8 @@ vl_api_lisp_eid_table_dump_t_handler (vl_api_lisp_eid_table_dump_t * mp)
{
memset (eid, 0, sizeof (*eid));
unformat_lisp_eid_api (eid, mp->eid_type,
clib_net_to_host_u32 (mp->vni), mp->eid,
mp->prefix_length);
unformat_lisp_eid_api (eid, clib_net_to_host_u32 (mp->vni),
mp->eid_type, mp->eid, mp->prefix_length);
mi = gid_dictionary_lookup (&lcm->mapping_index_by_gid, eid);
if ((u32) ~ 0 == mi)

View File

@ -2318,7 +2318,7 @@ static void *vl_api_lisp_add_del_remote_mapping_t_print
mp->eid_type, mp->eid, mp->eid_len, mp->seid, mp->seid_len,
mp->is_src_dst);
rloc_num = mp->rloc_num;
rloc_num = clib_net_to_host_u32 (mp->rloc_num);
if (0 == rloc_num)
s = format (s, "action %d", mp->action);
@ -2470,7 +2470,7 @@ static void *vl_api_lisp_add_del_locator_set_t_print
s = format (s, "locator-set %s ", mp->locator_set_name);
loc_num = mp->locator_num;
loc_num = clib_net_to_host_u32 (mp->locator_num);
locs = (ls_locator_t *) mp->locators;
for (i = 0; i < loc_num; i++)