[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
[safe/jmp/linux-2.6] / net / sctp / input.c
index 0e5ac5e..595fe32 100644 (file)
@@ -127,7 +127,6 @@ int sctp_rcv(struct sk_buff *skb)
        struct sctphdr *sh;
        union sctp_addr src;
        union sctp_addr dest;
-       union sctp_addr tmp, tmp2;
        int family;
        struct sctp_af *af;
 
@@ -155,7 +154,7 @@ int sctp_rcv(struct sk_buff *skb)
        if (skb->len < sizeof(struct sctp_chunkhdr))
                goto discard_it;
 
-       family = ipver2af(skb->nh.iph->version);
+       family = ipver2af(ip_hdr(skb)->version);
        af = sctp_get_af_specific(family);
        if (unlikely(!af))
                goto discard_it;
@@ -179,13 +178,10 @@ int sctp_rcv(struct sk_buff *skb)
            !af->addr_valid(&dest, NULL, skb))
                goto discard_it;
 
-       flip_to_n(&tmp, &dest);
-       flip_to_n(&tmp2, &src);
-
-       asoc = __sctp_rcv_lookup(skb, &tmp2, &tmp, &transport);
+       asoc = __sctp_rcv_lookup(skb, &src, &dest, &transport);
 
        if (!asoc)
-               ep = __sctp_rcv_lookup_endpoint(&tmp);
+               ep = __sctp_rcv_lookup_endpoint(&dest);
 
        /* Retrieve the common input handling substructure. */
        rcvr = asoc ? &asoc->base : &ep->base;
@@ -230,7 +226,7 @@ int sctp_rcv(struct sk_buff *skb)
        nf_reset(skb);
 
        if (sk_filter(sk, skb))
-                goto discard_release;
+               goto discard_release;
 
        /* Create an SCTP packet structure. */
        chunk = sctp_chunkify(skb, asoc, sk);
@@ -245,7 +241,7 @@ int sctp_rcv(struct sk_buff *skb)
        chunk->sctp_hdr = sh;
 
        /* Set the source and destination addresses of the incoming chunk.  */
-       sctp_init_addrs(chunk, &tmp2, &tmp);
+       sctp_init_addrs(chunk, &src, &dest);
 
        /* Remember where we came from.  */
        chunk->transport = transport;
@@ -297,11 +293,11 @@ discard_release:
 int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb)
 {
        struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
-       struct sctp_inq *inqueue = &chunk->rcvr->inqueue;
-       struct sctp_ep_common *rcvr = NULL;
+       struct sctp_inq *inqueue = &chunk->rcvr->inqueue;
+       struct sctp_ep_common *rcvr = NULL;
        int backloged = 0;
 
-       rcvr = chunk->rcvr;
+       rcvr = chunk->rcvr;
 
        /* If the rcvr is dead then the association or endpoint
         * has been deleted and we can safely drop the chunk
@@ -351,7 +347,7 @@ done:
        else
                BUG();
 
-        return 0;
+       return 0;
 }
 
 static void sctp_add_backlog(struct sock *sk, struct sk_buff *skb)
@@ -403,7 +399,7 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
         * Normally, if PMTU discovery is disabled, an ICMP Fragmentation
         * Needed will never be sent, but if a message was sent before
         * PMTU discovery was disabled that was larger than the PMTU, it
-        * would not be fragmented, so it must be re-transmitted fragmented.     
+        * would not be fragmented, so it must be re-transmitted fragmented.
         */
        sctp_retransmit(&asoc->outqueue, t, SCTP_RTXR_PMTUD);
 }
@@ -420,8 +416,8 @@ void sctp_icmp_frag_needed(struct sock *sk, struct sctp_association *asoc,
  *
  */
 void sctp_icmp_proto_unreachable(struct sock *sk,
-                           struct sctp_association *asoc,
-                           struct sctp_transport *t)
+                          struct sctp_association *asoc,
+                          struct sctp_transport *t)
 {
        SCTP_DEBUG_PRINTK("%s\n",  __FUNCTION__);
 
@@ -444,7 +440,6 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
        struct sock *sk = NULL;
        struct sctp_association *asoc;
        struct sctp_transport *transport = NULL;
-       union sctp_addr tmp, tmp2;
 
        *app = NULL; *tpp = NULL;
 
@@ -456,13 +451,11 @@ struct sock *sctp_err_lookup(int family, struct sk_buff *skb,
        /* Initialize local addresses for lookups. */
        af->from_skb(&saddr, skb, 1);
        af->from_skb(&daddr, skb, 0);
-       flip_to_n(&tmp, &saddr);
-       flip_to_n(&tmp2, &daddr);
 
        /* Look for an association that matches the incoming ICMP error
         * packet.
         */
-       asoc = __sctp_lookup_association(&tmp, &tmp2, &transport);
+       asoc = __sctp_lookup_association(&saddr, &daddr, &transport);
        if (!asoc)
                return NULL;
 
@@ -535,7 +528,7 @@ void sctp_v4_err(struct sk_buff *skb, __u32 info)
        /* Fix up skb to look at the embedded net header. */
        saveip = skb->nh.raw;
        savesctp  = skb->h.raw;
-       skb->nh.iph = iph;
+       skb_reset_network_header(skb);
        skb->h.raw = (char *)sh;
        sk = sctp_err_lookup(AF_INET, skb, sh, &asoc, &transport);
        /* Put back, the original pointers. */
@@ -879,11 +872,8 @@ int sctp_has_association(const union sctp_addr *laddr,
 {
        struct sctp_association *asoc;
        struct sctp_transport *transport;
-       union sctp_addr tmp, tmp2;
-       flip_to_n(&tmp, laddr);
-       flip_to_n(&tmp2, paddr);
 
-       if ((asoc = sctp_lookup_association(&tmp, &tmp2, &transport))) {
+       if ((asoc = sctp_lookup_association(laddr, paddr, &transport))) {
                sctp_association_put(asoc);
                return 1;
        }
@@ -921,7 +911,6 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb,
        sctp_init_chunk_t *init;
        struct sctp_transport *transport;
        struct sctp_af *af;
-       union sctp_addr tmp2;
 
        ch = (sctp_chunkhdr_t *) skb->data;
 
@@ -968,10 +957,9 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct sk_buff *skb,
                if (!af)
                        continue;
 
-               af->from_addr_param(paddr, params.addr, ntohs(sh->source), 0);
-               flip_to_n(&tmp2, paddr);
+               af->from_addr_param(paddr, params.addr, sh->source, 0);
 
-               asoc = __sctp_lookup_association(laddr, &tmp2, &transport);
+               asoc = __sctp_lookup_association(laddr, paddr, &transport);
                if (asoc)
                        return asoc;
        }