I am manipulating the connect() function in Linux Kernel source code (net/socket.c file) and need to get the source and destination port of an established connection. The function takes a struct sockaddr __user* uservaddr parameter from which I already could get the destination port by casting it to a struct sockaddr_in. But where is the local source port stored? The function also declares a struct socket* sock, which possibly contains the data I need, but I couldn't find any variable with the source port. Any help?