Commit c7f87783 authored by Florian Westphal's avatar Florian Westphal Committed by Steffen Klassert

xfrm: replay: remove advance indirection

Similar to other patches: add a new helper to avoid
an indirection.

v2: fix 'net/xfrm/xfrm_replay.c:519:13: warning: 'seq' may be used
uninitialized in this function' warning.
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent cfc61c59
...@@ -306,7 +306,6 @@ struct km_event { ...@@ -306,7 +306,6 @@ struct km_event {
}; };
struct xfrm_replay { struct xfrm_replay {
void (*advance)(struct xfrm_state *x, __be32 net_seq);
int (*check)(struct xfrm_state *x, int (*check)(struct xfrm_state *x,
struct sk_buff *skb, struct sk_buff *skb,
__be32 net_seq); __be32 net_seq);
...@@ -1722,6 +1721,7 @@ static inline int xfrm_policy_id2dir(u32 index) ...@@ -1722,6 +1721,7 @@ static inline int xfrm_policy_id2dir(u32 index)
} }
#ifdef CONFIG_XFRM #ifdef CONFIG_XFRM
void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq);
void xfrm_replay_notify(struct xfrm_state *x, int event); void xfrm_replay_notify(struct xfrm_state *x, int event);
static inline int xfrm_aevent_is_on(struct net *net) static inline int xfrm_aevent_is_on(struct net *net)
......
...@@ -665,7 +665,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type) ...@@ -665,7 +665,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
goto drop_unlock; goto drop_unlock;
} }
x->repl->advance(x, seq); xfrm_replay_advance(x, seq);
x->curlft.bytes += skb->len; x->curlft.bytes += skb->len;
x->curlft.packets++; x->curlft.packets++;
......
...@@ -150,14 +150,26 @@ static int xfrm_replay_check(struct xfrm_state *x, ...@@ -150,14 +150,26 @@ static int xfrm_replay_check(struct xfrm_state *x,
return -EINVAL; return -EINVAL;
} }
static void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq) static void xfrm_replay_advance_bmp(struct xfrm_state *x, __be32 net_seq);
static void xfrm_replay_advance_esn(struct xfrm_state *x, __be32 net_seq);
void xfrm_replay_advance(struct xfrm_state *x, __be32 net_seq)
{ {
u32 diff; u32 diff, seq;
u32 seq = ntohl(net_seq);
switch (x->repl_mode) {
case XFRM_REPLAY_MODE_LEGACY:
break;
case XFRM_REPLAY_MODE_BMP:
return xfrm_replay_advance_bmp(x, net_seq);
case XFRM_REPLAY_MODE_ESN:
return xfrm_replay_advance_esn(x, net_seq);
}
if (!x->props.replay_window) if (!x->props.replay_window)
return; return;
seq = ntohl(net_seq);
if (seq > x->replay.seq) { if (seq > x->replay.seq) {
diff = seq - x->replay.seq; diff = seq - x->replay.seq;
if (diff < x->props.replay_window) if (diff < x->props.replay_window)
...@@ -695,42 +707,36 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff ...@@ -695,42 +707,36 @@ static int xfrm_replay_overflow_offload_esn(struct xfrm_state *x, struct sk_buff
} }
static const struct xfrm_replay xfrm_replay_legacy = { static const struct xfrm_replay xfrm_replay_legacy = {
.advance = xfrm_replay_advance,
.check = xfrm_replay_check, .check = xfrm_replay_check,
.recheck = xfrm_replay_check, .recheck = xfrm_replay_check,
.overflow = xfrm_replay_overflow_offload, .overflow = xfrm_replay_overflow_offload,
}; };
static const struct xfrm_replay xfrm_replay_bmp = { static const struct xfrm_replay xfrm_replay_bmp = {
.advance = xfrm_replay_advance_bmp,
.check = xfrm_replay_check_bmp, .check = xfrm_replay_check_bmp,
.recheck = xfrm_replay_check_bmp, .recheck = xfrm_replay_check_bmp,
.overflow = xfrm_replay_overflow_offload_bmp, .overflow = xfrm_replay_overflow_offload_bmp,
}; };
static const struct xfrm_replay xfrm_replay_esn = { static const struct xfrm_replay xfrm_replay_esn = {
.advance = xfrm_replay_advance_esn,
.check = xfrm_replay_check_esn, .check = xfrm_replay_check_esn,
.recheck = xfrm_replay_recheck_esn, .recheck = xfrm_replay_recheck_esn,
.overflow = xfrm_replay_overflow_offload_esn, .overflow = xfrm_replay_overflow_offload_esn,
}; };
#else #else
static const struct xfrm_replay xfrm_replay_legacy = { static const struct xfrm_replay xfrm_replay_legacy = {
.advance = xfrm_replay_advance,
.check = xfrm_replay_check, .check = xfrm_replay_check,
.recheck = xfrm_replay_check, .recheck = xfrm_replay_check,
.overflow = xfrm_replay_overflow, .overflow = xfrm_replay_overflow,
}; };
static const struct xfrm_replay xfrm_replay_bmp = { static const struct xfrm_replay xfrm_replay_bmp = {
.advance = xfrm_replay_advance_bmp,
.check = xfrm_replay_check_bmp, .check = xfrm_replay_check_bmp,
.recheck = xfrm_replay_check_bmp, .recheck = xfrm_replay_check_bmp,
.overflow = xfrm_replay_overflow_bmp, .overflow = xfrm_replay_overflow_bmp,
}; };
static const struct xfrm_replay xfrm_replay_esn = { static const struct xfrm_replay xfrm_replay_esn = {
.advance = xfrm_replay_advance_esn,
.check = xfrm_replay_check_esn, .check = xfrm_replay_check_esn,
.recheck = xfrm_replay_recheck_esn, .recheck = xfrm_replay_recheck_esn,
.overflow = xfrm_replay_overflow_esn, .overflow = xfrm_replay_overflow_esn,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment