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

FRRouting + libyang build #2205

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions .github/workflows/frr-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: libyang+FRR HEAD CI
run-name: libyang CI FRR ${{ github.actor }} ⚗️
on:
workflow_dispatch:
inputs:
frr-versions:
description: 'FRRouting version'
required: true
default: 'master'
type: choice
options:
- master
- pull/15608/head
- frr-10.0
- frr-9.1
- frr-9.0.2
- frr-8.5.4
libyang-versions:
description: 'libyang version'
required: true
default: 'devel'
type: choice
options:
- devel
- v2.1.148
- v2.1.128
# schedule:
# # every night at 1.10
# - cron: '10 1 * * *'
# the following in pending for fixes per the comments of pr !2203
# push:
# branches:
# - '**'
# pull_request:
# branches:
# - '**'
jobs:
build-frr:
name: Build FRR
runs-on: ubuntu-latest
strategy:
matrix:
compiler: [ gcc ]
# frr-versions:
# - frr-9.1
# - frr-9.0.2
# - frr-8.5.4
# libyang-versions:
# - v2.1.128
steps:
- name: add missing packages per building-frr-for-ubuntu2204
uses: ConorMacBride/install-package@v1
with:
apt:
git
autoconf
libtool
make
libreadline-dev
texinfo
pkg-config
libelf-dev
libpam0g-dev
libjson-c-dev
bison
flex
libc-ares-dev
python3-dev
python3-sphinx
install-info
build-essential
libsnmp-dev
perl
libcap-dev
libelf-dev
libunwind-dev
protobuf-c-compiler
libprotobuf-c-dev
libgrpc++-dev
protobuf-compiler-grpc
libsqlite3-dev
libzmq5
libzmq3-dev
python3-pytest
- name: libyang ${{ inputs.libyang-versions }} ${{ matrix.compiler }}
uses: actions/checkout@v4
with:
ref: ${{ inputs.libyang-versions }}
submodules: false
fetch-depth: 0
filter: tree:0
fetch-tags: true
- name: make libyang from upstream
run: >-
git branch &&
mkdir build &&
cd build &&
export CC=${{ matrix.compiler }} &&
cmake -DCMAKE_BUILD_TYPE:String="Release" .. &&
make -j $(nproc) &&
sudo make install
- name: Add FRR user and groups
run: >-
sudo groupadd -r -g 92 frr &&
sudo groupadd -r -g 85 frrvty &&
sudo adduser --system --ingroup frr --home /var/run/frr/ --gecos "FRR suite" --shell /sbin/nologin frr &&
sudo usermod -a -G frrvty frr
- name: FRR github checkout
uses: actions/checkout@v4
with:
repository: 'FRRouting/frr.git'
ref: ${{ inputs.frr-versions }}
submodules: false
fetch-depth: 0
filter: tree:0
fetch-tags: true
- name: compile FRR with ${{ inputs.libyang-versions }} ${{ matrix.compiler }}
if: ${{ always() }}
run: >-
ls -la &&
export CC=${{ matrix.compiler }} &&
./bootstrap.sh &&
./configure \
--prefix=/usr \
--includedir=\${prefix}/include \
--bindir=\${prefix}/bin \
--sbindir=\${prefix}/lib/frr \
--libdir=\${prefix}/lib/frr \
--libexecdir=\${prefix}/lib/frr \
--sysconfdir=/etc \
--localstatedir=/var \
--with-moduledir=\${prefix}/lib/frr/modules \
--enable-configfile-mask=0640 \
--enable-logfile-mask=0640 \
--enable-vtysh \
--enable-pimd \
--enable-pim6d \
--enable-sharpd \
--enable-snmp=agentx \
--enable-multipath=64 \
--enable-user=frr \
--enable-group=frr \
--enable-vty-group=frrvty \
--with-pkg-git-version \
--with-pkg-extra-version=-MyOwnFRRVersion &&
make -j $(nproc) &&
sudo make install &&
cd tests/topotests &&
cd all_protocol_startup && pytest-3 -s -v
32 changes: 19 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# set version of the project
set(LIBYANG_MAJOR_VERSION 2)
set(LIBYANG_MINOR_VERSION 2)
set(LIBYANG_MICRO_VERSION 8)
set(LIBYANG_MICRO_VERSION 10)
set(LIBYANG_VERSION ${LIBYANG_MAJOR_VERSION}.${LIBYANG_MINOR_VERSION}.${LIBYANG_MICRO_VERSION})
# set version of the library
set(LIBYANG_MAJOR_SOVERSION 3)
set(LIBYANG_MINOR_SOVERSION 0)
set(LIBYANG_MICRO_SOVERSION 8)
set(LIBYANG_MICRO_SOVERSION 10)
set(LIBYANG_SOVERSION_FULL ${LIBYANG_MAJOR_SOVERSION}.${LIBYANG_MINOR_SOVERSION}.${LIBYANG_MICRO_SOVERSION})
set(LIBYANG_SOVERSION ${LIBYANG_MAJOR_SOVERSION})

