]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: expose sender side AS path loop detection
authorRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 29 Oct 2019 19:29:09 +0000 (16:29 -0300)
committerRafael Zalamena <rzalamena@opensourcerouting.org>
Tue, 29 Oct 2019 19:29:09 +0000 (16:29 -0300)
The sender side AS path loop detection code was implemented since the
import of Quagga code, however it was always disabled by a `ifdef`
guard.

Lets allow the user to decide whether or not to enable this feature on
run-time.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
bgpd/bgp_route.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index 77428bbb0f02807e9a4e376638de7f4f02bb69a2..41e32b31121310754df4883aaf49beea2904e762 100644 (file)
@@ -1639,9 +1639,9 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
                return 0;
        }
 
-#ifdef BGP_SEND_ASPATH_CHECK
        /* AS path loop check. */
-       if (onlypeer && aspath_loop_check(piattr->aspath, onlypeer->as)) {
+       if (onlypeer && onlypeer->as_path_loop_detection
+           && aspath_loop_check(piattr->aspath, onlypeer->as)) {
                if (bgp_debug_update(NULL, p, subgrp->update_group, 0))
                        zlog_debug(
                                "%s [Update:SEND] suppress announcement to peer AS %u "
@@ -1649,7 +1649,6 @@ int subgroup_announce_check(struct bgp_node *rn, struct bgp_path_info *pi,
                                onlypeer->host, onlypeer->as);
                return 0;
        }
-#endif /* BGP_SEND_ASPATH_CHECK */
 
        /* If we're a CONFED we need to loop check the CONFED ID too */
        if (CHECK_FLAG(bgp->config, BGP_CONFIG_CONFEDERATION)) {
index 9e81831ac7f59c17eb36b70f1de455dee26b2282..17c93ffc38fb92bb4706239e883dd3c780aa4fed 100644 (file)
@@ -6381,6 +6381,44 @@ ALIAS_HIDDEN(no_neighbor_addpath_tx_bestpath_per_as,
             NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2
             "Use addpath to advertise the bestpath per each neighboring AS\n")
 
+DEFPY(
+       neighbor_aspath_loop_detection, neighbor_aspath_loop_detection_cmd,
+       "neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
+       NEIGHBOR_STR
+       NEIGHBOR_ADDR_STR2
+       "Detect AS loops before sending to neighbor\n")
+{
+       struct peer *peer;
+
+       peer = peer_and_group_lookup_vty(vty, neighbor);
+       if (!peer)
+               return CMD_WARNING_CONFIG_FAILED;
+
+       peer->as_path_loop_detection = true;
+
+       return CMD_SUCCESS;
+}
+
+DEFPY(
+       no_neighbor_aspath_loop_detection,
+       no_neighbor_aspath_loop_detection_cmd,
+       "no neighbor <A.B.C.D|X:X::X:X|WORD>$neighbor sender-as-path-loop-detection",
+       NO_STR
+       NEIGHBOR_STR
+       NEIGHBOR_ADDR_STR2
+       "Detect AS loops before sending to neighbor\n")
+{
+       struct peer *peer;
+
+       peer = peer_and_group_lookup_vty(vty, neighbor);
+       if (!peer)
+               return CMD_WARNING_CONFIG_FAILED;
+
+       peer->as_path_loop_detection = false;
+
+       return CMD_SUCCESS;
+}
+
 static int set_ecom_list(struct vty *vty, int argc, struct cmd_token **argv,
                         struct ecommunity **list)
 {
@@ -13678,6 +13716,10 @@ void bgp_vty_init(void)
        install_element(BGP_VPNV6_NODE,
                        &no_neighbor_addpath_tx_bestpath_per_as_cmd);
 
+       /* "neighbor sender-as-path-loop-detection" commands. */
+       install_element(BGP_NODE, &neighbor_aspath_loop_detection_cmd);
+       install_element(BGP_NODE, &no_neighbor_aspath_loop_detection_cmd);
+
        /* "neighbor passive" commands. */
        install_element(BGP_NODE, &neighbor_passive_cmd);
        install_element(BGP_NODE, &no_neighbor_passive_cmd);
index a2d4c0101eba0dcb34ab848e5aab229293e8b2c7..06f6f933ac7d7f939d51e67557ac2b9066cc42fc 100644 (file)
@@ -7166,6 +7166,11 @@ static void bgp_config_write_peer_global(struct vty *vty, struct bgp *bgp,
        /* strict-capability-match */
        if (peergroup_flag_check(peer, PEER_FLAG_STRICT_CAP_MATCH))
                vty_out(vty, " neighbor %s strict-capability-match\n", addr);
+
+       /* Sender side AS path loop detection. */
+       if (peer->as_path_loop_detection)
+               vty_out(vty, " neighbor %s sender-as-path-loop-detection\n",
+                       addr);
 }
 
 /* BGP peer configuration display function. */
index 9f6148488c2cc53d25ed727693483517666dbea4..317f200b85cfb62c61adfa5e69e56e08d8f53bf8 100644 (file)
@@ -1225,6 +1225,9 @@ struct peer {
        char *hostname;
        char *domainname;
 
+       /* Sender side AS path loop detection. */
+       bool as_path_loop_detection;
+
        QOBJ_FIELDS
 };
 DECLARE_QOBJ_TYPE(peer)
@@ -1447,9 +1450,6 @@ struct bgp_nlri {
 #define BGP_VTY_PORT                          2605
 #define BGP_DEFAULT_CONFIG             "bgpd.conf"
 
-/* Check AS path loop when we send NLRI.  */
-/* #define BGP_SEND_ASPATH_CHECK */
-
 /* BGP Dynamic Neighbors feature */
 #define BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT    100
 #define BGP_DYNAMIC_NEIGHBORS_LIMIT_MIN          1