1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 19:21:53 +03:00
Commit Graph

24968 Commits

Author SHA1 Message Date
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
1b4cd0cf11 core: exclude .slice units from "systemctl isolate"
Fixes: #1969
2016-02-20 22:42:29 +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
1c4a6088ed sd-netlink: fix ifi_iftype type
The iftype is an unsigned short, and not just an unsigned.
2016-02-20 22:42:29 +01:00
Lennart Poettering
7cde237777 sd-lldp: fix how we create the LLDP listening socket
Specifiy the ethernet family, and make sure we se the O_CLOEXEC and O_NONBLOCK
bits how we should for all fds.
2016-02-20 22:42:29 +01: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
Lennart Poettering
358977458b sd-lldp: simplify lldp_network_bind_raw_socket() a bit
Let's constify the filter program, drop a few includes and structure
definitions.
2016-02-20 22:42:29 +01:00
Lennart Poettering
43a6a52efe sd-lldp: move ETHERTYPE_LLDP to missing.h
After all, most ETHERTYPE variables are defined in the system headers, hence
define these where we defined all other fill-ins for system headers.
2016-02-20 22:42:29 +01:00
Lennart Poettering
bd8650e9b8 test-lldp: fix error checking expressions 2016-02-20 22:42:29 +01:00
Lennart Poettering
32d2064523 libsystemd-network: sd-event uses 64bit priorities, expose them in the APIs as such 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
Lennart Poettering
2139d247bd sd-lldp: drop keeping of statistics
We don't expose them, and they are only of questionnable use.
2016-02-20 22:42:29 +01:00
Lennart Poettering
ccf8635435 libsystemd-network: don't abbreviate "callback" as "cb" needlessly
This isn't an excercise in creating APIs that are hard to understand, hence
let's call a callback a callback.
2016-02-20 22:42:29 +01:00
Lennart Poettering
c7d264ff98 sd-lldp: drop state field
There's really no point in maintaining a state, the state machine is trivial,
and we actually never look at the state anyway, we just keep updating it.
2016-02-20 22:42:29 +01:00
Daniel Mack
714c62b463 Merge pull request #2675 from samueltardieu/llmnr-typo
Fix typo on systemd-resolved log message
2016-02-20 12:27:48 +01:00
Samuel Tardieu
0ea929d52f systemd-resolved: fix typo on log message 2016-02-20 08:55:17 +01:00
Zbigniew Jędrzejewski-Szmek
cde0cf28a2 Merge pull request #2666 from keszybz/coverity-fixes
Coverity fixes
2016-02-19 15:18:40 -05:00
Zbigniew Jędrzejewski-Szmek
0f5777cbd4 Merge pull request #2670 from hbrueckner/for-upstream
udev/path_id: correct segmentation fault due to missing NULL check
2016-02-19 15:13:03 -05:00
Daniel Mack
6f5ea43f9b Merge pull request #2668 from samueltardieu/systemd-resolve-manual-typo
Fix typo in systemd-resolve man page
2016-02-19 15:52:43 +01:00
Hendrik Brueckner
5181ab917d udev/path_id: correct segmentation fault due to missing NULL check
Running "udevadm test-builtin path_id /sys/devices/platform/" results
in a segmentation fault.

The problem is that udev_device_get_subsystem(dev) might return NULL
in a streq() call.  Solve this problem by using streq_ptr() instead.
2016-02-19 15:21:18 +01:00
Samuel Tardieu
de2645af05 systemd-resolve: fix typo in man page 2016-02-19 14:42:38 +01:00
Zbigniew Jędrzejewski-Szmek
79d6297252 Use (void) to silenc coverity on proc title changes
This is a cosmetic best-effort thing anyway.
2016-02-19 07:35:35 -05:00
Zbigniew Jędrzejewski-Szmek
18665d1f67 resolved: fix NULL dereference in debug stmt
CID #1351544, #1351545.
2016-02-19 07:27:43 -05:00
Daniel Mack
a972e1e0b3 Merge pull request #2661 from nwmcsween/nwmcsween
Include and internal struct member fixes.
2016-02-19 12:29:23 +01:00
Daniel Mack
dfec18925e Merge pull request #2660 from keszybz/memleaks-and-ubsan
Memleaks and ubsan
2016-02-19 12:23:43 +01:00
Daniel Mack
22b73e9cd7 Merge pull request #2662 from keszybz/activate-setenv
activate: fix -E option parsing
2016-02-19 12:19:18 +01:00
Martin Pitt
e4d86881d5 Merge pull request #2648 from keszybz/dnssec-work
Better support for DANE, shell completion
2016-02-19 07:50:50 +01:00
Zbigniew Jędrzejewski-Szmek
b722348d05 activate: fix -E option parsing
Fixes #2658.
2016-02-18 21:54:31 -05:00
Zbigniew Jędrzejewski-Szmek
240a7ba9d8 time-util: rewrite check in a way that does not confuse gcc
gcc thinks that multiplier might be unitialized. Split out the inner
loop to make the function easier to grok.
2016-02-18 19:39:10 -05:00
Zbigniew Jędrzejewski-Szmek
d09139e187 test-hashmap: fix undefined behaviour on string constants
The test was failing at -O2+ with gcc 5.3 and 6.0.
"val1" == "val1" and "val1" != "val1" are both valid.
http://stackoverflow.com/questions/4843640/why-is-a-a-in-c
2016-02-18 19:39:10 -05:00
Zbigniew Jędrzejewski-Szmek
06466a7f03 journal/catalog: fix memory leaks
Various buffers were lost because finish_item() either consumed
the buffer or allocated a new one (if an entry with the same key existed).
The caller would simply forget the buffer in either case.

Also add a check for the case when a valid identifier is followed by
an empty body. We should not allow this.

Also be more consistent in error handling and always print an error
message.
2016-02-18 19:39:09 -05:00
Zbigniew Jędrzejewski-Szmek
82501b3fc4 basic/strbuf: do not call bsearch with a null argument
Das ist verboten!

src/basic/strbuf.c:162:23: runtime error: null pointer passed as argument 2,
                           which is declared to never be null
2016-02-18 19:39:09 -05:00
Nathan McSween
3a43755733 Don't use internal struct member names 2016-02-18 23:35:22 +00:00
Nathan McSween
e306723ec4 Remove/add (un)needed includes 2016-02-18 23:34:30 +00:00
Zbigniew Jędrzejewski-Szmek
48ddca5f35 Merge pull request #2644 from 0xAX/check-alloc-overflow-macro
alloc-util: extract overflow check into inline function
2016-02-18 15:32:22 -05:00
Alexander Kuleshov
dbacacaaea alloc-util: cleanups
This patch contains a set of little cleanups for alloc-util.h:

1. The malloc_multiply(), realloc_multiply() and memdup_multiply()
functions check allocation related parameters on overflow. Let's
move them to the separate size_multiply_overflow() function for
simplicity, code duplication prevention and possible reuse in future.

2. use SIZE_MAX from stdlib instead of ((size_t) - 1) to be more
clear.

3. The 'a'/'b' variables are renamed to 'size' and 'need' to be
more clear.'
2016-02-19 01:36:46 +06:00
Martin Pitt
2150e62287 Merge pull request #2621 from keszybz/wheel-group
build-sys: allow wheel group name to be specified
2016-02-18 19:20:14 +01:00
Zbigniew Jędrzejewski-Szmek
e81eb2874e systemd-resolve: initial shell completion
v2:
- use /sys/class/net to list interfaces,
  also copy the same code to systemd-nspawn
