diff options
Diffstat (limited to 'neutron/agent/linux/ipset_manager.py')
-rw-r--r-- | neutron/agent/linux/ipset_manager.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/neutron/agent/linux/ipset_manager.py b/neutron/agent/linux/ipset_manager.py index e5ab7a01e9..33b6379b58 100644 --- a/neutron/agent/linux/ipset_manager.py +++ b/neutron/agent/linux/ipset_manager.py @@ -11,6 +11,9 @@ # See the License for the specific language governing permissions and # limitations under the License. +from oslo_config import cfg + +from neutron.agent.common import config from neutron.agent.linux import utils as linux_utils from neutron.common import utils @@ -29,6 +32,7 @@ class IpsetManager(object): def __init__(self, execute=None, namespace=None): self.execute = execute or linux_utils.execute self.namespace = namespace + config.register_ipset_opts(cfg.CONF) self.ipset_sets = {} @staticmethod @@ -39,6 +43,15 @@ class IpsetManager(object): name = ethertype + id return name[:IPSET_NAME_MAX_LENGTH] + @staticmethod + def get_hashargs(): + args = [] + if cfg.CONF.AGENT.ipset_hashsize: + args.extend(['hashsize', str(cfg.CONF.AGENT.ipset_hashsize)]) + if cfg.CONF.AGENT.ipset_maxelem: + args.extend(['maxelem', str(cfg.CONF.AGENT.ipset_maxelem)]) + return args + def set_exists(self, id, ethertype): """Returns true if the id+ethertype pair is known to the manager.""" set_name = self.get_name(id, ethertype) @@ -85,8 +98,10 @@ class IpsetManager(object): def _refresh_set(self, set_name, member_ips, ethertype): new_set_name = set_name + SWAP_SUFFIX set_type = self._get_ipset_set_type(ethertype) - process_input = ["create %s hash:ip family %s" % (new_set_name, - set_type)] + hash_args = ' '.join(self.get_hashargs()) + process_input = ["create %s hash:ip family %s %s" % (new_set_name, + set_type, + hash_args)] for ip in member_ips: process_input.append("add %s %s" % (new_set_name, ip)) @@ -103,6 +118,7 @@ class IpsetManager(object): def _create_set(self, set_name, ethertype): cmd = ['ipset', 'create', '-exist', set_name, 'hash:ip', 'family', self._get_ipset_set_type(ethertype)] + cmd.extend(self.get_hashargs()) self._apply(cmd) self.ipset_sets[set_name] = [] |