diff options
-rw-r--r-- | catalog/systemd.pl.catalog.in | 14 | ||||
-rw-r--r-- | docs/TRANSIENT-SETTINGS.md | 1 | ||||
-rw-r--r-- | hwdb/60-sensor.hwdb | 4 | ||||
-rw-r--r-- | rules/50-udev-default.rules.in | 2 | ||||
-rw-r--r-- | src/basic/linux/if_ether.h | 169 | ||||
-rw-r--r-- | src/basic/meson.build | 1 | ||||
-rw-r--r-- | src/basic/socket-util.c | 17 | ||||
-rw-r--r-- | src/core/cgroup.c | 5 | ||||
-rw-r--r-- | src/core/dbus-cgroup.c | 30 | ||||
-rw-r--r-- | src/shared/bootspec.c | 3 | ||||
-rw-r--r-- | src/shared/bootspec.h | 6 | ||||
-rw-r--r-- | src/shared/bus-unit-util.c | 4 | ||||
-rw-r--r-- | src/shared/efivars.h | 4 | ||||
-rw-r--r-- | src/test/test-socket-util.c | 62 | ||||
-rw-r--r-- | src/udev/net/naming-scheme.c | 1 | ||||
-rw-r--r-- | src/udev/net/naming-scheme.h | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-net_id.c | 50 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 2 |
18 files changed, 364 insertions, 13 deletions
diff --git a/catalog/systemd.pl.catalog.in b/catalog/systemd.pl.catalog.in index b6c6b54205..b007ad1f05 100644 --- a/catalog/systemd.pl.catalog.in +++ b/catalog/systemd.pl.catalog.in @@ -388,3 +388,17 @@ Możliwe są następujące „etykiety”: użytkowników (przy wykorzystaniu przestrzeni nazw użytkowników lub NFS) nie wynosi 65534. Obecny system ma etykietę „@TAINT@”. + +-- fe6faa94e7774663a0da52717891d8ef +Subject: Proces jednostki @UNIT@ został zakończony przez OOM Killer +Defined-By: systemd +Support: %SUPPORT_URL% + +Proces jednostki @UNIT został zakończony przez mechanizm kończenia +procesów przy braku pamięci (OOM) jądra Linux. Zwykle wskazuje to, +że system ma mało pamięci i należało ją zwolnić. Proces powiązany +z jednostką @UNIT@ został uznany za najlepszy do zakończenia +i jądro wymusiło zakończenie jego działania. + +Proszę zauważyć, że brak pamięci mógł nie zostać spowodowany +przez jednostkę @UNIT@. diff --git a/docs/TRANSIENT-SETTINGS.md b/docs/TRANSIENT-SETTINGS.md index 798793f3ee..3aa68c0a26 100644 --- a/docs/TRANSIENT-SETTINGS.md +++ b/docs/TRANSIENT-SETTINGS.md @@ -253,6 +253,7 @@ All cgroup/resource control settings are available for transient units ✓ TasksAccounting= ✓ TasksMax= ✓ Delegate= +✓ DisableControllers= ✓ IPAccounting= ✓ IPAddressAllow= ✓ IPAddressDeny= diff --git a/hwdb/60-sensor.hwdb b/hwdb/60-sensor.hwdb index 1a6f2d875b..11d5e8349d 100644 --- a/hwdb/60-sensor.hwdb +++ b/hwdb/60-sensor.hwdb @@ -367,6 +367,10 @@ sensor:modalias:acpi:KIOX000A*:dmi:*:svnLINX*:pnLINX12X64:* sensor:modalias:acpi:SMO8500*:dmi:*:svnMEDION:pnAkoyaE2212TMD99720:* ACCEL_MOUNT_MATRIX=-1, 0, 0; 0, 1, 0; 0, 0, 1 +# Medion Akoya E3216 MD60900 +sensor:modalias:acpi:KIOX010A*:dmi:*:svnMEDION*:pnE3216*:* + ACCEL_MOUNT_MATRIX=0, -1, 0; -1, 0, 0; 0, 0, 1 + ######################################### # MSI ######################################### diff --git a/rules/50-udev-default.rules.in b/rules/50-udev-default.rules.in index 191f56f42e..580b8971a6 100644 --- a/rules/50-udev-default.rules.in +++ b/rules/50-udev-default.rules.in @@ -81,6 +81,8 @@ KERNEL=="fuse", MODE="0666", OPTIONS+="static_node=fuse" # The static_node is required on s390x and ppc (they are using MODULE_ALIAS) KERNEL=="kvm", GROUP="kvm", MODE="@DEV_KVM_MODE@", OPTIONS+="static_node=kvm" +KERNEL=="udmabuf", GROUP="kvm" + SUBSYSTEM=="ptp", ATTR{clock_name}=="KVM virtual PTP", SYMLINK += "ptp_kvm" LABEL="default_end" diff --git a/src/basic/linux/if_ether.h b/src/basic/linux/if_ether.h new file mode 100644 index 0000000000..3a45b4ad71 --- /dev/null +++ b/src/basic/linux/if_ether.h @@ -0,0 +1,169 @@ +/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ +/* + * INET An implementation of the TCP/IP protocol suite for the LINUX + * operating system. INET is implemented using the BSD Socket + * interface as the means of communication with the user level. + * + * Global definitions for the Ethernet IEEE 802.3 interface. + * + * Version: @(#)if_ether.h 1.0.1a 02/08/94 + * + * Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG> + * Donald Becker, <becker@super.org> + * Alan Cox, <alan@lxorguk.ukuu.org.uk> + * Steve Whitehouse, <gw7rrm@eeshack3.swan.ac.uk> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ + +#ifndef _UAPI_LINUX_IF_ETHER_H +#define _UAPI_LINUX_IF_ETHER_H + +#include <linux/types.h> + +/* + * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble + * and FCS/CRC (frame check sequence). + */ + +#define ETH_ALEN 6 /* Octets in one ethernet addr */ +#define ETH_TLEN 2 /* Octets in ethernet type field */ +#define ETH_HLEN 14 /* Total octets in header. */ +#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ +#define ETH_DATA_LEN 1500 /* Max. octets in payload */ +#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ +#define ETH_FCS_LEN 4 /* Octets in the FCS */ + +#define ETH_MIN_MTU 68 /* Min IPv4 MTU per RFC791 */ +#define ETH_MAX_MTU 0xFFFFU /* 65535, same as IP_MAX_MTU */ + +/* + * These are the defined Ethernet Protocol ID's. + */ + +#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ +#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ +#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ +#define ETH_P_TSN 0x22F0 /* TSN (IEEE 1722) packet */ +#define ETH_P_ERSPAN2 0x22EB /* ERSPAN version 2 (type III) */ +#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +#define ETH_P_X25 0x0805 /* CCITT X.25 */ +#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ +#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP Addr Trans packet */ +#define ETH_P_BATMAN 0x4305 /* B.A.T.M.A.N.-Advanced packet [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ +#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ +#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ +#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ +#define ETH_P_LAT 0x6004 /* DEC LAT */ +#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ +#define ETH_P_CUST 0x6006 /* DEC Customer use */ +#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ +#define ETH_P_TEB 0x6558 /* Trans Ether Bridging */ +#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ +#define ETH_P_ATALK 0x809B /* Appletalk DDP */ +#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ +#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ +#define ETH_P_ERSPAN 0x88BE /* ERSPAN type II */ +#define ETH_P_IPX 0x8137 /* IPX over DIX */ +#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ +#define ETH_P_PAUSE 0x8808 /* IEEE Pause frames. See 802.3 31B */ +#define ETH_P_SLOW 0x8809 /* Slow Protocol. See 802.3ad 43B */ +#define ETH_P_WCCP 0x883E /* Web-cache coordination protocol + * defined in draft-wilson-wrec-wccp-v2-00.txt */ +#define ETH_P_MPLS_UC 0x8847 /* MPLS Unicast traffic */ +#define ETH_P_MPLS_MC 0x8848 /* MPLS Multicast traffic */ +#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ +#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ +#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ +#define ETH_P_LINK_CTL 0x886c /* HPNA, wlan link local tunnel */ +#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport + * over Ethernet + */ +#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ +#define ETH_P_AOE 0x88A2 /* ATA over Ethernet */ +#define ETH_P_8021AD 0x88A8 /* 802.1ad Service VLAN */ +#define ETH_P_802_EX1 0x88B5 /* 802.1 Local Experimental 1. */ +#define ETH_P_PREAUTH 0x88C7 /* 802.11 Preauthentication */ +#define ETH_P_TIPC 0x88CA /* TIPC */ +#define ETH_P_MACSEC 0x88E5 /* 802.1ae MACsec */ +#define ETH_P_8021AH 0x88E7 /* 802.1ah Backbone Service Tag */ +#define ETH_P_MVRP 0x88F5 /* 802.1Q MVRP */ +#define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */ +#define ETH_P_NCSI 0x88F8 /* NCSI protocol */ +#define ETH_P_PRP 0x88FB /* IEC 62439-3 PRP/HSRv0 */ +#define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */ +#define ETH_P_IBOE 0x8915 /* Infiniband over Ethernet */ +#define ETH_P_TDLS 0x890D /* TDLS */ +#define ETH_P_FIP 0x8914 /* FCoE Initialization Protocol */ +#define ETH_P_80221 0x8917 /* IEEE 802.21 Media Independent Handover Protocol */ +#define ETH_P_HSR 0x892F /* IEC 62439-3 HSRv1 */ +#define ETH_P_NSH 0x894F /* Network Service Header */ +#define ETH_P_LOOPBACK 0x9000 /* Ethernet loopback packet, per IEEE 802.3 */ +#define ETH_P_QINQ1 0x9100 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_QINQ2 0x9200 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_QINQ3 0x9300 /* deprecated QinQ VLAN [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_EDSA 0xDADA /* Ethertype DSA [ NOT AN OFFICIALLY REGISTERED ID ] */ +#define ETH_P_IFE 0xED3E /* ForCES inter-FE LFB type */ +#define ETH_P_AF_IUCV 0xFBFB /* IBM af_iucv [ NOT AN OFFICIALLY REGISTERED ID ] */ + +#define ETH_P_802_3_MIN 0x0600 /* If the value in the ethernet type is less than this value + * then the frame is Ethernet II. Else it is 802.3 */ + +/* + * Non DIX types. Won't clash for 1500 types. + */ + +#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ +#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ +#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ +#define ETH_P_802_2 0x0004 /* 802.2 frames */ +#define ETH_P_SNAP 0x0005 /* Internal only */ +#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ +#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ +#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ +#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ +#define ETH_P_CAN 0x000C /* CAN: Controller Area Network */ +#define ETH_P_CANFD 0x000D /* CANFD: CAN flexible data rate*/ +#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ +#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ +#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ +#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ +#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ +#define ETH_P_ECONET 0x0018 /* Acorn Econet */ +#define ETH_P_HDLC 0x0019 /* HDLC frames */ +#define ETH_P_ARCNET 0x001A /* 1A for ArcNet :-) */ +#define ETH_P_DSA 0x001B /* Distributed Switch Arch. */ +#define ETH_P_TRAILER 0x001C /* Trailer switch tagging */ +#define ETH_P_PHONET 0x00F5 /* Nokia Phonet frames */ +#define ETH_P_IEEE802154 0x00F6 /* IEEE802.15.4 frame */ +#define ETH_P_CAIF 0x00F7 /* ST-Ericsson CAIF protocol */ +#define ETH_P_XDSA 0x00F8 /* Multiplexed DSA protocol */ +#define ETH_P_MAP 0x00F9 /* Qualcomm multiplexing and + * aggregation protocol + */ + +/* + * This is an Ethernet frame header. + */ + +/* allow libcs like musl to deactivate this, glibc does not implement this. */ +#ifndef __UAPI_DEF_ETHHDR +#define __UAPI_DEF_ETHHDR 1 +#endif + +#if __UAPI_DEF_ETHHDR +struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + __be16 h_proto; /* packet type ID field */ +} __attribute__((packed)); +#endif + + +#endif /* _UAPI_LINUX_IF_ETHER_H */ diff --git a/src/basic/meson.build b/src/basic/meson.build index 67f04bcbc4..7d281c8841 100644 --- a/src/basic/meson.build +++ b/src/basic/meson.build @@ -94,6 +94,7 @@ basic_sources = files(''' linux/if_arp.h linux/if_bonding.h linux/if_bridge.h + linux/if_ether.h linux/if_link.h linux/if_macsec.h linux/if_tun.h diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index 904bafb76f..e787d53d8f 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -1225,9 +1225,22 @@ int flush_accept(int fd) { .fd = fd, .events = POLLIN, }; - int r; + int r, b; + socklen_t l = sizeof(b); + + /* Similar to flush_fd() but flushes all incoming connection by accepting them and immediately + * closing them. */ + + if (getsockopt(fd, SOL_SOCKET, SO_ACCEPTCONN, &b, &l) < 0) + return -errno; - /* Similar to flush_fd() but flushes all incoming connection by accepting them and immediately closing them. */ + assert(l == sizeof(b)); + if (!b) /* Let's check if this is a socket accepting connections before calling accept(). That's + * because accept4() can return EOPNOTSUPP in the fd we are called on is not a listening + * socket, or in case the incoming TCP connection transiently triggered that (see accept(2) + * man page for details). The latter case is a transient error we should continue looping + * on. The former case however is fatal. */ + return -ENOTTY; for (;;) { int cfd; diff --git a/src/core/cgroup.c b/src/core/cgroup.c index ceb7ee2189..a288c07bc9 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -202,6 +202,7 @@ void cgroup_context_done(CGroupContext *c) { } void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) { + _cleanup_free_ char *disable_controllers_str = NULL; CGroupIODeviceLimit *il; CGroupIODeviceWeight *iw; CGroupIODeviceLatency *l; @@ -217,6 +218,8 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) { prefix = strempty(prefix); + (void) cg_mask_to_string(c->disable_controllers, &disable_controllers_str); + fprintf(f, "%sCPUAccounting=%s\n" "%sIOAccounting=%s\n" @@ -243,6 +246,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) { "%sMemoryLimit=%" PRIu64 "\n" "%sTasksMax=%" PRIu64 "\n" "%sDevicePolicy=%s\n" + "%sDisableControllers=%s\n" "%sDelegate=%s\n", prefix, yes_no(c->cpu_accounting), prefix, yes_no(c->io_accounting), @@ -269,6 +273,7 @@ void cgroup_context_dump(CGroupContext *c, FILE* f, const char *prefix) { prefix, c->memory_limit, prefix, c->tasks_max, prefix, cgroup_device_policy_to_string(c->device_policy), + prefix, strnull(disable_controllers_str), prefix, yes_no(c->delegate)); if (c->delegate) { diff --git a/src/core/dbus-cgroup.c b/src/core/dbus-cgroup.c index 5327bfb17d..74a583d81b 100644 --- a/src/core/dbus-cgroup.c +++ b/src/core/dbus-cgroup.c @@ -401,10 +401,10 @@ static int bus_cgroup_set_transient_property( return 1; - } else if (streq(name, "DelegateControllers")) { + } else if (STR_IN_SET(name, "DelegateControllers", "DisableControllers")) { CGroupMask mask = 0; - if (!UNIT_VTABLE(u)->can_delegate) + if (streq(name, "DelegateControllers") && !UNIT_VTABLE(u)->can_delegate) return sd_bus_error_setf(error, SD_BUS_ERROR_INVALID_ARGS, "Delegation not available for unit type"); r = sd_bus_message_enter_container(message, 'a', "s"); @@ -439,13 +439,25 @@ static int bus_cgroup_set_transient_property( if (r < 0) return r; - c->delegate = true; - if (mask == 0) - c->delegate_controllers = 0; - else - c->delegate_controllers |= mask; + if (streq(name, "DelegateControllers")) { + + c->delegate = true; + if (mask == 0) + c->delegate_controllers = 0; + else + c->delegate_controllers |= mask; + + unit_write_settingf(u, flags, name, "Delegate=%s", strempty(t)); - unit_write_settingf(u, flags, name, "Delegate=%s", strempty(t)); + } else if (streq(name, "DisableControllers")) { + + if (mask == 0) + c->disable_controllers = 0; + else + c->disable_controllers |= mask; + + unit_write_settingf(u, flags, name, "%s=%s", name, strempty(t)); + } } return 1; @@ -1426,7 +1438,7 @@ int bus_cgroup_set_property( return 1; } - if (u->transient && u->load_state == UNIT_STUB) + if (streq(name, "DisableControllers") || (u->transient && u->load_state == UNIT_STUB)) return bus_cgroup_set_transient_property(u, c, name, message, flags, error); return 0; diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index b2f8936038..5c823a3d84 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -725,8 +725,8 @@ int boot_entries_load_config_auto( return boot_entries_load_config(esp_where, xbootldr_where, config); } +#if ENABLE_EFI int boot_entries_augment_from_loader(BootConfig *config, bool only_auto) { - static const char * const title_table[] = { /* Pretty names for a few well-known automatically discovered entries. */ "auto-osx", "macOS", @@ -793,6 +793,7 @@ int boot_entries_augment_from_loader(BootConfig *config, bool only_auto) { return 0; } +#endif /********************************************************************************/ diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index b35eaf1110..c18d89494a 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -71,7 +71,13 @@ static inline BootEntry* boot_config_default_entry(BootConfig *config) { void boot_config_free(BootConfig *config); int boot_entries_load_config(const char *esp_path, const char *xbootldr_path, BootConfig *config); int boot_entries_load_config_auto(const char *override_esp_path, const char *override_xbootldr_path, BootConfig *config); +#if ENABLE_EFI int boot_entries_augment_from_loader(BootConfig *config, bool only_auto); +#else +static inline int boot_entries_augment_from_loader(BootConfig *config, bool only_auto) { + return -EOPNOTSUPP; +} +#endif static inline const char* boot_entry_title(const BootEntry *entry) { return entry->show_title ?: entry->title ?: entry->id; diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c index cae526ba40..c6cbc9828c 100644 --- a/src/shared/bus-unit-util.c +++ b/src/shared/bus-unit-util.c @@ -396,6 +396,10 @@ static int bus_append_cgroup_property(sd_bus_message *m, const char *field, cons return bus_append_cg_blkio_weight_parse(m, field, eq); + if (streq(field, "DisableControllers")) + + return bus_append_strv(m, "DisableControllers", eq, EXTRACT_QUOTES); + if (streq(field, "Delegate")) { r = parse_boolean(eq); diff --git a/src/shared/efivars.h b/src/shared/efivars.h index 49d1b338fb..1346da9323 100644 --- a/src/shared/efivars.h +++ b/src/shared/efivars.h @@ -79,6 +79,10 @@ static inline int efi_set_reboot_to_firmware(bool value) { return -EOPNOTSUPP; } +static inline char* efi_variable_path(sd_id128_t vendor, const char *name) { + return NULL; +} + static inline int efi_get_variable(sd_id128_t vendor, const char *name, uint32_t *attribute, void **value, size_t *size) { return -EOPNOTSUPP; } diff --git a/src/test/test-socket-util.c b/src/test/test-socket-util.c index 057840d76f..4e9a0bddf4 100644 --- a/src/test/test-socket-util.c +++ b/src/test/test-socket-util.c @@ -810,6 +810,67 @@ static void test_send_emptydata(void) { assert_se(fd == -999); } +static void test_flush_accept(void) { + _cleanup_close_ int listen_stream = -1, listen_dgram = -1, listen_seqpacket = 1, connect_stream = -1, connect_dgram = -1, connect_seqpacket = -1; + static const union sockaddr_union sa = { .un.sun_family = AF_UNIX }; + union sockaddr_union lsa; + socklen_t l; + + listen_stream = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); + assert_se(listen_stream >= 0); + + listen_dgram = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); + assert_se(listen_dgram >= 0); + + listen_seqpacket = socket(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); + assert_se(listen_seqpacket >= 0); + + assert_se(flush_accept(listen_stream) < 0); + assert_se(flush_accept(listen_dgram) < 0); + assert_se(flush_accept(listen_seqpacket) < 0); + + assert_se(bind(listen_stream, &sa.sa, sizeof(sa_family_t)) >= 0); + assert_se(bind(listen_dgram, &sa.sa, sizeof(sa_family_t)) >= 0); + assert_se(bind(listen_seqpacket, &sa.sa, sizeof(sa_family_t)) >= 0); + + assert_se(flush_accept(listen_stream) < 0); + assert_se(flush_accept(listen_dgram) < 0); + assert_se(flush_accept(listen_seqpacket) < 0); + + assert_se(listen(listen_stream, SOMAXCONN) >= 0); + assert_se(listen(listen_dgram, SOMAXCONN) < 0); + assert_se(listen(listen_seqpacket, SOMAXCONN) >= 0); + + assert_se(flush_accept(listen_stream) >= 0); + assert_se(flush_accept(listen_dgram) < 0); + assert_se(flush_accept(listen_seqpacket) >= 0); + + connect_stream = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); + assert_se(connect_stream >= 0); + + connect_dgram = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); + assert_se(connect_dgram >= 0); + + connect_seqpacket = socket(AF_UNIX, SOCK_SEQPACKET|SOCK_CLOEXEC|SOCK_NONBLOCK, 0); + assert_se(connect_seqpacket >= 0); + + l = sizeof(lsa); + assert_se(getsockname(listen_stream, &lsa.sa, &l) >= 0); + assert_se(connect(connect_stream, &lsa.sa, l) >= 0); + + l = sizeof(lsa); + assert_se(getsockname(listen_dgram, &lsa.sa, &l) >= 0); + assert_se(connect(connect_dgram, &lsa.sa, l) >= 0); + + l = sizeof(lsa); + assert_se(getsockname(listen_seqpacket, &lsa.sa, &l) >= 0); + assert_se(connect(connect_seqpacket, &lsa.sa, l) >= 0); + + assert_se(flush_accept(listen_stream) >= 0); + assert_se(flush_accept(listen_dgram) < 0); + assert_se(flush_accept(listen_seqpacket) >= 0); +} + int main(int argc, char *argv[]) { test_setup_logging(LOG_DEBUG); @@ -843,6 +904,7 @@ int main(int argc, char *argv[]) { test_receive_nopassfd(); test_send_nodata_nofd(); test_send_emptydata(); + test_flush_accept(); return 0; } diff --git a/src/udev/net/naming-scheme.c b/src/udev/net/naming-scheme.c index 27cede5e2e..8223f9cda1 100644 --- a/src/udev/net/naming-scheme.c +++ b/src/udev/net/naming-scheme.c @@ -8,6 +8,7 @@ static const NamingScheme naming_schemes[] = { { "v238", NAMING_V238 }, { "v239", NAMING_V239 }, { "v240", NAMING_V240 }, + { "v243", NAMING_V243 }, /* … add more schemes here, as the logic to name devices is updated … */ }; diff --git a/src/udev/net/naming-scheme.h b/src/udev/net/naming-scheme.h index 0b3d9bff1d..1f7cb0ccb9 100644 --- a/src/udev/net/naming-scheme.h +++ b/src/udev/net/naming-scheme.h @@ -27,11 +27,13 @@ typedef enum NamingSchemeFlags { NAMING_INFINIBAND = 1 << 2, /* Use "ib" prefix for infiniband, see 938d30aa98df887797c9e05074a562ddacdcdf5e */ NAMING_ZERO_ACPI_INDEX = 1 << 3, /* Allow zero acpi_index field, see d81186ef4f6a888a70f20a1e73a812d6acb9e22f */ NAMING_ALLOW_RERENAMES = 1 << 4, /* Allow re-renaming of devices, see #9006 */ + NAMING_NETDEVSIM = 1 << 5, /* Allow re-renaming of netdevsim devices */ /* And now the masks that combine the features above */ NAMING_V238 = 0, NAMING_V239 = NAMING_V238 | NAMING_SR_IOV_V | NAMING_NPAR_ARI, NAMING_V240 = NAMING_V239 | NAMING_INFINIBAND | NAMING_ZERO_ACPI_INDEX | NAMING_ALLOW_RERENAMES, + NAMING_V243 = NAMING_V240 | NAMING_NETDEVSIM, _NAMING_SCHEME_FLAGS_INVALID = -1, } NamingSchemeFlags; diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 03b281a771..2c7dcf7d2a 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -31,6 +31,7 @@ * — USB port number chain * v<slot> - VIO slot number (IBM PowerVM) * a<vendor><model>i<instance> — Platform bus ACPI instance id + * i<addr>n<phys_port_name> — Netdevsim bus address and port name * * All multi-function PCI devices will carry the [f<function>] number in the * device name, including the function 0 device. @@ -126,6 +127,7 @@ enum netname_type{ NET_CCW, NET_VIO, NET_PLATFORM, + NET_NETDEVSIM, }; struct netnames { @@ -145,6 +147,7 @@ struct netnames { char ccw_busid[IFNAMSIZ]; char vio_slot[IFNAMSIZ]; char platform_path[IFNAMSIZ]; + char netdevsim_path[IFNAMSIZ]; }; struct virtfn_info { @@ -794,6 +797,43 @@ static int names_mac(sd_device *dev, struct netnames *names) { return 0; } +static int names_netdevsim(sd_device *dev, struct netnames *names) { + sd_device *netdevsimdev; + const char *sysname; + unsigned addr; + const char *port_name = NULL; + int r; + bool ok; + + if (!naming_scheme_has(NAMING_NETDEVSIM)) + return 0; + + assert(dev); + assert(names); + + r = sd_device_get_parent_with_subsystem_devtype(dev, "netdevsim", NULL, &netdevsimdev); + if (r < 0) + return r; + r = sd_device_get_sysname(netdevsimdev, &sysname); + if (r < 0) + return r; + + if (sscanf(sysname, "netdevsim%u", &addr) != 1) + return -EINVAL; + + r = sd_device_get_sysattr_value(dev, "phys_port_name", &port_name); + if (r < 0) + return r; + + ok = snprintf_ok(names->netdevsim_path, sizeof(names->netdevsim_path), "i%un%s", addr, port_name); + if (!ok) + return -ENOBUFS; + + names->type = NET_NETDEVSIM; + + return 0; +} + /* IEEE Organizationally Unique Identifier vendor string */ static int ieee_oui(sd_device *dev, struct netnames *names, bool test) { char str[32]; @@ -897,6 +937,16 @@ static int builtin_net_id(sd_device *dev, int argc, char *argv[], bool test) { return 0; } + /* get netdevsim path names */ + if (names_netdevsim(dev, &names) >= 0 && names.type == NET_NETDEVSIM) { + char str[IFNAMSIZ]; + + if (snprintf_ok(str, sizeof str, "%s%s", prefix, names.netdevsim_path)) + udev_builtin_add_property(dev, test, "ID_NET_NAME_PATH", str); + + return 0; + } + /* get PCI based path names, we compose only PCI based paths */ if (names_pci(dev, &names) < 0) return 0; diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 63a967633b..96840b272c 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -2442,7 +2442,7 @@ int udev_rules_apply_to_event( case TK_A_RUN_BUILTIN: case TK_A_RUN_PROGRAM: { _cleanup_free_ char *cmd = NULL; - + if (event->run_final) break; if (cur->key.op == OP_ASSIGN_FINAL) |