Commit Graph

748 Commits

Author SHA1 Message Date
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
Pavel Šimerda
2167e4376b Revert "platform: work around missing kernel netlink notifications of default route changes"
This reverts commit 42b4323902.
2013-08-02 22:17:06 +02:00
Dan Williams
42b4323902 platform: work around missing kernel netlink notifications of default route changes
It appears the kernel does not send notifications via netlink if the
default route is removed in some cases.  This causes the platform
route cache to become stale, and thus when the default route is
reset by NM the platform thinks the route already exists, and does
not add it.  But the route doesn't exist, becuase the kernel silently
removed it without telling anyone.

Fix that with a big hammer by flushing/refilling the route cache when
devices are deactivated (deletion of their addresses causes the default
route to be removed by the kernel) and when the default route is
updated by NM itself.

Pavel: if we find a more granular method, we should probably revert
this as the cache refill can be expensive.
2013-07-31 12:14:52 -05:00
Pavel Šimerda
b502b6cd58 platform: ignore kernel-generated routes
This is necessary to avoid tinkering with IPv4 prefix routes
automatically inserted by the kernel for each IPv4 address.

https://bugzilla.gnome.org/show_bug.cgi?id=705102
2013-07-30 11:40:19 +02:00
Pavel Šimerda
68c3e1153c platform: update all address lifetimes
The nm_platform_ip[46]_address_sync() functions no longer use
nm_platform_ip[46]_address_exists() to avoid adding already
existing addresses. That means nm_platform_ip[46]_address_add()
is now called for *all* commited addresses and the lifetimes
are thus always updated.

Because of that, nm_platform_ip[46]_address_add() had to be modified to
accept existing addresses and update their lifetimes when appropriate.

https://bugzilla.gnome.org/show_bug.cgi?id=705102
2013-07-30 11:40:19 +02:00
Pavel Šimerda
afc3c2617a platform: cosmetic changes 2013-07-27 00:47:04 +02:00
Pavel Šimerda
2ef7110f37 platform: fix memory leaks 2013-07-27 00:47:04 +02:00
Pavel Šimerda
f121995fad platform: add support for address lifetimes 2013-07-26 22:45:15 +02:00
Pavel Šimerda
aca9b9b570 platform: fix udev/kernel interface race conditions
A network interface is only exposed if it's recognized by both netlink
cache and udev.
2013-07-26 21:14:08 +02:00
Pavel Šimerda
6d688f9c87 trivial: simplify a condition 2013-07-26 18:16:18 +02:00
Pavel Šimerda
7cc7a38288 platform: handle address/route deletion upon link actions (bgo #704770)
When link goes !IFF_UP by internal or external action, we need to delete
related routes from the route cache. The same is done for both addresses
and routes upon link removal.

https://bugzilla.gnome.org/show_bug.cgi?id=704770
2013-07-24 09:49:03 -05:00
Pavel Šimerda
38a57b3497 platform: listen for route changes properly 2013-07-24 10:05:41 +02:00
Pavel Šimerda
f625d6a269 platform: handle netlink failures properly 2013-06-21 04:03:41 +02:00