Commit Graph

366 Commits

Author SHA1 Message Date
Florian Westphal 761cf19d7b firewall-util: introduce context structure
for planned nft backend we have three choices:

- open/close a new nfnetlink socket for every operation
- keep a nfnetlink socket open internally
- expose a opaque fw_ctx and stash all internal data here.

Originally I opted for the 2nd option, but during review it was
suggested to avoid static storage duration because of perceived
problems with threaded applications.

This adds fw_ctx and new/free functions, then converts the existing api
and nspawn and networkd to use it.
2020-12-16 00:35:56 +01:00
Yu Watanabe 450fa34bd0 network: fix SIGABRT related to unreachable route with DHCP6
After #17834, unreachable routes generated through DHCP6 are managed by
Manager. But they are referrenced by the DHCP6 uplink. So, the routes
managed by Manager must be freed after all Link objects are freed.

Follow-up for 575f14eef0.

Fixes SIGABRT reproted in #17831.
2020-12-08 12:41:07 +09:00
Yu Watanabe f63e09ef75 network: use bus_error_message() 2020-12-02 20:31:39 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Purushottam choudhary 92b555aaab network: selinux hook handling to enumerate nexthop
When selinux is enabled, the call of
manager_rtnl_enumerate_nexthop() fails.

This fix is to facilitate selinux hook handling for enumerating
nexthop.

In manager_rtnl_enumerate_nexthop() there is a check
if "Not supported" is returned by the send_netlink() call.

This check expects that -EOPNOTSUPP is returned,
the selinux hook seems to return -EINVAL instead.

This happens in kernel older than 5.3
(more specificallytorvalds/linux@65ee00a) as it does not support
nexthop handling through netlink.

And if SELinux is enforced in the order kernel, callingRTM_GETNEXTHOP
returns -EINVAL.

Thus adding a call in the manager_rtnl_enumerate_nexthop for the
extra return -EINVAL.
2020-11-01 23:28:21 +09:00
Yu Watanabe 2a99eed02c network: stop DHCPv4 server in link_stop_clients()
Then, rename link_stop_clients() -> link_stop_engines().
2020-10-15 07:56:30 +09:00
Yu Watanabe ad208fac73 network: also manage routes without RTA_OIF attribute 2020-10-07 15:22:10 +02:00
Yu Watanabe 256c75fd1f network: move DUID related functions 2020-10-07 02:50:50 +09:00
Yu Watanabe bfbf150ee6 network: manage address pools by OrderedSet 2020-10-07 02:50:50 +09:00
Yu Watanabe ed76f58521 network: move functions related to address pool 2020-10-07 02:50:50 +09:00
Yu Watanabe e1fc2c4371 network: move manager_rtnl_process_address() 2020-10-07 02:44:43 +09:00
Yu Watanabe 4468f01b67 network: move manager_rtnl_process_route() 2020-10-07 02:44:42 +09:00
Yu Watanabe 1939ebeb89 network: cleanup headers in networkd-neighbor.[ch] 2020-10-07 02:44:42 +09:00
Yu Watanabe eab052d2b3 network: move manager_rtnl_process_neighbor() to networkd-neighbor.c 2020-10-07 02:44:42 +09:00
Yu Watanabe 75156ccbdc network: cleanup headers included in networkd-nexthop.h 2020-10-07 02:39:51 +09:00
Yu Watanabe 454c87b5d5 network: move manager_rtnl_process_nexthop() to networkd-nexthop.c 2020-10-07 02:39:51 +09:00
Yu Watanabe 446aaaf35f network: introduce helper function to enumerate information using netlink 2020-10-07 02:39:13 +09:00
Yu Watanabe 51a0dc4a15 network: move manager_rtnl_process_rule() to networkd-routing-policy-rule.[ch] 2020-10-07 02:36:29 +09:00
Yu Watanabe 8dfed23d92 network: use typesafe macro netlink_add_match() 2020-10-07 02:36:29 +09:00
Yu Watanabe 0d7d377b80 network: move log_message_warning_errno() to networkd-util.h 2020-10-07 02:36:29 +09:00
Yu Watanabe ca183bf8fd network: drop list of static routing policy rules
[RoutingPolicyRule] sections are managed by both LIST and Hashmap.
Let's drop list.
2020-10-07 02:36:29 +09:00
Yu Watanabe 2102d33cfb network: also process RTM_NEWRULE or RTM_DELRULE message which does not contain src and dst addresses
Fixes #16784.
2020-09-10 18:57:07 +09:00
Yu Watanabe 755dbda355 network: also logs priority of routing policy rules 2020-09-10 18:18:59 +09:00
Yu Watanabe b6c7c4a87b network: update log message for rtnl messages 2020-09-10 18:14:24 +09:00
Yu Watanabe a725efb08b network: increase receive buffer size for device monitor
If networkd creates huge amount of netdevs, then the buffer of device
monitor becomes easily flowed.

