ip addr flush hangs
Subsystems (3)
Hi,
I'm currently debugging the following problem: on a 2.6.3 kernel, when doing this
ifconfig eth0 down
ip addr flush dev eth0
The second command hangs indefinitely. The reason is that the kernel reports ipv6-all-hosts (ff02::1) when dumping all addresses, but RTM_DELADDR on ff02::1 doesn't do anything. As /sbin/ip will loop until the kernel reports no more matching addresses, it will go on like that forever.
I don't see an obvious fix to this issue. On one hand, calling ifconfig down will result in a call to addrconf_ifdown(dev, 0). This will clear the list of unicast addresses assigned to this interface, but will not clear the list of multicast addresses (it unloads them from the NIC, and sends IGMP leave packets, but the list of addresses will remain attached to the device). So it doesn't destroy the interface completely, it zaps its state just partly, intentionally.
On the other hand, if you manually remove all addresses from the interface, this will result in a call to addrconf_ifdown(dev, 1), causing the mcast list to be zapped as well.
This is not entirely consistent. Should a NETDEV_DOWN zap the ipv6 configuration completely?
Olaf
Signature · 3 lines
Olaf Kirch | Stop wasting entropy - start using predictable [email protected] | tempfile names today! ---------------+
Quoted 2 lines · Olaf Kirch
This is not entirely consistent. Should a
NETDEV_DOWNzap the ipv6 configuration completely?
Sorry to follow up on my own mail...
Cross-checking ipv4, I can see that it behaves the same way as IPv6 (i.e. NETDEV_DOWN partly leaves the interface configuration intact). The difference though is that dump_ifaddr doesn't include multicast addresses in its report.
The attached patch disables reporting of multicast and anycast addresses in inet6_dump_ifaddr
Olaf
Signature · 3 lines
Olaf Kirch | Stop wasting entropy - start using predictable [email protected] | tempfile names today! ---------------+
net/ipv6/addrconf.c renamed from net/ipv6/addrconf.c.orig +6 -0
@@ -2898,6 +2898,11 @@ static int inet6_dump_ifaddr(struct sk_b goto done; }#endif +/* You can't delete these via RTM_DELADDR, so we shouldn't +* display them here. Otherwise "ip addr flush" will loop +* forever trying to delete ff02::1 etc. +* --okir */ +#if 0 /* multicast address */ for (ifmca = idev->mc_list; ifmca; ifmca = ifmca->next, ip_idx++) {
@@ -2918,6 +2923,7 @@ static int inet6_dump_ifaddr(struct sk_b cb->nlh->nlmsg_seq, RTM_NEWADDR)) <= 0) goto done; } +#endif read_unlock_bh (&idev->lock);in6_dev_put (idev); }
Quoted 2 lines · On Tue, 9 Mar 2004 16:07:30 +0100 Olaf Kirch <[email protected]> wrote:
The attached patch disables reporting of multicast and anycast addresses in
inet6_dump_ifaddr
Better to fix /sbin/ip, Andi Kleen posted a patch for that tool in a thread on linux-kernel about this very issue.
Quoted 8 lines · David S. Miller
Quoted 2 lines · On Tue, 9 Mar 2004 16:07:30 +0100 Olaf Kirch <[email protected]> wrote:
The attached patch disables reporting of multicast and anycast addresses in
inet6_dump_ifaddrBetter to fix
/sbin/ip, Andi Kleen posted a patch for that tool in a thread on linux-kernel about this very issue.
The patch was buggy unfortunately - it fixed one case, but broke another. Fixing the root cause like Olaf proposes is better.
-Andi
Quoted 2 lines · On Tue, 9 Mar 2004 20:44:26 +0100 Andi Kleen <[email protected]> wrote:
The patch was buggy unfortunately - it fixed one case, but broke another. Fixing the root cause like Olaf proposes is better.
Ok, I'll review Olaf's patch then.
Thanks.
Quoted 5 lines · David S. Miller
Quoted 2 lines
The attached patch disables reporting of multicast and anycast addresses in
inet6_dump_ifaddrBetter to fix
/sbin/ip, Andi Kleen posted a patch for that tool in a thread on linux-kernel about this very issue.
His patch breaks ip addr flush completely, because it breaks the loop before flushing the RTM_DELADDR packet to the netlink socket.
Even if you fix it to break out ofthe loop in the proper place, it is still not entirely correct. ip does addr list and addr flush in a loop, because netlink can return only so many addresses in one packet. If you break out of the loop unconditionally, as Andi does in his patch, you break ip addr list/flush for systems with more than the normal number of addresses per device.
I think IPv6 is really wrong in reporting multicast addresses via RTM_GETADDR. IPv4 doesn't do this either.
Olaf
Signature · 3 lines
Olaf Kirch | Stop wasting entropy - start using predictable [email protected] | tempfile names today! ---------------+
David S. Miller
AppliedQuoted 2 lines · On Tue, 9 Mar 2004 16:07:30 +0100 Olaf Kirch <[email protected]> wrote:
The attached patch disables reporting of multicast and anycast addresses in
inet6_dump_ifaddr
Applied, except I changed it to just remove the code entirely instead of commenting it out.
Hi, Dave,
This fix causes a problem for SNMP IPv6 MIBs. It requires to dump all interface
address types unicast/mcast/anycast. I would like suggest to fix the ip command to fix the problem.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
Quoted 4 lines · On Tue, 9 Mar 2004 15:56:00 -0800 Shirley Ma <[email protected]> wrote:
This fix causes a problem for SNMP IPv6 MIBs. It requires to dump all interface
address types unicast/mcast/anycast. I would like suggest to fix the ip command to fix the problem.
We changed behavior which unexpectedly broke a pretty core tool on everyone's system. I'm not reverting this.
Create instead a new rtnetlink command which can ask for xxx_cast type addresses on an interface.
In article <OF34091B26.07758A8E-ON87256E52.00833C04-88256E53.00004022@us.ibm.com> (at Tue, 9 Mar 2004 15:56:00 -0800), Shirley Ma <[email protected]> says:
Quoted 4 lines
This fix causes a problem for SNMP IPv6 MIBs. It requires to dump all interface
address types unicast/mcast/anycast. I would like suggest to fix the ip command to fix the problem.
Grr... Putting anycast/multicast is not good idea. (Sorry, I did not notice at that time...)
Anycast should use IFA_ANYCAST ifaddrmsg instead of IFA_ADDRESS. Multicast should be provided in a different way (different rtmsg), or use IFA_MULTICAST or something like that.
--yoshfuji
OK, I will submit a patch for anycast and multicast addresses throught different rtmsg.
Thanks
Shirley Ma
IBM Linux Technology Center
15300 SW Koll Parkway
Beaverton, OR 97006-6063
Phone: (503) 578-7638
FAX: (503) 578-3228
YOSHIFUJI Hideaki
/ 吉藤英明
<yoshfuji@linux-i To
pv6.org> [email protected],
Sent by: "Hideaki [email protected], Shirley
YOSHIFUJI" Ma/Beaverton/IBM@IBMUS
<yoshfuji@cerberu cc
s.hongo.wide.ad.j [email protected],
p> [email protected]
Subject
Re: ip addr flush hangs
03/09/2004 07:32
PM
In article <OF34091B26.07758A8E-ON87256E52.00833C04-88256E53.00004022@us.ibm.com> (at Tue, 9 Mar 2004 15:56:00 -0800), Shirley Ma <[email protected]> says:
Quoted 4 lines
This fix causes a problem for SNMP IPv6 MIBs. It requires to dump all interface
address types unicast/mcast/anycast. I would like suggest to fix the ip command to fix the problem.
Grr... Putting anycast/multicast is not good idea. (Sorry, I did not notice at that time...)
Anycast should use IFA_ANYCAST ifaddrmsg instead of IFA_ADDRESS. Multicast should be provided in a different way (different rtmsg), or use IFA_MULTICAST or something like that.
--yoshfuji