On Tue, Nov 18, 2025 at 04:31:09PM -0500, Michael S. Tsirkin wrote:
> > +static int setup_ip_key_mask(struct virtio_net_ff_selector *selector,
> > + u8 *key,
> > + const struct ethtool_rx_flow_spec *fs)
> > +{
> > + struct iphdr *v4_m = (struct iphdr *)&selector->mask;
> > + struct iphdr *v4_k = (struct iphdr *)key;
> > +
> > + selector->type = VIRTIO_NET_FF_MASK_TYPE_IPV4;
> > + selector->length = sizeof(struct iphdr);
> > +
> > + if (fs->h_u.usr_ip4_spec.l4_4_bytes ||
> > + fs->h_u.usr_ip4_spec.tos ||
> > + fs->h_u.usr_ip4_spec.ip_ver != ETH_RX_NFC_IP4)
> > + return -EOPNOTSUPP;
>
> So include/uapi/linux/ethtool.h says:
>
> * struct ethtool_usrip4_spec - general flow specification for IPv4
> * @ip4src: Source host
> * @ip4dst: Destination host
> * @l4_4_bytes: First 4 bytes of transport (layer 4) header
> * @tos: Type-of-service
> * @ip_ver: Value must be %ETH_RX_NFC_IP4; mask must be 0
> * @proto: Transport protocol number; mask must be 0
>
> I guess this ETH_RX_NFC_IP4 check validates that userspace follows this
> documentation? But then shouldn't you check the mask
> as well? and mask for proto?
>
>
>
in fact, what if e.g. tos is 0 but mask is non-zero? should not
this be rejected, too?