FD.io VPP  v19.04.2-12-g66b1689
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 
20 #include <vnet/ip/ip.h>
22 
24 static clib_error_t *
26  int is_add, int is_export, int remote_listen)
27 {
28  ipfix_client_add_del_t ipfix_reg;
29  clib_error_t *rv = 0;
30 
31  ipfix_reg.client_name = format (0, "ip6-hbh-analyse-remote");
32  ipfix_reg.client_node = analyse_node_remote.index;
34 
35  if (is_export)
36  {
37  rv = ioam_flow_create (!is_add);
38  if (rv)
39  goto ret;
40  }
41 
42  if (is_add)
43  {
45  if (remote_listen)
46  {
47  ipfix_reg.del = 0;
48  ipfix_collector_reg_setid (vm, &ipfix_reg);
49  }
50  else
51  {
52  ioam_export_set_next_node (&ioam_export_main,
53  (u8 *) "ip6-hbh-analyse-local");
54  }
55  }
56  else
57  {
59  if (remote_listen)
60  {
61  ipfix_reg.del = 1;
62  ipfix_collector_reg_setid (vm, &ipfix_reg);
63  }
64  else
65  ioam_export_reset_next_node (&ioam_export_main);
66  }
67 
68 ret:
69  vec_free (ipfix_reg.client_name);
70  return rv;
71 }
72 
73 static clib_error_t *
75  vlib_cli_command_t * cmd)
76 {
77  int is_export = 0;
78  int is_add = 1;
79  int remote_listen = 0;
80 
82  {
83  if (unformat (input, "export-ipfix-collector"))
84  is_export = 1;
85  else if (unformat (input, "disable"))
86  is_add = 0;
87  else if (unformat (input, "listen-ipfix"))
88  remote_listen = 1;
89  else
90  break;
91  }
92 
93  return (ioam_analyse_enable_disable (vm, is_add, is_export, remote_listen));
94 }
95 
96 /* *INDENT-OFF* */
97 VLIB_CLI_COMMAND (set_ioam_analyse_command, static) = {
98  .path = "set ioam analyse",
99  .short_help = "set ioam analyse [export-ipfix-collector] [disable] [listen-ipfix]",
100  .function = set_ioam_analyse_command_fn,
101 };
102 /* *INDENT-ON* */
103 
104 static clib_error_t *
106  vlib_cli_command_t * cmd)
107 {
109  ioam_analyser_data_t *record = NULL;
110  u8 i;
111  u8 *s = 0;
112 
113  vec_reset_length (s);
114  s = format (0, "iOAM Analyse Information: \n");
116  {
117  record = am->aggregated_data + i;
118  if (record->is_free)
119  continue;
120 
121  s = format (s, "Flow Number: %u\n", i);
122  s = print_analyse_flow (s, record);
123  s = format (s, "\n");
124  }
125  vlib_cli_output (vm, "%v", s);
126 
127  vec_free (s);
128 
129  return 0;
130 }
131 
132 /* *INDENT-OFF* */
133 VLIB_CLI_COMMAND (ip6_show_ioam_ipfix_cmd, static) = {
134  .path = "show ioam analyse ",
135  .short_help = "show ioam analyser information",
136  .function = show_ioam_analyse_cmd_fn,
137 };
138 /* *INDENT-ON* */
139 
140 static clib_error_t *
142 {
144  u16 i;
145 
148  {
150  }
151 
152  return 0;
153 }
154 
156 
157 /*
158  * fd.io coding-style-patch-verification: ON
159  *
160  * Local Variables:
161  * eval: (c-set-style "gnu")
162  * End:
163  */
u16 del
Add(0) or del(1) operation.
#define vec_foreach_index(var, v)
Iterate over vector indices.
u16 ipfix_setid
Setid of IPFix for which client is intereseted in getting packets.
static u8 * print_analyse_flow(u8 *s, ioam_analyser_data_t *record)
Definition: ioam_analyse.h:452
static void ioam_export_reset_next_node(ioam_export_main_t *em)
Definition: ioam_export.h:99
static void ioam_analyse_init_data(ioam_analyser_data_t *data)
Definition: ioam_analyse.h:501
#define NULL
Definition: clib.h:58
int i
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:424
clib_error_t * ioam_flow_create(u8 del)
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
Definition: vec.h:450
unsigned char u8
Definition: types.h:56
ip6_ioam_analyser_main_t ioam_analyser_main
Definition: node.c:63
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
IP6-iOAM analyser main structure.
#define VLIB_INIT_FUNCTION(x)
Definition: init.h:163
u8 * client_name
String containing name of the client interested in getting ip-fix packets.
static clib_error_t * ioam_analyse_init(vlib_main_t *vm)
#define IPFIX_IOAM_EXPORT_ID
Definition: ioam_export.h:204
struct _unformat_input_t unformat_input_t
unsigned short u16
Definition: types.h:57
static clib_error_t * set_ioam_analyse_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define UNFORMAT_END_OF_INPUT
Definition: format.h:144
vlib_main_t * vm
Definition: buffer.c:312
static void ioam_export_set_next_node(ioam_export_main_t *em, u8 *next_node_name)
Definition: ioam_export.h:90
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:341
ioam_export_main_t ioam_export_main
Definition: ioam_export.c:61
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:155
ioam_analyser_data_t * aggregated_data
This contains the aggregated data from the time VPP started analysing.
u8 is_add
Definition: ipsec_gre.api:36
void ip6_ioam_analyse_register_handlers(void)
Definition: node.c:454
Analysed iOAM data.
Definition: ioam_analyse.h:97
static clib_error_t * show_ioam_analyse_cmd_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int ipfix_collector_reg_setid(vlib_main_t *vm, ipfix_client_add_del_t *info)
IP-FIX SetID registration function.
static clib_error_t * ioam_analyse_enable_disable(vlib_main_t *vm, int is_add, int is_export, int remote_listen)
Structure other nodes to use for registering with IP-FIX collector.
#define CLIB_CACHE_LINE_BYTES
Definition: cache.h:59
void ip6_ioam_analyse_unregister_handlers(void)
Definition: node.c:465
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:762
vlib_node_registration_t analyse_node_remote
(constructor) VLIB_REGISTER_NODE (analyse_node_remote)
Definition: node.c:498
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:972
u32 client_node
Node index where packets have to be redirected.
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:170