summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-netlink
Commit message (Collapse)AuthorAgeFilesLines
* sd-netlink: make rtnl_set_link_name() optionally append alternative namesYu Watanabe2023-05-163-23/+77
|
* libsystemd: drop _public_ attribute for non-exported functionsYu Watanabe2023-04-291-1/+1
|
* network: geneve: add InheritInnerProtocol flagJosef Miegl2023-03-061-13/+14
|
* test-netlink: use dummy interface to test assigning new interface nameYu Watanabe2023-01-101-4/+55
| | | | Fixes #25981.
* test: modernize test-netlink.cYu Watanabe2023-01-091-246/+116
|
* tree-wide: use -EBADF for fd initializationZbigniew Jędrzejewski-Szmek2022-12-192-3/+3
| | | | | | | | | | | | | | | | -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-netlink: add a test for rtnl_set_link_name()Nick Rosbrook2022-12-151-0/+27
| | | | | Add a test that verifies a deleted alternative name is restored on error in rtnl_set_link_name().
* sd-netlink: restore altname on error in rtnl_set_link_nameNick Rosbrook2022-12-151-3/+16
| | | | | | | If a current alternative name is to be used to rename a network interface, the alternative name must be removed first. If interface renaming fails, restore the alternative name that was deleted if necessary.
* sd-netlink: do not swap old name and alternative nameNick Rosbrook2022-12-151-13/+0
| | | | | | | | | Commit 434a348380 ("netlink: do not fail when new interface name is already used as an alternative name") added logic to set the old interface name as an alternative name, but only when the new name is currently an alternative name. This is not the desired outcome in most cases, and the important part of this commit was to delete the new name from the list of alternative names if necessary.
* sd-netlink: fix assertion triggered by message_get_serial()Yu Watanabe2022-11-301-1/+2
| | | | | | This fixes an issue introduced by 7b34bae3b1a8726e241a56600a6edf9b3733a4f4. Fixes https://github.com/systemd/systemd/pull/25565#issuecomment-1331353945.
* sd-netlink: append instead of prepend multipart messageYu Watanabe2022-11-261-9/+14
| | | | | | | | | | | | | | | | | | | | | | | Previously, e.g., networkd enumerated network interfaces with ifindex in a decreasing order, as sd-netlink inverses the order of the received multipart messages. Let's keep the order of the multipart messages. Hopefully this changes no behavior, as our code do not depend on the order of the received multipart messages. Before: === Nov 26 09:35:10 systemd[1]: Starting Network Configuration... Nov 26 09:35:11 systemd-networkd[36185]: wlp59s0: Saved new link: ifindex=3, iftype=ETHER(1), kind=n/a Nov 26 09:35:12 systemd-networkd[36185]: enp0s31f6: Saved new link: ifindex=2, iftype=ETHER(1), kind=n/a Nov 26 09:35:12 systemd-networkd[36185]: lo: Saved new link: ifindex=1, iftype=LOOPBACK(772), kind=n/a After: === Nov 26 09:45:18 systemd[1]: Starting Network Configuration... Nov 26 09:45:19 systemd-networkd[38372]: lo: Saved new link: ifindex=1, iftype=LOOPBACK(772), kind=n/a Nov 26 09:45:19 systemd-networkd[38372]: enp0s31f6: Saved new link: ifindex=2, iftype=ETHER(1), kind=n/a Nov 26 09:45:19 systemd-networkd[38372]: wlp59s0: Saved new link: ifindex=3, iftype=ETHER(1), kind=n/a
* sd-netlink: do not link non-multipart messagesYu Watanabe2022-11-261-33/+35
| | | | | | | | Previously, if a single packet contains multiple non-multipart messages, then the messages were linked and saved as a single entry, especially even if the messages has different serial numbers. Though, not sure if the kernel sends such packet. But at least for safety, let's link only multipart messages.
* sd-netlink: split out parse_message_one() from socket_read_message()Yu Watanabe2022-11-261-39/+60
| | | | | No functional change, just refactoring and preparation for later commits.
* sd-netlink: do not use serials currently queuedYu Watanabe2022-11-261-1/+10
|
* sd-netlink: also manage received messages by serialYu Watanabe2022-11-263-13/+41
| | | | | Then, we can easily find the received message matching with requested serial.
* sd-netlink: reimplement received message queueYu Watanabe2022-11-263-68/+46
| | | | | By using OrderedSet and Hashmap, we can drop all memmove() calls. No functional changes, just refactoring.
* sd-netlink: introduce netlink_queue_received_message() and friendYu Watanabe2022-11-263-44/+41
| | | | No functional change, just refactoring.
* sd-netlink: fix segfaultYu Watanabe2022-11-261-1/+2
|
* sd-netlink: fix possible use-after-freeYu Watanabe2022-11-261-27/+24
| | | | | | | When we receive a multi-part message and fail to parse it, then the prviously received message is freed with the _cleanup_ attribute, but still referenced by sd_netlink.rqueue_partial. That causes use-after-free when we receive another multi-part message.
* sd-netlink: return earlier when received invalid messageYu Watanabe2022-11-261-2/+7
|
* sd-netlink: allocate read buffer when necessaryYu Watanabe2022-11-262-5/+0
|
* sd-netlink: check received size in socket_recv_message()Yu Watanabe2022-11-261-14/+10
| | | | | No functional change, just refactoring and slightly shorten socket_read_message().
* sd-netlink: drop redundant 'else'Yu Watanabe2022-11-261-4/+2
|
* sd-netlink: always initialize return variable on successYu Watanabe2022-11-261-2/+7
|
* sd-netlink: handle EINTR from poll() gracefully, as successLennart Poettering2022-11-221-1/+6
|
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-083-3/+0
| | | | | util.h is now about logarithms only, so we can rename it. Many files included util.h for no apparent reason… Those includes are dropped.
* sd-netlink: unexport sd-netlinkYu Watanabe2022-09-174-135/+135
| | | | | | | This effectively reverts 84e1001541151da71bae2137e2a1c254b5a3b89f. The sd-netlink library has several issues, and we should not export it without solving them. See issues #24258 and #24124.
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-8/+3
|
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-1/+1
| | | | gcc will complain about all these with -Wformat-signedness.
* sd-netlink: add NetLabel supportTopi Miettinen2022-08-292-7/+20
|
* sd-netlink: fix attribute type for RTAX_CC_ALGOYu Watanabe2022-08-261-1/+1
|
* sd-netlink: use SD_EVENT_ONESHOT for a time-based callbackZbigniew Jędrzejewski-Szmek2022-08-191-1/+2
|
* sd-netlink: simplify error code retentionZbigniew Jędrzejewski-Szmek2022-08-191-14/+12
|
* sd-netlink: delete sd_netlink_new_from_fd()Zbigniew Jędrzejewski-Szmek2022-08-191-25/+0
| | | | It was somewhat similar to sd_netlink_open_fd(), and unused.
* sd-netlink: rename sd_netlink_message_request_dump to ↵Zbigniew Jędrzejewski-Szmek2022-08-192-3/+3
| | | | sd_netlink_message_set_request_dump
* sd-netlink: constify parameters in public api and adjust pointer formattingZbigniew Jędrzejewski-Szmek2022-08-195-13/+22
| | | | | In the internal api, 'char* const*' is used instead of 'const char* const*' because otherwise we'd get a mismatch with the various strv apis.
* sd-netlink: prefix output param names with 'ret'Zbigniew Jędrzejewski-Szmek2022-08-191-15/+15
| | | | | | | | | In some places, the code was already using that, so only the header file needed to be adjusted. We use 'nl' for the sd_netlink* when it's passed in as input. I was considering renaming to 'netlink', but that'd add a lot of verbosity and also we have 'sd_journal *j' in sd-journal, so the short name matches in style.
* sd-netlink: rename NLType and friendsYu Watanabe2022-08-0610-1727/+1722
| | | | | | | | | | | | | | | | | In sd-netlink, we use 'type' for naming many variables with different type, and worst of all, function like `type_get_type()` exists. That makes the code hard to understood. Let's rename - NLType -> NLAPolicy - NLTypeSystem -> NLAPolicySet - NLTypeSystemUnion -> NLAPolicySetUnion - type_get_type() -> policy_get_type() - type_get_type_system() -> policy_get_policy_set(), and so on. This also changes the type of attribute taken by e.g. `sd_netlink_message_append_string()` from `unsigned short` -> `uint16_t` to make the variable size clearer.
* sd-netlink: introduce sd_nfnl_{send,call}_batch()Yu Watanabe2022-07-242-22/+176
| | | | | This also introduces sd_nfnl_message_new() which can be also used for non-nftables subsystems.
* sd-netlink: do not compare pointer with 0Yu Watanabe2022-07-241-1/+1
|
* sd-netlink: merge sd_nfnl_nft_message_{new,del}_setelems_begin()Yu Watanabe2022-07-242-53/+24
| | | | | | | And this makes the new merged function `sd_nfnl_nft_message_new_setelems()` not open container, as containers should be opened and closed in the same function in general. Otherwise, it is hard to understand which level we are in the nested attribute tree.
* sd-netlink: drop unused sd_nfnl_nft_message_del_table()Yu Watanabe2022-07-232-23/+0
|
* sd-netlink: introduce sd_netlink_message_append_container_data()Yu Watanabe2022-07-232-16/+25
|
* sd-netlink: several cleanups for netfilterYu Watanabe2022-07-232-39/+52
| | | | | | | | - rename family -> nfproto, and other arguments, - check specified nfproto, - change type of several function arguments that specify data length, - add several assertions, - drop unnecessary headers.
* tree-wide: drop unnecessary inclusion of netlink-util.hYu Watanabe2022-07-232-2/+0
|
* sd-netlink: move rtnl_message_type_is_*() to netlink-message-rtnl.cYu Watanabe2022-07-232-40/+40
|
* sd-netlink: add sizes for some IP and Ethernet addressesTopi Miettinen2022-07-112-12/+12
| | | | | Add sizes for some uses of NETLINK_TYPE_IN_ADDR and NETLINK_TYPE_ETHER_ADDR types.
* basic/socket-util: rename fd_inc_rcvbuf → fd_increase_rxbufZbigniew Jędrzejewski-Szmek2022-06-301-1/+1
| | | | See previous commit for justification.
* sd-netlink: rename sd_netlink_inc_rcvbuf → sd_netlink_increase_rxbufZbigniew Jędrzejewski-Szmek2022-06-301-1/+1
| | | | | | We have RxBufferSize= and TxBufferSize= in .link files. Let's use the same abbreviation here. OTOH, "inc" could be short for "increment" or "increase", let's avoid that.
* sd-netlink: allow sd_netlink_message_read() to be used for union typesZbigniew Jędrzejewski-Szmek2022-06-301-3/+3
| | | | | | | | | | | Before, sd_netlink_message_read() expected to fill a buffer completely, and would return -EIO if the attribute being read was shorter than the buffer. This means that the function can be used to "peek" into attributes (by specifying a short buffer to just read part of the attribute), but cannot be used to read something into a union without knowing beforehand which specific field in the union is being filled. That latter operation seems more useful (messages are short, so we don't really need to do partial reads), so let's allow reads that don't fill the output buffer completely.