Mailing List Archive

bgpd: Views & IPv6
Hello! First of all, I'am not sure this is the rigth place to send this, so if
it's not, please let me know.

I'm working with quagga's bgpd and I need to use different views for IPv6
peers. Apparently, the current version of quagga (0.96.2) does not include a
set of "show bgp view ..." commands similar to the existing "show ip bgp
view..." commands. The only commands currently supported are "show bgp view
NAME summary" and "show bgp view NAME ipv6 summary".

As those commands are very necessary for my work, I've developed a patch that
adds the following commands:

- "show bgp view WORD"
- "show bgp view WORD X:X::X:X"
- "show bgp view WORD X:X::X:X/M"
- "show bgp view WORD neighbors"
- "show bgp view WORD neighbors (A.B.C.D.|X:X::X:X)"
- "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes"
- "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes"
- "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes"
- "show bgp view WORD neighbors (A.B.C.D.|X:X::X:X) flap-statistics"
- "show bgp view WORD neighbors (A.B.C.D.|X:X::X:X) dampened-routes"
- "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received prefix-filter"
- "show bgp neighbors (A.B.C.D.|X:X::X:X) flap-statistics"
- "show bgp neighbors (A.B.C.D.|X:X::X:X) dampened-routes"

It also adds ALIAS for the corresponding "show bgp view WORD ipv6 ..."
commands:

- "show bgp view WORD ipv6"
- "show bgp view WORD ipv6 X:X::X:X"
- "show bgp view WORD ipv6 X:X::X:X/M"
...
...
...

The patch only affects the files: "bgpd/bgp_route.c" and "bgpd/bgp_vty.c"

As I said before, I'am not sure if this is the right place for this, but I'd
like to post my patch here so anybody that finds it useful can use it.


Jose Luis

================================================================
--- quagga-0.96.2_original/bgpd/bgp_route.c 2003-08-12 07:32:27.000000000
+0200
+++ quagga-0.96.2/bgpd/bgp_route.c 2003-09-11 11:48:17.000000000 +0200
@@ -5305,6 +5305,70 @@
return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, NULL, 1);
}

+DEFUN (show_bgp_view,
+ show_bgp_view_cmd,
+ "show bgp view WORD",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n")
+{
+ return bgp_show (vty, argv[0], AFI_IP6, SAFI_UNICAST,
bgp_show_type_normal);
+}
+
+ALIAS (show_bgp_view,
+ show_bgp_view_ipv6_cmd,
+ "show bgp view WORD ipv6",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Address family\n")
+
+DEFUN (show_bgp_view_route,
+ show_bgp_view_route_cmd,
+ "show bgp view WORD X:X::X:X",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Network in the BGP routing table to display\n")
+{
+ return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL,
0);
+}
+
+ALIAS (show_bgp_view_route,
+ show_bgp_view_ipv6_route_cmd,
+ "show bgp view WORD ipv6 X:X::X:X",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Address family\n"
+ "Network in the BGP routing table to display\n")
+
+DEFUN (show_bgp_view_prefix,
+ show_bgp_view_prefix_cmd,
+ "show bgp view WORD X:X::X:X/M",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "IPv6 prefix <network>/<length>\n")
+{
+ return bgp_show_route (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, NULL,
1);
+}
+
+ALIAS (show_bgp_view_prefix,
+ show_bgp_view_ipv6_prefix_cmd,
+ "show bgp view WORD ipv6 X:X::X:X/M",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Address family\n"
+ "IPv6 prefix <network>/<length>\n")
+
/* old command */
DEFUN (show_ipv6_mbgp,
show_ipv6_mbgp_cmd,
@@ -7269,9 +7333,21 @@
bgp_show_type_prefix_longer);
}
#endif /* HAVE_IPV6 */
-
+
+/*
+ * This function has been modified for supporting "show bgp view WORD
neighbors ..." commands. A second argument
+ * "struct bgp *bgp" has been added to indicate the view that the show
command refers to.
+ *
+ * The changes only affect to the "bgp_get_default()" call. Now this function
is only called when the second argument
+ * "struct bgp *bgp" is NULL, in any other case the bgp structure received in
the second argument is used. This allows the use of this
+ * function for displaying route information for peers in any view, and not
only in the default view.
+ *
+ * The only call to this function is made from "peer_adj_route(...)" and has
been changed to pass the new argument.
+ *
+ * Also, the local variable "struct bgp *bgp" has been removed, as now the
argument with the same name is used instead.
+ */
void
-show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi,
+show_adj_route (struct vty *vty, struct bgp *bgp, struct peer *peer, afi_t
afi, safi_t safi,
int in)
{
struct bgp_table *table;
@@ -7280,10 +7356,10 @@
unsigned long output_count;
struct bgp_node *rn;
int header1 = 1;
- struct bgp *bgp;
int header2 = 1;

- bgp = bgp_get_default ();
+ if (!bgp)
+ bgp = bgp_get_default ();

if (! bgp)
return;
@@ -7359,20 +7435,48 @@
VTY_NEWLINE, output_count, VTY_NEWLINE);
}

