Commit Graph

13873 Commits

Author SHA1 Message Date
Jiří Klimeš
8dfafac17c clients: add vpn_type member to secret structure in secret agent
It is useful to know what VPN type the secret belongs to.
2015-12-12 17:37:30 +01:00
Jiří Klimeš
6dd1e2673e clients: move vpn_get_secret_names() to nm-vpn-helpers
It should eventually move into libnm and ideally the data be obtained from VPN
plugins.

(No functional change, only moving the function).
2015-12-12 17:37:30 +01:00
Jiří Klimeš
de86c23fbe clients: enable VPN secrets for nmtui/nmcli secret agent (rh #975185)
It allows nmcli and nmtui to ask for VPN passwords and thus successfully
activate VPN connections.

https://bugzilla.redhat.com/show_bug.cgi?id=975185
2015-12-12 17:37:30 +01:00
Thomas Haller
77cf564b45 platform/tests: add --no-persist option to monitor 2015-12-12 12:59:18 +01:00
Thomas Haller
e934bfb5d8 tests: don't assert for initialized tests in g_test_assert_expected_messages()
We call _nmtst_exit() atexit(), which in turn calls g_test_assert_expected_messages().
We must not assert there against initialized tests.

  $ ./src/platform/tests/monitor -h
  Usage:
    ./src/platform/tests/monitor [OPTION...]
  **
  NetworkManager:ERROR:monitor.c:11:_nmtst_exit: assertion failed: (nmtst_initialized ())
  Aborted (core dumped)
2015-12-12 12:57:18 +01:00
Thomas Haller
8a38b4dd13 platform: inline setup_socket() function
Constructing the sockets is already quite simple, yet distinct.
Later this distinction will become bigger, so unwrap setup_socket().
2015-12-12 12:34:29 +01:00
Thomas Haller
461cf0c571 platform: factor out completing and sending netlink message 2015-12-12 12:34:29 +01:00
Thomas Haller
7dce1f3b38 platform/tests: refactor nmtstp_link_*_add() functions
Let them return the platform object, and have the input argument
as const.
2015-12-11 17:55:09 +01:00
Thomas Haller
feab1ff655 platform/tests: add nmtstp_link_get_typed() 2015-12-11 17:55:09 +01:00
Lubomir Rintel
9ae0227591 device: don't tell the device to unconfigure if it's gone already
After the device is unrealized a lot of its properites are reset. Notably, it
doesn't have an ifindex anymore so there's nothing to unconfigure really. This
makes at least NMDeviceBond unhappy:

  (bond device with a slave is removed externally)

  NetworkManager[21022]: <info>  (bond0): device state change: activated -> unmanaged (reason 'unmanaged') [100 10 3]
  NetworkManager[21022]: nm_platform_link_release: assertion 'master > 0' failed

  Program received signal SIGTRAP, Trace/breakpoint trap.
  g_logv (log_domain=0x5555557592b1 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd370) at gmessages.c:1046
  1046              g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
  (gdb) bt
  #0  0x00007ffff4ec88c3 in g_logv (log_domain=0x5555557592b1 "NetworkManager", log_level=G_LOG_LEVEL_CRITICAL, format=<optimized out>, args=args@entry=0x7fffffffd370) at gmessages.c:1046
  #1  0x00007ffff4ec8a3f in g_log (log_domain=log_domain@entry=0x5555557592b1 "NetworkManager", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0x7ffff4f3673d "%s: assertion '%s' failed")
      at gmessages.c:1079
  #2  0x00007ffff4ec8a79 in g_return_if_fail_warning (log_domain=log_domain@entry=0x5555557592b1 "NetworkManager", pretty_function=pretty_function@entry=0x55555575ea50 <__FUNCTION__.33801> "nm_platform_link_relea8
  #3  0x000055555560559a in nm_platform_link_release (self=0x555555a27bb0 [NMLinuxPlatform], master=master@entry=0, slave=slave@entry=3) at platform/nm-platform.c:1326
  #4  0x00005555555b506e in release_slave (device=<optimized out>, slave=0x555555b6d770 [NMDeviceEthernet], configure=<optimized out>) at devices/nm-device-bond.c:423
  #5  0x00005555555dab7b in nm_device_master_release_one_slave (self=self@entry=0x555555bf0cc0 [NMDeviceBond], slave=0x555555b6d770 [NMDeviceEthernet], configure=configure@entry=1, reason=reason@entry=
      NM_DEVICE_STATE_REASON_NOW_UNMANAGED) at devices/nm-device.c:1137
  #6  0x00005555555dadb6 in nm_device_master_release_slaves (self=self@entry=0x555555bf0cc0 [NMDeviceBond]) at devices/nm-device.c:2344
  #7  0x00005555555dd12f in nm_device_cleanup (self=self@entry=0x555555bf0cc0 [NMDeviceBond], reason=reason@entry=NM_DEVICE_STATE_REASON_NOW_UNMANAGED, cleanup_type=cleanup_type@entry=CLEANUP_TYPE_DECONFIGURE)
      at devices/nm-device.c:9133
  #8  0x00005555555de3ea in _set_state_full (self=self@entry=0x555555bf0cc0 [NMDeviceBond], state=state@entry=NM_DEVICE_STATE_UNMANAGED, reason=reason@entry=
      NM_DEVICE_STATE_REASON_NOW_UNMANAGED, quitting=quitting@entry=0) at devices/nm-device.c:9510
  #9  0x00005555555dedb7 in nm_device_state_changed (self=self@entry=0x555555bf0cc0 [NMDeviceBond], state=state@entry=NM_DEVICE_STATE_UNMANAGED, reason=reason@entry=NM_DEVICE_STATE_REASON_NOW_UNMANAGED)
      at devices/nm-device.c:9769
  #10 0x00005555555e11b4 in nm_device_unrealize (self=self@entry=0x555555bf0cc0 [NMDeviceBond], remove_resources=remove_resources@entry=0, error=error@entry=0x7fffffffd788) at devices/nm-device.c:2062
  #11 0x000055555565c9c5 in _platform_link_cb_idle (data=0x555555c6e2b0) at nm-manager.c:2055
  #12 0x00007ffff4ec179a in g_main_context_dispatch (context=0x555555a226c0) at gmain.c:3109
  #13 0x00007ffff4ec179a in g_main_context_dispatch (context=context@entry=0x555555a226c0) at gmain.c:3708
  #14 0x00007ffff4ec1ae8 in g_main_context_iterate (context=0x555555a226c0, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3779
  #15 0x00007ffff4ec1dba in g_main_loop_run (loop=0x555555a22780) at gmain.c:3973
  #16 0x00005555555b3e5f in main (argc=1, argv=0x7fffffffdb18) at main.c:488
2015-12-11 17:23:51 +01:00
Lubomir Rintel
96c01f55bc manager: clean up the system_create_virtual_device() error handling
Do the reporting in system_create_virtual_device() only. None of the callers
checked for errors and some of the callees did issue a warning despite also
passing back a GError.

Also, drop the return value. It didn't make much sense and was not used anyway.
2015-12-11 17:03:54 +01:00
Lubomir Rintel
71a684159f manager: if there's an unrealized device that matches new connection, realize it
Fixes this:

  nmcli c add type bridge    # Creates and realizes the device, autoconnects connection
  nmcli c del bridge         # Device unrealizes
  nmcli c add type bridge    # The new connection does not autoconnect, since the
                             # device stays unrealized
2015-12-11 17:03:54 +01:00
Thomas Haller
95d67c683d platform/tests: ignore failure of iproute2 command for adding vxlan interface
Older version of iproute2 fail to add the vxlan (e.g. on Ubuntu 12.04)

  Running command: ip link add nm-test-device type vxlan id 42 dev nm-test-parent local 23.1.2.164 group 239.1.2.134 ttl 0 tos 00 dstport 4789 srcport 0 0 ageing 1245
  Garbage instead of arguments "id ...". Try "ip link help".

Fallback using only platform.
2015-12-11 16:45:31 +01:00
Thomas Haller
c2602469c3 platform/tests: workaround broken vxlan platform tests on older kernel
Strangely on Ubuntu 12.04, when not setting the port range for a vxlan
device, kernel chooses

  5: nm-test-device: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN mode DEFAULT group default
      link/ether 72:09:79:62:9c:45 brd ff:ff:ff:ff:ff:ff promiscuity 0
      vxlan id 42 group 239.1.2.134 local 23.1.2.164 dev nm-test-parent srcport 32768 61000 dstport 4789 ageing 1245
