Merge remote-tracking branch 'origin/cmaster' into cmaster-next

This commit is contained in:
Donald Sharp 2016-08-07 20:56:35 -04:00
commit cbca9a189c
10 changed files with 156 additions and 22 deletions

View File

@ -99,6 +99,9 @@ struct attr_extra
/* MP Nexthop length */ /* MP Nexthop length */
u_char mp_nexthop_len; u_char mp_nexthop_len;
/* MP Nexthop preference */
u_char mp_nexthop_prefer_global;
/* route tag */ /* route tag */
u_short tag; u_short tag;

View File

@ -317,6 +317,7 @@ bgp_vrf_enable (vrf_id_t vrf_id, const char *name, void **info)
{ {
struct vrf *vrf; struct vrf *vrf;
struct bgp *bgp; struct bgp *bgp;
vrf_id_t old_vrf_id;
vrf = vrf_lookup (vrf_id); vrf = vrf_lookup (vrf_id);
if (!vrf) // unexpected if (!vrf) // unexpected
@ -328,8 +329,13 @@ bgp_vrf_enable (vrf_id_t vrf_id, const char *name, void **info)
bgp = bgp_lookup_by_name(name); bgp = bgp_lookup_by_name(name);
if (bgp) if (bgp)
{ {
old_vrf_id = bgp->vrf_id;
/* We have instance configured, link to VRF and make it "up". */ /* We have instance configured, link to VRF and make it "up". */
bgp_vrf_link (bgp, vrf); bgp_vrf_link (bgp, vrf);
/* Update any redistribute vrf bitmaps if the vrf_id changed */
if (old_vrf_id != bgp->vrf_id)
bgp_update_redist_vrf_bitmaps(bgp, old_vrf_id);
bgp_instance_up (bgp); bgp_instance_up (bgp);
} }
@ -341,6 +347,7 @@ bgp_vrf_disable (vrf_id_t vrf_id, const char *name, void **info)
{ {
struct vrf *vrf; struct vrf *vrf;
struct bgp *bgp; struct bgp *bgp;
vrf_id_t old_vrf_id;
if (vrf_id == VRF_DEFAULT) if (vrf_id == VRF_DEFAULT)
return 0; return 0;
@ -355,8 +362,12 @@ bgp_vrf_disable (vrf_id_t vrf_id, const char *name, void **info)
bgp = bgp_lookup_by_name(name); bgp = bgp_lookup_by_name(name);
if (bgp) if (bgp)
{ {
old_vrf_id = bgp->vrf_id;
/* We have instance configured, unlink from VRF and make it "down". */ /* We have instance configured, unlink from VRF and make it "down". */
bgp_vrf_unlink (bgp, vrf); bgp_vrf_unlink (bgp, vrf);
/* Update any redistribute vrf bitmaps if the vrf_id changed */
if (old_vrf_id != bgp->vrf_id)
bgp_update_redist_vrf_bitmaps(bgp, old_vrf_id);
bgp_instance_down (bgp); bgp_instance_down (bgp);
} }

View File

@ -5873,7 +5873,7 @@ route_vty_out (struct vty *vty, struct prefix *p,
vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); vty_out (vty, "%-16s", inet_ntoa (attr->nexthop));
} }
} }
#ifdef HAVE_IPV6
/* IPv6 Next Hop */ /* IPv6 Next Hop */
else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr))
{ {
@ -5901,8 +5901,9 @@ route_vty_out (struct vty *vty, struct prefix *p,
json_object_string_add(json_nexthop_ll, "afi", "ipv6"); json_object_string_add(json_nexthop_ll, "afi", "ipv6");
json_object_string_add(json_nexthop_ll, "scope", "link-local"); json_object_string_add(json_nexthop_ll, "scope", "link-local");
if (IPV6_ADDR_CMP (&attr->extra->mp_nexthop_global, if ((IPV6_ADDR_CMP (&attr->extra->mp_nexthop_global,
&attr->extra->mp_nexthop_local) != 0) &attr->extra->mp_nexthop_local) != 0) &&
!attr->extra->mp_nexthop_prefer_global)
json_object_boolean_true_add(json_nexthop_ll, "used"); json_object_boolean_true_add(json_nexthop_ll, "used");
else else
json_object_boolean_true_add(json_nexthop_global, "used"); json_object_boolean_true_add(json_nexthop_global, "used");
@ -5912,7 +5913,10 @@ route_vty_out (struct vty *vty, struct prefix *p,
} }
else else
{ {
if ((attr->extra->mp_nexthop_len == 32) || (binfo->peer->conf_if)) /* Display LL if LL/Global both in table unless prefer-global is set */
if (((attr->extra->mp_nexthop_len == 32) &&
!attr->extra->mp_nexthop_prefer_global) ||
(binfo->peer->conf_if))
{ {
if (binfo->peer->conf_if) if (binfo->peer->conf_if)
{ {
@ -5954,7 +5958,6 @@ route_vty_out (struct vty *vty, struct prefix *p,
} }
} }
} }
#endif /* HAVE_IPV6 */
/* MED/Metric */ /* MED/Metric */
if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC))
@ -6635,7 +6638,6 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
if (json_paths) if (json_paths)
json_object_string_add(json_nexthop_global, "afi", "ipv4"); json_object_string_add(json_nexthop_global, "afi", "ipv4");
} }
#ifdef HAVE_IPV6
else else
{ {
assert (attr->extra); assert (attr->extra);
@ -6654,8 +6656,6 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
buf, INET6_ADDRSTRLEN)); buf, INET6_ADDRSTRLEN));
} }
} }
#endif /* HAVE_IPV6 */
/* Display the IGP cost or 'inaccessible' */ /* Display the IGP cost or 'inaccessible' */
if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID)) if (! CHECK_FLAG (binfo->flags, BGP_INFO_VALID))
@ -6761,7 +6761,6 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
if (!json_paths) if (!json_paths)
vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "%s", VTY_NEWLINE);
#ifdef HAVE_IPV6
/* display the link-local nexthop */ /* display the link-local nexthop */
if (attr->extra && attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) if (attr->extra && attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
{ {
@ -6775,13 +6774,19 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
json_object_string_add(json_nexthop_ll, "scope", "link-local"); json_object_string_add(json_nexthop_ll, "scope", "link-local");
json_object_boolean_true_add(json_nexthop_ll, "accessible"); json_object_boolean_true_add(json_nexthop_ll, "accessible");
json_object_boolean_true_add(json_nexthop_ll, "used");
if (!attr->extra->mp_nexthop_prefer_global)
json_object_boolean_true_add(json_nexthop_ll, "used");
else
json_object_boolean_true_add(json_nexthop_global, "used");
} }
else else
{ {
vty_out (vty, " (%s) (used)%s", vty_out (vty, " (%s) %s%s",
inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local,
buf, INET6_ADDRSTRLEN), buf, INET6_ADDRSTRLEN),
attr->extra->mp_nexthop_prefer_global ?
"(prefer-global)" : "(used)",
VTY_NEWLINE); VTY_NEWLINE);
} }
} }
@ -6791,7 +6796,6 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p,
if (json_paths) if (json_paths)
json_object_boolean_true_add(json_nexthop_global, "used"); json_object_boolean_true_add(json_nexthop_global, "used");
} }
#endif /* HAVE_IPV6 */
/* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */ /* Line 3 display Origin, Med, Locpref, Weight, Tag, valid, Int/Ext/Local, Atomic, best */
if (json_paths) if (json_paths)

