From 7eb9a24a96f5e88de0b92c65eae3dbc51fec9241 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen=20via=20Bird-users?= Date: Tue, 25 Feb 2025 16:05:10 +0100 Subject: [PATCH] Fix source-specific routing in Bird 3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Commit 69d1ffde4c72 ("Split route data structure to storage (ro) / manipulation (rw) structures.") changed rte->net from a pointer to a 'struct network' to a 'struct net_addr', but kept the address-of (&) operator before casting to 'net_addr_ip6_sadr *' when sending a source-specific route to the kernel. Because 'struct network' had an embedded struct member (struct fib_node), the address-of was needed to get back to a pointer to the data, but with the change in the commit mentioned above, e->net is now a straight pointer to the address. The bug meant that the source prefixes passed to the kernel were essentially garbage, leading to routes in the kernel like: default from b74:9e05:0:1:d8cf:c000::/86 via fe80::1 dev eth0 proto bird metric 32 pref medium Fix this by getting rid of the address-of operator. Note by commiter: used our TYPE_CAST macro instead of plain typecast to avoid this kind of problem in future. Fixes: 69d1ffde4c72 ("Split route data structure to storage (ro) / manipulation (rw) structures.") Signed-off-by: Toke Høiland-Jørgensen Signed-off-by: Maria Matejka --- sysdep/linux/netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdep/linux/netlink.c b/sysdep/linux/netlink.c index 1703a6759..75ed9ef7c 100644 --- a/sysdep/linux/netlink.c +++ b/sysdep/linux/netlink.c @@ -1494,7 +1494,7 @@ nl_send_route(struct krt_proto *p, const rte *e, int op) /* Add source address for IPv6 SADR routes */ if (e->net->type == NET_IP6_SADR) { - net_addr_ip6_sadr *a = (void *) &e->net; + net_addr_ip6_sadr *a = TYPE_CAST(net_addr *, net_addr_ip6_sadr *, e->net); nl_add_attr_ip6(&r->h, rsize, RTA_SRC, a->src_prefix); r->r.rtm_src_len = a->src_pxlen; } -- 2.47.2