Commit Graph

360 Commits

Author SHA1 Message Date
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
Thomas Haller
fa81901ed8 core/platform: replace strcpy by g_strlcpy
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-28 20:19:29 +01:00
Dan Williams
067db6f8d7 core/platform: add address/route sources (rh#1005416, bgo#722843)
Tag addresses and routes with their source.  We'll use this later to do
(or not do) operations based on where the item came from.

One thing to note is that when synchronizing items with the kernel, all
items are read as source=KERNEL even when they originally came from
NetworkManager, since the kernel has no way of providing this source
information.  This requires the source 'priority', which
nm_ip*_config_add_address() and nm_ip*_config_add_route() must respect
to ensure that NM-owned routes don't have their source overwritten
when merging various IP configs in ip*_config_merge_and_apply().

Also of note is that memcmp() can no longer be used to compare
addresses/routes in nm-platform.c, but this had problems before
anyway with ifindex, so that workaround from nm_platform_ip4_route_sync()
can be removed.

https://bugzilla.gnome.org/show_bug.cgi?id=722843
https://bugzilla.redhat.com/show_bug.cgi?id=1005416
2014-01-24 09:42:52 -06:00
Dan Winship
041f449a91 platform: fix linux nm_platform_link_get_physical_port_id() (rh #804527)
It was reading the wrong property name
2014-01-22 13:20:18 -05:00
Thomas Haller
177c767320 core/platform: fix wrong calculation of address lifetime/preferred for kernel addresses
When receiving an IPv4/IPv6 address from the kernel, platform set the
timestamp to an invalid value before. The address timestamp must be set
to *now*, because the lifetime and preferred arguments are counting from
now.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-16 20:44:29 +01:00
Dan Williams
90782cf023 platform: ignore errors adding IPv6 point-to-point address
For now, ignore them, as libnl does not support IPv6 PtP addresses
and returns an error.  In the future perhaps we'll want to add a host
route for the peer instead of using the point-to-point address.
2014-01-06 17:25:02 -06:00
Jiří Klimeš
5f32b8588e platform: fix uninitialized variable bcaddr in build_rtnl_addr()
platform/nm-linux-platform.c: In function 'build_rtnl_addr':
platform/nm-linux-platform.c:116:15: error: 'bcaddr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   nl_addr_put (*object);
               ^
platform/nm-linux-platform.c:2264:32: note: 'bcaddr' was declared here
   auto_nl_addr struct nl_addr *bcaddr;
                                ^
2013-12-05 09:57:37 +01:00
Dan Williams
7eb12a5b21 platform: set IPv4 broadcast address too (rh #1032819)
When moving over the platform, setting of the IPv4 broadcast address
got lost.  Bring it back.

https://bugzilla.redhat.com/show_bug.cgi?id=1032819
2013-12-03 14:25:08 -06:00
Dan Winship
f099a04132 platform/core: add back support for PtP/peer addresses (rh #1018317)
In the migration to NMPlatform, support for ptp/peer addresses was
accidentally dropped. This broke OpenVPN configurations using 'p2p'
topology, which send a different peer address than the local address
for tunX, plus the server may also push routes that use the peer
address as the next hop. NetworkManager was unable to add these
routes, because the kernel had no idea how to talk to the peer,
because the peer's address was not assigned to any interface or
reachable over any routes.

Partly based on a patch from Dan Williams.
2013-12-02 15:00:28 -05:00
Dan Williams
2086cab127 platform: dump objects that fail to be added (rh #1029213)
Attempt to figure out why the objects fail.
2013-11-13 20:06:39 -06:00
Pavel Šimerda
21b6f34f5e platform: avoid one bug warning 2013-11-08 16:46:43 -06:00
Thomas Haller
ac94d83f04 core: add ifa_flags to NMPlatformIP6Address structure
Add a field 'flags' to NMPlatformIP6Address that holds the
IFA_F_* flags as reported over netlink.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-08 00:46:33 +01:00
Dan Williams
1bf16b6f06 core: fix bridge port sysfs directory determination after f5507633 (platform: bridging and bonding options)
The device is not a slave if it *doesn't* have a master.  Code
previously returned an error if the slave did have a master, which
is wrong.
2013-11-07 11:52:28 -06:00
Dan Winship
b7300bbe5a core: improve handling of NPAR/SR-IOV devices (rh #804527)
Use the new kernel physical_port_id interface property to recognize
when two devices are just virtual devices sharing the same physical
port, and refuse to bond/team multiple slaves on the same port.
2013-11-06 10:26:16 -05:00
Thomas Haller
c67f978df0 core: fix compiler warnings -Werror=shadow by trivial renaming of variables
https://bugzilla.gnome.org/show_bug.cgi?id=710497

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-22 18:45:22 +02:00
Pavel Šimerda
f7ff042819 platform: use translated VLAN flags
The internal VLAN flags were translated into the kernel VLAN flags but
finally the internal ones were passed to the kernel instead.

Reported-by: Julien Nabet <serval2412@yahoo.fr>
2013-10-20 18:20:53 +02:00
Dan Williams
6b8bf26b79 platform: don't treat unrecognized WiMAX devices as Ethernet
If the WiMAX plugin isn't installed, or the WiMAX device isn't
recognized, NetworkManager shouldn't treat the interface as
regular ethernet since the device requires specific setup to
be ready for IP configuration, which of course NetworkManager
can't do because the WiMAX plugin isn't loaded.  Ignore them
instead.
2013-10-18 11:28:01 -05:00
Thomas Haller
bc092bcf44 core: announce device removal even for udev events with no ifindex property
Actually, this case should no longer happen, but just to be sure:
when a udev remove event without ifindex comes, get the ifindex from
the cache and announce the device removal.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-17 10:56:57 +02:00
Dan Williams
473018d8b2 platform: detect non-mac80211 WiFi devices as WiFi (rh #1015598)
Before NMPlatform landed, the old NMManager code looked at either
DEVTYPE=wlan or asked the internal wifi utilities whether the
device was WiFi or not.  This got lost when moving to NMPlatform.

It turns out that only mac80211-based drivers set the DEVTYPE=wlan
flag in sysfs, while older WEXT, out-of-tree, and staging drivers
often do not (though they should).

To avoid breaking recognition of these crappy drivers that used
to work, re-add the wifi utils checks.
2013-10-16 12:35:37 -05:00
Jiří Klimeš
a6944e157b platform: fix getting "ifindex" for devices on 'remove' udev action
We have to get IFINDEX using g_udev_device_get_property() instead of
g_udev_device_get_sysfs_attr().

On removal the IFINDEX in sysfs may not be available - this didn't caused
problems because such an event was ignored. But sometimes the sysfs IFINDEX
in 'remove' action was present, but *wrong*. It contained IFINDEX of a newly
created device of the same name, and thus it triggered removal of the new
device instead of the old one.

Logs (grepped):
...
NetworkManager[30628]: <info> Auto-activating connection 'b1'.
NetworkManager[30628]: <debug> [1381930187.149545] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (328)
NetworkManager[30628]: <debug> [1381930187.937222] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'add' subsys 'net' device 'bb' (328)
NetworkManager[30628]: <debug> [1381930187.937662] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (328)
NetworkManager[30628]: <info> (bb): deactivating device (reason 'user-requested') [39]
NetworkManager[30628]: <debug> [1381930193.266097] [platform/nm-platform.c:397] nm_platform_link_delete(): link: deleting 'bb' (328)
NetworkManager[30628]: <debug> [1381930193.279324] [platform/nm-platform.c:1777] log_link(): signal: link removed: bb (328)
NetworkManager[30628]: <debug> [1381930193.348167] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'remove' subsys 'net' device 'bb' (unknown)
NetworkManager[30628]: <info> Auto-activating connection 'b1'.
NetworkManager[30628]: <debug> [1381930193.561106] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (330)
NetworkManager[30628]: <debug> [1381930194.217300] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'add' subsys 'net' device 'bb' (330)
NetworkManager[30628]: <debug> [1381930194.217548] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (330)
NetworkManager[30628]: <info> (bb): deactivating device (reason 'user-requested') [39]
NetworkManager[30628]: <debug> [1381930216.329118] [platform/nm-platform.c:397] nm_platform_link_delete(): link: deleting 'bb' (330)
NetworkManager[30628]: <debug> [1381930216.344442] [platform/nm-platform.c:1777] log_link(): signal: link removed: bb (330)
NetworkManager[30628]: <info> Auto-activating connection 'b1'.
NetworkManager[30628]: <debug> [1381930216.598636] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (332)

This line is bad:
NetworkManager[30628]: <debug> [1381930217.79182] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'remove' subsys 'net' device 'bb' (332)

NetworkManager[30628]: <debug> [1381930217.81009] [platform/nm-platform.c:1777] log_link(): signal: link removed: bb (332)
NetworkManager[30628]: <info> (bb): deactivating device (reason 'removed') [36]
NetworkManager[30628]: <debug> [1381930217.95192] [platform/nm-linux-platform.c:2568] handle_udev_event(): UDEV event: action 'add' subsys 'net' device 'bb' (332)
NetworkManager[30628]: <debug> [1381930217.95492] [platform/nm-platform.c:1777] log_link(): signal: link added: bb (332)
NetworkManager[30628]: <info> Auto-activating connection 'b1'.
...
2013-10-16 19:00:45 +02:00
Jiří Klimeš
8ecbe53f37 platform: log links in event_notification() in debug mode 2013-10-16 17:28:04 +02:00
Thomas Haller
1d0a26e19d core: print ifindex when logging UDEV event
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-10-15 19:45:42 +02:00
Dan Williams
024f7e10b2 trivial: fix uninitialized bytes in ethtool driver name lookup
If the interface doesn't have an ethtool driver name, then '.driver'
will never be touched and (*drvinfo.driver) will access uninitialized
bytes.
2013-09-25 13:51:03 -05:00
Dan Winship
5a39715f2d platform: fix InfiniBand partition handling
Fix infiniband_partition_add() to put the newly-created device into
the link_cache before returning. Fix link_is_software() to recognize
partition devices as software, so that link_get() is willing to return
them even before we get the udev info.
2013-09-24 11:54:34 -04:00
Dan Winship
d20ac49dc9 platform: fix spelling of "announceable" 2013-09-24 11:54:34 -04:00
Jiří Klimeš
2b72214e52 platform: fix a crash when nm_platform_sysctl_get() returns NULL (rh #1010522)
nm_platform_sysctl_get() can return NULL on an error (when file specified by
'path' argument doesn't exist, can't be opened, etc.)

https://bugzilla.redhat.com/show_bug.cgi?id=1010522
2013-09-23 18:28:36 +02:00
Jiří Klimeš
28530239fa platform: fix a memory leak on an error 2013-09-23 18:28:36 +02:00
Dan Winship
fd85ec45b9 platform: fix VLAN ingress/egress map setting 2013-09-12 18:34:23 -04:00
Dan Winship
a059309628 platform: recognize Open vSwitch interfaces as Generic devices (rh #1004356)
They look exactly like normal Ethernet interfaces, but they are managed
entirely by the Open vSwitch tools in software, so NM shouldn't (yet)
touch them.  Treat them instead as generic devices that only get touched
through direct user requests.
2013-09-06 19:39:11 -05:00
Pavel Šimerda
8d10e8bbe6 platform: ignore multi-hop routes
https://bugzilla.gnome.org/show_bug.cgi?id=705606
2013-08-12 17:35:22 +02:00
Dan Williams
37efd55699 platform: fix some bogus compiler warnings
platform/nm-linux-platform.c: In function 'delete_object':
platform/nm-linux-platform.c:102:13: error: 'cached_object' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  if (object && *object) {
             ^
platform/nm-linux-platform.c:1019:35: note: 'cached_object' was declared here

Except that it won't be, but I guess the gsystem auto* stuff is
confusing the compiler.
2013-08-07 15:47:47 -05:00
Dan Williams
b637c6a101 platform: don't assert on multi-hop routes (rh #989022)
It only matters that there's at least one next hop, not that there
is only one.
2013-08-07 14:47:22 -05:00
Dan Williams
ead39cb421 core,platform: don't completely ignore WWAN pseudo-ethernet interfaces
The platform still needs to know about them, becuase the ethernet interface
is what gets configured and used for IP.  But the Manager doens't want to
create a full new NMDevice for them, because there's already a Modem
device that "owns" that WWAN interface.  So keep WWAN devices visible
to the platform, but just make the manager ignore them when creating
NMDevices.

Also, many WWAN pseduo-ethernet drivers set NOARP becuase they really
are point-to-point and thus ARP is pointless, and in this case, they
won't have any arptype of ARPHRD_ETHER.  So determining the NMLinkType
from udev must take that into account.
2013-08-07 14:39:00 -05:00
Dan Williams
eba7484367 core: don't wait for udev to find created software devices
NM knows software devices it creates exist immediately, and it knows
it can use them immediately instead of waiting for udev to find them.
Ideally we'd wait for udev to find all devices, to allow tags and
other rules to run, but when creating software devices they must
currently be available for use immediately.

Bridges and bonds are required to be IFF_UP before they can be
activated (see their is_available() implementation).  But during
activation code paths, specifically in nm_manager_activate_connection(),
the interface is created and immediately checked for availability
to activate (since the creation was a result of the user requesting
device activation).  That availability check fails, because the
device is not visible outside NMPlatform (because it hasn't been
found by udev yet, because we haven't gotten back to the event
loop) and thus nm_platform_link_is_up() fails, failing the
availability check.  Thus the device activation ends in error.

What should really happen is that device activation shouldn't
be synchronous; a new NMActiveConnection should be created for
any activation request, which can then wait until all the
resources it needs for activation are available (device found,
master devices created, etc).  That's going to take more work
though.
2013-08-06 16:36:51 -05:00
Dan Williams
7570832b20 platform: simplify getting routes and ignoring the default route
Most places except the tests don't want the default route when asking
the platform for all routes, so make that simpler by just adding a
parameter for including the default route or not.
2013-08-03 00:14:19 -05:00
Pavel Šimerda
356cad68fa platform: add reason attribute to all signals 2013-08-02 23:12:21 +02:00
Pavel Šimerda
c1bbacae4c platform: re-check potentially removed objects 2013-08-02 23:04:46 +02:00
Pavel Šimerda
d85ae74388 platform: rework the object refresh code 2013-08-02 22:17:07 +02:00
Pavel Šimerda
900b4b15c5 platform: don't check for route existence (fixup)
This was part of a patch that resulted in commit 5dd15bd but
unfortunately also part of a reverted patch 42b4323. We need
to add it back.
2013-08-02 22:17:07 +02:00