Skip to content

Commit ceb42c7

Browse files
Maximilian WilhelmBarbarossaTM
authored andcommitted
Propage Pre/Post policy indicator from BMP Reciver into BGPPath
Signed-off-by: Maximilian Wilhelm <maximilian@cloudflare.com>
1 parent 4a3b35f commit ceb42c7

File tree

5 files changed

+56
-41
lines changed

5 files changed

+56
-41
lines changed

protocols/bgp/server/fsm_address_family.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (f *fsmAddressFamily) processUpdate(u *packet.BGPUpdate, bmpPostPolicy bool
165165
return
166166
}
167167

168-
f.multiProtocolUpdates(u)
168+
f.multiProtocolUpdates(u, bmpPostPolicy)
169169
if f.afi == packet.AFIIPv4 {
170170
f.withdraws(u, bmpPostPolicy)
171171
f.updates(u, bmpPostPolicy)
@@ -175,24 +175,25 @@ func (f *fsmAddressFamily) processUpdate(u *packet.BGPUpdate, bmpPostPolicy bool
175175
func (f *fsmAddressFamily) withdraws(u *packet.BGPUpdate, bmpPostPolicy bool) {
176176
for r := u.WithdrawnRoutes; r != nil; r = r.Next {
177177
f.adjRIBIn.RemovePath(r.Prefix, &route.Path{
178-
BMPPostPolicy: bmpPostPolicy,
178+
BGPPath: &route.BGPPath{
179+
BMPPostPolicy: bmpPostPolicy,
180+
},
179181
})
180182
}
181183
}
182184

183185
func (f *fsmAddressFamily) updates(u *packet.BGPUpdate, bmpPostPolicy bool) {
184186
for r := u.NLRI; r != nil; r = r.Next {
185-
path := f.newRoutePath()
186-
path.BMPPostPolicy = bmpPostPolicy
187+
path := f.newRoutePath(bmpPostPolicy)
187188
f.processAttributes(u.PathAttributes, path)
188189
path.BGPPath.PathIdentifier = u.NLRI.PathIdentifier
189190

190191
f.adjRIBIn.AddPath(r.Prefix, path)
191192
}
192193
}
193194

194-
func (f *fsmAddressFamily) multiProtocolUpdates(u *packet.BGPUpdate) {
195-
path := f.newRoutePath()
195+
func (f *fsmAddressFamily) multiProtocolUpdates(u *packet.BGPUpdate, bmpPostPolicy bool) {
196+
path := f.newRoutePath(bmpPostPolicy)
196197
f.processAttributes(u.PathAttributes, path)
197198

198199
for pa := u.PathAttributes; pa != nil; pa = pa.Next {
@@ -205,10 +206,11 @@ func (f *fsmAddressFamily) multiProtocolUpdates(u *packet.BGPUpdate) {
205206
}
206207
}
207208

208-
func (f *fsmAddressFamily) newRoutePath() *route.Path {
209+
func (f *fsmAddressFamily) newRoutePath(bmpPostPolicy bool) *route.Path {
209210
return &route.Path{
210211
Type: route.BGPPathType,
211212
BGPPath: &route.BGPPath{
213+
BMPPostPolicy: bmpPostPolicy,
212214
BGPPathA: &route.BGPPathA{
213215
Source: f.fsm.peer.addr,
214216
EBGP: f.fsm.peer.localASN != f.fsm.peer.peerASN,

route/api/route.pb.go

Lines changed: 38 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

route/api/route.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ message BGPPath {
4949
uint32 originator_id = 12;
5050
repeated uint32 cluster_list = 13;
5151
repeated UnknownPathAttribute unknown_attributes = 14;
52+
bool bmp_post_policy = 15;
5253
}
5354

5455
message ASPathSegment {

route/bgp_path.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type BGPPath struct {
2222
UnknownAttributes []types.UnknownPathAttribute
2323
PathIdentifier uint32
2424
ASPathLen uint16
25+
BMPPostPolicy bool // BMPPostPolicy fields is a hack used in BMP to differentiate between pre/post policy routes (L flag of the per peer header)
2526
}
2627

2728
// BGPPathA represents cachable BGP path attributes
@@ -73,6 +74,7 @@ func (b *BGPPath) ToProto() *api.BGPPath {
7374
Source: b.BGPPathA.Source.ToProto(),
7475
UnknownAttributes: make([]*api.UnknownPathAttribute, len(b.UnknownAttributes)),
7576
OriginatorId: b.BGPPathA.OriginatorID,
77+
BmpPostPolicy: b.BMPPostPolicy,
7678
}
7779

7880
if b.ASPath != nil {
@@ -122,6 +124,7 @@ func BGPPathFromProtoBGPPath(pb *api.BGPPath, dedup bool) *BGPPath {
122124
},
123125
PathIdentifier: pb.PathIdentifier,
124126
ASPath: types.ASPathFromProtoASPath(pb.AsPath),
127+
BMPPostPolicy: pb.BmpPostPolicy,
125128
}
126129

127130
if dedup {

route/path.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ const (
2020

2121
// Path represents a network path
2222
type Path struct {
23-
Type uint8
24-
BMPPostPolicy bool // BMPPostPolicy fields is a hack used in BMP to differentiate between pre/post policy routes (L flag of the per peer header)
25-
HiddenReason uint8 // If set, Path is hidden and ineligible to be installed in LocRIB and used for path selection
26-
StaticPath *StaticPath
27-
BGPPath *BGPPath
28-
FIBPath *FIBPath
23+
Type uint8
24+
HiddenReason uint8 // If set, Path is hidden and ineligible to be installed in LocRIB and used for path selection
25+
StaticPath *StaticPath
26+
BGPPath *BGPPath
27+
FIBPath *FIBPath
2928
}
3029

3130
// Select returns negative if p < q, 0 if paths are equal, positive if p > q

0 commit comments

Comments
 (0)