Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

esp4: prepare esp_input_done2 for non-UDP encapsulation

For espintcp encapsulation, we will need to get the source port from the
TCP header instead of UDP. Introduce a variable to hold the port.

Co-developed-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>

authored by

Sabrina Dubroca and committed by
Steffen Klassert
25f6802b cac3c716

+14 -2
+14 -2
net/ipv4/esp4.c
··· 601 601 if (x->encap) { 602 602 struct xfrm_encap_tmpl *encap = x->encap; 603 603 struct udphdr *uh = (void *)(skb_network_header(skb) + ihl); 604 + __be16 source; 605 + 606 + switch (x->encap->encap_type) { 607 + case UDP_ENCAP_ESPINUDP: 608 + case UDP_ENCAP_ESPINUDP_NON_IKE: 609 + source = uh->source; 610 + break; 611 + default: 612 + WARN_ON_ONCE(1); 613 + err = -EINVAL; 614 + goto out; 615 + } 604 616 605 617 /* 606 618 * 1) if the NAT-T peer's IP or port changed then ··· 621 609 * SRC ports. 622 610 */ 623 611 if (iph->saddr != x->props.saddr.a4 || 624 - uh->source != encap->encap_sport) { 612 + source != encap->encap_sport) { 625 613 xfrm_address_t ipaddr; 626 614 627 615 ipaddr.a4 = iph->saddr; 628 - km_new_mapping(x, &ipaddr, uh->source); 616 + km_new_mapping(x, &ipaddr, source); 629 617 630 618 /* XXX: perhaps add an extra 631 619 * policy check here, to see