netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute 0/5] ila: additional configuratio support
@ 2017-11-22 20:05 Tom Herbert
  2017-11-22 20:05 ` [PATCH iproute 1/5] ila: Fix reporting of ILA locators and locator match Tom Herbert
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Tom Herbert @ 2017-11-22 20:05 UTC (permalink / raw)
  To: stephen; +Cc: netdev, rohit, Tom Herbert

Add configuration support for checksum neutral-map-auto, identifier
tyoes, and hook type (for LWT).

Tom Herbert (5):
  ila: Fix reporting of ILA locators and locator match
  ila: added csum neutral support to ipila
  ila: support to configure checksum neutral-map-auto
  ila: support for configuring identifier and hook types
  ila: create ila_common.h

 ip/ila_common.h       | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++
 ip/ipila.c            |  57 +++++++++++++++++++++++++--
 ip/iproute_lwtunnel.c |  68 +++++++++++++++++++-------------
 3 files changed, 200 insertions(+), 30 deletions(-)
 create mode 100644 ip/ila_common.h

-- 
2.11.0

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

* [PATCH iproute 1/5] ila: Fix reporting of ILA locators and locator match
  2017-11-22 20:05 [PATCH iproute 0/5] ila: additional configuratio support Tom Herbert
@ 2017-11-22 20:05 ` Tom Herbert
  2017-11-22 20:05 ` [PATCH iproute 2/5] ila: added csum neutral support to ipila Tom Herbert
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Herbert @ 2017-11-22 20:05 UTC (permalink / raw)
  To: stephen; +Cc: netdev, rohit, Tom Herbert

Fix retrieval of locator value for RTA to get 64 bits instead of 32.

Signed-off-by: Tom Herbert <tom@quantonium.net>
---
 ip/ipila.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/ipila.c b/ip/ipila.c
index 0403fc42..fe5c4d8b 100644
--- a/ip/ipila.c
+++ b/ip/ipila.c
@@ -79,7 +79,7 @@ static void print_ila_locid(FILE *fp, int attr, struct rtattr *tb[], int space)
 	int i;
 
 	if (tb[attr]) {
-		blen = print_addr64(rta_getattr_u32(tb[attr]),
+		blen = print_addr64(rta_getattr_u64(tb[attr]),
 				    abuf, sizeof(abuf));
 		fprintf(fp, "%s", abuf);
 	} else {
-- 
2.11.0

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

* [PATCH iproute 2/5] ila: added csum neutral support to ipila
  2017-11-22 20:05 [PATCH iproute 0/5] ila: additional configuratio support Tom Herbert
  2017-11-22 20:05 ` [PATCH iproute 1/5] ila: Fix reporting of ILA locators and locator match Tom Herbert
@ 2017-11-22 20:05 ` Tom Herbert
  2017-11-22 20:05 ` [PATCH iproute 3/5] ila: support to configure checksum neutral-map-auto Tom Herbert
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Herbert @ 2017-11-22 20:05 UTC (permalink / raw)
  To: stephen; +Cc: netdev, rohit, Tom Herbert

Add checksum neutral to ip ila configuration. This control whether
the C-bit is interpreted as checksum neutral bit.

Signed-off-by: Tom Herbert <tom@quantonium.net>
---
 ip/ipila.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/ip/ipila.c b/ip/ipila.c
index fe5c4d8b..d4935d18 100644
--- a/ip/ipila.c
+++ b/ip/ipila.c
@@ -26,7 +26,9 @@
 static void usage(void)
 {
 	fprintf(stderr, "Usage: ip ila add loc_match LOCATOR_MATCH "
-		"loc LOCATOR [ dev DEV ]\n");
+		"loc LOCATOR [ dev DEV ] "
+		"[ csum-mode { adj-transport | neutral-map | "
+		"no-action } ]\n");
 	fprintf(stderr, "       ip ila del loc_match LOCATOR_MATCH "
 		"[ loc LOCATOR ] [ dev DEV ]\n");
 	fprintf(stderr, "       ip ila list\n");
@@ -48,6 +50,32 @@ static int genl_family = -1;
 
 #define ADDR_BUF_SIZE sizeof("xxxx:xxxx:xxxx:xxxx")
 
