All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: SCTP getting EAGAIN but poll or select return socket is writable
@ 2017-04-11 19:14 Michael Tuexen
  2017-04-11 19:20 ` Deepak Khandelwal
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Michael Tuexen @ 2017-04-11 19:14 UTC (permalink / raw)
  To: linux-sctp

> On 11. Apr 2017, at 21:08, Deepak Khandelwal <dazz.87@gmail.com> wrote:
> 
> Hi,
> 
> I am using 4.4.x kernel.
> 
> in context of LKSCTP, what could be the possible reasons that poll or
> select on fd return false positive events, causing application do
> write on fd but failed with EAGAIN ?
I'm just guessing here... What if you can write something, but not
something big as you try...
So how big is the message you are trying so send?

Best regards
Michael
> 
> 
> Best Regards,
> Deepak
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 7+ messages in thread

* SCTP getting EAGAIN but poll or select return socket is writable
  2017-04-11 19:14 SCTP getting EAGAIN but poll or select return socket is writable Michael Tuexen
@ 2017-04-11 19:20 ` Deepak Khandelwal
  2017-04-11 19:36 ` Marcelo Ricardo Leitner
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Deepak Khandelwal @ 2017-04-11 19:20 UTC (permalink / raw)
  To: linux-sctp

Hi,

I am using 4.4.x kernel.

in context of LKSCTP, what could be the possible reasons that poll or
select on fd return false positive events, causing application do
write on fd but failed with EAGAIN ?


Best Regards,
Deepak

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SCTP getting EAGAIN but poll or select return socket is writable
  2017-04-11 19:14 SCTP getting EAGAIN but poll or select return socket is writable Michael Tuexen
  2017-04-11 19:20 ` Deepak Khandelwal
@ 2017-04-11 19:36 ` Marcelo Ricardo Leitner
  2017-04-11 20:36 ` Deepak Khandelwal
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-04-11 19:36 UTC (permalink / raw)
  To: linux-sctp

On Tue, Apr 11, 2017 at 09:14:52PM +0200, Michael Tuexen wrote:
> > On 11. Apr 2017, at 21:08, Deepak Khandelwal <dazz.87@gmail.com> wrote:
> > 
> > Hi,
> > 
> > I am using 4.4.x kernel.
> > 
> > in context of LKSCTP, what could be the possible reasons that poll or
> > select on fd return false positive events, causing application do
> > write on fd but failed with EAGAIN ?
> I'm just guessing here... What if you can write something, but not
> something big as you try...
> So how big is the message you are trying so send?

That's possible, yes.

Another possibility (and I guess the only other one) is that you're
polling on a socket that has sndbuf available but you're sending a msg
to a peer that requires starting another assoc. If it fails to bind
while creating this new asoc during sendmsg, it will return EAGAIN too.
Like, you created a UDP-style socket, but didn't bind() nor connect(),
and called sendmsg() directly on it. Sendmsg() will do an indirect
bind() but somehow, you're out of ephemeral ports, or something else is
blocking it.

Best regards,
Marcelo

> 
> Best regards
> Michael
> > 
> > 
> > Best Regards,
> > Deepak
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SCTP getting EAGAIN but poll or select return socket is writable
  2017-04-11 19:14 SCTP getting EAGAIN but poll or select return socket is writable Michael Tuexen
  2017-04-11 19:20 ` Deepak Khandelwal
  2017-04-11 19:36 ` Marcelo Ricardo Leitner
@ 2017-04-11 20:36 ` Deepak Khandelwal
  2017-04-11 21:51 ` Marcelo Ricardo Leitner
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Deepak Khandelwal @ 2017-04-11 20:36 UTC (permalink / raw)
  To: linux-sctp

Hi,


App act as client (1-1 Style SOCK_STREAM)
App try to send 278 bytes of message.

So you mean that, if socket has space for few bytes (say 1 or 2
bytes), lksctp will set POLLOUT event for fd,
but since user application doesn;t know the underlying socket space
available, it can write more than that but will fail with EAGAIN ?


Best Regards,
Deepak

On Wed, Apr 12, 2017 at 12:44 AM, Michael Tuexen
<Michael.Tuexen@lurchi.franken.de> wrote:
>> On 11. Apr 2017, at 21:08, Deepak Khandelwal <dazz.87@gmail.com> wrote:
>>
>> Hi,
>>
>> I am using 4.4.x kernel.
>>
>> in context of LKSCTP, what could be the possible reasons that poll or
>> select on fd return false positive events, causing application do
>> write on fd but failed with EAGAIN ?
> I'm just guessing here... What if you can write something, but not
> something big as you try...
> So how big is the message you are trying so send?
>
> Best regards
> Michael
>>
>>
>> Best Regards,
>> Deepak
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SCTP getting EAGAIN but poll or select return socket is writable
  2017-04-11 19:14 SCTP getting EAGAIN but poll or select return socket is writable Michael Tuexen
                   ` (2 preceding siblings ...)
  2017-04-11 20:36 ` Deepak Khandelwal
@ 2017-04-11 21:51 ` Marcelo Ricardo Leitner
  2017-04-12  2:50 ` Deepak Khandelwal
  2017-04-12 11:56 ` Neil Horman
  5 siblings, 0 replies; 7+ messages in thread
From: Marcelo Ricardo Leitner @ 2017-04-11 21:51 UTC (permalink / raw)
  To: linux-sctp

On Wed, Apr 12, 2017 at 01:54:41AM +0530, Deepak Khandelwal wrote:
> Hi,
> 

Please don't top post..

> 
> App act as client (1-1 Style SOCK_STREAM)
> App try to send 278 bytes of message.

Okay.

> 
> So you mean that, if socket has space for few bytes (say 1 or 2
> bytes), lksctp will set POLLOUT event for fd,
> but since user application doesn;t know the underlying socket space
> available, it can write more than that but will fail with EAGAIN ?

Was reading the code again on this, I actually don't think this can
happen. The sleep on waiting for sndbuf doesn't check for msgsize, just
if there is any amount of buffer available or not.

sctp_sendmsg()
{
...
        timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
        if (!sctp_wspace(asoc)) {
                err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len);
                if (err)
                        goto out_free;
        }
...
}

For returning -EAGAIN due to sndbuf, it has to match !sctp_wspace, which
is only about the soc/asoc and not the message. The EAGAIN in this case
comes from inside sctp_wait_for_sndbuf().

That leads us to my other question, are you binding/connecting this
socket before sending the message?

> 
> 
> Best Regards,
> Deepak
> 
> On Wed, Apr 12, 2017 at 12:44 AM, Michael Tuexen
> <Michael.Tuexen@lurchi.franken.de> wrote:
> >> On 11. Apr 2017, at 21:08, Deepak Khandelwal <dazz.87@gmail.com> wrote:
> >>
> >> Hi,
> >>
> >> I am using 4.4.x kernel.
> >>
> >> in context of LKSCTP, what could be the possible reasons that poll or
> >> select on fd return false positive events, causing application do
> >> write on fd but failed with EAGAIN ?
> > I'm just guessing here... What if you can write something, but not
> > something big as you try...
> > So how big is the message you are trying so send?
> >
> > Best regards
> > Michael
> >>
> >>
> >> Best Regards,
> >> Deepak
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> >
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SCTP getting EAGAIN but poll or select return socket is writable
  2017-04-11 19:14 SCTP getting EAGAIN but poll or select return socket is writable Michael Tuexen
                   ` (3 preceding siblings ...)
  2017-04-11 21:51 ` Marcelo Ricardo Leitner
@ 2017-04-12  2:50 ` Deepak Khandelwal
  2017-04-12 11:56 ` Neil Horman
  5 siblings, 0 replies; 7+ messages in thread
From: Deepak Khandelwal @ 2017-04-12  2:50 UTC (permalink / raw)
  To: linux-sctp

On Wed, Apr 12, 2017 at 3:21 AM, Marcelo Ricardo Leitner
<marcelo.leitner@gmail.com> wrote:
> On Wed, Apr 12, 2017 at 01:54:41AM +0530, Deepak Khandelwal wrote:
>> Hi,
>>
>
> Please don't top post..
>
>>
>> App act as client (1-1 Style SOCK_STREAM)
>> App try to send 278 bytes of message.
>
> Okay.
>
>>
>> So you mean that, if socket has space for few bytes (say 1 or 2
>> bytes), lksctp will set POLLOUT event for fd,
>> but since user application doesn;t know the underlying socket space
>> available, it can write more than that but will fail with EAGAIN ?
>
> Was reading the code again on this, I actually don't think this can
> happen. The sleep on waiting for sndbuf doesn't check for msgsize, just
> if there is any amount of buffer available or not.
>
> sctp_sendmsg()
> {
> ...
>         timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
>         if (!sctp_wspace(asoc)) {
>                 err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len);
>                 if (err)
>                         goto out_free;
>         }
> ...
> }
>
> For returning -EAGAIN due to sndbuf, it has to match !sctp_wspace, which
> is only about the soc/asoc and not the message. The EAGAIN in this case
> comes from inside sctp_wait_for_sndbuf().
>

So then it means that message written to fd is over committed and not
honoring socket send buffer space limits ?
and now next time when APP does POLL, it will not return POLLOUT event
for the fd,
because now there will be negative buffer space, due to over commit last time.

so in all APP shouldn't have got this EAGAIN error anytime (due to
over commit allowed atmost once)



> That leads us to my other question, are you binding/connecting this
> socket before sending the message?
>


yes i am doing bind/connect and then checking pullout events returned
by poll on that fd, before sending the message or writing to that fd.


>>
>>
>> Best Regards,
>> Deepak
>>
>> On Wed, Apr 12, 2017 at 12:44 AM, Michael Tuexen
>> <Michael.Tuexen@lurchi.franken.de> wrote:
>> >> On 11. Apr 2017, at 21:08, Deepak Khandelwal <dazz.87@gmail.com> wrote:
>> >>
>> >> Hi,
>> >>
>> >> I am using 4.4.x kernel.
>> >>
>> >> in context of LKSCTP, what could be the possible reasons that poll or
>> >> select on fd return false positive events, causing application do
>> >> write on fd but failed with EAGAIN ?
>> > I'm just guessing here... What if you can write something, but not
>> > something big as you try...
>> > So how big is the message you are trying so send?
>> >
>> > Best regards
>> > Michael
>> >>
>> >>
>> >> Best Regards,
>> >> Deepak
>> >> --
>> >> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
>> >> the body of a message to majordomo@vger.kernel.org
>> >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> >
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: SCTP getting EAGAIN but poll or select return socket is writable
  2017-04-11 19:14 SCTP getting EAGAIN but poll or select return socket is writable Michael Tuexen
                   ` (4 preceding siblings ...)
  2017-04-12  2:50 ` Deepak Khandelwal
@ 2017-04-12 11:56 ` Neil Horman
  5 siblings, 0 replies; 7+ messages in thread
From: Neil Horman @ 2017-04-12 11:56 UTC (permalink / raw)
  To: linux-sctp

On Tue, Apr 11, 2017 at 06:51:06PM -0300, Marcelo Ricardo Leitner wrote:
> On Wed, Apr 12, 2017 at 01:54:41AM +0530, Deepak Khandelwal wrote:
> > Hi,
> > 
> 
> Please don't top post..
> 
> > 
> > App act as client (1-1 Style SOCK_STREAM)
> > App try to send 278 bytes of message.
> 
> Okay.
> 
> > 
> > So you mean that, if socket has space for few bytes (say 1 or 2
> > bytes), lksctp will set POLLOUT event for fd,
> > but since user application doesn;t know the underlying socket space
> > available, it can write more than that but will fail with EAGAIN ?
> 
> Was reading the code again on this, I actually don't think this can
> happen. The sleep on waiting for sndbuf doesn't check for msgsize, just
> if there is any amount of buffer available or not.
> 
> sctp_sendmsg()
> {
> ...
>         timeo = sock_sndtimeo(sk, msg->msg_flags & MSG_DONTWAIT);
>         if (!sctp_wspace(asoc)) {
>                 err = sctp_wait_for_sndbuf(asoc, &timeo, msg_len);
>                 if (err)
>                         goto out_free;
>         }
> ...
> }
> 
> For returning -EAGAIN due to sndbuf, it has to match !sctp_wspace, which
> is only about the soc/asoc and not the message. The EAGAIN in this case
> comes from inside sctp_wait_for_sndbuf().
> 
> That leads us to my other question, are you binding/connecting this
> socket before sending the message?
> 
This was my thought.  sctp_wait_for_sndbuf actually doesn't appear to be able to
return EAGAIN from my read.  The only place I see it getting retured from the
socket layer in the sctp codes sendmsg path is if the socket hasn't been bound
and autobind fails.

Neil

> > 
> > 
> > Best Regards,
> > Deepak
> > 
> > On Wed, Apr 12, 2017 at 12:44 AM, Michael Tuexen
> > <Michael.Tuexen@lurchi.franken.de> wrote:
> > >> On 11. Apr 2017, at 21:08, Deepak Khandelwal <dazz.87@gmail.com> wrote:
> > >>
> > >> Hi,
> > >>
> > >> I am using 4.4.x kernel.
> > >>
> > >> in context of LKSCTP, what could be the possible reasons that poll or
> > >> select on fd return false positive events, causing application do
> > >> write on fd but failed with EAGAIN ?
> > > I'm just guessing here... What if you can write something, but not
> > > something big as you try...
> > > So how big is the message you are trying so send?
> > >
> > > Best regards
> > > Michael
> > >>
> > >>
> > >> Best Regards,
> > >> Deepak
> > >> --
> > >> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> > >> the body of a message to majordomo@vger.kernel.org
> > >> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2017-04-12 11:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 19:14 SCTP getting EAGAIN but poll or select return socket is writable Michael Tuexen
2017-04-11 19:20 ` Deepak Khandelwal
2017-04-11 19:36 ` Marcelo Ricardo Leitner
2017-04-11 20:36 ` Deepak Khandelwal
2017-04-11 21:51 ` Marcelo Ricardo Leitner
2017-04-12  2:50 ` Deepak Khandelwal
2017-04-12 11:56 ` Neil Horman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.