Commit 598790eb authored by Andrei Vagin's avatar Andrei Vagin

tcp: be ready that a size of tcp_info can be changed

(00.052683) Error (soccr/soccr.c:166): Failed to obtain TCP_INFO: No error information

We don't need a whole tcp info, so get only a part
what we are going to use.
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 7178717b
...@@ -246,7 +246,14 @@ static struct inet_sk_desc *gen_uncon_sk(int lfd, const struct fd_parms *p, int ...@@ -246,7 +246,14 @@ static struct inet_sk_desc *gen_uncon_sk(int lfd, const struct fd_parms *p, int
sk->sd.ino = p->stat.st_ino; sk->sd.ino = p->stat.st_ino;
if (proto == IPPROTO_TCP) { if (proto == IPPROTO_TCP) {
struct tcp_info info; struct {
__u8 tcpi_state;
__u8 tcpi_ca_state;
__u8 tcpi_retransmits;
__u8 tcpi_probes;
__u8 tcpi_backoff;
__u8 tcpi_options;
} info;
aux = sizeof(info); aux = sizeof(info);
ret = getsockopt(lfd, SOL_TCP, TCP_INFO, &info, &aux); ret = getsockopt(lfd, SOL_TCP, TCP_INFO, &info, &aux);
......
...@@ -157,7 +157,18 @@ void libsoccr_release(struct libsoccr_sk *sk) ...@@ -157,7 +157,18 @@ void libsoccr_release(struct libsoccr_sk *sk)
free(sk); free(sk);
} }
static int refresh_sk(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, struct tcp_info *ti) struct soccr_tcp_info {
__u8 tcpi_state;
__u8 tcpi_ca_state;
__u8 tcpi_retransmits;
__u8 tcpi_probes;
__u8 tcpi_backoff;
__u8 tcpi_options;
__u8 tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
};
static int refresh_sk(struct libsoccr_sk *sk,
struct libsoccr_sk_data *data, struct soccr_tcp_info *ti)
{ {
int size; int size;
socklen_t olen = sizeof(*ti); socklen_t olen = sizeof(*ti);
...@@ -215,7 +226,8 @@ static int refresh_sk(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, str ...@@ -215,7 +226,8 @@ static int refresh_sk(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, str
return 0; return 0;
} }
static int get_stream_options(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, struct tcp_info *ti) static int get_stream_options(struct libsoccr_sk *sk,
struct libsoccr_sk_data *data, struct soccr_tcp_info *ti)
{ {
int ret; int ret;
socklen_t auxl; socklen_t auxl;
...@@ -353,7 +365,7 @@ err_recv: ...@@ -353,7 +365,7 @@ err_recv:
int libsoccr_save(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, unsigned data_size) int libsoccr_save(struct libsoccr_sk *sk, struct libsoccr_sk_data *data, unsigned data_size)
{ {
struct tcp_info ti; struct soccr_tcp_info ti;
if (!data || data_size < SOCR_DATA_MIN_SIZE) { if (!data || data_size < SOCR_DATA_MIN_SIZE) {
loge("Invalid input parameters\n"); loge("Invalid input parameters\n");
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <linux/types.h>
#include "zdtmtst.h" #include "zdtmtst.h"
...@@ -14,7 +15,9 @@ static int port = 8880; ...@@ -14,7 +15,9 @@ static int port = 8880;
static int check_socket_closed(int sk) static int check_socket_closed(int sk)
{ {
int err, buffer = 0; int err, buffer = 0;
struct tcp_info info; struct {
__u8 tcpi_state;
} info;
socklen_t len = sizeof(info); socklen_t len = sizeof(info);
err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len); err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <sys/socket.h> #include <sys/socket.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <linux/types.h>
#include "zdtmtst.h" #include "zdtmtst.h"
...@@ -13,7 +14,9 @@ static int port = 8880; ...@@ -13,7 +14,9 @@ static int port = 8880;
static int check_socket_state(int sk, int state) static int check_socket_state(int sk, int state)
{ {
int err; int err;
struct tcp_info info; struct {
__u8 tcpi_state;
} info;
socklen_t len = sizeof(info); socklen_t len = sizeof(info);
err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len); err = getsockopt(sk, IPPROTO_TCP, TCP_INFO, (void *)&info, &len);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment