Commit Graph

8762 Commits

Author SHA1 Message Date
Dan Winship
29dc6d1ebe devices: clean up accept_ra/use_tempaddr handling
update_accept_ra_path() and update_ip6_privacy_save() were freeing
their path variables if they failed to read the existing values, but
if this ever actually happened it would cause problems later since
other code assumed that the variables were always set. Use
"priv->ip6_accept_ra_save = -1", etc, instead to indicate that the
value couldn't be read (and so shouldn't be restored later).

Merge the accept_ra and use_tempaddr code save/restore code together,
since they're always called together.

Fix the accept_ra-restoring code to correctly handle an original value
of "2".

Call update_ip6_properties_paths() from nm_device_set_ip_iface()
rather than act_stage3_ip6_config_start(), since set_ip_iface() is
when the paths actually change. Also, split the default-value-saving
code out into a separate function, since we only care about doing that
at construct time; if the IP6 property paths change later (because
iface != ip_iface), then we don't need to save and restore the values
on the ip_iface, since the interface will go away when we're done with
it.

https://bugzilla.gnome.org/show_bug.cgi?id=700414
2013-11-15 10:49:43 -05:00
Dan Winship
ee2b50fce8 devices: rename ip6_privacy_tempaddr_* vars to match sysctl
Rename ip6_privacy_tempaddr_path and ip6_privacy_tempaddr_save to
ip6_use_tempaddr_*, to match the sysctls, for consistency with the
accept_ra variables.
2013-11-15 10:49:43 -05:00
Dan Winship
46295e8fa1 devices: "deactivate" devices when going from UNMANAGED->UNAVAILABLE
We used to call nm_device_deactivate() when moving a device from
UNMANAGED to UNAVAILABLE (unless we were assuming the existing
connection), but this got lost when default-unmanaged was added. Fix
it to do this again, so the device will be in a known-clean state when
it is activated.
2013-11-15 10:49:43 -05: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
1981323b19 libnm-glib: fix a crash in NMObject
deferred_notify_cb() needs to take a ref on the object around emitting
its deferred signals, since otherwise if a notify:: handler drops the
last reference on an object, a following g_object_notify() call would
crash.
2013-11-14 13:01:55 -05:00
Dan Williams
6a75c9b8e8 core: allow default wired connections to stay up when quitting
Previously, the default wired connection was removed on quit when the
device was cleaned up.  This is inconsistent with other connections.
Leave the default wired connection up when quitting to fix this
inconsistency.

This allows default wired connections to be assumed when NM starts.
2013-11-14 11:34:07 -06:00
Dan Williams
7a256b9a05 settings: simplify connection signal handling
No need to store the ID since we can use g_signal_handlers_disconnect_by_func()
2013-11-14 10:55:46 -06:00
Jiří Klimeš
9a019f1fb5 device: bind the generated loopback connection to 'lo' interface
It is useful to bind the loopack connection to the loopback interface,
and it also allows activating it.
$ nmcli con up lo

