Commit Graph

21088 Commits

Author SHA1 Message Date
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
Thomas Haller
c8fa7b6f57 dnsmasq: use ipv4.dns and ipv4.dns-search with ipv4.method=shared
Configure the dnsmasq DHCP server for shared mode to announce the
configured name resolution settings.
2017-03-03 13:51:05 +01:00
Thomas Haller
9e429ddc0a dnsmasq: reuse string buffer in creating command line arguments in create_dm_cmd_line() 2017-03-03 13:23:01 +01:00
Thomas Haller
a81b604cc1 tests: accept trailing arguments to "tools/run-nm-test.sh"
Previously, the test runner would only accept leading options,
an optional "--" separator, followed by "$TEST" and optional arguments
for the test.

Like

  ./tools/run-nm-test.sh -m src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh

That is annoying, because to toggle an option you have to seek the
curser in the before the test name.

Now, accept a "--test" option, so that the above can be done with trialing
arguments:

  ./tools/run-nm-test.sh -t src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh -m

However, the arguments for the tests still must come last:

  ./tools/run-nm-test.sh -m [--] src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh -p /settings/plugins/ifcfg-rh/bridge/write-master
  ./tools/run-nm-test.sh -t src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh -m [--] -p /settings/plugins/ifcfg-rh/bridge/write-master
2017-03-02 16:08:54 +01:00
Thomas Haller
61f7dd7284 tests: fix "tools/run-nm-test.sh" to build test first
./tools/run-nm-test.sh -m src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh

makes the test before running it. However, that failed if the
test didn't exist already. Reorder the code so that we always
try to make the test before trying to run it.
2017-03-02 16:08:54 +01:00
Lubomir Rintel
045de51888 docs: update years 2017-03-02 15:51:46 +01:00
Lubomir Rintel
d2fd1b9fb7 contrib/rpm: drop EOL versions of Fedora
These are history and noone should be using them; special casing them is
essentially line noise.
2017-03-02 15:51:46 +01:00
Lubomir Rintel
ef8c292881 contrib/rpm: install D-Bus service files to /usr if we can
This is in fact the correct location, but dbus in RHEL 7 is still too
old to be able to use that.
2017-03-02 15:51:46 +01:00
Thomas Haller
9d39569287 ifcfg-rh,keyfile: merge branch 'th/ifcfg-reread-rh1427482'
https://bugzilla.redhat.com/show_bug.cgi?id=1427482
2017-03-02 15:06:28 +01:00
Thomas Haller
24be1fd913 ifcfg/trivial: rename svFileSetName() and svFileSetModified() to mark for testing
The filename of the shvarFile instance should be immutable and stay
unchanged for the entire lifetime of the instance. Similarly, the
modified flag should not be explicitly set.

However, for testing it is still useful to give the unit test a
direct access to those functions.

Rename the setters to make it clear that this is test-only.
2017-03-02 14:10:50 +01:00
Thomas Haller
670e088efe libnm-core: normalize invalid bridge|team slave-port settings
Having a bridge-port/team-port setting for a connection that
has a different slave-type makes no sense. Such a configuration
shall be considered invalid, and be fixed by normalization.

Note that there is already a normalization the other way around,
when you omit the "slave-type" but a "master" and one(!) port-type
setting is present, the slave-type is automatically determined
based on the port-type.

The use of this is of course to modify an existing slave connection
to make it a non-slave. Then the invalid port settings should be
automatically removed.

Previously, ifcfg-rh writer would write the "BRIDGING_OPTS" setting
without a "BRIDGE". The reader would then (correctly) ignore the
bridge-port. Avoid that altogehter, by requiring the connection to
strictly verify.
2017-03-02 12:14:29 +01:00
Thomas Haller
e0252e7a75 ifcfg-rh: require connections to be fully normalized for writing 2017-03-02 12:14:29 +01:00
Thomas Haller
b4594af55e keyfile: updated connection when writing keyfile
Writing a connection to keyfile and read it back should result
in the identical setting. That is, a full round-trip would not
alter any information.

That is however particularly not true for certificate properties, where
the keyfile writes blobs to file and coerces paths.

Thus, whenver writing a keyfile we must read back what we just
wrote and use that instead.
2017-03-02 12:14:29 +01:00
Thomas Haller
e636d28116 keyfile: extend internal API to re-read keyfile connection after writing
Add API to re-read the keyfile after writing it.
Usually, we would expect that whenever we serialize
something to disk, it can be read back exactly the same.

That is however not true for certificates, where we mangle
path and blobs while writing to file.

Anyway, extend the write-API to re-read what we just wrote.

The tests got extended to assert that whatever we write can
be read back the same.

Later, we want to reinject the reread connection into the settings
plugin again.
2017-03-02 12:14:29 +01:00
Thomas Haller
8b1b6f3d1a libnm-core: expose internal _nm_connection_verify() function 2017-03-02 12:14:29 +01:00
Thomas Haller
72bfe62a9a all: use stack-allocated uuid at various places
No need to create a UUID on the heap in this case.
2017-03-02 12:14:29 +01:00
Thomas Haller
cf213216fd libnm-core: add ethernet setting for vlan connection
A "vlan" setting can optionally have an ethernet setting.
However, ifcfg-rh reader always adds such a setting, because
well... Anyway, the result is that writing a VLAN setting
without ethernet section will yield a different result
on re-read.

Let's have normalization add the ethernet setting, so that
two we consistently have it present.
2017-03-02 12:14:29 +01:00
Thomas Haller
53018b92e8 ifcfg-rh: fix reading team slave types of vlan type
https://bugzilla.redhat.com/show_bug.cgi?id=1427482
2017-03-02 12:14:29 +01:00
Thomas Haller
5a82494fa6 ifcfg-rh/tests: add test for writing team slave
This shows the current bug, needs to be fixed.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1427482
2017-03-02 12:14:29 +01:00
Thomas Haller
13e9967a3a ifcfg-rh: add internal API to re-read connection after write
Our reader/writer has flaws. We easily write out something that
is re-read differently. That is a problem and should be fixed.

Add API to re-read the connection after writing.

Extend the tests to check that the re-read value is identical
to what we wrote. In some cases, this does not hold. That is
usually a bug which needs fixing. Note that for certificate
blobs and paths we may intentionally mutate the connection
during writing, so there are valid cases where a connection
is re-read differently.
2017-03-02 12:14:29 +01:00
Thomas Haller
5ef4db18ce ifcfg-rh: change "goto error" pattern to return early and nm_auto* 2017-03-02 12:14:29 +01:00
Lubomir Rintel
d63b67b0e0 libnm/manager: make sure the devices and acs won't notify manager after the manager is gone
https://bugzilla.redhat.com/show_bug.cgi?id=1425838
2017-02-28 10:47:21 +01:00
Lubomir Rintel
1992945fab merge: 'lr/nmtui-slaves-after-master-rh1369008'
https://bugzilla.redhat.com/show_bug.cgi?id=1369008
2017-02-27 11:19:01 +01:00