Re: [RTnet-developers] rtskb_acquire
Brought to you by:
bet-frogger,
kiszka
|
From: Jan K. <jan...@we...> - 2006-08-31 16:12:31
|
Hi Jorge,
Jorge Almeida wrote:
> Hello Jan.
>=20
> Can you please give me a description of wath is done in the rtskb_acqui=
re function in the rtskb.c file line 463.
That function passes the ownership of a rtskb from rtskb->pool to
comp_pool (compensation pool). For this purpose, an empty rtskb is
dequeued from comp_pool and enqueued in rtskb->pool, then rtskb->pool is
set to comp_pool.
>=20
> The rtnet is crashing with an SIG=3D11 in this function when i pass the=
cloned rtskb to the ETH_P_ALL socket.
Where precisely? Already considered to install kgdb for such development?=
>=20
> My clone function is the following:
> /** Clone a rtskb to another, allocating a rtskb for the copy */
> int rtskb_clone(struct rtskb *rtskb_1,struct rtskb *rtskb_2,struct rtsk=
b_queue *pool)
> {
>=20
> rtskb_1 =3D alloc_rtskb(rtskb_2->len,pool);
> if(rtskb_1 =3D=3D NULL)
> return -ENOMEM;
> =20
> =20
> memcpy(rtskb_1->data, rtskb_2->data, rtskb_2->len );
> rtskb_1->len =3D rtskb_2->len;
> rtskb_1->time_stamp =3D rtskb_2->time_stamp;
> rtskb_1->rtdev =3D rtskb_2->rtdev;
> rtskb_1->protocol =3D rtskb_2->protocol;
What about the things that happen in rt_eth_type_trans (except for
rtcap_mark_incoming)? Should case the crash above, but will cause
troubles when processing the rtskb.
> =20
> return 0;
> }
>=20
> I check the path between the driver and the stack manager and only find=
that these fields are necessary.
>=20
> the task manager does the following for the clone rtskb:
>=20
> list_for_each_entry(pt_entry, &rt_packets[hash], list_entry=
)
> {
> rt_printk("List entry protocol=3D %d %d name =3D %d\n",=
> ntohs(pt_entry->type),hash,strncmp(pt_entry->=
name,"PACKET_SOCKET",13));
> //the "PACKET_SOCKET" string is defined in line 188 of =
file af_packet.c
> //this string should be replaced by a #define declarati=
on
> if ( likely(ntohs(pt_entry->type) =3D=3D hash &&=20
> (strncmp(pt_entry->name,"PACKET_SOCKET",13)=
=3D=3D 0 )))
> {
> rtdm_lock_put_irqrestore(&rt_packets_lock, context)=
;
Don't drop the lock here when taking it two lines later again.
> // rt_printk("List entry 1 \n");
> =20
> sock =3D container_of(pt_entry, struct rtsocket,
> prot.packet.packet_type);
Fatal layering violation! This is a hack, the actual cloning should
rather take place inside the invoked handler. Same is true for the
enqueuing. This way you could also avoid to acquire an rtskb that was
already taken from the socket queue (redundant work).
> =20
> rtdm_lock_get_irqsave(&rt_packets_lock, context);
> err =3D rtskb_clone(clone_skb, skb, &sock->skb_pool=
);
> rtdm_lock_put_irqrestore(&rt_packets_lock, context)=
;
> if(err !=3D 0)
> {
> break;
> }
> =20
> rtskb_queue_head(&sock->skb_pool,clone_skb);
> //queue the message to fifo head here
> =20
> =20
> rtdm_lock_get_irqsave(&rt_packets_lock, context);
> pt_entry->refcount++;
> rtdm_lock_put_irqrestore(&rt_packets_lock, context)=
;
> // rt_printk("List entry 2 \n");
> err =3D pt_entry->handler(clone_skb, pt_entry);
> // rt_printk("List entry 3 \n");
> rtdm_lock_get_irqsave(&rt_packets_lock, context);
> pt_entry->refcount--;
> rtdm_lock_put_irqrestore(&rt_packets_lock, context)=
;
>=20
> }
> }
>=20
>=20
> I'm not sure if the cloned rtskb shoul be inserted in the queue head or=
not.
>=20
Move that stuff to af_packet.c.
Jan
|