The 'parse()' callback has a function type with 'void *change'
argument.  In all other cases it is used this way, except for
the route_table_parse().  That generates UBsan error:

  lib/netlink-notifier.c:190:25: runtime error: call to function
     route_table_parse through pointer to incorrect function type
     'int (*)(struct ofpbuf *, void *)'
  lib/route-table.c:227: note: route_table_parse defined here
    0 0x24d0 in nln_run lib/netlink-notifier.c:190:25
    1 0x7b39 in route_table_run lib/route-table.c:137:9
    2 0x5565 in netdev_vport_run lib/netdev-vport.c:364:5
    3 0xe978 in netdev_run lib/netdev.c:192:13
    4 0x2f25 in main vswitchd/ovs-vswitchd.c:132:9
    5 0xa1c9 in __libc_start_call_main
    6 0xa28a in __libc_start_main
    7 0xf004 in _start (vswitchd/ovs-vswitchd+0x726004)

Instead of turning off function sanitizer, let's just define
this callback as all the other parsing callbacks and cast the
void pointer inside the implementation.

This fixes system tests on Ubuntu 24.04 with UBsan.

Signed-off-by: Ilya Maximets <[email protected]>
---

Note: current ubuntu 24.04 kernel contains known conntrack bugs
that fail some of the system tests.

 lib/route-table.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/route-table.c b/lib/route-table.c
index f1fe32714..c6cb21394 100644
--- a/lib/route-table.c
+++ b/lib/route-table.c
@@ -85,7 +85,7 @@ static bool route_table_valid = false;
 
 static void route_table_reset(void);
 static void route_table_handle_msg(const struct route_table_msg *);
-static int route_table_parse(struct ofpbuf *, struct route_table_msg *);
+static int route_table_parse(struct ofpbuf *, void *change);
 static void route_table_change(const struct route_table_msg *, void *);
 static void route_map_clear(void);
 
@@ -110,8 +110,7 @@ route_table_init(void)
     ovs_assert(!route6_notifier);
 
     ovs_router_init();
-    nln = nln_create(NETLINK_ROUTE, (nln_parse_func *) route_table_parse,
-                     &rtmsg);
+    nln = nln_create(NETLINK_ROUTE, route_table_parse, &rtmsg);
 
     route_notifier =
         nln_notifier_create(nln, RTNLGRP_IPV4_ROUTE,
@@ -223,8 +222,9 @@ route_table_reset(void)
 /* Return RTNLGRP_IPV4_ROUTE or RTNLGRP_IPV6_ROUTE on success, 0 on parse
  * error. */
 static int
-route_table_parse(struct ofpbuf *buf, struct route_table_msg *change)
+route_table_parse(struct ofpbuf *buf, void *change_)
 {
+    struct route_table_msg *change = change_;
     bool parsed, ipv4 = false;
 
     static const struct nl_policy policy[] = {
-- 
2.46.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to