Commit Graph

18619 Commits

Author SHA1 Message Date
Thomas Haller
4c8673d978 cli: refactor connection.autoconnect-retires to use int-getter 2017-09-12 16:34:17 +02:00
Thomas Haller
e36ed195ba cli: refactor ipv4.dad-timeout to use int-getter
- Reduce duplicated code and implement the property according to
  best-practice for integer types.

- Do not translate the output

- This way, the setter also supprts the nick names
2017-09-12 16:03:05 +02:00
Thomas Haller
6ad53975b3 cli: fix _set_fcn_gobject_int_impl() to accept nick for setting int property
Fixes: e086cf1887
2017-09-12 16:02:39 +02:00
Thomas Haller
3c84dd15e0 core/dhcp: use addr-family parameter for instead of boolean
In many cases we want to treat IPv4 and IPv6 generically. That looks nicer
if we distingish by an @addr_family integer, instead of a boolean.

Replace the @is_ipv6 boolean with an @addr_family paramter. The @is_ipv6
boolean is inconsistent with other places where we use @is_ipv4 to
indicate the opposite. Eventually, we should use @addr_family
everywhere.

Also, at the call site it's not immediately clear what TRUE/FALSE means,
here AF_INET/AF_INET6 is better.
2017-09-11 15:05:57 +02:00
Thomas Haller
1aa36dde94 device: enable support for ipv6.dhcp-timeout
- cleanup data type and use guint32 consistently. We might want to
  introduce a new "infinity" value. But since libnm's
  NM_SETTING_IP_CONFIG_DHCP_TIMEOUT asserts against the range
  0 - G_MAXINT32, we cannot express it as -1 anyway. So, infinity
  will have the numerical value G_MAXINT32, hence guint32 is just
  fine.

- make use of existing ipv6.dhcp-timeout setting and add global
  default configuration in NetworkManager.conf

- instead of having subclasses call nm_device_set_dhcp_timeout(),
  add a virtual function get_dhcp_timeout().
2017-09-11 15:05:57 +02:00
Francesco Giudici
fa46736013 dhcp: dhclient: fix daemon start when dhcp-timeout is specified
A typo in the new dhcp-timeout option caused the dhclient daemon to exit
with error when the dhcp-timeout option was specified.
This prevents dhcp connection to be upped.

Fixes: 82ef497cc9
2017-09-11 14:52:51 +02:00
Thomas Haller
7d00a96d23 contrib/rpm: allow building RPM without fatal warnings
A newer compiler version might emit some warnings and break the build
of the RPM. Of course, such warnings must be fixed. But it is still very
inconvenient to break the build of an old RPM version without easy workaround.

When building without "test" (which is on by default), don't use fatal warnings
for compilation.
2017-09-11 14:22:10 +02:00
Thomas Haller
66a09b2192 contrib/NM-log: don't use exec in bash functions
When sourcing the file, using exec inside NM-show-journal is a bad idea,
because it replaces the calling shell.
2017-09-08 17:18:32 +02:00
Beniamino Galvani
44e71d70ea ppp: rename the interface only when necessary
Previously when the interface created by pppd was already the one we
expected, we would rename it to itself and remove the device from the
manager. Don't do it.

Fixes: 6c3195931e
2017-09-08 14:29:02 +02:00
Thomas Haller
4bc231e33a core: merge branch 'th/platform-route-pt4' (part 2)
Drop NMDefaultRouteManager.

https://github.com/NetworkManager/NetworkManager/pull/26
2017-09-08 13:50:33 +02:00
Thomas Haller
77ec302714 core: rework handling of default-routes and drop NMDefaultRouteManager
Remove NMDefaultRouteManager. Instead, add the default-route to the
NMIP4Config/NMIP6Config instance.

This basically reverts commit e8824f6a52.
We added NMDefaultRouteManager because we used the corresponding to `ip
route replace` when configuring routes. That would replace default-routes
on other interfaces so we needed a central manager to coordinate routes.
Now, we use the corresponding of `ip route append` to configure routes,
and each interface can configure routes indepdentently.

In NMDevice, when creating the default-route, ignore @auto_method for
external devices. We shall not touch these devices.

Especially the code in NMPolicy regarding selection of the best-device
seems wrong. It probably needs further adjustments in the future.
Especially get_best_ip_config() should be replaced, because this
distinction VPN vs. devices seems wrong to me.
Thereby, remove the @ignore_never_default argument. It was added by
commit bb75026004, I don't think it's
needed anymore.

