netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Atzm Watanabe <atzm@stratosphere.co.jp>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	David Miller <davem@davemloft.net>,
	Ben Hutchings <bhutchings@solarflare.com>,
	David Stevens <dlstevens@us.ibm.com>,
	Mike Rapoport <mike.rapoport@ravellosystems.com>
Subject: [PATCH iproute2 v6] vxlan: Allow setting destination to unicast address.
Date: Wed, 24 Jul 2013 14:01:01 +0900	[thread overview]
Message-ID: <87txjklfg2.wl%atzm@stratosphere.co.jp> (raw)

This patch allows setting VXLAN destination to unicast address.
It allows that VXLAN can be used as peer-to-peer tunnel without
multicast.

v6: change back to the v3 except for using new attribute because
    replacing command-line parameters breaks existing scripts,
    based by Cong Wang's comments.

v5: rebase on the latest.

v4: replace "group" with "remote" based by David Stevens's comments.

v3: move a new attribute REMOTE into the last of an enum list
    based by Stephen Hemminger's comments.
    fix the usage to show explicitly that both "remote" and "group"
    cannot be specified, based by Ben Hutchings's comments.

v2: use a new argument "remote" instead of "group" based by
    Stephen Hemminger's comments.

Signed-off-by: Atzm Watanabe <atzm@stratosphere.co.jp>
---
 ip/iplink_vxlan.c     | 28 +++++++++++++++++++++++-----
 man/man8/ip-link.8.in | 15 +++++++++++++--
 2 files changed, 36 insertions(+), 7 deletions(-)

diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index 1025326..4304b0d 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -23,7 +23,7 @@
 
 static void explain(void)
 {
-	fprintf(stderr, "Usage: ... vxlan id VNI [ group ADDR ] [ local ADDR ]\n");
+	fprintf(stderr, "Usage: ... vxlan id VNI [ { group | remote } ADDR ] [ local ADDR ]\n");
 	fprintf(stderr, "                 [ ttl TTL ] [ tos TOS ] [ dev PHYS_DEV ]\n");
 	fprintf(stderr, "                 [ port MIN MAX ] [ [no]learning ]\n");
 	fprintf(stderr, "                 [ [no]proxy ] [ [no]rsc ]\n");
@@ -42,6 +42,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 	int vni_set = 0;
 	__u32 saddr = 0;
 	__u32 gaddr = 0;
+	__u32 daddr = 0;
 	unsigned link = 0;
 	__u8 tos = 0;
 	__u8 ttl = 0;
@@ -68,7 +69,13 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 			gaddr = get_addr32(*argv);
 
 			if (!IN_MULTICAST(ntohl(gaddr)))
-				invarg("invald group address", *argv);
+				invarg("invalid group address", *argv);
+		} else if (!matches(*argv, "remote")) {
+			NEXT_ARG();
+			daddr = get_addr32(*argv);
+
+			if (IN_MULTICAST(ntohl(daddr)))
+				invarg("invalid remote address", *argv);
 		} else if (!matches(*argv, "local")) {
 			NEXT_ARG();
 			if (strcmp(*argv, "any"))
@@ -160,9 +167,15 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 		fprintf(stderr, "vxlan: missing virtual network identifier\n");
 		return -1;
 	}
+	if (gaddr && daddr) {
+		fprintf(stderr, "vxlan: both group and remote cannot be specified\n");
+		return -1;
+	}
 	addattr32(n, 1024, IFLA_VXLAN_ID, vni);
 	if (gaddr)
 		addattr_l(n, 1024, IFLA_VXLAN_GROUP, &gaddr, 4);
+	else if (daddr)
+		addattr_l(n, 1024, IFLA_VXLAN_GROUP, &daddr, 4);
 	if (saddr)
 		addattr_l(n, 1024, IFLA_VXLAN_LOCAL, &saddr, 4);
 	if (link)
@@ -208,9 +221,14 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 
 	if (tb[IFLA_VXLAN_GROUP]) {
 		__be32 addr = rta_getattr_u32(tb[IFLA_VXLAN_GROUP]);
-		if (addr)
-			fprintf(f, "group %s ",
-				format_host(AF_INET, 4, &addr, s1, sizeof(s1)));
+		if (addr) {
+			if (IN_MULTICAST(ntohl(addr)))
+				fprintf(f, "group %s ",
+					format_host(AF_INET, 4, &addr, s1, sizeof(s1)));
+			else
+				fprintf(f, "remote %s ",
+					format_host(AF_INET, 4, &addr, s1, sizeof(s1)));
+		}
 	}
 
 	if (tb[IFLA_VXLAN_LOCAL]) {
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index 86e0bc9..76f92dd 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -206,8 +206,8 @@ the following additional arguments are supported:
 .BI type " vxlan " id " ID
 .R " [ "
 .BI dev " PHYS_DEV "
-.R " ] [ "
-.BI group " IPADDR "
+.RB " ] [ { " group " | " remote " } "
+.I IPADDR
 .R " ] [ "
 .BI local " IPADDR "
 .R " ] [ "
@@ -240,6 +240,17 @@ Identifier) to use.
 .sp
 .BI group " IPADDR"
 - specifies the multicast IP address to join.
+This parameter cannot be specified with the
+.B remote
+parameter.
+
+.sp
+.BI remote " IPADDR"
+- specifies the unicast destination IP address to use in outgoing packets
+when the destination link layer address is not known in the VXLAN device
+forwarding database.  This parameter cannot be specified with the
+.B group
+parameter.
 
 .sp
 .BI local " IPADDR"
-- 
1.8.1.5

             reply	other threads:[~2013-07-24  5:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24  5:01 Atzm Watanabe [this message]
2013-07-26 21:26 ` [PATCH iproute2 v6] vxlan: Allow setting destination to unicast address 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=87txjklfg2.wl%atzm@stratosphere.co.jp \
    --to=atzm@stratosphere.co.jp \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=dlstevens@us.ibm.com \
    --cc=mike.rapoport@ravellosystems.com \
    --cc=netdev@vger.kernel.org \
    --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).