4 This file is part of systemd.
6 Copyright 2010 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 /* Missing glibc definitions to access certain kernel APIs */
26 #include <linux/audit.h>
27 #include <linux/capability.h>
28 #include <linux/if_link.h>
29 #include <linux/input.h>
30 #include <linux/loop.h>
31 #include <linux/neighbour.h>
32 #include <linux/oom.h>
33 #include <linux/rtnetlink.h>
35 #include <sys/resource.h>
36 #include <sys/syscall.h>
40 #include "musl_missing.h"
47 #include <asm/sgidefs.h>
50 #ifdef HAVE_LINUX_BTRFS_H
51 #include <linux/btrfs.h>
57 #define RLIMIT_RTTIME 15
60 /* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
61 #define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
63 #ifndef F_LINUX_SPECIFIC_BASE
64 #define F_LINUX_SPECIFIC_BASE 1024
68 #define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
72 #define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
76 #define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
77 #define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
79 #define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
80 #define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
81 #define F_SEAL_GROW 0x0004 /* prevent file from growing */
82 #define F_SEAL_WRITE 0x0008 /* prevent writes */
86 #define F_OFD_GETLK 36
87 #define F_OFD_SETLK 37
88 #define F_OFD_SETLKW 38
91 #ifndef MFD_ALLOW_SEALING
92 #define MFD_ALLOW_SEALING 0x0002U
96 #define MFD_CLOEXEC 0x0001U
100 #define IP_FREEBIND 15
103 #ifndef OOM_SCORE_ADJ_MIN
104 #define OOM_SCORE_ADJ_MIN (-1000)
107 #ifndef OOM_SCORE_ADJ_MAX
108 #define OOM_SCORE_ADJ_MAX 1000
111 #ifndef AUDIT_SERVICE_START
112 #define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
115 #ifndef AUDIT_SERVICE_STOP
116 #define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
120 #define TIOCVHANGUP 0x5437
123 #ifndef IP_TRANSPARENT
124 #define IP_TRANSPARENT 19
128 #define SOL_NETLINK 270
131 #ifndef NETLINK_LIST_MEMBERSHIPS
132 #define NETLINK_LIST_MEMBERSHIPS 9
139 #if !HAVE_DECL_PIVOT_ROOT
140 static inline int pivot_root(const char *new_root, const char *put_old) {
141 return syscall(SYS_pivot_root, new_root, put_old);
145 #ifndef __NR_memfd_create
146 # if defined __x86_64__
147 # define __NR_memfd_create 319
148 # elif defined __arm__
149 # define __NR_memfd_create 385
150 # elif defined __aarch64__
151 # define __NR_memfd_create 279
152 # elif defined __s390__
153 # define __NR_memfd_create 350
154 # elif defined _MIPS_SIM
155 # if _MIPS_SIM == _MIPS_SIM_ABI32
156 # define __NR_memfd_create 4354
158 # if _MIPS_SIM == _MIPS_SIM_NABI32
159 # define __NR_memfd_create 6318
161 # if _MIPS_SIM == _MIPS_SIM_ABI64
162 # define __NR_memfd_create 5314
164 # elif defined __i386__
165 # define __NR_memfd_create 356
167 # warning "__NR_memfd_create unknown for your architecture"
168 # define __NR_memfd_create 0xffffffff
172 #if !HAVE_DECL_MEMFD_CREATE
173 static inline int memfd_create(const char *name, unsigned int flags) {
174 return syscall(__NR_memfd_create, name, flags);
178 #ifndef __NR_getrandom
179 # if defined __x86_64__
180 # define __NR_getrandom 318
181 # elif defined(__i386__)
182 # define __NR_getrandom 355
183 # elif defined(__arm__)
184 # define __NR_getrandom 384
185 # elif defined(__aarch64__)
186 # define __NR_getrandom 278
187 # elif defined(__ia64__)
188 # define __NR_getrandom 1339
189 # elif defined(__m68k__)
190 # define __NR_getrandom 352
191 # elif defined(__s390x__)
192 # define __NR_getrandom 349
193 # elif defined(__powerpc__)
194 # define __NR_getrandom 359
195 # elif defined _MIPS_SIM
196 # if _MIPS_SIM == _MIPS_SIM_ABI32
197 # define __NR_getrandom 4353
199 # if _MIPS_SIM == _MIPS_SIM_NABI32
200 # define __NR_getrandom 6317
202 # if _MIPS_SIM == _MIPS_SIM_ABI64
203 # define __NR_getrandom 5313
206 # warning "__NR_getrandom unknown for your architecture"
207 # define __NR_getrandom 0xffffffff
211 #if !HAVE_DECL_GETRANDOM
212 static inline int getrandom(void *buffer, size_t count, unsigned flags) {
213 return syscall(__NR_getrandom, buffer, count, flags);
217 #ifndef GRND_NONBLOCK
218 #define GRND_NONBLOCK 0x0001
222 #define GRND_RANDOM 0x0002
225 #ifndef BTRFS_IOCTL_MAGIC
226 #define BTRFS_IOCTL_MAGIC 0x94
229 #ifndef BTRFS_PATH_NAME_MAX
230 #define BTRFS_PATH_NAME_MAX 4087
233 #ifndef BTRFS_DEVICE_PATH_NAME_MAX
234 #define BTRFS_DEVICE_PATH_NAME_MAX 1024
237 #ifndef BTRFS_FSID_SIZE
238 #define BTRFS_FSID_SIZE 16
241 #ifndef BTRFS_UUID_SIZE
242 #define BTRFS_UUID_SIZE 16
245 #ifndef BTRFS_SUBVOL_RDONLY
246 #define BTRFS_SUBVOL_RDONLY (1ULL << 1)
249 #ifndef BTRFS_SUBVOL_NAME_MAX
250 #define BTRFS_SUBVOL_NAME_MAX 4039
253 #ifndef BTRFS_INO_LOOKUP_PATH_MAX
254 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
257 #ifndef BTRFS_SEARCH_ARGS_BUFSIZE
258 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
261 #ifndef BTRFS_QGROUP_LEVEL_SHIFT
262 #define BTRFS_QGROUP_LEVEL_SHIFT 48
265 #if 0 /// UNNEEDED by elogind (It can not support BTRFS at all)
266 #ifndef HAVE_LINUX_BTRFS_H
267 struct btrfs_ioctl_vol_args {
269 char name[BTRFS_PATH_NAME_MAX + 1];
272 struct btrfs_qgroup_limit {
280 struct btrfs_qgroup_inherit {
283 __u64 num_ref_copies;
284 __u64 num_excl_copies;
285 struct btrfs_qgroup_limit lim;
289 struct btrfs_ioctl_qgroup_limit_args {
291 struct btrfs_qgroup_limit lim;
294 struct btrfs_ioctl_vol_args_v2 {
301 struct btrfs_qgroup_inherit *qgroup_inherit;
305 char name[BTRFS_SUBVOL_NAME_MAX + 1];
308 struct btrfs_ioctl_dev_info_args {
309 uint64_t devid; /* in/out */
310 uint8_t uuid[BTRFS_UUID_SIZE]; /* in/out */
311 uint64_t bytes_used; /* out */
312 uint64_t total_bytes; /* out */
313 uint64_t unused[379]; /* pad to 4k */
314 char path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
317 struct btrfs_ioctl_fs_info_args {
318 uint64_t max_id; /* out */
319 uint64_t num_devices; /* out */
320 uint8_t fsid[BTRFS_FSID_SIZE]; /* out */
321 uint64_t reserved[124]; /* pad to 1k */
324 struct btrfs_ioctl_ino_lookup_args {
327 char name[BTRFS_INO_LOOKUP_PATH_MAX];
330 struct btrfs_ioctl_search_key {
331 /* which root are we searching. 0 is the tree of tree roots */
334 /* keys returned will be >= min and <= max */
338 /* keys returned will be >= min and <= max */
342 /* max and min transids to search for */
346 /* keys returned will be >= min and <= max */
351 * how many items did userland ask for, and how many are we
356 /* align to 64 bits */
359 /* some extra for later */
366 struct btrfs_ioctl_search_header {
375 struct btrfs_ioctl_search_args {
376 struct btrfs_ioctl_search_key key;
377 char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
380 struct btrfs_ioctl_clone_range_args {
382 __u64 src_offset, src_length;
386 #define BTRFS_QUOTA_CTL_ENABLE 1
387 #define BTRFS_QUOTA_CTL_DISABLE 2
388 #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
389 struct btrfs_ioctl_quota_ctl_args {
395 #ifndef BTRFS_IOC_DEFRAG
396 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
397 struct btrfs_ioctl_vol_args)
400 #ifndef BTRFS_IOC_RESIZE
401 #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
402 struct btrfs_ioctl_vol_args)
405 #ifndef BTRFS_IOC_CLONE
406 #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
409 #ifndef BTRFS_IOC_CLONE_RANGE
410 #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
411 struct btrfs_ioctl_clone_range_args)
414 #ifndef BTRFS_IOC_SUBVOL_CREATE
415 #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
416 struct btrfs_ioctl_vol_args)
419 #ifndef BTRFS_IOC_SNAP_DESTROY
420 #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
421 struct btrfs_ioctl_vol_args)
424 #ifndef BTRFS_IOC_TREE_SEARCH
425 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
426 struct btrfs_ioctl_search_args)
429 #ifndef BTRFS_IOC_INO_LOOKUP
430 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
431 struct btrfs_ioctl_ino_lookup_args)
434 #ifndef BTRFS_IOC_SNAP_CREATE_V2
435 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
436 struct btrfs_ioctl_vol_args_v2)
439 #ifndef BTRFS_IOC_SUBVOL_GETFLAGS
440 #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
443 #ifndef BTRFS_IOC_SUBVOL_SETFLAGS
444 #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
447 #ifndef BTRFS_IOC_DEV_INFO
448 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
449 struct btrfs_ioctl_dev_info_args)
452 #ifndef BTRFS_IOC_FS_INFO
453 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
454 struct btrfs_ioctl_fs_info_args)
457 #ifndef BTRFS_IOC_DEVICES_READY
458 #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
459 struct btrfs_ioctl_vol_args)
462 #ifndef BTRFS_IOC_QUOTA_CTL
463 #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
464 struct btrfs_ioctl_quota_ctl_args)
467 #ifndef BTRFS_IOC_QGROUP_LIMIT
468 #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
469 struct btrfs_ioctl_qgroup_limit_args)
472 #ifndef BTRFS_FIRST_FREE_OBJECTID
473 #define BTRFS_FIRST_FREE_OBJECTID 256
476 #ifndef BTRFS_LAST_FREE_OBJECTID
477 #define BTRFS_LAST_FREE_OBJECTID -256ULL
480 #ifndef BTRFS_ROOT_TREE_OBJECTID
481 #define BTRFS_ROOT_TREE_OBJECTID 1
484 #ifndef BTRFS_QUOTA_TREE_OBJECTID
485 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL
488 #ifndef BTRFS_ROOT_ITEM_KEY
489 #define BTRFS_ROOT_ITEM_KEY 132
492 #ifndef BTRFS_QGROUP_STATUS_KEY
493 #define BTRFS_QGROUP_STATUS_KEY 240
496 #ifndef BTRFS_QGROUP_INFO_KEY
497 #define BTRFS_QGROUP_INFO_KEY 242
500 #ifndef BTRFS_QGROUP_LIMIT_KEY
501 #define BTRFS_QGROUP_LIMIT_KEY 244
504 #ifndef BTRFS_QGROUP_RELATION_KEY
505 #define BTRFS_QGROUP_RELATION_KEY 246
508 #ifndef BTRFS_ROOT_BACKREF_KEY
509 #define BTRFS_ROOT_BACKREF_KEY 144
512 #ifndef BTRFS_SUPER_MAGIC
513 #define BTRFS_SUPER_MAGIC 0x9123683E
518 #ifndef CGROUP_SUPER_MAGIC
519 #define CGROUP_SUPER_MAGIC 0x27e0eb
522 #ifndef CGROUP2_SUPER_MAGIC
523 #define CGROUP2_SUPER_MAGIC 0x63677270
527 #define TMPFS_MAGIC 0x01021994
535 #define MS_PRIVATE (1 << 18)
538 #if !HAVE_DECL_GETTID
539 static inline pid_t gettid(void) {
540 return (pid_t) syscall(SYS_gettid);
545 #define SCM_SECURITY 0x03
548 #ifndef MS_STRICTATIME
549 #define MS_STRICTATIME (1<<24)
557 #define MS_SHARED (1<<20)
560 #ifndef PR_SET_NO_NEW_PRIVS
561 #define PR_SET_NO_NEW_PRIVS 38
564 #ifndef PR_SET_CHILD_SUBREAPER
565 #define PR_SET_CHILD_SUBREAPER 36
568 #ifndef MAX_HANDLE_SZ
569 #define MAX_HANDLE_SZ 128
572 #ifndef __NR_name_to_handle_at
573 # if defined(__x86_64__)
574 # define __NR_name_to_handle_at 303
575 # elif defined(__i386__)
576 # define __NR_name_to_handle_at 341
577 # elif defined(__arm__)
578 # define __NR_name_to_handle_at 370
579 # elif defined(__powerpc__)
580 # define __NR_name_to_handle_at 345
582 # error "__NR_name_to_handle_at is not defined"
586 #if !HAVE_DECL_NAME_TO_HANDLE_AT
588 unsigned int handle_bytes;
590 unsigned char f_handle[0];
593 static inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) {
594 return syscall(__NR_name_to_handle_at, fd, name, handle, mnt_id, flags);
598 #ifndef HAVE_SECURE_GETENV
599 # ifdef HAVE___SECURE_GETENV
600 # define secure_getenv __secure_getenv
602 # error "neither secure_getenv nor __secure_getenv are available"
606 #ifndef CIFS_MAGIC_NUMBER
607 # define CIFS_MAGIC_NUMBER 0xFF534D42
610 #ifndef TFD_TIMER_CANCEL_ON_SET
611 # define TFD_TIMER_CANCEL_ON_SET (1 << 1)
615 # define SO_REUSEPORT 15
619 # define EVIOCREVOKE _IOW('E', 0x91, int)
622 #ifndef DRM_IOCTL_SET_MASTER
623 # define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
626 #ifndef DRM_IOCTL_DROP_MASTER
627 # define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
630 #if defined(__i386__) || defined(__x86_64__)
632 /* The precise definition of __O_TMPFILE is arch specific, so let's
633 * just define this on x86 where we know the value. */
636 #define __O_TMPFILE 020000000
639 /* a horrid kludge trying to make sure that this will fail on old kernels */
641 #define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
647 # if defined(__x86_64__)
648 # define __NR_setns 308
649 # elif defined(__i386__)
650 # define __NR_setns 346
652 # error "__NR_setns is not defined"
657 static inline int setns(int fd, int nstype) {
658 return syscall(__NR_setns, fd, nstype);
662 #if !HAVE_DECL_LO_FLAGS_PARTSCAN
663 #define LO_FLAGS_PARTSCAN 8
666 #ifndef LOOP_CTL_REMOVE
667 #define LOOP_CTL_REMOVE 0x4C81
670 #ifndef LOOP_CTL_GET_FREE
671 #define LOOP_CTL_GET_FREE 0x4C82
674 #if !HAVE_DECL_IFLA_INET6_ADDR_GEN_MODE
675 #define IFLA_INET6_UNSPEC 0
676 #define IFLA_INET6_FLAGS 1
677 #define IFLA_INET6_CONF 2
678 #define IFLA_INET6_STATS 3
679 #define IFLA_INET6_MCAST 4
680 #define IFLA_INET6_CACHEINFO 5
681 #define IFLA_INET6_ICMP6STATS 6
682 #define IFLA_INET6_TOKEN 7
683 #define IFLA_INET6_ADDR_GEN_MODE 8
684 #define __IFLA_INET6_MAX 9
686 #define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
688 #define IN6_ADDR_GEN_MODE_EUI64 0
689 #define IN6_ADDR_GEN_MODE_NONE 1
692 #if !HAVE_DECL_IFLA_MACVLAN_FLAGS
693 #define IFLA_MACVLAN_UNSPEC 0
694 #define IFLA_MACVLAN_MODE 1
695 #define IFLA_MACVLAN_FLAGS 2
696 #define __IFLA_MACVLAN_MAX 3
698 #define IFLA_MACVLAN_MAX (__IFLA_MACVLAN_MAX - 1)
701 #if !HAVE_DECL_IFLA_IPVLAN_MODE
702 #define IFLA_IPVLAN_UNSPEC 0
703 #define IFLA_IPVLAN_MODE 1
704 #define __IFLA_IPVLAN_MAX 2
706 #define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1)
708 #define IPVLAN_MODE_L2 0
709 #define IPVLAN_MODE_L3 1
713 #if !HAVE_DECL_IFLA_VTI_REMOTE
714 #define IFLA_VTI_UNSPEC 0
715 #define IFLA_VTI_LINK 1
716 #define IFLA_VTI_IKEY 2
717 #define IFLA_VTI_OKEY 3
718 #define IFLA_VTI_LOCAL 4
719 #define IFLA_VTI_REMOTE 5
720 #define __IFLA_VTI_MAX 6
722 #define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1)
725 #if !HAVE_DECL_IFLA_PHYS_PORT_ID
726 #define IFLA_EXT_MASK 29
727 #undef IFLA_PROMISCUITY
728 #define IFLA_PROMISCUITY 30
729 #define IFLA_NUM_TX_QUEUES 31
730 #define IFLA_NUM_RX_QUEUES 32
731 #define IFLA_CARRIER 33
732 #define IFLA_PHYS_PORT_ID 34
733 #define __IFLA_MAX 35
735 #define IFLA_MAX (__IFLA_MAX - 1)
738 #if !HAVE_DECL_IFLA_BOND_AD_INFO
739 #define IFLA_BOND_UNSPEC 0
740 #define IFLA_BOND_MODE 1
741 #define IFLA_BOND_ACTIVE_SLAVE 2
742 #define IFLA_BOND_MIIMON 3
743 #define IFLA_BOND_UPDELAY 4
744 #define IFLA_BOND_DOWNDELAY 5
745 #define IFLA_BOND_USE_CARRIER 6
746 #define IFLA_BOND_ARP_INTERVAL 7
747 #define IFLA_BOND_ARP_IP_TARGET 8
748 #define IFLA_BOND_ARP_VALIDATE 9
749 #define IFLA_BOND_ARP_ALL_TARGETS 10
750 #define IFLA_BOND_PRIMARY 11
751 #define IFLA_BOND_PRIMARY_RESELECT 12
752 #define IFLA_BOND_FAIL_OVER_MAC 13
753 #define IFLA_BOND_XMIT_HASH_POLICY 14
754 #define IFLA_BOND_RESEND_IGMP 15
755 #define IFLA_BOND_NUM_PEER_NOTIF 16
756 #define IFLA_BOND_ALL_SLAVES_ACTIVE 17
757 #define IFLA_BOND_MIN_LINKS 18
758 #define IFLA_BOND_LP_INTERVAL 19
759 #define IFLA_BOND_PACKETS_PER_SLAVE 20
760 #define IFLA_BOND_AD_LACP_RATE 21
761 #define IFLA_BOND_AD_SELECT 22
762 #define IFLA_BOND_AD_INFO 23
763 #define __IFLA_BOND_MAX 24
765 #define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1)
768 #if !HAVE_DECL_IFLA_VLAN_PROTOCOL
769 #define IFLA_VLAN_UNSPEC 0
770 #define IFLA_VLAN_ID 1
771 #define IFLA_VLAN_FLAGS 2
772 #define IFLA_VLAN_EGRESS_QOS 3
773 #define IFLA_VLAN_INGRESS_QOS 4
774 #define IFLA_VLAN_PROTOCOL 5
775 #define __IFLA_VLAN_MAX 6
777 #define IFLA_VLAN_MAX (__IFLA_VLAN_MAX - 1)
780 #if !HAVE_DECL_IFLA_VXLAN_REMCSUM_NOPARTIAL
781 #define IFLA_VXLAN_UNSPEC 0
782 #define IFLA_VXLAN_ID 1
783 #define IFLA_VXLAN_GROUP 2
784 #define IFLA_VXLAN_LINK 3
785 #define IFLA_VXLAN_LOCAL 4
786 #define IFLA_VXLAN_TTL 5
787 #define IFLA_VXLAN_TOS 6
788 #define IFLA_VXLAN_LEARNING 7
789 #define IFLA_VXLAN_AGEING 8
790 #define IFLA_VXLAN_LIMIT 9
791 #define IFLA_VXLAN_PORT_RANGE 10
792 #define IFLA_VXLAN_PROXY 11
793 #define IFLA_VXLAN_RSC 12
794 #define IFLA_VXLAN_L2MISS 13
795 #define IFLA_VXLAN_L3MISS 14
796 #define IFLA_VXLAN_PORT 15
797 #define IFLA_VXLAN_GROUP6 16
798 #define IFLA_VXLAN_LOCAL6 17
799 #define IFLA_VXLAN_UDP_CSUM 18
800 #define IFLA_VXLAN_UDP_ZERO_CSUM6_TX 19
801 #define IFLA_VXLAN_UDP_ZERO_CSUM6_RX 20
802 #define IFLA_VXLAN_REMCSUM_TX 21
803 #define IFLA_VXLAN_REMCSUM_RX 22
804 #define IFLA_VXLAN_GBP 23
805 #define IFLA_VXLAN_REMCSUM_NOPARTIAL 24
806 #define __IFLA_VXLAN_MAX 25
808 #define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
811 #if !HAVE_DECL_IFLA_IPTUN_ENCAP_DPORT
812 #define IFLA_IPTUN_UNSPEC 0
813 #define IFLA_IPTUN_LINK 1
814 #define IFLA_IPTUN_LOCAL 2
815 #define IFLA_IPTUN_REMOTE 3
816 #define IFLA_IPTUN_TTL 4
817 #define IFLA_IPTUN_TOS 5
818 #define IFLA_IPTUN_ENCAP_LIMIT 6
819 #define IFLA_IPTUN_FLOWINFO 7
820 #define IFLA_IPTUN_FLAGS 8
821 #define IFLA_IPTUN_PROTO 9
822 #define IFLA_IPTUN_PMTUDISC 10
823 #define IFLA_IPTUN_6RD_PREFIX 11
824 #define IFLA_IPTUN_6RD_RELAY_PREFIX 12
825 #define IFLA_IPTUN_6RD_PREFIXLEN 13
826 #define IFLA_IPTUN_6RD_RELAY_PREFIXLEN 14
827 #define IFLA_IPTUN_ENCAP_TYPE 15
828 #define IFLA_IPTUN_ENCAP_FLAGS 16
829 #define IFLA_IPTUN_ENCAP_SPORT 17
830 #define IFLA_IPTUN_ENCAP_DPORT 18
832 #define __IFLA_IPTUN_MAX 19
834 #define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1)
837 #if !HAVE_DECL_IFLA_GRE_ENCAP_DPORT
838 #define IFLA_GRE_UNSPEC 0
839 #define IFLA_GRE_LINK 1
840 #define IFLA_GRE_IFLAGS 2
841 #define IFLA_GRE_OFLAGS 3
842 #define IFLA_GRE_IKEY 4
843 #define IFLA_GRE_OKEY 5
844 #define IFLA_GRE_LOCAL 6
845 #define IFLA_GRE_REMOTE 7
846 #define IFLA_GRE_TTL 8
847 #define IFLA_GRE_TOS 9
848 #define IFLA_GRE_PMTUDISC 10
849 #define IFLA_GRE_ENCAP_LIMIT 11
850 #define IFLA_GRE_FLOWINFO 12
851 #define IFLA_GRE_FLAGS 13
852 #define IFLA_GRE_ENCAP_TYPE 14
853 #define IFLA_GRE_ENCAP_FLAGS 15
854 #define IFLA_GRE_ENCAP_SPORT 16
855 #define IFLA_GRE_ENCAP_DPORT 17
857 #define __IFLA_GRE_MAX 18
859 #define IFLA_GRE_MAX (__IFLA_GRE_MAX - 1)
862 #if !HAVE_DECL_IFLA_BRIDGE_VLAN_INFO
863 #define IFLA_BRIDGE_FLAGS 0
864 #define IFLA_BRIDGE_MODE 1
865 #define IFLA_BRIDGE_VLAN_INFO 2
866 #define __IFLA_BRIDGE_MAX 3
868 #define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
871 #if !HAVE_DECL_IFLA_BR_PRIORITY
872 #define IFLA_BR_UNSPEC 0
873 #define IFLA_BR_FORWARD_DELAY 1
874 #define IFLA_BR_HELLO_TIME 2
875 #define IFLA_BR_MAX_AGE 3
876 #define IFLA_BR_AGEING_TIME 4
877 #define IFLA_BR_STP_STATE 5
878 #define IFLA_BR_PRIORITY 6
879 #define __IFLA_BR_MAX 7
881 #define IFLA_BR_MAX (__IFLA_BR_MAX - 1)
884 #if !HAVE_DECL_IFLA_BRPORT_LEARNING_SYNC
885 #define IFLA_BRPORT_UNSPEC 0
886 #define IFLA_BRPORT_STATE 1
887 #define IFLA_BRPORT_PRIORITY 2
888 #define IFLA_BRPORT_COST 3
889 #define IFLA_BRPORT_MODE 4
890 #define IFLA_BRPORT_GUARD 5
891 #define IFLA_BRPORT_PROTECT 6
892 #define IFLA_BRPORT_FAST_LEAVE 7
893 #define IFLA_BRPORT_LEARNING 8
894 #define IFLA_BRPORT_UNICAST_FLOOD 9
895 #define IFLA_BRPORT_PROXYARP 10
896 #define IFLA_BRPORT_LEARNING_SYNC 11
897 #define __IFLA_BRPORT_MAX 12
899 #define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
902 #if !HAVE_DECL_NDA_IFINDEX
906 #define NDA_CACHEINFO 3
911 #define NDA_IFINDEX 8
914 #define NDA_MAX (__NDA_MAX - 1)
921 #ifndef IPV6_UNICAST_IF
922 #define IPV6_UNICAST_IF 76
925 #ifndef IFF_MULTI_QUEUE
926 #define IFF_MULTI_QUEUE 0x100
930 #define IFF_LOWER_UP 0x10000
934 #define IFF_DORMANT 0x20000
937 #ifndef BOND_XMIT_POLICY_ENCAP23
938 #define BOND_XMIT_POLICY_ENCAP23 3
941 #ifndef BOND_XMIT_POLICY_ENCAP34
942 #define BOND_XMIT_POLICY_ENCAP34 4
945 #ifndef NET_ADDR_RANDOM
946 # define NET_ADDR_RANDOM 1
949 #ifndef NET_NAME_UNKNOWN
950 # define NET_NAME_UNKNOWN 0
953 #ifndef NET_NAME_ENUM
954 # define NET_NAME_ENUM 1
957 #ifndef NET_NAME_PREDICTABLE
958 # define NET_NAME_PREDICTABLE 2
961 #ifndef NET_NAME_USER
962 # define NET_NAME_USER 3
965 #ifndef NET_NAME_RENAMED
966 # define NET_NAME_RENAMED 4
970 # define BPF_XOR 0xa0
973 /* Note that LOOPBACK_IFINDEX is currently not exported by the
974 * kernel/glibc, but hardcoded internally by the kernel. However, as
975 * it is exported to userspace indirectly via rtnetlink and the
976 * ioctls, and made use of widely we define it here too, in a way that
977 * is compatible with the kernel's internal definition. */
978 #ifndef LOOPBACK_IFINDEX
979 #define LOOPBACK_IFINDEX 1
982 #if !HAVE_DECL_IFA_FLAGS
986 #ifndef IFA_F_MANAGETEMPADDR
987 #define IFA_F_MANAGETEMPADDR 0x100
990 #ifndef IFA_F_NOPREFIXROUTE
991 #define IFA_F_NOPREFIXROUTE 0x200
994 #ifndef MAX_AUDIT_MESSAGE_LENGTH
995 #define MAX_AUDIT_MESSAGE_LENGTH 8970
998 #ifndef AUDIT_NLGRP_MAX
999 #define AUDIT_NLGRP_READLOG 1
1002 #ifndef CAP_MAC_OVERRIDE
1003 #define CAP_MAC_OVERRIDE 32
1006 #ifndef CAP_MAC_ADMIN
1007 #define CAP_MAC_ADMIN 33
1011 #define CAP_SYSLOG 34
1014 #ifndef CAP_WAKE_ALARM
1015 #define CAP_WAKE_ALARM 35
1018 #ifndef CAP_BLOCK_SUSPEND
1019 #define CAP_BLOCK_SUSPEND 36
1022 #ifndef CAP_AUDIT_READ
1023 #define CAP_AUDIT_READ 37
1026 static inline int raw_clone(unsigned long flags, void *child_stack) {
1027 #if defined(__s390__) || defined(__CRIS__)
1028 /* On s390 and cris the order of the first and second arguments
1029 * of the raw clone() system call is reversed. */
1030 return (int) syscall(__NR_clone, child_stack, flags);
1032 return (int) syscall(__NR_clone, flags, child_stack);
1036 static inline pid_t raw_getpid(void) {
1037 #if defined(__alpha__)
1038 return (pid_t) syscall(__NR_getxpid);
1040 return (pid_t) syscall(__NR_getpid);
1044 #if 0 /// UNNEEDED by elogind
1046 #if !HAVE_DECL_RENAMEAT2
1049 #ifndef __NR_renameat2
1050 # if defined __x86_64__
1051 # define __NR_renameat2 316
1052 # elif defined __arm__
1053 # define __NR_renameat2 382
1054 # elif defined _MIPS_SIM
1055 # if _MIPS_SIM == _MIPS_SIM_ABI32
1056 # define __NR_renameat2 4351
1058 # if _MIPS_SIM == _MIPS_SIM_NABI32
1059 # define __NR_renameat2 6315
1061 # if _MIPS_SIM == _MIPS_SIM_ABI64
1062 # define __NR_renameat2 5311
1064 # elif defined __i386__
1065 # define __NR_renameat2 353
1067 # warning "__NR_renameat2 unknown for your architecture"
1068 # define __NR_renameat2 0xffffffff
1072 static inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) {
1073 return syscall(__NR_renameat2, oldfd, oldname, newfd, newname, flags);
1077 #ifndef RENAME_NOREPLACE
1078 #define RENAME_NOREPLACE (1 << 0)
1082 static inline int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) {
1083 #if defined(__NR_kcmp)
1084 return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2);
1096 #ifndef INPUT_PROP_POINTING_STICK
1097 #define INPUT_PROP_POINTING_STICK 0x05
1100 #ifndef INPUT_PROP_ACCELEROMETER
1101 #define INPUT_PROP_ACCELEROMETER 0x06
1104 #ifndef HAVE_KEY_SERIAL_T
1105 typedef int32_t key_serial_t;
1108 #if !HAVE_DECL_KEYCTL
1109 static inline long keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4,unsigned long arg5) {
1110 #if defined(__NR_keyctl)
1111 return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5);
1118 static inline key_serial_t add_key(const char *type, const char *description, const void *payload, size_t plen, key_serial_t ringid) {
1119 #if defined (__NR_add_key)
1120 return syscall(__NR_add_key, type, description, payload, plen, ringid);
1127 static inline key_serial_t request_key(const char *type, const char *description, const char * callout_info, key_serial_t destringid) {
1128 #if defined (__NR_request_key)
1129 return syscall(__NR_request_key, type, description, callout_info, destringid);
1138 #define KEYCTL_READ 11
1141 #ifndef KEYCTL_SET_TIMEOUT
1142 #define KEYCTL_SET_TIMEOUT 15
1145 #ifndef KEY_SPEC_USER_KEYRING
1146 #define KEY_SPEC_USER_KEYRING -4
1150 #ifndef PR_CAP_AMBIENT
1151 #define PR_CAP_AMBIENT 47
1154 #ifndef PR_CAP_AMBIENT_IS_SET
1155 #define PR_CAP_AMBIENT_IS_SET 1
1158 #ifndef PR_CAP_AMBIENT_RAISE
1159 #define PR_CAP_AMBIENT_RAISE 2
1162 #ifndef PR_CAP_AMBIENT_CLEAR_ALL
1163 #define PR_CAP_AMBIENT_CLEAR_ALL 4
1166 /* The following two defines are actually available in the kernel headers for longer, but we define them here anyway,
1167 * since that makes it easier to use them in conjunction with the glibc net/if.h header which conflicts with
1169 #ifndef IF_OPER_UNKNOWN
1170 #define IF_OPER_UNKNOWN 0
1174 #define IF_OPER_UP 6
1176 #ifndef HAVE_CHAR32_T
1177 #define char32_t uint32_t
1180 #ifndef HAVE_CHAR16_T
1181 #define char16_t uint16_t