Commit Graph

30580 Commits

Author SHA1 Message Date
Thomas Haller
c09b37f3c7 platform/netlink: add flags argument to nl_socket_new()
The real purpose is that we set the socket options before bind().
For that, we need to be able to specify the flag during nl_socket_new().

Another reason is that these are common questions to ponder while
creating a netlink socket. There shouldn't be several setter functions,
just specify the flag right away. These parameters are not going to
change afterwards (at least, we don't need/use that and we don't have
API for that either).
2022-06-24 11:03:37 +02:00
Thomas Haller
919a61bc53 platform/netlink: extend nl_nlmsghdr_to_str() for genl messages
Print more details for generic netlink messages.

Also, pass the group that we obtained via NETLINK_PKTINFO.

Also, factor out simple to-string methods.
2022-06-24 11:03:36 +02:00
Thomas Haller
51b707357d platform/netlink: add reading NETLINK_PKTINFO in nl_recv()
We will need this, for getting nl_pktinfo control messages
that contain the extended destination group number.

Also, drop NL_SOCK_PASSCRED. It was only used to not iterate over the
control messages, but doing that should be cheap.
2022-06-24 11:03:35 +02:00
Thomas Haller
39320e26cd platform/netlink: minor cleanup in _netlink_recv_handle()
- drop "abort_parsing" variable, it was redundant.
- rename event_valid_msg(), as this is about NETLINK_ROUTE.
- rename "err" variable to "retval".
2022-06-24 11:03:35 +02:00
Thomas Haller
88df542b6b platform/netlink: move generic code in _netlink_recv_handle()
This also applies to genl messages. Move the code.
2022-06-24 11:03:34 +02:00
Thomas Haller
b1abd3ebdd platform/netlink: add nl_msg_lite struct to avoid allocating netlink message
There really is no need for two(!) heap allocations while parsing
the netlink message. We already have it in the buffer. Just use it.

Note that netlink attributes need to be aligned to 4 bytes. But
nlmsg_next() already ensures that, so not even for alignment purpose we
need to clone the message.

Create a new "struct nl_msg_lite" that can hold pointers to everything
we need.
2022-06-24 11:03:34 +02:00
Thomas Haller
1460adc918 platform/netlink: add const modifier for genl functions 2022-06-24 11:03:33 +02:00
Thomas Haller
59f577df56 platform/netlink: add const modifier to netlink header pointers
They are not supposed to be modified.
2022-06-23 20:36:53 +02:00
Thomas Haller
80afc691d5 platform/netlink: add "rxbuf/txbuf" arguments to nl_socket_new() 2022-06-23 20:36:52 +02:00
Thomas Haller
260d693ec4 platform/netlink: add "blocking" argument to nl_socket_new()
Whether we use a socket blockingly or non-blocking is usually determined
upfront and does not change. Make it a parameter of nl_socket_new().
Also, it saves an additional syscall.
2022-06-23 20:36:52 +02:00
Thomas Haller
6b0f67b736 connectivity: skip unexpected address families in system_resolver_resolve_cb()
This actually cannot happen, because GInetAddress is either
IPv4 or IPv6. Still.
2022-06-23 17:11:28 +02:00
Lubomir Rintel
0e2ddfd071 nmcli/devices: fix a crash
This is not good:

  $ nmcli device delete nm-bond
  Segmentation fault (core dumped)

Fixes: 5f9d2927ed ("nmcli/devices: use GPtrArray from get_device_list() directly")
2022-06-23 15:12:19 +02:00
Lubomir Rintel
9f9c82f39b merge: branch 'lr/nmcli-checkpoint'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1207
2022-06-23 11:49:48 +02:00
Beniamino Galvani
acdd31ed8d initrd: add comment on top of connections and conf snippets
Example:

  $ cat /run/NetworkManager/conf.d/15-carrier-timeout.conf
  # Created by nm-initrd-generator (from "rd.net.timeout.carrier")

  [device-15-carrier-timeout]
  match-device=*
  carrier-wait-timeout=12000
2022-06-23 09:50:50 +02:00
Beniamino Galvani
2c5846feec initrd: print generated configuration snippets
Instead of just printing something like "*** Carrier timeout 10sec",
print the actual configuration snippet that was generated.
2022-06-23 09:50:48 +02:00
Beniamino Galvani
a216739e09 device: stop ac6 grace time when ip6ll is ready in shared mode
The IPv6 shared mode starts IPv6 autoconf to send router
advertisements. IPv6 autoconf schedules a 30-second timeout waiting
for a link-local address to appear. When the link-local address
appears, we need to cancel the timeout.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1030
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1266
2022-06-22 18:05:55 +02:00
Thomas Haller
3ee61f0913 libnm/docs: add comment about background scanning to wifi.bssid property 2022-06-21 10:36:05 +02:00
Yuri Chornoivan
400ceb0f3b po: Update Ukrainian translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1265
2022-06-20 10:13:22 +02:00
Thomas Haller
bffb753515 wifi: merge branch 'owe-fixes'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1259
2022-06-17 19:52:11 +02:00
David Bauer
02e35f5b20 nmcli: distinguish OWE-TM from OWE BSS
Distinguish a OWE-TM enabled BSS (which itself is unencrypted) from the
OWE BSS actually employing encryption.

Signed-off-by: David Bauer <mail@david-bauer.net>
2022-06-17 19:50:40 +02:00
David Bauer
21a19383c8 libnm: fix compatibility of OWE-TM with unsecure profiles
A unsecure profile can be used with a OWE-TM network, in which case it
uses the non-OWE BSS.

Signed-off-by: David Bauer <mail@david-bauer.net>
2022-06-17 19:50:40 +02:00
David Bauer
482885e6e9 supplicant/config: supplicant: prevent OWE downgrade
Prevent downgrade of Enhanced Open / OWE connection profiles
to unencrypted connections by forcing wpa_supplicant to use OWE.

Signed-off-by: David Bauer <mail@david-bauer.net>
2022-06-17 19:50:40 +02:00
Thomas Haller
81b4b87c59 platform: merge branch 'th/platform-genl-1'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1262
2022-06-17 19:48:47 +02:00
Thomas Haller
2f8d8bba8f platform: extend netlink processing of messages for different protocols
Later, the same loop should also handle genl.
2022-06-17 19:40:37 +02:00
Thomas Haller
ddbcd668ec platform: move credential check in event_handler_recvmsgs() 2022-06-17 19:40:37 +02:00
Thomas Haller
f5d9428468 platform/netlink: add netlink_protocol argument to nl_nlmsghdr_to_str()
The meaning of the header depends on the netlink protocol. Add that parameter,
so we can also handle genl.
2022-06-17 19:40:37 +02:00
Thomas Haller
3ab66fd341 platform: move nl_recv() to separate function
Will be reused later.
2022-06-17 19:40:37 +02:00
Thomas Haller
2d211cfd5c platform: log information about (sync) genetlink socket 2022-06-17 19:40:37 +02:00
Thomas Haller
c7fea44e47 platform/trivial: rename netlink sockets in NMLinuxPlatform
- "priv->nlh" to "priv->sk_rtnl": as we also have an genl socket,
   "nlh" is not a good name. The point is that this is rtnetlink.
   Also, "h" sounds like a handle, that is, a file descriptor.
   Make this clearer with a "sk_" prefix.

- "priv->genl" to "priv->sk_genl_sync": This socket is only used for synchronous
   operations, that is, it is passed to various independent components, that use
   it to send a request and wait for the response (while consuming all messages).
   We will have a use for a second socket, hence the "_sync" part.
   The "sk_" prefix is for consistency with "sk_rtnl".

- "priv->event_source" to "priv->rtnl_event_source". Just make it
  clearer, that this is for the rtnetlink socket. In any case,
  this field is hardly used at all, it can have a sturdy name.
2022-06-17 19:40:36 +02:00
Thomas Haller
aa2fd36db4 platform: require generic netlink socket
Sockets are really a fundamental thing we require to operate.
We cannot meaningfully operate, if we fail to create them.
That is also why a too low file descriptor limit is fatal
and unsupported. This is similar with out of memory situations.

Just require that we always are able to create the generic
netlink socket.
2022-06-17 19:40:36 +02:00
Thomas Haller
9c8b957704 platform: drop _genl_sock() function and directly access data 2022-06-17 19:40:36 +02:00
Thomas Haller
67d64fd4e5 platform/netlink: also set NETLINK_EXT_ACK for genl socket
There are only two callers of nl_socket_new(). One for NETLINK_GENERIC
and one for NETLINK_ROUTE.

We already were enabling ext-ack for the rtnetlink socket. Also enable
it for the genl socket.

Do that, but just moving this inside nl_socket_new(). I cannot imagine a
case where we don't want this.
2022-06-17 19:40:36 +02:00
Thomas Haller
f96fbc8ebe platform/netlink: combine nl_socket_alloc() and nl_connect()
Create and use new nl_socket_new().

nl_socket_alloc() really does nothing but allocating the struct and
initializing the fd to -1. In all cases, we want to call nl_connect()
right after.

Combine the two. Then we also cannot  have a "struct nl_sock" without a
valid fd. This means several error checks can be dropped.

Note that former nl_connect() did several things at once. Maybe, for
more flexibility one would need to tweak what should be done there.
For now that is not necessary. In any case, if we need more flexibility,
then we would control what nl_connect() (now nl_socket_new()) does, and not
the split between nl_socket_alloc() and nl_connect().
2022-06-17 19:40:20 +02:00
Thomas Haller
4a22abdda1 platform/netlink: add nm_auto_nlsock cleanup macro 2022-06-17 19:38:57 +02:00
Thomas Haller
612528af89 libnm/docs: elaborate how ipv4.dns-search/ipv6.dns-search works 2022-06-17 19:32:41 +02:00
Beniamino Galvani
2807f6a893 dhcp: nettools: save the lease after it gets accepted
Currently the lease gets saved only on the extended (renewal)
event. Also save it after it gets accepted.

Fixes: 52a0fe584c ('dhcp/nettools: better track currently granted lease')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1261
2022-06-17 18:11:30 +02:00
Beniamino Galvani
393bc628ff dhcp: wait DAD completion for DHCPv6 addresses
Wait that addresses received through DHCPv6 complete duplicate address
detection before reporting that the lease can be used.

Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')

https://bugzilla.redhat.com/show_bug.cgi?id=2096386
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1258
2022-06-16 16:26:14 +02:00
Thomas Haller
7cfa8a01cd cli: reformat file to look better
Comments on the same line as field names are not rendered well by clang-format.
Even if manually edited, it seems not a preferable way to comment on a field.
Move the comment in the line before.
2022-06-16 11:02:20 +02:00
Thomas Haller
113fe2aaec build: add missing example files to "Makefile.examples" for dist 2022-06-16 09:41:01 +02:00
Thomas Haller
5218934244 build: sort files in Makefile.examples 2022-06-16 09:41:01 +02:00
liaohanqin
5f530904de feat: add example for wifi sae connection
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1247
2022-06-16 09:40:55 +02:00
Fernando Fernandez Mancera
3e4d084998 ifcfg-rh: fix wrong type for vint64 variable 2022-06-16 02:14:31 +02:00
Fernando Fernandez Mancera
87eb61c864 libnm: support wait-activation-delay property
The property wait-activation-delay will delay the activation of an
interface the specified amount of milliseconds. Please notice that it
could be delayed some milliseconds more due to other events in
NetworkManager.

This could be used in multiple scenarios where the user needs to define
an arbitrary delay e.g LACP bond configure where the LACP negotiation
takes a few seconds and traffic is not allowed, so they would like to
use nm-online and a setting configured with this new property to wait
some seconds. Therefore, when nm-online is finished, LACP bond should be
ready to receive traffic.

The delay will happen right before the device is ready to be activated.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1248

https://bugzilla.redhat.com/show_bug.cgi?id=2008337
2022-06-16 02:14:21 +02:00
Lubomir Rintel
c861a7e1d8 release: bump version to 1.39.7 (development) 2022-06-15 17:49:23 +02:00
Lubomir Rintel
1c17e55627 nmcli/devices: add "checkpoint" command
This is an interface to the Checkpoint/Restore functionality that's
available for quite some time. It runs a command with a checkpoint taken
and rolls back unless success is confirmed before the checkpoint times
out:

  $ nmcli dev checkpoint eth0 -- nmcli dev dis eth0
  Device 'eth0' successfully disconnected.
  Type "Yes" to commit the changes: No
  Checkpoint was removed.

The details about how it's used are documented in nmcli(1) and
nmcli-examples(7).
2022-06-15 12:26:08 +02:00
Lubomir Rintel
47eaf963e3 nmcli: be less insistant on exiting when readline() gets no input
When the input ends, we indeed eventually want to shut down.

Nevertheless, it might be that we terminated the input *because* we're
already shutting down and want do do our cleanup. Let's not take the
shortcut to nmc_exit() in case the main loop is no longer running.

This doesn't affect existing uses of nmc_readline(), but will be useful
in a future patch.
2022-06-15 12:13:26 +02:00
Lubomir Rintel
5f9d2927ed nmcli/devices: use GPtrArray from get_device_list() directly
This makes get_device_list() return an array of NMDevices with a
reference taken and a destroy notifier that unhooks disconnect_state_cb,
so that it could replace the GSList of the same utility used by
disconnect/delete commands.

Suggested-by: Thomas Haller <thaller@redhat.com>
2022-06-15 12:13:26 +02:00
Lubomir Rintel
2074b28976 nmcli/devices: return GPtrArray instead of GSList from get_device_list()
A pointer array is slightly more efficient here, since we don't really
need the ability to insert elements in the middle. In fact, we'd prefer
if we could just add to the end, so that we'd spare some callers from a
need to do a g_slist_reverse().

Even though that alone being a good reason to use a GPtrArray instead of
GSList, I'm doing this for so that I could actually use the returned value
as-is in a call to nm_client_checkpoint_create() in a future patch.
2022-06-15 12:13:26 +02:00
Lubomir Rintel
767afeffd8 nmcli/devices: make get_device_list() terminate on "--"
Don't consider "--" a device name. Instead, treat it as a signal to stop
reading the device list.

If a caller expects nothing beyond the device names, it now has to
check.
2022-06-15 12:13:26 +02:00
Lubomir Rintel
d576f4df44 nmcli/devices: make get_device_list() shift argc/argv
Prior to this patch, get_device_list() would give the caller no clue
about how many options did it consume. That is okay -- it would always
process all argument until the end, so the no callers would really care.

In a further patch, I'd like to allow termination of the device name
list (with a "--" arguments), so it will be possible to specify further
arguments.

Let's change the protype of this routine to use pointers to argc/argv,
that it will be possible to adjust them.
2022-06-15 12:13:26 +02:00