Skip to content

Commit a418da8

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Use the system-dependent string for IP protocol 4" into stable/zed
2 parents 49ba6c2 + 386ebde commit a418da8

File tree

2 files changed

+25
-15
lines changed

2 files changed

+25
-15
lines changed

neutron/agent/linux/iptables_firewall.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -775,10 +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-
# TODO(haleyb): remove once neutron-lib with fix is available
779-
# - 'ipip' uses 'ipencap' to match IPPROTO_IPIP from in.h,
780-
# which is IP-ENCAP/'4' in /etc/protocols (see bug #2054324)
781-
tmp_map[constants.PROTO_NAME_IPIP] = 'ipencap'
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']
782786
self._iptables_protocol_name_map = tmp_map
783787
return self._iptables_protocol_name_map
784788

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

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -490,37 +490,43 @@ def test_filter_ipv4_ingress_protocol_encap_by_num(self):
490490
self._test_prepare_port_filter(rule, ingress, egress)
491491

492492
def test_filter_ipv4_ingress_protocol_ipip(self):
493-
# 'ipip' via the API uses 'ipencap' to match what iptables-save
494-
# uses, which is IP-ENCAP/'4' from /etc/protocols (see bug #2054324)
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.
495496
rule = {'ethertype': 'IPv4',
496497
'direction': 'ingress',
497498
'protocol': 'ipip'}
499+
expected_proto_name = self.firewall._iptables_protocol_name('ipip')
498500
ingress = mock.call.add_rule('ifake_dev',
499-
'-p ipencap -j RETURN',
501+
'-p %s -j RETURN' % expected_proto_name,
500502
top=False, comment=None)
501503
egress = None
502504
self._test_prepare_port_filter(rule, ingress, egress)
503505

504-
def test_filter_ipv4_ingress_protocol_ipip_by_num(self):
505-
# '4' via the API uses 'ipencap' to match what iptables-save
506-
# uses, which is IP-ENCAP/'4' from /etc/protocols (see bug #2054324)
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.
507510
rule = {'ethertype': 'IPv4',
508511
'direction': 'ingress',
509512
'protocol': '4'}
513+
expected_proto_name = self.firewall._iptables_protocol_name('4')
510514
ingress = mock.call.add_rule('ifake_dev',
511-
'-p ipencap -j RETURN',
515+
'-p %s -j RETURN' % expected_proto_name,
512516
top=False, comment=None)
513517
egress = None
514518
self._test_prepare_port_filter(rule, ingress, egress)
515519

516-
def test_filter_ipv4_ingress_protocol_ipencap_by_num(self):
517-
# '94' via the API uses 'ipip' to match what iptables-save
518-
# uses, which is IPIP/'94' from /etc/protocols (see bug #2054324)
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.
519524
rule = {'ethertype': 'IPv4',
520525
'direction': 'ingress',
521526
'protocol': '94'}
527+
expected_proto_name = self.firewall._iptables_protocol_name('94')
522528
ingress = mock.call.add_rule('ifake_dev',
523-
'-p ipip -j RETURN',
529+
'-p %s -j RETURN' % expected_proto_name,
524530
top=False, comment=None)
525531
egress = None
526532
self._test_prepare_port_filter(rule, ingress, egress)

0 commit comments

Comments
 (0)