netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Patch iproute2] ipaddress: do not add ifa_flags when not necessary
@ 2014-04-04  6:05 Cong Wang
  2014-04-04 13:59 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2014-04-04  6:05 UTC (permalink / raw)
  To: netdev; +Cc: David S. Miller, Jiri Pirko, Stephen Hemminger, Cong Wang

commit 37c9b94ed21d5779acc23d89a4 (add support for extended ifa_flags)
introduced a regression:

	# ./ip/ip addr add 192.168.0.1/24 dev eth0
	RTNETLINK answers: Invalid argument

This is due to old kernels don't support IFA_FLAGS flag, it should be skipped
if we don't use this feature at all.

Cc: Jiri Pirko <jiri@resnulli.us>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

---
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 14d1720..71ae8f3 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1398,8 +1398,10 @@ static int ipaddr_modify(int cmd, int flags, int argc, char **argv)
 		}
 		argc--; argv++;
 	}
-	req.ifa.ifa_flags = ifa_flags;
-	addattr32(&req.n, sizeof(req), IFA_FLAGS, ifa_flags);
+	if (ifa_flags) {
+		req.ifa.ifa_flags = ifa_flags;
+		addattr32(&req.n, sizeof(req), IFA_FLAGS, ifa_flags);
+	}
 
 	if (d == NULL) {
 		fprintf(stderr, "Not enough information: \"dev\" argument is required.\n");

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Patch iproute2] ipaddress: do not add ifa_flags when not necessary
  2014-04-04  6:05 [Patch iproute2] ipaddress: do not add ifa_flags when not necessary Cong Wang
@ 2014-04-04 13:59 ` David Miller
  2014-04-04 16:52   ` Cong Wang
  0 siblings, 1 reply; 3+ messages in thread
From: David Miller @ 2014-04-04 13:59 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev, jiri, stephen

From: Cong Wang <xiyou.wangcong@gmail.com>
Date: Thu,  3 Apr 2014 23:05:03 -0700

> commit 37c9b94ed21d5779acc23d89a4 (add support for extended ifa_flags)
> introduced a regression:
> 
> 	# ./ip/ip addr add 192.168.0.1/24 dev eth0
> 	RTNETLINK answers: Invalid argument
> 
> This is due to old kernels don't support IFA_FLAGS flag, it should be skipped
> if we don't use this feature at all.
> 
> Cc: Jiri Pirko <jiri@resnulli.us>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>

Your patch doesn't really fully fix the problem.

If the kernel rejects because of presence of the IFA_FLAGS attribute,
it will do so for all such cases.

Therefore the guard you need is not whether ifa_flags is NULL, but
whether a large enough flag bit is set such that IFA_FLAGS is required.

IFA_FLAGS was added because ifa.ifa_flags is too small for the new
values we needed to add.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Patch iproute2] ipaddress: do not add ifa_flags when not necessary
  2014-04-04 13:59 ` David Miller
@ 2014-04-04 16:52   ` Cong Wang
  0 siblings, 0 replies; 3+ messages in thread
From: Cong Wang @ 2014-04-04 16:52 UTC (permalink / raw)
  To: David Miller
  Cc: Linux Kernel Network Developers, Jiří Pírko,
	Stephen Hemminger

On Fri, Apr 4, 2014 at 6:59 AM, David Miller <davem@davemloft.net> wrote:
> From: Cong Wang <xiyou.wangcong@gmail.com>
> Date: Thu,  3 Apr 2014 23:05:03 -0700
>
>> commit 37c9b94ed21d5779acc23d89a4 (add support for extended ifa_flags)
>> introduced a regression:
>>
>>       # ./ip/ip addr add 192.168.0.1/24 dev eth0
>>       RTNETLINK answers: Invalid argument
>>
>> This is due to old kernels don't support IFA_FLAGS flag, it should be skipped
>> if we don't use this feature at all.
>>
>> Cc: Jiri Pirko <jiri@resnulli.us>
>> Cc: Stephen Hemminger <stephen@networkplumber.org>
>> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
>
> Your patch doesn't really fully fix the problem.
>
> If the kernel rejects because of presence of the IFA_FLAGS attribute,
> it will do so for all such cases.
>
> Therefore the guard you need is not whether ifa_flags is NULL, but
> whether a large enough flag bit is set such that IFA_FLAGS is required.
>
> IFA_FLAGS was added because ifa.ifa_flags is too small for the new
> values we needed to add.

Right, we should use IFA_FLAGS only when ifa_flags > 0xFF.

Thanks!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-04-04 16:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-04  6:05 [Patch iproute2] ipaddress: do not add ifa_flags when not necessary Cong Wang
2014-04-04 13:59 ` David Miller
2014-04-04 16:52   ` Cong Wang

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).