1 /* BGP packet management routine.
2 Copyright (C) 1999 Kunihiro Ishiguro
4 This file is part of GNU Zebra.
6 GNU Zebra is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GNU Zebra is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Zebra; see the file COPYING. If not, write to the Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
30 #include "sockunion.h" /* for inet_ntop () */
34 #include "bgpd/bgpd.h"
35 #include "bgpd/bgp_table.h"
36 #include "bgpd/bgp_dump.h"
37 #include "bgpd/bgp_attr.h"
38 #include "bgpd/bgp_debug.h"
39 #include "bgpd/bgp_fsm.h"
40 #include "bgpd/bgp_route.h"
41 #include "bgpd/bgp_packet.h"
42 #include "bgpd/bgp_open.h"
43 #include "bgpd/bgp_aspath.h"
44 #include "bgpd/bgp_community.h"
45 #include "bgpd/bgp_ecommunity.h"
46 #include "bgpd/bgp_network.h"
47 #include "bgpd/bgp_mplsvpn.h"
48 #include "bgpd/bgp_advertise.h"
50 int stream_put_prefix (struct stream
*, struct prefix
*);
52 /* Set up BGP packet marker and packet type. */
54 bgp_packet_set_marker (struct stream
*s
, u_char type
)
59 for (i
= 0; i
< BGP_MARKER_SIZE
; i
++)
60 stream_putc (s
, 0xff);
62 /* Dummy total length. This field is should be filled in later on. */
65 /* BGP packet type. */
66 stream_putc (s
, type
);
68 /* Return current stream size. */
69 return stream_get_putp (s
);
72 /* Set BGP packet header size entry. If size is zero then use current
75 bgp_packet_set_size (struct stream
*s
)
79 /* Preserve current pointer. */
80 cp
= stream_get_putp (s
);
81 stream_set_putp (s
, BGP_MARKER_SIZE
);
84 /* Write back current pointer. */
85 stream_set_putp (s
, cp
);
90 /* Add new packet to the peer. */
92 bgp_packet_add (struct peer
*peer
, struct stream
*s
)
94 /* Add packet to the end of list. */
95 stream_fifo_push (peer
->obuf
, s
);
98 /* Free first packet. */
100 bgp_packet_delete (struct peer
*peer
)
102 stream_free (stream_fifo_pop (peer
->obuf
));
105 /* Duplicate packet. */
107 bgp_packet_dup (struct stream
*s
)
111 new = stream_new (stream_get_endp (s
));
117 memcpy (new->data
, s
->data
, stream_get_endp (s
));
122 /* Check file descriptor whether connect is established. */
124 bgp_connect_check (struct peer
*peer
)
130 /* Anyway I have to reset read and write thread. */
131 BGP_READ_OFF (peer
->t_read
);
132 BGP_WRITE_OFF (peer
->t_write
);
134 /* Check file descriptor. */
135 slen
= sizeof (status
);
136 ret
= getsockopt(peer
->fd
, SOL_SOCKET
, SO_ERROR
, (void *) &status
, &slen
);
138 /* If getsockopt is fail, this is fatal error. */
141 zlog (peer
->log
, LOG_INFO
, "can't get sockopt for nonblocking connect");
142 BGP_EVENT_ADD (peer
, TCP_fatal_error
);
146 /* When status is 0 then TCP connection is established. */
149 BGP_EVENT_ADD (peer
, TCP_connection_open
);
153 if (BGP_DEBUG (events
, EVENTS
))
154 plog_info (peer
->log
, "%s [Event] Connect failed (%s)",
155 peer
->host
, strerror (errno
));
156 BGP_EVENT_ADD (peer
, TCP_connection_open_failed
);
160 /* Make BGP update packet. */
162 bgp_update_packet (struct peer
*peer
, afi_t afi
, safi_t safi
)
165 struct bgp_adj_out
*adj
;
166 struct bgp_advertise
*adv
;
167 struct stream
*packet
;
168 struct bgp_node
*rn
= NULL
;
169 struct bgp_info
*binfo
= NULL
;
170 bgp_size_t total_attr_len
= 0;
173 struct prefix_rd
*prd
= NULL
;
179 adv
= FIFO_HEAD (&peer
->sync
[afi
][safi
]->update
);
190 prd
= (struct prefix_rd
*) &rn
->prn
->p
;
193 #endif /* MPLS_VPN */
195 /* When remaining space can't include NLRI and it's length. */
196 if (rn
&& STREAM_REMAIN (s
) <= BGP_NLRI_LENGTH
+ PSIZE (rn
->p
.prefixlen
))
199 /* If packet is empty, set attribute. */
200 if (stream_empty (s
))
202 bgp_packet_set_marker (s
, BGP_MSG_UPDATE
);
204 pos
= stream_get_putp (s
);
206 total_attr_len
= bgp_packet_attribute (NULL
, peer
, s
,
209 binfo
->peer
, prd
, tag
);
210 stream_putw_at (s
, pos
, total_attr_len
);
213 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
214 stream_put_prefix (s
, &rn
->p
);
216 if (BGP_DEBUG (update
, UPDATE_OUT
))
217 zlog (peer
->log
, LOG_INFO
, "%s send UPDATE %s/%d",
219 inet_ntop (rn
->p
.family
, &(rn
->p
.u
.prefix
), buf
, BUFSIZ
),
222 /* Synchnorize attribute. */
224 bgp_attr_unintern (adj
->attr
);
226 peer
->scount
[afi
][safi
]++;
228 adj
->attr
= bgp_attr_intern (adv
->baa
->attr
);
230 adv
= bgp_advertise_clean (peer
, adj
, afi
, safi
);
232 if (! (afi
== AFI_IP
&& safi
== SAFI_UNICAST
))
236 if (! stream_empty (s
))
238 bgp_packet_set_size (s
);
239 packet
= bgp_packet_dup (s
);
240 bgp_packet_add (peer
, packet
);
241 BGP_WRITE_ON (peer
->t_write
, bgp_write
, peer
->fd
);
249 /* Make BGP withdraw packet. */
251 bgp_withdraw_packet (struct peer
*peer
, afi_t afi
, safi_t safi
)
254 struct stream
*packet
;
255 struct bgp_adj_out
*adj
;
256 struct bgp_advertise
*adv
;
259 bgp_size_t unfeasible_len
;
260 bgp_size_t total_attr_len
;
262 struct prefix_rd
*prd
= NULL
;
267 while ((adv
= FIFO_HEAD (&peer
->sync
[afi
][safi
]->withdraw
)) != NULL
)
272 prd
= (struct prefix_rd
*) &rn
->prn
->p
;
273 #endif /* MPLS_VPN */
275 if (STREAM_REMAIN (s
)
276 < (BGP_NLRI_LENGTH
+ BGP_TOTAL_ATTR_LEN
+ PSIZE (rn
->p
.prefixlen
)))
279 if (stream_empty (s
))
281 bgp_packet_set_marker (s
, BGP_MSG_UPDATE
);
285 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
286 stream_put_prefix (s
, &rn
->p
);
289 pos
= stream_get_putp (s
);
292 = bgp_packet_withdraw (peer
, s
, &rn
->p
, afi
, safi
, prd
, NULL
);
294 /* Set total path attribute length. */
295 stream_putw_at (s
, pos
, total_attr_len
);
298 if (BGP_DEBUG (update
, UPDATE_OUT
))
299 zlog (peer
->log
, LOG_INFO
, "%s send UPDATE %s/%d -- unreachable",
301 inet_ntop (rn
->p
.family
, &(rn
->p
.u
.prefix
), buf
, BUFSIZ
),
304 peer
->scount
[afi
][safi
]--;
306 bgp_adj_out_remove (rn
, adj
, peer
, afi
, safi
);
307 bgp_unlock_node (rn
);
309 if (! (afi
== AFI_IP
&& safi
== SAFI_UNICAST
))
313 if (! stream_empty (s
))
315 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
318 = stream_get_putp (s
) - BGP_HEADER_SIZE
- BGP_UNFEASIBLE_LEN
;
319 stream_putw_at (s
, BGP_HEADER_SIZE
, unfeasible_len
);
322 bgp_packet_set_size (s
);
323 packet
= bgp_packet_dup (s
);
324 bgp_packet_add (peer
, packet
);
333 bgp_default_update_send (struct peer
*peer
, struct attr
*attr
,
334 afi_t afi
, safi_t safi
, struct peer
*from
)
337 struct stream
*packet
;
340 bgp_size_t total_attr_len
;
341 char attrstr
[BUFSIZ
];
344 #ifdef DISABLE_BGP_ANNOUNCE
346 #endif /* DISABLE_BGP_ANNOUNCE */
349 str2prefix ("0.0.0.0/0", &p
);
352 str2prefix ("::/0", &p
);
353 #endif /* HAVE_IPV6 */
355 /* Logging the attribute. */
356 if (BGP_DEBUG (update
, UPDATE_OUT
))
358 bgp_dump_attr (peer
, attr
, attrstr
, BUFSIZ
);
359 zlog (peer
->log
, LOG_INFO
, "%s send UPDATE %s/%d %s",
360 peer
->host
, inet_ntop(p
.family
, &(p
.u
.prefix
), buf
, BUFSIZ
),
361 p
.prefixlen
, attrstr
);
364 s
= stream_new (BGP_MAX_PACKET_SIZE
);
366 /* Make BGP update packet. */
367 bgp_packet_set_marker (s
, BGP_MSG_UPDATE
);
369 /* Unfeasible Routes Length. */
372 /* Make place for total attribute length. */
373 pos
= stream_get_putp (s
);
375 total_attr_len
= bgp_packet_attribute (NULL
, peer
, s
, attr
, &p
, afi
, safi
, from
, NULL
, NULL
);
377 /* Set Total Path Attribute Length. */
378 stream_putw_at (s
, pos
, total_attr_len
);
381 if (p
.family
== AF_INET
&& safi
== SAFI_UNICAST
)
382 stream_put_prefix (s
, &p
);
385 bgp_packet_set_size (s
);
387 packet
= bgp_packet_dup (s
);
390 /* Dump packet if debug option is set. */
392 bgp_packet_dump (packet
);
395 /* Add packet to the peer. */
396 bgp_packet_add (peer
, packet
);
398 BGP_WRITE_ON (peer
->t_write
, bgp_write
, peer
->fd
);
402 bgp_default_withdraw_send (struct peer
*peer
, afi_t afi
, safi_t safi
)
405 struct stream
*packet
;
409 bgp_size_t unfeasible_len
;
410 bgp_size_t total_attr_len
;
413 #ifdef DISABLE_BGP_ANNOUNCE
415 #endif /* DISABLE_BGP_ANNOUNCE */
418 str2prefix ("0.0.0.0/0", &p
);
421 str2prefix ("::/0", &p
);
422 #endif /* HAVE_IPV6 */
427 if (BGP_DEBUG (update
, UPDATE_OUT
))
428 zlog (peer
->log
, LOG_INFO
, "%s send UPDATE %s/%d -- unreachable",
429 peer
->host
, inet_ntop(p
.family
, &(p
.u
.prefix
), buf
, BUFSIZ
),
432 s
= stream_new (BGP_MAX_PACKET_SIZE
);
434 /* Make BGP update packet. */
435 bgp_packet_set_marker (s
, BGP_MSG_UPDATE
);
437 /* Unfeasible Routes Length. */;
438 cp
= stream_get_putp (s
);
441 /* Withdrawn Routes. */
442 if (p
.family
== AF_INET
&& safi
== SAFI_UNICAST
)
444 stream_put_prefix (s
, &p
);
446 unfeasible_len
= stream_get_putp (s
) - cp
- 2;
448 /* Set unfeasible len. */
449 stream_putw_at (s
, cp
, unfeasible_len
);
451 /* Set total path attribute length. */
456 pos
= stream_get_putp (s
);
458 total_attr_len
= bgp_packet_withdraw (peer
, s
, &p
, afi
, safi
, NULL
, NULL
);
460 /* Set total path attribute length. */
461 stream_putw_at (s
, pos
, total_attr_len
);
464 bgp_packet_set_size (s
);
466 packet
= bgp_packet_dup (s
);
469 /* Add packet to the peer. */
470 bgp_packet_add (peer
, packet
);
472 BGP_WRITE_ON (peer
->t_write
, bgp_write
, peer
->fd
);
475 /* Get next packet to be written. */
477 bgp_write_packet (struct peer
*peer
)
481 struct stream
*s
= NULL
;
482 struct bgp_advertise
*adv
;
484 s
= stream_fifo_head (peer
->obuf
);
488 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
489 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
491 adv
= FIFO_HEAD (&peer
->sync
[afi
][safi
]->withdraw
);
494 s
= bgp_withdraw_packet (peer
, afi
, safi
);
500 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
501 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
503 adv
= FIFO_HEAD (&peer
->sync
[afi
][safi
]->update
);
506 if (adv
->binfo
&& adv
->binfo
->uptime
< peer
->synctime
)
507 s
= bgp_update_packet (peer
, afi
, safi
);
517 /* Is there partially written packet or updates we can send right
520 bgp_write_proceed (struct peer
*peer
)
524 struct bgp_advertise
*adv
;
526 if (stream_fifo_head (peer
->obuf
))
529 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
530 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
531 if (FIFO_HEAD (&peer
->sync
[afi
][safi
]->withdraw
))
534 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
535 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
536 if ((adv
= FIFO_HEAD (&peer
->sync
[afi
][safi
]->update
)) != NULL
)
537 if (adv
->binfo
->uptime
< peer
->synctime
)
543 /* Write packet to the peer. */
545 bgp_write (struct thread
*thread
)
554 /* Yes first of all get peer pointer. */
555 peer
= THREAD_ARG (thread
);
556 peer
->t_write
= NULL
;
558 /* For non-blocking IO check. */
559 if (peer
->status
== Connect
)
561 bgp_connect_check (peer
);
565 /* Nonblocking write until TCP output buffer is full. */
570 s
= bgp_write_packet (peer
);
574 /* Number of bytes to be sent. */
575 writenum
= stream_get_endp (s
) - stream_get_getp (s
);
577 /* Call write() system call. */
578 num
= write (peer
->fd
, STREAM_PNT (s
), writenum
);
583 if (write_errno
== EWOULDBLOCK
|| write_errno
== EAGAIN
)
588 bgp_timer_set (peer
);
593 stream_forward (s
, num
);
595 if (write_errno
== EAGAIN
)
601 /* Retrieve BGP packet type. */
602 stream_set_getp (s
, BGP_MARKER_SIZE
+ 2);
603 type
= stream_getc (s
);
615 /* Double start timer. */
618 /* Overflow check. */
619 if (peer
->v_start
>= (60 * 2))
620 peer
->v_start
= (60 * 2);
622 /* BGP_EVENT_ADD (peer, BGP_Stop); */
625 bgp_timer_set (peer
);
628 case BGP_MSG_KEEPALIVE
:
629 peer
->keepalive_out
++;
631 case BGP_MSG_ROUTE_REFRESH_NEW
:
632 case BGP_MSG_ROUTE_REFRESH_OLD
:
635 case BGP_MSG_CAPABILITY
:
636 peer
->dynamic_cap_out
++;
640 /* OK we send packet so delete it. */
641 bgp_packet_delete (peer
);
643 if (++count
>= BGP_WRITE_PACKET_MAX
)
647 if (bgp_write_proceed (peer
))
648 BGP_WRITE_ON (peer
->t_write
, bgp_write
, peer
->fd
);
653 /* This is only for sending NOTIFICATION message to neighbor. */
655 bgp_write_notify (struct peer
*peer
)
661 /* There should be at least one packet. */
662 s
= stream_fifo_head (peer
->obuf
);
665 assert (stream_get_endp (s
) >= BGP_HEADER_SIZE
);
667 /* I'm not sure fd is writable. */
668 ret
= writen (peer
->fd
, STREAM_DATA (s
), stream_get_endp (s
));
673 bgp_timer_set (peer
);
677 /* Retrieve BGP packet type. */
678 stream_set_getp (s
, BGP_MARKER_SIZE
+ 2);
679 type
= stream_getc (s
);
681 assert (type
== BGP_MSG_NOTIFY
);
683 /* Type should be notify. */
686 /* Double start timer. */
689 /* Overflow check. */
690 if (peer
->v_start
>= (60 * 2))
691 peer
->v_start
= (60 * 2);
693 /* We don't call event manager at here for avoiding other events. */
696 bgp_timer_set (peer
);
701 /* Make keepalive packet and send it to the peer. */
703 bgp_keepalive_send (struct peer
*peer
)
708 s
= stream_new (BGP_MAX_PACKET_SIZE
);
710 /* Make keepalive packet. */
711 bgp_packet_set_marker (s
, BGP_MSG_KEEPALIVE
);
713 /* Set packet size. */
714 length
= bgp_packet_set_size (s
);
716 /* Dump packet if debug option is set. */
717 /* bgp_packet_dump (s); */
719 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
720 zlog_info ("%s sending KEEPALIVE", peer
->host
);
721 if (BGP_DEBUG (normal
, NORMAL
))
722 zlog_info ("%s send message type %d, length (incl. header) %d",
723 peer
->host
, BGP_MSG_KEEPALIVE
, length
);
725 /* Add packet to the peer. */
726 bgp_packet_add (peer
, s
);
728 BGP_WRITE_ON (peer
->t_write
, bgp_write
, peer
->fd
);
731 /* Make open packet and send it to the peer. */
733 bgp_open_send (struct peer
*peer
)
737 u_int16_t send_holdtime
;
740 if (CHECK_FLAG (peer
->config
, PEER_CONFIG_TIMER
))
741 send_holdtime
= peer
->holdtime
;
743 send_holdtime
= peer
->bgp
->default_holdtime
;
745 /* local-as Change */
746 if (peer
->change_local_as
)
747 local_as
= peer
->change_local_as
;
749 local_as
= peer
->local_as
;
751 s
= stream_new (BGP_MAX_PACKET_SIZE
);
753 /* Make open packet. */
754 bgp_packet_set_marker (s
, BGP_MSG_OPEN
);
756 /* Set open packet values. */
757 stream_putc (s
, BGP_VERSION_4
); /* BGP version */
758 stream_putw (s
, local_as
); /* My Autonomous System*/
759 stream_putw (s
, send_holdtime
); /* Hold Time */
760 stream_put_in_addr (s
, &peer
->local_id
); /* BGP Identifier */
762 /* Set capability code. */
763 bgp_open_capability (s
, peer
);
765 /* Set BGP packet length. */
766 length
= bgp_packet_set_size (s
);
768 if (BGP_DEBUG (normal
, NORMAL
))
769 zlog_info ("%s sending OPEN, version %d, my as %d, holdtime %d, id %s",
770 peer
->host
, BGP_VERSION_4
, local_as
,
771 send_holdtime
, inet_ntoa (peer
->local_id
));
773 if (BGP_DEBUG (normal
, NORMAL
))
774 zlog_info ("%s send message type %d, length (incl. header) %d",
775 peer
->host
, BGP_MSG_OPEN
, length
);
777 /* Dump packet if debug option is set. */
778 /* bgp_packet_dump (s); */
780 /* Add packet to the peer. */
781 bgp_packet_add (peer
, s
);
783 BGP_WRITE_ON (peer
->t_write
, bgp_write
, peer
->fd
);
786 /* Send BGP notify packet with data potion. */
788 bgp_notify_send_with_data (struct peer
*peer
, u_char code
, u_char sub_code
,
789 u_char
*data
, size_t datalen
)
794 /* Allocate new stream. */
795 s
= stream_new (BGP_MAX_PACKET_SIZE
);
797 /* Make nitify packet. */
798 bgp_packet_set_marker (s
, BGP_MSG_NOTIFY
);
800 /* Set notify packet values. */
801 stream_putc (s
, code
); /* BGP notify code */
802 stream_putc (s
, sub_code
); /* BGP notify sub_code */
804 /* If notify data is present. */
806 stream_write (s
, data
, datalen
);
808 /* Set BGP packet length. */
809 length
= bgp_packet_set_size (s
);
811 /* Add packet to the peer. */
812 stream_fifo_clean (peer
->obuf
);
813 bgp_packet_add (peer
, s
);
817 struct bgp_notify bgp_notify
;
822 bgp_notify
.code
= code
;
823 bgp_notify
.subcode
= sub_code
;
824 bgp_notify
.data
= NULL
;
825 bgp_notify
.length
= length
- BGP_MSG_NOTIFY_MIN_SIZE
;
827 if (bgp_notify
.length
)
829 bgp_notify
.data
= XMALLOC (MTYPE_TMP
, bgp_notify
.length
* 3);
830 for (i
= 0; i
< bgp_notify
.length
; i
++)
833 sprintf (c
, " %02x", data
[i
]);
834 strcat (bgp_notify
.data
, c
);
839 sprintf (c
, "%02x", data
[i
]);
840 strcpy (bgp_notify
.data
, c
);
843 bgp_notify_print (peer
, &bgp_notify
, "sending");
845 XFREE (MTYPE_TMP
, bgp_notify
.data
);
848 if (BGP_DEBUG (normal
, NORMAL
))
849 zlog_info ("%s send message type %d, length (incl. header) %d",
850 peer
->host
, BGP_MSG_NOTIFY
, length
);
852 /* peer reset cause */
853 if (sub_code
!= BGP_NOTIFY_CEASE_CONFIG_CHANGE
)
855 if (sub_code
== BGP_NOTIFY_CEASE_ADMIN_RESET
)
856 peer
->last_reset
= PEER_DOWN_USER_RESET
;
857 else if (sub_code
== BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN
)
858 peer
->last_reset
= PEER_DOWN_USER_SHUTDOWN
;
860 peer
->last_reset
= PEER_DOWN_NOTIFY_SEND
;
863 /* Call imidiately. */
864 BGP_WRITE_OFF (peer
->t_write
);
866 bgp_write_notify (peer
);
869 /* Send BGP notify packet. */
871 bgp_notify_send (struct peer
*peer
, u_char code
, u_char sub_code
)
873 bgp_notify_send_with_data (peer
, code
, sub_code
, NULL
, 0);
881 else if (afi
== AFI_IP6
)
884 return "Unknown AFI";
888 safi2str (safi_t safi
)
890 if (safi
== SAFI_UNICAST
)
891 return "SAFI_UNICAST";
892 else if (safi
== SAFI_MULTICAST
)
893 return "SAFI_MULTICAST";
894 else if (safi
== SAFI_MPLS_VPN
|| safi
== BGP_SAFI_VPNV4
)
895 return "SAFI_MPLS_VPN";
897 return "Unknown SAFI";
900 /* Send route refresh message to the peer. */
902 bgp_route_refresh_send (struct peer
*peer
, afi_t afi
, safi_t safi
,
903 u_char orf_type
, u_char when_to_refresh
, int remove
)
906 struct stream
*packet
;
908 struct bgp_filter
*filter
;
911 #ifdef DISABLE_BGP_ANNOUNCE
913 #endif /* DISABLE_BGP_ANNOUNCE */
915 filter
= &peer
->filter
[afi
][safi
];
917 /* Adjust safi code. */
918 if (safi
== SAFI_MPLS_VPN
)
919 safi
= BGP_SAFI_VPNV4
;
921 s
= stream_new (BGP_MAX_PACKET_SIZE
);
923 /* Make BGP update packet. */
924 if (CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
))
925 bgp_packet_set_marker (s
, BGP_MSG_ROUTE_REFRESH_NEW
);
927 bgp_packet_set_marker (s
, BGP_MSG_ROUTE_REFRESH_OLD
);
929 /* Encode Route Refresh message. */
930 stream_putw (s
, afi
);
932 stream_putc (s
, safi
);
934 if (orf_type
== ORF_TYPE_PREFIX
935 || orf_type
== ORF_TYPE_PREFIX_OLD
)
936 if (remove
|| filter
->plist
[FILTER_IN
].plist
)
942 stream_putc (s
, when_to_refresh
);
943 stream_putc (s
, orf_type
);
944 orfp
= stream_get_putp (s
);
949 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_PREFIX_SEND
);
950 stream_putc (s
, ORF_COMMON_PART_REMOVE_ALL
);
951 if (BGP_DEBUG (normal
, NORMAL
))
952 zlog_info ("%s sending REFRESH_REQ to remove ORF(%d) (%s) for afi/safi: %d/%d",
953 peer
->host
, orf_type
,
954 (when_to_refresh
== REFRESH_DEFER
? "defer" : "immediate"),
959 SET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_PREFIX_SEND
);
960 prefix_bgp_orf_entry (s
, filter
->plist
[FILTER_IN
].plist
,
961 ORF_COMMON_PART_ADD
, ORF_COMMON_PART_PERMIT
,
962 ORF_COMMON_PART_DENY
);
963 if (BGP_DEBUG (normal
, NORMAL
))
964 zlog_info ("%s sending REFRESH_REQ with pfxlist ORF(%d) (%s) for afi/safi: %d/%d",
965 peer
->host
, orf_type
,
966 (when_to_refresh
== REFRESH_DEFER
? "defer" : "immediate"),
970 /* Total ORF Entry Len. */
971 orf_len
= stream_get_putp (s
) - orfp
- 2;
972 stream_putw_at (s
, orfp
, orf_len
);
975 /* Set packet size. */
976 length
= bgp_packet_set_size (s
);
978 if (BGP_DEBUG (normal
, NORMAL
))
981 zlog_info ("%s sending REFRESH_REQ for afi/safi: %d/%d",
982 peer
->host
, afi
, safi
);
983 zlog_info ("%s send message type %d, length (incl. header) %d",
984 peer
->host
, CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
) ?
985 BGP_MSG_ROUTE_REFRESH_NEW
: BGP_MSG_ROUTE_REFRESH_OLD
, length
);
988 /* Make real packet. */
989 packet
= bgp_packet_dup (s
);
992 /* Add packet to the peer. */
993 bgp_packet_add (peer
, packet
);
995 BGP_WRITE_ON (peer
->t_write
, bgp_write
, peer
->fd
);
998 /* Send capability message to the peer. */
1000 bgp_capability_send (struct peer
*peer
, afi_t afi
, safi_t safi
,
1001 int capability_code
, int action
)
1004 struct stream
*packet
;
1007 /* Adjust safi code. */
1008 if (safi
== SAFI_MPLS_VPN
)
1009 safi
= BGP_SAFI_VPNV4
;
1011 s
= stream_new (BGP_MAX_PACKET_SIZE
);
1013 /* Make BGP update packet. */
1014 bgp_packet_set_marker (s
, BGP_MSG_CAPABILITY
);
1016 /* Encode MP_EXT capability. */
1017 if (capability_code
== CAPABILITY_CODE_MP
)
1019 stream_putc (s
, action
);
1020 stream_putc (s
, CAPABILITY_CODE_MP
);
1021 stream_putc (s
, CAPABILITY_CODE_MP_LEN
);
1022 stream_putw (s
, afi
);
1024 stream_putc (s
, safi
);
1026 if (BGP_DEBUG (normal
, NORMAL
))
1027 zlog_info ("%s sending CAPABILITY has %s MP_EXT CAP for afi/safi: %d/%d",
1028 peer
->host
, action
== CAPABILITY_ACTION_SET
?
1029 "Advertising" : "Removing", afi
, safi
);
1032 /* Encode Route Refresh capability. */
1033 if (capability_code
== CAPABILITY_CODE_REFRESH
)
1035 stream_putc (s
, action
);
1036 stream_putc (s
, CAPABILITY_CODE_REFRESH
);
1037 stream_putc (s
, CAPABILITY_CODE_REFRESH_LEN
);
1038 stream_putc (s
, action
);
1039 stream_putc (s
, CAPABILITY_CODE_REFRESH_OLD
);
1040 stream_putc (s
, CAPABILITY_CODE_REFRESH_LEN
);
1042 if (BGP_DEBUG (normal
, NORMAL
))
1043 zlog_info ("%s sending CAPABILITY has %s ROUTE-REFRESH capability",
1044 peer
->host
, action
== CAPABILITY_ACTION_SET
?
1045 "Advertising" : "Removing");
1048 /* Set packet size. */
1049 length
= bgp_packet_set_size (s
);
1051 /* Make real packet. */
1052 packet
= bgp_packet_dup (s
);
1055 /* Add packet to the peer. */
1056 bgp_packet_add (peer
, packet
);
1058 if (BGP_DEBUG (normal
, NORMAL
))
1059 zlog_info ("%s send message type %d, length (incl. header) %d",
1060 peer
->host
, BGP_MSG_CAPABILITY
, length
);
1062 BGP_WRITE_ON (peer
->t_write
, bgp_write
, peer
->fd
);
1065 /* RFC1771 6.8 Connection collision detection. */
1067 bgp_collision_detect (struct peer
*new, struct in_addr remote_id
)
1070 struct listnode
*nn
;
1073 bgp
= bgp_get_default ();
1077 /* Upon receipt of an OPEN message, the local system must examine
1078 all of its connections that are in the OpenConfirm state. A BGP
1079 speaker may also examine connections in an OpenSent state if it
1080 knows the BGP Identifier of the peer by means outside of the
1081 protocol. If among these connections there is a connection to a
1082 remote BGP speaker whose BGP Identifier equals the one in the
1083 OPEN message, then the local system performs the following
1084 collision resolution procedure: */
1086 LIST_LOOP (bgp
->peer
, peer
, nn
)
1088 /* Under OpenConfirm status, local peer structure already hold
1089 remote router ID. */
1092 && (peer
->status
== OpenConfirm
|| peer
->status
== OpenSent
)
1093 && sockunion_same (&peer
->su
, &new->su
))
1095 /* 1. The BGP Identifier of the local system is compared to
1096 the BGP Identifier of the remote system (as specified in
1097 the OPEN message). */
1099 if (ntohl (peer
->local_id
.s_addr
) < ntohl (remote_id
.s_addr
))
1101 /* 2. If the value of the local BGP Identifier is less
1102 than the remote one, the local system closes BGP
1103 connection that already exists (the one that is
1104 already in the OpenConfirm state), and accepts BGP
1105 connection initiated by the remote system. */
1108 bgp_notify_send (peer
, BGP_NOTIFY_CEASE
, BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
);
1113 /* 3. Otherwise, the local system closes newly created
1114 BGP connection (the one associated with the newly
1115 received OPEN message), and continues to use the
1116 existing one (the one that is already in the
1117 OpenConfirm state). */
1120 bgp_notify_send (new, BGP_NOTIFY_CEASE
,
1121 BGP_NOTIFY_CEASE_COLLISION_RESOLUTION
);
1130 bgp_open_receive (struct peer
*peer
, bgp_size_t size
)
1136 u_int16_t send_holdtime
;
1138 struct peer
*realpeer
;
1139 struct in_addr remote_id
;
1141 u_int8_t notify_data_remote_as
[2];
1142 u_int8_t notify_data_remote_id
[4];
1146 /* Parse open packet. */
1147 version
= stream_getc (peer
->ibuf
);
1148 memcpy (notify_data_remote_as
, stream_pnt (peer
->ibuf
), 2);
1149 remote_as
= stream_getw (peer
->ibuf
);
1150 holdtime
= stream_getw (peer
->ibuf
);
1151 memcpy (notify_data_remote_id
, stream_pnt (peer
->ibuf
), 4);
1152 remote_id
.s_addr
= stream_get_ipv4 (peer
->ibuf
);
1154 /* Receive OPEN message log */
1155 if (BGP_DEBUG (normal
, NORMAL
))
1156 zlog_info ("%s rcv OPEN, version %d, remote-as %d, holdtime %d, id %s",
1157 peer
->host
, version
, remote_as
, holdtime
,
1158 inet_ntoa (remote_id
));
1160 /* Lookup peer from Open packet. */
1161 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_ACCEPT_PEER
))
1165 realpeer
= peer_lookup_with_open (&peer
->su
, remote_as
, &remote_id
, &as
);
1169 /* Peer's source IP address is check in bgp_accept(), so this
1170 must be AS number mismatch or remote-id configuration
1174 if (BGP_DEBUG (normal
, NORMAL
))
1175 zlog_info ("%s bad OPEN, wrong router identifier %s",
1176 peer
->host
, inet_ntoa (remote_id
));
1177 bgp_notify_send_with_data (peer
,
1178 BGP_NOTIFY_OPEN_ERR
,
1179 BGP_NOTIFY_OPEN_BAD_BGP_IDENT
,
1180 notify_data_remote_id
, 4);
1184 if (BGP_DEBUG (normal
, NORMAL
))
1185 zlog_info ("%s bad OPEN, remote AS is %d, expected %d",
1186 peer
->host
, remote_as
, peer
->as
);
1187 bgp_notify_send_with_data (peer
,
1188 BGP_NOTIFY_OPEN_ERR
,
1189 BGP_NOTIFY_OPEN_BAD_PEER_AS
,
1190 notify_data_remote_as
, 2);
1196 /* When collision is detected and this peer is closed. Retrun
1198 ret
= bgp_collision_detect (peer
, remote_id
);
1203 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_ACCEPT_PEER
))
1205 if (ret
== 0 && realpeer
->status
!= Active
1206 && realpeer
->status
!= OpenSent
1207 && realpeer
->status
!= OpenConfirm
)
1209 if (BGP_DEBUG (events
, EVENTS
))
1210 zlog_info ("%s [Event] peer's status is %s close connection",
1211 realpeer
->host
, LOOKUP (bgp_status_msg
, peer
->status
));
1215 if (BGP_DEBUG (events
, EVENTS
))
1216 zlog_info ("%s [Event] Transfer temporary BGP peer to existing one",
1219 bgp_stop (realpeer
);
1221 /* Transfer file descriptor. */
1222 realpeer
->fd
= peer
->fd
;
1225 /* Transfer input buffer. */
1226 stream_free (realpeer
->ibuf
);
1227 realpeer
->ibuf
= peer
->ibuf
;
1228 realpeer
->packet_size
= peer
->packet_size
;
1231 /* Transfer status. */
1232 realpeer
->status
= peer
->status
;
1235 /* peer pointer change. Open packet send to neighbor. */
1237 bgp_open_send (peer
);
1240 zlog_err ("bgp_open_receive peer's fd is negative value %d",
1244 BGP_READ_ON (peer
->t_read
, bgp_read
, peer
->fd
);
1247 /* remote router-id check. */
1248 if (remote_id
.s_addr
== 0
1249 || ntohl (remote_id
.s_addr
) >= 0xe0000000
1250 || ntohl (peer
->local_id
.s_addr
) == ntohl (remote_id
.s_addr
))
1252 if (BGP_DEBUG (normal
, NORMAL
))
1253 zlog_info ("%s bad OPEN, wrong router identifier %s",
1254 peer
->host
, inet_ntoa (remote_id
));
1255 bgp_notify_send_with_data (peer
,
1256 BGP_NOTIFY_OPEN_ERR
,
1257 BGP_NOTIFY_OPEN_BAD_BGP_IDENT
,
1258 notify_data_remote_id
, 4);
1262 /* Set remote router-id */
1263 peer
->remote_id
= remote_id
;
1265 /* Peer BGP version check. */
1266 if (version
!= BGP_VERSION_4
)
1268 u_int8_t maxver
= BGP_VERSION_4
;
1269 if (BGP_DEBUG (normal
, NORMAL
))
1270 zlog_info ("%s bad protocol version, remote requested %d, local request %d",
1271 peer
->host
, version
, BGP_VERSION_4
);
1272 bgp_notify_send_with_data (peer
,
1273 BGP_NOTIFY_OPEN_ERR
,
1274 BGP_NOTIFY_OPEN_UNSUP_VERSION
,
1279 /* Check neighbor as number. */
1280 if (remote_as
!= peer
->as
)
1282 if (BGP_DEBUG (normal
, NORMAL
))
1283 zlog_info ("%s bad OPEN, remote AS is %d, expected %d",
1284 peer
->host
, remote_as
, peer
->as
);
1285 bgp_notify_send_with_data (peer
,
1286 BGP_NOTIFY_OPEN_ERR
,
1287 BGP_NOTIFY_OPEN_BAD_PEER_AS
,
1288 notify_data_remote_as
, 2);
1292 /* From the rfc: Upon receipt of an OPEN message, a BGP speaker MUST
1293 calculate the value of the Hold Timer by using the smaller of its
1294 configured Hold Time and the Hold Time received in the OPEN message.
1295 The Hold Time MUST be either zero or at least three seconds. An
1296 implementation may reject connections on the basis of the Hold Time. */
1298 if (holdtime
< 3 && holdtime
!= 0)
1300 bgp_notify_send (peer
,
1301 BGP_NOTIFY_OPEN_ERR
,
1302 BGP_NOTIFY_OPEN_UNACEP_HOLDTIME
);
1306 /* From the rfc: A reasonable maximum time between KEEPALIVE messages
1307 would be one third of the Hold Time interval. KEEPALIVE messages
1308 MUST NOT be sent more frequently than one per second. An
1309 implementation MAY adjust the rate at which it sends KEEPALIVE
1310 messages as a function of the Hold Time interval. */
1312 if (CHECK_FLAG (peer
->config
, PEER_CONFIG_TIMER
))
1313 send_holdtime
= peer
->holdtime
;
1315 send_holdtime
= peer
->bgp
->default_holdtime
;
1317 if (holdtime
< send_holdtime
)
1318 peer
->v_holdtime
= holdtime
;
1320 peer
->v_holdtime
= send_holdtime
;
1322 peer
->v_keepalive
= peer
->v_holdtime
/ 3;
1324 /* Open option part parse. */
1326 optlen
= stream_getc (peer
->ibuf
);
1329 ret
= bgp_open_option_parse (peer
, optlen
, &capability
);
1333 stream_forward (peer
->ibuf
, optlen
);
1337 if (BGP_DEBUG (normal
, NORMAL
))
1338 zlog_info ("%s rcvd OPEN w/ OPTION parameter len: 0",
1342 /* Override capability. */
1343 if (! capability
|| CHECK_FLAG (peer
->flags
, PEER_FLAG_OVERRIDE_CAPABILITY
))
1345 peer
->afc_nego
[AFI_IP
][SAFI_UNICAST
] = peer
->afc
[AFI_IP
][SAFI_UNICAST
];
1346 peer
->afc_nego
[AFI_IP
][SAFI_MULTICAST
] = peer
->afc
[AFI_IP
][SAFI_MULTICAST
];
1347 peer
->afc_nego
[AFI_IP6
][SAFI_UNICAST
] = peer
->afc
[AFI_IP6
][SAFI_UNICAST
];
1348 peer
->afc_nego
[AFI_IP6
][SAFI_MULTICAST
] = peer
->afc
[AFI_IP6
][SAFI_MULTICAST
];
1352 bgp_getsockname (peer
);
1354 BGP_EVENT_ADD (peer
, Receive_OPEN_message
);
1356 peer
->packet_size
= 0;
1358 stream_reset (peer
->ibuf
);
1363 /* Parse BGP Update packet and make attribute object. */
1365 bgp_update_receive (struct peer
*peer
, bgp_size_t size
)
1371 bgp_size_t attribute_len
;
1372 bgp_size_t update_len
;
1373 bgp_size_t withdraw_len
;
1374 struct bgp_nlri update
;
1375 struct bgp_nlri withdraw
;
1376 struct bgp_nlri mp_update
;
1377 struct bgp_nlri mp_withdraw
;
1378 char attrstr
[BUFSIZ
] = "";
1380 /* Status must be Established. */
1381 if (peer
->status
!= Established
)
1383 zlog_err ("%s [FSM] Update packet received under status %s",
1384 peer
->host
, LOOKUP (bgp_status_msg
, peer
->status
));
1385 bgp_notify_send (peer
, BGP_NOTIFY_FSM_ERR
, 0);
1389 /* Set initial values. */
1390 memset (&attr
, 0, sizeof (struct attr
));
1391 memset (&update
, 0, sizeof (struct bgp_nlri
));
1392 memset (&withdraw
, 0, sizeof (struct bgp_nlri
));
1393 memset (&mp_update
, 0, sizeof (struct bgp_nlri
));
1394 memset (&mp_withdraw
, 0, sizeof (struct bgp_nlri
));
1397 end
= stream_pnt (s
) + size
;
1399 /* RFC1771 6.3 If the Unfeasible Routes Length or Total Attribute
1400 Length is too large (i.e., if Unfeasible Routes Length + Total
1401 Attribute Length + 23 exceeds the message Length), then the Error
1402 Subcode is set to Malformed Attribute List. */
1403 if (stream_pnt (s
) + 2 > end
)
1405 zlog_err ("%s [Error] Update packet error"
1406 " (packet length is short for unfeasible length)",
1408 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
1409 BGP_NOTIFY_UPDATE_MAL_ATTR
);
1413 /* Unfeasible Route Length. */
1414 withdraw_len
= stream_getw (s
);
1416 /* Unfeasible Route Length check. */
1417 if (stream_pnt (s
) + withdraw_len
> end
)
1419 zlog_err ("%s [Error] Update packet error"
1420 " (packet unfeasible length overflow %d)",
1421 peer
->host
, withdraw_len
);
1422 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
1423 BGP_NOTIFY_UPDATE_MAL_ATTR
);
1427 /* Unfeasible Route packet format check. */
1428 if (withdraw_len
> 0)
1430 ret
= bgp_nlri_sanity_check (peer
, AFI_IP
, stream_pnt (s
), withdraw_len
);
1434 if (BGP_DEBUG (packet
, PACKET_RECV
))
1435 zlog_info ("%s [Update:RECV] Unfeasible NLRI received", peer
->host
);
1437 withdraw
.afi
= AFI_IP
;
1438 withdraw
.safi
= SAFI_UNICAST
;
1439 withdraw
.nlri
= stream_pnt (s
);
1440 withdraw
.length
= withdraw_len
;
1441 stream_forward (s
, withdraw_len
);
1444 /* Attribute total length check. */
1445 if (stream_pnt (s
) + 2 > end
)
1447 zlog_warn ("%s [Error] Packet Error"
1448 " (update packet is short for attribute length)",
1450 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
1451 BGP_NOTIFY_UPDATE_MAL_ATTR
);
1455 /* Fetch attribute total length. */
1456 attribute_len
= stream_getw (s
);
1458 /* Attribute length check. */
1459 if (stream_pnt (s
) + attribute_len
> end
)
1461 zlog_warn ("%s [Error] Packet Error"
1462 " (update packet attribute length overflow %d)",
1463 peer
->host
, attribute_len
);
1464 bgp_notify_send (peer
, BGP_NOTIFY_UPDATE_ERR
,
1465 BGP_NOTIFY_UPDATE_MAL_ATTR
);
1469 /* Parse attribute when it exists. */
1472 ret
= bgp_attr_parse (peer
, &attr
, attribute_len
,
1473 &mp_update
, &mp_withdraw
);
1478 /* Logging the attribute. */
1479 if (BGP_DEBUG (update
, UPDATE_IN
))
1481 ret
= bgp_dump_attr (peer
, &attr
, attrstr
, BUFSIZ
);
1484 zlog (peer
->log
, LOG_INFO
, "%s rcvd UPDATE w/ attr: %s",
1485 peer
->host
, attrstr
);
1488 /* Network Layer Reachability Information. */
1489 update_len
= end
- stream_pnt (s
);
1493 /* Check NLRI packet format and prefix length. */
1494 ret
= bgp_nlri_sanity_check (peer
, AFI_IP
, stream_pnt (s
), update_len
);
1498 /* Set NLRI portion to structure. */
1499 update
.afi
= AFI_IP
;
1500 update
.safi
= SAFI_UNICAST
;
1501 update
.nlri
= stream_pnt (s
);
1502 update
.length
= update_len
;
1503 stream_forward (s
, update_len
);
1506 /* NLRI is processed only when the peer is configured specific
1507 Address Family and Subsequent Address Family. */
1508 if (peer
->afc
[AFI_IP
][SAFI_UNICAST
])
1510 if (withdraw
.length
)
1511 bgp_nlri_parse (peer
, NULL
, &withdraw
);
1515 /* We check well-known attribute only for IPv4 unicast
1517 ret
= bgp_attr_check (peer
, &attr
);
1521 bgp_nlri_parse (peer
, &attr
, &update
);
1524 if (! attribute_len
&& ! withdraw_len
)
1526 /* End-of-RIB received */
1528 if (BGP_DEBUG (update
, UPDATE_IN
))
1529 zlog (peer
->log
, LOG_INFO
, "rcvd End-of-RIB for IPv4 Unicast from %s",
1533 if (peer
->afc
[AFI_IP
][SAFI_MULTICAST
])
1535 if (mp_update
.length
1536 && mp_update
.afi
== AFI_IP
1537 && mp_update
.safi
== SAFI_MULTICAST
)
1538 bgp_nlri_parse (peer
, &attr
, &mp_update
);
1540 if (mp_withdraw
.length
1541 && mp_withdraw
.afi
== AFI_IP
1542 && mp_withdraw
.safi
== SAFI_MULTICAST
)
1543 bgp_nlri_parse (peer
, NULL
, &mp_withdraw
);
1545 if (attribute_len
== 6 && ! withdraw_len
1546 && mp_withdraw
.afi
== AFI_IP
1547 && mp_withdraw
.safi
== SAFI_MULTICAST
1548 && mp_withdraw
.length
== 0)
1550 /* End-of-RIB received */
1552 if (BGP_DEBUG (update
, UPDATE_IN
))
1553 zlog (peer
->log
, LOG_INFO
, "rcvd End-of-RIB for IPv4 Multicast from %s",
1557 if (peer
->afc
[AFI_IP6
][SAFI_UNICAST
])
1559 if (mp_update
.length
1560 && mp_update
.afi
== AFI_IP6
1561 && mp_update
.safi
== SAFI_UNICAST
)
1562 bgp_nlri_parse (peer
, &attr
, &mp_update
);
1564 if (mp_withdraw
.length
1565 && mp_withdraw
.afi
== AFI_IP6
1566 && mp_withdraw
.safi
== SAFI_UNICAST
)
1567 bgp_nlri_parse (peer
, NULL
, &mp_withdraw
);
1569 if (attribute_len
== 6 && ! withdraw_len
1570 && mp_withdraw
.afi
== AFI_IP6
1571 && mp_withdraw
.safi
== SAFI_UNICAST
1572 && mp_withdraw
.length
== 0)
1574 /* End-of-RIB received */
1576 if (BGP_DEBUG (update
, UPDATE_IN
))
1577 zlog (peer
->log
, LOG_INFO
, "rcvd End-of-RIB for IPv6 Unicast from %s",
1581 if (peer
->afc
[AFI_IP6
][SAFI_MULTICAST
])
1583 if (mp_update
.length
1584 && mp_update
.afi
== AFI_IP6
1585 && mp_update
.safi
== SAFI_MULTICAST
)
1586 bgp_nlri_parse (peer
, &attr
, &mp_update
);
1588 if (mp_withdraw
.length
1589 && mp_withdraw
.afi
== AFI_IP6
1590 && mp_withdraw
.safi
== SAFI_MULTICAST
)
1591 bgp_nlri_parse (peer
, NULL
, &mp_withdraw
);
1593 if (attribute_len
== 6 && ! withdraw_len
1594 && mp_withdraw
.afi
== AFI_IP6
1595 && mp_withdraw
.safi
== SAFI_MULTICAST
1596 && mp_withdraw
.length
== 0)
1598 /* End-of-RIB received */
1600 if (BGP_DEBUG (update
, UPDATE_IN
))
1601 zlog (peer
->log
, LOG_INFO
, "rcvd End-of-RIB for IPv6 Multicast from %s",
1605 if (peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
])
1607 if (mp_update
.length
1608 && mp_update
.afi
== AFI_IP
1609 && mp_update
.safi
== BGP_SAFI_VPNV4
)
1610 bgp_nlri_parse_vpnv4 (peer
, &attr
, &mp_update
);
1612 if (mp_withdraw
.length
1613 && mp_withdraw
.afi
== AFI_IP
1614 && mp_withdraw
.safi
== BGP_SAFI_VPNV4
)
1615 bgp_nlri_parse_vpnv4 (peer
, NULL
, &mp_withdraw
);
1617 if (attribute_len
== 6 && ! withdraw_len
1618 && mp_withdraw
.afi
== AFI_IP
1619 && mp_withdraw
.safi
== BGP_SAFI_VPNV4
1620 && mp_withdraw
.length
== 0)
1622 /* End-of-RIB received */
1624 if (BGP_DEBUG (update
, UPDATE_IN
))
1625 zlog (peer
->log
, LOG_INFO
, "rcvd End-of-RIB for VPNv4 Unicast from %s",
1630 /* Everything is done. We unintern temporary structures which
1631 interned in bgp_attr_parse(). */
1633 aspath_unintern (attr
.aspath
);
1635 community_unintern (attr
.community
);
1636 if (attr
.ecommunity
)
1637 ecommunity_unintern (attr
.ecommunity
);
1639 cluster_unintern (attr
.cluster
);
1641 transit_unintern (attr
.transit
);
1643 /* If peering is stopped due to some reason, do not generate BGP
1645 if (peer
->status
!= Established
)
1648 /* Increment packet counter. */
1650 peer
->update_time
= time (NULL
);
1652 /* Generate BGP event. */
1653 BGP_EVENT_ADD (peer
, Receive_UPDATE_message
);
1658 /* Notify message treatment function. */
1660 bgp_notify_receive (struct peer
*peer
, bgp_size_t size
)
1662 struct bgp_notify bgp_notify
;
1664 if (peer
->notify
.data
)
1666 XFREE (MTYPE_TMP
, peer
->notify
.data
);
1667 peer
->notify
.data
= NULL
;
1668 peer
->notify
.length
= 0;
1671 bgp_notify
.code
= stream_getc (peer
->ibuf
);
1672 bgp_notify
.subcode
= stream_getc (peer
->ibuf
);
1673 bgp_notify
.length
= size
- 2;
1674 bgp_notify
.data
= NULL
;
1676 /* Preserv notify code and sub code. */
1677 peer
->notify
.code
= bgp_notify
.code
;
1678 peer
->notify
.subcode
= bgp_notify
.subcode
;
1679 /* For further diagnostic record returned Data. */
1680 if (bgp_notify
.length
)
1682 peer
->notify
.length
= size
- 2;
1683 peer
->notify
.data
= XMALLOC (MTYPE_TMP
, size
- 2);
1684 memcpy (peer
->notify
.data
, stream_pnt (peer
->ibuf
), size
- 2);
1693 if (bgp_notify
.length
)
1695 bgp_notify
.data
= XMALLOC (MTYPE_TMP
, bgp_notify
.length
* 3);
1696 for (i
= 0; i
< bgp_notify
.length
; i
++)
1699 sprintf (c
, " %02x", stream_getc (peer
->ibuf
));
1700 strcat (bgp_notify
.data
, c
);
1705 sprintf (c
, "%02x", stream_getc (peer
->ibuf
));
1706 strcpy (bgp_notify
.data
, c
);
1710 bgp_notify_print(peer
, &bgp_notify
, "received");
1711 if (bgp_notify
.data
)
1712 XFREE (MTYPE_TMP
, bgp_notify
.data
);
1715 /* peer count update */
1718 if (peer
->status
== Established
)
1719 peer
->last_reset
= PEER_DOWN_NOTIFY_RECEIVED
;
1721 /* We have to check for Notify with Unsupported Optional Parameter.
1722 in that case we fallback to open without the capability option.
1723 But this done in bgp_stop. We just mark it here to avoid changing
1725 if (bgp_notify
.code
== BGP_NOTIFY_OPEN_ERR
&&
1726 bgp_notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_PARAM
)
1727 UNSET_FLAG (peer
->sflags
, PEER_STATUS_CAPABILITY_OPEN
);
1729 /* Also apply to Unsupported Capability until remote router support
1731 if (bgp_notify
.code
== BGP_NOTIFY_OPEN_ERR
&&
1732 bgp_notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
1733 UNSET_FLAG (peer
->sflags
, PEER_STATUS_CAPABILITY_OPEN
);
1735 BGP_EVENT_ADD (peer
, Receive_NOTIFICATION_message
);
1738 /* Keepalive treatment function -- get keepalive send keepalive */
1740 bgp_keepalive_receive (struct peer
*peer
, bgp_size_t size
)
1742 if (BGP_DEBUG (keepalive
, KEEPALIVE
))
1743 zlog_info ("%s KEEPALIVE rcvd", peer
->host
);
1745 BGP_EVENT_ADD (peer
, Receive_KEEPALIVE_message
);
1748 /* Route refresh message is received. */
1750 bgp_route_refresh_receive (struct peer
*peer
, bgp_size_t size
)
1757 /* If peer does not have the capability, send notification. */
1758 if (! CHECK_FLAG (peer
->cap
, PEER_CAP_REFRESH_ADV
))
1760 plog_err (peer
->log
, "%s [Error] BGP route refresh is not enabled",
1762 bgp_notify_send (peer
,
1763 BGP_NOTIFY_HEADER_ERR
,
1764 BGP_NOTIFY_HEADER_BAD_MESTYPE
);
1768 /* Status must be Established. */
1769 if (peer
->status
!= Established
)
1771 plog_err (peer
->log
,
1772 "%s [Error] Route refresh packet received under status %s",
1773 peer
->host
, LOOKUP (bgp_status_msg
, peer
->status
));
1774 bgp_notify_send (peer
, BGP_NOTIFY_FSM_ERR
, 0);
1781 afi
= stream_getw (s
);
1782 reserved
= stream_getc (s
);
1783 safi
= stream_getc (s
);
1785 if (BGP_DEBUG (normal
, NORMAL
))
1786 zlog_info ("%s rcvd REFRESH_REQ for afi/safi: %d/%d",
1787 peer
->host
, afi
, safi
);
1789 /* Check AFI and SAFI. */
1790 if ((afi
!= AFI_IP
&& afi
!= AFI_IP6
)
1791 || (safi
!= SAFI_UNICAST
&& safi
!= SAFI_MULTICAST
1792 && safi
!= BGP_SAFI_VPNV4
))
1794 if (BGP_DEBUG (normal
, NORMAL
))
1796 zlog_info ("%s REFRESH_REQ for unrecognized afi/safi: %d/%d - ignored",
1797 peer
->host
, afi
, safi
);
1802 /* Adjust safi code. */
1803 if (safi
== BGP_SAFI_VPNV4
)
1804 safi
= SAFI_MPLS_VPN
;
1806 if (size
!= BGP_MSG_ROUTE_REFRESH_MIN_SIZE
- BGP_HEADER_SIZE
)
1809 u_char when_to_refresh
;
1813 if (size
- (BGP_MSG_ROUTE_REFRESH_MIN_SIZE
- BGP_HEADER_SIZE
) < 5)
1815 zlog_info ("%s ORF route refresh length error", peer
->host
);
1816 bgp_notify_send (peer
, BGP_NOTIFY_CEASE
, 0);
1820 when_to_refresh
= stream_getc (s
);
1821 end
= stream_pnt (s
) + (size
- 5);
1823 while (stream_pnt (s
) < end
)
1825 orf_type
= stream_getc (s
);
1826 orf_len
= stream_getw (s
);
1828 if (orf_type
== ORF_TYPE_PREFIX
1829 || orf_type
== ORF_TYPE_PREFIX_OLD
)
1831 u_char
*p_pnt
= stream_pnt (s
);
1832 u_char
*p_end
= stream_pnt (s
) + orf_len
;
1833 struct orf_prefix orfp
;
1841 if (BGP_DEBUG (normal
, NORMAL
))
1843 zlog_info ("%s rcvd Prefixlist ORF(%d) length %d",
1844 peer
->host
, orf_type
, orf_len
);
1847 /* ORF prefix-list name */
1848 sprintf (name
, "%s.%d.%d", peer
->host
, afi
, safi
);
1850 while (p_pnt
< p_end
)
1852 memset (&orfp
, 0, sizeof (struct orf_prefix
));
1854 if (common
& ORF_COMMON_PART_REMOVE_ALL
)
1856 if (BGP_DEBUG (normal
, NORMAL
))
1857 zlog_info ("%s rcvd Remove-All pfxlist ORF request", peer
->host
);
1858 prefix_bgp_orf_remove_all (name
);
1861 memcpy (&seq
, p_pnt
, sizeof (u_int32_t
));
1862 p_pnt
+= sizeof (u_int32_t
);
1863 orfp
.seq
= ntohl (seq
);
1866 orfp
.p
.prefixlen
= *p_pnt
++;
1867 orfp
.p
.family
= afi2family (afi
);
1868 psize
= PSIZE (orfp
.p
.prefixlen
);
1869 memcpy (&orfp
.p
.u
.prefix
, p_pnt
, psize
);
1872 if (BGP_DEBUG (normal
, NORMAL
))
1873 zlog_info ("%s rcvd %s %s seq %u %s/%d ge %d le %d",
1875 (common
& ORF_COMMON_PART_REMOVE
? "Remove" : "Add"),
1876 (common
& ORF_COMMON_PART_DENY
? "deny" : "permit"),
1878 inet_ntop (orfp
.p
.family
, &orfp
.p
.u
.prefix
, buf
, BUFSIZ
),
1879 orfp
.p
.prefixlen
, orfp
.ge
, orfp
.le
);
1881 ret
= prefix_bgp_orf_set (name
, afi
, &orfp
,
1882 (common
& ORF_COMMON_PART_DENY
? 0 : 1 ),
1883 (common
& ORF_COMMON_PART_REMOVE
? 0 : 1));
1885 if (ret
!= CMD_SUCCESS
)
1887 if (BGP_DEBUG (normal
, NORMAL
))
1888 zlog_info ("%s Received misformatted prefixlist ORF. Remove All pfxlist", peer
->host
);
1889 prefix_bgp_orf_remove_all (name
);
1893 peer
->orf_plist
[afi
][safi
] =
1894 prefix_list_lookup (AFI_ORF_PREFIX
, name
);
1896 stream_forward (s
, orf_len
);
1898 if (BGP_DEBUG (normal
, NORMAL
))
1899 zlog_info ("%s rcvd Refresh %s ORF request", peer
->host
,
1900 when_to_refresh
== REFRESH_DEFER
? "Defer" : "Immediate");
1901 if (when_to_refresh
== REFRESH_DEFER
)
1905 /* First update is deferred until ORF or ROUTE-REFRESH is received */
1906 if (CHECK_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
))
1907 UNSET_FLAG (peer
->af_sflags
[afi
][safi
], PEER_STATUS_ORF_WAIT_REFRESH
);
1909 /* Perform route refreshment to the peer */
1910 bgp_announce_route (peer
, afi
, safi
);
1914 bgp_capability_msg_parse (struct peer
*peer
, u_char
*pnt
, bgp_size_t length
)
1917 struct capability cap
;
1928 /* We need at least action, capability code and capability length. */
1931 zlog_info ("%s Capability length error", peer
->host
);
1932 bgp_notify_send (peer
, BGP_NOTIFY_CEASE
, 0);
1938 /* Fetch structure to the byte stream. */
1939 memcpy (&cap
, pnt
+ 1, sizeof (struct capability
));
1941 /* Action value check. */
1942 if (action
!= CAPABILITY_ACTION_SET
1943 && action
!= CAPABILITY_ACTION_UNSET
)
1945 zlog_info ("%s Capability Action Value error %d",
1946 peer
->host
, action
);
1947 bgp_notify_send (peer
, BGP_NOTIFY_CEASE
, 0);
1951 if (BGP_DEBUG (normal
, NORMAL
))
1952 zlog_info ("%s CAPABILITY has action: %d, code: %u, length %u",
1953 peer
->host
, action
, cap
.code
, cap
.length
);
1955 /* Capability length check. */
1956 if (pnt
+ (cap
.length
+ 3) > end
)
1958 zlog_info ("%s Capability length error", peer
->host
);
1959 bgp_notify_send (peer
, BGP_NOTIFY_CEASE
, 0);
1963 /* We know MP Capability Code. */
1964 if (cap
.code
== CAPABILITY_CODE_MP
)
1966 afi
= ntohs (cap
.mpc
.afi
);
1967 safi
= cap
.mpc
.safi
;
1969 /* Ignore capability when override-capability is set. */
1970 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_OVERRIDE_CAPABILITY
))
1973 /* Address family check. */
1976 && (safi
== SAFI_UNICAST
1977 || safi
== SAFI_MULTICAST
1978 || safi
== BGP_SAFI_VPNV4
))
1980 if (BGP_DEBUG (normal
, NORMAL
))
1981 zlog_info ("%s CAPABILITY has %s MP_EXT CAP for afi/safi: %u/%u",
1983 action
== CAPABILITY_ACTION_SET
1984 ? "Advertising" : "Removing",
1985 ntohs(cap
.mpc
.afi
) , cap
.mpc
.safi
);
1987 /* Adjust safi code. */
1988 if (safi
== BGP_SAFI_VPNV4
)
1989 safi
= SAFI_MPLS_VPN
;
1991 if (action
== CAPABILITY_ACTION_SET
)
1993 peer
->afc_recv
[afi
][safi
] = 1;
1994 if (peer
->afc
[afi
][safi
])
1996 peer
->afc_nego
[afi
][safi
] = 1;
1997 bgp_announce_route (peer
, afi
, safi
);
2002 peer
->afc_recv
[afi
][safi
] = 0;
2003 peer
->afc_nego
[afi
][safi
] = 0;
2005 if (peer_active_nego (peer
))
2006 bgp_clear_route (peer
, afi
, safi
);
2008 BGP_EVENT_ADD (peer
, BGP_Stop
);
2012 else if (cap
.code
== CAPABILITY_CODE_REFRESH
2013 || cap
.code
== CAPABILITY_CODE_REFRESH_OLD
)
2016 if (cap
.length
!= 0)
2018 zlog_info ("%s Route Refresh Capability length error %d",
2019 peer
->host
, cap
.length
);
2020 bgp_notify_send (peer
, BGP_NOTIFY_CEASE
, 0);
2024 if (BGP_DEBUG (normal
, NORMAL
))
2025 zlog_info ("%s CAPABILITY has %s ROUTE-REFRESH capability(%s) for all address-families",
2027 action
== CAPABILITY_ACTION_SET
2028 ? "Advertising" : "Removing",
2029 cap
.code
== CAPABILITY_CODE_REFRESH_OLD
2032 /* BGP refresh capability */
2033 if (action
== CAPABILITY_ACTION_SET
)
2035 if (cap
.code
== CAPABILITY_CODE_REFRESH_OLD
)
2036 SET_FLAG (peer
->cap
, PEER_CAP_REFRESH_OLD_RCV
);
2038 SET_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
);
2042 if (cap
.code
== CAPABILITY_CODE_REFRESH_OLD
)
2043 UNSET_FLAG (peer
->cap
, PEER_CAP_REFRESH_OLD_RCV
);
2045 UNSET_FLAG (peer
->cap
, PEER_CAP_REFRESH_NEW_RCV
);
2050 zlog_warn ("%s unrecognized capability code: %d - ignored",
2051 peer
->host
, cap
.code
);
2053 pnt
+= cap
.length
+ 3;
2058 /* Dynamic Capability is received. */
2060 bgp_capability_receive (struct peer
*peer
, bgp_size_t size
)
2065 /* Fetch pointer. */
2066 pnt
= stream_pnt (peer
->ibuf
);
2068 if (BGP_DEBUG (normal
, NORMAL
))
2069 zlog_info ("%s rcv CAPABILITY", peer
->host
);
2071 /* If peer does not have the capability, send notification. */
2072 if (! CHECK_FLAG (peer
->cap
, PEER_CAP_DYNAMIC_ADV
))
2074 plog_err (peer
->log
, "%s [Error] BGP dynamic capability is not enabled",
2076 bgp_notify_send (peer
,
2077 BGP_NOTIFY_HEADER_ERR
,
2078 BGP_NOTIFY_HEADER_BAD_MESTYPE
);
2082 /* Status must be Established. */
2083 if (peer
->status
!= Established
)
2085 plog_err (peer
->log
,
2086 "%s [Error] Dynamic capability packet received under status %s", peer
->host
, LOOKUP (bgp_status_msg
, peer
->status
));
2087 bgp_notify_send (peer
, BGP_NOTIFY_FSM_ERR
, 0);
2092 ret
= bgp_capability_msg_parse (peer
, pnt
, size
);
2095 /* BGP read utility function. */
2097 bgp_read_packet (struct peer
*peer
)
2102 readsize
= peer
->packet_size
- peer
->ibuf
->putp
;
2104 /* If size is zero then return. */
2108 /* Read packet from fd. */
2109 nbytes
= stream_read_unblock (peer
->ibuf
, peer
->fd
, readsize
);
2111 /* If read byte is smaller than zero then error occured. */
2114 if (errno
== EAGAIN
)
2117 plog_err (peer
->log
, "%s [Error] bgp_read_packet error: %s",
2118 peer
->host
, strerror (errno
));
2119 BGP_EVENT_ADD (peer
, TCP_fatal_error
);
2123 /* When read byte is zero : clear bgp peer and return */
2126 if (BGP_DEBUG (events
, EVENTS
))
2127 plog_info (peer
->log
, "%s [Event] BGP connection closed fd %d",
2128 peer
->host
, peer
->fd
);
2130 if (peer
->status
== Established
)
2131 peer
->last_reset
= PEER_DOWN_CLOSE_SESSION
;
2133 BGP_EVENT_ADD (peer
, TCP_connection_closed
);
2137 /* We read partial packet. */
2138 if (peer
->ibuf
->putp
!= peer
->packet_size
)
2146 bgp_marker_all_one (struct stream
*s
, int length
)
2150 for (i
= 0; i
< length
; i
++)
2151 if (s
->data
[i
] != 0xff)
2157 /* Starting point of packet process function. */
2159 bgp_read (struct thread
*thread
)
2165 char notify_data_length
[2];
2167 /* Yes first of all get peer pointer. */
2168 peer
= THREAD_ARG (thread
);
2169 peer
->t_read
= NULL
;
2171 /* For non-blocking IO check. */
2172 if (peer
->status
== Connect
)
2174 bgp_connect_check (peer
);
2181 zlog_err ("bgp_read peer's fd is negative value %d", peer
->fd
);
2184 BGP_READ_ON (peer
->t_read
, bgp_read
, peer
->fd
);
2187 /* Read packet header to determine type of the packet */
2188 if (peer
->packet_size
== 0)
2189 peer
->packet_size
= BGP_HEADER_SIZE
;
2191 if (peer
->ibuf
->putp
< BGP_HEADER_SIZE
)
2193 ret
= bgp_read_packet (peer
);
2195 /* Header read error or partial read packet. */
2199 /* Get size and type. */
2200 stream_forward (peer
->ibuf
, BGP_MARKER_SIZE
);
2201 memcpy (notify_data_length
, stream_pnt (peer
->ibuf
), 2);
2202 size
= stream_getw (peer
->ibuf
);
2203 type
= stream_getc (peer
->ibuf
);
2205 if (BGP_DEBUG (normal
, NORMAL
) && type
!= 2 && type
!= 0)
2206 zlog_info ("%s rcv message type %d, length (excl. header) %d",
2207 peer
->host
, type
, size
- BGP_HEADER_SIZE
);
2210 if (((type
== BGP_MSG_OPEN
) || (type
== BGP_MSG_KEEPALIVE
))
2211 && ! bgp_marker_all_one (peer
->ibuf
, BGP_MARKER_SIZE
))
2213 bgp_notify_send (peer
,
2214 BGP_NOTIFY_HEADER_ERR
,
2215 BGP_NOTIFY_HEADER_NOT_SYNC
);
2219 /* BGP type check. */
2220 if (type
!= BGP_MSG_OPEN
&& type
!= BGP_MSG_UPDATE
2221 && type
!= BGP_MSG_NOTIFY
&& type
!= BGP_MSG_KEEPALIVE
2222 && type
!= BGP_MSG_ROUTE_REFRESH_NEW
2223 && type
!= BGP_MSG_ROUTE_REFRESH_OLD
2224 && type
!= BGP_MSG_CAPABILITY
)
2226 if (BGP_DEBUG (normal
, NORMAL
))
2227 plog_err (peer
->log
,
2228 "%s unknown message type 0x%02x",
2230 bgp_notify_send_with_data (peer
,
2231 BGP_NOTIFY_HEADER_ERR
,
2232 BGP_NOTIFY_HEADER_BAD_MESTYPE
,
2236 /* Mimimum packet length check. */
2237 if ((size
< BGP_HEADER_SIZE
)
2238 || (size
> BGP_MAX_PACKET_SIZE
)
2239 || (type
== BGP_MSG_OPEN
&& size
< BGP_MSG_OPEN_MIN_SIZE
)
2240 || (type
== BGP_MSG_UPDATE
&& size
< BGP_MSG_UPDATE_MIN_SIZE
)
2241 || (type
== BGP_MSG_NOTIFY
&& size
< BGP_MSG_NOTIFY_MIN_SIZE
)
2242 || (type
== BGP_MSG_KEEPALIVE
&& size
!= BGP_MSG_KEEPALIVE_MIN_SIZE
)
2243 || (type
== BGP_MSG_ROUTE_REFRESH_NEW
&& size
< BGP_MSG_ROUTE_REFRESH_MIN_SIZE
)
2244 || (type
== BGP_MSG_ROUTE_REFRESH_OLD
&& size
< BGP_MSG_ROUTE_REFRESH_MIN_SIZE
)
2245 || (type
== BGP_MSG_CAPABILITY
&& size
< BGP_MSG_CAPABILITY_MIN_SIZE
))
2247 if (BGP_DEBUG (normal
, NORMAL
))
2248 plog_err (peer
->log
,
2249 "%s bad message length - %d for %s",
2251 type
== 128 ? "ROUTE-REFRESH" :
2252 bgp_type_str
[(int) type
]);
2253 bgp_notify_send_with_data (peer
,
2254 BGP_NOTIFY_HEADER_ERR
,
2255 BGP_NOTIFY_HEADER_BAD_MESLEN
,
2256 (u_char
*) notify_data_length
, 2);
2260 /* Adjust size to message length. */
2261 peer
->packet_size
= size
;
2264 ret
= bgp_read_packet (peer
);
2268 /* Get size and type again. */
2269 size
= stream_getw_from (peer
->ibuf
, BGP_MARKER_SIZE
);
2270 type
= stream_getc_from (peer
->ibuf
, BGP_MARKER_SIZE
+ 2);
2272 /* BGP packet dump function. */
2273 bgp_dump_packet (peer
, type
, peer
->ibuf
);
2275 size
= (peer
->packet_size
- BGP_HEADER_SIZE
);
2277 /* Read rest of the packet and call each sort of packet routine */
2282 bgp_open_receive (peer
, size
); /* XXX return value ignored! */
2284 case BGP_MSG_UPDATE
:
2285 peer
->readtime
= time(NULL
); /* Last read timer reset */
2286 bgp_update_receive (peer
, size
);
2288 case BGP_MSG_NOTIFY
:
2289 bgp_notify_receive (peer
, size
);
2291 case BGP_MSG_KEEPALIVE
:
2292 peer
->readtime
= time(NULL
); /* Last read timer reset */
2293 bgp_keepalive_receive (peer
, size
);
2295 case BGP_MSG_ROUTE_REFRESH_NEW
:
2296 case BGP_MSG_ROUTE_REFRESH_OLD
:
2298 bgp_route_refresh_receive (peer
, size
);
2300 case BGP_MSG_CAPABILITY
:
2301 peer
->dynamic_cap_in
++;
2302 bgp_capability_receive (peer
, size
);
2306 /* Clear input buffer. */
2307 peer
->packet_size
= 0;
2309 stream_reset (peer
->ibuf
);
2312 if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_ACCEPT_PEER
))
2314 if (BGP_DEBUG (events
, EVENTS
))
2315 zlog_info ("%s [Event] Accepting BGP peer delete", peer
->host
);