Commit Graph

22651 Commits

Author SHA1 Message Date
Thomas Haller
15a6b41239 release: bump version to 1.16.0 2019-03-15 16:15:04 +01:00
Thomas Haller
960f9fe937 release: update NEWS 2019-03-15 16:12:06 +01:00
Thomas Haller
e1ef6c0b26 device/wifi: fix handling static WEP connections in act_stage4_ip_config_timeout()
Fixes: 5e71f01605 ('device: merge stage3 and stage4 ip-config function for IPv4 and IPv6')
(cherry picked from commit fd2106dbd6)
2019-03-15 16:02:15 +01:00
Thomas Haller
fd2106dbd6 device/wifi: fix handling static WEP connections in act_stage4_ip_config_timeout()
Fixes: 5e71f01605 ('device: merge stage3 and stage4 ip-config function for IPv4 and IPv6')
2019-03-15 15:52:23 +01:00
Beniamino Galvani
47f1c931ee libnm: fix dns-configuration property type
Fixes: a8d6005256 ('libnm: implement support for DNS manager properties')

https://bugzilla.redhat.com/show_bug.cgi?id=1689055
(cherry picked from commit d867837d05)
2019-03-15 11:15:37 +01:00
Beniamino Galvani
d867837d05 libnm: fix dns-configuration property type
Fixes: a8d6005256 ('libnm: implement support for DNS manager properties')

https://bugzilla.redhat.com/show_bug.cgi?id=1689055
2019-03-15 11:13:26 +01:00
Thomas Haller
697b9864df platform/tests: adjust probabilities for generating randomized rules
The routing-rule tests generate a number of routing rules and tries to
add and delete them.

For that, _rule_create_random() sets random fields of the rule.
Note that especially interesting are rules that leave most fields
unset (at zero), because they trigger kernel issues rh#1686075 and
rh#1685816.

But a rule has many fields, so in order to generate rules that have most
fields unset, we need to use low probabilities when rolling the dice for
setting a field. Otherwise, most rules end up with several fields set
and don't reproduce the kernel issue (especially the test failed to hit
rh#1686075).
2019-03-15 09:18:17 +01:00
Thomas Haller
f2f72e8245 platform/tests: workaround FIB_RULE_INVERT of rules for kernel issue rh#1686075
Fixes: b8398b9e79 ('platform: add NMPRulesManager for syncing routing rules')
2019-03-15 09:18:11 +01:00
Thomas Haller
b38fbab080 libnm-core: fix types of nm_auto() macros for NMSockAddrEndpoint and NMWireGuardPeer
(cherry picked from commit b24f0a46ae)
2019-03-13 20:25:57 +01:00
Thomas Haller
f90c663d51 libnm-core: fix type of argument for nm_utils_inet_ntop_dup()
Fixes: 898f7a5665 ('libnm: add internal API nm_utils_inet*_ntop_dup()')
(cherry picked from commit a0d0d4d770)
2019-03-13 20:25:47 +01:00
Thomas Haller
b24f0a46ae libnm-core: fix types of nm_auto() macros for NMSockAddrEndpoint and NMWireGuardPeer 2019-03-13 20:23:11 +01:00
Thomas Haller
a0d0d4d770 libnm-core: fix type of argument for nm_utils_inet_ntop_dup()
Fixes: 898f7a5665 ('libnm: add internal API nm_utils_inet*_ntop_dup()')
2019-03-13 20:23:11 +01:00
Thomas Haller
d62dd09772 core: merge branch 'th/routing-rule-pt1'
https://github.com/NetworkManager/NetworkManager/pull/306
2019-03-13 20:17:23 +01:00
Thomas Haller
b8398b9e79 platform: add NMPRulesManager for syncing routing rules
Routing rules are unlike addresses or routes not tied to an interface.
NetworkManager thinks in terms of connection profiles. That works well
for addresses and routes, as one profile configures addresses and routes
for one device. For example, when activating a profile on a device, the
configuration does not interfere with the addresses/routes of other
devices. That is not the case for routing rules, which are global, netns-wide
entities.

