Skip to content

Commit 680d11f

Browse files
pyhdkuba-moo
authored andcommitted
udp: preserve the connected status if only UDP cmsg
If "udp_cmsg_send()" returned 0 (i.e. only UDP cmsg), "connected" should not be set to 0. Otherwise it stops the connected socket from using the cached route. Fixes: 2e8de85 ("udp: add gso segment cmsg") Signed-off-by: Yick Xie <[email protected]> Cc: [email protected] Reviewed-by: Willem de Bruijn <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f58f45c commit 680d11f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

net/ipv4/udp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,16 +1123,17 @@ int udp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
11231123

11241124
if (msg->msg_controllen) {
11251125
err = udp_cmsg_send(sk, msg, &ipc.gso_size);
1126-
if (err > 0)
1126+
if (err > 0) {
11271127
err = ip_cmsg_send(sk, msg, &ipc,
11281128
sk->sk_family == AF_INET6);
1129+
connected = 0;
1130+
}
11291131
if (unlikely(err < 0)) {
11301132
kfree(ipc.opt);
11311133
return err;
11321134
}
11331135
if (ipc.opt)
11341136
free = 1;
1135-
connected = 0;
11361137
}
11371138
if (!ipc.opt) {
11381139
struct ip_options_rcu *inet_opt;

net/ipv6/udp.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1474,9 +1474,11 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
14741474
ipc6.opt = opt;
14751475

14761476
err = udp_cmsg_send(sk, msg, &ipc6.gso_size);
1477-
if (err > 0)
1477+
if (err > 0) {
14781478
err = ip6_datagram_send_ctl(sock_net(sk), sk, msg, fl6,
14791479
&ipc6);
1480+
connected = false;
1481+
}
14801482
if (err < 0) {
14811483
fl6_sock_release(flowlabel);
14821484
return err;
@@ -1488,7 +1490,6 @@ int udpv6_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
14881490
}
14891491
if (!(opt->opt_nflen|opt->opt_flen))
14901492
opt = NULL;
1491-
connected = false;
14921493
}
14931494
if (!opt) {
14941495
opt = txopt_get(np);

0 commit comments

Comments
 (0)