* [PATCH ipsec 0/3] xfrm: a few fixes for espintcp
@ 2020-07-16 8:09 Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 1/3] espintcp: support non-blocking sends Sabrina Dubroca
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Sabrina Dubroca @ 2020-07-16 8:09 UTC (permalink / raw)
To: netdev; +Cc: Steffen Klassert, Sabrina Dubroca
Andrew Cagney reported some issues when trying to use async operations
on the encapsulation socket. Patches 1 and 2 take care of these bugs.
In addition, I missed a spot when adding IPv6 support and converting
to the common config option.
Sabrina Dubroca (3):
espintcp: support non-blocking sends
espintcp: recv() should return 0 when the peer socket is closed
xfrm: policy: fix IPv6-only espintcp
net/xfrm/espintcp.c | 31 +++++++++++++++++--------------
net/xfrm/xfrm_policy.c | 4 ++--
2 files changed, 19 insertions(+), 16 deletions(-)
--
2.27.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH ipsec 1/3] espintcp: support non-blocking sends
2020-07-16 8:09 [PATCH ipsec 0/3] xfrm: a few fixes for espintcp Sabrina Dubroca
@ 2020-07-16 8:09 ` Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 2/3] espintcp: recv() should return 0 when the peer socket is closed Sabrina Dubroca
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Sabrina Dubroca @ 2020-07-16 8:09 UTC (permalink / raw)
To: netdev; +Cc: Steffen Klassert, Sabrina Dubroca, Andrew Cagney
Currently, non-blocking sends from userspace result in EOPNOTSUPP.
To support this, we need to tell espintcp_sendskb_locked() and
espintcp_sendskmsg_locked() that non-blocking operation was requested
from espintcp_sendmsg().
Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")
Reported-by: Andrew Cagney <cagney@libreswan.org>
Tested-by: Andrew Cagney <cagney@libreswan.org>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
net/xfrm/espintcp.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/net/xfrm/espintcp.c b/net/xfrm/espintcp.c
index 100e29682b48..5d3d2b98c62d 100644
--- a/net/xfrm/espintcp.c
+++ b/net/xfrm/espintcp.c
@@ -213,7 +213,7 @@ static int espintcp_sendskmsg_locked(struct sock *sk,
return 0;
}
-static int espintcp_push_msgs(struct sock *sk)
+static int espintcp_push_msgs(struct sock *sk, int flags)
{
struct espintcp_ctx *ctx = espintcp_getctx(sk);
struct espintcp_msg *emsg = &ctx->partial;
@@ -227,12 +227,12 @@ static int espintcp_push_msgs(struct sock *sk)
ctx->tx_running = 1;
if (emsg->skb)
- err = espintcp_sendskb_locked(sk, emsg, 0);
+ err = espintcp_sendskb_locked(sk, emsg, flags);
else
- err = espintcp_sendskmsg_locked(sk, emsg, 0);
+ err = espintcp_sendskmsg_locked(sk, emsg, flags);
if (err == -EAGAIN) {
ctx->tx_running = 0;
- return 0;
+ return flags & MSG_DONTWAIT ? -EAGAIN : 0;
}
if (!err)
memset(emsg, 0, sizeof(*emsg));
@@ -257,7 +257,7 @@ int espintcp_push_skb(struct sock *sk, struct sk_buff *skb)
offset = skb_transport_offset(skb);
len = skb->len - offset;
- espintcp_push_msgs(sk);
+ espintcp_push_msgs(sk, 0);
if (emsg->len) {
kfree_skb(skb);
@@ -270,7 +270,7 @@ int espintcp_push_skb(struct sock *sk, struct sk_buff *skb)
emsg->len = len;
emsg->skb = skb;
- espintcp_push_msgs(sk);
+ espintcp_push_msgs(sk, 0);
return 0;
}
@@ -287,7 +287,7 @@ static int espintcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
char buf[2] = {0};
int err, end;
- if (msg->msg_flags)
+ if (msg->msg_flags & ~MSG_DONTWAIT)
return -EOPNOTSUPP;
if (size > MAX_ESPINTCP_MSG)
@@ -298,9 +298,10 @@ static int espintcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
lock_sock(sk);
- err = espintcp_push_msgs(sk);
+ err = espintcp_push_msgs(sk, msg->msg_flags & MSG_DONTWAIT);
if (err < 0) {
- err = -ENOBUFS;
+ if (err != -EAGAIN || !(msg->msg_flags & MSG_DONTWAIT))
+ err = -ENOBUFS;
goto unlock;
}
@@ -337,10 +338,9 @@ static int espintcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
tcp_rate_check_app_limited(sk);
- err = espintcp_push_msgs(sk);
+ err = espintcp_push_msgs(sk, msg->msg_flags & MSG_DONTWAIT);
/* this message could be partially sent, keep it */
- if (err < 0)
- goto unlock;
+
release_sock(sk);
return size;
@@ -374,7 +374,7 @@ static void espintcp_tx_work(struct work_struct *work)
lock_sock(sk);
if (!ctx->tx_running)
- espintcp_push_msgs(sk);
+ espintcp_push_msgs(sk, 0);
release_sock(sk);
}
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH ipsec 2/3] espintcp: recv() should return 0 when the peer socket is closed
2020-07-16 8:09 [PATCH ipsec 0/3] xfrm: a few fixes for espintcp Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 1/3] espintcp: support non-blocking sends Sabrina Dubroca
@ 2020-07-16 8:09 ` Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 3/3] xfrm: policy: fix IPv6-only espintcp compilation Sabrina Dubroca
2020-07-21 6:06 ` [PATCH ipsec 0/3] xfrm: a few fixes for espintcp Steffen Klassert
3 siblings, 0 replies; 5+ messages in thread
From: Sabrina Dubroca @ 2020-07-16 8:09 UTC (permalink / raw)
To: netdev; +Cc: Steffen Klassert, Sabrina Dubroca, Andrew Cagney
man 2 recv says:
RETURN VALUE
When a stream socket peer has performed an orderly shutdown, the
return value will be 0 (the traditional "end-of-file" return).
Currently, this works for blocking reads, but non-blocking reads will
return -EAGAIN. This patch overwrites that return value when the peer
won't send us any more data.
Fixes: e27cca96cd68 ("xfrm: add espintcp (RFC 8229)")
Reported-by: Andrew Cagney <cagney@libreswan.org>
Tested-by: Andrew Cagney <cagney@libreswan.org>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
net/xfrm/espintcp.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/espintcp.c b/net/xfrm/espintcp.c
index 5d3d2b98c62d..cb83e3664680 100644
--- a/net/xfrm/espintcp.c
+++ b/net/xfrm/espintcp.c
@@ -109,8 +109,11 @@ static int espintcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
flags |= nonblock ? MSG_DONTWAIT : 0;
skb = __skb_recv_datagram(sk, &ctx->ike_queue, flags, &off, &err);
- if (!skb)
+ if (!skb) {
+ if (err == -EAGAIN && sk->sk_shutdown & RCV_SHUTDOWN)
+ return 0;
return err;
+ }
copied = len;
if (copied > skb->len)
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH ipsec 3/3] xfrm: policy: fix IPv6-only espintcp compilation
2020-07-16 8:09 [PATCH ipsec 0/3] xfrm: a few fixes for espintcp Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 1/3] espintcp: support non-blocking sends Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 2/3] espintcp: recv() should return 0 when the peer socket is closed Sabrina Dubroca
@ 2020-07-16 8:09 ` Sabrina Dubroca
2020-07-21 6:06 ` [PATCH ipsec 0/3] xfrm: a few fixes for espintcp Steffen Klassert
3 siblings, 0 replies; 5+ messages in thread
From: Sabrina Dubroca @ 2020-07-16 8:09 UTC (permalink / raw)
To: netdev; +Cc: Steffen Klassert, Sabrina Dubroca
In case we're compiling espintcp support only for IPv6, we should
still initialize the common code.
Fixes: 26333c37fc28 ("xfrm: add IPv6 support for espintcp")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
net/xfrm/xfrm_policy.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 6847b3579f54..19c5e0fa3f44 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -39,7 +39,7 @@
#ifdef CONFIG_XFRM_STATISTICS
#include <net/snmp.h>
#endif
-#ifdef CONFIG_INET_ESPINTCP
+#ifdef CONFIG_XFRM_ESPINTCP
#include <net/espintcp.h>
#endif
@@ -4149,7 +4149,7 @@ void __init xfrm_init(void)
seqcount_init(&xfrm_policy_hash_generation);
xfrm_input_init();
-#ifdef CONFIG_INET_ESPINTCP
+#ifdef CONFIG_XFRM_ESPINTCP
espintcp_init();
#endif
--
2.27.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH ipsec 0/3] xfrm: a few fixes for espintcp
2020-07-16 8:09 [PATCH ipsec 0/3] xfrm: a few fixes for espintcp Sabrina Dubroca
` (2 preceding siblings ...)
2020-07-16 8:09 ` [PATCH ipsec 3/3] xfrm: policy: fix IPv6-only espintcp compilation Sabrina Dubroca
@ 2020-07-21 6:06 ` Steffen Klassert
3 siblings, 0 replies; 5+ messages in thread
From: Steffen Klassert @ 2020-07-21 6:06 UTC (permalink / raw)
To: Sabrina Dubroca; +Cc: netdev
On Thu, Jul 16, 2020 at 10:09:00AM +0200, Sabrina Dubroca wrote:
> Andrew Cagney reported some issues when trying to use async operations
> on the encapsulation socket. Patches 1 and 2 take care of these bugs.
>
> In addition, I missed a spot when adding IPv6 support and converting
> to the common config option.
>
> Sabrina Dubroca (3):
> espintcp: support non-blocking sends
> espintcp: recv() should return 0 when the peer socket is closed
> xfrm: policy: fix IPv6-only espintcp
All applied, thanks a lot Sabrina!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-07-21 6:06 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-16 8:09 [PATCH ipsec 0/3] xfrm: a few fixes for espintcp Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 1/3] espintcp: support non-blocking sends Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 2/3] espintcp: recv() should return 0 when the peer socket is closed Sabrina Dubroca
2020-07-16 8:09 ` [PATCH ipsec 3/3] xfrm: policy: fix IPv6-only espintcp compilation Sabrina Dubroca
2020-07-21 6:06 ` [PATCH ipsec 0/3] xfrm: a few fixes for espintcp Steffen Klassert
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).