summaryrefslogtreecommitdiff
path: root/src/dhcp-manager
Commit message (Collapse)AuthorAgeFilesLines
* dhcp-manager: Keep size of PID consistentlr/crashesLubomir Rintel2014-11-103-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Things explode on i386 when marshalling a 32-bit value when a 64-bit one is expected: Program received signal SIGSEGV, Segmentation fault. __memset_sse2 () at ../sysdeps/i386/i686/multiarch/memset-sse2.S:242 242 movdqu %xmm0, (%edx) Missing separate debuginfos, use: debuginfo-install nss-mdns-0.10-15.fc21.i686 (gdb) bt #0 0xffffffff in __memset_sse2 () at ../sysdeps/i386/i686/multiarch/memset-sse2.S:242 #1 0xffffffff in g_hash_table_remove_all_nodes (__len=<optimized out>, __ch=0, __dest=<optimized out>) at /usr/include/bits/string3.h:84 #2 0xffffffff in g_hash_table_remove_all_nodes (hash_table=hash_table@entry=0x82ee250<error reading variable: Cannot access memory at address 0x8dbaacd6>, notify=notify@entry=1) at ghash.c:481 #3 0xffffffff in g_hash_table_unref (hash_table=0x82ee250<error reading variable: Cannot access memory at address 0x8dbaacd6>) at ghash.c:1042 #4 0xffffffff in _g_type_boxed_free (type=136861824, value=0x82ee250) at gtype.c:4262 #5 0xffffffff in boxed_proxy_value_free (value=0xbfffe8ec) at gboxed.c:209 #6 0xffffffff in g_value_unset (value=value@entry=0xbfffe8ec) at gvalue.c:272 #7 0xffffffff in g_signal_emit_valist (instance=instance@entry=0x82492b8, signal_id=signal_id@entry=125, detail=detail@entry=0, var_args=<optimized out>, var_args@entry=0xbfffea4c "\030\342.\bL#") at gsignal.c:3338 #8 0xffffffff in g_signal_emit (instance=0x82492b8, signal_id=125, detail=0) at gsignal.c:3365 #9 0x0809c05d in handle_event (proxy=0xb5d012e8 [DBusGProxy], options=0x82eb640 = {...}, user_data=0x82492b8) at dhcp-manager/nm-dhcp-listener.c:146 #10 0xffffffff in g_cclosure_marshal_VOID__BOXED (closure=0x82bf270, return_value=0x0, n_param_values=2, param_values=0x82c60c0, invocation_hint=0xbfffec68, marshal_data=0x0) at gmarshal.c:1120 #11 0xffffffff in marshal_dbus_message_to_g_marshaller () at /lib/libdbus-glib-1.so.2 #15 0xffffffff in <emit signal received:org-freedesktop-nm_dhcp_client-Event on instance 0xb5d012e8 [DBusGProxy]> (instance=0xb5d012e8, signal_id=19, detail=915) at gsignal.c:3365 #12 0xffffffff in g_closure_invoke (closure=0x82bf270, return_value=return_value@entry=0x0, n_param_values=n_param_values@entry=3, param_values=param_values@entry=0xbfffecc0, invocation_hint=invocation_hint@entry=0xbfffec68) at gclosure.c:768 #13 0xffffffff in signal_emit_unlocked_R (node=node@entry=0x8263660, detail=detail@entry=915, instance=0xb5d012e8, emission_return=emission_return@entry=0x0, instance_and_params=0xbfffecc0) at gsignal.c:3553 #14 0xffffffff in g_signal_emit_valist (instance=instance@entry=0xb5d012e8, signal_id=signal_id@entry=19, detail=detail@entry=915, var_args=0xbfffee34 "\340\370.\b\004", var_args@entry=0xbfffee2c "\340\370.\b\300\303/\b\340\370.\b\004") at gsignal.c:3309 #16 0xffffffff in dbus_g_proxy_manager_filter () at /lib/libdbus-glib-1.so.2 #17 0xffffffff in dbus_connection_dispatch () at /lib/libdbus-1.so.3 #18 0xffffffff in message_queue_dispatch () at /lib/libdbus-glib-1.so.2 #19 0xffffffff in g_main_context_dispatch (context=0x8246720) at gmain.c:3111 #20 0xffffffff in g_main_context_dispatch (context=context@entry=0x8246720) at gmain.c:3710 #21 0xffffffff in g_main_context_iterate (context=0x8246720, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at gmain.c:3781 #22 0xffffffff in g_main_loop_run (loop=0x8246798) at gmain.c:3975 #23 0x08070c09 in main (argc=1, argv=0xbffff2b4) at main.c:479 (gdb) PIDs use native word width, a gint seems more suitable than gint32 or gint64. https://bugzilla.gnome.org/show_bug.cgi?id=739861
* dhcp: demote DHCP client registration message to 'debug' levelDan Williams2014-11-071-2/+8
| | | | Was supposed to be that level originally.
* iface-helper: add nm-iface-helper for dynamic configure-then-quit supportDan Williams2014-11-071-1/+8
| | | | | | | | | | | | When quitting, the Manager asks each device to spawn the interface helper, which persists and manages dynamic address on the interface after NetworkManager is gone. If the dynamic address cannot be maintaned, the helper quits and the interface's address may be removed when their lifetime runs out. To keep the helper as simple as possible, NetworkManager passes most of the configuration on the command-line, including some properties of the device's current state, which are necessary for the helper to maintain DHCP leases or IPv6 SLAAC addresses.
* dhcp: track last IPv4 address on start for renewalDan Williams2014-11-077-22/+30
| | | | | | | | | Really only used by systemd because it doesn't have as good lease handling, but it's also necessary if we switch DHCP clients mid-stream (which we'll be doing later) since the new DHCP client won't have a lease file for the current IP address, and thus has nowhere to pull the current IP address from to request the same address from the DHCP server.
* dhcp: preserve hostname for later useDan Williams2014-11-075-21/+31
|
* dhcp: preserve DHCPv4 client ID for later useDan Williams2014-11-079-83/+327
| | | | | If we can, read the existing client ID from the leasefile and preserve it for later use.
* dhcp: move client-specific knowledge out of the managerDan Williams2014-11-079-72/+140
|
* dhcp: move D-Bus DHCP listener into separate classDan Williams2014-11-077-247/+375
| | | | | This simplifies the manager and ensures that only the clients that use D-Bus-based DHCP helpers need to care about them.
* libnm,core: enhance nm_utils_hexstr2bin()Dan Williams2014-11-071-35/+6
| | | | | | | Make the type return GBytes since most in-tree users want that. Allow the function to accept many more formats as valid hex, including bytes delimited by ':' and a leading '0x'.
* core: cleanup type of route metric to ensure guint32Thomas Haller2014-11-074-13/+13
| | | | | | | Kernel, netlink an NMPlatformRoute treat route metrics as uint32. Fix several places to use the exact type. Signed-off-by: Thomas Haller <thaller@redhat.com>
* core: move definition of NMLinkType to nm-types.hThomas Haller2014-11-071-0/+1
| | | | | | | | | | | As we use NMLinkType in NetworkManagerUtils.h, we cannot use the utils header without nm-platform.h. That is clearly wrong. Apparently NMLinkType has a wider use outside of platform (and its name is not prefixed with 'platform' either). Move the enum definition to nm-types.h. Signed-off-by: Thomas Haller <thaller@redhat.com>
* platform: don't include gsystem-local-alloc.h in nm-platform.hThomas Haller2014-11-071-0/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* dhcp: fix building without sys/auxv.hJiří Klimeš2014-11-071-0/+2
|
* core, clients: implement dhcp-send-hostname for IPv6Dan Winship2014-11-072-3/+5
| | | | | | | | | | Now that NMSettingIP6Config inherits the dhcp-send-hostname property from NMSettingIPConfig, fix things up so that it actually gets used. (Note that this changes behavior: previously if ip6.dhcp-hostname was unset, no hostname would be sent. Now, the system hostname will be set. Also, ifcfg-rh does not currently support this property, so there is no way to disable this...)
* libnm-core: extract NMSettingIPConfig superclass out of IP4, IP6 classesDan Winship2014-11-073-0/+3
| | | | | | | | Split a base NMSettingIPConfig class out of NMSettingIP4Config and NMSettingIP6Config, and update things accordingly. Further simplifications of now-redundant IPv4-vs-IPv6 code are possible, and should happen in the future.
* dhcp/test: fix compiler warning about pointer arithmetric for void*Thomas Haller2014-11-071-1/+1
| | | | | | | | | | | | | | | clang warns: make[4]: Entering directory `./NetworkManager/src/dhcp-manager/tests' CC test-dhcp-utils.o test-dhcp-utils.c:684:2: error: arithmetic on a pointer to void is a GNU extension [-Werror,-Wpointer-arith] COMPARE_ID (nothex, TRUE, nothex, strlen (nothex)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ test-dhcp-utils.c:667:23: note: expanded from macro 'COMPARE_ID' g_assert (memcmp (p + 1, expected, expected_len) == 0); \ ~ ^ Signed-off-by: Thomas Haller <thaller@redhat.com>
* dhcp: fix swapped order of argument for logging functionThomas Haller2014-11-071-1/+1
| | | | Signed-off-by: Thomas Haller <thaller@redhat.com>
* sd-dhcp-client: Add missing initializersLubomir Rintel2014-11-076-16/+12
| | | | | | Missing initializers together with automatic cleanup seem to annoy GCC's -Werror=maybe-uninitialized, breaking the --enable-more-warnings=error builds.
* dhcp: add systemd-based "internal" DHCP clientDan Williams2014-11-063-0/+863
| | | | | | | | | We must also remove -Waggregate-return from m4/compiler-warnings.m4 because systemd uses aggregate return (correctly) in a couple cases, and we cannot keep single-level makefiles and override aggregate-return only for the systemd sub-library. This client currently only supports DHCPv4 because the base systemd code does not yet fully support DHCPv6.
* dhcp: add nm_dhcp_utils_client_id_string_to_bytes()Dan Williams2014-11-064-6/+110
| | | | | Generic function to convert a DHCP client identifier string in either hex form ("aa:bb:cc") or string form ("blahblah") to bytes.
* dhcp: systemd DHCP code changes necessary for NM integrationDan Williams2014-11-062-29/+18
| | | | Random functionality that's necessary for our use of the library.
* dhcp: make systemd DHCP code into a libraryDan Williams2014-11-0623-0/+434
| | | | | | | | | | | | | The systemd code was modified to add "#if 0 /* NM_IGNORED */" around lines that cause problems for compilation or code that is not actually used in the library. An adaptation layer (nm-sd-adapt) was added for glue between systemd functions and NetworkManager, but changes to the actual systemd code have been kept to a minimum. The sd_event/sd_event_source functions of systemd have been re-implemented on top of the GLib main loop.
* dhcp: fix compiler warning in IN_SET macroThomas Haller2014-11-061-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang warns: dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-client.c:120:24: error: duplicate 'const' declaration specifier [-Werror,-Wduplicate-decl-specifier] assert_return (IN_SET(client->state, DHCP_STATE_INIT, ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:376:17: note: expanded from macro 'IN_SET' const typeof(_y) _x = (x); \ ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:238:34: note: expanded from macro 'assert_return' if (_unlikely_(!(expr))) { \ ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:42:44: note: expanded from macro '_unlikely_' #define _unlikely_(x) (__builtin_expect(!!(x),0)) ^ dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-client.c:120:24: error: duplicate 'const' declaration specifier [-Werror,-Wduplicate-decl-specifier] ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:379:47: note: expanded from macro 'IN_SET' for (_i = 0; _i < 1 + sizeof((const typeof(_x)[]) { __VA_ARGS__ })/sizeof(const typeof(_x)); _i++) \ ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:238:34: note: expanded from macro 'assert_return' if (_unlikely_(!(expr))) { \ ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:42:44: note: expanded from macro '_unlikely_' #define _unlikely_(x) (__builtin_expect(!!(x),0)) ^ dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-client.c:120:24: error: duplicate 'const' declaration specifier [-Werror,-Wduplicate-decl-specifier] ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:379:91: note: expanded from macro 'IN_SET' for (_i = 0; _i < 1 + sizeof((const typeof(_x)[]) { __VA_ARGS__ })/sizeof(const typeof(_x)); _i++) \ ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:238:34: note: expanded from macro 'assert_return' if (_unlikely_(!(expr))) { \ ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:42:44: note: expanded from macro '_unlikely_' #define _unlikely_(x) (__builtin_expect(!!(x),0)) ^ dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-client.c:120:24: error: duplicate 'const' declaration specifier [-Werror,-Wduplicate-decl-specifier] ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:380:31: note: expanded from macro 'IN_SET' if (((const typeof(_x)[]) { _y, __VA_ARGS__ })[_i] == _x) { \ ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:238:34: note: expanded from macro 'assert_return' if (_unlikely_(!(expr))) { \ ^ ../src/dhcp-manager/systemd-dhcp/src/shared/macro.h:42:44: note: expanded from macro '_unlikely_' #define _unlikely_(x) (__builtin_expect(!!(x),0)) ^ Signed-off-by: Thomas Haller <thaller@redhat.com>
* sd-dhcp-client: fix REBOOT state handlingDan Williams2014-11-061-18/+15
| | | | | | | | | | | | | client->secs wasn't getting set in the REBOOT state, causing an assertion. REBOOT should work the same way as INIT, per RFC 2131: secs 2 Filled in by client, seconds elapsed since client began address acquisition or renewal process. REBOOT is necessary because many DHCP servers (especially on home routers) do not hand back the same IP address when in response to a DISCOVER packet, even if the same client ID is used.
* sd-dhcp-client: clean up raw socket sd_event_source when creating UDP sourceDan Williams2014-11-061-0/+3
| | | | | | | The raw socket sd_event_source used for DHCP server solicitations was simply dropped on the floor when creating the new UDP socket after a lease has been acquired. Clean it up properly so we're not still listening and responding to events on it.
* sd-dhcp-lease: expose load/save functionsDan Williams2014-11-063-5/+5
| | | | They're useful outside of networkd itself.
* sd-dhcp-lease: load/save client IDDan Williams2014-11-064-1/+80
| | | | | The lease is intimately tied to the client ID in use, so when loading and renewing a lease, the same client ID should be used.
* sd-dhcp-client: support custom client IDsDan Williams2014-11-062-12/+105
| | | | | | | Non-ethernet interface types use different client identifier formats, plus when doing DHCPv4 and DHCPv6 on the same interface, the client identifier should be related per RFC 4361. Thus let the caller override the existing MAC-based client identifier if necessary.
* sd-dhcp6-client: fix off-by-two error in DUID lengthDan Williams2014-11-061-5/+5
| | | | | The duid data passed by the client does not include the DUID type, but client->duid_len does account for the size of the DUID type.
* dhcp: add systemd DHCP codeDan Williams2014-11-0644-0/+19423
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a direct dump from systemd git on 2014-10-28, git commit c4ac990007. Only relevant files were included. SYSTEMD_DIR=../systemd COMMIT=c4ac990007cd0069bb7e76ec15dd731320f382fd mkdir -p ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/ mkdir -p ./src/dhcp-manager/systemd-dhcp/src/shared/ mkdir -p ./src/dhcp-manager/systemd-dhcp/src/systemd/ ( cd "$SYSTEMD_DIR" git checkout "$COMMIT" git clean -fdx ) /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-internal.h /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-lease-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-lease-internal.h /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-network.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-network.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-option.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-option.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-packet.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-packet.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp-protocol.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp-protocol.h /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-internal.h /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-lease-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-lease-internal.h /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-network.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-network.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-option.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-option.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/dhcp6-protocol.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/dhcp6-protocol.h /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/network-internal.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/network-internal.h ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/network-internal.h /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-client.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-client.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp-lease.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp-lease.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-client.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp6-client.c /bin/cp "$SYSTEMD_DIR"/src/libsystemd-network/sd-dhcp6-lease.c ./src/dhcp-manager/systemd-dhcp/src/libsystemd-network/sd-dhcp6-lease.c /bin/cp "$SYSTEMD_DIR"/src/shared/async.h ./src/dhcp-manager/systemd-dhcp/src/shared/async.h /bin/cp "$SYSTEMD_DIR"/src/shared/fileio.c ./src/dhcp-manager/systemd-dhcp/src/shared/fileio.c /bin/cp "$SYSTEMD_DIR"/src/shared/fileio.h ./src/dhcp-manager/systemd-dhcp/src/shared/fileio.h /bin/cp "$SYSTEMD_DIR"/src/shared/list.h ./src/dhcp-manager/systemd-dhcp/src/shared/list.h /bin/cp "$SYSTEMD_DIR"/src/shared/macro.h ./src/dhcp-manager/systemd-dhcp/src/shared/macro.h /bin/cp "$SYSTEMD_DIR"/src/shared/refcnt.h ./src/dhcp-manager/systemd-dhcp/src/shared/refcnt.h /bin/cp "$SYSTEMD_DIR"/src/shared/siphash24.c ./src/dhcp-manager/systemd-dhcp/src/shared/siphash24.c /bin/cp "$SYSTEMD_DIR"/src/shared/siphash24.h ./src/dhcp-manager/systemd-dhcp/src/shared/siphash24.h /bin/cp "$SYSTEMD_DIR"/src/shared/socket-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/socket-util.h /bin/cp "$SYSTEMD_DIR"/src/shared/sparse-endian.h ./src/dhcp-manager/systemd-dhcp/src/shared/sparse-endian.h /bin/cp "$SYSTEMD_DIR"/src/shared/strv.c ./src/dhcp-manager/systemd-dhcp/src/shared/strv.c /bin/cp "$SYSTEMD_DIR"/src/shared/strv.h ./src/dhcp-manager/systemd-dhcp/src/shared/strv.h /bin/cp "$SYSTEMD_DIR"/src/shared/time-util.c ./src/dhcp-manager/systemd-dhcp/src/shared/time-util.c /bin/cp "$SYSTEMD_DIR"/src/shared/time-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/time-util.h /bin/cp "$SYSTEMD_DIR"/src/shared/utf8.c ./src/dhcp-manager/systemd-dhcp/src/shared/utf8.c /bin/cp "$SYSTEMD_DIR"/src/shared/utf8.h ./src/dhcp-manager/systemd-dhcp/src/shared/utf8.h /bin/cp "$SYSTEMD_DIR"/src/shared/util.c ./src/dhcp-manager/systemd-dhcp/src/shared/util.c /bin/cp "$SYSTEMD_DIR"/src/shared/util.h ./src/dhcp-manager/systemd-dhcp/src/shared/util.h /bin/cp "$SYSTEMD_DIR"/src/shared/in-addr-util.c ./src/dhcp-manager/systemd-dhcp/src/shared/in-addr-util.c /bin/cp "$SYSTEMD_DIR"/src/shared/in-addr-util.h ./src/dhcp-manager/systemd-dhcp/src/shared/in-addr-util.h /bin/cp "$SYSTEMD_DIR"/src/systemd/_sd-common.h ./src/dhcp-manager/systemd-dhcp/src/systemd/_sd-common.h /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-client.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-client.h /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp-lease.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp-lease.h /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-client.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp6-client.h /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-dhcp6-lease.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-dhcp6-lease.h /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-event.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-event.h /bin/cp "$SYSTEMD_DIR"/src/systemd/sd-id128.h ./src/dhcp-manager/systemd-dhcp/src/systemd/sd-id128.h
* dhcp: don't add special route to DHCP server when having direct routeThomas Haller2014-10-311-5/+5
| | | | | | | | | | | When the DHCP server address is not on the same subnet, we used to add a /32 route to the server IP address via the gateway. Do not add this route, if we already got a direct route from DHCP. https://bugzilla.gnome.org/show_bug.cgi?id=738590 Signed-off-by: Thomas Haller <thaller@redhat.com>
* dhcp: suppress warning about invalid DNS serversDan Williams2014-10-271-20/+28
| | | | | | | | | If the DHCP server happens to send "0.0.0.0", which you see with some consumer gear that only has one nameserver set, don't warn because we know it's bogus. Also rename the copy & pasted 'searches' variable to what it's actually used for.
* dhclient: allow single hex digits in hexadecimal dhcp_client_idThomas Haller2014-10-272-3/+40
| | | | | | | | | | When checking whether the dhcp-client-identifier is a hex string, we expected pairs of hexadecimal digits separated by colon. Relax this check to also allow single hex digits. https://bugzilla.gnome.org/show_bug.cgi?id=737727 Signed-off-by: Thomas Haller <thaller@redhat.com>
* core: drop all remaining core-internal error domainsDan Winship2014-10-222-25/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | A number of classes in core had their own error domains that aren't really necessary. In the case of NMDcbError, NMDhcpManagerError, NMDnsManagerError, NMDnsmasqManagerError, NMPppManagerError, and NMSessionMonitorError, most of the codes they defined weren't even being used, and at any rate, the errors were always returned into contexts where they would just have their message extracted and then get thrown away without anyone ever looking at the domain or code. So all uses of those domains can just be replaced with NM_MANAGER_ERROR_FAILED without any loss of information. NMAuthManagerError only had 1 error code, and it just indicated "something went wrong", so it can be replaced with NM_MANAGER_ERROR_FAILED without loss of information. (nm-auth-manager.c has also been fixed to return NM_MANAGER_ERROR_FAILED when the CheckAuthorization D-Bus call fails, rather than returning whatever error domain/code the D-Bus call returned.) NMVpnManagerError used 2 of its 4 error codes, and they could actually end up getting returned across D-Bus in some cases. But there are NMManagerError codes that are semantically similar enough to make the NMVpnManagerError ones unnecessary.
* core: track origin of MTULubomir Rintel2014-10-201-1/+1
| | | | | Only override MTU if it came from a source of higher priority or is of equal priority but of lower value.
* core: Move NMPlatformSource to nm-types.hLubomir Rintel2014-10-202-7/+7
| | | | | ...and rename it while at it. It's going to be useful outside nm-platform, to weight MTU options from various sources.
* dhcp: relax check valid PID for dhcp processThomas Haller2014-10-101-1/+1
| | | | | | | | | All callers only pass a PID that previously was returned from spawning a process. AFAIS, there is no officially reserved range for lower PIDs that would enforce valid PIDs to be larger then 25. Relax this check. Signed-off-by: Thomas Haller <thaller@redhat.com>
* core/dhcp: kill external dhcp process using nm_utils_kill_process_sync()Thomas Haller2014-10-101-2/+6
| | | | | | | | | | | nm_utils_kill_child_sync() is not able to reap the external process. This causes NM to hang for 500 ms and logs the following error: <debug> [1412167360.400201] [NetworkManagerUtils.c:534] nm_utils_kill_child_sync(): kill child process 'dhcp-client' (7109): waiting up to 500 milliseconds for process to terminate normally afte <debug> [1412167360.900298] [NetworkManagerUtils.c:549] nm_utils_kill_child_sync(): kill child process 'dhcp-client' (7109): sending SIGKILL... <error> [1412167360.900369] [NetworkManagerUtils.c:576] nm_utils_kill_child_sync(): kill child process 'dhcp-client' (7109): after sending SIGTERM (15) and SIGKILL, waitpid failed with No child Signed-off-by: Thomas Haller <thaller@redhat.com>
* dhcp: treat lease expiry as failure (rh #1139326)Dan Williams2014-10-021-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Lease expiry means that the DHCP configuration is no longer valid, and that all attempts to renew/rebind the lease have failed. The IP config needs to be removed. NetworkManager also sets prefered/valid lifetimes on addresses, so the kernel will remove them when the lease expires anyway. That causes removal of the default route, if the default route was through the device whose config has now expired. DHCP clients will typically move to the 'renew' or 'rebind' states when nearing lease expiry, then if no answer is received move to the 'expire' state. Eventually they move to the 'fail' state when all attempts to contact the server have failed. Previously, since NM ignored the 'expire' DHCP state it would not clear out the DHCP IP4 config immediately when the lease expired, instead waiting for the DHCP client to move to the 'fail' state. But if the DHCP server appeared between the 'expire' and 'fail' states, NM would not notice and the device's NMIP4Config would not change, and thus the Policy would not get the "ip4-config-changed" signal to re-add the default route that the kernel had previously removed due to the valid lifetime reaching zero when the lease expired. https://bugzilla.redhat.com/show_bug.cgi?id=1139326
* dhcp: log DHCP client exit status betterJiří Klimeš2014-09-121-13/+22
|
* dhcp: fix dhclient abnormal exit due to SIGPIPE (bgo #735962)Jiří Klimeš2014-09-122-3/+10
| | | | | | | | | | | | | | | | | | | | | | | | | DHCP client may be killed by SIGPIPE when attempting to write to a broken pipe. This can be observed, for example, when journald is restarted. Fix that by redirecting both stdout and stderr to /dev/null. The client logs into syslog anyway. When NetworkManager is run with '--debug' we duplicate syslog to stderr, so the messages goes to terminal as well. Testcase: - start a NetworkManager service by systemd - activate an DHCP ethernet connection - sudo systemctl restart systemd-journald.service - reactive the ethernet connection (nmcli con up <my-eth>) - DHCP client is killed by SIGPIPE right after its startup: <info> (enp0s25): DHCPv4 client pid 13959 exited with status -1 <warn> DHCP client died abnormally Another possible fix would be ignoring SIGPIPE in the DHCP client as it is not useful in most cases. E.g. systemd ignores SIGPIPE for its services, by default: http://cgit.freedesktop.org/systemd/systemd/commit/?id=353e12c2f4a9e96a47eb80b80d2ffb7bc1d44a1b https://bugzilla.gnome.org/show_bug.cgi?id=735962
* core: consolidate helper progam searching (bgo #734131)Dan Williams2014-09-115-74/+36
| | | | | | | | | | Instead of having basically the same code in a bunch of different place to find helper programs, just have one place do it. Yes, this does mean that the same sequence of paths is searched for all helpers (so for example, dnsmasq will no longer be found first in /usr/local) but I think consistency is the better option here. https://bugzilla.gnome.org/show_bug.cgi?id=734131
* dhcp: fix g_error_free() called with a bad argumentJiří Klimeš2014-09-051-1/+1
|
* dhcp-manager: port nm-dhcp-helper from dbus-glib to gdbusDan Winship2014-09-042-238/+95
|
* libnm-core: change all mac-address properties to G_TYPE_STRINGDan Winship2014-09-049-31/+25
| | | | | | | | | | Make all mac-address properties (including NMSettingBluetooth:bdaddr, NMSettingOlpcMesh:dhcp-anycast-addr, and NMSettingWireless:bssid) be strings, using _nm_setting_class_transform_property() to handle translating to/from binary form when dealing with D-Bus. Update everything accordingly for the change, and also add a test for transformed setting properties to test-general.
* all: remove a bunch of unnecessary dbus/dbus-glib includesDan Winship2014-09-031-1/+0
|
* all: fix up multiple-include-guard definesDan Winship2014-08-166-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | Previously, src/nm-ip4-config.h, libnm/nm-ip4-config.h, and libnm-glib/nm-ip4-config.h all used "NM_IP4_CONFIG_H" as an include guard, which meant that nm-test-utils.h could not tell which of them was being included (and so, eg, if you tried to include nm-ip4-config.h in a libnm test, it would fail to compile because nm-test-utils.h was referring to symbols in src/nm-ip4-config.h). Fix this by changing the include guards in the non-API-stable parts of the tree: - libnm-glib/nm-ip4-config.h remains NM_IP4_CONFIG_H - libnm/nm-ip4-config.h now uses __NM_IP4_CONFIG_H__ - src/nm-ip4-config.h now uses __NETWORKMANAGER_IP4_CONFIG_H__ And likewise for all other headers. The two non-"nm"-prefixed headers, libnm/NetworkManager.h and src/NetworkManagerUtils.h are now __NETWORKMANAGER_H__ and __NETWORKMANAGER_UTILS_H__ respectively, which, while not entirely consistent with the general scheme, do still mostly make sense in isolation.
* dhcp: fix killing wrong process ID on dhclient releaseDan Williams2014-08-082-9/+14
| | | | | | | | The prototype of dhclient_start() changed in 30cdd1248 but that commit didn't update stop() correctly. Clearly treating a gboolean as pid_t isn't going to work. Second, we don't want to watch the child process on DHCP release because we're just going to kill it shortly after.
* libnm: add NetworkManager.h, disallow including individual headersDan Winship2014-08-011-0/+1
| | | | | | | | | | Add NetworkManager.h, which includes all of the other NM header, and require all external users of libnm to use that rather than the individual headers. (An exception is made for nm-dbus-interface.h, nm-vpn-dbus-interface.h, and nm-version.h, which can be included separately.)
* libnm, core, cli, tui: fix the capitalization of various typesDan Winship2014-08-018-171/+171
| | | | | | | | | | | | GLib/Gtk have mostly settled on the convention that two-letter acronyms in type names remain all-caps (eg, "IO"), but longer acronyms become initial-caps-only (eg, "Tcp"). NM was inconsistent, with most long acronyms using initial caps only (Adsl, Cdma, Dcb, Gsm, Olpc, Vlan), but others using all caps (DHCP, PPP, PPPOE, VPN). Fix libnm and src/ to use initial-caps only for all three-or-more-letter-long acronyms (and update nmcli and nmtui for the libnm changes).