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
9 .\" help from Matthew Wilcox.
10 .\" $Id: rtnetlink.7,v 1.8 2000/01/22 01:55:04 freitag Exp $
11 .TH RTNETLINK 7 1999-04-30 "Linux" "Linux Programmer's Manual"
13 rtnetlink, NETLINK_ROUTE \- Linux IPv4 routing socket
15 .B #include <asm/types.h>
17 .B #include <linux/netlink.h>
19 .B #include <linux/rtnetlink.h>
21 .B #include <sys/socket.h>
23 .BI "rtnetlink_socket = socket(PF_NETLINK, int " socket_type ", NETLINK_ROUTE);"
25 Rtnetlink allows the kernel's routing tables to be read and altered.
26 It is used within the kernel to communicate between
27 various subsystems, though this usage is not documented here, and for
28 communication with user-space programs.
29 Network routes, ip addresses, link parameters, neighbour setups, queueing
30 disciplines, traffic classes and packet classifiers may all be controlled
34 It is based on netlink messages, see
37 .\" FIXME all these macros could be moved to rtnetlink(3)
38 .SS "Routing Attributes"
39 Some rtnetlink messages have optional attributes after the initial header:
43 unsigned short rta_len; /* Length of option */
44 unsigned short rta_type; /* Type of option */
49 These attributes should be only manipulated using the RTA_* macros
53 Rtnetlink consists of these message types
54 (in addition to standard netlink messages):
56 .BR RTM_NEWLINK ", " RTM_DELLINK ", " RTM_GETLINK
57 Create, remove or get information about a specific network interface.
58 These messages contain an
60 structure followed by a series of
66 unsigned char ifi_family; /* AF_UNSPEC */
67 unsigned short ifi_type; /* Device type */
68 int ifi_index; /* Interface index */
69 unsigned int ifi_flags; /* Device flags */
70 unsigned int ifi_change; /* change mask */
76 contains the device flags, see
79 is the unique interface index,
81 is reserved for future use and should be always set to 0xFFFFFFFF.
87 rta_type:value type:description
89 IFLA_UNSPEC:-:unspecified.
90 IFLA_ADDRESS:hardware address:interface L2 address
91 IFLA_BROADCAST:hardware address:L2 broadcast address.
92 IFLA_IFNAME:asciiz string:Device name.
93 IFLA_MTU:unsigned int:MTU of the device.
94 IFLA_LINK:int:Link type.
95 IFLA_QDISC:asciiz string:Queueing discipline.
98 T}:Interface Statistics.
101 The value type for IFLA_STATS is \fIstruct net_device_stats\fP.
103 .BR RTM_NEWADDR ", " RTM_DELADDR ", " RTM_GETADDR
104 Add, remove or receive information about an IP address associated with
106 In Linux 2.2 an interface can carry multiple IP addresses,
107 this replaces the alias device concept in 2.0.
108 In Linux 2.2 these messages
109 support IPv4 and IPv6 addresses.
112 structure, optionally followed by
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 */
127 is the address family type (currently
132 is the length of the address mask of the address if defined for the
133 family (like for IPv4),
135 is the address scope,
137 is the interface index of the interface the address is associated with.
141 for secondary address (old alias interface),
143 for a permanent address set by the user and other undocumented flags.
150 rta_type:value type:description
152 IFA_UNSPEC:-:unspecified.
153 IFA_ADDRESS:raw protocol address:interface address
154 IFA_LOCAL:raw protocol address:local address
155 IFA_LABEL:asciiz string:name of the interface
156 IFA_BROADCAST:raw protocol address:broadcast address.
157 IFA_ANYCAST:raw protocol address:anycast address
158 IFA_CACHEINFO:struct ifa_cacheinfo:Address information.
160 .\" FIXME struct ifa_cacheinfo
162 .BR RTM_NEWROUTE ", " RTM_DELROUTE ", " RTM_GETROUTE
163 Create, remove or receive information about a network route.
164 These messages contain an
166 structure with an optional sequence of
168 structures following.
175 to 0 means you get all entries for the specified routing table.
176 For the other fields except
184 unsigned char rtm_family; /* Address family of route */
185 unsigned char rtm_dst_len; /* Length of source */
186 unsigned char rtm_src_len; /* Length of destination */
187 unsigned char rtm_tos; /* TOS filter */
189 unsigned char rtm_table; /* Routing table ID */
190 unsigned char rtm_protocol; /* Routing protocol; see below */
191 unsigned char rtm_scope; /* See below */
192 unsigned char rtm_type; /* See below */
194 unsigned int rtm_flags;
204 RTN_UNSPEC:unknown route
205 RTN_UNICAST:a gateway or direct route
206 RTN_LOCAL:a local interface route
208 a local broadcast route (sent as a broadcast)
211 a local broadcast route (sent as a unicast)
213 RTN_MULTICAST:a multicast route
214 RTN_BLACKHOLE:a packet dropping route
215 RTN_UNREACHABLE:an unreachable destination
216 RTN_PROHIBIT:a packet rejection route
217 RTN_THROW:continue routing lookup in another table
218 RTN_NAT:a network address translation rule
220 refer to an external resolver (not implemented)
227 rtm_protocol:Route origin.
229 RTPROT_UNSPEC:unknown
231 by an ICMP redirect (currently unused)
233 RTPROT_KERNEL:by the kernel
234 RTPROT_BOOT:during boot
235 RTPROT_STATIC:by the administrator
240 are not interpreted by the kernel, they are just for user information.
241 They may be used to tag the source of a routing information or to
242 distinguish between multiple routing daemons.
244 .IR <linux/rtnetlink.h>
245 for the routing daemon identifiers which are already assigned.
248 is the distance to the destination:
253 RT_SCOPE_UNIVERSE:global route
255 interior route in the local autonomous system
257 RT_SCOPE_LINK:route on this link
258 RT_SCOPE_HOST:route on the local host
259 RT_SCOPE_NOWHERE:destination doesn't exist
266 are available to the user.
270 have the following meanings:
276 if the route changes, notify the user via rtnetlink
278 RTM_F_CLONED:route is cloned from another route
279 RTM_F_EQUALIZE:a multicast equalizer (not yet implemented)
283 specifies the routing table
288 RT_TABLE_UNSPEC:an unspecified routing table
289 RT_TABLE_DEFAULT:the default table
290 RT_TABLE_MAIN:the main table
291 RT_TABLE_LOCAL:the local table
294 The user may assign arbitrary values between
297 .BR RT_TABLE_DEFAULT .
304 rta_type:value type:description
306 RTA_UNSPEC:-:ignored.
307 RTA_DST:protocol address:Route destination address.
308 RTA_SRC:protocol address:Route source address.
309 RTA_IIF:int:Input interface index.
310 RTA_OIF:int:Output interface index.
311 RTA_GATEWAY:protocol address:The gateway of the route
312 RTA_PRIORITY:int:Priority of route.
314 RTA_METRICS:int:Route metric
321 .B Fill these values in!
323 .BR RTM_NEWNEIGH ", " RTM_DELNEIGH ", " RTM_GETNEIGH
324 Add, remove or receive information about a neighbour table
325 entry (e.g. an ARP entry).
326 The message contains an
332 unsigned char ndm_family;
333 int ndm_ifindex; /* Interface index */
334 __u16 ndm_state; /* State */
335 __u8 ndm_flags; /* Flags */
339 struct nda_cacheinfo {
348 is a bitmask of the following states:
353 NUD_INCOMPLETE:a currently resolving cache entry
354 NUD_REACHABLE:a confirmed working cache entry
355 NUD_STALE:an expired cache entry
356 NUD_DELAY:an entry waiting for a timer
357 NUD_PROBE:a cache entry that is currently reprobed
358 NUD_FAILED:an invalid cache entry
359 NUD_NOARP:a device with no destination cache
360 NUD_PERMANENT:a static entry
370 NTF_PROXY:a proxy arp entry
371 NTF_ROUTER:an IPv6 router
374 .B document the members of the struct better
378 struct has the following meanings for the
385 NDA_UNSPEC:unknown type
386 NDA_DST:a neighbour cache network layer destination address
387 NDA_LLADDR:a neighbour cache link layer address
388 NDA_CACHEINFO:cache statistics.
396 .I struct nda_cacheinfo
399 .BR RTM_NEWRULE ", " RTM_DELRULE ", " RTM_GETRULE
400 Add, delete or retrieve a routing rule.
404 .BR RTM_NEWQDISC ", " RTM_DELQDISC ", " RTM_GETQDISC
405 Add, remove or get a queueing discipline.
406 The message contains a
408 and may be followed by a series of
413 unsigned char tcm_family;
414 int tcm_ifindex; /* interface index */
415 __u32 tcm_handle; /* Qdisc handle */
416 __u32 tcm_parent; /* Parent qdisc */
426 rta_type:value type:Description
428 TCA_UNSPEC:-:unspecified
429 TCA_KIND:asciiz string:Name of queueing discipline
430 TCA_OPTIONS:byte sequence:Qdisc specific options follow
431 TCA_STATS:struct tc_stats:Qdisc statistics.
432 TCA_XSTATS:qdisc specific:Module specific statistics.
433 TCA_RATE:struct tc_estimator:Rate limit.
436 In addition various other qdisc module specific attributes are allowed.
437 For more information see the appropriate include files.
439 .BR RTM_NEWTCLASS ", " RTM_DELTCLASS ", " RTM_GETTCLASS
440 Add, remove or get a traffic class.
441 These messages contain a
445 .BR RTM_NEWTFILTER ", " RTM_DELTFILTER ", " RTM_GETTFILTER
446 Add, remove or receive information about a traffic filter.
447 These messages contain a
452 is a new feature of Linux 2.2.
454 This manual page is lacking and incomplete.