Last active
July 23, 2019 04:33
-
-
Save kkumar-fk/e092c9cd3e824a9ce0ec2dfdd733e132 to your computer and use it in GitHub Desktop.
code blob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static int inet_reuseport_add_sock(struct sock *new_sk) | |
{ | |
/* First check if another identical LISTEN socket, prev_sk, | |
* exists. ... Then do the following: | |
*/ | |
if (prev_sk) { | |
/* | |
* Not the first listener - do the following: | |
* - Grow prev_sk->sk_reuseport_cb structure if required. | |
* - Save new_sk socket pointer in prev_sk's socks[]. | |
* - prev_sk->sk_reuseport_cb->socks[num_socks] = new_sk; | |
* - prev_sk->sk_reuseport_cb->num_socks++; | |
* - Pointer assignment of the control block: | |
* new_sk->sk_reuseport_cb = prev_sk->sk_reuseport_cb; | |
*/ | |
return reuseport_add_sock(new_sk, prev_sk); | |
} | |
/* | |
* First listener - do the following: | |
* - allocate new_sk->sk_reuseport_cb to contain 128 socks[] | |
* - new_sk->sk_reuseport_cb->max_socks = 128; | |
* - new_sk->sk_reuseport_cb->socks[0] = new_sk; | |
* - new_sk->sk_reuseport_cb->numsocks = 1; | |
*/ | |
return reuseport_alloc(new_sk); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment