From 335409248ea932e93ce4361564b8e92d0b83b071 Mon Sep 17 00:00:00 2001 From: Maria Matejka Date: Thu, 20 Apr 2023 19:33:00 +0200 Subject: [PATCH 1/2] Linpool: Fix lp_restore() When lp_save() is called on an empty linpool, then some allocation is done, then lp_restore() is called, the linpool is restored but the used chunks are inaccessible. Fix it. --- lib/mempool.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/mempool.c b/lib/mempool.c index 7c306e99..9d4404f7 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -240,9 +240,9 @@ lp_restore(linpool *m, lp_state *p) struct lp_chunk *c; /* Move ptr to the saved pos and free all newer large chunks */ - m->current = c = p->current; - m->ptr = p->ptr; - m->end = c ? c->data + LP_DATA_SIZE : NULL; + m->current = c = p->current ?: m->first; + m->ptr = p->ptr ?: (c ? c->data : NULL); + m->end = c ? (c->data + LP_DATA_SIZE) : NULL; m->total_large = p->total_large; while ((c = m->first_large) && (c != p->large)) From d61505b039bf0aa6697e28b2a4e07907c89ba1fb Mon Sep 17 00:00:00 2001 From: Luiz Amaral Date: Fri, 21 Apr 2023 01:37:30 +0200 Subject: [PATCH 2/2] BSD: IPv4 over IPv6 nexthop support on FreeBSD The support for IPv4 routes with IPv6 nexthops was implemented in FreeBSD 13.1, this patch allows to import and export such routes from/to kernel. Minor change from committer. --- sysdep/bsd/krt-sock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdep/bsd/krt-sock.c b/sysdep/bsd/krt-sock.c index 1f793293..d13e20a3 100644 --- a/sysdep/bsd/krt-sock.c +++ b/sysdep/bsd/krt-sock.c @@ -314,7 +314,7 @@ krt_send_route(struct krt_proto *p, int cmd, rte *e) if (ipa_is_link_local(gw)) _I0(gw) = 0xfe800000 | (i->index & 0x0000ffff); - sockaddr_fill(&gate, af, gw, NULL, 0); + sockaddr_fill(&gate, (ipa_is_ip4(gw) ? AF_INET : AF_INET6), gw, NULL, 0); msg.rtm.rtm_flags |= RTF_GATEWAY; msg.rtm.rtm_addrs |= RTA_GATEWAY; break; @@ -469,7 +469,7 @@ krt_read_route(struct ks_msg *msg, struct krt_proto *p, int scan) idst = ipa_from_sa(&dst); imask = ipa_from_sa(&mask); - igate = (gate.sa.sa_family == dst.sa.sa_family) ? ipa_from_sa(&gate) : IPA_NONE; + igate = ipa_from_sa(&gate); #ifdef KRT_SHARED_SOCKET if (!scan)