Commit Graph

22892 Commits

Author SHA1 Message Date
Lubomir Rintel
b027723e00 Revert "all: goodbye libnm-glib"
We need this for a little little longer :(

This reverts commit 1de8383ad9.
2019-04-03 08:52:38 +02:00
Thomas Haller
61aad8cda4 shared: better implement compat version of explicit_bzero()
If we don't have explicit_bzero(), try a bit harder and use
a volatile pointer.

This is also what libsecret's egg_secure_clear() does [1]. However, for
us this is less important, because commonly we expect glibc to provide
a useable explicit_bzero().

[1] b5442654d4/egg/egg-secure-memory.c (L1352)
2019-04-02 19:30:33 +02:00
Antonio Larrosa
e504b7fc96 Update connectivity value on device removal
When a device is removed (like when the user unplugs a usb network
device) the device object is removed, so it doesn't emit a notify signal
for a change in its connectivity and so, device_connectivity_changed
is not called. This means that nobody updates the global connectivity
value which is potentially wrong if the device was the one providing
network connectivity.

Since device_connectivity_changed's first two parameters aren't actually
used and are there just for the signal to be able to be connected, I
moved the code from device_connectivity_changed to a new
update_connectivity_value function that just takes a NMManager
parameter and also call it from remove_device.

[thaller@redhat.com: fix coding style regarding whitespace]

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/141

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/101
2019-04-02 17:19:31 +02:00
Milo Casagrande
aba01d3d8a po: update Italian (it) translation
* Fixed translation errors.
  * Completed untranslated strings.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/102
2019-04-02 16:52:11 +02:00
Yupeng Chang
1dd67583e3 ifupdown: fix connection iterator
Fixes: 6aa66426a4 ('settings/ifupdown: merge eni_ifaces and connections hashes in plugin')

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/145
https://bugzilla.redhat.com/show_bug.cgi?id=1694912
2019-04-02 11:33:25 +02:00
Beniamino Galvani
5b5a768b69 clients: only ask secrets for settings that require them
When nmcli needs secrets for a connection it asks them for every known
setting. nmtui is a bit smarter and asks them only for settings that
actually exist in the connection. Make a step further and let clients
ask secrets only for setting that exist *and* have any secret
property. This decreases the number of D-Bus calls when editing or
showing a connection with secrets.

https://bugzilla.redhat.com/show_bug.cgi?id=1506536
https://github.com/NetworkManager/NetworkManager/pull/327
2019-04-02 11:20:28 +02:00
Lubomir Rintel
9c9c8c68ff cli: fix a crash on "nmcli d wifi hotspot"
Call the correct _finish() function for
nm_client_add_and_activate_connection_async(). add_and_activate_cb()
somewhat confusingly alternates between two different ones depending on
whether info->create is set.

Fixes: 3593237527 ('cli: reuse connections in nmcli dev wifi con')
https://github.com/NetworkManager/NetworkManager/pull/326
2019-04-02 09:09:54 +02:00
Beniamino Galvani
23d8a4f230 libnm-core: fix memory leak in setting test
Fixes: 7fb23b0a62 ('libnm: add NMIPRoutingRule API')
2019-03-31 12:03:31 +02:00
Beniamino Galvani
bd4957fcd7 build: fix searching dlopen in configure
The 4th argument of AC_SEARCH_LIBS is a list of additional libraries,
not the name of the variable to hold the result which is always
ac_cv_search_$function. Also, we should ignore the result when it is
"none required".

Fixes: 1f2eeb85d8 ('build: rename $(LIBDL) to $(DL_LIBS) and modify detection')
2019-03-31 11:36:48 +02:00
Francesco Giudici
a0d1971c23 libnm-core: make compiler happy
../libnm-core/nm-utils.c:6784:30: error: unused variable 'var_unref' [-Werror,-Wunused-variable]
                gs_unref_variant GVariant *var_unref = vlan_var;
2019-03-29 12:16:37 +01:00
Francesco Giudici
bb0ecf07db libnm-core: drop unused variable 2019-03-28 18:35:30 +01:00
Lubomir Rintel
045b88a5b5 ovs: don't traverse interface through disconnected when the ovsdb entry is removed
Go straight to unmanaged. That's what all the other devices do when
their backing resources vanish. If the device reached disconnected
state, an autoconnect check would try to connect it back, in vain.

https://github.com/NetworkManager/NetworkManager/pull/324
2019-03-28 16:55:48 +01:00
Lubomir Rintel
3a55ec63e1 ovs-interface: dissociate the link on disconnection
Open vSwitch is the special kid on the block -- it likes to be in charge of
the link lifetime and so we shouldn't be. This means that we shouldn't be
attempting to remove the link: we'd just (gracefully) fail anyways.

More importantly, this also means that we shouldn't care if we see the link
go away. Once the device reaches DISCONNECTED state, its configuration is
cleaned up and we may already be activating another connection. We shouldn't
alter the device state when OpenVSwitch decides to drop the old link.

https://bugzilla.redhat.com/show_bug.cgi?id=1543557
https://github.com/NetworkManager/NetworkManager/pull/324
2019-03-28 16:55:40 +01:00
Lubomir Rintel
f034f17ff6 settings: keep the added connection alive for a bit longer
Fixes a crash on failed AddAndActivate:

  $ ip link set eth0 down
  $ nmcli d conn eth0
  Error: Failed to add/activate new connection: Connection 'eth0' is not available on device eth0 because device has no carrier
  <NetworkManager crashes>

  #3  0x000055555558b6c5 in _nm_g_return_if_fail_warning
  #4  0x00005555557008c7 in nm_settings_has_connection
  #5  0x0000555555700e5f in pk_add_cb
  #6  0x0000555555726e30 in pk_call_cb
  #7  0x0000555555726e30 in pk_call_cb
  #8  0x0000555555726e30 in pk_call_cb
  #9  0x00005555555aaea8 in _call_id_invoke_callback
  #10 0x00005555555ab2e8 in _call_on_idle

https://github.com/NetworkManager/NetworkManager/pull/325
2019-03-28 14:57:04 +01:00
Thomas Haller
7680014732 libnm,core: merge branch 'th/routing-rule-pt2'
https://github.com/NetworkManager/NetworkManager/pull/321
2019-03-27 16:32:39 +01:00
Thomas Haller
3f9347745b core: add handling of IP routing rules to NMDevice 2019-03-27 16:23:30 +01:00
Thomas Haller
ba59c7c3c0 cli: add support for routing rules to nmcli 2019-03-27 16:23:30 +01:00
Thomas Haller
4d46804437 ifcfg-rh: add support for routing rules as "ROUTING_RULE_#" keys
initscripts support rule-* and rule6-* files for that.

Up until now, we ignored these files for the most part, except if
a user configured such files, the profile could not contain any static
routes (or specify a route-table setting). This also worked together
with the dispatcher script "examples/dispatcher/10-ifcfg-rh-routes.sh".

We cannot now start taking over that file format for rules. It might
break existing setups, because we can never fully understand all rules as
they are understood by iproute2. Also, if a user has a rule/rule6 file and
uses NetworkManager successfully today, then clearly there is a script
in place to make that work. We must not break that when adding rules
support.

Hence, store routing rules as numbered "ROUTING_RULE_#" and
"ROUTING_RULE6_#" keys.

Note that we use different keys for IPv4 and IPv6. The main reason is
that the string format is mostly compatible with iproute2. That means,
you can take the value and pass it to `ip rule add`.
However, `ip rule add` only accepts IPv4 rules. For IPv6 rules, the user
needs to call `ip -6 rule add`. If we would use the same key for IPv4
and IPv6, then it would be hard to write a script to do this.
Also, nm_ip_routing_rule_from_string() does take the address family as
hint in this case. This makes

  ROUTING_RULE_1="pref 1"
  ROUTING_RULE6_1="pref 1"

automatically determine that address families. Otherwise, such
abbreviated forms would be not valid.
2019-03-27 16:23:30 +01:00
Thomas Haller
6e6d1e070c libnm: add API to NMSettingIPConfig for routing rules 2019-03-27 16:23:30 +01:00
Thomas Haller
7fb23b0a62 libnm: add NMIPRoutingRule API
Add NMIPRoutingRule API with a few basic rule properties. More
properties will be added later as we want to support them.

Also, add to/from functions for string/GVariant representations.
These will be needed to persist/load/exchange rules.

The to-string format follows the `ip rule add` syntax, with the aim
to be partially compatible. Full compatibility is not possible though,
for various reasons (see code comment).
2019-03-27 16:23:30 +01:00
Thomas Haller
71e40f519d cli: support escaping for splitting for objlist properties 2019-03-27 16:23:30 +01:00
Thomas Haller
408d637930 libnm/keyfile: add parser_full() hook for reading non GObject based properties 2019-03-27 16:23:30 +01:00
Thomas Haller
c02fadecec libnm/keyfile: add writer_full() hook for persisting non GObject based properties 2019-03-27 16:23:30 +01:00
Thomas Haller
699257d432 libnm/keyfile: return setting-info from _parse_info_find() 2019-03-27 16:23:30 +01:00
Thomas Haller
28efb61d07 libnm/keyfile: make parsing route/address keys reusable
Will be used for routing rules as well.
2019-03-27 16:23:30 +01:00
Thomas Haller
d0727509b2 libnm: add nm_utils_is_valid_iface_name_utf8safe() util 2019-03-27 16:23:30 +01:00
Thomas Haller
e96643a0b6 shared: add nm_utils_str_simpletokens_extract_next() 2019-03-27 16:23:30 +01:00
Thomas Haller
0ccb25c5fa shared: add nm_ip_addr_is_null() helper 2019-03-27 16:23:30 +01:00
Thomas Haller
ccf59be7f5 platform: set fib_rule_hdr.table to RT_TABLE_UNSPEC for tables larger 255
No difference in practice, because kernel will ignore the table field
is FRA_TABLE attribute is present.
2019-03-27 16:23:30 +01:00
Thomas Haller
48d8ffaff6 platform: fix default routing rules added by kernel in NMPRulesManager
Fixes: b8398b9e79 ('platform: add NMPRulesManager for syncing routing rules')
2019-03-27 16:12:15 +01:00
Thomas Haller
598ecbc482 cli: fix accepting %NULL value for '+' modifier
I find it questionable, how nmcli likes to coerce the empty input to
NULL to indicate resetting the value. If nmcli would like to set a
default, it should use a different way of signalling that. Anyway, the
assertion was too strict.

    $ nmcli connection modify "$PROFILE" +ipv4.addresses ''
2019-03-27 16:12:15 +01:00
Beniamino Galvani
02ae0fd00a lldp: merge branch 'bg/lldp-enh-rh1652211'
This adds new TLV types to the D-Bus and libnm API.

nmcli will be updated later to support those TLVs.

https://bugzilla.redhat.com/show_bug.cgi?id=1652211
https://github.com/NetworkManager/NetworkManager/pull/287
2019-03-27 11:02:12 +01:00
Thomas Haller
5b51a1a9f7 libnm/lldp: cleanup asserting for valid NMLldpNeighbor agument
At a few places we checked whether neighbor->attrs was non-NULL.
That is not necessary, unless we'd like to catch some dangling/invalid
pointers. The attrs hash is always set otherwise.

Instead of just dropping the check, add a NM_IS_LLDP_NEIGHBOR() macro
(inline function).
2019-03-27 10:47:24 +01:00
Thomas Haller
95aa7ac91e core/lldp: avoid default switch case in lldp_neighbor_to_variant()
Explicitly check for LLDP_ATTR_TYPE_NONE. That's the only one we expect,
and the compiler can warn about missing switch cases for enums.
2019-03-27 10:47:24 +01:00
Thomas Haller
1c7cbda67a core/lldp: fix checking for NM_MORE_ASSERTS
It's called NM_MORE_ASSERTS not WITH_MORE_ASSERTS.

Also, NM_MORE_ASSERTS is always enabled. It's wrong to check whether it
is defined.

Fixes: e1e428b21e
2019-03-27 10:47:24 +01:00
Thomas Haller
8db0319198 libnm/lldp: fix leak and bug in nm_lldp_neighbor_dup()
For one, just reassigning copy->attrs leaks the previous
hash table. Fix that.

Also, NMLldpNeighbor instances are not immutable. I think that
is an uglyness, and it would be preferable that they can be sealed.
A sealed object could safely share/ref the internal hash-table. However,
as it is, we cannot just have two NMLldpNeighbor instances share the
same hash-table. Do a full copy.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
8200078ec5 lldp: support IEEE 802.3 TLVs
Add support for IEEE 802.3 organizationally specific TLVs:

 - MAC/PHY configuration/status (IEEE 802.1AB-2009 clause F.2)
 - power via medium dependent interface (clause F.3)
 - maximum frame size (clause F.4)
2019-03-27 10:47:24 +01:00
Beniamino Galvani
452851cc35 lldp: support multiple PPVIDs
As done for VLANs, add a new 'ppvids' attribute that reports all 'port
and protocol VLAN ID' TLVs for the neighbor.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
c4be4ea298 lldp: support multiple vlans
Previously we exported the contents of VLAN Name TLV in the 'vid'
(uint32) and 'vlan-name' (string) attributes. This is not entirely
correct as the TLV can appear multiple times.

We need a way to export all the VLAN IDs and names for the
neighbor. Add a new 'vlans' attribute which obsoletes the other two
and is an array of dictionaries, where each dictionary contains the
'vid' and 'name' keys.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
6c52d946fc lldp: add support for management address TLV
Support the management address TLV (IEEE 802.1AB-2009 clause
8.5.9). The TLV can appear multiple times and so it is exported on
D-Bus as an array of dictionaries.
2019-03-27 10:47:24 +01:00
Beniamino Galvani
937796f6ea libnm: add nm_lldp_neighbor_get_attr_value()
The function provides access to the GVariant representing a LLDP
attribute.
2019-03-27 10:17:39 +01:00
Beniamino Galvani
8cdc011cd1 libnm: make attribute name const in LLDP API functions
Add the const qualifier to the attribute name in LLDP API functions so
that const strings and string literals are accepted. This change is
backwards compatible for existing users of the API.
2019-03-27 10:17:39 +01:00
Beniamino Galvani
15798df882 lldp: rename enum value 2019-03-27 10:17:39 +01:00
Beniamino Galvani
b1d5f11b3d cli: add lldp output tests
Check the result of 'nmcli device lldp' command.
2019-03-27 10:17:39 +01:00
Beniamino Galvani
a66ab735b6 lldp: drop _access* macros
Use unaligned access functions instead where needed.
2019-03-27 10:16:39 +01:00
Beniamino Galvani
579373a5df dns: fix memory leak of error
The error was leaked when cancelled.

Fixes: 818023c257 ('dns/resolved: add systemd-resolved backend')
2019-03-26 17:37:54 +01:00
Beniamino Galvani
fc4aedc6f3 merge: branch 'bg/bridge-vlan-filtering'
https://github.com/NetworkManager/NetworkManager/pull/322
https://bugzilla.redhat.com/show_bug.cgi?id=1652910
2019-03-26 17:32:03 +01:00
Beniamino Galvani
494f78440c device: support bridge vlans 2019-03-26 17:26:31 +01:00
Beniamino Galvani
fafde171ea platform: add support for bridge vlans 2019-03-26 17:19:39 +01:00
Beniamino Galvani
be2fbd0c69 platform: add @family argument to new-link function
This will be used to create bridge vlans, which require an AF_BRIDGE
message family.
2019-03-26 17:19:39 +01:00