View File

@ -103,6 +103,7 @@ o Cisco route-map
o Local extensions o Local extensions
set ipv6 next-hop global: Done set ipv6 next-hop global: Done
set ipv6 next-hop prefer-global: Done
set ipv6 next-hop local : Done set ipv6 next-hop local : Done
set as-path exclude : Done set as-path exclude : Done
@ -2192,6 +2193,61 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_global_cmd =
route_set_ipv6_nexthop_global_free route_set_ipv6_nexthop_global_free
}; };
/* Set next-hop preference value. */
static route_map_result_t
route_set_ipv6_nexthop_prefer_global (void *rule, struct prefix *prefix,
route_map_object_t type, void *object)
{
struct bgp_info *bgp_info;
struct peer *peer;
if (type == RMAP_BGP)
{
/* Fetch routemap's rule information. */
bgp_info = object;
peer = bgp_info->peer;
if ((CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IN) ||
CHECK_FLAG (peer->rmap_type, PEER_RMAP_TYPE_IMPORT))
&& peer->su_remote
&& sockunion_family (peer->su_remote) == AF_INET6)
{
/* Set next hop preference to global */
bgp_info->attr->extra->mp_nexthop_prefer_global = TRUE;
SET_FLAG(bgp_info->attr->rmap_change_flags,
BATTR_RMAP_IPV6_GLOBAL_NHOP_CHANGED);
}
}
return RMAP_OKAY;
}
static void *
route_set_ipv6_nexthop_prefer_global_compile (const char *arg)
{
int *rins = NULL;
rins = XCALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (int));
*rins = 1;
return rins;
}
/* Free route map's compiled `ip next-hop' value. */
static void
route_set_ipv6_nexthop_prefer_global_free (void *rule)
{
XFREE (MTYPE_ROUTE_MAP_COMPILED, rule);
}
/* Route map commands for ip nexthop set preferred. */
struct route_map_rule_cmd route_set_ipv6_nexthop_prefer_global_cmd =
{
"ipv6 next-hop prefer-global",
route_set_ipv6_nexthop_prefer_global,
route_set_ipv6_nexthop_prefer_global_compile,
route_set_ipv6_nexthop_prefer_global_free
};
/* `set ipv6 nexthop local IP_ADDRESS' */ /* `set ipv6 nexthop local IP_ADDRESS' */
/* Set nexthop to object. ojbect must be pointer to struct attr. */ /* Set nexthop to object. ojbect must be pointer to struct attr. */
@ -4366,11 +4422,34 @@ DEFUN (no_set_ipv6_nexthop_peer,
SET_STR SET_STR
IPV6_STR IPV6_STR
"IPv6 next-hop address\n" "IPv6 next-hop address\n"
) "Use peer address (for BGP only)\n")
{ {
return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL); return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop peer-address", NULL);
} }
DEFUN (set_ipv6_nexthop_prefer_global,
set_ipv6_nexthop_prefer_global_cmd,
"set ipv6 next-hop prefer-global",
SET_STR
IPV6_STR
"IPv6 next-hop address\n"
"Prefer global over link-local if both exist\n")
{
return bgp_route_set_add (vty, vty->index, "ipv6 next-hop prefer-global", NULL);;
}
DEFUN (no_set_ipv6_nexthop_prefer_global,
no_set_ipv6_nexthop_prefer_global_cmd,
"no set ipv6 next-hop prefer-global",
NO_STR
SET_STR
IPV6_STR
"IPv6 next-hop address\n"
"Prefer global over link-local if both exist\n")
{
return bgp_route_set_delete (vty, vty->index, "ipv6 next-hop prefer-global", NULL);
}
DEFUN (set_ipv6_nexthop_global, DEFUN (set_ipv6_nexthop_global,
set_ipv6_nexthop_global_cmd, set_ipv6_nexthop_global_cmd,
"set ipv6 next-hop global X:X::X:X", "set ipv6 next-hop global X:X::X:X",
@ -4704,6 +4783,7 @@ bgp_route_map_init (void)
route_map_install_match (&route_match_ipv6_next_hop_cmd); route_map_install_match (&route_match_ipv6_next_hop_cmd);
route_map_install_match (&route_match_ipv6_address_prefix_list_cmd); route_map_install_match (&route_match_ipv6_address_prefix_list_cmd);
route_map_install_set (&route_set_ipv6_nexthop_global_cmd); route_map_install_set (&route_set_ipv6_nexthop_global_cmd);
route_map_install_set (&route_set_ipv6_nexthop_prefer_global_cmd);
route_map_install_set (&route_set_ipv6_nexthop_local_cmd); route_map_install_set (&route_set_ipv6_nexthop_local_cmd);
route_map_install_set (&route_set_ipv6_nexthop_peer_cmd); route_map_install_set (&route_set_ipv6_nexthop_peer_cmd);
@ -4716,6 +4796,8 @@ bgp_route_map_init (void)
install_element (RMAP_NODE, &set_ipv6_nexthop_global_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_global_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_val_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_global_val_cmd);
install_element (RMAP_NODE, &set_ipv6_nexthop_prefer_global_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_prefer_global_cmd);
install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_local_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_cmd);
install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_local_val_cmd);

View File

@ -1136,12 +1136,18 @@ bgp_info_to_ipv6_nexthop (struct bgp_info *info)
/* If both global and link-local address present. */ /* If both global and link-local address present. */
if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL) if (info->attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
{ {
/* Workaround for Cisco's nexthop bug. */ /* Check if route-map is set to prefer global over link-local */
if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->extra->mp_nexthop_global) if (info->attr->extra->mp_nexthop_prefer_global)
&& info->peer->su_remote->sa.sa_family == AF_INET6) nexthop = &info->attr->extra->mp_nexthop_global;
nexthop = &info->peer->su_remote->sin6.sin6_addr;
else else
nexthop = &info->attr->extra->mp_nexthop_local; {
/* Workaround for Cisco's nexthop bug. */
if (IN6_IS_ADDR_UNSPECIFIED (&info->attr->extra->mp_nexthop_global)
&& info->peer->su_remote->sa.sa_family == AF_INET6)
nexthop = &info->peer->su_remote->sin6.sin6_addr;
else
nexthop = &info->attr->extra->mp_nexthop_local;
}
} }
return nexthop; return nexthop;
@ -1959,6 +1965,24 @@ bgp_redistribute_unset (struct bgp *bgp, afi_t afi, int type, u_short instance)
return CMD_SUCCESS; return CMD_SUCCESS;
} }
/* Update redistribute vrf bitmap during triggers like
restart networking or delete/add VRFs */
void
bgp_update_redist_vrf_bitmaps (struct bgp *bgp, vrf_id_t old_vrf_id)
{
int i;
afi_t afi;
for (afi = AFI_IP; afi < AFI_MAX; afi++)
for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
if (vrf_bitmap_check (zclient->redist[afi][i], old_vrf_id))
{
vrf_bitmap_unset (zclient->redist[afi][i], old_vrf_id);
vrf_bitmap_set (zclient->redist[afi][i], bgp->vrf_id);
}
return;
}
void void
bgp_zclient_reset (void) bgp_zclient_reset (void)
{ {

View File

@ -1504,4 +1504,5 @@ bgp_vrf_unlink (struct bgp *bgp, struct vrf *vrf)
bgp->vrf_id = VRF_UNKNOWN; bgp->vrf_id = VRF_UNKNOWN;
} }
extern void bgp_update_redist_vrf_bitmaps (struct bgp*, vrf_id_t);
#endif /* _QUAGGA_BGPD_H */ #endif /* _QUAGGA_BGPD_H */

View File

@ -7,7 +7,7 @@
## ##
AC_PREREQ(2.60) AC_PREREQ(2.60)
AC_INIT(Quagga, 0.99.24+cl3u2, [https://bugzilla.quagga.net]) AC_INIT(Quagga, 0.99.24+cl3u3, [https://bugzilla.quagga.net])
CONFIG_ARGS="$*" CONFIG_ARGS="$*"
AC_SUBST(CONFIG_ARGS) AC_SUBST(CONFIG_ARGS)
AC_CONFIG_SRCDIR(lib/zebra.h) AC_CONFIG_SRCDIR(lib/zebra.h)

10
debian/changelog vendored
View File

@ -1,4 +1,12 @@
quagga (0.99.23.1-1+cl3u2) Release; urgency=medium quagga (0.99.24+cl3u3) RELEASED; urgency=medium
* New Enabled: Merge up-to 0.99.24 code from upstream
* New Enabled: Additional CLI simplification
* New Enabled: Various Bug Fixes
-- dev-support <dev-support@cumulusnetworks.com> Thu, 04 Aug 2016 08:43:36 -0700
quagga (0.99.23.1-1+cl3u2) RELEASED; urgency=medium
* New Enabled: VRF - See Documentation for how to use * New Enabled: VRF - See Documentation for how to use
* New Enabled: Improved interface statistics * New Enabled: Improved interface statistics

View File

@ -220,7 +220,7 @@ do { \
#define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \ #define VTY_GET_INTEGER_RANGE(NAME,V,STR,MIN,MAX) \
do { \ do { \
unsigned long tmpl; \ unsigned long long tmpl; \
VTY_GET_INTEGER_RANGE_HEART(NAME,tmpl,STR,MIN,MAX); \ VTY_GET_INTEGER_RANGE_HEART(NAME,tmpl,STR,MIN,MAX); \
(V) = tmpl; \ (V) = tmpl; \
} while (0) } while (0)

View File

@ -2133,6 +2133,7 @@ config_write_debug (struct vty *vty)
struct ospf *ospf; struct ospf *ospf;
char str[16]; char str[16];
memset (str, 0, 16);
if ((ospf = ospf_lookup()) == NULL) if ((ospf = ospf_lookup()) == NULL)
return CMD_SUCCESS; return CMD_SUCCESS;