154 Commits

Author SHA1 Message Date
Wido den Hollander
990e4a6e40 ipv6: Allow all ICMPv6 traffic if -1 is provided as a ICMP type
ip6tables no longer takes '--icmpv6-type any' as a argument.

To allow all ICMPv6 traffic with ip6tables it has to be invoked this way:

  $ ip6tables -I i-2-14-VM -p icmpv6 -s ::/0 -j ACCEPT

All ICMPv6 traffic is now allow into the Instance.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
2017-07-25 16:31:35 +02:00
Jayapal
1cff18fcfa CLOUDSTACK-9657: Fixed security group ipset issues with long vm name 2017-02-24 15:20:04 +05:30
Wido den Hollander
115d6d5dc7
CLOUDSTACK-676: IPv6 In -and Egress filtering for Basic Networking
This commit implements Ingress and Egress filtering for IPv6 in
Basic Networking.

It allows for opening and closing ports just as can be done with IPv4.

Rules have to be specified twice, once for IPv4 and once for IPv6, for
example:

- 22 until 22: 0.0.0.0/0
- 22 until 22: ::/0

Egress filtering works the same as with IPv4. When no rule is applied all
traffic is allowed. Otherwise only the specified traffic (with DNS being
the exception) is allowed.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
2017-01-26 15:36:20 +01:00
Wido den Hollander
84e496b4f9
CLOUDSTACK-676: IPv6 Basic Security Grouping for KVM
This commit implements basic Security Grouping for KVM in
Basic Networking.

It does not implement full Security Grouping yet, but it does:
- Prevent IP-Address source spoofing
- Allow DHCPv6 clients, but disallow DHCPv6 servers
- Disallow Instances to send out Router Advertisements

The Security Grouping allows ICMPv6 packets as described by RFC4890
as they are essential for IPv6 connectivity.

Following RFC4890 it allows:
- Router Solicitations
- Router Advertisements (incoming only)
- Neighbor Advertisements
- Neighbor Solicitations
- Packet Too Big
- Time Exceeded
- Destination Unreachable
- Parameter Problem
- Echo Request

ICMPv6 is a essential part of IPv6, without it connectivity will break or be very
unreliable.

For now it allows any UDP and TCP packet to be send in to the Instance which
effectively opens up the firewall completely.

Future commits will implement Security Grouping further which allows controlling UDP and TCP
ports for IPv6 like can be done with IPv4.

Regardless of the egress filtering (which can't be done yet) it will always allow outbound DNS
to port 53 over UDP or TCP.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
2017-01-26 15:36:08 +01:00
Wido den Hollander
8ea75f1a85
CLOUDSTACK-9552: Allow egress TCP/53 implicitly in Basic Networking
Allow DNS queries over TCP when egress filtering is configured.

When using DNSSEC more and more queries are done over TCP and this
requires 53/TCP to be allowed.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
2016-10-31 09:57:25 +01:00
Wido den Hollander
26becef722
kvm: Aqcuire lock when running security group Python script
It could happen that when multiple instances are starting at the same
time on a KVM host the Agent spawns multiple instances of security_group.py
which both try to modify iptables/ebtables rules.

This fails with on of the two processes failing.

The instance is still started, but it doesn't have any IP connectivity due
to the failed programming of the security groups.

This modification lets the script aqcuire a exclusive lock on a file so that
only one instance of the scripts talks to iptables/ebtables at once.

Other instances of the script which start will poll every 500ms if they can
obtain the lock and otherwise execute anyway after 15 seconds.

The lock will be released as soon as the script exists, which is usually within
a few hundred ms.
2016-04-28 10:16:11 +02:00
Wido den Hollander
239148c31b CLOUDSTACK-9210: Pass secondary IPs to default_network_rules() function
This is a mandatory argument but it was NOT passed which caused the
re-programming of security groups to fail.

Simple fix to just add the argument since the variable is available
there.
2016-01-05 18:06:34 +01:00
Vincent Bernat
f2b8f2eade sysctl: don't modify /etc/sysctl.conf
To configure firewall rules, CloudStack modifies `/etc/sysctl.conf` and
execute those modifications. This may be harmful for several reasons:

 1. `/etc/sysctl.conf` may be managed by some configuration management
    system. Such a system will constantly restore the previous version.

 2. `/etc/sysctl.conf` may contain additional properties that have been
    changed later by some system administrator (for example, once a
    firewall has been configured, forwarding may have been activated
    while it is disabled in `/etc/sysctl.conf`). Executing the file
    again at a later time may disrupt the system.

 3. Entries are added again and again. `/etc/sysctl.conf` will contain
    the same directives repeated several times.

Using a configuration file is not needed as `sysctl` is able to directly
modify sysctl values with `-w` flag.

Signed-off-by: Vincent Bernat <Vincent.Bernat@exoscale.ch>
2015-09-04 14:31:09 +02:00
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
274222769a CLOUDSTACK-8252: Ignore VLAN 4095 which is n/a on linux
VLAN id 4095 is commonly used as a 'tag passthrough' in virtualization environments
(VMware, specifically). This vlan id is incompatible with Linux, but we can
allow the admin to manually configure the bridge if the same passthrough is
desired.

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
(cherry picked from commit aee35c96a8157e36b1237dc537bb5b01e1657d61)
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-05-22 13:26:06 +01: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
Star Guo
8ed833a13b scripts: add ip set interface up because in CentOS7 the interface will not auto up
This closes #97

Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
2015-03-10 10:19:04 +05:30
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
Kishan Kavala
b37ee25359 replace vconfig with ip link 2014-08-22 15:39:04 +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
Murali Reddy
771abe4286 fix KVM plug-in for OVS tunnel network. Fix addreses two issues.
fix  mismatch of ovs-host-setup, ovs_host_setup used Libvirt resource and
scripts

plug the nic to OVS bridges created for the tunnel network.

Conflicts:
	plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/OvsVifDriver.java
2014-04-25 15:02:17 +05:30
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
Murali Reddy
36541a2f4c adding distributed routing support for KVM OVS
some check style error fixes
2014-03-14 16:56:38 +05:30
jayapal
86124138a1 CLOUDSTACK-5924: Correcting regex to get vm names exactly from ebtables chains 2014-01-22 11:20:27 +05:30
tuna
a3b7248a16 enable stp on ovstunnel 2013-12-11 15:58:32 +07:00
tuna
c7dab82dc4 move cloudstack_pluginlib 2013-12-09 23:33:15 +07:00
tuna
3df8b912fc add kvm support & LB service 2013-12-09 23:33:14 +07:00
Marcus Sorensen
4a9f05bda0 CLOUDSTACK-4967
1) vxlan will use bridge scheme 'brvx-<vni>'. Multiple physical networks can host guest
traffic type with vxlan isolation, so long as they don't use the same VNI range.

2) Guest traffic labels can be physical interface if bridge by given name is not found.
Normally we take traffic label name, find the matching bridge, then resolve that to a
physical interface. Then we create guest bridges on that interface. Now we can just
specify the interface.
2013-10-29 15:34:39 -06:00
Toshiaki Hatano
3e70b145c4 CLOUDSTACK-4967: vxlan doesn't scale
- Fix inproper multicast address creation (when VNI > 65535)
- Fix missing bride name in delete oparation

Signed-off-by : Toshiaki Hatano <haeena@haeena.net>
2013-10-29 02:38:02 +09:00
ynojima
a45ee749ac CLOUDSTACK-2328: Linux native VXLAN support on KVM hypervisor
Initial patch for VXLAN support.
Fully functional, hopefully, for GuestNetwork - AdvancedZone.

Patch Note:
 in cloudstack-server
- Add isolation method VXLAN
- Add VxlanGuestNetworkGuru as plugin for VXLAN isolation
- Modify NetworkServiceImpl to handle extended vNet range for VXLAN isolation
- Add VXLAN isolation option in zoneWizard UI

 in cloudstack-agent (kvm)
- Add modifyvxlan.sh script that handle bridge/vxlan interface manipulation script
-- Usage is exactly same to modifyvlan.sh
- BridgeVifDriver will call modifyvxlan.sh instead of modifyvlan.sh when VXLAN is used for isolation

Database changes:
- No change in database structure.
- VXLAN isolation uses same tables that VLAN uses to store vNet allocation status.

Known Issue and/or TODO:
- Some resource still says 'VLAN' in log even if VXLAN is used
- in UI, "Network - GuestNetworks" dosen't display VNI
-- VLAN ID field displays "N/A"
- Documentation!

Signed-off-by : Toshiaki Hatano <haeena@haeena.net>
2013-09-26 23:37:18 +09:00
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
Toshiaki Hatano
914e7c4542 Revert "CLOUDSTACK-2328: Linux native VXLAN support on KVM hypervisor"
This reverts commit 34ae32e0c24777f9ac9cf265447688a3e21680c7.
2013-08-24 07:12:23 +00:00
Toshiaki Hatano
34ae32e0c2 CLOUDSTACK-2328: Linux native VXLAN support on KVM hypervisor
Initial patch for VXLAN support.
Fully functional, hopefully, for GuestNetwork - AdvancedZone.

Patch Note:
 in cloudstack-server
- Add isolation method VXLAN
- Add VxlanGuestNetworkGuru as plugin for VXLAN isolation
- Modify NetworkServiceImpl to handle extended vNet range for VXLAN isolation
- Add VXLAN isolation option in zoneWizard UI

 in cloudstack-agent (kvm)
- Add modifyvxlan.sh script that handle bridge/vxlan interface manipulation script
-- Usage is exactly same to modifyvlan.sh
- BridgeVifDriver will call modifyvxlan.sh instead of modifyvlan.sh when VXLAN is used for isolation

Database changes:
- No change in database structure.
- VXLAN isolation uses same tables that VLAN uses to store vNet allocation status.

Known Issue:
- Some resource still says 'VLAN' in log even if VXLAN is used
- in UI, "Network - GuestNetworks" dosen't display VNI
-- VLAN ID field displays "N/A"
2013-08-24 01:39:11 +00: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
Sheng Yang
4c1ace5e02 CLOUDSTACK-2775: Fix trunk port is not 1 on some hosts
Now searching for eth- or em- prefix, as the port for going outside.
2013-06-04 11:32:23 -07:00
Sheng Yang
0c7bd0777b PVLAN: Optimize pvlan scripts 2013-05-06 17:51:33 -07:00
Sheng Yang
3c3d67769b PVLAN: PvlanSetupCommand for KVM support 2013-05-01 13:23:09 -07:00
Sheng Yang
05885457ec PVLAN: Simplify OVS policy
We can resubmit the packet against the flow table to get simplier result.

Now we don't need to check if VM is in the same host as DHCP server or not.
2013-05-01 13:23:08 -07:00
Sheng Yang
b64039bafd Implement PVLAN on Xen
Start/stop vm/dhcp server are done. Not done with VM migration.

A new command(PvlanSetupCommand) is sent for setting up PVLAN for vms. Currently
it's focus on OVS implementation. Need to be more abstruct and add vSwitch part.
2013-05-01 13:23:08 -07: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