From patchwork Wed Jun 24 08:08:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Westphal X-Patchwork-Id: 217209 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AD25C433DF for ; Wed, 24 Jun 2020 08:08:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DBCF320874 for ; Wed, 24 Jun 2020 08:08:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390308AbgFXIIW (ORCPT ); Wed, 24 Jun 2020 04:08:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390293AbgFXIIT (ORCPT ); Wed, 24 Jun 2020 04:08:19 -0400 Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [IPv6:2a0a:51c0:0:12e:520::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A246C061573 for ; Wed, 24 Jun 2020 01:08:19 -0700 (PDT) Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1jo0S9-00068a-Mb; Wed, 24 Jun 2020 10:08:17 +0200 From: Florian Westphal To: steffen.klassert@secunet.com Cc: , Florian Westphal Subject: [PATCH ipsec-next v2 2/6] xfrm: replay: get rid of duplicated notification code Date: Wed, 24 Jun 2020 10:08:00 +0200 Message-Id: <20200624080804.7480-3-fw@strlen.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200624080804.7480-1-fw@strlen.de> References: <20200624080804.7480-1-fw@strlen.de> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org After previous patch, we can consolidate some code: xfrm_replay_notify, xfrm_replay_notify_bmp and _esn all contain the same code at the end. Remove it from xfrm_replay_notify_bmp/esn and reuse the one in xfrm_replay_notify. Signed-off-by: Florian Westphal --- net/xfrm/xfrm_replay.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/net/xfrm/xfrm_replay.c b/net/xfrm/xfrm_replay.c index e42a7afb8ee5..fac2f3af4c1a 100644 --- a/net/xfrm/xfrm_replay.c +++ b/net/xfrm/xfrm_replay.c @@ -56,10 +56,10 @@ void xfrm_replay_notify(struct xfrm_state *x, int event) break; case XFRM_REPLAY_MODE_BMP: xfrm_replay_notify_bmp(x, event); - return; + goto notify; case XFRM_REPLAY_MODE_ESN: xfrm_replay_notify_esn(x, event); - return; + goto notify; } switch (event) { @@ -86,6 +86,8 @@ void xfrm_replay_notify(struct xfrm_state *x, int event) } memcpy(&x->preplay, &x->replay, sizeof(struct xfrm_replay_state)); + +notify: c.event = XFRM_MSG_NEWAE; c.data.aevent = event; km_state_notify(x, &c); @@ -290,7 +292,6 @@ static void xfrm_replay_advance_bmp(struct xfrm_state *x, __be32 net_seq) static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event) { - struct km_event c; struct xfrm_replay_state_esn *replay_esn = x->replay_esn; struct xfrm_replay_state_esn *preplay_esn = x->preplay_esn; @@ -330,19 +331,11 @@ static void xfrm_replay_notify_bmp(struct xfrm_state *x, int event) memcpy(x->preplay_esn, x->replay_esn, xfrm_replay_state_esn_len(replay_esn)); - c.event = XFRM_MSG_NEWAE; - c.data.aevent = event; - km_state_notify(x, &c); - - if (x->replay_maxage && - !mod_timer(&x->rtimer, jiffies + x->replay_maxage)) - x->xflags &= ~XFRM_TIME_DEFER; } static void xfrm_replay_notify_esn(struct xfrm_state *x, int event) { u32 seq_diff, oseq_diff; - struct km_event c; struct xfrm_replay_state_esn *replay_esn = x->replay_esn; struct xfrm_replay_state_esn *preplay_esn = x->preplay_esn; @@ -396,13 +389,6 @@ static void xfrm_replay_notify_esn(struct xfrm_state *x, int event) memcpy(x->preplay_esn, x->replay_esn, xfrm_replay_state_esn_len(replay_esn)); - c.event = XFRM_MSG_NEWAE; - c.data.aevent = event; - km_state_notify(x, &c); - - if (x->replay_maxage && - !mod_timer(&x->rtimer, jiffies + x->replay_maxage)) - x->xflags &= ~XFRM_TIME_DEFER; } static int xfrm_replay_overflow_esn(struct xfrm_state *x, struct sk_buff *skb)