Move nl_socket_set_buffer_size() to be called after genl_connect(), otherwise nl_socket_set_buffer_size() always returns an NLE_BAD_SOCK error because sk->s_fd is equal to -1 at that stage. Signed-off-by: Gil Treibush <gil.tribush@xxxxxxxxx> --- iw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iw.c b/iw.c index 0f511d9..e3742cd 100644 --- a/iw.c +++ b/iw.c @@ -54,14 +54,14 @@ static int nl80211_init(struct nl80211_state *state) return -ENOMEM; } - nl_socket_set_buffer_size(state->nl_sock, 8192, 8192); - if (genl_connect(state->nl_sock)) { fprintf(stderr, "Failed to connect to generic netlink.\n"); err = -ENOLINK; goto out_handle_destroy; } + nl_socket_set_buffer_size(state->nl_sock, 8192, 8192); + state->nl80211_id = genl_ctrl_resolve(state->nl_sock, "nl80211"); if (state->nl80211_id < 0) { fprintf(stderr, "nl80211 not found.\n"); -- 1.9.1 --------------------------------------------------------------------- A member of the Intel Corporation group of companies This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies. -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html