tun: VIMAGE fix for if_tun cloner The if_tun cloner is not virtualised, but if_clone_attach() does use a virtualised list of cloners. The result is that we can't find the if_tun cloner when we try to remove a renamed tun interface. Virtualise the cloner, and move the final cleanup into a sysuninit so that we're sure this happens after all of the vnet_sysuninits Note that we need unit numbers to be system-unique (rather than unique per vnet, as is done by if_clone_simple()). The unit number is used to create the corresponding /dev/tunX device node, and this node must match with the interface. Switch to if_clone_advanced() so that we have control over the unit numbers. Reproduction scenario: jail -c -n foo persist vnet jexec test ifconfig tun create jexec test ifconfig tun0 name wg0 jexec test ifconfig wg0 destroy PR: 235704
Details
- Reviewers
bz hrs • hselasky - Group Reviewers
network - Commits
- rS345285: MFC r344794:
rS345286: MFC r344794:
rS344794: tun: VIMAGE fix for if_tun cloner
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Note that the character device subsystem is not virtualized, so tunX must be system uniq.
Thanks. The original reporter of the bug discovered that too.
I'll see what I can do about that.
sys/net/if_tun.c | ||
---|---|---|
182 ↗ | (On Diff #54462) | Technically you should check there is a digit after tun? if (name[0] == 't' && name[1] == 'u' && name[2] == 'n' && isdigit(name[3])) |
sys/net/if_tun.c | ||
---|---|---|
182 ↗ | (On Diff #54462) | That'd break ifconfig tun create. |
sys/net/if_tun.c | ||
---|---|---|
182 ↗ | (On Diff #54462) | So check for (name[3] == 0 || isdigit(name[3])) strncmp() will match anything that starts with tun. |
sys/net/if_tun.c | ||
---|---|---|
182 ↗ | (On Diff #54462) | That is a good idea. I'll update the patch. |
I hate manually virtualised cloners but people changed if_clone.c logic under the virtualised cloner infrastructure and I gave up on this years ago. Sorry I am not really helpful here currently. Also I think it needs more words describing the problem and part of the solution as I cannot imagine this only being a problem of tun(4) left but probably another few others?
sys/net/if_tun.c | ||
---|---|---|
184 ↗ | (On Diff #54483) | Probably '\0' |
Thanks for updating the description; The repro scenario really should be a test case. Accept for the general idea, not for having checked the code in detail.