Commit Graph

13873 Commits

Author SHA1 Message Date
Lubomir Rintel
700061f270 libnm/vpn-service-plugin: leave the state property in place
It's part of the DBus API; the skeleton has it and we can't remove it.

This partially reverts commit fd61b21706.
2015-10-14 18:44:57 +02:00
Thomas Haller
6786164e78 platform: merge branch 'th/platform-ipv4-peer-address-bgo756356'
https://bugzilla.gnome.org/show_bug.cgi?id=756356
2015-10-14 16:16:42 +02:00
Thomas Haller
06aafabf14 platform/test: add test adding IPv4 addresses that only differ by their peer-address
Also do a major cleanup of the tests:

- Have utility functions in "test-common.h" with a new prefix "nmtstp_".
  The prefix indicates that these are test functions for platform.

- Add functions to add/remove IP addresses that either use external
  iproute2 command or platform function itself. These commands also
  assert whether the command had the expected result.

- Randomize, whether we use the external command for adding
  ip-addresses. Both approaches should yield the same result
  for linux-platform.
  I did this now for address-tests, but effectively this doubled
  all our previous tests to use both internal and external ways
  to configure the address.

- Enable all address tests for fake-platform. They now
  automatically don't call external iproute2 but fallback
  to fake-platform implementation. This adds more coverage
  to the fake-platform, which we want to behave identical
  to linux-platform.

- Setup a clean test device before every address-test.
2015-10-14 16:16:21 +02:00
Thomas Haller
0d5428b1bd test: add nmtst_get_rand_int() helper 2015-10-14 12:52:07 +02:00
Thomas Haller
6a5dab5c7c platform: fix id-equality for IPv6 address to ignore prefix-length
For IPv6 addresses, the prefix-length is not part of the id.
E.g. you cannot add two IPv6 addresses that only differ by
plen.
2015-10-14 12:52:07 +02:00
Thomas Haller
eab5a462b4 platform: fix comparing peer-address for IPv6 address in nm_platform_ip6_address_cmp() 2015-10-14 12:52:07 +02:00
Thomas Haller
cc654b9dd3 ip-config: expose IP peer address on D-Bus 2015-10-14 12:52:07 +02:00
Thomas Haller
8968e15eb7 platform: properly handle peer-address for IPv4 addresses
Kernel allows to add the same IPv4 address that only differs by
peer-address (IFL_ADDRESS):

    $ ip link add dummy type dummy
    $ ip address add 1.1.1.1 peer 1.1.1.3/24 dev dummy
    $ ip address add 1.1.1.1 peer 1.1.1.4/24 dev dummy
    RTNETLINK answers: File exists
    $ ip address add 1.1.1.1 peer 1.1.2.3/24 dev dummy
    $ ip address show dev dummy
    2: dummy@NONE: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default
        link/ether 52:58:a7:1e:e8:93 brd ff:ff:ff:ff:ff:ff
        inet 1.1.1.1 peer 1.1.1.3/24 scope global dummy
           valid_lft forever preferred_lft forever
        inet 1.1.1.1 peer 1.1.2.3/24 scope global dummy
           valid_lft forever preferred_lft forever

We must also consider peer-address, otherwise platform will treat
two different addresses as one and the same.

https://bugzilla.gnome.org/show_bug.cgi?id=756356
2015-10-14 12:52:07 +02:00
Thomas Haller
df8e5da3c0 ip-config: refactor to use _addresses_get_index() function
Also change the semantic of nm_ip6_config_address_exists()
to ignore the prefix length. It seems more correct this way,
but as there are no users of the function it doesn't actually
matter.
2015-10-14 12:52:07 +02:00
Thomas Haller
560de03bf3 ip4-config: allow IPv4 addresses that only differ by prefix-length
Kernel treats IPv4 addresses with different netmask/prefix-length as
different addresses.
It is wrong to merge them together in nm_ip4_config_add_address().

For IPv6 addresses that is not the case and you cannot configure
two IPv6 addresses that only differ by plen (on the same interface).
2015-10-14 12:52:07 +02:00
Thomas Haller
44c43b4f5c platform: rename _CMP_POINTER() macro to _CMP_SELF()
This name is better, because _CMP_SELF() is the first check of the two
operands to catch pointer-equality and NULL values.
2015-10-14 12:52:07 +02:00
Thomas Haller
f193d98ced platform: refactor order of peer-address argument in ip_address_add() function
The peer-address seems less important then the prefix-length.
Also, nm_platform_ip4_address_delete() has the peer-address
argument as last.

Soon ip4_address_get() also receives a peer-address argument,
so get the order right first.
2015-10-14 12:52:07 +02:00
Thomas Haller
d1c528e64c device: fix regenerating IP settings for assumed connections
Fixes: 06da353242
2015-10-14 12:52:06 +02:00
Lubomir Rintel
f0422bb88c merge: branch 'lr/multiple-vpn'
https://bugzilla.gnome.org/show_bug.cgi?id=753966
2015-10-13 18:21:10 +02:00
Lubomir Rintel
5b48befaad vpn-manager: support multiple VPN connections of the same type
A separate instance of the support plugin is spawned for each connection with
a different bus name. The bus name is passed via --bus-name <name> argument.
Plugins that support the feature indicate it with
support-multiple-connections=true key in the [VPN Connection] section.

The bus name is currently generated by adding a .<connection.uuid> to the VPN
service name. It's guarranteed unique, but if it proves to be too long or ugly
it can easily be replaced with something more meaningful (such as the same number
as is used for connection's DBus name).

NMVpnService has been removed and folded into NMVpnConnection. A
NMVpnConnection will spawn a service plugin instance whenever it is activated
and notices the bus name it needs is not provided.

The NMVpnManager no longer needs to keep track of the connections in use apart
for compatibility purposes with plugins that don't support the feature.
2015-10-13 18:20:56 +02:00
Lubomir Rintel
9bbf5e94c2 device: allow multiple vpn IP configurations 2015-10-13 18:20:56 +02:00
Lubomir Rintel
965363a6d5 vpn-connection: export add nm_vpn_connection_get_service()
Will be useful later on.
2015-10-13 18:20:56 +02:00
Lubomir Rintel
6c213e3cb4 libnm-core/vpn-plugin-info: add nm_vpn_plugin_info_supports_multiple() 2015-10-13 18:20:56 +02:00
Lubomir Rintel
fd61b21706 libnm/vpn-service-plugin: remove nm_vpn_service_plugin_{get,set}_state()
The plugins set state only on failures and often forget to do that. Do the
correct status transition to STOPPED in nm_vpn_service_plugin_failure() instead.

The get_state() is only used to find out whether to fail or orderly disconnect
depending on whether we're STARTING or already STARTED. Handle that in
nm_vpn_service_plugin_disconnect() in a generic manner instead.
2015-10-13 18:20:55 +02:00
Lubomir Rintel
78f263a5fd libnm/vpn-service-plugin: quit when the peer we watch disconnects
We're of no use anymore as another user would start an instance with
a different bus name.
2015-10-13 18:20:55 +02:00
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