* [PATCH net-next 08/10] ipv6: refactor opts push in __ip6_make_skb()
[not found] <cover.1651071506.git.asml.silence@gmail.com>
@ 2022-04-28 10:56 ` Pavel Begunkov
2022-04-28 13:42 ` Paolo Abeni
2022-04-28 10:56 ` [PATCH net-next 09/10] ipv6: improve opt-less __ip6_make_skb() Pavel Begunkov
2022-04-28 10:56 ` [PATCH net-next 10/10] ipv6: clean up ip6_setup_cork Pavel Begunkov
2 siblings, 1 reply; 5+ messages in thread
From: Pavel Begunkov @ 2022-04-28 10:56 UTC (permalink / raw)
To: netdev, David S . Miller, Jakub Kicinski
Cc: David Ahern, Eric Dumazet, linux-kernel, Pavel Begunkov
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(-)
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);
--
2.36.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 09/10] ipv6: improve opt-less __ip6_make_skb()
[not found] <cover.1651071506.git.asml.silence@gmail.com>
2022-04-28 10:56 ` [PATCH net-next 08/10] ipv6: refactor opts push in __ip6_make_skb() Pavel Begunkov
@ 2022-04-28 10:56 ` Pavel Begunkov
2022-04-28 10:56 ` [PATCH net-next 10/10] ipv6: clean up ip6_setup_cork Pavel Begunkov
2 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-04-28 10:56 UTC (permalink / raw)
To: netdev, David S . Miller, Jakub Kicinski
Cc: David Ahern, Eric Dumazet, linux-kernel, Pavel Begunkov
We do a bit of a network header pointer shuffling in __ip6_make_skb()
expecting that ipv6_push_*frag_opts() might change the layout. Avoid it
with associated overhead when there are no opts.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
net/ipv6/ip6_output.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 43a541bbcf5f..416d14299242 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1880,22 +1880,20 @@ struct sk_buff *__ip6_make_skb(struct sock *sk,
/* Allow local fragmentation. */
skb->ignore_df = ip6_sk_ignore_df(sk);
- __skb_pull(skb, skb_network_header_len(skb));
-
final_dst = &fl6->daddr;
if (v6_cork->opt) {
struct ipv6_txoptions *opt = v6_cork->opt;
+ __skb_pull(skb, skb_network_header_len(skb));
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);
}
- skb_push(skb, sizeof(struct ipv6hdr));
- skb_reset_network_header(skb);
hdr = ipv6_hdr(skb);
-
ip6_flow_hdr(hdr, v6_cork->tclass,
ip6_make_flowlabel(net, skb, fl6->flowlabel,
ip6_autoflowlabel(net, np), fl6));
--
2.36.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next 10/10] ipv6: clean up ip6_setup_cork
[not found] <cover.1651071506.git.asml.silence@gmail.com>
2022-04-28 10:56 ` [PATCH net-next 08/10] ipv6: refactor opts push in __ip6_make_skb() Pavel Begunkov
2022-04-28 10:56 ` [PATCH net-next 09/10] ipv6: improve opt-less __ip6_make_skb() Pavel Begunkov
@ 2022-04-28 10:56 ` Pavel Begunkov
2 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-04-28 10:56 UTC (permalink / raw)
To: netdev, David S . Miller, Jakub Kicinski
Cc: David Ahern, Eric Dumazet, linux-kernel, Pavel Begunkov
Do a bit of refactoring for ip6_setup_cork(). Cache a xfrm_dst_path()
result to not call it twice, reshuffle ifs to not repeat some parts
twice and so.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
net/ipv6/ip6_output.c | 30 +++++++++++++-----------------
1 file changed, 13 insertions(+), 17 deletions(-)
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 416d14299242..a17b26d5f34d 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1358,15 +1358,13 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
struct ipv6_pinfo *np = inet6_sk(sk);
unsigned int mtu;
struct ipv6_txoptions *nopt, *opt = ipc6->opt;
+ struct dst_entry *xrfm_dst;
/* callers pass dst together with a reference, set it first so
* ip6_cork_release() can put it down even in case of an error.
*/
cork->base.dst = &rt->dst;
- /*
- * setup for corking
- */
if (opt) {
if (WARN_ON(v6_cork->opt))
return -EINVAL;
@@ -1399,28 +1397,26 @@ static int ip6_setup_cork(struct sock *sk, struct inet_cork_full *cork,
}
v6_cork->hop_limit = ipc6->hlimit;
v6_cork->tclass = ipc6->tclass;
- if (rt->dst.flags & DST_XFRM_TUNNEL)
- mtu = np->pmtudisc >= IPV6_PMTUDISC_PROBE ?
- READ_ONCE(rt->dst.dev->mtu) : dst_mtu(&rt->dst);
+
+ xrfm_dst = xfrm_dst_path(&rt->dst);
+ if (dst_allfrag(xrfm_dst))
+ cork->base.flags |= IPCORK_ALLFRAG;
+
+ if (np->pmtudisc < IPV6_PMTUDISC_PROBE)
+ mtu = dst_mtu(rt->dst.flags & DST_XFRM_TUNNEL ? &rt->dst : xrfm_dst);
else
- mtu = np->pmtudisc >= IPV6_PMTUDISC_PROBE ?
- READ_ONCE(rt->dst.dev->mtu) : dst_mtu(xfrm_dst_path(&rt->dst));
- if (np->frag_size < mtu) {
- if (np->frag_size)
- mtu = np->frag_size;
- }
+ mtu = READ_ONCE(rt->dst.dev->mtu);
+
+ if (np->frag_size < mtu && np->frag_size)
+ mtu = np->frag_size;
+
cork->base.fragsize = mtu;
cork->base.gso_size = ipc6->gso_size;
cork->base.tx_flags = 0;
cork->base.mark = ipc6->sockc.mark;
sock_tx_timestamp(sk, ipc6->sockc.tsflags, &cork->base.tx_flags);
-
- if (dst_allfrag(xfrm_dst_path(&rt->dst)))
- cork->base.flags |= IPCORK_ALLFRAG;
cork->base.length = 0;
-
cork->base.transmit_time = ipc6->sockc.transmit_time;
-
return 0;
}
--
2.36.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 08/10] ipv6: refactor opts push in __ip6_make_skb()
2022-04-28 10:56 ` [PATCH net-next 08/10] ipv6: refactor opts push in __ip6_make_skb() Pavel Begunkov
@ 2022-04-28 13:42 ` Paolo Abeni
2022-04-28 13:50 ` Pavel Begunkov
0 siblings, 1 reply; 5+ messages in thread
From: Paolo Abeni @ 2022-04-28 13:42 UTC (permalink / raw)
To: Pavel Begunkov, netdev, David S . Miller, Jakub Kicinski
Cc: David Ahern, Eric Dumazet, linux-kernel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next 08/10] ipv6: refactor opts push in __ip6_make_skb()
2022-04-28 13:42 ` Paolo Abeni
@ 2022-04-28 13:50 ` Pavel Begunkov
0 siblings, 0 replies; 5+ messages in thread
From: Pavel Begunkov @ 2022-04-28 13:50 UTC (permalink / raw)
To: Paolo Abeni, netdev, David S . Miller, Jakub Kicinski
Cc: David Ahern, Eric Dumazet, linux-kernel
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.
--
Pavel Begunkov
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-28 13:51 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <cover.1651071506.git.asml.silence@gmail.com>
2022-04-28 10:56 ` [PATCH net-next 08/10] ipv6: refactor opts push in __ip6_make_skb() Pavel Begunkov
2022-04-28 13:42 ` Paolo Abeni
2022-04-28 13:50 ` Pavel Begunkov
2022-04-28 10:56 ` [PATCH net-next 09/10] ipv6: improve opt-less __ip6_make_skb() Pavel Begunkov
2022-04-28 10:56 ` [PATCH net-next 10/10] ipv6: clean up ip6_setup_cork Pavel Begunkov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.