Flush explicit IP label

This commit is contained in:
2021-03-02 14:12:11 +01:00
parent eb53021893
commit aecd905a22
+8 -8
View File
@@ -338,8 +338,8 @@ class ContainerDHCPManager:
if path.lexists('{dhcp.netns}'): if path.lexists('{dhcp.netns}'):
logger.info('[dhcp container] Flushing IP addresses') logger.info('[dhcp container] Flushing IP addresses')
subprocess.check_call(['nsenter', f'-n{dhcp.netns}', '--', '/sbin/ip', 'address', 'flush', 'dev', subprocess.check_call(['nsenter', f'-n{dhcp.netns}', '--', '/sbin/ip', 'address', 'flush', 'dev',
str(dhcp.iface['ifname'])], timeout=1, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, str(dhcp.iface['ifname']), 'label', str(dhcp.iface['ifname'])],
stderr=subprocess.DEVNULL) timeout=1, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else: else:
logger.info('[dhcp container] Container gone, can\'t flush IP addresses') logger.info('[dhcp container] Container gone, can\'t flush IP addresses')
elif event_type == udhcpc.EventType.RENEW or event_type == udhcpc.EventType.BOUND: elif event_type == udhcpc.EventType.RENEW or event_type == udhcpc.EventType.BOUND:
@@ -350,19 +350,19 @@ class ContainerDHCPManager:
logger.info('[dhcp container] Flushing IP addresses') logger.info('[dhcp container] Flushing IP addresses')
subprocess.check_call(['nsenter', f'-n{dhcp.netns}', '--', '/sbin/ip', 'address', 'flush', 'dev', subprocess.check_call(['nsenter', f'-n{dhcp.netns}', '--', '/sbin/ip', 'address', 'flush', 'dev',
str(dhcp.iface['ifname'])], timeout=1, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, str(dhcp.iface['ifname']), 'label', str(dhcp.iface['ifname'])],
stderr=subprocess.DEVNULL) timeout=1, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
logger.info('[dhcp container] Adding IP addresses %s', dhcp.ip) logger.info('[dhcp container] Adding IP addresses %s', dhcp.ip)
subprocess.check_call(['nsenter', f'-n{dhcp.netns}', '--', '/sbin/ip', 'address', 'add', str(dhcp.ip), 'dev', subprocess.check_call(['nsenter', f'-n{dhcp.netns}', '--', '/sbin/ip', 'address', 'add', str(dhcp.ip), 'dev',
str(dhcp.iface['ifname'])], timeout=1, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, str(dhcp.iface['ifname'])],
stderr=subprocess.DEVNULL) timeout=1, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
if dhcp.gateway: if dhcp.gateway:
logger.info('[dhcp container] Replacing gateway with %s', dhcp.gateway) logger.info('[dhcp container] Replacing gateway with %s', dhcp.gateway)
subprocess.check_call(['nsenter', f'-n{dhcp.netns}', '--', '/sbin/ip', 'route', 'replace', 'default', 'via', subprocess.check_call(['nsenter', f'-n{dhcp.netns}', '--', '/sbin/ip', 'route', 'replace', 'default', 'via',
str(dhcp.gateway)], timeout=1, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, str(dhcp.gateway)],
stderr=subprocess.DEVNULL) timeout=1, stdin=subprocess.DEVNULL, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
else: else:
logger.info('[dhcp container] Unhandled Event %s: %s', event_type,_event) logger.info('[dhcp container] Unhandled Event %s: %s', event_type,_event)