On 17-01-04 07:11 PM, John Fastabend wrote:
> XDP programs can not consume multiple pages so we cap the MTU to
> avoid this case. Virtio-net however only checks the MTU at XDP
> program load and does not block MTU changes after the program
> has loaded.
> 
> This patch sets/clears the max_mtu value at XDP load/unload time.
> 
> Signed-off-by: John Fastabend <john.r.fastab...@intel.com>
> ---
>  drivers/net/virtio_net.c |   26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)


[...]

>  static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog)
>  {
> -     unsigned long int max_sz = PAGE_SIZE - sizeof(struct padded_vnet_hdr);
>       struct virtnet_info *vi = netdev_priv(dev);
>       struct bpf_prog *old_prog;
> +     unsigned long int max_sz;
>       u16 xdp_qp = 0, curr_qp;
>       int i, err;
>  
> @@ -1720,6 +1737,7 @@ static int virtnet_xdp_set(struct net_device *dev, 
> struct bpf_prog *prog)
>               return -EINVAL;
>       }
>  
> +     max_sz = virtnet_xdp_mtu(prog, vi);
>       if (dev->mtu > max_sz) {
>               netdev_warn(dev, "XDP requires MTU less than %lu\n", max_sz);
>               return -EINVAL;
> @@ -1748,6 +1766,9 @@ static int virtnet_xdp_set(struct net_device *dev, 
> struct bpf_prog *prog)
>                       virtnet_set_queues(vi, curr_qp);
>                       return PTR_ERR(prog);
>               }
> +             dev->max_mtu = max_sz;
> +     } else {
> +             dev->max_mtu = ETH_MAX_MTU;
>       }

oops v2 needed. The else branch is not required anymore. :/

Reply via email to