mm: migrate: Account a transhuge page properly when rate limiting
[deliverable/linux.git] / include / linux / netlink.h
CommitLineData
1da177e4
LT
1#ifndef __LINUX_NETLINK_H
2#define __LINUX_NETLINK_H
3
1da177e4
LT
4
5#include <linux/capability.h>
6#include <linux/skbuff.h>
abb17e6c 7#include <linux/export.h>
dbe9a417 8#include <net/scm.h>
607ca46e 9#include <uapi/linux/netlink.h>
1da177e4 10
56b49f4b
OW
11struct net;
12
b529ccf2
ACM
13static inline struct nlmsghdr *nlmsg_hdr(const struct sk_buff *skb)
14{
15 return (struct nlmsghdr *)skb->data;
16}
17
d94d9fee 18struct netlink_skb_parms {
dbe9a417 19 struct scm_creds creds; /* Skb credentials */
15e47304 20 __u32 portid;
d629b836 21 __u32 dst_group;
3fbc2905 22 struct sock *ssk;
1da177e4
LT
23};
24
25#define NETLINK_CB(skb) (*(struct netlink_skb_parms*)&((skb)->cb))
26#define NETLINK_CREDS(skb) (&NETLINK_CB((skb)).creds)
27
28
d136f1bd
JB
29extern void netlink_table_grab(void);
30extern void netlink_table_ungrab(void);
31
9785e10a
PNA
32#define NL_CFG_F_NONROOT_RECV (1 << 0)
33#define NL_CFG_F_NONROOT_SEND (1 << 1)
34
a31f2d17
PNA
35/* optional Netlink kernel configuration parameters */
36struct netlink_kernel_cfg {
37 unsigned int groups;
c9d2ea96 38 unsigned int flags;
a31f2d17
PNA
39 void (*input)(struct sk_buff *skb);
40 struct mutex *cb_mutex;
03292745 41 void (*bind)(int group);
a31f2d17
PNA
42};
43
9f00d977
PNA
44extern struct sock *__netlink_kernel_create(struct net *net, int unit,
45 struct module *module,
46 struct netlink_kernel_cfg *cfg);
47static inline struct sock *
48netlink_kernel_create(struct net *net, int unit, struct netlink_kernel_cfg *cfg)
49{
50 return __netlink_kernel_create(net, unit, THIS_MODULE, cfg);
51}
52
b7c6ba6e 53extern void netlink_kernel_release(struct sock *sk);
d136f1bd 54extern int __netlink_change_ngroups(struct sock *sk, unsigned int groups);
b4ff4f04 55extern int netlink_change_ngroups(struct sock *sk, unsigned int groups);
b8273570 56extern void __netlink_clear_multicast_users(struct sock *sk, unsigned int group);
84659eb5 57extern void netlink_clear_multicast_users(struct sock *sk, unsigned int group);
1da177e4 58extern void netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh, int err);
4277a083 59extern int netlink_has_listeners(struct sock *sk, unsigned int group);
15e47304
EB
60extern int netlink_unicast(struct sock *ssk, struct sk_buff *skb, __u32 portid, int nonblock);
61extern int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, __u32 portid,
dd0fc66f 62 __u32 group, gfp_t allocation);
910a7e90 63extern int netlink_broadcast_filtered(struct sock *ssk, struct sk_buff *skb,
15e47304 64 __u32 portid, __u32 group, gfp_t allocation,
910a7e90
EB
65 int (*filter)(struct sock *dsk, struct sk_buff *skb, void *data),
66 void *filter_data);
15e47304 67extern int netlink_set_err(struct sock *ssk, __u32 portid, __u32 group, int code);
1da177e4
LT
68extern int netlink_register_notifier(struct notifier_block *nb);
69extern int netlink_unregister_notifier(struct notifier_block *nb);
70
71/* finegrained unicast helpers: */
72struct sock *netlink_getsockbyfilp(struct file *filp);
9457afee 73int netlink_attachskb(struct sock *sk, struct sk_buff *skb,
c3d8d1e3 74 long *timeo, struct sock *ssk);
1da177e4 75void netlink_detachskb(struct sock *sk, struct sk_buff *skb);
7ee015e0 76int netlink_sendskb(struct sock *sk, struct sk_buff *skb);
1da177e4
LT
77
78/*
79 * skb should fit one page. This choice is good for headerless malloc.
fc910a27
DM
80 * But we should limit to 8K so that userspace does not have to
81 * use enormous buffer sizes on recvmsg() calls just to avoid
82 * MSG_TRUNC when PAGE_SIZE is very large.
1da177e4 83 */
fc910a27
DM
84#if PAGE_SIZE < 8192UL
85#define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(PAGE_SIZE)
86#else
87#define NLMSG_GOODSIZE SKB_WITH_OVERHEAD(8192UL)
88#endif
89
339bf98f 90#define NLMSG_DEFAULT_SIZE (NLMSG_GOODSIZE - NLMSG_HDRLEN)
1da177e4
LT
91
92
d94d9fee 93struct netlink_callback {
3a6c2b41
PM
94 struct sk_buff *skb;
95 const struct nlmsghdr *nlh;
96 int (*dump)(struct sk_buff * skb,
97 struct netlink_callback *cb);
98 int (*done)(struct netlink_callback *cb);
7175c883 99 void *data;
6dc878a8
G
100 /* the module that dump function belong to */
101 struct module *module;
c7ac8679
GR
102 u16 family;
103 u16 min_dump_alloc;
670dc283 104 unsigned int prev_seq, seq;
3a6c2b41 105 long args[6];
1da177e4
LT
106};
107
d94d9fee 108struct netlink_notify {
b4b51029 109 struct net *net;
15e47304 110 int portid;
1da177e4
LT
111 int protocol;
112};
113
a46621a3 114struct nlmsghdr *
15e47304 115__nlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, int type, int len, int flags);
1da177e4 116
80d326fa
PNA
117struct netlink_dump_control {
118 int (*dump)(struct sk_buff *skb, struct netlink_callback *);
6dc878a8 119 int (*done)(struct netlink_callback *);
7175c883 120 void *data;
6dc878a8 121 struct module *module;
80d326fa
PNA
122 u16 min_dump_alloc;
123};
124
6dc878a8
G
125extern int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
126 const struct nlmsghdr *nlh,
127 struct netlink_dump_control *control);
128static inline int netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
129 const struct nlmsghdr *nlh,
130 struct netlink_dump_control *control)
131{
132 if (!control->module)
133 control->module = THIS_MODULE;
134
135 return __netlink_dump_start(ssk, skb, nlh, control);
136}
1da177e4 137
1da177e4 138#endif /* __LINUX_NETLINK_H */
This page took 1.42008 seconds and 5 git commands to generate.