summaryrefslogtreecommitdiffstats
path: root/bgpd
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2015-05-22 13:40:57 +0300
committerDavid Lamparter <equinox@opensourcerouting.org>2015-05-29 07:30:44 +0200
commitc1c69e43cda64122b599746df4d1c6c5d8b52e37 (patch)
treecccc035647931b79657438087f92bc6a387aae96 /bgpd
parent80c9354835bb924983d12b0efad957e78f219287 (diff)
downloadquagga-c1c69e43cda64122b599746df4d1c6c5d8b52e37.tar.bz2
quagga-c1c69e43cda64122b599746df4d1c6c5d8b52e37.tar.xz
lib: allow caller to provide prefix storage in sockunion2hostprefix
Avoids a dynamic allocation which is usually freed immediate afterwards. Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_network.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c
index cea430cc..97650964 100644
--- a/bgpd/bgp_network.c
+++ b/bgpd/bgp_network.c
@@ -304,28 +304,27 @@ static int
bgp_update_address (struct interface *ifp, const union sockunion *dst,
union sockunion *addr)
{
- struct prefix *p, *sel, *d;
+ struct prefix *p, *sel, d;
struct connected *connected;
struct listnode *node;
int common;
- d = sockunion2hostprefix (dst);
+ sockunion2hostprefix (dst, &d);
sel = NULL;
common = -1;
for (ALL_LIST_ELEMENTS_RO (ifp->connected, node, connected))
{
p = connected->address;
- if (p->family != d->family)
+ if (p->family != d.family)
continue;
- if (prefix_common_bits (p, d) > common)
+ if (prefix_common_bits (p, &d) > common)
{
sel = p;
- common = prefix_common_bits (sel, d);
+ common = prefix_common_bits (sel, &d);
}
}
- prefix_free (d);
if (!sel)
return 1;