Skip to content

Commit a10fa20

Browse files
jpirkodavem330
authored andcommitted
net: sched: propagate q and parent from caller down to tcf_fill_node
The callers have this info, they will pass it down to tcf_fill_node. Signed-off-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 74e3be6 commit a10fa20

1 file changed

Lines changed: 35 additions & 20 deletions

File tree

‎net/sched/cls_api.c‎

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ static struct tcf_proto *tcf_chain_tp_find(struct tcf_chain *chain,
420420
}
421421

422422
static int tcf_fill_node(struct net *net, struct sk_buff *skb,
423-
struct tcf_proto *tp, void *fh, u32 portid,
424-
u32 seq, u16 flags, int event)
423+
struct tcf_proto *tp, struct Qdisc *q, u32 parent,
424+
void *fh, u32 portid, u32 seq, u16 flags, int event)
425425
{
426426
struct tcmsg *tcm;
427427
struct nlmsghdr *nlh;
@@ -434,8 +434,8 @@ static int tcf_fill_node(struct net *net, struct sk_buff *skb,
434434
tcm->tcm_family = AF_UNSPEC;
435435
tcm->tcm__pad1 = 0;
436436
tcm->tcm__pad2 = 0;
437-
tcm->tcm_ifindex = qdisc_dev(tp->q)->ifindex;
438-
tcm->tcm_parent = tp->classid;
437+
tcm->tcm_ifindex = qdisc_dev(q)->ifindex;
438+
tcm->tcm_parent = parent;
439439
tcm->tcm_info = TC_H_MAKE(tp->prio, tp->protocol);
440440
if (nla_put_string(skb, TCA_KIND, tp->ops->kind))
441441
goto nla_put_failure;
@@ -458,6 +458,7 @@ static int tcf_fill_node(struct net *net, struct sk_buff *skb,
458458

459459
static int tfilter_notify(struct net *net, struct sk_buff *oskb,
460460
struct nlmsghdr *n, struct tcf_proto *tp,
461+
struct Qdisc *q, u32 parent,
461462
void *fh, int event, bool unicast)
462463
{
463464
struct sk_buff *skb;
@@ -467,7 +468,7 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb,
467468
if (!skb)
468469
return -ENOBUFS;
469470

470-
if (tcf_fill_node(net, skb, tp, fh, portid, n->nlmsg_seq,
471+
if (tcf_fill_node(net, skb, tp, q, parent, fh, portid, n->nlmsg_seq,
471472
n->nlmsg_flags, event) <= 0) {
472473
kfree_skb(skb);
473474
return -EINVAL;
@@ -482,6 +483,7 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb,
482483

483484
static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
484485
struct nlmsghdr *n, struct tcf_proto *tp,
486+
struct Qdisc *q, u32 parent,
485487
void *fh, bool unicast, bool *last)
486488
{
487489
struct sk_buff *skb;
@@ -492,7 +494,7 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
492494
if (!skb)
493495
return -ENOBUFS;
494496

495-
if (tcf_fill_node(net, skb, tp, fh, portid, n->nlmsg_seq,
497+
if (tcf_fill_node(net, skb, tp, q, parent, fh, portid, n->nlmsg_seq,
496498
n->nlmsg_flags, RTM_DELTFILTER) <= 0) {
497499
kfree_skb(skb);
498500
return -EINVAL;
@@ -512,14 +514,15 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,
512514
}
513515

514516
static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb,
517+
struct Qdisc *q, u32 parent,
515518
struct nlmsghdr *n,
516519
struct tcf_chain *chain, int event)
517520
{
518521
struct tcf_proto *tp;
519522

520523
for (tp = rtnl_dereference(chain->filter_chain);
521524
tp; tp = rtnl_dereference(tp->next))
522-
tfilter_notify(net, oskb, n, tp, 0, event, false);
525+
tfilter_notify(net, oskb, n, tp, q, parent, 0, event, false);
523526
}
524527

525528
/* Add/change/delete/get a filter node */
@@ -638,7 +641,8 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
638641
}
639642

640643
if (n->nlmsg_type == RTM_DELTFILTER && prio == 0) {
641-
tfilter_notify_chain(net, skb, n, chain, RTM_DELTFILTER);
644+
tfilter_notify_chain(net, skb, q, parent, n,
645+
chain, RTM_DELTFILTER);
642646
tcf_chain_flush(chain);
643647
err = 0;
644648
goto errout;
@@ -685,7 +689,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
685689
if (!fh) {
686690
if (n->nlmsg_type == RTM_DELTFILTER && t->tcm_handle == 0) {
687691
tcf_chain_tp_remove(chain, &chain_info, tp);
688-
tfilter_notify(net, skb, n, tp, fh,
692+
tfilter_notify(net, skb, n, tp, q, parent, fh,
689693
RTM_DELTFILTER, false);
690694
tcf_proto_destroy(tp);
691695
err = 0;
@@ -710,8 +714,8 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
710714
}
711715
break;
712716
case RTM_DELTFILTER:
713-
err = tfilter_del_notify(net, skb, n, tp, fh, false,
714-
&last);
717+
err = tfilter_del_notify(net, skb, n, tp, q, parent,
718+
fh, false, &last);
715719
if (err)
716720
goto errout;
717721
if (last) {
@@ -720,7 +724,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
720724
}
721725
goto errout;
722726
case RTM_GETTFILTER:
723-
err = tfilter_notify(net, skb, n, tp, fh,
727+
err = tfilter_notify(net, skb, n, tp, q, parent, fh,
724728
RTM_NEWTFILTER, true);
725729
goto errout;
726730
default:
@@ -734,7 +738,8 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
734738
if (err == 0) {
735739
if (tp_created)
736740
tcf_chain_tp_insert(chain, &chain_info, tp);
737-
tfilter_notify(net, skb, n, tp, fh, RTM_NEWTFILTER, false);
741+
tfilter_notify(net, skb, n, tp, q, parent, fh,
742+
RTM_NEWTFILTER, false);
738743
} else {
739744
if (tp_created)
740745
tcf_proto_destroy(tp);
@@ -753,20 +758,23 @@ struct tcf_dump_args {
753758
struct tcf_walker w;
754759
struct sk_buff *skb;
755760
struct netlink_callback *cb;
761+
struct Qdisc *q;
762+
u32 parent;
756763
};
757764

758765
static int tcf_node_dump(struct tcf_proto *tp, void *n, struct tcf_walker *arg)
759766
{
760767
struct tcf_dump_args *a = (void *)arg;
761768
struct net *net = sock_net(a->skb->sk);
762769

763-
return tcf_fill_node(net, a->skb, tp, n, NETLINK_CB(a->cb->skb).portid,
770+
return tcf_fill_node(net, a->skb, tp, a->q, a->parent,
771+
n, NETLINK_CB(a->cb->skb).portid,
764772
a->cb->nlh->nlmsg_seq, NLM_F_MULTI,
765773
RTM_NEWTFILTER);
766774
}
767775

768-
static bool tcf_chain_dump(struct tcf_chain *chain, struct sk_buff *skb,
769-
struct netlink_callback *cb,
776+
static bool tcf_chain_dump(struct tcf_chain *chain, struct Qdisc *q, u32 parent,
777+
struct sk_buff *skb, struct netlink_callback *cb,
770778
long index_start, long *p_index)
771779
{
772780
struct net *net = sock_net(skb->sk);
@@ -788,7 +796,7 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct sk_buff *skb,
788796
memset(&cb->args[1], 0,
789797
sizeof(cb->args) - sizeof(cb->args[0]));
790798
if (cb->args[1] == 0) {
791-
if (tcf_fill_node(net, skb, tp, 0,
799+
if (tcf_fill_node(net, skb, tp, q, parent, 0,
792800
NETLINK_CB(cb->skb).portid,
793801
cb->nlh->nlmsg_seq, NLM_F_MULTI,
794802
RTM_NEWTFILTER) <= 0)
@@ -801,6 +809,8 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct sk_buff *skb,
801809
arg.w.fn = tcf_node_dump;
802810
arg.skb = skb;
803811
arg.cb = cb;
812+
arg.q = q;
813+
arg.parent = parent;
804814
arg.w.stop = 0;
805815
arg.w.skip = cb->args[1] - 1;
806816
arg.w.count = 0;
@@ -826,6 +836,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
826836
const struct Qdisc_class_ops *cops;
827837
long index_start;
828838
long index;
839+
u32 parent;
829840
int err;
830841

831842
if (nlmsg_len(cb->nlh) < sizeof(*tcm))
@@ -839,10 +850,13 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
839850
if (!dev)
840851
return skb->len;
841852

842-
if (!tcm->tcm_parent)
853+
parent = tcm->tcm_parent;
854+
if (!parent) {
843855
q = dev->qdisc;
844-
else
856+
parent = q->handle;
857+
} else {
845858
q = qdisc_lookup(dev, TC_H_MAJ(tcm->tcm_parent));
859+
}
846860
if (!q)
847861
goto out;
848862
cops = q->ops->cl_ops;
@@ -866,7 +880,8 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
866880
if (tca[TCA_CHAIN] &&
867881
nla_get_u32(tca[TCA_CHAIN]) != chain->index)
868882
continue;
869-
if (!tcf_chain_dump(chain, skb, cb, index_start, &index))
883+
if (!tcf_chain_dump(chain, q, parent, skb, cb,
884+
index_start, &index))
870885
break;
871886
}
872887

0 commit comments

Comments
 (0)