diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-12-15 18:25:50 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-12-15 18:26:32 +0900 |
commit | d6148c75a30d87c3f8c1d0f68725127e4c5f3a65 (patch) | |
tree | 42c7df8c6a11187f0d622baa9e0ea45ad6df0cd3 | |
parent | 1b386f627fb081f4e805a4d7b2f94a14b8790243 (diff) |
api: refactor afisafi api
remove unused fields
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r-- | api/gobgp.pb.go | 381 | ||||
-rw-r--r-- | api/gobgp.proto | 108 | ||||
-rw-r--r-- | gobgp/cmd/common.go | 2 | ||||
-rw-r--r-- | gobgp/cmd/monitor.go | 4 | ||||
-rw-r--r-- | gobgp/cmd/mrt.go | 6 | ||||
-rw-r--r-- | gobgp/cmd/neighbor.go | 10 | ||||
-rw-r--r-- | gobgp/cmd/rpki.go | 6 | ||||
-rw-r--r-- | packet/bgp.go | 81 | ||||
-rw-r--r-- | server/grpc_server.go | 10 | ||||
-rw-r--r-- | server/server.go | 19 | ||||
-rw-r--r-- | table/path.go | 4 |
11 files changed, 94 insertions, 537 deletions
diff --git a/api/gobgp.pb.go b/api/gobgp.pb.go index 4b59a079..df4c190e 100644 --- a/api/gobgp.pb.go +++ b/api/gobgp.pb.go @@ -26,24 +26,9 @@ It has these top-level messages: Destination Table Peer - AddPaths - AfiSafis - AfiSafi ApplyPolicy - AfiSafiGracefulRestart - LabelledUnicast - PrefixLimit - Unicast - Vpn - Prefixes - UseMultiplePaths - Ebgp - AsPathOptions PeerConf EbgpMultihop - ErrorHandling - PeerGracefulRestart - LoggingOptions RouteReflector PeerState Messages @@ -343,7 +328,7 @@ func (*Error) ProtoMessage() {} type Arguments struct { Resource Resource `protobuf:"varint,1,opt,name=resource,enum=gobgpapi.Resource" json:"resource,omitempty"` - Rf uint32 `protobuf:"varint,2,opt,name=rf" json:"rf,omitempty"` + Family uint32 `protobuf:"varint,2,opt,name=family" json:"family,omitempty"` Name string `protobuf:"bytes,3,opt,name=name" json:"name,omitempty"` } @@ -386,7 +371,7 @@ func (m *ModNeighborArguments) GetPeer() *Peer { type MrtArguments struct { Resource Resource `protobuf:"varint,1,opt,name=resource,enum=gobgpapi.Resource" json:"resource,omitempty"` - Rf uint32 `protobuf:"varint,2,opt,name=rf" json:"rf,omitempty"` + Family uint32 `protobuf:"varint,2,opt,name=family" json:"family,omitempty"` Interval uint64 `protobuf:"varint,3,opt,name=interval" json:"interval,omitempty"` NeighborAddress string `protobuf:"bytes,4,opt,name=neighbor_address" json:"neighbor_address,omitempty"` } @@ -526,7 +511,7 @@ type Path struct { IsWithdraw bool `protobuf:"varint,5,opt,name=is_withdraw" json:"is_withdraw,omitempty"` Validation int32 `protobuf:"varint,6,opt,name=validation" json:"validation,omitempty"` NoImplicitWithdraw bool `protobuf:"varint,7,opt,name=no_implicit_withdraw" json:"no_implicit_withdraw,omitempty"` - Rf uint32 `protobuf:"varint,8,opt,name=rf" json:"rf,omitempty"` + Family uint32 `protobuf:"varint,8,opt,name=family" json:"family,omitempty"` SourceAsn uint32 `protobuf:"varint,9,opt,name=source_asn" json:"source_asn,omitempty"` SourceId string `protobuf:"bytes,10,opt,name=source_id" json:"source_id,omitempty"` Filtered bool `protobuf:"varint,11,opt,name=filtered" json:"filtered,omitempty"` @@ -572,41 +557,21 @@ func (m *Table) GetDestinations() []*Destination { } type Peer struct { - Addpaths *AddPaths `protobuf:"bytes,1,opt,name=addpaths" json:"addpaths,omitempty"` - Afisafis *AfiSafis `protobuf:"bytes,2,opt,name=afisafis" json:"afisafis,omitempty"` - ApplyPolicy *ApplyPolicy `protobuf:"bytes,3,opt,name=apply_policy" json:"apply_policy,omitempty"` - AsPathOptions *AsPathOptions `protobuf:"bytes,4,opt,name=as_path_options" json:"as_path_options,omitempty"` - Conf *PeerConf `protobuf:"bytes,5,opt,name=conf" json:"conf,omitempty"` - EbgpMultihop *EbgpMultihop `protobuf:"bytes,6,opt,name=ebgp_multihop" json:"ebgp_multihop,omitempty"` - ErrorHandling *ErrorHandling `protobuf:"bytes,7,opt,name=error_handling" json:"error_handling,omitempty"` - GracefulRestart *PeerGracefulRestart `protobuf:"bytes,8,opt,name=graceful_restart" json:"graceful_restart,omitempty"` - LoggingOptions *LoggingOptions `protobuf:"bytes,9,opt,name=logging_options" json:"logging_options,omitempty"` - RouteReflector *RouteReflector `protobuf:"bytes,10,opt,name=route_reflector" json:"route_reflector,omitempty"` - Info *PeerState `protobuf:"bytes,11,opt,name=info" json:"info,omitempty"` - Timers *Timers `protobuf:"bytes,12,opt,name=timers" json:"timers,omitempty"` - Transport *Transport `protobuf:"bytes,13,opt,name=transport" json:"transport,omitempty"` - UseMultiplePaths *UseMultiplePaths `protobuf:"bytes,14,opt,name=use_multiple_paths" json:"use_multiple_paths,omitempty"` - RouteServer *RouteServer `protobuf:"bytes,15,opt,name=route_server" json:"route_server,omitempty"` + Families []uint32 `protobuf:"varint,2,rep,name=families" json:"families,omitempty"` + ApplyPolicy *ApplyPolicy `protobuf:"bytes,3,opt,name=apply_policy" json:"apply_policy,omitempty"` + Conf *PeerConf `protobuf:"bytes,5,opt,name=conf" json:"conf,omitempty"` + EbgpMultihop *EbgpMultihop `protobuf:"bytes,6,opt,name=ebgp_multihop" json:"ebgp_multihop,omitempty"` + RouteReflector *RouteReflector `protobuf:"bytes,10,opt,name=route_reflector" json:"route_reflector,omitempty"` + Info *PeerState `protobuf:"bytes,11,opt,name=info" json:"info,omitempty"` + Timers *Timers `protobuf:"bytes,12,opt,name=timers" json:"timers,omitempty"` + Transport *Transport `protobuf:"bytes,13,opt,name=transport" json:"transport,omitempty"` + RouteServer *RouteServer `protobuf:"bytes,15,opt,name=route_server" json:"route_server,omitempty"` } func (m *Peer) Reset() { *m = Peer{} } func (m *Peer) String() string { return proto.CompactTextString(m) } func (*Peer) ProtoMessage() {} -func (m *Peer) GetAddpaths() *AddPaths { - if m != nil { - return m.Addpaths - } - return nil -} - -func (m *Peer) GetAfisafis() *AfiSafis { - if m != nil { - return m.Afisafis - } - return nil -} - func (m *Peer) GetApplyPolicy() *ApplyPolicy { if m != nil { return m.ApplyPolicy @@ -614,13 +579,6 @@ func (m *Peer) GetApplyPolicy() *ApplyPolicy { return nil } -func (m *Peer) GetAsPathOptions() *AsPathOptions { - if m != nil { - return m.AsPathOptions - } - return nil -} - func (m *Peer) GetConf() *PeerConf { if m != nil { return m.Conf @@ -635,27 +593,6 @@ func (m *Peer) GetEbgpMultihop() *EbgpMultihop { return nil } -func (m *Peer) GetErrorHandling() *ErrorHandling { - if m != nil { - return m.ErrorHandling - } - return nil -} - -func (m *Peer) GetGracefulRestart() *PeerGracefulRestart { - if m != nil { - return m.GracefulRestart - } - return nil -} - -func (m *Peer) GetLoggingOptions() *LoggingOptions { - if m != nil { - return m.LoggingOptions - } - return nil -} - func (m *Peer) GetRouteReflector() *RouteReflector { if m != nil { return m.RouteReflector @@ -684,13 +621,6 @@ func (m *Peer) GetTransport() *Transport { return nil } -func (m *Peer) GetUseMultiplePaths() *UseMultiplePaths { - if m != nil { - return m.UseMultiplePaths - } - return nil -} - func (m *Peer) GetRouteServer() *RouteServer { if m != nil { return m.RouteServer @@ -698,152 +628,6 @@ func (m *Peer) GetRouteServer() *RouteServer { return nil } -type AddPaths struct { - Receive bool `protobuf:"varint,1,opt,name=receive" json:"receive,omitempty"` - SendMax uint32 `protobuf:"varint,2,opt,name=send_max" json:"send_max,omitempty"` -} - -func (m *AddPaths) Reset() { *m = AddPaths{} } -func (m *AddPaths) String() string { return proto.CompactTextString(m) } -func (*AddPaths) ProtoMessage() {} - -type AfiSafis struct { - Afisafi []*AfiSafi `protobuf:"bytes,1,rep,name=afisafi" json:"afisafi,omitempty"` -} - -func (m *AfiSafis) Reset() { *m = AfiSafis{} } -func (m *AfiSafis) String() string { return proto.CompactTextString(m) } -func (*AfiSafis) ProtoMessage() {} - -func (m *AfiSafis) GetAfisafi() []*AfiSafi { - if m != nil { - return m.Afisafi - } - return nil -} - -type AfiSafi struct { - Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` - ApplyPolicy *ApplyPolicy `protobuf:"bytes,2,opt,name=apply_policy" json:"apply_policy,omitempty"` - Enabled bool `protobuf:"varint,3,opt,name=enabled" json:"enabled,omitempty"` - GracefulRestart *AfiSafiGracefulRestart `protobuf:"bytes,4,opt,name=graceful_restart" json:"graceful_restart,omitempty"` - Ipv4LabelledUnicast *LabelledUnicast `protobuf:"bytes,5,opt,name=ipv4_labelled_unicast" json:"ipv4_labelled_unicast,omitempty"` - Ipv4Unicast *Unicast `protobuf:"bytes,6,opt,name=ipv4_unicast" json:"ipv4_unicast,omitempty"` - Ipv6LabelledUnicast *LabelledUnicast `protobuf:"bytes,7,opt,name=ipv6_labelled_unicast" json:"ipv6_labelled_unicast,omitempty"` - Ipv6Unicast *Unicast `protobuf:"bytes,8,opt,name=ipv6_unicast" json:"ipv6_unicast,omitempty"` - L2VpnEvpn *Vpn `protobuf:"bytes,9,opt,name=l2_vpn_evpn" json:"l2_vpn_evpn,omitempty"` - L2VpnVpls *Vpn `protobuf:"bytes,10,opt,name=l2_vpn_vpls" json:"l2_vpn_vpls,omitempty"` - L3VpnIpv4Multicast *Vpn `protobuf:"bytes,11,opt,name=l3_vpn_ipv4_multicast" json:"l3_vpn_ipv4_multicast,omitempty"` - L3VpnIpv4Unicast *Vpn `protobuf:"bytes,12,opt,name=l3_vpn_ipv4_unicast" json:"l3_vpn_ipv4_unicast,omitempty"` - L3VpnIpv6Multicast *Vpn `protobuf:"bytes,13,opt,name=l3_vpn_ipv6_multicast" json:"l3_vpn_ipv6_multicast,omitempty"` - L3VpnIpv6Unicast *Vpn `protobuf:"bytes,14,opt,name=l3_vpn_ipv6_unicast" json:"l3_vpn_ipv6_unicast,omitempty"` - UseMultiplePaths *UseMultiplePaths `protobuf:"bytes,15,opt,name=use_multiple_paths" json:"use_multiple_paths,omitempty"` - Active bool `protobuf:"varint,16,opt,name=active" json:"active,omitempty"` - Prefixes *Prefixes `protobuf:"bytes,17,opt,name=prefixes" json:"prefixes,omitempty"` -} - -func (m *AfiSafi) Reset() { *m = AfiSafi{} } -func (m *AfiSafi) String() string { return proto.CompactTextString(m) } -func (*AfiSafi) ProtoMessage() {} - -func (m *AfiSafi) GetApplyPolicy() *ApplyPolicy { - if m != nil { - return m.ApplyPolicy - } - return nil -} - -func (m *AfiSafi) GetGracefulRestart() *AfiSafiGracefulRestart { - if m != nil { - return m.GracefulRestart - } - return nil -} - -func (m *AfiSafi) GetIpv4LabelledUnicast() *LabelledUnicast { - if m != nil { - return m.Ipv4LabelledUnicast - } - return nil -} - -func (m *AfiSafi) GetIpv4Unicast() *Unicast { - if m != nil { - return m.Ipv4Unicast - } - return nil -} - -func (m *AfiSafi) GetIpv6LabelledUnicast() *LabelledUnicast { - if m != nil { - return m.Ipv6LabelledUnicast - } - return nil -} - -func (m *AfiSafi) GetIpv6Unicast() *Unicast { - if m != nil { - return m.Ipv6Unicast - } - return nil -} - -func (m *AfiSafi) GetL2VpnEvpn() *Vpn { - if m != nil { - return m.L2VpnEvpn - } - return nil -} - -func (m *AfiSafi) GetL2VpnVpls() *Vpn { - if m != nil { - return m.L2VpnVpls - } - return nil -} - -func (m *AfiSafi) GetL3VpnIpv4Multicast() *Vpn { - if m != nil { - return m.L3VpnIpv4Multicast - } - return nil -} - -func (m *AfiSafi) GetL3VpnIpv4Unicast() *Vpn { - if m != nil { - return m.L3VpnIpv4Unicast - } - return nil -} - -func (m *AfiSafi) GetL3VpnIpv6Multicast() *Vpn { - if m != nil { - return m.L3VpnIpv6Multicast - } - return nil -} - -func (m *AfiSafi) GetL3VpnIpv6Unicast() *Vpn { - if m != nil { - return m.L3VpnIpv6Unicast - } - return nil -} - -func (m *AfiSafi) GetUseMultiplePaths() *UseMultiplePaths { - if m != nil { - return m.UseMultiplePaths - } - return nil -} - -func (m *AfiSafi) GetPrefixes() *Prefixes { - if m != nil { - return m.Prefixes - } - return nil -} - type ApplyPolicy struct { InPolicy *PolicyAssignment `protobuf:"bytes,1,opt,name=in_policy" json:"in_policy,omitempty"` ExportPolicy *PolicyAssignment `protobuf:"bytes,2,opt,name=export_policy" json:"export_policy,omitempty"` @@ -875,115 +659,6 @@ func (m *ApplyPolicy) GetImportPolicy() *PolicyAssignment { return nil } -type AfiSafiGracefulRestart struct { - Advertised bool `protobuf:"varint,1,opt,name=advertised" json:"advertised,omitempty"` - Enabled bool `protobuf:"varint,2,opt,name=enabled" json:"enabled,omitempty"` - Received bool `protobuf:"varint,3,opt,name=received" json:"received,omitempty"` -} - -func (m *AfiSafiGracefulRestart) Reset() { *m = AfiSafiGracefulRestart{} } -func (m *AfiSafiGracefulRestart) String() string { return proto.CompactTextString(m) } -func (*AfiSafiGracefulRestart) ProtoMessage() {} - -type LabelledUnicast struct { - PrefixLimit *PrefixLimit `protobuf:"bytes,1,opt,name=prefix_limit" json:"prefix_limit,omitempty"` -} - -func (m *LabelledUnicast) Reset() { *m = LabelledUnicast{} } -func (m *LabelledUnicast) String() string { return proto.CompactTextString(m) } -func (*LabelledUnicast) ProtoMessage() {} - -func (m *LabelledUnicast) GetPrefixLimit() *PrefixLimit { - if m != nil { - return m.PrefixLimit - } - return nil -} - -type PrefixLimit struct { - MaxPrefixes uint32 `protobuf:"varint,1,opt,name=max_prefixes" json:"max_prefixes,omitempty"` - RestartTimer uint64 `protobuf:"varint,2,opt,name=restart_timer" json:"restart_timer,omitempty"` - ShutdownThresholdPct uint32 `protobuf:"varint,3,opt,name=shutdown_threshold_pct" json:"shutdown_threshold_pct,omitempty"` -} - -func (m *PrefixLimit) Reset() { *m = PrefixLimit{} } -func (m *PrefixLimit) String() string { return proto.CompactTextString(m) } -func (*PrefixLimit) ProtoMessage() {} - -type Unicast struct { - SendDefaultRoute bool `protobuf:"varint,1,opt,name=send_default_route" json:"send_default_route,omitempty"` - PrefixLimit *PrefixLimit `protobuf:"bytes,2,opt,name=prefix_limit" json:"prefix_limit,omitempty"` -} - -func (m *Unicast) Reset() { *m = Unicast{} } -func (m *Unicast) String() string { return proto.CompactTextString(m) } -func (*Unicast) ProtoMessage() {} - -func (m *Unicast) GetPrefixLimit() *PrefixLimit { - if m != nil { - return m.PrefixLimit - } - return nil -} - -type Vpn struct { - PrefixLimit *PrefixLimit `protobuf:"bytes,1,opt,name=prefix_limit" json:"prefix_limit,omitempty"` -} - -func (m *Vpn) Reset() { *m = Vpn{} } -func (m *Vpn) String() string { return proto.CompactTextString(m) } -func (*Vpn) ProtoMessage() {} - -func (m *Vpn) GetPrefixLimit() *PrefixLimit { - if m != nil { - return m.PrefixLimit - } - return nil -} - -type Prefixes struct { - Installed uint32 `protobuf:"varint,1,opt,name=installed" json:"installed,omitempty"` - Received uint32 `protobuf:"varint,2,opt,name=received" json:"received,omitempty"` - Sent uint32 `protobuf:"varint,3,opt,name=sent" json:"sent,omitempty"` -} - -func (m *Prefixes) Reset() { *m = Prefixes{} } -func (m *Prefixes) String() string { return proto.CompactTextString(m) } -func (*Prefixes) ProtoMessage() {} - -type UseMultiplePaths struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled" json:"enabled,omitempty"` - Ebgp *Ebgp `protobuf:"bytes,2,opt,name=ebgp" json:"ebgp,omitempty"` -} - -func (m *UseMultiplePaths) Reset() { *m = UseMultiplePaths{} } -func (m *UseMultiplePaths) String() string { return proto.CompactTextString(m) } -func (*UseMultiplePaths) ProtoMessage() {} - -func (m *UseMultiplePaths) GetEbgp() *Ebgp { - if m != nil { - return m.Ebgp - } - return nil -} - -type Ebgp struct { - AllowMultipleAs bool `protobuf:"varint,1,opt,name=allow_multiple_as" json:"allow_multiple_as,omitempty"` -} - -func (m *Ebgp) Reset() { *m = Ebgp{} } -func (m *Ebgp) String() string { return proto.CompactTextString(m) } -func (*Ebgp) ProtoMessage() {} - -type AsPathOptions struct { - AllowOwnAs uint32 `protobuf:"varint,1,opt,name=allow_own_as" json:"allow_own_as,omitempty"` - ReplacePeerAs bool `protobuf:"varint,2,opt,name=replace_peer_as" json:"replace_peer_as,omitempty"` -} - -func (m *AsPathOptions) Reset() { *m = AsPathOptions{} } -func (m *AsPathOptions) String() string { return proto.CompactTextString(m) } -func (*AsPathOptions) ProtoMessage() {} - type PeerConf struct { AuthPassword string `protobuf:"bytes,1,opt,name=auth_password" json:"auth_password,omitempty"` Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` @@ -1013,38 +688,6 @@ func (m *EbgpMultihop) Reset() { *m = EbgpMultihop{} } func (m *EbgpMultihop) String() string { return proto.CompactTextString(m) } func (*EbgpMultihop) ProtoMessage() {} -type ErrorHandling struct { - ErroneousUpdateMessages uint32 `protobuf:"varint,1,opt,name=erroneous_update_messages" json:"erroneous_update_messages,omitempty"` - TreatAsWithdraw bool `protobuf:"varint,2,opt,name=treat_as_withdraw" json:"treat_as_withdraw,omitempty"` -} - -func (m *ErrorHandling) Reset() { *m = ErrorHandling{} } -func (m *ErrorHandling) String() string { return proto.CompactTextString(m) } -func (*ErrorHandling) ProtoMessage() {} - -type PeerGracefulRestart struct { - Enabled bool `protobuf:"varint,1,opt,name=enabled" json:"enabled,omitempty"` - HelperOnly bool `protobuf:"varint,2,opt,name=helper_only" json:"helper_only,omitempty"` - LocalRestarting bool `protobuf:"varint,3,opt,name=local_restarting" json:"local_restarting,omitempty"` - Mode uint32 `protobuf:"varint,4,opt,name=mode" json:"mode,omitempty"` - PeerRestartTime uint32 `protobuf:"varint,5,opt,name=peer_restart_time" json:"peer_restart_time,omitempty"` - PeerRestarting bool `protobuf:"varint,6,opt,name=peer_restarting" json:"peer_restarting,omitempty"` - RestartTime uint32 `protobuf:"varint,7,opt,name=restart_time" json:"restart_time,omitempty"` - StaleRoutesTime uint64 `protobuf:"varint,8,opt,name=stale_routes_time" json:"stale_routes_time,omitempty"` -} - -func (m *PeerGracefulRestart) Reset() { *m = PeerGracefulRestart{} } -func (m *PeerGracefulRestart) String() string { return proto.CompactTextString(m) } -func (*PeerGracefulRestart) ProtoMessage() {} - -type LoggingOptions struct { - LogNeighborStateChanges bool `protobuf:"varint,1,opt,name=logNeighbor_state_changes" json:"logNeighbor_state_changes,omitempty"` -} - -func (m *LoggingOptions) Reset() { *m = LoggingOptions{} } -func (m *LoggingOptions) String() string { return proto.CompactTextString(m) } -func (*LoggingOptions) ProtoMessage() {} - type RouteReflector struct { RouteReflectorClient bool `protobuf:"varint,1,opt,name=route_reflector_client" json:"route_reflector_client,omitempty"` RouteReflectorClusterId uint32 `protobuf:"varint,2,opt,name=route_reflector_cluster_id" json:"route_reflector_cluster_id,omitempty"` diff --git a/api/gobgp.proto b/api/gobgp.proto index b052aaa6..fc800167 100644 --- a/api/gobgp.proto +++ b/api/gobgp.proto @@ -67,7 +67,7 @@ message Error { message Arguments { Resource resource = 1; - uint32 rf = 2; + uint32 family = 2; string name = 3; } @@ -84,7 +84,7 @@ message ModNeighborArguments { message MrtArguments { Resource resource = 1; - uint32 rf = 2; + uint32 family = 2; uint64 interval = 3; string neighbor_address = 4; } @@ -161,7 +161,7 @@ message Path { bool is_withdraw = 5; int32 validation = 6; bool no_implicit_withdraw = 7; - uint32 rf = 8; + uint32 family = 8; uint32 source_asn = 9; string source_id = 10; bool filtered = 11; @@ -181,103 +181,23 @@ message Table { } message Peer { - AddPaths addpaths = 1; - AfiSafis afisafis = 2; + repeated uint32 families = 2; ApplyPolicy apply_policy = 3; - AsPathOptions as_path_options = 4; PeerConf conf = 5; EbgpMultihop ebgp_multihop = 6; - ErrorHandling error_handling = 7; - PeerGracefulRestart graceful_restart = 8; - LoggingOptions logging_options = 9; RouteReflector route_reflector = 10; PeerState info = 11; Timers timers = 12; Transport transport = 13; - UseMultiplePaths use_multiple_paths = 14; RouteServer route_server = 15; } -message AddPaths { - bool receive = 1; - uint32 send_max = 2; -} - -message AfiSafis { - repeated AfiSafi afisafi = 1; -} - -message AfiSafi { - string name = 1; - ApplyPolicy apply_policy = 2; - bool enabled = 3; - AfiSafiGracefulRestart graceful_restart = 4; - LabelledUnicast ipv4_labelled_unicast = 5; - Unicast ipv4_unicast = 6; - LabelledUnicast ipv6_labelled_unicast = 7; - Unicast ipv6_unicast = 8; - Vpn l2_vpn_evpn = 9; - Vpn l2_vpn_vpls = 10; - Vpn l3_vpn_ipv4_multicast = 11; - Vpn l3_vpn_ipv4_unicast = 12; - Vpn l3_vpn_ipv6_multicast = 13; - Vpn l3_vpn_ipv6_unicast = 14; - UseMultiplePaths use_multiple_paths = 15; - bool active = 16; - Prefixes prefixes = 17; - } - message ApplyPolicy { PolicyAssignment in_policy = 1; PolicyAssignment export_policy = 2; PolicyAssignment import_policy = 3; } -message AfiSafiGracefulRestart { - bool advertised = 1; - bool enabled = 2; - bool received = 3; -} - -message LabelledUnicast { - PrefixLimit prefix_limit = 1; -} - -message PrefixLimit { - uint32 max_prefixes = 1; - uint64 restart_timer = 2; - uint32 shutdown_threshold_pct = 3; -} - -message Unicast { - bool send_default_route = 1; - PrefixLimit prefix_limit = 2; -} - -message Vpn { - PrefixLimit prefix_limit = 1; -} - -message Prefixes { - uint32 installed = 1; - uint32 received = 2; - uint32 sent = 3; -} - -message UseMultiplePaths { - bool enabled = 1; - Ebgp ebgp = 2; -} - -message Ebgp { - bool allow_multiple_as = 1; -} - -message AsPathOptions { - uint32 allow_own_as = 1; - bool replace_peer_as = 2; -} - message PeerConf { string auth_password = 1; string description = 2; @@ -299,26 +219,6 @@ message EbgpMultihop { uint32 multihop_ttl = 2; } -message ErrorHandling { - uint32 erroneous_update_messages = 1; - bool treat_as_withdraw = 2; -} - -message PeerGracefulRestart { - bool enabled = 1; - bool helper_only = 2; - bool local_restarting = 3; - uint32 mode = 4; - uint32 peer_restart_time = 5; - bool peer_restarting = 6; - uint32 restart_time = 7; - uint64 stale_routes_time = 8; -} - -message LoggingOptions { - bool logNeighbor_state_changes = 1; -} - message RouteReflector { bool route_reflector_client = 1; uint32 route_reflector_cluster_id = 2; diff --git a/gobgp/cmd/common.go b/gobgp/cmd/common.go index 51cb414a..8dfce3ff 100644 --- a/gobgp/cmd/common.go +++ b/gobgp/cmd/common.go @@ -167,7 +167,7 @@ type Path struct { func ApiStruct2Path(p *gobgpapi.Path) ([]*Path, error) { nlris := make([]bgp.AddrPrefixInterface, 0, 1) data := p.Nlri - if p.Rf == uint32(bgp.RF_IPv4_UC) && len(data) > 0 { + if p.Family == uint32(bgp.RF_IPv4_UC) && len(data) > 0 { nlri := &bgp.IPAddrPrefix{} err := nlri.DecodeFromBytes(data) if err != nil { diff --git a/gobgp/cmd/monitor.go b/gobgp/cmd/monitor.go index 75cda7fe..1bf0a046 100644 --- a/gobgp/cmd/monitor.go +++ b/gobgp/cmd/monitor.go @@ -30,14 +30,14 @@ func NewMonitorCmd() *cobra.Command { ribCmd := &cobra.Command{ Use: CMD_RIB, Run: func(cmd *cobra.Command, args []string) { - rf, err := checkAddressFamily(bgp.RouteFamily(0)) + family, err := checkAddressFamily(bgp.RouteFamily(0)) if err != nil { fmt.Println(err) os.Exit(1) } arg := &gobgpapi.Arguments{ Resource: gobgpapi.Resource_GLOBAL, - Rf: uint32(rf), + Family: uint32(family), } stream, err := client.MonitorBestChanged(context.Background(), arg) diff --git a/gobgp/cmd/mrt.go b/gobgp/cmd/mrt.go index 44641f33..b27f7b68 100644 --- a/gobgp/cmd/mrt.go +++ b/gobgp/cmd/mrt.go @@ -81,7 +81,7 @@ func dumpRib(r string, remoteIP net.IP, args []string) error { return fmt.Errorf("unknown resource type: %s", r) } - rf, err := checkAddressFamily(addr2AddressFamily(remoteIP)) + family, err := checkAddressFamily(addr2AddressFamily(remoteIP)) if err != nil { return err } @@ -97,12 +97,12 @@ func dumpRib(r string, remoteIP net.IP, args []string) error { arg := &api.MrtArguments{ Resource: resource, - Rf: uint32(rf), + Family: uint32(family), Interval: interval, NeighborAddress: remoteIP.String(), } - afi, _ := bgp.RouteFamilyToAfiSafi(rf) + afi, _ := bgp.RouteFamilyToAfiSafi(family) var af string switch afi { case bgp.AFI_IP: diff --git a/gobgp/cmd/neighbor.go b/gobgp/cmd/neighbor.go index 9c8b586a..83de7cf4 100644 --- a/gobgp/cmd/neighbor.go +++ b/gobgp/cmd/neighbor.go @@ -510,13 +510,13 @@ func showNeighborRib(r string, name string, args []string) error { } func resetNeighbor(cmd string, remoteIP string, args []string) error { - rf, err := checkAddressFamily(addr2AddressFamily(net.ParseIP(remoteIP))) + family, err := checkAddressFamily(addr2AddressFamily(net.ParseIP(remoteIP))) if err != nil { return err } arg := &api.Arguments{ - Name: remoteIP, - Rf: uint32(rf), + Name: remoteIP, + Family: uint32(family), } switch cmd { case CMD_RESET: @@ -533,8 +533,8 @@ func resetNeighbor(cmd string, remoteIP string, args []string) error { func stateChangeNeighbor(cmd string, remoteIP string, args []string) error { arg := &api.Arguments{ - Rf: uint32(bgp.RF_IPv4_UC), - Name: remoteIP, + Family: uint32(bgp.RF_IPv4_UC), + Name: remoteIP, } var err error switch cmd { diff --git a/gobgp/cmd/rpki.go b/gobgp/cmd/rpki.go index a2d72edc..099ac115 100644 --- a/gobgp/cmd/rpki.go +++ b/gobgp/cmd/rpki.go @@ -54,13 +54,13 @@ func showRPKIServer(args []string) error { } func showRPKITable(args []string) error { - rf, err := checkAddressFamily(bgp.RouteFamily(0)) + family, err := checkAddressFamily(bgp.RouteFamily(0)) if err != nil { fmt.Println(err) os.Exit(1) } arg := &api.Arguments{ - Rf: uint32(rf), + Family: uint32(family), } if len(args) > 0 { arg.Name = args[0] @@ -72,7 +72,7 @@ func showRPKITable(args []string) error { } var format string - afi, _ := bgp.RouteFamilyToAfiSafi(rf) + afi, _ := bgp.RouteFamilyToAfiSafi(family) if afi == bgp.AFI_IP { format = "%-18s %-6s %-10s %s\n" } else { diff --git a/packet/bgp.go b/packet/bgp.go index bac3edb0..61d36e4b 100644 --- a/packet/bgp.go +++ b/packet/bgp.go @@ -2926,44 +2926,51 @@ const ( RF_FS_IPv6_VPN RouteFamily = AFI_IP6<<16 | SAFI_FLOW_SPEC_VPN ) +var AddressFamilyNameMap = map[RouteFamily]string{ + RF_IPv4_UC: "ipv4-unicast", + RF_IPv6_UC: "ipv6-unicast", + RF_IPv4_MC: "ipv4-multicast", + RF_IPv6_MC: "ipv6-multicast", + RF_IPv4_MPLS: "ipv4-labelled-unicast", + RF_IPv6_MPLS: "ipv6-labelled-unicast", + RF_IPv4_VPN: "l3vpn-ipv4-unicast", + RF_IPv6_VPN: "l3vpn-ipv6-unicast", + RF_IPv4_VPN_MC: "l3vpn-ipv4-multicast", + RF_IPv6_VPN_MC: "l3vpn-ipv6-multicast", + RF_VPLS: "l2vpn-vpls", + RF_EVPN: "l2vpn-evpn", + RF_RTC_UC: "rtc", + RF_ENCAP: "encap", + RF_FS_IPv4_UC: "ipv4-flowspec", + RF_FS_IPv4_VPN: "l3vpn-ipv4-flowspec", + RF_FS_IPv6_UC: "ipv6-flowspec", + RF_FS_IPv6_VPN: "l3vpn-ipv6-flowspec", +} + +var AddressFamilyValueMap = map[string]RouteFamily{ + AddressFamilyNameMap[RF_IPv4_UC]: RF_IPv4_UC, + AddressFamilyNameMap[RF_IPv6_UC]: RF_IPv6_UC, + AddressFamilyNameMap[RF_IPv4_MC]: RF_IPv4_MC, + AddressFamilyNameMap[RF_IPv6_MC]: RF_IPv6_MC, + AddressFamilyNameMap[RF_IPv4_MPLS]: RF_IPv4_MPLS, + AddressFamilyNameMap[RF_IPv6_MPLS]: RF_IPv6_MPLS, + AddressFamilyNameMap[RF_IPv4_VPN]: RF_IPv4_VPN, + AddressFamilyNameMap[RF_IPv6_VPN]: RF_IPv6_VPN, + AddressFamilyNameMap[RF_IPv4_VPN_MC]: RF_IPv4_VPN_MC, + AddressFamilyNameMap[RF_IPv6_VPN_MC]: RF_IPv6_VPN_MC, + AddressFamilyNameMap[RF_VPLS]: RF_VPLS, + AddressFamilyNameMap[RF_EVPN]: RF_EVPN, + AddressFamilyNameMap[RF_RTC_UC]: RF_RTC_UC, + AddressFamilyNameMap[RF_ENCAP]: RF_ENCAP, + AddressFamilyNameMap[RF_FS_IPv4_UC]: RF_FS_IPv4_UC, + AddressFamilyNameMap[RF_FS_IPv4_VPN]: RF_FS_IPv4_VPN, + AddressFamilyNameMap[RF_FS_IPv6_UC]: RF_FS_IPv6_UC, + AddressFamilyNameMap[RF_FS_IPv6_VPN]: RF_FS_IPv6_VPN, +} + func GetRouteFamily(name string) (RouteFamily, error) { - switch name { - case "ipv4-unicast": - return RF_IPv4_UC, nil - case "ipv6-unicast": - return RF_IPv6_UC, nil - case "ipv4-multicast": - return RF_IPv4_MC, nil - case "ipv6-multicast": - return RF_IPv6_MC, nil - case "ipv4-labelled-unicast": - return RF_IPv4_MPLS, nil - case "ipv6-labelled-unicast": - return RF_IPv6_MPLS, nil - case "l3vpn-ipv4-unicast": - return RF_IPv4_VPN, nil - case "l3vpn-ipv6-unicast": - return RF_IPv6_VPN, nil - case "l3vpn-ipv4-multicast": - return RF_IPv4_VPN_MC, nil - case "l3vpn-ipv6-multicast": - return RF_IPv6_VPN_MC, nil - case "l2vpn-vpls": - return RF_VPLS, nil - case "l2vpn-evpn": - return RF_EVPN, nil - case "rtc": - return RF_RTC_UC, nil - case "encap": - return RF_ENCAP, nil - case "ipv4-flowspec": - return RF_FS_IPv4_UC, nil - case "l3vpn-ipv4-flowspec": - return RF_FS_IPv4_VPN, nil - case "ipv6-flowspec": - return RF_FS_IPv6_UC, nil - case "l3vpn-ipv6-flowspec": - return RF_FS_IPv6_VPN, nil + if v, ok := AddressFamilyValueMap[name]; ok { + return v, nil } return RouteFamily(0), fmt.Errorf("%s isn't a valid route family name", name) } diff --git a/server/grpc_server.go b/server/grpc_server.go index bc0dae4b..85652c75 100644 --- a/server/grpc_server.go +++ b/server/grpc_server.go @@ -154,7 +154,7 @@ func (s *Server) MonitorBestChanged(arg *api.Arguments, stream api.GobgpApi_Moni return fmt.Errorf("unsupported resource type: %v", arg.Resource) } - req := NewGrpcRequest(reqType, "", bgp.RouteFamily(arg.Rf), nil) + req := NewGrpcRequest(reqType, "", bgp.RouteFamily(arg.Family), nil) s.bgpServerCh <- req return handleMultipleResponses(req, func(res *GrpcResponse) error { @@ -174,7 +174,7 @@ func (s *Server) MonitorPeerState(arg *api.Arguments, stream api.GobgpApi_Monito func (s *Server) neighbor(reqType int, arg *api.Arguments) (*api.Error, error) { none := &api.Error{} - req := NewGrpcRequest(reqType, arg.Name, bgp.RouteFamily(arg.Rf), nil) + req := NewGrpcRequest(reqType, arg.Name, bgp.RouteFamily(arg.Family), nil) s.bgpServerCh <- req res := <-req.ResponseCh @@ -253,7 +253,7 @@ func (s *Server) GetMrt(arg *api.MrtArguments, stream api.GobgpApi_GetMrtServer) default: return fmt.Errorf("unsupported resource type: %v", arg.Resource) } - req := NewGrpcRequest(reqType, arg.NeighborAddress, bgp.RouteFamily(arg.Rf), arg.Interval) + req := NewGrpcRequest(reqType, arg.NeighborAddress, bgp.RouteFamily(arg.Family), arg.Interval) s.bgpServerCh <- req return handleMultipleResponses(req, func(res *GrpcResponse) error { return stream.Send(res.Data.(*api.MrtMessage)) @@ -269,7 +269,7 @@ func (s *Server) ModRPKI(ctx context.Context, arg *api.ModRpkiArguments) (*api.E } func (s *Server) GetRPKI(arg *api.Arguments, stream api.GobgpApi_GetRPKIServer) error { - req := NewGrpcRequest(REQ_RPKI, "", bgp.RouteFamily(arg.Rf), nil) + req := NewGrpcRequest(REQ_RPKI, "", bgp.RouteFamily(arg.Family), nil) s.bgpServerCh <- req return handleMultipleResponses(req, func(res *GrpcResponse) error { @@ -278,7 +278,7 @@ func (s *Server) GetRPKI(arg *api.Arguments, stream api.GobgpApi_GetRPKIServer) } func (s *Server) GetROA(arg *api.Arguments, stream api.GobgpApi_GetROAServer) error { - req := NewGrpcRequest(REQ_ROA, arg.Name, bgp.RouteFamily(arg.Rf), nil) + req := NewGrpcRequest(REQ_ROA, arg.Name, bgp.RouteFamily(arg.Family), nil) s.bgpServerCh <- req return handleMultipleResponses(req, func(res *GrpcResponse) error { diff --git a/server/server.go b/server/server.go index 081717fc..8b12b367 100644 --- a/server/server.go +++ b/server/server.go @@ -1865,7 +1865,7 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) (sMsgs []*S log.Infof("Peer %s is added", addr) } SetTcpMD5SigSockopts(listener(net.ParseIP(addr)), addr, arg.Peer.Conf.AuthPassword) - apitoConfig := func(a *api.Peer) config.Neighbor { + apitoConfig := func(a *api.Peer) (config.Neighbor, error) { var pconf config.Neighbor if a.Conf != nil { pconf.NeighborAddress = net.ParseIP(a.Conf.NeighborAddress) @@ -1924,9 +1924,13 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) (sMsgs []*S } } } - if a.Afisafis != nil { - for _, afisafi := range a.Afisafis.Afisafi { - cAfiSafi := config.AfiSafi{AfiSafiName: afisafi.Name} + if a.Families != nil { + for _, family := range a.Families { + name, ok := bgp.AddressFamilyNameMap[bgp.RouteFamily(family)] + if !ok { + return pconf, fmt.Errorf("invalid address family: %d", family) + } + cAfiSafi := config.AfiSafi{AfiSafiName: name} pconf.AfiSafis.AfiSafiList = append(pconf.AfiSafis.AfiSafiList, cAfiSafi) } } else { @@ -1942,9 +1946,12 @@ func (server *BgpServer) handleGrpcModNeighbor(grpcReq *GrpcRequest) (sMsgs []*S pconf.Transport.TransportConfig.LocalAddress = net.ParseIP(a.Transport.LocalAddress) pconf.Transport.TransportConfig.PassiveMode = a.Transport.PassiveMode } - return pconf + return pconf, nil + } + configneigh, err := apitoConfig(arg.Peer) + if err != nil { + return nil, err } - configneigh := apitoConfig(arg.Peer) peer := NewPeer(server.bgpConfig.Global, configneigh, server.globalRib, server.policy) server.setPolicyByConfig(peer.ID(), configneigh.ApplyPolicy) if peer.isRouteServerClient() { diff --git a/table/path.go b/table/path.go index 73b02061..6812a184 100644 --- a/table/path.go +++ b/table/path.go @@ -193,7 +193,7 @@ func (path *Path) IsIBGP() bool { func (path *Path) ToApiStruct(id string) *api.Path { nlri := path.GetNlri() n, _ := nlri.Serialize() - rf := uint32(bgp.AfiSafiToRouteFamily(nlri.AFI(), nlri.SAFI())) + family := uint32(bgp.AfiSafiToRouteFamily(nlri.AFI(), nlri.SAFI())) pattrs := func(arg []bgp.PathAttributeInterface) [][]byte { ret := make([][]byte, 0, len(arg)) for _, a := range arg { @@ -209,7 +209,7 @@ func (path *Path) ToApiStruct(id string) *api.Path { IsWithdraw: path.IsWithdraw, Validation: int32(path.Validation), Filtered: path.Filtered(id) > POLICY_DIRECTION_NONE, - Rf: rf, + Family: family, } } |