celzero / firestack

Userspace wireguard and network monitor
https://rethinkdns.com/app
Mozilla Public License 2.0
99 stars 16 forks source link

After a fd swap, netstack stops consuming dispatched packets #57

Closed hussainmohd-a closed 5 months ago

hussainmohd-a commented 5 months ago

Logs

2024-05-23 17:27:16.157  1885-28789 GoLog                   com.celzero.bravedns                 I  fdbased.go:238: I ns: tun(122 => 111): Swap: stopping previous dispatcher
2024-05-23 17:27:16.158  1885-28789 GoLog                   com.celzero.bravedns                 I  tunnel.go:260: I tun: new link; fd(111), mtu(1280); err? <nil>
2024-05-23 17:27:16.158  1885-29961 VpnLifecycle            com.celzero.bravedns                 I  mtu? true(o:null, n:1500); routes? false, vpn restarted
2024-05-23 17:27:18.161  1885-29242 GoLog                   com.celzero.bravedns                 I  dispatchers.go:208: I ns: dispatch: stop: fds closed event(132) tun(122); err? <nil>
2024-05-23 17:27:18.244  1885-28789 GoLog                   com.celzero.bravedns                 I  fdbased.go:444: I ns: tun(122): dispatchLoop: exit; err(no such file)
ignoramous commented 5 months ago

netstack stalls when protocol handlers (intra/netstack/[tcp|icmp|udp].go) are busy, hence making netstack wait until they are free to handle more work, since after recent changes (https://github.com/celzero/firestack/commit/760a9a472831b44740d56e782b129211f055d60e), dispatchers.go is delivering packets from a limited number of goroutines (the lower the number of dispatcher goroutines, the higher the chances of hitting a stall due to busy protocol handlers): https://github.com/celzero/firestack/issues/58#issuecomment-2132385019

ignoramous commented 5 months ago

Main bug: