Commit graph

414 commits

Author SHA1 Message Date
Tom Yan 4cef7fe3d1 networkd: Disable IPv6 when DHCPv6 is only enabled
DHCPv6 requires an IPv6 link-local address to work. The client will not be started (even when enabled explicitly with `DHCP=`) if none is configured (either by autoconfiguration or manually). Therefore, disable IPv6 in such case.
2016-05-25 20:40:48 +08:00
Tom Yan fbc38f230b networkd: set IFLA_INET6_ADDR_GEN_MODE as per stable_secret
Although networkd has option (LinkLocalAddressing=) to toggle IPv6LL autoconfiguration, when it is enabled, the address is autoconfigured by the kernel, but not networkd.

Therefore, we do not statically set IFLA_INET6_ADDR_GEN_MODE to IN6_ADDR_GEN_MODE_EUI64, but dynamically depending on whether stable_secret is set, just as what the kernel does by default.

Note that this does NOT affect the global addresses configured by networkd.
2016-05-25 20:04:01 +08:00
Susant Sahani 7209086d8a networkd: do not update state or IPv6LL address if link is failed or lingering
This is partial fix for #2228 and #2977, #3204.

bridge-test: netdev ready
docker0: Gained IPv6LL
wlan0: Gained IPv6LL
eth0: Gained IPv6LL
Enumeration completed
bridge-test: netdev exists, using existing without changing its
parameters
vboxnet0: IPv6 enabled for interface: Success
lo: Configured
docker0: Could not drop address: No such process
vboxnet0: Gained carrier
wlan0: Could not drop address: No such process
eth0: Could not drop address: No such process
eth0: Could not drop address: No such process
eth0: Could not drop address: No such process
vboxnet0: Gained IPv6LL
vboxnet0: Could not set NDisc route or address: Invalid argument
vboxnet0: Failed
[New Thread 0x7ffff6505700 (LWP 1111)]
[Thread 0x7ffff6505700 (LWP 1111) exited]
Assertion 'link->state == LINK_STATE_SETTING_ROUTES' failed at
src/network/networkd-link.c:672, function link_enter_configured().
Aborting.

Program received signal SIGABRT, Aborted.
0x00007ffff6dc6a98 in raise () from /lib64/libc.so.6
Missing separate debuginfos, use: dnf debuginfo-install
iptables-1.4.21-15.fc23.x86_64 libattr-2.4.47-14.fc23.x86_64
libidn-1.32-1.fc23.x86_64 pcre-8.38-7.fc23.x86_64

Debugging

(gdb) bt
"link->state == LINK_STATE_SETTING_ROUTES", file=0x5555556a34c8
"src/network/networkd-link.c", line=672,
    func=0x5555556a56d0 <__PRETTY_FUNCTION__.14850>
"link_enter_configured") at src/basic/log.c:788
src/network/networkd-link.c:672
src/network/networkd-link.c:720
flags=0 '\000', scope=0 '\000', cinfo=0x7fffffffe020) at
src/network/networkd-address.c:344
(rtnl=0x5555556eded0, message=0x55555570ff20, userdata=0x5555556ec590)
at src/network/networkd-manager.c:604
m=0x55555570ff20) at src/libsystemd/sd-netlink/sd-netlink.c:365
at src/libsystemd/sd-netlink/sd-netlink.c:395
ret=0x0) at src/libsystemd/sd-netlink/sd-netlink.c:429
revents=1, userdata=0x5555556eded0) at
src/libsystemd/sd-netlink/sd-netlink.c:723
src/libsystemd/sd-event/sd-event.c:2268
src/libsystemd/sd-event/sd-event.c:2629
timeout=18446744073709551615) at src/libsystemd/sd-event/sd-event.c:2688
bus=0x5555556eeba0, name=0x55555568a2f5 "org.freedesktop.network1",
timeout=30000000,
    check_idle=0x55555556adb6 <manager_check_idle>,
userdata=0x5555556ec590) at src/shared/bus-util.c:134
src/network/networkd-manager.c:1130
src/network/networkd.c:127

(gdb) f 3
src/network/networkd-link.c:672
672         assert(link->state == LINK_STATE_SETTING_ROUTES);
(gdb) p link->state
$1 = LINK_STATE_FAILED

