Skip to content

Commit

Permalink
BR: Test SCMP behaviour in border acceptance (#3447)
Browse files Browse the repository at this point in the history
Instead of the old python test that spins up a whole topology only test against a BR.
Also extend the acceptance framework with the needed bits.
Also make BR return an SCMP error if it receives traffic for an unknown interface.

Fixes #3422
  • Loading branch information
lukedirtwalker authored Dec 4, 2019
1 parent 8b5eb2d commit 6be2063
Show file tree
Hide file tree
Showing 16 changed files with 870 additions and 808 deletions.
1 change: 0 additions & 1 deletion .buildkite/steps/integration
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ if [ "$RUN_ALL_TESTS" = "y" ]; then
for mode in $MODES; do
run_test "e2e_integration" "$mode"
done
run_test "py_scmp_integration"
fi

for test in $TESTS; do
Expand Down
1 change: 0 additions & 1 deletion BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ pkg_tar(
"//go/examples/pingpong:pingpong",
"//go/examples/pingpong/pp_integration:pp_integration",
"//go/tools/buildkite_log_downloader:buildkite_log_downloader",
"//go/integration/scmp_error_pyintegration:scmp_error_pyintegration",
"//go/tools/scmp/scmp_integration:scmp_integration",
"//go/acceptance/sig_ping_acceptance:sig_ping_acceptance",
],
Expand Down
3 changes: 3 additions & 0 deletions go/border/braccept/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"peer_tests.go",
"print.go",
"revocation_tests.go",
"scmp_tests.go",
"send.go",
"sleep.go",
"svc_tests.go",
Expand All @@ -29,9 +30,11 @@ go_library(
"//go/border/braccept/layers:go_default_library",
"//go/border/braccept/parser:go_default_library",
"//go/border/braccept/shared:go_default_library",
"//go/lib/addr:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/infra:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/xtest:go_default_library",
"@com_github_google_gopacket//:go_default_library",
"@com_github_google_gopacket//afpacket:go_default_library",
"@com_github_google_gopacket//layers:go_default_library",
Expand Down
29 changes: 29 additions & 0 deletions go/border/braccept/br_tests.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2018 ETH Zurich
// Copyright 2019 ETH Zurich, Anapaya Systems
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -14,6 +15,10 @@

package main

import (
"github.com/scionproto/scion/go/lib/xtest"
)

func br_multi() int {
var failures int

Expand All @@ -29,6 +34,30 @@ func br_multi() int {

failures += revocation_parent_to_child()

scmpCfg := scmpTestCfg{
DstIA: xtest.MustParseIA("2-ff00:0:3"),
LocalInterface: 131,
}
failures += scmpCfg.scmpBadVersion()
failures += scmpCfg.scmpBadDstType()
failures += scmpCfg.scmpBadSrcType()
failures += scmpCfg.scmpBadPktLenShort()
failures += scmpCfg.scmpBadPktLenLong()
failures += scmpCfg.scmpBadHdrLenShort()
failures += scmpCfg.scmpBadHdrLenLong()
failures += scmpCfg.scmpBadInfoFieldOffsetLow()
failures += scmpCfg.scmpBadInfoFieldOffsetHigh()
failures += scmpCfg.scmpBadHopFieldOffsetLow()
failures += scmpCfg.scmpBadHopFieldOffsetHigh()
failures += scmpCfg.scmpPathRequired()
failures += scmpCfg.scmpBadMac()
failures += scmpCfg.scmpExpiredHopField()
failures += scmpCfg.scmpBadInterface()
failures += scmpCfg.scmpNonRoutingHopField()
failures += scmpCfg.scmpTooManyHopByHop()
failures += scmpCfg.scmpBadExtensionOrder()
failures += scmpCfg.scmpBadHopByHop()

return failures
}

Expand Down
7 changes: 6 additions & 1 deletion go/border/braccept/parser/extensions.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 ETH Zurich
// Copyright 2019 ETH Zurich, Anapaya Systems
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -98,6 +98,9 @@ func (hbh *HBHTaggedLayer) Update(lines []string) {
scmp := &hbh_scmp{}
scmp.updateFields(kvs)
e = scmp
case "HBH.Empty":
hbh.Data = []byte{}
return
default:
panic(fmt.Errorf("Unknown HBH layer Type '%s'", layerType))
}
Expand Down Expand Up @@ -173,6 +176,8 @@ func parseHBHType(t string) uint8 {
e = common.ExtnOneHopPathType
case "SIBRA":
panic(fmt.Errorf("Unsupported HBH Type: %s", t))
case "InvHBH":
e = common.ExtnType{Class: common.HopByHopClass, Type: 255}
default:
panic(fmt.Errorf("Unknown HBH Type: %s", t))
}
Expand Down
13 changes: 5 additions & 8 deletions go/border/braccept/parser/scion.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 ETH Zurich
// Copyright 2019 ETH Zurich, Anapaya Systems
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -20,7 +20,6 @@ import (
"hash"
"strconv"
"strings"
"time"

"github.com/google/gopacket"

Expand Down Expand Up @@ -230,12 +229,10 @@ func updateFieldsIF(inf *spath.InfoField, kvs propMap) {
switch k {
case "Flags":
updateFlagsIF(inf, v)
case "Ts":
t, err := time.Parse(common.TimeFmt, v)
if err != nil {
panic(err)
}
inf.TsInt = uint32(t.Unix())
case "TsInt":
// Note that users can still pass a normally formatted timestamp
// with fmt.Sprintf("%d", timeStamp.Unix()).
inf.TsInt = uint32(StrToInt(v))
case "ISD":
inf.ISD = uint16(StrToInt(v))
case "Hops":
Expand Down
64 changes: 63 additions & 1 deletion go/border/braccept/parser/scmp.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2019 ETH Zurich
// Copyright 2019 ETH Zurich, Anapaya Systems
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -95,6 +95,18 @@ func (s *SCMPTaggedLayer) Update(lines []string) {
s.Info = info
case "QUOTED":
s.updateQuotes(kvs)
case "InfoPktSize":
info := &InfoPktSize{}
skip = info.parse(lines[i:])
s.Info = info
case "InfoPathOffsets":
info := &InfoPathOffsets{}
skip = info.parse(lines[i:])
s.Info = info
case "InfoExtIdx":
info := &InfoExtIdx{}
skip = info.parse(lines[i:])
s.Info = info
default:
panic(fmt.Errorf("Unknown SCMP sub layer type '%s'\n", layerType))
}
Expand Down Expand Up @@ -134,10 +146,40 @@ func (info *InfoRevocation) parse(lines []string) int {
return 1
}

type InfoPktSize struct {
scmp.InfoPktSize
}

func (i *InfoPktSize) parse(lines []string) int {
if len(lines) < 1 {
panic(fmt.Sprintf("Bad InfoPktSize layer!\n%s\n", strings.Join(lines, "\n")))
}
_, _, kvStr := decodeLayerLine(lines[0])
kvs := getKeyValueMap(kvStr)
for k, v := range kvs {
switch k {
case "Size":
i.Size = uint16(StrToInt(v))
case "MTU":
i.MTU = uint16(StrToInt(v))
}
}
return 0
}

type InfoPathOffsets struct {
scmp.InfoPathOffsets
}

func (i *InfoPathOffsets) parse(lines []string) int {
if len(lines) < 1 {
panic(fmt.Sprintf("Bad InfoPathOffsets layer!\n%s\n", lines))
}
_, _, kvStr := decodeLayerLine(lines[0])
i.updateFields(getKeyValueMap(kvStr))
return 0
}

func (i *InfoPathOffsets) updateFields(kvs propMap) {
for k, v := range kvs {
switch k {
Expand All @@ -155,6 +197,26 @@ func (i *InfoPathOffsets) updateFields(kvs propMap) {
}
}

type InfoExtIdx struct {
scmp.InfoExtIdx
}

func (i *InfoExtIdx) parse(lines []string) int {
if len(lines) < 1 {
panic(fmt.Sprintf("Bad InfoExtIdx layer!\n%s\n", lines))
}
_, _, kvStr := decodeLayerLine(lines[0])
for k, v := range getKeyValueMap(kvStr) {
switch k {
case "Idx":
i.Idx = uint8(StrToInt(v))
default:
panic(fmt.Sprintf("Invalid InfoExtIdx field: %s=%v", k, v))
}
}
return 0
}

func (s *SCMPTaggedLayer) updateHeaderFields(kvs propMap) {
for k, v := range kvs {
switch k {
Expand Down
Loading

0 comments on commit 6be2063

Please sign in to comment.