Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
eacbf7b
FreeBSD: add FreeBSD-specific build wrapper
kostikbel Dec 25, 2025
34c926d
libibverbs/cmd_ioctl.h: fix typo in comment
kostikbel Mar 9, 2026
323df82
test version script: symbols are exported from the binary on FreeBSD
kostikbel Nov 5, 2025
66cfc92
buildlib/rdma_functions.cmake: drop -T option from ln(1) invocation
kostikbel Nov 5, 2025
b09d28a
buildlib/config.h.in: Make RDMA_CDEV_DIR right on FreeBSD
kostikbel Feb 17, 2026
7c8652f
CMakeLists.txt: netlink/netlink.h and netlink/route/route.h exist on …
kostikbel Dec 25, 2025
95407d3
librdmacm: on FreeBSD, epoll() is provided by epoll-shim
kostikbel Dec 25, 2025
52542fe
*/*: AF_* come from sys/socket.h
kostikbel Dec 24, 2025
b9aa650
*/*: add netinet/in.h and linux/ip6.h headers
kostikbel Dec 24, 2025
4eb510d
libibverbs/examples/xsrq_pingpong.c: needs sys/stat.h for S_IRUSR and…
kostikbel Dec 25, 2025
0e8c2f5
*/*: avoid redefining ALIGN() macro
kostikbel Dec 25, 2025
5c88958
librdmacm/preload.c: handle namespace polluition from the epoll-shim
kostikbel Jul 21, 2026
4a9c51c
librdmacm/preload.c: account for differences in sendfile with FreeBSD
kostikbel Dec 26, 2025
c3eb970
librdmacm/preload.c: switch init control to pthread_once
kostikbel Dec 26, 2025
f88f18b
librdmacm/preload.c: provide program_invocation_short_name for FreeBSD
kostikbel Dec 26, 2025
b583c84
librdmacm/preload.c: conditionalize handling of non-portable fcntls
kostikbel Dec 26, 2025
ef278a8
FreeBSD: add compat headers to mimic Linux build environment
kostikbel Dec 3, 2025
51dac0d
madvise(MADV_*FORK) is spelled minherit(2) on FreeBSD
kostikbel Dec 26, 2025
68c1a44
providers/rxe/rxe.c: use portable way to name ipv6 address field in s…
kostikbel Dec 28, 2025
9576d00
pyverbs/providers/mlx5/dr_action.pyx: fix type mismatch
kostikbel Dec 27, 2025
4c99329
libibverbs: Split Linux-specific initialization into dedicated source
kostikbel Jan 10, 2026
5cb3a56
libibverbs: Add FreeBSD-specific implementation of init and sysfs access
kostikbel Jan 19, 2026
a81239d
libibverbs/sysfs-sysctl.c: hack for ibv_read_ibdev_sysfs_file("device…
kostikbel Feb 10, 2026
dbaf1e3
FreeBSD: add IBVERBS_SYSCTL_VERBOSE
kostikbel Feb 2, 2026
983a018
Add README-FreeBSD.txt
kostikbel Dec 28, 2025
6d95ab4
buildlib/make_abi_structs.py: allow #ifdef <system name>
kostikbel Jun 2, 2026
1090cdd
kernel-headers/rdma/mlx5-abi.h: provide FreeBSD layout for mlx5_ib_cr…
kostikbel Jun 2, 2026
a207c6f
FreeBSD github ci workflow
kostikbel Jul 13, 2026
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
34 changes: 34 additions & 0 deletions .github/workflows/freebsd-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: FreeBSD Build

on:
push:
branches: [ "freebsd" ]
pull_request:
branches: [ "freebsd" ]

jobs:
build-freebsd:
# vmactions runs a QEMU VM inside an Ubuntu runner, so runs-on MUST be ubuntu-latest
runs-on: ubuntu-latest
name: Build rdma-core on FreeBSD

steps:
# Step 1: Check out your rdma-core repository into the Ubuntu host runner
- name: Checkout Code
uses: actions/checkout@v4

# Step 2: Fire up the FreeBSD VM and execute the build steps
- name: Build in FreeBSD VM
uses: vmactions/freebsd-vm@v1
with:
release: "15.1"
usesh: true # Use standard sh rather than tcsh (default shell on FreeBSD)

# The 'prepare' section runs inside the VM before copying files,
# ideal for installing system package dependencies.
prepare: |
uname -a
pkg install -y gcc cmake ninja python3 bash libepoll-shim pkgconf lang/cython

run: |
bash build-freebsd.sh
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -564,13 +564,15 @@ else()
set(NL_LIBRARIES "")
RDMA_DoFixup(0 "netlink/attr.h")
RDMA_DoFixup(0 "netlink/msg.h")
RDMA_DoFixup(0 "netlink/netlink.h")
RDMA_DoFixup(0 "netlink/object-api.h")
RDMA_DoFixup(0 "netlink/route/link.h")
RDMA_DoFixup(0 "netlink/route/link/vlan.h")
RDMA_DoFixup(0 "netlink/route/neighbour.h")
RDMA_DoFixup(0 "netlink/route/route.h")
RDMA_DoFixup(0 "netlink/route/rtnl.h")
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
RDMA_DoFixup(0 "netlink/netlink.h")
RDMA_DoFixup(0 "netlink/route/route.h")
endif()
endif()

# Older stuff blows up if these headers are included together
Expand Down Expand Up @@ -793,6 +795,9 @@ add_subdirectory(util/tests)
add_subdirectory(Documentation)
add_subdirectory(kernel-boot)
add_subdirectory(kernel-headers)
if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
add_subdirectory(freebsd-headers)
endif()
# Libraries
add_subdirectory(libibumad)
add_subdirectory(libibumad/man)
Expand Down
26 changes: 26 additions & 0 deletions README-FreeBSD.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
The port just compiles.

FreeBSD version should be main or stable/15, after the tdestroy(3) and
strdupa()/strndupa() additions.

You need to install the following packages:
cmake-core
ninja
gcc
python3
pyXXX-cython3
pyXXX-docutils
bash
libepoll-shim
pkgconf

1. All fake constants for (rt)netlink that are added in
freebsd-headers/linux point to the usage areas that need porting.
2. sysfs accesses must be replaced by sysctl.
Similarly, there should be use of /proc that needs to be ported.
3. I have no idea if the FreeBSD verbs/drivers ABI is compatible with
the Linux provided by kernel-headers/*.
4. Tests for the compilation environment properties done in CMakeLists.txt
are performed before the freebsd-headers get chance to populate build
environment. As such, some tests provide invalid results, e.g.
the co-existence of netinet/in.h and linux/in*.h.
22 changes: 22 additions & 0 deletions build-freebsd.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
set -e

LOCALBASE=$(/sbin/sysctl -n user.localbase)
CMAKE=${LOCALBASE}/bin/cmake
NINJA=${LOCALBASE}/bin/ninja
PYTHON=${LOCALBASE}/bin/python3
GCC=${LOCALBASE}/bin/gcc
GXX=${LOCALBASE}/bin/g++

SRCDIR=$(dirname $0)
BUILDDIR=${SRCDIR}/build

mkdir -p ${BUILDDIR}

cd ${BUILDDIR}

${CMAKE} -DIN_PLACE=1 -GNinja -DENABLE_RESOLVE_NEIGH=0 -DIOCTL_MODE=write \
-DPYTHON_EXECUTABLE=${PYTHON} \
-DCMAKE_C_COMPILER=${GCC} -DCMAKE_CXX_COMPILER=${GXX} \
${EXTRA_CMAKE_FLAGS:-} ..
${NINJA} -k 0
10 changes: 9 additions & 1 deletion buildlib/FindLDSymVer.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
# find_package helper to detect symbol version support in the compiler and
# linker. If supported then LDSYMVER_MODE will be set to GNU

if (CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
set(GLOBAL_SYMBOLS_BIN "
environ;
__progname;
")
endif()

# Basic sample GNU style map file
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test.map" "
IBVERBS_1.0 {
global:
ibv_get_device_list;
local: *;
${GLOBAL_SYMBOLS_BIN}
local: *;
};

IBVERBS_1.1 {
Expand Down
4 changes: 4 additions & 0 deletions buildlib/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
// FIXME: Remove this, The cmake version hard-requires new style CLOEXEC support
#define STREAM_CLOEXEC "e"

#if defined __linux__
#define RDMA_CDEV_DIR "/dev/infiniband"
#elif defined __FreeBSD__
#define RDMA_CDEV_DIR "/dev"
#endif

#define IBV_CONFIG_DIR "@CONFIG_DIR@"
#define RS_CONF_DIR "@CMAKE_INSTALL_FULL_SYSCONFDIR@/rdma/rsocket"
Expand Down
31 changes: 27 additions & 4 deletions buildlib/make_abi_structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,33 @@
import re;
import functools;
import sys;
import os;

def in_struct(ln,FO,nesting=0):
sysname=sys.argv[3]

def cpre_sysname():
mapping = {"Linux": "__linux__", "FreeBSD": "__FreeBSD__"}
try:
return mapping[sysname]
except KeyError:
raise NotImplementedError(sysname)

def in_struct(ln,FO,nesting=0,wait_for_endif=False,skip=False):
"""Copy a top level structure over to the #define output, keeping track of
nested structures."""
if wait_for_endif:
g = re.match(r"#endif", ln)
if g != None:
return functools.partial(in_struct,nesting=nesting,wait_for_endif=False,skip=False)
g = re.match(r"#ifdef\s+(\S+)",ln)
if g != None:
ifdefsym = g.group(1)
if ifdefsym == cpre_sysname():
return functools.partial(in_struct,nesting=nesting,wait_for_endif=True,skip=False)
return functools.partial(in_struct,nesting=nesting,wait_for_endif=True,skip=True)
if skip:
return functools.partial(in_struct,nesting=nesting,wait_for_endif=wait_for_endif,skip=skip)

if nesting == 0:
if re.match(r"(}.*);",ln):
FO.write(ln[:-1] + "\n\n");
Expand All @@ -31,11 +54,11 @@ def in_struct(ln,FO,nesting=0):
FO.write(ln + " \\\n");

if ln == "struct {" or ln == "union {":
return functools.partial(in_struct,nesting=nesting+1);
return functools.partial(in_struct,nesting=nesting+1,wait_for_endif=wait_for_endif,skip=skip);

if re.match(r"}.*;",ln):
return functools.partial(in_struct,nesting=nesting-1);
return functools.partial(in_struct,nesting=nesting);
return functools.partial(in_struct,nesting=nesting-1,wait_for_endif=wait_for_endif,skip=skip);
return functools.partial(in_struct,nesting=nesting,wait_for_endif=wait_for_endif,skip=skip);

def find_struct(ln,FO):
"""Look for the start of a top level structure"""
Expand Down
2 changes: 1 addition & 1 deletion buildlib/rdma_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function(rdma_create_symlink LINK_CONTENT DEST)

# Newer versions of cmake can use "${CMAKE_COMMAND}" "-E" "create_symlink"
# however it is broken weirdly on older versions.
execute_process(COMMAND "ln" "-Tsf"
execute_process(COMMAND "ln" "-sf"
"${LINK_CONTENT}" "${DEST}" RESULT_VARIABLE retcode)
if(NOT "${retcode}" STREQUAL "0")
message(FATAL_ERROR "Failed to create symlink in ${DEST}")
Expand Down
31 changes: 31 additions & 0 deletions freebsd-headers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
publish_internal_headers(""
alloca.h
errno.h
limits.h
string.h
)

publish_internal_headers(netinet
netinet/in.h
netinet/tcp.h
)

publish_internal_headers(sys
sys/mman.h
sys/sendfile.h
sys/shm.h
sys/socket.h
sys/sysmacros.h
)

publish_internal_headers(linux
linux/if_ether.h
linux/in.h
linux/in6.h
linux/ioctl.h
linux/ip.h
linux/netlink.h
linux/rtnetlink.h
linux/socket.h
linux/types.h
)
6 changes: 6 additions & 0 deletions freebsd-headers/alloca.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef __FREEBSD_ALLOCA_H__
#define __FREEBSD_ALLOCA_H__

/* empty */

#endif
10 changes: 10 additions & 0 deletions freebsd-headers/errno.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __FREEBSD_ERRNO_H__
#define __FREEBSD_ERRNO_H__

#include_next <errno.h>
#define ENODATA 100000
#define EBADE 100001
#define EREMOTEIO 100002
#define ENONET 100003

#endif
10 changes: 10 additions & 0 deletions freebsd-headers/limits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef __FREEBSD_LIMITS_H__
#define __FREEBSD_LIMITS_H__

#include <sys/param.h>

#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX MAXHOSTNAMELEN
#endif

#endif
4 changes: 4 additions & 0 deletions freebsd-headers/linux/if_ether.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include <net/ethernet.h>

#define ETH_ALEN ETHER_ADDR_LEN

4 changes: 4 additions & 0 deletions freebsd-headers/linux/in.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef __FREEBSD_LINUX_IN_H__
#define __FREEBSD_LINUX_IN_H__

#endif
25 changes: 25 additions & 0 deletions freebsd-headers/linux/in6.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#ifndef __FREEBSD_LINUX_IN6_H__
#define __FREEBSD_LINUX_IN6_H__

#include <linux/types.h>
#include <netinet/in.h>

struct linux_in6_addr {
union {
__u8 __u6_addr8[16];
__be16 __u6_addr16[8];
__be32 __u6_addr32[4];
} __in6_u;
};

#undef s6_addr
#define s6_addr __in6_u.__u6_addr8
#undef s6_addr16
#define s6_addr16 __in6_u.__u6_addr16
#undef s6_addr32
#define s6_addr32 __in6_u.__u6_addr32

#define in6_addr linux_in6_addr
#define in6_u __in6_u

#endif
1 change: 1 addition & 0 deletions freebsd-headers/linux/ioctl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <sys/ioctl.h>
31 changes: 31 additions & 0 deletions freebsd-headers/linux/ip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef __FREEBSD_LINUX_IP_H__
#define __FREEBSD_LINUX_IP_H__

#include <sys/endian.h>
#include <sys/socket.h>
#include <linux/types.h>

struct iphdr {
#if BYTE_ORDER == LITTLE_ENDIAN
__u8 ihl:4,
version:4;
#endif
#if BYTE_ORDER == BIG_ENDIAN
__u8 version:4,
ihl:4;
#endif
__u8 tos;
__be16 tot_len;
__be16 id;
__be16 frag_off;
__u8 ttl;
__u8 protocol;
__sum16 check;
__struct_group(/* no tag */, addrs, /* no attrs */,
__be32 saddr;
__be32 daddr;
);
/*The options start here. */
};

#endif
7 changes: 7 additions & 0 deletions freebsd-headers/linux/netlink.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __FREEBSD_LINUX_NETLINK_H
#define __FREEBSD_LINUX_NETLINK_H

#include <netlink/netlink.h>
#define NETLINK_RDMA 1000000

#endif
7 changes: 7 additions & 0 deletions freebsd-headers/linux/rtnetlink.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#ifndef __FREEBSD_LINUX_RTNETLINK_H__
#define __FREEBSD_LINUX_RTNETLINK_H__

#include <netlink/route/common.h>
#include <netlink/route/route.h>

#endif
4 changes: 4 additions & 0 deletions freebsd-headers/linux/socket.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#ifndef __FREEBSD_LINUX_SOCKET_H__
#define __FREEBSD_LINUX_SOCKET_H__

#endif
27 changes: 27 additions & 0 deletions freebsd-headers/linux/stddef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef __FREEBSD_LINUX_STDDEF_H__
#define __FREEBSD_LINUX_STDDEF_H__

#ifndef __cplusplus
#define __struct_group_tag(TAG) TAG
#else
#define __struct_group_tag(TAG)
#endif

#define __struct_group(TAG, NAME, ATTRS, MEMBERS...) \
union { \
struct { MEMBERS } ATTRS; \
struct __struct_group_tag(TAG) { MEMBERS } ATTRS NAME; \
} ATTRS

#ifdef __cplusplus
#define __DECLARE_FLEX_ARRAY(T, member) \

Check failure on line 17 in freebsd-headers/linux/stddef.h

View check run for this annotation

Azure Pipelines / linux-rdma.rdma-core (Build Compile Tests)

freebsd-headers/linux/stddef.h#L17

freebsd-headers/linux/stddef.h(17,): error COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses

Check failure on line 17 in freebsd-headers/linux/stddef.h

View check run for this annotation

Azure Pipelines / linux-rdma.rdma-core

freebsd-headers/linux/stddef.h#L17

freebsd-headers/linux/stddef.h(17,): error COMPLEX_MACRO: Macros with complex values should be enclosed in parentheses
T member[0]
#else
#define __DECLARE_FLEX_ARRAY(TYPE, NAME) \
struct { \
struct { } __empty_ ## NAME; \
TYPE NAME[]; \
}
#endif

#endif
Loading
Loading