diff options
author | mvs <mvs@openbsd.org> | 2021-01-18 09:55:43 +0000 |
---|---|---|
committer | mvs <mvs@openbsd.org> | 2021-01-18 09:55:43 +0000 |
commit | 3106ab340dcb50c20a5dced4de5940b11de81fee (patch) | |
tree | 9a7a763eb2655e50bc5e5044980ff7c52215b665 /share | |
parent | support PCAP_NETMASK_UNKNOWN, adapted from an old commit in upstream (diff) | |
download | wireguard-openbsd-3106ab340dcb50c20a5dced4de5940b11de81fee.tar.xz wireguard-openbsd-3106ab340dcb50c20a5dced4de5940b11de81fee.zip |
Introduce new function if_unit(9). This function returns a pointer the
interface descriptor corresponding to the unique name. This descriptor
is guaranteed to be valid until if_put(9) is called on the returned
pointer. if_unit(9) should replace already existent ifunit() which
returns descriptor not safe for dereference when context was switched.
This allow us to avoid some use-after-free issues in ioctl(2) path.
Also this unifies interface descriptor usage.
ok claudio@ sashan@
Diffstat (limited to 'share')
-rw-r--r-- | share/man/man9/if_get.9 | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/share/man/man9/if_get.9 b/share/man/man9/if_get.9 index 5174d7c2676..4138c747f39 100644 --- a/share/man/man9/if_get.9 +++ b/share/man/man9/if_get.9 @@ -1,4 +1,4 @@ -.\" $OpenBSD: if_get.9,v 1.2 2015/12/08 18:35:51 jmc Exp $ +.\" $OpenBSD: if_get.9,v 1.3 2021/01/18 09:55:43 mvs Exp $ .\" .\" Copyright (c) 2015 Martin Pieuchot .\" @@ -14,17 +14,20 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: December 8 2015 $ +.Dd $Mdocdate: January 18 2021 $ .Dt IF_GET 9 .Os .Sh NAME .Nm if_get , +.Nm if_unit , .Nm if_put .Nd get an interface pointer from an interface index .Sh SYNOPSIS .In net/if.h .Ft struct ifnet * .Fn if_get "unsigned int ifidx" +.Ft struct ifnet * +.Fn if_unit "const char *name" .Ft void .Fn if_put "struct ifnet *ifp" .Sh DESCRIPTION @@ -43,6 +46,15 @@ is never associated with an interface descriptor and can be used to determine if an interface index is valid or not. .Pp The +.Fn if_unit +function returns a pointer to the interface descriptor corresponding to the +unique name +.Fa name . +This descriptor is guaranteed to be valid until +.Fn if_put +is called on the returned pointer. +.Pp +The .Fn if_put function releases a reference on the interface descriptor pointed by .Fa ifp . @@ -53,6 +65,7 @@ is a pointer, no action occurs. .Sh CONTEXT .Fn if_get , +.Fn if_unit and .Fn if_put can be called during autoconf, from process context, or from interrupt context. @@ -60,3 +73,8 @@ can be called during autoconf, from process context, or from interrupt context. .Fn if_get returns a pointer to an interface descriptor if the index is valid, otherwise .Dv NULL . +.Pp +.Fn if_unit +returns a pointer to an interface descriptor if the interface with present +name exists, otherwise +.Dv NULL . |