HomeFreeBSD

libalias: Handle GetNewPort() errors properly

Description

libalias: Handle GetNewPort() errors properly

AddLink() fails when memory allocation fails or no free port is
available; both are error conditions. However, functions such as
FindUdpTcpIn() were converting such failures to PKT_ALIAS_IGNORED, which
effectively means, "pass the packet without translation," which isn't
what we want.

Fix the problem by making sure that AddLink() errors are converted to
PKT_ALIAS_ERROR where appropriate. The diff is a bit large but is
mostly mechanical: functions like TcpAliasOut() are converted to return
a result code, and an additional out-parameter is added to return the
alias_link pointer.

Reported by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
Tested by: Yuxiang Yang <yangyx22@mails.tsinghua.edu.cn>
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D47778

Details

Provenance
markjAuthored on Fri, Apr 18, 1:37 PM
Differential Revision
D47778: libalias: Handle GetNewPort() errors properly
Parents
rG0015baeb19eb: pf: Avoid logging state creation failures unless requested
Branches
Unknown
Tags
Unknown