From patchwork Fri Mar 22 14:10:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 1061226 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44QlvP4k3Wz9sRs for ; Sat, 23 Mar 2019 01:11:29 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728137AbfCVOLY (ORCPT ); Fri, 22 Mar 2019 10:11:24 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5172 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727746AbfCVOLY (ORCPT ); Fri, 22 Mar 2019 10:11:24 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id D0961248CE40E3374C06; Fri, 22 Mar 2019 22:11:20 +0800 (CST) Received: from [127.0.0.1] (10.184.189.20) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.408.0; Fri, 22 Mar 2019 22:11:11 +0800 From: linmiaohe Subject: [PATCH net] net: vrf: remove redundant vrf neigh entry To: David Ahern , Shrijeet Mukherjee , "David S. Miller" , , CC: Mingfangsen Message-ID: Date: Fri, 22 Mar 2019 22:10:35 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 Content-Language: en-US X-Originating-IP: [10.184.189.20] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Miaohe Lin When vrf->rth is created, it wouldn't change in his lifetime.And in func vrf_finish_output, we always create a neigh with ip_hdr(skb)->daddr as key because rth->rt_gateway is equal to 0. But I think we only need one vrf neigh entry because we strip the ethernet header and reset the dst_entry in vrf_process_v4_outbound. So I set rth->rt_gateway to loopback addr(It's ok to set any other valid ip address, just choose one.). And we would only create one vrf neigh entry. This helps saving some memory and improving the hitting rate of neigh lookup. If there is something I misunderstand, it's very nice of you to let me know. Thanks a lot. Signed-off-by: linmiaohe --- drivers/net/vrf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c index 7c1430ed0244..2b0227fb8f53 100644 --- a/drivers/net/vrf.c +++ b/drivers/net/vrf.c @@ -738,6 +738,7 @@ static int vrf_rtable_create(struct net_device *dev) return -ENOMEM; rth->dst.output = vrf_output; + rth->rt_gateway = htonl(INADDR_LOOPBACK); rcu_assign_pointer(vrf->rth, rth);