Skip to content

Commit

Permalink
Merge branch 'master' into antlr-update
Browse files Browse the repository at this point in the history
  • Loading branch information
jiceatscion authored Oct 4, 2024
2 parents 157b41c + 0e1fc18 commit 83f86bb
Show file tree
Hide file tree
Showing 622 changed files with 14,388 additions and 8,429 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/gobra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
caching: '1'
statsFile: ${{ env.statsFile }}
- name: Upload the verification report
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: verification_stats.json
path: ${{ env.statsFile }}
31 changes: 31 additions & 0 deletions .github/workflows/pr-title.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check the pull request title

on:
pull_request:
types: [opened, edited, reopened, synchronize]

jobs:
check:
runs-on: ubuntu-latest
steps:
- name : Check the PR title
env:
TITLE: ${{ github.event.pull_request.title }}
run: |
# Check that PR is of the form `<subsystem>: <lowercase message>`
url='https://docs.scion.org/en/latest/dev/git.html#good-commit-messages'
if [[ ! "$TITLE" =~ ^[a-z0-9,/-]*:[[:space:]] ]]; then
echo '::error::The PR title should start with `<substystem>: `. See '"$url"
exit 1
fi
# Title should be lower case; initialisms and identifiers still occur occasionally and should be allowed.
# -> enforce only the first word
if [[ ! "$TITLE" =~ ^[a-z0-9,/-]*:[[:space:]][a-z] ]]; then
echo '::error::The PR title should be lower case (enforced on first letter). See '"$url"
exit 1
fi
if [[ $TITLE =~ \.[[:space:]]*$ ]]; then
echo '::error::The PR title should not end with a ".". See '"$url"
exit 1
fi
10 changes: 10 additions & 0 deletions .golangcilint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ linters:
disable-all: true
enable:
# Default linters.
- forbidigo
- errcheck
- gosimple
- govet
Expand All @@ -19,6 +20,15 @@ linters:
- misspell
- goheader
linters-settings:
# ...
forbidigo:
forbid:
- p: "([iI][fF][iI]d)|([iI]F[iI][dD])|([iI][fF]i[dD])"
msg: "spell interface ID as ifID / IfID"
- p: "(?i)interfaceID" # case insensitive
msg: "spell interface ID as ifID / IfID"
- p: "Trc"
msg: "spell trust root certificate as trc / TRC"
lll:
line-length: 100
tab-width: 4
Expand Down
24 changes: 9 additions & 15 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag")
load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@bazel_skylib//rules:common_settings.bzl", "bool_flag", "string_flag")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@io_bazel_rules_go//go:def.bzl", "nogo")
Expand Down Expand Up @@ -63,16 +62,6 @@ config_setting(
},
)

# This is a dummy target so Make can "blaze build --announce_rc <something>
# Where something truly does nothing that we may care about.

config_setting(
name = "dummy_setting",
define_values = {
"whatever": "whatever",
},
)

