FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
cli.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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 <lb/lb.h>
17 #include <lb/util.h>
18 
19 static clib_error_t *
21  unformat_input_t * input, vlib_cli_command_t * cmd)
22 {
23  unformat_input_t _line_input, *line_input = &_line_input;
24  lb_vip_add_args_t args;
25  u8 del = 0;
26  int ret;
27  u32 port = 0;
28  u32 encap = 0;
29  u32 dscp = ~0;
30  u32 srv_type = LB_SRV_TYPE_CLUSTERIP;
31  u32 target_port = 0;
32  clib_error_t *error = 0;
33 
34  args.new_length = 1024;
35 
36  if (!unformat_user (input, unformat_line_input, line_input))
37  return 0;
38 
39  if (!unformat(line_input, "%U", unformat_ip46_prefix, &(args.prefix),
40  &(args.plen), IP46_TYPE_ANY, &(args.plen))) {
41  error = clib_error_return (0, "invalid vip prefix: '%U'",
42  format_unformat_error, line_input);
43  goto done;
44  }
45 
46  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
47  {
48  if (unformat(line_input, "new_len %d", &(args.new_length)))
49  ;
50  else if (unformat(line_input, "del"))
51  del = 1;
52  else if (unformat(line_input, "protocol tcp"))
53  {
54  args.protocol = (u8)IP_PROTOCOL_TCP;
55  }
56  else if (unformat(line_input, "protocol udp"))
57  {
58  args.protocol = (u8)IP_PROTOCOL_UDP;
59  }
60  else if (unformat(line_input, "port %d", &port))
61  ;
62  else if (unformat(line_input, "encap gre4"))
63  encap = LB_ENCAP_TYPE_GRE4;
64  else if (unformat(line_input, "encap gre6"))
65  encap = LB_ENCAP_TYPE_GRE6;
66  else if (unformat(line_input, "encap l3dsr"))
67  encap = LB_ENCAP_TYPE_L3DSR;
68  else if (unformat(line_input, "encap nat4"))
69  encap = LB_ENCAP_TYPE_NAT4;
70  else if (unformat(line_input, "encap nat6"))
71  encap = LB_ENCAP_TYPE_NAT6;
72  else if (unformat(line_input, "dscp %d", &dscp))
73  ;
74  else if (unformat(line_input, "type clusterip"))
75  srv_type = LB_SRV_TYPE_CLUSTERIP;
76  else if (unformat(line_input, "type nodeport"))
77  srv_type = LB_SRV_TYPE_NODEPORT;
78  else if (unformat(line_input, "target_port %d", &target_port))
79  ;
80  else {
81  error = clib_error_return (0, "parse error: '%U'",
82  format_unformat_error, line_input);
83  goto done;
84  }
85  }
86 
87  /* if port == 0, it means all-port VIP */
88  if (port == 0)
89  {
90  args.protocol = ~0;
91  args.port = 0;
92  }
93  else
94  {
95  args.port = (u16)port;
96  }
97 
98  if ((encap != LB_ENCAP_TYPE_L3DSR) && (dscp != ~0))
99  {
100  error = clib_error_return(0, "lb_vip_add error: "
101  "should not configure dscp for none L3DSR.");
102  goto done;
103  }
104 
105  if ((encap == LB_ENCAP_TYPE_L3DSR) && (dscp >= 64))
106  {
107  error = clib_error_return(0, "lb_vip_add error: "
108  "dscp for L3DSR should be less than 64.");
109  goto done;
110  }
111 
112  if (ip46_prefix_is_ip4(&(args.prefix), (args.plen)))
113  {
114  if (encap == LB_ENCAP_TYPE_GRE4)
115  args.type = LB_VIP_TYPE_IP4_GRE4;
116  else if (encap == LB_ENCAP_TYPE_GRE6)
117  args.type = LB_VIP_TYPE_IP4_GRE6;
118  else if (encap == LB_ENCAP_TYPE_L3DSR)
120  else if (encap == LB_ENCAP_TYPE_NAT4)
121  args.type = LB_VIP_TYPE_IP4_NAT4;
122  else if (encap == LB_ENCAP_TYPE_NAT6)
123  {
124  error = clib_error_return(0, "currently does not support NAT46");
125  goto done;
126  }
127  }
128  else
129  {
130  if (encap == LB_ENCAP_TYPE_GRE4)
131  args.type = LB_VIP_TYPE_IP6_GRE4;
132  else if (encap == LB_ENCAP_TYPE_GRE6)
133  args.type = LB_VIP_TYPE_IP6_GRE6;
134  else if (encap == LB_ENCAP_TYPE_NAT6)
135  args.type = LB_VIP_TYPE_IP6_NAT6;
136  else if (encap == LB_ENCAP_TYPE_NAT4)
137  {
138  error = clib_error_return(0, "currently does not support NAT64");
139  goto done;
140  }
141  }
142 
144 
145  u32 index;
146  if (!del) {
147  if (encap == LB_ENCAP_TYPE_L3DSR) {
148  args.encap_args.dscp = (u8)(dscp & 0x3F);
149  }
150  else if ((encap == LB_ENCAP_TYPE_NAT4)
151  || (encap == LB_ENCAP_TYPE_NAT6))
152  {
153  args.encap_args.srv_type = (u8) srv_type;
154  args.encap_args.target_port = (u16) target_port;
155  }
156 
157  if ((ret = lb_vip_add(args, &index))) {
158  error = clib_error_return (0, "lb_vip_add error %d", ret);
159  goto done;
160  } else {
161  vlib_cli_output(vm, "lb_vip_add ok %d", index);
162  }
163  } else {
164  if ((ret = lb_vip_find_index(&(args.prefix), args.plen,
165  args.protocol, args.port, &index))) {
166  error = clib_error_return (0, "lb_vip_find_index error %d", ret);
167  goto done;
168  } else if ((ret = lb_vip_del(index))) {
169  error = clib_error_return (0, "lb_vip_del error %d", ret);
170  goto done;
171  }
172  }
173 
174 done:
175  unformat_free (line_input);
176 
177  return error;
178 }
179 
181 {
182  .path = "lb vip",
183  .short_help = "lb vip <prefix> "
184  "[protocol (tcp|udp) port <n>] "
185  "[encap (gre6|gre4|l3dsr|nat4|nat6)] "
186  "[dscp <n>] "
187  "[type (nodeport|clusterip) target_port <n>] "
188  "[new_len <n>] [del]",
189  .function = lb_vip_command_fn,
190 };
191 
192 static clib_error_t *
194  unformat_input_t * input, vlib_cli_command_t * cmd)
195 {
196  unformat_input_t _line_input, *line_input = &_line_input;
197  ip46_address_t vip_prefix, as_addr;
198  u8 vip_plen;
199  ip46_address_t *as_array = 0;
200  u32 vip_index;
201  u32 port = 0;
202  u8 protocol = 0;
203  u8 del = 0;
204  u8 flush = 0;
205  int ret;
206  clib_error_t *error = 0;
207 
208  if (!unformat_user (input, unformat_line_input, line_input))
209  return 0;
210 
211  if (!unformat(line_input, "%U", unformat_ip46_prefix,
212  &vip_prefix, &vip_plen, IP46_TYPE_ANY))
213  {
214  error = clib_error_return (0, "invalid as address: '%U'",
215  format_unformat_error, line_input);
216  goto done;
217  }
218 
219  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
220  {
221  if (unformat(line_input, "%U", unformat_ip46_address,
222  &as_addr, IP46_TYPE_ANY))
223  {
224  vec_add1(as_array, as_addr);
225  }
226  else if (unformat(line_input, "del"))
227  {
228  del = 1;
229  }
230  else if (unformat(line_input, "flush"))
231  {
232  flush = 1;
233  }
234  else if (unformat(line_input, "protocol tcp"))
235  {
236  protocol = (u8)IP_PROTOCOL_TCP;
237  }
238  else if (unformat(line_input, "protocol udp"))
239  {
240  protocol = (u8)IP_PROTOCOL_UDP;
241  }
242  else if (unformat(line_input, "port %d", &port))
243  ;
244  else {
245  error = clib_error_return (0, "parse error: '%U'",
246  format_unformat_error, line_input);
247  goto done;
248  }
249  }
250 
251  /* If port == 0, it means all-port VIP */
252  if (port == 0)
253  {
254  protocol = ~0;
255  }
256 
257  if ((ret = lb_vip_find_index(&vip_prefix, vip_plen, protocol,
258  (u16)port, &vip_index))){
259  error = clib_error_return (0, "lb_vip_find_index error %d", ret);
260  goto done;
261  }
262 
263  if (!vec_len(as_array)) {
264  error = clib_error_return (0, "No AS address provided");
265  goto done;
266  }
267 
269  clib_warning("vip index is %d", vip_index);
270 
271  if (del) {
272  if ((ret = lb_vip_del_ass(vip_index, as_array, vec_len(as_array), flush)))
273  {
274  error = clib_error_return (0, "lb_vip_del_ass error %d", ret);
275  goto done;
276  }
277  } else {
278  if ((ret = lb_vip_add_ass(vip_index, as_array, vec_len(as_array))))
279  {
280  error = clib_error_return (0, "lb_vip_add_ass error %d", ret);
281  goto done;
282  }
283  }
284 
285 done:
286  unformat_free (line_input);
287  vec_free(as_array);
288 
289  return error;
290 }
291 
293 {
294  .path = "lb as",
295  .short_help = "lb as <vip-prefix> [protocol (tcp|udp) port <n>]"
296  " [<address> [<address> [...]]] [del] [flush]",
297  .function = lb_as_command_fn,
298 };
299 
300 static clib_error_t *
302  unformat_input_t * input, vlib_cli_command_t * cmd)
303 {
304  lb_main_t *lbm = &lb_main;
305  unformat_input_t _line_input, *line_input = &_line_input;
307  ip6_address_t ip6 = lbm->ip6_src_address;
308  u32 per_cpu_sticky_buckets = lbm->per_cpu_sticky_buckets;
309  u32 per_cpu_sticky_buckets_log2 = 0;
310  u32 flow_timeout = lbm->flow_timeout;
311  int ret;
312  clib_error_t *error = 0;
313 
314  if (!unformat_user (input, unformat_line_input, line_input))
315  return 0;
316 
317  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
318  {
319  if (unformat(line_input, "ip4-src-address %U", unformat_ip4_address, &ip4))
320  ;
321  else if (unformat(line_input, "ip6-src-address %U", unformat_ip6_address, &ip6))
322  ;
323  else if (unformat(line_input, "buckets %d", &per_cpu_sticky_buckets))
324  ;
325  else if (unformat(line_input, "buckets-log2 %d", &per_cpu_sticky_buckets_log2)) {
326  if (per_cpu_sticky_buckets_log2 >= 32)
327  return clib_error_return (0, "buckets-log2 value is too high");
328  per_cpu_sticky_buckets = 1 << per_cpu_sticky_buckets_log2;
329  } else if (unformat(line_input, "timeout %d", &flow_timeout))
330  ;
331  else {
332  error = clib_error_return (0, "parse error: '%U'",
333  format_unformat_error, line_input);
334  goto done;
335  }
336  }
337 
339 
340  if ((ret = lb_conf(&ip4, &ip6, per_cpu_sticky_buckets, flow_timeout))) {
341  error = clib_error_return (0, "lb_conf error %d", ret);
342  goto done;
343  }
344 
345 done:
346  unformat_free (line_input);
347 
348  return error;
349 }
350 
352 {
353  .path = "lb conf",
354  .short_help = "lb conf [ip4-src-address <addr>] [ip6-src-address <addr>] [buckets <n>] [timeout <s>]",
355  .function = lb_conf_command_fn,
356 };
357 
358 static clib_error_t *
360  unformat_input_t * input, vlib_cli_command_t * cmd)
361 {
363  return NULL;
364 }
365 
366 
368 {
369  .path = "show lb",
370  .short_help = "show lb",
371  .function = lb_show_command_fn,
372 };
373 
374 static clib_error_t *
376  unformat_input_t * input, vlib_cli_command_t * cmd)
377 {
378  unformat_input_t line_input;
379  lb_main_t *lbm = &lb_main;
380  lb_vip_t *vip;
381  u8 verbose = 0;
382 
383  if (!unformat_user (input, unformat_line_input, &line_input))
384  return 0;
385 
386  if (unformat(&line_input, "verbose"))
387  verbose = 1;
388 
389  /* Hide placeholder VIP */
390  pool_foreach (vip, lbm->vips) {
391  if (vip != lbm->vips) {
393  }
394  }
395 
396  unformat_free (&line_input);
397  return NULL;
398 }
399 
401 {
402  .path = "show lb vips",
403  .short_help = "show lb vips [verbose]",
404  .function = lb_show_vips_command_fn,
405 };
406 
407 static clib_error_t *
409  unformat_input_t * input,
410  vlib_cli_command_t * cmd,
411  u8 is_nat6)
412 {
413  unformat_input_t _line_input, *line_input = &_line_input;
414  vnet_main_t * vnm = vnet_get_main();
415  clib_error_t * error = 0;
416  u32 _sw_if_index, *sw_if_index = &_sw_if_index;
417  u32 * inside_sw_if_indices = 0;
418  int is_del = 0;
419 
420  /* Get a line of input. */
421  if (!unformat_user (input, unformat_line_input, line_input))
422  return 0;
423 
424  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
425  {
426  if (unformat (line_input, "in %U", unformat_vnet_sw_interface,
427  vnm, sw_if_index))
428  vec_add1 (inside_sw_if_indices, *sw_if_index);
429  else if (unformat (line_input, "del"))
430  is_del = 1;
431  else
432  {
433  error = clib_error_return (0, "unknown input '%U'",
434  format_unformat_error, line_input);
435  goto done;
436  }
437  }
438 
439  vec_foreach (sw_if_index, inside_sw_if_indices)
440  {
441  if (!is_nat6)
442  {
443  if (lb_nat4_interface_add_del (*sw_if_index, is_del))
444  {
446  0, "%s %U failed", is_del ? "del" : "add",
449  goto done;
450  }
451  }
452  else
453  {
454  if (lb_nat6_interface_add_del (*sw_if_index, is_del))
455  {
457  0, "%s %U failed", is_del ? "del" : "add",
460  goto done;
461  }
462  }
463  }
464 
465 done:
466  unformat_free (line_input);
467  vec_free (inside_sw_if_indices);
468 
469  return error;
470 }
471 
472 static clib_error_t *
474  unformat_input_t * input,
475  vlib_cli_command_t * cmd)
476 {
477  return lb_set_interface_nat_command_fn(vm, input, cmd, 0);
478 }
479 
481  .path = "lb set interface nat4",
483  .short_help = "lb set interface nat4 in <intfc> [del]",
484 };
485 
486 static clib_error_t *
488  unformat_input_t * input,
489  vlib_cli_command_t * cmd)
490 {
491  return lb_set_interface_nat_command_fn(vm, input, cmd, 1);
492 }
493 
495  .path = "lb set interface nat6",
497  .short_help = "lb set interface nat6 in <intfc> [del]",
498 };
499 
500 static clib_error_t *
502  unformat_input_t * input, vlib_cli_command_t * cmd)
503 {
504  lb_flush_vip_as(~0, 0);
505 
506  return NULL;
507 }
508 
509 static clib_error_t *
511  unformat_input_t * input,
512  vlib_cli_command_t * cmd)
513 {
514  unformat_input_t _line_input, *line_input = &_line_input;
515  int ret;
516  ip46_address_t vip_prefix;
517  u8 vip_plen;
518  u32 vip_index;
519  u8 protocol = 0;
520  u32 port = 0;
521  clib_error_t *error = 0;
522 
523  if (!unformat_user (input, unformat_line_input, line_input))
524  return 0;
525 
526  if (!unformat(line_input, "%U", unformat_ip46_prefix, &vip_prefix,
527  &vip_plen, IP46_TYPE_ANY, &vip_plen)) {
528  error = clib_error_return (0, "invalid vip prefix: '%U'",
529  format_unformat_error, line_input);
530  goto done;
531  }
532 
533  while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
534  {
535  if (unformat(line_input, "protocol tcp"))
536  {
537  protocol = (u8)IP_PROTOCOL_TCP;
538  }
539  else if (unformat(line_input, "protocol udp"))
540  {
541  protocol = (u8)IP_PROTOCOL_UDP;
542  }
543  else if (unformat(line_input, "port %d", &port))
544  ;
545  }
546 
547  if (port == 0)
548  {
549  protocol = ~0;
550  }
551 
552  if ((ret = lb_vip_find_index(&vip_prefix, vip_plen, protocol,
553  (u16)port, &vip_index))){
554  error = clib_error_return (0, "lb_vip_find_index error %d", ret);
555  goto done;
556  }
557 
558  if ((ret = lb_flush_vip_as(vip_index, ~0)))
559  {
560  error = clib_error_return (0, "lb_flush_vip error %d", ret);
561  }
562  else
563  {
564  vlib_cli_output(vm, "lb_flush_vip ok %d", vip_index);
565  }
566 
567 done:
568  unformat_free (line_input);
569 
570  return error;
571 }
572 
573 /*
574  * flush lb flowtable as per vip
575  */
577 {
578  .path = "lb flush vip",
579  .short_help = "lb flush vip <prefix> "
580  "[protocol (tcp|udp) port <n>]",
581  .function = lb_flush_vip_command_fn,
582 };
583 
584 /*
585  * flush all lb flowtables
586  * This is indented for debug and unit-tests purposes only
587  */
589 {
590  .path = "test lb flowtable flush",
591  .short_help = "test lb flowtable flush",
592  .function = lb_flowtable_flush_command_fn,
593 };
lb_main_t
Definition: lb.h:470
unformat_ip46_prefix
uword unformat_ip46_prefix(unformat_input_t *input, va_list *args)
Definition: util.c:32
unformat_user
uword unformat_user(unformat_input_t *input, unformat_function_t *func,...)
Definition: unformat.c:989
lb_main_t::per_cpu_sticky_buckets
u32 per_cpu_sticky_buckets
Number of buckets in the per-cpu sticky hash table.
Definition: lb.h:522
lb_set_interface_nat4_command_fn
static clib_error_t * lb_set_interface_nat4_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:473
ip4
vl_api_ip4_address_t ip4
Definition: one.api:376
lb_main
lb_main_t lb_main
Definition: lb.c:32
unformat_line_input
unformat_function_t unformat_line_input
Definition: format.h:275
lb_main_t::vips
lb_vip_t * vips
Pool of all Virtual IPs.
Definition: lb.h:474
LB_VIP_TYPE_IP6_GRE4
@ LB_VIP_TYPE_IP6_GRE4
Definition: lb.h:210
clib_error_return
#define clib_error_return(e, args...)
Definition: error.h:99
u8
#define u8
Padding.
Definition: clib.h:121
vlib_cli_command_t::path
char * path
Definition: cli.h:96
u16
unsigned short u16
Definition: types.h:57
lb_nat6_interface_add_del
int lb_nat6_interface_add_del(u32 sw_if_index, int is_del)
Definition: lb.c:1346
lb_vip_del_ass
int lb_vip_del_ass(u32 vip_index, ip46_address_t *addresses, u32 n, u8 flush)
Definition: lb.c:853
lb_main_t::ip4_src_address
ip4_address_t ip4_src_address
Source address used for IPv4 encapsulated traffic.
Definition: lb.h:517
lb_show_command
static vlib_cli_command_t lb_show_command
(constructor) VLIB_CLI_COMMAND (lb_show_command)
Definition: cli.c:367
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
vnet_get_sw_interface
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
Definition: interface_funcs.h:58
port
u16 port
Definition: lb_types.api:73
lb_nat4_interface_add_del
int lb_nat4_interface_add_del(u32 sw_if_index, int is_del)
Definition: lb.c:1330
lb_vip_add_args_t::plen
u8 plen
Definition: lb.h:575
unformat_input_t
struct _unformat_input_t unformat_input_t
lb_vip_del
int lb_vip_del(u32 vip_index)
Definition: lb.c:1202
error
Definition: cJSON.c:88
LB_ENCAP_TYPE_NAT4
@ LB_ENCAP_TYPE_NAT4
Definition: lb.h:188
lb_vip_add_args_t::port
u16 port
Definition: lb.h:577
LB_VIP_TYPE_IP4_L3DSR
@ LB_VIP_TYPE_IP4_L3DSR
Definition: lb.h:213
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
lb_vip_add_ass
int lb_vip_add_ass(u32 vip_index, ip46_address_t *addresses, u32 n)
Definition: lb.c:585
lb_flowtable_flush_command
static vlib_cli_command_t lb_flowtable_flush_command
(constructor) VLIB_CLI_COMMAND (lb_flowtable_flush_command)
Definition: cli.c:588
pool_foreach
#define pool_foreach(VAR, POOL)
Iterate through pool.
Definition: pool.h:534
lb_show_command_fn
static clib_error_t * lb_show_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:359
vec_len
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
Definition: vec_bootstrap.h:142
unformat_free
static void unformat_free(unformat_input_t *i)
Definition: format.h:155
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
LB_ENCAP_TYPE_L3DSR
@ LB_ENCAP_TYPE_L3DSR
Definition: lb.h:187
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
lb_vip_add_args_t::new_length
u32 new_length
Definition: lb.h:579
LB_ENCAP_TYPE_GRE4
@ LB_ENCAP_TYPE_GRE4
Definition: lb.h:185
unformat_ip46_address
unformat_function_t unformat_ip46_address
Definition: format.h:63
format_unformat_error
u8 * format_unformat_error(u8 *s, va_list *va)
Definition: unformat.c:91
VLIB_CLI_COMMAND
#define VLIB_CLI_COMMAND(x,...)
Definition: cli.h:163
lb_main_t::ip6_src_address
ip6_address_t ip6_src_address
Source address used in IPv6 encapsulated traffic.
Definition: lb.h:512
LB_VIP_TYPE_IP4_GRE4
@ LB_VIP_TYPE_IP4_GRE4
Definition: lb.h:212
lb_show_vips_command_fn
static clib_error_t * lb_show_vips_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:375
lb_vip_add_args_t::prefix
ip46_address_t prefix
Definition: lb.h:574
ip4_address_t
Definition: ip4_packet.h:50
LB_VIP_TYPE_IP4_NAT4
@ LB_VIP_TYPE_IP4_NAT4
Definition: lb.h:214
lb_vip_encap_args_t::target_port
u16 target_port
Definition: lb.h:233
lb_show_vips_command
static vlib_cli_command_t lb_show_vips_command
(constructor) VLIB_CLI_COMMAND (lb_show_vips_command)
Definition: cli.c:400
lb_vip_t
Load balancing service is provided per VIP+protocol+port.
Definition: lb.h:262
lb_conf_command
static vlib_cli_command_t lb_conf_command
(constructor) VLIB_CLI_COMMAND (lb_conf_command)
Definition: cli.c:351
LB_SRV_TYPE_NODEPORT
@ LB_SRV_TYPE_NODEPORT
Definition: lb.h:88
vlib_cli_output
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
Definition: cli.c:716
lb_vip_command
static vlib_cli_command_t lb_vip_command
(constructor) VLIB_CLI_COMMAND (lb_vip_command)
Definition: cli.c:180
lb_vip_add_args_t::encap_args
lb_vip_encap_args_t encap_args
Definition: lb.h:580
LB_VIP_TYPE_IP6_NAT6
@ LB_VIP_TYPE_IP6_NAT6
Definition: lb.h:215
lb_vip_add
int lb_vip_add(lb_vip_add_args_t args, u32 *vip_index)
Definition: lb.c:1048
lb_vip_add_args_t::protocol
u8 protocol
Definition: lb.h:576
LB_VIP_TYPE_IP4_GRE6
@ LB_VIP_TYPE_IP4_GRE6
Definition: lb.h:211
lb_set_interface_nat6_command
static vlib_cli_command_t lb_set_interface_nat6_command
(constructor) VLIB_CLI_COMMAND (lb_set_interface_nat6_command)
Definition: cli.c:494
lb.h
lb_flush_vip_command
static vlib_cli_command_t lb_flush_vip_command
(constructor) VLIB_CLI_COMMAND (lb_flush_vip_command)
Definition: cli.c:576
vnet_main_t
Definition: vnet.h:76
vec_free
#define vec_free(V)
Free vector's memory (no header).
Definition: vec.h:395
index
u32 index
Definition: flow_types.api:221
lb_as_command_fn
static clib_error_t * lb_as_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:193
format_lb_vip
format_function_t format_lb_vip
Definition: lb.h:388
lb_vip_encap_args_t::srv_type
u8 srv_type
Definition: lb.h:230
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:459
lb_flowtable_flush_command_fn
static clib_error_t * lb_flowtable_flush_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:501
LB_SRV_TYPE_CLUSTERIP
@ LB_SRV_TYPE_CLUSTERIP
Definition: lb.h:87
u32
unsigned int u32
Definition: types.h:88
lb_set_interface_nat_command_fn
static clib_error_t * lb_set_interface_nat_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd, u8 is_nat6)
Definition: cli.c:408
ip6
vl_api_ip6_address_t ip6
Definition: one.api:424
protocol
vl_api_ip_proto_t protocol
Definition: lb_types.api:72
lb_vip_command_fn
static clib_error_t * lb_vip_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:20
vec_foreach
#define vec_foreach(var, vec)
Vector iterator.
Definition: vec_bootstrap.h:213
lb_vip_find_index
int lb_vip_find_index(ip46_address_t *prefix, u8 plen, u8 protocol, u16 port, u32 *vip_index)
Definition: lb.c:554
format_lb_main
format_function_t format_lb_main
Definition: lb.h:622
LB_VIP_TYPE_IP6_GRE6
@ LB_VIP_TYPE_IP6_GRE6
Definition: lb.h:209
lb_vip_add_args_t::type
lb_vip_type_t type
Definition: lb.h:578
vlib_main_t
Definition: main.h:102
lb_as_command
static vlib_cli_command_t lb_as_command
(constructor) VLIB_CLI_COMMAND (lb_as_command)
Definition: cli.c:292
lb_set_interface_nat6_command_fn
static clib_error_t * lb_set_interface_nat6_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:487
u8
unsigned char u8
Definition: types.h:56
clib_error_t
Definition: clib_error.h:21
lb_flush_vip_as
int lb_flush_vip_as(u32 vip_index, u32 as_index)
Definition: lb.c:762
clib_warning
#define clib_warning(format, args...)
Definition: error.h:59
unformat_ip6_address
unformat_function_t unformat_ip6_address
Definition: format.h:89
IP46_TYPE_ANY
@ IP46_TYPE_ANY
Definition: ip46_address.h:24
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
lb_main_t::flow_timeout
u32 flow_timeout
Flow timeout in seconds.
Definition: lb.h:527
LB_ENCAP_TYPE_NAT6
@ LB_ENCAP_TYPE_NAT6
Definition: lb.h:189
lb_flush_vip_command_fn
static clib_error_t * lb_flush_vip_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:510
vlib_cli_command_t
Definition: cli.h:92
lb_vip_add_args_t
Definition: lb.h:573
sw_if_index
vl_api_interface_index_t sw_if_index
Definition: wireguard.api:34
util.h
format_lb_vip_detailed
format_function_t format_lb_vip_detailed
Definition: lb.h:389
ip46_prefix_is_ip4
#define ip46_prefix_is_ip4(ip46, len)
Definition: util.h:27
lb_vip_encap_args_t::dscp
u8 dscp
Definition: lb.h:236
LB_ENCAP_TYPE_GRE6
@ LB_ENCAP_TYPE_GRE6
Definition: lb.h:186
lb_conf
int lb_conf(ip4_address_t *ip4_address, ip6_address_t *ip6_address, u32 per_cpu_sticky_buckets, u32 flow_timeout)
Fix global load-balancer parameters.
Definition: lb.c:476
lb_conf_command_fn
static clib_error_t * lb_conf_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
Definition: cli.c:301
lb_garbage_collection
void lb_garbage_collection()
Definition: lb.c:357
dscp
vl_api_ip_dscp_t dscp
Definition: dhcp.api:163
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
lb_set_interface_nat4_command
static vlib_cli_command_t lb_set_interface_nat4_command
(constructor) VLIB_CLI_COMMAND (lb_set_interface_nat4_command)
Definition: cli.c:480
format_vnet_sw_interface_name
format_function_t format_vnet_sw_interface_name
Definition: interface_funcs.h:453