This brings another change. Now that we track default-routes in
NMIP4Config/NMIP6Config, they are also exposed on D-Bus like regular
routes. I think that makes sense, but it is a change in behavior, as
previously such routes were not exposed there.
2017-09-08 11:11:21 +02:00
Thomas Haller
0918b4914d core: support tracking default-route in NMIP4Config/NMIP6Config
Default-routes are for the most part like regular routes. Add support to
track them like regular routes in NMIP4Config/NMIP6Config.

One thing is, sometimes we need to figure out whether an ip-config
instance has a default-route. For that, keep track of the best
default-route (there might be multiple) and expose it. That is
the most complicated part of this patch, because there are so many
places where the list of routes gets modified (replace, intersect,
subtract, merge, add), and they all need to take care of updating
the best default-route.

In a next patch, NMDefaultRouteManager will be dropped and default-routes
will be tracked by NMIP4Config/NMIP6Config.
2017-09-08 11:11:21 +02:00
Thomas Haller
a214f398e7 core: merge branch 'th/platform-route-pt4' (part 1)
Several patches with cleanup and in prepration for dropping
NMDefaultRouteManager.

https://github.com/NetworkManager/NetworkManager/pull/26
2017-09-08 11:09:42 +02:00
Thomas Haller
96f1358eef core: return new route from _nm_ip_config_add_obj()
Later we will need the exact instance that we just added (or the previously
existing one, if the new route is already tracked).
2017-09-08 11:05:05 +02:00
Thomas Haller
ead1ffd9bc core/trivial: rename test functions _nmtst_nm_ip*_config_*() to _nmtst_ip*_config_*() 2017-09-08 11:05:05 +02:00
Thomas Haller
e805201f4b platform: delete routes after adding in nm_platform_ip_route_sync()
Previously, we would first delete routes that are not to be added,
before adding the new ones.

This has the advantage, that even if delete removes the wrong route,
add would restore the expected state. This tries to workaround the fact
that RTM_DELROUTE allows for wild-card fields, and might delete the
wrong route.

However, for example when bumping the route metric after connectivty
check (removing the default-route with metric 20100 and adding the one
with metric 100), there is a short moment when there is no
default-route.

To avoid that, don't do delete-then-add, but add-then-delete.
2017-09-08 11:05:05 +02:00
Thomas Haller
7ab40b9e10 core: ignore routes from non-main table in nm_ip4_config_capture()
and nm_ip6_config_capture().
2017-09-08 11:05:05 +02:00
Thomas Haller
199499967a core: don't loop twice over routes in nm_ip4_config_capture()
and nm_ip6_config_capture().
2017-09-08 11:05:05 +02:00
Thomas Haller
315bd0a97d core: add nm_utils_connection_has_default_route()
Taken from "src/nm-default-route-manager.c".
2017-09-08 11:05:04 +02:00
Thomas Haller
e99a603944 device: expose nm_device_get_ip_route_metric() function
Will be used later.
2017-09-08 11:05:04 +02:00
Thomas Haller
c16e871888 core: nm_utils_ip_route_metric_normalize() util
Functions that take and addr_family argument are just nicer
to use at places where we treat IPv4 and IPv6 generically.
2017-09-08 11:05:04 +02:00
Thomas Haller
6801cd65bf platform: add nm_clear_nmp_object() util 2017-09-08 11:05:04 +02:00
Thomas Haller
a0ca607080 core: return new object from _nm_ip_config_add_obj()
Will be used later.
2017-09-08 11:05:04 +02:00
Thomas Haller
546e12417a core: use _nm_ip_config_add_obj() in nm_ip4_config_replace() for routes
Avoid calling nm_dedup_multi_index_add() directly, like we do for all other places.
Instead, call the wrapper _nm_ip_config_add_obj() which does some pre-precessing.

In practice, the result is exactly the same (at the moment). But there should by
only one way to add the route.
2017-09-08 11:05:04 +02:00
Thomas Haller
af1ad0eed7 core/tests: add test for nm_ip6_config_replace() 2017-09-08 11:05:04 +02:00
Thomas Haller
b3254da173 platform/trivial: add code comments 2017-09-08 11:05:04 +02:00
Thomas Haller
5c7e0654eb policy: take reference to best_device/activating_device
Don't rely on manager keeping them alive long enough. E.g.
get-best-device() is used when resetting the best device,
however, it accesses the current device (hence, it relies
on manager removing the device from the list, but keeping
it alive long enough).
2017-09-08 11:05:04 +02:00
Thomas Haller
f8cb6dcbb1 policy: cleanup setting default_device/activating_device
- _LOGt() whenever the properties change.
- some minor refactoring
2017-09-08 11:05:04 +02:00
Thomas Haller
a75f528618 policy: don't re-lookup the best device during update_system_hostname()
We already track the best device as priv->default_device4 / priv->default_device6.
Don't try to look it up again. If the cached values from @priv are invalid/outdated,
that should be fixed instead.

