MT#55283 remove dst endpoint from sendmsg args

Change-Id: I76f6b6a8afaf5657599877f6c7c8f25011c7ed1e
pull/2169/head
Richard Fuchs 2 weeks ago
parent 632a9cfdc7
commit 1efaaf0a27

@ -644,8 +644,8 @@ void kernel_cleanup_pollers(void) {
}
__attribute__((nonnull(1, 2, 3)))
static ssize_t kernel_sendmsg(socket_t *s, const endpoint_t *dst, struct uring_req_sendmsg *req)
__attribute__((nonnull(1, 2)))
static ssize_t kernel_sendmsg(socket_t *s, struct uring_req_sendmsg *req)
{
size_t skblen = 0;
for (size_t i = 0; i < req->mh.msg_iovlen; i++)
@ -719,7 +719,11 @@ static ssize_t kernel_sendmsg(socket_t *s, const endpoint_t *dst, struct uring_r
slot->steps[0].offset = fill;
slot->steps[0].length = skblen;
dst->address.family->endpoint2kernel(&metaslot->dst, dst);
// bit of a detour...
endpoint_t dst;
endpoint_parse_sockaddr_storage(&dst, &req->ss);
dst.address.family->endpoint2kernel(&metaslot->dst, &dst);
s->local.address.family->endpoint2kernel(&metaslot->src, &s->local);
metaslot->tos = s->tos;

@ -367,7 +367,7 @@ static bool __send_timer_send_1(struct rtp_header *rh, struct packet_stream *sin
.msg_iovlen = 1,
};
req->buf = bufferpool_ref(cp->s.s);
uring_methods.sendmsg(&sink_fd->socket, &sink->endpoint, &req->req);
uring_sendmsg(&sink_fd->socket, &sink->endpoint, &req->req);
if (sink->call->recording && (rtpe_config.rec_egress || rtpe_config.rec_both)) {
// fill in required members

@ -707,7 +707,7 @@ int stun_binding_request(const endpoint_t *dst, uint32_t transaction[3], str *pw
fingerprint(&r->req.mh, &r->fp);
output_finish_src(&r->req.mh);
uring_methods.sendmsg(sock, dst, &r->req);
uring_sendmsg(sock, dst, &r->req);
return 0;
}

@ -202,7 +202,7 @@ static bool __ip6_sockaddr2endpoint(endpoint_t *ep, const void *p) {
ep->port = ntohs(sin->sin6_port);
return true;
}
void endpoint_parse_sockaddr_storage(endpoint_t *ep, struct sockaddr_storage *sa) {
void endpoint_parse_sockaddr_storage(endpoint_t *ep, const struct sockaddr_storage *sa) {
if (sa->ss_family == AF_INET)
__ip4_sockaddr2endpoint(ep, sa);
else if (sa->ss_family == AF_INET6)

@ -307,7 +307,7 @@ bool endpoint_parse_any(endpoint_t *, const char *); // address (ip) optional
bool sockaddr_getaddrinfo_alt(sockaddr_t *a, sockaddr_t *a2, const char *s);
bool endpoint_parse_any_getaddrinfo_alt(endpoint_t *d, endpoint_t *d2, const char *s); // address (ip or hostname) optional
INLINE bool endpoint_parse_any_getaddrinfo(endpoint_t *d, const char *s);
void endpoint_parse_sockaddr_storage(endpoint_t *, struct sockaddr_storage *);
void endpoint_parse_sockaddr_storage(endpoint_t *, const struct sockaddr_storage *);
void kernel2endpoint(endpoint_t *ep, const struct re_address *ra);
unsigned int sockaddr_hash(const sockaddr_t *);

@ -45,13 +45,9 @@ struct poller_req {
};
};
__attribute__((nonnull(1, 2, 3)))
static ssize_t __socket_sendmsg(socket_t *s, const endpoint_t *e, struct uring_req_sendmsg *r)
__attribute__((nonnull(1, 2)))
static ssize_t __socket_sendmsg(socket_t *s, struct uring_req_sendmsg *r)
{
s->family->endpoint2sockaddr(&r->ss, e);
r->mh.msg_name = &r->ss;
r->mh.msg_namelen = s->family->sockaddr_size;
ssize_t ret = socket_sendmsg_direct(s, &r->mh);
uring_req_release(&r->req);
return ret;
@ -93,14 +89,11 @@ struct uring_buffer_req {
static __thread struct io_uring rtpe_uring;
__attribute__((nonnull(1, 2, 3)))
static ssize_t __uring_sendmsg(socket_t *s, const endpoint_t *e, struct uring_req_sendmsg *r)
__attribute__((nonnull(1, 2)))
static ssize_t __uring_sendmsg(socket_t *s, struct uring_req_sendmsg *r)
{
struct io_uring_sqe *sqe = io_uring_get_sqe(&rtpe_uring);
assert(sqe != NULL);
s->family->endpoint2sockaddr(&r->ss, e);
r->mh.msg_name = &r->ss;
r->mh.msg_namelen = s->family->sockaddr_size;
io_uring_sqe_set_data(sqe, r);
io_uring_prep_sendmsg(sqe, s->fd, &r->mh, 0);

@ -20,8 +20,8 @@ struct uring_req_sendmsg {
};
struct uring_methods {
ssize_t (*sendmsg)(socket_t *, const endpoint_t *, struct uring_req_sendmsg *)
__attribute__((nonnull(1, 2, 3)));
ssize_t (*sendmsg)(socket_t *, struct uring_req_sendmsg *)
__attribute__((nonnull(1, 2)));
unsigned int (*thread_loop)(void);
void (*free)(struct uring_req *);
@ -38,6 +38,21 @@ INLINE void uring_req_release(struct uring_req *r) {
r->handler(r, 0, 0);
}
__attribute__((nonnull(1, 2, 3)))
INLINE void uring_sendmsg_prepare(socket_t *s, const endpoint_t *e, struct uring_req_sendmsg *r) {
s->family->endpoint2sockaddr(&r->ss, e);
r->mh.msg_name = &r->ss;
r->mh.msg_namelen = s->family->sockaddr_size;
}
__attribute__((nonnull(1, 2, 3)))
INLINE ssize_t uring_sendmsg(socket_t *s, const endpoint_t *e, struct uring_req_sendmsg *r) {
uring_sendmsg_prepare(s, e, r);
return uring_methods.sendmsg(s, r);
}
#define uring_alloc_sendmsg(sv, fn) ({ \
__typeof__(sv) __ret = uring_methods.__alloc_req((sv), sizeof(*(sv))); \
memset(sv, 0, sizeof(*(sv))); \

Loading…
Cancel
Save