Linux kernel: skbuff structure - routing information..
I have a doubt, pls clarify. Suppose I have a System connected like the below,
A -> B -> C -> D
I need to send a packet from A to D, so when a packet moves out of A, it should update the routing information somewhere in the packet or in the skbuff so that packet is routed correctly via B, so that it reaches the destination.
Pls let me know where it is updated in the packet开发者_如何转开发 means which header or which parameter in the skbuff..
Thnx in advance..
From your view, you only need the target address D and the first gateway (or router) B. You don't make any modification in the packet, this is done in the router(s). C or any other routers on the way to D are transparent for you.
Normally this happens by updating the source and destination mac address of the packet. This would be found in the ethernet header of the packet (assuming it's travelling over ethernet). In normal UDP or TCP routing, you can do this completely in userspace by modifying the routing tables.
Are you implementing a custom internet protocol? Otherwise, it's unlikely that a custom kernel module / patch is the right place for this.
When the packet is being sent from A to D in this network, A -> B -> C -> D, application on A has a socket to application on D. The IP at A needs to find the next hop through routing, which would be B in this case. This information can be cached in socket as well(as in some versions of Linux, in the socket->sock->dst_cache field). The IP datagram always has destination IP as IP of D. So, B forwards it to C based on routing table and similarly C to D.
Does this answer your question?
精彩评论