]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/rtnetlink.7
Convert to American spelling conventions
[thirdparty/man-pages.git] / man7 / rtnetlink.7
CommitLineData
fea681da
MK
1'\" t
2.\" Don't remove the line above, it tells man that tbl is needed.
3.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
4.\" Permission is granted to distribute possibly modified copies
5.\" of this page provided the header is included verbatim,
6.\" and in case of nontrivial modification author and date
7.\" of the modification is added to the header.
8.\" Based on the original comments from Alexey Kuznetsov, written with
c13182ef 9.\" help from Matthew Wilcox.
fea681da 10.\" $Id: rtnetlink.7,v 1.8 2000/01/22 01:55:04 freitag Exp $
69289f8a 11.TH RTNETLINK 7 1999-04-30 "Linux" "Linux Programmer's Manual"
fea681da
MK
12.SH NAME
13rtnetlink, NETLINK_ROUTE \- Linux IPv4 routing socket
14.SH SYNOPSIS
15.B #include <asm/types.h>
16.br
17.B #include <linux/netlink.h>
18.br
19.B #include <linux/rtnetlink.h>
20.br
21.B #include <sys/socket.h>
22
23.BI "rtnetlink_socket = socket(PF_NETLINK, int " socket_type ", NETLINK_ROUTE);"
fea681da 24.SH DESCRIPTION
c13182ef 25Rtnetlink allows the kernel's routing tables to be read and altered.
fea681da 26It is used within the kernel to communicate between
c13182ef 27various subsystems, though this usage is not documented here, and for
fea681da 28communication with user-space programs.
d9bfdb9c 29Network routes, ip addresses, link parameters, neighbor setups, queueing
fea681da
MK
30disciplines, traffic classes and packet classifiers may all be controlled
31through
32.B NETLINK_ROUTE
c13182ef
MK
33sockets.
34It is based on netlink messages, see
fea681da 35.BR netlink (7)
c13182ef
MK
36for more information.
37.\" FIXME all these macros could be moved to rtnetlink(3)
051815fe 38.SS "Routing Attributes"
fea681da
MK
39Some rtnetlink messages have optional attributes after the initial header:
40
41.nf
56185b42 42struct rtattr {
87866492
MK
43 unsigned short rta_len; /* Length of option */
44 unsigned short rta_type; /* Type of option */
c13182ef 45 /* Data follows */
fea681da
MK
46};
47.fi
48
c13182ef 49These attributes should be only manipulated using the RTA_* macros
9fdfa163 50or libnetlink, see
fea681da 51.BR rtnetlink (3).
051815fe 52.SS Messages
fea681da
MK
53Rtnetlink consists of these message types
54(in addition to standard netlink messages):
55.TP
56.BR RTM_NEWLINK ", " RTM_DELLINK ", " RTM_GETLINK
c13182ef 57Create, remove or get information about a specific network interface.
fea681da
MK
58These messages contain an
59.B ifinfomsg
60structure followed by a series of
61.B rtattr
62structures.
63
64.nf
56185b42 65struct ifinfomsg {
87866492 66 unsigned char ifi_family; /* AF_UNSPEC */
c13182ef 67 unsigned short ifi_type; /* Device type */
87866492
MK
68 int ifi_index; /* Interface index */
69 unsigned int ifi_flags; /* Device flags */
70 unsigned int ifi_change; /* change mask */
fea681da
MK
71};
72.fi
73
a749f870 74.\" FIXME ifi_type
c13182ef 75.B ifi_flags
fea681da 76contains the device flags, see
a7e1c01a 77.BR netdevice (7);
fea681da
MK
78.B ifi_index
79is the unique interface index,
80.B ifi_change
c13182ef 81is reserved for future use and should be always set to 0xFFFFFFFF.
fea681da
MK
82.TS
83tab(:);
84c
85l l l.
86Routing attributes
87rta_type:value type:description
88_
89IFLA_UNSPEC:-:unspecified.
c13182ef 90IFLA_ADDRESS:hardware address:interface L2 address
fea681da
MK
91IFLA_BROADCAST:hardware address:L2 broadcast address.
92IFLA_IFNAME:asciiz string:Device name.
93IFLA_MTU:unsigned int:MTU of the device.
94IFLA_LINK:int:Link type.
95IFLA_QDISC:asciiz string:Queueing discipline.
96IFLA_STATS:T{
be1d83d4 97see below
fea681da
MK
98T}:Interface Statistics.
99.TE
be1d83d4
MK
100.sp
101The value type for IFLA_STATS is \fIstruct net_device_stats\fP.
87866492
MK
102.TP
103.BR RTM_NEWADDR ", " RTM_DELADDR ", " RTM_GETADDR
c13182ef
MK
104Add, remove or receive information about an IP address associated with
105an interface.
106In Linux 2.2 an interface can carry multiple IP addresses,
107this replaces the alias device concept in 2.0.
108In Linux 2.2 these messages
109support IPv4 and IPv6 addresses.
110They contain an
fea681da
MK
111.B ifaddrmsg
112structure, optionally followed by
113.B rtaddr
114routing attributes.
115
116.nf
56185b42 117struct ifaddrmsg {
87866492
MK
118 unsigned char ifa_family; /* Address type */
119 unsigned char ifa_prefixlen; /* Prefixlength of address */
120 unsigned char ifa_flags; /* Address flags */
121 unsigned char ifa_scope; /* Address scope */
122 int ifa_index; /* Interface index */
fea681da
MK
123};
124.fi
125
126.B ifa_family
c13182ef 127is the address family type (currently
fea681da
MK
128.B AF_INET
129or
c13182ef 130.BR AF_INET6 ),
fea681da 131.B ifa_prefixlen
c13182ef
MK
132is the length of the address mask of the address if defined for the
133family (like for IPv4),
fea681da
MK
134.B ifa_scope
135is the address scope,
136.B ifa_index
c13182ef 137is the interface index of the interface the address is associated with.
fea681da
MK
138.B ifa_flags
139is a flag word of
140.B IFA_F_SECONDARY
c13182ef 141for secondary address (old alias interface),
fea681da
MK
142.B IFA_F_PERMANENT
143for a permanent address set by the user and other undocumented flags.
144
145.TS
146tab(:);
147c
148l l l.
149Attributes
150rta_type:value type:description
151_
152IFA_UNSPEC:-:unspecified.
153IFA_ADDRESS:raw protocol address:interface address
154IFA_LOCAL:raw protocol address:local address
155IFA_LABEL:asciiz string:name of the interface
156IFA_BROADCAST:raw protocol address:broadcast address.
157IFA_ANYCAST:raw protocol address:anycast address
c13182ef 158IFA_CACHEINFO:struct ifa_cacheinfo:Address information.
fea681da 159.TE
a749f870 160.\" FIXME struct ifa_cacheinfo
87866492
MK
161.TP
162.BR RTM_NEWROUTE ", " RTM_DELROUTE ", " RTM_GETROUTE
fea681da
MK
163Create, remove or receive information about a network route.
164These messages contain an
165.B rtmsg
c13182ef 166structure with an optional sequence of
fea681da 167.B rtattr
c13182ef
MK
168structures following.
169For
fea681da 170.B RTM_GETROUTE
c13182ef
MK
171setting
172.B rtm_dst_len
173and
174.B rtm_src_len
fea681da 175to 0 means you get all entries for the specified routing table.
c13182ef
MK
176For the other fields except
177.B rtm_table
178and
fea681da
MK
179.B rtm_protocol
1800 is the wildcard.
181
182.nf
56185b42 183struct rtmsg {
87866492
MK
184 unsigned char rtm_family; /* Address family of route */
185 unsigned char rtm_dst_len; /* Length of source */
c13182ef 186 unsigned char rtm_src_len; /* Length of destination */
87866492 187 unsigned char rtm_tos; /* TOS filter */
fea681da 188
87866492
MK
189 unsigned char rtm_table; /* Routing table ID */
190 unsigned char rtm_protocol; /* Routing protocol; see below */
c13182ef 191 unsigned char rtm_scope; /* See below */
87866492 192 unsigned char rtm_type; /* See below */
fea681da 193
87866492 194 unsigned int rtm_flags;
fea681da
MK
195};
196.fi
197
198.TS
199tab(:);
200l l
201l l.
202rtm_type:Route type
203_
204RTN_UNSPEC:unknown route
205RTN_UNICAST:a gateway or direct route
206RTN_LOCAL:a local interface route
207RTN_BROADCAST:T{
208a local broadcast route (sent as a broadcast)
209T}
210RTN_ANYCAST:T{
211a local broadcast route (sent as a unicast)
212T}
213RTN_MULTICAST:a multicast route
214RTN_BLACKHOLE:a packet dropping route
215RTN_UNREACHABLE:an unreachable destination
216RTN_PROHIBIT:a packet rejection route
217RTN_THROW:continue routing lookup in another table
218RTN_NAT:a network address translation rule
219RTN_XRESOLVE:T{
220refer to an external resolver (not implemented)
221T}
222.TE
223
224.TS
225tab(:);
226l l.
227rtm_protocol:Route origin.
228_
229RTPROT_UNSPEC:unknown
230RTPROT_REDIRECT:T{
231by an ICMP redirect (currently unused)
232T}
233RTPROT_KERNEL:by the kernel
234RTPROT_BOOT:during boot
235RTPROT_STATIC:by the administrator
236.TE
237
238Values larger than
239.B RTPROT_STATIC
9fdfa163 240are not interpreted by the kernel, they are just for user information.
c13182ef
MK
241They may be used to tag the source of a routing information or to
242distinguish between multiple routing daemons.
243See
bd12ab88 244.IR <linux/rtnetlink.h>
c13182ef 245for the routing daemon identifiers which are already assigned.
fea681da 246
c13182ef
MK
247.B rtm_scope
248is the distance to the destination:
fea681da
MK
249
250.TS
251tab(:);
252l l.
253RT_SCOPE_UNIVERSE:global route
254RT_SCOPE_SITE:T{
255interior route in the local autonomous system
256T}
257RT_SCOPE_LINK:route on this link
258RT_SCOPE_HOST:route on the local host
259RT_SCOPE_NOWHERE:destination doesn't exist
260.TE
261
262The values between
263.B RT_SCOPE_UNIVERSE
264and
265.B RT_SCOPE_SITE
266are available to the user.
267
268The
269.B rtm_flags
270have the following meanings:
271
272.TS
273tab(:);
274l l.
275RTM_F_NOTIFY:T{
276if the route changes, notify the user via rtnetlink
277T}
278RTM_F_CLONED:route is cloned from another route
279RTM_F_EQUALIZE:a multicast equalizer (not yet implemented)
280.TE
281
282.B rtm_table
283specifies the routing table
284
285.TS
286tab(:);
287l l.
288RT_TABLE_UNSPEC:an unspecified routing table
289RT_TABLE_DEFAULT:the default table
290RT_TABLE_MAIN:the main table
291RT_TABLE_LOCAL:the local table
292.TE
293
9fdfa163 294The user may assign arbitrary values between
fea681da
MK
295.B RT_TABLE_UNSPEC
296and
297.BR RT_TABLE_DEFAULT .
298
299.TS
300tab(:);
301c
302l l l.
303Attributes
304rta_type:value type:description
305_
306RTA_UNSPEC:-:ignored.
307RTA_DST:protocol address:Route destination address.
308RTA_SRC:protocol address:Route source address.
309RTA_IIF:int:Input interface index.
310RTA_OIF:int:Output interface index.
311RTA_GATEWAY:protocol address:The gateway of the route
312RTA_PRIORITY:int:Priority of route.
313RTA_PREFSRC::
314RTA_METRICS:int:Route metric
315RTA_MULTIPATH::
316RTA_PROTOINFO::
317RTA_FLOW::
318RTA_CACHEINFO::
319.TE
320
321.B Fill these values in!
87866492
MK
322.TP
323.BR RTM_NEWNEIGH ", " RTM_DELNEIGH ", " RTM_GETNEIGH
d9bfdb9c 324Add, remove or receive information about a neighbor table
c13182ef
MK
325entry (e.g. an ARP entry).
326The message contains an
fea681da
MK
327.B ndmsg
328structure.
329
330.nf
56185b42 331struct ndmsg {
87866492
MK
332 unsigned char ndm_family;
333 int ndm_ifindex; /* Interface index */
c13182ef 334 __u16 ndm_state; /* State */
87866492 335 __u8 ndm_flags; /* Flags */
c13182ef 336 __u8 ndm_type;
fea681da
MK
337};
338
56185b42 339struct nda_cacheinfo {
87866492
MK
340 __u32 ndm_confirmed;
341 __u32 ndm_used;
342 __u32 ndm_updated;
343 __u32 ndm_refcnt;
fea681da
MK
344};
345.fi
346
347.B ndm_state
c13182ef 348is a bitmask of the following states:
fea681da
MK
349
350.TS
351tab(:);
352l l.
353NUD_INCOMPLETE:a currently resolving cache entry
354NUD_REACHABLE:a confirmed working cache entry
355NUD_STALE:an expired cache entry
356NUD_DELAY:an entry waiting for a timer
357NUD_PROBE:a cache entry that is currently reprobed
358NUD_FAILED:an invalid cache entry
359NUD_NOARP:a device with no destination cache
360NUD_PERMANENT:a static entry
361.TE
362
363Valid
364.B ndm_flags
365are:
366
367.TS
368tab(:);
369l l.
370NTF_PROXY:a proxy arp entry
371NTF_ROUTER:an IPv6 router
372.TE
373
374.B document the members of the struct better
375
376The
377.B rtaddr
378struct has the following meanings for the
379.B rta_type
380field:
381
382.TS
383tab(:);
384l l.
385NDA_UNSPEC:unknown type
d9bfdb9c
MK
386NDA_DST:a neighbor cache n/w layer destination address
387NDA_LLADDR:a neighbor cache link layer address
fea681da
MK
388NDA_CACHEINFO:cache statistics.
389.TE
390
391If the
392.B rta_type
393field is
394.B NDA_CACHEINFO
395then a
8478ee02 396.I struct nda_cacheinfo
fea681da
MK
397header follows
398.TP
399.BR RTM_NEWRULE ", " RTM_DELRULE ", " RTM_GETRULE
c13182ef
MK
400Add, delete or retrieve a routing rule.
401Carries a
8478ee02 402.I struct rtmsg
fea681da
MK
403.TP
404.BR RTM_NEWQDISC ", " RTM_DELQDISC ", " RTM_GETQDISC
c13182ef
MK
405Add, remove or get a queueing discipline.
406The message contains a
8478ee02 407.I struct tcmsg
fea681da
MK
408and may be followed by a series of
409attributes.
410
411.nf
56185b42 412struct tcmsg {
87866492
MK
413 unsigned char tcm_family;
414 int tcm_ifindex; /* interface index */
c13182ef 415 __u32 tcm_handle; /* Qdisc handle */
87866492
MK
416 __u32 tcm_parent; /* Parent qdisc */
417 __u32 tcm_info;
fea681da
MK
418};
419.fi
420
421.TS
422tab(:);
423c
424l l l.
425Attributes
426rta_type:value type:Description
427_
428TCA_UNSPEC:-:unspecified
429TCA_KIND:asciiz string:Name of queueing discipline
430TCA_OPTIONS:byte sequence:Qdisc specific options follow
431TCA_STATS:struct tc_stats:Qdisc statistics.
432TCA_XSTATS:qdisc specific:Module specific statistics.
433TCA_RATE:struct tc_estimator:Rate limit.
434.TE
435
436In addition various other qdisc module specific attributes are allowed.
437For more information see the appropriate include files.
438.TP
439.BR RTM_NEWTCLASS ", " RTM_DELTCLASS ", " RTM_GETTCLASS
c13182ef
MK
440Add, remove or get a traffic class.
441These messages contain a
8478ee02 442.I struct tcmsg
fea681da
MK
443as described above.
444.TP
445.BR RTM_NEWTFILTER ", " RTM_DELTFILTER ", " RTM_GETTFILTER
c13182ef
MK
446Add, remove or receive information about a traffic filter.
447These messages contain a
8478ee02 448.I struct tcmsg
fea681da
MK
449as described above.
450.SH VERSIONS
c13182ef 451.B rtnetlink
fea681da
MK
452is a new feature of Linux 2.2.
453.SH BUGS
27fcc638 454This manual page is incomplete.
fea681da
MK
455.SH "SEE ALSO"
456.BR cmsg (3),
457.BR rtnetlink (3),
458.BR ip (7),
459.BR netlink (7)