]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
net: add net available in build_state
authorAlexander Aring <alex.aring@gmail.com>
Fri, 27 Mar 2020 22:00:21 +0000 (18:00 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 30 Mar 2020 05:30:57 +0000 (22:30 -0700)
The build_state callback of lwtunnel doesn't contain the net namespace
structure yet. This patch will add it so we can check on specific
address configuration at creation time of rpl source routes.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
13 files changed:
include/net/ip_fib.h
include/net/lwtunnel.h
net/core/lwt_bpf.c
net/core/lwtunnel.c
net/ipv4/fib_lookup.h
net/ipv4/fib_semantics.c
net/ipv4/fib_trie.c
net/ipv4/ip_tunnel_core.c
net/ipv6/ila/ila_lwt.c
net/ipv6/route.c
net/ipv6/seg6_iptunnel.c
net/ipv6/seg6_local.c
net/mpls/mpls_iptunnel.c

index dabe398bee4c6840574e86c2a30f1d321c0a6392..59e0d4e99f94e70325e477456ed251dcf0e04b47 100644 (file)
@@ -470,8 +470,9 @@ 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,
+int fib_nh_common_init(struct net *net, 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);
 
index b5e6edf74b70ba402b7bd6b12024ed31ada1d2f2..05cfd6ff65287e51dbfd5c05b4c2a0a8a45d6d6a 100644 (file)
@@ -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,
@@ -209,7 +209,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,
index 99a6de52b21da02f8c338d21ed21e636afbd7918..7d3438215f32c4311ec17f8fef0b2eca3289ce8d 100644 (file)
@@ -367,7 +367,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)
index 2f9c0de533c75c282b40dddd2fa9154968702849..4cd03955fa326e4109eb9f59fcb18172c5989483 100644 (file)
@@ -98,7 +98,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)
@@ -122,7 +122,7 @@ int lwtunnel_build_state(u16 encap_type,
        rcu_read_unlock();
 
        if (found) {
-               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);
        } else {
index c092e9a557907550070b3a7f03f97806b8e6ca53..818916b2a04d601a300659fdb6b9e27fbc792840 100644 (file)
@@ -35,7 +35,7 @@ static inline void fib_alias_accessed(struct fib_alias *fa)
 void fib_release_info(struct fib_info *);
 struct fib_info *fib_create_info(struct fib_config *cfg,
                                 struct netlink_ext_ack *extack);
-int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
+int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
                 struct netlink_ext_ack *extack);
 bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi);
 int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
index e4c62b8f57a8482f1ca61056178007719e43235b..6ed8c931717942a814aa6c9a8cac5ebd7e626c0f 100644 (file)
@@ -570,8 +570,9 @@ 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,
+int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc,
+                      struct nlattr *encap, u16 encap_type,
+                      void *cfg, gfp_t gfp_flags,
                       struct netlink_ext_ack *extack)
 {
        int err;
@@ -589,8 +590,9 @@ int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *encap,
                        err = -EINVAL;
                        goto lwt_failure;
                }
-               err = lwtunnel_build_state(encap_type, encap, nhc->nhc_family,
-                                          cfg, &lwtstate, extack);
+               err = lwtunnel_build_state(net, encap_type, encap,
+                                          nhc->nhc_family, cfg, &lwtstate,
+                                          extack);
                if (err)
                        goto lwt_failure;
 
@@ -614,7 +616,7 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
 
        nh->fib_nh_family = AF_INET;
 
-       err = fib_nh_common_init(&nh->nh_common, cfg->fc_encap,
+       err = fib_nh_common_init(net, &nh->nh_common, cfg->fc_encap,
                                 cfg->fc_encap_type, cfg, GFP_KERNEL, extack);
        if (err)
                return err;
@@ -814,7 +816,7 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
 
 #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,
@@ -826,7 +828,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->fib_nh_lws);
@@ -836,7 +838,7 @@ static int fib_encap_match(u16 encap_type,
        return result;
 }
 
-int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
+int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
                 struct netlink_ext_ack *extack)
 {
 #ifdef CONFIG_IP_ROUTE_MULTIPATH
@@ -857,8 +859,8 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
                struct fib_nh *nh = fib_info_nh(fi, 0);
 
                if (cfg->fc_encap) {
-                       if (fib_encap_match(cfg->fc_encap_type, cfg->fc_encap,
-                                           nh, cfg, extack))
+                       if (fib_encap_match(net, cfg->fc_encap_type,
+                                           cfg->fc_encap, nh, cfg, extack))
                                return 1;
                }
 #ifdef CONFIG_IP_ROUTE_CLASSID
index f4c2ac445b3fd43399038de067df805fc44d9072..b01b748df9dd7bf4af1d1a842e7126f00774228e 100644 (file)
@@ -1679,7 +1679,7 @@ int fib_table_delete(struct net *net, struct fib_table *tb,
                     fi->fib_prefsrc == cfg->fc_prefsrc) &&
                    (!cfg->fc_protocol ||
                     fi->fib_protocol == cfg->fc_protocol) &&
-                   fib_nh_match(cfg, fi, extack) == 0 &&
+                   fib_nh_match(net, cfg, fi, extack) == 0 &&
                    fib_metrics_match(cfg, fi)) {
                        fa_to_delete = fa;
                        break;
index 47f8b947eef1b763d9d9d8f487595a1ddb94739f..181b7a2a024766a7370dbb657acac85ed1f49016 100644 (file)
@@ -432,7 +432,7 @@ static int ip_tun_set_opts(struct nlattr *attr, struct ip_tunnel_info *info,
        return ip_tun_parse_opts(attr, info, extack);
 }
 
-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)
@@ -719,7 +719,7 @@ static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = {
        [LWTUNNEL_IP6_OPTS]             = { .type = NLA_NESTED },
 };
 
-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)
index 422dcc691f71cb878f2f6e273bfcf3f2ef6065c3..8c1ce78956bae202f6e96c01c861e29895a0f959 100644 (file)
@@ -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)
index afcde55d537c33463ad3e9bcb2805c14655e9e2e..310cbddaa533fcefc14c8fe3566afab494b64bc0 100644 (file)
@@ -3471,7 +3471,7 @@ int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
            !netif_carrier_ok(dev))
                fib6_nh->fib_nh_flags |= RTNH_F_LINKDOWN;
 
-       err = fib_nh_common_init(&fib6_nh->nh_common, cfg->fc_encap,
+       err = fib_nh_common_init(net, &fib6_nh->nh_common, cfg->fc_encap,
                                 cfg->fc_encap_type, cfg, gfp_flags, extack);
        if (err)
                goto out;
index ac837afb90407aa4138ead4acbc0a09a9ae28c32..c7cbfeae94f5eb8cbbe73a07bf30875fbb69cd84 100644 (file)
@@ -376,7 +376,7 @@ drop:
        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)
index 8165802d8e05dea47225264f20f995b5962565ae..52493423f32992f2578a4e29cbe8ac6a5e4c2299 100644 (file)
@@ -970,8 +970,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];
index 44b675016393a450e7ec7c73e2dfb514ade4e5f9..2def85718d946ab975b8f6d26f0ae3512ae71b66 100644 (file)
@@ -162,7 +162,7 @@ drop:
        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)