Skip to content

Commit 7c2395e

Browse files
author
Naredula Janardhana Reddy
committed
bug 10561: fix: last entry in the firewall rules unable to delete
1 parent 699b197 commit 7c2395e

3 files changed

Lines changed: 28 additions & 4 deletions

File tree

‎api/src/com/cloud/agent/api/routing/SetFirewallRulesCommand.java‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,19 @@ public String[][] generateFwRules() {
5151

5252

5353
for (FirewallRuleTO fwTO: rules) {
54-
if (fwTO.revoked() == true) continue;
54+
/* example : 172.16.92.44:tcp:80:80:0.0.0.0/0:,200.16.92.44:tcp:220:220:0.0.0.0/0:,
55+
* each entry format <ip>:protocol:srcport:destport:scidr:
56+
* reverted entry format <ip>:reverted:0:0:0:
57+
*/
58+
if (fwTO.revoked() == true)
59+
{
60+
StringBuilder sb = new StringBuilder();
61+
/* This entry is added just to make sure atleast there will one entry in the list to get the ipaddress */
62+
sb.append(fwTO.getSrcIp()).append(":reverted:0:0:0:");
63+
String fwRuleEntry = sb.toString();
64+
toAdd.add(fwRuleEntry);
65+
continue;
66+
}
5567

5668
List<String> cidr;
5769
StringBuilder sb = new StringBuilder();
@@ -64,6 +76,7 @@ public String[][] generateFwRules() {
6476
sb.append("0:0").append(":");
6577
else
6678
sb.append(fwTO.getStringSrcPortRange()).append(":");
79+
6780
cidr = fwTO.getSourceCidrList();
6881
if (cidr == null || cidr.isEmpty())
6982
{

‎patches/systemvm/debian/config/root/firewall_rule.sh‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ fw_entry_for_public_ip() {
6767
# note that rules are inserted after the RELATED,ESTABLISHED rule but before the DROP rule
6868
for src in $scidrs
6969
do
70+
if [ "$prot" == "reverted" ]
71+
then
72+
continue;
73+
fi
7074
if [ "$prot" == "icmp" ]
7175
then
7276
# TODO icmp code need to be implemented
@@ -75,7 +79,12 @@ fw_entry_for_public_ip() {
7579
then
7680
sudo iptables -t mangle -I FIREWALL_$pubIp 2 -s $src -p $prot -j RETURN
7781
else
78-
sudo iptables -t mangle -I FIREWALL_$pubIp 2 -s $src -p $prot --icmp-type $sport -j RETURN
82+
if ["$eport" == "-1"]
83+
then
84+
sudo iptables -t mangle -I FIREWALL_$pubIp 2 -s $src -p $prot --icmp-type $sport -j RETURN
85+
else
86+
sudo iptables -t mangle -I FIREWALL_$pubIp 2 -s $src -p $prot --icmp-type $sport/$eport -j RETURN
87+
fi
7988
fi
8089
else
8190
sudo iptables -t mangle -I FIREWALL_$pubIp 2 -s $src -p $prot --dport $sport:$eport -j RETURN
@@ -127,7 +136,9 @@ then
127136
fi
128137

129138
#-a 172.16.92.44:tcp:80:80:0.0.0.0/0:,172.16.92.44:tcp:220:220:0.0.0.0/0:,172.16.92.44:tcp:222:222:192.168.10.0/24-75.57.23.0/22-88.100.33.1/32
130-
139+
# if any entry is reverted , entry will be in the format <ip>:reverted:0:0:0
140+
# example : 172.16.92.44:tcp:80:80:0.0.0.0/0:,172.16.92.44:tcp:220:220:0.0.0.0/0:,200.1.1.2:reverted:0:0:0
141+
# The reverted entries will fix the following partially
131142
#FIXME: rule leak: when there are multiple ip address, there will chance that entry will be left over if the ipadress does not appear in the current execution when compare to old one
132143
# example : In the below first transaction have 2 ip's whereas in second transaction it having one ip, so after the second trasaction 200.1.2.3 ip will have rules in mangle table.
133144
# 1) -a 172.16.92.44:tcp:80:80:0.0.0.0/0:,200.16.92.44:tcp:220:220:0.0.0.0/0:,

‎scripts/network/domr/call_firewall.sh‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ usage() {
2929
printf "Usage for other purposes : %s: <domR eth1 ip> (-A|-D) -i <domR eth1 ip> -r <target-instance-ip> -P protocol (-p port_range | -t icmp_type_code) -l <public ip address> -d <target port> [-f <firewall ip> -u <firewall user> -y <firewall password> -z <firewall enable password> ] \n" $(basename $0) >&2
3030
}
3131

32-
set -x
32+
# set -x
3333

3434
# check if gateway domain is up and running
3535
check_gw() {

0 commit comments

Comments
 (0)