Commit graph

16224 commits

Author SHA1 Message Date
Lubomir Rintel df46c59775 nm-object: initialize the object buffer to zero 2016-11-10 16:48:47 +01:00
Thomas Haller 2481eaac15 man: clarify HWADDR for nm-setting-ifcfg-rh manual 2016-11-10 14:08:41 +01:00
Thomas Haller 81d058b5e8 team: log PID of died teamd instance 2016-11-10 10:56:35 +01:00
Thomas Haller 60be9cbc9e device: fix memleak for ndisc_search->domain in ndisc_set_router_config()
It is a bit fragile not to clone the string because we depend on
nm_ip6_config_get_search(priv->ip6_config) to be stable.

In practice, it's no problem. Saves an additional strdup and the
effort to cleanup the memory afterwards.
2016-11-10 10:19:57 +01:00
Thomas Haller b058c45d28 tests: fix run-nm-test.sh to use valgrind when --called-from-make
Fixes: dbafd2ce50
2016-11-10 10:06:40 +01:00
Thomas Haller aeeee116c7 device: fix array indexing in ndisc_set_router_config()
Fixes: de52c25cfd
2016-11-10 10:04:03 +01:00
Thomas Haller ba2b2de3ad build: allow using GCC C99 dialect instead of C89
We already use several GCC extenions, like typeof() and
__attribute__((cleanup)). They are too convinient to miss
and every supported compiler must support these.
Currently, gcc and clang does. Maybe other compilers would
support that too, but who knows, nobody seems to test that.

We also already use stdbool.h (C99) and the imported systemd
code is mostly gnu99 too (it's not clear to me, because I don't
find it precisely documented. Certainly it makes use of C99 features
too).

C99/gnu99 has some nice improvements that we no longer should miss
out. For example "flexible array members" or "variable declaration
in init-part of for loop".

It doesn't mean we have to use every obscure (badly supported?)
feature, it means we don't have to forgo features that are well
supported. C99 is 17 years old, I mean, really...

If somebody comes along and ports NM to non-gcc/clang, we can address
bugs about unsupported language features as they surface.
But let's not restrict us to some hypothetical compiler (or language
specification).

Also, NetworkManager is not ported on environment beside Linux.
We don't have to be so considerate about the required build environment.
Gcc is probably the most portable compiler out there. I doubt porting
NetworkManager to *BSD fails due to missing gnu99 features. And if that
causes issues, we should fix them after they happen in practice.
2016-11-10 09:34:39 +01:00
Thomas Haller de52c25cfd device: refactor ndisc_set_router_config()
- only record @now timestamp if we actually need it.
- use gint32 for @now. It seems wrong that NMNDiscDNSServer
  uses guint32 for the timestamp. We keep
  nm_utils_get_monotonic_timestamp_s() as gint32 for a reason.
- ensure the arrays are initialized to zero. E.g.
  ndisc_addr->dad_counter was uninitalized.
- set the size for arrays outside the loop
- use g_array_unref(). I think that is usually better. It makes
  only a difference when somebody else holds a reference to the
  array. And in that case, it usually seems better not to clear
  the array, just release your refrence.
2016-11-10 09:30:05 +01:00
Lubomir Rintel 2b304d82d7 device: properly size the arrays 2016-11-10 08:10:28 +01:00
Lubomir Rintel 3d7931bbf6 ifcfg-rh: fix a memory leak 2016-11-09 20:34:13 +01:00
Thomas Haller 0759f7fbdb policy: fix memleak in clear_ip6_prefix_delegation() 2016-11-09 18:16:48 +01:00
Thomas Haller 6c59784a59 policy: make dispose() reentrant and indention 2016-11-09 18:16:48 +01:00
Beniamino Galvani d9b529b47b merge: branch 'bg/tui-ip-tunnel-rh1391424'
https://bugzilla.redhat.com/show_bug.cgi?id=1391424
2016-11-09 17:51:49 +01:00
Thomas Haller 602247e8e3 ip-tunnel: avoid crash on missing NMPlatformLnkIp6Tnl lnk part
You cannot assume that we are always able to lookup a corresponding
lnk object. In fact, there is no guarantee that link->ifindex still
exists in the platform cache at all.
2016-11-09 17:45:39 +01:00
Thomas Haller a6416cbd13 ip-tunnel: tigthen up checks for valid IP tunnel modes
The compiler warns us when we don't specify all enum values
in a switch(), provided that default: is missing.

Make use of that to get a warning when we add a new tunnel mode.
2016-11-09 17:45:39 +01:00
Beniamino Galvani cd73f281cc tui: add support for IP tunnel connections 2016-11-09 17:45:39 +01:00
Beniamino Galvani 2805555bd2 ip-tunnel: fail the activation for unknown tunnel modes
When an IP-tunnel connection with mode different from the implemented
ones was activated, an assertion failed in tunnel_mode_to_link_type().

Instead we should return NM_LINK_TYPE_UNKNOWN there and fail the
activation.
2016-11-09 17:45:34 +01:00
Beniamino Galvani 5aea82d383 libnm-core: ensure a IP tunnel connection specifies a remote IP
The IP of the remote endpoint is always required.
2016-11-09 17:45:34 +01:00
Beniamino Galvani 75127b1348 libnm: add missing device includes in NetworkManager.h
And also sort the setting includes alphabetically.
2016-11-09 17:45:34 +01:00
Lubomir Rintel ecc6040cd8 merge: branch 'lr/ipv6-sharing'
https://bugzilla.gnome.org/show_bug.cgi?id=773777
2016-11-09 17:26:21 +01:00
Lubomir Rintel ec12fcf6bf policy: delegate IPv6 configuration to ipv6.method=shared connections
The policy listens to signals from shared devices that need subnets and
requesting devices that provide prefixes. Whenever a subnet is needed,
policy tries to obtain a subnets from all of default6 device's prefixes.
When it fails to get any, it asks for more prefixes.

This way we make it possible for the delegating router to either
provide us with a /64 for each of our shared interfaces, or provide a
larger prefix that we could subnet.

The policy also updates the shared device's DNS information to keep it in sync
with the best requesting device changes.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 479ad5065e device: add IPv6 configuration delegation machinery
There's two parts of the configuration involved: the subnet addresses
and the DNS information.

For the addressing, the shared (downlink) device signals the policy needs for a
/64 subnet. When it gets one, it merges it into the autoconf configuration and
forwards to the NDisc. When more prefixes are needed, the (uplink) device asks
the DHCP manager and eventually signals delegation (reception) of a prefix.
The NMDevice only provides the mechanism, the actual subnetting needs to
be done by the NMPolicy.

For the DNS configuration, the shared device just copies it from
whichever device the policy deems suitable.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 4ec37b0364 dhcp-manager: add ability to specify the number of IPv6 prefixes to request
Utilizes RFC 3633 prefix option in role of requesting router to ask the
delegating router for prefixes. In future we'll be able to use the
addresses from those prefixes on ipv6.method=shared connections.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 7d195856cc dhcp-manager: move the options logging one level up
It will make sense to log the options even if we're not creating an
ip6_config (e.g. we got a prefix option, not an address).

Also, guard it with a logging enable conditional. That way we save
precious microseconds so that we'll feel less guilty about the demise of
mankind and universe.
2016-11-09 17:23:32 +01:00
Lubomir Rintel d74e5e45e5 manager: allow ipv6.medhod=shared connections 2016-11-09 17:23:32 +01:00
Lubomir Rintel bda1e880de device: enable the IPv6 forwarding for shared connections
Useful when they have  internet-routable prefixes, consistent with IPv4.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 46e63e03af device: announce the managed IPv6 configuration with ipv6.method=shared
This esentially causes us to announce the prefixes of the addresses we
own and the DNS configuration.

