sonic-buildimage/dockers/docker-dhcp-relay/dhcpv6-relay.agents.j2
shlomibitton 1ebe52847a
[DHCPv6 relay] [202106] Fix DHCPv6 design to support multiple VLANS (#9163)
- Why I did it
If multiple Vlans are configured to have DHCPv6 relay, only one relay instance is able to capture DHCP packets received from upstream, this is as a result of kernel design to operate this way (SO_REUSEPORT).
DHCPv6 transmit unicast packets to clients, only multicast packets can be captured on multiple application listening on the same UDP port.
This issue causing only one Vlan interface to get packets from servers.

- How I did it
Change the design to neglect Vlan isolation and run only one relay instance serving all Vlans with all configured DHCP servers.

- How to verify it
Run DHCPv6 relay test with 2 Vlans configured do have a DHCP relay.

Signed-off-by: Shlomi Bitton <shlomibi@nvidia.com>
2021-11-18 19:40:48 +02:00

39 lines
1.5 KiB
Django/Jinja

{# Append DHCPv6 agent #}
{% set relay_for_ipv6 = { 'flag': False } %}
[program:isc-dhcpv6-relay-{{ v6_vlan_list|join("-") }}]
command=/usr/sbin/dhcrelay -d -6 --name-alias-map-file /tmp/port-name-alias-map.txt
{#- We get all DHCPv6 servers only once #}
{%- set dhcpv6_server_list = [] %}
{%- for vlan_name in v6_vlan_list %}
{%- for dhcpv6_server in VLAN[vlan_name]['dhcpv6_servers'] %}
{%- if dhcpv6_server | ipv6 and dhcpv6_server not in dhcpv6_server_list %}
{%- set _dummy = dhcpv6_server_list.append( dhcpv6_server ) %}
{%- endif %}
{%- endfor %}
{%- endfor %}
{#- We treat each VLAN as a downstream interface (-l), as we only want to listen for requests #}
{%- for vlan_name in v6_vlan_list %} -l {{ vlan_name }}{% endfor -%}
{#- We treat all other interfaces as upstream interfaces (-u), as we only want to listen for replies #}
{%- for dhcpv6_server in dhcpv6_server_list %}
{%- if dhcpv6_server | ipv6 %}
{%- for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
{%- if prefix | ipv6 and name not in v6_vlan_list%} -u {{ dhcpv6_server }}%%{{ name }} {% endif -%}
{% endfor %}
{% for (name, prefix) in INTERFACE|pfx_filter %}
{% if prefix | ipv6 %} -u {{ dhcpv6_server }}%%{{ name }} {% endif -%}
{% endfor %}
{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %}
{% if prefix | ipv6 %} -u {{ dhcpv6_server }}%%{{ name }} {% endif -%}
{% endfor %}
{% endif %}
{% endfor %}
priority=3
autostart=false
autorestart=false
stdout_logfile=syslog
stderr_logfile=syslog
dependent_startup=true
dependent_startup_wait_for=start:exited