rtnetlink.c File Reference

Go to the source code of this file.

Classes

struct  rtnl_link

Functions

static DEFINE_MUTEX (rtnl_mutex)
void rtnl_lock (void)
void __rtnl_unlock (void)
void rtnl_unlock (void)
int rtnl_trylock (void)
int rtnl_is_locked (void)
static int rtm_msgindex (int msgtype)
static rtnl_doit_func rtnl_get_doit (int protocol, int msgindex)
static rtnl_dumpit_func rtnl_get_dumpit (int protocol, int msgindex)
int __rtnl_register (int protocol, int msgtype, rtnl_doit_func doit, rtnl_dumpit_func dumpit)
 EXPORT_SYMBOL_GPL (__rtnl_register)
void rtnl_register (int protocol, int msgtype, rtnl_doit_func doit, rtnl_dumpit_func dumpit)
 rtnl_register - Register a rtnetlink message type
 EXPORT_SYMBOL_GPL (rtnl_register)
int rtnl_unregister (int protocol, int msgtype)
 EXPORT_SYMBOL_GPL (rtnl_unregister)
void rtnl_unregister_all (int protocol)
 EXPORT_SYMBOL_GPL (rtnl_unregister_all)
static LIST_HEAD (link_ops)
int __rtnl_link_register (struct rtnl_link_ops *ops)
 __rtnl_link_register - Register rtnl_link_ops with rtnetlink.
 EXPORT_SYMBOL_GPL (__rtnl_link_register)
int rtnl_link_register (struct rtnl_link_ops *ops)
 rtnl_link_register - Register rtnl_link_ops with rtnetlink.
 EXPORT_SYMBOL_GPL (rtnl_link_register)
static void __rtnl_kill_links (struct net *net, struct rtnl_link_ops *ops)
void rtnl_kill_links (struct net *net, struct rtnl_link_ops *ops)
 EXPORT_SYMBOL_GPL (rtnl_kill_links)
void __rtnl_link_unregister (struct rtnl_link_ops *ops)
 __rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink.
 EXPORT_SYMBOL_GPL (__rtnl_link_unregister)
void rtnl_link_unregister (struct rtnl_link_ops *ops)
 rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink.
 EXPORT_SYMBOL_GPL (rtnl_link_unregister)
static struct rtnl_link_ops * rtnl_link_ops_get (const char *kind)
static size_t rtnl_link_get_size (const struct net_device *dev)
static int rtnl_link_fill (struct sk_buff *skb, const struct net_device *dev)
void __rta_fill (struct sk_buff *skb, int attrtype, int attrlen, const void *data)
int rtnetlink_send (struct sk_buff *skb, struct net *net, u32 pid, unsigned group, int echo)
int rtnl_unicast (struct sk_buff *skb, struct net *net, u32 pid)
int rtnl_notify (struct sk_buff *skb, struct net *net, u32 pid, u32 group, struct nlmsghdr *nlh, gfp_t flags)
void rtnl_set_sk_err (struct net *net, u32 group, int error)
int rtnetlink_put_metrics (struct sk_buff *skb, u32 *metrics)
int rtnl_put_cacheinfo (struct sk_buff *skb, struct dst_entry *dst, u32 id, u32 ts, u32 tsage, long expires, u32 error)
 EXPORT_SYMBOL_GPL (rtnl_put_cacheinfo)
static void set_operstate (struct net_device *dev, unsigned char transition)
static void copy_rtnl_link_stats (struct rtnl_link_stats *a, const struct net_device_stats *b)
static size_t if_nlmsg_size (const struct net_device *dev)
static int rtnl_fill_ifinfo (struct sk_buff *skb, struct net_device *dev, int type, u32 pid, u32 seq, u32 change, unsigned int flags)
static int rtnl_dump_ifinfo (struct sk_buff *skb, struct netlink_callback *cb)
static struct net * get_net_ns_by_pid (pid_t pid)
static int validate_linkmsg (struct net_device *dev, struct nlattr *tb[])
static int do_setlink (struct net_device *dev, struct ifinfomsg *ifm, struct nlattr **tb, char *ifname, int modified)
static int rtnl_setlink (struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
static int rtnl_dellink (struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
struct net_device * rtnl_create_link (struct net *net, char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[])
static int rtnl_newlink (struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
static int rtnl_getlink (struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
static int rtnl_dump_all (struct sk_buff *skb, struct netlink_callback *cb)
void rtmsg_ifinfo (int type, struct net_device *dev, unsigned change)
static int rtnetlink_rcv_msg (struct sk_buff *skb, struct nlmsghdr *nlh)
static void rtnetlink_rcv (struct sk_buff *skb)
static int rtnetlink_event (struct notifier_block *this, unsigned long event, void *ptr)
static int rtnetlink_net_init (struct net *net)
static void rtnetlink_net_exit (struct net *net)
void __init rtnetlink_init (void)
 EXPORT_SYMBOL (__rta_fill)
 EXPORT_SYMBOL (rtnetlink_put_metrics)
 EXPORT_SYMBOL (rtnl_lock)
 EXPORT_SYMBOL (rtnl_trylock)
 EXPORT_SYMBOL (rtnl_unlock)
 EXPORT_SYMBOL (rtnl_is_locked)
 EXPORT_SYMBOL (rtnl_unicast)
 EXPORT_SYMBOL (rtnl_notify)
 EXPORT_SYMBOL (rtnl_set_sk_err)
 EXPORT_SYMBOL (rtnl_create_link)
 EXPORT_SYMBOL (ifla_policy)

Variables

static struct rtnl_linkrtnl_msg_handlers [NPROTO]
static const int rtm_min [RTM_NR_FAMILIES]
static const int rta_max [RTM_NR_FAMILIES]
struct nla_policy ifla_policy [IFLA_MAX+1]
static struct nla_policy ifla_info_policy [IFLA_INFO_MAX+1]
static struct rtattr ** rta_buf
static int rtattr_max
static struct notifier_block rtnetlink_dev_notifier
static struct pernet_operations rtnetlink_net_ops


Function Documentation

void __rta_fill ( struct sk_buff *  skb,
int  attrtype,
int  attrlen,
const void *  data 
)

Definition at line 426 of file rtnetlink.c.

static void __rtnl_kill_links ( struct net *  net,
struct rtnl_link_ops *  ops 
) [static]

Definition at line 277 of file rtnetlink.c.

int __rtnl_link_register ( struct rtnl_link_ops *  ops  ) 

__rtnl_link_register - Register rtnl_link_ops with rtnetlink.

: struct rtnl_link_ops * to register

The caller must hold the rtnl_mutex. This function should be used by drivers that create devices during module initialization. It must be called before registering the devices.

Returns 0 on success or a negative error code.

Definition at line 248 of file rtnetlink.c.

void __rtnl_link_unregister ( struct rtnl_link_ops *  ops  ) 

__rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink.

: struct rtnl_link_ops * to unregister

The caller must hold the rtnl_mutex.

Definition at line 303 of file rtnetlink.c.

int __rtnl_register ( int  protocol,
int  msgtype,
rtnl_doit_func  doit,
rtnl_dumpit_func  dumpit 
)

Definition at line 145 of file rtnetlink.c.

void __rtnl_unlock ( void   ) 

Definition at line 69 of file rtnetlink.c.

static void copy_rtnl_link_stats ( struct rtnl_link_stats *  a,
const struct net_device_stats *  b 
) [static]

Definition at line 554 of file rtnetlink.c.

static DEFINE_MUTEX ( rtnl_mutex   )  [static]

static int do_setlink ( struct net_device *  dev,
struct ifinfomsg *  ifm,
struct nlattr **  tb,
char *  ifname,
int  modified 
) [static]

Definition at line 763 of file rtnetlink.c.

EXPORT_SYMBOL ( ifla_policy   ) 

EXPORT_SYMBOL ( rtnl_create_link   ) 

EXPORT_SYMBOL ( rtnl_set_sk_err   ) 

EXPORT_SYMBOL ( rtnl_notify   ) 

EXPORT_SYMBOL ( rtnl_unicast   ) 

EXPORT_SYMBOL ( rtnl_is_locked   ) 

EXPORT_SYMBOL ( rtnl_unlock   ) 

EXPORT_SYMBOL ( rtnl_trylock   ) 

EXPORT_SYMBOL ( rtnl_lock   ) 

EXPORT_SYMBOL ( rtnetlink_put_metrics   ) 

EXPORT_SYMBOL ( __rta_fill   ) 

EXPORT_SYMBOL_GPL ( rtnl_put_cacheinfo   ) 

EXPORT_SYMBOL_GPL ( rtnl_link_unregister   ) 

EXPORT_SYMBOL_GPL ( __rtnl_link_unregister   ) 

EXPORT_SYMBOL_GPL ( rtnl_kill_links   ) 

EXPORT_SYMBOL_GPL ( rtnl_link_register   ) 

EXPORT_SYMBOL_GPL ( __rtnl_link_register   ) 

EXPORT_SYMBOL_GPL ( rtnl_unregister_all   ) 

EXPORT_SYMBOL_GPL ( rtnl_unregister   ) 

EXPORT_SYMBOL_GPL ( rtnl_register   ) 

EXPORT_SYMBOL_GPL ( __rtnl_register   ) 

static struct net* get_net_ns_by_pid ( pid_t  pid  )  [static, read]

Definition at line 729 of file rtnetlink.c.

static size_t if_nlmsg_size ( const struct net_device *  dev  )  [inline, static]

Definition at line 586 of file rtnetlink.c.

static LIST_HEAD ( link_ops   )  [static]

static int rtm_msgindex ( int  msgtype  )  [inline, static]

Definition at line 92 of file rtnetlink.c.

void rtmsg_ifinfo ( int  type,
struct net_device *  dev,
unsigned  change 
)

Definition at line 1234 of file rtnetlink.c.

static int rtnetlink_event ( struct notifier_block *  this,
unsigned long  event,
void *  ptr 
) [static]

Definition at line 1346 of file rtnetlink.c.

void __init rtnetlink_init ( void   ) 

Definition at line 1398 of file rtnetlink.c.

static void rtnetlink_net_exit ( struct net *  net  )  [static]

Definition at line 1387 of file rtnetlink.c.

static int rtnetlink_net_init ( struct net *  net  )  [static]

Definition at line 1376 of file rtnetlink.c.

int rtnetlink_put_metrics ( struct sk_buff *  skb,
u32 *  metrics 
)

Definition at line 478 of file rtnetlink.c.

static void rtnetlink_rcv ( struct sk_buff *  skb  )  [static]

Definition at line 1339 of file rtnetlink.c.

static int rtnetlink_rcv_msg ( struct sk_buff *  skb,
struct nlmsghdr *  nlh 
) [static]

Definition at line 1266 of file rtnetlink.c.

int rtnetlink_send ( struct sk_buff *  skb,
struct net *  net,
u32  pid,
unsigned  group,
int  echo 
)

Definition at line 438 of file rtnetlink.c.

struct net_device* rtnl_create_link ( struct net *  net,
char *  ifname,
const struct rtnl_link_ops *  ops,
struct nlattr *  tb[] 
) [read]

Definition at line 992 of file rtnetlink.c.

static int rtnl_dellink ( struct sk_buff *  skb,
struct nlmsghdr *  nlh,
void *  arg 
) [static]

Definition at line 956 of file rtnetlink.c.

static int rtnl_dump_all ( struct sk_buff *  skb,
struct netlink_callback *  cb 
) [static]

Definition at line 1209 of file rtnetlink.c.

static int rtnl_dump_ifinfo ( struct sk_buff *  skb,
struct netlink_callback *  cb 
) [static]

Definition at line 685 of file rtnetlink.c.

static int rtnl_fill_ifinfo ( struct sk_buff *  skb,
struct net_device *  dev,
int  type,
u32  pid,
u32  seq,
u32  change,
unsigned int  flags 
) [static]

Definition at line 606 of file rtnetlink.c.

static rtnl_doit_func rtnl_get_doit ( int  protocol,
int  msgindex 
) [static]

Definition at line 106 of file rtnetlink.c.

static rtnl_dumpit_func rtnl_get_dumpit ( int  protocol,
int  msgindex 
) [static]

Definition at line 117 of file rtnetlink.c.

static int rtnl_getlink ( struct sk_buff *  skb,
struct nlmsghdr *  nlh,
void *  arg 
) [static]

Definition at line 1167 of file rtnetlink.c.

int rtnl_is_locked ( void   ) 

Definition at line 85 of file rtnetlink.c.

void rtnl_kill_links ( struct net *  net,
struct rtnl_link_ops *  ops 
)

Definition at line 289 of file rtnetlink.c.

static int rtnl_link_fill ( struct sk_buff *  skb,
const struct net_device *  dev 
) [static]

Definition at line 361 of file rtnetlink.c.

static size_t rtnl_link_get_size ( const struct net_device *  dev  )  [static]

Definition at line 339 of file rtnetlink.c.

static struct rtnl_link_ops* rtnl_link_ops_get ( const char *  kind  )  [static, read]

Definition at line 328 of file rtnetlink.c.

int rtnl_link_register ( struct rtnl_link_ops *  ops  ) 

rtnl_link_register - Register rtnl_link_ops with rtnetlink.

: struct rtnl_link_ops * to register

Returns 0 on success or a negative error code.

Definition at line 265 of file rtnetlink.c.

void rtnl_link_unregister ( struct rtnl_link_ops *  ops  ) 

rtnl_link_unregister - Unregister rtnl_link_ops from rtnetlink.

: struct rtnl_link_ops * to unregister

Definition at line 319 of file rtnetlink.c.

void rtnl_lock ( void   ) 

Definition at line 64 of file rtnetlink.c.

static int rtnl_newlink ( struct sk_buff *  skb,
struct nlmsghdr *  nlh,
void *  arg 
) [static]

Definition at line 1035 of file rtnetlink.c.

int rtnl_notify ( struct sk_buff *  skb,
struct net *  net,
u32  pid,
u32  group,
struct nlmsghdr *  nlh,
gfp_t  flags 
)

Definition at line 459 of file rtnetlink.c.

int rtnl_put_cacheinfo ( struct sk_buff *  skb,
struct dst_entry *  dst,
u32  id,
u32  ts,
u32  tsage,
long  expires,
u32  error 
)

Definition at line 506 of file rtnetlink.c.

void rtnl_register ( int  protocol,
int  msgtype,
rtnl_doit_func  doit,
rtnl_dumpit_func  dumpit 
)

rtnl_register - Register a rtnetlink message type

Identical to __rtnl_register() but panics on failure. This is useful as failure of this function is very unlikely, it can only happen due to lack of memory when allocating the chain to store all message handlers for a protocol. Meant for use in init functions where lack of memory implies no sense in continueing.

Definition at line 183 of file rtnetlink.c.

void rtnl_set_sk_err ( struct net *  net,
u32  group,
int  error 
)

Definition at line 471 of file rtnetlink.c.

static int rtnl_setlink ( struct sk_buff *  skb,
struct nlmsghdr *  nlh,
void *  arg 
) [static]

Definition at line 914 of file rtnetlink.c.

int rtnl_trylock ( void   ) 

Definition at line 80 of file rtnetlink.c.

int rtnl_unicast ( struct sk_buff *  skb,
struct net *  net,
u32  pid 
)

Definition at line 452 of file rtnetlink.c.

void rtnl_unlock ( void   ) 

Definition at line 74 of file rtnetlink.c.

int rtnl_unregister ( int  protocol,
int  msgtype 
)

Definition at line 201 of file rtnetlink.c.

void rtnl_unregister_all ( int  protocol  ) 

Definition at line 226 of file rtnetlink.c.

static void set_operstate ( struct net_device *  dev,
unsigned char  transition 
) [static]

Definition at line 527 of file rtnetlink.c.

static int validate_linkmsg ( struct net_device *  dev,
struct nlattr *  tb[] 
) [static]

Definition at line 748 of file rtnetlink.c.


Variable Documentation

struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] [static]

Initial value:

 {
        [IFLA_INFO_KIND]        = { .type = NLA_STRING },
        [IFLA_INFO_DATA]        = { .type = NLA_NESTED },
}

Definition at line 724 of file rtnetlink.c.

struct nla_policy ifla_policy[IFLA_MAX+1]

Initial value:

 {
        [IFLA_IFNAME]           = { .type = NLA_STRING, .len = IFNAMSIZ-1 },
        [IFLA_ADDRESS]          = { .type = NLA_BINARY, .len = MAX_ADDR_LEN },
        [IFLA_BROADCAST]        = { .type = NLA_BINARY, .len = MAX_ADDR_LEN },
        [IFLA_MAP]              = { .len = sizeof(struct rtnl_link_ifmap) },
        [IFLA_MTU]              = { .type = NLA_U32 },
        [IFLA_LINK]             = { .type = NLA_U32 },
        [IFLA_TXQLEN]           = { .type = NLA_U32 },
        [IFLA_WEIGHT]           = { .type = NLA_U32 },
        [IFLA_OPERSTATE]        = { .type = NLA_U8 },
        [IFLA_LINKMODE]         = { .type = NLA_U8 },
        [IFLA_LINKINFO]         = { .type = NLA_NESTED },
        [IFLA_NET_NS_PID]       = { .type = NLA_U32 },
        [IFLA_IFALIAS]          = { .type = NLA_STRING, .len = IFALIASZ-1 },
}

Definition at line 708 of file rtnetlink.c.

struct rtattr** rta_buf [static]

Definition at line 1261 of file rtnetlink.c.

const int rta_max[RTM_NR_FAMILIES] [static]

Initial value:

{
        [RTM_FAM(RTM_NEWLINK)]      = IFLA_MAX,
        [RTM_FAM(RTM_NEWADDR)]      = IFA_MAX,
        [RTM_FAM(RTM_NEWROUTE)]     = RTA_MAX,
        [RTM_FAM(RTM_NEWRULE)]      = FRA_MAX,
        [RTM_FAM(RTM_NEWQDISC)]     = TCA_MAX,
        [RTM_FAM(RTM_NEWTCLASS)]    = TCA_MAX,
        [RTM_FAM(RTM_NEWTFILTER)]   = TCA_MAX,
        [RTM_FAM(RTM_NEWACTION)]    = TCAA_MAX,
}

Definition at line 413 of file rtnetlink.c.

int rtattr_max [static]

Definition at line 1262 of file rtnetlink.c.

const int rtm_min[RTM_NR_FAMILIES] [static]

Initial value:

{
        [RTM_FAM(RTM_NEWLINK)]      = NLMSG_LENGTH(sizeof(struct ifinfomsg)),
        [RTM_FAM(RTM_NEWADDR)]      = NLMSG_LENGTH(sizeof(struct ifaddrmsg)),
        [RTM_FAM(RTM_NEWROUTE)]     = NLMSG_LENGTH(sizeof(struct rtmsg)),
        [RTM_FAM(RTM_NEWRULE)]      = NLMSG_LENGTH(sizeof(struct fib_rule_hdr)),
        [RTM_FAM(RTM_NEWQDISC)]     = NLMSG_LENGTH(sizeof(struct tcmsg)),
        [RTM_FAM(RTM_NEWTCLASS)]    = NLMSG_LENGTH(sizeof(struct tcmsg)),
        [RTM_FAM(RTM_NEWTFILTER)]   = NLMSG_LENGTH(sizeof(struct tcmsg)),
        [RTM_FAM(RTM_NEWACTION)]    = NLMSG_LENGTH(sizeof(struct tcamsg)),
        [RTM_FAM(RTM_GETMULTICAST)] = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
        [RTM_FAM(RTM_GETANYCAST)]   = NLMSG_LENGTH(sizeof(struct rtgenmsg)),
}

Definition at line 399 of file rtnetlink.c.

struct notifier_block rtnetlink_dev_notifier [static]

Initial value:

 {
        .notifier_call  = rtnetlink_event,
}

Definition at line 1371 of file rtnetlink.c.

struct pernet_operations rtnetlink_net_ops [static]

Initial value:

 {
        .init = rtnetlink_net_init,
        .exit = rtnetlink_net_exit,
}

Definition at line 1393 of file rtnetlink.c.

struct rtnl_link* rtnl_msg_handlers[NPROTO] [static]

Definition at line 90 of file rtnetlink.c.


Generated on Wed Apr 11 06:39:16 2012 for DDE - The L4 Device Driver Environment by  doxygen 1.5.6