On 10/27/25 1:42 PM, Dima Chumak via dev wrote:
> After introducing multi-table routing, all local routing entries now
> resides in a dedicated table CLS_LOCAL. There is no need to keep a
> per-entry flag to distinguish local from non-local entry any longer, so
> drop it. This is the case because we're not considering any routes that
> are not unicast or local, i.e. we're not considering broadcast routes
> that would also normally reside in the local table.
> 
> A 'user' flag is added in place of the removed 'local' flag to simplify
> identification of user-added routes. Previously, it was done by
> comparing 'priority' and 'plen' fields, which was confusing in some
> cases.
> 
> Signed-off-by: Dima Chumak <[email protected]>
> ---
>  lib/netdev-dummy.c  | 12 ++++++------
>  lib/ovs-router.c    | 44 ++++++++++++++++++--------------------------
>  lib/ovs-router.h    |  5 ++---
>  lib/route-table.c   |  5 ++---
>  tests/ovs-router.at |  2 +-
>  5 files changed, 29 insertions(+), 39 deletions(-)
> 
> diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
> index 5e75012cd57a..b16085bad8e3 100644
> --- a/lib/netdev-dummy.c
> +++ b/lib/netdev-dummy.c
> @@ -2223,11 +2223,11 @@ netdev_dummy_ip4addr(struct unixctl_conn *conn, int 
> argc OVS_UNUSED,
>  
>              in6_addr_set_mapped_ipv4(&ip6, ip.s_addr);
>              /* Insert local route entry for the new address. */
> -            ovs_router_force_insert(CLS_LOCAL, 0, &ip6, 32 + 96, true,
> -                                    argv[1], &in6addr_any, &ip6);
> +            ovs_router_force_insert(CLS_LOCAL, 0, &ip6, 32 + 96, argv[1],
> +                                    &in6addr_any, &ip6);
>              /* Insert network route entry for the new address. */
> -            ovs_router_force_insert(CLS_MAIN, 0, &ip6, plen + 96, false,
> -                                    argv[1], &in6addr_any, &ip6);
> +            ovs_router_force_insert(CLS_MAIN, 0, &ip6, plen + 96, argv[1],
> +                                    &in6addr_any, &ip6);
>  
>              unixctl_command_reply(conn, "OK");
>          } else {
> @@ -2260,10 +2260,10 @@ netdev_dummy_ip6addr(struct unixctl_conn *conn, int 
> argc OVS_UNUSED,
>              netdev_dummy_add_in6(netdev, &ip6, &mask);
>  
>              /* Insert local route entry for the new address. */
> -            ovs_router_force_insert(CLS_LOCAL, 0, &ip6, 128, true, argv[1],
> +            ovs_router_force_insert(CLS_LOCAL, 0, &ip6, 128, argv[1],
>                                      &in6addr_any, &ip6);
>              /* Insert network route entry for the new address. */
> -            ovs_router_force_insert(CLS_MAIN, 0, &ip6, plen, false, argv[1],
> +            ovs_router_force_insert(CLS_MAIN, 0, &ip6, plen, argv[1],
>                                      &in6addr_any, &ip6);
>  
>              unixctl_command_reply(conn, "OK");
> diff --git a/lib/ovs-router.c b/lib/ovs-router.c
> index affe557571e0..6ace71497d1e 100644
> --- a/lib/ovs-router.c
> +++ b/lib/ovs-router.c
> @@ -85,7 +85,7 @@ struct ovs_router_entry {
>      struct in6_addr src_addr;
>      uint8_t plen;
>      uint8_t priority;
> -    bool local;
> +    bool user;
>      uint32_t mark;
>  };
>  
> @@ -126,7 +126,7 @@ cls_flush(struct classifier *cls, bool flush_all)
>  
>      classifier_defer(cls);
>      CLS_FOR_EACH (rt, cr, cls) {
> -        if (flush_all || rt->priority == rt->plen || rt->local) {
> +        if (flush_all || !rt->user) {
>              rt_entry_delete__(&rt->cr, cls);
>          }
>      }
> @@ -188,12 +188,7 @@ ovs_router_lookup(uint32_t mark, const struct in6_addr 
> *ip6_dst,
>  
>          cr_src = classifier_lookup(cls_local, OVS_VERSION_MAX, &flow_src,
>                                     NULL, NULL);
> -        if (cr_src) {
> -            struct ovs_router_entry *p_src = ovs_router_entry_cast(cr_src);
> -            if (!p_src->local) {
> -                return false;
> -            }
> -        } else {
> +        if (!cr_src) {
>              return false;
>          }
>      }
> @@ -364,7 +359,7 @@ out:
>  
>  static int
>  ovs_router_insert__(uint32_t table, uint32_t mark, uint8_t priority,
> -                    bool local, const struct in6_addr *ip6_dst,
> +                    bool user, const struct in6_addr *ip6_dst,
>                      uint8_t plen, const char output_netdev[],
>                      const struct in6_addr *gw,
>                      const struct in6_addr *ip6_src)
> @@ -388,7 +383,7 @@ ovs_router_insert__(uint32_t table, uint32_t mark, 
> uint8_t priority,
>      p->mark = mark;
>      p->nw_addr = match.flow.ipv6_dst;
>      p->plen = plen;
> -    p->local = local;
> +    p->user = user;
>      p->priority = priority;
>  
>      if (ipv6_addr_is_set(ip6_src)) {
> @@ -433,12 +428,11 @@ ovs_router_insert__(uint32_t table, uint32_t mark, 
> uint8_t priority,
>  
>  void
>  ovs_router_insert(uint32_t table, uint32_t mark, const struct in6_addr 
> *ip_dst,
> -                  uint8_t plen, bool local, const char output_netdev[],
> +                  uint8_t plen, bool user, const char output_netdev[],
>                    const struct in6_addr *gw, const struct in6_addr *prefsrc)
>  {
>      if (use_system_routing_table) {
> -        uint8_t priority = local ? plen + 64 : plen;
> -        ovs_router_insert__(table, mark, priority, local, ip_dst, plen,
> +        ovs_router_insert__(table, mark, plen, user, ip_dst, plen,
>                              output_netdev, gw, prefsrc);
>      }
>  }
> @@ -448,14 +442,12 @@ ovs_router_insert(uint32_t table, uint32_t mark, const 
> struct in6_addr *ip_dst,
>  void
>  ovs_router_force_insert(uint32_t table, uint32_t mark,
>                          const struct in6_addr *ip_dst,
> -                        uint8_t plen, bool local, const char output_netdev[],
> +                        uint8_t plen, const char output_netdev[],
>                          const struct in6_addr *gw,
>                          const struct in6_addr *prefsrc)
>  {
> -    uint8_t priority = local ? plen + 64 : plen;
> -
> -    ovs_router_insert__(table, mark, priority, local, ip_dst, plen,
> -                        output_netdev, gw, prefsrc);
> +    ovs_router_insert__(table, mark, plen, false, ip_dst, plen, 
> output_netdev,
> +                        gw, prefsrc);
>  }
>  
>  static void
> @@ -586,7 +578,7 @@ ovs_router_add(struct unixctl_conn *conn, int argc,
>          in6_addr_set_mapped_ipv4(&src6, src);
>      }
>  
> -    err = ovs_router_insert__(CLS_MAIN, mark, plen + 32, false, &ip6, plen,
> +    err = ovs_router_insert__(CLS_MAIN, mark, plen + 32, true, &ip6, plen,
>                                argv[2], &gw6, &src6);
>      if (err) {
>          unixctl_command_reply_error(conn, "Error while inserting route.");
> @@ -638,7 +630,6 @@ ovs_router_show_json(struct json *json_routes, const 
> struct classifier *cls,
>      }
>  
>      CLS_FOR_EACH (rt, cr, cls) {
> -        bool user = rt->priority != rt->plen && !rt->local;
>          uint8_t plen = rt->plen;
>          struct json *json, *nh;
>  
> @@ -650,8 +641,9 @@ ovs_router_show_json(struct json *json_routes, const 
> struct classifier *cls,
>          }
>  
>          json_object_put(json, "table", json_integer_create(table));
> -        json_object_put(json, "user", json_boolean_create(user));
> -        json_object_put(json, "local", json_boolean_create(rt->local));
> +        json_object_put(json, "user", json_boolean_create(rt->user));
> +        json_object_put(json, "local",
> +                        json_boolean_create(table == CLS_LOCAL && 
> !rt->user));
>          json_object_put(json, "priority", json_integer_create(rt->priority));
>          json_object_put(json, "prefix", json_integer_create(plen));
>          json_object_put_string(nh, "dev", rt->output_netdev);
> @@ -709,10 +701,10 @@ ovs_router_show_text(struct ds *ds, const struct 
> classifier *cls,
>  
>      CLS_FOR_EACH (rt, cr, cls) {
>          uint8_t plen;
> -        if (rt->priority == rt->plen || rt->local) {
> -            ds_put_format(ds, "Cached: ");
> -        } else {
> +        if (rt->user) {
>              ds_put_format(ds, "User: ");
> +        } else {
> +            ds_put_format(ds, "Cached: ");
>          }
>          ipv6_format_mapped(&rt->nw_addr, ds);
>          plen = rt->plen;
> @@ -731,7 +723,7 @@ ovs_router_show_text(struct ds *ds, const struct 
> classifier *cls,
>          }
>          ds_put_format(ds, " SRC ");
>          ipv6_format_mapped(&rt->src_addr, ds);
> -        if (rt->local) {
> +        if (table == CLS_LOCAL && !rt->user) {
>              ds_put_format(ds, " local");
>          }
>          if (!is_standard_table(table) && !show_header) {
> diff --git a/lib/ovs-router.h b/lib/ovs-router.h
> index 62d306423ce6..f9c1d90d39b0 100644
> --- a/lib/ovs-router.h
> +++ b/lib/ovs-router.h
> @@ -40,13 +40,12 @@ void ovs_router_init(void);
>  bool ovs_router_is_referenced(uint32_t table);
>  void ovs_router_insert(uint32_t table, uint32_t mark,
>                         const struct in6_addr *ip_dst,
> -                       uint8_t plen, bool local,
> +                       uint8_t plen, bool user,
>                         const char output_netdev[], const struct in6_addr *gw,
>                         const struct in6_addr *prefsrc);
>  void ovs_router_force_insert(uint32_t table, uint32_t mark,
>                               const struct in6_addr *ip_dst,
> -                             uint8_t plen, bool local,
> -                             const char output_netdev[],
> +                             uint8_t plen, const char output_netdev[],
>                               const struct in6_addr *gw,
>                               const struct in6_addr *prefsrc);
>  void ovs_router_rule_add(uint32_t prio, bool invert, uint8_t src_len,
> diff --git a/lib/route-table.c b/lib/route-table.c
> index 40be2762c2b4..b86f65bbdbc0 100644
> --- a/lib/route-table.c
> +++ b/lib/route-table.c
> @@ -771,9 +771,8 @@ route_table_handle_msg(const struct route_table_msg 
> *change,
>  
>          ovs_router_insert(table, rd->rta_mark, &rd->rta_dst,
>                            IN6_IS_ADDR_V4MAPPED(&rd->rta_dst)
> -                          ? rd->rtm_dst_len + 96 : rd->rtm_dst_len,
> -                          rd->rtn_local, rdnh->ifname, &rdnh->addr,
> -                          &rd->rta_prefsrc);
> +                          ? rd->rtm_dst_len + 96 : rd->rtm_dst_len, false,

nit: I'd move 'false' to the next line, even if rta_prefsrc will then
end up on its own line.  It's a little hard to read when it's mixed up
with the ternary.

> +                          rdnh->ifname, &rdnh->addr, &rd->rta_prefsrc);
>      }
>  }
>  
> diff --git a/tests/ovs-router.at b/tests/ovs-router.at
> index 4e5e26688b14..5837ff24bb34 100644
> --- a/tests/ovs-router.at
> +++ b/tests/ovs-router.at
> @@ -38,7 +38,7 @@ AT_CHECK([ovs-appctl --format=json --pretty 
> ovs/route/show], [0], [dnl
>          "dev": "br0"}],
>      "prefix": 32,
>      "prefsrc": "2.2.2.2",
> -    "priority": 192,
> +    "priority": 128,
>      "table": 255,
>      "user": false},
>    {

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

Reply via email to