Skip to content

Commit

Permalink
net-test: packetdrill: fix compilation/runtime error for linux 3.x
Browse files Browse the repository at this point in the history
For linux 3.10, TCP_CC_INFO and SO_MEMINFO are not supported. When we define HAVE_SO_MEMINFO / HAVE_TCP_CC_INFO as 0, functions like write_tcp_bbr_cc_info and write_so_meminfo will not be accessed. So wrap them with #ifdef and #endif.

Also, for lower linux version, tcp_info option value has less fields(e.g. 120 bytes). So remove the size assert.

Change-Id: Ibb4458067becdb857ff82f680bdd37727b5c2378
  • Loading branch information
Shu Ma committed Dec 24, 2018
1 parent 98f2e73 commit 93c5fbf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions gtests/net/packetdrill/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ static void write_tcp_info(struct code_state *code,
const struct _tcp_info *info,
int len)
{
assert(len >= sizeof(struct _tcp_info));

write_symbols(code);

/* Emit the recorded values of tcpi_foo values. */
Expand Down Expand Up @@ -198,6 +196,7 @@ static void write_tcp_info(struct code_state *code,
emit_var_end(code);
}

#if HAVE_TCP_CC_INFO
/* Write out a formatted representation of the given _tcp_bbr_info buffer. */
static void write_tcp_bbr_cc_info(struct code_state *code,
const union _tcp_cc_info *info,
Expand Down Expand Up @@ -264,7 +263,9 @@ static void write_tcp_cc_info(struct code_state *code,
write_tcp_vegas_cc_info(code, info, len);
emit_var_end(code);
}
#endif /* HAVE_TCP_CC_INFO */

#if HAVE_SO_MEMINFO
/* Write out a formatted representation of the given mem_info buffer. */
static void write_so_meminfo(struct code_state *code,
const u32 *mem_info,
Expand All @@ -284,6 +285,7 @@ static void write_so_meminfo(struct code_state *code,

emit_var_end(code);
}
#endif /* HAVE_SO_MEMINFO */
#endif /* linux */

#if defined(__FreeBSD__)
Expand All @@ -293,8 +295,6 @@ static void write_tcp_info(struct code_state *code,
const struct _tcp_info *info,
int len)
{
assert(len >= sizeof(struct _tcp_info));

write_symbols(code);

/* Emit the recorded values of tcpi_foo values. */
Expand Down Expand Up @@ -729,7 +729,6 @@ void run_code_event(struct state *state, struct event *event,

void *data = NULL;
void *data_ext = NULL;
void *data_meminfo = NULL;
int data_len = 0;
#if HAVE_TCP_INFO
code->data_type = DATA_TCP_INFO;
Expand All @@ -755,6 +754,7 @@ void run_code_event(struct state *state, struct event *event,
#endif /* HAVE_TCP_CC_INFO */
#if HAVE_SO_MEMINFO
code->data_type = DATA_SO_MEMINFO;
void *data_meminfo = NULL;
data_meminfo = get_data(state, event, fd, code->data_type, &data_len);
if (data_meminfo)
append_data(code, code->data_type, data_meminfo, data_len);
Expand Down

0 comments on commit 93c5fbf

Please sign in to comment.