Skip to content

Commit 25cfb8b

Browse files
Florian Westphalklassert
authored andcommitted
xfrm: replay: remove recheck indirection
Adds new xfrm_replay_recheck() helper and calls it from xfrm input path instead of the indirection. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent c7f8778 commit 25cfb8b

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

include/net/xfrm.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,6 @@ struct xfrm_replay {
309309
int (*check)(struct xfrm_state *x,
310310
struct sk_buff *skb,
311311
__be32 net_seq);
312-
int (*recheck)(struct xfrm_state *x,
313-
struct sk_buff *skb,
314-
__be32 net_seq);
315312
int (*overflow)(struct xfrm_state *x, struct sk_buff *skb);
316313
};
317314

@@ -1723,6 +1720,7 @@ static inline int xfrm_policy_id2dir(u32 index)
17231720
#ifdef CONFIG_XFRM
17241721
void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq);
17251722
void xfrm_replay_notify(struct xfrm_state *x, int event);
1723+
int xfrm_replay_recheck(struct xfrm_state *x, struct sk_buff *skb, __be32 net_seq);
17261724

17271725
static inline int xfrm_aevent_is_on(struct net *net)
17281726
{

net/xfrm/xfrm_input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
660660
/* only the first xfrm gets the encap type */
661661
encap_type = 0;
662662

663-
if (x->repl->recheck(x, skb, seq)) {
663+
if (xfrm_replay_recheck(x, skb, seq)) {
664664
XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATESEQERROR);
665665
goto drop_unlock;
666666
}

net/xfrm/xfrm_replay.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,22 @@ static int xfrm_replay_recheck_esn(struct xfrm_state *x,
519519
return xfrm_replay_check_esn(x, skb, net_seq);
520520
}
521521

522+
int xfrm_replay_recheck(struct xfrm_state *x,
523+
struct sk_buff *skb, __be32 net_seq)
524+
{
525+
switch (x->repl_mode) {
526+
case XFRM_REPLAY_MODE_LEGACY:
527+
break;
528+
case XFRM_REPLAY_MODE_BMP:
529+
/* no special recheck treatment */
530+
return xfrm_replay_check_bmp(x, skb, net_seq);
531+
case XFRM_REPLAY_MODE_ESN:
532+
return xfrm_replay_recheck_esn(x, skb, net_seq);
533+
}
534+
535+
return xfrm_replay_check(x, skb, net_seq);
536+
}
537+
522538
static void xfrm_replay_advance_esn(struct xfrm_state *x, __be32 net_seq)
523539
{
524540
unsigned int bitnr, nr, i;
@@ -708,37 +724,31 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff
708724

709725
static const struct xfrm_replay xfrm_replay_legacy = {
710726
.check = xfrm_replay_check,
711-
.recheck = xfrm_replay_check,
712727
.overflow = xfrm_replay_overflow_offload,
713728
};
714729

715730
static const struct xfrm_replay xfrm_replay_bmp = {
716731
.check = xfrm_replay_check_bmp,
717-
.recheck = xfrm_replay_check_bmp,
718732
.overflow = xfrm_replay_overflow_offload_bmp,
719733
};
720734

721735
static const struct xfrm_replay xfrm_replay_esn = {
722736
.check = xfrm_replay_check_esn,
723-
.recheck = xfrm_replay_recheck_esn,
724737
.overflow = xfrm_replay_overflow_offload_esn,
725738
};
726739
#else
727740
static const struct xfrm_replay xfrm_replay_legacy = {
728741
.check = xfrm_replay_check,
729-
.recheck = xfrm_replay_check,
730742
.overflow = xfrm_replay_overflow,
731743
};
732744

733745
static const struct xfrm_replay xfrm_replay_bmp = {
734746
.check = xfrm_replay_check_bmp,
735-
.recheck = xfrm_replay_check_bmp,
736747
.overflow = xfrm_replay_overflow_bmp,
737748
};
738749

739750
static const struct xfrm_replay xfrm_replay_esn = {
740751
.check = xfrm_replay_check_esn,
741-
.recheck = xfrm_replay_recheck_esn,
742752
.overflow = xfrm_replay_overflow_esn,
743753
};
744754
#endif

0 commit comments

Comments
 (0)