[TCP]: Prevent pseudo garbage in SYN's advertized window
[powerpc.git] / net / ipv4 / xfrm4_input.c
index 3e174c8..289146b 100644 (file)
@@ -6,14 +6,13 @@
  *             Split up af-specific portion
  *     Derek Atkins <derek@ihtfp.com>
  *             Add Encapsulation support
- *     
+ *
  */
 
 #include <linux/module.h>
 #include <linux/string.h>
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv4.h>
-#include <net/inet_ecn.h>
 #include <net/ip.h>
 #include <net/xfrm.h>
 
@@ -24,16 +23,7 @@ int xfrm4_rcv(struct sk_buff *skb)
 
 EXPORT_SYMBOL(xfrm4_rcv);
 
-static inline void ipip_ecn_decapsulate(struct sk_buff *skb)
-{
-       struct iphdr *outer_iph = skb->nh.iph;
-       struct iphdr *inner_iph = skb->h.ipiph;
-
-       if (INET_ECN_is_ce(outer_iph->tos))
-               IP_ECN_set_ce(inner_iph);
-}
-
-static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, u32 *spi, u32 *seq)
+static int xfrm4_parse_spi(struct sk_buff *skb, u8 nexthdr, __be32 *spi, __be32 *seq)
 {
        switch (nexthdr) {
        case IPPROTO_IPIP:
@@ -52,7 +42,7 @@ static inline int xfrm4_rcv_encap_finish(struct sk_buff *skb)
 
        if (skb->dst == NULL) {
                if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos,
-                                  skb->dev))
+                                  skb->dev))
                        goto drop;
        }
        return dst_input(skb);
@@ -65,7 +55,7 @@ drop:
 int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
 {
        int err;
-       u32 spi, seq;
+       __be32 spi, seq;
        struct xfrm_state *xfrm_vec[XFRM_MAX_DEPTH];
        struct xfrm_state *x;
        int xfrm_nr = 0;
@@ -113,24 +103,10 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
 
                xfrm_vec[xfrm_nr++] = x;
 
-               iph = skb->nh.iph;
-
-               if (x->props.mode) {
-                       if (iph->protocol != IPPROTO_IPIP)
-                               goto drop;
-                       if (!pskb_may_pull(skb, sizeof(struct iphdr)))
-                               goto drop;
-                       if (skb_cloned(skb) &&
-                           pskb_expand_head(skb, 0, 0, GFP_ATOMIC))
-                               goto drop;
-                       if (x->props.flags & XFRM_STATE_DECAP_DSCP)
-                               ipv4_copy_dscp(iph, skb->h.ipiph);
-                       if (!(x->props.flags & XFRM_STATE_NOECN))
-                               ipip_ecn_decapsulate(skb);
-                       skb->mac.raw = memmove(skb->data - skb->mac_len,
-                                              skb->mac.raw, skb->mac_len);
-                       skb->nh.raw = skb->data;
-                       memset(&(IPCB(skb)->opt), 0, sizeof(struct ip_options));
+               if (x->mode->input(x, skb))
+                       goto drop;
+
+               if (x->props.mode == XFRM_MODE_TUNNEL) {
                        decaps = 1;
                        break;
                }
@@ -173,7 +149,7 @@ int xfrm4_rcv_encap(struct sk_buff *skb, __u16 encap_type)
                ip_send_check(skb->nh.iph);
 
                NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, skb->dev, NULL,
-                       xfrm4_rcv_encap_finish);
+                       xfrm4_rcv_encap_finish);
                return 0;
 #else
                return -skb->nh.iph->protocol;