2011-05-13 15 views
19

Vorrei conoscere i possibili valori della colonna st in /proc/net/tcp. Penso che la colonna st corrisponda alla colonna STATE da netstat(8) o ss(8).Elenco degli stati dei socket interni possibili da/proc

sono riuscito ad identificare tre codici:

sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 
0: 0100007F:08A0 00000000:0000 0A 00000000:00000000 00:00000000 00000000  0  0 7321 1 ffff81002f449980 3000 0 0 2 -1      
1: 00000000:006F 00000000:0000 0A 00000000:00000000 00:00000000 00000000  0  0 6656 1 ffff81003a30c080 3000 0 0 2 -1      
2: 00000000:0272 00000000:0000 0A 00000000:00000000 00:00000000 00000000  0  0 6733 1 ffff81003a30c6c0 3000 0 0 2 -1      
3: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000  0  0 7411 1 ffff81002f448d00 3000 0 0 2 -1      
4: 0100007F:0019 00000000:0000 0A 00000000:00000000 00:00000000 00000000  0  0 7520 1 ffff81002f4486c0 3000 0 0 2 -1      
5: 0100007F:089F 00000000:0000 0A 00000000:00000000 00:00000000 00000000  0  0 7339 1 ffff81002f449340 3000 0 0 2 -1   
6: 0100007F:E753 0100007F:0016 01 00000000:00000000 02:000AFA92 00000000 500  0 18198 2 ffff81002f448080 204 40 20 2 -1     
7: 0100007F:E752 0100007F:0016 06 00000000:00000000 03:000005EC 00000000  0  0 0 2 ffff81000805dc00          

Gli spettacoli di cui sopra:

  • On Line SL 0: una porta di ascolto su TCP/2208. st = 0A = LISTEN
  • On line sl 6: una sessione stabilita su tcp/22. st = 01 = ESTABLISHED
  • On line sl 7: Un socket nello stato TIME_WAIT dopo il logout ssh. Nessun inode. st = 06 = TIME_WAIT

Qualcuno può espandersi in questo elenco? Il proc(5) pagina di manuale è piuttosto laconico sull'argomento affermando:

/proc/net/tcp 
      Holds a dump of the TCP socket table. Much of the information is not of use apart from debugging. The "sl" value is the kernel hash slot for the socket, the "local address" is the local address and 
      port number pair. The "remote address" is the remote address and port number pair (if connected). ’St’ is the internal status of the socket. The ’tx_queue’ and ’rx_queue’ are the outgoing and incom- 
      ing data queue in terms of kernel memory usage. The "tr", "tm->when", and "rexmits" fields hold internal information of the kernel socket state and are only useful for debugging. The "uid" field 
      holds the effective UID of the creator of the socket. 

E su una nota correlata, l'uscita/proc/net/tcp sopra sta mostrando alcuni processi di ascolto (2208, 62, 111, ecc). Tuttavia, non riesco a vedere una connessione tcp in ascolto su tcp/22, sebbene siano mostrati gli stati stabiliti e time_wait. Sì, posso vederli in /proc/net/tcp6 ma non dovrebbero essere presenti anche in /proc/net/tcp? L'output Netstat lo mostra in modo diverso rispetto alle applicazioni legate solo a ipv4. Per esempio.

tcp  0  0 0.0.0.0:111     0.0.0.0:*     LISTEN  4231/portmap   
tcp  0  0 :::22      :::*      LISTEN  4556/sshd   

Molte grazie, -Andrew

+0

Ecco alcuni [ulteriori letture] (http://www.readmespot.com/question/f/21657/semantics-of----and-0-0-0-0-in-dual-stack- ose) su IPv4 a IPv6 mappatura se qualcuno è interessato –

+0

Questo è un link morto ora. Penso che probabilmente si collega a questo: http://serverfault.com/questions/21657/semantics-of-and-0-0-0-0-in-dual-stack-oses – user314104

risposta

27

Devono corrispondere alla enum in ./include/net/tcp_states.h nei sorgenti del kernel Linux:

enum { 
    TCP_ESTABLISHED = 1, 
    TCP_SYN_SENT, 
    TCP_SYN_RECV, 
    TCP_FIN_WAIT1, 
    TCP_FIN_WAIT2, 
    TCP_TIME_WAIT, 
    TCP_CLOSE, 
    TCP_CLOSE_WAIT, 
    TCP_LAST_ACK, 
    TCP_LISTEN, 
    TCP_CLOSING, /* Now a valid state */ 

    TCP_MAX_STATES /* Leave at the end! */ 
}; 

quanto riguarda la tua domanda 2., sono davvero sicuro che c'è non un ascolto sshd su es 0.0.0.0:22? In caso contrario, sospetto che ciò che stai vedendo sia correlato ai socket v4-mapped-on-v6, vedi ad es. man 7 ipv6

+0

Grazie, non so perché io non l'ho capito quando avevi greppato la fonte. Penso che stavo provando ad abbinare su 'EST'. Non c'è sicuramente alcun servizio su '0016', quindi deve essere la mappatura da v4 a v6 come si menziona. Nuovo per me. –

+0

Inoltre, non sono completamente sicuro di come ottenere valori esadecimali da 'tcp_states.h'. Posso solo vedere ESTABLISHED avere un valore come hai incollato sopra, ma in che modo gli altri stati hanno funzionato e abbinati? –

+2

è un enum e inizia con 1. Quindi ad es. TCP_SYN_SENT è 2, TCP_LISTEN è 10. E 10 in decimale è 'A' in esadecimale, che è il' 0A' che vedi in/proc/net/tcp – nos

Problemi correlati