From: Mathias Kresin <dev@kresin.me>
Date: Fri, 8 Dec 2017 08:35:26 +0000 (+0100)
Subject: netifd: always send DHCPv4 hostname
X-Git-Tag: v18.06.0-rc1~1608
X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=abdf0dea3ab6470b596096635a60fbe2e8d0dfff;p=openwrt%2Fstaging%2Fpepe2k.git

netifd: always send DHCPv4 hostname

udhcpc doesn't send a hostname by default. Use the system hostname if
nothing else is specified, to always send a hostname.

It syncs the behaviour to odhcpc, which always sends a hostname.

Signed-off-by: Mathias Kresin <dev@kresin.me>
Acked-by: Stijn Tintel <stijn@linux-ipv6.be>
Acked-by: Hans Dedecker <dedeckeh@gmail.com>
---

diff --git a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
index ea02d68bb4..143e4451b6 100755
--- a/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
+++ b/package/network/config/netifd/files/lib/netifd/proto/dhcp.sh
@@ -40,6 +40,7 @@ proto_dhcp_setup() {
 		append dhcpopts "-x $opt"
 	done
 
+	[ -z "$hostname" ] && hostname="$(cat /proc/sys/kernel/hostname)"
 	[ "$broadcast" = 1 ] && broadcast="-B" || broadcast=
 	[ "$release" = 1 ] && release="-R" || release=
 	[ -n "$clientid" ] && clientid="-x 0x3d:${clientid//:/}" || clientid="-C"