gazelle(
name = "gazelle",
build_tags = select({
Expand Down Expand Up @@ -140,9 +129,10 @@ gazelle(
go_lint_config(
name = "go_lint_config",
exclude_filter = [
"mock_",
".pb.go",
".connect.go",
".gen.go",
".pb.go",
"mock_",
],
visibility = [
"//visibility:public",
Expand Down Expand Up @@ -211,7 +201,6 @@ pkg_tar(
"//tools/buildkite/cmd/buildkite_artifacts",
"//tools/end2end",
"//tools/end2end_integration",
"//tools/end2endblast",
"//tools/pktgen/cmd/pktgen",
"//tools/scion_integration",
"//tools/udpproxy",
Expand Down Expand Up @@ -261,6 +250,11 @@ write_source_files(
"//dispatcher/mgmtapi:write_files",
"//doc/command:write_files",
"//gateway/mgmtapi:write_files",
"//pkg/proto/control_plane/v1/control_planeconnect:write_files",
"//pkg/proto/daemon/v1/daemonconnect:write_files",
"//pkg/proto/discovery/v1/discoveryconnect:write_files",
"//pkg/proto/gateway/v1/gatewayconnect:write_files",
"//pkg/proto/hidden_segment/v1/hidden_segmentconnect:write_files",
"//private/ca/api:write_files",
"//private/mgmtapi/cppki/api:write_files",
"//private/mgmtapi/health/api:write_files",
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,14 @@ protobuf:
rm -f pkg/proto/*/*.pb.go
cp -r bazel-bin/pkg/proto/*/go_default_library_/github.com/scionproto/scion/pkg/proto/* pkg/proto
cp -r bazel-bin/pkg/proto/*/*/go_default_library_/github.com/scionproto/scion/pkg/proto/* pkg/proto
chmod 0644 pkg/proto/*/*.pb.go
chmod 0644 pkg/proto/*/*.pb.go pkg/proto/*/*/*.pb.go

mocks:
tools/gomocks.py

gazelle: go_deps.bzl
bazel run //:gazelle --verbose_failures --config=quiet
./tools/buildrill/go_integration_test_sync

licenses:
tools/licenses.sh
Expand Down Expand Up @@ -115,12 +116,12 @@ lint-go-bazel:
$(info ==> $@)
@tools/quiet bazel test --config lint //...

GO_BUILD_TAGS_ARG=$(shell bazel build --ui_event_filters=-stdout,-stderr --announce_rc --noshow_progress :dummy_setting 2>&1 | grep "'build' options" | sed -n "s/^.*--define gotags=\(\S*\).*/--build-tags \1/p" )
GO_BUILD_TAGS_ARG=$(shell bazel info --ui_event_filters=-stdout,-stderr --announce_rc --noshow_progress 2>&1 | grep "'build' options" | sed -n "s/^.*--define gotags=\(\S*\).*/--build-tags \1/p" )

lint-go-golangci:
$(info ==> $@)
@if [ -t 1 ]; then tty=true; else tty=false; fi; \
tools/quiet docker run --tty=$$tty --rm -v golangci-lint-modcache:/go -v golangci-lint-buildcache:/root/.cache -v "${PWD}:/src" -w /src golangci/golangci-lint:v1.54.2 golangci-lint run --config=/src/.golangcilint.yml --timeout=3m $(GO_BUILD_TAGS_ARG) --skip-dirs doc ./...
tools/quiet docker run --tty=$$tty --rm -v golangci-lint-modcache:/go -v golangci-lint-buildcache:/root/.cache -v "${PWD}:/src" -w /src golangci/golangci-lint:v1.60.3 golangci-lint run --config=/src/.golangcilint.yml --timeout=3m $(GO_BUILD_TAGS_ARG) --skip-dirs doc ./...

lint-go-semgrep:
$(info ==> $@)
Expand All @@ -141,7 +142,7 @@ lint-protobuf: lint-protobuf-buf

lint-protobuf-buf:
$(info ==> $@)
@tools/quiet bazel run --config=quiet @buf_bin//file:buf -- check lint
@tools/quiet bazel run --config=quiet @buf//:buf -- lint $(PWD) --path $(PWD)/proto

lint-openapi: lint-openapi-spectral

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Interested in contribution to the SCION project? Please visit our
for more information about how you can do so.

Join us on our [slack workspace](https://scionproto.slack.com) with this invite link:
[join scionproto.slack.com](https://join.slack.com/t/scionproto/shared_invite/zt-1gtgkuvk3-vQzq3gPOWOL6T58yu45vXg)
[join scionproto.slack.com](https://join.slack.com/t/scionproto/shared_invite/zt-2mhzmqe84-cWs~UuTYT7kwtlU7_2X3lg)

## License

Expand Down
55 changes: 28 additions & 27 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ workspace(
name = "com_github_scionproto_scion",
)

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

# linter rules
http_archive(
Expand All @@ -28,9 +28,9 @@ lint_setup({

http_archive(
name = "aspect_bazel_lib",
sha256 = "a185ccff9c1b8589c63f66d7eb908de15c5d6bb05562be5f46336c53e7a7326a",
strip_prefix = "bazel-lib-2.0.0-rc1",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.0.0-rc1/bazel-lib-v2.0.0-rc1.tar.gz",
sha256 = "714cf8ce95a198bab0a6a3adaffea99e929d2f01bf6d4a59a2e6d6af72b4818c",
strip_prefix = "bazel-lib-2.7.8",
url = "https://github.com/aspect-build/bazel-lib/releases/download/v2.7.8/bazel-lib-v2.7.8.tar.gz",
)

load("@aspect_bazel_lib//lib:repositories.bzl", "aspect_bazel_lib_dependencies", "aspect_bazel_lib_register_toolchains")
Expand All @@ -46,18 +46,22 @@ aspect_bazel_lib_register_toolchains()
# Bazel rules for Golang
http_archive(
name = "io_bazel_rules_go",
sha256 = "91585017debb61982f7054c9688857a2ad1fd823fc3f9cb05048b0025c47d023",
patch_args = ["-p0"],
patches = ["//patches:io_bazel_rules_go/import.patch"],
sha256 = "af47f30e9cbd70ae34e49866e201b3f77069abb111183f2c0297e7e74ba6bbc0",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.47.0/rules_go-v0.47.0.zip",
],
)

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")

go_rules_dependencies()

go_register_toolchains(
nogo = "@//:nogo",
version = "1.21.11",
version = "1.22.7",
)

# Gazelle
Expand All @@ -71,9 +75,6 @@ http_archive(
)

load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

go_rules_dependencies()

load("//:tool_deps.bzl", "tool_deps")

tool_deps()
Expand Down Expand Up @@ -205,6 +206,15 @@ load("@tester_debian10_packages//:packages.bzl", tester_debian_packages_install_

tester_debian_packages_install_deps()

# Buf CLI
http_archive(
name = "buf",
build_file_content = "exports_files([\"buf\"])",
sha256 = "16253b6702dd447ef941b01c9c386a2ab7c8d20bbbc86a5efa5953270f6c9010",
strip_prefix = "buf/bin",
urls = ["https://github.com/bufbuild/buf/releases/download/v1.32.2/buf-Linux-x86_64.tar.gz"],
)

# protobuf/gRPC
http_archive(
name = "rules_proto_grpc",
Expand Down Expand Up @@ -237,16 +247,6 @@ http_archive(
],
)

http_file(
name = "buf_bin",
downloaded_file_path = "buf",
executable = True,
sha256 = "5faf15ed0a3cd4bd0919ba5fcb95334c1fd2ba32770df289d615138fa188d36a",
urls = [
"https://github.com/bufbuild/buf/releases/download/v0.20.5/buf-Linux-x86_64",
],
)

load("//tools/lint/python:deps.bzl", "python_lint_deps")

python_lint_deps(python_interpreter)
Expand All @@ -257,27 +257,28 @@ install_python_lint_deps()

http_archive(
name = "aspect_rules_js",
sha256 = "a949d56fed8fa0a8dd82a0a660acc949253a05b2b0c52a07e4034e27f11218f6",
strip_prefix = "rules_js-1.33.1",
url = "https://github.com/aspect-build/rules_js/releases/download/v1.33.1/rules_js-v1.33.1.tar.gz",
sha256 = "a723815986f3dd8b2c58d0ea76fde0ed56eed65de3212df712e631e5fc7d8790",
strip_prefix = "rules_js-2.0.0-rc6",
url = "https://github.com/aspect-build/rules_js/releases/download/v2.0.0-rc6/rules_js-v2.0.0-rc6.tar.gz",
)

load("@aspect_rules_js//js:repositories.bzl", "rules_js_dependencies")

rules_js_dependencies()

load("@rules_nodejs//nodejs:repositories.bzl", "DEFAULT_NODE_VERSION", "nodejs_register_toolchains")
load("@rules_nodejs//nodejs:repositories.bzl", "nodejs_register_toolchains")

nodejs_register_toolchains(
name = "nodejs",
node_version = DEFAULT_NODE_VERSION,
node_version = "16.19.0", # use DEFAULT_NODE_VERSION from previous version rules_nodejs; the current version links against too new glibc
)

load("@aspect_rules_js//npm:npm_import.bzl", "npm_translate_lock")
load("@aspect_rules_js//npm:repositories.bzl", "npm_translate_lock")

npm_translate_lock(
name = "npm",
pnpm_lock = "@com_github_scionproto_scion//private/mgmtapi/tools:pnpm-lock.yaml",
pnpm_version = "9.4.0",
verify_node_modules_ignored = "@com_github_scionproto_scion//:.bazelignore",
)

Expand Down
4 changes: 3 additions & 1 deletion acceptance/router_benchmark/benchmarklib.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def run_test_case(self, case: str, map_args: list[str]) -> (int, int):
output = self.exec_br_load(case, map_args, 13)
end = "0"
for line in output.splitlines():
logger.info("BrLoad output: " + line)
if line.startswith("metricsBegin"):
end = line.split()[3] # "... metricsEnd: <end>"

Expand Down Expand Up @@ -322,7 +323,8 @@ def run_bm(self, test_cases: [str]) -> Results:
self.exec_br_load(test_cases[0], map_args, 5)

# Fetch the core count once. It doesn't change while the router is running.
# We can't get it until the router has done some work, but the warmup is enough.
# We cannot get this until the router has been up for a few seconds. If you shorten
# the warmup for some reason, make sure to add a delay.
cores = self.core_count()

# At long last, run the tests.
Expand Down
6 changes: 5 additions & 1 deletion acceptance/router_benchmark/brload/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ load("//:scion.bzl", "scion_go_binary")

go_library(
name = "go_default_library",
srcs = ["main.go"],
srcs = [
"main.go",
"mmsg.go",
],
importpath = "github.com/scionproto/scion/acceptance/router_benchmark/brload",
visibility = ["//visibility:private"],
deps = [
Expand All @@ -17,6 +20,7 @@ go_library(
"@com_github_google_gopacket//afpacket:go_default_library",
"@com_github_google_gopacket//layers:go_default_library",
"@com_github_spf13_cobra//:go_default_library",
"@org_golang_x_sys//unix:go_default_library",
],
)

Expand Down
29 changes: 22 additions & 7 deletions acceptance/router_benchmark/brload/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,37 @@ func run(cmd *cobra.Command) int {
// we don't need to update it.
binary.BigEndian.PutUint16(rawPkt[40:42], 0)

// Prepare a batch worth of packets.
batchSize := int(8)
allPkts := make([][]byte, batchSize)
for i := 0; i < batchSize; i++ {
allPkts[i] = make([]byte, len(rawPkt))
copy(allPkts[i], rawPkt)
}

// Share them with a multi-packets sender. We modify the flowIDs in-place for each batch.
sender := newMpktSender(writePktTo)
sender.setPkts(allPkts)

// We started everything that could be started. So the best window for perf mertics
// opens somewhere around now.
begin := time.Now()
metricsBegin := begin.Unix()

numPkt := 0
for time.Since(begin) < testDuration {
// Check the time only once every 10000 packets
for i := 0; i < 10000; i++ {
// we break every 1000 batches to check the time
for i := 0; i < 1000; i++ {
// Rotate through flowIDs. We patch it directly into the SCION header of the packet. The
// SCION header starts at offset 42. The flowID is the 20 least significant bits of the
// first 32 bit field. To make our life simpler, we only use the last 16 bits (so no
// more than 64K flows).
binary.BigEndian.PutUint16(rawPkt[44:46], uint16(numPkt%int(numStreams)))
numPkt++
if err := writePktTo.WritePacketData(rawPkt); err != nil {
for j := 0; j < batchSize; j++ {
binary.BigEndian.PutUint16(allPkts[j][44:46], uint16(numPkt%int(numStreams)))
numPkt++
}

if _, err := sender.sendAll(); err != nil {
log.Error("writing input packet", "case", string(caseToRun), "error", err)
return 1
}
Expand Down Expand Up @@ -289,9 +304,9 @@ func openDevices(interfaceNames []string) (map[string]*afpacket.TPacket, error)
handles := make(map[string]*afpacket.TPacket)

for _, intf := range interfaceNames {
handle, err := afpacket.NewTPacket(afpacket.OptInterface(intf))
handle, err := afpacket.NewTPacket(afpacket.OptInterface(intf), afpacket.OptFrameSize(4096))
if err != nil {
return nil, serrors.WrapStr("creating TPacket", err)
return nil, serrors.Wrap("creating TPacket", err)
}
handles[intf] = handle
}
Expand Down
Loading

0 comments on commit 83f86bb

Please sign in to comment.