From patchwork Mon Dec 11 20:38:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Herbert X-Patchwork-Id: 847211 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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; dkim=pass (2048-bit key; unprotected) header.d=quantonium-net.20150623.gappssmtp.com header.i=@quantonium-net.20150623.gappssmtp.com header.b="PWdF+PS0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ywZYp4fHlz9sRm for ; Tue, 12 Dec 2017 07:39:10 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752506AbdLKUjI (ORCPT ); Mon, 11 Dec 2017 15:39:08 -0500 Received: from mail-pg0-f68.google.com ([74.125.83.68]:42425 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752479AbdLKUjE (ORCPT ); Mon, 11 Dec 2017 15:39:04 -0500 Received: by mail-pg0-f68.google.com with SMTP id e14so11752541pgr.9 for ; Mon, 11 Dec 2017 12:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantonium-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jo8jIUE/tFvyqeE43NOJWn0uMeIXkTrwbYkczfk/I4k=; b=PWdF+PS03ffk8jI19oJG2qz6jnycQokLUWl7kCKZhPcPsvVanXsjyT1I720FIjfeRL BpHL928MddQ0LIyM2vvn5XlQ3X7BgkxxW4qtwFzkFxGRRifkPa+cKVhkyYsqHLqVPBsK hUP0nWV1MTJQlpgV+XyeTD7Qw0k5aSjedwPuSiyPtfrqzm1wnHzOWtgDOYblNRfuYQxB 7AZzgW5ojmotRgC752JSBSdpvkGNrg9aH6lL+7+NUAv7tpO69QhnxGqYXqfS0oBwSpPt Jn8ZIf15Bcjstl9ImjNMxmSUa5iCLgC5/bRsVJWF1wsCnWSfEdtyVj1Nv/QtCiaHeW6m MDJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jo8jIUE/tFvyqeE43NOJWn0uMeIXkTrwbYkczfk/I4k=; b=dI8UIJkI4XpmMPkzr3E+S+/Oln+bdkO1SaXOsCPukiQvmHsDMpJaCa0Z7F+I18GObW JcBlkh2L+9Qs8iZrQNQjcvlx7fBTs468/ekdWXoAPNJDtmeeYDsBnaHY9Kb4e6nWD4D2 GmtmEMLNS38pINdEORoIrJy+nKryHX8SOIPS+sU9UPvPhljP5YBUO7MXOHYhAGwqKtCa Hkq5xLP5cwIcMua/AwgRdCXqWSIxAYFJKhPGxRzxpeS7G7Em3eCr14dqWWc4soi1b33p j/qeTFYXEmEr1C/3AFFGL9A7o7njQhvrymVm0ctiYe3tTQJkV+jBmUJIHanlJQGUSK0b u6YA== X-Gm-Message-State: AKGB3mJDwSTzo+x3Yb3JRxaLw8t8hbyDnPpktkcjp1hd0D3kfecogMeV 35NV8J2czgnGWOjhxtlsyDsecQ== X-Google-Smtp-Source: ACJfBovUBXPorOXdnpwPBvk0Yv9SJh9IKxrcvrUwkz3aNowkhTzI1kv7DgTX7TkhBB5nh7I4oQJxxQ== X-Received: by 10.99.3.146 with SMTP id 140mr1373956pgd.275.1513024743213; Mon, 11 Dec 2017 12:39:03 -0800 (PST) Received: from localhost.localdomain (67-207-98-108.static.wiline.com. [67.207.98.108]) by smtp.gmail.com with ESMTPSA id t6sm26426790pfl.76.2017.12.11.12.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 12:39:02 -0800 (PST) From: Tom Herbert To: davem@davemloft.net Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com, rohit@quantonium.net, Tom Herbert Subject: [PATCH v3 net-next 1/9] lwt: Add net to build_state argument Date: Mon, 11 Dec 2017 12:38:29 -0800 Message-Id: <20171211203837.2540-2-tom@quantonium.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171211203837.2540-1-tom@quantonium.net> References: <20171211203837.2540-1-tom@quantonium.net> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Users of LWT need to know net if they want to have per net operations in LWT. Signed-off-by: Tom Herbert --- include/net/lwtunnel.h | 6 +++--- net/core/lwt_bpf.c | 2 +- net/core/lwtunnel.c | 4 ++-- net/ipv4/fib_semantics.c | 13 ++++++++----- net/ipv4/ip_tunnel_core.c | 4 ++-- net/ipv6/ila/ila_lwt.c | 2 +- net/ipv6/route.c | 2 +- net/ipv6/seg6_iptunnel.c | 2 +- net/ipv6/seg6_local.c | 5 +++-- net/mpls/mpls_iptunnel.c | 2 +- 10 files changed, 23 insertions(+), 19 deletions(-) diff --git a/include/net/lwtunnel.h b/include/net/lwtunnel.h index d747ef975cd8..da5e51e0d122 100644 --- a/include/net/lwtunnel.h +++ b/include/net/lwtunnel.h @@ -34,7 +34,7 @@ struct lwtunnel_state { }; struct lwtunnel_encap_ops { - int (*build_state)(struct nlattr *encap, + int (*build_state)(struct net *net, struct nlattr *encap, unsigned int family, const void *cfg, struct lwtunnel_state **ts, struct netlink_ext_ack *extack); @@ -113,7 +113,7 @@ int lwtunnel_valid_encap_type(u16 encap_type, struct netlink_ext_ack *extack); int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len, struct netlink_ext_ack *extack); -int lwtunnel_build_state(u16 encap_type, +int lwtunnel_build_state(struct net *net, u16 encap_type, struct nlattr *encap, unsigned int family, const void *cfg, struct lwtunnel_state **lws, @@ -192,7 +192,7 @@ static inline int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len, return 0; } -static inline int lwtunnel_build_state(u16 encap_type, +static inline int lwtunnel_build_state(struct net *net, u16 encap_type, struct nlattr *encap, unsigned int family, const void *cfg, struct lwtunnel_state **lws, diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c index e7e626fb87bb..3a3ac13fcf06 100644 --- a/net/core/lwt_bpf.c +++ b/net/core/lwt_bpf.c @@ -238,7 +238,7 @@ static const struct nla_policy bpf_nl_policy[LWT_BPF_MAX + 1] = { [LWT_BPF_XMIT_HEADROOM] = { .type = NLA_U32 }, }; -static int bpf_build_state(struct nlattr *nla, +static int bpf_build_state(struct net *net, struct nlattr *nla, unsigned int family, const void *cfg, struct lwtunnel_state **ts, struct netlink_ext_ack *extack) diff --git a/net/core/lwtunnel.c b/net/core/lwtunnel.c index 0b171756453c..b3f2f77dfe72 100644 --- a/net/core/lwtunnel.c +++ b/net/core/lwtunnel.c @@ -103,7 +103,7 @@ int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *ops, } EXPORT_SYMBOL_GPL(lwtunnel_encap_del_ops); -int lwtunnel_build_state(u16 encap_type, +int lwtunnel_build_state(struct net *net, u16 encap_type, struct nlattr *encap, unsigned int family, const void *cfg, struct lwtunnel_state **lws, struct netlink_ext_ack *extack) @@ -124,7 +124,7 @@ int lwtunnel_build_state(u16 encap_type, ops = rcu_dereference(lwtun_encaps[encap_type]); if (likely(ops && ops->build_state && try_module_get(ops->owner))) { found = true; - ret = ops->build_state(encap, family, cfg, lws, extack); + ret = ops->build_state(net, encap, family, cfg, lws, extack); if (ret) module_put(ops->owner); } diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index f04d944f8abe..4979e5c6b9b8 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c @@ -523,6 +523,7 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, if (nla) { struct lwtunnel_state *lwtstate; struct nlattr *nla_entype; + struct net *net = cfg->fc_nlinfo.nl_net; nla_entype = nla_find(attrs, attrlen, RTA_ENCAP_TYPE); @@ -533,7 +534,7 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, goto err_inval; } - ret = lwtunnel_build_state(nla_get_u16( + ret = lwtunnel_build_state(net, nla_get_u16( nla_entype), nla, AF_INET, cfg, &lwtstate, extack); @@ -607,7 +608,7 @@ static void fib_rebalance(struct fib_info *fi) #endif /* CONFIG_IP_ROUTE_MULTIPATH */ -static int fib_encap_match(u16 encap_type, +static int fib_encap_match(struct net *net, u16 encap_type, struct nlattr *encap, const struct fib_nh *nh, const struct fib_config *cfg, @@ -619,7 +620,7 @@ static int fib_encap_match(u16 encap_type, if (encap_type == LWTUNNEL_ENCAP_NONE) return 0; - ret = lwtunnel_build_state(encap_type, encap, AF_INET, + ret = lwtunnel_build_state(net, encap_type, encap, AF_INET, cfg, &lwtstate, extack); if (!ret) { result = lwtunnel_cmp_encap(lwtstate, nh->nh_lwtstate); @@ -632,6 +633,7 @@ static int fib_encap_match(u16 encap_type, int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, struct netlink_ext_ack *extack) { + struct net *net = cfg->fc_nlinfo.nl_net; #ifdef CONFIG_IP_ROUTE_MULTIPATH struct rtnexthop *rtnh; int remaining; @@ -642,7 +644,8 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi, if (cfg->fc_oif || cfg->fc_gw) { if (cfg->fc_encap) { - if (fib_encap_match(cfg->fc_encap_type, cfg->fc_encap, + if (fib_encap_match(net, cfg->fc_encap_type, + cfg->fc_encap, fi->fib_nh, cfg, extack)) return 1; } @@ -1180,7 +1183,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg, "LWT encap type not specified"); goto err_inval; } - err = lwtunnel_build_state(cfg->fc_encap_type, + err = lwtunnel_build_state(net, cfg->fc_encap_type, cfg->fc_encap, AF_INET, cfg, &lwtstate, extack); if (err) diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c index 2f39479be92f..32e05aa6117d 100644 --- a/net/ipv4/ip_tunnel_core.c +++ b/net/ipv4/ip_tunnel_core.c @@ -228,7 +228,7 @@ static const struct nla_policy ip_tun_policy[LWTUNNEL_IP_MAX + 1] = { [LWTUNNEL_IP_FLAGS] = { .type = NLA_U16 }, }; -static int ip_tun_build_state(struct nlattr *attr, +static int ip_tun_build_state(struct net *net, struct nlattr *attr, unsigned int family, const void *cfg, struct lwtunnel_state **ts, struct netlink_ext_ack *extack) @@ -327,7 +327,7 @@ static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = { [LWTUNNEL_IP6_FLAGS] = { .type = NLA_U16 }, }; -static int ip6_tun_build_state(struct nlattr *attr, +static int ip6_tun_build_state(struct net *net, struct nlattr *attr, unsigned int family, const void *cfg, struct lwtunnel_state **ts, struct netlink_ext_ack *extack) diff --git a/net/ipv6/ila/ila_lwt.c b/net/ipv6/ila/ila_lwt.c index 3d56a2fb6f86..9f1e46a1468e 100644 --- a/net/ipv6/ila/ila_lwt.c +++ b/net/ipv6/ila/ila_lwt.c @@ -125,7 +125,7 @@ static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = { [ILA_ATTR_HOOK_TYPE] = { .type = NLA_U8, }, }; -static int ila_build_state(struct nlattr *nla, +static int ila_build_state(struct net *net, struct nlattr *nla, unsigned int family, const void *cfg, struct lwtunnel_state **ts, struct netlink_ext_ack *extack) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index b3f4d19b3ca5..0e0cc97e8f42 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -2565,7 +2565,7 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg, if (cfg->fc_encap) { struct lwtunnel_state *lwtstate; - err = lwtunnel_build_state(cfg->fc_encap_type, + err = lwtunnel_build_state(net, cfg->fc_encap_type, cfg->fc_encap, AF_INET6, cfg, &lwtstate, extack); if (err) diff --git a/net/ipv6/seg6_iptunnel.c b/net/ipv6/seg6_iptunnel.c index bd6cc688bd19..a6cf2fba15f3 100644 --- a/net/ipv6/seg6_iptunnel.c +++ b/net/ipv6/seg6_iptunnel.c @@ -359,7 +359,7 @@ static int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb) return err; } -static int seg6_build_state(struct nlattr *nla, +static int seg6_build_state(struct net *net, struct nlattr *nla, unsigned int family, const void *cfg, struct lwtunnel_state **ts, struct netlink_ext_ack *extack) diff --git a/net/ipv6/seg6_local.c b/net/ipv6/seg6_local.c index 825b8e01f947..45dc670c5a93 100644 --- a/net/ipv6/seg6_local.c +++ b/net/ipv6/seg6_local.c @@ -779,8 +779,9 @@ static int parse_nla_action(struct nlattr **attrs, struct seg6_local_lwt *slwt) return 0; } -static int seg6_local_build_state(struct nlattr *nla, unsigned int family, - const void *cfg, struct lwtunnel_state **ts, +static int seg6_local_build_state(struct net *net, struct nlattr *nla, + unsigned int family, const void *cfg, + struct lwtunnel_state **ts, struct netlink_ext_ack *extack) { struct nlattr *tb[SEG6_LOCAL_MAX + 1]; diff --git a/net/mpls/mpls_iptunnel.c b/net/mpls/mpls_iptunnel.c index 6e558a419f60..c947310cc04f 100644 --- a/net/mpls/mpls_iptunnel.c +++ b/net/mpls/mpls_iptunnel.c @@ -157,7 +157,7 @@ static int mpls_xmit(struct sk_buff *skb) return -EINVAL; } -static int mpls_build_state(struct nlattr *nla, +static int mpls_build_state(struct net *net, struct nlattr *nla, unsigned int family, const void *cfg, struct lwtunnel_state **ts, struct netlink_ext_ack *extack)