Flashnux

GNU/Linux man pages

Livre :
Expressions régulières,
Syntaxe et mise en oeuvre :

ISBN : 978-2-7460-9712-4
EAN : 9782746097124
(Editions ENI)

GNU/Linux

CentOS 4.8

i386

rtnetlink(7)


RTNETLINK

RTNETLINK

NAME
SYNOPSIS
DESCRIPTION
ROUTING ATTRIBUTES
MESSAGES
VERSIONS
BUGS
SEE ALSO

NAME

rtnetlink, NETLINK_ROUTE − Linux IPv4 routing socket

SYNOPSIS

#include <asm/types.h>
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
#include <sys/socket.h>

rtnetlink_socket = socket(PF_NETLINK, int socket_type, NETLINK_ROUTE);

DESCRIPTION

Rtnetlink allows the kernel’s routing tables to be read and altered. It is used within the kernel to communicate between various subsystems, though this usage is not documented here, and for communication with user-space programs. Network routes, ip addresses, link parameters, neighbour setups, queueing disciplines, traffic classes and packet classifiers may all be controlled through NETLINK_ROUTE sockets. It is based on netlink messages, see netlink(7) for more information.

ROUTING ATTRIBUTES

Some rtnetlink messages have optional attributes after the initial header:

struct rtattr
{

unsigned short

rta_len;

/* Length of option */

unsigned short

rta_type;

/* Type of option */

/* Data follows */

};

These attributes should be only manipulated using the RTA_* macros or libnetlink, see rtnetlink(3).

MESSAGES

Rtnetlink consists of these message types (in addition to standard netlink messages):
RTM_NEWLINK
, RTM_DELLINK, RTM_GETLINK

Create, remove or get information about a specific network interface. These messages contain an ifinfomsg structure followed by a series of rtattr structures.

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 */

};

ifi_flags contains the device flags, see netdevice(7); ifi_index is the unique interface index, ifi_change is reserved for future use and should be always set to 0xFFFFFFFF.

Image /web_man_pages/man_unzipped/en/centos/4/4.81.png

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 ifaddrmsg structure, optionally followed by rtaddr routing attributes.

struct ifaddrmsg
{

unsigned char

ifa_family;

/* Address type */

unsigned char

ifa_prefixlen;/* Prefixlength of the address */

unsigned char

ifa_flags;

/* Address flags */

unsigned char

ifa_scope;

/* Address scope */

int

ifa_index;

/* Interface index */

};

ifa_family is the address family type (currently AF_INET or AF_INET6), ifa_prefixlen is the length of the address mask of the address if defined for the family (like for IPv4), ifa_scope is the address scope, ifa_index is the interface index of the interface the address is associated with. ifa_flags is a flag word of IFA_F_SECONDARY for secondary address (old alias interface), IFA_F_PERMANENT for a permanent address set by the user and other undocumented flags.

Image /web_man_pages/man_unzipped/en/centos/4/4.82.png

RTM_NEWROUTE, RTM_DELROUTE, RTM_GETROUTE

Create, remove or receive information about a network route. These messages contain an rtmsg structure with an optional sequence of rtattr structures following. For RTM_GETROUTE setting rtm_dst_len and rtm_src_len to 0 means you get all entries for the specified routing table. For the other fields except rtm_table and rtm_protocol 0 is the wildcard.

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 */

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 */

unsigned int

rtm_flags;

};

Image /web_man_pages/man_unzipped/en/centos/4/4.83.png

Image /web_man_pages/man_unzipped/en/centos/4/4.84.png

Values larger than 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 distingush between multiple routing daemons. See <linux/rtnetlink.h> for the routing daemon identifiers which are already assigned.

rtm_scope is the distance to the destination:

Image /web_man_pages/man_unzipped/en/centos/4/4.85.png

The values between RT_SCOPE_UNIVERSE and RT_SCOPE_SITE are available to the user.

The rtm_flags have the following meanings:

Image /web_man_pages/man_unzipped/en/centos/4/4.86.png

rtm_table specifies the routing table

Image /web_man_pages/man_unzipped/en/centos/4/4.87.png

The user may assign arbitary values between RT_TABLE_UNSPEC and RT_TABLE_DEFAULT.

Image /web_man_pages/man_unzipped/en/centos/4/4.88.png

Fill these values in!

RTM_NEWNEIGH, RTM_DELNEIGH, RTM_GETNEIGH

Add, remove or receive information about a neighbour table entry (e.g. an ARP entry). The message contains an ndmsg structure.

struct ndmsg
{

unsigned char

ndm_family;

int

ndm_ifindex;

/* Interface index */

__u16

ndm_state;

/* State */

__u8

ndm_flags;

/* Flags */

__u8

ndm_type;

};

struct nda_cacheinfo
{

__u32

ndm_confirmed;

__u32

ndm_used;

__u32

ndm_updated;

__u32

ndm_refcnt;

};

ndm_state is a bitmask of the following states:

Image /web_man_pages/man_unzipped/en/centos/4/4.89.png

Valid ndm_flags are:

Image /web_man_pages/man_unzipped/en/centos/4/4.810.png

document the members of the struct better

The rtaddr struct has the following meanings for the rta_type field:

Image /web_man_pages/man_unzipped/en/centos/4/4.811.png

If the rta_type field is NDA_CACHEINFO then a struct nda_cacheinfo header follows

RTM_NEWRULE, RTM_DELRULE, RTM_GETRULE

Add, delete or retrieve a routing rule. Carries a struct rtmsg

RTM_NEWQDISC, RTM_DELQDISC, RTM_GETQDISC

Add, remove or get a queueing discipline. The message contains a struct tcmsg and may be followed by a series of attributes.

struct tcmsg
{

unsigned char

tcm_family;

int

tcm_ifindex;

/* interface index */

__u32

tcm_handle;

/* Qdisc handle */

__u32

tcm_parent;

/* Parent qdisc */

__u32

tcm_info;

};

Image /web_man_pages/man_unzipped/en/centos/4/4.812.png

In addition various other qdisc module specific attributes are allowed. For more information see the appropriate include files.

RTM_NEWTCLASS, RTM_DELTCLASS, RTM_GETTCLASS

Add, remove or get a traffic class. These messages contain a struct tcmsg as described above.

RTM_NEWTFILTER, RTM_DELTFILTER, RTM_GETTFILTER

Add, remove or receive information about a traffic filter. These messages contain a struct tcmsg as described above.

VERSIONS

rtnetlink is a new feature of Linux 2.2.

BUGS

This manual page is lacking and incomplete.

SEE ALSO

netlink(7), cmsg(3), ip(7), rtnetlink(3)



rtnetlink(7)