def _set_network_ip_config(ip_config): """Set IP configuration on Vdsm controlled OVS network""" iface = ip_config.top_dev ipv4 = ip_config.ipv4 ipv6 = ip_config.ipv6 port = ip_config.port blocking_dhcp = ip_config.blocking_dhcp net_dev = NetDevice(iface, iproute2, ipv4=ipv4, ipv6=ipv6, blockingdhcp=blocking_dhcp) DynamicSourceRoute.addInterfaceTracking(net_dev) ipwrapper.linkSet(iface, ['down']) if ipv4.address: ipwrapper.addrAdd(iface, ipv4.address, ipv4.netmask) if ipv4.gateway and ipv4.defaultRoute: ipwrapper.routeAdd(['default', 'via', ipv4.gateway]) if ipv6.address or ipv6.ipv6autoconf or ipv6.dhcpv6: sysctl.disable_ipv6(iface, disable=False) else: sysctl.disable_ipv6(iface) if ipv6.address: ipv6addr, ipv6netmask = ipv6.address.split('/') ipwrapper.addrAdd(iface, ipv6addr, ipv6netmask, family=6) if ipv6.gateway: ipwrapper.routeAdd(['default', 'via', ipv6.gateway], dev=iface, family=6) ipwrapper.linkSet(port, ['up']) ipwrapper.linkSet(iface, ['up']) if ipv4.bootproto == 'dhcp': _run_dhclient(iface, blocking_dhcp, ipv4.defaultRoute, 4) if ipv6.dhcpv6: _run_dhclient(iface, blocking_dhcp, ipv6.defaultRoute, 6) iproute2._addSourceRoute(net_dev)
def _set_ip_config(ip_config): iface = ip_config.top_dev ipv4 = ip_config.ipv4 ipv6 = ip_config.ipv6 port = ip_config.port blocking_dhcp = ip_config.blocking_dhcp net_dev = NetDevice(iface, iproute2, ipv4=ipv4, ipv6=ipv6, blockingdhcp=blocking_dhcp) DynamicSourceRoute.addInterfaceTracking(net_dev) ipwrapper.linkSet(iface, ["down"]) if ipv4.address: ipwrapper.addrAdd(iface, ipv4.address, ipv4.netmask) if ipv4.gateway and ipv4.defaultRoute: ipwrapper.routeAdd(["default", "via", ipv4.gateway]) if ipv6.address or ipv6.ipv6autoconf or ipv6.dhcpv6: sysctl.disable_ipv6(iface, disable=False) else: sysctl.disable_ipv6(iface) if ipv6.address: ipv6addr, ipv6netmask = ipv6.address.split("/") ipwrapper.addrAdd(iface, ipv6addr, ipv6netmask, family=6) if ipv6.gateway: ipwrapper.routeAdd(["default", "via", ipv6.gateway], dev=iface, family=6) ipwrapper.linkSet(port, ["up"]) ipwrapper.linkSet(iface, ["up"]) if ipv4.bootproto == "dhcp": _run_dhclient(iface, blocking_dhcp, ipv4.defaultRoute, 4) if ipv6.dhcpv6: _run_dhclient(iface, blocking_dhcp, ipv6.defaultRoute, 6) iproute2._addSourceRoute(net_dev)
def add(iface, ipv4, ipv6): if ipv4.address: _add_ipv4_address(iface, ipv4) if ipv6: _add_ipv6_address(iface, ipv6) elif ipv6_supported(): sysctl.disable_ipv6(iface)
def _set_ip_config(iface, ipv4, ipv6, port, blockingdhcp): net_dev = NetDevice(iface, iproute2, ipv4=ipv4, ipv6=ipv6, blockingdhcp=blockingdhcp) DynamicSourceRoute.addInterfaceTracking(net_dev) ipwrapper.linkSet(iface, ['down']) if ipv4.address: ipwrapper.addrAdd(iface, ipv4.address, ipv4.netmask) if ipv4.gateway and ipv4.defaultRoute: ipwrapper.routeAdd(['default', 'via', ipv4.gateway]) if ipv6.address or ipv6.ipv6autoconf or ipv6.dhcpv6: sysctl.disable_ipv6(iface, disable=False) else: sysctl.disable_ipv6(iface) if ipv6.address: ipv6addr, ipv6netmask = ipv6.address.split('/') ipwrapper.addrAdd(iface, ipv6addr, ipv6netmask, family=6) if ipv6.gateway: ipwrapper.routeAdd(['default', 'via', ipv6.gateway], dev=iface, family=6) ipwrapper.linkSet(port, ['up']) ipwrapper.linkSet(iface, ['up']) if ipv4.bootproto == 'dhcp': _run_dhclient(iface, blockingdhcp, ipv4.defaultRoute, 4) if ipv6.dhcpv6: _run_dhclient(iface, blockingdhcp, ipv6.defaultRoute, 6) iproute2._addSourceRoute(net_dev)
def add(iface, ipv4, ipv6): if ipv4.address: ipwrapper.addrAdd(iface, ipv4.address, ipv4.netmask) if ipv4.gateway and ipv4.defaultRoute: ipwrapper.routeAdd(['default', 'via', ipv4.gateway]) if ipv6: _add_ipv6_address(iface, ipv6) elif ipv6_supported(): sysctl.disable_ipv6(iface)
def configureBridge(self, bridge, **opts): self.configApplier.addBridge(bridge, **opts) ifdown(bridge.name) if bridge.port: bridge.port.configure(**opts) self._addSourceRoute(bridge) _ifup(bridge) if not bridge.ipv6.address and not bridge.ipv6.ipv6autoconf and ( not bridge.ipv6.dhcpv6): sysctl.disable_ipv6(bridge.name)
def configureBridge(self, bridge, **opts): self.configApplier.addBridge(bridge, **opts) ifdown(bridge.name) if bridge.port: bridge.port.configure(**opts) self._addSourceRoute(bridge) _ifup(bridge) if not bridge.ipv6.address and not bridge.ipv6.ipv6autoconf and ( not bridge.ipv6.dhcpv6 and netinfo.ipv6_supported()): wait_for_device(bridge.name) sysctl.disable_ipv6(bridge.name)
def configureBridge(self, bridge, **opts): self.configApplier.addBridge(bridge) if bridge.port: bridge.port.configure(**opts) self.configApplier.addBridgePort(bridge) DynamicSourceRoute.addInterfaceTracking(bridge) self.configApplier.setIfaceConfigAndUp(bridge) if not bridge.ipv6.address and not bridge.ipv6.ipv6autoconf and (not bridge.ipv6.dhcpv6): sysctl.disable_ipv6(bridge.name) self._addSourceRoute(bridge) if "custom" in opts and "bridge_opts" in opts["custom"]: self.configApplier._setBridgeOpts(bridge, opts["custom"]["bridge_opts"])
def configureBridge(self, bridge, **opts): self.configApplier.addBridge(bridge, **opts) ifdown(bridge.name) if bridge.port: bridge.port.configure(**opts) self._addSourceRoute(bridge) _ifup(bridge) if ( not bridge.ipv6.address and not bridge.ipv6.ipv6autoconf and (not bridge.ipv6.dhcpv6 and misc.ipv6_supported()) ): wait_for_device(bridge.name) sysctl.disable_ipv6(bridge.name)
def configureBridge(self, bridge, **opts): self.configApplier.addBridge(bridge) if bridge.port: bridge.port.configure(**opts) self.configApplier.addBridgePort(bridge) DynamicSourceRoute.addInterfaceTracking(bridge) self.configApplier.setIfaceConfigAndUp(bridge) if not bridge.ipv6.address and not bridge.ipv6.ipv6autoconf and ( not bridge.ipv6.dhcpv6 and misc.ipv6_supported()): wait_for_device(bridge.name) sysctl.disable_ipv6(bridge.name) self._addSourceRoute(bridge) if 'custom' in opts and 'bridge_opts' in opts['custom']: self.configApplier._setBridgeOpts(bridge, opts['custom']['bridge_opts'])
def disable_ipv6(iface): if ipv6_supported(): sysctl.disable_ipv6(iface)
def _enable_ipv6(device_name, enable=True): # In broken networks, the device (and thus its sysctl node) may be missing. with _ignore_missing_device(device_name, enable): sysctl.disable_ipv6(device_name, disable=not enable)
def test_local_auto_when_ipv6_is_disabled(self): with dummy_device() as dev: sysctl.disable_ipv6(dev) self.assertEqual(False, addresses.is_ipv6_local_auto(dev))