[SK_BUFF]: Introduce ip_hdr(), remove skb->nh.iph
[pandora-kernel.git] / net / sctp / ipv6.c
index 3c3e560..742f9ff 100644 (file)
@@ -53,7 +53,6 @@
 #include <linux/socket.h>
 #include <linux/sockios.h>
 #include <linux/net.h>
-#include <linux/sched.h>
 #include <linux/in.h>
 #include <linux/in6.h>
 #include <linux/netdevice.h>
 
 #include <asm/uaccess.h>
 
+/* Event handler for inet6 address addition/deletion events.  */
+static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev,
+                               void *ptr)
+{
+       struct inet6_ifaddr *ifa = (struct inet6_ifaddr *)ptr;
+       struct sctp_sockaddr_entry *addr;
+       struct list_head *pos, *temp;
+
+       switch (ev) {
+       case NETDEV_UP:
+               addr = kmalloc(sizeof(struct sctp_sockaddr_entry), GFP_ATOMIC);
+               if (addr) {
+                       addr->a.v6.sin6_family = AF_INET6;
+                       addr->a.v6.sin6_port = 0;
+                       memcpy(&addr->a.v6.sin6_addr, &ifa->addr,
+                                sizeof(struct in6_addr));
+                       addr->a.v6.sin6_scope_id = ifa->idev->dev->ifindex;
+                       list_add_tail(&addr->list, &sctp_local_addr_list);
+               }
+               break;
+       case NETDEV_DOWN:
+               list_for_each_safe(pos, temp, &sctp_local_addr_list) {
+                       addr = list_entry(pos, struct sctp_sockaddr_entry, list);
+                       if (ipv6_addr_equal(&addr->a.v6.sin6_addr, &ifa->addr)) {
+                               list_del(pos);
+                               kfree(addr);
+                               break;
+                       }
+               }
+
+               break;
+       }
+
+       return NOTIFY_DONE;
+}
+
 static struct notifier_block sctp_inet6addr_notifier = {
-       .notifier_call = sctp_inetaddr_event,
+       .notifier_call = sctp_inet6addr_event,
 };
 
 /* ICMP error handler. */
@@ -87,7 +122,6 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
                             int type, int code, int offset, __be32 info)
 {
        struct inet6_dev *idev;
-       struct ipv6hdr *iph = (struct ipv6hdr *)skb->data;
        struct sctphdr *sh = (struct sctphdr *)(skb->data + offset);
        struct sock *sk;
        struct sctp_association *asoc;
@@ -101,7 +135,7 @@ SCTP_STATIC void sctp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        /* Fix up skb to look at the embedded net header. */
        saveip = skb->nh.raw;
        savesctp  = skb->h.raw;
-       skb->nh.ipv6h = iph;
+       skb_reset_network_header(skb);
        skb->h.raw = (char *)sh;
        sk = sctp_err_lookup(AF_INET6, skb, sh, &asoc, &transport);
        /* Put back, the original pointers. */
@@ -200,7 +234,7 @@ static struct dst_entry *sctp_v6_get_dst(struct sctp_association *asoc,
        ipv6_addr_copy(&fl.fl6_dst, &daddr->v6.sin6_addr);
        if (ipv6_addr_type(&daddr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL)
                fl.oif = daddr->v6.sin6_scope_id;
-       
+
 
        SCTP_DEBUG_PRINTK("%s: DST=" NIP6_FMT " ",
                          __FUNCTION__, NIP6(fl.fl6_dst));
@@ -325,7 +359,7 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist,
                return;
        }
 
-       read_lock(&in6_dev->lock);
+       read_lock_bh(&in6_dev->lock);
        for (ifp = in6_dev->addr_list; ifp; ifp = ifp->if_next) {
                /* Add the address to the local list.  */
                addr = t_new(struct sctp_sockaddr_entry, GFP_ATOMIC);
@@ -339,7 +373,7 @@ static void sctp_v6_copy_addrlist(struct list_head *addrlist,
                }
        }
 
-       read_unlock(&in6_dev->lock);
+       read_unlock_bh(&in6_dev->lock);
        rcu_read_unlock();
 }
 
@@ -736,9 +770,9 @@ static void sctp_inet6_skb_msgname(struct sk_buff *skb, char *msgname,
 
                /* Map ipv4 address into v4-mapped-on-v6 address. */
                if (sctp_sk(skb->sk)->v4mapped &&
-                   skb->nh.iph->version == 4) {
+                   ip_hdr(skb)->version == 4) {
                        sctp_v4_map_v6((union sctp_addr *)sin6);
-                       sin6->sin6_addr.s6_addr32[3] = skb->nh.iph->saddr;
+                       sin6->sin6_addr.s6_addr32[3] = ip_hdr(skb)->saddr;
                        return;
                }