Repository navigation
Client: bring a persistent TUN interface (camex.ko) down and remove its address on exit (3.5.1) (#99) - #100
Conversation
… address removed on exit (#99) With /dev/camex (or any --tun-dev but /dev/net/tun) the interface outlives the client: closing the fd left it UP with its address and the tunnel route until rmmod camex. On close the client now clears IFF_UP and sets the address to 0.0.0.0 (which removes it); the kernel drops the connected route and any route through the interface. Interfaces from /dev/net/tun go away by themselves; a device passed in (provider, CAMEX_TUN_FD) is not touched. test-e2e-persistent-tun.sh: a persistent tun interface named camex stands in for camex.ko; clean after SIGTERM, reused by the next client; /dev/net/tun unchanged. Version 3.5.1.
PR Summary by QodoClean up persistent Linux TUN interfaces on client exit
AI Description
Diagram
High-Level Assessment
Files changed (5)
|
Code Review by Qodo
1. The tunnel test passes without a tunnel
|
#99) Review fix (Qodo): the success line was logged even when an ioctl failed, and a failed SIOCGIFFLAGS was silent. Now each failure is logged and the last line says whether the interface is down and without its address, or what is left.
|
/review |
|
Code review by qodo was updated up to the latest commit 3d8285c |
|
/review |
|
Code review by qodo was updated up to the latest commit c1a6969 |
…ays what it does not cover (#99) Review fixes (Qodo): stop_client fails when pkill finds no client (one already gone got no signal); the header says the stand-in tests the interface's life cycle only, packets over the real camex.ko are the QEMU and device tests.
|
/review |
|
Code review by qodo was updated up to the latest commit cc4697d |
Fixes #99.
With
camex.ko(--tun-dev /dev/camex, or any device but/dev/net/tun) the interface belongs to the module and outlives the client. Closing the fd leftcamexUPwith its address and the tunnel route untilrmmod camex.src/tun.c: the Linux backend remembers whether the interface outlives its fd (tun_persistent: opened by us, not/dev/net/tun). On close it clearsIFF_UPand sets the address to0.0.0.0, which removes it; the kernel drops the connected route and any route through the interface. The routes fromCONFIGwere already removed before. LogsInterface camex down, address removed./dev/net/tuninterfaces go away by themselves and are not touched; a device passed in (TUN provider,CAMEX_TUN_FD) is not ours to change.docker/test-e2e-persistent-tun.sh(in CI): a persistent tun interface namedcamex(ip tuntap add,/dev/camex= the tun clone node) stands in forcamex.ko:/dev/net/tununchanged:tun0goes away with the client.CHANGELOG.md.Checked locally in containers (
compot/cross):make testOK;QEMU=1 ci/build-musl.shfor x86_64, arm, aarch64, mipsel: unit tests OK;test-e2e-persistent-tun.sh: 3.5.1 — PASS, 11/11; 3.5.0 fromlatest— the three cleanup checks fail, as expected.On the real router (OpenWrt 15.05.1, kernel 3.18.92,
camex.ko) the bug was seen with 3.5.0; this fix will be checked there with the CI build of this PR.