From 47d9c8067135b97bc1fbc5450dc5fa9b8e65e345 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Mon, 28 Aug 2023 21:21:14 +0200 Subject: T5428: fix DHCP address renewal/release when running in VRF --- data/templates/dhcp-client/daemon-options.tmpl | 4 ---- data/templates/dhcp-client/ipv6.override.conf.j2 | 10 ++++++++++ data/templates/dhcp-client/override.conf.j2 | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) delete mode 100644 data/templates/dhcp-client/daemon-options.tmpl create mode 100644 data/templates/dhcp-client/ipv6.override.conf.j2 create mode 100644 data/templates/dhcp-client/override.conf.j2 (limited to 'data') diff --git a/data/templates/dhcp-client/daemon-options.tmpl b/data/templates/dhcp-client/daemon-options.tmpl deleted file mode 100644 index 40629dca1..000000000 --- a/data/templates/dhcp-client/daemon-options.tmpl +++ /dev/null @@ -1,4 +0,0 @@ -### Autogenerated by interface.py ### - -DHCLIENT_OPTS="-nw -cf /var/lib/dhcp/dhclient_{{ifname}}.conf -pf /var/lib/dhcp/dhclient_{{ifname}}.pid -lf /var/lib/dhcp/dhclient_{{ifname}}.leases{{" -e IF_METRIC=" ~ dhcp_options.default_route_distance if dhcp_options.default_route_distance is defined and dhcp_options.default_route_distance is not none}} {{ifname}}" - diff --git a/data/templates/dhcp-client/ipv6.override.conf.j2 b/data/templates/dhcp-client/ipv6.override.conf.j2 new file mode 100644 index 000000000..47e48e86f --- /dev/null +++ b/data/templates/dhcp-client/ipv6.override.conf.j2 @@ -0,0 +1,10 @@ +{% set vrf_command = 'ip vrf exec ' ~ vrf ~ ' ' if vrf is defined and vrf is not none else '' %} +{% set no_release = '-n' if dhcpv6_options is defined and dhcpv6_options.no_release is defined and dhcpv6_options.no_release is not none else '' %} +{% set dhcp6c_options = '-D -k /run/dhcp6c/dhcp6c.' ~ ifname ~ '.sock -c /run/dhcp6c/dhcp6c.' ~ ifname ~ '.conf -p /run/dhcp6c/dhcp6c.' ~ ifname ~ '.pid ' ~ no_release %} + +[Unit] +ConditionPathExists=/run/dhcp6c/dhcp6c.{{ ifname }}.conf + +[Service] +ExecStart= +ExecStart={{ vrf_command }}/usr/sbin/dhcp6c {{ dhcp6c_options }} {{ ifname }} \ No newline at end of file diff --git a/data/templates/dhcp-client/override.conf.j2 b/data/templates/dhcp-client/override.conf.j2 new file mode 100644 index 000000000..5ceee9f5e --- /dev/null +++ b/data/templates/dhcp-client/override.conf.j2 @@ -0,0 +1,14 @@ +### Autogenerated by interface.py ### +{% set vrf_command = 'ip vrf exec ' ~ vrf ~ ' ' if vrf is defined and vrf is not none else '' %} +{% set if_metric = '-e IF_METRIC=' ~ dhcp_options.default_route_distance if dhcp_options is defined and dhcp_options.default_route_distance is defined and dhcp_options.default_route_distance is not none else '' %} +{% set dhclient_options = '-d -nw -cf /var/lib/dhcp/dhclient_' ~ ifname ~ '.conf -pf /var/lib/dhcp/dhclient_' ~ ifname ~ '.pid -lf /var/lib/dhcp/dhclient_' ~ ifname ~ '.leases ' ~ if_metric %} + +[Unit] +ConditionPathExists= +ConditionPathExists=/var/lib/dhcp/dhclient_{{ ifname }}.conf + +[Service] +ExecStart= +ExecStart={{ vrf_command }}/sbin/dhclient -4 {{ dhclient_options }} {{ ifname }} +ExecStop= +ExecStop={{ vrf_command }}/sbin/dhclient -4 -r {{ dhclient_options }} {{ ifname }} -- cgit v1.2.3