+static char *ila_csum_mode2name(__u8 csum_mode)
+{
+	switch (csum_mode) {
+	case ILA_CSUM_ADJUST_TRANSPORT:
+		return "adj-transport";
+	case ILA_CSUM_NEUTRAL_MAP:
+		return "neutral-map";
+	case ILA_CSUM_NO_ACTION:
+		return "no-action";
+	default:
+		return "unknown";
+	}
+}
+
+static int ila_csum_name2mode(char *name)
+{
+	if (strcmp(name, "adj-transport") == 0)
+		return ILA_CSUM_ADJUST_TRANSPORT;
+	else if (strcmp(name, "neutral-map") == 0)
+		return ILA_CSUM_NEUTRAL_MAP;
+	else if (strcmp(name, "no-action") == 0)
+		return ILA_CSUM_NO_ACTION;
+	else
+		return -1;
+}
+
 static int print_addr64(__u64 addr, char *buff, size_t len)
 {
 	__u16 *words = (__u16 *)&addr;
@@ -113,9 +141,19 @@ static int print_ila_mapping(const struct sockaddr_nl *who,
 	print_ila_locid(fp, ILA_ATTR_LOCATOR, tb, ADDR_BUF_SIZE);
 
 	if (tb[ILA_ATTR_IFINDEX])
-		fprintf(fp, "%s", ll_index_to_name(rta_getattr_u32(tb[ILA_ATTR_IFINDEX])));
+		fprintf(fp, "%-16s",
+			ll_index_to_name(rta_getattr_u32(
+						tb[ILA_ATTR_IFINDEX])));
+	else
+		fprintf(fp, "%-16s", "-");
+
+	if (tb[ILA_ATTR_CSUM_MODE])
+		fprintf(fp, "%s",
+			ila_csum_mode2name(rta_getattr_u8(
+						tb[ILA_ATTR_CSUM_MODE])));
 	else
 		fprintf(fp, "-");
+
 	fprintf(fp, "\n");
 
 	return 0;
@@ -152,9 +190,11 @@ static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 	__u64 locator = 0;
 	__u64 locator_match = 0;
 	int ifindex = 0;
+	int csum_mode = 0;
 	bool loc_set = false;
 	bool loc_match_set = false;
 	bool ifindex_set = false;
+	bool csum_mode_set = false;
 
 	while (argc > 0) {
 		if (!matches(*argv, "loc")) {
@@ -174,6 +214,16 @@ static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 				return -1;
 			}
 			loc_match_set = true;
+		} else if (!matches(*argv, "csum-mode")) {
+			NEXT_ARG();
+
+			csum_mode = ila_csum_name2mode(*argv);
+			if (csum_mode < 0) {
+				fprintf(stderr, "Bad csum-mode: %s\n",
+					*argv);
+				return -1;
+			}
+			csum_mode_set = true;
 		} else if (!matches(*argv, "dev")) {
 			NEXT_ARG();
 
@@ -211,6 +261,9 @@ static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 	if (ifindex_set)
 		addattr32(n, 1024, ILA_ATTR_IFINDEX, ifindex);
 
+	if (csum_mode_set)
+		addattr8(n, 1024, ILA_ATTR_CSUM_MODE, csum_mode);
+
 	return 0;
 }
 
-- 
2.11.0

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

* [PATCH iproute 3/5] ila: support to configure checksum neutral-map-auto
  2017-11-22 20:05 [PATCH iproute 0/5] ila: additional configuratio support Tom Herbert
  2017-11-22 20:05 ` [PATCH iproute 1/5] ila: Fix reporting of ILA locators and locator match Tom Herbert
  2017-11-22 20:05 ` [PATCH iproute 2/5] ila: added csum neutral support to ipila Tom Herbert
@ 2017-11-22 20:05 ` Tom Herbert
  2017-11-22 20:05 ` [PATCH iproute 4/5] ila: support for configuring identifier and hook types Tom Herbert
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Herbert @ 2017-11-22 20:05 UTC (permalink / raw)
  To: stephen; +Cc: netdev, rohit, Tom Herbert

Configuration support in both ip ila and ip LWT for checksum
neutral-map-auto. This is a mode of ILA where checksum
neutral mapping is assumed for packets (there is no C-bit
in the identifier to indicate checksum neutral).

Signed-off-by: Tom Herbert <tom@quantonium.net>
---
 ip/ipila.c            | 8 +++++---
 ip/iproute_lwtunnel.c | 4 ++++
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/ip/ipila.c b/ip/ipila.c
index d4935d18..0b706f0b 100644
--- a/ip/ipila.c
+++ b/ip/ipila.c
@@ -28,7 +28,7 @@ static void usage(void)
 	fprintf(stderr, "Usage: ip ila add loc_match LOCATOR_MATCH "
 		"loc LOCATOR [ dev DEV ] "
 		"[ csum-mode { adj-transport | neutral-map | "
-		"no-action } ]\n");
+		"neutral-map-auto | no-action } ]\n");
 	fprintf(stderr, "       ip ila del loc_match LOCATOR_MATCH "
 		"[ loc LOCATOR ] [ dev DEV ]\n");
 	fprintf(stderr, "       ip ila list\n");
@@ -59,6 +59,8 @@ static char *ila_csum_mode2name(__u8 csum_mode)
 		return "neutral-map";
 	case ILA_CSUM_NO_ACTION:
 		return "no-action";
+	case ILA_CSUM_NEUTRAL_MAP_AUTO:
+		return "neutral-map-auto";
 	default:
 		return "unknown";
 	}
