static int ovs_packet_family;
/* Generic Netlink socket. */
-static struct nl_sock *genl_sock;
static struct nln *nln = NULL;
static int dpif_linux_init(void);
buf = ofpbuf_new(1024);
dpif_linux_vport_to_ofpbuf(&request, buf);
- nl_dump_start(&state->dump, genl_sock, buf);
+ nl_dump_start(&state->dump, NETLINK_GENERIC, buf);
ofpbuf_delete(buf);
return 0;
buf = ofpbuf_new(1024);
dpif_linux_flow_to_ofpbuf(&request, buf);
- nl_dump_start(&state->dump, genl_sock, buf);
+ nl_dump_start(&state->dump, NETLINK_GENERIC, buf);
ofpbuf_delete(buf);
state->buf = NULL;
if (error == ENOENT) {
VLOG_DBG("dumped flow disappeared on get");
} else if (error) {
- VLOG_WARN("error fetching dumped flow: %s", strerror(error));
+ VLOG_WARN("error fetching dumped flow: %s",
+ ovs_strerror(error));
}
}
} while (error);
ofpbuf_use_stub(&request, request_stub, sizeof request_stub);
dpif_linux_encode_execute(dp_ifindex, execute, &request);
- error = nl_sock_transact(genl_sock, &request, NULL);
+ error = nl_transact(NETLINK_GENERIC, &request, NULL);
ofpbuf_uninit(&request);
return error;
for (i = 0; i < n_ops; i++) {
txnsp[i] = &auxes[i].txn;
}
- nl_sock_transact_multiple(genl_sock, txnsp, n_ops);
+ nl_transact_multiple(NETLINK_GENERIC, txnsp, n_ops);
for (i = 0; i < n_ops; i++) {
struct op_auxdata *aux = &auxes[i];
} else {
VLOG_WARN_RL(&error_rl,
"%s: failed to set upcall pid on port: %s",
- dpif_name(&dpif->dpif), strerror(error));
+ dpif_name(&dpif->dpif), ovs_strerror(error));
nl_sock_destroy(sock);
if (error == ENODEV || error == ENOENT) {
} while (retval < 0 && errno == EINTR);
if (retval < 0) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
- VLOG_WARN_RL(&rl, "epoll_wait failed (%s)", strerror(errno));
+ VLOG_WARN_RL(&rl, "epoll_wait failed (%s)", ovs_strerror(errno));
} else if (retval > 0) {
dpif->n_events = retval;
}
static int
dpif_linux_init(void)
{
- static int error = -1;
+ static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
+ static int error;
- if (error < 0) {
+ if (ovsthread_once_start(&once)) {
unsigned int ovs_vport_mcgroup;
error = nl_lookup_genl_family(OVS_DATAPATH_FAMILY,
error = nl_lookup_genl_family(OVS_PACKET_FAMILY,
&ovs_packet_family);
}
- if (!error) {
- error = nl_sock_create(NETLINK_GENERIC, &genl_sock);
- }
if (!error) {
error = nl_lookup_genl_mcgroup(OVS_VPORT_FAMILY, OVS_VPORT_MCGROUP,
&ovs_vport_mcgroup,
nln = nln_create(NETLINK_GENERIC, ovs_vport_mcgroup,
dpif_linux_nln_parse, &vport);
}
+
+ ovsthread_once_done(&once);
}
return error;
ofpbuf_delete(buf);
} else if (error != ENODEV && error != ENOENT) {
VLOG_WARN_RL(&error_rl, "%s: vport query failed (%s)",
- name, strerror(error));
+ name, ovs_strerror(error));
}
return reply.type == OVS_VPORT_TYPE_INTERNAL;
request_buf = ofpbuf_new(1024);
dpif_linux_vport_to_ofpbuf(request, request_buf);
- error = nl_sock_transact(genl_sock, request_buf, bufp);
+ error = nl_transact(NETLINK_GENERIC, request_buf, bufp);
ofpbuf_delete(request_buf);
if (reply) {
buf = ofpbuf_new(1024);
dpif_linux_dp_to_ofpbuf(&request, buf);
- nl_dump_start(dump, genl_sock, buf);
+ nl_dump_start(dump, NETLINK_GENERIC, buf);
ofpbuf_delete(buf);
}
request_buf = ofpbuf_new(1024);
dpif_linux_dp_to_ofpbuf(request, request_buf);
- error = nl_sock_transact(genl_sock, request_buf, bufp);
+ error = nl_transact(NETLINK_GENERIC, request_buf, bufp);
ofpbuf_delete(request_buf);
if (reply) {
request_buf = ofpbuf_new(1024);
dpif_linux_flow_to_ofpbuf(request, request_buf);
- error = nl_sock_transact(genl_sock, request_buf, bufp);
+ error = nl_transact(NETLINK_GENERIC, request_buf, bufp);
ofpbuf_delete(request_buf);
if (reply) {