Commit Graph

187 Commits

Author SHA1 Message Date
Zuul 5ae0ce59c9 Merge "Do not update static routes in snat-ns for dvr router with ha" 2023-06-21 22:43:04 +00:00
Rodolfo Alonso Hernandez 1d84aaf877 Bump the minimum pyroute2 version to 0.7.3
This patch also removes the pylint disablement message control
statements and imports NetNS and IPRoute from the new locations
in pyroute2.

Trivial-Fix

Change-Id: I298a7da767473c236ddf03c5702a2904d4870284
2023-01-18 04:43:09 +01:00
Anton Kurbatov f3c743d090 Do not update static routes in snat-ns for dvr router with ha
If a router is distributed with ha enabled, then the keepalived service
is responsible for setting static routes. This patch adds a check if
the router ha is disabled before adding routes. Otherwise, there are
duplicate routes and the issue when this route needs to be removed.
In addition this patch fixes multipath route in the snat-ns if no HA is
enabled.

Closes-Bug: #1999678
Signed-off-by: Anton Kurbatov <Anton.Kurbatov@acronis.com>
Change-Id: I8f1004b3fe2cad79cb61aa942b257c1508d18b68
2022-12-15 10:23:01 +00:00
Brian Haley 81330921d8 Fix some pylint indentation warnings
Running with a stricter .pylintrc generates a lot of
C0330 warnings (hanging/continued indentation). Fix
the ones in neutron/agent and neutron/privileged/agent.

Trivialfix

Change-Id: Ib94257481e62b99b3d7648ae5137af5411b4867a
2022-12-01 16:22:24 +00:00
Edward Hope-Morley 36bf1df46d Partially revert "Do not link up HA router gateway in backup node"
This partially reverts commit c52029c39a.

We revert everything except one minor addition to
neutron/agent/l3/ha_router.py which ensures that ha_confs path is
created when the keepalived manager is initialised.

Closes-Bug: #1965297
Change-Id: I14ad015c4344b32f7210c924902dac4e6ad1ae88
2022-05-24 11:24:30 +00:00
Slawek Kaplonski b5dd6efdca [DVR] Fix update of the MTU in the SNAT namespace
When network's MTU is changed, Neutron sends notification about it
to the L3 agents. In case of DVR (and DVR HA) MTU is then changed in
the qrouter- namespace but should be also changed on snat interfaces
in the snat namespace. And that part was missing.

This patch adds special implementation of the internal_network_updated()
method in the DvrEdgeRouter class so it can configure MTU also for
in the snat namespace.

This patch also removed passing attributes "interface_name",
"ip_cidrs" and "mtu" to the internal_network_updated() method and adds
"port" dict to be passed there. It is consistent with what is already
done in e.g. internal_network_added() method and "port" dict is actually
necessary to configure properly snat internal interface in the snat
namespace.

This patch adds also functional test of update network mtu for all types
of routers as there was no such test at all.

There is additional issue with DVR-HA which isn't fixed with that patch
and for which follow up will be proposed. Because of that this patch is
marked as partial fix for the related bug.

Related-Bug: #1933273
Change-Id: I200acfcaaae7f056ea9a563fead9ff2de8464971
2021-08-30 16:49:01 +02:00
XiaoYu Zhu 9b2983743b L3 router support ECMP
This patch changes the policy for updating routes to support ECMP,
and will now add ECMP routes to the Neutron router namespace when
there are multiple routes pointing to the same destination address.

Change-Id: I842c1408ee0235bc54441e9ed69c8b87ea30651b
Related-Bug: #1880532
2021-07-13 15:13:29 +08:00
Rodolfo Alonso Hernandez 074c131b57 Disable pep8 import check for pyroute2 library
Since version 0.6.2, pyroute2 library dynamically imports the needed
modules when loaded. A static analysis will fail when checking the
import references.

Change-Id: I5aaf9494a2d5c2533199e6b92d4df8fe785f83a3
Closes-Bug: #1930750
2021-06-03 20:06:44 +00:00
Slawek Kaplonski 24dcbcbe09 Block metadata requests to not go out from the router
Packets send from instances to the metadata service which is running in
the router's namespace should never go out from the router.
Even if e.g. nat rule to redirect it to port 9697 isn't installed in
iptables for some reason, in worst case such requests should be dropped.

Before that patch we had in mangle table rules to mark such packets with
specific mark. But we didn't block such packets later.
This patch adds rule to DROP such packets in the "scope" chain in the
filter table.

Co-authored-by: Rodolfo Alonso Hernandez <ralonsoh@redhat.com>

Related-Bug: #1920778
Change-Id: I6e9eec8fe9606d21fbce3699b4262e0783f667ec
2021-03-26 10:16:07 +01:00
Slawek Kaplonski 2325ad1950 Add locks for methods which sets nat rules in router
Router_info class and port_forwarding L3 extensions are using same
instance of the iptables manager class and it could happend that
method which sets address scope rules and method which sets
port forwarding nat rules where run in almost same time and
one of them was adding rules which wasn't expected to be added.
Because of that port forwarding rules wasn't configured properly.

This patch fixed that by adding lock for methods which are changing
rules in iptables_manager's nat table in both router_info and
port_forwarding extension.

Change-Id: Ic1d5f893a81b7b841745da82f38b7583e47e468d
Closes-Bug: #1896735
2020-10-11 19:40:20 +00:00
LIU Yulong 84d4fe177b [L3] Add missing address scope mark for IPv6 traffic
Any IPv6 traffic wants to go in/out directly on the DVR compute node
will be dropped by the mis-configured scope mark iptables rule. This
patch addresses this issue.

Closes-Bug: #1895401
Change-Id: Iee045e963e05f83d497e73bb39bb64c522f19543
2020-09-16 00:34:38 +00:00
Bence Romsics 3f30727c0a Use metadata constants from n-lib
Change-Id: I8045d1670045a68c955b0bf95077137ea07fd72e
Partial-Bug: #1460177
2020-09-04 15:08:30 +00:00
Bence Romsics a1f4ee3ade metadata-ipv6: Router namespace
We push a v6 host route to make the guest send its metadata requests
in the direction of our router. We redirect it to haproxy which
mangles the headers and sends the request along to metadata-agent.

Apparently the supported list of dhcp options for dhcpv6 is quite
short in dnsmasq (cf. dnsmasq --help dhcp6) - not including anything
like classless-static-route for dhcpv4. So we must rely solely on
radvd to push host routes to the guest.

Metadata access over IPv6 is supposed to work both on dual-stack and
v6-only networks.

The following v6 subnet modes are supposed to work:

--ipv6-ra-mode slaac --ipv6-address-mode slaac
--ipv6-ra-mode dhcpv6-stateless --ipv6-address-mode dhcpv6-stateless
--ipv6-ra-mode dhcpv6-stateful --ipv6-address-mode dhcpv6-stateful

Change-Id: I28f2914b1b67659af2db7240eae730ac43daccd2
Partial-Bug: #1460177
2020-08-31 13:02:49 +02:00
Zuul be1e4f845d Merge "Improve terminology in the Neutron tree" 2020-08-28 14:06:18 +00:00
Slawek Kaplonski 13b894288e Fix deletion of subnet_id from pd_subnets
In the RouterInfo._process_internal_ports() method when it process
old ports and port belongs to the subnet with CIDR assigned by
Prefix Delegation it will try to remove subnet_id key from the
pd_subnets dict.
However it seems that in some case it may happen that such subnet_id key
is not added to the pd_subnets dict and processing of ports fails.

We shouldn't fail in such case, if there is no subnet_id key in this
dict we should be good as we want to delete it simply. So this patch
changes that to not raise KeyError in such case.

Change-Id: I6e6d890c196716c0ef4bcc2922f1ec4c142a6e79
Closes-Bug: #1892364
2020-08-20 22:10:21 -04:00
Brian Haley 055036ba2b Improve terminology in the Neutron tree
There is no real reason we should be using some of the
terms we do, they're outdated, and we're behind other
open-source projects in this respect. Let's switch to
using more inclusive terms in all possible places.

Change-Id: I99913107e803384b34cbd5ca588451b1cf64d594
2020-08-19 16:47:53 -04:00
Rodolfo Alonso Hernandez 998b22b383 Implement "RouterInfo.update_routing_table" with Pyroute2
Change-Id: I715172e6bd64fcdd34ce10956fd4fdc20887a70a
Related-Bug: #1492714
2020-06-09 13:48:41 +00:00
Brian Haley 08a60f7483 Remove usage of six.add_metaclass
With python 3.x, classes can use the metaclass= logic
to not require usage of the six library.

One step in removing all of six usage from neutron.

Change-Id: I2f815e412d9a96eb5faf2b3bb3a1e393a9db9309
2020-05-21 14:41:18 -04:00
LIU Yulong c52029c39a Do not link up HA router gateway in backup node
L3 router will set its devices link up by default.
For HA routers, the gateway device will be pluged
in all scheduled hosts. When the gateway deivce is
up in backup node, it will send out IPv6 related
packets (MLDv2) according to some kernal config.
This will cause the physical fabric think that the
gateway MAC is now working in the backup node. And
finally the master node L3 traffic will be broken.

This patch sets the backup gateway device link down
by default. When the VRRP sets the master state in
one host, the L3 agent state change procedure will
do link up action for the gateway device.

Closes-Bug: #1859832
Change-Id: I8dca2c1a2f8cb467cfb44420f0eea54ca0932b05
2020-03-25 16:09:42 +08:00
Slawek Kaplonski 3faba7cae0 [L3] Switch order of processing added and removed router ports
It may happend that one router's port is going to be
removed and another one (same IP but new subnet) is going to be added
to the router in short time.
That can lead to the problem that IP which is allocated to the new
port is not added to keepalived's vips list because same IP address
is already in this list (this exising IP address belongs to old port).
But few seconds later old port is removed and finally router ends
up with new port configured without IP address.

To avoid such case, this patch switches order of processing new
and deleted ports in _process_internal_ports() method in RouterInfo
class.
So now first old ports will be removed and than new ports will be
configured so there will be no case when IP address is already added
to VIPs list when it is going to be removed in few seconds.

Change-Id: I72dc4a06a806731ec5124fa11c9f69c7dd6cbbb0
Closes-Bug: #1857021
2019-12-19 16:12:09 +01:00
Zuul 95034c4b4f Merge "Implement "ip route" commands using Pyroute2" 2019-07-09 05:18:41 +00:00
Slawek Kaplonski dfa37b2233 Don't match input interface in POSTROUTING table
Netfilter postrouting hooks don't provide the input interface. That
works fine in iptables implementation as the comparison simply happens
against an empty string, but cause problems with nftables which
aborts rule processing due to no data to compare against and
the rule doesn't match.
This is a problem in systems where nftables are used (e.g. RHEL 8).

This patch fixes this issue by removing input interface from
POSTROUTING rule used to prevent SNAT for router's internal traffic.

Change-Id: I79bb8054c113c77e7c96d64ec1408236d24b23b6
Closes-Bug: #1834825
2019-07-01 09:45:38 +02:00
Rodolfo Alonso Hernandez 0699713609 Implement "ip route" commands using Pyroute2
Commands implemented:
* Add route
* List routes

Related-Bug: #1492714

Change-Id: I5e5e9f6981024317773979d9d2d77db3f5e7ec98
2019-06-27 10:07:52 +00:00
Zuul 554b7cd228 Merge "Add router_factory to l3-agent and L3 extension API" 2019-04-27 06:37:15 +00:00
Yang Youseok ec875b42b6 Add router_factory to l3-agent and L3 extension API
Currently, most implementations override the L3NatAgent class itself
for their own logic since there is no proper interface to extend
RouterInfo class. This adds unnecessary complexity for developers
who just want to extend router mechanism instead of whole RPC.

Add a RouterFactory class that developer can registers RouterInfo class
and delegate it for RouterInfo creation. Seperate functions and variables
which currently used externally to abstract class from RouterInfo, so that
extension can use the basic interface.

Provide the router registration function to the l3 extension API so that
extension can extend RouterInfo itself which correspond to each features
(ha, distribtued, ha + distributed)

Depends-On: https://review.openstack.org/#/c/620348/
Closes-Bug: #1804634
Partially-Implements: blueprint openflow-based-dvr
Change-Id: I1eff726900a8e67596814ca9a5f392938f154d7b
2019-04-26 10:22:50 +09:00
Swaminathan Vasudevan 30f35e08f9 Packets getting lost during SNAT with too many connections
We have a problem with SNAT with too many connections using the
same source and destination on the network nodes.

In addition we can see in the conntrack table that the who
"instert_failed" increases.

This might be a generic problem with conntrack and linux.
We suspect that we encounter the following "limitation / bug"
in the kernel.

There seems to be a workaround to alleviate this behavior by
setting the -random-fully flag in iptables for port consumption.

This patch fixes the problem by adding the --random-fully to
the SNAT rules.

Change-Id: I246c1f56df889bad9c7e140b56c3614124d80a19
Closes-Bug: #1814002
2019-04-12 10:12:04 -04:00
Boden R 9bbe9911c4 remove neutron.common.constants
All of the externally consumed variables from neutron.common.constants
now live in neutron-lib. This patch removes neutron.common.constants
and switches all uses over to lib.

NeutronLibImpact

Depends-On: https://review.openstack.org/#/c/647836/
Change-Id: I3c2f28ecd18996a1cee1ae3af399166defe9da87
2019-04-04 14:10:26 -06:00
Zuul c21d922abd Merge "Fix pep8 E128 warnings in non-test code" 2019-03-15 11:37:27 +00:00
Brian Haley 8e4f625da6 Fix pylint R1717 (consider-using-dict-comprehension) refactor messages
Don't create an intermediate list before creating a dict.

Change-Id: Idb93835f2312625d649231c1baa2a3c566096825
2019-03-14 23:19:58 +00:00
Zuul 6b750059e7 Merge "Fix pylint E1128 (assignment-from-no-return) in l3-agent" 2019-03-13 16:51:58 +00:00
Brian Haley eaf990b2bc Fix pep8 E128 warnings in non-test code
Reduces E128 warnings by ~260 to just ~900,
no way we're getting rid of all of them at once (or ever).
Files under neutron/tests still have a ton of E128 warnings.

Change-Id: I9137150ccf129bf443e33428267cd4bc9c323b54
Co-Authored-By: Akihiro Motoki <amotoki@gmail.com>
2019-03-12 21:22:33 +00:00
Brian Haley 2ac0ee0b28 Fix pylint E1128 (assignment-from-no-return) in l3-agent
Changed migrate_centralized_floating_ip() to return a
status in DvrLocalRouter class.  Also changed the parent
method in RouterInfo class to return FLOATINGIP_STATUS_NOCHANGE,
which will cause the agent to not send an updated status for
the floating IP.

Also changed floating_ip_added_dist() to not use an
intermediate variable and just return directly.

Change-Id: I7dc4934308da95cf00a36b4ef1020aac7cef7d99
Closes-bug: #1816874
2019-03-12 13:43:58 +00:00
Sławek Kapłoński b09b44608b Remove deprecated 'external_network_bridge' option
This option is deprecated and marked to be deleted in Ocata. So
as we are now in Stein development cycle I think that it's good time
to remove it.

Change-Id: I07474713206c218710544ad98c08caaa37dbf53a
2019-03-09 22:07:38 +00:00
Slawek Kaplonski fe4e7724cd Don't disable radvd if radvd if it wasn't initialized
In some cases on dvr ha router it may happend that
RouterInfo.radvd.disable() will be called even if
radvd DaemonMonitor wasn't initialized earlier and it is
None.
To prevent exception in such case, this patch adds check
if DaemonMonitor is not None to call disable() method on
it.

