Skip to content

Commit 9170c75

Browse files
authored
Merge pull request #141 from stackhpc/upstream/2023.1-2024-04-29
Synchronise 2023.1 with upstream
2 parents 7450a50 + d3303c1 commit 9170c75

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

neutron/agent/linux/iptables_firewall.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,14 @@ def _protocol_name_map(self):
775775
if not self._iptables_protocol_name_map:
776776
tmp_map = constants.IPTABLES_PROTOCOL_NAME_MAP.copy()
777777
tmp_map.update(self._local_protocol_name_map())
778+
# iptables-save uses different strings for 'ipip' (protocol 4)
779+
# depending on the distro, which corresponds to the entry for
780+
# '4' in /etc/protocols. For example:
781+
# - 'ipencap' in Ubuntu
782+
# - 'ipv4' in CentOS/Fedora
783+
# For this reason, we need to map the string for 'ipip' to the
784+
# system-dependent string for '4', see bug #2054324.
785+
tmp_map[constants.PROTO_NAME_IPIP] = tmp_map['4']
778786
self._iptables_protocol_name_map = tmp_map
779787
return self._iptables_protocol_name_map
780788

neutron/tests/unit/agent/linux/test_iptables_firewall.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,48 @@ def test_filter_ipv4_ingress_protocol_encap_by_num(self):
489489
egress = None
490490
self._test_prepare_port_filter(rule, ingress, egress)
491491

492+
def test_filter_ipv4_ingress_protocol_ipip(self):
493+
# We want to use what the system-dependent string here is for 'ipip',
494+
# as it could be 'ipencap' or 'ipv4' depending on the distro.
495+
# See bug #2054324.
496+
rule = {'ethertype': 'IPv4',
497+
'direction': 'ingress',
498+
'protocol': 'ipip'}
499+
expected_proto_name = self.firewall._iptables_protocol_name('ipip')
500+
ingress = mock.call.add_rule('ifake_dev',
501+
'-p %s -j RETURN' % expected_proto_name,
502+
top=False, comment=None)
503+
egress = None
504+
self._test_prepare_port_filter(rule, ingress, egress)
505+
506+
def test_filter_ipv4_ingress_protocol_4(self):
507+
# We want to use what the system-dependent string here is for '4',
508+
# as it could be 'ipencap' or 'ipv4' depending on the distro.
509+
# See bug #2054324.
510+
rule = {'ethertype': 'IPv4',
511+
'direction': 'ingress',
512+
'protocol': '4'}
513+
expected_proto_name = self.firewall._iptables_protocol_name('4')
514+
ingress = mock.call.add_rule('ifake_dev',
515+
'-p %s -j RETURN' % expected_proto_name,
516+
top=False, comment=None)
517+
egress = None
518+
self._test_prepare_port_filter(rule, ingress, egress)
519+
520+
def test_filter_ipv4_ingress_protocol_94(self):
521+
# We want to use what the system-dependent string here is for '94',
522+
# as it could be 'ipip' or something else depending on the distro.
523+
# See bug #2054324.
524+
rule = {'ethertype': 'IPv4',
525+
'direction': 'ingress',
526+
'protocol': '94'}
527+
expected_proto_name = self.firewall._iptables_protocol_name('94')
528+
ingress = mock.call.add_rule('ifake_dev',
529+
'-p %s -j RETURN' % expected_proto_name,
530+
top=False, comment=None)
531+
egress = None
532+
self._test_prepare_port_filter(rule, ingress, egress)
533+
492534
def test_filter_ipv4_ingress_protocol_999_local(self):
493535
# There is no protocol 999, so let's return a mapping
494536
# that says there is and make sure the rule is created

0 commit comments

Comments
 (0)