summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-08-02 16:11:59 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-04-04 22:07:46 +0900
commit6f102593b71931226d78a9f592173c4742859549 (patch)
tree9a0d41f9210f3148ea91690a910785a2631b6f57
parente80b6ece00bec96ec331c839f9a61cf19027295e (diff)
table: handle paths with IPv4 NLRI and IPv6 nexthop properly
when a path has IPv4 NLRI and IPv6 nexthop, handle it in MPBGP manner. (use mp-reach-nlri path attribute instead of nexthop path attibute) Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--table/message.go8
-rw-r--r--table/path.go6
2 files changed, 12 insertions, 2 deletions
diff --git a/table/message.go b/table/message.go
index 07c15511..af4affa6 100644
--- a/table/message.go
+++ b/table/message.go
@@ -257,9 +257,13 @@ func UpdatePathAggregator4ByteAs(msg *bgp.BGPUpdate) error {
}
func createUpdateMsgFromPath(path *Path, msg *bgp.BGPMessage) *bgp.BGPMessage {
- rf := path.GetRouteFamily()
+ family := path.GetRouteFamily()
+ v4 := true
+ if family != bgp.RF_IPv4_UC || !path.IsWithdraw && path.GetNexthop().To4() == nil {
+ v4 = false
+ }
- if rf == bgp.RF_IPv4_UC {
+ if v4 {
nlri := path.GetNlri().(*bgp.IPAddrPrefix)
if path.IsWithdraw {
if msg != nil {
diff --git a/table/path.go b/table/path.go
index 82af18c1..c31d6cc6 100644
--- a/table/path.go
+++ b/table/path.go
@@ -394,6 +394,12 @@ func (path *Path) GetNexthop() net.IP {
}
func (path *Path) SetNexthop(nexthop net.IP) {
+ if path.GetRouteFamily() == bgp.RF_IPv4_UC && nexthop.To4() == nil {
+ path.delPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
+ mpreach := bgp.NewPathAttributeMpReachNLRI(nexthop.String(), []bgp.AddrPrefixInterface{path.GetNlri()})
+ path.setPathAttr(mpreach)
+ return
+ }
attr := path.getPathAttr(bgp.BGP_ATTR_TYPE_NEXT_HOP)
if attr != nil {
path.setPathAttr(bgp.NewPathAttributeNextHop(nexthop.String()))