AF_XDP:设置“SO_TIMESTAMP”不支持“SO_XDP”:协议不可用
AF_XDP: Set `SO_TIMESTAMP` not supported for `SO_XDP`: Protocol not available
为什么 AF_XDP
套接字不支持设置 SO_TIMESTAMP
?我的驱动程序 (mlnx 5.0
) 的用户手册指出
Incoming packets are time-stamped before they are distributed on the
PCI depending on the congestion in the PCI buffers.
据我所知,before distributed on the PCI
意味着还没有 Linux 内核涉及(还)- 对吗?
我试过这样设置:
int timestamp = SOF_TIMESTAMPING_RX_HARDWARE;
if(setsockopt(xsk_socket__fd(xsk_socket->xsk), SOL_XDP, SO_TIMESTAMP, (int*)×tamp, sizeof(int)) < 0) {
fprintf(stderr, "Failed to set `SO_TIMESTAMP`: %s\n", strerror(errno));
return;
}
并得到:
Failed to set SO_TIMESTAMP
: Protocol not available
我从xsk.c
(https://github.com/libbpf/libbpf/blob/master/src/xsk.c)复制了SO_XDP
的定义:
#ifndef SOL_XDP
#define SOL_XDP 283
#endif
不明白,为什么不支持...
没有技术原因没有实现。
确实,看起来它在 xdp 开发团队的待办事项列表中。
引用自here:
Important medium-term tasks
...
Metadata from hardware
There are various hardware metadata items that would be useful for XDP programs to access, to reduce the amount of processing that needs to happen in eBPF. These include:
- Checksum
- Hash value
- Flow designator
- Higher-level protocol header offsets
- Timestamps
看起来这是自 2019 年 6 月以来的待办事项,所以它可能没有最高优先级,否则它已经实施了。
为什么 AF_XDP
套接字不支持设置 SO_TIMESTAMP
?我的驱动程序 (mlnx 5.0
) 的用户手册指出
Incoming packets are time-stamped before they are distributed on the PCI depending on the congestion in the PCI buffers.
据我所知,before distributed on the PCI
意味着还没有 Linux 内核涉及(还)- 对吗?
我试过这样设置:
int timestamp = SOF_TIMESTAMPING_RX_HARDWARE;
if(setsockopt(xsk_socket__fd(xsk_socket->xsk), SOL_XDP, SO_TIMESTAMP, (int*)×tamp, sizeof(int)) < 0) {
fprintf(stderr, "Failed to set `SO_TIMESTAMP`: %s\n", strerror(errno));
return;
}
并得到:
Failed to set
SO_TIMESTAMP
: Protocol not available
我从xsk.c
(https://github.com/libbpf/libbpf/blob/master/src/xsk.c)复制了SO_XDP
的定义:
#ifndef SOL_XDP
#define SOL_XDP 283
#endif
不明白,为什么不支持...
没有技术原因没有实现。
确实,看起来它在 xdp 开发团队的待办事项列表中。
引用自here:
Important medium-term tasks
...
Metadata from hardware
There are various hardware metadata items that would be useful for XDP programs to access, to reduce the amount of processing that needs to happen in eBPF. These include:
- Checksum
- Hash value
- Flow designator
- Higher-level protocol header offsets
- Timestamps
看起来这是自 2019 年 6 月以来的待办事项,所以它可能没有最高优先级,否则它已经实施了。