From: Patrick McHardy <kaber@trash.net>
To: "David S. Miller" <davem@davemloft.net>
Cc: Linux Netdev List <netdev@vger.kernel.org>, patrick@tykepenguin.com
Subject: [DECNET]: Add support for fwmark masks in routing rules
Date: Fri, 25 Aug 2006 14:14:12 +0200 [thread overview]
Message-ID: <44EEE994.90404@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 0 bytes --]
[-- Attachment #2: 02.diff --]
[-- Type: text/plain, Size: 2530 bytes --]
[DECNET]: Add support for fwmark masks in routing rules
Add support for fwmark masks. For compatibility a mask of 0xFFFFFFFF is used
when a mark value != 0 is sent without a mask.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit bcd4f6996453aaf0a8d5515dcc533115621c961f
tree 62909d3d2c6edd4f236284b86c4c422cb40bc489
parent 9037bbabed75d822002be78047f518d42f225a00
author Patrick McHardy <kaber@trash.net> Fri, 25 Aug 2006 14:00:12 +0200
committer Patrick McHardy <kaber@trash.net> Fri, 25 Aug 2006 14:00:12 +0200
net/decnet/dn_rules.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/net/decnet/dn_rules.c b/net/decnet/dn_rules.c
index 50e819e..63ad63d 100644
--- a/net/decnet/dn_rules.c
+++ b/net/decnet/dn_rules.c
@@ -47,6 +47,7 @@ struct dn_fib_rule
u8 flags;
#ifdef CONFIG_DECNET_ROUTE_FWMARK
u32 fwmark;
+ u32 fwmask;
#endif
};
@@ -116,6 +117,7 @@ static struct nla_policy dn_fib_rule_pol
[FRA_SRC] = { .type = NLA_U16 },
[FRA_DST] = { .type = NLA_U16 },
[FRA_FWMARK] = { .type = NLA_U32 },
+ [FRA_FWMASK] = { .type = NLA_U32 },
[FRA_TABLE] = { .type = NLA_U32 },
};
@@ -130,7 +132,7 @@ static int dn_fib_rule_match(struct fib_
return 0;
#ifdef CONFIG_DECNET_ROUTE_FWMARK
- if (r->fwmark && (r->fwmark != fl->fld_fwmark))
+ if ((r->fwmark ^ fl->fld_fwmark) & r->fwmask)
return 0;
#endif
@@ -168,8 +170,17 @@ static int dn_fib_rule_configure(struct
r->dst = nla_get_u16(tb[FRA_DST]);
#ifdef CONFIG_DECNET_ROUTE_FWMARK
- if (tb[FRA_FWMARK])
+ if (tb[FRA_FWMARK]) {
r->fwmark = nla_get_u32(tb[FRA_FWMARK]);
+ if (r->fwmark)
+ /* compatibility: if the mark value is non-zero all bits
+ * are compared unless a mask is explicitly specified.
+ */
+ r->fwmask = 0xFFFFFFFF;
+ }
+
+ if (tb[FRA_FWMASK])
+ r->fwmask = nla_get_u32(tb[FRA_FWMASK]);
#endif
r->src_len = frh->src_len;
@@ -195,6 +206,9 @@ static int dn_fib_rule_compare(struct fi
#ifdef CONFIG_DECNET_ROUTE_FWMARK
if (tb[FRA_FWMARK] && (r->fwmark != nla_get_u32(tb[FRA_FWMARK])))
return 0;
+
+ if (tb[FRA_FWMASK] && (r->fwmask != nla_get_u32(tb[FRA_FWMASK])))
+ return 0;
#endif
if (tb[FRA_SRC] && (r->src != nla_get_u16(tb[FRA_SRC])))
@@ -237,6 +251,8 @@ static int dn_fib_rule_fill(struct fib_r
#ifdef CONFIG_DECNET_ROUTE_FWMARK
if (r->fwmark)
NLA_PUT_U32(skb, FRA_FWMARK, r->fwmark);
+ if (r->fwmask || r->fwmark)
+ NLA_PUT_U32(skb, FRA_FWMASK, r->fwmask);
#endif
if (r->dst_len)
NLA_PUT_U16(skb, FRA_DST, r->dst);
next reply other threads:[~2006-08-25 12:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-25 12:14 Patrick McHardy [this message]
2006-08-25 12:26 ` [DECNET]: Add support for fwmark masks in routing rules Steven Whitehouse
2006-08-25 23:11 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44EEE994.90404@trash.net \
--to=kaber@trash.net \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=patrick@tykepenguin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).