netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsa@cumulusnetworks.com>
To: netdev@vger.kernel.org
Cc: shm@cumulusnetworks.com, stephen@networkplumber.org,
	David Ahern <dsa@cumulusnetworks.com>
Subject: [PATCH iproute2] vrf: Add support for table names
Date: Tue,  8 Dec 2015 12:24:44 -0800	[thread overview]
Message-ID: <1449606284-42134-1-git-send-email-dsa@cumulusnetworks.com> (raw)

Currently, the table id for VRF devices requires an integer. Convert
it to use rtnl_rttable_a2n which handles table names from the iproute2
directory.

This also fixes a bug in the original commit where table name are not
properly handled.

Fixes: 15faa0a30bed ("add support for VRF device")
Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
 ip/iplink_vrf.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/ip/iplink_vrf.c b/ip/iplink_vrf.c
index 913a2892c95b..9b4b7728cf6f 100644
--- a/ip/iplink_vrf.c
+++ b/ip/iplink_vrf.c
@@ -28,12 +28,6 @@ static void explain(void)
 	vrf_explain(stderr);
 }
 
-static int table_arg(void)
-{
-	fprintf(stderr,"Error: argument of \"table\" must be 0-32767 and currently unused\n");
-	return -1;
-}
-
 static int vrf_parse_opt(struct link_util *lu, int argc, char **argv,
 			    struct nlmsghdr *n)
 {
@@ -43,9 +37,8 @@ static int vrf_parse_opt(struct link_util *lu, int argc, char **argv,
 
 			NEXT_ARG();
 
-			table = atoi(*argv);
-			if (table > 32767)
-				return table_arg();
+			if (rtnl_rttable_a2n(&table, *argv))
+				invarg("invalid table ID\n", *argv);
 			addattr32(n, 1024, IFLA_VRF_TABLE, table);
 		} else if (matches(*argv, "help") == 0) {
 			explain();
-- 
2.1.4

             reply	other threads:[~2015-12-08 20:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-08 20:24 David Ahern [this message]
2015-12-10 16:55 ` [PATCH iproute2] vrf: Add support for table names Stephen Hemminger

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=1449606284-42134-1-git-send-email-dsa@cumulusnetworks.com \
    --to=dsa@cumulusnetworks.com \
    --cc=netdev@vger.kernel.org \
    --cc=shm@cumulusnetworks.com \
    --cc=stephen@networkplumber.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).