MCPcopy
hub / github.com/osrg/gobgp / TestMultipleAsPathConditionEvaluate

Function TestMultipleAsPathConditionEvaluate

internal/pkg/table/policy_test.go:1230–1333  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1228}
1229
1230func TestMultipleAsPathConditionEvaluate(t *testing.T) {
1231 // setup
1232 // create path
1233 peer := &PeerInfo{AS: 65001, Address: netip.MustParseAddr("10.0.0.1")}
1234 origin := bgp.NewPathAttributeOrigin(0)
1235 aspathParam1 := []bgp.AsPathParamInterface{
1236 bgp.NewAsPathParam(2, []uint16{65001, 65000, 54000, 65004, 65005}),
1237 }
1238 aspath := bgp.NewPathAttributeAsPath(aspathParam1)
1239 nexthop, _ := bgp.NewPathAttributeNextHop(netip.MustParseAddr("10.0.0.1"))
1240 med := bgp.NewPathAttributeMultiExitDisc(0)
1241 pathAttributes := []bgp.PathAttributeInterface{origin, aspath, nexthop, med}
1242 nlri, _ := bgp.NewIPAddrPrefix(netip.MustParsePrefix("10.10.0.101/24"))
1243 updateMsg1 := bgp.NewBGPUpdateMessage(nil, pathAttributes, []bgp.PathNLRI{{NLRI: nlri}})
1244 UpdatePathAttrs4ByteAs(logger, updateMsg1.Body.(*bgp.BGPUpdate))
1245 path1 := ProcessMessage(updateMsg1, peer, time.Now(), false)[0]
1246
1247 // create match condition
1248 asPathSet1 := oc.AsPathSet{
1249 AsPathSetName: "asset1",
1250 AsPathList: []string{"^65001_65000"},
1251 }
1252
1253 asPathSet2 := oc.AsPathSet{
1254 AsPathSetName: "asset2",
1255 AsPathList: []string{"65004_65005$"},
1256 }
1257
1258 asPathSet3 := oc.AsPathSet{
1259 AsPathSetName: "asset3",
1260 AsPathList: []string{"65001_65000_54000"},
1261 }
1262
1263 asPathSet4 := oc.AsPathSet{
1264 AsPathSetName: "asset4",
1265 AsPathList: []string{"54000_65004_65005"},
1266 }
1267
1268 asPathSet5 := oc.AsPathSet{
1269 AsPathSetName: "asset5",
1270 AsPathList: []string{"^65001 65000 54000 65004 65005$"},
1271 }
1272
1273 asPathSet6 := oc.AsPathSet{
1274 AsPathSetName: "asset6",
1275 AsPathList: []string{".*_[0-9]+_65005"},
1276 }
1277
1278 asPathSet7 := oc.AsPathSet{
1279 AsPathSetName: "asset7",
1280 AsPathList: []string{".*_5[0-9]+_[0-9]+"},
1281 }
1282
1283 asPathSet8 := oc.AsPathSet{
1284 AsPathSetName: "asset8",
1285 AsPathList: []string{"6[0-9]+_6[0-9]+_5[0-9]+"},
1286 }
1287

Callers

nothing calls this directly

Calls 13

NewPathAttributeOriginFunction · 0.92
NewAsPathParamFunction · 0.92
NewPathAttributeAsPathFunction · 0.92
NewPathAttributeNextHopFunction · 0.92
NewIPAddrPrefixFunction · 0.92
NewBGPUpdateMessageFunction · 0.92
UpdatePathAttrs4ByteAsFunction · 0.85
ProcessMessageFunction · 0.85
NewAsPathSetFunction · 0.85
NewAsPathConditionFunction · 0.85
EvaluateMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…