Else "Error: no device found for connection 'lo'" is returned, because
connection_compatible() in libnm-glib/nm-device-generic.c wants the
connection to have an interface-name set.
2013-11-14 13:53:44 +01:00
Jiří Klimeš
2a2af5825a cli: allow editing 'generic' connections 2013-11-14 13:53:44 +01:00
Jiří Klimeš
dbba05a3db cli: fix crash on editing 'lo' connection (rh #1030395)
https://bugzilla.redhat.com/show_bug.cgi?id=1030395
2013-11-14 13:53:21 +01:00
Dan Williams
2086cab127 platform: dump objects that fail to be added (rh #1029213)
Attempt to figure out why the objects fail.
2013-11-13 20:06:39 -06:00
Dan Winship
3c236c88eb core: fix re-activation of existing active connection
The change to allow an NMConnection to only be active on a single
device accidentally broke the case of re-activating a connection on
the same device. Fix that.
2013-11-13 13:35:41 -05:00
Dan Williams
49983db85e settings: convert NMDefaultWiredConnection into a plain NMSettingsConnection (rh #1029464) (bgo #712188)
Changing the default wired connection has always deleted the connection
(thus disconnecting the interface) and re-added it as a settings plugin
connection.  That was always sub-optimal, but until the 'unsaved' connection
stuff landed this summer, we couldn't do anything about that.  Clean
that all up, adding the connection as an unsaved connection right from
the start, which allows changes to the connection without having to
delete and recreate it, thus preventing disconnection of any interface
that is using the connection.

A new signal is added to NMSettingsConnection that is only emitted when
the connection is changed from D-Bus (thus indicating an explicit user-
requested change) since the connection may be modified internally by
NetworkManager.  NM-triggered changes should not result in the connection
no longer being a default-wired connection.

https://bugzilla.gnome.org/show_bug.cgi?id=712188
https://bugzilla.redhat.com/show_bug.cgi?id=1029464
2013-11-13 11:50:12 -06:00
Thomas Haller
709bc90b6b coverity: fix various warnings detected with Coverity (fixup)
I missed to implement the remarks from
https://bugzilla.redhat.com/show_bug.cgi?id=1025894#c4

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 18:43:18 +01:00
Thomas Haller
97935382f4 coverity: fix various warnings detected with Coverity
These are (most likely) only warnings and not severe bugs.
Some of these changes are mostly made to get a clean run of
Coverity without any warnings.

Error found by running Coverity scan

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Co-Authored-By: Jiří Klimeš <jklimes@redhat.com>
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
ab92a0d69c cli: fix reading IP config for *-slaves
Error found by running Coverity

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
0139ad37f7 cli: fix potential crash in nmcli when using strcmp
Error found by running Coverity

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
7fd4d35463 core: fix setting wifi quality
wifi_utils_get_qual returns -1 on error. Keeping it in an unsigned
variable is a bug.

Error found by running Coverity

https://bugzilla.redhat.com/show_bug.cgi?id=1025894

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:29:24 +01:00
Thomas Haller
d0abf65004 gsystem: update libgsystem to current upstream master
This brings a fix for Coverity scan warning

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:14:52 +01:00
Thomas Haller
bbddc0e18a cli: fix bash completion for curser not at EOL (2)
Previous commit had an error in the following case:
  $ nmcli connection modify  '  <TAB>     id

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 15:02:23 +01:00
Thomas Haller
93f5687d7b cli: fix bash completion for curser not at EOL
If the curser is not at the end of the line, we want to complete
by ignoring everything right of the curser. However, the variable
$cur is set to the spaces since the last word, so we have to
get rid of them first

Without this, the following did not complete:
  $ nmcli connection modify id   <TAB>  lo
because $cur is set to '  '.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-13 14:42:59 +01:00
Thomas Haller
ce370fab64 cli: add bash-completion for 'nmcli general hostname'
https://bugzilla.redhat.com/show_bug.cgi?id=1018510
2013-11-13 12:19:51 +01:00
Jiří Klimeš
79ac1cf089 cli: add support for getting/setting hostname to nmcli (rh #1018510)
https://bugzilla.redhat.com/show_bug.cgi?id=1018510
2013-11-13 12:19:51 +01:00
Thomas Haller
d95da820fc cli: tivial fixup whitespace in command description text
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-12 20:45:05 +01:00
Thomas Haller
ed60815d4c cli: improve handling of quoting in bash completion
_init_completion returns the '${words[@]}' array with all the
quotes and escapes. We dont care about it so we drop (unescape)
first.

Before, the following failed:

  nmcli 'c' <TAB>
  nmcli connection modify id Wireless\ Connection\ 1 <TAB>

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-12 18:49:03 +01:00
Dan Winship
0e5de01cc8 core: require secondary connections to be VPNs (rh #997039) 2013-11-12 09:44:28 -05:00
Jiří Klimeš
07bf4eb802 keyfile: don't crash when in-memory-only connections don't have paths
If the connection has never been saved to disk, it won't have a path yet,
but that doesn't mean we should crash.  Next, when reloading connections,
only try to do connection matching on connections that have paths, otherwise
all in-memory-only connections would be removed at the end of
read_connections().
2013-11-12 15:04:15 +01:00
Dan Williams
696f655d7c ethernet: don't crash if device doesn't have a MAC address (rh #1029053)
Like IBM s390 CTC devices, which aren't really ethernet but for
historical reasons we treat them as such.
2013-11-11 15:43:13 -06:00
Jiří Klimeš
4f3a9cca6f ifcfg-rh: do not un-escape value in TEAM_CONFIG, TEAM_PORT_CONFIG
Doing so may cause NetworkManager to run into an very intensive loop in
svUnescape() in shvar.c.

This is 'top' output for very long (invalid team config) - 9309865 bytes long:
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
26855 root      20   0  305m  35m 6092 R 99.8  0.9   8:08.11 NetworkManager

and still not finished.
2013-11-11 17:53:38 +01:00
Thomas Haller
6107a94099 cli: improve bash completion to complete -h and --help aliases
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-11 15:27:45 +01:00
Thomas Haller
c9cfbae12b cli: make command line parsing check for help option first
Move the checks for nmc_arg_is_help to the beginning of the
checks for command matches.

Up to now, no command begins with 'h', so this has no behavioral
change whatsoever. But imagine a command that begins with 'h'
(for example `nmcli general hostname`), in that case `nmcli general h`
should still show the help, as users might be accustomed to this
abbreviation.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-11 15:27:45 +01:00
Thomas Haller
93131b1df2 cli: fix in matching command line arguments
Ensure in matches() that a non-empty cmd is given, otherwise
as currently

  nmcli general -

matches to '-h' and is thus treated as

  nmcli general -h

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-11 15:27:30 +01:00
Thomas Haller
ccc912e870 rdisc: cleanup handling of NMRDisc->lladdr field
Release the previous instance when setting the lladdr property
and unref it in the desctructor.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-09 20:32:23 +01:00
Dan Williams
465458a206 merge: better take-over of existing connections on NM startup (bgo #702488)
Read more state of connections that exist before NM starts, and take those
connections over more effectively.

https://bugzilla.gnome.org/show_bug.cgi?id=702488
2013-11-08 16:52:33 -06:00
Dan Williams
f413911239 core: don't deactivate assumed connections when quitting
If an assumed bridge/bond/team/whatever happened to be in the process
of activating (perhaps it had no recognized slaves and was waiting for
them to continue with IP configuration) when NM quits, don't deactivate
the device and blow away the assumed configuration.
2013-11-08 16:46:45 -06:00
Dan Winship
6b7ebc0eb9 core: NMManager:state fixes for assumed connections, etc
Don't set NMManager:state to CONNECTING when assuming a connection,
since it's not actually "connecting".

If there are active connections, but none has the default route, then
the global state should be CONNECTED_LOCAL, not CONNECTED_GLOBAL.

Also tweak the semantics of CONNECTING/DISCONNECTING slightly; we only
set state to CONNECTING when connecting a new connection if we are not
already CONNECTED_GLOBAL, and we only set it to DISCONNECTING if we
will be DISCONNECTED afterward.
2013-11-08 16:46:45 -06:00
Dan Williams
0e2457d71d core: don't up devices during IP configuration stages
Assumed connections shouldn't require touching the device, and the
device should was already set IFF_UP during stage2 (which is
skipped for assumed connections).  Instead, what the code was really
trying to do, was to ensure tha the IP interface the device was
going to use was up.

The only cases where the IP interface might *not* be up after stage2
is where the IP interface is different than the device's interface,
like for Bluetooth, ADSL, WWAN, and PPPoE.  Move the call to
nm_platform_link_set_up() into nm_device_set_ip_iface() which all
those device types will call.

Thus, only the device types that really need to up their IP interface
will do so, but other devices (including when activating assumed
connections) that don't need to do this, won't do it.
2013-11-08 16:46:45 -06:00
Dan Williams
0d8015cc98 core: don't generate connections for some devices
If the device has no IP configuration, is not a slave, and is not
a master, there's no point in generating a connection for it and
assuming that connection.

Fixes a problem where tun devices created by vpnc would be activated
with an empty assumed connection before NetworkManager could assign
the VPN IP config to it, and since IPv6 link-local timed out, the tun
device would be deactivated and VPN would be useless.
2013-11-08 16:46:45 -06:00
Dan Williams
f815b0d31d core: use ignore/disabled IP methods for assumed connections without IP config
Follow the IP configuration the device currently has.  For IPv6, this means
not using LINK_LOCAL if the interface doesn't have a LINK_LOCAL address.
Otherwise, NM assumes too much and may begin to activate an interface that
has no IP configuration, then time out and deactivate that device.
2013-11-08 16:46:45 -06:00
Pavel Šimerda
ce810d3660 core: remove non-NM-created bridge workarounds
Handle bridges like any other devices since soon we'll be able to
take them over without changing their existing configuration.
2013-11-08 16:46:45 -06:00
Dan Williams
93ad84a498 core: slaves have configuration by definition
The mere fact that a device is a slave means it has configuration
that NetworkManager should try to read.
2013-11-08 16:46:45 -06:00
Dan Williams
76ca47e6b3 core: make assumed activations go through all the stages
Assumed slave connections need to be added to their master devices,
which didn't used to happen because the devices activating assumed
connections jumped directly to stage3, bypassing all the master/slave
handling stuff.

Instead, make all assumed connections go through all activation stages,
but make sure that things which touch the device don't get done for
assumed connections.  This requires moving the master/slave code out
of the override-able class methods because we need to call the
master/slave code for assumed connections, but we don't want to call
the override-able class activation methods.
2013-11-08 16:46:45 -06:00
Dan Williams
d6b9465b18 core: find assumed connection masters
If an assumed connection should have a master (bridge port, bond slave,
etc) it needs to notify its master that it's a slave.  Since slaves
are ordered after their masters at start, the master should already
have a generated connection which we can use as the master.
2013-11-08 16:46:44 -06:00
Dan Williams
61744d41bb core: add nm_active_connection_[get|set]_assumed()
Various code during the activation paths will want to know whether
the connection is assumed or not, so that it doesn't do stuff that
touches the device.
2013-11-08 16:46:44 -06:00
Dan Williams
e7567859c9 core: allow devices to activate their generated connections
If the device has a valid generated connection, it's already applied
and the device is already "activated" outside NM, so let activation
happen inside NM regardless of whether the device is available or not
according to NM.
2013-11-08 16:46:44 -06:00
Dan Williams
ffea69e06b trivial: refine connection generation logging 2013-11-08 16:46:44 -06:00
Thomas Haller
5023af9b84 platform: sort slaves after their master devices
Slaves should get sorted after their masters so that when generating
connections, the NMManager knows about the masters already.

The convoluted logic here is to ensure that:

1) the kernel doesn't pass bad information that causes NM to crash
or infinite loop

2) that with complicated parent/child relationships (like a VLAN interface
with a parent that is also a slave), children always get sorted after
*all* of their ancestors.  The previous code was only sorting children
after their immediate parent/master's ifindex, but not actually after
the parent in the returned list.
2013-11-08 16:46:44 -06:00
Dan Williams
8bb9a65c91 ethernet: handle cloned/permanent MAC when updating connection 2013-11-08 16:46:44 -06:00
Dan Williams
24995b2c96 core: don't generate connections for devices NM just created
No sense in doing that, since they were just created and can't possibly
have any relevant configuration yet.
2013-11-08 16:46:44 -06:00
Dan Williams
0321073b3c core: capture initial device DHCP IP configuration
At least gives us DNS servers and definite gateway.
2013-11-08 16:46:44 -06:00