History

tools include: Add headers to make tools builds more hermetic

tools/lib/bpf/netlink.c depends on rtnetlink.h and genetlink.h (via nlattr.h) which then depends on if_addr.h. tools/bpf/bpftool/link.c depends on netfilter_arp.h which then depends on netfilter.h. Update check-headers.sh to keep these in sync.

Ian Rogers committed 1 year ago

Commit f0015d81 parent 57a64917 files · +1369 −1Browse files

Showing the changes to tools/include/uapi/linux (6 of 7 files). Show all

Unified · Split

6 files
  1. tools/include/uapi/linux/genetlink.h +103 −0
  2. tools/include/uapi/linux/if_addr.h +79 −0
  3. tools/include/uapi/linux/neighbour.h +229 −0
  4. tools/include/uapi/linux/netfilter.h +80 −0
  5. tools/include/uapi/linux/netfilter_arp.h +23 −0
  6. tools/include/uapi/linux/rtnetlink.h +848 −0
tools/include/uapi/linux/genetlink.h+103−0
@@ -0,0 +1,103 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+#ifndef _UAPI__LINUX_GENERIC_NETLINK_H
3+#define _UAPI__LINUX_GENERIC_NETLINK_H
4+
5+#include <linux/types.h>
6+#include <linux/netlink.h>
7+
8+#define GENL_NAMSIZ 16 /* length of family name */
9+
10+#define GENL_MIN_ID NLMSG_MIN_TYPE
11+#define GENL_MAX_ID 1023
12+
13+struct genlmsghdr {
14+ __u8 cmd;
15+ __u8 version;
16+ __u16 reserved;
17+};
18+
19+#define GENL_HDRLEN NLMSG_ALIGN(sizeof(struct genlmsghdr))
20+
21+#define GENL_ADMIN_PERM 0x01
22+#define GENL_CMD_CAP_DO 0x02
23+#define GENL_CMD_CAP_DUMP 0x04
24+#define GENL_CMD_CAP_HASPOL 0x08
25+#define GENL_UNS_ADMIN_PERM 0x10
26+
27+/*
28+ * List of reserved static generic netlink identifiers:
29+ */
30+#define GENL_ID_CTRL NLMSG_MIN_TYPE
31+#define GENL_ID_VFS_DQUOT (NLMSG_MIN_TYPE + 1)
32+#define GENL_ID_PMCRAID (NLMSG_MIN_TYPE + 2)
33+/* must be last reserved + 1 */
34+#define GENL_START_ALLOC (NLMSG_MIN_TYPE + 3)
35+
36+/**************************************************************************
37+ * Controller
38+ **************************************************************************/
39+
40+enum {
41+ CTRL_CMD_UNSPEC,
42+ CTRL_CMD_NEWFAMILY,
43+ CTRL_CMD_DELFAMILY,
44+ CTRL_CMD_GETFAMILY,
45+ CTRL_CMD_NEWOPS,
46+ CTRL_CMD_DELOPS,
47+ CTRL_CMD_GETOPS,
48+ CTRL_CMD_NEWMCAST_GRP,
49+ CTRL_CMD_DELMCAST_GRP,
50+ CTRL_CMD_GETMCAST_GRP, /* unused */
51+ CTRL_CMD_GETPOLICY,
52+ __CTRL_CMD_MAX,
53+};
54+
55+#define CTRL_CMD_MAX (__CTRL_CMD_MAX - 1)
56+
57+enum {
58+ CTRL_ATTR_UNSPEC,
59+ CTRL_ATTR_FAMILY_ID,
60+ CTRL_ATTR_FAMILY_NAME,
61+ CTRL_ATTR_VERSION,
62+ CTRL_ATTR_HDRSIZE,
63+ CTRL_ATTR_MAXATTR,
64+ CTRL_ATTR_OPS,
65+ CTRL_ATTR_MCAST_GROUPS,
66+ CTRL_ATTR_POLICY,
67+ CTRL_ATTR_OP_POLICY,
68+ CTRL_ATTR_OP,
69+ __CTRL_ATTR_MAX,
70+};
71+
72+#define CTRL_ATTR_MAX (__CTRL_ATTR_MAX - 1)
73+
74+enum {
75+ CTRL_ATTR_OP_UNSPEC,
76+ CTRL_ATTR_OP_ID,
77+ CTRL_ATTR_OP_FLAGS,
78+ __CTRL_ATTR_OP_MAX,
79+};
80+
81+#define CTRL_ATTR_OP_MAX (__CTRL_ATTR_OP_MAX - 1)
82+
83+enum {
84+ CTRL_ATTR_MCAST_GRP_UNSPEC,
85+ CTRL_ATTR_MCAST_GRP_NAME,
86+ CTRL_ATTR_MCAST_GRP_ID,
87+ __CTRL_ATTR_MCAST_GRP_MAX,
88+};
89+
90+#define CTRL_ATTR_MCAST_GRP_MAX (__CTRL_ATTR_MCAST_GRP_MAX - 1)
91+
92+enum {
93+ CTRL_ATTR_POLICY_UNSPEC,
94+ CTRL_ATTR_POLICY_DO,
95+ CTRL_ATTR_POLICY_DUMP,
96+
97+ __CTRL_ATTR_POLICY_DUMP_MAX,
98+ CTRL_ATTR_POLICY_DUMP_MAX = __CTRL_ATTR_POLICY_DUMP_MAX - 1
99+};
100+
101+#define CTRL_ATTR_POLICY_MAX (__CTRL_ATTR_POLICY_DUMP_MAX - 1)
102+
103+#endif /* _UAPI__LINUX_GENERIC_NETLINK_H */
tools/include/uapi/linux/if_addr.h+79−0
@@ -0,0 +1,79 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+#ifndef _UAPI__LINUX_IF_ADDR_H
3+#define _UAPI__LINUX_IF_ADDR_H
4+
5+#include <linux/types.h>
6+#include <linux/netlink.h>
7+
8+struct ifaddrmsg {
9+ __u8 ifa_family;
10+ __u8 ifa_prefixlen; /* The prefix length */
11+ __u8 ifa_flags; /* Flags */
12+ __u8 ifa_scope; /* Address scope */
13+ __u32 ifa_index; /* Link index */
14+};
15+
16+/*
17+ * Important comment:
18+ * IFA_ADDRESS is prefix address, rather than local interface address.
19+ * It makes no difference for normally configured broadcast interfaces,
20+ * but for point-to-point IFA_ADDRESS is DESTINATION address,
21+ * local address is supplied in IFA_LOCAL attribute.
22+ *
23+ * IFA_FLAGS is a u32 attribute that extends the u8 field ifa_flags.
24+ * If present, the value from struct ifaddrmsg will be ignored.
25+ */
26+enum {
27+ IFA_UNSPEC,
28+ IFA_ADDRESS,
29+ IFA_LOCAL,
30+ IFA_LABEL,
31+ IFA_BROADCAST,
32+ IFA_ANYCAST,
33+ IFA_CACHEINFO,
34+ IFA_MULTICAST,
35+ IFA_FLAGS,
36+ IFA_RT_PRIORITY, /* u32, priority/metric for prefix route */
37+ IFA_TARGET_NETNSID,
38+ IFA_PROTO, /* u8, address protocol */
39+ __IFA_MAX,
40+};
41+
42+#define IFA_MAX (__IFA_MAX - 1)
43+
44+/* ifa_flags */
45+#define IFA_F_SECONDARY 0x01
46+#define IFA_F_TEMPORARY IFA_F_SECONDARY
47+
48+#define IFA_F_NODAD 0x02
49+#define IFA_F_OPTIMISTIC 0x04
50+#define IFA_F_DADFAILED 0x08
51+#define IFA_F_HOMEADDRESS 0x10
52+#define IFA_F_DEPRECATED 0x20
53+#define IFA_F_TENTATIVE 0x40
54+#define IFA_F_PERMANENT 0x80
55+#define IFA_F_MANAGETEMPADDR 0x100
56+#define IFA_F_NOPREFIXROUTE 0x200
57+#define IFA_F_MCAUTOJOIN 0x400
58+#define IFA_F_STABLE_PRIVACY 0x800
59+
60+struct ifa_cacheinfo {
61+ __u32 ifa_prefered;
62+ __u32 ifa_valid;
63+ __u32 cstamp; /* created timestamp, hundredths of seconds */
64+ __u32 tstamp; /* updated timestamp, hundredths of seconds */
65+};
66+
67+/* backwards compatibility for userspace */
68+#ifndef __KERNEL__
69+#define IFA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct ifaddrmsg))))
70+#define IFA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct ifaddrmsg))
71+#endif
72+
73+/* ifa_proto */
74+#define IFAPROT_UNSPEC 0
75+#define IFAPROT_KERNEL_LO 1 /* loopback */
76+#define IFAPROT_KERNEL_RA 2 /* set by kernel from router announcement */
77+#define IFAPROT_KERNEL_LL 3 /* link-local set by kernel */
78+
79+#endif
tools/include/uapi/linux/neighbour.h+229−0
@@ -0,0 +1,229 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+#ifndef _UAPI__LINUX_NEIGHBOUR_H
3+#define _UAPI__LINUX_NEIGHBOUR_H
4+
5+#include <linux/types.h>
6+#include <linux/netlink.h>
7+
8+struct ndmsg {
9+ __u8 ndm_family;
10+ __u8 ndm_pad1;
11+ __u16 ndm_pad2;
12+ __s32 ndm_ifindex;
13+ __u16 ndm_state;
14+ __u8 ndm_flags;
15+ __u8 ndm_type;
16+};
17+
18+enum {
19+ NDA_UNSPEC,
20+ NDA_DST,
21+ NDA_LLADDR,
22+ NDA_CACHEINFO,
23+ NDA_PROBES,
24+ NDA_VLAN,
25+ NDA_PORT,
26+ NDA_VNI,
27+ NDA_IFINDEX,
28+ NDA_MASTER,
29+ NDA_LINK_NETNSID,
30+ NDA_SRC_VNI,
31+ NDA_PROTOCOL, /* Originator of entry */
32+ NDA_NH_ID,
33+ NDA_FDB_EXT_ATTRS,
34+ NDA_FLAGS_EXT,
35+ NDA_NDM_STATE_MASK,
36+ NDA_NDM_FLAGS_MASK,
37+ __NDA_MAX
38+};
39+
40+#define NDA_MAX (__NDA_MAX - 1)
41+
42+/*
43+ * Neighbor Cache Entry Flags
44+ */
45+
46+#define NTF_USE (1 << 0)
47+#define NTF_SELF (1 << 1)
48+#define NTF_MASTER (1 << 2)
49+#define NTF_PROXY (1 << 3) /* == ATF_PUBL */
50+#define NTF_EXT_LEARNED (1 << 4)
51+#define NTF_OFFLOADED (1 << 5)
52+#define NTF_STICKY (1 << 6)
53+#define NTF_ROUTER (1 << 7)
54+/* Extended flags under NDA_FLAGS_EXT: */
55+#define NTF_EXT_MANAGED (1 << 0)
56+#define NTF_EXT_LOCKED (1 << 1)
57+#define NTF_EXT_EXT_VALIDATED (1 << 2)
58+
59+/*
60+ * Neighbor Cache Entry States.
61+ */
62+
63+#define NUD_INCOMPLETE 0x01
64+#define NUD_REACHABLE 0x02
65+#define NUD_STALE 0x04
66+#define NUD_DELAY 0x08
67+#define NUD_PROBE 0x10
68+#define NUD_FAILED 0x20
69+
70+/* Dummy states */
71+#define NUD_NOARP 0x40
72+#define NUD_PERMANENT 0x80
73+#define NUD_NONE 0x00
74+
75+/* NUD_NOARP & NUD_PERMANENT are pseudostates, they never change and make no
76+ * address resolution or NUD.
77+ *
78+ * NUD_PERMANENT also cannot be deleted by garbage collectors. This holds true
79+ * for dynamic entries with NTF_EXT_LEARNED flag as well. However, upon carrier
80+ * down event, NUD_PERMANENT entries are not flushed whereas NTF_EXT_LEARNED
81+ * flagged entries explicitly are (which is also consistent with the routing
82+ * subsystem).
83+ *
84+ * When NTF_EXT_LEARNED is set for a bridge fdb entry the different cache entry
85+ * states don't make sense and thus are ignored. Such entries don't age and
86+ * can roam.
87+ *
88+ * NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf
89+ * of a user space control plane, and automatically refreshed so that (if
90+ * possible) they remain in NUD_REACHABLE state.
91+ *
92+ * NTF_EXT_LOCKED flagged bridge FDB entries are entries generated by the
93+ * bridge in response to a host trying to communicate via a locked bridge port
94+ * with MAB enabled. Their purpose is to notify user space that a host requires
95+ * authentication.
96+ *
97+ * NTF_EXT_EXT_VALIDATED flagged neighbor entries were externally validated by
98+ * a user space control plane. The kernel will not remove or invalidate them,
99+ * but it can probe them and notify user space when they become reachable.
100+ */
101+
102+struct nda_cacheinfo {
103+ __u32 ndm_confirmed;
104+ __u32 ndm_used;
105+ __u32 ndm_updated;
106+ __u32 ndm_refcnt;
107+};
108+
109+/*****************************************************************
110+ * Neighbour tables specific messages.
111+ *
112+ * To retrieve the neighbour tables send RTM_GETNEIGHTBL with the
113+ * NLM_F_DUMP flag set. Every neighbour table configuration is
114+ * spread over multiple messages to avoid running into message
115+ * size limits on systems with many interfaces. The first message
116+ * in the sequence transports all not device specific data such as
117+ * statistics, configuration, and the default parameter set.
118+ * This message is followed by 0..n messages carrying device
119+ * specific parameter sets.
120+ * Although the ordering should be sufficient, NDTA_NAME can be
121+ * used to identify sequences. The initial message can be identified
122+ * by checking for NDTA_CONFIG. The device specific messages do
123+ * not contain this TLV but have NDTPA_IFINDEX set to the
124+ * corresponding interface index.
125+ *
126+ * To change neighbour table attributes, send RTM_SETNEIGHTBL
127+ * with NDTA_NAME set. Changeable attribute include NDTA_THRESH[1-3],
128+ * NDTA_GC_INTERVAL, and all TLVs in NDTA_PARMS unless marked
129+ * otherwise. Device specific parameter sets can be changed by
130+ * setting NDTPA_IFINDEX to the interface index of the corresponding
131+ * device.
132+ ****/
133+
134+struct ndt_stats {
135+ __u64 ndts_allocs;
136+ __u64 ndts_destroys;
137+ __u64 ndts_hash_grows;
138+ __u64 ndts_res_failed;
139+ __u64 ndts_lookups;
140+ __u64 ndts_hits;
141+ __u64 ndts_rcv_probes_mcast;
142+ __u64 ndts_rcv_probes_ucast;
143+ __u64 ndts_periodic_gc_runs;
144+ __u64 ndts_forced_gc_runs;
145+ __u64 ndts_table_fulls;
146+};
147+
148+enum {
149+ NDTPA_UNSPEC,
150+ NDTPA_IFINDEX, /* u32, unchangeable */
151+ NDTPA_REFCNT, /* u32, read-only */
152+ NDTPA_REACHABLE_TIME, /* u64, read-only, msecs */
153+ NDTPA_BASE_REACHABLE_TIME, /* u64, msecs */
154+ NDTPA_RETRANS_TIME, /* u64, msecs */
155+ NDTPA_GC_STALETIME, /* u64, msecs */
156+ NDTPA_DELAY_PROBE_TIME, /* u64, msecs */
157+ NDTPA_QUEUE_LEN, /* u32 */
158+ NDTPA_APP_PROBES, /* u32 */
159+ NDTPA_UCAST_PROBES, /* u32 */
160+ NDTPA_MCAST_PROBES, /* u32 */
161+ NDTPA_ANYCAST_DELAY, /* u64, msecs */
162+ NDTPA_PROXY_DELAY, /* u64, msecs */
163+ NDTPA_PROXY_QLEN, /* u32 */
164+ NDTPA_LOCKTIME, /* u64, msecs */
165+ NDTPA_QUEUE_LENBYTES, /* u32 */
166+ NDTPA_MCAST_REPROBES, /* u32 */
167+ NDTPA_PAD,
168+ NDTPA_INTERVAL_PROBE_TIME_MS, /* u64, msecs */
169+ __NDTPA_MAX
170+};
171+#define NDTPA_MAX (__NDTPA_MAX - 1)
172+
173+struct ndtmsg {
174+ __u8 ndtm_family;
175+ __u8 ndtm_pad1;
176+ __u16 ndtm_pad2;
177+};
178+
179+struct ndt_config {
180+ __u16 ndtc_key_len;
181+ __u16 ndtc_entry_size;
182+ __u32 ndtc_entries;
183+ __u32 ndtc_last_flush; /* delta to now in msecs */
184+ __u32 ndtc_last_rand; /* delta to now in msecs */
185+ __u32 ndtc_hash_rnd;
186+ __u32 ndtc_hash_mask;
187+ __u32 ndtc_hash_chain_gc;
188+ __u32 ndtc_proxy_qlen;
189+};
190+
191+enum {
192+ NDTA_UNSPEC,
193+ NDTA_NAME, /* char *, unchangeable */
194+ NDTA_THRESH1, /* u32 */
195+ NDTA_THRESH2, /* u32 */
196+ NDTA_THRESH3, /* u32 */
197+ NDTA_CONFIG, /* struct ndt_config, read-only */
198+ NDTA_PARMS, /* nested TLV NDTPA_* */
199+ NDTA_STATS, /* struct ndt_stats, read-only */
200+ NDTA_GC_INTERVAL, /* u64, msecs */
201+ NDTA_PAD,
202+ __NDTA_MAX
203+};
204+#define NDTA_MAX (__NDTA_MAX - 1)
205+
206+ /* FDB activity notification bits used in NFEA_ACTIVITY_NOTIFY:
207+ * - FDB_NOTIFY_BIT - notify on activity/expire for any entry
208+ * - FDB_NOTIFY_INACTIVE_BIT - mark as inactive to avoid multiple notifications
209+ */
210+enum {
211+ FDB_NOTIFY_BIT = (1 << 0),
212+ FDB_NOTIFY_INACTIVE_BIT = (1 << 1)
213+};
214+
215+/* embedded into NDA_FDB_EXT_ATTRS:
216+ * [NDA_FDB_EXT_ATTRS] = {
217+ * [NFEA_ACTIVITY_NOTIFY]
218+ * ...
219+ * }
220+ */
221+enum {
222+ NFEA_UNSPEC,
223+ NFEA_ACTIVITY_NOTIFY,
224+ NFEA_DONT_REFRESH,
225+ __NFEA_MAX
226+};
227+#define NFEA_MAX (__NFEA_MAX - 1)
228+
229+#endif
tools/include/uapi/linux/netfilter.h+80−0
@@ -0,0 +1,80 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+#ifndef _UAPI__LINUX_NETFILTER_H
3+#define _UAPI__LINUX_NETFILTER_H
4+
5+#include <linux/types.h>
6+#include <linux/compiler.h>
7+#include <linux/in.h>
8+#include <linux/in6.h>
9+
10+/* Responses from hook functions. */
11+#define NF_DROP 0
12+#define NF_ACCEPT 1
13+#define NF_STOLEN 2
14+#define NF_QUEUE 3
15+#define NF_REPEAT 4
16+#define NF_STOP 5 /* Deprecated, for userspace nf_queue compatibility. */
17+#define NF_MAX_VERDICT NF_STOP
18+
19+/* we overload the higher bits for encoding auxiliary data such as the queue
20+ * number or errno values. Not nice, but better than additional function
21+ * arguments. */
22+#define NF_VERDICT_MASK 0x000000ff
23+
24+/* extra verdict flags have mask 0x0000ff00 */
25+#define NF_VERDICT_FLAG_QUEUE_BYPASS 0x00008000
26+
27+/* queue number (NF_QUEUE) or errno (NF_DROP) */
28+#define NF_VERDICT_QMASK 0xffff0000
29+#define NF_VERDICT_QBITS 16
30+
31+#define NF_QUEUE_NR(x) ((((x) << 16) & NF_VERDICT_QMASK) | NF_QUEUE)
32+
33+#define NF_DROP_ERR(x) (((-x) << 16) | NF_DROP)
34+
35+/* only for userspace compatibility */
36+#ifndef __KERNEL__
37+
38+/* NF_VERDICT_BITS should be 8 now, but userspace might break if this changes */
39+#define NF_VERDICT_BITS 16
40+#endif
41+
42+enum nf_inet_hooks {
43+ NF_INET_PRE_ROUTING,
44+ NF_INET_LOCAL_IN,
45+ NF_INET_FORWARD,
46+ NF_INET_LOCAL_OUT,
47+ NF_INET_POST_ROUTING,
48+ NF_INET_NUMHOOKS,
49+ NF_INET_INGRESS = NF_INET_NUMHOOKS,
50+};
51+
52+enum nf_dev_hooks {
53+ NF_NETDEV_INGRESS,
54+ NF_NETDEV_EGRESS,
55+ NF_NETDEV_NUMHOOKS
56+};
57+
58+enum {
59+ NFPROTO_UNSPEC = 0,
60+ NFPROTO_INET = 1,
61+ NFPROTO_IPV4 = 2,
62+ NFPROTO_ARP = 3,
63+ NFPROTO_NETDEV = 5,
64+ NFPROTO_BRIDGE = 7,
65+ NFPROTO_IPV6 = 10,
66+#ifndef __KERNEL__ /* no longer supported by kernel */
67+ NFPROTO_DECNET = 12,
68+#endif
69+ NFPROTO_NUMPROTO,
70+};
71+
72+union nf_inet_addr {
73+ __u32 all[4];
74+ __be32 ip;
75+ __be32 ip6[4];
76+ struct in_addr in;
77+ struct in6_addr in6;
78+};
79+
80+#endif /* _UAPI__LINUX_NETFILTER_H */
tools/include/uapi/linux/netfilter_arp.h+23−0
@@ -0,0 +1,23 @@
1+/* SPDX-License-Identifier: GPL-1.0+ WITH Linux-syscall-note */
2+#ifndef __LINUX_ARP_NETFILTER_H
3+#define __LINUX_ARP_NETFILTER_H
4+
5+/* ARP-specific defines for netfilter.
6+ * (C)2002 Rusty Russell IBM -- This code is GPL.
7+ */
8+
9+#include <linux/netfilter.h>
10+
11+/* There is no PF_ARP. */
12+#define NF_ARP 0
13+
14+/* ARP Hooks */
15+#define NF_ARP_IN 0
16+#define NF_ARP_OUT 1
17+#define NF_ARP_FORWARD 2
18+
19+#ifndef __KERNEL__
20+#define NF_ARP_NUMHOOKS 3
21+#endif
22+
23+#endif /* __LINUX_ARP_NETFILTER_H */
tools/include/uapi/linux/rtnetlink.h+848−0
@@ -0,0 +1,848 @@
1+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2+#ifndef _UAPI__LINUX_RTNETLINK_H
3+#define _UAPI__LINUX_RTNETLINK_H
4+
5+#include <linux/types.h>
6+#include <linux/netlink.h>
7+#include <linux/if_link.h>
8+#include <linux/if_addr.h>
9+#include <linux/neighbour.h>
10+
11+/* rtnetlink families. Values up to 127 are reserved for real address
12+ * families, values above 128 may be used arbitrarily.
13+ */
14+#define RTNL_FAMILY_IPMR 128
15+#define RTNL_FAMILY_IP6MR 129
16+#define RTNL_FAMILY_MAX 129
17+
18+/****
19+ * Routing/neighbour discovery messages.
20+ ****/
21+
22+/* Types of messages */
23+
24+enum {
25+ RTM_BASE = 16,
26+#define RTM_BASE RTM_BASE
27+
28+ RTM_NEWLINK = 16,
29+#define RTM_NEWLINK RTM_NEWLINK
30+ RTM_DELLINK,
31+#define RTM_DELLINK RTM_DELLINK
32+ RTM_GETLINK,
33+#define RTM_GETLINK RTM_GETLINK
34+ RTM_SETLINK,
35+#define RTM_SETLINK RTM_SETLINK
36+
37+ RTM_NEWADDR = 20,
38+#define RTM_NEWADDR RTM_NEWADDR
39+ RTM_DELADDR,
40+#define RTM_DELADDR RTM_DELADDR
41+ RTM_GETADDR,
42+#define RTM_GETADDR RTM_GETADDR
43+
44+ RTM_NEWROUTE = 24,
45+#define RTM_NEWROUTE RTM_NEWROUTE
46+ RTM_DELROUTE,
47+#define RTM_DELROUTE RTM_DELROUTE
48+ RTM_GETROUTE,
49+#define RTM_GETROUTE RTM_GETROUTE
50+
51+ RTM_NEWNEIGH = 28,
52+#define RTM_NEWNEIGH RTM_NEWNEIGH
53+ RTM_DELNEIGH,
54+#define RTM_DELNEIGH RTM_DELNEIGH
55+ RTM_GETNEIGH,
56+#define RTM_GETNEIGH RTM_GETNEIGH
57+
58+ RTM_NEWRULE = 32,
59+#define RTM_NEWRULE RTM_NEWRULE
60+ RTM_DELRULE,
61+#define RTM_DELRULE RTM_DELRULE
62+ RTM_GETRULE,
63+#define RTM_GETRULE RTM_GETRULE
64+
65+ RTM_NEWQDISC = 36,
66+#define RTM_NEWQDISC RTM_NEWQDISC
67+ RTM_DELQDISC,
68+#define RTM_DELQDISC RTM_DELQDISC
69+ RTM_GETQDISC,
70+#define RTM_GETQDISC RTM_GETQDISC
71+
72+ RTM_NEWTCLASS = 40,
73+#define RTM_NEWTCLASS RTM_NEWTCLASS
74+ RTM_DELTCLASS,
75+#define RTM_DELTCLASS RTM_DELTCLASS
76+ RTM_GETTCLASS,
77+#define RTM_GETTCLASS RTM_GETTCLASS
78+
79+ RTM_NEWTFILTER = 44,
80+#define RTM_NEWTFILTER RTM_NEWTFILTER
81+ RTM_DELTFILTER,
82+#define RTM_DELTFILTER RTM_DELTFILTER
83+ RTM_GETTFILTER,
84+#define RTM_GETTFILTER RTM_GETTFILTER
85+
86+ RTM_NEWACTION = 48,
87+#define RTM_NEWACTION RTM_NEWACTION
88+ RTM_DELACTION,
89+#define RTM_DELACTION RTM_DELACTION
90+ RTM_GETACTION,
91+#define RTM_GETACTION RTM_GETACTION
92+
93+ RTM_NEWPREFIX = 52,
94+#define RTM_NEWPREFIX RTM_NEWPREFIX
95+
96+ RTM_NEWMULTICAST = 56,
97+#define RTM_NEWMULTICAST RTM_NEWMULTICAST
98+ RTM_DELMULTICAST,
99+#define RTM_DELMULTICAST RTM_DELMULTICAST
100+ RTM_GETMULTICAST,
101+#define RTM_GETMULTICAST RTM_GETMULTICAST
102+
103+ RTM_NEWANYCAST = 60,
104+#define RTM_NEWANYCAST RTM_NEWANYCAST
105+ RTM_DELANYCAST,
106+#define RTM_DELANYCAST RTM_DELANYCAST
107+ RTM_GETANYCAST,
108+#define RTM_GETANYCAST RTM_GETANYCAST
109+
110+ RTM_NEWNEIGHTBL = 64,
111+#define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
112+ RTM_GETNEIGHTBL = 66,
113+#define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
114+ RTM_SETNEIGHTBL,
115+#define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
116+
117+ RTM_NEWNDUSEROPT = 68,
118+#define RTM_NEWNDUSEROPT RTM_NEWNDUSEROPT
119+
120+ RTM_NEWADDRLABEL = 72,
121+#define RTM_NEWADDRLABEL RTM_NEWADDRLABEL
122+ RTM_DELADDRLABEL,
123+#define RTM_DELADDRLABEL RTM_DELADDRLABEL
124+ RTM_GETADDRLABEL,
125+#define RTM_GETADDRLABEL RTM_GETADDRLABEL
126+
127+ RTM_GETDCB = 78,
128+#define RTM_GETDCB RTM_GETDCB
129+ RTM_SETDCB,
130+#define RTM_SETDCB RTM_SETDCB
131+
132+ RTM_NEWNETCONF = 80,
133+#define RTM_NEWNETCONF RTM_NEWNETCONF
134+ RTM_DELNETCONF,
135+#define RTM_DELNETCONF RTM_DELNETCONF
136+ RTM_GETNETCONF = 82,
137+#define RTM_GETNETCONF RTM_GETNETCONF
138+
139+ RTM_NEWMDB = 84,
140+#define RTM_NEWMDB RTM_NEWMDB
141+ RTM_DELMDB = 85,
142+#define RTM_DELMDB RTM_DELMDB
143+ RTM_GETMDB = 86,
144+#define RTM_GETMDB RTM_GETMDB
145+
146+ RTM_NEWNSID = 88,
147+#define RTM_NEWNSID RTM_NEWNSID
148+ RTM_DELNSID = 89,
149+#define RTM_DELNSID RTM_DELNSID
150+ RTM_GETNSID = 90,
151+#define RTM_GETNSID RTM_GETNSID
152+
153+ RTM_NEWSTATS = 92,
154+#define RTM_NEWSTATS RTM_NEWSTATS
155+ RTM_GETSTATS = 94,
156+#define RTM_GETSTATS RTM_GETSTATS
157+ RTM_SETSTATS,
158+#define RTM_SETSTATS RTM_SETSTATS
159+
160+ RTM_NEWCACHEREPORT = 96,
161+#define RTM_NEWCACHEREPORT RTM_NEWCACHEREPORT
162+
163+ RTM_NEWCHAIN = 100,
164+#define RTM_NEWCHAIN RTM_NEWCHAIN
165+ RTM_DELCHAIN,
166+#define RTM_DELCHAIN RTM_DELCHAIN
167+ RTM_GETCHAIN,
168+#define RTM_GETCHAIN RTM_GETCHAIN
169+
170+ RTM_NEWNEXTHOP = 104,
171+#define RTM_NEWNEXTHOP RTM_NEWNEXTHOP
172+ RTM_DELNEXTHOP,
173+#define RTM_DELNEXTHOP RTM_DELNEXTHOP
174+ RTM_GETNEXTHOP,
175+#define RTM_GETNEXTHOP RTM_GETNEXTHOP
176+
177+ RTM_NEWLINKPROP = 108,
178+#define RTM_NEWLINKPROP RTM_NEWLINKPROP
179+ RTM_DELLINKPROP,
180+#define RTM_DELLINKPROP RTM_DELLINKPROP
181+ RTM_GETLINKPROP,
182+#define RTM_GETLINKPROP RTM_GETLINKPROP
183+
184+ RTM_NEWVLAN = 112,
185+#define RTM_NEWVLAN RTM_NEWVLAN
186+ RTM_DELVLAN,
187+#define RTM_DELVLAN RTM_DELVLAN
188+ RTM_GETVLAN,
189+#define RTM_GETVLAN RTM_GETVLAN
190+
191+ RTM_NEWNEXTHOPBUCKET = 116,
192+#define RTM_NEWNEXTHOPBUCKET RTM_NEWNEXTHOPBUCKET
193+ RTM_DELNEXTHOPBUCKET,
194+#define RTM_DELNEXTHOPBUCKET RTM_DELNEXTHOPBUCKET
195+ RTM_GETNEXTHOPBUCKET,
196+#define RTM_GETNEXTHOPBUCKET RTM_GETNEXTHOPBUCKET
197+
198+ RTM_NEWTUNNEL = 120,
199+#define RTM_NEWTUNNEL RTM_NEWTUNNEL
200+ RTM_DELTUNNEL,
201+#define RTM_DELTUNNEL RTM_DELTUNNEL
202+ RTM_GETTUNNEL,
203+#define RTM_GETTUNNEL RTM_GETTUNNEL
204+
205+ __RTM_MAX,
206+#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
207+};
208+
209+#define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
210+#define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
211+#define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
212+
213+/*
214+ Generic structure for encapsulation of optional route information.
215+ It is reminiscent of sockaddr, but with sa_family replaced
216+ with attribute type.
217+ */
218+
219+struct rtattr {
220+ unsigned short rta_len;
221+ unsigned short rta_type;
222+};
223+
224+/* Macros to handle rtattributes */
225+
226+#define RTA_ALIGNTO 4U
227+#define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
228+#define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
229+ (rta)->rta_len >= sizeof(struct rtattr) && \
230+ (rta)->rta_len <= (len))
231+#define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
232+ (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
233+#define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
234+#define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
235+#define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
236+#define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
237+
238+
239+
240+
241+/******************************************************************************
242+ * Definitions used in routing table administration.
243+ ****/
244+
245+struct rtmsg {
246+ unsigned char rtm_family;
247+ unsigned char rtm_dst_len;
248+ unsigned char rtm_src_len;
249+ unsigned char rtm_tos;
250+
251+ unsigned char rtm_table; /* Routing table id */
252+ unsigned char rtm_protocol; /* Routing protocol; see below */
253+ unsigned char rtm_scope; /* See below */
254+ unsigned char rtm_type; /* See below */
255+
256+ unsigned rtm_flags;
257+};
258+
259+/* rtm_type */
260+
261+enum {
262+ RTN_UNSPEC,
263+ RTN_UNICAST, /* Gateway or direct route */
264+ RTN_LOCAL, /* Accept locally */
265+ RTN_BROADCAST, /* Accept locally as broadcast,
266+ send as broadcast */
267+ RTN_ANYCAST, /* Accept locally as broadcast,
268+ but send as unicast */
269+ RTN_MULTICAST, /* Multicast route */
270+ RTN_BLACKHOLE, /* Drop */
271+ RTN_UNREACHABLE, /* Destination is unreachable */
272+ RTN_PROHIBIT, /* Administratively prohibited */
273+ RTN_THROW, /* Not in this table */
274+ RTN_NAT, /* Translate this address */
275+ RTN_XRESOLVE, /* Use external resolver */
276+ __RTN_MAX
277+};
278+
279+#define RTN_MAX (__RTN_MAX - 1)
280+
281+
282+/* rtm_protocol */
283+
284+#define RTPROT_UNSPEC 0
285+#define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
286+ not used by current IPv4 */
287+#define RTPROT_KERNEL 2 /* Route installed by kernel */
288+#define RTPROT_BOOT 3 /* Route installed during boot */
289+#define RTPROT_STATIC 4 /* Route installed by administrator */
290+
291+/* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
292+ they are just passed from user and back as is.
293+ It will be used by hypothetical multiple routing daemons.
294+ Note that protocol values should be standardized in order to
295+ avoid conflicts.
296+ */
297+
298+#define RTPROT_GATED 8 /* Apparently, GateD */
299+#define RTPROT_RA 9 /* RDISC/ND router advertisements */
300+#define RTPROT_MRT 10 /* Merit MRT */
301+#define RTPROT_ZEBRA 11 /* Zebra */
302+#define RTPROT_BIRD 12 /* BIRD */
303+#define RTPROT_DNROUTED 13 /* DECnet routing daemon */
304+#define RTPROT_XORP 14 /* XORP */
305+#define RTPROT_NTK 15 /* Netsukuku */
306+#define RTPROT_DHCP 16 /* DHCP client */
307+#define RTPROT_MROUTED 17 /* Multicast daemon */
308+#define RTPROT_KEEPALIVED 18 /* Keepalived daemon */
309+#define RTPROT_BABEL 42 /* Babel daemon */
310+#define RTPROT_OVN 84 /* OVN daemon */
311+#define RTPROT_OPENR 99 /* Open Routing (Open/R) Routes */
312+#define RTPROT_BGP 186 /* BGP Routes */
313+#define RTPROT_ISIS 187 /* ISIS Routes */
314+#define RTPROT_OSPF 188 /* OSPF Routes */
315+#define RTPROT_RIP 189 /* RIP Routes */
316+#define RTPROT_EIGRP 192 /* EIGRP Routes */
317+
318+/* rtm_scope
319+
320+ Really it is not scope, but sort of distance to the destination.
321+ NOWHERE are reserved for not existing destinations, HOST is our
322+ local addresses, LINK are destinations, located on directly attached
323+ link and UNIVERSE is everywhere in the Universe.
324+
325+ Intermediate values are also possible f.e. interior routes
326+ could be assigned a value between UNIVERSE and LINK.
327+*/
328+
329+enum rt_scope_t {
330+ RT_SCOPE_UNIVERSE=0,
331+/* User defined values */
332+ RT_SCOPE_SITE=200,
333+ RT_SCOPE_LINK=253,
334+ RT_SCOPE_HOST=254,
335+ RT_SCOPE_NOWHERE=255
336+};
337+
338+/* rtm_flags */
339+
340+#define RTM_F_NOTIFY 0x100 /* Notify user of route change */
341+#define RTM_F_CLONED 0x200 /* This route is cloned */
342+#define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
343+#define RTM_F_PREFIX 0x800 /* Prefix addresses */
344+#define RTM_F_LOOKUP_TABLE 0x1000 /* set rtm_table to FIB lookup result */
345+#define RTM_F_FIB_MATCH 0x2000 /* return full fib lookup match */
346+#define RTM_F_OFFLOAD 0x4000 /* route is offloaded */
347+#define RTM_F_TRAP 0x8000 /* route is trapping packets */
348+#define RTM_F_OFFLOAD_FAILED 0x20000000 /* route offload failed, this value
349+ * is chosen to avoid conflicts with
350+ * other flags defined in
351+ * include/uapi/linux/ipv6_route.h
352+ */
353+
354+/* Reserved table identifiers */
355+
356+enum rt_class_t {
357+ RT_TABLE_UNSPEC=0,
358+/* User defined values */
359+ RT_TABLE_COMPAT=252,
360+ RT_TABLE_DEFAULT=253,
361+ RT_TABLE_MAIN=254,
362+ RT_TABLE_LOCAL=255,
363+ RT_TABLE_MAX=0xFFFFFFFF
364+};
365+
366+
367+/* Routing message attributes */
368+
369+enum rtattr_type_t {
370+ RTA_UNSPEC,
371+ RTA_DST,
372+ RTA_SRC,
373+ RTA_IIF,
374+ RTA_OIF,
375+ RTA_GATEWAY,
376+ RTA_PRIORITY,
377+ RTA_PREFSRC,
378+ RTA_METRICS,
379+ RTA_MULTIPATH,
380+ RTA_PROTOINFO, /* no longer used */
381+ RTA_FLOW,
382+ RTA_CACHEINFO,
383+ RTA_SESSION, /* no longer used */
384+ RTA_MP_ALGO, /* no longer used */
385+ RTA_TABLE,
386+ RTA_MARK,
387+ RTA_MFC_STATS,
388+ RTA_VIA,
389+ RTA_NEWDST,
390+ RTA_PREF,
391+ RTA_ENCAP_TYPE,
392+ RTA_ENCAP,
393+ RTA_EXPIRES,
394+ RTA_PAD,
395+ RTA_UID,
396+ RTA_TTL_PROPAGATE,
397+ RTA_IP_PROTO,
398+ RTA_SPORT,
399+ RTA_DPORT,
400+ RTA_NH_ID,
401+ RTA_FLOWLABEL,
402+ __RTA_MAX
403+};
404+
405+#define RTA_MAX (__RTA_MAX - 1)
406+
407+#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
408+#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
409+
410+/* RTM_MULTIPATH --- array of struct rtnexthop.
411+ *
412+ * "struct rtnexthop" describes all necessary nexthop information,
413+ * i.e. parameters of path to a destination via this nexthop.
414+ *
415+ * At the moment it is impossible to set different prefsrc, mtu, window
416+ * and rtt for different paths from multipath.
417+ */
418+
419+struct rtnexthop {
420+ unsigned short rtnh_len;
421+ unsigned char rtnh_flags;
422+ unsigned char rtnh_hops;
423+ int rtnh_ifindex;
424+};
425+
426+/* rtnh_flags */
427+
428+#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
429+#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
430+#define RTNH_F_ONLINK 4 /* Gateway is forced on link */
431+#define RTNH_F_OFFLOAD 8 /* Nexthop is offloaded */
432+#define RTNH_F_LINKDOWN 16 /* carrier-down on nexthop */
433+#define RTNH_F_UNRESOLVED 32 /* The entry is unresolved (ipmr) */
434+#define RTNH_F_TRAP 64 /* Nexthop is trapping packets */
435+
436+#define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN | \
437+ RTNH_F_OFFLOAD | RTNH_F_TRAP)
438+
439+/* Macros to handle hexthops */
440+
441+#define RTNH_ALIGNTO 4
442+#define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
443+#define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
444+ ((int)(rtnh)->rtnh_len) <= (len))
445+#define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
446+#define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
447+#define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
448+#define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
449+
450+/* RTA_VIA */
451+struct rtvia {
452+ __kernel_sa_family_t rtvia_family;
453+ __u8 rtvia_addr[];
454+};
455+
456+/* RTM_CACHEINFO */
457+
458+struct rta_cacheinfo {
459+ __u32 rta_clntref;
460+ __u32 rta_lastuse;
461+ __s32 rta_expires;
462+ __u32 rta_error;
463+ __u32 rta_used;
464+
465+#define RTNETLINK_HAVE_PEERINFO 1
466+ __u32 rta_id;
467+ __u32 rta_ts;
468+ __u32 rta_tsage;
469+};
470+
471+/* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
472+
473+enum {
474+ RTAX_UNSPEC,
475+#define RTAX_UNSPEC RTAX_UNSPEC
476+ RTAX_LOCK,
477+#define RTAX_LOCK RTAX_LOCK
478+ RTAX_MTU,
479+#define RTAX_MTU RTAX_MTU
480+ RTAX_WINDOW,
481+#define RTAX_WINDOW RTAX_WINDOW
482+ RTAX_RTT,
483+#define RTAX_RTT RTAX_RTT
484+ RTAX_RTTVAR,
485+#define RTAX_RTTVAR RTAX_RTTVAR
486+ RTAX_SSTHRESH,
487+#define RTAX_SSTHRESH RTAX_SSTHRESH
488+ RTAX_CWND,
489+#define RTAX_CWND RTAX_CWND
490+ RTAX_ADVMSS,
491+#define RTAX_ADVMSS RTAX_ADVMSS
492+ RTAX_REORDERING,
493+#define RTAX_REORDERING RTAX_REORDERING
494+ RTAX_HOPLIMIT,
495+#define RTAX_HOPLIMIT RTAX_HOPLIMIT
496+ RTAX_INITCWND,
497+#define RTAX_INITCWND RTAX_INITCWND
498+ RTAX_FEATURES,
499+#define RTAX_FEATURES RTAX_FEATURES
500+ RTAX_RTO_MIN,
501+#define RTAX_RTO_MIN RTAX_RTO_MIN
502+ RTAX_INITRWND,
503+#define RTAX_INITRWND RTAX_INITRWND
504+ RTAX_QUICKACK,
505+#define RTAX_QUICKACK RTAX_QUICKACK
506+ RTAX_CC_ALGO,
507+#define RTAX_CC_ALGO RTAX_CC_ALGO
508+ RTAX_FASTOPEN_NO_COOKIE,
509+#define RTAX_FASTOPEN_NO_COOKIE RTAX_FASTOPEN_NO_COOKIE
510+ __RTAX_MAX
511+};
512+
513+#define RTAX_MAX (__RTAX_MAX - 1)
514+
515+#define RTAX_FEATURE_ECN (1 << 0)
516+#define RTAX_FEATURE_SACK (1 << 1) /* unused */
517+#define RTAX_FEATURE_TIMESTAMP (1 << 2) /* unused */
518+#define RTAX_FEATURE_ALLFRAG (1 << 3) /* unused */
519+#define RTAX_FEATURE_TCP_USEC_TS (1 << 4)
520+
521+#define RTAX_FEATURE_MASK (RTAX_FEATURE_ECN | \
522+ RTAX_FEATURE_SACK | \
523+ RTAX_FEATURE_TIMESTAMP | \
524+ RTAX_FEATURE_ALLFRAG | \
525+ RTAX_FEATURE_TCP_USEC_TS)
526+
527+struct rta_session {
528+ __u8 proto;
529+ __u8 pad1;
530+ __u16 pad2;
531+
532+ union {
533+ struct {
534+ __u16 sport;
535+ __u16 dport;
536+ } ports;
537+
538+ struct {
539+ __u8 type;
540+ __u8 code;
541+ __u16 ident;
542+ } icmpt;
543+
544+ __u32 spi;
545+ } u;
546+};
547+
548+struct rta_mfc_stats {
549+ __u64 mfcs_packets;
550+ __u64 mfcs_bytes;
551+ __u64 mfcs_wrong_if;
552+};
553+
554+/****
555+ * General form of address family dependent message.
556+ ****/
557+
558+struct rtgenmsg {
559+ unsigned char rtgen_family;
560+};
561+
562+/*****************************************************************
563+ * Link layer specific messages.
564+ ****/
565+
566+/* struct ifinfomsg
567+ * passes link level specific information, not dependent
568+ * on network protocol.
569+ */
570+
571+struct ifinfomsg {
572+ unsigned char ifi_family;
573+ unsigned char __ifi_pad;
574+ unsigned short ifi_type; /* ARPHRD_* */
575+ int ifi_index; /* Link index */
576+ unsigned ifi_flags; /* IFF_* flags */
577+ unsigned ifi_change; /* IFF_* change mask */
578+};
579+
580+/********************************************************************
581+ * prefix information
582+ ****/
583+
584+struct prefixmsg {
585+ unsigned char prefix_family;
586+ unsigned char prefix_pad1;
587+ unsigned short prefix_pad2;
588+ int prefix_ifindex;
589+ unsigned char prefix_type;
590+ unsigned char prefix_len;
591+ unsigned char prefix_flags;
592+ unsigned char prefix_pad3;
593+};
594+
595+enum
596+{
597+ PREFIX_UNSPEC,
598+ PREFIX_ADDRESS,
599+ PREFIX_CACHEINFO,
600+ __PREFIX_MAX
601+};
602+
603+#define PREFIX_MAX (__PREFIX_MAX - 1)
604+
605+struct prefix_cacheinfo {
606+ __u32 preferred_time;
607+ __u32 valid_time;
608+};
609+
610+
611+/*****************************************************************
612+ * Traffic control messages.
613+ ****/
614+
615+struct tcmsg {
616+ unsigned char tcm_family;
617+ unsigned char tcm__pad1;
618+ unsigned short tcm__pad2;
619+ int tcm_ifindex;
620+ __u32 tcm_handle;
621+ __u32 tcm_parent;
622+/* tcm_block_index is used instead of tcm_parent
623+ * in case tcm_ifindex == TCM_IFINDEX_MAGIC_BLOCK
624+ */
625+#define tcm_block_index tcm_parent
626+ __u32 tcm_info;
627+};
628+
629+/* For manipulation of filters in shared block, tcm_ifindex is set to
630+ * TCM_IFINDEX_MAGIC_BLOCK, and tcm_parent is aliased to tcm_block_index
631+ * which is the block index.
632+ */
633+#define TCM_IFINDEX_MAGIC_BLOCK (0xFFFFFFFFU)
634+
635+enum {
636+ TCA_UNSPEC,
637+ TCA_KIND,
638+ TCA_OPTIONS,
639+ TCA_STATS,
640+ TCA_XSTATS,
641+ TCA_RATE,
642+ TCA_FCNT,
643+ TCA_STATS2,
644+ TCA_STAB,
645+ TCA_PAD,
646+ TCA_DUMP_INVISIBLE,
647+ TCA_CHAIN,
648+ TCA_HW_OFFLOAD,
649+ TCA_INGRESS_BLOCK,
650+ TCA_EGRESS_BLOCK,
651+ TCA_DUMP_FLAGS,
652+ TCA_EXT_WARN_MSG,
653+ __TCA_MAX
654+};
655+
656+#define TCA_MAX (__TCA_MAX - 1)
657+
658+#define TCA_DUMP_FLAGS_TERSE (1 << 0) /* Means that in dump user gets only basic
659+ * data necessary to identify the objects
660+ * (handle, cookie, etc.) and stats.
661+ */
662+
663+#define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
664+#define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
665+
666+/********************************************************************
667+ * Neighbor Discovery userland options
668+ ****/
669+
670+struct nduseroptmsg {
671+ unsigned char nduseropt_family;
672+ unsigned char nduseropt_pad1;
673+ unsigned short nduseropt_opts_len; /* Total length of options */
674+ int nduseropt_ifindex;
675+ __u8 nduseropt_icmp_type;
676+ __u8 nduseropt_icmp_code;
677+ unsigned short nduseropt_pad2;
678+ unsigned int nduseropt_pad3;
679+ /* Followed by one or more ND options */
680+};
681+
682+enum {
683+ NDUSEROPT_UNSPEC,
684+ NDUSEROPT_SRCADDR,
685+ __NDUSEROPT_MAX
686+};
687+
688+#define NDUSEROPT_MAX (__NDUSEROPT_MAX - 1)
689+
690+#ifndef __KERNEL__
691+/* RTnetlink multicast groups - backwards compatibility for userspace */
692+#define RTMGRP_LINK 1
693+#define RTMGRP_NOTIFY 2
694+#define RTMGRP_NEIGH 4
695+#define RTMGRP_TC 8
696+
697+#define RTMGRP_IPV4_IFADDR 0x10
698+#define RTMGRP_IPV4_MROUTE 0x20
699+#define RTMGRP_IPV4_ROUTE 0x40
700+#define RTMGRP_IPV4_RULE 0x80
701+
702+#define RTMGRP_IPV6_IFADDR 0x100
703+#define RTMGRP_IPV6_MROUTE 0x200
704+#define RTMGRP_IPV6_ROUTE 0x400
705+#define RTMGRP_IPV6_IFINFO 0x800
706+
707+#define RTMGRP_DECnet_IFADDR 0x1000
708+#define RTMGRP_DECnet_ROUTE 0x4000
709+
710+#define RTMGRP_IPV6_PREFIX 0x20000
711+#endif
712+
713+/* RTnetlink multicast groups */
714+enum rtnetlink_groups {
715+ RTNLGRP_NONE,
716+#define RTNLGRP_NONE RTNLGRP_NONE
717+ RTNLGRP_LINK,
718+#define RTNLGRP_LINK RTNLGRP_LINK
719+ RTNLGRP_NOTIFY,
720+#define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
721+ RTNLGRP_NEIGH,
722+#define RTNLGRP_NEIGH RTNLGRP_NEIGH
723+ RTNLGRP_TC,
724+#define RTNLGRP_TC RTNLGRP_TC
725+ RTNLGRP_IPV4_IFADDR,
726+#define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
727+ RTNLGRP_IPV4_MROUTE,
728+#define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
729+ RTNLGRP_IPV4_ROUTE,
730+#define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
731+ RTNLGRP_IPV4_RULE,
732+#define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
733+ RTNLGRP_IPV6_IFADDR,
734+#define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
735+ RTNLGRP_IPV6_MROUTE,
736+#define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
737+ RTNLGRP_IPV6_ROUTE,
738+#define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
739+ RTNLGRP_IPV6_IFINFO,
740+#define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
741+ RTNLGRP_DECnet_IFADDR,
742+#define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
743+ RTNLGRP_NOP2,
744+ RTNLGRP_DECnet_ROUTE,
745+#define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
746+ RTNLGRP_DECnet_RULE,
747+#define RTNLGRP_DECnet_RULE RTNLGRP_DECnet_RULE
748+ RTNLGRP_NOP4,
749+ RTNLGRP_IPV6_PREFIX,
750+#define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
751+ RTNLGRP_IPV6_RULE,
752+#define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE
753+ RTNLGRP_ND_USEROPT,
754+#define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT
755+ RTNLGRP_PHONET_IFADDR,
756+#define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR
757+ RTNLGRP_PHONET_ROUTE,
758+#define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE
759+ RTNLGRP_DCB,
760+#define RTNLGRP_DCB RTNLGRP_DCB
761+ RTNLGRP_IPV4_NETCONF,
762+#define RTNLGRP_IPV4_NETCONF RTNLGRP_IPV4_NETCONF
763+ RTNLGRP_IPV6_NETCONF,
764+#define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF
765+ RTNLGRP_MDB,
766+#define RTNLGRP_MDB RTNLGRP_MDB
767+ RTNLGRP_MPLS_ROUTE,
768+#define RTNLGRP_MPLS_ROUTE RTNLGRP_MPLS_ROUTE
769+ RTNLGRP_NSID,
770+#define RTNLGRP_NSID RTNLGRP_NSID
771+ RTNLGRP_MPLS_NETCONF,
772+#define RTNLGRP_MPLS_NETCONF RTNLGRP_MPLS_NETCONF
773+ RTNLGRP_IPV4_MROUTE_R,
774+#define RTNLGRP_IPV4_MROUTE_R RTNLGRP_IPV4_MROUTE_R
775+ RTNLGRP_IPV6_MROUTE_R,
776+#define RTNLGRP_IPV6_MROUTE_R RTNLGRP_IPV6_MROUTE_R
777+ RTNLGRP_NEXTHOP,
778+#define RTNLGRP_NEXTHOP RTNLGRP_NEXTHOP
779+ RTNLGRP_BRVLAN,
780+#define RTNLGRP_BRVLAN RTNLGRP_BRVLAN
781+ RTNLGRP_MCTP_IFADDR,
782+#define RTNLGRP_MCTP_IFADDR RTNLGRP_MCTP_IFADDR
783+ RTNLGRP_TUNNEL,
784+#define RTNLGRP_TUNNEL RTNLGRP_TUNNEL
785+ RTNLGRP_STATS,
786+#define RTNLGRP_STATS RTNLGRP_STATS
787+ RTNLGRP_IPV4_MCADDR,
788+#define RTNLGRP_IPV4_MCADDR RTNLGRP_IPV4_MCADDR
789+ RTNLGRP_IPV6_MCADDR,
790+#define RTNLGRP_IPV6_MCADDR RTNLGRP_IPV6_MCADDR
791+ RTNLGRP_IPV6_ACADDR,
792+#define RTNLGRP_IPV6_ACADDR RTNLGRP_IPV6_ACADDR
793+ __RTNLGRP_MAX
794+};
795+#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
796+
797+/* TC action piece */
798+struct tcamsg {
799+ unsigned char tca_family;
800+ unsigned char tca__pad1;
801+ unsigned short tca__pad2;
802+};
803+
804+enum {
805+ TCA_ROOT_UNSPEC,
806+ TCA_ROOT_TAB,
807+#define TCA_ACT_TAB TCA_ROOT_TAB
808+#define TCAA_MAX TCA_ROOT_TAB
809+ TCA_ROOT_FLAGS,
810+ TCA_ROOT_COUNT,
811+ TCA_ROOT_TIME_DELTA, /* in msecs */
812+ TCA_ROOT_EXT_WARN_MSG,
813+ __TCA_ROOT_MAX,
814+#define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1)
815+};
816+
817+#define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
818+#define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
819+/* tcamsg flags stored in attribute TCA_ROOT_FLAGS
820+ *
821+ * TCA_ACT_FLAG_LARGE_DUMP_ON user->kernel to request for larger than
822+ * TCA_ACT_MAX_PRIO actions in a dump. All dump responses will contain the
823+ * number of actions being dumped stored in for user app's consumption in
824+ * TCA_ROOT_COUNT
825+ *
826+ * TCA_ACT_FLAG_TERSE_DUMP user->kernel to request terse (brief) dump that only
827+ * includes essential action info (kind, index, etc.)
828+ *
829+ */
830+#define TCA_FLAG_LARGE_DUMP_ON (1 << 0)
831+#define TCA_ACT_FLAG_LARGE_DUMP_ON TCA_FLAG_LARGE_DUMP_ON
832+#define TCA_ACT_FLAG_TERSE_DUMP (1 << 1)
833+
834+/* New extended info filters for IFLA_EXT_MASK */
835+#define RTEXT_FILTER_VF (1 << 0)
836+#define RTEXT_FILTER_BRVLAN (1 << 1)
837+#define RTEXT_FILTER_BRVLAN_COMPRESSED (1 << 2)
838+#define RTEXT_FILTER_SKIP_STATS (1 << 3)
839+#define RTEXT_FILTER_MRP (1 << 4)
840+#define RTEXT_FILTER_CFM_CONFIG (1 << 5)
841+#define RTEXT_FILTER_CFM_STATUS (1 << 6)
842+#define RTEXT_FILTER_MST (1 << 7)
843+
844+/* End of information exported to user level */
845+
846+
847+
848+#endif /* _UAPI__LINUX_RTNETLINK_H */