mirror of
https://github.com/osrg/gobgp.git
synced 2024-05-11 05:55:10 +00:00
table: exclude mpreach and mpunreach attribute for normal v4 updates
It is possible that gobgp's v4 path structure contains mpreach or mpunreach attribute. (we store entire path attributes in path structure as they are received) Since we use a NLRI field of BGP update message for v4 updates and don't aggregate update/withdrawal messages for other address families, we need to exclude these attribute before sending out v4 updates. Signed-off-by: Wataru Ishida <[email protected]>
This commit is contained in:
committed by
FUJITA Tomonori
parent
539642d287
commit
fed596b613
+10
-2
@@ -278,8 +278,16 @@ func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
|
||||
u := msg.Body.(*bgp.BGPUpdate)
|
||||
u.NLRI = append(u.NLRI, nlri)
|
||||
} else {
|
||||
pathAttrs := path.GetPathAttrs()
|
||||
return bgp.NewBGPUpdateMessage(nil, pathAttrs, []*bgp.IPAddrPrefix{nlri})
|
||||
attrs := make([]bgp.PathAttributeInterface, 0, 8)
|
||||
for _, p := range path.GetPathAttrs() {
|
||||
switch p.GetType() {
|
||||
case bgp.BGP_ATTR_TYPE_MP_REACH_NLRI:
|
||||
case bgp.BGP_ATTR_TYPE_MP_UNREACH_NLRI:
|
||||
default:
|
||||
attrs = append(attrs, p)
|
||||
}
|
||||
}
|
||||
return bgp.NewBGPUpdateMessage(nil, attrs, []*bgp.IPAddrPrefix{nlri})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -458,3 +458,30 @@ func TestMixedMPReachMPUnreach(t *testing.T) {
|
||||
attrs = msgs[1].Body.(*bgp.BGPUpdate).PathAttributes
|
||||
assert.Equal(t, len(attrs), 1)
|
||||
}
|
||||
|
||||
func TestMixedNLRIAndMPUnreach(t *testing.T) {
|
||||
aspath1 := []bgp.AsPathParamInterface{
|
||||
bgp.NewAs4PathParam(2, []uint32{100}),
|
||||
}
|
||||
nlri1 := []*bgp.IPAddrPrefix{bgp.NewIPAddrPrefix(24, "10.0.0.0")}
|
||||
nlri2 := []bgp.AddrPrefixInterface{bgp.NewIPv6AddrPrefix(32, "1111::")}
|
||||
|
||||
p := []bgp.PathAttributeInterface{
|
||||
bgp.NewPathAttributeOrigin(0),
|
||||
bgp.NewPathAttributeAsPath(aspath1),
|
||||
bgp.NewPathAttributeNextHop("1.1.1.1"),
|
||||
bgp.NewPathAttributeMpUnreachNLRI(nlri2),
|
||||
}
|
||||
msg := bgp.NewBGPUpdateMessage(nil, p, nlri1)
|
||||
pList := ProcessMessage(msg, peerR1(), time.Now())
|
||||
|
||||
assert.Equal(t, len(pList), 2)
|
||||
assert.Equal(t, pList[0].IsWithdraw, false)
|
||||
assert.Equal(t, pList[1].IsWithdraw, true)
|
||||
msgs := CreateUpdateMsgFromPaths(pList)
|
||||
assert.Equal(t, len(msgs), 2)
|
||||
attrs := msgs[0].Body.(*bgp.BGPUpdate).PathAttributes
|
||||
assert.Equal(t, len(attrs), 1)
|
||||
attrs = msgs[1].Body.(*bgp.BGPUpdate).PathAttributes
|
||||
assert.Equal(t, len(attrs), 3)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user