Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dlbewley/5264935f02e3ed1416012c4494249b93 to your computer and use it in GitHub Desktop.
Save dlbewley/5264935f02e3ed1416012c4494249b93 to your computer and use it in GitHub Desktop.
  • I have a network and I want to list the ports on the ovs switch
[root@worker-4 ~]# ovs-vsctl find interface  --columns=name,mac_in_use,mtu external_ids:"k8s.ovn.org/network"="vlan-1924"
ovs-vsctl: Interface does not contain a column whose name matches "--columns"
[root@worker-4 ~]# ovs-vsctl  --columns=name,mac_in_use,mtu find interface external_ids:"k8s.ovn.org/network"="vlan-1924"
name                : "81a5ebcb6fa45_3"
mac_in_use          : "be:a0:20:9b:b1:de"
mtu                 : 1400

name                : "040cd3693b52c_3"
mac_in_use          : "c2:93:f7:05:0a:6e"
mtu                 : 1400

name                : "025ca4b7703f0_3"
mac_in_use          : "3e:e9:69:91:42:72"
mtu                 : 1400
[root@worker-4 ~]# ovs-vsctl  --columns=name,mac_in_use,mtu find interface external_ids:"k8s.ovn.org/network"="vlan-1926"
name                : "040cd3693b52c_4"
mac_in_use          : "0a:49:89:cf:97:81"
mtu                 : 1400

[root@worker-4 ~]# ovs-vsctl get interface 040cd3693b52c_4 mtu external_ids
1400
{attached_mac="02:14:56:00:00:07", iface-id=default.vlan.1926_demo-virt_virt-launcher-rhel-node-1-g5qx8, iface-id-ver="aea9ed07-5e3d-425e-8c0d-49b4e7ba66fe", "k8s.ovn.org/nad"="default/vlan-1926", "k8s.ovn.org/network"=vlan-1926, ovn-installed="true", ovn-installed-ts="1750089711663", sandbox="040cd3693b52c65ff667993d67678a8aa1cd48472de7d59f598f059e0360600b"}
  • I have a VM and I want to find the interface on the switch
$ oc get vmis,pods -o wide -n demo-client
NAME                                        AGE    PHASE     IP             NODENAME   READY   LIVE-MIGRATABLE   PAUSED
virtualmachineinstance.kubevirt.io/client   5d4h   Running   192.168.4.38   worker-4   True    True

NAME                             READY   STATUS    RESTARTS   AGE     IP            NODE       NOMINATED NODE   READINESS GATES
pod/virt-launcher-client-dhl7p   1/1     Running   0          2d12h   10.131.2.83   worker-4   <none>           1/1

$ oc rsh -n demo-client pod/virt-launcher-client-dhl7p ip -c -br link
lo               UNKNOWN        00:00:00:00:00:00 <LOOPBACK,UP,LOWER_UP>
eth0@if100       UP             0a:58:0a:83:02:53 <BROADCAST,MULTICAST,UP,LOWER_UP>
bf1af69c74c-nic@if101 UP             e2:38:e8:39:35:1e <BROADCAST,MULTICAST,UP,LOWER_UP>
k6t-bf1af69c74c  UP             16:15:68:ec:93:fc <BROADCAST,MULTICAST,UP,LOWER_UP>
tapbf1af69c74c   UP             16:15:68:ec:93:fc <BROADCAST,MULTICAST,UP,LOWER_UP>
podbf1af69c74c   DOWN           02:14:56:00:00:08 <BROADCAST,NOARP>
# there is often a stderr line of output about Polkit before the XML
$ oc rsh -n demo-client pod/virt-launcher-client-dhl7p virsh dumpxml 1 | grep -E '^\s*<\??' | xpath -q -e /domain/devices/interface
<interface type="ethernet">
      <mac address="02:14:56:00:00:08" />
      <target dev="tapbf1af69c74c" managed="no" />
      <model type="virtio-non-transitional" />
      <mtu size="1400" />
      <alias name="ua-nic-1924" />
      <rom enabled="no" />
      <address type="pci" domain="0x0000" bus="0x01" slot="0x00" function="0x0" />
    </interface>

Interface index is 100 for eth0 and 101 for the NIC which is the uplink from the linux bridge k6t-bf1af69c74c, the downlink is the tap interface which is passed into the VM container.

So ssh to worker-4 and lookup the switch port with ifindex 101.

[root@worker-4 ~]# ovs-vsctl find interface ifindex=101
_uuid               : 6dfe40d9-ebe1-43ae-8e3c-70641d841168                                                                                                                admin_state         : up
bfd                 : {}
bfd_status          : {}
cfm_fault           : []
cfm_fault_status    : []
cfm_flap_count      : []
cfm_health          : []
cfm_mpid            : []
cfm_remote_mpids    : []
cfm_remote_opstate  : []
duplex              : full
error               : []
external_ids        : {attached_mac="02:14:56:00:00:08", iface-id=default.vlan.1924_demo-client_virt-launcher-client-dhl7p, iface-id-ver="1c71fdf9-44f3-4fb4-aefa-e950a957
1b57", "k8s.ovn.org/nad"="default/vlan-1924", "k8s.ovn.org/network"=vlan-1924, ovn-installed="true", ovn-installed-ts="1750089884077", sandbox="81a5ebcb6fa45d69a32a15d1e1
cf617113d4ccfc12338522adb4119bc295e10f"}
ifindex             : 101
ingress_policing_burst: 0
ingress_policing_kpkts_burst: 0
ingress_policing_kpkts_rate: 0
ingress_policing_rate: 0
lacp_current        : []
link_resets         : 2
link_speed          : 10000000000
link_state          : up
lldp                : {}
mac                 : []
mac_in_use          : "be:a0:20:9b:b1:de"
mtu                 : 1400
mtu_request         : []
name                : "81a5ebcb6fa45_3"
ofport              : 99
ofport_request      : []
options             : {}
other_config        : {}
statistics          : {collisions=0, rx_bytes=4398008, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_missed_errors=0, rx_multicast_packets=0, rx_over_err=0,
 rx_packets=47894, tx_bytes=1275190855, tx_dropped=0, tx_errors=0, tx_packets=1882373, upcall_errors=0, upcall_packets=4728}
status              : {driver_name=veth, driver_version="1.0", firmware_version=""}
type                : ""
  • I know the virt launcher pod name and namespace
[root@worker-4 ~]# ovs-vsctl  --columns=name,mac_in_use,mtu find interface external_ids:iface-id=default.vlan.1924_demo-client_virt-launcher-client-dhl7p
name                : "81a5ebcb6fa45_3"
mac_in_use          : "be:a0:20:9b:b1:de"
mtu                 : 1400
@dlbewley
Copy link
Author

@dlbewley
Copy link
Author

Because my localnet NAD did not specify a MTU the ports are being created with a MTU of 1400 to allow for overhead when tunneled through geneve. This was breaking PXE boot. Since these are localnet ports there won't be any tunnelling. The fix is to set the MTU in the NAD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment