tzfile.5, tzselect.8: sync from tzdb upstream
[man-pages.git] / man7 / rtnetlink.7
blob2ce541c37b6e6b0dc46631823325b7fa6ce93512
1 '\" t
2 .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
3 .\"
4 .\" %%%LICENSE_START(VERBATIM_ONE_PARA)
5 .\" Permission is granted to distribute possibly modified copies
6 .\" of this page provided the header is included verbatim,
7 .\" and in case of nontrivial modification author and date
8 .\" of the modification is added to the header.
9 .\" %%%LICENSE_END
10 .\"
11 .\" Based on the original comments from Alexey Kuznetsov, written with
12 .\" help from Matthew Wilcox.
13 .\" $Id: rtnetlink.7,v 1.8 2000/01/22 01:55:04 freitag Exp $
14 .\"
15 .TH rtnetlink 7 (date) "Linux man-pages (unreleased)"
16 .SH NAME
17 rtnetlink \- Linux routing socket
18 .SH SYNOPSIS
19 .nf
20 .B #include <asm/types.h>
21 .B #include <linux/netlink.h>
22 .B #include <linux/rtnetlink.h>
23 .B #include <sys/socket.h>
24 .PP
25 .BI "rtnetlink_socket = socket(AF_NETLINK, int " socket_type ", NETLINK_ROUTE);"
26 .fi
27 .SH DESCRIPTION
28 Rtnetlink allows the kernel's routing tables to be read and altered.
29 It is used within the kernel to communicate between
30 various subsystems, though this usage is not documented here, and for
31 communication with user-space programs.
32 Network routes, IP addresses, link parameters, neighbor setups, queueing
33 disciplines, traffic classes and packet classifiers may all be controlled
34 through
35 .B NETLINK_ROUTE
36 sockets.
37 It is based on netlink messages; see
38 .BR netlink (7)
39 for more information.
40 .\" FIXME . ? all these macros could be moved to rtnetlink(3)
41 .SS Routing attributes
42 Some rtnetlink messages have optional attributes after the initial header:
43 .PP
44 .in +4n
45 .EX
46 struct rtattr {
47     unsigned short rta_len;    /* Length of option */
48     unsigned short rta_type;   /* Type of option */
49     /* Data follows */
51 .EE
52 .in
53 .PP
54 These attributes should be manipulated using only the RTA_* macros
55 or libnetlink, see
56 .BR rtnetlink (3).
57 .SS Messages
58 Rtnetlink consists of these message types
59 (in addition to standard netlink messages):
60 .TP
61 .BR RTM_NEWLINK ", " RTM_DELLINK ", " RTM_GETLINK
62 Create, remove, or get information about a specific network interface.
63 These messages contain an
64 .I ifinfomsg
65 structure followed by a series of
66 .I rtattr
67 structures.
68 .IP
69 .EX
70 struct ifinfomsg {
71     unsigned char  ifi_family; /* AF_UNSPEC */
72     unsigned short ifi_type;   /* Device type */
73     int            ifi_index;  /* Interface index */
74     unsigned int   ifi_flags;  /* Device flags  */
75     unsigned int   ifi_change; /* change mask */
77 .EE
78 .IP
79 .\" FIXME Document ifinfomsg.ifi_type
80 .I ifi_flags
81 contains the device flags, see
82 .BR netdevice (7);
83 .I ifi_index
84 is the unique interface index
85 (since Linux 3.7, it is possible to feed a nonzero value with the
86 .B RTM_NEWLINK
87 message, thus creating a link with the given
88 .IR ifindex );
89 .I ifi_change
90 is reserved for future use and should be always set to 0xFFFFFFFF.
91 .TS
92 tab(:);
93 c s s
94 lb l l.
95 Routing attributes
96 rta_type:Value type:Description
98 IFLA_UNSPEC:-:unspecified
99 IFLA_ADDRESS:hardware address:interface L2 address
100 IFLA_BROADCAST:hardware address:L2 broadcast address
101 IFLA_IFNAME:asciiz string:Device name
102 IFLA_MTU:unsigned int:MTU of the device
103 IFLA_LINK:int:Link type
104 IFLA_QDISC:asciiz string:Queueing discipline
105 IFLA_STATS:T{
106 see below
107 T}:Interface Statistics
110 The value type for
111 .B IFLA_STATS
113 .I struct rtnl_link_stats
114 .RI ( "struct net_device_stats"
115 in Linux 2.4 and earlier).
117 .BR RTM_NEWADDR ", " RTM_DELADDR ", " RTM_GETADDR
118 Add, remove, or receive information about an IP address associated with
119 an interface.
120 In Linux 2.2, an interface can carry multiple IP addresses,
121 this replaces the alias device concept in Linux 2.0.
122 In Linux 2.2, these messages
123 support IPv4 and IPv6 addresses.
124 They contain an
125 .I ifaddrmsg
126 structure, optionally followed by
127 .I rtattr
128 routing attributes.
131 struct ifaddrmsg {
132     unsigned char ifa_family;    /* Address type */
133     unsigned char ifa_prefixlen; /* Prefixlength of address */
134     unsigned char ifa_flags;     /* Address flags */
135     unsigned char ifa_scope;     /* Address scope */
136     unsigned int  ifa_index;     /* Interface index */
140 .I ifa_family
141 is the address family type (currently
142 .B AF_INET
144 .BR AF_INET6 ),
145 .I ifa_prefixlen
146 is the length of the address mask of the address if defined for the
147 family (like for IPv4),
148 .I ifa_scope
149 is the address scope,
150 .I ifa_index
151 is the interface index of the interface the address is associated with.
152 .I ifa_flags
153 is a flag word of
154 .B IFA_F_SECONDARY
155 for secondary address (old alias interface),
156 .B IFA_F_PERMANENT
157 for a permanent address set by the user and other undocumented flags.
159 tab(:);
160 c s s
161 lb l l.
162 Attributes
163 rta_type:Value type:Description
165 IFA_UNSPEC:-:unspecified
166 IFA_ADDRESS:raw protocol address:interface address
167 IFA_LOCAL:raw protocol address:local address
168 IFA_LABEL:asciiz string:name of the interface
169 IFA_BROADCAST:raw protocol address:broadcast address
170 IFA_ANYCAST:raw protocol address:anycast address
171 IFA_CACHEINFO:struct ifa_cacheinfo:Address information
173 .\" FIXME Document struct ifa_cacheinfo
175 .BR RTM_NEWROUTE ", " RTM_DELROUTE ", " RTM_GETROUTE
176 Create, remove, or receive information about a network route.
177 These messages contain an
178 .I rtmsg
179 structure with an optional sequence of
180 .I rtattr
181 structures following.
183 .BR RTM_GETROUTE ,
184 setting
185 .I rtm_dst_len
187 .I rtm_src_len
188 to 0 means you get all entries for the specified routing table.
189 For the other fields, except
190 .I rtm_table
192 .IR rtm_protocol ,
193 0 is the wildcard.
196 struct rtmsg {
197     unsigned char rtm_family;   /* Address family of route */
198     unsigned char rtm_dst_len;  /* Length of destination */
199     unsigned char rtm_src_len;  /* Length of source */
200     unsigned char rtm_tos;      /* TOS filter */
201     unsigned char rtm_table;    /* Routing table ID;
202                                    see RTA_TABLE below */
203     unsigned char rtm_protocol; /* Routing protocol; see below */
204     unsigned char rtm_scope;    /* See below */
205     unsigned char rtm_type;     /* See below */
207     unsigned int  rtm_flags;
211 tab(:);
212 lb l.
213 rtm_type:Route type
215 RTN_UNSPEC:unknown route
216 RTN_UNICAST:a gateway or direct route
217 RTN_LOCAL:a local interface route
218 RTN_BROADCAST:T{
219 a local broadcast route (sent as a broadcast)
221 RTN_ANYCAST:T{
222 a local broadcast route (sent as a unicast)
224 RTN_MULTICAST:a multicast route
225 RTN_BLACKHOLE:a packet dropping route
226 RTN_UNREACHABLE:an unreachable destination
227 RTN_PROHIBIT:a packet rejection route
228 RTN_THROW:continue routing lookup in another table
229 RTN_NAT:a network address translation rule
230 RTN_XRESOLVE:T{
231 refer to an external resolver (not implemented)
235 tab(:);
236 lb l.
237 rtm_protocol:Route origin
239 RTPROT_UNSPEC:unknown
240 RTPROT_REDIRECT:T{
241 by an ICMP redirect (currently unused)
243 RTPROT_KERNEL:by the kernel
244 RTPROT_BOOT:during boot
245 RTPROT_STATIC:by the administrator
247 .sp 1
248 Values larger than
249 .B RTPROT_STATIC
250 are not interpreted by the kernel, they are just for user information.
251 They may be used to tag the source of a routing information or to
252 distinguish between multiple routing daemons.
254 .I <linux/rtnetlink.h>
255 for the routing daemon identifiers which are already assigned.
257 .I rtm_scope
258 is the distance to the destination:
260 tab(:);
261 lb l.
262 RT_SCOPE_UNIVERSE:global route
263 RT_SCOPE_SITE:T{
264 interior route in the local autonomous system
266 RT_SCOPE_LINK:route on this link
267 RT_SCOPE_HOST:route on the local host
268 RT_SCOPE_NOWHERE:destination doesn't exist
270 .sp 1
271 The values between
272 .B RT_SCOPE_UNIVERSE
274 .B RT_SCOPE_SITE
275 are available to the user.
278 .I rtm_flags
279 have the following meanings:
281 tab(:);
282 lb l.
283 RTM_F_NOTIFY:T{
284 if the route changes, notify the user via rtnetlink
286 RTM_F_CLONED:route is cloned from another route
287 RTM_F_EQUALIZE:a multipath equalizer (not yet implemented)
289 .sp 1
290 .I rtm_table
291 specifies the routing table
293 tab(:);
294 lb l.
295 RT_TABLE_UNSPEC:an unspecified routing table
296 RT_TABLE_DEFAULT:the default table
297 RT_TABLE_MAIN:the main table
298 RT_TABLE_LOCAL:the local table
300 .sp 1
301 The user may assign arbitrary values between
302 .B RT_TABLE_UNSPEC
304 .BR RT_TABLE_DEFAULT .
305 .\" Keep table on same page
306 .bp +1
308 tab(:);
309 c s s
310 lb2 l2 l.
311 Attributes
312 rta_type:Value type:Description
314 RTA_UNSPEC:-:ignored
315 RTA_DST:protocol address:Route destination address
316 RTA_SRC:protocol address:Route source address
317 RTA_IIF:int:Input interface index
318 RTA_OIF:int:Output interface index
319 RTA_GATEWAY:protocol address:The gateway of the route
320 RTA_PRIORITY:int:Priority of route
321 RTA_PREFSRC:protocol address:Preferred source address
322 RTA_METRICS:int:Route metric
323 RTA_MULTIPATH::T{
324 Multipath nexthop data
326 (see below).
328 RTA_PROTOINFO::No longer used
329 RTA_FLOW:int:Route realm
330 RTA_CACHEINFO:struct rta_cacheinfo:(see linux/rtnetlink.h)
331 RTA_SESSION::No longer used
332 RTA_MP_ALGO::No longer used
333 RTA_TABLE:int:T{
334 Routing table ID; if set,
336 rtm_table is ignored
338 RTA_MARK:int:
339 RTA_MFC_STATS:struct rta_mfc_stats:(see linux/rtnetlink.h)
340 RTA_VIA:struct rtvia:T{
341 Gateway in different AF
342 (see below)
344 RTA_NEWDST:protocol address:T{
345 Change packet
346 destination address
348 RTA_PREF:char:T{
349 RFC4191 IPv6 router
350 preference (see below)
352 RTA_ENCAP_TYPE:short:T{
353 Encapsulation type for
355 lwtunnels (see below)
357 RTA_ENCAP::Defined by RTA_ENCAP_TYPE
358 RTA_EXPIRES:int:T{
359 Expire time for IPv6
360 routes (in seconds)
364 .B RTA_MULTIPATH
365 contains several packed instances of
366 .I struct rtnexthop
367 together with nested RTAs
368 .RB ( RTA_GATEWAY ):
370 .in +4n
372 struct rtnexthop {
373     unsigned short rtnh_len;     /* Length of struct + length
374                                     of RTAs */
375     unsigned char  rtnh_flags;   /* Flags (see
376                                     linux/rtnetlink.h) */
377     unsigned char  rtnh_hops;    /* Nexthop priority */
378     int            rtnh_ifindex; /* Interface index for this
379                                     nexthop */
384 There exist a bunch of
385 .B RTNH_*
386 macros similar to
387 .B RTA_*
389 .B NLHDR_*
390 macros
391 useful to handle these structures.
393 .in +4n
395 struct rtvia {
396     unsigned short rtvia_family;
397     unsigned char  rtvia_addr[0];
402 .I rtvia_addr
403 is the address,
404 .I rtvia_family
405 is its family type.
407 .B RTA_PREF
408 may contain values
409 .BR ICMPV6_ROUTER_PREF_LOW ,
410 .BR ICMPV6_ROUTER_PREF_MEDIUM ,
412 .B ICMPV6_ROUTER_PREF_HIGH
413 defined incw
414 .IR <linux/icmpv6.h> .
416 .B RTA_ENCAP_TYPE
417 may contain values
418 .BR LWTUNNEL_ENCAP_MPLS ,
419 .BR LWTUNNEL_ENCAP_IP ,
420 .BR LWTUNNEL_ENCAP_ILA ,
422 .B LWTUNNEL_ENCAP_IP6
423 defined in
424 .IR <linux/lwtunnel.h> .
426 .B Fill these values in!
428 .BR RTM_NEWNEIGH ", " RTM_DELNEIGH  ", " RTM_GETNEIGH
429 Add, remove, or receive information about a neighbor table
430 entry (e.g., an ARP entry).
431 The message contains an
432 .I ndmsg
433 structure.
436 struct ndmsg {
437     unsigned char ndm_family;
438     int           ndm_ifindex;  /* Interface index */
439     __u16         ndm_state;    /* State */
440     __u8          ndm_flags;    /* Flags */
441     __u8          ndm_type;
444 struct nda_cacheinfo {
445     __u32         ndm_confirmed;
446     __u32         ndm_used;
447     __u32         ndm_updated;
448     __u32         ndm_refcnt;
452 .I ndm_state
453 is a bit mask of the following states:
455 tab(:);
456 lb l.
457 NUD_INCOMPLETE:a currently resolving cache entry
458 NUD_REACHABLE:a confirmed working cache entry
459 NUD_STALE:an expired cache entry
460 NUD_DELAY:an entry waiting for a timer
461 NUD_PROBE:a cache entry that is currently reprobed
462 NUD_FAILED:an invalid cache entry
463 NUD_NOARP:a device with no destination cache
464 NUD_PERMANENT:a static entry
466 .sp 1
467 Valid
468 .I ndm_flags
469 are:
471 tab(:);
472 lb l.
473 NTF_PROXY:a proxy arp entry
474 NTF_ROUTER:an IPv6 router
476 .sp 1
477 .\" FIXME .
478 .\" document the members of the struct better
480 .I rtattr
481 struct has the following meanings for the
482 .I rta_type
483 field:
485 tab(:);
486 lb l.
487 NDA_UNSPEC:unknown type
488 NDA_DST:a neighbor cache n/w layer destination address
489 NDA_LLADDR:a neighbor cache link layer address
490 NDA_CACHEINFO:cache statistics
492 .sp 1
493 If the
494 .I rta_type
495 field is
496 .BR NDA_CACHEINFO ,
497 then a
498 .I struct nda_cacheinfo
499 header follows.
501 .BR RTM_NEWRULE ", " RTM_DELRULE ", " RTM_GETRULE
502 Add, delete, or retrieve a routing rule.
503 Carries a
504 .I struct rtmsg
506 .BR RTM_NEWQDISC ", " RTM_DELQDISC ", " RTM_GETQDISC
507 Add, remove, or get a queueing discipline.
508 The message contains a
509 .I struct tcmsg
510 and may be followed by a series of
511 attributes.
514 struct tcmsg {
515     unsigned char    tcm_family;
516     int              tcm_ifindex;   /* interface index */
517     __u32            tcm_handle;    /* Qdisc handle */
518     __u32            tcm_parent;    /* Parent qdisc */
519     __u32            tcm_info;
523 tab(:);
524 c s s
525 lb2 l2 l.
526 Attributes
527 rta_type:Value type:Description
529 TCA_UNSPEC:-:unspecified
530 TCA_KIND:asciiz string:Name of queueing discipline
531 TCA_OPTIONS:byte sequence:Qdisc-specific options follow
532 TCA_STATS:struct tc_stats:Qdisc statistics
533 TCA_XSTATS:qdisc-specific:Module-specific statistics
534 TCA_RATE:struct tc_estimator:Rate limit
536 .sp 1
537 In addition, various other qdisc-module-specific attributes are allowed.
538 For more information see the appropriate include files.
540 .BR RTM_NEWTCLASS ", " RTM_DELTCLASS ", " RTM_GETTCLASS
541 Add, remove, or get a traffic class.
542 These messages contain a
543 .I struct tcmsg
544 as described above.
546 .BR RTM_NEWTFILTER ", " RTM_DELTFILTER ", " RTM_GETTFILTER
547 Add, remove, or receive information about a traffic filter.
548 These messages contain a
549 .I struct tcmsg
550 as described above.
551 .SH VERSIONS
552 .B rtnetlink
553 is a new feature of Linux 2.2.
554 .SH BUGS
555 This manual page is incomplete.
556 .SH SEE ALSO
557 .BR cmsg (3),
558 .BR rtnetlink (3),
559 .BR ip (7),
560 .BR netlink (7)