diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-07-31 18:51:05 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-08 20:56:46 +0900 |
commit | bf9e135ba85cad641c3812abace9221cbf5a2615 (patch) | |
tree | 435728bd72e93ddfea7a3c02d78cfb1a9c65f16f /packet/bgp.go | |
parent | ecd079e318e1c5d5aa2d2f1348a4ad1a37daec37 (diff) |
server: support vrf
to add/delete vrf
$ gobgp vrf [add|del] <vrf-name> rd <rd> rt [import|export|both] <rt>...
show vrf
$ gobgp vrf
to add/delete a path to a specific vrf
$ gobgp vrf <vrf-name> rib [add|del] <prefix> -a <address-family>
show paths contained in a specific vrf
$ gobgp vrf <vrf-name> rib -a <address-family>
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'packet/bgp.go')
-rw-r--r-- | packet/bgp.go | 67 |
1 files changed, 45 insertions, 22 deletions
diff --git a/packet/bgp.go b/packet/bgp.go index 9fc3366e..62be473a 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -845,7 +845,7 @@ type RouteDistinguisherUnknown struct { DefaultRouteDistinguisher } -func getRouteDistinguisher(data []byte) RouteDistinguisherInterface { +func GetRouteDistinguisher(data []byte) RouteDistinguisherInterface { rdtype := binary.BigEndian.Uint16(data[0:2]) switch rdtype { case BGP_RD_TWO_OCTET_AS: @@ -1016,7 +1016,7 @@ func (l *LabeledVPNIPAddrPrefix) DecodeFromBytes(data []byte) error { l.Labels.Labels = []uint32{} } data = data[l.Labels.Len():] - l.RD = getRouteDistinguisher(data) + l.RD = GetRouteDistinguisher(data) data = data[l.RD.Len():] restbits := int(l.Length) - 8*(l.Labels.Len()+l.RD.Len()) l.decodePrefix(data, uint8(restbits), l.addrlen) @@ -1208,7 +1208,7 @@ func (n *RouteTargetMembershipNLRI) DecodeFromBytes(data []byte) error { return fmt.Errorf("Not all RouteTargetMembershipNLRI bytes available") } n.AS = binary.BigEndian.Uint32(data[0:4]) - rt, err := parseExtended(data[4:]) + rt, err := ParseExtended(data[4:]) n.RouteTarget = rt if err != nil { return err @@ -1389,7 +1389,7 @@ type EVPNEthernetAutoDiscoveryRoute struct { } func (er *EVPNEthernetAutoDiscoveryRoute) DecodeFromBytes(data []byte) error { - er.RD = getRouteDistinguisher(data) + er.RD = GetRouteDistinguisher(data) data = data[er.RD.Len():] err := er.ESI.DecodeFromBytes(data) if err != nil { @@ -1403,11 +1403,16 @@ func (er *EVPNEthernetAutoDiscoveryRoute) DecodeFromBytes(data []byte) error { } func (er *EVPNEthernetAutoDiscoveryRoute) Serialize() ([]byte, error) { - buf, err := er.RD.Serialize() - if err != nil { - return nil, err + var buf []byte + var err error + if er.RD != nil { + buf, err = er.RD.Serialize() + if err != nil { + return nil, err + } + } else { + buf = make([]byte, 8) } - tbuf, err := er.ESI.Serialize() if err != nil { return nil, err @@ -1441,7 +1446,7 @@ type EVPNMacIPAdvertisementRoute struct { } func (er *EVPNMacIPAdvertisementRoute) DecodeFromBytes(data []byte) error { - er.RD = getRouteDistinguisher(data) + er.RD = GetRouteDistinguisher(data) data = data[er.RD.Len():] err := er.ESI.DecodeFromBytes(data) if err != nil { @@ -1472,9 +1477,15 @@ func (er *EVPNMacIPAdvertisementRoute) DecodeFromBytes(data []byte) error { } func (er *EVPNMacIPAdvertisementRoute) Serialize() ([]byte, error) { - buf, err := er.RD.Serialize() - if err != nil { - return nil, err + var buf []byte + var err error + if er.RD != nil { + buf, err = er.RD.Serialize() + if err != nil { + return nil, err + } + } else { + buf = make([]byte, 8) } tbuf, err := er.ESI.Serialize() @@ -1536,7 +1547,7 @@ type EVPNMulticastEthernetTagRoute struct { } func (er *EVPNMulticastEthernetTagRoute) DecodeFromBytes(data []byte) error { - er.RD = getRouteDistinguisher(data) + er.RD = GetRouteDistinguisher(data) data = data[er.RD.Len():] er.ETag = binary.BigEndian.Uint32(data[0:4]) er.IPAddressLength = data[4] @@ -1550,9 +1561,15 @@ func (er *EVPNMulticastEthernetTagRoute) DecodeFromBytes(data []byte) error { } func (er *EVPNMulticastEthernetTagRoute) Serialize() ([]byte, error) { - buf, err := er.RD.Serialize() - if err != nil { - return nil, err + var buf []byte + var err error + if er.RD != nil { + buf, err = er.RD.Serialize() + if err != nil { + return nil, err + } + } else { + buf = make([]byte, 8) } tbuf := make([]byte, 4) binary.BigEndian.PutUint32(tbuf, er.ETag) @@ -1593,7 +1610,7 @@ type EVPNEthernetSegmentRoute struct { } func (er *EVPNEthernetSegmentRoute) DecodeFromBytes(data []byte) error { - er.RD = getRouteDistinguisher(data) + er.RD = GetRouteDistinguisher(data) data = data[er.RD.Len():] er.ESI.DecodeFromBytes(data) data = data[10:] @@ -1608,9 +1625,15 @@ func (er *EVPNEthernetSegmentRoute) DecodeFromBytes(data []byte) error { } func (er *EVPNEthernetSegmentRoute) Serialize() ([]byte, error) { - buf, err := er.RD.Serialize() - if err != nil { - return nil, err + var buf []byte + var err error + if er.RD != nil { + buf, err = er.RD.Serialize() + if err != nil { + return nil, err + } + } else { + buf = make([]byte, 8) } tbuf, err := er.ESI.Serialize() if err != nil { @@ -3585,7 +3608,7 @@ type PathAttributeExtendedCommunities struct { Value []ExtendedCommunityInterface } -func parseExtended(data []byte) (ExtendedCommunityInterface, error) { +func ParseExtended(data []byte) (ExtendedCommunityInterface, error) { attrType := ExtendedCommunityAttrType(data[0]) transitive := false switch attrType { @@ -3648,7 +3671,7 @@ func (p *PathAttributeExtendedCommunities) DecodeFromBytes(data []byte) error { } value := p.PathAttribute.Value for len(value) >= 8 { - e, err := parseExtended(value) + e, err := ParseExtended(value) if err != nil { return err } |