Before this change the struct route_data rtm_dst_len element was
stored as a value that could be fed directly into ipv6_create_mask.

As we prepare for external consumption of this structure this comes
across as unexpected, as anyone interacting with this code would
expect the element to behave like the well known kernel rtmsg UAPI.

Delay conversion of IPv4 prefix length until passing this value to
ovs_router_insert().

Suggested-by: Felix Huettner <[email protected]>
Signed-off-by: Frode Nordahl <[email protected]>
---
 lib/route-table.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/route-table.c b/lib/route-table.c
index a07e34f90..e143f421d 100644
--- a/lib/route-table.c
+++ b/lib/route-table.c
@@ -346,7 +346,7 @@ route_table_parse__(struct ofpbuf *buf, size_t ofs,
         }
 
         change->nlmsg_type     = nlmsg->nlmsg_type;
-        change->rd.rtm_dst_len = rtm->rtm_dst_len + (ipv4 ? 96 : 0);
+        change->rd.rtm_dst_len = rtm->rtm_dst_len;
         change->rd.rtm_protocol = rtm->rtm_protocol;
         change->rd.local = rtm->rtm_type == RTN_LOCAL;
         if (attrs[RTA_OIF]) {
@@ -511,7 +511,9 @@ route_table_handle_msg(const struct route_table_msg *change,
         rdnh = CONTAINER_OF(ovs_list_front(&change->rd.nexthops),
                             const struct route_data_nexthop, nexthop_node);
 
-        ovs_router_insert(rd->mark, &rd->rta_dst, rd->rtm_dst_len,
+        ovs_router_insert(rd->mark, &rd->rta_dst,
+                          IN6_IS_ADDR_V4MAPPED(&rd->rta_dst)
+                          ? rd->rtm_dst_len + 96 : rd->rtm_dst_len,
                           rd->local, rdnh->ifname, &rdnh->addr,
                           &rd->rta_prefsrc);
     }
-- 
2.45.2

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

Reply via email to