Message ID | 03db9765fe1ef0f61bfc87fc68b5a95b4126aa4e.1663143016.git.peilin.ye@bytedance.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [net-next,1/2] udp: Refactor udp_read_skb() | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Clearly marked for net-next |
netdev/apply | fail | Patch does not apply to net-next |
On Wed, 14 Sep 2022 01:15:30 -0700 Peilin Ye wrote: > Delete the unnecessary while loop in udp_read_skb() for readability. > Additionally, since recv_actor() cannot return a value greater than > skb->len (see sk_psock_verdict_recv()), remove the redundant check. These don't apply cleanly, please rebase?
On Tue, 20 Sep 2022 17:38:59 -0700 Jakub Kicinski wrote: > On Wed, 14 Sep 2022 01:15:30 -0700 Peilin Ye wrote: > > Delete the unnecessary while loop in udp_read_skb() for readability. > > Additionally, since recv_actor() cannot return a value greater than > > skb->len (see sk_psock_verdict_recv()), remove the redundant check. > > These don't apply cleanly, please rebase? Ah, it's the WARN_ON_ONCE() change. In that case please resend after net is merged into net-next (Thu evening).
On Tue, Sep 20, 2022 at 05:40:52PM -0700, Jakub Kicinski wrote: > On Tue, 20 Sep 2022 17:38:59 -0700 Jakub Kicinski wrote: > > On Wed, 14 Sep 2022 01:15:30 -0700 Peilin Ye wrote: > > > Delete the unnecessary while loop in udp_read_skb() for readability. > > > Additionally, since recv_actor() cannot return a value greater than > > > skb->len (see sk_psock_verdict_recv()), remove the redundant check. > > > > These don't apply cleanly, please rebase? > > Ah, it's the WARN_ON_ONCE() change. In that case please resend after > net is merged into net-next (Thu evening). Sure, but only the TCP part was merged [1] into net. I just sent the UDP part again [2], and will resend this patchset after both [1] and [2] are merged into net-next. Thanks! [1] https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=96628951869c0dedf0377adca01c8675172d8639 [2] https://lore.kernel.org/netdev/20220921005915.2697-1-yepeilin.cs@gmail.com/T/#u Peilin Ye
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 560d9eadeaa5..d63118ce5900 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -1801,41 +1801,29 @@ EXPORT_SYMBOL(__skb_recv_udp); int udp_read_skb(struct sock *sk, skb_read_actor_t recv_actor) { - int copied = 0; - - while (1) { - struct sk_buff *skb; - int err, used; - - skb = skb_recv_udp(sk, MSG_DONTWAIT, &err); - if (!skb) - return err; + struct sk_buff *skb; + int err, copied; - if (udp_lib_checksum_complete(skb)) { - __UDP_INC_STATS(sock_net(sk), UDP_MIB_CSUMERRORS, - IS_UDPLITE(sk)); - __UDP_INC_STATS(sock_net(sk), UDP_MIB_INERRORS, - IS_UDPLITE(sk)); - atomic_inc(&sk->sk_drops); - kfree_skb(skb); - continue; - } +try_again: + skb = skb_recv_udp(sk, MSG_DONTWAIT, &err); + if (!skb) + return err; - WARN_ON_ONCE(!skb_set_owner_sk_safe(skb, sk)); - used = recv_actor(sk, skb); - if (used <= 0) { - if (!copied) - copied = used; - kfree_skb(skb); - break; - } else if (used <= skb->len) { - copied += used; - } + if (udp_lib_checksum_complete(skb)) { + int is_udplite = IS_UDPLITE(sk); + struct net *net = sock_net(sk); + __UDP_INC_STATS(net, UDP_MIB_CSUMERRORS, is_udplite); + __UDP_INC_STATS(net, UDP_MIB_INERRORS, is_udplite); + atomic_inc(&sk->sk_drops); kfree_skb(skb); - break; + goto try_again; } + WARN_ON_ONCE(!skb_set_owner_sk_safe(skb, sk)); + copied = recv_actor(sk, skb); + kfree_skb(skb); + return copied; } EXPORT_SYMBOL(udp_read_skb);