Skip to content

Commit 154f4fb

Browse files
committed
Merge branch 'Fix-issues-in-tc-taprio-and-tc-cbs'
Vladimir Oltean says: ==================== Fix issues in tc-taprio and tc-cbs This series fixes one panic and one WARN_ON found in the tc-taprio qdisc, while trying to apply it: - On an interface which is not multi-queue - On an interface which has no carrier The tc-cbs was also visually found to suffer of the same issue as tc-taprio, and the fix was only compile-tested in that case. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 5f81d54 + 1c6c09a commit 154f4fb

File tree

2 files changed

+28
-22
lines changed

2 files changed

+28
-22
lines changed

net/sched/sch_cbs.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,6 @@ static struct sk_buff *cbs_dequeue_soft(struct Qdisc *sch)
181181
s64 credits;
182182
int len;
183183

184-
if (atomic64_read(&q->port_rate) == -1) {
185-
WARN_ONCE(1, "cbs: dequeue() called with unknown port rate.");
186-
return NULL;
187-
}
188-
189184
if (q->credits < 0) {
190185
credits = timediff_to_credits(now - q->last, q->idleslope);
191186

@@ -303,11 +298,19 @@ static int cbs_enable_offload(struct net_device *dev, struct cbs_sched_data *q,
303298
static void cbs_set_port_rate(struct net_device *dev, struct cbs_sched_data *q)
304299
{
305300
struct ethtool_link_ksettings ecmd;
301+
int speed = SPEED_10;
306302
int port_rate = -1;
303+
int err;
304+
305+
err = __ethtool_get_link_ksettings(dev, &ecmd);
306+
if (err < 0)
307+
goto skip;
308+
309+
if (ecmd.base.speed != SPEED_UNKNOWN)
310+
speed = ecmd.base.speed;
307311

308-
if (!__ethtool_get_link_ksettings(dev, &ecmd) &&
309-
ecmd.base.speed != SPEED_UNKNOWN)
310-
port_rate = ecmd.base.speed * 1000 * BYTES_PER_KBIT;
312+
skip:
313+
port_rate = speed * 1000 * BYTES_PER_KBIT;
311314

312315
atomic64_set(&q->port_rate, port_rate);
313316
netdev_dbg(dev, "cbs: set %s's port_rate to: %lld, linkspeed: %d\n",

net/sched/sch_taprio.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -477,11 +477,6 @@ static struct sk_buff *taprio_dequeue(struct Qdisc *sch)
477477
u32 gate_mask;
478478
int i;
479479

480-
if (atomic64_read(&q->picos_per_byte) == -1) {
481-
WARN_ONCE(1, "taprio: dequeue() called with unknown picos per byte.");
482-
return NULL;
483-
}
484-
485480
rcu_read_lock();
486481
entry = rcu_dereference(q->current_entry);
487482
/* if there's no entry, it means that the schedule didn't
@@ -958,12 +953,20 @@ static void taprio_set_picos_per_byte(struct net_device *dev,
958953
struct taprio_sched *q)
959954
{
960955
struct ethtool_link_ksettings ecmd;
961-
int picos_per_byte = -1;
956+
int speed = SPEED_10;
957+
int picos_per_byte;
958+
int err;
962959

963-
if (!__ethtool_get_link_ksettings(dev, &ecmd) &&
964-
ecmd.base.speed != SPEED_UNKNOWN)
965-
picos_per_byte = div64_s64(NSEC_PER_SEC * 1000LL * 8,
966-
ecmd.base.speed * 1000 * 1000);
960+
err = __ethtool_get_link_ksettings(dev, &ecmd);
961+
if (err < 0)
962+
goto skip;
963+
964+
if (ecmd.base.speed != SPEED_UNKNOWN)
965+
speed = ecmd.base.speed;
966+
967+
skip:
968+
picos_per_byte = div64_s64(NSEC_PER_SEC * 1000LL * 8,
969+
speed * 1000 * 1000);
967970

968971
atomic64_set(&q->picos_per_byte, picos_per_byte);
969972
netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
@@ -1249,6 +1252,10 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
12491252
*/
12501253
q->clockid = -1;
12511254

1255+
spin_lock(&taprio_list_lock);
1256+
list_add(&q->taprio_list, &taprio_list);
1257+
spin_unlock(&taprio_list_lock);
1258+
12521259
if (sch->parent != TC_H_ROOT)
12531260
return -EOPNOTSUPP;
12541261

@@ -1266,10 +1273,6 @@ static int taprio_init(struct Qdisc *sch, struct nlattr *opt,
12661273
if (!opt)
12671274
return -EINVAL;
12681275

1269-
spin_lock(&taprio_list_lock);
1270-
list_add(&q->taprio_list, &taprio_list);
1271-
spin_unlock(&taprio_list_lock);
1272-
12731276
for (i = 0; i < dev->num_tx_queues; i++) {
12741277
struct netdev_queue *dev_queue;
12751278
struct Qdisc *qdisc;

0 commit comments

Comments
 (0)