diff mbox series

[net-next,08/10] ipv6: refactor opts push in __ip6_make_skb()

Message ID 3d72bc581954b5a9156661cf6957a72c5940a459.1651071506.git.asml.silence@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series None | expand

Commit Message

Pavel Begunkov April 28, 2022, 10:56 a.m. UTC
Don't preload v6_cork->opt before we actually need it, it likely to be
saved on the stack and read again for no good reason.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 net/ipv6/ip6_output.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Paolo Abeni April 28, 2022, 1:42 p.m. UTC | #1
On Thu, 2022-04-28 at 11:56 +0100, Pavel Begunkov wrote:
> Don't preload v6_cork->opt before we actually need it, it likely to be
> saved on the stack and read again for no good reason.
> 
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>

It looks like most part of this series has been lost ?!? only 8/10,
9/10 and 10/10 landed on the ML. Could you please double check?

Thanks

Paolo
Pavel Begunkov April 28, 2022, 1:50 p.m. UTC | #2
On 4/28/22 14:42, Paolo Abeni wrote:
> On Thu, 2022-04-28 at 11:56 +0100, Pavel Begunkov wrote:
>> Don't preload v6_cork->opt before we actually need it, it likely to be
>> saved on the stack and read again for no good reason.
>>
>> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> 
> It looks like most part of this series has been lost ?!? only 8/10,
> 9/10 and 10/10 landed on the ML. Could you please double check?

Seems I somehow sent duplicates of those and with weird numbering,
sorry for that. Let me resend the set, will tag v2 for convenience.
diff mbox series

Patch

diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 976554d0fdec..43a541bbcf5f 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1855,7 +1855,6 @@  struct sk_buff *__ip6_make_skb(struct sock *sk,
 	struct ipv6_pinfo *np = inet6_sk(sk);
 	struct net *net = sock_net(sk);
 	struct ipv6hdr *hdr;
-	struct ipv6_txoptions *opt = v6_cork->opt;
 	struct rt6_info *rt = (struct rt6_info *)cork->base.dst;
 	struct flowi6 *fl6 = &cork->fl.u.ip6;
 	unsigned char proto = fl6->flowi6_proto;
@@ -1884,10 +1883,14 @@  struct sk_buff *__ip6_make_skb(struct sock *sk,
 	__skb_pull(skb, skb_network_header_len(skb));
 
 	final_dst = &fl6->daddr;
-	if (opt && opt->opt_flen)
-		ipv6_push_frag_opts(skb, opt, &proto);
-	if (opt && opt->opt_nflen)
-		ipv6_push_nfrag_opts(skb, opt, &proto, &final_dst, &fl6->saddr);
+	if (v6_cork->opt) {
+		struct ipv6_txoptions *opt = v6_cork->opt;
+
+		if (opt->opt_flen)
+			ipv6_push_frag_opts(skb, opt, &proto);
+		if (opt->opt_nflen)
+			ipv6_push_nfrag_opts(skb, opt, &proto, &final_dst, &fl6->saddr);
+	}
 
 	skb_push(skb, sizeof(struct ipv6hdr));
 	skb_reset_network_header(skb);