diff mbox

[iproute2,2/2] iplink: print out addrgenmode attribute

Message ID 1420561426-3118-2-git-send-email-jiri@resnulli.us
State Changes Requested, archived
Delegated to: stephen hemminger
Headers show

Commit Message

Jiri Pirko Jan. 6, 2015, 4:23 p.m. UTC
addrgenmode is currently write only by ip. So display this information
if provided by kernel as well.

Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
 ip/ipaddress.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Thomas Haller Jan. 6, 2015, 4:52 p.m. UTC | #1
On Tue, 2015-01-06 at 17:23 +0100, Jiri Pirko wrote:
> addrgenmode is currently write only by ip. So display this information
> if provided by kernel as well.

>  
> +static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr)
> +{
> +	struct rtattr *inet6_attr;
> +	struct rtattr *tb[IFLA_INET6_MAX + 1];
> +
> +	inet6_attr = parse_rtattr_one_nested(AF_INET6, af_spec_attr);
> +	if (!inet6_attr)
> +		return;
> +
> +	parse_rtattr_nested(tb, IFLA_INET6_MAX, inet6_attr);
> +
> +	if (tb[IFLA_INET6_ADDR_GEN_MODE]) {
> +		switch (rta_getattr_u8(tb[IFLA_INET6_ADDR_GEN_MODE])) {
> +		case IN6_ADDR_GEN_MODE_EUI64:
> +			fprintf(fp, "addrgenmode eui64 ");

eui64 is the default and the behavior of older kernels.

I dunno, would it be better not to print the default case?


Thomas
Jiri Pirko Jan. 6, 2015, 5:08 p.m. UTC | #2
Tue, Jan 06, 2015 at 05:52:33PM CET, thaller@redhat.com wrote:
>On Tue, 2015-01-06 at 17:23 +0100, Jiri Pirko wrote:
>> addrgenmode is currently write only by ip. So display this information
>> if provided by kernel as well.
>
>>  
>> +static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr)
>> +{
>> +	struct rtattr *inet6_attr;
>> +	struct rtattr *tb[IFLA_INET6_MAX + 1];
>> +
>> +	inet6_attr = parse_rtattr_one_nested(AF_INET6, af_spec_attr);
>> +	if (!inet6_attr)
>> +		return;
>> +
>> +	parse_rtattr_nested(tb, IFLA_INET6_MAX, inet6_attr);
>> +
>> +	if (tb[IFLA_INET6_ADDR_GEN_MODE]) {
>> +		switch (rta_getattr_u8(tb[IFLA_INET6_ADDR_GEN_MODE])) {
>> +		case IN6_ADDR_GEN_MODE_EUI64:
>> +			fprintf(fp, "addrgenmode eui64 ");
>
>eui64 is the default and the behavior of older kernels.
>
>I dunno, would it be better not to print the default case?


This prints only when show_details is on. So I believe it is ok to print
the default value of addrgenmode (same is done as for other things)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Hemminger Jan. 7, 2015, 11:10 p.m. UTC | #3
On Tue,  6 Jan 2015 17:23:46 +0100
Jiri Pirko <jiri@resnulli.us> wrote:

> addrgenmode is currently write only by ip. So display this information
> if provided by kernel as well.
> 
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

Patch does not apply to current iproute2 git
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jiri Pirko Jan. 8, 2015, 7:04 a.m. UTC | #4
Thu, Jan 08, 2015 at 12:10:36AM CET, stephen@networkplumber.org wrote:
>On Tue,  6 Jan 2015 17:23:46 +0100
>Jiri Pirko <jiri@resnulli.us> wrote:
>
>> addrgenmode is currently write only by ip. So display this information
>> if provided by kernel as well.
>> 
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>
>Patch does not apply to current iproute2 git

I made that against net-next branch. Which branch should I use for new
features?

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vadym Kochan Jan. 8, 2015, 7:13 a.m. UTC | #5
On Thu, Jan 08, 2015 at 08:04:39AM +0100, Jiri Pirko wrote:
> Thu, Jan 08, 2015 at 12:10:36AM CET, stephen@networkplumber.org wrote:
> >On Tue,  6 Jan 2015 17:23:46 +0100
> >Jiri Pirko <jiri@resnulli.us> wrote:
> >
> >> addrgenmode is currently write only by ip. So display this information
> >> if provided by kernel as well.
> >> 
> >> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> >
> >Patch does not apply to current iproute2 git
> 
> I made that against net-next branch. Which branch should I use for new
> features?
> 
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

I am not sure if I am right, but seems to me that net-next should keep
features which depends on the next Linux headers version, and as I
understand these new headers are merged into net-next branch and after
into master. But I tried fix your patch on the master and it compiles
OK, so I assume that it can be based on master branch.

Regards,
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stephen Hemminger Jan. 8, 2015, 6:19 p.m. UTC | #6
On Thu, 8 Jan 2015 08:04:39 +0100
Jiri Pirko <jiri@resnulli.us> wrote:

> Thu, Jan 08, 2015 at 12:10:36AM CET, stephen@networkplumber.org wrote:
> >On Tue,  6 Jan 2015 17:23:46 +0100
> >Jiri Pirko <jiri@resnulli.us> wrote:
> >
> >> addrgenmode is currently write only by ip. So display this information
> >> if provided by kernel as well.
> >> 
> >> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> >
> >Patch does not apply to current iproute2 git
> 
> I made that against net-next branch. Which branch should I use for new
> features?
> 

net-next hasn't been rebased to master. plus unless change is specific to
kernel net-next it should be against master.

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 4d99324..0a04d90 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -242,6 +242,29 @@  static void print_linktype(FILE *fp, struct rtattr *tb)
 	}
 }
 
+static void print_af_spec(FILE *fp, struct rtattr *af_spec_attr)
+{
+	struct rtattr *inet6_attr;
+	struct rtattr *tb[IFLA_INET6_MAX + 1];
+
+	inet6_attr = parse_rtattr_one_nested(AF_INET6, af_spec_attr);
+	if (!inet6_attr)
+		return;
+
+	parse_rtattr_nested(tb, IFLA_INET6_MAX, inet6_attr);
+
+	if (tb[IFLA_INET6_ADDR_GEN_MODE]) {
+		switch (rta_getattr_u8(tb[IFLA_INET6_ADDR_GEN_MODE])) {
+		case IN6_ADDR_GEN_MODE_EUI64:
+			fprintf(fp, "addrgenmode eui64 ");
+			break;
+		case IN6_ADDR_GEN_MODE_NONE:
+			fprintf(fp, "addrgenmode none ");
+			break;
+		}
+	}
+}
+
 static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
 {
 	struct ifla_vf_mac *vf_mac;
@@ -634,6 +657,9 @@  int print_linkinfo(const struct sockaddr_nl *who,
 	if (do_link && tb[IFLA_LINKINFO] && show_details)
 		print_linktype(fp, tb[IFLA_LINKINFO]);
 
+	if (do_link && tb[IFLA_AF_SPEC] && show_details)
+		print_af_spec(fp, tb[IFLA_AF_SPEC]);
+
 	if (do_link && tb[IFLA_IFALIAS]) {
 		fprintf(fp, "%s    alias %s", _SL_,
 			rta_getattr_str(tb[IFLA_IFALIAS]));