MCPcopy Create free account
hub / github.com/axboe/liburing / run_get_peername

Function run_get_peername

test/socket-getsetsock-cmd.c:139–175  ·  view source on GitHub ↗

* Run getsock operation using SO_PEERNAME using io_uring cmd operation * and getsockopt(2) and compare the results. */

Source from the content-addressed store, hash-verified

137 * and getsockopt(2) and compare the results.
138 */
139static int run_get_peername(struct io_uring *ring, struct fds *sockfds, bool async)
140{
141 struct sockaddr sval, uval = {};
142 socklen_t slen = sizeof(sval);
143 socklen_t ulen = sizeof(uval);
144 int err;
145
146 /* Get values from the systemcall */
147 err = getsockopt(sockfds->tx, SOL_SOCKET, SO_PEERNAME, &sval, &slen);
148 assert(err == 0);
149
150 /* Getting SO_PEERNAME */
151 err = submit_cmd_sqe(ring, sockfds->rx, SOCKET_URING_OP_GETSOCKOPT,
152 SOL_SOCKET, SO_PEERNAME, &uval, ulen, async);
153 assert(err == 1);
154
155 /* Wait for the CQE */
156 err = receive_cqe(ring);
157 if (err == -EOPNOTSUPP || err == -EINVAL) {
158 no_sock_opt = 1;
159 return T_EXIT_SKIP;
160 }
161
162 if (err < 0) {
163 fprintf(stderr, "%s: Error in the CQE: %d\n", __func__, err);
164 return T_EXIT_FAIL;
165 }
166
167 /* The length comes from cqe->res, which is returned from receive_cqe() */
168 ulen = err;
169
170 /* Make sure that io_uring operation returns the same values as the systemcall */
171 assert(sval.sa_family == uval.sa_family);
172 assert(slen == ulen);
173
174 return T_EXIT_PASS;
175}
176
177/*
178 * Run getsockopt tests. Basically comparing io_uring output and systemcall results

Callers 1

run_getsockopt_testFunction · 0.85

Calls 2

submit_cmd_sqeFunction · 0.85
receive_cqeFunction · 0.70

Tested by

no test coverage detected