Better network reporting from FreeBSD VM via xenstore

From: Ondra Knezour <knezour_at_weboutsourcing.cz>
Date: Fri, 05 Aug 2022 13:43:55 UTC
Hello all,

it seems to me that there is some room to improve how are things about 
networking reported from FreeBSD VM to the hypervisor.

Now we have function xe_ip_if() in /usr/local/sbin/xe-update-guest-attrs 
which just grep for xn interfaces, read one IP address for each which is 
eventually written to the /var/cache/xenstore/attr/ethNUMBER/ip

First - from where the ip node comes? I didn't find any such in 
https://xenbits.xen.org/docs/unstable/misc/xenstore-paths.html

We have

xenstore ls attr
eth0 = ""
  ip = "10.0.0.1"
PVAddons = ""
  MajorVersion = "6"
  MinorVersion = "2"
  MicroVersion = "0"
  BuildVersion = "76888"
  Installed = "1"

But on Linux

xenstore ls | grep attr -A 50
attr = ""
  PVAddons = ""
   BuildVersion = "1"
   Installed = "1"
   MajorVersion = "8"
   MinorVersion = "1"
   MicroVersion = "50"
  vif = ""
   1 = ""
    ipv6 = ""
     0 = "fe80::9c30:52ff:fef1:8711"
    ipv4 = ""
     0 = "10.128.99.15"
   2 = ""
    ipv4 = ""
     0 = "10.0.1.15"
    ipv6 = ""
     0 = "fe80::e833:9cff:fe5e:c21c"
   0 = ""
    ipv4 = ""
     0 = "172.22.1.15"
    ipv6 = ""
     0 = "fe80::c0ff:d7ff:fee2:b5ff"
xenserver = ""
  attr = ""
  device = ""
   vbd3 = ""
    768 = ""
    5696 = ""
   vif = ""
    0 = ""
     static-ip-setting = ""
      mac = "c2:ff:d7:e2:b5:ff"
      error-code = "0"
      error-msg = ""
      enabled = "0"
      enabled6 = "0"
    1 = ""
     static-ip-setting = ""
      mac = "9e:30:52:f1:87:11"
      error-code = "0"
      error-msg = ""
      enabled = "0"
      enabled6 = "0"
    2 = ""
     static-ip-setting = ""
      mac = "ea:33:9c:5e:c2:1c"
      error-code = "0"
      error-msg = ""
      enabled = "0"
      enabled6 = "0"

And secondly - I have multiple interfaces in VM, renamed by VLANs their 
are connected to. Some of them have multiple IPv4 addresses. Some also 
have IPv6 address(es). Bummer, I don't see any of this in pool 
management. And I wouldn't even without interface renames, because we 
report only one IPv4 address. First problem may be solved with some 
creative work with /etc/rc.conf, for example using result of following 
command in adition to simple ifconfig | grep xn

sysrc -a | grep -E "ifconfig_xn[[:digit:]]_name"
ifconfig_xn0_name: vlan1000
ifconfig_xn1_name: vlan1001
ifconfig_xn2_name: vlan2000

or list all ethernet interfaces (ifconfig -l ether) and look for 
ifconfig_xnX_name line for each not(xn). But regarding other missing 
info/nodes, I just don't know. May someone please enlighten me what is 
missing on our side?

uname -a
FreeBSD hostname 13.1-RELEASE FreeBSD 13.1-RELEASE 
releng/13.1-n250148-fc952ac2212 GENERIC amd64

pkg info xe\*
xe-guest-utilities-6.2.0_3
xen-guest-tools-4.14.0



-- 
Best regards

Ondra Knezour