]>
Commit | Line | Data |
---|---|---|
77117f4f | 1 | '\" t |
77117f4f | 2 | .\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>. |
2297bf0e | 3 | .\" |
00acdba1 | 4 | .\" %%%LICENSE_START(VERBATIM_ONE_PARA) |
77117f4f MK |
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. | |
8ff7380d | 9 | .\" %%%LICENSE_END |
6a717e5e | 10 | .\" |
77117f4f MK |
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 $ | |
6a717e5e | 14 | .\" |
4b8c67d9 | 15 | .TH RTNETLINK 7 2017-09-15 "Linux" "Linux Programmer's Manual" |
77117f4f | 16 | .SH NAME |
61310e03 | 17 | rtnetlink \- Linux IPv4 routing socket |
77117f4f MK |
18 | .SH SYNOPSIS |
19 | .B #include <asm/types.h> | |
20 | .br | |
21 | .B #include <linux/netlink.h> | |
22 | .br | |
23 | .B #include <linux/rtnetlink.h> | |
24 | .br | |
25 | .B #include <sys/socket.h> | |
68e4db0a | 26 | .PP |
d4c8c97c | 27 | .BI "rtnetlink_socket = socket(AF_NETLINK, int " socket_type ", NETLINK_ROUTE);" |
77117f4f MK |
28 | .SH DESCRIPTION |
29 | Rtnetlink allows the kernel's routing tables to be read and altered. | |
30 | It is used within the kernel to communicate between | |
31 | various subsystems, though this usage is not documented here, and for | |
32 | communication with user-space programs. | |
516ddeef | 33 | Network routes, IP addresses, link parameters, neighbor setups, queueing |
77117f4f MK |
34 | disciplines, traffic classes and packet classifiers may all be controlled |
35 | through | |
36 | .B NETLINK_ROUTE | |
37 | sockets. | |
516ddeef | 38 | It is based on netlink messages; see |
77117f4f MK |
39 | .BR netlink (7) |
40 | for more information. | |
bea08fec | 41 | .\" FIXME . ? all these macros could be moved to rtnetlink(3) |
73d8cece | 42 | .SS Routing attributes |
77117f4f | 43 | Some rtnetlink messages have optional attributes after the initial header: |
5711c04f | 44 | .PP |
77117f4f | 45 | .in +4n |
6545cc56 | 46 | .EX |
77117f4f MK |
47 | struct rtattr { |
48 | unsigned short rta_len; /* Length of option */ | |
49 | unsigned short rta_type; /* Type of option */ | |
50 | /* Data follows */ | |
51 | }; | |
6545cc56 | 52 | .EE |
77117f4f | 53 | .in |
5711c04f | 54 | .PP |
33a0ccb2 | 55 | These attributes should be manipulated using only the RTA_* macros |
77117f4f MK |
56 | or libnetlink, see |
57 | .BR rtnetlink (3). | |
58 | .SS Messages | |
59 | Rtnetlink consists of these message types | |
60 | (in addition to standard netlink messages): | |
61 | .TP | |
62 | .BR RTM_NEWLINK ", " RTM_DELLINK ", " RTM_GETLINK | |
63 | Create, remove or get information about a specific network interface. | |
64 | These messages contain an | |
65 | .I ifinfomsg | |
66 | structure followed by a series of | |
67 | .I rtattr | |
68 | structures. | |
5711c04f | 69 | .IP |
6545cc56 | 70 | .EX |
77117f4f MK |
71 | struct ifinfomsg { |
72 | unsigned char ifi_family; /* AF_UNSPEC */ | |
73 | unsigned short ifi_type; /* Device type */ | |
74 | int ifi_index; /* Interface index */ | |
75 | unsigned int ifi_flags; /* Device flags */ | |
76 | unsigned int ifi_change; /* change mask */ | |
77 | }; | |
6545cc56 | 78 | .EE |
5711c04f | 79 | .IP |
bea08fec | 80 | .\" FIXME Document ifinfomsg.ifi_type |
77117f4f MK |
81 | .I ifi_flags |
82 | contains the device flags, see | |
83 | .BR netdevice (7); | |
84 | .I ifi_index | |
5048ae1f PE |
85 | is the unique interface index |
86 | (since Linux 3.7, it is possible to feed a nonzero value with the | |
87 | .B RTM_NEWLINK | |
88 | message, thus creating a link with the given | |
89 | .IR ifindex ); | |
77117f4f MK |
90 | .I ifi_change |
91 | is reserved for future use and should be always set to 0xFFFFFFFF. | |
92 | .TS | |
93 | tab(:); | |
361ccbe1 | 94 | c s s |
77117f4f MK |
95 | l l l. |
96 | Routing attributes | |
97 | rta_type:value type:description | |
98 | _ | |
99 | IFLA_UNSPEC:-:unspecified. | |
100 | IFLA_ADDRESS:hardware address:interface L2 address | |
101 | IFLA_BROADCAST:hardware address:L2 broadcast address. | |
102 | IFLA_IFNAME:asciiz string:Device name. | |
103 | IFLA_MTU:unsigned int:MTU of the device. | |
104 | IFLA_LINK:int:Link type. | |
105 | IFLA_QDISC:asciiz string:Queueing discipline. | |
106 | IFLA_STATS:T{ | |
107 | see below | |
108 | T}:Interface Statistics. | |
109 | .TE | |
51f5698d | 110 | .PP |
94c0ab85 MK |
111 | The value type for |
112 | .B IFLA_STATS | |
3036baf0 MK |
113 | is |
114 | .IR "struct rtnl_link_stats" | |
115 | .RI ( "struct net_device_stats" | |
116 | in Linux 2.4 and earlier). | |
77117f4f MK |
117 | .TP |
118 | .BR RTM_NEWADDR ", " RTM_DELADDR ", " RTM_GETADDR | |
119 | Add, remove or receive information about an IP address associated with | |
120 | an interface. | |
516ddeef | 121 | In Linux 2.2, an interface can carry multiple IP addresses, |
77117f4f | 122 | this replaces the alias device concept in 2.0. |
516ddeef | 123 | In Linux 2.2, these messages |
77117f4f MK |
124 | support IPv4 and IPv6 addresses. |
125 | They contain an | |
126 | .I ifaddrmsg | |
127 | structure, optionally followed by | |
516ddeef | 128 | .I rtattr |
77117f4f | 129 | routing attributes. |
5711c04f | 130 | .IP |
6545cc56 | 131 | .EX |
77117f4f MK |
132 | struct ifaddrmsg { |
133 | unsigned char ifa_family; /* Address type */ | |
134 | unsigned char ifa_prefixlen; /* Prefixlength of address */ | |
135 | unsigned char ifa_flags; /* Address flags */ | |
136 | unsigned char ifa_scope; /* Address scope */ | |
137 | int ifa_index; /* Interface index */ | |
138 | }; | |
6545cc56 | 139 | .EE |
5711c04f | 140 | .IP |
77117f4f MK |
141 | .I ifa_family |
142 | is the address family type (currently | |
143 | .B AF_INET | |
144 | or | |
145 | .BR AF_INET6 ), | |
146 | .I ifa_prefixlen | |
147 | is the length of the address mask of the address if defined for the | |
148 | family (like for IPv4), | |
149 | .I ifa_scope | |
150 | is the address scope, | |
151 | .I ifa_index | |
152 | is the interface index of the interface the address is associated with. | |
153 | .I ifa_flags | |
154 | is a flag word of | |
155 | .B IFA_F_SECONDARY | |
156 | for secondary address (old alias interface), | |
157 | .B IFA_F_PERMANENT | |
158 | for a permanent address set by the user and other undocumented flags. | |
159 | .TS | |
160 | tab(:); | |
361ccbe1 | 161 | c s s |
77117f4f MK |
162 | l l l. |
163 | Attributes | |
164 | rta_type:value type:description | |
165 | _ | |
166 | IFA_UNSPEC:-:unspecified. | |
167 | IFA_ADDRESS:raw protocol address:interface address | |
168 | IFA_LOCAL:raw protocol address:local address | |
169 | IFA_LABEL:asciiz string:name of the interface | |
170 | IFA_BROADCAST:raw protocol address:broadcast address. | |
171 | IFA_ANYCAST:raw protocol address:anycast address | |
172 | IFA_CACHEINFO:struct ifa_cacheinfo:Address information. | |
173 | .TE | |
bea08fec | 174 | .\" FIXME Document struct ifa_cacheinfo |
77117f4f MK |
175 | .TP |
176 | .BR RTM_NEWROUTE ", " RTM_DELROUTE ", " RTM_GETROUTE | |
177 | Create, remove or receive information about a network route. | |
178 | These messages contain an | |
179 | .I rtmsg | |
180 | structure with an optional sequence of | |
181 | .I rtattr | |
182 | structures following. | |
183 | For | |
516ddeef | 184 | .BR RTM_GETROUTE , |
77117f4f MK |
185 | setting |
186 | .I rtm_dst_len | |
187 | and | |
188 | .I rtm_src_len | |
189 | to 0 means you get all entries for the specified routing table. | |
516ddeef | 190 | For the other fields, except |
77117f4f MK |
191 | .I rtm_table |
192 | and | |
516ddeef | 193 | .IR rtm_protocol , |
77117f4f | 194 | 0 is the wildcard. |
5711c04f | 195 | .IP |
6545cc56 | 196 | .EX |
77117f4f MK |
197 | struct rtmsg { |
198 | unsigned char rtm_family; /* Address family of route */ | |