From a330f47cd7187dc732cc3e0f0563fb0edb424a87 Mon Sep 17 00:00:00 2001 From: Maximilian Wilhelm Date: Sun, 7 Jan 2024 15:51:50 +0100 Subject: [PATCH] Lower the bar on building Bio-Routing (#459) * Add Makefile to build cmds and exmaples This Makefile provides some useful targets: * build (default) * clean * test * tets-coverage (test + write coverage) * all (clean build test) Signed-off-by: Maximilian Wilhelm * Add cmd/ris-lg/ris-lg to .gitignore and remove bazel Signed-off-by: Maximilian Wilhelm * Use make targets in GitHub workflow Remove build_examples.sh script replaced by Makefile Signed-off-by: Maximilian Wilhelm * Update README Signed-off-by: Maximilian Wilhelm * Remove -IS config from bio-rd example config Signed-off-by: Maximilian Wilhelm --------- Signed-off-by: Maximilian Wilhelm --- .github/workflows/tests.yml | 6 ++--- .gitignore | 4 +-- Makefile | 34 +++++++++++++++++++++++++ README.md | 49 ++++++++++++++++++++++++++++++------- cmd/bio-rd/bio-rd.yml | 12 --------- scripts/build_examples.sh | 6 ----- 6 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 Makefile delete mode 100755 scripts/build_examples.sh diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 3710b318..0d5a26c5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,7 +20,7 @@ jobs: run: .github/check-gofmt.sh - name: Test - run: go test -v -cover -coverprofile=coverage.txt ./... + run: make test-coverage # Upload Coverage Report - name: Upload coverage to Codecov @@ -31,5 +31,5 @@ jobs: name: codecov-${{ matrix.platform }}-${{ matrix.go-version }} fail_ci_if_error: true - - name: Build examples - run: scripts/build_examples.sh + - name: Build commands and examples + run: make build diff --git a/.gitignore b/.gitignore index c423c270..faa8fdda 100644 --- a/.gitignore +++ b/.gitignore @@ -23,10 +23,8 @@ coverage.txt /cmd/bio-rdc/bio-rdc /cmd/ris-mirror/ris-mirror /cmd/ris/ris +/cmd/ris-lg/ris-lg /cmd/riscli/riscli /examples/bgp/bgp /examples/bmp/bmp /examples/kernel - -# bazel directories -/bazel-* diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..016d6b27 --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +#!/usr/bin/make +# +# Bio-Routing Makefile +# +# Maximilian Wilhelm +# -- Tue 02 Jan 2024 08:21:17 PM CET +# + +expand_binary = $(dir)/$(notdir $(dir)) + +CMD_DIRS := $(wildcard cmd/*) +CMDS := $(foreach dir, $(CMD_DIRS), $(expand_binary)) +EXAMPLE_DIRS = $(wildcard examples/*) +EXAMPLES := $(foreach dir, $(EXAMPLE_DIRS), $(expand_binary)) + +%: + cd $(dir $(@)) && go build + + +build: $(CMDS) $(EXAMPLES) + +all: clean build test + +clean: + rm -f -- $(CMDS) $(EXMAPLES) + +test: + @echo "Running tests..." + go test ./... + +test-coverage: + go test -v -cover -coverprofile=coverage.txt ./... + +.PHONY: all build clean test test-coverage \ No newline at end of file diff --git a/README.md b/README.md index a30e3754..ca10e19e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# bio-rd +# Bio-Routing A re-implementation of BGP, IS-IS and OSPF in go. We value respect and robustness! @@ -9,18 +9,28 @@ A re-implementation of BGP, IS-IS and OSPF in go. We value respect and robustnes ## Building -### Build the examples - -#### BGP +To build Bio-Routing binares and/or examples you need Go installed and in your `$PATH`. +Currently the minimum supported Go version is v1.20. +To build all commands and examples, you can leverage the `Makefile`, if you have `make` installed, and run ```bash -cd examples/bgp/ && go build +make build ``` -#### BMP +If you're only interested in one particular command/service or example, found in the `cmd/` or `examples/` sub-directories within this repository, +enter the respective directory on a shell and run `go build`. +You should get a binary named like the current directory, which you can run. + +To build the BGP examples, this would look like +```bash +cd exmaples/bgp +go build +``` +To build the `bio-rd` service binary, this would look like ```bash -cd examples/bmp/ && go build +cd cmd/bio-rd +go build ``` ### Run Tests @@ -29,10 +39,31 @@ cd examples/bmp/ && go build go test -v -cover ./... ``` -### Update modules +## Running bio-rd + +`bio-rd` is the main binary which provides a configurable BGP speaker. +It supports the following command-line parameters: + + Usage of ./bio-rd: + -bgp.listen-addr-ipv4 string + BGP listen address for IPv4 AFI (default "0.0.0.0:179") + -bgp.listen-addr-ipv6 string + BGP listen address for IPv6 AFI (default "[::]:179") + -config.file string + bio-rd config file (default "bio-rd.yml") + -grpc_keepalive_min_time uint + Minimum time (seconds) for a client to wait between GRPC keepalive pings (default 1) + -grpc_port uint + GRPC API server port (default 5566) + -metrics_port uint + Metrics HTTP server port (default 55667) + +You can find an [example configuration file](cmd/bio-rd/bio-rd.yml) within in `cmd/bio-rd` directory. + +As `bio-rd` needs to listen on the priviledged TCP port 179 for BGP connections, you either need to start the service as `root` or using `sudo`, e.g. ```bash -go mod tidy +$ sudo ./bio-rd -config.file bio-rd.yml ``` ## Benchmarks diff --git a/cmd/bio-rd/bio-rd.yml b/cmd/bio-rd/bio-rd.yml index 148cb2e5..1adeb890 100644 --- a/cmd/bio-rd/bio-rd.yml +++ b/cmd/bio-rd/bio-rd.yml @@ -77,15 +77,3 @@ protocols: peer_as: 65300 import: ["PeerB-In"] export: ["ACCEPT_ALL"] - isis: - NETs: ["49.0001.0100.0000.0002.00"] - level1: - disable: true - interfaces: - - name: "tap0" - level2: - metric: 10 - - name: "lo" - passive: true - level2: - metric: 0 \ No newline at end of file diff --git a/scripts/build_examples.sh b/scripts/build_examples.sh deleted file mode 100755 index 7370c96c..00000000 --- a/scripts/build_examples.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -for i in examples/*; do - echo "building $i" - go install "github.com/bio-routing/bio-rd/$i" -done