shared/n-acd: reimport

git subtree pull --prefix shared/n-acd git@github.com:nettools/n-acd.git master --squash
This commit is contained in:
Thomas Haller 2020-06-03 22:12:09 +02:00
commit 53f27cfd40
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
12 changed files with 138 additions and 57 deletions

View file

@ -1,12 +0,0 @@
#!/bin/bash
set -e
rm -Rf "./ci-build"
mkdir "./ci-build"
cd "./ci-build"
${CHERRY_LIB_MESONSETUP} . "${CHERRY_LIB_SRCDIR}" ${N_ACD_CONF}
${CHERRY_LIB_NINJABUILD}
${CHERRY_LIB_MESONTEST}
# no valgrind tests, since bpf(2) is not supported by it

View file

@ -1,5 +0,0 @@
#!/bin/bash
set -e
CHERRY_MATRIX+=("export N_ACD_CONF=-Debpf=false ${CHERRY_LIB_M_DEFAULT[*]}")

122
shared/n-acd/.github/workflows/ci.yml vendored Normal file
View file

@ -0,0 +1,122 @@
name: Continuous Integration
on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'
jobs:
ci:
name: CI with Default Configuration
runs-on: ubuntu-latest
steps:
#
# Prepare CI
#
# We cannot use the github-action of the `ci-c-util` project, because we
# need privileges in the container. Therefore, fetch the CI sources and
# build the container manually.
#
- name: Fetch CI
uses: actions/checkout@v2
with:
repository: c-util/automation
ref: v1
path: automation
- name: Build CI
working-directory: automation/src/ci-c-util
run: docker build --tag ci-c-util:v1 .
#
# Run CI
#
# Take the CI image we built and run the CI with the default project
# configuration. We do not use valgrind, since it falls-over with bpf(2)
# syscalls.
#
- name: Fetch Sources
uses: actions/checkout@v2
with:
path: source
- name: Run through C-Util CI
run: |
docker run \
--privileged \
-v "$(pwd)/source:/github/workspace" \
"ci-c-util:v1" \
"--m32=1" \
"--source=/github/workspace"
ci-no-ebpf:
name: CI without eBPF
runs-on: ubuntu-latest
steps:
# See above in 'ci' job.
- name: Fetch CI
uses: actions/checkout@v2
with:
repository: c-util/automation
ref: v1
path: automation
- name: Build CI
working-directory: automation/src/ci-c-util
run: docker build --tag ci-c-util:v1 .
#
# Run CI
#
# This again runs the CI, but this time disables eBPF. We do support the
# legacy BPF fallback, so lets make sure we test for it.
#
- name: Fetch Sources
uses: actions/checkout@v2
with:
path: source
- name: Run through C-Util CI
run: |
docker run \
--privileged \
-v "$(pwd)/source:/github/workspace" \
"ci-c-util:v1" \
"--m32=1" \
"--mesonargs=-Debpf=false" \
"--source=/github/workspace"
ci-valgrind:
name: CI through Valgrind
runs-on: ubuntu-latest
steps:
# See above in 'ci' job.
- name: Fetch CI
uses: actions/checkout@v2
with:
repository: c-util/automation
ref: v1
path: automation
- name: Build CI
working-directory: automation/src/ci-c-util
run: docker build --tag ci-c-util:v1 .
#
# Run CI
#
# This again runs the CI, but this time through valgrind. Since some
# syscalls are not implemented on x86-64 32bit compat (e.g., bpf(2)), we
# disable the m32 mode.
#
- name: Fetch Sources
uses: actions/checkout@v2
with:
path: source
- name: Run through C-Util CI
run: |
docker run \
--privileged \
-v "$(pwd)/source:/github/workspace" \
"ci-c-util:v1" \
"--source=/github/workspace" \
"--valgrind=1"

View file

@ -1,21 +0,0 @@
os: linux
dist: trusty
language: c
services:
- docker
before_install:
- curl -O -L "https://raw.githubusercontent.com/cherry-pick/cherry-images/v1/scripts/vmrun"
- curl -O -L "https://raw.githubusercontent.com/cherry-pick/cherry-ci/v1/scripts/cherryci"
- chmod +x "./vmrun" "./cherryci"
jobs:
include:
- stage: test
script:
- ./vmrun -- ../src/cherryci -d ../src/.cherryci -s c-util -m
- script:
- ./vmrun -T armv7hl -- ../src/cherryci -d ../src/.cherryci -s c-util
- script:
- ./vmrun -T i686 -- ../src/cherryci -d ../src/.cherryci -s c-util

View file

@ -1,5 +1,3 @@
# SPDX-License-Identifier: LGPL-2.1+
project(
'n-acd',
'c',

View file

@ -1,5 +1,3 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# target: libnacd.so
#

View file

@ -328,6 +328,7 @@ int n_acd_ensure_bpf_map_space(NAcd *acd) {
_c_public_ int n_acd_new(NAcd **acdp, NAcdConfig *config) {
_c_cleanup_(n_acd_unrefp) NAcd *acd = NULL;
_c_cleanup_(c_closep) int fd_bpf_prog = -1;
struct epoll_event eevent;
int r;
if (config->ifindex <= 0 ||
@ -370,19 +371,19 @@ _c_public_ int n_acd_new(NAcd **acdp, NAcdConfig *config) {
if (r)
return r;
r = epoll_ctl(acd->fd_epoll, EPOLL_CTL_ADD, acd->timer.fd,
&(struct epoll_event){
.events = EPOLLIN,
.data.u32 = N_ACD_EPOLL_TIMER,
});
eevent = (struct epoll_event){
.events = EPOLLIN,
.data.u32 = N_ACD_EPOLL_TIMER,
};
r = epoll_ctl(acd->fd_epoll, EPOLL_CTL_ADD, acd->timer.fd, &eevent);
if (r < 0)
return -c_errno();
r = epoll_ctl(acd->fd_epoll, EPOLL_CTL_ADD, acd->fd_socket,
&(struct epoll_event){
.events = EPOLLIN,
.data.u32 = N_ACD_EPOLL_SOCKET,
});
eevent = (struct epoll_event){
.events = EPOLLIN,
.data.u32 = N_ACD_EPOLL_SOCKET,
};
r = epoll_ctl(acd->fd_epoll, EPOLL_CTL_ADD, acd->fd_socket, &eevent);
if (r < 0)
return -c_errno();

View file

@ -93,7 +93,7 @@ static void verify_failure(struct ether_arp *packet, int out_fd, int in_fd) {
}
static void test_filter(void) {
uint8_t buf[sizeof(struct ether_arp) + 1];
uint8_t buf[sizeof(struct ether_arp) + 1] = {};
struct ether_addr mac1 = { { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 } };
struct ether_addr mac2 = { { 0x01, 0x02, 0x03, 0x04, 0x05, 0x07 } };
struct in_addr ip0 = { 0 };

@ -1 +1 @@
Subproject commit 2e4b605c6217cd3c8a1ef773f82f5cc329ba650d
Subproject commit 6c53ef1c0066a3b0d82e9e181e90114eacb7c4aa

@ -1 +1 @@
Subproject commit b46392d25de7a7bab67d48ef18bf8350b429cff5
Subproject commit c8cf175278452686cc5993e154d472d0a64d7fac

@ -1 +1 @@
Subproject commit 7c42c592581906fef19458372b8db2b643278211
Subproject commit 2d159c7da1d542f2b1fcbbefea6931bce242b943

@ -1 +1 @@
Subproject commit 11930d259212605a15430523472ef54e0c7654ee
Subproject commit 8b8f941c57a790c277f49b099e73ed9f8ea141af