aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2011-04-08 16:37:22 -0700
committerBen Pfaff <blp@nicira.com>2011-04-11 10:55:52 -0700
commit8996f83642d6bd73a72d5864a1c6a66448b49214 (patch)
tree89bd2e45d1480f27225253de112db0b326e04c7d /lib
parent002d4a3c44a7a42fdfe5f40185fe3af0ed697454 (diff)
dpif-linux: Avoid segfault on netdev_get_stats() without kernel module.
netdev_linux_get_stats() calls into netdev_vport_get_stats(), which in turn attempts a transaction on genl_sock. If the kernel module isn't loaded, then genl_sock won't be there, and in any case there's nothing that guarantees that it's been initialized yet. This fixes the problem by ensuring that dpif_linux was initialized properly before attempting a transaction on genl_sock. Reported-by: Aaron Rosen <arosen@clemson.edu>
Diffstat (limited to 'lib')
-rw-r--r--lib/dpif-linux.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index 75cff0c4..fd08e640 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -1254,6 +1254,15 @@ dpif_linux_vport_transact(const struct dpif_linux_vport *request,
assert((reply != NULL) == (bufp != NULL));
+ error = dpif_linux_init();
+ if (error) {
+ if (reply) {
+ *bufp = NULL;
+ dpif_linux_vport_init(reply);
+ }
+ return error;
+ }
+
request_buf = ofpbuf_new(1024);
dpif_linux_vport_to_ofpbuf(request, request_buf);
error = nl_sock_transact(genl_sock, request_buf, bufp);