summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
AgeCommit message (Collapse)Author
2016-05-26dhcp: fix operator precedence issue with macroLennart Poettering
2016-05-26sd-ndisc: make the _stop() call idempotentLennart Poettering
It's a good idea to make stopcalls idempotent, so that they become nops if the object is already stopped.
2016-05-26sd-network: fix up assertion chaosLennart Poettering
assert_return() should only be used to validate user-facing parameters and state, assert() should be used for checking our own internal state and parameters.
2016-05-26sd-ndisc: rename sd_ndisc_init() to sd_ndisc_reset()Lennart Poettering
After all, it's actually used for resetting the state, not only for the initial initialization. While we are at it, also simplify the error path for sd_ndisc_discovery_start().
2016-05-26sd-network: rename "index" field of the various clients to "ifindex"Lennart Poettering
A field "index" is not particularly precise and also might conflict with libc's index() function definition. Also, pretty much everywhere else we call this concept "ifindex", including in networkd, the primary user of these libraries. Hence, let's fix this up and call this "ifindex" everywhere here too.
2016-05-26sd-ndisc: properly make various parameters unsignedLennart Poettering
2016-05-26sd-dhcp: shorten NUL initialization a bitLennart Poettering
2016-05-26sd-network: unify packet processing logic a bitLennart Poettering
Let's always check for errno being EAGAIN/EINTR the same way, and always log if we receive weirdly short packets.
2016-05-23networkd: networkd: ndisc set SO_BINDTODEVICE on socket (#3294)Susant Sahani
From the issue #2004 we are receiving packet even if this packet is not intended for this interface. This can be reproduced. lp3s0: Updating address: 2001:db8:1:0:7e7a:91ff:fe6d:ffe2/64 (valid for 1d) wlp3s0: Updating address: fe80::7e7a:91ff:fe6d:ffe2/64 (valid forever) NDisc CLIENT: Received RA from non-link-local address ::. Ignoring. NDisc CLIENT: Received RA on wrong interface: 2 != 6. Ignoring. NDisc CLIENT: Received RA on wrong interface: 2 != 3. Ignoring. enp0s25: Updating address: 2001:db8:1:0:2ad2:44ff:fe6a:ae07/64 (valid for 1d) enp0s25: Updating address: fe80::2ad2:44ff:fe6a:ae07/64 (valid forever) NDisc CLIENT: Sent Router Solicitation NDisc CLIENT: Sent Router Solicitation NDisc CLIENT: Sent Router Solicitation NDisc CLIENT: Received RA on wrong interface: 3 != 2. Ignoring. NDisc CLIENT: Received RA on wrong interface: 3 != 6. Ignoring. NDisc CLIENT: Received RA from non-link-local address ::. Ignoring. NDisc CLIENT: Received RA on wrong interface: 2 != 6. Ignoring. NDisc CLIENT: Received RA on wrong interface: 2 != 3. Ignoring. enp0s25: Updating address: 2001:db8:1:0:2ad2:44ff:fe6a:ae07/64 (valid for 1d) enp0s25: Updating address: fe80::2ad2:44ff:fe6a:ae07/64 (valid forever) Add SO_BINDTODEVICE to socket fixes #2004
2016-05-22ipv4acd/ipv4ll: stop using read() on SOCK_DGRAM socketsLennart Poettering
This is a follow-up to cf447cb62d01137f4cbd1cd14b83b88823542bbf. Let's generally follow the rule to not use read() on SOCK_DGRAM sockets, let's always use recv() on that. Also, don't abort IPV4ACD logic in case we read a short packet. Simply log and ignore.
2016-05-22sd-ipv4acd: do not define ether_addr_is_nul() redundantlyLennart Poettering
we already have ether_addr_is_null() in ether-addr-util.h, let's use it here, too.
2016-05-22sd-ipv4acd: drop HASH_KEY definition, as it is unusedLennart Poettering
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.