From: Patrick McHardy <kaber@trash.net>
To: jamal <hadi@cyberus.ca>
Cc: Maillist netdev <netdev@oss.sgi.com>
Subject: [PATCH PKT_SCHED 14/17]: Clean up pedit action
Date: Thu, 30 Dec 2004 04:40:56 +0100 [thread overview]
Message-ID: <41D378C8.9070808@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 50 bytes --]
Clean up pedit action, same as for gact and ipt.
[-- Attachment #2: 14.diff --]
[-- Type: text/x-patch, Size: 4461 bytes --]
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2004/12/30 03:44:02+01:00 kaber@coreworks.de
# [PKT_SCHED]: Clean up pedit action
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
# net/sched/pedit.c
# 2004/12/30 03:43:55+01:00 kaber@coreworks.de +25 -41
# [PKT_SCHED]: Clean up pedit action
#
# Signed-off-by: Patrick McHardy <kaber@trash.net>
#
diff -Nru a/net/sched/pedit.c b/net/sched/pedit.c
--- a/net/sched/pedit.c 2004-12-30 04:01:56 +01:00
+++ b/net/sched/pedit.c 2004-12-30 04:01:56 +01:00
@@ -54,36 +54,30 @@
static int
-tcf_pedit_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,int ovr, int bind)
+tcf_pedit_init(struct rtattr *rta, struct rtattr *est, struct tc_action *a,
+ int ovr, int bind)
{
struct rtattr *tb[TCA_PEDIT_MAX];
struct tc_pedit *parm;
int size = 0;
int ret = 0;
- struct tcf_pedit *p = NULL;
+ struct tcf_pedit *p;
if (rtattr_parse(tb, TCA_PEDIT_MAX, RTA_DATA(rta), RTA_PAYLOAD(rta)) < 0)
return -1;
-
- if (NULL == a || NULL == tb[TCA_PEDIT_PARMS - 1]) {
+ if (a == NULL || tb[TCA_PEDIT_PARMS - 1] == NULL) {
printk("BUG: tcf_pedit_init called with NULL params\n");
return -1;
}
parm = RTA_DATA(tb[TCA_PEDIT_PARMS - 1]);
-
p = tcf_hash_check(parm, a, ovr, bind);
-
- if (NULL == p) { /* new */
-
+ if (p == NULL) { /* new */
if (!parm->nkeys)
return -1;
-
- size = sizeof (*p)+ (parm->nkeys*sizeof(struct tc_pedit_key));
-
- p = tcf_hash_create(parm,est,a,size,ovr,bind);
-
- if (NULL == p)
+ size = sizeof(*p) + parm->nkeys * sizeof(struct tc_pedit_key);
+ p = tcf_hash_create(parm, est, a, size, ovr, bind);
+ if (p == NULL)
return -1;
ret = 1;
goto override;
@@ -94,7 +88,8 @@
p->flags = parm->flags;
p->nkeys = parm->nkeys;
p->action = parm->action;
- memcpy(p->keys,parm->keys,parm->nkeys*(sizeof(struct tc_pedit_key)));
+ memcpy(p->keys, parm->keys,
+ parm->nkeys * sizeof(struct tc_pedit_key));
}
return ret;
@@ -103,27 +98,22 @@
static int
tcf_pedit_cleanup(struct tc_action *a, int bind)
{
- struct tcf_pedit *p;
- p = PRIV(a,pedit);
+ struct tcf_pedit *p = PRIV(a,pedit);
+
if (NULL != p)
- return tcf_hash_release(p, bind);
+ return tcf_hash_release(p, bind);
return 0;
}
-/*
-**
-*/
static int
tcf_pedit(struct sk_buff **pskb, struct tc_action *a)
{
- struct tcf_pedit *p;
+ struct tcf_pedit *p = PRIV(a, pedit);
struct sk_buff *skb = *pskb;
int i, munged = 0;
u8 *pptr;
- p = PRIV(a,pedit);
-
- if (NULL == p) {
+ if (p == NULL) {
printk("BUG: tcf_pedit called with NULL params\n");
return -1; /* change to something symbolic */
}
@@ -141,11 +131,11 @@
p->tm.lastuse = jiffies;
- if (0 < p->nkeys) {
+ if (p->nkeys > 0) {
struct tc_pedit_key *tkey = p->keys;
for (i = p->nkeys; i > 0; i--, tkey++) {
- u32 *ptr ;
+ u32 *ptr;
int offset = tkey->off;
if (tkey->offmask) {
@@ -168,7 +158,6 @@
goto bad;
}
-
ptr = (u32 *)(pptr+offset);
/* just do it, baby */
*ptr = ((*ptr & tkey->mask) ^ tkey->val);
@@ -196,29 +185,24 @@
{
unsigned char *b = skb->tail;
struct tc_pedit *opt;
- struct tcf_pedit *p;
+ struct tcf_pedit *p = PRIV(a, pedit);
struct tcf_t t;
int s;
-
- p = PRIV(a,pedit);
-
- if (NULL == p) {
+ if (p == NULL) {
printk("BUG: tcf_pedit_dump called with NULL params\n");
goto rtattr_failure;
}
- s = sizeof (*opt)+(p->nkeys*sizeof(struct tc_pedit_key));
+ s = sizeof(*opt) + p->nkeys * sizeof(struct tc_pedit_key);
- /* netlink spinlocks held above us - must use ATOMIC
- * */
+ /* netlink spinlocks held above us - must use ATOMIC */
opt = kmalloc(s, GFP_ATOMIC);
if (opt == NULL)
return -ENOBUFS;
-
memset(opt, 0, s);
- memcpy(opt->keys,p->keys,p->nkeys*(sizeof(struct tc_pedit_key)));
+ memcpy(opt->keys, p->keys, p->nkeys * sizeof(struct tc_pedit_key));
opt->index = p->index;
opt->nkeys = p->nkeys;
opt->flags = p->flags;
@@ -239,15 +223,15 @@
(unsigned int)key->off,
(unsigned int)key->val,
(unsigned int)key->mask);
- }
- }
+ }
+ }
#endif
RTA_PUT(skb, TCA_PEDIT_PARMS, s, opt);
t.install = jiffies_to_clock_t(jiffies - p->tm.install);
t.lastuse = jiffies_to_clock_t(jiffies - p->tm.lastuse);
t.expires = jiffies_to_clock_t(p->tm.expires);
- RTA_PUT(skb, TCA_PEDIT_TM, sizeof (t), &t);
+ RTA_PUT(skb, TCA_PEDIT_TM, sizeof(t), &t);
return skb->len;
rtattr_failure:
reply other threads:[~2004-12-30 3:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41D378C8.9070808@trash.net \
--to=kaber@trash.net \
--cc=hadi@cyberus.ca \
--cc=netdev@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).