From patchwork Mon Oct 26 02:21:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Qilong X-Patchwork-Id: 288124 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5BB15C4363A for ; Mon, 26 Oct 2020 02:10:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1AB362222C for ; Mon, 26 Oct 2020 02:10:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1421355AbgJZCKs (ORCPT ); Sun, 25 Oct 2020 22:10:48 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2564 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1421350AbgJZCKr (ORCPT ); Sun, 25 Oct 2020 22:10:47 -0400 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CKJGL6hvYzhbtq; Mon, 26 Oct 2020 10:10:50 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Mon, 26 Oct 2020 10:10:41 +0800 From: Zhang Qilong To: , , , CC: , , Subject: [PATCH v2 -next] neigh: Adjustment calculation method of neighbour path symbols Date: Mon, 26 Oct 2020 10:21:26 +0800 Message-ID: <20201026022126.117741-1-zhangqilong3@huawei.com> X-Mailer: git-send-email 2.26.0.106.g9fadedd MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Using size of "net//neigh/" is not clear, the use of stitching("net/" + /neigh") should be clearer. Signed-off-by: Zhang Qilong --- net/core/neighbour.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 8e39e28b0a8d..0474e73c4f9f 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c @@ -3623,7 +3623,14 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, int i; struct neigh_sysctl_table *t; const char *dev_name_source; - char neigh_path[ sizeof("net//neigh/") + IFNAMSIZ + IFNAMSIZ ]; + + /* + * The path pattern is as follows + * "net/%s/neigh/%s", minusing one + * is for unnecessary terminators. + */ + char neigh_path[sizeof("net/") - 1 + IFNAMSIZ + + sizeof("/neigh/") + IFNAMSIZ]; char *p_name; t = kmemdup(&neigh_sysctl_template, sizeof(*t), GFP_KERNEL);