Message ID | 4F97A484.2040300@gmail.com |
---|---|
State | Changes Requested, archived |
Delegated to: | stephen hemminger |
Headers | show |
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. Nak, we should fix this in the kernel. It is ridiculous to have a convention that is true for one route attribute type but not for all of them. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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)