[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: debian9.1 ifdown bug



On Fri, 18 Aug 2017, Toad Zhou wrote:
> #ifconfig eth3
> eth3: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
>         inet 172.16.1.20
> 
> #cat /etc/network/interfaces
> auto eth3
> iface eth3 inet static
> address 172.16.1.16
> netmask 255.255.255.0
> 
> #ifdown -v eth3  #他删除的是新interfaces配置中的网络,而不是老的网络。
> /bin/ip addr del 172.16.1.16/255.255.255.0 broadcast 172.16.1.255
> dev eth3 label eth3
> 
> 我的临时修复方案是:
> # cat fix-network.sh
> #!/bin/bash
> /etc/init.d/networking stop
> $(ip addr|grep inet|grep -v 127.0.0.1|awk '{printf "ip addr del %s dev
> %s\n", $2,$NF}')
> /etc/init.d/networking start
> #ifup eth0
> 
> 
> =====================================
> google translation
> =====================================
> 
> 
> Newly installed system, I tried to modify the network. But networking
> restart has been in a failed state, but I can use it after reboot.
> Troubleshoot the reasons for finding ifdown -v ethx found ip addr del ip /
> mask deleted is not the old address, but the new address. So in the closed
> restart he just added / etc / network / interfaces in the new ip address.
> Ip addr found that they both coexist the state.

I see.  This is actually somewhat hard to fix, because ifdown would need
to differentiate primary and secondary addresses due to the way it was
(naively) designed.

If we change the ip addr del to ip addr flush, it will remove every
address from the device, including ones with other labels, etc.  This
breaks the way ifdown is supposed to work.

And the first ifdown has no state it can use to know otherwise.

The best I can see being done would be to:

1. not fail if ip addr del fails,
2. flush the device if the state file exists and tells us all related
interfaces (primary or secondary) are down *and* none of them is of type
"manual".

But I am not sure this is worth the possible breakages :-(  and one has
to test it on diskless boxes using NFS too, and wake-on-lan.  They
create annoying border conditions for network shutdown.

-- 
  Henrique Holschuh


Reply to: