Commit Graph

247 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 1db01a3339 network: make address_drop() accept NULL 2020-12-14 23:28:11 +09:00
Yu Watanabe 24f50382af network: introduce log_address_debug() 2020-12-14 23:28:07 +09:00
Yu Watanabe bd4733da64 network: do not configure static configs more than once simultaneously 2020-12-11 14:39:46 +09:00
Yu Watanabe b788a429d1 network: do not assume address ready callback is always set to static addresses 2020-12-11 14:22:35 +09:00
Yu Watanabe b2219cc4b6 network: drop assertions to check link state in netlink callback handlers
As, the link may be dropped while configuring addresses or routes.

Fixes #17920.
2020-12-11 13:47:24 +09:00
Yu Watanabe c5a0aeb33a network: use address_get() in address_exists()
And rename address_exists() to link_has_ipv6_address().
2020-12-08 12:41:07 +09:00
Yu Watanabe 1d30fc5cb6 network: revert previous changes to address_compare_func()
This partially reverts fe841414ef and
2a236f9fc0.

For IPv4, kernel compares the local address, prefix, and prefixlen.
For IPv6, kernel compares only the local address.
Let's follow the kernel's comparison way.

Fixes #17831.
2020-12-08 12:41:07 +09:00
Lennart Poettering ce9fb09e96
Merge pull request #17809 from yuwata/network-address-fixes-17803
network: two fixes for configuring address correctly
2020-12-03 21:04:58 +01:00
Florian Westphal 7509c7fdf9 fw_add_masquerade: remove unused function arguments
Similar to the previous commit.  All callers pass NULL.  This will
ease initial nftables backend implementation (less features to cover).

Add the function parameters as local variables and let compiler
remove branches.  Followup patch can remove the if (NULL) conditionals.
2020-12-03 11:05:14 +01:00
Yu Watanabe 2a236f9fc0 network: ignore broadcast address for /31 or /32 addresses
As they do not have broadcast address.
See https://tools.ietf.org/html/rfc3021
2020-12-03 10:23:12 +09:00
Yu Watanabe 05a7023d24 network: fix verification for broadcast address
Fixes a bug caused by fe841414ef.
2020-12-03 10:23:12 +09:00
Yu Watanabe dca63b5b46
Merge pull request #17474 from yuwata/network-drop-link-deserialization-logic
network: drop link deserialization logic
2020-11-27 09:08:01 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Timo Rothenpieler b8162cd200 network: store full hardware address in Link struct
This passes the legacy ethernet address to functions in a lot of places,
which all will need migrated to handle arbitrary size hardware addresses
eventually.
2020-10-28 14:44:43 +01:00
Yu Watanabe 7b829a7b3b network: do not serialize/deserialize addresses
The link state file is always removed when networkd is stopping. So,
the deserialization logic does not work. Moreover, the ADDRESSES=
entry is not used by sd-network, so serialization is also not necessary.
2020-10-28 18:15:57 +09:00
Yu Watanabe 3def88503a network: set previous DHCP4 address in link->addresses_foreign
Previously, the address was taken from the state file, but DHCP4_ADDRESS=
entry was dropped by 46986251d6.
Moreover, the link state file is always removed when networkd is
stopping. Let's take the address from the list of enumerated addresses.
2020-10-28 15:44:05 +09:00
Yu Watanabe 9c914c0401
Merge pull request #17357 from yuwata/network-dhcp6-pd-announce-17353
network: add an option to control announcement of delegated prefix
2020-10-23 12:57:58 +09:00
Yu Watanabe 8a08bbfc98 network: drop static prefixes and static route prefixes earlier if IPv6PrefixDelegation=no or dhcpv6 2020-10-19 10:09:38 +09:00
Yu Watanabe 7abe175c00 network: also unref IPv4 ACD clients in Address objects
This should not change any behavior, as currently link_free_engines() is
always called after all addresses are dropped. But the function may be
used in other places in the future. So, let's also stop the clients.
2020-10-15 08:11:32 +09:00
Yu Watanabe a391901eb2 network: drop unnecessary conditions
sd_ipv4acd_stop() and sd_ipv4ll_stop() are idempotent.
2020-10-15 07:40:13 +09:00
Yu Watanabe c6a7531e0e network: voidify sd_ipv4acd_stop() at one place 2020-10-15 07:39:40 +09:00
Yu Watanabe 84add3cd2b network: drop conditions to check existence of each engine 2020-10-15 07:38:45 +09:00
Yu Watanabe b1476b5210 network: constify arguments 2020-10-13 20:30:38 +09:00
Yu Watanabe fe841414ef network: read peer address, label, broadcast from rtnl message
Then, Address objects in Network and Link can be easily compared by
address_equal().
2020-10-13 20:30:35 +09:00
Yu Watanabe 9b9c5fff16 network: directly compare with in_addr element for IPv4 case
When peer address is set, address_compare_func() (or address_equal())
does not work in link_is_static_address_configured(), as an Address object
stored in a Link does not contain peer addresses. So, we need to also
compare with in_addr element for IPv4 case.

Fixes #17304.
2020-10-13 20:30:16 +09:00
Yu Watanabe 13ffa39f8e network: rename network_verify_xxx() -> network_drop_invalid_xxx()
As 'verify' implies a boolean result.
2020-10-07 03:22:03 +09:00
Yu Watanabe 494b6b43cb network: fix masquerade setting logic
Previously, address_establish() took Address object stored in Network
object. And address_release() took Address object stored in Link
object. Thus, address_release() always did nothing.
2020-10-07 03:13:26 +09:00
Yu Watanabe cd1caf30c0 network: always use RT_SCOPE_HOST for IPv4 loopback addresses
For IPv6 case, use RT_SCOPE_HOST only when scope is not explicitly specified.
2020-10-07 03:13:18 +09:00
Yu Watanabe d93d655c40 network: update MAC address in IPv4 ACD clients
When the MAC address of a link is updated, an address on the link may
be under checking address duplication. Or, (currently such code is not
implemented yet, but) address duplication check may be restarted later.
For that case, the IPv4 ACD clients must use the new updated MAC address.
2020-10-07 02:59:34 +09:00
Yu Watanabe 490ccbd5e5 network: configure IPv4 DAD per link address
Previously, IPv4 DAD is configured in each Address object stored in
Network object. If a .network file matches multipe links, then it causes
an assertion. To prevent it, now IPv4 DAD is configured in each Address
object belogs to Link object.
2020-10-07 02:57:58 +09:00
Yu Watanabe 693ec5ca83 network: constify one argument 2020-10-07 02:57:54 +09:00
Yu Watanabe cde1f0e8fc network: introduce address_copy() 2020-10-07 02:54:01 +09:00
Yu Watanabe eaff204f09 network: do not update Address::flags in address_configure() 2020-10-07 02:50:51 +09:00
Yu Watanabe f5ee7d74af network: fix indentation 2020-10-07 02:50:51 +09:00
Yu Watanabe 4cf8500067 network: use sd_event stored in Manager 2020-10-07 02:50:51 +09:00
Yu Watanabe 51f5dfd8ba network: move link_enumerate_ipv6_tentative_addresses() 2020-10-07 02:50:51 +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 093e35334d network: header cleanup 2020-10-07 02:50:50 +09:00
Yu Watanabe 67a58eb378 network: make several functions static 2020-10-07 02:50:50 +09:00
Yu Watanabe aa651e88de network: manage addresses from pool by Set 2020-10-07 02:50:50 +09:00
Yu Watanabe 9cd9fc8f44 network: drop list of static addresses
[Address] sections are managed by both LIST and Hashmap. Let's drop the
list and manage them by OrderedHashmap.
2020-10-07 02:50:50 +09:00
Yu Watanabe 7818f8589a network: make address_free() return NULL 2020-10-07 02:50:50 +09:00
Yu Watanabe 2488e4d934 network: introduce link_stop_ipv4_dad() 2020-10-07 02:50:50 +09:00
Yu Watanabe b87d6a8284 network: move link_configure_ipv4_dad() 2020-10-07 02:50:50 +09:00
Yu Watanabe da4d3a612d network: introduce link_deserialize_addresses() 2020-10-07 02:50:50 +09:00
Yu Watanabe 3b31e2b718 network: introduce link_serialize_addresses() 2020-10-07 02:50:50 +09:00
Yu Watanabe 32400c2ff0 network: introduce network_verify_addresses() 2020-10-07 02:50:50 +09:00
Yu Watanabe 9a0ad16b26 network: update log messages
And drop unnecessary log for in_addr_to_string(), as its result is used
only for the consequent logs.
2020-10-07 02:49:17 +09:00