From ccfded2fee746664b576df0a068aec727cb5fae5 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Sat, 27 Jun 2015 23:28:54 +0900 Subject: [PATCH] server/cli: support add/delete EVPN_INCLUSIVE_MULTICAST_ETHERNET_TAG route Signed-off-by: ISHIDA Wataru --- api/gobgp.pb.go | 22 +++++++- api/gobgp.proto | 9 ++- gobgp/global.go | 83 ++++++++++++++++++++++++---- packet/bgp.go | 11 +++- server/server.go | 140 ++++++++++++++++++++++++++++------------------- 5 files changed, 195 insertions(+), 70 deletions(-) diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index e0cde493..bc1cad51 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -21,6 +21,7 @@ It has these top-level messages: ExtendedCommunity EVPNNlri EvpnMacIpAdvertisement + EvpnInclusiveMulticastEthernetTag RTNlri Nlri TunnelEncapSubTLV @@ -690,7 +691,8 @@ func (*ExtendedCommunity) ProtoMessage() {} type EVPNNlri struct { Type EVPN_TYPE `protobuf:"varint,1,opt,name=type,enum=api.EVPN_TYPE" json:"type,omitempty"` // EvpnAutoDiscoveryRoute = 2; - MacIpAdv *EvpnMacIpAdvertisement `protobuf:"bytes,3,opt,name=mac_ip_adv" json:"mac_ip_adv,omitempty"` + MacIpAdv *EvpnMacIpAdvertisement `protobuf:"bytes,3,opt,name=mac_ip_adv" json:"mac_ip_adv,omitempty"` + MulticastEtag *EvpnInclusiveMulticastEthernetTag `protobuf:"bytes,4,opt,name=multicast_etag" json:"multicast_etag,omitempty"` } func (m *EVPNNlri) Reset() { *m = EVPNNlri{} } @@ -704,6 +706,13 @@ func (m *EVPNNlri) GetMacIpAdv() *EvpnMacIpAdvertisement { return nil } +func (m *EVPNNlri) GetMulticastEtag() *EvpnInclusiveMulticastEthernetTag { + if m != nil { + return m.MulticastEtag + } + return nil +} + type EvpnMacIpAdvertisement struct { MacAddr string `protobuf:"bytes,1,opt,name=mac_addr" json:"mac_addr,omitempty"` MacAddrLen uint32 `protobuf:"varint,2,opt,name=mac_addr_len" json:"mac_addr_len,omitempty"` @@ -719,6 +728,17 @@ func (m *EvpnMacIpAdvertisement) Reset() { *m = EvpnMacIpAdvertisement{} func (m *EvpnMacIpAdvertisement) String() string { return proto.CompactTextString(m) } func (*EvpnMacIpAdvertisement) ProtoMessage() {} +type EvpnInclusiveMulticastEthernetTag struct { + Rd string `protobuf:"bytes,1,opt,name=rd" json:"rd,omitempty"` + Etag uint32 `protobuf:"varint,2,opt,name=etag" json:"etag,omitempty"` + IpAddr string `protobuf:"bytes,3,opt,name=ip_addr" json:"ip_addr,omitempty"` + IpAddrLen uint32 `protobuf:"varint,4,opt,name=ip_addr_len" json:"ip_addr_len,omitempty"` +} + +func (m *EvpnInclusiveMulticastEthernetTag) Reset() { *m = EvpnInclusiveMulticastEthernetTag{} } +func (m *EvpnInclusiveMulticastEthernetTag) String() string { return proto.CompactTextString(m) } +func (*EvpnInclusiveMulticastEthernetTag) ProtoMessage() {} + type RTNlri struct { Asn uint32 `protobuf:"varint,1,opt,name=asn" json:"asn,omitempty"` Target *ExtendedCommunity `protobuf:"bytes,2,opt,name=target" json:"target,omitempty"` diff --git a/api/gobgp.proto b/api/gobgp.proto index 1467ab51..1e789502 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -210,7 +210,7 @@ message EVPNNlri { EVPN_TYPE type = 1; // EvpnAutoDiscoveryRoute = 2; EvpnMacIpAdvertisement mac_ip_adv = 3; -// EvpnInclusiveMulticastEthernetTag = 4; + EvpnInclusiveMulticastEthernetTag multicast_etag = 4; // EvpnEthernetSegmentRoute = 5; } @@ -225,6 +225,13 @@ message EvpnMacIpAdvertisement { repeated uint32 labels = 8; } +message EvpnInclusiveMulticastEthernetTag { + string rd = 1; + uint32 etag = 2; + string ip_addr = 3; + uint32 ip_addr_len = 4; +} + message RTNlri { uint32 asn = 1; ExtendedCommunity target = 2; diff --git a/gobgp/global.go b/gobgp/global.go index 00b0da6c..8744449f 100644 --- a/gobgp/global.go +++ b/gobgp/global.go @@ -21,6 +21,7 @@ import ( "github.com/spf13/cobra" "golang.org/x/net/context" "net" + "os" "strconv" ) @@ -36,7 +37,7 @@ func modPath(modtype string, eArgs []string) error { } path := &api.Path{} - var prefix, macAddr, ipAddr string + var prefix string switch rf { case api.AF_IPV4_UC, api.AF_IPV6_UC: if len(eArgs) == 1 || len(eArgs) == 3 { @@ -49,21 +50,71 @@ func modPath(modtype string, eArgs []string) error { Prefix: prefix, } case api.AF_EVPN: - if len(eArgs) == 4 { - macAddr = eArgs[0] - ipAddr = eArgs[1] - } else { - return fmt.Errorf("usage: global rib %s -a evpn", modtype) + var nlri *api.EVPNNlri + + if len(eArgs) < 1 { + return fmt.Errorf("usage: global rib %s { macadv | multicast } ... -a evpn", modtype) } - path.Nlri = &api.Nlri{ - Af: rf, - EvpnNlri: &api.EVPNNlri{ + subtype := eArgs[0] + + switch subtype { + case "macadv": + if len(eArgs) < 5 { + return fmt.Errorf("usage: global rib %s macadv