Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34628
b: refs/heads/master
c: bbfb39c
h: refs/heads/master
v: v3
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Sep 22, 2006
1 parent a966e54 commit 77c62c7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 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: 267935b197d2a6e6924f9de2841f0470bfe63acd
refs/heads/master: bbfb39cbf63829d1db607aa90cbdca557a3a131d
3 changes: 2 additions & 1 deletion trunk/include/linux/fib_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ enum
FRA_UNUSED3,
FRA_UNUSED4,
FRA_UNUSED5,
FRA_FWMARK, /* netfilter mark (IPv4/IPv6) */
FRA_FWMARK, /* netfilter mark */
FRA_FLOW, /* flow/class id */
FRA_UNUSED6,
FRA_UNUSED7,
FRA_UNUSED8,
FRA_TABLE, /* Extended table id */
FRA_FWMASK, /* mask for netfilter mark */
__FRA_MAX
};

Expand Down
21 changes: 19 additions & 2 deletions trunk/net/ipv4/fib_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct fib4_rule
u32 dstmask;
#ifdef CONFIG_IP_ROUTE_FWMARK
u32 fwmark;
u32 fwmask;
#endif
#ifdef CONFIG_NET_CLS_ROUTE
u32 tclassid;
Expand Down Expand Up @@ -160,7 +161,7 @@ static int fib4_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
return 0;

#ifdef CONFIG_IP_ROUTE_FWMARK
if (r->fwmark && (r->fwmark != fl->fl4_fwmark))
if ((r->fwmark ^ fl->fl4_fwmark) & r->fwmask)
return 0;
#endif

Expand All @@ -183,6 +184,7 @@ static struct nla_policy fib4_rule_policy[FRA_MAX+1] __read_mostly = {
[FRA_SRC] = { .type = NLA_U32 },
[FRA_DST] = { .type = NLA_U32 },
[FRA_FWMARK] = { .type = NLA_U32 },
[FRA_FWMASK] = { .type = NLA_U32 },
[FRA_FLOW] = { .type = NLA_U32 },
[FRA_TABLE] = { .type = NLA_U32 },
};
Expand Down Expand Up @@ -219,8 +221,17 @@ static int fib4_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
rule4->dst = nla_get_u32(tb[FRA_DST]);

#ifdef CONFIG_IP_ROUTE_FWMARK
if (tb[FRA_FWMARK])
if (tb[FRA_FWMARK]) {
rule4->fwmark = nla_get_u32(tb[FRA_FWMARK]);
if (rule4->fwmark)
/* compatibility: if the mark value is non-zero all bits
* are compared unless a mask is explicitly specified.
*/
rule4->fwmask = 0xFFFFFFFF;
}

if (tb[FRA_FWMASK])
rule4->fwmask = nla_get_u32(tb[FRA_FWMASK]);
#endif

#ifdef CONFIG_NET_CLS_ROUTE
Expand Down Expand Up @@ -256,6 +267,9 @@ static int fib4_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
#ifdef CONFIG_IP_ROUTE_FWMARK
if (tb[FRA_FWMARK] && (rule4->fwmark != nla_get_u32(tb[FRA_FWMARK])))
return 0;

if (tb[FRA_FWMASK] && (rule4->fwmask != nla_get_u32(tb[FRA_FWMASK])))
return 0;
#endif

#ifdef CONFIG_NET_CLS_ROUTE
Expand Down Expand Up @@ -285,6 +299,9 @@ static int fib4_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
#ifdef CONFIG_IP_ROUTE_FWMARK
if (rule4->fwmark)
NLA_PUT_U32(skb, FRA_FWMARK, rule4->fwmark);

if (rule4->fwmask || rule4->fwmark)
NLA_PUT_U32(skb, FRA_FWMASK, rule4->fwmask);
#endif

if (rule4->dst_len)
Expand Down

0 comments on commit 77c62c7

Please sign in to comment.