man-pages/man7/rtnetlink.7

450 lines
11 KiB
Groff
Raw Normal View History

2004-11-03 13:51:07 +00:00
'\" t
.\" Don't remove the line above, it tells man that tbl is needed.
.\" This man page is Copyright (C) 1999 Andi Kleen <ak@muc.de>.
.\" Permission is granted to distribute possibly modified copies
.\" of this page provided the header is included verbatim,
.\" and in case of nontrivial modification author and date
.\" of the modification is added to the header.
.\" Based on the original comments from Alexey Kuznetsov, written with
.\" help from Matthew Wilcox.
2004-11-03 13:51:07 +00:00
.\" $Id: rtnetlink.7,v 1.8 2000/01/22 01:55:04 freitag Exp $
2007-05-18 10:09:18 +00:00
.TH RTNETLINK 7 1999-04-30 "Linux" "Linux Programmer's Manual"
2004-11-03 13:51:07 +00:00
.SH NAME
rtnetlink, NETLINK_ROUTE \- Linux IPv4 routing socket
.SH SYNOPSIS
.B #include <asm/types.h>
.br
.B #include <linux/netlink.h>
.br
.B #include <linux/rtnetlink.h>
.br
.B #include <sys/socket.h>
2007-12-23 13:45:24 +00:00
.sp
2004-11-03 13:51:07 +00:00
.BI "rtnetlink_socket = socket(PF_NETLINK, int " socket_type ", NETLINK_ROUTE);"
.SH DESCRIPTION
Rtnetlink allows the kernel's routing tables to be read and altered.
2004-11-03 13:51:07 +00:00
It is used within the kernel to communicate between
various subsystems, though this usage is not documented here, and for
2004-11-03 13:51:07 +00:00
communication with user-space programs.
Network routes, ip addresses, link parameters, neighbor setups, queueing
2004-11-03 13:51:07 +00:00
disciplines, traffic classes and packet classifiers may all be controlled
through
.B NETLINK_ROUTE
sockets.
It is based on netlink messages, see
2004-11-03 13:51:07 +00:00
.BR netlink (7)
for more information.
2007-06-13 21:48:16 +00:00
.\" FIXME ? all these macros could be moved to rtnetlink(3)
2007-05-21 12:46:25 +00:00
.SS "Routing Attributes"
2004-11-03 13:51:07 +00:00
Some rtnetlink messages have optional attributes after the initial header:
2007-12-23 14:03:07 +00:00
.in +4n
2004-11-03 13:51:07 +00:00
.nf
struct rtattr {
unsigned short rta_len; /* Length of option */
unsigned short rta_type; /* Type of option */
/* Data follows */
2004-11-03 13:51:07 +00:00
};
.fi
2007-12-23 14:03:07 +00:00
.in
2004-11-03 13:51:07 +00:00
These attributes should be only manipulated using the RTA_* macros
or libnetlink, see
2004-11-03 13:51:07 +00:00
.BR rtnetlink (3).
2007-05-21 12:46:25 +00:00
.SS Messages
2004-11-03 13:51:07 +00:00
Rtnetlink consists of these message types
(in addition to standard netlink messages):
.TP
.BR RTM_NEWLINK ", " RTM_DELLINK ", " RTM_GETLINK
Create, remove or get information about a specific network interface.
2004-11-03 13:51:07 +00:00
These messages contain an
2007-06-23 07:56:56 +00:00
.I ifinfomsg
2004-11-03 13:51:07 +00:00
structure followed by a series of
2007-06-23 07:56:56 +00:00
.I rtattr
2004-11-03 13:51:07 +00:00
structures.
.nf
struct ifinfomsg {
unsigned char ifi_family; /* AF_UNSPEC */
unsigned short ifi_type; /* Device type */
int ifi_index; /* Interface index */
unsigned int ifi_flags; /* Device flags */
unsigned int ifi_change; /* change mask */
2004-11-03 13:51:07 +00:00
};
.fi
2005-10-26 11:27:52 +00:00
.\" FIXME ifi_type
2007-06-23 07:56:56 +00:00
.I ifi_flags
2004-11-03 13:51:07 +00:00
contains the device flags, see
2007-05-21 21:25:44 +00:00
.BR netdevice (7);
2007-06-23 07:56:56 +00:00
.I ifi_index
2004-11-03 13:51:07 +00:00
is the unique interface index,
2007-06-23 07:56:56 +00:00
.I ifi_change
is reserved for future use and should be always set to 0xFFFFFFFF.
2004-11-03 13:51:07 +00:00
.TS
tab(:);
c
l l l.
Routing attributes
rta_type:value type:description
_
IFLA_UNSPEC:-:unspecified.
IFLA_ADDRESS:hardware address:interface L2 address
2004-11-03 13:51:07 +00:00
IFLA_BROADCAST:hardware address:L2 broadcast address.
IFLA_IFNAME:asciiz string:Device name.
IFLA_MTU:unsigned int:MTU of the device.
IFLA_LINK:int:Link type.
IFLA_QDISC:asciiz string:Queueing discipline.
IFLA_STATS:T{
see below
2004-11-03 13:51:07 +00:00
T}:Interface Statistics.
.TE
.sp
The value type for IFLA_STATS is \fIstruct net_device_stats\fP.
.TP
.BR RTM_NEWADDR ", " RTM_DELADDR ", " RTM_GETADDR
Add, remove or receive information about an IP address associated with
an interface.
In Linux 2.2 an interface can carry multiple IP addresses,
this replaces the alias device concept in 2.0.
In Linux 2.2 these messages
support IPv4 and IPv6 addresses.
They contain an
2007-06-23 07:56:56 +00:00
.I ifaddrmsg
2004-11-03 13:51:07 +00:00
structure, optionally followed by
2007-06-23 07:56:56 +00:00
.I rtaddr
2004-11-03 13:51:07 +00:00
routing attributes.
.nf
struct ifaddrmsg {
unsigned char ifa_family; /* Address type */
unsigned char ifa_prefixlen; /* Prefixlength of address */
unsigned char ifa_flags; /* Address flags */
unsigned char ifa_scope; /* Address scope */
int ifa_index; /* Interface index */
2004-11-03 13:51:07 +00:00
};
.fi
2007-06-23 07:56:56 +00:00
.I ifa_family
is the address family type (currently
2004-11-03 13:51:07 +00:00
.B AF_INET
or
.BR AF_INET6 ),
2007-06-23 07:56:56 +00:00
.I ifa_prefixlen
is the length of the address mask of the address if defined for the
family (like for IPv4),
2007-06-23 07:56:56 +00:00
.I ifa_scope
2004-11-03 13:51:07 +00:00
is the address scope,
2007-06-23 07:56:56 +00:00
.I ifa_index
is the interface index of the interface the address is associated with.
2007-06-23 07:56:56 +00:00
.I ifa_flags
2004-11-03 13:51:07 +00:00
is a flag word of
.B IFA_F_SECONDARY
for secondary address (old alias interface),
2004-11-03 13:51:07 +00:00
.B IFA_F_PERMANENT
for a permanent address set by the user and other undocumented flags.
.TS
tab(:);
c
l l l.
Attributes
rta_type:value type:description
_
IFA_UNSPEC:-:unspecified.
IFA_ADDRESS:raw protocol address:interface address
IFA_LOCAL:raw protocol address:local address
IFA_LABEL:asciiz string:name of the interface
IFA_BROADCAST:raw protocol address:broadcast address.
IFA_ANYCAST:raw protocol address:anycast address
IFA_CACHEINFO:struct ifa_cacheinfo:Address information.
2004-11-03 13:51:07 +00:00
.TE
2005-10-26 11:27:52 +00:00
.\" FIXME struct ifa_cacheinfo
.TP
.BR RTM_NEWROUTE ", " RTM_DELROUTE ", " RTM_GETROUTE
2004-11-03 13:51:07 +00:00
Create, remove or receive information about a network route.
These messages contain an
2007-06-23 07:56:56 +00:00
.I rtmsg
structure with an optional sequence of
2007-06-23 07:56:56 +00:00
.I rtattr
structures following.
For
2004-11-03 13:51:07 +00:00
.B RTM_GETROUTE
setting
2007-06-23 07:56:56 +00:00
.I rtm_dst_len
and
2007-06-23 07:56:56 +00:00
.I rtm_src_len
2004-11-03 13:51:07 +00:00
to 0 means you get all entries for the specified routing table.
For the other fields except
2007-06-23 07:56:56 +00:00
.I rtm_table
and
2007-06-23 07:56:56 +00:00
.I rtm_protocol
2004-11-03 13:51:07 +00:00
0 is the wildcard.
.nf
struct rtmsg {
unsigned char rtm_family; /* Address family of route */
unsigned char rtm_dst_len; /* Length of source */
unsigned char rtm_src_len; /* Length of destination */
unsigned char rtm_tos; /* TOS filter */
2004-11-03 13:51:07 +00:00
unsigned char rtm_table; /* Routing table ID */
unsigned char rtm_protocol; /* Routing protocol; see below */
unsigned char rtm_scope; /* See below */
unsigned char rtm_type; /* See below */
2004-11-03 13:51:07 +00:00
unsigned int rtm_flags;
2004-11-03 13:51:07 +00:00
};
.fi
.TS
tab(:);
l l.
rtm_type:Route type
_
RTN_UNSPEC:unknown route
RTN_UNICAST:a gateway or direct route
RTN_LOCAL:a local interface route
RTN_BROADCAST:T{
a local broadcast route (sent as a broadcast)
T}
RTN_ANYCAST:T{
a local broadcast route (sent as a unicast)
T}
RTN_MULTICAST:a multicast route
RTN_BLACKHOLE:a packet dropping route
RTN_UNREACHABLE:an unreachable destination
RTN_PROHIBIT:a packet rejection route
RTN_THROW:continue routing lookup in another table
RTN_NAT:a network address translation rule
RTN_XRESOLVE:T{
refer to an external resolver (not implemented)
T}
.TE
.TS
tab(:);
l l.
rtm_protocol:Route origin.
_
RTPROT_UNSPEC:unknown
RTPROT_REDIRECT:T{
by an ICMP redirect (currently unused)
T}
RTPROT_KERNEL:by the kernel
RTPROT_BOOT:during boot
RTPROT_STATIC:by the administrator
.TE
Values larger than
.B 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
distinguish between multiple routing daemons.
See
2007-09-20 16:26:31 +00:00
.I <linux/rtnetlink.h>
for the routing daemon identifiers which are already assigned.
2004-11-03 13:51:07 +00:00
2007-06-23 07:56:56 +00:00
.I rtm_scope
is the distance to the destination:
2004-11-03 13:51:07 +00:00
.TS
tab(:);
l l.
RT_SCOPE_UNIVERSE:global route
RT_SCOPE_SITE:T{
interior route in the local autonomous system
T}
RT_SCOPE_LINK:route on this link
RT_SCOPE_HOST:route on the local host
RT_SCOPE_NOWHERE:destination doesn't exist
.TE
The values between
.B RT_SCOPE_UNIVERSE
and
.B RT_SCOPE_SITE
are available to the user.
The
2007-06-23 07:56:56 +00:00
.I rtm_flags
2004-11-03 13:51:07 +00:00
have the following meanings:
.TS
tab(:);
l l.
RTM_F_NOTIFY:T{
if the route changes, notify the user via rtnetlink
T}
RTM_F_CLONED:route is cloned from another route
RTM_F_EQUALIZE:a multipath equalizer (not yet implemented)
2004-11-03 13:51:07 +00:00
.TE
2007-06-23 07:56:56 +00:00
.I rtm_table
2004-11-03 13:51:07 +00:00
specifies the routing table
.TS
tab(:);
l l.
RT_TABLE_UNSPEC:an unspecified routing table
RT_TABLE_DEFAULT:the default table
RT_TABLE_MAIN:the main table
RT_TABLE_LOCAL:the local table
.TE
The user may assign arbitrary values between
2004-11-03 13:51:07 +00:00
.B RT_TABLE_UNSPEC
and
.BR RT_TABLE_DEFAULT .
.TS
tab(:);
c
l l l.
Attributes
rta_type:value type:description
_
RTA_UNSPEC:-:ignored.
RTA_DST:protocol address:Route destination address.
RTA_SRC:protocol address:Route source address.
RTA_IIF:int:Input interface index.
RTA_OIF:int:Output interface index.
RTA_GATEWAY:protocol address:The gateway of the route
RTA_PRIORITY:int:Priority of route.
RTA_PREFSRC::
RTA_METRICS:int:Route metric
RTA_MULTIPATH::
RTA_PROTOINFO::
RTA_FLOW::
RTA_CACHEINFO::
.TE
.B Fill these values in!
.TP
.BR RTM_NEWNEIGH ", " RTM_DELNEIGH ", " RTM_GETNEIGH
Add, remove or receive information about a neighbor table
entry (e.g., an ARP entry).
The message contains an
2007-06-23 07:56:56 +00:00
.I ndmsg
2004-11-03 13:51:07 +00:00
structure.
.nf
struct ndmsg {
unsigned char ndm_family;
int ndm_ifindex; /* Interface index */
__u16 ndm_state; /* State */
__u8 ndm_flags; /* Flags */
__u8 ndm_type;
2004-11-03 13:51:07 +00:00
};
struct nda_cacheinfo {
__u32 ndm_confirmed;
__u32 ndm_used;
__u32 ndm_updated;
__u32 ndm_refcnt;
2004-11-03 13:51:07 +00:00
};
.fi
2007-06-23 07:56:56 +00:00
.I ndm_state
2007-07-01 04:23:34 +00:00
is a bit mask of the following states:
2004-11-03 13:51:07 +00:00
.TS
tab(:);
l l.
NUD_INCOMPLETE:a currently resolving cache entry
NUD_REACHABLE:a confirmed working cache entry
NUD_STALE:an expired cache entry
NUD_DELAY:an entry waiting for a timer
NUD_PROBE:a cache entry that is currently reprobed
NUD_FAILED:an invalid cache entry
NUD_NOARP:a device with no destination cache
NUD_PERMANENT:a static entry
.TE
Valid
2007-06-23 07:56:56 +00:00
.I ndm_flags
2004-11-03 13:51:07 +00:00
are:
.TS
tab(:);
l l.
NTF_PROXY:a proxy arp entry
NTF_ROUTER:an IPv6 router
.TE
2007-08-27 08:45:16 +00:00
.\" FIXME
.\" document the members of the struct better
2004-11-03 13:51:07 +00:00
The
2007-06-23 07:56:56 +00:00
.I rtaddr
2004-11-03 13:51:07 +00:00
struct has the following meanings for the
2007-06-23 07:56:56 +00:00
.I rta_type
2004-11-03 13:51:07 +00:00
field:
.TS
tab(:);
l l.
NDA_UNSPEC:unknown type
NDA_DST:a neighbor cache n/w layer destination address
NDA_LLADDR:a neighbor cache link layer address
2004-11-03 13:51:07 +00:00
NDA_CACHEINFO:cache statistics.
.TE
If the
2007-06-23 07:56:56 +00:00
.I rta_type
2004-11-03 13:51:07 +00:00
field is
.B NDA_CACHEINFO
then a
2005-11-02 13:55:25 +00:00
.I struct nda_cacheinfo
2004-11-03 13:51:07 +00:00
header follows
.TP
.BR RTM_NEWRULE ", " RTM_DELRULE ", " RTM_GETRULE
Add, delete or retrieve a routing rule.
Carries a
2005-11-02 13:55:25 +00:00
.I struct rtmsg
2004-11-03 13:51:07 +00:00
.TP
.BR RTM_NEWQDISC ", " RTM_DELQDISC ", " RTM_GETQDISC
Add, remove or get a queueing discipline.
The message contains a
2005-11-02 13:55:25 +00:00
.I struct tcmsg
2004-11-03 13:51:07 +00:00
and may be followed by a series of
attributes.
.nf
struct tcmsg {
unsigned char tcm_family;
int tcm_ifindex; /* interface index */
__u32 tcm_handle; /* Qdisc handle */
__u32 tcm_parent; /* Parent qdisc */
__u32 tcm_info;
2004-11-03 13:51:07 +00:00
};
.fi
.TS
tab(:);
c
l l l.
Attributes
rta_type:value type:Description
_
TCA_UNSPEC:-:unspecified
TCA_KIND:asciiz string:Name of queueing discipline
2007-12-25 20:50:22 +00:00
TCA_OPTIONS:byte sequence:Qdisc-specific options follow
2004-11-03 13:51:07 +00:00
TCA_STATS:struct tc_stats:Qdisc statistics.
2007-12-25 20:50:22 +00:00
TCA_XSTATS:qdisc specific:Module-specific statistics.
2004-11-03 13:51:07 +00:00
TCA_RATE:struct tc_estimator:Rate limit.
.TE
In addition various other qdisc module specific attributes are allowed.
For more information see the appropriate include files.
.TP
.BR RTM_NEWTCLASS ", " RTM_DELTCLASS ", " RTM_GETTCLASS
Add, remove or get a traffic class.
These messages contain a
2005-11-02 13:55:25 +00:00
.I struct tcmsg
2004-11-03 13:51:07 +00:00
as described above.
.TP
.BR RTM_NEWTFILTER ", " RTM_DELTFILTER ", " RTM_GETTFILTER
Add, remove or receive information about a traffic filter.
These messages contain a
2005-11-02 13:55:25 +00:00
.I struct tcmsg
2004-11-03 13:51:07 +00:00
as described above.
.SH VERSIONS
.B rtnetlink
2004-11-03 13:51:07 +00:00
is a new feature of Linux 2.2.
.SH BUGS
2007-05-22 20:58:35 +00:00
This manual page is incomplete.
2004-11-03 13:51:07 +00:00
.SH "SEE ALSO"
.BR cmsg (3),
.BR rtnetlink (3),
.BR ip (7),
.BR netlink (7)