Skip to content

Commit ff24b50

Browse files
LGA1150gregkh
authored andcommitted
ppp: enable TX scatter-gather
[ Upstream commit 42fcb21 ] PPP channels using chan->direct_xmit prepend the PPP header to a skb and call dev_queue_xmit() directly. In this mode the skb does not need to be linear, but the PPP netdevice currently does not advertise scatter-gather features, causing unnecessary linearization and preventing GSO. Enable NETIF_F_SG and NETIF_F_FRAGLIST on PPP devices. In case a linear buffer is required (PPP compression, multilink, and channels without direct_xmit), call skb_linearize() explicitly. Signed-off-by: Qingfang Deng <dqfext@gmail.com> Link: https://patch.msgid.link/20260129012902.941-1-dqfext@gmail.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Stable-dep-of: 543adf0 ("ppp: annotate data races in ppp_generic") Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fa4e1da commit ff24b50

1 file changed

Lines changed: 25 additions & 5 deletions

File tree

drivers/net/ppp/ppp_generic.c

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,6 +1636,8 @@ static void ppp_setup(struct net_device *dev)
16361636
dev->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST;
16371637
dev->priv_destructor = ppp_dev_priv_destructor;
16381638
dev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
1639+
dev->features = NETIF_F_SG | NETIF_F_FRAGLIST;
1640+
dev->hw_features = dev->features;
16391641
netif_keep_dst(dev);
16401642
}
16411643

@@ -1700,6 +1702,10 @@ pad_compress_skb(struct ppp *ppp, struct sk_buff *skb)
17001702
ppp->xcomp->comp_extra + ppp->dev->hard_header_len;
17011703
int compressor_skb_size = ppp->dev->mtu +
17021704
ppp->xcomp->comp_extra + PPP_HDRLEN;
1705+
1706+
if (skb_linearize(skb))
1707+
return NULL;
1708+
17031709
new_skb = alloc_skb(new_skb_size, GFP_ATOMIC);
17041710
if (!new_skb) {
17051711
if (net_ratelimit())
@@ -1787,6 +1793,10 @@ ppp_send_frame(struct ppp *ppp, struct sk_buff *skb)
17871793
case PPP_IP:
17881794
if (!ppp->vj || (ppp->flags & SC_COMP_TCP) == 0)
17891795
break;
1796+
1797+
if (skb_linearize(skb))
1798+
goto drop;
1799+
17901800
/* try to do VJ TCP header compression */
17911801
new_skb = alloc_skb(skb->len + ppp->dev->hard_header_len - 2,
17921802
GFP_ATOMIC);
@@ -1884,19 +1894,26 @@ ppp_push(struct ppp *ppp)
18841894
}
18851895

18861896
if ((ppp->flags & SC_MULTILINK) == 0) {
1897+
struct ppp_channel *chan;
18871898
/* not doing multilink: send it down the first channel */
18881899
list = list->next;
18891900
pch = list_entry(list, struct channel, clist);
18901901

18911902
spin_lock(&pch->downl);
1892-
if (pch->chan) {
1893-
if (pch->chan->ops->start_xmit(pch->chan, skb))
1894-
ppp->xmit_pending = NULL;
1895-
} else {
1896-
/* channel got unregistered */
1903+
chan = pch->chan;
1904+
if (unlikely(!chan || (!chan->direct_xmit && skb_linearize(skb)))) {
1905+
/* channel got unregistered, or it requires a linear
1906+
* skb but linearization failed
1907+
*/
18971908
kfree_skb(skb);
18981909
ppp->xmit_pending = NULL;
1910+
goto out;
18991911
}
1912+
1913+
if (chan->ops->start_xmit(chan, skb))
1914+
ppp->xmit_pending = NULL;
1915+
1916+
out:
19001917
spin_unlock(&pch->downl);
19011918
return;
19021919
}
@@ -1981,6 +1998,8 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
19811998
return 0; /* can't take now, leave it in xmit_pending */
19821999

19832000
/* Do protocol field compression */
2001+
if (skb_linearize(skb))
2002+
goto err_linearize;
19842003
p = skb->data;
19852004
len = skb->len;
19862005
if (*p == 0 && mp_protocol_compress) {
@@ -2139,6 +2158,7 @@ static int ppp_mp_explode(struct ppp *ppp, struct sk_buff *skb)
21392158

21402159
noskb:
21412160
spin_unlock(&pch->downl);
2161+
err_linearize:
21422162
if (ppp->debug & 1)
21432163
netdev_err(ppp->dev, "PPP: no memory (fragment)\n");
21442164
++ppp->dev->stats.tx_errors;

0 commit comments

Comments
 (0)