When one connection profile specifies rules, then this per-device configuration
must be merged with the global configuration. And when a device disconnects later,
the rules must be removed.

Add a new NMPRulesManager API to track/untrack routing rules. Devices can
register/add there the routing rules they require. And the sync method will
apply the configuration. This is be implemented on top of NMPlatform's
caching API.
2019-03-13 09:47:37 +01:00
Thomas Haller
5ae2431b0f platform/tests: add tests for handling policy routing rules 2019-03-13 09:03:59 +01:00
Thomas Haller
9992ac1cf8 platform: add routing-rule add/delete netlink functions 2019-03-13 09:03:59 +01:00
Thomas Haller
9934a6a0e3 platform: add support for routing-rule objects and cache them in platform
Add and implement NMPlatformRoutingRule types and let the platform cache
handle rules.

Rules are special in two ways:

- they don't have an ifindex. That makes them different from all other
  currently existing NMPlatform* types, which have an "ifindex" field and
  "implement" NMPlatformObjWithIfindex.

- they have an address family, but contrary to addresses and routes, there
  is only one NMPlatformRoutingRule object to handle both address
  families.

Both of these points require some special considerations.

Kernel treats routing-rules quite similar to routes. That is, kernel
allows to add different rules/routes, as long as they differ in certain
fields. These "fields" make up the identity of the rules/routes. But
in practice, it's not defined which fields contribute to the identity
of these objects. That makes using the netlink API very hard. For
example, when kernel gains support for a new attribute which
NetworkManager does not know yet, then users can add two rules/routes
that look the same to NetworkManager. That can easily result in cache
inconsistencies.

Another problem is, that older kernel versions may not yet support all
fields, which NetworkManager (and newer kernels) considers for identity.
The older kernel will not simply reject netlink messages with these unknown
keys, instead it will proceed adding the route/rule without it. That means,
the added route/rule will have a different identity than what NetworkManager
intended to add.
2019-03-13 09:03:59 +01:00
Thomas Haller
b9ee40b86b platform: separate the refresh-type from the object type
Currently, there is a directy one to one relation between

 - DELAYED_ACTION_TYPE_REFRESH_ALL_*

 - REFRESH_ALL_TYPE_*

 - NMP_OBJECT_TYPE_*

For IP addresses, routes and routing policy rules, when we request
a refresh-all (NLM_F_DUMP), we want to specify the address family.

For addresses and routes that is currently solved by having two
sets of NMPObject types, for each address family one.

I think that is cumbersome because the implementations of both address
families are quite similar. By implementing both families as different
object types, we have a lot of duplicate code and it's hard to see where
the families actually differ. It would be better to have only one NMPObject
type, but then when we "refresh-all" such types, we still want to be able
to dump all (AF_UNSPEC) or only a particular address family (AF_INET, AF_INET6).

Decouple REFRESH_ALL_TYPE_* from NMP_OBJECT_TYPE_* to make that
possible.
2019-03-13 09:03:59 +01:00
Thomas Haller
0a2a861782 platform/trivial: rename enum DELAYED_ACTION_IDX_REFRESH_ALL_* to REFRESH_ALL_TYPE_*
While these numbers are strongly related to DELAYED_ACTION_TYPE_REFRESH_ALL_*,
they differ in their meaning.

These are the refresh-all-types that we support. While some of the delayed-actions
are indeed for refresh-all, they are not the same thing.

Rename the enum.
2019-03-13 09:03:59 +01:00
Thomas Haller
7c5ad2d910 platform: drop unused nm_platform_refresh_all()
The function is unused. It would require redesign to work with
future changes, and since it's unused, just drop it.

The long reasoning is:

    Currently, a refresh-all is tied to an NMPObjectType. However, with
    NMPObjectRoutingRule (for policy-routing-rules) that will no longer
    be the case.

    That is because NMPObjectRoutingRule will be one object type for
    AF_INET and AF_INET6. Contrary to IPv4 addresses and routes, where
    there are two sets of NMPObject types.

    The reason is, that it's preferable to treat IPv4 and IPv6 objects
    similarly, that is: as the same type with an address family property.

    That also follows netlink, which uses RTM_GET* messages for both
    address families, and the address family is expressed inside the
    message.

    But then an API like nm_platform_refresh_all() makes little sense,
    it would require at least an addr_family argument. But since the
    API is unused, just drop it.
2019-03-13 09:03:59 +01:00
Thomas Haller
bbfb8a9b33 platform: suppress unnecessary logging in do_request_all_no_delayed_actions()
When we refresh all links, we clear all flags to refresh a specific
link. However, only log a message if there was anything to clear.
2019-03-13 09:03:59 +01:00
Thomas Haller
2c37a3fb1e platform: add NULL check in inline nmp_object_unref() function
This allows the compiler to see that this function does nothing for %NULL.
That is not so unusual, as we use nm_auto_nmpobj to free objects. Often
the compiler can see that these pointers are %NULL.
2019-03-13 09:03:59 +01:00
Thomas Haller
ac4a1deba0 platform: add NMPlatformObjWithIfindex helper structure for handling NMPObject types
Until now, all implemented NMPObject types have an ifindex field (from
links, addresses, routes, qdisc to tfilter).

The NMPObject structure contains a union of all available types, that
makes it easier to down-case from an NMPObject pointer to the actual
content.

The "object" field of NMPObject of type NMPlatformObject is the lowest
common denominator.

We will add NMPlatformRoutingRules (for policy routing rules). That type
won't have an ifindex field.

Hence, drop the "ifindex" field from NMPlatformObject type. But also add
a new type NMPlatformObjWithIfindex, that can represent all types that
have an ifindex.
2019-03-13 09:03:59 +01:00
Thomas Haller
667aa52f89 platform: move nmp_class_from_type() to header to allow inlining 2019-03-13 09:03:59 +01:00
Thomas Haller
8f3724a6bd platform: drop unnecessary casts from NMP_OBJECT_CAST_*() macros
It's wrong to cast here. The caller must always provide an
NMPObject pointer.
2019-03-13 09:03:59 +01:00
Thomas Haller
7259195a91 platform: unify IPv4 and IPv6 variables for NMPlatformVTableRoute 2019-03-13 09:03:59 +01:00
Thomas Haller
237a17237d shared: add nm_hash_obfuscate_ptr() helper 2019-03-13 09:03:58 +01:00
Thomas Haller
83fa4aaf3c shared: add c_list_length_is() helper 2019-03-13 09:03:58 +01:00
Thomas Haller
bfd6d608e2 contrib: set shift for less in NM-log 2019-03-13 09:03:58 +01:00
Lubomir Rintel
2e8f43e379 wwan/device-modem: don't enter available state until registered
Based on Ubuntu's "Modify NMDeviceModem's available logic" patch by
Tony Espy <espy@canonical.com>. The original commit message:

This patch modifies NMDeviceModem's available logic such that the device
is only considered available if the modem_state is
>= NM_MODEM_STATE_REGISTERED.  NMDevice defines 'available' as meaning the
device is in such a state that it can be activated.  This change prevents
NM from trying to activate a modem which is not yet ready to be activated.

