Commit graph

30600 commits

Author SHA1 Message Date
Lubomir Rintel
c36b01c6a7 platform: fix build with kernels < 5.7
Fixes: 919a61bc53 ('platform/netlink: extend nl_nlmsghdr_to_str() for genl messages')
2022-06-25 19:16:53 +02:00
Lubomir Rintel
33688caabc merge: branch 'lr/ask-mode'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1215
2022-06-24 17:17:59 +02:00
Yuri Chornoivan
06d31500dc po: update Ukrainian translation
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1275
2022-06-24 15:09:55 +02:00
Beniamino Galvani
f8885d0724 core: avoid stale entries in the DNS manager for non-virtual devices
_dev_l3_register_l3cds() schedules a commit, but if the device has
commit type NONE, that doesn't emit a l3cd-changed. Do it manually,
to ensure that entries are removed from the DNS manager.

Related: b86388bef3 ('core: avoid stale entries in the DNS manager')
Fixes: 58287cbcc0 ('core: rework IP configuration in NetworkManager using layer 3 configuration')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/995
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1268
2022-06-24 12:02:45 +02:00
Thomas Haller
eb90ebc530
platform: merge branch 'th/platform-genl-2'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/1270
2022-06-24 11:09:09 +02:00
Thomas Haller
f8e061d7d6
platform/netlink: expose genl_ctrl_policy policy in header 2022-06-24 11:03:40 +02:00
Thomas Haller
4f405c5a07
platform/netlink: drop nl_socket_set_ext_ack() API
We just always want to set this. No need for a setter that is only
called once.
2022-06-24 11:03:39 +02:00
Thomas Haller
9cd986ba2e
platform/netlink: simplify socket flags and use boolean fields
- replace "s_flags" field by explicit boolean fields.

- "s_msg_peek" now is simplified. Previously, we would default
  to peek, unless the user caller nl_socket_disable_msg_peek()
  or set nl_socket_set_msg_buf_size(). Simplify that. We now
  default to peek, unless NL_SOCKET_FLAGS_DISABLE_MSG_PEEK is set.

  We have no callers that call nl_socket_set_msg_buf_size(),
  so we can simplify that logic and just enable peeking by default.

- keep "s_auto_ack" field, although it is always TRUE and there
  is no API to toggle that. However, it is kept as a self-documenting
  thing, so we would know the relevant places where auto-ack matters.

- drop nl_socket_disable_msg_peek(). We have no caller of this function
  and we can set peeking in nl_socket_new(). We also don't need to
  change it after creation of the socket.
2022-06-24 11:03:38 +02:00
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
Lubomir Rintel
cd2945f223 nmcli/connections: fix setting ifname with "--ask c add"
We almost always do the wrong thing in interactive add:

The software devices generally require an interactive name, but we don't
insist of asking for them; treating them as optional:

  $ nmcli -a c add type dummy
  There is 1 optional setting for General settings.
  Do you want to provide it? (yes/no) [yes]

For some interface types (bridges, bonds, ...) we make up a name, presumably
for historical reasons. But we don't give the user an option to modify
them:

  $ nmcli -a c add type bridge
  <not asking for interface name at all>
  There are 9 optional settings for Bridge device.
  Do you want to provide them? (yes/no) [yes]

This fixes the above use cases -- still set the default, but be sure to
ask:

  $ nmcli -a c add type dummy
  Interface name:

  $ nmcli -a c add type bridge
  Interface name [nm-bridge1]:

Beautiful.
2022-06-24 00:30:04 +02:00
Lubomir Rintel
647e255362 nmcli/connections: make sure the connection has a base setting
Do the same bookkeeping as would happen upon setting the "type" option
when the connection has a connection.type set upon its addition.

Otherwise the --ask mode is sad:

  $ nmcli --ask c add connection.type team
  ** nm:ERROR:src/nmcli/connections.c:5648:connection_get_base_meta_setting_type: assertion failed: (base_setting)
  Bail out! nm:ERROR:src/nmcli/connections.c:5648:connection_get_base_meta_setting_type: assertion failed: (base_setting)
  Aborted (core dumped)
