[26/29] network: Force dhcpcd to ask for an IP address

Message ID 20221201172318.3166615-26-michael.tremer@ipfire.org
State Accepted
Commit 8d09028b69202788d92631655764b78f70b6dc23
Headers
Series [01/29] libgudev: New package |

Commit Message

Michael Tremer Dec. 1, 2022, 5:23 p.m. UTC
  So since all this static nonsense wasn't feeling right, I opened a
ticket upstream and got a lead how to actually get some proper DHCP
working.

  https://github.com/NetworkConfiguration/dhcpcd/issues/129

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
---
 src/initscripts/networking/dhcpcd.exe | 95 ---------------------------
 src/initscripts/networking/red        |  2 +-
 2 files changed, 1 insertion(+), 96 deletions(-)
  

Patch

diff --git a/src/initscripts/networking/dhcpcd.exe b/src/initscripts/networking/dhcpcd.exe
index 220f95c83..c8a79999d 100644
--- a/src/initscripts/networking/dhcpcd.exe
+++ b/src/initscripts/networking/dhcpcd.exe
@@ -60,18 +60,6 @@  dhcpcd_up()
 		mv /tmp/hosts /etc/hosts
 	fi
 
-	# Try to set the default route if there is none
-	# This can happen when we are using the 3RD party configuration
-	# This should not be necessary, since dhcpcd says it will configure
-	# a default route, but that does not seem to happen:
-	# https://github.com/NetworkConfiguration/dhcpcd/issues/129
-	if ! ip route 2>/dev/null | grep ^default && [ -s "/var/ipfire/red/remote-ipaddress" ]; then
-		gateway=$(</var/ipfire/red/remote-ipaddress)
-
-		# XXX This is ignoring any MTU configuration
-		ip route add default via "${gateway}"
-	fi
-
 	if [ $update ]; then
 		# Consider RED being active
 		touch /var/ipfire/red/active
@@ -107,86 +95,6 @@  dhcpcd_down()
 	return 0
 }
 
-# Called when dhcpcd relies on a third party to configure an IP address
-dhcpcd_3rdparty() {
-	local qmi_device="$(qmi_find_device "${interface}")"
-
-	if [ -n "${qmi_device}" ]; then
-		setup_qmi "${qmi_device}" || return $?
-	fi
-
-	return 0
-}
-
-setup_qmi() {
-	local device="${1}"
-
-	local address
-	local netmask
-	local gateway
-	local mtu=1500
-	local dns1
-	local dns2
-
-	local line
-	while read -r line; do
-		# Extract the value
-		value="${line#*: }"
-
-		case "${line}" in
-			*IPv4\ address:*)
-				address="${value}"
-				;;
-			*IPv4\ subnet\ mask:*)
-				netmask="${value}"
-				;;
-			*IPv4\ gateway\ address:*)
-				gateway="${value}"
-				;;
-			*IPv4\ primary\ DNS:*)
-				dns1="${value}"
-				;;
-			*IPv4\ secondary\ DNS:*)
-				dns2="${value}"
-				;;
-			*MTU:*)
-				mtu="${value}"
-				;;
-		esac
-	done <<< "$(qmicli --device="${device}" --wds-get-current-settings)"
-
-	if [ -z "${address}" ] || [ -z "${netmask}" ] || [ -z "${gateway}" ]; then
-		logger -p "local0.info" -t "dhcpcd.exe[$$]" \
-			"Could not retrieve all information from the QMI interface"
-		return 1
-	fi
-
-	# Flush any previous configuration
-	ip addr flush dev "${interface}"
-
-	# Configure the IP address
-	ip addr add "${address}/${netmask}" dev "${interface}"
-
-	# Configure the default route
-	if [ -n "${gateway}" ]; then
-		# Store the default gateway
-		echo -n "${gateway}" > /var/ipfire/red/remote-ipaddress
-
-		# Configure the default route
-		ip route add default via "${gateway}" mtu "${mtu}"
-	fi
-
-	# Store and DNS servers
-	if [ -n "${dns1}" ]; then
-		echo -n "${dns1}" > /var/ipfire/red/dns1
-	fi
-	if [ -n "${dns2}" ]; then
-		echo -n "${dns2}" > /var/ipfire/red/dns2
-	fi
-
-	return 0
-}
-
 case "${reason}" in
 	BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT|STATIC)
 		dhcpcd_up
@@ -194,9 +102,6 @@  case "${reason}" in
 	PREINIT|EXPIRE|FAIL|IPV4LL|NAK|RELEASE|STOP)
 		dhcpcd_down
 		;;
-	3RDPARTY)
-		dhcpcd_3rdparty
-		;;
 	# Ignored events where we do not need to do anything
 	STOPPED|CARRIER|NOCARRIER)
 		;;
diff --git a/src/initscripts/networking/red b/src/initscripts/networking/red
index 2d68c1685..f927ddbfb 100644
--- a/src/initscripts/networking/red
+++ b/src/initscripts/networking/red
@@ -227,7 +227,7 @@  case "${1}" in
 				ip link set "${RED_DEV}" up &>/dev/null
 
 				# Start the DHCP client
-				dhcpcd_start "${RED_DEV}" --nolink
+				dhcpcd_start "${RED_DEV}" --dhcp
 
 				# Done
 				exit 0