Commit Graph

27 Commits

Author SHA1 Message Date
Lennart Poettering 4b58153dd2 core: add "invocation ID" concept to service manager
This adds a new invocation ID concept to the service manager. The invocation ID
identifies each runtime cycle of a unit uniquely. A new randomized 128bit ID is
generated each time a unit moves from and inactive to an activating or active
state.

The primary usecase for this concept is to connect the runtime data PID 1
maintains about a service with the offline data the journal stores about it.
Previously we'd use the unit name plus start/stop times, which however is
highly racy since the journal will generally process log data after the service
already ended.

The "invocation ID" kinda matches the "boot ID" concept of the Linux kernel,
except that it applies to an individual unit instead of the whole system.

The invocation ID is passed to the activated processes as environment variable.
It is additionally stored as extended attribute on the cgroup of the unit. The
latter is used by journald to automatically retrieve it for each log logged
message and attach it to the log entry. The environment variable is very easily
accessible, even for unprivileged services. OTOH the extended attribute is only
accessible to privileged processes (this is because cgroupfs only supports the
"trusted." xattr namespace, not "user."). The environment variable may be
altered by services, the extended attribute may not be, hence is the better
choice for the journal.

Note that reading the invocation ID off the extended attribute from journald is
racy, similar to the way reading the unit name for a logging process is.

This patch adds APIs to read the invocation ID to sd-id128:
sd_id128_get_invocation() may be used in a similar fashion to
sd_id128_get_boot().

PID1's own logging is updated to always include the invocation ID when it logs
information about a unit.

A new bus call GetUnitByInvocationID() is added that allows retrieving a bus
path to a unit by its invocation ID. The bus path is built using the invocation
ID, thus providing a path for referring to a unit that is valid only for the
current runtime cycleof it.

Outlook for the future: should the kernel eventually allow passing of cgroup
information along AF_UNIX/SOCK_DGRAM messages via a unique cgroup id, then we
can alter the invocation ID to be generated as hash from that rather than
entirely randomly. This way we can derive the invocation race-freely from the
messages.
2016-10-07 20:14:38 +02:00
Susant Sahani 92c918b06d networkd: add support to configure virtual CAN device (#4139)
1. add support for kind vcan
2. fixup indention netlink-types.c, networkd-netdev.c
2016-09-14 18:15:16 +02:00
Felipe Sateler 8dec4a9d2d core,network: Use const qualifiers for block-local variables in macro functions (#4019)
Prevents discard-qualifiers warnings when the passed variable was const
2016-08-23 12:29:30 +03:00
Andreas Rammhold 20897a0d6e networkd: added support for vrf interfaces (#3316) 2016-06-16 00:25:06 +02: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 0ef6f45425 tree-wide: place #pragma once at the same place everywhere
Usually, we place the #pragma once before the copyright blurb in header files,
but in a few cases we didn't. Move those around, so that we do the same thing
everywhere.
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
Thomas Hindoe Paaboel Andersen 71d35b6b55 tree-wide: sort includes in *.h
This is a continuation of the previous include sort patch, which
only sorted for .c files.
2015-11-18 23:09:02 +01:00
Susant Sahani 540eb5f037 networkd: add bridge properties
ForwardDelaySec:   forward delay
HelloTimeSec:      hello time
MaxAgeSec:         maximum message age

for more information see
http://www.tldp.org/HOWTO/BRIDGE-STP-HOWTO/set-up-the-bridge.html

In kernel
br_dev_newlink: does not have the this functionality to set while
creation.
br_changelink: after creation we can change the parameters.

we need to first create then set it the parameters.

Introduce new callback post_create .This should
set the properties after the creation.
2015-10-05 09:43:29 +05:30
Lennart Poettering fc2f9534d0 networkd: split up networkd.h into per-object header files
No functional changes, just moving definitions into separate header
files.
2015-08-27 14:01:23 +02:00
Susant Sahani f33ff02b1a networkd: add support for macvtap
This patch add support for macvtap.

see http://virt.kernelnewbies.org/MacVTap
2015-07-27 11:18:28 +05:30
Tom Gundersen 1c4baffc18 sd-netlink: rename from sd-rtnl 2015-06-13 19:52:54 +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
Susant Sahani 9011ce771f networkd: introduce vti6 tunnel
This patch add support to create vti6 tunnel

test:

vt6.network
[Match]
Name=wlan0

[Network]
Tunnel=ip6vti

vti6.netdev
[NetDev]
Name=ip6vti
Kind=vti6

[Tunnel]
Local=2a00:ffde:4567:edde::4987
Remote=2001:473:fece:cafe::5179

ip link

11: ip6_vti0@NONE: <NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT
group default
    link/tunnel6 :: brd ::
12: ip6vti@wlan0: <POINTOPOINT,NOARP> mtu 1500 qdisc noop state DOWN
mode DEFAULT group default
    link/tunnel6 2a00:ffde:4567:edde::4987 peer 2001:473:fece:cafe::5179
2015-04-29 21:54:00 +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
Lennart Poettering 98b3255670 networkd: fix confusion between log_netdev_error() but log_warning_netdev()
We should always name the object first, the level second, like
everywhere else in the sources.
2015-04-21 01:26:59 +02: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
Susant Sahani b16492f86f networkd: Introduce ip6gre and ip6gretap
This patch introduces ipv6 gre and gretap.

test:

ip6gre.netdev:
[NetDev]
Name=ip6gretap
Kind=ip6gretap

[Tunnel]
Local=2a00:ffde:4567:edde::4987
Remote=2001:473:fece:cafe::5179

ip6gre.network:
[Match]
Name=eno16777736

[Network]
Tunnel=ip6gretap

ip link

6: ip6gre@eno16777736: <POINTOPOINT,NOARP> mtu 1448 qdisc noop state
DOWN mode DEFAULT group default
    link/gre6 2a:00:ff🇩🇪45:67:ed🇩🇪00:00:00:00:00:00:49:87 peer
20:01:04:73:fe:ce:ca:fe:00:00:00:00:00:00:51:79
2015-01-22 21:29:42 +01:00
Susant Sahani 855ee1a1d2 networkd: Introduce IP6 tunnel
This patch enables networkd to create IP6 tunnels

example conf:

ipip6.netdev:
[NetDev]
Name=ipip6-tunnel
Kind=ip6tnl

[Tunnel]
Mode=ip4ipv6
Local=2a00:ffde:4567:edde::4987
Remote=2001:473:fece:cafe::5179

ipip6.network
[Match]
Name=wlan0

[Network]
Tunnel=ipip6-tunnel

23: ipip6-tunnel@wlan0: <POINTOPOINT,NOARP> mtu 1452 qdisc noop state
DOWN mode DEFAULT group default
    link/tunnel6 2a00:ffde:4567:edde::4987 peer 2001:473:fece:cafe::5179
2015-01-22 21:29:42 +01:00
Susant Sahani 1af2536acf networkd: introduce gretap
This patch introdeces gretap to networkd
2015-01-22 21:29:41 +01:00
Tom Gundersen c4a5ddc9f2 networkd: netdev - add ipvlan support 2015-01-19 23:25:16 +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
Lennart Poettering 086891e5c1 log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers
This change has two benefits:

- The format string %m will now resolve to the specified error (or to
  errno if the specified error is 0. This allows getting rid of a ton of
  strerror() invocations, a function that is not thread-safe.

- The specified error can be passed to the journal in the ERRNO= field.

Now of course, we just need somebody to convert all cases of this:

        log_error("Something happened: %s", strerror(-r));

into thus:

        log_error_errno(-r, "Something happened: %m");
2014-11-27 22:05:23 +01:00
Lennart Poettering 134e56dcc5 shared: rename condition-util.[ch] to condition.[ch]
Now that we only have one file with condition implementations around, we
can drop the -util suffix and simplify things a bit.
2014-11-06 14:21:11 +01:00
Tom Gundersen aa9f114058 networkd: netdev - split NetDev struct into per-kind structs
Similarly to how unit types work.
2014-07-21 13:32:27 +02:00
Lennart Poettering 0dd25fb9f0 change type for address family to "int"
Let's settle on a single type for all address family values, even if
UNIX is very inconsitent on the precise type otherwise. Given that
socket() is the primary entrypoint for the sockets API, and that uses
"int", and "int" is relatively simple and generic, we settle on "int"
for this.
2014-07-18 16:10:51 +02:00
Tom Gundersen 3be1d7e0c5 networkd: netdev - introduce vtable for netdev kinds
Split each netdev kind into its own .h/.c.
2014-07-14 16:49:41 +02:00