+
+ /* On XenServer systems, each network has one or more UUIDs
+ * associated with it, which we provide to the controller.
+ */
+ n_uuid = cfg_count("bridge.%s.xs-network-uuids", br_list.names[i]);
+ if (n_uuid) {
+ struct ofmptsr_dp_uuid *dp_uuid_tlv;
+ size_t tlv_len = sizeof(*dp_uuid_tlv) + n_uuid * OFMP_UUID_LEN;
+ int j;
+
+ dp_uuid_tlv = ofpbuf_put_zeros(buffer, sizeof(*dp_uuid_tlv));
+ dp_uuid_tlv->type = htons(OFMPTSR_DP_UUID);
+ dp_uuid_tlv->len = htons(tlv_len);
+ dp_uuid_tlv->dp_id = htonll(dp_id);
+
+ for (j=0; j<n_uuid; j++) {
+ const char *dp_uuid = cfg_get_string(j,
+ "bridge.%s.xs-network-uuids", br_list.names[i]);
+
+ /* The UUID list could change underneath us, so just
+ * fill with zeros in that case. Another update will be
+ * initiated shortly, which should contain corrected data.
+ */
+ if (dp_uuid) {
+ ofpbuf_put(buffer, dp_uuid, OFMP_UUID_LEN);
+ } else {
+ ofpbuf_put_zeros(buffer, OFMP_UUID_LEN);
+ }
+ }
+ }
+ }
+
+ /* On XenServer systems, extended information about virtual interfaces
+ * (VIFs) is available, which is needed by the controller.
+ */
+ svec_init(&port_list);
+ bridge_get_ifaces(&port_list);
+ for (i=0; i < port_list.n; i++) {
+ const char *vif_uuid, *vm_uuid, *net_uuid;
+ uint64_t vif_mac;
+ struct ofmptsr_vif *vif_tlv;
+
+ vif_uuid = cfg_get_string(0, "port.%s.vif-uuid", port_list.names[i]);
+ if (!vif_uuid) {
+ continue;
+ }
+
+ vif_tlv = ofpbuf_put_zeros(buffer, sizeof(*vif_tlv));
+ vif_tlv->type = htons(OFMPTSR_VIF);
+ vif_tlv->len = htons(sizeof(*vif_tlv));
+
+ memcpy(vif_tlv->name, port_list.names[i], strlen(port_list.names[i])+1);
+ memcpy(vif_tlv->vif_uuid, vif_uuid, sizeof(vif_tlv->vif_uuid));
+
+ vm_uuid = cfg_get_string(0, "port.%s.vm-uuid", port_list.names[i]);
+ if (vm_uuid) {
+ memcpy(vif_tlv->vm_uuid, vm_uuid, sizeof(vif_tlv->vm_uuid));
+ } else {
+ /* In case the vif disappeared underneath us. */
+ memset(vif_tlv->vm_uuid, '\0', sizeof(vif_tlv->vm_uuid));
+ }
+
+ net_uuid = cfg_get_string(0, "port.%s.net-uuid", port_list.names[i]);
+ if (net_uuid) {
+ memcpy(vif_tlv->net_uuid, net_uuid, sizeof(vif_tlv->net_uuid));
+ } else {
+ /* In case the vif disappeared underneath us. */
+ memset(vif_tlv->net_uuid, '\0', sizeof(vif_tlv->net_uuid));
+ }
+
+ vif_mac = cfg_get_mac(0, "port.%s.vif-mac", port_list.names[i]);
+ vif_tlv->vif_mac = htonll(vif_mac);