Commit Graph

13873 Commits

Author SHA1 Message Date
Thomas Haller
7354dc4c58 platform/trivial: remove unused argument from udev_get_driver() 2015-04-14 13:02:04 +02:00
Jiří Klimeš
8252553615 cli: add PHYS_PORT_ID property to devices
The physical-port-id property was added to libnm (libnm-glib) in commit
47cc8b25f2.
2015-04-14 12:18:00 +02:00
Beniamino Galvani
3e8d828008 wifi: fix memleak in nm_ap_update_from_properties()
Fixes: 59c8192b22
2015-04-13 21:39:21 +02:00
Dan Williams
e165463964 api: add missing device state reason for NewActivation
Fixes: 1ad193a017
2015-04-13 11:30:27 -05:00
Lubomir Rintel
0b9a4cd8df device: merge branch 'lr/veth-no-external-up'
https://bugzilla.gnome.org/show_bug.cgi?id=747465
2015-04-13 13:53:43 +02:00
Lubomir Rintel
bcc79cc0eb device: turn off "unmanaged unless IFF_UP externally" for veth
We currently don't manage a veth inside a container despite we should because
it's an externally configured software interface and thus waits for IFF_UP.

Given veths are prevented from being managed outside of a container by an udev
rule anyway it's safe to lift the external IFF_UP requirement for them.
2015-04-13 13:51:27 +02:00
Lubomir Rintel
adb6e9afb1 device: move the decision whether to wait for IFF_UP a virtual function
We'd like to override it for veths.
2015-04-13 13:51:27 +02:00
Dan Williams
62f40bade0 wifi: use the supplicant's CurrentBSS as the current AP (bgo #747424)
Instead of trying to do a bunch of fragile frequency/SSID/security
matching, just use what the supplicant thinks the current AP is.
2015-04-10 15:59:05 -05:00
Thomas Haller
1eaddced10 make use of NM_MORE_ASSERTS, nm_assert() and NM_MORE_LOGGING 2015-04-10 18:09:32 +02:00
Thomas Haller
63593a19d8 build: add --enable-more-logging configure option
NM core uses nm-logging which is entirely configurable at runtime.
Other components use glib-logging, which can also be partly configured
via G_MESSAGES_DEBUG.

It makes sense to have a compile time option to enable some
logging statements that are only useful for heavy debugging.

For glib-logging, this is a way to enable/disable extra logging.
For nm-logging, we could alternatively configure a least log-level
that is enabled at compile time (that way, we could configure to prune all
LOGL_TRACE logging). While that might be useful (too), this gives
an alternative way to disable/enable logging.

Add a configure option --enable-more-logging and a NM_MORE_LOGGING define
for that.

If we don't find this useful after a while, we can simply remove it,
because our logging statements are not part of a "stable" behavior.
2015-04-10 18:08:09 +02:00
Thomas Haller
08ecafd2bf build: add --enable-more-asserts configure option and nm_assert() macro
NM already has two kinds of assertions:
 - g_assert*(), conditionally compiled via #ifndef G_DISABLE_ASSERT
 - g_return*(), conditionally compiled via #ifndef G_DISABLE_CHECKS

In theory, one should be able to disable both asserts and NM should
still work correctly (and possibly more efficient). In practice,
hardly anybody is testing such a configuration and it might be broken.
Especially, we don't disable asserts for production builds, both because
of less test coverage and because it might reduce our ability to debug.

Add a new configure option --enable-more-asserts, which defines
NM_MORE_ASSERTS and nm_assert(). This is for expensive asserts,
that -- contrary to the asserts above -- are disabled by default.
This is useful for extended debugging.
2015-04-10 18:06:59 +02:00
Thomas Haller
4ab540939c test: print NMTST_SEED_RAND value with g_print()
For tests with assert-logging enabled, we already printed
the message with g_print(), instead of g_message().

We always want to print this value, because it is important
to reproduce a test failure. Hence, just (always) print
directly to stdout.

Also, add a leading newline, because the output was attached
to the previous line.
2015-04-10 18:06:20 +02:00
Dan Williams
fbf60536f9 wifi: fall back to band matching when frequency matching fails
Some dual-band access points use the same BSSID in both the 5GHz
and 2.4GHz bands, so obviously frequency must be taken into account
when matching.  But no AP should ever use the same SSID/BSSID pair
concurrently in the same band on different frequencies.

