[LLC]: Make llc_frame_alloc take a net_device as an argument

So as to set the newly created sk_buff ->dev member with it, that way we stop
using dev_base->next, that is the wrong thing to do, as there may well be
several interfaces being used with LLC. This was not such a big problem after
all as most of the users of llc_alloc_frame were setting the correct dev, but
this way code is reduced.

This also fixes another bug in llc_station_ac_send_null_dsap_xid_c, that was
not setting the skb->dev field.
Signed-off-by: default avatarJochen Friedrich <jochen@scram.de>
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@mandriva.com>
parent efb0372b
...@@ -13,10 +13,11 @@ ...@@ -13,10 +13,11 @@
*/ */
struct llc_sap; struct llc_sap;
struct sk_buff; struct sk_buff;
struct net_device;
extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb); extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb);
extern void llc_save_primitive(struct sk_buff* skb, unsigned char prim); extern void llc_save_primitive(struct sk_buff* skb, unsigned char prim);
extern struct sk_buff *llc_alloc_frame(void); extern struct sk_buff *llc_alloc_frame(struct net_device *dev);
extern void llc_build_and_send_test_pkt(struct llc_sap *sap, extern void llc_build_and_send_test_pkt(struct llc_sap *sap,
struct sk_buff *skb, struct sk_buff *skb,
......
...@@ -217,13 +217,12 @@ int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2(struct sock *sk, ...@@ -217,13 +217,12 @@ int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2(struct sock *sk,
int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD); llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_disc_cmd(nskb, 1); llc_pdu_init_as_disc_cmd(nskb, 1);
...@@ -243,14 +242,13 @@ free: ...@@ -243,14 +242,13 @@ free:
int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
u8 f_bit; u8 f_bit;
nskb->dev = llc->dev;
llc_pdu_decode_pf_bit(skb, &f_bit); llc_pdu_decode_pf_bit(skb, &f_bit);
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
...@@ -270,14 +268,13 @@ free: ...@@ -270,14 +268,13 @@ free:
int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
u8 f_bit = 1; u8 f_bit = 1;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_dm_rsp(nskb, f_bit); llc_pdu_init_as_dm_rsp(nskb, f_bit);
...@@ -306,11 +303,10 @@ int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb) ...@@ -306,11 +303,10 @@ 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); llc_pdu_decode_pf_bit(skb, &f_bit);
else else
f_bit = 0; f_bit = 0;
nskb = llc_alloc_frame(); nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); 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, f_bit, llc->vS,
...@@ -330,15 +326,14 @@ free: ...@@ -330,15 +326,14 @@ free:
int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
u8 f_bit = 0; u8 f_bit = 0;
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr; struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); 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, f_bit, llc->vS,
...@@ -360,15 +355,14 @@ int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) ...@@ -360,15 +355,14 @@ int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
u8 f_bit; u8 f_bit;
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb; struct sk_buff *nskb;
struct llc_sock *llc = llc_sk(sk);
llc_pdu_decode_pf_bit(skb, &f_bit); llc_pdu_decode_pf_bit(skb, &f_bit);
nskb = llc_alloc_frame(); nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); 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, f_bit, llc->vS,
...@@ -451,13 +445,12 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk, ...@@ -451,13 +445,12 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk,
u8 nr; u8 nr;
struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb);
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
...@@ -487,13 +480,12 @@ int llc_conn_ac_resend_i_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) ...@@ -487,13 +480,12 @@ int llc_conn_ac_resend_i_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD); llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR); llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR);
...@@ -512,14 +504,13 @@ free: ...@@ -512,14 +504,13 @@ free:
int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
u8 f_bit = 1; u8 f_bit = 1;
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR); llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR);
...@@ -538,14 +529,13 @@ free: ...@@ -538,14 +529,13 @@ free:
int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
u8 f_bit = 0; u8 f_bit = 0;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR); llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR);
...@@ -564,13 +554,12 @@ free: ...@@ -564,13 +554,12 @@ free:
int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD); llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR); llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR);
...@@ -589,14 +578,13 @@ free: ...@@ -589,14 +578,13 @@ free:
int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
u8 f_bit = 1; u8 f_bit = 1;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR); llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR);
...@@ -615,14 +603,13 @@ free: ...@@ -615,14 +603,13 @@ free:
int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
u8 f_bit = 0; u8 f_bit = 0;
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR); llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR);
...@@ -653,13 +640,12 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb) ...@@ -653,13 +640,12 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb)
int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR); llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR);
...@@ -678,13 +664,12 @@ free: ...@@ -678,13 +664,12 @@ free:
int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD); llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR); llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR);
...@@ -703,14 +688,13 @@ free: ...@@ -703,14 +688,13 @@ free:
int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
u8 f_bit = 1; u8 f_bit = 1;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR); llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
...@@ -729,14 +713,13 @@ free: ...@@ -729,14 +713,13 @@ free:
int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
u8 f_bit = 1; u8 f_bit = 1;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR); llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR);
...@@ -755,13 +738,12 @@ free: ...@@ -755,13 +738,12 @@ free:
int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
...@@ -780,13 +762,12 @@ free: ...@@ -780,13 +762,12 @@ free:
int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR);
...@@ -815,8 +796,8 @@ void llc_conn_set_p_flag(struct sock *sk, u8 value) ...@@ -815,8 +796,8 @@ void llc_conn_set_p_flag(struct sock *sk, u8 value)
int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame();
struct llc_sock *llc = llc_sk(sk); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
...@@ -824,7 +805,6 @@ int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) ...@@ -824,7 +805,6 @@ int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb)
if (llc->dev->flags & IFF_LOOPBACK) if (llc->dev->flags & IFF_LOOPBACK)
dmac = llc->dev->dev_addr; dmac = llc->dev->dev_addr;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_CMD); llc->daddr.lsap, LLC_PDU_CMD);
llc_pdu_init_as_sabme_cmd(nskb, 1); llc_pdu_init_as_sabme_cmd(nskb, 1);
...@@ -845,11 +825,11 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) ...@@ -845,11 +825,11 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb)
{ {
u8 f_bit; u8 f_bit;
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
llc_pdu_decode_pf_bit(skb, &f_bit); llc_pdu_decode_pf_bit(skb, &f_bit);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev; nskb->dev = llc->dev;
...@@ -1001,13 +981,12 @@ static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk, ...@@ -1001,13 +981,12 @@ static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk,
struct sk_buff *skb) struct sk_buff *skb)
{ {
int rc = -ENOBUFS; int rc = -ENOBUFS;
struct sk_buff *nskb = llc_alloc_frame(); struct llc_sock *llc = llc_sk(sk);
struct sk_buff *nskb = llc_alloc_frame(llc->dev);
if (nskb) { if (nskb) {
struct llc_sock *llc = llc_sk(sk);
struct llc_sap *sap = llc->sap; struct llc_sap *sap = llc->sap;
nskb->dev = llc->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap,
llc->daddr.lsap, LLC_PDU_RSP); llc->daddr.lsap, LLC_PDU_RSP);
llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR); llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR);
......
...@@ -103,10 +103,9 @@ int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb) ...@@ -103,10 +103,9 @@ int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb)
llc_pdu_decode_sa(skb, mac_da); llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_da(skb, mac_sa); llc_pdu_decode_da(skb, mac_sa);
llc_pdu_decode_ssap(skb, &dsap); llc_pdu_decode_ssap(skb, &dsap);
nskb = llc_alloc_frame(); nskb = llc_alloc_frame(skb->dev);
if (!nskb) if (!nskb)
goto out; goto out;
nskb->dev = skb->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
LLC_PDU_RSP); LLC_PDU_RSP);
llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0); llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0);
...@@ -149,10 +148,9 @@ int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb) ...@@ -149,10 +148,9 @@ int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb)
llc_pdu_decode_sa(skb, mac_da); llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_da(skb, mac_sa); llc_pdu_decode_da(skb, mac_sa);
llc_pdu_decode_ssap(skb, &dsap); llc_pdu_decode_ssap(skb, &dsap);
nskb = llc_alloc_frame(); nskb = llc_alloc_frame(skb->dev);
if (!nskb) if (!nskb)
goto out; goto out;
nskb->dev = skb->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap, llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
LLC_PDU_RSP); LLC_PDU_RSP);
llc_pdu_init_as_test_rsp(nskb, skb); llc_pdu_init_as_test_rsp(nskb, skb);
......
...@@ -26,11 +26,12 @@ ...@@ -26,11 +26,12 @@
/** /**
* llc_alloc_frame - allocates sk_buff for frame * llc_alloc_frame - allocates sk_buff for frame
* @dev: network device this skb will be sent over
* *
* Allocates an sk_buff for frame and initializes sk_buff fields. * Allocates an sk_buff for frame and initializes sk_buff fields.
* Returns allocated skb or %NULL when out of memory. * Returns allocated skb or %NULL when out of memory.
*/ */
struct sk_buff *llc_alloc_frame(void) struct sk_buff *llc_alloc_frame(struct net_device *dev)
{ {
struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC); struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC);
...@@ -38,7 +39,7 @@ struct sk_buff *llc_alloc_frame(void) ...@@ -38,7 +39,7 @@ struct sk_buff *llc_alloc_frame(void)
skb_reserve(skb, 50); skb_reserve(skb, 50);
skb->nh.raw = skb->h.raw = skb->data; skb->nh.raw = skb->h.raw = skb->data;
skb->protocol = htons(ETH_P_802_2); skb->protocol = htons(ETH_P_802_2);
skb->dev = dev_base->next; skb->dev = dev;
skb->mac.raw = skb->head; skb->mac.raw = skb->head;
} }
return skb; return skb;
......
...@@ -249,7 +249,7 @@ static int llc_station_ac_inc_xid_r_cnt_by_1(struct sk_buff *skb) ...@@ -249,7 +249,7 @@ static int llc_station_ac_inc_xid_r_cnt_by_1(struct sk_buff *skb)
static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff *skb) static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff *skb)
{ {
int rc = 1; int rc = 1;
struct sk_buff *nskb = llc_alloc_frame(); struct sk_buff *nskb = llc_alloc_frame(skb->dev);
if (!nskb) if (!nskb)
goto out; goto out;
...@@ -270,12 +270,11 @@ static int llc_station_ac_send_xid_r(struct sk_buff *skb) ...@@ -270,12 +270,11 @@ static int llc_station_ac_send_xid_r(struct sk_buff *skb)
{ {
u8 mac_da[ETH_ALEN], dsap; u8 mac_da[ETH_ALEN], dsap;
int rc = 1; int rc = 1;
struct sk_buff* nskb = llc_alloc_frame(); struct sk_buff* nskb = llc_alloc_frame(skb->dev);
if (!nskb) if (!nskb)
goto out; goto out;
rc = 0; rc = 0;
nskb->dev = skb->dev;
llc_pdu_decode_sa(skb, mac_da); llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_ssap(skb, &dsap); llc_pdu_decode_ssap(skb, &dsap);
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP); llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
...@@ -295,12 +294,11 @@ static int llc_station_ac_send_test_r(struct sk_buff *skb) ...@@ -295,12 +294,11 @@ static int llc_station_ac_send_test_r(struct sk_buff *skb)
{ {
u8 mac_da[ETH_ALEN], dsap; u8 mac_da[ETH_ALEN], dsap;
int rc = 1; int rc = 1;
struct sk_buff *nskb = llc_alloc_frame(); struct sk_buff *nskb = llc_alloc_frame(skb->dev);
if (!nskb) if (!nskb)
goto out; goto out;
rc = 0; rc = 0;
nskb->dev = skb->dev;
llc_pdu_decode_sa(skb, mac_da); llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_ssap(skb, &dsap); llc_pdu_decode_ssap(skb, &dsap);
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP); llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment