diff options
Diffstat (limited to 'include/linux/net.h')
-rw-r--r-- | include/linux/net.h | 91 |
1 files changed, 7 insertions, 84 deletions
diff --git a/include/linux/net.h b/include/linux/net.h index 529a0931711d..5e8083cacc8b 100644 --- a/include/linux/net.h +++ b/include/linux/net.h | |||
@@ -41,6 +41,7 @@ | |||
41 | #define SYS_SENDMSG 16 /* sys_sendmsg(2) */ | 41 | #define SYS_SENDMSG 16 /* sys_sendmsg(2) */ |
42 | #define SYS_RECVMSG 17 /* sys_recvmsg(2) */ | 42 | #define SYS_RECVMSG 17 /* sys_recvmsg(2) */ |
43 | #define SYS_ACCEPT4 18 /* sys_accept4(2) */ | 43 | #define SYS_ACCEPT4 18 /* sys_accept4(2) */ |
44 | #define SYS_RECVMMSG 19 /* sys_recvmmsg(2) */ | ||
44 | 45 | ||
45 | typedef enum { | 46 | typedef enum { |
46 | SS_FREE = 0, /* not allocated */ | 47 | SS_FREE = 0, /* not allocated */ |
@@ -198,9 +199,13 @@ struct proto_ops { | |||
198 | struct pipe_inode_info *pipe, size_t len, unsigned int flags); | 199 | struct pipe_inode_info *pipe, size_t len, unsigned int flags); |
199 | }; | 200 | }; |
200 | 201 | ||
202 | #define DECLARE_SOCKADDR(type, dst, src) \ | ||
203 | type dst = ({ __sockaddr_check_size(sizeof(*dst)); (type) src; }) | ||
204 | |||
201 | struct net_proto_family { | 205 | struct net_proto_family { |
202 | int family; | 206 | int family; |
203 | int (*create)(struct net *net, struct socket *sock, int protocol); | 207 | int (*create)(struct net *net, struct socket *sock, |
208 | int protocol, int kern); | ||
204 | struct module *owner; | 209 | struct module *owner; |
205 | }; | 210 | }; |
206 | 211 | ||
@@ -263,89 +268,6 @@ extern int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg); | |||
263 | extern int kernel_sock_shutdown(struct socket *sock, | 268 | extern int kernel_sock_shutdown(struct socket *sock, |
264 | enum sock_shutdown_cmd how); | 269 | enum sock_shutdown_cmd how); |
265 | 270 | ||
266 | #ifndef CONFIG_SMP | ||
267 | #define SOCKOPS_WRAPPED(name) name | ||
268 | #define SOCKOPS_WRAP(name, fam) | ||
269 | #else | ||
270 | |||
271 | #define SOCKOPS_WRAPPED(name) __unlocked_##name | ||
272 | |||
273 | #define SOCKCALL_WRAP(name, call, parms, args) \ | ||
274 | static int __lock_##name##_##call parms \ | ||
275 | { \ | ||
276 | int ret; \ | ||
277 | lock_kernel(); \ | ||
278 | ret = __unlocked_##name##_ops.call args ;\ | ||
279 | unlock_kernel(); \ | ||
280 | return ret; \ | ||
281 | } | ||
282 | |||
283 | #define SOCKCALL_UWRAP(name, call, parms, args) \ | ||
284 | static unsigned int __lock_##name##_##call parms \ | ||
285 | { \ | ||
286 | int ret; \ | ||
287 | lock_kernel(); \ | ||
288 | ret = __unlocked_##name##_ops.call args ;\ | ||
289 | unlock_kernel(); \ | ||
290 | return ret; \ | ||
291 | } | ||
292 | |||
293 | |||
294 | #define SOCKOPS_WRAP(name, fam) \ | ||
295 | SOCKCALL_WRAP(name, release, (struct socket *sock), (sock)) \ | ||
296 | SOCKCALL_WRAP(name, bind, (struct socket *sock, struct sockaddr *uaddr, int addr_len), \ | ||
297 | (sock, uaddr, addr_len)) \ | ||
298 | SOCKCALL_WRAP(name, connect, (struct socket *sock, struct sockaddr * uaddr, \ | ||
299 | int addr_len, int flags), \ | ||
300 | (sock, uaddr, addr_len, flags)) \ | ||
301 | SOCKCALL_WRAP(name, socketpair, (struct socket *sock1, struct socket *sock2), \ | ||
302 | (sock1, sock2)) \ | ||
303 | SOCKCALL_WRAP(name, accept, (struct socket *sock, struct socket *newsock, \ | ||
304 | int flags), (sock, newsock, flags)) \ | ||
305 | SOCKCALL_WRAP(name, getname, (struct socket *sock, struct sockaddr *uaddr, \ | ||
306 | int *addr_len, int peer), (sock, uaddr, addr_len, peer)) \ | ||
307 | SOCKCALL_UWRAP(name, poll, (struct file *file, struct socket *sock, struct poll_table_struct *wait), \ | ||
308 | (file, sock, wait)) \ | ||
309 | SOCKCALL_WRAP(name, ioctl, (struct socket *sock, unsigned int cmd, \ | ||
310 | unsigned long arg), (sock, cmd, arg)) \ | ||
311 | SOCKCALL_WRAP(name, compat_ioctl, (struct socket *sock, unsigned int cmd, \ | ||
312 | unsigned long arg), (sock, cmd, arg)) \ | ||
313 | SOCKCALL_WRAP(name, listen, (struct socket *sock, int len), (sock, len)) \ | ||
314 | SOCKCALL_WRAP(name, shutdown, (struct socket *sock, int flags), (sock, flags)) \ | ||
315 | SOCKCALL_WRAP(name, setsockopt, (struct socket *sock, int level, int optname, \ | ||
316 | char __user *optval, unsigned int optlen), (sock, level, optname, optval, optlen)) \ | ||
317 | SOCKCALL_WRAP(name, getsockopt, (struct socket *sock, int level, int optname, \ | ||
318 | char __user *optval, int __user *optlen), (sock, level, optname, optval, optlen)) \ | ||
319 | SOCKCALL_WRAP(name, sendmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t len), \ | ||
320 | (iocb, sock, m, len)) \ | ||
321 | SOCKCALL_WRAP(name, recvmsg, (struct kiocb *iocb, struct socket *sock, struct msghdr *m, size_t len, int flags), \ | ||
322 | (iocb, sock, m, len, flags)) \ | ||
323 | SOCKCALL_WRAP(name, mmap, (struct file *file, struct socket *sock, struct vm_area_struct *vma), \ | ||
324 | (file, sock, vma)) \ | ||
325 | \ | ||
326 | static const struct proto_ops name##_ops = { \ | ||
327 | .family = fam, \ | ||
328 | .owner = THIS_MODULE, \ | ||
329 | .release = __lock_##name##_release, \ | ||
330 | .bind = __lock_##name##_bind, \ | ||
331 | .connect = __lock_##name##_connect, \ | ||
332 | .socketpair = __lock_##name##_socketpair, \ | ||
333 | .accept = __lock_##name##_accept, \ | ||
334 | .getname = __lock_##name##_getname, \ | ||
335 | .poll = __lock_##name##_poll, \ | ||
336 | .ioctl = __lock_##name##_ioctl, \ | ||
337 | .compat_ioctl = __lock_##name##_compat_ioctl, \ | ||
338 | .listen = __lock_##name##_listen, \ | ||
339 | .shutdown = __lock_##name##_shutdown, \ | ||
340 | .setsockopt = __lock_##name##_setsockopt, \ | ||
341 | .getsockopt = __lock_##name##_getsockopt, \ | ||
342 | .sendmsg = __lock_##name##_sendmsg, \ | ||
343 | .recvmsg = __lock_##name##_recvmsg, \ | ||
344 | .mmap = __lock_##name##_mmap, \ | ||
345 | }; | ||
346 | |||
347 | #endif | ||
348 | |||
349 | #define MODULE_ALIAS_NETPROTO(proto) \ | 271 | #define MODULE_ALIAS_NETPROTO(proto) \ |
350 | MODULE_ALIAS("net-pf-" __stringify(proto)) | 272 | MODULE_ALIAS("net-pf-" __stringify(proto)) |
351 | 273 | ||
@@ -358,6 +280,7 @@ static const struct proto_ops name##_ops = { \ | |||
358 | 280 | ||
359 | #ifdef CONFIG_SYSCTL | 281 | #ifdef CONFIG_SYSCTL |
360 | #include <linux/sysctl.h> | 282 | #include <linux/sysctl.h> |
283 | #include <linux/ratelimit.h> | ||
361 | extern struct ratelimit_state net_ratelimit_state; | 284 | extern struct ratelimit_state net_ratelimit_state; |
362 | #endif | 285 | #endif |
363 | 286 | ||