]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/rtnetlink.7
man*/: srcfix (Use .P instead of .PP or .LP)
[thirdparty/man-pages.git] / man7 / rtnetlink.7
CommitLineData
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 12rtnetlink \- 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
23Rtnetlink allows the kernel's routing tables to be read and altered.
24It is used within the kernel to communicate between
25various subsystems, though this usage is not documented here, and for
26communication with user-space programs.
516ddeef 27Network routes, IP addresses, link parameters, neighbor setups, queueing
77117f4f
MK
28disciplines, traffic classes and packet classifiers may all be controlled
29through
30.B NETLINK_ROUTE
31sockets.
516ddeef 32It is based on netlink messages; see
77117f4f
MK
33.BR netlink (7)
34for more information.
bea08fec 35.\" FIXME . ? all these macros could be moved to rtnetlink(3)
73d8cece 36.SS Routing attributes
77117f4f 37Some rtnetlink messages have optional attributes after the initial header:
c6d039a3 38.P
77117f4f 39.in +4n
6545cc56 40.EX
77117f4f
MK
41struct 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 49These attributes should be manipulated using only the RTA_* macros
77117f4f
MK
50or libnetlink, see
51.BR rtnetlink (3).
52.SS Messages
53Rtnetlink 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 61Create, remove, or get information about a specific network interface.
77117f4f
MK
62These messages contain an
63.I ifinfomsg
64structure followed by a series of
65.I rtattr
66structures.
5711c04f 67.IP
6545cc56 68.EX
77117f4f
MK
69struct 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
80contains the device flags, see
81.BR netdevice (7);
82.I ifi_index
5048ae1f
PE
83is the unique interface index
84(since Linux 3.7, it is possible to feed a nonzero value with the
85.B RTM_NEWLINK
86message, thus creating a link with the given
87.IR ifindex );
77117f4f
MK
88.I ifi_change
89is reserved for future use and should be always set to 0xFFFFFFFF.
90.TS
91tab(:);
361ccbe1 92c s s
288d42bc 93lb l l.
77117f4f 94Routing attributes
ab08f669 95rta_type:Value type:Description
77117f4f 96_
ab08f669 97IFLA_UNSPEC:-:unspecified
77117f4f 98IFLA_ADDRESS:hardware address:interface L2 address
ab08f669
MK
99IFLA_BROADCAST:hardware address:L2 broadcast address
100IFLA_IFNAME:asciiz string:Device name
101IFLA_MTU:unsigned int:MTU of the device
102IFLA_LINK:int:Link type
103IFLA_QDISC:asciiz string:Queueing discipline
77117f4f
MK
104IFLA_STATS:T{
105see below
ab08f669 106T}:Interface Statistics
e10078cd
LH
107IFLA_PERM_ADDRESS:hardware address:T{
108hardware address provided by device (since Linux 5.5)
109T}
77117f4f 110.TE
1bad2785 111.IP
94c0ab85
MK
112The value type for
113.B IFLA_STATS
3036baf0 114is
1ae6b2c7 115.I struct rtnl_link_stats
3036baf0
MK
116.RI ( "struct net_device_stats"
117in 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 124Add, remove, or receive information about an IP address associated with
77117f4f 125an interface.
516ddeef 126In Linux 2.2, an interface can carry multiple IP addresses,
b324e17d 127this replaces the alias device concept in Linux 2.0.
516ddeef 128In Linux 2.2, these messages
77117f4f
MK
129support IPv4 and IPv6 addresses.
130They contain an
131.I ifaddrmsg
132structure, optionally followed by
516ddeef 133.I rtattr
77117f4f 134routing attributes.
5711c04f 135.IP
6545cc56 136.EX
77117f4f
MK
137struct 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
147is the address family type (currently
148.B AF_INET
149or
150.BR AF_INET6 ),
151.I ifa_prefixlen
152is the length of the address mask of the address if defined for the
153family (like for IPv4),
154.I ifa_scope
155is the address scope,
156.I ifa_index
157is the interface index of the interface the address is associated with.
158.I ifa_flags
159is a flag word of
160.B IFA_F_SECONDARY
161for secondary address (old alias interface),
162.B IFA_F_PERMANENT
163for a permanent address set by the user and other undocumented flags.
164.TS
165tab(:);
361ccbe1 166c s s
288d42bc 167lb l l.
77117f4f 168Attributes
ab08f669 169rta_type:Value type:Description
77117f4f 170_
ab08f669 171IFA_UNSPEC:-:unspecified
77117f4f
MK
172IFA_ADDRESS:raw protocol address:interface address
173IFA_LOCAL:raw protocol address:local address
174IFA_LABEL:asciiz string:name of the interface
ab08f669 175IFA_BROADCAST:raw protocol address:broadcast address
77117f4f 176IFA_ANYCAST:raw protocol address:anycast address
ab08f669 177IFA_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 186Create, remove, or receive information about a network route.
77117f4f
MK
187These messages contain an
188.I rtmsg
189structure with an optional sequence of
190.I rtattr
191structures following.
192For
516ddeef 193.BR RTM_GETROUTE ,
77117f4f
MK
194setting
195.I rtm_dst_len
196and
197.I rtm_src_len
198to 0 means you get all entries for the specified routing table.
516ddeef 199For the other fields, except
77117f4f
MK
200.I rtm_table
201and
516ddeef 202.IR rtm_protocol ,
77117f4f 2030 is the wildcard.
5711c04f 204.IP
6545cc56 205.EX
77117f4f
MK
206struct rtmsg {
207 unsigned char rtm_family; /* Address family of route */