2015-12-11 16:43:41 +01:00
Thomas Haller
9ce3733d0c platform: add const to input arguments to link-add functions
Some line-breaks and adding "const".
2015-12-11 14:14:13 +01:00
Lubomir Rintel
785c263c18 device: do the LL check when the device is disconnected
An IPv6 address might have been added externally and the device is yet to
traverse to a connected state.

On the other hand, the externally added devices still traverse through
DISCONNECTED state and we don't want to attempt the LL addition there. Let's
check if the link still exists instead.
2015-12-11 13:24:07 +01:00
Lubomir Rintel
7873b1761d build: bump soup requirement to 2.40
The dns-manager uses some newer API.
2015-12-10 19:17:56 +01:00
Lubomir Rintel
15f1cd09d9 build: use soup 2.32
We already use 2.32 API and also use API that was replaced with new one after
2.42 and deprecated in 2.53.
2015-12-10 18:53:49 +01:00
Lubomir Rintel
2b0cacef2d vpn-connection: fix getting of MTU from the VPN config
This time we noticed before the angry mob.
Thank you, test suite! :)
2015-12-10 17:57:11 +01:00
Thomas Haller
d2fab2df54 platform: EAGAIN is equal to EWOULDBLOCK
The macro EWOULDBLOCK is another name for EAGAIN; they are always the
  same in the GNU C Library.

  https://www.gnu.org/savannah-checkouts/gnu/libc/manual/html_node/Error-Codes.html

Otherwise, we would need a workaround for EWOULDBLOCK too, because
libnl maps that to NLE_FAILURE. So we would have to detect EAGAIN
as (nle == -NLE_FAILURE && errno == EWOULDBLOCK).
2015-12-10 17:53:04 +01:00
Thomas Haller
7235283a9a platform: merge branch 'th/platform-fixes-and-tests' 2015-12-10 17:14:04 +01:00
Thomas Haller
4c5ca7ddcf platform/tests: add test adding many dummy devices 2015-12-10 17:13:49 +01:00
Thomas Haller
acbb6e195d platform/tests: use nmtstp_link_del() function 2015-12-10 17:13:49 +01:00
Thomas Haller
7183676de1 platform/tests: add nmtstp_link_del() helper 2015-12-10 17:13:49 +01:00
Thomas Haller
7a758ae7a3 platform/tests: add nmtstp_link_get() helper 2015-12-10 17:13:49 +01:00
Thomas Haller
06eaf29109 platform/tests: add nmtstp_link_dummy_add() helper 2015-12-10 17:13:49 +01:00
Thomas Haller
d7518d111f platform/tests: log timestamp in test messages 2015-12-10 17:13:49 +01:00
Thomas Haller
eeb7d20ee0 platform: fix memleak in _nl_sock_flush_data()
Fixes: 9a16ce0876
2015-12-10 17:13:48 +01:00
Thomas Haller
10b684b827 platform: fix event_handler_read_netlink_one() wrongly returning with nothing to read
When the errno was accidentally set to EAGAIN or EWOULDBLOCK,
we would only read one single message and return that there is
nothing to read.

This means, if there were more then one messages ready to read,
we would only read the first one and return to the main-loop
(which then again calls back to platform as more data is ready
to be read).
2015-12-10 17:13:48 +01:00
Lubomir Rintel
1057e30dc8 vpn-connection: notify the object of banner change
Otherwise the D-Bus clients won't notice the banner has been set.
2015-12-10 16:12:02 +01:00
Thomas Haller
9bc7b295a4 platform: merge branch 'th/platform-api-cleanup-bgo759261' into master
https://bugzilla.gnome.org/show_bug.cgi?id=759261
2015-12-10 14:36:45 +01:00
Thomas Haller
76521816a5 platform/trivial: remove obsolete code comment
The explainations no longer hold for the most part. Documentation
that is not directly the code is bound the expire.

The code is the best documentation!! :)
2015-12-10 14:33:50 +01:00
Thomas Haller
9eea5b63a2 platform: remove g_return() checks for platform klass implementation
With g_return() we try to catch wrong invocations of a function
or passing invalid arguments.

