mirror of
https://github.com/systemd/systemd
synced 2024-10-15 12:34:37 +00:00
socket-util: add helper for querying the local AF_VSOCK CID
This commit is contained in:
parent
96f1f03c03
commit
d3109d8de0
|
@ -1753,3 +1753,18 @@ int socket_address_parse_vsock(SocketAddress *ret_address, const char *s) {
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int vsock_get_local_cid(unsigned *ret) {
|
||||
_cleanup_close_ int vsock_fd = -EBADF;
|
||||
|
||||
assert(ret);
|
||||
|
||||
vsock_fd = open("/dev/vsock", O_RDONLY|O_CLOEXEC);
|
||||
if (vsock_fd < 0)
|
||||
return log_debug_errno(errno, "Failed to open /dev/vsock: %m");
|
||||
|
||||
if (ioctl(vsock_fd, IOCTL_VM_SOCKETS_GET_LOCAL_CID, ret) < 0)
|
||||
return log_debug_errno(errno, "Failed to query local AF_VSOCK CID: %m");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -389,3 +389,5 @@ int socket_address_parse_vsock(SocketAddress *ret_address, const char *s);
|
|||
* /proc/sys/net/core/somaxconn anyway, thus by setting this to unbounded we just make that sysctl file
|
||||
* authoritative. */
|
||||
#define SOMAXCONN_DELUXE INT_MAX
|
||||
|
||||
int vsock_get_local_cid(unsigned *ret);
|
||||
|
|
Loading…
Reference in a new issue