summaryrefslogtreecommitdiffstats
path: root/src/network/networkd-setlink.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* network/bridge: fix UseBPDU= and AllowPortToBeRoot=Yu Watanabe2022-08-131-2/+2
| | | | | | Fixes bugs caused by 7f9915f0de67f3a10a4b22810d119da65af8c84a. Fixes #24268.
* network: also check SR-IOV PF port and other VF ports before configuringYu Watanabe2022-08-051-2/+16
| | | | | | | | | | | | | | When a PF port becomes down (this can happens e.g. the PF port is joining a bond interface), some drivers make its VF ports also become down, and may cause failures in configuring VF ports. Similary, when a VF port become down, some drivers make its PF port and other VF ports down. Let's configure SR-IOV ports (both PF and VFs) after all link-layer settings of all ports being applied. Fixes #23315.
* network: unset master ifindex only when necessaryYu Watanabe2022-08-051-5/+13
|
* network: do not try to bring up wifi interface if rfkill is activeYu Watanabe2022-07-231-2/+9
| | | | | | | | | This fixes the following error: --- systemd-networkd[465]: wlan0: Could not bring up interface: Operation not possible due to RF-kill --- Fixes #23649.
* network: do not silently stop to process configuration on activation failureYu Watanabe2022-07-231-11/+4
| | | | | | | | Previously, if activation failed, link did not enter the failed state, but still Link.activated flag not set. Hence, nothing processed even if the interface is manually brought up later. Partially fixes #23649.
* network: re-design request queueYu Watanabe2022-03-111-17/+18
| | | | | | | | This makes Request object takes hash, compare, free, and process functions. With this change, the logic in networkd-queue.c can be mostly independent of the type of the request or the object (e.g. Address) assigned to the request, and it becomes simpler.
* network: merge RequestType and SetLinkOperationYu Watanabe2022-03-111-88/+78
| | | | | These two enum indicate how we process the request. Hence, it is not necessary to introduce two separated indicators.
* network: refuse to configure link properties when in initialized stateYu Watanabe2022-03-111-2/+2
| | | | | | The condition should be satisfied only when users request to reconfigure the link, and in that case, all request will be cancelled. Hence, it is not necessary to process the request.
* network: drop unnecessary link_enter_failed()Yu Watanabe2022-03-111-24/+18
| | | | As returning negative errno makes the link will enter the failed state.
* network: introduce request_call_netlink_async()Yu Watanabe2022-03-111-123/+59
| | | | | | | | | | | | | | | | | | | | | In most netlink handlers, we do the following, 1. decrease the message counter, 2. check the link state, 3. error handling, 4. update link state via e.g. link_check_ready(). The first two steps are mostly common, hence let's extract it. Moreover, this is not only extracting the common logic, but provide a strong advantage; `request_call_netlink_async()` assigns the relevant Request object to the userdata of the netlink slot, and the request object has full information about the message we sent. Hence, in the future, netlink handler can print more detailed error message. E.g. when an address is failed to configure, then currently we only show an address is failed to configure, but with this commit, potentially we can show which address is failed explicitly. This does not change such error handling yet. But let's do that later.
* network: make request_process_address() and friends take Link and ↵Yu Watanabe2022-03-111-16/+6
| | | | | | | | | | | | | | | | | corresponding object This also renames e.g. request_process_address() -> address_process_request(). Also, this drops type checks such as `assert(req->type == REQUEST_TYPE_ADDRESS)`, as in the later commits, the function of processing request, e.g. `address_process_request()`, will be assigned to the Request object when it is created. And the request type will be used to distinguish and to avoid deduplicating requests which do not have any assigned objects, like REQUEST_TYPE_DHCP4_CLIENT. Hence, the type checks in process functions are mostly not necessary and redundant. This is mostly cleanups and preparation for later commits, and should not change any behavior.
* network: make address_configure() and friends take Request objectYu Watanabe2022-03-111-9/+8
| | | | | | This should not change any behavior. Just a preparation for a later commit which introduces request_call_netlink_async().
* network: drop detailed log messagesYu Watanabe2022-02-251-7/+7
| | | | | | | This also renames netlink message `req` -> `m` for preparation of later commits. Follow-ups for #22014.
* network: make link_down() independent of link_up_or_down()Yu Watanabe2022-02-251-16/+57
| | | | | And rename it to link_down_now() to emphasize it does not use request queue.
* Merge pull request #22452 from yuwata/network-ipv6llYu Watanabe2022-02-101-26/+19
|\ | | | | network: use sysctl to set IPv6LL address generation mode when the interface is already up
| * network: attempt to trigger kernel IPv6LL address generationJoerie de Gram2022-02-101-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Try to ensure kernel IPv6 link local address generation occurs by setting the per-if addr_gen_mode sysctl when the link is already up, instead of the netlink interface (IFLA_INET6_ADDR_GEN_MODE). The netlink setting is sufficient in cases where the interface is not yet up when networkd configures an interface - bringing the interface up will trigger in-kernel address generation. If the interface is already up, yet the interface has no IPv6LL assigned setting IFLA_INET6_ADDR_GEN_MODE has no effect. Writing the addr_gen_mode sysctl is a best effort attempt at triggering address generation regardless of interface state because it also works in cases where the interface is already up. Fixes #22424.
| * network: skip to set IPv6LL address generation mode if the requested mode is ↵Yu Watanabe2022-02-101-0/+3
| | | | | | | | already set
| * network: introduce two helper functions for setting IPv6LL address ↵Yu Watanabe2022-02-101-26/+3
| | | | | | | | generation mode
* | Add support for `isolated` parameterSanta Wiryaman2022-02-091-0/+6
|/ | | | | | | | | | | | | | | | | | Add the "Isolated" parameter in the *.network file, e.g., [Bridge] Isolated=true|false When the Isolated parameter is true, traffic coming out of this port will only be forward to other ports whose Isolated parameter is false. When Isolated is not specified, the port uses the kernel default setting (false). The "Isolated" parameter was introduced in Linux 4.19. See man bridge(8) for more details. But even though the kernel and bridge/iproute2 recognize the "Isolated" parameter, systemd-networkd did not have a way to set it.
* network: split out link_configure_fill_message(), simplify loggingZbigniew Jędrzejewski-Szmek2022-01-051-70/+79
|
* network: move logging from can_set_netlink_message() to the callerZbigniew Jędrzejewski-Szmek2022-01-051-1/+1
|
* network: de-duplicate logging in bridge_vlan_append_info() and the callerZbigniew Jędrzejewski-Szmek2022-01-051-1/+1
| | | | | The remaining message is changed, because the user would most likely not understand that "append VLANs" is just talking about the netlink message.
* network: move logging from ipoib_set_netlink_message() to the callerZbigniew Jędrzejewski-Szmek2022-01-051-1/+1
|
* tree-wide: fix typoYu Watanabe2021-12-251-1/+1
|
* network: wait until the DSA master interface becomes upYu Watanabe2021-12-161-3/+52
| | | | | | | | | | | | This is for the DSA subsystem, which have several stacked interfaces on the master interface. To bring up a stacked interface, it is necessary that the master is already up. See https://github.com/systemd/systemd/issues/7478#issuecomment-348508263. Note this is not necessary for newer kernels which includes https://github.com/torvalds/linux/commit/9d5ef190e5615a7b63af89f88c4106a5bc127974. Fixes #7478.
* network: make activation error criticalYu Watanabe2021-12-111-10/+17
|
* network: introduce link_remove()Yu Watanabe2021-12-071-0/+40
|
* network: set MAC address before enslaving to bond or bridge interfaceYu Watanabe2021-12-071-0/+9
| | | | As the master interface may inherit the slave MAC address.
* network,udev: do not adjust local assignment bit of specified MAC addressYu Watanabe2021-12-071-1/+1
| | | | | | | People often assigns the MAC address of the enslaved interface to e.g. bridge interface. So, the local assignment bit should not be adjusted. Fixes #21649.
* network: set MTU after IPoIB configs are appliedYu Watanabe2021-12-041-2/+12
| | | | MTU is updated when IB mode is changed.
* network: add support to configure IPoIB interfacesYu Watanabe2021-12-041-1/+25
|
* network: update commentYu Watanabe2021-11-261-2/+2
| | | | Addresses https://github.com/systemd/systemd/pull/21517#discussion_r757096584.
* network: make MACAddress= takes hardware address with its length is ↵Yu Watanabe2021-11-251-11/+13
| | | | | | | INFINIBAND_ALEN Also, the multicast and local bits in the specified MAC address for ethernet are adjusted.
* network: change link group type to int32Slava Bacherikov2021-11-151-2/+2
| | | | | | Both linux kernel kernel and iproute2 uses int32 type for a link group attribute and -1 has a special meaning, so setting it to 4294967295 would make it -1 in the linux kernel (and ip link cmd).
* network/bridge: drop if_bridge.h from bridge.hYu Watanabe2021-11-091-0/+1
| | | | To avoid future header conflicts.
* network: use NetworkConfigSource/State to manage addresses and routesYu Watanabe2021-09-241-0/+1
| | | | This also fixes #20146.
* network: introduce KeepMaster= settingYu Watanabe2021-09-031-6/+48
| | | | Closes #20624.
* network: use master ifindex to check if the interface is enslavedYu Watanabe2021-09-031-1/+1
|
* network: fix configuring of CAN devicesYu Watanabe2021-08-121-1/+5
| | | | | | Fix a bug introduced by 7558f9e717381eef0ddc8ddfb5a754ea4b0f3e6c. Fixes #20428.
* network: ignore errors on unsetting master ifindexYu Watanabe2021-08-041-2/+18
| | | | Fixes #20241.
* network: ignore errors on setting bridge configYu Watanabe2021-08-041-1/+1
| | | | | | | For some setups, kernel refuses to set bridge configs with -EOPNOTSUPP. See kernel's rtnl_bridge_setlink() in net/core/rtnetlink.c. Fixes #20373.
* network: add commentsYu Watanabe2021-08-041-10/+10
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-2/+2
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* network: use void* to correctly store SetLinkOperation in RequestYu Watanabe2021-06-151-6/+10
| | | | | | | | | | Previously, when `link_request_queue()` is called in link_request_set_link(), `SetLinkOperation` is casted with INT_TO_PTR(), and the value is assigned to `void *object`. However the value was read directly through the member `SetLinkOperation set_link_operation` of the union which `object` beloging to. Thus, read value was always 0 on big-endian systems. Fixes configuring link issue on s390x systems.
* tree-wide: add missing whitespace at the end of commentsYu Watanabe2021-06-151-1/+1
|
* Merge pull request #19913 from yuwata/network-fix-counterYu Watanabe2021-06-151-1/+10
|\ | | | | network: add missing increment of Link::set_flags_messages
| * network: add missing increment of Link::set_flags_messagesYu Watanabe2021-06-141-1/+10
| | | | | | | | | | | | | | | | | | link_up_or_down() will decrement the counter when the subsequent RTM_GETLINK netlink method is finished. So, we need to increment the counter here. Fixes the issue mentioned at https://github.com/systemd/systemd/issues/19832#issuecomment-860255692.
* | network: try to bring down before setting MAC addressYu Watanabe2021-06-141-2/+48
| | | | | | | | | | | | | | | | Most real network devices refuse to set MAC address when its operstate is not down. So, setting MAC address once failed, then let's bring down the interface and retry to set. Closes #6696.
* | network: check the size of hardware address before setting MAC addressYu Watanabe2021-06-141-0/+10
|/ | | | | Also, skip to set MAC address when the current address equals to the requrested one.
* networkd: drop one workaround initializationZbigniew Jędrzejewski-Szmek2021-06-091-1/+1
| | | | | | | As for the other ones in src/network/, if they are removed, gcc warns when they are removed. Should fix Coverity CID#1457466.