Skip to content

Commit faee676

Browse files
alexaringdavem330
authored andcommitted
net: add net available in build_state
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8610c7c commit faee676

File tree

13 files changed

+32
-28
lines changed

13 files changed

+32
-28
lines changed

include/net/ip_fib.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,8 +470,9 @@ int fib_nh_init(struct net *net, struct fib_nh *fib_nh,
470470
struct fib_config *cfg, int nh_weight,
471471
struct netlink_ext_ack *extack);
472472
void fib_nh_release(struct net *net, struct fib_nh *fib_nh);
473-
int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *fc_encap,
474-
u16 fc_encap_type, void *cfg, gfp_t gfp_flags,
473+
int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc,
474+
struct nlattr *fc_encap, u16 fc_encap_type,
475+
void *cfg, gfp_t gfp_flags,
475476
struct netlink_ext_ack *extack);
476477
void fib_nh_common_release(struct fib_nh_common *nhc);
477478

include/net/lwtunnel.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct lwtunnel_state {
3434
};
3535

3636
struct lwtunnel_encap_ops {
37-
int (*build_state)(struct nlattr *encap,
37+
int (*build_state)(struct net *net, struct nlattr *encap,
3838
unsigned int family, const void *cfg,
3939
struct lwtunnel_state **ts,
4040
struct netlink_ext_ack *extack);
@@ -113,7 +113,7 @@ int lwtunnel_valid_encap_type(u16 encap_type,
113113
struct netlink_ext_ack *extack);
114114
int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len,
115115
struct netlink_ext_ack *extack);
116-
int lwtunnel_build_state(u16 encap_type,
116+
int lwtunnel_build_state(struct net *net, u16 encap_type,
117117
struct nlattr *encap,
118118
unsigned int family, const void *cfg,
119119
struct lwtunnel_state **lws,
@@ -209,7 +209,7 @@ static inline int lwtunnel_valid_encap_type_attr(struct nlattr *attr, int len,
209209
return 0;
210210
}
211211

212-
static inline int lwtunnel_build_state(u16 encap_type,
212+
static inline int lwtunnel_build_state(struct net *net, u16 encap_type,
213213
struct nlattr *encap,
214214
unsigned int family, const void *cfg,
215215
struct lwtunnel_state **lws,

net/core/lwt_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ static const struct nla_policy bpf_nl_policy[LWT_BPF_MAX + 1] = {
367367
[LWT_BPF_XMIT_HEADROOM] = { .type = NLA_U32 },
368368
};
369369

370-
static int bpf_build_state(struct nlattr *nla,
370+
static int bpf_build_state(struct net *net, struct nlattr *nla,
371371
unsigned int family, const void *cfg,
372372
struct lwtunnel_state **ts,
373373
struct netlink_ext_ack *extack)

net/core/lwtunnel.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ int lwtunnel_encap_del_ops(const struct lwtunnel_encap_ops *ops,
9898
}
9999
EXPORT_SYMBOL_GPL(lwtunnel_encap_del_ops);
100100

101-
int lwtunnel_build_state(u16 encap_type,
101+
int lwtunnel_build_state(struct net *net, u16 encap_type,
102102
struct nlattr *encap, unsigned int family,
103103
const void *cfg, struct lwtunnel_state **lws,
104104
struct netlink_ext_ack *extack)
@@ -122,7 +122,7 @@ int lwtunnel_build_state(u16 encap_type,
122122
rcu_read_unlock();
123123

124124
if (found) {
125-
ret = ops->build_state(encap, family, cfg, lws, extack);
125+
ret = ops->build_state(net, encap, family, cfg, lws, extack);
126126
if (ret)
127127
module_put(ops->owner);
128128
} else {

net/ipv4/fib_lookup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static inline void fib_alias_accessed(struct fib_alias *fa)
3535
void fib_release_info(struct fib_info *);
3636
struct fib_info *fib_create_info(struct fib_config *cfg,
3737
struct netlink_ext_ack *extack);
38-
int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
38+
int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
3939
struct netlink_ext_ack *extack);
4040
bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi);
4141
int fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,

net/ipv4/fib_semantics.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,9 @@ static int fib_detect_death(struct fib_info *fi, int order,
570570
return 1;
571571
}
572572

573-
int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *encap,
574-
u16 encap_type, void *cfg, gfp_t gfp_flags,
573+
int fib_nh_common_init(struct net *net, struct fib_nh_common *nhc,
574+
struct nlattr *encap, u16 encap_type,
575+
void *cfg, gfp_t gfp_flags,
575576
struct netlink_ext_ack *extack)
576577
{
577578
int err;
@@ -589,8 +590,9 @@ int fib_nh_common_init(struct fib_nh_common *nhc, struct nlattr *encap,
589590
err = -EINVAL;
590591
goto lwt_failure;
591592
}
592-
err = lwtunnel_build_state(encap_type, encap, nhc->nhc_family,
593-
cfg, &lwtstate, extack);
593+
err = lwtunnel_build_state(net, encap_type, encap,
594+
nhc->nhc_family, cfg, &lwtstate,
595+
extack);
594596
if (err)
595597
goto lwt_failure;
596598

@@ -614,7 +616,7 @@ int fib_nh_init(struct net *net, struct fib_nh *nh,
614616

615617
nh->fib_nh_family = AF_INET;
616618

617-
err = fib_nh_common_init(&nh->nh_common, cfg->fc_encap,
619+
err = fib_nh_common_init(net, &nh->nh_common, cfg->fc_encap,
618620
cfg->fc_encap_type, cfg, GFP_KERNEL, extack);
619621
if (err)
620622
return err;
@@ -814,7 +816,7 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
814816

815817
#endif /* CONFIG_IP_ROUTE_MULTIPATH */
816818

817-
static int fib_encap_match(u16 encap_type,
819+
static int fib_encap_match(struct net *net, u16 encap_type,
818820
struct nlattr *encap,
819821
const struct fib_nh *nh,
820822
const struct fib_config *cfg,
@@ -826,7 +828,7 @@ static int fib_encap_match(u16 encap_type,
826828
if (encap_type == LWTUNNEL_ENCAP_NONE)
827829
return 0;
828830

829-
ret = lwtunnel_build_state(encap_type, encap, AF_INET,
831+
ret = lwtunnel_build_state(net, encap_type, encap, AF_INET,
830832
cfg, &lwtstate, extack);
831833
if (!ret) {
832834
result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws);
@@ -836,7 +838,7 @@ static int fib_encap_match(u16 encap_type,
836838
return result;
837839
}
838840

839-
int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
841+
int fib_nh_match(struct net *net, struct fib_config *cfg, struct fib_info *fi,
840842
struct netlink_ext_ack *extack)
841843
{
842844
#ifdef CONFIG_IP_ROUTE_MULTIPATH
@@ -857,8 +859,8 @@ int fib_nh_match(struct fib_config *cfg, struct fib_info *fi,
857859
struct fib_nh *nh = fib_info_nh(fi, 0);
858860

859861
if (cfg->fc_encap) {
860-
if (fib_encap_match(cfg->fc_encap_type, cfg->fc_encap,
861-
nh, cfg, extack))
862+
if (fib_encap_match(net, cfg->fc_encap_type,
863+
cfg->fc_encap, nh, cfg, extack))
862864
return 1;
863865
}
864866
#ifdef CONFIG_IP_ROUTE_CLASSID

net/ipv4/fib_trie.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@ int fib_table_delete(struct net *net, struct fib_table *tb,
16791679
fi->fib_prefsrc == cfg->fc_prefsrc) &&
16801680
(!cfg->fc_protocol ||
16811681
fi->fib_protocol == cfg->fc_protocol) &&
1682-
fib_nh_match(cfg, fi, extack) == 0 &&
1682+
fib_nh_match(net, cfg, fi, extack) == 0 &&
16831683
fib_metrics_match(cfg, fi)) {
16841684
fa_to_delete = fa;
16851685
break;

net/ipv4/ip_tunnel_core.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ static int ip_tun_set_opts(struct nlattr *attr, struct ip_tunnel_info *info,
432432
return ip_tun_parse_opts(attr, info, extack);
433433
}
434434

435-
static int ip_tun_build_state(struct nlattr *attr,
435+
static int ip_tun_build_state(struct net *net, struct nlattr *attr,
436436
unsigned int family, const void *cfg,
437437
struct lwtunnel_state **ts,
438438
struct netlink_ext_ack *extack)
@@ -719,7 +719,7 @@ static const struct nla_policy ip6_tun_policy[LWTUNNEL_IP6_MAX + 1] = {
719719
[LWTUNNEL_IP6_OPTS] = { .type = NLA_NESTED },
720720
};
721721

722-
static int ip6_tun_build_state(struct nlattr *attr,
722+
static int ip6_tun_build_state(struct net *net, struct nlattr *attr,
723723
unsigned int family, const void *cfg,
724724
struct lwtunnel_state **ts,
725725
struct netlink_ext_ack *extack)

net/ipv6/ila/ila_lwt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ static const struct nla_policy ila_nl_policy[ILA_ATTR_MAX + 1] = {
125125
[ILA_ATTR_HOOK_TYPE] = { .type = NLA_U8, },
126126
};
127127

128-
static int ila_build_state(struct nlattr *nla,
128+
static int ila_build_state(struct net *net, struct nlattr *nla,
129129
unsigned int family, const void *cfg,
130130
struct lwtunnel_state **ts,
131131
struct netlink_ext_ack *extack)

net/ipv6/route.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3471,7 +3471,7 @@ int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh,
34713471
!netif_carrier_ok(dev))
34723472
fib6_nh->fib_nh_flags |= RTNH_F_LINKDOWN;
34733473

3474-
err = fib_nh_common_init(&fib6_nh->nh_common, cfg->fc_encap,
3474+
err = fib_nh_common_init(net, &fib6_nh->nh_common, cfg->fc_encap,
34753475
cfg->fc_encap_type, cfg, gfp_flags, extack);
34763476
if (err)
34773477
goto out;

0 commit comments

Comments
 (0)