Commit graph

17060 commits

Author SHA1 Message Date
Thomas Haller 6aa4dc1958 platform: implement NM_LINUX_PLATFORM_GET_PRIVATE() via _NM_GET_PRIVATE_VOID() macro
We should implement all our private-getters with the very same pattern
(i.e. their type structure contains a field "_priv" and nm_assert()
with a GObject type check).

NM_LINUX_PLATFORM_GET_PRIVATE() was already doing all of that. Now just
use the _NM_GET_PRIVATE_VOID() macro which formally follows the
intended pattern.
2017-03-10 11:43:41 +01:00
Thomas Haller 7d88bd24f3 shared: add _NM_GET_PRIVATE_VOID() macro
_NM_GET_PRIVATE() macro is used to implement a standard private-getter, but it
requires that "self" is a pointer of either "const type *" or "type *". That
is great in most cases, but sometimes we have predominatly self pointers of
different type, so it would require a lot of casts.

Add a different form _NM_GET_PRIVATE_VOID() where self pointer can be any
non-const pointer and returns a non-const private pointer after casting.
2017-03-10 11:06:02 +01:00
Thomas Haller 3ce22c7319 platform/tests: use NMTST_WAIT_ASSERT() to wait for address 2017-03-09 23:06:08 +01:00
Beniamino Galvani 7ef2651d71 merge: branch 'bg/reapply-more-bgo779794'
https://bugzilla.gnome.org/show_bug.cgi?id=779794
2017-03-09 22:00:41 +01:00
Beniamino Galvani c4ca123a4a device: reapply proxy configuration
In order to support a reapply of proxy configuration, remember the PAC
URL received through DHCP and merge it again with configuration from
proxy setting on reapply.
2017-03-09 21:58:28 +01:00
Beniamino Galvani ad3fdcd90d device: allow reapply of MTU
The MTU is reapplied together with IP configuration: modify device
subclasses to announce they support the property in
can_reapply_change().
2017-03-09 21:58:28 +01:00
Beniamino Galvani 9cc9ce4bfa device: reapply connection.lldp property 2017-03-09 21:58:28 +01:00
Beniamino Galvani 3f5f5ed4eb device: ethernet: reapply link speed and wol settings 2017-03-09 21:58:28 +01:00
Beniamino Galvani 686fea6562 platform: tests: wait for non-tentative address before adding route
Wait that the address becomes non-tentative before adding the route
with RTA_PREFSRC.  Dummy interfaces are NOARP and thus don't do DAD,
but the kernel sets the address as tentative for a small amount of
time, which prevents the immediate addition of the route with
preferred source.

Fixes: 36d9e252d2
2017-03-09 19:01:59 +01:00
Thomas Haller 74f62d21ce platform/tests: add test code to initialize NMPCacheId with bogus data 2017-03-09 15:50:20 +01:00
Thomas Haller f0e295d3d7 platform: filter out invisible links for cache lookup by name
Fixes: ad1d74d142
2017-03-09 15:12:43 +01:00
Thomas Haller 3799874664 platform: fix check in NMP_CLASS_IS_VALID
Maybe it was not wrong before, but this looks more
correct.
2017-03-09 15:12:43 +01:00
Thomas Haller 2972fd55bf platform/trivial: remove obsolete code comment 2017-03-09 14:57:00 +01:00
Thomas Haller 831286df30 include: use double-quotes to include our own headers
In practice, this should only matter when there are multiple
header files with the same name. That is something we try
to avoid already, by giving headers a distinct name.

When building NetworkManager itself, we clearly want to use
double-quotes for including our own headers.
But we also want to do that in our public headers. For example:

  ./a.c
    #include <stdio.h>
    #include <nm-1.h>
    void main() {
        printf ("INCLUDED %s/nm-2.h\n", SYMB);
    }

  ./1/nm-1.h
    #include <nm-2.h>

  ./1/nm-2.h
    #define SYMB "1"

  ./2/nm-2.h
    #define SYMB "2"

$ cc -I./2 -I./1 ./a.c
$ ./a.out
INCLUDED 2/nm-2.h

Exceptions to this are
  - headers in "shared/nm-utils" that include <NetworkManager.h>. These
    headers are copied into projects and hence used like headers owned by
    those projects.
  - examples/C
2017-03-09 14:12:35 +01:00
Beniamino Galvani afd1bde366 device: ip-tunnel: free strings on dispose
Fixes: 570fdce93f
2017-03-09 12:05:59 +01:00
Thomas Haller fada1da80b systemd: merge branch systemd into master 2017-03-09 01:04:15 +01:00
Thomas Haller 41eae0d5bd systemd: update code from upstream (2017-03-08)
This is a direct dump from systemd git on 2017-03-08, git commit
37377227ff47aa88c698c4b704d68d600d695c9f.

======

SYSTEMD_DIR=../systemd
COMMIT=37377227ff47aa88c698c4b704d68d600d695c9f

(
  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/alloc-util.c"
nm_copy_sd "src/basic/alloc-util.h"
nm_copy_sd "src/basic/async.h"
nm_copy_sd "src/basic/escape.c"
nm_copy_sd "src/basic/escape.h"
nm_copy_sd "src/basic/ether-addr-util.c"
nm_copy_sd "src/basic/ether-addr-util.h"
nm_copy_sd "src/basic/extract-word.c"
nm_copy_sd "src/basic/extract-word.h"
nm_copy_sd "src/basic/fileio.c"
nm_copy_sd "src/basic/fileio.h"
nm_copy_sd "src/basic/fd-util.c"
nm_copy_sd "src/basic/fd-util.h"
nm_copy_sd "src/basic/fs-util.c"
nm_copy_sd "src/basic/fs-util.h"
nm_copy_sd "src/basic/hash-funcs.c"
nm_copy_sd "src/basic/hash-funcs.h"
nm_copy_sd "src/basic/hashmap.c"
nm_copy_sd "src/basic/hashmap.h"
nm_copy_sd "src/basic/hexdecoct.c"
nm_copy_sd "src/basic/hexdecoct.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/io-util.c"
nm_copy_sd "src/basic/io-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/mempool.h"
nm_copy_sd "src/basic/mempool.c"
nm_copy_sd "src/basic/parse-util.c"
nm_copy_sd "src/basic/parse-util.h"
nm_copy_sd "src/basic/path-util.c"
nm_copy_sd "src/basic/path-util.h"
nm_copy_sd "src/basic/prioq.h"
nm_copy_sd "src/basic/prioq.c"
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/set.h"
nm_copy_sd "src/basic/signal-util.h"
nm_copy_sd "src/basic/siphash24.c"
nm_copy_sd "src/basic/siphash24.h"
nm_copy_sd "src/basic/socket-util.c"
nm_copy_sd "src/basic/socket-util.h"
nm_copy_sd "src/basic/sparse-endian.h"
nm_copy_sd "src/basic/stdio-util.h"
nm_copy_sd "src/basic/string-table.c"
nm_copy_sd "src/basic/string-table.h"
nm_copy_sd "src/basic/string-util.c"
nm_copy_sd "src/basic/string-util.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/umask-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/arp-util.c"
nm_copy_sd "src/libsystemd-network/arp-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/lldp-internal.h"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.c"
nm_copy_sd "src/libsystemd-network/lldp-neighbor.h"
nm_copy_sd "src/libsystemd-network/lldp-network.c"
nm_copy_sd "src/libsystemd-network/lldp-network.h"
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-network/sd-ipv4acd.c"
nm_copy_sd "src/libsystemd-network/sd-lldp.c"
nm_copy_sd "src/libsystemd/sd-event/sd-event.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.c"
nm_copy_sd "src/libsystemd/sd-id128/id128-util.h"
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-ndisc.h"
nm_copy_sd "src/systemd/sd-id128.h"
nm_copy_sd "src/systemd/sd-ipv4acd.h"
nm_copy_sd "src/systemd/sd-ipv4ll.h"
nm_copy_sd "src/systemd/sd-lldp.h"
2017-03-09 01:03:49 +01:00
Francesco Giudici b17d28cb42 test: platform: remove the source parameter from the ip6 route option test
The test fails on some kernels. Needs more investigations.
In the meanwhile, remove the src option from the test.

Fixes 45dc2feded
2017-03-08 19:04:48 +01:00
Thomas Haller 2ab946502d core/tests: add test for nm_match_spec_device() to match "except:*"
We also allow negative matches for plain "*", meaning to explicitly
not manage anything.
2017-03-08 16:34:52 +01:00
Thomas Haller ab6e370195 all/trivial: unify construct-only property comments
Unify marking GObject properties that are G_PARAM_CONSTRUCT_ONLY
with a comment

    /* construct-only */
2017-03-08 13:47:00 +01:00
Thomas Haller 556b7c3b45 libnm: add assertion to NMObject that a dbus-object is set
The libnm cache types don't have public _new() functions.
However, such types can be easily created using g_object_new()
directly from user code.

Such a usage is not supported. Add an assertion that a valid
dbus-object is present.
2017-03-08 08:16:44 +01:00
Thomas Haller 9ed0e3705e libnm: chain up NMRemoteConnection::constructed() function
Fixes: 0fdd71fe6e
2017-03-07 23:47:43 +01:00
Beniamino Galvani 2eeb13d81e device: add check for NULL connection diff in check_and_reapply_connection()
Fixes: 592b211bcc
2017-03-07 09:57:45 +01:00
Thomas Haller e72b43e01f contrib/rpm: reorder spec file and move bcond definitions together 2017-03-06 20:23:15 +01:00
Thomas Haller 560801e237 contrib/rpm: remove unused default_with_* variables
They are unused since commit d2fd1b9fb7.
2017-03-06 20:23:14 +01:00
Thomas Haller 2b6f3ba3cf contrib/rpm: add explicit libxslt build dependency
We configurably use --enable-gtk-doc/--disable-gtk-doc, but
we always require --enable-introspection (due to --enable-vala).

Add the missing build requirement to the "xsltproc" binary, which is in
libxslt package.
2017-03-06 19:59:29 +01:00
Thomas Haller 86278ebd2e build: add configure check that we have perl and xstlproc for introspection
With --enable-introspection we generate various targets that either
require perl or xsltproc. Error out when building with introspection
enabled but the programs are not found.
2017-03-06 18:40:12 +01:00
Beniamino Galvani 468127ca69 merge: branch 'bg/route-options-rh1373698'
https://bugzilla.redhat.com/show_bug.cgi?id=1373698
2017-03-06 15:21:23 +01:00
Thomas Haller 10f58f2bd3 ifcg-rh/writer: stack allocate keys in write_ip4_setting()
And make the types of the integer count variables consistent.
2017-03-06 15:20:25 +01:00
Beniamino Galvani d094914120 cli: support route options 2017-03-06 15:20:25 +01:00
Beniamino Galvani 40e1fd9531 ifcfg-rh: support route options
For IPv4 we support both the legacy and the new route file format. In
the legacy format, option are appended to the "ip route" command
arguments:

  203.0.113.0/24 metric 3 via 198.51.100.1 dev eth2 cwnd 14 mtu lock 1500

This is backwards compatible with initscripts. In the new format, a
OPTIONSx= variable is added to represent the options in the same
format understood by iproute2:

 ADDRESS0=203.0.113.0
 NETMASK0=255.255.255.0
 GATEWAY0=198.51.100.1
 METRIC0=3
 OPTIONS0="cwnd 14 mtu lock 1500"

initscripts do not support this variable at the moment (but the
changes needed to support it are trivial).

By default the new format is used, unless the route file is already in
the legacy format.

For IPv6 only the legacy format is supported, as before.
2017-03-06 15:20:25 +01:00
Beniamino Galvani cdfa625102 keyfile: support route options 2017-03-06 15:20:25 +01:00
Beniamino Galvani dad1071374 core: apply route options from configuration 2017-03-06 15:20:25 +01:00
Beniamino Galvani 54e58eb96b libnm-core: define known route attribute names and validation function
This adds definition of a set of known route option attributes to
libnm-core and helper functions.

nm_ip_route_attribute_validate() performs the validation of the
attribute type and, in case of a formatted string attribute, of its
content.

nm_ip_route_get_variant_attribute_spec() returns the attribute format
specifier to be passed to nm_utils_parse_variant_attributes(). Since
at the moment NMIPRoute is the only user of NMVariantAttributeSpec and
the type is opaque to users of the library, the struct is extended to
carry some other data useful for validation.
2017-03-06 15:20:25 +01:00
Beniamino Galvani 93b3a478bb libnm-core: add attribute parsing/format helpers
Various libnm objects (addresses, routes) carry an hash table of
attributes represented as GVariants indexed by name. Add common
routines to convert to and from a string representation.

To parse a string, a knowledge of the supported attributes (and their
types) is needed: we represent it as an opaque type
NMVariantAttributeSpec that callers must query to the library for the
specific object type and pass to the parse function.
2017-03-06 15:20:25 +01:00
Beniamino Galvani 45dc2feded platform: add support for some route options
Add support for new route options: window, cwnd, initcwnd, initrwnd,
mtu (and their related *-lock flag), tos and src (RTA_SRC).
2017-03-06 15:20:25 +01:00
Beniamino Galvani 63951cad7f platform: change signature of nm_platform_ip{4,6}_route_add()
Change the functions to accept a platform route as argument. This will
make it easier to add new route options.
2017-03-06 15:20:25 +01:00
Beniamino Galvani 36d9e252d2 platform: support preferred source option for IPv6 routes
Extend the support for the preferred source route option (RTA_PREFSRC)
to IPv6.
2017-03-06 15:20:25 +01:00
Beniamino Galvani c55c631233 shared: add test utilities for IP routes
Add utility functions to check the value of a route attribute.
2017-03-06 15:20:25 +01:00
Beniamino Galvani b9d11ffaa2 checkpoint: reactivate/update connections only if necessary on rollback
On rollback, before updating the settings-connection check if it
actually changed. Also, only reactivate the connection if it was
deactivated or if the settings/applied connection changed.

https://bugzilla.redhat.com/show_bug.cgi?id=1427187
2017-03-06 14:38:33 +01:00
Beniamino Galvani 6b7419c780 merge: branch 'bg/bond-reapply-rh1348198'
https://bugzilla.redhat.com/show_bug.cgi?id=1348198
2017-03-06 10:38:01 +01:00
Beniamino Galvani 592b211bcc device: add list of changed properties to reapply audit log 2017-03-06 10:29:38 +01:00
Beniamino Galvani 2d26cce9c2 audit: add @args to device logging functions 2017-03-06 10:29:37 +01:00
Beniamino Galvani ef491acfde core: split nm_utils_format_con_diff_for_audit()
The function will be called to display in audit logs the changes done
to connections.
2017-03-06 10:29:37 +01:00
Beniamino Galvani 1ba25fd19f device: bond: implement connection reapply
Only a couple of bond options (active_slave, primary) are supported at
for now.
2017-03-06 10:29:37 +01:00
Beniamino Galvani 86388f41b8 device: introduce class methods for connection reapply
Add two new methods can_reapply_change() and reapply_connection() to
the device class. In this way device subclasses can declare that they
support the changes in a given setting and take care of reapplying it.
2017-03-06 10:29:37 +01:00
Beniamino Galvani 8922f9aabe device: internally export nm_device_hash_check_invalid_keys() 2017-03-06 10:29:16 +01:00
Beniamino Galvani 8eb49639fc bond: set the active slave only after enslavement
The kernel doesn't accept an interface to be set as active_slave until
the interface is enslaved to the bond. Delay the initialization of the
property.
2017-03-06 10:29:16 +01:00
Lubomir Rintel c2329e0ee3 libnm-core: remove a redundant docstring
It makes gtk-doc unhappy.
2017-03-05 21:04:06 +01:00
Beniamino Galvani d405cfd908 dhcp/dhclient: parse "interface" statements
Until now any "interface" statement was ignored and any enclosed
statement for which we have a special handling was considered, even if
belonging to a different interface. This can cause wrong options to be
set in the generated dhclient configuration.

Change the code to parse "interface" statements and skip the content
if the interface doesn't match.

https://bugzilla.gnome.org/show_bug.cgi?id=778430
2017-03-03 14:14:41 +01:00