Skip to content

Commit

Permalink
net_sched: make cls_ops->tcf_chain() optional
Browse files Browse the repository at this point in the history
Some qdiscs don't support attaching filters. Handle this centrally in
cls_api and return a proper errno code (EOPNOTSUPP) instead of EINVAL.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Sep 6, 2009
1 parent c9f1d03 commit 71ebe5e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
5 changes: 5 additions & 0 deletions net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
if ((cops = q->ops->cl_ops) == NULL)
return -EINVAL;

if (cops->tcf_chain == NULL)
return -EOPNOTSUPP;

/* Do we search for filter, attached to class? */
if (TC_H_MIN(parent)) {
cl = cops->get(q, parent);
Expand Down Expand Up @@ -433,6 +436,8 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)
goto out;
if ((cops = q->ops->cl_ops) == NULL)
goto errout;
if (cops->tcf_chain == NULL)
goto errout;
if (TC_H_MIN(tcm->tcm_parent)) {
cl = cops->get(q, tcm->tcm_parent);
if (cl == 0)
Expand Down
6 changes: 0 additions & 6 deletions net/sched/sch_red.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,6 @@ static void red_walk(struct Qdisc *sch, struct qdisc_walker *walker)
}
}

static struct tcf_proto **red_find_tcf(struct Qdisc *sch, unsigned long cl)
{
return NULL;
}

static const struct Qdisc_class_ops red_class_ops = {
.graft = red_graft,
.leaf = red_leaf,
Expand All @@ -344,7 +339,6 @@ static const struct Qdisc_class_ops red_class_ops = {
.change = red_change_class,
.delete = red_delete,
.walk = red_walk,
.tcf_chain = red_find_tcf,
.dump = red_dump_class,
};

Expand Down
6 changes: 0 additions & 6 deletions net/sched/sch_tbf.c
Original file line number Diff line number Diff line change
Expand Up @@ -433,11 +433,6 @@ static void tbf_walk(struct Qdisc *sch, struct qdisc_walker *walker)
}
}

static struct tcf_proto **tbf_find_tcf(struct Qdisc *sch, unsigned long cl)
{
return NULL;
}

static const struct Qdisc_class_ops tbf_class_ops =
{
.graft = tbf_graft,
Expand All @@ -447,7 +442,6 @@ static const struct Qdisc_class_ops tbf_class_ops =
.change = tbf_change_class,
.delete = tbf_delete,
.walk = tbf_walk,
.tcf_chain = tbf_find_tcf,
.dump = tbf_dump_class,
};

Expand Down

0 comments on commit 71ebe5e

Please sign in to comment.