Some APs also dynamically channel hop when they detect interference,
or when they restart, they do so on a different channel after finding
the channel with the lowest interference.  To assure that we don't
end up with stale scan list entries when the AP has switched to
another channel in the same band, fall back to band matching
when merging new scan results.
2015-04-10 10:17:45 -05:00
Dan Williams
227de48a91 wifi: remove unused AP 'broadcast' property
Nothing ever read the value.
2015-04-10 10:17:45 -05:00
Dan Williams
85aac315c0 wifi: always strict-match access points when merging
The only reason to allow lazy matching was to update a fake
current AP when its real scan result comes in.  Now that NM
tracks the current AP based on the the supplicant's current
BSS, a fake current AP will be replaced when the real scan
result arrives.  So it's pointless to update the fake one
when it'll just be removed soon.
2015-04-10 10:17:45 -05:00
Dan Williams
f191e204ac wifi: trivial whitespace fixup 2015-04-10 10:17:45 -05:00
Dan Williams
0bdee17402 wifi: update AP properties from supplicant signals 2015-04-10 10:17:45 -05:00
Dan Williams
37760fdc83 wifi: use supplicant's CurrentBSS as the current AP
Instead of keeping track of it internally, and attempting to fuzzy-match
access points and stuff, just use the supplicant's information.  If the
supplicant doesn't know what AP it's talking to, then we've got more
problems than just NM code.

The theory here is that when starting activation, we'll use the given
access point from the scan list that the supplicant already knows about.
If there isn't one yet (adhoc, hidden, or AP mode) then we'll create
a fake AP and add it to the scan list.

Once the supplicant has associated to the AP, it'll notify about the
current BSS which we then look up in the scan list, and set
priv->current AP to that.  If for some reason the given AP isn't yet
in our scan list (which often happens for adhoc/AP) then we'll just
live with the fake AP until we get the scan result, which should happen
very soon.

We don't need to do any fuzzy-matching to find the current AP because
it will either always be one the supplicant knows about, or a fake one
that the supplicant doesn't know about that will be replaced soon anyway.
2015-04-10 10:17:44 -05:00
Dan Williams
6b8df2035e wifi: use a hash table to track access points 2015-04-10 10:17:44 -05:00
Dan Williams
6596ceee14 supplicant: ignore NotConnected errors when disconnecting 2015-04-10 10:17:43 -05:00
Dan Williams
3c19ce7616 supplicant: track and expose wpa_supplicant's CurrentBSS property 2015-04-10 10:17:43 -05:00
Thomas Haller
0aca44c857 test: fix compiler warning in g_test_assert_expected_messages_internal()
-Wformat of gcc determines that the string arguments are NULL.

Fixes: 373d09b042
2015-04-10 15:06:23 +02:00
Thomas Haller
7c5d361c66 platform/trivial: rename object_type_from_nl_object() to _nlo_get_object_type()
The function names in linux-platform should get better prefixes
indicating whether they are related to libnl or nm objects.

Add a prefix _nlo_ for functions that operate on libnl objects.
2015-04-09 17:45:59 +02:00
Thomas Haller
850af91f22 platform/trivial: move code around so that libnl related stuff is together
Reorder some functions in nm-platform, so that we first have independent
libnl wrappers/utils, then NMPlatform type definition, and then the
rest.
2015-04-09 17:31:11 +02:00
Thomas Haller
ee64b8585b platform/trivial: add OBJECT_TYPE_MAX enum value 2015-04-09 17:31:11 +02:00
Thomas Haller
4c9a836774 test: make valgrind suppressions file configurable
Add a configure option --with-valgrind-suppressions=path to allow
specifying a different suppressions file.
2015-04-09 17:02:49 +02:00
Thomas Haller
373d09b042 test: log message at g_test_assert_expected_messages()
When disabling assert-logging with no-expect-message,
print a line at every g_test_assert_expected_messages()
invocation.
2015-04-09 16:39:13 +02:00
Thomas Haller
745f2aceac test: add description of test behavior to nm-test-utils.h 2015-04-09 16:39:13 +02:00
Beniamino Galvani
eab389bd8a build: update systemd code
This is a direct dump from systemd git on 2015-04-08, git commit
431c3b6bab9c; it updates the existing files and imports systemd IPv4LL
implementation.

    SYSTEMD_DIR=../systemd
    COMMIT=431c3b6bab9ceb54cd144d8df24d764a8a5f8fcc

    (
       cd "$SYSTEMD_DIR"
       git checkout "$COMMIT"
       git reset --hard
       git clean -fdx
    )
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd/sd-id128/sd-id128.c ./src/systemd/src/libsystemd/sd-id128/sd-id128.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-identifier.c ./src/systemd/src/libsystemd-network/dhcp-identifier.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-identifier.h ./src/systemd/src/libsystemd-network/dhcp-identifier.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-internal.h ./src/systemd/src/libsystemd-network/dhcp-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-lease-internal.h ./src/systemd/src/libsystemd-network/dhcp-lease-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-network.c ./src/systemd/src/libsystemd-network/dhcp-network.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-option.c ./src/systemd/src/libsystemd-network/dhcp-option.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-packet.c ./src/systemd/src/libsystemd-network/dhcp-packet.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-protocol.h ./src/systemd/src/libsystemd-network/dhcp-protocol.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-internal.h ./src/systemd/src/libsystemd-network/dhcp6-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-lease-internal.h ./src/systemd/src/libsystemd-network/dhcp6-lease-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-network.c ./src/systemd/src/libsystemd-network/dhcp6-network.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-option.c ./src/systemd/src/libsystemd-network/dhcp6-option.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-protocol.h ./src/systemd/src/libsystemd-network/dhcp6-protocol.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.c ./src/systemd/src/libsystemd-network/network-internal.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.h ./src/systemd/src/libsystemd-network/network-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-client.c ./src/systemd/src/libsystemd-network/sd-dhcp-client.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-lease.c ./src/systemd/src/libsystemd-network/sd-dhcp-lease.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-client.c ./src/systemd/src/libsystemd-network/sd-dhcp6-client.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-lease.c ./src/systemd/src/libsystemd-network/sd-dhcp6-lease.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/ipv4ll-internal.h ./src/systemd/src/libsystemd-network/ipv4ll-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/ipv4ll-internal.h ./src/systemd/src/libsystemd-network/ipv4ll-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/ipv4ll-network.c ./src/systemd/src/libsystemd-network/ipv4ll-network.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network//ipv4ll-packet.c ./src/systemd/src/libsystemd-network//ipv4ll-packet.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-ipv4ll.c ./src/systemd/src/libsystemd-network/sd-ipv4ll.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/async.h ./src/systemd/src/shared/async.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/fileio.c ./src/systemd/src/shared/fileio.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/fileio.h ./src/systemd/src/shared/fileio.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/list.h ./src/systemd/src/shared/list.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/log.h ./src/systemd/src/shared/log.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/macro.h ./src/systemd/src/shared/macro.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/path-util.c ./src/systemd/src/shared/path-util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/path-util.h ./src/systemd/src/shared/path-util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/refcnt.h ./src/systemd/src/shared/refcnt.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/siphash24.c ./src/systemd/src/shared/siphash24.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/siphash24.h ./src/systemd/src/shared/siphash24.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/socket-util.h ./src/systemd/src/shared/socket-util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/sparse-endian.h ./src/systemd/src/shared/sparse-endian.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/strv.c ./src/systemd/src/shared/strv.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/strv.h ./src/systemd/src/shared/strv.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/time-util.c ./src/systemd/src/shared/time-util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/time-util.h ./src/systemd/src/shared/time-util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/utf8.c ./src/systemd/src/shared/utf8.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/utf8.h ./src/systemd/src/shared/utf8.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/util.c ./src/systemd/src/shared/util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/util.h ./src/systemd/src/shared/util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/unaligned.h ./src/systemd/src/shared/unaligned.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/in-addr-util.c ./src/systemd/src/shared/in-addr-util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/in-addr-util.h ./src/systemd/src/shared/in-addr-util.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/_sd-common.h ./src/systemd/src/systemd/_sd-common.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-client.h ./src/systemd/src/systemd/sd-dhcp-client.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-lease.h ./src/systemd/src/systemd/sd-dhcp-lease.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-client.h ./src/systemd/src/systemd/sd-dhcp6-client.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-lease.h ./src/systemd/src/systemd/sd-dhcp6-lease.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-event.h ./src/systemd/src/systemd/sd-event.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-id128.h ./src/systemd/src/systemd/sd-id128.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-ipv4ll.h ./src/systemd/src/systemd/sd-ipv4ll.h
2015-04-08 16:12:44 +02:00
Thomas Haller
3c240a6d0b route-manager: merge branch 'th/route-manager-bgo740064'
https://bugzilla.gnome.org/show_bug.cgi?id=740064
2015-04-08 14:51:56 +02:00
Thomas Haller
bd0c44c1cf route-manager/test: add variations to test code 2015-04-08 14:50:43 +02:00
Thomas Haller
62c652c352 route-manager: refactor route-manager and route_sync()
Refactor the implementation of nm_route_manager_ip4_route_sync()
and nm_route_manager_ip6_route_sync().

- merge the implementations for IPv4 and IPv6.

- pre-sort the routes and iterate them in a way that we don't
  need to lookup a route in other lists. Do this by iterating
  two sorted lists at a time in a merge-sort way.
  The runtime complexity of sync is now O(n*ln(n)).

- previously, the algorithm would merge routes it found in platform
  to priv->ipx_routes. That was wrong, because then we loose the
  information which routes we wanted to configure internally and which
  are present externally.
  Instead, priv->ipx_routes now contains all the routes that were
  explicitly configured via sync(). Hence, it knows what should be
  configured (@ipx_routes) and can compare to what is configured
  (@plat_routes).

https://bugzilla.gnome.org/show_bug.cgi?id=740064
2015-04-08 14:50:43 +02:00
Thomas Haller
e65639bde9 util: add nm_utils_array_remove_at_indexes() function 2015-04-08 14:39:17 +02:00
Thomas Haller
3179b45412 default-route-manager: cleanup logging macros 2015-04-08 14:39:16 +02:00
Thomas Haller
110200d5d4 default-route-manager: use NMPlatformVTableRoute 2015-04-08 14:39:16 +02:00
Thomas Haller
290faa003d platform: add VTable to handle IPv4 and IPv6 routes generically 2015-04-08 14:39:16 +02:00
Thomas Haller
57453189e0 test: add option in nmtst_platform_ip4_routes_equal() to ignore ordering
Same for nmtst_platform_ip6_routes_equal().

It's useful to check for equal routes ignoring the ordering.
2015-04-08 14:39:16 +02:00
Thomas Haller
ba8ce3bbe5 route-manager/test: check for exact expected error message 2015-04-08 14:39:16 +02:00
Thomas Haller
5fd3827e49 route-manager/test: fix usage of g_assert_expect_message()
Tests that use g_assert_expect_message() must initialize with
nmtst_init_assert_logging().

Otherwise, the caller can change the logging level via
  NMTST_DEBUG=log-level=DEBUG,log-domains=DEFAULT
which breaks the assertions.

nmtst_init_assert_logging() allows the caller to turn of
checking of assertions via
  NMTST_DEBUG=log-level=DEBUG,log-domains=DEFAULT,no-expect-message

Also, don't use g_message() in platform tests otherwise the test fail
because nmtst now sets g_log_set_always_fatal().
2015-04-08 14:39:16 +02:00
Thomas Haller
cdd3e1c302 platform/test: clear host part of routes in fake platform
Adding a route with host part non zero is rejected by kernel.
But NMLinuxPlatform works around it -- so must fake platform.
2015-04-08 14:39:16 +02:00
Thomas Haller
21b129084f platform/test: fake platform must use nm-logging for reporting errors
Just like linux platform does.
2015-04-08 14:39:16 +02:00
Thomas Haller
24288f713a platform/test: split initialization of platform tests out
test-route-manager soon wants a different initialization
2015-04-08 14:39:16 +02:00
Thomas Haller
b6d3b98655 test: setup logging during nmtst_init_assert_logging()
Before, when having a test with nmtst_init_assert_logging(),
the caller was expected to setup logging separately according
to the log level that the test asserts against.

Since 5e74891b58, the logging
level can be reset via NMTST_DEBUG also for tests that
assert logging. In this case, it would be useful, if the test
would not overwrite the logging level that is set externally
via NMTST_DEBUG.

Instead, let the test pass the logging configuration to
nmtst_init_assert_logging(), and nmtst will setup logging
-- either according to NMTST_DEBUG or as passed in.

This way, setting the log level works also for no-expect-message
tests:

  NMTST_DEBUG="debug,no-expect-message,log-level=TRACE" $TEST
2015-04-08 14:39:16 +02:00
Thomas Haller
07f95c371c platform: don't write debug message to stderr
Use nm-logging instead.
2015-04-08 14:39:16 +02:00
Thomas Haller
3abeb7f2b9 test: fix enabling DEBUG logging for tests
For glog messages to print any debug messages, we must set G_MESSAGES_DEBUG.
nmtst does this for us if we set @is_debug. But fix the condition to
also set G_MESSAGES_DEBUG if set set c_log_level to DEBUG or TRACE.
2015-04-08 14:39:16 +02:00
Thomas Haller
0a2c0d12e8 test: fix parsing of NMTST_SEED_RAND 2015-04-08 14:39:15 +02:00
Thomas Haller
44a963c894 test: change message about random seed in nmtst
Make it clear, that you can overwrite the seed by setting the
environment variable NMTST_SEED_RAND.
2015-04-08 14:39:15 +02:00
Beniamino Galvani
aabc6fc57b wifi: indicate 2ghz and 5ghz wifi device capabilities
Add new capabilities CAP_FREQ_2GHZ and CAP_FREQ_5GHZ to indicate the
frequency bands supported by a Wifi device.

Add also CAP_FREQ_VALID, which is set when the values of the other 2
capabilities are available.

Original patch by Dan Williams <dcbw@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=723295
2015-04-08 10:48:38 +02:00
Lubomir Rintel
d78f4614a0 device: use "new-activation" reason when deactivating for another activation
"user-requested" has a side effect of disabling autoconnect.

Fixes: 600489003f
2015-04-08 10:00:14 +02:00
Lubomir Rintel
1ad193a017 device,libnm,cli: add "new-activation" reason for device state change
It will be used when the device is disconnected for new connection activation.
2015-04-08 10:00:11 +02:00