1 diff -ruNp iproute2-4.14.1.orig/ip/ipfou.c iproute2-4.14.1/ip/ipfou.c
2 --- iproute2-4.14.1.orig/ip/ipfou.c 2017-11-13 19:09:57.000000000 +0100
3 +++ iproute2-4.14.1/ip/ipfou.c 2018-02-19 15:49:27.105945493 +0100
4 @@ -28,6 +28,7 @@ static void usage(void)
5 fprintf(stderr, "Usage: ip fou add port PORT "
6 "{ ipproto PROTO | gue } [ -6 ]\n");
7 fprintf(stderr, " ip fou del port PORT [ -6 ]\n");
8 + fprintf(stderr, " ip fou show\n");
10 fprintf(stderr, "Where: PROTO { ipproto-name | 1..255 }\n");
11 fprintf(stderr, " PORT { 1..65535 }\n");
12 @@ -134,6 +135,63 @@ static int do_del(int argc, char **argv)
16 +static int print_fou_mapping(const struct sockaddr_nl *who,
17 + struct nlmsghdr *n, void *arg)
19 + FILE *fp = (FILE *)arg;
20 + struct genlmsghdr *ghdr;
21 + struct rtattr *tb[FOU_ATTR_MAX + 1];
22 + int len = n->nlmsg_len;
25 + if (n->nlmsg_type != genl_family)
28 + len -= NLMSG_LENGTH(GENL_HDRLEN);
32 + ghdr = NLMSG_DATA(n);
33 + parse_rtattr(tb, FOU_ATTR_MAX, (void *) ghdr + GENL_HDRLEN, len);
35 + if (tb[FOU_ATTR_PORT])
36 + fprintf(fp, "port %u", ntohs(rta_getattr_u16(tb[FOU_ATTR_PORT])));
37 + if (tb[FOU_ATTR_TYPE] && rta_getattr_u8(tb[FOU_ATTR_TYPE]) == FOU_ENCAP_GUE)
38 + fprintf(fp, " gue");
39 + else if (tb[FOU_ATTR_IPPROTO])
40 + fprintf(fp, " ipproto %u", rta_getattr_u8(tb[FOU_ATTR_IPPROTO]));
41 + if (tb[FOU_ATTR_AF]) {
42 + family = rta_getattr_u8(tb[FOU_ATTR_AF]);
43 + if (family == AF_INET6)
51 +static int do_show(int argc, char **argv)
53 + FOU_REQUEST(req, 4096, FOU_CMD_GET, NLM_F_REQUEST | NLM_F_DUMP);
56 + fprintf(stderr, "\"ip fou show\" does not take any arguments.\n");
60 + if (rtnl_send(&genl_rth, &req.n, req.n.nlmsg_len) < 0) {
61 + perror("Cannot send show request");
65 + if (rtnl_dump_filter(&genl_rth, print_fou_mapping, stdout) < 0) {
66 + fprintf(stderr, "Dump terminated\n");
73 int do_ipfou(int argc, char **argv)
76 @@ -149,6 +207,8 @@ int do_ipfou(int argc, char **argv)
77 return do_add(argc-1, argv+1);
78 if (matches(*argv, "delete") == 0)
79 return do_del(argc-1, argv+1);
80 + if (matches(*argv, "show") == 0)
81 + return do_show(argc-1, argv+1);
82 fprintf(stderr, "Command \"%s\" is unknown, try \"ip fou help\".\n", *argv);
85 diff -ruNp iproute2-4.14.1.orig/man/man8/ip-fou.8 iproute2-4.14.1/man/man8/ip-fou.8
86 --- iproute2-4.14.1.orig/man/man8/ip-fou.8 2017-11-13 19:09:57.000000000 +0100
87 +++ iproute2-4.14.1/man/man8/ip-fou.8 2018-02-19 15:49:23.558962613 +0100
88 @@ -29,6 +29,9 @@ ip-gue \- Generic UDP Encapsulation rece