Skip to content

Commit

Permalink
[S390]: Add AF_IUCV socket support
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Jennifer Hunt authored and davem330 committed Feb 8, 2007
1 parent 5da5e65 commit eac3731
Show file tree
Hide file tree
Showing 7 changed files with 1,197 additions and 2 deletions.
1 change: 1 addition & 0 deletions arch/s390/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ CONFIG_XFRM=y
# CONFIG_XFRM_SUB_POLICY is not set
CONFIG_NET_KEY=y
CONFIG_IUCV=m
CONFIG_AFIUCV=m
CONFIG_INET=y
CONFIG_IP_MULTICAST=y
# CONFIG_IP_ADVANCED_ROUTER is not set
Expand Down
2 changes: 1 addition & 1 deletion include/linux/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
struct poll_table_struct;
struct inode;

#define NPROTO 32 /* should be enough for now.. */
#define NPROTO 33 /* should be enough for now.. */

#define SYS_SOCKET 1 /* sys_socket(2) */
#define SYS_BIND 2 /* sys_bind(2) */
Expand Down
4 changes: 3 additions & 1 deletion include/linux/socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ struct ucred {
#define AF_LLC 26 /* Linux LLC */
#define AF_TIPC 30 /* TIPC sockets */
#define AF_BLUETOOTH 31 /* Bluetooth sockets */
#define AF_MAX 32 /* For now.. */
#define AF_IUCV 32 /* IUCV sockets */
#define AF_MAX 33 /* For now.. */

/* Protocol families, same as address families. */
#define PF_UNSPEC AF_UNSPEC
Expand Down Expand Up @@ -220,6 +221,7 @@ struct ucred {
#define PF_LLC AF_LLC
#define PF_TIPC AF_TIPC
#define PF_BLUETOOTH AF_BLUETOOTH
#define PF_IUCV AF_IUCV
#define PF_MAX AF_MAX

/* Maximum queue length specifiable by listen. */
Expand Down
106 changes: 106 additions & 0 deletions include/net/iucv/af_iucv.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
* Copyright 2006 IBM Corporation
* IUCV protocol stack for Linux on zSeries
* Version 1.0
* Author(s): Jennifer Hunt <[email protected]>
*
*/

#ifndef __AFIUCV_H
#define __AFIUCV_H

#include <asm/types.h>
#include <asm/byteorder.h>
#include <linux/list.h>
#include <linux/poll.h>
#include <linux/socket.h>

#ifndef AF_IUCV
#define AF_IUCV 32
#define PF_IUCV AF_IUCV
#endif

/* Connection and socket states */
enum {
IUCV_CONNECTED = 1,
IUCV_OPEN,
IUCV_BOUND,
IUCV_LISTEN,
IUCV_SEVERED,
IUCV_DISCONN,
IUCV_CLOSED
};

#define IUCV_QUEUELEN_DEFAULT 65535
#define IUCV_CONN_TIMEOUT (HZ * 40)
#define IUCV_DISCONN_TIMEOUT (HZ * 2)
#define IUCV_CONN_IDLE_TIMEOUT (HZ * 60)
#define IUCV_BUFSIZE_DEFAULT 32768

/* IUCV socket address */
struct sockaddr_iucv {
sa_family_t siucv_family;
unsigned short siucv_port; /* Reserved */
unsigned int siucv_addr; /* Reserved */
char siucv_nodeid[8]; /* Reserved */
char siucv_user_id[8]; /* Guest User Id */
char siucv_name[8]; /* Application Name */
};


/* Common socket structures and functions */

#define iucv_sk(__sk) ((struct iucv_sock *) __sk)

struct iucv_sock {
struct sock sk;
char src_user_id[8];
char src_name[8];
char dst_user_id[8];
char dst_name[8];
struct list_head accept_q;
struct sock *parent;
struct iucv_path *path;
struct sk_buff_head send_skb_q;
unsigned int send_tag;
};

struct iucv_sock_list {
struct hlist_head head;
rwlock_t lock;
atomic_t autobind_name;
};

static void iucv_sock_destruct(struct sock *sk);
static void iucv_sock_cleanup_listen(struct sock *parent);
static void iucv_sock_kill(struct sock *sk);
static void iucv_sock_close(struct sock *sk);
static int iucv_sock_create(struct socket *sock, int proto);
static int iucv_sock_bind(struct socket *sock, struct sockaddr *addr,
int addr_len);
static int iucv_sock_connect(struct socket *sock, struct sockaddr *addr,
int alen, int flags);
static int iucv_sock_listen(struct socket *sock, int backlog);
static int iucv_sock_accept(struct socket *sock, struct socket *newsock,
int flags);
static int iucv_sock_getname(struct socket *sock, struct sockaddr *addr,
int *len, int peer);
static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len);
static int iucv_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t len, int flags);
unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
poll_table *wait);
static int iucv_sock_release(struct socket *sock);
static int iucv_sock_shutdown(struct socket *sock, int how);

void iucv_sock_link(struct iucv_sock_list *l, struct sock *s);
void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s);
int iucv_sock_wait_state(struct sock *sk, int state, int state2,
unsigned long timeo);
int iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo);
void iucv_accept_enqueue(struct sock *parent, struct sock *sk);
void iucv_accept_unlink(struct sock *sk);
struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock);

#endif /* __IUCV_H */
8 changes: 8 additions & 0 deletions net/iucv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ config IUCV
Select this option if you want to use inter-user communication under
VM or VIF sockets. If you run on z/VM, say "Y" to enable a fast
communication link between VM guests.

config AFIUCV
tristate "AF_IUCV support (VM only)"
depends on IUCV
help
Select this option if you want to use inter-user communication under
VM or VIF sockets. If you run on z/VM, say "Y" to enable a fast
communication link between VM guests.
1 change: 1 addition & 0 deletions net/iucv/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
#

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

0 comments on commit eac3731

Please sign in to comment.