Lennart Poettering
e825610499
Merge pull request #16880 from yuwata/network-dhcp4-cleanups
...
network: DHCPv4 cleanups
2020-09-04 15:54:27 +02:00
Zbigniew Jędrzejewski-Szmek
459c41b9e2
Merge pull request #16881 from yuwata/network-routing-policy-rule-cleanups
...
network: routing policy rule cleanups
2020-09-04 12:57:20 +02:00
Yu Watanabe
2200c3cf56
network: fixes gateway assignment through DHCPv4
...
This fixes the following issue:
- If a DHCP lease does not contains router option, then routes with
`Gateway=_dhcp` setting introduce unexpected results.
This also makes several failure paths critical. And adjust warnings when
classless routes are provided.
2020-09-04 11:12:03 +02:00
Yu Watanabe
c45fdad66d
network: configure DHCP routes after DHCP address is ready
2020-09-04 09:05:45 +09:00
Yu Watanabe
687b3bc6f4
network: dhcp4: reset counter only when the lease address is new
2020-09-04 09:05:45 +09:00
Yu Watanabe
5acf54a063
network: dhcp4: stop IPv4ACD before assigning new address
2020-09-04 09:05:34 +09:00
Yu Watanabe
dce1cd4188
network: voidify return value of sd_ipv4acd_stop()
2020-09-04 09:04:43 +09:00
Yu Watanabe
5c72a6d5d3
network: logs about unknown key
2020-09-04 08:48:08 +09:00
Yu Watanabe
f405179d65
network: honor already specified family when parsing from= or to= in serialized rule
2020-09-04 08:48:08 +09:00
Yu Watanabe
9d6282d120
network: do not reallocate buffer
2020-09-04 08:48:04 +09:00
Yu Watanabe
d0ac05613b
network: serialize InvertRule= in [RoutingPolicyRule]
2020-09-04 08:47:22 +09:00
Yu Watanabe
1680b11df4
network: add whitespace after family= and priority= in serialized routing policy rule
...
This also makes priority= serialized only when its value is non-zero.
2020-09-04 08:44:19 +09:00
Yu Watanabe
3c94b20dd3
network: downgrade error level when the error is ignored
2020-09-04 08:44:14 +09:00
Yu Watanabe
7e60a37d04
network: move routing_policy_rule_read_full_file()
2020-09-04 08:42:01 +09:00
fangxiuning
6d95e7d9b2
tree-wide: drop pointless zero initialization ( #16900 )
2020-08-30 06:21:20 +09: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
876dc2b014
network: dhcp6: logs only new address
...
Closes #16731 .
2020-08-27 21:24:07 +02:00
Yu Watanabe
df696b1413
networkctl: label command does not take any argument
2020-08-27 16:32:13 +09:00
Zbigniew Jędrzejewski-Szmek
d521e6993d
Merge pull request #16824 from keszybz/no-such-unit-error
...
Add sd_bus_error_has_names() and use it to catch BUS_ERROR_NO_SUCH_UNIT
2020-08-25 09:16:25 +02:00
Zbigniew Jędrzejewski-Szmek
955a632971
tree-wide: use sd_bus_error_has_names() in more places
2020-08-24 19:48:26 +02:00
Clemens Gruber
f594b5feab
network: can: Fix CAN initialization
...
When introducing CAN-FD support, the .can_fd_mode was not initalized
with -1 and due to cm.mask containing the CAN_CTRLMODE_FD bit, it was
not ignored when FDMode was not configured but instead disabled.
The same thing happened when listen-only mode support was introduced.
On chips that do not support these features, this lead to an error:
can0: Failed to configure CAN link: Operation not supported
Fix it by intializing all the CAN related tristate variables
(.can_listen_only, .can_fd_mode and .can_non_iso) to -1.
2020-08-24 09:33:25 +02:00
Yu Watanabe
46b875fb80
network: do not fail if UseMTU=yes on DHCP lease lost
...
This fixes a bug introduced by 6906794dd1
.
Fixes #16768 .
2020-08-18 20:33:58 +02:00
Yu Watanabe
9b966cee43
network: wait for previous address removal before configuring static addresses
...
Fixes #16696 .
2020-08-08 12:41:03 +09:00
Yu Watanabe
b6766fb114
network: drop unnecessary bracket
2020-08-08 12:31:59 +09:00
Yu Watanabe
fb282d4e25
network: only process non-error message
2020-08-08 12:31:12 +09:00
Zbigniew Jędrzejewski-Szmek
d06bd2e785
Merge pull request #16596 from poettering/event-time-rel
...
Conflict in src/libsystemd-network/test-ndisc-rs.c fixed manually.
2020-08-04 16:07:03 +02:00
Yu Watanabe
2ac7eec3b5
network: fix use of uninitialized value
...
Follow-up for 6e537f62d7
.
2020-07-30 07:38:18 +02:00
Michael Marley
b209cff2ad
network: Fix "Unknown section 'DHCPv6PrefixDelegation'." message
...
Follow-up for 99e015e28c
2020-07-30 10:34:47 +09:00
Yu Watanabe
99e015e28c
network: rename settings about DHCPv6 Prefix Delegation
...
Closes #16602 .
2020-07-29 05:50:08 +09:00
Yu Watanabe
61c0ef4ff3
network: make RADVPrefixDelegation enum bitfield
...
This should not change any behavior.
2020-07-29 05:09:42 +09:00
Yu Watanabe
ea121d8f25
network: update address infomation even if link is in failed or linger state
...
As the link may be reconfigured later. If we do not update the address
information, then its setup state or operstate may not be updated
correctly.
2020-07-29 02:05:05 +09:00
Yu Watanabe
e55265184b
network: do not assume static addresses are configured
...
link_request_set_routes() is also called when a dynamic address is
configured. At that time, static addresses may not be configured yet.
Fixes #16546 .
2020-07-29 02:05:05 +09:00
Yu Watanabe
15797d6a2b
network: check at least one dynamic address is assigned when DHCP is enabled
2020-07-29 02:05:05 +09: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
1c09d84e42
network: rename ipv4ll_address -> ipv4ll_address_configured
2020-07-29 02:05:05 +09:00
Yu Watanabe
b0b9776656
network: ndisc: also remove old DNSSL or RDNSS records after an SLAAC address is ready
2020-07-29 02:05:05 +09:00
Yu Watanabe
69203fba70
network: ndisc: remove old addresses and routes after at least one SLAAC address becomes ready
...
Otherwise, the old addresses will exist in deperecated state.
2020-07-29 02:05:05 +09:00
Yu Watanabe
6e537f62d7
network: dhcp4: release old lease after the new address become ready
...
Previously, on DHCPv4 address renewal, the old address may be removed
while the new address is not ready yet.
This also simplifies the logic of removing address and routes.
2020-07-29 02:05:05 +09:00
Yu Watanabe
80b0e86084
network: make address/route_configure optionally return created Address/Route object
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
5f58af25e6
network: make link_check_ready() return earlier if the link is not in 'configuring' state
2020-07-29 02:05:05 +09:00
Yu Watanabe
3336e946da
network: ndisc: do not set configured flags when addresses or routes are not assigned yet
...
Just for safety.
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
97f000744f
network: introduce callback called when an address becomes ready
2020-07-29 02:05:00 +09:00
Yu Watanabe
3606ca659e
network: add debug log for configuring address
2020-07-29 01:50:54 +09:00
Lennart Poettering
39cf0351c5
tree-wide: make use of new relative time events in sd-event.h
2020-07-28 11:24:55 +02:00
Christian Göttsche
c8f12abc73
Fix clang-11 issues
...
Tested with clang 11.0.0-++20200715043845+0e377e253c1-1~exp1 on Debian sid
../src/network/test-networkd-conf.c:104:56: warning: adding 'int' to a string does not append to the string [-Wstring-plus-int]
test_config_parse_duid_rawdata_one(BYTES_0_128 + 2, 0, &(DUID){0, 128, BYTES_1_128});
~~~~~~~~~~~~^~~
../src/network/test-networkd-conf.c:104:56: note: use array indexing to silence this warning
test_config_parse_duid_rawdata_one(BYTES_0_128 + 2, 0, &(DUID){0, 128, BYTES_1_128});
^
& [ ]
1 warning generated.
../src/test/test-clock.c:52:17: warning: ignoring return value of function declared with 'warn_unused_result' attribute [-Wunused-result]
ftruncate(fileno(f), 0);
^~~~~~~~~ ~~~~~~~~~~~~
1 warning generated.
(gdb) run
Starting program: systemd/build/test-alloc-util
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
x1: 0x7fffffffd2d0
x2: 0x7fffffffdac0
y: 0x7fffffffd2cc
z: 0x7fffffffd2c0
cleanup2(0x7fffffffd2cc)
cleanup3(0x7fffffffd2c0)
cleanup1(0x7fffffffdac0)
cleanup1(0x7fffffffd2d0)
*** buffer overflow detected ***: terminated
Program received signal SIGABRT, Aborted.
__GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt full
set = {__val = {0, 18446744073709551615, 0, 0, 0, 0, 140737348658240, 140737348659520, 0, 0, 0, 0, 0, 0, 0, 0}}
pid = <optimized out>
tid = <optimized out>
ret = <optimized out>
save_stage = 1
act = {__sigaction_handler = {sa_handler = 0x22ff0, sa_sigaction = 0x22ff0}, sa_mask = {__val = {140737349888603, 4217127, 4217127, 4217127, 4217127, 4217383, 0, 0, 0, 0, 143329, 143344, 140737351162752, 8959, 18446744073709551328, 4289072}},
sa_flags = -138460788, sa_restorer = 0xffffffffffffffff}
sigs = {__val = {32, 0 <repeats 15 times>}}
ap = {{gp_offset = 24, fp_offset = 0, overflow_arg_area = 0x7fffffffd280, reg_save_area = 0x7fffffffd210}}
fd = <optimized out>
list = <optimized out>
nlist = <optimized out>
cp = <optimized out>
No locals.
No locals.
No locals.
No locals.
No locals.
l = 0
No locals.
p1 = 0x405500 "\223Nd\n\351\301mA\214\262A\247\306b\276\317\327\353\346k\035\024\273{\276&!kλ\233\217\t\207\276\327\347\351\355\307R\276\063{\235w=\237E\357\277KL\245\374\245\066M\201+\333\064\272\332g>1<@"
p2 = <optimized out>
i = <optimized out>
No locals.
2020-07-26 11:32:06 +02:00
Yu Watanabe
6f5d73aba6
network: compare with peer address if it is specified
...
Follow-ups for dfef713f3e
.
2020-07-23 16:37:56 +02:00
Yu Watanabe
2c62149509
network: ndisc: ignore duplicated IPv6Token=
2020-07-22 20:26:11 +09:00
Yu Watanabe
92ee90af47
network: ndisc: do not store duplicated data in Set
...
The Address objects in the set generated by ndisc_router_generate_addresses()
have the equivalent prefixlen, flags, prefered lifetime.
This commit makes ndisc_router_generate_addresses() return Set of
in6_addr.
2020-07-22 20:26:05 +09:00
Yu Watanabe
1b14222124
network: make bus methods sync link state file
2020-07-22 19:55:15 +09:00
Yu Watanabe
c2a6595014
network: introduce link_save_and_clean()
2020-07-22 19:55:14 +09:00
Yu Watanabe
f281fc1e95
tree-wide: use siphash24_compress_string() where it is applicable
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
Lennart Poettering
49f16281c9
tree-wide: use READ_FULL_FILE_CONNECT_SOCKET at various places
...
Let's use the new flag wherever we read key material/passphrases/hashes
off disk, so that people can plug in their own IPC service as backend if
they like, easily.
(My main goal was actually to support this for crypttab key files — i.e.
that you can specify AF_UNIX sockets as third column in crypttab — but
that's harder to implement, since the keys are read via libcryptsetup's
API, not ours.)
2020-07-21 10:32:01 +02:00
Lennart Poettering
f294470262
fileio: add explicit flag for generating world executable warning when reading file
2020-07-21 09:56:44 +02:00
Zbigniew Jędrzejewski-Szmek
2e3e2750bb
Merge pull request #16519 from yuwata/networkctl-altnames
...
networkctl: tiny cleanups about alternative names
2020-07-21 09:10:00 +02:00
Yu Watanabe
1cdea1a2f7
network: update one log message
2020-07-21 11:55:28 +09:00
Yu Watanabe
7695e2cbbe
network, resolve: use bus_message_read_ifindex() or friends
2020-07-21 04:08:22 +09:00
Yu Watanabe
10d4620467
util: introduce bus_mesage_read_dns_servers()
2020-07-21 04:08:22 +09:00
Yu Watanabe
4e11ddfdd3
network: add DBus method to set DNS server with port number and SNI
2020-07-21 04:08:22 +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
6458176514
network: do not save DNS= entries 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
807667f7ac
network: stop already running engines before updating MAC address
...
In NetworkdBridgeTests.test_bridge_configure_without_carrier of
systemd-networkd-tests.py
```
bridge99: MAC address: 2e:3a:ec:4d:d3:62
Assertion 'sd_ipv4ll_is_running(ll) == 0' failed at src/libsystemd-network/sd-ipv4ll.c:110, function int sd_ipv4ll_set_mac(sd_ipv4ll *, const struct ether_addr *)(). Ignoring.
bridge99: Could not update MAC address in IPv4LL client: Device or resource busy
```
2020-07-20 15:29:55 +09:00
Yu Watanabe
48c5398951
networkctl: do not ignore -EOPNOTSUPP when reading netlink message
...
If the kernel does not support alternative interface names, then
sd_netlink_message_read_strv() should just return -ENODATA.
2020-07-20 15:24:40 +09:00
Yu Watanabe
ae5b779252
networkctl: sort alternative names
2020-07-20 15:24:40 +09:00
Zbigniew Jędrzejewski-Szmek
d735e4f2d6
Merge pull request #16505 from yuwata/network-manage-foreign-routes-cleanups
...
network: do not enumerate foreign routes when ManageForeignRoutes=no, and tiny cleanups
2020-07-20 07:48:57 +02:00
YmrDtnJu
a9c9b18a95
networkd: Use NLM_F_ACK on the netlink message to add a neighbor.
...
sd_netlink_message_set_flags is called without NLM_F_ACK which results in
a timeout while networkd is waiting for an ACK that the kernel will never send.
2020-07-20 11:30:35 +09:00
Yu Watanabe
a8c10331b4
network: replace NDISC -> NDisc in log messages
2020-07-18 05:51:41 +09:00
Yu Watanabe
5eec0a0810
network: introduce address_exists() helper function
2020-07-18 05:51:41 +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
Yu Watanabe
13e8a49a58
network: ndisc: any failures in processing event make the link in failed state
...
Also adjust log levels.
2020-07-17 01:18:44 +09:00
Yu Watanabe
c97785168b
network: radv: clean up conf parsers
2020-07-17 01:16:38 +09:00
Yu Watanabe
d96edb2c6e
network: downgrade log level in conf parsers
2020-07-17 00:40:09 +09:00
Yu Watanabe
f766d9af38
network: dhcp4: add two warnings
2020-07-16 10:54:16 +09:00
Yu Watanabe
153cf04139
network: dhcp4: fix another race with SendDecline=yes
...
If the SD_IPV4ACD_EVENT_BIND event happens before all routes are
assigned, then the link stuck in configuring state.
2020-07-16 10:54:08 +09:00
Yu Watanabe
75be72d139
network: dhcp4: also release old lease in dhcp_lease_lost()
...
The lease lost may happen during renewing address. If it happens,
assertion hits in dhcp4_release_old_lease().
2020-07-16 10:51:46 +09:00
Christian Göttsche
aeba8dd523
network: fix typo
2020-07-16 08:45:42 +09:00
Yu Watanabe
43bf28741f
network: drop doubled white space
2020-07-15 17:15:25 +09:00
Yu Watanabe
93b0b88c3a
network: free address when it is removed
2020-07-15 17:15:25 +09:00
Yu Watanabe
6906794dd1
network: dhcp4: do not assign new address before old one is not removed
...
If DHCP4 client lost a lease, and then soon acquire new lease, then
the removal of the old address may not be completed. If that happens,
and the new and old addresses are the same, then the new address will be
considered as a foreign address. Such a situation can occur when the
DHCP4 server is restarted.
This makes networkd wait for the removal of the old address when a new
lease is acquired.
This also makes the link in configuring state when renewing address.
2020-07-15 17:15:25 +09:00
Yu Watanabe
5d976f5f64
network: do not call link_check_ready() in link_request_set_routing_policy_rule()
...
It will be called in link_request_set_nexthop() or serveral handlers().
2020-07-15 17:15:25 +09:00
Yu Watanabe
0c816fcc7b
network: make link_request_set_nexthop() called from link_request_set_routes() or route_handler()
...
Then we can drop static_routes_ready() flag.
2020-07-15 17:15:25 +09:00
Yu Watanabe
659ad3a0af
network: do not make link in configured state when no address is assigned
...
When DHCP6 and RA are enabled, and RA does not provide any addresses,
then link may become configured state even if no address is assigned,
due to the time-lag between RA completion and DHCP reply.
This makes if DHCP is explicitly enabled, then link must have at least
one valid address to be in the configured state.
2020-07-15 17:15:25 +09:00
Yu Watanabe
d98c546dac
network: ndisc: split ndisc_configured flag into for addresses and routes
2020-07-15 17:15:25 +09:00
Yu Watanabe
01c344bdd4
network: ndisc: do not ignore remaining addresses
...
Follow-up for c24c83dc67
.
2020-07-15 17:15:25 +09:00
Yu Watanabe
39373cb984
network: add debugging log why link is not in configured state yet
2020-07-15 17:15:16 +09:00
Yu Watanabe
eb01a2dfb1
network: make link_request_set_nexthop() static
2020-07-15 17:14:30 +09:00
Yu Watanabe
a4623f84ed
network: add a debugging log
2020-07-15 17:14:30 +09:00
Yu Watanabe
feb596b5c3
network: include error code in the log message
2020-07-15 17:14:30 +09:00
Yu Watanabe
2a877f4560
network: set dhcp6_xxx_configured flag after routes/addresses are assigned
2020-07-15 17:14:30 +09:00
fangxiuning
d67b1d18fc
bus: use bus_log_parse_error to print message
2020-07-12 06:33:48 +09:00
Alvin Šipraga
0d0de133f0
network: add support for MACVLAN source mode
...
Add support for creating a MACVLAN interface in "source" mode by
specifying Mode=source in the [MACVLAN] section of a .netdev file.
A list of allowed MAC addresses for the corresponding MACVLAN can also
be specified with the SourceMACAddress= option of the [MACVLAN] section.
An example .netdev file:
[NetDev]
Name=macvlan0
Kind=macvlan
MACAddress=02:DE:AD:BE:EF:00
[MACVLAN]
Mode=source
SourceMACAddress=02:AB:AB:AB:AB:01 02:CD:CD:CD:CD:01
SourceMACAddress=02:EF:EF:EF:EF:01
The same keys can also be specified in [MACVTAP] for MACVTAP kinds of
interfaces, with the same semantics.
2020-07-08 18:01:52 +02:00
Lennart Poettering
24e2494407
Merge pull request #16385 from JackFangXN/master
...
table add table_log_xx_error()
2020-07-08 12:12:29 +02:00
fangxiuning
4b6607d949
table use table_log_print_error() instead of table_log_show_error
2020-07-08 15:16:52 +08:00
Yu Watanabe
3650173fec
network: make address_handler() static
2020-07-07 19:48:38 +02:00
Yu Watanabe
a211ff4b84
network: introduce own address handler for dhcp6 delegated prefix
...
Fixes #16365 .
2020-07-07 19:48:26 +02:00
Zbigniew Jędrzejewski-Szmek
0da425df65
networkd: use capitalized "IP" and "TOS" in messages
2020-07-07 12:06:26 +02:00