Fix IPv6 session persistence failed

When an IPv6 load balancer is created, and the pool is enabled with
SOURCE IP session persistence, it does not work because the stick
table only records IPv4 addresses. However, an IPv6 stick table can
record both IPv4 and IPv6 addresses.

Closes-Bug: #2027934

Change-Id: I1c51a5d6d6593108f431809868dcdb3d4142df45
This commit is contained in:
Chen Tianhao 2023-07-14 17:23:24 +08:00
parent 12d8e0de5d
commit 2aac2a8d78
3 changed files with 9 additions and 3 deletions

View File

@ -324,10 +324,10 @@ backend {{ pool.id }}:{{ listener.id }}
{% if (pool.session_persistence.type == {% if (pool.session_persistence.type ==
constants.SESSION_PERSISTENCE_SOURCE_IP) %} constants.SESSION_PERSISTENCE_SOURCE_IP) %}
{% if loadbalancer.topology == constants.TOPOLOGY_ACTIVE_STANDBY %} {% if loadbalancer.topology == constants.TOPOLOGY_ACTIVE_STANDBY %}
stick-table type ip size {{ pool.stick_size }} peers {{ stick-table type ipv6 size {{ pool.stick_size }} peers {{
"%s_peers"|format(loadbalancer.id.replace("-", ""))|trim() }} "%s_peers"|format(loadbalancer.id.replace("-", ""))|trim() }}
{% else %} {% else %}
stick-table type ip size {{ pool.stick_size }} stick-table type ipv6 size {{ pool.stick_size }}
{% endif %} {% endif %}
stick on src stick on src
{% elif (pool.session_persistence.type == {% elif (pool.session_persistence.type ==

View File

@ -922,7 +922,7 @@ class TestHaproxyCfg(base.TestCase):
be = ("backend sample_pool_id_1:sample_listener_id_1\n" be = ("backend sample_pool_id_1:sample_listener_id_1\n"
" mode http\n" " mode http\n"
" balance roundrobin\n" " balance roundrobin\n"
" stick-table type ip size 10k\n" " stick-table type ipv6 size 10k\n"
" stick on src\n" " stick on src\n"
" timeout check 31s\n" " timeout check 31s\n"
" option httpchk GET /index.html HTTP/1.0\\r\\n\n" " option httpchk GET /index.html HTTP/1.0\\r\\n\n"

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Fixed the issue with session persistence based on source IP not working for
IPv6 load balancers. Session persistence now functions properly for IPv4,
IPv6 and dual-stack load balancers.