Skip to content

Commit d61eed0

Browse files
committed
router: don't mark packets permanently on SNAT
This will remove MARK-ing of packets via the mangle table. This also fixes an unexplained issue of failure of access via public SNAT ips across VMS of the same VPC. This also removes MARK usage across VR codebase except for VPN. Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
1 parent 392f62d commit d61eed0

3 files changed

Lines changed: 6 additions & 23 deletions

File tree

systemvm/debian/opt/cloud/bin/configure.py

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -851,24 +851,15 @@ def forward_vr(self, rule):
851851
rule['protocol'],
852852
self.portsToString(rule['internal_ports'], ':')
853853
)
854-
fw5 = "-A PREROUTING -d %s/32 -i %s -p %s -m %s --dport %s -j MARK --set-xmark %s/0xffffffff" % \
854+
fw5 = "-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" % \
855855
(
856856
rule['public_ip'],
857857
public_fwinterface,
858858
rule['protocol'],
859859
rule['protocol'],
860860
public_fwports,
861-
hex(int(public_fwinterface[3:]))
862861
)
863-
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" % \
864-
(
865-
rule['public_ip'],
866-
public_fwinterface,
867-
rule['protocol'],
868-
rule['protocol'],
869-
public_fwports,
870-
)
871-
fw7 = "-A FORWARD -i %s -o %s -p %s -m %s --dport %s -m state --state NEW,ESTABLISHED -j ACCEPT" % \
862+
fw6 = "-A FORWARD -i %s -o %s -p %s -m %s --dport %s -m state --state NEW,ESTABLISHED -j ACCEPT" % \
872863
(
873864
public_fwinterface,
874865
internal_fwinterface,
@@ -881,8 +872,7 @@ def forward_vr(self, rule):
881872
self.fw.append(["nat", "", fw3])
882873
self.fw.append(["nat", "", fw4])
883874
self.fw.append(["nat", "", fw5])
884-
self.fw.append(["nat", "", fw6])
885-
self.fw.append(["filter", "", fw7])
875+
self.fw.append(["filter", "", fw6])
886876

887877
def forward_vpc(self, rule):
888878
fw_prerout_rule = "-A PREROUTING -d %s/32 " % (rule["public_ip"])
@@ -922,12 +912,6 @@ def processStaticNatRule(self, rule):
922912
if device is None:
923913
raise Exception("Ip address %s has no device in the ips databag" % rule["public_ip"])
924914

925-
self.fw.append(["mangle", "",
926-
"-I PREROUTING -s %s/32 -m state --state NEW -j CONNMARK --save-mark --nfmask 0xffffffff --ctmask 0xffffffff" %
927-
rule["internal_ip"]])
928-
self.fw.append(["mangle", "",
929-
"-I PREROUTING -s %s/32 -m state --state NEW -j MARK --set-xmark 0x%s/0xffffffff" %
930-
(rule["internal_ip"], device[len("eth"):])])
931915
self.fw.append(["nat", "front",
932916
"-A PREROUTING -d %s/32 -j DNAT --to-destination %s" % (rule["public_ip"], rule["internal_ip"])])
933917
self.fw.append(["nat", "front",

systemvm/debian/opt/cloud/bin/cs/CsAddress.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,6 @@ def post_configure(self, address):
299299
CsHelper.reconfigure_interfaces(self.cl, interfaces)
300300
if not self.config.is_vpc() and (self.get_type() in ['public']):
301301
self.set_mark()
302-
if self.config.is_vpc() and (self.get_type() in ['public']):
303-
self.set_mark()
304302

305303
if 'gateway' in self.address:
306304
self.arpPing()
@@ -363,6 +361,7 @@ def setup_router_control(self):
363361
def fw_router(self):
364362
if self.config.is_vpc():
365363
return
364+
366365
self.fw.append(["mangle", "front", "-A PREROUTING " +
367366
"-m state --state RELATED,ESTABLISHED " +
368367
"-j CONNMARK --restore-mark --nfmask 0xffffffff --ctmask 0xffffffff"])

systemvm/debian/opt/cloud/bin/cs/CsRoute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ def add_network_route(self, dev, address):
6262
table = self.get_tablename(dev)
6363
logging.info("Adding route: dev " + dev + " table: " +
6464
table + " network: " + address + " if not present")
65-
cmd = "dev %s table %s throw %s proto static" % (dev, table, address)
65+
cmd = "throw %s table %s proto static" % (address, table)
6666
self.set_route(cmd)
6767

6868
def set_route(self, cmd, method="add"):
6969
""" Add a route if it is not already defined """
7070
found = False
71-
for i in CsHelper.execute("ip route show " + cmd):
71+
for i in CsHelper.execute("ip route show table " + cmd.split(" table")[1]):
7272
found = True
7373
if not found and method == "add":
7474
logging.info("Add " + cmd)

0 commit comments

Comments
 (0)