From: Jakub Kicinski <kuba@kernel.org>
To: danielj@nvidia.com
Cc: Jakub Kicinski <kuba@kernel.org>,
mst@redhat.com, netdev@vger.kernel.org, pabeni@redhat.com,
jasowang@redhat.com
Subject: Re: [net-next,v16,07/12] virtio_net: Implement layer 2 ethtool flow rules
Date: Thu, 22 Jan 2026 17:45:03 -0800 [thread overview]
Message-ID: <20260123014503.3008177-1-kuba@kernel.org> (raw)
In-Reply-To: <20260121220652.894364-8-danielj@nvidia.com>
This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.
For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
virtio_net: Implement layer 2 ethtool flow rules
This patch adds ethtool flow rule support for ethernet headers,
implementing classifier and rule management via virtio admin commands.
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index b406f5f1c75e..e3f2a7e0e99f 100644
[ ... ]
> +static int build_and_insert(struct virtnet_ff *ff,
> + struct virtnet_ethtool_rule *eth_rule)
> +{
> + struct virtio_net_resource_obj_ff_classifier *classifier;
> + struct ethtool_rx_flow_spec *fs = ð_rule->flow_spec;
> + struct virtio_net_ff_selector *selector;
> + struct virtnet_classifier *c;
> + size_t classifier_size;
> + int num_hdrs;
> + u8 key_size;
> + u8 *key;
> + int err;
> +
> + calculate_flow_sizes(fs, &key_size, &classifier_size, &num_hdrs);
> +
> + key = kzalloc(key_size, GFP_KERNEL);
> + if (!key)
> + return -ENOMEM;
> +
> + /*
> + * virtio_net_ff_obj_ff_classifier is already included in the
> + * classifier_size.
> + */
> + c = kzalloc(classifier_size +
> + sizeof(struct virtnet_classifier) -
> + sizeof(struct virtio_net_resource_obj_ff_classifier),
> + GFP_KERNEL);
> + if (!c) {
> + kfree(key);
> + return -ENOMEM;
> + }
> +
> + c->size = classifier_size;
> + classifier = &c->classifier;
> + classifier->count = num_hdrs;
> + selector = (void *)&classifier->selectors[0];
> +
> + setup_eth_hdr_key_mask(selector, key, fs);
> +
> + err = validate_classifier_selectors(ff, classifier, num_hdrs);
> + if (err)
> + goto err_key;
^^^^^^
If validate_classifier_selectors() fails, this jumps to err_key which
only frees key but not c. Should this be goto err_classifier instead,
to avoid leaking the struct virtnet_classifier allocation?
> +
> + err = setup_classifier(ff, c);
> + if (err)
> + goto err_classifier;
> +
> + err = insert_rule(ff, eth_rule, c->id, key, key_size);
> + if (err) {
> + /* destroy_classifier will free the classifier */
> + destroy_classifier(ff, c->id);
> + goto err_key;
> + }
> +
> + return 0;
> +
> +err_classifier:
> + kfree(c);
> +err_key:
> + kfree(key);
> +
> + return err;
> +}
next prev parent reply other threads:[~2026-01-23 1:45 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-21 22:06 [PATCH net-next v16 00/12] virtio_net: Add ethtool flow rules support Daniel Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 01/12] virtio_pci: Remove supported_cap size build assert Daniel Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 02/12] virtio: Add config_op for admin commands Daniel Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 03/12] virtio: Expose generic device capability operations Daniel Jurgens
2026-01-22 17:32 ` Michael S. Tsirkin
2026-01-21 22:06 ` [PATCH net-next v16 04/12] virtio: Expose object create and destroy API Daniel Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 05/12] virtio_net: Query and set flow filter caps Daniel Jurgens
2026-01-23 1:43 ` [net-next,v16,05/12] " Jakub Kicinski
2026-01-29 17:51 ` Dan Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 06/12] virtio_net: Create a FF group for ethtool steering Daniel Jurgens
2026-01-22 21:51 ` Michael S. Tsirkin
2026-01-29 17:08 ` Dan Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 07/12] virtio_net: Implement layer 2 ethtool flow rules Daniel Jurgens
2026-01-23 1:45 ` Jakub Kicinski [this message]
2026-01-21 22:06 ` [PATCH net-next v16 08/12] virtio_net: Use existing classifier if possible Daniel Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 09/12] virtio_net: Implement IPv4 ethtool flow rules Daniel Jurgens
2026-01-22 17:21 ` Michael S. Tsirkin
2026-01-29 18:46 ` Dan Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 10/12] virtio_net: Add support for IPv6 ethtool steering Daniel Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 11/12] virtio_net: Add support for TCP and UDP ethtool rules Daniel Jurgens
2026-01-21 22:06 ` [PATCH net-next v16 12/12] virtio_net: Add get ethtool flow rules ops Daniel Jurgens
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260123014503.3008177-1-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=danielj@nvidia.com \
--cc=jasowang@redhat.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox