69 Commits

Author SHA1 Message Date
Frank Louwers
d8f37c5e17 Sorry about the typo
Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>

This closes #601
2015-07-23 08:36:05 +02:00
Frank Louwers
4705d75d4a CLOUDSTACK-8650: Fix securitygroups ingress FW for protocol any and 0.0.0.0/0
Change way 0.0.0.0/0 + all is handles, as per feedback in Slack channel

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
2015-07-23 08:36:05 +02:00
Wido den Hollander
3e3c11ffca CLOUDSTACK-8559: IP Source spoofing should not be allowed
We did not verify if the packets leaving an Instance had the correct
source address.

Any IP packet not matching the Instance IP(s) will be dropped
2015-06-15 15:05:53 +02:00
Rohit Yadav
840c0a0974 CLOUDSTACK-8401: Fix KVM's SG script to properly cleanup old network rules
- Router VMs don't have a chain rule with -def suffix, this fixes name and
  properly removes VR vms not running on a host
- Before trying to remove dnats, filter empty/None elements from list
- destroy_ebtables_rules should check what kind of action is request to be
  performed (-A for add or -D for removed) and execute based on that
- Before executing any command, log it for debugging purposes
- Method to cleanup bridge, may be used in future

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit 39255121154cca214328e93093db65f968b8c9f8)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-04-25 03:14:05 +02:00
Rohit Yadav
acd9a251d3 CLOUDSTACK-4611: cleanup_rules using ebtables rules from /proc/modules
The SG python script depends on ebtables-save which is not available on Debian
based distros (Ubuntu and Debian for example). The commit uses /proc/modules
to find available bridge tables (one of nat, filter or broute) and then
find VMs that need to be removed. Further it uses set() to remove duplicate VMs
so we don't try to remove a VM's rules more than once leading to unwanted errors
in the log.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit d66677101c7770b5c4b8c39064eba5ee94d124c6)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-04-25 03:13:58 +02:00
Rohit Yadav
2a14f78248 xenserver: remove unwanted vmops.orig file (created during a past merge)
scripts: filter output instead of popping string from list
This is a defensive enhancement for KVM SG script that filters out empty string
instead of popping last item which may or may not be an empty string.

Squashed commits:
(cherry picked from commit f4cbc4c010947a41c1e296b46822531e7f2bc1c9)
(cherry picked from commit 64ab3554a14afa48bb33839631ed4f8e71945874)

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-04-21 17:41:16 +02:00
Vincent Bernat
3ea8a1187a CLOUDSTACK-7195: log wide exceptions in security_group.py
Some try/except in security_group.py catch a lot of exceptions. There
was already one fixed in CLOUDSTACK-1052. Here is another one. We use
logging.exception() to log those exceptions.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
Signed-off-by: Pierre-Luc Dion <pdion891@apache.org>
2014-12-05 17:24:27 -05:00
Kishan Kavala
08dc5c6f91 CLOUDSTACK-7428: Allow LXC cluster in SG enabled zones. Use lxc driver in security_group.py script for lxc host 2014-08-27 11:52:59 +05:30
Vincent Bernat
53650ed7bf CLOUDSTACK-7193: handle domain ID being an int
Recent versions of libvirt (at least 0.9.8) will return an int when
queried for the ID of a domain, not a string. This breaks some parts of
the `security_group.py` script which expects a string containing an
int. Notably, this breaks the part handling VM reboots which is
therefore not executed.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
Signed-off-by: Sebastien Goasguen <runseb@gmail.com>
2014-08-18 10:36:21 -04:00
Edison Su
2276a399ac KVM security bug: no forwarding rule applied
(cherry picked from commit e5c391fcf3852e50ebd99d4a72fd51d1753b05eb)

Signed-off-by: Animesh Chaturvedi <animesh@apache.org>
2014-03-28 16:21:36 -07:00
jayapal
86124138a1 CLOUDSTACK-5924: Correcting regex to get vm names exactly from ebtables chains 2014-01-22 11:20:27 +05:30
Wei Zhou
258118efa6 CLOUDSTACK-4405: additional patch for bridge name and firewall rules issues after KVM upgrade to 4.2
There still exist two issues after Edison's commits.
(1) Migration from new hosts to old hosts failed.
The bridge name on old host is set to cloudVirBr* if network.bridge.name.schema is set to 3.0 in /etc/cloudstack/agent/agent.properties, but the actual bridge name is breth*-* after running cloudstack-agent-upgrade.
(2) all ports of vms (Basic zone, or Advanced zone with security groups) on old hosts are open, because the iptables rules are binding to device (bridge) name which is changed by cloudstack-agent-upgrade.

After this, the KVM upgrade steps :
a. Install 4.2 cloudstack agent on each kvm host
b. Run "cloudstack-agent-upgrade". This script will upgrade all the existing bridge name to new bridge name, and update related firewall rules.
c. install a libvirt hook:
    c1. mkdir /etc/libvirt/hooks
    c2. cp /usr/share/cloudstack-agent/lib/libvirtqemuhook /etc/libvirt/hooks/qemu
    c3. chmod +x /etc/libvirt/hooks/qemu
    c4. service libvirtd restart
    c5. service cloudstack-agent restart

Signed-off-by: Wei Zhou <w.zhou@leaseweb.com>
2013-09-24 09:55:00 +02:00
Wei Zhou
3f42601c6d fix different type issue in write_rule_log_for_vm in security_group.py 2013-09-13 12:02:24 +02:00
Wei Zhou
83d3f7d2f3 change return value of getvmId() from int to string in security_group.py 2013-09-13 11:37:30 +02:00
Mike Tutkowski
60e0873a93 The 'domain' variable should be 'vmName'. 2013-09-12 09:17:48 -06:00
Rene Diepstraten
211b180d55 Replaced virsh() by python-libvirt functions
Signed-off-by: Rene Diepstraten <rene@renediepstraten.nl>
2013-07-25 18:10:58 +02:00
Rene Diepstraten
052bff15c6 Replaced multiple grep/awk/head commands by one awk command
Signed-off-by: Rene Diepstraten <mail@renediepstraten.nl>
2013-07-18 13:41:36 +02:00
Rene Diepstraten
cf73d5b858 Added logpath variable and replaced hardcoded path
Signed-off-by: Rene Diepstraten <mail@renediepstraten.nl>
2013-07-18 12:31:38 +02:00
Rene Diepstraten
c85d41d46f Corrected typos in logmessages
Signed-off-by: Rene Diepstraten <mail@renediepstraten.nl>
2013-07-18 11:47:30 +02:00
Rene Diepstraten
ffe7cfe076 Truncated trailing/double spaces
Signed-off-by: Rene Diepstraten <mail@renediepstraten.nl>
2013-07-17 18:31:28 +02:00
Wido den Hollander
67bcce71f7 Security Group: Use awk to do matching and printing instead of using grep + awk.
Makes it a bit shorter code wise
2013-07-12 11:09:41 +02:00
Wido den Hollander
8e4e56f731 CLOUDSTACK-3409: Do not clean up security group rules for Instances in the "paused" state.
When 'security_group.py cleanup_rules' is called by the KVM Agent it will clean up all Instances
not in the "running" state according to libvirt.

However, when a snapshot is created of a Instance it will go to the "paused" state while the snapshot
is created.

This leads to Security Rules being removed when a Instance is being snapshotted and the cleanup process
is initiated.
2013-07-10 13:12:46 +02:00
Edison Su
299cccf779 fix copy/paste bug 2013-04-24 18:32:06 -07:00
Jayapal Uradi
edaa72d0fc CLOUDSTACK-24: mipn feature for basiczone kvmhost
Signed-off-by: Abhinandan Prateek <aprateek@apache.org>
2013-03-15 10:22:56 +05:30
John Kinsella
08a0788b38 Summary: security_group.py: catch exception when flushing chain
Detail: Added exception handling around iptables chain flushing, along
with a call to default_network_rules() to re-initialize.

Testing:
On agent, ls /var/run/cloud and pick one of the VMs to test with. Make a
backup of it's logfile (eg cp /var/run/cloud/i-2-1722.log /tmp )
Destroy the firewall ruleset for that VM with
/usr/lib64/cloud/common/scripts/vm/network/security_group.py destroy_network_rules_for_vm --vmname i-2-1722-VM --vif vnet10
Now copy the log file back, edit the file and decrement the last field by 1
ACS should notice the out-of-date sequence ID and push a new ruleset for
the VM within 60 seconds.

BUG-ID: CLOUDSTACK-1685
Bugfix-for: John Kinsella
Reviewed-by:
Reported-by:
Signed-off-by: John Kinsella <jlk@stratosec.co> 1363286927 -0700
2013-03-14 11:48:47 -07:00
John Kinsella
1079d63b6f Summary: Prevent deletion of wrong iptables rules
Detail: A grep in security_group.py wasn't defined well enough, could
potentially delete rules for VMs other than intended

BUG-ID: CLOUDSTACK-309
Bugfix-for: master
Reviewed-by:
Reported-by: Francois Scala
Signed-off-by: John Kinsella <jlk@stratosec.co> 1363222521 -0700
2013-03-13 17:55:21 -07:00
John Kinsella
381f737e64 Summary: Fix exception handling in security_group.py
Detail: Code was attempting to concatinate an exception to a string.
Updated to convert to text and concatinate that.

BUG-ID: CLOUDSTACK-1052
Bugfix-for: master
Reported-by: Noa Resare
Signed-off-by: John Kinsella <jlk@stratosec.co> 1363218769 -0700
2013-03-13 16:52:49 -07:00
Marcus Sorensen
0ca85659a6 CLOUDSTACK-1651 - point agent scripts to correct logging location, due to move
of /var/log/cloud to /var/log/cloudstack

Signed-off-by: Marcus Sorensen <marcus@betterservers.com> 1363112422 -0600
2013-03-12 12:20:22 -06:00
Radoslaw Smigielski
0383803188 scripts: Fix security_group.py handling of args and unknown commands
Checks the args length, doesn't throw IndexError when no args
passed. Also logs to security_group.log when executed with no args or unknown
command.

Review: https://reviews.apache.org/r/9588
Reviewed-by: Rohit Yadav <bhaisaab@apache.org>

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2013-02-26 14:12:49 +05:30
Rohit Yadav
6f29317a84 CLOUDSTACK-591: Fix execute and string processing logic for reboot_vm in security_group
- Since we're always getting the first from the list, use head -1 to get the first
  of the results instead of processing again
- Remove unecessay pop (why was it even there)

Signed-off-by: Rohit Yadav <bhaisaab@apache.org>
2012-12-13 15:28:30 -08:00
Bill Rich
1ae2d720a3 CLOUDSTACK-591: Changed bridge name parsing in security_group.py to support bridges named with dashes 2012-12-13 15:28:30 -08:00
Edison Su
cefc5cbff3 bug CS-16172
Reviewed-by: chiradeep
2012-08-24 16:13:29 -07:00
David Nalley
d630fa8697 license header changes for scripts folder from Chip Childers 2012-06-23 00:58:00 -04:00
Wido den Hollander
bdec29b3dc Create iptable rules for all bridges assigned to a system VM
The default_network_rules_systemvm method in security_group.py only created the appropriate rules for
just one bridge.

This however leads to traffic not being forwarded to the virtual machine in the case of the system VMs
both (console & storage) having different bridges in basic networking.

This patch makes sure rules are generated for all target devices based on their source device/bridge

