From: Patrick McHardy <kaber@trash.net>
To: Stephen Hemminger <shemminger@osdl.org>
Cc: Jamal <hadi@cyberus.ca>, Masahide NAKAMURA <nakam@linux-ipv6.org>,
Thomas Graf <tgraf@suug.ch>,
netdev@vger.kernel.org
Subject: Re: iproute2 update
Date: Tue, 05 Dec 2006 19:43:43 +0100 [thread overview]
Message-ID: <4575BDDF.70902@trash.net> (raw)
In-Reply-To: <20061205101757.7a35bcbe@freekitty>
[-- Attachment #1: Type: text/plain, Size: 185 bytes --]
Stephen Hemminger wrote:
> I am about to push out a new version, so if you have any more patches pending
> the window is about to close.
I still have this one I would like to get in.
[-- Attachment #2: x --]
[-- Type: text/plain, Size: 3204 bytes --]
[IPROUTE]: Add support for routing rule fwmark masks
Needs kernel >= 2.6.19.
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
commit ba3145833888823f1e1af4ef093d16eea9baed2c
tree 23ef86c81e53c94d3f8d67d5395bcc3183d39e4b
parent 288384f22ffafd2d7d888ee45d8dfcf26d3f2b1c
author Patrick McHardy <kaber@trash.net> Tue, 05 Dec 2006 19:41:36 +0100
committer Patrick McHardy <kaber@trash.net> Tue, 05 Dec 2006 19:41:36 +0100
include/linux/rtnetlink.h | 1 +
ip/iprule.c | 25 +++++++++++++++++++++----
man/man8/ip.8 | 2 +-
3 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 1ee3a56..c02470c 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -264,6 +264,7 @@ enum rtattr_type_t
RTA_SESSION,
RTA_MP_ALGO,
RTA_TABLE,
+ RTA_FWMASK,
__RTA_MAX
};
diff --git a/ip/iprule.c b/ip/iprule.c
index c584b18..2a4d126 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -37,7 +37,7 @@ static void usage(void) __attribute__((n
static void usage(void)
{
fprintf(stderr, "Usage: ip rule [ list | add | del | flush ] SELECTOR ACTION\n");
- fprintf(stderr, "SELECTOR := [ not ] [ from PREFIX ] [ to PREFIX ] [ tos TOS ] [ fwmark FWMARK ]\n");
+ fprintf(stderr, "SELECTOR := [ not ] [ from PREFIX ] [ to PREFIX ] [ tos TOS ] [ fwmark FWMARK[/MASK] ]\n");
fprintf(stderr, " [ dev STRING ] [ pref NUMBER ]\n");
fprintf(stderr, "ACTION := [ table TABLE_ID ]\n");
fprintf(stderr, " [ prohibit | reject | unreachable ]\n");
@@ -129,8 +129,17 @@ int print_rule(const struct sockaddr_nl
SPRINT_BUF(b1);
fprintf(fp, "tos %s ", rtnl_dsfield_n2a(r->rtm_tos, b1, sizeof(b1)));
}
- if (tb[RTA_PROTOINFO]) {
- fprintf(fp, "fwmark %#x ", *(__u32*)RTA_DATA(tb[RTA_PROTOINFO]));
+ if (tb[RTA_PROTOINFO] || tb[RTA_FWMASK]) {
+ __u32 mark = 0, mask = 0;
+
+ if (tb[RTA_PROTOINFO])
+ mark = *(__u32*)RTA_DATA(tb[RTA_PROTOINFO]);
+
+ if (tb[RTA_FWMASK] &&
+ (mask = *(__u32*)RTA_DATA(tb[RTA_FWMASK])) != 0xFFFFFFFF)
+ fprintf(fp, "fwmark 0x%x/0x%x ", mark, mask);
+ else
+ fprintf(fp, "fwmark 0x%x ", mark);
}
if (tb[RTA_IIF]) {
@@ -252,11 +261,19 @@ static int iprule_modify(int cmd, int ar
invarg("TOS value is invalid\n", *argv);
req.r.rtm_tos = tos;
} else if (strcmp(*argv, "fwmark") == 0) {
- __u32 fwmark;
+ char *slash;
+ __u32 fwmark, fwmask;
NEXT_ARG();
+ if ((slash = strchr(*argv, '/')) != NULL)
+ *slash = '\0';
if (get_u32(&fwmark, *argv, 0))
invarg("fwmark value is invalid\n", *argv);
addattr32(&req.n, sizeof(req), RTA_PROTOINFO, fwmark);
+ if (slash) {
+ if (get_u32(&fwmask, slash+1, 0))
+ invarg("fwmask value is invalid\n", slash+1);
+ addattr32(&req.n, sizeof(req), RTA_FWMASK, fwmask);
+ }
} else if (matches(*argv, "realms") == 0) {
__u32 realm;
NEXT_ARG();
diff --git a/man/man8/ip.8 b/man/man8/ip.8
index 12da6d5..a9132da 100644
--- a/man/man8/ip.8
+++ b/man/man8/ip.8
@@ -223,7 +223,7 @@ throw " | " unreachable " | " prohibit "
.B tos
.IR TOS " ] [ "
.B fwmark
-.IR FWMARK " ] [ "
+.IR FWMARK[/MASK] " ] [ "
.B dev
.IR STRING " ] [ "
.B pref
next prev parent reply other threads:[~2006-12-05 18:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-05 18:17 iproute2 update Stephen Hemminger
2006-12-05 18:43 ` Patrick McHardy [this message]
2006-12-06 3:58 ` Masahide NAKAMURA
-- strict thread matches above, loose matches on Subject: below --
2005-01-12 20:59 Iproute2: update Stephen Hemminger
2005-01-16 17:09 ` jamal
2005-01-16 17:45 ` Jamal Hadi Salim
2005-01-17 19:39 ` Thomas Graf
2005-01-17 20:20 ` Thomas Graf
2005-01-17 20:57 ` Thomas Graf
2005-01-17 21:39 ` jamal
2005-01-17 22:24 ` Thomas Graf
2005-01-17 22:39 ` jamal
2005-01-17 22:24 ` Stephen Hemminger
2005-03-21 20:11 ` Lennert Buytenhek
2005-03-29 18:09 ` Stephen Hemminger
2005-03-29 19:07 ` Lennert Buytenhek
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=4575BDDF.70902@trash.net \
--to=kaber@trash.net \
--cc=hadi@cyberus.ca \
--cc=nakam@linux-ipv6.org \
--cc=netdev@vger.kernel.org \
--cc=shemminger@osdl.org \
--cc=tgraf@suug.ch \
/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).