File tree Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Expand file tree Collapse file tree 1 file changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -607,11 +607,26 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
607
607
return ERR_PTR (- EINVAL );
608
608
}
609
609
610
- ret = skb_ensure_writable_head_tail (skb , dev );
611
- if (unlikely (ret < 0 )) {
612
- macsec_txsa_put (tx_sa );
613
- kfree_skb (skb );
614
- return ERR_PTR (ret );
610
+ if (unlikely (skb_headroom (skb ) < MACSEC_NEEDED_HEADROOM ||
611
+ skb_tailroom (skb ) < MACSEC_NEEDED_TAILROOM )) {
612
+ struct sk_buff * nskb = skb_copy_expand (skb ,
613
+ MACSEC_NEEDED_HEADROOM ,
614
+ MACSEC_NEEDED_TAILROOM ,
615
+ GFP_ATOMIC );
616
+ if (likely (nskb )) {
617
+ consume_skb (skb );
618
+ skb = nskb ;
619
+ } else {
620
+ macsec_txsa_put (tx_sa );
621
+ kfree_skb (skb );
622
+ return ERR_PTR (- ENOMEM );
623
+ }
624
+ } else {
625
+ skb = skb_unshare (skb , GFP_ATOMIC );
626
+ if (!skb ) {
627
+ macsec_txsa_put (tx_sa );
628
+ return ERR_PTR (- ENOMEM );
629
+ }
615
630
}
616
631
617
632
unprotected_len = skb -> len ;
You can’t perform that action at this time.
0 commit comments