Commit Graph

7207 Commits

Author SHA1 Message Date
Jiří Klimeš
accaedbc37 ifcfg-rh: fix handling VLAN connections as bond/bridge slaves (bgo #737377)
MASTER=something denotes a bond slave. Thus we cannot write it for VLAN
setting. When reading, set the correct 'bond' slave type, not 'vlan'.

https://bugzilla.gnome.org/show_bug.cgi?id=737377
2014-09-26 10:11:52 +02:00
Dan Williams
6ae3c1bb82 trivial: quiet error setting userspace IPv6LL if link no longer exists 2014-09-25 16:05:31 -05:00
Thomas Haller
4d675ce0fc platform: fix parsing vxlan netlink message for older kernel
vxlan_info_data_parser() must take care of missing netlink attributes.
Otherwise, older kernels will crash NM.

Also, workaround compilation against old kernel headers which are
missing 'struct ifla_vxlan_port_range'. We do this by defining our
own 'struct nm_ifla_vxlan_port_range' version.

Reported-by: Javier Jardón <jjardon@gnome.org>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-25 17:45:53 +02:00
Thomas Haller
54f6666c66 core: recheck_assume_connection() do nothing if the device is not disconnected
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:45:21 +02:00
Thomas Haller
c9ece92a48 core: clean up nm-generated-assumed connections when assumption fails or connection disconnects
https://bugzilla.gnome.org/show_bug.cgi?id=731937

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:45:21 +02:00
Thomas Haller
ae680efa15 bluez: simplify cleanup of generated PAN connection
For PAN devices we create an unsaved connection if no matching
connection exists. After the device gets removed, we want to clean
up that connection, unless it was modified/saved in the meantime.

Before this was accomplished by creating a clone of the original
connection. When deciding whether the temporary connection was
modified, we would compare the current state with the original.

This can now be simplified, because we have the nm-generated flag
that gets cleared whenever the user modifies or saves the connection.
This code is also more robust, because the previous implementation
was a hack, but could not reliably detect whether the connection
was modified by the user.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:45:21 +02:00
Thomas Haller
6546e9d1ae core: use "nm-generated-assumed" flag instead of "nm-generated" for assumed connections
At a few places, we checked for nm_device_uses_generated_connection()
whether to touch the device or not. nm_device_uses_generated_connection() used
to look at the "nm-generated" property of the NMSettingsConnection.

We are about to change the meaning of "nm-generated", which will mean
"any connection generated by NM, for whatever reason".

Instead now use the new "nm-generated-assumed" connection flag that has
the meaning "nm-generated" used to have.
So rename nm_device_uses_generated_connection() to nm_device_uses_generated_assumed_connection()
which looks at the "nm-generated-assumed" flag instead.

Also, be more strict in nm_device_uses_generated_assumed_connection() to require
both an "nm-generated-assumed" connection *and* an active connection that is
nm_active_connection_get_assumed().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:32:11 +02:00
Thomas Haller
87739dbdf4 core: add "nm-generated-assumed" flag to NMSettingsConnection
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED_ASSUMED is a special kind of
NM_SETTINGS_CONNECTION_FLAGS_NM_GENERATED, that was generated for
connection assumption.

At the moment, the flag is used identical to NM_GENERATED. Later,
NM_GENERATED will get a slightly different meaning.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:32:11 +02:00
Thomas Haller
e5c719c0c0 settings: implement 'unsaved' and 'nm-generated' as #NMSettingsConnectionFlags
Before, NMSettingsConnection had two internal properties 'unsaved' and
'nm-generated'. Now, implement these properties as #NMSettingsConnectionFlags.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:32:11 +02:00
Thomas Haller
ec6d8385d3 settings: add NMSettingsConnection:flags
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:32:11 +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
Thomas Haller
3744544920 core: log when emitting RECHECK_ASSUME signal
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:12:45 +02:00
Thomas Haller
bda076bb3c core: add macros NM_FLAGS_HAS(), NM_FLAGS_ANY() and NM_FLAGS_ALL()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-24 16:12:45 +02:00
Lubomir Rintel
efd09845c4 platform: increase NL buffer for systems with lots of interfaces (rh #1141256)
Seems like 128k is not enough for systems with many interfaces. This adds 4k
per device, while keeping the 128k minimum. Therefore this change only
affects systems with more than 32 interfaces.

https://bugzilla.redhat.com/show_bug.cgi?id=1141256
2014-09-22 11:17:12 +02:00
Jiří Klimeš
7966b6c05f ifcfg-rh: fix typo in function name and enhance testcase
The testcase now includes an invalid value too.

Added by commit  8657b4229c.
2014-09-19 21:19:18 +02:00
Dan Williams
24ab568826 core: fix stray 'break' in switch
From 82222d389 "core: move carrier handling to NMDevice"
2014-09-19 12:07:00 -05:00
Dan Williams
e4f218875d core: fix 'tun' device owner/group property getters
The properties are int64, but get_property() was was using
g_value_set_uint().
2014-09-19 12:07:00 -05:00
Dan Winship
6793a32a8c libnm: port to GDBus
Port libnm-core/libnm to GDBus.

The NetworkManager daemon continues to use dbus-glib; the
previously-added connection hash/variant conversion methods are now
moved to NetworkManagerUtils (along with a few other utilities that
are now only needed by the daemon code).
2014-09-18 11:51:09 -04:00
Dan Winship
acf86f68b3 libnm-core: change connection hash tables to variants in API
In preparation for porting to GDBus, make nm_connection_to_dbus(),
etc, represent connections as GVariants of type 'a{sa{sv}}' rather
than as GHashTables-of-GHashTables-of-GValues.

This means we're constantly converting back and forth internally, but
this is just a stepping stone on the way to the full GDBus port, and
all of that code will go away again later.
2014-09-18 11:51:09 -04:00
Dan Winship
ad8b13091b libnm-core: fix up connection deserialize/copy/replace semantics
libnm-util's connection deserializing/copying/replacing functions have
odd semantics where sometimes they both modify a connection AND return
an error. libnm-core tried to improve things by guaranteeing that the
connection would not be modified if the new settings were invalid, but
this ended up breaking a bunch of places that needed to be able to
work with invalid connections. So re-fix the functions by reverting
back to the old semantics, but having return values that clearly
distinguish whether the connection was modified or not.

For comparison:

  - nm_connection_new_from_hash() / nm_simple_connection_new_from_dbus():

      - libnm-util: returns a valid connection or NULL.

      - OLD libnm-core: returned a valid connection or NULL.

      - NEW libnm-core: returns a valid connection or NULL.

  - nm_connection_duplicate() / nm_simple_connection_new_clone():

      - libnm-util: always succeeds, whether or not the connection is
        valid.

      - OLD libnm-core: returned a valid connection or NULL

      - NEW libnm-core: always succeeds, whether or not the connection
        is valid.

    - nm_connection_replace_settings_from_connection():

      - libnm-util: always replaces the settings, but returns FALSE if
        the connection is now invalid.

      - OLD libnm-core: either replaced the settings and returned TRUE
        (if the settings were valid), or else left the connection
        unchanged and returned FALSE (if not).

      - NEW libnm-core: always replaces the settings, and has no
        return value. (The modified connection is valid if and only if
        the replaced-from connection was valid; just like with the
        libnm-util version.)

    - nm_connection_replace_settings():

      - libnm-util: returns TRUE if the new settings are valid, or
        FALSE if either (a) the new settings could not be deserialized
        and the connection is unchanged, or (b) the new settings were
        deserialized, and the connection was updated, but is now not
        valid.

      - OLD libnm-core: either replaced the settings and returned TRUE
        (if the settings were valid), or else left the connection
        unchanged and returned FALSE (if not).

      - NEW libnm-core: returns TRUE if the connection was updated
        (whether or not it is valid), or FALSE if the new settings
        could not be deserialized and the connection is unchanged.
2014-09-17 08:21:21 -04:00
Lubomir Rintel
b05c8dbda5 core: fix casting of factory type (bgo #736780)
UINT is just 32bit, truncating the GType on 64-bit platforms. We do already use
cast to SIZE, which is as wide as a pointer, when we need a GType in another
place (nmtui); let's do it here as well.

Broken by [0bc1b5138] core: add support for internal device factories

https://bugzilla.gnome.org/show_bug.cgi?id=736780
2014-09-17 11:19:41 +02:00
Christian Hesse
c668297257 core: only set IPv6 hop_limit for values greater than zero
A "Cur Hop Limit" field value of 0 in a router advertisement means
"unspecified by this router" and should not be set in the kernel.
2014-09-15 12:10:24 -05:00
Jiří Klimeš
e47235b38d dhcp: log DHCP client exit status better 2014-09-12 12:51:18 +02:00
Jiří Klimeš
b27669612e dhcp: fix dhclient abnormal exit due to SIGPIPE (bgo #735962)
DHCP client may be killed by SIGPIPE when attempting to write to a broken pipe.
This can be observed, for example, when journald is restarted.

Fix that by redirecting both stdout and stderr to /dev/null. The client logs
into syslog anyway. When NetworkManager is run with '--debug' we duplicate
syslog to stderr, so the messages goes to terminal as well.

Testcase:
- start a NetworkManager service by systemd
- activate an DHCP ethernet connection
- sudo systemctl restart systemd-journald.service
- reactive the ethernet connection (nmcli con up <my-eth>)
- DHCP client is killed by SIGPIPE right after its startup:
    <info> (enp0s25): DHCPv4 client pid 13959 exited with status -1
    <warn> DHCP client died abnormally

Another possible fix would be ignoring SIGPIPE in the DHCP client as it is not
useful in most cases. E.g. systemd ignores SIGPIPE for its services, by
default:
http://cgit.freedesktop.org/systemd/systemd/commit/?id=353e12c2f4a9e96a47eb80b80d2ffb7bc1d44a1b

https://bugzilla.gnome.org/show_bug.cgi?id=735962
2014-09-12 12:49:16 +02:00
Dan Williams
3deb3ff683 tun: port to internal device factory 2014-09-11 12:50:17 -05:00
Dan Williams
11eb99e9a7 gre: port to internal device factory 2014-09-11 12:50:16 -05:00
Dan Williams
51aa432283 vxlan: port to internal device factory 2014-09-11 12:50:16 -05:00
Dan Williams
1cf7b6d3dd macvlan: port to internal device factory 2014-09-11 12:50:16 -05:00
Dan Williams
15db28e74b vlan: port to internal device factory 2014-09-11 12:50:16 -05:00
Dan Williams
1553b3e223 bond: port to internal device factory 2014-09-11 12:50:16 -05:00
Dan Williams
097eb3a6af bridge: port to internal device factory 2014-09-11 12:50:16 -05:00
Dan Williams
6d190f92d5 infiniband: port to internal device factory 2014-09-11 12:50:16 -05:00
Dan Williams
2a55c450bd ethernet: port to internal device factory 2014-09-11 12:50:16 -05:00
Dan Williams
388e53b180 veth: port to internal device factory
We must port NMDeviceVeth before NMDeviceEthernet because veth is
an ethernet subclass and uses symbols from nm-device-ethernet.c.
2014-09-11 12:50:16 -05:00
Dan Williams
0bc1b5138a core: add support for internal device factories 2014-09-11 12:50:15 -05:00
Dan Williams
38b076de8f build: ensure device source file constructors can be linked and called
gcc's linker does not add constructors from object files to the main
executable if they are built into a convenience library and then the
library is linked to the executable, unless something outside of the
object file with the constructor references a symbol from the object
file.

http://osdir.com/ml/libtool-gnu/2011-06/msg00003.html

"Yes, when convenience libraries are used to create a shared library, all the
objects are included in the output, when the output is an application they are
used like a normal archive library.

Either use them to create a shared library or, if creating an application,
don't use them, use the objects instead."

Further patches will remove all references to the NMDevice subclasses
from nm-manager.c, and have each NMDevice subclass register itself
with a factory through a constructor.  But due to the above issue,
we need to somehow ensure the constructor in each nm-device-*.c file
gets added to the executable.  This is accomplished by explicitly
linking each NMDevice subclass' object file into the main executable.

(Note that we cannot use -Wl,-whole-archive here because libtool only
supports this option for linking a convenience library to a shared
library, but not to an executable, and will actively prevent using
-whole-archive in LDFLAGS)
2014-09-11 12:48:17 -05:00
Dan Williams
706b9d2056 core: pass parent to device factories when creating devices for connections
We'll use it later for InfiniBand and VLAN.
2014-09-11 12:47:23 -05:00
Dan Williams
560fe126b5 core: split out device factory registration function
We'll soon use it for both shared-library-based plugins, and internal
device factories.
2014-09-11 12:47:23 -05:00
Dan Williams
00fe31f5cd core: move device factory type function into factory object
In preparation for internal device types exposing factories too, it's
easier to have the device type that the factory creates be returned
by the factory object instead of the plugin, because internal device
types don't have plugins.

This requires that we create the factory objects earlier, which
further requires that any operations that trigger signals must be
moved out of each factory's construction path to a separate start()
function.
2014-09-11 12:47:23 -05:00
Dan Williams
beb18050b5 settings: create default wired connection from NMDeviceEthernet
Instead of creating it in NMSettings, where we must use
NM_IS_DEVICE_ETHERNET() (not NM_DEVICE_TYPE_ETHERNET because various generic
devices masquerade as NM_DEVICE_TYPE_ETHERNET too), push knowledge
of which device types create default wired connections into the device
types themselves.  This solves a problem with testcases where
libNetworkManager.a (which testcases link to) requires the symbol
nm_type_device_ethernet().
2014-09-11 12:47:07 -05:00
Dan Williams
56e2915536 trivial: spacing and code cleanups in nm-manager.h
Remove some dead code and a redundant function.
2014-09-11 12:40:08 -05:00
Dan Williams
005cb2fc35 core: search for arping binary too (bgo #734131) 2014-09-11 12:11:57 -05:00
Dan Williams
544fc82aa7 core: consolidate helper progam searching (bgo #734131)
Instead of having basically the same code in a bunch of different
place to find helper programs, just have one place do it.  Yes, this
does mean that the same sequence of paths is searched for all helpers
(so for example, dnsmasq will no longer be found first in /usr/local)
but I think consistency is the better option here.

https://bugzilla.gnome.org/show_bug.cgi?id=734131
2014-09-11 12:11:56 -05:00
Jiří Klimeš
8657b4229c ifcfg-rh: fix reading HWADDR_BLACKLIST
Adding GSList to the property may crash NetworkManager. Also check MAC
addresses and filter out the invalid ones.

(broken by commit 6a4127cfa0)
2014-09-10 15:00:49 +02:00
Jiří Klimeš
5d982b3810 utils: use gssize (signed) 'len' parameter in nm_ethernet_address_is_valid()
Fix copyright statement too.
2014-09-05 11:11:01 +02:00
Jiří Klimeš
01d0d37615 dhcp: fix g_error_free() called with a bad argument 2014-09-05 10:25:03 +02:00
Dan Winship
89228569f8 ppp-manager: port nm-pppd-plugin from dbus-glib to gdbus 2014-09-04 18:19:21 -04:00
Dan Winship
66c238e7b2 dhcp-manager: port nm-dhcp-helper from dbus-glib to gdbus 2014-09-04 18:19:21 -04:00