Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
7405d5c7b7 nmcli: extend nmcli device set command to accept explicit ifname specifier
Without it, you cannot set the properties of a device named "help".
Now you can with:

  $ nmcli device set ifname help autoconnect no
2015-09-18 13:14:44 +02:00
Lubomir Rintel
4dffbf8f6a cli: add nmcli device set command
Co-Authored-By: Thomas Haller <thaller@redhat.com>
2015-09-18 13:14:35 +02:00
Lubomir Rintel
b2fa116486 libnm,libnm-glib: add Device.Managed setter 2015-09-18 13:14:23 +02:00
Thomas Haller
0eebf580c1 device: allow modifying Managed property
https://bugzilla.redhat.com/show_bug.cgi?id=1114685
https://bugzilla.gnome.org/show_bug.cgi?id=746566
Related: https://bugzilla.gnome.org/show_bug.cgi?id=680909
Related: https://bugzilla.gnome.org/show_bug.cgi?id=731014

Based-on-patch-by: Lubomir Rintel <lkundrak@v3.sk>
2015-09-18 13:14:23 +02:00
Beniamino Galvani
69315953eb core: merge branch 'bg/update-metered-on-the-fly-bgo724041'
https://bugzilla.gnome.org/show_bug.cgi?id=754409
2015-09-18 11:53:21 +02:00
Beniamino Galvani
2562a993c4 policy: react to firewall/metered changes on UPDATED_BY_USER signal
Subscribe to the UPDATED_BY_USER signal (instead of UPDATED) to listen
for changes to the firewall zone and metered properties of a
connection since these modifications are supposed to come from user
intervention.
2015-09-18 11:48:37 +02:00
Beniamino Galvani
d910c94beb policy: update device's metered property when connection changes
If the metered property of a connection is changed, an activated
device associated to the connection must be updated immediately with
the new metered value.

https://bugzilla.gnome.org/show_bug.cgi?id=754409
2015-09-18 11:48:37 +02:00
Beniamino Galvani
94fea0b581 policy: refactor handling of UPDATED signal
Obtain a reference to the device in connection_updated() so that it
will be easier to call other functions needing it.
2015-09-18 11:48:37 +02:00
Thomas Haller
54afd0400b platform: merge branch 'th/platform-refresh-link-bgo754996'
https://bugzilla.gnome.org/show_bug.cgi?id=754996
2015-09-18 11:27:40 +02:00
Thomas Haller
f4f4e1cf09 platform: cancel delayed action REFRESH_LINK when receiving an update
When we receive an update for a link, cancel a scheduled
REFRESH_LINK delayed-action for that ifindex. At the point when we
scheduled refrehing the link, we only cared about receiving a
notification that was newer then the current state.

We scheduled requesting this new notification to resync the cache.
It is not necessary to actually request a new update, any update we
receive *after* requesting a new update will suffice.

This potentially saves extra round-trips re-requesting the link.
2015-09-18 11:24:21 +02:00
Thomas Haller
2cd6aaa918 platform: refresh links when parent gets removed
When moving a link to another netns, it gets removed from
NMPlatform's view.

Currently kernel does not sent a notification to inform about
that change (see related bug rh#1262908).

Ensure that we reload all linked interfaces which now might
have an invisible parent.
2015-09-18 11:05:37 +02:00
Thomas Haller
eee240ffe8 platform: fix handling refresh-link delayed actions
Due to a bug, we would only handle one REFRESH_LINK delayed action
and ignore the ones queued afterwards.

Fixes: 051cf8bbde
2015-09-18 11:01:21 +02:00
Jiří Klimeš
0f694f1a9a coverity: calm coverity for clock_gettime() return value check
Defect type: CHECKED_RETURN
3. NetworkManager-1.0.6/src/platform/nm-linux-platform.c:1145: check_return: Calling "clock_gettime" without checking return value (as is done elsewhere 6 out of 7 times).
2015-09-18 08:40:08 +02:00
Thomas Haller
d20948647c exported-object: fix type of @interface variables to be GDBusInterfaceSkeleton 2015-09-17 16:59:16 +02:00
Jiří Klimeš
ed85fcc711 ifcfg-rh: ignore GATEWAY from network file for DHCP connections (rh #1262972)
The GATEWAY from /etc/sysconfig/network file is used as a default value when
no GATEWAY is in ifcfg file. However, we have to ignore that GATEWAY for
connections without static addresses. Otherwise such connections would be
invalid and would disappear after restart/reaload.

Some notes:
Putting GATEWAY into /etc/sysconfig/network is not recommended, because it
inherently belongs to the ifcfg file as it is a per-interface property.
The recommended practice is to specify GATEWAY in individual ifcfg files and
define DEFROUTE=no if the interface should not get the default route.
But we continue to read GATEWAY from /etc/sysconfig/network for compatibility
reasons.
See also
https://bugzilla.redhat.com/show_bug.cgi?id=896198#c25
https://bugzilla.redhat.com/show_bug.cgi?id=896198#c27

Fixes: f17699f4e3

https://bugzilla.redhat.com/show_bug.cgi?id=1262972
2015-09-17 15:02:35 +02:00
Jiří Klimeš
64e3873faf ifcfg-rh: (trivial) remove unused network_file parameter 2015-09-17 15:02:35 +02:00
Jiří Klimeš
8e3ae81566 examples: generate UUID in add-wifi-eap-connection.py
so that it can be run multiple times.
2015-09-17 14:49:04 +02:00
Jiří Klimeš
a25bbde641 examples: add a python example for adding WPA PSK Wi-Fi connection
and rename add-system-wifi-connection.py to add-wifi-eap-connection.py
2015-09-17 14:46:19 +02:00
Thomas Haller
9e52613612 dhcp/systemd: fix leaking leases after dhcp_lease_load()
Fixes: d2dd3b2c90
2015-09-17 12:14:22 +02:00
Thomas Haller
ed5577f762 dhcp/systemd: fix unrefing lease after API change of sd_dhcp_client_get_lease()
sd_dhcp_client_get_lease() no longer refs the lease as of
e6b18ffaea

Fixes: c05557971c
2015-09-17 12:05:50 +02:00
Thomas Haller
597efc7687 Revert "systemd/dhcp: make sd_dhcp_lease_*() functions public again"
Upstream systemd made a previously "public" API internal. In commit
e82f430eae I fixed that up by reverting
the upstream patch. Revise that, and instead adjust our usage of the
API to use the internal API.

After all, we anyway make use of systemd API that is not (currently)
intended to become part of the public API. Before the systemd library
happens, we must revisit this.

This reverts commit e82f430eae.
2015-09-16 17:11:39 +02:00
Thomas Haller
2ca1021168 systemd/build: split CPPFLAGS to only include needed paths
Optimally, we only make use of systemd API that is intended to be public
and that will be later part of the system-library. That is currently
not yet possible and we need "-Isrc/systemd/src/basic" to build
"nm-dhcp-systemd.h". Still, split the include paths to build systemd
code itself, contrary to the user of the API.
2015-09-16 16:55:43 +02:00
Thomas Haller
3ba1c8e297 systemd/build: use separate NETWORKMANAGER_COMPILATION define for systemd build 2015-09-16 16:54:51 +02:00
Thomas Haller
c05557971c systemd: merge branch 'systemd-integration' into master 2015-09-16 16:54:03 +02:00
Thomas Haller
08916936bc core: merge branch 'lr/default-unmanaged-bgo746566' (early part)
Fix setting D-Bus properties in "nm-manager.c" and do some refactoring
related to unmanaging devices.

https://bugzilla.gnome.org/show_bug.cgi?id=746566
2015-09-16 16:38:27 +02:00
Thomas Haller
6125523740 device: refactor setting unmanaged based on device-spec 2015-09-16 16:36:55 +02:00
Thomas Haller
fd8dde5c68 device: add explicit NM_UNMANAGED_LOOPBACK flag for not managing "lo" 2015-09-16 16:36:55 +02:00
Thomas Haller
a33fc00239 core: refactor setting of D-Bus properties via NMManager
- Also if the target object is the NMManager instance itself,
  re-fetch the manager via nm_bus_manager_get_registered_object().
  This way, we only set the property on the manager, if
  it's also exported according to the bus-manager. Also,
  we don't treat the manager instance special.

- Move fetching the object (nm_bus_manager_get_registered_object())
  from do_set_property_check() to prop_set_auth_done_cb(). Otherwise,
  we fetch the object first, but there is no guarantee that the object
  is still exported after the asynchronous authentication succeeds.
2015-09-16 16:36:46 +02:00
Thomas Haller
a55c87a2c0 core: refactor NMBusManager to hold reference to NMExportedObject directly
Previously, nm_bus_manager_register_object() would take various D-Bus
skeleton objects that were associated with one NMExportedObject.
This was confusing, in that these skeleton objects are all for the
same NMObject but correspond to different D-Bus interfaces.

Also, setting the D-Bus property "Managed" of a Device is broken
because we might retrieve the wrong skeleton.

Now, the NMBusManager has a reference to the exported object directly.
The skeleton interface instances instead are now exposed by the NMExportedObject.
2015-09-16 16:25:02 +02:00
Thomas Haller
e82f430eae systemd/dhcp: make sd_dhcp_lease_*() functions public again
This reverts systemd-upstream commit
bd91b83e57

  commit bd91b83e578165b4c242c9f34ff1d3be8fb3ab22
  Author: Lennart Poettering <lennart@poettering.net>
  Date:   Wed Aug 26 20:48:21 2015

      dhcp: keep lease save/load functions private

      When we make sd-dhcp public one day we really should not make
      sd_dhcp_lease_save() and sd_dhcp_lease_load() public, since it's pretty
      much only useful as internal utility for networkd itself.
2015-09-16 14:54:56 +02:00
Thomas Haller
3383d5d0a6 systemd: update code from upstream
This is a direct dump from systemd git on 2015-09-16, git commit
ac2896bab6.

======

SYSTEMD_DIR=../systemd
COMMIT=ac2896bab61bd8cd0b8a8b92f8347e2c11a088b5

(
  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/async.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.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/list.h"
nm_copy_sd "src/basic/log.h"
nm_copy_sd "src/basic/macro.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
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/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.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/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/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/ipv4ll-internal.h"
nm_copy_sd "src/libsystemd-network/ipv4ll-internal.h"
nm_copy_sd "src/libsystemd-network/ipv4ll-network.c"
nm_copy_sd "src/libsystemd-network/ipv4ll-packet.c"
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/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-icmp6-nd.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
2015-09-16 14:28:05 +02:00
Thomas Haller
30e6c71fad core: forward declare NMExportedObject in "nm-types.h" 2015-09-15 23:12:50 +02:00
Thomas Haller
0e5af7fa46 Revert "libnm: don't add objects to cache until they're async-inited"
Reverting, because patch breaks tests for "libnm/tests".

This reverts commit 88f0d646d5.
2015-09-15 23:11:47 +02:00
Thomas Haller
e908c9c293 trivial: fix spelling in comment
Fixes: 9a88d72fd4
2015-09-15 18:25:24 +02:00
Lubomir Rintel
88f0d646d5 libnm: don't add objects to cache until they're async-inited
Otherwise the uninitializeded objects could be prematurely signalled if their
paths are seen twice in quick succession. This happens when you have ethernet
hardware and add an ethernet connection -- it's immediatelly added to
AvialableConnections and the property reload signals the object addition
before the NMRemoteSettings's GetSettings() finishes:

  # nmcli c add type ethernet autoconnect no ifname '*'
  (process:4610): libnm-CRITICAL **: nm_connection_get_id: assertion 's_con != NULL' failed
  Connection '(null)' ((null)) successfully added.
  #

https://bugzilla.gnome.org/show_bug.cgi?id=754794
2015-09-15 16:53:26 +02:00
Lubomir Rintel
9a88d72fd4 core: register G_TYPE_SOCKET early
Concurrent registrations later on can cause a deadlock due to a GLib bug.

https://bugzilla.gnome.org/show_bug.cgi?id=754795
2015-09-15 16:53:17 +02:00
Jiří Klimeš
2b129cd8da merge: improve handling of wake-on-lan property (rh #1260584)
https://bugzilla.redhat.com/show_bug.cgi?id=1260584
2015-09-15 12:11:55 +02:00
Jiří Klimeš
4485b4ec2f nmcli: wake-on-lan property set/get fixes
- accept a numeric value (decimal or hex (0x prefix))
- display a numeric value of the property in addition to the strings
- add/accept spaces between string names

to behave similar to other flags' properties.
2015-09-15 11:46:37 +02:00
Jiří Klimeš
f88ce92b25 nmcli: allow "none" value for ethernet.wake-on-lan property (rh #1260584)
Aliases "disable" and "disabled" are accepted too.

nmcli> set 802-3-ethernet.wake-on-lan none

It was possible to remove flags by setting a string containing just white
spaces, but it was user unfriendly and non-intuitive.

https://bugzilla.redhat.com/show_bug.cgi?id=1260584
2015-09-15 11:46:37 +02:00
Thomas Haller
757999d484 manager: avoid wrong ref-counting in do_set_property_check()
Fixes: 52ed6a8e5c
2015-09-14 22:23:54 +02:00
Thomas Haller
4dd0b69a88 device: add debug log for setting unmanged flags
Only set priv->unmanaged_flags in one place and log
any changes. It is not trivial to understand from the
logfile why a device is unmanged.
2015-09-14 21:50:28 +02:00
Thomas Haller
b89826d874 device/trivial: move local variable closer to where it is used 2015-09-14 18:36:54 +02:00
Thomas Haller
de0f00e8d1 manager: avoid assertion in free_property_filter_data()
#0  0x00007fc52202dd3b in g_logv (breakpoint=1) at gmessages.c:315
    #1  0x00007fc52202dd3b in g_logv (log_domain=0x7fc522351b84 "GLib-GObject", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7ffeb818bfc0) at gmessages.c:1041
    #2  0x00007fc52202deaf in g_log (log_domain=<optimized out>, log_level=<optimized out>, format=<optimized out>) at gmessages.c:1079
    #3  0x000055c658ee819f in free_property_filter_data (pfd=0x55c65a009000) at nm-manager.c:4418
    #4  0x000055c658ee7e67 in do_set_property_check (user_data=0x55c65a009000) at nm-manager.c:4515
    #5  0x00007fc522026a8a in g_main_context_dispatch (context=0x55c659e161c0) at gmain.c:3122
    #6  0x00007fc522026a8a in g_main_context_dispatch (context=context@entry=0x55c659e161c0) at gmain.c:3737
    #7  0x00007fc522026e20 in g_main_context_iterate (context=0x55c659e161c0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3808
    #8  0x00007fc522027142 in g_main_loop_run (loop=0x55c659e16280) at gmain.c:4002
    #9  0x000055c658e047ee in main (argc=1, argv=0x7ffeb818c508) at main.c:449

Fixes: 751c674643
2015-09-14 18:36:54 +02:00
Thomas Haller
b0815813fa iface-helper: enabled dhcp4/slaac according to IP method
If at the moment when spawning nm-iface-helper dhcp4/slaac
did not yet complete, we would not enable it.

That is wrong. If the connection indicates to use dhcp4/slaac,
it should be used by nm-iface-helper without considering the
current state on the device.

https://bugzilla.redhat.com/show_bug.cgi?id=1260243
2015-09-13 15:50:44 +02:00
Dan Winship
5b512053e3 core: merge branch 'interface-types-bgo754416'
Fix the way NM uses GObject interface types, and use
G_DEFINE_INTERFACE().

https://bugzilla.gnome.org/show_bug.cgi?id=754416
2015-09-10 13:56:21 -04:00
Dan Winship
8e9f782082 core: fix interface type names
A GObject interface, like a class, has two different C types
associated with it; the type of the "class" struct (eg, GObjectClass,
GFileIface), and the type of instances of that class/interface (eg,
GObject, GFile).

NetworkManager was doing this wrong though, and using the same C type
to point to both the interface's class struct and to instances of the
interface. This ends up not actually breaking anything, since for
interface types, the instance type is a non-dereferenceable dummy type
anyway. But it's wrong, since if, eg, NMDeviceFactory is a struct type
containing members "start", "device_added", etc, then you should not
be using an NMDeviceFactory* to point to an object that does not
contain those members.

Fix this by splitting NMDeviceFactory into NMDeviceFactoryInterface
and NMDeviceFactory; by splitting NMConnectionProvider into
NMConnectionProviderInterface and NMConnectionProvider; and by
splitting NMSettingsPlugin into NMSettingsPluginInterface and
NMSettingsPlugin; and then use the right types in the right places.

As a bonus, this also lets us now use G_DEFINE_INTERFACE.
2015-09-10 13:43:47 -04:00
Dan Winship
b3d56e4885 settings: remove some NMSettingsPlugin cruft 2015-09-10 13:43:47 -04:00
Dan Winship
dfb77e3b19 settings: trivial: rename NMSystemConfigInterface to NMSettingsPlugin
Since there have not been separate system and user settings services
since 0.8, the "system" in NMSystemConfigInterface is kind of
meaningless. Rename it to NMSettingsPlugin, which describes what it
does better.

This is just:

    git mv src/settings/nm-system-config-interface.h src/settings/nm-settings-plugin.h
    git mv src/settings/nm-system-config-interface.c src/settings/nm-settings-plugin.c
    perl -pi -e 's/SystemConfigInterface/SettingsPlugin/g;' \
             -e 's/system_config_interface/settings_plugin/g;' \
             -e 's/system-config-interface/settings-plugin/g;' \
             -e 's/SYSTEM_CONFIG_INTERFACE/SETTINGS_PLUGIN/g;' \
             -e 's/sc_plugin/settings_plugin/g;' \
             -e 's/SC_PLUGIN/SETTINGS_PLUGIN/g;' \
             -e 's/SC_IS_PLUGIN/SETTINGS_IS_PLUGIN/g;' \
             -e 's/SC_TYPE_PLUGIN/SETTINGS_TYPE_PLUGIN/g;' \
             -e 's/SCPlugin/SettingsPlugin/g;' \
             -e 's/nm_system_config_factory/nm_settings_plugin_factory/g;' \
         $(find src/settings -type f)

(followed by some whitespace fixups in nm-settings-plugin.c, and a
Makefile.am fix for the rename)
2015-09-10 13:43:47 -04:00
Thomas Haller
04c4128356 core: fix D-Bus value for NM_IP6_CONFIG_ROUTES
Caused NMIP6Config:Routes property to have bogus values
and leaked the variants.

Fixes: 6c8f860820
2015-09-10 13:31:36 +02:00
Piotr Drąg
12746da039 po: update Polish (pl) translation (bgo #754798)
https://bugzilla.gnome.org/show_bug.cgi?id=754798
2015-09-10 11:25:07 +02:00