Currently the only way to get the IPv6 configuration on such device is
manual setting in the connection. This will change with IPv6 prefix
delegation.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 0e6d194060 settings: allow method=shared with manual IPv6 configuration
IPv4 already allows setting an address, reusing its prefix for the network
it shares connection with. Additionally, for IPv6, the NDP can also share
the DNS configuration.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 611870347a ifcfg: add ability to save/restore ipv6.method=shared
We use IPV6_AUTOCONF=shared for this.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 6387856602 ndisc/lndp: add ability to announce the managed IPv6 configuration
Announce the prefixes and DNS configuration.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 425ce65ed0 ndisc: rename the config-changed signal
The ndisc config can now be changed by NMDevice as well when the NDisc
is in ROUTER mode. But what we're really interested in is when we
receive a new one from the outside.
2016-11-09 17:23:32 +01:00
Lubomir Rintel 87624a6c50 ndisc: add logic for acting as a router 2016-11-09 17:23:32 +01:00
Lubomir Rintel be6a0c7ce5 ndisc: move the logging deduplication into a macro
We'll want to use it elsewhere.
2016-11-09 17:23:32 +01:00
Lubomir Rintel aed2106d3e ndisc: avoid calling start() multiple times
It hooks on ndp event callbacks and we'll end up in them being done
redundantly, leaking them on dispose and potentially even calling them.
2016-11-09 17:23:31 +01:00
Lubomir Rintel 679f8dfc7d ndisc/trivial: move nm_ndisc_set_iid upwards 2016-11-09 17:23:31 +01:00
Lubomir Rintel c84313a2b7 ndisc/lndp: drop an unused variable 2016-11-09 17:16:48 +01:00
Lubomir Rintel d09aea62ee ndisc/trivial: add a couple of comments of where do the constants come from 2016-11-09 17:16:48 +01:00
Lubomir Rintel f69b6c038e device: the domain list from DNSSL is in fact a search list 2016-11-09 17:16:48 +01:00
Lubomir Rintel 44fca246a7 rdisc: rename to ndisc
We'll soon not only do the router discovery, but announce ourselves as a
reouter. "Neighbor discovery" sounds to be a more appropriate name for
the class than "Router discovery".
2016-11-09 17:16:47 +01:00
Lubomir Rintel aa71dbc6c4 device: avoid a crash when L3 configuration fails
Don't call the IP check until at either IPv4 or IPv6 is actually
configured.
2016-11-09 15:06:21 +01:00
Lubomir Rintel 2e8f40f2c9 ifcfg-rh: avoid parsing the IPV6_PRIVACY string twice
This saves a couple of CPU cycles that would be better used for
something more useful, such as looking for transmissions from aliens.
2016-11-09 15:06:20 +01:00
Lubomir Rintel 577ba42e18 ifcfg-rh: get rid of an extra unused variable
This saves a couple of bits we could instead use to save memories of the
better days.
2016-11-09 15:06:20 +01:00
Lubomir Rintel b49c194f84 linux: don't assume short write when the kernel ignores the trailing whitespace
Certain sysctls don't appreciate the final newline. That's completely
fine.

  17941 open("/proc/sys/net/ipv6/conf/eth2/forwarding", O_WRONLY|O_TRUNC) = 21
  17941 write(21, "1\n", 2)               = 1
2016-11-09 15:06:20 +01:00
Lubomir Rintel 7279ea1317 client: don't do g_criticals
Also, be a bit more careful about the layers of errors. Just don't do this:

   (process:236): nmcli-CRITICAL **: Error: Could not create NMClient object:
     Permissions request failed: Authorization check failed:
     The name org.freedesktop.PolicyKit1 was not provided by any .service files.
2016-11-09 15:06:20 +01:00
Lubomir Rintel 2dd384c817 utils: allow valid_lft=0 addresses
We use the lifetime of 0 to indicate permanent addresses while
DHCP uses that lifetime to indicate the addresses should be removed.
Use the presence of a timestamp to differentiate the two.

  dhclient[10867]: XMT: Rebind on wls1, interval 1030ms.
  dhclient[10867]: RCV: Reply message on wls1 from fe80::21e:8cff:feec:3ca2.
  NetworkManager[10481]: <info>  [1478020967.7634] dhcp6 (wls1):   valid_lft 0
  NetworkManager[10481]: <info>  [1478020967.7634] dhcp6 (wls1):   preferred_lft 0
  NetworkManager[10481]: <info>  [1478020967.7636] dhcp6 (wls1):   address fd25:d463:2f14::927
  NetworkManager[10481]: <info>  [1478020967.7636] dhcp6 (wls1):   nameserver 'fe80::21e:8cff:feec:3ca2'
  NetworkManager[10481]: <info>  [1478020967.7637] dhcp (wls1):   domain search 'venom.'
  NetworkManager[10481]: <info>  [1478020967.7637] dhcp6 (wls1): state changed unknown -> bound, event ID="fa💿2c:86|1478020967"
  NetworkManager[10481]: ((src/nm-core-utils.c:3521)): assertion '<dropped>' failed
2016-11-09 15:06:20 +01:00
Lubomir Rintel ccb789edc2 device: ipv6.method=link-local does not need slaves
It already waits for carrier, which is sufficient -- DAD won't start
until there's carrier.
2016-11-09 15:06:20 +01:00
Lubomir Rintel f708184d6f device: don't fail the device if IPv4 forwarding fails
Just fail the IPv4 method.

Plus improve some comments.
2016-11-09 15:06:20 +01:00
Lubomir Rintel 888d8f4b10 ifcfg-rh: add parentheses
The code is now perfect.
2016-11-09 15:06:20 +01:00
Lubomir Rintel c2ceacb419 device: make some asserts less harsh
We're terrible programmers, but we don't need anyone to notice!
2016-11-09 15:06:20 +01:00
Lubomir Rintel 90beb7689a ifcfg-rh: drop an unused variable
Fixes: ecda08e1d1
2016-11-09 15:06:00 +01:00