Page MenuHomeFreeBSD

libalias: Handle GetNewPort() errors properly
ClosedPublic

Authored by markj on Nov 27 2024, 2:33 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Sep 17, 9:21 PM
Unknown Object (File)
Thu, Sep 17, 9:10 PM
Unknown Object (File)
Fri, Sep 11, 1:46 AM
Unknown Object (File)
Sun, Sep 6, 10:34 PM
Unknown Object (File)
Sun, Sep 6, 7:10 PM
Unknown Object (File)
Sun, Sep 6, 2:06 PM
Unknown Object (File)
Sun, Sep 6, 9:34 AM
Unknown Object (File)
Thu, Sep 3, 2:31 PM

Details

Summary

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>

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Nov 27 2024, 2:33 PM

If there are no objections, I will commit this soon.

With diagonal reading definitely seems like improvement, but I don't remember anything of libalias, didn't do a search for landmines. No objections!

This revision was not accepted when it landed; it landed in state Needs Review.Apr 18 2025, 3:12 PM
This revision was automatically updated to reflect the committed changes.