All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: steffen.klassert@secunet.com
Cc: <netdev@vger.kernel.org>, Florian Westphal <fw@strlen.de>
Subject: [PATCH ipsec-next v2 2/6] xfrm: replay: get rid of duplicated notification code
Date: Wed, 24 Jun 2020 10:08:00 +0200	[thread overview]
Message-ID: <20200624080804.7480-3-fw@strlen.de> (raw)
In-Reply-To: <20200624080804.7480-1-fw@strlen.de>

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 <fw@strlen.de>
---
 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)
-- 
2.26.2


  parent reply	other threads:[~2020-06-24  8:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24  8:07 [PATCH ipsec-next v2 0/6] xfrm: remove xfrm replay indirections Florian Westphal
2020-06-24  8:07 ` [PATCH ipsec-next v2 1/6] xfrm: replay: avoid xfrm replay notify indirection Florian Westphal
2020-06-24  8:08 ` Florian Westphal [this message]
2020-06-25  7:07   ` [PATCH ipsec-next v2 2/6] xfrm: replay: get rid of duplicated notification code Sabrina Dubroca
2020-06-25 10:09     ` Florian Westphal
2020-06-24  8:08 ` [PATCH ipsec-next v2 3/6] xfrm: replay: remove advance indirection Florian Westphal
2020-06-24  8:08 ` [PATCH ipsec-next v2 4/6] xfrm: replay: remove recheck indirection Florian Westphal
2020-06-24  8:08 ` [PATCH ipsec-next v2 5/6] xfrm: replay: avoid replay indirection Florian Westphal
2020-06-24  8:08 ` [PATCH ipsec-next v2 6/6] xfrm: replay: remove last " Florian Westphal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200624080804.7480-3-fw@strlen.de \
    --to=fw@strlen.de \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.