Commit graph

284 commits

Author SHA1 Message Date
Nick Owens 8add5f7970 networkd: create "kernel" setting for IPForwarding
In 5a8bcb674f, IPForwarding was introduced
to set forwarding flags on interfaces in .network files. networkd sets
forwarding options regardless of the previous setting, even if it was
set by e.g. sysctl. This commit creates a new option for IPForwarding,
"kernel", that preserves the sysctl settings rather than always setting
them.

See https://bugs.freedesktop.org/show_bug.cgi?id=89509 for the initial
bug report.
2015-06-11 12:09:21 -07:00
Umut Tezduyar Lindskog 9c34154a2b networkd: use async convenience call to set hostname 2015-06-10 13:15:39 +02:00
Lennart Poettering e941c27331 Merge pull request #113 from mezcalero/address-family
networkd: actually always use AddressFamilyBoolean as the bit mask it is
2015-06-09 10:47:04 +02:00
Lennart Poettering e0ee46f290 networkd: actually always use AddressFamilyBoolean as the bit mask it is 2015-06-09 01:21:02 +02:00
Lennart Poettering ee0eb1d891 Revert "networkd: create "kernel" setting for IPForwarding" 2015-06-08 23:24:32 +02:00
Nick Owens a70ec7f19f networkd: create "kernel" setting for IPForwarding
In 5a8bcb674f, IPForwarding was introduced
to set forwarding flags on interfaces in .network files. networkd sets
forwarding options regardless of the previous setting, even if it was
set by e.g. sysctl. This commit creates a new option for IPForwarding,
"kernel", that preserves the sysctl settings rather than always setting
them.

See https://bugs.freedesktop.org/show_bug.cgi?id=89509 for the initial
bug report.
2015-06-02 15:31:48 -07:00
Tom Gundersen 01d28f81a7 networkd: fix IFF_UP when ipv6 support is disabled
Passing ipv6 options (even when they should be noops) caused IFF_UP to fail when
ipv6 was supported.

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=90103
2015-05-25 17:41:42 +02:00
Lennart Poettering fe0272999c networkd: don't try to turn on ipv6 forwarding if kernel lacks IPv6 support
http://lists.freedesktop.org/archives/systemd-devel/2015-May/031598.html
2015-05-15 12:20:36 +02:00
Benedikt Morbach 505c5f6de1 networkd: don't touch global forwarding setting
This reverts commit 43c6d5abac
(and a small part of 4046d8361c)

It turns out we don't actually need to set the global ip_forward setting.
The only relevant setting is the one on each interface.

What the global toggle actually does is switch forwarding on/off for all
currently present interfaces and change the default for new ones.

That means that by setting the global ip_forward we

  - Introduce a race condition, because if the interface with IPForward=yes
    is brought up after one with IPForward=no, both will have forwarding
    enabled, because the global switch turns it on for all interfaces.
    If the other interface comes up first networkd correctly sets forward=0
    and it doesn't get overridden.

  - Change the forwarding setting for interfaces that networkd is not
    configured to touch, even if the user disabled forwarding via sysctl,
    either globally or per-interface

As forwarding works fine without this, as long as all relevant interfacest
individually set IPForward=yes:  just drop it

This means that non-networkd interfaces use the global default while
networkd interfaces default to off if IPForward isn't given.
2015-05-15 12:13:35 +02:00
Lennart Poettering f2341e0a87 core,network: major per-object logging rework
This changes log_unit_info() (and friends) to take a real Unit* object
insted of just a unit name as parameter. The call will now prefix all
logged messages with the unit name, thus allowing the unit name to be
dropped from the various passed romat strings, simplifying invocations
drastically, and unifying log output across messages. Also, UNIT= vs.
USER_UNIT= is now derived from the Manager object attached to the Unit
object, instead of getpid(). This has the benefit of correcting the
field for --test runs.

Also contains a couple of other logging improvements:

- Drops a couple of strerror() invocations in favour of using %m.

- Not only .mount units now warn if a symlinks exist for the mount
  point already, .automount units do that too, now.

- A few invocations of log_struct() that didn't actually pass any
  additional structured data have been replaced by simpler invocations
  of log_unit_info() and friends.

- For structured data a new LOG_UNIT_MESSAGE() macro has been added,
  that works like LOG_MESSAGE() but prefixes the message with the unit
  name. Similar, there's now LOG_LINK_MESSAGE() and
  LOG_NETDEV_MESSAGE().

- For structured data new LOG_UNIT_ID(), LOG_LINK_INTERFACE(),
  LOG_NETDEV_INTERFACE() macros have been added that generate the
  necessary per object fields. The old log_unit_struct() call has been
  removed in favour of these new macros used in raw log_struct()
  invocations. In addition to removing one more function call this
  allows generated structured log messages that contain two object
  fields, as necessary for example for network interfaces that are
  joined into another network interface, and whose messages shall be
  indexed by both.

- The LOG_ERRNO() macro has been removed, in favour of
  log_struct_errno(). The latter has the benefit of ensuring that %m in
  format strings is properly resolved to the specified error number.

- A number of logging messages have been converted to use
  log_unit_info() instead of log_info()

- The client code in sysv-generator no longer #includes core code from
  src/core/.

- log_unit_full_errno() has been removed, log_unit_full() instead takes
  an errno now, too.

- log_unit_info(), log_link_info(), log_netdev_info() and friends, now
  avoid double evaluation of their parameters
2015-05-11 22:24:45 +02:00
Patrik Flykt be3a09b7ff network: Implement fallback DHCPv6 prefix handling for older kernels
When setting IPv6 addresses acquired by DHCPv6, systemd-networkd sets
the IFA_F_NOPREFIXROUTE flag in the IFA_FLAGS netlink attribute. As
the flag and the attribute are present starting with Linux 3.14, older
kernels will need systemd-network to manage prefix route expiry.

By default, DHCPv6 addresses are first assigned setting the
IFA_F_NOPREFIXROUTE flag in the IFA_FLAGS netlink attribute. Should
the address assignment fail, the same assignment is tried without
the IFA_FLAGS attribute. Should also the second attempt fail, an error
is printed and address assignment ends with failure. As successful use
of the IFA_FLAGS netlink attribute is recorded in the Link structure,
the DHCPv6 code will know if the kernel or systemd-network fallback
code handles expiring prefixes.

The prefix expiration and IPv6 address updating fallback code is
resurrected from the parts deleted with commit
47d45d3cde.

This patch can be removed once the minimum kernel requirements are
greater than or equal to 3.14.
2015-05-04 09:42:37 +03:00
Lennart Poettering 190700621f sd-bus: drop bus parameter from message callback prototype
This should simplify the prototype a bit. The bus parameter is redundant
in most cases, and in the few where it matters it can be derived from
the message via sd_bus_message_get_bus().
2015-04-29 18:36:25 +02:00
Lennart Poettering 6a7a4e4d0a networkd: improve how networkd logs things
This makes adds a couple of fixes:

- Introduces log_netdev_error_errno() and friends, which takes an error
  number, and matches what log_link_error_errno() and friends do.

- Replaces a lof ot strerror() usage with log_netdev_error_errno(),
  log_link_error_errno() and log_erro_errno()

- Uppercases the first character of many log messages, after all this is
  supposed to be english language

- Drops manual negating of error codes before passing them to log
  functions, the log functions all do that internally anyway.

Some other minor fixes.

Behaviour should not change really.
2015-04-21 17:43:55 +02:00
Thomas Hindoe Paaboel Andersen 8489a3b769 networkd: do not assign the variable twice 2015-04-09 00:05:58 +02:00
Tom Gundersen cdfee94318 networkd: improve logging when processing links and addresses 2015-04-03 15:35:07 +02:00
Patrik Flykt 851c9f8273 systemd-networkd: Use IFA_F_NOPREFIXROUTE with IPv6 addresses
The IFA_F_NOPREFIXROUTE flag prevents the kernel from creating new onlink
prefixes when a DHCPv6 IPv6 address with a prefix length is set from user
space. IPv6 routing will follow the onlink status from Router Advertisment
Prefix Information options or any manually set route, which is the correct
thing to do.

As this flag has a larger value than what fits into an unsigned char, update
the flag attribute to an uint32_t and set it with an IFA_FLAGS attribute
when writing netlink messages to the kernel.
2015-03-27 13:57:13 +02:00
Alin Rauta 0d4ad91dd4 networkd: add support for Uplink Failure Detection
Introduce BindCarrier= to indicate the set of links that determine if
the current link should be brought UP or DOWN.

