-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[src/libraries/sonic-fib]: Add sonic-fib library to build libnexthopgroup deb for RIB/FIB #26423
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
Merged
eddieruan-alibaba
merged 2 commits into
sonic-net:master
from
GaladrielZhao:ribfib/sonic-fib
May 19, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
|
|
||
| SPATH := $($(LIBFIB)_SRC_PATH) | ||
| DEP_FILES := $(SONIC_COMMON_FILES_LIST) rules/sonic-fib.mk rules/sonic-fib.dep | ||
| DEP_FILES += $(SONIC_COMMON_BASE_FILES_LIST) | ||
| SMDEP_FILES := $(addprefix $(SPATH)/,$(shell cd $(SPATH) && git ls-files)) | ||
|
|
||
| $(LIBFIB)_CACHE_MODE := GIT_CONTENT_SHA | ||
| $(LIBFIB)_DEP_FLAGS := $(SONIC_COMMON_FLAGS_LIST) | ||
| $(LIBFIB)_DEP_FILES := $(DEP_FILES) | ||
| $(LIBFIB)_SMDEP_FILES := $(SMDEP_FILES) | ||
| $(LIBFIB)_SMDEP_PATHS := $(SPATH) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # libFIB package | ||
|
|
||
| LIBFIB_VERSION = 1.0.0 | ||
| LIBFIB_NAME = libnexthopgroup | ||
|
|
||
| LIBFIB = $(LIBFIB_NAME)_$(LIBFIB_VERSION)_$(CONFIGURED_ARCH).deb | ||
| $(LIBFIB)_SRC_PATH = $(SRC_PATH)/libraries/sonic-fib | ||
| $(LIBFIB)_VERSION = $(LIBFIB_VERSION) | ||
| $(LIBFIB)_NAME = $(LIBFIB_NAME) | ||
|
|
||
| SONIC_DPKG_DEBS += $(LIBFIB) | ||
|
|
||
| LIBFIB_DEV = $(LIBFIB_NAME)-dev_$(LIBFIB_VERSION)_$(CONFIGURED_ARCH).deb | ||
| $(eval $(call add_derived_package,$(LIBFIB),$(LIBFIB_DEV))) | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| # The .c, .cpp, .h & .hpp files under src/{$DBG_SRC_ARCHIVE list} | ||
| # are archived into debug one image to facilitate debugging. | ||
| # | ||
| DBG_SRC_ARCHIVE += libraries/sonic-fib | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # Compiled Source # | ||
| ################### | ||
| *.la | ||
| *.lo | ||
| *.o | ||
| *.swp | ||
| *.gcda | ||
| *.gcno | ||
| *.gcov | ||
| *.deb | ||
|
|
||
|
|
||
|
|
||
| # Packaging Files # | ||
| ################### | ||
| debian/.debhelper/ | ||
| debian/autoreconf.after | ||
| debian/autoreconf.before | ||
| debian/debhelper-build-stamp | ||
| debian/files | ||
| debian/*.debhelper.log | ||
| debian/*.substvars | ||
| debian/tmp/ | ||
|
|
||
| aclocal.m4 | ||
| autom4te.cache/ | ||
| config | ||
| config.h | ||
| config.h.in | ||
| config.h.in~ | ||
| config.log | ||
| config.status | ||
| configure | ||
| libtool | ||
| m4/libtool.m4 | ||
| m4/ltoptions.m4 | ||
| m4/ltsugar.m4 | ||
| m4/ltversion.m4 | ||
| m4/lt~obsolete.m4 | ||
| Makefile.in | ||
| stamp-h1 | ||
| .dirstamp | ||
| **/.deps/ | ||
| **/.libs/ | ||
| **/Makefile | ||
|
|
||
| # Executables # | ||
| ############### | ||
| tests/tests | ||
|
|
||
| # Bazel Build System # | ||
| /bazel-* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| lib_LTLIBRARIES = | ||
| bin_PROGRAMS = | ||
|
|
||
| if DEBUG | ||
| DBGFLAGS = -ggdb -DDEBUG -gdwarf-5 | ||
| else | ||
| DBGFLAGS = -g -DNDEBUG | ||
| endif | ||
|
|
||
| CLEANFILES = | ||
|
|
||
| include src/Makefile.am | ||
| include tests/Makefile.am | ||
|
|
||
| ACLOCAL_AMFLAGS = -I m4 | ||
|
|
||
|
|
||
| EXTRA_DIST += scripts/render_schema.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # sonic-fib | ||
|
|
||
| ## Cheating Sheet | ||
| ### 1. Clean stale build artifacts | ||
| make distclean 2>/dev/null || true | ||
| rm -rf autom4te.cache config.log config.status | ||
|
|
||
| ### 2. Regenerate build system (critical after Makefile.am changes) | ||
| autoreconf -fiv | ||
|
|
||
| ### 3. Reconfigure | ||
| ./configure | ||
|
|
||
| ### 4. Build (includes tests) | ||
| make -j$(nproc) | ||
|
|
||
| ### 5. Run tests (uses pre-built binary) | ||
| ``` | ||
| make check | ||
| make check V=1 # Verbose output | ||
| ``` | ||
|
|
||
| Note: | ||
| 1. Step 1 and Step 2 are used for installing test_drivers. Use the following command to check ls -la config/test-driver | ||
| 2. test log is at tests/tests.log |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| #!/bin/bash | ||
|
|
||
| libtoolize --force --copy && | ||
| autoreconf --force --install -I m4 | ||
| rm -Rf autom4te.cache | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| AC_INIT([fib],[1.0.0]) | ||
| AC_CONFIG_SRCDIR([]) | ||
| AC_CONFIG_AUX_DIR(config) | ||
| AM_CONFIG_HEADER(config.h) | ||
| AC_CONFIG_MACRO_DIR([m4]) | ||
| AM_INIT_AUTOMAKE([foreign subdir-objects parallel-tests]) | ||
| AC_LANG_C | ||
| AC_LANG([C++]) | ||
| AC_PROG_CC | ||
| AC_PROG_CXX | ||
| AC_PROG_LIBTOOL | ||
| AC_HEADER_STDC | ||
| AM_PATH_PYTHON | ||
| AM_PATH_PYTHON3 | ||
| AX_ADD_AM_MACRO_STATIC([]) | ||
|
|
||
| AC_ARG_ENABLE(debug, | ||
| [ --enable-debug Compile with debugging flags], | ||
| [case "${enableval}" in | ||
| yes) debug=true ;; | ||
| no) debug=false ;; | ||
| *) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;; | ||
| esac],[debug=false]) | ||
| AM_CONDITIONAL(DEBUG, test x$debug = xtrue) | ||
| if test x$CONFIGURED_ARCH = xarmhf && test x$CROSS_BUILD_ENVIRON = xy; then | ||
| AM_CONDITIONAL(ARCH64, false) | ||
| else | ||
| AM_CONDITIONAL(ARCH64, test `getconf LONG_BIT` = "64") | ||
| fi | ||
|
|
||
|
|
||
| CFLAGS_COMMON="" | ||
| CFLAGS_COMMON+=" -ansi" | ||
| CFLAGS_COMMON+=" -fPIC" | ||
| CFLAGS_COMMON+=" -std=c++14" | ||
| CFLAGS_COMMON+=" -Wall" | ||
| CFLAGS_COMMON+=" -Wcast-align" | ||
| CFLAGS_COMMON+=" -Wcast-qual" | ||
| CFLAGS_COMMON+=" -Wconversion" | ||
| CFLAGS_COMMON+=" -Wdisabled-optimization" | ||
| CFLAGS_COMMON+=" -Werror" | ||
| CFLAGS_COMMON+=" -Wextra" | ||
| CFLAGS_COMMON+=" -Wfloat-equal" | ||
| CFLAGS_COMMON+=" -Wformat=2" | ||
| CFLAGS_COMMON+=" -Wformat-nonliteral" | ||
| CFLAGS_COMMON+=" -Wformat-security" | ||
| CFLAGS_COMMON+=" -Wformat-y2k" | ||
| CFLAGS_COMMON+=" -Wimport" | ||
| CFLAGS_COMMON+=" -Winit-self" | ||
| CFLAGS_COMMON+=" -Winvalid-pch" | ||
| CFLAGS_COMMON+=" -Wlong-long" | ||
| CFLAGS_COMMON+=" -Wmissing-field-initializers" | ||
| CFLAGS_COMMON+=" -Wmissing-format-attribute" | ||
| CFLAGS_COMMON+=" -Wmissing-include-dirs" | ||
| CFLAGS_COMMON+=" -Wmissing-noreturn" | ||
| CFLAGS_COMMON+=" -Wno-aggregate-return" | ||
| CFLAGS_COMMON+=" -Wno-padded" | ||
| CFLAGS_COMMON+=" -Wno-switch-enum" | ||
| CFLAGS_COMMON+=" -Wno-unused-parameter" | ||
| CFLAGS_COMMON+=" -Wpacked" | ||
| CFLAGS_COMMON+=" -Wpointer-arith" | ||
| CFLAGS_COMMON+=" -Wredundant-decls" | ||
| CFLAGS_COMMON+=" -Wshadow" | ||
| CFLAGS_COMMON+=" -Wstack-protector" | ||
| CFLAGS_COMMON+=" -Wstrict-aliasing=3" | ||
| CFLAGS_COMMON+=" -Wswitch" | ||
| CFLAGS_COMMON+=" -Wswitch-default" | ||
| CFLAGS_COMMON+=" -Wunreachable-code" | ||
| CFLAGS_COMMON+=" -Wunused" | ||
| CFLAGS_COMMON+=" -Wvariadic-macros" | ||
| CFLAGS_COMMON+=" -Wno-write-strings" | ||
| CFLAGS_COMMON+=" -Wno-missing-format-attribute" | ||
| CFLAGS_COMMON+=" -Wno-long-long" | ||
| CFLAGS_COMMON+=" -fstack-protector-strong" | ||
|
|
||
| AC_SUBST(CFLAGS_COMMON) | ||
|
|
||
| AC_CONFIG_FILES([ | ||
| Makefile | ||
| ]) | ||
|
|
||
| AC_OUTPUT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| sonic-fib (1.0.0) stable; urgency=medium | ||
|
|
||
| * Initial release. | ||
|
|
||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| 12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| Source: sonic-fib | ||
| Section: libs | ||
| Maintainer: Eddie Ruan <your-email@example.com> | ||
| Priority: optional | ||
| Build-Depends: debhelper (>= 12), | ||
| autotools-dev, | ||
| python3, | ||
| nlohmann-json3-dev, | ||
| libgtest-dev, | ||
| libgmock-dev | ||
| Standards-Version: 1.0.0 | ||
|
|
||
| Package: libnexthopgroup | ||
| Architecture: any | ||
| Depends: ${shlibs:Depends}, ${misc:Pre-Depends} | ||
| Section: libs | ||
| Description: NextHopGroup serialization library for SONiC FIB This library provides JSON-based serialization for NextHopGroup data structures used between FRR (zebra) and fpmsyncd. | ||
|
|
||
| Package: libnexthopgroup-dev | ||
| Architecture: any | ||
| Depends: libnexthopgroup (= ${binary:Version}), nlohmann-json3-dev, ${misc:Depends} | ||
| Section: libdevel | ||
| Description: This package contains development files for nexthopgroup | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| usr/lib | ||
| usr/include/nexthopgroup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| usr/include/nexthopgroup/ | ||
| usr/include/nexthopgroup/c-api/ | ||
| usr/lib/*/libnexthopgroup.so |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| usr/lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| usr/lib/*/libnexthopgroup.so.* | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #!/usr/bin/make -f | ||
|
|
||
| # Enable security hardening | ||
| export DEB_BUILD_MAINT_OPTIONS = hardening=+all | ||
|
|
||
| # Import default build flags (CFLAGS, LDFLAGS, etc.) | ||
| DPKG_EXPORT_BUILDFLAGS = 1 | ||
| include /usr/share/dpkg/default.mk | ||
|
|
||
| # Configure arguments: disable static lib, enable shared | ||
| export CONFIGURE_ARGS = --disable-static --enable-shared | ||
|
|
||
| # Use autoreconf to ensure configure is up to date | ||
| %: | ||
| dh $@ --with autoreconf | ||
|
|
||
| # Optional: override configure if you need extra flags later | ||
| override_dh_auto_configure: | ||
| dh_auto_configure -- $(CONFIGURE_ARGS) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.