Commit Graph

91 Commits

Author SHA1 Message Date
Dan Williams
da016d91f5 core: don't leave additional default routes in captured IP config
There can be multiple default routes for an interface with different
metrics.  Grab the gateway of the default route with the lowest
metric as the overall gateway of the IP config.  Otherwise the rest
could get left in the config and applied at random times.
2013-11-22 15:02:58 -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 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
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
60b88d526c core: slaves should have empty captured IP configuration 2013-11-08 16:46:43 -06:00
Thomas Haller
47a0cf2a6c core: add nm_ip6_config_dump function
Also improve nm_ip4_config_dump to print all properties and make
use of nm_platform_*_to_string.

Also, ensure that never_default is set to gboolean 1 or 0.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-11-07 18:22:34 +01:00
Dan Winship
0a557ac01d core: fix crash when activating a never-default IPv4 connection 2013-10-24 15:15:02 -04:00
Thomas Haller
4fe20ed4d8 core: add const qualifier to functions in nm-ip[46]-config
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-25 23:12:37 +02:00
Thomas Haller
db9b7e10ac core: update existing IP[46]Config of device instead of replacing it (bgo #707617)
When the IP[46]Config changes, a new configuration gets assembled.
Before, whenever the new configuration was different than the current
one, the IP[46]Config of the device was completely replaced. This also
meant, that the old dbus IP[46]Config object was removed and the new one
was exported.

Now instead of recreating a new configuration, it updates the existing
(already exported) configuration in-place.

Also, add new gobject properties 'gateway' and 'searches' to the config class,
they will be exported over dbus.

Also, whenever any of the exported properties changes, make sure that a
notify signal gets emitted.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-25 23:12:37 +02:00
Thomas Haller
f0fccd99a5 core: add nm_ip[46]_config_replace functions
This new function copies the entire configuration of an existing
NMIP[46]Config object (src) and replaces the configuration in the destination
object (dst) in-place.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-25 23:12:37 +02:00
Thomas Haller
661e47311d core: add const qualifier to functions in nm-ip[46]-config
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-09-24 18:31:34 +02:00
Colin Walters
ff89e98fac trivial: consistently #include "libgsystem.h" rather than just gsystem-local-alloc.h
libgsystem contains more than just the local allocation macros; in the
future we will likely want to make use of some of this such as the
structured logging support.
2013-08-29 16:16:35 -05:00
Thomas Haller
fbde824584 core: fail activation when a route cannot be added
Before, when a route failed to be added, NM stopped adding further
routes. However, the activation still continued and the user was not
notified about the error.

Adding a route might fail for example if the gateway is not on one of
the subnets of the interface.

Now, a failure to add a route makes the activaion fail. If the
connection has autoconnect=yes, this might result in some unsuccessful
reconnection attempts.

In the future, we might want to distinguish between manually added routes
and routes from RA/DHCP. So that connecting to a wrongly configured DHCP
server still works for most parts.

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

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-26 23:36:38 +02:00
Thomas Haller
94dfe2856c core: fix leaking route instance in nm_ip4_config_update_setting
The fix in commit b5b43a6d65 missed the
release of the route instance (because nm_setting_ip4_config_add_route
does not take over the passed route but duplicates it).

So the orginal error was to free the route with the wrong deallocation
method gs_unref_object instead of nm_ip4_route_unref.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-26 10:56:16 +02:00
Thomas Haller
b5b43a6d65 core: fix wrong unref in nm-ip4-config/nm_ip4_config_update_setting
Signed-off-by: Thomas Haller <thaller@redhat.com>
2013-08-23 15:44:31 +02:00
Pavel Šimerda
7d37b714c8 core: don't return NULL from nm_ip[46]_config_capture()
Checking whether a connection is good enough is done by nm-device.

Acked-by: Dan Winship <danw@gnome.org>
Acked-by: Thomas Haller <thaller@redhat.com>
2013-08-22 22:06:47 +02:00
Pavel Šimerda
aae48a8557 core: don't use gs_unref_object for nm-ip[46]-address
It's not a GObject subclass.
2013-08-21 23:28:13 +02:00
Dan Williams
119345d90a core: fix double-free C&P error 2013-08-08 10:14:38 -05:00
Pavel Šimerda
6762b2f792 core: use NMIP[46]Route in nm-ip[46]-config 2013-08-03 00:15:07 -05:00
Dan Williams
7570832b20 platform: simplify getting routes and ignoring the default route
Most places except the tests don't want the default route when asking
the platform for all routes, so make that simpler by just adding a
parameter for including the default route or not.
2013-08-03 00:14:19 -05:00
Dan Williams
873df63e78 core: add nm_ip4_config_dump() 2013-08-02 17:19:36 -05:00
Dan Williams
7e21b528a9 core: add nm_ip4_config_subtract()
Removes anything in 'src' from 'dst'.
2013-08-02 17:19:36 -05:00
Dan Williams
468243baf2 core: combine and apply IPv4 configs instead of applying directly
Like IPv6, keep the DHCP/LLv4 config separate and combine it with the
NMSettingIP4Config to arrive at the final, combined IP4 config.  This
brings the behavior in line with IPv6 code flow and will allow adding
the VPN routes config into the mix more easily.
2013-08-02 17:19:35 -05:00
Pavel Šimerda
5216cd4eb3 core: detect automatic addresses when assuming connections 2013-07-27 00:52:00 +02:00
Pavel Šimerda
e07383f3de core: implement nm_ip[46]_config_update_setting() 2013-07-26 01:07:24 +02:00
Dan Williams
0f592b40c8 core: re-add assertions to NMIP[4|6]Config objects
They make any problems apparent at the source instead of later where
the problem must be more intesively debugged.
2013-07-22 14:28:48 -05:00
Pavel Šimerda
d8e6065f63 core: switch nm-ip4-config's NMIP[46]Address to NMPlatformIP[46]Address 2013-07-20 15:30:08 +02:00
Pavel Šimerda
74621a8f5c core: replace nm_ip[46]_config_diff()
Callers of these functions now only care whether two IP configs are
different and not what specific property changed, so we can simplify
this code down to a simple comparison for equality, based on the hashing
that's already done for the DNS manager.
2013-07-20 15:30:08 +02:00
Dan Williams
7c2abb2c9f core: fix stray semicolon causing VPN routes to not be added 2013-07-12 14:09:05 -05:00
Pavel Šimerda
7c0657a119 core: cleanup nm-ip[46]-config 2013-07-12 11:38:35 +02:00
Pavel Šimerda
c1538496a9 trivial: simplify nm_ip[46]_config_diff() NULL comparison logic 2013-07-04 18:15:30 +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
Pavel Šimerda
70916c79eb cleanup: remove libnl dependency from nm-ip4-config/nm-ip6-config 2013-06-25 09:53:27 +02:00
Dan Williams
8ce4250d8e core: ping the gateway during the IP_CHECK state (bgo #702515)
Using the new gateway-ping-timeout property, send pings to the first
gateway address until it replies or the timeout is reached, to deal
with dumb hardware that indicates carrier on but doesn't actually
pass traffic.

https://bugzilla.gnome.org/show_bug.cgi?id=702515
2013-06-21 16:18:49 -05:00
Dan Williams
c77c566983 core: ignore default routes when creating configuration for generic interface
NM handles the default routes, so they shouldn't show up in the NMIP4Config
for any interface.  They get exposed via the 'default' and 'default6' properties
of the ActiveConnection instead.
2013-06-19 13:49:12 -05:00
Dan Winship
43617d4c1d libnm-util: deprecate nm_utils_slist_free(), use g_slist_free_full() 2013-05-29 17:13:30 -03:00
Dan Williams
04cb58eacd core: convert the DBus manager to a single-ref object
It's created very, very early and never needs to be unrefed
by anything except the main() function.
2013-05-20 16:38:33 -03:00
Dan Winship
ab7ebead2c core: add IP configuration for unmanaged devices
Use NMPlatform to read the IP address/route configuration of unmanaged
devices, and export that via D-Bus like we do with NM-generated IP
configs.
2013-05-07 12:46:55 -04:00
Dan Williams
3c7f267fb9 core: use wrappers for DBus object registration/unregistration
When providing a service on the bus daemon and a private connection,
we'll need to track objects so we can register them with the
private connection too.  Thus all registration/unregistration
calls have to go through the NMDBusManager, not straight to
dbus-glib.
2013-04-08 10:55:37 -05:00
Dan Williams
cb0c2b4e82 trivial: use the constant for NM_IP*_COMPARE_FLAG_ALL 2012-06-12 10:00:03 -05:00
Dan Williams
90fb53de4c core: add hashing to IP config objects
We'll use this later to determine whether sets of IPxConfig
objects have actually changed without comparing them all
at once.
2012-06-12 09:37:26 -05:00
Dan Winship
cca40524ac core: silently ignore duplicates in NMIP[46]Config
The various nm_ip[46]_config_add_* routines were inconsistent in their
behavior when trying to add a duplicate item: add_address() and
add_route() would add it anyway; add_nameserver() and add_wins() would
g_return_if_fail(); and add_domain() and add_search() would return
silently. Update to use the "return silently" behavior everywhere.

In particular: if we get an RDNSS message listing the same nameserver
twice, don't cause a warning. (rh #820752)
2012-05-15 13:51:37 -04:00
Kjartan Maraas
c2b4b9c1d7 build: fix return types (bgo #644665)
Some functions were returning FALSE or 0 instead of NULL.
2011-03-14 01:05:51 -05:00
Dan Williams
e780145a8f dhcp4: handle NIS servers and domains 2010-07-16 11:28:39 -07:00
Dan Williams
b4767a5c1f dns: fix handling of searches and domains in resolv.conf
Fix a few issues here:

- nm_utils_merge_ip4_config() didn't reset domains, which would cause domains
    to still be used even if the user elected to ignore DHCP-provided DNS
- nm_ip4_config_add_domain() and nm_ip4_config_add_search() didn't filter
    duplicates
- nm_ip4_config_reset_searches() leaked everything
- If the user had specified an appended search in the connection, that search
    would be added to the 'searches' field in resolv.conf, but any server
    returned domains in 'domain_name' would be ignored because at least one
    search existed.
2009-05-11 20:07:39 -04:00
Dan Williams
f648c269bc core: ensure superclass' finalize method is called
Fixes a crash with PropertyChanged signals (triggered when using wifi + vpn and
rmmod-ing the driver) where properties_changed_info_destroy() wouldn't get
called on object destruction becuase the GObject finalize method never got
called for the DHCP4Config and IP4Config objects.
2009-02-25 13:53:24 -05:00
Dan Williams
f06a136a99 move nm_utils_ip4_addr_to_nl_addr() to nm-ip4-config.c
Since that's the only place it's used.
2009-01-18 20:04:14 -05:00
Dan Williams
a020ed21da Re-add WINS support to the IPv4 config
Don't do anything with WINS servers (dispatcher scripts installed with
samba could certainly update samba's idea of WINS servers), but at least
provide them so that the VPNs that can get upstream WINS servers can
at least make other stuff aware of them.
2008-12-19 17:01:06 -05:00
Dan Williams
948ee274da 2008-12-09 Dan Williams <dcbw@redhat.com>
* libnm-util/libnm-util.ver
	  libnm-util/nm-setting-ip4-config.c
	  libnm-util/nm-setting-ip4-config.h
		- Add 'never-default' property, which when true indicates that a
			connection should never be the default connection

	* src/nm-ip4-config.c
	  src/nm-ip4-config.h
		- (nm_ip4_config_get_never_default, nm_ip4_config_set_never_default):
			Add never-default helpers

	* src/NetworkManagerUtils.c
		- (nm_utils_merge_ip4_config): update never-default when merging the
			IP4 setting to the IP4 config

	* src/NetworkManagerSystem.c
		- (nm_system_apply_ip4_config): if the connection is never-default,
			don't add routes without a gateway

	* src/NetworkManagerPolicy.c
		- (get_best_device): don't let never-default connections be the best
		- (update_routing_and_dns): handle never-default for VPN connections

	* system-settings/plugins/ifcfg-rh/reader.c
		- (make_ip4_setting): handle never-default by checking GATEWAYDEV



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/branches/NETWORKMANAGER_0_7@4378 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
2008-12-09 20:01:49 +00:00