diff options
-rw-r--r-- | include/trace/socket.h | 26 | ||||
-rw-r--r-- | net/socket.c | 11 |
2 files changed, 37 insertions, 0 deletions
diff --git a/include/trace/socket.h b/include/trace/socket.h new file mode 100644 index 00000000000..228b5a7c944 --- /dev/null +++ b/include/trace/socket.h @@ -0,0 +1,26 @@ +#ifndef _TRACE_SOCKET_H +#define _TRACE_SOCKET_H + +#include <net/sock.h> +#include <linux/tracepoint.h> + +DECLARE_TRACE(socket_sendmsg, + TP_PROTO(struct socket *sock, struct msghdr *msg, size_t size, int ret), + TP_ARGS(sock, msg, size, ret)); +DECLARE_TRACE(socket_recvmsg, + TP_PROTO(struct socket *sock, struct msghdr *msg, size_t size, int flags, + int ret), + TP_ARGS(sock, msg, size, flags, ret)); +DECLARE_TRACE(socket_create, + TP_PROTO(struct socket *sock, int fd), + TP_ARGS(sock, fd)); +/* + * socket_call + * + * TODO : This tracepoint should be expanded to cover each element of the + * switch in sys_socketcall(). + */ +DECLARE_TRACE(socket_call, + TP_PROTO(int call, unsigned long a0), + TP_ARGS(call, a0)); +#endif diff --git a/net/socket.c b/net/socket.c index ac2219f90d5..319a3b8f241 100644 --- a/net/socket.c +++ b/net/socket.c @@ -98,6 +98,7 @@ #include <net/sock.h> #include <linux/netfilter.h> +#include <trace/socket.h> #include <linux/if_tun.h> #include <linux/ipv6_route.h> @@ -164,6 +165,11 @@ static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly; static DEFINE_PER_CPU(int, sockets_in_use); +DEFINE_TRACE(socket_sendmsg); +DEFINE_TRACE(socket_recvmsg); +DEFINE_TRACE(socket_create); +DEFINE_TRACE(socket_call); + /* * Support routines. * Move socket addresses back and forth across the kernel/user @@ -578,6 +584,7 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) ret = __sock_sendmsg(&iocb, sock, msg, size); if (-EIOCBQUEUED == ret) ret = wait_on_sync_kiocb(&iocb); + trace_socket_sendmsg(sock, msg, size, ret); return ret; } EXPORT_SYMBOL(sock_sendmsg); @@ -714,6 +721,7 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg, ret = __sock_recvmsg(&iocb, sock, msg, size, flags); if (-EIOCBQUEUED == ret) ret = wait_on_sync_kiocb(&iocb); + trace_socket_recvmsg(sock, msg, size, flags, ret); return ret; } EXPORT_SYMBOL(sock_recvmsg); @@ -1314,6 +1322,7 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol) if (retval < 0) goto out_release; + trace_socket_create(sock, retval); out: /* It may be already another descriptor 8) Not kernel problem. */ return retval; @@ -2249,6 +2258,8 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args) a0 = a[0]; a1 = a[1]; + trace_socket_call(call, a0); + switch (call) { case SYS_SOCKET: err = sys_socket(a0, a1, a[2]); |