Hi Quinn,
Thanks for the response, so I have made the problem statement even more easier for you / apple :-) - I don't even need to write it back, I am just reading the frames as and when they come and doing nothing / i.e drop it. And if I blast 9216 bytes from the python side, three or four of those flows for 30 seconds (till ENOBUFs start popping up) can cause the entire NETransparent proxy stuff to lockup. Note that after this, NOT JUST UDP, TCP IS ALSO LOCKED UP !!! Even tcp handleNewFlow() is not getting called!
Whatever happens, how much ever data is sent, enobufs or not, the code should not lock up like this - that is a BAD bug! And that too it locks up TCP too! Please can you check with the team owning this library and see whats going on?
--- apple NE code--
func readUdp(_ flowid: Int64, _ flow: NEAppProxyUDPFlow, _ endp: NWHostEndpoint) {
flow.readDatagrams(completionHandler: { data, _, error in
guard let data = data else {
return
}
if error != nil {
return
}
if data.count == 0 {
return
}
for data in data {
if data.count == 0 {
return
}
}
// Do nothing, just read more from this flow
readUdp(flowid, flow, endp)
})
}
func handleNewUDPFlow(_ flow: NEAppProxyUDPFlow, initialRemoteEndpoint endPoint: NWEndpoint) -> Bool {
flow.open(withLocalEndpoint: nil, completionHandler: { error in
if let err = error {
logger.error("flow open error")
} else {
readUdp(flowid, flow, endp)
}
}
---- Python code to blast packets-----
#!/usr/bin/env python3
import time
import os
from random import *
import subprocess
import sys
import socket
import errno
iter = 1
enobuf = False
send = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
send.settimeout(5.0)
while True:
print("----- ITERATION ", iter, "------")
iter += 1
chars = []
size = randint(1, 9216)
hdr = size.to_bytes(2, byteorder='big')
for i in range(0,size-2):
chars.append(chr(ord('a')+i%30))
out = ''.join(chars)
try:
send.sendto(hdr + bytes(out, 'utf-8'), ("100.64.0.99", 555))
except OSError as e:
if e.errno == errno.ENOBUFS:
print("ENOBUF")
enobuf = True
pass
Rgds,
Gopa.