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