[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <e01a463b-c52c-4f8a-9477-fd413286e41a@gmail.com>
Date: Mon, 18 Aug 2025 13:22:42 +0200
From: Richard Gobert <richardbgobert@...il.com>
To: Felix Fietkau <nbd@....name>, netdev@...r.kernel.org,
Michal Ostrowski <mostrows@...thlink.net>,
Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller"
<davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
David Ahern <dsahern@...nel.org>, Simon Horman <horms@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next v3] net: pppoe: implement GRO/GSO support
Felix Fietkau wrote:
> On 14.08.25 16:30, Richard Gobert wrote:
>> Felix Fietkau wrote:
>>> Only handles packets where the pppoe header length field matches the exact
>>> packet length. Significantly improves rx throughput.
>>>
>>> When running NAT traffic through a MediaTek MT7621 devices from a host
>>> behind PPPoE to a host directly connected via ethernet, the TCP throughput
>>> that the device is able to handle improves from ~130 Mbit/s to ~630 Mbit/s,
>>> using fraglist GRO.
>>>
>>> Signed-off-by: Felix Fietkau <nbd@....name>
>>> ---
>>> v2: fix compile error
>>> v3:
>>> - increase priority value
>>> - implement GSO support
>>> - use INDIRECT_CALL_INET
>>> - update pppoe length field
>>> - remove unnecessary network_offsets update
>>>
>>> drivers/net/ppp/pppoe.c | 160 +++++++++++++++++++++++++++++++++++++++-
>>> net/ipv4/af_inet.c | 2 +
>>> net/ipv6/ip6_offload.c | 2 +
>>> 3 files changed, 163 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c
>>> index 410effa42ade..a8d8eb870bce 100644
>>> --- a/drivers/net/ppp/pppoe.c
>>> +++ b/drivers/net/ppp/pppoe.c
>>> +compare_pppoe_header(struct pppoe_hdr *phdr, struct pppoe_hdr *phdr2)
>>> +{
>>> + return (__force __u16)((phdr->sid ^ phdr2->sid) |
>>> + (phdr->tag[0].tag_type ^ phdr2->tag[0].tag_type));
>>> +}
>>> +
>>> +static __be16 pppoe_hdr_proto(struct pppoe_hdr *phdr)
>>> +{
>>> + switch (phdr->tag[0].tag_type) {
>>> + case cpu_to_be16(PPP_IP):
>>> + return cpu_to_be16(ETH_P_IP);
>>> + case cpu_to_be16(PPP_IPV6):
>>> + return cpu_to_be16(ETH_P_IPV6);
>>> + default:
>>> + return 0;
>>> + }
>>> +
>>> +}
>>> +
>>> +static struct sk_buff *pppoe_gro_receive(struct list_head *head,
>>> + struct sk_buff *skb)
>>> +{
>>> + const struct packet_offload *ptype;
>>> + unsigned int hlen, off_pppoe;
>>> + struct sk_buff *pp = NULL;
>>> + struct pppoe_hdr *phdr;
>>> + struct sk_buff *p;
>>> + int flush = 1;
>>> + __be16 type;
>>> +
>>> + off_pppoe = skb_gro_offset(skb);
>>> + hlen = off_pppoe + sizeof(*phdr);
>>> + phdr = skb_gro_header(skb, hlen + 2, off_pppoe);
>>> + if (unlikely(!phdr))
>>> + goto out;
>>> +
>>> + /* ignore packets with padding or invalid length */
>>> + if (skb_gro_len(skb) != be16_to_cpu(phdr->length) + hlen)
>>> + goto out;
>>> +
>>> + type = pppoe_hdr_proto(phdr);
>>> + if (!type)
>>> + goto out;
>>> +
>>> + ptype = gro_find_receive_by_type(type);
>>> + if (!ptype)
>>> + goto out;
>>> +
>>> + flush = 0;
>>> +
>>> + list_for_each_entry(p, head, list) {
>>> + struct pppoe_hdr *phdr2;
>>> +
>>> + if (!NAPI_GRO_CB(p)->same_flow)
>>> + continue;
>>> +
>>> + phdr2 = (struct pppoe_hdr *)(p->data + off_pppoe);
>>> + if (compare_pppoe_header(phdr, phdr2))
>>> + NAPI_GRO_CB(p)->same_flow = 0;
>>> + }
>>> +
>>> + skb_gro_pull(skb, sizeof(*phdr) + 2);
>>> + skb_gro_postpull_rcsum(skb, phdr, sizeof(*phdr) + 2);
>>> +
>>> + pp = indirect_call_gro_receive_inet(ptype->callbacks.gro_receive,
>>> + ipv6_gro_receive, inet_gro_receive,
>>> + head, skb);
>>> +
>>> +out:
>>> + skb_gro_flush_final(skb, pp, flush);
>>> +
>>> + return pp;
>>> +}
>>> +
>>> +static int pppoe_gro_complete(struct sk_buff *skb, int nhoff)
>>> +{
>>> + struct pppoe_hdr *phdr = (struct pppoe_hdr *)(skb->data + nhoff);
>>> + __be16 type = pppoe_hdr_proto(phdr);
>>> + struct packet_offload *ptype;
>>> + int len, err;
>>> +
>>> + ptype = gro_find_complete_by_type(type);
>>> + if (!ptype)
>>> + return -ENOENT;
>>> +
>>> + err = INDIRECT_CALL_INET(ptype->callbacks.gro_complete,
>>> + ipv6_gro_complete, inet_gro_complete,
>>> + skb, nhoff + sizeof(*phdr) + 2);
>>> + if (err)
>>> + return err;
>>> +
>>> + len = skb->len - (nhoff + sizeof(*phdr));
>>> + phdr->length = cpu_to_be16(len);
>>> +
>>> + return 0;
>>> +}
>>> +
>>> +static struct sk_buff *pppoe_gso_segment(struct sk_buff *skb,
>>> + netdev_features_t features)
>>> +{
>>
>> I don't think this will be called for PPPoE over GRE packets,
>> since gre_gso_segment skips everything up to the network header.
>
> What's a good solution to this issue? Use the outer network header instead of the inner one when the protocol is PPPoE?
>
> - Felix
I don't really have a good solution for this. You could explicitly check
if the protocol is PPPoE in gre_gso_segment, but that wouldn't be very
elegant or future-proof.
I think setting skb->inner_network_header in pppoe_gro_complete
(while not resetting it in inet_gro_complete) wouldn't work since other
functions assume that skb->inner_network_header is an IP header.
Powered by blists - more mailing lists