diff options
author | Fan Du <fan.du@windriver.com> | 2014-01-03 11:18:32 +0800 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2014-01-03 07:29:12 +0100 |
commit | c454997e68eb013510ba128283ad3b4aefeff630 (patch) | |
tree | c32cd7284c1e831c84aa962bced9fb0d816b5c51 /net/core | |
parent | cf93d47ed4489cc349678f397290b3ecba868a3b (diff) | |
download | linux-stable-c454997e68eb013510ba128283ad3b4aefeff630.tar.gz linux-stable-c454997e68eb013510ba128283ad3b4aefeff630.tar.bz2 linux-stable-c454997e68eb013510ba128283ad3b4aefeff630.zip |
{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>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/pktgen.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 628f7c572c6e..b553c36ea0ca 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -2247,13 +2247,21 @@ static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow) struct xfrm_state *x = pkt_dev->flows[flow].x; struct pktgen_net *pn = net_generic(dev_net(pkt_dev->odev), pg_net_id); if (!x) { - /*slow path: we dont already have xfrm_state*/ - x = xfrm_stateonly_find(pn->net, DUMMY_MARK, - (xfrm_address_t *)&pkt_dev->cur_daddr, - (xfrm_address_t *)&pkt_dev->cur_saddr, - AF_INET, - pkt_dev->ipsmode, - pkt_dev->ipsproto, 0); + + if (pkt_dev->spi) { + /* We need as quick as possible to find the right SA + * Searching with minimum criteria to archieve this. + */ + x = xfrm_state_lookup_byspi(pn->net, htonl(pkt_dev->spi), AF_INET); + } else { + /* slow path: we dont already have xfrm_state */ + x = xfrm_stateonly_find(pn->net, DUMMY_MARK, + (xfrm_address_t *)&pkt_dev->cur_daddr, + (xfrm_address_t *)&pkt_dev->cur_saddr, + AF_INET, + pkt_dev->ipsmode, + pkt_dev->ipsproto, 0); + } if (x) { pkt_dev->flows[flow].x = x; set_pkt_overhead(pkt_dev); |