Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改 ovs-ovn-dpdk 容器镜像编译打包,解决容器中 ovs 运行不正常:无法添加物理网卡,无法创建 vhostuserclient port 问题 #1831

Merged
merged 10 commits into from
Aug 21, 2022
16 changes: 14 additions & 2 deletions dist/images/Dockerfile.base-dpdk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
FROM ubuntu:22.04 as ovs-builder

ARG ARCH
ARG NO_AVX512=false
ARG DEBIAN_FRONTEND=noninteractive
ENV SRC_DIR='/usr/src'

Expand Down Expand Up @@ -29,6 +30,8 @@ RUN cd /usr/src/ && \
cd ovs && \
git checkout c50a0f080d95e9027b7ba3a70150b02c2377c721 && \
curl -s https://github.com/kubeovn/ovs/commit/22ea22c40b46ee5adeae977ff6cfca81b3ff25d7.patch | git apply && \
# compile without avx512
if [ "$ARCH" = "amd64" -a "$NO_AVX512" = "true" ]; then curl -s https://github.com/kubeovn/ovs/commit/38c59e078d69b343f56ab0f380fb9f42b94b7c02.patch | git apply; fi && \
./boot.sh && \
rm -rf .git && \
export DPDK_DIR=/usr/src/dpdk-stable-20.11.1 && \
Expand All @@ -48,7 +51,14 @@ RUN cd /usr/src/ && git clone -b branch-21.06 --depth=1 https://github.com/kubeo
if [ "$ARCH" = "amd64" ]; then CONFIGURE_OPTS='LIBS=-ljemalloc CFLAGS="-O2 -g -msse4.2 -mpopcnt"'; fi && \
OVSDIR=/usr/src/ovs EXTRA_CONFIGURE_OPTS=$CONFIGURE_OPTS DEB_BUILD_OPTIONS='parallel=8 nocheck' fakeroot debian/rules binary

RUN cd /usr/src/ && \
cd ovs && \
./boot.sh && \
./configure --with-dpdk=yes && \
make

RUN mkdir /packages/ && \
cp /usr/src/ovs/vswitchd/ovs-vswitchd /packages && \
cp /usr/src/libopenvswitch*.deb /packages && \
cp /usr/src/openvswitch-*.deb /packages && \
cp /usr/src/python3-openvswitch*.deb /packages && \
Expand All @@ -58,7 +68,7 @@ RUN mkdir /packages/ && \
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt update && apt upgrade -y && apt install ca-certificates python3 hostname libunwind8 netbase \
RUN apt update && apt upgrade -y && apt install ca-certificates python3 hostname driverctl libunwind8 netbase \
ethtool iproute2 ncat libunbound-dev procps libatomic1 kmod iptables \
tcpdump ipset curl uuid-runtime openssl inetutils-ping arping ndisc6 \
logrotate libjemalloc2 dnsutils libnuma-dev -y --no-install-recommends && \
Expand All @@ -81,4 +91,6 @@ RUN --mount=type=bind,target=/packages,from=ovs-builder,source=/packages \
dpkg -i /packages/libopenvswitch*.deb && \
dpkg -i /packages/openvswitch-*.deb && \
dpkg -i /packages/python3-openvswitch*.deb &&\
dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/ovn-*.deb
dpkg -i --ignore-depends=openvswitch-switch,openvswitch-common /packages/ovn-*.deb && \
cp -f /packages/ovs-vswitchd /usr/sbin/

17 changes: 17 additions & 0 deletions dist/images/start-ovs-dpdk-v2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ if ! test -f "$OVS_DPDK_CONFIG_FILE"; then
fi
source $OVS_DPDK_CONFIG_FILE

# set up driver
modprobe vfio-pci


# band nic to dpdk driver
driverctl set-override ${DPDK_DEV} modprobe vfio-pci

# link sock
mkdir -p /usr/local/var/run

if [ -L /usr/local/var/run/openvswitch ]
then
echo "sock exist"
else
echo "link sock"
ln -s /var/run/openvswitch /usr/local/var/run/openvswitch
fi

export PATH=$PATH:/usr/share/openvswitch/scripts
export PATH=$PATH:/usr/share/ovn/scripts
Expand Down