Commit 8c3c447b authored by Paolo Abeni's avatar Paolo Abeni Committed by David S. Miller

net: use indirect calls helpers at the socket layer

This avoids an indirect call per {send,recv}msg syscall in
the common (IPv6 or IPv4 socket) case.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 97ff7ffb
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/xattr.h> #include <linux/xattr.h>
#include <linux/nospec.h> #include <linux/nospec.h>
#include <linux/indirect_call_wrapper.h>
#include <linux/uaccess.h> #include <linux/uaccess.h>
#include <asm/unistd.h> #include <asm/unistd.h>
...@@ -108,6 +109,13 @@ ...@@ -108,6 +109,13 @@
#include <net/busy_poll.h> #include <net/busy_poll.h>
#include <linux/errqueue.h> #include <linux/errqueue.h>
/* proto_ops for ipv4 and ipv6 use the same {recv,send}msg function */
#if IS_ENABLED(CONFIG_INET)
#define INDIRECT_CALL_INET4(f, f1, ...) INDIRECT_CALL_1(f, f1, __VA_ARGS__)
#else
#define INDIRECT_CALL_INET4(f, f1, ...) f(__VA_ARGS__)
#endif
#ifdef CONFIG_NET_RX_BUSY_POLL #ifdef CONFIG_NET_RX_BUSY_POLL
unsigned int sysctl_net_busy_read __read_mostly; unsigned int sysctl_net_busy_read __read_mostly;
unsigned int sysctl_net_busy_poll __read_mostly; unsigned int sysctl_net_busy_poll __read_mostly;
...@@ -645,10 +653,12 @@ EXPORT_SYMBOL(__sock_tx_timestamp); ...@@ -645,10 +653,12 @@ EXPORT_SYMBOL(__sock_tx_timestamp);
* Sends @msg through @sock, passing through LSM. * Sends @msg through @sock, passing through LSM.
* Returns the number of bytes sent, or an error code. * Returns the number of bytes sent, or an error code.
*/ */
INDIRECT_CALLABLE_DECLARE(int inet_sendmsg(struct socket *, struct msghdr *,
size_t));
static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg) static inline int sock_sendmsg_nosec(struct socket *sock, struct msghdr *msg)
{ {
int ret = sock->ops->sendmsg(sock, msg, msg_data_left(msg)); int ret = INDIRECT_CALL_INET4(sock->ops->sendmsg, inet_sendmsg, sock,
msg, msg_data_left(msg));
BUG_ON(ret == -EIOCBQUEUED); BUG_ON(ret == -EIOCBQUEUED);
return ret; return ret;
} }
...@@ -874,11 +884,13 @@ EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops); ...@@ -874,11 +884,13 @@ EXPORT_SYMBOL_GPL(__sock_recv_ts_and_drops);
* Receives @msg from @sock, passing through LSM. Returns the total number * Receives @msg from @sock, passing through LSM. Returns the total number
* of bytes received, or an error. * of bytes received, or an error.
*/ */
INDIRECT_CALLABLE_DECLARE(int inet_recvmsg(struct socket *, struct msghdr *,
size_t , int ));
static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg, static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
int flags) int flags)
{ {
return sock->ops->recvmsg(sock, msg, msg_data_left(msg), flags); return INDIRECT_CALL_INET4(sock->ops->recvmsg, inet_recvmsg, sock, msg,
msg_data_left(msg), flags);
} }
int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags) int sock_recvmsg(struct socket *sock, struct msghdr *msg, int flags)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment