Commit graph

25214 commits

Author SHA1 Message Date
Lennart Poettering e308ddcae2 util-lib: fix returned error code
Make sure we propagate errors properly.
2016-02-21 23:27:20 +01:00
Lennart Poettering ea3894c1ba util-lib: add (void) cast to indicate that we don't care about the normalization success
After all, we verify that every calendar part is not out of bounds later on,
and it's fully OK if the normalization has no effect.
2016-02-21 23:25:38 +01:00
Lennart Poettering cbbf38aefc networkd: make sure we allocate the NTA set before we add items to it
See: #2683
2016-02-21 22:27:01 +01:00
Lennart Poettering 1f210bdbe6 Merge pull request #2650 from vcaputo/async_fsync
Perform journal offlines asynchronously when possible
2016-02-21 21:35:50 +01:00
Lennart Poettering c7044f9ed2 Merge pull request #2681 from keszybz/udev-rules
udev-rules cleanup and coverity warning silencing
2016-02-21 21:22:55 +01:00
Lennart Poettering 67b56fb29e github: add a basic issue template
As documented here:

https://help.github.com/articles/creating-an-issue-template-for-your-repository/
2016-02-21 21:15:17 +01:00
Lennart Poettering 67bf157f38 github: move CONTRIBUTING.md into .github subdirectory
As suggested by:

https://github.com/blog/2111-issue-and-pull-request-templates
2016-02-21 21:05:02 +01:00
Lennart Poettering da6c766d53 man: document the new EmitLLDP= .network setting
Also, beef up the LLDP documentation a bit.
2016-02-21 20:59:55 +01:00
Lennart Poettering c8048350b8 update TODO 2016-02-21 20:59:55 +01: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 d08191a242 networkctl: ellipsize long LLDP fields in table output 2016-02-21 20:58:59 +01:00
Lennart Poettering f5207c2206 networkctl: add missing newline to printf() format string 2016-02-21 20:58:59 +01:00
Lennart Poettering 2a5a6e05ca network: turn on LLDP tx+rx for the default container network configuration
Containers are relatively trusted and the veth tunnels are small networks,
hence let's turn on LLDP both ways for them.
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 33859a6bf5 import: don't claim we had copied a settings file if we didn't 2016-02-21 20:40:57 +01:00
Lennart Poettering f479d3baa7 man: update references to fedora cloud image
We are now at F23, hence let's use that as example.
2016-02-21 20:40:57 +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 58fb367825 networkctl: print a nice warning when networkd isn't running 2016-02-21 20:40:57 +01:00
Lennart Poettering 33d5013db0 networkctl: if there's no data from networkd about an iface show as "unmanaged"
After all, if we know that an interface exists but networkd did not store any
info about it, then it's definitely unmanaged by it.

(Note that we add this fix-up to networkctl, and not to sd-network, simply
because a missing file might also be result of the interface not existing.)
2016-02-21 20:40:57 +01:00
Lennart Poettering 5f02f341c0 sd-network: use xsprintf() instead of asprintf() where we can 2016-02-21 20:40:57 +01:00
Lennart Poettering 4abd866d68 networkctl: add a couple of (void) casts
Where we knowingly ignore possible error results, let's cast to void.
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 7cececb2ea networkd: turn on LLDP reception by default, in "routers-only" mode
This way "networkctl status" becomes a bit more useful by default, as router
information is just visible, without any further configuration.

LLDP reception is fully passive and relatively low simple and low traffic,
hence this should be safe to enable by default.
2016-02-21 20:40:57 +01:00
Lennart Poettering 837f57da41 networkctl: extend "networkctl status" per-interface output to include LLDP info
This adds a small and useful field to the "systemctl status" output: the
router(s) the interface is connected to as reported via LLDP. Example output:

● 2: enp0s25
       Link File: /usr/lib/systemd/network/99-default.link
            Type: ether
           State: degraded (configured)
            Path: pci-0000:00:19.0
          Driver: e1000e
    Connected To: GS1900 on port 2 (foobar)

i.e. the last line is the relevant one.
2016-02-21 20:40:57 +01:00
Lennart Poettering 691d4da98a networkctl: make use of xsprintf() where we can 2016-02-21 20:40:57 +01:00
Lennart Poettering 7e5a080a94 networkctl: simplify networkctl
Move decode_and_sort_links() into acquire_info_all() which is the only place
this is used. The result is then nicely symmetric to acquire_info_strv().
2016-02-21 20:40:57 +01:00
Lennart Poettering b147503eb4 networkctl: rework interface data acquisition
Let's always use the same calls to acquire interface data. Specifically port
"networkctl status" to use acquire_link_info_strv() and acquire_link_info_all()
like the other calls.
2016-02-21 20:40:57 +01:00
Lennart Poettering e997c4b09d networkctl: extend "networkctl list" and "networctl lldp" to optionally take interface names
This way, the output may be reduced to only show data about the specified
interfaces.
2016-02-21 20:40:57 +01:00
Lennart Poettering 7d367b45f6 networkctl: add new call that unifies link data acquisition between "status" and "lldp" verbs 2016-02-21 20:40:57 +01:00
Lennart Poettering 1fb82beb38 networkctl: fix dispatch_verb() table
VERB_DEFAULT may only appear once.
2016-02-21 20:40:57 +01:00
Lennart Poettering 0070333f26 networkctl: split out system status stuff into its own function 2016-02-21 20:40:56 +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
Zbigniew Jędrzejewski-Szmek fdd21be6f5 udev-rules: use _cleanup_ for fclose 2016-02-21 11:05:13 -05:00
Zbigniew Jędrzejewski-Szmek 19a8e656a9 udev-rules: make error messages about rules more uniform
Also downgrade non-fatal warnings to log_warning.

Previously rule_add_key() would check the output array and log a cryptic
error and return -1. Most of the time the return value was ignored. This
does not seems right, because the buffer can overflow with enough rules.
It would also check if we have enough space for the *next* rule, even if
there might be not next rule, i.e. off-by-one.

Replace this with a check that we have enough space for a next rule before
we start parsing.

Normally using macros to alter flow is not allowed, but in this case I
think it is worth it, because it allows lots of boilerplate code to be
removed and hides repeated boring parameters, making function logic much
easier to follow.
2016-02-21 11:05:11 -05:00
Zbigniew Jędrzejewski-Szmek f4850a1d95 udev-rules: rewrite function to avoid clobbering arguments
If the attribute wasn't found, the last filename looked at was returned in
the input/output argument. This just seems bad style.

The return value was ignored, so change function to return void.
2016-02-21 11:05:08 -05:00
Zbigniew Jędrzejewski-Szmek 99f16bb8d9 udev-rules: modernize syntax a bit 2016-02-21 11:05:06 -05:00
Zbigniew Jędrzejewski-Szmek 4fd6af76c4 udev-rules: log_oom() on memory error and abort processing of event
CID #1313566.

Also, change the return value to void, because it is ignored anyway.
2016-02-21 11:05:02 -05:00
Zbigniew Jędrzejewski-Szmek bccfe92e46 sd-device: use (void) before set_iterate calls
set_iterate sets the output argument to NULL on error, and the return
value is not used in this case.

CID #1306804-09.
2016-02-20 19:37:10 -05:00
Zbigniew Jędrzejewski-Szmek a2daa2f075 time-util: check for overflow in conversion from ts to nsec_t
CID #1320855.
2016-02-20 19:37:10 -05: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