Commit 9d5c5d8f authored by Hendrik Brueckner's avatar Hendrik Brueckner Committed by David S. Miller

af_iucv: add sockopt() to enable/disable use of IPRM_DATA msgs

Provide the socket operations getsocktopt() and setsockopt() to enable/disable
sending of data in the parameter list of IUCV messages.
The patch sets respective flag only.
Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent af88b52d
...@@ -303,6 +303,7 @@ struct ucred { ...@@ -303,6 +303,7 @@ struct ucred {
#define SOL_BLUETOOTH 274 #define SOL_BLUETOOTH 274
#define SOL_PNPIPE 275 #define SOL_PNPIPE 275
#define SOL_RDS 276 #define SOL_RDS 276
#define SOL_IUCV 277
/* IPX options */ /* IPX options */
#define IPX_TYPE 1 #define IPX_TYPE 1
......
...@@ -73,8 +73,12 @@ struct iucv_sock { ...@@ -73,8 +73,12 @@ struct iucv_sock {
struct sk_buff_head backlog_skb_q; struct sk_buff_head backlog_skb_q;
struct sock_msg_q message_q; struct sock_msg_q message_q;
unsigned int send_tag; unsigned int send_tag;
u8 flags;
}; };
/* iucv socket options (SOL_IUCV) */
#define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */
struct iucv_sock_list { struct iucv_sock_list {
struct hlist_head head; struct hlist_head head;
rwlock_t lock; rwlock_t lock;
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#define CONFIG_IUCV_SOCK_DEBUG 1 #define CONFIG_IUCV_SOCK_DEBUG 1
#define IPRMDATA 0x80 #define IPRMDATA 0x80
#define VERSION "1.0" #define VERSION "1.1"
static char iucv_userid[80]; static char iucv_userid[80];
...@@ -226,6 +226,7 @@ static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio) ...@@ -226,6 +226,7 @@ static struct sock *iucv_sock_alloc(struct socket *sock, int proto, gfp_t prio)
spin_lock_init(&iucv_sk(sk)->message_q.lock); spin_lock_init(&iucv_sk(sk)->message_q.lock);
skb_queue_head_init(&iucv_sk(sk)->backlog_skb_q); skb_queue_head_init(&iucv_sk(sk)->backlog_skb_q);
iucv_sk(sk)->send_tag = 0; iucv_sk(sk)->send_tag = 0;
iucv_sk(sk)->flags = 0;
sk->sk_destruct = iucv_sock_destruct; sk->sk_destruct = iucv_sock_destruct;
sk->sk_sndtimeo = IUCV_CONN_TIMEOUT; sk->sk_sndtimeo = IUCV_CONN_TIMEOUT;
...@@ -1003,6 +1004,78 @@ static int iucv_sock_release(struct socket *sock) ...@@ -1003,6 +1004,78 @@ static int iucv_sock_release(struct socket *sock)
return err; return err;
} }
/* getsockopt and setsockopt */
static int iucv_sock_setsockopt(struct socket *sock, int level, int optname,
char __user *optval, int optlen)
{
struct sock *sk = sock->sk;
struct iucv_sock *iucv = iucv_sk(sk);
int val;
int rc;
if (level != SOL_IUCV)
return -ENOPROTOOPT;
if (optlen < sizeof(int))
return -EINVAL;
if (get_user(val, (int __user *) optval))
return -EFAULT;
rc = 0;
lock_sock(sk);
switch (optname) {
case SO_IPRMDATA_MSG:
if (val)
iucv->flags |= IUCV_IPRMDATA;
else
iucv->flags &= ~IUCV_IPRMDATA;
break;
default:
rc = -ENOPROTOOPT;
break;
}
release_sock(sk);
return rc;
}
static int iucv_sock_getsockopt(struct socket *sock, int level, int optname,
char __user *optval, int __user *optlen)
{
struct sock *sk = sock->sk;
struct iucv_sock *iucv = iucv_sk(sk);
int val, len;
if (level != SOL_IUCV)
return -ENOPROTOOPT;
if (get_user(len, optlen))
return -EFAULT;
if (len < 0)
return -EINVAL;
len = min_t(unsigned int, len, sizeof(int));
switch (optname) {
case SO_IPRMDATA_MSG:
val = (iucv->flags & IUCV_IPRMDATA) ? 1 : 0;
break;
default:
return -ENOPROTOOPT;
}
if (put_user(len, optlen))
return -EFAULT;
if (copy_to_user(optval, &val, len))
return -EFAULT;
return 0;
}
/* Callback wrappers - called from iucv base support */ /* Callback wrappers - called from iucv base support */
static int iucv_callback_connreq(struct iucv_path *path, static int iucv_callback_connreq(struct iucv_path *path,
u8 ipvmid[8], u8 ipuser[16]) u8 ipvmid[8], u8 ipuser[16])
...@@ -1229,8 +1302,8 @@ static struct proto_ops iucv_sock_ops = { ...@@ -1229,8 +1302,8 @@ static struct proto_ops iucv_sock_ops = {
.mmap = sock_no_mmap, .mmap = sock_no_mmap,
.socketpair = sock_no_socketpair, .socketpair = sock_no_socketpair,
.shutdown = iucv_sock_shutdown, .shutdown = iucv_sock_shutdown,
.setsockopt = sock_no_setsockopt, .setsockopt = iucv_sock_setsockopt,
.getsockopt = sock_no_getsockopt .getsockopt = iucv_sock_getsockopt,
}; };
static struct net_proto_family iucv_sock_family_ops = { static struct net_proto_family iucv_sock_family_ops = {
......
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