+/*
+ * This function has been modified for supporting "show bgp view WORD
neighbors ..." commands. A second argument
+ * "char *view_name" has been added to indicate the name of the view that the
show command refers to.
+ *
+ * The changes only affect to the "peer_lookup (...)" call. When a view name
is supplied in the second argument,
+ * the function "bgp_lookup_by_name" is used to get the bgp structure
corresponding to that view. If the second
+ * argument is NULL, variable bgp is left NULL and the call to
"peer_lookup(NULL, ...)" is exactly the same as
+ * it was in the previous version of this function.
+ *
+ * The existing calls to this function have been changed using "NULL" as
their second argument. Because when called in
+ * that way, the function is exactly the same as the previous version.
+ */
int
-peer_adj_routes (struct vty *vty, char *ip_str, afi_t afi, safi_t safi, int
in)
+peer_adj_routes (struct vty *vty, char *view_name, char *ip_str, afi_t afi,
safi_t safi, int in)
{
int ret;
struct peer *peer;
+ struct bgp *bgp;
union sockunion su;

+ /* BGP structure lookup. */
+ if (view_name)
+ {
+ bgp = bgp_lookup_by_name (view_name);
+ if (bgp == NULL)
+ {
+ vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+ else
+ {
+ bgp = NULL;
+ }
+
ret = str2sockunion (ip_str, &su);
if (ret < 0)
{
vty_out (vty, "Malformed address: %s%s", ip_str, VTY_NEWLINE);
return CMD_WARNING;
}
- peer = peer_lookup (NULL, &su);
+ peer = peer_lookup (bgp, &su);
if (! peer || ! peer->afc[afi][safi])
{
vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
@@ -7386,7 +7490,7 @@
return CMD_WARNING;
}

- show_adj_route (vty, peer, afi, safi, in);
+ show_adj_route (vty, bgp, peer, afi, safi, in);

return CMD_SUCCESS;
}
@@ -7402,7 +7506,7 @@
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
- return peer_adj_routes (vty, argv[0], AFI_IP, SAFI_UNICAST, 0);
+ return peer_adj_routes (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, 0);
}

DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route,
@@ -7420,9 +7524,9 @@
"Display the routes advertised to a BGP neighbor\n")
{
if (strncmp (argv[0], "m", 1) == 0)
- return peer_adj_routes (vty, argv[1], AFI_IP, SAFI_MULTICAST, 0);
+ return peer_adj_routes (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, 0);

- return peer_adj_routes (vty, argv[1], AFI_IP, SAFI_UNICAST, 0);
+ return peer_adj_routes (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, 0);
}

#ifdef HAVE_IPV6
@@ -7436,7 +7540,7 @@
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
- return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0);
+ return peer_adj_routes (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, 0);
}

ALIAS (show_bgp_neighbor_advertised_route,
@@ -7462,7 +7566,7 @@
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
- return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_UNICAST, 0);
+ return peer_adj_routes (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, 0);
}

/* old command */
@@ -7477,7 +7581,7 @@
"Neighbor to display information about\n"
"Display the routes advertised to a BGP neighbor\n")
{
- return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_MULTICAST, 0);
+ return peer_adj_routes (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, 0);
}
#endif /* HAVE_IPV6 */

@@ -7492,7 +7596,7 @@
"Neighbor to display information about\n"
"Display the received routes from neighbor\n")
{
- return peer_adj_routes (vty, argv[0], AFI_IP, SAFI_UNICAST, 1);
+ return peer_adj_routes (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST, 1);
}

DEFUN (show_ip_bgp_ipv4_neighbor_received_routes,
@@ -7510,9 +7614,9 @@
"Display the received routes from neighbor\n")
{
if (strncmp (argv[0], "m", 1) == 0)
- return peer_adj_routes (vty, argv[1], AFI_IP, SAFI_MULTICAST, 1);
+ return peer_adj_routes (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, 1);

- return peer_adj_routes (vty, argv[1], AFI_IP, SAFI_UNICAST, 1);
+ return peer_adj_routes (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, 1);
}

DEFUN (show_ip_bgp_neighbor_received_prefix_filter,
@@ -7615,7 +7719,7 @@
"Neighbor to display information about\n"
"Display the received routes from neighbor\n")
{
- return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_UNICAST, 1);
+ return peer_adj_routes (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, 1);
}

ALIAS (show_bgp_neighbor_received_routes,
@@ -7688,7 +7792,7 @@
"Neighbor to display information about\n"
"Display the received routes from neighbor\n")
{
- return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_UNICAST, 1);
+ return peer_adj_routes (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, 1);
}

/* old command */
@@ -7703,8 +7807,124 @@
"Neighbor to display information about\n"
"Display the received routes from neighbor\n")
{
- return peer_adj_routes (vty, argv[0], AFI_IP6, SAFI_MULTICAST, 1);
+ return peer_adj_routes (vty, NULL, argv[0], AFI_IP6, SAFI_MULTICAST, 1);
}
+
+DEFUN (show_bgp_view_neighbor_advertised_route,
+ show_bgp_view_neighbor_advertised_route_cmd,
+ "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) advertised-routes",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display the routes advertised to a BGP neighbor\n")
+{
+ return peer_adj_routes (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, 0);
+}
+
+ALIAS (show_bgp_view_neighbor_advertised_route,
+ show_bgp_view_ipv6_neighbor_advertised_route_cmd,
+ "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)
advertised-routes",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display the routes advertised to a BGP neighbor\n")
+
+DEFUN (show_bgp_view_neighbor_received_routes,
+ show_bgp_view_neighbor_received_routes_cmd,
+ "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received-routes",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display the received routes from neighbor\n")
+{
+ return peer_adj_routes (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, 1);
+}
+
+ALIAS (show_bgp_view_neighbor_received_routes,
+ show_bgp_view_ipv6_neighbor_received_routes_cmd,
+ "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)
received-routes",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display the received routes from neighbor\n")
+
+DEFUN (show_bgp_view_neighbor_received_prefix_filter,
+ show_bgp_view_neighbor_received_prefix_filter_cmd,
+ "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) received
prefix-filter",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display information received from a BGP neighbor\n"
+ "Display the prefixlist filter\n")
+{
+ char name[BUFSIZ];
+ union sockunion *su;
+ struct peer *peer;
+ struct bgp *bgp;
+ int count;
+
+ /* BGP structure lookup. */
+ bgp = bgp_lookup_by_name (argv[0]);
+ if (bgp == NULL)
+ {
+ vty_out (vty, "Can't find BGP view %s%s", argv[0], VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+
+ su = sockunion_str2su (argv[1]);
+ if (su == NULL)
+ return CMD_WARNING;
+
+ peer = peer_lookup (bgp, su);
+ if (! peer)
+ return CMD_WARNING;
+
+ sprintf (name, "%s.%d.%d", peer->host, AFI_IP6, SAFI_UNICAST);
+ count = prefix_bgp_show_prefix_list (NULL, AFI_IP6, name);
+ if (count)
+ {
+ vty_out (vty, "Address family: IPv6 Unicast%s", VTY_NEWLINE);
+ prefix_bgp_show_prefix_list (vty, AFI_IP6, name);
+ }
+
+ return CMD_SUCCESS;
+}
+
+ALIAS (show_bgp_view_neighbor_received_prefix_filter,
+ show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd,
+ "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) received
prefix-filter",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display information received from a BGP neighbor\n"
+ "Display the prefixlist filter\n")
#endif /* HAVE_IPV6 */

void
@@ -7716,13 +7936,41 @@
XFREE (MTYPE_SOCKUNION, su);
}

+/*
+ * This function has been modified for supporting "show bgp view WORD
neighbors ..." commands. A second argument
+ * "char *view_name" has been added to indicate the name of the view that the
show command refers to.
+ *
+ * The changes only affect to the "peer_lookup (...)" call. When a view name
is supplied in the second argument,
+ * the function "bgp_lookup_by_name" is used to get the bgp structure
corresponding to that view. If the second
+ * argument is NULL, variable bgp is left NULL and the call to
"peer_lookup(NULL, ...)" is exactly the same as
+ * it was in the previous version of this function.
+ *
+ * The existing calls to this function have been changed using "NULL" as
their second argument. Because when called in
+ * that way, the function is exactly the same as the previous version.
+ */
int
-bgp_show_neighbor_route (struct vty *vty, char *ip_str, afi_t afi,
+bgp_show_neighbor_route (struct vty *vty, char *view_name, char *ip_str,
afi_t afi,
safi_t safi, enum bgp_show_type type)
{
union sockunion *su;
struct peer *peer;
+ struct bgp *bgp;

+ /* BGP structure lookup. */
+ if (view_name)
+ {
+ bgp = bgp_lookup_by_name (view_name);
+ if (bgp == NULL)
+ {
+ vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
+ return CMD_WARNING;
+ }
+ }
+ else
+ {
+ bgp = NULL;
+ }
+
su = sockunion_str2su (ip_str);
if (su == NULL)
{
@@ -7730,7 +7978,7 @@
return CMD_WARNING;
}

- peer = peer_lookup (NULL, su);
+ peer = peer_lookup (bgp, su);
if (! peer || ! peer->afc[afi][safi])
{
vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
@@ -7741,7 +7989,7 @@
vty->output_arg = su;
vty->output_clean = bgp_show_neighbor_route_clean;

- return bgp_show (vty, NULL, afi, safi, type);
+ return bgp_show (vty, view_name, afi, safi, type);
}

DEFUN (show_ip_bgp_neighbor_routes,
@@ -7755,7 +8003,7 @@
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
- return bgp_show_neighbor_route (vty, argv[0], AFI_IP, SAFI_UNICAST,
+ return bgp_show_neighbor_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST,
bgp_show_type_neighbor);
}

@@ -7770,7 +8018,7 @@
"Neighbor to display information about\n"
"Display flap statistics of the routes learned from neighbor\n")
{
- return bgp_show_neighbor_route (vty, argv[0], AFI_IP, SAFI_UNICAST,
+ return bgp_show_neighbor_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST,
bgp_show_type_flap_neighbor);
}

@@ -7785,7 +8033,7 @@
"Neighbor to display information about\n"
"Display the dampened routes received from neighbor\n")
{
- return bgp_show_neighbor_route (vty, argv[0], AFI_IP, SAFI_UNICAST,
+ return bgp_show_neighbor_route (vty, NULL, argv[0], AFI_IP, SAFI_UNICAST,
bgp_show_type_damp_neighbor);
}

@@ -7804,10 +8052,10 @@
"Display routes learned from neighbor\n")
{
if (strncmp (argv[0], "m", 1) == 0)
- return bgp_show_neighbor_route (vty, argv[1], AFI_IP, SAFI_MULTICAST,
+ return bgp_show_neighbor_route (vty, NULL, argv[1], AFI_IP,
SAFI_MULTICAST,
bgp_show_type_neighbor);

- return bgp_show_neighbor_route (vty, argv[1], AFI_IP, SAFI_UNICAST,
+ return bgp_show_neighbor_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST,
bgp_show_type_neighbor);
}
#ifdef HAVE_IPV6
@@ -7821,7 +8069,7 @@
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
- return bgp_show_neighbor_route (vty, argv[0], AFI_IP6, SAFI_UNICAST,
+ return bgp_show_neighbor_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST,
bgp_show_type_neighbor);
}

@@ -7848,7 +8096,7 @@
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
- return bgp_show_neighbor_route (vty, argv[0], AFI_IP6, SAFI_UNICAST,
+ return bgp_show_neighbor_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST,
bgp_show_type_neighbor);
}

@@ -7864,9 +8112,146 @@
"Neighbor to display information about\n"
"Display routes learned from neighbor\n")
{
- return bgp_show_neighbor_route (vty, argv[0], AFI_IP6, SAFI_MULTICAST,
+ return bgp_show_neighbor_route (vty, NULL, argv[0], AFI_IP6,
SAFI_MULTICAST,
bgp_show_type_neighbor);
}
+
+DEFUN (show_bgp_neighbor_flap,
+ show_bgp_neighbor_flap_cmd,
+ "show bgp neighbors (A.B.C.D|X:X::X:X) flap-statistics",
+ SHOW_STR
+ BGP_STR
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display flap statistics of the routes learned from neighbor\n")
+{
+ return bgp_show_neighbor_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST,
+ bgp_show_type_flap_neighbor);
+}
+
+ALIAS (show_bgp_neighbor_flap,
+ show_bgp_ipv6_neighbor_flap_cmd,
+ "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) flap-statistics",
+ SHOW_STR
+ BGP_STR
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display flap statistics of the routes learned from neighbor\n")
+
+DEFUN (show_bgp_neighbor_damp,
+ show_bgp_neighbor_damp_cmd,
+ "show bgp neighbors (A.B.C.D|X:X::X:X) dampened-routes",
+ SHOW_STR
+ BGP_STR
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display the dampened routes received from neighbor\n")
+{
+ return bgp_show_neighbor_route (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST,
+ bgp_show_type_damp_neighbor);
+}
+
+ALIAS (show_bgp_neighbor_damp,
+ show_bgp_ipv6_neighbor_damp_cmd,
+ "show bgp ipv6 neighbors (A.B.C.D|X:X::X:X) dampened-routes",
+ SHOW_STR
+ BGP_STR
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display the dampened routes received from neighbor\n")
+
+DEFUN (show_bgp_view_neighbor_routes,
+ show_bgp_view_neighbor_routes_cmd,
+ "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) routes",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "BGP view name\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display routes learned from neighbor\n")
+{
+ return bgp_show_neighbor_route (vty, argv[0], argv[1], AFI_IP6,
SAFI_UNICAST,
+ bgp_show_type_neighbor);
+}
+
+ALIAS (show_bgp_view_neighbor_routes,
+ show_bgp_view_ipv6_neighbor_routes_cmd,
+ "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X) routes",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "BGP view name\n"
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display routes learned from neighbor\n")
+
+DEFUN (show_bgp_view_neighbor_damp,
+ show_bgp_view_neighbor_damp_cmd,
+ "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) dampened-routes",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "BGP view name\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display the dampened routes received from neighbor\n")
+{
+ return bgp_show_neighbor_route (vty, argv[0], argv[1], AFI_IP6,
SAFI_UNICAST,
+ bgp_show_type_damp_neighbor);
+}
+
+ALIAS (show_bgp_view_neighbor_damp,
+ show_bgp_view_ipv6_neighbor_damp_cmd,
+ "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)
dampened-routes",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "BGP view name\n"
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display the dampened routes received from neighbor\n")
+
+DEFUN (show_bgp_view_neighbor_flap,
+ show_bgp_view_neighbor_flap_cmd,
+ "show bgp view WORD neighbors (A.B.C.D|X:X::X:X) flap-statistics",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "BGP view name\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display flap statistics of the routes learned from neighbor\n")
+{
+ return bgp_show_neighbor_route (vty, argv[0], argv[1], AFI_IP6,
SAFI_UNICAST,
+ bgp_show_type_flap_neighbor);
+}
+
+ALIAS (show_bgp_view_neighbor_flap,
+ show_bgp_view_ipv6_neighbor_flap_cmd,
+ "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)
flap-statistics",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "BGP view name\n"
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n"
+ "Display flap statistics of the routes learned from neighbor\n")
#endif /* HAVE_IPV6 */

struct bgp_table *bgp_distance_table;
@@ -8905,6 +9290,28 @@
install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
install_element (VIEW_NODE, &show_bgp_neighbor_received_prefix_filter_cmd);
install_element (VIEW_NODE,
&show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
+ install_element (VIEW_NODE, &show_bgp_neighbor_flap_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
+ install_element (VIEW_NODE, &show_bgp_neighbor_damp_cmd);
+ install_element (VIEW_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_ipv6_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_route_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_ipv6_route_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_prefix_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_ipv6_prefix_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_neighbor_advertised_route_cmd);
+ install_element (VIEW_NODE,
&show_bgp_view_ipv6_neighbor_advertised_route_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_neighbor_received_routes_cmd);
+ install_element (VIEW_NODE,
&show_bgp_view_ipv6_neighbor_received_routes_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_neighbor_routes_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
+ install_element (VIEW_NODE,
&show_bgp_view_neighbor_received_prefix_filter_cmd);
+ install_element (VIEW_NODE,
&show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_neighbor_flap_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_neighbor_damp_cmd);
+ install_element (VIEW_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);

install_element (ENABLE_NODE, &show_bgp_cmd);
install_element (ENABLE_NODE, &show_bgp_ipv6_cmd);
@@ -8952,6 +9359,28 @@
install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_routes_cmd);
install_element (ENABLE_NODE,
&show_bgp_neighbor_received_prefix_filter_cmd);
install_element (ENABLE_NODE,
&show_bgp_ipv6_neighbor_received_prefix_filter_cmd);
+ install_element (ENABLE_NODE, &show_bgp_neighbor_flap_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_flap_cmd);
+ install_element (ENABLE_NODE, &show_bgp_neighbor_damp_cmd);
+ install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_damp_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_ipv6_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_route_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_ipv6_route_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_prefix_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_ipv6_prefix_cmd);
+ install_element (ENABLE_NODE,
&show_bgp_view_neighbor_advertised_route_cmd);
+ install_element (ENABLE_NODE,
&show_bgp_view_ipv6_neighbor_advertised_route_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_neighbor_received_routes_cmd);
+ install_element (ENABLE_NODE,
&show_bgp_view_ipv6_neighbor_received_routes_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_neighbor_routes_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_routes_cmd);
+ install_element (ENABLE_NODE,
&show_bgp_view_neighbor_received_prefix_filter_cmd);
+ install_element (ENABLE_NODE,
&show_bgp_view_ipv6_neighbor_received_prefix_filter_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_neighbor_flap_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_flap_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_neighbor_damp_cmd);
+ install_element (ENABLE_NODE, &show_bgp_view_ipv6_neighbor_damp_cmd);

/* old command */
install_element (VIEW_NODE, &show_ipv6_bgp_cmd);
@@ -8990,7 +9419,7 @@
install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_cmd);
install_element (VIEW_NODE, &show_ipv6_mbgp_community_list_exact_cmd);
install_element (VIEW_NODE, &show_ipv6_mbgp_prefix_longer_cmd);
-
+
/* old command */
install_element (ENABLE_NODE, &show_ipv6_bgp_cmd);
install_element (ENABLE_NODE, &show_ipv6_bgp_route_cmd);
--- quagga-0.96.2_original/bgpd/bgp_vty.c 2003-08-13 02:32:50.000000000 +0200
+++ quagga-0.96.2/bgpd/bgp_vty.c 2003-09-11 11:04:01.000000000 +0200
@@ -6973,6 +6973,25 @@
return bgp_show_neighbor_vty (vty, argv[0], show_all, NULL);
}

+ALIAS (show_ip_bgp_instance_neighbors,
+ show_bgp_instance_neighbors_cmd,
+ "show bgp view WORD neighbors",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Detailed information on TCP and BGP neighbor connections\n")
+
+ALIAS (show_ip_bgp_instance_neighbors,
+ show_bgp_instance_ipv6_neighbors_cmd,
+ "show bgp view WORD ipv6 neighbors",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n")
+
DEFUN (show_ip_bgp_instance_neighbors_peer,
show_ip_bgp_instance_neighbors_peer_cmd,
"show ip bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
@@ -6987,7 +7006,30 @@
{
return bgp_show_neighbor_vty (vty, argv[0], show_peer, argv[1]);
}
-
+
+ALIAS (show_ip_bgp_instance_neighbors_peer,
+ show_bgp_instance_neighbors_peer_cmd,
+ "show bgp view WORD neighbors (A.B.C.D|X:X::X:X)",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n")
+
+ALIAS (show_ip_bgp_instance_neighbors_peer,
+ show_bgp_instance_ipv6_neighbors_peer_cmd,
+ "show bgp view WORD ipv6 neighbors (A.B.C.D|X:X::X:X)",
+ SHOW_STR
+ BGP_STR
+ "BGP view\n"
+ "View name\n"
+ "Address family\n"
+ "Detailed information on TCP and BGP neighbor connections\n"
+ "Neighbor to display information about\n"
+ "Neighbor to display information about\n")
+
/* Show BGP's AS paths internal data. There are both `show ip bgp
paths' and `show ip mbgp paths'. Those functions results are the
same.*/
@@ -8502,10 +8544,18 @@
install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_cmd);
install_element (VIEW_NODE, &show_bgp_neighbors_peer_cmd);
install_element (VIEW_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
+ install_element (VIEW_NODE, &show_bgp_instance_neighbors_cmd);
+ install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
+ install_element (VIEW_NODE, &show_bgp_instance_neighbors_peer_cmd);
+ install_element (VIEW_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);
install_element (ENABLE_NODE, &show_bgp_neighbors_cmd);
install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_cmd);
install_element (ENABLE_NODE, &show_bgp_neighbors_peer_cmd);
install_element (ENABLE_NODE, &show_bgp_ipv6_neighbors_peer_cmd);
+ install_element (ENABLE_NODE, &show_bgp_instance_neighbors_cmd);
+ install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_cmd);
+ install_element (ENABLE_NODE, &show_bgp_instance_neighbors_peer_cmd);
+ install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbors_peer_cmd);

/* Old commands. */
install_element (VIEW_NODE, &show_ipv6_bgp_summary_cmd);
Re: bgpd: Views & IPv6 [ In reply to ]
Jose Luis Rubio Guivernau wrote:
> Hello! First of all, I'am not sure this is the rigth place to send
> this, so if it's not, please let me know.

This is perfectly right place for patches :).


--
Hasso Tepper
Elion Enterprises Ltd.
WAN administrator
Re: bgpd: Views & IPv6 [ In reply to ]
Hi Jose,

Missed this patch till now. Sorry.

On Thu, 11 Sep 2003, Jose Luis Rubio Guivernau wrote:

> Hello! First of all, I'am not sure this is the rigth place to send
> this, so if it's not, please let me know.
>
> I'm working with quagga's bgpd and I need to use different views
> for IPv6 peers. Apparently, the current version of quagga (0.96.2)
> does not include a set of "show bgp view ..." commands similar to
> the existing "show ip bgp view..." commands. The only commands
> currently supported are "show bgp view NAME summary" and "show bgp
> view NAME ipv6 summary".
>
> As those commands are very necessary for my work, I've developed a
> patch that adds the following commands:

[snip]

makes sense.

> The patch only affects the files: "bgpd/bgp_route.c" and "bgpd/bgp_vty.c"
>
> As I said before, I'am not sure if this is the right place for this, but I'd
> like to post my patch here so anybody that finds it useful can use it.

sure, looks grand except for one thing.

> Jose Luis

> +/*
> + * This function has been modified for supporting "show bgp view WORD
> neighbors ..." commands. A second argument
> + * "struct bgp *bgp" has been added to indicate the view that the show
> command refers to.
> + *
> + * The changes only affect to the "bgp_get_default()" call. Now this function
> is only called when the second argument
> + * "struct bgp *bgp" is NULL, in any other case the bgp structure received in
> the second argument is used. This allows the use of this
> + * function for displaying route information for peers in any view, and not
> only in the default view.
> + *
> + * The only call to this function is made from "peer_adj_route(...)" and has
> been changed to pass the new argument.
> + *
> + * Also, the local variable "struct bgp *bgp" has been removed, as now the
> argument with the same name is used instead.
> + */

comments are generally good, but the above is excessive, at least for
commiting to CVS :)

> int
> -peer_adj_routes (struct vty *vty, char *ip_str, afi_t afi, safi_t safi, int
> in)
> +peer_adj_routes (struct vty *vty, char *view_name, char *ip_str, afi_t afi,
> safi_t safi, int in)
> {
> int ret;
> struct peer *peer;
> + struct bgp *bgp;
> union sockunion su;
>
> + /* BGP structure lookup. */
> + if (view_name)
> + {
> + bgp = bgp_lookup_by_name (view_name);
> + if (bgp == NULL)
> + {
> + vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
> + return CMD_WARNING;
> + }
> + }
> + else
> + {
> + bgp = NULL;
> + }
> +

> - peer = peer_lookup (NULL, &su);
> + peer = peer_lookup (bgp, &su);

hmm... could we move the bgp and peer discovery to a helper function
perhaps? then use it in the /commands/ and let peer_adj_routes take a
struct peer * as argument, not a char *view_name.

you could in theory also make the non-view versions of each type of
commands be aliases to the view version, would clean stuff up.

regards,
--
Paul Jakma paul@clubi.ie paul@jakma.org Key ID: 64A2FF6A
warning: do not ever send email to spam@dishone.st
Fortune:
Serfs up!
-- Spartacus
Re: bgpd: Views & IPv6 [ In reply to ]
Hi Paul,

El Sáb 18 Oct 2003 22:03, Paul Jakma escribió:
> Missed this patch till now. Sorry.

Never mind :)

> comments are generally good, but the above is excessive, at least for
> commiting to CVS :)

It's true, they are too long :), I will remove them.

> > int
> > -peer_adj_routes (struct vty *vty, char *ip_str, afi_t afi, safi_t safi,
> > int in)
> > +peer_adj_routes (struct vty *vty, char *view_name, char *ip_str, afi_t
> > afi, safi_t safi, int in)
> > {
> > int ret;
> > struct peer *peer;
> > + struct bgp *bgp;
> > union sockunion su;
> >
> > + /* BGP structure lookup. */
> > + if (view_name)
> > + {
> > + bgp = bgp_lookup_by_name (view_name);
> > + if (bgp == NULL)
> > + {
> > + vty_out (vty, "Can't find BGP view %s%s", view_name, VTY_NEWLINE);
> > + return CMD_WARNING;
> > + }
> > + }
> > + else
> > + {
> > + bgp = NULL;
> > + }
> > +
> >
> > - peer = peer_lookup (NULL, &su);
> > + peer = peer_lookup (bgp, &su);
>
> hmm... could we move the bgp and peer discovery to a helper function
> perhaps? then use it in the /commands/ and let peer_adj_routes take a
> struct peer * as argument, not a char *view_name.

Ok, it's cleaner to create a helper function.
But anyway peer_adj_routes should take struct bgp* as an argument, because it
needs it for calling:
show_adj_route (vty, bgp, peer, afi, safi, in);

Perhaps peer_adj_routes could take struct bgp* & struct peer* instead of char
*view_name & char *ip_str.

> you could in theory also make the non-view versions of each type of
> commands be aliases to the view version, would clean stuff up.

You mean something like this:

DEFUN (show_bgp_view_neighbor_advertised_route,
show_bgp_view_neighbor_advertised_route_cmd,
...)
{
if (argc == 2)
return peer_adj_routes (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, 0);
else
return peer_adj_routes (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, 0);
}

ALIAS (show_bgp_view_neighbor_advertised_route,
show_bgp_neighbor_advertised_route_cmd,
...)

I don't like very much the "if(argc == 2) / else" clause, but I don't know how
to avoid it if we want the non-view version to work as an alias of the
view-version. Any ideas?

Jose Luis
Re: bgpd: Views & IPv6 [ In reply to ]
On Tue, 21 Oct 2003, Jose Luis Rubio wrote:

> Ok, it's cleaner to create a helper function.

yes, that was implied in a way.

> But anyway peer_adj_routes should take struct bgp* as an argument, because it
> needs it for calling:

no, unneccessary. see (struct peer).bgp :)

> show_adj_route (vty, bgp, peer, afi, safi, in);

ie

show_adj_route (vty, peer->bgp, peer, afi, safi, in);

however, thats a bit silly too, cause the same argument holds for
show_adj_route - it shouldnt need a struct bgp * argument - it can
find it from the struct peer.

(unless it does more than just examine that struct in that view) -
can you investigate, and unless there's a good reason, remove the
struct bgp argument from show_adj_route() too.

> Perhaps peer_adj_routes could take struct bgp* & struct peer*
> instead of char *view_name & char *ip_str.

AIUI struct peer * is enough - the very first field of struct peer is
a pointer to the struct bgp which that struct peer belongs to.

> > you could in theory also make the non-view versions of each type of
> > commands be aliases to the view version, would clean stuff up.
>
> You mean something like this:
>
> DEFUN (show_bgp_view_neighbor_advertised_route,
> show_bgp_view_neighbor_advertised_route_cmd,
> ...)
> {
> if (argc == 2)
> return peer_adj_routes (vty, argv[0], argv[1], AFI_IP6, SAFI_UNICAST, 0);
> else
> return peer_adj_routes (vty, NULL, argv[0], AFI_IP6, SAFI_UNICAST, 0);
> }
>
> ALIAS (show_bgp_view_neighbor_advertised_route,
> show_bgp_neighbor_advertised_route_cmd,
> ...)
>
> I don't like very much the "if(argc == 2) / else" clause,

why? whats wrong with it? :)

> but I don't know how to avoid it if we want the non-view version to
> work as an alias of the view-version. Any ideas?

the above seems fine.

>
> Jose Luis

regards,
--
Paul Jakma paul@clubi.ie paul@jakma.org Key ID: 64A2FF6A
warning: do not ever send email to spam@dishone.st
Fortune:
Chemist who falls in acid will be tripping for weeks.
Re: bgpd: Views & IPv6 [ In reply to ]
Hi Paul,

I have modified the patch like you suggested, this are the main changes:

- Created the helper function "peer_lookup_in_view", which takes "char
*view_name" and "char *ip_str" for arguments and returns "struct peer *" if
everything is ok. If something goes wrong it prints an error message (it also
takes "struct vty *vty" for argument) and then it returns NULL, so that
whoever called it knows that something went wrong.

- Now "peer_adj_routes" and "show_adj_routes" take "struct peer *peer" for
argument, and no longer char *view_name & char *ip_str.

- "bgp_show_neighbor_route" now takes "struct peer *peer" instead of "char
*ip_str"

- "bgp_show" now takes "struct bgp *bgp" instead of "char *view_name"

- All the calls to "peer_adj_routes", "bgp_show_neighbor_route" and "bgp_show"
have been changed, using the helper function "peer_lookup_in_view" when
necessary.

- Some commands have been redefined as ALIAS of their corresponding view
versions.

Should I change anything else?

regards,

Jose Luis
Re: bgpd: Views & IPv6 [ In reply to ]
On Fri, 24 Oct 2003, Jose Luis Rubio wrote:

> Hi Paul,
>
> I have modified the patch like you suggested, this are the main changes:
>
> - Created the helper function "peer_lookup_in_view", which takes "char
> *view_name" and "char *ip_str" for arguments and returns "struct peer *" if
> everything is ok. If something goes wrong it prints an error message (it also
> takes "struct vty *vty" for argument) and then it returns NULL, so that
> whoever called it knows that something went wrong.
>
> - Now "peer_adj_routes" and "show_adj_routes" take "struct peer *peer" for
> argument, and no longer char *view_name & char *ip_str.
>
> - "bgp_show_neighbor_route" now takes "struct peer *peer" instead of "char
> *ip_str"
>
> - "bgp_show" now takes "struct bgp *bgp" instead of "char *view_name"
>
> - All the calls to "peer_adj_routes", "bgp_show_neighbor_route" and "bgp_show"
> have been changed, using the helper function "peer_lookup_in_view" when
> necessary.
>
> - Some commands have been redefined as ALIAS of their corresponding view
> versions.
>
> Should I change anything else?

No. I think thats perfect. Thanks!

>
> regards,
>
> Jose Luis

regards,
--
Paul Jakma paul@clubi.ie paul@jakma.org Key ID: 64A2FF6A
warning: do not ever send email to spam@dishone.st
Fortune:
I'm going to give my psychoanalyst one more year, then I'm going to Lourdes.
-- Woody Allen