netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 0/2] vxlan: add configuration check
@ 2016-09-05  9:35 Jiri Benc
  2016-09-05  9:35 ` [PATCH iproute2 1/2] tunnels: use macros for IPv6 address comparison Jiri Benc
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jiri Benc @ 2016-09-05  9:35 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Mirror the vxlan configuration check recently added to the kernel.

While at this, I also converted open coded IPv6 address comparisons to the
standard macros.

Jiri Benc (2):
  tunnels: use macros for IPv6 address comparison
  vxlan: group address requires net device

 ip/ip6tunnel.c     |  8 ++++----
 ip/iplink_geneve.c |  6 +++---
 ip/iplink_vxlan.c  | 19 ++++++++++++-------
 3 files changed, 19 insertions(+), 14 deletions(-)

-- 
1.8.3.1

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH iproute2 1/2] tunnels: use macros for IPv6 address comparison
  2016-09-05  9:35 [PATCH iproute2 0/2] vxlan: add configuration check Jiri Benc
@ 2016-09-05  9:35 ` Jiri Benc
  2016-09-05  9:35 ` [PATCH iproute2 2/2] vxlan: group address requires net device Jiri Benc
  2016-09-05 10:30 ` [PATCH iproute2 0/2] vxlan: add configuration check Phil Sutter
  2 siblings, 0 replies; 5+ messages in thread
From: Jiri Benc @ 2016-09-05  9:35 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

Replace open coded comparison of IPv6 addresses with appropriate macros.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
 ip/ip6tunnel.c     |  8 ++++----
 ip/iplink_geneve.c |  6 +++---
 ip/iplink_vxlan.c  | 14 +++++++-------
 3 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/ip/ip6tunnel.c b/ip/ip6tunnel.c
