Commit Graph

3101 Commits

Author SHA1 Message Date
Yu Watanabe d9d6a10bce network: set protocol to route assigned through DHCP6 or DHCP6-PD 2020-12-04 11:23:23 +09:00
Yu Watanabe 575f14eef0 network: make IPv6 routes with reject type managed by Manager 2020-12-04 11:23:23 +09:00
Yu Watanabe 6c252588df network: introduce route_type_is_reject() helper 2020-12-04 11:23:23 +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 df8aa08642 network: do not set broadcast if prefixlen is 31 or 32
After fe841414ef, broadcast address is
also compared with existing one to determine whether the address is
foregin or not. So, the address object should not contain unnecessary
information.

Fixes #17803.
2020-12-03 10:22:50 +09:00
Zbigniew Jędrzejewski-Szmek 9c2c6692f3
Merge pull request #17707 from yuwata/network-fix-reconfigure
network: fix race in reconfiguring link
2020-12-02 15:10:34 +01:00
Zbigniew Jędrzejewski-Szmek efbbdf2923
Merge pull request #17798 from yuwata/ipv4ll-follow-ups
network: improve debug logs and add tests for IPv4LL
2020-12-02 14:59:33 +01:00
walbit-de 2d453f3597
network: add Protocol= to vlan netdev (#17794) 2020-12-02 14:58:02 +01:00
Yu Watanabe 59c31eba49 network: stop to assign UUID when reconfiguring link
This fixes the following race in reconfiguring link:
1. an interface requests UUID.
2. the interface is reconfigured and link_configure() is called.
3. sd-lldp client is started on the interface (it is enabled by default).
4. networkd acquires UUID, and get_product_uuid_handler() calls
   link_configure() for the link again.
5. link_lldp_rx_configure() fails to set ifindex for already running
   sd-lldp client.
6. the link enters failed state.
2020-12-02 20:31:39 +09:00
Yu Watanabe f63e09ef75 network: use bus_error_message() 2020-12-02 20:31:39 +09:00
Yu Watanabe 5f016e326d network: add debug log about requesting DHCP address
This addresses
https://github.com/systemd/systemd/pull/17474#discussion_r515996491.
2020-12-02 18:50:45 +09:00
Zbigniew Jędrzejewski-Szmek 0a67dd8310
Merge pull request #17692 from yuwata/ipv4ll
network: fold ipv4ll fallback modes into normal ipv4ll addressing
2020-12-01 21:59:30 +01:00
Lennart Poettering 986311c2da fileio: teach read_full_file_full() to read from offset/with maximum size 2020-12-01 14:17:47 +01:00
Yu Watanabe 53ec5dd028 network: use IN_SET() macro
Follow-up for 1d370b2c18.
2020-11-30 12:41:41 +09:00
Yu Watanabe 0d0799daf4 network: treat IPv4LL is one of dynamic addressing protocol
This makes an IPv4LL address optional when multiple dynamic
addressing protocols are enabled.
2020-11-30 12:41:41 +09:00
Yu Watanabe 0b4b66cc53 network: simplify the condition about ipv4ll is enabled or not 2020-11-30 12:41:41 +09:00
Yu Watanabe d19b993983 network: shorten link_check_ready() a bit 2020-11-30 12:41:41 +09:00
Yu Watanabe 8ccae2dd2d network: stop IPv4LL engine when DHCPv4 address is successfully acquired 2020-11-30 12:41:30 +09:00
Zbigniew Jędrzejewski-Szmek 0107b769b1 networkd: start ipv4ll when dhcp has trouble getting a lease
Fixes #13316.
2020-11-30 12:37:36 +09:00
Zbigniew Jędrzejewski-Szmek 3ca1fab70a networkd: merge ll addressing fallback modes into normal "boolean" values
They are not really boolean, because we have both ipv4 and ipv6, but
for each protocol we have either unset, no, and yes.

From https://github.com/systemd/systemd/issues/13316#issuecomment-582906817:
LinkLocalAddressing must be a boolean option, at least for ipv4:
- LinkLocalAddressing=no => no LL at all.

- LinkLocalAddressing=yes + Static Address => invalid configuration, warn and
  interpret as LinkLocalAddressing=no, no LL at all.

(we check that during parsing and reject)

- LinkLocalAddressing=yes + DHCP => LL process should be subordinated to the
  DHCP one, an LL address must be acquired at start or after a short N
  unsuccessful DHCP attemps, and must not stop DHCP to keeping trying. When a
  DHCP address is acquired, drop the LL address. If the DHCP address is lost,
  re-adquire a new LL address.

(next patch will move in this direction)

- LinkLocalAddressing=fallback has no reason to exist, because LL address must
  always be allocated as a fallback option when using DHCP. Having both DHCP
  and LL address at the same time is an RFC violation, so
  LinkLocalAdressing=yes correctly implemented is already the "fallback"
  behavior. The fallback option must be deprecated and if present in older
  configs must be interpreted as LinkLocalAddressing=yes.

(removed)

- And for IPv6, the LinkLocalAddress option has any sense at all? IPv6-LL
  address aren't required to be always set for every IPv6 enabled interface (in
  this case, coexisting with static or dynamic address if any)? Shouldn't be
  always =yes?

(good question)

This effectively reverts 29e81083bd. There is no
special "fallback" mode now, so the check doesn't make sense anymore.
2020-11-30 12:37:36 +09:00
Yu Watanabe bb2d0a24f3
Merge pull request #17761 from keszybz/documentation-followups
Two tiny fixlets
2020-11-29 05:32:33 +09:00
Zbigniew Jędrzejewski-Szmek 78cafcbc7e test-networkd-conf: add missing assert_se
Coverity CID#1437351. Fixup for f706340979.
2020-11-28 11:27:31 +01:00
Yu Watanabe 72f092815a network: fix return values 2020-11-27 14:35:20 +09:00
Yu Watanabe 5a9494bedb network: use SYNTHETIC_ERRNO() macro 2020-11-27 14:35:20 +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 0d5eb02134
Merge pull request #17478 from yuwata/split-network-internal
libsystemd-network: split network-internal.c
2020-11-27 09:04:19 +09:00
Jörg Thalheim 1d370b2c18 networkd/dhcp6: allow layer3 devices without MAC
Devices with multicast but without mac addresses i.e. tun devices
are not getting setuped correctly:

$ ip tuntap add mode tun dev tun0
$ ip addr show tun0
16: tun0: <NO-CARRIER,POINTOPOINT,MULTICAST,NOARP,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 500
    link/none
$ cat /etc/systemd/network/tun0.network
[Match]
Name = tun0

[Network]
Address=192.168.1.1/32
$ ./systemd-networkd
tun0: DHCP6 CLIENT: Failed to set identifier: Invalid argument
tun0: Failed
2020-11-23 13:56:48 +01:00
Zbigniew Jędrzejewski-Szmek 485a9202ba
Merge pull request #17643 from keszybz/man-news-independent
NEWS and man page tweaks
2020-11-17 17:14:14 +01:00
Zbigniew Jędrzejewski-Szmek dbc29e9175 network: use the common "cannot" form
Just for consistency.
2020-11-17 10:55:36 +01:00
Zbigniew Jędrzejewski-Szmek 7ad41997d1 man/systemd.netdev: remove bogus markup
There is no "Multicast" constant, and NULL doesn't make sense in the
context of addresses.
2020-11-17 10:55:12 +01:00
Yu Watanabe 0e686feaff network: honor M or O flag in RA even if IPv6AcceptRA.DHCPv6Cleint=always
Follow-up for ac24e418d9.

The original motivation of the commit and RFE #15339 is to start dhcpv6
client in managed mode when neither M nor O flag is set in the RA.
But, previously, if the setting is set to "always", then the DHCPv6
client is always started in managed mode even if O flag is set in the
RA. Such the behavior breaks RFC 7084.
2020-11-16 18:59:24 +09:00
Christof Efkemann cabe57119f networkd: fix default value of DHCPv6Client
The configuration of networkd has a DHCPv6Client setting in its
[IPv6AcceptRA] section, which, according to the man page, can be
a boolean, or the special value "always". The man page states
that "true" is the default.

The default value is implemented in src/network/networkd-network.c
by setting field ipv6_accept_ra_start_dhcp6_client of network to
true. However, this field is not a boolean, but an enum type
IPv6AcceptRAStartDHCP6Client (src/network/networkd-ndisc.h).

Setting ipv6_accept_ra_start_dhcp6_client to true effectively
corresponds to the enum value IPV6_ACCEPT_RA_START_DHCP6_CLIENT_ALWAYS,
resulting in the DHCPv6Client setting having the default value
"always".

This patch changes the initialisation to the correct enum value
IPV6_ACCEPT_RA_START_DHCP6_CLIENT_YES.
2020-11-16 16:09:37 +09:00
Jörg Thalheim d7aa78c32f meson: add option to skip installing to $sysconfdir
This is useful for development where overwriting files out side
the configured prefix will affect the host as well as stateless
systems such as NixOS that don't let packages install to /etc but handle
configuration on their own.

Alternative to https://github.com/systemd/systemd/pull/17501

tested with:

$ mkdir inst build && cd build
$ meson \
  -Dcreate-log-dirs=false \
  -Dsysvrcnd-path=$(realpath ../inst)/etc/rc.d \
  -Dsysvinit-path=$(realpath ../inst)/etc/init.d \
  -Drootprefix=$(realpath ../inst) \
  -Dinstall-sysconfdir=false \
  --prefix=$(realpath ../inst) ..
$ ninja install
2020-11-12 11:21:46 +01:00
Yu Watanabe 2075e596cf network: convert router lifetime from usec_t to uint16_t 2020-11-10 00:04:52 +09:00
Yu Watanabe 71a5db49fd network: make default router lifetime to 30min
Closes #17527.
2020-11-10 00:04:42 +09:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Lennart Poettering d3dcf4e3b9 fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name
This beefs up the READ_FULL_FILE_CONNECT_SOCKET logic of
read_full_file_full() a bit: when used a sender socket name may be
specified. If specified as NULL behaviour is as before: the client
socket name is picked by the kernel. But if specified as non-NULL the
client can pick a socket name to use when connecting. This is useful to
communicate a minimal amount of metainformation from client to server,
outside of the transport payload.

Specifically, these beefs up the service credential logic to pass an
abstract AF_UNIX socket name as client socket name when connecting via
READ_FULL_FILE_CONNECT_SOCKET, that includes the requesting unit name
and the eventual credential name. This allows servers implementing the
trivial credential socket logic to distinguish clients: via a simple
getpeername() it can be determined which unit is requesting a
credential, and which credential specifically.

Example: with this patch in place, in a unit file "waldo.service" a
configuration line like the following:

    LoadCredential=foo:/run/quux/creds.sock

will result in a connection to the AF_UNIX socket /run/quux/creds.sock,
originating from an abstract namespace AF_UNIX socket:

    @$RANDOM/unit/waldo.service/foo

(The $RANDOM is replaced by some randomized string. This is included in
the socket name order to avoid namespace squatting issues: the abstract
socket namespace is open to unprivileged users after all, and care needs
to be taken not to use guessable names)

The services listening on the /run/quux/creds.sock socket may thus
easily retrieve the name of the unit the credential is requested for
plus the credential name, via a simpler getpeername(), discarding the
random preifx and the /unit/ string.

This logic uses "/" as separator between the fields, since both unit
names and credential names appear in the file system, and thus are
designed to use "/" as outer separators. Given that it's a good safe
choice to use as separators here, too avoid any conflicts.

This is a minimal patch only: the new logic is used only for the unit
file credential logic. For other places where we use
READ_FULL_FILE_CONNECT_SOCKET it is probably a good idea to use this
scheme too, but this should be done carefully in later patches, since
the socket names become API that way, and we should determine the right
amount of info to pass over.
2020-11-03 09:48:04 +01: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
Zbigniew Jędrzejewski-Szmek 58f848148f
Merge pull request #17444 from BtbN/fix_ib_dhcp4
networkd: fix DHCP on InfiniBand interfaces
2020-10-29 19:27:29 +01:00
Zbigniew Jędrzejewski-Szmek e61f999755
Merge pull request #17472 from keszybz/spdx-license-headers
More SPDX license headers
2020-10-29 19:05:05 +01:00
Zbigniew Jędrzejewski-Szmek 4368277c74 tree-wide: use the usual SPDX header for our own files 2020-10-29 10:47:20 +01:00
Yu Watanabe 5722fb89bc net-condition: introduce struct NetMatch 2020-10-29 15:04:52 +09:00
Yu Watanabe 26f4d32365 meson: drop libsystemd_network from several binaries
This reduces the size of udevadm:

Before:
```
$ ll udevadm
-rwxrwxr-x 1 watanabe watanabe 1203800 Oct 29 01:36 udevadm
```

After:
```
$ ll udevadm
-rwxrwxr-x 1 watanabe watanabe 1094384 Oct 29 01:38 udevadm
```
2020-10-29 14:23:49 +09:00
Yu Watanabe 01ab92af71 tree-wide: drop unnecessary inclusion of network-internal.h 2020-10-29 14:23:49 +09:00
Yu Watanabe 7e19cc5462 net-condition: move net_match_config() and related conf parsers 2020-10-29 14:23:49 +09:00
Yu Watanabe 1929ed0e58 sd-network: move link_get_type_string() 2020-10-29 14:23:49 +09:00
Yu Watanabe 796aa313b3 network: move config_parse_bridge_port_priority() 2020-10-29 14:23:49 +09:00