From 0f62519cd77f1cf38dee5b58377d0c347fe619bc Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Tue, 9 May 2017 07:47:09 +0000 Subject: server: ignore routes when local AS is in AS_PATH RFC4271 9.1.2 Phase 2: Route Selection If the AS_PATH attribute of a BGP route contains an AS loop, the BGP route should be excluded from the Phase 2 decision function. AS loop detection is done by scanning the full AS path (as specified in the AS_PATH attribute), and checking that the autonomous system number of the local system does not appear in the AS path. Operations of a BGP speaker that is configured to accept routes with its own autonomous system number in the AS path are outside the scope of this document. Also this commit adds support for allow-own-as option to relax this. Signed-off-by: ISHIDA Wataru --- server/fsm_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'server/fsm_test.go') diff --git a/server/fsm_test.go b/server/fsm_test.go index 0fb67f98..aea6700b 100644 --- a/server/fsm_test.go +++ b/server/fsm_test.go @@ -287,6 +287,15 @@ func TestFSMHandlerEstablished_HoldtimeZero(t *testing.T) { assert.Equal(0, len(m.sendBuf)) } +func TestCheckOwnASLoop(t *testing.T) { + assert := assert.New(t) + aspathParam := []bgp.AsPathParamInterface{bgp.NewAs4PathParam(2, []uint32{65100})} + aspath := bgp.NewPathAttributeAsPath(aspathParam) + assert.False(hasOwnASLoop(65100, 10, aspath)) + assert.True(hasOwnASLoop(65100, 0, aspath)) + assert.False(hasOwnASLoop(65200, 0, aspath)) +} + func makePeerAndHandler() (*Peer, *FSMHandler) { p := &Peer{ fsm: NewFSM(&config.Global{}, &config.Neighbor{}, table.NewRoutingPolicy()), -- cgit v1.2.3