summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
authorJorge Boncompte [DTI2] <jorge@dti2.net>2012-05-07 16:53:03 +0000
committerDavid Lamparter <equinox@opensourcerouting.org>2012-05-22 20:25:49 +0200
commit489d005a9ad94675f40dc7bceff6176cfad36d45 (patch)
treec11edc9588fc1fd4ccef33f168a7367d0a34db65 /bgpd
parent6182d65b23fc0362b173e2a9314fa4551523a1c2 (diff)
bgpd: use on stack struct attr_extra in bgp_update_receive()
Reduce memory heap fragmentation and pressure on the memory allocator. Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_packet.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c
index 95ed8046..cfa0b57c 100644
--- a/bgpd/bgp_packet.c
+++ b/bgpd/bgp_packet.c
@@ -1519,6 +1519,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
u_char *end;
struct stream *s;
struct attr attr;
+ struct attr_extra extra;
bgp_size_t attribute_len;
bgp_size_t update_len;
bgp_size_t withdraw_len;
@@ -1538,10 +1539,12 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
/* Set initial values. */
memset (&attr, 0, sizeof (struct attr));
+ memset (&extra, 0, sizeof (struct attr_extra));
memset (&update, 0, sizeof (struct bgp_nlri));
memset (&withdraw, 0, sizeof (struct bgp_nlri));
memset (&mp_update, 0, sizeof (struct bgp_nlri));
memset (&mp_withdraw, 0, sizeof (struct bgp_nlri));
+ attr.extra = &extra;
s = peer->ibuf;
end = stream_pnt (s) + size;
@@ -1669,8 +1672,6 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
if (ret < 0)
{
bgp_attr_unintern_sub (&attr);
- if (attr.extra)
- bgp_attr_extra_free (&attr);
return -1;
}
@@ -1697,8 +1698,6 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
if (ret < 0)
{
bgp_attr_unintern_sub (&attr);
- if (attr.extra)
- bgp_attr_extra_free (&attr);
return -1;
}
@@ -1845,9 +1844,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size)
/* Everything is done. We unintern temporary structures which
interned in bgp_attr_parse(). */
bgp_attr_unintern_sub (&attr);
- if (attr.extra)
- bgp_attr_extra_free (&attr);
-
+
/* If peering is stopped due to some reason, do not generate BGP
event. */
if (peer->status != Established)