Hopefully fixes #16865.
2020-09-09 06:39:05 +09:00
Yu Watanabe d31f33e3c9 network: do not start device monitor if /sys is read-only
Follow-up for bf331d8717.
2020-09-09 06:39:05 +09:00
Yu Watanabe e13af7bdb6 network: honor the buffer size specified in networkd.socket 2020-09-09 06:39:05 +09:00
Yu Watanabe 8c63924c8d network: ignore error on increasing netlink receive buffer size 2020-09-09 06:39:05 +09:00
Zbigniew Jędrzejewski-Szmek 90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Lennart Poettering cd17bb6e71 networkd: consider any uevent other than "remove" sufficient for the network device to be ready 2020-08-28 17:45:05 +02:00
Yu Watanabe 1633c45731 network: dhcp6: drop addresses and delegated prefixes on client stop
Previously, we did not drop addresses and delegated prefixes when
DHCP6 client is stopped.

Fixes #15455.
Fixes #13564.
2020-07-29 02:05:05 +09:00
Yu Watanabe 8eec0b9da5 network: set key destructor in several hash_ops 2020-07-29 02:05:05 +09:00
Yu Watanabe 5d8c3ec1e9 network: make link enter failed state if address_update() failed 2020-07-29 02:05:05 +09:00
Yu Watanabe c2a6595014 network: introduce link_save_and_clean() 2020-07-22 19:55:14 +09:00
Zbigniew Jędrzejewski-Szmek 2859bb932b
Merge pull request #16530 from yuwata/udev-fix-race-in-renaming-network-interface
udev: fix race in renaming network interface
2020-07-22 11:50:09 +02:00
Yu Watanabe 1cdea1a2f7 network: update one log message 2020-07-21 11:55:28 +09:00
Yu Watanabe 87d6489776 network: save DNS servers specified by DBus interface
Also, filter out DNS servers which do not match link ifindex.
2020-07-21 04:08:22 +09:00
Yu Watanabe e77bd3fdff network: support port number and SNI in [Network] DNS= 2020-07-21 04:08:22 +09:00
Yu Watanabe d15818f227 network: update debug log when foreign routes are received with ManageForeignRoutes=no 2020-07-18 05:51:41 +09:00
Yu Watanabe 5ff1ef31f2 network: do not enumerate routes if ManageForeignRoutes=no 2020-07-18 05:51:32 +09:00
fangxiuning d67b1d18fc bus: use bus_log_parse_error to print message 2020-07-12 06:33:48 +09:00
Yu Watanabe 25b831bac8 network: check that received ifindex is valid 2020-06-25 13:13:47 +09:00
Zbigniew Jędrzejewski-Szmek 39dbd0c74c networkd: take ref immediately after storing item in set
I'm not sure if I understand the code correctly, but it seems that if
storig in the second set failed, we'd return with the first set having
no reference on the link object, and the link object could be freed in the
future, leaving the set with a dangling reference.
2020-06-24 10:38:15 +02:00
Zbigniew Jędrzejewski-Szmek de7fef4b6e tree-wide: use set_ensure_put()
Patch contains a coccinelle script, but it only works in some cases. Many
parts were converted by hand.

Note: I did not fix errors in return value handing. This will be done separate
to keep the patch comprehensible. No functional change is intended in this
patch.
2020-06-22 16:32:37 +02:00
Lennart Poettering 2a71d57f4e network: clean-up DHCP lease server data configuration
This is an attempt to clean up the POP3/SMTP/LPR/… DHCP lease server
data logic in networkd. This reduces code duplication and fixes a number
of bugs.

This removes any support for collecting POP3/SMPT/LPR servers acquired
via local DHCP client releases since noone uses that, and given how old
these protocols are I doubt this will change. It keeps support for
configuring them for the dhcp server however.

The differences between the DNS/NTP/SIP/POP3/SMTP/LPR configuration
logics are minimized.

This removes the relevant symbols from sd-network.h (which is an
internal API only at this point after all).

This is unfortunately not well test, given the old code for this had
barely any tests. But the new code should not perform worse at least,
and allow us to release, since it corrects some interfaces visible in
the .network configuration format.

Fixes: #15943
2020-06-18 13:08:18 +09:00
Marc-André Lureau cf72a78660 networkd: expose DHCPServer interface on links 2020-06-04 11:16:15 +02:00
Yu Watanabe c643bda5ec network: read driver name from ethtool
To make Driver= in [Match] section work in containers.

Note that ID_NET_DRIVER= property in udev database is set with the
result of the ethtool. So, this should not change anything for
non-container cases.

Closes #15678.
2020-06-03 18:25:37 +02:00
Lennart Poettering ddb82ec2a2 sd-dhcp: clean-up of DHCP lease server code
This is an attempt to clean-up the DHCP lease server type code a bit. We
now strictly use the same enum everywhere, and store server info in an
array. Moreover, we use the same nomenclature everywhere.

This only makes the changes in the sd-dhcp code. The networkd code is
untouched so far (but should be fixed up like this too. But it's more
complicated since this would then touch actual settings in .network
files).

Note that this also changes some field names in serialized lease files.
But given that these field names have not been part of a released
version of systemd yet, such a change should be ok.

This is pure renaming/refactoring, shouldn't actually change any
behaviour.
2020-05-30 14:18:43 +02:00
Benjamin Robin 0a0e594a26 tree-wide: Mark as _unused_ variables that are only used in assert()
Allow to build without any warning with NDEBUG defined
2020-05-06 23:03:25 +02:00
Zbigniew Jędrzejewski-Szmek 73781de41f
Merge pull request #15530 from ssahani/lpr-dhcpv4-option-9
network: add support to DHCPv4 server/client option 9 LPR
2020-04-23 09:10:14 +02:00