-
Notifications
You must be signed in to change notification settings - Fork 861
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
Add support for PACKET_FANOUT on Linux #869
Open
tsnoam
wants to merge
1
commit into
the-tcpdump-group:master
Choose a base branch
from
tsnoam:fanout
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
.\" Copyright (c) 1994, 1996, 1997 | ||
.\" The Regents of the University of California. All rights reserved. | ||
.\" | ||
.\" Redistribution and use in source and binary forms, with or without | ||
.\" modification, are permitted provided that: (1) source code distributions | ||
.\" retain the above copyright notice and this paragraph in its entirety, (2) | ||
.\" distributions including binary code include the above copyright notice and | ||
.\" this paragraph in its entirety in the documentation or other materials | ||
.\" provided with the distribution, and (3) all advertising materials mentioning | ||
.\" features or use of this software display the following acknowledgement: | ||
.\" ``This product includes software developed by the University of California, | ||
.\" Lawrence Berkeley Laboratory and its contributors.'' Neither the name of | ||
.\" the University nor the names of its contributors may be used to endorse | ||
.\" or promote products derived from this software without specific prior | ||
.\" written permission. | ||
.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED | ||
.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF | ||
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
.\" | ||
.TH PCAP_SET_FANOUT 3PCAP "16 April 2020" | ||
.SH NAME | ||
pcap_set_fanout_linux \- set fanout group for load balancing | ||
among processes | ||
.SH SYNOPSIS | ||
.nf | ||
.ft B | ||
#include <linux/if_packet.h> | ||
#include <pcap/pcap.h> | ||
.LP | ||
.ft B | ||
int pcap_set_fanout_linux(pcap_t *p, int enable, uint16_t mode, uint16_t group_id); | ||
.ft | ||
.fi | ||
.SH DESCRIPTION | ||
On Linux network interface devices, | ||
.B pcap_set_fanout_linux() | ||
sets the fanout configuration to be used in the | ||
.BR socket (2) | ||
call to create a capture socket when the handle is activated. | ||
.LP | ||
Using fanout is required if you want to load-balance multiple processes and/or | ||
threads to handle the intercepted traffic. When preparing the socket to be used, | ||
it is required to set a group_id in order to distinguish between different | ||
consumers. | ||
.LP | ||
A single fanout groups load-balances the handling of intercepted traffic. | ||
.LP | ||
It is possible to have any combination of fanout groups or "normal" consumers, | ||
as it is possible with only "normal" consumers ("normal" - non fanout). | ||
.LP | ||
This function is only provided on Linux, and, if it is used on any device other | ||
than a network interface, it will have no effect. | ||
.LP | ||
.IR enable | ||
is a boolean flag to control if fanout is enabled (default is FALSE). | ||
.LP | ||
.IR mode | ||
is the fanout mode and flags to use. More information on the various modes can | ||
be found in | ||
.BR packet (7)\c | ||
\&. | ||
.LP | ||
.IR group_id | ||
is a unique identifier of the socket group. | ||
.LP | ||
.BR pcap_set_fanout_linux() | ||
should not be used in portable code. | ||
|
||
.SH RETURN VALUE | ||
Returns 0 on success or | ||
.B PCAP_ERROR_ACTIVATED | ||
if called on a capture handle that has been activated. | ||
.SH SEE ALSO | ||
.BR pcap (3PCAP) | ||
.BR socket (2) | ||
.BR packet (7) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you please explain what the affect of having packet fanout mode?
When would I turn it on and why? Is there is a downside to it? What if every application turned it on?
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.
In the AF_PACKET fanout mode, packet reception can be load balanced among processes/threads.
When "configuring" the socket to be used, you would be required to set a group_id, use the same group_id to achieve the required load balancing.
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.
Don't tell me. Put it in the manpage!