Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bio-rd
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
danet
bio-rd
Commits
c515202f
Commit
c515202f
authored
6 years ago
by
Daniel Czerwonk
Browse files
Options
Downloads
Patches
Plain Diff
added sending of MP_UNREACH_NLRI
parent
0df629c0
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
protocols/bgp/server/update_sender.go
+9
-6
9 additions, 6 deletions
protocols/bgp/server/update_sender.go
protocols/bgp/server/withdraw.go
+14
-0
14 additions, 0 deletions
protocols/bgp/server/withdraw.go
protocols/bgp/server/withdraw_test.go
+40
-0
40 additions, 0 deletions
protocols/bgp/server/withdraw_test.go
with
63 additions
and
6 deletions
protocols/bgp/server/update_sender.go
+
9
−
6
View file @
c515202f
...
...
@@ -216,12 +216,7 @@ func (u *UpdateSender) copyAttributesWithoutNextHop(pa *packet.PathAttribute) (a
// RemovePath withdraws prefix `pfx` from a peer
func
(
u
*
UpdateSender
)
RemovePath
(
pfx
bnet
.
Prefix
,
p
*
route
.
Path
)
bool
{
if
u
.
fsm
.
options
.
SupportsMultiProtocol
{
// TODO: imeplent withdraw
return
false
}
err
:=
withDrawPrefixesAddPath
(
u
.
fsm
.
con
,
u
.
fsm
.
options
,
pfx
,
p
)
err
:=
u
.
withdrawPrefix
(
pfx
,
p
)
if
err
!=
nil
{
log
.
Errorf
(
"Unable to withdraw prefix: %v"
,
err
)
return
false
...
...
@@ -229,6 +224,14 @@ func (u *UpdateSender) RemovePath(pfx bnet.Prefix, p *route.Path) bool {
return
true
}
func
(
u
*
UpdateSender
)
withdrawPrefix
(
pfx
bnet
.
Prefix
,
p
*
route
.
Path
)
error
{
if
u
.
fsm
.
options
.
SupportsMultiProtocol
{
return
withDrawPrefixesMultiProtocol
(
u
.
fsm
.
con
,
u
.
fsm
.
options
,
pfx
)
}
return
withDrawPrefixesAddPath
(
u
.
fsm
.
con
,
u
.
fsm
.
options
,
pfx
,
p
)
}
// UpdateNewClient does nothing
func
(
u
*
UpdateSender
)
UpdateNewClient
(
client
routingtable
.
RouteTableClient
)
error
{
log
.
Warningf
(
"BGP Update Sender: UpdateNewClient not implemented"
)
...
...
This diff is collapsed.
Click to expand it.
protocols/bgp/server/withdraw.go
+
14
−
0
View file @
c515202f
...
...
@@ -58,3 +58,17 @@ func withDrawPrefixesAddPath(out io.Writer, opt *types.Options, pfx net.Prefix,
}
return
serializeAndSendUpdate
(
out
,
update
,
opt
)
}
func
withDrawPrefixesMultiProtocol
(
out
io
.
Writer
,
opt
*
types
.
Options
,
pfx
net
.
Prefix
)
error
{
update
:=
&
packet
.
BGPUpdate
{
PathAttributes
:
&
packet
.
PathAttribute
{
TypeCode
:
packet
.
MultiProtocolUnreachNLRICode
,
Value
:
packet
.
MultiProtocolUnreachNLRI
{
AFI
:
packet
.
IPv6AFI
,
SAFI
:
packet
.
UnicastSAFI
,
Prefixes
:
[]
net
.
Prefix
{
pfx
},
},
},
}
return
serializeAndSendUpdate
(
out
,
update
,
opt
)
}
This diff is collapsed.
Click to expand it.
protocols/bgp/server/withdraw_test.go
+
40
−
0
View file @
c515202f
...
...
@@ -61,6 +61,46 @@ func TestWithDrawPrefixes(t *testing.T) {
}
}
func
TestWithDrawPrefixesMultiProtocol
(
t
*
testing
.
T
)
{
tests
:=
[]
struct
{
Name
string
Prefix
net
.
Prefix
Expected
[]
byte
}{
{
Name
:
"IPv6 MP_UNREACH_NLRI"
,
Prefix
:
net
.
NewPfx
(
net
.
IPv6FromBlocks
(
0x2804
,
0x148c
,
0
,
0
,
0
,
0
,
0
,
0
),
32
),
Expected
:
[]
byte
{
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
0xff
,
// BGP Marker
0x00
,
0x22
,
// BGP Message Length
0x02
,
// BGP Message Type == Update
0x00
,
0x00
,
// WithDraw Octet length
0x00
,
0x0b
,
// Length
0x80
,
// Flags
0x0f
,
// Attribute Code
0x08
,
// Attribute length
0x00
,
0x02
,
// AFI
0x01
,
// SAFI
0x20
,
0x28
,
0x04
,
0x14
,
0x8c
,
// Prefix
},
},
}
for
_
,
test
:=
range
tests
{
t
.
Run
(
test
.
Name
,
func
(
t
*
testing
.
T
)
{
buf
:=
bytes
.
NewBuffer
([]
byte
{})
opt
:=
&
types
.
Options
{
AddPathRX
:
false
,
}
err
:=
withDrawPrefixesMultiProtocol
(
buf
,
opt
,
test
.
Prefix
)
if
err
!=
nil
{
t
.
Fatalf
(
"unexpected error: %v"
,
err
)
}
assert
.
Equal
(
t
,
test
.
Expected
,
buf
.
Bytes
())
})
}
}
func
TestWithDrawPrefixesAddPath
(
t
*
testing
.
T
)
{
testcases
:=
[]
struct
{
Name
string
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment