Skip to content

Commit 52cff74

Browse files
anishdavem330
authored andcommitted
dcbnl : Disable software interrupts before taking dcb_lock
Solves possible lockup issues that can be seen from firmware DCB agents calling into the DCB app api. DCB firmware event queues can be tied in with NAPI so that dcb events are generated in softIRQ context. This can results in calls to dcb_*app() functions which try to take the dcb_lock. If the the event triggers while we also have the dcb_lock because lldpad or some other agent happened to be issuing a get/set command we could see a cpu lockup. This code was not originally written with firmware agents in mind, hence grabbing dcb_lock from softIRQ context was not considered. Signed-off-by: Anish Bhatt <anish@chelsio.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 8c2dd54 commit 52cff74

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

‎net/dcb/dcbnl.c‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,13 +1080,13 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
10801080
if (!app)
10811081
return -EMSGSIZE;
10821082

1083-
spin_lock(&dcb_lock);
1083+
spin_lock_bh(&dcb_lock);
10841084
list_for_each_entry(itr, &dcb_app_list, list) {
10851085
if (itr->ifindex == netdev->ifindex) {
10861086
err = nla_put(skb, DCB_ATTR_IEEE_APP, sizeof(itr->app),
10871087
&itr->app);
10881088
if (err) {
1089-
spin_unlock(&dcb_lock);
1089+
spin_unlock_bh(&dcb_lock);
10901090
return -EMSGSIZE;
10911091
}
10921092
}
@@ -1097,7 +1097,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
10971097
else
10981098
dcbx = -EOPNOTSUPP;
10991099

1100-
spin_unlock(&dcb_lock);
1100+
spin_unlock_bh(&dcb_lock);
11011101
nla_nest_end(skb, app);
11021102

11031103
/* get peer info if available */
@@ -1234,7 +1234,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
12341234
}
12351235

12361236
/* local app */
1237-
spin_lock(&dcb_lock);
1237+
spin_lock_bh(&dcb_lock);
12381238
app = nla_nest_start(skb, DCB_ATTR_CEE_APP_TABLE);
12391239
if (!app)
12401240
goto dcb_unlock;
@@ -1271,7 +1271,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
12711271
else
12721272
dcbx = -EOPNOTSUPP;
12731273

1274-
spin_unlock(&dcb_lock);
1274+
spin_unlock_bh(&dcb_lock);
12751275

12761276
/* features flags */
12771277
if (ops->getfeatcfg) {
@@ -1326,7 +1326,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
13261326
return 0;
13271327

13281328
dcb_unlock:
1329-
spin_unlock(&dcb_lock);
1329+
spin_unlock_bh(&dcb_lock);
13301330
nla_put_failure:
13311331
return err;
13321332
}
@@ -1762,10 +1762,10 @@ u8 dcb_getapp(struct net_device *dev, struct dcb_app *app)
17621762
struct dcb_app_type *itr;
17631763
u8 prio = 0;
17641764

1765-
spin_lock(&dcb_lock);
1765+
spin_lock_bh(&dcb_lock);
17661766
if ((itr = dcb_app_lookup(app, dev->ifindex, 0)))
17671767
prio = itr->app.priority;
1768-
spin_unlock(&dcb_lock);
1768+
spin_unlock_bh(&dcb_lock);
17691769

17701770
return prio;
17711771
}
@@ -1789,7 +1789,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
17891789
if (dev->dcbnl_ops->getdcbx)
17901790
event.dcbx = dev->dcbnl_ops->getdcbx(dev);
17911791

1792-
spin_lock(&dcb_lock);
1792+
spin_lock_bh(&dcb_lock);
17931793
/* Search for existing match and replace */
17941794
if ((itr = dcb_app_lookup(new, dev->ifindex, 0))) {
17951795
if (new->priority)
@@ -1804,7 +1804,7 @@ int dcb_setapp(struct net_device *dev, struct dcb_app *new)
18041804
if (new->priority)
18051805
err = dcb_app_add(new, dev->ifindex);
18061806
out:
1807-
spin_unlock(&dcb_lock);
1807+
spin_unlock_bh(&dcb_lock);
18081808
if (!err)
18091809
call_dcbevent_notifiers(DCB_APP_EVENT, &event);
18101810
return err;
@@ -1823,10 +1823,10 @@ u8 dcb_ieee_getapp_mask(struct net_device *dev, struct dcb_app *app)
18231823
struct dcb_app_type *itr;
18241824
u8 prio = 0;
18251825

1826-
spin_lock(&dcb_lock);
1826+
spin_lock_bh(&dcb_lock);
18271827
if ((itr = dcb_app_lookup(app, dev->ifindex, 0)))
18281828
prio |= 1 << itr->app.priority;
1829-
spin_unlock(&dcb_lock);
1829+
spin_unlock_bh(&dcb_lock);
18301830

18311831
return prio;
18321832
}
@@ -1850,7 +1850,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
18501850
if (dev->dcbnl_ops->getdcbx)
18511851
event.dcbx = dev->dcbnl_ops->getdcbx(dev);
18521852

1853-
spin_lock(&dcb_lock);
1853+
spin_lock_bh(&dcb_lock);
18541854
/* Search for existing match and abort if found */
18551855
if (dcb_app_lookup(new, dev->ifindex, new->priority)) {
18561856
err = -EEXIST;
@@ -1859,7 +1859,7 @@ int dcb_ieee_setapp(struct net_device *dev, struct dcb_app *new)
18591859

18601860
err = dcb_app_add(new, dev->ifindex);
18611861
out:
1862-
spin_unlock(&dcb_lock);
1862+
spin_unlock_bh(&dcb_lock);
18631863
if (!err)
18641864
call_dcbevent_notifiers(DCB_APP_EVENT, &event);
18651865
return err;
@@ -1882,15 +1882,15 @@ int dcb_ieee_delapp(struct net_device *dev, struct dcb_app *del)
18821882
if (dev->dcbnl_ops->getdcbx)
18831883
event.dcbx = dev->dcbnl_ops->getdcbx(dev);
18841884

1885-
spin_lock(&dcb_lock);
1885+
spin_lock_bh(&dcb_lock);
18861886
/* Search for existing match and remove it. */
18871887
if ((itr = dcb_app_lookup(del, dev->ifindex, del->priority))) {
18881888
list_del(&itr->list);
18891889
kfree(itr);
18901890
err = 0;
18911891
}
18921892

1893-
spin_unlock(&dcb_lock);
1893+
spin_unlock_bh(&dcb_lock);
18941894
if (!err)
18951895
call_dcbevent_notifiers(DCB_APP_EVENT, &event);
18961896
return err;
@@ -1902,12 +1902,12 @@ static void dcb_flushapp(void)
19021902
struct dcb_app_type *app;
19031903
struct dcb_app_type *tmp;
19041904

1905-
spin_lock(&dcb_lock);
1905+
spin_lock_bh(&dcb_lock);
19061906
list_for_each_entry_safe(app, tmp, &dcb_app_list, list) {
19071907
list_del(&app->list);
19081908
kfree(app);
19091909
}
1910-
spin_unlock(&dcb_lock);
1910+
spin_unlock_bh(&dcb_lock);
19111911
}
19121912

19131913
static int __init dcbnl_init(void)

0 commit comments

Comments
 (0)