2 * IUCV protocol stack for Linux on zSeries
4 * Copyright IBM Corp. 2006, 2009
6 * Author(s): Jennifer Hunt <jenhunt@us.ibm.com>
7 * Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
9 * Ursula Braun <ursula.braun@de.ibm.com>
12 #define KMSG_COMPONENT "af_iucv"
13 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
15 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/list.h>
18 #include <linux/errno.h>
19 #include <linux/kernel.h>
20 #include <linux/sched.h>
21 #include <linux/slab.h>
22 #include <linux/skbuff.h>
23 #include <linux/init.h>
24 #include <linux/poll.h>
26 #include <asm/ebcdic.h>
27 #include <asm/cpcmd.h>
28 #include <linux/kmod.h>
30 #include <net/iucv/af_iucv.h>
34 static char iucv_userid
[80];
36 static const struct proto_ops iucv_sock_ops
;
38 static struct proto iucv_proto
= {
41 .obj_size
= sizeof(struct iucv_sock
),
44 static struct iucv_interface
*pr_iucv
;
46 /* special AF_IUCV IPRM messages */
47 static const u8 iprm_shutdown
[8] =
48 {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
50 #define TRGCLS_SIZE (sizeof(((struct iucv_message *)0)->class))
52 /* macros to set/get socket control buffer at correct offset */
53 #define CB_TAG(skb) ((skb)->cb) /* iucv message tag */
54 #define CB_TAG_LEN (sizeof(((struct iucv_message *) 0)->tag))
55 #define CB_TRGCLS(skb) ((skb)->cb + CB_TAG_LEN) /* iucv msg target class */
56 #define CB_TRGCLS_LEN (TRGCLS_SIZE)
58 #define __iucv_sock_wait(sk, condition, timeo, ret) \
60 DEFINE_WAIT(__wait); \
61 long __timeo = timeo; \
63 prepare_to_wait(sk_sleep(sk), &__wait, TASK_INTERRUPTIBLE); \
64 while (!(condition)) { \
69 if (signal_pending(current)) { \
70 ret = sock_intr_errno(__timeo); \
74 __timeo = schedule_timeout(__timeo); \
76 ret = sock_error(sk); \
80 finish_wait(sk_sleep(sk), &__wait); \
83 #define iucv_sock_wait(sk, condition, timeo) \
87 __iucv_sock_wait(sk, condition, timeo, __ret); \
91 static void iucv_sock_kill(struct sock
*sk
);
92 static void iucv_sock_close(struct sock
*sk
);
93 static void iucv_sever_path(struct sock
*, int);
95 static int afiucv_hs_rcv(struct sk_buff
*skb
, struct net_device
*dev
,
96 struct packet_type
*pt
, struct net_device
*orig_dev
);
97 static int afiucv_hs_send(struct iucv_message
*imsg
, struct sock
*sock
,
98 struct sk_buff
*skb
, u8 flags
);
99 static void afiucv_hs_callback_txnotify(struct sk_buff
*, enum iucv_tx_notify
);
101 /* Call Back functions */
102 static void iucv_callback_rx(struct iucv_path
*, struct iucv_message
*);
103 static void iucv_callback_txdone(struct iucv_path
*, struct iucv_message
*);
104 static void iucv_callback_connack(struct iucv_path
*, u8 ipuser
[16]);
105 static int iucv_callback_connreq(struct iucv_path
*, u8 ipvmid
[8],
107 static void iucv_callback_connrej(struct iucv_path
*, u8 ipuser
[16]);
108 static void iucv_callback_shutdown(struct iucv_path
*, u8 ipuser
[16]);
110 static struct iucv_sock_list iucv_sk_list
= {
111 .lock
= __RW_LOCK_UNLOCKED(iucv_sk_list
.lock
),
112 .autobind_name
= ATOMIC_INIT(0)
115 static struct iucv_handler af_iucv_handler
= {
116 .path_pending
= iucv_callback_connreq
,
117 .path_complete
= iucv_callback_connack
,
118 .path_severed
= iucv_callback_connrej
,
119 .message_pending
= iucv_callback_rx
,
120 .message_complete
= iucv_callback_txdone
,
121 .path_quiesced
= iucv_callback_shutdown
,
124 static inline void high_nmcpy(unsigned char *dst
, char *src
)
129 static inline void low_nmcpy(unsigned char *dst
, char *src
)
131 memcpy(&dst
[8], src
, 8);
134 static int afiucv_pm_prepare(struct device
*dev
)
136 #ifdef CONFIG_PM_DEBUG
137 printk(KERN_WARNING
"afiucv_pm_prepare\n");
142 static void afiucv_pm_complete(struct device
*dev
)
144 #ifdef CONFIG_PM_DEBUG
145 printk(KERN_WARNING
"afiucv_pm_complete\n");
150 * afiucv_pm_freeze() - Freeze PM callback
151 * @dev: AFIUCV dummy device
153 * Sever all established IUCV communication pathes
155 static int afiucv_pm_freeze(struct device
*dev
)
157 struct iucv_sock
*iucv
;
159 struct hlist_node
*node
;
162 #ifdef CONFIG_PM_DEBUG
163 printk(KERN_WARNING
"afiucv_pm_freeze\n");
165 read_lock(&iucv_sk_list
.lock
);
166 sk_for_each(sk
, node
, &iucv_sk_list
.head
) {
168 skb_queue_purge(&iucv
->send_skb_q
);
169 skb_queue_purge(&iucv
->backlog_skb_q
);
170 switch (sk
->sk_state
) {
174 iucv_sever_path(sk
, 0);
183 skb_queue_purge(&iucv
->send_skb_q
);
184 skb_queue_purge(&iucv
->backlog_skb_q
);
186 read_unlock(&iucv_sk_list
.lock
);
191 * afiucv_pm_restore_thaw() - Thaw and restore PM callback
192 * @dev: AFIUCV dummy device
194 * socket clean up after freeze
196 static int afiucv_pm_restore_thaw(struct device
*dev
)
199 struct hlist_node
*node
;
201 #ifdef CONFIG_PM_DEBUG
202 printk(KERN_WARNING
"afiucv_pm_restore_thaw\n");
204 read_lock(&iucv_sk_list
.lock
);
205 sk_for_each(sk
, node
, &iucv_sk_list
.head
) {
206 switch (sk
->sk_state
) {
209 sk
->sk_state
= IUCV_DISCONN
;
210 sk
->sk_state_change(sk
);
221 read_unlock(&iucv_sk_list
.lock
);
225 static const struct dev_pm_ops afiucv_pm_ops
= {
226 .prepare
= afiucv_pm_prepare
,
227 .complete
= afiucv_pm_complete
,
228 .freeze
= afiucv_pm_freeze
,
229 .thaw
= afiucv_pm_restore_thaw
,
230 .restore
= afiucv_pm_restore_thaw
,
233 static struct device_driver af_iucv_driver
= {
234 .owner
= THIS_MODULE
,
237 .pm
= &afiucv_pm_ops
,
240 /* dummy device used as trigger for PM functions */
241 static struct device
*af_iucv_dev
;
244 * iucv_msg_length() - Returns the length of an iucv message.
245 * @msg: Pointer to struct iucv_message, MUST NOT be NULL
247 * The function returns the length of the specified iucv message @msg of data
248 * stored in a buffer and of data stored in the parameter list (PRMDATA).
250 * For IUCV_IPRMDATA, AF_IUCV uses the following convention to transport socket
252 * PRMDATA[0..6] socket data (max 7 bytes);
253 * PRMDATA[7] socket data length value (len is 0xff - PRMDATA[7])
255 * The socket data length is computed by subtracting the socket data length
257 * If the socket data len is greater 7, then PRMDATA can be used for special
258 * notifications (see iucv_sock_shutdown); and further,
259 * if the socket data len is > 7, the function returns 8.
261 * Use this function to allocate socket buffers to store iucv message data.
263 static inline size_t iucv_msg_length(struct iucv_message
*msg
)
267 if (msg
->flags
& IUCV_IPRMDATA
) {
268 datalen
= 0xff - msg
->rmmsg
[7];
269 return (datalen
< 8) ? datalen
: 8;
275 * iucv_sock_in_state() - check for specific states
276 * @sk: sock structure
277 * @state: first iucv sk state
278 * @state: second iucv sk state
280 * Returns true if the socket in either in the first or second state.
282 static int iucv_sock_in_state(struct sock
*sk
, int state
, int state2
)
284 return (sk
->sk_state
== state
|| sk
->sk_state
== state2
);
288 * iucv_below_msglim() - function to check if messages can be sent
289 * @sk: sock structure
291 * Returns true if the send queue length is lower than the message limit.
292 * Always returns true if the socket is not connected (no iucv path for
293 * checking the message limit).
295 static inline int iucv_below_msglim(struct sock
*sk
)
297 struct iucv_sock
*iucv
= iucv_sk(sk
);
299 if (sk
->sk_state
!= IUCV_CONNECTED
)
301 if (iucv
->transport
== AF_IUCV_TRANS_IUCV
)
302 return (skb_queue_len(&iucv
->send_skb_q
) < iucv
->path
->msglim
);
304 return ((atomic_read(&iucv
->msg_sent
) < iucv
->msglimit_peer
) &&
305 (atomic_read(&iucv
->pendings
) <= 0));
309 * iucv_sock_wake_msglim() - Wake up thread waiting on msg limit
311 static void iucv_sock_wake_msglim(struct sock
*sk
)
313 struct socket_wq
*wq
;
316 wq
= rcu_dereference(sk
->sk_wq
);
317 if (wq_has_sleeper(wq
))
318 wake_up_interruptible_all(&wq
->wait
);
319 sk_wake_async(sk
, SOCK_WAKE_SPACE
, POLL_OUT
);
324 * afiucv_hs_send() - send a message through HiperSockets transport
326 static int afiucv_hs_send(struct iucv_message
*imsg
, struct sock
*sock
,
327 struct sk_buff
*skb
, u8 flags
)
329 struct iucv_sock
*iucv
= iucv_sk(sock
);
330 struct af_iucv_trans_hdr
*phs_hdr
;
331 struct sk_buff
*nskb
;
332 int err
, confirm_recv
= 0;
334 memset(skb
->head
, 0, ETH_HLEN
);
335 phs_hdr
= (struct af_iucv_trans_hdr
*)skb_push(skb
,
336 sizeof(struct af_iucv_trans_hdr
));
337 skb_reset_mac_header(skb
);
338 skb_reset_network_header(skb
);
339 skb_push(skb
, ETH_HLEN
);
340 skb_reset_mac_header(skb
);
341 memset(phs_hdr
, 0, sizeof(struct af_iucv_trans_hdr
));
343 phs_hdr
->magic
= ETH_P_AF_IUCV
;
344 phs_hdr
->version
= 1;
345 phs_hdr
->flags
= flags
;
346 if (flags
== AF_IUCV_FLAG_SYN
)
347 phs_hdr
->window
= iucv
->msglimit
;
348 else if ((flags
== AF_IUCV_FLAG_WIN
) || !flags
) {
349 confirm_recv
= atomic_read(&iucv
->msg_recv
);
350 phs_hdr
->window
= confirm_recv
;
352 phs_hdr
->flags
= phs_hdr
->flags
| AF_IUCV_FLAG_WIN
;
354 memcpy(phs_hdr
->destUserID
, iucv
->dst_user_id
, 8);
355 memcpy(phs_hdr
->destAppName
, iucv
->dst_name
, 8);
356 memcpy(phs_hdr
->srcUserID
, iucv
->src_user_id
, 8);
357 memcpy(phs_hdr
->srcAppName
, iucv
->src_name
, 8);
358 ASCEBC(phs_hdr
->destUserID
, sizeof(phs_hdr
->destUserID
));
359 ASCEBC(phs_hdr
->destAppName
, sizeof(phs_hdr
->destAppName
));
360 ASCEBC(phs_hdr
->srcUserID
, sizeof(phs_hdr
->srcUserID
));
361 ASCEBC(phs_hdr
->srcAppName
, sizeof(phs_hdr
->srcAppName
));
363 memcpy(&phs_hdr
->iucv_hdr
, imsg
, sizeof(struct iucv_message
));
365 skb
->dev
= iucv
->hs_dev
;
368 if (!(skb
->dev
->flags
& IFF_UP
) || !netif_carrier_ok(skb
->dev
))
370 if (skb
->len
> skb
->dev
->mtu
) {
371 if (sock
->sk_type
== SOCK_SEQPACKET
)
374 skb_trim(skb
, skb
->dev
->mtu
);
376 skb
->protocol
= ETH_P_AF_IUCV
;
377 skb_shinfo(skb
)->tx_flags
|= SKBTX_DRV_NEEDS_SK_REF
;
378 nskb
= skb_clone(skb
, GFP_ATOMIC
);
381 skb_queue_tail(&iucv
->send_skb_q
, nskb
);
382 err
= dev_queue_xmit(skb
);
383 if (net_xmit_eval(err
)) {
384 skb_unlink(nskb
, &iucv
->send_skb_q
);
387 atomic_sub(confirm_recv
, &iucv
->msg_recv
);
388 WARN_ON(atomic_read(&iucv
->msg_recv
) < 0);
390 return net_xmit_eval(err
);
393 static struct sock
*__iucv_get_sock_by_name(char *nm
)
396 struct hlist_node
*node
;
398 sk_for_each(sk
, node
, &iucv_sk_list
.head
)
399 if (!memcmp(&iucv_sk(sk
)->src_name
, nm
, 8))
405 static void iucv_sock_destruct(struct sock
*sk
)
407 skb_queue_purge(&sk
->sk_receive_queue
);
408 skb_queue_purge(&sk
->sk_write_queue
);
412 static void iucv_sock_cleanup_listen(struct sock
*parent
)
416 /* Close non-accepted connections */
417 while ((sk
= iucv_accept_dequeue(parent
, NULL
))) {
422 parent
->sk_state
= IUCV_CLOSED
;
425 /* Kill socket (only if zapped and orphaned) */
426 static void iucv_sock_kill(struct sock
*sk
)
428 if (!sock_flag(sk
, SOCK_ZAPPED
) || sk
->sk_socket
)
431 iucv_sock_unlink(&iucv_sk_list
, sk
);
432 sock_set_flag(sk
, SOCK_DEAD
);
436 /* Terminate an IUCV path */
437 static void iucv_sever_path(struct sock
*sk
, int with_user_data
)
439 unsigned char user_data
[16];
440 struct iucv_sock
*iucv
= iucv_sk(sk
);
441 struct iucv_path
*path
= iucv
->path
;
445 if (with_user_data
) {
446 low_nmcpy(user_data
, iucv
->src_name
);
447 high_nmcpy(user_data
, iucv
->dst_name
);
448 ASCEBC(user_data
, sizeof(user_data
));
449 pr_iucv
->path_sever(path
, user_data
);
451 pr_iucv
->path_sever(path
, NULL
);
452 iucv_path_free(path
);
456 /* Close an IUCV socket */
457 static void iucv_sock_close(struct sock
*sk
)
459 struct iucv_sock
*iucv
= iucv_sk(sk
);
467 switch (sk
->sk_state
) {
469 iucv_sock_cleanup_listen(sk
);
473 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
) {
475 blen
= sizeof(struct af_iucv_trans_hdr
) + ETH_HLEN
;
476 skb
= sock_alloc_send_skb(sk
, blen
, 1, &err
);
478 skb_reserve(skb
, blen
);
479 err
= afiucv_hs_send(NULL
, sk
, skb
,
482 sk
->sk_state
= IUCV_DISCONN
;
483 sk
->sk_state_change(sk
);
485 case IUCV_DISCONN
: /* fall through */
486 sk
->sk_state
= IUCV_CLOSING
;
487 sk
->sk_state_change(sk
);
489 if (!err
&& !skb_queue_empty(&iucv
->send_skb_q
)) {
490 if (sock_flag(sk
, SOCK_LINGER
) && sk
->sk_lingertime
)
491 timeo
= sk
->sk_lingertime
;
493 timeo
= IUCV_DISCONN_TIMEOUT
;
495 iucv_sock_in_state(sk
, IUCV_CLOSED
, 0),
499 case IUCV_CLOSING
: /* fall through */
500 sk
->sk_state
= IUCV_CLOSED
;
501 sk
->sk_state_change(sk
);
503 sk
->sk_err
= ECONNRESET
;
504 sk
->sk_state_change(sk
);
506 skb_queue_purge(&iucv
->send_skb_q
);
507 skb_queue_purge(&iucv
->backlog_skb_q
);
509 default: /* fall through */
510 iucv_sever_path(sk
, 1);
514 dev_put(iucv
->hs_dev
);
516 sk
->sk_bound_dev_if
= 0;
519 /* mark socket for deletion by iucv_sock_kill() */
520 sock_set_flag(sk
, SOCK_ZAPPED
);
525 static void iucv_sock_init(struct sock
*sk
, struct sock
*parent
)
528 sk
->sk_type
= parent
->sk_type
;
531 static struct sock
*iucv_sock_alloc(struct socket
*sock
, int proto
, gfp_t prio
)
534 struct iucv_sock
*iucv
;
536 sk
= sk_alloc(&init_net
, PF_IUCV
, prio
, &iucv_proto
);
541 sock_init_data(sock
, sk
);
542 INIT_LIST_HEAD(&iucv
->accept_q
);
543 spin_lock_init(&iucv
->accept_q_lock
);
544 skb_queue_head_init(&iucv
->send_skb_q
);
545 INIT_LIST_HEAD(&iucv
->message_q
.list
);
546 spin_lock_init(&iucv
->message_q
.lock
);
547 skb_queue_head_init(&iucv
->backlog_skb_q
);
549 atomic_set(&iucv
->pendings
, 0);
552 atomic_set(&iucv
->msg_sent
, 0);
553 atomic_set(&iucv
->msg_recv
, 0);
555 iucv
->sk_txnotify
= afiucv_hs_callback_txnotify
;
556 memset(&iucv
->src_user_id
, 0, 32);
558 iucv
->transport
= AF_IUCV_TRANS_IUCV
;
560 iucv
->transport
= AF_IUCV_TRANS_HIPER
;
562 sk
->sk_destruct
= iucv_sock_destruct
;
563 sk
->sk_sndtimeo
= IUCV_CONN_TIMEOUT
;
564 sk
->sk_allocation
= GFP_DMA
;
566 sock_reset_flag(sk
, SOCK_ZAPPED
);
568 sk
->sk_protocol
= proto
;
569 sk
->sk_state
= IUCV_OPEN
;
571 iucv_sock_link(&iucv_sk_list
, sk
);
575 /* Create an IUCV socket */
576 static int iucv_sock_create(struct net
*net
, struct socket
*sock
, int protocol
,
581 if (protocol
&& protocol
!= PF_IUCV
)
582 return -EPROTONOSUPPORT
;
584 sock
->state
= SS_UNCONNECTED
;
586 switch (sock
->type
) {
588 sock
->ops
= &iucv_sock_ops
;
591 /* currently, proto ops can handle both sk types */
592 sock
->ops
= &iucv_sock_ops
;
595 return -ESOCKTNOSUPPORT
;
598 sk
= iucv_sock_alloc(sock
, protocol
, GFP_KERNEL
);
602 iucv_sock_init(sk
, NULL
);
607 void iucv_sock_link(struct iucv_sock_list
*l
, struct sock
*sk
)
609 write_lock_bh(&l
->lock
);
610 sk_add_node(sk
, &l
->head
);
611 write_unlock_bh(&l
->lock
);
614 void iucv_sock_unlink(struct iucv_sock_list
*l
, struct sock
*sk
)
616 write_lock_bh(&l
->lock
);
617 sk_del_node_init(sk
);
618 write_unlock_bh(&l
->lock
);
621 void iucv_accept_enqueue(struct sock
*parent
, struct sock
*sk
)
624 struct iucv_sock
*par
= iucv_sk(parent
);
627 spin_lock_irqsave(&par
->accept_q_lock
, flags
);
628 list_add_tail(&iucv_sk(sk
)->accept_q
, &par
->accept_q
);
629 spin_unlock_irqrestore(&par
->accept_q_lock
, flags
);
630 iucv_sk(sk
)->parent
= parent
;
631 sk_acceptq_added(parent
);
634 void iucv_accept_unlink(struct sock
*sk
)
637 struct iucv_sock
*par
= iucv_sk(iucv_sk(sk
)->parent
);
639 spin_lock_irqsave(&par
->accept_q_lock
, flags
);
640 list_del_init(&iucv_sk(sk
)->accept_q
);
641 spin_unlock_irqrestore(&par
->accept_q_lock
, flags
);
642 sk_acceptq_removed(iucv_sk(sk
)->parent
);
643 iucv_sk(sk
)->parent
= NULL
;
647 struct sock
*iucv_accept_dequeue(struct sock
*parent
, struct socket
*newsock
)
649 struct iucv_sock
*isk
, *n
;
652 list_for_each_entry_safe(isk
, n
, &iucv_sk(parent
)->accept_q
, accept_q
) {
653 sk
= (struct sock
*) isk
;
656 if (sk
->sk_state
== IUCV_CLOSED
) {
657 iucv_accept_unlink(sk
);
662 if (sk
->sk_state
== IUCV_CONNECTED
||
663 sk
->sk_state
== IUCV_DISCONN
||
665 iucv_accept_unlink(sk
);
667 sock_graft(sk
, newsock
);
678 /* Bind an unbound socket */
679 static int iucv_sock_bind(struct socket
*sock
, struct sockaddr
*addr
,
682 struct sockaddr_iucv
*sa
= (struct sockaddr_iucv
*) addr
;
683 struct sock
*sk
= sock
->sk
;
684 struct iucv_sock
*iucv
;
686 struct net_device
*dev
;
689 /* Verify the input sockaddr */
690 if (!addr
|| addr
->sa_family
!= AF_IUCV
)
694 if (sk
->sk_state
!= IUCV_OPEN
) {
699 write_lock_bh(&iucv_sk_list
.lock
);
702 if (__iucv_get_sock_by_name(sa
->siucv_name
)) {
709 /* Bind the socket */
711 if (!memcmp(sa
->siucv_user_id
, iucv_userid
, 8))
712 goto vm_bind
; /* VM IUCV transport */
714 /* try hiper transport */
715 memcpy(uid
, sa
->siucv_user_id
, sizeof(uid
));
718 for_each_netdev_rcu(&init_net
, dev
) {
719 if (!memcmp(dev
->perm_addr
, uid
, 8)) {
720 memcpy(iucv
->src_name
, sa
->siucv_name
, 8);
721 memcpy(iucv
->src_user_id
, sa
->siucv_user_id
, 8);
722 sk
->sk_bound_dev_if
= dev
->ifindex
;
725 sk
->sk_state
= IUCV_BOUND
;
726 iucv
->transport
= AF_IUCV_TRANS_HIPER
;
728 iucv
->msglimit
= IUCV_HIPER_MSGLIM_DEFAULT
;
736 /* use local userid for backward compat */
737 memcpy(iucv
->src_name
, sa
->siucv_name
, 8);
738 memcpy(iucv
->src_user_id
, iucv_userid
, 8);
739 sk
->sk_state
= IUCV_BOUND
;
740 iucv
->transport
= AF_IUCV_TRANS_IUCV
;
742 iucv
->msglimit
= IUCV_QUEUELEN_DEFAULT
;
745 /* found no dev to bind */
748 /* Release the socket list lock */
749 write_unlock_bh(&iucv_sk_list
.lock
);
755 /* Automatically bind an unbound socket */
756 static int iucv_sock_autobind(struct sock
*sk
)
758 struct iucv_sock
*iucv
= iucv_sk(sk
);
762 if (unlikely(!pr_iucv
))
765 memcpy(iucv
->src_user_id
, iucv_userid
, 8);
767 write_lock_bh(&iucv_sk_list
.lock
);
769 sprintf(name
, "%08x", atomic_inc_return(&iucv_sk_list
.autobind_name
));
770 while (__iucv_get_sock_by_name(name
)) {
771 sprintf(name
, "%08x",
772 atomic_inc_return(&iucv_sk_list
.autobind_name
));
775 write_unlock_bh(&iucv_sk_list
.lock
);
777 memcpy(&iucv
->src_name
, name
, 8);
780 iucv
->msglimit
= IUCV_QUEUELEN_DEFAULT
;
785 static int afiucv_hs_connect(struct socket
*sock
)
787 struct sock
*sk
= sock
->sk
;
789 int blen
= sizeof(struct af_iucv_trans_hdr
) + ETH_HLEN
;
793 skb
= sock_alloc_send_skb(sk
, blen
, 1, &err
);
799 skb_reserve(skb
, blen
);
800 err
= afiucv_hs_send(NULL
, sk
, skb
, AF_IUCV_FLAG_SYN
);
805 static int afiucv_path_connect(struct socket
*sock
, struct sockaddr
*addr
)
807 struct sockaddr_iucv
*sa
= (struct sockaddr_iucv
*) addr
;
808 struct sock
*sk
= sock
->sk
;
809 struct iucv_sock
*iucv
= iucv_sk(sk
);
810 unsigned char user_data
[16];
813 high_nmcpy(user_data
, sa
->siucv_name
);
814 low_nmcpy(user_data
, iucv
->src_name
);
815 ASCEBC(user_data
, sizeof(user_data
));
818 iucv
->path
= iucv_path_alloc(iucv
->msglimit
,
819 IUCV_IPRMDATA
, GFP_KERNEL
);
824 err
= pr_iucv
->path_connect(iucv
->path
, &af_iucv_handler
,
825 sa
->siucv_user_id
, NULL
, user_data
,
828 iucv_path_free(iucv
->path
);
831 case 0x0b: /* Target communicator is not logged on */
834 case 0x0d: /* Max connections for this guest exceeded */
835 case 0x0e: /* Max connections for target guest exceeded */
838 case 0x0f: /* Missing IUCV authorization */
850 /* Connect an unconnected socket */
851 static int iucv_sock_connect(struct socket
*sock
, struct sockaddr
*addr
,
854 struct sockaddr_iucv
*sa
= (struct sockaddr_iucv
*) addr
;
855 struct sock
*sk
= sock
->sk
;
856 struct iucv_sock
*iucv
= iucv_sk(sk
);
859 if (addr
->sa_family
!= AF_IUCV
|| alen
< sizeof(struct sockaddr_iucv
))
862 if (sk
->sk_state
!= IUCV_OPEN
&& sk
->sk_state
!= IUCV_BOUND
)
865 if (sk
->sk_state
== IUCV_OPEN
&&
866 iucv
->transport
== AF_IUCV_TRANS_HIPER
)
867 return -EBADFD
; /* explicit bind required */
869 if (sk
->sk_type
!= SOCK_STREAM
&& sk
->sk_type
!= SOCK_SEQPACKET
)
872 if (sk
->sk_state
== IUCV_OPEN
) {
873 err
= iucv_sock_autobind(sk
);
880 /* Set the destination information */
881 memcpy(iucv
->dst_user_id
, sa
->siucv_user_id
, 8);
882 memcpy(iucv
->dst_name
, sa
->siucv_name
, 8);
884 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
)
885 err
= afiucv_hs_connect(sock
);
887 err
= afiucv_path_connect(sock
, addr
);
891 if (sk
->sk_state
!= IUCV_CONNECTED
)
892 err
= iucv_sock_wait(sk
, iucv_sock_in_state(sk
, IUCV_CONNECTED
,
894 sock_sndtimeo(sk
, flags
& O_NONBLOCK
));
896 if (sk
->sk_state
== IUCV_DISCONN
|| sk
->sk_state
== IUCV_CLOSED
)
899 if (err
&& iucv
->transport
== AF_IUCV_TRANS_IUCV
)
900 iucv_sever_path(sk
, 0);
907 /* Move a socket into listening state. */
908 static int iucv_sock_listen(struct socket
*sock
, int backlog
)
910 struct sock
*sk
= sock
->sk
;
916 if (sk
->sk_state
!= IUCV_BOUND
)
919 if (sock
->type
!= SOCK_STREAM
&& sock
->type
!= SOCK_SEQPACKET
)
922 sk
->sk_max_ack_backlog
= backlog
;
923 sk
->sk_ack_backlog
= 0;
924 sk
->sk_state
= IUCV_LISTEN
;
932 /* Accept a pending connection */
933 static int iucv_sock_accept(struct socket
*sock
, struct socket
*newsock
,
936 DECLARE_WAITQUEUE(wait
, current
);
937 struct sock
*sk
= sock
->sk
, *nsk
;
941 lock_sock_nested(sk
, SINGLE_DEPTH_NESTING
);
943 if (sk
->sk_state
!= IUCV_LISTEN
) {
948 timeo
= sock_rcvtimeo(sk
, flags
& O_NONBLOCK
);
950 /* Wait for an incoming connection */
951 add_wait_queue_exclusive(sk_sleep(sk
), &wait
);
952 while (!(nsk
= iucv_accept_dequeue(sk
, newsock
))) {
953 set_current_state(TASK_INTERRUPTIBLE
);
960 timeo
= schedule_timeout(timeo
);
961 lock_sock_nested(sk
, SINGLE_DEPTH_NESTING
);
963 if (sk
->sk_state
!= IUCV_LISTEN
) {
968 if (signal_pending(current
)) {
969 err
= sock_intr_errno(timeo
);
974 set_current_state(TASK_RUNNING
);
975 remove_wait_queue(sk_sleep(sk
), &wait
);
980 newsock
->state
= SS_CONNECTED
;
987 static int iucv_sock_getname(struct socket
*sock
, struct sockaddr
*addr
,
990 struct sockaddr_iucv
*siucv
= (struct sockaddr_iucv
*) addr
;
991 struct sock
*sk
= sock
->sk
;
992 struct iucv_sock
*iucv
= iucv_sk(sk
);
994 addr
->sa_family
= AF_IUCV
;
995 *len
= sizeof(struct sockaddr_iucv
);
998 memcpy(siucv
->siucv_user_id
, iucv
->dst_user_id
, 8);
999 memcpy(siucv
->siucv_name
, iucv
->dst_name
, 8);
1001 memcpy(siucv
->siucv_user_id
, iucv
->src_user_id
, 8);
1002 memcpy(siucv
->siucv_name
, iucv
->src_name
, 8);
1004 memset(&siucv
->siucv_port
, 0, sizeof(siucv
->siucv_port
));
1005 memset(&siucv
->siucv_addr
, 0, sizeof(siucv
->siucv_addr
));
1006 memset(&siucv
->siucv_nodeid
, 0, sizeof(siucv
->siucv_nodeid
));
1012 * iucv_send_iprm() - Send socket data in parameter list of an iucv message.
1014 * @msg: Pointer to a struct iucv_message
1015 * @skb: The socket data to send, skb->len MUST BE <= 7
1017 * Send the socket data in the parameter list in the iucv message
1018 * (IUCV_IPRMDATA). The socket data is stored at index 0 to 6 in the parameter
1019 * list and the socket data len at index 7 (last byte).
1020 * See also iucv_msg_length().
1022 * Returns the error code from the iucv_message_send() call.
1024 static int iucv_send_iprm(struct iucv_path
*path
, struct iucv_message
*msg
,
1025 struct sk_buff
*skb
)
1029 memcpy(prmdata
, (void *) skb
->data
, skb
->len
);
1030 prmdata
[7] = 0xff - (u8
) skb
->len
;
1031 return pr_iucv
->message_send(path
, msg
, IUCV_IPRMDATA
, 0,
1032 (void *) prmdata
, 8);
1035 static int iucv_sock_sendmsg(struct kiocb
*iocb
, struct socket
*sock
,
1036 struct msghdr
*msg
, size_t len
)
1038 struct sock
*sk
= sock
->sk
;
1039 struct iucv_sock
*iucv
= iucv_sk(sk
);
1040 struct sk_buff
*skb
;
1041 struct iucv_message txmsg
;
1042 struct cmsghdr
*cmsg
;
1048 int noblock
= msg
->msg_flags
& MSG_DONTWAIT
;
1050 err
= sock_error(sk
);
1054 if (msg
->msg_flags
& MSG_OOB
)
1057 /* SOCK_SEQPACKET: we do not support segmented records */
1058 if (sk
->sk_type
== SOCK_SEQPACKET
&& !(msg
->msg_flags
& MSG_EOR
))
1063 if (sk
->sk_shutdown
& SEND_SHUTDOWN
) {
1068 /* Return if the socket is not in connected state */
1069 if (sk
->sk_state
!= IUCV_CONNECTED
) {
1074 /* initialize defaults */
1075 cmsg_done
= 0; /* check for duplicate headers */
1078 /* iterate over control messages */
1079 for (cmsg
= CMSG_FIRSTHDR(msg
); cmsg
;
1080 cmsg
= CMSG_NXTHDR(msg
, cmsg
)) {
1082 if (!CMSG_OK(msg
, cmsg
)) {
1087 if (cmsg
->cmsg_level
!= SOL_IUCV
)
1090 if (cmsg
->cmsg_type
& cmsg_done
) {
1094 cmsg_done
|= cmsg
->cmsg_type
;
1096 switch (cmsg
->cmsg_type
) {
1097 case SCM_IUCV_TRGCLS
:
1098 if (cmsg
->cmsg_len
!= CMSG_LEN(TRGCLS_SIZE
)) {
1103 /* set iucv message target class */
1104 memcpy(&txmsg
.class,
1105 (void *) CMSG_DATA(cmsg
), TRGCLS_SIZE
);
1116 /* allocate one skb for each iucv message:
1117 * this is fine for SOCK_SEQPACKET (unless we want to support
1118 * segmented records using the MSG_EOR flag), but
1119 * for SOCK_STREAM we might want to improve it in future */
1120 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
)
1121 skb
= sock_alloc_send_skb(sk
,
1122 len
+ sizeof(struct af_iucv_trans_hdr
) + ETH_HLEN
,
1125 skb
= sock_alloc_send_skb(sk
, len
, noblock
, &err
);
1130 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
)
1131 skb_reserve(skb
, sizeof(struct af_iucv_trans_hdr
) + ETH_HLEN
);
1132 if (memcpy_fromiovec(skb_put(skb
, len
), msg
->msg_iov
, len
)) {
1137 /* wait if outstanding messages for iucv path has reached */
1138 timeo
= sock_sndtimeo(sk
, noblock
);
1139 err
= iucv_sock_wait(sk
, iucv_below_msglim(sk
), timeo
);
1143 /* return -ECONNRESET if the socket is no longer connected */
1144 if (sk
->sk_state
!= IUCV_CONNECTED
) {
1149 /* increment and save iucv message tag for msg_completion cbk */
1150 txmsg
.tag
= iucv
->send_tag
++;
1151 memcpy(CB_TAG(skb
), &txmsg
.tag
, CB_TAG_LEN
);
1153 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
) {
1154 atomic_inc(&iucv
->msg_sent
);
1155 err
= afiucv_hs_send(&txmsg
, sk
, skb
, 0);
1157 atomic_dec(&iucv
->msg_sent
);
1162 skb_queue_tail(&iucv
->send_skb_q
, skb
);
1164 if (((iucv
->path
->flags
& IUCV_IPRMDATA
) & iucv
->flags
)
1166 err
= iucv_send_iprm(iucv
->path
, &txmsg
, skb
);
1168 /* on success: there is no message_complete callback
1169 * for an IPRMDATA msg; remove skb from send queue */
1171 skb_unlink(skb
, &iucv
->send_skb_q
);
1175 /* this error should never happen since the
1176 * IUCV_IPRMDATA path flag is set... sever path */
1178 pr_iucv
->path_sever(iucv
->path
, NULL
);
1179 skb_unlink(skb
, &iucv
->send_skb_q
);
1184 err
= pr_iucv
->message_send(iucv
->path
, &txmsg
, 0, 0,
1185 (void *) skb
->data
, skb
->len
);
1189 memcpy(user_id
, iucv
->dst_user_id
, 8);
1191 memcpy(appl_id
, iucv
->dst_name
, 8);
1192 pr_err("Application %s on z/VM guest %s"
1193 " exceeds message limit\n",
1198 skb_unlink(skb
, &iucv
->send_skb_q
);
1213 /* iucv_fragment_skb() - Fragment a single IUCV message into multiple skb's
1215 * Locking: must be called with message_q.lock held
1217 static int iucv_fragment_skb(struct sock
*sk
, struct sk_buff
*skb
, int len
)
1219 int dataleft
, size
, copied
= 0;
1220 struct sk_buff
*nskb
;
1224 if (dataleft
>= sk
->sk_rcvbuf
/ 4)
1225 size
= sk
->sk_rcvbuf
/ 4;
1229 nskb
= alloc_skb(size
, GFP_ATOMIC
| GFP_DMA
);
1233 /* copy target class to control buffer of new skb */
1234 memcpy(CB_TRGCLS(nskb
), CB_TRGCLS(skb
), CB_TRGCLS_LEN
);
1236 /* copy data fragment */
1237 memcpy(nskb
->data
, skb
->data
+ copied
, size
);
1241 skb_reset_transport_header(nskb
);
1242 skb_reset_network_header(nskb
);
1245 skb_queue_tail(&iucv_sk(sk
)->backlog_skb_q
, nskb
);
1251 /* iucv_process_message() - Receive a single outstanding IUCV message
1253 * Locking: must be called with message_q.lock held
1255 static void iucv_process_message(struct sock
*sk
, struct sk_buff
*skb
,
1256 struct iucv_path
*path
,
1257 struct iucv_message
*msg
)
1262 len
= iucv_msg_length(msg
);
1264 /* store msg target class in the second 4 bytes of skb ctrl buffer */
1265 /* Note: the first 4 bytes are reserved for msg tag */
1266 memcpy(CB_TRGCLS(skb
), &msg
->class, CB_TRGCLS_LEN
);
1268 /* check for special IPRM messages (e.g. iucv_sock_shutdown) */
1269 if ((msg
->flags
& IUCV_IPRMDATA
) && len
> 7) {
1270 if (memcmp(msg
->rmmsg
, iprm_shutdown
, 8) == 0) {
1275 rc
= pr_iucv
->message_receive(path
, msg
,
1276 msg
->flags
& IUCV_IPRMDATA
,
1277 skb
->data
, len
, NULL
);
1282 /* we need to fragment iucv messages for SOCK_STREAM only;
1283 * for SOCK_SEQPACKET, it is only relevant if we support
1284 * record segmentation using MSG_EOR (see also recvmsg()) */
1285 if (sk
->sk_type
== SOCK_STREAM
&&
1286 skb
->truesize
>= sk
->sk_rcvbuf
/ 4) {
1287 rc
= iucv_fragment_skb(sk
, skb
, len
);
1291 pr_iucv
->path_sever(path
, NULL
);
1294 skb
= skb_dequeue(&iucv_sk(sk
)->backlog_skb_q
);
1296 skb_reset_transport_header(skb
);
1297 skb_reset_network_header(skb
);
1302 if (sock_queue_rcv_skb(sk
, skb
))
1303 skb_queue_head(&iucv_sk(sk
)->backlog_skb_q
, skb
);
1306 /* iucv_process_message_q() - Process outstanding IUCV messages
1308 * Locking: must be called with message_q.lock held
1310 static void iucv_process_message_q(struct sock
*sk
)
1312 struct iucv_sock
*iucv
= iucv_sk(sk
);
1313 struct sk_buff
*skb
;
1314 struct sock_msg_q
*p
, *n
;
1316 list_for_each_entry_safe(p
, n
, &iucv
->message_q
.list
, list
) {
1317 skb
= alloc_skb(iucv_msg_length(&p
->msg
), GFP_ATOMIC
| GFP_DMA
);
1320 iucv_process_message(sk
, skb
, p
->path
, &p
->msg
);
1323 if (!skb_queue_empty(&iucv
->backlog_skb_q
))
1328 static int iucv_sock_recvmsg(struct kiocb
*iocb
, struct socket
*sock
,
1329 struct msghdr
*msg
, size_t len
, int flags
)
1331 int noblock
= flags
& MSG_DONTWAIT
;
1332 struct sock
*sk
= sock
->sk
;
1333 struct iucv_sock
*iucv
= iucv_sk(sk
);
1334 unsigned int copied
, rlen
;
1335 struct sk_buff
*skb
, *rskb
, *cskb
, *sskb
;
1339 if ((sk
->sk_state
== IUCV_DISCONN
) &&
1340 skb_queue_empty(&iucv
->backlog_skb_q
) &&
1341 skb_queue_empty(&sk
->sk_receive_queue
) &&
1342 list_empty(&iucv
->message_q
.list
))
1345 if (flags
& (MSG_OOB
))
1348 /* receive/dequeue next skb:
1349 * the function understands MSG_PEEK and, thus, does not dequeue skb */
1350 skb
= skb_recv_datagram(sk
, flags
, noblock
, &err
);
1352 if (sk
->sk_shutdown
& RCV_SHUTDOWN
)
1357 rlen
= skb
->len
; /* real length of skb */
1358 copied
= min_t(unsigned int, rlen
, len
);
1361 if (skb_copy_datagram_iovec(cskb
, 0, msg
->msg_iov
, copied
)) {
1362 if (!(flags
& MSG_PEEK
))
1363 skb_queue_head(&sk
->sk_receive_queue
, skb
);
1367 /* SOCK_SEQPACKET: set MSG_TRUNC if recv buf size is too small */
1368 if (sk
->sk_type
== SOCK_SEQPACKET
) {
1370 msg
->msg_flags
|= MSG_TRUNC
;
1371 /* each iucv message contains a complete record */
1372 msg
->msg_flags
|= MSG_EOR
;
1375 /* create control message to store iucv msg target class:
1376 * get the trgcls from the control buffer of the skb due to
1377 * fragmentation of original iucv message. */
1378 err
= put_cmsg(msg
, SOL_IUCV
, SCM_IUCV_TRGCLS
,
1379 CB_TRGCLS_LEN
, CB_TRGCLS(skb
));
1381 if (!(flags
& MSG_PEEK
))
1382 skb_queue_head(&sk
->sk_receive_queue
, skb
);
1386 /* Mark read part of skb as used */
1387 if (!(flags
& MSG_PEEK
)) {
1389 /* SOCK_STREAM: re-queue skb if it contains unreceived data */
1390 if (sk
->sk_type
== SOCK_STREAM
) {
1391 skb_pull(skb
, copied
);
1393 skb_queue_head(&sk
->sk_receive_queue
, skb
);
1399 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
) {
1400 atomic_inc(&iucv
->msg_recv
);
1401 if (atomic_read(&iucv
->msg_recv
) > iucv
->msglimit
) {
1403 iucv_sock_close(sk
);
1408 /* Queue backlog skbs */
1409 spin_lock_bh(&iucv
->message_q
.lock
);
1410 rskb
= skb_dequeue(&iucv
->backlog_skb_q
);
1412 if (sock_queue_rcv_skb(sk
, rskb
)) {
1413 skb_queue_head(&iucv
->backlog_skb_q
,
1417 rskb
= skb_dequeue(&iucv
->backlog_skb_q
);
1420 if (skb_queue_empty(&iucv
->backlog_skb_q
)) {
1421 if (!list_empty(&iucv
->message_q
.list
))
1422 iucv_process_message_q(sk
);
1423 if (atomic_read(&iucv
->msg_recv
) >=
1424 iucv
->msglimit
/ 2) {
1425 /* send WIN to peer */
1426 blen
= sizeof(struct af_iucv_trans_hdr
) +
1428 sskb
= sock_alloc_send_skb(sk
, blen
, 1, &err
);
1430 skb_reserve(sskb
, blen
);
1431 err
= afiucv_hs_send(NULL
, sk
, sskb
,
1435 sk
->sk_state
= IUCV_DISCONN
;
1436 sk
->sk_state_change(sk
);
1440 spin_unlock_bh(&iucv
->message_q
.lock
);
1444 /* SOCK_SEQPACKET: return real length if MSG_TRUNC is set */
1445 if (sk
->sk_type
== SOCK_SEQPACKET
&& (flags
& MSG_TRUNC
))
1451 static inline unsigned int iucv_accept_poll(struct sock
*parent
)
1453 struct iucv_sock
*isk
, *n
;
1456 list_for_each_entry_safe(isk
, n
, &iucv_sk(parent
)->accept_q
, accept_q
) {
1457 sk
= (struct sock
*) isk
;
1459 if (sk
->sk_state
== IUCV_CONNECTED
)
1460 return POLLIN
| POLLRDNORM
;
1466 unsigned int iucv_sock_poll(struct file
*file
, struct socket
*sock
,
1469 struct sock
*sk
= sock
->sk
;
1470 unsigned int mask
= 0;
1472 sock_poll_wait(file
, sk_sleep(sk
), wait
);
1474 if (sk
->sk_state
== IUCV_LISTEN
)
1475 return iucv_accept_poll(sk
);
1477 if (sk
->sk_err
|| !skb_queue_empty(&sk
->sk_error_queue
))
1480 if (sk
->sk_shutdown
& RCV_SHUTDOWN
)
1483 if (sk
->sk_shutdown
== SHUTDOWN_MASK
)
1486 if (!skb_queue_empty(&sk
->sk_receive_queue
) ||
1487 (sk
->sk_shutdown
& RCV_SHUTDOWN
))
1488 mask
|= POLLIN
| POLLRDNORM
;
1490 if (sk
->sk_state
== IUCV_CLOSED
)
1493 if (sk
->sk_state
== IUCV_DISCONN
)
1496 if (sock_writeable(sk
) && iucv_below_msglim(sk
))
1497 mask
|= POLLOUT
| POLLWRNORM
| POLLWRBAND
;
1499 set_bit(SOCK_ASYNC_NOSPACE
, &sk
->sk_socket
->flags
);
1504 static int iucv_sock_shutdown(struct socket
*sock
, int how
)
1506 struct sock
*sk
= sock
->sk
;
1507 struct iucv_sock
*iucv
= iucv_sk(sk
);
1508 struct iucv_message txmsg
;
1513 if ((how
& ~SHUTDOWN_MASK
) || !how
)
1517 switch (sk
->sk_state
) {
1525 sk
->sk_shutdown
|= how
;
1529 if (how
== SEND_SHUTDOWN
|| how
== SHUTDOWN_MASK
) {
1532 err
= pr_iucv
->message_send(iucv
->path
, &txmsg
, IUCV_IPRMDATA
,
1533 0, (void *) iprm_shutdown
, 8);
1549 if (how
== RCV_SHUTDOWN
|| how
== SHUTDOWN_MASK
) {
1550 err
= pr_iucv
->path_quiesce(iucv
->path
, NULL
);
1554 skb_queue_purge(&sk
->sk_receive_queue
);
1557 /* Wake up anyone sleeping in poll */
1558 sk
->sk_state_change(sk
);
1565 static int iucv_sock_release(struct socket
*sock
)
1567 struct sock
*sk
= sock
->sk
;
1573 iucv_sock_close(sk
);
1580 /* getsockopt and setsockopt */
1581 static int iucv_sock_setsockopt(struct socket
*sock
, int level
, int optname
,
1582 char __user
*optval
, unsigned int optlen
)
1584 struct sock
*sk
= sock
->sk
;
1585 struct iucv_sock
*iucv
= iucv_sk(sk
);
1589 if (level
!= SOL_IUCV
)
1590 return -ENOPROTOOPT
;
1592 if (optlen
< sizeof(int))
1595 if (get_user(val
, (int __user
*) optval
))
1602 case SO_IPRMDATA_MSG
:
1604 iucv
->flags
|= IUCV_IPRMDATA
;
1606 iucv
->flags
&= ~IUCV_IPRMDATA
;
1609 switch (sk
->sk_state
) {
1612 if (val
< 1 || val
> (u16
)(~0))
1615 iucv
->msglimit
= val
;
1631 static int iucv_sock_getsockopt(struct socket
*sock
, int level
, int optname
,
1632 char __user
*optval
, int __user
*optlen
)
1634 struct sock
*sk
= sock
->sk
;
1635 struct iucv_sock
*iucv
= iucv_sk(sk
);
1638 if (level
!= SOL_IUCV
)
1639 return -ENOPROTOOPT
;
1641 if (get_user(len
, optlen
))
1647 len
= min_t(unsigned int, len
, sizeof(int));
1650 case SO_IPRMDATA_MSG
:
1651 val
= (iucv
->flags
& IUCV_IPRMDATA
) ? 1 : 0;
1655 val
= (iucv
->path
!= NULL
) ? iucv
->path
->msglim
/* connected */
1656 : iucv
->msglimit
; /* default */
1660 return -ENOPROTOOPT
;
1663 if (put_user(len
, optlen
))
1665 if (copy_to_user(optval
, &val
, len
))
1672 /* Callback wrappers - called from iucv base support */
1673 static int iucv_callback_connreq(struct iucv_path
*path
,
1674 u8 ipvmid
[8], u8 ipuser
[16])
1676 unsigned char user_data
[16];
1677 unsigned char nuser_data
[16];
1678 unsigned char src_name
[8];
1679 struct hlist_node
*node
;
1680 struct sock
*sk
, *nsk
;
1681 struct iucv_sock
*iucv
, *niucv
;
1684 memcpy(src_name
, ipuser
, 8);
1685 EBCASC(src_name
, 8);
1686 /* Find out if this path belongs to af_iucv. */
1687 read_lock(&iucv_sk_list
.lock
);
1690 sk_for_each(sk
, node
, &iucv_sk_list
.head
)
1691 if (sk
->sk_state
== IUCV_LISTEN
&&
1692 !memcmp(&iucv_sk(sk
)->src_name
, src_name
, 8)) {
1694 * Found a listening socket with
1695 * src_name == ipuser[0-7].
1700 read_unlock(&iucv_sk_list
.lock
);
1702 /* No socket found, not one of our paths. */
1707 /* Check if parent socket is listening */
1708 low_nmcpy(user_data
, iucv
->src_name
);
1709 high_nmcpy(user_data
, iucv
->dst_name
);
1710 ASCEBC(user_data
, sizeof(user_data
));
1711 if (sk
->sk_state
!= IUCV_LISTEN
) {
1712 err
= pr_iucv
->path_sever(path
, user_data
);
1713 iucv_path_free(path
);
1717 /* Check for backlog size */
1718 if (sk_acceptq_is_full(sk
)) {
1719 err
= pr_iucv
->path_sever(path
, user_data
);
1720 iucv_path_free(path
);
1724 /* Create the new socket */
1725 nsk
= iucv_sock_alloc(NULL
, sk
->sk_type
, GFP_ATOMIC
);
1727 err
= pr_iucv
->path_sever(path
, user_data
);
1728 iucv_path_free(path
);
1732 niucv
= iucv_sk(nsk
);
1733 iucv_sock_init(nsk
, sk
);
1735 /* Set the new iucv_sock */
1736 memcpy(niucv
->dst_name
, ipuser
+ 8, 8);
1737 EBCASC(niucv
->dst_name
, 8);
1738 memcpy(niucv
->dst_user_id
, ipvmid
, 8);
1739 memcpy(niucv
->src_name
, iucv
->src_name
, 8);
1740 memcpy(niucv
->src_user_id
, iucv
->src_user_id
, 8);
1743 /* Call iucv_accept */
1744 high_nmcpy(nuser_data
, ipuser
+ 8);
1745 memcpy(nuser_data
+ 8, niucv
->src_name
, 8);
1746 ASCEBC(nuser_data
+ 8, 8);
1748 /* set message limit for path based on msglimit of accepting socket */
1749 niucv
->msglimit
= iucv
->msglimit
;
1750 path
->msglim
= iucv
->msglimit
;
1751 err
= pr_iucv
->path_accept(path
, &af_iucv_handler
, nuser_data
, nsk
);
1753 iucv_sever_path(nsk
, 1);
1754 iucv_sock_kill(nsk
);
1758 iucv_accept_enqueue(sk
, nsk
);
1760 /* Wake up accept */
1761 nsk
->sk_state
= IUCV_CONNECTED
;
1762 sk
->sk_data_ready(sk
, 1);
1769 static void iucv_callback_connack(struct iucv_path
*path
, u8 ipuser
[16])
1771 struct sock
*sk
= path
->private;
1773 sk
->sk_state
= IUCV_CONNECTED
;
1774 sk
->sk_state_change(sk
);
1777 static void iucv_callback_rx(struct iucv_path
*path
, struct iucv_message
*msg
)
1779 struct sock
*sk
= path
->private;
1780 struct iucv_sock
*iucv
= iucv_sk(sk
);
1781 struct sk_buff
*skb
;
1782 struct sock_msg_q
*save_msg
;
1785 if (sk
->sk_shutdown
& RCV_SHUTDOWN
) {
1786 pr_iucv
->message_reject(path
, msg
);
1790 spin_lock(&iucv
->message_q
.lock
);
1792 if (!list_empty(&iucv
->message_q
.list
) ||
1793 !skb_queue_empty(&iucv
->backlog_skb_q
))
1796 len
= atomic_read(&sk
->sk_rmem_alloc
);
1797 len
+= SKB_TRUESIZE(iucv_msg_length(msg
));
1798 if (len
> sk
->sk_rcvbuf
)
1801 skb
= alloc_skb(iucv_msg_length(msg
), GFP_ATOMIC
| GFP_DMA
);
1805 iucv_process_message(sk
, skb
, path
, msg
);
1809 save_msg
= kzalloc(sizeof(struct sock_msg_q
), GFP_ATOMIC
| GFP_DMA
);
1812 save_msg
->path
= path
;
1813 save_msg
->msg
= *msg
;
1815 list_add_tail(&save_msg
->list
, &iucv
->message_q
.list
);
1818 spin_unlock(&iucv
->message_q
.lock
);
1821 static void iucv_callback_txdone(struct iucv_path
*path
,
1822 struct iucv_message
*msg
)
1824 struct sock
*sk
= path
->private;
1825 struct sk_buff
*this = NULL
;
1826 struct sk_buff_head
*list
= &iucv_sk(sk
)->send_skb_q
;
1827 struct sk_buff
*list_skb
= list
->next
;
1828 unsigned long flags
;
1831 if (!skb_queue_empty(list
)) {
1832 spin_lock_irqsave(&list
->lock
, flags
);
1834 while (list_skb
!= (struct sk_buff
*)list
) {
1835 if (!memcmp(&msg
->tag
, CB_TAG(list_skb
), CB_TAG_LEN
)) {
1839 list_skb
= list_skb
->next
;
1842 __skb_unlink(this, list
);
1844 spin_unlock_irqrestore(&list
->lock
, flags
);
1848 /* wake up any process waiting for sending */
1849 iucv_sock_wake_msglim(sk
);
1853 if (sk
->sk_state
== IUCV_CLOSING
) {
1854 if (skb_queue_empty(&iucv_sk(sk
)->send_skb_q
)) {
1855 sk
->sk_state
= IUCV_CLOSED
;
1856 sk
->sk_state_change(sk
);
1863 static void iucv_callback_connrej(struct iucv_path
*path
, u8 ipuser
[16])
1865 struct sock
*sk
= path
->private;
1867 if (sk
->sk_state
== IUCV_CLOSED
)
1871 iucv_sever_path(sk
, 1);
1872 sk
->sk_state
= IUCV_DISCONN
;
1874 sk
->sk_state_change(sk
);
1878 /* called if the other communication side shuts down its RECV direction;
1879 * in turn, the callback sets SEND_SHUTDOWN to disable sending of data.
1881 static void iucv_callback_shutdown(struct iucv_path
*path
, u8 ipuser
[16])
1883 struct sock
*sk
= path
->private;
1886 if (sk
->sk_state
!= IUCV_CLOSED
) {
1887 sk
->sk_shutdown
|= SEND_SHUTDOWN
;
1888 sk
->sk_state_change(sk
);
1893 /***************** HiperSockets transport callbacks ********************/
1894 static void afiucv_swap_src_dest(struct sk_buff
*skb
)
1896 struct af_iucv_trans_hdr
*trans_hdr
=
1897 (struct af_iucv_trans_hdr
*)skb
->data
;
1901 ASCEBC(trans_hdr
->destUserID
, sizeof(trans_hdr
->destUserID
));
1902 ASCEBC(trans_hdr
->destAppName
, sizeof(trans_hdr
->destAppName
));
1903 ASCEBC(trans_hdr
->srcUserID
, sizeof(trans_hdr
->srcUserID
));
1904 ASCEBC(trans_hdr
->srcAppName
, sizeof(trans_hdr
->srcAppName
));
1905 memcpy(tmpID
, trans_hdr
->srcUserID
, 8);
1906 memcpy(tmpName
, trans_hdr
->srcAppName
, 8);
1907 memcpy(trans_hdr
->srcUserID
, trans_hdr
->destUserID
, 8);
1908 memcpy(trans_hdr
->srcAppName
, trans_hdr
->destAppName
, 8);
1909 memcpy(trans_hdr
->destUserID
, tmpID
, 8);
1910 memcpy(trans_hdr
->destAppName
, tmpName
, 8);
1911 skb_push(skb
, ETH_HLEN
);
1912 memset(skb
->data
, 0, ETH_HLEN
);
1916 * afiucv_hs_callback_syn - react on received SYN
1918 static int afiucv_hs_callback_syn(struct sock
*sk
, struct sk_buff
*skb
)
1921 struct iucv_sock
*iucv
, *niucv
;
1922 struct af_iucv_trans_hdr
*trans_hdr
;
1926 trans_hdr
= (struct af_iucv_trans_hdr
*)skb
->data
;
1928 /* no sock - connection refused */
1929 afiucv_swap_src_dest(skb
);
1930 trans_hdr
->flags
= AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_FIN
;
1931 err
= dev_queue_xmit(skb
);
1935 nsk
= iucv_sock_alloc(NULL
, sk
->sk_type
, GFP_ATOMIC
);
1937 if ((sk
->sk_state
!= IUCV_LISTEN
) ||
1938 sk_acceptq_is_full(sk
) ||
1940 /* error on server socket - connection refused */
1943 afiucv_swap_src_dest(skb
);
1944 trans_hdr
->flags
= AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_FIN
;
1945 err
= dev_queue_xmit(skb
);
1950 niucv
= iucv_sk(nsk
);
1951 iucv_sock_init(nsk
, sk
);
1952 niucv
->transport
= AF_IUCV_TRANS_HIPER
;
1953 niucv
->msglimit
= iucv
->msglimit
;
1954 if (!trans_hdr
->window
)
1955 niucv
->msglimit_peer
= IUCV_HIPER_MSGLIM_DEFAULT
;
1957 niucv
->msglimit_peer
= trans_hdr
->window
;
1958 memcpy(niucv
->dst_name
, trans_hdr
->srcAppName
, 8);
1959 memcpy(niucv
->dst_user_id
, trans_hdr
->srcUserID
, 8);
1960 memcpy(niucv
->src_name
, iucv
->src_name
, 8);
1961 memcpy(niucv
->src_user_id
, iucv
->src_user_id
, 8);
1962 nsk
->sk_bound_dev_if
= sk
->sk_bound_dev_if
;
1963 niucv
->hs_dev
= iucv
->hs_dev
;
1964 dev_hold(niucv
->hs_dev
);
1965 afiucv_swap_src_dest(skb
);
1966 trans_hdr
->flags
= AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_ACK
;
1967 trans_hdr
->window
= niucv
->msglimit
;
1968 /* if receiver acks the xmit connection is established */
1969 err
= dev_queue_xmit(skb
);
1971 iucv_accept_enqueue(sk
, nsk
);
1972 nsk
->sk_state
= IUCV_CONNECTED
;
1973 sk
->sk_data_ready(sk
, 1);
1975 iucv_sock_kill(nsk
);
1979 return NET_RX_SUCCESS
;
1983 * afiucv_hs_callback_synack() - react on received SYN-ACK
1985 static int afiucv_hs_callback_synack(struct sock
*sk
, struct sk_buff
*skb
)
1987 struct iucv_sock
*iucv
= iucv_sk(sk
);
1988 struct af_iucv_trans_hdr
*trans_hdr
=
1989 (struct af_iucv_trans_hdr
*)skb
->data
;
1993 if (sk
->sk_state
!= IUCV_BOUND
)
1996 iucv
->msglimit_peer
= trans_hdr
->window
;
1997 sk
->sk_state
= IUCV_CONNECTED
;
1998 sk
->sk_state_change(sk
);
2002 return NET_RX_SUCCESS
;
2006 * afiucv_hs_callback_synfin() - react on received SYN_FIN
2008 static int afiucv_hs_callback_synfin(struct sock
*sk
, struct sk_buff
*skb
)
2010 struct iucv_sock
*iucv
= iucv_sk(sk
);
2014 if (sk
->sk_state
!= IUCV_BOUND
)
2017 sk
->sk_state
= IUCV_DISCONN
;
2018 sk
->sk_state_change(sk
);
2022 return NET_RX_SUCCESS
;
2026 * afiucv_hs_callback_fin() - react on received FIN
2028 static int afiucv_hs_callback_fin(struct sock
*sk
, struct sk_buff
*skb
)
2030 struct iucv_sock
*iucv
= iucv_sk(sk
);
2032 /* other end of connection closed */
2036 if (sk
->sk_state
== IUCV_CONNECTED
) {
2037 sk
->sk_state
= IUCV_DISCONN
;
2038 sk
->sk_state_change(sk
);
2043 return NET_RX_SUCCESS
;
2047 * afiucv_hs_callback_win() - react on received WIN
2049 static int afiucv_hs_callback_win(struct sock
*sk
, struct sk_buff
*skb
)
2051 struct iucv_sock
*iucv
= iucv_sk(sk
);
2052 struct af_iucv_trans_hdr
*trans_hdr
=
2053 (struct af_iucv_trans_hdr
*)skb
->data
;
2056 return NET_RX_SUCCESS
;
2058 if (sk
->sk_state
!= IUCV_CONNECTED
)
2059 return NET_RX_SUCCESS
;
2061 atomic_sub(trans_hdr
->window
, &iucv
->msg_sent
);
2062 iucv_sock_wake_msglim(sk
);
2063 return NET_RX_SUCCESS
;
2067 * afiucv_hs_callback_rx() - react on received data
2069 static int afiucv_hs_callback_rx(struct sock
*sk
, struct sk_buff
*skb
)
2071 struct iucv_sock
*iucv
= iucv_sk(sk
);
2075 return NET_RX_SUCCESS
;
2078 if (sk
->sk_state
!= IUCV_CONNECTED
) {
2080 return NET_RX_SUCCESS
;
2083 /* write stuff from iucv_msg to skb cb */
2084 if (skb
->len
<= sizeof(struct af_iucv_trans_hdr
)) {
2086 return NET_RX_SUCCESS
;
2088 skb_pull(skb
, sizeof(struct af_iucv_trans_hdr
));
2089 skb_reset_transport_header(skb
);
2090 skb_reset_network_header(skb
);
2091 spin_lock(&iucv
->message_q
.lock
);
2092 if (skb_queue_empty(&iucv
->backlog_skb_q
)) {
2093 if (sock_queue_rcv_skb(sk
, skb
)) {
2094 /* handle rcv queue full */
2095 skb_queue_tail(&iucv
->backlog_skb_q
, skb
);
2098 skb_queue_tail(&iucv_sk(sk
)->backlog_skb_q
, skb
);
2099 spin_unlock(&iucv
->message_q
.lock
);
2100 return NET_RX_SUCCESS
;
2104 * afiucv_hs_rcv() - base function for arriving data through HiperSockets
2106 * called from netif RX softirq
2108 static int afiucv_hs_rcv(struct sk_buff
*skb
, struct net_device
*dev
,
2109 struct packet_type
*pt
, struct net_device
*orig_dev
)
2111 struct hlist_node
*node
;
2113 struct iucv_sock
*iucv
;
2114 struct af_iucv_trans_hdr
*trans_hdr
;
2118 skb_pull(skb
, ETH_HLEN
);
2119 trans_hdr
= (struct af_iucv_trans_hdr
*)skb
->data
;
2120 EBCASC(trans_hdr
->destAppName
, sizeof(trans_hdr
->destAppName
));
2121 EBCASC(trans_hdr
->destUserID
, sizeof(trans_hdr
->destUserID
));
2122 EBCASC(trans_hdr
->srcAppName
, sizeof(trans_hdr
->srcAppName
));
2123 EBCASC(trans_hdr
->srcUserID
, sizeof(trans_hdr
->srcUserID
));
2124 memset(nullstring
, 0, sizeof(nullstring
));
2127 read_lock(&iucv_sk_list
.lock
);
2128 sk_for_each(sk
, node
, &iucv_sk_list
.head
) {
2129 if (trans_hdr
->flags
== AF_IUCV_FLAG_SYN
) {
2130 if ((!memcmp(&iucv_sk(sk
)->src_name
,
2131 trans_hdr
->destAppName
, 8)) &&
2132 (!memcmp(&iucv_sk(sk
)->src_user_id
,
2133 trans_hdr
->destUserID
, 8)) &&
2134 (!memcmp(&iucv_sk(sk
)->dst_name
, nullstring
, 8)) &&
2135 (!memcmp(&iucv_sk(sk
)->dst_user_id
,
2141 if ((!memcmp(&iucv_sk(sk
)->src_name
,
2142 trans_hdr
->destAppName
, 8)) &&
2143 (!memcmp(&iucv_sk(sk
)->src_user_id
,
2144 trans_hdr
->destUserID
, 8)) &&
2145 (!memcmp(&iucv_sk(sk
)->dst_name
,
2146 trans_hdr
->srcAppName
, 8)) &&
2147 (!memcmp(&iucv_sk(sk
)->dst_user_id
,
2148 trans_hdr
->srcUserID
, 8))) {
2154 read_unlock(&iucv_sk_list
.lock
);
2159 how should we send with no sock
2160 1) send without sock no send rc checking?
2161 2) introduce default sock to handle this cases
2163 SYN -> send SYN|ACK in good case, send SYN|FIN in bad case
2165 SYN|ACK, SYN|FIN, FIN -> no action? */
2167 switch (trans_hdr
->flags
) {
2168 case AF_IUCV_FLAG_SYN
:
2169 /* connect request */
2170 err
= afiucv_hs_callback_syn(sk
, skb
);
2172 case (AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_ACK
):
2173 /* connect request confirmed */
2174 err
= afiucv_hs_callback_synack(sk
, skb
);
2176 case (AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_FIN
):
2177 /* connect request refused */
2178 err
= afiucv_hs_callback_synfin(sk
, skb
);
2180 case (AF_IUCV_FLAG_FIN
):
2182 err
= afiucv_hs_callback_fin(sk
, skb
);
2184 case (AF_IUCV_FLAG_WIN
):
2185 err
= afiucv_hs_callback_win(sk
, skb
);
2186 if (skb
->len
== sizeof(struct af_iucv_trans_hdr
)) {
2192 /* plain data frame */
2193 memcpy(CB_TRGCLS(skb
), &trans_hdr
->iucv_hdr
.class,
2195 err
= afiucv_hs_callback_rx(sk
, skb
);
2205 * afiucv_hs_callback_txnotify() - handle send notifcations from HiperSockets
2208 static void afiucv_hs_callback_txnotify(struct sk_buff
*skb
,
2209 enum iucv_tx_notify n
)
2211 struct sock
*isk
= skb
->sk
;
2212 struct sock
*sk
= NULL
;
2213 struct iucv_sock
*iucv
= NULL
;
2214 struct sk_buff_head
*list
;
2215 struct sk_buff
*list_skb
;
2216 struct sk_buff
*nskb
;
2217 unsigned long flags
;
2218 struct hlist_node
*node
;
2220 read_lock_irqsave(&iucv_sk_list
.lock
, flags
);
2221 sk_for_each(sk
, node
, &iucv_sk_list
.head
)
2226 read_unlock_irqrestore(&iucv_sk_list
.lock
, flags
);
2228 if (!iucv
|| sock_flag(sk
, SOCK_ZAPPED
))
2231 list
= &iucv
->send_skb_q
;
2232 spin_lock_irqsave(&list
->lock
, flags
);
2233 if (skb_queue_empty(list
))
2235 list_skb
= list
->next
;
2236 nskb
= list_skb
->next
;
2237 while (list_skb
!= (struct sk_buff
*)list
) {
2238 if (skb_shinfo(list_skb
) == skb_shinfo(skb
)) {
2241 __skb_unlink(list_skb
, list
);
2242 kfree_skb(list_skb
);
2243 iucv_sock_wake_msglim(sk
);
2245 case TX_NOTIFY_PENDING
:
2246 atomic_inc(&iucv
->pendings
);
2248 case TX_NOTIFY_DELAYED_OK
:
2249 __skb_unlink(list_skb
, list
);
2250 atomic_dec(&iucv
->pendings
);
2251 if (atomic_read(&iucv
->pendings
) <= 0)
2252 iucv_sock_wake_msglim(sk
);
2253 kfree_skb(list_skb
);
2255 case TX_NOTIFY_UNREACHABLE
:
2256 case TX_NOTIFY_DELAYED_UNREACHABLE
:
2257 case TX_NOTIFY_TPQFULL
: /* not yet used */
2258 case TX_NOTIFY_GENERALERROR
:
2259 case TX_NOTIFY_DELAYED_GENERALERROR
:
2260 __skb_unlink(list_skb
, list
);
2261 kfree_skb(list_skb
);
2262 if (sk
->sk_state
== IUCV_CONNECTED
) {
2263 sk
->sk_state
= IUCV_DISCONN
;
2264 sk
->sk_state_change(sk
);
2274 spin_unlock_irqrestore(&list
->lock
, flags
);
2276 if (sk
->sk_state
== IUCV_CLOSING
) {
2277 if (skb_queue_empty(&iucv_sk(sk
)->send_skb_q
)) {
2278 sk
->sk_state
= IUCV_CLOSED
;
2279 sk
->sk_state_change(sk
);
2284 static const struct proto_ops iucv_sock_ops
= {
2286 .owner
= THIS_MODULE
,
2287 .release
= iucv_sock_release
,
2288 .bind
= iucv_sock_bind
,
2289 .connect
= iucv_sock_connect
,
2290 .listen
= iucv_sock_listen
,
2291 .accept
= iucv_sock_accept
,
2292 .getname
= iucv_sock_getname
,
2293 .sendmsg
= iucv_sock_sendmsg
,
2294 .recvmsg
= iucv_sock_recvmsg
,
2295 .poll
= iucv_sock_poll
,
2296 .ioctl
= sock_no_ioctl
,
2297 .mmap
= sock_no_mmap
,
2298 .socketpair
= sock_no_socketpair
,
2299 .shutdown
= iucv_sock_shutdown
,
2300 .setsockopt
= iucv_sock_setsockopt
,
2301 .getsockopt
= iucv_sock_getsockopt
,
2304 static const struct net_proto_family iucv_sock_family_ops
= {
2306 .owner
= THIS_MODULE
,
2307 .create
= iucv_sock_create
,
2310 static struct packet_type iucv_packet_type
= {
2311 .type
= cpu_to_be16(ETH_P_AF_IUCV
),
2312 .func
= afiucv_hs_rcv
,
2315 static int afiucv_iucv_init(void)
2319 err
= pr_iucv
->iucv_register(&af_iucv_handler
, 0);
2322 /* establish dummy device */
2323 af_iucv_driver
.bus
= pr_iucv
->bus
;
2324 err
= driver_register(&af_iucv_driver
);
2327 af_iucv_dev
= kzalloc(sizeof(struct device
), GFP_KERNEL
);
2332 dev_set_name(af_iucv_dev
, "af_iucv");
2333 af_iucv_dev
->bus
= pr_iucv
->bus
;
2334 af_iucv_dev
->parent
= pr_iucv
->root
;
2335 af_iucv_dev
->release
= (void (*)(struct device
*))kfree
;
2336 af_iucv_dev
->driver
= &af_iucv_driver
;
2337 err
= device_register(af_iucv_dev
);
2343 driver_unregister(&af_iucv_driver
);
2345 pr_iucv
->iucv_unregister(&af_iucv_handler
, 0);
2350 static int __init
afiucv_init(void)
2354 if (MACHINE_IS_VM
) {
2355 cpcmd("QUERY USERID", iucv_userid
, sizeof(iucv_userid
), &err
);
2356 if (unlikely(err
)) {
2358 err
= -EPROTONOSUPPORT
;
2362 pr_iucv
= try_then_request_module(symbol_get(iucv_if
), "iucv");
2364 printk(KERN_WARNING
"iucv_if lookup failed\n");
2365 memset(&iucv_userid
, 0, sizeof(iucv_userid
));
2368 memset(&iucv_userid
, 0, sizeof(iucv_userid
));
2372 err
= proto_register(&iucv_proto
, 0);
2375 err
= sock_register(&iucv_sock_family_ops
);
2380 err
= afiucv_iucv_init();
2384 dev_add_pack(&iucv_packet_type
);
2388 sock_unregister(PF_IUCV
);
2390 proto_unregister(&iucv_proto
);
2393 symbol_put(iucv_if
);
2397 static void __exit
afiucv_exit(void)
2400 device_unregister(af_iucv_dev
);
2401 driver_unregister(&af_iucv_driver
);
2402 pr_iucv
->iucv_unregister(&af_iucv_handler
, 0);
2403 symbol_put(iucv_if
);
2405 dev_remove_pack(&iucv_packet_type
);
2406 sock_unregister(PF_IUCV
);
2407 proto_unregister(&iucv_proto
);
2410 module_init(afiucv_init
);
2411 module_exit(afiucv_exit
);
2413 MODULE_AUTHOR("Jennifer Hunt <jenhunt@us.ibm.com>");
2414 MODULE_DESCRIPTION("IUCV Sockets ver " VERSION
);
2415 MODULE_VERSION(VERSION
);
2416 MODULE_LICENSE("GPL");
2417 MODULE_ALIAS_NETPROTO(PF_IUCV
);