Skip to content

Commit fba917b

Browse files
praveenkaligineedikuba-moo
authored andcommitted
gve: Fix use of netif_carrier_ok()
GVE driver wrongly relies on netif_carrier_ok() to check the interface administrative state when resources are being allocated/deallocated for queue(s). netif_carrier_ok() needs to be replaced with netif_running() for all such cases. Administrative state is the result of "ip link set dev <dev> up/down". It reflects whether the administrator wants to use the device for traffic and the corresponding resources have been allocated. Fixes: 5f08cd3 ("gve: Alloc before freeing when adjusting queues") Signed-off-by: Praveen Kaligineedi <[email protected]> Reviewed-by: Shailend Chand <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 89108cb commit fba917b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

drivers/net/ethernet/google/gve/gve_ethtool.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ static int gve_set_channels(struct net_device *netdev,
495495
return -EINVAL;
496496
}
497497

498-
if (!netif_carrier_ok(netdev)) {
498+
if (!netif_running(netdev)) {
499499
priv->tx_cfg.num_queues = new_tx;
500500
priv->rx_cfg.num_queues = new_rx;
501501
return 0;

drivers/net/ethernet/google/gve/gve_main.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ static int gve_set_xdp(struct gve_priv *priv, struct bpf_prog *prog,
15661566
u32 status;
15671567

15681568
old_prog = READ_ONCE(priv->xdp_prog);
1569-
if (!netif_carrier_ok(priv->dev)) {
1569+
if (!netif_running(priv->dev)) {
15701570
WRITE_ONCE(priv->xdp_prog, prog);
15711571
if (old_prog)
15721572
bpf_prog_put(old_prog);
@@ -1847,7 +1847,7 @@ int gve_adjust_queues(struct gve_priv *priv,
18471847
rx_alloc_cfg.qcfg = &new_rx_config;
18481848
tx_alloc_cfg.num_rings = new_tx_config.num_queues;
18491849

1850-
if (netif_carrier_ok(priv->dev)) {
1850+
if (netif_running(priv->dev)) {
18511851
err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg);
18521852
return err;
18531853
}
@@ -2064,7 +2064,7 @@ static int gve_set_features(struct net_device *netdev,
20642064

20652065
if ((netdev->features & NETIF_F_LRO) != (features & NETIF_F_LRO)) {
20662066
netdev->features ^= NETIF_F_LRO;
2067-
if (netif_carrier_ok(netdev)) {
2067+
if (netif_running(netdev)) {
20682068
err = gve_adjust_config(priv, &tx_alloc_cfg, &rx_alloc_cfg);
20692069
if (err)
20702070
goto revert_features;
@@ -2359,7 +2359,7 @@ static int gve_reset_recovery(struct gve_priv *priv, bool was_up)
23592359

23602360
int gve_reset(struct gve_priv *priv, bool attempt_teardown)
23612361
{
2362-
bool was_up = netif_carrier_ok(priv->dev);
2362+
bool was_up = netif_running(priv->dev);
23632363
int err;
23642364

23652365
dev_info(&priv->pdev->dev, "Performing reset\n");
@@ -2700,7 +2700,7 @@ static void gve_shutdown(struct pci_dev *pdev)
27002700
{
27012701
struct net_device *netdev = pci_get_drvdata(pdev);
27022702
struct gve_priv *priv = netdev_priv(netdev);
2703-
bool was_up = netif_carrier_ok(priv->dev);
2703+
bool was_up = netif_running(priv->dev);
27042704

27052705
rtnl_lock();
27062706
if (was_up && gve_close(priv->dev)) {
@@ -2718,7 +2718,7 @@ static int gve_suspend(struct pci_dev *pdev, pm_message_t state)
27182718
{
27192719
struct net_device *netdev = pci_get_drvdata(pdev);
27202720
struct gve_priv *priv = netdev_priv(netdev);
2721-
bool was_up = netif_carrier_ok(priv->dev);
2721+
bool was_up = netif_running(priv->dev);
27222722

27232723
priv->suspend_cnt++;
27242724
rtnl_lock();

0 commit comments

Comments
 (0)