[IPV6] ROUTE: Routing by FWMARK.
Based on patch by Jean Lorchat <lorchat@sfc.wide.ad.jp>.
Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c
index 91f6233..aebd9e2 100644
--- a/net/ipv6/fib6_rules.c
+++ b/net/ipv6/fib6_rules.c
@@ -26,6 +26,9 @@
struct fib_rule common;
struct rt6key src;
struct rt6key dst;
+#ifdef CONFIG_IPV6_ROUTE_FWMARK
+ u8 fwmark;
+#endif
u8 tclass;
};
@@ -124,6 +127,11 @@
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;
}
@@ -164,6 +172,11 @@
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;
@@ -195,6 +208,11 @@
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;
}
@@ -216,6 +234,11 @@
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: