Release 4.7 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 <asm/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 | denis v. lunev | 21 | 95.45% | 1 | 50.00% |
nicolas dichtel | 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 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 ATOMIC_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 | patrick mchardy | 22 | 95.65% | 1 | 50.00% |
stephen hemminger | 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 | 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 | 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 | daniel borkmann | 93 | 98.94% | 1 | 50.00% |
stephen hemminger | 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 | 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 | daniel borkmann | 57 | 95.00% | 1 | 50.00% |
varka bhadram | 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 | 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 | 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 | 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 | 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 | patrick mchardy | 71 | 97.26% | 1 | 50.00% |
nicolas dichtel | 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 | patrick mchardy | 60 | 96.77% | 1 | 50.00% |
nicolas dichtel | 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 | florian westphal | 57 | 82.61% | 1 | 50.00% |
patrick mchardy | 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 | florian westphal | 40 | 68.97% | 1 | 33.33% |
patrick mchardy | 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 |
florian westphal | florian westphal | 49 | 38.28% | 1 | 9.09% |
pre-git | pre-git | 37 | 28.91% | 2 | 18.18% |
patrick mchardy | patrick mchardy | 29 | 22.66% | 3 | 27.27% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 5 | 3.91% | 2 | 18.18% |
david s. miller | david s. miller | 3 | 2.34% | 1 | 9.09% |
ilpo jarvinen | ilpo jarvinen | 3 | 2.34% | 1 | 9.09% |
james morris | james morris | 2 | 1.56% | 1 | 9.09% |
| Total | 128 | 100.00% | 11 | 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 |
pre-git | pre-git | 88 | 89.80% | 4 | 57.14% |
eric dumazet | eric dumazet | 4 | 4.08% | 1 | 14.29% |
arjan van de ven | arjan van de ven | 3 | 3.06% | 1 | 14.29% |
johannes berg | 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 |
pre-git | pre-git | 18 | 78.26% | 3 | 60.00% |
eric dumazet | eric dumazet | 4 | 17.39% | 1 | 20.00% |
arjan van de ven | 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 |
pre-git | pre-git | 27 | 96.43% | 2 | 66.67% |
patrick mchardy | 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 |
pre-git | pre-git | 22 | 95.65% | 2 | 66.67% |
patrick mchardy | 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 | herbert xu | 26 | 40.62% | 2 | 50.00% |
thomas graf | thomas graf | 23 | 35.94% | 1 | 25.00% |
gao feng | 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 | 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 | thomas graf | 33 | 67.35% | 2 | 50.00% |
herbert xu | herbert xu | 12 | 24.49% | 1 | 25.00% |
gao feng | 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 | ying xue | 40 | 66.67% | 1 | 25.00% |
herbert xu | 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 | patrick mchardy | 21 | 32.81% | 1 | 12.50% |
pre-git | pre-git | 17 | 26.56% | 2 | 25.00% |
thomas graf | thomas graf | 9 | 14.06% | 1 | 12.50% |
herbert xu | herbert xu | 8 | 12.50% | 1 | 12.50% |
gao feng | gao feng | 4 | 6.25% | 1 | 12.50% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 3 | 4.69% | 1 | 12.50% |
eric w. biederman | eric w. biederman | 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 | patrick mchardy | 81 | 67.50% | 1 | 25.00% |
eric dumazet | eric dumazet | 22 | 18.33% | 2 | 50.00% |
johannes berg | 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 | herbert xu | 125 | 69.44% | 6 | 50.00% |
thomas graf | thomas graf | 24 | 13.33% | 2 | 16.67% |
daniel borkmann | daniel borkmann | 16 | 8.89% | 1 | 8.33% |
ying xue | ying xue | 10 | 5.56% | 1 | 8.33% |
gao feng | gao feng | 3 | 1.67% | 1 | 8.33% |
eric w. biederman | eric w. biederman | 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 | thomas graf | 47 | 43.52% | 1 | 12.50% |
herbert xu | herbert xu | 33 | 30.56% | 2 | 25.00% |
johannes berg | johannes berg | 21 | 19.44% | 2 | 25.00% |
pre-git | pre-git | 6 | 5.56% | 2 | 25.00% |
patrick mchardy | 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);
}
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 | patrick mchardy | 101 | 73.72% | 3 | 33.33% |
pre-git | pre-git | 17 | 12.41% | 1 | 11.11% |
eric w. biederman | eric w. biederman | 12 | 8.76% | 2 | 22.22% |
david s. miller | david s. miller | 4 | 2.92% | 1 | 11.11% |
eric dumazet | eric dumazet | 2 | 1.46% | 1 | 11.11% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 1 | 0.73% | 1 | 11.11% |
| Total | 137 | 100.00% | 9 | 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 | patrick mchardy | 115 | 38.08% | 5 | 26.32% |
pre-git | pre-git | 50 | 16.56% | 2 | 10.53% |
harald welte | harald welte | 32 | 10.60% | 1 | 5.26% |
richard guy briggs | richard guy briggs | 26 | 8.61% | 1 | 5.26% |
pablo neira ayuso | pablo neira ayuso | 24 | 7.95% | 1 | 5.26% |
alexey dobriyan | alexey dobriyan | 15 | 4.97% | 1 | 5.26% |
johannes berg | johannes berg | 11 | 3.64% | 2 | 10.53% |
eric dumazet | eric dumazet | 10 | 3.31% | 1 | 5.26% |
eric w. biederman | eric w. biederman | 9 | 2.98% | 2 | 10.53% |
david s. miller | david s. miller | 6 | 1.99% | 1 | 5.26% |
eric paris | eric paris | 3 | 0.99% | 1 | 5.26% |
arnaldo carvalho de melo | 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);
sock_put(&nlk->sk);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
thomas graf | thomas graf | 34 | 100.00% | 1 | 100.00% |
| Total | 34 | 100.00% | 1 | 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,
};
atomic_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 | johannes berg | 78 | 19.95% | 2 | 6.45% |
pre-git | pre-git | 59 | 15.09% | 3 | 9.68% |
eric dumazet | eric dumazet | 49 | 12.53% | 3 | 9.68% |
patrick mchardy | patrick mchardy | 43 | 11.00% | 4 | 12.90% |
denis v. lunev | denis v. lunev | 38 | 9.72% | 3 | 9.68% |
james morris | james morris | 27 | 6.91% | 1 | 3.23% |
pablo neira ayuso | pablo neira ayuso | 22 | 5.63% | 1 | 3.23% |
harald welte | harald welte | 18 | 4.60% | 1 | 3.23% |
david s. miller | david s. miller | 14 | 3.58% | 2 | 6.45% |
richard guy briggs | richard guy briggs | 11 | 2.81% | 1 | 3.23% |
eric w. biederman | eric w. biederman | 8 | 2.05% | 2 | 6.45% |
thomas graf | thomas graf | 7 | 1.79% | 1 | 3.23% |
art haas | art haas | 4 | 1.02% | 1 | 3.23% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 4 | 1.02% | 2 | 6.45% |
dmitry ivanov | dmitry ivanov | 4 | 1.02% | 1 | 3.23% |
hideaki yoshifuji | hideaki yoshifuji | 3 | 0.77% | 1 | 3.23% |
herbert xu | herbert xu | 1 | 0.26% | 1 | 3.23% |
alan stern | alan stern | 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 | herbert xu | 69 | 40.83% | 3 | 21.43% |
pre-git | pre-git | 61 | 36.09% | 2 | 14.29% |
david s. miller | david s. miller | 14 | 8.28% | 2 | 14.29% |
eric w. biederman | eric w. biederman | 12 | 7.10% | 2 | 14.29% |
gao feng | gao feng | 3 | 1.78% | 1 | 7.14% |
hideaki yoshifuji | hideaki yoshifuji | 3 | 1.78% | 1 | 7.14% |
thomas goff | thomas goff | 3 | 1.78% | 1 | 7.14% |
thomas graf | thomas graf | 3 | 1.78% | 1 | 7.14% |
arnaldo carvalho de melo | 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. biederman | eric w. biederman | 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. biederman | eric w. biederman | 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. biederman | eric w. biederman | 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. biederman | eric w. biederman | 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 | james morris | 30 | 63.83% | 1 | 12.50% |
eric w. biederman | eric w. biederman | 11 | 23.40% | 2 | 25.00% |
pablo neira ayuso | pablo neira ayuso | 3 | 6.38% | 2 | 25.00% |
herbert xu | herbert xu | 1 | 2.13% | 1 | 12.50% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 1 | 2.13% | 1 | 12.50% |
stephen hemminger | stephen hemminger | 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 | 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 | patrick mchardy | 88 | 53.66% | 1 | 50.00% |
johannes berg | 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 | richard guy briggs | 56 | 72.73% | 1 | 20.00% |
johannes berg | johannes berg | 18 | 23.38% | 2 | 40.00% |
pablo neira ayuso | pablo neira ayuso | 2 | 2.60% | 1 | 20.00% |
hiroaki shimoda | 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 |
pre-git | pre-git | 99 | 26.54% | 3 | 13.04% |
richard guy briggs | richard guy briggs | 94 | 25.20% | 1 | 4.35% |
patrick mchardy | patrick mchardy | 67 | 17.96% | 3 | 13.04% |
herbert xu | herbert xu | 62 | 16.62% | 3 | 13.04% |
hannes frederic sowa | hannes frederic sowa | 14 | 3.75% | 1 | 4.35% |
david s. miller | david s. miller | 12 | 3.22% | 1 | 4.35% |
eric w. biederman | eric w. biederman | 9 | 2.41% | 3 | 13.04% |
johannes berg | johannes berg | 7 | 1.88% | 3 | 13.04% |
hideaki yoshifuji | hideaki yoshifuji | 3 | 0.80% | 1 | 4.35% |
pablo neira ayuso | pablo neira ayuso | 3 | 0.80% | 2 | 8.70% |
james morris | james morris | 2 | 0.54% | 1 | 4.35% |
arnaldo carvalho de melo | 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 |
pre-git | pre-git | 129 | 67.54% | 4 | 25.00% |
herbert xu | herbert xu | 15 | 7.85% | 3 | 18.75% |
changli gao | changli gao | 15 | 7.85% | 1 | 6.25% |
david s. miller | david s. miller | 14 | 7.33% | 1 | 6.25% |
mike pecovnik | mike pecovnik | 6 | 3.14% | 1 | 6.25% |
patrick mchardy | patrick mchardy | 5 | 2.62% | 1 | 6.25% |
eric w. biederman | eric w. biederman | 3 | 1.57% | 2 | 12.50% |
james morris | james morris | 2 | 1.05% | 1 | 6.25% |
pablo neira ayuso | pablo neira ayuso | 1 | 0.52% | 1 | 6.25% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 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 |
pre-git | pre-git | 89 | 68.46% | 2 | 20.00% |
david s. miller | david s. miller | 18 | 13.85% | 2 | 20.00% |
patrick mchardy | patrick mchardy | 13 | 10.00% | 3 | 30.00% |
cyrill gorcunov | cyrill gorcunov | 7 | 5.38% | 1 | 10.00% |
eric w. biederman | eric w. biederman | 2 | 1.54% | 1 | 10.00% |
arnaldo carvalho de melo | 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 | 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 | andrew morton | 34 | 34.69% | 1 | 7.69% |
pre-git | pre-git | 21 | 21.43% | 3 | 23.08% |
herbert xu | herbert xu | 14 | 14.29% | 1 | 7.69% |
david s. miller | david s. miller | 10 | 10.20% | 1 | 7.69% |
eric w. biederman | eric w. biederman | 7 | 7.14% | 2 | 15.38% |
denis v. lunev | denis v. lunev | 4 | 4.08% | 1 | 7.69% |
hideaki yoshifuji | hideaki yoshifuji | 3 | 3.06% | 1 | 7.69% |
james morris | james morris | 3 | 3.06% | 1 | 7.69% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 1 | 1.02% | 1 | 7.69% |
adrian bunk | 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 | andrew morton | 56 | 73.68% | 1 | 16.67% |
pre-git | pre-git | 10 | 13.16% | 3 | 50.00% |
matthew wilcox | matthew wilcox | 7 | 9.21% | 1 | 16.67% |
al viro | 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 | pablo neira ayuso | 101 | 99.02% | 2 | 66.67% |
eric dumazet | 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 |
pre-git | pre-git | 148 | 66.67% | 7 | 36.84% |
andrew morton | andrew morton | 38 | 17.12% | 1 | 5.26% |
alexey kuznetsov | alexey kuznetsov | 10 | 4.50% | 1 | 5.26% |
patrick mchardy | patrick mchardy | 8 | 3.60% | 3 | 15.79% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 8 | 3.60% | 3 | 15.79% |
david s. miller | david s. miller | 5 | 2.25% | 1 | 5.26% |
james morris | james morris | 2 | 0.90% | 1 | 5.26% |
nicolas dichtel | nicolas dichtel | 2 | 0.90% | 1 | 5.26% |
denis v. lunev | 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 | andrew morton | 20 | 41.67% | 1 | 20.00% |
pre-git | pre-git | 15 | 31.25% | 1 | 20.00% |
eric dumazet | eric dumazet | 6 | 12.50% | 1 | 20.00% |
daniel borkmann | daniel borkmann | 5 | 10.42% | 1 | 20.00% |
arnaldo carvalho de melo | 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 | eric dumazet | 24 | 72.73% | 1 | 25.00% |
pre-git | pre-git | 8 | 24.24% | 2 | 50.00% |
andrew morton | 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 | 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;
}
if (!pskb_expand_head(skb, 0, -delta, allocation))
skb->truesize -= delta;
return skb;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
herbert xu | herbert xu | 103 | 85.83% | 3 | 33.33% |
pablo neira ayuso | pablo neira ayuso | 7 | 5.83% | 1 | 11.11% |
patrick mchardy | patrick mchardy | 5 | 4.17% | 1 | 11.11% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 2 | 1.67% | 1 | 11.11% |
eric dumazet | eric dumazet | 1 | 0.83% | 1 | 11.11% |
david s. miller | david s. miller | 1 | 0.83% | 1 | 11.11% |
al viro | al viro | 1 | 0.83% | 1 | 11.11% |
| Total | 120 | 100.00% | 9 | 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 | patrick mchardy | 45 | 41.67% | 1 | 20.00% |
denis v. lunev | denis v. lunev | 37 | 34.26% | 1 | 20.00% |
florian westphal | florian westphal | 16 | 14.81% | 1 | 20.00% |
eric dumazet | eric dumazet | 5 | 4.63% | 1 | 20.00% |
eric w. biederman | eric w. biederman | 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 | florian westphal | 94 | 56.29% | 1 | 11.11% |
andrew morton | andrew morton | 28 | 16.77% | 1 | 11.11% |
patrick mchardy | patrick mchardy | 26 | 15.57% | 2 | 22.22% |
stephen hemminger | stephen hemminger | 11 | 6.59% | 1 | 11.11% |
denis v. lunev | denis v. lunev | 3 | 1.80% | 1 | 11.11% |
herbert xu | herbert xu | 3 | 1.80% | 2 | 22.22% |
daniel borkmann | 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 | patrick mchardy | 56 | 65.12% | 1 | 20.00% |
johannes berg | johannes berg | 23 | 26.74% | 1 | 20.00% |
eric dumazet | eric dumazet | 6 | 6.98% | 2 | 40.00% |
denis v. lunev | 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 |
pre-git | pre-git | 57 | 64.77% | 2 | 20.00% |
herbert xu | herbert xu | 11 | 12.50% | 1 | 10.00% |
david s. miller | david s. miller | 10 | 11.36% | 1 | 10.00% |
stephen hemminger | stephen hemminger | 4 | 4.55% | 1 | 10.00% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 3 | 3.41% | 2 | 20.00% |
nicolas dichtel | nicolas dichtel | 1 | 1.14% | 1 | 10.00% |
eric dumazet | eric dumazet | 1 | 1.14% | 1 | 10.00% |
patrick mchardy | patrick mchardy | 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 |
pre-git | pre-git | 105 | 24.94% | 2 | 9.09% |
nicolas dichtel | nicolas dichtel | 99 | 23.52% | 2 | 9.09% |
herbert xu | herbert xu | 61 | 14.49% | 2 | 9.09% |
eric w. biederman | eric w. biederman | 45 | 10.69% | 3 | 13.64% |
pablo neira ayuso | pablo neira ayuso | 26 | 6.18% | 2 | 9.09% |
stephen hemminger | stephen hemminger | 24 | 5.70% | 1 | 4.55% |
david s. miller | david s. miller | 22 | 5.23% | 3 | 13.64% |
patrick mchardy | patrick mchardy | 18 | 4.28% | 2 | 9.09% |
hideaki yoshifuji | hideaki yoshifuji | 8 | 1.90% | 2 | 9.09% |
tommy s. christensen | tommy s. christensen | 7 | 1.66% | 1 | 4.55% |
rami rosen | rami rosen | 5 | 1.19% | 1 | 4.55% |
arnaldo carvalho de melo | 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 | herbert xu | 128 | 54.24% | 3 | 18.75% |
eric w. biederman | eric w. biederman | 54 | 22.88% | 3 | 18.75% |
neil horman | neil horman | 16 | 6.78% | 1 | 6.25% |
pablo neira ayuso | pablo neira ayuso | 14 | 5.93% | 1 | 6.25% |
pre-git | pre-git | 8 | 3.39% | 3 | 18.75% |
david s. miller | david s. miller | 5 | 2.12% | 1 | 6.25% |
tommy s. christensen | tommy s. christensen | 4 | 1.69% | 1 | 6.25% |
hideaki yoshifuji | hideaki yoshifuji | 3 | 1.27% | 1 | 6.25% |
mel gorman | mel gorman | 3 | 1.27% | 1 | 6.25% |
al viro | 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. biederman | eric w. biederman | 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 | herbert xu | 72 | 50.35% | 1 | 10.00% |
pablo neira ayuso | pablo neira ayuso | 28 | 19.58% | 1 | 10.00% |
patrick mchardy | patrick mchardy | 18 | 12.59% | 2 | 20.00% |
eric w. biederman | eric w. biederman | 12 | 8.39% | 2 | 20.00% |
hideaki yoshifuji | hideaki yoshifuji | 6 | 4.20% | 1 | 10.00% |
octavian purdila | octavian purdila | 5 | 3.50% | 1 | 10.00% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 1 | 0.70% | 1 | 10.00% |
nicolas dichtel | nicolas dichtel | 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 |
pre-git | pre-git | 35 | 38.89% | 3 | 33.33% |
herbert xu | herbert xu | 32 | 35.56% | 1 | 11.11% |
pablo neira ayuso | pablo neira ayuso | 13 | 14.44% | 2 | 22.22% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 5 | 5.56% | 1 | 11.11% |
eric w. biederman | eric w. biederman | 3 | 3.33% | 1 | 11.11% |
david s. miller | 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 | 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 | patrick mchardy | 192 | 47.29% | 3 | 16.67% |
pablo neira ayuso | pablo neira ayuso | 68 | 16.75% | 3 | 16.67% |
nicolas dichtel | nicolas dichtel | 52 | 12.81% | 2 | 11.11% |
richard guy briggs | richard guy briggs | 45 | 11.08% | 2 | 11.11% |
christophe ricard | christophe ricard | 26 | 6.40% | 1 | 5.56% |
johannes berg | johannes berg | 19 | 4.68% | 4 | 22.22% |
eric dumazet | eric dumazet | 2 | 0.49% | 1 | 5.56% |
david s. miller | david s. miller | 1 | 0.25% | 1 | 5.56% |
eric w. biederman | eric w. biederman | 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 | patrick mchardy | 152 | 31.21% | 1 | 12.50% |
david herrmann | david herrmann | 146 | 29.98% | 2 | 25.00% |
pablo neira ayuso | pablo neira ayuso | 118 | 24.23% | 2 | 25.00% |
christophe ricard | christophe ricard | 60 | 12.32% | 1 | 12.50% |
heiko carstens | heiko carstens | 8 | 1.64% | 1 | 12.50% |
nicolas dichtel | 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 | 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 | 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 |
pre-git | pre-git | 249 | 60.58% | 4 | 14.29% |
eric w. biederman | eric w. biederman | 53 | 12.90% | 5 | 17.86% |
james morris | james morris | 27 | 6.57% | 4 | 14.29% |
benjamin lahaise | benjamin lahaise | 26 | 6.33% | 1 | 3.57% |
patrick mchardy | patrick mchardy | 12 | 2.92% | 1 | 3.57% |
david s. miller | david s. miller | 12 | 2.92% | 1 | 3.57% |
steffen hurrle | steffen hurrle | 8 | 1.95% | 1 | 3.57% |
herbert xu | herbert xu | 8 | 1.95% | 1 | 3.57% |
pablo neira ayuso | pablo neira ayuso | 7 | 1.70% | 4 | 14.29% |
christoph hellwig | christoph hellwig | 3 | 0.73% | 1 | 3.57% |
eric dumazet | eric dumazet | 2 | 0.49% | 1 | 3.57% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 2 | 0.49% | 2 | 7.14% |
stephen hemminger | stephen hemminger | 1 | 0.24% | 1 | 3.57% |
al viro | al viro | 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,
16384);
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 |
pre-git | pre-git | 217 | 50.35% | 2 | 7.69% |
johannes berg | johannes berg | 44 | 10.21% | 2 | 7.69% |
benjamin lahaise | benjamin lahaise | 31 | 7.19% | 1 | 3.85% |
eric dumazet | eric dumazet | 29 | 6.73% | 1 | 3.85% |
patrick mchardy | patrick mchardy | 27 | 6.26% | 3 | 11.54% |
andrey vagin | andrey vagin | 25 | 5.80% | 1 | 3.85% |
david s. miller | david s. miller | 19 | 4.41% | 4 | 15.38% |
nicolas dichtel | nicolas dichtel | 18 | 4.18% | 2 | 7.69% |
steffen hurrle | steffen hurrle | 7 | 1.62% | 1 | 3.85% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 6 | 1.39% | 3 | 11.54% |
stephen hemminger | stephen hemminger | 2 | 0.46% | 1 | 3.85% |
christoph hellwig | christoph hellwig | 2 | 0.46% | 1 | 3.85% |
ben pfaff | ben pfaff | 1 | 0.23% | 1 | 3.85% |
pravin b shelar | pravin b shelar | 1 | 0.23% | 1 | 3.85% |
eric w. biederman | eric w. biederman | 1 | 0.23% | 1 | 3.85% |
james morris | james morris | 1 | 0.23% | 1 | 3.85% |
| Total | 431 | 100.00% | 26 | 100.00% |
static void netlink_data_ready(struct sock *sk)
{
BUG();
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
pre-git | pre-git | 11 | 78.57% | 2 | 50.00% |
denis v. lunev | denis v. lunev | 2 | 14.29% | 1 | 25.00% |
stephen hemminger | 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 | patrick mchardy | 102 | 26.15% | 6 | 18.18% |
pre-git | pre-git | 72 | 18.46% | 2 | 6.06% |
pablo neira ayuso | pablo neira ayuso | 68 | 17.44% | 4 | 12.12% |
eric w. biederman | eric w. biederman | 21 | 5.38% | 4 | 12.12% |
harald welte | harald welte | 21 | 5.38% | 1 | 3.03% |
gao feng | gao feng | 17 | 4.36% | 1 | 3.03% |
pavel emelianov | pavel emelianov | 16 | 4.10% | 1 | 3.03% |
herbert xu | herbert xu | 11 | 2.82% | 2 | 6.06% |
eric dumazet | eric dumazet | 11 | 2.82% | 1 | 3.03% |
hiroaki shimoda | hiroaki shimoda | 11 | 2.82% | 1 | 3.03% |
james morris | james morris | 10 | 2.56% | 1 | 3.03% |
denis v. lunev | denis v. lunev | 10 | 2.56% | 3 | 9.09% |
jesper juhl | jesper juhl | 8 | 2.05% | 1 | 3.03% |
akinobu mita | akinobu mita | 4 | 1.03% | 1 | 3.03% |
johannes berg | johannes berg | 3 | 0.77% | 1 | 3.03% |
david s. miller | david s. miller | 3 | 0.77% | 1 | 3.03% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 1 | 0.26% | 1 | 3.03% |
nicolas dichtel | 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. biederman | eric w. biederman | 16 | 53.33% | 1 | 33.33% |
denis v. lunev | 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 | johannes berg | 118 | 84.29% | 3 | 50.00% |
eric dumazet | eric dumazet | 20 | 14.29% | 2 | 33.33% |
lai jiangshan | 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 | 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 | 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 | denys vlasenko | 122 | 96.83% | 1 | 33.33% |
hong zhi guo | hong zhi guo | 2 | 1.59% | 1 | 33.33% |
eric w. biederman | eric w. biederman | 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_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 |
pre-git | pre-git | 127 | 32.90% | 2 | 10.00% |
ronen arad | ronen arad | 50 | 12.95% | 1 | 5.00% |
thomas graf | thomas graf | 45 | 11.66% | 3 | 15.00% |
patrick mchardy | patrick mchardy | 32 | 8.29% | 2 | 10.00% |
stephen hemminger | stephen hemminger | 30 | 7.77% | 1 | 5.00% |
eric dumazet | eric dumazet | 28 | 7.25% | 2 | 10.00% |
greg rose | greg rose | 20 | 5.18% | 1 | 5.00% |
herbert xu | herbert xu | 17 | 4.40% | 1 | 5.00% |
david s. miller | david s. miller | 13 | 3.37% | 1 | 5.00% |
pravin b shelar | pravin b shelar | 8 | 2.07% | 1 | 5.00% |
johannes berg | johannes berg | 7 | 1.81% | 1 | 5.00% |
gao feng | gao feng | 5 | 1.30% | 1 | 5.00% |
florian westphal | florian westphal | 2 | 0.52% | 1 | 5.00% |
dan carpenter | dan carpenter | 1 | 0.26% | 1 | 5.00% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 1 | 0.26% | 1 | 5.00% |
| Total | 386 | 100.00% | 20 | 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 | pravin b shelar | 106 | 35.93% | 1 | 5.56% |
pre-git | pre-git | 83 | 28.14% | 2 | 11.11% |
gao feng | gao feng | 26 | 8.81% | 1 | 5.56% |
tom herbert | tom herbert | 21 | 7.12% | 1 | 5.56% |
david s. miller | david s. miller | 15 | 5.08% | 1 | 5.56% |
patrick mchardy | patrick mchardy | 13 | 4.41% | 3 | 16.67% |
andrey vagin | andrey vagin | 12 | 4.07% | 1 | 5.56% |
herbert xu | herbert xu | 5 | 1.69% | 1 | 5.56% |
eric w. biederman | eric w. biederman | 4 | 1.36% | 2 | 11.11% |
denis v. lunev | denis v. lunev | 3 | 1.02% | 1 | 5.56% |
hideaki yoshifuji | hideaki yoshifuji | 3 | 1.02% | 1 | 5.56% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 2 | 0.68% | 2 | 11.11% |
pablo neira ayuso | pablo neira ayuso | 2 | 0.68% | 1 | 5.56% |
| 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 |
pre-git | pre-git | 118 | 50.86% | 2 | 16.67% |
david s. miller | david s. miller | 47 | 20.26% | 1 | 8.33% |
christophe ricard | christophe ricard | 32 | 13.79% | 1 | 8.33% |
thomas graf | thomas graf | 22 | 9.48% | 3 | 25.00% |
eric w. biederman | eric w. biederman | 8 | 3.45% | 2 | 16.67% |
hideaki yoshifuji | hideaki yoshifuji | 3 | 1.29% | 1 | 8.33% |
john fastabend | john fastabend | 1 | 0.43% | 1 | 8.33% |
florian westphal | 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 | thomas graf | 149 | 82.32% | 4 | 50.00% |
denis v. lunev | denis v. lunev | 23 | 12.71% | 2 | 25.00% |
martin murray | martin murray | 6 | 3.31% | 1 | 12.50% |
arnaldo carvalho de melo | 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 | thomas graf | 86 | 74.78% | 1 | 33.33% |
pablo neira ayuso | pablo neira ayuso | 23 | 20.00% | 1 | 33.33% |
eric w. biederman | eric w. biederman | 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 | herbert xu | 48 | 67.61% | 2 | 33.33% |
stephen hemminger | stephen hemminger | 17 | 23.94% | 1 | 16.67% |
bob copeland | bob copeland | 2 | 2.82% | 1 | 16.67% |
thomas graf | thomas graf | 2 | 2.82% | 1 | 16.67% |
pre-git | 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 | herbert xu | 16 | 59.26% | 1 | 20.00% |
stephen hemminger | stephen hemminger | 8 | 29.63% | 1 | 20.00% |
thomas graf | thomas graf | 1 | 3.70% | 1 | 20.00% |
pre-git | pre-git | 1 | 3.70% | 1 | 20.00% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 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 | herbert xu | 90 | 69.23% | 2 | 22.22% |
stephen hemminger | stephen hemminger | 16 | 12.31% | 1 | 11.11% |
thomas graf | thomas graf | 14 | 10.77% | 3 | 33.33% |
gao feng | gao feng | 5 | 3.85% | 1 | 11.11% |
eric w. biederman | eric w. biederman | 3 | 2.31% | 1 | 11.11% |
hideaki yoshifuji | 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 | herbert xu | 82 | 91.11% | 2 | 40.00% |
stephen hemminger | stephen hemminger | 4 | 4.44% | 1 | 20.00% |
eric w. biederman | eric w. biederman | 3 | 3.33% | 1 | 20.00% |
thomas graf | 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 | herbert xu | 27 | 90.00% | 2 | 66.67% |
stephen hemminger | 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 | herbert xu | 22 | 57.89% | 1 | 50.00% |
stephen hemminger | 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 | stephen hemminger | 42 | 34.43% | 1 | 6.67% |
pre-git | pre-git | 31 | 25.41% | 2 | 13.33% |
patrick mchardy | patrick mchardy | 12 | 9.84% | 2 | 13.33% |
david s. miller | david s. miller | 12 | 9.84% | 1 | 6.67% |
pablo neira ayuso | pablo neira ayuso | 8 | 6.56% | 1 | 6.67% |
masatake yamato | masatake yamato | 6 | 4.92% | 1 | 6.67% |
eric dumazet | eric dumazet | 4 | 3.28% | 2 | 13.33% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 3 | 2.46% | 2 | 13.33% |
pravin b shelar | pravin b shelar | 2 | 1.64% | 1 | 6.67% |
eric w. biederman | eric w. biederman | 1 | 0.82% | 1 | 6.67% |
john levon | 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 | stephen hemminger | 14 | 42.42% | 1 | 16.67% |
denis v. lunev | denis v. lunev | 5 | 15.15% | 1 | 16.67% |
pavel emelianov | pavel emelianov | 5 | 15.15% | 1 | 16.67% |
eric w. biederman | eric w. biederman | 5 | 15.15% | 1 | 16.67% |
herbert xu | herbert xu | 3 | 9.09% | 1 | 16.67% |
pre-git | 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 atomic_notifier_chain_register(&netlink_chain, nb);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
james morris | james morris | 18 | 94.74% | 1 | 50.00% |
alan stern | alan stern | 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 atomic_notifier_chain_unregister(&netlink_chain, nb);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
james morris | james morris | 18 | 94.74% | 1 | 50.00% |
alan stern | alan stern | 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. biederman | eric w. biederman | 35 | 85.37% | 1 | 33.33% |
gao feng | gao feng | 5 | 12.20% | 1 | 33.33% |
pavel emelianov | pavel emelianov | 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. biederman | eric w. biederman | 20 | 76.92% | 1 | 33.33% |
gao feng | gao feng | 5 | 19.23% | 1 | 33.33% |
pavel emelianov | pavel emelianov | 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 | david s. miller | 80 | 79.21% | 1 | 25.00% |
eric dumazet | eric dumazet | 12 | 11.88% | 1 | 25.00% |
pablo neira ayuso | 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 | herbert xu | 55 | 80.88% | 3 | 42.86% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 5 | 7.35% | 1 | 14.29% |
pre-git | pre-git | 5 | 7.35% | 2 | 28.57% |
patrick mchardy | 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 | herbert xu | 88 | 51.76% | 2 | 12.50% |
pre-git | pre-git | 21 | 12.35% | 3 | 18.75% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 16 | 9.41% | 2 | 12.50% |
thomas graf | thomas graf | 12 | 7.06% | 1 | 6.25% |
akinobu mita | akinobu mita | 11 | 6.47% | 1 | 6.25% |
hideaki yoshifuji | hideaki yoshifuji | 7 | 4.12% | 2 | 12.50% |
daniel borkmann | daniel borkmann | 6 | 3.53% | 1 | 6.25% |
david s. miller | david s. miller | 3 | 1.76% | 1 | 6.25% |
eric w. biederman | eric w. biederman | 3 | 1.76% | 2 | 12.50% |
panagiotis issaris* | panagiotis issaris* | 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 |
pre-git | pre-git | 2246 | 18.75% | 18 | 6.29% |
patrick mchardy | patrick mchardy | 1668 | 13.93% | 24 | 8.39% |
herbert xu | herbert xu | 1425 | 11.90% | 23 | 8.04% |
daniel borkmann | daniel borkmann | 676 | 5.64% | 8 | 2.80% |
eric w. biederman | eric w. biederman | 645 | 5.39% | 14 | 4.90% |
johannes berg | johannes berg | 640 | 5.34% | 14 | 4.90% |
pablo neira ayuso | pablo neira ayuso | 562 | 4.69% | 17 | 5.94% |
thomas graf | thomas graf | 553 | 4.62% | 17 | 5.94% |
david s. miller | david s. miller | 347 | 2.90% | 13 | 4.55% |
florian westphal | florian westphal | 263 | 2.20% | 2 | 0.70% |
eric dumazet | eric dumazet | 261 | 2.18% | 15 | 5.24% |
stephen hemminger | stephen hemminger | 252 | 2.10% | 8 | 2.80% |
nicolas dichtel | nicolas dichtel | 246 | 2.05% | 2 | 0.70% |
richard guy briggs | richard guy briggs | 232 | 1.94% | 2 | 0.70% |
andrew morton | andrew morton | 207 | 1.73% | 2 | 0.70% |
denis v. lunev | denis v. lunev | 171 | 1.43% | 10 | 3.50% |
james morris | james morris | 150 | 1.25% | 9 | 3.15% |
david herrmann | david herrmann | 146 | 1.22% | 2 | 0.70% |
denys vlasenko | denys vlasenko | 127 | 1.06% | 1 | 0.35% |
christophe ricard | christophe ricard | 122 | 1.02% | 1 | 0.35% |
arnaldo carvalho de melo | arnaldo carvalho de melo | 122 | 1.02% | 11 | 3.85% |
pravin b shelar | pravin b shelar | 117 | 0.98% | 1 | 0.35% |
gao feng | gao feng | 93 | 0.78% | 4 | 1.40% |
harald welte | harald welte | 71 | 0.59% | 1 | 0.35% |
benjamin lahaise | benjamin lahaise | 57 | 0.48% | 1 | 0.35% |
ying xue | ying xue | 51 | 0.43% | 1 | 0.35% |
ronen arad | ronen arad | 50 | 0.42% | 1 | 0.35% |
andrey vagin | andrey vagin | 50 | 0.42% | 2 | 0.70% |
hideaki yoshifuji | hideaki yoshifuji | 45 | 0.38% | 6 | 2.10% |
rusty russell | rusty russell | 38 | 0.32% | 1 | 0.35% |
david decotigny | david decotigny | 25 | 0.21% | 1 | 0.35% |
pavel emelianov | pavel emelianov | 23 | 0.19% | 3 | 1.05% |
tom herbert | tom herbert | 21 | 0.18% | 1 | 0.35% |
greg rose | greg rose | 20 | 0.17% | 1 | 0.35% |
neil horman | neil horman | 16 | 0.13% | 1 | 0.35% |
changli gao | changli gao | 15 | 0.13% | 1 | 0.35% |
steffen hurrle | steffen hurrle | 15 | 0.13% | 1 | 0.35% |
alexey dobriyan | alexey dobriyan | 15 | 0.13% | 1 | 0.35% |
akinobu mita | akinobu mita | 15 | 0.13% | 1 | 0.35% |
hannes frederic sowa | hannes frederic sowa | 14 | 0.12% | 1 | 0.35% |
hiroaki shimoda | hiroaki shimoda | 12 | 0.10% | 1 | 0.35% |
tommy s. christensen | tommy s. christensen | 11 | 0.09% | 2 | 0.70% |
alexey kuznetsov | alexey kuznetsov | 10 | 0.08% | 1 | 0.35% |
heiko carstens | heiko carstens | 8 | 0.07% | 1 | 0.35% |
jesper juhl | jesper juhl | 8 | 0.07% | 1 | 0.35% |
matthew wilcox | matthew wilcox | 7 | 0.06% | 1 | 0.35% |
al viro | al viro | 7 | 0.06% | 4 | 1.40% |
alan stern | alan stern | 7 | 0.06% | 1 | 0.35% |
cyrill gorcunov | cyrill gorcunov | 7 | 0.06% | 1 | 0.35% |
mike pecovnik | mike pecovnik | 6 | 0.05% | 1 | 0.35% |
masatake yamato | masatake yamato | 6 | 0.05% | 1 | 0.35% |
martin murray | martin murray | 6 | 0.05% | 1 | 0.35% |
linus torvalds | linus torvalds | 5 | 0.04% | 3 | 1.05% |
octavian purdila | octavian purdila | 5 | 0.04% | 1 | 0.35% |
christoph hellwig | christoph hellwig | 5 | 0.04% | 1 | 0.35% |
arjan van de ven | arjan van de ven | 5 | 0.04% | 2 | 0.70% |
rami rosen | rami rosen | 5 | 0.04% | 1 | 0.35% |
dmitry ivanov | dmitry ivanov | 4 | 0.03% | 1 | 0.35% |
art haas | art haas | 4 | 0.03% | 1 | 0.35% |
thomas gleixner | thomas gleixner | 4 | 0.03% | 1 | 0.35% |
thomas goff | thomas goff | 3 | 0.03% | 1 | 0.35% |
mel gorman | mel gorman | 3 | 0.03% | 1 | 0.35% |
eric paris | eric paris | 3 | 0.03% | 1 | 0.35% |
ilpo jarvinen | ilpo jarvinen | 3 | 0.03% | 1 | 0.35% |
panagiotis issaris* | panagiotis issaris* | 3 | 0.03% | 1 | 0.35% |
randy dunlap | randy dunlap | 3 | 0.03% | 1 | 0.35% |
varka bhadram | varka bhadram | 3 | 0.03% | 1 | 0.35% |
lai jiangshan | lai jiangshan | 2 | 0.02% | 1 | 0.35% |
hong zhi guo | hong zhi guo | 2 | 0.02% | 1 | 0.35% |
bob copeland | bob copeland | 2 | 0.02% | 1 | 0.35% |
ben pfaff | ben pfaff | 1 | 0.01% | 1 | 0.35% |
adrian bunk | adrian bunk | 1 | 0.01% | 1 | 0.35% |
dan carpenter | dan carpenter | 1 | 0.01% | 1 | 0.35% |
john fastabend | john fastabend | 1 | 0.01% | 1 | 0.35% |
philippe de muyter | philippe de muyter | 1 | 0.01% | 1 | 0.35% |
john levon | john levon | 1 | 0.01% | 1 | 0.35% |
| Total | 11977 | 100.00% | 286 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.