On Sun, Aug 07, 2022 at 03:53:27AM +0300, Vitaliy Makkoveev wrote: > Please note, the `so_pcb' can't be NULL. We nullify it only on dead > socket, which should not be passed to (*pr_userreq)(). The newly created > socket has `so_pcb' set to NULL only until we pass it to (*pr_attach)() > and we don't use sockets if attach failed. So I use KASSERT() instead of > pcb != NULL check.
For TCP this is not true. A reset packet in tcp_input() calls tcp_drop() -> tcp_close() -> in_pcbdetach() -> so->so_pcb = NULL This cannot happen in any TCP state. But KASSERT(inp != NULL) in tcp_disconnect() wrong. On the other hand if (tp == NULL) is not necessary everywhere. > - if (error) > - break; > + if (error != 0) > + return (error); I prefer the first idiom. If there is an error, do something. We should not change the style in opposite direction. This will prevent consistency. Otherwise I think the diff is correct. bluhm
