lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200623194843.19612-3-fw@strlen.de>
Date:   Tue, 23 Jun 2020 21:48:39 +0200
From:   Florian Westphal <fw@...len.de>
To:     Steffen Klassert <steffen.klassert@...unet.com>
Cc:     <netdev@...r.kernel.org>, Florian Westphal <fw@...len.de>
Subject: [PATCH ipsec-next 2/6] xfrm: replay: get rid of duplicated notification code

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@...len.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