[tomegun: add a bit to commit message]
2015-02-27 13:58:30 -05:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Tom Gundersen 5c3072eab6 networkd: explicitly enable/disable ipv6ll addresses
The kernel does not like getting an empty container, so just always pass the parameter, even if
it is the default.
2015-02-12 14:23:02 +01:00
Tom Gundersen a245ced0d7 networkd: fdb - fix const warning 2015-02-11 13:13:50 +01:00
Tom Gundersen ea6ec096db networkd: fdb - refactor a bit
Pass around Link objcets rather than FdbEntry objects. The link objects have an up-to-date
ifname we can use for logging. match_name sholud _never_ be used for anything except
matching. Firstly, it may be unset (usually is), and secondly it may not be up-to-date.
2015-02-10 22:30:35 +01:00
Torstein Husebø e2acdb6b0f treewide: correct typos and use consistent "MAC" spelling 2015-02-09 14:32:49 +01:00
Tom Gundersen 7f77697a17 networkd: add support for IPv6 tokens
This allows the admin to set the host-specific part of IPv6 addresses, but still
receive the prefix via SLAAC.

.network file snippet:

[Network]
IPv6Token=::12

gives:

$ ip token
token ::12 dev eth0

This closes https://bugs.freedesktop.org/show_bug.cgi?id=81177.
2015-02-09 12:20:10 +01:00
Tom Gundersen d0d6a4cd70 networkd: generalize IPv4LL to LinkLocal
This allows both IPv4 and IPv6 link-local addresses to be enabled or disabled. By default
we still enable IPv6LL and disable IPv4LL. The old config option is kept for backwards
compatibility, but removed from the documentation.
2015-02-09 12:20:10 +01:00
Tom Gundersen a97dcc12e4 networkd: exit on idle
We will be woken up on rtnl or dbus activity, so let's just quit if some time has passed and that is the only thing that can happen.

Note that we will always stay around if we expect network activity (e.g. DHCP is enabled), as we are not restarted on that.
2015-02-05 12:04:19 +01:00
Tom Gundersen 3f171cabad networkd: don't unlink state files on exit
Only unlink state files on DELLINK. This allows sd-network to be used even when networkd is not running.
2015-02-05 11:50:46 +01:00
Tom Gundersen e331e24649 networkd: add basic dbus API
Only the very basics, more to come.

For now:

$ busctl tree org.freedesktop.network1
└─/org/freedesktop/network1
  └─/org/freedesktop/network1/link
    ├─/org/freedesktop/network1/link/1
    ├─/org/freedesktop/network1/link/2
    ├─/org/freedesktop/network1/link/3
    ├─/org/freedesktop/network1/link/4
    ├─/org/freedesktop/network1/link/5
    ├─/org/freedesktop/network1/link/6
    ├─/org/freedesktop/network1/link/7
    ├─/org/freedesktop/network1/link/8
    └─/org/freedesktop/network1/link/9

$ busctl introspect org.freedesktop.network1 /org/freedesktop/network1
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.network1.Manager    interface -         -            -
.OperationalState                   property  s         "carrier" emits-change

$ busctl introspect org.freedesktop.network1 /org/freedesktop/network1/link/1
NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
org.freedesktop.network1.Link       interface -         -            -
.AdministrativeState                property  s         "unmanaged" emits-change
.OperationalState                   property  s         "carrier" emits-change
2015-02-05 11:50:34 +01:00
Tom Gundersen 6a24f1484f networkd: don't warn about missing links unnecessarily
If we get a NEWLINK + NEWADDR between enumerating the links and enumerating the addresses, we
would get a warning that the link corresponding to the address does not exist. This is a false
warning as both the NEWLINK and NEWADDR would be processed after enumerating completed, so drop
it.
2015-02-05 11:50:34 +01:00
Tom Gundersen 9c0a72f961 networkd: handle suspend events 2015-02-03 22:20:38 +01:00
Lennart Poettering 63c372cb9d util: rework strappenda(), and rename it strjoina()
After all it is now much more like strjoin() than strappend(). At the
same time, add support for NULL sentinels, even if they are normally not
necessary.
2015-02-03 02:05:59 +01:00
Tom Gundersen d4cdbea555 networkd: dhcp-server - start as soon as addresses have been set
We would otherwise wait for the interface to be completely configured, which
could take considerable time with IPv4LL. As a result nspawn was very slow
at obtaining IP addresses.
2015-01-31 15:26:08 +01:00
Tom Gundersen 07e10d1a7c networkd: plug lldp leak 2015-01-21 23:02:22 +01:00
Lennart Poettering 43c6d5abac networkd: propagate IPFoward= per-interface setting also to /proc/sys/net/ipv4/ip_forward
We need to turn on /proc/sys/net/ipv4/ip_forward before the
per-interface forwarding setting is useful, hence let's propagate the
per-interface setting once to the system-wide setting.

Due to the unclear ownership rules of that flag, and the fact that
turning it on also has effects on other sysctl flags we try to minimize
changes to the flag, and only turn it on once. There's no logic to
turning it off again, but this should be fairly unproblematic as the
per-interface setting defaults to off anyway.
2015-01-13 20:55:13 +01:00
Lennart Poettering 769d324c99 networkd: make IP forwarding for IPv4 and IPv6 individually configurable 2015-01-13 20:17:07 +01:00
Lennart Poettering cb9fc36a12 networkd: introduce an AddressFamilyBoolean enum type
This introduces am AddressFamilyBoolean type that works more or less
like a booleaan, but can optionally turn on/off things for ipv4 and ipv6
independently. THis also ports the DHCP field over to it.
2015-01-13 20:17:06 +01:00
Lennart Poettering 5a8bcb674f networkd: add minimal IP forwarding and masquerading support to .network files
This adds two new settings to networkd's .network files:
IPForwarding=yes and IPMasquerade=yes. The former controls the
"forwarding" sysctl setting of the interface, thus controlling whether
IP forwarding shall be enabled on the specific interface. The latter
controls whether a firewall rule shall be installed that exposes traffic
coming from the interface as coming from the local host to all other
interfaces.

This also enables both options by default for container network
interfaces, thus making "systemd-nspawn --network-veth" have network
connectivity out of the box.
2015-01-13 13:55:15 +01:00
Tom Gundersen bfcdba8d56 networkd: link - plug leak 2014-12-19 08:34:04 +01:00
Susant Sahani 49699bac94 LLDP: Add support for networkctl 2014-12-19 08:15:05 +05:30
Susant Sahani ce43e48446 networkd: integrate LLDP
This patch integrates LLDP with networkd.

Example conf:
file : lldp.network

[Match]
Name=em1

[Network]
LLDP=yes
2014-12-19 08:02:45 +05:30
Alin Rauta b98b483bac networkd: add FDB support 2014-12-18 15:28:16 +01:00
Patrik Flykt 5c79bd7983 networkd-dhcp6: Move ICMPv6 and DHCPv6 configuration to new file
Handle all aspects of ICMPv6 and DHCPv6 in a file of its own as is done
with DHCPv4 and IPv4LL.
2014-12-10 18:31:21 +01:00
Thomas Hindoe Paaboel Andersen 1372d5eff4 networkd: remove unused variable
It is no longer used after 45af44d47d
2014-12-09 20:51:58 +01:00
Tom Gundersen 45af44d47d networkd: manager - enumerate addresses globally, rather than per-link
The kernel always returns all addresses, rather than only for the given link, so let's only enumerate once.
2014-12-08 22:13:40 +01:00
Tom Gundersen 1e19f35297 networkd: link - typo 2014-12-08 18:38:55 +01:00
Tom Gundersen c106cc36b9 networkd: add basic [Link] settings to .network files
This allows the default link settings (set in .link files) to be overridden per Network. Only MTU and MACAddress is supported for now.
2014-12-05 00:38:10 +01:00
Tom Gundersen 00e8d83a5a networkd: fix compile
Rebase failure on my side.
2014-12-04 12:19:57 +01:00
Susant Sahani e1853b00ef networkd: Add bridge port path cost
This patch add support to specify path cost of the
bridge port to be configured via conf file.

Exampe: conf

file: br.netdev

[NetDev]
Name=br-test
Kind=bridge

file: br.network
[Match]
Name=em1

[Network]
Bridge=br-test

[BridgePort]
Cost=332

 bridge link
2: em1 state UP : <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master
br-test state disabled priority 32 cost 332
2014-12-04 11:13:32 +01:00
Lennart Poettering 6c861f0aef networkd: update logging macros for parameter order, and errno, to match rest of the code 2014-11-28 02:18:46 +01:00
Lennart Poettering 79008bddf6 log: rearrange log function naming
- Rename log_meta() → log_internal(), to follow naming scheme of most
  other log functions that are usually invoked through macros, but never
  directly.

- Rename log_info_object() to log_object_info(), simply because the
  object should be before any other parameters, to follow OO-style
  programming style.
2014-11-27 22:05:24 +01:00
Tom Gundersen 1dc24d5f48 sd-dhcp-lease: expose load/save functions
Based on patch by Dan Williams.
2014-11-18 19:10:37 +01:00