[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 @@
*/
struct llc_sap;
struct sk_buff;
struct net_device;
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 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,
struct sk_buff *skb,
......
This diff is collapsed.
......@@ -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_da(skb, mac_sa);
llc_pdu_decode_ssap(skb, &dsap);
nskb = llc_alloc_frame();
nskb = llc_alloc_frame(skb->dev);
if (!nskb)
goto out;
nskb->dev = skb->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
LLC_PDU_RSP);
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)
llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_da(skb, mac_sa);
llc_pdu_decode_ssap(skb, &dsap);
nskb = llc_alloc_frame();
nskb = llc_alloc_frame(skb->dev);
if (!nskb)
goto out;
nskb->dev = skb->dev;
llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap,
LLC_PDU_RSP);
llc_pdu_init_as_test_rsp(nskb, skb);
......
......@@ -26,11 +26,12 @@
/**
* 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.
* 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);
......@@ -38,7 +39,7 @@ struct sk_buff *llc_alloc_frame(void)
skb_reserve(skb, 50);
skb->nh.raw = skb->h.raw = skb->data;
skb->protocol = htons(ETH_P_802_2);
skb->dev = dev_base->next;
skb->dev = dev;
skb->mac.raw = skb->head;
}
return 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)
{
int rc = 1;
struct sk_buff *nskb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame(skb->dev);
if (!nskb)
goto out;
......@@ -270,12 +270,11 @@ static int llc_station_ac_send_xid_r(struct sk_buff *skb)
{
u8 mac_da[ETH_ALEN], dsap;
int rc = 1;
struct sk_buff* nskb = llc_alloc_frame();
struct sk_buff* nskb = llc_alloc_frame(skb->dev);
if (!nskb)
goto out;
rc = 0;
nskb->dev = skb->dev;
llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_ssap(skb, &dsap);
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)
{
u8 mac_da[ETH_ALEN], dsap;
int rc = 1;
struct sk_buff *nskb = llc_alloc_frame();
struct sk_buff *nskb = llc_alloc_frame(skb->dev);
if (!nskb)
goto out;
rc = 0;
nskb->dev = skb->dev;
llc_pdu_decode_sa(skb, mac_da);
llc_pdu_decode_ssap(skb, &dsap);
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