VPN get disconnected between connecting and connected when includeAllNetworks is set

I am trying to set includeAllNetworks flags right now and I see some wield behaviors from macOS system:

default	13:32:50.825941+0800	*****	<debug> newStatus = Connecting...
default	13:32:51.816353+0800	*****	<debug> newStatus = Disconnected
default	13:32:52.222371+0800	*****	<debug> newStatus = Connected

The app which is observing VPN status gets notified with disconnected status between connecting and connected. And in some cases I find that app will never gets connected notification after disconnected. In that case tunnel interface and all tunnel network settings are well set. But our UI logic will just handle the disconnected case.

If I just clear the includeAllNetwork flag, then everything is fine.

default	14:13:50.075947+0800	*****<debug> newStatus = Connecting...
default	14:13:50.829195+0800	*****<debug> newStatus = Connected

The test environment is macOS 14.0 and I am using network extension framework for the status KVO.

So I am just wondering if this is expected behavior or not. If this is expected, then is there any suggestion that I should use to work around it?

Tried it for the same case on iOS, and I found that when includeAllNetworks is set in the profile, the VPN status will get disconnected status after connecting.

How should we use includeAllNetworks correctly on iOS/macOS?

Any help is appreciate.

On macOS sometimes the VPN status is notified with Disconnected. But if we run ifconfig in terminal, the utun is up and running with well set configuration.

This does not sound good to me and this issue could be seen out of three times a try in a row.

Is this as expected or something that I am not aware of?

VPN get disconnected between connecting and connected when includeAllNetworks is set
 
 
Q