Subj. The getpeername(2) sysckall is pretty simple. For inet and unix sockets it follows the code which was already unlocked with accept(2) unlocking. Just copy the 'sockaddr' structure containing the peer address. For key management and route domain sockets it just copies the read-only global 'sockaddr' structure.
ok? Index: sys/kern/syscalls.master =================================================================== RCS file: /cvs/src/sys/kern/syscalls.master,v retrieving revision 1.221 diff -u -p -r1.221 syscalls.master --- sys/kern/syscalls.master 23 Dec 2021 18:50:31 -0000 1.221 +++ sys/kern/syscalls.master 3 Jan 2022 16:39:02 -0000 @@ -97,7 +97,7 @@ socklen_t *fromlenaddr); } 30 STD NOLOCK { int sys_accept(int s, struct sockaddr *name, \ socklen_t *anamelen); } -31 STD { int sys_getpeername(int fdes, struct sockaddr *asa, \ +31 STD NOLOCK { int sys_getpeername(int fdes, struct sockaddr *asa, \ socklen_t *alen); } 32 STD { int sys_getsockname(int fdes, struct sockaddr *asa, \ socklen_t *alen); }