Skip to content

Commit c68f24c

Browse files
Eric Dumazetdavem330
authored andcommitted
ipv6: RCU changes in ipv6_get_mtu() and ip6_dst_hoplimit()
Use RCU to avoid atomic ops on idev refcnt in ipv6_get_mtu() and ip6_dst_hoplimit() Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Acked-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f6bc7d9 commit c68f24c

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

net/ipv6/route.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,11 +1084,11 @@ static int ipv6_get_mtu(struct net_device *dev)
10841084
int mtu = IPV6_MIN_MTU;
10851085
struct inet6_dev *idev;
10861086

1087-
idev = in6_dev_get(dev);
1088-
if (idev) {
1087+
rcu_read_lock();
1088+
idev = __in6_dev_get(dev);
1089+
if (idev)
10891090
mtu = idev->cnf.mtu6;
1090-
in6_dev_put(idev);
1091-
}
1091+
rcu_read_unlock();
10921092
return mtu;
10931093
}
10941094

@@ -1097,12 +1097,15 @@ int ip6_dst_hoplimit(struct dst_entry *dst)
10971097
int hoplimit = dst_metric(dst, RTAX_HOPLIMIT);
10981098
if (hoplimit < 0) {
10991099
struct net_device *dev = dst->dev;
1100-
struct inet6_dev *idev = in6_dev_get(dev);
1101-
if (idev) {
1100+
struct inet6_dev *idev;
1101+
1102+
rcu_read_lock();
1103+
idev = __in6_dev_get(dev);
1104+
if (idev)
11021105
hoplimit = idev->cnf.hop_limit;
1103-
in6_dev_put(idev);
1104-
} else
1106+
else
11051107
hoplimit = dev_net(dev)->ipv6.devconf_all->hop_limit;
1108+
rcu_read_unlock();
11061109
}
11071110
return hoplimit;
11081111
}

0 commit comments

Comments
 (0)