Penguin
Blame: rtnetlink(7)
EditPageHistoryDiffInfoLikePages
Annotated edit history of rtnetlink(7) version 1, including all changes. View license author blame.
Rev Author # Line
1 perry 1 RTNETLINK
2 !!!RTNETLINK
3 NAME
4 SYNOPSIS
5 DESCRIPTION
6 ROUTING ATTRIBUTES
7 MESSAGES
8 VERSIONS
9 BUGS
10 SEE ALSO
11 ----
12 !!NAME
13
14
15 rtnetlink, NETLINK_ROUTE - Linux IPv4 routing socket.
16 !!SYNOPSIS
17
18
19 __#include __
20 #include __
21 #include __
22 #include __
23
24
25 __rtnetlink_socket = socket(PF_NETLINK, int__
26 ''socket_type''__, NETLINK_ROUTE);__
27 !!DESCRIPTION
28
29
30 Rtnetlink allows the kernel's routing tables to be read and
31 altered. It is used within the kernel to communicate between
32 various subsystems, though this usage is not documented
33 here, and for communication with user-space programs.
34 Network routes, ip addresses, link parameters, neighbour
35 setups, queueing disciplines, traffic classes and packet
36 classifiers may all be controlled through
37 __NETLINK_ROUTE__ sockets. It is based on netlink
38 messages, see netlink(7) for more
39 information.
40 !!ROUTING ATTRIBUTES
41
42
43 Some rtnetlink messages have optional attributes after the
44 initial header:
45
46
47 struct rtattr
48 {
49 unsigned short rta_len; /* Length of option */
50 unsigned short rta_type; /* Type of option */
51 /* Data follows */
52 };
53 These attributes should be only manipulated using the RTA_* macros or libnetlink, see rtnetlink(3).
54 !!MESSAGES
55
56
57 Rtnetlink consists of these message types (in addition to
58 standard netlink messages):
59
60
61 __RTM_NEWLINK__, __RTM_DELLINK__,
62 __RTM_GETLINK__
63
64
65 Create, remove or get information about a specific network
66 interface. These messages contain an __ifinfomsg__
67 structure followed by a series of __rtattr__
68 structures.
69
70
71 struct ifinfomsg
72 {
73 unsigned char ifi_family; /* AF_UNSPEC */
74 unsigned short ifi_type; /* Device type */
75 int ifi_index; /* Interface index */
76 unsigned int ifi_flags; /* Device flags */
77 unsigned int ifi_change; /* change mask */
78 };
79 __ifi_flags__ contains the device flags, see __netdevice(7); ifi_index__ is the unique interface index, __ifi_change__ is reserved for future use and should be always set to 0xFFFFFFFF.
80
81
82 __RTM_NEWADDR__, __RTM_DELADDR__, __RTM_GETADDR__
83
84
85 Add, remove or receive information about an IP address
86 associated with an interface. In Linux 2.2 an interface can
87 carry multiple IP addresses, this replaces the alias device
88 concept in 2.0. In Linux 2.2 these messages support IPv4 and
89 IPv6 addresses. They contain an __ifaddrmsg__ structure,
90 optionally followed by __rtaddr__ routing
91 attributes.
92
93
94 struct ifaddrmsg
95 {
96 unsigned char ifa_family; /* Address type */
97 unsigned char ifa_prefixlen;/* Prefixlength of the address */
98 unsigned char ifa_flags; /* Address flags */
99 unsigned char ifa_scope; /* Address scope */
100 int ifa_index; /* Interface index */
101 };
102 __ifa_family__ is the address family type (currently __AF_INET__ or __AF_INET6), ifa_prefixlen__ is the length of the address mask of the address if defined for the family (like for IPv4), __ifa_scope__ is the address scope, __ifa_index__ is the interface index of the interface the address is associated with. __ifa_flags__ is a flag word of __IFA_F_SECONDARY__ for secondary address (old alias interface), __IFA_F_PERMANENT__ for a permanent address set by the user and other undocumented flags.
103
104
105 __RTM_NEWROUTE__, __RTM_DELROUTE__, __RTM_GETROUTE__
106
107
108 Create, remove or receive information about a network route.
109 These messages contain an __rtmsg__ structure with an
110 optional sequence of __rtattr__ structures following. For
111 __RTM_GETROUTE__ setting __rtm_dst_len__ and
112 __rtm_src_len__ to 0 means you get all entries for the
113 specified routing table. For the other fields except
114 __rtm_table__ and __rtm_protocol__ 0 is the
115 wildcard.
116
117
118 struct rtmsg
119 {
120 unsigned char rtm_family; /* Address family of route */
121 unsigned char rtm_dst_len; /* Length of source */
122 unsigned char rtm_src_len; /* Length of destination */
123 unsigned char rtm_tos; /* TOS filter */
124 unsigned char rtm_table; /* Routing table id */
125 unsigned char rtm_protocol;/* Routing protocol; see below */
126 unsigned char rtm_scope; /* See below */
127 unsigned char rtm_type; /* See below */
128 unsigned int rtm_flags;
129 };
130
131
132 Values larger than __RTPROT_STATIC__ are not interpreted by the kernel, they are just for user information. They may be used to tag the source of a routing information or to distingush between multiple routing daemons. See ____ for the routing daemon identifiers which are already assigned.
133
134
135 __rtm_scope__ is the distance to the
136 destination:
137
138
139 The values between __RT_SCOPE_UNIVERSE__ and __RT_SCOPE_SITE__ are available to the user.
140
141
142 The __rtm_flags__ have the following
143 meanings:
144
145
146 __rtm_table__ specifies the routing table
147
148
149 The user may assign arbitary values between __RT_TABLE_UNSPEC__ and __RT_TABLE_DEFAULT__.
150
151
152 __Fill these values in!__
153
154
155 __RTM_NEWNEIGH__, __RTM_DELNEIGH__,
156 __RTM_GETNEIGH__
157
158
159 Add, remove or receive information about a neighbour table
160 entry (e.g. an ARP entry). The message contains an
161 __ndmsg__ structure.
162
163
164 struct ndmsg
165 {
166 unsigned char ndm_family;
167 int ndm_ifindex; /* Interface index */
168 __u16 ndm_state; /* State */
169 __u8 ndm_flags; /* Flags */
170 __u8 ndm_type;
171 };
172 struct nda_cacheinfo
173 {
174 __u32 ndm_confirmed;
175 __u32 ndm_used;
176 __u32 ndm_updated;
177 __u32 ndm_refcnt;
178 };
179 __ndm_state__ is a bitmask of the following states:
180
181
182 Valid __ndm_flags__ are:
183
184
185 __document the members of the struct better__
186
187
188 The __rtaddr__ struct has the following meanings for the
189 __rta_type__ field:
190
191
192 If the __rta_type__ field is __NDA_CACHEINFO__ then a __struct nda_cacheinfo__ header follows
193
194
195 __RTM_NEWRULE__, __RTM_DELRULE__,
196 __RTM_GETRULE__
197
198
199 Add, delete or retrieve a routing rule. Carries a __struct
200 rtmsg__
201
202
203 __RTM_NEWQDISC__, __RTM_DELQDISC__,
204 __RTM_GETQDISC__
205
206
207 Add, remove or get a queueing discipline. The message
208 contains a __struct tcmsg__ and may be followed by a
209 series of attributes.
210
211
212 struct tcmsg
213 {
214 unsigned char tcm_family;
215 int tcm_ifindex; /* interface index */
216 __u32 tcm_handle; /* Qdisc handle */
217 __u32 tcm_parent; /* Parent qdisc */
218 __u32 tcm_info;
219 };
220
221
222 In addition various other qdisc module specific attributes are allowed. For more information see the appropriate include files.
223
224
225 __RTM_NEWTCLASS__, __RTM_DELTCLASS__,
226 __RTM_GETTCLASS__
227
228
229 Add, remove or get a traffic class. These messages contain a
230 __struct tcmsg__ as described above.
231
232
233 __RTM_NEWTFILTER__, __RTM_DELTFILTER__,
234 __RTM_GETTFILTER__
235
236
237 Add, remove or receive information about a traffic filter.
238 These messages contain a __struct tcmsg__ as described
239 above.
240 !!VERSIONS
241
242
243 __rtnetlink__ is a new feature of Linux 2.2.
244 !!BUGS
245
246
247 This manual page is lacking and incomplete.
248 !!SEE ALSO
249
250
251 netlink(7), cmsg(3), ip(7),
252 rtnetlink(3)
253 ----
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.