summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-lldp.c
AgeCommit message (Collapse)Author
2016-03-14lldp: fix starting ttl timer for lldp neighborThomas Haller
lldp_start_timer() was only called during sd_lldp_get_neighbors(). Ensure that the timer is (re-)started when a new neighbor appears. Otherwise, the timer is not started when relying on the events alone. Fixes: 34437b4f9c9c51b0a6f93788bdb9a105b8e46b66
2016-02-21sd-lldp: beef up callback logicLennart Poettering
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-21sd-lldp: filter out LLDP messages coming from our own MAC addressLennart Poettering
Let's not get confused should we be connected to some bridge that mirrors back our packets.
2016-02-21sd-lldp: rework sd-lldp APILennart Poettering
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-20sd-lldp: drop "port" objectLennart Poettering
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-20sd-lldp: drop keeping of statisticsLennart Poettering
We don't expose them, and they are only of questionnable use.
2016-02-20libsystemd-network: don't abbreviate "callback" as "cb" needlesslyLennart Poettering
This isn't an excercise in creating APIs that are hard to understand, hence let's call a callback a callback.
2016-02-20sd-lldp: drop state fieldLennart Poettering
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-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-12-25Merge pull request #2223 from ssahani/lldpZbigniew Jędrzejewski-Szmek
Closes #2223.
2015-12-25V3 LLDP: Add packet validation (system name and description)Susant Sahani
LLDP type system name and system description should be with in 255 characters and unique. Let's add the validation to discard corrupt packets.
2015-12-25lldp: improve loggingSusant Sahani
2015-11-27tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering
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-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-27util-lib: move more file I/O related calls into fileio.[ch]Lennart Poettering
2015-10-25util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering
There are more than enough to deserve their own .c file, hence move them over.
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-10-06Merge pull request #1465 from teg/siphash24Lennart Poettering
hashmap/siphash24: refactor hash functions
2015-10-05hashmap: hash_funcs - make inputs unambiguousTom Gundersen
Make sure all variable-length inputs are properly terminated or that their length is encoded in some way. This avoids ambiguity of adjacent inputs. E.g., in case of a hash function taking two strings, compressing "ab" followed by "c" is now distinct from "a" followed by "bc".
2015-10-05hashmap: refactor hash_funcTom Gundersen
All our hash functions are based on siphash24(), factor out siphash_init() and siphash24_finalize() and pass the siphash state to the hash functions rather than the hash key. This simplifies the hash functions, and in particular makes composition simpler as calling siphash24_compress() repeatedly on separate chunks of input has the same effect as first concatenating the input and then calling siphash23_compress() on the result.
2015-10-02lldp: add support for organizationally specific TLVsBeniamino Galvani
LLDP TLVs of type 127 are used to carry organizationally specific information and include additional fields to specify the OUI and subtype. Add support for parsing such fields and functions to access the most common IEEE 802.1 specific TLVs.
2015-10-02lldp: add public function to export LLDP TLV packetsBeniamino Galvani
Add a public function to get a list of current LLDP neighbours' TLV packets. The function populates an array of pointers to the opaque type sd_lldp_packet and returns the number of elements found. Callers must take care of freeing the array and decreasing the refcount of elements when done.
2015-10-02lldp: export opaque TLV type and accessor functionsBeniamino Galvani
Export struct tlv_packet as a public opaque sd_lldp_packet type and make its accessor functions public.
2015-10-02lldp: change order of arguments of lldp_read_*() functionsBeniamino Galvani
These functions are going to be exported, swap the 'data' and 'length' arguments so that their signature is consistent with the rest of the code.
2015-10-02lldp: add reference counter to struct tlv_packetBeniamino Galvani
Add a reference counter to the tlv_packet structure so that it can be shared between multiple users and properly free'd when no longer in use.
2015-09-22sd-lldp: hide internal detailsDavid Herrmann
Currently, sd-lldp.h exports "UPDATE_INFO".. and defines it to a magic constant '10'. This is completely bogus, so fix it to follow our coding standards: - Prefix exported symbols by SD_LLDP_* - Define a separate event-enum for event types - Translate internal state to external event-types
2015-08-03tree-wide: convert bootchart and lldp code to use clock_boottime_or_monotonic()Lennart Poettering
We should avoid using CLOCK_BOOTTIME directly unless we actually can sensible distuingish it from CLOCK_MONOTONIC. CLOCK_BOOTTIME is only fully feature on very recent Linux kernels, hence we should stick to a fallback logic, which is already available in the clock_boottime_or_monotonic() call.
2015-07-29tree-wide: port everything over to fflush_and_check()Lennart Poettering
Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers.
2015-07-02lldp: set correct state for processingSusant Sahani
ldp_receive_frame after correct processing of the packet the state should be LLDP_AGENT_RX_WAIT_FOR_FRAME not LLDP_AGENT_RX_UPDATE_INFO.
2015-03-13Use space after a silencing (void)Zbigniew Jędrzejewski-Szmek
We were using a space more often than not, and this way is codified in CODING_STYLE.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen
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-01-05libsystemd-network: fix typo in lldpTorstein Husebø
2015-01-01network: fix scanf/printf formatZbigniew Jędrzejewski-Szmek
usec_t is defined as 64 bit wide, but long is 32 bit on many archs.
2014-12-31lldp: fix sd_lldp_save()David Herrmann
Fix a bunch of needless memzero() calls, a bunch of use-after-free regarding _cleanup_free_ and drop unused variables. Hint: Do NOT use _cleanup_free_ for temporary strappend() helpers that are freed multiple times. All you safe is the last free() call, which is really not worth the trouble resetting it to NULL all the time.
2014-12-31lldp: fix double freeDavid Herrmann
'k' is marked as _cleanup_free_ so reset it to NULL if we free it explicitly.
2014-12-19sd-lldp: minor header cleanupTom Gundersen
* (potentially) public headers must reside in src/systemd/ (not in src/libsystemd*) * some private (not prefixed with sd_) functions moved from sd-lldp.h to lldp-internal.h * introduce lldp-util.h for the cleanup macro, as these should not be public * rename the cleanup macro, we always name them _cleanup_foo_, never _cleanup_sd_foo_ * mark some function arguments as 'const'
2014-12-19LLDP: Add support for networkctlSusant Sahani
2014-12-19networkd: Introduce Link Layer Discovery Protocol (LLDP)Susant Sahani
This patch introduces LLDP support to networkd. it implements the receiver side of the protocol. The Link Layer Discovery Protocol (LLDP) is an industry-standard, vendor-neutral method to allow networked devices to advertise capabilities, identity, and other information onto a LAN. The Layer 2 protocol, detailed in IEEE 802.1AB-2005.LLDP allows network devices that operate at the lower layers of a protocol stack (such as Layer 2 bridges and switches) to learn some of the capabilities and characteristics of LAN devices available to higher layer protocols.