How to get XDP program into kernel with iproute2? - ebpf

I am using "ip link" command to put xdp program into kernel, in my virtual machine(kernel-version:4.18)
command like this:
ip link set dev ens33 xdp obj xdpsock_kern.o sec .text
but after this command, the error said:
No ELF library support compiled in.
what should I do to solve this problem?

I solve this problem by reconfigure the iproutes.
git clone git://git.kernel.org/pub/pub/scm/network/iproute2/iproute2.git
cd iproute2/
./configure --prefix=/usr
make
sudo make install

Related

qemu-system-arm run barebox image

may I ask? I need to build a barebox image inside yocto and run it in qemu, I can’t build a qemuarm image in yocto, there is no such recipe, in general, the question is, is it possible to somehow slip under such a dts into the barebox assembly that qemu-system-arm with -M mcimx6ul-evk option will be able to run barebox builded in yocto?
You can enable CONFIG_BOARD_ARM_GENERIC_DT=y in the barebox config and barebox will generate an images/barebox-dt-2nd.img file that is bootable like a Linux kernel: You can pass it to QEMU -kernel and it will receive a device tree from the outside.
barebox contains a test/emulate.pl script that can spawn QEMU VMs for you. Passing it --dryrun will print the options used (edited for formatting):
$ ./test/emulate.pl --no-tuxmake --dry-run virt#vexpress_defconfig
/usr/bin/qemu-system-arm -M virt -cpu cortex-a7 -m 1024M -kernel \
./build/images/barebox-dt-2nd.img -serial mon:stdio -trace file=/dev/null
In the above case, QEMU will provide the device tree, but you can pass your own as well (make sure to build barebox with a config that enables board and platform support in line with the FDT and QEMU machine you configure). See the barebox documentation on Emulated targets for more information.

.sh script that executes command as "real" root

