Commit Graph

198 Commits

Author SHA1 Message Date
Thomas Haller
ff145486d1 core: add nm_ipX_config_get_direct_route_for_host() functions
add two functions nm_ip4_config_get_direct_route_for_host()
and nm_ip6_config_get_direct_route_for_host() to check if we have
a direct (non-gw) route to a certain host.

Signed-off-by: Thomas Haller <thaller@redhat.com>

https://bugzilla.gnome.org/show_bug.cgi?id=738590
2014-10-31 18:35:31 +01:00
Lubomir Rintel
48b4f6f830 Merge branch 'lr/rpm-make-check'
https://bugzilla.gnome.org/show_bug.cgi?id=739127
2014-10-30 14:40:47 +01:00
Thomas Haller
caa1779f33 utils: fix printf format for pid_t in nm_utils_get_start_time_for_pid()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-29 15:02:04 +01:00
Lubomir Rintel
b54030de22 core: Fall back to CLOCK_MONOTONIC if CLOCK_BOOTTIME unsupported
It was added fairly recently (2.6.39), this breaks run (and test run in mock)
on RHEL-6 with 2.6.32.
2014-10-24 19:24:32 +02:00
Thomas Haller
41e0d5b9ce core: add nm_utils_log_connection_diff
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 21:17:17 +02:00
Thomas Haller
f87e876f79 core: prefer connections with higher priority for autoconnect
https://bugzilla.gnome.org/show_bug.cgi?id=580018

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-12 20:13:18 +02:00
Thomas Haller
efd8be04f1 core: add nm_utils_kill_process_sync() function
This utility function is for killing other processes.
Contrary to nm_utils_kill_child_*() which is for killing
and reaping child processes.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-10 12:28:59 +02:00
Thomas Haller
99c5edbacd core: add nm_utils_get_start_time_for_pid() function
Move the code from nm-auth-subject.c over to NetworkManagerUtils.c

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-10 11:51:40 +02:00
Thomas Haller
ca2145bef2 core: minor fix in nm_utils_kill_child_sync() having side-effects in MIN() macro (again)
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-02 11:27:22 +02:00
Thomas Haller
1e4dd48698 core: minor fix in nm_utils_kill_child_sync() having side-effects in MIN() macro
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-10-01 16:29:21 +02:00
Thomas Haller
05494423de auth: rename file nm-manager-auth.* to nm-auth-utils.*
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-09-29 13:00:11 +02: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 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š
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
Dan Winship
3a54d05098 libnm-core: change all mac-address properties to G_TYPE_STRING
Make all mac-address properties (including NMSettingBluetooth:bdaddr,
NMSettingOlpcMesh:dhcp-anycast-addr, and NMSettingWireless:bssid) be
strings, using _nm_setting_class_transform_property() to handle
translating to/from binary form when dealing with D-Bus.

Update everything accordingly for the change, and also add a test for
transformed setting properties to test-general.
2014-09-04 09:20:10 -04:00
Dan Winship
7d233cc956 core: abstract out the duplicated default-ifname-generating code
NMDeviceBond, NMDeviceBridge, and NMDeviceTeam all used basically the
same code to generate a default interface name. Move it into
nm_utils_complete_generic().
2014-09-04 09:18:44 -04:00
Thomas Haller
ed20177d27 core: refactor nm_utils_complete_generic() not to use a dynamic format string
For NMDeviceWifi and NMDeviceWimax, the printf format string for
nm_utils_complete_generic() was created based on ssid/nsp. Since
these input strings are untrusted, this is a serious bug.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-25 16:46:14 +02:00
Thomas Haller
8fe1b79012 libnm-core: declare NM_SETTING_COMPARE_FLAG_INFERRABLE flag in "nm-core-internal.h"
As this flag is used by NM-core, move it to nm-core-internal.h
header file.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-22 15:22:16 +02:00
Peter Korsgaard
123322c6d6 core: fix build with toolchains not exporting CLOCK_BOOTTIME
E.G. uClibc 0.9.33 and earlier.

https://bugzilla.gnome.org/show_bug.cgi?id=734599

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-11 13:16:22 +02:00
Dan Winship
44b9a8708b libnm-core, etc: add nm_utils_hwaddr_matches()
Add nm_utils_hwaddr_matches(), for comparing hardware addresses for
equality, allowing either binary or ASCII hardware addresses to be
passed, and handling the special rules for InfiniBand hardware
addresses automatically. Update code to use it.
2014-08-07 15:34:50 -04:00
Dan Winship
ea456aaa81 all: remove use of struct ether_addr / ether_aton()
Lots of old code used struct ether_addr to store hardware addresses,
and ether_aton() to parse them, but more recent code generally uses
guint8 arrays, and the nm_utils_hwaddr_* methods, to be able to share
code between ETH_ALEN and INFINIBAND_ALEN cases. So update the old
code to match the new. (In many places, this ends up getting rid of
casts between struct ether_addr and guint8* anyway.)

(Also, in some places, variables were switched from struct ether_addr
to guint8[] a while back, but some code still used "&" when referring
to them even though that's unnecessary now. Clean that up.)
2014-08-07 12:11:49 -04:00
Thomas Haller
43df0e9ae4 core: fix warning calling non-returning g_error()
g_error() does not return, but clang seems not to understand that
and gives the following warning.

    make[4]: Entering directory `./NetworkManager/src'
      CC       NetworkManagerUtils.lo
    NetworkManagerUtils.c:1584:1: error: control may reach end of non-void function [-Werror,-Wreturn-type]
    }
    ^

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:00 +02:00
Dan Williams
e2270040c0 core: use Interface Identifiers for IPv6 SLAAC addresses
Ethernet-like interfaces aren't the only type of interfaces that can
run IPv6 but the rdisc code only returns an address if the interface's
hardware address is 6 bytes.

Interface types like PPP (rfc5072) and IPoIB (rfc4391) have their own
specifications for constructing IPv6 addresses and we should honor
those.

So instead of expecting a MAC address, let each device subclass
generate an Interface Identifier and use that for rdisc instead.
2014-07-23 12:53:55 -05:00
Dan Winship
2b2faf9c28 config: move some spec-match-list handling from config to core
NMConfig accepted no-auto-default and ignore-carrier lists with
untagged specs (ie, interface names not prefixed with
"interface-name:" and hardware addresses not prefixed with "mac:").
Move that handling into nm_match_spec_interface_name() and
nm_match_spec_hwaddr() instead.
2014-07-23 10:56:26 -04:00
Dan Winship
b28f6526c2 core: fill in nm-types.h, clean out other headers
Clean up some of the cross-includes between headers (which made it so
that, eg, if you included NetworkManagerUtils.h in a test program, you
would need to build the test with -I$(top_srcdir)/src/platform, and if
you included nm-device.h you'd need $(POLKIT_CFLAGS)) by moving all
GObject struct definitions for src/ and src/settings/ into nm-types.h
(which already existed to solve the NMDevice/NMActRequest circular
references).

Update various .c files to explicitly include the headers they used to
get implicitly, and remove some now-unnecessary -I options from
Makefiles.
2014-07-23 10:56:26 -04:00
Jiří Klimeš
70e930bc0e utils: add nm_utils_is_specific_hostname()
The function detects whether the hostname is a specific hostname diferrent
from default hostnames like localhost, localhost[6].localdomain[6].
2014-07-14 17:36:07 +02:00
Thomas Haller
1f8418541e core: add nm_utils_kill_child_async() and nm_utils_kill_child_sync() function
Add utility function to kill and reap a child process.

https://bugzilla.gnome.org/show_bug.cgi?id=725660

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-10 16:25:10 +02:00
Thomas Haller
f600f31289 core: remove nm_utils_normalize_connection function
This functionality is now provided by nm_connection_normalize().

Contrary to nm_utils_normalize_connection(), nm_connection_normalize()
is in libnm-util and available to clients as well.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-30 18:35:46 +02:00
Dan Williams
e5ccc30e3c core: suppress missing MAC address warning during connection matching
One of the connetions may not have a MAC address, so don't expect one.
2014-06-06 16:37:03 -05:00
Thomas Haller
8f8b247e34 core: add nm_utils_get_monotonic_timestamp_ns() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 19:04:05 +02:00
Thomas Haller
bc34ee7779 core: add code comment to nm_utils_get_monotonic_timestamp_*s() functions
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-06-06 19:04:05 +02:00
Dan Winship
53857a3ef7 core: add debug logging to nm_utils_match_connection()
Related: rh#1086237
2014-06-04 11:24:05 -04:00
Jiří Klimeš
a7fa1aed1b trivial: clarify comments in test-general.c and NetworkManagerUtils.c 2014-05-30 09:21:02 +02:00
Jiří Klimeš
fbdf8857c3 core: take over connections with IPv6 method 'ignore' for 'auto' (rh #1083196)
If we had a connection with IPv6.method = ignore, we simply ignored IPv6. So
we should assume this connection even if there is an SLAAC address on the
interface.

https://bugzilla.redhat.com/show_bug.cgi?id=1083196
2014-05-30 09:20:55 +02:00
Thomas Haller
9ef23947cc all: fix various warnings detected with coverity
https://bugzilla.gnome.org/show_bug.cgi?id=728320

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-05-02 15:20:30 +02:00
Jiří Klimeš
7251e4ea22 utils: allow matching connections with no MAC (missing HWADDR) (rh #1083196) 2014-04-11 10:06:08 +02:00
Jiří Klimeš
d12b2079bf utils: fix check_possible_match() function
We can only allow possible match if all the differences are exceptions.
Before, we accepted the connection if an exception was found, but it is wrong
because there may be another difference (that is fatal).
2014-04-11 09:59:12 +02:00
Thomas Haller
80d2d0ebe1 core: refactor nm_utils_ascii_str_to_int64()
No need to allocate a dynamic buffer in most of the cases.

And extended test cases to test with/without white space
and leading zeros.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:32:20 +02:00
Thomas Haller
e739e01900 core: use ASSERT_VALID_PATH_COMPONENT
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:27:02 +02:00
Thomas Haller
ec7fc72e67 core: add ASSERT_VALID_PATH_COMPONENT function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:27:02 +02:00
Thomas Haller
2b3ef7664f core/trivial: clearify code comment on error for nm_utils_ascii_str_to_int64()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-04-10 16:27:02 +02:00
Jiří Klimeš
7ff7df7640 core: improve ifname matching of existing x generated connections (rh #1077743)
DEVICE="ens3"
ONBOOT=yes
NETBOOT=yes
UUID="23466771-f5fa-4ca9-856f-eaf4a8e20c3f"
BOOTPROTO=none
IPADDR="10.0.0.2"
PREFIX="24"
GATEWAY="10.0.0.1"
HWADDR="52:54:00:12:34:56"
TYPE=Ethernet
NAME="ens3"

This ifcfg file results in connection.interface-name=ens3.
However, device-generated connection didn't set interface-name property.

Fix that by setting interface-name property when generating a connection. Also
allow matching connections if interface-name is not set in a connection.

https://bugzilla.redhat.com/show_bug.cgi?id=1077743
2014-03-21 09:24:13 +01:00
Jiří Klimeš
4112bda940 core: allow matching IPv6 'link-local' method to 'ignore' (rh #1073824)
When an existing connection profile has IPv6 method 'ignore', NM doesn't simply
care about IPv6. Thus we should allow matching such a profile to devices with
just a link-local address.

The example can be a simple configuration like this:
/etc/sysconfig/network-scripts/ifcfg-ens3:
DEVICE="ens3"
ONBOOT=yes
NETBOOT=yes
UUID="aa17d688-a38d-481d-888d-6d69cca781b8"
BOOTPROTO=dhcp
HWADDR="52:54:00:32:77:59"
TYPE=Ethernet
NAME="ens3"

https://bugzilla.redhat.com/show_bug.cgi?id=1073824
2014-03-12 09:41:27 +01:00
Dan Winship
a10bd9991f core: move NMDevice's ip6_property_path() to NetworkManagerUtils 2014-03-04 17:04:01 -05:00
Dan Williams
1d5847c8a6 core: match IPv4 'disabled' method to 'auto' when device has no link
If IPv4 configuration did not succeed or the device has no IPv4 addresses
when NM restarts, it will detect the existing device configuration as
'disabled'.  This can happen when a bridge has no slaves and thus cannot
perform IPv4 addressing because it has no carrier (since bridge carrier
status depends on slave carriers).  When NM starts or restarts, it
sees the bridge has no IPv4 address and assumes the IPv4 method is
'disabled'.  This creates a new connection, which blocks any slave
connections from activating if they specify their master via UUID
 (since the bridge's active connection is generated).

Fix this by allowing matches from 'disabled' to 'auto' if the device
has no carrier, and there are no other differences between the
original and the candidate connections.
2014-03-04 15:21:58 -06:00
Dan Williams
7b65f8934e core: refactor connection matching and add testcase
Refactor in preparation for some additional matching, and add testcases.
2014-03-04 15:21:58 -06:00
Thomas Haller
0024c72586 trivial: fix whitespace
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-24 21:35:33 +01:00
Thomas Haller
e8775dd9fc core: add function nm_utils_ip6_address_clear_host_address()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 21:40:58 +01:00
Thomas Haller
a0e734764f core: add nm_utils_get_monotonic_timestamp_us() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-02-14 15:53:11 +01:00
Thomas Haller
84ea5b6302 core: minor change of logging output about monotonic_timestamp
Make it more clear, what the current monotonic_timestamp is and
what's it's offset to CLOCK_BOOTTIME.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-31 13:28:42 +01:00