neutron/neutron/agent/linux
Brian Haley 44c113651b Fix iptables mapping of 'ipip' protocol
Map 'ipip' to use the string 'ipencap' so the
IptablesFirewallDriver class in neutron works correctly.
Once neutron-lib is bumped this can be removed.

Add tests for IP protocol 'ipip', '4' and '94' to make
sure the IptablesFirewallDriver class in neutron treats
them correctly.

Long description below.

This is one of those confusing edge cases and I think
Linux is conspiring against us. Let me explain.

1) neutron-lib does correctly define the protocol name 'ipip' as 4.

2) The linux kernel uses the same in in.h:

 IPPROTO_IPIP = 4
 IPPROTO_BEETPH = 94 (?)

3) iptables maps 'ipip' to 94 and 'ipencap' to 4.

 # for num in {0..255}; do iptables -A INPUT -p $num; done
 # iptables-save | grep -E 'ipip|ipencap'
 -A INPUT -p ipencap
 -A INPUT -p ipip

4) /etc/protocols does the same as iptables:

 grep -E 'ipencap|ipip' /etc/protocols
 ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'')
 ipip 94 IPIP # IP-within-IP Encapsulation Protocol

5) getprotoby{name|number} does what /etc/protocols does:

 $ getprotobyname ipip
 struct protoent: (0x7fbbbcca9c60)
   p_name ipip
   p_aliases IPIP
   p_proto 94

 $ getprotobynumber 4
 struct protoent: (0x7fc51ad86be0)
   p_name ipencap
   p_aliases IP-ENCAP
   p_proto 4

Neutron actually builds a mapping based on the getprotoby*
calls, so in the iptables case it winds-up doing the wrong
thing.

Partial-bug: #2054324
Change-Id: Icc84b54be07d39059723d6c233c03aa130102423
(cherry picked from commit 793dfb04d0)
2024-03-04 16:18:10 +00:00
..
openvswitch_firewall Fix some new pylint "R" warnings 2023-07-18 18:06:51 -04:00
__init__.py Empty files should not contain copyright or license 2014-10-20 00:50:32 +00:00
bridge_lib.py Bump the minimum pyroute2 version to 0.7.3 2023-01-18 04:43:09 +01:00
daemon.py Remove "six" library 2020-07-28 16:55:52 +00:00
devlink.py Add `devlink.get_port` method for devlink ports 2022-12-12 20:08:06 +01:00
dhcp.py dhcp: fix usage of helper function to retrieve process name 2024-02-01 15:15:53 +00:00
dibbler.py Fix some pylint indentation warnings 2022-12-01 16:22:24 +00:00
external_process.py Remove obsolete PID files before start 2023-11-15 22:08:23 +00:00
interface.py If method `set_netns` fails, restore previous device namespace 2024-01-21 08:18:34 +00:00
ip_conntrack.py Fix some pylint indentation warnings 2022-12-01 16:22:24 +00:00
ip_lib.py If method `set_netns` fails, restore previous device namespace 2024-01-21 08:18:34 +00:00
ipset_manager.py Remove rootwrap execution (5) 2021-02-19 08:47:17 +00:00
iptables_comments.py Iptables firewall driver adds forward rules for trusted ports 2018-03-06 10:13:44 +01:00
iptables_firewall.py Fix iptables mapping of 'ipip' protocol 2024-03-04 16:18:10 +00:00
iptables_manager.py Merge "Fix some new pylint "R" warnings" 2023-07-28 06:58:46 +00:00
keepalived.py Remove obsolete PID files before start 2023-11-15 22:08:23 +00:00
l3_tc_lib.py Fix a error when l3-agent gets filter id for ip 2022-01-11 01:28:17 +00:00
of_monitor.py OpenFlow monitor 2019-11-20 18:00:13 +00:00
pd_driver.py Remove usage of six.add_metaclass 2020-05-21 14:41:18 -04:00
pd.py Use payloads for ROUTER AFTER_ callbacks 2021-08-09 14:13:28 +00:00
ra.py Remove more empty lines in ipv6 ra conf. 2020-09-30 11:02:02 +08:00
tc_lib.py Fix some new pylint "C" warnings 2023-05-18 21:54:38 -04:00
utils.py Add `devlink.get_port` method for devlink ports 2022-12-12 20:08:06 +01:00