Commit Graph

9141 Commits

Author SHA1 Message Date
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
Dan Williams
20483d65ae core: add nm_ip4_config_address_exists() and nm_ip6_config_address_exists() 2013-11-08 16:46:44 -06:00
Dan Williams
afcc4f2a25 core: read gateway when capturing IP configs 2013-11-08 16:46:44 -06:00
Dan Williams
048052cb6e dhcp: make dhclient lease parsing code testable 2013-11-08 16:46:43 -06:00
Dan Williams
11e17856c9 dhclient: fill IPv4 config more completely when reading lease files 2013-11-08 16:46:43 -06:00
Dan Williams
15f9a27d2e platform: clarify that address lifetimes are in seconds 2013-11-08 16:46:43 -06:00
Dan Williams
f7645f4ab4 dhclient: simplify lease expiration checking
Use GDateTime instead of open-coding it.
2013-11-08 16:46:43 -06:00
Dan Williams
e2fa51cd67 dhcp: rename get_lease_config -> get_lease_ip_configs
Since dhcpcd doesn't implement this function yet, just remove the
stub implementation.
2013-11-08 16:46:43 -06:00
Pavel Šimerda
21b6f34f5e platform: avoid one bug warning 2013-11-08 16:46:43 -06:00
Pavel Šimerda
10f9b6c58b core: support slave devices in nm_platform_generate_connection()
Ask each device class to update the slave configuration for their
type of slave.
2013-11-08 16:46:43 -06:00
Dan Williams
60b88d526c core: slaves should have empty captured IP configuration 2013-11-08 16:46:43 -06:00
Dan Williams
b54a9868fd core: clean up legacy connection matching; remove match_l2_config
All previous users of this API are gone, so remove it.
2013-11-08 16:46:22 -06:00
Dan Williams
ab586236e3 core: implement update_connection() for Team 2013-11-08 16:35:18 -06:00
Dan Williams
1609b32dd9 core: implement update_connection() for Infiniband
FIXME: implement partition support
2013-11-08 16:34:57 -06:00
Dan Williams
0626fe37d0 core: implement update_connection() for Generic devices
tun/tap, macvlan, and GRE devices may be bridge, bond, or team slaves
and should get that configuration detected at startup.
2013-11-08 16:38:49 -06:00
Pavel Šimerda
142bca6504 core: implement update_connection() for VLANs 2013-11-08 16:38:49 -06:00
Pavel Šimerda
c90730fa43 core: implement update_connection() for bonds 2013-11-08 16:38:49 -06:00
Pavel Šimerda
a3af5cfe9d core: implement update_connection() for bridging 2013-11-08 16:38:48 -06:00
Dan Williams
12fb2519af core: add nm_connection_provider_get_connection_by_uuid() 2013-11-08 16:38:48 -06:00
Dan Williams
c23e1bbb44 ifcfg-rh: 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-08 16:38:48 -06:00
Dan Williams
6b6265ebeb team: fix possible crash by ensuring teamd context is cleared
teamd_cleanup() might get called multiple times, and since the rest
of the function is safe against multi-calls, make priv->tdc safe
against being called again too.
2013-11-08 15:35:48 -06:00
Thomas Haller
788eed99de core: workaround crash when connecting to wifi (rh #1025371)
rh #1025371 reports a crash in handle_ip_config_timeout() because
nm_device_wifi_get_activation_ap() did not return any access point.

The handling of the AP in nm-device-wifi.c should be reworked and soon
will be fixed. For now, play it safe, and try to cope with any cases
where nm_device_wifi_get_activation_ap() might return NULL.

Later, this patch should be reverted and handling of the AP properly
cleaned up.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-08 18:11:50 +01:00