Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 368678
b: refs/heads/master
c: de179c8
h: refs/heads/master
v: v3
  • Loading branch information
Hong zhi guo authored and David S. Miller committed Mar 26, 2013
1 parent 588e9eb commit 92af722
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8dc57da2e23085642cad20d11385e13e079715c4
refs/heads/master: de179c8c12e9e5a292269fa59e7c26ca797dc7bf
9 changes: 5 additions & 4 deletions trunk/net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,12 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)

if ((n->nlmsg_type != RTM_GETTFILTER) && !capable(CAP_NET_ADMIN))
return -EPERM;

replay:
err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL);
if (err < 0)
return err;

t = nlmsg_data(n);
protocol = TC_H_MIN(t->tcm_info);
prio = TC_H_MAJ(t->tcm_info);
Expand All @@ -164,10 +169,6 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n)
if (dev == NULL)
return -ENODEV;

err = nlmsg_parse(n, sizeof(*t), tca, TCA_MAX, NULL);
if (err < 0)
return err;

/* Find qdisc */
if (!parent) {
q = dev->qdisc;
Expand Down
36 changes: 21 additions & 15 deletions trunk/net/sched/sch_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,22 +977,23 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n)
struct tcmsg *tcm = nlmsg_data(n);
struct nlattr *tca[TCA_MAX + 1];
struct net_device *dev;
u32 clid = tcm->tcm_parent;
u32 clid;
struct Qdisc *q = NULL;
struct Qdisc *p = NULL;
int err;

if ((n->nlmsg_type != RTM_GETQDISC) && !capable(CAP_NET_ADMIN))
return -EPERM;

dev = __dev_get_by_index(net, tcm->tcm_ifindex);
if (!dev)
return -ENODEV;

err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL);
if (err < 0)
return err;

dev = __dev_get_by_index(net, tcm->tcm_ifindex);
if (!dev)
return -ENODEV;

clid = tcm->tcm_parent;
if (clid) {
if (clid != TC_H_ROOT) {
if (TC_H_MAJ(clid) != TC_H_MAJ(TC_H_INGRESS)) {
Expand Down Expand Up @@ -1053,6 +1054,10 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n)

replay:
/* Reinit, just in case something touches this. */
err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL);
if (err < 0)
return err;

tcm = nlmsg_data(n);
clid = tcm->tcm_parent;
q = p = NULL;
Expand All @@ -1061,9 +1066,6 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n)
if (!dev)
return -ENODEV;

err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL);
if (err < 0)
return err;

if (clid) {
if (clid != TC_H_ROOT) {
Expand Down Expand Up @@ -1382,22 +1384,22 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n)
const struct Qdisc_class_ops *cops;
unsigned long cl = 0;
unsigned long new_cl;
u32 portid = tcm->tcm_parent;
u32 clid = tcm->tcm_handle;
u32 qid = TC_H_MAJ(clid);
u32 portid;
u32 clid;
u32 qid;
int err;

if ((n->nlmsg_type != RTM_GETTCLASS) && !capable(CAP_NET_ADMIN))
return -EPERM;

dev = __dev_get_by_index(net, tcm->tcm_ifindex);
if (!dev)
return -ENODEV;

err = nlmsg_parse(n, sizeof(*tcm), tca, TCA_MAX, NULL);
if (err < 0)
return err;

dev = __dev_get_by_index(net, tcm->tcm_ifindex);
if (!dev)
return -ENODEV;

/*
parent == TC_H_UNSPEC - unspecified parent.
parent == TC_H_ROOT - class is root, which has no parent.
Expand All @@ -1413,6 +1415,10 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n)

/* Step 1. Determine qdisc handle X:0 */

portid = tcm->tcm_parent;
clid = tcm->tcm_handle;
qid = TC_H_MAJ(clid);

if (portid != TC_H_ROOT) {
u32 qid1 = TC_H_MAJ(portid);

Expand Down

0 comments on commit 92af722

Please sign in to comment.