Thread (5 messages) 5 messages, 2 authors, 2003-03-20

Re: Casting (struct rtable*) to (struct dst_entry*)

From: N N Ashok <hidden>
Date: 2003-03-20 05:27:41

On Wednesday 19 March 2003 23:59, David S. Miller wrote:
   From: N N Ashok [off-list ref]
   Date: Wed, 19 Mar 2003 23:55:02 -0500

   I am unable to understand how a rtable structure casted to dst_entry
will give a correct pointer to the input() function. I looked at the fields
in rtable and dst_entry, the fields in the structures are cannot be lined
up (the fourth field in rtable is not the same type as the fourth field in
dst_entry).

"struct rtable" starts with a "struct dst_entry"
Thanks David.

I did see that. But however, I could not understand how "struct rtable" can be 
casted to "struct dst_entry" and then back again, all the while accessing 
fields of both structures. When the (struct rtable *)rth is filled in 
ip_route_input(), the variables accessed are those of rtable. Then rth is 
cast to (struct dst_entry *) and assigned to skb->dst (which is of type 
struct dst_entry *). 
After this, in ip_rcv_finish(), the field of dst_entry is accessed as in:
skb->dst->input(). I am unable to understand how, data filled in as rtable 
fields will be valid when accessed as dst_entry fields.
Later in ip_forward() (for a packet to be forwarded), the skb->dst is cast to 
(struct rtable *) and its fields accessed.

A correction to the previous post: the skb->dst->input() is invoked in 
ip_rcv_finish() and not in ip_route_input() as mentioned in the post.

Thanks,
Ashok
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help