All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: xemul@parallels.com
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH 3/3] sock-diag: Report shutdown for inet and unix sockets
Date: Tue, 23 Oct 2012 13:42:36 -0400 (EDT)	[thread overview]
Message-ID: <20121023.134236.1262093514433122608.davem@davemloft.net> (raw)
In-Reply-To: <5086C5A6.7050101@parallels.com>

From: Pavel Emelyanov <xemul@parallels.com>
Date: Tue, 23 Oct 2012 20:28:22 +0400

> +static inline int shutdown_mask2u(int mask)
> +{
> +	/*
> +	 * map
> +	 * 	RCV_SHUTDOWN -> SHUT_RD
> +	 * 	SEND_SHUTDOWN -> SHUT_WR
> +	 * 	SHUTDOWN_MASK -> SHUT_RDWR
> +	 */
> +
> +	return mask - 1;
> +}

This is horrible.

You're returning "-1" when the socket hasn't been shutdown in any way.

Do this:

1) Use a '1' based encoding like the kernel codes so that '0' means
   no shutdown, as any sane interface would.  That's why we use that
   representation internally.

2) Get rid of all of this extension crap, and just report this value
   in the pad byte.  In older kernels it will just be zero, which is
   fine.

  parent reply	other threads:[~2012-10-23 17:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 16:18 [PATCH net-next 0/3] Report socket shutdown state via sock-diag Pavel Emelyanov
2012-10-23 16:22 ` [PATCH 1/3] sk: Introduce the shutdown user-to-mask routine Pavel Emelyanov
2012-10-23 16:26 ` [PATCH 2/3] inet-diag: Get more bits for extension flag Pavel Emelyanov
2012-10-23 16:28 ` [PATCH 3/3] sock-diag: Report shutdown for inet and unix sockets Pavel Emelyanov
2012-10-23 16:53   ` Eric Dumazet
2012-10-23 17:26     ` Pavel Emelyanov
2012-10-23 17:42   ` David Miller [this message]
2012-10-23 17:53     ` Pavel Emelyanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121023.134236.1262093514433122608.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=xemul@parallels.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.