Commit bb664f49 authored by Hendrik Brueckner's avatar Hendrik Brueckner Committed by David S. Miller

af_iucv: Change if condition in sendmsg() for more readability

Change the if condition to exit sendmsg() if the socket in not connected.
Signed-off-by: default avatarHendrik Brueckner <brueckner@linux.vnet.ibm.com>
Signed-off-by: default avatarUrsula Braun <ursula.braun@de.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cb2107be
...@@ -747,108 +747,107 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock, ...@@ -747,108 +747,107 @@ static int iucv_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
goto out; goto out;
} }
if (sk->sk_state == IUCV_CONNECTED) { /* Return if the socket is not in connected state */
/* initialize defaults */ if (sk->sk_state != IUCV_CONNECTED) {
cmsg_done = 0; /* check for duplicate headers */ err = -ENOTCONN;
txmsg.class = 0; goto out;
}
/* iterate over control messages */
for (cmsg = CMSG_FIRSTHDR(msg); cmsg;
cmsg = CMSG_NXTHDR(msg, cmsg)) {
if (!CMSG_OK(msg, cmsg)) {
err = -EINVAL;
goto out;
}
if (cmsg->cmsg_level != SOL_IUCV) /* initialize defaults */
continue; cmsg_done = 0; /* check for duplicate headers */
txmsg.class = 0;
if (cmsg->cmsg_type & cmsg_done) { /* iterate over control messages */
err = -EINVAL; for (cmsg = CMSG_FIRSTHDR(msg); cmsg;
goto out; cmsg = CMSG_NXTHDR(msg, cmsg)) {
}
cmsg_done |= cmsg->cmsg_type;
switch (cmsg->cmsg_type) { if (!CMSG_OK(msg, cmsg)) {
case SCM_IUCV_TRGCLS: err = -EINVAL;
if (cmsg->cmsg_len != CMSG_LEN(TRGCLS_SIZE)) { goto out;
err = -EINVAL; }
goto out;
}
/* set iucv message target class */ if (cmsg->cmsg_level != SOL_IUCV)
memcpy(&txmsg.class, continue;
(void *) CMSG_DATA(cmsg), TRGCLS_SIZE);
break; if (cmsg->cmsg_type & cmsg_done) {
err = -EINVAL;
goto out;
}
cmsg_done |= cmsg->cmsg_type;
default: switch (cmsg->cmsg_type) {
case SCM_IUCV_TRGCLS:
if (cmsg->cmsg_len != CMSG_LEN(TRGCLS_SIZE)) {
err = -EINVAL; err = -EINVAL;
goto out; goto out;
break;
} }
}
/* allocate one skb for each iucv message: /* set iucv message target class */
* this is fine for SOCK_SEQPACKET (unless we want to support memcpy(&txmsg.class,
* segmented records using the MSG_EOR flag), but (void *) CMSG_DATA(cmsg), TRGCLS_SIZE);
* 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)))
goto out;
if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) { break;
err = -EFAULT;
goto fail; default:
err = -EINVAL;
goto out;
break;
} }
}
/* increment and save iucv message tag for msg_completion cbk */ /* allocate one skb for each iucv message:
txmsg.tag = iucv->send_tag++; * this is fine for SOCK_SEQPACKET (unless we want to support
memcpy(CB_TAG(skb), &txmsg.tag, CB_TAG_LEN); * segmented records using the MSG_EOR flag), but
skb_queue_tail(&iucv->send_skb_q, skb); * for SOCK_STREAM we might want to improve it in future */
skb = sock_alloc_send_skb(sk, len, msg->msg_flags & MSG_DONTWAIT,
&err);
if (!skb)
goto out;
if (memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len)) {
err = -EFAULT;
goto fail;
}
if (((iucv->path->flags & IUCV_IPRMDATA) & iucv->flags) /* increment and save iucv message tag for msg_completion cbk */
&& skb->len <= 7) { txmsg.tag = iucv->send_tag++;
err = iucv_send_iprm(iucv->path, &txmsg, skb); memcpy(CB_TAG(skb), &txmsg.tag, CB_TAG_LEN);
skb_queue_tail(&iucv->send_skb_q, skb);
/* on success: there is no message_complete callback if (((iucv->path->flags & IUCV_IPRMDATA) & iucv->flags)
* for an IPRMDATA msg; remove skb from send queue */ && skb->len <= 7) {
if (err == 0) { err = iucv_send_iprm(iucv->path, &txmsg, skb);
skb_unlink(skb, &iucv->send_skb_q);
kfree_skb(skb);
}
/* this error should never happen since the /* on success: there is no message_complete callback
* IUCV_IPRMDATA path flag is set... sever path */ * for an IPRMDATA msg; remove skb from send queue */
if (err == 0x15) { if (err == 0) {
iucv_path_sever(iucv->path, NULL); skb_unlink(skb, &iucv->send_skb_q);
skb_unlink(skb, &iucv->send_skb_q); kfree_skb(skb);
err = -EPIPE; }
goto fail;
} /* this error should never happen since the
} else * IUCV_IPRMDATA path flag is set... sever path */
err = iucv_message_send(iucv->path, &txmsg, 0, 0, if (err == 0x15) {
(void *) skb->data, skb->len); iucv_path_sever(iucv->path, NULL);
if (err) {
if (err == 3) {
user_id[8] = 0;
memcpy(user_id, iucv->dst_user_id, 8);
appl_id[8] = 0;
memcpy(appl_id, iucv->dst_name, 8);
pr_err("Application %s on z/VM guest %s"
" exceeds message limit\n",
user_id, appl_id);
}
skb_unlink(skb, &iucv->send_skb_q); skb_unlink(skb, &iucv->send_skb_q);
err = -EPIPE; err = -EPIPE;
goto fail; goto fail;
} }
} else
} else { err = iucv_message_send(iucv->path, &txmsg, 0, 0,
err = -ENOTCONN; (void *) skb->data, skb->len);
goto out; if (err) {
if (err == 3) {
user_id[8] = 0;
memcpy(user_id, iucv->dst_user_id, 8);
appl_id[8] = 0;
memcpy(appl_id, iucv->dst_name, 8);
pr_err("Application %s on z/VM guest %s"
" exceeds message limit\n",
appl_id, user_id);
}
skb_unlink(skb, &iucv->send_skb_q);
err = -EPIPE;
goto fail;
} }
release_sock(sk); release_sock(sk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment