7. TAP(Test Access Point)
device
• A TAP device, such as vnet0 is how hypervisors
such as KVM and Xen implement a virtual network
interface card.
• An ethernet frame sent to a TAP device is received
by the guest operating system.
vm: $ ip a
2: eth0: …
link/ether fa:16:3e:49:94:00 brd ff:ff:ff:ff:ff:ff
inet 10.10.100.6/24 brd 10.10.100.255 scope global eth0
inet6 fe80::f816:3eff:fe49:9400/64 scope link
!
compute-node:$ ip a
22: tapbb4782e2-d1(vnet0): …
link/ether fe:16:3e:49:94:00 brd ff:ff:ff:ff:ff:ff
inet6 fe80::fc16:3eff:fe49:9400/64 scope link
!
fa:16:3e:49:94:00
fe:16:3e:49:94:00
$ cat /etc/libvirt/qemu/instance-00000002.xml
<domain type='kvm'>
<devices>
<interface type='bridge'>
<mac address='fa:16:3e:49:94:00'/>
<source bridge='qbrbb4782e2-d1'/>
<target dev='tapbb4782e2-d1'/>
…
9. VETH(Virtual ETHernet)
pair
• A veth pair is a pair of virtual network interfaces correctly directly
together. An ethernet frame sent to one end of a veth pair is received
by the other end of a veth pair.
• OpenStack networking makes use of veth pairs as virtual patch
cables in order to make connections between virtual bridges.
$ ip a
20: qvobb4782e2-d1: …
21: qvbbb4782e2-d1: …
!
$ ethtool -S qvbbb4782e2-d1
NIC statistics:
peer_ifindex: 20
$ ethtool -S qvobb4782e2-d1
NIC statistics:
peer_ifindex: 21
$ ip a
14: phy-br-eth1: …
15: int-br-eth1: …
!
$ ethtool -S int-br-eth1
NIC statistics:
peer_ifindex: 14
$ ethtool -S phy-br-eth1
NIC statistics:
peer_ifindex: 15
$ ip a
9: tap5bd4ac3b-87: …
$ ip netns
qdhcp-fb57d1bd-e0e5-484c-b5d7-9ad807d9e7b8
$ ip netns exec qdhcp-fb57d1bd-e0e5-484c-b5d7-9ad807d9e7b8 ip a
8: ns-5bd4ac3b-87: …
!
$ ethtool -S tap5bd4ac3b-87
NIC statistics:
peer_ifindex: 8
$ ip netns exec qdhcp-fb57d1bd-e0e5-484c-b5d7-9ad807d9e7b8
ethtool -S ns-5bd4ac3b-87
NIC statistics:
peer_ifindex: 9
11. Linux bridge
• A Linux bridge behaves like a hub: you can connect multiple (physical or
virtual) network interfaces devices to a Linux bridge.
• Any ethernet frames that come in from one interface attached to the
bridge is transmitted to all of the other devices.
$ brctl show
bridge name bridge id … interfaces
qbrbb4782e2-d1 8000.3a7ef7e39d98 … qvbbb4782e2-d1
tapbb4782e2-d1(vnet0)
$ ip a
19: qbrbb4782e2-d1: …
link/ether 3a:7e:f7:e3:9d:98 brd ff:ff:ff:ff:ff:ff
inet6 fe80::d8e3:16ff:fef5:f854/64 scope link
$ cat /etc/libvirt/qemu/instance-00000002.xml
<domain type='kvm'>
<devices>
<interface type='bridge'>
<mac address='fa:16:3e:49:94:00'/>
<source bridge='qbrbb4782e2-d1'/>
<target dev='tapbb4782e2-d1'/>
…
13. Open vSwitch
• An Open vSwitch bridge behaves like a virtual switch: network interface devices
connect to Open vSwitch bridge's ports, and the ports can be configured much
like a physical switch's ports, including VLAN configurations.
$ ovs-vsctl show
Bridge "br-eth1"
Port "br-eth1"
Interface "br-eth1"
type: internal
Port "eth1"
Interface "eth1"
Port "phy-br-eth1"
Interface "phy-br-eth1"
Bridge br-int
Port "tapad3cdca6-b4"
tag: 1
Interface "tapad3cdca6-b4"
Port "qvobb4782e2-d1"
tag: 1
Interface "qvobb4782e2-d1"
Port br-int
Interface br-int
type: internal
Port "int-br-eth1"
Interface "int-br-eth1"
14. Open vSwitch
vlan tag
$ ovs-vsctl show
Bridge "br-eth1"
Port "br-eth1"
Interface "br-eth1"
type: internal
Port "eth1"
Interface "eth1"
Port "phy-br-eth1"
Interface "phy-br-eth1"
Bridge br-int
Port "tapad3cdca6-b4"
tag: 1
Interface "tapad3cdca6-b4"
Port "qvobb4782e2-d1"
tag: 1
Interface "qvobb4782e2-d1"
Port br-int
Interface br-int
type: internal
Port "int-br-eth1"
Interface "int-br-eth1"
• vlan tag
해당 bridge에서 port를 지날때:
- tag 1이 적힌 packet은 tag를 제거하고 통과시킴
해당 port에서 bridge를 지날때:
- packet에 tag 1을 적음