[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231219145333.240323-3-radu-nicolae.pirea@oss.nxp.com>
Date: Tue, 19 Dec 2023 16:53:26 +0200
From: "Radu Pirea (NXP OSS)" <radu-nicolae.pirea@....nxp.com>
To: sd@...asysnail.net,
davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
andrew@...n.ch,
hkallweit1@...il.com,
linux@...linux.org.uk,
richardcochran@...il.com
Cc: linux-kernel@...r.kernel.org,
netdev@...r.kernel.org,
sebastian.tobuschat@....nxp.com,
andrei.botila@....nxp.com,
"Radu Pirea (NXP OSS)" <radu-nicolae.pirea@....nxp.com>
Subject: [PATCH net-next v9 2/9] net: macsec: use skb_ensure_writable_head_tail to expand the skb
Use skb_ensure_writable_head_tail to expand the skb if needed instead of
reimplementing a similar operation.
Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@....nxp.com>
---
Changes in v9:
- patch added in v9
drivers/net/macsec.c | 25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 9663050a852d..972bd816292a 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -604,26 +604,11 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
return ERR_PTR(-EINVAL);
}
- if (unlikely(skb_headroom(skb) < MACSEC_NEEDED_HEADROOM ||
- skb_tailroom(skb) < MACSEC_NEEDED_TAILROOM)) {
- struct sk_buff *nskb = skb_copy_expand(skb,
- MACSEC_NEEDED_HEADROOM,
- MACSEC_NEEDED_TAILROOM,
- GFP_ATOMIC);
- if (likely(nskb)) {
- consume_skb(skb);
- skb = nskb;
- } else {
- macsec_txsa_put(tx_sa);
- kfree_skb(skb);
- return ERR_PTR(-ENOMEM);
- }
- } else {
- skb = skb_unshare(skb, GFP_ATOMIC);
- if (!skb) {
- macsec_txsa_put(tx_sa);
- return ERR_PTR(-ENOMEM);
- }
+ ret = skb_ensure_writable_head_tail(skb, dev);
+ if (unlikely(ret < 0)) {
+ macsec_txsa_put(tx_sa);
+ kfree_skb(skb);
+ return ERR_PTR(ret);
}
unprotected_len = skb->len;
--
2.34.1
Powered by blists - more mailing lists