From: Patrick McHardy <kaber@trash.net>
To: Stephen Hemminger <shemminger@vyatta.com>
Cc: Linux Netdev List <netdev@vger.kernel.org>
Subject: [PATCH iproute] ip: add support for multicast rules
Date: Tue, 13 Apr 2010 17:06:24 +0200 [thread overview]
Message-ID: <4BC48870.7070704@trash.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 207 bytes --]
This patch adds support for a "ip mrule" command, which is used
to configure multicast routing rules.
The corresponding kernel patches have been sent to Dave and
should (hopefully) appear in net-next soon.
[-- Attachment #2: mrule.diff --]
[-- Type: text/x-patch, Size: 2934 bytes --]
>From 1c21ad3ad0a5cd10d1f8cf9c7c5f5b28ae558103 Mon Sep 17 00:00:00 2001
From: Patrick McHardy <kaber@trash.net>
Date: Tue, 13 Apr 2010 17:03:47 +0200
Subject: [PATCH] ip: add support for multicast rules
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
include/linux/fib_rules.h | 8 ++++++++
ip/ip.c | 3 ++-
ip/ip_common.h | 1 +
ip/iprule.c | 12 ++++++++++++
4 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/include/linux/fib_rules.h b/include/linux/fib_rules.h
index 51da65b..04a3976 100644
--- a/include/linux/fib_rules.h
+++ b/include/linux/fib_rules.h
@@ -15,6 +15,14 @@
/* try to find source address in routing lookups */
#define FIB_RULE_FIND_SADDR 0x00010000
+/* fib_rules families. values up to 127 are reserved for real address
+ * families, values above 128 may be used arbitrarily.
+ */
+#define FIB_RULES_IPV4 AF_INET
+#define FIB_RULES_IPV6 AF_INET6
+#define FIB_RULES_DECNET AF_DECnet
+#define FIB_RULES_IPMR 128
+
struct fib_rule_hdr {
__u8 family;
__u8 dst_len;
diff --git a/ip/ip.c b/ip/ip.c
index e0cf175..9f29533 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -42,7 +42,7 @@ static void usage(void)
"Usage: ip [ OPTIONS ] OBJECT { COMMAND | help }\n"
" ip [ -force ] -batch filename\n"
"where OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |\n"
-" tunnel | tuntap | maddr | mroute | monitor | xfrm }\n"
+" tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
" -f[amily] { inet | inet6 | ipx | dnet | link } |\n"
" -o[neline] | -t[imestamp] | -b[atch] [filename] |\n"
@@ -76,6 +76,7 @@ static const struct cmd {
{ "monitor", do_ipmonitor },
{ "xfrm", do_xfrm },
{ "mroute", do_multiroute },
+ { "mrule", do_multirule },
{ "help", do_help },
{ 0 }
};
diff --git a/ip/ip_common.h b/ip/ip_common.h
index c857667..a114186 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -37,6 +37,7 @@ extern int do_iplink(int argc, char **argv);
extern int do_ipmonitor(int argc, char **argv);
extern int do_multiaddr(int argc, char **argv);
extern int do_multiroute(int argc, char **argv);
+extern int do_multirule(int argc, char **argv);
extern int do_xfrm(int argc, char **argv);
static inline int rtm_get_table(struct rtmsg *r, struct rtattr **tb)
diff --git a/ip/iprule.c b/ip/iprule.c
index 7140375..abb8752 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -436,3 +436,15 @@ int do_iprule(int argc, char **argv)
exit(-1);
}
+int do_multirule(int argc, char **argv)
+{
+ if (preferred_family == AF_UNSPEC ||
+ preferred_family == AF_INET)
+ preferred_family = FIB_RULES_IPMR;
+ else {
+ fprintf(stderr, "Multicast rules are only supported for IPv4\n");
+ exit(-1);
+ }
+
+ return do_iprule(argc, argv);
+}
--
1.7.0.4
next reply other threads:[~2010-04-13 15:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-13 15:06 Patrick McHardy [this message]
2010-05-19 16:03 ` [PATCH iproute] ip: add support for multicast rules Stephen Hemminger
2010-05-20 14:01 ` Patrick McHardy
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=4BC48870.7070704@trash.net \
--to=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@vyatta.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.