Skip to content

Commit 9f780ef

Browse files
committed
Merge branch 'ipv6-devconf-lockless'
Eric Dumazet says: ==================== ipv6: lockless accesses to devconf - First patch puts in a cacheline_group the fields used in fast paths. - Annotate all data races around idev->cnf fields. - Last patch in this series removes RTNL use for RTM_GETNETCONF dumps. v3: addressed Jakub Kicinski feedback in addrconf_disable_ipv6() Added tags from Jiri and Florian. v2: addressed Jiri Pirko feedback - Added "ipv6: addrconf_disable_ipv6() optimizations" and "ipv6: addrconf_disable_policy() optimization" ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 65f5dd4 + 2a02f83 commit 9f780ef

File tree

20 files changed

+245
-229
lines changed

20 files changed

+245
-229
lines changed

drivers/net/ethernet/netronome/nfp/flower/action.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ nfp_fl_set_tun(struct nfp_app *app, struct nfp_fl_set_tun *set_tun,
460460
set_tun->ttl = ip6_dst_hoplimit(dst);
461461
dst_release(dst);
462462
} else {
463-
set_tun->ttl = net->ipv6.devconf_all->hop_limit;
463+
set_tun->ttl = READ_ONCE(net->ipv6.devconf_all->hop_limit);
464464
}
465465
#endif
466466
} else {

drivers/net/usb/cdc_mbim.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static void do_neigh_solicit(struct usbnet *dev, u8 *buf, u16 tci)
339339
in6_dev = in6_dev_get(netdev);
340340
if (!in6_dev)
341341
goto out;
342-
is_router = !!in6_dev->cnf.forwarding;
342+
is_router = !!READ_ONCE(in6_dev->cnf.forwarding);
343343
in6_dev_put(in6_dev);
344344

345345
/* ipv6_stub != NULL if in6_dev_get returned an inet6_dev */

include/linux/ipv6.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@
33
#define _IPV6_H
44

55
#include <uapi/linux/ipv6.h>
6+
#include <linux/cache.h>
67

78
#define ipv6_optlen(p) (((p)->hdrlen+1) << 3)
89
#define ipv6_authlen(p) (((p)->hdrlen+2) << 2)
910
/*
1011
* This structure contains configuration options per IPv6 link.
1112
*/
1213
struct ipv6_devconf {
13-
__s32 forwarding;
14+
/* RX & TX fastpath fields. */
15+
__cacheline_group_begin(ipv6_devconf_read_txrx);
16+
__s32 disable_ipv6;
1417
__s32 hop_limit;
1518
__s32 mtu6;
19+
__s32 forwarding;
20+
__s32 disable_policy;
21+
__s32 proxy_ndp;
22+
__cacheline_group_end(ipv6_devconf_read_txrx);
23+
1624
__s32 accept_ra;
1725
__s32 accept_redirects;
1826
__s32 autoconf;
@@ -45,7 +53,6 @@ struct ipv6_devconf {
4553
__s32 accept_ra_rt_info_max_plen;
4654
#endif
4755
#endif
48-
__s32 proxy_ndp;
4956
__s32 accept_source_route;
5057
__s32 accept_ra_from_local;
5158
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
@@ -55,7 +62,6 @@ struct ipv6_devconf {
5562
#ifdef CONFIG_IPV6_MROUTE
5663
atomic_t mc_forwarding;
5764
#endif
58-
__s32 disable_ipv6;
5965
__s32 drop_unicast_in_l2_multicast;
6066
__s32 accept_dad;
6167
__s32 force_tllao;
@@ -76,7 +82,6 @@ struct ipv6_devconf {
7682
#endif
7783
__u32 enhanced_dad;
7884
__u32 addr_gen_mode;
79-
__s32 disable_policy;
8085
__s32 ndisc_tclass;
8186
__s32 rpl_seg_enabled;
8287
__u32 ioam6_id;

include/net/addrconf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ static inline bool ip6_ignore_linkdown(const struct net_device *dev)
417417
if (unlikely(!idev))
418418
return true;
419419

420-
return !!idev->cnf.ignore_routes_with_linkdown;
420+
return !!READ_ONCE(idev->cnf.ignore_routes_with_linkdown);
421421
}
422422

423423
void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);

include/net/ip6_route.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static inline unsigned int ip6_dst_mtu_maybe_forward(const struct dst_entry *dst
332332
rcu_read_lock();
333333
idev = __in6_dev_get(dst->dev);
334334
if (idev)
335-
mtu = idev->cnf.mtu6;
335+
mtu = READ_ONCE(idev->cnf.mtu6);
336336
rcu_read_unlock();
337337

338338
out:

include/net/ipv6.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,13 +534,15 @@ static inline int ipv6_hopopt_jumbo_remove(struct sk_buff *skb)
534534
return 0;
535535
}
536536

537-
static inline bool ipv6_accept_ra(struct inet6_dev *idev)
537+
static inline bool ipv6_accept_ra(const struct inet6_dev *idev)
538538
{
539+
s32 accept_ra = READ_ONCE(idev->cnf.accept_ra);
540+
539541
/* If forwarding is enabled, RA are not accepted unless the special
540542
* hybrid mode (accept_ra=2) is enabled.
541543
*/
542-
return idev->cnf.forwarding ? idev->cnf.accept_ra == 2 :
543-
idev->cnf.accept_ra;
544+
return READ_ONCE(idev->cnf.forwarding) ? accept_ra == 2 :
545+
accept_ra;
544546
}
545547

546548
#define IPV6_FRAG_HIGH_THRESH (4 * 1024*1024) /* 4194304 */

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5988,7 +5988,7 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
59885988
return -ENODEV;
59895989

59905990
idev = __in6_dev_get_safely(dev);
5991-
if (unlikely(!idev || !idev->cnf.forwarding))
5991+
if (unlikely(!idev || !READ_ONCE(idev->cnf.forwarding)))
59925992
return BPF_FIB_LKUP_RET_FWD_DISABLED;
59935993

59945994
if (flags & BPF_FIB_LOOKUP_OUTPUT) {

0 commit comments

Comments
 (0)