diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/bgp/attrs.c | 14 | ||||
-rw-r--r-- | proto/bgp/bgp.c | 4 | ||||
-rw-r--r-- | proto/ospf/rt.c | 20 | ||||
-rw-r--r-- | proto/ospf/rt.h | 1 |
4 files changed, 29 insertions, 10 deletions
diff --git a/proto/bgp/attrs.c b/proto/bgp/attrs.c index d5bf2add..73318c6a 100644 --- a/proto/bgp/attrs.c +++ b/proto/bgp/attrs.c @@ -1224,6 +1224,15 @@ bgp_init_prefix_table(struct bgp_channel *c) c->prefix_slab = alen ? sl_new(c->pool, sizeof(struct bgp_prefix) + alen) : NULL; } +void +bgp_free_prefix_table(struct bgp_channel *c) +{ + HASH_FREE(c->prefix_hash); + + rfree(c->prefix_slab); + c->prefix_slab = NULL; +} + static struct bgp_prefix * bgp_get_prefix(struct bgp_channel *c, net_addr *net, u32 path_id) { @@ -1323,6 +1332,7 @@ bgp_import_control(struct proto *P, rte **new, ea_list **attrs UNUSED, struct li return 0; } + static adata null_adata; /* adata of length 0 */ static ea_list * @@ -1394,11 +1404,11 @@ bgp_update_attrs(struct bgp_proto *p, struct bgp_channel *c, rte *e, ea_list *at /* Prepend src cluster ID */ if (src->rr_cluster_id) - ad = int_set_add(pool, ad, src->rr_cluster_id); + ad = int_set_prepend(pool, ad, src->rr_cluster_id); /* Prepend dst cluster ID if src and dst clusters are different */ if (p->rr_cluster_id && (src->rr_cluster_id != p->rr_cluster_id)) - ad = int_set_add(pool, ad, p->rr_cluster_id); + ad = int_set_prepend(pool, ad, p->rr_cluster_id); /* Should be at least one prepended cluster ID */ bgp_set_attr_ptr(&attrs, pool, BA_CLUSTER_LIST, 0, ad); diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c index 61d24f42..5e95e6b4 100644 --- a/proto/bgp/bgp.c +++ b/proto/bgp/bgp.c @@ -559,6 +559,10 @@ bgp_conn_leave_established_state(struct bgp_proto *p) BGP_TRACE(D_EVENTS, "BGP session closed"); p->conn = NULL; + // XXXX free these tables to avoid memory leak during graceful restart + // bgp_free_prefix_table(p); + // bgp_free_bucket_table(p); + if (p->p.proto_state == PS_UP) bgp_stop(p, 0); } diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c index 054841ca..49167ceb 100644 --- a/proto/ospf/rt.c +++ b/proto/ospf/rt.c @@ -422,10 +422,9 @@ add_network(struct ospf_area *oa, net_addr *net, int metric, struct top_hash_ent if (en == oa->rt) { /* - * Local stub networks does not have proper iface in en->nhi - * (because they all have common top_hash_entry en). - * We have to find iface responsible for that stub network. - * Configured stubnets does not have any iface. They will + * Local stub networks do not have proper iface in en->nhi (because they all + * have common top_hash_entry en). We have to find iface responsible for + * that stub network. Configured stubnets do not have any iface. They will * be removed in rt_sync(). */ @@ -1429,7 +1428,6 @@ ospf_ext_spf(struct ospf_proto *p) struct top_hash_entry *en; struct ospf_lsa_ext_local rt; ort *nf1, *nf2; - orta nfa = {}; u32 br_metric; struct ospf_area *atmp; @@ -1437,6 +1435,8 @@ ospf_ext_spf(struct ospf_proto *p) WALK_SLIST(en, p->lsal) { + orta nfa = {}; + /* 16.4. (1) */ if ((en->lsa_type != LSA_T_EXT) && (en->lsa_type != LSA_T_NSSA)) continue; @@ -1578,6 +1578,7 @@ ospf_rt_reset(struct ospf_proto *p) FIB_WALK(&p->rtf, ort, ri) { ri->area_net = 0; + ri->keep = 0; reset_ri(ri); } FIB_WALK_END; @@ -1941,9 +1942,12 @@ again1: } } - /* Remove configured stubnets */ - if (!nf->n.nhs) + /* Remove configured stubnets but keep the entries */ + if (nf->n.type && !nf->n.nhs) + { reset_ri(nf); + nf->keep = 1; + } if (nf->n.type) /* Add the route */ { @@ -1999,7 +2003,7 @@ again1: } /* Remove unused rt entry, some special entries are persistent */ - if (!nf->n.type && !nf->external_rte && !nf->area_net) + if (!nf->n.type && !nf->external_rte && !nf->area_net && !nf->keep) { if (nf->lsa_id) idm_free(&p->idm, nf->lsa_id); diff --git a/proto/ospf/rt.h b/proto/ospf/rt.h index 959d12e9..118d09b7 100644 --- a/proto/ospf/rt.h +++ b/proto/ospf/rt.h @@ -84,6 +84,7 @@ typedef struct ort u32 lsa_id; u8 external_rte; u8 area_net; + u8 keep; struct fib_node fn; } |