Merge "Extend vxlan_group option to allow a range of group addresses"
This commit is contained in:
commit
0ce542ff00
@ -21,8 +21,12 @@
|
|||||||
# (IntOpt) use specific TOS for vxlan interface protocol packets
|
# (IntOpt) use specific TOS for vxlan interface protocol packets
|
||||||
# tos =
|
# tos =
|
||||||
#
|
#
|
||||||
# (StrOpt) multicast group to use for broadcast emulation.
|
# (StrOpt) multicast group or group range to use for broadcast emulation.
|
||||||
# This group must be the same on all the agents.
|
# Specifying a range allows different VNIs to use different group addresses,
|
||||||
|
# reducing or eliminating spurious broadcast traffic to the tunnel endpoints.
|
||||||
|
# Ranges are specified by using CIDR notation. To reserve a unique group for
|
||||||
|
# each possible (24-bit) VNI, use a /8 such as 239.0.0.0/8.
|
||||||
|
# This setting must be the same on all the agents.
|
||||||
# vxlan_group = 224.0.0.1
|
# vxlan_group = 224.0.0.1
|
||||||
#
|
#
|
||||||
# (StrOpt) Local IP address to use for VXLAN endpoints (required)
|
# (StrOpt) Local IP address to use for VXLAN endpoints (required)
|
||||||
|
@ -30,7 +30,11 @@ vxlan_opts = [
|
|||||||
cfg.IntOpt('tos',
|
cfg.IntOpt('tos',
|
||||||
help=_("TOS for vxlan interface protocol packets.")),
|
help=_("TOS for vxlan interface protocol packets.")),
|
||||||
cfg.StrOpt('vxlan_group', default=DEFAULT_VXLAN_GROUP,
|
cfg.StrOpt('vxlan_group', default=DEFAULT_VXLAN_GROUP,
|
||||||
help=_("Multicast group for vxlan interface.")),
|
help=_("Multicast group(s) for vxlan interface. A range of "
|
||||||
|
"group addresses may be specified by using CIDR "
|
||||||
|
"notation. To reserve a unique group for each possible "
|
||||||
|
"(24-bit) VNI, use a /8 such as 239.0.0.0/8. This "
|
||||||
|
"setting must be the same on all the agents.")),
|
||||||
cfg.IPOpt('local_ip', version=4,
|
cfg.IPOpt('local_ip', version=4,
|
||||||
help=_("Local IP address of the VXLAN endpoints.")),
|
help=_("Local IP address of the VXLAN endpoints.")),
|
||||||
cfg.BoolOpt('l2_population', default=False,
|
cfg.BoolOpt('l2_population', default=False,
|
||||||
|
@ -26,6 +26,7 @@ import time
|
|||||||
import eventlet
|
import eventlet
|
||||||
eventlet.monkey_patch()
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
|
import netaddr
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
import oslo_messaging
|
import oslo_messaging
|
||||||
@ -128,6 +129,22 @@ class LinuxBridgeManager(object):
|
|||||||
LOG.warning(_LW("Invalid Segmentation ID: %s, will lead to "
|
LOG.warning(_LW("Invalid Segmentation ID: %s, will lead to "
|
||||||
"incorrect vxlan device name"), segmentation_id)
|
"incorrect vxlan device name"), segmentation_id)
|
||||||
|
|
||||||
|
def get_vxlan_group(self, segmentation_id):
|
||||||
|
try:
|
||||||
|
# Ensure the configured group address/range is valid and multicast
|
||||||
|
net = netaddr.IPNetwork(cfg.CONF.VXLAN.vxlan_group)
|
||||||
|
if not (net.network.is_multicast() and
|
||||||
|
net.broadcast.is_multicast()):
|
||||||
|
raise ValueError()
|
||||||
|
# Map the segmentation ID to (one of) the group address(es)
|
||||||
|
return str(net.network +
|
||||||
|
(int(segmentation_id) & int(net.hostmask)))
|
||||||
|
except (netaddr.core.AddrFormatError, ValueError):
|
||||||
|
LOG.warning(_LW("Invalid VXLAN Group: %s, must be an address "
|
||||||
|
"or network (in CIDR notation) in a multicast "
|
||||||
|
"range"),
|
||||||
|
cfg.CONF.VXLAN.vxlan_group)
|
||||||
|
|
||||||
def get_all_neutron_bridges(self):
|
def get_all_neutron_bridges(self):
|
||||||
neutron_bridge_list = []
|
neutron_bridge_list = []
|
||||||
bridge_list = os.listdir(BRIDGE_FS)
|
bridge_list = os.listdir(BRIDGE_FS)
|
||||||
@ -241,7 +258,7 @@ class LinuxBridgeManager(object):
|
|||||||
'segmentation_id': segmentation_id})
|
'segmentation_id': segmentation_id})
|
||||||
args = {'dev': self.local_int}
|
args = {'dev': self.local_int}
|
||||||
if self.vxlan_mode == lconst.VXLAN_MCAST:
|
if self.vxlan_mode == lconst.VXLAN_MCAST:
|
||||||
args['group'] = cfg.CONF.VXLAN.vxlan_group
|
args['group'] = self.get_vxlan_group(segmentation_id)
|
||||||
if cfg.CONF.VXLAN.ttl:
|
if cfg.CONF.VXLAN.ttl:
|
||||||
args['ttl'] = cfg.CONF.VXLAN.ttl
|
args['ttl'] = cfg.CONF.VXLAN.ttl
|
||||||
if cfg.CONF.VXLAN.tos:
|
if cfg.CONF.VXLAN.tos:
|
||||||
@ -547,7 +564,7 @@ class LinuxBridgeManager(object):
|
|||||||
|
|
||||||
def vxlan_mcast_supported(self):
|
def vxlan_mcast_supported(self):
|
||||||
if not cfg.CONF.VXLAN.vxlan_group:
|
if not cfg.CONF.VXLAN.vxlan_group:
|
||||||
LOG.warning(_LW('VXLAN muticast group must be provided in '
|
LOG.warning(_LW('VXLAN muticast group(s) must be provided in '
|
||||||
'vxlan_group option to enable VXLAN MCAST mode'))
|
'vxlan_group option to enable VXLAN MCAST mode'))
|
||||||
return False
|
return False
|
||||||
if not ip_lib.iproute_arg_supported(
|
if not ip_lib.iproute_arg_supported(
|
||||||
|
@ -397,6 +397,19 @@ class TestLinuxBridgeManager(base.BaseTestCase):
|
|||||||
"vxlan-" + str(vn_id))
|
"vxlan-" + str(vn_id))
|
||||||
self.assertIsNone(self.lbm.get_vxlan_device_name(vn_id + 1))
|
self.assertIsNone(self.lbm.get_vxlan_device_name(vn_id + 1))
|
||||||
|
|
||||||
|
def test_get_vxlan_group(self):
|
||||||
|
cfg.CONF.set_override('vxlan_group', '239.1.2.3/24', 'VXLAN')
|
||||||
|
vn_id = p_const.MAX_VXLAN_VNI
|
||||||
|
self.assertEqual('239.1.2.255', self.lbm.get_vxlan_group(vn_id))
|
||||||
|
vn_id = 256
|
||||||
|
self.assertEqual('239.1.2.0', self.lbm.get_vxlan_group(vn_id))
|
||||||
|
vn_id = 257
|
||||||
|
self.assertEqual('239.1.2.1', self.lbm.get_vxlan_group(vn_id))
|
||||||
|
cfg.CONF.set_override('vxlan_group', '240.0.0.0', 'VXLAN')
|
||||||
|
self.assertIsNone(self.lbm.get_vxlan_group(vn_id))
|
||||||
|
cfg.CONF.set_override('vxlan_group', '224.0.0.1/', 'VXLAN')
|
||||||
|
self.assertIsNone(self.lbm.get_vxlan_group(vn_id))
|
||||||
|
|
||||||
def test_get_all_neutron_bridges(self):
|
def test_get_all_neutron_bridges(self):
|
||||||
br_list = ["br-int", "brq1", "brq2", "br-ex"]
|
br_list = ["br-int", "brq1", "brq2", "br-ex"]
|
||||||
with mock.patch.object(os, 'listdir') as listdir_fn:
|
with mock.patch.object(os, 'listdir') as listdir_fn:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user