Commit Graph

198 Commits

Author SHA1 Message Date
Thomas Haller
fca51f3717 core: add nm_utils_get_monotonic_timestamp_* functions
https://bugzilla.gnome.org/show_bug.cgi?id=720833

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-30 19:51:45 +01:00
Thomas Haller
63075d98a5 core: add nm_utils_ascii_str_to_int64() function
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-01-22 12:12:02 +01:00
Thomas Haller
4dd6ab8f4b libnl-util: refactor nm_utils_ip4_prefix_to_netmask/netmask_to_prefix
- use a more efficient implementation for prefix_to_netmask
- fix netmask_to_prefix to behave consistently in case of
  invalid netmask
- remove unused duplicated functions from NetworkManagerUtils.c
- add test functions

Based-on-patch-by: Pavel Šimerda <psimerda@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
Related: https://bugzilla.gnome.org/show_bug.cgi?id=721771
2014-01-10 13:34:57 -06:00
Dan Williams
befa9083e8 core: fuzzier matching of generated connections to persistent ones
When generating a connection, if the device has no non-link-local IPv6
address, then it's unclear whether (a) the connection was link-local
originally, or (b) the connection was 'auto' but IPv6 failed or timed
out.

In this case, if there is a persistent connection that is 'auto' but
the generated connection is 'link-local', the persistent connection
should be used.

Add a more-testable framework for doing the connection matching to
handle this.
2013-12-05 17:09:46 -06:00
Dan Williams
12d96c30f2 core: capture DNS configuration from resolv.conf when generating connections
If the interface who's IP configuration is being captured has the default
route, then read DNS servers from resolv.conf into the NMIP[4|6]Config.

This allows NetworkManager to repopulate resolv.conf if anything changes.
For example, if the system does not define a persistent hostname, then
when a device which has generated a connection activates, a hostname
lookup will be performed.  The results of that lookup may change resolv.conf,
and thus NetworkManager must rewrite resolv.conf.  Without capturing
DNS information at startup when generating connections, an empty
resolv.conf would be written.
2013-11-22 15:01:10 -06:00
Dan Winship
7bc7da83ec core: remove redundant sysctl utilities
NMDevice was still using the old sysctl functions from
NetworkManagerUtils rather than the new NMPlatform ones. Fix it, and
remove the old functions.
2013-11-15 10:49:43 -05:00
Dan Winship
f03635e5ac core: don't have IP4 and IP6 configs on slaves
Although it's convenient in some places to have IP configs on all
connections, it makes more sense in other places to not have IP
configs on slaves. (eg, it's confusing for nmcli, etc, to report a
full NMSettingIP4Config on a slave device). So revert parts of the
earlier patch. However, it's still safe to assume that s_ip4 != NULL
if method != DISABLED, so some of the earlier simplifications can
stay.

Also, add nm_utils_get_ip_config_method(), which returns the correct
IP config method for a connection, whether the connection has IP4 and
IP6 settings objects or not, and use that to keep some more of the
simplifications from the earlier patch.
2013-10-14 12:07:37 -04:00
Dan Winship
68f12b4e9c settings: make connections always have s_ip4 and s_ip6
Make sure that all connections returned from NMSettings or created via
AddAndActivateConnection have an NMSettingIP4Config and an
NMSettingIP6Config, with non-NULL methods, and get rid of
now-unnecessary checks for those.

Also move the slaves-can't-have-IP-config checks into the
platform-independent code as well. This also gets rid of spurious
"ignoring IP4/IP6 configuration" warnings in ifcfg-rh when reading a
slave ifcfg file.

Partly based on a patch from Pavel.

https://bugzilla.gnome.org/show_bug.cgi?id=708875
2013-10-11 12:24:34 -04:00
Jiří Klimeš
713755780f core: don't use deprecated 'security' property of wifi setting
That means replacing/removing
- nm_setting_wireless_get_security() function
- NM_SETTING_WIRELESS_SEC property
2013-09-02 09:46:31 +02:00
Pavel Šimerda
7dcec4d100 trivial: move back nm_match_spec_string()
Was moved by accident.
2013-07-04 20:20:27 +02:00
Pavel Šimerda
7967a6524a trivial: move a couple of functions to nm-ip[46]-config
Note that this patch doesn't effectively change any code.

Functions moved from nm-system:

* nm_system_apply_ip?_config → nm_ip?_config_commit
* ip?_dest_in_same_subnet → nm_ip?_config_destination_is_direct

Functions moved from NetworkManagerUtils:

* nm_utils_merge_ip?_config → nm_ip?_config_merge_setting

Functions renamed (and moved down to form one group):

* nm_ip?_config_new_for_interface → nm_ip?_config_capture

(The rationale for the rename is that from the achitectural point of
view it doesn't matter whether the function creates a new object or
updates an existing one. After the rename, it's obvious that
nm_ip?_config_capture() and nm_ip?_config_commit() are counterparts of
each other.)
2013-07-03 16:12:23 +02:00
Dan Winship
d575381c28 settings: fix unmanaging of InfiniBand devices
ifcfg-rh didn't let you unmanage an InfiniBand device by hardware
address because it was recording the hardware address with uppercase
letters, while nm_match_spec_hwaddr() required lowercase. Fix this by
making nm_match_spec_hwaddr() match case-insensitively (and remove the
manual lowercasing that several other places were doing to work around
this.)

keyfile didn't let you unmanage an InfiniBand device by hardware
address because it only accepted ARPHRD_ETHER hardware addresses. Fix
that by using nm_utils_hwaddr_valid() instead.
2013-06-13 15:52:51 -03:00
Dan Winship
0b815ca166 config: add NMConfigDevice
Add NMConfigDevice, which is mostly just a wrapper around
nm_device_get_hw_address() and nm_device_spec_match_list(), and
implement it in NMDevice. This will be used for config options that
match devices. (We can't use NMDevice directly for dependency
reasons.)
2013-04-03 10:23:48 -04:00
Dan Winship
c308e75b92 core: allow marking a device unmanaged by its interface name
Virtual devices often don't have stable hardware addresses. So allow
for marking a device unmanaged via its interface name instead.

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 16:45:19 -04:00
Dan Williams
a11771dfe6 core: preserve errno in nm_utils_do_sysctl()
Callers may need the error to determine their course of action
in response to a failure.
2013-02-04 10:37:46 -06:00
Dan Williams
43952e28c2 core: fix writing blank sysctl values
Sometimes we need to write blank values.
2013-02-04 10:37:45 -06:00
Dan Williams
a021e40e33 core: fix semantics of nm_utils_do_sysctl()
This function gets used for both /proc/sys (ie, sysctl) and for
sysfs attributes.  There are two issues with it:

1) most sysctl values don't care about a trailing LF, but some
sysfs attributes (infiniband) do; so we always have to add the
trailing LF.  Just move that into the function to ensure that
callers don't forget to add it.

2) neither sysfs or sysctl support partial writes, while the
existing function did partial writes.  Practically, both the
write handlers for sysfs and sysctl should always handle all
the data, but if they don't, partial writes are wrong.  So
instead, try three times to write all the data.
2012-11-30 13:21:50 -06:00
Dan Winship
6878d20ac4 all: Don't use ctype.h macros
The ctype macros (eg, isalnum(), tolower()) are locale-dependent. Use
glib's ASCII-only versions instead.

Also, replace isascii() with g_ascii_isprint(), since isascii()
accepts control characters, which isn't what the code wanted in any of
the places where it was using it.
2012-09-26 12:14:37 -04:00
Dan Winship
74b6b9c768 libnm-util: move nm_utils_is_uuid() here
This is useful outside the daemon too, so move it into libnm-utils.
2012-09-26 12:14:37 -04:00
Dan Williams
cf255aa83b core: split dispatcher into its own file 2012-09-11 17:06:16 -05:00
Dan Williams
f3b7e71b34 core: fix compat VLAN interface addition when interface already exists
If the interface already exists, the compat code would fail.  Fix that
and clean up the function.  Also double-check that an existing VLAN
interface that has the name we expect also has the master and VLAN
ID we expect.
2012-08-06 13:05:05 -05:00
Jiří Klimeš
78dda3b093 core: unblock signals for child processes we spawn out of NM (rh #739836)
Commit 217c5bf6ac fixed processing of unix
signals: signals are blocked in all threads and a dedicated thread handles the
signals using sigwait().
However, the commit forgot that child processes inherit signal mask as well.
That is why we have to unblock signals for child processes we spawn from NM, so
that they can receive signals.
2012-05-21 15:00:51 +02:00
Jiří Klimeš
5238aa4107 utils: override VPN plugin's never-default when ignoring auto routes (rh #804563)
Setting never-default ito TRUE when VPN server provides routes was done
in https://bugzilla.gnome.org/show_bug.cgi?id=621698
2012-03-20 17:17:49 +01:00
Dan Williams
57b77b10b6 core: fix parent/master confusion in some argument names
It's the parent, not the master, that we care about here.
2012-03-01 17:40:17 -06:00
Jiří Klimeš
785b6fb807 utils: more flexible reading of /proc/sys/net
- changes nm_utils_get_proc_sys_net_value() to allow all values, not just 0,1
- adds nm_utils_get_proc_sys_net_value_with_bounds() for limiting valid values
2012-02-27 16:27:44 +01:00
Dan Williams
b35afe4d0f core: automatically create VLAN interfaces when needed 2012-02-16 15:20:50 -06:00
Dan Williams
fcce9daa15 core: add utility function nm_utils_is_uuid() 2012-02-16 15:20:50 -06:00
Thomas Graf
5b7503e95e core: use nm_connection_get_setting_<type>() whenever possible
Leads to shorter, easier to read code and improves type casting safety.

Signed-off-by: Thomas Graf <tgraf@redhat.com>
2011-12-06 16:06:43 -06:00
Dan Williams
21fab21ec0 trivial: remove some unused includes 2011-12-02 13:30:08 -06:00
Dan Winship
2510c617ec libnm-util: add ether_ntoa/ether_aton-like utility methods
nm_utils_hwaddr_ntoa() and nm_utils_hwaddr_aton() are like
ether_ntoa()/ether_aton(), but handle IPoIB too.

nm_utils_hwaddr_atoba() is like _aton() but returns a GByteArray,
since that's what's wanted in many places.

Also remove nm_ether_ntop() and replace uses of it with
nm_utils_hwaddr_ntoa().
2011-11-17 13:37:08 -06:00
Dan Williams
88cd34feef core: remove unused includes 2011-07-22 12:50:54 -05:00
Dan Williams
5cf1addbdf core: add utility function to get a connection's shared wifi permission
If the connection is a shared wifi connection, return the appropriate
permission the user must obtain to use the connection.
2011-07-01 15:41:00 -05:00
Dan Williams
74d798b6dd dispatcher: pass DHCP options as string:string hash
This is what was originally intended, but the NM-side code wasn't
doing this due to an oversight...
2011-05-11 16:01:12 -05:00
Dan Williams
f898dbf1a9 dispatcher: enhance dispatcher script environment (bgo #648382)
For VPN connections, the interface name would be that of the VPN's
IP interface, but the script environment would be the that of the
VPN's parent device.  Enhance the environment by adding any VPN
specific details as additional environment variables prefixed by
"VPN_".  Leave the existing environment setup intact for backwards
compatiblity.

Additionally, the dispatcher never got updated for IPv6 support,
so push IPv6 configuration and DHCPv6 configuration into the
environment too.

Even better, push everything the dispatcher needs to it instead
of making the dispatcher make D-Bus requests back to NM, which
sometimes fails if NM has already torn down the device or the
connection which the device was using.

And add some testcases to ensure that we don't break backwards compat,
the testcases here were grabbed from a 0.8.4 machine with a hacked up
dispatcher to dump everything it was given from NM.
2011-05-02 22:54:28 -05:00
Jiří Klimeš
c207d020f7 core: use nm_connection_get_id() and nm_connection_get_uuid() to simplify code 2011-03-08 13:41:28 +01:00
Dan Williams
a4ab74d903 core: don't autocomplete non-IPv6-capable connections with IPv6 enabled
Mobile broadband and PPPoE don't yet support IPv6, so don't enable
IPv6 on these connections when completing them.
2011-02-25 11:58:16 -06:00
Dan Williams
b712274e86 core: fix dbus-glib crash on shutdown with systemd
It's really dbus-glib's fault, but the problem seems to be that when
short-lived D-Bus calls are made (with dbus_g_proxy_call_no_reply)
and the service is activated, then quits immediately like the
dispatcher does, there's not enough time for internal dbus-glib
housekeeping.  The GetNameOwner call that's kicked off when the
DBusGProxy is created hasn't returned by the time the proxy is
being unrefed, so the proxy doesn't end up on the
unassociated_proxies list.  But when the proxy is destroyed, and
it destroys it's DBusGProxyManager, the manager expects that
the proxy is on unassociated_proxies.  Thus the crash.

I'm not entirely sure why we hit this only at shutdown with
systemd; it could be that systemd is killing the bus daemon at
the same time as we're running the dispatcher and that's why the
GetNameOwner call doesn't complete.

Work around all this by expecting a message return, which works fine
during normal operation, but on shutdown allows us to avoid urefing
the proxy until everything in dbus-glib has been handled, which at
shutdown time really just means leaking it.  But then we exit, so
it's cleaned up anyway.
2011-02-21 17:18:41 -06:00
Dan Williams
e68e27aa75 libnm-util: add 'flags' argument to nm_connection_to_hash() and nm_setting_to_hash()
Simplifies code internally, and makes it easier for clients as well in
some cases where they want to control what ends up in the resulting
hash and what does not.
2011-01-26 14:14:37 -06:00
Dan Williams
53766ae291 core: move generic connection complete function to a generic location
Out of NMDevice specific places to the utils code, so it can be used
more easily from everywhere.  There's nothing device-specific about
it anyway.
2011-01-13 13:28:52 -06:00
Daniel Gnoutcheff
fb96309899 DBus: merge NetworkManger{,SystemSettings}
Remove the org.freedesktop.NetworkManagerSystemSettings bus name and
have everybody talk to org.freedesktop.NetworkManager. Now that we have
a single settings service that's embedded in the main daemon, we don't
need separate names anymore.
2010-08-07 01:19:46 -04:00
Daniel Gnoutcheff
5fda5283b9 core: remove internal API refs. to user settings
Remove all references to connection scope and user-settings services
from the various internal APIs of the daemon. The external DBus API
remains unchanged, albeit in stub form for scope stuff.
2010-08-06 13:05:46 -04:00
Dan Williams
0b41797b49 s390: replace 'zvm' with s390
ZVM isn't the right terminology here.  s390 is.
2010-06-17 21:24:14 -07:00
Dan Williams
5f03706a6b ethernet: handle zvm-subchannels unmanaged spec (rh #591533) 2010-05-26 16:28:51 -07:00
Dan Williams
d9cca49784 logging: silence ignorable warning
Since the NMDevice's interface isn't always the same as a kernel
interface name, we won't always have an entry in /proc/sys/net for it.
2010-05-04 16:12:52 -07:00
Dan Williams
7926b3ca95 ip6: turn RA acceptance off when RAs shouldn't be used (rh #588163)
Make sure we don't inadvertenly let the kernel assign an RA address
when connections that don't allow RA are used.
2010-05-03 03:42:43 -07:00
Dan Williams
1f1a28ae20 core: update logging in misc files 2010-04-07 12:28:57 -07:00
Dan Williams
4af1cc2661 utils: add boolean value hash helper 2010-03-16 23:51:55 -07:00
Dan Winship
fc8e609784 Initial IPv6 support (only handles "manual" and "ignore" currently) 2009-07-29 21:35:01 -04:00
Dan Williams
fa2bde265e core: kill nm_print_device_capabilities() 2009-07-07 14:38:55 -04:00
Dan Williams
c9067d8fed everything: use libgudev instead of HAL; merge NM and nm-system-settings
The only thing that doesn't work yet is the system-settings service's
"auto eth" connections for ethernet devices that don't have an existing
connection.  Might also have issues with unmanaged devices that can't
provide a MAC address until they are brought up, but we'll see.
2009-06-11 00:39:12 -04:00