Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

uevent: Fix netlink error while assigning pid in netlink client #217

Merged
merged 1 commit into from
Apr 23, 2018

Conversation

amshinde
Copy link
Member

unix.SockaddrNetlink represents a netlink client with the Pid
being the netlink socket address. This can be assigned the actual
pid of the process, but in case we have two netlink sockets opened
at the same time, this results in errors in binding to the netlink
socket. Assign this to zero which means the kernel takes care of
assigning it.

See http://man7.org/linux/man-pages/man7/netlink.7.html

Fixes #216

Signed-off-by: Archana Shinde archana.m.shinde@intel.com

@@ -35,7 +34,7 @@ type ReaderCloser struct {
func NewReaderCloser() (io.ReadCloser, error) {
nl := unix.SockaddrNetlink{
Family: unix.AF_NETLINK,
Pid: uint32(os.Getpid()),
Pid: uint32(0),
Copy link
Contributor

Choose a reason for hiding this comment

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

I appreciate you've documented this in the commit, but I'd also be tempted to put a comment above this line as it looks "odd" ;)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

unix.SockaddrNetlink represents a netlink client with the Pid
being the netlink socket address. This can be assigned the actual
pid of the process, but in case we have two netlink sockets opened
at the same time, this results in errors in binding to the netlink
socket. Assign this to zero which means the kernel takes care of
assigning it.

See http://man7.org/linux/man-pages/man7/netlink.7.html

Fixes kata-containers#216

Signed-off-by: Archana Shinde <archana.m.shinde@intel.com>
@codecov
Copy link

codecov bot commented Apr 23, 2018

Codecov Report

Merging #217 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #217   +/-   ##
=======================================
  Coverage   40.05%   40.05%           
=======================================
  Files          12       12           
  Lines        1790     1790           
=======================================
  Hits          717      717           
  Misses        971      971           
  Partials      102      102

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bdc70d4...8f828bb. Read the comment docs.

@jodh-intel
Copy link
Contributor

jodh-intel commented Apr 23, 2018

lgtm

Approved with PullApprove

@bergwolf
Copy link
Member

bergwolf commented Apr 23, 2018

lgtm!

Approved with PullApprove

@sboeuf sboeuf merged commit bf6f367 into kata-containers:master Apr 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants