Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrizhu committed Sep 25, 2024
1 parent 1081f50 commit b90ba94
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,6 @@ func bgpInit() {
log.Fatal().Err(err).Msg("Failed to start BGP server")
}

s.SetPolicyAssignment(context.Background(), &api.SetPolicyAssignmentRequest{
Assignment: &api.PolicyAssignment{
Name: "global",
Direction: api.PolicyDirection_IMPORT,
DefaultAction: api.RouteAction_REJECT,
},
})

if err := s.WatchEvent(ctx, &api.WatchEventRequest{Peer: &api.WatchEventRequest_Peer{}}, func(r *api.WatchEventResponse) {
if p := r.GetPeer(); p != nil && p.Type == api.WatchEventResponse_PeerEvent_STATE {
log.Debug().
Expand Down Expand Up @@ -136,12 +128,26 @@ func (p *Prefix) bgpAnnounce(site *ConfigSite) {
adminSet = 65535
}

policy := &api.ApplyPolicy{
InPolicy: &api.PolicyAssignment{
Name: "reject",
Direction: api.PolicyDirection_IMPORT,
DefaultAction: api.RouteAction_REJECT,
},
ImportPolicy: &api.PolicyAssignment{
Name: "reject",
Direction: api.PolicyDirection_IMPORT,
DefaultAction: api.RouteAction_REJECT,
},
}

n := &api.Peer{
Conf: &api.PeerConf{
NeighborAddress: site.Neighbor,
PeerAsn: uint32(site.ASN),
Vrf: p.vrfName,
},
ApplyPolicy: policy,
}

if err := s.AddPeer(ctx, &api.AddPeerRequest{
Expand Down

0 comments on commit b90ba94

Please sign in to comment.