-
-
Notifications
You must be signed in to change notification settings - Fork 207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sFlow for tunnels: Tunnel extension & IPv6 encapsulation support #574
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ static int verbose = 0; | |
typedef ssize_t (*packet_function_t)(int, void *, size_t, int, struct sockaddr *, socklen_t *); | ||
|
||
static option_t sfcapdConfig[] = { | ||
{.name = "gre", .valBool = 0, .flags = OPTDEFAULT}, {.name = "maxworkers", .valUint64 = 2, .flags = OPTDEFAULT}, {.name = NULL}}; | ||
{.name = "gre", .valBool = 0, .flags = OPTDEFAULT}, {.name = "6in4", .valBool = 0, .flags = OPTDEFAULT}, {.name = "maxworkers", .valUint64 = 2, .flags = OPTDEFAULT}, {.name = NULL}}; | ||
|
||
/* module limited globals */ | ||
static FlowSource_t *FlowSource; | ||
|
@@ -115,7 +115,7 @@ static void IntHandler(int signal); | |
static inline FlowSource_t *GetFlowSource(struct sockaddr_storage *ss); | ||
|
||
static void run(packet_function_t receive_packet, int socket, int pfd, int rfd, time_t twin, time_t t_begin, char *time_extension, int compress, | ||
int parse_gre); | ||
int parse_gre, int parse_6in4); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One argument -> int parse_tunnel |
||
|
||
/* Functions */ | ||
static void usage(char *name) { | ||
|
@@ -140,7 +140,7 @@ static void usage(char *name) { | |
"-i interval\tMetric interval in s for metric exporter\n" | ||
"-m socket\t\tEnable metric exporter on socket.\n" | ||
"-M dir \t\tSet the output directory for dynamic sources.\n" | ||
"-o options \tAdd sfcpad options, separated with ','. Available: 'gre'\n" | ||
"-o options \tAdd sfcpad options, separated with ','. Available: 'gre', '6in4'\n" | ||
"-P pidfile\tset the PID file\n" | ||
"-R IP[/port]\tRepeat incoming packets to IP address/port. Max 8 repeaters.\n" | ||
"-A\t\tEnable source address spoofing for packet repeater -R.\n" | ||
|
@@ -272,7 +272,7 @@ static int SendRepeaterMessage(int fd, void *in_buff, size_t cnt, struct sockadd | |
} // End of SendRepeaterMessage | ||
|
||
static void run(packet_function_t receive_packet, int socket, int pfd, int rfd, time_t twin, time_t t_begin, char *time_extension, int compress, | ||
int parse_gre) { | ||
int parse_gre, int parse_6in4) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just one option -> int parse_tunnel |
||
struct sockaddr_storage sf_sender; | ||
socklen_t sf_sender_size = sizeof(sf_sender); | ||
|
||
|
@@ -430,7 +430,7 @@ static void run(packet_function_t receive_packet, int socket, int pfd, int rfd, | |
|
||
fs->received = tv; | ||
/* Process data - have a look at the common header */ | ||
Process_sflow(in_buff, cnt, fs, parse_gre); | ||
Process_sflow(in_buff, cnt, fs, parse_gre, parse_6in4); | ||
|
||
// each Process_xx function has to process the entire input buffer, therefore it's empty | ||
// now. | ||
|
@@ -458,7 +458,7 @@ int main(int argc, char **argv) { | |
FlowSource_t *fs; | ||
int family, bufflen, metricInterval; | ||
time_t twin; | ||
int sock, do_daemonize, expire, spec_time_extension, parse_gre; | ||
int sock, do_daemonize, expire, spec_time_extension, parse_gre, parse_6in4; | ||
int subdir_index, compress, srcSpoofing; | ||
uint64_t workers; | ||
#ifdef PCAP | ||
|
@@ -495,6 +495,7 @@ int main(int argc, char **argv) { | |
options = NULL; | ||
workers = 0; | ||
parse_gre = 0; | ||
parse_6in4 = 0; | ||
|
||
int c; | ||
while ((c = getopt(argc, argv, "46AB:b:C:d:DeEf:g:hI:i:jJ:l:m:M:n:o:p:P:R:S:T:t:u:vVW:w:x:X:yz::Z:")) != EOF) { | ||
|
@@ -786,6 +787,7 @@ int main(int argc, char **argv) { | |
exit(EXIT_FAILURE); | ||
} | ||
OptGetBool(sfcapdConfig, "gre", &parse_gre); | ||
OptGetBool(sfcapdConfig, "6in4", &parse_6in4); | ||
|
||
if (datadir && !AddFlowSource(&FlowSource, Ident, ANYIP, datadir)) { | ||
LogError("Failed to add default data collector directory"); | ||
|
@@ -920,7 +922,7 @@ int main(int argc, char **argv) { | |
sigaction(SIGPIPE, &act, NULL); | ||
|
||
LogInfo("Startup sfcapd."); | ||
run(receive_packet, sock, pfd, rfd, twin, t_start, time_extension, compress, parse_gre); | ||
run(receive_packet, sock, pfd, rfd, twin, t_start, time_extension, compress, parse_gre, parse_6in4); | ||
|
||
// shutdown | ||
close(sock); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,7 +279,13 @@ typedef struct _SFSample { | |
#define SF_ABORT_DECODE_ERROR 2 | ||
#define SF_ABORT_LENGTH_ERROR 3 | ||
|
||
int parse_gre; | ||
/* tunnels */ | ||
int parse_gre; /* Enable GRE tunnel introspection */ | ||
int parse_6in4; /* Enable 6in4 tunnel introspection */ | ||
Comment on lines
+283
to
+284
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One single option |
||
SFLAddress tun_ipsrc; | ||
SFLAddress tun_ipdst; | ||
uint32_t tun_proto; | ||
|
||
|
||
} SFSample; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one option .name = "tunnel" ..