Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func bgppublish(s *gobgp.BgpServer,typ string, ip string, nexthop string){
- nlri, _ := ptypes.MarshalAny(&api.IPAddressPrefix{
- Prefix: ip,
- PrefixLen: 32,
- })
- a1, _ := ptypes.MarshalAny(&api.OriginAttribute{
- Origin: 0,
- })
- a2, _ := ptypes.MarshalAny(&api.NextHopAttribute{
- NextHop: nexthop,
- })
- c, _ := ptypes.MarshalAny(&api.CommunitiesAttribute{
- Communities: []uint32{stringToCommunityValue("11111:11111")}, // real value is different
- })
- attrs := []*any.Any{a1,a2,c}
- path := &api.Path{
- Family: &api.Family{Afi: api.Family_AFI_IP, Safi: api.Family_SAFI_UNICAST},
- Nlri: nlri,
- Pattrs: attrs,
- NoImplicitWithdraw: true,
- }
- if typ == "ANNOUNCE" {
- _, err := s.AddPath(context.Background(), &api.AddPathRequest{
- Path: path,
- })
- if err != nil {
- log.Fatal(err)
- }
- } else if typ == "DEANNOUNCE" {
- err := s.DeletePath(context.Background(), &api.DeletePathRequest{
- Path: path,
- })
- if err != nil {
- log.Fatal(err)
- }
- }
- }
- func main() {
- bgppublish(bgpserver,"ANNOUNCE","1.1.1.1","2.2.2.2")
- bgppublish(bgpserver,"ANNOUNCE","1.1.1.1","3.3.3.3")
- bgppublish(bgpserver,"DEANNOUNCE","1.1.1.1","2.2.2.2")
- time.Sleep(time.Minute * 3)
- }
- INFO[0000] Add a peer configuration for:x.x.x.x Topic=Peer
- DEBU[0000] IdleHoldTimer expired Duration=0 Key=x.x.x.x Topic=Peer
- DEBU[0000] state changed Key=x.x.x.x Topic=Peer new=BGP_FSM_ACTIVE old=BGP_FSM_IDLE reason=idle-hold-timer-expired
- DEBU[0005] try to connect Key=x.x.x.x Topic=Peer
- DEBU[0005] state changed Key=x.x.x.x Topic=Peer new=BGP_FSM_OPENSENT old=BGP_FSM_ACTIVE reason=new-connection
- DEBU[0005] state changed Key=x.x.x.x Topic=Peer new=BGP_FSM_OPENCONFIRM old=BGP_FSM_OPENSENT reason=open-msg-received
- INFO[0005] Peer Up Key=x.x.x.x State=BGP_FSM_OPENCONFIRM Topic=Peer
- DEBU[0005] state changed Key=x.x.x.x Topic=Peer new=BGP_FSM_ESTABLISHED old=BGP_FSM_OPENCONFIRM reason=open-msg-negotiated
- INFO[0005] conf:<local_as:11111111 neighbor_address:"x.x.x.x" peer_as:111111111 > state:<local_as:11111111 neighbor_address:"x.x.x.x" peer_as:111111111 session_state:ESTABLISHED router_id:"85.10.249.230" > transport:<local_address:"x.x.x.x" local_port:32809 remote_port:179 >
- DEBU[0010] create Destination Nlri=1.1.1.1/32 Topic=Table
- DEBU[0010] computeKnownBestPath knownPathList: 1 Topic=Table
- DEBU[0010] computeKnownBestPath knownPathList: 2 Topic=Table
- DEBU[0010] enter compareByReachableNexthop -- path1: { 1.1.1.1/32 | src: local, nh: 2.2.2.2 }, path2: { 1.1.1.1/32 | src: local, nh: 3.3.3.3 } Topic=Table
- DEBU[0010] enter compareByHighestWeight -- path1: { 1.1.1.1/32 | src: local, nh: 2.2.2.2 }, path2: { 1.1.1.1/32 | src: local, nh: 3.3.3.3 } Topic=Table
- DEBU[0010] enter compareByLocalPref Topic=Table
- DEBU[0010] enter compareByLocalOrigin Topic=Table
- DEBU[0010] enter compareByASPath Topic=Table
- DEBU[0010] compareByASPath -- l1: 0, l2: 0 Topic=Table
- DEBU[0010] enter compareByOrigin Topic=Table
- DEBU[0010] compareByOrigin -- origin1: 0, origin2: 0 Topic=Table
- DEBU[0010] enter compareByMED Topic=Table
- DEBU[0010] compareByMED -- med1: 0, med2: 0 Topic=Table
- DEBU[0010] enter compareByASNumber Topic=Table
- DEBU[0010] compareByASNumber -- p1Asn: 0, p2Asn: 0 Topic=Table
- DEBU[0010] sent update Key=x.x.x.x State=BGP_FSM_ESTABLISHED Topic=Peer attributes="[{Origin: i} 11111111 {Nexthop: 3.3.3.3} {Communities: 11111:11111}]" nlri="[1.1.1.1/32]" withdrawals="[]"
- DEBU[0010] enter compareByIGPCost -- path1: { 1.1.1.1/32 | src: local, nh: 2.2.2.2 }, path2: { 1.1.1.1/32 | src: local, nh: 3.3.3.3 } Topic=Table
- DEBU[0010] enter compareByRouterID Topic=Table
- DEBU[0010] Removing withdrawals Key=1.1.1.1/32 Topic=Table
- DEBU[0010] computeKnownBestPath knownPathList: 1 Topic=Table
- DEBU[0010] sent update Key=x.x.x.x State=BGP_FSM_ESTABLISHED Topic=Peer attributes="[{Origin: i} 11111111 {Nexthop: 2.2.2.2} {Communities: 11111:11111}]" nlri="[1.1.1.1/32]" withdrawals="[]"
- DEBU[0035] sent Key=x.x.x.x State=BGP_FSM_ESTABLISHED Topic=Peer data="&{{[] 19 4} 0x13dc758}"
- DEBU[0065] sent Key=x.x.x.x State=BGP_FSM_ESTABLISHED Topic=Peer data="&{{[] 19 4} 0x13dc758}"
- DEBU[0095] sent Key=x.x.x.x State=BGP_FSM_ESTABLISHED Topic=Peer data="&{{[] 19 4} 0x13dc758}"
- DEBU[0125] sent Key=x.x.x.x State=BGP_FSM_ESTABLISHED Topic=Peer data="&{{[] 19 4} 0x13dc758}"
- DEBU[0155] sent Key=x.x.x.x State=BGP_FSM_ESTABLISHED Topic=Peer data="&{{[] 19 4} 0x13dc758}"
- DEBU[0185] sent Key=x.x.x.x State=BGP_FSM_ESTABLISHED Topic=Peer data="&{{[] 19 4} 0x13dc758}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement