Merge remote-tracking branch 'origin/fastpath'

* origin/fastpath:
  Remove unnecessary assert in ICMP analyzer (addresses #822).
  Improve script debugger backtrace and print commands.
This commit is contained in:
Robin Sommer 2012-05-30 17:03:31 -07:00
commit e9354284eb
10 changed files with 92 additions and 12 deletions

45
CHANGES
View file

@ -1,4 +1,49 @@
2.0-395 | 2012-05-30 17:03:31 -0700
* Remove unnecessary assert in ICMP analyzer which could lead to
aborts. Addresses #822.
* Improve script debugger backtrace and print commands. (Jon Siwek)
* Switching default DS compression to gzip. (Robin Sommer)
* Improve availability of IPv6 flow label in connection records.
This adds a "flow_label" field to the "endpoint" record type,
which is used for both the "orig" and "resp" fields of
"connection" records. The new "connection_flow_label_changed"
event also allows tracking of changes in flow labels: it's raised
each time one direction of the connection starts using a different
label. (Jon Siwek)
* Add unit tests for Broccoli SSL and Broccoli IPv6 connectivity.
(Jon Siwek)
* Remove AI_ADDRCONFIG getaddrinfo hints flag for listening sockets.
(Jon Siwek)
* Undo unnecessary communication protocol version bump. (Jon Siwek)
* Add support to Bro for connecting with peers over IPv6. (Jon Siwek)
- Communication::listen_ipv6 needs to be redef'd to true in order
for IPv6 listening sockets to be opened.
- Added Communication::listen_retry option as an interval at which
to retry binding to socket addresses that were already in use.
- Added some explicit baselines to check in the istate.events and
istate.events-ssl tests -- the SSL test was incorrectly passing
because it compared two empty files. (The files being empty
because "http/base" was given as an argument to Bro which it
couldn't handle because that script doesn't exist anymore).
- Support for communication over non-global IPv6 addresses. This
usually requires specifying an additional zone identifier (see
RFC 4007). The connect() and listen() BIFs have been changed to
accept this zone identifier as an argument.
2.0-377 | 2012-05-24 16:46:06 -0700 2.0-377 | 2012-05-24 16:46:06 -0700
* Documentation fixes. (Jon Siwek and Daniel Thayer) * Documentation fixes. (Jon Siwek and Daniel Thayer)

View file

@ -1 +1 @@
2.0-377 2.0-395

View file

@ -721,7 +721,6 @@ static char* get_prompt(bool reset_counter = false)
string get_context_description(const Stmt* stmt, const Frame* frame) string get_context_description(const Stmt* stmt, const Frame* frame)
{ {
char buf[1024];
ODesc d; ODesc d;
const BroFunc* func = frame->GetFunction(); const BroFunc* func = frame->GetFunction();
@ -739,10 +738,14 @@ string get_context_description(const Stmt* stmt, const Frame* frame)
loc.last_line = 0; loc.last_line = 0;
} }
safe_snprintf(buf, sizeof(buf), "In %s at %s:%d", size_t buf_size = strlen(d.Description()) + strlen(loc.filename) + 1024;
char* buf = new char[buf_size];
safe_snprintf(buf, buf_size, "In %s at %s:%d",
d.Description(), loc.filename, loc.last_line); d.Description(), loc.filename, loc.last_line);
return string(buf); string retval(buf);
delete [] buf;
return retval;
} }
int dbg_handle_debug_input() int dbg_handle_debug_input()
@ -924,6 +927,8 @@ bool post_execute_stmt(Stmt* stmt, Frame* f, Val* result, stmt_flow_type* flow)
// Evaluates the given expression in the context of the currently selected // Evaluates the given expression in the context of the currently selected
// frame. Returns the resulting value, or nil if none (or there was an error). // frame. Returns the resulting value, or nil if none (or there was an error).
Expr* g_curr_debug_expr = 0; Expr* g_curr_debug_expr = 0;
const char* g_curr_debug_error = 0;
bool in_debug = false;
// ### fix this hardwired access to external variables etc. // ### fix this hardwired access to external variables etc.
struct yy_buffer_state; struct yy_buffer_state;
@ -969,6 +974,11 @@ Val* dbg_eval_expr(const char* expr)
Val* result = 0; Val* result = 0;
if ( yyparse() ) if ( yyparse() )
{ {
if ( g_curr_debug_error )
debug_msg("Parsing expression '%s' failed: %s\n", expr, g_curr_debug_error);
else
debug_msg("Parsing expression '%s' failed\n", expr);
if ( g_curr_debug_expr ) if ( g_curr_debug_expr )
{ {
delete g_curr_debug_expr; delete g_curr_debug_expr;
@ -983,6 +993,9 @@ Val* dbg_eval_expr(const char* expr)
delete g_curr_debug_expr; delete g_curr_debug_expr;
g_curr_debug_expr = 0; g_curr_debug_expr = 0;
delete [] g_curr_debug_error;
g_curr_debug_error = 0;
in_debug = false;
return result; return result;
} }

View file

@ -553,6 +553,7 @@ int dbg_cmd_print(DebugCmd cmd, const vector<string>& args)
for ( int i = 0; i < int(args.size()); ++i ) for ( int i = 0; i < int(args.size()); ++i )
{ {
expr += args[i]; expr += args[i];
if ( i < int(args.size()) - 1 )
expr += " "; expr += " ";
} }
@ -566,8 +567,7 @@ int dbg_cmd_print(DebugCmd cmd, const vector<string>& args)
} }
else else
{ {
// ### Print something? debug_msg("<expression has no value>\n");
// debug_msg("<expression has no value>\n");
} }
return 1; return 1;

View file

@ -49,9 +49,7 @@ void ICMP_Analyzer::DeliverPacket(int len, const u_char* data,
const struct icmp* icmpp = (const struct icmp*) data; const struct icmp* icmpp = (const struct icmp*) data;
assert(caplen >= len); // Should have been caught earlier already. if ( ! ignore_checksums && caplen >= len )
if ( ! ignore_checksums )
{ {
int chksum = 0; int chksum = 0;

View file

@ -112,13 +112,14 @@ bool is_export = false; // true if in an export {} block
* (obviously not reentrant). * (obviously not reentrant).
*/ */
extern Expr* g_curr_debug_expr; extern Expr* g_curr_debug_expr;
extern bool in_debug;
extern const char* g_curr_debug_error;
#define YYLTYPE yyltype #define YYLTYPE yyltype
Expr* bro_this = 0; Expr* bro_this = 0;
int in_init = 0; int in_init = 0;
int in_record = 0; int in_record = 0;
bool in_debug = false;
bool resolving_global_ID = false; bool resolving_global_ID = false;
bool defining_global_ID = false; bool defining_global_ID = false;
@ -249,7 +250,6 @@ bro:
TOK_DEBUG { in_debug = true; } expr TOK_DEBUG { in_debug = true; } expr
{ {
g_curr_debug_expr = $3; g_curr_debug_expr = $3;
in_debug = false;
} }
; ;
@ -1685,6 +1685,9 @@ int yyerror(const char msg[])
strcat(msgbuf, "\nDocumentation mode is enabled: " strcat(msgbuf, "\nDocumentation mode is enabled: "
"remember to check syntax of ## style comments\n"); "remember to check syntax of ## style comments\n");
if ( in_debug )
g_curr_debug_error = copy_string(msg);
reporter->Error("%s", msgbuf); reporter->Error("%s", msgbuf);
return 0; return 0;

View file

@ -22,3 +22,11 @@
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p name addl notice peer #fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p name addl notice peer
#types time string addr port addr port string string bool string #types time string addr port addr port string string bool string
1334094648.590126 - - - - - truncated_IP - F bro 1334094648.590126 - - - - - truncated_IP - F bro
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path weird
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p name addl notice peer
#types time string addr port addr port string string bool string
1338328954.078361 - - - - - internally_truncated_header - F bro

Binary file not shown.

Binary file not shown.

View file

@ -6,4 +6,17 @@
# @TEST-EXEC: cat weird.log >> output # @TEST-EXEC: cat weird.log >> output
# @TEST-EXEC: bro -r $TRACES/trunc/ip6-ext-trunc.pcap # @TEST-EXEC: bro -r $TRACES/trunc/ip6-ext-trunc.pcap
# @TEST-EXEC: cat weird.log >> output # @TEST-EXEC: cat weird.log >> output
# If an ICMP packet's payload is truncated due to too small snaplen,
# the checksum calculation is bypassed (and Bro doesn't crash, of course).
# @TEST-EXEC: rm -f weird.log
# @TEST-EXEC: bro -r $TRACES/trunc/icmp-payload-trunc.pcap
# @TEST-EXEC: test ! -e weird.log
# If an ICMP packet has the ICMP header truncated due to too small snaplen,
# an internally_truncated_header weird gets generated.
# @TEST-EXEC: bro -r $TRACES/trunc/icmp-header-trunc.pcap
# @TEST-EXEC: cat weird.log >> output
# @TEST-EXEC: btest-diff output # @TEST-EXEC: btest-diff output