Message ID | 20210207151426.804348-1-arseny.krasnov@kaspersky.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | virtio/vsock: introduce SOCK_SEQPACKET support | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | fail | Series longer than 15 patches |
netdev/tree_selection | success | Guessed tree name to be net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 1 maintainers not CCed: alex.popov@linux.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 161 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Sun, Feb 07, 2021 at 06:14:23PM +0300, Arseny Krasnov wrote: >This prepares af_vsock.c for SEQPACKET support: some functions such >as setsockopt(), getsockopt(), connect(), recvmsg(), sendmsg() are >shared between both types of sockets, so rename them in general >manner. > >Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com> >--- > net/vmw_vsock/af_vsock.c | 64 +++++++++++++++++++++------------------- > 1 file changed, 34 insertions(+), 30 deletions(-) This patch LGTM: Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Thanks, Stefano > >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index 6894f21dc147..f4fabec50650 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -604,8 +604,8 @@ static void vsock_pending_work(struct work_struct *work) > > /**** SOCKET OPERATIONS ****/ > >-static int __vsock_bind_stream(struct vsock_sock *vsk, >- struct sockaddr_vm *addr) >+static int __vsock_bind_connectible(struct vsock_sock *vsk, >+ struct sockaddr_vm *addr) > { > static u32 port; > struct sockaddr_vm new_addr; >@@ -685,7 +685,7 @@ static int __vsock_bind(struct sock *sk, struct sockaddr_vm *addr) > switch (sk->sk_socket->type) { > case SOCK_STREAM: > spin_lock_bh(&vsock_table_lock); >- retval = __vsock_bind_stream(vsk, addr); >+ retval = __vsock_bind_connectible(vsk, addr); > spin_unlock_bh(&vsock_table_lock); > break; > >@@ -767,6 +767,11 @@ static struct sock *__vsock_create(struct net *net, > return sk; > } > >+static bool sock_type_connectible(u16 type) >+{ >+ return type == SOCK_STREAM; >+} >+ > static void __vsock_release(struct sock *sk, int level) > { > if (sk) { >@@ -785,7 +790,7 @@ static void __vsock_release(struct sock *sk, int level) > > if (vsk->transport) > vsk->transport->release(vsk); >- else if (sk->sk_type == SOCK_STREAM) >+ else if (sock_type_connectible(sk->sk_type)) > vsock_remove_sock(vsk); > > sock_orphan(sk); >@@ -945,7 +950,7 @@ static int vsock_shutdown(struct socket *sock, int mode) > sk = sock->sk; > if (sock->state == SS_UNCONNECTED) { > err = -ENOTCONN; >- if (sk->sk_type == SOCK_STREAM) >+ if (sock_type_connectible(sk->sk_type)) > return err; > } else { > sock->state = SS_DISCONNECTING; >@@ -960,7 +965,7 @@ static int vsock_shutdown(struct socket *sock, int mode) > sk->sk_state_change(sk); > release_sock(sk); > >- if (sk->sk_type == SOCK_STREAM) { >+ if (sock_type_connectible(sk->sk_type)) { > sock_reset_flag(sk, SOCK_DONE); > vsock_send_shutdown(sk, mode); > } >@@ -1013,7 +1018,7 @@ static __poll_t vsock_poll(struct file *file, struct socket *sock, > if (!(sk->sk_shutdown & SEND_SHUTDOWN)) > mask |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND; > >- } else if (sock->type == SOCK_STREAM) { >+ } else if (sock_type_connectible(sk->sk_type)) { > const struct vsock_transport *transport; > > lock_sock(sk); >@@ -1263,8 +1268,8 @@ static void vsock_connect_timeout(struct work_struct *work) > sock_put(sk); > } > >-static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr, >- int addr_len, int flags) >+static int vsock_connect(struct socket *sock, struct sockaddr *addr, >+ int addr_len, int flags) > { > int err; > struct sock *sk; >@@ -1414,7 +1419,7 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags, > > lock_sock(listener); > >- if (sock->type != SOCK_STREAM) { >+ if (!sock_type_connectible(sock->type)) { > err = -EOPNOTSUPP; > goto out; > } >@@ -1491,7 +1496,7 @@ static int vsock_listen(struct socket *sock, int backlog) > > lock_sock(sk); > >- if (sock->type != SOCK_STREAM) { >+ if (!sock_type_connectible(sk->sk_type)) { > err = -EOPNOTSUPP; > goto out; > } >@@ -1535,11 +1540,11 @@ static void vsock_update_buffer_size(struct vsock_sock *vsk, > vsk->buffer_size = val; > } > >-static int vsock_stream_setsockopt(struct socket *sock, >- int level, >- int optname, >- sockptr_t optval, >- unsigned int optlen) >+static int vsock_connectible_setsockopt(struct socket *sock, >+ int level, >+ int optname, >+ sockptr_t optval, >+ unsigned int optlen) > { > int err; > struct sock *sk; >@@ -1617,10 +1622,10 @@ static int vsock_stream_setsockopt(struct socket *sock, > return err; > } > >-static int vsock_stream_getsockopt(struct socket *sock, >- int level, int optname, >- char __user *optval, >- int __user *optlen) >+static int vsock_connectible_getsockopt(struct socket *sock, >+ int level, int optname, >+ char __user *optval, >+ int __user *optlen) > { > int err; > int len; >@@ -1688,8 +1693,8 @@ static int vsock_stream_getsockopt(struct socket *sock, > return 0; > } > >-static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, >- size_t len) >+static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, >+ size_t len) > { > struct sock *sk; > struct vsock_sock *vsk; >@@ -1828,10 +1833,9 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, > return err; > } > >- > static int >-vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, >- int flags) >+vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, >+ int flags) > { > struct sock *sk; > struct vsock_sock *vsk; >@@ -2007,7 +2011,7 @@ static const struct proto_ops vsock_stream_ops = { > .owner = THIS_MODULE, > .release = vsock_release, > .bind = vsock_bind, >- .connect = vsock_stream_connect, >+ .connect = vsock_connect, > .socketpair = sock_no_socketpair, > .accept = vsock_accept, > .getname = vsock_getname, >@@ -2015,10 +2019,10 @@ static const struct proto_ops vsock_stream_ops = { > .ioctl = sock_no_ioctl, > .listen = vsock_listen, > .shutdown = vsock_shutdown, >- .setsockopt = vsock_stream_setsockopt, >- .getsockopt = vsock_stream_getsockopt, >- .sendmsg = vsock_stream_sendmsg, >- .recvmsg = vsock_stream_recvmsg, >+ .setsockopt = vsock_connectible_setsockopt, >+ .getsockopt = vsock_connectible_getsockopt, >+ .sendmsg = vsock_connectible_sendmsg, >+ .recvmsg = vsock_connectible_recvmsg, > .mmap = sock_no_mmap, > .sendpage = sock_no_sendpage, > }; >-- >2.25.1 >
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 6894f21dc147..f4fabec50650 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -604,8 +604,8 @@ static void vsock_pending_work(struct work_struct *work) /**** SOCKET OPERATIONS ****/ -static int __vsock_bind_stream(struct vsock_sock *vsk, - struct sockaddr_vm *addr) +static int __vsock_bind_connectible(struct vsock_sock *vsk, + struct sockaddr_vm *addr) { static u32 port; struct sockaddr_vm new_addr; @@ -685,7 +685,7 @@ static int __vsock_bind(struct sock *sk, struct sockaddr_vm *addr) switch (sk->sk_socket->type) { case SOCK_STREAM: spin_lock_bh(&vsock_table_lock); - retval = __vsock_bind_stream(vsk, addr); + retval = __vsock_bind_connectible(vsk, addr); spin_unlock_bh(&vsock_table_lock); break; @@ -767,6 +767,11 @@ static struct sock *__vsock_create(struct net *net, return sk; } +static bool sock_type_connectible(u16 type) +{ + return type == SOCK_STREAM; +} + static void __vsock_release(struct sock *sk, int level) { if (sk) { @@ -785,7 +790,7 @@ static void __vsock_release(struct sock *sk, int level) if (vsk->transport) vsk->transport->release(vsk); - else if (sk->sk_type == SOCK_STREAM) + else if (sock_type_connectible(sk->sk_type)) vsock_remove_sock(vsk); sock_orphan(sk); @@ -945,7 +950,7 @@ static int vsock_shutdown(struct socket *sock, int mode) sk = sock->sk; if (sock->state == SS_UNCONNECTED) { err = -ENOTCONN; - if (sk->sk_type == SOCK_STREAM) + if (sock_type_connectible(sk->sk_type)) return err; } else { sock->state = SS_DISCONNECTING; @@ -960,7 +965,7 @@ static int vsock_shutdown(struct socket *sock, int mode) sk->sk_state_change(sk); release_sock(sk); - if (sk->sk_type == SOCK_STREAM) { + if (sock_type_connectible(sk->sk_type)) { sock_reset_flag(sk, SOCK_DONE); vsock_send_shutdown(sk, mode); } @@ -1013,7 +1018,7 @@ static __poll_t vsock_poll(struct file *file, struct socket *sock, if (!(sk->sk_shutdown & SEND_SHUTDOWN)) mask |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND; - } else if (sock->type == SOCK_STREAM) { + } else if (sock_type_connectible(sk->sk_type)) { const struct vsock_transport *transport; lock_sock(sk); @@ -1263,8 +1268,8 @@ static void vsock_connect_timeout(struct work_struct *work) sock_put(sk); } -static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr, - int addr_len, int flags) +static int vsock_connect(struct socket *sock, struct sockaddr *addr, + int addr_len, int flags) { int err; struct sock *sk; @@ -1414,7 +1419,7 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags, lock_sock(listener); - if (sock->type != SOCK_STREAM) { + if (!sock_type_connectible(sock->type)) { err = -EOPNOTSUPP; goto out; } @@ -1491,7 +1496,7 @@ static int vsock_listen(struct socket *sock, int backlog) lock_sock(sk); - if (sock->type != SOCK_STREAM) { + if (!sock_type_connectible(sk->sk_type)) { err = -EOPNOTSUPP; goto out; } @@ -1535,11 +1540,11 @@ static void vsock_update_buffer_size(struct vsock_sock *vsk, vsk->buffer_size = val; } -static int vsock_stream_setsockopt(struct socket *sock, - int level, - int optname, - sockptr_t optval, - unsigned int optlen) +static int vsock_connectible_setsockopt(struct socket *sock, + int level, + int optname, + sockptr_t optval, + unsigned int optlen) { int err; struct sock *sk; @@ -1617,10 +1622,10 @@ static int vsock_stream_setsockopt(struct socket *sock, return err; } -static int vsock_stream_getsockopt(struct socket *sock, - int level, int optname, - char __user *optval, - int __user *optlen) +static int vsock_connectible_getsockopt(struct socket *sock, + int level, int optname, + char __user *optval, + int __user *optlen) { int err; int len; @@ -1688,8 +1693,8 @@ static int vsock_stream_getsockopt(struct socket *sock, return 0; } -static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, - size_t len) +static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, + size_t len) { struct sock *sk; struct vsock_sock *vsk; @@ -1828,10 +1833,9 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, return err; } - static int -vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, - int flags) +vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, + int flags) { struct sock *sk; struct vsock_sock *vsk; @@ -2007,7 +2011,7 @@ static const struct proto_ops vsock_stream_ops = { .owner = THIS_MODULE, .release = vsock_release, .bind = vsock_bind, - .connect = vsock_stream_connect, + .connect = vsock_connect, .socketpair = sock_no_socketpair, .accept = vsock_accept, .getname = vsock_getname, @@ -2015,10 +2019,10 @@ static const struct proto_ops vsock_stream_ops = { .ioctl = sock_no_ioctl, .listen = vsock_listen, .shutdown = vsock_shutdown, - .setsockopt = vsock_stream_setsockopt, - .getsockopt = vsock_stream_getsockopt, - .sendmsg = vsock_stream_sendmsg, - .recvmsg = vsock_stream_recvmsg, + .setsockopt = vsock_connectible_setsockopt, + .getsockopt = vsock_connectible_getsockopt, + .sendmsg = vsock_connectible_sendmsg, + .recvmsg = vsock_connectible_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, };
This prepares af_vsock.c for SEQPACKET support: some functions such as setsockopt(), getsockopt(), connect(), recvmsg(), sendmsg() are shared between both types of sockets, so rename them in general manner. Signed-off-by: Arseny Krasnov <arseny.krasnov@kaspersky.com> --- net/vmw_vsock/af_vsock.c | 64 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 30 deletions(-)