Commit Graph

15047 Commits

Author SHA1 Message Date
Thomas Haller
8d3618a07b rdisc: emit config_change signal for update of address lifetime
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 18:07:38 +01:00
Thomas Haller
a032d82e2a core: refactor ip6_addr_to_string in nm-dns-dnsmasq
ip6_addr_to_string did assume, that inet_ntop might write a scope id to
the result. But it does not (and cannot, because struct in6_addr does
not have any interface identifer).

Simplify and rework the function.

Also fix a memory leak.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 17:21:22 +01:00
Thomas Haller
6f2cfe263e all: refactor to make use of nm_utils_inet[46]_ntop functions
https://bugzilla.gnome.org/show_bug.cgi?id=711684

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 17:21:22 +01:00
Thomas Haller
41f8114359 libnm-util: add nm_utils_inet[46]_ntop functions
https://bugzilla.gnome.org/show_bug.cgi?id=711684

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 17:21:21 +01:00
Jiří Klimeš
d40a499c01 cli: add active connections to 'nmcli device status' 2013-12-09 12:35:43 +01:00
Thomas Haller
1c031cddf7 libnm-util: bugfix wrong diff result in nm_connection_diff
Commit 6abc7b78f6 introduced a
bug in nm_connection_diff() by not reading the property value with
g_object_get_property().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-09 11:26:33 +01:00
Dan Williams
597c1c7a9a core: fuzzier matching of connections on startup (rh #1029859)
Because it's not trivial to generate a connection that exactly matches
one which was applied by NetworkManager before a restart, we need to
make matching somewhat fuzzier.  Mark any setting property that can be
read from the system or kernel as INFERRABLE, and match only on those
properties when trying to find the persistent connection (if any) which
is already active on that device.

https://bugzilla.redhat.com/show_bug.cgi?id=1029859
2013-12-05 17:25:33 -06:00
Thomas Haller
6abc7b78f6 libnm-util: call virtual compare_property in nm_connection_diff
nm_connection_diff must also use the virtual functions like
nm_connection_compare. This way, settings can overwrite the default
comparison of individual properties.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-05 17:09:46 -06:00
Dan Williams
4fba2260f3 core: ignore gateway host route during connection generation
When a gateway is not in the prefix of any of the interface's IP addresses,
NetworkManager adds a static host route to the gateway through the
interface to ensure the gateway can be reached.  That route will not
be part of the persistent connection (since it was added automatically)
but would normally be picked up by connection generation.  This would
cause the generated connection not to match with the persistent
connection, because the persistent connection does not have the host
route.  Ignore the gateway host route when capturing the interface's
existing IP configuration.
2013-12-05 17:09:46 -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
75d694db9b core: optimize generated connection matching a bit
Do a quick check to see if the connetion is compatible with the device
before we start doing a relatively heavy connection comparison.
2013-12-05 16:07:24 -06:00
Dan Williams
5f15409684 libnm-util: add INFERRABLE flag and remove CANDIDATE
INFERRABLE means the opposite of CANDIDATE; a property which NetworkManager
can read ("infer") from the system or the kernel when generating
connections.  CANDIDATE isn't a great name and thus dies.
2013-12-05 16:07:24 -06:00
Jiří Klimeš
5f32b8588e platform: fix uninitialized variable bcaddr in build_rtnl_addr()
platform/nm-linux-platform.c: In function 'build_rtnl_addr':
platform/nm-linux-platform.c:116:15: error: 'bcaddr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
   nl_addr_put (*object);
               ^
platform/nm-linux-platform.c:2264:32: note: 'bcaddr' was declared here
   auto_nl_addr struct nl_addr *bcaddr;
                                ^
2013-12-05 09:57:37 +01:00
Thomas Haller
c0e09de2b7 core: suppress logging warning when trying to create existing directory
Suppress logging the following line:
  <warn> Error creating directory "/var/run/NetworkManager": 17 (File exists)

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-04 17:14:34 +01:00
Jiří Klimeš
b7d6c61fe7 manager: handle NULL ifname in nm_manager_can_device_auto_connect gracefully 2013-12-04 16:11:10 +01:00
Jiří Klimeš
41d3efbd73 manager: do not create software devices when device was manually disconnected
We can only create virtual interfaces when the connection has autoconnect
property *and* the device was not manually disconnected before.

Without this commit NetworkManager would auto-activate all virtual connections
when a change was done (e.g. new virtual connection was addded).
2013-12-04 16:06:08 +01:00
Jiří Klimeš
d0c2a24b71 device: do not remove software devices on initial disconnected (rh #1035814)
When a device is initialized to be managed, it will transition through states
unmanaged -> unavailable -> disconnected. We don't want to remove software
devices during this initial transition to disconnected, because it prevents
auto-activation.

Test case:
$ nmcli con add type vlan ifname myvlan dev eth0 id 123
NM should immediately create myvlan interface and automatically activate it.

https://bugzilla.redhat.com/show_bug.cgi?id=1035814
2013-12-04 14:08:30 +01:00
Dan Winship
c9c6c73166 agent-manager: if an agent returns UserCanceled, stop
If an agent returns a UserCanceled error in response to a secrets
request, don't ask any other remaining secret agents for secrets.
2013-12-03 16:41:00 -05:00
Dan Winship
a8ef01b2c6 settings: prefer secret agents in the same process as the request
When an activation request requires secrets, if there is a secret
agent in the process that made the request, then prefer that to all
other secret agents.
2013-12-03 16:41:00 -05:00
Dan Winship
f3c2851c2b settings: port NMAgentManager, etc, to use NMAuthSubject
Rather than explicitly passing around a UID and a flag saying whether
or not it's relevant.

(This also fixes a bug where the wrong UID was being recorded in
nm-settings-connection.c::auth_start(), which caused problems such as
agent-owned secrets not getting saved because of a perceived UID
mismatch.)
2013-12-03 16:39:45 -05:00
Dan Winship
37b8983c39 core: make NMSessionMonitor non-refcounted
and ensure that main() frees the singleton before exiting
2013-12-03 16:39:37 -05:00
Dan Williams
6e73f01b6e platform: fix possible out-of-bounds access with RA route masking
If the prefix length was 128, that could cause an access beyond the
end of the array.  Found by Thomas Haller.
2013-12-03 14:25:08 -06:00
Dan Williams
7eb12a5b21 platform: set IPv4 broadcast address too (rh #1032819)
When moving over the platform, setting of the IPv4 broadcast address
got lost.  Bring it back.

https://bugzilla.redhat.com/show_bug.cgi?id=1032819
2013-12-03 14:25:08 -06:00
Dan Williams
ebace3def5 trivial: remove duplicate code 2013-12-02 16:21:46 -06:00
Dan Williams
5333296d81 core: connection matching and libnm-util cleanups (bgo #715196)
https://bugzilla.gnome.org/show_bug.cgi?id=715196
2013-12-02 15:34:23 -06:00
Dan Williams
ea5c30b1d9 core: generated slave connections should not have IP settings
Slaves have no IP configuration and should not have any IP settings.
This fixes connection comparison between generated slave connections
and persistent slave connections, as persistent slave connections won't
have any IP configuration.
2013-12-02 15:32:31 -06:00
Dan Williams
75a9bc8e31 core: updating a Generic setting should set the interface name
Generic connections need an interface name, and that can only be
stored in the Connection setting.
2013-12-02 15:32:31 -06:00
Dan Williams
038e45d29a Revert "device: bind the generated loopback connection to 'lo' interface"
This reverts commit 9a019f1fb5.

Generic connections should be bound to their interface names in a more generic
way instead of in nm-device.c.  The Generic device itself should set the
attributes it needs when generating the connection, like other device types do.
This will be done in a following commit.
2013-12-02 15:32:23 -06:00
Dan Williams
664d64e0c0 keyfile: ensure slave connections have the right settings
If the connection describes a bridge/bond/team/etc slave, where the
slave setting (like NMSettingBridgePort or NMSettingTeamPort) has all
default values, the setting does not get written out because the
plugin does not write default values.  But then when reading the
connection back in, we need to add that all-default slave type setting
since it's required for a valid connection.
2013-12-02 15:26:13 -06:00
Dan Williams
53ad869e92 ifcfg-rh: write zero-value bridge and bridge port options
Zero values are actually valid values for various bridge options
and should be written out.  Otherwise, when reading the property
back in, it gets assigned the default value which is often not
zero, causing the wrong value to be set in the connection.

Only properties with default values should not be written out.
2013-12-02 15:26:12 -06:00
Dan Williams
983079cd59 libnm-util: remove usage of NM_SETTING_PARAM_SERIALIZE
The only property that is not serializes is each settings' 'name'
property, so the flag serves no purpose.
2013-12-02 15:26:12 -06:00
Thomas Haller
1b0f832c7f core: print peer_address in NMPlatform address_to_string
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-12-02 21:13:11 +01:00
Dan Winship
f099a04132 platform/core: add back support for PtP/peer addresses (rh #1018317)
In the migration to NMPlatform, support for ptp/peer addresses was
accidentally dropped. This broke OpenVPN configurations using 'p2p'
topology, which send a different peer address than the local address
for tunX, plus the server may also push routes that use the peer
address as the next hop. NetworkManager was unable to add these
routes, because the kernel had no idea how to talk to the peer,
because the peer's address was not assigned to any interface or
reachable over any routes.

Partly based on a patch from Dan Williams.
2013-12-02 15:00:28 -05:00
Jiří Klimeš
62f07eea26 cli: fix nmcli help for connection object (rh #1036545)
https://bugzilla.redhat.com/show_bug.cgi?id=1036545
2013-12-02 15:40:11 +01:00
Jiří Klimeš
6c96f5f777 manager: fix connection auto-activation in timestamp-based order (rh #1029854)
This commit fixes a regression from a1f16cd4d9
(nm-policy.c change).

https://bugzilla.redhat.com/show_bug.cgi?id=1029854
2013-11-29 15:42:37 +01:00
Jiří Klimeš
aa54604f59 examples: update examples for new device types 2013-11-29 09:29:56 +01:00
Jiří Klimeš
888a2618ea trivial: update a comment 2013-11-29 08:42:36 +01:00
Jiří Klimeš
655af71c6d nmcli: fix connecting VLANs without an explicit interface-name (rh #1034908)
nm_connection_get_virtual_iface_name() doesn't work when determining virtual
connections, because for VLANs it can return NULL.

See also commit e1e4740648.

https://bugzilla.redhat.com/show_bug.cgi?id=1034908
2013-11-28 16:50:42 +01:00
Jiří Klimeš
a312aad848 tools: enhance description for the nm-settings manual page 2013-11-28 13:23:53 +01:00
Jiří Klimeš
b26656f003 tools: add team, team-port and dcb settings into generate-settings-spec.c 2013-11-28 11:35:52 +01:00
Jiří Klimeš
0d4a5f0328 Revert "libnm-util: refactor NMSetting construction, assert of setting name"
This reverts commit f43586fc17.

This broke stuff as "name" was set on various places after construction. So we
revert the commit for now, and will rework it.
2013-11-28 11:18:54 +01:00
Dan Williams
e2ecf5b808 dhcp: dhcpcd uses a fixed path for PID files
It always uses RUNDIR and the change to NMRUNDIR was in error.  This
could cause NetworkManager not to be able to kill old dhcpcd processes.
2013-11-27 19:00:14 -06:00
Dan Williams
b11aec3f15 dhcp: force IPv4-only for dhcpcd
dhcpcd v5.99 and later automatically enabled IPv6 behavior unless
specifically disabled.  This is undesirable for two reason:

1) dhcpcd sends IPv4 Router Solicitations, which NetworkManager
handles itself, so there's no need to do it twice.  NetworkManager
knows better than dhcpcd whether IPv6 is supposed to be used for
that interface or not.

2) Some devices don't react well to IPv6 when they aren't expecting
it.  For example, older Qualcomm Gobi-based devices will listen
for Router Solicitations and attempt to set up IPv6, but if other
settings are not done correctly, or the firmware doesn't actually
support it, the firmware will then crash.  So simply upgrading your
dhcpcd from 5.x to 6.x magically stops WWAN working for these
devices.
2013-11-27 17:14:32 -06:00
Thomas Haller
f43586fc17 libnm-util: refactor NMSetting construction, assert of setting name
Make the name property CONSTRUCT_ONLY. With this there is also no more
need to overwrite the constructor().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 23:10:17 +01:00
Thomas Haller
b8b8af38c1 libnm-util: fix minor memory leak in infiniband setting
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 21:19:11 +01:00
Thomas Haller
5cdd592457 libnm-util: trivial: rename private field and enum value in NMSettingVlan
The public property is called NM_SETTING_VLAN_INTERFACE_NAME,
so also the internal field and the PROP_* enum should carry
the same name.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 21:01:41 +01:00
Thomas Haller
63c9c399c5 libnm-util: fix minor memory leaks in bond and team setting
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-27 20:55:58 +01:00
Dan Williams
d35cb5b77c cli: add support for DCB settings 2013-11-27 10:05:43 -06:00
Dan Winship
ff93ed672b devices: if IP4 and IP6 config both fail right away, fail the device
Previously, the device activation would stall in this case, because
the code wasn't expecting it to happen. In particular, this happens
when trying to assume a device that is up but has no IP config.

https://bugzilla.gnome.org/show_bug.cgi?id=715181
2013-11-27 08:54:18 -05:00
Jiří Klimeš
91a95dd916 agents: fix crash in nm_secret_agent_cancel_secrets() (rh #922855)
When request for getting secrets is being freed in request_free(),
cancel_callback is get_cancel_cb(). It uses parent->current as a secret agent
object. However, this object can be already freed and thus there is a problem
getting priv in nm_secret_agent_cancel_secrets:

g_return_if_fail (self != NULL);
priv = NM_SECRET_AGENT_GET_PRIVATE (self);
(gdb) p self
$66 = (NMSecretAgent *) 0x7fae9afd42e0
(gdb) p *self
$67 = {parent = {g_type_instance = {g_class = 0x0}, ref_count = 0, qdata = 0x0}}

 #0  nm_secret_agent_cancel_secrets (self=0x7fae9afd42e0, call=0x1) at settings/nm-secret-agent.c:325
 #1  0x00007fae9a774882 in request_free (req=0x7fae9afc48f0) at settings/nm-agent-manager.c:496
 #2  0x00007fae967b251a in g_hash_table_remove_internal (hash_table=0x7fae9aefdf00, key=0x2, notify=1) at ghash.c:1276
 #3  0x00007fae9a72b340 in dispose (object=0x7fae9af77200) at nm-activation-request.c:446
 #4  0x00007fae96cbeee8 in g_object_unref (_object=0x7fae9af77200) at gobject.c:3160
 #5  0x00007fae9a73d87c in _active_connection_cleanup (user_data=<optimized out>) at nm-manager.c:359
 #6  0x00007fae967c32a6 in g_main_dispatch (context=0x7fae9aedb180) at gmain.c:3066
 #7  g_main_context_dispatch (context=context@entry=0x7fae9aedb180) at gmain.c:3642
 #8  0x00007fae967c3628 in g_main_context_iterate (context=0x7fae9aedb180, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3713
 #9  0x00007fae967c3a3a in g_main_loop_run (loop=0x7fae9aedb860) at gmain.c:3907

So we need to ref() 'agent' when adding it to pending list, so that the object
is not freed if the secret agent unregisters and is removed.

Test case:
1. run NM and nm-applet
2. activate a Wi-Fi network
3. nm-applet will ask for a password; ignore the popup window and kill nm-applet
4. start nm-applet again
5. click the same Wi-Fi network in nm-applet
6. NM will experience problems in nm_secret_agent_cancel_secrets() or crashes
(the procedure may not be 100%, but reproduces most of the time)

https://bugzilla.redhat.com/show_bug.cgi?id=922855
2013-11-26 14:43:11 +01:00