Commit graph

21253 commits

Author SHA1 Message Date
Beniamino Galvani
81a565ebe5 build: autodetect ebpf support 2018-09-19 17:23:11 +02:00
Beniamino Galvani
c7c3acf280 merge: branch 'bg/meson-fixes'
https://github.com/NetworkManager/NetworkManager/pull/204
2018-09-19 16:03:50 +02:00
Beniamino Galvani
470c5c0a82 initrd: enable meson builds 2018-09-19 16:03:32 +02:00
Beniamino Galvani
5af7d46be4 travis: disable gtk-doc for meson builds
Introspection can't be enabled on travis due to a GLib bug [1].
Therefore, gtk-doc must be disabled as well.

[1] https://bugzilla.gnome.org/show_bug.cgi?id=774368
2018-09-19 16:03:32 +02:00
Beniamino Galvani
84701c049c build: meson: GTK documentation requires introspection 2018-09-19 16:03:32 +02:00
Beniamino Galvani
19a718bc13 build: meson: fix computing NM exported symbols
The script didn't include all the symbols needed by plugins because
libNetworkManager.a, as built by meson, doesn't include symbols from
other static libraries that are linked in. Since we used
libNetworkManager.a to know which symbols are potentiall available
from NM, the result was an incomplete list.

Unfortunately, the only way to include the whole static library is to
create a dependency object and use 'link_whole', but this is only
available in meson >= 0.46. Since 'link_whole' is available for
executables in meson >= 0.40, create a fake executable and use that to
enumerate symbols.

Also add tests to check that plugins can be loaded correctly.

Fixes: dfa2a2b40c
2018-09-19 16:03:32 +02:00
Beniamino Galvani
6da369252a docs: include openvswitch(7) man page only when ovs is enabled 2018-09-19 16:03:32 +02:00
Beniamino Galvani
c06a6aec1a build: meson: gtk-doc needs common.ent 2018-09-19 16:03:32 +02:00
Beniamino Galvani
c8636449b3 build: meson: man files depend on common.ent 2018-09-19 16:03:32 +02:00
Beniamino Galvani
37954c91bd build: meson: check vapi prerequisites and allow autodetection
Turn the vapi option into a combo that allows autodetection and check
whether all prerequisites are satisfied (including introspection
support) when vapi is explicitly enabled.

https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/28
2018-09-19 16:03:32 +02:00
Beniamino Galvani
98b4a19a53 build: meson: support $DESTDIR in installation script
Adapt the meson post-installation script to handle the $DESTDIR
variable supplied by user to specify the installation target
directory. While at it, convert the script to shell because it seems
simpler to me.
2018-09-19 16:03:32 +02:00
Lubomir Rintel
e732789bbf core/tests: remove an unused variable
test-general.c:6612:19: error: unused variable 'buf_free_1'
                                 [-Werror,-Wunused-variable]
        gs_free gpointer buf_free_1 = NULL;
2018-09-19 14:28:08 +02:00
Lubomir Rintel
b64ae759ad settings/ifupdown/tests: avoid asserting on an array
char[] is not a char *; it can not go NULL.

  test-ifupdown.c:147:27: error: address of array 'n->name' will always evaluate
                                 to 'true' [-Werror,-Wpointer-bool-conversion]
                g_assert (b->name && n->name);
  test-ifupdown.c:156:27: error: address of array 'm->key' will always evaluate
                                 to 'true' [-Werror,-Wpointer-bool-conversion]
                        g_assert (k->key && m->key);
2018-09-19 14:28:08 +02:00
Lubomir Rintel
92d36114dd crypto: remove some unused variables
libnm-core/nm-crypto.c:191:39: error: unused variable 'data_content'
                                        [-Werror,-Wunused-variable]
        nm_auto_clear_secret_ptr NMSecretPtr data_content = { 0 };
  libnm-core/nm-crypto.c:341:18: error: unused variable 'der'
                                        [-Werror,-Wunused-variable]
        gs_free guchar *der = NULL;
  libnm-core/nm-crypto.c:518:16: error: unused variable 'output'
                                        [-Werror,-Wunused-variable]
        gs_free char *output = NULL;
