Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
16b0ddb66d policy: resync routes on platform change events
Monitor default routes from platform, and resync the default routes
on changes.

For one, this fixes the following use-case: have an assumed device em1
with two routes of metric 20 and 21. Activate em2, which will get effective
metric 22.
When externally removing route em1/20, em2 would resync the effective metric to
20. This is correct and already worked before. However, when deleting em1/21,
nothing happened. With this change, em2 would resync to metric 21 to fill the gap.

However this commit has much bigger effects: whenever the user externally adds
a default route to an interface for which NM manages an default route, NM will
delete it.
Also, when deleting the default route (managed by NM), NM would readd
it. Effectivly, the user can no longer mess with the default route on
interfaces for which it manages the default route.

If the connection is configured never-default, the user still can add
default routes and NM will not touch them.

Obviously, this has no effect for assumed devices either and the user
can externally add and remove default routes as he wishes.

https://bugzilla.gnome.org/show_bug.cgi?id=735512

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 22:55:32 +01:00
Thomas Haller
b4b67c47f1 policy: consider additional assumed routes when synchronizing the default route
Don't only consider the best route of assumed devices when syncing the route
metrics. This fixes the following scenario:

Have em1 assumed, with two default routes (metric 20 and 21).
When activating em2, NMDefaultRouteManager would  have determined
21 as the effective metric, thus replacing the assumed route of em1.

Since we don't want to touch assumed interfaces, it is wrong to
replace their default routes.

Instead, keep track of all the assumed default routes and consider their
metrics when choosing effective_metric.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 22:55:32 +01:00
Thomas Haller
6d4bb29781 policy: minor refactoring in NMDefaultRouteManager to access routes generically
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 22:55:32 +01:00
Thomas Haller
57dd4a125b device: only add default route when having any addresses
This fixes the failure to add a default route because no
addresses are configured yet.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 22:55:32 +01:00
Thomas Haller
462456f255 policy: remove redundant remove_default_route() functions from NMDefaultRouteManager
When calling update_default_route(), NMDefaultRouteManager will look at the
source, and determine whether it has a default route or not. For example
for device sources, this means calling nm_device_get_ip4_default_route().

If the source indicates that it has no default route, the effect of
calling update_default_route() is the same as calling
remove_default_route() (hence, remove() can be replaced by update()).

If the source however still indicates a default route, the behavior
would be different. This case would be an undesired inconsistancy,
because source and NMDefaultRouteManager would disagree of whether
the source has a default route.
Source must always properly indicate whether it has a default route
or not, hence this situation does not arise.

Hence it is always better to call update().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 22:55:32 +01:00
Thomas Haller
393f213c3b policy: remove unused @do_sync argument from NMDefaultRouteManager functions
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 22:55:32 +01:00
Thomas Haller
825885d5b1 policy: minor fix when having multiple default routes with metric MAXUINT32
The case of having a metric MAXUINT32 is special, because in face of
multiple default routes with the same metric, NMDefaultRouteManager
cannot reduce the effective metric (because there is no lower priority
value).

