Commit graph

13203 commits

Author SHA1 Message Date
Lubomir Rintel 9f15abbda7 libnm/vpn-service-plugin: add watch-peer property
Make it possible to construct the plugin instance in a way that disconnects the
connection if the DBus client that activated it drops off the bus. This makes the
plugins conveniently clean up when NetworkManager crashes.

We need this, as with multiple VPN support we can loose track of the client bus
names when the daemon crashes leaving to nice way to clean up on respawn.

However, this behavior is not desired for debugging or hypotetical VPN plugin
users other than NetworkManager (say; "gdbus call -m o.fd.NM.VPN.Plugin.Connect").
Let the plugin decide when to use it.
2015-10-13 18:20:55 +02:00
Lubomir Rintel 1bb553798c libnm/vpn-service-plugin: add a missing return 2015-10-13 18:20:55 +02:00
Beniamino Galvani 0650b0b147 libnm-core: fix documentation for DHCP_TIMEOUT ifcfg-rh variable
Fixes: 3f0d595cc8
2015-10-13 15:36:46 +02:00
Beniamino Galvani 9184418b2e device: introduce a global default value for ipv4.dhcp-timeout
This allows the ipv4.dhcp-timeout default value to be set from user
configuration.

https://bugzilla.gnome.org/show_bug.cgi?id=756423
2015-10-13 09:37:34 +02:00
Beniamino Galvani b1ab958def merge: LLDP support
Add support for receiving LLDP frames and exporting through D-Bus the
list of LLDP neighbors.

https://bugzilla.redhat.com/show_bug.cgi?id=1142898
2015-10-12 14:52:43 +02:00
Beniamino Galvani bd4df767c6 examples: add python GI example for retrieving LLDP neighbors 2015-10-12 14:44:31 +02:00
Beniamino Galvani 83ac84cd7a libnm: document that some return values are immutable
Document that the GPtrArray returned by

  - nm_device_get_lldp_neighbors()
  - nm_ip_config_get_addresses()
  - nm_ip_config_get_routes()

is immutable and can be used by callers without the need of a copy.
2015-10-12 14:44:31 +02:00
Beniamino Galvani 0d31b95343 cli: add support for 'connection.lldp' property 2015-10-12 14:44:31 +02:00
Beniamino Galvani 5966e14abf ifcfg-rh: add support for 'LLDP' connection property 2015-10-12 14:44:31 +02:00
Beniamino Galvani 6f41f42533 ifcfg-rh: split out parsing of boolean values from svTrueValue()
Move the parsing code to new function svParseBoolean() and rename
svTrueValue() to svGetValueBoolean().
2015-10-12 14:44:31 +02:00
Thomas Haller 2041e140bf macros: add nm_clear_g_variant() util 2015-10-12 14:44:31 +02:00
Beniamino Galvani d3d2b49400 libnm: add LLDP support
Add functions to libnm for retrieving a list of LLDP neighbors and
accessor functions to get their attributes.
2015-10-12 14:44:31 +02:00
Beniamino Galvani 07a9364d9c device: export list of LLDP neighbors through D-Bus
This adds a LldpNeighbors property to the Device D-Bus interface
carrying information about devices discovered through LLDP. The
property is an array of hashes and each hash describes the values of
LLDP TLVs for a specific neighbor.
2015-10-12 14:44:30 +02:00
Beniamino Galvani c364ef0b97 libnm: add 'lldp' property to NMSettingConnection
Add the 'lldp' property to NMSettingConnection, which specifies
whether the reception and parsing of LLDP frames to discover neighbor
devices should be enabled.
2015-10-12 14:44:19 +02:00
Jiří Klimeš 237030ce2b libnm: specify (transfer none) introspection annotation (bgo #756380)
Otherwise the callers would free the address and it would result in
double-free.

Ideally, the function would return const pointer, but changing it now
would require changing also other prototypes and much code due to
snowball effect of const.

https://bugzilla.gnome.org/show_bug.cgi?id=756380
2015-10-12 12:29:31 +02:00
Thomas Haller 76958f94d4 macros: remove early return from nm_clear_g_signal_handler()
It is valid to call nm_clear_g_signal_handler() with missing
@self argument if (and only if) the @id is unspecified as well.

Remove the check for @self to get an assertion in case @id
is missing *and* @self is invalid. In this case,
g_signal_handler_disconnect() will raise a g_critical() for us.

Fixes: c33416178f
2015-10-12 11:10:48 +02:00
Jiří Klimeš f70f098d21 ppp: do not pass NULL to g_variant_new ("(s)")
The string does not like it:
(NetworkManager:21031): GLib-CRITICAL **: g_variant_new_string: assertion 'string != NULL' failed
2015-10-12 09:08:12 +02:00
Jiří Klimeš c33416178f macros: allow NULL pointer in nm_clear_g_signal_handler()
It does not make sense to issue an error. This should be a helper function.
"NetworkManager[18341]: nm_clear_g_signal_handler: assertion 'G_IS_OBJECT (self)' failed"
error started since commit e6d7fee5a6 due to that.
2015-10-12 09:07:54 +02:00
Thomas Haller 90b5e4e3c5 core: disable assertion in nm_ip[46]_config_replace() by default
Only enable the assertion when compiling with nm-more-asserts.
2015-10-10 20:51:19 +02:00
Thomas Haller 3e76701961 platform: fix wrongly return "FALSE" instead of "NULL" for pointer type 2015-10-10 19:46:28 +02:00
Thomas Haller 1ef431ab38 platform: use nm_g_hash_table_add() compat wrapper in _nmp_cache_update_add() 2015-10-10 19:41:42 +02:00
Thomas Haller 9fdc5e6596 libnm-util/test: use "nm-test-utils.h" in test-setting-dcb 2015-10-10 19:41:42 +02:00
Thomas Haller 120847c8a3 device: fix wrongly managing external-down device due to not setting EXTERNAL_DOWN
The unmanaged-flag NM_UNMANAGED_EXTERNAL_DOWN is initially set during
nm_device_finish_init(). But it was only set if the device was down at
that point.

If due to a race the platform device was not yet initialized, a later
initialization in device_link_changed() would clear NM_UNMANAGED_PLATFORM_INIT.
If the device is not external-down (because it was already up during
nm_device_finish_init()), the device will be managed right away with
reason NM_DEVICE_STATE_REASON_NOW_MANAGED.

Together with commit e29ab54335, this
is a race that causes a failure to assume the external-down device.

https://bugzilla.redhat.com/show_bug.cgi?id=1269199
2015-10-09 23:36:36 +02:00
Thomas Haller 9f1eb190f7 platform: downgrade logging level for "event-notification" messages
We get a lot of these debugging message, although the event is entirely
internal to NMLinuxPlatform and only interesting when debugging a problem
in platform itself.

Downgrade to TRACE level.
2015-10-09 15:38:41 +02:00
Thomas Haller c71c301c3b logging: merge branch 'th/logging-keep-bgo756175'
https://bugzilla.gnome.org/show_bug.cgi?id=756175
2015-10-09 14:59:10 +02:00
Thomas Haller 6b0cb77b88 logging: properly use current domains when setting logging
When setting the logging with omitting the domains, we would
use the previously set logging domains. That was wrong since
the addition of the 'KEEP' level:

 (1) $ nmcli g l level INFO domains DNS,CORE
     $ nmcli g l
     LEVEL  DOMAINS
     INFO   DNS,CORE

 (2) $ nmcli g l level KEEP domains PPP:TRACE
     $ nmcli g l
     LEVEL  DOMAINS
     INFO   PPP:TRACE,DNS,CORE

 (3) $ nmcli g l level ERR
     $ nmcli g l
     LEVEL  DOMAINS
     ERR    PPP:TRACE

with this change, command (3) effectively translates to:

    $ nmcli g l level ERR domains PPP,DNS,CORE
    $ nmcli g l
    LEVEL  DOMAINS
    ERR    PPP,DNS,CORE
2015-10-09 14:58:03 +02:00
Thomas Haller da776dd0bc logging: refactor global variable to have them in a struct
"nm-logging.c" uses several global variables. As their name doesn't
indicate that they are global variables, this is quite confusing.

Pack them all into a struct @global, which effectively puts the
variables into a separate namespace.
2015-10-09 14:58:03 +02:00
Thomas Haller 2f6978efb7 logging/trivial: move code 2015-10-09 14:58:03 +02:00
Thomas Haller 98e34208bd platform: warn about growing sysctl logging cache and clear it
When debug-logging for platform is enabled, every access to sysctl
is cached (to log the last values).

This cache can grow quite large if the system has a large number of
interfaces (e.g. docker creating veth pairs for each container).

We already used to clear the cache, when we were about to access
sysctl *and* logging was disabled in the meantime.

Now, when logging setup changes, immediately clear the cache.
Having "nm-logging.c" call into platform code is a bit of a hack
and a better design would be to have logging code emit a signal to
which platform would subscribe. But that seems to involve much
more code (especially, as no other users care about such a signal
and because nm-logging is not a GObject).

Also, log a warning when the cache grows large to inform the user
about the cache and what he can do to clear it. The extra effort to
clear the cache when changing logging setup is done so that we do
what we tell the user: changing the logging level, will clear the
cache -- right away, not some time later when the next message is
logged.
2015-10-09 14:56:50 +02:00
Thomas Haller fd87ce503c logging: add special logging level "KEEP"
Without this, the user cannot configure only certain logging domains
without touching them all.

E.g.

  # nmcli general logging level DEBUG domains PLATFORM

will disable all non-PLATFORM domains.
Well, the user can do:

  # nmcli general logging level INFO domains PLATFORM:DEBUG
  # nmcli general logging level DEBUG domains ALL:INFO,PLATFORM

but in this case all non-PLATFORM domains are reset explicitly.

Now the user can:

  # nmcli general logging level KEEP domains PLATFORM:DEBUG
  # nmcli general logging level DEBUG domains ALL:KEEP,PLATFORM

which will only change the platform domain.
2015-10-09 14:55:00 +02:00
Lubomir Rintel cc6b07c439 ifcfg-rh/tests: add a missing file to the distribution
Fixes: 68eb350ad8
2015-10-09 14:26:46 +02:00
Jiří Klimeš ce27e1e21e tui: add a checkbox for ignore-auto-routes (bgo #756200)
https://bugzilla.gnome.org/show_bug.cgi?id=756200
2015-10-09 09:27:49 +02:00
Beniamino Galvani 296ea386bf device: get rid of ipv4ll_timeout_remove()
nm_clear_g_source() already does that.
2015-10-08 22:29:49 +02:00
Beniamino Galvani e6d7fee5a6 device/vlan: update VLAN MAC address when parent's one changes
When a VLAN has a bond as parent device the MAC address of the bond
may change when other devices are enslaved and then the VLAN would
have a MAC which is different from parent's one.

Let the VLAN device listen for changes in hw-address property of
parent and update its MAC address accordingly.

https://bugzilla.redhat.com/show_bug.cgi?id=1264322
2015-10-08 22:01:48 +02:00
Thomas Haller e29ab54335 device: fix race wrongly managing external-down device due to late udev signal
Executing:

  # brctl addbr lbr0
  # ip addr add 10.1.1.1/24 dev lbr0
  # ip link set lbr0 up

can result in a race so that NetworkManager would manage the device
(and clear the IP addresses).

It happens, when NetworkManager first receives platform signals that
the device is already up:

    signal: link changed: 11: lbr0 <UP,LOWER_UP;broadcast,multicast,up,running,lowerup> mtu 1500 arp 1 bridge* not-init addrgenmode eui64 addr D2:A1:B4:17:18:F2 driver bridge

Note that the device is still unknown via udev (not-init). The
unmanaged-state NM_UNMANAGED_EXTERNAL_DOWN gets cleared, but the
device still stays unmanaged.

Only afterwards the device is known in udev:

    signal: link changed: 11: lbr0 <UP,LOWER_UP;broadcast,multicast,up,running,lowerup> mtu 1500 arp 1 bridge* init addrgenmode eui64 addr D2:A1:B4:17:18:F2 driver bridge

At this point, we also clear NM_UNMANAGED_PLATFORM_INIT, making
the device managed with reason NM_DEVICE_STATE_REASON_NOW_MANAGED.
That results in managing the external device.

Fix that by only clearing NM_UNMANAGED_EXTERNAL_DOWN after the device
is no longer NM_UNMANAGED_PLATFORM_INIT.

https://bugzilla.redhat.com/show_bug.cgi?id=1269199
2015-10-08 20:01:16 +02:00
Lubomir Rintel 97a962a788 systemd: grant the daemon a license to kill kids
It's for their own good. Otherwise stale dnsmasq instances haunt the shared
connections.
2015-10-08 19:23:53 +02:00
Josef Bacik 68eb350ad8 ifcfg-rh: accept BOOTPROTO=static with missing IPv4 addresses
Dracut when faced with an ipv6 only setup during kickstart will generate a ifcfg
file that sets the ipv4 address things to null but sets BOOTPROTO=static.  This
makes network manager screw up because it expects an ipv4 address to be set.
Instead deal with this case by checking if we have any ipv4 addrs set, and if
not just disable ipv4.  This fixes our inability to kickstart in our ipv6 only
clusters.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>

https://mail.gnome.org/archives/networkmanager-list/2015-October/msg00015.html
2015-10-08 19:00:19 +02:00
Beniamino Galvani 90fb64024c merge: merge branch 'systemd' into master 2015-10-08 14:14:19 +02:00
Thomas Haller 68b3790ad3 libnm: explicitly cast enum type for g_object_set()
Fixes: 687b651598
2015-10-08 13:11:44 +02:00
Lubomir Rintel a8af3fae57 dhcp-systemd: sd_dhcp_lease_load() returns no lease or error on ENOENT
If the lease file doesn't exist sd_dhcp_lease_load() still indicates
success while not returning any lease, resulting in an assertion fail
when we try to generate an IP4Config:

  #0  g_logv (log_domain=0x7f309b45dba0 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7ffc815c38e0) at gmessages.c:1046
  #1  0x00007f3097d4fa3f in g_log (log_domain=log_domain@entry=0x7f309b45dba0 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7f3097dbd73d "%s: assertion '%s' failed")
      at gmessages.c:1079
  #2  0x00007f3097d4fa79 in g_return_if_fail_warning (log_domain=log_domain@entry=0x7f309b45dba0 "NetworkManager", pretty_function=pretty_function@entry=0x7f309b456b30 <__FUNCTION__.31435> "lease_to_ip4_config",
      expression=expression@entry=0x7f309b456417 "lease != NULL") at gmessages.c:1088
  #3  0x00007f309b35454a in lease_to_ip4_config (lease=0x0, options=options@entry=0x0, default_priority=default_priority@entry=100, log_lease=log_lease@entry=0, error=0x0) at dhcp-manager/nm-dhcp-systemd.c:230
  #4  0x00007f309b3546a0 in nm_dhcp_systemd_get_lease_ip_configs (iface=<optimized out>, uuid=<optimized out>, ipv6=<optimized out>, default_route_metric=100) at dhcp-manager/nm-dhcp-systemd.c:397
  #5  0x00007f309b35ed4a in find_ip4_lease_config (ext_ip4_config=0x7f309cbe8640, connection=0x7f309cb98250, self=0x7f309cbfb7b0) at devices/nm-device.c:7215
  #6  capture_lease_config (ext_ip6_config=0x0, out_ip6_config=0x0, out_ip4_config=0x7f309cbfb5d0, ext_ip4_config=0x7f309cbe8640, self=0x7f309cbfb7b0) at devices/nm-device.c:7289
  #7  update_ip4_config (self=self@entry=0x7f309cbfb7b0, initial=initial@entry=1) at devices/nm-device.c:7323
  #8  0x00007f309b3608be in nm_device_capture_initial_config (self=self@entry=0x7f309cbfb7b0) at devices/nm-device.c:7428
  #9  0x00007f309b3dbaad in get_existing_connection (out_generated=<synthetic pointer>, device=0x7f309cbfb7b0, manager=0x7f309cb7f150) at nm-manager.c:1550
  #10 recheck_assume_connection (device=device@entry=0x7f309cbfb7b0, user_data=user_data@entry=0x7f309cb7f150) at nm-manager.c:1689
  #11 0x00007f309b3dc62d in add_device (self=0x7f309cb7f150, device=0x7f309cbfb7b0, try_assume=1) at nm-manager.c:1875
  #12 0x00007f309b3dcd10 in platform_link_added (self=self@entry=0x7f309cb7f150, ifindex=<optimized out>, plink=plink@entry=0x7f309cbcff40) at nm-manager.c:1984
  #13 0x00007f309b3df7d4 in platform_query_devices (self=0x7f309cb7f150) at nm-manager.c:2056
  #14 nm_manager_start (self=0x7f309cb7f150) at nm-manager.c:4220
  #15 0x00007f309b341f2c in main (argc=1, argv=0x7ffc815c3f68) at main.c:494
2015-10-08 12:20:29 +02:00
Thomas Haller 16522ec7f5 core: merge branch 'th/device-schedule-activation-bgo756129'
https://bugzilla.gnome.org/show_bug.cgi?id=756129
2015-10-07 18:23:09 +02:00
Thomas Haller 061028961a device: refactor setting firewall zone during activation-stage2
schedule_stage3() used to set the firewall before really
scheduling the stage3. In that case, fw_change_zone_cb() would
then directly call:
  activation_source_schedule (self, activate_stage3_ip_config_start, AF_INET);

This was different from all other places. Usually, only the
nm_device_schedule_*() functions would directly call to
activation_source_schedule().

Change this, to behave similar as when we wait for master-ready
while scheduling stage2. As such, it is more idiomatic, and
it would still work correctly even if there were multiple conditions
that would block scheduling-stage3.
2015-10-07 18:22:57 +02:00
Thomas Haller b343956d40 device/logging: refactor logging for activation-stage
Instead of adding explicit logging lines while scheduling and processing
the activation-stages, only log them in activation_source_schedule()
and activation_source_handle_cb().

Effectively, lines like:

  "Activation: Stage 1 of 5 (Device Prepare) started..."

are now:

  "activation-stage: invoke activate_stage1_device_prepare,2 (id x)"
2015-10-07 18:21:37 +02:00
Thomas Haller 823ce8bf73 device: rename nm_device_activate_*() functions
The function name is logged, so change them to be more suitable:

  - drop the "nm_device_" prefix. It is redundant in the logging,
    and usually our static functions don't have an nm-prefix.
  - have all functions now start with "activate_stagex_". The
    stage number corresponds to what we are currently logging
    during activation:
       "Activation: Stage 1 of 5 (Device Prepare)..."
    No other functions start with a "activate_stagex_" prefix,
    so it's easy to grep.
2015-10-07 16:48:48 +02:00
Thomas Haller 78ca961c0f device: refactor scheduling the activation source
Every activation-source handler first cleared the current
activation-source (activation_source_clear()) and later
returned FALSE/G_SOURCE_REMOVE.

Do not directly attach the handlers to g_idle_add().
Instead wrap the actual handler. This wrapper
  - always clears the activation source first
  - always returns G_SOURCE_REMOVE
  - does trace logging about invoking the handler

This also avoids a possibility for a bug where the handler returns
G_SOURCE_REMOVE, without also clearing activation_source_clear().
2015-10-07 16:48:48 +02:00
Thomas Haller d4d2e65eb7 macros: add NM_SET_OUT() macro 2015-10-07 16:35:19 +02:00
Thomas Haller e73e55c6ec device: update hw_addr_len before emitting signal in nm_device_update_hw_address() 2015-10-07 16:35:06 +02:00
Lubomir Rintel 3abe1bb21a device: don't complain about repeated schedules of the same activation stage
Can easily happend with a storm of DHCP responses or RAs before the idle
handler has a chance to run.

https://bugzilla.redhat.com/show_bug.cgi?id=1269520
2015-10-07 15:54:45 +02:00
Beniamino Galvani 76726b9922 dhcp-manager: fix memory leak in DHCP listener
Fixes: 7f6e39ec6e
2015-10-07 14:21:37 +02:00
Jiří Klimeš ee3c6d57a4 ifcfg-rh: write REORDER_HDR as more common "yes", "no"
initscripts just search for negative values "no" or "0"
(/etc/sysconfig/network-scripts/ifup)

Related: ccea442504
2015-10-07 13:45:30 +02:00