增加对dhcpv4的支持(tcp、udp socket已写好,但由于缺少epoll机制,尚未完整测试) (#237)

* 为virtio网卡完成smoltcp的phy层配置

* raw socket

* 初步写完udp和tcp socket

* 能够正常通过dhcp获取ipv4地址(具有全局iface btree)

---------

Co-authored-by: guanjinquan <1666320330@qq.com>
This commit is contained in:
login
2023-04-10 20:22:39 +08:00
committed by GitHub
parent 78bf93f02f
commit 13776c114b
26 changed files with 1723 additions and 105 deletions

View File

@ -0,0 +1,27 @@
# Replace with your wired Ethernet interface name
ETH=eno1
sudo modprobe bridge
sudo modprobe br_netfilter
sudo sysctl -w net.bridge.bridge-nf-call-arptables=0
sudo sysctl -w net.bridge.bridge-nf-call-ip6tables=0
sudo sysctl -w net.bridge.bridge-nf-call-iptables=0
sudo ip tuntap add name tap0 mode tap user $USER
sudo brctl addbr br0
sudo brctl addif br0 tap0
sudo brctl addif br0 $ETH
sudo ip link set tap0 up
sudo ip link set $ETH up
sudo ip link set br0 up
# This connects your host system to the internet, so you can use it
# at the same time you run the examples.
sudo dhcpcd br0
sudo mkdir -p /usr/local/etc/qemu
sudo mkdir -p /etc/qemu
sudo sh -c 'echo "allow br0" > /usr/local/etc/qemu/bridge.conf'
sudo sh -c 'echo "allow br0" > /etc/qemu/bridge.conf'

View File

@ -6,7 +6,7 @@ echo "$@"
allflags=$(qemu-system-x86_64 -cpu help | awk '/flags/ {y=1; getline}; y {print}' | tr ' ' '\n' | grep -Ev "^$" | sed -r 's|^|+|' | tr '\n' ',' | sed -r "s|,$||")
ARCH="x86_64"
#ARCH="i386"
# 请根据自己的需要,在-d 后方加入所需的trace事件
# 请根据自己的需要,在-d 后方加入所需的 trace 事件
# 标准的trace events
qemu_trace_std=cpu_reset,guest_errors,exec,cpu,trace:virtio*
@ -29,7 +29,7 @@ QEMU_RTC_CLOCK="clock=host,base=localtime"
QEMU_SERIAL="file:../serial_opt.txt"
QEMU_DRIVE="id=disk,file=${QEMU_DISK_IMAGE},if=none"
QEMU_DEVICES="-device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 -nic user,model=virtio -usb -device qemu-xhci,id=xhci,p2=8,p3=4 -machine accel=${qemu_accel}"
QEMU_DEVICES="-device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 -nic user,model=virtio-net-pci -usb -device qemu-xhci,id=xhci,p2=8,p3=4 -machine accel=${qemu_accel}"
QEMU_ARGUMENT="-d ${QEMU_DISK_IMAGE} -m ${QEMU_MEMORY} -smp ${QEMU_SMP} -boot order=d -monitor ${QEMU_MONITOR} -d ${qemu_trace_std} "