Commit Graph

18368 Commits

Author SHA1 Message Date
Thomas Haller
9012ae00aa shared: add nm_dedup_multi_entry_reorder() function
This allows to reorder elements in NMDedupMultiIndex.
2017-08-12 16:02:11 +02:00
Thomas Haller
3e1914e4fc platform: cleanup lookup API for objects in NMPCache 2017-08-12 16:02:11 +02:00
Thomas Haller
5331d4d63e platform: fix code comment for nmp_cache_remove_netlink() 2017-08-12 16:02:11 +02:00
Thomas Haller
82fd320900 platform: improve logging of netlink message
Also log the nlmsg_flags, they will be useful for RTM_NEWROUTE messages.
2017-08-12 16:02:11 +02:00
Thomas Haller
7c52235026 platform: simplify to-string output of IPv6 routes by dropping " src ::/0"
IPv6 routes without source are common. Simplify the output in this case.
2017-08-12 16:02:11 +02:00
Thomas Haller
80e585a65d test: redirect glib logging to stdout
Default g_log() logs to stdout for INFO level and higher, but logs to stderr
for DEBUG/TRACE. That is annoying, because especially when redirecting the streams,
the messages get mixed up. Install a log handler and just print to stdout for
the tests.
2017-08-12 16:02:11 +02:00
Thomas Haller
1fcc3c8c39 platform: add nmp_object_id_cmp() function
We already had a nmp_object_id_equal() function. Generally, an equal() function
is more useful then a cmp() function.

However, implementing a cmp() function is about the same effort then implementing
an equal() function. Also, an equal function can be trivially implemented based on
a compare function, but not the other way around.