Expand All @@ -78,7 +78,7 @@ else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -std=c11")
endif()

include_directories(${PROJECT_BINARY_DIR}/src ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/plugins_exts)
include_directories(${PROJECT_BINARY_DIR}/libyang ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/plugins_exts)

# type plugins are separate because they have their documentation generated
set(type_plugins
Expand Down Expand Up @@ -205,16 +205,16 @@ set(internal_headers
src/xpath.h)

set(gen_headers
src/version.h
src/ly_config.h)
version.h
ly_config.h)

# files to generate doxygen from
set(doxy_files
doc/build.dox
doc/transition_1_2.dox
doc/transition_2_3.dox
${headers}
${PROJECT_BINARY_DIR}/src/version.h
${PROJECT_BINARY_DIR}/libyang/version.h
${type_plugins})

# project (doxygen) logo
Expand Down Expand Up @@ -246,6 +246,7 @@ option(ENABLE_FUZZ_TARGETS "Build target programs suitable for fuzzing with AFL"
option(ENABLE_INTERNAL_DOCS "Generate doxygen documentation also from internal headers" OFF)
option(ENABLE_YANGLINT_INTERACTIVE "Enable interactive CLI yanglint" ON)
option(ENABLE_TOOLS "Build binary tools 'yanglint' and 'yangre'" ON)
option(ENABLE_COMMON_TARGETS "Define common custom target names such as 'doc' or 'uninstall', may cause conflicts when using add_subdirectory() to build this project" ON)
option(BUILD_SHARED_LIBS "By default, shared libs are enabled. Turn off for a static build." ON)
set(YANG_MODULE_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/yang/modules/libyang" CACHE STRING "Directory where to copy the YANG modules to")

Expand Down Expand Up @@ -321,9 +322,10 @@ if ("${BUILD_TYPE_UPPER}" STREQUAL "DEBUG")
source_format_enable(0.77)
endif()

# generate files
configure_file(${PROJECT_SOURCE_DIR}/src/ly_config.h.in ${PROJECT_BINARY_DIR}/src/ly_config.h @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/src/version.h.in ${PROJECT_BINARY_DIR}/src/version.h @ONLY)
# generate and copy all public header files
configure_file(${PROJECT_SOURCE_DIR}/src/ly_config.h.in ${PROJECT_BINARY_DIR}/libyang/ly_config.h @ONLY)
configure_file(${PROJECT_SOURCE_DIR}/src/version.h.in ${PROJECT_BINARY_DIR}/libyang/version.h @ONLY)
file(COPY ${headers} DESTINATION ${PROJECT_BINARY_DIR}/libyang)

# DOC-only target with no extra dependencies
if("${BUILD_TYPE_UPPER}" STREQUAL "DOCONLY")
Expand Down Expand Up @@ -409,7 +411,7 @@ target_link_libraries(yang ${PCRE2_LIBRARIES})

# generated header list
foreach(h IN LISTS gen_headers)
list(APPEND g_headers ${PROJECT_BINARY_DIR}/${h})
list(APPEND g_headers ${PROJECT_BINARY_DIR}/libyang/${h})
endforeach()

# install the modules
Expand Down Expand Up @@ -462,10 +464,12 @@ if(ENABLE_TOOLS)
endif()

# generate doxygen documentation for libyang API
gen_doc("${doxy_files}" ${LIBYANG_VERSION} ${LIBYANG_DESCRIPTION} ${project_logo})
if(ENABLE_COMMON_TARGETS)
gen_doc("${doxy_files}" ${LIBYANG_VERSION} ${LIBYANG_DESCRIPTION} ${project_logo})
endif()

# generate API/ABI report
if ("${BUILD_TYPE_UPPER}" STREQUAL "ABICHECK")
if("${BUILD_TYPE_UPPER}" STREQUAL "ABICHECK")
lib_abi_check(yang "${headers}" ${LIBYANG_SOVERSION_FULL} dae82c1a652bdca0074544c62469a7f51d92c5e8)
endif()

Expand All @@ -474,7 +478,9 @@ endif()
source_format(${format_sources})

# uninstall
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake")
if(ENABLE_COMMON_TARGETS)
add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake")
endif()

# clean cmake cache
add_custom_target(cclean
Expand Down
40 changes: 17 additions & 23 deletions src/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@ static void
log_vprintf(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, LY_VECODE vecode, char *data_path,
char *schema_path, uint64_t line, const char *apptag, const char *format, va_list args)
{
char *msg = NULL;
char *dyn_msg = NULL;
const char *msg;
ly_bool free_strs = 1, lolog, lostore;

/* learn effective logger options */
Expand All @@ -610,33 +611,26 @@ log_vprintf(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, LY_VECODE
}

if (err == LY_EMEM) {
/* just print it, anything else would most likely fail anyway */
if (lolog) {
if (log_clb) {
log_clb(level, LY_EMEM_MSG, data_path, schema_path, line);
} else {
fprintf(stderr, "libyang[%d]: ", level);
vfprintf(stderr, format, args);
log_stderr_path_line(data_path, schema_path, line);
}
/* no not use more dynamic memory */
vsnprintf(last_msg, LY_LAST_MSG_SIZE, format, args);
msg = last_msg;
} else {
/* print into a single message */
if (vasprintf(&dyn_msg, format, args) == -1) {
LOGMEM(ctx);
goto cleanup;
}
goto cleanup;
}
msg = dyn_msg;

/* print into a single message */
if (vasprintf(&msg, format, args) == -1) {
LOGMEM(ctx);
goto cleanup;
/* store as the last message */
strncpy(last_msg, msg, LY_LAST_MSG_SIZE - 1);
}

/* store as the last message */
strncpy(last_msg, msg, LY_LAST_MSG_SIZE - 1);

/* store the error/warning in the context (if we need to store errors internally, it does not matter what are
* the user log options) */
if ((level < LY_LLVRB) && ctx && lostore) {
* the user log options), if the message is not dynamic, it would most likely fail to store (no memory) */
if ((level < LY_LLVRB) && ctx && lostore && dyn_msg) {
free_strs = 0;
if (log_store(ctx, level, err, vecode, msg, data_path, schema_path, line, apptag ? strdup(apptag) : NULL)) {
if (log_store(ctx, level, err, vecode, dyn_msg, data_path, schema_path, line, apptag ? strdup(apptag) : NULL)) {
goto cleanup;
}
}
Expand All @@ -656,7 +650,7 @@ log_vprintf(const struct ly_ctx *ctx, LY_LOG_LEVEL level, LY_ERR err, LY_VECODE
if (free_strs) {
free(data_path);
free(schema_path);
free(msg);
free(dyn_msg);
}
}

Expand Down
Loading
Loading