]> git.puffer.fish Git - matthieu/frr.git/commitdiff
Cleanup of missing NEXTHOP_FORCE_SELF
authorDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 22 Jul 2015 20:18:24 +0000 (13:18 -0700)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Wed, 22 Jul 2015 20:18:24 +0000 (13:18 -0700)
bgpd/bgp_routemap.c
bgpd/bgp_vty.c
bgpd/bgpd.c
bgpd/bgpd.h

index 81786541876b55c5960546b687fd2ec697a54cb9..78c58de8e6101a12478d7b0e4fd87796a18d3533 100644 (file)
@@ -100,7 +100,7 @@ o Cisco route-map
       tag               :  Done
       weight            :  Done
 
-o Local extensions
+o Local extention
 
   set ipv6 next-hop global: Done
   set ipv6 next-hop local : Done
@@ -108,26 +108,6 @@ o Local extensions
 
 */ 
 
- /* generic as path object to be shared in multiple rules */
-
-static void *
-route_aspath_compile (const char *arg)
-{
-  struct aspath *aspath;
-
-  aspath = aspath_str2aspath (arg);
-  if (! aspath)
-    return NULL;
-  return aspath;
-}
-
-static void
-route_aspath_free (void *rule)
-{
-  struct aspath *aspath = rule;
-  aspath_free (aspath);
-}
-
  /* 'match peer (A.B.C.D|X:X::X:X)' */
 
 /* Compares the peer specified in the 'match peer' clause with the peer
@@ -1450,13 +1430,33 @@ route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t
   return RMAP_OKAY;
 }
 
-/* Set as-path prepend rule structure. */
+/* Compile function for as-path prepend. */
+static void *
+route_set_aspath_prepend_compile (const char *arg)
+{
+  struct aspath *aspath;
+
+  aspath = aspath_str2aspath (arg);
+  if (! aspath)
+    return NULL;
+  return aspath;
+}
+
+/* Compile function for as-path prepend. */
+static void
+route_set_aspath_prepend_free (void *rule)
+{
+  struct aspath *aspath = rule;
+  aspath_free (aspath);
+}
+
+/* Set metric rule structure. */
 struct route_map_rule_cmd route_set_aspath_prepend_cmd = 
 {
   "as-path prepend",
   route_set_aspath_prepend,
-  route_aspath_compile,
-  route_aspath_free,
+  route_set_aspath_prepend_compile,
+  route_set_aspath_prepend_free,
 };
 
 /* `set as-path exclude ASn' */
@@ -1484,13 +1484,37 @@ route_set_aspath_exclude (void *rule, struct prefix *dummy, route_map_object_t t
   return RMAP_OKAY;
 }
 
+/* FIXME: consider using route_set_aspath_prepend_compile() and
+ * route_set_aspath_prepend_free(), which two below function are
+ * exact clones of.
+ */
+
+/* Compile function for as-path exclude. */
+static void *
+route_set_aspath_exclude_compile (const char *arg)
+{
+  struct aspath *aspath;
+
+  aspath = aspath_str2aspath (arg);
+  if (! aspath)
+    return NULL;
+  return aspath;
+}
+
+static void
+route_set_aspath_exclude_free (void *rule)
+{
+  struct aspath *aspath = rule;
+  aspath_free (aspath);
+}
+
 /* Set ASn exlude rule structure. */
 struct route_map_rule_cmd route_set_aspath_exclude_cmd = 
 {
   "as-path exclude",
   route_set_aspath_exclude,
-  route_aspath_compile,
-  route_aspath_free,
+  route_set_aspath_exclude_compile,
+  route_set_aspath_exclude_free,
 };
 
 /* `set community COMMUNITY' */
@@ -1847,7 +1871,7 @@ route_set_origin_free (void *rule)
   XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
 }
 
-/* Set origin rule structure. */
+/* Set metric rule structure. */
 struct route_map_rule_cmd route_set_origin_cmd = 
 {
   "origin",
@@ -2496,7 +2520,7 @@ route_set_originator_id_free (void *rule)
   XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
 }
 
-/* Set originator-id rule structure. */
+/* Set metric rule structure. */
 struct route_map_rule_cmd route_set_originator_id_cmd = 
 {
   "originator-id",
index c69ef0831a25f7d097daa70554068cb737c4737a..625473b2546225d1a3179d539d9413ddd3bb0ccc 100644 (file)
@@ -3390,43 +3390,53 @@ DEFUN (no_neighbor_capability_orf_prefix,
 /* neighbor next-hop-self. */
 DEFUN (neighbor_nexthop_self,
        neighbor_nexthop_self_cmd,
-       NEIGHBOR_CMD2 "next-hop-self {all}",
+       NEIGHBOR_CMD2 "next-hop-self",
        NEIGHBOR_STR
        NEIGHBOR_ADDR_STR2
-       "Disable the next hop calculation for this neighbor\n"
-       "Apply also to ibgp-learned routes when acting as a route reflector\n")
+       "Disable the next hop calculation for this neighbor\n")
 {
-  u_int32_t flags = PEER_FLAG_NEXTHOP_SELF, unset = 0;
-  int rc;
-
-  /* Check if "all" is specified */
-  if (argv[1] != NULL)
-    flags |= PEER_FLAG_NEXTHOP_SELF_ALL;
-  else
-    unset |= PEER_FLAG_NEXTHOP_SELF_ALL;
+  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
+                              bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
+}
 
-  rc = peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
-                            bgp_node_safi (vty), flags);
-  if ( rc == CMD_SUCCESS && unset )
-    rc = peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
-                                bgp_node_safi (vty), unset);
-  return rc;
+/* neighbor next-hop-self. */
+DEFUN (neighbor_nexthop_self_force,
+       neighbor_nexthop_self_force_cmd,
+       NEIGHBOR_CMD2 "next-hop-self force",
+       NEIGHBOR_STR
+       NEIGHBOR_ADDR_STR2
+       "Disable the next hop calculation for this neighbor\n"
+       "Set the next hop to self for reflected routes\n")
+{
+  return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
+                              bgp_node_safi (vty),
+                              (PEER_FLAG_FORCE_NEXTHOP_SELF |
+                               PEER_FLAG_NEXTHOP_SELF));
 }
 
 DEFUN (no_neighbor_nexthop_self,
        no_neighbor_nexthop_self_cmd,
-       NO_NEIGHBOR_CMD2 "next-hop-self {all}",
+       NO_NEIGHBOR_CMD2 "next-hop-self",
        NO_STR
        NEIGHBOR_STR
        NEIGHBOR_ADDR_STR2
-       "Disable the next hop calculation for this neighbor\n"
-       "Apply also to ibgp-learned routes when acting as a route reflector\n")
+       "Disable the next hop calculation for this neighbor\n")
 {
   return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
                                 bgp_node_safi (vty),
-                                PEER_FLAG_NEXTHOP_SELF|PEER_FLAG_NEXTHOP_SELF_ALL);
+                                (PEER_FLAG_NEXTHOP_SELF |
+                                 PEER_FLAG_FORCE_NEXTHOP_SELF));
 }
 
+ALIAS (no_neighbor_nexthop_self,
+       no_neighbor_nexthop_self_force_cmd,
+       NO_NEIGHBOR_CMD2 "next-hop-self force",
+       NO_STR
+       NEIGHBOR_STR
+       NEIGHBOR_ADDR_STR2
+       "Disable the next hop calculation for this neighbor\n"
+       "Set the next hop to self for reflected routes\n")
+
 /* neighbor as-override */
 DEFUN (neighbor_as_override,
        neighbor_as_override_cmd,
@@ -9115,6 +9125,7 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
     vty_out (vty, "  Route-Server Client%s", VTY_NEWLINE);
   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_SOFT_RECONFIG))
     vty_out (vty, "  Inbound soft reconfiguration allowed%s", VTY_NEWLINE);
+
   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE))
     vty_out (vty, "  Private AS numbers replaced in updates to this neighbor%s", VTY_NEWLINE);
   else if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_REMOVE_PRIVATE_AS))
@@ -9124,7 +9135,7 @@ bgp_show_peer_afi (struct vty *vty, struct peer *p, afi_t afi, safi_t safi)
     vty_out (vty, "  Override ASNs in outbound updates if aspath equals remote-as%s", VTY_NEWLINE);
 
   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF) ||
-      CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
+      CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_FORCE_NEXTHOP_SELF))
     vty_out (vty, "  NEXT_HOP is always this router%s", VTY_NEWLINE);
   if (CHECK_FLAG (p->af_flags[afi][safi], PEER_FLAG_AS_PATH_UNCHANGED))
     vty_out (vty, "  AS_PATH is propagated unchanged to this neighbor%s", VTY_NEWLINE);
@@ -12034,6 +12045,20 @@ bgp_vty_init (void)
   install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_cmd);
   install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_cmd);
 
+  /* "neighbor next-hop-self force" commands. */
+  install_element (BGP_NODE, &neighbor_nexthop_self_force_cmd);
+  install_element (BGP_NODE, &no_neighbor_nexthop_self_force_cmd);
+  install_element (BGP_IPV4_NODE, &neighbor_nexthop_self_force_cmd);
+  install_element (BGP_IPV4_NODE, &no_neighbor_nexthop_self_force_cmd);
+  install_element (BGP_IPV4M_NODE, &neighbor_nexthop_self_force_cmd);
+  install_element (BGP_IPV4M_NODE, &no_neighbor_nexthop_self_force_cmd);
+  install_element (BGP_IPV6_NODE, &neighbor_nexthop_self_force_cmd);
+  install_element (BGP_IPV6_NODE, &no_neighbor_nexthop_self_force_cmd);
+  install_element (BGP_IPV6M_NODE, &neighbor_nexthop_self_force_cmd);
+  install_element (BGP_IPV6M_NODE, &no_neighbor_nexthop_self_force_cmd);
+  install_element (BGP_VPNV4_NODE, &neighbor_nexthop_self_force_cmd);
+  install_element (BGP_VPNV4_NODE, &no_neighbor_nexthop_self_force_cmd);
+
   /* "neighbor as-override" commands. */
   install_element (BGP_NODE, &neighbor_as_override_cmd);
   install_element (BGP_NODE, &no_neighbor_as_override_cmd);
index 5ef07f0c4bce476781ecde2e627d75e93fb472fe..53756cb89154077d394b981310925447f711457e 100644 (file)
@@ -3248,7 +3248,7 @@ static const struct peer_flag_action peer_af_flag_action_list[] =
     { PEER_FLAG_ORF_PREFIX_SM,            1, peer_change_reset },
     { PEER_FLAG_ORF_PREFIX_RM,            1, peer_change_reset },
     { PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED,  0, peer_change_reset_out },
-    { PEER_FLAG_NEXTHOP_SELF_ALL,         1, peer_change_reset_out },
+    { PEER_FLAG_FORCE_NEXTHOP_SELF,       1, peer_change_reset_out },
     { PEER_FLAG_AS_OVERRIDE,              1, peer_change_reset_out },
     { 0, 0, 0 }
   };
@@ -6246,11 +6246,13 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
             VTY_NEWLINE);
 
   /* Nexthop self. */
-  if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)
+  if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_FORCE_NEXTHOP_SELF)
       && ! peer->af_group[afi][safi])
-    vty_out (vty, " neighbor %s next-hop-self%s%s", addr,
-            peer_af_flag_check (peer, afi, safi, PEER_FLAG_NEXTHOP_SELF_ALL) ?
-            " all" : "", VTY_NEWLINE);
+    vty_out (vty, " neighbor %s next-hop-self force%s",
+            addr, VTY_NEWLINE);
+  else if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_NEXTHOP_SELF)
+      && ! peer->af_group[afi][safi])
+    vty_out (vty, " neighbor %s next-hop-self%s", addr, VTY_NEWLINE);
 
   /* remove-private-AS */
   if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS) && !peer->af_group[afi][safi])
index 5c9457feac7d407d4ea864ffe6395ada45c3149a..95939fe0a8cb7c114f93e74a0827e674bc476a0b 100644 (file)
@@ -637,7 +637,7 @@ struct peer
 #define PEER_FLAG_MAX_PREFIX                (1 << 14) /* maximum prefix */
 #define PEER_FLAG_MAX_PREFIX_WARNING        (1 << 15) /* maximum prefix warning-only */
 #define PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED   (1 << 16) /* leave link-local nexthop unchanged */
-#define PEER_FLAG_NEXTHOP_SELF_ALL          (1 << 17) /* next-hop-self all */
+#define PEER_FLAG_FORCE_NEXTHOP_SELF        (1 << 17) /* next-hop-self force */
 #define PEER_FLAG_REMOVE_PRIVATE_AS_ALL     (1 << 18) /* remove-private-as all */
 #define PEER_FLAG_REMOVE_PRIVATE_AS_REPLACE (1 << 19) /* remove-private-as replace-as */
 #define PEER_FLAG_AS_OVERRIDE               (1 << 20) /* as-override */