This was already introduced by commit 773c006a4c.
But I don't think it should be done.
2017-09-08 11:05:04 +02:00
Thomas Haller
8881c11f93 policy: always check for hostname from DHCPv6 in update_system_hostname()
There is no reason for if-else-if. If DHCPv4 doesn't provide a hostname (but we
are doing DHCP), just check for DHCPv6.
2017-09-08 11:05:04 +02:00
Thomas Haller
9574472f9b policy: refactor setting hostname from DHCP in update_system_hostname() 2017-09-08 11:05:04 +02:00
Thomas Haller
959944d623 shared: add nm_g_object_ref_set() and nm_clear_g_object()
- nm_clear_g_object() is like g_clear_object() but:

  - it returns a boolean value, indicating that something was cleared.

  - it includes an nm_assert() to check that the pointer is still
    valid.

  - it uses typeof() instead of blindly casting the argument.

- nm_g_object_ref_set() combines nm_clear_g_object() and resetting
  the pointer to a new object, including taking a reference.

  - also returns a boolean, indicating whether something changed.

  - it gets the order of operations right: first it increses the
    ref-count, before unrefing the old object.

  - like nm_clear_g_object() and nm_clear_g_free() it first sets
    the destination to NULL, instead of leaving a dangling pointer
    for the duraction of the unref/free call.

- fix nm_clear_g_free() not to use a possibly dangling pointer.
  Striclty speaking, that is undefined behavior.
2017-09-08 11:05:04 +02:00
Thomas Haller
19716df23d shared: add nm_g_object_class_find_property_from_gtype() util
And relax the type for nm_auto_unref_gtypeclass macro. Like
g_type_class_unref() itself, you usually don't use it with a GTypeClass
base class, but some subtype like GObjectClass.
2017-09-07 18:10:06 +02:00
Thomas Haller
ac5350fef2 dns: use 127.0.0.53 address in /etc/resolv.conf with systemd-resolved
https://bugzilla.gnome.org/show_bug.cgi?id=787378
2017-09-07 15:29:57 +02:00
Beniamino Galvani
2f3e978f57 ifnet: ensure an error is always returned when add fails
There are many places where the function can fail without returning an
error, leading to a crash. Fix this.
2017-09-07 15:09:15 +02:00
Thomas Haller
d4a5e2b1c8 contrib/NM-log: don't run less with --quit-on-intr argument
I find it annoying when ^C exits less and it prompts me to often
do `NM-log | less -R` instead.
2017-09-07 14:45:26 +02:00
Thomas Haller
83e2764050 contrib/NM-log: colorize warnings and errors in red (fix)
Must not colorize the trailing space, otherwise the following
" device" will no longer match.
2017-09-07 14:29:11 +02:00
Thomas Haller
b20fc58b3c contrib/NM-log: colorize warnings and errors in red
- remove "\r\n" line endings
- colorize <warn> and <error> in red
- extend matching the info levels to include the timestamp. This
  (intentionally) will no longer highlight messages from ModemManager,
  which don't include a timestamp.
2017-09-07 14:24:56 +02:00
Thomas Haller
cffde0101e contrib/NM-log: improve script and make it sourceable
- use "grep -a" so that grep doesn't refuse to work in binary input.
- make the script source-able to only define the NM-colorize and
  NM-show-journal
- In case the script is sourced, it also defines a NM-log function,
  which does the same as the script itself.
- rename internal functions so that they have names starting with "NM"
  in case of sourcing.
2017-09-07 14:04:13 +02:00
Piotr Drąg
5ad6c8471d po: mark broken strings in Japanese translation as fuzzy (bgo#787382)
https://bugzilla.gnome.org/show_bug.cgi?id=787382
2017-09-07 12:22:44 +02:00
Piotr Drąg
b13ba34acb po: update Polish (pl) translation (bgo #787380)
https://bugzilla.gnome.org/show_bug.cgi?id=787380
2017-09-07 12:19:45 +02:00
Thomas Haller
42edfb4a7f vpn: merge branch 'th/vpn-route-bgo787370'
Fix and improve determining the route to the external VPN gateway.

https://bugzilla.gnome.org/show_bug.cgi?id=787370
2017-09-07 12:05:06 +02:00
Thomas Haller
10fc74819c vpn: only rely on ip route get to resolve route to external VPN gateway
Until recently, we would only consier the IP config of the parent device
to determine the route to the external VPN gateway. We changed that, to
additionally improve the guess by letting kernel resolve the route.

Now, drop checking the parent's config entirely. The only thing that
matters is the here and now runtime configuraion on the parent device.
And for that we ask kernel to resolve the route.
2017-09-07 12:00:36 +02:00
Thomas Haller
f6dabee068 vpn: improve resolving route to external VPN gateway by restricting oif
Previously, we would try to resolve the route in general (unrestricted
to a certain ifindex), and reject it the result wasn't on the parent
device.

Now, use the oif argument, and resolve the route only on the parent device.

The problem is that kernel would pretend that the destination is onlink, if
there is no route to it. Hence, hack around that by only accepting an onlink
route, if the VPN gateway itself is site-local. Yes, there are scenarios where
this will still lead to a wrong guess. See related bug rh#1489343 for kernel.
2017-09-07 11:57:44 +02:00
Thomas Haller
7046ce5332 platform: add oif argument to nm_platform_ip_route_get()
Analog to `ip route get $DST oif $IFACE`.
2017-09-07 11:14:27 +02:00
Thomas Haller
cac10198f6 vpn: apply parent config in nm_vpn_connection_apply_config() first
In practice, it shouldn't matter much, because NM may frequently
reapply the IP config. Hence, it anyway must cope with the fact that
IP config from a previous iteration is already applied on the VPN device,
before applying it to the parent device.

Anyway, it makes a bit more sense to apply it first the the parent device.
2017-09-07 11:14:27 +02:00
Thomas Haller
c8e6f3e5fb vpn: fix ifindex of parent IP config in apply_parent_device_config()
When creating the NMIP4Config/NMIP6Config instance, we must always use the right
ifindex. That is the ifindex, on which we want to apply the config. It also means,
that for device-based VPNs (those with priv->ip_ifindex set, like OpenVPN), the
parent's config must have the ip-ifindex of the parent device. Not of the
VPN's device.

One effect of this bug is that in add_ip4_vpn_gateway_route() we resolve
the route to the external gateway and only accept it if it's on the
parent device. But since the ifindex of the config was wrong, we would accept
route on the wrong interface.

https://bugzilla.gnome.org/show_bug.cgi?id=787370
2017-09-07 11:14:27 +02:00
Beniamino Galvani
bb99a0e433 platform: refetch IPv6 address if still present after deletion
After commit 5a69b27a64 ("platform: let platform operations only
consider kernel response") the platform only relies on kernel messages
and doesn't check if a deleted object is gone from the cache. For IPv6
addresses it can happen that the RTM_DELADDR comes after the ack, and
this causes random failures in test /address/ipv6/general-2:

 [10.8009] platform: address: deleting IPv6 address 2001:db8:a🅱️1:2:3:4/64, ifindex 12 dev nm-test-device
 [10.8009] platform-linux: delayed-action: schedule wait-for-nl-response (seq 55, timeout in 0.199999680, response-type 0)
 [10.8009] platform-linux: delayed-action: handle wait-for-nl-response (any)
 [10.8009] platform-linux: netlink: recvmsg: new message (2), flags 0x0100, seq 55
 [10.8009] platform-linux: delayed-action: complete wait-for-nl-response (seq 55, timeout in 0.199980533, response-type 0, success)
 [10.8009] platform-linux: do-delete-ip6-address[12: 2001:db8:a🅱️1:2:3:4]: success
 **
 NetworkManager:ERROR:src/platform/tests/test-common.c:1127:_ip_address_del: assertion failed: (external_command)

Use the same workaround in place for the addition of IPv6 addresses,
i.e. refetch the object if the address is still present after the ack.
2017-09-07 09:50:59 +02:00
Beniamino Galvani
04182dcc9a platform: fix coding style (missing braces) 2017-09-07 09:50:16 +02:00
Thomas Haller
4a5ab5f6cb tui: extend range of route metric to full uint32
That is how kernel allows it and the rest of NetworkManager's API.
2017-09-05 19:27:19 +02:00