That means, it is little extra effort to have both an equal() function
and a cmp() function. Add nmp_object_id_cmp(). If only to be
consistent with other code, which also provides both.
2017-08-12 15:58:58 +02:00
Dan Williams
d989be8235 wifi: merge branch 'dcbw/wifi-scan' 2017-08-11 12:36:41 -05:00
Dan Williams
4acc17053b devices/wifi: move scan option processing to D-Bus request scan handler
Only the D-Bus bits use it, and we wouldn't pass a GVariant array around
in internal code anyway.  Also validate the scan options earlier rather
than waiting for the supplicant to tell us they are invalid.
2017-08-11 12:35:01 -05:00
Dan Williams
e1da16f799 supplicant: don't allow scans to trigger a supplicant roaming decision
Just because the user requested a scan doesn't mean the supplicant should
use the result of that scan to jump to an AP that's slightly better than
the current one.  Let the supplicant handle when it's supposed to roam
based on it's own logic, not random scans from users or NM clients.
2017-08-11 12:35:01 -05:00
Dan Williams
fd6ddcc794 devices/wifi: delegate connected periodic scanning to the supplicant (bgo #766482)
Enable background scanning for most WiFi connections except for
shared/AP and BSSID-locked ones.  Make the non-WPA-Enterprise
interval very, very long to effectively disable periodic scanning
while connected.

Related: https://bugzilla.gnome.org/show_bug.cgi?id=766482
2017-08-11 12:35:01 -05:00
Dan Williams
631ca80692 devices/wifi: flip meaning of scanning allowed signal
Change it to return TRUE when scanning is prohibited so that we
don't have to use use g_signal_emitv() and its special handling of
return values.  Make the return value only change when we don't
want the default behavior (which would be to allow the scan).

Also add a parameter to the signal indicating whether the scan is
user/dbus-requested or whether it's an internal periodic scan.
2017-08-11 11:59:58 -05:00
Francesco Giudici
121a6bb638 build: fix building src/systemd
While rebasing systemd from upstream the "sd-adapt/process-util.h" file
was renamed and few other header files were added in the sources.
Update Makefile.am.

Fixes: e0cdaf9880
2017-08-11 12:42:21 +02:00
Thomas Haller
752afada0b docs: fix spelling errors in tranlated strings and documentation
https://bugzilla.gnome.org/show_bug.cgi?id=786131
2017-08-11 11:05:12 +02:00
Beniamino Galvani
e0cdaf9880 systemd: merge branch systemd into master
- fix DHCP over Infiniband

https://bugzilla.redhat.com/show_bug.cgi?id=1477678
2017-08-10 11:21:31 +02:00
Beniamino Galvani
dc1bfde56b systemd: update code from upstream (2017-08-09)
This is a direct dump from systemd git on 2017-08-09, git commit
c7f6ca9379279affa8f22d15fa13063491f86a49.

======

SYSTEMD_DIR=../systemd
COMMIT=c7f6ca9379279affa8f22d15fa13063491f86a49

(
  cd "$SYSTEMD_DIR"
  git checkout "$COMMIT"
  git reset --hard
  git clean -fdx
)

git ls-files :/src/systemd/src/ | xargs -d '\n' rm -f

nm_copy_sd() {
    mkdir -p "./src/systemd/$(dirname "$1")"
    cp "$SYSTEMD_DIR/$1" "./src/systemd/$1"
}

nm_copy_sd "src/basic/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/extract-word.c"
nm_copy_sd "src/basic/extract-word.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.h"
nm_copy_sd "src/basic/hostname-util.c"
nm_copy_sd "src/basic/hostname-util.h"
nm_copy_sd "src/basic/in-addr-util.c"
nm_copy_sd "src/basic/in-addr-util.h"
nm_copy_sd "src/basic/io-util.c"
nm_copy_sd "src/basic/io-util.h"
nm_copy_sd "src/basic/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
nm_copy_sd "src/basic/process-util.h"
nm_copy_sd "src/basic/process-util.c"
nm_copy_sd "src/basic/random-util.c"
nm_copy_sd "src/basic/random-util.h"
nm_copy_sd "src/basic/refcnt.h"
nm_copy_sd "src/basic/set.h"
nm_copy_sd "src/basic/signal-util.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.h"
nm_copy_sd "src/basic/strv.c"
nm_copy_sd "src/basic/strv.h"
nm_copy_sd "src/basic/time-util.c"
nm_copy_sd "src/basic/time-util.h"
nm_copy_sd "src/basic/umask-util.h"
nm_copy_sd "src/basic/unaligned.h"
nm_copy_sd "src/basic/utf8.c"
nm_copy_sd "src/basic/utf8.h"
nm_copy_sd "src/basic/util.c"
nm_copy_sd "src/basic/util.h"
nm_copy_sd "src/libsystemd-network/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-util.h"
nm_copy_sd "src/libsystemd-network/dhcp6-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp6-network.c"
nm_copy_sd "src/libsystemd-network/dhcp6-option.c"
nm_copy_sd "src/libsystemd-network/dhcp6-protocol.h"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.c"
nm_copy_sd "src/libsystemd-network/dhcp-identifier.h"
nm_copy_sd "src/libsystemd-network/dhcp-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-lease-internal.h"
nm_copy_sd "src/libsystemd-network/dhcp-network.c"
nm_copy_sd "src/libsystemd-network/dhcp-option.c"
nm_copy_sd "src/libsystemd-network/dhcp-packet.c"
nm_copy_sd "src/libsystemd-network/dhcp-protocol.h"
nm_copy_sd "src/libsystemd-network/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
nm_copy_sd "src/libsystemd-network/network-internal.c"
nm_copy_sd "src/libsystemd-network/network-internal.h"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp6-lease.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-client.c"
nm_copy_sd "src/libsystemd-network/sd-dhcp-lease.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4ll.c"
nm_copy_sd "src/libsystemd-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
nm_copy_sd "src/libsystemd/sd-id128/sd-id128.c"
nm_copy_sd "src/shared/dns-domain.c"
nm_copy_sd "src/shared/dns-domain.h"
nm_copy_sd "src/systemd/_sd-common.h"
nm_copy_sd "src/systemd/sd-dhcp6-client.h"
nm_copy_sd "src/systemd/sd-dhcp6-lease.h"
nm_copy_sd "src/systemd/sd-dhcp-client.h"
nm_copy_sd "src/systemd/sd-dhcp-lease.h"
nm_copy_sd "src/systemd/sd-event.h"
nm_copy_sd "src/systemd/sd-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2017-08-09 14:30:44 +02:00
Thomas Haller
a7aca2ab08 core: fix crash with bluetooth device factory wrongly claiming NAP connection
The bluetooth device *never* manages NAP connection. Hence, checking for
nm_bt_vtable_network_server in "nm-bluez-manager.c" is wrong.
Especially, because nm_bt_vtable_network_server is only initialized
much later, so during initial start, the bluetooth factory would wronly
claim to support it. This leads to a crash when having a NAP connection.

Also, the bridge factory requires the bluetooth plugin. It should only
claim to support NAP when the bluetooth plugin is present. That
way, we get a proper "missing plugin" error message, instead of failing
later during activation.

It seems to me, distributing the logic to various match_connection()
functions makes it more complicated, because the implementation is
spread out and interact in complicated ways. Anyway.

Fixes: 8665cdfeff
2017-08-06 07:50:48 +02:00
Beniamino Galvani
220a329fea ppp: merge branch 'bg/ppp-bgo559134'
Support for PPPoE on arbitrary devices.

https://bugzilla.gnome.org/show_bug.cgi?id=559134
2017-08-05 08:05:14 +02:00
Beniamino Galvani
74bf32ff9a core: ppp: use a different unit for each activation
We can't tell pppd to create an interface with a given name, so we use
the name generated by kernel and rename the interface afterwards. A
race condition can happen during the rename: NM receives the interface
name from pppd, but in the meantime the interface could be deleted and
another one with that name could appear. In this case we would rename
the wrong interface.

Using a changing unit index, we ensure that interfaces created by NM
don't race with each others. There is still the chance to race with
externally-created interfaces, but I guess this is not easily solvable
since the pppd plugin does not expose the ifindex.

When the specified unit is already in use, the kernel selects another
one.
2017-08-05 08:03:16 +02:00
Beniamino Galvani
a7afa9ead7 device: use ppp device for new style pppoe setting 2017-08-05 08:03:16 +02:00
Beniamino Galvani
6c3195931e core: implement activation of PPP devices
Add code to NMPppDevice to activate new-style PPPoE connections. This
is a bit tricky because we can't create the link as usual in
create_and_realize(). Instead, we create a device without ifindex and
start pppd in stage2; when pppd reports a new configuration, we rename
the platform link to the correct name and set the ifindex into the
device.

This mechanism is inherently racy, but there is no way to tell pppd to
create an arbitrary interface name.
2017-08-05 08:03:16 +02:00
Beniamino Galvani
695f6ceebb device: accept NULL plink
For PPP devices we can't create a link in advance, as the link is
created by pppd when the connection is established.
2017-08-05 08:03:16 +02:00
Beniamino Galvani
8665cdfeff core: device-factory: implement match_connection()
Make it possible to register different factories for the same setting
type, and add a match_connection() method to let each factory decide
if it's capable of handling a connection.

This will be used to decide whether a PPPoE connection must be handled
through the legacy Ethernet factory or through the new PPP factory.
2017-08-05 08:03:16 +02:00
Beniamino Galvani
df72cad107 device: add NMDevicePPP
The new device type represents a PPP interface, and will implement the
activation of new-style PPPoE connections, i.e. the ones that don't
claim the parent device.
2017-08-05 08:03:15 +02:00
Beniamino Galvani
d5c2c3f6d7 platform: add nm_platform_link_set_name()
We'll need it to rename the new PPP interface to a given name.
2017-08-05 08:03:15 +02:00
Beniamino Galvani
f83e56ec6d libnm,clients: add 'parent' property to PPPoE setting
When the property is set, it specifies the device on which PPPoE is to
be started. The ppp interface will be named as the
connection.interface-name property.

When the property is not set the previous behavior will be retained,
i.e. the PPPoE connection will be started on connection.interface-name
and the PPP interface will have a random name.
2017-08-05 08:03:15 +02:00
Beniamino Galvani
c521cffd7b device: ethernet: remove unused private member 2017-08-05 08:03:04 +02:00
Thomas Haller
6da6323080 platform: merge branch 'th/platform-route-pt1-bgo785449'
- extend platform's route-compare() functions with a mode argument.
  Most important is the new mode NM_PLATFORM_IP_ROUTE_CMP_TYPE_ID,
  which corresponds kernels ID of how routes compare.

- when deleting routes, set all known parameters in the netlink message.
  Previously we would omit paramters, but that causes kernel to delete
  the first matching route.

- cleanup fields of routes

https://bugzilla.gnome.org/show_bug.cgi?id=785449
2017-08-03 19:04:54 +02:00
Thomas Haller
d373855e98 platform: extend API for adding routes
Via the flags of the RTM_NEWROUTE netlink message, kernel and iproute2
support various variants to add a route.

 - ip route add
 - ip route change
 - ip route replace
 - ip route prepend
 - ip route append
 - ip route test

Previously, our nm_platform_ip4_route_add() function was basically
`ip route replace`. In the future, we should rather user `ip route
append` instead.

Anyway, expose the netlink message flags in the API. This allows to
use the various forms, and makes it also more apparent to the user that
they even exist.
2017-08-03 18:51:57 +02:00
Thomas Haller
75dc0fdd27 platform,libnm: cleanup handling of TOS for routes
- kernel ignores rtm_tos for IPv6 routes. While iproute2 accepts it,
  let libnm reject TOS attribute for routes as well.

- move the tos field from NMPlatformIPRoute to NMPlatformIP4Route.

- the tos field is part of the weak-id of an IPv4 route. Meaning,
  `ip route add` can add routes that only differ by their TOS.
2017-08-03 18:51:57 +02:00
Thomas Haller
f5c800885b ifcfg-rh: fix writing/reading TOS for routes in hexadecimal
iproute2 expects TOS in hex.

This is a change in behavior.
2017-08-03 18:51:57 +02:00
Thomas Haller
9be9cab646 core: implement NMIP4Config's and NMIP6Config's route equality based on nm_platform_ipx_route_cmp()
There are various notions of how to compare routes. Collect them all
in nm_platform_ip4_route_cmp(), nm_platform_ip4_route_hash(),
nm_platform_ip6_route_cmp(), and nm_platform_ip6_route_hash().

This way, we have them side-by-side, which makes the differences more
discoverable.
2017-08-03 18:51:35 +02:00
Thomas Haller
7141a3b87a platform: cleanup handling metric paramters for non-exclusive routes 2017-08-03 18:33:00 +02:00
Thomas Haller
93fd03277f platform: cleanup handling locks for non-exclusive routes 2017-08-03 18:33:00 +02:00
Thomas Haller
19a709069a platform: print lock paramters of route
It is valid to set "lock" for a property with numeric value 0.

    # ip route append 192.168.7.0/24 dev bond0 window lock 0
    # ip route append 192.168.7.0/24 dev bond0 window 0
    # ip route append 192.168.7.0/24 dev bond0 window lock 10
    # ip route append 192.168.7.0/24 dev bond0 window 10
    # ip -4 -d route show dev bond0
    unicast 192.168.7.0/24 proto boot scope link linkdown
    unicast 192.168.7.0/24 proto boot scope link linkdown
    unicast 192.168.7.0/24 proto boot scope link linkdown window lock 10
    unicast 192.168.7.0/24 proto boot scope link linkdown window 10

Our to-string methods should accurately print the content of
the routes. Note that iproute2 fails to do so too.
2017-08-03 18:33:00 +02:00
Thomas Haller
bf348cde69 platform: cleanup handling "window" for non-exclusive routes 2017-08-03 18:33:00 +02:00
Thomas Haller
8fc669c02a platform: use route src/src_plen when deleting IPv6 route 2017-08-03 18:33:00 +02:00
Thomas Haller
415e00d086 platform: use route pref_src when deleting IP route 2017-08-03 18:32:59 +02:00
Thomas Haller
8e4c5b173f platform: use route mss when deleting IP route
The mss (advmss, RTA_METRICS.RTAX_ADVMSS) is in a way part of
the ID for IPv4 routes. That is, you can add multiple IPv4 routes, that
only differ by mss.

On the other hand, that is not the case for IPv6. Two IPv6 routes
that only differ by mss are considered the same.

Another issue is, that you cannot selectively delete an IPv4 route based
on the mss:

    ip netns del x
    ip netns add x
    IP() {
      ip netns exec x ip "$@"
    }

    IP link add type veth
    IP link set veth0 name v
    IP link set veth1 up
    IP link set v up

    IP route append 192.168.7.0/24 dev v advmss 6
    IP route append 192.168.7.0/24 dev v advmss 7

    IP -d route show dev v

    IP route delete 192.168.7.0/24 dev v advmss 7

    IP -d route show dev v

It seems for deleting routes, kernel ignores mss (which doesn't really
matter for IPv6, but does so for IPv4).
2017-08-03 18:32:59 +02:00
Thomas Haller
88da13f0b2 platform: use correct gateway for deleting route
Routes may only differ by their gateway. When deleting
a route, we must specify the exact gateway to delete.
2017-08-03 18:32:59 +02:00
Thomas Haller
a041e431da platform: use correct scope for deleting IPv4 route
Refactor _nl_msg_new_route() to obtain the route scope (rtm_scope)
from the NMPObject, instead of a separate argument.

That way, when deleting an IPv4 route, we don't pick the first route
that matches (RT_SCOPE_NOWHERE), but use the actual scope of the route
that we want to delete. That matters, if there are more then one
otherwise identical routes that only differ by their scope.

For kernel, the scope of IPv6 routes is always global
(RT_SCOPE_UNIVERSE).

Also, during ip4_route_add() initialize the intermediate @obj to have
the values as we expect them after adding the route. That is necessary
to use it in _nl_msg_new_route(). But also nicer for consistency.

Also, move the scope_inv field in NMPlatformIP4Route to let the other
in_addr_t fields life side by side.
2017-08-03 18:32:59 +02:00
Thomas Haller
5a422af0d1 platform: use proper rt_source of route for add and delete
_nl_msg_new_route() should not get extra arguments, but instead
use all parameters from the NMPObject argument. This will allow
during nm_platform_ip_route_delete() to pick the exact route
that should be deleted.

Also, in ip4_route_add()/ip6_route_add(), keep the stack-allocated
@obj object consistent with what we expect to add. That is, set
the rt_source argument to the value of what the route will have
after kernel adds it. That might be necessary, because
do_add_addrroute() searches the cache for @obj.
2017-08-03 18:32:59 +02:00
Thomas Haller
b94e25e269 platform: drop duplicate cmd_obj_stackinit_id() virtual function
It can be implemented solely based on cmd_plobj_id_copy().
2017-08-03 18:32:59 +02:00
Thomas Haller
372f14a6ef platform: add compare functions for routes with different compare semantics
Routes are complicated.

`ip route add` and `ip route append` behaves differently with respect to
determine whether an existing route is idential or not.

Extend the cmp() and hash() functions to have a compare type, that
covers the different semantics.
2017-08-03 18:32:59 +02:00
Thomas Haller
54f8c2ac22 core: add nm_utils_ip6_address_same_prefix_cmp() helper
Useful for sorting/comparing.
2017-07-31 15:13:31 +02:00
Thomas Haller
8d03caf599 shared: cleanup NM_CMP_*() macros 2017-07-31 15:13:31 +02:00
Thomas Haller
b9fd352eca shared: move NM_CMP_*() helper macros to shared header 2017-07-31 15:13:31 +02:00
Thomas Haller
c8f3cd51ac platform/trivial: rename cmp helper macros 2017-07-31 15:13:31 +02:00
Beniamino Galvani
3bd5a83eff platform: fix failed assertion with cloned route
platform-linux: event-notification: NEWROUTE, seq 5: fd02::2/128 via fd01::1 dev 17 metric 0 mss 0 rt-src rt-unspec src ::/0 cloned mtu 1400
NetworkManager:ERROR:src/platform/nmp-object.h:614:ASSERT_nmp_cache_ops: assertion failed: (obj_old || obj_new)

Fixes: 9440eefb6d
2017-07-31 09:51:45 +02:00
Beniamino Galvani
565adb4df2 ppp: fix generation of IP config received from pppd
Since commit 22edeb5b69 ("core: track addresses for
NMIP4Config/NMIP6Config via NMDedupMultiIndex"), addresses can be
added to a IP config only after the ifindex has been set.

Fixes: 22edeb5b69
2017-07-28 10:37:23 +02:00