aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-05-23 12:38:22 -0400
committerDamjan Marion <dmarion@me.com>2019-05-24 08:23:15 +0000
commit34716fae918750e4fc7a7da4b06e0dfbdef2d1c5 (patch)
tree1dafbf3146545bf0b72663f665c758440083e843
parenta40776c76c28d241dff42c2155e7b91fc021858c (diff)
Remove historical ip4 icmp OAM code
Add a registration overwritten warning to ip4_icmp_register_type(...) Change-Id: I6c2aabdb979b54ec49e827225acc74559ac4caab Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r--src/vat/api_format.c56
-rw-r--r--src/vnet/ip/icmp4.c7
-rw-r--r--src/vpp/CMakeLists.txt3
-rw-r--r--src/vpp/api/custom_dump.c22
-rw-r--r--src/vpp/api/vpe_all_api_h.h3
-rw-r--r--src/vpp/oam/oam.api75
-rw-r--r--src/vpp/oam/oam.c644
-rw-r--r--src/vpp/oam/oam.h96
-rw-r--r--src/vpp/oam/oam_api.c127
9 files changed, 7 insertions, 1026 deletions
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 10e9d3e8593..b330a389ef8 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -5170,7 +5170,6 @@ _(proxy_arp_add_del_reply) \
_(proxy_arp_intfc_enable_disable_reply) \
_(sw_interface_set_unnumbered_reply) \
_(ip_neighbor_add_del_reply) \
-_(oam_add_del_reply) \
_(reset_fib_reply) \
_(dhcp_proxy_config_reply) \
_(dhcp_proxy_set_vss_reply) \
@@ -5379,7 +5378,6 @@ _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
_(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
_(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
_(CREATE_SUBIF_REPLY, create_subif_reply) \
-_(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
_(RESET_FIB_REPLY, reset_fib_reply) \
_(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
_(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
@@ -9538,59 +9536,6 @@ api_create_subif (vat_main_t * vam)
}
static int
-api_oam_add_del (vat_main_t * vam)
-{
- unformat_input_t *i = vam->input;
- vl_api_oam_add_del_t *mp;
- u32 vrf_id = 0;
- u8 is_add = 1;
- ip4_address_t src, dst;
- u8 src_set = 0;
- u8 dst_set = 0;
- int ret;
-
- while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (i, "vrf %d", &vrf_id))
- ;
- else if (unformat (i, "src %U", unformat_ip4_address, &src))
- src_set = 1;
- else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
- dst_set = 1;
- else if (unformat (i, "del"))
- is_add = 0;
- else
- {
- clib_warning ("parse error '%U'", format_unformat_error, i);
- return -99;
- }
- }
-
- if (src_set == 0)
- {
- errmsg ("missing src addr");
- return -99;
- }
-
- if (dst_set == 0)
- {
- errmsg ("missing dst addr");
- return -99;
- }
-
- M (OAM_ADD_DEL, mp);
-
- mp->vrf_id = ntohl (vrf_id);
- mp->is_add = is_add;
- clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
- clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
-
- S (mp);
- W (ret);
- return ret;
-}
-
-static int
api_reset_fib (vat_main_t * vam)
{
unformat_input_t *i = vam->input;
@@ -22414,7 +22359,6 @@ _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
"[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
"[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
"[outer_vlan_id_any][inner_vlan_id_any]") \
-_(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
_(reset_fib, "vrf <n> [ipv6]") \
_(dhcp_proxy_config, \
"svr <v46-address> src <v46-address>\n" \
diff --git a/src/vnet/ip/icmp4.c b/src/vnet/ip/icmp4.c
index 4ca108c63da..1cf6a93be50 100644
--- a/src/vnet/ip/icmp4.c
+++ b/src/vnet/ip/icmp4.c
@@ -737,10 +737,17 @@ void
ip4_icmp_register_type (vlib_main_t * vm, icmp4_type_t type, u32 node_index)
{
icmp4_main_t *im = &icmp4_main;
+ u32 old_next_index;
ASSERT ((int) type < ARRAY_LEN (im->ip4_input_next_index_by_type));
+ old_next_index = im->ip4_input_next_index_by_type[type];
+
im->ip4_input_next_index_by_type[type]
= vlib_node_add_next (vm, ip4_icmp_input_node.index, node_index);
+
+ if (old_next_index &&
+ (old_next_index != im->ip4_input_next_index_by_type[type]))
+ clib_warning ("WARNING: changed next_by_type[%d]", (int) type);
}
static clib_error_t *
diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt
index d14aa6145ea..a5ac2f6d81a 100644
--- a/src/vpp/CMakeLists.txt
+++ b/src/vpp/CMakeLists.txt
@@ -35,7 +35,6 @@ option(VPP_API_TEST_BUILTIN "Use builtin VPP API test." ON)
set(VPP_API_FILES
api/vpe.api
- oam/oam.api
)
vpp_add_api_files(vpp ${VPP_API_FILES})
@@ -53,8 +52,6 @@ set(VPP_SOURCES
vnet/main.c
app/vpe_cli.c
app/version.c
- oam/oam.c
- oam/oam_api.c
stats/stat_segment.c
api/api.c
api/json_format.c
diff --git a/src/vpp/api/custom_dump.c b/src/vpp/api/custom_dump.c
index 622bd66a02c..0122496a6f6 100644
--- a/src/vpp/api/custom_dump.c
+++ b/src/vpp/api/custom_dump.c
@@ -42,7 +42,6 @@
#include <vlibmemory/api.h>
#include <vnet/lisp-cp/lisp_types.h>
#include <vnet/qos/qos_types.h>
-#include <vpp/oam/oam.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/ethernet/ethernet_types_api.h>
@@ -1101,26 +1100,6 @@ static void *vl_api_delete_subif_t_print
FINISH;
}
-static void *vl_api_oam_add_del_t_print
- (vl_api_oam_add_del_t * mp, void *handle)
-{
- u8 *s;
-
- s = format (0, "SCRIPT: oam_add_del ");
-
- if (mp->vrf_id)
- s = format (s, "vrf %d ", ntohl (mp->vrf_id));
-
- s = format (s, "src %U ", format_ip4_address, mp->src_address);
-
- s = format (s, "dst %U ", format_ip4_address, mp->dst_address);
-
- if (mp->is_add == 0)
- s = format (s, "del ");
-
- FINISH;
-}
-
static void *
vl_api_reset_fib_t_print (vl_api_reset_fib_t * mp, void *handle)
{
@@ -3799,7 +3778,6 @@ _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
_(IP_NEIGHBOR_ADD_DEL, ip_neighbor_add_del) \
_(CREATE_VLAN_SUBIF, create_vlan_subif) \
_(CREATE_SUBIF, create_subif) \
-_(OAM_ADD_DEL, oam_add_del) \
_(RESET_FIB, reset_fib) \
_(DHCP_PROXY_CONFIG, dhcp_proxy_config) \
_(DHCP_PROXY_SET_VSS, dhcp_proxy_set_vss) \
diff --git a/src/vpp/api/vpe_all_api_h.h b/src/vpp/api/vpe_all_api_h.h
index 343efe470db..397cd8074b3 100644
--- a/src/vpp/api/vpe_all_api_h.h
+++ b/src/vpp/api/vpe_all_api_h.h
@@ -28,9 +28,6 @@
/* Include the current layer (third) vpp API definition layer */
#include <vpp/api/vpe.api.h>
-/* Include OAM APIs */
-#include <vpp/oam/oam.api.h>
-
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vpp/oam/oam.api b/src/vpp/oam/oam.api
deleted file mode 100644
index 3823d8e2eed..00000000000
--- a/src/vpp/oam/oam.api
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2015-2017 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.
- */
-
-/** \file
-
- This file defines vpe control-plane API messages which are generally
- called through a shared memory interface.
-*/
-
-option version = "1.0.0";
-
-/** \brief OAM event structure
- @param dst_address[] -
- @param state
-*/
-define oam_event
-{
- u8 dst_address[4];
- u8 state;
-};
-
-/** \brief Want OAM events request
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param enable_disable- enable if non-zero, else disable
- @param pid - pid of the requesting process
-*/
-autoreply define want_oam_events
-{
- u32 client_index;
- u32 context;
- u32 enable_disable;
- u32 pid;
-};
-
-service {
- rpc want_oam_events returns want_oam_events_reply
- events oam_event;
-};
-
-/** \brief OAM add / del target request
- @param client_index - opaque cookie to identify the sender
- @param context - sender context, to match reply w/ request
- @param vrf_id - vrf_id of the target
- @param src_address[] - source address to use for the updates
- @param dst_address[] - destination address of the target
- @param is_add - add target if non-zero, else delete
-*/
-autoreply define oam_add_del
-{
- u32 client_index;
- u32 context;
- u32 vrf_id;
- u8 src_address[4];
- u8 dst_address[4];
- u8 is_add;
-};
-
-/*
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/src/vpp/oam/oam.c b/src/vpp/oam/oam.c
deleted file mode 100644
index 8cee64b9628..00000000000
--- a/src/vpp/oam/oam.c
+++ /dev/null
@@ -1,644 +0,0 @@
-/*
- * 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.
- */
-#include <vpp/oam/oam.h>
-
-oam_main_t oam_main;
-
-static vlib_node_registration_t oam_node;
-
-static void
-init_oam_packet_template (oam_main_t * om, oam_target_t * t)
-{
- oam_template_t *h;
- int i;
- ip_csum_t sum;
- u16 csum;
-
- vec_validate (t->template, 0);
-
- h = t->template;
- clib_memset (h, 0, sizeof (*h));
-
- h->ip4.src_address.as_u32 = t->src_address.as_u32;
- h->ip4.dst_address.as_u32 = t->dst_address.as_u32;
- h->ip4.ip_version_and_header_length = 0x45;
- h->ip4.length = clib_host_to_net_u16 (sizeof (*h));
- h->ip4.ttl = 64; /* as in linux */
- h->ip4.protocol = IP_PROTOCOL_ICMP;
- h->ip4.checksum = ip4_header_checksum (&h->ip4);
-
- /*
- * Template has seq = 0. Each time we send one of these puppies,
- * change the sequence number and fix the execrated checksum
- */
- h->icmp.type = ICMP4_echo_request;
- h->id = clib_host_to_net_u16 (t->id);
-
- for (i = 0; i < ARRAY_LEN (h->data); i++)
- h->data[i] = 'A' + i;
-
- sum = ip_incremental_checksum (0, &h->icmp,
- sizeof (h->icmp) + sizeof (h->id) +
- sizeof (h->seq) + sizeof (h->data));
- csum = ~ip_csum_fold (sum);
- h->icmp.checksum = csum;
-}
-
-int
-vpe_oam_add_del_target (ip4_address_t * src_address,
- ip4_address_t * dst_address, u32 fib_id, int is_add)
-{
- u64 key;
- uword *p;
- oam_main_t *om = &oam_main;
- oam_target_t *t;
- ip4_main_t *im = &ip4_main;
- u32 fib_index;
-
- /* Make sure the FIB actually exists */
- p = hash_get (im->fib_index_by_table_id, fib_id);
- if (!p)
- return VNET_API_ERROR_NO_SUCH_FIB;
-
- fib_index = p[0];
-
- key = ((u64) fib_index << 32) | (dst_address->as_u32);
- p = hash_get (om->target_by_address_and_fib_id, key);
-
- if (is_add)
- {
- if (p)
- return VNET_API_ERROR_INVALID_REGISTRATION; /* already there... */
-
- pool_get (om->targets, t);
- clib_memset (t, 0, sizeof (*t));
- t->src_address.as_u32 = src_address->as_u32;
- t->dst_address.as_u32 = dst_address->as_u32;
- t->fib_id = fib_id;
- t->fib_index = fib_index;
- t->state = OAM_STATE_DEAD;
- t->last_heard_time = vlib_time_now (om->vlib_main);
- t->last_heard_seq = (u16) ~ om->misses_allowed;
- t->id = (u16) random_u32 (&om->random_seed);
- t->seq = 1;
- init_oam_packet_template (om, t);
- hash_set (om->target_by_address_and_fib_id, key, t - om->targets);
- }
- else
- {
- if (!p)
- return VNET_API_ERROR_NO_SUCH_ENTRY; /* no such oam target */
- t = pool_elt_at_index (om->targets, p[0]);
- vec_free (t->template);
- hash_unset (om->target_by_address_and_fib_id, key);
- pool_put (om->targets, t);
- }
- return 0;
-}
-
-static clib_error_t *
-oam_add_del_target_command_fn (vlib_main_t * vm,
- unformat_input_t * input,
- vlib_cli_command_t * cmd)
-{
- int is_add = -1;
- ip4_address_t src_address;
- int src_set = 0;
- ip4_address_t dst_address;
- int dst_set = 0;
- u32 fib_id = 0;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "add"))
- is_add = 1;
- else if (unformat (input, "del"))
- is_add = 0;
- else if (unformat (input, "src %U", unformat_ip4_address, &src_address))
- src_set = 1;
- else if (unformat (input, "dst %U", unformat_ip4_address, &dst_address))
- dst_set = 1;
- else if (unformat (input, "fib %d", &fib_id))
- ;
- else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
- }
-
- if (is_add == -1)
- return clib_error_return (0, "missing add / del qualifier");
- if (src_set == 0)
- return clib_error_return (0, "src address not set");
- if (dst_set == 0)
- return clib_error_return (0, "dst address not set");
-
- (void) vpe_oam_add_del_target (&src_address, &dst_address, fib_id, is_add);
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (oam_add_del_target_command, static) = {
- .path = "oam",
- .short_help = "oam [add|del] target <ip4-address> fib <fib-id>",
- .function = oam_add_del_target_command_fn,
-};
-/* *INDENT-ON* */
-
-static uword
-oam_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f_arg)
-{
- oam_main_t *om = &oam_main;
- uword *event_data = 0;
- oam_target_t *t;
- oam_template_t *h0;
- u32 bi0;
- u16 new_seq;
- ip_csum_t sum0;
- vlib_frame_t *f;
- u32 *to_next, *from;
- u32 ip4_lookup_node_index;
- vlib_node_t *ip4_lookup_node;
- vlib_buffer_t *b0;
- static u32 *buffers;
- oam_template_copy_t *copy_src, *copy_dst;
- void send_oam_event (oam_target_t * t);
- u32 nalloc;
-
- /* Enqueue pkts to ip4-lookup */
- ip4_lookup_node = vlib_get_node_by_name (vm, (u8 *) "ip4-lookup");
- ip4_lookup_node_index = ip4_lookup_node->index;
-
- while (1)
- {
- /* Only timeout events at the moment */
- vlib_process_wait_for_event_or_clock (vm, om->interval);
- vec_reset_length (event_data);
-
- if (pool_elts (om->targets) == 0)
- continue;
-
- if (vec_len (buffers) < pool_elts (om->targets))
- vec_validate (buffers, pool_elts (om->targets) - 1);
-
- nalloc = vlib_buffer_alloc (vm, buffers, pool_elts (om->targets));
- if (nalloc < pool_elts (om->targets))
- {
- vlib_buffer_free (vm, buffers, nalloc);
- continue;
- }
-
- f = vlib_get_frame_to_node (vm, ip4_lookup_node_index);
- f->n_vectors = 0;
- to_next = vlib_frame_vector_args (f);
- from = buffers;
-
- /* *INDENT-OFF* */
- pool_foreach (t, om->targets,
- ({
- /* State transition announcement... */
- if ((t->seq - t->last_heard_seq) >= om->misses_allowed)
- {
- if (t->state == OAM_STATE_ALIVE)
- {
- if (CLIB_DEBUG > 0)
- clib_warning ("oam target %U now DEAD",
- format_ip4_address, &t->dst_address);
- t->state = OAM_STATE_DEAD;
- send_oam_event (t);
- }
- }
- else
- {
- if (t->state == OAM_STATE_DEAD)
- {
- if (CLIB_DEBUG > 0)
- clib_warning ("oam target %U now ALIVE",
- format_ip4_address, &t->dst_address);
- t->state = OAM_STATE_ALIVE;
- send_oam_event (t);
- }
- }
-
- /* Send a new icmp */
- t->seq++;
- new_seq = clib_host_to_net_u16 (t->seq);
-
- bi0 = from[0];
- from++;
-
- b0 = vlib_get_buffer (vm, bi0);
- vnet_buffer (b0)->sw_if_index[VLIB_RX] = 0;
- vnet_buffer (b0)->sw_if_index [VLIB_TX] = t->fib_index;
-
- /* Marginally faster than memcpy, probably */
- copy_dst = (oam_template_copy_t *) b0->data;
- copy_src = (oam_template_copy_t *) t->template;
-
- copy_dst->v8[0] = copy_src->v8[0];
- copy_dst->v8[1] = copy_src->v8[1];
- copy_dst->v8[2] = copy_src->v8[2];
- copy_dst->v8[3] = copy_src->v8[3];
- copy_dst->v4 = copy_src->v4;
-
- b0->current_data = 0;
- b0->current_length = sizeof (*t->template);
- h0 = vlib_buffer_get_current (b0);
-
- sum0 = h0->icmp.checksum;
- sum0 = ip_csum_update(sum0, 0 /* old seq */,
- new_seq, oam_template_t, seq);
- h0->seq = new_seq;
- h0->icmp.checksum = ip_csum_fold (sum0);
-
- to_next[0] = bi0;
- to_next++;
- f->n_vectors++;
- if (f->n_vectors == VLIB_FRAME_SIZE)
- {
- clib_warning ("Too many OAM clients...");
- goto out;
- }
- }));
- /* *INDENT-ON* */
-
- out:
- vlib_put_frame_to_node (vm, ip4_lookup_node_index, f);
- }
- return 0; /* not so much */
-}
-
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (oam_process_node,static) = {
- .function = oam_process,
- .type = VLIB_NODE_TYPE_PROCESS,
- .name = "vpe-oam-process",
-};
-/* *INDENT-ON* */
-
-static clib_error_t *
-oam_config (vlib_main_t * vm, unformat_input_t * input)
-{
- oam_main_t *om = &oam_main;
- f64 interval;
- u32 misses_allowed;
-
- while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
- {
- if (unformat (input, "interval %f", &interval))
- om->interval = interval;
- else if (unformat (input, "misses-allowed %d", &misses_allowed))
- om->interval = misses_allowed;
- else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
- }
- return 0;
-}
-
-VLIB_CONFIG_FUNCTION (oam_config, "oam");
-
-static clib_error_t *
-oam_init (vlib_main_t * vm)
-{
- oam_main_t *om = &oam_main;
-
- om->vlib_main = vm;
- om->vnet_main = vnet_get_main ();
- om->interval = 2.04;
- om->misses_allowed = 3;
- om->random_seed = (u32) (vlib_time_now (vm) * 1e6);
- om->target_by_address_and_fib_id = hash_create (0, sizeof (uword));
- om->icmp_id = random_u32 (&om->random_seed);
-
- ip4_icmp_register_type (vm, ICMP4_echo_reply, oam_node.index);
-
- return 0;
-}
-
-VLIB_INIT_FUNCTION (oam_init);
-
-static u8 *
-format_oam_target (u8 * s, va_list * args)
-{
- oam_target_t *t = va_arg (*args, oam_target_t *);
- int verbose = va_arg (*args, int);
-
- if (t == 0)
- return format (s, "%=6s%=14s%=14s%=12s%=10s",
- "Fib", "Src", "Dst", "Last Heard", "State");
-
- s = format (s, "%=6d%=14U%=14U%=12.2f%=10s",
- t->fib_id,
- format_ip4_address, &t->src_address,
- format_ip4_address, &t->dst_address,
- t->last_heard_time,
- (t->state == OAM_STATE_ALIVE) ? "alive" : "dead");
- if (verbose)
- s = format (s, " seq %d last_heard_seq %d", t->seq, t->last_heard_seq);
-
- return s;
-}
-
-static clib_error_t *
-show_oam_command_fn (vlib_main_t * vm,
- unformat_input_t * input, vlib_cli_command_t * cmd)
-{
- oam_main_t *om = &oam_main;
- oam_target_t *t;
- int verbose = 0;
-
- if (unformat (input, "verbose") || unformat (input, "v"))
- verbose = 1;
-
- /* print header */
- vlib_cli_output (vm, "%U", format_oam_target, 0, verbose);
-
- /* *INDENT-OFF* */
- pool_foreach (t, om->targets,
- ({
- vlib_cli_output (vm, "%U", format_oam_target, t, verbose);
- }));
- /* *INDENT-ON* */
-
- return 0;
-}
-
-/* *INDENT-OFF* */
-VLIB_CLI_COMMAND (show_oam_command, static) = {
- .path = "show oam",
- .short_help = "show oam",
- .function = show_oam_command_fn,
-};
-/* *INDENT-ON* */
-
-typedef struct
-{
- u32 target_pool_index;
- ip4_address_t address;
-} oam_trace_t;
-
-/* packet trace format function */
-static u8 *
-format_swap_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 *);
- oam_trace_t *t = va_arg (*args, oam_trace_t *);
-
- s = format (s, "OAM: rx from address %U, target index %d",
- format_ip4_address, &t->address, t->target_pool_index);
- return s;
-}
-
-
-#define foreach_oam_error \
-_(PROCESSED, "vpe icmp4 oam replies processed") \
-_(DROPPED, "icmp4 replies dropped (no registration)")
-
-typedef enum
-{
-#define _(sym,str) OAM_ERROR_##sym,
- foreach_oam_error
-#undef _
- OAM_N_ERROR,
-} oam_error_t;
-
-static char *oam_error_strings[] = {
-#define _(sym,string) string,
- foreach_oam_error
-#undef _
-};
-
-/*
- * To drop a pkt and increment one of the previous counters:
- *
- * set b0->error = error_node->errors[OAM_ERROR_EXAMPLE];
- * set next0 to a disposition index bound to "error-drop".
- *
- * To manually increment the specific counter OAM_ERROR_EXAMPLE:
- *
- * vlib_node_t *n = vlib_get_node (vm, oam.index);
- * u32 node_counter_base_index = n->error_heap_index;
- * vlib_error_main_t * em = &vm->error_main;
- * em->counters[node_counter_base_index + OAM_ERROR_EXAMPLE] += 1;
- *
- */
-
-typedef enum
-{
- OAM_NEXT_DROP,
- OAM_NEXT_PUNT,
- OAM_N_NEXT,
-} oam_next_t;
-
-static uword
-oam_node_fn (vlib_main_t * vm,
- vlib_node_runtime_t * node, vlib_frame_t * frame)
-{
- u32 n_left_from, *from, *to_next;
- oam_next_t next_index;
- oam_main_t *om = &oam_main;
- u32 next0 = OAM_NEXT_DROP; /* all pkts go to the hopper... */
- u32 next1 = OAM_NEXT_DROP;
- uword *u0, *u1;
- oam_template_t *oam0, *oam1;
- u32 fib_index0, fib_index1;
- u64 key0, key1;
- oam_target_t *t0, *t1;
- ip4_main_t *im = &ip4_main;
-
- from = vlib_frame_vector_args (frame);
- n_left_from = frame->n_vectors;
- next_index = node->cached_next_index;
-
- while (n_left_from > 0)
- {
- u32 n_left_to_next;
-
- vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
-
- while (n_left_from >= 4 && n_left_to_next >= 2)
- {
- u32 bi0, bi1;
- vlib_buffer_t *b0, *b1;
- u32 sw_if_index0, sw_if_index1;
-
- /* Prefetch next iteration. */
- {
- vlib_buffer_t *p2, *p3;
-
- p2 = vlib_get_buffer (vm, from[2]);
- p3 = vlib_get_buffer (vm, from[3]);
-
- vlib_prefetch_buffer_header (p2, LOAD);
- vlib_prefetch_buffer_header (p3, LOAD);
-
- CLIB_PREFETCH (p2->data, CLIB_CACHE_LINE_BYTES, STORE);
- CLIB_PREFETCH (p3->data, CLIB_CACHE_LINE_BYTES, STORE);
- }
-
- /* speculatively enqueue b0 and b1 to the current next frame */
- to_next[0] = bi0 = from[0];
- to_next[1] = bi1 = from[1];
- from += 2;
- to_next += 2;
- n_left_from -= 2;
- n_left_to_next -= 2;
-
- b0 = vlib_get_buffer (vm, bi0);
- b1 = vlib_get_buffer (vm, bi1);
-
- sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
- sw_if_index1 = vnet_buffer (b1)->sw_if_index[VLIB_RX];
-
- oam0 = vlib_buffer_get_current (b0);
- oam1 = vlib_buffer_get_current (b1);
- fib_index0 = vec_elt (im->fib_index_by_sw_if_index, sw_if_index0);
- fib_index1 = vec_elt (im->fib_index_by_sw_if_index, sw_if_index1);
-
- key0 = ((u64) fib_index0 << 32) | oam0->ip4.src_address.as_u32;
- u0 = hash_get (om->target_by_address_and_fib_id, key0);
- if (u0)
- {
- t0 = pool_elt_at_index (om->targets, u0[0]);
- t0->last_heard_time = vlib_time_now (vm);
- t0->last_heard_seq = clib_net_to_host_u16 (oam0->seq);
- b0->error = node->errors[OAM_ERROR_PROCESSED];
- }
- else
- b0->error = node->errors[OAM_ERROR_DROPPED];
-
- key1 = ((u64) fib_index1 << 32) | oam1->ip4.src_address.as_u32;
- u1 = hash_get (om->target_by_address_and_fib_id, key1);
- if (u1)
- {
- t1 = pool_elt_at_index (om->targets, u1[0]);
- t1->last_heard_time = vlib_time_now (vm);
- t1->last_heard_seq = clib_net_to_host_u16 (oam1->seq);
- b1->error = node->errors[OAM_ERROR_PROCESSED];
- }
- else
- b1->error = node->errors[OAM_ERROR_DROPPED];
-
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)))
- {
- if (b0->flags & VLIB_BUFFER_IS_TRACED)
- {
- oam_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
- t->target_pool_index = u0 ? u0[0] : (u32) ~ 0;
- t->address.as_u32 = oam0->ip4.src_address.as_u32;
- }
- if (b1->flags & VLIB_BUFFER_IS_TRACED)
- {
- oam_trace_t *t = vlib_add_trace (vm, node, b1, sizeof (*t));
- t->target_pool_index = u1 ? u1[0] : (u32) ~ 0;
- t->address.as_u32 = oam1->ip4.src_address.as_u32;
-
- }
- }
-
- if (vm->os_punt_frame)
- next0 = next1 = OAM_NEXT_PUNT;
-
- /* verify speculative enqueues, maybe switch current next frame */
- vlib_validate_buffer_enqueue_x2 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, bi1, next0, next1);
- }
-
- while (n_left_from > 0 && n_left_to_next > 0)
- {
- u32 bi0, sw_if_index0;
- vlib_buffer_t *b0;
-
- /* speculatively enqueue b0 to the current next frame */
- bi0 = from[0];
- to_next[0] = bi0;
- from += 1;
- to_next += 1;
- n_left_from -= 1;
- n_left_to_next -= 1;
-
- b0 = vlib_get_buffer (vm, bi0);
-
- sw_if_index0 = vnet_buffer (b0)->sw_if_index[VLIB_RX];
-
- oam0 = vlib_buffer_get_current (b0);
- fib_index0 = vec_elt (im->fib_index_by_sw_if_index, sw_if_index0);
-
- key0 = ((u64) fib_index0 << 32) | oam0->ip4.src_address.as_u32;
- u0 = hash_get (om->target_by_address_and_fib_id, key0);
- if (u0)
- {
- t0 = pool_elt_at_index (om->targets, u0[0]);
- t0->last_heard_time = vlib_time_now (vm);
- t0->last_heard_seq = clib_net_to_host_u16 (oam0->seq);
- b0->error = node->errors[OAM_ERROR_PROCESSED];
- }
- else
- b0->error = node->errors[OAM_ERROR_DROPPED];
-
- if (PREDICT_FALSE ((node->flags & VLIB_NODE_FLAG_TRACE)
- && (b0->flags & VLIB_BUFFER_IS_TRACED)))
- {
- oam_trace_t *t = vlib_add_trace (vm, node, b0, sizeof (*t));
- t->target_pool_index = u0 ? u0[0] : (u32) ~ 0;
- t->address.as_u32 = oam0->ip4.src_address.as_u32;
- }
-
- if (vm->os_punt_frame)
- next0 = OAM_NEXT_PUNT;
-
- /* verify speculative enqueue, maybe switch current next frame */
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
- }
-
- vlib_put_next_frame (vm, node, next_index, n_left_to_next);
- }
-
- return frame->n_vectors;
-}
-
-/* *INDENT-OFF* */
-VLIB_REGISTER_NODE (oam_node,static) = {
- .function = oam_node_fn,
- .name = "vpe-icmp4-oam",
- .vector_size = sizeof (u32),
- .format_trace = format_swap_trace,
- .type = VLIB_NODE_TYPE_INTERNAL,
-
- .n_errors = ARRAY_LEN(oam_error_strings),
- .error_strings = oam_error_strings,
-
- .n_next_nodes = OAM_N_NEXT,
-
- /* edit / add dispositions here */
- .next_nodes = {
- [OAM_NEXT_DROP] = "error-drop",
- [OAM_NEXT_PUNT] = "error-punt",
- },
-};
-/* *INDENT-ON* */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/src/vpp/oam/oam.h b/src/vpp/oam/oam.h
deleted file mode 100644
index f6af978893f..00000000000
--- a/src/vpp/oam/oam.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * 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.
- */
-#ifndef __included_oam_h__
-#define __included_oam_h__
-
-#include <vlib/vlib.h>
-#include <vnet/vnet.h>
-#include <vnet/ip/ip.h>
-#include <vnet/interface.h>
-
-/* 36 octets, make a note of it... */
-/* *INDENT-OFF* */
-typedef CLIB_PACKED (struct {
- ip4_header_t ip4;
- icmp46_header_t icmp;
- u16 id;
- u16 seq;
- u8 data[8];
-}) oam_template_t;
-/* *INDENT-ON* */
-
-/* *INDENT-OFF* */
-typedef CLIB_PACKED (struct {
- u64 v8[4];
- u32 v4;
-}) oam_template_copy_t;
-/* *INDENT-ON* */
-
-typedef enum
-{
- OAM_STATE_UNKNOWN = 0,
- OAM_STATE_ALIVE,
- OAM_STATE_DEAD,
-} oam_state_t;
-
-typedef struct
-{
- ip4_address_t src_address;
- ip4_address_t dst_address;
- u32 fib_id;
- u32 fib_index;
- f64 last_heard_time;
- u16 seq;
- u16 last_heard_seq;
- u16 id;
- u8 state;
- oam_template_t *template;
-} oam_target_t;
-
-typedef struct
-{
- /* OAM targets */
- oam_target_t *targets;
- uword *target_by_address_and_fib_id;
-
- /* Config parameters */
- f64 interval;
- u32 misses_allowed;
-
- /* random number seed */
- u32 random_seed;
- u16 icmp_id;
-
- /* oam packet template */
- vlib_packet_template_t packet_template;
-
- /* convenience */
- vlib_main_t *vlib_main;
- vnet_main_t *vnet_main;
-} oam_main_t;
-
-int vpe_oam_add_del_target (ip4_address_t * src_address,
- ip4_address_t * dst_address,
- u32 fib_id, int is_add);
-
-#endif /* __included_oam_h__ */
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */
diff --git a/src/vpp/oam/oam_api.c b/src/vpp/oam/oam_api.c
deleted file mode 100644
index 915d02d4cc6..00000000000
--- a/src/vpp/oam/oam_api.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- *------------------------------------------------------------------
- * oam_api.c - vnet OAM api
- *
- * Copyright (c) 2016 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.
- *------------------------------------------------------------------
- */
-
-#include <vnet/vnet.h>
-#include <vlibmemory/api.h>
-
-#include <vpp/oam/oam.h>
-
-#include <vpp/api/vpe_msg_enum.h>
-
-#define vl_typedefs /* define message structures */
-#include <vpp/api/vpe_all_api_h.h>
-#undef vl_typedefs
-#define vl_endianfun /* define message structures */
-#include <vpp/api/vpe_all_api_h.h>
-#undef vl_endianfun
-/* instantiate all the print functions we know about */
-#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
-#define vl_printfun
-#include <vpp/api/vpe_all_api_h.h>
-#undef vl_printfun
-#include <vlibapi/api_helper_macros.h>
-
-#define foreach_oam_api_msg \
-_(WANT_OAM_EVENTS, want_oam_events) \
-_(OAM_ADD_DEL, oam_add_del)
-
-pub_sub_handler (oam_events, OAM_EVENTS);
-
-void
-send_oam_event (oam_target_t * t)
-{
- vpe_api_main_t *vam = &vpe_api_main;
- vl_api_registration_t *vl_reg;
- vpe_client_registration_t *reg;
- vl_api_oam_event_t *mp;
-
- /* *INDENT-OFF* */
- pool_foreach(reg, vam->oam_events_registrations,
- ({
- vl_reg = vl_api_client_index_to_registration (reg->client_index);
- if (vl_reg)
- {
- mp = vl_msg_api_alloc (sizeof (*mp));
- mp->_vl_msg_id = ntohs (VL_API_OAM_EVENT);
- clib_memcpy (mp->dst_address, &t->dst_address,
- sizeof (mp->dst_address));
- mp->state = t->state;
- vl_api_send_msg (vl_reg, (u8 *)mp);
- }
- }));
- /* *INDENT-ON* */
-}
-
-static void
-vl_api_oam_add_del_t_handler (vl_api_oam_add_del_t * mp)
-{
- vl_api_oam_add_del_reply_t *rmp;
- int rv;
-
- rv = vpe_oam_add_del_target ((ip4_address_t *) mp->src_address,
- (ip4_address_t *) mp->dst_address,
- ntohl (mp->vrf_id), (int) (mp->is_add));
-
- REPLY_MACRO (VL_API_OAM_ADD_DEL_REPLY);
-}
-
-#define vl_msg_name_crc_list
-#include <vpp/oam/oam.api.h>
-#undef vl_msg_name_crc_list
-
-static void
-setup_message_id_table (api_main_t * am)
-{
-#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
- foreach_vl_msg_name_crc_oam;
-#undef _
-}
-
-static clib_error_t *
-oam_api_hookup (vlib_main_t * vm)
-{
- api_main_t *am = &api_main;
-
-#define _(N,n) \
- vl_msg_api_set_handlers(VL_API_##N, #n, \
- vl_api_##n##_t_handler, \
- vl_noop_handler, \
- vl_api_##n##_t_endian, \
- vl_api_##n##_t_print, \
- sizeof(vl_api_##n##_t), 1);
- foreach_oam_api_msg;
-#undef _
-
- /*
- * Set up the (msg_name, crc, message-id) table
- */
- setup_message_id_table (am);
-
- return 0;
-}
-
-VLIB_API_INIT_FUNCTION (oam_api_hookup);
-
-/*
- * fd.io coding-style-patch-verification: ON
- *
- * Local Variables:
- * eval: (c-set-style "gnu")
- * End:
- */