mirror of
				https://git.proxmox.com/git/mirror_frr
				synced 2025-11-04 11:45:06 +00:00 
			
		
		
		
	bgpd: remove encap safi show commands
Signed-off-by: Lou Berger <lberger@labn.net>
This commit is contained in:
		
							parent
							
								
									3c6ba3ec02
								
							
						
					
					
						commit
						33c0d63f9c
					
				
							
								
								
									
										526
									
								
								bgpd/bgp_encap.c
									
									
									
									
									
								
							
							
						
						
									
										526
									
								
								bgpd/bgp_encap.c
									
									
									
									
									
								
							@ -202,533 +202,7 @@ bgp_nlri_parse_encap(
 | 
			
		||||
  return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int
 | 
			
		||||
show_adj_route_encap (struct vty *vty, struct peer *peer, struct prefix_rd *prd)
 | 
			
		||||
{
 | 
			
		||||
  struct bgp *bgp;
 | 
			
		||||
  struct bgp_table *table;
 | 
			
		||||
  struct bgp_node *rn;
 | 
			
		||||
  struct bgp_node *rm;
 | 
			
		||||
  struct attr *attr;
 | 
			
		||||
  int rd_header;
 | 
			
		||||
  int header = 1;
 | 
			
		||||
  char v4_header[] = "   Network          Next Hop            Metric LocPrf Weight Path%s";
 | 
			
		||||
 | 
			
		||||
  bgp = bgp_get_default ();
 | 
			
		||||
  if (bgp == NULL)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_ENCAP]); rn;
 | 
			
		||||
       rn = bgp_route_next (rn))
 | 
			
		||||
    {
 | 
			
		||||
      if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
 | 
			
		||||
        continue;
 | 
			
		||||
 | 
			
		||||
      if ((table = rn->info) != NULL)
 | 
			
		||||
        {
 | 
			
		||||
          rd_header = 1;
 | 
			
		||||
 | 
			
		||||
          for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
 | 
			
		||||
            if ((attr = rm->info) != NULL)
 | 
			
		||||
              {
 | 
			
		||||
                if (header)
 | 
			
		||||
                  {
 | 
			
		||||
                    vty_out (vty, "BGP table version is 0, local router ID is %s%s",
 | 
			
		||||
                             inet_ntoa (bgp->router_id), VTY_NEWLINE);
 | 
			
		||||
                    vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
 | 
			
		||||
                             VTY_NEWLINE);
 | 
			
		||||
                    vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
 | 
			
		||||
                             VTY_NEWLINE, VTY_NEWLINE);
 | 
			
		||||
                    vty_out (vty, v4_header, VTY_NEWLINE);
 | 
			
		||||
                    header = 0;
 | 
			
		||||
                  }
 | 
			
		||||
 | 
			
		||||
                if (rd_header)
 | 
			
		||||
                  {
 | 
			
		||||
                    u_int16_t type;
 | 
			
		||||
                    struct rd_as rd_as;
 | 
			
		||||
                    struct rd_ip rd_ip;
 | 
			
		||||
                    u_char *pnt;
 | 
			
		||||
 | 
			
		||||
                    pnt = rn->p.u.val;
 | 
			
		||||
 | 
			
		||||
                    vty_out (vty, "Route Distinguisher: ");
 | 
			
		||||
 | 
			
		||||
                    /* Decode RD type. */
 | 
			
		||||
                    type = decode_rd_type (pnt);
 | 
			
		||||
 | 
			
		||||
		    switch (type) {
 | 
			
		||||
 | 
			
		||||
		    case RD_TYPE_AS:
 | 
			
		||||
                      decode_rd_as (pnt + 2, &rd_as);
 | 
			
		||||
                      vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
 | 
			
		||||
		      break;
 | 
			
		||||
 | 
			
		||||
		    case RD_TYPE_IP:
 | 
			
		||||
                      decode_rd_ip (pnt + 2, &rd_ip);
 | 
			
		||||
                      vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
 | 
			
		||||
		      break;
 | 
			
		||||
 | 
			
		||||
		    default:
 | 
			
		||||
                      vty_out (vty, "unknown RD type");
 | 
			
		||||
		    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
                    vty_out (vty, "%s", VTY_NEWLINE);
 | 
			
		||||
                    rd_header = 0;
 | 
			
		||||
                  }
 | 
			
		||||
                route_vty_out_tmp (vty, &rm->p, attr, SAFI_ENCAP, 0, NULL);
 | 
			
		||||
              }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
  return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int
 | 
			
		||||
bgp_show_encap (
 | 
			
		||||
    struct vty *vty,
 | 
			
		||||
    afi_t afi,
 | 
			
		||||
    struct prefix_rd *prd,
 | 
			
		||||
    enum bgp_show_type type,
 | 
			
		||||
    void *output_arg,
 | 
			
		||||
    int tags)
 | 
			
		||||
{
 | 
			
		||||
  struct bgp *bgp;
 | 
			
		||||
  struct bgp_table *table;
 | 
			
		||||
  struct bgp_node *rn;
 | 
			
		||||
  struct bgp_node *rm;
 | 
			
		||||
  struct bgp_info *ri;
 | 
			
		||||
  int rd_header;
 | 
			
		||||
  int header = 1;
 | 
			
		||||
  char v4_header[] = "   Network          Next Hop            Metric LocPrf Weight Path%s";
 | 
			
		||||
  char v4_header_tag[] = "   Network          Next Hop      In tag/Out tag%s";
 | 
			
		||||
 | 
			
		||||
  unsigned long output_count = 0;
 | 
			
		||||
  unsigned long total_count  = 0;
 | 
			
		||||
 | 
			
		||||
  bgp = bgp_get_default ();
 | 
			
		||||
  if (bgp == NULL)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "No BGP process is configured%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if ((afi != AFI_IP) && (afi != AFI_IP6)) {
 | 
			
		||||
      vty_out (vty, "Afi %d not supported%s", afi, VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  for (rn = bgp_table_top (bgp->rib[afi][SAFI_ENCAP]); rn; rn = bgp_route_next (rn))
 | 
			
		||||
    {
 | 
			
		||||
      if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0)
 | 
			
		||||
	continue;
 | 
			
		||||
 | 
			
		||||
      if ((table = rn->info) != NULL)
 | 
			
		||||
	{
 | 
			
		||||
	  rd_header = 1;
 | 
			
		||||
 | 
			
		||||
	  for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
 | 
			
		||||
	    for (ri = rm->info; ri; ri = ri->next)
 | 
			
		||||
	      {
 | 
			
		||||
                total_count++;
 | 
			
		||||
		if (type == bgp_show_type_neighbor)
 | 
			
		||||
		  {
 | 
			
		||||
		    union sockunion *su = output_arg;
 | 
			
		||||
 | 
			
		||||
		    if (ri->peer->su_remote == NULL || ! sockunion_same(ri->peer->su_remote, su))
 | 
			
		||||
		      continue;
 | 
			
		||||
		  }
 | 
			
		||||
		if (header)
 | 
			
		||||
		  {
 | 
			
		||||
		    if (tags)
 | 
			
		||||
		      vty_out (vty, v4_header_tag, VTY_NEWLINE);
 | 
			
		||||
		    else
 | 
			
		||||
		      {
 | 
			
		||||
			vty_out (vty, "BGP table version is 0, local router ID is %s%s",
 | 
			
		||||
				 inet_ntoa (bgp->router_id), VTY_NEWLINE);
 | 
			
		||||
			vty_out (vty, "Status codes: s suppressed, d damped, h history, * valid, > best, i - internal%s",
 | 
			
		||||
				 VTY_NEWLINE);
 | 
			
		||||
			vty_out (vty, "Origin codes: i - IGP, e - EGP, ? - incomplete%s%s",
 | 
			
		||||
				 VTY_NEWLINE, VTY_NEWLINE);
 | 
			
		||||
			vty_out (vty, v4_header, VTY_NEWLINE);
 | 
			
		||||
		      }
 | 
			
		||||
		    header = 0;
 | 
			
		||||
		  }
 | 
			
		||||
 | 
			
		||||
		if (rd_header)
 | 
			
		||||
		  {
 | 
			
		||||
		    u_int16_t type;
 | 
			
		||||
		    struct rd_as rd_as;
 | 
			
		||||
		    struct rd_ip rd_ip;
 | 
			
		||||
		    u_char *pnt;
 | 
			
		||||
 | 
			
		||||
		    pnt = rn->p.u.val;
 | 
			
		||||
 | 
			
		||||
		    /* Decode RD type. */
 | 
			
		||||
		    type = decode_rd_type (pnt);
 | 
			
		||||
 | 
			
		||||
		    vty_out (vty, "Route Distinguisher: ");
 | 
			
		||||
 | 
			
		||||
		    switch (type) {
 | 
			
		||||
 | 
			
		||||
		    case RD_TYPE_AS:
 | 
			
		||||
		      decode_rd_as (pnt + 2, &rd_as);
 | 
			
		||||
		      vty_out (vty, "%u:%d", rd_as.as, rd_as.val);
 | 
			
		||||
		      break;
 | 
			
		||||
 | 
			
		||||
		    case RD_TYPE_IP:
 | 
			
		||||
		      decode_rd_ip (pnt + 2, &rd_ip);
 | 
			
		||||
		      vty_out (vty, "%s:%d", inet_ntoa (rd_ip.ip), rd_ip.val);
 | 
			
		||||
		      break;
 | 
			
		||||
 | 
			
		||||
		    default:
 | 
			
		||||
		      vty_out (vty, "Unknown RD type");
 | 
			
		||||
		      break;
 | 
			
		||||
		    }
 | 
			
		||||
 | 
			
		||||
		    vty_out (vty, "%s", VTY_NEWLINE);		  
 | 
			
		||||
		    rd_header = 0;
 | 
			
		||||
		  }
 | 
			
		||||
	        if (tags)
 | 
			
		||||
		  route_vty_out_tag (vty, &rm->p, ri, 0, SAFI_ENCAP, NULL);
 | 
			
		||||
	        else
 | 
			
		||||
		  route_vty_out (vty, &rm->p, ri, 0, SAFI_ENCAP, NULL);
 | 
			
		||||
                output_count++;
 | 
			
		||||
	      }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (output_count == 0)
 | 
			
		||||
    {
 | 
			
		||||
        vty_out (vty, "No prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE);
 | 
			
		||||
    }
 | 
			
		||||
  else
 | 
			
		||||
    vty_out (vty, "%sDisplayed %ld routes and %ld total paths%s",
 | 
			
		||||
	     VTY_NEWLINE, output_count, total_count, VTY_NEWLINE);
 | 
			
		||||
 | 
			
		||||
  return CMD_SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv4_encap_rd,
 | 
			
		||||
       show_bgp_ipv4_encap_rd_cmd,
 | 
			
		||||
       "show [ip] bgp ipv4 encap rd ASN:nn_or_IP-address:nn",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display information for a route distinguisher\n"
 | 
			
		||||
       "ENCAP Route Distinguisher\n")
 | 
			
		||||
{
 | 
			
		||||
  int idx_rd = 5;
 | 
			
		||||
  int ret;
 | 
			
		||||
  struct prefix_rd prd;
 | 
			
		||||
 | 
			
		||||
  ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
 | 
			
		||||
  if (! ret)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
  return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv6_encap_rd,
 | 
			
		||||
       show_bgp_ipv6_encap_rd_cmd,
 | 
			
		||||
       "show [ip] bgp ipv6 encap rd ASN:nn_or_IP-address:nn",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display information for a route distinguisher\n"
 | 
			
		||||
       "ENCAP Route Distinguisher\n"
 | 
			
		||||
       "Display BGP tags for prefixes\n")
 | 
			
		||||
{
 | 
			
		||||
  int idx_rd = 5;
 | 
			
		||||
  int ret;
 | 
			
		||||
  struct prefix_rd prd;
 | 
			
		||||
 | 
			
		||||
  ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
 | 
			
		||||
  if (! ret)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
  return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv4_encap_tags,
 | 
			
		||||
       show_bgp_ipv4_encap_tags_cmd,
 | 
			
		||||
       "show [ip] bgp ipv4 encap tags",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display BGP tags for prefixes\n")
 | 
			
		||||
{
 | 
			
		||||
  return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_normal, NULL,  1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv6_encap_tags,
 | 
			
		||||
       show_bgp_ipv6_encap_tags_cmd,
 | 
			
		||||
       "show [ip] bgp ipv6 encap tags",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display BGP tags for prefixes\n")
 | 
			
		||||
{
 | 
			
		||||
  return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL,  1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv4_encap_rd_tags,
 | 
			
		||||
       show_bgp_ipv4_encap_rd_tags_cmd,
 | 
			
		||||
       "show [ip] bgp ipv4 encap rd ASN:nn_or_IP-address:nn tags",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display information for a route distinguisher\n"
 | 
			
		||||
       "ENCAP Route Distinguisher\n"
 | 
			
		||||
       "Display BGP tags for prefixes\n")
 | 
			
		||||
{
 | 
			
		||||
  int idx_rd = 5;
 | 
			
		||||
  int ret;
 | 
			
		||||
  struct prefix_rd prd;
 | 
			
		||||
 | 
			
		||||
  ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
 | 
			
		||||
  if (! ret)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
  return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv6_encap_rd_tags,
 | 
			
		||||
       show_bgp_ipv6_encap_rd_tags_cmd,
 | 
			
		||||
       "show [ip] bgp ipv6 encap rd ASN:nn_or_IP-address:nn tags",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display information for a route distinguisher\n"
 | 
			
		||||
       "ENCAP Route Distinguisher\n"
 | 
			
		||||
       "Display BGP tags for prefixes\n")
 | 
			
		||||
{
 | 
			
		||||
  int idx_rd = 5;
 | 
			
		||||
  int ret;
 | 
			
		||||
  struct prefix_rd prd;
 | 
			
		||||
 | 
			
		||||
  ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
 | 
			
		||||
  if (! ret)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
  return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes,
 | 
			
		||||
       show_bgp_ipv4_encap_rd_neighbor_routes_cmd,
 | 
			
		||||
       "show [ip] bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> routes",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display information for a route distinguisher\n"
 | 
			
		||||
       "ENCAP Route Distinguisher\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")
 | 
			
		||||
{
 | 
			
		||||
  int idx_rd = 5;
 | 
			
		||||
  int idx_peer = 7;
 | 
			
		||||
  int ret;
 | 
			
		||||
  union sockunion su;
 | 
			
		||||
  struct peer *peer;
 | 
			
		||||
  struct prefix_rd prd;
 | 
			
		||||
 | 
			
		||||
  ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
 | 
			
		||||
  if (! ret)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (str2sockunion(argv[idx_peer]->arg, &su))
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
 | 
			
		||||
               return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  peer = peer_lookup (NULL, &su);
 | 
			
		||||
  if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes,
 | 
			
		||||
       show_bgp_ipv6_encap_rd_neighbor_routes_cmd,
 | 
			
		||||
       "show [ip] bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> routes",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display information for a route distinguisher\n"
 | 
			
		||||
       "ENCAP Route Distinguisher\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")
 | 
			
		||||
{
 | 
			
		||||
  int idx_rd = 5;
 | 
			
		||||
  int idx_peer = 7;
 | 
			
		||||
  int ret;
 | 
			
		||||
  union sockunion su;
 | 
			
		||||
  struct peer *peer;
 | 
			
		||||
  struct prefix_rd prd;
 | 
			
		||||
 | 
			
		||||
  ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
 | 
			
		||||
  if (! ret)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  if (str2sockunion(argv[idx_peer]->arg, &su))
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
 | 
			
		||||
               return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  peer = peer_lookup (NULL, &su);
 | 
			
		||||
  if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP])
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_neighbor, &su, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes,
 | 
			
		||||
       show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd,
 | 
			
		||||
       "show [ip] bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> advertised-routes",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display information for a route distinguisher\n"
 | 
			
		||||
       "ENCAP Route Distinguisher\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")
 | 
			
		||||
{
 | 
			
		||||
  int idx_rd = 5;
 | 
			
		||||
  int idx_peer = 7;
 | 
			
		||||
  int ret;
 | 
			
		||||
  struct peer *peer;
 | 
			
		||||
  struct prefix_rd prd;
 | 
			
		||||
  union sockunion su;
 | 
			
		||||
 | 
			
		||||
  ret = str2sockunion (argv[idx_peer]->arg, &su);
 | 
			
		||||
  if (ret < 0)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
  peer = peer_lookup (NULL, &su);
 | 
			
		||||
  if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP])
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
 | 
			
		||||
  if (! ret)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return show_adj_route_encap (vty, peer, &prd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes,
 | 
			
		||||
       show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd,
 | 
			
		||||
       "show [ip] bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors <A.B.C.D|X:X::X:X> advertised-routes",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
       "Address Family\n"
 | 
			
		||||
       "Display ENCAP NLRI specific information\n"
 | 
			
		||||
       "Display information for a route distinguisher\n"
 | 
			
		||||
       "ENCAP Route Distinguisher\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")
 | 
			
		||||
{
 | 
			
		||||
  int idx_rd = 5;
 | 
			
		||||
  int idx_peer = 7;
 | 
			
		||||
  int ret;
 | 
			
		||||
  struct peer *peer;
 | 
			
		||||
  struct prefix_rd prd;
 | 
			
		||||
  union sockunion su;
 | 
			
		||||
 | 
			
		||||
  ret = str2sockunion (argv[idx_peer]->arg, &su);
 | 
			
		||||
  if (ret < 0)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
  peer = peer_lookup (NULL, &su);
 | 
			
		||||
  if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP])
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  ret = str2prefix_rd (argv[idx_rd]->arg, &prd);
 | 
			
		||||
  if (! ret)
 | 
			
		||||
    {
 | 
			
		||||
      vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE);
 | 
			
		||||
      return CMD_WARNING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  return show_adj_route_encap (vty, peer, &prd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
bgp_encap_init (void)
 | 
			
		||||
{
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_cmd);
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv4_encap_tags_cmd);
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_tags_cmd);
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_neighbor_routes_cmd);
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd);
 | 
			
		||||
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_cmd);
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv6_encap_tags_cmd);
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_tags_cmd);
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_neighbor_routes_cmd);
 | 
			
		||||
  install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -25,7 +25,5 @@
 | 
			
		||||
 | 
			
		||||
