summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-ndisc.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-191-1/+1
| | | | | | | | | | | | | | | | -1 was used everywhere, but -EBADF or -EBADFD started being used in various places. Let's make things consistent in the new style. Note that there are two candidates: EBADF 9 Bad file descriptor EBADFD 77 File descriptor in bad state Since we're initializating the fd, we're just assigning a value that means "no fd yet", so it's just a bad file descriptor, and the first errno fits better. If instead we had a valid file descriptor that became invalid because of some operation or state change, the other errno would fit better. In some places, initialization is dropped if unnecessary.
* sd-ndisc: ignore failure in sending solicitationYu Watanabe2022-10-111-7/+6
| | | | | | | | | Even if a bonding master interface has carrier, the underlying slave interfaces may not. In such a case, sending solicitation fails with -ENOBUS. Here, let's unconditionally ignore errors, as anyway we will send a solicitation later. Fixes #24717.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-6/+3
|
* basic/in-addr-util: add IN_ADDR_TO_STRINGZbigniew Jędrzejewski-Szmek2022-06-061-3/+2
| | | | | | | | | | | | | | | Since we don't need the error value, and the buffer is allocated with a fixed size, the whole logic provided by in_addr_to_string() becomes unnecessary, so it's enough to wrap inet_ntop() directly. inet_ntop() can only fail with ENOSPC. But we specify a buffer that is supposed to be large enough, so this should never fail. A bunch of tests of this are added. This allows all the wrappers like strna(), strnull(), strempty() to be dropped. The guard of 'if (DEBUG_LOGGING)' can be dropped from around log_debug(), because log_debug() implements the check outside of the function call. But log_link_debug() does not, so it we need it to avoid unnecessary evaluation of the formatting.
* time-util: assume CLOCK_BOOTTIME always existsLennart Poettering2022-03-281-5/+5
| | | | | | | | Let's raise our supported baseline a bit: CLOCK_BOOTTIME started to work with timerfd in kernel 3.15 (i.e. back in 2014), let's require support for it now. This will raise our baseline only modestly from 3.13 → 3.15.
* libsystemd-network: ignore -ENETDOWN or friends in recv()Yu Watanabe2021-12-091-8/+9
| | | | And this makes most errors in io events ignored.
* libsystemd-network: drop _public_ attributeYu Watanabe2021-10-291-9/+9
| | | | No function in libsystemd-network is exposed yet.
* sd-ndisc: drop unused functionsYu Watanabe2021-10-291-28/+0
| | | | | All received information is stored in sd_ndisc_router, and we have sd_ndisc_router_get_mtu() and sd_ndisc_router_get_hop_limit().
* libsystemd-network: make sd_dhcp_client_get_ifname() or friends return ↵Yu Watanabe2021-09-291-4/+12
| | | | negative errno on error
* libsystemd-network: disable event sources before unref themYu Watanabe2021-09-241-4/+5
| | | | Fixes #20825.
* tree-wide: add FORMAT_TIMESPAN()Zbigniew Jędrzejewski-Szmek2021-07-091-3/+1
|
* libsystemd-network: make log_dhcp_client() or friends include interface nameYu Watanabe2021-03-041-18/+18
|
* libsystemd-network: introduce sd_xxx_{set,get}_ifname()Yu Watanabe2021-03-041-0/+19
|
* network: suffix types with _t in public headersLennart Poettering2021-02-181-2/+2
| | | | | | | | | | | | Apparently, in our current public headers (i.e. those called sd-*.h) we suffixed typedefs that we use as values with _t, but we didn't do this for enum typedefs. Fix that while this stuff is not actually public yet. With this scheme "value typedefs" now end systematically in _t, and "object typedefs" (i.e. structures that are typically passed around via pointers and not values) do not. No code changes, just some renaming.
* tree-wide: constify variables if possibleYu Watanabe2021-02-181-1/+1
|
* sd-ndisc: fix indentationYu Watanabe2020-12-241-2/+1
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* libsystemd-network: do not request each daemon exist in sd_xxx_stop()Yu Watanabe2020-10-151-1/+2
|
* ndisc: make first solicit delayed randomlyYu Watanabe2019-09-161-1/+1
| | | | Closes #13460.
* util: split out memcmp()/memset() related calls into memory-util.[ch]Lennart Poettering2019-03-131-1/+1
| | | | Just some source rearranging.
* Delete duplicate linesTopi Miettinen2019-01-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by inspecting results of running this small program: int main(int argc, const char **argv) { for (int i = 1; i < argc; i++) { FILE *f; char line[1024], prev[1024], *r; int lineno; prev[0] = '\0'; lineno = 1; f = fopen(argv[i], "r"); if (!f) exit(1); do { r = fgets(line, sizeof(line), f); if (!r) break; if (strcmp(line, prev) == 0) printf("%s:%d: error: dup %s", argv[i], lineno, line); lineno++; strcpy(prev, line); } while (!feof(f)); fclose(f); } }
* sd-ndisc: do not unref() event sources when update or disable themYu Watanabe2018-11-161-41/+24
|
* sd-ndisc: use structured initializer at one more placeYu Watanabe2018-11-161-3/+5
|
* ndisc: improve debug log messageYu Watanabe2018-11-061-2/+13
|
* sd-ndisc: change return value of ndisc_reset() to voidLennart Poettering2018-10-131-3/+1
| | | | | We never generate anything other than 0 anyway, and we never check it, hence let's just simplify things.
* sd-ndisc: voidify sd_ndisc_stop() callLennart Poettering2018-10-131-1/+1
| | | | CID 1395839
* sd-ndisc: generate debug log messages on unexpected errorsLennart Poettering2018-10-021-1/+8
| | | | | We really should make it possible to debug unexpected errors, hence log something at LOG_DEBUG.
* tree-wide: use DEFINE_TRIVIAL_REF_UNREF_FUNC() macro or friends where applicableYu Watanabe2018-08-271-21/+4
|
* tree-wide: use proper unicode © instead of (C) where we canLennart Poettering2018-06-141-1/+1
| | | | | | Let's use a proper unicode copyright symbol where we can, it's prettier. This important patch is very important.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-2/+1
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* sd-ndisc.c: Move Router Solicitation sending after timer computaionPatrik Flykt2017-05-301-6/+6
| | | | | | | | Move ICMPv6 Router Solicitation sending after timer computation so that timers are already set up when the packet is being sent. This makes it possible to create a test that inspects Router Solicitation timer values when the Router Solicitation is sent out on the network.
* sd-ndisc: Implement Router Solicitation backoff methodPatrik Flykt2017-05-301-18/+70
| | | | | | | | | | | | | Instead of sending a fixed amount of Router Solicitiations, implement the backoff algorithm proposed in RFC 7559. The backoff algorithm is the same as used by DHCPv6. Time out after 12s as specified in RFC 4861 in order not to delay setting up a link for too long while sending Router Solicitations in the background. Notice that after this change the callback will receive a SD_NDISC_EVENT_TIMEOUT timeout event, and at a later point when a router appears, a received Router Advertisment will cause the callback to be called again with the SD_NDISC_EVENT_ROUTER event.
* sd-radv: Receive Router SolicitationsPatrik Flykt2017-05-151-73/+20
| | | | | | | | Receive Router Solicitations and send a unicast Router Advertisment in response. Refactor ICMPv6 packet handling code so that the common ICMPv6 validation parts are reused between the existing router discovery and the new functionality adding reception of Router Solicitation messages.
* sd-ndisc: Reset counter for sent Router Solicitations (#5874)Patrik Flykt2017-05-021-0/+1
| | | | | | Reset also the counter for number of Router Solicitations sent when the associated file descriptor is closed and the event source unreferenced. With this change the router discovery can now be stopped and restarted arbitrary many times.
* tree-wide: use mfree moreZbigniew Jędrzejewski-Szmek2016-10-161-3/+1
|
* sd-ndisc: add missing castLennart Poettering2016-06-141-1/+1
| | | | | | 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.
* network: beef up ipv6 RA support considerablyLennart Poettering2016-06-061-418/+133
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* sd-ndisc: small coding style fixesLennart Poettering2016-05-261-3/+2
| | | | | | 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.
* sd-ndisc: add more whitespaceLennart Poettering2016-05-261-10/+12
| | | | Whitespace doesn't hurt and helps structuring things.
* sd-ndisc: stop discovery properly when something failsLennart Poettering2016-05-261-7/+13
|
* sd-ndisc: rework size checking in ndisc_ra_parse()Lennart Poettering2016-05-261-8/+7
| | | | | | | | 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.
* sd-ndisc: simplify clamping of router "pref" parameterLennart Poettering2016-05-261-7/+1
|
* sd-ndisc: append "event_source" to event source objects stored in structuresLennart Poettering2016-05-261-17/+15
| | | | | Otherwise it gets too confusing whether "timeout" refers to an event source or just a timeout time specification.
* sd-ndisc: add log_ndisc_errno() macro, to complement log_ndisc() like elsewhereLennart Poettering2016-05-261-5/+5
| | | | Also make use of it where appropriate.
* sd-ndisc: use the right object to pass to log_ndisc()Lennart Poettering2016-05-261-2/+2
| | | | | | | 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.
* sd-ndisc: Typo fix: s/advertisment/advertisement/Lennart Poettering2016-05-261-6/+6
|
* sd-ndisc: make the _stop() call idempotentLennart Poettering2016-05-261-3/+4
| | | | | It's a good idea to make stopcalls idempotent, so that they become nops if the object is already stopped.