[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231012164853.7882fa86@kernel.org>
Date: Thu, 12 Oct 2023 16:48:53 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: "Nambiar, Amritha" <amritha.nambiar@...el.com>
Cc: <netdev@...r.kernel.org>, <sridhar.samudrala@...el.com>
Subject: Re: [net-next PATCH v4 04/10] netdev-genl: Add netlink framework
functions for queue
On Wed, 11 Oct 2023 16:54:00 -0700 Nambiar, Amritha wrote:
> >> +static int netdev_nl_queue_validate(struct net_device *netdev, u32 q_id,
> >> + u32 q_type)
> >> +{
> >> + switch (q_type) {
> >> + case NETDEV_QUEUE_TYPE_RX:
> >> + if (q_id >= netdev->real_num_rx_queues)
> >> + return -EINVAL;
> >> + return 0;
> >> + case NETDEV_QUEUE_TYPE_TX:
> >> + if (q_id >= netdev->real_num_tx_queues)
> >> + return -EINVAL;
> >> + return 0;
> >> + default:
> >> + return -EOPNOTSUPP;
> >
> > Doesn't the netlink policy prevent this already?
>
> For this, should I be using "checks: max:" as an attribute property for
> the 'queue-id' attribute in the yaml. If so, not sure how I can give a
> custom value (not hard-coded) for max.
> Or should I include a pre-doit hook.
Weird, I was convinced that if you specify enum by default the code gen
will automatically generate the range check to make sure that the value
is within the enum..
Looks like it does, this is the policy, right?
+static const struct nla_policy netdev_queue_get_do_nl_policy[NETDEV_A_QUEUE_QUEUE_TYPE + 1] = {
+ [NETDEV_A_QUEUE_IFINDEX] = NLA_POLICY_MIN(NLA_U32, 1),
+ [NETDEV_A_QUEUE_QUEUE_TYPE] = NLA_POLICY_MAX(NLA_U32, 1),
^^^^^^^^^^^^^^^^^^^^^^^^^^^
Powered by blists - more mailing lists