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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wednesday 19 March 2003 23:59, David S. Miller wrote:
>    From: N N Ashok <nalkunda@cse.msu.edu>
>    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
-
: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux 802.1Q VLAN]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Git]     [Bugtraq]     [Yosemite News and Information]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux PCI]     [Linux Admin]     [Samba]

  Powered by Linux