Commit graph

649 commits

Author SHA1 Message Date
Dan Williams
beb18050b5 settings: create default wired connection from NMDeviceEthernet
Instead of creating it in NMSettings, where we must use
NM_IS_DEVICE_ETHERNET() (not NM_DEVICE_TYPE_ETHERNET because various generic
devices masquerade as NM_DEVICE_TYPE_ETHERNET too), push knowledge
of which device types create default wired connections into the device
types themselves.  This solves a problem with testcases where
libNetworkManager.a (which testcases link to) requires the symbol
nm_type_device_ethernet().
2014-09-11 12:47:07 -05:00
Dan Williams
005cb2fc35 core: search for arping binary too (bgo #734131) 2014-09-11 12:11:57 -05:00
Dan Williams
544fc82aa7 core: consolidate helper progam searching (bgo #734131)
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
2014-09-11 12:11:56 -05:00
Dan Williams
5e4761a3a9 core: take over IPv6LL address management if kernel supports it (bgo #734149)
NM keeps interfaces IFF_UP when possible to receive link layer
events like carrier changes.  Unfortunately, the kernel also
uses IFF_UP as a flag to assign an IPv6LL address to the interface,
which results in IPv6 connectivity on the link even if the interface
is not supposed to be activated/connected.

NM sets disable_ipv6=1 to ensure that the kernel does not set up
IPv6LL connectivity on interfaces when they are not supposed to
be active and connected.  Unfortunately, that prevents users from
manually adding IPv6 addresses to the interface, since they expect
previous kernel behavior where IPv6 is enabled whenever the
interface is IFF_UP.

Furthermore, interfaces like PPP and some WWAN devices provide
misleading information to the kernel which causes the kernel to
create the wrong IPv6LL address for the interface.  The IPv6LL
address for these devices is obtained through control channels
instead (IPV6CP for PPP, proprietary protocols for WWAN devices)
and should be used instead of the kernel address.  So we'd like
to suppress kernel IPv6LL address generation on these interfaces
anyway.

This patch makes use of the netlink IFLA_INET6_ADDR_GEN_MODE
attribute to take over assignment of IPv6LL addresses while
keeping the interface IFF_UP, to ensure there is only IPv6
connectivity when the user requests it.

To remain compliant with standards, if a user adds IPv6 addresses
externally, NetworkManager must also immediately add an IPv6LL
address for that interface too.

https://bugzilla.gnome.org/show_bug.cgi?id=734149
2014-09-04 15:11:04 -05:00
Dan Winship
3a54d05098 libnm-core: change all mac-address properties to G_TYPE_STRING
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.
2014-09-04 09:20:10 -04:00
Dan Williams
cbcca18149 core: complete IPv6 even if RA times out when there are manual/external addresses
Even if we never receive an RA, if there are manually-specified or external
addresses, consider IPv6 to complete successfully.  No reason to fail IPv6
if we have IP configuration already, but RA doesn't respond.  If RA shows
up again, we're still listening for it and will apply the config at that
time.
2014-08-29 16:03:37 -05:00
Dan Williams
c69531041a core: apply manual IPv6 configuration earlier when RA is also used (rh #1101809)
Reporter left SLAAC enabled (because it's default and requires being
explicitly turned off) and added manual IPv6 address.  They expected that
address to be assigned very soon after starting the connection, but it was
not assigned.

This happened because NM waits for RA before assigning any IPv6 configuration,
including the manually specified addresses.  In the reporters case, there was
no IPv6 router on the network, so NM waited indefinitely for a router
advertisement and never applied any IPv6 configuration.

It seems reasonable to apply any IPv6 configuration we have available, when
we have it.  We already apply RA configuration before starting DHCP, and
apply DHCP configuration if/when we get that.
2014-08-29 16:03:37 -05:00
Dan Williams
17e323fd22 core: sync IPv6 pre-commit hook with IPv4 behavior
The IPv4 pre-commit hook was called right before the config was
committed, while the IPv6 one was called before commit in only
one case (from nm_device_activate_ip6_config_commit).  The IPv4
behavior is the intended behavior.

Note that this doesn't have any actual effect yet, since nothing
actually implements the IPv6 pre-commit hook
2014-08-29 16:03:36 -05:00
Dan Williams
7c9d4e8f5a rdisc: add RA wait timeout
Add an advisory timeout when waiting for router advertisements so
we can fail IPv6 addressing attempts when no router advertisement
has been received.
2014-08-29 16:03:36 -05:00
Dan Winship
e1ba13a426 libnm-core, libnm, core: make NMConnection an interface
The fact that NMRemoteConnection has to be an NMConnection and
therefore can't be an NMObject means that it needs to reimplement bits
of NMObject functionality (and likewise NMObject needs some special
magic to deal with it). Likewise, we will need a daemon-side
equivalent of NMObject as part of the gdbus port, and we would want
NMSettingsConnection to be able to inherit from this as well.

Solve this problem by making NMConnection into an interface, and
having NMRemoteConnection and NMSettingsConnection implement it. (We
use some hacks to keep the GHashTable of NMSettings objects inside
nm-connection.c rather than having to be implemented by the
implementations.)

Since NMConnection is no longer an instantiable type, this adds
NMSimpleConnection to replace the various non-D-Bus-based uses of
NMConnection throughout the code. nm_connection_new() becomes
nm_simple_connection_new(), nm_connection_new_from_hash() becomes
nm_simple_connection_new_from_hash(), and nm_connection_duplicate()
becomes nm_simple_connection_new_clone().
2014-08-16 10:17:53 -04:00
Dan Winship
58a66cc70b core: fix a warning and a leak
For devices where we don't set the hardware address at construct time,
the first call to nm_device_update_hw_address() was hitting a
return-if-fail.

Also, when updating the hardware address, we were leaking the old
value.
2014-08-08 11:17:03 -04:00
Dan Winship
b019348fdd core: update data types of some hwaddr properties
Now that we have nm_utils_hwaddr_matches() for comparing addresses
(even when one is a string and the other binary), there are now places
where it's more convenient to store hardware addresses as strings
rather than binary, since we want them in string form for most
non-comparison purposes. So update for that.

In particular, this also changes nm_device_get_hw_address() to return
a string.

Also, simplify the update_permanent_hw_address() implementations by
assuming that they will only be called once. (Since they will.)
2014-08-07 15:41:04 -04:00
Dan Winship
44b9a8708b libnm-core, etc: add nm_utils_hwaddr_matches()
Add nm_utils_hwaddr_matches(), for comparing hardware addresses for
equality, allowing either binary or ASCII hardware addresses to be
passed, and handling the special rules for InfiniBand hardware
addresses automatically. Update code to use it.
2014-08-07 15:34:50 -04:00
Dan Winship
357efd26e4 libnm-core: include ETH_ALEN/INFINIBAND_ALEN defines in nm-utils.h
Include <linux/if_ether.h> and <linux/if_infiniband.h> from
nm-utils.h, to get ETH_ALEN and INFINIBAND_ALEN, and remove those
includes (as well as <net/ethernet.h> and <netinet/ether.h>, and
various headers that had been included to get the ARPHRD_* constants)
from other files where they're not needed now.
2014-08-07 14:04:14 -04:00
Dan Winship
35f36ba4c3 libnm-core, etc: drop type-based hwaddr funcs, port to length-based ones
Drop the arptype-based nm_utils_hwaddr funcs, and rename the
length-based ones to no longer have _len in their names. This also
switches nm_utils_hwaddr_atoba() to using a length rather than an
arptype, and adds a length argument to nm_utils_hwaddr_valid() (making
nm_utils_hwaddr_valid() now a replacement for nm_utils_hwaddr_aton()
in some places, where we were only using aton() to do validity
checking).
2014-08-07 12:08:16 -04:00
Thomas Haller
4b36f8b35b logging: use new logging macros in NMDevice subclasses
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-06 19:22:02 +02:00
Thomas Haller
950989c45c logging: extract logging macros for devices to nm-device-logging.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-06 19:22:02 +02:00
Thomas Haller
ab8966d935 core: cleanup getting iface for NMDevice for logging
Since refactoring logging, these calls are not needed.
Just forgot to remove them.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-02 00:51:36 +02:00
Dan Winship
3ac0f52878 libnm, core, cli, tui: fix the capitalization of various types
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).
2014-08-01 14:34:06 -04:00
Thomas Haller
be55d774eb core: refactoring logging in NMDevice to use new _LOG() macros
Make use of the previously added _LOG() macros in nm-device.c.
This reduces code, but also ensures printing the same prefix for
every logline produced *for* a device instance.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:09:47 +02:00
Thomas Haller
7de955c0d2 core/trivial: change variable name for self pointer in NMDevice to @self
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:09:23 +02:00
Thomas Haller
75d8a805e7 core: add logging macro _LOG() and _LOGD() to nm-device.c
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
7509d4f80f core/logging: change order or domain/level arguments for nm_log()
Now the order of arguments corresponds to nm_logging_enabled().

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:25 +02:00
Thomas Haller
8720c8e136 core: no need to clone ifname in nm_device_generate_connection()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 19:06:24 +02:00
Thomas Haller
a2a36d8450 core: fix warning about comparing unsigned enum values being positive
clang warns:

    make[4]: Entering directory `./NetworkManager/src'
      CC       nm-device.lo
    devices/nm-device.c:367:12: error: comparison of unsigned enum expression >= 0 is always true [-Werror,-Wtautological-compare]
            if (state >= 0 && state < G_N_ELEMENTS (state_table))
                ~~~~~ ^  ~
    devices/nm-device.c:443:13: error: comparison of unsigned enum expression >= 0 is always true [-Werror,-Wtautological-compare]
            if (reason >= 0 && reason < G_N_ELEMENTS (reason_table))
                ~~~~~~ ^  ~

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-08-01 13:17:00 +02:00
Dan Williams
784d263170 dhcp: DHCPv6 OtherConf failures should not be fatal
OtherConf implies the address has already been delivered via RA,
and possibly DNS too, meaning our IP configuration is already
good enough.  If nothing on the network bothers to reply to our
DHCPv6 Information Requests, let's just run with the config
we already have instead of tearing down the whole device.
2014-07-23 14:26:40 -05:00
Dan Williams
8c05e26c42 wwan: add infrastructure for IPv6 config results 2014-07-23 14:26:39 -05:00
Dan Williams
af1f183b3d wwan: split out WWAN IP4Config from device config
We want to set the WWAN config last, to ensure that the configuration we
use overwrites anything that pppd might have set, becuase it touches some
stuff itself.  That means we have to keep the WWAN config separate, since
dev_ip4_config is used for DHCP and IPv4LL, which we always set first to
ensure they these don't overwrite external, administrator added config
(eg, priv->ext_ip4_config).

This also synchronizes the IPv4 config path with the upcoming IPv6
config path.
2014-07-23 14:26:39 -05:00
Dan Williams
288bf39e44 core: fail IPv6 router discovery if IID cannot be generated
If the IID cannot be generated, the IPv6 address resulting from
the combination of an advertised prefix and 64-bits of zero is
both wrong and quite likely to clash with some other machine on
the network that doesn't implement IPv6 quite right either.

Require an valid interface identifier.  If NetworkManager doesn't
know how to generate one, then we should fix NM to do so.
2014-07-23 14:21:11 -05:00
Dan Williams
05e99e24a1 trivial: move addrconf6_start_with_link_ready() above caller 2014-07-23 12:53:55 -05:00
Dan Williams
e2270040c0 core: use Interface Identifiers for IPv6 SLAAC addresses
Ethernet-like interfaces aren't the only type of interfaces that can
run IPv6 but the rdisc code only returns an address if the interface's
hardware address is 6 bytes.

Interface types like PPP (rfc5072) and IPoIB (rfc4391) have their own
specifications for constructing IPv6 addresses and we should honor
those.

So instead of expecting a MAC address, let each device subclass
generate an Interface Identifier and use that for rdisc instead.
2014-07-23 12:53:55 -05:00
Dan Williams
27f91d054c core: simplify hardware address reading
We no longer need a class method for reading the hardware address
length, for a couple reasons:

1) Using the IP interface hardware address for IP operations now makes
NMDevice's priv->hw_addr_len constant.  So there's no reason to re-read
it all the time.

2) get_hw_address_length() is now only used for determining whether the
hardware address is permanent, and that only mattered for Bluetooth.
Since Bluetooth interfaces have a bogus interface name, they will never
have a valid ifindex, and thus nm_platform_link_get_address() would be
useless.  So instead of using the 'permanent' stuff, just don't bother
updating the hardware address if the NMDevice's ifindex isn't valid,
and let subclasses pass the initial hardware address at device creation.

This also works correctly for NMDevice classes that previously
implemented get_hw_address_length() like ADSL and WWAN, since those
too will never have a valid ifindex or a valid hardware address.

3) Reading the device's hardware address length just ended up calling
nm_platform_link_get_address() for most devices anyway, so
nm_device_update_hw_address() would effectively read the link address
twice (once to read the length, the second time to read the actual
address).  Let's just read the address once.
2014-07-23 12:53:55 -05:00
Thomas Haller
ac4fafe7a4 platform: assert against the maximum length of link_get_address()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-23 12:42:45 -05:00
Dan Williams
7f771d0a05 core: use IP interface hardware address for IP-level operations
The IP interface may have its own hardware address (like the net
port for WWAN devices) and that's the hardware address that must be
used for DHCP and IPv6 SLAAC, not the hardware address (if any) of
the NMDevice itself.

This patch does change the NMDevice hardware address property to
always be the Device's hardware address, instead of the IP interface
hardware address.  This means that ADSL and WWAN will no longer
change their hardware address to the hardware address of their
IP interface.  But in all these cases, the hardware address is
non-existent (PPP) or transient and meaningless (WWAN/ADSL).
2014-07-23 12:42:45 -05:00
Dan Winship
7da97fc6fe config: drop NMConfigDevice, use NMDevice directly
NMConfigDevice was added because in the 0.9.8 days, when each subdir
of src/ was compiled separately, it was impossible to make src/config/
depend on src/devices/ because of circular dependencies.

Since now everything gets compiled into a single libNetworkManager.la,
this is no longer a problem, and so NMConfigDevice is just an
unnecessary complication.
2014-07-23 10:56:26 -04:00
Dan Winship
b28f6526c2 core: fill in nm-types.h, clean out other headers
Clean up some of the cross-includes between headers (which made it so
that, eg, if you included NetworkManagerUtils.h in a test program, you
would need to build the test with -I$(top_srcdir)/src/platform, and if
you included nm-device.h you'd need $(POLKIT_CFLAGS)) by moving all
GObject struct definitions for src/ and src/settings/ into nm-types.h
(which already existed to solve the NMDevice/NMActRequest circular
references).

Update various .c files to explicitly include the headers they used to
get implicitly, and remove some now-unnecessary -I options from
Makefiles.
2014-07-23 10:56:26 -04:00
Dan Williams
a1c86a9a27 dhcp: pass IPv6 privacy preference to client class 2014-07-22 14:39:20 -05:00
Dan Williams
24c1523b51 dhcp: pass individual options to DHCP instead of NMSettingIPxConfig 2014-07-22 14:39:19 -05:00
Dan Williams
6ffcde08dd dhcp: pass DHCP options with BOUND state change
The options hash is never used except for BOUND events, so don't
bother caching it in the DHCP client object.  Just pass it along
with the BOUND state change, like the IP configuration object.
2014-07-22 14:39:19 -05:00
Dan Williams
31d19f51d1 dhcp: filter DHCP options when setting them
Don't bother storing all the options, only store the ones we care
about and ones we export through the NMDHCP4Config and NMDHCP6Config
objects.
2014-07-22 14:39:19 -05:00
Dan Williams
4ce6e39a8f dhcp: pass IP config in state signal
Just pass it in the state change signal.
2014-07-22 14:39:19 -05:00
Dan Williams
a7a84d7f76 core: consolidate DHCP client termination in dhcp[4|6]_fail()
DHCP failure should just clean up the client in all cases.  This
also has the benefit of removing the signal handler for the DHCP
client's state-change signal before telling the client to terminate,
which will simplify some DHCP code later.
2014-07-22 14:39:18 -05:00
Dan Williams
9568ae52e4 dhcp: merge TIMEOUT signal with DHCP_STATE_TIMEOUT
No reason to have two signals for the same thing. Previously, the
TIMEOUT signal was used for the internal overall DHCP transaction
bound, while DHCP_STATE_TIMEOUT/DHC_TIMEOUT was a signal from
the DHCP client itself that something had timed out.  But in both
cases the results should be the same, so just collapse the
stand-alone TIMEOUT signal into the DHCP_STATE_TIMEOUT state.
2014-07-22 14:39:18 -05:00
Dan Williams
9e75e2ad0d dhcp: simplify DHCP states
The existing DHC_* states are pretty specific to dhclient, and aren't
useful for more generalized DHCP.  NetworkManager wasn't using many
of the states anyway, and doesn't need to differentiate between
states like REBOOT/REBIND/RENEW anyway.  So simplify the DHCP states
into the ones we really care about.
2014-07-22 14:39:18 -05:00
Dan Williams
37b6fc1c85 dhcp: pass ifindex to DHCP clients 2014-07-22 14:33:39 -05:00
Jiří Klimeš
3ff1477349 device: add a new D-Bus 'Delete' method for removing software devices 2014-07-22 14:24:42 +02:00
Jiří Klimeš
bbf13002d3 device: indicate software devices in NMDeviceCapabilities
It is visible by clients in 'capabilities' property.
2014-07-22 14:24:42 +02:00
Thomas Haller
7a5af89f0b core: #include gsystem-local-alloc.h instead of libgsystem.h
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-15 22:47:43 +02:00
Thomas Haller
ff3b753857 core: use nm_utils_kill_child_async() and nm_utils_kill_child_sync()
Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-10 16:25:10 +02:00
Thomas Haller
62dd70e1d1 core: use singleton nm_firewall_manager_get() throughout without taking additional ref
No need to keep references of the singleton and take an additional ref
when accessing nm_firewall_manager_get().
Especially, since the firewall manager instance was nowhere passed in from
externally, it doesn't even sense for some vague testing purporse. Not to
mention, that there are no tests that actually inject a firewall manager stub.

Signed-off-by: Thomas Haller <thaller@redhat.com>
2014-07-02 15:27:32 +02:00