Release 4.11 net/netlink/af_netlink.c
/*
* NETLINK Kernel-user communication protocol.
*
* Authors: Alan Cox <alan@lxorguk.ukuu.org.uk>
* Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
* Patrick McHardy <kaber@trash.net>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*
* Tue Jun 26 14:36:48 MEST 2001 Herbert "herp" Rosmanith
* added netlink_proto_exit
* Tue Jan 22 18:32:44 BRST 2002 Arnaldo C. de Melo <acme@conectiva.com.br>
* use nlk_sk, as sk->protinfo is on a diet 8)
* Fri Jul 22 19:51:12 MEST 2005 Harald Welte <laforge@gnumonks.org>
* - inc module use count of module that owns
* the kernel socket in case userspace opens
* socket of same protocol
* - remove all module support, since netlink is
* mandatory if CONFIG_NET=y these days
*/
#include <linux/module.h>
#include <linux/capability.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/signal.h>
#include <linux/sched.h>
#include <linux/errno.h>
#include <linux/string.h>
#include <linux/stat.h>
#include <linux/socket.h>
#include <linux/un.h>
#include <linux/fcntl.h>
#include <linux/termios.h>
#include <linux/sockios.h>
#include <linux/net.h>
#include <linux/fs.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/rtnetlink.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/notifier.h>
#include <linux/security.h>
#include <linux/jhash.h>
#include <linux/jiffies.h>
#include <linux/random.h>
#include <linux/bitops.h>
#include <linux/mm.h>
#include <linux/types.h>
#include <linux/audit.h>
#include <linux/mutex.h>
#include <linux/vmalloc.h>
#include <linux/if_arp.h>
#include <linux/rhashtable.h>
#include <asm/cacheflush.h>
#include <linux/hash.h>
#include <linux/genetlink.h>
#include <net/net_namespace.h>
#include <net/sock.h>
#include <net/scm.h>
#include <net/netlink.h>
#include "af_netlink.h"
struct listeners {
struct rcu_head rcu;
unsigned long masks[0];
};
/* state bits */
#define NETLINK_S_CONGESTED 0x0
/* flags */
#define NETLINK_F_KERNEL_SOCKET 0x1
#define NETLINK_F_RECV_PKTINFO 0x2
#define NETLINK_F_BROADCAST_SEND_ERROR 0x4
#define NETLINK_F_RECV_NO_ENOBUFS 0x8
#define NETLINK_F_LISTEN_ALL_NSID 0x10
#define NETLINK_F_CAP_ACK 0x20
static inline int netlink_is_kernel(struct sock *sk)
{
return nlk_sk(sk)->flags & NETLINK_F_KERNEL_SOCKET;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Denis V. Lunev | 21 | 95.45% | 1 | 50.00% |
Nicolas Dichtel | 1 | 4.55% | 1 | 50.00% |
Total | 22 | 100.00% | 2 | 100.00% |
struct netlink_table *nl_table __read_mostly;
EXPORT_SYMBOL_GPL(nl_table);
static DECLARE_WAIT_QUEUE_HEAD(nl_table_wait);
static struct lock_class_key nlk_cb_mutex_keys[MAX_LINKS];
static const char *const nlk_cb_mutex_key_strings[MAX_LINKS + 1] = {
"nlk_cb_mutex-ROUTE",
"nlk_cb_mutex-1",
"nlk_cb_mutex-USERSOCK",
"nlk_cb_mutex-FIREWALL",
"nlk_cb_mutex-SOCK_DIAG",
"nlk_cb_mutex-NFLOG",
"nlk_cb_mutex-XFRM",
"nlk_cb_mutex-SELINUX",
"nlk_cb_mutex-ISCSI",
"nlk_cb_mutex-AUDIT",
"nlk_cb_mutex-FIB_LOOKUP",
"nlk_cb_mutex-CONNECTOR",
"nlk_cb_mutex-NETFILTER",
"nlk_cb_mutex-IP6_FW",
"nlk_cb_mutex-DNRTMSG",
"nlk_cb_mutex-KOBJECT_UEVENT",
"nlk_cb_mutex-GENERIC",
"nlk_cb_mutex-17",
"nlk_cb_mutex-SCSITRANSPORT",
"nlk_cb_mutex-ECRYPTFS",
"nlk_cb_mutex-RDMA",
"nlk_cb_mutex-CRYPTO",
"nlk_cb_mutex-SMC",
"nlk_cb_mutex-23",
"nlk_cb_mutex-24",
"nlk_cb_mutex-25",
"nlk_cb_mutex-26",
"nlk_cb_mutex-27",
"nlk_cb_mutex-28",
"nlk_cb_mutex-29",
"nlk_cb_mutex-30",
"nlk_cb_mutex-31",
"nlk_cb_mutex-MAX_LINKS"
};
static int netlink_dump(struct sock *sk);
static void netlink_skb_destructor(struct sk_buff *skb);
/* nl_table locking explained:
* Lookup and traversal are protected with an RCU read-side lock. Insertion
* and removal are protected with per bucket lock while using RCU list
* modification primitives and may run in parallel to RCU protected lookups.
* Destruction of the Netlink socket may only occur *after* nl_table_lock has
* been acquired * either during or after the socket has been removed from
* the list and after an RCU grace period.
*/
DEFINE_RWLOCK(nl_table_lock);
EXPORT_SYMBOL_GPL(nl_table_lock);
static atomic_t nl_table_users = ATOMIC_INIT(0);
#define nl_deref_protected(X) rcu_dereference_protected(X, lockdep_is_held(&nl_table_lock));
static BLOCKING_NOTIFIER_HEAD(netlink_chain);
static DEFINE_SPINLOCK(netlink_tap_lock);
static struct list_head netlink_tap_all __read_mostly;
static const struct rhashtable_params netlink_rhashtable_params;
static inline u32 netlink_group_mask(u32 group)
{
return group ? 1 << (group - 1) : 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 22 | 95.65% | 1 | 50.00% |
Stephen Hemminger | 1 | 4.35% | 1 | 50.00% |
Total | 23 | 100.00% | 2 | 100.00% |
static struct sk_buff *netlink_to_full_skb(const struct sk_buff *skb,
gfp_t gfp_mask)
{
unsigned int len = skb_end_offset(skb);
struct sk_buff *new;
new = alloc_skb(len, gfp_mask);
if (new == NULL)
return NULL;
NETLINK_CB(new).portid = NETLINK_CB(skb).portid;
NETLINK_CB(new).dst_group = NETLINK_CB(skb).dst_group;
NETLINK_CB(new).creds = NETLINK_CB(skb).creds;
memcpy(skb_put(new, len), skb->data, len);
return new;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 110 | 100.00% | 1 | 100.00% |
Total | 110 | 100.00% | 1 | 100.00% |
int netlink_add_tap(struct netlink_tap *nt)
{
if (unlikely(nt->dev->type != ARPHRD_NETLINK))
return -EINVAL;
spin_lock(&netlink_tap_lock);
list_add_rcu(&nt->list, &netlink_tap_all);
spin_unlock(&netlink_tap_lock);
__module_get(nt->module);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 60 | 100.00% | 1 | 100.00% |
Total | 60 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL_GPL(netlink_add_tap);
static int __netlink_remove_tap(struct netlink_tap *nt)
{
bool found = false;
struct netlink_tap *tmp;
spin_lock(&netlink_tap_lock);
list_for_each_entry(tmp, &netlink_tap_all, list) {
if (nt == tmp) {
list_del_rcu(&nt->list);
found = true;
goto out;
}
}
pr_warn("__netlink_remove_tap: %p not found\n", nt);
out:
spin_unlock(&netlink_tap_lock);
if (found)
module_put(nt->module);
return found ? 0 : -ENODEV;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 93 | 98.94% | 1 | 50.00% |
Stephen Hemminger | 1 | 1.06% | 1 | 50.00% |
Total | 94 | 100.00% | 2 | 100.00% |
int netlink_remove_tap(struct netlink_tap *nt)
{
int ret;
ret = __netlink_remove_tap(nt);
synchronize_net();
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 26 | 100.00% | 1 | 100.00% |
Total | 26 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL_GPL(netlink_remove_tap);
static bool netlink_filter_tap(const struct sk_buff *skb)
{
struct sock *sk = skb->sk;
/* We take the more conservative approach and
* whitelist socket protocols that may pass.
*/
switch (sk->sk_protocol) {
case NETLINK_ROUTE:
case NETLINK_USERSOCK:
case NETLINK_SOCK_DIAG:
case NETLINK_NFLOG:
case NETLINK_XFRM:
case NETLINK_FIB_LOOKUP:
case NETLINK_NETFILTER:
case NETLINK_GENERIC:
return true;
}
return false;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 57 | 95.00% | 1 | 50.00% |
Varka Bhadram | 3 | 5.00% | 1 | 50.00% |
Total | 60 | 100.00% | 2 | 100.00% |
static int __netlink_deliver_tap_skb(struct sk_buff *skb,
struct net_device *dev)
{
struct sk_buff *nskb;
struct sock *sk = skb->sk;
int ret = -ENOMEM;
dev_hold(dev);
if (is_vmalloc_addr(skb->head))
nskb = netlink_to_full_skb(skb, GFP_ATOMIC);
else
nskb = skb_clone(skb, GFP_ATOMIC);
if (nskb) {
nskb->dev = dev;
nskb->protocol = htons((u16) sk->sk_protocol);
nskb->pkt_type = netlink_is_kernel(sk) ?
PACKET_KERNEL : PACKET_USER;
skb_reset_network_header(nskb);
ret = dev_queue_xmit(nskb);
if (unlikely(ret > 0))
ret = net_xmit_errno(ret);
}
dev_put(dev);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 144 | 100.00% | 5 | 100.00% |
Total | 144 | 100.00% | 5 | 100.00% |
static void __netlink_deliver_tap(struct sk_buff *skb)
{
int ret;
struct netlink_tap *tmp;
if (!netlink_filter_tap(skb))
return;
list_for_each_entry_rcu(tmp, &netlink_tap_all, list) {
ret = __netlink_deliver_tap_skb(skb, tmp->dev);
if (unlikely(ret))
break;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 57 | 100.00% | 2 | 100.00% |
Total | 57 | 100.00% | 2 | 100.00% |
static void netlink_deliver_tap(struct sk_buff *skb)
{
rcu_read_lock();
if (unlikely(!list_empty(&netlink_tap_all)))
__netlink_deliver_tap(skb);
rcu_read_unlock();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 34 | 100.00% | 1 | 100.00% |
Total | 34 | 100.00% | 1 | 100.00% |
static void netlink_deliver_tap_kernel(struct sock *dst, struct sock *src,
struct sk_buff *skb)
{
if (!(netlink_is_kernel(dst) && netlink_is_kernel(src)))
netlink_deliver_tap(skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Daniel Borkmann | 41 | 100.00% | 1 | 100.00% |
Total | 41 | 100.00% | 1 | 100.00% |
static void netlink_overrun(struct sock *sk)
{
struct netlink_sock *nlk = nlk_sk(sk);
if (!(nlk->flags & NETLINK_F_RECV_NO_ENOBUFS)) {
if (!test_and_set_bit(NETLINK_S_CONGESTED,
&nlk_sk(sk)->state)) {
sk->sk_err = ENOBUFS;
sk->sk_error_report(sk);
}
}
atomic_inc(&sk->sk_drops);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 71 | 97.26% | 1 | 50.00% |
Nicolas Dichtel | 2 | 2.74% | 1 | 50.00% |
Total | 73 | 100.00% | 2 | 100.00% |
static void netlink_rcv_wake(struct sock *sk)
{
struct netlink_sock *nlk = nlk_sk(sk);
if (skb_queue_empty(&sk->sk_receive_queue))
clear_bit(NETLINK_S_CONGESTED, &nlk->state);
if (!test_bit(NETLINK_S_CONGESTED, &nlk->state))
wake_up_interruptible(&nlk->wait);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 60 | 96.77% | 1 | 50.00% |
Nicolas Dichtel | 2 | 3.23% | 1 | 50.00% |
Total | 62 | 100.00% | 2 | 100.00% |
static void netlink_skb_destructor(struct sk_buff *skb)
{
if (is_vmalloc_addr(skb->head)) {
if (!skb->cloned ||
!atomic_dec_return(&(skb_shinfo(skb)->dataref)))
vfree(skb->head);
skb->head = NULL;
}
if (skb->sk != NULL)
sock_rfree(skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Westphal | 57 | 82.61% | 1 | 50.00% |
Patrick McHardy | 12 | 17.39% | 1 | 50.00% |
Total | 69 | 100.00% | 2 | 100.00% |
static void netlink_skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
{
WARN_ON(skb->sk != NULL);
skb->sk = sk;
skb->destructor = netlink_skb_destructor;
atomic_add(skb->truesize, &sk->sk_rmem_alloc);
sk_mem_charge(sk, skb->truesize);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Westphal | 40 | 68.97% | 1 | 33.33% |
Patrick McHardy | 18 | 31.03% | 2 | 66.67% |
Total | 58 | 100.00% | 3 | 100.00% |
static void netlink_sock_destruct(struct sock *sk)
{
struct netlink_sock *nlk = nlk_sk(sk);
if (nlk->cb_running) {
if (nlk->cb.done)
nlk->cb.done(&nlk->cb);
module_put(nlk->cb.module);
kfree_skb(nlk->cb.skb);
}
skb_queue_purge(&sk->sk_receive_queue);
if (!sock_flag(sk, SOCK_DEAD)) {
printk(KERN_ERR "Freeing alive netlink socket %p\n", sk);
return;
}
WARN_ON(atomic_read(&sk->sk_rmem_alloc));
WARN_ON(atomic_read(&sk->sk_wmem_alloc));
WARN_ON(nlk_sk(sk)->groups);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 37 | 28.91% | 2 | 16.67% |
Florian Westphal | 32 | 25.00% | 1 | 8.33% |
Patrick McHardy | 25 | 19.53% | 3 | 25.00% |
Herbert Xu | 21 | 16.41% | 1 | 8.33% |
Arnaldo Carvalho de Melo | 5 | 3.91% | 2 | 16.67% |
David S. Miller | 3 | 2.34% | 1 | 8.33% |
Ilpo Järvinen | 3 | 2.34% | 1 | 8.33% |
James Morris | 2 | 1.56% | 1 | 8.33% |
Total | 128 | 100.00% | 12 | 100.00% |
static void netlink_sock_destruct_work(struct work_struct *work)
{
struct netlink_sock *nlk = container_of(work, struct netlink_sock,
work);
sk_free(&nlk->sk);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 34 | 100.00% | 2 | 100.00% |
Total | 34 | 100.00% | 2 | 100.00% |
/* This lock without WQ_FLAG_EXCLUSIVE is good on UP and it is _very_ bad on
* SMP. Look, when several writers sleep and reader wakes them up, all but one
* immediately hit write lock and grab all the cpus. Exclusive sleep solves
* this, _but_ remember, it adds useless work on UP machines.
*/
void netlink_table_grab(void)
__acquires
(nl_table_lock)
{
might_sleep();
write_lock_irq(&nl_table_lock);
if (atomic_read(&nl_table_users)) {
DECLARE_WAITQUEUE(wait, current);
add_wait_queue_exclusive(&nl_table_wait, &wait);
for (;;) {
set_current_state(TASK_UNINTERRUPTIBLE);
if (atomic_read(&nl_table_users) == 0)
break;
write_unlock_irq(&nl_table_lock);
schedule();
write_lock_irq(&nl_table_lock);
}
__set_current_state(TASK_RUNNING);
remove_wait_queue(&nl_table_wait, &wait);
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 88 | 89.80% | 4 | 57.14% |
Eric Dumazet | 4 | 4.08% | 1 | 14.29% |
Arjan van de Ven | 3 | 3.06% | 1 | 14.29% |
Johannes Berg | 3 | 3.06% | 1 | 14.29% |
Total | 98 | 100.00% | 7 | 100.00% |
void netlink_table_ungrab(void)
__releases
(nl_table_lock)
{
write_unlock_irq(&nl_table_lock);
wake_up(&nl_table_wait);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 18 | 78.26% | 3 | 60.00% |
Eric Dumazet | 4 | 17.39% | 1 | 20.00% |
Arjan van de Ven | 1 | 4.35% | 1 | 20.00% |
Total | 23 | 100.00% | 5 | 100.00% |
static inline void
netlink_lock_table(void)
{
/* read_lock() synchronizes us to netlink_table_grab */
read_lock(&nl_table_lock);
atomic_inc(&nl_table_users);
read_unlock(&nl_table_lock);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 27 | 96.43% | 2 | 66.67% |
Patrick McHardy | 1 | 3.57% | 1 | 33.33% |
Total | 28 | 100.00% | 3 | 100.00% |
static inline void
netlink_unlock_table(void)
{
if (atomic_dec_and_test(&nl_table_users))
wake_up(&nl_table_wait);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 22 | 95.65% | 2 | 66.67% |
Patrick McHardy | 1 | 4.35% | 1 | 33.33% |
Total | 23 | 100.00% | 3 | 100.00% |
struct netlink_compare_arg
{
possible_net_t pnet;
u32 portid;
};
/* Doing sizeof directly may yield 4 extra bytes on 64-bit. */
#define netlink_compare_arg_len \
(offsetof(struct netlink_compare_arg, portid) + sizeof(u32))
static inline int netlink_compare(struct rhashtable_compare_arg *arg,
const void *ptr)
{
const struct netlink_compare_arg *x = arg->key;
const struct netlink_sock *nlk = ptr;
return nlk->portid != x->portid ||
!net_eq(sock_net(&nlk->sk), read_pnet(&x->pnet));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 26 | 40.62% | 2 | 50.00% |
Thomas Graf | 23 | 35.94% | 1 | 25.00% |
Gao Feng | 15 | 23.44% | 1 | 25.00% |
Total | 64 | 100.00% | 4 | 100.00% |
static void netlink_compare_arg_init(struct netlink_compare_arg *arg,
struct net *net, u32 portid)
{
memset(arg, 0, sizeof(*arg));
write_pnet(&arg->pnet, net);
arg->portid = portid;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 48 | 100.00% | 1 | 100.00% |
Total | 48 | 100.00% | 1 | 100.00% |
static struct sock *__netlink_lookup(struct netlink_table *table, u32 portid,
struct net *net)
{
struct netlink_compare_arg arg;
netlink_compare_arg_init(&arg, net, portid);
return rhashtable_lookup_fast(&table->hash, &arg,
netlink_rhashtable_params);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Graf | 33 | 67.35% | 2 | 50.00% |
Herbert Xu | 12 | 24.49% | 1 | 25.00% |
Gao Feng | 4 | 8.16% | 1 | 25.00% |
Total | 49 | 100.00% | 4 | 100.00% |
static int __netlink_insert(struct netlink_table *table, struct sock *sk)
{
struct netlink_compare_arg arg;
netlink_compare_arg_init(&arg, sock_net(sk), nlk_sk(sk)->portid);
return rhashtable_lookup_insert_key(&table->hash, &arg,
&nlk_sk(sk)->node,
netlink_rhashtable_params);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ying Xue | 40 | 66.67% | 1 | 25.00% |
Herbert Xu | 20 | 33.33% | 3 | 75.00% |
Total | 60 | 100.00% | 4 | 100.00% |
static struct sock *netlink_lookup(struct net *net, int protocol, u32 portid)
{
struct netlink_table *table = &nl_table[protocol];
struct sock *sk;
rcu_read_lock();
sk = __netlink_lookup(table, portid, net);
if (sk)
sock_hold(sk);
rcu_read_unlock();
return sk;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 21 | 32.81% | 1 | 12.50% |
Linus Torvalds (pre-git) | 17 | 26.56% | 2 | 25.00% |
Thomas Graf | 9 | 14.06% | 1 | 12.50% |
Herbert Xu | 8 | 12.50% | 1 | 12.50% |
Gao Feng | 4 | 6.25% | 1 | 12.50% |
Arnaldo Carvalho de Melo | 3 | 4.69% | 1 | 12.50% |
Eric W. Biedermann | 2 | 3.12% | 1 | 12.50% |
Total | 64 | 100.00% | 8 | 100.00% |
static const struct proto_ops netlink_ops;
static void
netlink_update_listeners(struct sock *sk)
{
struct netlink_table *tbl = &nl_table[sk->sk_protocol];
unsigned long mask;
unsigned int i;
struct listeners *listeners;
listeners = nl_deref_protected(tbl->listeners);
if (!listeners)
return;
for (i = 0; i < NLGRPLONGS(tbl->groups); i++) {
mask = 0;
sk_for_each_bound(sk, &tbl->mc_list) {
if (i < NLGRPLONGS(nlk_sk(sk)->ngroups))
mask |= nlk_sk(sk)->groups[i];
}
listeners->masks[i] = mask;
}
/* this function is only called with the netlink table "grabbed", which
* makes sure updates are visible before bind or setsockopt return. */
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 81 | 67.50% | 1 | 25.00% |
Eric Dumazet | 22 | 18.33% | 2 | 50.00% |
Johannes Berg | 17 | 14.17% | 1 | 25.00% |
Total | 120 | 100.00% | 4 | 100.00% |
static int netlink_insert(struct sock *sk, u32 portid)
{
struct netlink_table *table = &nl_table[sk->sk_protocol];
int err;
lock_sock(sk);
err = nlk_sk(sk)->portid == portid ? 0 : -EBUSY;
if (nlk_sk(sk)->bound)
goto err;
err = -ENOMEM;
if (BITS_PER_LONG > 32 &&
unlikely(atomic_read(&table->hash.nelems) >= UINT_MAX))
goto err;
nlk_sk(sk)->portid = portid;
sock_hold(sk);
err = __netlink_insert(table, sk);
if (err) {
/* In case the hashtable backend returns with -EBUSY
* from here, it must not escape to the caller.
*/
if (unlikely(err == -EBUSY))
err = -EOVERFLOW;
if (err == -EEXIST)
err = -EADDRINUSE;
sock_put(sk);
goto err;
}
/* We need to ensure that the socket is hashed and visible. */
smp_wmb();
nlk_sk(sk)->bound = portid;
err:
release_sock(sk);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 125 | 69.44% | 6 | 50.00% |
Thomas Graf | 24 | 13.33% | 2 | 16.67% |
Daniel Borkmann | 16 | 8.89% | 1 | 8.33% |
Ying Xue | 10 | 5.56% | 1 | 8.33% |
Gao Feng | 3 | 1.67% | 1 | 8.33% |
Eric W. Biedermann | 2 | 1.11% | 1 | 8.33% |
Total | 180 | 100.00% | 12 | 100.00% |
static void netlink_remove(struct sock *sk)
{
struct netlink_table *table;
table = &nl_table[sk->sk_protocol];
if (!rhashtable_remove_fast(&table->hash, &nlk_sk(sk)->node,
netlink_rhashtable_params)) {
WARN_ON(atomic_read(&sk->sk_refcnt) == 1);
__sock_put(sk);
}
netlink_table_grab();
if (nlk_sk(sk)->subscriptions) {
__sk_del_bind_node(sk);
netlink_update_listeners(sk);
}
if (sk->sk_protocol == NETLINK_GENERIC)
atomic_inc(&genl_sk_destructing_cnt);
netlink_table_ungrab();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Graf | 47 | 43.52% | 1 | 12.50% |
Herbert Xu | 33 | 30.56% | 2 | 25.00% |
Johannes Berg | 21 | 19.44% | 2 | 25.00% |
Linus Torvalds (pre-git) | 6 | 5.56% | 2 | 25.00% |
Patrick McHardy | 1 | 0.93% | 1 | 12.50% |
Total | 108 | 100.00% | 8 | 100.00% |
static struct proto netlink_proto = {
.name = "NETLINK",
.owner = THIS_MODULE,
.obj_size = sizeof(struct netlink_sock),
};
static int __netlink_create(struct net *net, struct socket *sock,
struct mutex *cb_mutex, int protocol,
int kern)
{
struct sock *sk;
struct netlink_sock *nlk;
sock->ops = &netlink_ops;
sk = sk_alloc(net, PF_NETLINK, GFP_KERNEL, &netlink_proto, kern);
if (!sk)
return -ENOMEM;
sock_init_data(sock, sk);
nlk = nlk_sk(sk);
if (cb_mutex) {
nlk->cb_mutex = cb_mutex;
} else {
nlk->cb_mutex = &nlk->cb_def_mutex;
mutex_init(nlk->cb_mutex);
lockdep_set_class_and_name(nlk->cb_mutex,
nlk_cb_mutex_keys + protocol,
nlk_cb_mutex_key_strings[protocol]);
}
init_waitqueue_head(&nlk->wait);
sk->sk_destruct = netlink_sock_destruct;
sk->sk_protocol = protocol;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 101 | 66.01% | 3 | 30.00% |
Linus Torvalds (pre-git) | 17 | 11.11% | 1 | 10.00% |
Herbert Xu | 16 | 10.46% | 1 | 10.00% |
Eric W. Biedermann | 12 | 7.84% | 2 | 20.00% |
David S. Miller | 4 | 2.61% | 1 | 10.00% |
Eric Dumazet | 2 | 1.31% | 1 | 10.00% |
Arnaldo Carvalho de Melo | 1 | 0.65% | 1 | 10.00% |
Total | 153 | 100.00% | 10 | 100.00% |
static int netlink_create(struct net *net, struct socket *sock, int protocol,
int kern)
{
struct module *module = NULL;
struct mutex *cb_mutex;
struct netlink_sock *nlk;
int (*bind)(struct net *net, int group);
void (*unbind)(struct net *net, int group);
int err = 0;
sock->state = SS_UNCONNECTED;
if (sock->type != SOCK_RAW && sock->type != SOCK_DGRAM)
return -ESOCKTNOSUPPORT;
if (protocol < 0 || protocol >= MAX_LINKS)
return -EPROTONOSUPPORT;
netlink_lock_table();
#ifdef CONFIG_MODULES
if (!nl_table[protocol].registered) {
netlink_unlock_table();
request_module("net-pf-%d-proto-%d", PF_NETLINK, protocol);
netlink_lock_table();
}
#endif
if (nl_table[protocol].registered &&
try_module_get(nl_table[protocol].module))
module = nl_table[protocol].module;
else
err = -EPROTONOSUPPORT;
cb_mutex = nl_table[protocol].cb_mutex;
bind = nl_table[protocol].bind;
unbind = nl_table[protocol].unbind;
netlink_unlock_table();
if (err < 0)
goto out;
err = __netlink_create(net, sock, cb_mutex, protocol, kern);
if (err < 0)
goto out_module;
local_bh_disable();
sock_prot_inuse_add(net, &netlink_proto, 1);
local_bh_enable();
nlk = nlk_sk(sock->sk);
nlk->module = module;
nlk->netlink_bind = bind;
nlk->netlink_unbind = unbind;
out:
return err;
out_module:
module_put(module);
goto out;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 115 | 38.08% | 5 | 26.32% |
Linus Torvalds (pre-git) | 50 | 16.56% | 2 | 10.53% |
Harald Welte | 32 | 10.60% | 1 | 5.26% |
Richard Guy Briggs | 26 | 8.61% | 1 | 5.26% |
Pablo Neira Ayuso | 24 | 7.95% | 1 | 5.26% |
Alexey Dobriyan | 15 | 4.97% | 1 | 5.26% |
Johannes Berg | 11 | 3.64% | 2 | 10.53% |
Eric Dumazet | 10 | 3.31% | 1 | 5.26% |
Eric W. Biedermann | 9 | 2.98% | 2 | 10.53% |
David S. Miller | 6 | 1.99% | 1 | 5.26% |
Eric Paris | 3 | 0.99% | 1 | 5.26% |
Arnaldo Carvalho de Melo | 1 | 0.33% | 1 | 5.26% |
Total | 302 | 100.00% | 19 | 100.00% |
static void deferred_put_nlk_sk(struct rcu_head *head)
{
struct netlink_sock *nlk = container_of(head, struct netlink_sock, rcu);
struct sock *sk = &nlk->sk;
if (!atomic_dec_and_test(&sk->sk_refcnt))
return;
if (nlk->cb_running && nlk->cb.done) {
INIT_WORK(&nlk->work, netlink_sock_destruct_work);
schedule_work(&nlk->work);
return;
}
sk_free(sk);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 53 | 61.63% | 1 | 50.00% |
Thomas Graf | 33 | 38.37% | 1 | 50.00% |
Total | 86 | 100.00% | 2 | 100.00% |
static int netlink_release(struct socket *sock)
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk;
if (!sk)
return 0;
netlink_remove(sk);
sock_orphan(sk);
nlk = nlk_sk(sk);
/*
* OK. Socket is unlinked, any packets that arrive now
* will be purged.
*/
/* must not acquire netlink_table_lock in any way again before unbind
* and notifying genetlink is done as otherwise it might deadlock
*/
if (nlk->netlink_unbind) {
int i;
for (i = 0; i < nlk->ngroups; i++)
if (test_bit(i, nlk->groups))
nlk->netlink_unbind(sock_net(sk), i + 1);
}
if (sk->sk_protocol == NETLINK_GENERIC &&
atomic_dec_return(&genl_sk_destructing_cnt) == 0)
wake_up(&genl_sk_destructing_waitq);
sock->sk = NULL;
wake_up_interruptible_all(&nlk->wait);
skb_queue_purge(&sk->sk_write_queue);
if (nlk->portid && nlk->bound) {
struct netlink_notify n = {
.net = sock_net(sk),
.protocol = sk->sk_protocol,
.portid = nlk->portid,
};
blocking_notifier_call_chain(&netlink_chain,
NETLINK_URELEASE, &n);
}
module_put(nlk->module);
if (netlink_is_kernel(sk)) {
netlink_table_grab();
BUG_ON(nl_table[sk->sk_protocol].registered == 0);
if (--nl_table[sk->sk_protocol].registered == 0) {
struct listeners *old;
old = nl_deref_protected(nl_table[sk->sk_protocol].listeners);
RCU_INIT_POINTER(nl_table[sk->sk_protocol].listeners, NULL);
kfree_rcu(old, rcu);
nl_table[sk->sk_protocol].module = NULL;
nl_table[sk->sk_protocol].bind = NULL;
nl_table[sk->sk_protocol].unbind = NULL;
nl_table[sk->sk_protocol].flags = 0;
nl_table[sk->sk_protocol].registered = 0;
}
netlink_table_ungrab();
}
kfree(nlk->groups);
nlk->groups = NULL;
local_bh_disable();
sock_prot_inuse_add(sock_net(sk), &netlink_proto, -1);
local_bh_enable();
call_rcu(&nlk->rcu, deferred_put_nlk_sk);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johannes Berg | 78 | 19.95% | 2 | 6.45% |
Linus Torvalds (pre-git) | 59 | 15.09% | 3 | 9.68% |
Eric Dumazet | 49 | 12.53% | 3 | 9.68% |
Patrick McHardy | 43 | 11.00% | 4 | 12.90% |
Denis V. Lunev | 38 | 9.72% | 3 | 9.68% |
James Morris | 27 | 6.91% | 1 | 3.23% |
Pablo Neira Ayuso | 22 | 5.63% | 1 | 3.23% |
Harald Welte | 18 | 4.60% | 1 | 3.23% |
David S. Miller | 14 | 3.58% | 2 | 6.45% |
Richard Guy Briggs | 11 | 2.81% | 1 | 3.23% |
Eric W. Biedermann | 8 | 2.05% | 2 | 6.45% |
Thomas Graf | 7 | 1.79% | 1 | 3.23% |
Dmitry Ivanov | 4 | 1.02% | 1 | 3.23% |
Arnaldo Carvalho de Melo | 4 | 1.02% | 2 | 6.45% |
Art Haas | 4 | 1.02% | 1 | 3.23% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 0.77% | 1 | 3.23% |
Herbert Xu | 1 | 0.26% | 1 | 3.23% |
Américo Wang | 1 | 0.26% | 1 | 3.23% |
Total | 391 | 100.00% | 31 | 100.00% |
static int netlink_autobind(struct socket *sock)
{
struct sock *sk = sock->sk;
struct net *net = sock_net(sk);
struct netlink_table *table = &nl_table[sk->sk_protocol];
s32 portid = task_tgid_vnr(current);
int err;
s32 rover = -4096;
bool ok;
retry:
cond_resched();
rcu_read_lock();
ok = !__netlink_lookup(table, portid, net);
rcu_read_unlock();
if (!ok) {
/* Bind collision, search negative portid values. */
if (rover == -4096)
/* rover will be in range [S32_MIN, -4097] */
rover = S32_MIN + prandom_u32_max(-4096 - S32_MIN);
else if (rover >= -4096)
rover = -4097;
portid = rover--;
goto retry;
}
err = netlink_insert(sk, portid);
if (err == -EADDRINUSE)
goto retry;
/* If 2 threads race to autobind, that is fine. */
if (err == -EBUSY)
err = 0;
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 69 | 40.83% | 3 | 21.43% |
Linus Torvalds (pre-git) | 61 | 36.09% | 2 | 14.29% |
David S. Miller | 14 | 8.28% | 2 | 14.29% |
Eric W. Biedermann | 12 | 7.10% | 2 | 14.29% |
Thomas Goff | 3 | 1.78% | 1 | 7.14% |
Thomas Graf | 3 | 1.78% | 1 | 7.14% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 1.78% | 1 | 7.14% |
Gao Feng | 3 | 1.78% | 1 | 7.14% |
Arnaldo Carvalho de Melo | 1 | 0.59% | 1 | 7.14% |
Total | 169 | 100.00% | 14 | 100.00% |
/**
* __netlink_ns_capable - General netlink message capability test
* @nsp: NETLINK_CB of the socket buffer holding a netlink command from userspace.
* @user_ns: The user namespace of the capability to use
* @cap: The capability to use
*
* Test to see if the opener of the socket we received the message
* from had when the netlink socket was created and the sender of the
* message has has the capability @cap in the user namespace @user_ns.
*/
bool __netlink_ns_capable(const struct netlink_skb_parms *nsp,
struct user_namespace *user_ns, int cap)
{
return ((nsp->flags & NETLINK_SKB_DST) ||
file_ns_capable(nsp->sk->sk_socket->file, user_ns, cap)) &&
ns_capable(user_ns, cap);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric W. Biedermann | 52 | 100.00% | 2 | 100.00% |
Total | 52 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(__netlink_ns_capable);
/**
* netlink_ns_capable - General netlink message capability test
* @skb: socket buffer holding a netlink command from userspace
* @user_ns: The user namespace of the capability to use
* @cap: The capability to use
*
* Test to see if the opener of the socket we received the message
* from had when the netlink socket was created and the sender of the
* message has has the capability @cap in the user namespace @user_ns.
*/
bool netlink_ns_capable(const struct sk_buff *skb,
struct user_namespace *user_ns, int cap)
{
return __netlink_ns_capable(&NETLINK_CB(skb), user_ns, cap);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric W. Biedermann | 33 | 100.00% | 1 | 100.00% |
Total | 33 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL(netlink_ns_capable);
/**
* netlink_capable - Netlink global message capability test
* @skb: socket buffer holding a netlink command from userspace
* @cap: The capability to use
*
* Test to see if the opener of the socket we received the message
* from had when the netlink socket was created and the sender of the
* message has has the capability @cap in all user namespaces.
*/
bool netlink_capable(const struct sk_buff *skb, int cap)
{
return netlink_ns_capable(skb, &init_user_ns, cap);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric W. Biedermann | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL(netlink_capable);
/**
* netlink_net_capable - Netlink network namespace message capability test
* @skb: socket buffer holding a netlink command from userspace
* @cap: The capability to use
*
* Test to see if the opener of the socket we received the message
* from had when the netlink socket was created and the sender of the
* message has has the capability @cap over the network namespace of
* the socket we received the message from.
*/
bool netlink_net_capable(const struct sk_buff *skb, int cap)
{
return netlink_ns_capable(skb, sock_net(skb->sk)->user_ns, cap);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric W. Biedermann | 31 | 100.00% | 1 | 100.00% |
Total | 31 | 100.00% | 1 | 100.00% |
EXPORT_SYMBOL(netlink_net_capable);
static inline int netlink_allowed(const struct socket *sock, unsigned int flag)
{
return (nl_table[sock->sk->sk_protocol].flags & flag) ||
ns_capable(sock_net(sock->sk)->user_ns, CAP_NET_ADMIN);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
James Morris | 30 | 63.83% | 1 | 12.50% |
Eric W. Biedermann | 11 | 23.40% | 2 | 25.00% |
Pablo Neira Ayuso | 3 | 6.38% | 2 | 25.00% |
Stephen Hemminger | 1 | 2.13% | 1 | 12.50% |
Herbert Xu | 1 | 2.13% | 1 | 12.50% |
Arnaldo Carvalho de Melo | 1 | 2.13% | 1 | 12.50% |
Total | 47 | 100.00% | 8 | 100.00% |
static void
netlink_update_subscriptions(struct sock *sk, unsigned int subscriptions)
{
struct netlink_sock *nlk = nlk_sk(sk);
if (nlk->subscriptions && !subscriptions)
__sk_del_bind_node(sk);
else if (!nlk->subscriptions && subscriptions)
sk_add_bind_node(sk, &nl_table[sk->sk_protocol].mc_list);
nlk->subscriptions = subscriptions;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 70 | 100.00% | 1 | 100.00% |
Total | 70 | 100.00% | 1 | 100.00% |
static int netlink_realloc_groups(struct sock *sk)
{
struct netlink_sock *nlk = nlk_sk(sk);
unsigned int groups;
unsigned long *new_groups;
int err = 0;
netlink_table_grab();
groups = nl_table[sk->sk_protocol].groups;
if (!nl_table[sk->sk_protocol].registered) {
err = -ENOENT;
goto out_unlock;
}
if (nlk->ngroups >= groups)
goto out_unlock;
new_groups = krealloc(nlk->groups, NLGRPSZ(groups), GFP_ATOMIC);
if (new_groups == NULL) {
err = -ENOMEM;
goto out_unlock;
}
memset((char *)new_groups + NLGRPSZ(nlk->ngroups), 0,
NLGRPSZ(groups) - NLGRPSZ(nlk->ngroups));
nlk->groups = new_groups;
nlk->ngroups = groups;
out_unlock:
netlink_table_ungrab();
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 88 | 53.66% | 1 | 50.00% |
Johannes Berg | 76 | 46.34% | 1 | 50.00% |
Total | 164 | 100.00% | 2 | 100.00% |
static void netlink_undo_bind(int group, long unsigned int groups,
struct sock *sk)
{
struct netlink_sock *nlk = nlk_sk(sk);
int undo;
if (!nlk->netlink_unbind)
return;
for (undo = 0; undo < group; undo++)
if (test_bit(undo, &groups))
nlk->netlink_unbind(sock_net(sk), undo + 1);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Richard Guy Briggs | 56 | 72.73% | 1 | 20.00% |
Johannes Berg | 18 | 23.38% | 2 | 40.00% |
Pablo Neira Ayuso | 2 | 2.60% | 1 | 20.00% |
Hiroaki SHIMODA | 1 | 1.30% | 1 | 20.00% |
Total | 77 | 100.00% | 5 | 100.00% |
static int netlink_bind(struct socket *sock, struct sockaddr *addr,
int addr_len)
{
struct sock *sk = sock->sk;
struct net *net = sock_net(sk);
struct netlink_sock *nlk = nlk_sk(sk);
struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
int err;
long unsigned int groups = nladdr->nl_groups;
bool bound;
if (addr_len < sizeof(struct sockaddr_nl))
return -EINVAL;
if (nladdr->nl_family != AF_NETLINK)
return -EINVAL;
/* Only superuser is allowed to listen multicasts */
if (groups) {
if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV))
return -EPERM;
err = netlink_realloc_groups(sk);
if (err)
return err;
}
bound = nlk->bound;
if (bound) {
/* Ensure nlk->portid is up-to-date. */
smp_rmb();
if (nladdr->nl_pid != nlk->portid)
return -EINVAL;
}
if (nlk->netlink_bind && groups) {
int group;
for (group = 0; group < nlk->ngroups; group++) {
if (!test_bit(group, &groups))
continue;
err = nlk->netlink_bind(net, group + 1);
if (!err)
continue;
netlink_undo_bind(group, groups, sk);
return err;
}
}
/* No need for barriers here as we return to user-space without
* using any of the bound attributes.
*/
if (!bound) {
err = nladdr->nl_pid ?
netlink_insert(sk, nladdr->nl_pid) :
netlink_autobind(sock);
if (err) {
netlink_undo_bind(nlk->ngroups, groups, sk);
return err;
}
}
if (!groups && (nlk->groups == NULL || !(u32)nlk->groups[0]))
return 0;
netlink_table_grab();
netlink_update_subscriptions(sk, nlk->subscriptions +
hweight32(groups) -
hweight32(nlk->groups[0]));
nlk->groups[0] = (nlk->groups[0] & ~0xffffffffUL) | groups;
netlink_update_listeners(sk);
netlink_table_ungrab();
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 99 | 26.54% | 3 | 13.04% |
Richard Guy Briggs | 94 | 25.20% | 1 | 4.35% |
Patrick McHardy | 67 | 17.96% | 3 | 13.04% |
Herbert Xu | 62 | 16.62% | 3 | 13.04% |
Hannes Frederic Sowa | 14 | 3.75% | 1 | 4.35% |
David S. Miller | 12 | 3.22% | 1 | 4.35% |
Eric W. Biedermann | 9 | 2.41% | 3 | 13.04% |
Johannes Berg | 7 | 1.88% | 3 | 13.04% |
Pablo Neira Ayuso | 3 | 0.80% | 2 | 8.70% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 0.80% | 1 | 4.35% |
James Morris | 2 | 0.54% | 1 | 4.35% |
Arnaldo Carvalho de Melo | 1 | 0.27% | 1 | 4.35% |
Total | 373 | 100.00% | 23 | 100.00% |
static int netlink_connect(struct socket *sock, struct sockaddr *addr,
int alen, int flags)
{
int err = 0;
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
if (alen < sizeof(addr->sa_family))
return -EINVAL;
if (addr->sa_family == AF_UNSPEC) {
sk->sk_state = NETLINK_UNCONNECTED;
nlk->dst_portid = 0;
nlk->dst_group = 0;
return 0;
}
if (addr->sa_family != AF_NETLINK)
return -EINVAL;
if ((nladdr->nl_groups || nladdr->nl_pid) &&
!netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
return -EPERM;
/* No need for barriers here as we return to user-space without
* using any of the bound attributes.
*/
if (!nlk->bound)
err = netlink_autobind(sock);
if (err == 0) {
sk->sk_state = NETLINK_CONNECTED;
nlk->dst_portid = nladdr->nl_pid;
nlk->dst_group = ffs(nladdr->nl_groups);
}
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 129 | 67.54% | 4 | 25.00% |
Changli Gao | 15 | 7.85% | 1 | 6.25% |
Herbert Xu | 15 | 7.85% | 3 | 18.75% |
David S. Miller | 14 | 7.33% | 1 | 6.25% |
Mike Pecovnik | 6 | 3.14% | 1 | 6.25% |
Patrick McHardy | 5 | 2.62% | 1 | 6.25% |
Eric W. Biedermann | 3 | 1.57% | 2 | 12.50% |
James Morris | 2 | 1.05% | 1 | 6.25% |
Arnaldo Carvalho de Melo | 1 | 0.52% | 1 | 6.25% |
Pablo Neira Ayuso | 1 | 0.52% | 1 | 6.25% |
Total | 191 | 100.00% | 16 | 100.00% |
static int netlink_getname(struct socket *sock, struct sockaddr *addr,
int *addr_len, int peer)
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
DECLARE_SOCKADDR(struct sockaddr_nl *, nladdr, addr);
nladdr->nl_family = AF_NETLINK;
nladdr->nl_pad = 0;
*addr_len = sizeof(*nladdr);
if (peer) {
nladdr->nl_pid = nlk->dst_portid;
nladdr->nl_groups = netlink_group_mask(nlk->dst_group);
} else {
nladdr->nl_pid = nlk->portid;
nladdr->nl_groups = nlk->groups ? nlk->groups[0] : 0;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 89 | 68.46% | 2 | 20.00% |
David S. Miller | 18 | 13.85% | 2 | 20.00% |
Patrick McHardy | 13 | 10.00% | 3 | 30.00% |
Cyrill V. Gorcunov | 7 | 5.38% | 1 | 10.00% |
Eric W. Biedermann | 2 | 1.54% | 1 | 10.00% |
Arnaldo Carvalho de Melo | 1 | 0.77% | 1 | 10.00% |
Total | 130 | 100.00% | 10 | 100.00% |
static int netlink_ioctl(struct socket *sock, unsigned int cmd,
unsigned long arg)
{
/* try to hand this ioctl down to the NIC drivers.
*/
return -ENOIOCTLCMD;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David Decotigny | 24 | 100.00% | 1 | 100.00% |
Total | 24 | 100.00% | 1 | 100.00% |
static struct sock *netlink_getsockbyportid(struct sock *ssk, u32 portid)
{
struct sock *sock;
struct netlink_sock *nlk;
sock = netlink_lookup(sock_net(ssk), ssk->sk_protocol, portid);
if (!sock)
return ERR_PTR(-ECONNREFUSED);
/* Don't bother queuing skb if kernel socket has no input function */
nlk = nlk_sk(sock);
if (sock->sk_state == NETLINK_CONNECTED &&
nlk->dst_portid != nlk_sk(ssk)->portid) {
sock_put(sock);
return ERR_PTR(-ECONNREFUSED);
}
return sock;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 34 | 34.69% | 1 | 7.69% |
Linus Torvalds (pre-git) | 21 | 21.43% | 3 | 23.08% |
Herbert Xu | 14 | 14.29% | 1 | 7.69% |
David S. Miller | 10 | 10.20% | 1 | 7.69% |
Eric W. Biedermann | 7 | 7.14% | 2 | 15.38% |
Denis V. Lunev | 4 | 4.08% | 1 | 7.69% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 3.06% | 1 | 7.69% |
James Morris | 3 | 3.06% | 1 | 7.69% |
Arnaldo Carvalho de Melo | 1 | 1.02% | 1 | 7.69% |
Adrian Bunk | 1 | 1.02% | 1 | 7.69% |
Total | 98 | 100.00% | 13 | 100.00% |
struct sock *netlink_getsockbyfilp(struct file *filp)
{
struct inode *inode = file_inode(filp);
struct sock *sock;
if (!S_ISSOCK(inode->i_mode))
return ERR_PTR(-ENOTSOCK);
sock = SOCKET_I(inode)->sk;
if (sock->sk_family != AF_NETLINK)
return ERR_PTR(-EINVAL);
sock_hold(sock);
return sock;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 56 | 73.68% | 1 | 16.67% |
Linus Torvalds (pre-git) | 10 | 13.16% | 3 | 50.00% |
Matthew Wilcox | 7 | 9.21% | 1 | 16.67% |
Al Viro | 3 | 3.95% | 1 | 16.67% |
Total | 76 | 100.00% | 6 | 100.00% |
static struct sk_buff *netlink_alloc_large_skb(unsigned int size,
int broadcast)
{
struct sk_buff *skb;
void *data;
if (size <= NLMSG_GOODSIZE || broadcast)
return alloc_skb(size, GFP_KERNEL);
size = SKB_DATA_ALIGN(size) +
SKB_DATA_ALIGN(sizeof(struct skb_shared_info));
data = vmalloc(size);
if (data == NULL)
return NULL;
skb = __build_skb(data, size);
if (skb == NULL)
vfree(data);
else
skb->destructor = netlink_skb_destructor;
return skb;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pablo Neira Ayuso | 101 | 99.02% | 2 | 66.67% |
Eric Dumazet | 1 | 0.98% | 1 | 33.33% |
Total | 102 | 100.00% | 3 | 100.00% |
/*
* Attach a skb to a netlink socket.
* The caller must hold a reference to the destination socket. On error, the
* reference is dropped. The skb is not send to the destination, just all
* all error checks are performed and memory in the queue is reserved.
* Return values:
* < 0: error. skb freed, reference to sock dropped.
* 0: continue
* 1: repeat lookup - reference dropped while waiting for socket memory.
*/
int netlink_attachskb(struct sock *sk, struct sk_buff *skb,
long *timeo, struct sock *ssk)
{
struct netlink_sock *nlk;
nlk = nlk_sk(sk);
if ((atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf ||
test_bit(NETLINK_S_CONGESTED, &nlk->state))) {
DECLARE_WAITQUEUE(wait, current);
if (!*timeo) {
if (!ssk || netlink_is_kernel(ssk))
netlink_overrun(sk);
sock_put(sk);
kfree_skb(skb);
return -EAGAIN;
}
__set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue(&nlk->wait, &wait);
if ((atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf ||
test_bit(NETLINK_S_CONGESTED, &nlk->state)) &&
!sock_flag(sk, SOCK_DEAD))
*timeo = schedule_timeout(*timeo);
__set_current_state(TASK_RUNNING);
remove_wait_queue(&nlk->wait, &wait);
sock_put(sk);
if (signal_pending(current)) {
kfree_skb(skb);
return sock_intr_errno(*timeo);
}
return 1;
}
netlink_skb_set_owner_r(skb, sk);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 148 | 66.67% | 7 | 36.84% |
Andrew Morton | 38 | 17.12% | 1 | 5.26% |
Alexey Kuznetsov | 10 | 4.50% | 1 | 5.26% |
Arnaldo Carvalho de Melo | 8 | 3.60% | 3 | 15.79% |
Patrick McHardy | 8 | 3.60% | 3 | 15.79% |
David S. Miller | 5 | 2.25% | 1 | 5.26% |
Nicolas Dichtel | 2 | 0.90% | 1 | 5.26% |
James Morris | 2 | 0.90% | 1 | 5.26% |
Denis V. Lunev | 1 | 0.45% | 1 | 5.26% |
Total | 222 | 100.00% | 19 | 100.00% |
static int __netlink_sendskb(struct sock *sk, struct sk_buff *skb)
{
int len = skb->len;
netlink_deliver_tap(skb);
skb_queue_tail(&sk->sk_receive_queue, skb);
sk->sk_data_ready(sk);
return len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 20 | 41.67% | 1 | 20.00% |
Linus Torvalds (pre-git) | 15 | 31.25% | 1 | 20.00% |
Eric Dumazet | 6 | 12.50% | 1 | 20.00% |
Daniel Borkmann | 5 | 10.42% | 1 | 20.00% |
Arnaldo Carvalho de Melo | 2 | 4.17% | 1 | 20.00% |
Total | 48 | 100.00% | 5 | 100.00% |
int netlink_sendskb(struct sock *sk, struct sk_buff *skb)
{
int len = __netlink_sendskb(sk, skb);
sock_put(sk);
return len;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric Dumazet | 24 | 72.73% | 1 | 25.00% |
Linus Torvalds (pre-git) | 8 | 24.24% | 2 | 50.00% |
Andrew Morton | 1 | 3.03% | 1 | 25.00% |
Total | 33 | 100.00% | 4 | 100.00% |
void netlink_detachskb(struct sock *sk, struct sk_buff *skb)
{
kfree_skb(skb);
sock_put(sk);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 25 | 100.00% | 1 | 100.00% |
Total | 25 | 100.00% | 1 | 100.00% |
static struct sk_buff *netlink_trim(struct sk_buff *skb, gfp_t allocation)
{
int delta;
WARN_ON(skb->sk != NULL);
delta = skb->end - skb->tail;
if (is_vmalloc_addr(skb->head) || delta * 2 < skb->truesize)
return skb;
if (skb_shared(skb)) {
struct sk_buff *nskb = skb_clone(skb, allocation);
if (!nskb)
return skb;
consume_skb(skb);
skb = nskb;
}
pskb_expand_head(skb, 0, -delta,
(allocation & ~__GFP_DIRECT_RECLAIM) |
__GFP_NOWARN | __GFP_NORETRY);
return skb;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 94 | 78.33% | 3 | 30.00% |
Eric Dumazet | 10 | 8.33% | 2 | 20.00% |
Pablo Neira Ayuso | 7 | 5.83% | 1 | 10.00% |
Patrick McHardy | 5 | 4.17% | 1 | 10.00% |
Arnaldo Carvalho de Melo | 2 | 1.67% | 1 | 10.00% |
David S. Miller | 1 | 0.83% | 1 | 10.00% |
Al Viro | 1 | 0.83% | 1 | 10.00% |
Total | 120 | 100.00% | 10 | 100.00% |
static int netlink_unicast_kernel(struct sock *sk, struct sk_buff *skb,
struct sock *ssk)
{
int ret;
struct netlink_sock *nlk = nlk_sk(sk);
ret = -ECONNREFUSED;
if (nlk->netlink_rcv != NULL) {
ret = skb->len;
netlink_skb_set_owner_r(skb, sk);
NETLINK_CB(skb).sk = ssk;
netlink_deliver_tap_kernel(sk, ssk, skb);
nlk->netlink_rcv(skb);
consume_skb(skb);
} else {
kfree_skb(skb);
}
sock_put(sk);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 45 | 41.67% | 1 | 20.00% |
Denis V. Lunev | 37 | 34.26% | 1 | 20.00% |
Florian Westphal | 16 | 14.81% | 1 | 20.00% |
Eric Dumazet | 5 | 4.63% | 1 | 20.00% |
Eric W. Biedermann | 5 | 4.63% | 1 | 20.00% |
Total | 108 | 100.00% | 5 | 100.00% |
int netlink_unicast(struct sock *ssk, struct sk_buff *skb,
u32 portid, int nonblock)
{
struct sock *sk;
int err;
long timeo;
skb = netlink_trim(skb, gfp_any());
timeo = sock_sndtimeo(ssk, nonblock);
retry:
sk = netlink_getsockbyportid(ssk, portid);
if (IS_ERR(sk)) {
kfree_skb(skb);
return PTR_ERR(sk);
}
if (netlink_is_kernel(sk))
return netlink_unicast_kernel(sk, skb, ssk);
if (sk_filter(sk, skb)) {
err = skb->len;
kfree_skb(skb);
sock_put(sk);
return err;
}
err = netlink_attachskb(sk, skb, &timeo, ssk);
if (err == 1)
goto retry;
if (err)
return err;
return netlink_sendskb(sk, skb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Florian Westphal | 94 | 56.29% | 1 | 11.11% |
Andrew Morton | 28 | 16.77% | 1 | 11.11% |
Patrick McHardy | 26 | 15.57% | 2 | 22.22% |
Stephen Hemminger | 11 | 6.59% | 1 | 11.11% |
Herbert Xu | 3 | 1.80% | 2 | 22.22% |
Denis V. Lunev | 3 | 1.80% | 1 | 11.11% |
Daniel Borkmann | 2 | 1.20% | 1 | 11.11% |
Total | 167 | 100.00% | 9 | 100.00% |
EXPORT_SYMBOL(netlink_unicast);
int netlink_has_listeners(struct sock *sk, unsigned int group)
{
int res = 0;
struct listeners *listeners;
BUG_ON(!netlink_is_kernel(sk));
rcu_read_lock();
listeners = rcu_dereference(nl_table[sk->sk_protocol].listeners);
if (listeners && group - 1 < nl_table[sk->sk_protocol].groups)
res = test_bit(group - 1, listeners->masks);
rcu_read_unlock();
return res;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 56 | 65.12% | 1 | 20.00% |
Johannes Berg | 23 | 26.74% | 1 | 20.00% |
Eric Dumazet | 6 | 6.98% | 2 | 40.00% |
Denis V. Lunev | 1 | 1.16% | 1 | 20.00% |
Total | 86 | 100.00% | 5 | 100.00% |
EXPORT_SYMBOL_GPL(netlink_has_listeners);
static int netlink_broadcast_deliver(struct sock *sk, struct sk_buff *skb)
{
struct netlink_sock *nlk = nlk_sk(sk);
if (atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf &&
!test_bit(NETLINK_S_CONGESTED, &nlk->state)) {
netlink_skb_set_owner_r(skb, sk);
__netlink_sendskb(sk, skb);
return atomic_read(&sk->sk_rmem_alloc) > (sk->sk_rcvbuf >> 1);
}
return -1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 57 | 64.77% | 2 | 20.00% |
Herbert Xu | 11 | 12.50% | 1 | 10.00% |
David S. Miller | 10 | 11.36% | 1 | 10.00% |
Stephen Hemminger | 4 | 4.55% | 1 | 10.00% |
Arnaldo Carvalho de Melo | 3 | 3.41% | 2 | 20.00% |
Patrick McHardy | 1 | 1.14% | 1 | 10.00% |
Nicolas Dichtel | 1 | 1.14% | 1 | 10.00% |
Eric Dumazet | 1 | 1.14% | 1 | 10.00% |
Total | 88 | 100.00% | 10 | 100.00% |
struct netlink_broadcast_data {
struct sock *exclude_sk;
struct net *net;
u32 portid;
u32 group;
int failure;
int delivery_failure;
int congested;
int delivered;
gfp_t allocation;
struct sk_buff *skb, *skb2;
int (*tx_filter)(struct sock *dsk, struct sk_buff *skb, void *data);
void *tx_data;
};
static void do_one_broadcast(struct sock *sk,
struct netlink_broadcast_data *p)
{
struct netlink_sock *nlk = nlk_sk(sk);
int val;
if (p->exclude_sk == sk)
return;
if (nlk->portid == p->portid || p->group - 1 >= nlk->ngroups ||
!test_bit(p->group - 1, nlk->groups))
return;
if (!net_eq(sock_net(sk), p->net)) {
if (!(nlk->flags & NETLINK_F_LISTEN_ALL_NSID))
return;
if (!peernet_has_id(sock_net(sk), p->net))
return;
if (!file_ns_capable(sk->sk_socket->file, p->net->user_ns,
CAP_NET_BROADCAST))
return;
}
if (p->failure) {
netlink_overrun(sk);
return;
}
sock_hold(sk);
if (p->skb2 == NULL) {
if (skb_shared(p->skb)) {
p->skb2 = skb_clone(p->skb, p->allocation);
} else {
p->skb2 = skb_get(p->skb);
/*
* skb ownership may have been set when
* delivered to a previous socket.
*/
skb_orphan(p->skb2);
}
}
if (p->skb2 == NULL) {
netlink_overrun(sk);
/* Clone failed. Notify ALL listeners. */
p->failure = 1;
if (nlk->flags & NETLINK_F_BROADCAST_SEND_ERROR)
p->delivery_failure = 1;
goto out;
}
if (p->tx_filter && p->tx_filter(sk, p->skb2, p->tx_data)) {
kfree_skb(p->skb2);
p->skb2 = NULL;
goto out;
}
if (sk_filter(sk, p->skb2)) {
kfree_skb(p->skb2);
p->skb2 = NULL;
goto out;
}
NETLINK_CB(p->skb2).nsid = peernet2id(sock_net(sk), p->net);
NETLINK_CB(p->skb2).nsid_is_set = true;
val = netlink_broadcast_deliver(sk, p->skb2);
if (val < 0) {
netlink_overrun(sk);
if (nlk->flags & NETLINK_F_BROADCAST_SEND_ERROR)
p->delivery_failure = 1;
} else {
p->congested |= val;
p->delivered = 1;
p->skb2 = NULL;
}
out:
sock_put(sk);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 105 | 24.94% | 2 | 9.09% |
Nicolas Dichtel | 99 | 23.52% | 2 | 9.09% |
Herbert Xu | 61 | 14.49% | 2 | 9.09% |
Eric W. Biedermann | 45 | 10.69% | 3 | 13.64% |
Pablo Neira Ayuso | 26 | 6.18% | 2 | 9.09% |
Stephen Hemminger | 24 | 5.70% | 1 | 4.55% |
David S. Miller | 22 | 5.23% | 3 | 13.64% |
Patrick McHardy | 18 | 4.28% | 2 | 9.09% |
Hideaki Yoshifuji / 吉藤英明 | 8 | 1.90% | 2 | 9.09% |
Tommy S. Christensen | 7 | 1.66% | 1 | 4.55% |
Rami Rosen | 5 | 1.19% | 1 | 4.55% |
Arnaldo Carvalho de Melo | 1 | 0.24% | 1 | 4.55% |
Total | 421 | 100.00% | 22 | 100.00% |
int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb, u32 portid,
u32 group, gfp_t allocation,
int (*filter)(struct sock *dsk, struct sk_buff *skb, void *data),
void *filter_data)
{
struct net *net = sock_net(ssk);
struct netlink_broadcast_data info;
struct sock *sk;
skb = netlink_trim(skb, allocation);
info.exclude_sk = ssk;
info.net = net;
info.portid = portid;
info.group = group;
info.failure = 0;
info.delivery_failure = 0;
info.congested = 0;
info.delivered = 0;
info.allocation = allocation;
info.skb = skb;
info.skb2 = NULL;
info.tx_filter = filter;
info.tx_data = filter_data;
/* While we sleep in clone, do not allow to change socket list */
netlink_lock_table();
sk_for_each_bound(sk, &nl_table[ssk->sk_protocol].mc_list)
do_one_broadcast(sk, &info);
consume_skb(skb);
netlink_unlock_table();
if (info.delivery_failure) {
kfree_skb(info.skb2);
return -ENOBUFS;
}
consume_skb(info.skb2);
if (info.delivered) {
if (info.congested && gfpflags_allow_blocking(allocation))
yield();
return 0;
}
return -ESRCH;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 128 | 54.24% | 3 | 18.75% |
Eric W. Biedermann | 54 | 22.88% | 3 | 18.75% |
Neil Horman | 16 | 6.78% | 1 | 6.25% |
Pablo Neira Ayuso | 14 | 5.93% | 1 | 6.25% |
Linus Torvalds (pre-git) | 8 | 3.39% | 3 | 18.75% |
David S. Miller | 5 | 2.12% | 1 | 6.25% |
Tommy S. Christensen | 4 | 1.69% | 1 | 6.25% |
Mel Gorman | 3 | 1.27% | 1 | 6.25% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 1.27% | 1 | 6.25% |
Al Viro | 1 | 0.42% | 1 | 6.25% |
Total | 236 | 100.00% | 16 | 100.00% |
EXPORT_SYMBOL(netlink_broadcast_filtered);
int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 portid,
u32 group, gfp_t allocation)
{
return netlink_broadcast_filtered(ssk, skb, portid, group, allocation,
NULL, NULL);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric W. Biedermann | 42 | 100.00% | 2 | 100.00% |
Total | 42 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(netlink_broadcast);
struct netlink_set_err_data {
struct sock *exclude_sk;
u32 portid;
u32 group;
int code;
};
static int do_one_set_err(struct sock *sk, struct netlink_set_err_data *p)
{
struct netlink_sock *nlk = nlk_sk(sk);
int ret = 0;
if (sk == p->exclude_sk)
goto out;
if (!net_eq(sock_net(sk), sock_net(p->exclude_sk)))
goto out;
if (nlk->portid == p->portid || p->group - 1 >= nlk->ngroups ||
!test_bit(p->group - 1, nlk->groups))
goto out;
if (p->code == ENOBUFS && nlk->flags & NETLINK_F_RECV_NO_ENOBUFS) {
ret = 1;
goto out;
}
sk->sk_err = p->code;
sk->sk_error_report(sk);
out:
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 72 | 50.35% | 1 | 10.00% |
Pablo Neira Ayuso | 28 | 19.58% | 1 | 10.00% |
Patrick McHardy | 18 | 12.59% | 2 | 20.00% |
Eric W. Biedermann | 12 | 8.39% | 2 | 20.00% |
Hideaki Yoshifuji / 吉藤英明 | 6 | 4.20% | 1 | 10.00% |
Octavian Purdila | 5 | 3.50% | 1 | 10.00% |
Nicolas Dichtel | 1 | 0.70% | 1 | 10.00% |
Arnaldo Carvalho de Melo | 1 | 0.70% | 1 | 10.00% |
Total | 143 | 100.00% | 10 | 100.00% |
/**
* netlink_set_err - report error to broadcast listeners
* @ssk: the kernel netlink socket, as returned by netlink_kernel_create()
* @portid: the PORTID of a process that we want to skip (if any)
* @group: the broadcast group that will notice the error
* @code: error code, must be negative (as usual in kernelspace)
*
* This function returns the number of broadcast listeners that have set the
* NETLINK_NO_ENOBUFS socket option.
*/
int netlink_set_err(struct sock *ssk, u32 portid, u32 group, int code)
{
struct netlink_set_err_data info;
struct sock *sk;
int ret = 0;
info.exclude_sk = ssk;
info.portid = portid;
info.group = group;
/* sk->sk_err wants a positive error value */
info.code = -code;
read_lock(&nl_table_lock);
sk_for_each_bound(sk, &nl_table[ssk->sk_protocol].mc_list)
ret += do_one_set_err(sk, &info);
read_unlock(&nl_table_lock);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 35 | 38.89% | 3 | 33.33% |
Herbert Xu | 32 | 35.56% | 1 | 11.11% |
Pablo Neira Ayuso | 13 | 14.44% | 2 | 22.22% |
Arnaldo Carvalho de Melo | 5 | 5.56% | 1 | 11.11% |
Eric W. Biedermann | 3 | 3.33% | 1 | 11.11% |
David S. Miller | 2 | 2.22% | 1 | 11.11% |
Total | 90 | 100.00% | 9 | 100.00% |
EXPORT_SYMBOL(netlink_set_err);
/* must be called with netlink table grabbed */
static void netlink_update_socket_mc(struct netlink_sock *nlk,
unsigned int group,
int is_new)
{
int old, new = !!is_new, subscriptions;
old = test_bit(group - 1, nlk->groups);
subscriptions = nlk->subscriptions - old + new;
if (new)
__set_bit(group - 1, nlk->groups);
else
__clear_bit(group - 1, nlk->groups);
netlink_update_subscriptions(&nlk->sk, subscriptions);
netlink_update_listeners(&nlk->sk);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johannes Berg | 97 | 100.00% | 1 | 100.00% |
Total | 97 | 100.00% | 1 | 100.00% |
static int netlink_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, unsigned int optlen)
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
unsigned int val = 0;
int err;
if (level != SOL_NETLINK)
return -ENOPROTOOPT;
if (optlen >= sizeof(int) &&
get_user(val, (unsigned int __user *)optval))
return -EFAULT;
switch (optname) {
case NETLINK_PKTINFO:
if (val)
nlk->flags |= NETLINK_F_RECV_PKTINFO;
else
nlk->flags &= ~NETLINK_F_RECV_PKTINFO;
err = 0;
break;
case NETLINK_ADD_MEMBERSHIP:
case NETLINK_DROP_MEMBERSHIP: {
if (!netlink_allowed(sock, NL_CFG_F_NONROOT_RECV))
return -EPERM;
err = netlink_realloc_groups(sk);
if (err)
return err;
if (!val || val - 1 >= nlk->ngroups)
return -EINVAL;
if (optname == NETLINK_ADD_MEMBERSHIP && nlk->netlink_bind) {
err = nlk->netlink_bind(sock_net(sk), val);
if (err)
return err;
}
netlink_table_grab();
netlink_update_socket_mc(nlk, val,
optname == NETLINK_ADD_MEMBERSHIP);
netlink_table_ungrab();
if (optname == NETLINK_DROP_MEMBERSHIP && nlk->netlink_unbind)
nlk->netlink_unbind(sock_net(sk), val);
err = 0;
break;
}
case NETLINK_BROADCAST_ERROR:
if (val)
nlk->flags |= NETLINK_F_BROADCAST_SEND_ERROR;
else
nlk->flags &= ~NETLINK_F_BROADCAST_SEND_ERROR;
err = 0;
break;
case NETLINK_NO_ENOBUFS:
if (val) {
nlk->flags |= NETLINK_F_RECV_NO_ENOBUFS;
clear_bit(NETLINK_S_CONGESTED, &nlk->state);
wake_up_interruptible(&nlk->wait);
} else {
nlk->flags &= ~NETLINK_F_RECV_NO_ENOBUFS;
}
err = 0;
break;
case NETLINK_LISTEN_ALL_NSID:
if (!ns_capable(sock_net(sk)->user_ns, CAP_NET_BROADCAST))
return -EPERM;
if (val)
nlk->flags |= NETLINK_F_LISTEN_ALL_NSID;
else
nlk->flags &= ~NETLINK_F_LISTEN_ALL_NSID;
err = 0;
break;
case NETLINK_CAP_ACK:
if (val)
nlk->flags |= NETLINK_F_CAP_ACK;
else
nlk->flags &= ~NETLINK_F_CAP_ACK;
err = 0;
break;
default:
err = -ENOPROTOOPT;
}
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 192 | 47.29% | 3 | 16.67% |
Pablo Neira Ayuso | 68 | 16.75% | 3 | 16.67% |
Nicolas Dichtel | 52 | 12.81% | 2 | 11.11% |
Richard Guy Briggs | 45 | 11.08% | 2 | 11.11% |
Christophe Ricard | 26 | 6.40% | 1 | 5.56% |
Johannes Berg | 19 | 4.68% | 4 | 22.22% |
Eric Dumazet | 2 | 0.49% | 1 | 5.56% |
David S. Miller | 1 | 0.25% | 1 | 5.56% |
Eric W. Biedermann | 1 | 0.25% | 1 | 5.56% |
Total | 406 | 100.00% | 18 | 100.00% |
static int netlink_getsockopt(struct socket *sock, int level, int optname,
char __user *optval, int __user *optlen)
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
int len, val, err;
if (level != SOL_NETLINK)
return -ENOPROTOOPT;
if (get_user(len, optlen))
return -EFAULT;
if (len < 0)
return -EINVAL;
switch (optname) {
case NETLINK_PKTINFO:
if (len < sizeof(int))
return -EINVAL;
len = sizeof(int);
val = nlk->flags & NETLINK_F_RECV_PKTINFO ? 1 : 0;
if (put_user(len, optlen) ||
put_user(val, optval))
return -EFAULT;
err = 0;
break;
case NETLINK_BROADCAST_ERROR:
if (len < sizeof(int))
return -EINVAL;
len = sizeof(int);
val = nlk->flags & NETLINK_F_BROADCAST_SEND_ERROR ? 1 : 0;
if (put_user(len, optlen) ||
put_user(val, optval))
return -EFAULT;
err = 0;
break;
case NETLINK_NO_ENOBUFS:
if (len < sizeof(int))
return -EINVAL;
len = sizeof(int);
val = nlk->flags & NETLINK_F_RECV_NO_ENOBUFS ? 1 : 0;
if (put_user(len, optlen) ||
put_user(val, optval))
return -EFAULT;
err = 0;
break;
case NETLINK_LIST_MEMBERSHIPS: {
int pos, idx, shift;
err = 0;
netlink_lock_table();
for (pos = 0; pos * 8 < nlk->ngroups; pos += sizeof(u32)) {
if (len - pos < sizeof(u32))
break;
idx = pos / sizeof(unsigned long);
shift = (pos % sizeof(unsigned long)) * 8;
if (put_user((u32)(nlk->groups[idx] >> shift),
(u32 __user *)(optval + pos))) {
err = -EFAULT;
break;
}
}
if (put_user(ALIGN(nlk->ngroups / 8, sizeof(u32)), optlen))
err = -EFAULT;
netlink_unlock_table();
break;
}
case NETLINK_CAP_ACK:
if (len < sizeof(int))
return -EINVAL;
len = sizeof(int);
val = nlk->flags & NETLINK_F_CAP_ACK ? 1 : 0;
if (put_user(len, optlen) ||
put_user(val, optval))
return -EFAULT;
err = 0;
break;
default:
err = -ENOPROTOOPT;
}
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 152 | 31.21% | 1 | 12.50% |
David Herrmann | 146 | 29.98% | 2 | 25.00% |
Pablo Neira Ayuso | 118 | 24.23% | 2 | 25.00% |
Christophe Ricard | 60 | 12.32% | 1 | 12.50% |
Heiko Carstens | 8 | 1.64% | 1 | 12.50% |
Nicolas Dichtel | 3 | 0.62% | 1 | 12.50% |
Total | 487 | 100.00% | 8 | 100.00% |
static void netlink_cmsg_recv_pktinfo(struct msghdr *msg, struct sk_buff *skb)
{
struct nl_pktinfo info;
info.group = NETLINK_CB(skb).dst_group;
put_cmsg(msg, SOL_NETLINK, NETLINK_PKTINFO, sizeof(info), &info);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 48 | 100.00% | 1 | 100.00% |
Total | 48 | 100.00% | 1 | 100.00% |
static void netlink_cmsg_listen_all_nsid(struct sock *sk, struct msghdr *msg,
struct sk_buff *skb)
{
if (!NETLINK_CB(skb).nsid_is_set)
return;
put_cmsg(msg, SOL_NETLINK, NETLINK_LISTEN_ALL_NSID, sizeof(int),
&NETLINK_CB(skb).nsid);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Nicolas Dichtel | 54 | 100.00% | 1 | 100.00% |
Total | 54 | 100.00% | 1 | 100.00% |
static int netlink_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
DECLARE_SOCKADDR(struct sockaddr_nl *, addr, msg->msg_name);
u32 dst_portid;
u32 dst_group;
struct sk_buff *skb;
int err;
struct scm_cookie scm;
u32 netlink_skb_flags = 0;
if (msg->msg_flags&MSG_OOB)
return -EOPNOTSUPP;
err = scm_send(sock, msg, &scm, true);
if (err < 0)
return err;
if (msg->msg_namelen) {
err = -EINVAL;
if (addr->nl_family != AF_NETLINK)
goto out;
dst_portid = addr->nl_pid;
dst_group = ffs(addr->nl_groups);
err = -EPERM;
if ((dst_group || dst_portid) &&
!netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
goto out;
netlink_skb_flags |= NETLINK_SKB_DST;
} else {
dst_portid = nlk->dst_portid;
dst_group = nlk->dst_group;
}
if (!nlk->bound) {
err = netlink_autobind(sock);
if (err)
goto out;
} else {
/* Ensure nlk is hashed and visible. */
smp_rmb();
}
err = -EMSGSIZE;
if (len > sk->sk_sndbuf - 32)
goto out;
err = -ENOBUFS;
skb = netlink_alloc_large_skb(len, dst_group);
if (skb == NULL)
goto out;
NETLINK_CB(skb).portid = nlk->portid;
NETLINK_CB(skb).dst_group = dst_group;
NETLINK_CB(skb).creds = scm.creds;
NETLINK_CB(skb).flags = netlink_skb_flags;
err = -EFAULT;
if (memcpy_from_msg(skb_put(skb, len), msg, len)) {
kfree_skb(skb);
goto out;
}
err = security_netlink_send(sk, skb);
if (err) {
kfree_skb(skb);
goto out;
}
if (dst_group) {
atomic_inc(&skb->users);
netlink_broadcast(sk, skb, dst_portid, dst_group, GFP_KERNEL);
}
err = netlink_unicast(sk, skb, dst_portid, msg->msg_flags&MSG_DONTWAIT);
out:
scm_destroy(&scm);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 249 | 60.58% | 4 | 14.29% |
Eric W. Biedermann | 53 | 12.90% | 5 | 17.86% |
James Morris | 27 | 6.57% | 4 | 14.29% |
Benjamin LaHaise | 26 | 6.33% | 1 | 3.57% |
Patrick McHardy | 12 | 2.92% | 1 | 3.57% |
David S. Miller | 12 | 2.92% | 1 | 3.57% |
Steffen Hurrle | 8 | 1.95% | 1 | 3.57% |
Herbert Xu | 8 | 1.95% | 1 | 3.57% |
Pablo Neira Ayuso | 7 | 1.70% | 4 | 14.29% |
Christoph Hellwig | 3 | 0.73% | 1 | 3.57% |
Arnaldo Carvalho de Melo | 2 | 0.49% | 2 | 7.14% |
Eric Dumazet | 2 | 0.49% | 1 | 3.57% |
Al Viro | 1 | 0.24% | 1 | 3.57% |
Stephen Hemminger | 1 | 0.24% | 1 | 3.57% |
Total | 411 | 100.00% | 28 | 100.00% |
static int netlink_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
int flags)
{
struct scm_cookie scm;
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
int noblock = flags&MSG_DONTWAIT;
size_t copied;
struct sk_buff *skb, *data_skb;
int err, ret;
if (flags&MSG_OOB)
return -EOPNOTSUPP;
copied = 0;
skb = skb_recv_datagram(sk, flags, noblock, &err);
if (skb == NULL)
goto out;
data_skb = skb;
#ifdef CONFIG_COMPAT_NETLINK_MESSAGES
if (unlikely(skb_shinfo(skb)->frag_list)) {
/*
* If this skb has a frag_list, then here that means that we
* will have to use the frag_list skb's data for compat tasks
* and the regular skb's data for normal (non-compat) tasks.
*
* If we need to send the compat skb, assign it to the
* 'data_skb' variable so that it will be used below for data
* copying. We keep 'skb' for everything else, including
* freeing both later.
*/
if (flags & MSG_CMSG_COMPAT)
data_skb = skb_shinfo(skb)->frag_list;
}
#endif
/* Record the max length of recvmsg() calls for future allocations */
nlk->max_recvmsg_len = max(nlk->max_recvmsg_len, len);
nlk->max_recvmsg_len = min_t(size_t, nlk->max_recvmsg_len,
SKB_WITH_OVERHEAD(32768));
copied = data_skb->len;
if (len < copied) {
msg->msg_flags |= MSG_TRUNC;
copied = len;
}
skb_reset_transport_header(data_skb);
err = skb_copy_datagram_msg(data_skb, 0, msg, copied);
if (msg->msg_name) {
DECLARE_SOCKADDR(struct sockaddr_nl *, addr, msg->msg_name);
addr->nl_family = AF_NETLINK;
addr->nl_pad = 0;
addr->nl_pid = NETLINK_CB(skb).portid;
addr->nl_groups = netlink_group_mask(NETLINK_CB(skb).dst_group);
msg->msg_namelen = sizeof(*addr);
}
if (nlk->flags & NETLINK_F_RECV_PKTINFO)
netlink_cmsg_recv_pktinfo(msg, skb);
if (nlk->flags & NETLINK_F_LISTEN_ALL_NSID)
netlink_cmsg_listen_all_nsid(sk, msg, skb);
memset(&scm, 0, sizeof(scm));
scm.creds = *NETLINK_CREDS(skb);
if (flags & MSG_TRUNC)
copied = data_skb->len;
skb_free_datagram(sk, skb);
if (nlk->cb_running &&
atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) {
ret = netlink_dump(sk);
if (ret) {
sk->sk_err = -ret;
sk->sk_error_report(sk);
}
}
scm_recv(sock, msg, &scm, flags);
out:
netlink_rcv_wake(sk);
return err ? : copied;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 217 | 50.00% | 2 | 7.41% |
Johannes Berg | 44 | 10.14% | 2 | 7.41% |
Eric Dumazet | 32 | 7.37% | 2 | 7.41% |
Benjamin LaHaise | 31 | 7.14% | 1 | 3.70% |
Patrick McHardy | 27 | 6.22% | 3 | 11.11% |
Andrey Vagin | 25 | 5.76% | 1 | 3.70% |
David S. Miller | 19 | 4.38% | 4 | 14.81% |
Nicolas Dichtel | 18 | 4.15% | 2 | 7.41% |
Steffen Hurrle | 7 | 1.61% | 1 | 3.70% |
Arnaldo Carvalho de Melo | 6 | 1.38% | 3 | 11.11% |
Stephen Hemminger | 2 | 0.46% | 1 | 3.70% |
Christoph Hellwig | 2 | 0.46% | 1 | 3.70% |
Eric W. Biedermann | 1 | 0.23% | 1 | 3.70% |
James Morris | 1 | 0.23% | 1 | 3.70% |
Ben Pfaff | 1 | 0.23% | 1 | 3.70% |
Pravin B Shelar | 1 | 0.23% | 1 | 3.70% |
Total | 434 | 100.00% | 27 | 100.00% |
static void netlink_data_ready(struct sock *sk)
{
BUG();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 11 | 78.57% | 2 | 50.00% |
Denis V. Lunev | 2 | 14.29% | 1 | 25.00% |
Stephen Hemminger | 1 | 7.14% | 1 | 25.00% |
Total | 14 | 100.00% | 4 | 100.00% |
/*
* We export these functions to other modules. They provide a
* complete set of kernel non-blocking support for message
* queueing.
*/
struct sock *
__netlink_kernel_create(struct net *net, int unit, struct module *module,
struct netlink_kernel_cfg *cfg)
{
struct socket *sock;
struct sock *sk;
struct netlink_sock *nlk;
struct listeners *listeners = NULL;
struct mutex *cb_mutex = cfg ? cfg->cb_mutex : NULL;
unsigned int groups;
BUG_ON(!nl_table);
if (unit < 0 || unit >= MAX_LINKS)
return NULL;
if (sock_create_lite(PF_NETLINK, SOCK_DGRAM, unit, &sock))
return NULL;
if (__netlink_create(net, sock, cb_mutex, unit, 1) < 0)
goto out_sock_release_nosk;
sk = sock->sk;
if (!cfg || cfg->groups < 32)
groups = 32;
else
groups = cfg->groups;
listeners = kzalloc(sizeof(*listeners) + NLGRPSZ(groups), GFP_KERNEL);
if (!listeners)
goto out_sock_release;
sk->sk_data_ready = netlink_data_ready;
if (cfg && cfg->input)
nlk_sk(sk)->netlink_rcv = cfg->input;
if (netlink_insert(sk, 0))
goto out_sock_release;
nlk = nlk_sk(sk);
nlk->flags |= NETLINK_F_KERNEL_SOCKET;
netlink_table_grab();
if (!nl_table[unit].registered) {
nl_table[unit].groups = groups;
rcu_assign_pointer(nl_table[unit].listeners, listeners);
nl_table[unit].cb_mutex = cb_mutex;
nl_table[unit].module = module;
if (cfg) {
nl_table[unit].bind = cfg->bind;
nl_table[unit].unbind = cfg->unbind;
nl_table[unit].flags = cfg->flags;
if (cfg->compare)
nl_table[unit].compare = cfg->compare;
}
nl_table[unit].registered = 1;
} else {
kfree(listeners);
nl_table[unit].registered++;
}
netlink_table_ungrab();
return sk;
out_sock_release:
kfree(listeners);
netlink_kernel_release(sk);
return NULL;
out_sock_release_nosk:
sock_release(sock);
return NULL;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Patrick McHardy | 102 | 26.15% | 6 | 18.18% |
Linus Torvalds (pre-git) | 72 | 18.46% | 2 | 6.06% |
Pablo Neira Ayuso | 68 | 17.44% | 4 | 12.12% |
Harald Welte | 21 | 5.38% | 1 | 3.03% |
Eric W. Biedermann | 21 | 5.38% | 4 | 12.12% |
Gao Feng | 17 | 4.36% | 1 | 3.03% |
Pavel Emelyanov | 16 | 4.10% | 1 | 3.03% |
Hiroaki SHIMODA | 11 | 2.82% | 1 | 3.03% |
Eric Dumazet | 11 | 2.82% | 1 | 3.03% |
Herbert Xu | 11 | 2.82% | 2 | 6.06% |
Denis V. Lunev | 10 | 2.56% | 3 | 9.09% |
James Morris | 10 | 2.56% | 1 | 3.03% |
Jesper Juhl | 8 | 2.05% | 1 | 3.03% |
Akinobu Mita | 4 | 1.03% | 1 | 3.03% |
Johannes Berg | 3 | 0.77% | 1 | 3.03% |
David S. Miller | 3 | 0.77% | 1 | 3.03% |
Arnaldo Carvalho de Melo | 1 | 0.26% | 1 | 3.03% |
Nicolas Dichtel | 1 | 0.26% | 1 | 3.03% |
Total | 390 | 100.00% | 33 | 100.00% |
EXPORT_SYMBOL(__netlink_kernel_create);
void
netlink_kernel_release(struct sock *sk)
{
if (sk == NULL || sk->sk_socket == NULL)
return;
sock_release(sk->sk_socket);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric W. Biedermann | 16 | 53.33% | 1 | 33.33% |
Denis V. Lunev | 14 | 46.67% | 2 | 66.67% |
Total | 30 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL(netlink_kernel_release);
int __netlink_change_ngroups(struct sock *sk, unsigned int groups)
{
struct listeners *new, *old;
struct netlink_table *tbl = &nl_table[sk->sk_protocol];
if (groups < 32)
groups = 32;
if (NLGRPSZ(tbl->groups) < NLGRPSZ(groups)) {
new = kzalloc(sizeof(*new) + NLGRPSZ(groups), GFP_ATOMIC);
if (!new)
return -ENOMEM;
old = nl_deref_protected(tbl->listeners);
memcpy(new->masks, old->masks, NLGRPSZ(tbl->groups));
rcu_assign_pointer(tbl->listeners, new);
kfree_rcu(old, rcu);
}
tbl->groups = groups;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johannes Berg | 118 | 84.29% | 3 | 50.00% |
Eric Dumazet | 20 | 14.29% | 2 | 33.33% |
Lai Jiangshan | 2 | 1.43% | 1 | 16.67% |
Total | 140 | 100.00% | 6 | 100.00% |
/**
* netlink_change_ngroups - change number of multicast groups
*
* This changes the number of multicast groups that are available
* on a certain netlink family. Note that it is not possible to
* change the number of groups to below 32. Also note that it does
* not implicitly call netlink_clear_multicast_users() when the
* number of groups is reduced.
*
* @sk: The kernel netlink socket, as returned by netlink_kernel_create().
* @groups: The new number of groups.
*/
int netlink_change_ngroups(struct sock *sk, unsigned int groups)
{
int err;
netlink_table_grab();
err = __netlink_change_ngroups(sk, groups);
netlink_table_ungrab();
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johannes Berg | 35 | 100.00% | 2 | 100.00% |
Total | 35 | 100.00% | 2 | 100.00% |
void __netlink_clear_multicast_users(struct sock *ksk, unsigned int group)
{
struct sock *sk;
struct netlink_table *tbl = &nl_table[ksk->sk_protocol];
sk_for_each_bound(sk, &tbl->mc_list)
netlink_update_socket_mc(nlk_sk(sk), group, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Johannes Berg | 50 | 100.00% | 2 | 100.00% |
Total | 50 | 100.00% | 2 | 100.00% |
struct nlmsghdr *
__nlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, int type, int len, int flags)
{
struct nlmsghdr *nlh;
int size = nlmsg_msg_size(len);
nlh = (struct nlmsghdr *)skb_put(skb, NLMSG_ALIGN(size));
nlh->nlmsg_type = type;
nlh->nlmsg_len = size;
nlh->nlmsg_flags = flags;
nlh->nlmsg_pid = portid;
nlh->nlmsg_seq = seq;
if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0)
memset(nlmsg_data(nlh) + len, 0, NLMSG_ALIGN(size) - size);
return nlh;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Denys Vlasenko | 122 | 96.83% | 1 | 33.33% |
Eric W. Biedermann | 2 | 1.59% | 1 | 33.33% |
Hong Zhi Guo | 2 | 1.59% | 1 | 33.33% |
Total | 126 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL(__nlmsg_put);
/*
* It looks a bit ugly.
* It would be better to create kernel thread.
*/
static int netlink_dump(struct sock *sk)
{
struct netlink_sock *nlk = nlk_sk(sk);
struct netlink_callback *cb;
struct sk_buff *skb = NULL;
struct nlmsghdr *nlh;
struct module *module;
int len, err = -ENOBUFS;
int alloc_min_size;
int alloc_size;
mutex_lock(nlk->cb_mutex);
if (!nlk->cb_running) {
err = -EINVAL;
goto errout_skb;
}
if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf)
goto errout_skb;
/* NLMSG_GOODSIZE is small to avoid high order allocations being
* required, but it makes sense to _attempt_ a 16K bytes allocation
* to reduce number of system calls on dump operations, if user
* ever provided a big enough buffer.
*/
cb = &nlk->cb;
alloc_min_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);
if (alloc_min_size < nlk->max_recvmsg_len) {
alloc_size = nlk->max_recvmsg_len;
skb = alloc_skb(alloc_size,
(GFP_KERNEL & ~__GFP_DIRECT_RECLAIM) |
__GFP_NOWARN | __GFP_NORETRY);
}
if (!skb) {
alloc_size = alloc_min_size;
skb = alloc_skb(alloc_size, GFP_KERNEL);
}
if (!skb)
goto errout_skb;
/* Trim skb to allocated size. User is expected to provide buffer as
* large as max(min_dump_alloc, 16KiB (mac_recvmsg_len capped at
* netlink_recvmsg())). dump will pack as many smaller messages as
* could fit within the allocated skb. skb is typically allocated
* with larger space than required (could be as much as near 2x the
* requested size with align to next power of 2 approach). Allowing
* dump to use the excess space makes it difficult for a user to have a
* reasonable static buffer based on the expected largest dump of a
* single netdev. The outcome is MSG_TRUNC error.
*/
skb_reserve(skb, skb_tailroom(skb) - alloc_size);
netlink_skb_set_owner_r(skb, sk);
len = cb->dump(skb, cb);
if (len > 0) {
mutex_unlock(nlk->cb_mutex);
if (sk_filter(sk, skb))
kfree_skb(skb);
else
__netlink_sendskb(sk, skb);
return 0;
}
nlh = nlmsg_put_answer(skb, cb, NLMSG_DONE, sizeof(len), NLM_F_MULTI);
if (!nlh)
goto errout_skb;
nl_dump_check_consistent(cb, nlh);
memcpy(nlmsg_data(nlh), &len, sizeof(len));
if (sk_filter(sk, skb))
kfree_skb(skb);
else
__netlink_sendskb(sk, skb);
if (cb->done)
cb->done(cb);
nlk->cb_running = false;
module = cb->module;
skb = cb->skb;
mutex_unlock(nlk->cb_mutex);
module_put(module);
consume_skb(skb);
return 0;
errout_skb:
mutex_unlock(nlk->cb_mutex);
kfree_skb(skb);
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 127 | 32.48% | 2 | 9.52% |
Arad, Ronen | 50 | 12.79% | 1 | 4.76% |
Thomas Graf | 45 | 11.51% | 3 | 14.29% |
Eric Dumazet | 33 | 8.44% | 3 | 14.29% |
Patrick McHardy | 32 | 8.18% | 2 | 9.52% |
Stephen Hemminger | 30 | 7.67% | 1 | 4.76% |
Greg Rose | 20 | 5.12% | 1 | 4.76% |
Herbert Xu | 17 | 4.35% | 1 | 4.76% |
David S. Miller | 13 | 3.32% | 1 | 4.76% |
Pravin B Shelar | 8 | 2.05% | 1 | 4.76% |
Johannes Berg | 7 | 1.79% | 1 | 4.76% |
Gao Feng | 5 | 1.28% | 1 | 4.76% |
Florian Westphal | 2 | 0.51% | 1 | 4.76% |
Dan Carpenter | 1 | 0.26% | 1 | 4.76% |
Arnaldo Carvalho de Melo | 1 | 0.26% | 1 | 4.76% |
Total | 391 | 100.00% | 21 | 100.00% |
int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
const struct nlmsghdr *nlh,
struct netlink_dump_control *control)
{
struct netlink_callback *cb;
struct sock *sk;
struct netlink_sock *nlk;
int ret;
atomic_inc(&skb->users);
sk = netlink_lookup(sock_net(ssk), ssk->sk_protocol, NETLINK_CB(skb).portid);
if (sk == NULL) {
ret = -ECONNREFUSED;
goto error_free;
}
nlk = nlk_sk(sk);
mutex_lock(nlk->cb_mutex);
/* A dump is in progress... */
if (nlk->cb_running) {
ret = -EBUSY;
goto error_unlock;
}
/* add reference of module which cb->dump belongs to */
if (!try_module_get(control->module)) {
ret = -EPROTONOSUPPORT;
goto error_unlock;
}
cb = &nlk->cb;
memset(cb, 0, sizeof(*cb));
cb->start = control->start;
cb->dump = control->dump;
cb->done = control->done;
cb->nlh = nlh;
cb->data = control->data;
cb->module = control->module;
cb->min_dump_alloc = control->min_dump_alloc;
cb->skb = skb;
nlk->cb_running = true;
mutex_unlock(nlk->cb_mutex);
if (cb->start)
cb->start(cb);
ret = netlink_dump(sk);
sock_put(sk);
if (ret)
return ret;
/* We successfully started a dump, by returning -EINTR we
* signal not to send ACK even if it was requested.
*/
return -EINTR;
error_unlock:
sock_put(sk);
mutex_unlock(nlk->cb_mutex);
error_free:
kfree_skb(skb);
return ret;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Pravin B Shelar | 106 | 35.93% | 1 | 5.56% |
Linus Torvalds (pre-git) | 83 | 28.14% | 2 | 11.11% |
Gao Feng | 26 | 8.81% | 1 | 5.56% |
Tom Herbert | 21 | 7.12% | 1 | 5.56% |
David S. Miller | 15 | 5.08% | 1 | 5.56% |
Patrick McHardy | 13 | 4.41% | 3 | 16.67% |
Andrey Vagin | 12 | 4.07% | 1 | 5.56% |
Herbert Xu | 5 | 1.69% | 1 | 5.56% |
Eric W. Biedermann | 4 | 1.36% | 2 | 11.11% |
Denis V. Lunev | 3 | 1.02% | 1 | 5.56% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 1.02% | 1 | 5.56% |
Pablo Neira Ayuso | 2 | 0.68% | 1 | 5.56% |
Arnaldo Carvalho de Melo | 2 | 0.68% | 2 | 11.11% |
Total | 295 | 100.00% | 18 | 100.00% |
EXPORT_SYMBOL(__netlink_dump_start);
void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err)
{
struct sk_buff *skb;
struct nlmsghdr *rep;
struct nlmsgerr *errmsg;
size_t payload = sizeof(*errmsg);
struct netlink_sock *nlk = nlk_sk(NETLINK_CB(in_skb).sk);
/* Error messages get the original request appened, unless the user
* requests to cap the error message.
*/
if (!(nlk->flags & NETLINK_F_CAP_ACK) && err)
payload += nlmsg_len(nlh);
skb = nlmsg_new(payload, GFP_KERNEL);
if (!skb) {
struct sock *sk;
sk = netlink_lookup(sock_net(in_skb->sk),
in_skb->sk->sk_protocol,
NETLINK_CB(in_skb).portid);
if (sk) {
sk->sk_err = ENOBUFS;
sk->sk_error_report(sk);
sock_put(sk);
}
return;
}
rep = __nlmsg_put(skb, NETLINK_CB(in_skb).portid, nlh->nlmsg_seq,
NLMSG_ERROR, payload, 0);
errmsg = nlmsg_data(rep);
errmsg->error = err;
memcpy(&errmsg->msg, nlh, payload > sizeof(*errmsg) ? nlh->nlmsg_len : sizeof(*nlh));
netlink_unicast(in_skb->sk, skb, NETLINK_CB(in_skb).portid, MSG_DONTWAIT);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 118 | 50.86% | 2 | 16.67% |
David S. Miller | 47 | 20.26% | 1 | 8.33% |
Christophe Ricard | 32 | 13.79% | 1 | 8.33% |
Thomas Graf | 22 | 9.48% | 3 | 25.00% |
Eric W. Biedermann | 8 | 3.45% | 2 | 16.67% |
Hideaki Yoshifuji / 吉藤英明 | 3 | 1.29% | 1 | 8.33% |
John Fastabend | 1 | 0.43% | 1 | 8.33% |
Florian Westphal | 1 | 0.43% | 1 | 8.33% |
Total | 232 | 100.00% | 12 | 100.00% |
EXPORT_SYMBOL(netlink_ack);
int netlink_rcv_skb(struct sk_buff *skb, int (*cb)(struct sk_buff *,
struct nlmsghdr *))
{
struct nlmsghdr *nlh;
int err;
while (skb->len >= nlmsg_total_size(0)) {
int msglen;
nlh = nlmsg_hdr(skb);
err = 0;
if (nlh->nlmsg_len < NLMSG_HDRLEN || skb->len < nlh->nlmsg_len)
return 0;
/* Only requests are handled by the kernel */
if (!(nlh->nlmsg_flags & NLM_F_REQUEST))
goto ack;
/* Skip control messages */
if (nlh->nlmsg_type < NLMSG_MIN_TYPE)
goto ack;
err = cb(skb, nlh);
if (err == -EINTR)
goto skip;
ack:
if (nlh->nlmsg_flags & NLM_F_ACK || err)
netlink_ack(skb, nlh, err);
skip:
msglen = NLMSG_ALIGN(nlh->nlmsg_len);
if (msglen > skb->len)
msglen = skb->len;
skb_pull(skb, msglen);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Graf | 149 | 82.32% | 4 | 50.00% |
Denis V. Lunev | 23 | 12.71% | 2 | 25.00% |
Martin Murray | 6 | 3.31% | 1 | 12.50% |
Arnaldo Carvalho de Melo | 3 | 1.66% | 1 | 12.50% |
Total | 181 | 100.00% | 8 | 100.00% |
EXPORT_SYMBOL(netlink_rcv_skb);
/**
* nlmsg_notify - send a notification netlink message
* @sk: netlink socket to use
* @skb: notification message
* @portid: destination netlink portid for reports or 0
* @group: destination multicast group or 0
* @report: 1 to report back, 0 to disable
* @flags: allocation flags
*/
int nlmsg_notify(struct sock *sk, struct sk_buff *skb, u32 portid,
unsigned int group, int report, gfp_t flags)
{
int err = 0;
if (group) {
int exclude_portid = 0;
if (report) {
atomic_inc(&skb->users);
exclude_portid = portid;
}
/* errors reported via destination sk->sk_err, but propagate
* delivery errors if NETLINK_BROADCAST_ERROR flag is set */
err = nlmsg_multicast(sk, skb, exclude_portid, group, flags);
}
if (report) {
int err2;
err2 = nlmsg_unicast(sk, skb, portid);
if (!err || err == -ESRCH)
err = err2;
}
return err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Thomas Graf | 86 | 74.78% | 1 | 33.33% |
Pablo Neira Ayuso | 23 | 20.00% | 1 | 33.33% |
Eric W. Biedermann | 6 | 5.22% | 1 | 33.33% |
Total | 115 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL(nlmsg_notify);
#ifdef CONFIG_PROC_FS
struct nl_seq_iter {
struct seq_net_private p;
struct rhashtable_iter hti;
int link;
};
static int netlink_walk_start(struct nl_seq_iter *iter)
{
int err;
err = rhashtable_walk_init(&nl_table[iter->link].hash, &iter->hti,
GFP_KERNEL);
if (err) {
iter->link = MAX_LINKS;
return err;
}
err = rhashtable_walk_start(&iter->hti);
return err == -EAGAIN ? 0 : err;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 48 | 67.61% | 2 | 33.33% |
Stephen Hemminger | 17 | 23.94% | 1 | 16.67% |
Thomas Graf | 2 | 2.82% | 1 | 16.67% |
Bob Copeland | 2 | 2.82% | 1 | 16.67% |
Linus Torvalds (pre-git) | 2 | 2.82% | 1 | 16.67% |
Total | 71 | 100.00% | 6 | 100.00% |
static void netlink_walk_stop(struct nl_seq_iter *iter)
{
rhashtable_walk_stop(&iter->hti);
rhashtable_walk_exit(&iter->hti);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 16 | 59.26% | 1 | 20.00% |
Stephen Hemminger | 8 | 29.63% | 1 | 20.00% |
Arnaldo Carvalho de Melo | 1 | 3.70% | 1 | 20.00% |
Thomas Graf | 1 | 3.70% | 1 | 20.00% |
Linus Torvalds (pre-git) | 1 | 3.70% | 1 | 20.00% |
Total | 27 | 100.00% | 5 | 100.00% |
static void *__netlink_seq_next(struct seq_file *seq)
{
struct nl_seq_iter *iter = seq->private;
struct netlink_sock *nlk;
do {
for (;;) {
int err;
nlk = rhashtable_walk_next(&iter->hti);
if (IS_ERR(nlk)) {
if (PTR_ERR(nlk) == -EAGAIN)
continue;
return nlk;
}
if (nlk)
break;
netlink_walk_stop(iter);
if (++iter->link >= MAX_LINKS)
return NULL;
err = netlink_walk_start(iter);
if (err)
return ERR_PTR(err);
}
} while (sock_net(&nlk->sk) != seq_file_net(seq));
return nlk;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 90 | 69.23% | 2 | 22.22% |
Stephen Hemminger | 16 | 12.31% | 1 | 11.11% |
Thomas Graf | 14 | 10.77% | 3 | 33.33% |
Gao Feng | 5 | 3.85% | 1 | 11.11% |
Eric W. Biedermann | 3 | 2.31% | 1 | 11.11% |
Hideaki Yoshifuji / 吉藤英明 | 2 | 1.54% | 1 | 11.11% |
Total | 130 | 100.00% | 9 | 100.00% |
static void *netlink_seq_start(struct seq_file *seq, loff_t *posp)
{
struct nl_seq_iter *iter = seq->private;
void *obj = SEQ_START_TOKEN;
loff_t pos;
int err;
iter->link = 0;
err = netlink_walk_start(iter);
if (err)
return ERR_PTR(err);
for (pos = *posp; pos && obj && !IS_ERR(obj); pos--)
obj = __netlink_seq_next(seq);
return obj;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 82 | 91.11% | 2 | 40.00% |
Stephen Hemminger | 4 | 4.44% | 1 | 20.00% |
Eric W. Biedermann | 3 | 3.33% | 1 | 20.00% |
Thomas Graf | 1 | 1.11% | 1 | 20.00% |
Total | 90 | 100.00% | 5 | 100.00% |
static void *netlink_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
++*pos;
return __netlink_seq_next(seq);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 27 | 90.00% | 2 | 66.67% |
Stephen Hemminger | 3 | 10.00% | 1 | 33.33% |
Total | 30 | 100.00% | 3 | 100.00% |
static void netlink_seq_stop(struct seq_file *seq, void *v)
{
struct nl_seq_iter *iter = seq->private;
if (iter->link >= MAX_LINKS)
return;
netlink_walk_stop(iter);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 22 | 57.89% | 1 | 50.00% |
Stephen Hemminger | 16 | 42.11% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
static int netlink_seq_show(struct seq_file *seq, void *v)
{
if (v == SEQ_START_TOKEN) {
seq_puts(seq,
"sk Eth Pid Groups "
"Rmem Wmem Dump Locks Drops Inode\n");
} else {
struct sock *s = v;
struct netlink_sock *nlk = nlk_sk(s);
seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %d %-8d %-8d %-8lu\n",
s,
s->sk_protocol,
nlk->portid,
nlk->groups ? (u32)nlk->groups[0] : 0,
sk_rmem_alloc_get(s),
sk_wmem_alloc_get(s),
nlk->cb_running,
atomic_read(&s->sk_refcnt),
atomic_read(&s->sk_drops),
sock_i_ino(s)
);
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 42 | 34.43% | 1 | 6.67% |
Linus Torvalds (pre-git) | 31 | 25.41% | 2 | 13.33% |
David S. Miller | 12 | 9.84% | 1 | 6.67% |
Patrick McHardy | 12 | 9.84% | 2 | 13.33% |
Pablo Neira Ayuso | 8 | 6.56% | 1 | 6.67% |
Masatake YAMATO | 6 | 4.92% | 1 | 6.67% |
Eric Dumazet | 4 | 3.28% | 2 | 13.33% |
Arnaldo Carvalho de Melo | 3 | 2.46% | 2 | 13.33% |
Pravin B Shelar | 2 | 1.64% | 1 | 6.67% |
Eric W. Biedermann | 1 | 0.82% | 1 | 6.67% |
John Levon | 1 | 0.82% | 1 | 6.67% |
Total | 122 | 100.00% | 15 | 100.00% |
static const struct seq_operations netlink_seq_ops = {
.start = netlink_seq_start,
.next = netlink_seq_next,
.stop = netlink_seq_stop,
.show = netlink_seq_show,
};
static int netlink_seq_open(struct inode *inode, struct file *file)
{
return seq_open_net(inode, file, &netlink_seq_ops,
sizeof(struct nl_seq_iter));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Stephen Hemminger | 14 | 42.42% | 1 | 16.67% |
Eric W. Biedermann | 5 | 15.15% | 1 | 16.67% |
Denis V. Lunev | 5 | 15.15% | 1 | 16.67% |
Pavel Emelyanov | 5 | 15.15% | 1 | 16.67% |
Herbert Xu | 3 | 9.09% | 1 | 16.67% |
Linus Torvalds (pre-git) | 1 | 3.03% | 1 | 16.67% |
Total | 33 | 100.00% | 6 | 100.00% |
static const struct file_operations netlink_seq_fops = {
.owner = THIS_MODULE,
.open = netlink_seq_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release_net,
};
#endif
int netlink_register_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_register(&netlink_chain, nb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
James Morris | 18 | 94.74% | 1 | 50.00% |
Américo Wang | 1 | 5.26% | 1 | 50.00% |
Total | 19 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(netlink_register_notifier);
int netlink_unregister_notifier(struct notifier_block *nb)
{
return blocking_notifier_chain_unregister(&netlink_chain, nb);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
James Morris | 18 | 94.74% | 1 | 50.00% |
Américo Wang | 1 | 5.26% | 1 | 50.00% |
Total | 19 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL(netlink_unregister_notifier);
static const struct proto_ops netlink_ops = {
.family = PF_NETLINK,
.owner = THIS_MODULE,
.release = netlink_release,
.bind = netlink_bind,
.connect = netlink_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = netlink_getname,
.poll = datagram_poll,
.ioctl = netlink_ioctl,
.listen = sock_no_listen,
.shutdown = sock_no_shutdown,
.setsockopt = netlink_setsockopt,
.getsockopt = netlink_getsockopt,
.sendmsg = netlink_sendmsg,
.recvmsg = netlink_recvmsg,
.mmap = sock_no_mmap,
.sendpage = sock_no_sendpage,
};
static const struct net_proto_family netlink_family_ops = {
.family = PF_NETLINK,
.create = netlink_create,
.owner = THIS_MODULE, /* for consistency 8) */
};
static int __net_init netlink_net_init(struct net *net)
{
#ifdef CONFIG_PROC_FS
if (!proc_create("netlink", 0, net->proc_net, &netlink_seq_fops))
return -ENOMEM;
#endif
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric W. Biedermann | 35 | 85.37% | 1 | 33.33% |
Gao Feng | 5 | 12.20% | 1 | 33.33% |
Pavel Emelyanov | 1 | 2.44% | 1 | 33.33% |
Total | 41 | 100.00% | 3 | 100.00% |
static void __net_exit netlink_net_exit(struct net *net)
{
#ifdef CONFIG_PROC_FS
remove_proc_entry("netlink", net->proc_net);
#endif
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Eric W. Biedermann | 20 | 76.92% | 1 | 33.33% |
Gao Feng | 5 | 19.23% | 1 | 33.33% |
Pavel Emelyanov | 1 | 3.85% | 1 | 33.33% |
Total | 26 | 100.00% | 3 | 100.00% |
static void __init netlink_add_usersock_entry(void)
{
struct listeners *listeners;
int groups = 32;
listeners = kzalloc(sizeof(*listeners) + NLGRPSZ(groups), GFP_KERNEL);
if (!listeners)
panic("netlink_add_usersock_entry: Cannot allocate listeners\n");
netlink_table_grab();
nl_table[NETLINK_USERSOCK].groups = groups;
rcu_assign_pointer(nl_table[NETLINK_USERSOCK].listeners, listeners);
nl_table[NETLINK_USERSOCK].module = THIS_MODULE;
nl_table[NETLINK_USERSOCK].registered = 1;
nl_table[NETLINK_USERSOCK].flags = NL_CFG_F_NONROOT_SEND;
netlink_table_ungrab();
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
David S. Miller | 80 | 79.21% | 1 | 25.00% |
Eric Dumazet | 12 | 11.88% | 1 | 25.00% |
Pablo Neira Ayuso | 9 | 8.91% | 2 | 50.00% |
Total | 101 | 100.00% | 4 | 100.00% |
static struct pernet_operations __net_initdata netlink_net_ops = {
.init = netlink_net_init,
.exit = netlink_net_exit,
};
static inline u32 netlink_hash(const void *data, u32 len, u32 seed)
{
const struct netlink_sock *nlk = data;
struct netlink_compare_arg arg;
netlink_compare_arg_init(&arg, sock_net(&nlk->sk), nlk->portid);
return jhash2((u32 *)&arg, netlink_compare_arg_len / sizeof(u32), seed);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 55 | 80.88% | 3 | 42.86% |
Linus Torvalds (pre-git) | 5 | 7.35% | 2 | 28.57% |
Arnaldo Carvalho de Melo | 5 | 7.35% | 1 | 14.29% |
Patrick McHardy | 3 | 4.41% | 1 | 14.29% |
Total | 68 | 100.00% | 7 | 100.00% |
static const struct rhashtable_params netlink_rhashtable_params = {
.head_offset = offsetof(struct netlink_sock, node),
.key_len = netlink_compare_arg_len,
.obj_hashfn = netlink_hash,
.obj_cmpfn = netlink_compare,
.automatic_shrinking = true,
};
static int __init netlink_proto_init(void)
{
int i;
int err = proto_register(&netlink_proto, 0);
if (err != 0)
goto out;
BUILD_BUG_ON(sizeof(struct netlink_skb_parms) > FIELD_SIZEOF(struct sk_buff, cb));
nl_table = kcalloc(MAX_LINKS, sizeof(*nl_table), GFP_KERNEL);
if (!nl_table)
goto panic;
for (i = 0; i < MAX_LINKS; i++) {
if (rhashtable_init(&nl_table[i].hash,
&netlink_rhashtable_params) < 0) {
while (--i > 0)
rhashtable_destroy(&nl_table[i].hash);
kfree(nl_table);
goto panic;
}
}
INIT_LIST_HEAD(&netlink_tap_all);
netlink_add_usersock_entry();
sock_register(&netlink_family_ops);
register_pernet_subsys(&netlink_net_ops);
/* The netlink device handler may be needed early. */
rtnetlink_init();
out:
return err;
panic:
panic("netlink_init: Cannot allocate nl_table\n");
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Herbert Xu | 88 | 51.76% | 2 | 12.50% |
Linus Torvalds (pre-git) | 21 | 12.35% | 3 | 18.75% |
Arnaldo Carvalho de Melo | 16 | 9.41% | 2 | 12.50% |
Thomas Graf | 12 | 7.06% | 1 | 6.25% |
Akinobu Mita | 11 | 6.47% | 1 | 6.25% |
Hideaki Yoshifuji / 吉藤英明 | 7 | 4.12% | 2 | 12.50% |
Daniel Borkmann | 6 | 3.53% | 1 | 6.25% |
Panagiotis Issaris | 3 | 1.76% | 1 | 6.25% |
Eric W. Biedermann | 3 | 1.76% | 2 | 12.50% |
David S. Miller | 3 | 1.76% | 1 | 6.25% |
Total | 170 | 100.00% | 16 | 100.00% |
core_initcall(netlink_proto_init);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Linus Torvalds (pre-git) | 2245 | 18.44% | 18 | 6.14% |
Patrick McHardy | 1664 | 13.67% | 24 | 8.19% |
Herbert Xu | 1628 | 13.37% | 26 | 8.87% |
Daniel Borkmann | 676 | 5.55% | 8 | 2.73% |
Eric W. Biedermann | 645 | 5.30% | 14 | 4.78% |
Johannes Berg | 640 | 5.26% | 14 | 4.78% |
Pablo Neira Ayuso | 562 | 4.62% | 17 | 5.80% |
Thomas Graf | 552 | 4.53% | 17 | 5.80% |
David S. Miller | 347 | 2.85% | 13 | 4.44% |
Eric Dumazet | 278 | 2.28% | 17 | 5.80% |
Stephen Hemminger | 252 | 2.07% | 8 | 2.73% |
Nicolas Dichtel | 246 | 2.02% | 2 | 0.68% |
Florian Westphal | 246 | 2.02% | 2 | 0.68% |
Richard Guy Briggs | 232 | 1.91% | 2 | 0.68% |
Andrew Morton | 207 | 1.70% | 2 | 0.68% |
Denis V. Lunev | 171 | 1.40% | 10 | 3.41% |
James Morris | 150 | 1.23% | 9 | 3.07% |
David Herrmann | 146 | 1.20% | 2 | 0.68% |
Denys Vlasenko | 127 | 1.04% | 1 | 0.34% |
Christophe Ricard | 122 | 1.00% | 1 | 0.34% |
Arnaldo Carvalho de Melo | 122 | 1.00% | 11 | 3.75% |
Pravin B Shelar | 117 | 0.96% | 1 | 0.34% |
Gao Feng | 93 | 0.76% | 4 | 1.37% |
Harald Welte | 71 | 0.58% | 1 | 0.34% |
Benjamin LaHaise | 57 | 0.47% | 1 | 0.34% |
Ying Xue | 51 | 0.42% | 1 | 0.34% |
Arad, Ronen | 50 | 0.41% | 1 | 0.34% |
Andrey Vagin | 50 | 0.41% | 2 | 0.68% |
Hideaki Yoshifuji / 吉藤英明 | 45 | 0.37% | 6 | 2.05% |
Rusty Russell | 38 | 0.31% | 1 | 0.34% |
David Decotigny | 25 | 0.21% | 1 | 0.34% |
Pavel Emelyanov | 23 | 0.19% | 3 | 1.02% |
Tom Herbert | 21 | 0.17% | 1 | 0.34% |
Greg Rose | 20 | 0.16% | 1 | 0.34% |
Neil Horman | 16 | 0.13% | 1 | 0.34% |
Changli Gao | 15 | 0.12% | 1 | 0.34% |
Steffen Hurrle | 15 | 0.12% | 1 | 0.34% |
Alexey Dobriyan | 15 | 0.12% | 1 | 0.34% |
Akinobu Mita | 15 | 0.12% | 1 | 0.34% |
Hannes Frederic Sowa | 14 | 0.11% | 1 | 0.34% |
Hiroaki SHIMODA | 12 | 0.10% | 1 | 0.34% |
Tommy S. Christensen | 11 | 0.09% | 2 | 0.68% |
Alexey Kuznetsov | 10 | 0.08% | 1 | 0.34% |
Jesper Juhl | 8 | 0.07% | 1 | 0.34% |
Heiko Carstens | 8 | 0.07% | 1 | 0.34% |
Matthew Wilcox | 7 | 0.06% | 1 | 0.34% |
Al Viro | 7 | 0.06% | 4 | 1.37% |
Cyrill V. Gorcunov | 7 | 0.06% | 1 | 0.34% |
Linus Torvalds | 6 | 0.05% | 4 | 1.37% |
Masatake YAMATO | 6 | 0.05% | 1 | 0.34% |
Martin Murray | 6 | 0.05% | 1 | 0.34% |
Mike Pecovnik | 6 | 0.05% | 1 | 0.34% |
Christoph Hellwig | 5 | 0.04% | 1 | 0.34% |
Octavian Purdila | 5 | 0.04% | 1 | 0.34% |
Rami Rosen | 5 | 0.04% | 1 | 0.34% |
Arjan van de Ven | 5 | 0.04% | 2 | 0.68% |
Américo Wang | 4 | 0.03% | 1 | 0.34% |
Thomas Gleixner | 4 | 0.03% | 1 | 0.34% |
Dmitry Ivanov | 4 | 0.03% | 1 | 0.34% |
Art Haas | 4 | 0.03% | 1 | 0.34% |
Eric Paris | 3 | 0.02% | 1 | 0.34% |
Randy Dunlap | 3 | 0.02% | 1 | 0.34% |
Thomas Goff | 3 | 0.02% | 1 | 0.34% |
Ilpo Järvinen | 3 | 0.02% | 1 | 0.34% |
Varka Bhadram | 3 | 0.02% | 1 | 0.34% |
Panagiotis Issaris | 3 | 0.02% | 1 | 0.34% |
Alan Stern | 3 | 0.02% | 1 | 0.34% |
Mel Gorman | 3 | 0.02% | 1 | 0.34% |
Lai Jiangshan | 2 | 0.02% | 1 | 0.34% |
Bob Copeland | 2 | 0.02% | 1 | 0.34% |
Hong Zhi Guo | 2 | 0.02% | 1 | 0.34% |
Philippe De Muyter | 1 | 0.01% | 1 | 0.34% |
Dan Carpenter | 1 | 0.01% | 1 | 0.34% |
John Fastabend | 1 | 0.01% | 1 | 0.34% |
Adrian Bunk | 1 | 0.01% | 1 | 0.34% |
Ben Pfaff | 1 | 0.01% | 1 | 0.34% |
John Levon | 1 | 0.01% | 1 | 0.34% |
Total | 12175 | 100.00% | 293 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.