From 9591da265339577c67a6f8083cdce4ac73070724 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 6 Apr 2019 20:08:34 -0400 Subject: [PATCH] bgpd: Remove extra alloc function bgp_path_info_new The bgp_path_info_new function whenever it was called pretty much duplicated the info_make function call. So convert over to using it and remove the bgp_path_info_new function so people are not tempted. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 6 ------ bgpd/bgp_route.h | 1 - bgpd/rfapi/rfapi.c | 8 +------- bgpd/rfapi/rfapi_import.c | 14 +++++--------- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 555a085522..e8a8e56150 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -239,12 +239,6 @@ struct bgp_path_info_extra *bgp_path_info_extra_get(struct bgp_path_info *pi) return pi->extra; } -/* Allocate new bgp info structure. */ -struct bgp_path_info *bgp_path_info_new(void) -{ - return XCALLOC(MTYPE_BGP_ROUTE, sizeof(struct bgp_path_info)); -} - /* Free bgp route information. */ static void bgp_path_info_free(struct bgp_path_info *path) { diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h index fc5bf0c755..a559a6b58c 100644 --- a/bgpd/bgp_route.h +++ b/bgpd/bgp_route.h @@ -564,7 +564,6 @@ extern void bgp_process_queues_drain_immediate(void); extern struct bgp_node *bgp_afi_node_lookup(struct bgp_table *table, afi_t afi, safi_t safi, struct prefix *p, struct prefix_rd *prd); -extern struct bgp_path_info *bgp_path_info_new(void); extern void bgp_path_info_restore(struct bgp_node *rn, struct bgp_path_info *path); diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index a41473fa4f..5525547454 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -1059,14 +1059,8 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ } } - - new = bgp_path_info_new(); - new->type = type; - new->sub_type = sub_type; - new->peer = rfd->peer; + new = info_make(type, sub_type, 0, rfd->peer, new_attr, NULL); SET_FLAG(new->flags, BGP_PATH_VALID); - new->attr = new_attr; - new->uptime = bgp_clock(); /* save backref to rfapi handle */ assert(bgp_path_info_extra_get(new)); diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 93729c1476..568f8d68e8 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -509,13 +509,11 @@ static struct bgp_path_info *rfapiBgpInfoCreate(struct attr *attr, { struct bgp_path_info *new; - new = bgp_path_info_new(); - assert(new); + new = info_make(type, sub_type, 0, peer, attr, NULL); + + if (attr) + new->attr = bgp_attr_intern(attr); - if (attr) { - if (!new->attr) - new->attr = bgp_attr_intern(attr); - } bgp_path_info_extra_get(new); if (prd) { new->extra->vnc.import.rd = *prd; @@ -523,9 +521,7 @@ static struct bgp_path_info *rfapiBgpInfoCreate(struct attr *attr, } if (label) encode_label(*label, &new->extra->label[0]); - new->type = type; - new->sub_type = sub_type; - new->peer = peer; + peer_lock(peer); return new; -- 2.39.5