[XFRM]: Fix missing protocol comparison of larval SAs.

I noticed that in xfrm_state_add we look for the larval SA in a few
places without checking for protocol match. So when using both
AH and ESP, whichever one gets added first, deletes the larval SA.
It seems AH always gets added first and ESP is always the larval
SA's protocol since the xfrm->tmpl has it first. Thus causing the
additional km_query()

Adding the check eliminates accidental double SA creation.

Signed-off-by: Joy Latten <latten@austin.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by Joy Latten and committed by David S. Miller 75e252d9 ce0ecd59

+4 -2
+4 -2
net/xfrm/xfrm_state.c
··· 704 704 x->props.mode != mode || 705 705 x->props.family != family || 706 706 x->km.state != XFRM_STATE_ACQ || 707 - x->id.spi != 0) 707 + x->id.spi != 0 || 708 + x->id.proto != proto) 708 709 continue; 709 710 710 711 switch (family) { ··· 802 801 803 802 if (use_spi && x->km.seq) { 804 803 x1 = __xfrm_find_acq_byseq(x->km.seq); 805 - if (x1 && xfrm_addr_cmp(&x1->id.daddr, &x->id.daddr, family)) { 804 + if (x1 && ((x1->id.proto != x->id.proto) || 805 + xfrm_addr_cmp(&x1->id.daddr, &x->id.daddr, family))) { 806 806 xfrm_state_put(x1); 807 807 x1 = NULL; 808 808 }