af_netlink.c (9a64e8e0ace51b309fdcff4b4754b3649250382a) | af_netlink.c (a31f2d17b331db970259e875b7223d3aba7e3821) |
---|---|
1/* 2 * NETLINK Kernel-user communication protocol. 3 * 4 * Authors: Alan Cox <alan@lxorguk.ukuu.org.uk> 5 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 1489 unchanged lines hidden (view full) --- 1498 1499/* 1500 * We export these functions to other modules. They provide a 1501 * complete set of kernel non-blocking support for message 1502 * queueing. 1503 */ 1504 1505struct sock * | 1/* 2 * NETLINK Kernel-user communication protocol. 3 * 4 * Authors: Alan Cox <alan@lxorguk.ukuu.org.uk> 5 * Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License --- 1489 unchanged lines hidden (view full) --- 1498 1499/* 1500 * We export these functions to other modules. They provide a 1501 * complete set of kernel non-blocking support for message 1502 * queueing. 1503 */ 1504 1505struct sock * |
1506netlink_kernel_create(struct net *net, int unit, unsigned int groups, 1507 void (*input)(struct sk_buff *skb), 1508 struct mutex *cb_mutex, struct module *module) | 1506netlink_kernel_create(struct net *net, int unit, 1507 struct module *module, 1508 struct netlink_kernel_cfg *cfg) |
1509{ 1510 struct socket *sock; 1511 struct sock *sk; 1512 struct netlink_sock *nlk; 1513 struct listeners *listeners = NULL; | 1509{ 1510 struct socket *sock; 1511 struct sock *sk; 1512 struct netlink_sock *nlk; 1513 struct listeners *listeners = NULL; |
1514 struct mutex *cb_mutex = cfg ? cfg->cb_mutex : NULL; 1515 unsigned int groups; |
|
1514 1515 BUG_ON(!nl_table); 1516 1517 if (unit < 0 || unit >= MAX_LINKS) 1518 return NULL; 1519 1520 if (sock_create_lite(PF_NETLINK, SOCK_DGRAM, unit, &sock)) 1521 return NULL; --- 5 unchanged lines hidden (view full) --- 1527 */ 1528 1529 if (__netlink_create(&init_net, sock, cb_mutex, unit) < 0) 1530 goto out_sock_release_nosk; 1531 1532 sk = sock->sk; 1533 sk_change_net(sk, net); 1534 | 1516 1517 BUG_ON(!nl_table); 1518 1519 if (unit < 0 || unit >= MAX_LINKS) 1520 return NULL; 1521 1522 if (sock_create_lite(PF_NETLINK, SOCK_DGRAM, unit, &sock)) 1523 return NULL; --- 5 unchanged lines hidden (view full) --- 1529 */ 1530 1531 if (__netlink_create(&init_net, sock, cb_mutex, unit) < 0) 1532 goto out_sock_release_nosk; 1533 1534 sk = sock->sk; 1535 sk_change_net(sk, net); 1536 |
1535 if (groups < 32) | 1537 if (!cfg || cfg->groups < 32) |
1536 groups = 32; | 1538 groups = 32; |
1539 else 1540 groups = cfg->groups; |
|
1537 1538 listeners = kzalloc(sizeof(*listeners) + NLGRPSZ(groups), GFP_KERNEL); 1539 if (!listeners) 1540 goto out_sock_release; 1541 1542 sk->sk_data_ready = netlink_data_ready; | 1541 1542 listeners = kzalloc(sizeof(*listeners) + NLGRPSZ(groups), GFP_KERNEL); 1543 if (!listeners) 1544 goto out_sock_release; 1545 1546 sk->sk_data_ready = netlink_data_ready; |
1543 if (input) 1544 nlk_sk(sk)->netlink_rcv = input; | 1547 if (cfg && cfg->input) 1548 nlk_sk(sk)->netlink_rcv = cfg->input; |
1545 1546 if (netlink_insert(sk, net, 0)) 1547 goto out_sock_release; 1548 1549 nlk = nlk_sk(sk); 1550 nlk->flags |= NETLINK_KERNEL_SOCKET; 1551 1552 netlink_table_grab(); --- 639 unchanged lines hidden --- | 1549 1550 if (netlink_insert(sk, net, 0)) 1551 goto out_sock_release; 1552 1553 nlk = nlk_sk(sk); 1554 nlk->flags |= NETLINK_KERNEL_SOCKET; 1555 1556 netlink_table_grab(); --- 639 unchanged lines hidden --- |