summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss White <russ@riw.us>2018-07-31 21:09:06 -0400
committerGitHub <noreply@github.com>2018-07-31 21:09:06 -0400
commita111e0ac23f370938a96a7dea2c093dc4ea47b60 (patch)
tree54488b71d2efd3b1344822f7fb2b3ab387993fa2
parent22bc293f9058b9b1a34c5124d4c0504d27bdaa47 (diff)
parentc2e10422033771da9f12a4a283b0bc767240a3d8 (diff)
Merge pull request #2755 from ton31337/feature/default-originate_apply_route-maps
bgpd: Make sure default-originate works without route-map as well
-rw-r--r--bgpd/bgp_updgrp_adv.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c
index 1f80470f59..f44e95a50a 100644
--- a/bgpd/bgp_updgrp_adv.c
+++ b/bgpd/bgp_updgrp_adv.c
@@ -662,6 +662,7 @@ void subgroup_announce_route(struct update_subgroup *subgrp)
void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
{
struct bgp *bgp;
+ struct attr attr;
struct bgp_info *info, init_info;
struct prefix p;
struct peer *from;
@@ -685,8 +686,23 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
bgp = peer->bgp;
from = bgp->peer_self;
- init_info.attr = NULL;
+ bgp_attr_default_set(&attr, BGP_ORIGIN_IGP);
+ attr.local_pref = bgp->default_local_pref;
+
+ if ((afi == AFI_IP6) || peer_cap_enhe(peer, afi, safi)) {
+ /* IPv6 global nexthop must be included.
+ */
+ attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL;
+
+ /* If the peer is on shared nextwork and
+ * we have link-local nexthop set it. */
+ if (peer->shared_network
+ && !IN6_IS_ADDR_UNSPECIFIED(&peer->nexthop.v6_local))
+ attr.mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
+ }
+ init_info.attr = &attr;
info = &init_info;
+ bgp_attr_intern(info->attr);
memset(&p, 0, sizeof(p));
p.family = afi2family(afi);
@@ -709,13 +725,9 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
if ((afi == AFI_IP6)
|| peer_cap_enhe(peer, afi, safi)) {
- /* IPv6 global nexthop must be included.
- */
tmp_info.attr->mp_nexthop_len =
BGP_ATTR_NHLEN_IPV6_GLOBAL;
- /* If the peer is on shared nextwork and
- * we have link-local nexthop set it. */
if (peer->shared_network
&& !IN6_IS_ADDR_UNSPECIFIED(
&peer->nexthop.v6_local))
@@ -728,6 +740,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
&rn->p, RMAP_BGP, &tmp_info);
info = &tmp_info;
+ bgp_attr_intern(info->attr);
if (ret != RMAP_DENYMATCH)
break;
@@ -776,6 +789,7 @@ void subgroup_default_originate(struct update_subgroup *subgrp, int withdraw)
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
}
}
+ aspath_unintern(&info->attr->aspath);
}
/*