Bug-Ubuntu: https://bugs.launchpad.net/bugs/1445080
https://github.com/NetworkManager/NetworkManager/pull/312
2019-03-12 16:02:04 +01:00
Thomas Haller
cfb970b277 shared/systemd: fix gettid() compat implementation shadowing function from glibc
On Fedora rawhide we get the following build failure:

    In file included from shared/systemd/src/basic/alloc-util.c:3:
    ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:114:21: error: static declaration of 'gettid' follows non-static declaration
      114 | static inline pid_t gettid(void) {
          |                     ^~~~~~
    In file included from /usr/include/unistd.h:1170,
                     from /usr/include/glib-2.0/gio/gcredentials.h:32,
                     from /usr/include/glib-2.0/gio/gio.h:46,
                     from ./shared/nm-utils/nm-macros-internal.h:31,
                     from ./shared/nm-default.h:293,
                     from ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:22,
                     from shared/systemd/src/basic/alloc-util.c:3:
    /usr/include/bits/unistd_ext.h:34:16: note: previous declaration of 'gettid' was here
       34 | extern __pid_t gettid (void) __THROW;
          |                ^~~~~~

glibc supports now gettid() call ([1]) which conflicts with our compat
implementation. Rename it.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92

(cherry picked from commit 10276322bd)
2019-03-11 19:09:59 +01:00
Thomas Haller
10276322bd shared/systemd: fix gettid() compat implementation shadowing function from glibc
On Fedora rawhide we get the following build failure:

    In file included from shared/systemd/src/basic/alloc-util.c:3:
    ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:114:21: error: static declaration of 'gettid' follows non-static declaration
      114 | static inline pid_t gettid(void) {
          |                     ^~~~~~
    In file included from /usr/include/unistd.h:1170,
                     from /usr/include/glib-2.0/gio/gcredentials.h:32,
                     from /usr/include/glib-2.0/gio/gio.h:46,
                     from ./shared/nm-utils/nm-macros-internal.h:31,
                     from ./shared/nm-default.h:293,
                     from ./shared/systemd/sd-adapt-shared/nm-sd-adapt-shared.h:22,
                     from shared/systemd/src/basic/alloc-util.c:3:
    /usr/include/bits/unistd_ext.h:34:16: note: previous declaration of 'gettid' was here
       34 | extern __pid_t gettid (void) __THROW;
          |                ^~~~~~

glibc supports now gettid() call ([1]) which conflicts with our compat
implementation. Rename it.

[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=1d0fc213824eaa2a8f8c4385daaa698ee8fb7c92
2019-03-11 18:17:12 +01:00
Thomas Haller
96be30cbcc release: bump version to 1.15.91 (1.16-rc2) 2019-03-11 16:50:17 +01:00
Thomas Haller
9294b42ba0 ifcfg-rh: avoid duplicate cache lookup in is_wifi_device()
(cherry picked from commit 6580f2931d)
2019-03-11 16:44:59 +01:00
Frédéric Danis
10502f1701 tests: Fix variant_from_dbus() for arrays of UInt32
Using test-networkmanager-servic.py, I get the following error when
trying to add manual config with a dns address:

    Error: g-io-error-quark: Traceback (most recent call last):
      File "/usr/lib/python2.7/dist-packages/dbus/service.py", line 707, in _message_cb
        retval = candidate_method(self, *args, **keywords)
      File "tools/test-networkmanager-service.py", line 1727, in AddConnection
        return self.add_connection(con_hash)
      File "tools/test-networkmanager-service.py", line 1731, in add_connection
        con_inst = Connection(self.c_counter, con_hash, do_verify_strict)
      File "tools/test-networkmanager-service.py", line 1601, in __init__
        NmUtil.con_hash_verify(con_hash, do_verify_strict=do_verify_strict)
      File "tools/test-networkmanager-service.py", line 497, in con_hash_verify
        BusErr.raise_nmerror(e)
      File "tools/test-networkmanager-service.py", line 419, in raise_nmerror
        raise e
    Exception: Unsupported value ipv4.dns = dbus.Array([dbus.UInt32(168430090L), dbus.UInt32(218893066L)], signature=dbus.Signature('u'), variant_level=1) (Cannot convert array element to type 'u': Must be number, not Variant)

https://mail.gnome.org/archives/networkmanager-list/2019-March/msg00013.html
(cherry picked from commit 9a71d7d273)
2019-03-11 16:44:22 +01:00
Thomas Haller
355cbbfb5c core: assert for valid NM_DEVICE_DEVICE_TYPE setting
(cherry picked from commit 7dd44d6dc8)
2019-03-11 16:43:20 +01:00
Lubomir Rintel
4251f4e476 all: codespell fixes
Codespel run with the same arguments as described in
commit 58510ed566 ('docs: misc. typos pt2').

(cherry picked from commit bf0c4e6ac2)
2019-03-11 12:03:46 +01:00
Lubomir Rintel
bf0c4e6ac2 all: codespell fixes
Codespel run with the same arguments as described in
commit 58510ed566 ('docs: misc. typos pt2').
2019-03-11 12:01:44 +01:00
Beniamino Galvani
25d1e5f51c merge: branch 'bg/restore-ipv6-on-up-rh1548237'
https://bugzilla.redhat.com/show_bug.cgi?id=1548237
(cherry picked from commit 766864c5de)
2019-03-11 10:31:50 +01:00
Beniamino Galvani
97de744afd device: restore IPv6 addresses when the link comes up
When the link goes down the kernel removes IPv6 addresses from the
interface. In update_ext_ip_config() we detect that addresses were
removed externally and drop them from various internal
configurations. Don't do that if the link is down so that those
addresses will be restored again on link up.

(cherry picked from commit 505d2adbc2)
2019-03-11 10:31:30 +01:00
Beniamino Galvani
e096742809 core: allow ignoring addresses when intersecting ip configs
Add a new argument to nm_ip_config_* helpers to also ignore addresses
similarly to what we already do for routes. This will be used in the
next commit; no change in behavior here.

(cherry picked from commit 39b7257208)
2019-03-11 10:31:29 +01:00
Beniamino Galvani
058bf25ac4 device: reset the ipv6 DAD counter when the link comes up
We can detect false DAD failures if the link goes down. Don't try to
prevent them, but just reset the counter if the link goes down.

(cherry picked from commit 056470a4ba)
2019-03-11 10:31:28 +01:00
Beniamino Galvani
d159a1153a device: don't try to add IPv6LL address to a down interface
When the interface is down DAD failures becomes irrelevant and we
shouldn't try to add a link-local address even if the configuration
contains other IPv6 addresses.

(cherry picked from commit 72385f363c)
2019-03-11 10:31:26 +01:00
Beniamino Galvani
4753ea38c3 core: fix _nm_ip4_config_intersect_helper()
Fixes: 8f07b3ac4f ('ip-config: add @intersect_routes argument to intersect functions')
(cherry picked from commit d86dd9a0fe)
2019-03-11 10:31:25 +01:00
Beniamino Galvani
766864c5de merge: branch 'bg/restore-ipv6-on-up-rh1548237'
https://bugzilla.redhat.com/show_bug.cgi?id=1548237
2019-03-11 10:18:50 +01:00
Beniamino Galvani
505d2adbc2 device: restore IPv6 addresses when the link comes up
When the link goes down the kernel removes IPv6 addresses from the
interface. In update_ext_ip_config() we detect that addresses were
removed externally and drop them from various internal
configurations. Don't do that if the link is down so that those
addresses will be restored again on link up.
2019-03-09 15:31:46 +01:00
Beniamino Galvani
39b7257208 core: allow ignoring addresses when intersecting ip configs
Add a new argument to nm_ip_config_* helpers to also ignore addresses
similarly to what we already do for routes. This will be used in the
next commit; no change in behavior here.
2019-03-09 15:30:22 +01:00
Beniamino Galvani
056470a4ba device: reset the ipv6 DAD counter when the link comes up
We can detect false DAD failures if the link goes down. Don't try to
prevent them, but just reset the counter if the link goes down.
2019-03-09 15:27:54 +01:00
Beniamino Galvani
72385f363c device: don't try to add IPv6LL address to a down interface
When the interface is down DAD failures becomes irrelevant and we
shouldn't try to add a link-local address even if the configuration
contains other IPv6 addresses.
2019-03-09 15:25:47 +01:00
Beniamino Galvani
d86dd9a0fe core: fix _nm_ip4_config_intersect_helper()
Fixes: 8f07b3ac4f ('ip-config: add @intersect_routes argument to intersect functions')
2019-03-09 15:25:43 +01:00