From: Andrew Cann <shum@canndrew.org>
To: netdev@vger.kernel.org
Subject: Automatic TAP destruction/Monitoring namespace destruction
Date: Fri, 23 Feb 2018 04:39:37 -0500 [thread overview]
Message-ID: <20180223093937.GA8120@canndrew.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1290 bytes --]
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
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next reply other threads:[~2018-02-23 10:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-23 9:39 Andrew Cann [this message]
2018-02-26 16:35 ` Automatic TAP destruction/Monitoring namespace destruction Jiri Benc
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180223093937.GA8120@canndrew.org \
--to=shum@canndrew.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).