diff options
author | Neale Ranns <nranns@cisco.com> | 2016-10-03 09:40:25 +0100 |
---|---|---|
committer | Florin Coras <florin.coras@gmail.com> | 2016-10-03 11:45:15 +0000 |
commit | 5e575b1d59a5a4c1590ca09d6383a876fb9fdd25 (patch) | |
tree | fcba6d058fe32d9b32fe246577565020d10455ff /vnet/vnet/ethernet | |
parent | 553d808fc44e61846e4cda108083dd88beb338e3 (diff) |
L2 over LISP and GRE (VPP-457)
Change-Id: I0d7f9c7f41a9f9e0acb0950adedb90d45df08c2a
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'vnet/vnet/ethernet')
-rw-r--r-- | vnet/vnet/ethernet/ethernet.h | 26 | ||||
-rw-r--r-- | vnet/vnet/ethernet/init.c | 32 | ||||
-rw-r--r-- | vnet/vnet/ethernet/interface.c | 41 |
3 files changed, 89 insertions, 10 deletions
diff --git a/vnet/vnet/ethernet/ethernet.h b/vnet/vnet/ethernet/ethernet.h index 1855b9144db..728da522e3a 100644 --- a/vnet/vnet/ethernet/ethernet.h +++ b/vnet/vnet/ethernet/ethernet.h @@ -43,6 +43,7 @@ #include <vnet/vnet.h> #include <vnet/ethernet/packet.h> #include <vnet/pg/pg.h> +#include <vnet/ip/ip_feature_registration.h> always_inline u64 ethernet_mac_address_u64 (u8 * a) @@ -224,7 +225,6 @@ typedef struct u32 input_next_mpls; } next_by_ethertype_t; - typedef struct { vlib_main_t *vlib_main; @@ -263,10 +263,34 @@ typedef struct /* debug: make sure we don't wipe out an ethernet registration by mistake */ u8 next_by_ethertype_register_called; + /** per-interface features */ + ip_config_main_t feature_config_mains[VNET_N_IP_FEAT]; + + /** Feature path configuration lists */ + vnet_ip_feature_registration_t *next_feature[VNET_N_IP_FEAT]; + + /** Save results for show command */ + char **feature_nodes[VNET_N_IP_FEAT]; + + /** feature node indicies */ + u32 ethernet_tx_feature_drop; } ethernet_main_t; ethernet_main_t ethernet_main; +#define VNET_ETHERNET_TX_FEATURE_INIT(x,...) \ + __VA_ARGS__ vnet_ip_feature_registration_t tx_##x; \ +static void __vnet_add_feature_registration_tx_##x (void) \ + __attribute__((__constructor__)) ; \ +static void __vnet_add_feature_registration_tx_##x (void) \ +{ \ + ethernet_main_t * im = ðernet_main; \ + tx_##x.next = im->next_feature[VNET_IP_TX_FEAT]; \ + im->next_feature[VNET_IP_TX_FEAT] = &tx_##x; \ +} \ +__VA_ARGS__ vnet_ip_feature_registration_t tx_##x + + always_inline ethernet_type_info_t * ethernet_get_type_info (ethernet_main_t * em, ethernet_type_t type) { diff --git a/vnet/vnet/ethernet/init.c b/vnet/vnet/ethernet/init.c index 86597c4f66c..513d9c66c18 100644 --- a/vnet/vnet/ethernet/init.c +++ b/vnet/vnet/ethernet/init.c @@ -39,6 +39,7 @@ #include <vlib/vlib.h> #include <vnet/ethernet/ethernet.h> +#include <vnet/ip/ip.h> // for feature registration /* Global main structure. */ ethernet_main_t ethernet_main; @@ -60,6 +61,34 @@ add_type (ethernet_main_t * em, ethernet_type_t type, char *type_name) hash_set_mem (em->type_info_by_name, ti->name, i); } +static char *feature_start_nodes[] = { + "adj-midchain-tx-no-count", +}; + +/* Built-in ip4 tx feature path definition */ +/* *INDENT-OFF* */ +VNET_ETHERNET_TX_FEATURE_INIT (ethernet_tx_drop, static) = +{ + .node_name = "error-drop", + .runs_before = 0, /* not before any other features */ + .feature_index = ðernet_main.ethernet_tx_feature_drop, +}; +/* *INDENT-ON* */ + +static clib_error_t * +ethernet_feature_init (vlib_main_t * vm) +{ + ip_config_main_t *cm = ðernet_main.feature_config_mains[VNET_IP_TX_FEAT]; + vnet_config_main_t *vcm = &cm->config_main; + + return (ip_feature_init_cast (vm, cm, vcm, + feature_start_nodes, + ARRAY_LEN (feature_start_nodes), + ethernet_main.next_feature[VNET_IP_TX_FEAT], + ðernet_main.feature_nodes + [VNET_IP_TX_FEAT])); +} + static clib_error_t * ethernet_init (vlib_main_t * vm) { @@ -87,7 +116,7 @@ ethernet_init (vlib_main_t * vm) if ((error = vlib_call_init_function (vm, ethernet_input_init))) return error; - return error; + return (ethernet_feature_init (vm)); } VLIB_INIT_FUNCTION (ethernet_init); @@ -99,7 +128,6 @@ ethernet_get_main (vlib_main_t * vm) return ðernet_main; } - /* * fd.io coding-style-patch-verification: ON * diff --git a/vnet/vnet/ethernet/interface.c b/vnet/vnet/ethernet/interface.c index 91d5a3c6aa3..43f1cd4af44 100644 --- a/vnet/vnet/ethernet/interface.c +++ b/vnet/vnet/ethernet/interface.c @@ -46,6 +46,13 @@ #include <vnet/lisp-gpe/lisp_gpe.h> #include <vnet/devices/af_packet/af_packet.h> +/** + * @file + * @brief Loopback Interfaces. + * + * This file contains code to manage loopback interfaces. + */ + int vnet_sw_interface_is_p2p (vnet_main_t * vnm, u32 sw_if_index) { @@ -57,13 +64,6 @@ vnet_sw_interface_is_p2p (vnet_main_t * vnm, u32 sw_if_index) hw->hw_class_index == srp_hw_interface_class.index)); } -/** - * @file - * @brief Loopback Interfaces. - * - * This file contains code to manage loopback interfaces. - */ - static uword ethernet_set_rewrite (vnet_main_t * vnm, u32 sw_if_index, @@ -691,6 +691,33 @@ VLIB_CLI_COMMAND (delete_sub_interface_command, static) = { }; /* *INDENT-ON* */ +static clib_error_t * +show_ethernet_interface_features_command_fn (vlib_main_t * vm, + unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + vnet_main_t *vnm = vnet_get_main (); + ethernet_main_t *em = ðernet_main; + u32 sw_if_index; + + if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) + return clib_error_return (0, "Interface not specified..."); + + vlib_cli_output (vm, "Ethernet feature paths configured on %U...", + format_vnet_sw_if_index_name, vnm, sw_if_index); + + ip_interface_features_show (vm, "Ethernet", + em->feature_config_mains, sw_if_index); + + return 0; +} + +VLIB_CLI_COMMAND (show_ethernet_interface_features_command, static) = +{ +.path = "show ethernet interface features",.short_help = + "show ethernet interface features <intfc>",.function = + show_ethernet_interface_features_command_fn,}; + /* * fd.io coding-style-patch-verification: ON * |