1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _UAPI__LINUX_RTNETLINK_H
3 #define _UAPI__LINUX_RTNETLINK_H
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>
11 /* rtnetlink families. Values up to 127 are reserved for real address
12 * families, values above 128 may be used arbitrarily.
14 #define RTNL_FAMILY_IPMR 128
15 #define RTNL_FAMILY_IP6MR 129
16 #define RTNL_FAMILY_MAX 129
19 * Routing/neighbour discovery messages.
22 /* Types of messages */
26 #define RTM_BASE RTM_BASE
29 #define RTM_NEWLINK RTM_NEWLINK
31 #define RTM_DELLINK RTM_DELLINK
33 #define RTM_GETLINK RTM_GETLINK
35 #define RTM_SETLINK RTM_SETLINK
38 #define RTM_NEWADDR RTM_NEWADDR
40 #define RTM_DELADDR RTM_DELADDR
42 #define RTM_GETADDR RTM_GETADDR
45 #define RTM_NEWROUTE RTM_NEWROUTE
47 #define RTM_DELROUTE RTM_DELROUTE
49 #define RTM_GETROUTE RTM_GETROUTE
52 #define RTM_NEWNEIGH RTM_NEWNEIGH
54 #define RTM_DELNEIGH RTM_DELNEIGH
56 #define RTM_GETNEIGH RTM_GETNEIGH
59 #define RTM_NEWRULE RTM_NEWRULE
61 #define RTM_DELRULE RTM_DELRULE
63 #define RTM_GETRULE RTM_GETRULE
66 #define RTM_NEWQDISC RTM_NEWQDISC
68 #define RTM_DELQDISC RTM_DELQDISC
70 #define RTM_GETQDISC RTM_GETQDISC
73 #define RTM_NEWTCLASS RTM_NEWTCLASS
75 #define RTM_DELTCLASS RTM_DELTCLASS
77 #define RTM_GETTCLASS RTM_GETTCLASS
80 #define RTM_NEWTFILTER RTM_NEWTFILTER
82 #define RTM_DELTFILTER RTM_DELTFILTER
84 #define RTM_GETTFILTER RTM_GETTFILTER
87 #define RTM_NEWACTION RTM_NEWACTION
89 #define RTM_DELACTION RTM_DELACTION
91 #define RTM_GETACTION RTM_GETACTION
94 #define RTM_NEWPREFIX RTM_NEWPREFIX
96 RTM_GETMULTICAST
= 58,
97 #define RTM_GETMULTICAST RTM_GETMULTICAST
100 #define RTM_GETANYCAST RTM_GETANYCAST
102 RTM_NEWNEIGHTBL
= 64,
103 #define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
104 RTM_GETNEIGHTBL
= 66,
105 #define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
107 #define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
109 RTM_NEWNDUSEROPT
= 68,
110 #define RTM_NEWNDUSEROPT RTM_NEWNDUSEROPT
112 RTM_NEWADDRLABEL
= 72,
113 #define RTM_NEWADDRLABEL RTM_NEWADDRLABEL
115 #define RTM_DELADDRLABEL RTM_DELADDRLABEL
117 #define RTM_GETADDRLABEL RTM_GETADDRLABEL
120 #define RTM_GETDCB RTM_GETDCB
122 #define RTM_SETDCB RTM_SETDCB
125 #define RTM_NEWNETCONF RTM_NEWNETCONF
127 #define RTM_DELNETCONF RTM_DELNETCONF
129 #define RTM_GETNETCONF RTM_GETNETCONF
132 #define RTM_NEWMDB RTM_NEWMDB
134 #define RTM_DELMDB RTM_DELMDB
136 #define RTM_GETMDB RTM_GETMDB
139 #define RTM_NEWNSID RTM_NEWNSID
141 #define RTM_DELNSID RTM_DELNSID
143 #define RTM_GETNSID RTM_GETNSID
146 #define RTM_NEWSTATS RTM_NEWSTATS
148 #define RTM_GETSTATS RTM_GETSTATS
150 RTM_NEWCACHEREPORT
= 96,
151 #define RTM_NEWCACHEREPORT RTM_NEWCACHEREPORT
154 #define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
157 #define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
158 #define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
159 #define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
162 Generic structure for encapsulation of optional route information.
163 It is reminiscent of sockaddr, but with sa_family replaced
168 unsigned short rta_len
;
169 unsigned short rta_type
;
172 /* Macros to handle rtattributes */
174 #define RTA_ALIGNTO 4U
175 #define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
176 #define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
177 (rta)->rta_len >= sizeof(struct rtattr) && \
178 (rta)->rta_len <= (len))
179 #define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
180 (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
181 #define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
182 #define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
183 #define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
184 #define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
189 /******************************************************************************
190 * Definitions used in routing table administration.
194 unsigned char rtm_family
;
195 unsigned char rtm_dst_len
;
196 unsigned char rtm_src_len
;
197 unsigned char rtm_tos
;
199 unsigned char rtm_table
; /* Routing table id */
200 unsigned char rtm_protocol
; /* Routing protocol; see below */
201 unsigned char rtm_scope
; /* See below */
202 unsigned char rtm_type
; /* See below */
211 RTN_UNICAST
, /* Gateway or direct route */
212 RTN_LOCAL
, /* Accept locally */
213 RTN_BROADCAST
, /* Accept locally as broadcast,
215 RTN_ANYCAST
, /* Accept locally as broadcast,
216 but send as unicast */
217 RTN_MULTICAST
, /* Multicast route */
218 RTN_BLACKHOLE
, /* Drop */
219 RTN_UNREACHABLE
, /* Destination is unreachable */
220 RTN_PROHIBIT
, /* Administratively prohibited */
221 RTN_THROW
, /* Not in this table */
222 RTN_NAT
, /* Translate this address */
223 RTN_XRESOLVE
, /* Use external resolver */
227 #define RTN_MAX (__RTN_MAX - 1)
232 #define RTPROT_UNSPEC 0
233 #define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
234 not used by current IPv4 */
235 #define RTPROT_KERNEL 2 /* Route installed by kernel */
236 #define RTPROT_BOOT 3 /* Route installed during boot */
237 #define RTPROT_STATIC 4 /* Route installed by administrator */
239 /* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
240 they are just passed from user and back as is.
241 It will be used by hypothetical multiple routing daemons.
242 Note that protocol values should be standardized in order to
246 #define RTPROT_GATED 8 /* Apparently, GateD */
247 #define RTPROT_RA 9 /* RDISC/ND router advertisements */
248 #define RTPROT_MRT 10 /* Merit MRT */
249 #define RTPROT_ZEBRA 11 /* Zebra */
250 #define RTPROT_BIRD 12 /* BIRD */
251 #define RTPROT_DNROUTED 13 /* DECnet routing daemon */
252 #define RTPROT_XORP 14 /* XORP */
253 #define RTPROT_NTK 15 /* Netsukuku */
254 #define RTPROT_DHCP 16 /* DHCP client */
255 #define RTPROT_MROUTED 17 /* Multicast daemon */
256 #define RTPROT_BABEL 42 /* Babel daemon */
260 Really it is not scope, but sort of distance to the destination.
261 NOWHERE are reserved for not existing destinations, HOST is our
262 local addresses, LINK are destinations, located on directly attached
263 link and UNIVERSE is everywhere in the Universe.
265 Intermediate values are also possible f.e. interior routes
266 could be assigned a value between UNIVERSE and LINK.
271 /* User defined values */
280 #define RTM_F_NOTIFY 0x100 /* Notify user of route change */
281 #define RTM_F_CLONED 0x200 /* This route is cloned */
282 #define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
283 #define RTM_F_PREFIX 0x800 /* Prefix addresses */
284 #define RTM_F_LOOKUP_TABLE 0x1000 /* set rtm_table to FIB lookup result */
285 #define RTM_F_FIB_MATCH 0x2000 /* return full fib lookup match */
287 /* Reserved table identifiers */
291 /* User defined values */
293 RT_TABLE_DEFAULT
=253,
296 RT_TABLE_MAX
=0xFFFFFFFF
300 /* Routing message attributes */
313 RTA_PROTOINFO
, /* no longer used */
316 RTA_SESSION
, /* no longer used */
317 RTA_MP_ALGO
, /* no longer used */
333 #define RTA_MAX (__RTA_MAX - 1)
335 #define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
336 #define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
338 /* RTM_MULTIPATH --- array of struct rtnexthop.
340 * "struct rtnexthop" describes all necessary nexthop information,
341 * i.e. parameters of path to a destination via this nexthop.
343 * At the moment it is impossible to set different prefsrc, mtu, window
344 * and rtt for different paths from multipath.
348 unsigned short rtnh_len
;
349 unsigned char rtnh_flags
;
350 unsigned char rtnh_hops
;
356 #define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
357 #define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
358 #define RTNH_F_ONLINK 4 /* Gateway is forced on link */
359 #define RTNH_F_OFFLOAD 8 /* offloaded route */
360 #define RTNH_F_LINKDOWN 16 /* carrier-down on nexthop */
361 #define RTNH_F_UNRESOLVED 32 /* The entry is unresolved (ipmr) */
363 #define RTNH_COMPARE_MASK (RTNH_F_DEAD | RTNH_F_LINKDOWN | RTNH_F_OFFLOAD)
365 /* Macros to handle hexthops */
367 #define RTNH_ALIGNTO 4
368 #define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
369 #define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
370 ((int)(rtnh)->rtnh_len) <= (len))
371 #define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
372 #define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
373 #define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
374 #define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
378 __kernel_sa_family_t rtvia_family
;
384 struct rta_cacheinfo
{
391 #define RTNETLINK_HAVE_PEERINFO 1
397 /* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
401 #define RTAX_UNSPEC RTAX_UNSPEC
403 #define RTAX_LOCK RTAX_LOCK
405 #define RTAX_MTU RTAX_MTU
407 #define RTAX_WINDOW RTAX_WINDOW
409 #define RTAX_RTT RTAX_RTT
411 #define RTAX_RTTVAR RTAX_RTTVAR
413 #define RTAX_SSTHRESH RTAX_SSTHRESH
415 #define RTAX_CWND RTAX_CWND
417 #define RTAX_ADVMSS RTAX_ADVMSS
419 #define RTAX_REORDERING RTAX_REORDERING
421 #define RTAX_HOPLIMIT RTAX_HOPLIMIT
423 #define RTAX_INITCWND RTAX_INITCWND
425 #define RTAX_FEATURES RTAX_FEATURES
427 #define RTAX_RTO_MIN RTAX_RTO_MIN
429 #define RTAX_INITRWND RTAX_INITRWND
431 #define RTAX_QUICKACK RTAX_QUICKACK
433 #define RTAX_CC_ALGO RTAX_CC_ALGO
437 #define RTAX_MAX (__RTAX_MAX - 1)
439 #define RTAX_FEATURE_ECN (1 << 0)
440 #define RTAX_FEATURE_SACK (1 << 1)
441 #define RTAX_FEATURE_TIMESTAMP (1 << 2)
442 #define RTAX_FEATURE_ALLFRAG (1 << 3)
444 #define RTAX_FEATURE_MASK (RTAX_FEATURE_ECN | RTAX_FEATURE_SACK | \
445 RTAX_FEATURE_TIMESTAMP | RTAX_FEATURE_ALLFRAG)
468 struct rta_mfc_stats
{
475 * General form of address family dependent message.
479 unsigned char rtgen_family
;
482 /*****************************************************************
483 * Link layer specific messages.
487 * passes link level specific information, not dependent
488 * on network protocol.
492 unsigned char ifi_family
;
493 unsigned char __ifi_pad
;
494 unsigned short ifi_type
; /* ARPHRD_* */
495 int ifi_index
; /* Link index */
496 unsigned ifi_flags
; /* IFF_* flags */
497 unsigned ifi_change
; /* IFF_* change mask */
500 /********************************************************************
505 unsigned char prefix_family
;
506 unsigned char prefix_pad1
;
507 unsigned short prefix_pad2
;
509 unsigned char prefix_type
;
510 unsigned char prefix_len
;
511 unsigned char prefix_flags
;
512 unsigned char prefix_pad3
;
523 #define PREFIX_MAX (__PREFIX_MAX - 1)
525 struct prefix_cacheinfo
{
526 __u32 preferred_time
;
531 /*****************************************************************
532 * Traffic control messages.
536 unsigned char tcm_family
;
537 unsigned char tcm__pad1
;
538 unsigned short tcm__pad2
;
561 #define TCA_MAX (__TCA_MAX - 1)
563 #define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
564 #define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
566 /********************************************************************
567 * Neighbor Discovery userland options
570 struct nduseroptmsg
{
571 unsigned char nduseropt_family
;
572 unsigned char nduseropt_pad1
;
573 unsigned short nduseropt_opts_len
; /* Total length of options */
574 int nduseropt_ifindex
;
575 __u8 nduseropt_icmp_type
;
576 __u8 nduseropt_icmp_code
;
577 unsigned short nduseropt_pad2
;
578 unsigned int nduseropt_pad3
;
579 /* Followed by one or more ND options */
588 #define NDUSEROPT_MAX (__NDUSEROPT_MAX - 1)
591 /* RTnetlink multicast groups - backwards compatibility for userspace */
592 #define RTMGRP_LINK 1
593 #define RTMGRP_NOTIFY 2
594 #define RTMGRP_NEIGH 4
597 #define RTMGRP_IPV4_IFADDR 0x10
598 #define RTMGRP_IPV4_MROUTE 0x20
599 #define RTMGRP_IPV4_ROUTE 0x40
600 #define RTMGRP_IPV4_RULE 0x80
602 #define RTMGRP_IPV6_IFADDR 0x100
603 #define RTMGRP_IPV6_MROUTE 0x200
604 #define RTMGRP_IPV6_ROUTE 0x400
605 #define RTMGRP_IPV6_IFINFO 0x800
607 #define RTMGRP_DECnet_IFADDR 0x1000
608 #define RTMGRP_DECnet_ROUTE 0x4000
610 #define RTMGRP_IPV6_PREFIX 0x20000
613 /* RTnetlink multicast groups */
614 enum rtnetlink_groups
{
616 #define RTNLGRP_NONE RTNLGRP_NONE
618 #define RTNLGRP_LINK RTNLGRP_LINK
620 #define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
622 #define RTNLGRP_NEIGH RTNLGRP_NEIGH
624 #define RTNLGRP_TC RTNLGRP_TC
626 #define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
628 #define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
630 #define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
632 #define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
634 #define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
636 #define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
638 #define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
640 #define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
641 RTNLGRP_DECnet_IFADDR
,
642 #define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
644 RTNLGRP_DECnet_ROUTE
,
645 #define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
647 #define RTNLGRP_DECnet_RULE RTNLGRP_DECnet_RULE
650 #define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
652 #define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE
654 #define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT
655 RTNLGRP_PHONET_IFADDR
,
656 #define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR
657 RTNLGRP_PHONET_ROUTE
,
658 #define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE
660 #define RTNLGRP_DCB RTNLGRP_DCB
661 RTNLGRP_IPV4_NETCONF
,
662 #define RTNLGRP_IPV4_NETCONF RTNLGRP_IPV4_NETCONF
663 RTNLGRP_IPV6_NETCONF
,
664 #define RTNLGRP_IPV6_NETCONF RTNLGRP_IPV6_NETCONF
666 #define RTNLGRP_MDB RTNLGRP_MDB
668 #define RTNLGRP_MPLS_ROUTE RTNLGRP_MPLS_ROUTE
670 #define RTNLGRP_NSID RTNLGRP_NSID
671 RTNLGRP_MPLS_NETCONF
,
672 #define RTNLGRP_MPLS_NETCONF RTNLGRP_MPLS_NETCONF
673 RTNLGRP_IPV4_MROUTE_R
,
674 #define RTNLGRP_IPV4_MROUTE_R RTNLGRP_IPV4_MROUTE_R
675 RTNLGRP_IPV6_MROUTE_R
,
676 #define RTNLGRP_IPV6_MROUTE_R RTNLGRP_IPV6_MROUTE_R
679 #define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
681 /* TC action piece */
683 unsigned char tca_family
;
684 unsigned char tca__pad1
;
685 unsigned short tca__pad2
;
691 #define TCA_ACT_TAB TCA_ROOT_TAB
692 #define TCAA_MAX TCA_ROOT_TAB
695 TCA_ROOT_TIME_DELTA
, /* in msecs */
697 #define TCA_ROOT_MAX (__TCA_ROOT_MAX - 1)
700 #define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
701 #define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
702 /* tcamsg flags stored in attribute TCA_ROOT_FLAGS
704 * TCA_FLAG_LARGE_DUMP_ON user->kernel to request for larger than TCA_ACT_MAX_PRIO
705 * actions in a dump. All dump responses will contain the number of actions
706 * being dumped stored in for user app's consumption in TCA_ROOT_COUNT
709 #define TCA_FLAG_LARGE_DUMP_ON (1 << 0)
711 /* New extended info filters for IFLA_EXT_MASK */
712 #define RTEXT_FILTER_VF (1 << 0)
713 #define RTEXT_FILTER_BRVLAN (1 << 1)
714 #define RTEXT_FILTER_BRVLAN_COMPRESSED (1 << 2)
715 #define RTEXT_FILTER_SKIP_STATS (1 << 3)
717 /* End of information exported to user level */
721 #endif /* _UAPI__LINUX_RTNETLINK_H */