{"id":815964,"url":"http://patchwork.ozlabs.org/api/covers/815964/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/cover/1505871820-31580-1-git-send-email-liuhangbin@gmail.com/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<1505871820-31580-1-git-send-email-liuhangbin@gmail.com>","list_archive_url":null,"date":"2017-09-20T01:43:38","name":"[PATCHv3,iproute2,0/2] libnetlink: malloc correct buff at run time","submitter":{"id":15639,"url":"http://patchwork.ozlabs.org/api/people/15639/?format=json","name":"Hangbin Liu","email":"liuhangbin@gmail.com"},"mbox":"http://patchwork.ozlabs.org/project/netdev/cover/1505871820-31580-1-git-send-email-liuhangbin@gmail.com/mbox/","series":[{"id":4000,"url":"http://patchwork.ozlabs.org/api/series/4000/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=4000","date":"2017-09-20T01:43:38","name":"libnetlink: malloc correct buff at run time","version":1,"mbox":"http://patchwork.ozlabs.org/series/4000/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/covers/815964/comments/","headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"PbfctYjy\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xxjG548gCz9s8J\n\tfor <patchwork-incoming@ozlabs.org>;\n\tWed, 20 Sep 2017 11:44:13 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751549AbdITBoK (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tTue, 19 Sep 2017 21:44:10 -0400","from mail-pg0-f65.google.com ([74.125.83.65]:34966 \"EHLO\n\tmail-pg0-f65.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751000AbdITBoG (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Tue, 19 Sep 2017 21:44:06 -0400","by mail-pg0-f65.google.com with SMTP id j16so789613pga.2\n\tfor <netdev@vger.kernel.org>; Tue, 19 Sep 2017 18:44:05 -0700 (PDT)","from leo.usersys.redhat.com ([209.132.188.80])\n\tby smtp.gmail.com with ESMTPSA id\n\tq23sm5070313pfk.182.2017.09.19.18.44.02\n\t(version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);\n\tTue, 19 Sep 2017 18:44:04 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id;\n\tbh=gptnp0ssEbJUEIJZyt7tDvCZDRc3RZ8BVQkIjw91Eh4=;\n\tb=PbfctYjyD/AKcqeZ3On5d5k9adSScihyGir9uNBIb8QkQ5XTZXdTrrEJSx66gBuiVs\n\tgm5CL8dl4mktqu1XHRlHf4wOjbTn5fH8o7h8Tun4k9vacA2fNHBnR4MrrCwp+KLcpLfo\n\t2GfpJB5GNMC59Fn4XtElEtpXdefF9tzrDjKCvLNwdf3qga72rACbAHvl+6aXdizyY3Gv\n\t1vkuabX0yeoNDxsQtA6bWdSXJr9HsusRQCt5WxGwExAjG8+WQdeY97juS9OlSypnllL9\n\tXlNd37IS5Qd9hz9MEvyVbod4ZT0Ck57Rm9zlwny6yrfKus8kMduA0f/HW+V9dgAMeAEE\n\tbJNA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id;\n\tbh=gptnp0ssEbJUEIJZyt7tDvCZDRc3RZ8BVQkIjw91Eh4=;\n\tb=FWwCifOs5S+xwEZ/YQYS4oNplnCNVZ+99FBFd6cK73sCiWCwrOkjF5GiROEl5nZKOR\n\tXsPx83ncd3zNSNnmwtn3MVM1CM6AOzhIzBZs2IbIF0ju8wqZWrET9MoWwVcoBQ1kTY+B\n\t8gs6zlFPZtZKM6FzqwV+yhwy6rUdCAxogGVQZtAw4Y+ABI8/+xjGo0nuMxL6PVoarFve\n\tSMFb6A3gkbuGcDUhdfGn2JQvaUkG6hSAXju2xkMSYD6wFMGWxLUY0+yXyNGANSZ915PI\n\t2bTGXnN3oYbUuVvCVuE4xo9Xapyv42r+mVqhLFdpLxaTW9eJFvQW7AGODMBZw5jrb0m4\n\t0r7Q==","X-Gm-Message-State":"AHPjjUgCnlkXw+jTs5lRHff0zrXmkWU544gAjZq4NIsk9TEvYk+TA6uP\n\ts4F2ezUz/wSrlyy2jLxrmzPRSQ==","X-Google-Smtp-Source":"AOwi7QAHnKlwzY2bwLjW7mM9kblMXhDJuiuJkrJY9MS4htXdme9XZQJp4XOhfMt7UXHyspQVeQ52nQ==","X-Received":"by 10.98.72.83 with SMTP id v80mr551945pfa.54.1505871845476;\n\tTue, 19 Sep 2017 18:44:05 -0700 (PDT)","From":"Hangbin Liu <liuhangbin@gmail.com>","To":"netdev@vger.kernel.org","Cc":"Stephen Hemminger <stephen@networkplumber.org>,\n\tMichal Kubecek <mkubecek@suse.cz>, Phil Sutter <phil@nwl.cc>,\n\tHangbin Liu <liuhangbin@gmail.com>","Subject":"[PATCHv3 iproute2 0/2] libnetlink: malloc correct buff at run time","Date":"Wed, 20 Sep 2017 09:43:38 +0800","Message-Id":"<1505871820-31580-1-git-send-email-liuhangbin@gmail.com>","X-Mailer":"git-send-email 2.5.5","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"With commit 72b365e8e0fd (\"libnetlink: Double the dump buffer size\") and\n460c03f3f3cc (\"iplink: double the buffer size also in iplink_get()\"), we\nextend the buffer size to avoid truncated message with large numbers of\nVFs. But just as Michal said, this is not future-proof since the NIC\nnumber is increasing. We have customer even has 220+ VFs now.\n\nThis is not make sense to hard code the buffer and increase it all the time.\nSo let's just malloc the correct buff size at run time.\n\nTested with most ip cmds and all look good.\n\n---\nv2 -> v3:\n* rtnl_recvmsg():\n  * free buf before each return.\n  * return errno when recvmsg failed.\nv1 -> v2 by Phil:\n* rtnl_recvmsg():\n  * Rename output buffer pointer arg to 'answer'.\n  * Use realloc() and make sure old buffer is freed on error.\n  * Always return a newly allocated buffer for caller to free.\n  * Retry on EINTR or EAGAIN so caller doesn't have to.\n  * Return well-known negative error codes instead of just -1 on error.\n  * Simplify goto label names.\n  * If no answer pointer was passed, just free the buffer.\n* rtnl_dump_filter_l():\n  * Don't retry if rtnl_recvmsg() returns 0 as this can't happen\n    anymore.\n  * Free buffer returned by rtnl_recvmsg().\n* __rtnl_talk():\n  * Don't retry if rtnl_recvmsg() returns 0 as this can't happen\n    anymore.\n  * Free buffer returned by rtnl_recvmsg().\n  * Return a newly allocated buffer for callers to free.\n* genl_ctrl_resolve_family()\n  * Replace 'ghdr + GENL_HDRLEN' to 'answer + NLMSG_LENGTH(GENL_HDRLEN)'\n* tc_action_gd()\n  * Call print_action() only if cmd == RTM_GETACTION\n* Change callers of rtnl_talk*() to always free the answer buffer if\n  they passed one.\n* Drop extra request buffer space in callers if only used for holding\n  output data.\n* Drop initialization of answer pointer if not necessary.\n* Change callers to pass NULL instead of answer pointer if they don't\n  use it afterwards.\n\n\nHangbin Liu (2):\n  lib/libnetlink: re malloc buff if size is not enough\n  lib/libnetlink: update rtnl_talk to support malloc buff at run time\n\n bridge/fdb.c         |   2 +-\n bridge/link.c        |   2 +-\n bridge/mdb.c         |   2 +-\n bridge/vlan.c        |   2 +-\n genl/ctrl.c          |  19 +++++---\n include/libnetlink.h |   6 +--\n ip/ipaddress.c       |   4 +-\n ip/ipaddrlabel.c     |   4 +-\n ip/ipfou.c           |   4 +-\n ip/ipila.c           |   4 +-\n ip/ipl2tp.c          |   8 +--\n ip/iplink.c          |  38 +++++++--------\n ip/iplink_vrf.c      |  44 ++++++++---------\n ip/ipmacsec.c        |   2 +-\n ip/ipneigh.c         |   2 +-\n ip/ipnetns.c         |  23 +++++----\n ip/ipntable.c        |   2 +-\n ip/iproute.c         |  26 ++++++----\n ip/iprule.c          |   6 +--\n ip/ipseg6.c          |   8 +--\n ip/iptoken.c         |   2 +-\n ip/link_gre.c        |  11 +++--\n ip/link_gre6.c       |  11 +++--\n ip/link_ip6tnl.c     |  11 +++--\n ip/link_iptnl.c      |  10 ++--\n ip/link_vti.c        |  11 +++--\n ip/link_vti6.c       |  11 +++--\n ip/tcp_metrics.c     |   8 +--\n ip/xfrm_policy.c     |  25 +++++-----\n ip/xfrm_state.c      |  30 ++++++------\n lib/libgenl.c        |   9 +++-\n lib/libnetlink.c     | 134 ++++++++++++++++++++++++++++++++++-----------------\n misc/ss.c            |   2 +-\n tc/m_action.c        |  12 ++---\n tc/tc_class.c        |   2 +-\n tc/tc_filter.c       |   8 +--\n tc/tc_qdisc.c        |   2 +-\n 37 files changed, 298 insertions(+), 209 deletions(-)"}