mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-10 21:51:06 +00:00
Merge pull request #2876 from donaldsharp/lsa_new_and_data
ospfd: Add ospf_lsa_new_and_data function and abstract away
This commit is contained in:
commit
9e32cce03f
@ -1425,19 +1425,7 @@ struct ospf_lsa *ospf_apiserver_opaque_lsa_new(struct ospf_area *area,
|
|||||||
newlsa->length = htons(length);
|
newlsa->length = htons(length);
|
||||||
|
|
||||||
/* Create OSPF LSA. */
|
/* Create OSPF LSA. */
|
||||||
if ((new = ospf_lsa_new()) == NULL) {
|
new = ospf_lsa_new_and_data(length);
|
||||||
zlog_warn("ospf_apiserver_opaque_lsa_new: ospf_lsa_new() ?");
|
|
||||||
stream_free(s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((new->data = ospf_lsa_data_new(length)) == NULL) {
|
|
||||||
zlog_warn(
|
|
||||||
"ospf_apiserver_opaque_lsa_new: ospf_lsa_data_new() ?");
|
|
||||||
ospf_lsa_unlock(&new);
|
|
||||||
stream_free(s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
new->area = area;
|
new->area = area;
|
||||||
new->oi = oi;
|
new->oi = oi;
|
||||||
|
@ -977,20 +977,7 @@ static struct ospf_lsa *ospf_ext_pref_lsa_new(struct ospf_area *area,
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Now, create an OSPF LSA instance. */
|
/* Now, create an OSPF LSA instance. */
|
||||||
new = ospf_lsa_new();
|
new = ospf_lsa_new_and_data(length);
|
||||||
if (new == NULL) {
|
|
||||||
zlog_warn("EXT (%s): ospf_lsa_new() error", __func__);
|
|
||||||
stream_free(s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
new->data = ospf_lsa_data_new(length);
|
|
||||||
if (new->data == NULL) {
|
|
||||||
zlog_warn("EXT (%s): ospf_lsa_data_new() error", __func__);
|
|
||||||
ospf_lsa_unlock(&new);
|
|
||||||
new = NULL;
|
|
||||||
stream_free(s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Segment Routing belongs only to default VRF */
|
/* Segment Routing belongs only to default VRF */
|
||||||
new->vrf_id = VRF_DEFAULT;
|
new->vrf_id = VRF_DEFAULT;
|
||||||
@ -1056,20 +1043,7 @@ static struct ospf_lsa *ospf_ext_link_lsa_new(struct ospf_area *area,
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Now, create an OSPF LSA instance. */
|
/* Now, create an OSPF LSA instance. */
|
||||||
new = ospf_lsa_new();
|
new = ospf_lsa_new_and_data(length);
|
||||||
if (new == NULL) {
|
|
||||||
zlog_warn("EXT (%s): ospf_lsa_new() error", __func__);
|
|
||||||
stream_free(s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
new->data = ospf_lsa_data_new(length);
|
|
||||||
if (new->data == NULL) {
|
|
||||||
zlog_warn("EXT (%s): ospf_lsa_data_new() error", __func__);
|
|
||||||
ospf_lsa_unlock(&new);
|
|
||||||
new = NULL;
|
|
||||||
stream_free(s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Segment Routing belongs only to default VRF */
|
/* Segment Routing belongs only to default VRF */
|
||||||
new->vrf_id = VRF_DEFAULT;
|
new->vrf_id = VRF_DEFAULT;
|
||||||
|
@ -810,8 +810,7 @@ struct ospf_lsa *ospf_ls_request_new(struct lsa_header *lsah)
|
|||||||
{
|
{
|
||||||
struct ospf_lsa *new;
|
struct ospf_lsa *new;
|
||||||
|
|
||||||
new = ospf_lsa_new();
|
new = ospf_lsa_new_and_data(OSPF_LSA_HEADER_SIZE);
|
||||||
new->data = ospf_lsa_data_new(OSPF_LSA_HEADER_SIZE);
|
|
||||||
memcpy(new->data, lsah, OSPF_LSA_HEADER_SIZE);
|
memcpy(new->data, lsah, OSPF_LSA_HEADER_SIZE);
|
||||||
|
|
||||||
return new;
|
return new;
|
||||||
|
@ -167,6 +167,16 @@ struct ospf_lsa *ospf_lsa_new()
|
|||||||
return new;
|
return new;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct ospf_lsa *ospf_lsa_new_and_data(size_t size)
|
||||||
|
{
|
||||||
|
struct ospf_lsa *new;
|
||||||
|
|
||||||
|
new = ospf_lsa_new();
|
||||||
|
new->data = ospf_lsa_data_new(size);
|
||||||
|
|
||||||
|
return new;
|
||||||
|
}
|
||||||
|
|
||||||
/* Duplicate OSPF LSA. */
|
/* Duplicate OSPF LSA. */
|
||||||
struct ospf_lsa *ospf_lsa_dup(struct ospf_lsa *lsa)
|
struct ospf_lsa *ospf_lsa_dup(struct ospf_lsa *lsa)
|
||||||
{
|
{
|
||||||
@ -781,17 +791,13 @@ static struct ospf_lsa *ospf_router_lsa_new(struct ospf_area *area)
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Now, create OSPF LSA instance. */
|
/* Now, create OSPF LSA instance. */
|
||||||
if ((new = ospf_lsa_new()) == NULL) {
|
new = ospf_lsa_new_and_data(length);
|
||||||
zlog_err("%s: Unable to create new lsa", __func__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
new->area = area;
|
new->area = area;
|
||||||
SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
||||||
new->vrf_id = area->ospf->vrf_id;
|
new->vrf_id = area->ospf->vrf_id;
|
||||||
|
|
||||||
/* Copy LSA data to store, discard stream. */
|
/* Copy LSA data to store, discard stream. */
|
||||||
new->data = ospf_lsa_data_new(length);
|
|
||||||
memcpy(new->data, lsah, length);
|
memcpy(new->data, lsah, length);
|
||||||
stream_free(s);
|
stream_free(s);
|
||||||
|
|
||||||
@ -997,17 +1003,13 @@ static struct ospf_lsa *ospf_network_lsa_new(struct ospf_interface *oi)
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Create OSPF LSA instance. */
|
/* Create OSPF LSA instance. */
|
||||||
if ((new = ospf_lsa_new()) == NULL) {
|
new = ospf_lsa_new_and_data(length);
|
||||||
zlog_err("%s: ospf_lsa_new returned NULL", __func__);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
new->area = oi->area;
|
new->area = oi->area;
|
||||||
SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
||||||
new->vrf_id = oi->ospf->vrf_id;
|
new->vrf_id = oi->ospf->vrf_id;
|
||||||
|
|
||||||
/* Copy LSA to store. */
|
/* Copy LSA to store. */
|
||||||
new->data = ospf_lsa_data_new(length);
|
|
||||||
memcpy(new->data, lsah, length);
|
memcpy(new->data, lsah, length);
|
||||||
stream_free(s);
|
stream_free(s);
|
||||||
|
|
||||||
@ -1181,13 +1183,12 @@ static struct ospf_lsa *ospf_summary_lsa_new(struct ospf_area *area,
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Create OSPF LSA instance. */
|
/* Create OSPF LSA instance. */
|
||||||
new = ospf_lsa_new();
|
new = ospf_lsa_new_and_data(length);
|
||||||
new->area = area;
|
new->area = area;
|
||||||
SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
||||||
new->vrf_id = area->ospf->vrf_id;
|
new->vrf_id = area->ospf->vrf_id;
|
||||||
|
|
||||||
/* Copy LSA to store. */
|
/* Copy LSA to store. */
|
||||||
new->data = ospf_lsa_data_new(length);
|
|
||||||
memcpy(new->data, lsah, length);
|
memcpy(new->data, lsah, length);
|
||||||
stream_free(s);
|
stream_free(s);
|
||||||
|
|
||||||
@ -1323,13 +1324,12 @@ static struct ospf_lsa *ospf_summary_asbr_lsa_new(struct ospf_area *area,
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Create OSPF LSA instance. */
|
/* Create OSPF LSA instance. */
|
||||||
new = ospf_lsa_new();
|
new = ospf_lsa_new_and_data(length);
|
||||||
new->area = area;
|
new->area = area;
|
||||||
SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
SET_FLAG(new->flags, OSPF_LSA_SELF | OSPF_LSA_SELF_CHECKED);
|
||||||
new->vrf_id = area->ospf->vrf_id;
|
new->vrf_id = area->ospf->vrf_id;
|
||||||
|
|
||||||
/* Copy LSA to store. */
|
/* Copy LSA to store. */
|
||||||
new->data = ospf_lsa_data_new(length);
|
|
||||||
memcpy(new->data, lsah, length);
|
memcpy(new->data, lsah, length);
|
||||||
stream_free(s);
|
stream_free(s);
|
||||||
|
|
||||||
@ -1629,14 +1629,13 @@ static struct ospf_lsa *ospf_external_lsa_new(struct ospf *ospf,
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Now, create OSPF LSA instance. */
|
/* Now, create OSPF LSA instance. */
|
||||||
new = ospf_lsa_new();
|
new = ospf_lsa_new_and_data(length);
|
||||||
new->area = NULL;
|
new->area = NULL;
|
||||||
SET_FLAG(new->flags,
|
SET_FLAG(new->flags,
|
||||||
OSPF_LSA_SELF | OSPF_LSA_APPROVED | OSPF_LSA_SELF_CHECKED);
|
OSPF_LSA_SELF | OSPF_LSA_APPROVED | OSPF_LSA_SELF_CHECKED);
|
||||||
new->vrf_id = ospf->vrf_id;
|
new->vrf_id = ospf->vrf_id;
|
||||||
|
|
||||||
/* Copy LSA data to store, discard stream. */
|
/* Copy LSA data to store, discard stream. */
|
||||||
new->data = ospf_lsa_data_new(length);
|
|
||||||
memcpy(new->data, lsah, length);
|
memcpy(new->data, lsah, length);
|
||||||
stream_free(s);
|
stream_free(s);
|
||||||
|
|
||||||
|
@ -235,6 +235,7 @@ extern int ospf_check_nbr_status(struct ospf *);
|
|||||||
|
|
||||||
/* Prototype for LSA primitive. */
|
/* Prototype for LSA primitive. */
|
||||||
extern struct ospf_lsa *ospf_lsa_new(void);
|
extern struct ospf_lsa *ospf_lsa_new(void);
|
||||||
|
extern struct ospf_lsa *ospf_lsa_new_and_data(size_t size);
|
||||||
extern struct ospf_lsa *ospf_lsa_dup(struct ospf_lsa *);
|
extern struct ospf_lsa *ospf_lsa_dup(struct ospf_lsa *);
|
||||||
extern void ospf_lsa_free(struct ospf_lsa *);
|
extern void ospf_lsa_free(struct ospf_lsa *);
|
||||||
extern struct ospf_lsa *ospf_lsa_lock(struct ospf_lsa *);
|
extern struct ospf_lsa *ospf_lsa_lock(struct ospf_lsa *);
|
||||||
|
@ -1742,7 +1742,7 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create OSPF LSA instance. */
|
/* Create OSPF LSA instance. */
|
||||||
lsa = ospf_lsa_new();
|
lsa = ospf_lsa_new_and_data(length);
|
||||||
|
|
||||||
lsa->vrf_id = oi->ospf->vrf_id;
|
lsa->vrf_id = oi->ospf->vrf_id;
|
||||||
/* We may wish to put some error checking if type NSSA comes in
|
/* We may wish to put some error checking if type NSSA comes in
|
||||||
@ -1761,7 +1761,6 @@ static struct list *ospf_ls_upd_list_lsa(struct ospf_neighbor *nbr,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
lsa->data = ospf_lsa_data_new(length);
|
|
||||||
memcpy(lsa->data, lsah, length);
|
memcpy(lsa->data, lsah, length);
|
||||||
|
|
||||||
if (IS_DEBUG_OSPF_EVENT)
|
if (IS_DEBUG_OSPF_EVENT)
|
||||||
|
@ -775,18 +775,7 @@ static struct ospf_lsa *ospf_router_info_lsa_new()
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Now, create an OSPF LSA instance. */
|
/* Now, create an OSPF LSA instance. */
|
||||||
if ((new = ospf_lsa_new()) == NULL) {
|
new = ospf_lsa_new_and_data(length);
|
||||||
zlog_warn("ospf_router_info_lsa_new: ospf_lsa_new() ?");
|
|
||||||
stream_free(s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if ((new->data = ospf_lsa_data_new(length)) == NULL) {
|
|
||||||
zlog_warn("ospf_router_info_lsa_new: ospf_lsa_data_new() ?");
|
|
||||||
ospf_lsa_unlock(&new);
|
|
||||||
new = NULL;
|
|
||||||
stream_free(s);
|
|
||||||
return new;
|
|
||||||
}
|
|
||||||
|
|
||||||
new->area = OspfRI.area; /* Area must be null if the Opaque type is AS
|
new->area = OspfRI.area; /* Area must be null if the Opaque type is AS
|
||||||
scope, fulfill otherwise */
|
scope, fulfill otherwise */
|
||||||
|
@ -1201,18 +1201,7 @@ static struct ospf_lsa *ospf_mpls_te_lsa_new(struct ospf *ospf,
|
|||||||
lsah->length = htons(length);
|
lsah->length = htons(length);
|
||||||
|
|
||||||
/* Now, create an OSPF LSA instance. */
|
/* Now, create an OSPF LSA instance. */
|
||||||
if ((new = ospf_lsa_new()) == NULL) {
|
new = ospf_lsa_new_and_data(length);
|
||||||
zlog_warn("%s: ospf_lsa_new() ?", __func__);
|
|
||||||
stream_free(s);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
if ((new->data = ospf_lsa_data_new(length)) == NULL) {
|
|
||||||
zlog_warn("%s: ospf_lsa_data_new() ?", __func__);
|
|
||||||
ospf_lsa_unlock(&new);
|
|
||||||
new = NULL;
|
|
||||||
stream_free(s);
|
|
||||||
return new;
|
|
||||||
}
|
|
||||||
|
|
||||||
new->vrf_id = ospf->vrf_id;
|
new->vrf_id = ospf->vrf_id;
|
||||||
if (area && area->ospf)
|
if (area && area->ospf)
|
||||||
|
Loading…
Reference in New Issue
Block a user