All of lore.kernel.org
 help / color / mirror / Atom feed
* LTP recv/recvmsg tests failing on 3.17
@ 2014-09-23 14:11 Chuck Ebbert
  2014-09-23 14:57 ` Willem de Bruijn
  0 siblings, 1 reply; 5+ messages in thread
From: Chuck Ebbert @ 2014-09-23 14:11 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: netdev

LTP tests recv01, recvfrom01 and recvmsg01 are reporting failure on
their "invalid flags" tests on 3.17. They pass a value of -1 for flags
and expect to get EINVAL back, but now they get EAGAIN. It looks like
this is due to:

commit 4ed2d765dfaccff5ebdac68e2064b59125033a3b
Author: Willem de Bruijn <willemb@google.com>
Date:   Mon Aug 4 22:11:49 2014 -0400

    net-timestamp: TCP timestamping

which adds this hunk to net/ipv4/tcp.c:

@@ -1617,6 +1630,9 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
        struct sk_buff *skb;
        u32 urg_hole = 0;
 
+       if (unlikely(flags & MSG_ERRQUEUE))
+               return ip_recv_error(sk, msg, len, addr_len);
+
        if (sk_can_busy_loop(sk) && skb_queue_empty(&sk->sk_receive_queue) &&
            (sk->sk_state == TCP_ESTABLISHED))
                sk_busy_loop(sk, nonblock);

Before this change, the first flag tested was MSG_OOB, which eventually
causes EINVAL to be returned. Now this flag gets tested first, and
ip_recv_err() returns EAGAIN.

LTP setting every flag and expecting behavior to remain unchanged is
probably wrong, but is EAGAIN correct here? I can't find any spec for
this.

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

* Re: LTP recv/recvmsg tests failing on 3.17
  2014-09-23 14:11 LTP recv/recvmsg tests failing on 3.17 Chuck Ebbert
@ 2014-09-23 14:57 ` Willem de Bruijn
  2014-09-23 15:39   ` Chuck Ebbert
  2014-09-23 15:59   ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Willem de Bruijn @ 2014-09-23 14:57 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: Network Development

On Tue, Sep 23, 2014 at 10:11 AM, Chuck Ebbert <cebbert.lkml@gmail.com> wrote:
> LTP tests recv01, recvfrom01 and recvmsg01 are reporting failure on
> their "invalid flags" tests on 3.17. They pass a value of -1 for flags
> and expect to get EINVAL back, but now they get EAGAIN.
..
>
> Before this change, the first flag tested was MSG_OOB, which eventually
> causes EINVAL to be returned. Now this flag gets tested first, and
> ip_recv_err() returns EAGAIN.
>
> LTP setting every flag and expecting behavior to remain unchanged is
> probably wrong, but is EAGAIN correct here? I can't find any spec for
> this.

EINVAL does seem a suitable return value for invalid
combinations of flags, if those are explicitly checked. The
stack does not do this, though. Most flags are simply
ignored. For backward compatibility, this leniency is
likely required.

Previously, EINVAL was returned, but not  because msg_flags
contained an unsupported combination. MSG_OOB happened
to be the first tested flag in the set and happens to return
EINVAL when no urgent data is waiting.

I think applications simply cannot assume a consistent
return value when passing unsupported combinations
of flags. This is undefined behavior.

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

* Re: LTP recv/recvmsg tests failing on 3.17
  2014-09-23 14:57 ` Willem de Bruijn
@ 2014-09-23 15:39   ` Chuck Ebbert
  2014-09-23 16:24     ` Willem de Bruijn
  2014-09-23 15:59   ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Chuck Ebbert @ 2014-09-23 15:39 UTC (permalink / raw)
  To: Willem de Bruijn; +Cc: Network Development

On Tue, 23 Sep 2014 10:57:41 -0400
Willem de Bruijn <willemb@google.com> wrote:

> I think applications simply cannot assume a consistent
> return value when passing unsupported combinations
> of flags. This is undefined behavior.

Yeah, I think LTP is wrong here. There is no explicit test for invalid
combinations of flags and it was assuming there was.

But I was also wondering why we return EAGAIN here for no data waiting,
when we return EINVAL for the same case with a different type of data.
There's no spec and it's not documented, so I guess the answer is "it's
always been that way."

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

* Re: LTP recv/recvmsg tests failing on 3.17
  2014-09-23 14:57 ` Willem de Bruijn
  2014-09-23 15:39   ` Chuck Ebbert
@ 2014-09-23 15:59   ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2014-09-23 15:59 UTC (permalink / raw)
  To: willemb; +Cc: cebbert.lkml, netdev

From: Willem de Bruijn <willemb@google.com>
Date: Tue, 23 Sep 2014 10:57:41 -0400

> I think applications simply cannot assume a consistent
> return value when passing unsupported combinations
> of flags. This is undefined behavior.

Agreed.

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

* Re: LTP recv/recvmsg tests failing on 3.17
  2014-09-23 15:39   ` Chuck Ebbert
@ 2014-09-23 16:24     ` Willem de Bruijn
  0 siblings, 0 replies; 5+ messages in thread
From: Willem de Bruijn @ 2014-09-23 16:24 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: Network Development

> But I was also wondering why we return EAGAIN here for no data waiting,
> when we return EINVAL for the same case with a different type of data.
> There's no spec and it's not documented, so I guess the answer is "it's
> always been that way."

EAGAIN is the common response. I don't know why TCP urgent
data returns EINVAL. It is unusual enough that the relevant line
in tcp_recv_urg explicitly comments on it:

                return -EINVAL; /* Yes this is right ! */

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

end of thread, other threads:[~2014-09-23 16:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-23 14:11 LTP recv/recvmsg tests failing on 3.17 Chuck Ebbert
2014-09-23 14:57 ` Willem de Bruijn
2014-09-23 15:39   ` Chuck Ebbert
2014-09-23 16:24     ` Willem de Bruijn
2014-09-23 15:59   ` David Miller

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.