pyroute2 icon indicating copy to clipboard operation
pyroute2 copied to clipboard

"_get_ns_by_inode" can return error ENOENT if a namespace is delete during the function loop

Open ralonsoh opened this issue 4 years ago • 3 comments

"_get_ns_by_inode" can return an exception (ENOENT) if during the function loop, one of the namespaces listed in "listnetns" [1] is deleted. [2] will fail if the namespace does not exist at this time.

[1] https://github.com/svinota/pyroute2/blob/b25a6ca6c91da45cb5b54e7caffa1644fed2330d/pyroute2/netns/init.py#L153 [2] https://github.com/svinota/pyroute2/blob/b25a6ca6c91da45cb5b54e7caffa1644fed2330d/pyroute2/netns/init.py#L155

ralonsoh avatar Aug 28 '19 10:08 ralonsoh

@ralonsoh having a minute pls review this change, could it be enough to close the issue: https://github.com/svinota/pyroute2/pull/969/files

svinota avatar Jul 22 '22 09:07 svinota

Sorry for the delay.

I've manually applied this patch, reverting the Neutron's one, and seems to work.

I've also faked a long delay in between the namespace iteration (adding a sleep method) and I've manually deleted one of the listed namespaces. Now the method skips the deleted namespace.

I also works when "/var/run/nents" has not been created yet because no namespace has been created in this system since the last reboot.

Thanks!

ralonsoh avatar Jul 26 '22 10:07 ralonsoh

Thanks!

svinota avatar Jul 26 '22 10:07 svinota

@svinota so this issue can be closed now?

pkulev avatar Apr 14 '23 09:04 pkulev

@pkulev I believe yes

svinota avatar Apr 14 '23 12:04 svinota

Thanks for heads-up

svinota avatar Apr 14 '23 12:04 svinota