Often when troubleshooting an issue in a Contrail setup, there is a need to log in to a compute node to check a virtual machine's interface details. Given a VM name, there are many ways to locate its corresponding vif interface.
This article introduces a quick way to locate the vif interface without using a vRouter introspect.
Suppose that a VM named "pings-net-bcomp80-firefly-1" has been created from an Openstack node. We can see that the VM has been created successfully on the compute node as shown here:
root@opsk99:~# nova show pings-net-bcomp80-firefly-1 +--------------------------------------+--------------------------------------------------------------+ | Property | Value | +--------------------------------------+--------------------------------------------------------------+ | OS-DCF:diskConfig | AUTO | | OS-EXT-AZ:availability_zone | bComp80-dpdk | | OS-EXT-SRV-ATTR:host | bcomp80 | | OS-EXT-SRV-ATTR:hypervisor_hostname | bcomp80.localdomain | | OS-EXT-SRV-ATTR:instance_name | instance-000000e1 | | OS-EXT-STS:power_state | 1 | | OS-EXT-STS:task_state | - | | OS-EXT-STS:vm_state | active | | OS-SRV-USG:launched_at | 2018-10-31T03:55:13.000000 | | OS-SRV-USG:terminated_at | - | | accessIPv4 | | | accessIPv6 | | | config_drive | | | created | 2018-10-31T03:55:09Z | | flavor | m1.medium.dpdk (4b7b8390-f26f-481d-a452-ce9f81ea3e6c) | | hostId | 376a1cfa5f668e39c52330a85481a78374b5416725571b9044b27b98 | | id | 4617925e-8f9f-4cdc-9b74-10018b695e48 | | image | firefly-12.1X47-D20.7 (42b1e976-b26a-4455-996e-7dcd4c34c22f) | | key_name | - | | metadata | {} | | name | pings-net-bcomp80-firefly-1 | | os-extended-volumes:volumes_attached | [] | | pings-net network | 4.4.4.12 | | progress | 0 | | security_groups | default | | status | ACTIVE | | tenant_id | ede15b5d21eb4401bd2a56e8d373aa71 | | updated | 2018-11-20T15:11:12Z | | user_id | 5afceb032d3c4dfda9391abe1a362ddb | +--------------------------------------+--------------------------------------------------------------+
We then log in to the compute node and verify that the created VM is indeed in this node before we proceed:
root@bcomp80:~# for i in $(virsh list --all | grep instance | awk '{print $2}'); do virsh dumpxml $i | grep nova:name; done | grep ping s-net-bcomp80-firefly-1 <nova:name>pings-net-bcomp80-firefly-1
Now that we see the created VM's name in the right compute node, we can find the name of the tap interfaces that belong to this VM:
root@bcomp80:~# grep -hr pings-net-bcomp80-firefly-1 /var/lib/contrail/ports | python -mjson.tool { "author": "/usr/bin/vrouter-port-control", "display-name": "pings-net-bcomp80-firefly-1", "id": "d173cfb2-5752-4a99-bf8e-861e3c98a3d1", "instance-id": "4617925e-8f9f-4cdc-9b74-10018b695e48", "ip-address": "4.4.4.12", "ip6-address": "None", "mac-address": "02:d1:73:cf:b2:57", "rx-vlan-id": -1, "system-name": "tapd173cfb2-57", #<<<<<< "time": "2019-04-11 12:37:11.072747", "tx-vlan-id": -1, "type": 0, "vm-project-id": "ede15b5d-21eb-4401-bd2a-56e8d373aa71", "vn-id": "704049de-6cad-4d2f-8920-b066ac9a9f1b" }
From the tap interface name, we can now find the vif or vrf number.
root@bcomp80:~# vif -l | grep tapd173cfb2-57 vif0/37 PMD: tapd173cfb2-57 root@bcomp80:~# vif --get 37 Vrouter Interface Table Flags: P=Policy, X=Cross Connect, S=Service Chain, Mr=Receive Mirror Mt=Transmit Mirror, Tc=Transmit Checksum Offload, L3=Layer 3, L2=Layer 2 D=DHCP, Vp=Vhost Physical, Pr=Promiscuous, Vnt=Native Vlan Tagged Mnp=No MAC Proxy, Dpdk=DPDK PMD Interface, Rfl=Receive Filtering Offload, Mon=Interface is Monitored Uuf=Unknown Unicast Flood, Vof=VLAN insert/strip offload, Df=Drop New Flows, Proxy=MAC Requests Proxied Always Mn=Mirror without Vlan Tag vif0/37 PMD: tapd173cfb2-57 Type:Virtual HWaddr:00:00:5e:00:01:00 IPaddr:4.4.4.12 Vrf:3 Flags:PL3L2D QOS:-1 Ref:23 RX port packets:224495 errors:0 RX queue packets:11494 errors:0 RX queue errors to lcore 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 RX packets:224495 bytes:9744538 errors:0 TX packets:332450 bytes:13974186 errors:0 TX port packets:332450 errors:0 syscalls:307271 Drops:26
From the above output, we can determine the vif and vrf numbers as 37 and 3, respectively.