Skip to content

Commit 93c839e

Browse files
q2venkuba-moo
authored andcommitted
ipv6: Convert net.ipv6.conf.${DEV}.XXX sysctl to per-netns RTNL.
net.ipv6.conf.${DEV}.XXX sysctl are changed under RTNL: * forwarding * ignore_routes_with_linkdown * disable_ipv6 * proxy_ndp * addr_gen_mode * stable_secret * disable_policy Let's use rtnl_net_lock() there. Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f7a6082 commit 93c839e

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

net/ipv6/addrconf.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ static void addrconf_forward_change(struct net *net, __s32 newf)
852852
struct inet6_dev *idev;
853853

854854
for_each_netdev(net, dev) {
855-
idev = __in6_dev_get(dev);
855+
idev = __in6_dev_get_rtnl_net(dev);
856856
if (idev) {
857857
int changed = (!idev->cnf.forwarding) ^ (!newf);
858858

@@ -865,13 +865,12 @@ static void addrconf_forward_change(struct net *net, __s32 newf)
865865

866866
static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, int newf)
867867
{
868-
struct net *net;
868+
struct net *net = (struct net *)table->extra2;
869869
int old;
870870

871-
if (!rtnl_trylock())
871+
if (!rtnl_net_trylock(net))
872872
return restart_syscall();
873873

874-
net = (struct net *)table->extra2;
875874
old = *p;
876875
WRITE_ONCE(*p, newf);
877876

@@ -881,7 +880,7 @@ static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, int
881880
NETCONFA_FORWARDING,
882881
NETCONFA_IFINDEX_DEFAULT,
883882
net->ipv6.devconf_dflt);
884-
rtnl_unlock();
883+
rtnl_net_unlock(net);
885884
return 0;
886885
}
887886

@@ -903,7 +902,7 @@ static int addrconf_fixup_forwarding(const struct ctl_table *table, int *p, int
903902
net->ipv6.devconf_all);
904903
} else if ((!newf) ^ (!old))
905904
dev_forward_change((struct inet6_dev *)table->extra1);
906-
rtnl_unlock();
905+
rtnl_net_unlock(net);
907906

908907
if (newf)
909908
rt6_purge_dflt_routers(net);
@@ -916,7 +915,7 @@ static void addrconf_linkdown_change(struct net *net, __s32 newf)
916915
struct inet6_dev *idev;
917916

918917
for_each_netdev(net, dev) {
919-
idev = __in6_dev_get(dev);
918+
idev = __in6_dev_get_rtnl_net(dev);
920919
if (idev) {
921920
int changed = (!idev->cnf.ignore_routes_with_linkdown) ^ (!newf);
922921

@@ -933,13 +932,12 @@ static void addrconf_linkdown_change(struct net *net, __s32 newf)
933932

934933
static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int newf)
935934
{
936-
struct net *net;
935+
struct net *net = (struct net *)table->extra2;
937936
int old;
938937

939-
if (!rtnl_trylock())
938+
if (!rtnl_net_trylock(net))
940939
return restart_syscall();
941940

942-
net = (struct net *)table->extra2;
943941
old = *p;
944942
WRITE_ONCE(*p, newf);
945943

@@ -950,7 +948,7 @@ static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int ne
950948
NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN,
951949
NETCONFA_IFINDEX_DEFAULT,
952950
net->ipv6.devconf_dflt);
953-
rtnl_unlock();
951+
rtnl_net_unlock(net);
954952
return 0;
955953
}
956954

@@ -964,7 +962,8 @@ static int addrconf_fixup_linkdown(const struct ctl_table *table, int *p, int ne
964962
NETCONFA_IFINDEX_ALL,
965963
net->ipv6.devconf_all);
966964
}
967-
rtnl_unlock();
965+
966+
rtnl_net_unlock(net);
968967

969968
return 1;
970969
}
@@ -6370,7 +6369,7 @@ static void addrconf_disable_change(struct net *net, __s32 newf)
63706369
struct inet6_dev *idev;
63716370

