mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-21 17:29:05 +07:00
9b2c45d479
Changes since v1: Added changes in these files: drivers/infiniband/hw/usnic/usnic_transport.c drivers/staging/lustre/lnet/lnet/lib-socket.c drivers/target/iscsi/iscsi_target_login.c drivers/vhost/net.c fs/dlm/lowcomms.c fs/ocfs2/cluster/tcp.c security/tomoyo/network.c Before: All these functions either return a negative error indicator, or store length of sockaddr into "int *socklen" parameter and return zero on success. "int *socklen" parameter is awkward. For example, if caller does not care, it still needs to provide on-stack storage for the value it does not need. None of the many FOO_getname() functions of various protocols ever used old value of *socklen. They always just overwrite it. This change drops this parameter, and makes all these functions, on success, return length of sockaddr. It's always >= 0 and can be differentiated from an error. Tests in callers are changed from "if (err)" to "if (err < 0)", where needed. rpc_sockname() lost "int buflen" parameter, since its only use was to be passed to kernel_getsockname() as &buflen and subsequently not used in any way. Userspace API is not changed. text data bss dec hex filename 30108430 2633624 873672 33615726 200ef6e vmlinux.before.o 30108109 2633612 873672 33615393 200ee21 vmlinux.o Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com> CC: David S. Miller <davem@davemloft.net> CC: linux-kernel@vger.kernel.org CC: netdev@vger.kernel.org CC: linux-bluetooth@vger.kernel.org CC: linux-decnet-user@lists.sourceforge.net CC: linux-wireless@vger.kernel.org CC: linux-rdma@vger.kernel.org CC: linux-sctp@vger.kernel.org CC: linux-nfs@vger.kernel.org CC: linux-x25@vger.kernel.org Signed-off-by: David S. Miller <davem@davemloft.net>
163 lines
3.7 KiB
C
163 lines
3.7 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* net/atm/pvc.c - ATM PVC sockets */
|
|
|
|
/* Written 1995-2000 by Werner Almesberger, EPFL LRC/ICA */
|
|
|
|
|
|
#include <linux/net.h> /* struct socket, struct proto_ops */
|
|
#include <linux/atm.h> /* ATM stuff */
|
|
#include <linux/atmdev.h> /* ATM devices */
|
|
#include <linux/errno.h> /* error codes */
|
|
#include <linux/kernel.h> /* printk */
|
|
#include <linux/init.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/export.h>
|
|
#include <net/sock.h> /* for sock_no_* */
|
|
|
|
#include "resources.h" /* devs and vccs */
|
|
#include "common.h" /* common for PVCs and SVCs */
|
|
|
|
|
|
static int pvc_shutdown(struct socket *sock, int how)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static int pvc_bind(struct socket *sock, struct sockaddr *sockaddr,
|
|
int sockaddr_len)
|
|
{
|
|
struct sock *sk = sock->sk;
|
|
struct sockaddr_atmpvc *addr;
|
|
struct atm_vcc *vcc;
|
|
int error;
|
|
|
|
if (sockaddr_len != sizeof(struct sockaddr_atmpvc))
|
|
return -EINVAL;
|
|
addr = (struct sockaddr_atmpvc *)sockaddr;
|
|
if (addr->sap_family != AF_ATMPVC)
|
|
return -EAFNOSUPPORT;
|
|
lock_sock(sk);
|
|
vcc = ATM_SD(sock);
|
|
if (!test_bit(ATM_VF_HASQOS, &vcc->flags)) {
|
|
error = -EBADFD;
|
|
goto out;
|
|
}
|
|
if (test_bit(ATM_VF_PARTIAL, &vcc->flags)) {
|
|
if (vcc->vpi != ATM_VPI_UNSPEC)
|
|
addr->sap_addr.vpi = vcc->vpi;
|
|
if (vcc->vci != ATM_VCI_UNSPEC)
|
|
addr->sap_addr.vci = vcc->vci;
|
|
}
|
|
error = vcc_connect(sock, addr->sap_addr.itf, addr->sap_addr.vpi,
|
|
addr->sap_addr.vci);
|
|
out:
|
|
release_sock(sk);
|
|
return error;
|
|
}
|
|
|
|
static int pvc_connect(struct socket *sock, struct sockaddr *sockaddr,
|
|
int sockaddr_len, int flags)
|
|
{
|
|
return pvc_bind(sock, sockaddr, sockaddr_len);
|
|
}
|
|
|
|
static int pvc_setsockopt(struct socket *sock, int level, int optname,
|
|
char __user *optval, unsigned int optlen)
|
|
{
|
|
struct sock *sk = sock->sk;
|
|
int error;
|
|
|
|
lock_sock(sk);
|
|
error = vcc_setsockopt(sock, level, optname, optval, optlen);
|
|
release_sock(sk);
|
|
return error;
|
|
}
|
|
|
|
static int pvc_getsockopt(struct socket *sock, int level, int optname,
|
|
char __user *optval, int __user *optlen)
|
|
{
|
|
struct sock *sk = sock->sk;
|
|
int error;
|
|
|
|
lock_sock(sk);
|
|
error = vcc_getsockopt(sock, level, optname, optval, optlen);
|
|
release_sock(sk);
|
|
return error;
|
|
}
|
|
|
|
static int pvc_getname(struct socket *sock, struct sockaddr *sockaddr,
|
|
int peer)
|
|
{
|
|
struct sockaddr_atmpvc *addr;
|
|
struct atm_vcc *vcc = ATM_SD(sock);
|
|
|
|
if (!vcc->dev || !test_bit(ATM_VF_ADDR, &vcc->flags))
|
|
return -ENOTCONN;
|
|
addr = (struct sockaddr_atmpvc *)sockaddr;
|
|
memset(addr, 0, sizeof(*addr));
|
|
addr->sap_family = AF_ATMPVC;
|
|
addr->sap_addr.itf = vcc->dev->number;
|
|
addr->sap_addr.vpi = vcc->vpi;
|
|
addr->sap_addr.vci = vcc->vci;
|
|
return sizeof(struct sockaddr_atmpvc);
|
|
}
|
|
|
|
static const struct proto_ops pvc_proto_ops = {
|
|
.family = PF_ATMPVC,
|
|
.owner = THIS_MODULE,
|
|
|
|
.release = vcc_release,
|
|
.bind = pvc_bind,
|
|
.connect = pvc_connect,
|
|
.socketpair = sock_no_socketpair,
|
|
.accept = sock_no_accept,
|
|
.getname = pvc_getname,
|
|
.poll = vcc_poll,
|
|
.ioctl = vcc_ioctl,
|
|
#ifdef CONFIG_COMPAT
|
|
.compat_ioctl = vcc_compat_ioctl,
|
|
#endif
|
|
.listen = sock_no_listen,
|
|
.shutdown = pvc_shutdown,
|
|
.setsockopt = pvc_setsockopt,
|
|
.getsockopt = pvc_getsockopt,
|
|
.sendmsg = vcc_sendmsg,
|
|
.recvmsg = vcc_recvmsg,
|
|
.mmap = sock_no_mmap,
|
|
.sendpage = sock_no_sendpage,
|
|
};
|
|
|
|
|
|
static int pvc_create(struct net *net, struct socket *sock, int protocol,
|
|
int kern)
|
|
{
|
|
if (net != &init_net)
|
|
return -EAFNOSUPPORT;
|
|
|
|
sock->ops = &pvc_proto_ops;
|
|
return vcc_create(net, sock, protocol, PF_ATMPVC, kern);
|
|
}
|
|
|
|
static const struct net_proto_family pvc_family_ops = {
|
|
.family = PF_ATMPVC,
|
|
.create = pvc_create,
|
|
.owner = THIS_MODULE,
|
|
};
|
|
|
|
|
|
/*
|
|
* Initialize the ATM PVC protocol family
|
|
*/
|
|
|
|
|
|
int __init atmpvc_init(void)
|
|
{
|
|
return sock_register(&pvc_family_ops);
|
|
}
|
|
|
|
void atmpvc_exit(void)
|
|
{
|
|
sock_unregister(PF_ATMPVC);
|
|
}
|