]> git.ipfire.org Git - thirdparty/man-pages.git/blobdiff - man7/rtnetlink.7
err.3: EXAMPLES: use EXIT_FAILURE rather than 1 as exit status
[thirdparty/man-pages.git] / man7 / rtnetlink.7
index bdf5de8b36c29306c055bbe9e5dcd3355aa7527d..dbd4fbbb1d6030a346a5e2e16c11595d34e9c492 100644 (file)
@@ -12,7 +12,7 @@
 .\" help from Matthew Wilcox.
 .\" $Id: rtnetlink.7,v 1.8 2000/01/22 01:55:04 freitag Exp $
 .\"
-.TH RTNETLINK  7 2013-03-05 "Linux" "Linux Programmer's Manual"
+.TH RTNETLINK  7 2020-02-09 "Linux" "Linux Programmer's Manual"
 .SH NAME
 rtnetlink \- Linux IPv4 routing socket
 .SH SYNOPSIS
@@ -23,7 +23,7 @@ rtnetlink \- Linux IPv4 routing socket
 .B #include <linux/rtnetlink.h>
 .br
 .B #include <sys/socket.h>
-.sp
+.PP
 .BI "rtnetlink_socket = socket(AF_NETLINK, int " socket_type ", NETLINK_ROUTE);"
 .SH DESCRIPTION
 Rtnetlink allows the kernel's routing tables to be read and altered.
@@ -38,20 +38,20 @@ sockets.
 It is based on netlink messages; see
 .BR netlink (7)
 for more information.
-.\" FIXME ? all these macros could be moved to rtnetlink(3)
+.\" FIXME ? all these macros could be moved to rtnetlink(3)
 .SS Routing attributes
 Some rtnetlink messages have optional attributes after the initial header:
-
+.PP
 .in +4n
-.nf
+.EX
 struct rtattr {
     unsigned short rta_len;    /* Length of option */
     unsigned short rta_type;   /* Type of option */
     /* Data follows */
 };
-.fi
+.EE
 .in
-
+.PP
 These attributes should be manipulated using only the RTA_* macros
 or libnetlink, see
 .BR rtnetlink (3).
@@ -66,8 +66,8 @@ These messages contain an
 structure followed by a series of
 .I rtattr
 structures.
-
-.nf
+.IP
+.EX
 struct ifinfomsg {
     unsigned char  ifi_family; /* AF_UNSPEC */
     unsigned short ifi_type;   /* Device type */
@@ -75,9 +75,9 @@ struct ifinfomsg {
     unsigned int   ifi_flags;  /* Device flags  */
     unsigned int   ifi_change; /* change mask */
 };
-.fi
-
-.\" FIXME ifi_type
+.EE
+.IP
+.\" FIXME Document ifinfomsg.ifi_type
 .I ifi_flags
 contains the device flags, see
 .BR netdevice (7);
@@ -94,20 +94,20 @@ tab(:);
 c s s
 l l l.
 Routing attributes
-rta_type:value type:description
+rta_type:Value type:Description
 _
-IFLA_UNSPEC:-:unspecified.
+IFLA_UNSPEC:-:unspecified
 IFLA_ADDRESS:hardware address:interface L2 address
-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_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
-T}:Interface Statistics.
+T}:Interface Statistics
 .TE
-.sp
+.PP
 The value type for
 .B IFLA_STATS
 is
@@ -127,17 +127,17 @@ They contain an
 structure, optionally followed by
 .I rtattr
 routing attributes.
-
-.nf
+.IP
+.EX
 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 */
+    unsigned int  ifa_index;     /* Interface index */
 };
-.fi
-
+.EE
+.IP
 .I ifa_family
 is the address family type (currently
 .B AF_INET
@@ -161,17 +161,17 @@ tab(:);
 c s s
 l l l.
 Attributes
-rta_type:value type:description
+rta_type:Value type:Description
 _
-IFA_UNSPEC:-:unspecified.
+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_BROADCAST:raw protocol address:broadcast address
 IFA_ANYCAST:raw protocol address:anycast address
-IFA_CACHEINFO:struct ifa_cacheinfo:Address information.
+IFA_CACHEINFO:struct ifa_cacheinfo:Address information
 .TE
-.\" FIXME struct ifa_cacheinfo
+.\" FIXME Document struct ifa_cacheinfo
 .TP
 .BR RTM_NEWROUTE ", " RTM_DELROUTE ", " RTM_GETROUTE
 Create, remove or receive information about a network route.
@@ -192,22 +192,22 @@ For the other fields, except
 and
 .IR rtm_protocol ,
 0 is the wildcard.
-
-.nf
+.IP
+.EX
 struct rtmsg {
     unsigned char rtm_family;   /* Address family of route */
     unsigned char rtm_dst_len;  /* Length of destination */
     unsigned char rtm_src_len;  /* Length of source */
     unsigned char rtm_tos;      /* TOS filter */
-
-    unsigned char rtm_table;    /* Routing table ID */
+    unsigned char rtm_table;    /* Routing table ID;
+                                   see RTA_TABLE below */
     unsigned char rtm_protocol; /* Routing protocol; see below */
     unsigned char rtm_scope;    /* See below */
     unsigned char rtm_type;     /* See below */
 
     unsigned int  rtm_flags;
 };
-.fi
+.EE
 .TS
 tab(:);
 l l.
@@ -235,7 +235,7 @@ T}
 .TS
 tab(:);
 l l.
-rtm_protocol:Route origin.
+rtm_protocol:Route origin
 _
 RTPROT_UNSPEC:unknown
 RTPROT_REDIRECT:T{
@@ -245,7 +245,7 @@ RTPROT_KERNEL:by the kernel
 RTPROT_BOOT:during boot
 RTPROT_STATIC:by the administrator
 .TE
-
+.sp 1
 Values larger than
 .B RTPROT_STATIC
 are not interpreted by the kernel, they are just for user information.
@@ -254,7 +254,7 @@ distinguish between multiple routing daemons.
 See
 .I <linux/rtnetlink.h>
 for the routing daemon identifiers which are already assigned.
-
+.IP
 .I rtm_scope
 is the distance to the destination:
 .TS
@@ -268,13 +268,13 @@ RT_SCOPE_LINK:route on this link
 RT_SCOPE_HOST:route on the local host
 RT_SCOPE_NOWHERE:destination doesn't exist
 .TE
-
+.sp 1
 The values between
 .B RT_SCOPE_UNIVERSE
 and
 .B RT_SCOPE_SITE
 are available to the user.
-
+.IP
 The
 .I rtm_flags
 have the following meanings:
@@ -287,7 +287,7 @@ T}
 RTM_F_CLONED:route is cloned from another route
 RTM_F_EQUALIZE:a multipath equalizer (not yet implemented)
 .TE
-
+.sp 1
 .I rtm_table
 specifies the routing table
 .TS
@@ -298,7 +298,7 @@ RT_TABLE_DEFAULT:the default table
 RT_TABLE_MAIN:the main table
 RT_TABLE_LOCAL:the local table
 .TE
-
+.sp 1
 The user may assign arbitrary values between
 .B RT_TABLE_UNSPEC
 and
@@ -308,25 +308,108 @@ and
 .TS
 tab(:);
 c s s
-l l l.
+l2 l2 l.
 Attributes
-rta_type:value type:description
+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_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_PRIORITY:int:Priority of route
+RTA_PREFSRC:protocol address:Preferred source address
 RTA_METRICS:int:Route metric
-RTA_MULTIPATH::
-RTA_PROTOINFO::
-RTA_FLOW::
-RTA_CACHEINFO::
+RTA_MULTIPATH::T{
+Multipath nexthop data
+br
+(see below).
+T}
+RTA_PROTOINFO::No longer used
+RTA_FLOW:int:Route realm
+RTA_CACHEINFO:struct rta_cacheinfo:(see linux/rtnetlink.h)
+RTA_SESSION::No longer used
+RTA_MP_ALGO::No longer used
+RTA_TABLE:int:T{
+Routing table ID; if set,
+.br
+rtm_table is ignored
+T}
+RTA_MARK:int:
+RTA_MFC_STATS:struct rta_mfc_stats:(see linux/rtnetlink.h)
+RTA_VIA:struct rtvia:T{
+Gateway in different AF
+(see below)
+T}
+RTA_NEWDST:protocol address:T{
+Change packet
+destination address
+T}
+RTA_PREF:char:T{
+RFC4191 IPv6 router
+preference (see below)
+T}
+RTA_ENCAP_TYPE:short:T{
+Encapsulation type for
+.br
+lwtunnels (see below)
+T}
+RTA_ENCAP::Defined by RTA_ENCAP_TYPE
+RTA_EXPIRES:int:T{
+Expire time for IPv6
+routes (in seconds)
+T}
 .TE
-
+.PP
+.I RTA_MULTIPATH
+contains several packed instances of
+.I struct rtnexthop
+together with nested RTAs
+.RB ( RTA_GATEWAY ):
+.PP
+.in +4n
+.EX
+struct rtnexthop {
+    unsigned short rtnh_len;     /* Length of struct + length
+                                    of RTAs */
+    unsigned char  rtnh_flags;   /* Flags (see linux/rtnetlink.h) */
+    unsigned char  rtnh_hops;    /* Nexthop priority */
+    int            rtnh_ifindex; /* Interface index for this
+                                    nexthop */
+}
+.EE
+.in
+.PP
+There exist a bunch of RTNH_* macros similar to RTA_* and NLHDR_* macros
+useful to handle these structures.
+.PP
+.nf
+.in +4n
+.EX
+struct rtvia {
+    unsigned short rtvia_family;
+    unsigned char  rtvia_addr[0];
+};
+.EE
+.in
+.PP
+.I rtvia_addr
+is the address,
+.I rtvia_family
+is its family type.
+.PP
+.I RTA_PREF
+may contain values ICMPV6_ROUTER_PREF_LOW,
+ICMPV6_ROUTER_PREF_MEDIUM and
+ICMPV6_ROUTER_PREF_HIGH defined in <linux/icmpv6.h>
+.PP
+.I RTA_ENCAP_TYPE
+may contain values
+LWTUNNEL_ENCAP_MPLS, LWTUNNEL_ENCAP_IP,
+LWTUNNEL_ENCAP_ILA or LWTUNNEL_ENCAP_IP6
+defined in <linux/lwtunnel.h>.
+.sp 1
 .B Fill these values in!
 .TP
 .BR RTM_NEWNEIGH ", " RTM_DELNEIGH  ", " RTM_GETNEIGH
@@ -335,8 +418,8 @@ entry (e.g., an ARP entry).
 The message contains an
 .I ndmsg
 structure.
-
-.nf
+.IP
+.EX
 struct ndmsg {
     unsigned char ndm_family;
     int           ndm_ifindex;  /* Interface index */
@@ -351,8 +434,8 @@ struct nda_cacheinfo {
     __u32         ndm_updated;
     __u32         ndm_refcnt;
 };
-.fi
-
+.EE
+.IP
 .I ndm_state
 is a bit mask of the following states:
 .TS
@@ -367,7 +450,7 @@ NUD_FAILED:an invalid cache entry
 NUD_NOARP:a device with no destination cache
 NUD_PERMANENT:a static entry
 .TE
-
+.sp 1
 Valid
 .I ndm_flags
 are:
@@ -377,8 +460,8 @@ l l.
 NTF_PROXY:a proxy arp entry
 NTF_ROUTER:an IPv6 router
 .TE
-
-.\" FIXME
+.sp 1
+.\" FIXME .
 .\" document the members of the struct better
 The
 .I rtattr
@@ -391,13 +474,13 @@ l l.
 NDA_UNSPEC:unknown type
 NDA_DST:a neighbor cache n/w layer destination address
 NDA_LLADDR:a neighbor cache link layer address
-NDA_CACHEINFO:cache statistics.
+NDA_CACHEINFO:cache statistics
 .TE
-
+.sp 1
 If the
 .I rta_type
 field is
-.B NDA_CACHEINFO
+.BR NDA_CACHEINFO ,
 then a
 .I struct nda_cacheinfo
 header follows
@@ -413,8 +496,8 @@ The message contains a
 .I struct tcmsg
 and may be followed by a series of
 attributes.
-
-.nf
+.IP
+.EX
 struct tcmsg {
     unsigned char    tcm_family;
     int              tcm_ifindex;   /* interface index */
@@ -422,22 +505,22 @@ struct tcmsg {
     __u32            tcm_parent;    /* Parent qdisc */
     __u32            tcm_info;
 };
-.fi
+.EE
 .TS
 tab(:);
 c s s
 l2 l2 l.
 Attributes
-rta_type:value type:Description
+rta_type:Value type:Description
 _
 TCA_UNSPEC:-:unspecified
 TCA_KIND:asciiz string:Name of queueing discipline
 TCA_OPTIONS:byte sequence:Qdisc-specific options follow
-TCA_STATS:struct tc_stats:Qdisc statistics.
-TCA_XSTATS:qdisc-specific:Module-specific statistics.
-TCA_RATE:struct tc_estimator:Rate limit.
+TCA_STATS:struct tc_stats:Qdisc statistics
+TCA_XSTATS:qdisc-specific:Module-specific statistics
+TCA_RATE:struct tc_estimator:Rate limit
 .TE
-
+.sp 1
 In addition, various other qdisc-module-specific attributes are allowed.
 For more information see the appropriate include files.
 .TP