Merge to Fedora kernel-2.6.18-1.2224_FC5 patched with stable patch-2.6.18.1-vs2.0...
[linux-2.6.git] / net / ax25 / ax25_in.c
index 01a2c86..e9d9429 100644 (file)
@@ -9,7 +9,6 @@
  * Copyright (C) Joerg Reuter DL1BKE (jreuter@yaina.de)
  * Copyright (C) Hans-Joachim Hetscher DD8NE (dd8ne@bnv-bamberg.de)
  */
-#include <linux/config.h>
 #include <linux/errno.h>
 #include <linux/types.h>
 #include <linux/socket.h>
@@ -26,9 +25,7 @@
 #include <linux/skbuff.h>
 #include <linux/netfilter.h>
 #include <net/sock.h>
-#include <net/ip.h>                    /* For ip_rcv */
-#include <net/tcp.h>
-#include <net/arp.h>                   /* For arp_rcv */
+#include <net/tcp_states.h>
 #include <asm/uaccess.h>
 #include <asm/system.h>
 #include <linux/fcntl.h>
@@ -105,8 +102,8 @@ static int ax25_rx_fragment(ax25_cb *ax25, struct sk_buff *skb)
 int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb)
 {
        int (*func)(struct sk_buff *, ax25_cb *);
-       volatile int queued = 0;
        unsigned char pid;
+       int queued = 0;
 
        if (skb == NULL) return 0;
 
@@ -114,7 +111,6 @@ int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb)
 
        pid = *skb->data;
 
-#ifdef CONFIG_INET
        if (pid == AX25_P_IP) {
                /* working around a TCP bug to keep additional listeners
                 * happy. TCP re-uses the buffer and destroys the original
@@ -127,15 +123,14 @@ int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb)
                }
 
                skb_pull(skb, 1);       /* Remove PID */
-               skb->h.raw    = skb->data;
+               skb->mac.raw  = skb->nh.raw;
                skb->nh.raw   = skb->data;
                skb->dev      = ax25->ax25_dev->dev;
                skb->pkt_type = PACKET_HOST;
                skb->protocol = htons(ETH_P_IP);
-               ip_rcv(skb, skb->dev, NULL);    /* Wrong ptype */
+               netif_rx(skb);
                return 1;
        }
-#endif
        if (pid == AX25_P_SEGMENT) {
                skb_pull(skb, 1);       /* Remove PID */
                return ax25_rx_fragment(ax25, skb);
@@ -250,7 +245,6 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
 
                /* Now we are pointing at the pid byte */
                switch (skb->data[1]) {
-#ifdef CONFIG_INET
                case AX25_P_IP:
                        skb_pull(skb,2);                /* drop PID/CTRL */
                        skb->h.raw    = skb->data;
@@ -258,7 +252,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
                        skb->dev      = dev;
                        skb->pkt_type = PACKET_HOST;
                        skb->protocol = htons(ETH_P_IP);
-                       ip_rcv(skb, dev, ptype);        /* Note ptype here is the wrong one, fix me later */
+                       netif_rx(skb);
                        break;
 
                case AX25_P_ARP:
@@ -268,13 +262,13 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
                        skb->dev      = dev;
                        skb->pkt_type = PACKET_HOST;
                        skb->protocol = htons(ETH_P_ARP);
-                       arp_rcv(skb, dev, ptype);       /* Note ptype here is wrong... */
+                       netif_rx(skb);
                        break;
-#endif
                case AX25_P_TEXT:
                        /* Now find a suitable dgram socket */
                        sk = ax25_get_socket(&dest, &src, SOCK_DGRAM);
                        if (sk != NULL) {
+                               bh_lock_sock(sk);
                                if (atomic_read(&sk->sk_rmem_alloc) >=
                                    sk->sk_rcvbuf) {
                                        kfree_skb(skb);
@@ -286,7 +280,8 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
                                        if (sock_queue_rcv_skb(sk, skb) != 0)
                                                kfree_skb(skb);
                                }
-                               release_sock(sk);
+                               bh_unlock_sock(sk);
+                               sock_put(sk);
                        } else {
                                kfree_skb(skb);
                        }
@@ -356,7 +351,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
 
        if (sk != NULL) {
                bh_lock_sock(sk);
-               if (sk->sk_ack_backlog == sk->sk_max_ack_backlog ||
+               if (sk_acceptq_is_full(sk) ||
                    (make = ax25_make_new(sk, ax25_dev)) == NULL) {
                        if (mine)
                                ax25_return_dm(dev, &src, &dest, &dp);
@@ -406,10 +401,8 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
        }
 
        if (dp.ndigi == 0) {
-               if (ax25->digipeat != NULL) {
-                       kfree(ax25->digipeat);
-                       ax25->digipeat = NULL;
-               }
+               kfree(ax25->digipeat);
+               ax25->digipeat = NULL;
        } else {
                /* Reverse the source SABM's path */
                memcpy(ax25->digipeat, &reverse_dp, sizeof(ax25_digi));
@@ -452,7 +445,7 @@ static int ax25_rcv(struct sk_buff *skb, struct net_device *dev,
  *     Receive an AX.25 frame via a SLIP interface.
  */
 int ax25_kiss_rcv(struct sk_buff *skb, struct net_device *dev,
-                 struct packet_type *ptype)
+                 struct packet_type *ptype, struct net_device *orig_dev)
 {
        skb->sk = NULL;         /* Initially we don't know who it's for */
        skb->destructor = NULL; /* Who initializes this, dammit?! */