Skip to content

Commit

Permalink
rxrpc: Call udp_sendmsg() directly
Browse files Browse the repository at this point in the history
  • Loading branch information
dhowells committed Apr 28, 2022
1 parent 091c691 commit fdcaaad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions net/ipv6/udp.c
Expand Up @@ -1611,6 +1611,7 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
err = 0;
goto out;
}
EXPORT_SYMBOL(udpv6_sendmsg);

void udpv6_destroy_sock(struct sock *sk)
{
Expand Down
32 changes: 23 additions & 9 deletions net/rxrpc/output.c
Expand Up @@ -13,8 +13,20 @@
#include <linux/export.h>
#include <net/sock.h>
#include <net/af_rxrpc.h>
#include <net/udp.h>
#include "ar-internal.h"

extern int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len);

static ssize_t do_udp_sendmsg(struct socket *sk, struct msghdr *msg, size_t len)
{
struct sockaddr *sa = msg->msg_name;

if (sa->sa_family == AF_INET6)
return udpv6_sendmsg(sk->sk, msg, len);
return udp_sendmsg(sk->sk, msg, len);
}

struct rxrpc_abort_buffer {
struct rxrpc_wire_header whdr;
__be32 abort_code;
Expand Down Expand Up @@ -216,7 +228,8 @@ static int rxrpc_send_ack_packet(struct rxrpc_local *local, struct rxrpc_txbuf *
if (txb->ack.reason == RXRPC_ACK_PING)
rtt_slot = rxrpc_begin_rtt_probe(call, serial, rxrpc_rtt_tx_ping);

ret = kernel_sendmsg(local->socket, &msg, iov, 1, len);
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, len);
ret = do_udp_sendmsg(conn->params.local->socket, &msg, len);
call->peer->last_tx_at = ktime_get_seconds();
if (ret < 0)
trace_rxrpc_tx_fail(call->debug_id, serial, ret,
Expand Down Expand Up @@ -326,8 +339,8 @@ int rxrpc_send_abort_packet(struct rxrpc_call *call)
serial = atomic_inc_return(&conn->serial);
pkt.whdr.serial = htonl(serial);

ret = kernel_sendmsg(conn->params.local->socket,
&msg, iov, 1, sizeof(pkt));
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, sizeof(pkt));
ret = do_udp_sendmsg(conn->params.local->socket, &msg, sizeof(pkt));
conn->params.peer->last_tx_at = ktime_get_seconds();
if (ret < 0)
trace_rxrpc_tx_fail(call->debug_id, serial, ret,
Expand Down Expand Up @@ -377,6 +390,7 @@ static int rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_txbuf *t
msg.msg_control = NULL;
msg.msg_controllen = 0;
msg.msg_flags = 0;
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 1, len);

/* If our RTT cache needs working on, request an ACK. Also request
* ACKs if a DATA packet appears to have been lost.
Expand Down Expand Up @@ -441,7 +455,7 @@ static int rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_txbuf *t
* - in which case, we'll have processed the ICMP error
* message and update the peer record
*/
ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 1, len);
ret = do_udp_sendmsg(conn->params.local->socket, &msg, len);
conn->params.peer->last_tx_at = ktime_get_seconds();

up_read(&conn->params.local->defrag_sem);
Expand Down Expand Up @@ -514,8 +528,7 @@ static int rxrpc_send_data_packet(struct rxrpc_call *call, struct rxrpc_txbuf *t
case AF_INET:
ip_sock_set_mtu_discover(conn->params.local->socket->sk,
IP_PMTUDISC_DONT);
ret = kernel_sendmsg(conn->params.local->socket, &msg,
iov, 1, len);
ret = do_udp_sendmsg(conn->params.local->socket, &msg, len);
conn->params.peer->last_tx_at = ktime_get_seconds();

ip_sock_set_mtu_discover(conn->params.local->socket->sk,
Expand Down Expand Up @@ -601,8 +614,8 @@ void rxrpc_reject_packets(struct rxrpc_local *local)
whdr.flags ^= RXRPC_CLIENT_INITIATED;
whdr.flags &= RXRPC_CLIENT_INITIATED;

ret = kernel_sendmsg(local->socket, &msg,
iov, ioc, size);
iov_iter_kvec(&msg.msg_iter, WRITE, iov, ioc, size);
ret = do_udp_sendmsg(local->socket, &msg, size);
if (ret < 0)
trace_rxrpc_tx_fail(local->debug_id, 0, ret,
rxrpc_tx_point_reject);
Expand Down Expand Up @@ -657,7 +670,8 @@ void rxrpc_send_keepalive(struct rxrpc_peer *peer)

_proto("Tx VERSION (keepalive)");

ret = kernel_sendmsg(peer->local->socket, &msg, iov, 2, len);
iov_iter_kvec(&msg.msg_iter, WRITE, iov, 2, len);
ret = do_udp_sendmsg(peer->local->socket, &msg, len);
if (ret < 0)
trace_rxrpc_tx_fail(peer->debug_id, 0, ret,
rxrpc_tx_point_version_keepalive);
Expand Down

0 comments on commit fdcaaad

Please sign in to comment.