Skip to content
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
106 changes: 26 additions & 80 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,92 +2,38 @@ name: Release

on:
push:
tags:
- 'v[0-9]+.[0-9]+'
branch:
- 'release/*'

jobs:
build-debian-package-jammy:
name: build (Ubuntu 22.04)
runs-on: builder
container:
image: yanetplatform/builder-lite
name: build-image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
id-token: write
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- run: |
export YANET_VERSION=${{github.ref_name}}
export YANET_VERSION=${YANET_VERSION#v}
export YANET_VERSION_MAJOR=${YANET_VERSION%.*}
export YANET_VERSION_MINOR=${YANET_VERSION#*.}
export YANET_VERSION_REVISION=${{github.run_number}}
export YANET_VERSION_HASH=${{github.sha}}
export YANET_VERSION_CUSTOM=stable
meson setup --prefix=/target \
-Dtarget=release \
-Darch=corei7,broadwell,knl \
-Dversion_major=$YANET_VERSION_MAJOR \
-Dversion_minor=$YANET_VERSION_MINOR \
-Dversion_revision=$YANET_VERSION_REVISION \
-Dversion_hash=$YANET_VERSION_HASH \
-Dversion_custom=$YANET_VERSION_CUSTOM \
build
meson compile -C build
- run: meson install -C build
- run: |
export YANET_VERSION=${{github.ref_name}}
export YANET_VERSION=${YANET_VERSION#v}
cp -r debian /target/DEBIAN
sed -i "s/__VERSION__/${YANET_VERSION}/g" /target/DEBIAN/control
- run: |
export YANET_VERSION=${{github.ref_name}}
export YANET_VERSION=${YANET_VERSION#v}
mkdir /export
dpkg-deb -b "/target" /export/yanet_${YANET_VERSION}_ubuntu22.04.deb
- uses: actions/upload-artifact@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
name: target_debian
path: /export/yanet*.deb

build-debian-package-bionic:
name: build (Ubuntu 18.04)
runs-on: builder
container:
image: yanetplatform/builder_ubuntu18.04-lite
steps:
- uses: actions/checkout@v1
images: yanetplatform/yanet
- name: Log in to Docker Hub
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
submodules: recursive
- run: |
export YANET_VERSION=${{github.ref_name}}
export YANET_VERSION=${YANET_VERSION#v}
export YANET_VERSION_MAJOR=${YANET_VERSION%.*}
export YANET_VERSION_MINOR=${YANET_VERSION#*.}
export YANET_VERSION_REVISION=${{github.run_number}}
export YANET_VERSION_HASH=${{github.sha}}
export YANET_VERSION_CUSTOM=stable
meson setup --prefix=/target \
-Dtarget=release \
-Darch=corei7,broadwell,knl \
-Dversion_major=$YANET_VERSION_MAJOR \
-Dversion_minor=$YANET_VERSION_MINOR \
-Dversion_revision=$YANET_VERSION_REVISION \
-Dversion_hash=$YANET_VERSION_HASH \
-Dversion_custom=$YANET_VERSION_CUSTOM \
build
meson compile -C build
- run: meson install -C build
- run: |
export YANET_VERSION=${{github.ref_name}}
export YANET_VERSION=${YANET_VERSION#v}
cp -r debian /target/DEBIAN
sed -i "s/__VERSION__/${YANET_VERSION}/g" /target/DEBIAN/control
- run: |
export YANET_VERSION=${{github.ref_name}}
export YANET_VERSION=${YANET_VERSION#v}
mkdir /export
dpkg-deb -b "/target" /export/yanet_${YANET_VERSION}_ubuntu18.04.deb
- uses: actions/upload-artifact@v3
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
id: push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
name: target_debian
path: /export/yanet*.deb
context: .
file: ./build/Dockerfile.image
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
46 changes: 46 additions & 0 deletions autotest/autotest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,16 @@ void tAutotest::mainThread()

result = step_dumpPackets(yamlStep["dumpPackets"], configFilePath);
}
else if (yamlStep["bird"])
{
YANET_LOG_DEBUG("step: bird\n");

result = step_bird(yamlStep["bird"], configFilePath);
}
else if (yamlStep["birdc"])
{
YANET_LOG_DEBUG("step: birdc\n");
}
else
{
YANET_LOG_ERROR("unknown step\n");
Expand Down Expand Up @@ -2006,6 +2016,42 @@ bool tAutotest::step_dumpPackets(const YAML::Node& yamlStep,
return true;
}

bool tAutotest::step_bird(const YAML::Node& yamlStep,
const std::string& path)
{
std::string confPath;
for (const auto& yamlIter : yamlStep)
{
confPath = yamlIter.as<std::string>();
}
Comment on lines +2022 to +2026
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we reinitializing that string in a loop?
Maybe just std::string confPath = yamlStep[0].as<std::string>(); is enough?


if (!confPath.empty())
{
const std::string execCommand = "bird -c " + path + confPath;

std::string resExec = exec(execCommand.c_str());

printf("%s", resExec.data());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just

Suggested change
printf("%s", resExec.data());
std::cout <<resExec;

Or use YANET_LOG_something. Using plain printf seems strange, after all, we're using C++


return true;
}
return false;
}

bool tAutotest::step_birdc(const YAML::Node& yamlStep)
{
std::string command = "birdc ";
for (const auto& yamlIter : yamlStep)
{
command += yamlIter.as<std::string>() + " ";
}
Comment on lines +2043 to +2047
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use std::ostringstream when building strings in a loop. Current approach is not efficient as you will gradually create more and more objects of increasing size.

Suggested change
std::string command = "birdc ";
for (const auto& yamlIter : yamlStep)
{
command += yamlIter.as<std::string>() + " ";
}
std::ostringstream command_stream;
command_stream << "birdc ";
for (const auto& yamlIter : yamlStep)
{
command_stream << yamlIter.as<std::string>() << ' ';
}
const std::string command = command_stream.str();


auto res_birdc = exec(command.c_str());

printf("birdc:\n %s\n", res_birdc.data());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
printf("birdc:\n %s\n", res_birdc.data());
std::cout << "birdc:\n" << res_birdc << '\n';

return true;
}

void tAutotest::fflushSharedMemory()
{
size_t size = std::get<0>(rawShmInfo);
Expand Down
2 changes: 2 additions & 0 deletions autotest/autotest.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class tAutotest
bool step_reload_async(const YAML::Node& yamlStep);
bool step_echo(const YAML::Node& yamlStep);
bool step_dumpPackets(const YAML::Node& yamlStep, const std::string& path);
bool step_bird(const YAML::Node& yamlStep, const std::string& path);
bool step_birdc(const YAML::Node& yamlStep);

eResult initSockets();
eResult initSharedMemory();
Expand Down
8 changes: 8 additions & 0 deletions autotest/units/001_one_port/077_bird/autotest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
steps:
- bird:
- bird/bird.conf
- birdc:
- show route
- sleep: 20
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 20 second sleep absolutely needed? I would like to see a lesser value though if it's necessary, then feel free to ignore

- cli:
- rib prefixes
61 changes: 61 additions & 0 deletions autotest/units/001_one_port/077_bird/bird/bird.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This is a simple example configuration file with no aim for completeness.
* See documentation for full description.
*/

# Router ID in IPv4 format
router id 62.168.0.1;

# Load device information from kernel.
protocol device {}

# Generate direct routes for interfaces. Useful on BSD.
protocol direct {
ipv4;
disabled;
}

protocol direct {
ipv6;
disabled;
}

# Feed routes to kernel FIB
protocol kernel {
ipv4 { export all; import all; };
learn; # Learn all routes from the kernel
# scan time 10; # Scan kernel tables every 10 seconds
}

protocol kernel {
ipv6 { import all; };
learn;
}

# Static route feed
protocol static {
ipv4 { export all; };
route 10.0.0.0/24 via 192.168.1.32;
route 10.10.0.0/16 blackhole;
route 10.20.0.0/20 via 192.168.1.22;
route 10.30.50.0/28 prohibit;
}

protocol static {
ipv6 { export all; };
route 2001:db8:1::/48 via 5555::6666;
route 2001:db8:2::/48 blackhole;
route 2001:db8:3::/48 prohibit;
route 2001:db8:4::/48 unreachable;
}

protocol export {
table master4;
socket "/var/tmp/bird-master4.sock";
}

protocol export {
table master6;
socket "/var/tmp/bird-master6.sock";
}

42 changes: 42 additions & 0 deletions autotest/units/001_one_port/077_bird/controlplane.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"modules": {
"lp0.100": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "100",
"macAddress": "00:11:22:33:44:55",
"nextModule": "vrf0"
},
"lp0.200": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "200",
"macAddress": "00:11:22:33:44:55",
"nextModule": "vrf0"
},
"vrf0": {
"type": "route",
"interfaces": {
"kni0.100": {
"nextModule": "lp0.100"
},
"kni0.200": {
"ipv4Prefix": "200.0.0.2/24",
"neighborIPv4Address": "200.0.0.1",
"neighborMacAddress": "00:00:00:11:11:11",
"nextModule": "lp0.200"
}
},
"birdImport": [
{
"socket": "/var/tmp/bird-master4.sock",
"vrf": "master4"
},
{
"socket": "/var/tmp/bird-master6.sock",
"vrf": "master6"
}
]
}
}
}
10 changes: 7 additions & 3 deletions build/Dockerfile.image
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG RELEASE=22.04
FROM --platform=linux/amd64 ubuntu:${RELEASE} as environment
FROM --platform=linux/amd64 ubuntu:${RELEASE} AS environment

RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
Expand Down Expand Up @@ -28,7 +28,8 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \

RUN python3 -m pip install meson==0.61.2

FROM environment as builder

FROM environment AS builder

ARG YANET_VERSION_MAJOR=0
ARG YANET_VERSION_MINOR=0
Expand All @@ -50,6 +51,7 @@ RUN meson setup --prefix=/target \

RUN meson compile -C build


FROM --platform=linux/amd64 ubuntu:${RELEASE}

RUN apt-get update
Expand All @@ -61,8 +63,10 @@ RUN DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
libmlx5-1 \
libnuma1 \
libpcap0.8 \
netbase
netbase \
python3

COPY --from=builder /opt/yanet/build/controlplane/yanet-controlplane /usr/bin/
COPY --from=builder /opt/yanet/build/dataplane/yanet-dataplane /usr/bin/
COPY --from=builder /opt/yanet/build/cli/yanet-cli /usr/bin/
COPY --from=builder /opt/yanet/yanet-announcer.py /usr/bin/yanet-announcer
9 changes: 9 additions & 0 deletions cli/telegraf.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,13 @@ void unsafe()
const auto& [memory_groups, memory_objects] = memory_stats;

const auto durations = controlplane.controlplane_durations();
uint64_t total_acl_ingress_dropPackets = 0, total_acl_egress_dropPackets = 0;

for (const auto& [coreId, worker] : responseWorkers)
{
const auto& [iterations, stats, ports_stats] = worker;
total_acl_ingress_dropPackets += stats.acl_ingress_dropPackets;
total_acl_egress_dropPackets += stats.acl_egress_dropPackets;

printf("worker,coreId=%u "
"iterations=%luu,"
Expand Down Expand Up @@ -174,6 +177,12 @@ void unsafe()
stats.logs_drops,
stats.logs_packets);

printf("worker,coreId=all "
"acl_ingress_dropPackets=%luu,"
"acl_egress_dropPackets=%luu\n",
total_acl_ingress_dropPackets,
total_acl_egress_dropPackets);

for (const auto& [physicalPortName, stats] : ports_stats)
{
printf("worker,coreId=%u,physicalPortName=%s "
Expand Down
2 changes: 2 additions & 0 deletions common/config.release.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#pragma once

#define CONFIG_YADECAP_MBUFS_COUNT (48 * 1024)
#define CONFIG_YADECAP_MBUF_SIZE (10 * 1024)
#define CONFIG_YADECAP_WORKER_PORTS_SIZE (8)
Expand Down
4 changes: 3 additions & 1 deletion common/icp.h
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,9 @@ using eor = std::tuple<std::string, ///< protocol
ip_address_t, ///< peer
std::string>; ///< table_name

using request = std::vector<std::variant<insert, remove, clear, eor>>;
using action = std::variant<insert, remove, clear, eor>;

using request = std::vector<action>;
}

namespace rib_summary
Expand Down
Loading
Loading