Skip to content

Commit

Permalink
northd: Fix NULL pointer deref within build_bfd_table.
Browse files Browse the repository at this point in the history
The cb_bt pointer was pointing to different struct and might
have been NULL at this point. Make sure we are using the correct
pointer in the strcmp() and sbrec_bfd_set_chassis_name() call.

At the same time make sure we are actually running all tests that
do require the BFD beacon, as it was skipped in all CI stages. The
OpenBFDD project is not available as rpm, so we need to compile it
from source.

Fixes: 4885e33 ("rbac: Only allow relevant chassis to update BFD.")
Signed-off-by: Ales Musil <amusil@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
  • Loading branch information
almusil authored and putnopvut committed Mar 11, 2024
1 parent dbca38f commit a55eb4a
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 2 deletions.
5 changes: 3 additions & 2 deletions northd/northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -9804,8 +9804,9 @@ build_bfd_table(struct ovsdb_idl_txn *ovnsb_txn,
}
build_bfd_update_sb_conf(nb_bt, bfd_e->sb_bt);
if (op && op->sb && op->sb->chassis &&
strcmp(op->sb->chassis->name, sb_bt->chassis_name)) {
sbrec_bfd_set_chassis_name(sb_bt, op->sb->chassis->name);
strcmp(op->sb->chassis->name, bfd_e->sb_bt->chassis_name)) {
sbrec_bfd_set_chassis_name(bfd_e->sb_bt,
op->sb->chassis->name);
}

hmap_remove(&sb_only, &bfd_e->hmap_node);
Expand Down
1 change: 1 addition & 0 deletions utilities/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ EXTRA_DIST += \
utilities/ovndb-servers.ocf \
utilities/checkpatch.py \
utilities/containers/Makefile \
utilities/containers/openbfdd.patch \
utilities/containers/py-requirements.txt \
utilities/containers/fedora/Dockerfile \
utilities/containers/ubuntu/Dockerfile \
Expand Down
18 changes: 18 additions & 0 deletions utilities/containers/fedora/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,24 @@ RUN git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git \
&& \
make -j4 PREFIX=/usr HAVE_LLVM= HAVE_SQLITE= install

# Compile OpenBFDD from source
WORKDIR /workspace/OpenBFDD

COPY $CONTAINERS_PATH/openbfdd.patch /tmp/openbfdd.patch

RUN git clone https://github.com/dyninc/OpenBFDD.git \
/workspace/OpenBFDD \
&& \
git apply /tmp/openbfdd.patch \
&& \
./autogen.sh \
&& \
./configure --enable-silent-rules \
&& \
make \
&& \
make install

WORKDIR /workspace

COPY $CONTAINERS_PATH/py-requirements.txt /tmp/py-requirements.txt
Expand Down
39 changes: 39 additions & 0 deletions utilities/containers/openbfdd.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
diff --git a/Logger.cpp b/Logger.cpp
index f375b20..e72afba 100755
--- a/Logger.cpp
+++ b/Logger.cpp
@@ -11,6 +11,8 @@
#include <errno.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
+#include <pthread.h>

const size_t Logger::MaxMessageLen;

diff --git a/SchedulerBase.cpp b/SchedulerBase.cpp
index 3eab298..c1dffc4 100755
--- a/SchedulerBase.cpp
+++ b/SchedulerBase.cpp
@@ -11,6 +11,8 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
+#include <pthread.h>

using namespace std;

diff --git a/utils.cpp b/utils.cpp
index 79c7b68..f846459 100755
--- a/utils.cpp
+++ b/utils.cpp
@@ -13,6 +13,8 @@
#include <sys/stat.h>
#include <sys/param.h>
#include <sys/socket.h>
+#include <time.h>
+#include <pthread.h>

using namespace std;

18 changes: 18 additions & 0 deletions utilities/containers/ubuntu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ RUN git clone git://git.kernel.org/pub/scm/devel/sparse/sparse.git \
&& \
make -j4 PREFIX=/usr HAVE_LLVM= HAVE_SQLITE= install

# Compile OpenBFDD from source
WORKDIR /workspace/OpenBFDD

COPY $CONTAINERS_PATH/openbfdd.patch /tmp/openbfdd.patch

RUN git clone https://github.com/dyninc/OpenBFDD.git \
/workspace/OpenBFDD \
&& \
git apply /tmp/openbfdd.patch \
&& \
./autogen.sh \
&& \
./configure --enable-silent-rules \
&& \
make \
&& \
make install

WORKDIR /workspace

COPY $CONTAINERS_PATH/py-requirements.txt /tmp/py-requirements.txt
Expand Down

0 comments on commit a55eb4a

Please sign in to comment.