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
);
94 static int afiucv_hs_rcv(struct sk_buff
*skb
, struct net_device
*dev
,
95 struct packet_type
*pt
, struct net_device
*orig_dev
);
96 static int afiucv_hs_send(struct iucv_message
*imsg
, struct sock
*sock
,
97 struct sk_buff
*skb
, u8 flags
);
98 static void afiucv_hs_callback_txnotify(struct sk_buff
*, enum iucv_tx_notify
);
100 /* Call Back functions */
101 static void iucv_callback_rx(struct iucv_path
*, struct iucv_message
*);
102 static void iucv_callback_txdone(struct iucv_path
*, struct iucv_message
*);
103 static void iucv_callback_connack(struct iucv_path
*, u8 ipuser
[16]);
104 static int iucv_callback_connreq(struct iucv_path
*, u8 ipvmid
[8],
106 static void iucv_callback_connrej(struct iucv_path
*, u8 ipuser
[16]);
107 static void iucv_callback_shutdown(struct iucv_path
*, u8 ipuser
[16]);
109 static struct iucv_sock_list iucv_sk_list
= {
110 .lock
= __RW_LOCK_UNLOCKED(iucv_sk_list
.lock
),
111 .autobind_name
= ATOMIC_INIT(0)
114 static struct iucv_handler af_iucv_handler
= {
115 .path_pending
= iucv_callback_connreq
,
116 .path_complete
= iucv_callback_connack
,
117 .path_severed
= iucv_callback_connrej
,
118 .message_pending
= iucv_callback_rx
,
119 .message_complete
= iucv_callback_txdone
,
120 .path_quiesced
= iucv_callback_shutdown
,
123 static inline void high_nmcpy(unsigned char *dst
, char *src
)
128 static inline void low_nmcpy(unsigned char *dst
, char *src
)
130 memcpy(&dst
[8], src
, 8);
133 static int afiucv_pm_prepare(struct device
*dev
)
135 #ifdef CONFIG_PM_DEBUG
136 printk(KERN_WARNING
"afiucv_pm_prepare\n");
141 static void afiucv_pm_complete(struct device
*dev
)
143 #ifdef CONFIG_PM_DEBUG
144 printk(KERN_WARNING
"afiucv_pm_complete\n");
149 * afiucv_pm_freeze() - Freeze PM callback
150 * @dev: AFIUCV dummy device
152 * Sever all established IUCV communication pathes
154 static int afiucv_pm_freeze(struct device
*dev
)
156 struct iucv_sock
*iucv
;
158 struct hlist_node
*node
;
161 #ifdef CONFIG_PM_DEBUG
162 printk(KERN_WARNING
"afiucv_pm_freeze\n");
164 read_lock(&iucv_sk_list
.lock
);
165 sk_for_each(sk
, node
, &iucv_sk_list
.head
) {
167 skb_queue_purge(&iucv
->send_skb_q
);
168 skb_queue_purge(&iucv
->backlog_skb_q
);
169 switch (sk
->sk_state
) {
175 err
= pr_iucv
->path_sever(iucv
->path
, NULL
);
176 iucv_path_free(iucv
->path
);
188 read_unlock(&iucv_sk_list
.lock
);
193 * afiucv_pm_restore_thaw() - Thaw and restore PM callback
194 * @dev: AFIUCV dummy device
196 * socket clean up after freeze
198 static int afiucv_pm_restore_thaw(struct device
*dev
)
201 struct hlist_node
*node
;
203 #ifdef CONFIG_PM_DEBUG
204 printk(KERN_WARNING
"afiucv_pm_restore_thaw\n");
206 read_lock(&iucv_sk_list
.lock
);
207 sk_for_each(sk
, node
, &iucv_sk_list
.head
) {
208 switch (sk
->sk_state
) {
211 sk
->sk_state
= IUCV_DISCONN
;
212 sk
->sk_state_change(sk
);
224 read_unlock(&iucv_sk_list
.lock
);
228 static const struct dev_pm_ops afiucv_pm_ops
= {
229 .prepare
= afiucv_pm_prepare
,
230 .complete
= afiucv_pm_complete
,
231 .freeze
= afiucv_pm_freeze
,
232 .thaw
= afiucv_pm_restore_thaw
,
233 .restore
= afiucv_pm_restore_thaw
,
236 static struct device_driver af_iucv_driver
= {
237 .owner
= THIS_MODULE
,
240 .pm
= &afiucv_pm_ops
,
243 /* dummy device used as trigger for PM functions */
244 static struct device
*af_iucv_dev
;
247 * iucv_msg_length() - Returns the length of an iucv message.
248 * @msg: Pointer to struct iucv_message, MUST NOT be NULL
250 * The function returns the length of the specified iucv message @msg of data
251 * stored in a buffer and of data stored in the parameter list (PRMDATA).
253 * For IUCV_IPRMDATA, AF_IUCV uses the following convention to transport socket
255 * PRMDATA[0..6] socket data (max 7 bytes);
256 * PRMDATA[7] socket data length value (len is 0xff - PRMDATA[7])
258 * The socket data length is computed by subtracting the socket data length
260 * If the socket data len is greater 7, then PRMDATA can be used for special
261 * notifications (see iucv_sock_shutdown); and further,
262 * if the socket data len is > 7, the function returns 8.
264 * Use this function to allocate socket buffers to store iucv message data.
266 static inline size_t iucv_msg_length(struct iucv_message
*msg
)
270 if (msg
->flags
& IUCV_IPRMDATA
) {
271 datalen
= 0xff - msg
->rmmsg
[7];
272 return (datalen
< 8) ? datalen
: 8;
278 * iucv_sock_in_state() - check for specific states
279 * @sk: sock structure
280 * @state: first iucv sk state
281 * @state: second iucv sk state
283 * Returns true if the socket in either in the first or second state.
285 static int iucv_sock_in_state(struct sock
*sk
, int state
, int state2
)
287 return (sk
->sk_state
== state
|| sk
->sk_state
== state2
);
291 * iucv_below_msglim() - function to check if messages can be sent
292 * @sk: sock structure
294 * Returns true if the send queue length is lower than the message limit.
295 * Always returns true if the socket is not connected (no iucv path for
296 * checking the message limit).
298 static inline int iucv_below_msglim(struct sock
*sk
)
300 struct iucv_sock
*iucv
= iucv_sk(sk
);
302 if (sk
->sk_state
!= IUCV_CONNECTED
)
304 if (iucv
->transport
== AF_IUCV_TRANS_IUCV
)
305 return (skb_queue_len(&iucv
->send_skb_q
) < iucv
->path
->msglim
);
307 return ((atomic_read(&iucv
->msg_sent
) < iucv
->msglimit_peer
) &&
308 (atomic_read(&iucv
->pendings
) <= 0));
312 * iucv_sock_wake_msglim() - Wake up thread waiting on msg limit
314 static void iucv_sock_wake_msglim(struct sock
*sk
)
316 struct socket_wq
*wq
;
319 wq
= rcu_dereference(sk
->sk_wq
);
320 if (wq_has_sleeper(wq
))
321 wake_up_interruptible_all(&wq
->wait
);
322 sk_wake_async(sk
, SOCK_WAKE_SPACE
, POLL_OUT
);
327 * afiucv_hs_send() - send a message through HiperSockets transport
329 static int afiucv_hs_send(struct iucv_message
*imsg
, struct sock
*sock
,
330 struct sk_buff
*skb
, u8 flags
)
332 struct net
*net
= sock_net(sock
);
333 struct iucv_sock
*iucv
= iucv_sk(sock
);
334 struct af_iucv_trans_hdr
*phs_hdr
;
335 struct sk_buff
*nskb
;
336 int err
, confirm_recv
= 0;
338 memset(skb
->head
, 0, ETH_HLEN
);
339 phs_hdr
= (struct af_iucv_trans_hdr
*)skb_push(skb
,
340 sizeof(struct af_iucv_trans_hdr
));
341 skb_reset_mac_header(skb
);
342 skb_reset_network_header(skb
);
343 skb_push(skb
, ETH_HLEN
);
344 skb_reset_mac_header(skb
);
345 memset(phs_hdr
, 0, sizeof(struct af_iucv_trans_hdr
));
347 phs_hdr
->magic
= ETH_P_AF_IUCV
;
348 phs_hdr
->version
= 1;
349 phs_hdr
->flags
= flags
;
350 if (flags
== AF_IUCV_FLAG_SYN
)
351 phs_hdr
->window
= iucv
->msglimit
;
352 else if ((flags
== AF_IUCV_FLAG_WIN
) || !flags
) {
353 confirm_recv
= atomic_read(&iucv
->msg_recv
);
354 phs_hdr
->window
= confirm_recv
;
356 phs_hdr
->flags
= phs_hdr
->flags
| AF_IUCV_FLAG_WIN
;
358 memcpy(phs_hdr
->destUserID
, iucv
->dst_user_id
, 8);
359 memcpy(phs_hdr
->destAppName
, iucv
->dst_name
, 8);
360 memcpy(phs_hdr
->srcUserID
, iucv
->src_user_id
, 8);
361 memcpy(phs_hdr
->srcAppName
, iucv
->src_name
, 8);
362 ASCEBC(phs_hdr
->destUserID
, sizeof(phs_hdr
->destUserID
));
363 ASCEBC(phs_hdr
->destAppName
, sizeof(phs_hdr
->destAppName
));
364 ASCEBC(phs_hdr
->srcUserID
, sizeof(phs_hdr
->srcUserID
));
365 ASCEBC(phs_hdr
->srcAppName
, sizeof(phs_hdr
->srcAppName
));
367 memcpy(&phs_hdr
->iucv_hdr
, imsg
, sizeof(struct iucv_message
));
370 skb
->dev
= dev_get_by_index_rcu(net
, sock
->sk_bound_dev_if
);
374 if (!(skb
->dev
->flags
& IFF_UP
))
376 if (skb
->len
> skb
->dev
->mtu
) {
377 if (sock
->sk_type
== SOCK_SEQPACKET
)
380 skb_trim(skb
, skb
->dev
->mtu
);
382 skb
->protocol
= ETH_P_AF_IUCV
;
383 skb_shinfo(skb
)->tx_flags
|= SKBTX_DRV_NEEDS_SK_REF
;
384 nskb
= skb_clone(skb
, GFP_ATOMIC
);
387 skb_queue_tail(&iucv
->send_skb_q
, nskb
);
388 err
= dev_queue_xmit(skb
);
390 skb_unlink(nskb
, &iucv
->send_skb_q
);
393 atomic_sub(confirm_recv
, &iucv
->msg_recv
);
394 WARN_ON(atomic_read(&iucv
->msg_recv
) < 0);
400 static void iucv_sock_timeout(unsigned long arg
)
402 struct sock
*sk
= (struct sock
*)arg
;
405 sk
->sk_err
= ETIMEDOUT
;
406 sk
->sk_state_change(sk
);
413 static void iucv_sock_clear_timer(struct sock
*sk
)
415 sk_stop_timer(sk
, &sk
->sk_timer
);
418 static struct sock
*__iucv_get_sock_by_name(char *nm
)
421 struct hlist_node
*node
;
423 sk_for_each(sk
, node
, &iucv_sk_list
.head
)
424 if (!memcmp(&iucv_sk(sk
)->src_name
, nm
, 8))
430 static void iucv_sock_destruct(struct sock
*sk
)
432 skb_queue_purge(&sk
->sk_receive_queue
);
433 skb_queue_purge(&sk
->sk_write_queue
);
437 static void iucv_sock_cleanup_listen(struct sock
*parent
)
441 /* Close non-accepted connections */
442 while ((sk
= iucv_accept_dequeue(parent
, NULL
))) {
447 parent
->sk_state
= IUCV_CLOSED
;
450 /* Kill socket (only if zapped and orphaned) */
451 static void iucv_sock_kill(struct sock
*sk
)
453 if (!sock_flag(sk
, SOCK_ZAPPED
) || sk
->sk_socket
)
456 iucv_sock_unlink(&iucv_sk_list
, sk
);
457 sock_set_flag(sk
, SOCK_DEAD
);
461 /* Close an IUCV socket */
462 static void iucv_sock_close(struct sock
*sk
)
464 unsigned char user_data
[16];
465 struct iucv_sock
*iucv
= iucv_sk(sk
);
470 iucv_sock_clear_timer(sk
);
473 switch (sk
->sk_state
) {
475 iucv_sock_cleanup_listen(sk
);
479 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
) {
481 blen
= sizeof(struct af_iucv_trans_hdr
) + ETH_HLEN
;
482 skb
= sock_alloc_send_skb(sk
, blen
, 1, &err
);
485 sizeof(struct af_iucv_trans_hdr
) +
487 err
= afiucv_hs_send(NULL
, sk
, skb
,
490 sk
->sk_state
= IUCV_DISCONN
;
491 sk
->sk_state_change(sk
);
494 sk
->sk_state
= IUCV_CLOSING
;
495 sk
->sk_state_change(sk
);
497 if (!skb_queue_empty(&iucv
->send_skb_q
)) {
498 if (sock_flag(sk
, SOCK_LINGER
) && sk
->sk_lingertime
)
499 timeo
= sk
->sk_lingertime
;
501 timeo
= IUCV_DISCONN_TIMEOUT
;
503 iucv_sock_in_state(sk
, IUCV_CLOSED
, 0),
507 case IUCV_CLOSING
: /* fall through */
508 sk
->sk_state
= IUCV_CLOSED
;
509 sk
->sk_state_change(sk
);
512 low_nmcpy(user_data
, iucv
->src_name
);
513 high_nmcpy(user_data
, iucv
->dst_name
);
514 ASCEBC(user_data
, sizeof(user_data
));
515 pr_iucv
->path_sever(iucv
->path
, user_data
);
516 iucv_path_free(iucv
->path
);
520 sk
->sk_err
= ECONNRESET
;
521 sk
->sk_state_change(sk
);
523 skb_queue_purge(&iucv
->send_skb_q
);
524 skb_queue_purge(&iucv
->backlog_skb_q
);
528 /* nothing to do here */
532 /* mark socket for deletion by iucv_sock_kill() */
533 sock_set_flag(sk
, SOCK_ZAPPED
);
538 static void iucv_sock_init(struct sock
*sk
, struct sock
*parent
)
541 sk
->sk_type
= parent
->sk_type
;
544 static struct sock
*iucv_sock_alloc(struct socket
*sock
, int proto
, gfp_t prio
)
547 struct iucv_sock
*iucv
;
549 sk
= sk_alloc(&init_net
, PF_IUCV
, prio
, &iucv_proto
);
554 sock_init_data(sock
, sk
);
555 INIT_LIST_HEAD(&iucv
->accept_q
);
556 spin_lock_init(&iucv
->accept_q_lock
);
557 skb_queue_head_init(&iucv
->send_skb_q
);
558 INIT_LIST_HEAD(&iucv
->message_q
.list
);
559 spin_lock_init(&iucv
->message_q
.lock
);
560 skb_queue_head_init(&iucv
->backlog_skb_q
);
562 atomic_set(&iucv
->pendings
, 0);
565 atomic_set(&iucv
->msg_sent
, 0);
566 atomic_set(&iucv
->msg_recv
, 0);
568 iucv
->sk_txnotify
= afiucv_hs_callback_txnotify
;
569 memset(&iucv
->src_user_id
, 0, 32);
571 iucv
->transport
= AF_IUCV_TRANS_IUCV
;
573 iucv
->transport
= AF_IUCV_TRANS_HIPER
;
575 sk
->sk_destruct
= iucv_sock_destruct
;
576 sk
->sk_sndtimeo
= IUCV_CONN_TIMEOUT
;
577 sk
->sk_allocation
= GFP_DMA
;
579 sock_reset_flag(sk
, SOCK_ZAPPED
);
581 sk
->sk_protocol
= proto
;
582 sk
->sk_state
= IUCV_OPEN
;
584 setup_timer(&sk
->sk_timer
, iucv_sock_timeout
, (unsigned long)sk
);
586 iucv_sock_link(&iucv_sk_list
, sk
);
590 /* Create an IUCV socket */
591 static int iucv_sock_create(struct net
*net
, struct socket
*sock
, int protocol
,
596 if (protocol
&& protocol
!= PF_IUCV
)
597 return -EPROTONOSUPPORT
;
599 sock
->state
= SS_UNCONNECTED
;
601 switch (sock
->type
) {
603 sock
->ops
= &iucv_sock_ops
;
606 /* currently, proto ops can handle both sk types */
607 sock
->ops
= &iucv_sock_ops
;
610 return -ESOCKTNOSUPPORT
;
613 sk
= iucv_sock_alloc(sock
, protocol
, GFP_KERNEL
);
617 iucv_sock_init(sk
, NULL
);
622 void iucv_sock_link(struct iucv_sock_list
*l
, struct sock
*sk
)
624 write_lock_bh(&l
->lock
);
625 sk_add_node(sk
, &l
->head
);
626 write_unlock_bh(&l
->lock
);
629 void iucv_sock_unlink(struct iucv_sock_list
*l
, struct sock
*sk
)
631 write_lock_bh(&l
->lock
);
632 sk_del_node_init(sk
);
633 write_unlock_bh(&l
->lock
);
636 void iucv_accept_enqueue(struct sock
*parent
, struct sock
*sk
)
639 struct iucv_sock
*par
= iucv_sk(parent
);
642 spin_lock_irqsave(&par
->accept_q_lock
, flags
);
643 list_add_tail(&iucv_sk(sk
)->accept_q
, &par
->accept_q
);
644 spin_unlock_irqrestore(&par
->accept_q_lock
, flags
);
645 iucv_sk(sk
)->parent
= parent
;
646 sk_acceptq_added(parent
);
649 void iucv_accept_unlink(struct sock
*sk
)
652 struct iucv_sock
*par
= iucv_sk(iucv_sk(sk
)->parent
);
654 spin_lock_irqsave(&par
->accept_q_lock
, flags
);
655 list_del_init(&iucv_sk(sk
)->accept_q
);
656 spin_unlock_irqrestore(&par
->accept_q_lock
, flags
);
657 sk_acceptq_removed(iucv_sk(sk
)->parent
);
658 iucv_sk(sk
)->parent
= NULL
;
662 struct sock
*iucv_accept_dequeue(struct sock
*parent
, struct socket
*newsock
)
664 struct iucv_sock
*isk
, *n
;
667 list_for_each_entry_safe(isk
, n
, &iucv_sk(parent
)->accept_q
, accept_q
) {
668 sk
= (struct sock
*) isk
;
671 if (sk
->sk_state
== IUCV_CLOSED
) {
672 iucv_accept_unlink(sk
);
677 if (sk
->sk_state
== IUCV_CONNECTED
||
678 sk
->sk_state
== IUCV_SEVERED
||
679 sk
->sk_state
== IUCV_DISCONN
|| /* due to PM restore */
681 iucv_accept_unlink(sk
);
683 sock_graft(sk
, newsock
);
685 if (sk
->sk_state
== IUCV_SEVERED
)
686 sk
->sk_state
= IUCV_DISCONN
;
697 /* Bind an unbound socket */
698 static int iucv_sock_bind(struct socket
*sock
, struct sockaddr
*addr
,
701 struct sockaddr_iucv
*sa
= (struct sockaddr_iucv
*) addr
;
702 struct sock
*sk
= sock
->sk
;
703 struct iucv_sock
*iucv
;
705 struct net_device
*dev
;
708 /* Verify the input sockaddr */
709 if (!addr
|| addr
->sa_family
!= AF_IUCV
)
713 if (sk
->sk_state
!= IUCV_OPEN
) {
718 write_lock_bh(&iucv_sk_list
.lock
);
721 if (__iucv_get_sock_by_name(sa
->siucv_name
)) {
728 /* Bind the socket */
731 if (!memcmp(sa
->siucv_user_id
, iucv_userid
, 8))
732 goto vm_bind
; /* VM IUCV transport */
734 /* try hiper transport */
735 memcpy(uid
, sa
->siucv_user_id
, sizeof(uid
));
738 for_each_netdev_rcu(&init_net
, dev
) {
739 if (!memcmp(dev
->perm_addr
, uid
, 8)) {
740 memcpy(iucv
->src_name
, sa
->siucv_name
, 8);
741 memcpy(iucv
->src_user_id
, sa
->siucv_user_id
, 8);
742 sock
->sk
->sk_bound_dev_if
= dev
->ifindex
;
743 sk
->sk_state
= IUCV_BOUND
;
744 iucv
->transport
= AF_IUCV_TRANS_HIPER
;
746 iucv
->msglimit
= IUCV_HIPER_MSGLIM_DEFAULT
;
754 /* use local userid for backward compat */
755 memcpy(iucv
->src_name
, sa
->siucv_name
, 8);
756 memcpy(iucv
->src_user_id
, iucv_userid
, 8);
757 sk
->sk_state
= IUCV_BOUND
;
758 iucv
->transport
= AF_IUCV_TRANS_IUCV
;
760 iucv
->msglimit
= IUCV_QUEUELEN_DEFAULT
;
763 /* found no dev to bind */
766 /* Release the socket list lock */
767 write_unlock_bh(&iucv_sk_list
.lock
);
773 /* Automatically bind an unbound socket */
774 static int iucv_sock_autobind(struct sock
*sk
)
776 struct iucv_sock
*iucv
= iucv_sk(sk
);
777 char query_buffer
[80];
781 /* Set the userid and name */
782 cpcmd("QUERY USERID", query_buffer
, sizeof(query_buffer
), &err
);
786 memcpy(iucv
->src_user_id
, query_buffer
, 8);
788 write_lock_bh(&iucv_sk_list
.lock
);
790 sprintf(name
, "%08x", atomic_inc_return(&iucv_sk_list
.autobind_name
));
791 while (__iucv_get_sock_by_name(name
)) {
792 sprintf(name
, "%08x",
793 atomic_inc_return(&iucv_sk_list
.autobind_name
));
796 write_unlock_bh(&iucv_sk_list
.lock
);
798 memcpy(&iucv
->src_name
, name
, 8);
801 iucv
->msglimit
= IUCV_QUEUELEN_DEFAULT
;
806 static int afiucv_hs_connect(struct socket
*sock
)
808 struct sock
*sk
= sock
->sk
;
810 int blen
= sizeof(struct af_iucv_trans_hdr
) + ETH_HLEN
;
814 skb
= sock_alloc_send_skb(sk
, blen
, 1, &err
);
820 skb_reserve(skb
, blen
);
821 err
= afiucv_hs_send(NULL
, sk
, skb
, AF_IUCV_FLAG_SYN
);
826 static int afiucv_path_connect(struct socket
*sock
, struct sockaddr
*addr
)
828 struct sockaddr_iucv
*sa
= (struct sockaddr_iucv
*) addr
;
829 struct sock
*sk
= sock
->sk
;
830 struct iucv_sock
*iucv
= iucv_sk(sk
);
831 unsigned char user_data
[16];
834 high_nmcpy(user_data
, sa
->siucv_name
);
835 low_nmcpy(user_data
, iucv
->src_name
);
836 ASCEBC(user_data
, sizeof(user_data
));
839 iucv
->path
= iucv_path_alloc(iucv
->msglimit
,
840 IUCV_IPRMDATA
, GFP_KERNEL
);
845 err
= pr_iucv
->path_connect(iucv
->path
, &af_iucv_handler
,
846 sa
->siucv_user_id
, NULL
, user_data
,
849 iucv_path_free(iucv
->path
);
852 case 0x0b: /* Target communicator is not logged on */
855 case 0x0d: /* Max connections for this guest exceeded */
856 case 0x0e: /* Max connections for target guest exceeded */
859 case 0x0f: /* Missing IUCV authorization */
871 /* Connect an unconnected socket */
872 static int iucv_sock_connect(struct socket
*sock
, struct sockaddr
*addr
,
875 struct sockaddr_iucv
*sa
= (struct sockaddr_iucv
*) addr
;
876 struct sock
*sk
= sock
->sk
;
877 struct iucv_sock
*iucv
= iucv_sk(sk
);
880 if (addr
->sa_family
!= AF_IUCV
|| alen
< sizeof(struct sockaddr_iucv
))
883 if (sk
->sk_state
!= IUCV_OPEN
&& sk
->sk_state
!= IUCV_BOUND
)
886 if (sk
->sk_state
== IUCV_OPEN
&&
887 iucv
->transport
== AF_IUCV_TRANS_HIPER
)
888 return -EBADFD
; /* explicit bind required */
890 if (sk
->sk_type
!= SOCK_STREAM
&& sk
->sk_type
!= SOCK_SEQPACKET
)
893 if (sk
->sk_state
== IUCV_OPEN
) {
894 err
= iucv_sock_autobind(sk
);
901 /* Set the destination information */
902 memcpy(iucv
->dst_user_id
, sa
->siucv_user_id
, 8);
903 memcpy(iucv
->dst_name
, sa
->siucv_name
, 8);
905 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
)
906 err
= afiucv_hs_connect(sock
);
908 err
= afiucv_path_connect(sock
, addr
);
912 if (sk
->sk_state
!= IUCV_CONNECTED
)
913 err
= iucv_sock_wait(sk
, iucv_sock_in_state(sk
, IUCV_CONNECTED
,
915 sock_sndtimeo(sk
, flags
& O_NONBLOCK
));
917 if (sk
->sk_state
== IUCV_DISCONN
|| sk
->sk_state
== IUCV_CLOSED
)
920 if (err
&& iucv
->transport
== AF_IUCV_TRANS_IUCV
) {
921 pr_iucv
->path_sever(iucv
->path
, NULL
);
922 iucv_path_free(iucv
->path
);
931 /* Move a socket into listening state. */
932 static int iucv_sock_listen(struct socket
*sock
, int backlog
)
934 struct sock
*sk
= sock
->sk
;
940 if (sk
->sk_state
!= IUCV_BOUND
)
943 if (sock
->type
!= SOCK_STREAM
&& sock
->type
!= SOCK_SEQPACKET
)
946 sk
->sk_max_ack_backlog
= backlog
;
947 sk
->sk_ack_backlog
= 0;
948 sk
->sk_state
= IUCV_LISTEN
;
956 /* Accept a pending connection */
957 static int iucv_sock_accept(struct socket
*sock
, struct socket
*newsock
,
960 DECLARE_WAITQUEUE(wait
, current
);
961 struct sock
*sk
= sock
->sk
, *nsk
;
965 lock_sock_nested(sk
, SINGLE_DEPTH_NESTING
);
967 if (sk
->sk_state
!= IUCV_LISTEN
) {
972 timeo
= sock_rcvtimeo(sk
, flags
& O_NONBLOCK
);
974 /* Wait for an incoming connection */
975 add_wait_queue_exclusive(sk_sleep(sk
), &wait
);
976 while (!(nsk
= iucv_accept_dequeue(sk
, newsock
))) {
977 set_current_state(TASK_INTERRUPTIBLE
);
984 timeo
= schedule_timeout(timeo
);
985 lock_sock_nested(sk
, SINGLE_DEPTH_NESTING
);
987 if (sk
->sk_state
!= IUCV_LISTEN
) {
992 if (signal_pending(current
)) {
993 err
= sock_intr_errno(timeo
);
998 set_current_state(TASK_RUNNING
);
999 remove_wait_queue(sk_sleep(sk
), &wait
);
1004 newsock
->state
= SS_CONNECTED
;
1011 static int iucv_sock_getname(struct socket
*sock
, struct sockaddr
*addr
,
1014 struct sockaddr_iucv
*siucv
= (struct sockaddr_iucv
*) addr
;
1015 struct sock
*sk
= sock
->sk
;
1016 struct iucv_sock
*iucv
= iucv_sk(sk
);
1018 addr
->sa_family
= AF_IUCV
;
1019 *len
= sizeof(struct sockaddr_iucv
);
1022 memcpy(siucv
->siucv_user_id
, iucv
->dst_user_id
, 8);
1023 memcpy(siucv
->siucv_name
, iucv
->dst_name
, 8);
1025 memcpy(siucv
->siucv_user_id
, iucv
->src_user_id
, 8);
1026 memcpy(siucv
->siucv_name
, iucv
->src_name
, 8);
1028 memset(&siucv
->siucv_port
, 0, sizeof(siucv
->siucv_port
));
1029 memset(&siucv
->siucv_addr
, 0, sizeof(siucv
->siucv_addr
));
1030 memset(&siucv
->siucv_nodeid
, 0, sizeof(siucv
->siucv_nodeid
));
1036 * iucv_send_iprm() - Send socket data in parameter list of an iucv message.
1038 * @msg: Pointer to a struct iucv_message
1039 * @skb: The socket data to send, skb->len MUST BE <= 7
1041 * Send the socket data in the parameter list in the iucv message
1042 * (IUCV_IPRMDATA). The socket data is stored at index 0 to 6 in the parameter
1043 * list and the socket data len at index 7 (last byte).
1044 * See also iucv_msg_length().
1046 * Returns the error code from the iucv_message_send() call.
1048 static int iucv_send_iprm(struct iucv_path
*path
, struct iucv_message
*msg
,
1049 struct sk_buff
*skb
)
1053 memcpy(prmdata
, (void *) skb
->data
, skb
->len
);
1054 prmdata
[7] = 0xff - (u8
) skb
->len
;
1055 return pr_iucv
->message_send(path
, msg
, IUCV_IPRMDATA
, 0,
1056 (void *) prmdata
, 8);
1059 static int iucv_sock_sendmsg(struct kiocb
*iocb
, struct socket
*sock
,
1060 struct msghdr
*msg
, size_t len
)
1062 struct sock
*sk
= sock
->sk
;
1063 struct iucv_sock
*iucv
= iucv_sk(sk
);
1064 struct sk_buff
*skb
;
1065 struct iucv_message txmsg
;
1066 struct cmsghdr
*cmsg
;
1072 int noblock
= msg
->msg_flags
& MSG_DONTWAIT
;
1074 err
= sock_error(sk
);
1078 if (msg
->msg_flags
& MSG_OOB
)
1081 /* SOCK_SEQPACKET: we do not support segmented records */
1082 if (sk
->sk_type
== SOCK_SEQPACKET
&& !(msg
->msg_flags
& MSG_EOR
))
1087 if (sk
->sk_shutdown
& SEND_SHUTDOWN
) {
1092 /* Return if the socket is not in connected state */
1093 if (sk
->sk_state
!= IUCV_CONNECTED
) {
1098 /* initialize defaults */
1099 cmsg_done
= 0; /* check for duplicate headers */
1102 /* iterate over control messages */
1103 for (cmsg
= CMSG_FIRSTHDR(msg
); cmsg
;
1104 cmsg
= CMSG_NXTHDR(msg
, cmsg
)) {
1106 if (!CMSG_OK(msg
, cmsg
)) {
1111 if (cmsg
->cmsg_level
!= SOL_IUCV
)
1114 if (cmsg
->cmsg_type
& cmsg_done
) {
1118 cmsg_done
|= cmsg
->cmsg_type
;
1120 switch (cmsg
->cmsg_type
) {
1121 case SCM_IUCV_TRGCLS
:
1122 if (cmsg
->cmsg_len
!= CMSG_LEN(TRGCLS_SIZE
)) {
1127 /* set iucv message target class */
1128 memcpy(&txmsg
.class,
1129 (void *) CMSG_DATA(cmsg
), TRGCLS_SIZE
);
1140 /* allocate one skb for each iucv message:
1141 * this is fine for SOCK_SEQPACKET (unless we want to support
1142 * segmented records using the MSG_EOR flag), but
1143 * for SOCK_STREAM we might want to improve it in future */
1144 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
)
1145 skb
= sock_alloc_send_skb(sk
,
1146 len
+ sizeof(struct af_iucv_trans_hdr
) + ETH_HLEN
,
1149 skb
= sock_alloc_send_skb(sk
, len
, noblock
, &err
);
1152 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
)
1153 skb_reserve(skb
, sizeof(struct af_iucv_trans_hdr
) + ETH_HLEN
);
1154 if (memcpy_fromiovec(skb_put(skb
, len
), msg
->msg_iov
, len
)) {
1159 /* wait if outstanding messages for iucv path has reached */
1160 timeo
= sock_sndtimeo(sk
, noblock
);
1161 err
= iucv_sock_wait(sk
, iucv_below_msglim(sk
), timeo
);
1165 /* return -ECONNRESET if the socket is no longer connected */
1166 if (sk
->sk_state
!= IUCV_CONNECTED
) {
1171 /* increment and save iucv message tag for msg_completion cbk */
1172 txmsg
.tag
= iucv
->send_tag
++;
1173 memcpy(CB_TAG(skb
), &txmsg
.tag
, CB_TAG_LEN
);
1174 if (iucv
->transport
== AF_IUCV_TRANS_HIPER
) {
1175 atomic_inc(&iucv
->msg_sent
);
1176 err
= afiucv_hs_send(&txmsg
, sk
, skb
, 0);
1178 atomic_dec(&iucv
->msg_sent
);
1183 skb_queue_tail(&iucv
->send_skb_q
, skb
);
1185 if (((iucv
->path
->flags
& IUCV_IPRMDATA
) & iucv
->flags
)
1187 err
= iucv_send_iprm(iucv
->path
, &txmsg
, skb
);
1189 /* on success: there is no message_complete callback
1190 * for an IPRMDATA msg; remove skb from send queue */
1192 skb_unlink(skb
, &iucv
->send_skb_q
);
1196 /* this error should never happen since the
1197 * IUCV_IPRMDATA path flag is set... sever path */
1199 pr_iucv
->path_sever(iucv
->path
, NULL
);
1200 skb_unlink(skb
, &iucv
->send_skb_q
);
1205 err
= pr_iucv
->message_send(iucv
->path
, &txmsg
, 0, 0,
1206 (void *) skb
->data
, skb
->len
);
1210 memcpy(user_id
, iucv
->dst_user_id
, 8);
1212 memcpy(appl_id
, iucv
->dst_name
, 8);
1213 pr_err("Application %s on z/VM guest %s"
1214 " exceeds message limit\n",
1219 skb_unlink(skb
, &iucv
->send_skb_q
);
1234 /* iucv_fragment_skb() - Fragment a single IUCV message into multiple skb's
1236 * Locking: must be called with message_q.lock held
1238 static int iucv_fragment_skb(struct sock
*sk
, struct sk_buff
*skb
, int len
)
1240 int dataleft
, size
, copied
= 0;
1241 struct sk_buff
*nskb
;
1245 if (dataleft
>= sk
->sk_rcvbuf
/ 4)
1246 size
= sk
->sk_rcvbuf
/ 4;
1250 nskb
= alloc_skb(size
, GFP_ATOMIC
| GFP_DMA
);
1254 /* copy target class to control buffer of new skb */
1255 memcpy(CB_TRGCLS(nskb
), CB_TRGCLS(skb
), CB_TRGCLS_LEN
);
1257 /* copy data fragment */
1258 memcpy(nskb
->data
, skb
->data
+ copied
, size
);
1262 skb_reset_transport_header(nskb
);
1263 skb_reset_network_header(nskb
);
1266 skb_queue_tail(&iucv_sk(sk
)->backlog_skb_q
, nskb
);
1272 /* iucv_process_message() - Receive a single outstanding IUCV message
1274 * Locking: must be called with message_q.lock held
1276 static void iucv_process_message(struct sock
*sk
, struct sk_buff
*skb
,
1277 struct iucv_path
*path
,
1278 struct iucv_message
*msg
)
1283 len
= iucv_msg_length(msg
);
1285 /* store msg target class in the second 4 bytes of skb ctrl buffer */
1286 /* Note: the first 4 bytes are reserved for msg tag */
1287 memcpy(CB_TRGCLS(skb
), &msg
->class, CB_TRGCLS_LEN
);
1289 /* check for special IPRM messages (e.g. iucv_sock_shutdown) */
1290 if ((msg
->flags
& IUCV_IPRMDATA
) && len
> 7) {
1291 if (memcmp(msg
->rmmsg
, iprm_shutdown
, 8) == 0) {
1296 rc
= pr_iucv
->message_receive(path
, msg
,
1297 msg
->flags
& IUCV_IPRMDATA
,
1298 skb
->data
, len
, NULL
);
1303 /* we need to fragment iucv messages for SOCK_STREAM only;
1304 * for SOCK_SEQPACKET, it is only relevant if we support
1305 * record segmentation using MSG_EOR (see also recvmsg()) */
1306 if (sk
->sk_type
== SOCK_STREAM
&&
1307 skb
->truesize
>= sk
->sk_rcvbuf
/ 4) {
1308 rc
= iucv_fragment_skb(sk
, skb
, len
);
1312 pr_iucv
->path_sever(path
, NULL
);
1315 skb
= skb_dequeue(&iucv_sk(sk
)->backlog_skb_q
);
1317 skb_reset_transport_header(skb
);
1318 skb_reset_network_header(skb
);
1323 if (sock_queue_rcv_skb(sk
, skb
))
1324 skb_queue_head(&iucv_sk(sk
)->backlog_skb_q
, skb
);
1327 /* iucv_process_message_q() - Process outstanding IUCV messages
1329 * Locking: must be called with message_q.lock held
1331 static void iucv_process_message_q(struct sock
*sk
)
1333 struct iucv_sock
*iucv
= iucv_sk(sk
);
1334 struct sk_buff
*skb
;
1335 struct sock_msg_q
*p
, *n
;
1337 list_for_each_entry_safe(p
, n
, &iucv
->message_q
.list
, list
) {
1338 skb
= alloc_skb(iucv_msg_length(&p
->msg
), GFP_ATOMIC
| GFP_DMA
);
1341 iucv_process_message(sk
, skb
, p
->path
, &p
->msg
);
1344 if (!skb_queue_empty(&iucv
->backlog_skb_q
))
1349 static int iucv_sock_recvmsg(struct kiocb
*iocb
, struct socket
*sock
,
1350 struct msghdr
*msg
, size_t len
, int flags
)
1352 int noblock
= flags
& MSG_DONTWAIT
;
1353 struct sock
*sk
= sock
->sk
;
1354 struct iucv_sock
*iucv
= iucv_sk(sk
);
1355 unsigned int copied
, rlen
;
1356 struct sk_buff
*skb
, *rskb
, *cskb
, *sskb
;
1360 if ((sk
->sk_state
== IUCV_DISCONN
|| sk
->sk_state
== IUCV_SEVERED
) &&
1361 skb_queue_empty(&iucv
->backlog_skb_q
) &&
1362 skb_queue_empty(&sk
->sk_receive_queue
) &&
1363 list_empty(&iucv
->message_q
.list
))
1366 if (flags
& (MSG_OOB
))
1369 /* receive/dequeue next skb:
1370 * the function understands MSG_PEEK and, thus, does not dequeue skb */
1371 skb
= skb_recv_datagram(sk
, flags
, noblock
, &err
);
1373 if (sk
->sk_shutdown
& RCV_SHUTDOWN
)
1378 rlen
= skb
->len
; /* real length of skb */
1379 copied
= min_t(unsigned int, rlen
, len
);
1382 if (skb_copy_datagram_iovec(cskb
, 0, msg
->msg_iov
, copied
)) {
1383 if (!(flags
& MSG_PEEK
))
1384 skb_queue_head(&sk
->sk_receive_queue
, skb
);
1388 /* SOCK_SEQPACKET: set MSG_TRUNC if recv buf size is too small */
1389 if (sk
->sk_type
== SOCK_SEQPACKET
) {
1391 msg
->msg_flags
|= MSG_TRUNC
;
1392 /* each iucv message contains a complete record */
1393 msg
->msg_flags
|= MSG_EOR
;
1396 /* create control message to store iucv msg target class:
1397 * get the trgcls from the control buffer of the skb due to
1398 * fragmentation of original iucv message. */
1399 err
= put_cmsg(msg
, SOL_IUCV
, SCM_IUCV_TRGCLS
,
1400 CB_TRGCLS_LEN
, CB_TRGCLS(skb
));
1402 if (!(flags
& MSG_PEEK
))
1403 skb_queue_head(&sk
->sk_receive_queue
, skb
);
1407 /* Mark read part of skb as used */
1408 if (!(flags
& MSG_PEEK
)) {
1410 /* SOCK_STREAM: re-queue skb if it contains unreceived data */
1411 if (sk
->sk_type
== SOCK_STREAM
) {
1412 skb_pull(skb
, copied
);
1414 skb_queue_head(&sk
->sk_receive_queue
, skb
);
1420 atomic_inc(&iucv
->msg_recv
);
1422 /* Queue backlog skbs */
1423 spin_lock_bh(&iucv
->message_q
.lock
);
1424 rskb
= skb_dequeue(&iucv
->backlog_skb_q
);
1426 if (sock_queue_rcv_skb(sk
, rskb
)) {
1427 skb_queue_head(&iucv
->backlog_skb_q
,
1431 rskb
= skb_dequeue(&iucv
->backlog_skb_q
);
1434 if (skb_queue_empty(&iucv
->backlog_skb_q
)) {
1435 if (!list_empty(&iucv
->message_q
.list
))
1436 iucv_process_message_q(sk
);
1437 if (atomic_read(&iucv
->msg_recv
) >=
1438 iucv
->msglimit
/ 2) {
1439 /* send WIN to peer */
1440 blen
= sizeof(struct af_iucv_trans_hdr
) +
1442 sskb
= sock_alloc_send_skb(sk
, blen
, 1, &err
);
1445 sizeof(struct af_iucv_trans_hdr
)
1447 err
= afiucv_hs_send(NULL
, sk
, sskb
,
1451 sk
->sk_state
= IUCV_DISCONN
;
1452 sk
->sk_state_change(sk
);
1456 spin_unlock_bh(&iucv
->message_q
.lock
);
1460 /* SOCK_SEQPACKET: return real length if MSG_TRUNC is set */
1461 if (sk
->sk_type
== SOCK_SEQPACKET
&& (flags
& MSG_TRUNC
))
1467 static inline unsigned int iucv_accept_poll(struct sock
*parent
)
1469 struct iucv_sock
*isk
, *n
;
1472 list_for_each_entry_safe(isk
, n
, &iucv_sk(parent
)->accept_q
, accept_q
) {
1473 sk
= (struct sock
*) isk
;
1475 if (sk
->sk_state
== IUCV_CONNECTED
)
1476 return POLLIN
| POLLRDNORM
;
1482 unsigned int iucv_sock_poll(struct file
*file
, struct socket
*sock
,
1485 struct sock
*sk
= sock
->sk
;
1486 unsigned int mask
= 0;
1488 sock_poll_wait(file
, sk_sleep(sk
), wait
);
1490 if (sk
->sk_state
== IUCV_LISTEN
)
1491 return iucv_accept_poll(sk
);
1493 if (sk
->sk_err
|| !skb_queue_empty(&sk
->sk_error_queue
))
1496 if (sk
->sk_shutdown
& RCV_SHUTDOWN
)
1499 if (sk
->sk_shutdown
== SHUTDOWN_MASK
)
1502 if (!skb_queue_empty(&sk
->sk_receive_queue
) ||
1503 (sk
->sk_shutdown
& RCV_SHUTDOWN
))
1504 mask
|= POLLIN
| POLLRDNORM
;
1506 if (sk
->sk_state
== IUCV_CLOSED
)
1509 if (sk
->sk_state
== IUCV_DISCONN
|| sk
->sk_state
== IUCV_SEVERED
)
1512 if (sock_writeable(sk
))
1513 mask
|= POLLOUT
| POLLWRNORM
| POLLWRBAND
;
1515 set_bit(SOCK_ASYNC_NOSPACE
, &sk
->sk_socket
->flags
);
1520 static int iucv_sock_shutdown(struct socket
*sock
, int how
)
1522 struct sock
*sk
= sock
->sk
;
1523 struct iucv_sock
*iucv
= iucv_sk(sk
);
1524 struct iucv_message txmsg
;
1529 if ((how
& ~SHUTDOWN_MASK
) || !how
)
1533 switch (sk
->sk_state
) {
1542 sk
->sk_shutdown
|= how
;
1546 if (how
== SEND_SHUTDOWN
|| how
== SHUTDOWN_MASK
) {
1549 err
= pr_iucv
->message_send(iucv
->path
, &txmsg
, IUCV_IPRMDATA
,
1550 0, (void *) iprm_shutdown
, 8);
1566 if (how
== RCV_SHUTDOWN
|| how
== SHUTDOWN_MASK
) {
1567 err
= pr_iucv
->path_quiesce(iucv
->path
, NULL
);
1571 skb_queue_purge(&sk
->sk_receive_queue
);
1574 /* Wake up anyone sleeping in poll */
1575 sk
->sk_state_change(sk
);
1582 static int iucv_sock_release(struct socket
*sock
)
1584 struct sock
*sk
= sock
->sk
;
1590 iucv_sock_close(sk
);
1592 /* Unregister with IUCV base support */
1593 if (iucv_sk(sk
)->path
) {
1594 pr_iucv
->path_sever(iucv_sk(sk
)->path
, NULL
);
1595 iucv_path_free(iucv_sk(sk
)->path
);
1596 iucv_sk(sk
)->path
= NULL
;
1604 /* getsockopt and setsockopt */
1605 static int iucv_sock_setsockopt(struct socket
*sock
, int level
, int optname
,
1606 char __user
*optval
, unsigned int optlen
)
1608 struct sock
*sk
= sock
->sk
;
1609 struct iucv_sock
*iucv
= iucv_sk(sk
);
1613 if (level
!= SOL_IUCV
)
1614 return -ENOPROTOOPT
;
1616 if (optlen
< sizeof(int))
1619 if (get_user(val
, (int __user
*) optval
))
1626 case SO_IPRMDATA_MSG
:
1628 iucv
->flags
|= IUCV_IPRMDATA
;
1630 iucv
->flags
&= ~IUCV_IPRMDATA
;
1633 switch (sk
->sk_state
) {
1636 if (val
< 1 || val
> (u16
)(~0))
1639 iucv
->msglimit
= val
;
1655 static int iucv_sock_getsockopt(struct socket
*sock
, int level
, int optname
,
1656 char __user
*optval
, int __user
*optlen
)
1658 struct sock
*sk
= sock
->sk
;
1659 struct iucv_sock
*iucv
= iucv_sk(sk
);
1662 if (level
!= SOL_IUCV
)
1663 return -ENOPROTOOPT
;
1665 if (get_user(len
, optlen
))
1671 len
= min_t(unsigned int, len
, sizeof(int));
1674 case SO_IPRMDATA_MSG
:
1675 val
= (iucv
->flags
& IUCV_IPRMDATA
) ? 1 : 0;
1679 val
= (iucv
->path
!= NULL
) ? iucv
->path
->msglim
/* connected */
1680 : iucv
->msglimit
; /* default */
1684 return -ENOPROTOOPT
;
1687 if (put_user(len
, optlen
))
1689 if (copy_to_user(optval
, &val
, len
))
1696 /* Callback wrappers - called from iucv base support */
1697 static int iucv_callback_connreq(struct iucv_path
*path
,
1698 u8 ipvmid
[8], u8 ipuser
[16])
1700 unsigned char user_data
[16];
1701 unsigned char nuser_data
[16];
1702 unsigned char src_name
[8];
1703 struct hlist_node
*node
;
1704 struct sock
*sk
, *nsk
;
1705 struct iucv_sock
*iucv
, *niucv
;
1708 memcpy(src_name
, ipuser
, 8);
1709 EBCASC(src_name
, 8);
1710 /* Find out if this path belongs to af_iucv. */
1711 read_lock(&iucv_sk_list
.lock
);
1714 sk_for_each(sk
, node
, &iucv_sk_list
.head
)
1715 if (sk
->sk_state
== IUCV_LISTEN
&&
1716 !memcmp(&iucv_sk(sk
)->src_name
, src_name
, 8)) {
1718 * Found a listening socket with
1719 * src_name == ipuser[0-7].
1724 read_unlock(&iucv_sk_list
.lock
);
1726 /* No socket found, not one of our paths. */
1731 /* Check if parent socket is listening */
1732 low_nmcpy(user_data
, iucv
->src_name
);
1733 high_nmcpy(user_data
, iucv
->dst_name
);
1734 ASCEBC(user_data
, sizeof(user_data
));
1735 if (sk
->sk_state
!= IUCV_LISTEN
) {
1736 err
= pr_iucv
->path_sever(path
, user_data
);
1737 iucv_path_free(path
);
1741 /* Check for backlog size */
1742 if (sk_acceptq_is_full(sk
)) {
1743 err
= pr_iucv
->path_sever(path
, user_data
);
1744 iucv_path_free(path
);
1748 /* Create the new socket */
1749 nsk
= iucv_sock_alloc(NULL
, sk
->sk_type
, GFP_ATOMIC
);
1751 err
= pr_iucv
->path_sever(path
, user_data
);
1752 iucv_path_free(path
);
1756 niucv
= iucv_sk(nsk
);
1757 iucv_sock_init(nsk
, sk
);
1759 /* Set the new iucv_sock */
1760 memcpy(niucv
->dst_name
, ipuser
+ 8, 8);
1761 EBCASC(niucv
->dst_name
, 8);
1762 memcpy(niucv
->dst_user_id
, ipvmid
, 8);
1763 memcpy(niucv
->src_name
, iucv
->src_name
, 8);
1764 memcpy(niucv
->src_user_id
, iucv
->src_user_id
, 8);
1767 /* Call iucv_accept */
1768 high_nmcpy(nuser_data
, ipuser
+ 8);
1769 memcpy(nuser_data
+ 8, niucv
->src_name
, 8);
1770 ASCEBC(nuser_data
+ 8, 8);
1772 /* set message limit for path based on msglimit of accepting socket */
1773 niucv
->msglimit
= iucv
->msglimit
;
1774 path
->msglim
= iucv
->msglimit
;
1775 err
= pr_iucv
->path_accept(path
, &af_iucv_handler
, nuser_data
, nsk
);
1777 err
= pr_iucv
->path_sever(path
, user_data
);
1778 iucv_path_free(path
);
1779 iucv_sock_kill(nsk
);
1783 iucv_accept_enqueue(sk
, nsk
);
1785 /* Wake up accept */
1786 nsk
->sk_state
= IUCV_CONNECTED
;
1787 sk
->sk_data_ready(sk
, 1);
1794 static void iucv_callback_connack(struct iucv_path
*path
, u8 ipuser
[16])
1796 struct sock
*sk
= path
->private;
1798 sk
->sk_state
= IUCV_CONNECTED
;
1799 sk
->sk_state_change(sk
);
1802 static void iucv_callback_rx(struct iucv_path
*path
, struct iucv_message
*msg
)
1804 struct sock
*sk
= path
->private;
1805 struct iucv_sock
*iucv
= iucv_sk(sk
);
1806 struct sk_buff
*skb
;
1807 struct sock_msg_q
*save_msg
;
1810 if (sk
->sk_shutdown
& RCV_SHUTDOWN
) {
1811 pr_iucv
->message_reject(path
, msg
);
1815 spin_lock(&iucv
->message_q
.lock
);
1817 if (!list_empty(&iucv
->message_q
.list
) ||
1818 !skb_queue_empty(&iucv
->backlog_skb_q
))
1821 len
= atomic_read(&sk
->sk_rmem_alloc
);
1822 len
+= SKB_TRUESIZE(iucv_msg_length(msg
));
1823 if (len
> sk
->sk_rcvbuf
)
1826 skb
= alloc_skb(iucv_msg_length(msg
), GFP_ATOMIC
| GFP_DMA
);
1830 iucv_process_message(sk
, skb
, path
, msg
);
1834 save_msg
= kzalloc(sizeof(struct sock_msg_q
), GFP_ATOMIC
| GFP_DMA
);
1837 save_msg
->path
= path
;
1838 save_msg
->msg
= *msg
;
1840 list_add_tail(&save_msg
->list
, &iucv
->message_q
.list
);
1843 spin_unlock(&iucv
->message_q
.lock
);
1846 static void iucv_callback_txdone(struct iucv_path
*path
,
1847 struct iucv_message
*msg
)
1849 struct sock
*sk
= path
->private;
1850 struct sk_buff
*this = NULL
;
1851 struct sk_buff_head
*list
= &iucv_sk(sk
)->send_skb_q
;
1852 struct sk_buff
*list_skb
= list
->next
;
1853 unsigned long flags
;
1855 if (!skb_queue_empty(list
)) {
1856 spin_lock_irqsave(&list
->lock
, flags
);
1858 while (list_skb
!= (struct sk_buff
*)list
) {
1859 if (!memcmp(&msg
->tag
, CB_TAG(list_skb
), CB_TAG_LEN
)) {
1863 list_skb
= list_skb
->next
;
1866 __skb_unlink(this, list
);
1868 spin_unlock_irqrestore(&list
->lock
, flags
);
1872 /* wake up any process waiting for sending */
1873 iucv_sock_wake_msglim(sk
);
1878 if (sk
->sk_state
== IUCV_CLOSING
) {
1879 if (skb_queue_empty(&iucv_sk(sk
)->send_skb_q
)) {
1880 sk
->sk_state
= IUCV_CLOSED
;
1881 sk
->sk_state_change(sk
);
1887 static void iucv_callback_connrej(struct iucv_path
*path
, u8 ipuser
[16])
1889 struct sock
*sk
= path
->private;
1891 if (!list_empty(&iucv_sk(sk
)->accept_q
))
1892 sk
->sk_state
= IUCV_SEVERED
;
1894 sk
->sk_state
= IUCV_DISCONN
;
1896 sk
->sk_state_change(sk
);
1899 /* called if the other communication side shuts down its RECV direction;
1900 * in turn, the callback sets SEND_SHUTDOWN to disable sending of data.
1902 static void iucv_callback_shutdown(struct iucv_path
*path
, u8 ipuser
[16])
1904 struct sock
*sk
= path
->private;
1907 if (sk
->sk_state
!= IUCV_CLOSED
) {
1908 sk
->sk_shutdown
|= SEND_SHUTDOWN
;
1909 sk
->sk_state_change(sk
);
1914 /***************** HiperSockets transport callbacks ********************/
1915 static void afiucv_swap_src_dest(struct sk_buff
*skb
)
1917 struct af_iucv_trans_hdr
*trans_hdr
=
1918 (struct af_iucv_trans_hdr
*)skb
->data
;
1922 ASCEBC(trans_hdr
->destUserID
, sizeof(trans_hdr
->destUserID
));
1923 ASCEBC(trans_hdr
->destAppName
, sizeof(trans_hdr
->destAppName
));
1924 ASCEBC(trans_hdr
->srcUserID
, sizeof(trans_hdr
->srcUserID
));
1925 ASCEBC(trans_hdr
->srcAppName
, sizeof(trans_hdr
->srcAppName
));
1926 memcpy(tmpID
, trans_hdr
->srcUserID
, 8);
1927 memcpy(tmpName
, trans_hdr
->srcAppName
, 8);
1928 memcpy(trans_hdr
->srcUserID
, trans_hdr
->destUserID
, 8);
1929 memcpy(trans_hdr
->srcAppName
, trans_hdr
->destAppName
, 8);
1930 memcpy(trans_hdr
->destUserID
, tmpID
, 8);
1931 memcpy(trans_hdr
->destAppName
, tmpName
, 8);
1932 skb_push(skb
, ETH_HLEN
);
1933 memset(skb
->data
, 0, ETH_HLEN
);
1937 * afiucv_hs_callback_syn - react on received SYN
1939 static int afiucv_hs_callback_syn(struct sock
*sk
, struct sk_buff
*skb
)
1942 struct iucv_sock
*iucv
, *niucv
;
1943 struct af_iucv_trans_hdr
*trans_hdr
;
1947 trans_hdr
= (struct af_iucv_trans_hdr
*)skb
->data
;
1949 /* no sock - connection refused */
1950 afiucv_swap_src_dest(skb
);
1951 trans_hdr
->flags
= AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_FIN
;
1952 err
= dev_queue_xmit(skb
);
1956 nsk
= iucv_sock_alloc(NULL
, sk
->sk_type
, GFP_ATOMIC
);
1958 if ((sk
->sk_state
!= IUCV_LISTEN
) ||
1959 sk_acceptq_is_full(sk
) ||
1961 /* error on server socket - connection refused */
1964 afiucv_swap_src_dest(skb
);
1965 trans_hdr
->flags
= AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_FIN
;
1966 err
= dev_queue_xmit(skb
);
1971 niucv
= iucv_sk(nsk
);
1972 iucv_sock_init(nsk
, sk
);
1973 niucv
->transport
= AF_IUCV_TRANS_HIPER
;
1974 niucv
->msglimit
= iucv
->msglimit
;
1975 if (!trans_hdr
->window
)
1976 niucv
->msglimit_peer
= IUCV_HIPER_MSGLIM_DEFAULT
;
1978 niucv
->msglimit_peer
= trans_hdr
->window
;
1979 memcpy(niucv
->dst_name
, trans_hdr
->srcAppName
, 8);
1980 memcpy(niucv
->dst_user_id
, trans_hdr
->srcUserID
, 8);
1981 memcpy(niucv
->src_name
, iucv
->src_name
, 8);
1982 memcpy(niucv
->src_user_id
, iucv
->src_user_id
, 8);
1983 nsk
->sk_bound_dev_if
= sk
->sk_bound_dev_if
;
1984 afiucv_swap_src_dest(skb
);
1985 trans_hdr
->flags
= AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_ACK
;
1986 trans_hdr
->window
= niucv
->msglimit
;
1987 /* if receiver acks the xmit connection is established */
1988 err
= dev_queue_xmit(skb
);
1990 iucv_accept_enqueue(sk
, nsk
);
1991 nsk
->sk_state
= IUCV_CONNECTED
;
1992 sk
->sk_data_ready(sk
, 1);
1994 iucv_sock_kill(nsk
);
1998 return NET_RX_SUCCESS
;
2002 * afiucv_hs_callback_synack() - react on received SYN-ACK
2004 static int afiucv_hs_callback_synack(struct sock
*sk
, struct sk_buff
*skb
)
2006 struct iucv_sock
*iucv
= iucv_sk(sk
);
2007 struct af_iucv_trans_hdr
*trans_hdr
=
2008 (struct af_iucv_trans_hdr
*)skb
->data
;
2012 if (sk
->sk_state
!= IUCV_BOUND
)
2015 iucv
->msglimit_peer
= trans_hdr
->window
;
2016 sk
->sk_state
= IUCV_CONNECTED
;
2017 sk
->sk_state_change(sk
);
2021 return NET_RX_SUCCESS
;
2025 * afiucv_hs_callback_synfin() - react on received SYN_FIN
2027 static int afiucv_hs_callback_synfin(struct sock
*sk
, struct sk_buff
*skb
)
2029 struct iucv_sock
*iucv
= iucv_sk(sk
);
2033 if (sk
->sk_state
!= IUCV_BOUND
)
2036 sk
->sk_state
= IUCV_DISCONN
;
2037 sk
->sk_state_change(sk
);
2041 return NET_RX_SUCCESS
;
2045 * afiucv_hs_callback_fin() - react on received FIN
2047 static int afiucv_hs_callback_fin(struct sock
*sk
, struct sk_buff
*skb
)
2049 struct iucv_sock
*iucv
= iucv_sk(sk
);
2051 /* other end of connection closed */
2054 if (!list_empty(&iucv
->accept_q
))
2055 sk
->sk_state
= IUCV_SEVERED
;
2057 sk
->sk_state
= IUCV_DISCONN
;
2058 sk
->sk_state_change(sk
);
2062 return NET_RX_SUCCESS
;
2066 * afiucv_hs_callback_win() - react on received WIN
2068 static int afiucv_hs_callback_win(struct sock
*sk
, struct sk_buff
*skb
)
2070 struct iucv_sock
*iucv
= iucv_sk(sk
);
2071 struct af_iucv_trans_hdr
*trans_hdr
=
2072 (struct af_iucv_trans_hdr
*)skb
->data
;
2075 return NET_RX_SUCCESS
;
2077 if (sk
->sk_state
!= IUCV_CONNECTED
)
2078 return NET_RX_SUCCESS
;
2080 atomic_sub(trans_hdr
->window
, &iucv
->msg_sent
);
2081 iucv_sock_wake_msglim(sk
);
2082 return NET_RX_SUCCESS
;
2086 * afiucv_hs_callback_rx() - react on received data
2088 static int afiucv_hs_callback_rx(struct sock
*sk
, struct sk_buff
*skb
)
2090 struct iucv_sock
*iucv
= iucv_sk(sk
);
2094 return NET_RX_SUCCESS
;
2097 if (sk
->sk_state
!= IUCV_CONNECTED
) {
2099 return NET_RX_SUCCESS
;
2102 /* write stuff from iucv_msg to skb cb */
2103 if (skb
->len
<= sizeof(struct af_iucv_trans_hdr
)) {
2105 return NET_RX_SUCCESS
;
2107 skb_pull(skb
, sizeof(struct af_iucv_trans_hdr
));
2108 skb_reset_transport_header(skb
);
2109 skb_reset_network_header(skb
);
2110 spin_lock(&iucv
->message_q
.lock
);
2111 if (skb_queue_empty(&iucv
->backlog_skb_q
)) {
2112 if (sock_queue_rcv_skb(sk
, skb
)) {
2113 /* handle rcv queue full */
2114 skb_queue_tail(&iucv
->backlog_skb_q
, skb
);
2117 skb_queue_tail(&iucv_sk(sk
)->backlog_skb_q
, skb
);
2118 spin_unlock(&iucv
->message_q
.lock
);
2119 return NET_RX_SUCCESS
;
2123 * afiucv_hs_rcv() - base function for arriving data through HiperSockets
2125 * called from netif RX softirq
2127 static int afiucv_hs_rcv(struct sk_buff
*skb
, struct net_device
*dev
,
2128 struct packet_type
*pt
, struct net_device
*orig_dev
)
2130 struct hlist_node
*node
;
2132 struct iucv_sock
*iucv
;
2133 struct af_iucv_trans_hdr
*trans_hdr
;
2137 skb_pull(skb
, ETH_HLEN
);
2138 trans_hdr
= (struct af_iucv_trans_hdr
*)skb
->data
;
2139 EBCASC(trans_hdr
->destAppName
, sizeof(trans_hdr
->destAppName
));
2140 EBCASC(trans_hdr
->destUserID
, sizeof(trans_hdr
->destUserID
));
2141 EBCASC(trans_hdr
->srcAppName
, sizeof(trans_hdr
->srcAppName
));
2142 EBCASC(trans_hdr
->srcUserID
, sizeof(trans_hdr
->srcUserID
));
2143 memset(nullstring
, 0, sizeof(nullstring
));
2146 read_lock(&iucv_sk_list
.lock
);
2147 sk_for_each(sk
, node
, &iucv_sk_list
.head
) {
2148 if (trans_hdr
->flags
== AF_IUCV_FLAG_SYN
) {
2149 if ((!memcmp(&iucv_sk(sk
)->src_name
,
2150 trans_hdr
->destAppName
, 8)) &&
2151 (!memcmp(&iucv_sk(sk
)->src_user_id
,
2152 trans_hdr
->destUserID
, 8)) &&
2153 (!memcmp(&iucv_sk(sk
)->dst_name
, nullstring
, 8)) &&
2154 (!memcmp(&iucv_sk(sk
)->dst_user_id
,
2160 if ((!memcmp(&iucv_sk(sk
)->src_name
,
2161 trans_hdr
->destAppName
, 8)) &&
2162 (!memcmp(&iucv_sk(sk
)->src_user_id
,
2163 trans_hdr
->destUserID
, 8)) &&
2164 (!memcmp(&iucv_sk(sk
)->dst_name
,
2165 trans_hdr
->srcAppName
, 8)) &&
2166 (!memcmp(&iucv_sk(sk
)->dst_user_id
,
2167 trans_hdr
->srcUserID
, 8))) {
2173 read_unlock(&iucv_sk_list
.lock
);
2178 how should we send with no sock
2179 1) send without sock no send rc checking?
2180 2) introduce default sock to handle this cases
2182 SYN -> send SYN|ACK in good case, send SYN|FIN in bad case
2184 SYN|ACK, SYN|FIN, FIN -> no action? */
2186 switch (trans_hdr
->flags
) {
2187 case AF_IUCV_FLAG_SYN
:
2188 /* connect request */
2189 err
= afiucv_hs_callback_syn(sk
, skb
);
2191 case (AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_ACK
):
2192 /* connect request confirmed */
2193 err
= afiucv_hs_callback_synack(sk
, skb
);
2195 case (AF_IUCV_FLAG_SYN
| AF_IUCV_FLAG_FIN
):
2196 /* connect request refused */
2197 err
= afiucv_hs_callback_synfin(sk
, skb
);
2199 case (AF_IUCV_FLAG_FIN
):
2201 err
= afiucv_hs_callback_fin(sk
, skb
);
2203 case (AF_IUCV_FLAG_WIN
):
2204 err
= afiucv_hs_callback_win(sk
, skb
);
2205 if (skb
->len
> sizeof(struct af_iucv_trans_hdr
))
2206 err
= afiucv_hs_callback_rx(sk
, skb
);
2211 /* plain data frame */
2212 err
= afiucv_hs_callback_rx(sk
, skb
);
2222 * afiucv_hs_callback_txnotify() - handle send notifcations from HiperSockets
2225 static void afiucv_hs_callback_txnotify(struct sk_buff
*skb
,
2226 enum iucv_tx_notify n
)
2228 struct sock
*isk
= skb
->sk
;
2229 struct sock
*sk
= NULL
;
2230 struct iucv_sock
*iucv
= NULL
;
2231 struct sk_buff_head
*list
;
2232 struct sk_buff
*list_skb
;
2233 struct sk_buff
*this = NULL
;
2234 unsigned long flags
;
2235 struct hlist_node
*node
;
2237 read_lock(&iucv_sk_list
.lock
);
2238 sk_for_each(sk
, node
, &iucv_sk_list
.head
)
2243 read_unlock(&iucv_sk_list
.lock
);
2249 list
= &iucv
->send_skb_q
;
2250 list_skb
= list
->next
;
2251 if (skb_queue_empty(list
))
2254 spin_lock_irqsave(&list
->lock
, flags
);
2255 while (list_skb
!= (struct sk_buff
*)list
) {
2256 if (skb_shinfo(list_skb
) == skb_shinfo(skb
)) {
2260 __skb_unlink(this, list
);
2261 iucv_sock_wake_msglim(sk
);
2264 case TX_NOTIFY_PENDING
:
2265 atomic_inc(&iucv
->pendings
);
2267 case TX_NOTIFY_DELAYED_OK
:
2268 __skb_unlink(this, list
);
2269 atomic_dec(&iucv
->pendings
);
2270 if (atomic_read(&iucv
->pendings
) <= 0)
2271 iucv_sock_wake_msglim(sk
);
2274 case TX_NOTIFY_UNREACHABLE
:
2275 case TX_NOTIFY_DELAYED_UNREACHABLE
:
2276 case TX_NOTIFY_TPQFULL
: /* not yet used */
2277 case TX_NOTIFY_GENERALERROR
:
2278 case TX_NOTIFY_DELAYED_GENERALERROR
:
2279 __skb_unlink(this, list
);
2281 if (!list_empty(&iucv
->accept_q
))
2282 sk
->sk_state
= IUCV_SEVERED
;
2284 sk
->sk_state
= IUCV_DISCONN
;
2285 sk
->sk_state_change(sk
);
2290 list_skb
= list_skb
->next
;
2292 spin_unlock_irqrestore(&list
->lock
, flags
);
2297 static const struct proto_ops iucv_sock_ops
= {
2299 .owner
= THIS_MODULE
,
2300 .release
= iucv_sock_release
,
2301 .bind
= iucv_sock_bind
,
2302 .connect
= iucv_sock_connect
,
2303 .listen
= iucv_sock_listen
,
2304 .accept
= iucv_sock_accept
,
2305 .getname
= iucv_sock_getname
,
2306 .sendmsg
= iucv_sock_sendmsg
,
2307 .recvmsg
= iucv_sock_recvmsg
,
2308 .poll
= iucv_sock_poll
,
2309 .ioctl
= sock_no_ioctl
,
2310 .mmap
= sock_no_mmap
,
2311 .socketpair
= sock_no_socketpair
,
2312 .shutdown
= iucv_sock_shutdown
,
2313 .setsockopt
= iucv_sock_setsockopt
,
2314 .getsockopt
= iucv_sock_getsockopt
,
2317 static const struct net_proto_family iucv_sock_family_ops
= {
2319 .owner
= THIS_MODULE
,
2320 .create
= iucv_sock_create
,
2323 static struct packet_type iucv_packet_type
= {
2324 .type
= cpu_to_be16(ETH_P_AF_IUCV
),
2325 .func
= afiucv_hs_rcv
,
2328 static int afiucv_iucv_init(void)
2332 err
= pr_iucv
->iucv_register(&af_iucv_handler
, 0);
2335 /* establish dummy device */
2336 af_iucv_driver
.bus
= pr_iucv
->bus
;
2337 err
= driver_register(&af_iucv_driver
);
2340 af_iucv_dev
= kzalloc(sizeof(struct device
), GFP_KERNEL
);
2345 dev_set_name(af_iucv_dev
, "af_iucv");
2346 af_iucv_dev
->bus
= pr_iucv
->bus
;
2347 af_iucv_dev
->parent
= pr_iucv
->root
;
2348 af_iucv_dev
->release
= (void (*)(struct device
*))kfree
;
2349 af_iucv_dev
->driver
= &af_iucv_driver
;
2350 err
= device_register(af_iucv_dev
);
2356 driver_unregister(&af_iucv_driver
);
2358 pr_iucv
->iucv_unregister(&af_iucv_handler
, 0);
2363 static int __init
afiucv_init(void)
2367 if (MACHINE_IS_VM
) {
2368 cpcmd("QUERY USERID", iucv_userid
, sizeof(iucv_userid
), &err
);
2369 if (unlikely(err
)) {
2371 err
= -EPROTONOSUPPORT
;
2375 pr_iucv
= try_then_request_module(symbol_get(iucv_if
), "iucv");
2377 printk(KERN_WARNING
"iucv_if lookup failed\n");
2378 memset(&iucv_userid
, 0, sizeof(iucv_userid
));
2381 memset(&iucv_userid
, 0, sizeof(iucv_userid
));
2385 err
= proto_register(&iucv_proto
, 0);
2388 err
= sock_register(&iucv_sock_family_ops
);
2393 err
= afiucv_iucv_init();
2397 dev_add_pack(&iucv_packet_type
);
2401 sock_unregister(PF_IUCV
);
2403 proto_unregister(&iucv_proto
);
2406 symbol_put(iucv_if
);
2410 static void __exit
afiucv_exit(void)
2413 device_unregister(af_iucv_dev
);
2414 driver_unregister(&af_iucv_driver
);
2415 pr_iucv
->iucv_unregister(&af_iucv_handler
, 0);
2416 symbol_put(iucv_if
);
2418 dev_remove_pack(&iucv_packet_type
);
2419 sock_unregister(PF_IUCV
);
2420 proto_unregister(&iucv_proto
);
2423 module_init(afiucv_init
);
2424 module_exit(afiucv_exit
);
2426 MODULE_AUTHOR("Jennifer Hunt <jenhunt@us.ibm.com>");
2427 MODULE_DESCRIPTION("IUCV Sockets ver " VERSION
);
2428 MODULE_VERSION(VERSION
);
2429 MODULE_LICENSE("GPL");
2430 MODULE_ALIAS_NETPROTO(PF_IUCV
);