Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 34617
b: refs/heads/master
c: 75bff8f
h: refs/heads/master
i:
  34615: cb8bf07
v: v3
  • Loading branch information
YOSHIFUJI Hideaki authored and David S. Miller committed Sep 22, 2006
1 parent bfc565e commit 2982de9
Show file tree
Hide file tree
Showing 6 changed files with 35 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: 2cc67cc731d9b693a08e781e98fec0e3a6d6ba44
refs/heads/master: 75bff8f023e02b045a8f68f36fa7da98dca124b8
2 changes: 1 addition & 1 deletion trunk/include/linux/fib_rules.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ enum
FRA_UNUSED3,
FRA_UNUSED4,
FRA_UNUSED5,
FRA_FWMARK, /* netfilter mark (IPv4) */
FRA_FWMARK, /* netfilter mark (IPv4/IPv6) */
FRA_FLOW, /* flow/class id */
FRA_UNUSED6,
FRA_UNUSED7,
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/net/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct flowi {
struct {
struct in6_addr daddr;
struct in6_addr saddr;
__u32 fwmark;
__u32 flowlabel;
} ip6_u;

Expand All @@ -42,6 +43,7 @@ struct flowi {
#define fld_scope nl_u.dn_u.scope
#define fl6_dst nl_u.ip6_u.daddr
#define fl6_src nl_u.ip6_u.saddr
#define fl6_fwmark nl_u.ip6_u.fwmark
#define fl6_flowlabel nl_u.ip6_u.flowlabel
#define fl4_dst nl_u.ip4_u.daddr
#define fl4_src nl_u.ip4_u.saddr
Expand Down
7 changes: 7 additions & 0 deletions trunk/net/ipv6/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,10 @@ config IPV6_MULTIPLE_TABLES
---help---
Support multiple routing tables.

config IPV6_ROUTE_FWMARK
bool "IPv6: use netfilter MARK value as routing key"
depends on IPV6_MULTIPLE_TABLES && NETFILTER
---help---
If you say Y here, you will be able to specify different routes for
packets with different mark values (see iptables(8), MARK target).

23 changes: 23 additions & 0 deletions trunk/net/ipv6/fib6_rules.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ struct fib6_rule
struct fib_rule common;
struct rt6key src;
struct rt6key dst;
#ifdef CONFIG_IPV6_ROUTE_FWMARK
u8 fwmark;
#endif
u8 tclass;
};

Expand Down Expand Up @@ -124,6 +127,11 @@ static int fib6_rule_match(struct fib_rule *rule, struct flowi *fl, int flags)
if (r->tclass && r->tclass != ((ntohl(fl->fl6_flowlabel) >> 20) & 0xff))
return 0;

#ifdef CONFIG_IPV6_ROUTE_FWMARK
if (r->fwmark && (r->fwmark != fl->fl6_fwmark))
return 0;
#endif

return 1;
}

Expand Down Expand Up @@ -164,6 +172,11 @@ static int fib6_rule_configure(struct fib_rule *rule, struct sk_buff *skb,
nla_memcpy(&rule6->dst.addr, tb[FRA_DST],
sizeof(struct in6_addr));

#ifdef CONFIG_IPV6_ROUTE_FWMARK
if (tb[FRA_FWMARK])
rule6->fwmark = nla_get_u32(tb[FRA_FWMARK]);
#endif

rule6->src.plen = frh->src_len;
rule6->dst.plen = frh->dst_len;
rule6->tclass = frh->tos;
Expand Down Expand Up @@ -195,6 +208,11 @@ static int fib6_rule_compare(struct fib_rule *rule, struct fib_rule_hdr *frh,
nla_memcmp(tb[FRA_DST], &rule6->dst.addr, sizeof(struct in6_addr)))
return 0;

#ifdef CONFIG_IPV6_ROUTE_FWMARK
if (tb[FRA_FWMARK] && (rule6->fwmark != nla_get_u32(tb[FRA_FWMARK])))
return 0;
#endif

return 1;
}

Expand All @@ -216,6 +234,11 @@ static int fib6_rule_fill(struct fib_rule *rule, struct sk_buff *skb,
NLA_PUT(skb, FRA_SRC, sizeof(struct in6_addr),
&rule6->src.addr);

#ifdef CONFIG_IPV6_ROUTE_FWMARK
if (rule6->fwmark)
NLA_PUT_U32(skb, FRA_FWMARK, rule6->fwmark);
#endif

return 0;

nla_put_failure:
Expand Down
1 change: 1 addition & 0 deletions trunk/net/ipv6/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ void ip6_route_input(struct sk_buff *skb)
.ip6_u = {
.daddr = iph->daddr,
.saddr = iph->saddr,
.fwmark = skb->nfmark,
.flowlabel = (* (u32 *) iph)&IPV6_FLOWINFO_MASK,
},
},
Expand Down

0 comments on commit 2982de9

Please sign in to comment.