iucv / af_iucv patches for net-next-2.6.30-rc1
Subsystems (5)
cover iucv / af_iucv patches for net-next-2.6.30-rc1
Dave,
thanks for applying our critical af_iucv bug fixes to net-2.6. Here is now the series of iucv / af_iucv patches for the current development cycle.
The patches are based on top of the current net-next-2.6 kernel (2.6.30-rc1).
Hendrik Brueckner (7)
af_iucv: sync sk shutdown flag if iucv path is quiesced
af_iucv: add sockopt() to enable/disable use of IPRM_DATA msgs
af_iucv: Support data in IUCV msg parameter lists (IPRMDATA)
af_iucv: Modify iucv msg target class using control msghdr
af_iucv: Provide new socket type SOCK_SEQPACKET
af_iucv: cleanup and refactor recvmsg() EFAULT handling
af_iucv: New socket option for setting IUCV MSGLIMITs
Ursula Braun (1):
iucv: provide second per-cpu IUCV command parameter block
Kind regards,
Ursula Braun
PATCH 1/8 iucv: provide second per-cpu IUCV command parameter block
From: Ursula Braun <[email protected]>
Some of the IUCV commands can be invoked in interrupt context. Those commands need a different per-cpu IUCV command parameter block, otherwise they might overwrite an IUCV command parameter of a not yet finished IUCV command invocation in process context.
---
net/iucv/iucv.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-)
net/iucv/iucv.c +31 -10
@@ -280,6 +280,7 @@ union iucv_param {* Anchor for per-cpu IUCV command parameter block. */ static union iucv_param *iucv_param[NR_CPUS ]; +static union iucv_param *iucv_param_irq[NR_CPUS ];/** * iucv_call_b2f0
@@ -358,7 +359,7 @@ static void iucv_allow_cpu(void *data)* 0x10 - Flag to allow priority message completion interrupts * 0x08 - Flag to allow IUCV control interrupts */ - parm = iucv_param[cpu]; + parm = iucv_param_irq[cpu];memset (parm,0 ,sizeof (union iucv_param )); parm->set_mask.ipmask =0xf8 ;iucv_call_b2f0 (IUCV_SETMASK , parm);
@@ -379,7 +380,7 @@ static void iucv_block_cpu(void *data)union iucv_param *parm;/* Disable all iucv interrupts. */ - parm = iucv_param[cpu]; + parm = iucv_param_irq[cpu];memset (parm,0 ,sizeof (union iucv_param ));iucv_call_b2f0 (IUCV_SETMASK , parm);
@@ -403,7 +404,7 @@ static void iucv_declare_cpu(void *data)return ;/* Declare interrupt buffer. */ - parm = iucv_param[cpu]; + parm = iucv_param_irq[cpu];memset (parm,0 ,sizeof (union iucv_param )); parm->db.ipbfadr1 =virt_to_phys (iucv_irq_data[cpu]); rc =iucv_call_b2f0 (IUCV_DECLARE_BUFFER , parm);
@@ -460,7 +461,7 @@ static void iucv_retrieve_cpu(void *dataiucv_block_cpu (NULL );/* Retrieve interrupt buffer. */ - parm = iucv_param[cpu]; + parm = iucv_param_irq[cpu];iucv_call_b2f0 (IUCV_RETRIEVE_BUFFER , parm);/* Clear indication that an iucv buffer exists for this cpu. */
@@ -574,11 +575,22 @@ static int __cpuinit iucv_cpu_notify(str iucv_irq_data[cpu] =NULL ;return NOTIFY_BAD ; } + iucv_param_irq[cpu] =kmalloc_node (sizeof (union iucv_param ), +GFP_KERNEL |GFP_DMA ,cpu_to_node (cpu)); +if (!iucv_param_irq[cpu]) { +kfree (iucv_param[cpu]); + iucv_param[cpu] =NULL ; +kfree (iucv_irq_data[cpu]); + iucv_irq_data[cpu] =NULL ; +return NOTIFY_BAD ; + }break ;case CPU_UP_CANCELED :case CPU_UP_CANCELED_FROZEN :case CPU_DEAD :case CPU_DEAD_FROZEN : +kfree (iucv_param_irq[cpu]); + iucv_param_irq[cpu] =NULL ;kfree (iucv_param[cpu]); iucv_param[cpu] =NULL ;kfree (iucv_irq_data[cpu]);
@@ -625,7 +637,7 @@ static int iucv_sever_pathid(u16 pathid, {union iucv_param *parm; - parm = iucv_param[smp_processor_id ()]; + parm = iucv_param_irq[smp_processor_id ()];memset (parm,0 ,sizeof (union iucv_param ));if (userdata)memcpy (parm->ctrl.ipuser, userdata,sizeof (parm->ctrl.ipuser));
@@ -918,10 +930,8 @@ int iucv_path_sever(struct iucv_path *paif (iucv_active_cpu !=smp_processor_id ())spin_lock_bh (&iucv_table_lock); rc =iucv_sever_pathid (path->pathid, userdata); -if (!rc) { - iucv_path_table[path->pathid] =NULL ; -list_del_init (&path->list); - } + iucv_path_table[path->pathid] =NULL ; +list_del_init (&path->list);if (iucv_active_cpu !=smp_processor_id ())spin_unlock_bh (&iucv_table_lock);preempt_enable ();
@@ -1413,7 +1423,7 @@ static void iucv_path_severed(struct iucelse {iucv_sever_pathid (path->pathid,NULL ); iucv_path_table[path->pathid] =NULL ; -list_del_init (&path->list); +list_del (&path->list);iucv_path_free (path); } }
@@ -1717,6 +1727,13 @@ static int __init iucv_init(void) rc = -ENOMEM ; goto out_free; } + iucv_param_irq[cpu] =kmalloc_node (sizeof (union iucv_param ), +GFP_KERNEL |GFP_DMA ,cpu_to_node (cpu)); +if (!iucv_param_irq[cpu]) { + rc = -ENOMEM ; + goto out_free; + } + } rc =register_hotcpu_notifier (&iucv_cpu_notifier);if (rc)
@@ -1734,6 +1751,8 @@ out_cpu:unregister_hotcpu_notifier (&iucv_cpu_notifier); out_free:for_each_possible_cpu (cpu) { +kfree (iucv_param_irq[cpu]); + iucv_param_irq[cpu] =NULL ;kfree (iucv_param[cpu]); iucv_param[cpu] =NULL ;kfree (iucv_irq_data[cpu]);
@@ -1764,6 +1783,8 @@ static void __exit iucv_exit(void)spin_unlock_irq (&iucv_queue_lock);unregister_hotcpu_notifier (&iucv_cpu_notifier);for_each_possible_cpu (cpu) { +kfree (iucv_param_irq[cpu]); + iucv_param_irq[cpu] =NULL ;kfree (iucv_param[cpu]); iucv_param[cpu] =NULL ;kfree (iucv_irq_data[cpu]);
PATCH 2/8 af_iucv: sync sk shutdown flag if iucv path is quiesced
In reply to Ursula BraunFrom: Hendrik Brueckner <[email protected]>
If the af_iucv communication partner quiesces the path to shutdown its receive direction, provide a quiesce callback implementation to shutdown the (local) send direction. This ensures that both sides are synchronized.
---
net/iucv/af_iucv.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
net/iucv/af_iucv.c +18 -1
@@ -54,6 +54,7 @@ static void iucv_callback_connack(structstatic int iucv_callback_connreq (struct iucv_path *,u8 ipvmid[8 ],u8 ipuser[16 ]);static void iucv_callback_connrej (struct iucv_path *,u8 ipuser[16 ]); +static void iucv_callback_shutdown (struct iucv_path *,u8 ipuser[16 ]);static struct iucv_sock_list iucv_sk_list = { .lock =__RW_LOCK_UNLOCKED (iucv_sk_list.lock),
@@ -65,7 +66,8 @@ static struct iucv_handler af_iucv_handl .path_complete = iucv_callback_connack, .path_severed = iucv_callback_connrej, .message_pending = iucv_callback_rx, - .message_complete = iucv_callback_txdone + .message_complete = iucv_callback_txdone, + .path_quiesced = iucv_callback_shutdown, };static inline void high_nmcpy (unsigned char *dst,char *src)
@@ -1196,6 +1198,21 @@ static void iucv_callback_connrej(struct sk->sk_state_change (sk); } +/* called if the other communication side shuts down its RECV direction; +* in turn, the callback sets SEND_SHUTDOWN to disable sending of data. +*/ +static void iucv_callback_shutdown (struct iucv_path *path,u8 ipuser[16 ]) +{ +struct sock *sk = path->private; + +bh_lock_sock (sk); +if (sk->sk_state !=IUCV_CLOSED ) { + sk->sk_shutdown |=SEND_SHUTDOWN ; + sk->sk_state_change (sk); + } +bh_unlock_sock (sk); +} +static struct proto_ops iucv_sock_ops = { .family =PF_IUCV , .owner =THIS_MODULE ,
PATCH 3/8 af_iucv: add sockopt() to enable/disable use of IPRM_DATA msgs
In reply to Ursula BraunFrom: Hendrik Brueckner <[email protected]>
Provide the socket operations getsocktopt() and setsockopt() to enable/disable sending of data in the parameter list of IUCV messages.
The patch sets respective flag only.
---
include/linux/socket.h | 1 include/net/iucv/af_iucv.h | 4 ++ net/iucv/af_iucv.c | 79 +++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 3 deletions(-)
include/linux/socket.h +1 -0
@@ -303,6 +303,7 @@ struct ucred {#define SOL_BLUETOOTH 274#define SOL_PNPIPE 275#define SOL_RDS 276 +#define SOL_IUCV 277/* IPX options */ #define IPX_TYPE 1
include/net/iucv/af_iucv.h +4 -0
@@ -73,8 +73,12 @@ struct iucv_sock {struct sk_buff_head backlog_skb_q;struct sock_msg_q message_q;unsigned int send_tag; +u8 flags; }; +/* iucv socket options (SOL_IUCV) */ +#define SO_IPRMDATA_MSG 0x0080/* send/recv IPRM_DATA msgs */ +struct iucv_sock_list {struct hlist_head head;rwlock_t lock;
net/iucv/af_iucv.c +76 -3
103 lines not on this page · raw message
PATCH 4/8 af_iucv: Support data in IUCV msg parameter lists (IPRMDATA)
In reply to Ursula BraunFrom: Hendrik Brueckner <[email protected]>
The patch allows to send and receive data in the parameter list of an iucv message.
The parameter list is an arry of 8 bytes that are used by af_iucv as follows:
0..6 7 bytes for socket data and
7 1 byte to store the data length.
Instead of storing the data length directly, the difference between 0xFF and the data length is used.
This convention does not interfere with the existing use of PRM messages for shutting down the send direction of an AF_IUCV socket (shutdown() operation). Data lenghts greater than 7 (or PRM message byte 8 is less than 0xF8) denotes to special messages. Currently, the special SEND_SHUTDOWN message is supported only.
To use IPRM messages, both communicators must set the IUCV_IPRMDATA flag during path negotiation, i.e. in iucv_connect() and path_pending().
To be compatible to older af_iucv implementations, sending PRM messages is controlled by the socket option SO_IPRMDATA_MSG. Receiving PRM messages does not depend on the socket option (but requires the IUCV_IPRMDATA path flag to be set).
Sending/Receiving data in the parameter list improves performance for small amounts of data by reducing message_completion() interrupts and memory copy operations.
---
net/iucv/af_iucv.c | 121 ++++++++++++++++++++++++++++++++++++++++++++--------- net/iucv/iucv.c | 2 2 files changed, 103 insertions(+), 20 deletions(-)
net/iucv/af_iucv.c +101 -20
@@ -29,9 +29,6 @@#include <net/iucv/iucv.h> #include <net/iucv/af_iucv.h> -#define CONFIG_IUCV_SOCK_DEBUG 1 - -#define IPRMDATA 0x80#define VERSION "1.1"static char iucv_userid[80 ];
@@ -44,6 +41,10 @@ static struct proto iucv_proto = { .obj_size = sizeof(struct iucv_sock), }; +/* special AF_IUCV IPRM messages */ +static const u8 iprm_shutdown[8 ] = + {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x01 }; +static void iucv_sock_kill (struct sock *sk);static void iucv_sock_close (struct sock *sk);
@@ -80,6 +81,37 @@ static inline void low_nmcpy(unsigned chmemcpy (&dst[8 ], src,8 ); } +/** +* iucv_msg_length() - Returns the length of an iucv message. +* @msg: Pointer to struct iucv_message, MUST NOT be NULL +* +* The function returns the length of the specified iucv message @msg of data +* stored in a buffer and of data stored in the parameter list (PRMDATA). +* +* For IUCV_IPRMDATA, AF_IUCV uses the following convention to transport socket +* data: +* PRMDATA[0..6] socket data (max 7 bytes); +* PRMDATA[7] socket data length value (len is 0xff - PRMDATA[7]) +* +* The socket data length is computed by substracting the socket data length +* value from 0xFF. +* If the socket data len is greater 7, then PRMDATA can be used for special +* notifications (see iucv_sock_shutdown); and further, +* if the socket data len is > 7, the function returns 8. +* +* Use this function to allocate socket buffers to store iucv message data. +*/ +static inline size_t iucv_msg_length (struct iucv_message *msg) +{ +size_t datalen; + +if (msg->flags &IUCV_IPRMDATA ) { + datalen =0xff - msg->rmmsg[7 ]; +return (datalen <8 ) ? datalen :8 ; + } +return msg->length; +} +/* Timers */ static void iucv_sock_timeout (unsigned long arg) {
@@ -487,7 +519,7 @@ static int iucv_sock_connect(struct sock iucv =iucv_sk (sk);/* Create path. */ iucv->path =iucv_path_alloc (IUCV_QUEUELEN_DEFAULT , -IPRMDATA ,GFP_KERNEL ); +IUCV_IPRMDATA ,GFP_KERNEL );if (!iucv->path) { err = -ENOMEM ; goto done;
@@ -521,8 +553,7 @@ static int iucv_sock_connect(struct sock }if (sk->sk_state ==IUCV_DISCONN ) { -release_sock (sk); -return -ECONNREFUSED ; + err = -ECONNREFUSED ; }if (err) {
@@ -636,6 +667,30 @@ static int iucv_sock_getname(struct sockreturn 0 ; } +/** +* iucv_send_iprm() - Send socket data in parameter list of an iucv message. +* @path: IUCV path +* @msg: Pointer to a struct iucv_message +* @skb: The socket data to send, skb->len MUST BE <= 7 +* +* Send the socket data in the parameter list in the iucv message +* (IUCV_IPRMDATA). The socket data is stored at index 0 to 6 in the parameter +* list and the socket data len at index 7 (last byte). +* See also iucv_msg_length(). +* +* Returns the error code from the iucv_message_send() call. +*/ +static int iucv_send_iprm (struct iucv_path *path,struct iucv_message *msg, +struct sk_buff *skb) +{ +u8 prmdata[8 ]; + +memcpy (prmdata, (void *) skb->data, skb->len); + prmdata[7 ] =0xff - (u8 ) skb->len; +return iucv_message_send (path, msg,IUCV_IPRMDATA ,0 , + (void *) prmdata,8 ); +} +static int iucv_sock_sendmsg (struct kiocb *iocb,struct socket *sock,struct msghdr *msg,size_t len) {
@@ -677,8 +732,29 @@ static int iucv_sock_sendmsg(struct kioc txmsg.tag = iucv->send_tag++;memcpy (skb->cb, &txmsg.tag,4 );skb_queue_tail (&iucv->send_skb_q, skb); - err =iucv_message_send (iucv->path, &txmsg,0 ,0 , - (void *) skb->data, skb->len); + +if (((iucv->path->flags &IUCV_IPRMDATA ) & iucv->flags) + && skb->len <=7 ) { + err =iucv_send_iprm (iucv->path, &txmsg, skb); + +/* on success: there is no message_complete callback +* for an IPRMDATA msg; remove skb from send queue */ +if (err ==0 ) { +skb_unlink (skb, &iucv->send_skb_q); +kfree_skb (skb); + } + +/* this error should never happen since the +* IUCV_IPRMDATA path flag is set... sever path */ +if (err ==0x15 ) { +iucv_path_sever (iucv->path,NULL ); +skb_unlink (skb, &iucv->send_skb_q); + err = -EPIPE ; + goto fail; + } + }else + err =iucv_message_send (iucv->path, &txmsg,0 ,0 , + (void *) skb->data, skb->len);if (err) {if (err ==3 ) { user_id[8 ] =0 ;
@@ -744,19 +820,25 @@ static void iucv_process_message(struct struct iucv_message *msg) {int rc; +unsigned int len; -if (msg->flags &IPRMDATA ) { - skb->data =NULL ; - skb->len =0 ; + len =iucv_msg_length (msg); + +/* check for special IPRM messages (e.g. iucv_sock_shutdown) */ +if ((msg->flags &IUCV_IPRMDATA ) && len >7 ) { +if (memcmp (msg->rmmsg, iprm_shutdown,8 ) ==0 ) { + skb->data =NULL ; + skb->len =0 ; + } }else { - rc =iucv_message_receive (path, msg,0 , skb->data, - msg->length,NULL ); + rc =iucv_message_receive (path, msg, msg->flags &IUCV_IPRMDATA , + skb->data, len,NULL );if (rc) {kfree_skb (skb);return ; }if (skb->truesize >= sk->sk_rcvbuf /4 ) { - rc =iucv_fragment_skb (sk, skb, msg->length); + rc =iucv_fragment_skb (sk, skb, len);kfree_skb (skb); skb =NULL ;if (rc) {
@@ -767,7 +849,7 @@ static void iucv_process_message(struct }else {skb_reset_transport_header (skb);skb_reset_network_header (skb); - skb->len = msg->length; + skb->len = len; } }
@@ -782,7 +864,7 @@ static void iucv_process_message_q(strucstruct sock_msg_q *p, *n;list_for_each_entry_safe (p, n, &iucv->message_q.list, list) { - skb =alloc_skb (p->msg.length,GFP_ATOMIC |GFP_DMA ); + skb =alloc_skb (iucv_msg_length (&p->msg),GFP_ATOMIC |GFP_DMA );if (!skb)break ;iucv_process_message (sk, skb, p->path, &p->msg);
@@ -928,7 +1010,6 @@ static int iucv_sock_shutdown(struct socstruct iucv_sock *iucv =iucv_sk (sk);struct iucv_message txmsg;int err =0 ; -u8 prmmsg[8 ] = {0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x01 }; how++;
@@ -950,7 +1031,7 @@ static int iucv_sock_shutdown(struct soc txmsg.class =0 ; txmsg.tag =0 ; err =iucv_message_send (iucv->path, &txmsg,IUCV_IPRMDATA ,0 , - (void *) prmmsg,8 ); + (void *) iprm_shutdown,8 );if (err) {switch (err) {case 1 :
@@ -1196,11 +1277,11 @@ static void iucv_callback_rx(struct iucv goto save_message; len =atomic_read (&sk->sk_rmem_alloc); - len += msg->length +sizeof (struct sk_buff ); + len +=iucv_msg_length (msg) +sizeof (struct sk_buff );if (len > sk->sk_rcvbuf) goto save_message; - skb =alloc_skb (msg->length,GFP_ATOMIC |GFP_DMA ); + skb =alloc_skb (iucv_msg_length (msg),GFP_ATOMIC |GFP_DMA );if (!skb) goto save_message;
net/iucv/iucv.c +2 -0
@@ -1388,6 +1388,8 @@ static void iucv_path_complete(struct iustruct iucv_path_complete *ipc = (void *) data;struct iucv_path *path = iucv_path_table[ipc->ippathid]; +if (path) + path->flags = ipc->ipflags1;if (path && path->handler && path->handler->path_complete) path->handler->path_complete (path, ipc->ipuser); }
PATCH 5/8 af_iucv: Modify iucv msg target class using control msghdr
In reply to Ursula BraunFrom: Hendrik Brueckner <[email protected]>
Allow 'classification' of socket data that is sent or received over an af_iucv socket. For classification of data, the target class of an (native) iucv message is used.
This patch provides the cmsg interface for iucv_sock_recvmsg() and iucv_sock_sendmsg(). Applications can use the msg_control field of struct msghdr to set or get the target class as a "socket control message" (SCM/CMSG).
---
include/net/iucv/af_iucv.h | 3 + net/iucv/af_iucv.c | 79 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 78 insertions(+), 4 deletions(-)
include/net/iucv/af_iucv.h +3 -0
@@ -79,6 +79,9 @@ struct iucv_sock {/* iucv socket options (SOL_IUCV) */ #define SO_IPRMDATA_MSG 0x0080/* send/recv IPRM_DATA msgs */ +/* iucv related control messages (scm) */ +#define SCM_IUCV_TRGCLS 0x0001/* target class control message */ +struct iucv_sock_list {struct hlist_head head;rwlock_t lock;
net/iucv/af_iucv.c +75 -4
128 lines not on this page · raw message
PATCH 6/8 af_iucv: Provide new socket type SOCK_SEQPACKET
In reply to Ursula BraunFrom: Hendrik Brueckner <[email protected]>
This patch provides the socket type SOCK_SEQPACKET in addition to SOCK_STREAM.
AF_IUCV sockets of type SOCK_SEQPACKET supports an 1:1 mapping of socket read or write operations to complete IUCV messages. Socket data or IUCV message data is not fragmented as this is the case for SOCK_STREAM sockets.
The intention is to help application developers who write applications or device drivers using native IUCV interfaces (Linux kernel or z/VM IUCV interfaces).
---
net/iucv/af_iucv.c | 73 ++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 17 deletions(-)
net/iucv/af_iucv.c +56 -17
@@ -289,11 +289,22 @@ static int iucv_sock_create(struct net * {struct sock *sk; -if (sock->type !=SOCK_STREAM ) -return -ESOCKTNOSUPPORT ; +if (protocol && protocol !=PF_IUCV ) +return -EPROTONOSUPPORT ; sock->state =SS_UNCONNECTED ; - sock->ops = &iucv_sock_ops; + +switch (sock->type) { +case SOCK_STREAM : + sock->ops = &iucv_sock_ops; +break ; +case SOCK_SEQPACKET : +/* currently, proto ops can handle both sk types */ + sock->ops = &iucv_sock_ops; +break ; +default : +return -ESOCKTNOSUPPORT ; + } sk =iucv_sock_alloc (sock, protocol,GFP_KERNEL );if (!sk)
@@ -504,11 +515,9 @@ static int iucv_sock_connect(struct sockif (sk->sk_state !=IUCV_OPEN && sk->sk_state !=IUCV_BOUND )return -EBADFD ; -if (sk->sk_type !=SOCK_STREAM ) +if (sk->sk_type !=SOCK_STREAM && sk->sk_type !=SOCK_SEQPACKET )return -EINVAL ; - iucv =iucv_sk (sk); -if (sk->sk_state ==IUCV_OPEN ) { err =iucv_sock_autobind (sk);if (unlikely (err))
@@ -585,7 +594,10 @@ static int iucv_sock_listen(struct sockelock_sock (sk); err = -EINVAL ; -if (sk->sk_state !=IUCV_BOUND || sock->type !=SOCK_STREAM ) +if (sk->sk_state !=IUCV_BOUND ) + goto done; + +if (sock->type !=SOCK_STREAM && sock->type !=SOCK_SEQPACKET ) goto done; sk->sk_max_ack_backlog = backlog;
@@ -720,6 +732,10 @@ static int iucv_sock_sendmsg(struct kiocif (msg->msg_flags &MSG_OOB )return -EOPNOTSUPP ; +/* SOCK_SEQPACKET: we do not support segmented records */ +if (sk->sk_type ==SOCK_SEQPACKET && !(msg->msg_flags &MSG_EOR )) +return -EOPNOTSUPP ; +lock_sock (sk);if (sk->sk_shutdown &SEND_SHUTDOWN ) {
@@ -770,6 +786,10 @@ static int iucv_sock_sendmsg(struct kioc } } +/* allocate one skb for each iucv message: +* this is fine for SOCK_SEQPACKET (unless we want to support +* segmented records using the MSG_EOR flag), but +* for SOCK_STREAM we might want to improve it in future */ if (!(skb =sock_alloc_send_skb (sk, len, msg->msg_flags &MSG_DONTWAIT , &err)))
@@ -897,7 +917,11 @@ static void iucv_process_message(structkfree_skb (skb);return ; } -if (skb->truesize >= sk->sk_rcvbuf /4 ) { +/* we need to fragment iucv messages for SOCK_STREAM only; +* for SOCK_SEQPACKET, it is only relevant if we support +* record segmentation using MSG_EOR (see also recvmsg()) */ +if (sk->sk_type ==SOCK_STREAM && + skb->truesize >= sk->sk_rcvbuf /4 ) { rc =iucv_fragment_skb (sk, skb, len);kfree_skb (skb); skb =NULL ;
@@ -941,7 +965,8 @@ static int iucv_sock_recvmsg(struct kiocint noblock = flags &MSG_DONTWAIT ;struct sock *sk = sock->sk;struct iucv_sock *iucv =iucv_sk (sk); -int target, copied =0 ; +int target; +unsigned int copied, rlen;struct sk_buff *skb, *rskb, *cskb;int err =0 ;
@@ -963,7 +988,8 @@ static int iucv_sock_recvmsg(struct kiocreturn err; } - copied = min_t(unsigned int, skb->len, len); + rlen = skb->len;/* real length of skb */ + copied = min_t(unsigned int, rlen, len); cskb = skb;if (memcpy_toiovec (msg->msg_iov, cskb->data, copied)) {
@@ -973,7 +999,13 @@ static int iucv_sock_recvmsg(struct kioc goto done; } - len -= copied; +/* SOCK_SEQPACKET: set MSG_TRUNC if recv buf size is too small */ +if (sk->sk_type ==SOCK_SEQPACKET ) { +if (copied < rlen) + msg->msg_flags |=MSG_TRUNC ; +/* each iucv message contains a complete record */ + msg->msg_flags |=MSG_EOR ; + }/* create control message to store iucv msg target class: * get the trgcls from the control buffer of the skb due to
@@ -988,11 +1020,14 @@ static int iucv_sock_recvmsg(struct kioc/* Mark read part of skb as used */ if (!(flags &MSG_PEEK )) { -skb_pull (skb, copied); -if (skb->len) { -skb_queue_head (&sk->sk_receive_queue, skb); - goto done; +/* SOCK_STREAM: re-queue skb if it contains unreceived data */ +if (sk->sk_type ==SOCK_STREAM ) { +skb_pull (skb, copied); +if (skb->len) { +skb_queue_head (&sk->sk_receive_queue, skb); + goto done; + } }kfree_skb (skb);
@@ -1019,7 +1054,11 @@ static int iucv_sock_recvmsg(struct kiocskb_queue_head (&sk->sk_receive_queue, skb); done: -return err ? : copied; +/* SOCK_SEQPACKET: return real length if MSG_TRUNC is set */ +if (sk->sk_type ==SOCK_SEQPACKET && (flags &MSG_TRUNC )) + copied = rlen; + +return copied; }static inline unsigned int iucv_accept_poll (struct sock *parent)
@@ -1281,7 +1320,7 @@ static int iucv_callback_connreq(struct }/* Create the new socket */ - nsk =iucv_sock_alloc (NULL ,SOCK_STREAM ,GFP_ATOMIC ); + nsk =iucv_sock_alloc (NULL , sk->sk_type,GFP_ATOMIC );if (!nsk) { err =iucv_path_sever (path, user_data);iucv_path_free (path);
PATCH 7/8 af_iucv: cleanup and refactor recvmsg() EFAULT handling
In reply to Ursula BraunFrom: Hendrik Brueckner <[email protected]>
If the skb cannot be copied to user iovec, always return -EFAULT. The skb is enqueued again, except MSG_PEEK flag is set, to allow user space applications to correct its iovec pointer.
---
net/iucv/af_iucv.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
net/iucv/af_iucv.c +3 -7
@@ -965,7 +965,6 @@ static int iucv_sock_recvmsg(struct kiocint noblock = flags &MSG_DONTWAIT ;struct sock *sk = sock->sk;struct iucv_sock *iucv =iucv_sk (sk); -int target;unsigned int copied, rlen;struct sk_buff *skb, *rskb, *cskb;int err =0 ;
@@ -979,8 +978,6 @@ static int iucv_sock_recvmsg(struct kiocif (flags & (MSG_OOB ))return -EOPNOTSUPP ; - target =sock_rcvlowat (sk, flags &MSG_WAITALL , len); - skb =skb_recv_datagram (sk, flags, noblock, &err);if (!skb) {if (sk->sk_shutdown &RCV_SHUTDOWN )
@@ -993,10 +990,9 @@ static int iucv_sock_recvmsg(struct kioc cskb = skb;if (memcpy_toiovec (msg->msg_iov, cskb->data, copied)) { -skb_queue_head (&sk->sk_receive_queue, skb); -if (copied ==0 ) -return -EFAULT ; - goto done; +if (!(flags &MSG_PEEK )) +skb_queue_head (&sk->sk_receive_queue, skb); +return -EFAULT ; }/* SOCK_SEQPACKET: set MSG_TRUNC if recv buf size is too small */
PATCH 8/8 af_iucv: New socket option for setting IUCV MSGLIMITs
In reply to Ursula BraunFrom: Hendrik Brueckner <[email protected]>
The SO_MSGLIMIT socket option modifies the message limit for new IUCV communication paths.
The message limit specifies the maximum number of outstanding messages that are allowed for connections. This setting can be lowered by z/VM when an IUCV connection is established.
Expects an integer value in the range of 1 to 65535. The default value is 65535.
The message limit must be set before calling connect() or listen() for sockets.
If sockets are already connected or in state listen, changing the message limit is not supported.
For reading the message limit value, unconnected sockets return the limit that has been set or the default limit. For connected sockets, the actual message limit is returned. The actual message limit is assigned by z/VM for each connection and it depends on IUCV MSGLIMIT authorizations specified for the z/VM guest virtual machine.
---
include/net/iucv/af_iucv.h | 2 ++ net/iucv/af_iucv.c | 27 +++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-)
include/net/iucv/af_iucv.h +2 -0
@@ -74,10 +74,12 @@ struct iucv_sock {struct sock_msg_q message_q;unsigned int send_tag;u8 flags; +u16 msglimit; };/* iucv socket options (SOL_IUCV) */ #define SO_IPRMDATA_MSG 0x0080/* send/recv IPRM_DATA msgs */ +#define SO_MSGLIMIT 0x1000/* get/set IUCV MSGLIMIT */ /* iucv related control messages (scm) */ #define SCM_IUCV_TRGCLS 0x0001/* target class control message */
net/iucv/af_iucv.c +25 -2
@@ -268,6 +268,7 @@ static struct sock *iucv_sock_alloc(struskb_queue_head_init (&iucv_sk (sk)->backlog_skb_q);iucv_sk (sk)->send_tag =0 ;iucv_sk (sk)->flags =0 ; +iucv_sk (sk)->msglimit =IUCV_QUEUELEN_DEFAULT ; sk->sk_destruct = iucv_sock_destruct; sk->sk_sndtimeo =IUCV_CONN_TIMEOUT ;
@@ -536,7 +537,7 @@ static int iucv_sock_connect(struct sock iucv =iucv_sk (sk);/* Create path. */ - iucv->path =iucv_path_alloc (IUCV_QUEUELEN_DEFAULT , + iucv->path =iucv_path_alloc (iucv->msglimit,IUCV_IPRMDATA ,GFP_KERNEL );if (!iucv->path) { err = -ENOMEM ;
@@ -1219,6 +1220,20 @@ static int iucv_sock_setsockopt(struct selse iucv->flags &= ~IUCV_IPRMDATA ;break ; +case SO_MSGLIMIT : +switch (sk->sk_state) { +case IUCV_OPEN : +case IUCV_BOUND : +if (val <1 || val > (u16)(~0 )) + rc = -EINVAL ; +else + iucv->msglimit = val; +break ; +default : + rc = -EINVAL ; +break ; + } +break ;default : rc = -ENOPROTOOPT ;break ;
@@ -1250,6 +1265,12 @@ static int iucv_sock_getsockopt(struct scase SO_IPRMDATA_MSG : val = (iucv->flags &IUCV_IPRMDATA ) ?1 :0 ;break ; +case SO_MSGLIMIT : +lock_sock (sk); + val = (iucv->path !=NULL ) ? iucv->path->msglim/* connected */ + : iucv->msglimit;/* default */ +release_sock (sk); +break ;default :return -ENOPROTOOPT ; }
@@ -1339,7 +1360,9 @@ static int iucv_callback_connreq(structmemcpy (nuser_data +8 , niucv->src_name,8 );ASCEBC (nuser_data +8 ,8 ); - path->msglim =IUCV_QUEUELEN_DEFAULT ; +/* set message limit for path based on msglimit of accepting socket */ + niucv->msglimit = iucv->msglimit; + path->msglim = iucv->msglimit; err =iucv_path_accept (path, &af_iucv_handler, nuser_data, nsk);if (err) { err =iucv_path_sever (path, user_data);
David Miller
maintainerFrom: Ursula Braun <[email protected]>
Date: Wed, 22 Apr 2009 11:26:19 +0200
Quoted 5 lines
thanks for applying our critical
af_iucvbug fixes to net-2.6. Here is now the series of iucv /af_iucvpatches for the current development cycle.
The patches are based on top of the current net-next-2.6 kernel (2.6.30-rc1).
Do I need to pull net-2.6 into net-next-2.6 for this stuff to apply properly?
Just checking.