Skip to content

Commit 0a266f8

Browse files
committed
Merge remote-tracking branch 'origin/testing'
Sabrina Dubroca says: ==================== xfrm: a few fixes for espintc 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. ==================== Signed-off-by: Steffen Klassert <[email protected]>
2 parents 17175d1 + 95a35b4 commit 0a266f8

File tree

2 files changed

+19
-16
lines changed

2 files changed

+19
-16
lines changed

net/xfrm/espintcp.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,11 @@ static int espintcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
109109
flags |= nonblock ? MSG_DONTWAIT : 0;
110110

111111
skb = __skb_recv_datagram(sk, &ctx->ike_queue, flags, &off, &err);
112-
if (!skb)
112+
if (!skb) {
113+
if (err == -EAGAIN && sk->sk_shutdown & RCV_SHUTDOWN)
114+
return 0;
113115
return err;
116+
}
114117

115118
copied = len;
116119
if (copied > skb->len)
@@ -213,7 +216,7 @@ static int espintcp_sendskmsg_locked(struct sock *sk,
213216
return 0;
214217
}
215218

216-
static int espintcp_push_msgs(struct sock *sk)
219+
static int espintcp_push_msgs(struct sock *sk, int flags)
217220
{
218221
struct espintcp_ctx *ctx = espintcp_getctx(sk);
219222
struct espintcp_msg *emsg = &ctx->partial;
@@ -227,12 +230,12 @@ static int espintcp_push_msgs(struct sock *sk)
227230
ctx->tx_running = 1;
228231

229232
if (emsg->skb)
230-
err = espintcp_sendskb_locked(sk, emsg, 0);
233+
err = espintcp_sendskb_locked(sk, emsg, flags);
231234
else
232-
err = espintcp_sendskmsg_locked(sk, emsg, 0);
235+
err = espintcp_sendskmsg_locked(sk, emsg, flags);
233236
if (err == -EAGAIN) {
234237
ctx->tx_running = 0;
235-
return 0;
238+
return flags & MSG_DONTWAIT ? -EAGAIN : 0;
236239
}
237240
if (!err)
238241
memset(emsg, 0, sizeof(*emsg));
@@ -257,7 +260,7 @@ int espintcp_push_skb(struct sock *sk, struct sk_buff *skb)
257260
offset = skb_transport_offset(skb);
258261
len = skb->len - offset;
259262

260-
espintcp_push_msgs(sk);
263+
espintcp_push_msgs(sk, 0);
261264

262265
if (emsg->len) {
263266
kfree_skb(skb);
@@ -270,7 +273,7 @@ int espintcp_push_skb(struct sock *sk, struct sk_buff *skb)
270273
emsg->len = len;
271274
emsg->skb = skb;
272275

273-
espintcp_push_msgs(sk);
276+
espintcp_push_msgs(sk, 0);
274277

275278
return 0;
276279
}
@@ -287,7 +290,7 @@ static int espintcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
287290
char buf[2] = {0};
288291
int err, end;
289292

290-
if (msg->msg_flags)
293+
if (msg->msg_flags & ~MSG_DONTWAIT)
291294
return -EOPNOTSUPP;
292295

293296
if (size > MAX_ESPINTCP_MSG)
@@ -298,9 +301,10 @@ static int espintcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
298301

299302
lock_sock(sk);
300303

301-
err = espintcp_push_msgs(sk);
304+
err = espintcp_push_msgs(sk, msg->msg_flags & MSG_DONTWAIT);
302305
if (err < 0) {
303-
err = -ENOBUFS;
306+
if (err != -EAGAIN || !(msg->msg_flags & MSG_DONTWAIT))
307+
err = -ENOBUFS;
304308
goto unlock;
305309
}
306310

@@ -337,10 +341,9 @@ static int espintcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t size)
337341

338342
tcp_rate_check_app_limited(sk);
339343

340-
err = espintcp_push_msgs(sk);
344+
err = espintcp_push_msgs(sk, msg->msg_flags & MSG_DONTWAIT);
341345
/* this message could be partially sent, keep it */
342-
if (err < 0)
343-
goto unlock;
346+
344347
release_sock(sk);
345348

346349
return size;
@@ -374,7 +377,7 @@ static void espintcp_tx_work(struct work_struct *work)
374377

375378
lock_sock(sk);
376379
if (!ctx->tx_running)
377-
espintcp_push_msgs(sk);
380+
espintcp_push_msgs(sk, 0);
378381
release_sock(sk);
379382
}
380383

net/xfrm/xfrm_policy.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#ifdef CONFIG_XFRM_STATISTICS
4040
#include <net/snmp.h>
4141
#endif
42-
#ifdef CONFIG_INET_ESPINTCP
42+
#ifdef CONFIG_XFRM_ESPINTCP
4343
#include <net/espintcp.h>
4444
#endif
4545

@@ -4149,7 +4149,7 @@ void __init xfrm_init(void)
41494149
seqcount_init(&xfrm_policy_hash_generation);
41504150
xfrm_input_init();
41514151

4152-
#ifdef CONFIG_INET_ESPINTCP
4152+
#ifdef CONFIG_XFRM_ESPINTCP
41534153
espintcp_init();
41544154
#endif
41554155

0 commit comments

Comments
 (0)