1 /* BGP-4, BGP-4+ daemon program
2 * Copyright (C) 1996, 97, 98, 99, 2000 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"
40 #include "bgpd/bgpd.h"
41 #include "bgpd/bgp_aspath.h"
42 #include "bgpd/bgp_route.h"
43 #include "bgpd/bgp_dump.h"
44 #include "bgpd/bgp_debug.h"
45 #include "bgpd/bgp_community.h"
46 #include "bgpd/bgp_attr.h"
47 #include "bgpd/bgp_clist.h"
48 #include "bgpd/bgp_fsm.h"
49 #include "bgpd/bgp_packet.h"
50 #include "bgpd/bgp_zebra.h"
51 #include "bgpd/bgp_open.h"
52 #include "bgpd/bgp_filter.h"
53 #include "bgpd/bgp_nexthop.h"
54 #include "bgpd/bgp_damp.h"
55 #include "bgpd/bgp_mplsvpn.h"
57 #define min(a, b) ((a) < (b) ? (a) : (b))
59 /* All BGP instance. */
60 struct list
*bgp_list
;
62 /* All peer instance. */
63 struct list
*peer_list
;
65 /* BGP multiple instance flag. */
66 int bgp_multiple_instance
;
68 /* Enable BGP mutliple instance configuration. */
69 DEFUN (bgp_multiple_instance_func
,
70 bgp_multiple_instance_cmd
,
71 "bgp multiple-instance",
72 "BGP specific commands\n"
73 "Enable bgp multiple instance\n")
75 bgp_multiple_instance
= 1;
79 /* Disable BGP multiple instance. */
80 DEFUN (no_bgp_multiple_instance
,
81 no_bgp_multiple_instance_cmd
,
82 "no bgp multiple-instance",
84 "BGP specific commands\n"
85 "BGP multiple instance\n")
87 if (bgp_list
->count
> 1)
89 vty_out (vty
, "There are more than two BGP instances%s",
93 bgp_multiple_instance
= 0;
97 /* Peer group cofiguration. */
101 struct peer_group
*group
;
103 group
= XMALLOC (MTYPE_PEER_GROUP
, sizeof (struct peer_group
));
104 memset (group
, 0, sizeof (struct peer_group
));
109 peer_group_free (struct peer_group
*group
)
111 XFREE (MTYPE_PEER_GROUP
, group
);
115 peer_group_lookup (struct list
*glist
, char *name
)
117 struct peer_group
*group
;
120 LIST_LOOP (glist
, group
, nn
)
122 if (strcmp(group
->name
, name
) == 0)
129 peer_group_get (struct vty
*vty
, char *name
, int afi
, int safi
)
132 struct peer_group
*group
;
135 group
= peer_group_lookup (bgp
->peer_group
, name
);
139 vty_out (vty
, "Same name peer-group already exists%s", VTY_NEWLINE
);
143 group
= peer_group_new ();
144 group
->name
= strdup (name
);
145 group
->peer_conf
= list_new ();
146 listnode_add (bgp
->peer_group
, group
);
152 peer_conf_peer_group (struct vty
*vty
, char *peer_str
, char *group_str
)
155 struct peer_group
*group
;
159 group
= peer_group_lookup (bgp
->peer_group
, group_str
);
164 DEFUN (neighbor_peer_group
,
165 neighbor_peer_group_cmd
,
166 "neighbor WORD peer-group",
169 "Configure peer-group\n")
171 return peer_group_get (vty
, argv
[0], 0, 0);
174 DEFUN (neighbor_peer_group_remote_as
,
175 neighbor_peer_group_remote_as_cmd
,
176 "neighbor WORD remote-as <1-65535>",
179 "Specify a BGP neighbor\n"
180 "AS of remote neighbor\n")
183 struct peer_group
*group
;
188 group
= peer_group_lookup (bgp
->peer_group
, argv
[0]);
192 vty_out (vty
, "Please configure peer-group first%s", VTY_NEWLINE
);
195 if (group
->peer_conf
->count
)
197 vty_out (vty
, "Can't configure AS number for existance peer%s",
202 /* Convert string to number. */
203 as
= strtoul (argv
[1], &endptr
, 10);
204 if (as
== ULONG_MAX
|| *endptr
!= '\0' || as
< 1 || as
> 65535)
206 vty_out (vty
, "AS value error%s", VTY_NEWLINE
);
214 DEFUN (neighbor_set_peer_group
,
215 neighbor_set_peer_group_cmd
,
216 NEIGHBOR_CMD
"peer-group WORD",
219 "Member of the peer-group"
222 return peer_conf_peer_group (vty
, argv
[0], argv
[1]);
225 /* Set BGP's router identifier. */
227 bgp_router_id_set (struct vty
*vty
, char *id_str
)
232 struct peer_conf
*conf
;
235 ret
= inet_aton (id_str
, &id
);
238 vty_out (vty
, "Malformed bgp router identifier%s", VTY_NEWLINE
);
242 /* Set identifier to BGP structure. */
245 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_ROUTER_ID
)
246 && bgp
->id
.s_addr
== id
.s_addr
)
250 SET_FLAG (bgp
->config
, BGP_CONFIG_ROUTER_ID
);
252 /* Set all peer's local identifier with this value. */
253 LIST_LOOP (bgp
->peer_conf
, conf
, nn
)
255 conf
->peer
->local_id
= id
;
256 /* Reset all BGP sessions */
257 BGP_EVENT_ADD (conf
->peer
, BGP_Stop
);
263 /* Unset BGP router identifier. */
265 bgp_router_id_unset (struct vty
*vty
, char *id_str
)
270 struct peer_conf
*conf
;
277 ret
= inet_aton (id_str
, &id
);
280 vty_out (vty
, "Malformed bgp router identifier%s", VTY_NEWLINE
);
284 if (!IPV4_ADDR_SAME (&bgp
->id
, &id
))
286 vty_out (vty
, "bgp router-id doesn't match%s", VTY_NEWLINE
);
291 if (! CHECK_FLAG (bgp
->config
, BGP_CONFIG_ROUTER_ID
))
295 UNSET_FLAG (bgp
->config
, BGP_CONFIG_ROUTER_ID
);
297 LIST_LOOP (bgp
->peer_conf
, conf
, nn
)
299 conf
->peer
->local_id
.s_addr
= 0;
302 /* Set router-id from interface's address. */
303 bgp_if_update_all ();
305 /* Reset all BGP sessions */
306 LIST_LOOP (bgp
->peer_conf
, conf
, nn
)
308 BGP_EVENT_ADD (conf
->peer
, BGP_Stop
);
314 DEFUN (bgp_router_id
, bgp_router_id_cmd
,
315 "bgp router-id A.B.C.D",
316 "BGP specific commands\n"
317 "Override configured router identifier\n"
318 "Manually configured router identifier\n")
320 return bgp_router_id_set (vty
, argv
[0]);
323 DEFUN (no_bgp_router_id
, no_bgp_router_id_cmd
,
326 "BGP specific commands\n"
327 "Override configured router identifier\n")
330 return bgp_router_id_unset (vty
, NULL
);
332 return bgp_router_id_unset (vty
, argv
[0]);
335 ALIAS (no_bgp_router_id
, no_bgp_router_id_val_cmd
,
336 "no bgp router-id A.B.C.D",
338 "BGP specific commands\n"
339 "Override configured router identifier\n"
340 "Manually configured router identifier\n")
342 /* Set BGP's global timers. */
344 bgp_timers_set (struct vty
*vty
, char *keep_str
, char *hold_str
, int set
)
347 struct peer_conf
*conf
;
349 unsigned long keepalive
= 0;
350 unsigned long holdtime
= 0;
355 /* keepalive value check. */
356 keepalive
= strtoul (keep_str
, &endptr
, 10);
358 if (keepalive
== ULONG_MAX
|| *endptr
!= '\0')
360 vty_out (vty
, "%% keepalive time value must be positive integer%s",
364 if (keepalive
> 65535)
366 vty_out (vty
, "%% keepalive time value must be <0-65535>%s", VTY_NEWLINE
);
370 /* Holdtime value check. */
371 holdtime
= strtoul (hold_str
, &endptr
, 10);
373 if (holdtime
== ULONG_MAX
|| *endptr
!= '\0')
375 vty_out (vty
, "%% hold time value must be positive integer%s", VTY_NEWLINE
);
378 if (holdtime
> 65535)
380 vty_out (vty
, "%% hold time value must be <0,3-65535>%s", VTY_NEWLINE
);
383 if (holdtime
< 3 && holdtime
!= 0)
385 vty_out (vty
, "%% hold time value must be either 0 or greater than 3%s",
391 /* Set identifier to BGP structure. */
394 /* Set value to the configuration. */
397 bgp
->default_holdtime
= holdtime
;
398 bgp
->default_keepalive
= (keepalive
< holdtime
/ 3 ? keepalive
: holdtime
/ 3);
402 bgp
->default_holdtime
= BGP_DEFAULT_HOLDTIME
;
403 bgp
->default_keepalive
= BGP_DEFAULT_KEEPALIVE
;
406 /* Set all peer's global timers with this value. */
407 LIST_LOOP (bgp
->peer_conf
, conf
, nn
)
409 conf
->peer
->global_holdtime
= bgp
->default_holdtime
;
410 conf
->peer
->global_keepalive
= bgp
->default_keepalive
;
416 DEFUN (bgp_timers
, bgp_timers_cmd
,
417 "timers bgp <0-65535> <0-65535>",
418 "Adjust routing timers\n"
420 "Keepalive interval\n"
423 return bgp_timers_set (vty
, argv
[0], argv
[1], 1);
426 DEFUN (no_bgp_timers
, no_bgp_timers_cmd
,
429 "Adjust routing timers\n"
432 return bgp_timers_set (vty
, NULL
, NULL
, 0);
435 /* BGP's cluster-id control. */
437 bgp_cluster_id_set (struct vty
*vty
, char *cluster_str
)
441 struct in_addr cluster
;
443 ret
= inet_aton (cluster_str
, &cluster
);
446 vty_out (vty
, "Malformed bgp cluster identifier%s", VTY_NEWLINE
);
450 bgp
->cluster
= cluster
;
451 bgp
->config
|= BGP_CONFIG_CLUSTER_ID
;
457 bgp_cluster_id_unset (struct vty
*vty
, char *cluster_str
)
461 struct in_addr cluster
;
467 ret
= inet_aton (cluster_str
, &cluster
);
470 vty_out (vty
, "Malformed bgp cluster identifier%s", VTY_NEWLINE
);
473 if (! IPV4_ADDR_SAME (&bgp
->cluster
, &cluster
))
475 vty_out (vty
, "bgp cluster-id doesn't match%s", VTY_NEWLINE
);
479 bgp
->cluster
.s_addr
= 0;
480 bgp
->config
&= ~BGP_CONFIG_CLUSTER_ID
;
485 DEFUN (bgp_cluster_id
, bgp_cluster_id_cmd
,
486 "bgp cluster-id A.B.C.D",
487 "BGP specific commands\n"
488 "Configure Route-Reflector Cluster-id\n"
489 "Route-Reflector Cluster-id in IP address format\n")
491 return bgp_cluster_id_set (vty
, argv
[0]);
494 ALIAS (bgp_cluster_id
, bgp_cluster_id32_cmd
,
495 "bgp cluster-id <1-4294967295>",
496 "BGP specific commands\n"
497 "Configure Route-Reflector Cluster-id\n"
498 "Route-Reflector Cluster-id as 32 bit quantity\n")
500 DEFUN (no_bgp_cluster_id
, no_bgp_cluster_id_cmd
,
503 "BGP specific commands\n"
504 "Configure Route-Reflector Cluster-id\n")
507 return bgp_cluster_id_unset (vty
, NULL
);
509 return bgp_cluster_id_unset (vty
, argv
[0]);
512 ALIAS (no_bgp_cluster_id
, no_bgp_cluster_id_val_cmd
,
513 "no bgp cluster-id A.B.C.D",
515 "BGP specific commands\n"
516 "Configure Route-Reflector Cluster-id\n"
517 "Route-Reflector Cluster-id in IP address format\n")
520 bgp_confederation_id_set (struct vty
*vty
, char *id_str
)
527 int old_confed_flag
; /* Old Confederations status */
533 as
= strtoul (id_str
, &endptr
, 10);
534 if (as
== ULONG_MAX
|| *endptr
!= '\0' || as
< 1 || as
> 65535)
536 vty_out (vty
, "AS value error%s", VTY_NEWLINE
);
540 /* Remember - were we doing CONFEDs before? */
541 old_confed_flag
= CHECK_FLAG (bgp
->config
, BGP_CONFIG_CONFEDERATION
);
542 bgp
->confederation_id
= as
;
543 SET_FLAG (bgp
->config
, BGP_CONFIG_CONFEDERATION
);
546 * how to handle already setup peers?
547 * Answer - If we were doing CONFEDs already
548 * - this is just an external AS change
549 * - just Reset EBGP sessions, not CONFED sessions
550 * If we were not doing CONFEDs before
551 * - Reset all EBGP sessions
553 LIST_LOOP (peer_list
, peer
, nn
)
555 /* We're looking for peers who's AS is not local or part of
559 if (peer_sort (peer
) == BGP_PEER_EBGP
)
562 BGP_EVENT_ADD (peer
, BGP_Stop
);
567 /* Not doign CONFEDs before, so reset every non-local
569 if (peer_sort (peer
) != BGP_PEER_IBGP
)
571 /* Reset the local_as to be our EBGP one */
572 if (peer_sort (peer
) == BGP_PEER_EBGP
)
574 BGP_EVENT_ADD (peer
, BGP_Stop
);
582 vty_out (vty
, "No AS Number provided%s", VTY_NEWLINE
);
589 bgp_confederation_id_unset (struct vty
*vty
, char *id_str
)
601 as
= strtoul (id_str
, &endptr
, 10);
602 if (as
== ULONG_MAX
|| *endptr
!= '\0' || as
< 1 || as
> 65535)
604 vty_out (vty
, "%% AS value error%s", VTY_NEWLINE
);
608 if (bgp
->confederation_id
!= as
)
610 vty_out (vty
, "%% AS value does not match%s", VTY_NEWLINE
);
614 bgp
->confederation_id
= 0;
615 UNSET_FLAG (bgp
->config
, BGP_CONFIG_CONFEDERATION
);
618 * How do we handle all EBGP peers if we have no external AS?
619 * Assumption - No Confed ID == no CONFEDERATIONS, so
620 * clear all EBGP *AND* CONFED peers and bring up with no spoofing.
622 LIST_LOOP (peer_list
, peer
, nn
)
624 /* We're looking for peers who's AS is not local */
625 if (peer_sort (peer
) != BGP_PEER_IBGP
)
627 peer
->local_as
= bgp
->as
;
628 BGP_EVENT_ADD (peer
, BGP_Stop
);
635 vty_out (vty
, "%% No AS Number provided%s", VTY_NEWLINE
);
641 /* Is an AS part of the confed or not? */
643 bgp_confederation_peers_check (struct bgp
*bgp
, as_t as
)
650 for(i
= 0; i
< bgp
->confederation_peers_cnt
; i
++)
652 if (bgp
->confederation_peers
[i
] == as
)
659 /* Add an AS to the CONFED set */
661 bgp_confederation_peers_add (struct bgp
*bgp
, as_t as
)
663 bgp
->confederation_peers
= XREALLOC (MTYPE_BGP_CONFED_LIST
,
664 bgp
->confederation_peers
,
665 bgp
->confederation_peers_cnt
+ 1);
666 bgp
->confederation_peers
[bgp
->confederation_peers_cnt
] = as
;
667 bgp
->confederation_peers_cnt
++;
671 bgp_confederation_peers_remove (struct bgp
*bgp
, as_t as
)
676 for(i
= 0; i
< bgp
->confederation_peers_cnt
; i
++)
678 if(bgp
->confederation_peers
[i
] == as
)
680 /* Remove this entry */
681 for(j
= i
+1; j
< bgp
->confederation_peers_cnt
; j
++)
683 bgp
->confederation_peers
[j
-1] = bgp
->confederation_peers
[j
];
688 bgp
->confederation_peers_cnt
--;
690 if (bgp
->confederation_peers_cnt
== 0)
692 bgp
->confederation_peers
= NULL
;
696 bgp
->confederation_peers
= XREALLOC(MTYPE_BGP_CONFED_LIST
,
697 bgp
->confederation_peers
,
698 bgp
->confederation_peers_cnt
);
703 bgp_confederation_peers_set (struct vty
*vty
, int argc
, char *argv
[])
712 for(i
= 0; i
< argc
; i
++)
714 as
= strtoul (argv
[i
], &endptr
, 10);
715 if (as
== ULONG_MAX
|| as
< 1 || as
> 65535)
717 vty_out (vty
, "AS Value error (%s), ignoring%s",
718 argv
[i
], VTY_NEWLINE
);
724 vty_out (vty
, "%% Local member-AS not allowed in confed peer list%s",
728 if (! bgp_confederation_peers_check (bgp
, as
))
733 /* Its not there already, so add it */
734 bgp_confederation_peers_add (bgp
, as
);
736 /* Now reset any peer who's remote AS has just joined
737 the CONFED unless its an iBGP peer */
738 LIST_LOOP (peer_list
, peer
, nn
)
742 /* If the AS added to the list */
743 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_CONFEDERATION
))
745 peer
->local_as
= bgp
->as
;
746 BGP_EVENT_ADD (peer
, BGP_Stop
);
753 /* Silently ignore repeated ASs */
761 bgp_confederation_peers_unset (struct vty
*vty
, int argc
, char *argv
[])
770 for(i
= 0; i
< argc
; i
++)
772 as
= strtoul (argv
[i
], &endptr
, 10);
774 if (as
== ULONG_MAX
|| as
< 1 || as
> 65535)
777 if (! bgp_confederation_peers_check(bgp
, as
))
779 /* Its not there already, so silently ignore this*/
786 /* Its there - we need to remove it */
787 bgp_confederation_peers_remove (bgp
, as
);
789 /* Now reset any peer who's remote AS has just been
790 removed from the CONFED */
791 LIST_LOOP (peer_list
, peer
, nn
)
795 /* Set the peer's local-as correctly */
796 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_CONFEDERATION
))
798 peer
->local_as
= bgp
->confederation_id
;
799 BGP_EVENT_ADD (peer
, BGP_Stop
);
809 bgp_confederation_peers_print (struct vty
*vty
, struct bgp
*bgp
)
813 for(i
= 0; i
< bgp
->confederation_peers_cnt
; i
++)
817 vty_out(vty
, "%d", bgp
->confederation_peers
[i
]);
821 DEFUN (bgp_confederation_peers
, bgp_confederation_peers_cmd
,
822 "bgp confederation peers .<1-65535>",
823 "BGP specific commands\n"
824 "AS confederation parameters\n"
825 "Peer ASs in BGP confederation\n"
828 return bgp_confederation_peers_set(vty
, argc
, argv
);
831 DEFUN (bgp_confederation_identifier
, bgp_confederation_identifier_cmd
,
832 "bgp confederation identifier <1-65535>",
833 "BGP specific commands\n"
834 "AS confederation parameters\n"
836 "Set routing domain confederation AS\n")
838 return bgp_confederation_id_set(vty
, argv
[0]);
841 DEFUN (no_bgp_confederation_peers
, no_bgp_confederation_peers_cmd
,
842 "no bgp confederation peers .<1-65535>",
844 "BGP specific commands\n"
845 "AS confederation parameters\n"
846 "Peer ASs in BGP confederation\n"
849 return bgp_confederation_peers_unset(vty
, argc
, argv
);
852 DEFUN (no_bgp_confederation_identifier
, no_bgp_confederation_identifier_cmd
,
853 "no bgp confederation identifier <1-65535>",
855 "BGP specific commands\n"
856 "AS confederation parameters\n"
858 "Set routing domain confederation AS\n")
860 return bgp_confederation_id_unset(vty
, argv
[0]);
863 /* "no bgp client-to-client reflection" configuration. */
864 DEFUN (no_bgp_client_to_client_reflection
,
865 no_bgp_client_to_client_reflection_cmd
,
866 "no bgp client-to-client reflection",
868 "BGP specific commands\n"
869 "Configure client to client route reflection\n"
870 "reflection of routes allowed\n")
875 SET_FLAG (bgp
->config
, BGP_CONFIG_NO_CLIENT_TO_CLIENT
);
879 DEFUN (bgp_client_to_client_reflection
,
880 bgp_client_to_client_reflection_cmd
,
881 "bgp client-to-client reflection",
882 "BGP specific commands\n"
883 "Configure client to client route reflection\n"
884 "reflection of routes allowed\n")
889 UNSET_FLAG (bgp
->config
, BGP_CONFIG_NO_CLIENT_TO_CLIENT
);
893 /* "bgp always-compare-med" configuration. */
894 DEFUN (bgp_always_compare_med
,
895 bgp_always_compare_med_cmd
,
896 "bgp always-compare-med",
897 "BGP specific commands\n"
898 "Allow comparing MED from different neighbors\n")
903 SET_FLAG (bgp
->config
, BGP_CONFIG_ALWAYS_COMPARE_MED
);
907 DEFUN (no_bgp_always_compare_med
,
908 no_bgp_always_compare_med_cmd
,
909 "no bgp always-compare-med",
911 "BGP specific commands\n"
912 "Allow comparing MED from different neighbors\n")
917 UNSET_FLAG (bgp
->config
, BGP_CONFIG_ALWAYS_COMPARE_MED
);
921 /* "bgp deterministic-med" configuration. */
922 DEFUN (bgp_deterministic_med
,
923 bgp_deterministic_med_cmd
,
924 "bgp deterministic-med",
925 "BGP specific commands\n"
926 "Pick the best-MED path among paths advertised from the neighboring AS\n")
931 SET_FLAG (bgp
->config
, BGP_CONFIG_DETERMINISTIC_MED
);
935 DEFUN (no_bgp_deterministic_med
,
936 no_bgp_deterministic_med_cmd
,
937 "no bgp deterministic-med",
939 "BGP specific commands\n"
940 "Pick the best-MED path among paths advertised from the neighboring AS\n")
945 UNSET_FLAG (bgp
->config
, BGP_CONFIG_DETERMINISTIC_MED
);
949 /* "bgp enforce-first-as" configuration. */
950 DEFUN (bgp_enforce_first_as
,
951 bgp_enforce_first_as_cmd
,
952 "bgp enforce-first-as",
954 "Enforce the first AS for EBGP routes\n")
959 SET_FLAG (bgp
->config
, BGP_CONFIG_ENFORCE_FIRST_AS
);
963 DEFUN (no_bgp_enforce_first_as
,
964 no_bgp_enforce_first_as_cmd
,
965 "no bgp enforce-first-as",
968 "Enforce the first AS for EBGP routes\n")
973 UNSET_FLAG (bgp
->config
, BGP_CONFIG_ENFORCE_FIRST_AS
);
977 /* "bgp bestpath compare-routerid" configuration. */
978 DEFUN (bgp_bestpath_compare_router_id
,
979 bgp_bestpath_compare_router_id_cmd
,
980 "bgp bestpath compare-routerid",
981 "BGP specific commands\n"
982 "Change the default bestpath selection\n"
983 "Compare router-id for identical EBGP paths\n")
988 SET_FLAG (bgp
->config
, BGP_CONFIG_COMPARE_ROUTER_ID
);
992 DEFUN (no_bgp_bestpath_compare_router_id
,
993 no_bgp_bestpath_compare_router_id_cmd
,
994 "no bgp bestpath compare-routerid",
996 "BGP specific commands\n"
997 "Change the default bestpath selection\n"
998 "Compare router-id for identical EBGP paths\n")
1003 UNSET_FLAG (bgp
->config
, BGP_CONFIG_COMPARE_ROUTER_ID
);
1007 /* "bgp bestpath as-path ignore" configuration. */
1008 DEFUN (bgp_bestpath_aspath_ignore
,
1009 bgp_bestpath_aspath_ignore_cmd
,
1010 "bgp bestpath as-path ignore",
1011 "BGP specific commands\n"
1012 "Change the default bestpath selection\n"
1013 "AS-path attribute\n"
1014 "Ignore as-path length in selecting a route\n")
1019 SET_FLAG (bgp
->config
, BGP_CONFIG_ASPATH_IGNORE
);
1023 DEFUN (no_bgp_bestpath_aspath_ignore
,
1024 no_bgp_bestpath_aspath_ignore_cmd
,
1025 "no bgp bestpath as-path ignore",
1027 "BGP specific commands\n"
1028 "Change the default bestpath selection\n"
1029 "AS-path attribute\n"
1030 "Ignore as-path length in selecting a route\n")
1035 UNSET_FLAG (bgp
->config
, BGP_CONFIG_ASPATH_IGNORE
);
1040 /* "bgp bestpath med" configuration. */
1041 DEFUN (bgp_bestpath_med
,
1042 bgp_bestpath_med_cmd
,
1043 "bgp bestpath med (confed|missing-as-worst)",
1044 "BGP specific commands\n"
1045 "Change the default bestpath selection\n"
1047 "Compare MED among confederation paths\n"
1048 "Treat missing MED as the least preferred one\n")
1054 if (strcmp (argv
[0], "confed") == 0)
1055 SET_FLAG (bgp
->config
, BGP_CONFIG_MED_CONFED
);
1057 SET_FLAG (bgp
->config
, BGP_CONFIG_MED_MISSING_AS_WORST
);
1062 DEFUN (bgp_bestpath_med2
,
1063 bgp_bestpath_med2_cmd
,
1064 "bgp bestpath med confed missing-as-worst",
1065 "BGP specific commands\n"
1066 "Change the default bestpath selection\n"
1068 "Compare MED among confederation paths\n"
1069 "Treat missing MED as the least preferred one\n")
1074 SET_FLAG (bgp
->config
, BGP_CONFIG_MED_CONFED
);
1075 SET_FLAG (bgp
->config
, BGP_CONFIG_MED_MISSING_AS_WORST
);
1079 ALIAS (bgp_bestpath_med2
,
1080 bgp_bestpath_med3_cmd
,
1081 "bgp bestpath med missing-as-worst confed",
1082 "BGP specific commands\n"
1083 "Change the default bestpath selection\n"
1085 "Treat missing MED as the least preferred one\n"
1086 "Compare MED among confederation paths\n")
1088 DEFUN (no_bgp_bestpath_med
,
1089 no_bgp_bestpath_med_cmd
,
1090 "no bgp bestpath med (confed|missing-as-worst)",
1092 "BGP specific commands\n"
1093 "Change the default bestpath selection\n"
1095 "Compare MED among confederation paths\n"
1096 "Treat missing MED as the least preferred one\n")
1102 if (strcmp (argv
[0], "confed") == 0)
1103 UNSET_FLAG (bgp
->config
, BGP_CONFIG_MED_CONFED
);
1105 UNSET_FLAG (bgp
->config
, BGP_CONFIG_MED_MISSING_AS_WORST
);
1110 DEFUN (no_bgp_bestpath_med2
,
1111 no_bgp_bestpath_med2_cmd
,
1112 "no bgp bestpath med confed missing-as-worst",
1114 "BGP specific commands\n"
1115 "Change the default bestpath selection\n"
1117 "Compare MED among confederation paths\n"
1118 "Treat missing MED as the least preferred one\n")
1123 UNSET_FLAG (bgp
->config
, BGP_CONFIG_MED_CONFED
);
1124 UNSET_FLAG (bgp
->config
, BGP_CONFIG_MED_MISSING_AS_WORST
);
1128 ALIAS (no_bgp_bestpath_med2
,
1129 no_bgp_bestpath_med3_cmd
,
1130 "no bgp bestpath med missing-as-worst confed",
1132 "BGP specific commands\n"
1133 "Change the default bestpath selection\n"
1135 "Treat missing MED as the least preferred one\n"
1136 "Compare MED among confederation paths\n")
1138 DEFUN (no_bgp_default_ipv4_unicast
,
1139 no_bgp_default_ipv4_unicast_cmd
,
1140 "no bgp default ipv4-unicast",
1142 "BGP specific commands\n"
1143 "Configure BGP defaults\n"
1144 "Activate ipv4-unicast for a peer by default\n")
1149 SET_FLAG (bgp
->config
, BGP_CONFIG_NO_DEFAULT_IPV4
);
1153 DEFUN (bgp_default_ipv4_unicast
,
1154 bgp_default_ipv4_unicast_cmd
,
1155 "bgp default ipv4-unicast",
1156 "BGP specific commands\n"
1157 "Configure BGP defaults\n"
1158 "Activate ipv4-unicast for a peer by default\n")
1163 UNSET_FLAG (bgp
->config
, BGP_CONFIG_NO_DEFAULT_IPV4
);
1167 /* "bgp import-check" configuration. */
1168 DEFUN (bgp_network_import_check
,
1169 bgp_network_import_check_cmd
,
1170 "bgp network import-check",
1171 "BGP specific commands\n"
1172 "BGP network command\n"
1173 "Check BGP network route exists in IGP\n")
1178 SET_FLAG (bgp
->config
, BGP_CONFIG_IMPORT_CHECK
);
1182 DEFUN (no_bgp_network_import_check
,
1183 no_bgp_network_import_check_cmd
,
1184 "no bgp network import-check",
1186 "BGP specific commands\n"
1187 "BGP network command\n"
1188 "Check BGP network route exists in IGP\n")
1193 UNSET_FLAG (bgp
->config
, BGP_CONFIG_IMPORT_CHECK
);
1197 DEFUN (bgp_default_local_preference
,
1198 bgp_default_local_preference_cmd
,
1199 "bgp default local-preference <0-4294967295>",
1200 "BGP specific commands\n"
1201 "Configure BGP defaults\n"
1202 "local preference (higher=more preferred)\n"
1203 "Configure default local preference value\n")
1208 bgp
->default_local_pref
= atoi(argv
[0]);
1212 DEFUN (no_bgp_default_local_preference
,
1213 no_bgp_default_local_preference_cmd
,
1214 "no bgp default local-preference",
1216 "BGP specific commands\n"
1217 "Configure BGP defaults\n"
1218 "local preference (higher=more preferred)\n")
1223 bgp
->default_local_pref
= BGP_DEFAULT_LOCAL_PREF
;
1227 ALIAS (no_bgp_default_local_preference
,
1228 no_bgp_default_local_preference_val_cmd
,
1229 "no bgp default local-preference <0-4294967295>",
1231 "BGP specific commands\n"
1232 "Configure BGP defaults\n"
1233 "local preference (higher=more preferred)\n"
1234 "Configure default local preference value\n")
1236 /* allocate new peer object */
1243 /* Allocate new peer. */
1244 peer
= XMALLOC (MTYPE_BGP_PEER
, sizeof (struct peer
));
1245 memset (peer
, 0, sizeof (struct peer
));
1247 /* Set default value. */
1249 peer
->v_start
= BGP_INIT_START_TIMER
;
1250 peer
->v_connect
= BGP_DEFAULT_CONNECT_RETRY
;
1251 peer
->v_holdtime
= BGP_DEFAULT_HOLDTIME
;
1252 peer
->v_keepalive
= BGP_DEFAULT_KEEPALIVE
;
1253 peer
->v_asorig
= BGP_DEFAULT_ASORIGINATE
;
1254 peer
->v_routeadv
= BGP_DEFAULT_ROUTEADV
;
1255 peer
->status
= Idle
;
1256 peer
->ostatus
= Idle
;
1257 peer
->version
= BGP_VERSION_4
;
1259 peer
->translate_update
= 0;
1260 SET_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
], PEER_FLAG_SEND_COMMUNITY
);
1261 SET_FLAG (peer
->af_flags
[AFI_IP
][SAFI_MULTICAST
], PEER_FLAG_SEND_COMMUNITY
);
1262 SET_FLAG (peer
->af_flags
[AFI_IP
][SAFI_MPLS_VPN
], PEER_FLAG_SEND_COMMUNITY
);
1263 SET_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
], PEER_FLAG_SEND_COMMUNITY
);
1264 SET_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_MULTICAST
], PEER_FLAG_SEND_COMMUNITY
);
1265 SET_FLAG (peer
->af_flags
[AFI_IP
][SAFI_UNICAST
], PEER_FLAG_SEND_EXT_COMMUNITY
);
1266 SET_FLAG (peer
->af_flags
[AFI_IP
][SAFI_MULTICAST
], PEER_FLAG_SEND_EXT_COMMUNITY
);
1267 SET_FLAG (peer
->af_flags
[AFI_IP
][SAFI_MPLS_VPN
], PEER_FLAG_SEND_EXT_COMMUNITY
);
1268 SET_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_UNICAST
], PEER_FLAG_SEND_EXT_COMMUNITY
);
1269 SET_FLAG (peer
->af_flags
[AFI_IP6
][SAFI_MULTICAST
], PEER_FLAG_SEND_EXT_COMMUNITY
);
1270 SET_FLAG (peer
->flags
, PEER_FLAG_CAPABILITY_ROUTE_REFRESH
);
1271 SET_FLAG (peer
->sflags
, PEER_STATUS_CAPABILITY_OPEN
);
1273 peer
->ibuf
= stream_new (BGP_MAX_PACKET_SIZE
);
1274 peer
->obuf
= stream_fifo_new ();
1275 peer
->conf
= list_new ();
1277 peer
->adj_in
[AFI_IP
][SAFI_UNICAST
] = route_table_init ();
1278 peer
->adj_in
[AFI_IP
][SAFI_MULTICAST
] = route_table_init ();
1279 peer
->adj_in
[AFI_IP6
][SAFI_UNICAST
] = route_table_init ();
1280 peer
->adj_in
[AFI_IP6
][SAFI_MULTICAST
] = route_table_init ();
1282 peer
->adj_out
[AFI_IP
][SAFI_UNICAST
] = route_table_init ();
1283 peer
->adj_out
[AFI_IP
][SAFI_MULTICAST
] = route_table_init ();
1284 peer
->adj_out
[AFI_IP
][SAFI_MPLS_VPN
] = route_table_init ();
1285 peer
->adj_out
[AFI_IP6
][SAFI_UNICAST
] = route_table_init ();
1286 peer
->adj_out
[AFI_IP6
][SAFI_MULTICAST
] = route_table_init ();
1288 /* Get service port number. */
1289 sp
= getservbyname ("bgp", "tcp");
1290 peer
->port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs(sp
->s_port
);
1295 /* Check peer's AS number and determin is this peer IBPG or EBGP */
1297 peer_sort (struct peer
*peer
)
1299 /* Find the relevant BGP structure */
1301 struct peer_conf
*conf
;
1302 struct listnode
*nn
;
1304 /* This becomes slightly more complicated as we have to find the
1305 CONFEDERATION list, so we can see if this is a BGP_PEER_CONFED */
1307 LIST_LOOP (peer
->conf
, conf
, nn
)
1312 if(bgp
&& CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
1314 if (peer
->local_as
== 0)
1315 return BGP_PEER_INTERNAL
;
1317 if (peer
->local_as
== peer
->as
)
1319 if (peer
->local_as
== bgp
->confederation_id
)
1320 return BGP_PEER_EBGP
;
1322 return BGP_PEER_IBGP
;
1325 if (bgp_confederation_peers_check(bgp
, peer
->as
))
1326 return BGP_PEER_CONFED
;
1328 return BGP_PEER_EBGP
;
1332 return (peer
->local_as
== 0
1333 ? BGP_PEER_INTERNAL
: peer
->local_as
== peer
->as
1334 ? BGP_PEER_IBGP
: BGP_PEER_EBGP
);
1339 peer_list_cmp (struct peer
*p1
, struct peer
*p2
)
1341 return sockunion_cmp (&p1
->su
, &p2
->su
);
1345 peer_conf_cmp (struct peer_conf
*p1
, struct peer_conf
*p2
)
1347 return sockunion_cmp (&p1
->peer
->su
, &p2
->peer
->su
);
1353 struct peer_conf
*pconf
;
1355 pconf
= XMALLOC (MTYPE_PEER_CONF
, sizeof (struct peer_conf
));
1356 memset (pconf
, 0, sizeof (struct peer_conf
));
1361 peer_conf_free (struct peer_conf
*pconf
)
1363 XFREE (MTYPE_PEER_CONF
, pconf
);
1367 peer_conf_delete (struct peer_conf
*conf
)
1372 struct bgp_filter
*filter
;
1374 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1375 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1377 filter
= &conf
->filter
[afi
][safi
];
1379 for (i
= FILTER_IN
; i
< FILTER_MAX
; i
++)
1381 if (filter
->dlist
[i
].name
)
1382 free (filter
->dlist
[i
].name
);
1383 if (filter
->plist
[i
].name
)
1384 free (filter
->plist
[i
].name
);
1385 if (filter
->aslist
[i
].name
)
1386 free (filter
->aslist
[i
].name
);
1387 if (filter
->map
[i
].name
)
1388 free (filter
->map
[i
].name
);
1391 peer_conf_free (conf
);
1394 /* BGP instance creation by `router bgp' commands. */
1402 bgp
= XMALLOC (MTYPE_BGP
, sizeof (struct bgp
));
1403 memset (bgp
, 0, sizeof (struct bgp
));
1405 bgp
->peer_group
= list_new ();
1406 bgp
->peer_conf
= list_new ();
1407 bgp
->peer_conf
->cmp
= (int (*)(void *, void *)) peer_conf_cmp
;
1409 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1410 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1412 bgp
->route
[afi
][safi
] = route_table_init ();
1413 bgp
->aggregate
[afi
][safi
] = route_table_init ();
1414 bgp
->rib
[afi
][safi
] = route_table_init ();
1417 bgp
->default_local_pref
= BGP_DEFAULT_LOCAL_PREF
;
1418 bgp
->default_holdtime
= BGP_DEFAULT_HOLDTIME
;
1419 bgp
->default_keepalive
= BGP_DEFAULT_KEEPALIVE
;
1424 /* Return first entry of BGP. */
1429 return bgp_list
->head
->data
;
1433 /* Lookup BGP entry. */
1435 bgp_lookup (as_t as
, char *name
)
1438 struct listnode
*nn
;
1440 LIST_LOOP (bgp_list
, bgp
, nn
)
1442 && ((bgp
->name
== NULL
&& name
== NULL
)
1443 || (bgp
->name
&& name
&& strcmp (bgp
->name
, name
) == 0)))
1448 /* Lookup BGP structure by view name. */
1450 bgp_lookup_by_name (char *name
)
1453 struct listnode
*nn
;
1455 LIST_LOOP (bgp_list
, bgp
, nn
)
1456 if ((bgp
->name
== NULL
&& name
== NULL
)
1457 || (bgp
->name
&& name
&& strcmp (bgp
->name
, name
) == 0))
1462 /* Called from VTY commands. */
1464 bgp_get (struct vty
*vty
, as_t as
, char *name
)
1468 /* Multiple instance check. */
1469 if (! bgp_multiple_instance
)
1473 vty_out (vty
, "Please specify 'bgp multiple-instance' first%s",
1478 /* Get first BGP structure if exists. */
1479 bgp
= bgp_get_default ();
1485 vty_out (vty
, "BGP is already running; AS is %d%s", bgp
->as
,
1489 vty
->node
= BGP_NODE
;
1494 bgp
= bgp_create ();
1496 listnode_add (bgp_list
, bgp
);
1497 bgp_if_update_all ();
1498 vty
->node
= BGP_NODE
;
1504 bgp
= bgp_lookup (as
, name
);
1508 vty
->node
= BGP_NODE
;
1513 bgp
= bgp_create ();
1516 bgp
->name
= strdup (name
);
1517 listnode_add (bgp_list
, bgp
);
1518 bgp_if_update_all ();
1519 vty
->node
= BGP_NODE
;
1528 bgp_get_by_str (struct vty
*vty
, char *as_str
, char *name
)
1530 char *endptr
= NULL
;
1533 /* Convert string to number. */
1534 as
= strtoul (as_str
, &endptr
, 10);
1535 if (as
== ULONG_MAX
|| *endptr
!= '\0' || as
< 1 || as
> 65535)
1537 vty_out (vty
, "AS value error%s", VTY_NEWLINE
);
1540 return bgp_get (vty
, as
, name
);
1543 /* Delete BGP instance. */
1545 bgp_delete (struct bgp
*bgp
)
1547 struct peer_conf
*conf
;
1548 struct listnode
*nn
;
1549 struct listnode
*next
;
1553 /* Delete static route. */
1554 bgp_static_delete (bgp
);
1556 bgp
->peer_group
->del
= (void (*)(void *)) peer_group_free
;
1558 list_delete (bgp
->peer_group
);
1560 for (nn
= bgp
->peer_conf
->head
; nn
; nn
= next
)
1564 peer_delete (conf
->peer
);
1567 /* Clear peer_conf */
1568 list_delete (bgp
->peer_conf
);
1570 listnode_delete (bgp_list
, bgp
);
1575 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
1576 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
1578 if (bgp
->route
[afi
][safi
])
1579 XFREE (MTYPE_ROUTE_TABLE
, bgp
->route
[afi
][safi
]);
1580 if (bgp
->aggregate
[afi
][safi
])
1581 XFREE (MTYPE_ROUTE_TABLE
,bgp
->aggregate
[afi
][safi
]) ;
1582 if (bgp
->rib
[afi
][safi
])
1583 XFREE (MTYPE_ROUTE_TABLE
,bgp
->rib
[afi
][safi
]);
1586 XFREE (MTYPE_BGP
, bgp
);
1589 /* This function is called from VTY command. Act as a wrapper of
1592 bgp_destroy (struct vty
*vty
, char *as_str
, char *name
)
1595 char *endptr
= NULL
;
1597 /* struct in_addr id; */
1599 /* Convert string to number. */
1600 as
= strtoul (as_str
, &endptr
, 10);
1601 if (as
== ULONG_MAX
|| *endptr
!= '\0' || as
< 1 || as
> 65535)
1603 vty_out (vty
, "AS value error%s", VTY_NEWLINE
);
1607 /* Lookup bgp structure. */
1608 bgp
= bgp_lookup (as
, name
);
1612 vty_out (vty
, "Can't find BGP instance%s", VTY_NEWLINE
);
1621 /* `router bgp' commands. */
1624 "router bgp <1-65535>",
1629 return bgp_get_by_str (vty
, argv
[0], NULL
);
1632 DEFUN (router_bgp_view
,
1633 router_bgp_view_cmd
,
1634 "router bgp <1-65535> view WORD",
1641 return bgp_get_by_str (vty
, argv
[0], argv
[1]);
1644 /* `no router bgp' commands. */
1645 DEFUN (no_router_bgp
,
1647 "no router bgp <1-65535>",
1653 return bgp_destroy (vty
, argv
[0], NULL
);
1656 DEFUN (no_router_bgp_view
,
1657 no_router_bgp_view_cmd
,
1658 "no router bgp <1-65535> view WORD",
1666 return bgp_destroy (vty
, argv
[0], argv
[1]);
1669 /* Peer identification.
1671 Peer structure is identified by it's IP address, local AS number,
1672 remote AS number and local router-id. Normally, local router-id
1673 identification is used only for Merit MRT like route server
1676 When user configure the peer under specific BGP instance node, only
1677 IP address and local AS number are used for looking up. If the
1678 peer's remote AS number and user configuration AS number is
1679 different, the peer's AS number is changed. */
1682 peer_lookup_with_local_as (union sockunion
*su
, as_t local_as
)
1685 struct listnode
*nn
;
1687 LIST_LOOP (peer_list
, peer
, nn
)
1689 if (sockunion_same (&peer
->su
, su
)
1690 && peer
->local_as
== local_as
)
1696 /* Accepting remote BGP connection, at least remote connection's
1697 source IP address is configured as a peer. This function check the
1698 existance of the IP address. */
1701 peer_lookup_by_su (union sockunion
*su
)
1704 struct listnode
*nn
;
1706 LIST_LOOP (peer_list
, peer
, nn
)
1708 if (sockunion_same (&peer
->su
, su
)
1709 && ! CHECK_FLAG (peer
->sflags
, PEER_STATUS_ACCEPT_PEER
))
1715 /* BGP Open packet includes remote router's AS number and router-id.
1716 We lookup local peer with those information. First loop check
1717 exact match peer including remote router-id. Second loop check
1718 anonymous router-id peer. */
1721 peer_lookup_with_open (union sockunion
*su
, as_t remote_as
,
1722 struct in_addr
*remote_id
, int *as
)
1725 struct listnode
*nn
;
1727 LIST_LOOP (peer_list
, peer
, nn
)
1729 if (sockunion_same (&peer
->su
, su
)
1730 && ! CHECK_FLAG (peer
->sflags
, PEER_STATUS_ACCEPT_PEER
))
1732 if (peer
->as
== remote_as
1733 && peer
->remote_id
.s_addr
== remote_id
->s_addr
)
1735 if (peer
->as
== remote_as
)
1739 LIST_LOOP (peer_list
, peer
, nn
)
1741 if (sockunion_same (&peer
->su
, su
)
1742 && ! CHECK_FLAG (peer
->sflags
, PEER_STATUS_ACCEPT_PEER
))
1744 if (peer
->as
== remote_as
1745 && peer
->remote_id
.s_addr
== 0)
1747 if (peer
->as
== remote_as
)
1755 peer_conf_lookup (struct bgp
*bgp
, union sockunion
*su
, int afi
)
1757 struct listnode
*nn
;
1758 struct peer_conf
*conf
;
1760 LIST_LOOP (bgp
->peer_conf
, conf
, nn
)
1762 if (sockunion_same (&conf
->peer
->su
, su
))
1768 /* Utility function for lookup peer from VTY commands. */
1770 peer_conf_lookup_vty (struct vty
*vty
, char *ip_str
, int afi
)
1775 struct peer_conf
*conf
;
1779 ret
= str2sockunion (ip_str
, &su
);
1782 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
1786 conf
= peer_conf_lookup (bgp
, &su
, afi
);
1789 vty_out (vty
, "Can't find peer: %s%s", ip_str
, VTY_NEWLINE
);
1796 peer_conf_lookup_existing (struct bgp
*bgp
, union sockunion
*su
)
1798 struct listnode
*nn
;
1799 struct peer_conf
*conf
;
1801 LIST_LOOP (bgp
->peer_conf
, conf
, nn
)
1803 if (sockunion_same (&conf
->peer
->su
, su
))
1809 #define BGP_UPTIME_LEN 25
1811 /* Display peer uptime. */
1813 peer_uptime (time_t uptime2
, char *buf
, size_t len
)
1818 /* Check buffer length. */
1819 if (len
< BGP_UPTIME_LEN
)
1821 zlog_warn ("peer_uptime (): buffer shortage %d", len
);
1825 /* If there is no connection has been done before print `never'. */
1828 snprintf (buf
, len
, "never ");
1832 /* Get current time. */
1833 uptime1
= time (NULL
);
1835 tm
= gmtime (&uptime1
);
1837 /* Making formatted timer strings. */
1838 #define ONE_DAY_SECOND 60*60*24
1839 #define ONE_WEEK_SECOND 60*60*24*7
1841 if (uptime1
< ONE_DAY_SECOND
)
1842 snprintf (buf
, len
, "%02d:%02d:%02d",
1843 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
);
1844 else if (uptime1
< ONE_WEEK_SECOND
)
1845 snprintf (buf
, len
, "%dd%02dh%02dm",
1846 tm
->tm_yday
, tm
->tm_hour
, tm
->tm_min
);
1848 snprintf (buf
, len
, "%02dw%dd%02dh",
1849 tm
->tm_yday
/7, tm
->tm_yday
- ((tm
->tm_yday
/7) * 7), tm
->tm_hour
);
1853 /* If peer is configured at least one address family return 1. */
1855 peer_active (struct peer
*peer
)
1857 if (peer
->afc
[AFI_IP
][SAFI_UNICAST
]
1858 || peer
->afc
[AFI_IP
][SAFI_MULTICAST
]
1859 || peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
]
1860 || peer
->afc
[AFI_IP6
][SAFI_UNICAST
]
1861 || peer
->afc
[AFI_IP6
][SAFI_MULTICAST
])
1867 peer_create (union sockunion
*su
, as_t local_as
, struct in_addr id
,
1868 as_t remote_as
, u_int32_t holdtime
, u_int32_t keepalive
)
1871 char buf
[SU_ADDRSTRLEN
];
1875 peer
->local_as
= local_as
;
1876 peer
->as
= remote_as
;
1877 peer
->local_id
= id
;
1878 peer
->global_holdtime
= holdtime
;
1879 peer
->global_keepalive
= keepalive
;
1880 listnode_add_sort (peer_list
, peer
);
1882 /* Last read time set */
1883 peer
->readtime
= time(NULL
);
1885 /* Default TTL set. */
1886 peer
->ttl
= (peer_sort (peer
) == BGP_PEER_IBGP
? 255 : 1);
1888 /* Make peer's address string. */
1889 sockunion2str (su
, buf
, SU_ADDRSTRLEN
);
1890 peer
->host
= strdup (buf
);
1892 /* Set up peer's events and timers. */
1893 bgp_timer_set (peer
);
1898 /* Make accept BGP peer. Called from bgp_accept (). */
1900 peer_create_accept ()
1905 listnode_add_sort (peer_list
, peer
);
1910 /* Change peer's AS number */
1912 peer_as_change (struct peer
*peer
, as_t as
)
1919 /* ebgp-multihop reset. */
1925 peer_af_flag_reset (afi_t afi
, safi_t safi
, struct peer_conf
*conf
)
1928 struct bgp_filter
*filter
;
1932 filter
= &conf
->filter
[afi
][safi
];
1934 /* Clear neighbor filter and route-map */
1935 for (i
= FILTER_IN
; i
< FILTER_MAX
; i
++)
1937 if (filter
->dlist
[i
].name
)
1939 free (filter
->dlist
[i
].name
);
1940 filter
->dlist
[i
].name
= NULL
;
1942 if (filter
->plist
[i
].name
)
1944 free (filter
->plist
[i
].name
);
1945 filter
->plist
[i
].name
= NULL
;
1947 if (filter
->aslist
[i
].name
)
1949 free (filter
->aslist
[i
].name
);
1950 filter
->aslist
[i
].name
= NULL
;
1952 if (filter
->map
[i
].name
)
1954 free (filter
->map
[i
].name
);
1955 filter
->map
[i
].name
= NULL
;
1959 /* Clear neighbor next-hop-self */
1960 UNSET_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
);
1962 /* Clear neighbor send-community */
1963 SET_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
);
1964 SET_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SEND_EXT_COMMUNITY
);
1966 /* Clear neighbor route-reflector-client */
1967 UNSET_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
);
1969 /* Clear neighbor route-server-client */
1970 UNSET_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
);
1972 /* Clear neighbor soft-reconfiguration inbound */
1973 UNSET_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
);
1975 /* Clear neighbor maximum-prefix */
1976 conf
->pmax
[afi
][safi
] = 0;
1977 conf
->pmax_warning
[afi
][safi
] = 0;
1981 peer_conf_create (int afi
, int safi
, struct peer
*peer
)
1983 struct peer_conf
*conf
;
1986 /* Make new peer configuration then link it to the peer. */
1987 conf
= peer_conf_new ();
1989 listnode_add_sort (peer
->conf
, conf
);
1991 /* Store peer's active status. */
1992 active
= peer_active (peer
);
1994 if (safi
& SAFI_UNICAST
)
1996 conf
->afc
[afi
][SAFI_UNICAST
] = 1;
1997 peer
->afc
[afi
][SAFI_UNICAST
]++;
1999 if (safi
& SAFI_MULTICAST
)
2001 conf
->afc
[afi
][SAFI_MULTICAST
] = 1;
2002 peer
->afc
[afi
][SAFI_MULTICAST
]++;
2004 if (safi
== SAFI_MPLS_VPN
)
2006 conf
->afc
[afi
][safi
] = 1;
2007 peer
->afc
[afi
][safi
]++;
2010 /* If this configuration activate the peer, set start timer. */
2011 if (! active
&& peer_active (peer
))
2012 bgp_timer_set (peer
);
2018 peer_conf_active (int afi
, int safi
, struct peer_conf
*conf
)
2024 active
= peer_active (peer
);
2026 conf
->afc
[afi
][safi
] = 1;
2027 conf
->peer
->afc
[afi
][safi
]++;
2029 /* If this configuration activate the peer, set start timer. */
2030 if (! active
&& peer_active (peer
))
2031 bgp_timer_set (peer
);
2033 BGP_EVENT_ADD (peer
, BGP_Stop
);
2037 peer_conf_deactive (int afi
, int safi
, struct peer_conf
*conf
)
2043 /* Must be configured. */
2044 if (! conf
->afc
[afi
][safi
])
2047 conf
->afc
[afi
][safi
] = 0;
2048 peer
->afc
[afi
][safi
]--;
2050 /* Clear peer Per AF configuration */
2051 peer_af_flag_reset (afi
, safi
, conf
);
2053 BGP_EVENT_ADD (peer
, BGP_Stop
);
2056 /* Make or change remote peer's AS number. */
2058 peer_remote_as (struct vty
*vty
, char *ip_str
, char *as_str
, int afi
, int safi
)
2062 char *endptr
= NULL
;
2066 struct peer_conf
*conf
;
2068 ret
= str2sockunion (ip_str
, &su
);
2071 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
2075 as
= strtoul (as_str
, &endptr
, 10);
2076 if (as
== ULONG_MAX
|| *endptr
!= '\0' || as
< 1 || as
> 65535)
2078 vty_out (vty
, "AS value error: %s%s", as_str
, VTY_NEWLINE
);
2084 peer
= peer_lookup_with_local_as (&su
, bgp
->as
);
2085 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
) && ! peer
)
2087 peer
= peer_lookup_with_local_as (&su
, bgp
->confederation_id
);
2092 /* Lookup peer_conf */
2093 conf
= peer_conf_lookup (bgp
, &su
, afi
);
2097 /* New peer configuration. */
2098 conf
= peer_conf_create (afi
, safi
, peer
);
2100 listnode_add_sort (bgp
->peer_conf
, conf
);
2103 /* Existing peer's AS number change. */
2105 peer_as_change (peer
, as
);
2107 /* Existing peer's SAFI change. */
2108 /* XXXX need code here. */;
2112 /* Real peer creation. */
2114 /* If the peer is not part of our CONFED, and its not an iBGP peer then
2115 spoof the source AS */
2116 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_CONFEDERATION
)
2117 && ! bgp_confederation_peers_check(bgp
, as
)
2120 peer
= peer_create (&su
, bgp
->confederation_id
,
2121 bgp
->id
, as
, bgp
->default_holdtime
,
2122 bgp
->default_keepalive
);
2126 peer
= peer_create (&su
, bgp
->as
, bgp
->id
, as
,
2127 bgp
->default_holdtime
,
2128 bgp
->default_keepalive
);
2131 /* If this is IPv4 unicast configuration and "no bgp default
2132 ipv4-unicast" is specified. */
2133 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_NO_DEFAULT_IPV4
)
2134 && afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
2135 conf
= peer_conf_create (0, 0, peer
);
2137 conf
= peer_conf_create (afi
, safi
, peer
);
2140 listnode_add_sort (bgp
->peer_conf
, conf
);
2147 peer_activate (struct vty
*vty
, char *ip_str
, int afi
, int safi
)
2152 struct peer_conf
*conf
;
2157 ret
= str2sockunion (ip_str
, &su
);
2160 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
2164 conf
= peer_conf_lookup_existing (bgp
, &su
);
2167 vty_out (vty
, "%% Specify remote-as or peer-group commands first%s",
2172 /* Activate the address family configuration. */
2173 if (! conf
->afc
[afi
][safi
])
2174 peer_conf_active (afi
, safi
, conf
);
2180 peer_deactivate (struct vty
*vty
, char *ip_str
, int afi
, int safi
)
2185 struct peer_conf
*conf
;
2190 ret
= str2sockunion (ip_str
, &su
);
2193 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
2197 conf
= peer_conf_lookup_existing (bgp
, &su
);
2200 vty_out (vty
, "%% Specify remote-as or peer-group commands first%s",
2205 /* De-activate the address family configuration. */
2206 if (conf
->afc
[afi
][safi
])
2207 peer_conf_deactive (afi
, safi
, conf
);
2212 /* Delete peer from confguration. */
2214 peer_delete (struct peer
*peer
)
2216 struct peer_conf
*conf
;
2217 struct listnode
*nn
;
2219 /* Withdraw all information from routing table. We can not use
2220 BGP_EVENT_ADD (peer, BGP_Stop) at here. Because the event is
2221 executed after peer structure is deleted. */
2223 fsm_change_status (peer
, Idle
);
2225 /* Delete peer_conf link from BGP structure. */
2226 LIST_LOOP (peer
->conf
, conf
, nn
)
2228 listnode_delete (conf
->bgp
->peer_conf
, conf
);
2231 /* Free peer_conf structure. */
2232 peer
->conf
->del
= (void (*) (void *)) peer_conf_delete
;
2233 list_delete (peer
->conf
);
2236 /* Stop all timers. */
2237 BGP_TIMER_OFF (peer
->t_start
);
2238 BGP_TIMER_OFF (peer
->t_keepalive
);
2239 BGP_TIMER_OFF (peer
->t_holdtime
);
2240 BGP_TIMER_OFF (peer
->t_connect
);
2241 BGP_TIMER_OFF (peer
->t_asorig
);
2242 BGP_TIMER_OFF (peer
->t_routeadv
);
2244 /* Delete from all peer list. */
2245 listnode_delete (peer_list
, peer
);
2248 stream_free (peer
->ibuf
);
2251 stream_fifo_free (peer
->obuf
);
2253 /* Free allocated host character. */
2257 /* Local and remote addresses. */
2259 XFREE (MTYPE_TMP
, peer
->su_local
);
2260 if (peer
->su_remote
)
2261 XFREE (MTYPE_TMP
, peer
->su_remote
);
2263 if (peer
->adj_in
[AFI_IP
][SAFI_UNICAST
])
2264 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_in
[AFI_IP
][SAFI_UNICAST
] );
2265 if (peer
->adj_in
[AFI_IP
][SAFI_MULTICAST
])
2266 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_in
[AFI_IP
][SAFI_MULTICAST
] );
2267 if (peer
->adj_in
[AFI_IP6
][SAFI_UNICAST
])
2268 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_in
[AFI_IP6
][SAFI_UNICAST
] );
2269 if (peer
->adj_in
[AFI_IP6
][SAFI_MULTICAST
])
2270 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_in
[AFI_IP6
][SAFI_MULTICAST
]);
2271 if (peer
->adj_out
[AFI_IP
][SAFI_UNICAST
])
2272 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_out
[AFI_IP
][SAFI_UNICAST
] );
2273 if (peer
->adj_out
[AFI_IP
][SAFI_MULTICAST
])
2274 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_out
[AFI_IP
][SAFI_MULTICAST
] );
2275 if (peer
->adj_out
[AFI_IP
][SAFI_MPLS_VPN
])
2276 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_out
[AFI_IP
][SAFI_MPLS_VPN
] );
2277 if (peer
->adj_out
[AFI_IP6
][SAFI_UNICAST
])
2278 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_out
[AFI_IP6
][SAFI_UNICAST
] );
2279 if (peer
->adj_out
[AFI_IP6
][SAFI_MULTICAST
])
2280 XFREE (MTYPE_ROUTE_TABLE
,peer
->adj_out
[AFI_IP6
][SAFI_MULTICAST
]);
2282 /* Free peer structure. */
2283 XFREE (MTYPE_BGP_PEER
, peer
);
2287 peer_destroy (struct vty
*vty
, char *ip_str
, char *as_str
, int afi
, int safi
)
2291 char *endptr
= NULL
;
2296 ret
= str2sockunion (ip_str
, &su
);
2299 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
2305 as
= strtoul (as_str
, &endptr
, 10);
2306 if (as
== ULONG_MAX
|| *endptr
!= '\0' || as
< 1 || as
> 65535)
2308 vty_out (vty
, "AS value error: %s%s", as_str
, VTY_NEWLINE
);
2315 peer
= peer_lookup_with_local_as (&su
, bgp
->as
);
2316 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
) && !peer
)
2318 peer
= peer_lookup_with_local_as (&su
, bgp
->confederation_id
);
2323 vty_out (vty
, "Can't find peer: %s%s", ip_str
, VTY_NEWLINE
);
2326 if (as_str
&& peer
->as
!= as
)
2328 vty_out (vty
, "AS mismatch%s", VTY_NEWLINE
);
2337 /* peer_flag_change_type. */
2338 enum flag_change_type
2341 flag_change_set_reset
,
2343 flag_change_unset_reset
2346 /* Change specified peer flag. */
2348 peer_change_af_flag (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
2349 u_int16_t flag
, enum flag_change_type type
)
2352 struct peer_conf
*conf
;
2354 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
2357 if (! conf
->afc
[afi
][safi
])
2359 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
2366 if (type
== flag_change_set
2367 || type
== flag_change_set_reset
)
2369 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], flag
))
2372 SET_FLAG (peer
->af_flags
[afi
][safi
], flag
);
2373 if (type
== flag_change_set_reset
)
2374 BGP_EVENT_ADD (peer
, BGP_Stop
);
2378 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], flag
))
2381 UNSET_FLAG (peer
->af_flags
[afi
][safi
], flag
);
2382 if (type
== flag_change_unset_reset
)
2383 BGP_EVENT_ADD (peer
, BGP_Stop
);
2389 /* Change specified peer flag. */
2391 peer_change_flag (struct vty
*vty
, char *ip_str
, int afi
, u_int16_t flag
,
2395 struct peer_conf
*conf
;
2397 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
2403 SET_FLAG (peer
->flags
, flag
);
2405 UNSET_FLAG (peer
->flags
, flag
);
2409 /* Change specified peer flag with resetting the connection. If the
2410 flag is not changed nothing occur. */
2412 peer_change_flag_with_reset (struct vty
*vty
, char *ip_str
, int afi
,
2413 u_int16_t flag
, int set
)
2416 struct peer_conf
*conf
;
2418 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
2425 if (! CHECK_FLAG (peer
->flags
, flag
))
2427 SET_FLAG (peer
->flags
, flag
);
2428 BGP_EVENT_ADD (peer
, BGP_Stop
);
2433 if (CHECK_FLAG (peer
->flags
, flag
))
2435 UNSET_FLAG (peer
->flags
, flag
);
2436 BGP_EVENT_ADD (peer
, BGP_Stop
);
2442 DEFUN (neighbor_remote_as
,
2443 neighbor_remote_as_cmd
,
2444 NEIGHBOR_CMD
"remote-as <1-65535>",
2447 "Specify a BGP neighbor\n"
2450 return peer_remote_as (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
);
2453 DEFUN (neighbor_remote_as_unicast
,
2454 neighbor_remote_as_unicast_cmd
,
2455 NEIGHBOR_CMD
"remote-as <1-65535> nlri unicast",
2458 "Specify a BGP neighbor\n"
2460 "Network Layer Reachable Information\n"
2461 "Configure for unicast routes\n")
2463 return peer_remote_as (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
);
2466 DEFUN (neighbor_remote_as_multicast
,
2467 neighbor_remote_as_multicast_cmd
,
2468 NEIGHBOR_CMD
"remote-as <1-65535> nlri multicast",
2471 "Specify a BGP neighbor\n"
2473 "Network Layer Reachable Information\n"
2474 "Configure for multicast routes\n")
2476 return peer_remote_as (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_MULTICAST
);
2479 DEFUN (neighbor_remote_as_unicast_multicast
,
2480 neighbor_remote_as_unicast_multicast_cmd
,
2481 NEIGHBOR_CMD
"remote-as <1-65535> nlri unicast multicast",
2484 "Specify a BGP neighbor\n"
2486 "Network Layer Reachable Information\n"
2487 "Configure for unicast routes\n"
2488 "Configure for multicast routes\n")
2490 return peer_remote_as (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST_MULTICAST
);
2493 DEFUN (neighbor_activate
,
2494 neighbor_activate_cmd
,
2495 NEIGHBOR_CMD
"activate",
2498 "Enable the Address Family for this Neighbor\n")
2500 return peer_activate (vty
, argv
[0], bgp_node_afi (vty
),
2501 bgp_node_safi (vty
));
2504 DEFUN (no_neighbor_activate
,
2505 no_neighbor_activate_cmd
,
2506 NO_NEIGHBOR_CMD
"activate",
2510 "Enable the Address Family for this Neighbor\n")
2512 return peer_deactivate (vty
, argv
[0], bgp_node_afi (vty
),
2513 bgp_node_safi (vty
));
2517 DEFUN (ipv6_bgp_neighbor_remote_as
,
2518 ipv6_bgp_neighbor_remote_as_cmd
,
2519 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) remote-as <1-65535>",
2525 "Specify a BGP neighbor\n"
2528 return peer_remote_as (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
);
2531 DEFUN (ipv6_bgp_neighbor_remote_as_unicast
,
2532 ipv6_bgp_neighbor_remote_as_unicast_cmd
,
2533 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) remote-as <1-65535> nlri unicast",
2539 "Specify a BGP neighbor\n"
2541 "Network Layer Reachable Information\n"
2542 "Configure for unicast routes\n")
2544 return peer_remote_as (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
);
2547 DEFUN (ipv6_bgp_neighbor_remote_as_multicast
,
2548 ipv6_bgp_neighbor_remote_as_multicast_cmd
,
2549 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) remote-as <1-65535> nlri multicast",
2555 "Specify a BGP neighbor\n"
2557 "Network Layer Reachable Information\n"
2558 "Configure for multicast routes\n")
2560 return peer_remote_as (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_MULTICAST
);
2563 DEFUN (ipv6_bgp_neighbor_remote_as_unicast_multicast
,
2564 ipv6_bgp_neighbor_remote_as_unicast_multicast_cmd
,
2565 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) remote-as <1-65535> nlri unicast multicast",
2571 "Specify a BGP neighbor\n"
2573 "Network Layer Reachable Information\n"
2574 "Configure for unicast routes\n"
2575 "Configure for multicast routes\n")
2577 return peer_remote_as (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST_MULTICAST
);
2580 #endif /* HAVE_IPV6 */
2589 return peer_destroy (vty
, argv
[0], NULL
, AFI_IP
, SAFI_UNICAST
);
2592 DEFUN (no_neighbor_remote_as
,
2593 no_neighbor_remote_as_cmd
,
2594 NO_NEIGHBOR_CMD
"remote-as <1-65535>",
2598 "Specify a BGP neighbor\n"
2601 return peer_destroy (vty
, argv
[0], argv
[1], AFI_IP
, SAFI_UNICAST
);
2604 DEFUN (no_ipv6_bgp_neighbor
,
2605 no_ipv6_bgp_neighbor_cmd
,
2606 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X)",
2614 return peer_destroy (vty
, argv
[0], NULL
, AFI_IP6
, SAFI_UNICAST
);
2617 DEFUN (no_ipv6_bgp_neighbor_remote_as
,
2618 no_ipv6_bgp_neighbor_remote_as_cmd
,
2619 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) remote-as <1-65535>",
2626 "Specify a BGP neighbor\n"
2629 return peer_destroy (vty
, argv
[0], argv
[1], AFI_IP6
, SAFI_UNICAST
);
2632 /* router-id set. */
2634 peer_router_id (struct vty
*vty
, char *ip_str
, int afi
, char *id_str
)
2637 struct peer_conf
*conf
;
2641 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
2649 ret
= inet_aton (id_str
, &id
);
2652 vty_out (vty
, "Malformed router identifier: %s%s", id_str
,
2656 peer
->remote_id
= id
;
2660 peer
->remote_id
.s_addr
= 0;
2666 DEFUN (neighbor_router_id
,
2667 neighbor_router_id_cmd
,
2668 NEIGHBOR_CMD
"router-id A.B.C.D",
2671 "Set neighbor's special router-id value\n"
2674 return peer_router_id (vty
, argv
[0], AFI_IP
, argv
[1]);
2677 DEFUN (no_neighbor_router_id
,
2678 no_neighbor_router_id_cmd
,
2679 NO_NEIGHBOR_CMD
"router-id A.B.C.D",
2683 "Set neighbor's special router-id value\n"
2686 return peer_router_id (vty
, argv
[0], AFI_IP
, NULL
);
2689 /* neighbor passive. */
2690 DEFUN (neighbor_passive
,
2691 neighbor_passive_cmd
,
2692 NEIGHBOR_CMD
"passive",
2695 "Don't send open messages to this neighbor\n")
2697 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
2698 PEER_FLAG_PASSIVE
, 1);
2701 DEFUN (no_neighbor_passive
,
2702 no_neighbor_passive_cmd
,
2703 NO_NEIGHBOR_CMD
"passive",
2707 "Don't send open messages to this neighbor\n")
2709 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
2710 PEER_FLAG_PASSIVE
, 0);
2713 DEFUN (ipv6_bgp_neighbor_passive
,
2714 ipv6_bgp_neighbor_passive_cmd
,
2715 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) passive",
2721 "Don't send open messages to this neighbor\n")
2723 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
2724 PEER_FLAG_PASSIVE
, 1);
2727 DEFUN (no_ipv6_bgp_neighbor_passive
,
2728 no_ipv6_bgp_neighbor_passive_cmd
,
2729 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) passive",
2736 "Don't send open messages to this neighbor\n")
2738 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
2739 PEER_FLAG_PASSIVE
, 0);
2742 /* neighbor shutdown. */
2743 DEFUN (neighbor_shutdown
,
2744 neighbor_shutdown_cmd
,
2745 NEIGHBOR_CMD
"shutdown",
2748 "Administratively shut down this neighbor\n")
2750 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
2751 PEER_FLAG_SHUTDOWN
, 1);
2754 DEFUN (no_neighbor_shutdown
,
2755 no_neighbor_shutdown_cmd
,
2756 NO_NEIGHBOR_CMD
"shutdown",
2760 "Administratively shut down this neighbor\n")
2762 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
2763 PEER_FLAG_SHUTDOWN
, 0);
2766 DEFUN (ipv6_bgp_neighbor_shutdown
,
2767 ipv6_bgp_neighbor_shutdown_cmd
,
2768 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) shutdown",
2774 "Administratively shut down this neighbor\n")
2776 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
2777 PEER_FLAG_SHUTDOWN
, 1);
2780 DEFUN (no_ipv6_bgp_neighbor_shutdown
,
2781 no_ipv6_bgp_neighbor_shutdown_cmd
,
2782 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) shutdown",
2789 "Administratively shut down this neighbor\n")
2791 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
2792 PEER_FLAG_SHUTDOWN
, 0);
2795 /* neighbor ebgp-multihop. */
2797 peer_ebgp_multihop_set (struct vty
*vty
, char *ip_str
, char *ttl_str
, int afi
)
2800 struct peer_conf
*conf
;
2803 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
2808 ttl
= atoi (ttl_str
);
2812 vty_out (vty
, "TTL value error: %s%s", ttl_str
, VTY_NEWLINE
);
2817 if (peer_sort (peer
) == BGP_PEER_IBGP
)
2819 vty_out (vty
, "peer is IBGP peer%s", VTY_NEWLINE
);
2825 /* Set runnning connection's ttl. */
2827 sockopt_ttl (peer
->su
.sa
.sa_family
, peer
->fd
, peer
->ttl
);
2833 peer_ebgp_multihop_unset (struct vty
*vty
, char *ip_str
, char *ttl_str
,
2837 struct peer_conf
*conf
;
2840 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
2845 ttl
= atoi (ttl_str
);
2849 vty_out (vty
, "TTL value error: %s%s", ttl_str
, VTY_NEWLINE
);
2854 if (peer_sort (peer
) == BGP_PEER_IBGP
)
2856 vty_out (vty
, "peer is IBGP peer%s", VTY_NEWLINE
);
2860 /* Set default EBGP TTL. */
2863 /* Set runnning connection's ttl. */
2865 sockopt_ttl (peer
->su
.sa
.sa_family
, peer
->fd
, peer
->ttl
);
2870 /* neighbor ebgp-multihop. */
2871 DEFUN (neighbor_ebgp_multihop
,
2872 neighbor_ebgp_multihop_cmd
,
2873 NEIGHBOR_CMD
"ebgp-multihop",
2876 "Allow EBGP neighbors not on directly connected networks\n")
2878 return peer_ebgp_multihop_set (vty
, argv
[0], NULL
, AFI_IP
);
2881 DEFUN (neighbor_ebgp_multihop_ttl
,
2882 neighbor_ebgp_multihop_ttl_cmd
,
2883 NEIGHBOR_CMD
"ebgp-multihop <1-255>",
2886 "Allow EBGP neighbors not on directly connected networks\n"
2887 "maximum hop count\n")
2889 return peer_ebgp_multihop_set (vty
, argv
[0], argv
[1], AFI_IP
);
2892 DEFUN (no_neighbor_ebgp_multihop
,
2893 no_neighbor_ebgp_multihop_cmd
,
2894 NO_NEIGHBOR_CMD
"ebgp-multihop",
2898 "Allow EBGP neighbors not on directly connected networks\n")
2900 return peer_ebgp_multihop_unset (vty
, argv
[0], NULL
, AFI_IP
);
2903 DEFUN (no_neighbor_ebgp_multihop_ttl
,
2904 no_neighbor_ebgp_multihop_ttl_cmd
,
2905 NO_NEIGHBOR_CMD
"ebgp-multihop <1-255>",
2909 "Allow EBGP neighbors not on directly connected networks\n"
2910 "maximum hop count\n")
2912 return peer_ebgp_multihop_unset (vty
, argv
[0], argv
[1], AFI_IP
);
2915 DEFUN (ipv6_bgp_neighbor_ebgp_multihop
,
2916 ipv6_bgp_neighbor_ebgp_multihop_cmd
,
2917 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) ebgp-multihop",
2923 "Allow EBGP neighbors not on directly connected networks\n")
2925 return peer_ebgp_multihop_set (vty
, argv
[0], NULL
, AFI_IP6
);
2928 DEFUN (ipv6_bgp_neighbor_ebgp_multihop_ttl
,
2929 ipv6_bgp_neighbor_ebgp_multihop_ttl_cmd
,
2930 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) ebgp-multihop <1-255>",
2936 "Allow EBGP neighbors not on directly connected networks\n"
2937 "maximum hop count\n")
2939 return peer_ebgp_multihop_set (vty
, argv
[0], argv
[1], AFI_IP6
);
2942 DEFUN (no_ipv6_bgp_neighbor_ebgp_multihop
,
2943 no_ipv6_bgp_neighbor_ebgp_multihop_cmd
,
2944 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) ebgp-multihop",
2951 "Allow EBGP neighbors not on directly connected networks\n")
2953 return peer_ebgp_multihop_unset (vty
, argv
[0], NULL
, AFI_IP6
);
2956 DEFUN (no_ipv6_bgp_neighbor_ebgp_multihop_ttl
,
2957 no_ipv6_bgp_neighbor_ebgp_multihop_ttl_cmd
,
2958 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) ebgp-multihop <1-255>",
2965 "Allow EBGP neighbors not on directly connected networks\n"
2966 "maximum hop count\n")
2968 return peer_ebgp_multihop_unset (vty
, argv
[0], argv
[1], AFI_IP6
);
2971 /* neighbor description. */
2973 peer_description_set (struct vty
*vty
, char *ip_str
, int afi
, char *str
)
2976 struct peer_conf
*conf
;
2978 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
2984 XFREE (MTYPE_TMP
, peer
->desc
);
2990 peer_description_unset (struct vty
*vty
, char *ip_str
, int afi
)
2993 struct peer_conf
*conf
;
2995 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
3001 XFREE (MTYPE_TMP
, peer
->desc
);
3006 DEFUN (neighbor_description
,
3007 neighbor_description_cmd
,
3008 NEIGHBOR_CMD
"description .LINE",
3011 "Neighbor specific description\n"
3012 "Up to 80 characters describing this neighbor\n")
3021 /* Make string from buffer. This function should be provided by
3023 b
= buffer_new (1024);
3024 for (i
= 1; i
< argc
; i
++)
3026 buffer_putstr (b
, (u_char
*)argv
[i
]);
3027 buffer_putc (b
, ' ');
3029 buffer_putc (b
, '\0');
3030 str
= buffer_getstr (b
);
3033 return peer_description_set (vty
, argv
[0], AFI_IP
, str
);
3036 DEFUN (no_neighbor_description
,
3037 no_neighbor_description_cmd
,
3038 NO_NEIGHBOR_CMD
"description",
3042 "Neighbor specific description\n")
3044 return peer_description_unset (vty
, argv
[0], AFI_IP
);
3047 ALIAS (no_neighbor_description
,
3048 no_neighbor_description_val_cmd
,
3049 NO_NEIGHBOR_CMD
"description .LINE",
3053 "Neighbor specific description\n"
3054 "Up to 80 characters describing this neighbor\n")
3056 DEFUN (ipv6_bgp_neighbor_description
,
3057 ipv6_bgp_neighbor_description_cmd
,
3058 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) description .LINE",
3064 "Neighbor specific description\n"
3065 "Up to 80 characters describing this neighbor\n")
3074 b
= buffer_new (1024);
3075 for (i
= 1; i
< argc
; i
++)
3077 buffer_putstr (b
, (u_char
*)argv
[i
]);
3078 buffer_putc (b
, ' ');
3080 buffer_putc (b
, '\0');
3081 str
= buffer_getstr (b
);
3084 return peer_description_set (vty
, argv
[0], AFI_IP6
, str
);
3087 DEFUN (no_ipv6_bgp_neighbor_description
,
3088 no_ipv6_bgp_neighbor_description_cmd
,
3089 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) description",
3096 "Neighbor specific description\n")
3098 return peer_description_unset (vty
, argv
[0], AFI_IP6
);
3101 ALIAS (no_ipv6_bgp_neighbor_description
,
3102 no_ipv6_bgp_neighbor_description_val_cmd
,
3103 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) description .LINE",
3110 "Neighbor specific description\n"
3111 "Up to 80 characters describing this neighbor\n")
3113 /* neighbor next-hop-self. */
3114 DEFUN (neighbor_nexthop_self
,
3115 neighbor_nexthop_self_cmd
,
3116 NEIGHBOR_CMD
"next-hop-self",
3119 "Disable the next hop calculation for this neighbor\n")
3121 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
),
3122 bgp_node_safi (vty
), PEER_FLAG_NEXTHOP_SELF
,
3126 DEFUN (no_neighbor_nexthop_self
,
3127 no_neighbor_nexthop_self_cmd
,
3128 NO_NEIGHBOR_CMD
"next-hop-self",
3132 "Disable the next hop calculation for this neighbor\n")
3134 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
),
3135 bgp_node_safi (vty
), PEER_FLAG_NEXTHOP_SELF
,
3139 DEFUN (ipv6_bgp_neighbor_nexthop_self
,
3140 ipv6_bgp_neighbor_nexthop_self_cmd
,
3141 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) next-hop-self",
3147 "Disable the next hop calculation for this neighbor\n")
3149 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3150 PEER_FLAG_NEXTHOP_SELF
, flag_change_set
);
3153 DEFUN (no_ipv6_bgp_neighbor_nexthop_self
,
3154 no_ipv6_bgp_neighbor_nexthop_self_cmd
,
3155 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) next-hop-self",
3162 "Disable the next hop calculation for this neighbor\n")
3164 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3165 PEER_FLAG_NEXTHOP_SELF
, flag_change_unset
);
3168 /* neighbor update-source. */
3170 peer_update_source_set (struct vty
*vty
, char *ip_str
, int afi
,
3174 struct peer_conf
*conf
;
3176 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
3181 if (peer
->update_source
)
3183 XFREE (MTYPE_SOCKUNION
, peer
->update_source
);
3184 peer
->update_source
= NULL
;
3186 if (peer
->update_if
)
3188 free (peer
->update_if
);
3189 peer
->update_if
= NULL
;
3192 peer
->update_source
= sockunion_str2su (source_str
);
3194 if (peer
->update_source
== NULL
)
3195 peer
->update_if
= strdup (source_str
);
3201 peer_update_source_unset (struct vty
*vty
, char *ip_str
, int afi
)
3204 struct peer_conf
*conf
;
3206 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
3211 if (peer
->update_source
)
3213 XFREE (MTYPE_SOCKUNION
, peer
->update_source
);
3214 peer
->update_source
= NULL
;
3216 if (peer
->update_if
)
3218 free (peer
->update_if
);
3219 peer
->update_if
= NULL
;
3225 DEFUN (neighbor_update_source
,
3226 neighbor_update_source_cmd
,
3227 NEIGHBOR_CMD
"update-source WORD",
3230 "Source of routing updates\n"
3233 return peer_update_source_set (vty
, argv
[0], AFI_IP
, argv
[1]);
3236 DEFUN (no_neighbor_update_source
,
3237 no_neighbor_update_source_cmd
,
3238 NO_NEIGHBOR_CMD
"update-source",
3242 "Source of routing updates\n"
3245 return peer_update_source_unset (vty
, argv
[0], AFI_IP
);
3248 DEFUN (ipv6_bgp_neighbor_update_source
,
3249 ipv6_bgp_neighbor_update_source_cmd
,
3250 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) update-source WORD",
3256 "Source of routing updates\n"
3259 return peer_update_source_set (vty
, argv
[0], AFI_IP6
, argv
[1]);
3262 DEFUN (no_ipv6_bgp_neighbor_update_source
,
3263 no_ipv6_bgp_neighbor_update_source_cmd
,
3264 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) update-source",
3271 "Source of routing updates\n"
3274 return peer_update_source_unset (vty
, argv
[0], AFI_IP6
);
3277 /* neighbor default-originate. */
3278 DEFUN (neighbor_default_originate
,
3279 neighbor_default_originate_cmd
,
3280 NEIGHBOR_CMD
"default-originate",
3283 "Originate default route to this neighbor\n")
3285 return peer_change_flag (vty
, argv
[0], AFI_IP
, PEER_FLAG_DEFAULT_ORIGINATE
, 1);
3288 DEFUN (no_neighbor_default_originate
,
3289 no_neighbor_default_originate_cmd
,
3290 NO_NEIGHBOR_CMD
"default-originate",
3294 "Originate default route to this neighbor\n")
3296 return peer_change_flag (vty
, argv
[0], AFI_IP
, PEER_FLAG_DEFAULT_ORIGINATE
, 0);
3299 DEFUN (ipv6_bgp_neighbor_default_originate
,
3300 ipv6_bgp_neighbor_default_originate_cmd
,
3301 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) default-originate",
3307 "Originate default route to this neighbor\n")
3309 return peer_change_flag (vty
, argv
[0], AFI_IP6
, PEER_FLAG_DEFAULT_ORIGINATE
, 1);
3312 DEFUN (no_ipv6_bgp_neighbor_default_originate
,
3313 no_ipv6_bgp_neighbor_default_originate_cmd
,
3314 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) default-originate",
3321 "Originate default route to this neighbor\n")
3323 return peer_change_flag (vty
, argv
[0], AFI_IP6
, PEER_FLAG_DEFAULT_ORIGINATE
, 0);
3326 /* neighbor port. */
3328 peer_port (struct vty
*vty
, char *ip_str
, int afi
, char *port_str
)
3331 struct peer_conf
*conf
;
3332 unsigned long port
= 0;
3333 char *endptr
= NULL
;
3336 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
3341 if (port_str
== NULL
)
3343 sp
= getservbyname ("bgp", "tcp");
3344 peer
->port
= (sp
== NULL
) ? BGP_PORT_DEFAULT
: ntohs (sp
->s_port
);
3348 port
= strtoul (port_str
, &endptr
, 10);
3349 if (port
== ULONG_MAX
|| *endptr
!= '\0')
3351 vty_out (vty
, "port value error%s", VTY_NEWLINE
);
3356 vty_out (vty
, "port value error%s", VTY_NEWLINE
);
3360 /* Set peer port. */
3366 /* Set specified peer's BGP version. */
3367 DEFUN (neighbor_port
,
3369 NEIGHBOR_CMD
"port <0-65535>",
3372 "Neighbor's BGP port\n"
3373 "TCP port number\n")
3375 return peer_port (vty
, argv
[0], AFI_IP
, argv
[1]);
3378 DEFUN (no_neighbor_port
,
3379 no_neighbor_port_cmd
,
3380 NO_NEIGHBOR_CMD
"port",
3384 "Neighbor's BGP port\n")
3386 return peer_port (vty
, argv
[0], AFI_IP
, NULL
);
3389 ALIAS (no_neighbor_port
,
3390 no_neighbor_port_val_cmd
,
3391 NO_NEIGHBOR_CMD
"port <0-65535>",
3395 "Neighbor's BGP port\n"
3396 "TCP port number\n")
3398 DEFUN (ipv6_bgp_neighbor_port
,
3399 ipv6_bgp_neighbor_port_cmd
,
3400 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) port <0-65535>",
3406 "Neighbor's BGP port\n"
3407 "TCP port number\n")
3409 return peer_port (vty
, argv
[0], AFI_IP6
, argv
[1]);
3412 DEFUN (no_ipv6_bgp_neighbor_port
,
3413 no_ipv6_bgp_neighbor_port_cmd
,
3414 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) port",
3421 "Neighbor's BGP port\n")
3423 return peer_port (vty
, argv
[0], AFI_IP6
, NULL
);
3426 ALIAS (no_ipv6_bgp_neighbor_port
,
3427 no_ipv6_bgp_neighbor_port_val_cmd
,
3428 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) port <0-65535>",
3435 "Neighbor's BGP port\n"
3436 "TCP port number\n")
3438 /* neighbor send-community. */
3439 DEFUN (neighbor_send_community
,
3440 neighbor_send_community_cmd
,
3441 NEIGHBOR_CMD
"send-community",
3444 "Send Community attribute to this neighbor (default enable)\n")
3446 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3447 PEER_FLAG_SEND_COMMUNITY
, flag_change_set
);
3450 DEFUN (no_neighbor_send_community
,
3451 no_neighbor_send_community_cmd
,
3452 NO_NEIGHBOR_CMD
"send-community",
3456 "Send Community attribute to this neighbor (default enable)\n")
3458 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3459 PEER_FLAG_SEND_COMMUNITY
, flag_change_unset
);
3462 DEFUN (ipv6_bgp_neighbor_send_community
,
3463 ipv6_bgp_neighbor_send_community_cmd
,
3464 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) send-community",
3470 "Send Community attribute to this neighbor (default enable)\n")
3472 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3473 PEER_FLAG_SEND_COMMUNITY
, flag_change_set
);
3476 DEFUN (no_ipv6_bgp_neighbor_send_community
,
3477 no_ipv6_bgp_neighbor_send_community_cmd
,
3478 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) send-community",
3485 "Send Community attribute to this neighbor (default enable)\n")
3487 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3488 PEER_FLAG_SEND_COMMUNITY
, flag_change_unset
);
3491 /* neighbor send-community extended. */
3492 DEFUN (neighbor_send_community_type
,
3493 neighbor_send_community_type_cmd
,
3494 NEIGHBOR_CMD
"send-community (both|extended|standard)",
3497 "Send Community attribute to this neighbor (default enable)\n"
3498 "Send Standard and Extended Community attributes\n"
3499 "Send Extended Community attributes\n"
3500 "Send Standard Community attributes\n")
3504 if (strncmp (argv
[1], "s", 1) == 0)
3505 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3506 PEER_FLAG_SEND_COMMUNITY
, flag_change_set
);
3507 if (strncmp (argv
[1], "e", 1) == 0)
3508 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3509 PEER_FLAG_SEND_EXT_COMMUNITY
, flag_change_set
);
3511 ret
= peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3512 PEER_FLAG_SEND_COMMUNITY
, flag_change_set
);
3513 if (ret
== CMD_WARNING
)
3515 ret
= peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3516 PEER_FLAG_SEND_EXT_COMMUNITY
, flag_change_set
);
3517 if (ret
== CMD_WARNING
)
3523 DEFUN (no_neighbor_send_community_type
,
3524 no_neighbor_send_community_type_cmd
,
3525 NO_NEIGHBOR_CMD
"send-community (both|extended|standard)",
3529 "Send Community attribute to this neighbor (default enable)\n"
3530 "Send Standard and Extended Community attributes\n"
3531 "Send Extended Community attributes\n"
3532 "Send Standard Community attributes\n")
3536 if (strncmp (argv
[1], "s", 1) == 0)
3537 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3538 PEER_FLAG_SEND_COMMUNITY
, flag_change_unset
);
3539 if (strncmp (argv
[1], "e", 1) == 0)
3540 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3541 PEER_FLAG_SEND_EXT_COMMUNITY
, flag_change_unset
);
3543 ret
= peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3544 PEER_FLAG_SEND_COMMUNITY
, flag_change_unset
);
3545 if (ret
== CMD_WARNING
)
3547 ret
= peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3548 PEER_FLAG_SEND_EXT_COMMUNITY
, flag_change_unset
);
3549 if (ret
== CMD_WARNING
)
3555 DEFUN (ipv6_bgp_neighbor_send_community_extended
,
3556 ipv6_bgp_neighbor_send_community_extended_cmd
,
3557 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) send-community extended",
3563 "Send Community attribute to this neighbor (default enable)\n"
3564 "Extended Community\n")
3566 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3567 PEER_FLAG_SEND_EXT_COMMUNITY
, flag_change_set
);
3570 DEFUN (no_ipv6_bgp_neighbor_send_community_extended
,
3571 no_ipv6_bgp_neighbor_send_community_extended_cmd
,
3572 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) send-community extended",
3579 "Send Community attribute to this neighbor (default enable)\n"
3580 "Extended Community\n")
3582 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3583 PEER_FLAG_SEND_EXT_COMMUNITY
, flag_change_unset
);
3586 /* neighbor weight. */
3588 peer_weight_set (struct vty
*vty
, char *ip_str
, int afi
, char *weight_str
)
3591 struct peer_conf
*conf
;
3592 unsigned long weight
;
3593 char *endptr
= NULL
;
3595 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
3600 weight
= strtoul (weight_str
, &endptr
, 10);
3601 if (weight
== ULONG_MAX
|| *endptr
!= '\0')
3603 vty_out (vty
, "weight value error%s", VTY_NEWLINE
);
3608 vty_out (vty
, "weight value error%s", VTY_NEWLINE
);
3612 /* Set weight flag to peer configure. */
3613 peer
->weight
= weight
;
3619 peer_weight_unset (struct vty
*vty
, char *ip_str
, int afi
)
3622 struct peer_conf
*conf
;
3624 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
3633 DEFUN (neighbor_weight
,
3634 neighbor_weight_cmd
,
3635 NEIGHBOR_CMD
"weight <0-65535>",
3638 "Set default weight for routes from this neighbor\n"
3641 return peer_weight_set (vty
, argv
[0], AFI_IP
, argv
[1]);
3644 DEFUN (no_neighbor_weight
,
3645 no_neighbor_weight_cmd
,
3646 NO_NEIGHBOR_CMD
"weight",
3650 "Set default weight for routes from this neighbor\n")
3652 return peer_weight_unset (vty
, argv
[0], AFI_IP
);
3655 ALIAS (no_neighbor_weight
,
3656 no_neighbor_weight_val_cmd
,
3657 NO_NEIGHBOR_CMD
"weight <0-65535>",
3661 "Set default weight for routes from this neighbor\n"
3664 DEFUN (ipv6_bgp_neighbor_weight
,
3665 ipv6_bgp_neighbor_weight_cmd
,
3666 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) weight <0-65535>",
3672 "Set default weight for routes from this neighbor\n"
3675 return peer_weight_set (vty
, argv
[0], AFI_IP6
, argv
[1]);
3678 DEFUN (no_ipv6_bgp_neighbor_weight
,
3679 no_ipv6_bgp_neighbor_weight_cmd
,
3680 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) weight",
3687 "Set default weight for routes from this neighbor\n")
3689 return peer_weight_unset (vty
, argv
[0], AFI_IP6
);
3692 ALIAS (no_ipv6_bgp_neighbor_weight
,
3693 no_ipv6_bgp_neighbor_weight_val_cmd
,
3694 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) weight <0-65535>",
3701 "Set default weight for routes from this neighbor\n"
3704 /* neighbor soft-reconfig. */
3705 DEFUN (neighbor_soft_reconfiguration
,
3706 neighbor_soft_reconfiguration_cmd
,
3707 NEIGHBOR_CMD
"soft-reconfiguration inbound",
3710 "Per neighbor soft reconfiguration\n"
3711 "Allow inbound soft reconfiguration for this neighbor\n")
3715 struct peer_conf
*conf
;
3717 conf
= peer_conf_lookup_vty (vty
, argv
[0], bgp_node_afi (vty
));
3723 ret
= peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3724 PEER_FLAG_SOFT_RECONFIG
, flag_change_set
);
3726 if (ret
== CMD_SUCCESS
)
3728 if (peer
->status
== Established
3729 && (peer
->refresh_nego_old
|| peer
->refresh_nego_new
))
3730 bgp_route_refresh_send (peer
, bgp_node_afi (vty
), bgp_node_safi (vty
));
3732 BGP_EVENT_ADD (peer
, BGP_Stop
);
3738 DEFUN (no_neighbor_soft_reconfiguration
,
3739 no_neighbor_soft_reconfiguration_cmd
,
3740 NO_NEIGHBOR_CMD
"soft-reconfiguration inbound",
3744 "Per neighbor soft reconfiguration\n"
3745 "Allow inbound soft reconfiguration for this neighbor\n")
3749 struct peer_conf
*conf
;
3751 conf
= peer_conf_lookup_vty (vty
, argv
[0], bgp_node_afi (vty
));
3757 ret
= peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3758 PEER_FLAG_SOFT_RECONFIG
, flag_change_unset
);
3760 if (ret
== CMD_SUCCESS
)
3761 bgp_adj_clear (peer
->adj_in
[bgp_node_afi (vty
)][bgp_node_safi (vty
)],
3762 bgp_node_safi (vty
));
3767 DEFUN (ipv6_bgp_neighbor_soft_reconfiguration
,
3768 ipv6_bgp_neighbor_soft_reconfiguration_cmd
,
3769 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) soft-reconfiguration inbound",
3775 "Per neighbor soft reconfiguration\n"
3776 "Allow inbound soft reconfiguration for this neighbor\n")
3778 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3779 PEER_FLAG_SOFT_RECONFIG
, flag_change_set_reset
);
3782 DEFUN (no_ipv6_bgp_neighbor_soft_reconfiguration
,
3783 no_ipv6_bgp_neighbor_soft_reconfiguration_cmd
,
3784 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) soft-reconfiguration inbound",
3791 "Per neighbor soft reconfiguration\n"
3792 "Allow inbound soft reconfiguration for this neighbor\n")
3796 struct peer_conf
*conf
;
3798 conf
= peer_conf_lookup_vty (vty
, argv
[0], AFI_IP6
);
3804 ret
= peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3805 PEER_FLAG_SOFT_RECONFIG
, flag_change_unset
);
3807 if (ret
== CMD_SUCCESS
)
3808 bgp_adj_clear (peer
->adj_in
[AFI_IP6
][SAFI_UNICAST
],
3815 DEFUN (neighbor_route_reflector_client
,
3816 neighbor_route_reflector_client_cmd
,
3817 NEIGHBOR_CMD
"route-reflector-client",
3820 "Configure a neighbor as Route Reflector client\n")
3823 struct peer_conf
*conf
;
3825 conf
= peer_conf_lookup_vty (vty
, argv
[0], bgp_node_afi (vty
));
3831 if (peer_sort (peer
) != BGP_PEER_IBGP
)
3833 vty_out (vty
, "%% Invalid command. Not an internal neighbor%s",
3838 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3839 PEER_FLAG_REFLECTOR_CLIENT
, flag_change_set_reset
);
3842 DEFUN (no_neighbor_route_reflector_client
,
3843 no_neighbor_route_reflector_client_cmd
,
3844 NO_NEIGHBOR_CMD
"route-reflector-client",
3848 "Configure a neighbor as Route Reflector client\n")
3850 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3851 PEER_FLAG_REFLECTOR_CLIENT
, flag_change_unset_reset
);
3854 DEFUN (ipv6_bgp_neighbor_route_reflector_client
,
3855 ipv6_bgp_neighbor_route_reflector_client_cmd
,
3856 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) route-reflector-client",
3862 "Configure a neighbor as Route Reflector client\n")
3865 struct peer_conf
*conf
;
3867 conf
= peer_conf_lookup_vty (vty
, argv
[0], bgp_node_afi (vty
));
3873 if (peer_sort (peer
) != BGP_PEER_IBGP
)
3875 vty_out (vty
, "%% Invalid command. Not an internal neighbor%s",
3880 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3881 PEER_FLAG_REFLECTOR_CLIENT
, flag_change_set_reset
);
3884 DEFUN (no_ipv6_bgp_neighbor_route_reflector_client
,
3885 no_ipv6_bgp_neighbor_route_reflector_client_cmd
,
3886 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) route-reflector-client",
3893 "Configure a neighbor as Route Reflector client\n")
3895 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3896 PEER_FLAG_REFLECTOR_CLIENT
, flag_change_unset_reset
);
3899 /* neighbor route-server-client. */
3900 DEFUN (neighbor_route_server_client
,
3901 neighbor_route_server_client_cmd
,
3902 NEIGHBOR_CMD
"route-server-client",
3905 "Configure a neighbor as Route Server client\n")
3908 struct peer_conf
*conf
;
3910 conf
= peer_conf_lookup_vty (vty
, argv
[0], bgp_node_afi (vty
));
3916 if (peer_sort (peer
) != BGP_PEER_EBGP
)
3918 vty_out (vty
, "%% Invalid command. Not an external neighbor%s",
3923 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3924 PEER_FLAG_RSERVER_CLIENT
, flag_change_set_reset
);
3927 DEFUN (no_neighbor_route_server_client
,
3928 no_neighbor_route_server_client_cmd
,
3929 NO_NEIGHBOR_CMD
"route-server-client",
3933 "Configure a neighbor as Route Server client\n")
3935 return peer_change_af_flag (vty
, argv
[0], bgp_node_afi (vty
), bgp_node_safi (vty
),
3936 PEER_FLAG_RSERVER_CLIENT
, flag_change_unset_reset
);
3939 DEFUN (ipv6_bgp_neighbor_route_server_client
,
3940 ipv6_bgp_neighbor_route_server_client_cmd
,
3941 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) route-server-client",
3947 "Configure a neighbor as Route Server client\n")
3950 struct peer_conf
*conf
;
3952 conf
= peer_conf_lookup_vty (vty
, argv
[0], AFI_IP6
);
3958 if (peer_sort (peer
) != BGP_PEER_EBGP
)
3960 vty_out (vty
, "%% Invalid command. Not an external neighbor%s",
3964 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3965 PEER_FLAG_RSERVER_CLIENT
, flag_change_set_reset
);
3968 DEFUN (no_ipv6_bgp_neighbor_route_server_client
,
3969 no_ipv6_bgp_neighbor_route_server_client_cmd
,
3970 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) route-server-client",
3977 "Configure a neighbor as Route Server client\n")
3979 return peer_change_af_flag (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
3980 PEER_FLAG_RSERVER_CLIENT
, flag_change_unset_reset
);
3983 /* neighbor capability route-refresh. */
3984 DEFUN (neighbor_capability_route_refresh
,
3985 neighbor_capability_route_refresh_cmd
,
3986 NEIGHBOR_CMD
"capability route-refresh",
3989 "Outbound capability configuration\n"
3990 "Advertise route-refresh capability to this neighbor\n")
3992 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
3993 PEER_FLAG_CAPABILITY_ROUTE_REFRESH
, 1);
3996 DEFUN (no_neighbor_capability_route_refresh
,
3997 no_neighbor_capability_route_refresh_cmd
,
3998 NO_NEIGHBOR_CMD
"capability route-refresh",
4002 "Outbound capability configuration\n"
4003 "Advertise route-refresh capability to this neighbor\n")
4005 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
4006 PEER_FLAG_CAPABILITY_ROUTE_REFRESH
, 0);
4009 DEFUN (ipv6_bgp_neighbor_capability_route_refresh
,
4010 ipv6_bgp_neighbor_capability_route_refresh_cmd
,
4011 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) capability route-refresh",
4017 "Outbound capability configuration\n"
4018 "Advertise route-refresh capability to this neighbor\n")
4020 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
4021 PEER_FLAG_CAPABILITY_ROUTE_REFRESH
, 1);
4024 DEFUN (no_ipv6_bgp_neighbor_capability_route_refresh
,
4025 no_ipv6_bgp_neighbor_capability_route_refresh_cmd
,
4026 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) capability route-refresh",
4033 "Outbound capability configuration\n"
4034 "Advertise route-refresh capability to this neighbor\n")
4036 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
4037 PEER_FLAG_CAPABILITY_ROUTE_REFRESH
, 0);
4040 /* neighbor transparent-as */
4041 DEFUN (neighbor_transparent_as
,
4042 neighbor_transparent_as_cmd
,
4043 NEIGHBOR_CMD
"transparent-as",
4046 "Do not append my AS number even peer is EBGP peer\n")
4048 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
4049 PEER_FLAG_TRANSPARENT_AS
, 1);
4052 DEFUN (no_neighbor_transparent_as
,
4053 no_neighbor_transparent_as_cmd
,
4054 NO_NEIGHBOR_CMD
"transparent-as",
4058 "Do not append my AS number even peer is EBGP peer\n")
4060 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
4061 PEER_FLAG_TRANSPARENT_AS
, 0);
4064 DEFUN (ipv6_bgp_neighbor_transparent_as
,
4065 ipv6_bgp_neighbor_transparent_as_cmd
,
4066 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) transparent-as",
4072 "Do not append my AS number even peer is EBGP peer\n")
4074 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
4075 PEER_FLAG_TRANSPARENT_AS
, 1);
4078 DEFUN (no_ipv6_bgp_neighbor_transparent_as
,
4079 no_ipv6_bgp_neighbor_transparent_as_cmd
,
4080 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) transparent-as",
4087 "Do not append my AS number even peer is EBGP peer\n")
4089 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
4090 PEER_FLAG_TRANSPARENT_AS
, 0);
4093 /* neighbor transparent-nexthop */
4094 DEFUN (neighbor_transparent_nexthop
,
4095 neighbor_transparent_nexthop_cmd
,
4096 NEIGHBOR_CMD
"transparent-nexthop",
4099 "Do not change nexthop even peer is EBGP peer\n")
4101 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
4102 PEER_FLAG_TRANSPARENT_NEXTHOP
, 1);
4105 DEFUN (no_neighbor_transparent_nexthop
,
4106 no_neighbor_transparent_nexthop_cmd
,
4107 NO_NEIGHBOR_CMD
"transparent-nexthop",
4111 "Do not change nexthop even peer is EBGP peer\n")
4113 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP
,
4114 PEER_FLAG_TRANSPARENT_NEXTHOP
, 0);
4117 DEFUN (ipv6_bgp_neighbor_transparent_nexthop
,
4118 ipv6_bgp_neighbor_transparent_nexthop_cmd
,
4119 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) transparent-nexthop",
4125 "Do not change nexthop even peer is EBGP peer\n")
4127 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
4128 PEER_FLAG_TRANSPARENT_NEXTHOP
, 1);
4131 DEFUN (no_ipv6_bgp_neighbor_transparent_nexthop
,
4132 no_ipv6_bgp_neighbor_transparent_nexthop_cmd
,
4133 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) transparent-nexthop",
4140 "Do not change nexthop even peer is EBGP peer\n")
4142 return peer_change_flag_with_reset (vty
, argv
[0], AFI_IP6
,
4143 PEER_FLAG_TRANSPARENT_NEXTHOP
, 0);
4146 /* neighbor translate-update. */
4148 peer_translate_update (struct vty
*vty
, char *ip_str
, int afi
, int safi
)
4151 struct peer_conf
*conf
;
4153 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4158 peer
->translate_update
= safi
;
4162 DEFUN (neighbor_translate_update_multicast
,
4163 neighbor_translate_update_multicast_cmd
,
4164 NEIGHBOR_CMD
"translate-update nlri multicast",
4167 "Translate bgp updates\n"
4168 "Network Layer Reachable Information\n"
4169 "multicast information\n")
4171 return peer_translate_update (vty
, argv
[0], AFI_IP
, SAFI_MULTICAST
);
4174 DEFUN (neighbor_translate_update_unimulti
,
4175 neighbor_translate_update_unimulti_cmd
,
4176 NEIGHBOR_CMD
"translate-update nlri unicast multicast",
4179 "Translate bgp updates\n"
4180 "Network Layer Reachable Information\n"
4181 "unicast information\n"
4182 "multicast inforamtion\n")
4184 return peer_translate_update (vty
, argv
[0], AFI_IP
, SAFI_UNICAST_MULTICAST
);
4187 DEFUN (no_neighbor_translate_update
,
4188 no_neighbor_translate_update_cmd
,
4189 NO_NEIGHBOR_CMD
"translate-update",
4193 "Translate bgp updates\n")
4195 return peer_translate_update (vty
, argv
[0], AFI_IP
, 0);
4198 DEFUN (no_neighbor_translate_update_multicast
,
4199 no_neighbor_translate_update_multicast_cmd
,
4200 NO_NEIGHBOR_CMD
"translate-update nlri multicast",
4204 "Translate bgp updates\n"
4205 "Network Layer Reachable Information\n"
4206 "multicast information\n")
4208 return peer_translate_update (vty
, argv
[0], AFI_IP
, 0);
4211 DEFUN (no_neighbor_translate_update_unimulti
,
4212 no_neighbor_translate_update_unimulti_cmd
,
4213 NO_NEIGHBOR_CMD
"translate-update nlri unicast multicast",
4217 "Translate bgp updates\n"
4218 "Network Layer Reachable Information\n"
4219 "unicast information\n"
4220 "multicast inforamtion\n")
4222 return peer_translate_update (vty
, argv
[0], AFI_IP
, 0);
4225 /* neighbor dont-capability-negotiate */
4226 DEFUN (neighbor_dont_capability_negotiate
,
4227 neighbor_dont_capability_negotiate_cmd
,
4228 NEIGHBOR_CMD
"dont-capability-negotiate",
4231 "Do not perform capability negotiation\n")
4233 return peer_change_flag (vty
, argv
[0], AFI_IP
,
4234 PEER_FLAG_DONT_CAPABILITY
, 1);
4237 DEFUN (no_neighbor_dont_capability_negotiate
,
4238 no_neighbor_dont_capability_negotiate_cmd
,
4239 NO_NEIGHBOR_CMD
"dont-capability-negotiate",
4243 "Do not perform capability negotiation\n")
4245 return peer_change_flag (vty
, argv
[0], AFI_IP
,
4246 PEER_FLAG_DONT_CAPABILITY
, 0);
4249 DEFUN (ipv6_neighbor_dont_capability_negotiate
,
4250 ipv6_neighbor_dont_capability_negotiate_cmd
,
4251 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) dont-capability-negotiate",
4257 "Do not perform capability negotiation\n")
4259 return peer_change_flag (vty
, argv
[0], AFI_IP6
,
4260 PEER_FLAG_DONT_CAPABILITY
, 1);
4263 DEFUN (no_ipv6_neighbor_dont_capability_negotiate
,
4264 no_ipv6_neighbor_dont_capability_negotiate_cmd
,
4265 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) dont-capability-negotiate",
4272 "Do not perform capability negotiation\n")
4274 return peer_change_flag (vty
, argv
[0], AFI_IP6
,
4275 PEER_FLAG_DONT_CAPABILITY
, 0);
4278 /* Override capability negotiation. */
4280 peer_override_capability (struct vty
*vty
, char *ip_str
, int afi
, int set
)
4283 struct peer_conf
*conf
;
4285 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4292 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_STRICT_CAP_MATCH
))
4294 vty_out (vty
, "Can't set override-capability and strict-capability-match at the same time%s", VTY_NEWLINE
);
4297 SET_FLAG (peer
->flags
, PEER_FLAG_OVERRIDE_CAPABILITY
);
4300 UNSET_FLAG (peer
->flags
, PEER_FLAG_OVERRIDE_CAPABILITY
);
4304 /* Override capability negotiation. */
4305 DEFUN (neighbor_override_capability
,
4306 neighbor_override_capability_cmd
,
4307 NEIGHBOR_CMD
"override-capability",
4310 "Override capability negotiation result\n")
4312 return peer_override_capability (vty
, argv
[0], AFI_IP
, 1);
4315 DEFUN (no_neighbor_override_capability
,
4316 no_neighbor_override_capability_cmd
,
4317 NO_NEIGHBOR_CMD
"override-capability",
4321 "Override capability negotiation result\n")
4323 return peer_override_capability (vty
, argv
[0], AFI_IP
, 0);
4326 DEFUN (ipv6_neighbor_override_capability
,
4327 ipv6_neighbor_override_capability_cmd
,
4328 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) override-capability",
4334 "Override capability negotiation result\n")
4336 return peer_override_capability (vty
, argv
[0], AFI_IP6
, 1);
4339 DEFUN (no_ipv6_neighbor_override_capability
,
4340 no_ipv6_neighbor_override_capability_cmd
,
4341 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) override-capability",
4348 "Override capability negotiation result\n")
4350 return peer_override_capability (vty
, argv
[0], AFI_IP6
, 0);
4353 /* Strict capability match. */
4355 peer_strict_capability (struct vty
*vty
, char *ip_str
, int afi
, int set
)
4358 struct peer_conf
*conf
;
4360 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4367 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_OVERRIDE_CAPABILITY
))
4369 vty_out (vty
, "Can't set override-capability and strict-capability-match at the same time%s", VTY_NEWLINE
);
4372 SET_FLAG (peer
->flags
, PEER_FLAG_STRICT_CAP_MATCH
);
4375 UNSET_FLAG (peer
->flags
, PEER_FLAG_STRICT_CAP_MATCH
);
4379 DEFUN (neighbor_strict_capability
,
4380 neighbor_strict_capability_cmd
,
4381 NEIGHBOR_CMD
"strict-capability-match",
4384 "Strict capability negotiation match\n")
4386 return peer_strict_capability (vty
, argv
[0], AFI_IP
, 1);
4389 DEFUN (no_neighbor_strict_capability
,
4390 no_neighbor_strict_capability_cmd
,
4391 NO_NEIGHBOR_CMD
"strict-capability-match",
4395 "Strict capability negotiation match\n")
4397 return peer_strict_capability (vty
, argv
[0], AFI_IP
, 0);
4400 DEFUN (ipv6_neighbor_strict_capability
,
4401 ipv6_neighbor_strict_capability_cmd
,
4402 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) strict-capability-match",
4408 "Strict capability negotiation match\n")
4410 return peer_strict_capability (vty
, argv
[0], AFI_IP6
, 1);
4413 DEFUN (no_ipv6_neighbor_strict_capability
,
4414 no_ipv6_neighbor_strict_capability_cmd
,
4415 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) strict-capability-match",
4422 "Strict capability negotiation match\n")
4424 return peer_strict_capability (vty
, argv
[0], AFI_IP6
, 0);
4428 peer_timers_set (struct vty
*vty
, char *ip_str
, int afi
,
4429 char *keep_str
, char *hold_str
)
4432 struct peer_conf
*conf
;
4433 unsigned long keepalive
;
4434 unsigned long holdtime
;
4435 char *endptr
= NULL
;
4437 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4443 /* keepalive value check. */
4444 keepalive
= strtoul (keep_str
, &endptr
, 10);
4446 if (keepalive
== ULONG_MAX
|| *endptr
!= '\0')
4448 vty_out (vty
, "%% keepalive time value must be positive integer%s",
4452 if (keepalive
> 65535)
4454 vty_out (vty
, "%% keepalive time value must be <0-65535>%s", VTY_NEWLINE
);
4458 /* Holdtime value check. */
4459 holdtime
= strtoul (hold_str
, &endptr
, 10);
4461 if (holdtime
== ULONG_MAX
|| *endptr
!= '\0')
4463 vty_out (vty
, "%% hold time value must be positive integer%s", VTY_NEWLINE
);
4466 if (holdtime
> 65535)
4468 vty_out (vty
, "%% hold time value must be <0,3-65535>%s", VTY_NEWLINE
);
4471 if (holdtime
< 3 && holdtime
!= 0)
4473 vty_out (vty
, "%% hold time value must be either 0 or greater than 3%s",
4478 /* Set value to the configuration. */
4479 peer
->config
|= PEER_CONFIG_TIMER
;
4480 peer
->holdtime
= holdtime
;
4481 peer
->keepalive
= (keepalive
< holdtime
/ 3 ? keepalive
: holdtime
/ 3);
4487 peer_timers_unset (struct vty
*vty
, char *ip_str
, int afi
)
4490 struct peer_conf
*conf
;
4492 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4498 /* Clear configuration. */
4499 peer
->config
&= ~PEER_CONFIG_TIMER
;
4500 peer
->keepalive
= 0;
4506 DEFUN (neighbor_timers
,
4507 neighbor_timers_cmd
,
4508 NEIGHBOR_CMD
"timers <0-65535> <0-65535>",
4511 "BGP per neighbor timers\n"
4512 "Keepalive interval\n"
4515 return peer_timers_set (vty
, argv
[0], AFI_IP
, argv
[1], argv
[2]);
4518 DEFUN (no_neighbor_timers
,
4519 no_neighbor_timers_cmd
,
4520 NO_NEIGHBOR_CMD
"timers",
4524 "BGP per neighbor timers\n")
4526 return peer_timers_unset (vty
, argv
[0], AFI_IP
);
4529 DEFUN (ipv6_bgp_neighbor_timers
,
4530 ipv6_bgp_neighbor_timers_cmd
,
4531 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) timers <0-65535> <0-65535>",
4537 "BGP per neighbor timers\n"
4538 "Keepalive interval\n"
4541 return peer_timers_set (vty
, argv
[0], AFI_IP6
, argv
[1], argv
[2]);
4544 DEFUN (no_ipv6_bgp_neighbor_timers
,
4545 no_ipv6_bgp_neighbor_timers_cmd
,
4546 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) timers",
4553 "BGP per neighbor timers\n")
4555 return peer_timers_unset (vty
, argv
[0], AFI_IP6
);
4559 peer_timers_connect_set (struct vty
*vty
, char *ip_str
, int afi
,
4563 struct peer_conf
*conf
;
4564 unsigned long connect
;
4565 char *endptr
= NULL
;
4567 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4573 /* Hold time value check. */
4574 connect
= strtoul (time_str
, &endptr
, 10);
4576 if (connect
== ULONG_MAX
|| *endptr
!= '\0')
4578 vty_out (vty
, "connect time value must be positive integer%s",
4582 if (connect
> 65535)
4584 vty_out (vty
, "connect time value must be <0-65535>%s", VTY_NEWLINE
);
4588 /* Set value to the configuration. */
4589 peer
->config
|= PEER_CONFIG_CONNECT
;
4590 peer
->connect
= connect
;
4592 /* Set value to timer setting. */
4593 peer
->v_connect
= connect
;
4599 peer_timers_connect_unset (struct vty
*vty
, char *ip_str
, int afi
)
4602 struct peer_conf
*conf
;
4604 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4609 /* Clear configuration. */
4610 UNSET_FLAG (peer
->config
, PEER_CONFIG_CONNECT
);
4613 /* Set timer setting to default value. */
4614 peer
->v_connect
= BGP_DEFAULT_CONNECT_RETRY
;
4619 DEFUN (neighbor_timers_connect
,
4620 neighbor_timers_connect_cmd
,
4621 NEIGHBOR_CMD
"timers connect <0-65535>",
4624 "BGP per neighbor timers\n"
4625 "BGP connect timer\n"
4628 return peer_timers_connect_set (vty
, argv
[0], AFI_IP
, argv
[1]);
4631 DEFUN (no_neighbor_timers_connect
,
4632 no_neighbor_timers_connect_cmd
,
4633 NO_NEIGHBOR_CMD
"timers connect [TIMER]",
4637 "BGP per neighbor timers\n"
4638 "BGP connect timer\n"
4641 return peer_timers_connect_unset (vty
, argv
[0], AFI_IP
);
4644 DEFUN (ipv6_bgp_neighbor_timers_connect
,
4645 ipv6_bgp_neighbor_timers_connect_cmd
,
4646 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) timers connect <0-65535>",
4652 "BGP per neighbor timers\n"
4653 "BGP connect timer\n"
4656 return peer_timers_connect_set (vty
, argv
[0], AFI_IP6
, argv
[1]);
4659 DEFUN (no_ipv6_bgp_neighbor_timers_connect
,
4660 no_ipv6_bgp_neighbor_timers_connect_cmd
,
4661 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) timers connect [TIMER]",
4668 "BGP per neighbor timers\n"
4669 "BGP connect timer\n"
4672 return peer_timers_connect_unset (vty
, argv
[0], AFI_IP6
);
4676 peer_version (struct vty
*vty
, char *ip_str
, int afi
, char *str
)
4679 struct peer_conf
*conf
;
4681 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4686 /* BGP version string check. */
4689 if (strcmp (str
, "4") == 0)
4690 peer
->version
= BGP_VERSION_4
;
4691 else if (strcmp (str
, "4-") == 0)
4692 peer
->version
= BGP_VERSION_MP_4_DRAFT_00
;
4694 vty_out (vty
, "BGP version malformed!%s", VTY_NEWLINE
);
4697 peer
->version
= BGP_VERSION_4
;
4702 DEFUN (neighbor_version
,
4703 neighbor_version_cmd
,
4704 NEIGHBOR_CMD
"version (4|4-)",
4707 "Neighbor's BGP version\n"
4708 "Border Gateway Protocol 4\n"
4709 "Multiprotocol Extensions for BGP-4(Old Draft)\n")
4711 return peer_version (vty
, argv
[0], AFI_IP
, argv
[1]);
4714 DEFUN (no_neighbor_version
,
4715 no_neighbor_version_cmd
,
4716 NO_NEIGHBOR_CMD
"version",
4720 "Neighbor's BGP version\n")
4722 return peer_version (vty
, argv
[0], AFI_IP
, NULL
);
4725 DEFUN (ipv6_bgp_neighbor_version
,
4726 ipv6_bgp_neighbor_version_cmd
,
4727 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) version (4|4-)",
4733 "Neighbor's BGP version\n"
4734 "Border Gateway Protocol 4\n"
4735 "Multiprotocol Extensions for BGP-4(Old Draft)\n")
4737 return peer_version (vty
, argv
[0], AFI_IP6
, argv
[1]);
4740 DEFUN (no_ipv6_bgp_neighbor_version
,
4741 no_ipv6_bgp_neighbor_version_cmd
,
4742 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) version",
4749 "Neighbor's BGP version\n")
4751 return peer_version (vty
, argv
[0], AFI_IP6
, NULL
);
4754 /* neighbor interface */
4756 peer_interface (struct vty
*vty
, char *ip_str
, int afi
, char *str
)
4759 struct peer_conf
*conf
;
4761 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4769 free (peer
->ifname
);
4770 peer
->ifname
= strdup (str
);
4775 free (peer
->ifname
);
4776 peer
->ifname
= NULL
;
4781 DEFUN (neighbor_interface
,
4782 neighbor_interface_cmd
,
4783 NEIGHBOR_CMD
"interface WORD",
4789 return peer_interface (vty
, argv
[0], AFI_IP
, argv
[1]);
4792 DEFUN (no_neighbor_interface
,
4793 no_neighbor_interface_cmd
,
4794 NO_NEIGHBOR_CMD
"interface WORD",
4801 return peer_interface (vty
, argv
[0], AFI_IP
, NULL
);
4804 DEFUN (ipv6_bgp_neighbor_interface
,
4805 ipv6_bgp_neighbor_interface_cmd
,
4806 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) interface WORD",
4815 return peer_interface (vty
, argv
[0], AFI_IP6
, argv
[1]);
4818 DEFUN (no_ipv6_bgp_neighbor_interface
,
4819 no_ipv6_bgp_neighbor_interface_cmd
,
4820 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) interface WORD",
4830 return peer_interface (vty
, argv
[0], AFI_IP6
, NULL
);
4833 /* Set distribute list to the peer. */
4835 bgp_distribute_set (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
4836 char *name_str
, char *direct_str
)
4838 struct peer_conf
*conf
;
4839 struct bgp_filter
*filter
;
4842 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4845 if (! conf
->afc
[afi
][safi
])
4847 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
4852 /* Check filter direction. */
4853 if (strncmp (direct_str
, "i", 1) == 0)
4855 else if (strncmp (direct_str
, "o", 1) == 0)
4856 direct
= FILTER_OUT
;
4859 vty_out (vty
, "filter direction must be [in|out]%s", VTY_NEWLINE
);
4863 filter
= &conf
->filter
[afi
][safi
];
4865 if (filter
->dlist
[direct
].name
)
4866 free (filter
->dlist
[direct
].name
);
4868 filter
->dlist
[direct
].name
= strdup (name_str
);
4869 filter
->dlist
[direct
].alist
= access_list_lookup (afi
, name_str
);
4875 bgp_distribute_unset (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
4876 char *name_str
, char *direct_str
)
4878 struct peer_conf
*conf
;
4879 struct bgp_filter
*filter
;
4882 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
4885 if (! conf
->afc
[afi
][safi
])
4887 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
4892 /* Check filter direction. */
4893 if (strncmp (direct_str
, "i", 1) == 0)
4895 else if (strncmp (direct_str
, "o", 1) == 0)
4896 direct
= FILTER_OUT
;
4899 vty_out (vty
, "distribute direction must be [in|out]%s", VTY_NEWLINE
);
4903 filter
= &conf
->filter
[afi
][safi
];
4905 if (! filter
->dlist
[direct
].name
)
4907 vty_out (vty
, "%% There is no such filter: %s%s", name_str
, VTY_NEWLINE
);
4910 if (strcmp (filter
->dlist
[direct
].name
, name_str
) != 0)
4912 vty_out (vty
, "%% There is no such filter: %s%s", name_str
, VTY_NEWLINE
);
4915 free (filter
->dlist
[direct
].name
);
4916 filter
->dlist
[direct
].name
= NULL
;
4917 filter
->dlist
[direct
].alist
= NULL
;
4922 /* Update distribute list. */
4924 bgp_distribute_update (struct access_list
*access
)
4929 struct listnode
*nn
, *nm
;
4931 struct peer_conf
*conf
;
4932 struct bgp_filter
*filter
;
4934 LIST_LOOP (bgp_list
, bgp
, nn
)
4936 LIST_LOOP (bgp
->peer_conf
, conf
, nm
)
4938 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
4939 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
4941 filter
= &conf
->filter
[afi
][safi
];
4943 for (direct
= FILTER_IN
; direct
< FILTER_MAX
; direct
++)
4945 if (filter
->dlist
[direct
].name
)
4946 filter
->dlist
[direct
].alist
=
4947 access_list_lookup (afi
, filter
->dlist
[direct
].name
);
4949 filter
->dlist
[direct
].alist
= NULL
;
4956 DEFUN (neighbor_distribute_list
,
4957 neighbor_distribute_list_cmd
,
4958 NEIGHBOR_CMD
"distribute-list WORD (in|out)",
4961 "Filter updates to/from this neighbor\n"
4962 "IP Access-list name\n"
4963 "Filter incoming updates\n"
4964 "Filter outgoing updates\n")
4966 return bgp_distribute_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4970 DEFUN (no_neighbor_distribute_list
,
4971 no_neighbor_distribute_list_cmd
,
4972 NO_NEIGHBOR_CMD
"distribute-list WORD (in|out)",
4976 "Filter updates to/from this neighbor\n"
4977 "IP Access-list name\n"
4978 "Filter incoming updates\n"
4979 "Filter outgoing updates\n")
4981 return bgp_distribute_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
4985 DEFUN (ipv6_bgp_neighbor_distribute_list
,
4986 ipv6_bgp_neighbor_distribute_list_cmd
,
4987 NEIGHBOR_CMD
"distribute-list WORD (in|out)",
4990 "Filter updates to/from this neighbor\n"
4991 "IPv6 Access-list name\n"
4992 "Filter incoming updates\n"
4993 "Filter outgoing updates\n")
4995 return bgp_distribute_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
4999 DEFUN (no_ipv6_bgp_neighbor_distribute_list
,
5000 no_ipv6_bgp_neighbor_distribute_list_cmd
,
5001 NO_NEIGHBOR_CMD
"distribute-list WORD (in|out)",
5005 "Filter updates to/from this neighbor\n"
5006 "IPv6 Access-list name\n"
5007 "Filter incoming updates\n"
5008 "Filter outgoing updates\n")
5010 return bgp_distribute_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5014 ALIAS (ipv6_bgp_neighbor_distribute_list
,
5015 old_ipv6_bgp_neighbor_distribute_list_cmd
,
5016 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) distribute-list WORD (in|out)",
5022 "Filter updates to/from this neighbor\n"
5023 "IPv6 Access-list name\n"
5024 "Filter incoming updates\n"
5025 "Filter outgoing updates\n")
5027 ALIAS (no_ipv6_bgp_neighbor_distribute_list
,
5028 old_no_ipv6_bgp_neighbor_distribute_list_cmd
,
5029 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) distribute-list WORD (in|out)",
5036 "Filter updates to/from this neighbor\n"
5037 "IPv6 Access-list name\n"
5038 "Filter incoming updates\n"
5039 "Filter outgoing updates\n")
5041 /* Set prefix list to the peer. */
5043 bgp_prefix_list_set (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
5044 char *name_str
, char *direct_str
)
5046 struct peer_conf
*conf
;
5048 struct bgp_filter
*filter
;
5050 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
5053 if (! conf
->afc
[afi
][safi
])
5055 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
5060 /* Check filter direction. */
5061 if (strncmp (direct_str
, "i", 1) == 0)
5063 else if (strncmp (direct_str
, "o", 1) == 0)
5064 direct
= FILTER_OUT
;
5067 vty_out (vty
, "vty, filter direction must be [in|out]%s", VTY_NEWLINE
);
5071 filter
= &conf
->filter
[afi
][safi
];
5073 if (filter
->plist
[direct
].name
)
5074 free (filter
->plist
[direct
].name
);
5075 filter
->plist
[direct
].name
= strdup (name_str
);
5076 filter
->plist
[direct
].plist
= prefix_list_lookup (afi
, name_str
);
5082 bgp_prefix_list_unset (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
5083 char *name_str
, char *direct_str
)
5085 struct peer_conf
*conf
;
5087 struct bgp_filter
*filter
;
5089 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
5093 /* Check filter direction. */
5094 if (strncmp (direct_str
, "i", 1) == 0)
5096 else if (strncmp (direct_str
, "o", 1) == 0)
5097 direct
= FILTER_OUT
;
5100 vty_out (vty
, "filter direction must be [in|out]%s", VTY_NEWLINE
);
5104 filter
= &conf
->filter
[afi
][safi
];
5106 if (! filter
->plist
[direct
].name
)
5108 vty_out (vty
, "There is no such filter: %s%s", name_str
, VTY_NEWLINE
);
5111 if (strcmp (filter
->plist
[direct
].name
, name_str
) != 0)
5113 vty_out (vty
, "There is no such filter: %s%s", name_str
, VTY_NEWLINE
);
5116 free (filter
->plist
[direct
].name
);
5117 filter
->plist
[direct
].name
= NULL
;
5118 filter
->plist
[direct
].plist
= NULL
;
5123 /* Update prefix-list list. */
5125 bgp_prefix_list_update ()
5127 struct listnode
*nn
, *nm
;
5129 struct peer_conf
*conf
;
5130 struct bgp_filter
*filter
;
5135 LIST_LOOP (bgp_list
, bgp
, nn
)
5137 LIST_LOOP (bgp
->peer_conf
, conf
, nm
)
5139 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
5140 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
5142 filter
= &conf
->filter
[afi
][safi
];
5144 for (direct
= FILTER_IN
; direct
< FILTER_MAX
; direct
++)
5146 if (filter
->plist
[direct
].name
)
5147 filter
->plist
[direct
].plist
=
5148 prefix_list_lookup (afi
, filter
->plist
[direct
].name
);
5150 filter
->plist
[direct
].plist
= NULL
;
5157 DEFUN (neighbor_prefix_list
,
5158 neighbor_prefix_list_cmd
,
5159 NEIGHBOR_CMD
"prefix-list WORD (in|out)",
5162 "Filter updates to/from this neighbor\n"
5163 "Name of a prefix list\n"
5164 "Filter incoming updates\n"
5165 "Filter outgoing updates\n")
5167 return bgp_prefix_list_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5171 DEFUN (no_neighbor_prefix_list
,
5172 no_neighbor_prefix_list_cmd
,
5173 NO_NEIGHBOR_CMD
"prefix-list WORD (in|out)",
5177 "Filter updates to/from this neighbor\n"
5178 "Name of a prefix list\n"
5179 "Filter incoming updates\n"
5180 "Filter outgoing updates\n")
5182 return bgp_prefix_list_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5186 DEFUN (ipv6_bgp_neighbor_prefix_list
,
5187 ipv6_bgp_neighbor_prefix_list_cmd
,
5188 NEIGHBOR_CMD
"prefix-list WORD (in|out)",
5191 "Filter updates to/from this neighbor\n"
5192 "Name of a prefix list\n"
5193 "Filter incoming updates\n"
5194 "Filter outgoing updates\n")
5196 return bgp_prefix_list_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5200 DEFUN (no_ipv6_bgp_neighbor_prefix_list
,
5201 no_ipv6_bgp_neighbor_prefix_list_cmd
,
5202 NO_NEIGHBOR_CMD
"prefix-list WORD (in|out)",
5206 "Filter updates to/from this neighbor\n"
5207 "Name of a prefix list\n"
5208 "Filter incoming updates\n"
5209 "Filter outgoing updates\n")
5211 return bgp_prefix_list_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5215 ALIAS (ipv6_bgp_neighbor_prefix_list
,
5216 old_ipv6_bgp_neighbor_prefix_list_cmd
,
5217 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) prefix-list WORD (in|out)",
5223 "Filter updates to/from this neighbor\n"
5224 "Name of a prefix list\n"
5225 "Filter incoming updates\n"
5226 "Filter outgoing updates\n")
5228 ALIAS (no_ipv6_bgp_neighbor_prefix_list
,
5229 old_no_ipv6_bgp_neighbor_prefix_list_cmd
,
5230 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) prefix-list WORD (in|out)",
5237 "Filter updates to/from this neighbor\n"
5238 "Name of a prefix list\n"
5239 "Filter incoming updates\n"
5240 "Filter outgoing updates\n")
5243 bgp_aslist_set (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
5244 char *name_str
, char *direct_str
)
5246 struct as_list
*as_list_lookup (char *name
);
5247 struct peer_conf
*conf
;
5249 struct bgp_filter
*filter
;
5251 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
5254 if (! conf
->afc
[afi
][safi
])
5256 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
5261 /* Check filter direction. */
5262 if (strncmp (direct_str
, "i", 1) == 0)
5264 else if (strncmp (direct_str
, "o", 1) == 0)
5265 direct
= FILTER_OUT
;
5268 vty_out (vty
, "filter direction must be [in|out]%s", VTY_NEWLINE
);
5272 filter
= &conf
->filter
[afi
][safi
];
5274 if (filter
->aslist
[direct
].name
)
5275 free (filter
->aslist
[direct
].name
);
5277 filter
->aslist
[direct
].name
= strdup (name_str
);
5278 filter
->aslist
[direct
].aslist
= as_list_lookup (name_str
);
5284 bgp_aslist_unset (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
5285 char *name_str
, char *direct_str
)
5287 struct peer_conf
*conf
;
5289 struct bgp_filter
*filter
;
5291 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
5294 if (! conf
->afc
[afi
][safi
])
5296 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
5301 /* Check filter direction. */
5302 if (strncmp (direct_str
, "i", 1) == 0)
5304 else if (strncmp (direct_str
, "o", 1) == 0)
5305 direct
= FILTER_OUT
;
5308 vty_out (vty
, "filter direction must be [in|out]%s", VTY_NEWLINE
);
5312 filter
= &conf
->filter
[afi
][safi
];
5314 if (! filter
->aslist
[direct
].name
)
5316 vty_out (vty
, "There is no such filter: %s%s", name_str
, VTY_NEWLINE
);
5319 if (strcmp (filter
->aslist
[direct
].name
, name_str
) != 0)
5321 vty_out (vty
, "There is no such filter: %s%s", name_str
, VTY_NEWLINE
);
5324 free (filter
->aslist
[direct
].name
);
5325 filter
->aslist
[direct
].name
= NULL
;
5326 filter
->aslist
[direct
].aslist
= NULL
;
5332 bgp_aslist_update ()
5337 struct listnode
*nn
, *nm
;
5339 struct peer_conf
*conf
;
5340 struct bgp_filter
*filter
;
5342 LIST_LOOP (bgp_list
, bgp
, nn
)
5344 LIST_LOOP (bgp
->peer_conf
, conf
, nm
)
5346 for (afi
= AFI_IP
; afi
< AFI_MAX
; afi
++)
5347 for (safi
= SAFI_UNICAST
; safi
< SAFI_MAX
; safi
++)
5349 filter
= &conf
->filter
[afi
][safi
];
5351 for (direct
= FILTER_IN
; direct
< FILTER_MAX
; direct
++)
5353 if (filter
->aslist
[direct
].name
)
5354 filter
->aslist
[direct
].aslist
=
5355 as_list_lookup (filter
->aslist
[direct
].name
);
5357 filter
->aslist
[direct
].aslist
= NULL
;
5364 DEFUN (neighbor_filter_list
,
5365 neighbor_filter_list_cmd
,
5366 NEIGHBOR_CMD
"filter-list WORD (in|out)",
5369 "Establish BGP filters\n"
5370 "AS path access-list name\n"
5371 "Filter incoming routes\n"
5372 "Filter outgoing routes\n")
5374 return bgp_aslist_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5378 DEFUN (no_neighbor_filter_list
,
5379 no_neighbor_filter_list_cmd
,
5380 NO_NEIGHBOR_CMD
"filter-list WORD (in|out)",
5384 "Establish BGP filters\n"
5385 "AS path access-list name\n"
5386 "Filter incoming routes\n"
5387 "Filter outgoing routes\n")
5389 return bgp_aslist_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5393 DEFUN (ipv6_bgp_neighbor_filter_list
,
5394 ipv6_bgp_neighbor_filter_list_cmd
,
5395 NEIGHBOR_CMD
"filter-list WORD (in|out)",
5398 "Establish BGP filters\n"
5399 "AS path access-list name\n"
5400 "Filter incoming routes\n"
5401 "Filter outgoing routes\n")
5403 return bgp_aslist_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, argv
[1], argv
[2]);
5406 DEFUN (no_ipv6_bgp_neighbor_filter_list
,
5407 no_ipv6_bgp_neighbor_filter_list_cmd
,
5408 NO_NEIGHBOR_CMD
"filter-list WORD (in|out)",
5412 "Establish BGP filters\n"
5413 "AS path access-list name\n"
5414 "Filter incoming routes\n"
5415 "Filter outgoing routes\n")
5417 return bgp_aslist_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
, argv
[1], argv
[2]);
5420 ALIAS (ipv6_bgp_neighbor_filter_list
,
5421 old_ipv6_bgp_neighbor_filter_list_cmd
,
5422 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) filter-list WORD (in|out)",
5428 "Establish BGP filters\n"
5429 "AS path access-list name\n"
5430 "Filter incoming routes\n"
5431 "Filter outgoing routes\n")
5433 ALIAS (no_ipv6_bgp_neighbor_filter_list
,
5434 old_no_ipv6_bgp_neighbor_filter_list_cmd
,
5435 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) filter-list WORD (in|out)",
5442 "Establish BGP filters\n"
5443 "AS path access-list name\n"
5444 "Filter incoming routes\n"
5445 "Filter outgoing routes\n")
5447 /* Set route-map to the peer. */
5449 bgp_route_map_set (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
5450 char *name_str
, char *direct_str
)
5452 struct peer_conf
*conf
;
5454 struct bgp_filter
*filter
;
5456 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
5459 if (! conf
->afc
[afi
][safi
])
5461 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
5466 /* Check filter direction. */
5467 if (strncmp (direct_str
, "i", 1) == 0)
5469 else if (strncmp (direct_str
, "o", 1) == 0)
5470 direct
= FILTER_OUT
;
5473 vty_out (vty
, "filter direction must be [in|out]%s", VTY_NEWLINE
);
5477 filter
= &conf
->filter
[afi
][safi
];
5479 if (filter
->map
[direct
].name
)
5480 free (filter
->map
[direct
].name
);
5482 filter
->map
[direct
].name
= strdup (name_str
);
5483 filter
->map
[direct
].map
= route_map_lookup_by_name (name_str
);
5488 /* Unset route-map from the peer. */
5490 bgp_route_map_unset (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
5491 char *name_str
, char *direct_str
)
5493 struct peer_conf
*conf
;
5495 struct bgp_filter
*filter
;
5497 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
5500 if (! conf
->afc
[afi
][safi
])
5502 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
5507 /* Check filter direction. */
5508 if (strncmp (direct_str
, "i", 1) == 0)
5510 else if (strncmp (direct_str
, "o", 1) == 0)
5511 direct
= FILTER_OUT
;
5514 vty_out (vty
, "filter direction must be [in|out]%s", VTY_NEWLINE
);
5518 filter
= &conf
->filter
[afi
][safi
];
5520 if (! filter
->map
[direct
].name
)
5522 vty_out (vty
, "There is no such filter: %s%s", name_str
, VTY_NEWLINE
);
5525 if (strcmp (filter
->map
[direct
].name
, name_str
) != 0)
5527 vty_out (vty
, "There is no such filter: %s%s", name_str
, VTY_NEWLINE
);
5531 free (filter
->map
[direct
].name
);
5532 filter
->map
[direct
].name
= NULL
;
5533 filter
->map
[direct
].map
= NULL
;
5538 DEFUN (neighbor_route_map
,
5539 neighbor_route_map_cmd
,
5540 NEIGHBOR_CMD
"route-map WORD (in|out)",
5543 "Apply route map to neighbor\n"
5544 "Name of route map\n"
5545 "Apply map to incoming routes\n"
5546 "Apply map to outbound routes\n")
5548 return bgp_route_map_set (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5552 DEFUN (no_neighbor_route_map
,
5553 no_neighbor_route_map_cmd
,
5554 NO_NEIGHBOR_CMD
"route-map WORD (in|out)",
5558 "Apply route map to neighbor\n"
5559 "Name of route map\n"
5560 "Apply map to incoming routes\n"
5561 "Apply map to outbound routes\n")
5563 return bgp_route_map_unset (vty
, argv
[0], AFI_IP
, bgp_node_safi (vty
),
5567 DEFUN (ipv6_bgp_neighbor_route_map
,
5568 ipv6_bgp_neighbor_route_map_cmd
,
5569 NEIGHBOR_CMD
"route-map WORD (in|out)",
5572 "Apply route map to neighbor\n"
5573 "Name of route map\n"
5574 "Apply map to incoming routes\n"
5575 "Apply map to outbound routes\n")
5577 return bgp_route_map_set (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5581 DEFUN (no_ipv6_bgp_neighbor_route_map
,
5582 no_ipv6_bgp_neighbor_route_map_cmd
,
5583 NO_NEIGHBOR_CMD
"route-map WORD (in|out)",
5587 "Apply route map to neighbor\n"
5588 "Name of route map\n"
5589 "Apply map to incoming routes\n"
5590 "Apply map to outbound routes\n")
5592 return bgp_route_map_unset (vty
, argv
[0], AFI_IP6
, SAFI_UNICAST
,
5596 ALIAS (ipv6_bgp_neighbor_route_map
,
5597 old_ipv6_bgp_neighbor_route_map_cmd
,
5598 "ipv6 bgp neighbor (A.B.C.D|X:X::X:X) route-map WORD (in|out)",
5604 "Apply route map to neighbor\n"
5605 "Name of route map\n"
5606 "Apply map to incoming routes\n"
5607 "Apply map to outbound routes\n")
5609 ALIAS (no_ipv6_bgp_neighbor_route_map
,
5610 old_no_ipv6_bgp_neighbor_route_map_cmd
,
5611 "no ipv6 bgp neighbor (A.B.C.D|X:X::X:X) route-map WORD (in|out)",
5618 "Apply route map to neighbor\n"
5619 "Name of route map\n"
5620 "Apply map to incoming routes\n"
5621 "Apply map to outbound routes\n")
5624 bgp_maximum_prefix_set (struct vty
*vty
, char *ip_str
, afi_t afi
, safi_t safi
,
5625 char *num_str
, int warning
)
5627 struct peer_conf
*conf
;
5629 char *endptr
= NULL
;
5631 /* Lookup peer configuration. */
5632 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
5635 if (! conf
->afc
[afi
][safi
])
5637 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
5642 /* Convert string to unsigned long. */
5643 num
= strtoul (num_str
, &endptr
, 10);
5644 if (num
== ULONG_MAX
|| *endptr
!= '\0')
5646 vty_out (vty
, "%% maximum-prefix count must be positive integer%s",
5651 /* Set maximum prefix value. */
5652 conf
->pmax
[afi
][safi
] = num
;
5653 conf
->pmax_warning
[afi
][safi
] = (warning
? 1 : 0);
5659 bgp_maximum_prefix_unset (struct vty
*vty
, char *ip_str
,
5660 afi_t afi
, safi_t safi
)
5662 struct peer_conf
*conf
;
5664 /* Lookup peer configuration. */
5665 conf
= peer_conf_lookup_vty (vty
, ip_str
, afi
);
5668 if (! conf
->afc
[afi
][safi
])
5670 vty_out (vty
, "%% Activate the neighbor for the address family first%s",
5675 conf
->pmax
[afi
][safi
] = 0;
5676 conf
->pmax_warning
[afi
][safi
] = 0;
5681 /* Maximum number of prefix configuration. prefix count is different
5682 for each peer configuration. So this configuration can be set for
5683 each peer configuration. */
5684 DEFUN (neighbor_maximum_prefix
,
5685 neighbor_maximum_prefix_cmd
,
5686 NEIGHBOR_CMD
"maximum-prefix <1-4294967295>",
5689 "Maximum number of prefix accept from this peer\n"
5690 "maximum no. of prefix limit\n")
5692 return bgp_maximum_prefix_set (vty
, argv
[0], bgp_node_afi (vty
),
5693 bgp_node_safi (vty
), argv
[1], 0);
5696 DEFUN (neighbor_maximum_prefix_warning
,
5697 neighbor_maximum_prefix_warning_cmd
,
5698 NEIGHBOR_CMD
"maximum-prefix <1-4294967295> warning-only",
5701 "Maximum number of prefix accept from this peer\n"
5702 "maximum no. of prefix limit\n"
5703 "Only give warning message when limit is exceeded\n")
5705 return bgp_maximum_prefix_set (vty
, argv
[0], bgp_node_afi (vty
),
5706 bgp_node_safi (vty
), argv
[1], 1);
5709 DEFUN (no_neighbor_maximum_prefix
,
5710 no_neighbor_maximum_prefix_cmd
,
5711 NO_NEIGHBOR_CMD
"maximum-prefix",
5715 "Maximum number of prefix accept from this peer\n")
5717 return bgp_maximum_prefix_unset (vty
, argv
[0], bgp_node_afi (vty
),
5718 bgp_node_safi (vty
));
5721 ALIAS (no_neighbor_maximum_prefix
,
5722 no_neighbor_maximum_prefix_val_cmd
,
5723 NO_NEIGHBOR_CMD
"maximum-prefix <1-4294967295>",
5727 "Maximum number of prefix accept from this peer\n"
5728 "maximum no. of prefix limit\n")
5730 ALIAS (no_neighbor_maximum_prefix
,
5731 no_neighbor_maximum_prefix_val2_cmd
,
5732 NO_NEIGHBOR_CMD
"maximum-prefix <1-4294967295> warning-only",
5736 "Maximum number of prefix accept from this peer\n"
5737 "maximum no. of prefix limit\n"
5738 "Only give warning message when limit is exceeded\n")
5740 /* Address family configuration. */
5741 DEFUN (address_family_ipv4_multicast
,
5742 address_family_ipv4_multicast_cmd
,
5743 "address-family ipv4 multicast",
5744 "Enter Address Family command mode\n"
5748 vty
->node
= BGP_IPV4M_NODE
;
5752 DEFUN (address_family_ipv6_unicast
,
5753 address_family_ipv6_unicast_cmd
,
5754 "address-family ipv6 unicast",
5755 "Enter Address Family command mode\n"
5759 vty
->node
= BGP_IPV6_NODE
;
5763 ALIAS (address_family_ipv6_unicast
,
5764 address_family_ipv6_cmd
,
5765 "address-family ipv6",
5766 "Enter Address Family command mode\n"
5769 DEFUN (exit_address_family
,
5770 exit_address_family_cmd
,
5771 "exit-address-family",
5772 "Exit from Address Family configuration mode\n")
5774 if (vty
->node
== BGP_IPV4M_NODE
5775 || vty
->node
== BGP_VPNV4_NODE
5776 || vty
->node
== BGP_IPV6_NODE
)
5777 vty
->node
= BGP_NODE
;
5781 /* BGP clear types. */
5791 peer_have_afi (struct peer
*peer
, int afi
)
5793 return ((afi
== AFI_IP
&& (peer
->afc
[AFI_IP
][SAFI_UNICAST
]
5794 || peer
->afc
[AFI_IP
][SAFI_MULTICAST
]
5795 || peer
->afc
[AFI_IP
][SAFI_MPLS_VPN
]))
5796 || (afi
== AFI_IP6
&& (peer
->afc
[AFI_IP6
][SAFI_UNICAST
]
5797 || peer
->afc
[AFI_IP6
][SAFI_MULTICAST
]
5798 || peer
->afc
[AFI_IP6
][SAFI_MPLS_VPN
])));
5801 /* `clear ip bgp' functions. */
5803 clear_bgp (struct vty
*vty
, int afi
, enum clear_type type
, char *arg
)
5807 struct listnode
*nn
;
5809 unsigned long as_ul
;
5810 char *endptr
= NULL
;
5814 /* Clear all bgp neighbors. */
5815 if (type
== clear_all
)
5817 LIST_LOOP (peer_list
, peer
, nn
)
5819 if (peer_have_afi (peer
, afi
))
5821 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_SHUTDOWN
))
5823 UNSET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
5824 peer
->v_start
= BGP_INIT_START_TIMER
;
5825 BGP_EVENT_ADD (peer
, BGP_Stop
);
5829 vty_out (vty
, "All bgp neighbors cleared%s", VTY_NEWLINE
);
5833 /* Clear specified peer. Arg is string of the peer. */
5834 else if (type
== clear_peer
)
5838 /* Make sockunion for lookup. */
5839 ret
= str2sockunion (arg
, &su
);
5842 vty_out (vty
, "Malformed address: %s%s", arg
, VTY_NEWLINE
);
5846 LIST_LOOP (peer_list
, peer
, nn
)
5848 if (peer_have_afi (peer
, afi
) && sockunion_same (&peer
->su
, &su
))
5850 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_SHUTDOWN
))
5852 UNSET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
5853 peer
->v_start
= BGP_INIT_START_TIMER
;
5854 BGP_EVENT_ADD (peer
, BGP_Stop
);
5861 vty_out (vty
, "neighbor %s is cleared%s", arg
, VTY_NEWLINE
);
5863 vty_out (vty
, "%%BGP: Unknown neighbor - \"%s\"%s", arg
, VTY_NEWLINE
);
5867 /* AS based clear. */
5868 else if (type
== clear_as
)
5872 as_ul
= strtoul(arg
, &endptr
, 10);
5874 if ((as_ul
== ULONG_MAX
) || (*endptr
!= '\0') || (as_ul
> USHRT_MAX
))
5876 vty_out (vty
, "Invalid neighbor specifier: %s%s", arg
,
5883 LIST_LOOP (peer_list
, peer
, nn
)
5885 if (peer_have_afi (peer
, afi
) && peer
->as
== as
)
5887 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_SHUTDOWN
))
5889 UNSET_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
);
5890 peer
->v_start
= BGP_INIT_START_TIMER
;
5891 BGP_EVENT_ADD (peer
, BGP_Stop
);
5897 vty_out (vty
, "All neighbors which AS is %s cleared%s", arg
,
5900 vty_out (vty
, "%%BGP: No peer is configured with AS %s%s", arg
,
5910 DEFUN (clear_ip_bgp_all
,
5911 clear_ip_bgp_all_cmd
,
5916 "Clear all peers\n")
5918 return clear_bgp (vty
, AFI_IP
, clear_all
, NULL
);
5921 DEFUN (clear_ip_bgp_peer
,
5922 clear_ip_bgp_peer_cmd
,
5923 "clear ip bgp (A.B.C.D|X:X::X:X)",
5927 "BGP neighbor IP address to clear\n"
5928 "BGP neighbor IPv6 address to clear\n")
5930 return clear_bgp (vty
, AFI_IP
, clear_peer
, argv
[0]);
5933 DEFUN (clear_ip_bgp_peer_group
,
5934 clear_ip_bgp_peer_group_cmd
,
5935 "clear ip bgp peer-group WORD",
5939 "Clear all members of peer-group\n"
5940 "BGP peer-group name\n")
5942 return clear_bgp (vty
, AFI_IP
, clear_peer_group
, argv
[0]);
5945 DEFUN (clear_ip_bgp_as
,
5946 clear_ip_bgp_as_cmd
,
5947 "clear ip bgp <1-65535>",
5951 "Clear peers with the AS number\n")
5953 return clear_bgp (vty
, AFI_IP
, clear_as
, argv
[0]);
5957 DEFUN (clear_bgp_all
,
5962 "Clear all peers\n")
5964 return clear_bgp (vty
, AFI_IP6
, clear_all
, NULL
);
5967 ALIAS (clear_bgp_all
,
5968 clear_bgp_ipv6_all_cmd
,
5973 "Clear all peers\n")
5975 DEFUN (clear_bgp_peer
,
5977 "clear bgp (A.B.C.D|X:X::X:X)",
5980 "BGP neighbor address to clear\n"
5981 "BGP IPv6 neighbor to clear\n")
5983 return clear_bgp (vty
, AFI_IP6
, clear_peer
, argv
[0]);
5986 ALIAS (clear_bgp_peer
,
5987 clear_bgp_ipv6_peer_cmd
,
5988 "clear bgp ipv6 (A.B.C.D|X:X::X:X)",
5992 "BGP neighbor address to clear\n"
5993 "BGP IPv6 neighbor to clear\n")
5995 DEFUN (clear_bgp_peer_group
,
5996 clear_bgp_peer_group_cmd
,
5997 "clear bgp peer-group WORD",
6000 "Clear all members of peer-group\n"
6001 "BGP peer-group name\n")
6003 return clear_bgp (vty
, AFI_IP6
, clear_peer_group
, argv
[0]);
6006 ALIAS (clear_bgp_peer_group
,
6007 clear_bgp_ipv6_peer_group_cmd
,
6008 "clear bgp ipv6 peer-group WORD",
6012 "Clear all members of peer-group\n"
6013 "BGP peer-group name\n")
6015 DEFUN (clear_bgp_as
,
6017 "clear bgp <1-65535>",
6020 "Clear peers with the AS number\n")
6022 return clear_bgp (vty
, AFI_IP6
, clear_as
, argv
[0]);
6025 ALIAS (clear_bgp_as
,
6026 clear_bgp_ipv6_as_cmd
,
6027 "clear bgp ipv6 <1-65535>",
6031 "Clear peers with the AS number\n")
6032 #endif /* HAVE_IPV6 */
6034 /* Clear ip bgp neighbor soft in. */
6036 clear_bgp_soft_in (struct vty
*vty
, afi_t afi
, safi_t safi
, enum clear_type type
, char *arg
, int soft
)
6041 struct listnode
*nn
;
6043 unsigned long as_ul
;
6044 char *endptr
= NULL
;
6047 if (type
== clear_peer
)
6049 /* Looking up peer with IP address string. */
6050 ret
= str2sockunion (arg
, &su
);
6053 vty_out (vty
, "Malformed address: %s%s", arg
, VTY_NEWLINE
);
6058 if (type
== clear_as
)
6060 as_ul
= strtoul(arg
, &endptr
, 10);
6061 if ((as_ul
== ULONG_MAX
) || (*endptr
!= '\0') || (as_ul
> USHRT_MAX
))
6063 vty_out (vty
, "Invalid neighbor specifier: %s%s", arg
, VTY_NEWLINE
);
6069 LIST_LOOP (peer_list
, peer
, nn
)
6071 if ((type
== clear_peer
&& sockunion_same (&peer
->su
, &su
))
6072 || (type
== clear_as
&& peer
->as
== as
)
6073 || type
== clear_all
)
6076 if (peer
->afc
[afi
][safi
])
6078 if (peer
->status
== Established
)
6082 /* If neighbor has soft reconfiguration inbound flag.
6083 Use Adj-RIB-In database. */
6084 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
6086 if (safi
== SAFI_MPLS_VPN
)
6088 vty_out (vty
, "%%BGP: Soft-reconfiguration inbound is not supported for vpnv4%s", VTY_NEWLINE
);
6091 bgp_soft_reconfig_in (peer
, afi
, safi
);
6092 vty_out (vty
, "neighbor %s is inbound cleared (s)%s",
6093 peer
->host
, VTY_NEWLINE
);
6097 /* If neighbor has route refresh capability, send route refresh
6098 message to the peer. */
6099 if (peer
->refresh_nego_old
|| peer
->refresh_nego_new
)
6101 bgp_route_refresh_send (peer
, afi
, safi
);
6102 vty_out (vty
, "neighbor %s is inbound cleared (r)%s",
6103 peer
->host
, VTY_NEWLINE
);
6106 vty_out (vty
, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer
->host
, VTY_NEWLINE
, VTY_NEWLINE
);
6111 /* If neighbor has route refresh capability, send route refresh
6112 message to the peer. */
6113 if (peer
->refresh_nego_old
|| peer
->refresh_nego_new
)
6115 bgp_route_refresh_send (peer
, afi
, safi
);
6116 vty_out (vty
, "neighbor %s is inbound cleared (r)%s",
6117 peer
->host
, VTY_NEWLINE
);
6121 /* If neighbor has soft reconfiguration inbound flag.
6122 Use Adj-RIB-In database. */
6123 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_SOFT_RECONFIG
))
6125 if (safi
== SAFI_MPLS_VPN
)
6127 vty_out (vty
, "%%BGP: Soft-reconfiguration inbound is not supported for vpnv4%s", VTY_NEWLINE
);
6130 bgp_soft_reconfig_in (peer
, afi
, safi
);
6131 vty_out (vty
, "neighbor %s is inbound cleared (s)%s",
6132 peer
->host
, VTY_NEWLINE
);
6135 vty_out (vty
, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer
->host
, VTY_NEWLINE
, VTY_NEWLINE
);
6140 else if (type
== clear_peer
|| type
== clear_as
)
6141 vty_out (vty
, "%%BGP: Enable %s %s address family for the neighbor %s%s",
6142 afi
== AFI_IP6
? "IPv6" : safi
== SAFI_MPLS_VPN
? "VPNv4" : "IPv4",
6143 safi
== SAFI_MULTICAST
? "Multicast" : "Unicast",
6144 peer
->host
, VTY_NEWLINE
);
6148 if (! find
&& type
== clear_peer
)
6150 vty_out (vty
, "%%BGP: Unknown neighbor - \"%s\"%s", arg
, VTY_NEWLINE
);
6153 if (! find
&& type
== clear_as
)
6155 vty_out (vty
, "%%BGP: No peer is configured with AS %s%s", arg
, VTY_NEWLINE
);
6162 DEFUN (clear_ip_bgp_peer_soft_in
,
6163 clear_ip_bgp_peer_soft_in_cmd
,
6164 "clear ip bgp A.B.C.D soft in",
6168 "BGP neighbor address to clear\n"
6170 "Soft reconfig inbound update\n")
6172 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0], 1);
6175 DEFUN (clear_ip_bgp_peer_in
,
6176 clear_ip_bgp_peer_in_cmd
,
6177 "clear ip bgp A.B.C.D in",
6181 "BGP neighbor address to clear\n"
6182 "Soft reconfig inbound update\n")
6184 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0], 0);
6187 DEFUN (clear_ip_bgp_peer_ipv4_soft_in
,
6188 clear_ip_bgp_peer_ipv4_soft_in_cmd
,
6189 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft in",
6193 "BGP neighbor address to clear\n"
6195 "Address Family modifier\n"
6196 "Address Family modifier\n"
6198 "Soft reconfig inbound update\n")
6200 if (strncmp (argv
[1], "m", 1) == 0)
6201 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_peer
, argv
[0], 1);
6203 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0], 1);
6206 DEFUN (clear_ip_bgp_peer_ipv4_in
,
6207 clear_ip_bgp_peer_ipv4_in_cmd
,
6208 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) in",
6212 "BGP neighbor address to clear\n"
6214 "Address Family modifier\n"
6215 "Address Family modifier\n"
6216 "Soft reconfig inbound update\n")
6218 if (strncmp (argv
[1], "m", 1) == 0)
6219 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_peer
, argv
[0], 0);
6221 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0], 0);
6224 DEFUN (clear_ip_bgp_as_soft_in
,
6225 clear_ip_bgp_as_soft_in_cmd
,
6226 "clear ip bgp <1-65535> soft in",
6230 "Clear peers with the AS number\n"
6232 "Soft reconfig inbound update\n")
6234 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0], 1);
6237 DEFUN (clear_ip_bgp_as_in
,
6238 clear_ip_bgp_as_in_cmd
,
6239 "clear ip bgp <1-65535> in",
6243 "Clear peers with the AS number\n"
6244 "Soft reconfig inbound update\n")
6246 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0], 0);
6249 DEFUN (clear_ip_bgp_as_ipv4_soft_in
,
6250 clear_ip_bgp_as_ipv4_soft_in_cmd
,
6251 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft in",
6255 "Clear peers with the AS number\n"
6257 "Address Family modifier\n"
6258 "Address Family modifier\n"
6260 "Soft reconfig inbound update\n")
6262 if (strncmp (argv
[1], "m", 1) == 0)
6263 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_as
, argv
[0], 1);
6265 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0], 1);
6268 DEFUN (clear_ip_bgp_as_ipv4_in
,
6269 clear_ip_bgp_as_ipv4_in_cmd
,
6270 "clear ip bgp <1-65535> ipv4 (unicast|multicast) in",
6274 "Clear peers with the AS number\n"
6276 "Address Family modifier\n"
6277 "Address Family modifier\n"
6278 "Soft reconfig inbound update\n")
6280 if (strncmp (argv
[1], "m", 1) == 0)
6281 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_as
, argv
[0], 0);
6283 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0], 0);
6286 DEFUN (clear_ip_bgp_all_soft_in
,
6287 clear_ip_bgp_all_soft_in_cmd
,
6288 "clear ip bgp * soft in",
6294 "Soft reconfig inbound update\n")
6296 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
, 1);
6299 DEFUN (clear_ip_bgp_all_in
,
6300 clear_ip_bgp_all_in_cmd
,
6301 "clear ip bgp * in",
6306 "Soft reconfig inbound update\n")
6308 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
, 0);
6311 DEFUN (clear_ip_bgp_all_ipv4_soft_in
,
6312 clear_ip_bgp_all_ipv4_soft_in_cmd
,
6313 "clear ip bgp * ipv4 (unicast|multicast) soft in",
6319 "Address Family modifier\n"
6320 "Address Family modifier\n"
6322 "Soft reconfig inbound update\n")
6324 if (strncmp (argv
[0], "m", 1) == 0)
6325 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_all
, NULL
, 1);
6327 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
, 1);
6330 DEFUN (clear_ip_bgp_all_ipv4_in
,
6331 clear_ip_bgp_all_ipv4_in_cmd
,
6332 "clear ip bgp * ipv4 (unicast|multicast) in",
6338 "Address Family modifier\n"
6339 "Address Family modifier\n"
6340 "Soft reconfig inbound update\n")
6342 if (strncmp (argv
[0], "m", 1) == 0)
6343 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_all
, NULL
, 0);
6345 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
, 0);
6349 DEFUN (clear_ip_bgp_peer_vpnv4_soft_in
,
6350 clear_ip_bgp_peer_vpnv4_soft_in_cmd
,
6351 "clear ip bgp A.B.C.D vpnv4 unicast soft in",
6355 "BGP neighbor address to clear\n"
6357 "Address Family Modifier\n"
6359 "Soft reconfig inbound update\n")
6361 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_peer
, argv
[0], 0);
6364 DEFUN (clear_ip_bgp_peer_vpnv4_in
,
6365 clear_ip_bgp_peer_vpnv4_in_cmd
,
6366 "clear ip bgp A.B.C.D vpnv4 unicast in",
6370 "BGP neighbor address to clear\n"
6372 "Address Family Modifier\n"
6373 "Soft reconfig inbound update\n")
6375 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_peer
, argv
[0], 0);
6378 DEFUN (clear_ip_bgp_as_vpnv4_soft_in
,
6379 clear_ip_bgp_as_vpnv4_soft_in_cmd
,
6380 "clear ip bgp <1-65535> vpnv4 unicast soft in",
6384 "Clear peers with the AS number\n"
6386 "Address Family modifier\n"
6388 "Soft reconfig inbound update\n")
6390 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_as
, argv
[0], 0);
6393 DEFUN (clear_ip_bgp_as_vpnv4_in
,
6394 clear_ip_bgp_as_vpnv4_in_cmd
,
6395 "clear ip bgp <1-65535> vpnv4 unicast in",
6399 "Clear peers with the AS number\n"
6401 "Address Family modifier\n"
6402 "Soft reconfig inbound update\n")
6404 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_as
, argv
[0], 0);
6407 DEFUN (clear_ip_bgp_all_vpnv4_soft_in
,
6408 clear_ip_bgp_all_vpnv4_soft_in_cmd
,
6409 "clear ip bgp * vpnv4 unicast soft in",
6415 "Address Family Modifier\n"
6417 "Soft reconfig inbound update\n")
6419 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_all
, NULL
, 0);
6422 DEFUN (clear_ip_bgp_all_vpnv4_in
,
6423 clear_ip_bgp_all_vpnv4_in_cmd
,
6424 "clear ip bgp * vpnv4 unicast in",
6430 "Address Family Modifier\n"
6431 "Soft reconfig inbound update\n")
6433 return clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_all
, NULL
, 0);
6436 /* Clear ip bgp neighbor soft out. */
6438 clear_bgp_soft_out (struct vty
*vty
, afi_t afi
, safi_t safi
, enum clear_type type
, char *arg
)
6443 struct listnode
*nn
;
6445 unsigned long as_ul
;
6446 char *endptr
= NULL
;
6449 if (type
== clear_peer
)
6451 /* Looking up peer with IP address string. */
6452 ret
= str2sockunion (arg
, &su
);
6455 vty_out (vty
, "Malformed address: %s%s", arg
, VTY_NEWLINE
);
6460 if (type
== clear_as
)
6462 as_ul
= strtoul(arg
, &endptr
, 10);
6463 if ((as_ul
== ULONG_MAX
) || (*endptr
!= '\0') || (as_ul
> USHRT_MAX
))
6465 vty_out (vty
, "Invalid neighbor specifier: %s%s", arg
, VTY_NEWLINE
);
6471 LIST_LOOP (peer_list
, peer
, nn
)
6473 if ((type
== clear_peer
&& sockunion_same (&peer
->su
, &su
))
6474 || (type
== clear_as
&& peer
->as
== as
)
6475 || type
== clear_all
)
6478 if (peer
->afc
[afi
][safi
])
6480 if (peer
->status
== Established
)
6482 /* Performing soft out is same as receiving route
6484 bgp_refresh_table (peer
, afi
, safi
);
6485 vty_out (vty
, "neighbor %s is outbound cleared%s",
6486 peer
->host
, VTY_NEWLINE
);
6489 else if (type
== clear_peer
|| type
== clear_as
)
6490 vty_out (vty
, "%%BGP: Enable %s %s address family for the neighbor %s%s",
6491 afi
== AFI_IP6
? "IPv6" : safi
== SAFI_MPLS_VPN
? "VPNv4" : "IPv4",
6492 safi
== SAFI_MULTICAST
? "Multicast" : "Unicast",
6493 peer
->host
, VTY_NEWLINE
);
6497 if (! find
&& type
== clear_peer
)
6499 vty_out (vty
, "%%BGP: Unknown neighbor - \"%s\"%s", arg
, VTY_NEWLINE
);
6502 if (! find
&& type
== clear_as
)
6504 vty_out (vty
, "%%BGP: No peer is configured with AS %s%s", arg
, VTY_NEWLINE
);
6511 DEFUN (clear_ip_bgp_peer_soft_out
,
6512 clear_ip_bgp_peer_soft_out_cmd
,
6513 "clear ip bgp A.B.C.D soft out",
6517 "BGP neighbor address to clear\n"
6519 "Soft reconfig outbound update\n")
6521 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0]);
6524 ALIAS (clear_ip_bgp_peer_soft_out
,
6525 clear_ip_bgp_peer_out_cmd
,
6526 "clear ip bgp A.B.C.D out",
6530 "BGP neighbor address to clear\n"
6531 "Soft reconfig outbound update\n")
6533 DEFUN (clear_ip_bgp_peer_ipv4_soft_out
,
6534 clear_ip_bgp_peer_ipv4_soft_out_cmd
,
6535 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft out",
6539 "BGP neighbor address to clear\n"
6541 "Address Family modifier\n"
6542 "Address Family modifier\n"
6544 "Soft reconfig outbound update\n")
6546 if (strncmp (argv
[1], "m", 1) == 0)
6547 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MULTICAST
, clear_peer
, argv
[0]);
6549 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0]);
6552 ALIAS (clear_ip_bgp_peer_ipv4_soft_out
,
6553 clear_ip_bgp_peer_ipv4_out_cmd
,
6554 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) out",
6558 "BGP neighbor address to clear\n"
6560 "Address Family modifier\n"
6561 "Address Family modifier\n"
6562 "Soft reconfig outbound update\n")
6564 DEFUN (clear_ip_bgp_as_soft_out
,
6565 clear_ip_bgp_as_soft_out_cmd
,
6566 "clear ip bgp <1-65535> soft out",
6570 "Clear peers with the AS number\n"
6572 "Soft reconfig outbound update\n")
6574 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0]);
6577 ALIAS (clear_ip_bgp_as_soft_out
,
6578 clear_ip_bgp_as_out_cmd
,
6579 "clear ip bgp <1-65535> out",
6583 "Clear peers with the AS number\n"
6584 "Soft reconfig outbound update\n")
6586 DEFUN (clear_ip_bgp_as_ipv4_soft_out
,
6587 clear_ip_bgp_as_ipv4_soft_out_cmd
,
6588 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft out",
6592 "Clear peers with the AS number\n"
6594 "Address Family modifier\n"
6595 "Address Family modifier\n"
6597 "Soft reconfig outbound update\n")
6599 if (strncmp (argv
[1], "m", 1) == 0)
6600 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MULTICAST
, clear_as
, argv
[0]);
6602 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0]);
6605 ALIAS (clear_ip_bgp_as_ipv4_soft_out
,
6606 clear_ip_bgp_as_ipv4_out_cmd
,
6607 "clear ip bgp <1-65535> ipv4 (unicast|multicast) out",
6611 "Clear peers with the AS number\n"
6613 "Address Family modifier\n"
6614 "Address Family modifier\n"
6615 "Soft reconfig outbound update\n")
6617 DEFUN (clear_ip_bgp_all_soft_out
,
6618 clear_ip_bgp_all_soft_out_cmd
,
6619 "clear ip bgp * soft out",
6625 "Soft reconfig outbound update\n")
6627 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
);
6630 ALIAS (clear_ip_bgp_all_soft_out
,
6631 clear_ip_bgp_all_out_cmd
,
6632 "clear ip bgp * out",
6637 "Soft reconfig outbound update\n")
6639 DEFUN (clear_ip_bgp_all_ipv4_soft_out
,
6640 clear_ip_bgp_all_ipv4_soft_out_cmd
,
6641 "clear ip bgp * ipv4 (unicast|multicast) soft out",
6647 "Address Family modifier\n"
6648 "Address Family modifier\n"
6650 "Soft reconfig outbound update\n")
6652 if (strncmp (argv
[0], "m", 1) == 0)
6653 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MULTICAST
, clear_all
, NULL
);
6655 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
);
6658 ALIAS (clear_ip_bgp_all_ipv4_soft_out
,
6659 clear_ip_bgp_all_ipv4_out_cmd
,
6660 "clear ip bgp * ipv4 (unicast|multicast) out",
6666 "Address Family modifier\n"
6667 "Address Family modifier\n"
6668 "Soft reconfig outbound update\n")
6670 DEFUN (clear_ip_bgp_peer_vpnv4_soft_out
,
6671 clear_ip_bgp_peer_vpnv4_soft_out_cmd
,
6672 "clear ip bgp A.B.C.D vpnv4 unicast soft out",
6676 "BGP neighbor address to clear\n"
6678 "Address Family Modifier\n"
6680 "Soft reconfig outbound update\n")
6682 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_peer
, argv
[0]);
6685 ALIAS (clear_ip_bgp_peer_vpnv4_soft_out
,
6686 clear_ip_bgp_peer_vpnv4_out_cmd
,
6687 "clear ip bgp A.B.C.D vpnv4 unicast out",
6691 "BGP neighbor address to clear\n"
6693 "Address Family Modifier\n"
6694 "Soft reconfig outbound update\n")
6696 DEFUN (clear_ip_bgp_as_vpnv4_soft_out
,
6697 clear_ip_bgp_as_vpnv4_soft_out_cmd
,
6698 "clear ip bgp <1-65535> vpnv4 unicast soft out",
6702 "Clear peers with the AS number\n"
6704 "Address Family modifier\n"
6706 "Soft reconfig outbound update\n")
6708 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_as
, argv
[0]);
6711 ALIAS (clear_ip_bgp_as_vpnv4_soft_out
,
6712 clear_ip_bgp_as_vpnv4_out_cmd
,
6713 "clear ip bgp <1-65535> vpnv4 unicast out",
6717 "Clear peers with the AS number\n"
6719 "Address Family modifier\n"
6720 "Soft reconfig outbound update\n")
6722 DEFUN (clear_ip_bgp_all_vpnv4_soft_out
,
6723 clear_ip_bgp_all_vpnv4_soft_out_cmd
,
6724 "clear ip bgp * vpnv4 unicast soft out",
6730 "Address Family Modifier\n"
6732 "Soft reconfig outbound update\n")
6734 return clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_all
, NULL
);
6737 ALIAS (clear_ip_bgp_all_vpnv4_soft_out
,
6738 clear_ip_bgp_all_vpnv4_out_cmd
,
6739 "clear ip bgp * vpnv4 unicast out",
6745 "Address Family Modifier\n"
6746 "Soft reconfig outbound update\n")
6748 /* soft reset both inbound and outbound */
6749 DEFUN (clear_ip_bgp_peer_soft
,
6750 clear_ip_bgp_peer_soft_cmd
,
6751 "clear ip bgp A.B.C.D soft",
6755 "BGP neighbor address to clear\n"
6758 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0]) == CMD_SUCCESS
)
6759 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0], 0);
6764 DEFUN (clear_ip_bgp_peer_ipv4_soft
,
6765 clear_ip_bgp_peer_ipv4_soft_cmd
,
6766 "clear ip bgp A.B.C.D ipv4 (unicast|multicast) soft",
6770 "BGP neighbor address to clear\n"
6772 "Address Family Modifier\n"
6773 "Address Family Modifier\n"
6776 if (strncmp (argv
[1], "m", 1) == 0)
6778 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MULTICAST
, clear_peer
, argv
[0]) == CMD_SUCCESS
)
6779 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_peer
, argv
[0], 0);
6782 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0]) == CMD_SUCCESS
)
6783 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_peer
, argv
[0], 0);
6788 DEFUN (clear_ip_bgp_as_soft
,
6789 clear_ip_bgp_as_soft_cmd
,
6790 "clear ip bgp <1-65535> soft",
6794 "Clear peers with the AS number\n"
6797 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0]) == CMD_SUCCESS
)
6798 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0], 0);
6803 DEFUN (clear_ip_bgp_as_ipv4_soft
,
6804 clear_ip_bgp_as_ipv4_soft_cmd
,
6805 "clear ip bgp <1-65535> ipv4 (unicast|multicast) soft",
6809 "Clear peers with the AS number\n"
6811 "Address Family Modifier\n"
6812 "Address Family Modifier\n"
6815 if (strncmp (argv
[1], "m", 1) == 0)
6817 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MULTICAST
, clear_as
, argv
[0]) == CMD_SUCCESS
)
6818 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_as
, argv
[0], 0);
6821 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0]) == CMD_SUCCESS
)
6822 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_as
, argv
[0], 0);
6827 DEFUN (clear_ip_bgp_all_soft
,
6828 clear_ip_bgp_all_soft_cmd
,
6829 "clear ip bgp * soft",
6836 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
) == CMD_SUCCESS
)
6837 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
, 0);
6842 DEFUN (clear_ip_bgp_all_ipv4_soft
,
6843 clear_ip_bgp_all_ipv4_soft_cmd
,
6844 "clear ip bgp * ipv4 (unicast|multicast) soft",
6850 "Address Family Modifier\n"
6851 "Address Family Modifier\n"
6854 if (strncmp (argv
[0], "m", 1) == 0)
6856 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MULTICAST
, clear_all
, NULL
) == CMD_SUCCESS
)
6857 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MULTICAST
, clear_all
, NULL
, 0);
6860 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
) == CMD_SUCCESS
)
6861 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_UNICAST
, clear_all
, NULL
, 0);
6866 DEFUN (clear_ip_bgp_peer_vpnv4_soft
,
6867 clear_ip_bgp_peer_vpnv4_soft_cmd
,
6868 "clear ip bgp A.B.C.D vpnv4 unicast soft",
6872 "BGP neighbor address to clear\n"
6874 "Address Family Modifier\n"
6877 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_peer
, argv
[0]) == CMD_SUCCESS
)
6878 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_peer
, argv
[0], 0);
6883 DEFUN (clear_ip_bgp_as_vpnv4_soft
,
6884 clear_ip_bgp_as_vpnv4_soft_cmd
,
6885 "clear ip bgp <1-65535> vpnv4 unicast soft",
6889 "Clear peers with the AS number\n"
6891 "Address Family Modifier\n"
6894 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_as
, argv
[0]) == CMD_SUCCESS
)
6895 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_as
, argv
[0], 0);
6900 DEFUN (clear_ip_bgp_all_vpnv4_soft
,
6901 clear_ip_bgp_all_vpnv4_soft_cmd
,
6902 "clear ip bgp * vpnv4 unicast soft",
6908 "Address Family Modifier\n"
6911 if (clear_bgp_soft_out (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_all
, NULL
) == CMD_SUCCESS
)
6912 clear_bgp_soft_in (vty
, AFI_IP
, SAFI_MPLS_VPN
, clear_all
, NULL
, 0);
6917 DEFUN (clear_bgp_peer_soft_in
,
6918 clear_bgp_peer_soft_in_cmd
,
6919 "clear bgp (A.B.C.D|X:X::X:X) soft in",
6922 "BGP neighbor address to clear\n"
6923 "BGP IPv6 neighbor to clear\n"
6925 "Soft reconfig inbound update\n")
6927 return clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_peer
, argv
[0], 1);
6930 ALIAS (clear_bgp_peer_soft_in
,
6931 clear_bgp_ipv6_peer_soft_in_cmd
,
6932 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft in",
6936 "BGP neighbor address to clear\n"
6937 "BGP IPv6 neighbor to clear\n"
6939 "Soft reconfig inbound update\n")
6941 DEFUN (clear_bgp_peer_in
,
6942 clear_bgp_peer_in_cmd
,
6943 "clear bgp (A.B.C.D|X:X::X:X) in",
6946 "BGP neighbor address to clear\n"
6947 "BGP IPv6 neighbor to clear\n"
6948 "Soft reconfig inbound update\n")
6950 return clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_peer
, argv
[0], 0);
6953 ALIAS (clear_bgp_peer_in
,
6954 clear_bgp_ipv6_peer_in_cmd
,
6955 "clear bgp ipv6 (A.B.C.D|X:X::X:X) in",
6959 "BGP neighbor address to clear\n"
6960 "BGP IPv6 neighbor to clear\n"
6961 "Soft reconfig inbound update\n")
6963 DEFUN (clear_bgp_as_soft_in
,
6964 clear_bgp_as_soft_in_cmd
,
6965 "clear bgp <1-65535> soft in",
6968 "Clear peers with the AS number\n"
6970 "Soft reconfig inbound update\n")
6972 return clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_as
, argv
[0], 1);
6975 ALIAS (clear_bgp_as_soft_in
,
6976 clear_bgp_ipv6_as_soft_in_cmd
,
6977 "clear bgp ipv6 <1-65535> soft in",
6981 "Clear peers with the AS number\n"
6983 "Soft reconfig inbound update\n")
6985 DEFUN (clear_bgp_as_in
,
6986 clear_bgp_as_in_cmd
,
6987 "clear bgp <1-65535> in",
6990 "Clear peers with the AS number\n"
6991 "Soft reconfig inbound update\n")
6993 return clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_as
, argv
[0], 0);
6996 ALIAS (clear_bgp_as_in
,
6997 clear_bgp_ipv6_as_in_cmd
,
6998 "clear bgp ipv6 <1-65535> in",
7002 "Clear peers with the AS number\n"
7003 "Soft reconfig inbound update\n")
7005 DEFUN (clear_bgp_all_soft_in
,
7006 clear_bgp_all_soft_in_cmd
,
7007 "clear bgp * soft in",
7012 "Soft reconfig inbound update\n")
7014 return clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_all
, NULL
, 1);
7017 ALIAS (clear_bgp_all_soft_in
,
7018 clear_bgp_ipv6_all_soft_in_cmd
,
7019 "clear bgp ipv6 * soft in",
7025 "Soft reconfig inbound update\n")
7027 DEFUN (clear_bgp_all_in
,
7028 clear_bgp_all_in_cmd
,
7033 "Soft reconfig inbound update\n")
7035 return clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_all
, NULL
, 0);
7038 ALIAS (clear_bgp_all_in
,
7039 clear_bgp_ipv6_all_in_cmd
,
7040 "clear bgp ipv6 * in",
7045 "Soft reconfig inbound update\n")
7047 DEFUN (clear_bgp_peer_soft_out
,
7048 clear_bgp_peer_soft_out_cmd
,
7049 "clear bgp (A.B.C.D|X:X::X:X) soft out",
7052 "BGP neighbor address to clear\n"
7053 "BGP IPv6 neighbor to clear\n"
7055 "Soft reconfig outbound update\n")
7057 return clear_bgp_soft_out (vty
, AFI_IP6
, SAFI_UNICAST
, clear_peer
, argv
[0]);
7060 ALIAS (clear_bgp_peer_soft_out
,
7061 clear_bgp_ipv6_peer_soft_out_cmd
,
7062 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft out",
7066 "BGP neighbor address to clear\n"
7067 "BGP IPv6 neighbor to clear\n"
7069 "Soft reconfig outbound update\n")
7071 ALIAS (clear_bgp_peer_soft_out
,
7072 clear_bgp_peer_out_cmd
,
7073 "clear bgp (A.B.C.D|X:X::X:X) out",
7076 "BGP neighbor address to clear\n"
7077 "BGP IPv6 neighbor to clear\n"
7078 "Soft reconfig outbound update\n")
7080 ALIAS (clear_bgp_peer_soft_out
,
7081 clear_bgp_ipv6_peer_out_cmd
,
7082 "clear bgp ipv6 (A.B.C.D|X:X::X:X) out",
7086 "BGP neighbor address to clear\n"
7087 "BGP IPv6 neighbor to clear\n"
7088 "Soft reconfig outbound update\n")
7090 DEFUN (clear_bgp_as_soft_out
,
7091 clear_bgp_as_soft_out_cmd
,
7092 "clear bgp <1-65535> soft out",
7095 "Clear peers with the AS number\n"
7097 "Soft reconfig outbound update\n")
7099 return clear_bgp_soft_out (vty
, AFI_IP6
, SAFI_UNICAST
, clear_as
, argv
[0]);
7102 ALIAS (clear_bgp_as_soft_out
,
7103 clear_bgp_ipv6_as_soft_out_cmd
,
7104 "clear bgp ipv6 <1-65535> soft out",
7108 "Clear peers with the AS number\n"
7110 "Soft reconfig outbound update\n")
7112 ALIAS (clear_bgp_as_soft_out
,
7113 clear_bgp_as_out_cmd
,
7114 "clear bgp <1-65535> out",
7117 "Clear peers with the AS number\n"
7118 "Soft reconfig outbound update\n")
7120 ALIAS (clear_bgp_as_soft_out
,
7121 clear_bgp_ipv6_as_out_cmd
,
7122 "clear bgp ipv6 <1-65535> out",
7126 "Clear peers with the AS number\n"
7127 "Soft reconfig outbound update\n")
7129 DEFUN (clear_bgp_all_soft_out
,
7130 clear_bgp_all_soft_out_cmd
,
7131 "clear bgp * soft out",
7136 "Soft reconfig outbound update\n")
7138 return clear_bgp_soft_out (vty
, AFI_IP6
, SAFI_UNICAST
, clear_all
, NULL
);
7141 ALIAS (clear_bgp_all_soft_out
,
7142 clear_bgp_ipv6_all_soft_out_cmd
,
7143 "clear bgp ipv6 * soft out",
7149 "Soft reconfig outbound update\n")
7151 ALIAS (clear_bgp_all_soft_out
,
7152 clear_bgp_all_out_cmd
,
7157 "Soft reconfig outbound update\n")
7159 ALIAS (clear_bgp_all_soft_out
,
7160 clear_bgp_ipv6_all_out_cmd
,
7161 "clear bgp ipv6 * out",
7166 "Soft reconfig outbound update\n")
7168 DEFUN (clear_bgp_peer_soft
,
7169 clear_bgp_peer_soft_cmd
,
7170 "clear bgp (A.B.C.D|X:X::X:X) soft",
7173 "BGP neighbor address to clear\n"
7174 "BGP IPv6 neighbor to clear\n"
7177 if (clear_bgp_soft_out (vty
, AFI_IP6
, SAFI_UNICAST
, clear_peer
, argv
[0]) == CMD_SUCCESS
)
7178 clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_peer
, argv
[0], 0);
7183 ALIAS (clear_bgp_peer_soft
,
7184 clear_bgp_ipv6_peer_soft_cmd
,
7185 "clear bgp ipv6 (A.B.C.D|X:X::X:X) soft",
7189 "BGP neighbor address to clear\n"
7190 "BGP IPv6 neighbor to clear\n"
7193 DEFUN (clear_bgp_as_soft
,
7194 clear_bgp_as_soft_cmd
,
7195 "clear bgp <1-65535> soft",
7198 "Clear peers with the AS number\n"
7201 if (clear_bgp_soft_out (vty
, AFI_IP6
, SAFI_UNICAST
, clear_as
, argv
[0]) == CMD_SUCCESS
)
7202 clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_as
, argv
[0], 0);
7207 ALIAS (clear_bgp_as_soft
,
7208 clear_bgp_ipv6_as_soft_cmd
,
7209 "clear bgp ipv6 <1-65535> soft",
7213 "Clear peers with the AS number\n"
7216 DEFUN (clear_bgp_all_soft
,
7217 clear_bgp_all_soft_cmd
,
7224 if (clear_bgp_soft_out (vty
, AFI_IP6
, SAFI_UNICAST
, clear_all
, NULL
) == CMD_SUCCESS
)
7225 clear_bgp_soft_in (vty
, AFI_IP6
, SAFI_UNICAST
, clear_all
, NULL
, 0);
7230 ALIAS (clear_bgp_all_soft
,
7231 clear_bgp_ipv6_all_soft_cmd
,
7232 "clear bgp ipv6 * soft",
7238 #endif /* HAVE_IPV6 */
7240 /* Show BGP peer's summary information. */
7242 bgp_show_summary (struct vty
*vty
, int afi
, int safi
)
7246 struct peer_conf
*conf
;
7247 struct listnode
*nn
;
7248 struct listnode
*nm
;
7250 char timebuf
[BGP_UPTIME_LEN
];
7253 /* Header string for each address family. */
7254 static char header
[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd";
7256 LIST_LOOP (bgp_list
, bgp
, nn
)
7258 LIST_LOOP (bgp
->peer_conf
, conf
, nm
)
7262 if (conf
->afc
[afi
][safi
])
7267 "BGP router identifier %s, local AS number %d%s",
7268 inet_ntoa (bgp
->id
), bgp
->as
, VTY_NEWLINE
);
7270 "%ld BGP AS-PATH entries%s", aspath_count (),
7273 "%ld BGP community entries%s", community_count (),
7276 if (CHECK_FLAG(bgp
->config
, BGP_CONFIG_DAMPENING
))
7277 vty_out (vty
, "Dampening enabled.%s", VTY_NEWLINE
);
7278 vty_out (vty
, "%s", VTY_NEWLINE
);
7279 vty_out (vty
, "%s%s", header
, VTY_NEWLINE
);
7283 len
= vty_out (vty
, "%s", peer
->host
);
7286 vty_out (vty
, "%s%*s", VTY_NEWLINE
, 16, " ");
7288 vty_out (vty
, "%*s", len
, " ");
7290 switch (peer
->version
)
7293 vty_out (vty
, "4 ");
7295 case BGP_VERSION_MP_4_DRAFT_00
:
7296 vty_out (vty
, "4-");
7300 vty_out (vty
, "%5d %7d %7d %8d %4d %4ld ",
7302 peer
->open_in
+ peer
->update_in
+
7303 peer
->keepalive_in
+ peer
->notify_in
+ peer
->refresh_in
,
7304 peer
->open_out
+ peer
->update_out
+
7305 peer
->keepalive_out
+ peer
->notify_out
+ peer
->refresh_out
,
7306 0, 0, peer
->obuf
->count
);
7308 vty_out (vty
, "%8s",
7309 peer_uptime (peer
->uptime
, timebuf
, BGP_UPTIME_LEN
));
7311 if (peer
->status
== Established
)
7313 vty_out (vty
, " %8ld", conf
->pcount
[afi
][safi
]);
7317 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_SHUTDOWN
))
7318 vty_out (vty
, " Idle (Admin)");
7319 else if (CHECK_FLAG (peer
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
))
7320 vty_out (vty
, " Idle (PfxCt)");
7322 vty_out (vty
, " %-11s", LOOKUP(bgp_status_msg
, peer
->status
));
7325 vty_out (vty
, "%s", VTY_NEWLINE
);
7331 vty_out (vty
, "%sTotal number of neighbors %d%s", VTY_NEWLINE
,
7332 count
, VTY_NEWLINE
);
7334 vty_out (vty
, "No %s neighbor is configured%s",
7335 afi
== AFI_IP
? "IPv4" : "IPv6", VTY_NEWLINE
);
7339 /* `show ip bgp summary' commands. */
7340 DEFUN (show_ip_bgp_summary
,
7341 show_ip_bgp_summary_cmd
,
7342 "show ip bgp summary",
7346 "Summary of BGP neighbor status\n")
7348 return bgp_show_summary (vty
, AFI_IP
, SAFI_UNICAST
);
7351 DEFUN (show_ip_bgp_ipv4_summary
,
7352 show_ip_bgp_ipv4_summary_cmd
,
7353 "show ip bgp ipv4 (unicast|multicast) summary",
7358 "Address Family modifier\n"
7359 "Address Family modifier\n"
7360 "Summary of BGP neighbor status\n")
7362 if (strncmp (argv
[0], "m", 1) == 0)
7363 return bgp_show_summary (vty
, AFI_IP
, SAFI_MULTICAST
);
7365 return bgp_show_summary (vty
, AFI_IP
, SAFI_UNICAST
);
7368 DEFUN (show_ip_bgp_vpnv4_all_summary
,
7369 show_ip_bgp_vpnv4_all_summary_cmd
,
7370 "show ip bgp vpnv4 all summary",
7374 "Display VPNv4 NLRI specific information\n"
7375 "Display information about all VPNv4 NLRIs\n"
7376 "Summary of BGP neighbor status\n")
7378 return bgp_show_summary (vty
, AFI_IP
, SAFI_MPLS_VPN
);
7381 DEFUN (show_ip_bgp_vpnv4_rd_summary
,
7382 show_ip_bgp_vpnv4_rd_summary_cmd
,
7383 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary",
7387 "Display VPNv4 NLRI specific information\n"
7388 "Display information for a route distinguisher\n"
7389 "VPN Route Distinguisher\n"
7390 "Summary of BGP neighbor status\n")
7393 struct prefix_rd prd
;
7395 ret
= str2prefix_rd (argv
[0], &prd
);
7398 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
7402 return bgp_show_summary (vty
, AFI_IP
, SAFI_MPLS_VPN
);
7406 DEFUN (show_bgp_summary
,
7407 show_bgp_summary_cmd
,
7411 "Summary of BGP neighbor status\n")
7413 return bgp_show_summary (vty
, AFI_IP6
, SAFI_UNICAST
);
7416 ALIAS (show_bgp_summary
,
7417 show_bgp_ipv6_summary_cmd
,
7418 "show bgp ipv6 summary",
7422 "Summary of BGP neighbor status\n")
7425 DEFUN (show_ipv6_bgp_summary
,
7426 show_ipv6_bgp_summary_cmd
,
7427 "show ipv6 bgp summary",
7431 "Summary of BGP neighbor status\n")
7433 return bgp_show_summary (vty
, AFI_IP6
, SAFI_UNICAST
);
7437 DEFUN (show_ipv6_mbgp_summary
,
7438 show_ipv6_mbgp_summary_cmd
,
7439 "show ipv6 mbgp summary",
7443 "Summary of BGP neighbor status\n")
7445 return bgp_show_summary (vty
, AFI_IP6
, SAFI_MULTICAST
);
7447 #endif /* HAVE_IPV6 */
7449 /* Show BGP peer's information. */
7456 /* Return next event time. */
7458 bgp_next_timer (struct thread
*thread
)
7460 struct timeval timer_now
;
7461 gettimeofday (&timer_now
, NULL
);
7462 return thread
->u
.sands
.tv_sec
- timer_now
.tv_sec
;
7466 bgp_show_peer_afi (struct vty
*vty
, struct peer_conf
*conf
, afi_t afi
, safi_t safi
)
7468 struct bgp_filter
*filter
;
7472 filter
= &conf
->filter
[afi
][safi
];
7474 vty_out (vty
, " For address family: %s %s%s",
7475 afi
== AFI_IP6
? "IPv6" :
7476 safi
== SAFI_MPLS_VPN
? "VPNv4" : "IPv4",
7477 safi
== SAFI_MULTICAST
? "Multicast" : "Unicast",
7479 if (CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
7480 vty_out (vty
, " Route-Reflector Client%s", VTY_NEWLINE
);
7481 if (CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
7482 vty_out (vty
, " Route-Server Client%s", VTY_NEWLINE
);
7483 if (CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
7484 vty_out (vty
, " Inbound soft reconfiguration allowed%s", VTY_NEWLINE
);
7485 if (CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
))
7486 vty_out (vty
, " NEXT_HOP is always this router%s", VTY_NEWLINE
);
7487 if (CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
7488 || CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_EXT_COMMUNITY
))
7490 vty_out (vty
, " Community attribute sent to this neighbor");
7491 if (CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
7492 && CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_EXT_COMMUNITY
))
7493 vty_out (vty
, " (both)%s", VTY_NEWLINE
);
7494 else if (CHECK_FLAG (p
->af_flags
[afi
][safi
], PEER_FLAG_SEND_EXT_COMMUNITY
))
7495 vty_out (vty
, " (extended)%s", VTY_NEWLINE
);
7497 vty_out (vty
, " (standard)%s", VTY_NEWLINE
);
7499 if (filter
->plist
[FILTER_IN
].name
||
7500 filter
->dlist
[FILTER_IN
].name
||
7501 filter
->aslist
[FILTER_IN
].name
||
7502 filter
->map
[FILTER_IN
].name
)
7503 vty_out (vty
, " Inbound path policy configured%s", VTY_NEWLINE
);
7504 if (filter
->plist
[FILTER_OUT
].name
||
7505 filter
->dlist
[FILTER_OUT
].name
||
7506 filter
->aslist
[FILTER_OUT
].name
||
7507 filter
->map
[FILTER_OUT
].name
)
7508 vty_out (vty
, " Outbound path policy configured%s", VTY_NEWLINE
);
7511 if (filter
->plist
[FILTER_IN
].name
)
7512 vty_out (vty
, " Incoming update prefix filter list is %s%s%s",
7513 filter
->plist
[FILTER_IN
].plist
? "*" : "",
7514 filter
->plist
[FILTER_IN
].name
,
7516 if (filter
->plist
[FILTER_OUT
].name
)
7517 vty_out (vty
, " Outgoing update prefix filter list is %s%s%s",
7518 filter
->plist
[FILTER_OUT
].plist
? "*" : "",
7519 filter
->plist
[FILTER_OUT
].name
,
7522 /* distribute-list */
7523 if (filter
->dlist
[FILTER_IN
].name
)
7524 vty_out (vty
, " Incoming update network filter list is %s%s%s",
7525 filter
->dlist
[FILTER_IN
].alist
? "*" : "",
7526 filter
->dlist
[FILTER_IN
].name
,
7528 if (filter
->dlist
[FILTER_OUT
].name
)
7529 vty_out (vty
, " Outgoing update network filter list is %s%s%s",
7530 filter
->dlist
[FILTER_OUT
].alist
? "*" : "",
7531 filter
->dlist
[FILTER_OUT
].name
,
7535 if (filter
->aslist
[FILTER_IN
].name
)
7536 vty_out (vty
, " Incoming update AS path filter list is %s%s%s",
7537 filter
->aslist
[FILTER_IN
].aslist
? "*" : "",
7538 filter
->aslist
[FILTER_IN
].name
,
7540 if (filter
->aslist
[FILTER_OUT
].name
)
7541 vty_out (vty
, " Outgoing update AS path filter list is %s%s%s",
7542 filter
->aslist
[FILTER_OUT
].aslist
? "*" : "",
7543 filter
->aslist
[FILTER_OUT
].name
,
7547 if (filter
->map
[FILTER_IN
].name
)
7548 vty_out (vty
, " Route map for incoming advertisements is %s%s%s",
7549 filter
->map
[FILTER_IN
].map
? "*" : "",
7550 filter
->map
[FILTER_IN
].name
,
7552 if (filter
->map
[FILTER_OUT
].name
)
7553 vty_out (vty
, " Route map for outgoing advertisements is %s%s%s",
7554 filter
->map
[FILTER_OUT
].map
? "*" : "",
7555 filter
->map
[FILTER_OUT
].name
,
7558 vty_out (vty
, " %ld accepted prefixes",
7559 conf
->pcount
[afi
][safi
]);
7560 if (conf
->pmax
[afi
][safi
])
7562 vty_out (vty
, ", maximum limit %ld%s",
7563 conf
->pmax
[afi
][safi
],
7564 conf
->pmax_warning
[afi
][safi
] ? " (warning-only)" : "");
7566 vty_out (vty
, "%s", VTY_NEWLINE
);
7568 vty_out (vty
, "%s", VTY_NEWLINE
);
7572 bgp_show_peer (struct vty
*vty
, struct peer_conf
*conf
, afi_t afi
, safi_t safi
)
7575 char timebuf
[BGP_UPTIME_LEN
];
7580 /* Configured IP address. */
7581 vty_out (vty
, "BGP neighbor is %s, ", p
->host
);
7582 vty_out (vty
, "remote AS %d, ", p
->as
);
7583 vty_out (vty
, "local AS %d, ", p
->local_as
);
7584 vty_out (vty
, "%s link%s",
7585 p
->as
== p
->local_as
? "internal" : "external",
7590 vty_out (vty
, " Description: %s%s", p
->desc
, VTY_NEWLINE
);
7592 /* Administrative shutdown. */
7593 if (CHECK_FLAG (p
->flags
, PEER_FLAG_SHUTDOWN
))
7594 vty_out (vty
, " Administratively shut down%s", VTY_NEWLINE
);
7597 vty_out (vty
, " BGP version 4");
7598 if (p
->version
== BGP_VERSION_MP_4_DRAFT_00
)
7599 vty_out (vty
, "(with draft-00 verion of multiporotocol extension)");
7600 vty_out (vty
, ", remote router ID %s%s",
7601 inet_ntop (AF_INET
, &p
->remote_id
, buf1
, BUFSIZ
),
7605 if (bgp_confederation_peers_check (conf
->bgp
, p
->as
))
7606 vty_out (vty
, " Neighbor under common administration%s", VTY_NEWLINE
);
7609 vty_out (vty
, " BGP state = %s",
7610 CHECK_FLAG (p
->flags
, PEER_FLAG_SHUTDOWN
)
7611 ? "Idle" : LOOKUP(bgp_status_msg
, p
->status
));
7612 if (p
->status
== Established
)
7613 vty_out (vty
, ", up for %8s",
7614 peer_uptime (p
->uptime
, timebuf
, BGP_UPTIME_LEN
));
7615 vty_out (vty
, "%s", VTY_NEWLINE
);
7618 vty_out (vty
, " Last read %s", peer_uptime (p
->readtime
, timebuf
, BGP_UPTIME_LEN
));
7620 /* Configured timer values. */
7621 vty_out (vty
, ", hold time is %d, keepalive interval is %d seconds%s",
7622 p
->v_holdtime
, p
->v_keepalive
, VTY_NEWLINE
);
7623 if (p
->config
& PEER_CONFIG_TIMER
)
7625 vty_out (vty
, " Configured hold time is %d", p
->holdtime
);
7626 vty_out (vty
, ", keepalive interval is %d seconds%s",
7627 p
->keepalive
, VTY_NEWLINE
);
7631 if (p
->status
== Established
)
7633 if ((p
->refresh_adv
|| p
->refresh_nego_old
|| p
->refresh_nego_new
)
7634 || (p
->afc_adv
[AFI_IP
][SAFI_UNICAST
] || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
])
7635 || (p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
] || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
])
7637 || (p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
] || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
])
7638 || (p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
] || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
])
7639 #endif /* HAVE_IPV6 */
7640 || (p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
] || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
]))
7642 vty_out (vty
, " Neighbor capabilities:%s", VTY_NEWLINE
);
7645 if (p
->refresh_adv
|| p
->refresh_nego_old
|| p
->refresh_nego_new
)
7647 vty_out (vty
, " Route refresh:");
7649 vty_out (vty
, " advertised");
7650 if (p
->refresh_nego_old
|| p
->refresh_nego_new
)
7653 vty_out (vty
, " and");
7654 vty_out (vty
, " received");
7655 if (p
->refresh_nego_old
&& p
->refresh_nego_new
)
7656 vty_out (vty
, " (old and new)");
7657 else if (p
->refresh_nego_old
)
7658 vty_out (vty
, " (old)");
7660 vty_out (vty
, " (new)");
7662 vty_out (vty
, "%s", VTY_NEWLINE
);
7666 if (p
->afc_adv
[AFI_IP
][SAFI_UNICAST
] || p
->afc_recv
[AFI_IP
][SAFI_UNICAST
])
7668 vty_out (vty
, " Address family IPv4 Unicast:");
7669 if (p
->afc_adv
[AFI_IP
][SAFI_UNICAST
])
7670 vty_out (vty
, " advertised");
7671 if (p
->afc_recv
[AFI_IP
][SAFI_UNICAST
])
7673 if (p
->afc_adv
[AFI_IP
][SAFI_UNICAST
])
7674 vty_out (vty
, " and");
7675 vty_out (vty
, " received");
7677 vty_out (vty
, "%s", VTY_NEWLINE
);
7679 if (p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
] || p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
])
7681 vty_out (vty
, " Address family IPv4 Multicast:");
7682 if (p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
])
7683 vty_out (vty
, " advertised");
7684 if (p
->afc_recv
[AFI_IP
][SAFI_MULTICAST
])
7686 if (p
->afc_adv
[AFI_IP
][SAFI_MULTICAST
])
7687 vty_out (vty
, " and");
7688 vty_out (vty
, " received");
7690 vty_out (vty
, "%s", VTY_NEWLINE
);
7692 if (p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
] || p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
])
7694 vty_out (vty
, " Address family VPNv4 Unicast:");
7695 if (p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
])
7696 vty_out (vty
, " advertised");
7697 if (p
->afc_recv
[AFI_IP
][SAFI_MPLS_VPN
])
7699 if (p
->afc_adv
[AFI_IP
][SAFI_MPLS_VPN
])
7700 vty_out (vty
, " and");
7701 vty_out (vty
, " received");
7703 vty_out (vty
, "%s", VTY_NEWLINE
);
7707 if (p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
] || p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
])
7709 vty_out (vty
, " Address family IPv6 Unicast:");
7710 if (p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
])
7711 vty_out (vty
, " advertised");
7712 if (p
->afc_recv
[AFI_IP6
][SAFI_UNICAST
])
7714 if (p
->afc_adv
[AFI_IP6
][SAFI_UNICAST
])
7715 vty_out (vty
, " and");
7716 vty_out (vty
, " received");
7718 vty_out (vty
, "%s", VTY_NEWLINE
);
7720 if (p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
] || p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
])
7722 vty_out (vty
, " Address family IPv6 Multicast:");
7723 if (p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
])
7724 vty_out (vty
, " advertised");
7725 if (p
->afc_recv
[AFI_IP6
][SAFI_MULTICAST
])
7727 if (p
->afc_adv
[AFI_IP6
][SAFI_MULTICAST
])
7728 vty_out (vty
, " and");
7729 vty_out (vty
, " received");
7731 vty_out (vty
, "%s", VTY_NEWLINE
);
7733 #endif /* HAVE_IPV6 */
7737 /* Packet counts. */
7738 vty_out(vty
, " Received %d messages, %d notifications, %d in queue%s",
7739 p
->open_in
+ p
->update_in
+ p
->keepalive_in
,
7740 p
->notify_in
, 0, VTY_NEWLINE
);
7741 vty_out(vty
, " Sent %d messages, %d notifications, %ld in queue%s",
7742 p
->open_out
+ p
->update_out
+ p
->keepalive_out
,
7743 p
->notify_out
, p
->obuf
->count
, VTY_NEWLINE
);
7744 vty_out(vty
, " Route refresh request: received %d, sent %d%s",
7745 p
->refresh_in
, p
->refresh_out
, VTY_NEWLINE
);
7747 /* advertisement-interval (Current not supported)*/
7748 vty_out (vty
, " Minimum time between advertisement runs is 0 seconds%s",
7751 /* Default weight */
7753 vty_out (vty
, " Default weight %d%s", p
->weight
,
7756 vty_out (vty
, "%s", VTY_NEWLINE
);
7758 /* Address Family Information */
7759 if (p
->afc
[AFI_IP
][SAFI_UNICAST
])
7760 bgp_show_peer_afi (vty
, conf
, AFI_IP
, SAFI_UNICAST
);
7761 if (p
->afc
[AFI_IP
][SAFI_MULTICAST
])
7762 bgp_show_peer_afi (vty
, conf
, AFI_IP
, SAFI_MULTICAST
);
7763 if (p
->afc
[AFI_IP
][SAFI_MPLS_VPN
])
7764 bgp_show_peer_afi (vty
, conf
, AFI_IP
, SAFI_MPLS_VPN
);
7766 if (p
->afc
[AFI_IP6
][SAFI_UNICAST
])
7767 bgp_show_peer_afi (vty
, conf
, AFI_IP6
, SAFI_UNICAST
);
7768 if (p
->afc
[AFI_IP6
][SAFI_MULTICAST
])
7769 bgp_show_peer_afi (vty
, conf
, AFI_IP6
, SAFI_MULTICAST
);
7770 #endif /* HAVE_IPV6 */
7772 vty_out (vty
, " Connections established %d; dropped %d%s",
7773 p
->established
, p
->dropped
,
7776 if (CHECK_FLAG (p
->sflags
, PEER_STATUS_PREFIX_OVERFLOW
))
7778 vty_out (vty
, " Peer had exceeded the max. no. of prefixes configured.%s", VTY_NEWLINE
);
7779 vty_out (vty
, " Reduce the no. of prefix and clear ip bgp %s to restore peering%s",
7780 p
->host
, VTY_NEWLINE
);
7784 if (peer_sort (p
) == BGP_PEER_EBGP
&& p
->ttl
> 1)
7785 vty_out (vty
, " External BGP neighbor may be up to %d hops away.%s",
7786 p
->ttl
, VTY_NEWLINE
);
7788 /* Local address. */
7791 vty_out (vty
, "Local host: %s, Local port: %d%s",
7792 sockunion2str (p
->su_local
, buf1
, SU_ADDRSTRLEN
),
7793 ntohs (p
->su_local
->sin
.sin_port
),
7797 /* Remote address. */
7800 vty_out (vty
, "Foreign host: %s, Foreign port: %d%s",
7801 sockunion2str (p
->su_remote
, buf1
, SU_ADDRSTRLEN
),
7802 ntohs (p
->su_remote
->sin
.sin_port
),
7806 /* Nexthop display. */
7809 vty_out (vty
, "Nexthop: %s%s",
7810 inet_ntop (AF_INET
, &p
->nexthop
.v4
, buf1
, BUFSIZ
),
7813 vty_out (vty
, "Nexthop global: %s%s",
7814 inet_ntop (AF_INET6
, &p
->nexthop
.v6_global
, buf1
, BUFSIZ
),
7816 vty_out (vty
, "Nexthop local: %s%s",
7817 inet_ntop (AF_INET6
, &p
->nexthop
.v6_local
, buf1
, BUFSIZ
),
7819 vty_out (vty
, "BGP connection: %s%s",
7820 p
->shared_network
? "shared network" : "non shared network",
7822 #endif /* HAVE_IPV6 */
7825 /* Timer information. */
7827 vty_out (vty
, "Next start timer due in %d seconds%s",
7828 bgp_next_timer (p
->t_start
), VTY_NEWLINE
);
7830 vty_out (vty
, "Next connect timer due in %d seconds%s",
7831 bgp_next_timer (p
->t_connect
), VTY_NEWLINE
);
7833 vty_out (vty
, "Read thread: %s Write thread: %s%s",
7834 p
->t_read
? "on" : "off",
7835 p
->t_write
? "on" : "off",
7838 if (p
->notify
.code
== BGP_NOTIFY_OPEN_ERR
7839 && p
->notify
.subcode
== BGP_NOTIFY_OPEN_UNSUP_CAPBL
)
7840 bgp_capability_vty_out (vty
, p
);
7842 vty_out (vty
, "%s", VTY_NEWLINE
);
7846 bgp_show_neighbor (struct vty
*vty
, int afi
, int safi
, enum show_type type
,
7849 struct listnode
*nn
, *nm
;
7851 struct peer_conf
*conf
;
7858 ret
= str2sockunion (ip_str
, &su
);
7861 vty_out (vty
, "Malformed address: %s%s", ip_str
, VTY_NEWLINE
);
7866 LIST_LOOP (bgp_list
, bgp
, nn
)
7868 LIST_LOOP (bgp
->peer_conf
, conf
, nm
)
7873 if (conf
->afc
[afi
][safi
])
7874 bgp_show_peer (vty
, conf
, afi
, safi
);
7877 if (conf
->afc
[afi
][safi
]
7878 && sockunion_same (&conf
->peer
->su
, &su
))
7881 bgp_show_peer (vty
, conf
, afi
, safi
);
7888 if (type
== show_peer
&& ! find
)
7889 vty_out (vty
, "%% No such neighbor or address family%s", VTY_NEWLINE
);
7894 DEFUN (show_ip_bgp_neighbors
,
7895 show_ip_bgp_neighbors_cmd
,
7896 "show ip bgp neighbors",
7900 "Detailed information on TCP and BGP neighbor connections\n")
7902 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_UNICAST
, show_all
, NULL
);
7905 DEFUN (show_ip_bgp_ipv4_neighbors
,
7906 show_ip_bgp_ipv4_neighbors_cmd
,
7907 "show ip bgp ipv4 (unicast|multicast) neighbors",
7912 "Address Family modifier\n"
7913 "Address Family modifier\n"
7914 "Detailed information on TCP and BGP neighbor connections\n")
7916 if (strncmp (argv
[0], "m", 1) == 0)
7917 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_MULTICAST
, show_all
, NULL
);
7919 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_UNICAST
, show_all
, NULL
);
7922 DEFUN (show_ip_bgp_neighbors_peer
,
7923 show_ip_bgp_neighbors_peer_cmd
,
7924 "show ip bgp neighbors (A.B.C.D|X:X::X:X)",
7928 "Detailed information on TCP and BGP neighbor connections\n"
7929 "Neighbor to display information about\n"
7930 "Neighbor to display information about\n")
7932 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_UNICAST
, show_peer
, argv
[0]);
7935 DEFUN (show_ip_bgp_ipv4_neighbors_peer
,
7936 show_ip_bgp_ipv4_neighbors_peer_cmd
,
7937 "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X)",
7942 "Address Family modifier\n"
7943 "Address Family modifier\n"
7944 "Detailed information on TCP and BGP neighbor connections\n"
7945 "Neighbor to display information about\n"
7946 "Neighbor to display information about\n")
7948 if (strncmp (argv
[0], "m", 1) == 0)
7949 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_MULTICAST
, show_peer
, argv
[1]);
7951 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_UNICAST
, show_peer
, argv
[1]);
7954 DEFUN (show_ip_bgp_vpnv4_all_neighbors
,
7955 show_ip_bgp_vpnv4_all_neighbors_cmd
,
7956 "show ip bgp vpnv4 all neighbors",
7960 "Display VPNv4 NLRI specific information\n"
7961 "Display information about all VPNv4 NLRIs\n"
7962 "Detailed information on TCP and BGP neighbor connections\n")
7964 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_MPLS_VPN
, show_all
, NULL
);
7967 DEFUN (show_ip_bgp_vpnv4_rd_neighbors
,
7968 show_ip_bgp_vpnv4_rd_neighbors_cmd
,
7969 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors",
7973 "Display VPNv4 NLRI specific information\n"
7974 "Display information for a route distinguisher\n"
7975 "VPN Route Distinguisher\n"
7976 "Detailed information on TCP and BGP neighbor connections\n")
7979 struct prefix_rd prd
;
7981 ret
= str2prefix_rd (argv
[0], &prd
);
7984 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
7988 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_MPLS_VPN
, show_all
, NULL
);
7991 DEFUN (show_ip_bgp_vpnv4_all_neighbors_peer
,
7992 show_ip_bgp_vpnv4_all_neighbors_peer_cmd
,
7993 "show ip bgp vpnv4 all neighbors A.B.C.D",
7997 "Display VPNv4 NLRI specific information\n"
7998 "Display information about all VPNv4 NLRIs\n"
7999 "Detailed information on TCP and BGP neighbor connections\n"
8000 "Neighbor to display information about\n")
8002 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_MPLS_VPN
, show_peer
, argv
[0]);
8005 DEFUN (show_ip_bgp_vpnv4_rd_neighbors_peer
,
8006 show_ip_bgp_vpnv4_rd_neighbors_peer_cmd
,
8007 "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D",
8011 "Display VPNv4 NLRI specific information\n"
8012 "Display information about all VPNv4 NLRIs\n"
8013 "Detailed information on TCP and BGP neighbor connections\n"
8014 "Neighbor to display information about\n")
8017 struct prefix_rd prd
;
8019 ret
= str2prefix_rd (argv
[0], &prd
);
8022 vty_out (vty
, "%% Malformed Route Distinguisher%s", VTY_NEWLINE
);
8026 return bgp_show_neighbor (vty
, AFI_IP
, SAFI_MPLS_VPN
, show_peer
, argv
[1]);
8030 DEFUN (show_bgp_neighbors
,
8031 show_bgp_neighbors_cmd
,
8032 "show bgp neighbors",
8035 "Detailed information on TCP and BGP neighbor connections\n")
8037 return bgp_show_neighbor (vty
, AFI_IP6
, SAFI_UNICAST
, show_all
, NULL
);
8040 ALIAS (show_bgp_neighbors
,
8041 show_bgp_ipv6_neighbors_cmd
,
8042 "show bgp ipv6 neighbors",
8046 "Detailed information on TCP and BGP neighbor connections\n")
8049 DEFUN (show_ipv6_bgp_neighbors
,
8050 show_ipv6_bgp_neighbors_cmd
,
8051 "show ipv6 bgp neighbors",
8055 "Detailed information on TCP and BGP neighbor connections\n")
8057 return bgp_show_neighbor (vty
, AFI_IP6
, SAFI_UNICAST
, show_all
, NULL
);
8060 DEFUN (show_bgp_neighbors_peer
,
8061 show_bgp_neighbors_peer_cmd
,
8062 "show bgp neighbors (A.B.C.D|X:X::X:X)",
8065 "Detailed information on TCP and BGP neighbor connections\n"
8066 "Neighbor to display information about\n"
8067 "Neighbor to display information about\n")
8069 return bgp_show_neighbor (vty
, AFI_IP6
, SAFI_UNICAST
, show_peer
, argv
[0]);
8072 ALIAS (show_bgp_neighbors_peer
,
8073 show_bgp_ipv6_neighbors_peer_cmd
,
8074 "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X)",
8078 "Detailed information on TCP and BGP neighbor connections\n"
8079 "Neighbor to display information about\n"
8080 "Neighbor to display information about\n")
8083 DEFUN (show_ipv6_bgp_neighbors_peer
,
8084 show_ipv6_bgp_neighbors_peer_cmd
,
8085 "show ipv6 bgp neighbors (A.B.C.D|X:X::X:X)",
8089 "Detailed information on TCP and BGP neighbor connections\n"
8090 "Neighbor to display information about\n"
8091 "Neighbor to display information about\n")
8093 return bgp_show_neighbor (vty
, AFI_IP6
, SAFI_UNICAST
, show_peer
, argv
[0]);
8097 DEFUN (show_ipv6_mbgp_neighbors
,
8098 show_ipv6_mbgp_neighbors_cmd
,
8099 "show ipv6 mbgp neighbors",
8103 "Detailed information on TCP and BGP neighbor connections\n")
8105 return bgp_show_neighbor (vty
, AFI_IP6
, SAFI_MULTICAST
, show_all
, NULL
);
8109 DEFUN (show_ipv6_mbgp_neighbors_peer
,
8110 show_ipv6_mbgp_neighbors_peer_cmd
,
8111 "show ipv6 mbgp neighbors (A.B.C.D|X:X::X:X)",
8115 "Detailed information on TCP and BGP neighbor connections\n"
8116 "Neighbor to display information about\n"
8117 "Neighbor to display information about\n")
8119 return bgp_show_neighbor (vty
, AFI_IP6
, SAFI_MULTICAST
, show_peer
, argv
[0]);
8121 #endif /* HAVE_IPV6 */
8123 /* Show BGP's AS paths internal data. There are both `show ip bgp
8124 paths' and `show ip mbgp paths'. Those functions results are the
8126 DEFUN (show_ip_bgp_paths
,
8127 show_ip_bgp_paths_cmd
,
8128 "show ip bgp paths",
8132 "Path information\n")
8134 vty_out (vty
, "Address Refcnt Path%s", VTY_NEWLINE
);
8135 aspath_print_all_vty (vty
);
8139 DEFUN (show_ip_bgp_ipv4_paths
,
8140 show_ip_bgp_ipv4_paths_cmd
,
8141 "show ip bgp ipv4 (unicast|multicast) paths",
8146 "Address Family modifier\n"
8147 "Address Family modifier\n"
8148 "Path information\n")
8150 vty_out (vty
, "Address Refcnt Path\r\n");
8151 aspath_print_all_vty (vty
);
8156 /* Show BGP's community internal data. */
8157 DEFUN (show_ip_bgp_community_info
,
8158 show_ip_bgp_community_info_cmd
,
8159 "show ip bgp community-info",
8163 "List all bgp community information\n")
8165 vty_out (vty
, "Address Refcnt Community%s", VTY_NEWLINE
);
8166 community_print_all_vty (vty
);
8170 DEFUN (show_ip_bgp_attr_info
,
8171 show_ip_bgp_attr_info_cmd
,
8172 "show ip bgp attribute-info",
8176 "List all bgp attribute information\n")
8178 void attrhash_dump (struct vty
*);
8180 attrhash_dump (vty
);
8185 bgp_config_write_filter (struct vty
*vty
, struct bgp_filter
*filter
,
8188 /* distribute-list. */
8189 if (filter
->dlist
[FILTER_IN
].name
)
8190 vty_out (vty
, " neighbor %s distribute-list %s in%s", addr
,
8191 filter
->dlist
[FILTER_IN
].name
, VTY_NEWLINE
);
8192 if (filter
->dlist
[FILTER_OUT
].name
)
8193 vty_out (vty
, " neighbor %s distribute-list %s out%s", addr
,
8194 filter
->dlist
[FILTER_OUT
].name
, VTY_NEWLINE
);
8197 if (filter
->plist
[FILTER_IN
].name
)
8198 vty_out (vty
, " neighbor %s prefix-list %s in%s", addr
,
8199 filter
->plist
[FILTER_IN
].name
, VTY_NEWLINE
);
8200 if (filter
->plist
[FILTER_OUT
].name
)
8201 vty_out (vty
, " neighbor %s prefix-list %s out%s", addr
,
8202 filter
->plist
[FILTER_OUT
].name
, VTY_NEWLINE
);
8205 if (filter
->aslist
[FILTER_IN
].name
)
8206 vty_out (vty
, " neighbor %s filter-list %s in%s", addr
,
8207 filter
->aslist
[FILTER_IN
].name
, VTY_NEWLINE
);
8208 if (filter
->aslist
[FILTER_OUT
].name
)
8209 vty_out (vty
, " neighbor %s filter-list %s out%s", addr
,
8210 filter
->aslist
[FILTER_OUT
].name
, VTY_NEWLINE
);
8213 if (filter
->map
[FILTER_IN
].name
)
8214 vty_out (vty
, " neighbor %s route-map %s in%s", addr
,
8215 filter
->map
[FILTER_IN
].name
, VTY_NEWLINE
);
8216 if (filter
->map
[FILTER_OUT
].name
)
8217 vty_out (vty
, " neighbor %s route-map %s out%s", addr
,
8218 filter
->map
[FILTER_OUT
].name
, VTY_NEWLINE
);
8221 /* BGP peer configuration display function. */
8223 bgp_config_write_peer (struct vty
*vty
, struct bgp
*bgp
,
8224 struct peer_conf
*conf
, afi_t afi
, safi_t safi
)
8227 char addr
[SU_ADDRSTRLEN
];
8228 char buf
[SU_ADDRSTRLEN
];
8229 struct bgp_filter
*filter
;
8232 filter
= &conf
->filter
[afi
][safi
];
8233 sockunion2str (&peer
->su
, addr
, SU_ADDRSTRLEN
);
8235 /************************************
8236 ****** Global to the neighbor ******
8237 ************************************/
8238 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8241 vty_out (vty
, " neighbor %s remote-as %d%s", addr
, peer
->as
,
8246 vty_out (vty
, " neighbor %s description %s%s", addr
, peer
->desc
,
8250 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_SHUTDOWN
))
8251 vty_out (vty
, " neighbor %s shutdown%s", addr
, VTY_NEWLINE
);
8254 if (peer
->port
!= BGP_PORT_DEFAULT
)
8255 vty_out (vty
, " neighbor %s port %d%s", addr
, peer
->port
,
8258 /* Local interface name. */
8260 vty_out (vty
, " neighbor %s interface %s%s", addr
, peer
->ifname
,
8264 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_PASSIVE
))
8265 vty_out (vty
, " neighbor %s passive%s", addr
, VTY_NEWLINE
);
8267 /* ebgp-multihop print. */
8268 if (peer_sort (peer
) == BGP_PEER_EBGP
&& peer
->ttl
!= 1)
8269 vty_out (vty
, " neighbor %s ebgp-multihop %d%s", addr
, peer
->ttl
,
8272 /* Update-source. */
8273 if (peer
->update_if
)
8274 vty_out (vty
, " neighbor %s update-source %s%s", addr
,
8275 peer
->update_if
, VTY_NEWLINE
);
8276 if (peer
->update_source
)
8277 vty_out (vty
, " neighbor %s update-source %s%s", addr
,
8278 sockunion2str (peer
->update_source
, buf
, SU_ADDRSTRLEN
),
8281 /* BGP version print. */
8282 if (peer
->version
== BGP_VERSION_MP_4_DRAFT_00
)
8283 vty_out (vty
, " neighbor %s version %s%s",
8284 addr
,"4-", VTY_NEWLINE
);
8287 if (peer
->config
& PEER_CONFIG_TIMER
)
8288 vty_out (vty
, " neighbor %s timers %d %d%s", addr
,
8289 peer
->keepalive
, peer
->holdtime
, VTY_NEWLINE
);
8290 if (peer
->config
& PEER_CONFIG_CONNECT
)
8291 vty_out (vty
, " neighbor %s timers connect %d%s", addr
,
8292 peer
->connect
, VTY_NEWLINE
);
8294 /* Default weight. */
8296 vty_out (vty
, " neighbor %s weight %d%s", addr
, peer
->weight
,
8299 /* Route refresh. */
8300 if (! CHECK_FLAG (peer
->flags
, PEER_FLAG_CAPABILITY_ROUTE_REFRESH
))
8301 vty_out (vty
, " no neighbor %s capability route-refresh%s", addr
,
8304 /* dont capability negotiation. */
8305 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_DONT_CAPABILITY
))
8306 vty_out (vty
, " neighbor %s dont-capability-negotiate%s", addr
,
8309 /* override capability negotiation. */
8310 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_OVERRIDE_CAPABILITY
))
8311 vty_out (vty
, " neighbor %s override-capability%s", addr
,
8314 /* strict capability negotiation. */
8315 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_STRICT_CAP_MATCH
))
8316 vty_out (vty
, " neighbor %s strict-capability-match%s", addr
,
8319 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_NO_DEFAULT_IPV4
))
8321 if (conf
->afc
[AFI_IP
][SAFI_UNICAST
])
8322 vty_out (vty
, " neighbor %s activate%s", addr
, VTY_NEWLINE
);
8326 if (! conf
->afc
[AFI_IP
][SAFI_UNICAST
])
8327 vty_out (vty
, " no neighbor %s activate%s", addr
, VTY_NEWLINE
);
8332 /************************************
8333 ****** Per AF to the neighbor ******
8334 ************************************/
8336 if (! (afi
== AFI_IP
&& safi
== SAFI_UNICAST
))
8337 vty_out (vty
, " neighbor %s activate%s", addr
, VTY_NEWLINE
);
8339 /* Route reflector client. */
8340 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_REFLECTOR_CLIENT
))
8341 vty_out (vty
, " neighbor %s route-reflector-client%s", addr
, VTY_NEWLINE
);
8344 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_NEXTHOP_SELF
))
8345 vty_out (vty
, " neighbor %s next-hop-self%s", addr
, VTY_NEWLINE
);
8347 /* send-community print. */
8348 if (! (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8349 && CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SEND_EXT_COMMUNITY
)))
8351 if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SEND_COMMUNITY
)
8352 && ! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SEND_EXT_COMMUNITY
))
8353 vty_out (vty
, " no neighbor %s send-community both%s",
8355 else if (! CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SEND_EXT_COMMUNITY
))
8356 vty_out (vty
, " no neighbor %s send-community extended%s",
8359 vty_out (vty
, " no neighbor %s send-community%s",
8363 /* Default information */
8364 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_DEFAULT_ORIGINATE
)
8365 && (afi
== AFI_IP
&& safi
== SAFI_UNICAST
))
8366 vty_out (vty
, " neighbor %s default-originate%s", addr
, VTY_NEWLINE
);
8368 /* Soft reconfiguration inbound. */
8369 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_SOFT_RECONFIG
))
8370 vty_out (vty
, " neighbor %s soft-reconfiguration inbound%s", addr
,
8373 /* maximum-prefix. */
8374 if (conf
->pmax
[afi
][safi
])
8375 vty_out (vty
, " neighbor %s maximum-prefix %ld%s%s",
8376 addr
, conf
->pmax
[afi
][safi
],
8377 conf
->pmax_warning
[afi
][safi
] ? " warning-only" : "",
8380 /* Route server client. */
8381 if (CHECK_FLAG (peer
->af_flags
[afi
][safi
], PEER_FLAG_RSERVER_CLIENT
))
8382 vty_out (vty
, " neighbor %s route-server-client%s", addr
, VTY_NEWLINE
);
8384 /* translate-update. */
8385 if (peer
->translate_update
8386 && (afi
== AFI_IP
&& safi
== SAFI_UNICAST
))
8388 vty_out (vty
, " neighbor %s", addr
);
8390 if (peer
->translate_update
== SAFI_UNICAST_MULTICAST
)
8391 vty_out (vty
, " translate-update nlri unicast multicast%s",
8393 else if (peer
->translate_update
== SAFI_MULTICAST
)
8394 vty_out (vty
, " translate-update nlri multicast%s",
8399 bgp_config_write_filter (vty
, filter
, addr
);
8401 /* transparent-as. */
8402 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_TRANSPARENT_AS
)
8403 && (afi
== AFI_IP
&& safi
== SAFI_UNICAST
))
8404 vty_out (vty
, " neighbor %s transparent-as%s", addr
, VTY_NEWLINE
);
8406 /* transparent-nexthop. */
8407 if (CHECK_FLAG (peer
->flags
, PEER_FLAG_TRANSPARENT_NEXTHOP
)
8408 && (afi
== AFI_IP
&& safi
== SAFI_UNICAST
))
8409 vty_out (vty
, " neighbor %s transparent-nexthop%s", addr
,
8413 /* Display "address-family" configuration header. */
8415 bgp_config_write_family_header (struct vty
*vty
, afi_t afi
, safi_t safi
,
8421 if (afi
== AFI_IP
&& safi
== SAFI_UNICAST
)
8424 vty_out (vty
, "!%s address-family ", VTY_NEWLINE
);
8428 if (safi
== SAFI_MULTICAST
)
8429 vty_out (vty
, "ipv4 multicast");
8430 else if (safi
== SAFI_MPLS_VPN
)
8431 vty_out (vty
, "vpnv4 unicast");
8433 else if (afi
== AFI_IP6
)
8434 vty_out (vty
, "ipv6");
8436 vty_out (vty
, "%s", VTY_NEWLINE
);
8441 /* Address family based peer configuration display. */
8443 bgp_config_write_family (struct vty
*vty
, struct bgp
*bgp
, afi_t afi
,
8447 struct peer_conf
*conf
;
8448 struct listnode
*nn
;
8450 bgp_config_write_network (vty
, bgp
, afi
, safi
, &write
);
8452 bgp_config_write_redistribute (vty
, bgp
, afi
, safi
, &write
);
8454 LIST_LOOP (bgp
->peer_conf
, conf
, nn
)
8456 if (conf
->afc
[afi
][safi
])
8458 bgp_config_write_family_header (vty
, afi
, safi
, &write
);
8459 bgp_config_write_peer (vty
, bgp
, conf
, afi
, safi
);
8463 vty_out (vty
, " exit-address-family%s", VTY_NEWLINE
);
8469 bgp_config_write (struct vty
*vty
)
8473 struct peer_group
*group
;
8474 struct peer_conf
*conf
;
8475 struct listnode
*nn
, *nm
, *no
;
8477 /* BGP Multiple instance. */
8478 if (bgp_multiple_instance
)
8480 vty_out (vty
, "bgp multiple-instance%s", VTY_NEWLINE
);
8481 vty_out (vty
, "!%s", VTY_NEWLINE
);
8484 /* BGP configuration. */
8485 LIST_LOOP (bgp_list
, bgp
, nn
)
8488 vty_out (vty
, "!%s", VTY_NEWLINE
);
8490 /* Router bgp ASN */
8491 vty_out (vty
, "router bgp %d", bgp
->as
);
8493 if (bgp_multiple_instance
)
8496 vty_out (vty
, " view %s", bgp
->name
);
8498 vty_out (vty
, "%s", VTY_NEWLINE
);
8500 /* BGP router ID. */
8501 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_ROUTER_ID
))
8502 vty_out (vty
, " bgp router-id %s%s", inet_ntoa (bgp
->id
),
8505 /* BGP configuration. */
8506 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_ALWAYS_COMPARE_MED
))
8507 vty_out (vty
, " bgp always-compare-med%s", VTY_NEWLINE
);
8509 /* BGP default ipv4-unicast. */
8510 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_NO_DEFAULT_IPV4
))
8511 vty_out (vty
, " no bgp default ipv4-unicast%s", VTY_NEWLINE
);
8513 /* BGP default local-preference. */
8514 if (bgp
->default_local_pref
!= BGP_DEFAULT_LOCAL_PREF
)
8515 vty_out (vty
, " bgp default local-preference %d%s",
8516 bgp
->default_local_pref
,
8519 /* BGP client-to-client reflection. */
8520 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_NO_CLIENT_TO_CLIENT
))
8521 vty_out (vty
, " no bgp client-to-client reflection%s", VTY_NEWLINE
);
8523 /* BGP cluster ID. */
8524 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_CLUSTER_ID
))
8525 vty_out (vty
, " bgp cluster-id %s%s", inet_ntoa (bgp
->cluster
),
8528 /* Confederation Information */
8529 if(CHECK_FLAG(bgp
->config
, BGP_CONFIG_CONFEDERATION
))
8531 vty_out(vty
, " bgp confederation identifier %i%s",
8532 bgp
->confederation_id
,
8534 if(bgp
->confederation_peers_cnt
> 0)
8536 vty_out(vty
, " bgp confederation peers");
8537 bgp_confederation_peers_print(vty
, bgp
);
8538 vty_out(vty
, "%s", VTY_NEWLINE
);
8542 /* BGP enforce-first-as. */
8543 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_ENFORCE_FIRST_AS
))
8544 vty_out (vty
, " bgp enforce-first-as%s", VTY_NEWLINE
);
8546 /* BGP deterministic-med. */
8547 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_DETERMINISTIC_MED
))
8548 vty_out (vty
, " bgp deterministic-med%s", VTY_NEWLINE
);
8550 /* BGP bestpath method. */
8551 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_ASPATH_IGNORE
))
8552 vty_out (vty
, " bgp bestpath as-path ignore%s", VTY_NEWLINE
);
8553 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_COMPARE_ROUTER_ID
))
8554 vty_out (vty
, " bgp bestpath compare-routerid%s", VTY_NEWLINE
);
8555 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_MED_CONFED
)
8556 || CHECK_FLAG (bgp
->config
, BGP_CONFIG_MED_MISSING_AS_WORST
))
8558 vty_out (vty
, " bgp bestpath med");
8559 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_MED_CONFED
))
8560 vty_out (vty
, " confed");
8561 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_MED_MISSING_AS_WORST
))
8562 vty_out (vty
, " missing-as-worst");
8563 vty_out (vty
, "%s", VTY_NEWLINE
);
8566 /* BGP network import check. */
8567 if (CHECK_FLAG (bgp
->config
, BGP_CONFIG_IMPORT_CHECK
))
8568 vty_out (vty
, " bgp network import-check%s", VTY_NEWLINE
);
8570 /* BGP scan interval. */
8571 bgp_config_write_scan_time (vty
);
8573 /* BGP flag dampening. */
8574 bgp_config_write_damp (vty
);
8576 /* BGP static route configuration. */
8577 bgp_config_write_network (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, &write
);
8579 /* BGP redistribute configuration. */
8580 bgp_config_write_redistribute (vty
, bgp
, AFI_IP
, SAFI_UNICAST
, &write
);
8582 /* BGP timers configuration. */
8583 if (bgp
->default_keepalive
!= BGP_DEFAULT_KEEPALIVE
8584 && bgp
->default_holdtime
!= BGP_DEFAULT_HOLDTIME
)
8585 vty_out (vty
, " timers bgp %d %d%s", bgp
->default_keepalive
,
8586 bgp
->default_holdtime
, VTY_NEWLINE
);
8589 LIST_LOOP (bgp
->peer_group
, group
, nm
)
8591 vty_out (vty
, " neighbor %s peer-group", group
->name
);
8592 vty_out (vty
, "%s", VTY_NEWLINE
);
8595 vty_out (vty
, " remote-as %d%s", group
->as
, VTY_NEWLINE
);
8598 /* Normal neighbor configuration. */
8599 LIST_LOOP (bgp
->peer_conf
, conf
, no
)
8601 bgp_config_write_peer (vty
, bgp
, conf
, AFI_IP
, SAFI_UNICAST
);
8604 /* Distance configuration. */
8605 bgp_config_write_distance (vty
, bgp
);
8607 /* IPv4 multicast configuration. */
8608 write
+= bgp_config_write_family (vty
, bgp
, AFI_IP
, SAFI_MULTICAST
);
8610 /* IPv4 VPN configuration. */
8611 write
+= bgp_config_write_family (vty
, bgp
, AFI_IP
, SAFI_MPLS_VPN
);
8613 /* IPv6 unicast configuration. */
8614 write
+= bgp_config_write_family (vty
, bgp
, AFI_IP6
, SAFI_UNICAST
);
8621 /* BGP node structure. */
8622 struct cmd_node bgp_node
=
8625 "%s(config-router)# ",
8629 struct cmd_node bgp_ipv4_multicast_node
=
8632 "%s(config-router-af)# ",
8636 struct cmd_node bgp_ipv6_unicast_node
=
8639 "%s(config-router-af)# ",
8643 /* Install bgp related commands. */
8647 /* Install bgp top node. */
8648 install_node (&bgp_node
, bgp_config_write
);
8649 install_node (&bgp_ipv4_multicast_node
, NULL
);
8650 install_node (&bgp_ipv6_unicast_node
, NULL
);
8652 install_default (BGP_NODE
);
8653 install_default (BGP_IPV4M_NODE
);
8654 install_default (BGP_IPV6_NODE
);
8656 /* "bgp multiple-instance" commands. */
8657 install_element (CONFIG_NODE
, &bgp_multiple_instance_cmd
);
8658 install_element (CONFIG_NODE
, &no_bgp_multiple_instance_cmd
);
8660 /* "bgp router-id" commands. */
8661 install_element (BGP_NODE
, &bgp_router_id_cmd
);
8662 install_element (BGP_NODE
, &no_bgp_router_id_cmd
);
8663 install_element (BGP_NODE
, &no_bgp_router_id_val_cmd
);
8665 /* "timers bgp" commands. */
8666 install_element (BGP_NODE
, &bgp_timers_cmd
);
8667 install_element (BGP_NODE
, &no_bgp_timers_cmd
);
8669 /* "bgp cluster-id" commands. */
8670 install_element (BGP_NODE
, &bgp_cluster_id_cmd
);
8671 install_element (BGP_NODE
, &bgp_cluster_id32_cmd
);
8672 install_element (BGP_NODE
, &no_bgp_cluster_id_cmd
);
8673 install_element (BGP_NODE
, &no_bgp_cluster_id_val_cmd
);
8675 /* "bgp client-to-client reflection" commands */
8676 install_element (BGP_NODE
, &no_bgp_client_to_client_reflection_cmd
);
8677 install_element (BGP_NODE
, &bgp_client_to_client_reflection_cmd
);
8679 /* "bgp always-compare-med" commands */
8680 install_element (BGP_NODE
, &bgp_always_compare_med_cmd
);
8681 install_element (BGP_NODE
, &no_bgp_always_compare_med_cmd
);
8683 /* "bgp deterministic-med" commands */
8684 install_element (BGP_NODE
, &bgp_deterministic_med_cmd
);
8685 install_element (BGP_NODE
, &no_bgp_deterministic_med_cmd
);
8687 /* "bgp enforce-first-as" commands */
8688 install_element (BGP_NODE
, &bgp_enforce_first_as_cmd
);
8689 install_element (BGP_NODE
, &no_bgp_enforce_first_as_cmd
);
8691 /* "bgp bestpath compare-routerid" commands */
8692 install_element (BGP_NODE
, &bgp_bestpath_compare_router_id_cmd
);
8693 install_element (BGP_NODE
, &no_bgp_bestpath_compare_router_id_cmd
);
8695 /* "bgp bestpath as-path ignore" commands */
8696 install_element (BGP_NODE
, &bgp_bestpath_aspath_ignore_cmd
);
8697 install_element (BGP_NODE
, &no_bgp_bestpath_aspath_ignore_cmd
);
8699 /* "bgp bestpath med" commands */
8700 install_element (BGP_NODE
, &bgp_bestpath_med_cmd
);
8701 install_element (BGP_NODE
, &bgp_bestpath_med2_cmd
);
8702 install_element (BGP_NODE
, &bgp_bestpath_med3_cmd
);
8703 install_element (BGP_NODE
, &no_bgp_bestpath_med_cmd
);
8704 install_element (BGP_NODE
, &no_bgp_bestpath_med2_cmd
);
8705 install_element (BGP_NODE
, &no_bgp_bestpath_med3_cmd
);
8707 /* "bgp network import-check" commands. */
8708 install_element (BGP_NODE
, &bgp_network_import_check_cmd
);
8709 install_element (BGP_NODE
, &no_bgp_network_import_check_cmd
);
8711 /* "no bgp default ipv4-unicast" commands. */
8712 install_element (BGP_NODE
, &no_bgp_default_ipv4_unicast_cmd
);
8713 install_element (BGP_NODE
, &bgp_default_ipv4_unicast_cmd
);
8715 /* "bgp default local-preference" commands. */
8716 install_element (BGP_NODE
, &bgp_default_local_preference_cmd
);
8717 install_element (BGP_NODE
, &no_bgp_default_local_preference_cmd
);
8718 install_element (BGP_NODE
, &no_bgp_default_local_preference_val_cmd
);
8720 /* "router bgp" commands. */
8721 install_element (CONFIG_NODE
, &router_bgp_cmd
);
8722 install_element (CONFIG_NODE
, &router_bgp_view_cmd
);
8724 /* "no router bgp" commands. */
8725 install_element (CONFIG_NODE
, &no_router_bgp_cmd
);
8726 install_element (CONFIG_NODE
, &no_router_bgp_view_cmd
);
8728 /* "neighbor remote-as" commands. */
8729 install_element (BGP_NODE
, &neighbor_remote_as_cmd
);
8730 install_element (BGP_NODE
, &neighbor_remote_as_unicast_cmd
);
8731 install_element (BGP_NODE
, &neighbor_remote_as_multicast_cmd
);
8732 install_element (BGP_NODE
, &neighbor_remote_as_unicast_multicast_cmd
);
8734 install_element (BGP_NODE
, &neighbor_activate_cmd
);
8735 install_element (BGP_NODE
, &no_neighbor_activate_cmd
);
8736 install_element (BGP_IPV4M_NODE
, &neighbor_activate_cmd
);
8737 install_element (BGP_IPV4M_NODE
, &no_neighbor_activate_cmd
);
8738 install_element (BGP_IPV6_NODE
, &neighbor_activate_cmd
);
8739 install_element (BGP_IPV6_NODE
, &no_neighbor_activate_cmd
);
8741 /* "no neighbor remote-as" commands. */
8742 install_element (BGP_NODE
, &no_neighbor_cmd
);
8743 install_element (BGP_NODE
, &no_neighbor_remote_as_cmd
);
8745 /* "neighbor passive" commands. */
8746 install_element (BGP_NODE
, &neighbor_passive_cmd
);
8747 install_element (BGP_NODE
, &no_neighbor_passive_cmd
);
8749 /* "neighbor shutdown" commands. */
8750 install_element (BGP_NODE
, &neighbor_shutdown_cmd
);
8751 install_element (BGP_NODE
, &no_neighbor_shutdown_cmd
);
8753 /* "neighbor ebgp-multihop" commands. */
8754 install_element (BGP_NODE
, &neighbor_ebgp_multihop_cmd
);
8755 install_element (BGP_NODE
, &neighbor_ebgp_multihop_ttl_cmd
);
8756 install_element (BGP_NODE
, &no_neighbor_ebgp_multihop_cmd
);
8757 install_element (BGP_NODE
, &no_neighbor_ebgp_multihop_ttl_cmd
);
8759 /* "neighbor description" commands. */
8760 install_element (BGP_NODE
, &neighbor_description_cmd
);
8761 install_element (BGP_NODE
, &no_neighbor_description_cmd
);
8762 install_element (BGP_NODE
, &no_neighbor_description_val_cmd
);
8764 /* "neighbor version" commands. */
8765 install_element (BGP_NODE
, &neighbor_version_cmd
);
8766 install_element (BGP_NODE
, &no_neighbor_version_cmd
);
8768 /* "neighbor interface" commands. */
8769 install_element (BGP_NODE
, &neighbor_interface_cmd
);
8770 install_element (BGP_NODE
, &no_neighbor_interface_cmd
);
8772 /* "neighbor next-hop-self" commands. */
8773 install_element (BGP_NODE
, &neighbor_nexthop_self_cmd
);
8774 install_element (BGP_NODE
, &no_neighbor_nexthop_self_cmd
);
8775 install_element (BGP_IPV4M_NODE
, &neighbor_nexthop_self_cmd
);
8776 install_element (BGP_IPV4M_NODE
, &no_neighbor_nexthop_self_cmd
);
8777 install_element (BGP_IPV6_NODE
, &neighbor_nexthop_self_cmd
);
8778 install_element (BGP_IPV6_NODE
, &no_neighbor_nexthop_self_cmd
);
8780 /* "neighbor update-source" commands. "*/
8781 install_element (BGP_NODE
, &neighbor_update_source_cmd
);
8782 install_element (BGP_NODE
, &no_neighbor_update_source_cmd
);
8784 /* "neighbor default-originate" commands. */
8785 install_element (BGP_NODE
, &neighbor_default_originate_cmd
);
8786 install_element (BGP_NODE
, &no_neighbor_default_originate_cmd
);
8788 /* "neighbor port" commands. */
8789 install_element (BGP_NODE
, &neighbor_port_cmd
);
8790 install_element (BGP_NODE
, &no_neighbor_port_cmd
);
8791 install_element (BGP_NODE
, &no_neighbor_port_val_cmd
);
8793 /* "neighbor send-community" commands.*/
8794 install_element (BGP_NODE
, &neighbor_send_community_cmd
);
8795 install_element (BGP_NODE
, &neighbor_send_community_type_cmd
);
8796 install_element (BGP_NODE
, &no_neighbor_send_community_cmd
);
8797 install_element (BGP_NODE
, &no_neighbor_send_community_type_cmd
);
8798 install_element (BGP_IPV4M_NODE
, &neighbor_send_community_cmd
);
8799 install_element (BGP_IPV4M_NODE
, &neighbor_send_community_type_cmd
);
8800 install_element (BGP_IPV4M_NODE
, &no_neighbor_send_community_cmd
);
8801 install_element (BGP_IPV4M_NODE
, &no_neighbor_send_community_type_cmd
);
8802 install_element (BGP_IPV6_NODE
, &neighbor_send_community_cmd
);
8803 install_element (BGP_IPV6_NODE
, &neighbor_send_community_type_cmd
);
8804 install_element (BGP_IPV6_NODE
, &no_neighbor_send_community_cmd
);
8805 install_element (BGP_IPV6_NODE
, &no_neighbor_send_community_type_cmd
);
8807 /* "neighbor weight" commands. */
8808 install_element (BGP_NODE
, &neighbor_weight_cmd
);
8809 install_element (BGP_NODE
, &no_neighbor_weight_cmd
);
8810 install_element (BGP_NODE
, &no_neighbor_weight_val_cmd
);
8812 /* "neighbor softreconfiguration inbound" commands.*/
8813 install_element (BGP_NODE
, &neighbor_soft_reconfiguration_cmd
);
8814 install_element (BGP_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
8815 install_element (BGP_IPV4M_NODE
, &neighbor_soft_reconfiguration_cmd
);
8816 install_element (BGP_IPV4M_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
8817 install_element (BGP_IPV6_NODE
, &neighbor_soft_reconfiguration_cmd
);
8818 install_element (BGP_IPV6_NODE
, &no_neighbor_soft_reconfiguration_cmd
);
8820 /* "neighbor route-reflector" commands.*/
8821 install_element (BGP_NODE
, &neighbor_route_reflector_client_cmd
);
8822 install_element (BGP_NODE
, &no_neighbor_route_reflector_client_cmd
);
8823 install_element (BGP_IPV4M_NODE
, &neighbor_route_reflector_client_cmd
);
8824 install_element (BGP_IPV4M_NODE
, &no_neighbor_route_reflector_client_cmd
);
8825 install_element (BGP_IPV6_NODE
, &neighbor_route_reflector_client_cmd
);
8826 install_element (BGP_IPV6_NODE
, &no_neighbor_route_reflector_client_cmd
);
8828 /* "neighbor route-server" commands.*/
8829 install_element (BGP_NODE
, &neighbor_route_server_client_cmd
);
8830 install_element (BGP_NODE
, &no_neighbor_route_server_client_cmd
);
8831 install_element (BGP_IPV4M_NODE
, &neighbor_route_server_client_cmd
);
8832 install_element (BGP_IPV4M_NODE
, &no_neighbor_route_server_client_cmd
);
8833 install_element (BGP_IPV6_NODE
, &neighbor_route_server_client_cmd
);
8834 install_element (BGP_IPV6_NODE
, &no_neighbor_route_server_client_cmd
);
8836 /* "neighbor capability route-refresh" commands.*/
8837 install_element (BGP_NODE
, &neighbor_capability_route_refresh_cmd
);
8838 install_element (BGP_NODE
, &no_neighbor_capability_route_refresh_cmd
);
8840 /* "neighbor translate-update" commands. */
8841 install_element (BGP_NODE
, &neighbor_translate_update_multicast_cmd
);
8842 install_element (BGP_NODE
, &neighbor_translate_update_unimulti_cmd
);
8843 install_element (BGP_NODE
, &no_neighbor_translate_update_cmd
);
8844 install_element (BGP_NODE
, &no_neighbor_translate_update_multicast_cmd
);
8845 install_element (BGP_NODE
, &no_neighbor_translate_update_unimulti_cmd
);
8847 /* "neighbor dont-capability-negotiate" commands. */
8848 install_element (BGP_NODE
, &neighbor_dont_capability_negotiate_cmd
);
8849 install_element (BGP_NODE
, &no_neighbor_dont_capability_negotiate_cmd
);
8851 /* "neighbor override-capability" commands. */
8852 install_element (BGP_NODE
, &neighbor_override_capability_cmd
);
8853 install_element (BGP_NODE
, &no_neighbor_override_capability_cmd
);
8855 /* "neighbor strict-capability-match" commands. */
8856 install_element (BGP_NODE
, &neighbor_strict_capability_cmd
);
8857 install_element (BGP_NODE
, &no_neighbor_strict_capability_cmd
);
8859 /* "neighbor timers" commands. */
8860 install_element (BGP_NODE
, &neighbor_timers_cmd
);
8861 install_element (BGP_NODE
, &no_neighbor_timers_cmd
);
8863 /* "neighbor timers connect" commands. */
8864 install_element (BGP_NODE
, &neighbor_timers_connect_cmd
);
8865 install_element (BGP_NODE
, &no_neighbor_timers_connect_cmd
);
8868 install_element (BGP_NODE
, &neighbor_distribute_list_cmd
);
8869 install_element (BGP_NODE
, &no_neighbor_distribute_list_cmd
);
8870 install_element (BGP_NODE
, &neighbor_prefix_list_cmd
);
8871 install_element (BGP_NODE
, &no_neighbor_prefix_list_cmd
);
8872 install_element (BGP_NODE
, &neighbor_filter_list_cmd
);
8873 install_element (BGP_NODE
, &no_neighbor_filter_list_cmd
);
8874 install_element (BGP_NODE
, &neighbor_route_map_cmd
);
8875 install_element (BGP_NODE
, &no_neighbor_route_map_cmd
);
8876 install_element (BGP_IPV4M_NODE
, &neighbor_distribute_list_cmd
);
8877 install_element (BGP_IPV4M_NODE
, &no_neighbor_distribute_list_cmd
);
8878 install_element (BGP_IPV4M_NODE
, &neighbor_prefix_list_cmd
);
8879 install_element (BGP_IPV4M_NODE
, &no_neighbor_prefix_list_cmd
);
8880 install_element (BGP_IPV4M_NODE
, &neighbor_filter_list_cmd
);
8881 install_element (BGP_IPV4M_NODE
, &no_neighbor_filter_list_cmd
);
8882 install_element (BGP_IPV4M_NODE
, &neighbor_route_map_cmd
);
8883 install_element (BGP_IPV4M_NODE
, &no_neighbor_route_map_cmd
);
8885 install_element (BGP_NODE
, &neighbor_peer_group_cmd
);
8886 install_element (BGP_NODE
, &neighbor_peer_group_remote_as_cmd
);
8889 /* "neighbor maximum-prefix" commands. */
8890 install_element (BGP_NODE
, &neighbor_maximum_prefix_cmd
);
8891 install_element (BGP_NODE
, &neighbor_maximum_prefix_warning_cmd
);
8892 install_element (BGP_NODE
, &no_neighbor_maximum_prefix_cmd
);
8893 install_element (BGP_NODE
, &no_neighbor_maximum_prefix_val_cmd
);
8894 install_element (BGP_NODE
, &no_neighbor_maximum_prefix_val2_cmd
);
8895 install_element (BGP_IPV4M_NODE
, &neighbor_maximum_prefix_cmd
);
8896 install_element (BGP_IPV4M_NODE
, &neighbor_maximum_prefix_warning_cmd
);
8897 install_element (BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_cmd
);
8898 install_element (BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_val_cmd
);
8899 install_element (BGP_IPV4M_NODE
, &no_neighbor_maximum_prefix_val2_cmd
);
8900 install_element (BGP_IPV6_NODE
, &neighbor_maximum_prefix_cmd
);
8901 install_element (BGP_IPV6_NODE
, &neighbor_maximum_prefix_warning_cmd
);
8902 install_element (BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_cmd
);
8903 install_element (BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_val_cmd
);
8904 install_element (BGP_IPV6_NODE
, &no_neighbor_maximum_prefix_val2_cmd
);
8906 /* "bgp confederation" commands. */
8907 install_element (BGP_NODE
, &bgp_confederation_identifier_cmd
);
8908 install_element (BGP_NODE
, &bgp_confederation_peers_cmd
);
8909 install_element (BGP_NODE
, &no_bgp_confederation_identifier_cmd
);
8910 install_element (BGP_NODE
, &no_bgp_confederation_peers_cmd
);
8912 /* "transparent-as" commands. */
8913 install_element (BGP_NODE
, &neighbor_transparent_as_cmd
);
8914 install_element (BGP_NODE
, &no_neighbor_transparent_as_cmd
);
8916 /* "transparent-nexthop" commands. */
8917 install_element (BGP_NODE
, &neighbor_transparent_nexthop_cmd
);
8918 install_element (BGP_NODE
, &no_neighbor_transparent_nexthop_cmd
);
8920 /* "show ip bgp summary" commands. */
8921 install_element (VIEW_NODE
, &show_ip_bgp_summary_cmd
);
8922 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_summary_cmd
);
8923 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_summary_cmd
);
8924 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_summary_cmd
);
8926 install_element (ENABLE_NODE
, &show_ip_bgp_summary_cmd
);
8927 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_summary_cmd
);
8928 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_summary_cmd
);
8929 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_summary_cmd
);
8931 /* "show ip bgp neighbors" commands. */
8932 install_element (VIEW_NODE
, &show_ip_bgp_neighbors_cmd
);
8933 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbors_cmd
);
8934 install_element (VIEW_NODE
, &show_ip_bgp_neighbors_peer_cmd
);
8935 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_neighbors_peer_cmd
);
8936 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_neighbors_cmd
);
8937 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_neighbors_cmd
);
8938 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd
);
8939 install_element (VIEW_NODE
, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd
);
8941 install_element (ENABLE_NODE
, &show_ip_bgp_neighbors_cmd
);
8942 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbors_cmd
);
8943 install_element (ENABLE_NODE
, &show_ip_bgp_neighbors_peer_cmd
);
8944 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_neighbors_peer_cmd
);
8945 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_neighbors_cmd
);
8946 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_neighbors_cmd
);
8947 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd
);
8948 install_element (ENABLE_NODE
, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd
);
8950 /* "show ip bgp paths" commands. */
8951 install_element (VIEW_NODE
, &show_ip_bgp_paths_cmd
);
8952 install_element (VIEW_NODE
, &show_ip_bgp_ipv4_paths_cmd
);
8953 install_element (ENABLE_NODE
, &show_ip_bgp_paths_cmd
);
8954 install_element (ENABLE_NODE
, &show_ip_bgp_ipv4_paths_cmd
);
8956 /* "show ip bgp community" commands. */
8957 install_element (VIEW_NODE
, &show_ip_bgp_community_info_cmd
);
8958 install_element (ENABLE_NODE
, &show_ip_bgp_community_info_cmd
);
8960 /* "show ip bgp attribute-info" commands. */
8961 install_element (VIEW_NODE
, &show_ip_bgp_attr_info_cmd
);
8962 install_element (ENABLE_NODE
, &show_ip_bgp_attr_info_cmd
);
8964 /* "clear ip bgp commands" */
8965 install_element (ENABLE_NODE
, &clear_ip_bgp_all_cmd
);
8966 install_element (ENABLE_NODE
, &clear_ip_bgp_as_cmd
);
8967 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_cmd
);
8969 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_group_cmd
);
8972 /* "clear ip bgp neighbor soft in" */
8973 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_soft_in_cmd
);
8974 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_in_cmd
);
8975 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_ipv4_soft_in_cmd
);
8976 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_ipv4_in_cmd
);
8977 install_element (ENABLE_NODE
, &clear_ip_bgp_as_soft_in_cmd
);
8978 install_element (ENABLE_NODE
, &clear_ip_bgp_as_in_cmd
);
8979 install_element (ENABLE_NODE
, &clear_ip_bgp_as_ipv4_soft_in_cmd
);
8980 install_element (ENABLE_NODE
, &clear_ip_bgp_as_ipv4_in_cmd
);
8981 install_element (ENABLE_NODE
, &clear_ip_bgp_all_soft_in_cmd
);
8982 install_element (ENABLE_NODE
, &clear_ip_bgp_all_in_cmd
);
8983 install_element (ENABLE_NODE
, &clear_ip_bgp_all_ipv4_soft_in_cmd
);
8984 install_element (ENABLE_NODE
, &clear_ip_bgp_all_ipv4_in_cmd
);
8986 /* "clear ip bgp neighbor soft out" */
8987 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_soft_out_cmd
);
8988 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_out_cmd
);
8989 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_ipv4_soft_out_cmd
);
8990 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_ipv4_out_cmd
);
8991 install_element (ENABLE_NODE
, &clear_ip_bgp_as_soft_out_cmd
);
8992 install_element (ENABLE_NODE
, &clear_ip_bgp_as_out_cmd
);
8993 install_element (ENABLE_NODE
, &clear_ip_bgp_as_ipv4_soft_out_cmd
);
8994 install_element (ENABLE_NODE
, &clear_ip_bgp_as_ipv4_out_cmd
);
8995 install_element (ENABLE_NODE
, &clear_ip_bgp_all_soft_out_cmd
);
8996 install_element (ENABLE_NODE
, &clear_ip_bgp_all_out_cmd
);
8997 install_element (ENABLE_NODE
, &clear_ip_bgp_all_ipv4_soft_out_cmd
);
8998 install_element (ENABLE_NODE
, &clear_ip_bgp_all_ipv4_out_cmd
);
9000 /* "clear ip bgp neighbor soft" */
9001 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_soft_cmd
);
9002 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_ipv4_soft_cmd
);
9003 install_element (ENABLE_NODE
, &clear_ip_bgp_as_soft_cmd
);
9004 install_element (ENABLE_NODE
, &clear_ip_bgp_as_ipv4_soft_cmd
);
9005 install_element (ENABLE_NODE
, &clear_ip_bgp_all_soft_cmd
);
9006 install_element (ENABLE_NODE
, &clear_ip_bgp_all_ipv4_soft_cmd
);
9009 /* "clear ip bgp vpnv4 soft in" */
9010 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_vpnv4_soft_in_cmd
);
9011 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_vpnv4_in_cmd
);
9012 install_element (ENABLE_NODE
, &clear_ip_bgp_as_vpnv4_soft_in_cmd
);
9013 install_element (ENABLE_NODE
, &clear_ip_bgp_as_vpnv4_in_cmd
);
9014 install_element (ENABLE_NODE
, &clear_ip_bgp_all_vpnv4_soft_in_cmd
);
9015 install_element (ENABLE_NODE
, &clear_ip_bgp_all_vpnv4_in_cmd
);
9017 /* "clear ip bgp vpnv4 soft out" */
9018 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_vpnv4_soft_out_cmd
);
9019 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_vpnv4_out_cmd
);
9020 install_element (ENABLE_NODE
, &clear_ip_bgp_as_vpnv4_soft_out_cmd
);
9021 install_element (ENABLE_NODE
, &clear_ip_bgp_as_vpnv4_out_cmd
);
9022 install_element (ENABLE_NODE
, &clear_ip_bgp_all_vpnv4_soft_out_cmd
);
9023 install_element (ENABLE_NODE
, &clear_ip_bgp_all_vpnv4_out_cmd
);
9025 /* "clear ip bgp vpnv4 soft" */
9026 install_element (ENABLE_NODE
, &clear_ip_bgp_peer_vpnv4_soft_cmd
);
9027 install_element (ENABLE_NODE
, &clear_ip_bgp_as_vpnv4_soft_cmd
);
9028 install_element (ENABLE_NODE
, &clear_ip_bgp_all_vpnv4_soft_cmd
);
9031 /* BGP-MP for IPv6 unicast. */
9032 install_element (BGP_NODE
, &address_family_ipv6_cmd
);
9033 install_element (BGP_NODE
, &address_family_ipv6_unicast_cmd
);
9034 install_element (BGP_IPV6_NODE
, &exit_address_family_cmd
);
9036 install_element (BGP_NODE
, &ipv6_bgp_neighbor_remote_as_cmd
);
9037 install_element (BGP_NODE
, &ipv6_bgp_neighbor_remote_as_unicast_cmd
);
9038 install_element (BGP_NODE
, &ipv6_bgp_neighbor_remote_as_multicast_cmd
);
9039 install_element (BGP_NODE
, &ipv6_bgp_neighbor_remote_as_unicast_multicast_cmd
);
9041 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_cmd
);
9042 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_remote_as_cmd
);
9044 /* "IPv6 neighbor passive" commands. */
9045 install_element (BGP_NODE
, &ipv6_bgp_neighbor_passive_cmd
);
9046 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_passive_cmd
);
9048 install_element (BGP_NODE
, &ipv6_bgp_neighbor_shutdown_cmd
);
9049 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_shutdown_cmd
);
9051 install_element (BGP_NODE
, &ipv6_bgp_neighbor_ebgp_multihop_cmd
);
9052 install_element (BGP_NODE
, &ipv6_bgp_neighbor_ebgp_multihop_ttl_cmd
);
9053 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_ebgp_multihop_cmd
);
9054 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_ebgp_multihop_ttl_cmd
);
9056 install_element (BGP_NODE
, &ipv6_bgp_neighbor_description_cmd
);
9057 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_description_cmd
);
9058 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_description_val_cmd
);
9060 install_element (BGP_NODE
, &ipv6_bgp_neighbor_version_cmd
);
9061 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_version_cmd
);
9063 install_element (BGP_NODE
, &ipv6_bgp_neighbor_interface_cmd
);
9064 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_interface_cmd
);
9066 install_element (BGP_NODE
, &ipv6_bgp_neighbor_nexthop_self_cmd
);
9067 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_nexthop_self_cmd
);
9069 install_element (BGP_NODE
, &ipv6_bgp_neighbor_update_source_cmd
);
9070 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_update_source_cmd
);
9072 install_element (BGP_NODE
, &ipv6_bgp_neighbor_default_originate_cmd
);
9073 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_default_originate_cmd
);
9075 install_element (BGP_NODE
, &ipv6_bgp_neighbor_port_cmd
);
9076 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_port_cmd
);
9077 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_port_val_cmd
);
9079 install_element (BGP_NODE
, &ipv6_bgp_neighbor_send_community_cmd
);
9080 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_send_community_cmd
);
9082 install_element (BGP_NODE
, &ipv6_bgp_neighbor_send_community_extended_cmd
);
9083 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_send_community_extended_cmd
);
9085 install_element (BGP_NODE
, &ipv6_bgp_neighbor_weight_cmd
);
9086 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_weight_cmd
);
9087 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_weight_val_cmd
);
9089 install_element (BGP_NODE
, &ipv6_bgp_neighbor_soft_reconfiguration_cmd
);
9090 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_soft_reconfiguration_cmd
);
9092 install_element (BGP_NODE
, &ipv6_bgp_neighbor_route_reflector_client_cmd
);
9093 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_route_reflector_client_cmd
);
9095 install_element (BGP_NODE
, &ipv6_bgp_neighbor_route_server_client_cmd
);
9096 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_route_server_client_cmd
);
9098 install_element (BGP_NODE
, &ipv6_bgp_neighbor_capability_route_refresh_cmd
);
9099 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_capability_route_refresh_cmd
);
9101 install_element (BGP_NODE
, &ipv6_neighbor_dont_capability_negotiate_cmd
);
9102 install_element (BGP_NODE
, &no_ipv6_neighbor_dont_capability_negotiate_cmd
);
9104 install_element (BGP_NODE
, &ipv6_neighbor_override_capability_cmd
);
9105 install_element (BGP_NODE
, &no_ipv6_neighbor_override_capability_cmd
);
9107 install_element (BGP_NODE
, &ipv6_neighbor_strict_capability_cmd
);
9108 install_element (BGP_NODE
, &no_ipv6_neighbor_strict_capability_cmd
);
9110 install_element (BGP_NODE
, &ipv6_bgp_neighbor_timers_cmd
);
9111 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_timers_cmd
);
9113 install_element (BGP_NODE
, &ipv6_bgp_neighbor_timers_connect_cmd
);
9114 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_timers_connect_cmd
);
9116 install_element (BGP_IPV6_NODE
, &ipv6_bgp_neighbor_distribute_list_cmd
);
9117 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_neighbor_distribute_list_cmd
);
9118 install_element (BGP_IPV6_NODE
, &ipv6_bgp_neighbor_prefix_list_cmd
);
9119 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_neighbor_prefix_list_cmd
);
9120 install_element (BGP_IPV6_NODE
, &ipv6_bgp_neighbor_filter_list_cmd
);
9121 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_neighbor_filter_list_cmd
);
9122 install_element (BGP_IPV6_NODE
, &ipv6_bgp_neighbor_route_map_cmd
);
9123 install_element (BGP_IPV6_NODE
, &no_ipv6_bgp_neighbor_route_map_cmd
);
9125 install_element (BGP_NODE
, &old_ipv6_bgp_neighbor_distribute_list_cmd
);
9126 install_element (BGP_NODE
, &old_no_ipv6_bgp_neighbor_distribute_list_cmd
);
9127 install_element (BGP_NODE
, &old_ipv6_bgp_neighbor_prefix_list_cmd
);
9128 install_element (BGP_NODE
, &old_no_ipv6_bgp_neighbor_prefix_list_cmd
);
9129 install_element (BGP_NODE
, &old_ipv6_bgp_neighbor_filter_list_cmd
);
9130 install_element (BGP_NODE
, &old_no_ipv6_bgp_neighbor_filter_list_cmd
);
9131 install_element (BGP_NODE
, &old_ipv6_bgp_neighbor_route_map_cmd
);
9132 install_element (BGP_NODE
, &old_no_ipv6_bgp_neighbor_route_map_cmd
);
9134 install_element (BGP_NODE
, &ipv6_bgp_neighbor_transparent_as_cmd
);
9135 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_transparent_as_cmd
);
9137 install_element (BGP_NODE
, &ipv6_bgp_neighbor_transparent_nexthop_cmd
);
9138 install_element (BGP_NODE
, &no_ipv6_bgp_neighbor_transparent_nexthop_cmd
);
9140 install_element (VIEW_NODE
, &show_bgp_summary_cmd
);
9141 install_element (VIEW_NODE
, &show_bgp_ipv6_summary_cmd
);
9142 install_element (VIEW_NODE
, &show_bgp_neighbors_cmd
);
9143 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbors_cmd
);
9144 install_element (VIEW_NODE
, &show_bgp_neighbors_peer_cmd
);
9145 install_element (VIEW_NODE
, &show_bgp_ipv6_neighbors_peer_cmd
);
9147 install_element (ENABLE_NODE
, &show_bgp_summary_cmd
);
9148 install_element (ENABLE_NODE
, &show_bgp_ipv6_summary_cmd
);
9149 install_element (ENABLE_NODE
, &show_bgp_neighbors_cmd
);
9150 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbors_cmd
);
9151 install_element (ENABLE_NODE
, &show_bgp_neighbors_peer_cmd
);
9152 install_element (ENABLE_NODE
, &show_bgp_ipv6_neighbors_peer_cmd
);
9155 install_element (VIEW_NODE
, &show_ipv6_bgp_summary_cmd
);
9156 install_element (VIEW_NODE
, &show_ipv6_mbgp_summary_cmd
);
9159 install_element (ENABLE_NODE
, &show_ipv6_bgp_summary_cmd
);
9160 install_element (ENABLE_NODE
, &show_ipv6_mbgp_summary_cmd
);
9163 install_element (VIEW_NODE
, &show_ipv6_bgp_neighbors_cmd
);
9164 install_element (VIEW_NODE
, &show_ipv6_bgp_neighbors_peer_cmd
);
9165 install_element (VIEW_NODE
, &show_ipv6_mbgp_neighbors_cmd
);
9166 install_element (VIEW_NODE
, &show_ipv6_mbgp_neighbors_peer_cmd
);
9169 install_element (ENABLE_NODE
, &show_ipv6_bgp_neighbors_cmd
);
9170 install_element (ENABLE_NODE
, &show_ipv6_bgp_neighbors_peer_cmd
);
9171 install_element (ENABLE_NODE
, &show_ipv6_mbgp_neighbors_cmd
);
9172 install_element (ENABLE_NODE
, &show_ipv6_mbgp_neighbors_peer_cmd
);
9174 install_element (ENABLE_NODE
, &clear_bgp_all_cmd
);
9175 install_element (ENABLE_NODE
, &clear_bgp_ipv6_all_cmd
);
9176 install_element (ENABLE_NODE
, &clear_bgp_peer_cmd
);
9177 install_element (ENABLE_NODE
, &clear_bgp_ipv6_peer_cmd
);
9179 install_element (ENABLE_NODE
, &clear_bgp_peer_group_cmd
);
9180 install_element (ENABLE_NODE
, &clear_bgp_ipv6_peer_group_cmd
);
9182 install_element (ENABLE_NODE
, &clear_bgp_as_cmd
);
9183 install_element (ENABLE_NODE
, &clear_bgp_ipv6_as_cmd
);
9185 install_element (ENABLE_NODE
, &clear_bgp_peer_soft_in_cmd
);
9186 install_element (ENABLE_NODE
, &clear_bgp_ipv6_peer_soft_in_cmd
);
9187 install_element (ENABLE_NODE
, &clear_bgp_peer_in_cmd
);
9188 install_element (ENABLE_NODE
, &clear_bgp_ipv6_peer_in_cmd
);
9189 install_element (ENABLE_NODE
, &clear_bgp_as_soft_in_cmd
);
9190 install_element (ENABLE_NODE
, &clear_bgp_ipv6_as_soft_in_cmd
);
9191 install_element (ENABLE_NODE
, &clear_bgp_as_in_cmd
);
9192 install_element (ENABLE_NODE
, &clear_bgp_ipv6_as_in_cmd
);
9193 install_element (ENABLE_NODE
, &clear_bgp_all_soft_in_cmd
);
9194 install_element (ENABLE_NODE
, &clear_bgp_ipv6_all_soft_in_cmd
);
9195 install_element (ENABLE_NODE
, &clear_bgp_all_in_cmd
);
9196 install_element (ENABLE_NODE
, &clear_bgp_ipv6_all_in_cmd
);
9198 install_element (ENABLE_NODE
, &clear_bgp_peer_soft_out_cmd
);
9199 install_element (ENABLE_NODE
, &clear_bgp_ipv6_peer_soft_out_cmd
);
9200 install_element (ENABLE_NODE
, &clear_bgp_peer_out_cmd
);
9201 install_element (ENABLE_NODE
, &clear_bgp_ipv6_peer_out_cmd
);
9202 install_element (ENABLE_NODE
, &clear_bgp_as_soft_out_cmd
);
9203 install_element (ENABLE_NODE
, &clear_bgp_ipv6_as_soft_out_cmd
);
9204 install_element (ENABLE_NODE
, &clear_bgp_as_out_cmd
);
9205 install_element (ENABLE_NODE
, &clear_bgp_ipv6_as_out_cmd
);
9206 install_element (ENABLE_NODE
, &clear_bgp_all_soft_out_cmd
);
9207 install_element (ENABLE_NODE
, &clear_bgp_ipv6_all_soft_out_cmd
);
9208 install_element (ENABLE_NODE
, &clear_bgp_all_out_cmd
);
9209 install_element (ENABLE_NODE
, &clear_bgp_ipv6_all_out_cmd
);
9211 install_element (ENABLE_NODE
, &clear_bgp_peer_soft_cmd
);
9212 install_element (ENABLE_NODE
, &clear_bgp_ipv6_peer_soft_cmd
);
9213 install_element (ENABLE_NODE
, &clear_bgp_as_soft_cmd
);
9214 install_element (ENABLE_NODE
, &clear_bgp_ipv6_as_soft_cmd
);
9215 install_element (ENABLE_NODE
, &clear_bgp_all_soft_cmd
);
9216 install_element (ENABLE_NODE
, &clear_bgp_ipv6_all_soft_cmd
);
9217 #endif /* HAVE_IPV6 */
9219 /* BGP-MP for IPv4 multicast. */
9220 install_element (BGP_NODE
, &address_family_ipv4_multicast_cmd
);
9221 install_element (BGP_IPV4M_NODE
, &exit_address_family_cmd
);
9223 /* Make global lists. */
9224 bgp_list
= list_new ();
9225 peer_list
= list_new ();
9226 peer_list
->cmp
= (int (*)(void *, void *)) peer_list_cmp
;
9228 /* BGP multiple instance. */
9229 bgp_multiple_instance
= 0;
9239 bgp_route_map_init ();
9242 /* Access list initialize. */
9243 access_list_init ();
9244 access_list_add_hook (bgp_distribute_update
);
9245 access_list_delete_hook (bgp_distribute_update
);
9247 /* Filter list initialize. */
9249 as_list_add_hook (bgp_aslist_update
);
9250 as_list_delete_hook (bgp_aslist_update
);
9252 /* Prefix list initialize.*/
9253 prefix_list_init ();
9254 prefix_list_add_hook (bgp_prefix_list_update
);
9255 prefix_list_delete_hook (bgp_prefix_list_update
);
9257 /* Community list initialize. */
9258 community_list_init ();
9262 #endif /* HAVE_SNMP */
9264 bgp_damp_disable (NULL
);