summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2021-11-19 07:43:32 -0800
committerDavid S. Miller <davem@davemloft.net>2021-11-22 12:49:42 +0000
commit6d872df3e3b91532b142de9044e5b4984017a55f (patch)
tree65f08dd7fd68e0584c00a3fb74077be873070a33 /net
parent4b66d2161b8125b6caa6971815e85631cf3cf36f (diff)
net: annotate accesses to dev->gso_max_segs
dev->gso_max_segs is written under RTNL protection, or when the device is not yet visible, but is read locklessly. Add netif_set_gso_max_segs() helper. Add the READ_ONCE()/WRITE_ONCE() pairs, and use netif_set_gso_max_segs() where we can to better document what is going on. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/8021q/vlan.c2
-rw-r--r--net/8021q/vlan_dev.c2
-rw-r--r--net/bridge/br_if.c2
-rw-r--r--net/core/dev.c2
-rw-r--r--net/core/rtnetlink.c4
-rw-r--r--net/core/sock.c3
6 files changed, 8 insertions, 7 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 34c0ffa81e5f..0c00200c9cb2 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -323,7 +323,7 @@ static void vlan_transfer_features(struct net_device *dev,
struct vlan_dev_priv *vlan = vlan_dev_priv(vlandev);
netif_set_gso_max_size(vlandev, dev->gso_max_size);
- vlandev->gso_max_segs = dev->gso_max_segs;
+ netif_set_gso_max_segs(vlandev, dev->gso_max_segs);
if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto))
vlandev->hard_header_len = dev->hard_header_len;
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 208f6845f6dd..e9499a7c19fe 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -574,7 +574,7 @@ static int vlan_dev_init(struct net_device *dev)
dev->features |= dev->hw_features | NETIF_F_LLTX;
netif_set_gso_max_size(dev, real_dev->gso_max_size);
- dev->gso_max_segs = real_dev->gso_max_segs;
+ netif_set_gso_max_segs(dev, real_dev->gso_max_segs);
if (dev->features & NETIF_F_VLAN_FEATURES)
netdev_warn(real_dev, "VLAN features are set incorrectly. Q-in-Q configurations may not work correctly.\n");
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index d3e1c2276551..3915832a03c2 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -526,7 +526,7 @@ static void br_set_gso_limits(struct net_bridge *br)
gso_max_segs = min(gso_max_segs, p->dev->gso_max_segs);
}
netif_set_gso_max_size(br->dev, gso_max_size);
- br->dev->gso_max_segs = gso_max_segs;
+ netif_set_gso_max_segs(br->dev, gso_max_segs);
}
/*
diff --git a/net/core/dev.c b/net/core/dev.c
index 9219e319e901..9c4fc8c3f981 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3396,7 +3396,7 @@ static netdev_features_t gso_features_check(const struct sk_buff *skb,
{
u16 gso_segs = skb_shinfo(skb)->gso_segs;
- if (gso_segs > dev->gso_max_segs)
+ if (gso_segs > READ_ONCE(dev->gso_max_segs))
return features & ~NETIF_F_GSO_MASK;
if (!skb_shinfo(skb)->gso_type) {
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 2af8aeeadadf..fd030e02f16d 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2768,7 +2768,7 @@ static int do_setlink(const struct sk_buff *skb,
}
if (dev->gso_max_segs ^ max_segs) {
- dev->gso_max_segs = max_segs;
+ netif_set_gso_max_segs(dev, max_segs);
status |= DO_SETLINK_MODIFIED;
}
}
@@ -3222,7 +3222,7 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname,
if (tb[IFLA_GSO_MAX_SIZE])
netif_set_gso_max_size(dev, nla_get_u32(tb[IFLA_GSO_MAX_SIZE]));
if (tb[IFLA_GSO_MAX_SEGS])
- dev->gso_max_segs = nla_get_u32(tb[IFLA_GSO_MAX_SEGS]);
+ netif_set_gso_max_segs(dev, nla_get_u32(tb[IFLA_GSO_MAX_SEGS]));
return dev;
}
diff --git a/net/core/sock.c b/net/core/sock.c
index 4418e2a07c34..31a2b79c9b38 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2259,7 +2259,8 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM;
/* pairs with the WRITE_ONCE() in netif_set_gso_max_size() */
sk->sk_gso_max_size = READ_ONCE(dst->dev->gso_max_size);
- max_segs = max_t(u32, dst->dev->gso_max_segs, 1);
+ /* pairs with the WRITE_ONCE() in netif_set_gso_max_segs() */
+ max_segs = max_t(u32, READ_ONCE(dst->dev->gso_max_segs), 1);
}
}
sk->sk_gso_max_segs = max_segs;