summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2017-07-31 10:00:35 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-10-03 23:04:20 +0900
commit21ac7fa3ca69ff95b6fab96245d8c03612ee56eb (patch)
tree66087056f7fd5974d138102d1e46a1a08bfda128
parente1d2dd025de89dd0c5db88322f990d60e09cc91f (diff)
packet/mrt: Enable RibEntry to switch add-path enabled
Because path_id = 0 is valid Path ID, we cannot determine whether add-path is enabled based on just a value of path_id. This patch adds a new argument to switch add-path features. Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-rw-r--r--packet/mrt/mrt.go8
-rw-r--r--packet/mrt/mrt_test.go16
2 files changed, 12 insertions, 12 deletions
diff --git a/packet/mrt/mrt.go b/packet/mrt/mrt.go
index 559455d1..1b7c3e05 100644
--- a/packet/mrt/mrt.go
+++ b/packet/mrt/mrt.go
@@ -431,13 +431,13 @@ func (e *RibEntry) Serialize() ([]byte, error) {
return buf, nil
}
-func NewRibEntry(index uint16, time uint32, pathid uint32, pathattrs []bgp.PathAttributeInterface) *RibEntry {
+func NewRibEntry(index uint16, time uint32, pathId uint32, pathAttrs []bgp.PathAttributeInterface, isAddPath bool) *RibEntry {
return &RibEntry{
PeerIndex: index,
OriginatedTime: time,
- PathIdentifier: pathid,
- PathAttributes: pathattrs,
- isAddPath: pathid != 0,
+ PathIdentifier: pathId,
+ PathAttributes: pathAttrs,
+ isAddPath: isAddPath,
}
}
diff --git a/packet/mrt/mrt_test.go b/packet/mrt/mrt_test.go
index e2e601a5..30edd496 100644
--- a/packet/mrt/mrt_test.go
+++ b/packet/mrt/mrt_test.go
@@ -114,7 +114,7 @@ func TestMrtRibEntry(t *testing.T) {
bgp.NewPathAttributeLocalPref(1 << 22),
}
- e1 := NewRibEntry(1, uint32(time.Now().Unix()), 0, p)
+ e1 := NewRibEntry(1, uint32(time.Now().Unix()), 0, p, false)
b1, err := e1.Serialize()
if err != nil {
t.Fatal(err)
@@ -143,7 +143,7 @@ func TestMrtRibEntryWithAddPath(t *testing.T) {
bgp.NewPathAttributeMultiExitDisc(1 << 20),
bgp.NewPathAttributeLocalPref(1 << 22),
}
- e1 := NewRibEntry(1, uint32(time.Now().Unix()), 200, p)
+ e1 := NewRibEntry(1, uint32(time.Now().Unix()), 200, p, true)
b1, err := e1.Serialize()
if err != nil {
t.Fatal(err)
@@ -173,9 +173,9 @@ func TestMrtRib(t *testing.T) {
bgp.NewPathAttributeLocalPref(1 << 22),
}
- e1 := NewRibEntry(1, uint32(time.Now().Unix()), 0, p)
- e2 := NewRibEntry(2, uint32(time.Now().Unix()), 0, p)
- e3 := NewRibEntry(3, uint32(time.Now().Unix()), 0, p)
+ e1 := NewRibEntry(1, uint32(time.Now().Unix()), 0, p, false)
+ e2 := NewRibEntry(2, uint32(time.Now().Unix()), 0, p, false)
+ e3 := NewRibEntry(3, uint32(time.Now().Unix()), 0, p, false)
r1 := NewRib(1, bgp.NewIPAddrPrefix(24, "192.168.0.0"), []*RibEntry{e1, e2, e3})
b1, err := r1.Serialize()
@@ -207,9 +207,9 @@ func TestMrtRibWithAddPath(t *testing.T) {
bgp.NewPathAttributeLocalPref(1 << 22),
}
- e1 := NewRibEntry(1, uint32(time.Now().Unix()), 100, p)
- e2 := NewRibEntry(2, uint32(time.Now().Unix()), 200, p)
- e3 := NewRibEntry(3, uint32(time.Now().Unix()), 300, p)
+ e1 := NewRibEntry(1, uint32(time.Now().Unix()), 100, p, true)
+ e2 := NewRibEntry(2, uint32(time.Now().Unix()), 200, p, true)
+ e3 := NewRibEntry(3, uint32(time.Now().Unix()), 300, p, true)
r1 := NewRib(1, bgp.NewIPAddrPrefix(24, "192.168.0.0"), []*RibEntry{e1, e2, e3})
b1, err := r1.Serialize()