Userspace programs also have several alternative ways of sending data. They can use two network-related system calls (sendto and send) or the write and writev functions of the file layer. Because, once again, the code in the kernel merges at a certain point, it is sufficient to examine the implementation of the first of the above calls (in the sys_sendto procedure in the kernel sources). The associated code flow diagram is shown in Figure 12-34.34
move_addr_to_kernel sock_sendmsg sock->ops->sendmsg
Figure 12-34: Code flow diagram for sys_sendto.
fget_light and sock_from_file find the relevant socket by reference to the file descriptor. The data to be sent are copied from userspace to kernel space using move_addr_to_kernel before sock_sendmsg invokes the protocol-specific send routine sock->ops->sendmsg. This routine generates a packet in the required format and forwards it to the lower layers.
Continue reading here: Networking from within the Kernel
Was this article helpful?