FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
ip6_ioam_analyse.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <vnet/ethernet/ethernet.h>
21 #include <vnet/ip/ip.h>
23 
25 static clib_error_t *
27  int is_add, int is_export, int remote_listen)
28 {
29  ipfix_client_add_del_t ipfix_reg;
30  clib_error_t *rv = 0;
31 
32  ipfix_reg.client_name = format (0, "ip6-hbh-analyse-remote");
33  ipfix_reg.client_node = analyse_node_remote.index;
35 
36  if (is_export)
37  {
38  rv = ioam_flow_create (!is_add);
39  if (rv)
40  goto ret;
41  }
42 
43  if (is_add)
44  {
46  if (remote_listen)
47  {
48  ipfix_reg.del = 0;
49  ipfix_collector_reg_setid (vm, &ipfix_reg);
50  }
51  else
52  {
54  (u8 *) "ip6-hbh-analyse-local");
55  }
56  }
57  else
58  {
60  if (remote_listen)
61  {
62  ipfix_reg.del = 1;
63  ipfix_collector_reg_setid (vm, &ipfix_reg);
64  }
65  else
67  }
68 
69 ret:
70  vec_free (ipfix_reg.client_name);
71  return rv;
72 }
73 
74 static clib_error_t *
76  vlib_cli_command_t * cmd)
77 {
78  int is_export = 0;
79  int is_add = 1;
80  int remote_listen = 0;
81 
83  {
84  if (unformat (input, "export-ipfix-collector"))
85  is_export = 1;
86  else if (unformat (input, "disable"))
87  is_add = 0;
88  else if (unformat (input, "listen-ipfix"))
89  remote_listen = 1;
90  else
91  break;
92  }
93 
94  return (ioam_analyse_enable_disable (vm, is_add, is_export, remote_listen));
95 }
96 
97 /* *INDENT-OFF* */
99  .path = "set ioam analyse",
100  .short_help = "set ioam analyse [export-ipfix-collector] [disable] [listen-ipfix]",
101  .function = set_ioam_analyse_command_fn,
102 };
103 /* *INDENT-ON* */
104 
105 static clib_error_t *
107  vlib_cli_command_t * cmd)
108 {
110  ioam_analyser_data_t *record = NULL;
111  u8 i;
112  u8 *s = 0;
113 
114  vec_reset_length (s);
115  s = format (0, "iOAM Analyse Information: \n");
116  vec_foreach_index (i, am->aggregated_data)
117  {
118  record = am->aggregated_data + i;
119  if (record->is_free)
120  continue;
121 
122  s = format (s, "Flow Number: %u\n", i);
123  s = print_analyse_flow (s, record);
124  s = format (s, "\n");
125  }
126  vlib_cli_output (vm, "%v", s);
127 
128  vec_free (s);
129 
130  return 0;
131 }
132 
133 /* *INDENT-OFF* */
135  .path = "show ioam analyse ",
136  .short_help = "show ioam analyser information",
137  .function = show_ioam_analyse_cmd_fn,
138 };
139 /* *INDENT-ON* */
140 
141 static clib_error_t *
143 {
145  u16 i;
146 
147  vec_validate_aligned (am->aggregated_data, 50, CLIB_CACHE_LINE_BYTES);
148  vec_foreach_index (i, am->aggregated_data)
149  {
150  ioam_analyse_init_data (am->aggregated_data + i);
151  }
152 
153  return 0;
154 }
155 
157 
158 /*
159  * fd.io coding-style-patch-verification: ON
160  *
161  * Local Variables:
162  * eval: (c-set-style "gnu")
163  * End:
164  */
vec_reset_length
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
Definition: vec_bootstrap.h:194
ioam_export.h
ioam_analyse_enable_disable
static clib_error_t * ioam_analyse_enable_disable(vlib_main_t *vm, int is_add, int is_export, int remote_listen)
Definition: ip6_ioam_analyse.c:26
print_analyse_flow
static u8 * print_analyse_flow(u8 *s, ioam_analyser_data_t *record)
Definition: ioam_analyse.h:449
ip6_show_ioam_ipfix_cmd
static vlib_cli_command_t ip6_show_ioam_ipfix_cmd
(constructor) VLIB_CLI_COMMAND (ip6_show_ioam_ipfix_cmd)
Definition: ip6_ioam_analyse.c:134
vlib_cli_command_t::path
char * path
Definition: cli.h:96
u16
unsigned short u16
Definition: types.h:57
IPFIX_IOAM_EXPORT_ID
#define IPFIX_IOAM_EXPORT_ID
Definition: ioam_export.h:204
am
app_main_t * am
Definition: application.c:489
ip6_ioam_analyse.h
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
ipfix_client_add_del_t
Structure other nodes to use for registering with IP-FIX collector.
Definition: ipfixcollector.h:30
unformat_input_t
struct _unformat_input_t unformat_input_t
ipfix_client_add_del_t::client_node
u32 client_node
Node index where packets have to be redirected.
Definition: ipfixcollector.h:37
ethernet.h
ipfixcollector.h
set_ioam_analyse_command_fn
static clib_error_t * set_ioam_analyse_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip6_ioam_analyse.c:75
ioam_analyse_init
static clib_error_t * ioam_analyse_init(vlib_main_t *vm)
Definition: ip6_ioam_analyse.c:142
ipfix_client_add_del_t::client_name
u8 * client_name
String containing name of the client interested in getting ip-fix packets.
Definition: ipfixcollector.h:34
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
ip6_ioam_analyser_main_t
IP6-iOAM analyser main structure.
Definition: ip6_ioam_analyse.h:26
set_ioam_analyse_command
static vlib_cli_command_t set_ioam_analyse_command
(constructor) VLIB_CLI_COMMAND (set_ioam_analyse_command)
Definition: ip6_ioam_analyse.c:98
ip6_ioam_analyse_unregister_handlers
void ip6_ioam_analyse_unregister_handlers(void)
Definition: node.c:460
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
vec_validate_aligned
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:534
vec_foreach_index
#define vec_foreach_index(var, v)
Iterate over vector indices.
Definition: vec_bootstrap.h:220
i
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:261
analyse_node_remote
vlib_node_registration_t analyse_node_remote
(constructor) VLIB_REGISTER_NODE (analyse_node_remote)
Definition: node.c:493
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
ip6_ioam_analyse_register_handlers
void ip6_ioam_analyse_register_handlers(void)
Definition: node.c:449
CLIB_CACHE_LINE_BYTES
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
format
description fragment has unexpected format
Definition: map.api:433
ioam_export_reset_next_node
static void ioam_export_reset_next_node(ioam_export_main_t *em)
Definition: ioam_export.h:101
ip.h
VLIB_INIT_FUNCTION
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:172
ioam_flow_create
clib_error_t * ioam_flow_create(u8 del)
Definition: ioam_summary_export.c:397
ipfix_client_add_del_t::del
u16 del
Add(0) or del(1) operation.
Definition: ipfixcollector.h:43
ioam_export_main_t
Definition: ioam_export.h:47
ioam_summary_export.h
ioam_analyser_data_t_::is_free
u8 is_free
Definition: ioam_analyse.h:102
ioam_analyser_data_t_
Analysed iOAM data.
Definition: ioam_analyse.h:98
vlib_main_t
Definition: main.h:102
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
vlib_init_function_t
clib_error_t *() vlib_init_function_t(struct vlib_main_t *vm)
Definition: init.h:51
ioam_export_set_next_node
static void ioam_export_set_next_node(ioam_export_main_t *em, u8 *next_node_name)
Definition: ioam_export.h:92
rv
int __clib_unused rv
Definition: application.c:491
show_ioam_analyse_cmd_fn
static clib_error_t * show_ioam_analyse_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: ip6_ioam_analyse.c:106
vlib_cli_command_t
Definition: cli.h:92
ioam_analyse.h
ipfix_client_add_del_t::ipfix_setid
u16 ipfix_setid
Setid of IPFix for which client is interested in getting packets.
Definition: ipfixcollector.h:40
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
ioam_export_main
ioam_export_main_t ioam_export_main
Definition: ioam_export.c:37
ipfix_collector_reg_setid
int ipfix_collector_reg_setid(vlib_main_t *vm, ipfix_client_add_del_t *info)
IP-FIX SetID registration function.
Definition: ipfixcollector.c:39
ioam_analyser_main
ip6_ioam_analyser_main_t ioam_analyser_main
Definition: node.c:64
ioam_analyse_init_data
static void ioam_analyse_init_data(ioam_analyser_data_t *data)
Definition: ioam_analyse.h:498