Commit Graph

4279 Commits

Author SHA1 Message Date
Dan Winship
57b0ed4154 settings: clarify that NMDefaultWiredConnection is ethernet-only
NMSettings would try to create an NMDefaultWiredConnection for any
NMDeviceWired subclass, and there was some code to deal with
InfiniBand in the code. But nm_default_wired_connection_new() required
the hwaddr length to be ETH_ALEN, so InfiniBand would never have
worked (and probably shouldn't have, since people generally don't want
the auto-default behavior on servers anyway). And we certainly never
intended for this code to apply to bridges and bonds. So fix it to
only apply to ethernet devices, and remove the vestigial
InfiniBand-related code.
2013-04-03 10:23:48 -04:00
Dan Winship
b3e8361f0f settings: don't pass config_path to NMSettings and settings plugins
They can just call nm_config_get() now to get the config, and
nm_config_get_path() to get its path.
2013-04-03 10:23:48 -04:00
Dan Winship
26de9db14b core: remove some can't-happen checks
Most of the various nm_foo_manager_get/new() calls never return NULL,
so just g_assert() that fact rather than logging a separate error
message for each one.
2013-04-03 10:23:48 -04:00
Dan Winship
213a3a4d2e core: don't pass config data to NMDHCPManager and NMDnsManager
Rather than passing specific bits of data to NMDHCPManager and
NMDnsManager, just let them call nm_config_get() and then get the data
themselves.

Also, remove the GError argument from nm_dhcp_manager_new(), since the
function never returned NULL. This in turn means there is no longer
any need for a distinction between nm_dhcp_manager_new() and
nm_dhcp_manager_get(), so remove the former.
2013-04-03 10:23:48 -04: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
29ed892de7 config, man: hide connectivity-check command-line options
There is no reason to configure the connectivity-check options from
the command line rather than from the config file. Keep the options,
for backward-compatibility, but remove them from the man page and hide
them from --help.
2013-04-03 10:23:48 -04:00
Dan Winship
8bb9ee8d3b config: fix documentation of --log-domains
The list of log domains in the --log-domains documentation had gotten
out of date. Fix this by adding nm_logging_all_domain_to_string()
(and, for completeness, nm_logging_all_levels_to_string()), and use
those to fill in the help string.
2013-04-03 10:23:47 -04:00
Dan Winship
3407726758 config: move config-related command-line options into nm-config.c
Rather than having main.c parse them and then hand them all to
nm_config_new(), just let nm-config provide its own GOptionEntry
array to merge in with main's.
2013-04-03 10:23:47 -04:00
Dan Winship
4a7727d93a config: make NMConfig non-refcounted
It's a singleton that always exists. Callers shouldn't have to
refcount it.

Also, move its cleanup code from dispose() to finalize(), and remove
some unnecessary checks in it.
2013-04-03 10:23:47 -04:00
Dan Winship
53bd84feff config: move NMConfig into its own subdirectory/library
Also, remove the unused NMConfigError, and add a config-parsing test
program.
2013-04-03 10:23:47 -04:00
Dan Winship
228f6459e1 dns-manager: remove an incorrect and unnecessary line
gcc 4.8.0 has a new warning that triggers on

    static void
    compute_hash (NMDnsManager *self, guint8 buffer[HASH_LEN])
    {
        ...
        memset (buffer, 0, sizeof (buffer));
        ...
    }

because "sizeof (buffer)" is *not* HASH_LEN, it's sizeof(guint8*). The
memset() was not necessary anyway since the g_checksum_get_digest()
after it will always end up filling in buffer, so just remove it.

https://bugzilla.gnome.org/show_bug.cgi?id=697041
2013-04-02 16:15:06 -04:00
Pavel Šimerda
eb2b990ddc trivial: rename rand to avoid -Wshadow 2013-04-02 11:03:47 +02:00
Jiří Klimeš
2109f41cc6 libnm-util: consolidate hex-string <-> bin conversion functions
and move them to libnm-util's nm-utils.s so that they are easily available.
2013-03-28 16:59:58 +01:00
Dan Williams
5d6d5cd136 dhclient: copy leasefiles from old location if needed (rh #916233) (bgo #696210)
When the default leasefile location got moved from distro-specific
dhclient locations to a single NM-specific location, that apparently
broke scripts and external tools that depended on the old location,
like dract netbooting.

During a netboot, DHCP is started from the initramfs and gets a
lease, and the leasefile lives in the initramfs.  When the real
system is started, and the rootfs switches from the initramfs to
the actual rootfs, something needs to copy the leasefiles over to
where NetworkManager can find them.  For dracut at least, various
dracut scripts were doing this, and copying to the old location
in /var/lib/dhclient or /var/lib/dhcp.  Which means NM can no
longer find them, and proceeds to acquire a new DHCP lease when
taking over the existing connection, rather than renewing the
existing lease.  This can lead to loss of network connectivity
and thus the netboot process fails.

If no leasefile for the connection in the new location exists,
look in the old locations and copy that leasefile over to the new
location.
2013-03-26 15:26:18 -05:00
Dan Williams
e8cbde2704 mobile: clarifiy modem state change log message
Otherwise it looks like it might be the NMDevice state change, which
it isn't.
2013-03-25 15:56:06 -05:00
Dan Williams
6ef543d3a6 mobile: downgrade MM launch failure warning severity to debug
MM won't always be present, and if it's not, your logs will fill up
with warnings about MM not being able to be launched.  And when
running with systemd, you'll get a different class of errors like:

<warn> error poking ModemManager: GDBus.Error:org.freedesktop.systemd1.LoadFailed:
   Unit dbus-org.freedesktop.ModemManager1.service failed to load: No such file or
   directory. See system logs and 'systemctl status
   dbus-org.freedesktop.ModemManager1.service' for details.

and I'm tired of chasing and special-casing all the launch-failed
errors that D-Bus and systemd use.

Plus, we have dynamic log level changing via the D-Bus interface so if
people need to debug this, just chaning the log level will tell you
what's wrong.
2013-03-25 15:38:00 -05:00
Dan Williams
824fd06c34 ppp: ignore errors getting final PPP stats
The PPP interface may be gone already, especially if the connection
was terminated by the PPP peer.  It's pointless to warn in these
cases since getitng the final stats is best-effort anyway.
2013-03-25 15:26:51 -05:00
Dan Williams
f515df39b5 core: don't crash checking unmanaged specs if device has no hardware address
Not all devices have a hardware address, like WWAN or ADSL.  So don't
unconditionally expect one.
2013-03-25 15:17:35 -05:00
Jiří Klimeš
82fb1978a4 all: use G_VALUE_INIT to initialize GValue variables
It makes the initializations more explicit.
G_VALUE_INIT is available since glib 2.30, and NM now require glib >= 2.32
2013-03-25 08:41:18 +01:00
Dan Williams
360a02fc13 ifcfg-rh: ensure missing STP property is interpreted as "off" (rh #922702)
The initscripts interpreted it this way, so we do too.
2013-03-22 09:13:12 -05:00
Dan Williams
c934038b59 dhcp: fix up testcase for "also request static-routes;" 2013-03-21 13:20:13 -05:00
Dan Williams
0bf0ee7136 dhcp: look harder for machine-id, and generate random DUID if it doesn't exist (bgo #696109)
Not all systems have machine-id in /etc, some still have it in /var/lib/dbus/
especially if they aren't using systemd.  Furthermore, if we don't have
any machine-id file (like in the future, if we don't have a messaebus
daemon running) fall back to a random DUID as a last resort.
2013-03-20 11:28:53 -05:00
Dan Williams
3e293e1101 dhcp: we don't always have an NMSettingIP6Config for the DHCP hostname
Prevents:

NetworkManager[19405]: nm_setting_ip6_config_get_dhcp_hostname: assertion `NM_IS_SETTING_IP6_CONFIG (setting)' failed
2013-03-20 11:28:22 -05:00
Dan Williams
bd636ffb40 dbus: reinstall property filter on dbus connection changes (rh #918273)
Like if the dbus daemon restarts; in this case the connection has changed
and the new connection doesn't have the filter installed, and libdbus
aborts when we try to remove a filter that doesn't exist on the connection.
Fix that by re-adding the filter when the connection changes.
2013-03-20 08:51:08 -05:00
Dan Fruehauf
edd1ebe8a0 dbus: allow talking to the NetworkManager-SSH VPN plugin 2013-03-20 08:28:14 -05:00
Jiří Klimeš
a96053fe13 dhclient: also request 'static-routes' option from DHCP server (rh #922558)
DHCP server won't send 'Static Route' option to the client if it is not
explicitly requested.
2013-03-20 10:00:42 +01:00
Dan Williams
6551e9bbc4 core: don't fail IPv6 if otherconf/info-only DHCPv6 fails
Just like we don't fail IPv4 if DHCP fails to get DNS servers,
don't fail IPv6 if we've already got an RA and for some reason
DHCPv6 fails.  otherconf/info-only DHCP is not mandatory, and
lack of results thus should not fail the entire IPv6 config,
since DNS servers can also be passed in the RA.

RFC4861:

1-bit "Other configuration" flag.  When set, it
indicates that other configuration information is
available via DHCPv6.  Examples of such information
are DNS-related information or information on other
servers within the network.
2013-03-14 13:57:52 -05:00
Jiří Klimeš
df1a1bf69e keyfile: fix reading unmanaged-devices for interface name
[keyfile]
unmanaged-devices=interface-name:eth0
2013-03-14 12:03:47 +01:00
Pavel Šimerda
a290c5c3a6 Revert "trivial: remove nm-netlink-monitor.h from main"
This reverts commit 272335a2cf.

Done by mistake. Sorry.
2013-03-13 23:52:14 +01:00
Pavel Šimerda
272335a2cf trivial: remove nm-netlink-monitor.h from main
nm-netlink-monitor is deprecated and the only consumer that still uses
it is nm-ip6-manager, which will start it on its own.

Conflicts:
	src/main.c
2013-03-13 23:08:06 +01:00
Pavel Šimerda
fa86a377a0 main: don't activate nm-netlink-monitor
It will be activated by the first module that needs it.
2013-03-13 22:15:37 +01:00
Pavel Šimerda
363dece23b netlink: don't ref/unref the singleton 2013-03-13 22:15:29 +01:00
Dan Winship
d9e87d933b core: document some NMDevice methods 2013-03-13 16:45:19 -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 Winship
611df342af core: make nm_device_check_connection_compatible() check interface-name
If an NMConnection specifies an interface-name, it is only compatible
with a device with the same iface.

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 16:45:19 -04:00
Dan Winship
cda65e1802 settings: read/write NMSettingConnection:interface-name
https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 16:45:18 -04:00
Dan Winship
1cc367711d core: simplify nm_device_get_best_auto_connection()
As with the other connection-matching methods, move the loop and the
device-independent bits into NMDevice. By reusing
nm_device_check_connection_compatible(), this means that most device
types now no longer need any type-specific code for this.

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 13:21:59 -04:00
Dan Winship
971bab01ea core: simplify/rename nm_device_connection_match_config()
nm_device_connection_match_config() sounded more generic than it
really was; rename it to nm_device_find_assumable_connection(), which
is what it really does.

There was also a lot of redundancy/cut+paste in the subclass
implementations of connection_match_config(); Improve things by moving
the looping-over-connections code into NMDevice itself, and also doing
the general-device-compatibility and IP-config checking there, leaving
the device subclasses to just verify L2 properties. Which most of them
aren't doing...

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 13:21:59 -04:00
Dan Winship
a3f6af817b core: simplify nm_device_spec_match_list()
Since NMDevice has a generic get_hw_address() method now, it can do
nm_device_spec_match_list() itself (for everything except ethernet,
which needs to match against s390 subchannels too).

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 13:21:59 -04:00
Dan Winship
1a8790b2a0 core: fix NMDeviceEthernet matching
nm_device_connection_match_config() on an ethernet connection could
succeed for a device that was in the connection's
mac-address-blacklist, but then NM would immediately fail to activate
the connection because nm_device_connection_compatible() would check
the blacklist and return FALSE. Fix the former to match the latter.

https://bugzilla.gnome.org/show_bug.cgi?id=693684
2013-03-13 13:21:59 -04:00
Jiří Klimeš
cc66b547cf device: do not call nm_system_iface_set_up() with invalid index (rh #920145)
in hw_take_down()

usb 1-3: USB disconnect, device number 6
modem-manager[547]: <info>  (tty/ttyACM0): released by modem /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-3
<info>  (tty/ttyACM0): released by modem /sys/devices/pci0000:00/0000:00:1a.7/usb1/1-3
<info> (ttyACM0): device state change: disconnected -> unmanaged (reason 'removed') [30 10 36]
<info> (ttyACM0): cleaning up...
<info> (ttyACM0): taking down device.
nm_system_iface_set_up: assertion `ifindex > 0' failed
2013-03-13 09:34:51 +01:00
Pavel Šimerda
b4954be855 modem: it is not a problem to flush IPv6 global routes
Whether they are supported or not. We already remove all addressess.
2013-03-12 18:48:34 +01:00
Jiří Klimeš
8e748bced8 core: fix find_vlan_parent() to return proper device (bgo #695362)
when VLAN parent device is identified through a connection UUID
2013-03-12 18:01:11 +01:00
Jiří Klimeš
0e92228476 trivial: remove extra semicolons 2013-03-12 09:32:47 +01:00
Dan Williams
c636fe88e3 config: rename fill_from_file() to read_config() 2013-03-11 14:45:12 -05:00
Dan Williams
875c1af2fd core: use Config object for connectivity checking parameters 2013-03-11 14:45:12 -05:00
Dan Williams
2e0fead744 config: fix bounds of connectivity_interval values
0 means "turn off connectivity checking", so we can't use that to
determine whether or not the interval has already been set by
command-line options or not.  Instead, store the interval
internally as a signed int and use -1 to mean "not yet set".

Second, validate input values for interval to ensure they can't
be less than 0 or more than G_MAXINT.
2013-03-11 14:45:11 -05:00
Jonh Wendell
06dca1b056 config: honor CLI arguments when config file is not found
If no config file was present, the Config object is returned empty
even if some options were passed via the command-line.
2013-03-11 14:44:47 -05:00
Dan Williams
f378c10e01 trivial: move NMConfig GObject functions to the bottom
More closely match the style of other objects in NM, where the
actual logic is nearer the top, and GObject stuff is near the bottom.
2013-03-11 14:44:46 -05:00
Thomas Bechtold
c910a52241 config: convert NMConfig to object 2013-03-11 14:43:24 -05:00