diff options
author | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2010-03-29 16:38:51 +0200 |
---|---|---|
committer | Jiri Olsa <Jiri Olsa jolsa@redhat.com> | 2010-03-29 16:38:51 +0200 |
commit | b19b72eebbe375efe062c47468155d986db57c1f (patch) | |
tree | 1b8fb8bc4a94e0be8282b6ed21baa26365cf1453 | |
parent | 6ebd057e3ee33870481defeb2bacabe995e6e354 (diff) | |
download | tsnif-b19b72eebbe375efe062c47468155d986db57c1f.tar.gz tsnif-b19b72eebbe375efe062c47468155d986db57c1f.tar.xz tsnif-b19b72eebbe375efe062c47468155d986db57c1f.zip |
NETLINK_NO_ENOBUFS support
-rw-r--r-- | src/fsm.c | 2 | ||||
-rw-r--r-- | src/trans-libnl.c | 19 |
2 files changed, 20 insertions, 1 deletions
@@ -51,7 +51,7 @@ static int new(struct tsnif_handle *h, case TSNIF_CMD_ATTACH: /* got ATTACH cmd without error ??? */ err = -EINVAL; - if (msg->err) + if (!msg->err) break; err = process_error(h, term, msg->error); diff --git a/src/trans-libnl.c b/src/trans-libnl.c index e692cd9..e49407d 100644 --- a/src/trans-libnl.c +++ b/src/trans-libnl.c @@ -9,6 +9,10 @@ #include "intf.h" #include "trans.h" +#ifndef SOL_NETLINK +#define SOL_NETLINK 270 +#endif + TSNIF_POLICY(gnl_policy); static int ack_cb(struct nl_msg *msg, void *arg) @@ -101,6 +105,15 @@ static int parse_cb(struct nl_msg *msg, void *arg) return CB_RET(h->cb(h, &m)); } +static int set_no_enobufs(struct trans_handle *h) +{ + int val = 1; + + return setsockopt(trans_fd(h), + SOL_NETLINK, NETLINK_NO_ENOBUFS, + &val, sizeof(val)); +} + int trans_init(struct trans_handle *h, trans_cb_t cb) { struct nl_handle *sock; @@ -125,6 +138,7 @@ int trans_init(struct trans_handle *h, trans_cb_t cb) TSNIF_DEBUG("tsnif module found\n"); + nl_socket_modify_cb(sock, NL_CB_VALID, NL_CB_CUSTOM, parse_cb, h); nl_socket_modify_cb(sock, NL_CB_SEND_ACK, NL_CB_CUSTOM, ack_cb, h); nl_socket_modify_cb(sock, NL_CB_SEQ_CHECK, NL_CB_CUSTOM, seq_cb, h); @@ -133,6 +147,11 @@ int trans_init(struct trans_handle *h, trans_cb_t cb) h->sock = sock; h->family = family; h->cb = cb; + + err = set_no_enobufs(h); + if (err) + TSNIF_DEBUG("failed to set ENOBUFS, moving on...\n"); + return 0; } |