diff options
author | Mingli Yu <mingli.yu@windriver.com> | 2020-04-02 14:26:08 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-04-02 15:24:59 +0100 |
commit | 5badcf8168b7267c7f594cf07c109765a796c144 (patch) | |
tree | c09252ca363c6511b553d946e4b812e25a5945fa | |
parent | 4882a93566f2ef24787777d33950f12a9cc5db4e (diff) | |
download | poky-5badcf8168b7267c7f594cf07c109765a796c144.tar.gz |
dhclient: not always skip the nfsroot interface
Don't skip the nfsroot interface when use dhcp
to get the address for nfsroot interface as the
nfsroot interface may need dhclient to renew
the lease.
(From OE-Core rev: 27aec88c2ff4588acacadbe1cd61d7ce233fc817)
Signed-off-by: Mingli Yu <mingli.yu@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper b/meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper index 7d0e224a1d..87c60fa95f 100644 --- a/meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper +++ b/meta/recipes-connectivity/dhcp/files/dhclient-systemd-wrapper | |||
@@ -1,5 +1,19 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | 2 | ||
3 | # Add an initial /var/lib/dhcp/dhclient.leases to make | ||
4 | # sure the IP which dhclient try to renew is the same | ||
5 | # with the IP which kernel got from dhcp server during | ||
6 | # boot | ||
7 | update_dhclient_leases() | ||
8 | { | ||
9 | local addr=$1 | ||
10 | local interface=$2 | ||
11 | echo "lease {" >> /var/lib/dhcp/dhclient.leases | ||
12 | echo " interface \"${addr}\";" >> /var/lib/dhcp/dhclient.leases | ||
13 | echo " fixed-address ${interface:0:-3};" >> /var/lib/dhcp/dhclient.leases | ||
14 | echo "}" >> /var/lib/dhcp/dhclient.leases | ||
15 | } | ||
16 | |||
3 | # In case the interface is used for nfs, skip it. | 17 | # In case the interface is used for nfs, skip it. |
4 | nfsroot=0 | 18 | nfsroot=0 |
5 | interfaces="" | 19 | interfaces="" |
@@ -19,6 +33,7 @@ while read dev mtpt fstype rest; do | |||
19 | done | 33 | done |
20 | exec 0<&9 9<&- | 34 | exec 0<&9 9<&- |
21 | 35 | ||
36 | |||
22 | if [ $nfsroot -eq 0 ]; then | 37 | if [ $nfsroot -eq 0 ]; then |
23 | interfaces="$INTERFACES" | 38 | interfaces="$INTERFACES" |
24 | else | 39 | else |
@@ -27,7 +42,16 @@ else | |||
27 | fi | 42 | fi |
28 | for i in $INTERFACES; do | 43 | for i in $INTERFACES; do |
29 | if test "x$i" = "x$nfs_iface"; then | 44 | if test "x$i" = "x$nfs_iface"; then |
30 | echo "dhclient skipping nfsroot interface $i" | 45 | interface_addr=`ip -4 address show $nfs_iface | grep 'inet '|sed 's/.*inet \(\S\+\).*/\1/'` |
46 | if [ "x$interface_addr" != "x" ] && cat /proc/cmdline | grep "ip=dhcp" > /dev/null ; then | ||
47 | # use to renew lease if needed | ||
48 | interfaces="$interfaces $i" | ||
49 | # use to update /var/lib/dhcp/dhclient.leases if needed | ||
50 | # when the ip got by kernel, we need use dhclient to renew the ip | ||
51 | update_dhclient_leases $nfs_iface $interface_addr | ||
52 | else | ||
53 | echo "dhclient skipping nfsroot interface $i" | ||
54 | fi | ||
31 | else | 55 | else |
32 | interfaces="$interfaces $i" | 56 | interfaces="$interfaces $i" |
33 | fi | 57 | fi |