mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'origin/4.11' into 4.12
This commit is contained in:
commit
fb555b11ae
@ -858,7 +858,7 @@ class CsForwardingRules(CsDataBag):
|
|||||||
rule['protocol'],
|
rule['protocol'],
|
||||||
rule['protocol'],
|
rule['protocol'],
|
||||||
public_fwports,
|
public_fwports,
|
||||||
hex(int(public_fwinterface[3:]))
|
hex(100 + int(public_fwinterface[3:]))
|
||||||
)
|
)
|
||||||
fw6 = "-A PREROUTING -d %s/32 -i %s -p %s -m %s --dport %s -m state --state NEW -j CONNMARK --save-mark --nfmask 0xffffffff --ctmask 0xffffffff" % \
|
fw6 = "-A PREROUTING -d %s/32 -i %s -p %s -m %s --dport %s -m state --state NEW -j CONNMARK --save-mark --nfmask 0xffffffff --ctmask 0xffffffff" % \
|
||||||
(
|
(
|
||||||
@ -927,7 +927,7 @@ class CsForwardingRules(CsDataBag):
|
|||||||
rule["internal_ip"]])
|
rule["internal_ip"]])
|
||||||
self.fw.append(["mangle", "",
|
self.fw.append(["mangle", "",
|
||||||
"-I PREROUTING -s %s/32 -m state --state NEW -j MARK --set-xmark %s/0xffffffff" %
|
"-I PREROUTING -s %s/32 -m state --state NEW -j MARK --set-xmark %s/0xffffffff" %
|
||||||
(rule["internal_ip"], hex(int(device[len("eth"):])))])
|
(rule["internal_ip"], hex(100 + int(device[len("eth"):])))])
|
||||||
self.fw.append(["nat", "front",
|
self.fw.append(["nat", "front",
|
||||||
"-A PREROUTING -d %s/32 -j DNAT --to-destination %s" % (rule["public_ip"], rule["internal_ip"])])
|
"-A PREROUTING -d %s/32 -j DNAT --to-destination %s" % (rule["public_ip"], rule["internal_ip"])])
|
||||||
self.fw.append(["nat", "front",
|
self.fw.append(["nat", "front",
|
||||||
|
|||||||
@ -258,7 +258,7 @@ class CsIP:
|
|||||||
|
|
||||||
def __init__(self, dev, config):
|
def __init__(self, dev, config):
|
||||||
self.dev = dev
|
self.dev = dev
|
||||||
self.dnum = hex(int(dev[3:]))
|
self.dnum = hex(100 + int(dev[3:]))
|
||||||
self.iplist = {}
|
self.iplist = {}
|
||||||
self.address = {}
|
self.address = {}
|
||||||
self.list()
|
self.list()
|
||||||
@ -518,12 +518,11 @@ class CsIP:
|
|||||||
|
|
||||||
if method == "add":
|
if method == "add":
|
||||||
if not self.config.is_vpc():
|
if not self.config.is_vpc():
|
||||||
# treat the first IP on a interface as special case to set up the routing rules
|
if self.get_type() in ["public"]:
|
||||||
if self.get_type() in ["public"] and (len(self.iplist) == 1):
|
route.set_route("table %s throw %s proto static" % (tableName, self.config.address().dbag['eth0'][0]['network']))
|
||||||
CsHelper.execute("sudo ip route add throw " + self.config.address().dbag['eth0'][0]['network'] + " table " + tableName + " proto static")
|
route.set_route("table %s throw %s proto static" % (tableName, self.config.address().dbag['eth1'][0]['network']))
|
||||||
CsHelper.execute("sudo ip route add throw " + self.config.address().dbag['eth1'][0]['network'] + " table " + tableName + " proto static")
|
|
||||||
|
|
||||||
# add 'defaul via gateway' rule in the device specific routing table
|
# add 'default via gateway' rule in the device specific routing table
|
||||||
if "gateway" in self.address and self.address["gateway"] and self.address["gateway"] != "None":
|
if "gateway" in self.address and self.address["gateway"] and self.address["gateway"] != "None":
|
||||||
route.add_route(self.dev, self.address["gateway"])
|
route.add_route(self.dev, self.address["gateway"])
|
||||||
if "network" in self.address and self.address["network"]:
|
if "network" in self.address and self.address["network"]:
|
||||||
|
|||||||
@ -351,6 +351,33 @@ class CsRedundant(object):
|
|||||||
|
|
||||||
interfaces = [interface for interface in self.address.get_interfaces() if interface.is_public()]
|
interfaces = [interface for interface in self.address.get_interfaces() if interface.is_public()]
|
||||||
CsHelper.reconfigure_interfaces(self.cl, interfaces)
|
CsHelper.reconfigure_interfaces(self.cl, interfaces)
|
||||||
|
|
||||||
|
public_devices = list(set([interface.get_device() for interface in interfaces]))
|
||||||
|
if len(public_devices) > 1:
|
||||||
|
# Handle specific failures when multiple public interfaces
|
||||||
|
|
||||||
|
public_devices.sort()
|
||||||
|
|
||||||
|
# Ensure the default route is added, or outgoing traffic from VMs with static NAT on
|
||||||
|
# the subsequent interfaces will go from he wrong IP
|
||||||
|
route = CsRoute()
|
||||||
|
dev = ''
|
||||||
|
for interface in interfaces:
|
||||||
|
if dev == interface.get_device():
|
||||||
|
continue
|
||||||
|
dev = interface.get_device()
|
||||||
|
gateway = interface.get_gateway()
|
||||||
|
if gateway:
|
||||||
|
route.add_route(dev, gateway)
|
||||||
|
|
||||||
|
# The first public interface has a static MAC address between VRs. Subsequent ones don't,
|
||||||
|
# so an ARP announcement is needed on failover
|
||||||
|
for device in public_devices[1:]:
|
||||||
|
logging.info("Sending garp messages for IPs on %s" % device)
|
||||||
|
for interface in interfaces:
|
||||||
|
if interface.get_device() == device:
|
||||||
|
CsHelper.execute("arping -I %s -U %s -c 1" % (device, interface.get_ip()))
|
||||||
|
|
||||||
logging.info("Router switched to master mode")
|
logging.info("Router switched to master mode")
|
||||||
|
|
||||||
def _collect_ignore_ips(self):
|
def _collect_ignore_ips(self):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user