Skip to content

Commit 53b7997

Browse files
yoshfujidavem330
authored andcommitted
ipv6 netns: Make several "global" sysctl variables namespace aware.
Signed-off-by: YOSHIFUJI Hideaki <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 721499e commit 53b7997

File tree

9 files changed

+21
-16
lines changed

9 files changed

+21
-16
lines changed

net/ipv6/addrconf.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,7 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
18631863
struct inet6_ifaddr * ifp;
18641864
struct in6_addr addr;
18651865
int create = 0, update_lft = 0;
1866+
struct net *net = dev_net(dev);
18661867

18671868
if (pinfo->prefix_len == 64) {
18681869
memcpy(&addr, &pinfo->prefix, 8);
@@ -1881,15 +1882,15 @@ void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len)
18811882

18821883
ok:
18831884

1884-
ifp = ipv6_get_ifaddr(dev_net(dev), &addr, dev, 1);
1885+
ifp = ipv6_get_ifaddr(net, &addr, dev, 1);
18851886

18861887
if (ifp == NULL && valid_lft) {
18871888
int max_addresses = in6_dev->cnf.max_addresses;
18881889
u32 addr_flags = 0;
18891890

18901891
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
18911892
if (in6_dev->cnf.optimistic_dad &&
1892-
!ipv6_devconf.forwarding)
1893+
!net->ipv6.devconf_all->forwarding)
18931894
addr_flags = IFA_F_OPTIMISTIC;
18941895
#endif
18951896

@@ -2314,11 +2315,12 @@ static void init_loopback(struct net_device *dev)
23142315
static void addrconf_add_linklocal(struct inet6_dev *idev, struct in6_addr *addr)
23152316
{
23162317
struct inet6_ifaddr * ifp;
2318+
struct net *net = dev_net(idev->dev);
23172319
u32 addr_flags = IFA_F_PERMANENT;
23182320

23192321
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
23202322
if (idev->cnf.optimistic_dad &&
2321-
!ipv6_devconf.forwarding)
2323+
!net->ipv6.devconf_all->forwarding)
23222324
addr_flags |= IFA_F_OPTIMISTIC;
23232325
#endif
23242326

net/ipv6/anycast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, struct in6_addr *addr)
6060
struct inet6_dev *idev;
6161
struct ipv6_ac_socklist *pac;
6262
struct net *net = sock_net(sk);
63-
int ishost = !ipv6_devconf.forwarding;
63+
int ishost = !net->ipv6.devconf_all->forwarding;
6464
int err = 0;
6565

6666
if (!capable(CAP_NET_ADMIN))

net/ipv6/exthdrs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
319319
int n, i;
320320
struct ipv6_rt_hdr *hdr;
321321
struct rt0_hdr *rthdr;
322-
int accept_source_route = ipv6_devconf.accept_source_route;
322+
int accept_source_route = dev_net(skb->dev)->ipv6.devconf_all->accept_source_route;
323323

324324
idev = in6_dev_get(skb->dev);
325325
if (idev) {

net/ipv6/ip6_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ int ip6_mc_input(struct sk_buff *skb)
249249
/*
250250
* IPv6 multicast router mode is now supported ;)
251251
*/
252-
if (ipv6_devconf.mc_forwarding &&
252+
if (dev_net(skb->dev)->ipv6.devconf_all->mc_forwarding &&
253253
likely(!(IP6CB(skb)->flags & IP6SKB_FORWARDED))) {
254254
/*
255255
* Okay, we try to forward - split and duplicate

net/ipv6/ip6_output.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ int ip6_forward(struct sk_buff *skb)
411411
struct inet6_skb_parm *opt = IP6CB(skb);
412412
struct net *net = dev_net(dst->dev);
413413

414-
if (ipv6_devconf.forwarding == 0)
414+
if (net->ipv6.devconf_all->forwarding == 0)
415415
goto error;
416416

417417
if (skb_warn_if_lro(skb))
@@ -458,7 +458,7 @@ int ip6_forward(struct sk_buff *skb)
458458
}
459459

460460
/* XXX: idev->cnf.proxy_ndp? */
461-
if (ipv6_devconf.proxy_ndp &&
461+
if (net->ipv6.devconf_all->proxy_ndp &&
462462
pneigh_lookup(&nd_tbl, net, &hdr->daddr, skb->dev, 0)) {
463463
int proxied = ip6_forward_proxy_check(skb);
464464
if (proxied > 0)

net/ipv6/ipv6_sockglue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
10381038
dst_release(dst);
10391039
}
10401040
if (val < 0)
1041-
val = ipv6_devconf.hop_limit;
1041+
val = sock_net(sk)->ipv6.devconf_all->hop_limit;
10421042
break;
10431043
}
10441044

net/ipv6/mcast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static int ip6_mc_leave_src(struct sock *sk, struct ipv6_mc_socklist *iml,
151151
#define IGMP6_UNSOLICITED_IVAL (10*HZ)
152152
#define MLD_QRV_DEFAULT 2
153153

154-
#define MLD_V1_SEEN(idev) (ipv6_devconf.force_mld_version == 1 || \
154+
#define MLD_V1_SEEN(idev) (dev_net((idev)->dev)->ipv6.devconf_all->force_mld_version == 1 || \
155155
(idev)->cnf.force_mld_version == 1 || \
156156
((idev)->mc_v1_seen && \
157157
time_before(jiffies, (idev)->mc_v1_seen)))

net/ipv6/ndisc.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -784,15 +784,17 @@ static void ndisc_recv_ns(struct sk_buff *skb)
784784

785785
idev = ifp->idev;
786786
} else {
787+
struct net *net = dev_net(dev);
788+
787789
idev = in6_dev_get(dev);
788790
if (!idev) {
789791
/* XXX: count this drop? */
790792
return;
791793
}
792794

793-
if (ipv6_chk_acast_addr(dev_net(dev), dev, &msg->target) ||
795+
if (ipv6_chk_acast_addr(net, dev, &msg->target) ||
794796
(idev->cnf.forwarding &&
795-
(ipv6_devconf.proxy_ndp || idev->cnf.proxy_ndp) &&
797+
(net->ipv6.devconf_all->proxy_ndp || idev->cnf.proxy_ndp) &&
796798
(is_router = pndisc_is_router(&msg->target, dev)) >= 0)) {
797799
if (!(NEIGH_CB(skb)->flags & LOCALLY_ENQUEUED) &&
798800
skb->pkt_type != PACKET_HOST &&
@@ -921,6 +923,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
921923

922924
if (neigh) {
923925
u8 old_flags = neigh->flags;
926+
struct net *net = dev_net(dev);
924927

925928
if (neigh->nud_state & NUD_FAILED)
926929
goto out;
@@ -931,8 +934,8 @@ static void ndisc_recv_na(struct sk_buff *skb)
931934
* has already sent a NA to us.
932935
*/
933936
if (lladdr && !memcmp(lladdr, dev->dev_addr, dev->addr_len) &&
934-
ipv6_devconf.forwarding && ipv6_devconf.proxy_ndp &&
935-
pneigh_lookup(&nd_tbl, dev_net(dev), &msg->target, dev, 0)) {
937+
net->ipv6.devconf_all->forwarding && net->ipv6.devconf_all->proxy_ndp &&
938+
pneigh_lookup(&nd_tbl, net, &msg->target, dev, 0)) {
936939
/* XXX: idev->cnf.prixy_ndp */
937940
goto out;
938941
}

net/ipv6/route.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
676676
int strict = 0;
677677
int attempts = 3;
678678
int err;
679-
int reachable = ipv6_devconf.forwarding ? 0 : RT6_LOOKUP_F_REACHABLE;
679+
int reachable = net->ipv6.devconf_all->forwarding ? 0 : RT6_LOOKUP_F_REACHABLE;
680680

681681
strict |= flags & RT6_LOOKUP_F_IFACE;
682682

@@ -1058,7 +1058,7 @@ int ip6_dst_hoplimit(struct dst_entry *dst)
10581058
hoplimit = idev->cnf.hop_limit;
10591059
in6_dev_put(idev);
10601060
} else
1061-
hoplimit = ipv6_devconf.hop_limit;
1061+
hoplimit = dev_net(dev)->ipv6.devconf_all->hop_limit;
10621062
}
10631063
return hoplimit;
10641064
}

0 commit comments

Comments
 (0)