summaryrefslogtreecommitdiffstats
path: root/src/vnet/gre
AgeCommit message (Collapse)AuthorFilesLines
2018-01-30Allow the provider of a midchain adjacency to pass context data that is ↵Neale Ranns1-4/+7
returned in the fixup function Change-Id: I458e6e03b03e27775df33a2fd302743126d6ac44 Signed-off-by: Neale Ranns <nranns@cisco.com>
2018-01-23VPPAPIGEN: vppapigen replacement in Python PLY.Ole Troan1-1/+1
This is a version of the VPP API generator in Python PLY. It supports the existing language, and has a plugin architecture for generators. Currently C and JSON are supported. Changes: - vl_api_version to option version = "major.minor.patch" - enum support - Added error checking and reporting - import support (removed the C pre-processor) - services (tying request/reply together) Version: option version = "1.0.0"; Enum: enum colours { RED, BLUE = 50, }; define foo { vl_api_colours_t colours; }; Services: service { rpc foo returns foo_reply; rpc foo_dump returns stream foo_details; rpc want_stats returns want_stats_reply events ip4_counters, ip6_counters; }; Future planned features: - unions - bool, text - array support (including length) - proto3 output plugin - Refactor C/C++ generator as a plugin - Refactor Java generator as a plugin Change-Id: Ifa289966c790e1b1a8e2938a91e69331e3a58bdf Signed-off-by: Ole Troan <ot@cisco.com>
2018-01-13Improve "show xxx tunnel" and "show int addr" outputJohn Lo1-23/+7
Improve "show xxx tunnel" output functions format_xxx_tunnel() for GRE, VXLAN, VXLAN-GPE, GENEVE and GTPU tunnels to make their output more consistent and provide better information. Improved the output of "show int addr" to make its info more consistent with tunnels and provide fib-index info. Change-Id: Icd4b5b85a5bec417f8ee19afea336c770ad3b4c5 Signed-off-by: John Lo <loj@cisco.com>
2018-01-11api: remove transport specific code from handlersFlorin Coras1-10/+8
This does not update api client code. In other words, if the client assumes the transport is shmem based, this patch does not change that. Furthermore, code that checks queue size, for tail dropping, is not updated. Done for the following apis: Plugins - acl - gtpu - memif - nat - pppoe VNET - bfd - bier - tapv2 - vhost user - dhcp - flow - geneve - ip - punt - ipsec/ipsec-gre - l2 - l2tp - lisp-cp/one-cp - lisp-gpe - map - mpls - policer - session - span - udp - tap - vxlan/vxlan-gpe - interface VPP - api/api.c OAM - oam_api.c Stats - stats.c Change-Id: I0e33ecefb2bdab0295698c0add948068a5a83345 Signed-off-by: Florin Coras <fcoras@cisco.com>
2018-01-09api: refactor vlibmemoryFlorin Coras1-2/+2
- separate client/server code for both memory and socket apis - separate memory api code from generic vlib api code - move unix_shared_memory_fifo to svm and rename to svm_fifo_t - overall declutter Change-Id: I90cdd98ff74d0787d58825b914b0f1eafcfa4dc2 Signed-off-by: Florin Coras <fcoras@cisco.com>
2018-01-09GRE tunnel key should use fib_index instead of fib_id (VPP-1118)John Lo1-12/+1
Follow up fix - vl_api_gre_add_del_tunnel_t_handler should pass outer_fib_id from API message to vnet_gre_add_del_tunnel() and not convert it to fib_index, since vnet_gre_add_del_tunnel() already perform the lookup to get fib_index from fib_id. Change-Id: I24967a97f82ce018ddef596e556bd3eb1706cb63 Signed-off-by: John Lo <loj@cisco.com>
2018-01-06GRE tunnel key should use fib_index instead of fib_id (VPP-1118)John Lo1-2/+11
The code path in src/vnet/gre/interface.c uses fib_id as a component to generate hash key for GRE tunnel. This should be fib_index as the GRE rx/decap data path will be using fib_index to generate the hash key to lookup the GRE tunnel. Change-Id: Ia7f0892d84f9dac79223a6e016775892b61eb5fb Signed-off-by: John Lo <loj@cisco.com> (cherry picked from commit 72247c803250894834d15952a6fddcd8f4a39a9c)
2017-12-16GRE tunnel key includes the FIB tableNeale Ranns4-137/+219
- GRE tunnels with the same src,dst addresses are not the same tunnel - Two data-plane improvements: - the cached key was never updated and so useless - no need to dereference the tunnel's HW interface to get the sw_if_index Change-Id: I2f2ea6e08c759a810b753cec22c497e921a2ca01 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-12-13GRE: fix single loop decap and add testNeale Ranns1-1/+1
Change-Id: I64e8a76a17057ae69de72a5a80c0a194cd0c21cb Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-11-27VPP-253 Coding standards cleanup - vnet/vnet/greSwarup Nayak6-878/+968
Change-Id: I95f98b91faf74178c05f30da9eb3d6125193b7ef Signed-off-by: Swarup Nayak <swarupnpvt@gmail.com>
2017-11-26FIB: store the node type not the function pointer.Neale Ranns1-2/+0
Saves memory at no appreciable performance cost. before: DBGvpp# sh fib mem FIB memory Name Size in-use /allocated totals Entry 80 7 / 150 560/12000 after: DBGvpp# sh fib mem FIB memory Name Size in-use /allocated totals Entry 72 7 / 7 504/504 Change-Id: Ic5d3920ceb57b54260dc9af2078c26484335fef1 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-10-24Add extern to *_main global variable declarations in header files.Dave Wallace1-1/+1
- Global variables declared in header files without the use of the 'extern' keword will result in multiple instances of the variable to be created by the compiler -- one for each different source file in which the the header file is included. This results in wasted memory allocated in the BSS segments as well as potentially introducing bugs in the application. Change-Id: I6ef1790b60a0bd9dd3994f8510723decf258b0cc Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
2017-10-09vppapigen: support per-file (major,minor,patch) version stampsDave Barach1-0/+2
Add one of these statements to foo.api: vl_api_version 1.2.3 to generate a version tuple stanza in foo.api.h: /****** Version tuple *****/ vl_api_version_tuple(foo, 1, 2, 3) Change-Id: Ic514439e4677999daa8463a94f948f76b132ff15 Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Ole Troan <ot@cisco.com>
2017-10-04[aarch64] Fixes CLI crashes on dpaa2 platform.Christophe Fontaine1-1/+1
- always use 'va_args' as pointer in all format_* functions - u32 for all 'indent' params as it's declaration was inconsistent Change-Id: Ic5799309a6b104c9b50fec309cba789c8da99e79 Signed-off-by: Christophe Fontaine <christophe.fontaine@enea.com>
2017-04-13Remove unsed parameter from fib_table_entry_special_add() (only used in FIB ↵Neale Ranns1-2/+1
tests). The DPO was incorrectly initialised with FIB_PROTO_MAX Change-Id: I962df9e162e4dfb6837a5ce79ea795d5ff2d7315 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-04-06Use thread local storage for thread indexDamjan Marion1-4/+4
This patch deprecates stack-based thread identification, Also removes requirement that thread stacks are adjacent. Finally, possibly annoying for some folks, it renames all occurences of cpu_index and cpu_number with thread index. Using word "cpu" is misleading here as thread can be migrated ti different CPU, and also it is not related to linux cpu index. Change-Id: I68cdaf661e701d2336fc953dcb9978d10a70f7c1 Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-04-05GRE over IPv6Ciara Loftus5-165/+533
Refactors the GRE node to work with both IPv4 and IPv6 transports. Note that this changes the binary configuration API to support both address families; each address uses the same memory for either address type and a flag to indicate which is in use. The CLI and VAT syntax remains unchanged; the code detects whether an IPv4 or an IPv6 address was given. Configuration examples: IPv4 CLI: create gre tunnel src 192.168.1.1 dst 192.168.1.2 IPv6 CLI: create gre tunnel src 2620:124:9000::1 dst 2620:124:9000::2 IPv4 VAT: gre_add_del_tunnel src 192.168.1.1 dst 192.168.1.2 IPv6 VAT: gre_add_del_tunnel src 2620:124:9000::1 dst 2620:124:9000::2 Change-Id: Ica8ee775dc101047fb8cd41617ddc8fafc2741b0 Signed-off-by: Ciara Loftus <ciara.loftus@intel.com>
2017-04-04Fix issue with gre protocol registration when running multithreadedDamjan Marion2-39/+15
Change-Id: Ic5bd7da08f8a46b548d56516e4633f0b8badf2a1 Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-04-03Adjacency layout change and move to vnet/adjNeale Ranns1-2/+2
Change-Id: I03195a86c69f84a301051c6b3ab64456bbf28645 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-03-16vlib: make runtime_data thread-localDamjan Marion1-5/+21
Change-Id: I4aa3e7e42fb81211de1aed07dc7befee87a1e18b Signed-off-by: Damjan Marion <damarion@cisco.com>
2017-03-09Tests to target holes in adjacency and DPO test coverageNeale Ranns1-1/+3
Change-Id: Ic6ac7e441a7b75baa02f03c1585d1ae00903a399 Signed-off-by: Neale Ranns <nranns@cisco.com>
2017-02-22VPP-635: CLI Memory leak with invalid parameterBilly McFall1-10/+25
In the CLI parsing, below is a common pattern: /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "x")) x = 1; : else return clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); } unformat_free (line_input); The 'else' returns if an unknown string is encountered. There a memory leak because the 'unformat_free(line_input)' is not called. There is a large number of instances of this pattern. Replaced the previous pattern with: /* Get a line of input. */ if (!unformat_user (input, unformat_line_input, line_input)) return 0; while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) { if (unformat (line_input, "x")) x = 1; : else { error = clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); goto done: } } /* ...Remaining code... */ done: unformat_free (line_input); return error; } In multiple files, 'unformat_free (line_input);' was never called, so there was a memory leak whether an invalid string was entered or not. Also, there were multiple instance where: error = clib_error_return (0, "unknown input `%U'", format_unformat_error, line_input); used 'input' as the last parameter instead of 'line_input'. The result is that output did not contain the substring in error, instead just an empty string. Fixed all of those as well. There are a lot of file, and very mind numbing work, so tried to keep it to a pattern to avoid mistakes. Change-Id: I8902f0c32a47dd7fb3bb3471a89818571702f1d2 Signed-off-by: Billy McFall <bmcfall@redhat.com> Signed-off-by: Dave Barach <dave@barachs.net>
2017-02-13Basic support for LISP-GPE encapsulated NSH packetsFlorin Coras1-0/+3
Change-Id: I97fedb0f70dd18ed9bbe985407cc5fe714e8a2e2 Signed-off-by: Florin Coras <fcoras@cisco.com>
2016-12-28Reorganize source tree to use single autotools instanceDamjan Marion9-0/+2243
Change-Id: I7b51f88292e057c6443b12224486f2d0c9f8ae23 Signed-off-by: Damjan Marion <damarion@cisco.com>
s="p">, sizeof (h->ethernet.src_address)); if (dst_address) clib_memcpy (h->ethernet.dst_address, dst_address, sizeof (h->ethernet.dst_address)); else clib_memset (h->ethernet.dst_address, ~0, sizeof (h->ethernet.dst_address)); /* broadcast */ h->ethernet.type = clib_host_to_net_u16 (type); h->srp.as_u16 = 0; h->srp.mode = SRP_MODE_data; h->srp.ttl = sm->default_data_ttl; srp_header_compute_parity (&h->srp); return (rewrite); } static void srp_register_interface_helper (u32 * hw_if_indices_by_side, u32 redistribute); void serialize_srp_main (serialize_main_t * m, va_list * va) { srp_main_t * sm = &srp_main; srp_interface_t * si; serialize_integer (m, pool_elts (sm->interface_pool), sizeof (u32)); pool_foreach (si, sm->interface_pool, ({ serialize_integer (m, si->rings[SRP_RING_OUTER].hw_if_index, sizeof (u32)); serialize_integer (m, si->rings[SRP_RING_INNER].hw_if_index, sizeof (u32)); })); } void unserialize_srp_main (serialize_main_t * m, va_list * va) { u32 i, n_ifs, hw_if_indices[SRP_N_RING]; unserialize_integer (m, &n_ifs, sizeof (u32)); for (i = 0; i < n_ifs; i++) { unserialize_integer (m, &hw_if_indices[SRP_RING_OUTER], sizeof (u32)); unserialize_integer (m, &hw_if_indices[SRP_RING_INNER], sizeof (u32)); srp_register_interface_helper (hw_if_indices, /* redistribute */ 0); } } static void srp_register_interface_helper (u32 * hw_if_indices_by_side, u32 redistribute) { vnet_main_t * vnm = vnet_get_main(); srp_main_t * sm = &srp_main; srp_interface_t * si; vnet_hw_interface_t * hws[SRP_N_RING]; uword s, * p; /* Check if interface has already been registered. */ p = hash_get (sm->interface_index_by_hw_if_index, hw_if_indices_by_side[0]); if (p) { si = pool_elt_at_index (sm->interface_pool, p[0]); } else { pool_get (sm->interface_pool, si); clib_memset (si, 0, sizeof (si[0])); } for (s = 0; s < SRP_N_SIDE; s++) { hws[s] = vnet_get_hw_interface (vnm, hw_if_indices_by_side[s]); si->rings[s].ring = s; si->rings[s].hw_if_index = hw_if_indices_by_side[s]; si->rings[s].sw_if_index = hws[s]->sw_if_index; hash_set (sm->interface_index_by_hw_if_index, hw_if_indices_by_side[s], si - sm->interface_pool); } /* Inherit MAC address from outer ring. */ clib_memcpy (si->my_address, hws[SRP_RING_OUTER]->hw_address, vec_len (hws[SRP_RING_OUTER]->hw_address)); /* Default time to wait to restore signal. */ si->config.wait_to_restore_idle_delay = 60; si->config.ips_tx_interval = 1; } void srp_register_interface (u32 * hw_if_indices_by_side) { srp_register_interface_helper (hw_if_indices_by_side, /* redistribute */ 1); } void srp_interface_set_hw_wrap_function (u32 hw_if_index, srp_hw_wrap_function_t * f) { srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index); si->hw_wrap_function = f; } void srp_interface_set_hw_enable_function (u32 hw_if_index, srp_hw_enable_function_t * f) { srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index); si->hw_enable_function = f; } void srp_interface_enable_ips (u32 hw_if_index) { srp_main_t * sm = &srp_main; srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index); si->ips_process_enable = 1; vlib_node_set_state (sm->vlib_main, srp_ips_process_node.index, VLIB_NODE_STATE_POLLING); } static uword srp_is_valid_class_for_interface (vnet_main_t * vnm, u32 hw_if_index, u32 hw_class_index) { srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index); if (! si) return 0; /* Both sides must be admin down. */ if (vnet_sw_interface_is_admin_up (vnm, si->rings[SRP_RING_OUTER].sw_if_index)) return 0; if (vnet_sw_interface_is_admin_up (vnm, si->rings[SRP_RING_INNER].sw_if_index)) return 0; return 1; } static void srp_interface_hw_class_change (vnet_main_t * vnm, u32 hw_if_index, u32 old_hw_class_index, u32 new_hw_class_index) { srp_main_t * sm = &srp_main; srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index); vnet_hw_interface_t * hi; vnet_device_class_t * dc; u32 r, to_srp; if (!si) { clib_warning ("srp interface no set si = 0"); return; } to_srp = new_hw_class_index == srp_hw_interface_class.index; /* Changing class on either outer or inner rings implies changing the class of the other. */ for (r = 0; r < SRP_N_RING; r++) { srp_interface_ring_t * ir = &si->rings[r]; hi = vnet_get_hw_interface (vnm, ir->hw_if_index); dc = vnet_get_device_class (vnm, hi->dev_class_index); /* hw_if_index itself will be handled by caller. */ if (ir->hw_if_index != hw_if_index) { vnet_hw_interface_init_for_class (vnm, ir->hw_if_index, new_hw_class_index, to_srp ? si - sm->interface_pool : ~0); if (dc->hw_class_change) dc->hw_class_change (vnm, ir->hw_if_index, new_hw_class_index); } else hi->hw_instance = to_srp ? si - sm->interface_pool : ~0; } if (si->hw_enable_function) si->hw_enable_function (si, /* enable */ to_srp); } VNET_HW_INTERFACE_CLASS (srp_hw_interface_class) = { .name = "SRP", .format_address = format_ethernet_address, .format_header = format_srp_header_with_length, .format_device = format_srp_device, .unformat_hw_address = unformat_ethernet_address, .unformat_header = unformat_srp_header, .build_rewrite = srp_build_rewrite, .update_adjacency = ethernet_update_adjacency, .is_valid_class_for_interface = srp_is_valid_class_for_interface, .hw_class_change = srp_interface_hw_class_change, }; void srp_interface_get_interface_config (u32 hw_if_index, srp_interface_config_t * c) { srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index); ASSERT (si != 0); c[0] = si->config; } void srp_interface_set_interface_config (u32 hw_if_index, srp_interface_config_t * c) { srp_interface_t * si = srp_get_interface_from_vnet_hw_interface (hw_if_index); ASSERT (si != 0); if (memcmp (&si->config, &c[0], sizeof (c[0]))) { si->config = c[0]; } } #if DEBUG > 0 #define VNET_SIMULATED_SRP_TX_NEXT_SRP_INPUT VNET_INTERFACE_TX_N_NEXT /* Echo packets back to srp input. */ static uword simulated_srp_interface_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame) { u32 n_left_from, n_left_to_next, n_copy, * from, * to_next; u32 next_index = VNET_SIMULATED_SRP_TX_NEXT_SRP_INPUT; u32 i; vlib_buffer_t * b; n_left_from = frame->n_vectors; from = vlib_frame_vector_args (frame); while (n_left_from > 0) { vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next); n_copy = clib_min (n_left_from, n_left_to_next); clib_memcpy_fast (to_next, from, n_copy * sizeof (from[0])); n_left_to_next -= n_copy; n_left_from -= n_copy; for (i = 0; i < n_copy; i++) { b = vlib_get_buffer (vm, from[i]); /* TX interface will be fake eth; copy to RX for benefit of srp-input. */ b->sw_if_index[VLIB_RX] = b->sw_if_index[VLIB_TX]; } vlib_put_next_frame (vm, node, next_index, n_left_to_next); } return n_left_from; } static u8 * format_simulated_srp_name (u8 * s, va_list * args) { u32 dev_instance = va_arg (*args, u32); return format (s, "fake-srp%d", dev_instance); } VNET_DEVICE_CLASS (srp_simulated_device_class,static) = { .name = "Simulated srp", .format_device_name = format_simulated_srp_name, .tx_function = simulated_srp_interface_tx, }; static clib_error_t * create_simulated_srp_interfaces (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { vnet_main_t * vnm = vnet_get_main(); u8 address[6]; u32 hw_if_index; vnet_hw_interface_t * hi; static u32 instance; if (! unformat_user (input, unformat_ethernet_address, &address)) { clib_memset (address, 0, sizeof (address)); address[0] = 0xde; address[1] = 0xad; address[5] = instance; } hw_if_index = vnet_register_interface (vnm, srp_simulated_device_class.index, instance++, srp_hw_interface_class.index, 0); hi = vnet_get_hw_interface (vnm, hw_if_index); srp_setup_node (vm, hi->output_node_index); hi->min_packet_bytes = 40 + 16; /* Standard default ethernet MTU. */ vnet_sw_interface_set_mtu (vnm, sw_if_index, 1500); vec_free (hi->hw_address); vec_add (hi->hw_address, address, sizeof (address)); { uword slot; slot = vlib_node_add_named_next_with_slot (vm, hi->tx_node_index, "srp-input", VNET_SIMULATED_SRP_TX_NEXT_SRP_INPUT); ASSERT (slot == VNET_SIMULATED_SRP_TX_NEXT_SRP_INPUT); } return /* no error */ 0; } static VLIB_CLI_COMMAND (create_simulated_srp_interface_command) = { .path = "srp create-interfaces", .short_help = "Create simulated srp interface", .function = create_simulated_srp_interfaces, }; #endif