From: Fan Zhang Date: Tue, 23 Jan 2018 12:32:11 +0000 (+0000) Subject: examples/ipsec_secgw: fix security session X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a6b57a534d5462cdc8656549218a3a031d77b174;p=dpdk.git examples/ipsec_secgw: fix security session Fixes: 3da37f682173 ("examples/ipsec_secgw: create session mempools for ethdevs") Some NICs do not have the rte_security context, this patch fixes the segment fault caused by this. Signed-off-by: Fan Zhang Acked-by: Radu Nicolau --- diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c index 3a28fcceb9..c67f79db95 100644 --- a/examples/ipsec-secgw/ipsec-secgw.c +++ b/examples/ipsec-secgw/ipsec-secgw.c @@ -1384,10 +1384,16 @@ cryptodevs_init(void) max_sess_sz = sess_sz; } for (port_id = 0; port_id < rte_eth_dev_count(); port_id++) { + void *sec_ctx; + if ((enabled_port_mask & (1 << port_id)) == 0) continue; - sess_sz = rte_security_session_get_size( - rte_eth_dev_get_sec_ctx(port_id)); + + sec_ctx = rte_eth_dev_get_sec_ctx(port_id); + if (sec_ctx == NULL) + continue; + + sess_sz = rte_security_session_get_size(sec_ctx); if (sess_sz > max_sess_sz) max_sess_sz = sess_sz; }