Commit 2d5f6a8d authored by Peilin Ye's avatar Peilin Ye Committed by Paolo Abeni

net/sched: Refactor qdisc_graft() for ingress and clsact Qdiscs

Grafting ingress and clsact Qdiscs does not need a for-loop in
qdisc_graft().  Refactor it.  No functional changes intended.
Tested-by: default avatarPedro Tammela <pctammela@mojatatu.com>
Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: default avatarVlad Buslov <vladbu@nvidia.com>
Signed-off-by: default avatarPeilin Ye <peilin.ye@bytedance.com>
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parent 41f2c7c3
...@@ -1079,12 +1079,12 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, ...@@ -1079,12 +1079,12 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
if (parent == NULL) { if (parent == NULL) {
unsigned int i, num_q, ingress; unsigned int i, num_q, ingress;
struct netdev_queue *dev_queue;
ingress = 0; ingress = 0;
num_q = dev->num_tx_queues; num_q = dev->num_tx_queues;
if ((q && q->flags & TCQ_F_INGRESS) || if ((q && q->flags & TCQ_F_INGRESS) ||
(new && new->flags & TCQ_F_INGRESS)) { (new && new->flags & TCQ_F_INGRESS)) {
num_q = 1;
ingress = 1; ingress = 1;
if (!dev_ingress_queue(dev)) { if (!dev_ingress_queue(dev)) {
NL_SET_ERR_MSG(extack, "Device does not have an ingress queue"); NL_SET_ERR_MSG(extack, "Device does not have an ingress queue");
...@@ -1100,18 +1100,18 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, ...@@ -1100,18 +1100,18 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
if (new && new->ops->attach && !ingress) if (new && new->ops->attach && !ingress)
goto skip; goto skip;
for (i = 0; i < num_q; i++) { if (!ingress) {
struct netdev_queue *dev_queue = dev_ingress_queue(dev); for (i = 0; i < num_q; i++) {
if (!ingress)
dev_queue = netdev_get_tx_queue(dev, i); dev_queue = netdev_get_tx_queue(dev, i);
old = dev_graft_qdisc(dev_queue, new);
old = dev_graft_qdisc(dev_queue, new); if (new && i > 0)
if (new && i > 0) qdisc_refcount_inc(new);
qdisc_refcount_inc(new);
if (!ingress)
qdisc_put(old); qdisc_put(old);
}
} else {
dev_queue = dev_ingress_queue(dev);
old = dev_graft_qdisc(dev_queue, new);
} }
skip: skip:
......
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