“无法打开共享对象文件”与 OpenOnload
我已经构建并安装了 https://github.com/Xilinx-CNS/onload 共享库。
然后我正在尝试: onload ping 8.8.8.8
出现此错误:
ERROR: ld.so: object 'libonload.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=110 time=29.2 ms
但它可以与 sudo onload ping 8.8.8.8
一起使用:
oo:ping[724989]: netif_tcp_helper_alloc_u: ENODEV. This error can occur if:
- no Solarflare network interfaces are active/UP, or they are running packed stream firmware or are disabled, and
- there are no AF_XDP interfaces registered with sfc_resource Please check your configuration.
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=110 time=50.4 ms
有人可以帮助我,如何在没有 sudo 的情况下实现此命令?例如,onload nc -l $PORT
无需 sudo 即可工作,但 ping 则不行。
一些调试信息:
sudo find / -name libonload.so
:
/usr/lib/x86_64-linux-gnu/libonload.so
cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
cat /etc/ld.so.conf.d /*.conf
/usr/lib/x86_64-linux-gnu/libfakeroot
/usr/local/lib
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
/lib32
/usr/lib32
sudo ldconfig -v
:
...
/usr/lib/x86_64-linux-gnu/libfakeroot:
libfakeroot-0.so -> libfakeroot-tcp.so
/usr/local/lib:
/lib/x86_64-linux-gnu:
...
libonload_ext.so.2 -> libonload_ext.so.2.0.0
libonload.so -> libonload.so
...
...
ls -l /usr/lib/x86_64-linux-gnu | grep onload
-rwxr-xr-x 1 root root 9528312 Mar 3 01:17 libonload.so
-rw-r--r-- 1 root root 106222 Mar 3 01:17 libonload_ext.a
lrwxrwxrwx 1 root root 18 Mar 3 01:17 libonload_ext.so -> libonload_ext.so.2
lrwxrwxrwx 1 root root 22 Mar 3 01:17 libonload_ext.so.2 -> libonload_ext.so.2.0.0
-rwxr-xr-x 1 root root 31344 Mar 3 01:17 libonload_ext.so.2.0.0
ls -l /lib/x86_64-linux-gnu | grep onload
ls -l /lib/x86_64-linux-gnu | grep onload grep onload
-rwxr-xr-x 1 root root 9528312 Mar 3 01:17 libonload.so
-rw-r--r-- 1 root root 106222 Mar 3 01:17 libonload_ext.a
lrwxrwxrwx 1 root root 18 Mar 3 01:17 libonload_ext.so -> libonload_ext.so.2
lrwxrwxrwx 1 root root 22 Mar 3 01:17 libonload_ext.so.2 -> libonload_ext.so.2.0.0
-rwxr-xr-x 1 root root 31344 Mar 3 01:17 libonload_ext.so.2.0.0
/lib$ ls -l | grep x86_64-linux-gnu
drwxr-xr-x 35 root root 36864 Mar 3 01:17 x86_64-linux-gnu
/usr/lib$ ls -l | grep x86_64-linux-gnu
drwxr-xr-x 35 root root 36864 Mar 3 01:17 x86_64-linux-gnu
I have built and installed https://github.com/Xilinx-CNS/onload shared lib.
Then I am trying:onload ping 8.8.8.8
Got this error:
ERROR: ld.so: object 'libonload.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=110 time=29.2 ms
But it works with sudo onload ping 8.8.8.8
:
oo:ping[724989]: netif_tcp_helper_alloc_u: ENODEV. This error can occur if:
- no Solarflare network interfaces are active/UP, or they are running packed stream firmware or are disabled, and
- there are no AF_XDP interfaces registered with sfc_resource Please check your configuration.
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data. 64 bytes from 8.8.8.8: icmp_seq=1 ttl=110 time=50.4 ms
Can someone help me, how I can achieve this command working without sudo? For example, onload nc -l $PORT
works without sudo, but ping do not.
Some debug information:
sudo find / -name libonload.so
:
/usr/lib/x86_64-linux-gnu/libonload.so
cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf
cat /etc/ld.so.conf.d/*.conf
/usr/lib/x86_64-linux-gnu/libfakeroot
/usr/local/lib
/usr/local/lib/x86_64-linux-gnu
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
/lib32
/usr/lib32
sudo ldconfig -v
:
...
/usr/lib/x86_64-linux-gnu/libfakeroot:
libfakeroot-0.so -> libfakeroot-tcp.so
/usr/local/lib:
/lib/x86_64-linux-gnu:
...
libonload_ext.so.2 -> libonload_ext.so.2.0.0
libonload.so -> libonload.so
...
...
ls -l /usr/lib/x86_64-linux-gnu | grep onload
-rwxr-xr-x 1 root root 9528312 Mar 3 01:17 libonload.so
-rw-r--r-- 1 root root 106222 Mar 3 01:17 libonload_ext.a
lrwxrwxrwx 1 root root 18 Mar 3 01:17 libonload_ext.so -> libonload_ext.so.2
lrwxrwxrwx 1 root root 22 Mar 3 01:17 libonload_ext.so.2 -> libonload_ext.so.2.0.0
-rwxr-xr-x 1 root root 31344 Mar 3 01:17 libonload_ext.so.2.0.0
ls -l /lib/x86_64-linux-gnu | grep onload
-rwxr-xr-x 1 root root 9528312 Mar 3 01:17 libonload.so
-rw-r--r-- 1 root root 106222 Mar 3 01:17 libonload_ext.a
lrwxrwxrwx 1 root root 18 Mar 3 01:17 libonload_ext.so -> libonload_ext.so.2
lrwxrwxrwx 1 root root 22 Mar 3 01:17 libonload_ext.so.2 -> libonload_ext.so.2.0.0
-rwxr-xr-x 1 root root 31344 Mar 3 01:17 libonload_ext.so.2.0.0
/lib$ ls -l | grep x86_64-linux-gnu
drwxr-xr-x 35 root root 36864 Mar 3 01:17 x86_64-linux-gnu
/usr/lib$ ls -l | grep x86_64-linux-gnu
drwxr-xr-x 35 root root 36864 Mar 3 01:17 x86_64-linux-gnu
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最可能的原因是
ping
应用程序使用setuid
但 Onload 库未随其安装。运行ping
将有效地将应用程序提升为 root 用户,以允许创建原始套接字,但库将以普通用户身份加载,因此无法使用。以 root 用户身份运行可以避免这种情况,因为库是作为 root 用户加载的。我认为 GitHub 版本的 Onload 不支持使用 Onload 库的
setuid
加载,但您可以使用chmod +s
自行设置。值得指出的是,Onload 不会加速ping
,因为该库只会加速 UDP 和 TCP 套接字和管道,因此您不会从中看到任何好处。The most likely reason is the
ping
application usessetuid
but the Onload library isn't installed with that. Runningping
will effectively promote the application to root user to allow the creation of a raw socket but the library will be loaded as the regular user and so it can't be used. Running as the root user avoids this since the library is loaded as the root user to start with.I don't think GitHub version of Onload supports loading with
setuid
for the Onload library but you can set this yourself usingchmod +s <libpath>
. It's worth pointing out thatping
isn't accelerated by Onload since the library will only accelerate UDP and TCP socket and pipes so you wouldn't see any benefit from this.