I am trying to integrate multipath tcp (https://www.multipath-tcp.org/) into a project, and I would like to modify the source code in order to manually choose the outgoing socket port for a new mptcp subflow so that I can identify the packets going in and out within my application.
The address is created with:
inet_create(sock_net(meta_sk), &sock, IPPROTO_TCP, 1);
and bound:
sock.ops->bind(&sock, (struct sockaddr *)&loc_in, sizeof(struct sockaddr_in));
and then connected:
sock.ops->connect(&sock, (struct sockaddr *)&rem_in,
sizeof(struct sockaddr_in), O_NONBLOCK);
My question is this: How can I manually set the outgoing port of a socket at kernel level, and/or where is the port set in this sequence of calls, so I can modify it?