I want to write a .sh-script that sends a message to my ejabberd-account. (the script is "called" by the apache2 standard-user "www-data").
The script should execute the following command: ejabberdctl send_message chat admin#my-domain user#my-domain "title" "my message"
However, I can't run any ejabberdctl command without "being" root. So sudo ejabberdctl is not working (in terminal or any .sh-script). I can only do sudo -s followed by ejabberdctl my-command, which doesn't work in .sh-scripts (or am I wrong?).
(I've installed ejabberd 20.07 on ubuntu 20.04 with the help of this tutorial: Install Ejabberd...)
Is there a way to run a command in a .sh-script as "real root" or to create a root-session and run the command there (like I do manually with sudo -s ...)?
Is there any solution to my problem or should I install ejabberd the "normal way"?
When ejabberd is compiled and installed from source code, it's possible to prepare it with something like
./configure -–enable-group=ejagroup
Then, you can simply create the system group ejagroup, and add the www-data user to that ejagroup.
See https://docs.ejabberd.im/admin/installation/#options
In your case, that you use the Debian package from ProcessOne, I see the tutorial mentions that you create a system account called ejabberd. Maybe you can run ejabberdctl from that account, no need to be root?
I still don't know why I can only run ejabberdctl when I'm "logged-in" as root (sudo ejabberdctl is still not working)
Is my .bashrc file wrong? (last line: PATH=$PATH:/opt/ejabberd-20.07/bin/)
Anyway, at least I can run sudo /opt/ejabberd-20.07/bin/ejabberdctl my_command with any user, like they did here: Ejabberd sbin/ejabberdctl start (No such file or directory)
Has someone else experienced this weird behavior with sudo: any_command: not found ?
Let me know if you have a more "elegant" solution to my problem.

esptool.py not recognized as internal or external command, operable program or batch file

I recently tried to load MicroPython on ESP8266 board, but failed. To do that I had to install esptool. I successfully installed it but when I wanted to use it, it would not work.
For instance,
esptool.py --help
'not recognized as internal or external command, operable program or batch file'
I found many questions on this topic, but none of the answers helped me. I tried adding everything to the Windows path and it still did not work.
Try installing esptool using pip command on Windows.
Then use only "esptool" instead of "esptool.py"
I was in the same position as the OP.
On Windows 10 I must use this syntax at a CMD prompt launched as an admin:
py -m esptool --help
I'm running Python 3.10.2 and esptool was installed using
py -m pip install --user pip
pip3 install esptool (Administration Mode)
Problem :
C:\WINDOWS\system32>esptool --chip esp328266 -p COM3 erase_flash
'esptool' is not recognized as an internal or external command,
operable program or batch file.
AFTER DOING THIS
C:\WINDOWS\system32>pip3 install esptool
Collecting esptool
Downloading esptool-3.1.tar.gz (175 kB)
----------Successfull----------------------
C:\WINDOWS\system32>esptool.py --chip esp8266 -p COM3 erase_flash
esptool.py v3.1
Serial port COM3
Connecting....
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: e8:db:84:9b:5a:57
Uploading stub
Running stub
Stub running
Chip erase completed successfully in 2.7s
Hard resetting via RTS pin...
By using "esptool -h" I could check the help option.

schroot is giving error on centos 6

When I'm using command: schroot -c 32bit -- bash --login -c "rm -rf ~/SC32 ;"
I'm getting these errors:
E: 20copyfiles: cp: cannot create regular file `/var/lib/schroot/mount/32bit-dcc62f68-de18-4d2a-95d9-b71f0be314ce/etc/resolv.conf': No such file or directory
E: 32bit-dcc62f68-de18-4d2a-95d9-b71f0be314ce: Chroot setup failed: stage=setup-start
Since i'm new to Linux Environment i don't know what to do to solve this error.
The Cent OS which I'm using is 6.3 with x64 architecture
Also i have configured 32bit in /etc/schroot/schroot.conf as
[32bit]
type=directory
description=CentOS 6.3 32bit
directory=/chroot/32bit
users=temp
root-groups=root
personality=linux32
Also I Have this directory available /chroot/32bit
I'm not the root user of the system.
Can anybody tell me what to do to resolve this error?
To debug problems with schroot, try running it verbosely:
schroot -v
or to make it really verbose
schroot -v --debug=notice
The actual failure here is to copy /etc/resolv.conf. There are two potential reasons for this
The source file isn't copyable. Normally unlikely, but try cp and cat by hand to check.
The destination doesn't exist. This is the usual cause of such errors.
Your chroot is /chroot/32bit and it's being (bind) mounted on /var/lib/schroot/mount/32bit-dcc62f68-de18-4d2a-95d9-b71f0be314ce. If /chroot/32bit/etc does not exist, then /var/lib/schroot/mount/32bit-dcc62f68-de18-4d2a-95d9-b71f0be314ce/etc won't exist either, and so the copy operation will fail. You must have a proper system available under /chroot/32bit with all the usual directories (/bin, /etc, /lib etc.).
Assuming that you do have a proper chroot in /chroot/32bit, then something has gone wrong during setup. Running with verbose or debug messages enabled may shed some light on the cause of the failure.
Regards,
Roger
(schroot author)
I followed #Roger 's solution and all is well. But I found another workaround solution:
Enter your schroot directory, maybe like this location: /chroot/32bit, you can find this path in "/etc/schroot/schroot.conf" setting file.
cd /chroot/32bit
mv /chroot/32bit/etc/resolv.conf /chroot/32bit/etc/resolv.conf.bk
Then you can try your schroot login command and check is success.
schroot -c 32bit
(32bit)WDan#linux-buildy01:~$
Enjoy it!

QEMU - redirect guestOS booting to host machine

I used QEMU to bring CentOS.img (downloaded some where). I find the boot screen of CentOS.img took over the console session of the current terminal and I could see CentOS booting up process and prompts me to the login screen of the guestVM CentOS. This is really helpful for me as I ran QEMU instance from remote console machine.
Now, I created a new RHEL.img using iso and when I try to boot it; I was not able to see anything in the screen other then some symbol of (Y) :(
$>/usr/libexec/qemu-kvm -hda ./RHEL.img -bios bios.bin -nographic -net nic,model=e1000,macaddr=00:AD:BE:EF:4F:BD -net tap,script=./qemu-ifup -m 1024 -smp 2
...Y
on investigation, I find we can do it by redirecting RHEL boot to console using
# virt-edit RHEL_VM /boot/grub/grub.conf
...
title rhel (2.6.38.6-26.rc1.fc15.x86_64)
root (hd0,0)
kernel /vmlinuz ro [...] console=ttyS0
...
but nothing worked out. I am trying to bring the rhel VM session to the same console where I invoked qemu-kvm from remote terminal. Thanks in advance.
NOTE: I don't have GUI enabled on the physical host machine.
You could try adding a serial port and sending output to that. Although you do have to be able to boot it at least once to do these steps...
You might get lucky if you just add a serial port to the qemu command line and then telnet to that; hoping linux detects this and sends output there
edit /etc/init/ttyS0.conf and add
respawn
console none
start on (local-filesystems)
stop on [!12345]
script
exec start ttyS0
end script
then
ln -s /etc/init/ttyS0.conf /etc/rc2.d/S99ttyS0.conf
ln -s /etc/init/ttyS0.conf /etc/rc0.d/S99ttyS0.conf
ln -s /etc/init/ttyS0.conf /etc/rc6.d/S99ttyS0.conf
then do this to enable grub
Edit /etc/default/grub
1. Edit the GRUB_CMDLINE_DEFAULT="" line to start the console on /dev/ttyS0
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,38400n8"
2. Add a serial console section
# Serial console
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"
3. Rebuild the grub.cfg file
sudo sh
grub-mkconfig > /boot/grub/grub.cfg