From 8e12bc0a9df46516b851c9baa48d9da6b0999022 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Mork?= Date: Mon, 4 Jan 2016 10:58:05 +0100 Subject: [PATCH] iplink: support show and set of "addrgenmode random" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "random" is a new IPv6 addrgenmode, enabling "stable_secret" type addresses with an auto-generated secret. $ ip link set eth0 addrgenmode random $ ip -d link show dev eth0 2: eth0: mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000 link/ether 00:21:86:a3:25:7d brd ff:ff:ff:ff:ff:ff promiscuity 0 addrgenmode random Cc: Hannes Frederic Sowa Signed-off-by: Bjørn Mork --- ip/ipaddress.c | 3 +++ ip/iplink.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ip/ipaddress.c b/ip/ipaddress.c index a495a391..9d254d27 100644 --- a/ip/ipaddress.c +++ b/ip/ipaddress.c @@ -296,6 +296,9 @@ static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr) case IN6_ADDR_GEN_MODE_STABLE_PRIVACY: fprintf(fp, "addrgenmode stable_secret "); break; + case IN6_ADDR_GEN_MODE_RANDOM: + fprintf(fp, "addrgenmode random "); + break; default: fprintf(fp, "addrgenmode %#.2hhx ", mode); break; diff --git a/ip/iplink.c b/ip/iplink.c index e824082f..75b21540 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -84,7 +84,7 @@ void iplink_usage(void) fprintf(stderr, " [ state { auto | enable | disable} ] ]\n"); fprintf(stderr, " [ master DEVICE ]\n"); fprintf(stderr, " [ nomaster ]\n"); - fprintf(stderr, " [ addrgenmode { eui64 | none | stable_secret } ]\n"); + fprintf(stderr, " [ addrgenmode { eui64 | none | stable_secret | random } ]\n"); fprintf(stderr, " [ protodown { on | off } ]\n"); fprintf(stderr, " ip link show [ DEVICE | group GROUP ] [up] [master DEV] [type TYPE]\n"); @@ -178,6 +178,8 @@ static int get_addr_gen_mode(const char *mode) return IN6_ADDR_GEN_MODE_NONE; if (strcasecmp(mode, "stable_secret") == 0) return IN6_ADDR_GEN_MODE_STABLE_PRIVACY; + if (strcasecmp(mode, "random") == 0) + return IN6_ADDR_GEN_MODE_RANDOM; return -1; }