Only have one number to name mapping for IPv6 ICMP

Neutron normalized the IPv6 ICMP protocol string to 'ipv6-icmp',
but the number to name mapping dict incorrectly shows 'icmpv6':

>>> constants.IP_PROTOCOL_NUM_TO_NAME_MAP['58']
'icmpv6'

This is because in the name to number mapping dict there are
two keys, 'ipv6-icmp' and 'icmpv6', that have a value of 58
in order to keep backwards-compatibility. Since the number
to name mapping is built automatically from that, it overwrites
the '58' key value to be 'icmpv6'. Filter it out so there is
only a single mapping to 'ipv6-icmp'.

Change-Id: I6b6c34c13f006ffca4cb4e2f18a2f825764374ec
Related-bug: #1582500
This commit is contained in:
Brian Haley 2019-07-15 15:35:47 -04:00
parent 7778e3118b
commit 1376d2e807

View File

@ -429,7 +429,10 @@ ETHERTYPE_IPV6 = 0x86DD
IP_PROTOCOL_NAME_ALIASES = {PROTO_NAME_IPV6_ICMP_LEGACY:
PROTO_NAME_IPV6_ICMP}
IP_PROTOCOL_NUM_TO_NAME_MAP = {str(v): k for k, v in IP_PROTOCOL_MAP.items()}
# We only want one mapping from '58' to 'ipv6-icmp' since that is the
# normalized string, the name to number mapping can have both
IP_PROTOCOL_NUM_TO_NAME_MAP = ({str(v): k for k, v in IP_PROTOCOL_MAP.items()
if k != PROTO_NAME_IPV6_ICMP_LEGACY})
# When using iptables-save we specify '-p {proto}',
# but sometimes those values are not identical. This is a map