Skip to content

Commit

Permalink
修改 ovs-ovn-dpdk 容器镜像编译打包,解决容器中 ovs 运行不正常:无法添加物理网卡,无法创建 vhostuserclien…
Browse files Browse the repository at this point in the history
…t port 问题 (#1831)

* add webhook vaildate the vpc resource whether can be deleted.

* add note for dpdk-v2 install

* set vhostuser dir 777 for qemu has the permission to create sock

* Change gosec args to make it happy

* edit ovs ovn source patch for compile ovs-dpdk

* edit Dockerfile.base-dpdk for compile ovn-ovs-dpdk image

Co-authored-by: oilbeater <liumengxinfly@gmail.com>
Co-authored-by: wanglong <wang.long@99cloud.net>
  • Loading branch information
3 people committed Aug 21, 2022
1 parent 0ed5c92 commit babd802
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
16 changes: 14 additions & 2 deletions dist/images/Dockerfile.base-dpdk
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
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

0 comments on commit babd802

Please sign in to comment.