examples/ipsec-secgw: fix inbound SA checking
authorKonstantin Ananyev <konstantin.ananyev@intel.com>
Thu, 10 Jan 2019 21:09:09 +0000 (21:09 +0000)
committerPablo de Lara <pablo.de.lara.guarch@intel.com>
Thu, 10 Jan 2019 15:57:22 +0000 (16:57 +0100)
In the inbound_sa_check() make sure that sa pointer stored
inside mbuf private area is not NULL.

Fixes: d299106e8e31 ("examples/ipsec-secgw: add IPsec sample application")
Cc: stable@dpdk.org
Signed-off-by: Bernard Iremonger <bernard.iremonger@intel.com>
Acked-by: Radu Nicolau <radu.nicolau@intel.com>
Acked-by: Akhil Goyal <akhil.goyal@nxp.com>
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
examples/ipsec-secgw/sa.c

index f6271bc..839aaca 100644 (file)
@@ -947,10 +947,15 @@ int
 inbound_sa_check(struct sa_ctx *sa_ctx, struct rte_mbuf *m, uint32_t sa_idx)
 {
        struct ipsec_mbuf_metadata *priv;
+       struct ipsec_sa *sa;
 
        priv = get_priv(m);
+       sa = priv->sa;
+       if (sa != NULL)
+               return (sa_ctx->sa[sa_idx].spi == sa->spi);
 
-       return (sa_ctx->sa[sa_idx].spi == priv->sa->spi);
+       RTE_LOG(ERR, IPSEC, "SA not saved in private data\n");
+       return 0;
 }
 
 static inline void