* [PATCH] sctp: fix the sendmsg() flag SCTP_EOF to comply to spec
@ 2009-09-10 3:19 Wei Yongjun
2009-09-10 17:35 ` Vlad Yasevich
0 siblings, 1 reply; 2+ messages in thread
From: Wei Yongjun @ 2009-09-10 3:19 UTC (permalink / raw)
To: linux-sctp
It should be possible to send a message and set the SCTP_EOF flag
at the same time, but we don't support it yet. This patch fix the
sendmsg() flag SCTP_EOF to comply to spec.
Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
---
net/sctp/socket.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 89af37a..d48e18c 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
@@ -1540,13 +1540,12 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
goto out_nounlock;
}
- /* If SCTP_EOF is set, no data can be sent. Disallow sending zero
- * length messages when SCTP_EOF|SCTP_ABORT is not set.
+ /* Disallow sending zero length messages when SCTP_EOF|SCTP_ABORT
+ * is not set.
* If SCTP_ABORT is set, the message length could be non zero with
* the msg_iov set to the user abort reason.
*/
- if (((sinfo_flags & SCTP_EOF) && (msg_len > 0)) ||
- (!(sinfo_flags & (SCTP_EOF|SCTP_ABORT)) && (msg_len = 0))) {
+ if (!(sinfo_flags & (SCTP_EOF|SCTP_ABORT)) && (msg_len = 0)) {
err = -EINVAL;
goto out_nounlock;
}
@@ -1603,7 +1602,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
goto out_unlock;
}
- if (sinfo_flags & SCTP_EOF) {
+ if ((sinfo_flags & SCTP_EOF) && msg_len = 0) {
SCTP_DEBUG_PRINTK("Shutting down association: %p\n",
asoc);
sctp_primitive_SHUTDOWN(asoc, NULL);
@@ -1835,6 +1834,12 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
else
err = msg_len;
+ if (sinfo_flags & SCTP_EOF) {
+ SCTP_DEBUG_PRINTK("Shutting down association: %p\n",
+ asoc);
+ sctp_primitive_SHUTDOWN(asoc, NULL);
+ }
+
/* If we are already past ASSOCIATE, the lower
* layers are responsible for association cleanup.
*/
--
1.6.2.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sctp: fix the sendmsg() flag SCTP_EOF to comply to spec
2009-09-10 3:19 [PATCH] sctp: fix the sendmsg() flag SCTP_EOF to comply to spec Wei Yongjun
@ 2009-09-10 17:35 ` Vlad Yasevich
0 siblings, 0 replies; 2+ messages in thread
From: Vlad Yasevich @ 2009-09-10 17:35 UTC (permalink / raw)
To: linux-sctp
Wei Yongjun wrote:
> It should be possible to send a message and set the SCTP_EOF flag
> at the same time, but we don't support it yet. This patch fix the
> sendmsg() flag SCTP_EOF to comply to spec.
Hi Wei
Good start, but I don't think this will work with implicit connection.
We are going to attempt to associate, queue the DATA, and then issue a
shutdown, which will call sctp_sf_cookie_wait_prm_shutdown() thus never
sending.
Also, we might want to forbid this combination on non-blocking sockets
since we would essentially need to run the whole thing in a separate task.
-vlad
>
> Signed-off-by: Wei Yongjun <yjwei@cn.fujitsu.com>
> ---
> net/sctp/socket.c | 15 ++++++++++-----
> 1 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/net/sctp/socket.c b/net/sctp/socket.c
> index 89af37a..d48e18c 100644
> --- a/net/sctp/socket.c
> +++ b/net/sctp/socket.c
> @@ -1540,13 +1540,12 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
> goto out_nounlock;
> }
>
> - /* If SCTP_EOF is set, no data can be sent. Disallow sending zero
> - * length messages when SCTP_EOF|SCTP_ABORT is not set.
> + /* Disallow sending zero length messages when SCTP_EOF|SCTP_ABORT
> + * is not set.
> * If SCTP_ABORT is set, the message length could be non zero with
> * the msg_iov set to the user abort reason.
> */
> - if (((sinfo_flags & SCTP_EOF) && (msg_len > 0)) ||
> - (!(sinfo_flags & (SCTP_EOF|SCTP_ABORT)) && (msg_len = 0))) {
> + if (!(sinfo_flags & (SCTP_EOF|SCTP_ABORT)) && (msg_len = 0)) {
> err = -EINVAL;
> goto out_nounlock;
> }
> @@ -1603,7 +1602,7 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
> goto out_unlock;
> }
>
> - if (sinfo_flags & SCTP_EOF) {
> + if ((sinfo_flags & SCTP_EOF) && msg_len = 0) {
> SCTP_DEBUG_PRINTK("Shutting down association: %p\n",
> asoc);
> sctp_primitive_SHUTDOWN(asoc, NULL);
> @@ -1835,6 +1834,12 @@ SCTP_STATIC int sctp_sendmsg(struct kiocb *iocb, struct sock *sk,
> else
> err = msg_len;
>
> + if (sinfo_flags & SCTP_EOF) {
> + SCTP_DEBUG_PRINTK("Shutting down association: %p\n",
> + asoc);
> + sctp_primitive_SHUTDOWN(asoc, NULL);
> + }
> +
> /* If we are already past ASSOCIATE, the lower
> * layers are responsible for association cleanup.
> */
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-09-10 17:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-09-10 3:19 [PATCH] sctp: fix the sendmsg() flag SCTP_EOF to comply to spec Wei Yongjun
2009-09-10 17:35 ` Vlad Yasevich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).