Merge branch 'master' of ssh://master.kernel.org/pub/scm/linux/kernel/git/linville...
[safe/jmp/linux-2.6] / net / llc / llc_c_ac.c
index db98ea2..019c780 100644 (file)
@@ -27,7 +27,6 @@
 #include <net/llc_pdu.h>
 #include <net/llc.h>
 
-#include "llc_output.h"
 
 static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb);
 static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb);
@@ -60,23 +59,10 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb)
 
 int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb)
 {
-       int rc = -ENOTCONN;
-       u8 dsap;
-       struct llc_sap *sap;
-
-       llc_pdu_decode_dsap(skb, &dsap);
-       sap = llc_sap_find(dsap);
-       if (sap) {
-               struct llc_conn_state_ev *ev = llc_conn_ev(skb);
-               struct llc_sock *llc = llc_sk(sk);
+       struct llc_conn_state_ev *ev = llc_conn_ev(skb);
 
-               llc_pdu_decode_sa(skb, llc->daddr.mac);
-               llc_pdu_decode_da(skb, llc->laddr.mac);
-               llc->dev = skb->dev;
-               ev->ind_prim = LLC_CONN_PRIM;
-               rc = 0;
-       }
-       return rc;
+       ev->ind_prim = LLC_CONN_PRIM;
+       return 0;
 }
 
 int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb)
@@ -120,10 +106,8 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct sk_buff *skb)
                        reason = LLC_DISC_REASON_RX_DISC_CMD_PDU;
        } else if (ev->type == LLC_CONN_EV_TYPE_ACK_TMR)
                reason = LLC_DISC_REASON_ACK_TMR_EXP;
-       else {
-               reason = 0;
+       else
                rc = -EINVAL;
-       }
        if (!rc) {
                ev->reason   = reason;
                ev->ind_prim = LLC_DISC_PRIM;
@@ -160,9 +144,6 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb)
                           LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME) {
                        reason = LLC_RESET_REASON_REMOTE;
                        rc = 0;
-               } else {
-                       reason = 0;
-                       rc  = 1;
                }
                break;
        case LLC_CONN_EV_TYPE_ACK_TMR:
@@ -172,8 +153,7 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb)
                if (llc->retry_count > llc->n2) {
                        reason = LLC_RESET_REASON_LOCAL;
                        rc = 0;
-               } else
-                       rc = 1;
+               }
                break;
        }
        if (!rc) {
@@ -218,7 +198,7 @@ int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -227,7 +207,7 @@ int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_CMD);
                llc_pdu_init_as_disc_cmd(nskb, 1);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
                llc_conn_ac_set_p_flag_1(sk, skb);
@@ -243,7 +223,7 @@ int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -254,7 +234,7 @@ int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_RSP);
                llc_pdu_init_as_dm_rsp(nskb, f_bit);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -269,17 +249,16 @@ int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
-               u8 f_bit = 1;
 
                llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
                                    llc->daddr.lsap, LLC_PDU_RSP);
-               llc_pdu_init_as_dm_rsp(nskb, f_bit);
+               llc_pdu_init_as_dm_rsp(nskb, 1);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -303,7 +282,8 @@ int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb)
                llc_pdu_decode_pf_bit(skb, &f_bit);
        else
                f_bit = 0;
-       nskb = llc_alloc_frame(llc->dev);
+       nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
+                              sizeof(struct llc_frmr_info));
        if (nskb) {
                struct llc_sap *sap = llc->sap;
 
@@ -312,7 +292,7 @@ int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb)
                llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
                                         llc->vR, INCORRECT);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -327,19 +307,19 @@ int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
+                                              sizeof(struct llc_frmr_info));
 
        if (nskb) {
-               u8 f_bit = 0;
                struct llc_sap *sap = llc->sap;
                struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr;
 
                llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
                                    llc->daddr.lsap, LLC_PDU_RSP);
-               llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
+               llc_pdu_init_as_frmr_rsp(nskb, pdu, 0, llc->vS,
                                         llc->vR, INCORRECT);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -358,7 +338,8 @@ int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
        struct llc_sock *llc = llc_sk(sk);
 
        llc_pdu_decode_pf_bit(skb, &f_bit);
-       nskb = llc_alloc_frame(llc->dev);
+       nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U,
+                              sizeof(struct llc_frmr_info));
        if (nskb) {
                struct llc_sap *sap = llc->sap;
                struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
@@ -368,7 +349,7 @@ int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
                llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS,
                                         llc->vR, INCORRECT);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -389,7 +370,7 @@ int llc_conn_ac_send_i_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
                            llc->daddr.lsap, LLC_PDU_CMD);
        llc_pdu_init_as_i_cmd(skb, 1, llc->vS, llc->vR);
        rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
-       if (!rc) {
+       if (likely(!rc)) {
                llc_conn_send_pdu(sk, skb);
                llc_conn_ac_inc_vs_by_1(sk, skb);
        }
@@ -406,7 +387,7 @@ static int llc_conn_ac_send_i_cmd_p_set_0(struct sock *sk, struct sk_buff *skb)
                            llc->daddr.lsap, LLC_PDU_CMD);
        llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR);
        rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
-       if (!rc) {
+       if (likely(!rc)) {
                llc_conn_send_pdu(sk, skb);
                llc_conn_ac_inc_vs_by_1(sk, skb);
        }
@@ -423,7 +404,7 @@ int llc_conn_ac_send_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
                            llc->daddr.lsap, LLC_PDU_CMD);
        llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR);
        rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
-       if (!rc) {
+       if (likely(!rc)) {
                llc_conn_send_pdu(sk, skb);
                llc_conn_ac_inc_vs_by_1(sk, skb);
        }
@@ -446,7 +427,7 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
        struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -455,7 +436,7 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
                                    llc->daddr.lsap, LLC_PDU_RSP);
                llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (!rc)
+               if (likely(!rc))
                        llc_conn_send_pdu(sk, nskb);
                else
                        kfree_skb(skb);
@@ -481,7 +462,7 @@ int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -490,7 +471,7 @@ int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_CMD);
                llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -505,17 +486,16 @@ int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
-               u8 f_bit = 1;
                struct llc_sap *sap = llc->sap;
 
                llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
                                    llc->daddr.lsap, LLC_PDU_RSP);
-               llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR);
+               llc_pdu_init_as_rej_rsp(nskb, 1, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -530,17 +510,16 @@ int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
-               u8 f_bit = 0;
 
                llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
                                    llc->daddr.lsap, LLC_PDU_RSP);
-               llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR);
+               llc_pdu_init_as_rej_rsp(nskb, 0, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -555,7 +534,7 @@ int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -564,7 +543,7 @@ int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_CMD);
                llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -579,17 +558,16 @@ int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
-               u8 f_bit = 1;
 
                llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
                                    llc->daddr.lsap, LLC_PDU_RSP);
-               llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR);
+               llc_pdu_init_as_rnr_rsp(nskb, 1, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -604,17 +582,16 @@ int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
-               u8 f_bit = 0;
                struct llc_sap *sap = llc->sap;
 
                llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
                                    llc->daddr.lsap, LLC_PDU_RSP);
-               llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR);
+               llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -632,7 +609,7 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
        if (!llc->remote_busy_flag) {
                llc->remote_busy_flag = 1;
                mod_timer(&llc->busy_state_timer.timer,
-                        jiffies + llc->busy_state_timer.expire * HZ);
+                        jiffies + llc->busy_state_timer.expire);
        }
        return 0;
 }
@@ -641,7 +618,7 @@ int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -650,7 +627,7 @@ int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_RSP);
                llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -665,7 +642,7 @@ int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -674,7 +651,7 @@ int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_CMD);
                llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -689,7 +666,7 @@ int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -699,7 +676,7 @@ int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_RSP);
                llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -714,17 +691,16 @@ int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
-               u8 f_bit = 1;
 
                llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
                                    llc->daddr.lsap, LLC_PDU_RSP);
-               llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
+               llc_pdu_init_as_rr_rsp(nskb, 1, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -739,7 +715,7 @@ int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -748,7 +724,7 @@ int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_RSP);
                llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -763,7 +739,7 @@ int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -772,7 +748,7 @@ int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_RSP);
                llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -797,7 +773,7 @@ int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -809,7 +785,7 @@ int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_CMD);
                llc_pdu_init_as_sabme_cmd(nskb, 1);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, dmac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
                llc_conn_set_p_flag(sk, 1);
@@ -826,7 +802,7 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
        u8 f_bit;
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_U, 0);
 
        llc_pdu_decode_pf_bit(skb, &f_bit);
        if (nskb) {
@@ -837,7 +813,7 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
                                    llc->daddr.lsap, LLC_PDU_RSP);
                llc_pdu_init_as_ua_rsp(nskb, f_bit);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -866,7 +842,7 @@ int llc_conn_ac_start_p_timer(struct sock *sk, struct sk_buff *skb)
 
        llc_conn_set_p_flag(sk, 1);
        mod_timer(&llc->pf_cycle_timer.timer,
-                 jiffies + llc->pf_cycle_timer.expire * HZ);
+                 jiffies + llc->pf_cycle_timer.expire);
        return 0;
 }
 
@@ -892,7 +868,8 @@ int llc_conn_ac_send_ack_if_needed(struct sock *sk, struct sk_buff *skb)
                llc->ack_must_be_send = 1;
                llc->ack_pf = pf_bit & 1;
        }
-       if (((llc->vR - llc->first_pdu_Ns + 129) % 128) >= llc->npta) {
+       if (((llc->vR - llc->first_pdu_Ns + 1 + LLC_2_SEQ_NBR_MODULO)
+                       % LLC_2_SEQ_NBR_MODULO) >= llc->npta) {
                llc_conn_ac_send_rr_rsp_f_set_ackpf(sk, skb);
                llc->ack_must_be_send   = 0;
                llc->ack_pf             = 0;
@@ -937,7 +914,7 @@ static int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock *sk,
                            llc->daddr.lsap, LLC_PDU_RSP);
        llc_pdu_init_as_i_cmd(skb, llc->ack_pf, llc->vS, llc->vR);
        rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac);
-       if (!rc) {
+       if (likely(!rc)) {
                llc_conn_send_pdu(sk, skb);
                llc_conn_ac_inc_vs_by_1(sk, skb);
        }
@@ -982,7 +959,7 @@ static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
 {
        int rc = -ENOBUFS;
        struct llc_sock *llc = llc_sk(sk);
-       struct sk_buff *nskb = llc_alloc_frame(llc->dev);
+       struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev, LLC_PDU_TYPE_S, 0);
 
        if (nskb) {
                struct llc_sap *sap = llc->sap;
@@ -991,7 +968,7 @@ static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
                                    llc->daddr.lsap, LLC_PDU_RSP);
                llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR);
                rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac);
-               if (rc)
+               if (unlikely(rc))
                        goto free;
                llc_conn_send_pdu(sk, nskb);
        }
@@ -1020,8 +997,8 @@ static int llc_conn_ac_inc_npta_value(struct sock *sk, struct sk_buff *skb)
                llc->dec_step = 0;
                llc->dec_cntr = llc->inc_cntr = 2;
                ++llc->npta;
-               if (llc->npta > 127)
-                       llc->npta = 127 ;
+               if (llc->npta > (u8) ~LLC_2_SEQ_NBR_MODULO)
+                       llc->npta = (u8) ~LLC_2_SEQ_NBR_MODULO;
        } else
                --llc->inc_cntr;
        return 0;
@@ -1091,9 +1068,10 @@ int llc_conn_ac_dec_tx_win_size(struct sock *sk, struct sk_buff *skb)
        struct llc_sock *llc = llc_sk(sk);
        u8 unacked_pdu = skb_queue_len(&llc->pdu_unack_q);
 
-       llc->k -= unacked_pdu;
-       if (llc->k < 2)
-               llc->k = 2;
+       if (llc->k - unacked_pdu < 1)
+               llc->k = 1;
+       else
+               llc->k -= unacked_pdu;
        return 0;
 }
 
@@ -1110,8 +1088,8 @@ int llc_conn_ac_inc_tx_win_size(struct sock *sk, struct sk_buff *skb)
        struct llc_sock *llc = llc_sk(sk);
 
        llc->k += 1;
-       if (llc->k > 128)
-               llc->k = 128 ;
+       if (llc->k > (u8) ~LLC_2_SEQ_NBR_MODULO)
+               llc->k = (u8) ~LLC_2_SEQ_NBR_MODULO;
        return 0;
 }
 
@@ -1144,7 +1122,7 @@ int llc_conn_ac_start_ack_timer(struct sock *sk, struct sk_buff *skb)
 {
        struct llc_sock *llc = llc_sk(sk);
 
-       mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire * HZ);
+       mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire);
        return 0;
 }
 
@@ -1153,7 +1131,7 @@ int llc_conn_ac_start_rej_timer(struct sock *sk, struct sk_buff *skb)
        struct llc_sock *llc = llc_sk(sk);
 
        mod_timer(&llc->rej_sent_timer.timer,
-                 jiffies + llc->rej_sent_timer.expire * HZ);
+                 jiffies + llc->rej_sent_timer.expire);
        return 0;
 }
 
@@ -1164,7 +1142,7 @@ int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk,
 
        if (!timer_pending(&llc->ack_timer.timer))
                mod_timer(&llc->ack_timer.timer,
-                         jiffies + llc->ack_timer.expire * HZ);
+                         jiffies + llc->ack_timer.expire);
        return 0;
 }
 
@@ -1212,7 +1190,7 @@ int llc_conn_ac_upd_nr_received(struct sock *sk, struct sk_buff *skb)
                }
                if (unacked)
                        mod_timer(&llc->ack_timer.timer,
-                                 jiffies + llc->ack_timer.expire * HZ);
+                                 jiffies + llc->ack_timer.expire);
        } else if (llc->failed_data_req) {
                u8 f_bit;
 
@@ -1333,13 +1311,13 @@ int llc_conn_ac_set_vs_nr(struct sock *sk, struct sk_buff *skb)
        return 0;
 }
 
-int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb)
+static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb)
 {
-       llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % 128;
+       llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % LLC_2_SEQ_NBR_MODULO;
        return 0;
 }
 
-void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data)
+static void llc_conn_tmr_common_cb(unsigned long timeout_data, u8 type)
 {
        struct sock *sk = (struct sock *)timeout_data;
        struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
@@ -1348,59 +1326,31 @@ void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data)
        if (skb) {
                struct llc_conn_state_ev *ev = llc_conn_ev(skb);
 
-               skb->sk  = sk;
-               ev->type = LLC_CONN_EV_TYPE_P_TMR;
+               skb_set_owner_r(skb, sk);
+               ev->type = type;
                llc_process_tmr_ev(sk, skb);
        }
        bh_unlock_sock(sk);
 }
 
-void llc_conn_busy_tmr_cb(unsigned long timeout_data)
+void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data)
 {
-       struct sock *sk = (struct sock *)timeout_data;
-       struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
-
-       bh_lock_sock(sk);
-       if (skb) {
-               struct llc_conn_state_ev *ev = llc_conn_ev(skb);
+       llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_P_TMR);
+}
 
-               skb->sk  = sk;
-               ev->type = LLC_CONN_EV_TYPE_BUSY_TMR;
-               llc_process_tmr_ev(sk, skb);
-       }
-       bh_unlock_sock(sk);
+void llc_conn_busy_tmr_cb(unsigned long timeout_data)
+{
+       llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_BUSY_TMR);
 }
 
 void llc_conn_ack_tmr_cb(unsigned long timeout_data)
 {
-       struct sock* sk = (struct sock *)timeout_data;
-       struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
-
-       bh_lock_sock(sk);
-       if (skb) {
-               struct llc_conn_state_ev *ev = llc_conn_ev(skb);
-
-               skb->sk  = sk;
-               ev->type = LLC_CONN_EV_TYPE_ACK_TMR;
-               llc_process_tmr_ev(sk, skb);
-       }
-       bh_unlock_sock(sk);
+       llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_ACK_TMR);
 }
 
 void llc_conn_rej_tmr_cb(unsigned long timeout_data)
 {
-       struct sock *sk = (struct sock *)timeout_data;
-       struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC);
-
-       bh_lock_sock(sk);
-       if (skb) {
-               struct llc_conn_state_ev *ev = llc_conn_ev(skb);
-
-               skb->sk  = sk;
-               ev->type = LLC_CONN_EV_TYPE_REJ_TMR;
-               llc_process_tmr_ev(sk, skb);
-       }
-       bh_unlock_sock(sk);
+       llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_REJ_TMR);
 }
 
 int llc_conn_ac_rst_vs(struct sock *sk, struct sk_buff *skb)
@@ -1480,7 +1430,7 @@ static void llc_process_tmr_ev(struct sock *sk, struct sk_buff *skb)
 {
        if (llc_sk(sk)->state == LLC_CONN_OUT_OF_SVC) {
                printk(KERN_WARNING "%s: timer called on closed connection\n",
-                      __FUNCTION__);
+                      __func__);
                kfree_skb(skb);
        } else {
                if (!sock_owned_by_user(sk))