Commit 30357d7d authored by David Ahern's avatar David Ahern Committed by David S. Miller

lwtunnel: remove device arg to lwtunnel_build_state

Nothing about lwt state requires a device reference, so remove the
input argument.
Signed-off-by: default avatarDavid Ahern <dsa@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6ad20165
...@@ -33,7 +33,7 @@ struct lwtunnel_state { ...@@ -33,7 +33,7 @@ struct lwtunnel_state {
}; };
struct lwtunnel_encap_ops { struct lwtunnel_encap_ops {
int (*build_state)(struct net_device *dev, struct nlattr *encap, int (*build_state)(struct nlattr *encap,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **ts); struct lwtunnel_state **ts);
void (*destroy_state)(struct lwtunnel_state *lws); void (*destroy_state)(struct lwtunnel_state *lws);
...@@ -109,7 +109,7 @@ int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op, ...@@ -109,7 +109,7 @@ int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *op,
unsigned int num); unsigned int num);
int lwtunnel_valid_encap_type(u16 encap_type); int lwtunnel_valid_encap_type(u16 encap_type);
int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len); int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len);
int lwtunnel_build_state(struct net_device *dev, u16 encap_type, int lwtunnel_build_state(u16 encap_type,
struct nlattr *encap, struct nlattr *encap,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **lws); struct lwtunnel_state **lws);
...@@ -181,7 +181,7 @@ static inline int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len) ...@@ -181,7 +181,7 @@ static inline int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len)
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static inline int lwtunnel_build_state(struct net_device *dev, u16 encap_type, static inline int lwtunnel_build_state(u16 encap_type,
struct nlattr *encap, struct nlattr *encap,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **lws) struct lwtunnel_state **lws)
......
...@@ -237,7 +237,7 @@ static const struct nla_policy bpf_nl_policy[LWT_BPF_MAX + 1] = { ...@@ -237,7 +237,7 @@ static const struct nla_policy bpf_nl_policy[LWT_BPF_MAX + 1] = {
[LWT_BPF_XMIT_HEADROOM] = { .type = NLA_U32 }, [LWT_BPF_XMIT_HEADROOM] = { .type = NLA_U32 },
}; };
static int bpf_build_state(struct net_device *dev, struct nlattr *nla, static int bpf_build_state(struct nlattr *nla,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **ts) struct lwtunnel_state **ts)
{ {
......
...@@ -101,7 +101,7 @@ int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *ops, ...@@ -101,7 +101,7 @@ int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *ops,
} }
EXPORT_SYMBOL(lwtunnel_encap_del_ops); EXPORT_SYMBOL(lwtunnel_encap_del_ops);
int lwtunnel_build_state(struct net_device *dev, u16 encap_type, int lwtunnel_build_state(u16 encap_type,
struct nlattr *encap, unsigned int family, struct nlattr *encap, unsigned int family,
const void *cfg, struct lwtunnel_state **lws) const void *cfg, struct lwtunnel_state **lws)
{ {
...@@ -116,7 +116,7 @@ int lwtunnel_build_state(struct net_device *dev, u16 encap_type, ...@@ -116,7 +116,7 @@ int lwtunnel_build_state(struct net_device *dev, u16 encap_type,
rcu_read_lock(); rcu_read_lock();
ops = rcu_dereference(lwtun_encaps[encap_type]); ops = rcu_dereference(lwtun_encaps[encap_type]);
if (likely(ops && ops->build_state && try_module_get(ops->owner))) { if (likely(ops && ops->build_state && try_module_get(ops->owner))) {
ret = ops->build_state(dev, encap, family, cfg, lws); ret = ops->build_state(encap, family, cfg, lws);
if (ret) if (ret)
module_put(ops->owner); module_put(ops->owner);
} }
......
...@@ -471,7 +471,6 @@ static int fib_count_nexthops(struct rtnexthop *rtnh, int remaining) ...@@ -471,7 +471,6 @@ static int fib_count_nexthops(struct rtnexthop *rtnh, int remaining)
static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
int remaining, struct fib_config *cfg) int remaining, struct fib_config *cfg)
{ {
struct net *net = cfg->fc_nlinfo.nl_net;
int ret; int ret;
change_nexthops(fi) { change_nexthops(fi) {
...@@ -503,16 +502,14 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh, ...@@ -503,16 +502,14 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
nla = nla_find(attrs, attrlen, RTA_ENCAP); nla = nla_find(attrs, attrlen, RTA_ENCAP);
if (nla) { if (nla) {
struct lwtunnel_state *lwtstate; struct lwtunnel_state *lwtstate;
struct net_device *dev = NULL;
struct nlattr *nla_entype; struct nlattr *nla_entype;
nla_entype = nla_find(attrs, attrlen, nla_entype = nla_find(attrs, attrlen,
RTA_ENCAP_TYPE); RTA_ENCAP_TYPE);
if (!nla_entype) if (!nla_entype)
goto err_inval; goto err_inval;
if (cfg->fc_oif)
dev = __dev_get_by_index(net, cfg->fc_oif); ret = lwtunnel_build_state(nla_get_u16(
ret = lwtunnel_build_state(dev, nla_get_u16(
nla_entype), nla_entype),
nla, AF_INET, cfg, nla, AF_INET, cfg,
&lwtstate); &lwtstate);
...@@ -597,21 +594,18 @@ static inline void fib_add_weight(struct fib_info *fi, ...@@ -597,21 +594,18 @@ static inline void fib_add_weight(struct fib_info *fi,
#endif /* CONFIG_IP_ROUTE_MULTIPATH */ #endif /* CONFIG_IP_ROUTE_MULTIPATH */
static int fib_encap_match(struct net *net, u16 encap_type, static int fib_encap_match(u16 encap_type,
struct nlattr *encap, struct nlattr *encap,
int oif, const struct fib_nh *nh, const struct fib_nh *nh,
const struct fib_config *cfg) const struct fib_config *cfg)
{ {
struct lwtunnel_state *lwtstate; struct lwtunnel_state *lwtstate;
struct net_device *dev = NULL;
int ret, result = 0; int ret, result = 0;
if (encap_type == LWTUNNEL_ENCAP_NONE) if (encap_type == LWTUNNEL_ENCAP_NONE)
return 0; return 0;
if (oif) ret = lwtunnel_build_state(encap_type, encap,
dev = __dev_get_by_index(net, oif);
ret = lwtunnel_build_state(dev, encap_type, encap,
AF_INET, cfg, &lwtstate); AF_INET, cfg, &lwtstate);
if (!ret) { if (!ret) {
result = lwtunnel_cmp_encap(lwtstate, nh->nh_lwtstate); result = lwtunnel_cmp_encap(lwtstate, nh->nh_lwtstate);
...@@ -623,7 +617,6 @@ static int fib_encap_match(struct net *net, u16 encap_type, ...@@ -623,7 +617,6 @@ static int fib_encap_match(struct net *net, u16 encap_type,
int fib_nh_match(struct fib_config *cfg, struct fib_info *fi) int fib_nh_match(struct fib_config *cfg, struct fib_info *fi)
{ {
struct net *net = cfg->fc_nlinfo.nl_net;
#ifdef CONFIG_IP_ROUTE_MULTIPATH #ifdef CONFIG_IP_ROUTE_MULTIPATH
struct rtnexthop *rtnh; struct rtnexthop *rtnh;
int remaining; int remaining;
...@@ -634,9 +627,8 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi) ...@@ -634,9 +627,8 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi)
if (cfg->fc_oif || cfg->fc_gw) { if (cfg->fc_oif || cfg->fc_gw) {
if (cfg->fc_encap) { if (cfg->fc_encap) {
if (fib_encap_match(net, cfg->fc_encap_type, if (fib_encap_match(cfg->fc_encap_type,
cfg->fc_encap, cfg->fc_oif, cfg->fc_encap, fi->fib_nh, cfg))
fi->fib_nh, cfg))
return 1; return 1;
} }
if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->nh_oif) && if ((!cfg->fc_oif || cfg->fc_oif == fi->fib_nh->nh_oif) &&
...@@ -1093,13 +1085,10 @@ struct fib_info *fib_create_info(struct fib_config *cfg) ...@@ -1093,13 +1085,10 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
if (cfg->fc_encap) { if (cfg->fc_encap) {
struct lwtunnel_state *lwtstate; struct lwtunnel_state *lwtstate;
struct net_device *dev = NULL;
if (cfg->fc_encap_type == LWTUNNEL_ENCAP_NONE) if (cfg->fc_encap_type == LWTUNNEL_ENCAP_NONE)
goto err_inval; goto err_inval;
if (cfg->fc_oif) err = lwtunnel_build_state(cfg->fc_encap_type,
dev = __dev_get_by_index(net, cfg->fc_oif);
err = lwtunnel_build_state(dev, cfg->fc_encap_type,
cfg->fc_encap, AF_INET, cfg, cfg->fc_encap, AF_INET, cfg,
&lwtstate); &lwtstate);
if (err) if (err)
......
...@@ -226,7 +226,7 @@ static const struct nla_policy ip_tun_policy[LWTUNNEL_IP_MAX + 1] = { ...@@ -226,7 +226,7 @@ static const struct nla_policy ip_tun_policy[LWTUNNEL_IP_MAX + 1] = {
[LWTUNNEL_IP_FLAGS] = { .type = NLA_U16 }, [LWTUNNEL_IP_FLAGS] = { .type = NLA_U16 },
}; };
static int ip_tun_build_state(struct net_device *dev, struct nlattr *attr, static int ip_tun_build_state(struct nlattr *attr,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **ts) struct lwtunnel_state **ts)
{ {
...@@ -323,7 +323,7 @@ static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = { ...@@ -323,7 +323,7 @@ static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = {
[LWTUNNEL_IP6_FLAGS] = { .type = NLA_U16 }, [LWTUNNEL_IP6_FLAGS] = { .type = NLA_U16 },
}; };
static int ip6_tun_build_state(struct net_device *dev, struct nlattr *attr, static int ip6_tun_build_state(struct nlattr *attr,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **ts) struct lwtunnel_state **ts)
{ {
......
...@@ -115,7 +115,7 @@ static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = { ...@@ -115,7 +115,7 @@ static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = {
[ILA_ATTR_CSUM_MODE] = { .type = NLA_U8, }, [ILA_ATTR_CSUM_MODE] = { .type = NLA_U8, },
}; };
static int ila_build_state(struct net_device *dev, struct nlattr *nla, static int ila_build_state(struct nlattr *nla,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **ts) struct lwtunnel_state **ts)
{ {
......
...@@ -1897,7 +1897,7 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg) ...@@ -1897,7 +1897,7 @@ static struct rt6_info *ip6_route_info_create(struct fib6_config *cfg)
if (cfg->fc_encap) { if (cfg->fc_encap) {
struct lwtunnel_state *lwtstate; struct lwtunnel_state *lwtstate;
err = lwtunnel_build_state(dev, cfg->fc_encap_type, err = lwtunnel_build_state(cfg->fc_encap_type,
cfg->fc_encap, AF_INET6, cfg, cfg->fc_encap, AF_INET6, cfg,
&lwtstate); &lwtstate);
if (err) if (err)
......
...@@ -303,7 +303,7 @@ int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb) ...@@ -303,7 +303,7 @@ int seg6_output(struct net *net, struct sock *sk, struct sk_buff *skb)
return err; return err;
} }
static int seg6_build_state(struct net_device *dev, struct nlattr *nla, static int seg6_build_state(struct nlattr *nla,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **ts) struct lwtunnel_state **ts)
{ {
......
...@@ -133,7 +133,7 @@ static int mpls_xmit(struct sk_buff *skb) ...@@ -133,7 +133,7 @@ static int mpls_xmit(struct sk_buff *skb)
return -EINVAL; return -EINVAL;
} }
static int mpls_build_state(struct net_device *dev, struct nlattr *nla, static int mpls_build_state(struct nlattr *nla,
unsigned int family, const void *cfg, unsigned int family, const void *cfg,
struct lwtunnel_state **ts) struct lwtunnel_state **ts)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment