Skip to content
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

Make packetbeat process monitor aware of bound address #9443

Merged
merged 2 commits into from
Dec 11, 2018

Conversation

adriansr
Copy link
Contributor

@adriansr adriansr commented Dec 7, 2018

The current implementation of Packetbeat's process monitor detects the local process by looking at the local port number used. However, different processes can be bound to the same port on different interfaces, causing Packetbeat to associate an event to the wrong process.

This PR fixes the problem by looking up the process by using the tuple (address, port).

There's still a case where Packetbeat can pick the wrong process:

When one process is bound to INADDR_ANY and another to a specific local address. Testing suggests that the last socket to be bound takes precedence over the other. However, I couldn't find this behavior documented anywhere.

As Packetbeat can't tell which socket was bound first, there's no way of telling which process is really receiving the traffic. This PR will give precedence to a socket bound to a local IP-address over a socket bound to INADDR_ANY.

Fixes #9151

The current implementation of Packetbeat's process monitor detects the
local process by looking at the local port number used. However,
differnet processes can be bound to the same port on different
interfaces.

This patch fixes the problem by looking up the process by using the
tuple (address, port).

Fixes elastic#9151
@adriansr adriansr changed the title Make packetbeat process monitor local address aware Make packetbeat process monitor aware of bound address Dec 7, 2018
@adriansr adriansr added the needs_backport PR is waiting to be backported to other branches. label Dec 9, 2018
Copy link
Member

@andrewkroh andrewkroh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. This needs a CHANGELOG entry.

@adriansr
Copy link
Contributor Author

jenkins, test this

@adriansr adriansr merged commit 824d443 into elastic:master Dec 11, 2018
adriansr added a commit to adriansr/beats that referenced this pull request Dec 11, 2018
The current implementation of Packetbeat's process monitor detects the
local process by looking at the local port number used. However,
different processes can be bound to the same port on different
interfaces.

This patch fixes the problem by looking up the process by using the
tuple (address, port).

There's still a case where Packetbeat can pick the wrong process:

When one process is bound to INADDR_ANY and another to a specific
local address. Testing suggests that the last socket to be bound takes
precedence over the other. However, I couldn't find this behavior
documented anywhere.

As Packetbeat can't tell which socket was bound first, there's no way
of telling which process is really receiving the traffic. This PR will give
precedence to a socket bound to a local IP-address over a socket
bound to INADDR_ANY.



Fixes elastic#9151

(cherry picked from commit 824d443)
@adriansr adriansr added v6.6.0 and removed needs_backport PR is waiting to be backported to other branches. labels Dec 11, 2018
adriansr added a commit that referenced this pull request Dec 12, 2018
The current implementation of Packetbeat's process monitor detects the
local process by looking at the local port number used. However,
different processes can be bound to the same port on different
interfaces.

This patch fixes the problem by looking up the process by using the
tuple (address, port).

There's still a case where Packetbeat can pick the wrong process:

When one process is bound to INADDR_ANY and another to a specific
local address. Testing suggests that the last socket to be bound takes
precedence over the other. However, I couldn't find this behavior
documented anywhere.

As Packetbeat can't tell which socket was bound first, there's no way
of telling which process is really receiving the traffic. This PR will give
precedence to a socket bound to a local IP-address over a socket
bound to INADDR_ANY.



Fixes #9151

(cherry picked from commit 824d443)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect Client Commandline Picked up for Packetbeat flows
2 participants