1
0
mirror of https://github.com/systemd/systemd synced 2026-04-09 00:24:49 +02:00

Compare commits

..

No commits in common. "788e720181aead8c85ba30fc7ec9a1455a865cbe" and "f5caacec1c5b5701ba1d17f75983bf27aad54d7e" have entirely different histories.

31 changed files with 101 additions and 197 deletions

View File

@ -60,7 +60,7 @@ Interface](https://systemd.io/BOOT_LOADER_INTERFACE).
| _Root Partition (TILE-Gx)_ | `c50cdd70-3862-4cc3-90e1-809a8c93ee2c` | ditto | ditto |
| _Root Partition (x86)_ | `44479540-f297-41b2-9af7-d131d5f0458a` | ditto | ditto |
| _Root Partition (amd64/x86_64)_ | `4f68bce3-e8cd-4db1-96e7-fbcaf984b709` | ditto | ditto |
| _`/usr/` Partition (Alpha)_ | `e18cf08c-33ec-4c0d-8246-c6c6fb3da024` | Any native, optionally in LUKS | Similar semantics to root partition, but just the `/usr/` partition. |
| _`/usr/` Partition (Alpha)_ | `e18cf08c-33ec-4c0d-8246-c6c6fb3da024` | A dm-verity superblock followed by hash data | Contains dm-verity integrity hash data for the matching root partition. If this feature is used the partition UUID of the root partition should be the first 128 bits of the root hash of the dm-verity hash data, and the partition UUID of this dm-verity partition should be the final 128 bits of it, so that the root partition and its Verity partition can be discovered easily, simply by specifying the root hash. |
| _`/usr/` Partition (ARC)_ | `7978a683-6316-4922-bbee-38bff5a2fecc` | ditto | ditto |
| _`/usr/` Partition (32-bit ARM)_ | `7d0359a3-02b3-4f0a-865c-654403e70625` | ditto | ditto |
| _`/usr/` Partition (64-bit ARM/AArch64)_ | `b0e01050-ee5f-4390-949a-9101b17104e9` | ditto | ditto |
@ -78,7 +78,7 @@ Interface](https://systemd.io/BOOT_LOADER_INTERFACE).
| _`/usr/` Partition (TILE-Gx)_ | `55497029-c7c1-44cc-aa39-815ed1558630` | ditto | ditto |
| _`/usr/` Partition (x86)_ | `75250d76-8cc6-458e-bd66-bd47cc81a812` | ditto | ditto |
| _`/usr/` Partition (amd64/x86_64)_ | `8484680c-9521-48c6-9c11-b0720656f69e` | ditto | ditto |
| _Root Verity Partition (Alpha)_ | `fc56d9e9-e6e5-4c06-be32-e74407ce09a5` | A dm-verity superblock followed by hash data | Contains dm-verity integrity hash data for the matching root partition. If this feature is used the partition UUID of the root partition should be the first 128 bits of the root hash of the dm-verity hash data, and the partition UUID of this dm-verity partition should be the final 128 bits of it, so that the root partition and its Verity partition can be discovered easily, simply by specifying the root hash. |
| _Root Verity Partition (Alpha)_ | `fc56d9e9-e6e5-4c06-be32-e74407ce09a5` | A serialized JSON object, see below | Contains a root hash and a PKCS#7 signature for it, permitting signed dm-verity GPT images. |
| _Root Verity Partition (ARC)_ | `24b2d975-0f97-4521-afa1-cd531e421b8d` | ditto | ditto |
| _Root Verity Partition (32-bit ARM)_ | `7386cdf2-203c-47a9-a498-f2ecce45a2d6` | ditto | ditto |
| _Root Verity Partition (64-bit ARM/AArch64)_ | `df3300ce-d69f-4c92-978c-9bfb0f38d820` | ditto | ditto |
@ -96,7 +96,7 @@ Interface](https://systemd.io/BOOT_LOADER_INTERFACE).
| _Root Verity Partition (TILE-Gx)_ | `966061ec-28e4-4b2e-b4a5-1f0a825a1d84` | ditto | ditto |
| _Root Verity Partition (amd64/x86_64)_ | `2c7357ed-ebd2-46d9-aec1-23d437ec2bf5` | ditto | ditto |
| _Root Verity Partition (x86)_ | `d13c5d3b-b5d1-422a-b29f-9454fdc89d76` | ditto | ditto |
| _`/usr/` Verity Partition (Alpha)_ | `8cce0d25-c0d0-4a44-bd87-46331bf1df67` | A dm-verity superblock followed by hash data | Similar semantics to root Verity partition, but just for the `/usr/` partition. |
| _`/usr/` Verity Partition (Alpha)_ | `8cce0d25-c0d0-4a44-bd87-46331bf1df67` | Any native, optionally in LUKS | Similar semantics to root partition, but just the `/usr/` partition. |
| _`/usr/` Verity Partition (ARC)_ | `fca0598c-d880-4591-8c16-4eda05c7347c` | ditto | ditto |
| _`/usr/` Verity Partition (32-bit ARM)_ | `c215d751-7bcd-4649-be90-6627490a4c05` | ditto | ditto |
| _`/usr/` Verity Partition (64-bit ARM/AArch64)_ | `6e11a4e7-fbca-4ded-b9e9-e1a512bb664e` | ditto | ditto |
@ -114,7 +114,7 @@ Interface](https://systemd.io/BOOT_LOADER_INTERFACE).
| _`/usr/` Verity Partition (TILE-Gx)_ | `2fb4bf56-07fa-42da-8132-6b139f2026ae` | ditto | ditto |
| _`/usr/` Verity Partition (amd64/x86_64)_ | `77ff5f63-e7b6-4633-acf4-1565b864c0e6` | ditto | ditto |
| _`/usr/` Verity Partition (x86)_ | `8f461b0d-14ee-4e81-9aa9-049b6fb97abd` | ditto | ditto |
| _Root Verity Signature Partition (Alpha)_ | `d46495b7-a053-414f-80f7-700c99921ef8` | A serialized JSON object, see below | Contains a root hash and a PKCS#7 signature for it, permitting signed dm-verity GPT images. |
| _Root Verity Signature Partition (Alpha)_ | `d46495b7-a053-414f-80f7-700c99921ef8` | A dm-verity superblock followed by hash data | Similar semantics to root Verity partition, but just for the `/usr/` partition. |
| _Root Verity Signature Partition (ARC)_ | `143a70ba-cbd3-4f06-919f-6c05683a78bc` | ditto | ditto |
| _Root Verity Signature Partition (32-bit ARM)_ | `42b0455f-eb11-491d-98d3-56145ba9d037` | ditto | ditto |
| _Root Verity Signature Partition (64-bit ARM/AArch64)_ | `6db69de6-29f4-4758-a7a5-962190f00ce3` | ditto | ditto |

View File

@ -101,7 +101,7 @@ static const MountEntry apivfs_table[] = {
};
/* ProtectKernelTunables= option and the related filesystem APIs */
static const MountEntry protect_kernel_tunables_proc_table[] = {
static const MountEntry protect_kernel_tunables_table[] = {
{ "/proc/acpi", READONLY, true },
{ "/proc/apm", READONLY, true }, /* Obsolete API, there's no point in permitting access to this, ever */
{ "/proc/asound", READONLY, true },
@ -116,9 +116,6 @@ static const MountEntry protect_kernel_tunables_proc_table[] = {
{ "/proc/sys", READONLY, true },
{ "/proc/sysrq-trigger", READONLY, true },
{ "/proc/timer_stats", READONLY, true },
};
static const MountEntry protect_kernel_tunables_sys_table[] = {
{ "/sys", READONLY, false },
{ "/sys/fs/bpf", READONLY, true },
{ "/sys/fs/cgroup", READWRITE_IMPLICIT, false }, /* READONLY is set by ProtectControlGroups= option */
@ -136,11 +133,8 @@ static const MountEntry protect_kernel_modules_table[] = {
};
/* ProtectKernelLogs= option */
static const MountEntry protect_kernel_logs_proc_table[] = {
static const MountEntry protect_kernel_logs_table[] = {
{ "/proc/kmsg", INACCESSIBLE, true },
};
static const MountEntry protect_kernel_logs_dev_table[] = {
{ "/dev/kmsg", INACCESSIBLE, true },
};
@ -1560,11 +1554,9 @@ static size_t namespace_calculate_mounts(
(n_extension_images > 0 ? n_hierarchies + n_extension_images : 0) + /* Mount each image plus an overlay per hierarchy */
n_temporary_filesystems +
ns_info->private_dev +
(ns_info->protect_kernel_tunables ?
ELEMENTSOF(protect_kernel_tunables_proc_table) + ELEMENTSOF(protect_kernel_tunables_sys_table) : 0) +
(ns_info->protect_kernel_tunables ? ELEMENTSOF(protect_kernel_tunables_table) : 0) +
(ns_info->protect_kernel_modules ? ELEMENTSOF(protect_kernel_modules_table) : 0) +
(ns_info->protect_kernel_logs ?
ELEMENTSOF(protect_kernel_logs_proc_table) + ELEMENTSOF(protect_kernel_logs_dev_table) : 0) +
(ns_info->protect_kernel_logs ? ELEMENTSOF(protect_kernel_logs_table) : 0) +
(ns_info->protect_control_groups ? 1 : 0) +
protect_home_cnt + protect_system_cnt +
(ns_info->protect_hostname ? 2 : 0) +
@ -2087,21 +2079,10 @@ int setup_namespace(
.flags = DEV_MOUNT_OPTIONS,
};
/* In case /proc is successfully mounted with pid tree subset only (ProcSubset=pid), the
protective mounts to non-pid /proc paths would fail. But the pid only option may have
failed gracefully, so let's try the mounts but it's not fatal if they don't succeed. */
bool ignore_protect_proc = ns_info->ignore_protect_paths || ns_info->proc_subset == PROC_SUBSET_PID;
if (ns_info->protect_kernel_tunables) {
r = append_static_mounts(&m,
protect_kernel_tunables_proc_table,
ELEMENTSOF(protect_kernel_tunables_proc_table),
ignore_protect_proc);
if (r < 0)
goto finish;
r = append_static_mounts(&m,
protect_kernel_tunables_sys_table,
ELEMENTSOF(protect_kernel_tunables_sys_table),
protect_kernel_tunables_table,
ELEMENTSOF(protect_kernel_tunables_table),
ns_info->ignore_protect_paths);
if (r < 0)
goto finish;
@ -2118,15 +2099,8 @@ int setup_namespace(
if (ns_info->protect_kernel_logs) {
r = append_static_mounts(&m,
protect_kernel_logs_proc_table,
ELEMENTSOF(protect_kernel_logs_proc_table),
ignore_protect_proc);
if (r < 0)
goto finish;
r = append_static_mounts(&m,
protect_kernel_logs_dev_table,
ELEMENTSOF(protect_kernel_logs_dev_table),
protect_kernel_logs_table,
ELEMENTSOF(protect_kernel_logs_table),
ns_info->ignore_protect_paths);
if (r < 0)
goto finish;

View File

@ -1,9 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright © 2020 VMware, Inc. */
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "bareudp.h"
#include "netlink-util.h"
#include "networkd-manager.h"
@ -82,5 +79,4 @@ const NetDevVTable bare_udp_vtable = {
.config_verify = netdev_bare_udp_verify,
.fill_message_create = netdev_bare_udp_fill_message_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_NONE,
};

View File

@ -1,9 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <inttypes.h>
#include <netinet/in.h>
#include <linux/genetlink.h>
#include <linux/if_arp.h>
#include "batadv.h"
#include "fileio.h"
@ -202,5 +200,4 @@ const NetDevVTable batadv_vtable = {
.fill_message_create = netdev_batadv_fill_message_create,
.post_create = netdev_batadv_post_create,
.create_type = NETDEV_CREATE_MASTER,
.iftype = ARPHRD_ETHER,
};

View File

@ -1,8 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "alloc-util.h"
#include "bond.h"
#include "bond-util.h"
@ -452,6 +449,5 @@ const NetDevVTable bond_vtable = {
.sections = NETDEV_COMMON_SECTIONS "Bond\0",
.fill_message_create = netdev_bond_fill_message_create,
.create_type = NETDEV_CREATE_MASTER,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -2,7 +2,6 @@
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include <linux/if_bridge.h>
#include "bridge.h"
@ -277,5 +276,4 @@ const NetDevVTable bridge_vtable = {
.sections = NETDEV_COMMON_SECTIONS "Bridge\0",
.post_create = netdev_bridge_post_create,
.create_type = NETDEV_CREATE_MASTER,
.iftype = ARPHRD_ETHER,
};

View File

@ -1,13 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "dummy.h"
const NetDevVTable dummy_vtable = {
.object_size = sizeof(Dummy),
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,8 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "alloc-util.h"
#include "conf-parser.h"
@ -294,6 +292,5 @@ const NetDevVTable geneve_vtable = {
.fill_message_create = netdev_geneve_fill_message_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_geneve_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,14 +1,11 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright © 2019 VMware, Inc. */
#include <linux/if_arp.h>
#include "ifb.h"
const NetDevVTable ifb_vtable = {
.object_size = sizeof(IntermediateFunctionalBlock),
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,8 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "conf-parser.h"
#include "ipvlan.h"
@ -65,7 +63,6 @@ const NetDevVTable ipvlan_vtable = {
.sections = NETDEV_COMMON_SECTIONS "IPVLAN\0",
.fill_message_create = netdev_ipvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@ -75,7 +72,6 @@ const NetDevVTable ipvtap_vtable = {
.sections = NETDEV_COMMON_SECTIONS "IPVTAP\0",
.fill_message_create = netdev_ipvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <netinet/in.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/if_macsec.h>
#include <linux/genetlink.h>
@ -1231,6 +1230,5 @@ const NetDevVTable macsec_vtable = {
.done = macsec_done,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_macsec_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,8 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "conf-parser.h"
#include "macvlan.h"
@ -155,7 +153,6 @@ const NetDevVTable macvtap_vtable = {
.sections = NETDEV_COMMON_SECTIONS "MACVTAP\0",
.fill_message_create = netdev_macvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@ -166,6 +163,5 @@ const NetDevVTable macvlan_vtable = {
.sections = NETDEV_COMMON_SECTIONS "MACVLAN\0",
.fill_message_create = netdev_macvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -49,7 +49,7 @@ NetDev.Description, config_parse_string,
NetDev.Name, config_parse_ifname, 0, offsetof(NetDev, ifname)
NetDev.Kind, config_parse_netdev_kind, 0, offsetof(NetDev, kind)
NetDev.MTUBytes, config_parse_mtu, AF_UNSPEC, offsetof(NetDev, mtu)
NetDev.MACAddress, config_parse_hw_addr, ETH_ALEN, offsetof(NetDev, hw_addr)
NetDev.MACAddress, config_parse_ether_addr, 0, offsetof(NetDev, mac)
VLAN.Id, config_parse_vlanid, 0, offsetof(VLan, id)
VLAN.Protocol, config_parse_vlanprotocol, 0, offsetof(VLan, protocol)
VLAN.GVRP, config_parse_tristate, 0, offsetof(VLan, gvrp)
@ -111,7 +111,7 @@ L2TPSession.PeerSessionId, config_parse_l2tp_session_id,
L2TPSession.Layer2SpecificHeader, config_parse_l2tp_session_l2spec, 0, 0
L2TPSession.Name, config_parse_l2tp_session_name, 0, 0
Peer.Name, config_parse_ifname, 0, offsetof(Veth, ifname_peer)
Peer.MACAddress, config_parse_hw_addr, ETH_ALEN, offsetof(Veth, hw_addr_peer)
Peer.MACAddress, config_parse_ether_addr, 0, offsetof(Veth, mac_peer)
VXCAN.Peer, config_parse_ifname, 0, offsetof(VxCan, ifname_peer)
VXLAN.VNI, config_parse_uint32, 0, offsetof(VxLan, vni)
VXLAN.Id, config_parse_uint32, 0, offsetof(VxLan, vni) /* deprecated */

View File

@ -2,11 +2,9 @@
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include <unistd.h>
#include "alloc-util.h"
#include "arphrd-util.h"
#include "bareudp.h"
#include "batadv.h"
#include "bond.h"
@ -25,7 +23,6 @@
#include "macvlan.h"
#include "netdev.h"
#include "netdevsim.h"
#include "netif-util.h"
#include "netlink-util.h"
#include "networkd-manager.h"
#include "networkd-queue.h"
@ -232,6 +229,7 @@ static NetDev *netdev_free(NetDev *netdev) {
free(netdev->description);
free(netdev->ifname);
free(netdev->mac);
condition_free_list(netdev->conditions);
/* Invoke the per-kind done() destructor, but only if the state field is initialized. We conditionalize that
@ -426,52 +424,46 @@ int netdev_set_ifindex(NetDev *netdev, sd_netlink_message *message) {
#define HASH_KEY SD_ID128_MAKE(52,e1,45,bd,00,6f,29,96,21,c6,30,6d,83,71,04,48)
int netdev_generate_hw_addr(NetDev *netdev, const char *name, struct hw_addr_data *hw_addr) {
bool warn_invalid = false;
struct hw_addr_data a;
int netdev_get_mac(const char *ifname, struct ether_addr **ret) {
_cleanup_free_ struct ether_addr *mac = NULL;
uint64_t result;
size_t l, sz;
uint8_t *v;
int r;
assert(netdev);
assert(name);
assert(hw_addr);
assert(ifname);
assert(ret);
if (hw_addr->length == 0) {
uint64_t result;
mac = new0(struct ether_addr, 1);
if (!mac)
return -ENOMEM;
/* HardwareAddress= is not specified. */
l = strlen(ifname);
sz = sizeof(sd_id128_t) + l;
v = newa(uint8_t, sz);
if (!NETDEV_VTABLE(netdev)->generate_mac)
return 0;
if (NETDEV_VTABLE(netdev)->iftype != ARPHRD_ETHER)
return 0;
r = net_get_unique_predictable_data_from_name(name, &HASH_KEY, &result);
if (r < 0) {
log_netdev_warning_errno(netdev, r,
"Failed to generate persistent MAC address, ignoring: %m");
return 0;
}
a.length = arphrd_to_hw_addr_len(NETDEV_VTABLE(netdev)->iftype);
assert(a.length <= sizeof(result));
memcpy(a.bytes, &result, a.length);
if (ether_addr_is_null(&a.ether) || ether_addr_is_broadcast(&a.ether)) {
log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
"Failed to generate persistent MAC address, ignoring: %m");
return 0;
}
} else {
a = *hw_addr;
warn_invalid = true;
}
r = net_verify_hardware_address(name, warn_invalid, NETDEV_VTABLE(netdev)->iftype, NULL, &a);
/* fetch some persistent data unique to the machine */
r = sd_id128_get_machine((sd_id128_t*) v);
if (r < 0)
return r;
*hw_addr = a;
/* combine with some data unique (on this machine) to this
* netdev */
memcpy(v + sizeof(sd_id128_t), ifname, l);
/* Let's hash the host machine ID plus the container name. We
* use a fixed, but originally randomly created hash key here. */
result = siphash24(v, sz, HASH_KEY.bytes);
assert_cc(ETH_ALEN <= sizeof(result));
memcpy(mac->ether_addr_octet, &result, ETH_ALEN);
/* see eth_random_addr in the kernel */
mac->ether_addr_octet[0] &= 0xfe; /* clear multicast bit */
mac->ether_addr_octet[0] |= 0x02; /* set local assignment bit (IEEE802) */
*ret = TAKE_PTR(mac);
return 0;
}
@ -502,8 +494,8 @@ static int netdev_create(NetDev *netdev, Link *link, link_netlink_message_handle
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_IFNAME, attribute: %m");
if (netdev->hw_addr.length > 0) {
r = netlink_message_append_hw_addr(m, IFLA_ADDRESS, &netdev->hw_addr);
if (netdev->mac) {
r = sd_netlink_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_ADDRESS attribute: %m");
}
@ -821,9 +813,12 @@ int netdev_load_one(Manager *manager, const char *filename) {
if (!netdev->filename)
return log_oom();
r = netdev_generate_hw_addr(netdev, netdev->ifname, &netdev->hw_addr);
if (!netdev->mac && NETDEV_VTABLE(netdev)->generate_mac) {
r = netdev_get_mac(netdev->ifname, &netdev->mac);
if (r < 0)
return r;
return log_netdev_error_errno(netdev, r,
"Failed to generate predictable MAC address: %m");
}
r = hashmap_ensure_put(&netdev->manager->netdevs, &string_hash_ops, netdev->ifname, netdev);
if (r == -ENOMEM)

View File

@ -4,7 +4,6 @@
#include "sd-netlink.h"
#include "conf-parser.h"
#include "ether-addr-util.h"
#include "list.h"
#include "log-link.h"
#include "networkd-link.h"
@ -119,7 +118,7 @@ typedef struct NetDev {
NetDevKind kind;
char *description;
char *ifname;
struct hw_addr_data hw_addr;
struct ether_addr *mac;
uint32_t mtu;
int ifindex;
} NetDev;
@ -160,9 +159,6 @@ typedef struct NetDevVTable {
/* verify that compulsory configuration options were specified */
int (*config_verify)(NetDev *netdev, const char *filename);
/* expected iftype, e.g. ARPHRD_ETHER. */
uint16_t iftype;
/* Generate MAC address when MACAddress= is not specified. */
bool generate_mac;
} NetDevVTable;
@ -198,7 +194,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(NetDev*, netdev_unref);
bool netdev_is_managed(NetDev *netdev);
int netdev_get(Manager *manager, const char *name, NetDev **ret);
int netdev_set_ifindex(NetDev *netdev, sd_netlink_message *newlink);
int netdev_generate_hw_addr(NetDev *netdev, const char *name, struct hw_addr_data *hw_addr);
int netdev_get_mac(const char *ifname, struct ether_addr **ret);
int netdev_join(NetDev *netdev, Link *link, link_netlink_message_handler_t cb);
int request_process_stacked_netdev(Request *req);

View File

@ -1,13 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "netdevsim.h"
const NetDevVTable netdevsim_vtable = {
.object_size = sizeof(NetDevSim),
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,16 +1,14 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "nlmon.h"
static int netdev_nlmon_verify(NetDev *netdev, const char *filename) {
assert(netdev);
assert(filename);
if (netdev->hw_addr.length > 0) {
if (netdev->mac) {
log_netdev_warning(netdev, "%s: MACAddress= is not supported. Ignoring", filename);
netdev->hw_addr = HW_ADDR_NULL;
netdev->mac = mfree(netdev->mac);
}
return 0;
@ -21,5 +19,4 @@ const NetDevVTable nlmon_vtable = {
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_nlmon_verify,
.iftype = ARPHRD_NETLINK,
};

View File

@ -2,9 +2,8 @@
#include <netinet/in.h>
#include <linux/fou.h>
#include <linux/if_arp.h>
#include <linux/if_tunnel.h>
#include <linux/ip.h>
#include <linux/if_tunnel.h>
#include <linux/ip6_tunnel.h>
#include "conf-parser.h"
@ -818,7 +817,7 @@ const NetDevVTable ipip_vtable = {
.fill_message_create = netdev_ipip_sit_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_TUNNEL,
.generate_mac = true,
};
const NetDevVTable sit_vtable = {
@ -828,7 +827,7 @@ const NetDevVTable sit_vtable = {
.fill_message_create = netdev_ipip_sit_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_SIT,
.generate_mac = true,
};
const NetDevVTable vti_vtable = {
@ -838,7 +837,7 @@ const NetDevVTable vti_vtable = {
.fill_message_create = netdev_vti_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_TUNNEL,
.generate_mac = true,
};
const NetDevVTable vti6_vtable = {
@ -848,7 +847,7 @@ const NetDevVTable vti6_vtable = {
.fill_message_create = netdev_vti_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_TUNNEL6,
.generate_mac = true,
};
const NetDevVTable gre_vtable = {
@ -858,7 +857,7 @@ const NetDevVTable gre_vtable = {
.fill_message_create = netdev_gre_erspan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_IPGRE,
.generate_mac = true,
};
const NetDevVTable gretap_vtable = {
@ -868,7 +867,6 @@ const NetDevVTable gretap_vtable = {
.fill_message_create = netdev_gre_erspan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@ -879,7 +877,7 @@ const NetDevVTable ip6gre_vtable = {
.fill_message_create = netdev_ip6gre_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_IP6GRE,
.generate_mac = true,
};
const NetDevVTable ip6gretap_vtable = {
@ -889,7 +887,6 @@ const NetDevVTable ip6gretap_vtable = {
.fill_message_create = netdev_ip6gre_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@ -900,7 +897,7 @@ const NetDevVTable ip6tnl_vtable = {
.fill_message_create = netdev_ip6tnl_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_TUNNEL6,
.generate_mac = true,
};
const NetDevVTable erspan_vtable = {
@ -910,6 +907,5 @@ const NetDevVTable erspan_vtable = {
.fill_message_create = netdev_gre_erspan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -136,7 +136,7 @@ static int tuntap_verify(NetDev *netdev, const char *filename) {
"Please set it in the corresponding .network file.",
netdev_kind_to_string(netdev->kind), filename);
if (netdev->hw_addr.length > 0)
if (netdev->mac)
log_netdev_warning(netdev,
"MACAddress= configured for %s device in %s will be ignored.\n"
"Please set it in the corresponding .network file.",
@ -152,7 +152,6 @@ const NetDevVTable tun_vtable = {
.done = tuntap_done,
.create = netdev_create_tuntap,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_NONE,
};
const NetDevVTable tap_vtable = {
@ -162,5 +161,4 @@ const NetDevVTable tap_vtable = {
.done = tuntap_done,
.create = netdev_create_tuntap,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_ETHER,
};

View File

@ -1,12 +1,10 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "vcan.h"
const NetDevVTable vcan_vtable = {
.object_size = sizeof(VCan),
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_CAN,
.generate_mac = true,
};

View File

@ -2,11 +2,8 @@
#include <errno.h>
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include <linux/veth.h>
#include "netlink-util.h"
#include "veth.h"
static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
@ -31,8 +28,8 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_netlin
return log_netdev_error_errno(netdev, r, "Failed to add netlink interface name: %m");
}
if (v->hw_addr_peer.length > 0) {
r = netlink_message_append_hw_addr(m, IFLA_ADDRESS, &v->hw_addr_peer);
if (v->mac_peer) {
r = sd_netlink_message_append_ether_addr(m, IFLA_ADDRESS, v->mac_peer);
if (r < 0)
return log_netdev_error_errno(netdev, r, "Could not append IFLA_ADDRESS attribute: %m");
}
@ -61,14 +58,21 @@ static int netdev_veth_verify(NetDev *netdev, const char *filename) {
assert(v);
if (!v->ifname_peer)
return log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
"Veth NetDev without peer name configured in %s. Ignoring",
if (!v->ifname_peer) {
log_netdev_warning(netdev, "Veth NetDev without peer name configured in %s. Ignoring",
filename);
return -EINVAL;
}
r = netdev_generate_hw_addr(netdev, v->ifname_peer, &v->hw_addr_peer);
if (r < 0)
return r;
if (!v->mac_peer) {
r = netdev_get_mac(v->ifname_peer, &v->mac_peer);
if (r < 0) {
log_netdev_warning(netdev,
"Failed to generate predictable MAC address for %s. Ignoring",
v->ifname_peer);
return -EINVAL;
}
}
return 0;
}
@ -83,6 +87,7 @@ static void veth_done(NetDev *n) {
assert(v);
free(v->ifname_peer);
free(v->mac_peer);
}
const NetDevVTable veth_vtable = {
@ -92,6 +97,5 @@ const NetDevVTable veth_vtable = {
.fill_message_create = netdev_veth_fill_message_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_veth_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -9,7 +9,7 @@ struct Veth {
NetDev meta;
char *ifname_peer;
struct hw_addr_data hw_addr_peer;
struct ether_addr *mac_peer;
};
DEFINE_NETDEV_CAST(VETH, Veth);

View File

@ -2,7 +2,6 @@
#include <errno.h>
#include <net/if.h>
#include <linux/if_arp.h>
#include <linux/if_vlan.h>
#include "parse-util.h"
@ -230,5 +229,4 @@ const NetDevVTable vlan_vtable = {
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_vlan_verify,
.done = vlan_done,
.iftype = ARPHRD_ETHER,
};

View File

@ -1,8 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "vrf.h"
@ -30,6 +28,5 @@ const NetDevVTable vrf_vtable = {
.sections = NETDEV_COMMON_SECTIONS "VRF\0",
.fill_message_create = netdev_vrf_fill_message_create,
.create_type = NETDEV_CREATE_MASTER,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/can/vxcan.h>
#include <linux/if_arp.h>
#include "vxcan.h"
@ -71,5 +70,5 @@ const NetDevVTable vxcan_vtable = {
.fill_message_create = netdev_vxcan_fill_message_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_vxcan_verify,
.iftype = ARPHRD_CAN,
.generate_mac = true,
};

View File

@ -1,8 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "conf-parser.h"
#include "alloc-util.h"
@ -396,6 +394,5 @@ const NetDevVTable vxlan_vtable = {
.fill_message_create = netdev_vxlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_vxlan_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -5,8 +5,6 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "sd-resolve.h"
@ -939,5 +937,5 @@ const NetDevVTable wireguard_vtable = {
.done = wireguard_done,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = wireguard_verify,
.iftype = ARPHRD_NONE,
.generate_mac = true,
};

View File

@ -1,7 +1,5 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "missing_network.h"
#include "xfrm.h"
@ -31,6 +29,5 @@ const NetDevVTable xfrm_vtable = {
.object_size = sizeof(Xfrm),
.sections = NETDEV_COMMON_SECTIONS "Xfrm\0",
.fill_message_create = xfrm_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_NONE,
.create_type = NETDEV_CREATE_STACKED
};

View File

@ -981,19 +981,15 @@ void link_foreignize_routes(Link *link) {
static int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
Route *route = userdata;
Link *link;
int r;
assert(route);
assert(route->manager || (route->link && route->link->manager));
link = route->link; /* This may be NULL. */
assert(route->link);
r = route_remove(route);
if (r < 0) {
log_link_warning_errno(link, r, "Could not remove route: %m");
if (link)
link_enter_failed(link);
log_link_warning_errno(route->link, r, "Could not remove route: %m");
link_enter_failed(route->link);
}
return 1;

View File

@ -1082,8 +1082,7 @@ class NetworkdNetDevTests(unittest.TestCase, Utilities):
output = check_output('ip link show dropin-test')
print(output)
# 00:50:56:c0:00:28 was requested, and the local bit is set by networkd.
self.assertRegex(output, '02:50:56:c0:00:28')
self.assertRegex(output, '00:50:56:c0:00:28')
def test_match_udev_property(self):
copy_unit_to_networkd_unit_path('12-dummy.netdev', '13-not-match-udev-property.network', '14-match-udev-property.network')

View File

@ -58,21 +58,21 @@ DESCRIPTIONS = {
'If the partition is encrypted with LUKS or has dm-verity integrity data (see below), the '
'device mapper file will be named `/dev/mapper/root`.'),
'USR': (
'Any native, optionally in LUKS',
'Similar semantics to root partition, but just the `/usr/` partition.'),
'ROOT_VERITY': (
'A dm-verity superblock followed by hash data',
'Contains dm-verity integrity hash data for the matching root partition. If this feature is '
'used the partition UUID of the root partition should be the first 128 bits of the root hash '
'of the dm-verity hash data, and the partition UUID of this dm-verity partition should be the '
'final 128 bits of it, so that the root partition and its Verity partition can be discovered '
'easily, simply by specifying the root hash.'),
'USR_VERITY': (
'A dm-verity superblock followed by hash data',
'Similar semantics to root Verity partition, but just for the `/usr/` partition.'),
'ROOT_VERITY_SIG': (
'ROOT_VERITY': (
'A serialized JSON object, see below',
'Contains a root hash and a PKCS#7 signature for it, permitting signed dm-verity GPT images.'),
'USR_VERITY': (
'Any native, optionally in LUKS',
'Similar semantics to root partition, but just the `/usr/` partition.'),
'ROOT_VERITY_SIG': (
'A dm-verity superblock followed by hash data',
'Similar semantics to root Verity partition, but just for the `/usr/` partition.'),
'USR_VERITY_SIG': (
'A serialized JSON object, see below',
'Similar semantics to root Verity signature partition, but just for the `/usr/` partition.'),