index ce760bd0bd41..b1c0ae62944c 100644
--- a/ip/ip6tunnel.c
+++ b/ip/ip6tunnel.c
@@ -313,10 +313,10 @@ static int ip6_tnl_parm_match(const struct ip6_tnl_parm2 *p1,
 {
 	return ((!p1->link || p1->link == p2->link) &&
 		(!p1->name[0] || strcmp(p1->name, p2->name) == 0) &&
-		(memcmp(&p1->laddr, &in6addr_any, sizeof(p1->laddr)) == 0 ||
-		 memcmp(&p1->laddr, &p2->laddr, sizeof(p1->laddr)) == 0) &&
-		(memcmp(&p1->raddr, &in6addr_any, sizeof(p1->raddr)) == 0 ||
-		 memcmp(&p1->raddr, &p2->raddr, sizeof(p1->raddr)) == 0) &&
+		(IN6_IS_ADDR_UNSPECIFIED(&p1->laddr) ||
+		 IN6_ARE_ADDR_EQUAL(&p1->laddr, &p2->laddr)) &&
+		(IN6_IS_ADDR_UNSPECIFIED(&p1->raddr) ||
+		 IN6_ARE_ADDR_EQUAL(&p1->raddr, &p2->raddr)) &&
 		(!p1->proto || !p2->proto || p1->proto == p2->proto) &&
 		(!p1->encap_limit || p1->encap_limit == p2->encap_limit) &&
 		(!p1->hop_limit || p1->hop_limit == p2->hop_limit) &&
diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
index 65af6b35eb8b..3bfba91c644c 100644
--- a/ip/iplink_geneve.c
+++ b/ip/iplink_geneve.c
@@ -150,7 +150,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 			return -1;
 		}
 
-		if (!daddr && memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) == 0) {
+		if (!daddr && IN6_IS_ADDR_UNSPECIFIED(&daddr6)) {
 			fprintf(stderr, "geneve: remote link partner not specified\n");
 			return -1;
 		}
@@ -159,7 +159,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 	addattr32(n, 1024, IFLA_GENEVE_ID, vni);
 	if (daddr)
 		addattr_l(n, 1024, IFLA_GENEVE_REMOTE, &daddr, 4);
-	if (memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) != 0)
+	if (!IN6_IS_ADDR_UNSPECIFIED(&daddr6))
 		addattr_l(n, 1024, IFLA_GENEVE_REMOTE6, &daddr6, sizeof(struct in6_addr));
 	addattr32(n, 1024, IFLA_GENEVE_LABEL, label);
 	addattr8(n, 1024, IFLA_GENEVE_TTL, ttl);
@@ -203,7 +203,7 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		struct in6_addr addr;
 
 		memcpy(&addr, RTA_DATA(tb[IFLA_GENEVE_REMOTE6]), sizeof(struct in6_addr));
-		if (memcmp(&addr, &in6addr_any, sizeof(addr)) != 0) {
+		if (!IN6_IS_ADDR_UNSPECIFIED(&addr)) {
 			if (!IN6_IS_ADDR_MULTICAST(&addr))
 				fprintf(f, "remote %s ",
 					format_host(AF_INET6, sizeof(struct in6_addr), &addr));
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index 7ba68bc14c78..251d3f1cfb0b 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -260,8 +260,8 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 	}
 
 	if ((gaddr && daddr) ||
-		(memcmp(&gaddr6, &in6addr_any, sizeof(gaddr6)) &&
-		 memcmp(&daddr6, &in6addr_any, sizeof(daddr6)))) {
+	    (!IN6_IS_ADDR_UNSPECIFIED(&gaddr6) &&
+	     !IN6_IS_ADDR_UNSPECIFIED(&daddr6))) {
 		fprintf(stderr, "vxlan: both group and remote cannot be specified\n");
 		return -1;
 	}
@@ -281,14 +281,14 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 		addattr_l(n, 1024, IFLA_VXLAN_GROUP, &gaddr, 4);
 	else if (daddr)
 		addattr_l(n, 1024, IFLA_VXLAN_GROUP, &daddr, 4);
-	if (memcmp(&gaddr6, &in6addr_any, sizeof(gaddr6)) != 0)
+	if (!IN6_IS_ADDR_UNSPECIFIED(&gaddr6))
 		addattr_l(n, 1024, IFLA_VXLAN_GROUP6, &gaddr6, sizeof(struct in6_addr));
-	else if (memcmp(&daddr6, &in6addr_any, sizeof(daddr6)) != 0)
+	else if (!IN6_IS_ADDR_UNSPECIFIED(&daddr6))
 		addattr_l(n, 1024, IFLA_VXLAN_GROUP6, &daddr6, sizeof(struct in6_addr));
 
 	if (saddr)
 		addattr_l(n, 1024, IFLA_VXLAN_LOCAL, &saddr, 4);
-	else if (memcmp(&saddr6, &in6addr_any, sizeof(saddr6)) != 0)
+	else if (!IN6_IS_ADDR_UNSPECIFIED(&saddr6))
 		addattr_l(n, 1024, IFLA_VXLAN_LOCAL6, &saddr6, sizeof(struct in6_addr));
 
 	if (link)
@@ -365,7 +365,7 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		struct in6_addr addr;
 
 		memcpy(&addr, RTA_DATA(tb[IFLA_VXLAN_GROUP6]), sizeof(struct in6_addr));
-		if (memcmp(&addr, &in6addr_any, sizeof(addr)) != 0) {
+		if (!IN6_IS_ADDR_UNSPECIFIED(&addr)) {
 			if (IN6_IS_ADDR_MULTICAST(&addr))
 				fprintf(f, "group %s ",
 					format_host(AF_INET6, sizeof(struct in6_addr), &addr));
@@ -385,7 +385,7 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		struct in6_addr addr;
 
 		memcpy(&addr, RTA_DATA(tb[IFLA_VXLAN_LOCAL6]), sizeof(struct in6_addr));
-		if (memcmp(&addr, &in6addr_any, sizeof(addr)) != 0)
+		if (!IN6_IS_ADDR_UNSPECIFIED(&addr))
 			fprintf(f, "local %s ",
 				format_host(AF_INET6, sizeof(struct in6_addr), &addr));
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2 2/2] vxlan: group address requires net device
  2016-09-05  9:35 [PATCH iproute2 0/2] vxlan: add configuration check Jiri Benc
  2016-09-05  9:35 ` [PATCH iproute2 1/2] tunnels: use macros for IPv6 address comparison Jiri Benc
@ 2016-09-05  9:35 ` Jiri Benc
  2016-09-20 16:47   ` Stephen Hemminger
  2016-09-05 10:30 ` [PATCH iproute2 0/2] vxlan: add configuration check Phil Sutter
  2 siblings, 1 reply; 5+ messages in thread
From: Jiri Benc @ 2016-09-05  9:35 UTC (permalink / raw)
  To: netdev; +Cc: Stephen Hemminger

This is now enforced in the kernel, check also in iproute to get a better
error message.

Signed-off-by: Jiri Benc <jbenc@redhat.com>
---
 ip/iplink_vxlan.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index 251d3f1cfb0b..93af979a1e97 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -266,6 +266,11 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 		return -1;
 	}
 
+	if ((gaddr || !IN6_IS_ADDR_UNSPECIFIED(&gaddr6)) && !link) {
+		fprintf(stderr, "vxlan: 'group' requires 'dev' to be specified\n");
+		return -1;
+	}
+
 	if (!dst_port_set && gpe) {
 		dstport = 4790;
 	} else if (!dst_port_set) {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2 0/2] vxlan: add configuration check
  2016-09-05  9:35 [PATCH iproute2 0/2] vxlan: add configuration check Jiri Benc
  2016-09-05  9:35 ` [PATCH iproute2 1/2] tunnels: use macros for IPv6 address comparison Jiri Benc
  2016-09-05  9:35 ` [PATCH iproute2 2/2] vxlan: group address requires net device Jiri Benc
@ 2016-09-05 10:30 ` Phil Sutter
  2 siblings, 0 replies; 5+ messages in thread
From: Phil Sutter @ 2016-09-05 10:30 UTC (permalink / raw)
  To: Jiri Benc; +Cc: netdev, Stephen Hemminger

On Mon, Sep 05, 2016 at 11:35:26AM +0200, Jiri Benc wrote:
> Mirror the vxlan configuration check recently added to the kernel.
> 
> While at this, I also converted open coded IPv6 address comparisons to the
> standard macros.
> 
> Jiri Benc (2):
>   tunnels: use macros for IPv6 address comparison
>   vxlan: group address requires net device
> 
>  ip/ip6tunnel.c     |  8 ++++----
>  ip/iplink_geneve.c |  6 +++---
>  ip/iplink_vxlan.c  | 19 ++++++++++++-------
>  3 files changed, 19 insertions(+), 14 deletions(-)

Series:
Acked-by: Phil Sutter <phil@nwl.cc>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2 2/2] vxlan: group address requires net device
  2016-09-05  9:35 ` [PATCH iproute2 2/2] vxlan: group address requires net device Jiri Benc
@ 2016-09-20 16:47   ` Stephen Hemminger
  0 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2016-09-20 16:47 UTC (permalink / raw)
  To: Jiri Benc; +Cc: netdev

On Mon,  5 Sep 2016 11:35:28 +0200
Jiri Benc <jbenc@redhat.com> wrote:

> This is now enforced in the kernel, check also in iproute to get a better
> error message.
> 
> Signed-off-by: Jiri Benc <jbenc@redhat.com>

Applied

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-09-20 16:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-05  9:35 [PATCH iproute2 0/2] vxlan: add configuration check Jiri Benc
2016-09-05  9:35 ` [PATCH iproute2 1/2] tunnels: use macros for IPv6 address comparison Jiri Benc
2016-09-05  9:35 ` [PATCH iproute2 2/2] vxlan: group address requires net device Jiri Benc
2016-09-20 16:47   ` Stephen Hemminger
2016-09-05 10:30 ` [PATCH iproute2 0/2] vxlan: add configuration check Phil Sutter

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).