We should not be in this state .

even if vboxnet0 failed we went into this state.

vboxnet0: Could not set NDisc route or address: Invalid argument
vboxnet0: Failed
2016-05-17 22:59:56 -04:00
Clemens Gruber 77ff6022fa networkd: Add EmitRouter= option for DHCP Server (#3251)
Add an option to disable appending DHCP option 3 (Router) to the DHCP
OFFER and ACK packets.
This commit adds the boolean option EmitRouter= for the [DHCPServer]
section in .network files.

Rationale: On embedded devices, it is very useful to have a DHCP server
running on an USB OTG ethernet gadget interface to avoid manual setup on
the client PCs, but it should only serve IP addresses, no route(r)s.
Otherwise, Windows clients experience network connectivity issues, due
to them using the address set in DHCP option 3 as default gateway.

Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
2016-05-17 19:34:25 -04:00
Zbigniew Jędrzejewski-Szmek 483d099e16 tree-wide: drop spurious "&"s when passing functions around
Also adjust indentation in various places.
2016-05-15 19:56:59 -04:00
Lennart Poettering 7272b25e16 networkd: reworkd LLDP emission to allow control of propagation level
This allows selecting the propagation level of emitted LLDP packets
(specifically: the destination MAC address of the packets). This is useful
because it allows generating LLDP packets that optionally cross certain types
of bridges.

See 802.11ab-2009, Table 7-1 for details.
2016-05-09 15:45:31 +02:00
Zbigniew Jędrzejewski-Szmek 8341a5c381 networkd: rework duid_{type,duid_type,duid,duid_len} setting
Separate fields are replaced  with a struct.

Second second duid type field is removed. The first field was used to carry
the result of DUIDType= configuration, and the second was either a copy of
this, or contained the type extracted from DuidRawData. The semantics are changed
so that the type specified in DUIDType is always used. DUIDRawData= no longer
overrides the type setting.

The networkd code is now more constrained than the sd-dhcp code:
DUIDRawData cannot have 0 length, length 0 is treated the same as unsetting.
Likewise, it is not possible to set a DUIDType=0. If it ever becomes necessary
to set type=0 or a zero-length duid, the code can be changed to support that.
Nevertheless, I think that's unlikely.

This addresses #3127 § 1 and 3.

v2:
- rename DUID.duid, DUID.duid_len to DUID.raw_data, DUID.raw_data_len
2016-05-03 12:23:01 -04:00
Zbigniew Jędrzejewski-Szmek 634f0f983c networkd: rework headers to avoid circular includes
Header files were organized in a way where the includer would add various
typedefs used by the includee before including it, resulting in a tangled
web of dependencies between files.

Replace this with the following logic:

          networkd.h
         /          \
networkd-link.h      \
networkd-ipv4ll.h--\__\
networkd-fdb.h         \
networkd-network.h    netword-netdev-*.h
networkd-route.h           \
                      networkd-netdev.h

If a pointer to a structure defined in a different header file is needed,
use a typedef line instead of including the whole header.
2016-04-29 19:01:28 -04:00
Lennart Poettering e0a24179c0 Merge pull request #3137 from keszybz/dirent-simplification
Various small cleanups in shared code
2016-04-29 10:40:15 +02:00
Susant Sahani 6fc2549711 networkd: reconfigure IPv6 and static address after link up event (#3105)
Now we are not setting static address, start dhcp6 client and
discovering IPv6 routers after link gained carrier.

This fixes #2912.
2016-04-28 19:03:29 -04:00
Zbigniew Jędrzejewski-Szmek b1e02ee7cf networkd: drop unnecessary stmt 2016-04-27 09:05:42 -04:00
Lennart Poettering fa7099927c networkd: consider various IPv6 features as disabled if IPv6 is not available in the kernel 2016-04-22 16:06:20 +02:00
Susant Sahani 0c241a378d networkd: When link gets dirty mark manager dirty too (#3080)
If we not marking manager dirty when link is dirty then
the state file is not updated. This is a side effect of
issue 2850
setting CriticalConnection=yes

timesyncd NTP servers given by DHCP server are ignored.
2016-04-21 16:08:07 +02:00
Susant Sahani 439689c6ec networkd: bump MTU to 1280 for interfaces which have IPv6 enabled (#3077)
IPv6 protocol requires a minimum MTU of 1280 bytes on the interface.
This fixes #3046.

Introduce helper link_ipv6_enabled() to figure out whether IPV6 is enabled.
Introduce network_has_static_ipv6_addresses() to find out if any static
ipv6 address configured.
If IPv6 is not configured on any interface that is SLAAC, DHCPv6 and static
IPv6 addresses not configured, then IPv6 will be automatically disabled for that
interface, that is we write "1" to /proc/sys/net/ipv6/conf//disable_ipv6.
2016-04-20 20:34:13 -04:00
Susant Sahani 23d8b221c0 networkd: Add support to configure proxy arp support to interfaces (#3020)
Fixes: #2889
2016-04-14 11:56:57 +02:00
Zbigniew Jędrzejewski-Szmek 1db30aeab1 Merge pull request #2915 from vinaykul/master 2016-03-31 00:52:23 -04:00
Vinay Kulkarni 413708d106 DHCP DUID, IAID configuration options 2016-03-30 16:33:55 -07:00
Beniamino Galvani 6afa676780 lldp: move public macros to sd-lldp.h and namespace them
lldp.h contains definitions of LLDP types, subtypes and capabilities which
should be exposed in public headers. Get rid of the file and move those
definitions to sd-lldp.h with the SD_ prefix.
2016-03-24 16:41:48 +01:00
Zbigniew Jędrzejewski-Szmek afec45395f Revert "DHCP DUID and IAID configurability" 2016-03-21 18:24:24 -04:00
Vinay Kulkarni c83321e6d4 DHCP DUID and IAID configurability 2016-03-09 21:58:44 -08:00
Vito Caputo 9ed794a32d tree-wide: minor formatting inconsistency cleanups 2016-02-23 14:20:34 -08:00
Vito Caputo 313cefa1d9 tree-wide: make ++/-- usage consistent WRT spacing
Throughout the tree there's spurious use of spaces separating ++ and --
operators from their respective operands.  Make ++ and -- operator
consistent with the majority of existing uses; discard the spaces.
2016-02-22 20:32:04 -08:00
Lennart Poettering 90dffb2241 sd-lldp: beef up callback logic
Instead of just notifying about the fact that something changed in the
database, actually inform the callback what precisely changed. This is useful,
so that the LLDP tx logic can be put into "fast" mode as soon as a previously
unknown peer appears, as suggested by the LLDP spec.
2016-02-21 20:58:59 +01:00
Lennart Poettering 8e1ad1eaf7 networkd: add basic LLDP transmission support
Let's add some minimalistic LLDP sender support. The idea is that this is
either on or off, and all fields determined automatically rather than
configured explicitly.
2016-02-21 20:58:59 +01:00
Lennart Poettering b553a6b13c sd-lldp: filter out LLDP messages coming from our own MAC address
Let's not get confused should we be connected to some bridge that mirrors back
our packets.
2016-02-21 20:40:58 +01:00
Lennart Poettering b9d74c40c6 networkd: make a couple of functions static
These functions are nowadays used only within networkd-link.c, hence ther's no
point in littering our public namespace with them.
2016-02-21 20:40:57 +01:00
Lennart Poettering 273eec24f5 networkd: rework when LLDP reception is enabled
Being on the link-layer LLDP is nothing we should turn on only when there's a
link beat. Instead, turn it on, whenever the iface is UP regardless if there's
a link beat or not. This closes the race between a link beat being available
and us subscribing to LLDP as a result.
2016-02-21 20:40:57 +01:00
Lennart Poettering b295beea88 networkd: rework how carrier bindings are serialized
Instead of serializing the interface name, expose the interface index, since
that's the only stable identifier.
2016-02-21 20:40:57 +01:00
Lennart Poettering 34437b4f9c sd-lldp: rework sd-lldp API
This reworks the sd-lldp substantially, simplifying things on one hand, and
extending the logic a bit on the other.

Specifically:

- Besides the sd_lldp object only one other object is maintained now,
  sd_lldp_neighbor. It's used both as storage for literal LLDP packets, and for
  maintainging info about peers in the database. Separation between packet, TLV
  and chassis data is not maintained anymore. This should be a major
  simplification.

- The sd-lldp API has been extended so that a couple of per-neighbor fields may
  be queried directly, without iterating through the object. Other fields that
  may appear multiple times, OTOH have to be iterated through.

- The maximum number of entries in the neighbor database is now configurable
  during runtime.

- The generation of callbacks from sd_lldp objects is more restricted:
  callbacks are only invoked when actual data changed.

- The TTL information is now hooked with a timer event, so that removals from
  the neighbor database due to TTLs now result in a callback event.

- Querying LLDP neighbor database will now return a strictly ordered array, to
  guarantee stability.

- A "capabilities" mask may now be configured, that selects what type of LLDP
  neighbor data is collected. This may be used to restrict collection of LLDP
  info about routers instead of all neighbors. This is now exposed via
  networkd's LLDP= setting.

- sd-lldp's API to serialize the collected data to text files has been removed.
  Instead, there's now an API to extract the raw binary data from LLDP neighbor
  objects, as well as one to convert this raw binary data back to an LLDP
  neighbor object. networkd will save this raw binary data to /run now, and the
  client side can simply parse the information.

- support for parsing the more exotic TLVs has been removed, since we are not
  using that. Instead there are now APIs to extract the raw data from TLVs.
  Given how easy it is to parse the TLVs clients should do so now directly
  instead of relying on our APIs for that.

- A lot of the APIs that parse out LLDP strings have been simplified so that
  they actually return strings, instead of char arrays with a length. To deal
  with possibly dangerous characters the strings are escaped if needed.

- APIs to extract and format the chassis and port IDs as strings has been
  added.

- lldp.h has been simplified a lot. The enums are anonymous now, since they
  were never used as enums, but simply as constants. Most definitions we don't
  actually use ourselves have eben removed.
2016-02-21 20:40:56 +01:00
Lennart Poettering 36c7d7097b networkd: fix logging of error codes 2016-02-20 22:42:29 +01:00
Lennart Poettering b710e6b68d networkd: enable LLDP only on ethernet 2016-02-20 22:42:29 +01:00
Lennart Poettering 032b27f534 sd-lldp: drop "port" object
Let's just keep the few parts we actually need of it in the main sd_lldp
object, so that we can simplify things quite a bit.

While we are at it, remove ifname and mac fields which we make no use of
whatsoever.
2016-02-20 22:42:29 +01:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Lennart Poettering d390f8ef2d util: introduce fputs_with_space() and make use of it at various places
The call combines outputing a string with prefixing it with a space, optionally. This is useful to shorten the logic
for outputing lists of strings, that are space separated.
2016-01-26 14:42:04 +01:00
Lennart Poettering b2a81c0b52 networkd: optinally use DHCP lease domain info for routing only
This changes the UseDomains= setting of .network files to take an optional third value "route", in addition to the
boolean values. If set, the passed domain information is used for routing rules only, but not for the search path
logic.
2016-01-26 14:42:04 +01:00
Lennart Poettering 27cb34f574 networkd: rename a few Network object properties to be more like the configuration settings
All booleans called dhcp_xyz are now called ".dhcp_use_xyz", to match their respective configuration file settings. This
should clarify things a bit, in particular as there is a DHCP hostname that was previously called just ".hostname"
because ".dhcp_hostname" was already existing as a bool. Since this confusion is removed now because the bool is called
".dhcp_use_hostname", the string field is now renamed to ".dhcp_hostname".
2016-01-26 14:42:04 +01:00
Lennart Poettering 3df9bec57c networkd: rework Domains= setting
Previously, .network files only knew a vaguely defined "Domains=" concept, for which the documentation declared it was
the "DNS domain" for the network connection, without specifying what that means.

With this the Domains setting is reworked, so that there are now "routing" domains and "search" domains. The former are
to be used by resolved to route DNS request to specific network interfaces, the latter is to be used for searching
single-label hostnames with (in addition to being used for routing). Both settings are configured in the "Domains="
setting. Normal domain names listed in it are now considered search domains (for compatibility with existing setups),
while those prefixed with "~" are considered routing domains only. To route all lookups to a specific interface the
routing domain "." may be used, referring to the root domain. An alternative syntax for this is the "*", as was already
implemented before using the "wildcard" domain concept.

This commit adds proper parsers for this new logic, and exposes this via the sd-network API. This information is not
used by resolved yet, this will be added in a later commit.
2016-01-26 14:42:03 +01:00
Tom Gundersen 4ddbb47472 Merge pull request #2267 from gdamjan/dont-drop-critical
networkd: link - do not drop config for critical interfaces
2016-01-20 17:33:59 +01:00
Daniel Mack 201f0c916d tree-wide: unify argument lists of IN_SET()
The new implementation will not allow passing the same values more than
once, so clean up first.
2016-01-10 18:10:08 +01:00
Lennart Poettering 8a516214c4 resolved: introduce support for per-interface negative trust anchors 2016-01-06 18:36:32 +01:00
Lennart Poettering ad6c047561 resolved,networkd: add a per-interface DNSSEC setting
This adds a DNSSEC= setting to .network files, and makes resolved honour
them.
2016-01-05 20:10:31 +01:00
Lennart Poettering aaa297d4e5 networkd,resolved: add a per-interface mdns configuration option 2016-01-05 17:41:41 +01:00
Damjan Georgievski 02e2862194 networkd: link - do not drop config for critical interfaces
the idea is that interfaces marked as critical are typically used
for NFS root. networkd shouldn't drop that config.

discussion at #780
2016-01-05 01:00:16 +01:00
Lennart Poettering 4afd3348c7 tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
GLIB has recently started to officially support the gcc cleanup
attribute in its public API, hence let's do the same for our APIs.

With this patch we'll define an xyz_unrefp() call for each public
xyz_unref() call, to make it easy to use inside a
__attribute__((cleanup())) expression. Then, all code is ported over to
make use of this.

The new calls are also documented in the man pages, with examples how to
use them (well, I only added docs where the _unref() call itself already
had docs, and the examples, only cover sd_bus_unrefp() and
sd_event_unrefp()).

This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we
tend to call our destructors these days.

Note that this defines no public macro that wraps gcc's attribute and
makes it easier to use. While I think it's our duty in the library to
make our stuff easy to use, I figure it's not our duty to make gcc's own
features easy to use on its own. Most likely, client code which wants to
make use of this should define its own:

       #define _cleanup_(function) __attribute__((cleanup(function)))

Or similar, to make the gcc feature easier to use.

Making this logic public has the benefit that we can remove three header
files whose only purpose was to define these functions internally.

See #2008.
2015-11-27 19:19:36 +01:00
Christian Hesse e5d44b34cc networkd: link - do not drop config for loopback device
Commit 5e5b137a (networkd: link - drop foreign config when configuring
link) introduced a regression where addresses (including 127.0.0.1) are
removed from loopback device.
Do not handle loopback device when removing foreign configs.

Signed-off-by: Christian Hesse <mail@eworm.de>
2015-11-25 20:02:53 +01:00
Thomas Hindoe Paaboel Andersen 74544b4ead networkd: link - fix reading routes
This regressed during the port to extract_first_word in c598ac76
(v228).

CID #1338083
2015-11-22 18:53:36 +01:00
Tom Gundersen fe30727643 Revert "networkd: ndisc - revert to letting the kernel handle NDisc"
This reverts commit 23f186494c.

The bug has now been fixed, so we can go back to managing this ourselves.
2015-11-19 01:25:40 +01:00
Thomas Hindoe Paaboel Andersen 928bc597b7 network: fix indentation 2015-11-18 19:08:44 +01:00
Tom Gundersen 23f186494c networkd: ndisc - revert to letting the kernel handle NDisc
There is still a bug in the userspace version, so temporarily revert this.

This is a work-around for issue #1866.
2015-11-18 14:26:36 +01:00
Tom Gundersen c601ebf79f sd-dhcp6-client: bind to link-local address
This ensures that several DHCPv6 clients can run on separate interfaces
simultaneously.
2015-11-17 14:17:41 +01:00