Commit 9da93ece authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

net: sched: refactor grafting Qdiscs with a parent

The code for grafting Qdiscs when there is a parent has two needless
indentation levels, and breaks the "keep the success path unindented"
guideline.  Refactor.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarJohn Hurley <john.hurley@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bfaee911
...@@ -1007,7 +1007,6 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, ...@@ -1007,7 +1007,6 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
{ {
struct Qdisc *q = old; struct Qdisc *q = old;
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
int err = 0;
if (parent == NULL) { if (parent == NULL) {
unsigned int i, num_q, ingress; unsigned int i, num_q, ingress;
...@@ -1062,28 +1061,29 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, ...@@ -1062,28 +1061,29 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent,
dev_activate(dev); dev_activate(dev);
} else { } else {
const struct Qdisc_class_ops *cops = parent->ops->cl_ops; const struct Qdisc_class_ops *cops = parent->ops->cl_ops;
unsigned long cl;
int err;
/* Only support running class lockless if parent is lockless */ /* Only support running class lockless if parent is lockless */
if (new && (new->flags & TCQ_F_NOLOCK) && if (new && (new->flags & TCQ_F_NOLOCK) &&
parent && !(parent->flags & TCQ_F_NOLOCK)) parent && !(parent->flags & TCQ_F_NOLOCK))
new->flags &= ~TCQ_F_NOLOCK; new->flags &= ~TCQ_F_NOLOCK;
err = -EOPNOTSUPP; if (!cops || !cops->graft)
if (cops && cops->graft) { return -EOPNOTSUPP;
unsigned long cl = cops->find(parent, classid);
if (cl) { cl = cops->find(parent, classid);
err = cops->graft(parent, cl, new, &old, if (!cl) {
extack);
} else {
NL_SET_ERR_MSG(extack, "Specified class not found"); NL_SET_ERR_MSG(extack, "Specified class not found");
err = -ENOENT; return -ENOENT;
}
} }
if (!err)
err = cops->graft(parent, cl, new, &old, extack);
if (err)
return err;
notify_and_destroy(net, skb, n, classid, old, new); notify_and_destroy(net, skb, n, classid, old, new);
} }
return err; return 0;
} }
static int qdisc_block_indexes_set(struct Qdisc *sch, struct nlattr **tca, static int qdisc_block_indexes_set(struct Qdisc *sch, struct nlattr **tca,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment