Commit Graph

13873 Commits

Author SHA1 Message Date
Dan Williams
32e1d6a9a9 platform: update code documentation for nm_platform_link_get_physical_port_id() 2015-03-27 15:11:33 -05:00
Dan Williams
8173f0f9e8 platform: prevent warning when udev is clueless about a device
udev doesn't know about the device yet when NM creates it internally.

NetworkManager[9275]: <info>  (team0): carrier is OFF
NetworkManager[9275]: <info>  (team0): new Team device (driver: 'team' ifindex: 16)
(NetworkManager:9275): GUdev-CRITICAL **: g_udev_device_get_property: assertion 'G_UDEV_IS_DEVICE (device)' failed
NetworkManager[9275]: <info>  (team0): exported as /org/freedesktop/NetworkManager/Devices/5
2015-03-27 15:03:36 -05:00
Jiří Klimeš
9b464f8c65 man: add an example to nmcli manual page 2015-03-26 09:48:16 +01:00
Jiří Klimeš
ba35c63db6 libnm-util: allow 0.0.0.0/1 route in verify() (rh #1203904)
OpenVPN uses a trick to override default route by adding these two routes:
0.0.0.0/1 and 128.0.0.0/1.
We should allow this and only refuse real default route (i.e. prefix == 0).

Also verify IPv6 addresses and routes.

See:
man openvpn (search for def1)
https://community.openvpn.net/openvpn/wiki/IgnoreRedirectGateway

https://bugzilla.redhat.com/show_bug.cgi?id=1203904
2015-03-24 12:19:17 +01:00
Thomas Haller
99df201a0c dhcp: merge branch 'systemd-dhcp' into master
Conflicts:
	src/dhcp-manager/systemd-dhcp/src/shared/util.c
2015-03-23 21:12:31 +01:00
Thomas Haller
ddb5112180 dhcp: update systemd DHCP code
This is a direct dump from systemd git on 2015-03-23, git commit
eaa5251d9167027.  Only relevant files were included.

    SYSTEMD_DIR=../systemd
    COMMIT=eaa5251d9167027275d8275862e23e0b7dc8866e

    (
       cd "$SYSTEMD_DIR"
       git checkout "$COMMIT"
       git reset --hard
       git clean -fdx
    )
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd/sd-id128/sd-id128.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd/sd-id128/sd-id128.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-identifier.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-identifier.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-identifier.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-lease-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-lease-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-network.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-network.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-option.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-option.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-packet.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-packet.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-protocol.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-protocol.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-lease-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-lease-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-network.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-network.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-option.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-option.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-protocol.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-protocol.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/network-internal.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/network-internal.h
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-client.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-client.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-lease.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-lease.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-client.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp6-client.c
    /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-lease.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp6-lease.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/async.h ./src/dhcp-manager/systemd-dhcp/src/shared/async.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/fileio.c ./src/dhcp-manager/systemd-dhcp/src/shared/fileio.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/fileio.h ./src/dhcp-manager/systemd-dhcp/src/shared/fileio.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/list.h ./src/dhcp-manager/systemd-dhcp/src/shared/list.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/log.h ./src/dhcp-manager/systemd-dhcp/src/shared/log.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/macro.h ./src/dhcp-manager/systemd-dhcp/src/shared/macro.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/path-util.c ./src/dhcp-manager/systemd-dhcp/src/shared/path-util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/path-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/path-util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/refcnt.h ./src/dhcp-manager/systemd-dhcp/src/shared/refcnt.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/siphash24.c ./src/dhcp-manager/systemd-dhcp/src/shared/siphash24.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/siphash24.h ./src/dhcp-manager/systemd-dhcp/src/shared/siphash24.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/socket-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/socket-util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/sparse-endian.h ./src/dhcp-manager/systemd-dhcp/src/shared/sparse-endian.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/strv.c ./src/dhcp-manager/systemd-dhcp/src/shared/strv.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/strv.h ./src/dhcp-manager/systemd-dhcp/src/shared/strv.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/time-util.c ./src/dhcp-manager/systemd-dhcp/src/shared/time-util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/time-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/time-util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/utf8.c ./src/dhcp-manager/systemd-dhcp/src/shared/utf8.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/utf8.h ./src/dhcp-manager/systemd-dhcp/src/shared/utf8.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/util.c ./src/dhcp-manager/systemd-dhcp/src/shared/util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/util.h ./src/dhcp-manager/systemd-dhcp/src/shared/util.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/unaligned.h ./src/dhcp-manager/systemd-dhcp/src/shared/unaligned.h
    /bin/cp "$SYSTEMD_DIR"/src/shared/in-addr-util.c ./src/dhcp-manager/systemd-dhcp/src/shared/in-addr-util.c
    /bin/cp "$SYSTEMD_DIR"/src/shared/in-addr-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/in-addr-util.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/_sd-common.h ./src/dhcp-manager/systemd-dhcp/src/systemd/_sd-common.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-client.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-client.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-lease.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-lease.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-client.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp6-client.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-lease.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp6-lease.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-event.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-event.h
    /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-id128.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-id128.h
2015-03-23 20:56:47 +01:00
Lubomir Rintel
ca9679334c platform: merge branch 'lr/udev-unmanaged-fd731014'
https://bugzilla.gnome.org/show_bug.cgi?id=731014
2015-03-23 15:17:07 +01:00
Lubomir Rintel
498d45e85f Revert "core: make veth devices default-unmanaged for now"
This reverts commit ebeaeaed4d.

No need to hardwire these as unmanaged anymore, an udev rule will take care of
it.
2015-03-23 15:13:02 +01:00
Lubomir Rintel
ceea3c6782 data: move OLPC MESH udev rules away from callouts
No idea why was it there in the first place.

This also fixes a bug that the rules file was conditionally included in dist
depending on presence of udev dir at configure time.
2015-03-23 15:13:02 +01:00
Lubomir Rintel
7ba30cfd26 data: add udev rules to make emulated ethernet devices default unmanaged
There are some out-of-tree drivers that create devices masquerading as
ethernets which are supposed to use their own management tools. Avoid touching
them.

The rules should be run after 80-net-setup-link.rules, so that the
ID_NET_DRIVER is set.
2015-03-23 15:13:02 +01:00
Lubomir Rintel
85ee1f4a9c platform: give the platform an opportunity to override default-unmanaged
Some out of tree drivers add Ethernet devices that are supposed to be managed
by other their tooling, e.g. VirtualBox or VMWare.

Rather than hardcoding their drivers (at least VirtualBox doesn't even set a
"driver" property in sysfs) or hardcoding a logic that identifies such devices
let's just add a possibility to blacklist them in udev. This makes it possible
for whoever who ships such a driver to ship rules that prevent NetworkManager
from managing the device itself.

Furthermore it makes it possible for the user with special needs leverage the
flexibility of udev rules to override the defaults. In the end the user can
decide to let NetworkManager manage default-unmanaged interfaces such as VEth
or turn on default-unmanaged for devices on a particular bus.

An udev rule for VirtualBox would look like this:

  SUBSYSTEM=="net", ENV{INTERFACE}=="vboxnet[0-9]*", ENV{NM_UNMANAGED}="1"
2015-03-23 15:13:02 +01:00
Lubomir Rintel
4a05869557 platform: don't wait for udev device initializaton if there's no udev
There's no udev running in containers, it only starts if /sys is writable. If a
hardware device is added to the container's namespace NM would not announce it.

This also removes the software link special case -- the software links will now
wait for udev initialization (in case udev is there) as well. There's no reason
to treat them differently anymore. This makes it possible to use udev properties
of the software links.

https://bugzilla.gnome.org/show_bug.cgi?id=740526
2015-03-23 15:13:02 +01:00
Lubomir Rintel
b3667afa22 contrib: ensure udev rules from RPM package are applied
We install udev rules and need to ensure that correct ones are in effect when
the package is installed, updated or removed.
2015-03-20 19:09:01 +01:00
Thomas Haller
c6011cde14 trivial: remove semicolon after macro definition
Fixes: 58f08c8c9c
2015-03-20 13:38:44 +01:00
Thomas Haller
89c88f2480 libnm/keyfile: sort keyfile entries and nm_connection_for_each_setting_value()
Fix the order for keyfile writer. It is nicer to have a fixed, sensible
order with [connection] first.

Do this by sorting the order in nm_connection_for_each_setting_value()
and nm_setting_enumerate_values().

https://mail.gnome.org/archives/networkmanager-list/2015-March/msg00050.html
2015-03-20 13:30:22 +01:00
Thomas Haller
58f08c8c9c libnm: sort properties for nm_setting_enumerate_values()
The sort order of nm_setting_enumerate_values() affects the
order in which keyfile writer serializes the properties.

Have a defined, stable sort order by sorting the properties
by name (with prefering id,uuid,type for NMSettingConnection).
2015-03-20 13:19:20 +01:00
Thomas Haller
e50fbe466b libnm: sort settings for nm_connection_for_each_setting_value()
nm_connection_for_each_setting_value() is used by keyfile writer to iterate
over the settings and write the keyfile entires. The order there is important
as g_key_file_to_data() prints the groups in the order they were created.

To have a stable order and to have the [connection] entry first, sort the
settings.
2015-03-20 13:19:20 +01:00
Thomas Haller
81119c69d8 keyfile/test: refactor and cleanup _keyfile_convert()
_keyfile_convert() should really test for successful round-trip
conversion of keyfile-connection and vice versa.
2015-03-20 13:19:20 +01:00
Thomas Haller
a5ea98005f test: print connections as keyfile on failure of nmtst_assert_connection_equals()
If the assertion nmtst_assert_connection_equals() is about to fail,
dump out the offending connections as keyfile.
2015-03-20 13:19:20 +01:00
Thomas Haller
3790d8db2e test: fix printing error in nmtst_assert_connection_equals() 2015-03-20 13:19:20 +01:00
Thomas Haller
94cc7ca4f8 test: fix __NMTST_LOG() macro to allow format-string-only argument
We want to be able to call __NMTST_LOG(g_message, "hallo"); without
additional format string arguments.
2015-03-20 13:19:15 +01:00
Thomas Haller
3ef2a5364b libnm: merge branch 'th/wep-key-bgo745890'
Don't verify() secrets.

https://bugzilla.gnome.org/show_bug.cgi?id=745890
2015-03-20 13:02:59 +01:00
Thomas Haller
628f47285d libnm: accept unknown WEP key type in nm_utils_wep_key_valid()
libnm-core treated the UNKNOWN WEP key type as KEY. Relax that
and try to guess the correct type based on the key.

This is for example important if you have a valid connection with
  wep-key-type=0 (unknown)
If you request passwords for such a connection, the user cannot
enter them in password format -- but there is no UI indication
that the password must be KEY.
2015-03-20 13:02:04 +01:00
Thomas Haller
dbbedce21f libnm: don't check for valid passwords in NMSetting:verify()
We must never fail verification of a connection based on a password
because the password is re-requested during activation.

Otherwise, if the user enters an invalid password for a (previously)
valid connection, the connection becomes invalid. NetworkManager does
not expect or handle that requesting password can make a connection
invalid.
Invalid passwords should be treated as wrong passwords. Only a UI
(such as nm-connection-editor or nmcli) should validate passwords
against a certain scheme.

Note that there is need_secrets() which on the contrary must check for
valid passwords.

Error scenario:

  Connect to a WEP Wi-Fi, via `nmcli device wifi connect SSID`. The
  generated connection has wep-key-type=0 (UNKNOWN) and wep-key-flags=0.
  When trying to connect, NM will ask for secrets and set the wep-key0
  field. After that, verification can fail (e.g. if the password is longer
  then 64 chars).
2015-03-20 13:01:04 +01:00
Thomas Haller
8e58fc7425 nm-iface-helper: remove duplicate setpgid() call
Fixes: 5775df9a6d
2015-03-20 12:31:44 +01:00
Thomas Haller
6ce7b7df96 core: merge branch 'th/main-order-bgo746254'
Some refactoring of the main() functions for NetworkManager and
nm-iface-helper. Most notably, start the D-Bus service earlier so
that NetworkManager starts faster.

https://bugzilla.gnome.org/show_bug.cgi?id=746254
2015-03-20 11:45:11 +01:00
Thomas Haller
21562052ec main: (order) early start D-Bus service
systemd considers the startup time of NetworkManager until the D-Bus
service is claimed. By doing that earlier, this time is significantly
reduced.
This has the advantage, that services that are ordered to start
after NetworkManager can start earlier. Most notably, 'network.target'
orders itself After=NetworkManager.service and many services are ordered
After=network.target.

  $ systemd-analyze blame | grep NetworkManager.service
2015-03-20 11:43:30 +01:00
Thomas Haller
7fe0f349ce main: (order) move run_from_build_dir check before setting up logging
Or: move setup of nm-logging immediately after it is really needed:
before setup of config.
2015-03-20 11:43:30 +01:00
Thomas Haller
49cfe64874 main: (order) earlier create rundir
Create the rundir earlier and before setting up nm-logging.
nm_main_utils_ensure_rundir() errors out with fprintf(stderr)
and does not need nm-logging.
2015-03-20 11:43:30 +01:00
Thomas Haller
f64c79afda main: (order) log "is starting" message immediately after setting up logging 2015-03-20 11:43:30 +01:00
Thomas Haller
7be9024c82 main: (order) parse state file later and use nm-logging
Parse the state file a bit later after daemonizing and setting up
logging. That way, we can use nm-logging.
2015-03-20 11:43:30 +01:00
Thomas Haller
af2b44cb43 main: (order) check pidfile earlier for running NM
We should check for conflicting process (pidfile)
early on and error out.
2015-03-20 11:43:30 +01:00
Thomas Haller
e36bfaadf7 nm-iface-helper: fix pidfile name and obtain the ifindex earlier
The @ifindex is needed for the @pidfile. Obtain the @ifindex earlier
without resorting to platform.
2015-03-20 11:43:30 +01:00
Thomas Haller
95786a4e4e main: (order) move root user check after help/version option
With this change, `NetworkManager --help` and `NetworkManager --version`
work for non-root user.
2015-03-20 11:43:30 +01:00
Thomas Haller
3696c675fe main: (order) early call _init_nm_debug()
_init_nm_debug() only depends on DEBUG config setting.
Let's call it first after parsing configuration.
2015-03-20 11:43:30 +01:00
Thomas Haller
c50622c845 main: (order) set g_log_set_always_fatal() early on
After parsing the cmd line options, we already can setup fatal glog
level.
2015-03-20 11:43:30 +01:00
Thomas Haller
0587dbe96c main: (order) call g_type_init() very early in main()
g_type_init() is independent of all NetworkManager
functionality. Just get it done early on.
2015-03-20 11:43:30 +01:00
Thomas Haller
12ad2c7fe7 main: refactor nm_main_utils_check_pidfile() to exit directly on failure
And rename the function to nm_main_utils_ensure_not_running_pidfile()
to match the other _ensure_ functions that exit(1).

Also no longer pass @name to nm_main_utils_ensure_not_running_pidfile()
and use g_get_prgname() instead.
nm_main_utils_ensure_not_running_pidfile() checks that the running
process has the same program name, so this changes behavior if the
user renamed the binary. Before, we would check whether the running
process is named 'NetworkManager' ('nm-iface-helper'). Now we check
whether the process has the same name as the current process.
This means, that if you rename the binary to 'NetworkManager2' we
would now only detect a conflicting 'NetworkManager2'. Before we would
only detect conflicting 'NetworkManager' binaries.
2015-03-20 11:43:30 +01:00
Thomas Haller
29718fcaa4 main: split out nm_main_utils_ensure_rundir ()
Also, don't use nm_log_err() as nm-logging is not yet setup.
2015-03-20 11:43:30 +01:00
Thomas Haller
5775df9a6d main: refactor early setup in main()
Move call to nm_main_utils_early_setup() to a separate function.
Also move the @options array away from the main function, saving
a few bytes on the stack.
Now only do_early_setup() modifies the @global_opt structure.
2015-03-20 11:43:29 +01:00
Thomas Haller
1fc5aba42a main: move option variables to static variable
Move the variables to a static struct so that we can factor
out some of the initialization code.

Also it's nice to have all options placed together in one struct so
that is is obvious which static variables are part of the command line
options, and which have other use.
2015-03-20 11:43:29 +01:00
Thomas Haller
b5ca5bd7b7 main-utils: don't leak description for command line arguments in nm_main_utils_early_setup() 2015-03-20 11:43:29 +01:00
Thomas Haller
5e962bef87 main: don't unref config instance at end of main()
config is a singleton implemented using NM_DEFINE_SINGLETON_DESTRUCTOR().
No need to unref it manually.
2015-03-20 11:43:29 +01:00
Thomas Haller
ee4543bd6e main/trivial: change order of arguments for nm_main_utils_early_setup()
Change the order of the argv and argc argument to match
the main() function.
2015-03-20 11:43:29 +01:00
Jiří Klimeš
b8a2f42a38 cli: allow multiple devices for 'nmcli device disconnect/delete' (bgo #746097)
Allow disconnecting and deleting multiple interfaces at a time. It is much
more user friendly. TAB and bash completions are supported as well.

https://bugzilla.gnome.org/show_bug.cgi?id=746097
2015-03-20 11:03:44 +01:00
Thomas Haller
ae0d563906 trivial: use macro instead of plain C string for gobject property name 2015-03-19 17:01:57 +01:00
Lubomir Rintel
5206a9b28d build: fix clang + glib 2.43 build
Known glib issue. Fixes Fedora 22 build.
2015-03-19 16:29:33 +01:00
Lubomir Rintel
f0740aff88 build: disable warnings that trigger known clang problems
Fixes build with clang 3.5 on Fedora 21.
2015-03-19 11:48:49 +01:00
Lubomir Rintel
3ccc6f290d build: disable warnings where macros expand to tautological comparisons 2015-03-19 11:48:49 +01:00
Lubomir Rintel
a43f95b0ac trivial: remove a tautological compare
Unsigned enum is always >= 0.
2015-03-19 11:48:49 +01:00