Skip to content

Commit c1fc002

Browse files
raveningRakesh Venkatesh
andauthored
Fix iptable rules when chain reference count is 0 (#5328)
Sometimes the chain reference count is 0 and in that case proper iptables rules are not applied. Because of this, ping fails. So check the reference count for the main chain and as well as -IN and -OUT chain as well Co-authored-by: Rakesh Venkatesh <rakeshv@apache.org>
1 parent 7fa63b3 commit c1fc002

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

scripts/vm/network/security_group.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1327,9 +1327,11 @@ def add_fw_framework(brname):
13271327

13281328
try:
13291329
refs = int(execute("""iptables -n -L %s | awk '/%s(.*)references/ {gsub(/\(/, "") ;print $3}'""" % (brfw,brfw)).strip())
1330+
refs_in = int(execute("""iptables -n -L %s-IN | awk '/%s-IN(.*)references/ {gsub(/\(/, "") ;print $3}'""" % (brfw,brfw)).strip())
1331+
refs_out = int(execute("""iptables -n -L %s-OUT | awk '/%s-OUT(.*)references/ {gsub(/\(/, "") ;print $3}'""" % (brfw,brfw)).strip())
13301332
refs6 = int(execute("""ip6tables -n -L %s | awk '/%s(.*)references/ {gsub(/\(/, "") ;print $3}'""" % (brfw,brfw)).strip())
13311333

1332-
if refs == 0:
1334+
if refs == 0 or refs_in == 0 or refs_out == 0:
13331335
execute("iptables -I FORWARD -i " + brname + " -j DROP")
13341336
execute("iptables -I FORWARD -o " + brname + " -j DROP")
13351337
execute("iptables -I FORWARD -i " + brname + " -m physdev --physdev-is-bridged -j " + brfw)

0 commit comments

Comments
 (0)