[dpdk-dev,v2,5/7] examples/ipsec-secgw: check sp only when setup

Message ID 1474616734-118291-6-git-send-email-sergio.gonzalez.monroy@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Pablo de Lara Guarch
Headers

Commit Message

Sergio Gonzalez Monroy Sept. 23, 2016, 7:45 a.m. UTC
  Application will segfault if there is IPv4 or IPv6 and no SP/ACL rules
for IPv4 or IPv6 respectively.

Avoid checking the ACL/SP in such cases.

Fixes: 906257e965b7 ("examples/ipsec-secgw: support IPv6")

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 examples/ipsec-secgw/ipsec-secgw.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Patch

diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 8b55534..9eee96f 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -388,7 +388,7 @@  inbound_sp_sa(struct sp_ctx *sp, struct sa_ctx *sa, struct traffic_type *ip,
 	struct rte_mbuf *m;
 	uint32_t i, j, res, sa_idx;
 
-	if (ip->num == 0)
+	if (ip->num == 0 || sp == NULL)
 		return;
 
 	rte_acl_classify((struct rte_acl_ctx *)sp, ip->data, ip->res,
@@ -463,7 +463,7 @@  outbound_sp(struct sp_ctx *sp, struct traffic_type *ip,
 	struct rte_mbuf *m;
 	uint32_t i, j, sa_idx;
 
-	if (ip->num == 0)
+	if (ip->num == 0 || sp == NULL)
 		return;
 
 	rte_acl_classify((struct rte_acl_ctx *)sp, ip->data, ip->res,