From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,USER_AGENT_NEOMUTT 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 791CBC43381 for ; Thu, 28 Mar 2019 15:50:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FF3721773 for ; Thu, 28 Mar 2019 15:50:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="duYqlfox" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726430AbfC1Pug (ORCPT ); Thu, 28 Mar 2019 11:50:36 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:34754 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726185AbfC1Puf (ORCPT ); Thu, 28 Mar 2019 11:50:35 -0400 Received: by mail-pl1-f195.google.com with SMTP id y6so5158058plt.1 for ; Thu, 28 Mar 2019 08:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=r5ilWsbtH3wyozS/LgBTTeOWOmDmc9rJhYLxVqWbYnI=; b=duYqlfox4wqYQPpZ5tHlkbpKdqQMRf7OF1xPZG0AsFe3Kb38lMA+6wUWLxgeoMUJEa gOcxkzpl3PGdwv0uQwe1VraTnLlpxaHSSl7ckV6QPwk8kzjc/KzU6MvrE4NVTza1p8+y 9U9ngRP/k3Eo/xl5fxCmayjIX1qMWthclBK8/5167PzlPx/ymB4mvvskTDUxaqPooXnc wvfwS3MlVpf/T89udQVexAGcAJ83GAfGyVTyl1K2ww4IxsXUBSU6SOlUyByO+GUMYC66 ce82BpOEaz0Yp24wqHuY6rmPiHcfyBXmTDM2H9tcG6e7mMO9YOYtB9ZIiuzInKLxGBoF PzAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=r5ilWsbtH3wyozS/LgBTTeOWOmDmc9rJhYLxVqWbYnI=; b=KZPjXhzqEBO075jMN9eo88a1CKh3eASbKQ5D9Qon0f7ZlwcUjqBhCqpE6xhkYA6o01 qAwy1WyiyJjQn/+MFcpFFel5ZIQYfA6f9pI/Kn5meEDStMdct+Nbihs+yJfgUMBw65EX 8+he9PvDJCnxwTs461jJjl2AnT0FYThuQRutq+vm7VJoeD26qpElaZiupwIrFLCUonK6 fLSrSnqNuV9YfkeMmWqIVqHEe/vfRGu4IgHQEqZxLhcZBucKT3x6CjQ8AnS6M/pvI14X Fv4Rf8tPMhQHqpYfyvsQyW2ewOAdDR3AUIjat8zPBhhsyYR9BGiMcdkYDU9qgeZdeBtL ++JA== X-Gm-Message-State: APjAAAV7dBVlTeJNiBl/XU/CRZrL/57GIpMevV9abfj3l/IG4JXaNB/S OdyQqnX9VtQ9thOmg8C66Eg= X-Google-Smtp-Source: APXvYqxzCOQSEdb9H98oIiRSjZFyDWKMUfrXD1Ie65RHa2v7FCMZMJeuFgTdirnumWQ9ZARurvEvdw== X-Received: by 2002:a17:902:8506:: with SMTP id bj6mr43100836plb.60.1553788234713; Thu, 28 Mar 2019 08:50:34 -0700 (PDT) Received: from ast-mbp ([2620:10d:c090:180::4bd6]) by smtp.gmail.com with ESMTPSA id d2sm29964466pgg.47.2019.03.28.08.50.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Mar 2019 08:50:33 -0700 (PDT) Date: Thu, 28 Mar 2019 08:50:30 -0700 From: Alexei Starovoitov To: David Ahern Cc: davem@davemloft.net, netdev@vger.kernel.org, idosch@mellanox.com, jiri@mellanox.com, saeedm@mellanox.com, David Ahern Subject: Re: [PATCH v3 net-next 13/13] net: Use common nexthop init and release helpers Message-ID: <20190328155027.rm6zfeece7wlhn2i@ast-mbp> References: <20190328035358.4929-1-dsahern@kernel.org> <20190328035358.4929-14-dsahern@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190328035358.4929-14-dsahern@kernel.org> User-Agent: NeoMutt/20180223 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, Mar 27, 2019 at 08:53:58PM -0700, David Ahern wrote: > From: David Ahern > > With fib_nh_common in place, move common initialization and release > code into helpers used by both ipv4 and ipv6. For the moment, the init > is just the lwt encap and the release is both the netdev reference and > the the lwt state reference. More will be added later. > > Signed-off-by: David Ahern > --- > include/net/ip_fib.h | 4 ++++ > net/ipv4/fib_semantics.c | 60 +++++++++++++++++++++++++++++++----------------- > net/ipv6/route.c | 21 ++++------------- > 3 files changed, 48 insertions(+), 37 deletions(-) > > diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h > index 70548b1a6322..12a6d759cf57 100644 > --- a/include/net/ip_fib.h > +++ b/include/net/ip_fib.h > @@ -441,6 +441,10 @@ int fib_nh_init(struct net *net, struct fib_nh *fib_nh, > struct fib_config *cfg, int nh_weight, > struct netlink_ext_ack *extack); > void fib_nh_release(struct net *net, struct fib_nh *fib_nh); > +int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *fc_encap, > + u16 fc_encap_type, void *cfg, gfp_t gfp_flags, > + struct netlink_ext_ack *extack); > +void fib_nh_common_release(struct fib_nh_common *nhc); > > /* Exported by fib_trie.c */ > void fib_trie_init(void); > diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c > index e9992407863e..df777af7e278 100644 > --- a/net/ipv4/fib_semantics.c > +++ b/net/ipv4/fib_semantics.c > @@ -204,16 +204,22 @@ static void rt_fibinfo_free_cpus(struct rtable __rcu * __percpu *rtp) > free_percpu(rtp); > } > > +void fib_nh_common_release(struct fib_nh_common *nhc) > +{ > + if (nhc->nhc_dev) > + dev_put(nhc->nhc_dev); > + > + lwtstate_put(nhc->nhc_lwtstate); > +} > +EXPORT_SYMBOL_GPL(fib_nh_common_release); > + > void fib_nh_release(struct net *net, struct fib_nh *fib_nh) > { > #ifdef CONFIG_IP_ROUTE_CLASSID > if (fib_nh->nh_tclassid) > net->ipv4.fib_num_tclassid_users--; > #endif > - if (fib_nh->fib_nh_dev) > - dev_put(fib_nh->fib_nh_dev); > - > - lwtstate_put(fib_nh->fib_nh_lws); > + fib_nh_common_release(&fib_nh->nh_common); > free_nh_exceptions(fib_nh); > rt_fibinfo_free_cpus(fib_nh->nh_pcpu_rth_output); > rt_fibinfo_free(&fib_nh->nh_rth_input); > @@ -462,6 +468,30 @@ static int fib_detect_death(struct fib_info *fi, int order, > return 1; > } > > +int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *encap, > + u16 encap_type, void *cfg, gfp_t gfp_flags, > + struct netlink_ext_ack *extack) > +{ > + if (encap) { > + struct lwtunnel_state *lwtstate; > + int err; > + > + if (encap_type == LWTUNNEL_ENCAP_NONE) { > + NL_SET_ERR_MSG(extack, "LWT encap type not specified"); > + return -EINVAL; > + } > + err = lwtunnel_build_state(encap_type, encap, nhc->nhc_family, > + cfg, &lwtstate, extack); > + if (err) > + return err; > + > + nhc->nhc_lwtstate = lwtstate_get(lwtstate); > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(fib_nh_common_init); > + > int fib_nh_init(struct net *net, struct fib_nh *nh, > struct fib_config *cfg, int nh_weight, > struct netlink_ext_ack *extack) > @@ -474,22 +504,10 @@ int fib_nh_init(struct net *net, struct fib_nh *nh, > if (!nh->nh_pcpu_rth_output) > goto err_out; > > - if (cfg->fc_encap) { > - struct lwtunnel_state *lwtstate; > - > - err = -EINVAL; > - if (cfg->fc_encap_type == LWTUNNEL_ENCAP_NONE) { > - NL_SET_ERR_MSG(extack, "LWT encap type not specified"); > - goto lwt_failure; > - } > - err = lwtunnel_build_state(cfg->fc_encap_type, > - cfg->fc_encap, AF_INET, cfg, > - &lwtstate, extack); Init of nhc_family should have been part of this patch instead of previous one, but it's not a big deal. patch 5 isn't pretty still and you didn't answer my question why pointer to fib6_flags is worse than duplicated check. But it's ok to me in this shape, so for the set: Acked-by: Alexei Starovoitov