Commit 03485f2a authored by Vlad Yasevich's avatar Vlad Yasevich Committed by David S. Miller

udpv6: Add lockless sendmsg() support

This commit adds the same functionaliy to IPv6 that
commit 903ab86d
Author: Herbert Xu <herbert@gondor.apana.org.au>
Date:   Tue Mar 1 02:36:48 2011 +0000

    udp: Add lockless transmit path

added to IPv4.

UDP transmit path can now run without a socket lock,
thus allowing multiple threads to send to a single socket
more efficiently.
This is only used when corking/MSG_MORE is not used.
Signed-off-by: default avatarVladislav Yasevich <vyasevic@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d39d938c
...@@ -1177,6 +1177,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1177,6 +1177,7 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (len > INT_MAX - sizeof(struct udphdr)) if (len > INT_MAX - sizeof(struct udphdr))
return -EMSGSIZE; return -EMSGSIZE;
getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
if (up->pending) { if (up->pending) {
/* /*
* There are pending frames. * There are pending frames.
...@@ -1307,6 +1308,20 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1307,6 +1308,20 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
goto do_confirm; goto do_confirm;
back_from_confirm: back_from_confirm:
/* Lockless fast path for the non-corking case */
if (!corkreq) {
struct sk_buff *skb;
skb = ip6_make_skb(sk, getfrag, msg, ulen,
sizeof(struct udphdr), hlimit, tclass, opt,
&fl6, (struct rt6_info *)dst,
msg->msg_flags, dontfrag);
err = PTR_ERR(skb);
if (!IS_ERR_OR_NULL(skb))
err = udp_v6_send_skb(skb, &fl6);
goto release_dst;
}
lock_sock(sk); lock_sock(sk);
if (unlikely(up->pending)) { if (unlikely(up->pending)) {
/* The socket is already corked while preparing it. */ /* The socket is already corked while preparing it. */
...@@ -1324,7 +1339,6 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1324,7 +1339,6 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
if (dontfrag < 0) if (dontfrag < 0)
dontfrag = np->dontfrag; dontfrag = np->dontfrag;
up->len += ulen; up->len += ulen;
getfrag = is_udplite ? udplite_getfrag : ip_generic_getfrag;
err = ip6_append_data(sk, getfrag, msg, ulen, err = ip6_append_data(sk, getfrag, msg, ulen,
sizeof(struct udphdr), hlimit, tclass, opt, &fl6, sizeof(struct udphdr), hlimit, tclass, opt, &fl6,
(struct rt6_info *)dst, (struct rt6_info *)dst,
...@@ -1336,6 +1350,11 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1336,6 +1350,11 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
else if (unlikely(skb_queue_empty(&sk->sk_write_queue))) else if (unlikely(skb_queue_empty(&sk->sk_write_queue)))
up->pending = 0; up->pending = 0;
if (err > 0)
err = np->recverr ? net_xmit_errno(err) : 0;
release_sock(sk);
release_dst:
if (dst) { if (dst) {
if (connected) { if (connected) {
ip6_dst_store(sk, dst, ip6_dst_store(sk, dst,
...@@ -1352,9 +1371,6 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk, ...@@ -1352,9 +1371,6 @@ int udpv6_sendmsg(struct kiocb *iocb, struct sock *sk,
dst = NULL; dst = NULL;
} }
if (err > 0)
err = np->recverr ? net_xmit_errno(err) : 0;
release_sock(sk);
out: out:
dst_release(dst); dst_release(dst);
fl6_sock_release(flowlabel); fl6_sock_release(flowlabel);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment