Commit 76d2d42c authored by Patrick McHardy's avatar Patrick McHardy Committed by David S. Miller

[PKT_SCHED]: act_api.c: use consistent comparison style

Signed-off-by: default avatarPatrick McHardy <kaber@trash.net>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 91ec3432
...@@ -196,7 +196,7 @@ void tcf_action_destroy(struct tc_action *act, int bind) ...@@ -196,7 +196,7 @@ void tcf_action_destroy(struct tc_action *act, int bind)
DPRINTK("tcf_action_destroy destroying %p next %p\n", DPRINTK("tcf_action_destroy destroying %p next %p\n",
a, a->next ? a->next : NULL); a, a->next ? a->next : NULL);
act = act->next; act = act->next;
if (ACT_P_DELETED == a->ops->cleanup(a, bind)) if (a->ops->cleanup(a, bind) == ACT_P_DELETED)
module_put(a->ops->owner); module_put(a->ops->owner);
a->ops = NULL; a->ops = NULL;
...@@ -220,7 +220,7 @@ tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref) ...@@ -220,7 +220,7 @@ tcf_action_dump_old(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
{ {
int err = -EINVAL; int err = -EINVAL;
if ((NULL == a) || (NULL == a->ops) || (NULL == a->ops->dump)) if ((a == NULL) || (a->ops == NULL) || (a->ops->dump == NULL))
return err; return err;
return a->ops->dump(skb, a, bind, ref); return a->ops->dump(skb, a, bind, ref);
} }
...@@ -232,8 +232,8 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref) ...@@ -232,8 +232,8 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
unsigned char *b = skb->tail; unsigned char *b = skb->tail;
struct rtattr *r; struct rtattr *r;
if ((NULL == a) || (NULL == a->ops) || (NULL == a->ops->dump) || if ((a == NULL) || (a->ops == NULL) || (a->ops->dump == NULL) ||
(NULL == a->ops->kind)) (a->ops->kind == NULL))
return err; return err;
RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind); RTA_PUT(skb, TCA_KIND, IFNAMSIZ, a->ops->kind);
...@@ -264,7 +264,7 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref) ...@@ -264,7 +264,7 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref)
act = a->next; act = a->next;
RTA_PUT(skb, a->order, 0, NULL); RTA_PUT(skb, a->order, 0, NULL);
err = tcf_action_dump_1(skb, a, bind, ref); err = tcf_action_dump_1(skb, a, bind, ref);
if (0 > err) if (err < 0)
goto rtattr_failure; goto rtattr_failure;
r->rta_len = skb->tail - (u8*)r; r->rta_len = skb->tail - (u8*)r;
} }
...@@ -287,12 +287,12 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, ...@@ -287,12 +287,12 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
*err = -EINVAL; *err = -EINVAL;
if (NULL == name) { if (name == NULL) {
if (rtattr_parse(tb, TCA_ACT_MAX, RTA_DATA(rta), if (rtattr_parse(tb, TCA_ACT_MAX, RTA_DATA(rta),
RTA_PAYLOAD(rta)) < 0) RTA_PAYLOAD(rta)) < 0)
goto err_out; goto err_out;
kind = tb[TCA_ACT_KIND-1]; kind = tb[TCA_ACT_KIND-1];
if (NULL != kind) { if (kind != NULL) {
sprintf(act_name, "%s", (char*)RTA_DATA(kind)); sprintf(act_name, "%s", (char*)RTA_DATA(kind));
if (RTA_PAYLOAD(kind) >= IFNAMSIZ) { if (RTA_PAYLOAD(kind) >= IFNAMSIZ) {
printk("Action %s bad\n", printk("Action %s bad\n",
...@@ -310,7 +310,7 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, ...@@ -310,7 +310,7 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
a_o = tc_lookup_action_n(name); a_o = tc_lookup_action_n(name);
} }
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
if (NULL == a_o) { if (a_o == NULL) {
DPRINTK("tcf_action_init_1: trying to load module %s\n", DPRINTK("tcf_action_init_1: trying to load module %s\n",
act_name); act_name);
request_module(act_name); request_module(act_name);
...@@ -318,7 +318,7 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, ...@@ -318,7 +318,7 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
} }
#endif #endif
if (NULL == a_o) { if (a_o == NULL) {
printk("failed to find %s\n", act_name); printk("failed to find %s\n", act_name);
goto err_out; goto err_out;
} }
...@@ -331,7 +331,7 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est, ...@@ -331,7 +331,7 @@ struct tc_action *tcf_action_init_1(struct rtattr *rta, struct rtattr *est,
memset(a, 0, sizeof(*a)); memset(a, 0, sizeof(*a));
/* backward compatibility for policer */ /* backward compatibility for policer */
if (NULL == name) { if (name == NULL) {
*err = a_o->init(tb[TCA_ACT_OPTIONS-1], est, a, ovr, bind); *err = a_o->init(tb[TCA_ACT_OPTIONS-1], est, a, ovr, bind);
if (*err < 0) { if (*err < 0) {
*err = -EINVAL; *err = -EINVAL;
...@@ -414,7 +414,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a) ...@@ -414,7 +414,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a)
/* place holder */ /* place holder */
#endif #endif
if (NULL == h) if (h == NULL)
goto errout; goto errout;
if (a->type == TCA_OLD_COMPAT) if (a->type == TCA_OLD_COMPAT)
...@@ -427,7 +427,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a) ...@@ -427,7 +427,7 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *a)
if (err < 0) if (err < 0)
goto errout; goto errout;
if (NULL != a->ops && NULL != a->ops->get_stats) if (a->ops != NULL && a->ops->get_stats != NULL)
if (a->ops->get_stats(skb, a) < 0) if (a->ops->get_stats(skb, a) < 0)
goto errout; goto errout;
...@@ -464,7 +464,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq, ...@@ -464,7 +464,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
x = (struct rtattr*) skb->tail; x = (struct rtattr*) skb->tail;
RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
if (0 > tcf_action_dump(skb, a, bind, ref)) if (tcf_action_dump(skb, a, bind, ref) < 0)
goto rtattr_failure; goto rtattr_failure;
x->rta_len = skb->tail - (u8*)x; x->rta_len = skb->tail - (u8*)x;
...@@ -510,7 +510,7 @@ static int tcf_action_get_1(struct rtattr *rta, struct tc_action *a, ...@@ -510,7 +510,7 @@ static int tcf_action_get_1(struct rtattr *rta, struct tc_action *a,
if (rtattr_parse(tb, TCA_ACT_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) < 0) if (rtattr_parse(tb, TCA_ACT_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) < 0)
goto err_out; goto err_out;
kind = tb[TCA_ACT_KIND-1]; kind = tb[TCA_ACT_KIND-1];
if (NULL != kind) { if (kind != NULL) {
sprintf(act_name, "%s", (char*)RTA_DATA(kind)); sprintf(act_name, "%s", (char*)RTA_DATA(kind));
if (RTA_PAYLOAD(kind) >= IFNAMSIZ) { if (RTA_PAYLOAD(kind) >= IFNAMSIZ) {
printk("tcf_action_get_1: action %s bad\n", printk("tcf_action_get_1: action %s bad\n",
...@@ -531,21 +531,21 @@ static int tcf_action_get_1(struct rtattr *rta, struct tc_action *a, ...@@ -531,21 +531,21 @@ static int tcf_action_get_1(struct rtattr *rta, struct tc_action *a,
a_o = tc_lookup_action(kind); a_o = tc_lookup_action(kind);
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
if (NULL == a_o) { if (a_o == NULL) {
request_module (act_name); request_module (act_name);
a_o = tc_lookup_action_n(act_name); a_o = tc_lookup_action_n(act_name);
} }
#endif #endif
if (NULL == a_o) { if (a_o == NULL) {
printk("failed to find %s\n", act_name); printk("failed to find %s\n", act_name);
goto err_out; goto err_out;
} }
if (NULL == a) if (a == NULL)
goto err_mod; goto err_mod;
a->ops = a_o; a->ops = a_o;
if (NULL == a_o->lookup || 0 == a_o->lookup(a, index)) { if (a_o->lookup == NULL || a_o->lookup(a, index) == 0) {
a->ops = NULL; a->ops = NULL;
err = -EINVAL; err = -EINVAL;
goto err_mod; goto err_mod;
...@@ -579,7 +579,7 @@ static struct tc_action_ops *get_ao(struct rtattr *kind, struct tc_action *a) ...@@ -579,7 +579,7 @@ static struct tc_action_ops *get_ao(struct rtattr *kind, struct tc_action *a)
char act_name[4 + IFNAMSIZ + 1]; char act_name[4 + IFNAMSIZ + 1];
struct tc_action_ops *a_o = NULL; struct tc_action_ops *a_o = NULL;
if (NULL != kind) { if (kind != NULL) {
sprintf(act_name, "%s", (char*)RTA_DATA(kind)); sprintf(act_name, "%s", (char*)RTA_DATA(kind));
if (RTA_PAYLOAD(kind) >= IFNAMSIZ) { if (RTA_PAYLOAD(kind) >= IFNAMSIZ) {
printk("get_ao: action %s bad\n", printk("get_ao: action %s bad\n",
...@@ -593,14 +593,13 @@ static struct tc_action_ops *get_ao(struct rtattr *kind, struct tc_action *a) ...@@ -593,14 +593,13 @@ static struct tc_action_ops *get_ao(struct rtattr *kind, struct tc_action *a)
a_o = tc_lookup_action(kind); a_o = tc_lookup_action(kind);
#ifdef CONFIG_KMOD #ifdef CONFIG_KMOD
if (NULL == a_o) { if (a_o == NULL) {
DPRINTK("get_ao: trying to load module %s\n", act_name); DPRINTK("get_ao: trying to load module %s\n", act_name);
request_module(act_name); request_module(act_name);
a_o = tc_lookup_action_n(act_name); a_o = tc_lookup_action_n(act_name);
} }
#endif #endif
if (a_o == NULL) {
if (NULL == a_o) {
printk("get_ao: failed to find %s\n", act_name); printk("get_ao: failed to find %s\n", act_name);
return NULL; return NULL;
} }
...@@ -614,7 +613,7 @@ static struct tc_action *create_a(int i) ...@@ -614,7 +613,7 @@ static struct tc_action *create_a(int i)
struct tc_action *act = NULL; struct tc_action *act = NULL;
act = kmalloc(sizeof(*act), GFP_KERNEL); act = kmalloc(sizeof(*act), GFP_KERNEL);
if (NULL == act) { /* grrr .. */ if (act == NULL) {
printk("create_a: failed to alloc!\n"); printk("create_a: failed to alloc!\n");
return NULL; return NULL;
} }
...@@ -636,7 +635,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid) ...@@ -636,7 +635,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
struct tc_action *a = create_a(0); struct tc_action *a = create_a(0);
int err = -EINVAL; int err = -EINVAL;
if (NULL == a) { if (a == NULL) {
printk("tca_action_flush: couldnt create tc_action\n"); printk("tca_action_flush: couldnt create tc_action\n");
return err; return err;
} }
...@@ -654,7 +653,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid) ...@@ -654,7 +653,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
goto err_out; goto err_out;
kind = tb[TCA_ACT_KIND-1]; kind = tb[TCA_ACT_KIND-1];
if (NULL == get_ao(kind, a)) if (get_ao(kind, a) == NULL)
goto err_out; goto err_out;
nlh = NLMSG_PUT(skb, pid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t)); nlh = NLMSG_PUT(skb, pid, n->nlmsg_seq, RTM_DELACTION, sizeof(*t));
...@@ -665,7 +664,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid) ...@@ -665,7 +664,7 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); err = a->ops->walk(skb, &dcb, RTM_DELACTION, a);
if (0 > err) if (err < 0)
goto rtattr_failure; goto rtattr_failure;
x->rta_len = skb->tail - (u8 *) x; x->rta_len = skb->tail - (u8 *) x;
...@@ -680,7 +679,6 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid) ...@@ -680,7 +679,6 @@ static int tca_action_flush(struct rtattr *rta, struct nlmsghdr *n, u32 pid)
return err; return err;
rtattr_failure: rtattr_failure:
module_put(a->ops->owner); module_put(a->ops->owner);
nlmsg_failure: nlmsg_failure:
...@@ -709,15 +707,15 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event) ...@@ -709,15 +707,15 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
} }
if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) {
if (NULL != tb[0] && NULL == tb[1]) if (tb[0] != NULL && tb[1] == NULL)
return tca_action_flush(tb[0], n, pid); return tca_action_flush(tb[0], n, pid);
} }
for (i=0; i < TCA_ACT_MAX_PRIO; i++) { for (i=0; i < TCA_ACT_MAX_PRIO; i++) {
if (NULL == tb[i]) if (tb[i] == NULL)
break; break;
act = create_a(i+1); act = create_a(i+1);
if (NULL != a && a != act) { if (a != NULL && a != act) {
a->next = act; a->next = act;
a = act; a = act;
} else } else
...@@ -736,7 +734,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event) ...@@ -736,7 +734,7 @@ tca_action_gd(struct rtattr *rta, struct nlmsghdr *n, u32 pid, int event)
} }
} }
if (RTM_GETACTION == event) if (event == RTM_GETACTION)
ret = act_get_notify(pid, n, a_s, event); ret = act_get_notify(pid, n, a_s, event);
else { /* delete */ else { /* delete */
struct sk_buff *skb; struct sk_buff *skb;
...@@ -792,7 +790,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event, ...@@ -792,7 +790,7 @@ static int tcf_add_notify(struct tc_action *a, u32 pid, u32 seq, int event,
x = (struct rtattr*) skb->tail; x = (struct rtattr*) skb->tail;
RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
if (0 > tcf_action_dump(skb, a, 0, 0)) if (tcf_action_dump(skb, a, 0, 0) < 0)
goto rtattr_failure; goto rtattr_failure;
x->rta_len = skb->tail - (u8*)x; x->rta_len = skb->tail - (u8*)x;
...@@ -847,7 +845,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg) ...@@ -847,7 +845,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, void *arg)
u32 pid = skb ? NETLINK_CB(skb).pid : 0; u32 pid = skb ? NETLINK_CB(skb).pid : 0;
int ret = 0, ovr = 0; int ret = 0, ovr = 0;
if (NULL == tca[TCA_ACT_TAB-1]) { if (tca[TCA_ACT_TAB-1] == NULL) {
printk("tc_ctl_action: received NO action attribs\n"); printk("tc_ctl_action: received NO action attribs\n");
return -EINVAL; return -EINVAL;
} }
...@@ -894,14 +892,13 @@ find_dump_kind(struct nlmsghdr *n) ...@@ -894,14 +892,13 @@ find_dump_kind(struct nlmsghdr *n)
if (rtattr_parse(rta, TCAA_MAX, attr, attrlen) < 0) if (rtattr_parse(rta, TCAA_MAX, attr, attrlen) < 0)
return NULL; return NULL;
tb1 = rta[TCA_ACT_TAB - 1]; tb1 = rta[TCA_ACT_TAB - 1];
if (NULL == tb1) { if (tb1 == NULL)
return NULL; return NULL;
}
if (rtattr_parse(tb, TCA_ACT_MAX_PRIO, RTA_DATA(tb1), if (rtattr_parse(tb, TCA_ACT_MAX_PRIO, RTA_DATA(tb1),
NLMSG_ALIGN(RTA_PAYLOAD(tb1))) < 0) NLMSG_ALIGN(RTA_PAYLOAD(tb1))) < 0)
return NULL; return NULL;
if (NULL == tb[0]) if (tb[0] == NULL)
return NULL; return NULL;
if (rtattr_parse(tb2, TCA_ACT_MAX, RTA_DATA(tb[0]), if (rtattr_parse(tb2, TCA_ACT_MAX, RTA_DATA(tb[0]),
...@@ -924,13 +921,13 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -924,13 +921,13 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh); struct tcamsg *t = (struct tcamsg *) NLMSG_DATA(cb->nlh);
char *kind = find_dump_kind(cb->nlh); char *kind = find_dump_kind(cb->nlh);
if (NULL == kind) { if (kind == NULL) {
printk("tc_dump_action: action bad kind\n"); printk("tc_dump_action: action bad kind\n");
return 0; return 0;
} }
a_o = tc_lookup_action_n(kind); a_o = tc_lookup_action_n(kind);
if (NULL == a_o) { if (a_o == NULL) {
printk("failed to find %s\n", kind); printk("failed to find %s\n", kind);
return 0; return 0;
} }
...@@ -938,7 +935,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -938,7 +935,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
memset(&a, 0, sizeof(struct tc_action)); memset(&a, 0, sizeof(struct tc_action));
a.ops = a_o; a.ops = a_o;
if (NULL == a_o->walk) { if (a_o->walk == NULL) {
printk("tc_dump_action: %s !capable of dumping table\n", kind); printk("tc_dump_action: %s !capable of dumping table\n", kind);
goto rtattr_failure; goto rtattr_failure;
} }
...@@ -952,7 +949,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -952,7 +949,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
RTA_PUT(skb, TCA_ACT_TAB, 0, NULL); RTA_PUT(skb, TCA_ACT_TAB, 0, NULL);
ret = a_o->walk(skb, cb, RTM_GETACTION, &a); ret = a_o->walk(skb, cb, RTM_GETACTION, &a);
if (0 > ret) if (ret < 0)
goto rtattr_failure; goto rtattr_failure;
if (ret > 0) { if (ret > 0) {
......
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