git sha: c010e28c1e19f7bfa5b4ea4218de37dce97afa54
Author: Eelco Chaudron <[email protected]>
dpif: Add dpif_get_features() API.

This patch adds a new dpif_get_features() API to query currently
configured features, complementing the existing dpif_set_features() API.

> diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
> index fa265b8fc..c09b1c7c7 100644
> --- a/lib/dpif-netdev.c
> +++ b/lib/dpif-netdev.c
> @@ -9973,6 +9973,7 @@ const struct dpif_class dpif_netdev_class = {
>      dpif_netdev_wait,
>      dpif_netdev_get_stats,
>      NULL,                      /* set_features */
> +    NULL,                      /* get_features */
>      dpif_netdev_port_add,
>      dpif_netdev_port_del,
>      dpif_netdev_port_set_config,
> diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
> index 04d7c8ed6..e161930be 100644
> --- a/lib/dpif-netlink.c
> +++ b/lib/dpif-netlink.c
> @@ -121,6 +121,8 @@ static int dpif_netlink_dp_get(const struct dpif *,
>                                 struct ofpbuf **bufp);
>  static int
>  dpif_netlink_set_features(struct dpif *dpif_, uint32_t new_features);
> +static uint32_t
> +dpif_netlink_get_features(struct dpif *dpif_);
> 
>  static void
>  dpif_netlink_unixctl_dispatch_mode(struct unixctl_conn *conn, int argc,
> @@ -880,6 +882,14 @@ dpif_netlink_set_features(struct dpif *dpif_, uint32_t 
> new_features)
>      return error;
>  }
> 
> +static uint32_t
> +dpif_netlink_get_features(struct dpif *dpif_)
> +{
> +    struct dpif_netlink *dpif = dpif_netlink_cast(dpif_);
> +
> +    return dpif->user_features;
> +}

The implementation looks correct - it returns the cached user_features
value maintained by the dpif_netlink structure.

> @@ -4373,6 +4383,7 @@ const struct dpif_class dpif_netlink_class = {
>      NULL,                       /* wait */
>      dpif_netlink_get_stats,
>      dpif_netlink_set_features,
> +    dpif_netlink_get_features,
>      dpif_netlink_port_add,
>      dpif_netlink_port_del,
>      NULL,                       /* port_set_config */

[ ... ]

> diff --git a/lib/dpif.c b/lib/dpif.c
> index e8bbd65b7..4b068b013 100644
> --- a/lib/dpif.c
> +++ b/lib/dpif.c
> @@ -566,12 +566,22 @@ dpif_get_dp_stats(const struct dpif *dpif, struct 
> dpif_dp_stats *stats)
>  int
>  dpif_set_features(struct dpif *dpif, uint32_t new_features)
>  {
> -    int error = dpif->dpif_class->set_features(dpif, new_features);
> +    int error = dpif->dpif_class->set_features
> +                    ? dpif->dpif_class->set_features(dpif, new_features)
> +                    : EOPNOTSUPP;

The existing code in the same function at the top of the diff shows 
"dpif->dpif_class->set_features(dpif, new_features)" being called
directly. Is the original code missing NULL checks or does this patch
introduce a behavioral change by adding NULL checks where none existed
before?

> +uint32_t
> +dpif_get_features(struct dpif *dpif)
> +{
> +    return dpif->dpif_class->get_features
> +               ? dpif->dpif_class->get_features(dpif)
> +               : 0;
> +}

Should dpif_get_features() log the operation similar to how
dpif_set_features() calls log_operation()?

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

Reply via email to