/* The ODPP_NONE "reserved" port number uses the "ovs-system"'s
* channel, since it is not heavily loaded. */
uint32_t idx = port_idx >= dpif->uc_array_size ? 0 : port_idx;
- pid = nl_sock_pid(dpif->channels[idx].sock);
+ const struct nl_sock *sock = dpif->channels[idx].sock;
+ pid = sock ? nl_sock_pid(sock) : 0;
}
ovs_mutex_unlock(&dpif->upcall_lock);
return 0;
}
-static bool
+static int
dpif_linux_port_dump_next__(const struct dpif *dpif_, struct nl_dump *dump,
struct dpif_linux_vport *vport)
{
break;
default:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
}
break;
default:
- NOT_REACHED();
+ OVS_NOT_REACHED();
}
ofpbuf_uninit(&aux->request);
dpif->n_events = dpif->event_offset = 0;
dpif_linux_port_dump_start__(dpif_, &dump);
- while (dpif_linux_port_dump_next__(dpif_, &dump, &vport)) {
+ while (!dpif_linux_port_dump_next__(dpif_, &dump, &vport)) {
uint32_t port_no = odp_to_u32(vport.port_no);
struct nl_sock *sock = (port_no < dpif->uc_array_size
? dpif->channels[port_no].sock
return EINVAL;
}
- memset(upcall, 0, sizeof *upcall);
+ /* (Re)set ALL fields of '*upcall' on successful return. */
upcall->type = type;
- upcall->packet = buf;
- upcall->packet->data = CONST_CAST(struct nlattr *,
- nl_attr_get(a[OVS_PACKET_ATTR_PACKET]));
- upcall->packet->size = nl_attr_get_size(a[OVS_PACKET_ATTR_PACKET]);
upcall->key = CONST_CAST(struct nlattr *,
nl_attr_get(a[OVS_PACKET_ATTR_KEY]));
upcall->key_len = nl_attr_get_size(a[OVS_PACKET_ATTR_KEY]);
upcall->userdata = a[OVS_PACKET_ATTR_USERDATA];
+
+ /* Allow overwriting the netlink attribute header without reallocating. */
+ ofpbuf_use_stub(&upcall->packet,
+ CONST_CAST(struct nlattr *,
+ nl_attr_get(a[OVS_PACKET_ATTR_PACKET])) - 1,
+ nl_attr_get_size(a[OVS_PACKET_ATTR_PACKET]) +
+ sizeof(struct nlattr));
+ upcall->packet.data = (char *)upcall->packet.data + sizeof(struct nlattr);
+ upcall->packet.size = nl_attr_get_size(a[OVS_PACKET_ATTR_PACKET]);
+
*dp_ifindex = ovs_header->dp_ifindex;
return 0;