return BGP_VPNV4_NODE;
case SAFI_FLOWSPEC:
return BGP_FLOWSPECV4_NODE;
- default:
+ case SAFI_UNSPEC:
+ case SAFI_ENCAP:
+ case SAFI_EVPN:
+ case SAFI_MAX:
/* not expected */
return BGP_IPV4_NODE;
}
+ break;
case AFI_IP6:
switch (safi) {
case SAFI_UNICAST:
return BGP_VPNV6_NODE;
case SAFI_FLOWSPEC:
return BGP_FLOWSPECV6_NODE;
- default:
- /* not expected */
+ case SAFI_UNSPEC:
+ case SAFI_ENCAP:
+ case SAFI_EVPN:
+ case SAFI_MAX:
+ /* not expected and the return value seems wrong */
return BGP_IPV4_NODE;
}
+ break;
case AFI_L2VPN:
return BGP_EVPN_NODE;
case AFI_UNSPEC:
return "ipv4-labeled-unicast";
case SAFI_FLOWSPEC:
return "ipv4-flowspec";
- default:
+ case SAFI_UNSPEC:
+ case SAFI_EVPN:
+ case SAFI_MAX:
return "unknown-afi/safi";
}
break;
return "ipv6-labeled-unicast";
case SAFI_FLOWSPEC:
return "ipv6-flowspec";
- default:
+ case SAFI_UNSPEC:
+ case SAFI_EVPN:
+ case SAFI_MAX:
return "unknown-afi/safi";
}
break;
switch (safi) {
case SAFI_EVPN:
return "l2vpn-evpn";
- default:
+ case SAFI_UNICAST:
+ case SAFI_MULTICAST:
+ case SAFI_MPLS_VPN:
+ case SAFI_ENCAP:
+ case SAFI_LABELED_UNICAST:
+ case SAFI_FLOWSPEC:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
return "unknown-afi/safi";
}
+ break;
case AFI_UNSPEC:
case AFI_MAX:
return "unknown-afi/safi";
}
/* all AFIs are accounted for above, so this shouldn't happen */
- return "unknown-afi/safi";
+
+ assert(!"Reached end of function where we did not expect to");
}
int bgp_get_vty(struct bgp **bgp, as_t *as, const char *name,
return CMD_SUCCESS;
}
+ DEFPY(neighbor_path_attribute_treat_as_withdraw,
+ neighbor_path_attribute_treat_as_withdraw_cmd,
+ "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute treat-as-withdraw (1-255)...",
+ NEIGHBOR_STR
+ NEIGHBOR_ADDR_STR2
+ "Manipulate path attributes from incoming UPDATE messages\n"
+ "Treat-as-withdraw any incoming BGP UPDATE messages that contain the specified attribute\n"
+ "Attribute number\n")
+ {
+ struct peer *peer;
+ int idx = 0;
+ const char *withdraw_attrs = NULL;
+
+ peer = peer_and_group_lookup_vty(vty, neighbor);
+ if (!peer)
+ return CMD_WARNING_CONFIG_FAILED;
+
+ argv_find(argv, argc, "(1-255)", &idx);
+ if (idx)
+ withdraw_attrs = argv_concat(argv, argc, idx);
+
+ bgp_path_attribute_withdraw_vty(vty, peer, withdraw_attrs, true);
+
+ return CMD_SUCCESS;
+ }
+
+ DEFPY(no_neighbor_path_attribute_treat_as_withdraw,
+ no_neighbor_path_attribute_treat_as_withdraw_cmd,
+ "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor path-attribute treat-as-withdraw (1-255)...",
+ NO_STR
+ NEIGHBOR_STR
+ NEIGHBOR_ADDR_STR2
+ "Manipulate path attributes from incoming UPDATE messages\n"
+ "Treat-as-withdraw any incoming BGP UPDATE messages that contain the specified attribute\n"
+ "Attribute number\n")
+ {
+ struct peer *peer;
+ int idx = 0;
+ const char *withdraw_attrs = NULL;
+
+ peer = peer_and_group_lookup_vty(vty, neighbor);
+ if (!peer)
+ return CMD_WARNING_CONFIG_FAILED;
+
+ argv_find(argv, argc, "(1-255)", &idx);
+ if (idx)
+ withdraw_attrs = argv_concat(argv, argc, idx);
+
+ bgp_path_attribute_withdraw_vty(vty, peer, withdraw_attrs, false);
+
+ return CMD_SUCCESS;
+ }
+
static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv,
struct ecommunity **list, bool is_rt6)
{
vty_out(vty, " neighbor %s path-attribute discard %s\n", addr,
discard_attrs_str);
+ /* path-attribute treat-as-withdraw */
+ char withdraw_attrs_str[BUFSIZ] = {0};
+ bool withdraw_attrs = bgp_path_attribute_treat_as_withdraw(
+ peer, withdraw_attrs_str, sizeof(withdraw_attrs_str));
+
+ if (withdraw_attrs)
+ vty_out(vty,
+ " neighbor %s path-attribute treat-as-withdraw %s\n",
+ addr, withdraw_attrs_str);
+
if (!CHECK_FLAG(peer->peer_gr_new_status_flag,
PEER_GRACEFUL_RESTART_NEW_STATE_INHERIT)) {
install_element(BGP_NODE, &neighbor_path_attribute_discard_cmd);
install_element(BGP_NODE, &no_neighbor_path_attribute_discard_cmd);
+ /* "neighbor path-attribute treat-as-withdraw" commands. */
+ install_element(BGP_NODE,
+ &neighbor_path_attribute_treat_as_withdraw_cmd);
+ install_element(BGP_NODE,
+ &no_neighbor_path_attribute_treat_as_withdraw_cmd);
+
/* "neighbor passive" commands. */
install_element(BGP_NODE, &neighbor_passive_cmd);
install_element(BGP_NODE, &no_neighbor_passive_cmd);
/* Path attributes discard */
bool discard_attrs[BGP_ATTR_MAX];
+ /* Path attributes treat-as-withdraw */
+ bool withdraw_attrs[BGP_ATTR_MAX];
+
QOBJ_FIELDS;
};
DECLARE_QOBJ_TYPE(peer);
return BGP_AF_IPV4_ENCAP;
case SAFI_FLOWSPEC:
return BGP_AF_IPV4_FLOWSPEC;
- default:
+ case SAFI_EVPN:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
return BGP_AF_MAX;
}
break;
return BGP_AF_IPV6_ENCAP;
case SAFI_FLOWSPEC:
return BGP_AF_IPV6_FLOWSPEC;
- default:
+ case SAFI_EVPN:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
return BGP_AF_MAX;
}
break;
switch (safi) {
case SAFI_EVPN:
return BGP_AF_L2VPN_EVPN;
- default:
+ case SAFI_UNICAST:
+ case SAFI_MULTICAST:
+ case SAFI_LABELED_UNICAST:
+ case SAFI_MPLS_VPN:
+ case SAFI_ENCAP:
+ case SAFI_FLOWSPEC:
+ case SAFI_UNSPEC:
+ case SAFI_MAX:
return BGP_AF_MAX;
}
- default:
+ break;
+ case AFI_UNSPEC:
+ case AFI_MAX:
return BGP_AF_MAX;
}
+
+ assert(!"Reached end of function we should never hit");
}
/* If the peer is not a peer-group but is bound to a peer-group return 1 */
int outbound);
extern bool bgp_path_attribute_discard(struct peer *peer, char *buf,
size_t size);
+ extern bool bgp_path_attribute_treat_as_withdraw(struct peer *peer, char *buf,
+ size_t size);
#ifdef _FRR_ATTRIBUTE_PRINTFRR
/* clang-format off */
#pragma FRR printfrr_ext "%pBP" (struct peer *)
If you do not want specific attributes, you can drop them using this command, and
let the BGP proceed by ignoring those attributes.
+ .. clicmd:: neighbor <A.B.C.D|X:X::X:X|WORD> path-attribute treat-as-withdraw (1-255)...
+
+ Received BGP UPDATES that contain specified path attributes are treat-as-withdraw. If
+ there is an existing prefix in the BGP routing table, it will be removed.
+
.. clicmd:: neighbor <A.B.C.D|X:X::X:X|WORD> graceful-shutdown
Mark all routes from this neighbor as less preferred by setting ``graceful-shutdown``
Displaying Information about Peers
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-.. clicmd:: show bgp <afi> <safi> neighbors WORD bestpath-routes [json] [wide]
+.. clicmd:: show bgp <afi> <safi> neighbors WORD bestpath-routes [detail] [json] [wide]
For the given neighbor, WORD, that is specified list the routes selected
by BGP as having the best path.
+ If ``detail`` option is specified, the detailed version of all routes
+ will be displayed. The same format as ``show [ip] bgp [afi] [safi] PREFIX``
+ will be used, but for the whole table of received, advertised or filtered
+ prefixes.
+
+ If ``json`` option is specified, output is displayed in JSON format.
+
+ If ``wide`` option is specified, then the prefix table's width is increased
+ to fully display the prefix and the nexthop.
+
.. _bgp-peer-filtering:
Peer Filtering
The ``terse`` option can be used in combination with the remote-as, neighbor,
failed and established filters, and with the ``wide`` option as well.
-.. clicmd:: show bgp [afi] [safi] [neighbor [PEER] [routes|advertised-routes|received-routes] [detail] [json]
+.. clicmd:: show bgp [afi] [safi] [neighbor [PEER] [routes|advertised-routes|received-routes] [<A.B.C.D/M|X:X::X:X/M> | detail] [json]
This command shows information on a specific BGP peer of the relevant
afi and safi selected.
The ``received-routes`` keyword displays all routes belonging to this
address-family (prior to inbound policy) that were received by this peer.
+ If a specific prefix is specified, the detailed version of that prefix will
+ be displayed.
+
If ``detail`` option is specified, the detailed version of all routes
will be displayed. The same format as ``show [ip] bgp [afi] [safi] PREFIX``
will be used, but for the whole table of received, advertised or filtered
If the ``json`` option is specified, output is displayed in JSON format.
-.. clicmd:: show [ip] bgp [afi] [safi] [all] neighbors A.B.C.D [advertised-routes|received-routes|filtered-routes] [detail] [json|wide]
+.. clicmd:: show [ip] bgp [afi] [safi] [all] neighbors A.B.C.D [advertised-routes|received-routes|filtered-routes] [<A.B.C.D/M|X:X::X:X/M> | detail] [json|wide]
Display the routes advertised to a BGP neighbor or received routes
from neighbor or filtered routes received from neighbor based on the
if afi is specified, with ``all`` option, routes will be displayed for
each SAFI in the selcted AFI
+ If a specific prefix is specified, the detailed version of that prefix will
+ be displayed.
+
If ``detail`` option is specified, the detailed version of all routes
will be displayed. The same format as ``show [ip] bgp [afi] [safi] PREFIX``
will be used, but for the whole table of received, advertised or filtered