summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-network
Commit message (Collapse)AuthorAgeFilesLines
* network: Show network and link file dropins in networkctl statusDaan De Meyer2023-01-121-0/+19
| | | | Fixes #24428
* 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.
* basic: rename util.h to logarithm.hZbigniew Jędrzejewski-Szmek2022-11-081-1/+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-network: make sd_network_link_get_dns() or friends return -ENODATAYu Watanabe2022-09-271-14/+4
| | | | To make them consistent with other functions.
* sd-network: drop fallback valuesYu Watanabe2022-09-271-65/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This drops spurious lines in `networkctl status` for unmanaged interfaces. Before: ``` $ networkctl status --lines 0 lo ● 1: lo Link File: n/a Network File: n/a Type: loopback State: carrier (unmanaged) Online state: unknown HW Address: 00:00:00:00:00:00 MTU: 65536 QDisc: noqueue IPv6 Address Generation Mode: eui64 Queue Length (Tx/Rx): 1/1 Address: 127.0.0.1 ::1 Activation Policy: up Required For Online: yes ``` After: ``` $ networkctl status --lines 0 lo ● 1: lo Link File: n/a Network File: n/a State: carrier (unmanaged) Online state: unknown Type: loopback Hardware Address: 00:00:00:00:00:00 MTU: 65536 QDisc: noqueue IPv6 Address Generation Mode: eui64 Number of Queues (Tx/Rx): 1/1 Address: 127.0.0.1 ::1 ``` That is, the lines for Activation Policy and Required For Online are dropped.
* sd-network: introduce network_link_get_boolean() helper functionYu Watanabe2022-09-271-14/+12
|
* sd-network: accept all space-like separatorsYu Watanabe2022-09-271-2/+2
|
* sd-network: propagate -ENOENTYu Watanabe2022-09-271-19/+0
| | | | | | On -ENOENT, it suggests that network-manager is not running, and interfaces are not unmanaged. Such information may be useful for callers.
* sd-network: rename function arguments for storing return valueYu Watanabe2022-09-271-55/+54
|
* sd-network: Keep inotify watch if watch descriptor didn't changeDaan De Meyer2022-05-041-17/+20
| | | | | | | | | | | | | In sd_network_monitor_flush(), we shouldn't remove the inotify watch for the current directory if the directory the network monitor is waiting for wasn't created yet. inotify_add_watch() returns the same unique watch descriptor if a path is already being watched. Let's return the watch descriptor from monitor_add_inotify_watch() so we can check if it's the same as the watch descriptor of the inotify event. If they are equal, we're still watching the same path and we don't need to remove the inotify watch just yet.
* inotify-util: declare iterator in FOREACH_INOTIFY_EVENT()Yu Watanabe2022-03-241-1/+0
| | | | | This also makes the macro check if the event is actually in the buffer, and if it is not, then log about that and finish the loop.
* network-util: introduce network_link_get_operational_state()Yu Watanabe2022-01-212-0/+21
|
* sd-network: introduce sd_network_link_get_stat()Yu Watanabe2021-12-081-0/+17
|
* sd-network: drop unnecessary +1 for buffer sizeYu Watanabe2021-12-081-4/+4
|
* sd-network: drop _public_ attributeYu Watanabe2021-12-081-43/+43
| | | | sd-network is not public yet.
* tree-wide: use ERRNO_IS_TRANSIENT()Yu Watanabe2021-11-301-1/+1
|
* netif-util: move several functions from network-util.[ch] to ↵Yu Watanabe2021-11-092-90/+2
| | | | | | | shared/netif-util.[ch] These functions are not relevant to sd-network, and only used by networkd, networkctl, and udevd.
* arphrd-util: rename arphrd-list.[ch] -> arphrd-util.[ch]Yu Watanabe2021-11-091-1/+1
|
* basic: split out inotify-related calls from fs-util.h → inotify-util.hLennart Poettering2021-10-051-0/+1
|
* tree-wide: voidify unchecked close_nointr callsLuca Boccassi2021-08-031-1/+1
| | | | | | | | | | These have ignored the return value forever. Two are public APIs so we can't really change what they return anyway, and the other one is a cleanup path and the existing error code is more important. CID#1461274 CID#1461275 CID#1461276
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* network: use the overall online state in network_is_online()Alvin Šipraga2021-05-191-9/+23
| | | | | | | Since networkd advertises a reliable online state, use it in network_is_online(). If for some reason networkd does not know the online state (e.g. it does not manage any of the network interfaces), fall back to the original best-guess logic.
* network: add an online state for links and managerAlvin Šipraga2021-05-193-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a new state of type LinkOnlineState which indicates whether a link is online or not. The state is also used by networkd's manager to expose the overall online state of the system. The possible states are: offline the link (or system) is offline partial at least one required link is online (see below) online all required links are online For links, a link is defined to be "online" if: - it is managed; and - its operational state is within the range defined by RequiredForOnline=; and - it has an IPv4 address if RequiredFamilyForOnline=ipv4 or =both; and - it has an IPv6 address if RequiredFamilyForOnline=ipv6 or =both. A link is defined to be "offline" if: - it is managed; and - it is not online, i.e. its operational state is not within the range defined by RequiredForOnline=, and/or it is missing an IP address in a required address family. Otherwise, the link online state is undefined (represented internally as _LINK_ONLINE_STATUS_INVALID or -EINVAL). Put another way, networkd will only offer a meaningful online state for managed links where RequiredForOnline=yes. For the manager, the online state is a function of the online state of all links which are requried for online, i.e. RequiredForOnline=yes. If all required links are online, then the manager online state is defined to be "online". If at least one of the required links is online, then the manager online state is defined to be "partial". If none of the required links are online, then the manager online state is defined to be "offline". If there are no managed links, or RequiredForOnline=no for all managed links, then the manager online state is undefined as above. The purpose of the "partial" state is analogous to the --any switch in systemd-networkd-wait-online.service(8). For example, a required link which lacks a carrier on boot will not force the overall (manager) online state to "offline" if there is an alternative link available.
* udev,network: make link_get_type_string() return negative errno on failureYu Watanabe2021-05-142-7/+14
| | | | And make net_match_config() propagate the error.
* sd-network: read IPv4/IPv6 address states from state filesLetzteInstanz2021-04-141-0/+36
|
* network: save IPv4/IPv6 address states into state fileLetzteInstanz2021-04-142-0/+12
| | | | | This also introduces RequiredFamilyForOnline= setting to .network file, and IPv4AddressState/IPv6AddressState DBus properties.
* network: move AddressFamily into network-util for the use by wait-online laterLetzteInstanz2021-04-141-0/+10
|
* tree-wide: use UINT64_MAX or friendsYu Watanabe2021-03-051-2/+2
|
* tree-wide: use -EINVAL for enum invalid valuesZbigniew Jędrzejewski-Szmek2021-02-101-3/+3
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/11484#issuecomment-775288617. This does not touch anything exposed in src/systemd. Changing the defines there would be a compatibility break. Note that tests are broken after this commit. They will be fixed in the next one.
* save link activation policy to state file and display in networkctlDan Streetman2021-01-211-0/+21
|
* Merge pull request #17478 from yuwata/split-network-internalYu Watanabe2020-11-272-0/+83
|\ | | | | libsystemd-network: split network-internal.c
| * sd-network: move net_get_unique_predictable_data() and net_get_name_persisten()Yu Watanabe2020-10-292-0/+59
| |
| * sd-network: move link_get_type_string()Yu Watanabe2020-10-292-0/+24
| |
* | license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-093-3/+3
|/
* sd-{login,netlink,network}: use TAKE_FD() in more placesZbigniew Jędrzejewski-Szmek2020-09-221-9/+3
|
* sd-network: drop unused functionsYu Watanabe2020-06-231-12/+0
|
* network: clean-up DHCP lease server data configurationLennart Poettering2020-06-181-16/+0
| | | | | | | | | | | | | | | | | | | | | | | | This is an attempt to clean up the POP3/SMTP/LPR/… DHCP lease server data logic in networkd. This reduces code duplication and fixes a number of bugs. This removes any support for collecting POP3/SMPT/LPR servers acquired via local DHCP client releases since noone uses that, and given how old these protocols are I doubt this will change. It keeps support for configuring them for the dhcp server however. The differences between the DNS/NTP/SIP/POP3/SMTP/LPR configuration logics are minimized. This removes the relevant symbols from sd-network.h (which is an internal API only at this point after all). This is unfortunately not well test, given the old code for this had barely any tests. But the new code should not perform worse at least, and allow us to release, since it corrects some interfaces visible in the .network configuration format. Fixes: #15943
* sd-network: Introduce APIs to get DHCP6 DUIDSusant Sahani2020-06-101-0/+4
|
* sd-network: Introduce API to get DHCPv6 IAIDSusant Sahani2020-06-091-0/+4
|
* sd-network: Introduce API to access DHCP4 client IDSusant Sahani2020-06-081-0/+4
|
* sd-network: Add support to retrive LPR serversSusant Sahani2020-04-221-0/+4
|
* sd-network: Add support to emit and receive SMTP server informationSusant Sahani2020-03-291-0/+4
|
* sd-network: Add support to emit and receive pop3 server informationSusant Sahani2020-03-281-0/+4
|
* sd-network: Provice APIs to access SIP servers given by DHCP4 serverSusant Sahani2020-03-221-0/+4
|
* Merge pull request #14536 from DaanDeMeyer/wait-online-max-operstateZbigniew Jędrzejewski-Szmek2020-02-052-0/+58
|\ | | | | wait-online: add maximum operational state option
| * wait-online: Support waiting for interfaces to disappearDaan De Meyer2020-01-182-1/+3
| |
| * wait-online: Add maximum operational state optionDaan De Meyer2020-01-182-0/+56
| |
* | tree-wide: make parse_ifindex simply return the indexZbigniew Jędrzejewski-Szmek2020-01-111-7/+4
|/ | | | | | | | We don't need a seperate output parameter that is of type int. glibc() says that the type is "unsigned", but the kernel thinks it's "int". And the "alternative names" interface also uses ints. So let's standarize on ints, since it's clearly not realisitic to have interface numbers in the upper half of unsigned int range.
* tree-wide: drop string.h when string-util.h or friends are includedYu Watanabe2019-11-041-1/+0
|
* network: DHCP server Add support to transmit SIP serverSusant Sahani2019-09-201-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. DHCP server trasmit 2. Client parses and saves in leases Implements http://www.rfc-editor.org/rfc/rfc3361.txt ``` Frame 134: 348 bytes on wire (2784 bits), 348 bytes captured (2784 bits) on interface 0 Ethernet II, Src: 42:65:85:d6:4e:32 (42:65:85:d6:4e:32), Dst: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4) Internet Protocol Version 4, Src: 192.168.5.1, Dst: 192.168.5.11 User Datagram Protocol, Src Port: 67, Dst Port: 68 Dynamic Host Configuration Protocol (ACK) Message type: Boot Reply (2) Hardware type: Ethernet (0x01) Hardware address length: 6 Hops: 0 Transaction ID: 0x7cc87cb4 Seconds elapsed: 0 Bootp flags: 0x0000 (Unicast) Client IP address: 0.0.0.0 Your (client) IP address: 192.168.5.11 Next server IP address: 0.0.0.0 Relay agent IP address: 0.0.0.0 Client MAC address: 1e:04:f8:b8:2f:d4 (1e:04:f8:b8:2f:d4) Client hardware address padding: 00000000000000000000 Server host name not given Boot file name not given Magic cookie: DHCP Option: (53) DHCP Message Type (ACK) Length: 1 DHCP: ACK (5) Option: (51) IP Address Lease Time Length: 4 IP Address Lease Time: (3600s) 1 hour Option: (1) Subnet Mask (255.255.255.0) Length: 4 Subnet Mask: 255.255.255.0 Option: (3) Router Length: 4 Router: 192.168.5.1 Option: (6) Domain Name Server Length: 4 Domain Name Server: 192.168.5.1 Option: (42) Network Time Protocol Servers Length: 4 Network Time Protocol Server: 192.168.1.1 Option: (120) SIP Servers <=====here Length: 9 SIP Server Encoding: IPv4 Address (1) SIP Server Address: 192.168.1.1 SIP Server Address: 192.168.5.2 Option: (101) TCode Length: 13 TZ TCode: Europe/Berlin Option: (54) DHCP Server Identifier (192.168.5.1) Length: 4 DHCP Server Identifier: 192.168.5.1 Option: (255) End Option End: 255 ``` ``` cat /run/systemd/netif/state  ✔  ⚡  3148  16:40:51 OPER_STATE=routable CARRIER_STATE=carrier ADDRESS_STATE=routable DNS=192.168.94.2 192.168.5.1 NTP=192.168.5.1 SIP=192.168.1.1 192.168.5.2 ``` aa