Skip to content

Commit

Permalink
B OpenNebula#3354: add NIC aliases to the IP spoofing filter
Browse files Browse the repository at this point in the history
- src/vnm_mad/remotes/lib/vm.rb:
   add array of NIC aliases to the nic Array

- src/vnm_mad/remotes/lib/security_groups_iptables.rb:
   update ipv4s(and ipv6s) with the alias ips

Signed-off-by: Anton Todorov <a.todorov@storpool.com>
  • Loading branch information
atodorov-storpool committed May 19, 2019
1 parent e178b5c commit 3e87f3f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/vnm_mad/remotes/lib/security_groups_iptables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,14 @@ def self.nic_pre(vm, nic)
ipv4s << nic[key] if !nic[key].nil? && !nic[key].empty?
end

if !nic[:aliases].nil? && !nic[:aliases].empty?
nic[:aliases].each do |nicalias|
[:ip, :vrouter_ip].each do |key|
ipv4s << nicalias[key] if !nicalias[key].nil? && !nicalias[key].empty?
end
end
end

if !ipv4s.empty?
#bootp
commands.add :iptables, "-A #{chain_out} -p udp "\
Expand Down Expand Up @@ -456,6 +464,14 @@ def self.nic_pre(vm, nic)
ipv6s << nic[key] if !nic[key].nil? && !nic[key].empty?
end

if !nic[:aliases].nil? && !nic[:aliases].empty?
nic[:aliases].each do |nicalias|
[:ip6, :ip6_global, :ip6_link, :ip6_ula].each do |key|
ipv6s << nicalias[key] if !nicalias[key].nil? && !nicalias[key].empty?
end
end
end

if !ipv6s.empty?
set = "#{vars[:chain]}-ip6-spoofing"

Expand Down
9 changes: 9 additions & 0 deletions src/vnm_mad/remotes/lib/vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ def initialize(vm_root, xpath_filter, deploy_id)
nic.get_tap(self)
end

if !nic[:alias_ids].nil?
nic[:aliases] = []
@vm_root.elements.each("TEMPLATE/NIC_ALIAS[PARENT_ID=\"#{nic[:nic_id]}\"]") do |nicalias_element|
nicalias = nics.new_nic
nic_build_hash(nicalias_element, nicalias)
nic[:aliases] << nicalias
end
end

nics << nic
end

Expand Down

0 comments on commit 3e87f3f

Please sign in to comment.