[PATCH iproute2 3/4] iplink: support show and set of "addrgenmode random"
From: Bjørn Mork <bjorn@mork.no>
Date: 2016-01-04 09:58:33
Subsystem:
the rest · Maintainer:
Linus Torvalds
"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: <NO-CARRIER,BROADCAST,MULTICAST,UP> 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 <redacted>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
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 a495a391a0ec..9d254d27bc1b 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 e824082f7d81..75b21540c6b5 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; }
--
2.1.4