2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

KVM guest でXDP を使う

Posted at

KVMゲストで、XDP を使うときの設定。

必要な設定

  <vcpu placement='static'>8</vcpu>
  ...
  <devices>
    <interface type='bridge'>
      <model type='virtio'/>
      <driver name='vhost' queues='16'>
        <guest csum='off' tso4='off' tso6='off' ecn='off' ufo='off'/>
      </driver>
    </interface>
  </devices>

ポイント

<driver ... queues='x'> の queues の値は、vcpu 数の2倍以上である必要がある。
VCPUが8なら、queues は16以上。

queuesが小さいと、Too few free TX rings available になる。

# ip link set dev eth0 xdp object xdp_dummy.o
Error: virtio_net: Too few free TX rings available.

各種offloadをoffにする必要がある。
csum='off' tso4='off' tso6='off' ecn='off' ufo='off'

offloadとは、IPパケットに関する処理をカーネルでするのではなく、NICで行う機能。

  • csum: IPチェックサム計算のoffload
  • tso4: TCP segmentation offload for IPv4
  • tso6: TCP segmentation offload for IPv6
  • ecn: ECN (Explicit Congestion Notification)付のTCP segmentation offload
  • ufo: UDP Fragmentation offload

無効にしてないと、Can't set XDP while host is implementing LRO/CSUM になる。

# ip link set dev eth0 xdp object xdp_dummy.o
Error: virtio_net: Can't set XDP while host is implementing LRO/CSUM, disable LRO/CSUM first.

環境

VM host

CentOS7 + kernel-ml
qemu-kvm-common-ev-2.12.0-44.1.el7_8.1.x86_64
qemu-kvm-ev-2.12.0-44.1.el7_8.1.x86_64

# uname -r
5.6.15-1.el7.elrepo.x86_64

VM guest

CentOS7 + kernel-ml

$ uname -r
5.7.7-1.el7.elrepo.x86_64
2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?