Re: What's going on with vnets and epairs w/ addresses?

From: Alexander Leidinger <Alexander_at_leidinger.net>
Date: Wed, 14 Dec 2022 07:28:06 UTC
Quoting "Bjoern A. Zeeb" <bz@freebsd.org> (from Tue, 13 Dec 2022  
23:03:42 +0000 (UTC)):

> Hi,
>
> I have used scripts like the below for almost a decade and a half
> (obviously doing more than that in the middle).  I haven't used them
> much lately but given other questions I just wanted to fire up a test.
>
> I have an end-November kernel doing the below my eapirs do not come back
> to be destroyed (immediately).
> I have to start polling for the jid to be no longer alive and not in
> dying state (hence added the jls/ifconfig -l lines and removed the
> error checking from ifconfig destroy).  That seems sometimes rather
> unreasonably long (to the point I give up).
>
> If I don't configure the addresses below this isn't a problem.
>
> Sorry I am confused by too many incarnations of the code; I know I once
> had a version with an async shutdown path but I believe that never made
> it into mainline, so why are we holding onto the epairs now and not
> nuking the addresses and returning them and are clean?

Kristof, isn't this (epair destruction in jails) one of the issues you  
looked at? Sorry if I remember incorrectly.

What I have in my jails-shutdown is to do an "ifconfig $epair_in_jail  
-vnet $jail; sleep 2; ifconfig $epair destroy". With this I don't see  
any issues, Everything is cleaned up when the stop finishes.

Bye,
Alexander.

> It's a bit more funny; I added a twiddle loop at the end and nothing
> happened.  So I stop the script and start it again and suddenly another
> jail or two have cleaned up and their epairs are back.  Something feels
> very very wonky.  Play around with this and see ... and let me know if
> you can reproduce this...  I quite wonder why some test cases haven't
> gone crazy ...
>
> /bz
>
> ------------------------------------------------------------------------
> #!/bin/sh
>
> set -e
> set -x
>
> js=`jail -i -c -n jl host.hostname=left.example.net vnet persist`
> jb=`jail -i -c -n jr host.hostname=right.example.net vnet persist`
>
> # Create an epair connecting the two machines (vnet jails).
> ep=`ifconfig epair create | sed -e 's/a$//'`
>
> # Add one end to each vnet jail.
> ifconfig ${ep}a vnet ${js}
> ifconfig ${ep}b vnet ${jb}
>
> # Add an IP address on the epairs in each vnet jail.
> # XXX Leave these out and the cleanup seems to work fine.
> jexec ${js}  ifconfig ${ep}a inet  192.0.2.1/24
> jexec ${jb}  ifconfig ${ep}b inet  192.0.2.2/24
>
> # Clean up.
> jail -r ${jb}
> jail -r ${js}
>
> # You want to be able to remove this line ...
> set +e
>
> # No epairs to destroy with addresses configured; fine otherwise.
> ifconfig ${ep}a destroy
> # echo $?
>
> # Add this is here only as things are funny ...
> # jls -av jid dying
> # ifconfig -l
>
> # end
> ------------------------------------------------------------------------
>
> -- 
> Bjoern A. Zeeb                                                     r15:7


-- 
http://www.Leidinger.net Alexander@Leidinger.net: PGP 0x8F31830F9F2772BF
http://www.FreeBSD.org    netchild@FreeBSD.org  : PGP 0x8F31830F9F2772BF