From 102a0743326a03cd1a1202ceda21e175b7d3575c Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Tue, 20 Feb 2024 01:20:52 +0000 Subject: [PATCH] add new system file --- kernel/net/xfrm/xfrm_ipcomp.c | 32 ++++++++++---------------------- 1 files changed, 10 insertions(+), 22 deletions(-) diff --git a/kernel/net/xfrm/xfrm_ipcomp.c b/kernel/net/xfrm/xfrm_ipcomp.c index a979973..24ac680 100644 --- a/kernel/net/xfrm/xfrm_ipcomp.c +++ b/kernel/net/xfrm/xfrm_ipcomp.c @@ -1,13 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-or-later /* * IP Payload Compression Protocol (IPComp) - RFC3173. * * Copyright (c) 2003 James Morris <jmorris@intercode.com.au> * Copyright (c) 2003-2008 Herbert Xu <herbert@gondor.apana.org.au> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. * * Todo: * - Tunable compression parameters. @@ -20,7 +16,6 @@ #include <linux/list.h> #include <linux/module.h> #include <linux/mutex.h> -#include <linux/locallock.h> #include <linux/percpu.h> #include <linux/slab.h> #include <linux/smp.h> @@ -37,7 +32,6 @@ static DEFINE_MUTEX(ipcomp_resource_mutex); static void * __percpu *ipcomp_scratches; -static DEFINE_LOCAL_IRQ_LOCK(ipcomp_scratches_lock); static int ipcomp_scratch_users; static LIST_HEAD(ipcomp_tfms_list); @@ -47,15 +41,12 @@ const int plen = skb->len; int dlen = IPCOMP_SCRATCH_SIZE; const u8 *start = skb->data; - u8 *scratch; - struct crypto_comp *tfm; - int err, len; + const int cpu = get_cpu(); + u8 *scratch = *per_cpu_ptr(ipcomp_scratches, cpu); + struct crypto_comp *tfm = *per_cpu_ptr(ipcd->tfms, cpu); + int err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); + int len; - local_lock(ipcomp_scratches_lock); - - scratch = *this_cpu_ptr(ipcomp_scratches); - tfm = *this_cpu_ptr(ipcd->tfms); - err = crypto_comp_decompress(tfm, start, plen, scratch, &dlen); if (err) goto out; @@ -94,7 +85,7 @@ if (dlen < len) len = dlen; - frag->page_offset = 0; + skb_frag_off_set(frag, 0); skb_frag_size_set(frag, len); memcpy(skb_frag_address(frag), scratch, len); @@ -108,7 +99,7 @@ err = 0; out: - local_unlock(ipcomp_scratches_lock); + put_cpu(); return err; } @@ -151,8 +142,6 @@ int err; local_bh_disable(); - local_lock(ipcomp_scratches_lock); - scratch = *this_cpu_ptr(ipcomp_scratches); tfm = *this_cpu_ptr(ipcd->tfms); err = crypto_comp_compress(tfm, start, plen, scratch, &dlen); @@ -165,14 +154,12 @@ } memcpy(start + sizeof(struct ip_comp_hdr), scratch, dlen); - local_unlock(ipcomp_scratches_lock); local_bh_enable(); pskb_trim(skb, dlen + sizeof(struct ip_comp_hdr)); return 0; out: - local_unlock(ipcomp_scratches_lock); local_bh_enable(); return err; } @@ -225,6 +212,7 @@ vfree(*per_cpu_ptr(scratches, i)); free_percpu(scratches); + ipcomp_scratches = NULL; } static void * __percpu *ipcomp_alloc_scratches(void) @@ -263,7 +251,7 @@ break; } - WARN_ON(!pos); + WARN_ON(list_entry_is_head(pos, &ipcomp_tfms_list, list)); if (--pos->users) return; -- Gitblit v1.6.2