summaryrefslogtreecommitdiffhomepage
path: root/packet/bgp
diff options
context:
space:
mode:
authorIWASE Yusuke <iwase.yusuke0@gmail.com>2018-02-08 14:45:12 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2018-02-16 11:28:02 +0900
commit421a3840e00b4508567c040b5241b3e74cf711e8 (patch)
tree8376d27ad9b64da857718672436f82dfe11776b6 /packet/bgp
parent9fbec19c4c2624df842ab33bb91943bd9befdffa (diff)
cli: Support to advertise PMSI Tunnel Attribute
This patch enables "gobgp" command to advertise the PMSI Tunnel Attribute which is appended to the EVPN Inclusive Multicast Ethernet Tag routes for example. Usage Example: $ gobgp global rib -a evpn add multicast 10.0.0.1 etag 10 rd 65000:100 pmsi ingress-repl 100 1.1.1.1 $ gobgp global rib -a evpn Network Labels Next Hop AS_PATH Age Attrs *> [type:multicast][rd:65000:100][etag:10][ip:10.0.0.1] 0.0.0.0 00:00:00 [{Origin: ?} {Pmsi: type: ingress-repl, label: 100, tunnel-id: 1.1.1.1}] Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'packet/bgp')
-rw-r--r--packet/bgp/bgp.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/packet/bgp/bgp.go b/packet/bgp/bgp.go
index df2e1571..8e9288e0 100644
--- a/packet/bgp/bgp.go
+++ b/packet/bgp/bgp.go
@@ -7927,6 +7927,53 @@ func NewPathAttributePmsiTunnel(typ PmsiTunnelType, isLeafInfoRequired bool, lab
}
}
+func ParsePmsiTunnel(args []string) (*PathAttributePmsiTunnel, error) {
+ // Format:
+ // "<type>" ["leaf-info-required"] "<label>" "<tunnel-id>"
+ if len(args) < 3 {
+ return nil, fmt.Errorf("invalid pmsi tunnel arguments: %s", args)
+ }
+
+ pmsi := NewPathAttributePmsiTunnel(0, false, 0, nil)
+
+ switch args[0] {
+ case "ingress-repl":
+ pmsi.TunnelType = PMSI_TUNNEL_TYPE_INGRESS_REPL
+ default:
+ typ, err := strconv.ParseUint(args[0], 10, 8)
+ if err != nil {
+ return nil, fmt.Errorf("invalid pmsi tunnel type: %s", args[0])
+ }
+ pmsi.TunnelType = PmsiTunnelType(typ)
+ }
+
+ indx := 1
+ if args[indx] == "leaf-info-required" {
+ pmsi.IsLeafInfoRequired = true
+ indx++
+ }
+
+ label, err := strconv.ParseUint(args[indx], 10, 32)
+ if err != nil {
+ return nil, fmt.Errorf("invalid pmsi tunnel label: %s", args[indx])
+ }
+ pmsi.Label = uint32(label)
+ indx++
+
+ switch pmsi.TunnelType {
+ case PMSI_TUNNEL_TYPE_INGRESS_REPL:
+ ip := net.ParseIP(args[indx])
+ if ip == nil {
+ return nil, fmt.Errorf("invalid pmsi tunnel identifier: %s", args[indx])
+ }
+ pmsi.TunnelID = &IngressReplTunnelID{Value: ip}
+ default:
+ pmsi.TunnelID = &DefaultPmsiTunnelID{Value: []byte(args[indx])}
+ }
+
+ return pmsi, nil
+}
+
type AigpTLVType uint8
const (