extern void bgp_encap_init (void);
 | 
			
		||||
extern int bgp_nlri_parse_encap (struct peer *, struct attr *, struct bgp_nlri *);
 | 
			
		||||
extern int bgp_show_encap (struct vty *vty, afi_t afi, struct prefix_rd *prd, 
 | 
			
		||||
                           enum bgp_show_type type, void *output_arg, int tags);
 | 
			
		||||
#include "bgp_encap_types.h"
 | 
			
		||||
#endif /* _QUAGGA_BGP_ENCAP_H */
 | 
			
		||||
 | 
			
		||||
@ -7840,12 +7840,6 @@ bgp_show (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
 | 
			
		||||
      return bgp_show_mpls_vpn(vty, afi, NULL, type, output_arg,
 | 
			
		||||
                               0, use_json);
 | 
			
		||||
    }
 | 
			
		||||
  if (safi == SAFI_ENCAP) 
 | 
			
		||||
    {
 | 
			
		||||
      return bgp_show_encap(vty, afi, NULL, type, output_arg,
 | 
			
		||||
                            0);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
  table = bgp->rib[afi][safi];
 | 
			
		||||
 | 
			
		||||
@ -8217,7 +8211,7 @@ bgp_show_lcommunity_list (struct vty *vty, struct bgp *bgp, const char *lcom,
 | 
			
		||||
 | 
			
		||||
DEFUN (show_ip_bgp_large_community_list,
 | 
			
		||||
       show_ip_bgp_large_community_list_cmd,
 | 
			
		||||
       "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]] large-community-list <(1-500)|WORD> [json]",
 | 
			
		||||
       "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn>]] large-community-list <(1-500)|WORD> [json]",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
@ -8227,7 +8221,6 @@ DEFUN (show_ip_bgp_large_community_list,
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Display routes matching the large-community-list\n"
 | 
			
		||||
       "large-community-list number\n"
 | 
			
		||||
       "large-community-list name\n"
 | 
			
		||||
@ -8263,7 +8256,7 @@ DEFUN (show_ip_bgp_large_community_list,
 | 
			
		||||
}
 | 
			
		||||
DEFUN (show_ip_bgp_large_community,
 | 
			
		||||
       show_ip_bgp_large_community_cmd,
 | 
			
		||||
       "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]] large-community [AA:BB:CC] [json]",
 | 
			
		||||
       "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn>]] large-community [AA:BB:CC] [json]",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
       BGP_STR
 | 
			
		||||
@ -8273,7 +8266,6 @@ DEFUN (show_ip_bgp_large_community,
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Display routes matching the large-communities\n"
 | 
			
		||||
       "List of large-community numbers\n"
 | 
			
		||||
       JSON_STR)
 | 
			
		||||
@ -8429,8 +8421,6 @@ DEFUN (show_ip_bgp,
 | 
			
		||||
 | 
			
		||||
  if (safi == SAFI_MPLS_VPN)
 | 
			
		||||
    return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, uj);
 | 
			
		||||
  else if (safi == SAFI_ENCAP)
 | 
			
		||||
    return bgp_show_encap (vty, afi, NULL, bgp_show_type_normal, NULL, 0);
 | 
			
		||||
  else
 | 
			
		||||
    return bgp_show (vty, bgp, afi, safi, sh_type, NULL, uj);
 | 
			
		||||
}
 | 
			
		||||
@ -9214,7 +9204,7 @@ bgp_peer_counts (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, u_c
 | 
			
		||||
 | 
			
		||||
DEFUN (show_ip_bgp_instance_neighbor_prefix_counts,
 | 
			
		||||
       show_ip_bgp_instance_neighbor_prefix_counts_cmd,
 | 
			
		||||
       "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]] "
 | 
			
		||||
       "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn>]] "
 | 
			
		||||
       "neighbors <A.B.C.D|X:X::X:X|WORD> prefix-counts [json]",
 | 
			
		||||
       SHOW_STR
 | 
			
		||||
       IP_STR
 | 
			
		||||
@ -9225,7 +9215,6 @@ DEFUN (show_ip_bgp_instance_neighbor_prefix_counts,
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Address Family modifier\n"
 | 
			
		||||
       "Detailed information on TCP and BGP neighbor connections\n"
 | 
			
		||||
       "Neighbor to display information about\n"
 | 
			
		||||
       "Neighbor to display information about\n"
 | 
			
		||||
 | 
			
		||||
@ -155,7 +155,7 @@ argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *af
 | 
			
		||||
  return ret;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* supports <unicast|multicast|vpn|encap> */
 | 
			
		||||
/* supports <unicast|multicast|vpn> */
 | 
			
		||||
safi_t
 | 
			
		||||
bgp_vty_safi_from_arg(const char *safi_str)
 | 
			
		||||
{
 | 
			
		||||
@ -164,8 +164,6 @@ bgp_vty_safi_from_arg(const char *safi_str)
 | 
			
		||||
    safi = SAFI_MULTICAST;
 | 
			
		||||
  else if (strncmp (safi_str, "u", 1) == 0)
 | 
			
		||||
    safi = SAFI_UNICAST;
 | 
			
		||||
  else if (strncmp (safi_str, "e", 1) == 0)
 | 
			
		||||
    safi = SAFI_ENCAP;
 | 
			
		||||
  else if (strncmp (safi_str, "v", 1) == 0)
 | 
			
		||||
    safi = SAFI_MPLS_VPN;
 | 
			
		||||
  return safi;
 | 
			
		||||
@ -193,12 +191,6 @@ argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t
 | 
			
		||||
      if (safi)
 | 
			
		||||
        *safi = SAFI_MPLS_VPN;
 | 
			
		||||
    }
 | 
			
		||||
  else if (argv_find (argv, argc, "encap", index))
 | 
			
		||||
    {
 | 
			
		||||
      ret = 1;
 | 
			
		||||
      if (safi)
 | 
			
		||||
        *safi = SAFI_ENCAP;
 | 
			
		||||
    }
 | 
			
		||||
  else if (argv_find (argv, argc, "evpn", index))
 | 
			
		||||
    {
 | 
			
		||||
      ret = 1;
 | 
			
		||||
@ -218,12 +210,12 @@ argv_find_and_parse_safi (struct cmd_token **argv, int argc, int *index, safi_t
 | 
			
		||||
 * that is being parsed.
 | 
			
		||||
 *
 | 
			
		||||
 * The show commands are generally of the form:
 | 
			
		||||
 * "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]] ..."
 | 
			
		||||
 * "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn>]] ..."
 | 
			
		||||
 *
 | 
			
		||||
 * Since we use argv_find if the show command in particular doesn't have:
 | 
			
		||||
 * [ip]
 | 
			
		||||
 * [<view|vrf> WORD]
 | 
			
		||||
 * [<ipv4|ipv6> [<unicast|multicast|vpn|encap>]]
 | 
			
		||||
 * [<ipv4|ipv6> [<unicast|multicast|vpn>]]
 | 
			
		||||
 * The command parsing should still be ok.
 | 
			
		||||
 *
 | 
			
		||||
 * vty  -> The vty for the command so we can output some useful data in
 | 
			
		||||
 | 
			
		||||
@ -28,9 +28,8 @@ struct bgp;
 | 
			
		||||
 | 
			
		||||
#define BGP_AFI_CMD_STR         "<ipv4|ipv6>"
 | 
			
		||||
#define BGP_AFI_HELP_STR        "Address Family\nAddress Family\n"
 | 
			
		||||
#define BGP_SAFI_CMD_STR        "<unicast|multicast|vpn|encap>"
 | 
			
		||||
#define BGP_SAFI_CMD_STR        "<unicast|multicast|vpn>"
 | 
			
		||||
#define BGP_SAFI_HELP_STR       \
 | 
			
		||||
  "Address Family modifier\n"   \
 | 
			
		||||
  "Address Family modifier\n"   \
 | 
			
		||||
  "Address Family modifier\n"   \
 | 
			
		||||
  "Address Family modifier\n"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user