2022-06-24 00:30:04 +02:00
Lubomir Rintel
e3fa6dfd7f nmcli/connections: factor out code run after new connection's type is set
After the connection's type is set, some bookkeeping is necessary for
the interactive (--ask) mode: appropriate setting need to be added and
options enabled.

Currently it happens in an option setter; which runs when the "type"
options is present on the command line, or the value is set in a
response to interactive mode:

  $ nmcli --ask c add type team

  $ nmcli --ask c add
  Connection type: team

But not when the property is set directly:

  $ nmcli --ask c add connection.type team
  ** nm:ERROR:src/nmcli/connections.c:5648:connection_get_base_meta_setting_type: assertion failed: (base_setting)
  Bail out! nm:ERROR:src/nmcli/connections.c:5648:connection_get_base_meta_setting_type: assertion failed: (base_setting)
  Aborted (core dumped)

This doesn't fix the issue -- a followup commit (hopefully) will.
2022-06-24 00:30:04 +02:00
Lubomir Rintel
b171dcec0d nmcli/connections: use the current value in default in ask_option()
For new connections, this ensures the value in square brackets on
interactive add are always correct.

Apart from that, this allows us to initialize some non-default values
before asking (such as making up an interface name for some software
devices), and inform the user about what we picked:

  Interface name [nm-bridge]:
2022-06-24 00:30:04 +02:00
Lubomir Rintel
ad7ac866db nmcli/connections: don't ask to ask with --ask
This is slightly annoying:

  $ nmcli -a c add type ethernet
  There is 1 optional setting for General settings.

No point in asking if there's just one option. Just ask right away:

  $ nmcli -a c add type ethernet
  Interface name:
2022-06-24 00:30:04 +02:00
Lubomir Rintel
69e65a9b0e nmcli/connections: make sure the connection has a type
We use it before we validate the connection, thus need to check if it's
actually there.
2022-06-24 00:30:04 +02:00
Lubomir Rintel
cf62f0e3a1 nmcli/connections: make enable_options() always enable an option 2022-06-24 00:30:04 +02:00
Lubomir Rintel
6fee8aa454 nmcli/connections: make opts argument to enable_options() optional
This makes things slightly less annoying when dealing with options that
map nicely to properties (unlike bridge options).
2022-06-24 00:30:04 +02:00
Lubomir Rintel
a5e099d008 nmcli/connections: allow empty lists with "--ask c add"
The interactive add is not too enthusiastic about not providing a value
in a list.

That is before on getting an empty line in ask_option() we take a
shortcut instead of dispatching to set_option(). That way we skip
setting the PROPERTY_INF_FLAG_DISABLED flag, causing the option to
be included in questionnaire_one_optional()'s info list.

There's no reason to avoid calling set_option() if we don't get a value;
set_option() handles NULL value just fine.

  $ nmcli -a c add
  Connection type: dummy
  There is 1 optional setting for General settings.
  Do you want to provide it? (yes/no) [yes]
  Interface name [*]: lala
  There are 2 optional settings for IPv4 protocol.
  Do you want to provide them? (yes/no) [yes]
  You can specify this option more than once. Press <Enter> when you're done.
  IPv4 address (IP[/plen]) [none]:
  You can specify this option more than once. Press <Enter> when you're done.
  IPv4 address (IP[/plen]) [none]:
  You can specify this option more than once. Press <Enter> when you're done.
  IPv4 address (IP[/plen]) [none]:
  ...
2022-06-24 00:30:04 +02:00
Lubomir Rintel
d51140d2ab nmcli/connections: do not remove a bond option unless reset is allowed
If we're setting an option with no value given and no reset allowed,
let's just set the default value.
2022-06-24 00:30:04 +02:00
Lubomir Rintel
0cb971d1d6 nmcli/connections: pass allow_reset to check_and_set() callback
Like the regular set_option() handler, the special ones also need to
know whether to reset an option or keep the value.
2022-06-24 00:30:04 +02:00
Lubomir Rintel
fe82c3a37a libnmc-setting: fix default suggestions for some options
These are just plain wrong.
2022-06-24 00:29:58 +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