summaryrefslogtreecommitdiffstats
path: root/test
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 /test
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 'test')
-rw-r--r--test/test_lb.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/test_lb.py b/test/test_lb.py
index 6e8d82dfe40..e44684ecf2b 100644
--- a/test/test_lb.py
+++ b/test/test_lb.py
@@ -403,6 +403,29 @@ class TestLB(VppTestCase):
self.vapi.cli("lb vip 90.0.0.0/8 encap l3dsr dscp 7 del")
self.vapi.cli("test lb flowtable flush")
+ def test_lb_ip4_l3dsr_src_ip_sticky(self):
+ """Load Balancer IP4 L3DSR on vip with src_ip_sticky case"""
+ try:
+ self.vapi.cli("lb vip 90.0.0.0/8 encap l3dsr dscp 7 src_ip_sticky")
+ for asid in self.ass:
+ self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u" % (asid))
+
+ # Generate duplicated packets
+ pkts = self.generatePackets(self.pg0, isv4=True)
+ pkts = pkts[: len(pkts) // 2]
+ pkts = pkts + pkts
+
+ self.pg0.add_stream(pkts)
+ self.pg_enable_capture(self.pg_interfaces)
+ self.pg_start()
+ self.checkCapture(encap="l3dsr", isv4=True, src_ip_sticky=True)
+
+ finally:
+ for asid in self.ass:
+ self.vapi.cli("lb as 90.0.0.0/8 10.0.0.%u del" % (asid))
+ self.vapi.cli("lb vip 90.0.0.0/8 encap l3dsr dscp 7 src_ip_sticky del")
+ self.vapi.cli("test lb flowtable flush")
+
def test_lb_ip4_l3dsr_port(self):
"""Load Balancer IP4 L3DSR on per-port-vip case"""
try:
@@ -432,6 +455,12 @@ class TestLB(VppTestCase):
def test_lb_ip4_l3dsr_port_src_ip_sticky(self):
"""Load Balancer IP4 L3DSR on per-port-vip with src_ip_sticky case"""
try:
+ # This VIP at port 1000 does not receive packets, but is defined
+ # as a dummy to verify that the src_ip_sticky flag can be set
+ # independently for each port.
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 10000 encap l3dsr dscp 7"
+ )
self.vapi.cli(
"lb vip 90.0.0.0/8 protocol udp port 20000 encap l3dsr dscp 7 src_ip_sticky"
)
@@ -458,6 +487,9 @@ class TestLB(VppTestCase):
self.vapi.cli(
"lb vip 90.0.0.0/8 protocol udp port 20000 encap l3dsr dscp 7 src_ip_sticky del"
)
+ self.vapi.cli(
+ "lb vip 90.0.0.0/8 protocol udp port 10000 encap l3dsr dscp 7 del"
+ )
self.vapi.cli("test lb flowtable flush")
def test_lb_ip4_nat4_port(self):