Ondřej Svoboda has uploaded a new change for review. Change subject: iproute2, dhclient: Deal with v4/v6 protocols separately ......................................................................
iproute2, dhclient: Deal with v4/v6 protocols separately When taking over DHCP services, stop the previously running dhclient only if the protocol matches. Similarly, flush only the respective adresses (also keep link-local v6 addresses for DHCPv6 functionality). Change-Id: I5708c4db6f6d450536bd243a0475164b89f46f93 Signed-off-by: Ondřej Svoboda <[email protected]> --- M lib/vdsm/ipwrapper.py M vdsm/network/configurators/dhclient.py 2 files changed, 14 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/04/31104/1 diff --git a/lib/vdsm/ipwrapper.py b/lib/vdsm/ipwrapper.py index 3b38be4..79ad112 100644 --- a/lib/vdsm/ipwrapper.py +++ b/lib/vdsm/ipwrapper.py @@ -556,8 +556,10 @@ _execCmd(command) -def addrFlush(dev): - command = [_IP_BINARY.cmd, 'addr', 'flush', 'dev', dev] +def addrFlush(dev, family='both'): + family = ['-%s' % family] if family in (4, 6) else [] + command = [_IP_BINARY.cmd] + family + ['addr', 'flush', 'dev', dev, + 'scope', 'global'] _execCmd(command) diff --git a/vdsm/network/configurators/dhclient.py b/vdsm/network/configurators/dhclient.py index 8adbc2a..8f1617a 100644 --- a/vdsm/network/configurators/dhclient.py +++ b/vdsm/network/configurators/dhclient.py @@ -48,7 +48,7 @@ def _dhclient(self): # Ask dhclient to stop any dhclient running for the device if os.path.exists(os.path.join(netinfo.NET_PATH, self.iface)): - kill_dhclient(self.iface) + kill_dhclient(self.iface, self.family) rc, out, err = execCmd([self.DHCLIENT.cmd, '-%s' % self.family, '-1', '-pf', self.pidFile, '-lf', self.leaseFile, self.iface]) @@ -76,7 +76,7 @@ _kill_and_rm_pid(pid, self.pidFile) -def kill_dhclient(device_name): +def kill_dhclient(device_name, family=4): for pid in pgrep('dhclient'): try: with open('/proc/%s/cmdline' % pid) as cmdline: @@ -88,18 +88,24 @@ continue tokens = iter(args) pid_file = '/var/run/dhclient.pid' # Default client pid location + running_family = 4 for token in tokens: if token == '-pf': pid_file = next(tokens) elif token == '--no-pid': pid_file = None + elif token == '-6': + running_family = 6 + if running_family != family: + continue _kill_and_rm_pid(pid, pid_file) # In order to be able to configure the device with dhclient again. It is # necessary that dhclient does not find it configured with any IP address - # (except 0.0.0.0 which is fine). - ipwrapper.addrFlush(device_name) + # (except 0.0.0.0 which is fine, or IPv6 link-local address needed for + # DHCPv6). + ipwrapper.addrFlush(device_name, family) def _kill_and_rm_pid(pid, pid_file): -- To view, visit http://gerrit.ovirt.org/31104 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5708c4db6f6d450536bd243a0475164b89f46f93 Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Ondřej Svoboda <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
