fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / net / llc / llc_if.c
index 31253d2..a899171 100644 (file)
  *
  * See the GNU General Public License for more details.
  */
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
-#include <linux/tcp.h>
 #include <asm/errno.h>
 #include <net/llc_if.h>
 #include <net/llc_sap.h>
@@ -25,8 +23,7 @@
 #include <net/llc_c_ev.h>
 #include <net/llc_c_ac.h>
 #include <net/llc_c_st.h>
-
-u8 llc_mac_null_var[IFHWADDRLEN];
+#include <net/tcp_states.h>
 
 /**
  *     llc_build_and_send_pkt - Connection data sending for upper layers.
@@ -45,16 +42,13 @@ int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb)
 {
        struct llc_conn_state_ev *ev;
        int rc = -ECONNABORTED;
-       struct llc_opt *llc = llc_sk(sk);
+       struct llc_sock *llc = llc_sk(sk);
 
-       if (llc->state == LLC_CONN_STATE_ADM)
+       if (unlikely(llc->state == LLC_CONN_STATE_ADM))
                goto out;
        rc = -EBUSY;
-       if (llc_data_accept_state(llc->state)) { /* data_conn_refuse */
-               llc->failed_data_req = 1;
-               goto out;
-       }
-       if (llc->p_flag) {
+       if (unlikely(llc_data_accept_state(llc->state) || /* data_conn_refuse */
+                    llc->p_flag)) {
                llc->failed_data_req = 1;
                goto out;
        }
@@ -86,7 +80,7 @@ int llc_establish_connection(struct sock *sk, u8 *lmac, u8 *dmac, u8 dsap)
        int rc = -EISCONN;
        struct llc_addr laddr, daddr;
        struct sk_buff *skb;
-       struct llc_opt *llc = llc_sk(sk);
+       struct llc_sock *llc = llc_sk(sk);
        struct sock *existing;
 
        laddr.lsap = llc->sap->laddr.lsap;
@@ -110,6 +104,7 @@ int llc_establish_connection(struct sock *sk, u8 *lmac, u8 *dmac, u8 dsap)
                ev->type      = LLC_CONN_EV_TYPE_PRIM;
                ev->prim      = LLC_CONN_PRIM;
                ev->prim_type = LLC_PRIM_TYPE_REQ;
+               skb_set_owner_w(skb, sk);
                rc = llc_conn_state_process(sk, skb);
        }
 out_put:
@@ -144,6 +139,7 @@ int llc_send_disc(struct sock *sk)
        skb = alloc_skb(0, GFP_ATOMIC);
        if (!skb)
                goto out;
+       skb_set_owner_w(skb, sk);
        sk->sk_state  = TCP_CLOSING;
        ev            = llc_conn_ev(skb);
        ev->type      = LLC_CONN_EV_TYPE_PRIM;
@@ -155,27 +151,3 @@ out:
        return rc;
 }
 
-/**
- *     llc_build_and_send_reset_pkt - Resets an established LLC connection
- *     @prim: pointer to structure that contains service parameters.
- *
- *     Called when upper layer wants to reset an established LLC connection
- *     with a remote machine. This function packages a proper event and sends
- *     it to connection component state machine. Returns 0 for success, 1
- *     otherwise.
- */
-int llc_build_and_send_reset_pkt(struct sock *sk)
-{
-       int rc = 1;
-       struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
-
-       if (skb) {
-               struct llc_conn_state_ev *ev = llc_conn_ev(skb);
-
-               ev->type      = LLC_CONN_EV_TYPE_PRIM;
-               ev->prim      = LLC_RESET_PRIM;
-               ev->prim_type = LLC_PRIM_TYPE_REQ;
-               rc = llc_conn_state_process(sk, skb);
-       }
-       return rc;
-}