Skip to content

Commit eac3731

Browse files
Jennifer Huntdavem330
authored andcommitted
[S390]: Add AF_IUCV socket support
From: Jennifer Hunt <[email protected]> This patch adds AF_IUCV socket support. Signed-off-by: Frank Pavlic <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5da5e65 commit eac3731

File tree

7 files changed

+1197
-2
lines changed

7 files changed

+1197
-2
lines changed

arch/s390/defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ CONFIG_XFRM=y
180180
# CONFIG_XFRM_SUB_POLICY is not set
181181
CONFIG_NET_KEY=y
182182
CONFIG_IUCV=m
183+
CONFIG_AFIUCV=m
183184
CONFIG_INET=y
184185
CONFIG_IP_MULTICAST=y
185186
# CONFIG_IP_ADVANCED_ROUTER is not set

include/linux/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
struct poll_table_struct;
2525
struct inode;
2626

27-
#define NPROTO 32 /* should be enough for now.. */
27+
#define NPROTO 33 /* should be enough for now.. */
2828

2929
#define SYS_SOCKET 1 /* sys_socket(2) */
3030
#define SYS_BIND 2 /* sys_bind(2) */

include/linux/socket.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ struct ucred {
187187
#define AF_LLC 26 /* Linux LLC */
188188
#define AF_TIPC 30 /* TIPC sockets */
189189
#define AF_BLUETOOTH 31 /* Bluetooth sockets */
190-
#define AF_MAX 32 /* For now.. */
190+
#define AF_IUCV 32 /* IUCV sockets */
191+
#define AF_MAX 33 /* For now.. */
191192

192193
/* Protocol families, same as address families. */
193194
#define PF_UNSPEC AF_UNSPEC
@@ -220,6 +221,7 @@ struct ucred {
220221
#define PF_LLC AF_LLC
221222
#define PF_TIPC AF_TIPC
222223
#define PF_BLUETOOTH AF_BLUETOOTH
224+
#define PF_IUCV AF_IUCV
223225
#define PF_MAX AF_MAX
224226

225227
/* Maximum queue length specifiable by listen. */

include/net/iucv/af_iucv.h

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Copyright 2006 IBM Corporation
3+
* IUCV protocol stack for Linux on zSeries
4+
* Version 1.0
5+
* Author(s): Jennifer Hunt <[email protected]>
6+
*
7+
*/
8+
9+
#ifndef __AFIUCV_H
10+
#define __AFIUCV_H
11+
12+
#include <asm/types.h>
13+
#include <asm/byteorder.h>
14+
#include <linux/list.h>
15+
#include <linux/poll.h>
16+
#include <linux/socket.h>
17+
18+
#ifndef AF_IUCV
19+
#define AF_IUCV 32
20+
#define PF_IUCV AF_IUCV
21+
#endif
22+
23+
/* Connection and socket states */
24+
enum {
25+
IUCV_CONNECTED = 1,
26+
IUCV_OPEN,
27+
IUCV_BOUND,
28+
IUCV_LISTEN,
29+
IUCV_SEVERED,
30+
IUCV_DISCONN,
31+
IUCV_CLOSED
32+
};
33+
34+
#define IUCV_QUEUELEN_DEFAULT 65535
35+
#define IUCV_CONN_TIMEOUT (HZ * 40)
36+
#define IUCV_DISCONN_TIMEOUT (HZ * 2)
37+
#define IUCV_CONN_IDLE_TIMEOUT (HZ * 60)
38+
#define IUCV_BUFSIZE_DEFAULT 32768
39+
40+
/* IUCV socket address */
41+
struct sockaddr_iucv {
42+
sa_family_t siucv_family;
43+
unsigned short siucv_port; /* Reserved */
44+
unsigned int siucv_addr; /* Reserved */
45+
char siucv_nodeid[8]; /* Reserved */
46+
char siucv_user_id[8]; /* Guest User Id */
47+
char siucv_name[8]; /* Application Name */
48+
};
49+
50+
51+
/* Common socket structures and functions */
52+
53+
#define iucv_sk(__sk) ((struct iucv_sock *) __sk)
54+
55+
struct iucv_sock {
56+
struct sock sk;
57+
char src_user_id[8];
58+
char src_name[8];
59+
char dst_user_id[8];
60+
char dst_name[8];
61+
struct list_head accept_q;
62+
struct sock *parent;
63+
struct iucv_path *path;
64+
struct sk_buff_head send_skb_q;
65+
unsigned int send_tag;
66+
};
67+
68+
struct iucv_sock_list {
69+
struct hlist_head head;
70+
rwlock_t lock;
71+
atomic_t autobind_name;
72+
};
73+
74+
static void iucv_sock_destruct(struct sock *sk);
75+
static void iucv_sock_cleanup_listen(struct sock *parent);
76+
static void iucv_sock_kill(struct sock *sk);
77+
static void iucv_sock_close(struct sock *sk);
78+
static int iucv_sock_create(struct socket *sock, int proto);
79+
static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
80+
int addr_len);
81+
static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
82+
int alen, int flags);
83+
static int iucv_sock_listen(struct socket *sock, int backlog);
84+
static int iucv_sock_accept(struct socket *sock, struct socket *newsock,
85+
int flags);
86+
static int iucv_sock_getname(struct socket *sock, struct sockaddr *addr,
87+
int *len, int peer);
88+
static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
89+
struct msghdr *msg, size_t len);
90+
static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
91+
struct msghdr *msg, size_t len, int flags);
92+
unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
93+
poll_table *wait);
94+
static int iucv_sock_release(struct socket *sock);
95+
static int iucv_sock_shutdown(struct socket *sock, int how);
96+
97+
void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
98+
void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
99+
int iucv_sock_wait_state(struct sock *sk, int state, int state2,
100+
unsigned long timeo);
101+
int iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo);
102+
void iucv_accept_enqueue(struct sock *parent, struct sock *sk);
103+
void iucv_accept_unlink(struct sock *sk);
104+
struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock);
105+
106+
#endif /* __IUCV_H */

net/iucv/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,11 @@ config IUCV
55
Select this option if you want to use inter-user communication under
66
VM or VIF sockets. If you run on z/VM, say "Y" to enable a fast
77
communication link between VM guests.
8+
9+
config AFIUCV
10+
tristate "AF_IUCV support (VM only)"
11+
depends on IUCV
12+
help
13+
Select this option if you want to use inter-user communication under
14+
VM or VIF sockets. If you run on z/VM, say "Y" to enable a fast
15+
communication link between VM guests.

net/iucv/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
#
44

55
obj-$(CONFIG_IUCV) += iucv.o
6+
obj-$(CONFIG_AFIUCV) += af_iucv.o

0 commit comments

Comments
 (0)