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

Trace Go Network Namespace #28

Open
zhouhaibing089 opened this issue Jan 31, 2018 · 0 comments
Open

Trace Go Network Namespace #28

zhouhaibing089 opened this issue Jan 31, 2018 · 0 comments

Comments

@zhouhaibing089
Copy link
Owner

zhouhaibing089 commented Jan 31, 2018

Find the thread using strace

$ strace -e trace=network -f -p <pid> -o trace.log

For example, the following output:

16652 socket(PF_INET, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP) = 783
16652 setsockopt(783, SOL_SOCKET, SO_BROADCAST, [1], 4) = 0
16652 connect(783, {sa_family=AF_INET, sin_port=htons(6443), sin_addr=inet_addr("10.212.173.184")}, 16) = -1 ENETUNREACH (Network is unreachable)

Here 16652 is the thread ID.

Get the network namespace the thread is using

$ ls -al /proc/<pid>/task/<threadid>/ns/net

Attach to that network namespace

$ nsenter --net=/proc/<pid>/task/<threadid>/ns/net ip a s
@zhouhaibing089 zhouhaibing089 changed the title Troubleshooting Unreachable Case Trace Go Network Namespace Jan 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant