Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1520192pxb; Sun, 22 Aug 2021 20:22:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxvldU2fhet41F8EuMS69XBEipb2e8R6z/2XdlZ4JCBhFYk5FO5g603gy+FdjFY77QuBl0F X-Received: by 2002:a17:906:2bcf:: with SMTP id n15mr33939678ejg.414.1629688940750; Sun, 22 Aug 2021 20:22:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629688940; cv=none; d=google.com; s=arc-20160816; b=vY12o8f3+fzGpGvfVqm+7xCNMx2Bg85M8JZapVvSSKADentYN/Ou0DqG/b27b1VMOE AcpktOoUkmMT8A1wF59gAEieUAyBtraQSAi7tJaRMPzidPtJRXZOAJzmkx9WWXAq0FaH it7R85Oxso34aRzTWtqmFd3xBkM6H3yUMgP11mWx0PDTHbkj3JsQC9zK4cXohHbB1aTs kC6J+NFkMx/ca1rFqyB5b5msy8c4Rfow6w2Jxd1JAYtTMFlS6t5Lh5nRAZOx9TE/0Ccn Ym2RdWmtuhEguHsfpWCURkqkv7DgPQQdmrlx4AvAtYlYtR/BcREJiSeVGjaitwgazmOw oePA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2Z1Hh5wWV41gbyuhJN3abIA+9gChn8bbFfF4TW2obKU=; b=MSjYdYYs07eU3alC2PLzb7ePPAt1tkMM6N+LjgCYr27C1uEQo4R3996jgazr4jxcrk uplzn+e7HsjdB9yVj5y/M5FpRF5nufXSNsiRKY7xb2h5hedoRF5k4cdJ7XIg+H75Pl8V N08E7ZYBpLwHdVLMRVCIL8ic/6puAxR8gtyRoLNFgfm0SfpgXVQPiASIiJ9SIUCyCOgw z3Lq938hrEbfr/J8gF3Nh13lOfgAsxYsNAXIsB0mLIRiOmVEPiw8Rywc1sXUWI0Q7yuu 8byO7oCcSHJlDGQ7fBJBVW8upuTrntTkPJ58/bAQznkqFHPeSpZpOlsMpn6UdGpBLx08 zVgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=CDdQ1JG2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b22si7579621edw.438.2021.08.22.20.21.57; Sun, 22 Aug 2021 20:22:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=CDdQ1JG2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232866AbhHWDS6 (ORCPT + 99 others); Sun, 22 Aug 2021 23:18:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232362AbhHWDS5 (ORCPT ); Sun, 22 Aug 2021 23:18:57 -0400 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E32DCC061575; Sun, 22 Aug 2021 20:18:15 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1629688693; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2Z1Hh5wWV41gbyuhJN3abIA+9gChn8bbFfF4TW2obKU=; b=CDdQ1JG2iZjwBlI4QV8BgfHbsiVrArqxODTen8H35pkiOhn+T0efcWmoCCm610gu+3toQV bwE6/sXg0+6q3TLjVZJ6+Gs+quHjXfPP+pWPyaCnQ5IzaNZNBjZx56M3FqfvMvZMfO2Gqq bo5oWNHz0v/NkdENoQoxn4hbOVTrP2Q= From: Yajun Deng To: davem@davemloft.net, yoshfuji@linux-ipv6.org, dsahern@kernel.org, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng Subject: [PATCH net-next] net: ipv4: Move ip_options_fragment() out of loop Date: Mon, 23 Aug 2021 11:17:59 +0800 Message-Id: <20210823031759.25395-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: yajun.deng@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ip_options_fragment() only called when iter->offset is equal to zero, so move it out of loop, and inline 'Copy the flags to each fragment.' As also, remove the unused parameter in ip_frag_ipcb(). Signed-off-by: Yajun Deng --- net/ipv4/ip_output.c | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 6b04a88466b2..9a8f05d5476e 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -606,18 +606,6 @@ void ip_fraglist_init(struct sk_buff *skb, struct iphdr *iph, } EXPORT_SYMBOL(ip_fraglist_init); -static void ip_fraglist_ipcb_prepare(struct sk_buff *skb, - struct ip_fraglist_iter *iter) -{ - struct sk_buff *to = iter->frag; - - /* Copy the flags to each fragment. */ - IPCB(to)->flags = IPCB(skb)->flags; - - if (iter->offset == 0) - ip_options_fragment(to); -} - void ip_fraglist_prepare(struct sk_buff *skb, struct ip_fraglist_iter *iter) { unsigned int hlen = iter->hlen; @@ -663,7 +651,7 @@ void ip_frag_init(struct sk_buff *skb, unsigned int hlen, EXPORT_SYMBOL(ip_frag_init); static void ip_frag_ipcb(struct sk_buff *from, struct sk_buff *to, - bool first_frag, struct ip_frag_state *state) + bool first_frag) { /* Copy the flags to each fragment. */ IPCB(to)->flags = IPCB(from)->flags; @@ -837,12 +825,13 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, /* Everything is OK. Generate! */ ip_fraglist_init(skb, iph, hlen, &iter); + ip_options_fragment(iter.frag); for (;;) { /* Prepare header of the next frame, * before previous one went down. */ if (iter.frag) { - ip_fraglist_ipcb_prepare(skb, &iter); + IPCB(iter.frag)->flags = IPCB(skb)->flags; ip_fraglist_prepare(skb, &iter); } @@ -897,7 +886,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb, err = PTR_ERR(skb2); goto fail; } - ip_frag_ipcb(skb, skb2, first_frag, &state); + ip_frag_ipcb(skb, skb2, first_frag); /* * Put this fragment into the sending queue. -- 2.32.0