Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34630
b: refs/heads/master
c: b4e9b52
h: refs/heads/master
v: v3
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Sep 22, 2006
1 parent 31eb62d commit aa30e72
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 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: 88e91f290307d22ae88302e3a24f0c36905e8a6c
refs/heads/master: b4e9b520ca5d07a37ea59648e7f50f478e7487a3
1 change: 1 addition & 0 deletions trunk/include/linux/pkt_cls.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ enum
TCA_FW_POLICE,
TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
TCA_FW_MASK,
__TCA_FW_MAX
};

Expand Down
25 changes: 24 additions & 1 deletion trunk/net/sched/cls_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
struct fw_head
{
struct fw_filter *ht[HTSIZE];
u32 mask;
};

struct fw_filter
Expand Down Expand Up @@ -101,7 +102,7 @@ static int fw_classify(struct sk_buff *skb, struct tcf_proto *tp,
struct fw_filter *f;
int r;
#ifdef CONFIG_NETFILTER
u32 id = skb->nfmark;
u32 id = skb->nfmark & head->mask;
#else
u32 id = 0;
#endif
Expand Down Expand Up @@ -209,7 +210,9 @@ static int
fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
struct rtattr **tb, struct rtattr **tca, unsigned long base)
{
struct fw_head *head = (struct fw_head *)tp->root;
struct tcf_exts e;
u32 mask;
int err;

err = tcf_exts_validate(tp, tb, tca[TCA_RATE-1], &e, &fw_ext_map);
Expand All @@ -232,6 +235,15 @@ fw_change_attrs(struct tcf_proto *tp, struct fw_filter *f,
}
#endif /* CONFIG_NET_CLS_IND */

if (tb[TCA_FW_MASK-1]) {
if (RTA_PAYLOAD(tb[TCA_FW_MASK-1]) != sizeof(u32))
goto errout;
mask = *(u32*)RTA_DATA(tb[TCA_FW_MASK-1]);
if (mask != head->mask)
goto errout;
} else if (head->mask != 0xFFFFFFFF)
goto errout;

tcf_exts_change(tp, &f->exts, &e);

return 0;
Expand Down Expand Up @@ -267,9 +279,17 @@ static int fw_change(struct tcf_proto *tp, unsigned long base,
return -EINVAL;

if (head == NULL) {
u32 mask = 0xFFFFFFFF;
if (tb[TCA_FW_MASK-1]) {
if (RTA_PAYLOAD(tb[TCA_FW_MASK-1]) != sizeof(u32))
return -EINVAL;
mask = *(u32*)RTA_DATA(tb[TCA_FW_MASK-1]);
}

head = kzalloc(sizeof(struct fw_head), GFP_KERNEL);
if (head == NULL)
return -ENOBUFS;
head->mask = mask;

tcf_tree_lock(tp);
tp->root = head;
Expand Down Expand Up @@ -330,6 +350,7 @@ static void fw_walk(struct tcf_proto *tp, struct tcf_walker *arg)
static int fw_dump(struct tcf_proto *tp, unsigned long fh,
struct sk_buff *skb, struct tcmsg *t)
{
struct fw_head *head = (struct fw_head *)tp->root;
struct fw_filter *f = (struct fw_filter*)fh;
unsigned char *b = skb->tail;
struct rtattr *rta;
Expand All @@ -351,6 +372,8 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
if (strlen(f->indev))
RTA_PUT(skb, TCA_FW_INDEV, IFNAMSIZ, f->indev);
#endif /* CONFIG_NET_CLS_IND */
if (head->mask != 0xFFFFFFFF)
RTA_PUT(skb, TCA_FW_MASK, 4, &head->mask);

if (tcf_exts_dump(skb, &f->exts, &fw_ext_map) < 0)
goto rtattr_failure;
Expand Down

0 comments on commit aa30e72

Please sign in to comment.