]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Fix source-specific routing in Bird 3
authorToke Høiland-Jørgensen via Bird-users <bird-users@network.cz>
Tue, 25 Feb 2025 15:05:10 +0000 (16:05 +0100)
committerMaria Matejka <mq@ucw.cz>
Wed, 26 Feb 2025 10:07:57 +0000 (11:07 +0100)
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 <toke@toke.dk>
Signed-off-by: Maria Matejka <mq@jmq.cz>
sysdep/linux/netlink.c

index 1703a67595d5ae7957381882da07466b59875d56..75ed9ef7c7519e2539d6f99a1455b405394fdd1a 100644 (file)
@@ -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;
     }