v3:
- do not propose "any" twice for --type
2016-02-18 11:50:53 -05:00
Zbigniew Jędrzejewski-Szmek
e1caa6e09b resolve: also allow SSHFP payload to be exported 2016-02-18 11:41:40 -05:00
Zbigniew Jędrzejewski-Szmek
236d312b8d resolve: print TLSA packets in hexadecimal
https://tools.ietf.org/html/rfc6698#section-2.2 says:
> The certificate association data field MUST be represented as a string
> of hexadecimal characters. Whitespace is allowed within the string of
> hexadecimal characters
2016-02-18 11:41:40 -05:00
Zbigniew Jędrzejewski-Szmek
82d1d24093 systemd-resolve: easy querying of TLSA records
$ systemd-resolve --tlsa fedoraproject.org
_443._tcp.fedoraproject.org IN TLSA 0 0 1 GUAL5bejH7czkXcAeJ0vCiRxwMnVBsDlBMBsFtfLF8A=
        -- Cert. usage: CA constraint
        -- Selector: Full Certificate
        -- Matching type: SHA-256

$ systemd-resolve --tlsa=tcp fedoraproject.org:443
_443._tcp.fedoraproject.org IN TLSA 0 0 1 GUAL5bejH7czkXcAeJ0vCiRxwMnVBsDlBMBsFtfLF8A=
        ...

$ systemd-resolve --tlsa=udp fedoraproject.org
_443._udp.fedoraproject.org: resolve call failed: '_443._udp.fedoraproject.org' not found

v2:
- use uint16_t
- refuse port 0
2016-02-18 11:41:40 -05:00
Zbigniew Jędrzejewski-Szmek
57156d9507 Merge pull request #2646 from evverx/fix-2637
Fix #2637 (doubled specifier expansion in ExecStart=)
2016-02-18 10:24:16 -05:00
Martin Pitt
04af5d645e Merge pull request #2653 from keszybz/test-dns-domain
build-sys: remove duplicated entry in tests
2016-02-18 16:11:03 +01:00
Zbigniew Jędrzejewski-Szmek
43a90c32c2 build-sys: remove duplicated entry in tests
test-dns-domain should be built and run even without ENABLE_RESOLVED.
2016-02-18 08:30:18 -05:00
Evgeny Vereshchagin
bd1b973fb3 core: revert "core: resolve specifier in config_parse_exec()"
This reverts commit cb48dfca6a.

Exec*-settings resolve specifiers twice:
%%U -> config_parse_exec [cb48dfca6a] -> %U -> service_spawn -> 0

Fixes #2637
2016-02-18 11:55:53 +00:00
Martin Pitt
8ac0402c06 Merge pull request #2652 from filbranden/testsresolved1
Do not build tests that depend on resolved when it has been disabled
2016-02-18 10:33:39 +01:00
Filipe Brandenburger
e49a8dcc29 build-sys: Do not build tests that depend on resolved when it has been disabled
If ./configure --disable-resolved has been used, do not try to build
test-dns-packet and test-resolve-tables which depend on it.

Previously, the SOURCES, LIBS and LDADDs for these tests were made conditional
while the main rules for them weren't, causing build failures trying to build a
binary with no sources.

This was uncovered when trying to build udeb for systemd in CI, which uses
--disable-resolved for a minimal build, which uncovered the issue.

Fixes #2651.
2016-02-18 00:39:38 -08:00
Zbigniew Jędrzejewski-Szmek
2a998ffa1e build-sys: allow references to wheel group to be omitted
https://github.com/systemd/systemd/issues/2492
2016-02-17 23:47:23 -05:00
Evgeny Vereshchagin
252549990f tests: add test for https://github.com/systemd/systemd/issues/2637
+ perl -e 'exit(!(qq{0} eq qq{\x25U}))'
exec-spec-interpolation.service: Main process exited, code=exited, status=1/FAILURE
exec-spec-interpolation.service: Unit entered failed state.
exec-spec-interpolation.service: Failed with result 'exit-code'.
        PID: 11270
        Start Timestamp: Wed 2016-02-17 22:21:31 UTC
        Exit Timestamp: Wed 2016-02-17 22:21:31 UTC
        Exit Code: exited
        Exit Status: 1
Assertion 'service->main_exec_status.status == status_expected' failed at src/test/test-execute.c:65, function check(). Aborting.
2016-02-17 22:40:26 +00:00