summaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorImcom Jin <jinyu.bjut@gmail.com>2021-05-27 15:49:04 +0800
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2021-06-07 09:25:54 +0900
commitd277950d0f55a98e31822bacaea15bb5c29ac032 (patch)
tree7982a336350037be29e9a631e70c2838ad170b6d /internal
parent94d720ff40644d09d99829d6a1520075b9f8475a (diff)
refactor: nlri/nexthop requires MP will get MP explicitly already.
so we can safely remove the MP_REACH_NLRI from ipv4_uc with ipv4 nexthop
Diffstat (limited to 'internal')
-rw-r--r--internal/pkg/table/message.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/internal/pkg/table/message.go b/internal/pkg/table/message.go
index 369fb6d6..12e4928e 100644
--- a/internal/pkg/table/message.go
+++ b/internal/pkg/table/message.go
@@ -444,19 +444,27 @@ func (p *packerV4) pack(options ...*bgp.MarshallingOption) []*bgp.BGPMessage {
attrs := paths[0].GetPathAttrs()
// we can apply a fix here when gobgp receives from MP peer
// and propagtes to non-MP peer
- // we should make sure that we next-hop exists in pathattrs
+ // we should make sure that next-hop exists in pathattrs
// while we build the update message
// we do not want to modify the `path` though
if paths[0].getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP) == nil {
attrs = append(attrs, bgp.NewPathAttributeNextHop(paths[0].GetNexthop().String()))
}
+ // if we have ever reach here
+ // there is no point keeping MP_REACH_NLRI in the announcement
+ attrs_without_mp := make([]bgp.PathAttributeInterface, 0, len(attrs))
+ for _, attr := range attrs {
+ if attr.GetType() != bgp.BGP_ATTR_TYPE_MP_REACH_NLRI {
+ attrs_without_mp = append(attrs_without_mp, attr)
+ }
+ }
attrsLen := 0
- for _, a := range attrs {
+ for _, a := range attrs_without_mp {
attrsLen += a.Len()
}
loop(attrsLen, paths, func(nlris []*bgp.IPAddrPrefix) {
- msgs = append(msgs, bgp.NewBGPUpdateMessage(nil, attrs, nlris))
+ msgs = append(msgs, bgp.NewBGPUpdateMessage(nil, attrs_without_mp, nlris))
})
}
}