From: "John W. Linville" <linville@tuxdriver.com>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH 1/2] iplink_geneve: add ttl configuration at link creation
Date: Mon, 15 Jun 2015 14:38:46 -0400 [thread overview]
Message-ID: <20150615183845.GF16684@tuxdriver.com> (raw)
In-Reply-To: <1434393436-4487-2-git-send-email-linville@tuxdriver.com>
On Mon, Jun 15, 2015 at 02:37:15PM -0400, John W. Linville wrote:
> Signed-off-by: John W. Linville <linville@tuxdriver.com>
> ---
> include/linux/if_link.h | 1 +
This includes the include/linux/if_link.h bits, that will need to be
dropped after iproute2 does the 4.1 update for that file.
> ip/iplink_geneve.c | 23 ++++++++++++++++++++++-
> man/man8/ip-link.8.in | 7 +++++++
> 3 files changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/if_link.h b/include/linux/if_link.h
> index 7720ad34c6b3..2b5268531bef 100644
> --- a/include/linux/if_link.h
> +++ b/include/linux/if_link.h
> @@ -393,6 +393,7 @@ enum {
> IFLA_GENEVE_UNSPEC,
> IFLA_GENEVE_ID,
> IFLA_GENEVE_REMOTE,
> + IFLA_GENEVE_TTL,
> __IFLA_GENEVE_MAX
> };
> #define IFLA_GENEVE_MAX (__IFLA_GENEVE_MAX - 1)
> diff --git a/ip/iplink_geneve.c b/ip/iplink_geneve.c
> index 74703e1ee156..dff08a62d9a9 100644
> --- a/ip/iplink_geneve.c
> +++ b/ip/iplink_geneve.c
> @@ -17,9 +17,11 @@
> static void print_explain(FILE *f)
> {
> fprintf(f, "Usage: ... geneve id VNI remote ADDR\n");
> + fprintf(f, " [ ttl TTL ]\n");
> fprintf(f, "\n");
> fprintf(f, "Where: VNI := 0-16777215\n");
> fprintf(f, " ADDR := IP_ADDRESS\n");
> + fprintf(f, " TTL := { 1..255 | inherit }\n");
> }
>
> static void explain(void)
> @@ -34,7 +36,7 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
> int vni_set = 0;
> __u32 daddr = 0;
> struct in6_addr daddr6 = IN6ADDR_ANY_INIT;
> -
> + __u8 ttl = 0;
>
> while (argc > 0) {
> if (!matches(*argv, "id") ||
> @@ -52,6 +54,18 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
> }
> if (IN_MULTICAST(ntohl(daddr)))
> invarg("invalid remote address", *argv);
> + } else if (!matches(*argv, "ttl") ||
> + !matches(*argv, "hoplimit")) {
> + unsigned uval;
> +
> + NEXT_ARG();
> + if (strcmp(*argv, "inherit") != 0) {
> + if (get_unsigned(&uval, *argv, 0))
> + invarg("invalid TTL", *argv);
> + if (uval > 255)
> + invarg("TTL must be <= 255", *argv);
> + ttl = uval;
> + }
> } else if (matches(*argv, "help") == 0) {
> explain();
> return -1;
> @@ -80,6 +94,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);
> + addattr8(n, 1024, IFLA_GENEVE_TTL, ttl);
>
> return 0;
> }
> @@ -105,6 +120,12 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
> fprintf(f, "remote %s ",
> format_host(AF_INET, 4, &addr, s1, sizeof(s1)));
> }
> +
> + if (tb[IFLA_GENEVE_TTL]) {
> + __u8 ttl = rta_getattr_u8(tb[IFLA_GENEVE_TTL]);
> + if (ttl)
> + fprintf(f, "ttl %d ", ttl);
> + }
> }
>
> static void geneve_print_help(struct link_util *lu, int argc, char **argv,
> diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
> index 8cac246d7296..51d0c624a023 100644
> --- a/man/man8/ip-link.8.in
> +++ b/man/man8/ip-link.8.in
> @@ -606,6 +606,9 @@ the following additional arguments are supported:
>
> .BI "ip link add " DEVICE
> .BI type " geneve " id " ID " remote " IPADDR"
> +.R " [ "
> +.BI ttl " TTL "
> +.R " ]"
>
> .in +8
> .sp
> @@ -616,6 +619,10 @@ the following additional arguments are supported:
> .BI remote " IPADDR"
> - specifies the unicast destination IP address to use in outgoing packets.
>
> +.sp
> +.BI ttl " TTL"
> +- specifies the TTL value to use in outgoing packets.
> +
> .in -8
>
> .SS ip link delete - delete virtual link
> --
> 2.1.0
>
>
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
next prev parent reply other threads:[~2015-06-15 18:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 16:57 [PATCH v3] add GENEVE netdev tunnel driver John W. Linville
2015-05-13 16:57 ` [PATCH v3 1/5] geneve: remove MODULE_ALIAS_RTNL_LINK from net/ipv4/geneve.c John W. Linville
2015-05-13 16:57 ` [PATCH v3 2/5] geneve: move definition of geneve_hdr() to geneve.h John W. Linville
2015-05-13 16:57 ` [PATCH v3 3/5] geneve: Rename support library as geneve_core John W. Linville
2015-05-13 16:57 ` [PATCH v3 4/5] geneve_core: identify as driver library in modules description John W. Linville
2015-05-13 16:57 ` [PATCH v3 5/5] geneve: add initial netdev driver for GENEVE tunnels John W. Linville
2015-05-13 17:02 ` [PATCH v3] iproute2: GENEVE support John W. Linville
2015-05-21 22:19 ` Stephen Hemminger
2015-05-22 18:45 ` John W. Linville
2015-05-22 18:46 ` [PATCH] iproute2: update ip-link.8 for geneve tunnels John W. Linville
2015-06-15 18:37 ` [PATCH 0/2] iplink_geneve: add ttl and tos configuration bits John W. Linville
2015-06-15 18:37 ` [PATCH 1/2] iplink_geneve: add ttl configuration at link creation John W. Linville
2015-06-15 18:38 ` John W. Linville [this message]
2015-06-15 18:37 ` [PATCH 2/2] iplink_geneve: add tos " John W. Linville
2015-06-15 18:39 ` John W. Linville
2015-05-13 19:59 ` [PATCH v3] add GENEVE netdev tunnel driver David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150615183845.GF16684@tuxdriver.com \
--to=linville@tuxdriver.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).