From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Abeni Subject: Re: [RFC PATCH v3 06/10] udp: cope with UDP GRO packet misdirection Date: Wed, 31 Oct 2018 10:54:16 +0100 Message-ID: References: <0fbc6f0cea4b3a976a003a593c6365cb4e4a9e99.1540920083.git.pabeni@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Cc: "David S. Miller" , Willem de Bruijn , Steffen Klassert , Subash Abhinov Kasiviswanathan To: netdev@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:55240 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727527AbeJaSvo (ORCPT ); Wed, 31 Oct 2018 14:51:44 -0400 In-Reply-To: <0fbc6f0cea4b3a976a003a593c6365cb4e4a9e99.1540920083.git.pabeni@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 2018-10-30 at 18:24 +0100, Paolo Abeni wrote: > --- a/include/net/udp.h > +++ b/include/net/udp.h > @@ -406,17 +406,24 @@ static inline int copy_linear_skb(struct sk_buff *skb, int len, int off, > } while(0) > > #if IS_ENABLED(CONFIG_IPV6) > -#define __UDPX_INC_STATS(sk, field) \ > -do { \ > - if ((sk)->sk_family == AF_INET) \ > - __UDP_INC_STATS(sock_net(sk), field, 0); \ > - else \ > - __UDP6_INC_STATS(sock_net(sk), field, 0); \ > -} while (0) > +#define __UDPX_MIB(sk, ipv4) \ > +({ \ > + ipv4 ? (IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_statistics : \ > + sock_net(sk)->mib.udp_statistics) : \ > + (IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_stats_in6 : \ > + sock_net(sk)->mib.udp_stats_in6); \ > +}) > #else > -#define __UDPX_INC_STATS(sk, field) __UDP_INC_STATS(sock_net(sk), field, 0) > +#define __UDPX_MIB(sk, ipv4) \ > +({ \ > + IS_UDPLITE(sk) ? sock_net(sk)->mib.udplite_statistics : \ > + sock_net(sk)->mib.udp_statistics; \ > +}) > #endif > > +#define __UDPX_INC_STATS(sk, field) \ > + __SNMP_INC_STATS(__UDPX_MIB(sk, (sk)->sk_family == AF_INET, field) > + This is broken (complains only if CONFIG_AF_RXRPC is set), will fix in next iteration (thanks kbuildbot). But I'd prefer to keep the above helper: it can be used in a follow-up patch to cleanup a bit udp6_recvmsg(). > #ifdef CONFIG_PROC_FS > struct udp_seq_afinfo { > sa_family_t family; > @@ -450,4 +457,32 @@ DECLARE_STATIC_KEY_FALSE(udpv6_encap_needed_key); > void udpv6_encap_enable(void); > #endif > > +static inline struct sk_buff *udp_rcv_segment(struct sock *sk, > + struct sk_buff *skb) > +{ > + bool ipv4 = skb->protocol == htons(ETH_P_IP); And this cause a compile warning when # CONFIG_IPV6 is not set, I will fix in the next iteration (again thanks kbuildbot) Cheers, Paolo