Change-Id: Ib9b5f4eeae6e4cebcb958928e6521cf1d69b049c
Closes-Bug: #1817435
2019-03-01 17:56:31 +00:00
Doug Wiegley 7e208c3014 Bump pylint version to one that supports python3.7
The listed revision no longer supports python2, but afaik, we are
always running under python3 for those tests anyway.

Change-Id: Iba94d73eeb65fb21f5d098afe0fbe4348dbea850
2019-02-21 13:22:26 +00:00
Slawek Kaplonski 21cddc47b4 Fix update of ports cache in router_info class
RouterInfo class has got internal_ports cache which is updated
in _process_internal_ports() method.
There was an issue in this updates logic because it was
iterating through enumerate local variable "internal_ports"
which represents current router ports and if such current port
was found in updated_ports list it was storred in
RouterInfo().internal_ports variable under same index as was
found in "internal_ports" local variable.
This sometimes leads to an issue because same port can be
stored under different index in internal_ports and
RouterInfo().internal_ports lists thus wrong port in
RouterInfo().internal_ports was overwritten.

Such issue leads to problem with generating radvd config file
because in ports cache list there was duplicate info about same port
so radvd config file contained duplicate interface definitions too.

This should be properly fixed by changing RouterInfo.internal_ports
to be a dict instead of list of ports but such patch would be much
bigger and (possibly) harded to backport to stable branches.

Change-Id: I2e38457942518c8a3e07e606091bb6720317b77e
Closes-Bug: #1813279
2019-02-07 15:49:59 +01:00
Zuul b86fa161ed Merge "remove neutron.common.exceptions" 2019-02-03 17:07:02 +00:00
Boden R 68fd13af40 remove neutron.common.exceptions
Today the neutron common exceptions already live in neutron-lib and are
shimmed from neutron. This patch removes the neutron.common.exceptions
module and changes neutron's imports over to use their respective
neutron-lib exception module instead.

NeutronLibImpact

Change-Id: I9704f20eb21da85d2cf024d83338b3d94593671e
2019-02-01 14:35:00 -07:00
LIU Yulong e108ac6bdf Add port forwarding floating IP QoS
Port forwarding floating IPs QoS should be limited under
the binding QoS policy. So this patch extends the l3-agent
fip-qos agent extension floating IP list with the port
forwarding related IPs.

Change-Id: Iddabfabafc0803edd1e4ac0893dc188f1907234a
Closes-Bug: #1796925
2019-01-30 14:04:00 +00:00
Doug Wiegley 8914f8247f Update neutron files for new over-indentation hacking rule (E117)
Change-Id: I594e2d1238f6ffa3c1039624e3b3ed6569485837
2019-01-29 15:36:20 -05:00
LIU Yulong cd3cc7e908 [L3][QoS] Agent side router gateway IP rate limit
This patch implements the L3 agent side router gateway IP rate
limit. For routers in centralized snat node (network node),
the tc rules will be set on the corresponding device in router
namespace:
    1. Legacy and HA router, qrouter-namespace and qg-device
    2. Dvr (edge) router, snat namespace and qg-device

If gateway IP rate limit was set, then under the same router,
all the VMs without floating IP will share the bandwidth.

Partially-Implements blueprint: router-gateway-ip-qos
Closes-Bug: #1757044
Change-Id: Ie92ff0d4df0e85ce71c7d50f34ea6ff973812af8
2018-12-01 17:45:47 +08:00
Zuul 8db1a47fa8 Merge "Enable 'all' IPv6 forwarding knob correctly" 2018-11-30 03:25:24 +00:00
Brian Haley b847cd02c5 Enable 'all' IPv6 forwarding knob correctly
When the external gateway is plugged and we enable IPv6
forwarding on it, make sure the 'all' sysctl knob is also
enabled, else IPv6 packets will not be forwarded.  This
seems to only affect HA routers that default to disabling
this 'all' knob on creation.

Also, when we are removing all the IPv6 addresses from a
HA router internal interface, set 'accept_ra' to zero so
it doesn't accidentally auto-configure an address.  Set
it back to one when adding them back.

Re-homed newly added _wait_until_ipv6_forwarding_has_state()
accordingly.

Closes-bug: #1787919

Change-Id: Ia1f311ee31d1479089685367a97bf13cf170b342
2018-11-15 14:59:49 -05:00
Swaminathan Vasudevan cd0cc47a6a DVR: Centralized FloatingIPs are not cleared after migration.
With DVR routers, if a port is associated with a FloatingIP,
before it is used by a VM, the FloatingIP will be initially
started at the Network Node SNAT Namespace, since the port
is not bound to any host.

Then when the port is attached to a VM, the port gets its
host binding, and then the FloatingIP setup should be migrated
to the Compute host and the original FloatingIP in the Network
Node SNAT Namespace should be cleared.

But the original FloatingIP setup in SNAT Namespace was not
cleared by the agent.

This patch addresses the issue.

Change-Id: I55a16bcc0020087aa1abe76f5bc85cd64ccdaecd
Closes-Bug: #1796491
2018-11-13 16:25:04 -05:00
Brian Haley d19dcf1ef2 Fix IPv6 prefix delegation issue on agent restart
On l3-agent restart, prefix delegation subnets weren't always
inserted into the local router_info cache, leading to a missing
ip6tables rule.  Add it when the internal network is configured
if the prefix has already been assigned.

Change-Id: Ic045e2763ba2772bcaf037591821501e84e40878
Closes-bug: #1789403
2018-09-17 13:04:21 +00:00
ZhaoBo de9b39ed2c [agent side] L3 agent side Floating IP port forwarding
This patch contains the l3 agent extension and agent part code.
This patch introduce a new l3 agent extension named "port_forwarding",
to process the binding of the port forwarding resources, manage its own
floatingip configuration on router interface and floatingip status.
Currrently, we support all Neutron Router reference implementations.

This extension uses the period router sync task and PortForwarding OVO
rpc.

* The main idea about this new extension is using the generic router sync
  rpc to maintain the host port forwarding resources,
* For a single port forwarding create/update/delete, process it one by one
  in smaller scope for forbidding refresh the iptables with a larger
  scope frequently.

Partially-Implements: blueprint port-forwarding
Partial-Bug: #1491317
Change-Id: Ic56e67d428f6177099c285a9d1bccabc1e710f2b
2018-07-27 18:25:47 +08:00
Miguel Angel Ajo 88f5e11d8b Avoid agents adding ports as trunk by default.
Agent OVS interface code adds ports without a vlan tag,
if neutron-openvswitch-agent fails to set the tag, or takes
too long, the port will be a trunk port, receiving
traffic from the external network or any other port
sending traffic on br-int.

Also, those kinds of ports are triggering a code path
on the ovs-vswitchd revalidator thread which can eventually
hog the CPU of the host (that's a bug under investigation [1])

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1558336

Co-Authored-By: Slawek Kaplonski <skaplons@redhat.com>
Change-Id: I024bbbdf7059835b2f23c264b48478c71633a43c
Closes-Bug: 1767422
2018-05-09 14:07:27 +02:00
Brian Haley c3b83a9ca6 Fix all pep8 E265 errors
Fixed all pep8 E265 errors and changed tox.ini to no longer
ignore them.  Also removed an N536 comment missed from a
previous change.

Change-Id: Ie6db8406c3b884c95b2a54a7598ea83476b8dba1
2018-04-30 16:35:52 -04:00
Brian Haley 90cd939047 Fix W503 pep8 warnings
Fix W503 (line break before binary operator) pep8 warnings
and no longer ignore new failures.

Trivialfix

Change-Id: I7539f3b7187f2ad40681781f74b6e05a01bac474
2018-04-17 14:22:58 +00:00
Brian Haley 6941977827 Add iptables metadata marking rule on router init
Move the iptables metadata marking rule earlier in
router init, that way any stray metadata requests
that arrive before the filter metadata redirect rule is
installed will just be dropped.  We do this irregardless
of whether we will be running the metadata proxy.

Partial-bug: #1735724

Change-Id: I8982523dbb94a7c5b8a4db88a196fabc4dd2873f
2017-12-19 10:07:33 -05:00