idiag: deprecate IDIAG_SS_* socket states

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.

Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
This commit is contained in:
Thomas Haller 2014-11-24 17:14:50 +01:00
parent 3b5226e3a2
commit 94039ca48a
3 changed files with 38 additions and 30 deletions

View file

@ -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

View file

@ -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
*

View file

@ -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));