Page MenuHomeFreeBSD

if_ovpn: ensure we're in vnet context when calling sorele()
ClosedPublic

Authored by kp on Nov 10 2022, 1:31 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Jun 10, 3:50 AM
Unknown Object (File)
Mar 20 2024, 6:06 PM
Unknown Object (File)
Dec 23 2023, 1:49 AM
Unknown Object (File)
Oct 27 2023, 10:40 AM
Unknown Object (File)
Sep 3 2023, 6:41 PM
Unknown Object (File)
Jul 2 2023, 3:05 PM
Unknown Object (File)
Jul 2 2023, 3:04 PM
Unknown Object (File)
Jul 2 2023, 3:04 PM

Details

Summary

We reference count to ensure we don't release the socket while we still
have data in flight. That means that we can end up releasing the socket
from ovpn_encrypt_tx_cb().

We must have a vnet context set when calling sorele() (which asserts
this from within sofree()), so move the CURVNET_SET()/CURVNET_RESTORE()
to ensure this is the case.

While here also add a couple of assertions to make this more obvious,
and to ease future debugging.

Sponsored by: Rubicon Communications, LLC ("Netgate")

Diff Detail

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

Event Timeline

kp requested review of this revision.Nov 10 2022, 1:31 PM

Just a fractional micropercent optimization suggestion. First set the VNET context, then enter the epoch. Same at the end: first exit the epoch, then restore VNET pointer. The VNET context set on a thread for extra time doesn't have any negative impact. The epoch prolonged for extra time does.

micro-optimisation, as recommended by Gleb.

This revision was not accepted when it landed; it landed in state Needs Review.Nov 14 2022, 8:37 AM
This revision was automatically updated to reflect the committed changes.