From b90ba940a655cad1bffabec36e1d15ed7fb48dac Mon Sep 17 00:00:00 2001 From: Ezri Zhu Date: Wed, 25 Sep 2024 19:51:21 -0400 Subject: [PATCH] fix --- bgp.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/bgp.go b/bgp.go index 416f3db..5280326 100644 --- a/bgp.go +++ b/bgp.go @@ -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(). @@ -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{