Skip to contentSkip to conversation

ila: additional configuratio support

PATCH Applied Tom Herbert 2 participants 7 messages Nov 22, 2017 – Nov 24, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover ila: additional configuratio support

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
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/5 ila: Fix reporting of ILA locators and locator match

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

---
 ip/ipila.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ip/ipila.c +1 -1
index 0403fc42..fe5c4d8b 100644
@@ -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 {
Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/5 ila: added csum neutral support to ipila

In reply to Tom Herbert

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

---
 ip/ipila.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)
ip/ipila.c +55 -2
index fe5c4d8b..d4935d18 100644
@@ -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;
 }
 
Signature · 1 line
2.11.0
#3 lore raw

PATCH 3/5 ila: support to configure checksum neutral-map-auto

In reply to 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).

---
 ip/ipila.c            | 8 +++++---
 ip/iproute_lwtunnel.c | 4 ++++
 2 files changed, 9 insertions(+), 3 deletions(-)
ip/ipila.c +5 -3
index d4935d18..0b706f0b 100644
@@ -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;
 }
ip/iproute_lwtunnel.c +4 -0
index 1c8adbe7..ebedd94a 100644
@@ -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;
 }
Signature · 1 line
2.11.0
#4 lore raw

PATCH 4/5 ila: support for configuring identifier and hook types

In reply to Tom Herbert

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

---
 ip/ipila.c            |  75 ++++++++++++++++++++++++++++++++++-
 ip/iproute_lwtunnel.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 179 insertions(+), 3 deletions(-)
ip/ipila.c +73 -2
index 0b706f0b..c7a8ede8 100644
@@ -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;
 }
 
ip/iproute_lwtunnel.c +106 -1

125 lines not on this page · raw message

Signature · 1 line
2.11.0
#5 lore raw

PATCH 5/5 ila: create ila_common.h

In reply to Tom Herbert

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

---
 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
ip/ila_common.h new file +105 -0
new file mode 100644
index 00000000..04c6c2ed
@@ -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_ */
ip/ipila.c +1 -76

89 lines not on this page · raw message

ip/iproute_lwtunnel.c +1 -96

109 lines not on this page · raw message

Signature · 1 line
2.11.0
#6 lore raw
In reply to Tom Herbert
Quoted 10 lines · On Wed, 22 Nov 2017 12:05:32 -0800 Tom Herbert <[email protected]> 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

Quoted 6 lines
 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.