[PATCH 06/13] idiag: deprecate IDIAG_SS_* socket states
Thomas Haller
thaller at redhat.com
Mon Nov 24 08:14:50 PST 2014
These values mirror TCP_* socket states from 'netinit/tcp.h'.
There is no good reason to expose a copy of those values.
User space should use the original values (if they care).
The only value that is actually useful is IDIAGNL_SS_ALL.
Signed-off-by: Thomas Haller <thaller at redhat.com>
---
include/netlink/idiag/idiagnl.h | 39 +++++++++++++++++++++++++--------------
lib/idiag/idiag.c | 27 ++++++++++++---------------
src/idiag-socket-details.c | 2 +-
3 files changed, 38 insertions(+), 30 deletions(-)
diff --git a/include/netlink/idiag/idiagnl.h b/include/netlink/idiag/idiagnl.h
index 9f3345a..3b3b57e 100644
--- a/include/netlink/idiag/idiagnl.h
+++ b/include/netlink/idiag/idiagnl.h
@@ -32,28 +32,39 @@ extern "C" {
/**
* Socket state identifiers
* @ingroup idiag
+ * @deprecated: use instead the TCP_* defines from netinet/tcp.h.
*/
enum {
- IDIAG_SS_UNKNOWN,
- IDIAG_SS_ESTABLISHED,
- IDIAG_SS_SYN_SENT,
- IDIAG_SS_SYN_RECV,
- IDIAG_SS_FIN_WAIT1,
- IDIAG_SS_FIN_WAIT2,
- IDIAG_SS_TIME_WAIT,
- IDIAG_SS_CLOSE,
- IDIAG_SS_CLOSE_WAIT,
- IDIAG_SS_LAST_ACK,
- IDIAG_SS_LISTEN,
- IDIAG_SS_CLOSING,
- IDIAG_SS_MAX
+ IDIAG_SS_UNKNOWN = 0,
+
+ IDIAG_SS_ESTABLISHED = 1, /* TCP_ESTABLISHED */
+ IDIAG_SS_SYN_SENT = 2, /* TCP_SYN_SENT */
+ IDIAG_SS_SYN_RECV = 3, /* TCP_SYN_RECV */
+ IDIAG_SS_FIN_WAIT1 = 4, /* TCP_FIN_WAIT1 */
+ IDIAG_SS_FIN_WAIT2 = 5, /* TCP_FIN_WAIT2 */
+ IDIAG_SS_TIME_WAIT = 6, /* TCP_TIME_WAIT */
+ IDIAG_SS_CLOSE = 7, /* TCP_CLOSE */
+ IDIAG_SS_CLOSE_WAIT = 8, /* TCP_CLOSE_WAIT */
+ IDIAG_SS_LAST_ACK = 9, /* TCP_LAST_ACK */
+ IDIAG_SS_LISTEN = 10, /* TCP_LISTEN */
+ IDIAG_SS_CLOSING = 11, /* TCP_CLOSING */
+
+ IDIAG_SS_MAX = 12,
};
/**
* Macro to represent all socket states.
* @ingroup idiag
*/
-#define IDIAG_SS_ALL ((1<<IDIAG_SS_MAX)-1)
+#define IDIAGNL_SS_ALL (((1<<12)-1))
+
+/**
+ * Macro to represent all socket states.
+ * @ingroup idiag
+ * @deprecated
+ */
+#define IDIAG_SS_ALL IDIAGNL_SS_ALL
+
/**
* Inet Diag extended attributes
diff --git a/lib/idiag/idiag.c b/lib/idiag/idiag.c
index 2162352..303ffea 100644
--- a/lib/idiag/idiag.c
+++ b/lib/idiag/idiag.c
@@ -82,25 +82,22 @@ int idiagnl_send_simple(struct nl_sock *sk, int flags, uint8_t family,
*/
static const struct trans_tbl idiag_states[] = {
- __ADD(IDIAG_SS_UNKNOWN, unknown),
- __ADD(IDIAG_SS_ESTABLISHED, established),
- __ADD(IDIAG_SS_SYN_SENT, syn_sent),
- __ADD(IDIAG_SS_SYN_RECV, syn_recv),
- __ADD(IDIAG_SS_FIN_WAIT1, fin_wait),
- __ADD(IDIAG_SS_FIN_WAIT2, fin_wait2),
- __ADD(IDIAG_SS_TIME_WAIT, time_wait),
- __ADD(IDIAG_SS_CLOSE, close),
- __ADD(IDIAG_SS_CLOSE_WAIT, close_wait),
- __ADD(IDIAG_SS_LAST_ACK, last_ack),
- __ADD(IDIAG_SS_LISTEN, listen),
- __ADD(IDIAG_SS_CLOSING, closing),
- __ADD(IDIAG_SS_MAX, max),
- { ((1<<IDIAG_SS_MAX)-1), "all" }
+ __ADD(TCP_ESTABLISHED, established),
+ __ADD(TCP_SYN_SENT, syn_sent),
+ __ADD(TCP_SYN_RECV, syn_recv),
+ __ADD(TCP_FIN_WAIT1, fin_wait),
+ __ADD(TCP_FIN_WAIT2, fin_wait2),
+ __ADD(TCP_TIME_WAIT, time_wait),
+ __ADD(TCP_CLOSE, close),
+ __ADD(TCP_CLOSE_WAIT, close_wait),
+ __ADD(TCP_LAST_ACK, last_ack),
+ __ADD(TCP_LISTEN, listen),
+ __ADD(TCP_CLOSING, closing),
};
/**
* Convert inet diag socket states to strings.
- * @arg state inetdiag socket state (e.g., IDIAG_SS_ESTABLISHED)
+ * @arg state inetdiag socket state (e.g., TCP_ESTABLISHED)
* @arg buf output buffer which will hold string result
* @arg len length in bytes of the output buffer
*
diff --git a/src/idiag-socket-details.c b/src/idiag-socket-details.c
index 9568676..17bcef2 100644
--- a/src/idiag-socket-details.c
+++ b/src/idiag-socket-details.c
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
}
}
- if ((err = idiagnl_msg_alloc_cache(sock, AF_INET, IDIAG_SS_ALL,
+ if ((err = idiagnl_msg_alloc_cache(sock, AF_INET, IDIAGNL_SS_ALL,
&idiag_cache))) {
nl_cli_fatal(err, "Unable to allocate idiag msg cache: %s",
nl_geterror(err));
--
1.9.3
More information about the libnl
mailing list