Commit Graph
38 Commits
Author SHA1 Message Date
Yu Watanabe cb8453cc51 network: sriov: use request queue to configure SR-IOV virtual functions 2022-03-23 16:48:36 +09:00
Yu Watanabe 09d09207de network: re-design request queue
This makes Request object takes hash, compare, free, and process functions.

With this change, the logic in networkd-queue.c can be mostly
independent of the type of the request or the object (e.g. Address) assigned
to the request, and it becomes simpler.
2022-03-11 14:20:31 +09:00
Yu Watanabe 4c8b81caa5 network: increment reference counters of Link and Request before processing requests
To prevent the request or link is freed while processing requests.
2022-03-11 14:20:31 +09:00
Yu Watanabe eb93dc9bde network: merge RequestType and SetLinkOperation
These two enum indicate how we process the request. Hence, it is not
necessary to introduce two separated indicators.
2022-03-11 14:20:31 +09:00
Yu Watanabe 80d62d4f1a network: introduce request_call_netlink_async()
In most netlink handlers, we do the following,
1. decrease the message counter,
2. check the link state,
3. error handling,
4. update link state via e.g. link_check_ready().

The first two steps are mostly common, hence let's extract it.

Moreover, this is not only extracting the common logic, but provide a
strong advantage; `request_call_netlink_async()` assigns the relevant
Request object to the userdata of the netlink slot, and the request object
has full information about the message we sent. Hence, in the future,
netlink handler can print more detailed error message. E.g. when
an address is failed to configure, then currently we only show an
address is failed to configure, but with this commit, potentially we can
show which address is failed explicitly.

This does not change such error handling yet. But let's do that later.
2022-03-11 14:20:31 +09:00
Yu Watanabe e26d3d407c network: make Request object take Manager*
Previously, even though all Request object are owned by Manager, they
do not have direct reference to Manager, but through Link or NetDev
object. But, as Link or NetDev can be NULL, we need to conditionalize
how to access Manager from Request with the type of the request.
This makes the way simpler, as now Request object has direct reference
to Manager.

This also rename request_drop() -> request_detach(), as in the previous
commit, the reference counter is introduced, so even if a reference of
a Request object from Manager is dropped, the object may still alive.
The naming `request_drop()` sounds the object will freed by the
function. But it may not. And `request_detach()` suggests the object
will not be managed by Manager any more, and I think it is more
appropreate.

This is just a cleanup, and should not change any behavior.
2022-03-11 14:20:31 +09:00
Yu Watanabe e9ef9a1484 network: introduce reference counter for Request object
Currently, all Request object are always owned by Manager, and freed
when it is processed, especially, soon after a netlink message is sent.
So, it is not necessary to introduce the reference counter.

In a later commit, the Request object will _not_ be freed at the time
when a netlink message is sent, but assigned to the relevant netlink
slot as a userdata, and will be freed when a reply is received. So, the
owner of the Request object is changed in its lifetime. In that case, it
is convenient that the object has reference counter to avoid memleak or
double free.
2022-03-11 14:20:31 +09:00
Yu Watanabe ff51134c93 network: make request_process_address() and friends take Link and corresponding object
This also renames e.g. request_process_address() -> address_process_request().

Also, this drops type checks such as `assert(req->type == REQUEST_TYPE_ADDRESS)`,
as in the later commits, the function of processing request, e.g.
`address_process_request()`, will be assigned to the Request object when
it is created. And the request type will be used to distinguish and to
avoid deduplicating requests which do not have any assigned objects,
like REQUEST_TYPE_DHCP4_CLIENT. Hence, the type checks in process functions
are mostly not necessary and redundant.

This is mostly cleanups and preparation for later commits, and should
not change any behavior.
2022-03-11 14:16:41 +09:00
Yu Watanabe f1eef3675c network: tc: assign netlink handlers into Request object
This should not change any behavior, as req->netlink_handler is always
qdisc_handler or tclass_handler.

This is just a preparation for a later commit which introduces
request_call_netlink_async().
2022-03-11 10:39:05 +09:00
Yu Watanabe 3a67b8bb0d network: traffic control: drop meta from QDisc and TClass
Since #22248, it is not necessary to manage QDisc and TClass in same Set
or Hashmap. Let's manage them independently.
2022-02-26 14:58:01 +09:00
Yu Watanabe 5d4a925af0 network: netdev: use request queue to create independent netdevs 2022-02-15 16:06:37 +09:00
Yu Watanabe efa7b8adde network: netdev: increment reference counter on request
Otherwise, it may be freed on reload.
2022-02-15 15:54:02 +09:00
Yu Watanabe 709055dabb network: rename REQUEST_TYPE_STACKED_NETDEV -> REQUEST_TYPE_NETDEV_STACKED 2022-02-15 15:54:02 +09:00
Yu Watanabe 1dec9d816b network: tc: use request queue to configure traffic control
But no dependency resolution is implemented.
2022-02-09 14:43:19 +09:00
Yu Watanabe 89346ac6f6 network: coding style fixes 2022-02-09 14:35:25 +09:00
Yu Watanabe ba4c7184b3 network: configure NDisc after MAC address is assigned 2022-01-31 13:10:28 +09:00
Yu Watanabe b8355de49e network: drop unused features in request queue 2021-09-24 21:46:36 +09:00
Yu Watanabe b14686ff3a network: adjust log messages, function names, etc. 2021-08-12 14:39:39 +09:00
Yu Watanabe ccffa166d8 network: use request queue to configure DHCP{4,6} clients
Previously, when UUID is requested for DUID, then the clients are
configured in callback of bus methods.
But now, 'request queue' was implemented, so we can use it to wait until
the product UUID is obtained.
2021-08-10 14:55:34 +09:00
Yu Watanabe a254fab20d network: use request queue to configure IPv6 RA engine 2021-08-04 22:19:14 +09:00
Yu Watanabe 2b24292692 network: update comment and man page 2021-08-04 22:19:14 +09:00
Zbigniew Jędrzejewski-Szmek 04499a70fb Drop the text argument from assert_not_reached()
In general we almost never hit those asserts in production code, so users see
them very rarely, if ever. But either way, we just need something that users
can pass to the developers.

We have quite a few of those asserts, and some have fairly nice messages, but
many are like "WTF?" or "???" or "unexpected something". The error that is
printed includes the file location, and function name. In almost all functions
there's at most one assert, so the function name alone is enough to identify
the failure for a developer. So we don't get much extra from the message, and
we might just as well drop them.

Dropping them makes our code a tiny bit smaller, and most importantly, improves
development experience by making it easy to insert such an assert in the code
without thinking how to phrase the argument.
2021-08-03 10:05:10 +02:00
Yu Watanabe 475ec3346f network: make request_drop() accept NULL 2021-07-01 00:49:03 +09:00
Yu Watanabe 9b682672e4 network: use void* to correctly store SetLinkOperation in Request
Previously, when `link_request_queue()` is called in link_request_set_link(),
`SetLinkOperation` is casted with INT_TO_PTR(), and the value is assigned to
`void *object`. However the value was read directly through the member
`SetLinkOperation set_link_operation` of the union which `object`
beloging to. Thus, read value was always 0 on big-endian systems.

Fixes configuring link issue on s390x systems.
2021-06-15 20:58:20 +02:00
Yu Watanabe 68f5206349 network: use request queue to handle bound_to list 2021-06-09 04:59:23 +09:00
Yu Watanabe 112a0972a2 network: introduce link_request_to_activate()
The request will be processed after all setlink requests are processed.
The function will be used in later commits.
2021-06-08 06:39:48 +09:00
Yu Watanabe 71a754f70f network: introduce link_request_to_create_stacked_netdev()
This will be used in later commits.
2021-06-08 06:33:27 +09:00
Yu Watanabe 0fa8ee6c77 network: use request queue to set MTU 2021-06-08 06:33:27 +09:00
Yu Watanabe 40b12fa20d network: introduce request_hash_ops to dedup requests
If KeepConfiguration= or ConfigureWithoutCarrier= is set, then the same
requests may be queued.
2021-06-08 06:33:27 +09:00
Yu Watanabe fdeba3f5cc network: use request queue to configure IPv6 proxy NDP addresses 2021-06-08 06:33:27 +09:00
Yu Watanabe 354bc760cd network: address label: use request queue to configure address labels 2021-06-08 06:33:27 +09:00
Yu Watanabe 9a038aaced network: use request queue to configure bridge MDB 2021-06-08 06:33:27 +09:00
Yu Watanabe 1d28a3cf6c network: use request queue to configure DHCP server 2021-06-08 06:33:27 +09:00
Yu Watanabe e5b35bf6c2 network: use queue to configure bridge FDB 2021-05-20 18:23:15 +09:00
Yu Watanabe 76c5a0f27b network: use request queue to configure addresses, routes, and nexthops
Why is this necessary? Several examples below.

- When a route sets prefsrc, then the address must be already assigned
  (see issue #19285), and also it must be ready if IPv6.
- When a route or nexthop sets gateway, then the address must be reachable.
- When a route sets nexthop ID, then the corresponding nexthop must be
  assigned.
- When a route sets multipath routes on another interface, then the
  interface must exist and be ready to configure.
- When configuring address, the same address must not be under removing
  (see issue #18108).
Etc,. etc,...

So, this makes all requests about addresses, routes, and nethops are once
stored in the queue, and will be processed when they are ready to configure.

Fixes #18108 and #19285.
2021-05-12 11:26:06 +09:00
Yu Watanabe 40ca350ea1 network: use request queue to configure neighbors 2021-05-12 11:26:06 +09:00
Yu Watanabe 0e5ef6beb6 network: use request queue to configure routing policy rules 2021-05-12 11:26:06 +09:00
Yu Watanabe 19d9a5adf0 network: add skeleton of request queue
This will be used in later commits.
2021-05-12 11:26:06 +09:00