git://ftp.safe.ca
/
safe
/
jmp
/
linux-2.6
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[NETFILTER]: Add partial checksum validation helper
[safe/jmp/linux-2.6]
/
net
/
sched
/
cls_fw.c
diff --git
a/net/sched/cls_fw.c
b/net/sched/cls_fw.c
index
a1a9f4d
..
b0f90e5
100644
(file)
--- a/
net/sched/cls_fw.c
+++ b/
net/sched/cls_fw.c
@@
-47,7
+47,7
@@
struct fw_filter
struct tcf_exts exts;
};
struct tcf_exts exts;
};
-static struct tcf_ext_map fw_ext_map = {
+static
const
struct tcf_ext_map fw_ext_map = {
.action = TCA_FW_ACT,
.police = TCA_FW_POLICE
};
.action = TCA_FW_ACT,
.police = TCA_FW_POLICE
};
@@
-186,6
+186,12
@@
out:
return -EINVAL;
}
return -EINVAL;
}
+static const struct nla_policy fw_policy[TCA_FW_MAX + 1] = {
+ [TCA_FW_CLASSID] = { .type = NLA_U32 },
+ [TCA_FW_INDEV] = { .type = NLA_STRING, .len = IFNAMSIZ },
+ [TCA_FW_MASK] = { .type = NLA_U32 },
+};
+
static int
fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
struct nlattr **tb, struct nlattr **tca, unsigned long base)
static int
fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
struct nlattr **tb, struct nlattr **tca, unsigned long base)
@@
-201,9
+207,7
@@
fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
err = -EINVAL;
if (tb[TCA_FW_CLASSID]) {
err = -EINVAL;
if (tb[TCA_FW_CLASSID]) {
- if (nla_len(tb[TCA_FW_CLASSID]) != sizeof(u32))
- goto errout;
- f->res.classid = *(u32*)nla_data(tb[TCA_FW_CLASSID]);
+ f->res.classid = nla_get_u32(tb[TCA_FW_CLASSID]);
tcf_bind_filter(tp, &f->res, base);
}
tcf_bind_filter(tp, &f->res, base);
}
@@
-216,9
+220,7
@@
fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
#endif /* CONFIG_NET_CLS_IND */
if (tb[TCA_FW_MASK]) {
#endif /* CONFIG_NET_CLS_IND */
if (tb[TCA_FW_MASK]) {
- if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32))
- goto errout;
- mask = *(u32*)nla_data(tb[TCA_FW_MASK]);
+ mask = nla_get_u32(tb[TCA_FW_MASK]);
if (mask != head->mask)
goto errout;
} else if (head->mask != 0xFFFFFFFF)
if (mask != head->mask)
goto errout;
} else if (head->mask != 0xFFFFFFFF)
@@
-246,7
+248,7
@@
static int fw_change(struct tcf_proto *tp, unsigned long base,
if (!opt)
return handle ? -EINVAL : 0;
if (!opt)
return handle ? -EINVAL : 0;
- err = nla_parse_nested(tb, TCA_FW_MAX, opt,
NULL
);
+ err = nla_parse_nested(tb, TCA_FW_MAX, opt,
fw_policy
);
if (err < 0)
return err;
if (err < 0)
return err;
@@
-261,11
+263,8
@@
static int fw_change(struct tcf_proto *tp, unsigned long base,
if (head == NULL) {
u32 mask = 0xFFFFFFFF;
if (head == NULL) {
u32 mask = 0xFFFFFFFF;
- if (tb[TCA_FW_MASK]) {
- if (nla_len(tb[TCA_FW_MASK]) != sizeof(u32))
- return -EINVAL;
- mask = *(u32*)nla_data(tb[TCA_FW_MASK]);
- }
+ if (tb[TCA_FW_MASK])
+ mask = nla_get_u32(tb[TCA_FW_MASK]);
head = kzalloc(sizeof(struct fw_head), GFP_KERNEL);
if (head == NULL)
head = kzalloc(sizeof(struct fw_head), GFP_KERNEL);
if (head == NULL)
@@
-334,7
+333,7
@@
static int fw_dump(struct tcf_proto *tp, unsigned long fh,
struct fw_head *head = (struct fw_head *)tp->root;
struct fw_filter *f = (struct fw_filter*)fh;
unsigned char *b = skb_tail_pointer(skb);
struct fw_head *head = (struct fw_head *)tp->root;
struct fw_filter *f = (struct fw_filter*)fh;
unsigned char *b = skb_tail_pointer(skb);
- struct nlattr *n
la
;
+ struct nlattr *n
est
;
if (f == NULL)
return skb->len;
if (f == NULL)
return skb->len;
@@
-344,22
+343,23
@@
static int fw_dump(struct tcf_proto *tp, unsigned long fh,
if (!f->res.classid && !tcf_exts_is_available(&f->exts))
return skb->len;
if (!f->res.classid && !tcf_exts_is_available(&f->exts))
return skb->len;
- nla = (struct nlattr*)b;
- NLA_PUT(skb, TCA_OPTIONS, 0, NULL);
+ nest = nla_nest_start(skb, TCA_OPTIONS);
+ if (nest == NULL)
+ goto nla_put_failure;
if (f->res.classid)
if (f->res.classid)
- NLA_PUT
(skb, TCA_FW_CLASSID, 4, &
f->res.classid);
+ NLA_PUT
_U32(skb, TCA_FW_CLASSID,
f->res.classid);
#ifdef CONFIG_NET_CLS_IND
if (strlen(f->indev))
#ifdef CONFIG_NET_CLS_IND
if (strlen(f->indev))
- NLA_PUT
(skb, TCA_FW_INDEV, IFNAMSIZ
, f->indev);
+ NLA_PUT
_STRING(skb, TCA_FW_INDEV
, f->indev);
#endif /* CONFIG_NET_CLS_IND */
if (head->mask != 0xFFFFFFFF)
#endif /* CONFIG_NET_CLS_IND */
if (head->mask != 0xFFFFFFFF)
- NLA_PUT
(skb, TCA_FW_MASK, 4, &
head->mask);
+ NLA_PUT
_U32(skb, TCA_FW_MASK,
head->mask);
if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0)
goto nla_put_failure;
if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0)
goto nla_put_failure;
- nla
->nla_len = skb_tail_pointer(skb) - b
;
+ nla
_nest_end(skb, nest)
;
if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0)
goto nla_put_failure;
if (tcf_exts_dump_stats(skb, &f->exts, &fw_ext_map) < 0)
goto nla_put_failure;