google / gvisor

Application Kernel for Containers
https://gvisor.dev
Apache License 2.0
15.63k stars 1.29k forks source link

Support advanced AF_PACKET features in netstack #1409

Open majek opened 4 years ago

majek commented 4 years ago

Currently netstack supports only extremaly basic AF_PACKET sockets. Needed features:

I wrote a simple C program that can be helpful in testing these features https://gist.github.com/majek/9668716d4bb88fbe562037a912d0ae35

hbhasker commented 4 years ago

Thanks for the feature request and the program. Could you also provide use cases that you expect this to unblock. Currently we have not priortized AF_PACKET features beyond what we have already added and knowing more about the use case will help us with our prioritization.

majek commented 4 years ago

The most important is compatibility with debugging tools (tcpdump). Right now its very hard to debug netstack, since there is very little visibility into flying packets. Asking my users to run workloads on a platform that doesn't have tcpdump working is rather a tough sell.

hbhasker commented 4 years ago

I believe tcpdump works now. @kevinGC could you confirm?

majek commented 4 years ago

Not the stock one

root@runsc:/# strace -e trace=network -f tcpdump   
socket(AF_PACKET, SOCK_DGRAM, 768)      = 3
setsockopt(3, SOL_PACKET, PACKET_AUXDATA, [1], 4) = -1 EOPNOTSUPP (Operation not supported)
tcpdump: setsockopt: Operation not supported

and with interface

root@runsc:/# strace -e trace=network -f tcpdump -i lo
socket(AF_UNIX, SOCK_RAW, 0)            = 3
ioctl(3, SIOCETHTOOL, 0x7f7392966280)   = -1 ENOTTY (Inappropriate ioctl for device)
...
tcpdump: lo: SIOCETHTOOL(ETHTOOL_GET_TS_INFO) ioctl failed: Inappropriate ioctl for device

As the code I linked shows, you can get some packet capture functionality by using lower level stuff (raw AF_PACKET, without SIOCETHTOOL, binding to interface, etc), but you still see packets in only one direction.

hbhasker commented 4 years ago

Thanks. I will let Kevin take a look at this as he is the most experienced with our raw socket and af_packet socket implementations.

kevinGC commented 4 years ago

I believe tcpdump was working before -- I'll take a look.

I can prioritize outbound packets, but as @hbhasker mentioned it would be helpful to know more in order to prioritize other AF_PACKET features.

github-actions[bot] commented 4 years ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 30 days.

hbhasker commented 4 years ago

Just an update some of the things below are now addressed. Tcpdump now works in non promiscuous mode.

Currently netstack supports only extremaly basic AF_PACKET sockets. Needed features:

AF_PACKET seem to see inbound only packets. No way to see outbound packets.

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 30 days.