From aada42795c0fd1290a28e227fed7820bed8bb03d Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Mon, 30 Nov 2020 22:36:28 +0100 Subject: [PATCH 1/3] DHCP: Rename options to dhcp-* Signed-off-by: Maximilian Wilhelm --- executor-scripts/linux/dhcp | 16 ++++++++-------- libifupdown/interface-file.c | 5 +++++ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/executor-scripts/linux/dhcp b/executor-scripts/linux/dhcp index 8666822..3d32a0b 100755 --- a/executor-scripts/linux/dhcp +++ b/executor-scripts/linux/dhcp @@ -1,6 +1,6 @@ #!/bin/sh # some users provide a shell fragment for the hostname property. -[ -n "$IF_HOSTNAME" ] && IF_HOSTNAME=$(eval echo $IF_HOSTNAME) +[ -n "$IF_DHCP_HOSTNAME" ] && IF_DHCP_HOSTNAME=$(eval echo $IF_DHCP_HOSTNAME) determine_implementation() { [ -n "$IF_DHCP_PROGRAM" ] && echo "$IF_DHCP_PROGRAM" && return @@ -14,10 +14,10 @@ determine_implementation() { start() { case "$1" in dhcpcd) - [ -n "$IF_HOSTNAME" ] && optargs="$optargs -h $IF_HOSTNAME" - [ -n "$IF_VENDOR" ] && optargs="$optargs -i $IF_VENDOR" - [ -n "$IF_CLIENT" ] && optargs="$optargs -i $IF_CLIENT" - [ -n "$IF_LEASETIME" ] && optargs="$optargs -l $IF_LEASETIME" + [ -n "$IF_DHCP_HOSTNAME" ] && optargs="$optargs -h $IF_DHCP_HOSTNAME" + [ -n "$IF_DHCP_VENDOR" ] && optargs="$optargs -i $IF_DHCP_VENDOR" + [ -n "$IF_DHCP_CLIENT_ID" ] && optargs="$optargs -i $IF_DHCP_CLIENT_ID" + [ -n "$IF_DHCP_LEASETIME" ] && optargs="$optargs -l $IF_DHCP_LEASETIME" ${MOCK} /sbin/dhcpcd $optargs $IFACE ;; dhclient) @@ -25,9 +25,9 @@ start() { ;; udhcpc) optargs=$(eval echo $IF_UDHCPC_OPTS) - [ -n "$IF_HOSTNAME" ] && optargs="$optargs -x hostname:$IF_HOSTNAME" - [ -n "$IF_CLIENT" ] && optargs="$optargs -c $IF_CLIENT" - [ -n "$IF_SCRIPT" ] && optargs="$optargs -s $IF_SCRIPT" + [ -n "$IF_DHCP_HOSTNAME" ] && optargs="$optargs -x hostname:$IF_DHCP_HOSTNAME" + [ -n "$IF_DHCP_CLIENT_ID" ] && optargs="$optargs -c $IF_DHCP_CLIENT_ID" + [ -n "$IF_DHCP_SCRIPT" ] && optargs="$optargs -s $IF_DHCP_SCRIPT" ${MOCK} /sbin/udhcpc -b -R -p /var/run/udhcpc.$IFACE.pid -i $IFACE $optargs ;; *) diff --git a/libifupdown/interface-file.c b/libifupdown/interface-file.c index d5c9fa5..c438ffb 100644 --- a/libifupdown/interface-file.c +++ b/libifupdown/interface-file.c @@ -32,6 +32,7 @@ struct remap_token { static const struct remap_token tokens[] = { {"bond-ad-sys-priority", "bond-ad-actor-sys-prio"}, /* ifupdown2 */ {"bond-slaves", "bond-members"}, /* legacy ifupdown, ifupdown2 */ + {"client", "dhcp-client-id"}, /* legacy ifupdown */ {"driver-message-level", "ethtool-msglvl"}, /* Debian ethtool integration */ {"endpoint", "tunnel-remote"}, /* legacy ifupdown */ {"ethernet-autoneg", "ethtool-ethernet-autoneg"}, /* Debian ethtool integration */ @@ -68,6 +69,8 @@ static const struct remap_token tokens[] = { {"hardware-irq-coalesce-tx-usecs-high", "ethtool-coalesce-tx-usecs-high"}, /* Debian ethtool integration */ {"hardware-irq-coalesce-tx-usecs-irq", "ethtool-coalesce-tx-usecs-irq"}, /* Debian ethtool integration */ {"hardware-irq-coalesce-tx-usecs-low", "ethtool-coalesce-tx-usecs-low"}, /* Debian ethtool integration */ + {"hostname", "dhcp-hostname"}, /* legacy ifupdown */ + {"leasetime", "dhcp-leastime"}, /* legacy ifupdown */ {"link-autoneg", "ethtool-ethernet-autoneg"}, /* ifupdown2 */ {"link-duplex", "ethtool-link-duplex"}, /* Debian ethtool integration */ {"link-fec", "ethtool-link-fec"}, /* ifupdown2 */ @@ -85,6 +88,7 @@ static const struct remap_token tokens[] = { {"offload-ufo", "ethtool-offload-ufo"}, /* Debian ethtool integration */ {"pointopoint", "point-to-point"}, /* legacy ifupdown, ifupdown2 */ {"provider", "ppp-provider"}, /* legacy ifupdown, ifupdown2 */ + {"script", "dhcp-script"}, /* legacy ifupdown */ {"rx-offload", "ethtool-offload-rx"}, /* ifupdown2 */ {"tso-offload", "ethtool-offload-tso"}, /* ifupdown2 */ {"ttl", "tunnel-ttl"}, /* legacy ifupdown */ @@ -92,6 +96,7 @@ static const struct remap_token tokens[] = { {"tunnel-physdev", "tunnel-dev"}, /* ifupdown2 */ {"tx-offload", "ethtool-offload-tx"}, /* ifupdown2 */ {"ufo-offload", "ethtool-offload-ufo"}, /* ifupdown2 */ + {"vendor", "dhcp-vendor"}, /* legacy ifupdown */ {"vrf", "vrf-member"}, /* ifupdown2 */ {"vxlan-local-tunnelip", "vxlan-local-ip"}, /* ifupdown2 */ {"vxlan-remoteip", "vxlan-remote-ip"}, /* ifupdown2 */ From b21cb37df05e7696464bead0c824538031e7e10f Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Mon, 30 Nov 2020 22:38:32 +0100 Subject: [PATCH 2/3] dhcp: Pass given config file to dhclient, if present Signed-off-by: Maximilian Wilhelm --- executor-scripts/linux/dhcp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/executor-scripts/linux/dhcp b/executor-scripts/linux/dhcp index 3d32a0b..30d1903 100755 --- a/executor-scripts/linux/dhcp +++ b/executor-scripts/linux/dhcp @@ -21,7 +21,12 @@ start() { ${MOCK} /sbin/dhcpcd $optargs $IFACE ;; dhclient) - ${MOCK} /usr/sbin/dhclient -pf /var/run/dhclient.$IFACE.pid $IFACE + # Specific config file given? + if [ -n "$IF_DHCP_CONFIG" ]; then + optargs="$optargs -cf $IF_DHCP_CONFIG" + fi + + ${MOCK} /usr/sbin/dhclient -pf /var/run/dhclient.$IFACE.pid $optarts $IFACE ;; udhcpc) optargs=$(eval echo $IF_UDHCPC_OPTS) From ff8e5d392ca331eb6eda702495bd9c4d1c5d7de3 Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Mon, 23 Nov 2020 21:52:31 +0100 Subject: [PATCH 3/3] dhcp: Fix test Signed-off-by: Maximilian Wilhelm --- tests/linux/dhcp_test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/linux/dhcp_test b/tests/linux/dhcp_test index 57d988f..d3d78f1 100755 --- a/tests/linux/dhcp_test +++ b/tests/linux/dhcp_test @@ -48,7 +48,7 @@ udhcpc_opts_up_subshell_body() { } hostname_subshell_body() { - export IFACE=eth0 PHASE=up MOCK=echo IF_DHCP_PROGRAM=udhcpc IF_HOSTNAME="\$(echo test)" + export IFACE=eth0 PHASE=up MOCK=echo IF_DHCP_PROGRAM=udhcpc IF_DHCP_HOSTNAME="\$(echo test)" atf_check -s exit:0 -o match:'/sbin/udhcpc -b -R -p /var/run/udhcpc.eth0.pid -i eth0 -x hostname:test' \ ${EXECUTOR} }