Skip to content

Commit 69f397e

Browse files
JasonXinggregkh
authored andcommitted
net: remove NULL-pointer net parameter in ip_metrics_convert
[ Upstream commit 61e2bba ] When I was doing some experiments, I found that when using the first parameter, namely, struct net, in ip_metrics_convert() always triggers NULL pointer crash. Then I digged into this part, realizing that we can remove this one due to its uselessness. Signed-off-by: Jason Xing <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent fc1b1e1 commit 69f397e

File tree

6 files changed

+14
-17
lines changed

6 files changed

+14
-17
lines changed

include/net/ip.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,8 +497,7 @@ static inline unsigned int ip_skb_dst_mtu(struct sock *sk,
497497
return mtu - lwtunnel_headroom(skb_dst(skb)->lwtstate, mtu);
498498
}
499499

500-
struct dst_metrics *ip_fib_metrics_init(struct net *net, struct nlattr *fc_mx,
501-
int fc_mx_len,
500+
struct dst_metrics *ip_fib_metrics_init(struct nlattr *fc_mx, int fc_mx_len,
502501
struct netlink_ext_ack *extack);
503502
static inline void ip_fib_metrics_put(struct dst_metrics *fib_metrics)
504503
{

include/net/tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ extern struct tcp_congestion_ops tcp_reno;
11401140

11411141
struct tcp_congestion_ops *tcp_ca_find(const char *name);
11421142
struct tcp_congestion_ops *tcp_ca_find_key(u32 key);
1143-
u32 tcp_ca_get_key_by_name(struct net *net, const char *name, bool *ecn_ca);
1143+
u32 tcp_ca_get_key_by_name(const char *name, bool *ecn_ca);
11441144
#ifdef CONFIG_INET
11451145
char *tcp_ca_get_name_by_key(u32 key, char *buffer);
11461146
#else

net/ipv4/fib_semantics.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ bool fib_metrics_match(struct fib_config *cfg, struct fib_info *fi)
10301030
bool ecn_ca = false;
10311031

10321032
nla_strscpy(tmp, nla, sizeof(tmp));
1033-
val = tcp_ca_get_key_by_name(fi->fib_net, tmp, &ecn_ca);
1033+
val = tcp_ca_get_key_by_name(tmp, &ecn_ca);
10341034
} else {
10351035
if (nla_len(nla) != sizeof(u32))
10361036
return false;
@@ -1459,8 +1459,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
14591459
fi = kzalloc(struct_size(fi, fib_nh, nhs), GFP_KERNEL);
14601460
if (!fi)
14611461
goto failure;
1462-
fi->fib_metrics = ip_fib_metrics_init(fi->fib_net, cfg->fc_mx,
1463-
cfg->fc_mx_len, extack);
1462+
fi->fib_metrics = ip_fib_metrics_init(cfg->fc_mx, cfg->fc_mx_len, extack);
14641463
if (IS_ERR(fi->fib_metrics)) {
14651464
err = PTR_ERR(fi->fib_metrics);
14661465
kfree(fi);

net/ipv4/metrics.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <net/net_namespace.h>
88
#include <net/tcp.h>
99

10-
static int ip_metrics_convert(struct net *net, struct nlattr *fc_mx,
10+
static int ip_metrics_convert(struct nlattr *fc_mx,
1111
int fc_mx_len, u32 *metrics,
1212
struct netlink_ext_ack *extack)
1313
{
@@ -31,7 +31,7 @@ static int ip_metrics_convert(struct net *net, struct nlattr *fc_mx,
3131
char tmp[TCP_CA_NAME_MAX];
3232

3333
nla_strscpy(tmp, nla, sizeof(tmp));
34-
val = tcp_ca_get_key_by_name(net, tmp, &ecn_ca);
34+
val = tcp_ca_get_key_by_name(tmp, &ecn_ca);
3535
if (val == TCP_CA_UNSPEC) {
3636
NL_SET_ERR_MSG(extack, "Unknown tcp congestion algorithm");
3737
return -EINVAL;
@@ -63,7 +63,7 @@ static int ip_metrics_convert(struct net *net, struct nlattr *fc_mx,
6363
return 0;
6464
}
6565

66-
struct dst_metrics *ip_fib_metrics_init(struct net *net, struct nlattr *fc_mx,
66+
struct dst_metrics *ip_fib_metrics_init(struct nlattr *fc_mx,
6767
int fc_mx_len,
6868
struct netlink_ext_ack *extack)
6969
{
@@ -77,7 +77,7 @@ struct dst_metrics *ip_fib_metrics_init(struct net *net, struct nlattr *fc_mx,
7777
if (unlikely(!fib_metrics))
7878
return ERR_PTR(-ENOMEM);
7979

80-
err = ip_metrics_convert(net, fc_mx, fc_mx_len, fib_metrics->metrics,
80+
err = ip_metrics_convert(fc_mx, fc_mx_len, fib_metrics->metrics,
8181
extack);
8282
if (!err) {
8383
refcount_set(&fib_metrics->refcnt, 1);

net/ipv4/tcp_cong.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ void tcp_set_ca_state(struct sock *sk, const u8 ca_state)
4646
}
4747

4848
/* Must be called with rcu lock held */
49-
static struct tcp_congestion_ops *tcp_ca_find_autoload(struct net *net,
50-
const char *name)
49+
static struct tcp_congestion_ops *tcp_ca_find_autoload(const char *name)
5150
{
5251
struct tcp_congestion_ops *ca = tcp_ca_find(name);
5352

@@ -182,15 +181,15 @@ int tcp_update_congestion_control(struct tcp_congestion_ops *ca, struct tcp_cong
182181
return ret;
183182
}
184183

185-
u32 tcp_ca_get_key_by_name(struct net *net, const char *name, bool *ecn_ca)
184+
u32 tcp_ca_get_key_by_name(const char *name, bool *ecn_ca)
186185
{
187186
const struct tcp_congestion_ops *ca;
188187
u32 key = TCP_CA_UNSPEC;
189188

190189
might_sleep();
191190

192191
rcu_read_lock();
193-
ca = tcp_ca_find_autoload(net, name);
192+
ca = tcp_ca_find_autoload(name);
194193
if (ca) {
195194
key = ca->key;
196195
*ecn_ca = ca->flags & TCP_CONG_NEEDS_ECN;
@@ -287,7 +286,7 @@ int tcp_set_default_congestion_control(struct net *net, const char *name)
287286
int ret;
288287

289288
rcu_read_lock();
290-
ca = tcp_ca_find_autoload(net, name);
289+
ca = tcp_ca_find_autoload(name);
291290
if (!ca) {
292291
ret = -ENOENT;
293292
} else if (!bpf_try_module_get(ca, ca->owner)) {
@@ -425,7 +424,7 @@ int tcp_set_congestion_control(struct sock *sk, const char *name, bool load,
425424
if (!load)
426425
ca = tcp_ca_find(name);
427426
else
428-
ca = tcp_ca_find_autoload(sock_net(sk), name);
427+
ca = tcp_ca_find_autoload(name);
429428

430429
/* No change asking for existing value */
431430
if (ca == icsk->icsk_ca_ops) {

net/ipv6/route.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3754,7 +3754,7 @@ static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg,
37543754
if (!rt)
37553755
goto out;
37563756

3757-
rt->fib6_metrics = ip_fib_metrics_init(net, cfg->fc_mx, cfg->fc_mx_len,
3757+
rt->fib6_metrics = ip_fib_metrics_init(cfg->fc_mx, cfg->fc_mx_len,
37583758
extack);
37593759
if (IS_ERR(rt->fib6_metrics)) {
37603760
err = PTR_ERR(rt->fib6_metrics);

0 commit comments

Comments
 (0)