@@ -70,8 +72,8 @@ static int ila_csum_name2mode(char *name)
 		return ILA_CSUM_ADJUST_TRANSPORT;
 	else if (strcmp(name, "neutral-map") == 0)
 		return ILA_CSUM_NEUTRAL_MAP;
-	else if (strcmp(name, "no-action") == 0)
-		return ILA_CSUM_NO_ACTION;
+	else if (strcmp(name, "neutral-map-auto") == 0)
+		return ILA_CSUM_NEUTRAL_MAP_AUTO;
 	else
 		return -1;
 }
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index 1c8adbe7..ebedd94a 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -288,6 +288,8 @@ static char *ila_csum_mode2name(__u8 csum_mode)
 		return "neutral-map";
 	case ILA_CSUM_NO_ACTION:
 		return "no-action";
+	case ILA_CSUM_NEUTRAL_MAP_AUTO:
+		return "neutral-map-auto";
 	default:
 		return "unknown";
 	}
@@ -301,6 +303,8 @@ static int ila_csum_name2mode(char *name)
 		return ILA_CSUM_NEUTRAL_MAP;
 	else if (strcmp(name, "no-action") == 0)
 		return ILA_CSUM_NO_ACTION;
+	else if (strcmp(name, "neutral-map-auto") == 0)
+		return ILA_CSUM_NEUTRAL_MAP_AUTO;
 	else
 		return -1;
 }
-- 
2.11.0

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

* [PATCH iproute 4/5] ila: support for configuring identifier and hook types
  2017-11-22 20:05 [PATCH iproute 0/5] ila: additional configuratio support Tom Herbert
                   ` (2 preceding siblings ...)
  2017-11-22 20:05 ` [PATCH iproute 3/5] ila: support to configure checksum neutral-map-auto Tom Herbert
@ 2017-11-22 20:05 ` Tom Herbert
  2017-11-22 20:05 ` [PATCH iproute 5/5] ila: create ila_common.h Tom Herbert
  2017-11-24 17:26 ` [PATCH iproute 0/5] ila: additional configuratio support Stephen Hemminger
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Herbert @ 2017-11-22 20:05 UTC (permalink / raw)
  To: stephen; +Cc: netdev, rohit, Tom Herbert

Expose identifier type and hook types in ILA configuraiton
and reporting. This adds support in both ip ila ILA LWT.

Signed-off-by: Tom Herbert <tom@quantonium.net>
---
 ip/ipila.c            |  75 ++++++++++++++++++++++++++++++++++-
 ip/iproute_lwtunnel.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 179 insertions(+), 3 deletions(-)

diff --git a/ip/ipila.c b/ip/ipila.c
index 0b706f0b..c7a8ede8 100644
--- a/ip/ipila.c
+++ b/ip/ipila.c
@@ -28,7 +28,8 @@ static void usage(void)
 	fprintf(stderr, "Usage: ip ila add loc_match LOCATOR_MATCH "
 		"loc LOCATOR [ dev DEV ] "
 		"[ csum-mode { adj-transport | neutral-map | "
-		"neutral-map-auto | no-action } ]\n");
+		"neutral-map-auto | no-action } ] "
+		"[ ident-type { luid | use-format } ]\n");
 	fprintf(stderr, "       ip ila del loc_match LOCATOR_MATCH "
 		"[ loc LOCATOR ] [ dev DEV ]\n");
 	fprintf(stderr, "       ip ila list\n");
@@ -74,6 +75,54 @@ static int ila_csum_name2mode(char *name)
 		return ILA_CSUM_NEUTRAL_MAP;
 	else if (strcmp(name, "neutral-map-auto") == 0)
 		return ILA_CSUM_NEUTRAL_MAP_AUTO;
+	else if (strcmp(name, "no-action") == 0)
+		return ILA_CSUM_NO_ACTION;
+	else if (strcmp(name, "neutral-map-auto") == 0)
+		return ILA_CSUM_NEUTRAL_MAP_AUTO;
+	else
+		return -1;
+}
+
+static char *ila_ident_type2name(__u8 ident_type)
+{
+	switch (ident_type) {
+	case ILA_ATYPE_IID:
+		return "iid";
+	case ILA_ATYPE_LUID:
+		return "luid";
+	case ILA_ATYPE_VIRT_V4:
+		return "virt-v4";
+	case ILA_ATYPE_VIRT_UNI_V6:
+		return "virt-uni-v6";
+	case ILA_ATYPE_VIRT_MULTI_V6:
+		return "virt-multi-v6";
+	case ILA_ATYPE_NONLOCAL_ADDR:
+		return "nonlocal-addr";
+	case ILA_ATYPE_USE_FORMAT:
+		return "use-format";
+	default:
+		return "unknown";
+	}
+}
+
+static int ila_ident_name2type(char *name)
+{
+	if (!strcmp(name, "luid"))
+		return ILA_ATYPE_LUID;
+	else if (!strcmp(name, "use-format"))
+		return ILA_ATYPE_USE_FORMAT;
+#if 0 /* No kernel support for configuring these yet */
+	else if (!strcmp(name, "iid"))
+		return ILA_ATYPE_IID;
+	else if (!strcmp(name, "virt-v4"))
+		return ILA_ATYPE_VIRT_V4;
+	else if (!strcmp(name, "virt-uni-v6"))
+		return ILA_ATYPE_VIRT_UNI_V6;
+	else if (!strcmp(name, "virt-multi-v6"))
+		return ILA_ATYPE_VIRT_MULTI_V6;
+	else if (!strcmp(name, "nonlocal-addr"))
+		return ILA_ATYPE_NONLOCAL_ADDR;
+#endif
 	else
 		return -1;
 }
@@ -147,13 +196,20 @@ static int print_ila_mapping(const struct sockaddr_nl *who,
 			ll_index_to_name(rta_getattr_u32(
 						tb[ILA_ATTR_IFINDEX])));
 	else
-		fprintf(fp, "%-16s", "-");
+		fprintf(fp, "%-10s ", "-");
 
 	if (tb[ILA_ATTR_CSUM_MODE])
 		fprintf(fp, "%s",
 			ila_csum_mode2name(rta_getattr_u8(
 						tb[ILA_ATTR_CSUM_MODE])));
 	else
+		fprintf(fp, "%-10s ", "-");
+
+	if (tb[ILA_ATTR_IDENT_TYPE])
+		fprintf(fp, "%s",
+			ila_ident_type2name(rta_getattr_u8(
+						tb[ILA_ATTR_IDENT_TYPE])));
+	else
 		fprintf(fp, "-");
 
 	fprintf(fp, "\n");
@@ -193,10 +249,12 @@ static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 	__u64 locator_match = 0;
 	int ifindex = 0;
 	int csum_mode = 0;
+	int ident_type = 0;
 	bool loc_set = false;
 	bool loc_match_set = false;
 	bool ifindex_set = false;
 	bool csum_mode_set = false;
+	bool ident_type_set = false;
 
 	while (argc > 0) {
 		if (!matches(*argv, "loc")) {
@@ -226,6 +284,16 @@ static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 				return -1;
 			}
 			csum_mode_set = true;
+		} else if (!matches(*argv, "ident-type")) {
+			NEXT_ARG();
+
+			ident_type = ila_ident_name2type(*argv);
+			if (ident_type < 0) {
+				fprintf(stderr, "Bad ident-type: %s\n",
+					*argv);
+				return -1;
+			}
+			ident_type_set = true;
 		} else if (!matches(*argv, "dev")) {
 			NEXT_ARG();
 
@@ -266,6 +334,9 @@ static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n,
 	if (csum_mode_set)
 		addattr8(n, 1024, ILA_ATTR_CSUM_MODE, csum_mode);
 
+	if (ident_type_set)
+		addattr8(n, 1024, ILA_ATTR_IDENT_TYPE, ident_type);
+
 	return 0;
 }
 
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index ebedd94a..e57cc9f3 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -309,6 +309,72 @@ static int ila_csum_name2mode(char *name)
 		return -1;
 }
 
+static char *ila_ident_type2name(__u8 ident_type)
+{
+	switch (ident_type) {
+	case ILA_ATYPE_IID:
+		return "iid";
+	case ILA_ATYPE_LUID:
+		return "luid";
+	case ILA_ATYPE_VIRT_V4:
+		return "virt-v4";
+	case ILA_ATYPE_VIRT_UNI_V6:
+		return "virt-uni-v6";
+	case ILA_ATYPE_VIRT_MULTI_V6:
+		return "virt-multi-v6";
+	case ILA_ATYPE_NONLOCAL_ADDR:
+		return "nonlocal-addr";
+	case ILA_ATYPE_USE_FORMAT:
+		return "use-format";
+	default:
+		return "unknown";
+	}
+}
+
+static int ila_ident_name2type(char *name)
+{
+	if (!strcmp(name, "luid"))
+		return ILA_ATYPE_LUID;
+	else if (!strcmp(name, "use-format"))
+		return ILA_ATYPE_USE_FORMAT;
+#if 0 /* No kernel support for configuring these yet */
+	else if (!strcmp(name, "iid"))
+		return ILA_ATYPE_IID;
+	else if (!strcmp(name, "virt-v4"))
+		return ILA_ATYPE_VIRT_V4;
+	else if (!strcmp(name, "virt-uni-v6"))
+		return ILA_ATYPE_VIRT_UNI_V6;
+	else if (!strcmp(name, "virt-multi-v6"))
+		return ILA_ATYPE_VIRT_MULTI_V6;
+	else if (!strcmp(name, "nonlocal-addr"))
+		return ILA_ATYPE_NONLOCAL_ADDR;
+#endif
+	else
+		return -1;
+}
+
+static char *ila_hook_type2name(__u8 hook_type)
+{
+	switch (hook_type) {
+	case ILA_HOOK_ROUTE_OUTPUT:
+		return "output";
+	case ILA_HOOK_ROUTE_INPUT:
+		return "input";
+	default:
+		return "unknown";
+	}
+}
+
+static int ila_hook_name2type(char *name)
+{
+	if (!strcmp(name, "output"))
+		return ILA_HOOK_ROUTE_OUTPUT;
+	else if (!strcmp(name, "input"))
+		return ILA_HOOK_ROUTE_INPUT;
+	else
+		return -1;
+}
+
 static void print_encap_ila(FILE *fp, struct rtattr *encap)
 {
 	struct rtattr *tb[ILA_ATTR_MAX+1];
@@ -325,7 +391,18 @@ static void print_encap_ila(FILE *fp, struct rtattr *encap)
 
 	if (tb[ILA_ATTR_CSUM_MODE])
 		fprintf(fp, " csum-mode %s ",
-			ila_csum_mode2name(rta_getattr_u8(tb[ILA_ATTR_CSUM_MODE])));
+			ila_csum_mode2name(rta_getattr_u8(
+						tb[ILA_ATTR_CSUM_MODE])));
+
+	if (tb[ILA_ATTR_IDENT_TYPE])
+		fprintf(fp, " ident-type %s ",
+			ila_ident_type2name(rta_getattr_u8(
+						tb[ILA_ATTR_IDENT_TYPE])));
+
+	if (tb[ILA_ATTR_HOOK_TYPE])
+		fprintf(fp, " hook-type %s ",
+			ila_hook_type2name(rta_getattr_u8(
+						tb[ILA_ATTR_HOOK_TYPE])));
 }
 
 static void print_encap_ip6(FILE *fp, struct rtattr *encap)
@@ -777,6 +854,34 @@ static int parse_encap_ila(struct rtattr *rta, size_t len,
 				     (__u8)csum_mode);
 
 			argc--; argv++;
+		} else if (strcmp(*argv, "ident-type") == 0) {
+			int ident_type;
+
+			NEXT_ARG();
+
+			ident_type = ila_ident_name2type(*argv);
+			if (ident_type < 0)
+				invarg("\"ident-type\" value is invalid\n",
+				       *argv);
+
+			rta_addattr8(rta, 1024, ILA_ATTR_IDENT_TYPE,
+				     (__u8)ident_type);
+
+			argc--; argv++;
+		} else if (strcmp(*argv, "hook-type") == 0) {
+			int hook_type;
+
+			NEXT_ARG();
+
+			hook_type = ila_hook_name2type(*argv);
+			if (hook_type < 0)
+				invarg("\"hook-type\" value is invalid\n",
+				       *argv);
+
+			rta_addattr8(rta, 1024, ILA_ATTR_HOOK_TYPE,
+				     (__u8)hook_type);
+
+			argc--; argv++;
 		} else {
 			break;
 		}
-- 
2.11.0

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

* [PATCH iproute 5/5] ila: create ila_common.h
  2017-11-22 20:05 [PATCH iproute 0/5] ila: additional configuratio support Tom Herbert
                   ` (3 preceding siblings ...)
  2017-11-22 20:05 ` [PATCH iproute 4/5] ila: support for configuring identifier and hook types Tom Herbert
@ 2017-11-22 20:05 ` Tom Herbert
  2017-11-24 17:26 ` [PATCH iproute 0/5] ila: additional configuratio support Stephen Hemminger
  5 siblings, 0 replies; 7+ messages in thread
From: Tom Herbert @ 2017-11-22 20:05 UTC (permalink / raw)
  To: stephen; +Cc: netdev, rohit, Tom Herbert

Move common functions related to checksum, identifier and hook-type
parsing to a common include file.

Signed-off-by: Tom Herbert <tom@quantonium.net>
---
 ip/ila_common.h       | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++
 ip/ipila.c            |  77 +-----------------------------------
 ip/iproute_lwtunnel.c |  97 +---------------------------------------------
 3 files changed, 107 insertions(+), 172 deletions(-)
 create mode 100644 ip/ila_common.h

diff --git a/ip/ila_common.h b/ip/ila_common.h
new file mode 100644
index 00000000..04c6c2ed
--- /dev/null
+++ b/ip/ila_common.h
@@ -0,0 +1,105 @@
+#ifndef _ILA_COMMON_H_
+#define _ILA_COMMON_H_
+
+#include <linux/ila.h>
+#include <string.h>
+
+static inline char *ila_csum_mode2name(__u8 csum_mode)
+{
+	switch (csum_mode) {
+	case ILA_CSUM_ADJUST_TRANSPORT:
+		return "adj-transport";
+	case ILA_CSUM_NEUTRAL_MAP:
+		return "neutral-map";
+	case ILA_CSUM_NO_ACTION:
+		return "no-action";
+	case ILA_CSUM_NEUTRAL_MAP_AUTO:
+		return "neutral-map-auto";
+	default:
+		return "unknown";
+	}
+}
+
+static inline int ila_csum_name2mode(char *name)
+{
+	if (strcmp(name, "adj-transport") == 0)
+		return ILA_CSUM_ADJUST_TRANSPORT;
+	else if (strcmp(name, "neutral-map") == 0)
+		return ILA_CSUM_NEUTRAL_MAP;
+	else if (strcmp(name, "neutral-map-auto") == 0)
+		return ILA_CSUM_NEUTRAL_MAP_AUTO;
+	else if (strcmp(name, "no-action") == 0)
+		return ILA_CSUM_NO_ACTION;
+	else if (strcmp(name, "neutral-map-auto") == 0)
+		return ILA_CSUM_NEUTRAL_MAP_AUTO;
+	else
+		return -1;
+}
+
+static inline char *ila_ident_type2name(__u8 ident_type)
+{
+	switch (ident_type) {
+	case ILA_ATYPE_IID:
+		return "iid";
+	case ILA_ATYPE_LUID:
+		return "luid";
+	case ILA_ATYPE_VIRT_V4:
+		return "virt-v4";
+	case ILA_ATYPE_VIRT_UNI_V6:
+		return "virt-uni-v6";
+	case ILA_ATYPE_VIRT_MULTI_V6:
+		return "virt-multi-v6";
+	case ILA_ATYPE_NONLOCAL_ADDR:
+		return "nonlocal-addr";
+	case ILA_ATYPE_USE_FORMAT:
+		return "use-format";
+	default:
+		return "unknown";
+	}
+}
+
+static inline int ila_ident_name2type(char *name)
+{
+	if (!strcmp(name, "luid"))
+		return ILA_ATYPE_LUID;
+	else if (!strcmp(name, "use-format"))
+		return ILA_ATYPE_USE_FORMAT;
+#if 0 /* No kernel support for configuring these yet */
+	else if (!strcmp(name, "iid"))
+		return ILA_ATYPE_IID;
+	else if (!strcmp(name, "virt-v4"))
+		return ILA_ATYPE_VIRT_V4;
+	else if (!strcmp(name, "virt-uni-v6"))
+		return ILA_ATYPE_VIRT_UNI_V6;
+	else if (!strcmp(name, "virt-multi-v6"))
+		return ILA_ATYPE_VIRT_MULTI_V6;
+	else if (!strcmp(name, "nonlocal-addr"))
+		return ILA_ATYPE_NONLOCAL_ADDR;
+#endif
+	else
+		return -1;
+}
+
+static inline char *ila_hook_type2name(__u8 hook_type)
+{
+	switch (hook_type) {
+	case ILA_HOOK_ROUTE_OUTPUT:
+		return "output";
+	case ILA_HOOK_ROUTE_INPUT:
+		return "input";
+	default:
+		return "unknown";
+	}
+}
+
+static inline int ila_hook_name2type(char *name)
+{
+	if (!strcmp(name, "output"))
+		return ILA_HOOK_ROUTE_OUTPUT;
+	else if (!strcmp(name, "input"))
+		return ILA_HOOK_ROUTE_INPUT;
+	else
+		return -1;
+}
+
+#endif /* _ILA_COMMON_H_ */
diff --git a/ip/ipila.c b/ip/ipila.c
index c7a8ede8..fcc20bf7 100644
--- a/ip/ipila.c
+++ b/ip/ipila.c
@@ -22,6 +22,7 @@
 #include "libgenl.h"
 #include "utils.h"
 #include "ip_common.h"
+#include "ila_common.h"
 
 static void usage(void)
 {
@@ -51,82 +52,6 @@ static int genl_family = -1;
 
 #define ADDR_BUF_SIZE sizeof("xxxx:xxxx:xxxx:xxxx")
 
-static char *ila_csum_mode2name(__u8 csum_mode)
-{
-	switch (csum_mode) {
-	case ILA_CSUM_ADJUST_TRANSPORT:
-		return "adj-transport";
-	case ILA_CSUM_NEUTRAL_MAP:
-		return "neutral-map";
-	case ILA_CSUM_NO_ACTION:
-		return "no-action";
-	case ILA_CSUM_NEUTRAL_MAP_AUTO:
-		return "neutral-map-auto";
-	default:
-		return "unknown";
-	}
-}
-
-static int ila_csum_name2mode(char *name)
-{
-	if (strcmp(name, "adj-transport") == 0)
-		return ILA_CSUM_ADJUST_TRANSPORT;
-	else if (strcmp(name, "neutral-map") == 0)
-		return ILA_CSUM_NEUTRAL_MAP;
-	else if (strcmp(name, "neutral-map-auto") == 0)
-		return ILA_CSUM_NEUTRAL_MAP_AUTO;
-	else if (strcmp(name, "no-action") == 0)
-		return ILA_CSUM_NO_ACTION;
-	else if (strcmp(name, "neutral-map-auto") == 0)
-		return ILA_CSUM_NEUTRAL_MAP_AUTO;
-	else
-		return -1;
-}
-
-static char *ila_ident_type2name(__u8 ident_type)
-{
-	switch (ident_type) {
-	case ILA_ATYPE_IID:
-		return "iid";
-	case ILA_ATYPE_LUID:
-		return "luid";
-	case ILA_ATYPE_VIRT_V4:
-		return "virt-v4";
-	case ILA_ATYPE_VIRT_UNI_V6:
-		return "virt-uni-v6";
-	case ILA_ATYPE_VIRT_MULTI_V6:
-		return "virt-multi-v6";
-	case ILA_ATYPE_NONLOCAL_ADDR:
-		return "nonlocal-addr";
-	case ILA_ATYPE_USE_FORMAT:
-		return "use-format";
-	default:
-		return "unknown";
-	}
-}
-
-static int ila_ident_name2type(char *name)
-{
-	if (!strcmp(name, "luid"))
-		return ILA_ATYPE_LUID;
-	else if (!strcmp(name, "use-format"))
-		return ILA_ATYPE_USE_FORMAT;
-#if 0 /* No kernel support for configuring these yet */
-	else if (!strcmp(name, "iid"))
-		return ILA_ATYPE_IID;
-	else if (!strcmp(name, "virt-v4"))
-		return ILA_ATYPE_VIRT_V4;
-	else if (!strcmp(name, "virt-uni-v6"))
-		return ILA_ATYPE_VIRT_UNI_V6;
-	else if (!strcmp(name, "virt-multi-v6"))
-		return ILA_ATYPE_VIRT_MULTI_V6;
-	else if (!strcmp(name, "nonlocal-addr"))
-		return ILA_ATYPE_NONLOCAL_ADDR;
-#endif
-	else
-		return -1;
-}
-
 static int print_addr64(__u64 addr, char *buff, size_t len)
 {
 	__u16 *words = (__u16 *)&addr;
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index e57cc9f3..27266171 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -25,6 +25,7 @@
 #include "utils.h"
 #include "iproute_lwtunnel.h"
 #include "bpf_util.h"
+#include "ila_common.h"
 
 #include <linux/seg6.h>
 #include <linux/seg6_iptunnel.h>
@@ -279,102 +280,6 @@ static void print_encap_ip(FILE *fp, struct rtattr *encap)
 		fprintf(fp, "tos %d ", rta_getattr_u8(tb[LWTUNNEL_IP_TOS]));
 }
 
-static char *ila_csum_mode2name(__u8 csum_mode)
-{
-	switch (csum_mode) {
-	case ILA_CSUM_ADJUST_TRANSPORT:
-		return "adj-transport";
-	case ILA_CSUM_NEUTRAL_MAP:
-		return "neutral-map";
-	case ILA_CSUM_NO_ACTION:
-		return "no-action";
-	case ILA_CSUM_NEUTRAL_MAP_AUTO:
-		return "neutral-map-auto";
-	default:
-		return "unknown";
-	}
-}
-
-static int ila_csum_name2mode(char *name)
-{
-	if (strcmp(name, "adj-transport") == 0)
-		return ILA_CSUM_ADJUST_TRANSPORT;
-	else if (strcmp(name, "neutral-map") == 0)
-		return ILA_CSUM_NEUTRAL_MAP;
-	else if (strcmp(name, "no-action") == 0)
-		return ILA_CSUM_NO_ACTION;
-	else if (strcmp(name, "neutral-map-auto") == 0)
-		return ILA_CSUM_NEUTRAL_MAP_AUTO;
-	else
-		return -1;
-}
-
-static char *ila_ident_type2name(__u8 ident_type)
-{
-	switch (ident_type) {
-	case ILA_ATYPE_IID:
-		return "iid";
-	case ILA_ATYPE_LUID:
-		return "luid";
-	case ILA_ATYPE_VIRT_V4:
-		return "virt-v4";
-	case ILA_ATYPE_VIRT_UNI_V6:
-		return "virt-uni-v6";
-	case ILA_ATYPE_VIRT_MULTI_V6:
-		return "virt-multi-v6";
-	case ILA_ATYPE_NONLOCAL_ADDR:
-		return "nonlocal-addr";
-	case ILA_ATYPE_USE_FORMAT:
-		return "use-format";
-	default:
-		return "unknown";
-	}
-}
-
-static int ila_ident_name2type(char *name)
-{
-	if (!strcmp(name, "luid"))
-		return ILA_ATYPE_LUID;
-	else if (!strcmp(name, "use-format"))
-		return ILA_ATYPE_USE_FORMAT;
-#if 0 /* No kernel support for configuring these yet */
-	else if (!strcmp(name, "iid"))
-		return ILA_ATYPE_IID;
-	else if (!strcmp(name, "virt-v4"))
-		return ILA_ATYPE_VIRT_V4;
-	else if (!strcmp(name, "virt-uni-v6"))
-		return ILA_ATYPE_VIRT_UNI_V6;
-	else if (!strcmp(name, "virt-multi-v6"))
-		return ILA_ATYPE_VIRT_MULTI_V6;
-	else if (!strcmp(name, "nonlocal-addr"))
-		return ILA_ATYPE_NONLOCAL_ADDR;
-#endif
-	else
-		return -1;
-}
-
-static char *ila_hook_type2name(__u8 hook_type)
-{
-	switch (hook_type) {
-	case ILA_HOOK_ROUTE_OUTPUT:
-		return "output";
-	case ILA_HOOK_ROUTE_INPUT:
-		return "input";
-	default:
-		return "unknown";
-	}
-}
-
-static int ila_hook_name2type(char *name)
-{
-	if (!strcmp(name, "output"))
-		return ILA_HOOK_ROUTE_OUTPUT;
-	else if (!strcmp(name, "input"))
-		return ILA_HOOK_ROUTE_INPUT;
-	else
-		return -1;
-}
-
 static void print_encap_ila(FILE *fp, struct rtattr *encap)
 {
 	struct rtattr *tb[ILA_ATTR_MAX+1];
-- 
2.11.0

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

* Re: [PATCH iproute 0/5] ila: additional configuratio support
  2017-11-22 20:05 [PATCH iproute 0/5] ila: additional configuratio support Tom Herbert
                   ` (4 preceding siblings ...)
  2017-11-22 20:05 ` [PATCH iproute 5/5] ila: create ila_common.h Tom Herbert
@ 2017-11-24 17:26 ` Stephen Hemminger
  5 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2017-11-24 17:26 UTC (permalink / raw)
  To: Tom Herbert; +Cc: netdev, rohit

