Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net/sched: Introduce tc block netdev tracking infra

This commit makes tc blocks track which ports have been added to them.
And, with that, we'll be able to use this new information to send
packets to the block's ports. Which will be done in the patch #3 of this
series.

Suggested-by: Jiri Pirko <jiri@nvidia.com>
Co-developed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
Co-developed-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Victor Nogueira and committed by
David S. Miller
913b47d3 b1dffcf0

+62 -1
+2
include/net/sch_generic.h
··· 19 19 #include <net/gen_stats.h> 20 20 #include <net/rtnetlink.h> 21 21 #include <net/flow_offload.h> 22 + #include <linux/xarray.h> 22 23 23 24 struct Qdisc_ops; 24 25 struct qdisc_walker; ··· 457 456 }; 458 457 459 458 struct tcf_block { 459 + struct xarray ports; /* datapath accessible */ 460 460 /* Lock protects tcf_block and lifetime-management data of chains 461 461 * attached to the block (refcnt, action_refcnt, explicitly_created). 462 462 */
+2
net/sched/cls_api.c
··· 531 531 { 532 532 mutex_destroy(&block->lock); 533 533 mutex_destroy(&block->proto_destroy_lock); 534 + xa_destroy(&block->ports); 534 535 kfree_rcu(block, rcu); 535 536 } 536 537 ··· 1003 1002 refcount_set(&block->refcnt, 1); 1004 1003 block->net = net; 1005 1004 block->index = block_index; 1005 + xa_init(&block->ports); 1006 1006 1007 1007 /* Don't store q pointer for blocks which are shared */ 1008 1008 if (!tcf_block_shared(block))
+41
net/sched/sch_api.c
··· 1180 1180 return 0; 1181 1181 } 1182 1182 1183 + static int qdisc_block_add_dev(struct Qdisc *sch, struct net_device *dev, 1184 + struct netlink_ext_ack *extack) 1185 + { 1186 + const struct Qdisc_class_ops *cl_ops = sch->ops->cl_ops; 1187 + struct tcf_block *block; 1188 + int err; 1189 + 1190 + block = cl_ops->tcf_block(sch, TC_H_MIN_INGRESS, NULL); 1191 + if (block) { 1192 + err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL); 1193 + if (err) { 1194 + NL_SET_ERR_MSG(extack, 1195 + "ingress block dev insert failed"); 1196 + return err; 1197 + } 1198 + } 1199 + 1200 + block = cl_ops->tcf_block(sch, TC_H_MIN_EGRESS, NULL); 1201 + if (block) { 1202 + err = xa_insert(&block->ports, dev->ifindex, dev, GFP_KERNEL); 1203 + if (err) { 1204 + NL_SET_ERR_MSG(extack, 1205 + "Egress block dev insert failed"); 1206 + goto err_out; 1207 + } 1208 + } 1209 + 1210 + return 0; 1211 + 1212 + err_out: 1213 + block = cl_ops->tcf_block(sch, TC_H_MIN_INGRESS, NULL); 1214 + if (block) 1215 + xa_erase(&block->ports, dev->ifindex); 1216 + 1217 + return err; 1218 + } 1219 + 1183 1220 static int qdisc_block_indexes_set(struct Qdisc *sch, struct nlattr **tca, 1184 1221 struct netlink_ext_ack *extack) 1185 1222 { ··· 1386 1349 1387 1350 qdisc_hash_add(sch, false); 1388 1351 trace_qdisc_create(ops, dev, parent); 1352 + 1353 + err = qdisc_block_add_dev(sch, dev, extack); 1354 + if (err) 1355 + goto err_out4; 1389 1356 1390 1357 return sch; 1391 1358
+17 -1
net/sched/sch_generic.c
··· 1051 1051 static void __qdisc_destroy(struct Qdisc *qdisc) 1052 1052 { 1053 1053 const struct Qdisc_ops *ops = qdisc->ops; 1054 + struct net_device *dev = qdisc_dev(qdisc); 1055 + const struct Qdisc_class_ops *cops; 1056 + struct tcf_block *block; 1054 1057 1055 1058 #ifdef CONFIG_NET_SCHED 1056 1059 qdisc_hash_del(qdisc); ··· 1064 1061 1065 1062 qdisc_reset(qdisc); 1066 1063 1064 + cops = ops->cl_ops; 1065 + if (ops->ingress_block_get) { 1066 + block = cops->tcf_block(qdisc, TC_H_MIN_INGRESS, NULL); 1067 + if (block) 1068 + xa_erase(&block->ports, dev->ifindex); 1069 + } 1070 + 1071 + if (ops->egress_block_get) { 1072 + block = cops->tcf_block(qdisc, TC_H_MIN_EGRESS, NULL); 1073 + if (block) 1074 + xa_erase(&block->ports, dev->ifindex); 1075 + } 1076 + 1067 1077 if (ops->destroy) 1068 1078 ops->destroy(qdisc); 1069 1079 1070 1080 module_put(ops->owner); 1071 - netdev_put(qdisc_dev(qdisc), &qdisc->dev_tracker); 1081 + netdev_put(dev, &qdisc->dev_tracker); 1072 1082 1073 1083 trace_qdisc_destroy(qdisc); 1074 1084