Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zapi version 5 #1766

Closed
wants to merge 125 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
1c828f8
Added a fix for sending VRF routes to FRR/Zebra
Jan 9, 2018
c768039
Updated to deal with API change in github.com/satori/go.uuid
Jan 15, 2018
2495917
Revert "Updated to deal with API change in github.com/satori/go.uuid"
Jan 15, 2018
4692ebf
Merge branch 'revert-c768039b' into 'master'
Jan 15, 2018
6183b03
Run 'go fmt'
Jan 24, 2018
a2b485a
Merge branch 'master' of github.com:amanshaikh75/gobgp
Jan 24, 2018
771ccb7
Merge branch 'master' of https://github.com/osrg/gobgp
Jan 24, 2018
845ffed
Merge branch 'master' of github.com:osrg/gobgp
Jan 26, 2018
b55de54
cli: Implement "neighbor update" command
iwaseyusuke Jan 29, 2018
e94387a
zclinet: Enable to request MPLS label range to FRRouting
iwaseyusuke Feb 5, 2018
a0318b6
zclient: Enable to redistribute routes with label
iwaseyusuke Feb 5, 2018
c339fdd
Merge branch 'master' of https://github.com/osrg/gobgp
Feb 5, 2018
794c447
Merge branch 'zclient-Enable_to_request_MPLS_label_range' of https://…
Feb 5, 2018
239bd8b
zclinet: Enable to request MPLS label range to FRRouting
iwaseyusuke Feb 5, 2018
e085697
zclient: Enable to redistribute routes with label
iwaseyusuke Feb 5, 2018
d69d73e
zclient: Allocate MPLS label dynamically
iwaseyusuke Feb 6, 2018
6f27b63
Merge branch 'zclient-Enable_to_request_MPLS_label_range' of https://…
Feb 6, 2018
5a39915
zclinet: Enable to request MPLS label range to FRRouting
iwaseyusuke Feb 5, 2018
52e75e8
Merge branch 'zclient-Enable_to_request_MPLS_label_range' of https://…
Feb 9, 2018
23637b0
Started work on supporting ZAPI version 5
Feb 19, 2018
8c77df5
Added support for version 5 by changing the header format
Feb 19, 2018
966010c
Added support for ZAPI version 5
Feb 19, 2018
b2998d7
Updated version number to 1.28.1
Feb 19, 2018
fba21c8
Added constants/enums for FRR ZAPI 5
Feb 20, 2018
fad7cb0
Updated several parts to deal with ZAPI 5
Feb 20, 2018
16c7041
Updated RouteFamily() to take ZAPI version as input arg
Feb 20, 2018
d1a8a73
Updated to change in function signatures in zapi.go
Feb 21, 2018
b808426
Updated methods to work with ZAPI version 5
Feb 21, 2018
1ed8141
Updated IPRouteBody::DecodeFromBytes() to support ZAPI 5
Feb 21, 2018
6406c65
Updated NexthopLookupBody methods to work with ZAPI 5
Feb 21, 2018
5d8acb8
Added Message.parseFrr5Message() method to parse ZAPI 5 messages
Feb 21, 2018
dac5d59
Added VrfLabelBody and Serialize method for it
Feb 21, 2018
eaf05f9
Extended code for dealing VRF_LABEL message
Feb 22, 2018
364f893
Ran stringer for LSP_TYPE
Feb 22, 2018
af982c1
Added FRR5_VRF_LABEL case in ParseFrr5Message() method
Feb 22, 2018
327ce0d
Added code to send VRF_LABEL message to Zebra when a VRF is added
Feb 22, 2018
f93c815
Changed how function looks up VRF
Feb 22, 2018
0054be8
Added log message
Feb 22, 2018
f68f5f8
Merged branch 'master' of https://github.com/osrg/gobgp into zapi_ver…
Mar 2, 2018
0a5f572
Updated version number
Mar 2, 2018
62a44ae
Merged branch 'master' of https://github.com/osrg/gobgp
Mar 2, 2018
6c0850c
Disable installation of VPNv(4|6) routes into default VRF
Mar 2, 2018
d85b611
Merge remote-tracking branch 'origin/disallow_vpn_routes_in_default_f…
Mar 3, 2018
7435d5f
Define NEXTHOP_TYPE
Mar 14, 2018
a551d7f
Renamed NEXTHOP_FLAG to NEXTHOP_TYPE
Mar 14, 2018
d251eaf
Change comment
Mar 14, 2018
33c229c
Run go generate command
Mar 14, 2018
0a7474c
Added how Zebra decodes next-hop in ZAPI 5
Mar 14, 2018
0518df0
Updated Nexthop structure and serializeNexthops function for ZAPI ver…
Mar 14, 2018
57eba2c
Update Nexthop structure and serializeNexthops function for ZAPI vers…
Mar 14, 2018
0f4eba4
Merge branch 'zapi_version_5' of git@gitlab.research.att.com:ashaikh/…
Mar 14, 2018
609bebb
Start work on modifying next-hop in IPRouteBody
Mar 15, 2018
b9b77fb
Converted Nexthops in IPRouteBody to []*Nexthop
Mar 15, 2018
7456e5a
Convert Nexthops in IPRouteBody to []*Nexthop
Mar 15, 2018
549d679
Update newIPRouteBody to remove compilation errors
Mar 15, 2018
f0184c1
Merge branch 'zapi_version_5' of git@gitlab.research.att.com:ashaikh/…
Mar 15, 2018
ccd0d5f
Separated NEXTHOP_TYPE into NEXTHOP_TYPE and ZAPI_NEXTHOP_TYPE
Mar 19, 2018
dd485ac
Added nextHopToZapiNextHopMap map
Mar 19, 2018
0ab06ed
Added zapiNextHopToNextHopMap map
Mar 19, 2018
9e2329b
Fix initialization of maps
Mar 19, 2018
53618db
Continue updating code that deals with next-hop type
Mar 19, 2018
7f5fe0c
Complete making all changes to next-hop-type
Mar 19, 2018
eab1d47
Add appropriate setting of next-hop type
Mar 19, 2018
bb43273
Add labels to VPN paths
Mar 20, 2018
89262b5
Add debug statement at the end of SendIPRoute function
Mar 20, 2018
078237b
Change debug message
Mar 20, 2018
7863433
Add debug statement in newIPRouteBody for VPNv4 route
Mar 21, 2018
584e92d
Move debug message in newIPRouteBody
Mar 21, 2018
fcda081
Add printstack() in newIPRouteBody()
Mar 21, 2018
8958cbf
Add printstack to notifyBestWatcher()
Mar 21, 2018
e20881b
Add debug message just before calling SendIPRoute
Apr 2, 2018
8f54671
Add debug message
Apr 2, 2018
0edfe2a
Add debug and printstack statements in ToLocal() method
Apr 3, 2018
a8d4a5b
Add debug messages in filterpath
Apr 6, 2018
b373e7b
Change in debug info
Apr 6, 2018
37b6aac
Add VRF info in debug message
Apr 6, 2018
e24e9c8
Add debug message to BgpServer::notifyBestWatcher() method
Apr 19, 2018
e4723e7
Add VRF-ids in log message
Apr 19, 2018
77adc9b
Remove debug.PrintStack()
Apr 19, 2018
686d67b
Add Path to debug message
Apr 19, 2018
724526e
Remove runtime/debug
Apr 19, 2018
93c9cce
Remove PrintStack() call
Apr 19, 2018
b76b979
Change vrfId to uin32 and add receiveVrfId to Path
Apr 20, 2018
0fd5fef
Include receiveVrfId in path.String() method
Apr 20, 2018
e5308bc
Replace i with vrfId
Apr 20, 2018
f9bf52b
Add code to deal with VPN route installation in Zebra
Apr 23, 2018
ce279f3
Use of FRR5_ROUTE_ADD and DELETE for both IPv4 and v6
Apr 24, 2018
ed4ebac
Add AFI in IP route body
Apr 24, 2018
94a9dbc
Add Unix socket address family
Apr 24, 2018
1c32fd1
Add several debug statements to notifyBestWatcher()
Apr 25, 2018
34e71bd
Add debug message
Apr 25, 2018
7194dd5
Fix bug in serialize()
Apr 25, 2018
a5afedf
Minor changes
Apr 25, 2018
ed02b5c
Add debug messages in serializeNexthops() method
Apr 26, 2018
a3d3ab5
Add debug messages
Apr 26, 2018
6bc1cd8
Add buf to debug message
Apr 26, 2018
f11bb15
Add buf length debug mesg
Apr 26, 2018
9d05bd6
Make minor change
Apr 26, 2018
3e2b8fe
Bug fix
Apr 26, 2018
da4e313
Bug fix
Apr 26, 2018
95ef84f
Add debug messages
Apr 26, 2018
5769f15
Add debug message
Apr 26, 2018
a9f1741
Fix bug related to setting of label flag in message flag
Apr 27, 2018
91544fc
Change metric flag from Quagga to FRR ZAPI 5
Apr 27, 2018
ac759d6
Fix how label is encoded
Apr 27, 2018
3e22109
Fix how label is encoded
Apr 27, 2018
79b2a07
Add debug message
Apr 27, 2018
985e07a
Change how label is encoded
Apr 27, 2018
1190cb3
Change in how label is encoded
Apr 27, 2018
3e1dbc9
Change in label encoding
Apr 27, 2018
53f45ef
Change label encoding
Apr 27, 2018
0bdc58b
Change how label is encoded.
Apr 27, 2018
5cb0758
Add debug message for label encoding
Apr 27, 2018
83dfc0e
Add debug statement
Apr 27, 2018
57aadb2
Change label encoding
Apr 27, 2018
ed85d60
Change encoding of label
Apr 27, 2018
669561f
Change encoding of label
Apr 27, 2018
b94b7df
Change encoding of label
Apr 27, 2018
b71d1a2
Change in label encoding
Apr 27, 2018
a7b8439
Add FRR5_CAPABILITIES in Zebra command types
May 1, 2018
dec6801
Add debug messages
May 1, 2018
19f14e0
Add debug messages
May 1, 2018
576c840
Merge branch 'master' of https://github.com/osrg/gobgp
May 3, 2018
97bac55
Merge branch 'master' into zapi_version_5
May 3, 2018
be5d8fc
Fix compilation problem
May 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.31
1.31.1
1,349 changes: 718 additions & 631 deletions api/gobgp.pb.go

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions api/gobgp.proto
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ service GobgpApi {
rpc GetServer(GetServerRequest) returns (GetServerResponse) {}
rpc AddNeighbor(AddNeighborRequest) returns (AddNeighborResponse) {}
rpc DeleteNeighbor(DeleteNeighborRequest) returns (DeleteNeighborResponse) {}
rpc UpdateNeighbor(UpdateNeighborRequest) returns (UpdateNeighborResponse) {}
rpc GetNeighbor(GetNeighborRequest) returns (GetNeighborResponse) {}
rpc ResetNeighbor(ResetNeighborRequest) returns (ResetNeighborResponse) {}
rpc SoftResetNeighbor(SoftResetNeighborRequest) returns (SoftResetNeighborResponse) {}
Expand Down Expand Up @@ -157,6 +158,20 @@ message DeleteNeighborRequest {
message DeleteNeighborResponse {
}

message UpdateNeighborRequest {
Peer peer = 1;
// Calls SoftResetIn after updating the neighbor configuration if needed.
bool do_soft_reset_in = 2;
}

message UpdateNeighborResponse {
// Indicates whether calling SoftResetIn is required due to this update. If
// "true" is set, the client should call SoftResetIn manually. If
// "do_soft_reset_in = true" is set in the request, always returned with
// "false".
bool needs_soft_reset_in = 1;
}

message ResetNeighborRequest {
string address = 1;
string communication = 2;
Expand Down
15 changes: 15 additions & 0 deletions api/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1343,6 +1343,21 @@ func (s *Server) DeleteNeighbor(ctx context.Context, arg *DeleteNeighborRequest)
}})
}

func (s *Server) UpdateNeighbor(ctx context.Context, arg *UpdateNeighborRequest) (*UpdateNeighborResponse, error) {
c, err := NewNeighborFromAPIStruct(arg.Peer)
if err != nil {
return nil, err
}
needsSoftResetIn, err := s.bgpServer.UpdateNeighbor(c)
if err != nil {
return nil, err
}
if arg.DoSoftResetIn && needsSoftResetIn {
return &UpdateNeighborResponse{NeedsSoftResetIn: false}, s.bgpServer.SoftResetIn("", bgp.RouteFamily(0))
}
return &UpdateNeighborResponse{NeedsSoftResetIn: needsSoftResetIn}, nil
}

func NewPrefixFromApiStruct(a *Prefix) (*table.Prefix, error) {
_, prefix, err := net.ParseCIDR(a.IpPrefix)
if err != nil {
Expand Down
7 changes: 5 additions & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,11 @@ func (cli *Client) DeleteNeighbor(c *config.Neighbor) error {
return err
}

//func (cli *Client) UpdateNeighbor(c *config.Neighbor) (bool, error) {
//}
func (cli *Client) UpdateNeighbor(c *config.Neighbor, doSoftResetIn bool) (bool, error) {
peer := api.NewPeerFromConfigStruct(c)
response, err := cli.cli.UpdateNeighbor(context.Background(), &api.UpdateNeighborRequest{Peer: peer, DoSoftResetIn: doSoftResetIn})
return response.NeedsSoftResetIn, err
}

func (cli *Client) ShutdownNeighbor(addr, communication string) error {
_, err := cli.cli.ShutdownNeighbor(context.Background(), &api.ShutdownNeighborRequest{Address: addr, Communication: communication})
Expand Down
17 changes: 15 additions & 2 deletions config/bgp_configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1116,13 +1116,18 @@ type ZebraState struct {
// original -> gobgp:redistribute-route-type
RedistributeRouteTypeList []InstallProtocolType `mapstructure:"redistribute-route-type-list" json:"redistribute-route-type-list,omitempty"`
// original -> gobgp:version
// Configure version of zebra protocol. Default is 2. Supported up to 3.
// Configure version of zebra protocol. Default is 2.
// Supported version are 2 or 3 for Quagga and 4 for FRRouting.
Version uint8 `mapstructure:"version" json:"version,omitempty"`
// original -> gobgp:nexthop-trigger-enable
// gobgp:nexthop-trigger-enable's original type is boolean.
NexthopTriggerEnable bool `mapstructure:"nexthop-trigger-enable" json:"nexthop-trigger-enable,omitempty"`
// original -> gobgp:nexthop-trigger-delay
NexthopTriggerDelay uint8 `mapstructure:"nexthop-trigger-delay" json:"nexthop-trigger-delay,omitempty"`
// original -> gobgp:mpls-label-range-size
// Configure MPLS label range size which will be requested to
// FRR/Zebra.
MplsLabelRangeSize uint32 `mapstructure:"mpls-label-range-size" json:"mpls-label-range-size,omitempty"`
}

// struct for container gobgp:config.
Expand All @@ -1137,13 +1142,18 @@ type ZebraConfig struct {
// original -> gobgp:redistribute-route-type
RedistributeRouteTypeList []InstallProtocolType `mapstructure:"redistribute-route-type-list" json:"redistribute-route-type-list,omitempty"`
// original -> gobgp:version
// Configure version of zebra protocol. Default is 2. Supported up to 3.
// Configure version of zebra protocol. Default is 2.
// Supported version are 2 or 3 for Quagga and 4 for FRRouting.
Version uint8 `mapstructure:"version" json:"version,omitempty"`
// original -> gobgp:nexthop-trigger-enable
// gobgp:nexthop-trigger-enable's original type is boolean.
NexthopTriggerEnable bool `mapstructure:"nexthop-trigger-enable" json:"nexthop-trigger-enable,omitempty"`
// original -> gobgp:nexthop-trigger-delay
NexthopTriggerDelay uint8 `mapstructure:"nexthop-trigger-delay" json:"nexthop-trigger-delay,omitempty"`
// original -> gobgp:mpls-label-range-size
// Configure MPLS label range size which will be requested to
// FRR/Zebra.
MplsLabelRangeSize uint32 `mapstructure:"mpls-label-range-size" json:"mpls-label-range-size,omitempty"`
}

func (lhs *ZebraConfig) Equal(rhs *ZebraConfig) bool {
Expand Down Expand Up @@ -1173,6 +1183,9 @@ func (lhs *ZebraConfig) Equal(rhs *ZebraConfig) bool {
if lhs.NexthopTriggerDelay != rhs.NexthopTriggerDelay {
return false
}
if lhs.MplsLabelRangeSize != rhs.MplsLabelRangeSize {
return false
}
return true
}

Expand Down
4 changes: 2 additions & 2 deletions config/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ func setDefaultConfigValuesWithViper(v *viper.Viper, b *BgpConfigSet) error {
}
if b.Zebra.Config.Version < 2 {
b.Zebra.Config.Version = 2
} else if b.Zebra.Config.Version > 4 {
b.Zebra.Config.Version = 4
} else if b.Zebra.Config.Version > 5 {
b.Zebra.Config.Version = 5
}
if !v.IsSet("zebra.config.nexthop-trigger-enable") && !b.Zebra.Config.NexthopTriggerEnable && b.Zebra.Config.Version > 2 {
b.Zebra.Config.NexthopTriggerEnable = true
Expand Down
89 changes: 58 additions & 31 deletions gobgp/cmd/neighbor.go
Original file line number Diff line number Diff line change
Expand Up @@ -987,53 +987,82 @@ func modNeighbor(cmdType string, args []string) error {
params["replace-peer-as"] = PARAM_FLAG
usage += " as <VALUE> [ family <address-families-list> | vrf <vrf-name> | route-reflector-client [<cluster-id>] | route-server-client | allow-own-as <num> | remove-private-as (all|replace) | replace-peer-as ]"
}

m, err := extractReserved(args, params)
if err != nil || (len(m[""]) != 1 && len(m["interface"]) != 1) {
return fmt.Errorf("%s", usage)
}

unnumbered := len(m["interface"]) > 0
if !unnumbered {
if _, err := net.ResolveIPAddr("ip", m[""][0]); err != nil {
return err
}
}

getConf := func(asn uint32) (*config.Neighbor, error) {
peer := &config.Neighbor{
Config: config.NeighborConfig{
PeerAs: asn,
},
}
getNeighborAddress := func() (string, error) {
if unnumbered {
peer.Config.NeighborInterface = m["interface"][0]
addr, err := config.GetIPv6LinkLocalNeighborAddress(peer.Config.NeighborInterface)
return config.GetIPv6LinkLocalNeighborAddress(m["interface"][0])
}
return m[""][0], nil
}

getNeighborConfig := func() (*config.Neighbor, error) {
var peer *config.Neighbor
switch cmdType {
case CMD_ADD, CMD_DEL:
peer = &config.Neighbor{}
addr, err := getNeighborAddress()
if err != nil {
return nil, err
}
if unnumbered {
peer.Config.NeighborInterface = m["interface"][0]
} else {
peer.Config.NeighborAddress = addr
}
peer.State.NeighborAddress = addr
} else {
peer.Config.NeighborAddress = m[""][0]
peer.State.NeighborAddress = m[""][0]
case CMD_UPDATE:
addr, err := getNeighborAddress()
if err != nil {
return nil, err
}
peer, err = client.GetNeighbor(addr)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("invalid command: %s", cmdType)
}
return peer, nil
}

updateNeighborConfig := func(peer *config.Neighbor) error {
if len(m["as"]) > 0 {
as, err := strconv.ParseUint(m["as"][0], 10, 32)
if err != nil {
return err
}
peer.Config.PeerAs = uint32(as)
}
if len(m["family"]) == 1 {
peer.AfiSafis = make([]config.AfiSafi, 0) // for the case of CMD_UPDATE
for _, family := range strings.Split(m["family"][0], ",") {
afiSafiName := config.AfiSafiType(family)
if afiSafiName.ToInt() == -1 {
return nil, fmt.Errorf("invalid family value: %s", family)
return fmt.Errorf("invalid family value: %s", family)
}
peer.AfiSafis = append(peer.AfiSafis, config.AfiSafi{Config: config.AfiSafiConfig{AfiSafiName: afiSafiName}})
}
}
if len(m["vrf"]) == 1 {
peer.Config.Vrf = m["vrf"][0]
}
if rr, ok := m["route-reflector-client"]; ok {
if option, ok := m["route-reflector-client"]; ok {
peer.RouteReflector.Config = config.RouteReflectorConfig{
RouteReflectorClient: true,
}
if len(rr) == 1 {
peer.RouteReflector.Config.RouteReflectorClusterId = config.RrClusterIdType(rr[0])
if len(option) == 1 {
peer.RouteReflector.Config.RouteReflectorClusterId = config.RrClusterIdType(option[0])
}
}
if _, ok := m["route-server-client"]; ok {
Expand All @@ -1044,7 +1073,7 @@ func modNeighbor(cmdType string, args []string) error {
if option, ok := m["allow-own-as"]; ok {
as, err := strconv.ParseUint(option[0], 10, 8)
if err != nil {
return nil, err
return err
}
peer.AsPathOptions.Config.AllowOwnAs = uint8(as)
}
Expand All @@ -1055,36 +1084,34 @@ func modNeighbor(cmdType string, args []string) error {
case "replace":
peer.Config.RemovePrivateAs = config.REMOVE_PRIVATE_AS_OPTION_REPLACE
default:
return nil, fmt.Errorf("invalid remove-private-as value: all or replace")
return fmt.Errorf("invalid remove-private-as value: all or replace")
}
}
if _, ok := m["replace-peer-as"]; ok {
peer.AsPathOptions.Config.ReplacePeerAs = true
}
return peer, nil
}

var as uint64
if len(m["as"]) > 0 {
var err error
if as, err = strconv.ParseUint(m["as"][0], 10, 32); err != nil {
return err
}
return nil
}

n, err := getConf(uint32(as))
n, err := getNeighborConfig()
if err != nil {
return err
}

switch cmdType {
case CMD_ADD:
if len(m[""]) > 0 && len(m["as"]) != 1 {
return fmt.Errorf("%s", usage)
if err := updateNeighborConfig(n); err != nil {
return err
}
return client.AddNeighbor(n)
case CMD_DEL:
return client.DeleteNeighbor(n)
case CMD_UPDATE:
if err := updateNeighborConfig(n); err != nil {
return err
}
_, err := client.UpdateNeighbor(n, true)
return err
}
return nil
}
Expand Down Expand Up @@ -1220,7 +1247,7 @@ func NewNeighborCmd() *cobra.Command {
},
}

for _, v := range []string{CMD_ADD, CMD_DEL} {
for _, v := range []string{CMD_ADD, CMD_DEL, CMD_UPDATE} {
cmd := &cobra.Command{
Use: v,
Run: func(c *cobra.Command, args []string) {
Expand Down
33 changes: 32 additions & 1 deletion server/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,24 +363,50 @@ func (peer *Peer) filterpath(path, old *table.Path) *table.Path {
} else {
return nil
}
log.WithFields(log.Fields{
"Topic": "Path",
"Path": path,
"Peer": peer.ID(),
"Vrf": peer.fsm.pConf.Config.Vrf,
}).Debug("Peer.filterpath(): localized path for VRF")
}

// replace-peer-as handling
if path != nil && !path.IsWithdraw && peer.fsm.pConf.AsPathOptions.State.ReplacePeerAs {
path = path.ReplaceAS(peer.fsm.pConf.Config.LocalAs, peer.fsm.pConf.Config.PeerAs)
log.WithFields(log.Fields{
"Topic": "Path",
"Path": path,
"Peer": peer.ID(),
}).Debug("Peer.filterpath(): after calling ReplaceAS()")
}

if path = filterpath(peer, path, old); path == nil {
return nil
}
log.WithFields(log.Fields{
"Topic": "Path",
"Path": path,
"Peer": peer.ID(),
}).Debug("Peer.filterpath(): after calling filterpath()")

path = table.UpdatePathAttrs(peer.fsm.gConf, peer.fsm.pConf, peer.fsm.peerInfo, path)
log.WithFields(log.Fields{
"Topic": "Path",
"Path": path,
"Peer": peer.ID(),
}).Debug("Peer.filterpath(): after calling UpdatePathAttrs()")

options := &table.PolicyOptions{
Info: peer.fsm.peerInfo,
}
path = peer.policy.ApplyPolicy(peer.TableID(), table.POLICY_DIRECTION_EXPORT, path, options)
// When 'path' is filtered (path == nil), check 'old' has been sent to this peer.
log.WithFields(log.Fields{
"Topic": "Path",
"Path": path,
"Peer": peer.ID(),
}).Debug("Peer.filterpath(): after calling ApplyPolicy()")
// When 'path' is filetered (path == nil), check 'old' has been sent to this peer.
// If it has, send withdrawal to the peer.
if path == nil && old != nil {
o := peer.policy.ApplyPolicy(peer.TableID(), table.POLICY_DIRECTION_EXPORT, old, options)
Expand Down Expand Up @@ -409,6 +435,11 @@ func (peer *Peer) filterpath(path, old *table.Path) *table.Path {
if path != nil && !peer.isIBGPPeer() && !peer.isRouteServerClient() {
path.RemoveLocalPref()
}
log.WithFields(log.Fields{
"Topic": "Path",
"Path": path,
"Peer": peer.ID(),
}).Debugf("Peer.filterpath(): exit after removing local-pref")
return path
}

Expand Down
Loading