1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

F #2161 Support 2 modes for vxlan multicast and EVPN

Co-authored-by: Jan Orel <jorel@opennebula.systems>
(cherry picked from commit 107f86b556f8cbb394dddca1f7af71a7cdb96b27)
This commit is contained in:
Ruben S. Montero 2018-10-31 11:59:12 +01:00
parent 610ce4dcbb
commit 4774916ae9
2 changed files with 49 additions and 10 deletions

View File

@ -51,6 +51,10 @@
# VXLAN Options
################################################################################
# Multicast protocol for multi destination BUM traffic. Options:
# - multicast, for IP multicast
# - evpn, for BGP EVPN control plane
:vxlan_mode: multicast
# Base multicast address for each VLAN. The mc address is :vxlan_mc + :vlan_id
:vxlan_mc: 239.0.0.0
# Time To Live (TTL) should be > 1 in routed multicast networks (IGMP)
@ -58,6 +62,16 @@
# Default MTU for the VXLAN interface
:vxlan_mtu: 1500
# Tunnel endpoint communication type. Only for evpn vxlan_mode.
# - dev, tunnel endpoint communication is sent to PHYDEV
# - local_ip, first ip addr of PHYDEV is used as address for the communication
:vxlan_tep: dev
# Additional ip link options, uncomment the following to disable learning for
# EVPN mode
# :ip_link_conf:
# :nolearning:
################################################################################
# Security Group Options
################################################################################
@ -98,4 +112,3 @@
# :ip_link_conf:
# :udp6zerocsumrx:
# :tos: 3

View File

@ -24,14 +24,30 @@ module VXLAN
# This function creates and activate a VLAN device
############################################################################
def create_vlan_dev
begin
ipaddr = IPAddr.new @nic[:conf][:vxlan_mc]
rescue
ipaddr = IPAddr.new "239.0.0.0"
end
vxlan_mode = @nic[:conf][:vxlan_mode] || 'multicast'
group = ""
mc = ipaddr.to_i + @nic[@attr_vlan_id].to_i
mcs = IPAddr.new(mc, Socket::AF_INET).to_s
if vxlan_mode.downcase == 'evpn'
vxlan_tep = @nic[:conf][:vxlan_tep] || 'dev'
if vxlan_tep.downcase == 'dev'
tep = "dev #{@nic[:phydev]}"
else
tep = "local #{get_interface_first_ip(@nic[:phydev])}"
end
else
begin
ipaddr = IPAddr.new @nic[:conf][:vxlan_mc]
rescue
ipaddr = IPAddr.new "239.0.0.0"
end
mc = ipaddr.to_i + @nic[@attr_vlan_id].to_i
mcs = IPAddr.new(mc, Socket::AF_INET).to_s
group = "group #{mcs}"
tep = "dev #{@nic[:phydev]}"
end
mtu = @nic[:mtu] ? "mtu #{@nic[:mtu]}" : "mtu #{@nic[:conf][:vxlan_mtu]}"
ttl = @nic[:conf][:vxlan_ttl] ? "ttl #{@nic[:conf][:vxlan_ttl]}" : ""
@ -50,8 +66,8 @@ module VXLAN
end
OpenNebula.exec_and_log("#{command(:ip)} link add #{@nic[@attr_vlan_dev]}"\
" #{mtu} type vxlan id #{@nic[@attr_vlan_id]} group #{mcs} #{ttl}"\
" dev #{@nic[:phydev]} #{ip_link_conf}")
" #{mtu} type vxlan id #{@nic[@attr_vlan_id]} #{group} #{ttl}"\
" #{tep} #{ip_link_conf}")
OpenNebula.exec_and_log("#{command(:ip)} link set #{@nic[@attr_vlan_dev]} up")
end
@ -72,4 +88,14 @@ module VXLAN
nil
end
def get_interface_first_ip(name)
text = %x(#{command(:ip)} addr show dev #{name})
return nil if $?.exitstatus != 0
text.each_line do |line|
m = line.match(/^\s*inet6? ([a-f:\d\.]+)/i)
return m[1] if m
end
end
end