netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
To: netdev@vger.kernel.org
Subject: [PATCH v2 2/2] ip rule: suppress routes based on ifgroup
Date: Thu, 1 Aug 2013 17:47:05 +0200	[thread overview]
Message-ID: <20130801154705.GE21970@zirkel.wertarbyte.de> (raw)

Signed-off-by: Stefan Tomanek <stefan.tomanek@wertarbyte.de>
---
 include/linux/fib_rules.h |    2 +-
 ip/iprule.c               |   13 +++++++++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/linux/fib_rules.h b/include/linux/fib_rules.h
index 59cd31b..63e3116 100644
--- a/include/linux/fib_rules.h
+++ b/include/linux/fib_rules.h
@@ -44,7 +44,7 @@ enum {
 	FRA_FWMARK,	/* mark */
 	FRA_FLOW,	/* flow/class id */
 	FRA_UNUSED6,
-	FRA_UNUSED7,
+	FRA_SUPPRESS_IFGROUP,
 	FRA_TABLE_PREFIXLEN_MIN,
 	FRA_TABLE,	/* Extended table id */
 	FRA_FWMASK,	/* mask for netfilter mark */
diff --git a/ip/iprule.c b/ip/iprule.c
index a789863..de9f292 100644
--- a/ip/iprule.c
+++ b/ip/iprule.c
@@ -41,6 +41,7 @@ static void usage(void)
 	fprintf(stderr, "          [ goto NUMBER ]\n");
 	fprintf(stderr, "          SUPPRESSOR\n");
 	fprintf(stderr, "SUPPRESSOR := [ prefixlength NUMBER ]\n");
+	fprintf(stderr, "              [ suppress_group DEVGROUP ]\n");
 	fprintf(stderr, "TABLE_ID := [ local | main | default | NUMBER ]\n");
 	exit(-1);
 }
@@ -163,6 +164,12 @@ int print_rule(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
 				fprintf(fp, "prefixlength %u ", pl);
 			}
 		}
+		if (tb[FRA_SUPPRESS_IFGROUP]) {
+			int group = rta_getattr_u32(tb[FRA_SUPPRESS_IFGROUP]);
+			if (group) {
+				fprintf(fp, "suppress_ifgroup %d ", group);
+			}
+		}
 	}
 	if (tb[FRA_FLOW]) {
 		__u32 to = rta_getattr_u32(tb[FRA_FLOW]);
@@ -325,6 +332,12 @@ static int iprule_modify(int cmd, int argc, char **argv)
 			if (get_u8(&pl, *argv, 0))
 				invarg("prefixlength value is invalid\n", *argv);
 			addattr8(&req.n, sizeof(req), FRA_TABLE_PREFIXLEN_MIN, pl);
+		} else if (matches(*argv, "suppress_group") == 0) {
+			NEXT_ARG();
+			int group;
+			if (rtnl_group_a2n(&group, *argv))
+				invarg("Invalid \"suppress_group\" value\n", *argv);
+			addattr32(&req.n, sizeof(req), FRA_SUPPRESS_IFGROUP, group);
 		} else if (strcmp(*argv, "dev") == 0 ||
 			   strcmp(*argv, "iif") == 0) {
 			NEXT_ARG();
-- 
1.7.10.4

                 reply	other threads:[~2013-08-01 15:47 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20130801154705.GE21970@zirkel.wertarbyte.de \
    --to=stefan.tomanek@wertarbyte.de \
    --cc=netdev@vger.kernel.org \
    /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).