Having ~forgot~ to overwrite a virtual function is such a serious
and fundamental issue, that checking for it at runtime is wasteful
and unnessesary.

If we ever hit such a situation, just crash.
2015-12-10 14:33:50 +01:00
Thomas Haller
1a7b19ea6a platform: move reading sysctl-options for master/slave to NMPlatform
These functions are only helpers for accessing sysctl and independent
from NMLinuxPlatform. Move their implementation to the base class.
2015-12-10 14:33:49 +01:00
Thomas Haller
9166ee6958 platform/trivial: rename sysctl slave/master option functions
These function purely operate on sysctl by reading/writing to file.
Rename them to reflect that they are not related to netlink parts
of platform.
2015-12-10 14:33:49 +01:00
Thomas Haller
eef388990f platform/trivial: rename link related functions
Link related functions should have a "nm_platform_link" prefix. Rename.

Naming is a subjective matter and one might argue that omitting
the "link" part from the name is shorter and even preferred.

However, I think functions related to links should have a common
prefix as the underlyings are strongly related.
2015-12-10 14:33:49 +01:00
Thomas Haller
6a7730241b trival: fix whitespace 2015-12-10 14:33:49 +01:00
Thomas Haller
a4de9187ff platform: return pointer to NMPlatformLink object for add functions
Let the link-add functions return the internal pointer to the platform
link object. Similar to link-get, which doesn't copy the link either.

Also adjust the sole users of the add-functions (create-and-realize)
to take the pointer.

Eventually we still copy the returned data, because accessing platform can
invalidate the returned pointer. Thus we don't actually safe any copying
by this (at least every use of the function currently leads to the data
being copied).
Still change it, because I think the API of NMPlatform should look like that.
2015-12-10 14:33:49 +01:00
Thomas Haller
2a14a28fe0 device: pass const NMPlatformLink instance to setup_start()/setup_finish()
NMPlatformLink is a plain struct (not a GObject, for which we usually
don't use const). We certainly don't want the functions to modify the
passed-in data.
2015-12-09 17:05:45 +01:00
Thomas Haller
590b9a830d device: accept UNKNOWN device types during create_and_realize()
There are the link-types NONE and UNKNOWN. NONE is a linktype that is never
returned by platform, but UNKNOWN is very much a valid (albeit unspecified)
type.

Effectively, create_and_realized() should create a link of a known type,
thus it should never return an UNKNOWN link type at this point. Still
change it because it feels more correct.
2015-12-09 16:57:39 +01:00
Beniamino Galvani
efd5515f96 merge: vxlan devices creation support
https://bugzilla.gnome.org/show_bug.cgi?id=756963
2015-12-09 16:37:05 +01:00
Beniamino Galvani
69f3489954 platform/tests: use nmtst_inet{4,6}_from_string() helpers 2015-12-09 16:36:46 +01:00
Beniamino Galvani
228d2dab82 libnm-glib: consider unknown devices as generic ones
After commit 8ca6e412c1, libnm-glib is
able to instantiate unknown devices as dummy objects without creating
a D-Bus proxy for them. Enable this behavior for every new unknown
device type.
2015-12-09 16:36:46 +01:00
Beniamino Galvani
dc0676330b platform/tests: create vxlan links also using platform code 2015-12-09 16:36:46 +01:00
Beniamino Galvani
d6a0b2c28f libnm: add NMDeviceVxlan 2015-12-09 16:36:46 +01:00
Beniamino Galvani
a448854b44 device/vxlan: support device creation 2015-12-09 16:36:46 +01:00
Beniamino Galvani
01e95c8c95 platform: add vxlan support
Add a new method to the platform code to create vxlan devices.
2015-12-09 16:36:46 +01:00
Beniamino Galvani
7da440b798 cli: add vxlan support 2015-12-09 16:36:46 +01:00
Beniamino Galvani
95dfd99afc libnm-core: add NMSettingVxlan
Add a new NMSettingVxlan which describes properties of VXLAN
connections.
2015-12-09 16:36:46 +01:00
Lubomir Rintel
a5c42eeb45 device: don't try to match the spec against a device with no hwaddr
It could be an unrealized device.
2015-12-09 15:55:12 +01:00