{pktgen, xfrm} Introduce xfrm_state_lookup_byspi for pktgen
Introduce xfrm_state_lookup_byspi to find user specified by custom from "pgset spi xxx". Using this scheme, any flow regardless its saddr/daddr could be transform by SA specified with configurable spi. Signed-off-by: Fan Du <fan.du@windriver.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
@@ -915,6 +915,28 @@ xfrm_stateonly_find(struct net *net, u32 mark,
|
||||
}
|
||||
EXPORT_SYMBOL(xfrm_stateonly_find);
|
||||
|
||||
struct xfrm_state *xfrm_state_lookup_byspi(struct net *net, __be32 spi,
|
||||
unsigned short family)
|
||||
{
|
||||
struct xfrm_state *x;
|
||||
struct xfrm_state_walk *w;
|
||||
|
||||
spin_lock_bh(&net->xfrm.xfrm_state_lock);
|
||||
list_for_each_entry(w, &net->xfrm.state_all, all) {
|
||||
x = container_of(w, struct xfrm_state, km);
|
||||
if (x->props.family != family ||
|
||||
x->id.spi != spi)
|
||||
continue;
|
||||
|
||||
spin_unlock_bh(&net->xfrm.xfrm_state_lock);
|
||||
xfrm_state_hold(x);
|
||||
return x;
|
||||
}
|
||||
spin_unlock_bh(&net->xfrm.xfrm_state_lock);
|
||||
return NULL;
|
||||
}
|
||||
EXPORT_SYMBOL(xfrm_state_lookup_byspi);
|
||||
|
||||
static void __xfrm_state_insert(struct xfrm_state *x)
|
||||
{
|
||||
struct net *net = xs_net(x);
|
||||
|
Reference in New Issue
Block a user