public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta•com>
To: Shan Wei <shanwei88@gmail•com>
Cc: xemul@parallels•com, NetDev <netdev@vger•kernel.org>
Subject: Re: [PATCH 1/2] ss: fix the incorrect value of total UNIX_DIAG_* number
Date: Wed, 25 Apr 2012 13:21:26 -0700	[thread overview]
Message-ID: <20120425132126.6859f1be@nehalam.linuxnetplumber.net> (raw)
In-Reply-To: <4F97A484.2040300@gmail.com>

On Wed, 25 Apr 2012 15:15:16 +0800
Shan Wei <shanwei88@gmail•com> wrote:

> From: Shan Wei <davidshan@tencent•com>
> 
> UNIX_DIAG_MAX is included in enum type.
> It is equal to the total number of enum element.
> 
> But lots of enum MAX value is defined as the max enum element, e.g. INET_DIAG_MAX, XFRMA_MAX. 
> The right fixing way seems to define UNIX_DIAG_MAX as UNIX_DIAG_MEMINFO,
> but this way will break other user application.
> 
> So, just fix it on user application.
> 
> 
> Signed-off-by: Shan Wei <davidshan@tencent•com>
> ---
>  misc/ss.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/misc/ss.c b/misc/ss.c
> index 4017918..5f70a26 100644
> --- a/misc/ss.c
> +++ b/misc/ss.c
> @@ -2011,12 +2011,12 @@ void unix_list_print(struct unixstat *list, struct filter *f)
>  static int unix_show_sock(struct nlmsghdr *nlh, struct filter *f)
>  {
>  	struct unix_diag_msg *r = NLMSG_DATA(nlh);
> -	struct rtattr *tb[UNIX_DIAG_MAX+1];
> +	struct rtattr *tb[UNIX_DIAG_MAX];
>  	char name[128];
>  	int peer_ino;
>  	int rqlen;
>  
> -	parse_rtattr(tb, UNIX_DIAG_MAX, (struct rtattr*)(r+1),
> +	parse_rtattr(tb, UNIX_DIAG_MAX-1, (struct rtattr*)(r+1),
>  		     nlh->nlmsg_len - NLMSG_LENGTH(sizeof(*r)));
>  
>  	if (netid_width)

Ok, I'll put this in but with a big juicy comment so that nobody
else is surprised by the fact we got it wrong here.

      parent reply	other threads:[~2012-04-25 20:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-25  7:15 [PATCH 1/2] ss: fix the incorrect value of total UNIX_DIAG_* number Shan Wei
2012-04-25 16:26 ` Stephen Hemminger
2012-04-25 17:38   ` [PATCH] unix_diag: use netlink attribute MAX convention Stephen Hemminger
2012-04-25 18:16     ` David Miller
2012-04-25 18:56       ` Stephen Hemminger
2012-04-25 19:07         ` David Miller
2012-04-25 19:47           ` Stephen Hemminger
2012-04-25 19:57             ` David Miller
2012-04-25 20:09               ` Stephen Hemminger
2012-04-25 20:12                 ` David Miller
2012-04-25 20:21 ` Stephen Hemminger [this message]

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=20120425132126.6859f1be@nehalam.linuxnetplumber.net \
    --to=shemminger@vyatta$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=shanwei88@gmail$(echo .)com \
    --cc=xemul@parallels$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox