/* BGP routing information
- Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
- Copyright (C) 2016 Job Snijders <job@instituut.net>
-
-This file is part of GNU Zebra.
-
-GNU Zebra is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 2, or (at your option) any
-later version.
-
-GNU Zebra is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Zebra; see the file COPYING. If not, write to the Free
-Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA. */
+ * Copyright (C) 1996, 97, 98, 99 Kunihiro Ishiguro
+ * Copyright (C) 2016 Job Snijders <job@instituut.net>
+ *
+ * This file is part of GNU Zebra.
+ *
+ * GNU Zebra is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * GNU Zebra is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; see the file COPYING; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
#include <zebra.h>
#include "bgpd/bgp_filter.h"
#include "bgpd/bgp_fsm.h"
#include "bgpd/bgp_mplsvpn.h"
-#include "bgpd/bgp_encap.h"
#include "bgpd/bgp_nexthop.h"
#include "bgpd/bgp_damp.h"
#include "bgpd/bgp_advertise.h"
}
/* If it's labeled safi, make sure the route has a valid label. */
- if (bgp_labeled_safi(safi))
+ if (safi == SAFI_LABELED_UNICAST)
{
u_char *tag = bgp_adv_label(rn, ri, peer, afi, safi);
if (!bgp_is_valid_label(tag))
#define NEXTHOP_IS_V6 (\
(safi != SAFI_ENCAP && safi != SAFI_MPLS_VPN &&\
- (p->family == AF_INET6 || peer_cap_enhe(peer))) || \
+ (p->family == AF_INET6 || peer_cap_enhe(peer, afi, safi))) || \
((safi == SAFI_ENCAP || safi == SAFI_MPLS_VPN) &&\
attr->extra->mp_nexthop_len >= IPV6_MAX_BYTELEN))
if (!reflect ||
CHECK_FLAG (peer->af_flags[afi][safi],
PEER_FLAG_FORCE_NEXTHOP_SELF))
- subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ?
+ subgroup_announce_reset_nhop ((peer_cap_enhe(peer, afi, safi) ?
AF_INET6 : p->family), attr);
}
else if (peer->sort == BGP_PEER_EBGP)
break;
}
if (!paf)
- subgroup_announce_reset_nhop ((peer_cap_enhe(peer) ? AF_INET6 : p->family), attr);
+ subgroup_announce_reset_nhop ((peer_cap_enhe(peer, afi, safi) ? AF_INET6 : p->family), attr);
}
/* If IPv6/MP and nexthop does not have any override and happens to
* be a link-local address, reset it so that we don't pass along the
* source's link-local IPv6 address to recipients who may not be on
* the same interface.
*/
- if (p->family == AF_INET6 || peer_cap_enhe(peer))
+ if (p->family == AF_INET6 || peer_cap_enhe(peer, afi, safi))
{
if (IN6_IS_ADDR_LINKLOCAL (&attr->extra->mp_nexthop_global))
subgroup_announce_reset_nhop (AF_INET6, attr);
* Right now, since we only deal with per-prefix labels, it is not necessary
* to do this upon changes to best path except of the label index changes.
*/
- bgp_table_lock (bgp_node_table (rn));
- if (bgp_labeled_safi (safi))
+ if (safi == SAFI_LABELED_UNICAST)
{
+ bgp_table_lock (bgp_node_table (rn));
if (new_select)
{
if (!old_select ||
peer->rcvd_attr_printed = 1;
}
- zlog_debug ("%s rcvd %s%s ", peer->host,
+ zlog_debug ("%s rcvd %s %s ", peer->host,
bgp_debug_rdpfxpath2str (prd, p, addpath_id ? 1 : 0,
addpath_id, pfx_buf, sizeof (pfx_buf)), label_buf);
}
new = info_make(type, sub_type, 0, peer, attr_new, rn);
/* Update MPLS tag. */
- if (bgp_labeled_safi(safi) || safi == SAFI_EVPN)
+ if (bgp_labeled_safi(safi))
memcpy ((bgp_info_extra_get (new))->tag, tag, 3);
/* Update Overlay Index */
/* Nexthop reachability check. */
if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK) &&
- safi == SAFI_UNICAST)
+ (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST))
{
- if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, 0) &&
- safi == SAFI_UNICAST)
+ if (bgp_find_or_add_nexthop (bgp, afi, ri, NULL, 0))
bgp_info_set_flag (rn, ri, BGP_INFO_VALID);
else
{
new = info_make(ZEBRA_ROUTE_BGP, BGP_ROUTE_STATIC, 0, bgp->peer_self, attr_new,
rn);
/* Nexthop reachability check. */
- if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK))
+ if (bgp_flag_check (bgp, BGP_FLAG_IMPORT_CHECK) &&
+ (safi == SAFI_UNICAST || safi == SAFI_LABELED_UNICAST))
{
if (bgp_find_or_add_nexthop (bgp, afi, new, NULL, 0))
bgp_info_set_flag (rn, new, BGP_INFO_VALID);
if ((safi == SAFI_EVPN) || (safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))
{
- if (bgp_static->igpnexthop.s_addr)
+ if (afi == AFI_IP)
{
bgp_attr_extra_get (&attr)->mp_nexthop_global_in = bgp_static->igpnexthop;
bgp_attr_extra_get (&attr)->mp_nexthop_len = IPV4_MAX_BYTELEN;
for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
{
- bgp_static = rn->info;
+ bgp_static = rm->info;
bgp_static_update_safi (bgp, &rm->p, bgp_static, afi, safi);
}
}
for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
{
- bgp_static = rn->info;
+ bgp_static = rm->info;
bgp_static_withdraw_safi (bgp, &rm->p,
AFI_IP, safi,
(struct prefix_rd *)&rn->p,
afi_t afi;
safi_t safi;
struct bgp_node *rn;
+ struct bgp_node *rm;
+ struct bgp_table *table;
struct bgp_static *bgp_static;
/* Use this flag to force reprocessing of the route */
for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn))
if (rn->info != NULL)
{
- bgp_static = rn->info;
- bgp_static_update (bgp, &rn->p, bgp_static, afi, safi);
+ if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) || (safi == SAFI_EVPN))
+ {
+ table = rn->info;
+
+ for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm))
+ {
+ bgp_static = rm->info;
+ bgp_static_update_safi (bgp, &rm->p, bgp_static, afi, safi);
+ }
+ }
+ else
+ {
+ bgp_static = rn->info;
+ bgp_static_update (bgp, &rn->p, bgp_static, afi, safi);
+ }
}
bgp_flag_unset(bgp, BGP_FLAG_FORCE_STATIC_PROCESS);
}
* I think it can probably be factored with bgp_static_set.
*/
int
-bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str,
- const char *rd_str, const char *tag_str,
+bgp_static_set_safi (afi_t afi, safi_t safi, struct vty *vty, const char *ip_str,
+ const char *rd_str, const char *label_str,
const char *rmap_str, int evpn_type, const char *esi, const char *gwip,
const char *ethtag, const char *routermac)
{
struct bgp_table *table;
struct bgp_static *bgp_static;
u_char tag[3];
- afi_t afi;
struct prefix gw_ip;
- if(safi == SAFI_EVPN)
- afi = AFI_L2VPN;
- else
- afi = AFI_IP;
-
/* validate ip prefix */
ret = str2prefix (ip_str, &p);
if (! ret)
return CMD_WARNING;
}
- if (tag_str)
+ if (label_str)
{
- ret = str2tag (tag_str, tag);
- if (! ret)
- {
- vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
- return CMD_WARNING;
- }
+ unsigned long label_val;
+ VTY_GET_INTEGER_RANGE("Label/tag", label_val, label_str, 0, 16777215);
+ encode_label (label_val, tag);
}
else
{
- encode_label (0, tag);
+ memset (tag, 0, sizeof(tag)); /* empty, not even BoS */
}
if (safi == SAFI_EVPN)
{
if (rmap_str)
{
if (bgp_static->rmap.name)
- free (bgp_static->rmap.name);
- bgp_static->rmap.name = strdup (rmap_str);
+ XFREE(MTYPE_ROUTE_MAP_NAME, bgp_static->rmap.name);
+ bgp_static->rmap.name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, rmap_str);
bgp_static->rmap.map = route_map_lookup_by_name (rmap_str);
}
/* Configure static BGP network. */
int
-bgp_static_unset_safi(safi_t safi, struct vty *vty, const char *ip_str,
- const char *rd_str, const char *tag_str,
+bgp_static_unset_safi(afi_t afi, safi_t safi, struct vty *vty, const char *ip_str,
+ const char *rd_str, const char *label_str,
int evpn_type, const char *esi, const char *gwip, const char *ethtag)
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
struct bgp_table *table;
struct bgp_static *bgp_static;
u_char tag[3];
- afi_t afi;
-
- if(safi == SAFI_EVPN)
- afi = AFI_L2VPN;
- else
- afi = AFI_IP;
/* Convert IP prefix string to struct prefix. */
ret = str2prefix (ip_str, &p);
return CMD_WARNING;
}
- ret = str2tag (tag_str, tag);
- if (! ret)
+ if (label_str)
{
- vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE);
- return CMD_WARNING;
+ unsigned long label_val;
+ VTY_GET_INTEGER_RANGE("Label/tag", label_val, label_str, 0, MPLS_LABEL_MAX);
+ encode_label (label_val, tag);
+ }
+ else
+ {
+ memset (tag, 0, sizeof(tag)); /* empty, not even BoS */
}
prn = bgp_node_get (bgp->route[afi][safi],
DEFUN (bgp_network_label_index,
bgp_network_label_index_cmd,
- "network A.B.C.D/M label-index (0-4294967294)",
+ "network A.B.C.D/M label-index (0-1048560)",
"Specify a network to announce via BGP\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
"Label index to associate with the prefix\n"
DEFUN (bgp_network_label_index_route_map,
bgp_network_label_index_route_map_cmd,
- "network A.B.C.D/M label-index (0-4294967294) route-map WORD",
+ "network A.B.C.D/M label-index (0-1048560) route-map WORD",
"Specify a network to announce via BGP\n"
"IP prefix\n"
"Label index to associate with the prefix\n"
ALIAS (no_bgp_network,
no_bgp_network_label_index_cmd,
- "no network A.B.C.D/M label-index (0-4294967294)",
+ "no network A.B.C.D/M label-index (0-1048560)",
NO_STR
"Specify a network to announce via BGP\n"
"IP prefix <network>/<length>, e.g., 35.0.0.0/8\n"
ALIAS (no_bgp_network,
no_bgp_network_label_index_route_map_cmd,
- "no network A.B.C.D/M label-index (0-4294967294) route-map WORD",
+ "no network A.B.C.D/M label-index (0-1048560) route-map WORD",
NO_STR
"Specify a network to announce via BGP\n"
"IP prefix\n"
DEFUN (ipv6_bgp_network_label_index,
ipv6_bgp_network_label_index_cmd,
- "network X:X::X:X/M label-index (0-4294967294)",
+ "network X:X::X:X/M label-index (0-1048560)",
"Specify a network to announce via BGP\n"
"IPv6 prefix <network>/<length>\n"
"Label index to associate with the prefix\n"
DEFUN (ipv6_bgp_network_label_index_route_map,
ipv6_bgp_network_label_index_route_map_cmd,
- "network X:X::X:X/M label-index (0-4294967294) route-map WORD",
+ "network X:X::X:X/M label-index (0-1048560) route-map WORD",
"Specify a network to announce via BGP\n"
"IPv6 prefix\n"
"Label index to associate with the prefix\n"
ALIAS (no_ipv6_bgp_network,
no_ipv6_bgp_network_label_index_cmd,
- "no network X:X::X:X/M label-index (0-4294967294)",
+ "no network X:X::X:X/M label-index (0-1048560)",
NO_STR
"Specify a network to announce via BGP\n"
"IPv6 prefix <network>/<length>\n"
ALIAS (no_ipv6_bgp_network,
no_ipv6_bgp_network_label_index_route_map_cmd,
- "no network X:X::X:X/M label-index (0-4294967294) route-map WORD",
+ "no network X:X::X:X/M label-index (0-1048560) route-map WORD",
NO_STR
"Specify a network to announce via BGP\n"
"IPv6 prefix\n"
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];
{
struct listnode *node, *nnode;
struct bgp *bgp;
- struct bgp_table *table;
int is_first = 1;
if (use_json)
? "Default" : bgp->name,
VTY_NEWLINE);
}
- table = bgp->rib[afi][safi];
- bgp_show_table (vty, bgp, table,
- bgp_show_type_normal, NULL, use_json);
+ bgp_show (vty, bgp, afi, safi, bgp_show_type_normal, NULL, use_json);
}
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|labeled-unicast>]] large-community-list <(1-500)|WORD> [json]",
+ "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] large-community-list <(1-500)|WORD> [json]",
SHOW_STR
IP_STR
BGP_STR
"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"
}
DEFUN (show_ip_bgp_large_community,
show_ip_bgp_large_community_cmd,
- "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|encap|labeled-unicast>]] large-community [AA:BB:CC] [json]",
+ "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] large-community [AA:BB:CC] [json]",
SHOW_STR
IP_STR
BGP_STR
"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)
}
/* prefix-longer */
if (argv_find(argv, argc, "A.B.C.D/M", &idx) || argv_find(argv, argc, "X:X::X:X/M", &idx))
- return bgp_show_prefix_longer (vty, bgp, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_longer);
+ return bgp_show_prefix_longer (vty, bgp, argv[idx]->arg, afi, safi, bgp_show_type_prefix_longer);
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);
}
int i;
char *str;
int first = 0;
+ int ret = 0;
b = buffer_new (1024);
for (i = 0; i < argc; i++)
return CMD_WARNING;
}
- return bgp_show (vty, bgp, afi, safi,
- (exact ? bgp_show_type_community_exact :
- bgp_show_type_community), com, 0);
+ ret = bgp_show (vty, bgp, afi, safi,
+ (exact ? bgp_show_type_community_exact :
+ bgp_show_type_community), com, 0);
+ community_free (com);
+
+ return ret;
}
static int
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|labeled-unicast>]] "
+ "show [ip] bgp [<view|vrf> WORD] [<ipv4|ipv6> [<unicast|multicast|vpn|labeled-unicast>]] "
"neighbors <A.B.C.D|X:X::X:X|WORD> prefix-counts [json]",
SHOW_STR
IP_STR
prefix_rd2str (prd, rdbuf, RD_ADDRSTRLEN);
label = decode_label (bgp_static->tag);
- vty_out (vty, " network %s/%d rd %s tag %d",
+ vty_out (vty, " network %s/%d rd %s",
inet_ntop (p->family, &p->u.prefix, buf, SU_ADDRSTRLEN),
- p->prefixlen,
- rdbuf, label);
+ p->prefixlen, rdbuf);
+ if (safi == SAFI_MPLS_VPN)
+ vty_out (vty, " label %u", label);
+
+ if (bgp_static->rmap.name)
+ vty_out (vty, " route-map %s", bgp_static->rmap.name);
+ else
+ {
+ if (bgp_static->backdoor)
+ vty_out (vty, " backdoor");
+ }
vty_out (vty, "%s", VTY_NEWLINE);
}
return 0;
install_element (BGP_IPV6_NODE, &ipv6_bgp_network_route_map_cmd);
install_element (BGP_IPV6_NODE, &no_bgp_table_map_cmd);
install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_cmd);
- install_element (BGP_IPV6_NODE, &ipv6_bgp_network_label_index_cmd);
- install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_label_index_cmd);
- install_element (BGP_IPV6_NODE, &ipv6_bgp_network_label_index_route_map_cmd);
- install_element (BGP_IPV6_NODE, &no_ipv6_bgp_network_label_index_route_map_cmd);
+ install_element (BGP_IPV6L_NODE, &ipv6_bgp_network_label_index_cmd);
+ install_element (BGP_IPV6L_NODE, &no_ipv6_bgp_network_label_index_cmd);
+ install_element (BGP_IPV6L_NODE, &ipv6_bgp_network_label_index_route_map_cmd);
+ install_element (BGP_IPV6L_NODE, &no_ipv6_bgp_network_label_index_route_map_cmd);
install_element (BGP_IPV6_NODE, &ipv6_aggregate_address_cmd);
install_element (BGP_IPV6_NODE, &no_ipv6_aggregate_address_cmd);