2018-09-19 14:28:08 +02:00
Lubomir Rintel
36f0825626 devices/acd-manager: avoid uninitialzied variable use
src/devices/nm-acd-manager.c:419:31: error: variable 'info' is uninitialized
                                       when used here [-Werror,-Wuninitialized]
                       nm_utils_inet4_ntop (info->address, NULL),
2018-09-19 14:28:08 +02:00
Thomas Haller
57780600dc wifi/iwd: merge branch 'balrog-kun/iwd-fixes' (pr#206)
https://github.com/NetworkManager/NetworkManager/pull/206
2018-09-19 08:47:33 +02:00
Andrew Zaborowski
061913c588 wifi/iwd: don't change state in secrets callback
Also make sure the secrets request callback only send a reply to IWD and
the Connect method return callback executes the device state change to
"disconnected".
2018-09-19 08:37:52 +02:00
Andrew Zaborowski
44af62eb1f wifi/iwd: actually wait for Connect() call return
state_changed (called when IWD signalled device state change) was
supposed to not change NM device state on connect success or failure and
instead wait for the DBus Connect() method callback but it would
actually still call nm_device_emit_recheck_auto_activate on failure so
refactor state_changed and network_connect_cb to make sure
the state change and nm_device_emit_recheck_auto_activate are only
called from network_connect_cb.

This fixes a race where during a switch from one network to another NM
would immediately start a new activation after state_changed and
network_connect_cb would then handle the Connect failure and mark the
new activation as failed.
2018-09-19 08:37:52 +02:00
Andrew Zaborowski
e3aba12d14 wifi/iwd: don't save secrets in mirror NM connections
When creating the mirror 802.1x connections for IWD 802.1x profiles
set the NM_SETTING_SECRET_FLAG_NOT_SAVED flag on the secrets that
may at some point be requested from our agent.  The saved secrets could
not be used anyway because of our use of
NM_SECRET_AGENT_GET_SECRETS_FLAG_REQUEST_NEW in
nm_device_iwd_agent_query.  But also try to respect whatever secret
caching policy has been configured in the IWD profile for those secrets,
IWD would be responsible for storing them if it was allowed in the
profile.
2018-09-19 08:37:52 +02:00
Andrew Zaborowski
fd1cfa6db4 wifi/iwd: access Network objects through ObjectManager
In two places stop using g_dbus_proxy_new_* to create whole new
interface proxy objects for net.connman.iwd.Network as this will
normally have a huge overhead compared to asking the ObjectManager
client that we already have in NMIwdManager for those proxies.
dbus-monitor shows that for each network path returned by
GetOrderedNetworks () -- and we call it every 10 or 20 seconds and may
get many dozens of networks back -- gdbus would do the following each
time:
org.freedesktop.DBus.AddMatch("member=PropertiesChanged")
org.freedesktop.DBus.StartServiceByName("net.connman.iwd")
org.freedesktop.DBus.GetNameOwner("net.connman.iwd")
org.freedesktop.DBus.Properties.GetAll("net.connman.iwd.Network")
org.freedesktop.DBus.RemoveMatch("member=PropertiesChanged")
2018-09-19 08:37:52 +02:00
Lubomir Rintel
a82e9083c1 manager: initialize a potentially uninitialized variable 2018-09-18 18:14:27 +02:00
Lubomir Rintel
e4a5f0b900 initrd: adjust to the newer nm_utils_parse_inaddr_*bin() API 2018-09-18 18:14:09 +02:00
Lubomir Rintel
7c270f0860 initrd-generator: add a missing include 2018-09-18 18:12:34 +02:00
Lubomir Rintel
40f571cb53 merge: branch 'lr/initrd'
https://github.com/NetworkManager/NetworkManager/pull/116
2018-09-18 17:46:38 +02:00
Lubomir Rintel
9dab0a5eba man/NetworkManager: document --configure-and-quit option 2018-09-18 17:40:47 +02:00
Lubomir Rintel
298f698c9e build: disable ibft settings plugin by default 2018-09-18 17:40:47 +02:00
Lubomir Rintel
9f9609555d initrd: add configuration generator
nm-initrd-generator scans the command line for options relevant to network
configuration and creates configuration files for an early instance of
NetworkManager run from the initial ramdisk during early boot.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
ecc074b2f8 initrd: add command line parser 2018-09-18 17:40:47 +02:00
Lubomir Rintel
b544f7243d initrd: add iBFT reader
This is loosely based on nms-ibft-reader, but with some significant
changes. Notably, it parses /sys/firmware/ibft directly instead of
iscsiadm output.

iscsiadm is not available on early boot (perhaps it's too large) and
turns out that parsing sysfs directly is easier and more
straightforwared anyways. A win-win situation.

It is not useful alone, it's in a separate commit just for the sake of
easier review.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
c263f5355c config: add --configure-and-quit=initrd mode
We need a mode that:

* doesn't leave processes behind
* doesn't force an internal dhclient
* doesn't auto-generate default connections
* doesn't write out files into libdir, only /run

The original configure-and-quit mode doesn't really fit the initrd use. But
it's proobably not a good idea to just change its behavior.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
e03d9ad1e0 dbus: don't even bother connecting in configure-and-quit mode
It makes no sense, results in unnecessary complexity both in code and in
code comments.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
ce4dbd7daf keyfile: write in-memory connections to /run
This is useful for in-memory connections to persist NetworkManager
restarts (as opposed to machine restarts).

Perhaps most improtantly, this allows generating in-memory connections outside
NetworkManager, e.g. passing configuration from early boot firmware in initrd.

Note that this does *not* aspire to do more than it says on the tin:
Notably, it doesn't touch the problem of provisioning connections in multiple
persistent connection directories and thus doesn't have to deal with the
problem of deleting or overlaying the connections tha (rh #772414) deals
with.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
e98ebc7e3b manager: don't save deactivating connections in the state file
Especially with configure-and-quit, it's easy to encounter a condition,
where the device reached a failed state, policy decides to quit, but the
active connection is not yet torn down from the device.

Upon the next start NetworkManager would think the connection succeeded
activating.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
e1fc005239 dns: don't let the plugins assert the bus manager has a connection
Make them just ask for connections from GDBus, as other D-Bus clients
do. GDBus anyway reuses the connection if it has one, but allows us to
deal with errors in a more civilized manner.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
89d1c9fb30 devices: make sure the generated connections are normalized
Using these unormalized was wrong all along, but by chance didn't hit
paths that needed normalized connections. This may change if we
actually write in memory connections to /run with the keyfile plugin,
because that one wants them normalized.

This also saves some work, because normalization does boring things for
us, such as adding default ipv4/ipv6/proxy settings everywhere.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
c39b134da1 core/setting: don't assume we have a connection when synthesizing a property
nm_setting_to_string() operates on the setting alone, without a
connection. Tolerate that.

This fixed nm_connection_dump(vlan_connection).
2018-09-18 17:40:47 +02:00
Lubomir Rintel
acbeda57fc build: drop unused SBINDIR 2018-09-18 17:40:47 +02:00
Lubomir Rintel
639a45f6c3 config: change formatting for no reason 2018-09-18 17:40:47 +02:00
Lubomir Rintel
47b877a7a6 device: don't leave dhclient running upon device removal
Leaving processes behind is a no-no for early boot, but probably a wrong
thing to do in any other cases either.
2018-09-18 17:40:47 +02:00
Lubomir Rintel
55d24ba94e dhcp: save root-path in the state file
On networked boot we need to somehow communicate this to the early boot
machinery. Sadly, no DBus there and we're running in configure-and-quit
mode.

Abusing the state file for this sounds almost reasonable and is
reasonably straightforward thing to do.
2018-09-18 17:40:47 +02:00
Beniamino Galvani
e07b13ca02 merge: branch 'bg/n-acd-update'
https://github.com/NetworkManager/NetworkManager/pull/195
2018-09-18 15:53:39 +02:00
Beniamino Galvani
691c71a7f2 build: allow disabling eBPF support in n-acd
Add a configure option to disable eBPF support in n-acd.

Note that, even if eBPF is not supported, n-acd requires a kernel >
3.19, which means that the setsockopt(..., SO_ATTACH_BPF) option must
be defined. To allow building on older kernels without modifying the
n-acd code, we inject the SO_ATTACH_BPF value as a preprocessor define
in the compiler the command line.
2018-09-18 15:32:36 +02:00
Beniamino Galvani
d9a4b59c18 acd: adapt NM code and build options
Adapt the nm-acd-manager.c code to the new API and also tweak build
options to the new project structure.
2018-09-18 15:32:36 +02:00
Beniamino Galvani
88072c6621 build: compile the c-rbtree library 2018-09-18 15:15:34 +02:00
Beniamino Galvani
51776b297e build: don't change CFLAGS from configure.ac
If configure.ac automatically adds compiler flags to CFLAGS, it
becomes hard to override one of them for a specific target because
CFLAGS is added last. It is better to use AM_CFLAGS. See [1].

[1] https://www.gnu.org/software/automake/manual/html_node/Flag-Variables-Ordering.html
2018-09-18 15:15:31 +02:00
Beniamino Galvani
d0c32a15a5 Merge commit '1361ede099f51cc29b478ebee6a736219ad74b97' into bg/n-acd-update
git subtree pull --prefix shared/n-acd git@github.com:nettools/n-acd.git master --squash
2018-09-18 15:15:02 +02:00
Beniamino Galvani
1361ede099 Squashed 'shared/n-acd/' changes from a68b55992..a40949267
a40949267 build: add CI run without ebpf
044db2056 n-acd: drop redundant headers
6a391cd83 n-acd: fix build without eBPF
bb194cf09 n-acd/config: make transport mandatory
ec2865743 build: drop unused c-sundry
721d9d84f n-acd: inline c_container_of()
1a7ee317c util/timer: fix coding-style
6c96f926b util/timer: fall back to CLOCK_MONOTONIC if necessary
4ea3165fc n-acd: only use CLOCK_BOOTTIME if really necessary
c1b853c6c util/timer: cleanup headers
b1d6ad272 n-acd: add destructors that return void
185be55b6 test-bpf: skip test in case of unsufficient privs
84a40e8fa build: add NEWS file
bf11443ff build: mention mailinglist in readme
e2797984a test-bpf: drop bpf-filter.h
668ed3c82 subprojects: pull in updates
dd8cab3f0 test-veth: reduce parallel execution to 9
68b09ba2b build: update AUTHORS
3f77e3e88 test: make function headers valid C
5275a5120 test: get rid of spurious tab
037df412c n-acd: make struct initializers valid C
346ec0c67 build: upgrade CI
38682a36d n-acd: fix signed vs unsigned comparison
5e7578b33 bpf: properly zero out trailing bpf_attr space
ee1e432ae probe: fix coding-style
a143540f9 build: use lower-case build options
835533e7d build: minor style fixes
2bd6d1d29 build: get rid of tabs
b14979934 eBPF: make compile-time optional
6f13c27ee n-acd: filter out invalid packets
4e6a169a0 build: sync with c-util repositories
6c4a9117b build: document eBPF kernel requirement
3ef08394d n-acd: don't remember dropped defense attempts
4dff8771f n-acd: fix coding-style
b11fb9706 n-acd/config: default to the RFC-specified timeout
d885bb3b7 n-acd/event: don't expose the type of operation that caused a conflict
e2f87e047 TODO: drop remaining items
f06993856 test/veth: reduce the number of probed addresses
8b4f7ed64 test/veth: bump the timeout a bit
14e4606f6 n-acd/probe: don't cap the jitter at 4s
a0247b86f test/veth: fix stackvariable corruption
a64ac8389 n-acd/probe: update comments
aa9c25bc1 n-acd/handle_timeout: update comments
b6c2df3a9 timer: rename timer_pop() to timer_pop_timeout()
47c657a8d test: fix handling of child addresses
27168ba9e timer: move timer_read() from n-acd.c to util/timer.c
21a1e37aa timer: require timer to be explicitly rearmed
ee1080820 bpf/map: make key/value sizes self-documenting
fd444353e test/veth: rework test
ba2bc433c test: rework child_ip() helper
07881b8da test: silence a warning
38da00b0a test/bpf: make tests for map modifications more comprehensive
6a2ffd23a test/timerfd: for documentation purposes verify the kernel API
01a9cf54b probe: move from ms to ns internally
4fe438dd9 n-acd: move to use the Timer utility library
e098cfc79 util: add a timer utility helper
8ea196e5b subprojects: pull in c-sundry
0c0b3c29f acd/probe: do not subscribe to packets in FAILED state
9c922ea3d acd/probe: introduce probe_{un,}link() helpers
024a830e6 acd/probe: use unschedule() helper in free()
b098a3bcc tests/veth: minor fixes to the test
fe3d9578a acd/packet: consider unexpected packets a fatal error
34d7656d7 acd: stop state-machine after USED or CONFLICT events
7d9e5ec6b acd: don't declare iovec entries inline
7afd8d8a3 tests: add veth test
26a737b42 tests/veth: add helper for adding IP addresses to child device
e73a37a11 probe: store a userdata pointer in the probe object
327e82625 test: introduce loopback helper
0682b15f8 acd: reduce default map size
afead881f tests: reinstate loopback test
4527d2f71 BPF: move and document the eBPF helpers
88bacc022 socket filter: move to the new eBPF helpers
245104d5c tests: skip tests if lacking permissions
195d9ff5a n-acd: rework API to support many probes on a context
ab440eb99 eBPF: never return packets that userspace should unconditionally drop
ac933f412 eBPF: add eBPF helper functions

git-subtree-dir: shared/n-acd
git-subtree-split: a40949267923c45cb232fa4c1d60eafacee4b36e
2018-09-18 15:14:49 +02:00
Beniamino Galvani
ba4452fe77 Merge commit '4f4e96655625a0ad8c5fc451c5a3a8dda3bf5456' as 'shared/c-rbtree'
Imported c-rbtree code with command:

  git subtree add --prefix shared/c-rbtree git@github.com:c-util/c-rbtree.git bf627e0c32241915108f66ad9738444e4d045b45 --squash

To update the library use:

  git subtree pull --prefix shared/c-rbtree git@github.com:c-util/c-rbtree.git master --squash
2018-09-18 15:08:46 +02:00
Beniamino Galvani
4f4e966556 Squashed 'shared/c-rbtree/' content from commit bf627e0c3
git-subtree-dir: shared/c-rbtree
git-subtree-split: bf627e0c32241915108f66ad9738444e4d045b45
2018-09-18 15:08:36 +02:00
Thomas Haller
9ad60ad092 shared: relax assertion in nm_utils_parse_inaddr()/nm_utils_parse_inaddr_prefix()
The assertion fails in nmtui's ip_route_transform_from_dest_string(),
which does not initialize the address output argument to %NULL.

There are three possibilities how the API could work:

 - assert/require the user to pass in arguments which pre-initialized
   to NULL or unset.
 - always set the output arguments, even if the function fails.
 - don't bother and leave output values untouched, if function fails.

It's not clear which approach is the best. Not to bother possibliy
leaves uninitialized values, which could be error prone. Still, do
just that.

Fixes: 0b3197a3fd
2018-09-18 08:00:06 +02:00