summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
AgeCommit message (Collapse)Author
2017-02-20Include 'vendor class identifier option' into DHCPREQUEST message (#5380)Alexander Galanin
2017-02-16libsystemd-network: ipv4ll probe conflict counter (#5361)Jason Reeder
A bug exists where the conflict counter is cleared regardless of whether or not the next probe attempt leads to a successful address acquisition. This causes 'bursts' of MAX_CONFLICTS probes followed by a delay of RATE_LIMIT_INTERVAL instead of a single probe each RATE_LIMIT_INTERVAL when beyond MAX_CONFLICTS. The conflict counter should only be cleared after an address is successfully acquired. This commit achieves that goal. From RFC3927: A host should maintain a counter of the number of address conflicts it has experienced in the process of trying to acquire an address, and if the number of conflicts exceeds MAX_CONFLICTS then the host MUST limit the rate at which it probes for new addresses to no more than one new address per RATE_LIMIT_INTERVAL. This is to prevent catastrophic ARP storms in pathological failure cases, such as a rogue host that answers all ARP probes, causing legitimate hosts to go into an infinite loop attempting to select a usable address. Signed-off-by: Jason Reeder <jasonreeder@gmail.com>
2017-02-09networkd: add multicast membership to lldp socket (#5282)27o
2017-02-09dhcp-server: always save the ACKed lease address (#5281)27o
2017-01-31tree-wide: adjust fall through comments so that gcc is happyZbigniew Jędrzejewski-Szmek
gcc 7 adds -Wimplicit-fallthrough=3 to -Wextra. There are a few ways we could deal with that. After we take into account the need to stay compatible with older versions of the compiler (and other compilers), I don't think adding __attribute__((fallthrough)), even as a macro, is worth the trouble. It sticks out too much, a comment is just as good. But gcc has some very specific requiremnts how the comment should look. Adjust it the specific form that it likes. I don't think the extra stuff we had in those comments was adding much value. (Note: the documentation seems to be wrong, and seems to describe a different pattern from the one that is actually used. I guess either the docs or the code will have to change before gcc 7 is finalized.)
2017-01-23sd-network: fix memleak in dhcp6_lease_set_domains (#5113)Evgeny Vereshchagin
The simplest way to reproduce: ```diff diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index bd289fa..4e14d8f 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -286,6 +286,8 @@ static int test_advertise_option(sd_event *e) { assert_se(optlen == 11); assert_se(dhcp6_lease_set_domains(lease, optval, optlen) >= 0); + assert_se(dhcp6_lease_set_domains(lease, optval, + optlen) >= 0); break; case SD_DHCP6_OPTION_SNTP_SERVERS: ``` Fixes: ``` ==27369==ERROR: LeakSanitizer: detected memory leaks Direct leak of 10 byte(s) in 1 object(s) allocated from: #0 0x7f90e7d21160 in strdup (/lib64/libasan.so.3+0x5a160) #1 0x7f90e7467f69 in strv_extend src/basic/strv.c:552 #2 0x5612fcc19379 in dhcp6_option_parse_domainname src/libsystemd-network/dhcp6-option.c:399 #3 0x5612fcc1acdf in dhcp6_lease_set_domains src/libsystemd-network/sd-dhcp6-lease.c:225 #4 0x5612fcc06b95 in test_advertise_option src/libsystemd-network/test-dhcp6-client.c:287 #5 0x5612fcc0a987 in main src/libsystemd-network/test-dhcp6-client.c:761 #6 0x7f90e6d46400 in __libc_start_main (/lib64/libc.so.6+0x20400) SUMMARY: AddressSanitizer: 10 byte(s) leaked in 1 allocation(s). ```
2017-01-23sd-network: fix memleak in dhcp6_option_parse_domainname (#5114)Evgeny Vereshchagin
The simplest way to reproduce: ```diff diff --git a/src/libsystemd-network/test-dhcp6-client.c b/src/libsystemd-network/test-dhcp6-client.c index bd289fa..7b0a5ef 100644 --- a/src/libsystemd-network/test-dhcp6-client.c +++ b/src/libsystemd-network/test-dhcp6-client.c @@ -168,7 +168,7 @@ static uint8_t msg_advertise[198] = { 0x00, 0x17, 0x00, 0x10, 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x0b, - 0x03, 0x6c, 0x61, 0x62, 0x05, 0x69, 0x6e, 0x74, + 0x01, 0x6c, 0x01, 0x62, 0x00, 0x0a, 0x6e, 0x74, 0x72, 0x61, 0x00, 0x00, 0x1f, 0x00, 0x10, 0x20, 0x01, 0x0d, 0xb8, 0xde, 0xad, 0xbe, 0xef, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, @@ -338,9 +338,7 @@ static int test_advertise_option(sd_event *e) { assert_se(!memcmp(addrs, &msg_advertise[124], r * 16)); r = sd_dhcp6_lease_get_domains(lease, &domains); - assert_se(r == 1); - assert_se(!strcmp("lab.intra", domains[0])); - assert_se(domains[1] == NULL); + assert_se(r == -ENOENT); r = sd_dhcp6_lease_get_ntp_addrs(lease, &addrs); assert_se(r == 1); ``` Fixes: ``` ================================================================= ==15043==ERROR: LeakSanitizer: detected memory leaks Direct leak of 4 byte(s) in 1 object(s) allocated from: #0 0x7f13c8564160 in strdup (/lib64/libasan.so.3+0x5a160) #1 0x7f13c7caaf69 in strv_extend src/basic/strv.c:552 #2 0x55f775787230 in dhcp6_option_parse_domainname src/libsystemd-network/dhcp6-option.c:399 #3 0x55f775788b96 in dhcp6_lease_set_domains src/libsystemd-network/sd-dhcp6-lease.c:225 #4 0x55f775774b95 in test_advertise_option src/libsystemd-network/test-dhcp6-client.c:287 #5 0x55f77577883e in main src/libsystemd-network/test-dhcp6-client.c:759 #6 0x7f13c7589400 in __libc_start_main (/lib64/libc.so.6+0x20400) Direct leak of 4 byte(s) in 1 object(s) allocated from: #0 0x7f13c8564160 in strdup (/lib64/libasan.so.3+0x5a160) #1 0x7f13c7caaf69 in strv_extend src/basic/strv.c:552 #2 0x55f775787230 in dhcp6_option_parse_domainname src/libsystemd-network/dhcp6-option.c:399 #3 0x55f775788b96 in dhcp6_lease_set_domains src/libsystemd-network/sd-dhcp6-lease.c:225 #4 0x55f775781348 in client_parse_message src/libsystemd-network/sd-dhcp6-client.c:807 #5 0x55f775781ba2 in client_receive_advertise src/libsystemd-network/sd-dhcp6-client.c:895 #6 0x55f775782453 in client_receive_message src/libsystemd-network/sd-dhcp6-client.c:994 #7 0x7f13c7e447f4 in source_dispatch src/libsystemd/sd-event/sd-event.c:2268 #8 0x7f13c7e471b0 in sd_event_dispatch src/libsystemd/sd-event/sd-event.c:2627 #9 0x7f13c7e47ab3 in sd_event_run src/libsystemd/sd-event/sd-event.c:2686 #10 0x7f13c7e47c21 in sd_event_loop src/libsystemd/sd-event/sd-event.c:2706 #11 0x55f77577863c in test_client_solicit src/libsystemd-network/test-dhcp6-client.c:737 #12 0x55f77577884b in main src/libsystemd-network/test-dhcp6-client.c:760 #13 0x7f13c7589400 in __libc_start_main (/lib64/libc.so.6+0x20400) SUMMARY: AddressSanitizer: 8 byte(s) leaked in 2 allocation(s). ```
2016-12-20ndisc: ignore invalid SLAAC prefix lengths (#4923)Jörg Thalheim
- linux does not accept prefixes for SLAAC unequal to 64 bits: http://lxr.free-electrons.com/source/net/ipv6/addrconf.c#L2741 - when networkd tries export such a route to the kernel it will get -EINVAL and set the whole device into a failed state. - this patch will make networkd ignore such prefixes for SLAAC, but process other informations which may contain other prefixes. - Note that rfc4862 does not forbid prefix length != 64 bit
2016-12-07network: fix const qualifier (#4849)David Michael
Follow up for #4809.
2016-12-07network: support negation in matching patterns (#4809)David Michael
2016-12-07dhcp: bind udp sockets to interfaces (#4822)27o
2016-11-21sd-dhcp-client: use free_and_strdupZbigniew Jędrzejewski-Szmek
This changes the return value a bit: 1 will be returned if the value is changed. But the return value was not documented, and the change should be for the good anyway. Current callers don't care.
2016-11-21dhcp4: filter bogus DNS/NTP server addresses silentlyLennart Poettering
if we receive a bogus lease with a DNS/NTP server within local scope let's politely ignore. Fixes: #4524
2016-11-21basic: add explicit ipv4-specific in_addr classification callsLennart Poettering
This adds in4_addr_is_localhost() and in4_addr_is_link_local() that only take an IPv4 "struct in_addr", to match in_addr_is_localhost() and in_addr_is_link_local() that that a "union in_addr_union". This matches the existing in4_addr_is_null() call that already exists. For IPv6 glibc already exports a set of macros, hence we don't add similar functions in6_addr_is_localhost(). We also drop in6_addr_is_null() as IN6_IS_ADDR_UNSPECIFIED() already provides that.
2016-11-21sd-dhcp: permit unsetting the hostname againLennart Poettering
Let's handle NULL hostnames (for unsetting it) before we validate the name.
2016-11-10networkd: support setting dhcp client listen port (#4631)Susant Sahani
Allow setting custom port for the DHCP client to listen on in networkd. [DHCP] ListenPort=6677
2016-10-16tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek
2016-07-12Various fixes for typos found by lintian (#3705)Michael Biebl
2016-06-30Fix #3236 (#3633)Lennart Poettering
* networkd: condition_test() can return a negative error, handle that If a condition check fails with an error we should not consider the check successful. Fix that. We should probably also improve logging in this case, but for now, let's just unbreak this breakage. Fixes: #3236 * condition: handle unrecognized architectures nicer When we encounter a check for an architecture we don't know we should not let the condition check fail with an error code, but instead simply return false. After all the architecture might just be newer than the ones we know, in which case it's certainly not our local one. Fixes: #3236
2016-06-16Merge pull request #3481 from poettering/relative-memcgLennart Poettering
various changes, most importantly regarding memory metrics
2016-06-15tree-wide: htonl() is weird, let's use htobe32() instead (#3538)Lennart Poettering
Super-important change, yeah!
2016-06-14sd-ndisc: add missing castLennart Poettering
Apparently newer gcc versions are a bit more forgiving when assigning an "unsigned char*" pointer to something of a different type. Let's add the missing cast so that old gcc versions are fine, too.
2016-06-06network: beef up ipv6 RA support considerablyLennart Poettering
This reworks sd-ndisc and networkd substantially to support IPv6 RA much more comprehensively. Since the API is extended quite a bit networkd has been ported over too, and the patch is not as straight-forward as one could wish. The rework includes: - Support for DNSSL, RDNSS and RA routing options in sd-ndisc and networkd. Two new configuration options have been added to networkd to make this configurable. - sd-ndisc now exposes an sd_ndisc_router object that encapsulates a full RA message, and has direct, friendly acessor functions for the singleton RA properties, as well as an iterative interface to iterate through known and unsupported options. The router object may either be retrieved from the wire, or generated from raw data. In many ways the sd-ndisc API now matches the sd-lldp API, except that no implicit database of seen data is kept. (Note that sd-ndisc actually had a half-written, but unused implementaiton of such a store, which is removed now.) - sd-ndisc will now collect the reception timestamps of RA, which is useful to make sd_ndisc_router fully descriptive of what it covers. Fixes: #1079
2016-06-06network: use inet_ntop() rather than SD_NDISC_ADDRESS_FORMAT_VAL() when ↵Lennart Poettering
serializing Let's use the usual libc API for serializing IPv6 addresses, instead of the NDISC-specific macro we should get rid of anyway.
2016-06-06lldp: minor coding style improvementLennart Poettering
2016-06-06lldp: add sd_lldp_get_event() callLennart Poettering
sd-ndisc has something like this, let's add this for sd-lldp, too.
2016-06-06lldp: deal properly with recv() returning EAGAIN/EINTRLennart Poettering
It might very well return EAGAIN in case of packet checksum problems and suchlike, hence let's better handle this nicely, the same way as we do it in the other sd-network libraries for incoming datagrams.
2016-06-06lldp: pass correct neighbor object to REMOVED callbackLennart Poettering
2016-06-06lldp: rename TLV accessor pseudo-macrosLennart Poettering
Let's make sure the inline functions for retrieving TLV data actually carry TLV in the name, so that we don#t assume they retrieve the whole, raw packet data.
2016-06-06lldp: make sd_lldp_neighbor_tlv_rewind() return whether there's a first entryLennart Poettering
This way it's nicer to use as it matches how sd_lldp_neighbor_tlv_next() indicates an EOF too via its return value.
2016-06-06lldp: use NULL instead 0, when we deal with a pointerLennart Poettering
2016-06-06lldp: add _public_ to a two exported functions missing itLennart Poettering
2016-06-06lldp: clarify that sd_lldp_neighbor_get_ttl() returns secondsLennart Poettering
Let's simply encode this in the parameter name.
2016-06-06lldp: add proper ref counting to sd_lldp object and a separate call for ↵Lennart Poettering
setting the ifindex Let's make sd-lldp a bit more like sd-ndisc ant the other APIs, and add proper ref counting and a separate call for setting the ifindex. This also adds a new lldp_reset() call we can use at various places to close all fds. This is also similar to how sd-ndisc already does it.
2016-06-06sd-lldp: take triple timestamp when reading LLDP packetsLennart Poettering
It's a good idea to store away the recption time of LLDP packets in the neighbor object, simply because the LLDP data only has a validity of a certain amount of time. Hence, let's record the timestamp when we receive the datagram and expose an API for it. Also, automatically expire LLDP neighbors based on this new timestamp.
2016-06-04Merge pull request #3392 from poettering/assorted-stuffZbigniew Jędrzejewski-Szmek
Assorted stuff
2016-05-31network: fix wrong include of source file "ether-addr-util.c" (#3402)Thomas Haller
Fixes: 9ed8b06c9be4a5efae432d5cf4b1c47d03e6f107
2016-05-30dhcp-server: fix integer underflowLennart Poettering
Let's better ignore an invalid message size parameter, than assume ridiculously larger sizes.
2016-05-28Merge pull request #3360 from glaubitz/masterZbigniew Jędrzejewski-Szmek
Fix multiple unaligned accesses in test-dns-packet and sd-dhcp-server.
2016-05-27networkd/sd-dhcp-server: Fix unaligned access in parse_request().John Paul Adrian Glaubitz
2016-05-26ipv4ll: shorten some checks by using IN_SET a bitLennart Poettering
As suggested: https://github.com/systemd/systemd/pull/3328#discussion-diff-64285764
2016-05-26sd-ndisc: small coding style fixesLennart Poettering
Let's use usec_t internally always, when dealing with time values. Let's use uint8_t* pointers if we are dealing with generic byte pointers.
2016-05-26sd-ndisc: add more whitespaceLennart Poettering
Whitespace doesn't hurt and helps structuring things.
2016-05-26sd-ndisc: stop discovery properly when something failsLennart Poettering
2016-05-26sd-ndisc: rework size checking in ndisc_ra_parse()Lennart Poettering
Let's better check the size before we subtract. Also, let's change the size argument to size_t, as it cannot be signed anyway. Finally, use EBADMSG for indicating invalid packets, like we do everywhere else.
2016-05-26sd-ndisc: simplify clamping of router "pref" parameterLennart Poettering
2016-05-26sd-ndisc: append "event_source" to event source objects stored in structuresLennart Poettering
Otherwise it gets too confusing whether "timeout" refers to an event source or just a timeout time specification.
2016-05-26sd-ndisc: add log_ndisc_errno() macro, to complement log_ndisc() like elsewhereLennart Poettering
Also make use of it where appropriate.
2016-05-26sd-ndisc: use the right object to pass to log_ndisc()Lennart Poettering
There's no "client" object, in both cases. There's only "nd". This wasn't noticed before, as the context object is currently not actually used by the log macros.
2016-05-26sd-ndisc: Typo fix: s/advertisment/advertisement/Lennart Poettering