* [PATCH iproute v3 0/5] iproute: ila and fou additions
@ 2016-08-09 21:41 Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 1/5] ila: Support for checksum neutral translation Tom Herbert
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Tom Herbert @ 2016-08-09 21:41 UTC (permalink / raw)
To: stephen, netdev; +Cc: kernel-team, Tom Herbert
Patch set includes:
- Allow configuring checksum mode for ila LWT (e.g. configure
checksum neutral
- Configuration for performing ila translations using netfilter hook
- fou encapsulation for ip6tnl and gre6
- fou listener for IPv6
v2:
- Fixed coding style issues
v3:
- Fixed uniinitialized variable waning in ipila.c
Tom Herbert (5):
ila: Support for checksum neutral translation
ila: Support for configuring ila to use netfilter hook
ip6tnl: Support for fou encapsulation
gre6: Support for fou encapsulation
fou: Allowing configuring IPv6 listener
ip/Makefile | 2 +-
ip/ip.c | 3 +-
ip/ip_common.h | 1 +
ip/ipfou.c | 9 +-
ip/ipila.c | 268 ++++++++++++++++++++++++++++++++++++++++++++++++++
ip/iproute_lwtunnel.c | 58 ++++++++++-
ip/link_gre.c | 2 +-
ip/link_gre6.c | 101 +++++++++++++++++++
ip/link_ip6tnl.c | 92 ++++++++++++++++-
9 files changed, 528 insertions(+), 8 deletions(-)
create mode 100644 ip/ipila.c
--
2.8.0.rc2
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH iproute v3 1/5] ila: Support for checksum neutral translation
2016-08-09 21:41 [PATCH iproute v3 0/5] iproute: ila and fou additions Tom Herbert
@ 2016-08-09 21:41 ` Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 2/5] ila: Support for configuring ila to use netfilter hook Tom Herbert
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-08-09 21:41 UTC (permalink / raw)
To: stephen, netdev; +Cc: kernel-team, Tom Herbert
Add configuration of ila LWT tunnels for checksum mode including
checksum neutral translation.
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
ip/iproute_lwtunnel.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c
index bdbb15d..b656143 100644
--- a/ip/iproute_lwtunnel.c
+++ b/ip/iproute_lwtunnel.c
@@ -90,6 +90,32 @@ 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";
+ default:
+ return "unknown";
+ }
+}
+
+static __u8 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 void print_encap_ila(FILE *fp, struct rtattr *encap)
{
struct rtattr *tb[ILA_ATTR_MAX+1];
@@ -103,6 +129,10 @@ static void print_encap_ila(FILE *fp, struct rtattr *encap)
abuf, sizeof(abuf));
fprintf(fp, " %s ", abuf);
}
+
+ if (tb[ILA_ATTR_CSUM_MODE])
+ fprintf(fp, " csum-mode %s ",
+ ila_csum_mode2name(rta_getattr_u8(tb[ILA_ATTR_CSUM_MODE])));
}
static void print_encap_ip6(FILE *fp, struct rtattr *encap)
@@ -246,10 +276,34 @@ static int parse_encap_ila(struct rtattr *rta, size_t len,
exit(1);
}
+ argc--; argv++;
+
rta_addattr64(rta, 1024, ILA_ATTR_LOCATOR, locator);
- *argcp = argc;
- *argvp = argv;
+ while (argc > 0) {
+ if (strcmp(*argv, "csum-mode") == 0) {
+ __u8 csum_mode;
+
+ NEXT_ARG();
+
+ csum_mode = ila_csum_name2mode(*argv);
+ if (csum_mode < 0)
+ invarg("\"csum-mode\" value is invalid\n", *argv);
+
+ rta_addattr8(rta, 1024, ILA_ATTR_CSUM_MODE, csum_mode);
+
+ argc--; argv++;
+ } else {
+ break;
+ }
+ }
+
+ /* argv is currently the first unparsed argument,
+ * but the lwt_parse_encap() caller will move to the next,
+ * so step back
+ */
+ *argcp = argc + 1;
+ *argvp = argv - 1;
return 0;
}
--
2.8.0.rc2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute v3 2/5] ila: Support for configuring ila to use netfilter hook
2016-08-09 21:41 [PATCH iproute v3 0/5] iproute: ila and fou additions Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 1/5] ila: Support for checksum neutral translation Tom Herbert
@ 2016-08-09 21:41 ` Tom Herbert
2016-08-12 20:01 ` Stephen Hemminger
2016-08-09 21:41 ` [PATCH iproute v3 3/5] ip6tnl: Support for fou encapsulation Tom Herbert
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Tom Herbert @ 2016-08-09 21:41 UTC (permalink / raw)
To: stephen, netdev; +Cc: kernel-team, Tom Herbert
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
ip/Makefile | 2 +-
ip/ip.c | 3 +-
ip/ip_common.h | 1 +
ip/ipila.c | 268 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 272 insertions(+), 2 deletions(-)
create mode 100644 ip/ipila.c
diff --git a/ip/Makefile b/ip/Makefile
index 33e9286..86c8cdc 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -7,7 +7,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
iplink_vxlan.o tcp_metrics.o iplink_ipoib.o ipnetconf.o link_ip6tnl.o \
link_iptnl.o link_gre6.o iplink_bond.o iplink_bond_slave.o iplink_hsr.o \
iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \
- iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o
+ iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o
RTMONOBJ=rtmon.o
diff --git a/ip/ip.c b/ip/ip.c
index 166ef17..cb3adcb 100644
--- a/ip/ip.c
+++ b/ip/ip.c
@@ -51,7 +51,7 @@ static void usage(void)
" ip [ -force ] -batch filename\n"
"where OBJECT := { link | address | addrlabel | route | rule | neigh | ntable |\n"
" tunnel | tuntap | maddress | mroute | mrule | monitor | xfrm |\n"
-" netns | l2tp | fou | macsec | tcp_metrics | token | netconf }\n"
+" netns | l2tp | fou | macsec | tcp_metrics | token | netconf | ila }\n"
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |\n"
" -h[uman-readable] | -iec |\n"
" -f[amily] { inet | inet6 | ipx | dnet | mpls | bridge | link } |\n"
@@ -84,6 +84,7 @@ static const struct cmd {
{ "link", do_iplink },
{ "l2tp", do_ipl2tp },
{ "fou", do_ipfou },
+ { "ila", do_ipila },
{ "macsec", do_ipmacsec },
{ "tunnel", do_iptunnel },
{ "tunl", do_iptunnel },
diff --git a/ip/ip_common.h b/ip/ip_common.h
index c818812..93ff5bc 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -52,6 +52,7 @@ int do_netns(int argc, char **argv);
int do_xfrm(int argc, char **argv);
int do_ipl2tp(int argc, char **argv);
int do_ipfou(int argc, char **argv);
+extern int do_ipila(int argc, char **argv);
int do_tcp_metrics(int argc, char **argv);
int do_ipnetconf(int argc, char **argv);
int do_iptoken(int argc, char **argv);
diff --git a/ip/ipila.c b/ip/ipila.c
new file mode 100644
index 0000000..42da9f2
--- /dev/null
+++ b/ip/ipila.c
@@ -0,0 +1,268 @@
+/*
+ * ipila.c ILA (Identifier Locator Addressing) support
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Tom Herbert <tom@herbertland.com>
+ */
+
+#include <netdb.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <net/if.h>
+#include <linux/ila.h>
+#include <linux/genetlink.h>
+#include <linux/ip.h>
+#include <arpa/inet.h>
+
+#include "libgenl.h"
+#include "utils.h"
+#include "ip_common.h"
+
+static void usage(void)
+{
+ fprintf(stderr, "Usage: ip ila add loc_match LOCATOR_MATCH "
+ "loc LOCATOR [ dev DEV ]\n");
+ fprintf(stderr, " ip ila del loc_match LOCATOR_MATCH "
+ "[ loc LOCATOR ] [ dev DEV ]\n");
+ fprintf(stderr, " ip ila list\n");
+ fprintf(stderr, "\n");
+
+ exit(-1);
+}
+
+/* netlink socket */
+static struct rtnl_handle genl_rth = { .fd = -1 };
+static int genl_family = -1;
+
+#define ILA_REQUEST(_req, _bufsiz, _cmd, _flags) \
+ GENL_REQUEST(_req, _bufsiz, genl_family, 0, \
+ ILA_GENL_VERSION, _cmd, _flags)
+
+#define ILA_RTA(g) ((struct rtattr *)(((char *)(g)) + \
+ NLMSG_ALIGN(sizeof(struct genlmsghdr))))
+
+#define ADDR_BUF_SIZE sizeof("xxxx:xxxx:xxxx:xxxx")
+
+static int print_addr64(__u64 addr, char *buff, size_t len)
+{
+ __u16 *words = (__u16 *)&addr;
+ __u16 v;
+ int i, ret;
+ size_t written = 0;
+ char *sep = ":";
+
+ for (i = 0; i < 4; i++) {
+ v = ntohs(words[i]);
+
+ if (i == 3)
+ sep = "";
+
+ ret = snprintf(&buff[written], len - written, "%x%s", v, sep);
+ if (ret < 0)
+ return ret;
+
+ written += ret;
+ }
+
+ return written;
+}
+
+static void print_ila_locid(FILE *fp, int attr, struct rtattr *tb[], int space)
+{
+ char abuf[256];
+ size_t blen;
+ int i;
+
+ if (tb[attr]) {
+ blen = print_addr64(rta_getattr_u32(tb[attr]),
+ abuf, sizeof(abuf));
+ fprintf(fp, "%s", abuf);
+ } else {
+ fprintf(fp, "-");
+ blen = 1;
+ }
+
+ for (i = 0; i < space - blen; i++)
+ fprintf(fp, " ");
+}
+
+static int print_ila_mapping(const struct sockaddr_nl *who,
+ struct nlmsghdr *n, void *arg)
+{
+ FILE *fp = (FILE *)arg;
+ struct genlmsghdr *ghdr;
+ struct rtattr *tb[ILA_ATTR_MAX + 1];
+ int len = n->nlmsg_len;
+
+ if (n->nlmsg_type != genl_family)
+ return 0;
+
+ len -= NLMSG_LENGTH(GENL_HDRLEN);
+ if (len < 0)
+ return -1;
+
+ ghdr = NLMSG_DATA(n);
+ parse_rtattr(tb, ILA_ATTR_MAX, (void *) ghdr + GENL_HDRLEN, len);
+
+ print_ila_locid(fp, ILA_ATTR_LOCATOR_MATCH, tb, ADDR_BUF_SIZE);
+ 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])));
+ else
+ fprintf(fp, "-");
+ fprintf(fp, "\n");
+
+ return 0;
+}
+
+#define NLMSG_BUF_SIZE 4096
+
+static int do_list(int argc, char **argv)
+{
+ ILA_REQUEST(req, 1024, ILA_CMD_GET, NLM_F_REQUEST | NLM_F_DUMP);
+
+ if (argc > 0) {
+ fprintf(stderr, "\"ip ila show\" does not take "
+ "any arguments.\n");
+ return -1;
+ }
+
+ if (rtnl_send(&genl_rth, (void *)&req, req.n.nlmsg_len) < 0) {
+ perror("Cannot send dump request");
+ exit(1);
+ }
+
+ if (rtnl_dump_filter(&genl_rth, print_ila_mapping, stdout) < 0) {
+ fprintf(stderr, "Dump terminated\n");
+ return 1;
+ }
+
+ return 0;
+}
+
+static int ila_parse_opt(int argc, char **argv, struct nlmsghdr *n,
+ bool adding)
+{
+ __u64 locator = 0;
+ __u64 locator_match = 0;
+ int ifindex = 0;
+ bool loc_set = false;
+ bool loc_match_set = false;
+ bool ifindex_set = false;
+
+ while (argc > 0) {
+ if (!matches(*argv, "loc")) {
+ NEXT_ARG();
+
+ if (get_addr64(&locator, *argv) < 0) {
+ fprintf(stderr, "Bad locator: %s\n", *argv);
+ return -1;
+ }
+ loc_set = true;
+ } else if (!matches(*argv, "loc_match")) {
+ NEXT_ARG();
+
+ if (get_addr64(&locator_match, *argv) < 0) {
+ fprintf(stderr, "Bad locator to match: %s\n",
+ *argv);
+ return -1;
+ }
+ loc_match_set = true;
+ } else if (!matches(*argv, "dev")) {
+ NEXT_ARG();
+
+ ifindex = ll_name_to_index(*argv);
+ if (ifindex == 0) {
+ fprintf(stderr, "No such interface: %s\n",
+ *argv);
+ return -1;
+ }
+ ifindex_set = true;
+ } else {
+ usage();
+ return -1;
+ }
+ argc--, argv++;
+ }
+
+ if (adding) {
+ if (!loc_set) {
+ fprintf(stderr, "ila: missing locator\n");
+ return -1;
+ }
+ if (!loc_match_set) {
+ fprintf(stderr, "ila: missing locator0match\n");
+ return -1;
+ }
+ }
+
+ if (loc_match_set)
+ addattr64(n, 1024, ILA_ATTR_LOCATOR_MATCH, locator_match);
+ if (loc_set)
+ addattr64(n, 1024, ILA_ATTR_LOCATOR, locator);
+
+ if (ifindex_set)
+ addattr32(n, 1024, ILA_ATTR_IFINDEX, ifindex);
+
+ return 0;
+}
+
+static int do_add(int argc, char **argv)
+{
+ ILA_REQUEST(req, 1024, ILA_CMD_ADD, NLM_F_REQUEST);
+
+ ila_parse_opt(argc, argv, &req.n, true);
+
+ if (rtnl_talk(&genl_rth, &req.n, NULL, 0) < 0)
+ return -2;
+
+ return 0;
+}
+
+static int do_del(int argc, char **argv)
+{
+ ILA_REQUEST(req, 1024, ILA_CMD_DEL, NLM_F_REQUEST);
+
+ ila_parse_opt(argc, argv, &req.n, false);
+
+ if (rtnl_talk(&genl_rth, &req.n, NULL, 0) < 0)
+ return -2;
+
+ return 0;
+}
+
+int do_ipila(int argc, char **argv)
+{
+ if (genl_family < 0) {
+ if (rtnl_open_byproto(&genl_rth, 0, NETLINK_GENERIC) < 0) {
+ fprintf(stderr, "Cannot open generic netlink socket\n");
+ exit(1);
+ }
+
+ genl_family = genl_resolve_family(&genl_rth, ILA_GENL_NAME);
+ if (genl_family < 0)
+ exit(1);
+ }
+
+ if (argc < 1)
+ usage();
+
+ if (matches(*argv, "add") == 0)
+ return do_add(argc-1, argv+1);
+ if (matches(*argv, "delete") == 0)
+ return do_del(argc-1, argv+1);
+ if (matches(*argv, "list") == 0)
+ return do_list(argc-1, argv+1);
+ if (matches(*argv, "help") == 0)
+ usage();
+
+ fprintf(stderr, "Command \"%s\" is unknown, try \"ip ila help\".\n",
+ *argv);
+ exit(-1);
+}
--
2.8.0.rc2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute v3 3/5] ip6tnl: Support for fou encapsulation
2016-08-09 21:41 [PATCH iproute v3 0/5] iproute: ila and fou additions Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 1/5] ila: Support for checksum neutral translation Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 2/5] ila: Support for configuring ila to use netfilter hook Tom Herbert
@ 2016-08-09 21:41 ` Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 4/5] gre6: " Tom Herbert
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-08-09 21:41 UTC (permalink / raw)
To: stephen, netdev; +Cc: kernel-team, Tom Herbert
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
ip/link_ip6tnl.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 91 insertions(+), 1 deletion(-)
diff --git a/ip/link_ip6tnl.c b/ip/link_ip6tnl.c
index 89861c6..59162a3 100644
--- a/ip/link_ip6tnl.c
+++ b/ip/link_ip6tnl.c
@@ -37,6 +37,9 @@ static void print_usage(FILE *f)
fprintf(f, " [ dev PHYS_DEV ] [ encaplimit ELIM ]\n");
fprintf(f, " [ hoplimit HLIM ] [ tclass TCLASS ] [ flowlabel FLOWLABEL ]\n");
fprintf(f, " [ dscp inherit ] [ fwmark inherit ]\n");
+ fprintf(f, " [ noencap ] [ encap { fou | gue | none } ]\n");
+ fprintf(f, " [ encap-sport PORT ] [ encap-dport PORT ]\n");
+ fprintf(f, " [ [no]encap-csum ] [ [no]encap-csum6 ] [ [no]encap-remcsum ]\n");
fprintf(f, "\n");
fprintf(f, "Where: NAME := STRING\n");
fprintf(f, " ADDR := IPV6_ADDRESS\n");
@@ -82,6 +85,10 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
__u32 flags = 0;
__u32 link = 0;
__u8 proto = 0;
+ __u16 encaptype = 0;
+ __u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
+ __u16 encapsport = 0;
+ __u16 encapdport = 0;
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
if (rtnl_talk(&rth, &req.n, &req.n, sizeof(req)) < 0) {
@@ -182,7 +189,7 @@ get_failed:
if (get_u8(&uval, *argv, 0))
invarg("invalid HLIM", *argv);
hop_limit = uval;
- } else if (matches(*argv, "encaplimit") == 0) {
+ } else if (strcmp(*argv, "encaplimit") == 0) {
NEXT_ARG();
if (strcmp(*argv, "none") == 0) {
flags |= IP6_TNL_F_IGN_ENCAP_LIMIT;
@@ -236,6 +243,40 @@ get_failed:
if (strcmp(*argv, "inherit") != 0)
invarg("not inherit", *argv);
flags |= IP6_TNL_F_USE_ORIG_FWMARK;
+ } else if (strcmp(*argv, "noencap") == 0) {
+ encaptype = TUNNEL_ENCAP_NONE;
+ } else if (strcmp(*argv, "encap") == 0) {
+ NEXT_ARG();
+ if (strcmp(*argv, "fou") == 0)
+ encaptype = TUNNEL_ENCAP_FOU;
+ else if (strcmp(*argv, "gue") == 0)
+ encaptype = TUNNEL_ENCAP_GUE;
+ else if (strcmp(*argv, "none") == 0)
+ encaptype = TUNNEL_ENCAP_NONE;
+ else
+ invarg("Invalid encap type.", *argv);
+ } else if (strcmp(*argv, "encap-sport") == 0) {
+ NEXT_ARG();
+ if (strcmp(*argv, "auto") == 0)
+ encapsport = 0;
+ else if (get_u16(&encapsport, *argv, 0))
+ invarg("Invalid source port.", *argv);
+ } else if (strcmp(*argv, "encap-dport") == 0) {
+ NEXT_ARG();
+ if (get_u16(&encapdport, *argv, 0))
+ invarg("Invalid destination port.", *argv);
+ } else if (strcmp(*argv, "encap-csum") == 0) {
+ encapflags |= TUNNEL_ENCAP_FLAG_CSUM;
+ } else if (strcmp(*argv, "noencap-csum") == 0) {
+ encapflags &= ~TUNNEL_ENCAP_FLAG_CSUM;
+ } else if (strcmp(*argv, "encap-udp6-csum") == 0) {
+ encapflags |= TUNNEL_ENCAP_FLAG_CSUM6;
+ } else if (strcmp(*argv, "noencap-udp6-csum") == 0) {
+ encapflags &= ~TUNNEL_ENCAP_FLAG_CSUM6;
+ } else if (strcmp(*argv, "encap-remcsum") == 0) {
+ encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM;
+ } else if (strcmp(*argv, "noencap-remcsum") == 0) {
+ encapflags |= ~TUNNEL_ENCAP_FLAG_REMCSUM;
} else
usage();
argc--, argv++;
@@ -250,6 +291,11 @@ get_failed:
addattr32(n, 1024, IFLA_IPTUN_FLAGS, flags);
addattr32(n, 1024, IFLA_IPTUN_LINK, link);
+ addattr16(n, 1024, IFLA_IPTUN_ENCAP_TYPE, encaptype);
+ addattr16(n, 1024, IFLA_IPTUN_ENCAP_FLAGS, encapflags);
+ addattr16(n, 1024, IFLA_IPTUN_ENCAP_SPORT, htons(encapsport));
+ addattr16(n, 1024, IFLA_IPTUN_ENCAP_DPORT, htons(encapdport));
+
return 0;
}
@@ -334,6 +380,50 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
if (flags & IP6_TNL_F_USE_ORIG_FWMARK)
fprintf(f, "fwmark inherit ");
+
+ if (tb[IFLA_IPTUN_ENCAP_TYPE] &&
+ rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_TYPE]) !=
+ TUNNEL_ENCAP_NONE) {
+ __u16 type = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_TYPE]);
+ __u16 flags = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_FLAGS]);
+ __u16 sport = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_SPORT]);
+ __u16 dport = rta_getattr_u16(tb[IFLA_IPTUN_ENCAP_DPORT]);
+
+ fputs("encap ", f);
+ switch (type) {
+ case TUNNEL_ENCAP_FOU:
+ fputs("fou ", f);
+ break;
+ case TUNNEL_ENCAP_GUE:
+ fputs("gue ", f);
+ break;
+ default:
+ fputs("unknown ", f);
+ break;
+ }
+
+ if (sport == 0)
+ fputs("encap-sport auto ", f);
+ else
+ fprintf(f, "encap-sport %u", ntohs(sport));
+
+ fprintf(f, "encap-dport %u ", ntohs(dport));
+
+ if (flags & TUNNEL_ENCAP_FLAG_CSUM)
+ fputs("encap-csum ", f);
+ else
+ fputs("noencap-csum ", f);
+
+ if (flags & TUNNEL_ENCAP_FLAG_CSUM6)
+ fputs("encap-csum6 ", f);
+ else
+ fputs("noencap-csum6 ", f);
+
+ if (flags & TUNNEL_ENCAP_FLAG_REMCSUM)
+ fputs("encap-remcsum ", f);
+ else
+ fputs("noencap-remcsum ", f);
+ }
}
static void ip6tunnel_print_help(struct link_util *lu, int argc, char **argv,
--
2.8.0.rc2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute v3 4/5] gre6: Support for fou encapsulation
2016-08-09 21:41 [PATCH iproute v3 0/5] iproute: ila and fou additions Tom Herbert
` (2 preceding siblings ...)
2016-08-09 21:41 ` [PATCH iproute v3 3/5] ip6tnl: Support for fou encapsulation Tom Herbert
@ 2016-08-09 21:41 ` Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 5/5] fou: Allowing configuring IPv6 listener Tom Herbert
2016-08-12 19:55 ` [PATCH iproute v3 0/5] iproute: ila and fou additions Stephen Hemminger
5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-08-09 21:41 UTC (permalink / raw)
To: stephen, netdev; +Cc: kernel-team, Tom Herbert
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
ip/link_gre.c | 2 +-
ip/link_gre6.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 102 insertions(+), 1 deletion(-)
diff --git a/ip/link_gre.c b/ip/link_gre.c
index 5dc4067..3b99e56 100644
--- a/ip/link_gre.c
+++ b/ip/link_gre.c
@@ -429,7 +429,7 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
fputs("external ", f);
if (tb[IFLA_GRE_ENCAP_TYPE] &&
- *(__u16 *)RTA_DATA(tb[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
+ rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
__u16 type = rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]);
__u16 flags = rta_getattr_u16(tb[IFLA_GRE_ENCAP_FLAGS]);
__u16 sport = rta_getattr_u16(tb[IFLA_GRE_ENCAP_SPORT]);
diff --git a/ip/link_gre6.c b/ip/link_gre6.c
index 6767ef6..d00db1f 100644
--- a/ip/link_gre6.c
+++ b/ip/link_gre6.c
@@ -38,6 +38,9 @@ static void print_usage(FILE *f)
fprintf(f, " [ hoplimit TTL ] [ encaplimit ELIM ]\n");
fprintf(f, " [ tclass TCLASS ] [ flowlabel FLOWLABEL ]\n");
fprintf(f, " [ dscp inherit ] [ dev PHYS_DEV ]\n");
+ fprintf(f, " [ noencap ] [ encap { fou | gue | none } ]\n");
+ fprintf(f, " [ encap-sport PORT ] [ encap-dport PORT ]\n");
+ fprintf(f, " [ [no]encap-csum ] [ [no]encap-csum6 ] [ [no]encap-remcsum ]\n");
fprintf(f, "\n");
fprintf(f, "Where: NAME := STRING\n");
fprintf(f, " ADDR := IPV6_ADDRESS\n");
@@ -86,6 +89,10 @@ static int gre_parse_opt(struct link_util *lu, int argc, char **argv,
unsigned int flags = 0;
__u8 hop_limit = DEFAULT_TNL_HOP_LIMIT;
__u8 encap_limit = IPV6_DEFAULT_TNL_ENCAP_LIMIT;
+ __u16 encaptype = 0;
+ __u16 encapflags = TUNNEL_ENCAP_FLAG_CSUM6;
+ __u16 encapsport = 0;
+ __u16 encapdport = 0;
int len;
if (!(n->nlmsg_flags & NLM_F_CREATE)) {
@@ -146,6 +153,18 @@ get_failed:
if (greinfo[IFLA_GRE_FLAGS])
flags = rta_getattr_u32(greinfo[IFLA_GRE_FLAGS]);
+
+ if (greinfo[IFLA_GRE_ENCAP_TYPE])
+ encaptype = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_TYPE]);
+
+ if (greinfo[IFLA_GRE_ENCAP_FLAGS])
+ encapflags = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_FLAGS]);
+
+ if (greinfo[IFLA_GRE_ENCAP_SPORT])
+ encapsport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_SPORT]);
+
+ if (greinfo[IFLA_GRE_ENCAP_DPORT])
+ encapdport = rta_getattr_u16(greinfo[IFLA_GRE_ENCAP_DPORT]);
}
while (argc > 0) {
@@ -277,6 +296,40 @@ get_failed:
if (strcmp(*argv, "inherit") != 0)
invarg("not inherit", *argv);
flags |= IP6_TNL_F_RCV_DSCP_COPY;
+ } else if (strcmp(*argv, "noencap") == 0) {
+ encaptype = TUNNEL_ENCAP_NONE;
+ } else if (strcmp(*argv, "encap") == 0) {
+ NEXT_ARG();
+ if (strcmp(*argv, "fou") == 0)
+ encaptype = TUNNEL_ENCAP_FOU;
+ else if (strcmp(*argv, "gue") == 0)
+ encaptype = TUNNEL_ENCAP_GUE;
+ else if (strcmp(*argv, "none") == 0)
+ encaptype = TUNNEL_ENCAP_NONE;
+ else
+ invarg("Invalid encap type.", *argv);
+ } else if (strcmp(*argv, "encap-sport") == 0) {
+ NEXT_ARG();
+ if (strcmp(*argv, "auto") == 0)
+ encapsport = 0;
+ else if (get_u16(&encapsport, *argv, 0))
+ invarg("Invalid source port.", *argv);
+ } else if (strcmp(*argv, "encap-dport") == 0) {
+ NEXT_ARG();
+ if (get_u16(&encapdport, *argv, 0))
+ invarg("Invalid destination port.", *argv);
+ } else if (strcmp(*argv, "encap-csum") == 0) {
+ encapflags |= TUNNEL_ENCAP_FLAG_CSUM;
+ } else if (strcmp(*argv, "noencap-csum") == 0) {
+ encapflags &= ~TUNNEL_ENCAP_FLAG_CSUM;
+ } else if (strcmp(*argv, "encap-udp6-csum") == 0) {
+ encapflags |= TUNNEL_ENCAP_FLAG_CSUM6;
+ } else if (strcmp(*argv, "noencap-udp6-csum") == 0) {
+ encapflags &= ~TUNNEL_ENCAP_FLAG_CSUM6;
+ } else if (strcmp(*argv, "encap-remcsum") == 0) {
+ encapflags |= TUNNEL_ENCAP_FLAG_REMCSUM;
+ } else if (strcmp(*argv, "noencap-remcsum") == 0) {
+ encapflags &= ~TUNNEL_ENCAP_FLAG_REMCSUM;
} else
usage();
argc--; argv++;
@@ -295,6 +348,11 @@ get_failed:
addattr_l(n, 1024, IFLA_GRE_FLOWINFO, &flowinfo, 4);
addattr_l(n, 1024, IFLA_GRE_FLAGS, &flowinfo, 4);
+ addattr16(n, 1024, IFLA_GRE_ENCAP_TYPE, encaptype);
+ addattr16(n, 1024, IFLA_GRE_ENCAP_FLAGS, encapflags);
+ addattr16(n, 1024, IFLA_GRE_ENCAP_SPORT, htons(encapsport));
+ addattr16(n, 1024, IFLA_GRE_ENCAP_DPORT, htons(encapdport));
+
return 0;
}
@@ -393,6 +451,49 @@ static void gre_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
fputs("icsum ", f);
if (oflags & GRE_CSUM)
fputs("ocsum ", f);
+
+ if (tb[IFLA_GRE_ENCAP_TYPE] &&
+ rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]) != TUNNEL_ENCAP_NONE) {
+ __u16 type = rta_getattr_u16(tb[IFLA_GRE_ENCAP_TYPE]);
+ __u16 flags = rta_getattr_u16(tb[IFLA_GRE_ENCAP_FLAGS]);
+ __u16 sport = rta_getattr_u16(tb[IFLA_GRE_ENCAP_SPORT]);
+ __u16 dport = rta_getattr_u16(tb[IFLA_GRE_ENCAP_DPORT]);
+
+ fputs("encap ", f);
+ switch (type) {
+ case TUNNEL_ENCAP_FOU:
+ fputs("fou ", f);
+ break;
+ case TUNNEL_ENCAP_GUE:
+ fputs("gue ", f);
+ break;
+ default:
+ fputs("unknown ", f);
+ break;
+ }
+
+ if (sport == 0)
+ fputs("encap-sport auto ", f);
+ else
+ fprintf(f, "encap-sport %u", ntohs(sport));
+
+ fprintf(f, "encap-dport %u ", ntohs(dport));
+
+ if (flags & TUNNEL_ENCAP_FLAG_CSUM)
+ fputs("encap-csum ", f);
+ else
+ fputs("noencap-csum ", f);
+
+ if (flags & TUNNEL_ENCAP_FLAG_CSUM6)
+ fputs("encap-csum6 ", f);
+ else
+ fputs("noencap-csum6 ", f);
+
+ if (flags & TUNNEL_ENCAP_FLAG_REMCSUM)
+ fputs("encap-remcsum ", f);
+ else
+ fputs("noencap-remcsum ", f);
+ }
}
static void gre_print_help(struct link_util *lu, int argc, char **argv,
--
2.8.0.rc2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH iproute v3 5/5] fou: Allowing configuring IPv6 listener
2016-08-09 21:41 [PATCH iproute v3 0/5] iproute: ila and fou additions Tom Herbert
` (3 preceding siblings ...)
2016-08-09 21:41 ` [PATCH iproute v3 4/5] gre6: " Tom Herbert
@ 2016-08-09 21:41 ` Tom Herbert
2016-08-12 19:55 ` [PATCH iproute v3 0/5] iproute: ila and fou additions Stephen Hemminger
5 siblings, 0 replies; 8+ messages in thread
From: Tom Herbert @ 2016-08-09 21:41 UTC (permalink / raw)
To: stephen, netdev; +Cc: kernel-team, Tom Herbert
Signed-off-by: Tom Herbert <tom@herbertland.com>
---
ip/ipfou.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/ip/ipfou.c b/ip/ipfou.c
index 2a6ae17..0673d11 100644
--- a/ip/ipfou.c
+++ b/ip/ipfou.c
@@ -25,8 +25,9 @@
static void usage(void)
{
- fprintf(stderr, "Usage: ip fou add port PORT { ipproto PROTO | gue }\n");
- fprintf(stderr, " ip fou del port PORT\n");
+ fprintf(stderr, "Usage: ip fou add port PORT "
+ "{ ipproto PROTO | gue } [ -6 ]\n");
+ fprintf(stderr, " ip fou del port PORT [ -6 ]\n");
fprintf(stderr, "\n");
fprintf(stderr, "Where: PROTO { ipproto-name | 1..255 }\n");
fprintf(stderr, " PORT { 1..65535 }\n");
@@ -50,6 +51,7 @@ static int fou_parse_opt(int argc, char **argv, struct nlmsghdr *n,
__u8 ipproto, type;
bool gue_set = false;
int ipproto_set = 0;
+ unsigned short family = AF_INET;
while (argc > 0) {
if (!matches(*argv, "port")) {
@@ -71,6 +73,8 @@ static int fou_parse_opt(int argc, char **argv, struct nlmsghdr *n,
ipproto_set = 1;
} else if (!matches(*argv, "gue")) {
gue_set = true;
+ } else if (!matches(*argv, "-6")) {
+ family = AF_INET6;
} else {
fprintf(stderr, "fou: unknown command \"%s\"?\n", *argv);
usage();
@@ -98,6 +102,7 @@ static int fou_parse_opt(int argc, char **argv, struct nlmsghdr *n,
addattr16(n, 1024, FOU_ATTR_PORT, port);
addattr8(n, 1024, FOU_ATTR_TYPE, type);
+ addattr16(n, 1024, FOU_ATTR_AF, family);
if (ipproto_set)
addattr8(n, 1024, FOU_ATTR_IPPROTO, ipproto);
--
2.8.0.rc2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH iproute v3 0/5] iproute: ila and fou additions
2016-08-09 21:41 [PATCH iproute v3 0/5] iproute: ila and fou additions Tom Herbert
` (4 preceding siblings ...)
2016-08-09 21:41 ` [PATCH iproute v3 5/5] fou: Allowing configuring IPv6 listener Tom Herbert
@ 2016-08-12 19:55 ` Stephen Hemminger
5 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2016-08-12 19:55 UTC (permalink / raw)
To: Tom Herbert; +Cc: netdev, kernel-team
On Tue, 9 Aug 2016 14:41:34 -0700
Tom Herbert <tom@herbertland.com> wrote:
> Patch set includes:
>
> - Allow configuring checksum mode for ila LWT (e.g. configure
> checksum neutral
> - Configuration for performing ila translations using netfilter hook
> - fou encapsulation for ip6tnl and gre6
> - fou listener for IPv6
>
> v2:
> - Fixed coding style issues
>
> v3:
> - Fixed uniinitialized variable waning in ipila.c
>
>
> Tom Herbert (5):
> ila: Support for checksum neutral translation
> ila: Support for configuring ila to use netfilter hook
> ip6tnl: Support for fou encapsulation
> gre6: Support for fou encapsulation
> fou: Allowing configuring IPv6 listener
>
> ip/Makefile | 2 +-
> ip/ip.c | 3 +-
> ip/ip_common.h | 1 +
> ip/ipfou.c | 9 +-
> ip/ipila.c | 268 ++++++++++++++++++++++++++++++++++++++++++++++++++
> ip/iproute_lwtunnel.c | 58 ++++++++++-
> ip/link_gre.c | 2 +-
> ip/link_gre6.c | 101 +++++++++++++++++++
> ip/link_ip6tnl.c | 92 ++++++++++++++++-
> 9 files changed, 528 insertions(+), 8 deletions(-)
> create mode 100644 ip/ipila.c
>
Applied but I needed to fix one whitespace issue.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH iproute v3 2/5] ila: Support for configuring ila to use netfilter hook
2016-08-09 21:41 ` [PATCH iproute v3 2/5] ila: Support for configuring ila to use netfilter hook Tom Herbert
@ 2016-08-12 20:01 ` Stephen Hemminger
0 siblings, 0 replies; 8+ messages in thread
From: Stephen Hemminger @ 2016-08-12 20:01 UTC (permalink / raw)
To: Tom Herbert; +Cc: netdev, kernel-team
On Tue, 9 Aug 2016 14:41:36 -0700
Tom Herbert <tom@herbertland.com> wrote:
> Signed-off-by: Tom Herbert <tom@herbertland.com>
> ---
> ip/Makefile | 2 +-
> ip/ip.c | 3 +-
> ip/ip_common.h | 1 +
> ip/ipila.c | 268 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 272 insertions(+), 2 deletions(-)
> create mode 100644 ip/ipila.c
You didn't fix this warning.
ipila.c: In function ‘ila_parse_opt.constprop’:
ipila.c:205:2: warning: ‘locator_match’ may be used uninitialized in this function [-Wmaybe-uninitialized]
addattr64(n, 1024, ILA_ATTR_LOCATOR_MATCH, locator_match);
Please send a followup patch for this.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2016-08-12 20:01 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-09 21:41 [PATCH iproute v3 0/5] iproute: ila and fou additions Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 1/5] ila: Support for checksum neutral translation Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 2/5] ila: Support for configuring ila to use netfilter hook Tom Herbert
2016-08-12 20:01 ` Stephen Hemminger
2016-08-09 21:41 ` [PATCH iproute v3 3/5] ip6tnl: Support for fou encapsulation Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 4/5] gre6: " Tom Herbert
2016-08-09 21:41 ` [PATCH iproute v3 5/5] fou: Allowing configuring IPv6 listener Tom Herbert
2016-08-12 19:55 ` [PATCH iproute v3 0/5] iproute: ila and fou additions 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).