63726371
for_each_netdev(net, dev) {
6373-
idev = __in6_dev_get(dev);
6372+
idev = __in6_dev_get_rtnl_net(dev);
63746373
if (idev) {
63756374
int changed = (!idev->cnf.disable_ipv6) ^ (!newf);
63766375

@@ -6391,7 +6390,7 @@ static int addrconf_disable_ipv6(const struct ctl_table *table, int *p, int newf
63916390
return 0;
63926391
}
63936392

6394-
if (!rtnl_trylock())
6393+
if (!rtnl_net_trylock(net))
63956394
return restart_syscall();
63966395

63976396
old = *p;
@@ -6400,10 +6399,11 @@ static int addrconf_disable_ipv6(const struct ctl_table *table, int *p, int newf
64006399
if (p == &net->ipv6.devconf_all->disable_ipv6) {
64016400
WRITE_ONCE(net->ipv6.devconf_dflt->disable_ipv6, newf);
64026401
addrconf_disable_change(net, newf);
6403-
} else if ((!newf) ^ (!old))
6402+
} else if ((!newf) ^ (!old)) {
64046403
dev_disable_change((struct inet6_dev *)table->extra1);
6404+
}
64056405

6406-
rtnl_unlock();
6406+
rtnl_net_unlock(net);
64076407
return 0;
64086408
}
64096409

@@ -6446,28 +6446,28 @@ static int addrconf_sysctl_proxy_ndp(const struct ctl_table *ctl, int write,
64466446
if (write && old != new) {
64476447
struct net *net = ctl->extra2;
64486448

6449-
if (!rtnl_trylock())
6449+
if (!rtnl_net_trylock(net))
64506450
return restart_syscall();
64516451

6452-
if (valp == &net->ipv6.devconf_dflt->proxy_ndp)
6452+
if (valp == &net->ipv6.devconf_dflt->proxy_ndp) {
64536453
inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
64546454
NETCONFA_PROXY_NEIGH,
64556455
NETCONFA_IFINDEX_DEFAULT,
64566456
net->ipv6.devconf_dflt);
6457-
else if (valp == &net->ipv6.devconf_all->proxy_ndp)
6457+
} else if (valp == &net->ipv6.devconf_all->proxy_ndp) {
64586458
inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
64596459
NETCONFA_PROXY_NEIGH,
64606460
NETCONFA_IFINDEX_ALL,
64616461
net->ipv6.devconf_all);
6462-
else {
6462+
} else {
64636463
struct inet6_dev *idev = ctl->extra1;
64646464

64656465
inet6_netconf_notify_devconf(net, RTM_NEWNETCONF,
64666466
NETCONFA_PROXY_NEIGH,
64676467
idev->dev->ifindex,
64686468
&idev->cnf);
64696469
}
6470-
rtnl_unlock();
6470+
rtnl_net_unlock(net);
64716471
}
64726472

64736473
return ret;
@@ -6487,7 +6487,7 @@ static int addrconf_sysctl_addr_gen_mode(const struct ctl_table *ctl, int write,
64876487
.mode = ctl->mode,
64886488
};
64896489

6490-
if (!rtnl_trylock())
6490+
if (!rtnl_net_trylock(net))
64916491
return restart_syscall();
64926492

64936493
new_val = *((u32 *)ctl->data);
@@ -6517,7 +6517,7 @@ static int addrconf_sysctl_addr_gen_mode(const struct ctl_table *ctl, int write,
65176517

65186518
WRITE_ONCE(net->ipv6.devconf_dflt->addr_gen_mode, new_val);
65196519
for_each_netdev(net, dev) {
6520-
idev = __in6_dev_get(dev);
6520+
idev = __in6_dev_get_rtnl_net(dev);
65216521
if (idev &&
65226522
idev->cnf.addr_gen_mode != new_val) {
65236523
WRITE_ONCE(idev->cnf.addr_gen_mode,
@@ -6531,7 +6531,7 @@ static int addrconf_sysctl_addr_gen_mode(const struct ctl_table *ctl, int write,
65316531
}
65326532

65336533
out:
6534-
rtnl_unlock();
6534+
rtnl_net_unlock(net);
65356535

65366536
return ret;
65376537
}
@@ -6553,7 +6553,7 @@ static int addrconf_sysctl_stable_secret(const struct ctl_table *ctl, int write,
65536553
lctl.maxlen = IPV6_MAX_STRLEN;
65546554
lctl.data = str;
65556555

6556-
if (!rtnl_trylock())
6556+
if (!rtnl_net_trylock(net))
65576557
return restart_syscall();
65586558

65596559
if (!write && !secret->initialized) {
@@ -6583,7 +6583,7 @@ static int addrconf_sysctl_stable_secret(const struct ctl_table *ctl, int write,
65836583
struct net_device *dev;
65846584

65856585
for_each_netdev(net, dev) {
6586-
struct inet6_dev *idev = __in6_dev_get(dev);
6586+
struct inet6_dev *idev = __in6_dev_get_rtnl_net(dev);
65876587

65886588
if (idev) {
65896589
WRITE_ONCE(idev->cnf.addr_gen_mode,
@@ -6598,7 +6598,7 @@ static int addrconf_sysctl_stable_secret(const struct ctl_table *ctl, int write,
65986598
}
65996599

66006600
out:
6601-
rtnl_unlock();
6601+
rtnl_net_unlock(net);
66026602

66036603
return err;
66046604
}
@@ -6682,7 +6682,7 @@ int addrconf_disable_policy(const struct ctl_table *ctl, int *valp, int val)
66826682
return 0;
66836683
}
66846684

6685-
if (!rtnl_trylock())
6685+
if (!rtnl_net_trylock(net))
66866686
return restart_syscall();
66876687

66886688
WRITE_ONCE(*valp, val);
@@ -6691,7 +6691,7 @@ int addrconf_disable_policy(const struct ctl_table *ctl, int *valp, int val)
66916691
struct net_device *dev;
66926692

66936693
for_each_netdev(net, dev) {
6694-
idev = __in6_dev_get(dev);
6694+
idev = __in6_dev_get_rtnl_net(dev);
66956695
if (idev)
66966696
addrconf_disable_policy_idev(idev, val);
66976697
}
@@ -6700,7 +6700,7 @@ int addrconf_disable_policy(const struct ctl_table *ctl, int *valp, int val)
67006700
addrconf_disable_policy_idev(idev, val);
67016701
}
67026702

6703-
rtnl_unlock();
6703+
rtnl_net_unlock(net);
67046704
return 0;
67056705
}
67066706

0 commit comments

Comments
 (0)