From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCH iproute2 1/1] actions: Add support for user cookies Date: Thu, 23 Nov 2017 13:12:04 -0800 Message-ID: <20171123131204.30f2e55e@xeon-e3> References: <1492864583-20892-1-git-send-email-jhs@emojatatu.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org To: Jamal Hadi Salim Return-path: Received: from mail-pg0-f46.google.com ([74.125.83.46]:43042 "EHLO mail-pg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752150AbdKWVMG (ORCPT ); Thu, 23 Nov 2017 16:12:06 -0500 Received: by mail-pg0-f46.google.com with SMTP id r12so14423744pgu.10 for ; Thu, 23 Nov 2017 13:12:06 -0800 (PST) In-Reply-To: <1492864583-20892-1-git-send-email-jhs@emojatatu.com> Sender: netdev-owner@vger.kernel.org List-ID: On Sat, 22 Apr 2017 08:36:23 -0400 Jamal Hadi Salim wrote: > + > fprintf(f, "\tAction statistics:\n"); > print_tcstats2_attr(f, tb[TCA_ACT_STATS], "\t", NULL); > + if (tb[TCA_ACT_COOKIE]) { > + int strsz = RTA_PAYLOAD(tb[TCA_ACT_COOKIE]); > + char b1[strsz+1]; > + > + fprintf(f, "\n\tcookie len %d %s ", strsz, > + hexstring_n2a(RTA_DATA(tb[TCA_ACT_COOKIE]), > + strsz, b1, sizeof(b1))) I don't think you need to print len here. Already know that by the output of hexstring. Since payload length is in bytes and hex takes two characters per byte then the buffer needs to be bigger (like TCPCOOKIE_MAX_SIZE * 2 + 1)