2005-04-16 16:20:36 -06:00
|
|
|
#ifndef __LINUX_RTNETLINK_H
|
|
|
|
#define __LINUX_RTNETLINK_H
|
|
|
|
|
2009-01-30 10:10:32 -07:00
|
|
|
#include <linux/types.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/netlink.h>
|
2006-09-27 23:40:19 -06:00
|
|
|
#include <linux/if_link.h>
|
2006-12-08 00:49:45 -07:00
|
|
|
#include <linux/if_addr.h>
|
|
|
|
#include <linux/neighbour.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/****
|
|
|
|
* Routing/neighbour discovery messages.
|
|
|
|
****/
|
|
|
|
|
|
|
|
/* Types of messages */
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RTM_BASE = 16,
|
|
|
|
#define RTM_BASE RTM_BASE
|
|
|
|
|
|
|
|
RTM_NEWLINK = 16,
|
|
|
|
#define RTM_NEWLINK RTM_NEWLINK
|
|
|
|
RTM_DELLINK,
|
|
|
|
#define RTM_DELLINK RTM_DELLINK
|
|
|
|
RTM_GETLINK,
|
|
|
|
#define RTM_GETLINK RTM_GETLINK
|
|
|
|
RTM_SETLINK,
|
|
|
|
#define RTM_SETLINK RTM_SETLINK
|
|
|
|
|
|
|
|
RTM_NEWADDR = 20,
|
|
|
|
#define RTM_NEWADDR RTM_NEWADDR
|
|
|
|
RTM_DELADDR,
|
|
|
|
#define RTM_DELADDR RTM_DELADDR
|
|
|
|
RTM_GETADDR,
|
|
|
|
#define RTM_GETADDR RTM_GETADDR
|
|
|
|
|
|
|
|
RTM_NEWROUTE = 24,
|
|
|
|
#define RTM_NEWROUTE RTM_NEWROUTE
|
|
|
|
RTM_DELROUTE,
|
|
|
|
#define RTM_DELROUTE RTM_DELROUTE
|
|
|
|
RTM_GETROUTE,
|
|
|
|
#define RTM_GETROUTE RTM_GETROUTE
|
|
|
|
|
|
|
|
RTM_NEWNEIGH = 28,
|
|
|
|
#define RTM_NEWNEIGH RTM_NEWNEIGH
|
|
|
|
RTM_DELNEIGH,
|
|
|
|
#define RTM_DELNEIGH RTM_DELNEIGH
|
|
|
|
RTM_GETNEIGH,
|
|
|
|
#define RTM_GETNEIGH RTM_GETNEIGH
|
|
|
|
|
|
|
|
RTM_NEWRULE = 32,
|
|
|
|
#define RTM_NEWRULE RTM_NEWRULE
|
|
|
|
RTM_DELRULE,
|
|
|
|
#define RTM_DELRULE RTM_DELRULE
|
|
|
|
RTM_GETRULE,
|
|
|
|
#define RTM_GETRULE RTM_GETRULE
|
|
|
|
|
|
|
|
RTM_NEWQDISC = 36,
|
|
|
|
#define RTM_NEWQDISC RTM_NEWQDISC
|
|
|
|
RTM_DELQDISC,
|
|
|
|
#define RTM_DELQDISC RTM_DELQDISC
|
|
|
|
RTM_GETQDISC,
|
|
|
|
#define RTM_GETQDISC RTM_GETQDISC
|
|
|
|
|
|
|
|
RTM_NEWTCLASS = 40,
|
|
|
|
#define RTM_NEWTCLASS RTM_NEWTCLASS
|
|
|
|
RTM_DELTCLASS,
|
|
|
|
#define RTM_DELTCLASS RTM_DELTCLASS
|
|
|
|
RTM_GETTCLASS,
|
|
|
|
#define RTM_GETTCLASS RTM_GETTCLASS
|
|
|
|
|
|
|
|
RTM_NEWTFILTER = 44,
|
|
|
|
#define RTM_NEWTFILTER RTM_NEWTFILTER
|
|
|
|
RTM_DELTFILTER,
|
|
|
|
#define RTM_DELTFILTER RTM_DELTFILTER
|
|
|
|
RTM_GETTFILTER,
|
|
|
|
#define RTM_GETTFILTER RTM_GETTFILTER
|
|
|
|
|
|
|
|
RTM_NEWACTION = 48,
|
|
|
|
#define RTM_NEWACTION RTM_NEWACTION
|
|
|
|
RTM_DELACTION,
|
|
|
|
#define RTM_DELACTION RTM_DELACTION
|
|
|
|
RTM_GETACTION,
|
|
|
|
#define RTM_GETACTION RTM_GETACTION
|
|
|
|
|
|
|
|
RTM_NEWPREFIX = 52,
|
|
|
|
#define RTM_NEWPREFIX RTM_NEWPREFIX
|
|
|
|
|
|
|
|
RTM_GETMULTICAST = 58,
|
|
|
|
#define RTM_GETMULTICAST RTM_GETMULTICAST
|
|
|
|
|
|
|
|
RTM_GETANYCAST = 62,
|
|
|
|
#define RTM_GETANYCAST RTM_GETANYCAST
|
|
|
|
|
2005-06-18 23:50:55 -06:00
|
|
|
RTM_NEWNEIGHTBL = 64,
|
|
|
|
#define RTM_NEWNEIGHTBL RTM_NEWNEIGHTBL
|
|
|
|
RTM_GETNEIGHTBL = 66,
|
|
|
|
#define RTM_GETNEIGHTBL RTM_GETNEIGHTBL
|
|
|
|
RTM_SETNEIGHTBL,
|
|
|
|
#define RTM_SETNEIGHTBL RTM_SETNEIGHTBL
|
|
|
|
|
2007-10-10 22:22:05 -06:00
|
|
|
RTM_NEWNDUSEROPT = 68,
|
|
|
|
#define RTM_NEWNDUSEROPT RTM_NEWNDUSEROPT
|
|
|
|
|
2007-11-13 23:56:23 -07:00
|
|
|
RTM_NEWADDRLABEL = 72,
|
|
|
|
#define RTM_NEWADDRLABEL RTM_NEWADDRLABEL
|
|
|
|
RTM_DELADDRLABEL,
|
2009-09-09 04:42:23 -06:00
|
|
|
#define RTM_DELADDRLABEL RTM_DELADDRLABEL
|
2007-11-13 23:56:23 -07:00
|
|
|
RTM_GETADDRLABEL,
|
|
|
|
#define RTM_GETADDRLABEL RTM_GETADDRLABEL
|
|
|
|
|
2008-11-20 21:52:10 -07:00
|
|
|
RTM_GETDCB = 78,
|
|
|
|
#define RTM_GETDCB RTM_GETDCB
|
|
|
|
RTM_SETDCB,
|
|
|
|
#define RTM_SETDCB RTM_SETDCB
|
|
|
|
|
2005-05-03 15:27:35 -06:00
|
|
|
__RTM_MAX,
|
|
|
|
#define RTM_MAX (((__RTM_MAX + 3) & ~3) - 1)
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
2005-05-03 15:29:39 -06:00
|
|
|
#define RTM_NR_MSGTYPES (RTM_MAX + 1 - RTM_BASE)
|
|
|
|
#define RTM_NR_FAMILIES (RTM_NR_MSGTYPES >> 2)
|
2005-05-03 15:29:00 -06:00
|
|
|
#define RTM_FAM(cmd) (((cmd) - RTM_BASE) >> 2)
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
Generic structure for encapsulation of optional route information.
|
|
|
|
It is reminiscent of sockaddr, but with sa_family replaced
|
|
|
|
with attribute type.
|
|
|
|
*/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct rtattr {
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned short rta_len;
|
|
|
|
unsigned short rta_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Macros to handle rtattributes */
|
|
|
|
|
|
|
|
#define RTA_ALIGNTO 4
|
|
|
|
#define RTA_ALIGN(len) ( ((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1) )
|
|
|
|
#define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \
|
|
|
|
(rta)->rta_len >= sizeof(struct rtattr) && \
|
|
|
|
(rta)->rta_len <= (len))
|
|
|
|
#define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \
|
|
|
|
(struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len)))
|
|
|
|
#define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len))
|
|
|
|
#define RTA_SPACE(len) RTA_ALIGN(RTA_LENGTH(len))
|
|
|
|
#define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0)))
|
|
|
|
#define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* Definitions used in routing table administration.
|
|
|
|
****/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct rtmsg {
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned char rtm_family;
|
|
|
|
unsigned char rtm_dst_len;
|
|
|
|
unsigned char rtm_src_len;
|
|
|
|
unsigned char rtm_tos;
|
|
|
|
|
|
|
|
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 rtm_flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* rtm_type */
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
enum {
|
2005-04-16 16:20:36 -06:00
|
|
|
RTN_UNSPEC,
|
|
|
|
RTN_UNICAST, /* Gateway or direct route */
|
|
|
|
RTN_LOCAL, /* Accept locally */
|
|
|
|
RTN_BROADCAST, /* Accept locally as broadcast,
|
|
|
|
send as broadcast */
|
|
|
|
RTN_ANYCAST, /* Accept locally as broadcast,
|
|
|
|
but send as unicast */
|
|
|
|
RTN_MULTICAST, /* Multicast route */
|
|
|
|
RTN_BLACKHOLE, /* Drop */
|
|
|
|
RTN_UNREACHABLE, /* Destination is unreachable */
|
|
|
|
RTN_PROHIBIT, /* Administratively prohibited */
|
|
|
|
RTN_THROW, /* Not in this table */
|
|
|
|
RTN_NAT, /* Translate this address */
|
|
|
|
RTN_XRESOLVE, /* Use external resolver */
|
|
|
|
__RTN_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RTN_MAX (__RTN_MAX - 1)
|
|
|
|
|
|
|
|
|
|
|
|
/* rtm_protocol */
|
|
|
|
|
|
|
|
#define RTPROT_UNSPEC 0
|
|
|
|
#define RTPROT_REDIRECT 1 /* Route installed by ICMP redirects;
|
|
|
|
not used by current IPv4 */
|
|
|
|
#define RTPROT_KERNEL 2 /* Route installed by kernel */
|
|
|
|
#define RTPROT_BOOT 3 /* Route installed during boot */
|
|
|
|
#define RTPROT_STATIC 4 /* Route installed by administrator */
|
|
|
|
|
|
|
|
/* Values of protocol >= RTPROT_STATIC are not interpreted by kernel;
|
|
|
|
they are just passed from user and back as is.
|
|
|
|
It will be used by hypothetical multiple routing daemons.
|
|
|
|
Note that protocol values should be standardized in order to
|
|
|
|
avoid conflicts.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define RTPROT_GATED 8 /* Apparently, GateD */
|
|
|
|
#define RTPROT_RA 9 /* RDISC/ND router advertisements */
|
|
|
|
#define RTPROT_MRT 10 /* Merit MRT */
|
|
|
|
#define RTPROT_ZEBRA 11 /* Zebra */
|
|
|
|
#define RTPROT_BIRD 12 /* BIRD */
|
|
|
|
#define RTPROT_DNROUTED 13 /* DECnet routing daemon */
|
|
|
|
#define RTPROT_XORP 14 /* XORP */
|
2006-03-20 23:26:17 -07:00
|
|
|
#define RTPROT_NTK 15 /* Netsukuku */
|
2009-03-20 00:49:41 -06:00
|
|
|
#define RTPROT_DHCP 16 /* DHCP client */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* rtm_scope
|
|
|
|
|
|
|
|
Really it is not scope, but sort of distance to the destination.
|
|
|
|
NOWHERE are reserved for not existing destinations, HOST is our
|
|
|
|
local addresses, LINK are destinations, located on directly attached
|
|
|
|
link and UNIVERSE is everywhere in the Universe.
|
|
|
|
|
|
|
|
Intermediate values are also possible f.e. interior routes
|
|
|
|
could be assigned a value between UNIVERSE and LINK.
|
|
|
|
*/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
enum rt_scope_t {
|
2005-04-16 16:20:36 -06:00
|
|
|
RT_SCOPE_UNIVERSE=0,
|
|
|
|
/* User defined values */
|
|
|
|
RT_SCOPE_SITE=200,
|
|
|
|
RT_SCOPE_LINK=253,
|
|
|
|
RT_SCOPE_HOST=254,
|
|
|
|
RT_SCOPE_NOWHERE=255
|
|
|
|
};
|
|
|
|
|
|
|
|
/* rtm_flags */
|
|
|
|
|
|
|
|
#define RTM_F_NOTIFY 0x100 /* Notify user of route change */
|
|
|
|
#define RTM_F_CLONED 0x200 /* This route is cloned */
|
|
|
|
#define RTM_F_EQUALIZE 0x400 /* Multipath equalizer: NI */
|
|
|
|
#define RTM_F_PREFIX 0x800 /* Prefix addresses */
|
|
|
|
|
|
|
|
/* Reserved table identifiers */
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
enum rt_class_t {
|
2005-04-16 16:20:36 -06:00
|
|
|
RT_TABLE_UNSPEC=0,
|
|
|
|
/* User defined values */
|
2008-06-10 16:44:49 -06:00
|
|
|
RT_TABLE_COMPAT=252,
|
2005-04-16 16:20:36 -06:00
|
|
|
RT_TABLE_DEFAULT=253,
|
|
|
|
RT_TABLE_MAIN=254,
|
|
|
|
RT_TABLE_LOCAL=255,
|
2006-08-11 00:12:34 -06:00
|
|
|
RT_TABLE_MAX=0xFFFFFFFF
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Routing message attributes */
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
enum rtattr_type_t {
|
2005-04-16 16:20:36 -06:00
|
|
|
RTA_UNSPEC,
|
|
|
|
RTA_DST,
|
|
|
|
RTA_SRC,
|
|
|
|
RTA_IIF,
|
|
|
|
RTA_OIF,
|
|
|
|
RTA_GATEWAY,
|
|
|
|
RTA_PRIORITY,
|
|
|
|
RTA_PREFSRC,
|
|
|
|
RTA_METRICS,
|
|
|
|
RTA_MULTIPATH,
|
2008-06-03 17:36:27 -06:00
|
|
|
RTA_PROTOINFO, /* no longer used */
|
2005-04-16 16:20:36 -06:00
|
|
|
RTA_FLOW,
|
|
|
|
RTA_CACHEINFO,
|
2008-06-03 17:36:27 -06:00
|
|
|
RTA_SESSION, /* no longer used */
|
2007-06-10 18:22:39 -06:00
|
|
|
RTA_MP_ALGO, /* no longer used */
|
2006-08-11 00:09:48 -06:00
|
|
|
RTA_TABLE,
|
2005-04-16 16:20:36 -06:00
|
|
|
__RTA_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RTA_MAX (__RTA_MAX - 1)
|
|
|
|
|
|
|
|
#define RTM_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct rtmsg))))
|
|
|
|
#define RTM_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct rtmsg))
|
|
|
|
|
|
|
|
/* RTM_MULTIPATH --- array of struct rtnexthop.
|
|
|
|
*
|
|
|
|
* "struct rtnexthop" describes all necessary nexthop information,
|
|
|
|
* i.e. parameters of path to a destination via this nexthop.
|
|
|
|
*
|
|
|
|
* At the moment it is impossible to set different prefsrc, mtu, window
|
|
|
|
* and rtt for different paths from multipath.
|
|
|
|
*/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct rtnexthop {
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned short rtnh_len;
|
|
|
|
unsigned char rtnh_flags;
|
|
|
|
unsigned char rtnh_hops;
|
|
|
|
int rtnh_ifindex;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* rtnh_flags */
|
|
|
|
|
|
|
|
#define RTNH_F_DEAD 1 /* Nexthop is dead (used by multipath) */
|
|
|
|
#define RTNH_F_PERVASIVE 2 /* Do recursive gateway lookup */
|
|
|
|
#define RTNH_F_ONLINK 4 /* Gateway is forced on link */
|
|
|
|
|
|
|
|
/* Macros to handle hexthops */
|
|
|
|
|
|
|
|
#define RTNH_ALIGNTO 4
|
|
|
|
#define RTNH_ALIGN(len) ( ((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1) )
|
|
|
|
#define RTNH_OK(rtnh,len) ((rtnh)->rtnh_len >= sizeof(struct rtnexthop) && \
|
|
|
|
((int)(rtnh)->rtnh_len) <= (len))
|
|
|
|
#define RTNH_NEXT(rtnh) ((struct rtnexthop*)(((char*)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len)))
|
|
|
|
#define RTNH_LENGTH(len) (RTNH_ALIGN(sizeof(struct rtnexthop)) + (len))
|
|
|
|
#define RTNH_SPACE(len) RTNH_ALIGN(RTNH_LENGTH(len))
|
|
|
|
#define RTNH_DATA(rtnh) ((struct rtattr*)(((char*)(rtnh)) + RTNH_LENGTH(0)))
|
|
|
|
|
|
|
|
/* RTM_CACHEINFO */
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct rta_cacheinfo {
|
2005-04-16 16:20:36 -06:00
|
|
|
__u32 rta_clntref;
|
|
|
|
__u32 rta_lastuse;
|
|
|
|
__s32 rta_expires;
|
|
|
|
__u32 rta_error;
|
|
|
|
__u32 rta_used;
|
|
|
|
|
|
|
|
#define RTNETLINK_HAVE_PEERINFO 1
|
|
|
|
__u32 rta_id;
|
|
|
|
__u32 rta_ts;
|
|
|
|
__u32 rta_tsage;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* RTM_METRICS --- array of struct rtattr with types of RTAX_* */
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
enum {
|
2005-04-16 16:20:36 -06:00
|
|
|
RTAX_UNSPEC,
|
|
|
|
#define RTAX_UNSPEC RTAX_UNSPEC
|
|
|
|
RTAX_LOCK,
|
|
|
|
#define RTAX_LOCK RTAX_LOCK
|
|
|
|
RTAX_MTU,
|
|
|
|
#define RTAX_MTU RTAX_MTU
|
|
|
|
RTAX_WINDOW,
|
|
|
|
#define RTAX_WINDOW RTAX_WINDOW
|
|
|
|
RTAX_RTT,
|
|
|
|
#define RTAX_RTT RTAX_RTT
|
|
|
|
RTAX_RTTVAR,
|
|
|
|
#define RTAX_RTTVAR RTAX_RTTVAR
|
|
|
|
RTAX_SSTHRESH,
|
|
|
|
#define RTAX_SSTHRESH RTAX_SSTHRESH
|
|
|
|
RTAX_CWND,
|
|
|
|
#define RTAX_CWND RTAX_CWND
|
|
|
|
RTAX_ADVMSS,
|
|
|
|
#define RTAX_ADVMSS RTAX_ADVMSS
|
|
|
|
RTAX_REORDERING,
|
|
|
|
#define RTAX_REORDERING RTAX_REORDERING
|
|
|
|
RTAX_HOPLIMIT,
|
|
|
|
#define RTAX_HOPLIMIT RTAX_HOPLIMIT
|
|
|
|
RTAX_INITCWND,
|
|
|
|
#define RTAX_INITCWND RTAX_INITCWND
|
|
|
|
RTAX_FEATURES,
|
|
|
|
#define RTAX_FEATURES RTAX_FEATURES
|
2007-08-30 23:10:28 -06:00
|
|
|
RTAX_RTO_MIN,
|
|
|
|
#define RTAX_RTO_MIN RTAX_RTO_MIN
|
2005-04-16 16:20:36 -06:00
|
|
|
__RTAX_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define RTAX_MAX (__RTAX_MAX - 1)
|
|
|
|
|
|
|
|
#define RTAX_FEATURE_ECN 0x00000001
|
tcp: Revert per-route SACK/DSACK/TIMESTAMP changes.
It creates a regression, triggering badness for SYN_RECV
sockets, for example:
[19148.022102] Badness at net/ipv4/inet_connection_sock.c:293
[19148.022570] NIP: c02a0914 LR: c02a0904 CTR: 00000000
[19148.023035] REGS: eeecbd30 TRAP: 0700 Not tainted (2.6.32)
[19148.023496] MSR: 00029032 <EE,ME,CE,IR,DR> CR: 24002442 XER: 00000000
[19148.024012] TASK = eee9a820[1756] 'privoxy' THREAD: eeeca000
This is likely caused by the change in the 'estab' parameter
passed to tcp_parse_options() when invoked by the functions
in net/ipv4/tcp_minisocks.c
But even if that is fixed, the ->conn_request() changes made in
this patch series is fundamentally wrong. They try to use the
listening socket's 'dst' to probe the route settings. The
listening socket doesn't even have a route, and you can't
get the right route (the child request one) until much later
after we setup all of the state, and it must be done by hand.
This stuff really isn't ready, so the best thing to do is a
full revert. This reverts the following commits:
f55017a93f1a74d50244b1254b9a2bd7ac9bbf7d
022c3f7d82f0f1c68018696f2f027b87b9bb45c2
1aba721eba1d84a2defce45b950272cee1e6c72a
cda42ebd67ee5fdf09d7057b5a4584d36fe8a335
345cda2fd695534be5a4494f1b59da9daed33663
dc343475ed062e13fc260acccaab91d7d80fd5b2
05eaade2782fb0c90d3034fd7a7d5a16266182bb
6a2a2d6bf8581216e08be15fcb563cfd6c430e1e
Signed-off-by: David S. Miller <davem@davemloft.net>
2009-12-15 21:56:42 -07:00
|
|
|
#define RTAX_FEATURE_SACK 0x00000002
|
|
|
|
#define RTAX_FEATURE_TIMESTAMP 0x00000004
|
2005-04-16 16:20:36 -06:00
|
|
|
#define RTAX_FEATURE_ALLFRAG 0x00000008
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct rta_session {
|
2005-04-16 16:20:36 -06:00
|
|
|
__u8 proto;
|
2005-06-28 13:56:45 -06:00
|
|
|
__u8 pad1;
|
|
|
|
__u16 pad2;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
__u16 sport;
|
|
|
|
__u16 dport;
|
|
|
|
} ports;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
__u8 type;
|
|
|
|
__u8 code;
|
|
|
|
__u16 ident;
|
|
|
|
} icmpt;
|
|
|
|
|
|
|
|
__u32 spi;
|
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
|
|
|
/****
|
|
|
|
* General form of address family dependent message.
|
|
|
|
****/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct rtgenmsg {
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned char rtgen_family;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* Link layer specific messages.
|
|
|
|
****/
|
|
|
|
|
|
|
|
/* struct ifinfomsg
|
|
|
|
* passes link level specific information, not dependent
|
|
|
|
* on network protocol.
|
|
|
|
*/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct ifinfomsg {
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned char ifi_family;
|
|
|
|
unsigned char __ifi_pad;
|
|
|
|
unsigned short ifi_type; /* ARPHRD_* */
|
|
|
|
int ifi_index; /* Link index */
|
|
|
|
unsigned ifi_flags; /* IFF_* flags */
|
|
|
|
unsigned ifi_change; /* IFF_* change mask */
|
|
|
|
};
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* prefix information
|
|
|
|
****/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct prefixmsg {
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned char prefix_family;
|
2005-06-28 13:56:45 -06:00
|
|
|
unsigned char prefix_pad1;
|
|
|
|
unsigned short prefix_pad2;
|
2005-04-16 16:20:36 -06:00
|
|
|
int prefix_ifindex;
|
|
|
|
unsigned char prefix_type;
|
|
|
|
unsigned char prefix_len;
|
|
|
|
unsigned char prefix_flags;
|
2005-06-28 13:56:45 -06:00
|
|
|
unsigned char prefix_pad3;
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PREFIX_UNSPEC,
|
|
|
|
PREFIX_ADDRESS,
|
|
|
|
PREFIX_CACHEINFO,
|
|
|
|
__PREFIX_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define PREFIX_MAX (__PREFIX_MAX - 1)
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct prefix_cacheinfo {
|
2005-04-16 16:20:36 -06:00
|
|
|
__u32 preferred_time;
|
|
|
|
__u32 valid_time;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************
|
|
|
|
* Traffic control messages.
|
|
|
|
****/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct tcmsg {
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned char tcm_family;
|
|
|
|
unsigned char tcm__pad1;
|
|
|
|
unsigned short tcm__pad2;
|
|
|
|
int tcm_ifindex;
|
|
|
|
__u32 tcm_handle;
|
|
|
|
__u32 tcm_parent;
|
|
|
|
__u32 tcm_info;
|
|
|
|
};
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
enum {
|
2005-04-16 16:20:36 -06:00
|
|
|
TCA_UNSPEC,
|
|
|
|
TCA_KIND,
|
|
|
|
TCA_OPTIONS,
|
|
|
|
TCA_STATS,
|
|
|
|
TCA_XSTATS,
|
|
|
|
TCA_RATE,
|
|
|
|
TCA_FCNT,
|
|
|
|
TCA_STATS2,
|
2008-07-20 01:08:47 -06:00
|
|
|
TCA_STAB,
|
2005-04-16 16:20:36 -06:00
|
|
|
__TCA_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TCA_MAX (__TCA_MAX - 1)
|
|
|
|
|
|
|
|
#define TCA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcmsg))))
|
|
|
|
#define TCA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcmsg))
|
|
|
|
|
2007-10-10 22:22:05 -06:00
|
|
|
/********************************************************************
|
|
|
|
* Neighbor Discovery userland options
|
|
|
|
****/
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
struct nduseroptmsg {
|
2007-10-10 22:22:05 -06:00
|
|
|
unsigned char nduseropt_family;
|
|
|
|
unsigned char nduseropt_pad1;
|
|
|
|
unsigned short nduseropt_opts_len; /* Total length of options */
|
2007-11-12 18:58:35 -07:00
|
|
|
int nduseropt_ifindex;
|
2007-10-10 22:22:05 -06:00
|
|
|
__u8 nduseropt_icmp_type;
|
|
|
|
__u8 nduseropt_icmp_code;
|
|
|
|
unsigned short nduseropt_pad2;
|
2007-11-12 18:58:35 -07:00
|
|
|
unsigned int nduseropt_pad3;
|
2007-10-10 22:22:05 -06:00
|
|
|
/* Followed by one or more ND options */
|
|
|
|
};
|
|
|
|
|
2009-11-04 10:50:58 -07:00
|
|
|
enum {
|
2007-10-10 22:22:05 -06:00
|
|
|
NDUSEROPT_UNSPEC,
|
|
|
|
NDUSEROPT_SRCADDR,
|
|
|
|
__NDUSEROPT_MAX
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NDUSEROPT_MAX (__NDUSEROPT_MAX - 1)
|
|
|
|
|
2005-08-14 20:29:52 -06:00
|
|
|
#ifndef __KERNEL__
|
|
|
|
/* RTnetlink multicast groups - backwards compatibility for userspace */
|
2005-04-16 16:20:36 -06:00
|
|
|
#define RTMGRP_LINK 1
|
|
|
|
#define RTMGRP_NOTIFY 2
|
|
|
|
#define RTMGRP_NEIGH 4
|
|
|
|
#define RTMGRP_TC 8
|
|
|
|
|
|
|
|
#define RTMGRP_IPV4_IFADDR 0x10
|
|
|
|
#define RTMGRP_IPV4_MROUTE 0x20
|
|
|
|
#define RTMGRP_IPV4_ROUTE 0x40
|
2006-03-23 02:16:06 -07:00
|
|
|
#define RTMGRP_IPV4_RULE 0x80
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define RTMGRP_IPV6_IFADDR 0x100
|
|
|
|
#define RTMGRP_IPV6_MROUTE 0x200
|
|
|
|
#define RTMGRP_IPV6_ROUTE 0x400
|
|
|
|
#define RTMGRP_IPV6_IFINFO 0x800
|
|
|
|
|
|
|
|
#define RTMGRP_DECnet_IFADDR 0x1000
|
|
|
|
#define RTMGRP_DECnet_ROUTE 0x4000
|
|
|
|
|
|
|
|
#define RTMGRP_IPV6_PREFIX 0x20000
|
2005-08-14 20:29:52 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* RTnetlink multicast groups */
|
|
|
|
enum rtnetlink_groups {
|
|
|
|
RTNLGRP_NONE,
|
|
|
|
#define RTNLGRP_NONE RTNLGRP_NONE
|
|
|
|
RTNLGRP_LINK,
|
|
|
|
#define RTNLGRP_LINK RTNLGRP_LINK
|
|
|
|
RTNLGRP_NOTIFY,
|
|
|
|
#define RTNLGRP_NOTIFY RTNLGRP_NOTIFY
|
|
|
|
RTNLGRP_NEIGH,
|
|
|
|
#define RTNLGRP_NEIGH RTNLGRP_NEIGH
|
|
|
|
RTNLGRP_TC,
|
|
|
|
#define RTNLGRP_TC RTNLGRP_TC
|
|
|
|
RTNLGRP_IPV4_IFADDR,
|
|
|
|
#define RTNLGRP_IPV4_IFADDR RTNLGRP_IPV4_IFADDR
|
|
|
|
RTNLGRP_IPV4_MROUTE,
|
|
|
|
#define RTNLGRP_IPV4_MROUTE RTNLGRP_IPV4_MROUTE
|
|
|
|
RTNLGRP_IPV4_ROUTE,
|
|
|
|
#define RTNLGRP_IPV4_ROUTE RTNLGRP_IPV4_ROUTE
|
2006-03-23 02:16:06 -07:00
|
|
|
RTNLGRP_IPV4_RULE,
|
|
|
|
#define RTNLGRP_IPV4_RULE RTNLGRP_IPV4_RULE
|
2005-08-14 20:29:52 -06:00
|
|
|
RTNLGRP_IPV6_IFADDR,
|
|
|
|
#define RTNLGRP_IPV6_IFADDR RTNLGRP_IPV6_IFADDR
|
|
|
|
RTNLGRP_IPV6_MROUTE,
|
|
|
|
#define RTNLGRP_IPV6_MROUTE RTNLGRP_IPV6_MROUTE
|
|
|
|
RTNLGRP_IPV6_ROUTE,
|
|
|
|
#define RTNLGRP_IPV6_ROUTE RTNLGRP_IPV6_ROUTE
|
|
|
|
RTNLGRP_IPV6_IFINFO,
|
|
|
|
#define RTNLGRP_IPV6_IFINFO RTNLGRP_IPV6_IFINFO
|
|
|
|
RTNLGRP_DECnet_IFADDR,
|
|
|
|
#define RTNLGRP_DECnet_IFADDR RTNLGRP_DECnet_IFADDR
|
2005-12-19 14:54:44 -07:00
|
|
|
RTNLGRP_NOP2,
|
2005-08-14 20:29:52 -06:00
|
|
|
RTNLGRP_DECnet_ROUTE,
|
|
|
|
#define RTNLGRP_DECnet_ROUTE RTNLGRP_DECnet_ROUTE
|
2006-08-09 16:56:46 -06:00
|
|
|
RTNLGRP_DECnet_RULE,
|
|
|
|
#define RTNLGRP_DECnet_RULE RTNLGRP_DECnet_RULE
|
2005-12-19 14:54:44 -07:00
|
|
|
RTNLGRP_NOP4,
|
2005-08-14 20:29:52 -06:00
|
|
|
RTNLGRP_IPV6_PREFIX,
|
|
|
|
#define RTNLGRP_IPV6_PREFIX RTNLGRP_IPV6_PREFIX
|
2006-08-04 04:39:02 -06:00
|
|
|
RTNLGRP_IPV6_RULE,
|
|
|
|
#define RTNLGRP_IPV6_RULE RTNLGRP_IPV6_RULE
|
2007-10-10 22:22:05 -06:00
|
|
|
RTNLGRP_ND_USEROPT,
|
|
|
|
#define RTNLGRP_ND_USEROPT RTNLGRP_ND_USEROPT
|
2008-09-22 20:51:15 -06:00
|
|
|
RTNLGRP_PHONET_IFADDR,
|
|
|
|
#define RTNLGRP_PHONET_IFADDR RTNLGRP_PHONET_IFADDR
|
|
|
|
RTNLGRP_PHONET_ROUTE,
|
|
|
|
#define RTNLGRP_PHONET_ROUTE RTNLGRP_PHONET_ROUTE
|
2005-08-14 20:29:52 -06:00
|
|
|
__RTNLGRP_MAX
|
|
|
|
};
|
|
|
|
#define RTNLGRP_MAX (__RTNLGRP_MAX - 1)
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* TC action piece */
|
2009-11-04 10:50:58 -07:00
|
|
|
struct tcamsg {
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned char tca_family;
|
|
|
|
unsigned char tca__pad1;
|
|
|
|
unsigned short tca__pad2;
|
|
|
|
};
|
|
|
|
#define TA_RTA(r) ((struct rtattr*)(((char*)(r)) + NLMSG_ALIGN(sizeof(struct tcamsg))))
|
|
|
|
#define TA_PAYLOAD(n) NLMSG_PAYLOAD(n,sizeof(struct tcamsg))
|
|
|
|
#define TCA_ACT_TAB 1 /* attr type must be >=1 */
|
|
|
|
#define TCAA_MAX 1
|
|
|
|
|
|
|
|
/* End of information exported to user level */
|
|
|
|
|
|
|
|
#ifdef __KERNEL__
|
|
|
|
|
2006-03-20 23:23:58 -07:00
|
|
|
#include <linux/mutex.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
static __inline__ int rtattr_strcmp(const struct rtattr *rta, const char *str)
|
|
|
|
{
|
|
|
|
int len = strlen(str) + 1;
|
|
|
|
return len > rta->rta_len || memcmp(RTA_DATA(rta), str, len);
|
|
|
|
}
|
|
|
|
|
2007-11-19 23:26:51 -07:00
|
|
|
extern int rtnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, u32 group, int echo);
|
|
|
|
extern int rtnl_unicast(struct sk_buff *skb, struct net *net, u32 pid);
|
2009-02-25 00:18:28 -07:00
|
|
|
extern void rtnl_notify(struct sk_buff *skb, struct net *net, u32 pid,
|
|
|
|
u32 group, struct nlmsghdr *nlh, gfp_t flags);
|
2007-11-19 23:26:51 -07:00
|
|
|
extern void rtnl_set_sk_err(struct net *net, u32 group, int error);
|
2005-04-16 16:20:36 -06:00
|
|
|
extern int rtnetlink_put_metrics(struct sk_buff *skb, u32 *metrics);
|
2006-11-27 10:27:07 -07:00
|
|
|
extern int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst,
|
|
|
|
u32 id, u32 ts, u32 tsage, long expires,
|
|
|
|
u32 error);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
extern void __rta_fill(struct sk_buff *skb, int attrtype, int attrlen, const void *data);
|
|
|
|
|
|
|
|
#define RTA_PUT(skb, attrtype, attrlen, data) \
|
|
|
|
({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
|
|
|
|
goto rtattr_failure; \
|
|
|
|
__rta_fill(skb, attrtype, attrlen, data); })
|
|
|
|
|
2005-06-23 22:00:58 -06:00
|
|
|
#define RTA_APPEND(skb, attrlen, data) \
|
2005-04-16 16:20:36 -06:00
|
|
|
({ if (unlikely(skb_tailroom(skb) < (int)(attrlen))) \
|
|
|
|
goto rtattr_failure; \
|
2005-06-23 22:00:58 -06:00
|
|
|
memcpy(skb_put(skb, attrlen), data, attrlen); })
|
|
|
|
|
|
|
|
#define RTA_PUT_NOHDR(skb, attrlen, data) \
|
2005-06-28 13:54:43 -06:00
|
|
|
({ RTA_APPEND(skb, RTA_ALIGN(attrlen), data); \
|
2007-04-19 21:29:13 -06:00
|
|
|
memset(skb_tail_pointer(skb) - (RTA_ALIGN(attrlen) - attrlen), 0, \
|
2005-06-28 13:54:43 -06:00
|
|
|
RTA_ALIGN(attrlen) - attrlen); })
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
|
2005-06-18 23:52:36 -06:00
|
|
|
#define RTA_PUT_U8(skb, attrtype, value) \
|
|
|
|
({ u8 _tmp = (value); \
|
|
|
|
RTA_PUT(skb, attrtype, sizeof(u8), &_tmp); })
|
|
|
|
|
|
|
|
#define RTA_PUT_U16(skb, attrtype, value) \
|
|
|
|
({ u16 _tmp = (value); \
|
|
|
|
RTA_PUT(skb, attrtype, sizeof(u16), &_tmp); })
|
|
|
|
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
#define RTA_PUT_U32(skb, attrtype, value) \
|
|
|
|
({ u32 _tmp = (value); \
|
|
|
|
RTA_PUT(skb, attrtype, sizeof(u32), &_tmp); })
|
|
|
|
|
|
|
|
#define RTA_PUT_U64(skb, attrtype, value) \
|
|
|
|
({ u64 _tmp = (value); \
|
|
|
|
RTA_PUT(skb, attrtype, sizeof(u64), &_tmp); })
|
|
|
|
|
|
|
|
#define RTA_PUT_SECS(skb, attrtype, value) \
|
|
|
|
RTA_PUT_U64(skb, attrtype, (value) / HZ)
|
|
|
|
|
|
|
|
#define RTA_PUT_MSECS(skb, attrtype, value) \
|
|
|
|
RTA_PUT_U64(skb, attrtype, jiffies_to_msecs(value))
|
|
|
|
|
|
|
|
#define RTA_PUT_STRING(skb, attrtype, value) \
|
|
|
|
RTA_PUT(skb, attrtype, strlen(value) + 1, value)
|
|
|
|
|
2005-06-18 23:52:36 -06:00
|
|
|
#define RTA_PUT_FLAG(skb, attrtype) \
|
|
|
|
RTA_PUT(skb, attrtype, 0, NULL);
|
|
|
|
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
#define RTA_NEST(skb, type) \
|
2007-04-19 21:29:13 -06:00
|
|
|
({ struct rtattr *__start = (struct rtattr *)skb_tail_pointer(skb); \
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
RTA_PUT(skb, type, 0, NULL); \
|
|
|
|
__start; })
|
|
|
|
|
|
|
|
#define RTA_NEST_END(skb, start) \
|
2007-04-19 21:29:13 -06:00
|
|
|
({ (start)->rta_len = skb_tail_pointer(skb) - (unsigned char *)(start); \
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
(skb)->len; })
|
|
|
|
|
2007-06-25 15:30:16 -06:00
|
|
|
#define RTA_NEST_COMPAT(skb, type, attrlen, data) \
|
|
|
|
({ struct rtattr *__start = (struct rtattr *)skb_tail_pointer(skb); \
|
|
|
|
RTA_PUT(skb, type, attrlen, data); \
|
|
|
|
RTA_NEST(skb, type); \
|
|
|
|
__start; })
|
|
|
|
|
|
|
|
#define RTA_NEST_COMPAT_END(skb, start) \
|
|
|
|
({ struct rtattr *__nest = (void *)(start) + NLMSG_ALIGN((start)->rta_len); \
|
|
|
|
(start)->rta_len = skb_tail_pointer(skb) - (unsigned char *)(start); \
|
|
|
|
RTA_NEST_END(skb, __nest); \
|
|
|
|
(skb)->len; })
|
|
|
|
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
#define RTA_NEST_CANCEL(skb, start) \
|
2005-06-18 23:51:26 -06:00
|
|
|
({ if (start) \
|
|
|
|
skb_trim(skb, (unsigned char *) (start) - (skb)->data); \
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
-1; })
|
|
|
|
|
2005-06-18 23:52:36 -06:00
|
|
|
#define RTA_GET_U8(rta) \
|
|
|
|
({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u8)) \
|
|
|
|
goto rtattr_failure; \
|
|
|
|
*(u8 *) RTA_DATA(rta); })
|
|
|
|
|
|
|
|
#define RTA_GET_U16(rta) \
|
|
|
|
({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u16)) \
|
|
|
|
goto rtattr_failure; \
|
|
|
|
*(u16 *) RTA_DATA(rta); })
|
|
|
|
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
#define RTA_GET_U32(rta) \
|
|
|
|
({ if (!rta || RTA_PAYLOAD(rta) < sizeof(u32)) \
|
|
|
|
goto rtattr_failure; \
|
|
|
|
*(u32 *) RTA_DATA(rta); })
|
|
|
|
|
|
|
|
#define RTA_GET_U64(rta) \
|
|
|
|
({ u64 _tmp; \
|
|
|
|
if (!rta || RTA_PAYLOAD(rta) < sizeof(u64)) \
|
|
|
|
goto rtattr_failure; \
|
|
|
|
memcpy(&_tmp, RTA_DATA(rta), sizeof(_tmp)); \
|
|
|
|
_tmp; })
|
|
|
|
|
2005-06-18 23:52:36 -06:00
|
|
|
#define RTA_GET_FLAG(rta) (!!(rta))
|
|
|
|
|
[NETLINK] Routing attribute related shortcuts
RTA_GET_U(32|64)(tlv)
Assumes TLV is a u32/u64 field and returns its value.
RTA_GET_[M]SECS(tlv)
Assumes TLV is a u64 and transports jiffies converted
to seconds or milliseconds and returns its value.
RTA_PUT_U(32|64)(skb, type, value)
Appends %value as fixed u32/u64 to %skb as TLV %type.
RTA_PUT_[M]SECS(skb, type, jiffies)
Converts %jiffies to secs/msecs and appends it as u64
to %skb as TLV %type.
RTA_PUT_STRING(skb, type, string)
Appends %NUL terminated %string to %skb as TLV %type.
RTA_NEST(skb, type)
Starts a nested TLV %type and returns the nesting handle.
RTA_NEST_END(skb, nesting_handle)
Finishes the nested TLV %nesting_handle, must be called
symmetric to RTA_NEST(). Returns skb->len
RTA_NEST_CANCEL(skb, nesting_handle)
Cancel the nested TLV %nesting_handle and trim nested TLV
from skb again, returns -1.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2005-06-18 23:50:38 -06:00
|
|
|
#define RTA_GET_SECS(rta) ((unsigned long) RTA_GET_U64(rta) * HZ)
|
|
|
|
#define RTA_GET_MSECS(rta) (msecs_to_jiffies((unsigned long) RTA_GET_U64(rta)))
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
static inline struct rtattr *
|
|
|
|
__rta_reserve(struct sk_buff *skb, int attrtype, int attrlen)
|
|
|
|
{
|
|
|
|
struct rtattr *rta;
|
|
|
|
int size = RTA_LENGTH(attrlen);
|
|
|
|
|
|
|
|
rta = (struct rtattr*)skb_put(skb, RTA_ALIGN(size));
|
|
|
|
rta->rta_type = attrtype;
|
|
|
|
rta->rta_len = size;
|
2005-06-28 13:54:43 -06:00
|
|
|
memset(RTA_DATA(rta) + attrlen, 0, RTA_ALIGN(size) - size);
|
2005-04-16 16:20:36 -06:00
|
|
|
return rta;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define __RTA_PUT(skb, attrtype, attrlen) \
|
|
|
|
({ if (unlikely(skb_tailroom(skb) < (int)RTA_SPACE(attrlen))) \
|
|
|
|
goto rtattr_failure; \
|
|
|
|
__rta_reserve(skb, attrtype, attrlen); })
|
|
|
|
|
|
|
|
extern void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change);
|
|
|
|
|
2006-03-20 23:23:58 -07:00
|
|
|
/* RTNL is used as a global lock for all changes to network configuration */
|
2005-04-16 16:20:36 -06:00
|
|
|
extern void rtnl_lock(void);
|
|
|
|
extern void rtnl_unlock(void);
|
2006-03-20 23:23:58 -07:00
|
|
|
extern int rtnl_trylock(void);
|
2008-04-23 23:10:48 -06:00
|
|
|
extern int rtnl_is_locked(void);
|
2006-03-20 23:23:58 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
extern void rtnetlink_init(void);
|
2006-03-20 23:23:58 -07:00
|
|
|
extern void __rtnl_unlock(void);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#define ASSERT_RTNL() do { \
|
2008-04-23 23:10:48 -06:00
|
|
|
if (unlikely(!rtnl_is_locked())) { \
|
2005-04-16 16:20:36 -06:00
|
|
|
printk(KERN_ERR "RTNL: assertion failed at %s (%d)\n", \
|
|
|
|
__FILE__, __LINE__); \
|
|
|
|
dump_stack(); \
|
|
|
|
} \
|
|
|
|
} while(0)
|
|
|
|
|
2006-08-11 00:09:48 -06:00
|
|
|
static inline u32 rtm_get_table(struct rtattr **rta, u8 table)
|
|
|
|
{
|
|
|
|
return RTA_GET_U32(rta[RTA_TABLE-1]);
|
|
|
|
rtattr_failure:
|
|
|
|
return table;
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif /* __KERNEL__ */
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* __LINUX_RTNETLINK_H */
|