summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
AgeCommit message (Collapse)Author
2016-07-28fixLuke Shumaker
2016-07-27fixLuke Shumaker
2016-06-12moreLuke Shumaker
2016-06-09./move.shLuke Shumaker
2016-05-22libsystemd-network: use recv(..., 0) instead of read(...) (#3317)Tom Gundersen
According to recv(2) these should be the same, but that is not true. Passing a buffer of length 0 to read is defined to be a noop according to read(2), but passing a buffer of length 0 to recv will discard the pending pacet. We can easily hit this as we allocate our buffer size depending on the size of the incoming packet (using FIONREAD). As pointed out in issue #3299 simply sending an empty UDP packet to the DHCP client port will trigger a busy loop in networkd as we are polling on the socket but never discarding the empty packet. This reverts ad5ae47a0d159ea473c9730d7e0298a3e5d31cf6 but fixes the same issue.
2016-05-20Merge pull request #3235 from dkg/hwaddr-cleanupTom Gundersen
minor improvements for dealing with MAC Addresses
2016-05-20sd-dhcp-client: fix busy loop reading zero sized DHCP UDP packets. (#3299)sadag
2016-05-17networkd: Add EmitRouter= option for DHCP Server (#3251)Clemens Gruber
Add an option to disable appending DHCP option 3 (Router) to the DHCP OFFER and ACK packets. This commit adds the boolean option EmitRouter= for the [DHCPServer] section in .network files. Rationale: On embedded devices, it is very useful to have a DHCP server running on an USB OTG ethernet gadget interface to avoid manual setup on the client PCs, but it should only serve IP addresses, no route(r)s. Otherwise, Windows clients experience network connectivity issues, due to them using the address set in DHCP option 3 as default gateway. Signed-off-by: Clemens Gruber <clemens.gruber@pqgruber.com>
2016-05-17network: rely on ether_addr_from_string instead of sscanfDaniel Kahn Gillmor
2016-05-15sd-dhcp6-client: add log_errno macro and improve debug messages a bitZbigniew Jędrzejewski-Szmek
2016-05-15tree-wide: drop spurious "&"s when passing functions aroundZbigniew Jędrzejewski-Szmek
Also adjust indentation in various places.
2016-05-09network: Make sure we log about parse errors for ifname listsLennart Poettering
Fix-up for 93e2822684b37a4eeef03775a7a1f44a3055d7b2
2016-05-09tree-wide: port more code to use ifname_valid()Lennart Poettering
2016-05-06networkd: cleanup FOREACH_WORDSusant Sahani
2016-05-03network: get rid of DUID_TYPE_RAWZbigniew Jędrzejewski-Szmek
It wasn't used for anything after the recent changes.
2016-05-03dh-dhcp{,6}-client: change the semantics of DUID settingZbigniew Jędrzejewski-Szmek
Both versions of the code are changed to allow the caller to override DUID using simple rules: duid type and value may be specified, in which case the caller is responsible to providing the contents, or just duid type may be specified as DUID_TYPE_EN, in which case we we fill in the values. In the future more support for other types may be added, e.g. DUID_TYPE_LLT. There still remains and ugly discrepancy between dhcp4 and dhcp6 code: dhcp6 has sd_dhcp6_client_set_duid and sd_dhcp6_client_set_iaid and requires client->state to be DHCP6_STATE_STOPPED, while dhcp4 has sd_dhcp_client_set_iaid_duid and will reconfigure the client if it is not stopped. This commit doesn't touch that part. This addresses #3127 § 2.
2016-05-03dhcp-identifier: un-inline dhcp_validate_duid_lenZbigniew Jędrzejewski-Szmek
After all it is used in more than one place and is not that short. Also tweak the test a bit: - do not check that duid_len > 0, because we want to allow unknown duid types, and there might be some which are fine with 0 length data, (also assert should not be called from library code), - always check that duid_len <= MAX_DUID_LEN, because we could overwrite available buffer space otherwise.
2016-05-03sd-dhcp: change uint8_t *duid to const void*Zbigniew Jędrzejewski-Szmek
2016-05-03sd-dhcp{,6}-client: use standard indentation for functions argsZbigniew Jędrzejewski-Szmek
2016-04-04Address code-review items for pull-request #2890Vinay Kulkarni
1. Replace strtol with unhexchar, verified with valid and invalid DUID strings. 2. Fix logging to use log_syntax instead of log_error. 3. On error reading DUID, ignore read and preserve previous state. 4. Fix man-pages to use markup, remove options not yet implemented. 5. Remove spurious header line in new files.
2016-04-01dhcp-identifier: handle too long duid_len in dhcp_validate_duid_len()Thomas Haller
Callers of dhcp_validate_duid_len() know that they must not pass a zero duid_len. Thus asserting against that is appropriate. On the other hand, they are not aware of the maximum allowed length of a duid, as that is the reason why they call dhcp_validate_duid_len() in the first place. So dhcp_validate_duid_len() should just signal a regular error. Thereby, change assert_return() to an assert() as this is an internal function.
2016-03-31Merge pull request #2915 from vinaykul/masterZbigniew Jędrzejewski-Szmek
2016-03-30DHCP DUID, IAID configuration optionsVinay Kulkarni
2016-03-24lldp: move public macros to sd-lldp.h and namespace themBeniamino Galvani
lldp.h contains definitions of LLDP types, subtypes and capabilities which should be exposed in public headers. Get rid of the file and move those definitions to sd-lldp.h with the SD_ prefix.
2016-03-21Revert "DHCP DUID and IAID configurability"Zbigniew Jędrzejewski-Szmek
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-03-09DHCP DUID and IAID configurabilityVinay Kulkarni
2016-03-04lldp: fix memleakZbigniew Jędrzejewski-Szmek
in_addr_to_string returned 0, which was treated as error by the calling code, which expects 1 on success. CID #1351757, #1351758.
2016-02-27core: avoid compiler warning when compiling with -fexceptionsThomas Haller
Initialize auto variables with cleanup attribute, otherwise we get a compiler warning with -fexceptions. ./configure CFLAGS='-Wmaybe-uninitialized -fexceptions -O2'
2016-02-25sd-dhcp-server: Send replies to BOOTP relay server portPatrik Flykt
RFC 2131 Section 4.1 says that "If the ’giaddr’ field in a DHCP message from a client is non-zero, the server sends any return messages to the ’DHCP server’ port on the BOOTP relay agent whose address appears in ’giaddr’." Fix this by adding a destination port when sending unicast UDP packets and provide the server port when a BOOTP relay agent is being used.
2016-02-23tree-wide: minor formatting inconsistency cleanupsVito Caputo
2016-02-22tree-wide: make ++/-- usage consistent WRT spacingVito Caputo
Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
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: fix how we create the LLDP listening socketLennart Poettering
Specifiy the ethernet family, and make sure we se the O_CLOEXEC and O_NONBLOCK bits how we should for all fds.
2016-02-20tree-wide: place #pragma once at the same place everywhereLennart Poettering
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-20sd-lldp: simplify lldp_network_bind_raw_socket() a bitLennart Poettering
Let's constify the filter program, drop a few includes and structure definitions.
2016-02-20sd-lldp: move ETHERTYPE_LLDP to missing.hLennart Poettering
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-20test-lldp: fix error checking expressionsLennart Poettering
2016-02-20libsystemd-network: sd-event uses 64bit priorities, expose them in the APIs ↵Lennart Poettering
as such
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-18Remove/add (un)needed includesNathan McSween
2016-02-16networkd: FIONREAD is not reliable on some socketsLennart Poettering
Fixes: #2457
2016-02-15dhcp: assert the success of sd_event_now()Beniamino Galvani
The function must never fail.
2016-02-13Merge pull request #2589 from keszybz/resolve-tool-2Lennart Poettering
Better support of OPENPGPKEY, CAA, TLSA packets and tests
2016-02-11Add memcpy_safeZbigniew Jędrzejewski-Szmek
ISO/IEC 9899:1999 §7.21.1/2 says: Where an argument declared as size_t n specifies the length of the array for a function, n can have the value zero on a call to that function. Unless explicitly stated otherwise in the description of a particular function in this subclause, pointer arguments on such a call shall still have valid values, as described in 7.1.4. In base64_append_width memcpy was called as memcpy(x, NULL, 0). GCC 4.9 started making use of this and assumes This worked fine under -O0, but does something strange under -O3. This patch fixes a bug in base64_append_width(), fixes a possible bug in journal_file_append_entry_internal(), and makes use of the new function to simplify the code in other places.