2 .\" SPDX-License-Identifier: Linux-man-pages-1-para
4 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
6 .\" Based on the original comments from Alexey Kuznetsov, written with
7 .\" help from Matthew Wilcox.
8 .\" $Id: rtnetlink.7,v 1.8 2000/01/22 01:55:04 freitag Exp $
10 .TH rtnetlink 7 (date) "Linux man-pages (unreleased)"
12 rtnetlink \- Linux routing socket
15 .B #include <asm/types.h>
16 .B #include <linux/netlink.h>
17 .B #include <linux/rtnetlink.h>
18 .B #include <sys/socket.h>
20 .BI "rtnetlink_socket = socket(AF_NETLINK, int " socket_type ", NETLINK_ROUTE);"
23 Rtnetlink allows the kernel's routing tables to be read and altered.
24 It is used within the kernel to communicate between
25 various subsystems, though this usage is not documented here, and for
26 communication with user-space programs.
27 Network routes, IP addresses, link parameters, neighbor setups, queueing
28 disciplines, traffic classes and packet classifiers may all be controlled
32 It is based on netlink messages; see
35 .\" FIXME . ? all these macros could be moved to rtnetlink(3)
36 .SS Routing attributes
37 Some rtnetlink messages have optional attributes after the initial header:
42 unsigned short rta_len; /* Length of option */
43 unsigned short rta_type; /* Type of option */
49 These attributes should be manipulated using only the RTA_* macros
53 Rtnetlink consists of these message types
54 (in addition to standard netlink messages):
61 Create, remove, or get information about a specific network interface.
62 These messages contain an
64 structure followed by a series of
70 unsigned char ifi_family; /* AF_UNSPEC */
71 unsigned short ifi_type; /* Device type */
72 int ifi_index; /* Interface index */
73 unsigned int ifi_flags; /* Device flags */
74 unsigned int ifi_change; /* change mask */
78 .\" FIXME Document ifinfomsg.ifi_type
80 contains the device flags, see
83 is the unique interface index
84 (since Linux 3.7, it is possible to feed a nonzero value with the
86 message, thus creating a link with the given
89 is reserved for future use and should be always set to 0xFFFFFFFF.
95 rta_type:Value type:Description
97 IFLA_UNSPEC:-:unspecified
98 IFLA_ADDRESS:hardware address:interface L2 address
99 IFLA_BROADCAST:hardware address:L2 broadcast address
100 IFLA_IFNAME:asciiz string:Device name
101 IFLA_MTU:unsigned int:MTU of the device
102 IFLA_LINK:int:Link type
103 IFLA_QDISC:asciiz string:Queueing discipline
106 T}:Interface Statistics
107 IFLA_PERM_ADDRESS:hardware address:T{
108 hardware address provided by device (since Linux 5.5)
115 .I struct rtnl_link_stats
116 .RI ( "struct net_device_stats"
117 in Linux 2.4 and earlier).
124 Add, remove, or receive information about an IP address associated with
126 In Linux 2.2, an interface can carry multiple IP addresses,
127 this replaces the alias device concept in Linux 2.0.
128 In Linux 2.2, these messages
129 support IPv4 and IPv6 addresses.
132 structure, optionally followed by
138 unsigned char ifa_family; /* Address type */
139 unsigned char ifa_prefixlen; /* Prefixlength of address */
140 unsigned char ifa_flags; /* Address flags */
141 unsigned char ifa_scope; /* Address scope */
142 unsigned int ifa_index; /* Interface index */
147 is the address family type (currently
152 is the length of the address mask of the address if defined for the
153 family (like for IPv4),
155 is the address scope,
157 is the interface index of the interface the address is associated with.
161 for secondary address (old alias interface),
163 for a permanent address set by the user and other undocumented flags.
169 rta_type:Value type:Description
171 IFA_UNSPEC:-:unspecified
172 IFA_ADDRESS:raw protocol address:interface address
173 IFA_LOCAL:raw protocol address:local address
174 IFA_LABEL:asciiz string:name of the interface
175 IFA_BROADCAST:raw protocol address:broadcast address
176 IFA_ANYCAST:raw protocol address:anycast address
177 IFA_CACHEINFO:struct ifa_cacheinfo:Address information
179 .\" FIXME Document struct ifa_cacheinfo
186 Create, remove, or receive information about a network route.
187 These messages contain an
189 structure with an optional sequence of
191 structures following.
198 to 0 means you get all entries for the specified routing table.
199 For the other fields, except
207 unsigned char rtm_family; /* Address family of route */
208 unsigned char rtm_dst_len; /* Length of destination */
209 unsigned char rtm_src_len; /* Length of source */
210 unsigned char rtm_tos; /* TOS filter */
211 unsigned char rtm_table; /* Routing table ID;
212 see RTA_TABLE below */
213 unsigned char rtm_protocol; /* Routing protocol; see below */
214 unsigned char rtm_scope; /* See below */
215 unsigned char rtm_type; /* See below */
217 unsigned int rtm_flags;
225 RTN_UNSPEC:unknown route
226 RTN_UNICAST:a gateway or direct route
227 RTN_LOCAL:a local interface route
229 a local broadcast route (sent as a broadcast)
232 a local broadcast route (sent as a unicast)
234 RTN_MULTICAST:a multicast route
235 RTN_BLACKHOLE:a packet dropping route
236 RTN_UNREACHABLE:an unreachable destination
237 RTN_PROHIBIT:a packet rejection route
238 RTN_THROW:continue routing lookup in another table
239 RTN_NAT:a network address translation rule
241 refer to an external resolver (not implemented)
247 rtm_protocol:Route origin
249 RTPROT_UNSPEC:unknown
251 by an ICMP redirect (currently unused)
253 RTPROT_KERNEL:by the kernel
254 RTPROT_BOOT:during boot
255 RTPROT_STATIC:by the administrator
260 are not interpreted by the kernel, they are just for user information.
261 They may be used to tag the source of a routing information or to
262 distinguish between multiple routing daemons.
264 .I <linux/rtnetlink.h>
265 for the routing daemon identifiers which are already assigned.
268 is the distance to the destination:
272 RT_SCOPE_UNIVERSE:global route
274 interior route in the local autonomous system
276 RT_SCOPE_LINK:route on this link
277 RT_SCOPE_HOST:route on the local host
278 RT_SCOPE_NOWHERE:destination doesn't exist
285 are available to the user.
289 have the following meanings:
294 if the route changes, notify the user via rtnetlink
296 RTM_F_CLONED:route is cloned from another route
297 RTM_F_EQUALIZE:a multipath equalizer (not yet implemented)
301 specifies the routing table
305 RT_TABLE_UNSPEC:an unspecified routing table
306 RT_TABLE_DEFAULT:the default table
307 RT_TABLE_MAIN:the main table
308 RT_TABLE_LOCAL:the local table
311 The user may assign arbitrary values between
314 .BR RT_TABLE_DEFAULT .
315 .\" Keep table on same page
322 rta_type:Value type:Description
325 RTA_DST:protocol address:Route destination address
326 RTA_SRC:protocol address:Route source address
327 RTA_IIF:int:Input interface index
328 RTA_OIF:int:Output interface index
329 RTA_GATEWAY:protocol address:The gateway of the route
330 RTA_PRIORITY:int:Priority of route
331 RTA_PREFSRC:protocol address:Preferred source address
332 RTA_METRICS:int:Route metric
334 Multipath nexthop data
338 RTA_PROTOINFO::No longer used
339 RTA_FLOW:int:Route realm
340 RTA_CACHEINFO:struct rta_cacheinfo:(see linux/rtnetlink.h)
341 RTA_SESSION::No longer used
342 RTA_MP_ALGO::No longer used
344 Routing table ID; if set,
349 RTA_MFC_STATS:struct rta_mfc_stats:(see linux/rtnetlink.h)
350 RTA_VIA:struct rtvia:T{
351 Gateway in different AF
354 RTA_NEWDST:protocol address:T{
360 preference (see below)
362 RTA_ENCAP_TYPE:short:T{
363 Encapsulation type for
365 lwtunnels (see below)
367 RTA_ENCAP::Defined by RTA_ENCAP_TYPE
375 contains several packed instances of
377 together with nested RTAs
383 unsigned short rtnh_len; /* Length of struct + length
385 unsigned char rtnh_flags; /* Flags (see
386 linux/rtnetlink.h) */
387 unsigned char rtnh_hops; /* Nexthop priority */
388 int rtnh_ifindex; /* Interface index for this
394 There exist a bunch of
401 useful to handle these structures.
406 unsigned short rtvia_family;
407 unsigned char rtvia_addr[0];
419 .BR ICMPV6_ROUTER_PREF_LOW ,
420 .BR ICMPV6_ROUTER_PREF_MEDIUM ,
422 .B ICMPV6_ROUTER_PREF_HIGH
424 .IR <linux/icmpv6.h> .
428 .BR LWTUNNEL_ENCAP_MPLS ,
429 .BR LWTUNNEL_ENCAP_IP ,
430 .BR LWTUNNEL_ENCAP_ILA ,
432 .B LWTUNNEL_ENCAP_IP6
434 .IR <linux/lwtunnel.h> .
436 .B Fill these values in!
443 Add, remove, or receive information about a neighbor table
444 entry (e.g., an ARP entry).
445 The message contains an
451 unsigned char ndm_family;
452 int ndm_ifindex; /* Interface index */
453 __u16 ndm_state; /* State */
454 __u8 ndm_flags; /* Flags */
458 struct nda_cacheinfo {
467 is a bit mask of the following states:
471 NUD_INCOMPLETE:a currently resolving cache entry
472 NUD_REACHABLE:a confirmed working cache entry
473 NUD_STALE:an expired cache entry
474 NUD_DELAY:an entry waiting for a timer
475 NUD_PROBE:a cache entry that is currently reprobed
476 NUD_FAILED:an invalid cache entry
477 NUD_NOARP:a device with no destination cache
478 NUD_PERMANENT:a static entry
487 NTF_PROXY:a proxy arp entry
488 NTF_ROUTER:an IPv6 router
492 .\" document the members of the struct better
495 struct has the following meanings for the
501 NDA_UNSPEC:unknown type
502 NDA_DST:a neighbor cache n/w layer destination address
503 NDA_LLADDR:a neighbor cache link layer address
504 NDA_CACHEINFO:cache statistics
512 .I struct nda_cacheinfo
520 Add, delete, or retrieve a routing rule.
529 Add, remove, or get a queueing discipline.
530 The message contains a
532 and may be followed by a series of
537 unsigned char tcm_family;
538 int tcm_ifindex; /* interface index */
539 __u32 tcm_handle; /* Qdisc handle */
540 __u32 tcm_parent; /* Parent qdisc */
549 rta_type:Value type:Description
551 TCA_UNSPEC:-:unspecified
552 TCA_KIND:asciiz string:Name of queueing discipline
553 TCA_OPTIONS:byte sequence:Qdisc-specific options follow
554 TCA_STATS:struct tc_stats:Qdisc statistics
555 TCA_XSTATS:qdisc-specific:Module-specific statistics
556 TCA_RATE:struct tc_estimator:Rate limit
559 In addition, various other qdisc-module-specific attributes are allowed.
560 For more information see the appropriate include files.
567 Add, remove, or get a traffic class.
568 These messages contain a
577 Add, remove, or receive information about a traffic filter.
578 These messages contain a
583 is a new feature of Linux 2.2.
585 This manual page is incomplete.