aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSteffen Klassert <steffen.klassert@secunet.com>2011-03-28 15:46:39 -0400
committerDavid S. Miller <davem@davemloft.net>2011-03-29 02:34:52 -0400
commitaf2f464e326ebad57284cfdecb03f1606e89bbc7 (patch)
tree0b9f1e9918a47f49e1454a0df5e045a0d627050d /include
parent36ae0148dbb6b9e15d8f067bb7523fd2b765a6af (diff)
xfrm: Assign esn pointers when cloning a state
When we clone a xfrm state we have to assign the replay_esn and the preplay_esn pointers to the state if we use the new replay detection method. To this end, we add a xfrm_replay_clone() function that allocates memory for the replay detection and takes over the necessary values from the original state. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r--include/net/xfrm.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index cffa5dc66449..6ae4bc5ce8a7 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -1601,6 +1601,28 @@ static inline int xfrm_replay_state_esn_len(struct xfrm_replay_state_esn *replay
1601} 1601}
1602 1602
1603#ifdef CONFIG_XFRM_MIGRATE 1603#ifdef CONFIG_XFRM_MIGRATE
1604static inline int xfrm_replay_clone(struct xfrm_state *x,
1605 struct xfrm_state *orig)
1606{
1607 x->replay_esn = kzalloc(xfrm_replay_state_esn_len(orig->replay_esn),
1608 GFP_KERNEL);
1609 if (!x->replay_esn)
1610 return -ENOMEM;
1611
1612 x->replay_esn->bmp_len = orig->replay_esn->bmp_len;
1613 x->replay_esn->replay_window = orig->replay_esn->replay_window;
1614
1615 x->preplay_esn = kmemdup(x->replay_esn,
1616 xfrm_replay_state_esn_len(x->replay_esn),
1617 GFP_KERNEL);
1618 if (!x->preplay_esn) {
1619 kfree(x->replay_esn);
1620 return -ENOMEM;
1621 }
1622
1623 return 0;
1624}
1625
1604static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) 1626static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig)
1605{ 1627{
1606 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL); 1628 return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL);