8b192a1151
This is change taken as part of the HLD: sonic-net/SONiC#1470 and this is a follow up on the PR #16827 where in the docker-dhcp we pick the value of primary gateway of the interface from the VLAN_Interface table which has "secondary" flag set in the config_db Microsoft ADO (number only): 16784946 How did I do it - Changes in the j2 file to add a new "-pg" parameter in the dhcpv4-relay.agents.j2, the ip would be retrieved from the config db's vlan_interface table such that the interface which are picked will have secondary field set. - Changes in isc-dhcp to re-order the addresses of the discovered interface and which has the ip which has the passed parameter.
44 lines
1.8 KiB
Django/Jinja
44 lines
1.8 KiB
Django/Jinja
{# Append DHCPv4 agents #}
|
|
{% if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 %}
|
|
{% for dhcp_server in VLAN[vlan_name]['dhcp_servers'] %}
|
|
{% if dhcp_server | ipv4 %}
|
|
{% set _dummy = relay_for_ipv4.update({'flag': True}) %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% if relay_for_ipv4.flag %}
|
|
{% set _dummy = relay_for_ipv4.update({'flag': False}) %}
|
|
[program:isc-dhcpv4-relay-{{ vlan_name }}]
|
|
{# We treat this VLAN as a downstream interface (-id), as we only want to listen for requests #}
|
|
command=/usr/sbin/dhcrelay -d -m discard -a %%h:%%p %%P --name-alias-map-file /tmp/port-name-alias-map.txt -id {{ vlan_name }}
|
|
{#- Dual ToR Option #}
|
|
{% if 'subtype' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['subtype'] == 'DualToR' %} -U Loopback0 -dt{% endif -%}
|
|
{#- si option to use intf addr in relay #}
|
|
{% if DEVICE_METADATA['localhost']['deployment_id'] == '8' %} -si{% endif -%}
|
|
{#- We treat all other interfaces as upstream interfaces (-iu), as we only want to listen for replies #}
|
|
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
|
|
{% if prefix | ipv4 and name != vlan_name %} -iu {{ name }}{% endif -%}
|
|
{% endfor %}
|
|
{% for (name, prefix) in INTERFACE|pfx_filter %}
|
|
{% if prefix | ipv4 %} -iu {{ name }}{% endif -%}
|
|
{% endfor %}
|
|
{% for (name, prefix) in PORTCHANNEL_INTERFACE|pfx_filter %}
|
|
{% if prefix | ipv4 %} -iu {{ name }}{% endif -%}
|
|
{% endfor %}
|
|
{% for (name, gateway) in VLAN_INTERFACE|get_primary_addr %}
|
|
{% if gateway | ipv4 and name == vlan_name %} -pg {{ gateway }}{% endif -%}
|
|
{% endfor %}
|
|
{% for dhcp_server in VLAN[vlan_name]['dhcp_servers'] %}
|
|
{%- if dhcp_server | ipv4 %} {{ dhcp_server }}{% endif -%}
|
|
{% endfor %}
|
|
|
|
priority=3
|
|
autostart=false
|
|
autorestart=false
|
|
stdout_logfile=syslog
|
|
stderr_logfile=syslog
|
|
dependent_startup=true
|
|
dependent_startup_wait_for=start:exited
|
|
|
|
{% endif %}
|
|
{% endif %}
|