summaryrefslogtreecommitdiff
path: root/data
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-09-02 19:02:55 +0200
committerGitHub <noreply@github.com>2023-09-02 19:02:55 +0200
commite74b38c4d862feed7a401723c1f0b1c9d9a03324 (patch)
tree3b7e21cb3462ce3d026b32de6e73c54faad7d98b /data
parent0ba723bcdbf608ba73bedbba74a8aa9be1d7df7b (diff)
parentf7473c735ab2d5b74718012cbd27a6ca38e5dfa1 (diff)
downloadvyos-1x-e74b38c4d862feed7a401723c1f0b1c9d9a03324.tar.gz
vyos-1x-e74b38c4d862feed7a401723c1f0b1c9d9a03324.zip
Merge pull request #2191 from c-po/equuleus
T5428: fix DHCP client running in VRF context
Diffstat (limited to 'data')
-rw-r--r--data/templates/dhcp-client/daemon-options.tmpl4
-rw-r--r--data/templates/dhcp-client/ipv6.override.conf.j210
-rw-r--r--data/templates/dhcp-client/override.conf.j214
3 files changed, 24 insertions, 4 deletions
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 }}