It however excludes the LinkLocalBridge since no filtering is needed on that bridge.
2012-06-19 12:20:22 +02:00
John Kinsella
efe318336a CS-14955: security_group.py only creates ICMP iptables rules for ICMP type -1
Description:
Unindented 3 lines to update logic flow to execute iptables when
passed ICMP type is not -1.
2012-05-27 19:39:56 -04:00
Edison Su
d913e3bdfb security group: exactly match bridge name 2012-05-04 13:56:34 -07:00
frank
2f634c0913 Switch to Apache license 2012-04-03 04:50:05 -07:00
Naredula Janardhana Reddy
c7766ea6c8 bug 10617: kvm related changes. 2011-12-02 17:07:36 +05:30
Naredula Janardhana Reddy
09905b641b bug 10617: merge code from branch bug10617. 2011-12-01 14:17:52 +05:30
Naredula Janardhana Reddy
f1b99f4f07 Revert "bug 10617: merging code from branch bug10617"
This reverts commit 8bc33448b9220534ba0ddc6c642ffb1e69d5844e.

Conflicts:

	server/src/com/cloud/api/ApiResponseHelper.java
2011-11-11 20:23:26 +05:30
Naredula Janardhana Reddy
02adbd4bd3 bug 10617: merging code from branch bug10617 2011-11-10 15:23:48 +05:30
Chiradeep Vittal
d817f3c364 Revert "bug 10617: Added Egress rules to Security groups."
revert pending review

This reverts commit a19212703b9734ebd44ebf55cfdd81ebdc9d7fe4.
2011-09-12 14:45:58 -07:00
Chiradeep Vittal
53970c89dc Revert "bug 10617: blocking between security groups for egress rules fixed."
revert pending review

This reverts commit 7d30dfd79e3c4b01492f606333c26e36bcdc5d13.
2011-09-12 14:45:58 -07:00
Chiradeep Vittal
e216686029 Revert "bug 10617: Intermediate checking"
revert pending review

This reverts commit 561b27565512d438db3d8896df6f97b644b0b498.
2011-09-12 14:45:58 -07:00
Naredula Janardhana Reddy
f9b0962ad9 bug 10617: Intermediate checking
Changes :
         - Fixing API doc +response name + errorMessage
         - Adding seperate events to Egress rules
         - Egress rules Using the same database table as that of ingress with new column type.

   Pending Tasks:
         - db upgrade
         - database table rename from security_ingress_rule to generic name, renaming some of the jave class from ingress to generic name.
         - Retesting on kvm
2011-09-09 18:14:19 +05:30
Naredula Janardhana Reddy
10d2ca8d0a bug 10617: blocking between security groups for egress rules fixed. 2011-09-02 16:17:08 +05:30
Naredula Janardhana Reddy
854f81962f bug 10617: Added Egress rules to Security groups.
Description :
   API's:
     -  Two new api's authorizeSecurityGroupEgress,revokeSecurityGroupEgressCmd are added. These two API's are similer to ingress rule API's.
           - authorizeSecurityGroupEgress :Authorizes a particular egress rule for this security group . Usageof API is very similer to that of authorizeSecurityGroupIngress except that instead of source cidr  there will be destination cidr. By default like ingress, all the outgoing flows are blocked.
           - revokeSecurityGroupEgress : It is similer to revokeSecurityGroupIngress api, It removes the egress rule.
     -  listSecurityGroup API's response changed. It include's egress list apart from the existing ingress rules in the output of the API.

   Hypervisors :
      - It is implemented in Xen and KVM.

   Pending Tasks :  Blocking using destination security groups.

   Previous commits: c9fda641673df7701f44963ef27e1d488f121219 , 24e4e44b8f0712a37147a3777833de3f9e24829e
2011-08-30 16:28:35 +05:30
Edison Su
c3174664de after vm reboot, change the security group if needed 2011-07-29 15:28:16 -07:00
Edison Su
5724a016c6 fix security group clean up on centos 5 2011-07-26 16:57:49 -07:00
Edison Su
1e944a2d86 cleanup ebtables rules if vm is manually deleted 2011-06-20 10:32:05 -04:00