From patchwork Mon Jan 13 23:42:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 1222386 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zx2c4.com header.i=@zx2c4.com header.a=rsa-sha1 header.s=mail header.b=3LkTUaiy; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47xVWc5SHgz9sNx for ; Tue, 14 Jan 2020 10:42:52 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729031AbgAMXmw (ORCPT ); Mon, 13 Jan 2020 18:42:52 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:55677 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727382AbgAMXmv (ORCPT ); Mon, 13 Jan 2020 18:42:51 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id b87a15e6; Mon, 13 Jan 2020 22:42:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=yFTEYuAAUFsA3SagGCmWoojHL KY=; b=3LkTUaiy1c1c1A2NnOTRthpnHw+VaXxjPgbX8i7ESFlbyVcrYVTHaEfB1 UmvAAkPa5Ma88WTOb409EOciJW9E8F3Lt9PLtKlYmIMNluOvtlameM61uju6uEl8 vBUn45M3/Uy2X4c4+AHatSms293Bx/t0ikfm66YZOsHCetHbcaNwy3kSwlU1Oflw Mi3lcITXslF9PCNe9QiO/7DH8y8ICcsr0lXid/vDbzJq1q1mSV0RA1UvjKJosa3U 4js4iJEsbT47SyRg1wS+32voNMrmFT3Z+iTJJU2g9Zy4Dk5VbHA0H7+yTZLRyQRK qWr8tBg2FdkV6/Y2DXaUuEP6H9GCA== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id d8bf47ce (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 13 Jan 2020 22:42:50 +0000 (UTC) From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes@sipsolutions.net, netdev@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH net-next 1/8] net: skbuff: disambiguate argument and member for skb_list_walk_safe helper Date: Mon, 13 Jan 2020 18:42:26 -0500 Message-Id: <20200113234233.33886-2-Jason@zx2c4.com> In-Reply-To: <20200113234233.33886-1-Jason@zx2c4.com> References: <20200113234233.33886-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This worked before, because we made all callers name their next pointer "next". But in trying to be more "drop-in" ready, the silliness here is revealed. This commit fixes the problem by making the macro argument and the member use different names. Signed-off-by: Jason A. Donenfeld --- include/linux/skbuff.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 016b3c4ab99a..aaf73b34f72f 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1479,9 +1479,9 @@ static inline void skb_mark_not_on_list(struct sk_buff *skb) } /* Iterate through singly-linked GSO fragments of an skb. */ -#define skb_list_walk_safe(first, skb, next) \ - for ((skb) = (first), (next) = (skb) ? (skb)->next : NULL; (skb); \ - (skb) = (next), (next) = (skb) ? (skb)->next : NULL) +#define skb_list_walk_safe(first, skb, next_skb) \ + for ((skb) = (first), (next_skb) = (skb) ? (skb)->next : NULL; (skb); \ + (skb) = (next_skb), (next_skb) = (skb) ? (skb)->next : NULL) static inline void skb_list_del_init(struct sk_buff *skb) { From patchwork Mon Jan 13 23:42:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 1222387 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zx2c4.com header.i=@zx2c4.com header.a=rsa-sha1 header.s=mail header.b=nli/K1um; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47xVWd1dhSz9sP3 for ; Tue, 14 Jan 2020 10:42:53 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729083AbgAMXmw (ORCPT ); Mon, 13 Jan 2020 18:42:52 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:55677 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728794AbgAMXmw (ORCPT ); Mon, 13 Jan 2020 18:42:52 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 4baae44e; Mon, 13 Jan 2020 22:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=EhwLIUjBjeBtpZCJnF1+3OnHk 5M=; b=nli/K1ummPBJq/sbGgAd2bXjGAx4/JxlzIvKgFb9jHkDwtE9hLDYaL4ew hA+2whDyH6Ntqo9/bfxcyiMFb31IqZFUDAOIz20rjbeLLKfdDIvKq5GXhI7DafGh sUcsGWPIU3KqRDhtyU6aKQV8nlakOCacSnIkd7CsSMphdLR/kkVBR2nfEVz3FHWY FVCm8plAt4X3UqIeAfSJNwjWLvsP69KGvVcXxrbWH11Wp6xOvT0IpC0gCUWbXZwA Tx6UZKFiSZdvtlCpbEERsnhm8xn7jLnsjJte6xJXkI549ZjULETD+EYuK+X9iGU4 +VnG56FEECG/uXP/8KhXL0hEUUxWQ== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id c91f5f4e (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 13 Jan 2020 22:42:52 +0000 (UTC) From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes@sipsolutions.net, netdev@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH net-next 2/8] net: udp: use skb_list_walk_safe helper for gso segments Date: Mon, 13 Jan 2020 18:42:27 -0500 Message-Id: <20200113234233.33886-3-Jason@zx2c4.com> In-Reply-To: <20200113234233.33886-1-Jason@zx2c4.com> References: <20200113234233.33886-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a straight-forward conversion case for the new function, iterating over the return value from udp_rcv_segment, which actually is a wrapper around skb_gso_segment. Signed-off-by: Jason A. Donenfeld --- net/ipv4/udp.c | 3 +-- net/ipv6/udp.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 93a355b6b092..208da0917469 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -2104,8 +2104,7 @@ static int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) BUILD_BUG_ON(sizeof(struct udp_skb_cb) > SKB_SGO_CB_OFFSET); __skb_push(skb, -skb_mac_offset(skb)); segs = udp_rcv_segment(sk, skb, true); - for (skb = segs; skb; skb = next) { - next = skb->next; + skb_list_walk_safe(segs, skb, next) { __skb_pull(skb, skb_transport_offset(skb)); ret = udp_queue_rcv_one_skb(sk, skb); if (ret > 0) diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 9fec580c968e..5dc439a391fe 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c @@ -690,8 +690,7 @@ static int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) __skb_push(skb, -skb_mac_offset(skb)); segs = udp_rcv_segment(sk, skb, false); - for (skb = segs; skb; skb = next) { - next = skb->next; + skb_list_walk_safe(segs, skb, next) { __skb_pull(skb, skb_transport_offset(skb)); ret = udpv6_queue_rcv_one_skb(sk, skb); From patchwork Mon Jan 13 23:42:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 1222388 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zx2c4.com header.i=@zx2c4.com header.a=rsa-sha1 header.s=mail header.b=IOvlLoQa; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47xVWh2qLKz9sNx for ; Tue, 14 Jan 2020 10:42:56 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729141AbgAMXmz (ORCPT ); Mon, 13 Jan 2020 18:42:55 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:55677 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728794AbgAMXmz (ORCPT ); Mon, 13 Jan 2020 18:42:55 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id d7112655; Mon, 13 Jan 2020 22:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=vF/SpMgpzCZ3bXnbdrKZDuJPd Io=; b=IOvlLoQaoIQY2bYbNq19qRyyCVJB2h+6QzN0LfyAg2ZX5Ht/DzQKBS9Mq ppzeHBhgp684Fdceunus+fS763L+vKhOhMcdLDNIAaSaMn2Dy9gY777GLMzIleL8 dS0Jszwj8UD2s54eyfkmxaW41k32gIzxXEq8r8fSOIF0gvqCMcWkvWdW9CHELqQz k7dS/O7MmS1W8VYFtyVVKXiH+s08j4RG2Kz9EIDqzAGNMvsMUHVyY2FifyE0lz2I oUNynSGg1g8VNvXGvbD66sqxIdOcqUY4KSEuBSJemPhR3TNOtsg+0cx8NPKSFlKN uB/jGeS1xWah4U4fqhsFr1nlnuayQ== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 5b9d984c (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 13 Jan 2020 22:42:53 +0000 (UTC) From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes@sipsolutions.net, netdev@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH net-next 3/8] net: xfrm: use skb_list_walk_safe helper for gso segments Date: Mon, 13 Jan 2020 18:42:28 -0500 Message-Id: <20200113234233.33886-4-Jason@zx2c4.com> In-Reply-To: <20200113234233.33886-1-Jason@zx2c4.com> References: <20200113234233.33886-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is converts xfrm segment iteration to use the new function, keeping the flow of the existing code as intact as possible. One case is very straight-forward, whereas the other case has some more subtle code that likes to peak at ->next and relink skbs. By keeping the variables the same as before, we can upgrade this code with minimal surgery required. Signed-off-by: Jason A. Donenfeld --- net/xfrm/xfrm_device.c | 15 ++++----------- net/xfrm/xfrm_output.c | 9 +++------ 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c index 189ef15acbbc..50f567a88f45 100644 --- a/net/xfrm/xfrm_device.c +++ b/net/xfrm/xfrm_device.c @@ -78,7 +78,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur int err; unsigned long flags; struct xfrm_state *x; - struct sk_buff *skb2; + struct sk_buff *skb2, *nskb; struct softnet_data *sd; netdev_features_t esp_features = features; struct xfrm_offload *xo = xfrm_offload(skb); @@ -148,11 +148,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur return skb; } - skb2 = skb; - - do { - struct sk_buff *nskb = skb2->next; - + skb_list_walk_safe(skb, skb2, nskb) { esp_features |= skb->dev->gso_partial_features; skb_mark_not_on_list(skb2); @@ -176,14 +172,11 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur if (!skb) return NULL; - goto skip_push; + continue; } skb_push(skb2, skb2->data - skb_mac_header(skb2)); - -skip_push: - skb2 = nskb; - } while (skb2); + } return skb; } diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index b1db55b50ba1..fafc7aba705f 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c @@ -533,7 +533,7 @@ static int xfrm_output2(struct net *net, struct sock *sk, struct sk_buff *skb) static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb) { - struct sk_buff *segs; + struct sk_buff *segs, *nskb; BUILD_BUG_ON(sizeof(*IPCB(skb)) > SKB_SGO_CB_OFFSET); BUILD_BUG_ON(sizeof(*IP6CB(skb)) > SKB_SGO_CB_OFFSET); @@ -544,8 +544,7 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb if (segs == NULL) return -EINVAL; - do { - struct sk_buff *nskb = segs->next; + skb_list_walk_safe(segs, segs, nskb) { int err; skb_mark_not_on_list(segs); @@ -555,9 +554,7 @@ static int xfrm_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb kfree_skb_list(nskb); return err; } - - segs = nskb; - } while (segs); + } return 0; } From patchwork Mon Jan 13 23:42:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 1222389 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zx2c4.com header.i=@zx2c4.com header.a=rsa-sha1 header.s=mail header.b=oRE+Emwa; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47xVWk1Ksnz9sNx for ; Tue, 14 Jan 2020 10:42:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729210AbgAMXm5 (ORCPT ); Mon, 13 Jan 2020 18:42:57 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:55677 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729088AbgAMXmz (ORCPT ); Mon, 13 Jan 2020 18:42:55 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id a2974b3b; Mon, 13 Jan 2020 22:42:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=ZqXj0juaBipmcsv7BSxQNxYO0 90=; b=oRE+EmwaN6ITMVkleZVKa22w4lLN0TxmqO23ZF7yQYnSkjqnWKTFR1jn6 clyZ+97s82yGyzEZMefvXls4boNrlxvXHVVY7kGnw1dhApZ31/7K/v16KIaia8hx qJuDNnfEBy2ba76SeKBJkUChTmw89dj212Lm6r1iPItx7/D64Z311HMN8rjbnWFv mnfA1DBgN7Zc4sI9mc7yXYS1DvIxAEOOzFAn9WHMBD+05SVx2eecVXdgwMQNFA1M AQgIAQMEPTCOhYkGyAt2+Bch5awrTYz0XFvyABBqhf1MoN10STDPOF2WDL8COHVE r2auSK28JfRJbKLRvpmBDobf4mt8g== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 8f823dd8 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 13 Jan 2020 22:42:55 +0000 (UTC) From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes@sipsolutions.net, netdev@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH net-next 4/8] net: openvswitch: use skb_list_walk_safe helper for gso segments Date: Mon, 13 Jan 2020 18:42:29 -0500 Message-Id: <20200113234233.33886-5-Jason@zx2c4.com> In-Reply-To: <20200113234233.33886-1-Jason@zx2c4.com> References: <20200113234233.33886-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a straight-forward conversion case for the new function, keeping the flow of the existing code as intact as possible. Signed-off-by: Jason A. Donenfeld --- net/openvswitch/datapath.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index e3a37d22539c..659c2a790fe7 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c @@ -321,8 +321,7 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, } /* Queue all of the segments. */ - skb = segs; - do { + skb_list_walk_safe(segs, skb, nskb) { if (gso_type & SKB_GSO_UDP && skb != segs) key = &later_key; @@ -330,17 +329,15 @@ static int queue_gso_packets(struct datapath *dp, struct sk_buff *skb, if (err) break; - } while ((skb = skb->next)); + } /* Free all of the segments. */ - skb = segs; - do { - nskb = skb->next; + skb_list_walk_safe(segs, skb, nskb) { if (err) kfree_skb(skb); else consume_skb(skb); - } while ((skb = nskb)); + } return err; } From patchwork Mon Jan 13 23:42:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 1222390 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zx2c4.com header.i=@zx2c4.com header.a=rsa-sha1 header.s=mail header.b=OZxdqHiJ; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47xVWm6lMjz9sNx for ; Tue, 14 Jan 2020 10:43:00 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729239AbgAMXnA (ORCPT ); Mon, 13 Jan 2020 18:43:00 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:55677 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728794AbgAMXm4 (ORCPT ); Mon, 13 Jan 2020 18:42:56 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 795d2bec; Mon, 13 Jan 2020 22:42:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=lpYQ8mRTKKl00+oMm1LKTn2+b 2U=; b=OZxdqHiJTVgxLo6ec8KH7Kc1HC0A5DsFdISCvHXFEFl1NyFhXP1t0qLgj ylpJo0VgbCJ0MPaA/VwHOK6ci34OvKdQFi3N1wFHSiqPGtt7qT/2X9Zbd4jagycl aaRPzzUbO26ymZ4jvy2sbsZpj58wn9gEx+nGNxRm/K78asu/7m58BVd0+BsJi/6g 7n0GaOjEf7OfgW6LiopWXu5ZBr8HPkM8k8mZ4Lki4EVJc6BXddrgCGcIx1buD4Hc XrU9E7drtaYdx9UCSQBpxKTiqG/SSsS6Ip6RJrj6gNDb5hBJDWTeEt5C2z4Hwo5y j4kWhOVlOjqqDbLBSbJEkLjsmfbWA== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 9f5ad967 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 13 Jan 2020 22:42:56 +0000 (UTC) From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes@sipsolutions.net, netdev@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH net-next 5/8] net: sched: use skb_list_walk_safe helper for gso segments Date: Mon, 13 Jan 2020 18:42:30 -0500 Message-Id: <20200113234233.33886-6-Jason@zx2c4.com> In-Reply-To: <20200113234233.33886-1-Jason@zx2c4.com> References: <20200113234233.33886-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a straight-forward conversion case for the new function, keeping the flow of the existing code as intact as possible. Signed-off-by: Jason A. Donenfeld --- net/sched/sch_cake.c | 4 +--- net/sched/sch_tbf.c | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c index 90ef7cc79b69..1496e87cd07b 100644 --- a/net/sched/sch_cake.c +++ b/net/sched/sch_cake.c @@ -1682,8 +1682,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch, if (IS_ERR_OR_NULL(segs)) return qdisc_drop(skb, sch, to_free); - while (segs) { - nskb = segs->next; + skb_list_walk_safe(segs, segs, nskb) { skb_mark_not_on_list(segs); qdisc_skb_cb(segs)->pkt_len = segs->len; cobalt_set_enqueue_time(segs, now); @@ -1696,7 +1695,6 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch, slen += segs->len; q->buffer_used += segs->truesize; b->packets++; - segs = nskb; } /* stats */ diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index 5f72f3f916a5..2cd94973795c 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c @@ -155,8 +155,7 @@ static int tbf_segment(struct sk_buff *skb, struct Qdisc *sch, return qdisc_drop(skb, sch, to_free); nb = 0; - while (segs) { - nskb = segs->next; + skb_list_walk_safe(segs, segs, nskb) { skb_mark_not_on_list(segs); qdisc_skb_cb(segs)->pkt_len = segs->len; len += segs->len; @@ -167,7 +166,6 @@ static int tbf_segment(struct sk_buff *skb, struct Qdisc *sch, } else { nb++; } - segs = nskb; } sch->q.qlen += nb; if (nb > 1) From patchwork Mon Jan 13 23:42:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 1222391 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zx2c4.com header.i=@zx2c4.com header.a=rsa-sha1 header.s=mail header.b=nBMEj4EK; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47xVWq4K2pz9sNx for ; Tue, 14 Jan 2020 10:43:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729255AbgAMXnC (ORCPT ); Mon, 13 Jan 2020 18:43:02 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:55677 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729211AbgAMXm6 (ORCPT ); Mon, 13 Jan 2020 18:42:58 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id d929d7a2; Mon, 13 Jan 2020 22:42:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=0gEIfT81wd3jBIyRff7NNLZ/X d4=; b=nBMEj4EK0pfMGzn0NQVsnr1/oct2+x18C2VKlFh1PKEu4vH3quUJO2Jp9 nzdLxvPZ6aIY6yubJIMPl8GVT3YFJMo2e4Zf0ERdw29iilNSaP+xQQ/x6sUfwH6g PEQv0/mBNZpodW7SCwOVnBU5EuGuYEXhFYOediA4DUI9/OoCgpojWDQtT5Div/Or 9WlwseKbTwDBFEQRfkIJCTx0QQF3Up0Qz4WeiOtzoKMHECNtlOdNBFGvM8fZxByO BFVE8K2mxZ7Ezor4kZrn4VG0K78L1r3RBxvZ5dW/OiuI2B9xzm0kZZCwAwetlWSi kv66TKBYY46QC7XcovE5ZWrpe5zxQ== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 199c41b3 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 13 Jan 2020 22:42:57 +0000 (UTC) From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes@sipsolutions.net, netdev@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH net-next 6/8] net: ipv4: use skb_list_walk_safe helper for gso segments Date: Mon, 13 Jan 2020 18:42:31 -0500 Message-Id: <20200113234233.33886-7-Jason@zx2c4.com> In-Reply-To: <20200113234233.33886-1-Jason@zx2c4.com> References: <20200113234233.33886-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a straight-forward conversion case for the new function, keeping the flow of the existing code as intact as possible. Signed-off-by: Jason A. Donenfeld --- net/ipv4/ip_output.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 14db1e0b8a6e..d84819893db9 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -240,8 +240,8 @@ static int ip_finish_output2(struct net *net, struct sock *sk, struct sk_buff *s static int ip_finish_output_gso(struct net *net, struct sock *sk, struct sk_buff *skb, unsigned int mtu) { + struct sk_buff *segs, *nskb; netdev_features_t features; - struct sk_buff *segs; int ret = 0; /* common case: seglen is <= mtu @@ -272,8 +272,7 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk, consume_skb(skb); - do { - struct sk_buff *nskb = segs->next; + skb_list_walk_safe(segs, segs, nskb) { int err; skb_mark_not_on_list(segs); @@ -281,8 +280,7 @@ static int ip_finish_output_gso(struct net *net, struct sock *sk, if (err && ret == 0) ret = err; - segs = nskb; - } while (segs); + } return ret; } From patchwork Mon Jan 13 23:42:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 1222392 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zx2c4.com header.i=@zx2c4.com header.a=rsa-sha1 header.s=mail header.b=ko0kmr7Q; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47xVWr3D32z9sP3 for ; Tue, 14 Jan 2020 10:43:04 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729248AbgAMXnC (ORCPT ); Mon, 13 Jan 2020 18:43:02 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:55249 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729236AbgAMXnA (ORCPT ); Mon, 13 Jan 2020 18:43:00 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id f3c65720; Mon, 13 Jan 2020 22:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=dV/9ypqPU0loa5AZnhX0lQcT2 OY=; b=ko0kmr7QFv4tP6TDHFbziU4Rkng32He06KpzSxDUNXPgDCxHEUgw3vvvm EjhHFfRcaQJUtw7Vm1nP+cqz0Kyjdt/ehAab9k2BJDzeknMD6OYLW71q8QYU2fL/ jqlwjJJCumitaSqZJaIPs6+xEvpDH5jht32tq4tDB3JtTVj4TcEYi6fdMQ5RMPMs eCkstjXsVZI0EpKUX597/JM7dwegmVM9AoaOyQgf+5AOu3K7CGuUkfHYf5E1DLru KFl1y0Ul2QfPPlDYp+bOuHbUz5lGgzNsBpicYHKSNilLdNISMhgR7nqJKF52PqpV 8hHpDB54nEasmsAT8bD/rDHRFQPwA== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id e38220c5 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 13 Jan 2020 22:42:58 +0000 (UTC) From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes@sipsolutions.net, netdev@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH net-next 7/8] net: netfilter: use skb_list_walk_safe helper for gso segments Date: Mon, 13 Jan 2020 18:42:32 -0500 Message-Id: <20200113234233.33886-8-Jason@zx2c4.com> In-Reply-To: <20200113234233.33886-1-Jason@zx2c4.com> References: <20200113234233.33886-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a straight-forward conversion case for the new function, keeping the flow of the existing code as intact as possible. Signed-off-by: Jason A. Donenfeld --- net/netfilter/nfnetlink_queue.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index feabdfb22920..76535fd9278c 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c @@ -778,7 +778,7 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum) { unsigned int queued; struct nfqnl_instance *queue; - struct sk_buff *skb, *segs; + struct sk_buff *skb, *segs, *nskb; int err = -ENOBUFS; struct net *net = entry->state.net; struct nfnl_queue_net *q = nfnl_queue_pernet(net); @@ -815,8 +815,7 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum) goto out_err; queued = 0; err = 0; - do { - struct sk_buff *nskb = segs->next; + skb_list_walk_safe(segs, segs, nskb) { if (err == 0) err = __nfqnl_enqueue_packet_gso(net, queue, segs, entry); @@ -824,8 +823,7 @@ nfqnl_enqueue_packet(struct nf_queue_entry *entry, unsigned int queuenum) queued++; else kfree_skb(segs); - segs = nskb; - } while (segs); + } if (queued) { if (err) /* some segments are already queued */ From patchwork Mon Jan 13 23:42:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason A. Donenfeld" X-Patchwork-Id: 1222393 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=zx2c4.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=zx2c4.com header.i=@zx2c4.com header.a=rsa-sha1 header.s=mail header.b=1gUoaCqf; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 47xVWt70vnz9sNx for ; Tue, 14 Jan 2020 10:43:06 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729268AbgAMXnF (ORCPT ); Mon, 13 Jan 2020 18:43:05 -0500 Received: from frisell.zx2c4.com ([192.95.5.64]:55249 "EHLO frisell.zx2c4.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728794AbgAMXnB (ORCPT ); Mon, 13 Jan 2020 18:43:01 -0500 Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTP id 07fa34b0; Mon, 13 Jan 2020 22:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=zx2c4.com; h=from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; s=mail; bh=tVnUNJOazYgFVI3CzDvPdFfXT 4k=; b=1gUoaCqfSH21UP/T8H/kYla/uDGgR0lTivlFsn7eMNDOckIQ5N/kap+uL zAY/pw3ciwvkWMRssvpm3vXbFhQXTpaRleyAVVmiTccPiBM4aY/WCXvqBhIACqfi MRpmnObjEAMFqdjr6hl/bzfjCfmmDrQ1xAlPLo1dXTFG0bfjcYi+frldDIwMqhom NJ7ztHliOu1COE6M5VW3dSGu2TL2/FaiofXAffw8FCfSNNq/94fgDmWGqR8+2fA7 PrZen+s7WI2Kj9VV2mrIEL7JHnwKweeQxnfYPoL4L62+E4m4LFmM5UbICf2bj3vc CfkIr9nFBDXdzci2X2PWJm4Ouc0qg== Received: by frisell.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id d65a9e72 (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256:NO); Mon, 13 Jan 2020 22:43:00 +0000 (UTC) From: "Jason A. Donenfeld" To: davem@davemloft.net, johannes@sipsolutions.net, netdev@vger.kernel.org Cc: "Jason A. Donenfeld" Subject: [PATCH net-next 8/8] net: mac80211: use skb_list_walk_safe helper for gso segments Date: Mon, 13 Jan 2020 18:42:33 -0500 Message-Id: <20200113234233.33886-9-Jason@zx2c4.com> In-Reply-To: <20200113234233.33886-1-Jason@zx2c4.com> References: <20200113234233.33886-1-Jason@zx2c4.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is a conversion case for the new function, keeping the flow of the existing code as intact as possible. We also switch over to using skb_mark_not_on_list instead of a null write to skb->next. Finally, this code appeared to have a memory leak in the case where header building fails before the last gso segment. In that case, the remaining segments are not freed. So this commit also adds the proper kfree_skb_list call for the remainder of the skbs. Signed-off-by: Jason A. Donenfeld --- net/mac80211/tx.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index a8a7306a1f56..4bd1faf4f779 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c @@ -3949,18 +3949,15 @@ void __ieee80211_subif_start_xmit(struct sk_buff *skb, } } - next = skb; - while (next) { - skb = next; - next = skb->next; - - skb->prev = NULL; - skb->next = NULL; + skb_list_walk_safe(skb, skb, next) { + skb_mark_not_on_list(skb); skb = ieee80211_build_hdr(sdata, skb, info_flags, sta, ctrl_flags); - if (IS_ERR(skb)) + if (IS_ERR(skb)) { + kfree_skb_list(next); goto out; + } ieee80211_tx_stats(dev, skb->len);