diff options
| author | Herbert Xu <herbert@gondor.apana.org.au> | 2004-06-25 21:34:31 -0700 |
|---|---|---|
| committer | David S. Miller <davem@nuts.davemloft.net> | 2004-06-25 21:34:31 -0700 |
| commit | 4bddee2c398b538bd5871d3a57a99f06dc20e856 (patch) | |
| tree | d1c84001d8edc783a3493b22862a086680b6478c | |
| parent | c889f502d4def3ca21be7bf5c50b2105170d1f50 (diff) | |
[IPSEC]: Move common code out of udp_encap_rcv().
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@redhat.com>
| -rw-r--r-- | net/ipv4/udp.c | 56 |
1 files changed, 27 insertions, 29 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 3c3d0d3881c3..bfa78d5ee608 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c @@ -976,34 +976,6 @@ static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb) /* Must be an IKE packet.. pass it through */ return 1; - decaps: - /* At this point we are sure that this is an ESPinUDP packet, - * so we need to remove 'len' bytes from the packet (the UDP - * header and optional ESP marker bytes) and then modify the - * protocol to ESP, and then call into the transform receiver. - */ - - /* Now we can update and verify the packet length... */ - iph = skb->nh.iph; - iphlen = iph->ihl << 2; - iph->tot_len = htons(ntohs(iph->tot_len) - len); - if (skb->len < iphlen + len) { - /* packet is too small!?! */ - return 0; - } - - /* pull the data buffer up to the ESP header and set the - * transport header to point to ESP. Keep UDP on the stack - * for later. - */ - skb->h.raw = skb_pull(skb, len); - - /* modify the protocol (it's ESP!) */ - iph->protocol = IPPROTO_ESP; - - /* and let the caller know to send this into the ESP processor... */ - return -1; - case UDP_ENCAP_ESPINUDP_NON_IKE: /* Check if this is a keepalive packet. If so, eat it. */ if (len == 1 && udpdata[0] == 0xff) { @@ -1013,11 +985,37 @@ static int udp_encap_rcv(struct sock * sk, struct sk_buff *skb) /* ESP Packet with Non-IKE marker */ len = sizeof(struct udphdr) + 2 * sizeof(u32); - goto decaps; } else /* Must be an IKE packet.. pass it through */ return 1; } + + /* At this point we are sure that this is an ESPinUDP packet, + * so we need to remove 'len' bytes from the packet (the UDP + * header and optional ESP marker bytes) and then modify the + * protocol to ESP, and then call into the transform receiver. + */ + + /* Now we can update and verify the packet length... */ + iph = skb->nh.iph; + iphlen = iph->ihl << 2; + iph->tot_len = htons(ntohs(iph->tot_len) - len); + if (skb->len < iphlen + len) { + /* packet is too small!?! */ + return 0; + } + + /* pull the data buffer up to the ESP header and set the + * transport header to point to ESP. Keep UDP on the stack + * for later. + */ + skb->h.raw = skb_pull(skb, len); + + /* modify the protocol (it's ESP!) */ + iph->protocol = IPPROTO_ESP; + + /* and let the caller know to send this into the ESP processor... */ + return -1; #endif } |
