This file contains hidden or 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
struct sock *__inet_lookup_skb(tcp_hashinfo, skb, src_port, dst_port) | |
{ | |
/* Get the IPv4 header to know the source and destination IP's */ | |
const struct iphdr *iph = ip_hdr(skb); | |
/* | |
* Look up the incoming skb in tcp_hashinfo using the | |
* [ Source-IP:Port, Destination-IP:Port ] tuple. | |
*/ | |
return __inet_lookup(tcp_hashinfo, skb, iph->saddr, src_port, iph->daddr, dst_port); |
This file contains hidden or 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
#define LHTABLE_SIZE 32 /* Yes, really, this is all you need */ | |
struct inet_hashinfo { | |
/* Hash table for fully established sockets */ | |
struct inet_ehash_bucket *ehash; | |
/* Hash table for LISTEN sockets */ | |
struct inet_listen_hashbucket listening_hash[LHTABLE_SIZE]; | |
}; | |
struct inet_hashinfo tcp_hashinfo; |
This file contains hidden or 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
# Server is listening on port #45000 | |
$ ss -tan | grep :45000 | |
LISTEN 0 1 10.20.1.1:45000 *:* | |
# A client connects to the server using it's source port 54762. A new | |
# socket is created and is seen in ESTABLISHED state, along with the | |
# earlier LISTEN socket. | |
$ ss -tan | grep :45000 | |
LISTEN 0 1 10.20.1.1:45000 *:* | |
ESTAB 0 0 10.20.1.1:45000 10.20.1.100:54762 |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <sys/wait.h> | |
#include <netdb.h> | |
void create_children(int nprocs, int parent_pid) | |
{ | |
while (nprocs-- > 0) { | |
if (getpid() == parent_pid && fork() < 0) |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <strings.h> | |
#include <sys/wait.h> | |
#include <netdb.h> | |
void create_children(int nprocs, int parent_pid) | |
{ | |
while (nprocs-- > 0) { |
NewerOlder