Commit Graph

748 Commits

Author SHA1 Message Date
Dan Williams
085bc0876c platform: better detection of OLPC Mesh interfaces
Instead of just looking at the udev tags, also look for sysfs entries
that the libertas driver uses when mesh is enabled.
2014-05-13 12:38:44 -05:00
Dan Williams
a9fa1bd9e2 platform: don't crash on link_change() error when ifname is NULL
to_string_link() logs link details and creates a new link to do this,
filling in the various filed in init_link().  init_link() attempts to
fill in the driver name, and might call ethtool to do that.  Well,
ethtool API only accepts an interface name (which we don't have) and
not an ifindex (which we do have), and dies.  Ensure that the ethtool
functions bail out instead of crashing if they don't get an interface
name.

Unfortunately, most callers of link_change() don't bother setting
ifindex or ifname on the link that ends up getting passed to
to_string_link(), because libnl doesn't require that when calling
rtnl_link_change().  Modify all callers to at least set the
ifindex so that to_string_link() has something useful to log.

NetworkManager[10651]: <info> (msh0): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
NetworkManager[10651]: (platform/nm-linux-platform.c:684):link_extract_type: runtime check failed: (ifname != NULL)
NetworkManager[10651]: <error> [1398107504.807205] [platform/nm-linux-platform.c:1856] link_change(): Netlink error changing link 12:  <UP> mtu 0 (1) driver 'usb8xxx' udi '/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0/net/msh0': Message sequence number mismatch

    at platform/nm-linux-platform.c:691
    at platform/nm-linux-platform.c:1850
    at devices/nm-device.c:5523
    NM_DEVICE_STATE_REASON_NOW_MANAGED) at devices/nm-device.c:6662
    at nm-manager.c:2115
2014-05-13 12:38:43 -05:00
Thomas Haller
d16761d939 platform/trivial: rename object type enums to give them a common name prefix
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
Thomas Haller
38ffd3eb9b platform: refactor build_rtnl_addr() by replacing addr4_to_broadcast()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-03 03:44:22 +02:00
Thomas Haller
857e5e0b21 platform: don't zero terminate the result GArray of get_all() functions
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-03 03:44:22 +02:00
Thomas Haller
53b6a99798 platform: refactor ip4_route_get_all() and ip6_route_get_all()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-03 01:03:06 +02:00
Thomas Haller
a4d2d71409 platform: refactor ip4_address_get_all() and ip6_address_get_all()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-03 01:03:06 +02:00
Peter Wu
a2eb4789ac platform: set link scope for IP4LL addresses
https://bugzilla.gnome.org/show_bug.cgi?id=728595

[thaller@redhat.com: minor change in coding style]
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-27 15:32:07 +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
05b5577815 platform: be more resilient in init_link against missing name of the rtnl link
Now we use init_link to print the rtnllink object, so be more
resilient to incompletly initilized objects and just set the
fields to NULL.

This fixes the (non harmful) warning:

  <debug> [1397563880.690580] [platform/nm-linux-platform.c:1950] link_change_flags(): link: change 3: flags set 'up' (1)
  init_link: assertion 'rtnl_link_get_name (rtnllink)' failed
  file platform/nm-linux-platform.c: line 1021 (to_string_link): should not be reached
  <error> [1397563880.690632] [platform/nm-linux-platform.c:1836] link_change(): Netlink error changing link (invalid link 0x7f88b5cf93c0): Unspecific failure

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-15 14:42:14 +02:00
Thomas Haller
fe88dcd8fe platform: relax assert when checking pathnames for accessing sysctl
Asserting against "/.." is wrong, because one could rename a link to
"..em1", which is a valid ifname but would crash NetworkManager.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:32:20 +02:00
Thomas Haller
e739e01900 core: use ASSERT_VALID_PATH_COMPONENT
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:27:02 +02:00
Thomas Haller
dac51747ab platform: workaround older kernels that don't accept extended address flags via netlink
Extended address flags are represented by the additional netlink
attribute IFA_FLAGS. Older kernels don't know this flag and refuse
the messages RTM_NEWADDR and RTMDEL_ADDR when it contains unknown
attributes. See net/core/rtnetlink.c, rtnetlink_rcv_msg(). This was
fixed by kernel commit 661d2967b3f1b34eeaa7e212e7b9bbe8ee072b59.

libnl was fixed in commit 5206c050504f8676a24854519b9c351470fb7cc6 only to
send the additional netlink attribute, when there are actually flags
that make this necessary.

This commit changes nm-platform to strip the flags to &= 0xFF, if we detect
that the kernel does not understand extended address flags.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-04 19:48:44 +02:00
Dan Winship
4dba720d8c platform: fix handling of labels
If an address has a label without a ':' in it (eg, its label is just
$DEVICE, not $DEVICE:$NUM), then ignore it.
2014-03-26 12:56:57 -04:00
Dan Winship
bc43d532ee platform: support address labels for IPv4 addresses 2014-03-26 10:39:37 -04:00
Dan Williams
893735c814 platform: fix crash if link has no name after 5e935dfd
When a VPN goes down, like at suspend, and the link has already
disappeared, the new platform logging code tries to print the
link information using a link object with only the ifindex filled
in.  When adding/removing/changing links, internal code often fills
in just the ifindex (becuase that's all you need).  Thus
to_string_link() will always fail if that operation fails.

    at platform/nm-linux-platform.c:688
    at platform/nm-linux-platform.c:1835
    at vpn-manager/nm-vpn-connection.c:274

Work around that for now and live with the warnings until
we decide what to actually do about to_string_link().
2014-03-14 15:58:41 -05:00
Thomas Haller
e7daeeecb4 platform: add logging for adding/changing links
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 21:40:42 +01:00
Thomas Haller
5e935dfd15 platform: add to_string functions for libnl objects
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 21:12:49 +01:00
Thomas Haller
59394aef74 platform: be more resilient to unexpected libnl objects
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-13 21:12:49 +01:00
Thomas Haller
3d396d6f72 platform: react on udev signal "move"
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-12 16:58:19 +01:00
Thomas Haller
b9d85bb783 platform: fix link_type_from_udev() to use ifname from libnl
When an interface gets renamed, we first receive a libnl update with
the changed interface name.

This results in the following chain of calls:
  - event_notification()
  - announce_object()
  - link_init()
  - link_extract_type()
  - link_type_from_udev()
Then link_type_from_udev() looks up the name in the udev data (getting
the previous name, because we did not yet recieve the udev notification)
and passes the name to wifi_utils_is_wifi(), which eventually calls
nm_platform_link_get_ifindex() -- doing a lookup by the old name.

Fix this, by passing the ifname from libnl to link_type_from_udev().

Also, change hack_empty_master_iff_lower_up() because it is called
from event_notification(), at a moment when the link cache possibly
does not yet know the ifindex -- so that the call chain to
link_extract_type(), link_type_from_udev(), wifi_utils_is_wifi()
again might lead to lookup for something that does not yet exist.
Note, that in this case the name would not yet exist, because we
did not yet put the libnl object into the link cache.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-12 16:58:19 +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
Dan Winship
b1adf22ebb platform: fix some tabs-vs-spaces
The nla_policy struct declarations for GRE, etc, were originally
copied from the kernel sources, where they used tabs to align the "="
columns. Fix them to use spaces instead.
2014-03-06 09:47:09 -05:00
Dan Winship
f43fa7a0ac platform: fix a logging bug
Absence of a "-" meant that a debug-level message got logged as an
error.
2014-03-05 11:20:54 -05:00
Thomas Haller
3e9ba55c3a platform: move asserts for sysctl_get/set functions to nm-linux-platform
Also assert inside of sysctl_get() that we read the expected file
locations. Especially because now we might log the content of these
files.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-04 21:21:35 +01:00
Thomas Haller
087c88f729 platform: add logging when reading and writing sysctl values
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-04 21:06:21 +01:00
Thomas Haller
6655d5c949 platform: remove logging about check_cache_items()
We don't thoroughly log the pointer values of our libnl objects,
so the logging in check_cache_items() is not usefull, it only
clutters the logfile.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-03-04 18:21:37 +01:00
Dan Winship
5fe94852ef platform: change sysctl_get/set error logging
Remove the "silent_on_error" flag from nm_platform_sysctl_get(), and
make both get() and set() log at debug level on ENOENT and error level
on all other errors, always.

Also ensure that we don't sometimes write "failed to set 'x' to 'y':
Success" when a partial write occurs.
2014-02-27 15:28:11 -05:00
Thomas Haller
72f5542488 platform: downgrade error logging about NLE_DUMP_INTR on event socket
Such a failure can happen easily, because we now request an initial dump
to get AF_INET6 addresses in order to check for extended ifa flags support.

This is not critical, so downgrade the error log.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-25 16:31:53 +01:00
Thomas Haller
79f0f72b84 trivial: rename function in platform
To make the name analog to init_ip4_address, etc. which start with
init_*.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 22:06:07 +01:00
Thomas Haller
66f5256b94 core: add nm_platform_link_refresh() function to refresh the libnl cache for links
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-23 22:31:42 +01:00
Dan Winship
eac0573d5e platform: log warnings if macvlan/gre property reads fail 2014-02-21 13:54:02 -05:00
Dan Winship
4e273c4be8 platform: fix macvlan flags checking
You can't do an #ifdef on an enum value, so we were actually never
requesting IFLA_MACVLAN_FLAGS.
2014-02-21 13:54:02 -05:00
Dan Winship
95cf36fa8b platform: sanitize a boolean property
Make sure NMPlatformGreProperties->path_mtu_discovery is always TRUE
or FALSE, even if the value from the kernel is "2" or "16" or
something. (This makes it consistent with what we do for other boolean
netlink properties.)
2014-02-21 13:54:02 -05:00
Thomas Haller
5f5c7284d1 platform: refactor delete_object() and allow deletion of objects that are not cached
- refactor delete_object() by merging with delete_kernel_object()

- allow deletion of object that we cannot find in the cache
  currently. The kernel might have such an address, even if we don't
  have it currently cached. In this case, fall back to @obj.

  Also try to work around an issue, that we cannot delete an IPv4 route without
  knowing its scope.

- suppress logging error message for NLE_NOADDR, which is a common
  failure when deleting an address. But at the same time, add some more
  debug logging, for NLE_NOADDR and NLE_OBJ_NOTFOUND.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 21:41:23 +01:00
Thomas Haller
d6add4de5c platform: clear host identifier before adding a route
Adding IPv4 routes, with a non-zero host identifer fails with an
error message. Adding IPv6 addresses, does not return an error,
but it seems to have no effect.

Thus we have to make sure that the host part of routes
is always zero.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 21:40:58 +01:00
Thomas Haller
ebbd6575ff platform: log the link family in event_notification() and get_kernel_object()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 21:40:58 +01:00
Thomas Haller
a6f9266555 platform: fix caching for link types
This bug was present since a long time, however libnl3-v3.2.23
(commit fdd1ba220dd7b780400e9d0652cde80e59f63572) changed the returned
family of bridge link objects, which breaks NetworkManager.

This resulted in error messages such as:

  DBG<4>            object.c:207  nl_object_get: New reference to object 0x19c34b0, total 2
  DBG<5>        route/link.c:895  link_keygen: link 0x19c34b0 key (dev 9 fam 7) keysz 8, hash 0x2b2
  DBG<2>         hashtable.c:127  nl_hash_table_add: Warning: Add to hashtable found duplicate...
  DBG<4>            object.c:221  nl_object_put: Returned object reference 0x19c34b0, 1 remaining
  NetworkManager[17745]: <error> [1392114373.475432] [platform/nm-linux-platform.c:1328] event_notification(): netlink cache error: Object exists

Even before the change of libnl, I saw the following error lines
 <debug> [...] [platform/nm-linux-platform.c:1216] event_notification(): netlink event (type 16) for link: virbr0 (4)
 <error> [...] [platform/nm-linux-platform.c:1265] event_notification(): netlink cache error: Object exists
Hence, the caching mechanism for libnl objects already had a bug.

For rtnl link objects, the identifier consists of family and ifindex.
Since in upper layers, we don't easily know the family, we need a way to find
the objects inside the cache. We do this, by only caching links of family
AF_UNSPEC.

Objects that we receive via event_notification() are never cached. They are only used
to trigger refetching the kernel_object. Their family is irrelevant, we
only need to know, that something about this ifindex changed.

For objects retrieved via get_kernel_object(), we only get link objects of
family AF_UNSPEC or AF_BRIDGE. In any case, we reset (coerce) their family
before caching. This way, inside the link cache, there are only objects with
(coerced) family AF_UNSPEC. We loose the information, which family the
link had, however we don't need it anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=719905
https://bugzilla.redhat.com/show_bug.cgi?id=1063290

Duplicates:
https://bugzilla.gnome.org/show_bug.cgi?id=724225
https://bugzilla.redhat.com/show_bug.cgi?id=1063800

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 21:40:58 +01:00
Thomas Haller
a5f3fcae29 platform: add function choose_cache_by_type()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 21:40:58 +01:00
Thomas Haller
dc54b2e3b2 platform: cleanup object_type_from_nl_object()
- change object_type_from_nl_object() to accept unknown object
  types.
- replace g_assert_not_reached() with g_return_if_fail().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 21:40:57 +01:00
Thomas Haller
e02b1a8620 platform: refactor link_get() not to use auto_nl_object
The previous implementation called nl_object_get() and nl_object_put()
each time in link_get(). As nl_object_get() and nl_object_put()
causes debug logging in libnl, this clutters the output.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 18:35:07 +01:00
Thomas Haller
6c2f96421b core/platform: fix wrong warning log in nm-linux-platform
According to documentation, nl_rtgen_request() returns 0 on success.
Due to a bug (fixed upstream) in older libnl versions, nl_rtgen_request()
returns the number of bytes sent, which caused logging although
succeeding.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-31 14:54:33 +01:00
Thomas Haller
0535aa44db core: use nm_utils_get_monotonic_timestamp_s for timestamp of NMPlatformIP[46]Address
https://bugzilla.gnome.org/show_bug.cgi?id=720833

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 19:51:45 +01:00
Thomas Haller
7841f9ea0a core/platform: add check_support_kernel_extended_ifa_flags function
The kernel adds a new capability to allow user space to manage
temporary IPv6 addresses. We need to detect this capability
to act differently, depending on whether NM has an older kernel
at hand.

This capability got introduced together when extending the
ifa_flags to 32 bit. So, we can check the netlink message,
whether we have such an nl attribute at hand.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 17:04:36 +01:00
Thomas Haller
616fdb35ea core/platform: fix passing wrong type to variadic function nl_socket_add_memberships
nl_socket_add_memberships expects a variadic list of int,
NULL is possibly defined as ((void *) 0) or 0L.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 17:03:43 +01:00
Thomas Haller
2fd8d40a5a core/platform: silence error about reading sysctl file phys_port_id
It is common that the file exists, but cannot be read
(Operation not supported). So, silence any error when
reading the phys_port_id file.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 16:34:06 +01:00
Thomas Haller
4b2533fc00 core/tun: make reading of tun properties more robust
There seems to be the possibility of a race while reading tun
properties from sysctl. In this case, when being unable to
read the properties at construction of NMDeviceTun, we retry
shortly after.

- let tun_get_properties() not log any errors and it
  does not stop on the first error but tries to read all
  the values. Also, it initializes all fields of the output
  structure with a default value (NULL).

- hard code kernel flag #ifndef in header files. Even if the
  flag IFF_MULTI_QUEUE is not defined at compile time of NM,
  it could still be supported by the kernel (eg. when booting
  a newer kernel then the installed kernel headers). Simply
  hard code the value, this value is not ever going to change
  anyway.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 11:53:32 +01:00
Thomas Haller
634e4c99c3 platform: add parameter to nm_platform_sysctl_get() to suppress logging error
In some cases, an error when reading the sysctl value can be expected.
In this case, we want to suppress the error message

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 11:53:32 +01:00