summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2022-07-11 16:58:59 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2022-07-11 16:58:59 +0000
commit523ac84ec045a30b675a9a2cd433aedcdaa0c46a (patch)
treea5731c4f7f579e1d94ca8f89bd3f106de7ecd050 /usr.sbin/bgpd
parent53060c68c15f330b45fe7ff9df53bb40cb446b58 (diff)
Properly roll back in the add-path send case in up_dump_prefix()
When up_dump_prefix() runs out of space while filling out prefixes a possible path_id needs to be removed from the buf or else a corrupted UPDATE is sent out. OK tb@
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/rde_update.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c
index 9332136f757..49253b30e18 100644
--- a/usr.sbin/bgpd/rde_update.c
+++ b/usr.sbin/bgpd/rde_update.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_update.c,v 1.143 2022/07/11 16:55:21 claudio Exp $ */
+/* $OpenBSD: rde_update.c,v 1.144 2022/07/11 16:58:58 claudio Exp $ */
/*
* Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org>
@@ -675,8 +675,11 @@ up_dump_prefix(u_char *buf, int len, struct prefix_tree *prefix_head,
}
pt_getaddr(p->pt, &addr);
if ((r = prefix_write(buf + wpos, len - wpos,
- &addr, p->pt->prefixlen, withdraw)) == -1)
+ &addr, p->pt->prefixlen, withdraw)) == -1) {
+ if (peer_has_add_path(peer, p->pt->aid, CAPA_AP_SEND))
+ wpos -= sizeof(pathid);
break;
+ }
wpos += r;
/* make sure we only dump prefixes which belong together */
@@ -688,7 +691,6 @@ up_dump_prefix(u_char *buf, int len, struct prefix_tree *prefix_head,
(np->flags & PREFIX_FLAG_EOR))
done = 1;
-
if (withdraw) {
/* prefix no longer needed, remove it */
prefix_adjout_destroy(p);
@@ -700,6 +702,7 @@ up_dump_prefix(u_char *buf, int len, struct prefix_tree *prefix_head,
peer->up_nlricnt--;
peer->prefix_sent_update++;
}
+
if (done)
break;
}