On Wed, 22 Nov 2017 12:05:32 -0800
Tom Herbert <tom@quantonium.net> wrote:

> Add configuration support for checksum neutral-map-auto, identifier
> tyoes, and hook type (for LWT).
> 
> Tom Herbert (5):
>   ila: Fix reporting of ILA locators and locator match
>   ila: added csum neutral support to ipila
>   ila: support to configure checksum neutral-map-auto
>   ila: support for configuring identifier and hook types
>   ila: create ila_common.h
> 
>  ip/ila_common.h       | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  ip/ipila.c            |  57 +++++++++++++++++++++++++--
>  ip/iproute_lwtunnel.c |  68 +++++++++++++++++++-------------
>  3 files changed, 200 insertions(+), 30 deletions(-)
>  create mode 100644 ip/ila_common.h
> 

Applied, thanks.

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

end of thread, other threads:[~2017-11-24 17:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-22 20:05 [PATCH iproute 0/5] ila: additional configuratio support Tom Herbert
2017-11-22 20:05 ` [PATCH iproute 1/5] ila: Fix reporting of ILA locators and locator match Tom Herbert
2017-11-22 20:05 ` [PATCH iproute 2/5] ila: added csum neutral support to ipila Tom Herbert
2017-11-22 20:05 ` [PATCH iproute 3/5] ila: support to configure checksum neutral-map-auto Tom Herbert
2017-11-22 20:05 ` [PATCH iproute 4/5] ila: support for configuring identifier and hook types Tom Herbert
2017-11-22 20:05 ` [PATCH iproute 5/5] ila: create ila_common.h Tom Herbert
2017-11-24 17:26 ` [PATCH iproute 0/5] ila: additional configuratio support Stephen Hemminger

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