aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lb/lb.c
diff options
context:
space:
mode:
authorNobuhiro MIKI <nmiki@yahoo-corp.jp>2023-06-28 15:15:58 +0900
committerMohammed HAWARI <momohawari@gmail.com>2023-07-13 08:10:26 +0000
commit95c2da7c251a87a4a9e8c618d76df0502e7b24f4 (patch)
tree8b5b929c95572ec187f66cd1663bae3ac342db47 /src/plugins/lb/lb.c
parentdf4d342d7618b959d9d2ac87aa70d47049b911bc (diff)
lb: Fix src_ip_sticky evaluation bug in per-port-vip case.
Before this fix, the src_ip_sticky flag was passed as an argument to the lb_node_get_hash function, which computes a hash value for a packet. However, in per-port-vip case, the value of src_ip_sticky flag may be different for each port number. As a result, the value is the same for all port numbers, even though it is a per-port-vip case. This commit fixes the src_ip_sticky evaluation by delaying it until the packet is received, so that the correct value is obtained. Also, the unit test case has been enhanced for this bug fix. The steps to reproduce this bug are described below: https://lists.fd.io/g/vpp-dev/message/23248 Type: fix Fixes: 613e6dc0bf92 ("lb: add source ip based sticky load balancing") Change-Id: I483492b214a1768e7a21fd86edd5151b3c46528b Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp>
Diffstat (limited to 'src/plugins/lb/lb.c')
-rw-r--r--src/plugins/lb/lb.c120
1 files changed, 0 insertions, 120 deletions
diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c
index c6f5a0ab89a..c0a443b2cda 100644
--- a/src/plugins/lb/lb.c
+++ b/src/plugins/lb/lb.c
@@ -93,78 +93,6 @@ const static char* const * const lb_dpo_nat6_port_nodes[DPO_PROTO_NUM] =
[DPO_PROTO_IP6] = lb_dpo_nat6_ip6_port,
};
-const static char *const lb_dpo_gre4_ip4_sticky[] = { "lb4-gre4-sticky",
- NULL };
-const static char *const lb_dpo_gre4_ip6_sticky[] = { "lb6-gre4-sticky",
- NULL };
-const static char *const *const lb_dpo_gre4_sticky_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = lb_dpo_gre4_ip4_sticky,
- [DPO_PROTO_IP6] = lb_dpo_gre4_ip6_sticky,
-};
-
-const static char *const lb_dpo_gre6_ip4_sticky[] = { "lb4-gre6-sticky",
- NULL };
-const static char *const lb_dpo_gre6_ip6_sticky[] = { "lb6-gre6-sticky",
- NULL };
-const static char *const *const lb_dpo_gre6_sticky_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = lb_dpo_gre6_ip4_sticky,
- [DPO_PROTO_IP6] = lb_dpo_gre6_ip6_sticky,
-};
-
-const static char *const lb_dpo_gre4_ip4_port_sticky[] = {
- "lb4-gre4-port-sticky", NULL
-};
-const static char *const lb_dpo_gre4_ip6_port_sticky[] = {
- "lb6-gre4-port-sticky", NULL
-};
-const static char *const
- *const lb_dpo_gre4_port_sticky_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = lb_dpo_gre4_ip4_port_sticky,
- [DPO_PROTO_IP6] = lb_dpo_gre4_ip6_port_sticky,
- };
-
-const static char *const lb_dpo_gre6_ip4_port_sticky[] = {
- "lb4-gre6-port-sticky", NULL
-};
-const static char *const lb_dpo_gre6_ip6_port_sticky[] = {
- "lb6-gre6-port-sticky", NULL
-};
-const static char *const
- *const lb_dpo_gre6_port_sticky_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = lb_dpo_gre6_ip4_port_sticky,
- [DPO_PROTO_IP6] = lb_dpo_gre6_ip6_port_sticky,
- };
-
-const static char *const lb_dpo_l3dsr_ip4_sticky[] = { "lb4-l3dsr-sticky",
- NULL };
-const static char *const *const lb_dpo_l3dsr_sticky_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = lb_dpo_l3dsr_ip4_sticky,
-};
-
-const static char *const lb_dpo_l3dsr_ip4_port_sticky[] = {
- "lb4-l3dsr-port-sticky", NULL
-};
-const static char *const
- *const lb_dpo_l3dsr_port_sticky_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = lb_dpo_l3dsr_ip4_port_sticky,
- };
-
-const static char *const lb_dpo_nat4_ip4_port_sticky[] = {
- "lb4-nat4-port-sticky", NULL
-};
-const static char *const
- *const lb_dpo_nat4_port_sticky_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP4] = lb_dpo_nat4_ip4_port_sticky,
- };
-
-const static char *const lb_dpo_nat6_ip6_port_sticky[] = {
- "lb6-nat6-port-sticky", NULL
-};
-const static char *const
- *const lb_dpo_nat6_port_sticky_nodes[DPO_PROTO_NUM] = {
- [DPO_PROTO_IP6] = lb_dpo_nat6_ip6_port_sticky,
- };
-
u32 lb_hash_time_now(vlib_main_t * vm)
{
return (u32) (vlib_time_now(vm) + 10000);
@@ -1024,22 +952,6 @@ static void lb_vip_add_adjacency(lb_main_t *lbm, lb_vip_t *vip,
dpo_type = lbm->dpo_nat4_port_type;
else if (lb_vip_is_nat6_port(vip))
dpo_type = lbm->dpo_nat6_port_type;
- else if (lb_vip_is_gre4_sticky (vip))
- dpo_type = lbm->dpo_gre4_sticky_type;
- else if (lb_vip_is_gre6_sticky (vip))
- dpo_type = lbm->dpo_gre6_sticky_type;
- else if (lb_vip_is_gre4_port_sticky (vip))
- dpo_type = lbm->dpo_gre4_port_sticky_type;
- else if (lb_vip_is_gre6_port_sticky (vip))
- dpo_type = lbm->dpo_gre6_port_sticky_type;
- else if (lb_vip_is_l3dsr_sticky (vip))
- dpo_type = lbm->dpo_l3dsr_sticky_type;
- else if (lb_vip_is_l3dsr_port_sticky (vip))
- dpo_type = lbm->dpo_l3dsr_port_sticky_type;
- else if (lb_vip_is_nat4_port_sticky (vip))
- dpo_type = lbm->dpo_nat4_port_sticky_type;
- else if (lb_vip_is_nat6_port_sticky (vip))
- dpo_type = lbm->dpo_nat6_port_sticky_type;
dpo_set(&dpo, dpo_type, proto, *vip_prefix_index);
fib_table_entry_special_dpo_add(0,
@@ -1406,22 +1318,6 @@ lb_as_stack (lb_as_t *as)
dpo_type = lbm->dpo_nat4_port_type;
else if (lb_vip_is_nat6_port(vip))
dpo_type = lbm->dpo_nat6_port_type;
- else if (lb_vip_is_gre4_sticky (vip))
- dpo_type = lbm->dpo_gre4_sticky_type;
- else if (lb_vip_is_gre6_sticky (vip))
- dpo_type = lbm->dpo_gre6_sticky_type;
- else if (lb_vip_is_gre4_port_sticky (vip))
- dpo_type = lbm->dpo_gre4_port_sticky_type;
- else if (lb_vip_is_gre6_port_sticky (vip))
- dpo_type = lbm->dpo_gre6_port_sticky_type;
- else if (lb_vip_is_l3dsr_sticky (vip))
- dpo_type = lbm->dpo_l3dsr_sticky_type;
- else if (lb_vip_is_l3dsr_port_sticky (vip))
- dpo_type = lbm->dpo_l3dsr_port_sticky_type;
- else if (lb_vip_is_nat4_port_sticky (vip))
- dpo_type = lbm->dpo_nat4_port_sticky_type;
- else if (lb_vip_is_nat6_port_sticky (vip))
- dpo_type = lbm->dpo_nat6_port_sticky_type;
dpo_stack(dpo_type,
lb_vip_is_ip4(vip->type)?DPO_PROTO_IP4:DPO_PROTO_IP6,
@@ -1523,22 +1419,6 @@ lb_init (vlib_main_t * vm)
lb_dpo_nat4_port_nodes);
lbm->dpo_nat6_port_type = dpo_register_new_type(&lb_vft,
lb_dpo_nat6_port_nodes);
- lbm->dpo_gre4_sticky_type =
- dpo_register_new_type (&lb_vft, lb_dpo_gre4_sticky_nodes);
- lbm->dpo_gre6_sticky_type =
- dpo_register_new_type (&lb_vft, lb_dpo_gre6_sticky_nodes);
- lbm->dpo_gre4_port_sticky_type =
- dpo_register_new_type (&lb_vft, lb_dpo_gre4_port_sticky_nodes);
- lbm->dpo_gre6_port_sticky_type =
- dpo_register_new_type (&lb_vft, lb_dpo_gre6_port_sticky_nodes);
- lbm->dpo_l3dsr_sticky_type =
- dpo_register_new_type (&lb_vft, lb_dpo_l3dsr_sticky_nodes);
- lbm->dpo_l3dsr_port_sticky_type =
- dpo_register_new_type (&lb_vft, lb_dpo_l3dsr_port_sticky_nodes);
- lbm->dpo_nat4_port_sticky_type =
- dpo_register_new_type (&lb_vft, lb_dpo_nat4_port_sticky_nodes);
- lbm->dpo_nat6_port_sticky_type =
- dpo_register_new_type (&lb_vft, lb_dpo_nat6_port_sticky_nodes);
lbm->fib_node_type = fib_node_register_new_type ("lb", &lb_fib_node_vft);
//Init AS reference counters