]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/shared/missing.h
fstab-generator: ignore invalid swap priority
[thirdparty/systemd.git] / src / shared / missing.h
CommitLineData
03467c88 1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
15ae422b 2
c2f1db8f 3#pragma once
b9f880f4 4
15ae422b
LP
5/***
6 This file is part of systemd.
7
8 Copyright 2010 Lennart Poettering
9
10 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
11 under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
15ae422b
LP
13 (at your option) any later version.
14
15 systemd is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 18 Lesser General Public License for more details.
15ae422b 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
15ae422b
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
b9f880f4
LP
24/* Missing glibc definitions to access certain kernel APIs */
25
26#include <sys/resource.h>
15ae422b 27#include <sys/syscall.h>
16c42ce1 28#include <fcntl.h>
4db17f29 29#include <stdlib.h>
82c121a4 30#include <unistd.h>
3b794314 31#include <errno.h>
dd6c17b1 32#include <linux/oom.h>
118ecf32 33#include <linux/input.h>
d5eff740 34#include <linux/if_link.h>
a853c45d 35#include <linux/loop.h>
875c2e22 36#include <linux/audit.h>
2822da4f 37#include <linux/capability.h>
cf1755ba 38#include <linux/neighbour.h>
dd6c17b1
LP
39
40#ifdef HAVE_AUDIT
41#include <libaudit.h>
42#endif
b9f880f4 43
d59d0a2b 44#ifdef ARCH_MIPS
45#include <asm/sgidefs.h>
46#endif
47
700c6087
LP
48#ifdef HAVE_LINUX_BTRFS_H
49#include <linux/btrfs.h>
50#endif
51
a60e9f7f
LP
52#include "macro.h"
53
b9f880f4
LP
54#ifndef RLIMIT_RTTIME
55#define RLIMIT_RTTIME 15
56#endif
57
517d56b1
LP
58/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
59#define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
60
4fd5948e
LP
61#ifndef F_LINUX_SPECIFIC_BASE
62#define F_LINUX_SPECIFIC_BASE 1024
63#endif
64
65#ifndef F_SETPIPE_SZ
66#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
67#endif
68
69#ifndef F_GETPIPE_SZ
70#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
71#endif
72
a6082d77
DM
73#ifndef F_ADD_SEALS
74#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
a6082d77 75#define F_GET_SEALS (F_LINUX_SPECIFIC_BASE + 10)
a6082d77 76
a6082d77 77#define F_SEAL_SEAL 0x0001 /* prevent further seals from being set */
a6082d77 78#define F_SEAL_SHRINK 0x0002 /* prevent file from shrinking */
a6082d77 79#define F_SEAL_GROW 0x0004 /* prevent file from growing */
a6082d77
DM
80#define F_SEAL_WRITE 0x0008 /* prevent writes */
81#endif
82
f4a53250
MM
83#ifndef F_OFD_GETLK
84#define F_OFD_GETLK 36
85#define F_OFD_SETLK 37
86#define F_OFD_SETLKW 38
87#endif
88
a6082d77 89#ifndef MFD_ALLOW_SEALING
45071fca
LP
90#define MFD_ALLOW_SEALING 0x0002U
91#endif
92
93#ifndef MFD_CLOEXEC
94#define MFD_CLOEXEC 0x0001U
a6082d77
DM
95#endif
96
16c42ce1
KS
97#ifndef IP_FREEBIND
98#define IP_FREEBIND 15
99#endif
100
dd6c17b1
LP
101#ifndef OOM_SCORE_ADJ_MIN
102#define OOM_SCORE_ADJ_MIN (-1000)
103#endif
104
105#ifndef OOM_SCORE_ADJ_MAX
106#define OOM_SCORE_ADJ_MAX 1000
107#endif
15ae422b 108
4927fcae 109#ifndef AUDIT_SERVICE_START
dd6c17b1 110#define AUDIT_SERVICE_START 1130 /* Service (daemon) start */
4927fcae
LP
111#endif
112
113#ifndef AUDIT_SERVICE_STOP
dd6c17b1 114#define AUDIT_SERVICE_STOP 1131 /* Service (daemon) stop */
4927fcae
LP
115#endif
116
6ea832a2
LP
117#ifndef TIOCVHANGUP
118#define TIOCVHANGUP 0x5437
119#endif
120
b90865ba
KS
121#ifndef IP_TRANSPARENT
122#define IP_TRANSPARENT 19
123#endif
124
66269b05
TG
125#ifndef SOL_NETLINK
126#define SOL_NETLINK 270
127#endif
128
a8348796 129#if !HAVE_DECL_PIVOT_ROOT
dd6c17b1
LP
130static inline int pivot_root(const char *new_root, const char *put_old) {
131 return syscall(SYS_pivot_root, new_root, put_old);
132}
a8348796 133#endif
dd6c17b1 134
b244d9f3
LP
135#ifndef __NR_memfd_create
136# if defined __x86_64__
a6082d77 137# define __NR_memfd_create 319
b244d9f3 138# elif defined __arm__
a6082d77 139# define __NR_memfd_create 385
7fd68245
MO
140# elif defined __aarch64__
141# define __NR_memfd_create 279
b244d9f3 142# elif defined _MIPS_SIM
e6c01902
VOR
143# if _MIPS_SIM == _MIPS_SIM_ABI32
144# define __NR_memfd_create 4354
145# endif
146# if _MIPS_SIM == _MIPS_SIM_NABI32
147# define __NR_memfd_create 6318
148# endif
149# if _MIPS_SIM == _MIPS_SIM_ABI64
150# define __NR_memfd_create 5314
151# endif
03e8fdb3 152# elif defined __i386__
a6082d77 153# define __NR_memfd_create 356
03e8fdb3
DH
154# else
155# warning "__NR_memfd_create unknown for your architecture"
156# define __NR_memfd_create 0xffffffff
a6082d77 157# endif
22be093f
LP
158#endif
159
a6082d77 160#ifndef HAVE_MEMFD_CREATE
06b7f7bd 161static inline int memfd_create(const char *name, unsigned int flags) {
46327770 162 return syscall(__NR_memfd_create, name, flags);
a6082d77
DM
163}
164#endif
165
539618a0
LP
166#ifndef __NR_getrandom
167# if defined __x86_64__
74a550c5 168# define __NR_getrandom 318
568981d2
ZJS
169# elif defined(__i386__)
170# define __NR_getrandom 355
7fd68245 171# elif defined(__arm__)
568981d2 172# define __NR_getrandom 384
7fd68245
MO
173# elif defined(__aarch64__)
174# define __NR_getrandom 278
568981d2
ZJS
175# elif defined(__ia64__)
176# define __NR_getrandom 1339
177# elif defined(__m68k__)
178# define __NR_getrandom 352
179# elif defined(__s390x__)
180# define __NR_getrandom 349
d01efa07
MH
181# elif defined(__powerpc__)
182# define __NR_getrandom 359
3bec6d46
AK
183# elif defined _MIPS_SIM
184# if _MIPS_SIM == _MIPS_SIM_ABI32
185# define __NR_getrandom 4353
186# endif
187# if _MIPS_SIM == _MIPS_SIM_NABI32
188# define __NR_getrandom 6317
189# endif
190# if _MIPS_SIM == _MIPS_SIM_ABI64
191# define __NR_getrandom 5313
192# endif
539618a0
LP
193# else
194# warning "__NR_getrandom unknown for your architecture"
195# define __NR_getrandom 0xffffffff
196# endif
197#endif
198
199#if !HAVE_DECL_GETRANDOM
200static inline int getrandom(void *buffer, size_t count, unsigned flags) {
201 return syscall(__NR_getrandom, buffer, count, flags);
202}
203#endif
204
97768fc5
LP
205#ifndef GRND_NONBLOCK
206#define GRND_NONBLOCK 0x0001
207#endif
208
209#ifndef GRND_RANDOM
210#define GRND_RANDOM 0x0002
211#endif
212
4b357e15
MM
213#ifndef BTRFS_IOCTL_MAGIC
214#define BTRFS_IOCTL_MAGIC 0x94
215#endif
216
217#ifndef BTRFS_PATH_NAME_MAX
218#define BTRFS_PATH_NAME_MAX 4087
219#endif
220
221#ifndef BTRFS_DEVICE_PATH_NAME_MAX
222#define BTRFS_DEVICE_PATH_NAME_MAX 1024
223#endif
224
225#ifndef BTRFS_FSID_SIZE
226#define BTRFS_FSID_SIZE 16
227#endif
228
229#ifndef BTRFS_UUID_SIZE
230#define BTRFS_UUID_SIZE 16
231#endif
232
233#ifndef HAVE_LINUX_BTRFS_H
234struct btrfs_ioctl_vol_args {
235 int64_t fd;
236 char name[BTRFS_PATH_NAME_MAX + 1];
237};
238
239struct btrfs_ioctl_dev_info_args {
240 uint64_t devid; /* in/out */
241 uint8_t uuid[BTRFS_UUID_SIZE]; /* in/out */
242 uint64_t bytes_used; /* out */
243 uint64_t total_bytes; /* out */
244 uint64_t unused[379]; /* pad to 4k */
245 char path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
246};
247
248struct btrfs_ioctl_fs_info_args {
249 uint64_t max_id; /* out */
250 uint64_t num_devices; /* out */
251 uint8_t fsid[BTRFS_FSID_SIZE]; /* out */
252 uint64_t reserved[124]; /* pad to 1k */
253};
254#endif
255
256#ifndef BTRFS_IOC_DEFRAG
7bed7f0e
ZJS
257#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
258 struct btrfs_ioctl_vol_args)
4b357e15
MM
259#endif
260
261#ifndef BTRFS_IOC_DEV_INFO
262#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
263 struct btrfs_ioctl_dev_info_args)
264#endif
265
266#ifndef BTRFS_IOC_FS_INFO
267#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
7bed7f0e
ZJS
268 struct btrfs_ioctl_fs_info_args)
269#endif
270
271#ifndef BTRFS_IOC_DEVICES_READY
272#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
273 struct btrfs_ioctl_vol_args)
4b357e15
MM
274#endif
275
10f9c755
LP
276#ifndef BTRFS_FIRST_FREE_OBJECTID
277#define BTRFS_FIRST_FREE_OBJECTID 256
278#endif
279
b6b18498
LP
280#ifndef BTRFS_ROOT_TREE_OBJECTID
281#define BTRFS_ROOT_TREE_OBJECTID 1
282#endif
283
284#ifndef BTRFS_QUOTA_TREE_OBJECTID
285#define BTRFS_QUOTA_TREE_OBJECTID 8ULL
286#endif
287
10f9c755
LP
288#ifndef BTRFS_ROOT_ITEM_KEY
289#define BTRFS_ROOT_ITEM_KEY 132
290#endif
291
b6b18498
LP
292#ifndef BTRFS_QGROUP_STATUS_KEY
293#define BTRFS_QGROUP_STATUS_KEY 240
294#endif
295
296#ifndef BTRFS_QGROUP_INFO_KEY
297#define BTRFS_QGROUP_INFO_KEY 242
298#endif
299
300#ifndef BTRFS_QGROUP_LIMIT_KEY
301#define BTRFS_QGROUP_LIMIT_KEY 244
302#endif
303
746f8906
LP
304#ifndef BTRFS_SUPER_MAGIC
305#define BTRFS_SUPER_MAGIC 0x9123683E
306#endif
307
94d82985
LP
308#ifndef MS_MOVE
309#define MS_MOVE 8192
310#endif
311
7cb1094a
HH
312#ifndef MS_PRIVATE
313#define MS_PRIVATE (1 << 18)
314#endif
315
a8348796 316#if !HAVE_DECL_GETTID
4d14be09
LP
317static inline pid_t gettid(void) {
318 return (pid_t) syscall(SYS_gettid);
319}
a8348796 320#endif
4d14be09 321
54ecda32
LP
322#ifndef SCM_SECURITY
323#define SCM_SECURITY 0x03
324#endif
325
48ac500b
LP
326#ifndef MS_STRICTATIME
327#define MS_STRICTATIME (1<<24)
328#endif
329
a9621528
AM
330#ifndef MS_REC
331#define MS_REC 16384
332#endif
333
334#ifndef MS_SHARED
335#define MS_SHARED (1<<20)
336#endif
337
8351ceae
LP
338#ifndef PR_SET_NO_NEW_PRIVS
339#define PR_SET_NO_NEW_PRIVS 38
340#endif
d4447f4d
AK
341
342#ifndef PR_SET_CHILD_SUBREAPER
343#define PR_SET_CHILD_SUBREAPER 36
344#endif
a8348796
LP
345
346#ifndef MAX_HANDLE_SZ
347#define MAX_HANDLE_SZ 128
348#endif
349
66330455
LP
350#ifndef __NR_name_to_handle_at
351# if defined(__x86_64__)
848af055 352# define __NR_name_to_handle_at 303
66330455 353# elif defined(__i386__)
848af055 354# define __NR_name_to_handle_at 341
66330455 355# elif defined(__arm__)
f527b6b8 356# define __NR_name_to_handle_at 370
66330455 357# elif defined(__powerpc__)
f527b6b8 358# define __NR_name_to_handle_at 345
66330455
LP
359# else
360# error "__NR_name_to_handle_at is not defined"
f527b6b8 361# endif
a8348796
LP
362#endif
363
9388e99e 364#if !HAVE_DECL_NAME_TO_HANDLE_AT
a8348796
LP
365struct file_handle {
366 unsigned int handle_bytes;
367 int handle_type;
368 unsigned char f_handle[0];
369};
370
371static inline int name_to_handle_at(int fd, const char *name, struct file_handle *handle, int *mnt_id, int flags) {
372 return syscall(__NR_name_to_handle_at, fd, name, handle, mnt_id, flags);
373}
374#endif
4db17f29
ZJS
375
376#ifndef HAVE_SECURE_GETENV
377# ifdef HAVE___SECURE_GETENV
378# define secure_getenv __secure_getenv
379# else
66330455 380# error "neither secure_getenv nor __secure_getenv are available"
4db17f29
ZJS
381# endif
382#endif
85210bff
LP
383
384#ifndef CIFS_MAGIC_NUMBER
65b3903f 385# define CIFS_MAGIC_NUMBER 0xFF534D42
85210bff 386#endif
8742514c
LP
387
388#ifndef TFD_TIMER_CANCEL_ON_SET
65b3903f 389# define TFD_TIMER_CANCEL_ON_SET (1 << 1)
8742514c 390#endif
f7db7a69
SL
391
392#ifndef SO_REUSEPORT
65b3903f 393# define SO_REUSEPORT 15
f7db7a69 394#endif
118ecf32
DH
395
396#ifndef EVIOCREVOKE
65b3903f 397# define EVIOCREVOKE _IOW('E', 0x91, int)
118ecf32
DH
398#endif
399
400#ifndef DRM_IOCTL_SET_MASTER
65b3903f 401# define DRM_IOCTL_SET_MASTER _IO('d', 0x1e)
118ecf32
DH
402#endif
403
404#ifndef DRM_IOCTL_DROP_MASTER
65b3903f
ZJS
405# define DRM_IOCTL_DROP_MASTER _IO('d', 0x1f)
406#endif
407
c09918f9
LP
408#if defined(__i386__) || defined(__x86_64__)
409
410/* The precise definition of __O_TMPFILE is arch specific, so let's
411 * just define this on x86 where we know the value. */
412
413#ifndef __O_TMPFILE
414#define __O_TMPFILE 020000000
415#endif
416
417/* a horrid kludge trying to make sure that this will fail on old kernels */
418#ifndef O_TMPFILE
419#define O_TMPFILE (__O_TMPFILE | O_DIRECTORY)
420#endif
421
422#endif
3b794314
HS
423
424#ifndef __NR_setns
425# if defined(__x86_64__)
426# define __NR_setns 308
427# elif defined(__i386__)
428# define __NR_setns 346
429# else
430# error "__NR_setns is not defined"
431# endif
432#endif
433
434#if !HAVE_DECL_SETNS
435static inline int setns(int fd, int nstype) {
436 return syscall(__NR_setns, fd, nstype);
437}
438#endif
5f381b35
LP
439
440#if !HAVE_DECL_LO_FLAGS_PARTSCAN
441#define LO_FLAGS_PARTSCAN 8
442#endif
a853c45d
LP
443
444#ifndef LOOP_CTL_REMOVE
445#define LOOP_CTL_REMOVE 0x4C81
446#endif
447
448#ifndef LOOP_CTL_GET_FREE
449#define LOOP_CTL_GET_FREE 0x4C82
450#endif
0830ba61 451
84dd59b5
DH
452#if !HAVE_DECL_IFLA_INET6_ADDR_GEN_MODE
453#define IFLA_INET6_UNSPEC 0
454#define IFLA_INET6_FLAGS 1
455#define IFLA_INET6_CONF 2
456#define IFLA_INET6_STATS 3
457#define IFLA_INET6_MCAST 4
458#define IFLA_INET6_CACHEINFO 5
459#define IFLA_INET6_ICMP6STATS 6
460#define IFLA_INET6_TOKEN 7
461#define IFLA_INET6_ADDR_GEN_MODE 8
462#define __IFLA_INET6_MAX 9
463
464#define IFLA_INET6_MAX (__IFLA_INET6_MAX - 1)
465
466#define IN6_ADDR_GEN_MODE_EUI64 0
467#define IN6_ADDR_GEN_MODE_NONE 1
468#endif
469
75616a13
ZJS
470#if !HAVE_DECL_IFLA_MACVLAN_FLAGS
471#define IFLA_MACVLAN_UNSPEC 0
472#define IFLA_MACVLAN_MODE 1
473#define IFLA_MACVLAN_FLAGS 2
474#define __IFLA_MACVLAN_MAX 3
475
476#define IFLA_MACVLAN_MAX (__IFLA_MACVLAN_MAX - 1)
477#endif
478
c4a5ddc9
TG
479#if !HAVE_DECL_IFLA_IPVLAN_MODE
480#define IFLA_IPVLAN_UNSPEC 0
481#define IFLA_IPVLAN_MODE 1
482#define __IFLA_IPVLAN_MAX 2
483
484#define IFLA_IPVLAN_MAX (__IFLA_IPVLAN_MAX - 1)
485
486#define IPVLAN_MODE_L2 0
487#define IPVLAN_MODE_L3 1
488#define IPVLAN_MAX 2
489#endif
490
6589d0db
JAS
491#if !HAVE_DECL_IFLA_VTI_REMOTE
492#define IFLA_VTI_UNSPEC 0
493#define IFLA_VTI_LINK 1
494#define IFLA_VTI_IKEY 2
495#define IFLA_VTI_OKEY 3
496#define IFLA_VTI_LOCAL 4
497#define IFLA_VTI_REMOTE 5
498#define __IFLA_VTI_MAX 6
499
500#define IFLA_VTI_MAX (__IFLA_VTI_MAX - 1)
501#endif
502
81577dc2
ZJS
503#if !HAVE_DECL_IFLA_PHYS_PORT_ID
504#undef IFLA_PROMISCUITY
505#define IFLA_PROMISCUITY 30
506#define IFLA_NUM_TX_QUEUES 31
507#define IFLA_NUM_RX_QUEUES 32
508#define IFLA_CARRIER 33
509#define IFLA_PHYS_PORT_ID 34
510#define __IFLA_MAX 35
511
512#define IFLA_MAX (__IFLA_MAX - 1)
513#endif
514
515#if !HAVE_DECL_IFLA_BOND_AD_INFO
516#define IFLA_BOND_UNSPEC 0
517#define IFLA_BOND_MODE 1
518#define IFLA_BOND_ACTIVE_SLAVE 2
519#define IFLA_BOND_MIIMON 3
520#define IFLA_BOND_UPDELAY 4
521#define IFLA_BOND_DOWNDELAY 5
522#define IFLA_BOND_USE_CARRIER 6
523#define IFLA_BOND_ARP_INTERVAL 7
524#define IFLA_BOND_ARP_IP_TARGET 8
525#define IFLA_BOND_ARP_VALIDATE 9
526#define IFLA_BOND_ARP_ALL_TARGETS 10
527#define IFLA_BOND_PRIMARY 11
528#define IFLA_BOND_PRIMARY_RESELECT 12
529#define IFLA_BOND_FAIL_OVER_MAC 13
530#define IFLA_BOND_XMIT_HASH_POLICY 14
531#define IFLA_BOND_RESEND_IGMP 15
532#define IFLA_BOND_NUM_PEER_NOTIF 16
533#define IFLA_BOND_ALL_SLAVES_ACTIVE 17
534#define IFLA_BOND_MIN_LINKS 18
535#define IFLA_BOND_LP_INTERVAL 19
536#define IFLA_BOND_PACKETS_PER_SLAVE 20
537#define IFLA_BOND_AD_LACP_RATE 21
538#define IFLA_BOND_AD_SELECT 22
539#define IFLA_BOND_AD_INFO 23
540#define __IFLA_BOND_MAX 24
0830ba61 541
79306206 542#define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1)
0830ba61 543#endif
81577dc2
ZJS
544
545#if !HAVE_DECL_IFLA_VLAN_PROTOCOL
546#define IFLA_VLAN_UNSPEC 0
547#define IFLA_VLAN_ID 1
548#define IFLA_VLAN_FLAGS 2
549#define IFLA_VLAN_EGRESS_QOS 3
550#define IFLA_VLAN_INGRESS_QOS 4
551#define IFLA_VLAN_PROTOCOL 5
552#define __IFLA_VLAN_MAX 6
553
554#define IFLA_VLAN_MAX (__IFLA_VLAN_MAX - 1)
555#endif
556
557#if !HAVE_DECL_IFLA_VXLAN_LOCAL6
558#define IFLA_VXLAN_UNSPEC 0
559#define IFLA_VXLAN_ID 1
560#define IFLA_VXLAN_GROUP 2
561#define IFLA_VXLAN_LINK 3
562#define IFLA_VXLAN_LOCAL 4
563#define IFLA_VXLAN_TTL 5
564#define IFLA_VXLAN_TOS 6
565#define IFLA_VXLAN_LEARNING 7
566#define IFLA_VXLAN_AGEING 8
567#define IFLA_VXLAN_LIMIT 9
568#define IFLA_VXLAN_PORT_RANGE 10
569#define IFLA_VXLAN_PROXY 11
570#define IFLA_VXLAN_RSC 12
571#define IFLA_VXLAN_L2MISS 13
572#define IFLA_VXLAN_L3MISS 14
573#define IFLA_VXLAN_PORT 15
574#define IFLA_VXLAN_GROUP6 16
575#define IFLA_VXLAN_LOCAL6 17
576#define __IFLA_VXLAN_MAX 18
577
578#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
579#endif
580
581#if !HAVE_DECL_IFLA_IPTUN_6RD_RELAY_PREFIXLEN
582#define IFLA_IPTUN_UNSPEC 0
583#define IFLA_IPTUN_LINK 1
584#define IFLA_IPTUN_LOCAL 2
585#define IFLA_IPTUN_REMOTE 3
586#define IFLA_IPTUN_TTL 4
587#define IFLA_IPTUN_TOS 5
588#define IFLA_IPTUN_ENCAP_LIMIT 6
589#define IFLA_IPTUN_FLOWINFO 7
590#define IFLA_IPTUN_FLAGS 8
591#define IFLA_IPTUN_PROTO 9
592#define IFLA_IPTUN_PMTUDISC 10
593#define IFLA_IPTUN_6RD_PREFIX 11
594#define IFLA_IPTUN_6RD_RELAY_PREFIX 12
595#define IFLA_IPTUN_6RD_PREFIXLEN 13
596#define IFLA_IPTUN_6RD_RELAY_PREFIXLEN 14
597#define __IFLA_IPTUN_MAX 15
598
599#define IFLA_IPTUN_MAX (__IFLA_IPTUN_MAX - 1)
600#endif
601
602#if !HAVE_DECL_IFLA_BRIDGE_VLAN_INFO
603#define IFLA_BRIDGE_FLAGS 0
604#define IFLA_BRIDGE_MODE 1
605#define IFLA_BRIDGE_VLAN_INFO 2
606#define __IFLA_BRIDGE_MAX 3
607
608#define IFLA_BRIDGE_MAX (__IFLA_BRIDGE_MAX - 1)
609#endif
623a4c97 610
8ecec322
ZJS
611#if !HAVE_DECL_IFLA_BRPORT_UNICAST_FLOOD
612#define IFLA_BRPORT_UNSPEC 0
613#define IFLA_BRPORT_STATE 1
614#define IFLA_BRPORT_PRIORITY 2
615#define IFLA_BRPORT_COST 3
616#define IFLA_BRPORT_MODE 4
617#define IFLA_BRPORT_GUARD 5
618#define IFLA_BRPORT_PROTECT 6
619#define IFLA_BRPORT_FAST_LEAVE 7
620#define IFLA_BRPORT_LEARNING 8
621#define IFLA_BRPORT_UNICAST_FLOOD 9
622#define __IFLA_BRPORT_MAX 10
623
624#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
625#endif
626
cf1755ba
MO
627#if !HAVE_DECL_NDA_IFINDEX
628#define NDA_UNSPEC 0
629#define NDA_DST 1
630#define NDA_LLADDR 2
631#define NDA_CACHEINFO 3
632#define NDA_PROBES 4
633#define NDA_VLAN 5
634#define NDA_PORT 6
635#define NDA_VNI 7
636#define NDA_IFINDEX 8
637#define __NDA_MAX 9
638
639#define NDA_MAX (__NDA_MAX - 1)
640#endif
641
623a4c97
LP
642#ifndef IPV6_UNICAST_IF
643#define IPV6_UNICAST_IF 76
644#endif
ec2c5e43 645
04d180c8
TG
646#ifndef IFF_MULTI_QUEUE
647#define IFF_MULTI_QUEUE 0x100
648#endif
649
ec2c5e43
LP
650#ifndef IFF_LOWER_UP
651#define IFF_LOWER_UP 0x10000
652#endif
653
654#ifndef IFF_DORMANT
655#define IFF_DORMANT 0x20000
656#endif
91988149
LP
657
658#ifndef BOND_XMIT_POLICY_ENCAP23
659#define BOND_XMIT_POLICY_ENCAP23 3
660#endif
661
662#ifndef BOND_XMIT_POLICY_ENCAP34
663#define BOND_XMIT_POLICY_ENCAP34 4
664#endif
04b67d49
TG
665
666#ifndef NET_ADDR_RANDOM
667# define NET_ADDR_RANDOM 1
668#endif
669
1cb636d9
CW
670#ifndef NET_NAME_UNKNOWN
671# define NET_NAME_UNKNOWN 0
672#endif
673
04b67d49
TG
674#ifndef NET_NAME_ENUM
675# define NET_NAME_ENUM 1
676#endif
677
678#ifndef NET_NAME_PREDICTABLE
679# define NET_NAME_PREDICTABLE 2
680#endif
681
682#ifndef NET_NAME_USER
683# define NET_NAME_USER 3
684#endif
685
686#ifndef NET_NAME_RENAMED
687# define NET_NAME_RENAMED 4
688#endif
7965435e
MO
689
690#ifndef BPF_XOR
691# define BPF_XOR 0xa0
692#endif
a5f03596
LP
693
694/* Note that LOOPBACK_IFINDEX is currently not exported by the
695 * kernel/glibc, but hardcoded internally by the kernel. However, as
696 * it is exported to userspace indirectly via rtnetlink and the
697 * ioctls, and made use of widely we define it here too, in a way that
698 * is compatible with the kernel's internal definition. */
699#ifndef LOOPBACK_IFINDEX
700#define LOOPBACK_IFINDEX 1
701#endif
875c2e22
LP
702
703#ifndef MAX_AUDIT_MESSAGE_LENGTH
704#define MAX_AUDIT_MESSAGE_LENGTH 8970
705#endif
706
707#ifndef AUDIT_NLGRP_MAX
708#define AUDIT_NLGRP_READLOG 1
709#endif
2822da4f
LP
710
711#ifndef CAP_MAC_OVERRIDE
712#define CAP_MAC_OVERRIDE 32
713#endif
714
715#ifndef CAP_MAC_ADMIN
716#define CAP_MAC_ADMIN 33
717#endif
718
719#ifndef CAP_SYSLOG
720#define CAP_SYSLOG 34
721#endif
722
723#ifndef CAP_WAKE_ALARM
724#define CAP_WAKE_ALARM 35
725#endif
726
727#ifndef CAP_BLOCK_SUSPEND
728#define CAP_BLOCK_SUSPEND 36
729#endif
730
731#ifndef CAP_AUDIT_READ
732#define CAP_AUDIT_READ 37
733#endif
60e1651a 734
ee05e779 735static inline int raw_clone(unsigned long flags, void *child_stack) {
60e1651a
KW
736#if defined(__s390__) || defined(__CRIS__)
737 /* On s390 and cris the order of the first and second arguments
738 * of the raw clone() system call is reversed. */
ee05e779 739 return (int) syscall(__NR_clone, child_stack, flags);
60e1651a 740#else
ee05e779 741 return (int) syscall(__NR_clone, flags, child_stack);
60e1651a
KW
742#endif
743}
ee05e779
ZJS
744
745static inline pid_t raw_getpid(void) {
746 return (pid_t) syscall(__NR_getpid);
747}
ebd93cb6
LP
748
749#if !HAVE_DECL_RENAMEAT2
e65ef51d
ZJS
750
751#ifndef __NR_renameat2
752# if defined __x86_64__
753# define __NR_renameat2 316
754# elif defined __arm__
755# define __NR_renameat2 382
756# elif defined _MIPS_SIM
757# if _MIPS_SIM == _MIPS_SIM_ABI32
758# define __NR_renameat2 4351
759# endif
760# if _MIPS_SIM == _MIPS_SIM_NABI32
761# define __NR_renameat2 6315
762# endif
763# if _MIPS_SIM == _MIPS_SIM_ABI64
764# define __NR_renameat2 5311
765# endif
766# elif defined __i386__
767# define __NR_renameat2 353
768# else
769# warning "__NR_renameat2 unknown for your architecture"
770# define __NR_renameat2 0xffffffff
771# endif
772#endif
773
ebd93cb6
LP
774static inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) {
775 return syscall(__NR_renameat2, oldfd, oldname, newfd, newname, flags);
776}
777#endif
778
779#ifndef RENAME_NOREPLACE
780#define RENAME_NOREPLACE (1 << 0)
781#endif
f7ad54a3
LP
782
783#if !HAVE_DECL_KCMP
784static inline int kcmp(pid_t pid1, pid_t pid2, int type, unsigned long idx1, unsigned long idx2) {
785 return syscall(__NR_kcmp, pid1, pid2, type, idx1, idx2);
786}
787#endif
788
789#ifndef KCMP_FILE
790#define KCMP_FILE 0
791#endif