sch_api.c (1e7f32f776089af32b6ec9b801fe976778c8448b) sch_api.c (5891cd5ec46c2c2eb6427cb54d214b149635dd0e)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * net/sched/sch_api.c Packet scheduler API.
4 *
5 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
6 *
7 * Fixes:
8 *

--- 287 unchanged lines hidden (view full) ---

296EXPORT_SYMBOL(qdisc_hash_del);
297
298struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
299{
300 struct Qdisc *q;
301
302 if (!handle)
303 return NULL;
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * net/sched/sch_api.c Packet scheduler API.
4 *
5 * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
6 *
7 * Fixes:
8 *

--- 287 unchanged lines hidden (view full) ---

296EXPORT_SYMBOL(qdisc_hash_del);
297
298struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle)
299{
300 struct Qdisc *q;
301
302 if (!handle)
303 return NULL;
304 q = qdisc_match_from_root(dev->qdisc, handle);
304 q = qdisc_match_from_root(rtnl_dereference(dev->qdisc), handle);
305 if (q)
306 goto out;
307
308 if (dev_ingress_queue(dev))
309 q = qdisc_match_from_root(
310 dev_ingress_queue(dev)->qdisc_sleeping,
311 handle);
312out:
313 return q;
314}
315
316struct Qdisc *qdisc_lookup_rcu(struct net_device *dev, u32 handle)
317{
318 struct netdev_queue *nq;
319 struct Qdisc *q;
320
321 if (!handle)
322 return NULL;
305 if (q)
306 goto out;
307
308 if (dev_ingress_queue(dev))
309 q = qdisc_match_from_root(
310 dev_ingress_queue(dev)->qdisc_sleeping,
311 handle);
312out:
313 return q;
314}
315
316struct Qdisc *qdisc_lookup_rcu(struct net_device *dev, u32 handle)
317{
318 struct netdev_queue *nq;
319 struct Qdisc *q;
320
321 if (!handle)
322 return NULL;
323 q = qdisc_match_from_root(dev->qdisc, handle);
323 q = qdisc_match_from_root(rcu_dereference(dev->qdisc), handle);
324 if (q)
325 goto out;
326
327 nq = dev_ingress_queue_rcu(dev);
328 if (nq)
329 q = qdisc_match_from_root(nq->qdisc_sleeping, handle);
330out:
331 return q;

--- 745 unchanged lines hidden (view full) ---

1077
1078 if (!ingress)
1079 qdisc_put(old);
1080 }
1081
1082skip:
1083 if (!ingress) {
1084 notify_and_destroy(net, skb, n, classid,
324 if (q)
325 goto out;
326
327 nq = dev_ingress_queue_rcu(dev);
328 if (nq)
329 q = qdisc_match_from_root(nq->qdisc_sleeping, handle);
330out:
331 return q;

--- 745 unchanged lines hidden (view full) ---

1077
1078 if (!ingress)
1079 qdisc_put(old);
1080 }
1081
1082skip:
1083 if (!ingress) {
1084 notify_and_destroy(net, skb, n, classid,
1085 dev->qdisc, new);
1085 rtnl_dereference(dev->qdisc), new);
1086 if (new && !new->ops->attach)
1087 qdisc_refcount_inc(new);
1086 if (new && !new->ops->attach)
1087 qdisc_refcount_inc(new);
1088 dev->qdisc = new ? : &noop_qdisc;
1088 rcu_assign_pointer(dev->qdisc, new ? : &noop_qdisc);
1089
1090 if (new && new->ops->attach)
1091 new->ops->attach(new);
1092 } else {
1093 notify_and_destroy(net, skb, n, classid, old, new);
1094 }
1095
1096 if (dev->flags & IFF_UP)

--- 349 unchanged lines hidden (view full) ---

1446 NL_SET_ERR_MSG(extack, "Failed to find qdisc with specified classid");
1447 return -ENOENT;
1448 }
1449 q = qdisc_leaf(p, clid);
1450 } else if (dev_ingress_queue(dev)) {
1451 q = dev_ingress_queue(dev)->qdisc_sleeping;
1452 }
1453 } else {
1089
1090 if (new && new->ops->attach)
1091 new->ops->attach(new);
1092 } else {
1093 notify_and_destroy(net, skb, n, classid, old, new);
1094 }
1095
1096 if (dev->flags & IFF_UP)

--- 349 unchanged lines hidden (view full) ---

1446 NL_SET_ERR_MSG(extack, "Failed to find qdisc with specified classid");
1447 return -ENOENT;
1448 }
1449 q = qdisc_leaf(p, clid);
1450 } else if (dev_ingress_queue(dev)) {
1451 q = dev_ingress_queue(dev)->qdisc_sleeping;
1452 }
1453 } else {
1454 q = dev->qdisc;
1454 q = rtnl_dereference(dev->qdisc);
1455 }
1456 if (!q) {
1457 NL_SET_ERR_MSG(extack, "Cannot find specified qdisc on specified device");
1458 return -ENOENT;
1459 }
1460
1461 if (tcm->tcm_handle && q->handle != tcm->tcm_handle) {
1462 NL_SET_ERR_MSG(extack, "Invalid handle");

--- 72 unchanged lines hidden (view full) ---

1535 NL_SET_ERR_MSG(extack, "Failed to find specified qdisc");
1536 return -ENOENT;
1537 }
1538 q = qdisc_leaf(p, clid);
1539 } else if (dev_ingress_queue_create(dev)) {
1540 q = dev_ingress_queue(dev)->qdisc_sleeping;
1541 }
1542 } else {
1455 }
1456 if (!q) {
1457 NL_SET_ERR_MSG(extack, "Cannot find specified qdisc on specified device");
1458 return -ENOENT;
1459 }
1460
1461 if (tcm->tcm_handle && q->handle != tcm->tcm_handle) {
1462 NL_SET_ERR_MSG(extack, "Invalid handle");

--- 72 unchanged lines hidden (view full) ---

1535 NL_SET_ERR_MSG(extack, "Failed to find specified qdisc");
1536 return -ENOENT;
1537 }
1538 q = qdisc_leaf(p, clid);
1539 } else if (dev_ingress_queue_create(dev)) {
1540 q = dev_ingress_queue(dev)->qdisc_sleeping;
1541 }
1542 } else {
1543 q = dev->qdisc;
1543 q = rtnl_dereference(dev->qdisc);
1544 }
1545
1546 /* It may be default qdisc, ignore it */
1547 if (q && q->handle == 0)
1548 q = NULL;
1549
1550 if (!q || !tcm->tcm_handle || q->handle != tcm->tcm_handle) {
1551 if (tcm->tcm_handle) {

--- 205 unchanged lines hidden (view full) ---

1757 struct netdev_queue *dev_queue;
1758
1759 if (idx < s_idx)
1760 goto cont;
1761 if (idx > s_idx)
1762 s_q_idx = 0;
1763 q_idx = 0;
1764
1544 }
1545
1546 /* It may be default qdisc, ignore it */
1547 if (q && q->handle == 0)
1548 q = NULL;
1549
1550 if (!q || !tcm->tcm_handle || q->handle != tcm->tcm_handle) {
1551 if (tcm->tcm_handle) {

--- 205 unchanged lines hidden (view full) ---

1757 struct netdev_queue *dev_queue;
1758
1759 if (idx < s_idx)
1760 goto cont;
1761 if (idx > s_idx)
1762 s_q_idx = 0;
1763 q_idx = 0;
1764
1765 if (tc_dump_qdisc_root(dev->qdisc, skb, cb, &q_idx, s_q_idx,
1765 if (tc_dump_qdisc_root(rtnl_dereference(dev->qdisc),
1766 skb, cb, &q_idx, s_q_idx,
1766 true, tca[TCA_DUMP_INVISIBLE]) < 0)
1767 goto done;
1768
1769 dev_queue = dev_ingress_queue(dev);
1770 if (dev_queue &&
1771 tc_dump_qdisc_root(dev_queue->qdisc_sleeping, skb, cb,
1772 &q_idx, s_q_idx, false,
1773 tca[TCA_DUMP_INVISIBLE]) < 0)

--- 254 unchanged lines hidden (view full) ---

2028
2029 if (qid && qid1) {
2030 /* If both majors are known, they must be identical. */
2031 if (qid != qid1)
2032 return -EINVAL;
2033 } else if (qid1) {
2034 qid = qid1;
2035 } else if (qid == 0)
1767 true, tca[TCA_DUMP_INVISIBLE]) < 0)
1768 goto done;
1769
1770 dev_queue = dev_ingress_queue(dev);
1771 if (dev_queue &&
1772 tc_dump_qdisc_root(dev_queue->qdisc_sleeping, skb, cb,
1773 &q_idx, s_q_idx, false,
1774 tca[TCA_DUMP_INVISIBLE]) < 0)

--- 254 unchanged lines hidden (view full) ---

2029
2030 if (qid && qid1) {
2031 /* If both majors are known, they must be identical. */
2032 if (qid != qid1)
2033 return -EINVAL;
2034 } else if (qid1) {
2035 qid = qid1;
2036 } else if (qid == 0)
2036 qid = dev->qdisc->handle;
2037 qid = rtnl_dereference(dev->qdisc)->handle;
2037
2038 /* Now qid is genuine qdisc handle consistent
2039 * both with parent and child.
2040 *
2041 * TC_H_MAJ(portid) still may be unspecified, complete it now.
2042 */
2043 if (portid)
2044 portid = TC_H_MAKE(qid, portid);
2045 } else {
2046 if (qid == 0)
2038
2039 /* Now qid is genuine qdisc handle consistent
2040 * both with parent and child.
2041 *
2042 * TC_H_MAJ(portid) still may be unspecified, complete it now.
2043 */
2044 if (portid)
2045 portid = TC_H_MAKE(qid, portid);
2046 } else {
2047 if (qid == 0)
2047 qid = dev->qdisc->handle;
2048 qid = rtnl_dereference(dev->qdisc)->handle;
2048 }
2049
2050 /* OK. Locate qdisc */
2051 q = qdisc_lookup(dev, qid);
2052 if (!q)
2053 return -ENOENT;
2054
2055 /* An check that it supports classes */

--- 144 unchanged lines hidden (view full) ---

2200 return 0;
2201 dev = dev_get_by_index(net, tcm->tcm_ifindex);
2202 if (!dev)
2203 return 0;
2204
2205 s_t = cb->args[0];
2206 t = 0;
2207
2049 }
2050
2051 /* OK. Locate qdisc */
2052 q = qdisc_lookup(dev, qid);
2053 if (!q)
2054 return -ENOENT;
2055
2056 /* An check that it supports classes */

--- 144 unchanged lines hidden (view full) ---

2201 return 0;
2202 dev = dev_get_by_index(net, tcm->tcm_ifindex);
2203 if (!dev)
2204 return 0;
2205
2206 s_t = cb->args[0];
2207 t = 0;
2208
2208 if (tc_dump_tclass_root(dev->qdisc, skb, tcm, cb, &t, s_t, true) < 0)
2209 if (tc_dump_tclass_root(rtnl_dereference(dev->qdisc),
2210 skb, tcm, cb, &t, s_t, true) < 0)
2209 goto done;
2210
2211 dev_queue = dev_ingress_queue(dev);
2212 if (dev_queue &&
2213 tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb,
2214 &t, s_t, false) < 0)
2215 goto done;
2216

--- 80 unchanged lines hidden ---
2211 goto done;
2212
2213 dev_queue = dev_ingress_queue(dev);
2214 if (dev_queue &&
2215 tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb,
2216 &t, s_t, false) < 0)
2217 goto done;
2218

--- 80 unchanged lines hidden ---