mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 00:41:20 +00:00
bgpd: merge branch tteras/master~3 (b304dcb
)
route-map tidying + next-hop-self all Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
commit
0ff692ed59
@ -976,7 +976,8 @@ bgp_announce_check (struct bgp_info *ri, struct peer *peer, struct prefix *p,
|
||||
}
|
||||
|
||||
/* next-hop-set */
|
||||
if (transparent || reflect
|
||||
if (transparent
|
||||
|| (reflect && ! CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_SELF_ALL))
|
||||
|| (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_NEXTHOP_UNCHANGED)
|
||||
&& ((p->family == AF_INET && attr->nexthop.s_addr)
|
||||
#ifdef HAVE_IPV6
|
||||
|
@ -93,7 +93,7 @@ o Cisco route-map
|
||||
tag : (This will not be implemented by bgpd)
|
||||
weight : Done
|
||||
|
||||
o Local extention
|
||||
o Local extensions
|
||||
|
||||
set ipv6 next-hop global: Done
|
||||
set ipv6 next-hop local : Done
|
||||
@ -101,6 +101,26 @@ o Local extention
|
||||
|
||||
*/
|
||||
|
||||
/* 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
|
||||
@ -1228,33 +1248,13 @@ route_set_aspath_prepend (void *rule, struct prefix *prefix, route_map_object_t
|
||||
return RMAP_OKAY;
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
/* Set as-path prepend rule structure. */
|
||||
struct route_map_rule_cmd route_set_aspath_prepend_cmd =
|
||||
{
|
||||
"as-path prepend",
|
||||
route_set_aspath_prepend,
|
||||
route_set_aspath_prepend_compile,
|
||||
route_set_aspath_prepend_free,
|
||||
route_aspath_compile,
|
||||
route_aspath_free,
|
||||
};
|
||||
|
||||
/* `set as-path exclude ASn' */
|
||||
@ -1282,37 +1282,13 @@ 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_set_aspath_exclude_compile,
|
||||
route_set_aspath_exclude_free,
|
||||
route_aspath_compile,
|
||||
route_aspath_free,
|
||||
};
|
||||
|
||||
/* `set community COMMUNITY' */
|
||||
@ -1705,7 +1681,7 @@ route_set_origin_free (void *rule)
|
||||
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
||||
}
|
||||
|
||||
/* Set metric rule structure. */
|
||||
/* Set origin rule structure. */
|
||||
struct route_map_rule_cmd route_set_origin_cmd =
|
||||
{
|
||||
"origin",
|
||||
@ -2191,7 +2167,7 @@ route_set_originator_id_free (void *rule)
|
||||
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
|
||||
}
|
||||
|
||||
/* Set metric rule structure. */
|
||||
/* Set originator-id rule structure. */
|
||||
struct route_map_rule_cmd route_set_originator_id_cmd =
|
||||
{
|
||||
"originator-id",
|
||||
|
@ -2093,25 +2093,41 @@ DEFUN (no_neighbor_capability_orf_prefix,
|
||||
/* neighbor next-hop-self. */
|
||||
DEFUN (neighbor_nexthop_self,
|
||||
neighbor_nexthop_self_cmd,
|
||||
NEIGHBOR_CMD2 "next-hop-self",
|
||||
NEIGHBOR_CMD2 "next-hop-self {all}",
|
||||
NEIGHBOR_STR
|
||||
NEIGHBOR_ADDR_STR2
|
||||
"Disable the next hop calculation for this neighbor\n")
|
||||
"Disable the next hop calculation for this neighbor\n"
|
||||
"Apply also to ibgp-learned routes when acting as a route reflector\n")
|
||||
{
|
||||
return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty),
|
||||
bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
DEFUN (no_neighbor_nexthop_self,
|
||||
no_neighbor_nexthop_self_cmd,
|
||||
NO_NEIGHBOR_CMD2 "next-hop-self",
|
||||
NO_NEIGHBOR_CMD2 "next-hop-self {all}",
|
||||
NO_STR
|
||||
NEIGHBOR_STR
|
||||
NEIGHBOR_ADDR_STR2
|
||||
"Disable the next hop calculation for this neighbor\n")
|
||||
"Disable the next hop calculation for this neighbor\n"
|
||||
"Apply also to ibgp-learned routes when acting as a route reflector\n")
|
||||
{
|
||||
return peer_af_flag_unset_vty (vty, argv[0], bgp_node_afi (vty),
|
||||
bgp_node_safi (vty), PEER_FLAG_NEXTHOP_SELF);
|
||||
bgp_node_safi (vty),
|
||||
PEER_FLAG_NEXTHOP_SELF|PEER_FLAG_NEXTHOP_SELF_ALL);
|
||||
}
|
||||
|
||||
/* neighbor remove-private-AS. */
|
||||
|
@ -2355,6 +2355,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 },
|
||||
{ 0, 0, 0 }
|
||||
};
|
||||
|
||||
@ -4990,7 +4991,9 @@ bgp_config_write_peer (struct vty *vty, struct bgp *bgp,
|
||||
/* Nexthop self. */
|
||||
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);
|
||||
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);
|
||||
|
||||
/* Remove private AS. */
|
||||
if (peer_af_flag_check (peer, afi, safi, PEER_FLAG_REMOVE_PRIVATE_AS)
|
||||
|
@ -412,6 +412,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 */
|
||||
|
||||
/* MD5 password */
|
||||
char *password;
|
||||
|
@ -299,10 +299,12 @@ This command is deprecated and may be removed in a future release. Its
|
||||
use should be avoided.
|
||||
@end deffn
|
||||
|
||||
@deffn {BGP} {neighbor @var{peer} next-hop-self} {}
|
||||
@deffnx {BGP} {no neighbor @var{peer} next-hop-self} {}
|
||||
@deffn {BGP} {neighbor @var{peer} next-hop-self [all]} {}
|
||||
@deffnx {BGP} {no neighbor @var{peer} next-hop-self [all]} {}
|
||||
This command specifies an announced route's nexthop as being equivalent
|
||||
to the address of the bgp router.
|
||||
to the address of the bgp router if it is learned via eBGP.
|
||||
If the optional keyword @code{all} is specified the modifiation is done
|
||||
also for routes learned via iBGP.
|
||||
@end deffn
|
||||
|
||||
@deffn {BGP} {neighbor @var{peer} update-source @var{<ifname|address>}} {}
|
||||
|
Loading…
Reference in New Issue
Block a user