Commit 913cd70d authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPSEC]: Remove run-time encap_type checks in esp4.

This allows us to remove all the per-packet checks on x->encap->encap_type.
I've left the check in esp_input just in case someone adds a non-ESP encap
type in future.

However, printing a warning and then continuing is definitely wrong.
So expect a follow-up patch to drop the packet when encap_type is
unknown in esp_input.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent 7c9b47ff
......@@ -94,8 +94,9 @@ int esp_output(struct sk_buff **pskb)
if (x->props.mode) {
top_iph = (struct iphdr*)skb_push(*pskb, x->props.header_len);
esph = (struct ip_esp_hdr*)(top_iph+1);
if (encap && encap->encap_type) {
if (encap) {
switch (encap->encap_type) {
default:
case UDP_ENCAP_ESPINUDP:
uh = (struct udphdr*) esph;
esph = (struct ip_esp_hdr*)(uh+1);
......@@ -108,12 +109,6 @@ int esp_output(struct sk_buff **pskb)
esph = (struct ip_esp_hdr*)(udpdata32+2);
top_iph->protocol = IPPROTO_UDP;
break;
default:
printk(KERN_INFO
"esp_output(): Unhandled encap: %u\n",
encap->encap_type);
top_iph->protocol = IPPROTO_ESP;
break;
}
} else
top_iph->protocol = IPPROTO_ESP;
......@@ -136,8 +131,9 @@ int esp_output(struct sk_buff **pskb)
esph = (struct ip_esp_hdr*)skb_push(*pskb, x->props.header_len);
top_iph = (struct iphdr*)skb_push(*pskb, iph->ihl*4);
memcpy(top_iph, &tmp_iph, iph->ihl*4);
if (encap && encap->encap_type) {
if (encap) {
switch (encap->encap_type) {
default:
case UDP_ENCAP_ESPINUDP:
uh = (struct udphdr*) esph;
esph = (struct ip_esp_hdr*)(uh+1);
......@@ -150,12 +146,6 @@ int esp_output(struct sk_buff **pskb)
esph = (struct ip_esp_hdr*)(udpdata32+2);
top_iph->protocol = IPPROTO_UDP;
break;
default:
printk(KERN_INFO
"esp_output(): Unhandled encap: %u\n",
encap->encap_type);
top_iph->protocol = IPPROTO_ESP;
break;
}
} else
top_iph->protocol = IPPROTO_ESP;
......@@ -365,11 +355,8 @@ int esp_post_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct
if (encap->encap_type != decap->decap_type)
return -EINVAL;
/* Next, if we don't have an encap type, then ignore it */
if (!encap->encap_type)
return 0;
switch (encap->encap_type) {
default:
case UDP_ENCAP_ESPINUDP:
case UDP_ENCAP_ESPINUDP_NON_IKE:
/*
......@@ -406,11 +393,6 @@ int esp_post_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct
skb->ip_summed = CHECKSUM_UNNECESSARY;
break;
default:
printk(KERN_INFO
"esp4_post_input(): Unhandled encap type: %u\n",
encap->encap_type);
break;
}
}
return 0;
......@@ -547,20 +529,14 @@ int esp_init_state(struct xfrm_state *x, void *args)
if (x->encap) {
struct xfrm_encap_tmpl *encap = x->encap;
if (encap->encap_type) {
switch (encap->encap_type) {
case UDP_ENCAP_ESPINUDP:
x->props.header_len += sizeof(struct udphdr);
break;
case UDP_ENCAP_ESPINUDP_NON_IKE:
x->props.header_len += sizeof(struct udphdr) + 2 * sizeof(u32);
break;
default:
printk (KERN_INFO
"esp_init_state(): Unhandled encap type: %u\n",
encap->encap_type);
break;
}
switch (encap->encap_type) {
default:
case UDP_ENCAP_ESPINUDP:
x->props.header_len += sizeof(struct udphdr);
break;
case UDP_ENCAP_ESPINUDP_NON_IKE:
x->props.header_len += sizeof(struct udphdr) + 2 * sizeof(u32);
break;
}
}
x->data = esp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment