]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
7c4ddad1 | 2 | .\" SPDX-License-Identifier: Linux-man-pages-1-para |
2297bf0e | 3 | .\" |
7c4ddad1 | 4 | .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>. |
6a717e5e | 5 | .\" |
77117f4f MK |
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 $ | |
6a717e5e | 9 | .\" |
4c1c5274 | 10 | .TH rtnetlink 7 (date) "Linux man-pages (unreleased)" |
77117f4f | 11 | .SH NAME |
7c978d18 | 12 | rtnetlink \- Linux routing socket |
77117f4f | 13 | .SH SYNOPSIS |
c7db92b9 | 14 | .nf |
77117f4f | 15 | .B #include <asm/types.h> |
77117f4f | 16 | .B #include <linux/netlink.h> |
77117f4f | 17 | .B #include <linux/rtnetlink.h> |
77117f4f | 18 | .B #include <sys/socket.h> |
c6d039a3 | 19 | .P |
d4c8c97c | 20 | .BI "rtnetlink_socket = socket(AF_NETLINK, int " socket_type ", NETLINK_ROUTE);" |
c7db92b9 | 21 | .fi |
77117f4f MK |
22 | .SH DESCRIPTION |
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. | |
516ddeef | 27 | Network routes, IP addresses, link parameters, neighbor setups, queueing |
77117f4f MK |
28 | disciplines, traffic classes and packet classifiers may all be controlled |
29 | through | |
30 | .B NETLINK_ROUTE | |
31 | sockets. | |
516ddeef | 32 | It is based on netlink messages; see |
77117f4f MK |
33 | .BR netlink (7) |
34 | for more information. | |
bea08fec | 35 | .\" FIXME . ? all these macros could be moved to rtnetlink(3) |
73d8cece | 36 | .SS Routing attributes |
77117f4f | 37 | Some rtnetlink messages have optional attributes after the initial header: |
c6d039a3 | 38 | .P |
77117f4f | 39 | .in +4n |
6545cc56 | 40 | .EX |
77117f4f MK |
41 | struct rtattr { |
42 | unsigned short rta_len; /* Length of option */ | |
43 | unsigned short rta_type; /* Type of option */ | |
44 | /* Data follows */ | |
45 | }; | |
6545cc56 | 46 | .EE |
77117f4f | 47 | .in |
c6d039a3 | 48 | .P |
33a0ccb2 | 49 | These attributes should be manipulated using only the RTA_* macros |
77117f4f MK |
50 | or libnetlink, see |
51 | .BR rtnetlink (3). | |
52 | .SS Messages | |
53 | Rtnetlink consists of these message types | |
54 | (in addition to standard netlink messages): | |
55 | .TP | |
6fdb1c03 AC |
56 | .B RTM_NEWLINK |
57 | .TQ | |
58 | .B RTM_DELLINK | |
59 | .TQ | |
60 | .B RTM_GETLINK | |
50dc2db4 | 61 | Create, remove, or get information about a specific network interface. |
77117f4f MK |
62 | These messages contain an |
63 | .I ifinfomsg | |
64 | structure followed by a series of | |
65 | .I rtattr | |
66 | structures. | |
5711c04f | 67 | .IP |
6545cc56 | 68 | .EX |
77117f4f MK |
69 | struct ifinfomsg { |
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 */ | |
75 | }; | |
6545cc56 | 76 | .EE |
5711c04f | 77 | .IP |
bea08fec | 78 | .\" FIXME Document ifinfomsg.ifi_type |
77117f4f MK |
79 | .I ifi_flags |
80 | contains the device flags, see | |
81 | .BR netdevice (7); | |
82 | .I ifi_index | |
5048ae1f PE |
83 | is the unique interface index |
84 | (since Linux 3.7, it is possible to feed a nonzero value with the | |
85 | .B RTM_NEWLINK | |
86 | message, thus creating a link with the given | |
87 | .IR ifindex ); | |
77117f4f MK |
88 | .I ifi_change |
89 | is reserved for future use and should be always set to 0xFFFFFFFF. | |
90 | .TS | |
91 | tab(:); | |
361ccbe1 | 92 | c s s |
288d42bc | 93 | lb l l. |
77117f4f | 94 | Routing attributes |
ab08f669 | 95 | rta_type:Value type:Description |
77117f4f | 96 | _ |
ab08f669 | 97 | IFLA_UNSPEC:-:unspecified |
77117f4f | 98 | IFLA_ADDRESS:hardware address:interface L2 address |
ab08f669 MK |
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 | |
77117f4f MK |
104 | IFLA_STATS:T{ |
105 | see below | |
ab08f669 | 106 | T}:Interface Statistics |
e10078cd LH |
107 | IFLA_PERM_ADDRESS:hardware address:T{ |
108 | hardware address provided by device (since Linux 5.5) | |
109 | T} | |
77117f4f | 110 | .TE |
1bad2785 | 111 | .IP |
94c0ab85 MK |
112 | The value type for |
113 | .B IFLA_STATS | |
3036baf0 | 114 | is |
1ae6b2c7 | 115 | .I struct rtnl_link_stats |
3036baf0 MK |
116 | .RI ( "struct net_device_stats" |
117 | in Linux 2.4 and earlier). | |
77117f4f | 118 | .TP |
6fdb1c03 AC |
119 | .B RTM_NEWADDR |
120 | .TQ | |
121 | .B RTM_DELADDR | |
122 | .TQ | |
123 | .B RTM_GETADDR | |
50dc2db4 | 124 | Add, remove, or receive information about an IP address associated with |
77117f4f | 125 | an interface. |
516ddeef | 126 | In Linux 2.2, an interface can carry multiple IP addresses, |
b324e17d | 127 | this replaces the alias device concept in Linux 2.0. |
516ddeef | 128 | In Linux 2.2, these messages |
77117f4f MK |
129 | support IPv4 and IPv6 addresses. |
130 | They contain an | |
131 | .I ifaddrmsg | |
132 | structure, optionally followed by | |
516ddeef | 133 | .I rtattr |
77117f4f | 134 | routing attributes. |
5711c04f | 135 | .IP |
6545cc56 | 136 | .EX |
77117f4f MK |
137 | struct ifaddrmsg { |
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 */ | |
7aec4106 | 142 | unsigned int ifa_index; /* Interface index */ |
77117f4f | 143 | }; |
6545cc56 | 144 | .EE |
5711c04f | 145 | .IP |
77117f4f MK |
146 | .I ifa_family |
147 | is the address family type (currently | |
148 | .B AF_INET | |
149 | or | |
150 | .BR AF_INET6 ), | |
151 | .I ifa_prefixlen | |
152 | is the length of the address mask of the address if defined for the | |
153 | family (like for IPv4), | |
154 | .I ifa_scope | |
155 | is the address scope, | |
156 | .I ifa_index | |
157 | is the interface index of the interface the address is associated with. | |
158 | .I ifa_flags | |
159 | is a flag word of | |
160 | .B IFA_F_SECONDARY | |
161 | for secondary address (old alias interface), | |
162 | .B IFA_F_PERMANENT | |
163 | for a permanent address set by the user and other undocumented flags. | |
164 | .TS | |
165 | tab(:); | |
361ccbe1 | 166 | c s s |
288d42bc | 167 | lb l l. |
77117f4f | 168 | Attributes |
ab08f669 | 169 | rta_type:Value type:Description |
77117f4f | 170 | _ |
ab08f669 | 171 | IFA_UNSPEC:-:unspecified |
77117f4f MK |
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 | |
ab08f669 | 175 | IFA_BROADCAST:raw protocol address:broadcast address |
77117f4f | 176 | IFA_ANYCAST:raw protocol address:anycast address |
ab08f669 | 177 | IFA_CACHEINFO:struct ifa_cacheinfo:Address information |
77117f4f | 178 | .TE |
bea08fec | 179 | .\" FIXME Document struct ifa_cacheinfo |
77117f4f | 180 | .TP |
6fdb1c03 AC |
181 | .B RTM_NEWROUTE |
182 | .TQ | |
183 | .B RTM_DELROUTE | |
184 | .TQ | |
185 | .B RTM_GETROUTE | |
50dc2db4 | 186 | Create, remove, or receive information about a network route. |
77117f4f MK |
187 | These messages contain an |
188 | .I rtmsg | |
189 | structure with an optional sequence of | |
190 | .I rtattr | |
191 | structures following. | |
192 | For | |
516ddeef | 193 | .BR RTM_GETROUTE , |
77117f4f MK |
194 | setting |
195 | .I rtm_dst_len | |
196 | and | |
197 | .I rtm_src_len | |
198 | to 0 means you get all entries for the specified routing table. | |
516ddeef | 199 | For the other fields, except |
77117f4f MK |
200 | .I rtm_table |
201 | and | |
516ddeef | 202 | .IR rtm_protocol , |
77117f4f | 203 | 0 is the wildcard. |
5711c04f | 204 | .IP |
6545cc56 | 205 | .EX |
77117f4f MK |
206 | struct rtmsg { |
207 | unsigned char rtm_family; /* Address family of route */ | |