Commit 4be2af3e authored by Laine Stump's avatar Laine Stump

kill dhclient before attempting to change guest IP in no-ip-spoofing test

This test changes the IP address of the guest interface so that it can
send out a packet with a different source IP address. It may have
worked properly with older versions of Fedora running on the test
guest, but at least in Fedora 27, NetworkManager keeps the dhclient
process running after it has already acquired an IP address, and if
you set the interface offline and then back on, dhclient will very
quickly re-acquire the IP address, so the test ends up sending a ping
from the *same* address, the packet passes the filters, and the test
fails.

The solution is to just kill the dhclient process. This allows the
manually set IP address to "stick". Since the guest is shutdown
immediately after this test, it doesn't matter that dhclient is no
longer running. (We *do* need to set the IP address back to its
original setting though, so that the ssh socket used for the test
(which is connecting via the same interface) won't hang and delay
completion of the test (also causing it to fail).
Signed-off-by: default avatarLaine Stump <laine@laine.org>
Reviewed-by: default avatarStefan Berger <stefanb@linux.vnet.ibm.com>
Reviewed-by: default avatarDaniel P. Berrangé <berrange@redhat.com>
parent f00f55d7
......@@ -83,6 +83,7 @@ my $cmdfile = <<EOF;
echo "DEV=\\\$(ip link | head -3 | tail -1 | awk '{print \\\$2}' | sed -e 's/://')
MASK=\\\$(ip addr show \\\$DEV | grep 'inet ' | awk '{print \\\$2}' | sed -e 's/.*\\///;q')
ip addr show \\\$DEV
kill \\\$(pidof dhclient)
ip link set \\\$DEV down
ip addr flush dev \\\$DEV
ip addr add 192.168.122.183/\\\$MASK dev \\\$DEV
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment