summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2015-07-22 22:18:24 +0200
committerDonald Sharp <sharpd@cumulusnetworks.com>2015-07-22 22:18:24 +0200
commita538debe669cf669ec84eda2fc20d4bbcd8456c3 (patch)
treeca5b17397752815d45cb96ecd4621c5faeea882c
parentFixup of some last remaining differences between stg and git (diff)
downloadfrr-a538debe669cf669ec84eda2fc20d4bbcd8456c3.tar.xz
frr-a538debe669cf669ec84eda2fc20d4bbcd8456c3.zip
Cleanup of missing NEXTHOP_FORCE_SELF
-rw-r--r--bgpd/bgp_routemap.c80
-rw-r--r--bgpd/bgp_vty.c69
-rw-r--r--bgpd/bgpd.c12
-rw-r--r--bgpd/bgpd.h2
4 files changed, 107 insertions, 56 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 817865418..78c58de8e 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -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",
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index c69ef0831..625473b25 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -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);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 5ef07f0c4..53756cb89 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -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])
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 5c9457fea..95939fe0a 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -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 */