This case works already correct, just when adding such a default route,
ensure that we add it to the *first* entry.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 22:55:32 +01:00
Thomas Haller
a43ed6cb80 policy: refactor NMDefaultRouteManager to use union type NMPlatformIPXRoute
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 22:55:31 +01:00
Lubomir Rintel
d4240ad04c cli: Abort when given name of a non-existent connection for nmcli up
Even when ifname is present: nmcli c up name Nonexistent ifname wlan0
2014-11-19 19:51:44 +01:00
Lubomir Rintel
75f767ca23 libnm: Don't expect VPN connections to attach to the device 2014-11-19 19:51:44 +01:00
Lubomir Rintel
282d9b0e10 vpn: Propagate daemon exec error correctly
NetworkManager[31624]: <warn>  VPN service 'openvpn': could not launch the VPN service. error: (8) Failed to execute child process "/usr/local/libexec/nm-openvpn-service" (No such file or directory).
**
NetworkManager:ERROR:nm-manager.c:3094:_activation_auth_done: assertion failed: (error)
2014-11-19 19:51:44 +01:00
Lubomir Rintel
51974196f9 cli: Only escape VPN banner if it's present
If the connection is in ACTIVATING state, the banner is still NULL.
2014-11-19 19:51:44 +01:00
Thomas Haller
81446b5ad3 platform: add typedef for unions NMPlatformIPXAddress and NMPlatformIPXRoute
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 19:51:36 +01:00
Dan Winship
9f5cff0bb3 Merge branch 'dhcp-fixes' 2014-11-19 12:03:24 -05:00
Dan Winship
93799e68ba man: document the "internal" DHCP client 2014-11-19 12:03:03 -05:00
Dan Winship
4f2c553172 dhcp: Simplify nm-dhcp-systemd lease-handling code
An sd_dhcp_lease will always have an associated address, netmask, and
lifetime, so we don't have to check for errors when fetching them.
(The systemd code will fill in a default netmask if the server didn't
provide one; nm-dhcp-systemd's code to do that itself was redundant
and unused.)

Also, log the expiration time and NTP servers, for consistency with
everything else.
2014-11-19 12:03:03 -05:00
Dan Winship
7bf7ebc470 dhcp: fix startup warnings with dhcp=internal
If asked to read a file that doesn't exist, sd_dhcp_lease_load()
returns 0 (success) without setting the out lease argument. So we need
to check both the return status and the lease before proceeding.
2014-11-19 12:03:03 -05:00
Dan Winship
71b676590c dhcp: fix systemd-dhcp's writing of routes in lease file
inet_ntoa() uses a static buffer, so you can't call it twice in the
same fprintf() call.

https://bugs.freedesktop.org/show_bug.cgi?id=86438
2014-11-19 12:03:03 -05:00
Dan Winship
44eb50d12f dhcp: update system-dhcp code from upstream 2014-11-19 12:02:36 -05:00
Dan Winship
e30b07149f dhcp: update nm-dhcp-systemd code for system-dhcp re-import
Some of the patches we proposed were committed in slightly different
form.
2014-11-19 12:02:17 -05:00
Dan Winship
74678cf56b dhcp: re-fix system-dhcp code after re-import 2014-11-19 12:02:12 -05:00
Dan Winship
1ea0dd41b0 Merge branch 'master' into dhcp-merge
Conflicts:
	src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-client.c
	src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-lease.c
	src/dhcp-manager/systemd-dhcp/src/shared/fileio.c
	src/dhcp-manager/systemd-dhcp/src/shared/util.c
	src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-client.h
	src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-lease.h
