Commit ad13b5b0 authored by Eric Dumazet's avatar Eric Dumazet Committed by Paolo Abeni

rtnetlink: do not depend on RTNL for IFLA_TXQLEN output

rtnl_fill_ifinfo() can read dev->tx_queue_len locklessly,
granted we add corresponding READ_ONCE()/WRITE_ONCE() annotations.

Add missing READ_ONCE(dev->tx_queue_len) in teql_enqueue()
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 8a582681
...@@ -8959,7 +8959,7 @@ int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len) ...@@ -8959,7 +8959,7 @@ int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len)
return -ERANGE; return -ERANGE;
if (new_len != orig_len) { if (new_len != orig_len) {
dev->tx_queue_len = new_len; WRITE_ONCE(dev->tx_queue_len, new_len);
res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev); res = call_netdevice_notifiers(NETDEV_CHANGE_TX_QUEUE_LEN, dev);
res = notifier_to_errno(res); res = notifier_to_errno(res);
if (res) if (res)
...@@ -8973,7 +8973,7 @@ int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len) ...@@ -8973,7 +8973,7 @@ int dev_change_tx_queue_len(struct net_device *dev, unsigned long new_len)
err_rollback: err_rollback:
netdev_err(dev, "refused to change device tx_queue_len\n"); netdev_err(dev, "refused to change device tx_queue_len\n");
dev->tx_queue_len = orig_len; WRITE_ONCE(dev->tx_queue_len, orig_len);
return res; return res;
} }
......
...@@ -1837,7 +1837,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, ...@@ -1837,7 +1837,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
if (nla_put_string(skb, IFLA_IFNAME, devname)) if (nla_put_string(skb, IFLA_IFNAME, devname))
goto nla_put_failure; goto nla_put_failure;
if (nla_put_u32(skb, IFLA_TXQLEN, dev->tx_queue_len) || if (nla_put_u32(skb, IFLA_TXQLEN, READ_ONCE(dev->tx_queue_len)) ||
nla_put_u8(skb, IFLA_OPERSTATE, nla_put_u8(skb, IFLA_OPERSTATE,
netif_running(dev) ? dev->operstate : IF_OPER_DOWN) || netif_running(dev) ? dev->operstate : IF_OPER_DOWN) ||
nla_put_u8(skb, IFLA_LINKMODE, dev->link_mode) || nla_put_u8(skb, IFLA_LINKMODE, dev->link_mode) ||
......
...@@ -1334,7 +1334,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev, ...@@ -1334,7 +1334,7 @@ static struct Qdisc *qdisc_create(struct net_device *dev,
* before again attaching a qdisc. * before again attaching a qdisc.
*/ */
if ((dev->priv_flags & IFF_NO_QUEUE) && (dev->tx_queue_len == 0)) { if ((dev->priv_flags & IFF_NO_QUEUE) && (dev->tx_queue_len == 0)) {
dev->tx_queue_len = DEFAULT_TX_QUEUE_LEN; WRITE_ONCE(dev->tx_queue_len, DEFAULT_TX_QUEUE_LEN);
netdev_info(dev, "Caught tx_queue_len zero misconfig\n"); netdev_info(dev, "Caught tx_queue_len zero misconfig\n");
} }
......
...@@ -78,7 +78,7 @@ teql_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free) ...@@ -78,7 +78,7 @@ teql_enqueue(struct sk_buff *skb, struct Qdisc *sch, struct sk_buff **to_free)
struct net_device *dev = qdisc_dev(sch); struct net_device *dev = qdisc_dev(sch);
struct teql_sched_data *q = qdisc_priv(sch); struct teql_sched_data *q = qdisc_priv(sch);
if (q->q.qlen < dev->tx_queue_len) { if (q->q.qlen < READ_ONCE(dev->tx_queue_len)) {
__skb_queue_tail(&q->q, skb); __skb_queue_tail(&q->q, skb);
return NET_XMIT_SUCCESS; return NET_XMIT_SUCCESS;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment