Commit graph

436 commits

Author SHA1 Message Date
Jiří Klimeš
43b4c8f826 platform: ignore nm_platform_ip4_route_add/delete return value
Coverity:
Defect type: CHECKED_RETURN
2014-12-05 09:38:40 +01:00
Thomas Haller
34124296c0 core: fix route metrics for subnet routes
For IPv4 addresses, the kernel automatically adds a route when
configuring an IP address. Unfortunately, there is no way to control
this behavior or to set the route metric.

Fix this, by adding our own route and removing the kernel provided
one.

Note that this adds a major change in that we no longer call
nm_ip4_config_commit() for assumed devices.

https://bugzilla.gnome.org/show_bug.cgi?id=723178

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-25 22:30:38 +01:00
Thomas Haller
0b50940f43 platform: add paramter to ip4_route_add to set src (RTA_PREFSRC)
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-25 22:30:38 +01:00
Dan Winship
3bfb163a74 all: consistently include config.h
config.h should be included from every .c file, and it should be
included before any other include. Fix that.

(As a side effect of how I did this, this also changes us to
consistently use "config.h" rather than <config.h>. To the extent that
it matters [which is not much], quotes are more correct anyway, since
we're talking about a file in our own build tree, not a system
include.)
2014-11-13 17:18:42 -05:00
Thomas Haller
66b05c94c0 platform: assert against expected lifetime values of NMPlatformIPAddress
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-12 15:58:47 +01:00
Thomas Haller
276424c881 core: remove unneeded check in nm_ip4_config_commit() for default routes
These lines are part of NM for a very long time.
I think they are wrong, because the default route is not
added to the NMIP4Config/NMIP6Config objects.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:12 +01:00
Thomas Haller
0c355ea5a0 platform: support route_get_all() to return route for every ifindex
By passing an ifindex of 0, the search is not limited to a certain
ifindex.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:11 +01:00
Thomas Haller
3ef807c6ae platform: extend nm_platform_ipX_route_get_all() to return default-routes only
Add a new enum NMPlatformGetRouteMode. This extends the existing
functions nm_platform_ip4_route_get_all() and nm_platform_ip6_route_get_all()
to return default routes only.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:23:11 +01:00
Thomas Haller
52ddd72bde core: cleanup type of route metric to ensure guint32
Kernel, netlink an NMPlatformRoute treat route metrics as
uint32. Fix several places to use the exact type.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:06 +01:00
Thomas Haller
c262819360 platform: don't include gsystem-local-alloc.h in nm-platform.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-11-07 15:19:05 +01:00
Dan Williams
fb78b671d7 platform: fix lifetime/preferred type in _address_get_lifetime()
They are defined as gint32 but are assigned a guint32 value and
then immediately passed back to the caller of _address_get_lifetime()
as guint32.  They can never be negative, and may receive values
greater than G_MAXINT32, so they should be unsigned.
2014-11-05 12:44:59 -06:00
Dan Winship
ace746df4e platform: deal with default route being passed to route_sync() (bgo 735325)
NMIP4Configs and NMIP6Configs are never supposed to contain a default
route, and thus nm_platform_ip6_route_sync() should never have to deal
with one. Unfortunately, if it *does* get passed a default route, it
will add it even if it was already there. This will result in an
RTM_NEWROUTE notification, which will cause NMPlatform to emit
ip6-route-changed, which will result in NMDevice doing some work and
then calling nm_ip6_config_commit(), which will result in NMIP6Config
passing the same list of routes to nm_platform_ip6_route_sync() again,
including the default route, which will cause NMPlatform to add the
route again...

(Something eventually causes this cycle to get broken, but it starts
up again the next time NM receives an RA.)

Fix this by having the route_sync() functions never add/modify the
default route (They were already not deleting it.)
2014-10-29 09:14:03 -04:00
Lubomir Rintel
33866e4030 core: Move NMPlatformSource to nm-types.h
...and rename it while at it. It's going to be useful outside nm-platform,
to weight MTU options from various sources.
2014-10-20 12:41:50 +02:00
Thomas Haller
94a6f609f7 platform: fix format string for logging MTU in nm_platform_link_set_mtu()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-09 13:12:51 +02:00
Thomas Haller
388d4d9030 platform: add @peer_address argument to nm_platform_ip4_address_delete()
Deleting an IPv4 address using libnl requires the proper peer address.
Pass the address of the peer on to nm_platform_ip4_address_delete().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:32:11 +02:00
Thomas Haller
64851f9559 platform: log ifindex and ifname when deleting addresses or routes
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:32:11 +02:00
Thomas Haller
fa18bd6e0a platform/trivial: move code in nm-platform.c
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:12:45 +02:00
Dan Williams
37f11fbdf8 platform: add support for kernel IPv6LL address generation modes
This patch requires both upstream kernel support for
IFLA_INET6_ADDR_GEN_MODE which was merged in this patch:

ipv6: addrconf: implement address generation modes
bc91b0f07ada5535427373a4e2050877bcc12218

and corresponding libnl support, merged in these patches:

veth: add kernel header linux/veth.h for VETH defines
9dc6e6da90016a33929f262bea0187396e1a061b

link: update copy of kernel header include/linux/if_link.h
b51815a9dbd8e45fd2558bbe337fb360ca2fd861

link/inet6: add link IPv6 address generation mode support
558f966782539f6d975da705fd73cea561c9dc83
2014-09-04 15:10:26 -05:00
Dan Winship
c43f88907b libnm-core: change DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES
Change all DBUS_TYPE_G_UCHAR_ARRAY properties to G_TYPE_BYTES, and
update corresponding APIs. Notably, this means they are now refcounted
rather than being copied.

Update the rest of NM for the changes. The daemon still converts SSIDs
to GByteArrays internally, because changing it to use GBytes has lots
of trickle-down effects. It can possibly be changed later.
2014-09-04 09:20:11 -04:00
Dan Winship
ea456aaa81 all: remove use of struct ether_addr / ether_aton()
Lots of old code used struct ether_addr to store hardware addresses,
and ether_aton() to parse them, but more recent code generally uses
guint8 arrays, and the nm_utils_hwaddr_* methods, to be able to share
code between ETH_ALEN and INFINIBAND_ALEN cases. So update the old
code to match the new. (In many places, this ends up getting rid of
casts between struct ether_addr and guint8* anyway.)

(Also, in some places, variables were switched from struct ether_addr
to guint8[] a while back, but some code still used "&" when referring
to them even though that's unnecessary now. Clean that up.)
2014-08-07 12:11:49 -04:00
Dan Winship
a7c4d53d03 all: port everything to libnm
Since the API has not changed at this point, this is mostly just a
matter of updating Makefiles, and changing references to the library
name in comments.

NetworkManager cannot link to libnm due to the duplicated type/symbol
names. So it links to libnm-core.la directly, which means that
NetworkManager gets a separate copy of that code from libnm.so.
Everything else links to libnm.
2014-08-01 14:34:05 -04:00
Thomas Haller
6f013183e8 platform: extend nm_platform_ip_address_cmp_expiry() to handle addresses without timestamp
If the timestamp is set to zero, the to_string() functions treat the lifetime
as based on *now*. For nm_platform_ip_address_cmp_expiry() this makes no
sense, because there is no absolute exiry to compare. Instead compare
them as expire earlier then the other address.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-19 22:26:10 +02:00
Thomas Haller
c6d45a4083 platform: modify address to_string() to show raw lifetime values
The "lifetime" part when printing an address in nm_platform_ip[46]_address_to_string()
is supposed to show the raw, internal values of the address.

We already have the "lft" and "pref" output that presents the expiries based on now.
These fields are already crafted to show what the user probably wants
to see when looking at debugging log. "lifetime" should not do any
special casing and just print the raw values.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-19 22:26:10 +02:00
Thomas Haller
c29496125f platform: handle unset address timestamp as *now* in to_string()
When printing an address in nm_platform_ip4_address_to_string()
and nm_platform_ip6_address_to_string() treat an unset @timestamp
as counting from @now.

This is useful, if you just have the remaining lifetime at hand
and want to print an address. In general it is not a good idea to
leave the timestamp not anchored to an absolute @timestamp.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-19 22:26:10 +02:00
Dan Winship
3c13d9e3fd misc: remove some dead code
The G_DISABLE_CHECKS version of g_return_if_reached() still returns,
it just doesn't log. So don't include a manual return after a
return-if-reached.
2014-06-12 17:13:56 -04:00
Thomas Haller
63ef089f69 platform: pass optional padding to _rebase_relative_time_on_now()
_rebase_relative_time_on_now() is used both by _address_get_lifetime()/nm_platform_ip[46]_address_sync()
and the to_string() functions.

In the latter case, we want to print the original value, without padding. Otherwise in
the addresses are printed in the logs with an additional 5 seconds
padding, which is confusing.

For adding addresses in platform however, we still want to keep the
padding. So pass it on as additional parameter.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-07 11:35:22 +02:00
Thomas Haller
a04df905fd platform: fix format specifyer in _lifetime_to_string() for unsigned
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 20:05:08 +02:00
Thomas Haller
2ff046e5aa platform: change address_to_string functions to show remaining lifetime/preferred times
Change the to_string functions to convert the lifetime/preferred values
to the time remaining when the function is evaluated. These functions
are used for printing/debugging, so it's more sensible to show the
remaining time.

On the other hand, for debugging, it's better to see the raw values (also).
In addition to the remaining time we keep to print the timestamps+now if the
address is not permanent. So when inspecting the logs it is possible to figure
out the real values.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 20:01:38 +02:00
Thomas Haller
e1410b5a88 platform: refactor calculating valid/preferred times when adding address
Replace the calls to subtract_guint32() by _rebase_relative_time_on_now()
and _address_get_lifetime().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 20:01:37 +02:00
Thomas Haller
d90b9ff2c8 platform: fix setting preferred time for address
Before nm_platform_ip4_address_sync() set the preferred time to the same value
as the address lifetime. The result was that the preferred time was
always identical to valid lifetime.

This will lead to the kernel using the address longer then the desired
preferred time (until validity of the address expires).

https://bugzilla.redhat.com/show_bug.cgi?id=1082041
https://bugzilla.redhat.com/show_bug.cgi?id=1083283

Reported-by: Kai Engert <kengert@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 20:01:37 +02:00
Thomas Haller
84cfd06d6a core/platform: limit the preferred time to address lifetime
Related: https://bugzilla.redhat.com/show_bug.cgi?id=1082041

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 20:01:37 +02:00
Dan Winship
662ade1e47 platform: improve tracking of route sources
NMIP[46]Route had a "source" field, but it was always set to KERNEL
for routes read from the kernel (even if they were originally added by
NM).

Fix things a bit by translating between our "source" field and the
kernel's "protocol" field.

https://bugzilla.gnome.org/show_bug.cgi?id=729203
2014-06-06 10:24:43 -04:00
Dan Winship
e644745d85 trivial: route-related whitespace/indentation fixes 2014-06-06 10:23:28 -04:00
Pavel Šimerda
f008c9fbea platform/test: fix fake platform to emit signals synchronously (analog to Linux platform)
When adding a link, the Linux platform implementation raises the
link-changed signal synchronously. Fix the fake platform to behave identically
and also fix all the tests.

This also fixes the Linux platform tests for the most part because now the
test functions (and fake platform) behave like the Linux system
implementation.

https://bugzilla.gnome.org/show_bug.cgi?id=706293

Co-Authored-By: Thomas Haller <thaller@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
66e2e932b5 platform: add nm_platform_link_get()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-05 18:12:57 +02:00
Thomas Haller
968b468b2f platform: allow setting address when adding software link (bridge)
Add an additional address parameter to link_add/bridge_add, to set the
MAC address of software devices.

https://bugzilla.gnome.org/show_bug.cgi?id=729844

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-30 17:02:31 +02:00
Thomas Haller
59a56a0aff platform: add function nm_platform_link_cmp()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-03 03:44:23 +02:00
Thomas Haller
9cd7b40a04 platform: add nm_platform_ip_address_cmp_expiry()
This compares two addresses and returns which one has a longer
remaining life (i.e. a later expiry timestamp).

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-03 03:44:23 +02:00
Thomas Haller
09d3c833fd platform: refactor signals by combining added/changed/removed
Before platform raised 3 signals for each object type. Combine
them into one and add a new parameter @change_type to distinguish
between the change type.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-03 03:44:22 +02:00
Dan Winship
ddb17bef81 platform: add link_get_wake_on_lan() 2014-04-17 12:48:20 -04:00
Dan Winship
df435f4015 wifi: move wifi-utils into platform
Move wifi-utils into NMPlatform, and update callers to use the new
NMPlatform wrappers
2014-04-17 12:45:32 -04:00
Thomas Haller
0a9cfb48ff platform: add nm_platform_sysctl_get_int_checked() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:27:02 +02:00
Thomas Haller
2b3ef7664f core/trivial: clearify code comment on error for nm_utils_ascii_str_to_int64()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:27:02 +02:00
Dan Winship
bc43d532ee platform: support address labels for IPv4 addresses 2014-03-26 10:39:37 -04:00
Thomas Haller
2331f9b00d platform: extract function nm_platform_addr_flags2str() to wrap rtnl_addr_flags2str()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 21:40:42 +01:00
Thomas Haller
c6374debe8 platform: log more details about link signal
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 21:12:49 +01:00
Thomas Haller
6a97ca06ff platform: add function nm_platform_link_to_string()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 21:12:49 +01:00
Dan Winship
42df06e575 platform, devices: add support for vxlan devices
Since vxlan is new-ish, and vxlan IPv6 support in particular has only
been in the kernel since 3.11, we include our own copy of the vxlan
netlink constants rather than depending on the installed headers.
2014-03-06 09:48:15 -05:00
Thomas Haller
eca6a49e2d platform: fix converting address flags in nm_platform_ip6_address_to_string()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-05 11:06:37 +01:00
Thomas Haller
8cd0de231a tivial/core: move common #defines to header file
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-05 10:59:24 +01:00