FD.io VPP  v21.10.1-2-g0a485f517
Vector Packet Processing
lb.h
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 /**
17  * lb-plugin implements a MagLev-like load balancer.
18  * http://research.google.com/pubs/pub44824.html
19  *
20  * It hasn't been tested for interoperability with the original MagLev
21  * but intends to provide similar functionality.
22  * The load-balancer receives traffic destined to VIP (Virtual IP)
23  * addresses from one or multiple(ECMP) routers.
24  * The load-balancer tunnels the traffic toward many application servers
25  * ensuring session stickyness (i.e. that a single sessions is tunneled
26  * towards a single application server).
27  *
28  */
29 
30 #ifndef LB_PLUGIN_LB_LB_H_
31 #define LB_PLUGIN_LB_LB_H_
32 
33 #include <lb/util.h>
34 #include <vnet/util/refcount.h>
35 
36 #include <vnet/vnet.h>
37 #include <vnet/ip/ip.h>
38 #include <vnet/dpo/dpo.h>
39 #include <vnet/fib/fib_table.h>
40 #include <vppinfra/hash.h>
41 #include <vppinfra/bihash_8_8.h>
42 #include <vppinfra/bihash_24_8.h>
43 #include <lb/lbhash.h>
44 #include <vppinfra/lock.h>
45 
46 #define LB_DEFAULT_PER_CPU_STICKY_BUCKETS 1 << 10
47 #define LB_DEFAULT_FLOW_TIMEOUT 40
48 #define LB_MAPPING_BUCKETS 1024
49 #define LB_MAPPING_MEMORY_SIZE 64<<20
50 
51 #define LB_VIP_PER_PORT_BUCKETS 1024
52 #define LB_VIP_PER_PORT_MEMORY_SIZE 64<<20
53 
54 typedef enum {
57 } lb_next_t;
58 
59 typedef enum {
64 
65 typedef enum {
70 
71 #define foreach_lb_nat_in2out_error \
72 _(UNSUPPORTED_PROTOCOL, "Unsupported protocol") \
73 _(IN2OUT_PACKETS, "Good in2out packets processed") \
74 _(NO_TRANSLATION, "No translation")
75 
76 typedef enum {
77 #define _(sym,str) LB_NAT_IN2OUT_ERROR_##sym,
79 #undef _
82 
83 /**
84  * lb for kube-proxy supports three types of service
85  */
86 typedef enum {
91 
92 typedef enum {
97 
98 typedef enum {
103 
104 /**
105  * Each VIP is configured with a set of
106  * application server.
107  */
108 typedef struct {
109  /**
110  * Registration to FIB event.
111  */
113 
114  /**
115  * Destination address used to tunnel traffic towards
116  * that application server.
117  * The address is also used as ID and pseudo-random
118  * seed for the load-balancing process.
119  */
120  ip46_address_t address;
121 
122  /**
123  * ASs are indexed by address and VIP Index.
124  * Which means there will be duplicated if the same server
125  * address is used for multiple VIPs.
126  */
128 
129  /**
130  * Some per-AS flags.
131  * For now only LB_AS_FLAGS_USED is defined.
132  */
134 
135 #define LB_AS_FLAGS_USED 0x1
136 
137  /**
138  * Rotating timestamp of when LB_AS_FLAGS_USED flag was last set.
139  *
140  * AS removal is based on garbage collection and reference counting.
141  * When an AS is removed, there is a race between configuration core
142  * and worker cores which may still add a reference while it should not
143  * be used. This timestamp is used to not remove the AS while a race condition
144  * may happen.
145  */
147 
148  /**
149  * The FIB entry index for the next-hop
150  */
152 
153  /**
154  * The child index on the FIB entry
155  */
157 
158  /**
159  * The next DPO in the graph to follow.
160  */
162 
163 } lb_as_t;
164 
166 
167 typedef struct {
170 
171 #define lb_foreach_vip_counter \
172  _(NEXT_PACKET, "packet from existing sessions", 0) \
173  _(FIRST_PACKET, "first session packet", 1) \
174  _(UNTRACKED_PACKET, "untracked packet", 2) \
175  _(NO_SERVER, "no server configured", 3)
176 
177 typedef enum {
178 #define _(a,b,c) LB_VIP_COUNTER_##a = c,
180 #undef _
183 
184 typedef enum {
192 
193 /**
194  * Lookup type
195  */
196 
197 typedef enum {
202 } lb_lkp_type_t;
203 
204 /**
205  * The load balancer supports IPv4 and IPv6 traffic
206  * and GRE4, GRE6, L3DSR and NAT4, NAT6 encap.
207  */
208 typedef enum {
217 } lb_vip_type_t;
218 
221 
222 
223 /* args for different vip encap types */
224 typedef struct {
225  union
226  {
227  struct
228  {
229  /* Service type. clusterip or nodeport */
231 
232  /* Pod's port corresponding to specific service. network byte order */
234  };
235  /* DSCP bits for L3DSR */
238  };
240 
241 typedef struct {
242  /* all fields in NET byte order */
243  union {
244  struct {
249  };
251  };
253 
254 /**
255  * Load balancing service is provided per VIP+protocol+port.
256  * In this data model, a VIP can be a whole prefix.
257  * But load balancing only
258  * occurs on a per-source-address/port basis. Meaning that if a given source
259  * reuses the same port for multiple destinations within the same VIP,
260  * they will be considered as a single flow.
261  */
262 typedef struct {
263 
264  //Runtime
265 
266  /**
267  * Vector mapping (flow-hash & new_connect_table_mask) to AS index.
268  * This is used for new flows.
269  */
271 
272  /**
273  * New flows table length - 1
274  * (length MUST be a power of 2)
275  */
277 
278  /**
279  * Last time garbage collection was run to free the ASs.
280  */
282 
283  //Not runtime
284 
285  /**
286  * A Virtual IP represents a given service delivered
287  * by a set of application servers. It can be a single
288  * address or a prefix.
289  * IPv4 prefixes are encoded using IPv4-in-IPv6 embedded address
290  * (i.e. ::/96 prefix).
291  */
292  ip46_address_t prefix;
293 
294  /**
295  * The VIP prefix length.
296  * In case of IPv4, plen = 96 + ip4_plen.
297  */
299 
300  /* tcp or udp. If not per-port vip, set to ~0 */
302 
303  /* tcp port or udp port. If not per-port vip, set to ~0 */
305 
306  /* Valid for per-port vip */
308 
309  /**
310  * The type of traffic for this.
311  * LB_TYPE_UNDEFINED if unknown.
312  */
314 
315  /* args for different vip encap types */
317 
318  /**
319  * Flags related to this VIP.
320  * LB_VIP_FLAGS_USED means the VIP is active.
321  * When it is not set, the VIP in the process of being removed.
322  * We cannot immediately remove a VIP because the VIP index still may be stored
323  * in the adjacency index.
324  */
326 #define LB_VIP_FLAGS_USED 0x1
327 
328  /**
329  * Pool of AS indexes used for this VIP.
330  * This also includes ASs that have been removed (but are still referenced).
331  */
333 } lb_vip_t;
334 
335 #define lb_vip_is_ip4(type) (type == LB_VIP_TYPE_IP4_GRE6 \
336  || type == LB_VIP_TYPE_IP4_GRE4 \
337  || type == LB_VIP_TYPE_IP4_L3DSR \
338  || type == LB_VIP_TYPE_IP4_NAT4 )
339 
340 #define lb_vip_is_ip6(type) (type == LB_VIP_TYPE_IP6_GRE6 \
341  || type == LB_VIP_TYPE_IP6_GRE4 \
342  || type == LB_VIP_TYPE_IP6_NAT6 )
343 
344 #define lb_encap_is_ip4(vip) ((vip)->type == LB_VIP_TYPE_IP6_GRE4 \
345  || (vip)->type == LB_VIP_TYPE_IP4_GRE4 \
346  || (vip)->type == LB_VIP_TYPE_IP4_L3DSR \
347  || (vip)->type == LB_VIP_TYPE_IP4_NAT4 )
348 
349 #define lb_vip_is_gre4(vip) (((vip)->type == LB_VIP_TYPE_IP6_GRE4 \
350  || (vip)->type == LB_VIP_TYPE_IP4_GRE4) \
351  && ((vip)->port == 0))
352 
353 
354 #define lb_vip_is_gre6(vip) (((vip)->type == LB_VIP_TYPE_IP6_GRE6 \
355  || (vip)->type == LB_VIP_TYPE_IP4_GRE6) \
356  && ((vip)->port == 0))
357 
358 #define lb_vip_is_gre4_port(vip) (((vip)->type == LB_VIP_TYPE_IP6_GRE4 \
359  || (vip)->type == LB_VIP_TYPE_IP4_GRE4) \
360  && ((vip)->port != 0))
361 
362 #define lb_vip_is_gre6_port(vip) (((vip)->type == LB_VIP_TYPE_IP6_GRE6 \
363  || (vip)->type == LB_VIP_TYPE_IP4_GRE6) \
364  && ((vip)->port != 0))
365 
366 always_inline bool
368 {
369  return (vip->type == LB_VIP_TYPE_IP4_L3DSR && vip->port ==0);
370 }
371 
372 always_inline bool
374 {
375  return (vip->type == LB_VIP_TYPE_IP4_L3DSR && vip->port !=0);
376 }
377 always_inline bool
379 {
380  return (vip->type == LB_VIP_TYPE_IP4_NAT4 && vip->port !=0);
381 }
382 always_inline bool
384 {
385  return (vip->type == LB_VIP_TYPE_IP6_NAT6 && vip->port !=0);
386 }
387 
390 
391 #define foreach_lb_nat_protocol \
392  _(UDP, 0, udp, "udp") \
393  _(TCP, 1, tcp, "tcp")
394 
395 typedef enum {
396 #define _(N, i, n, s) LB_NAT_PROTOCOL_##N = i,
398 #undef _
400 
403 {
404  u32 nat_proto = ~0;
405 
406  nat_proto = (ip_proto == IP_PROTOCOL_UDP) ? LB_NAT_PROTOCOL_UDP : nat_proto;
407  nat_proto = (ip_proto == IP_PROTOCOL_TCP) ? LB_NAT_PROTOCOL_TCP : nat_proto;
408 
409  return nat_proto;
410 }
411 
412 /* Key for Pod's egress SNAT */
413 typedef struct {
414  union
415  {
416  struct
417  {
422  };
424  };
426 
427 typedef struct
428 {
429  union
430  {
431  struct
432  {
433  ip6_address_t addr;
437  };
439  };
441 
442 typedef struct {
443  /**
444  * for vip + port case, src_ip = vip;
445  * for node ip + node_port, src_ip = node_ip
446  */
447  ip46_address_t src_ip;
448  ip46_address_t as_ip;
451  /**
452  * Network byte order
453  * for vip + port case, src_port = port;
454  * for node ip + node_port, src_port = node_port
455  */
457  u16 target_port; /* Network byte order */
461 
462 typedef struct {
463  /**
464  * Each CPU has its own sticky flow hash table.
465  * One single table is used for all VIPs.
466  */
468 } lb_per_cpu_t;
469 
470 typedef struct {
471  /**
472  * Pool of all Virtual IPs
473  */
475 
476  /**
477  * bitmap for vip prefix to support per-port vip
478  */
480 
481  /**
482  * Pool of ASs.
483  * ASs are referenced by address and vip index.
484  * The first element (index 0) is special and used only to fill
485  * new_flow_tables when no AS has been configured.
486  */
488 
489  /**
490  * Each AS has an associated reference counter.
491  * As ass[0] has a special meaning, its associated counter
492  * starts at 0 and is decremented instead. i.e. do not use it.
493  */
495 
496  /* hash lookup vip_index by key: {u16: nodeport} */
498 
499  /**
500  * Some global data is per-cpu
501  */
503 
504  /**
505  * Node next index for IP adjacencies, for each of the traffic types.
506  */
507  u32 ip_lookup_next_index[LB_VIP_N_TYPES];
508 
509  /**
510  * Source address used in IPv6 encapsulated traffic
511  */
512  ip6_address_t ip6_src_address;
513 
514  /**
515  * Source address used for IPv4 encapsulated traffic
516  */
518 
519  /**
520  * Number of buckets in the per-cpu sticky hash table.
521  */
523 
524  /**
525  * Flow timeout in seconds.
526  */
528 
529  /**
530  * Per VIP counter
531  */
533 
534  /**
535  * DPO used to send packet from IP4/6 lookup to LB node.
536  */
545  /**
546  * Node type for registering to fib changes.
547  */
549 
550  /* lookup per_port vip by key */
551  clib_bihash_8_8_t vip_index_per_port;
552 
553  /* Find a static mapping by AS IP : target_port */
554  clib_bihash_8_8_t mapping_by_as4;
555  clib_bihash_24_8_t mapping_by_as6;
556 
557  /* Static mapping pool */
559 
560  /**
561  * API dynamically registered base ID.
562  */
564 
566 
567  /* convenience */
570 } lb_main_t;
571 
572 /* args for different vip encap types */
573 typedef struct {
574  ip46_address_t prefix;
582 
583 extern lb_main_t lb_main;
590 
591 /**
592  * Fix global load-balancer parameters.
593  * @param ip4_address IPv4 source address used for encapsulated traffic
594  * @param ip6_address IPv6 source address used for encapsulated traffic
595  * @param sticky_buckets FIXME
596  * @param flow_timeout FIXME
597  * @return 0 on success. VNET_LB_ERR_XXX on error
598  */
599 int lb_conf(ip4_address_t *ip4_address, ip6_address_t *ip6_address,
600  u32 sticky_buckets, u32 flow_timeout);
601 
602 int lb_vip_add(lb_vip_add_args_t args, u32 *vip_index);
603 
604 int lb_vip_del(u32 vip_index);
605 
606 int lb_vip_find_index(ip46_address_t *prefix, u8 plen, u8 protocol,
607  u16 port, u32 *vip_index);
608 
609 #define lb_vip_get_by_index(index) (pool_is_free_index(lb_main.vips, index)?NULL:pool_elt_at_index(lb_main.vips, index))
610 
611 int lb_vip_add_ass(u32 vip_index, ip46_address_t *addresses, u32 n);
612 int lb_vip_del_ass(u32 vip_index, ip46_address_t *addresses, u32 n, u8 flush);
613 int lb_flush_vip_as (u32 vip_index, u32 as_index);
614 
616 
617 void lb_garbage_collection();
618 
619 int lb_nat4_interface_add_del (u32 sw_if_index, int is_del);
620 int lb_nat6_interface_add_del (u32 sw_if_index, int is_del);
621 
623 
624 #endif /* LB_PLUGIN_LB_LB_H_ */
lb_main_t
Definition: lb.h:470
LB6_NODEPORT_NEXT_DROP
@ LB6_NODEPORT_NEXT_DROP
Definition: lb.h:100
LB_nat4_in2out_next_t
LB_nat4_in2out_next_t
Definition: lb.h:59
bihash_24_8.h
lb_main_t::vip_index_per_port
clib_bihash_8_8_t vip_index_per_port
Definition: lb.h:551
lb_main_t::vlib_main
vlib_main_t * vlib_main
Definition: lb.h:568
lb_vip_encap_args_t::as_u64
u64 as_u64
Definition: lb.h:237
lb_main_t::msg_id_base
u16 msg_id_base
API dynamically registered base ID.
Definition: lb.h:563
lb_vip_t::prefix
ip46_address_t prefix
A Virtual IP represents a given service delivered by a set of application servers.
Definition: lb.h:292
vip_port_key_t::vip_prefix_index
u32 vip_prefix_index
Definition: lb.h:245
lb_snat_mapping_t
Definition: lb.h:442
lb_as_t
Each VIP is configured with a set of application server.
Definition: lb.h:108
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_as_t::next_hop_fib_entry_index
fib_node_index_t next_hop_fib_entry_index
The FIB entry index for the next-hop.
Definition: lb.h:151
bihash_8_8.h
lb_snat_mapping_t::src_port
u16 src_port
Network byte order for vip + port case, src_port = port; for node ip + node_port, src_port = node_por...
Definition: lb.h:456
LB6_NODEPORT_NEXT_IP6_NAT6
@ LB6_NODEPORT_NEXT_IP6_NAT6
Definition: lb.h:99
ip_proto
ip_proto
Definition: ip_types.api:75
lb_main_t::vip_index_by_nodeport
uword * vip_index_by_nodeport
Definition: lb.h:497
lb_main_t::vips
lb_vip_t * vips
Pool of all Virtual IPs.
Definition: lb.h:474
lb_snat4_key_t::port
u16 port
Definition: lb.h:419
vip_port_key_t::protocol
u8 protocol
Definition: lb.h:247
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
LB_VIP_TYPE_IP6_GRE4
@ LB_VIP_TYPE_IP6_GRE4
Definition: lb.h:210
fib_table.h
lb_as_t::address
ip46_address_t address
Destination address used to tunnel traffic towards that application server.
Definition: lb.h:120
foreach_lb_nat_in2out_error
#define foreach_lb_nat_in2out_error
Definition: lb.h:71
LB_NAT6_IN2OUT_NEXT_DROP
@ LB_NAT6_IN2OUT_NEXT_DROP
Definition: lb.h:66
u16
unsigned short u16
Definition: types.h:57
lb_main_t::ip4_src_address
ip4_address_t ip4_src_address
Source address used for IPv4 encapsulated traffic.
Definition: lb.h:517
vm
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
Definition: nat44_ei.c:3047
lb_as_t::last_used
u32 last_used
Rotating timestamp of when LB_AS_FLAGS_USED flag was last set.
Definition: lb.h:146
lb_vip_t::plen
u8 plen
The VIP prefix length.
Definition: lb.h:298
LB_NAT6_IN2OUT_NEXT_LOOKUP
@ LB_NAT6_IN2OUT_NEXT_LOOKUP
Definition: lb.h:67
lb_main_t::per_cpu
lb_per_cpu_t * per_cpu
Some global data is per-cpu.
Definition: lb.h:502
lb_main_t::vip_prefix_indexes
uword * vip_prefix_indexes
bitmap for vip prefix to support per-port vip
Definition: lb.h:479
port
u16 port
Definition: lb_types.api:73
lb_main_t::as_refcount
vlib_refcount_t as_refcount
Each AS has an associated reference counter.
Definition: lb.h:494
lb_vip_add_args_t::plen
u8 plen
Definition: lb.h:575
lb_snat6_key_t::fib_index
u32 fib_index
Definition: lb.h:436
lb_main_t::dpo_gre6_type
dpo_type_t dpo_gre6_type
Definition: lb.h:538
LB_NAT4_IN2OUT_NEXT_LOOKUP
@ LB_NAT4_IN2OUT_NEXT_LOOKUP
Definition: lb.h:61
lb_vip_t::protocol
u8 protocol
Definition: lb.h:301
fib_node_type_t
enum fib_node_type_t_ fib_node_type_t
The types of nodes in a FIB graph.
lb_vip_t::port
u16 port
Definition: lb.h:304
lb_snat4_key_t::protocol
u16 protocol
Definition: lb.h:420
lb4_node
vlib_node_registration_t lb4_node
lb_main_t::dpo_nat4_port_type
dpo_type_t dpo_nat4_port_type
Definition: lb.h:543
LB_ENCAP_TYPE_NAT4
@ LB_ENCAP_TYPE_NAT4
Definition: lb.h:188
lb_as_t::vip_index
u32 vip_index
ASs are indexed by address and VIP Index.
Definition: lb.h:127
lb_vip_add_args_t::port
u16 port
Definition: lb.h:577
lb_per_cpu_t
Definition: lb.h:462
LB_VIP_TYPE_IP4_L3DSR
@ LB_VIP_TYPE_IP4_L3DSR
Definition: lb.h:213
LB4_NODEPORT_N_NEXT
@ LB4_NODEPORT_N_NEXT
Definition: lb.h:95
lb_main_t::dpo_l3dsr_port_type
dpo_type_t dpo_l3dsr_port_type
Definition: lb.h:542
lb_snat6_key_t::addr
ip6_address_t addr
Definition: lb.h:433
LB6_NODEPORT_N_NEXT
@ LB6_NODEPORT_N_NEXT
Definition: lb.h:101
hash.h
lb_main_t::dpo_gre4_port_type
dpo_type_t dpo_gre4_port_type
Definition: lb.h:539
lb_next_t
lb_next_t
Definition: lb.h:54
dpo.h
lb_nat_in2out_error_t
lb_nat_in2out_error_t
Definition: lb.h:76
lb_main_t::dpo_l3dsr_type
dpo_type_t dpo_l3dsr_type
Definition: lb.h:541
LB_ENCAP_TYPE_L3DSR
@ LB_ENCAP_TYPE_L3DSR
Definition: lb.h:187
lb_main_t::dpo_gre6_port_type
dpo_type_t dpo_gre6_port_type
Definition: lb.h:540
lb_hash_time_now
u32 lb_hash_time_now(vlib_main_t *vm)
Definition: lb.c:96
lb_snat4_key_t::addr
ip4_address_t addr
Definition: lb.h:418
lock.h
unformat_lb_vip_type
unformat_function_t unformat_lb_vip_type
Definition: lb.h:220
lb_lkp_type_t
lb_lkp_type_t
Lookup type.
Definition: lb.h:197
lb_snat4_key_t::fib_index
u16 fib_index
Definition: lb.h:421
lb_snat_mapping_t::src_ip_is_ipv6
u8 src_ip_is_ipv6
Definition: lb.h:449
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_ENCAP_N_TYPES
@ LB_ENCAP_N_TYPES
Definition: lb.h:190
lb_main_t::dpo_nat6_port_type
dpo_type_t dpo_nat6_port_type
Definition: lb.h:544
lb_main_t::dpo_gre4_type
dpo_type_t dpo_gre4_type
DPO used to send packet from IP4/6 lookup to LB node.
Definition: lb.h:537
lb_vip_encap_args_t
Definition: lb.h:224
clib_spinlock_s
Definition: lock.h:51
LB_NAT4_IN2OUT_N_NEXT
@ LB_NAT4_IN2OUT_N_NEXT
Definition: lb.h:62
fib_node_index_t
u32 fib_node_index_t
A typedef of a node index.
Definition: fib_types.h:29
lb_vip_t::last_garbage_collection
u32 last_garbage_collection
Last time garbage collection was run to free the ASs.
Definition: lb.h:281
lb4_nodeport_next_t
lb4_nodeport_next_t
Definition: lb.h:92
uword
u64 uword
Definition: types.h:112
format_lb_as
format_function_t format_lb_as
Definition: lb.h:165
lb_vip_add_args_t::new_length
u32 new_length
Definition: lb.h:579
lb_nat4_interface_add_del
int lb_nat4_interface_add_del(u32 sw_if_index, int is_del)
Definition: lb.c:1330
lb_vip_is_nat6_port
static bool lb_vip_is_nat6_port(const lb_vip_t *vip)
Definition: lb.h:383
LB_ENCAP_TYPE_GRE4
@ LB_ENCAP_TYPE_GRE4
Definition: lb.h:185
dpo_type_t
enum dpo_type_t_ dpo_type_t
Common types of data-path objects New types can be dynamically added using dpo_register_new_type()
lb_nat_protocol_t
lb_nat_protocol_t
Definition: lb.h:395
lb_snat4_key_t::as_u64
u64 as_u64
Definition: lb.h:423
lb_vip_del
int lb_vip_del(u32 vip_index)
Definition: lb.c:1202
lb_vip_t::type
lb_vip_type_t type
The type of traffic for this.
Definition: lb.h:313
lb_vip_t::encap_args
lb_vip_encap_args_t encap_args
Definition: lb.h:316
lb_main_t::ip6_src_address
ip6_address_t ip6_src_address
Source address used in IPv6 encapsulated traffic.
Definition: lb.h:512
lb_hash_t
Definition: lbhash.h:58
LB_VIP_TYPE_IP4_GRE4
@ LB_VIP_TYPE_IP4_GRE4
Definition: lb.h:212
lb_nat6_in2out_node
vlib_node_registration_t lb_nat6_in2out_node
(constructor) VLIB_REGISTER_NODE (lb_nat6_in2out_node)
Definition: node.c:1276
lb_vip_add_args_t::prefix
ip46_address_t prefix
Definition: lb.h:574
lb_nat4_in2out_node
vlib_node_registration_t lb_nat4_in2out_node
(constructor) VLIB_REGISTER_NODE (lb_nat4_in2out_node)
Definition: node.c:1253
ip4_address_t
Definition: ip4_packet.h:50
vip_port_key_t::rsv
u8 rsv
Definition: lb.h:248
LB_VIP_TYPE_IP4_NAT4
@ LB_VIP_TYPE_IP4_NAT4
Definition: lb.h:214
lb_garbage_collection
void lb_garbage_collection()
Definition: lb.c:357
lb_vip_encap_args_t::target_port
u16 target_port
Definition: lb.h:233
lb_vip_t
Load balancing service is provided per VIP+protocol+port.
Definition: lb.h:262
LB_SRV_TYPE_NODEPORT
@ LB_SRV_TYPE_NODEPORT
Definition: lb.h:88
vlib_node_registration_t
struct _vlib_node_registration vlib_node_registration_t
lb_new_flow_entry_t
Definition: lb.h:167
lb_vip_add_args_t::encap_args
lb_vip_encap_args_t encap_args
Definition: lb.h:580
lb_flush_vip_as
int lb_flush_vip_as(u32 vip_index, u32 as_index)
Definition: lb.c:762
lb_snat_mapping_t::fib_index
u32 fib_index
Definition: lb.h:459
LB_VIP_TYPE_IP6_NAT6
@ LB_VIP_TYPE_IP6_NAT6
Definition: lb.h:215
lb_as_t::fib_node
fib_node_t fib_node
Registration to FIB event.
Definition: lb.h:112
lb_vip_add_args_t::protocol
u8 protocol
Definition: lb.h:576
LB_NAT6_IN2OUT_N_NEXT
@ LB_NAT6_IN2OUT_N_NEXT
Definition: lb.h:68
LB_VIP_TYPE_IP4_GRE6
@ LB_VIP_TYPE_IP4_GRE6
Definition: lb.h:211
lb_main_t::writer_lock
clib_spinlock_t writer_lock
Definition: lb.h:565
LB_N_VIP_COUNTERS
@ LB_N_VIP_COUNTERS
Definition: lb.h:181
format_lb_vip_type
format_function_t format_lb_vip_type
Definition: lb.h:219
LB_LKP_N_TYPES
@ LB_LKP_N_TYPES
Definition: lb.h:201
format_function_t
u8 *() format_function_t(u8 *s, va_list *args)
Definition: format.h:48
vnet_main_t
Definition: vnet.h:76
always_inline
#define always_inline
Definition: rdma_mlx5dv.h:23
LB_LKP_ALL_PORT_IP
@ LB_LKP_ALL_PORT_IP
Definition: lb.h:200
format_lb_vip
format_function_t format_lb_vip
Definition: lb.h:388
LB_NAT4_IN2OUT_NEXT_DROP
@ LB_NAT4_IN2OUT_NEXT_DROP
Definition: lb.h:60
lb_vip_encap_args_t::srv_type
u8 srv_type
Definition: lb.h:230
u64
unsigned long u64
Definition: types.h:89
lb_vip_t::vip_prefix_index
u32 vip_prefix_index
Definition: lb.h:307
LB_nat6_in2out_next_t
LB_nat6_in2out_next_t
Definition: lb.h:65
LB_SRV_TYPE_CLUSTERIP
@ LB_SRV_TYPE_CLUSTERIP
Definition: lb.h:87
lb_per_cpu_t::sticky_ht
lb_hash_t * sticky_ht
Each CPU has its own sticky flow hash table.
Definition: lb.h:467
lb_conf
int lb_conf(ip4_address_t *ip4_address, ip6_address_t *ip6_address, u32 sticky_buckets, u32 flow_timeout)
Fix global load-balancer parameters.
Definition: lb.c:476
lb_snat_mapping_t::as_ip_is_ipv6
u8 as_ip_is_ipv6
Definition: lb.h:450
lb4_nodeport_node
vlib_node_registration_t lb4_nodeport_node
(constructor) VLIB_REGISTER_NODE (lb4_nodeport_node)
Definition: node.c:1214
ip.h
u32
unsigned int u32
Definition: types.h:88
lb6_node
vlib_node_registration_t lb6_node
vip_port_key_t::as_u64
u64 as_u64
Definition: lb.h:250
vip_port_key_t::port
u16 port
Definition: lb.h:246
protocol
vl_api_ip_proto_t protocol
Definition: lb_types.api:72
ip4_address
manual_print typedef u8 ip4_address[4]
Definition: ip_types.api:18
lb_encap_type_t
lb_encap_type_t
Definition: lb.h:184
lb_as_t::dpo
dpo_id_t dpo
The next DPO in the graph to follow.
Definition: lb.h:161
ip6_address
manual_print typedef u8 ip6_address[16]
Definition: ip_types.api:19
LB_LKP_DIFF_IP_PORT
@ LB_LKP_DIFF_IP_PORT
Definition: lb.h:199
as_u64
u64 as_u64
Definition: bihash_doc.h:63
unformat_function_t
uword() unformat_function_t(unformat_input_t *input, va_list *args)
Definition: format.h:225
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_main_t::mapping_by_as4
clib_bihash_8_8_t mapping_by_as4
Definition: lb.h:554
LB4_NODEPORT_NEXT_DROP
@ LB4_NODEPORT_NEXT_DROP
Definition: lb.h:94
lb_main_t::mapping_by_as6
clib_bihash_24_8_t mapping_by_as6
Definition: lb.h:555
fib_node_t_
An node in the FIB graph.
Definition: fib_node.h:301
lb_vip_add_args_t::type
lb_vip_type_t type
Definition: lb.h:578
lb_vip_type_t
lb_vip_type_t
The load balancer supports IPv4 and IPv6 traffic and GRE4, GRE6, L3DSR and NAT4, NAT6 encap.
Definition: lb.h:208
lb_vip_t::flags
u8 flags
Flags related to this VIP.
Definition: lb.h:325
lb_vip_t::new_flow_table
lb_new_flow_entry_t * new_flow_table
Vector mapping (flow-hash & new_connect_table_mask) to AS index.
Definition: lb.h:270
lb6_nodeport_node
vlib_node_registration_t lb6_nodeport_node
(constructor) VLIB_REGISTER_NODE (lb6_nodeport_node)
Definition: node.c:1230
vlib_main_t
Definition: main.h:102
lb_vip_is_l3dsr_port
static bool lb_vip_is_l3dsr_port(const lb_vip_t *vip)
Definition: lb.h:373
LB_VIP_N_TYPES
@ LB_VIP_N_TYPES
Definition: lb.h:216
vlib_simple_counter_main_t
A collection of simple counters.
Definition: counter.h:57
u8
unsigned char u8
Definition: types.h:56
lb_ip_proto_to_nat_proto
static u32 lb_ip_proto_to_nat_proto(u8 ip_proto)
Definition: lb.h:402
refcount.h
lb_vip_is_l3dsr
static bool lb_vip_is_l3dsr(const lb_vip_t *vip)
Definition: lb.h:367
lb_main_t::ass
lb_as_t * ass
Pool of ASs.
Definition: lb.h:487
LB_LKP_SAME_IP_PORT
@ LB_LKP_SAME_IP_PORT
Definition: lb.h:198
lb_vip_add
int lb_vip_add(lb_vip_add_args_t args, u32 *vip_index)
Definition: lb.c:1048
foreach_lb_nat_protocol
#define foreach_lb_nat_protocol
Definition: lb.h:391
lb_snat6_key_t
Definition: lb.h:427
lb_as_t::flags
u8 flags
Some per-AS flags.
Definition: lb.h:133
dpo_id_t_
The identity of a DPO is a combination of its type and its instance number/index of objects of that t...
Definition: dpo.h:172
lb_snat4_key_t
Definition: lb.h:413
lb_main_t::flow_timeout
u32 flow_timeout
Flow timeout in seconds.
Definition: lb.h:527
vlib_refcount_t
Definition: refcount.h:49
lb_snat_mapping_t::src_ip
ip46_address_t src_ip
for vip + port case, src_ip = vip; for node ip + node_port, src_ip = node_ip
Definition: lb.h:447
lb_main_t::fib_node_type
fib_node_type_t fib_node_type
Node type for registering to fib changes.
Definition: lb.h:548
LB_ENCAP_TYPE_NAT6
@ LB_ENCAP_TYPE_NAT6
Definition: lb.h:189
lb_vip_t::new_flow_table_mask
u32 new_flow_table_mask
New flows table length - 1 (length MUST be a power of 2)
Definition: lb.h:276
lb_vip_counter_t
lb_vip_counter_t
Definition: lb.h:177
lb_svr_type_t
lb_svr_type_t
lb for kube-proxy supports three types of service
Definition: lb.h:86
vnet.h
lb_main
lb_main_t lb_main
Definition: lb.c:32
lb_vip_t::as_indexes
u32 * as_indexes
Pool of AS indexes used for this VIP.
Definition: lb.h:332
lbhash.h
lb_snat6_key_t::port
u16 port
Definition: lb.h:434
LB_NEXT_DROP
@ LB_NEXT_DROP
Definition: lb.h:55
lb_vip_is_nat4_port
static bool lb_vip_is_nat4_port(const lb_vip_t *vip)
Definition: lb.h:378
lb_foreach_vip_counter
#define lb_foreach_vip_counter
Definition: lb.h:171
lb_vip_add_args_t
Definition: lb.h:573
lb_snat_mapping_t::vrf_id
u32 vrf_id
Definition: lb.h:458
lb_as_t::next_hop_child_index
u32 next_hop_child_index
The child index on the FIB entry.
Definition: lb.h:156
lb_vip_add_ass
int lb_vip_add_ass(u32 vip_index, ip46_address_t *addresses, u32 n)
Definition: lb.c:585
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
lb_main_t::snat_mappings
lb_snat_mapping_t * snat_mappings
Definition: lb.h:558
lb_main_t::vnet_main
vnet_main_t * vnet_main
Definition: lb.h:569
lb6_nodeport_next_t
lb6_nodeport_next_t
Definition: lb.h:98
lb_vip_encap_args_t::dscp
u8 dscp
Definition: lb.h:236
LB_ENCAP_TYPE_GRE6
@ LB_ENCAP_TYPE_GRE6
Definition: lb.h:186
LB4_NODEPORT_NEXT_IP4_NAT4
@ LB4_NODEPORT_NEXT_IP4_NAT4
Definition: lb.h:93
lb_snat_mapping_t::as_ip
ip46_address_t as_ip
Definition: lb.h:448
lb_new_flow_entry_t::as_index
u32 as_index
Definition: lb.h:168
prefix
vl_api_prefix_t prefix
Definition: ip.api:175
LB_SRV_N_TYPES
@ LB_SRV_N_TYPES
Definition: lb.h:89
vip_port_key_t
Definition: lb.h:241
LB_NAT_IN2OUT_N_ERROR
@ LB_NAT_IN2OUT_N_ERROR
Definition: lb.h:80
lb_snat_mapping_t::target_port
u16 target_port
Definition: lb.h:457
LB_N_NEXT
@ LB_N_NEXT
Definition: lb.h:56
lb_snat6_key_t::protocol
u16 protocol
Definition: lb.h:435