2014-11-19 12:02:00 -05:00
Jiří Klimeš
af525e8a18 trivial: fix a comment typo in generate-plugin-docs.pl 2014-11-19 17:54:03 +01:00
Dan Winship
e2e4637cf4 dhcp: update systemd DHCP code
This is a direct dump from systemd git on 2014-11-19, git commit
a4962513.  Only relevant files were included.

    SYSTEMD_DIR=../systemd
    COMMIT=a4962513c555fe3ac4b5bebf97a71701361a45b0

    (
       cd "$SYSTEMD_DIR"
       git checkout "$COMMIT"
       git clean -fdx
    )
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-lease-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-lease-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-network.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-network.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-option.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-option.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-packet.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-packet.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-protocol.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-protocol.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-lease-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-lease-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-network.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-network.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-option.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-option.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-protocol.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-protocol.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/network-internal.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/network-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-client.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-client.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-lease.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-lease.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-client.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp6-client.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-lease.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp6-lease.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/async.h ./src/dhcp-manager/systemd-dhcp/src/shared/async.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/fileio.c ./src/dhcp-manager/systemd-dhcp/src/shared/fileio.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/fileio.h ./src/dhcp-manager/systemd-dhcp/src/shared/fileio.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/list.h ./src/dhcp-manager/systemd-dhcp/src/shared/list.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/macro.h ./src/dhcp-manager/systemd-dhcp/src/shared/macro.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/refcnt.h ./src/dhcp-manager/systemd-dhcp/src/shared/refcnt.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/siphash24.c ./src/dhcp-manager/systemd-dhcp/src/shared/siphash24.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/siphash24.h ./src/dhcp-manager/systemd-dhcp/src/shared/siphash24.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/socket-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/socket-util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/sparse-endian.h ./src/dhcp-manager/systemd-dhcp/src/shared/sparse-endian.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/strv.c ./src/dhcp-manager/systemd-dhcp/src/shared/strv.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/strv.h ./src/dhcp-manager/systemd-dhcp/src/shared/strv.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/time-util.c ./src/dhcp-manager/systemd-dhcp/src/shared/time-util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/time-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/time-util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/utf8.c ./src/dhcp-manager/systemd-dhcp/src/shared/utf8.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/utf8.h ./src/dhcp-manager/systemd-dhcp/src/shared/utf8.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/util.c ./src/dhcp-manager/systemd-dhcp/src/shared/util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/util.h ./src/dhcp-manager/systemd-dhcp/src/shared/util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/unaligned.h ./src/dhcp-manager/systemd-dhcp/src/shared/unaligned.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/in-addr-util.c ./src/dhcp-manager/systemd-dhcp/src/shared/in-addr-util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/in-addr-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/in-addr-util.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/_sd-common.h ./src/dhcp-manager/systemd-dhcp/src/systemd/_sd-common.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-client.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-client.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-lease.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-lease.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-client.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp6-client.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-lease.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp6-lease.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-event.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-event.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-id128.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-id128.h
2014-11-19 11:34:52 -05:00
Thomas Haller
0555df65d3 core: minor fix to ensure safe boolean comparison in have_ip6_address()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 17:12:00 +01:00
Lubomir Rintel
653b7e4805 cli: Watch for device as well as AC state changes when activating
The signals might be delivered in no particular order and we need to wait for
the device to reach stable state (whether it's successfully conntected or not)
as well as the active connection to leave ACTIVATING state.

https://bugzilla.gnome.org/show_bug.cgi?id=740320
2014-11-19 17:06:33 +01:00
Jiří Klimeš
9503d35d1e man: fix formatting leftover from man -> xml migration 2014-11-19 16:53:30 +01:00
Jiří Klimeš
3c8dfb91f6 man: update version reference to 1.0 in manual pages 2014-11-19 16:53:30 +01:00
Jiří Klimeš
9a13378753 dispatcher: introduce new env variables for gateway address (bgo #740363)
IP4_GATEWAY
VPN_IP4_GATEWAY
IP6_GATEWAY
VPN_IP6_GATEWAY

We still put gateway into IP[46]_ADDRESS_N for backward compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=740363
2014-11-19 16:52:25 +01:00
Lubomir Rintel
c30379e0fd libnm-core: Add missing type cast
Fixes testing on 32-bit arches:

/core/general/test_setting_compare_timestamp:
(./test-general:29331): GLib-GObject-WARNING **: g_object_set_valist: object class `NMSettingConnection' has no property named `$?\xff\xff\x89t$0\x89|$4\xe8\u001c\x98\xff\xff\x85\xc0tM\x83\xf8\xfft3\x8dT$(\xc7D$\u0008'
/bin/sh: line 5: 29331 Trace/breakpoint trap   ${dir}$tst
FAIL: test-general

Fixes: 093a3c88d0
2014-11-19 16:04:41 +01:00
Dan Winship
8473bb310d tui: refresh the "nmtui connect" list when connections are added/removed
We were refreshing the list when the set of available devices changed,
or the set of active connections changed, but not when the set of
available connections changed.

https://bugzilla.gnome.org/show_bug.cgi?id=740333
2014-11-19 10:03:57 -05:00
Dan Winship
11c1cad8ae docs: update setting/plugin docs, and build them from libnm (bgo 740224) 2014-11-19 09:24:10 -05:00
Jiří Klimeš
485edd52a7 libnm-core: update ip6-privacy ifcfg-rh description 2014-11-19 09:24:10 -05:00
Jiří Klimeš
a4d4fa04b5 libnm-core: document AUTOCONNECT_PRIORITY for ifcfg-rh 2014-11-19 09:24:10 -05:00
Jiří Klimeš
3bcba5ddf9 libnm-core: update BAND and CHANNEL ifcfg-rh description
We support BAND variable now.
2014-11-19 09:24:10 -05:00
Jiří Klimeš
a244e61688 libnm-core: update documentation of addresses and gateway properties 2014-11-19 09:24:10 -05:00
Jiří Klimeš
07bd9a1b76 man: ifcfg-rh manual page text update 2014-11-19 09:24:10 -05:00
Dan Winship
c7341c982d man, docs: add the secret flags notes non-hackishly
Since libnm-core secret-flags properties are now enum-typed rather
than just being uints, we can now actually recognize them when
generating docs, rather than just assuming that every property whose
name ends in '-flags', but isn't in NMSettingDcb, is a secret-flags
property.
2014-11-19 09:24:10 -05:00
Dan Winship
e43ba45f2f cli, libnm: don't use D-Bus-specific documentation in nmcli
Now that nm-setting-docs.xml is more D-Bus-specific, it's less
appropriate for nmcli's internal documentation. So generate a second
copy of the docs without using the overrides file, and use that one
for nmcli's documentation.
2014-11-19 09:24:10 -05:00
Dan Winship
36156b70dc libnm: Override parts of nm-setting-docs.xml
Add "---dbus---" sections to the NMSetting property docs, in the same
style as the plugin docs, parse them out into a file
"nm-setting-docs-overrides.xml", and use them to override the GObject
property docs in nm-setting-docs.xml.

This lets us put more D-Bus-specific information in the setting docs,
without cluttering up the property docs, and it also lets us document
dbus-only properties.
2014-11-19 09:24:10 -05:00
Dan Winship
780d8bf2fe libnm: fix nm-setting-docs.xml property types
Add nm_setting_get_dbus_property_type(), and use this to get the
correct type for properties in nm-seting-docs.xml, in situations where
the D-Bus and GObject property types don't match.

In the case of enum/flags-valued properties, give both the enum name
and the underlying D-Bus type.
2014-11-19 09:24:10 -05:00
Dan Winship
2f81a8bcbe libnm-core: make GBytes D-Bus marshalling be built-in to NMSetting
Each GBytes-valued property was using
_nm_setting_class_transform_property() to register a GBytes<->'ay'
transform. So just build that rule into the generic machinery in
nm-setting.c.
2014-11-19 09:24:10 -05:00
Dan Winship
c14486984e libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.

With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).

The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...

(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-11-19 09:24:09 -05:00
Jiří Klimeš
3889ff864c man: update nmcli-examples manual page 2014-11-19 15:21:34 +01:00
Jiří Klimeš
3595bef178 man: fix a typo in nmtui manual page 2014-11-19 13:22:28 +01:00
Thomas Haller
d638ccdeca firewall: merge branch 'th/rh1098281_firewall_assumed_device'
https://bugzilla.redhat.com/show_bug.cgi?id=1098281

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 13:08:15 +01:00
Thomas Haller
06a45fdcaf firewall: don't set firewall zone for assumed devices
https://bugzilla.redhat.com/show_bug.cgi?id=1098281

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 12:59:42 +01:00
Thomas Haller
1141727690 firewall: always complete callbacks asynchronously
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 12:59:42 +01:00
Thomas Haller
90a3332199 firewall: invoke FwAddToZoneFunc callback also when cancelling
Not invoking a callback when cancelling the operation is counter
intuitive.

Note that NMPolicy refs the device, cancelling the call would leave
the reference hanging. That was not an issue because the call was
never cancelled. But still the behavior of NMFirewallManager is
unexpected.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 12:58:36 +01:00
Thomas Haller
b0b7473af1 firewall: make call handle an opaque pointer type
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-19 12:58:36 +01:00