From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from canndrew.org ([199.167.29.165]:56010 "EHLO canndrew.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751330AbeBWKCf (ORCPT ); Fri, 23 Feb 2018 05:02:35 -0500 Received: from shum by canndrew.org with local (Exim 4.84_2) (envelope-from ) id 1ep9pJ-000288-NY for netdev@vger.kernel.org; Fri, 23 Feb 2018 04:39:37 -0500 Date: Fri, 23 Feb 2018 04:39:37 -0500 From: Andrew Cann To: netdev@vger.kernel.org Subject: Automatic TAP destruction/Monitoring namespace destruction Message-ID: <20180223093937.GA8120@canndrew.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="FCuugMFkClbJLl1L" Content-Disposition: inline Sender: netdev-owner@vger.kernel.org List-ID: --FCuugMFkClbJLl1L Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Hi Linux people, I hope this is an appropriate place to ask this.. In a program I'm writing I have a network namespace with a virtual (TAP) network interface assigned to it. I would like it so that the interface is automatically destroyed when the namespace is destroyed (ie. when the last process in the namespace exits). I can't see any way to implement this.. As I understand it, when a namespace is destroyed all its interfaces are moved to the root namespace. If this is the case, is there anyway to detect when an interface is moved so that I can close it manually? Alternatively, is there a way to detect when a namespace is destroyed? I figured it might possible to use inotify to do this, but it won't let me watch directories under /proc. Also the files under /proc/*/ns/ seem to be some kind of wierd symlink-to-a-raw-inode-thing (?) - is there a way to detect when an inode is destroyed that I can use with these? I also thought it might be possible to use a netlink socket to detect when an interface changes namespace. But the netlink docs don't seem to suggest that this is possible. Basically I'm looking for any event the Linux kernel can give me that I can use to implement what I want. Does anyone have any ideas? Thanks for any help anyone can give me. - Andrew --FCuugMFkClbJLl1L Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJaj+FZAAoJEJQq94U5BTTOVmEQAMOhX04g1RgOR+y1iKoogOpr /z7h+56sbOrcXNLgQCjG88/TODyFnzUpndmlFNSHVOshCZhu7MNtAVudN5B6lxrj IxWM6bpwBA9BXNboPxTw6JPeG7hseM129/p2ORNaGfwX8bkGR6CFAyDcvp1szV5y JagRGREJfqNXyv3AUOQpp5XeJjPaaosyD76WF/LLZQaLRUWkTzvXjB0rHIQHP/LA wIvY1GmlSk3OL+krrj/pNAknP/ye4aHonGHnclOczKCFSuwWYVNnN6vIX/6ETCyw xzgjQUVcnW1ZExzWP1nX67EW19+KnOwXSqtkLhmjaLMFeVoSwxnA6Lmm5J9RJL7z urESMp0wj8eXKaOSAnNiyCUL2L0oJ0G48FdCkWisbpwcC3xxfsgFGzqW432el2cN oZhrejOjO6FtatFP8DdBsgxDnUFWiARqK8uaIcj2eCKkw0rDuCN1ZLEtBEOZl+00 iLXyteQXLm8HYvw0vAmwoJ0krCF37ALfU+8uHxc887Z23FJHJx5uvgS58S6mGBrN mzji67n+poq0zrQxY1lGLvjlV6NRsek9Ij1RWg16z8Wafxh1GFc0b6n067qxwGNV UHvcf/l52MZwXAsGG1R8XIBn4IZG6K6RqfpGi6nDZeb0Qfiwtxv+t2xAqOO8O0aJ EqGPO6G2Sp3/s3Ur1re8 =x/n3 -----END PGP SIGNATURE----- --FCuugMFkClbJLl1L--