Merge remote-tracking branch 'olaldiko/master'

* olaldiko/master:
  Add tests for ERSPAN Type I patch
  Add ERSPAN Type I patch
This commit is contained in:
Tim Wojtulewicz 2021-03-17 10:35:59 -07:00
commit f53fb9a22e
7 changed files with 55 additions and 5 deletions

11
CHANGES
View file

@ -1,3 +1,14 @@
4.1.0-dev.328 | 2021-03-17 10:35:59 -0700
* Add tests for ERSPAN Type I patch
Co-authored-by: Markel Elorza Alvarez <melorzaalvarez@gmail.com>
Co-authored-by: Ivan Arrizabalaga Cupido <ivanarrcup@gmail.com> (Gorka Olalde Mendia)
* Add ERSPAN Type I patch
Co-authored-by: Markel Elorza Alvarez <melorzaalvarez@gmail.com>
Co-authored-by: Ivan Arrizabalaga Cupido <ivanarrcup@gmail.com> (Gorka Olalde Mendia)
4.1.0-dev.323 | 2021-03-11 12:43:21 -0800 4.1.0-dev.323 | 2021-03-11 12:43:21 -0800

View file

@ -1 +1 @@
4.1.0-dev.323 4.1.0-dev.328

View file

@ -99,13 +99,24 @@ bool GREAnalyzer::AnalyzePacket(size_t len, const uint8_t* data, Packet* packet)
else if ( proto_typ == 0x88be ) else if ( proto_typ == 0x88be )
{ {
// ERSPAN type II if ( len > gre_len + 14 )
if ( len > gre_len + 14 + 8 )
{ {
erspan_len = 8; // ERSPAN type I
erspan_len = 0;
eth_len = 14; eth_len = 14;
gre_link_type = DLT_EN10MB; gre_link_type = DLT_EN10MB;
proto_typ = ntohs(*((uint16_t*)(data + gre_len + erspan_len + eth_len - 2))); bool have_sequence_header = ((flags_ver & 0x1000) == 0x1000);
if ( have_sequence_header )
{
// ERSPAN type II
erspan_len += 8;
if ( len < gre_len + eth_len + erspan_len )
{
Weird("truncated_GRE", packet);
return false;
}
}
proto_typ = ntohs(*((uint16_t *) (data + gre_len + erspan_len + eth_len - 2)));
} }
else else
{ {

View file

@ -0,0 +1,11 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path conn
#open XXXX-XX-XX-XX-XX-XX
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p proto service duration orig_bytes resp_bytes conn_state local_orig local_resp missed_bytes history orig_pkts orig_ip_bytes resp_pkts resp_ip_bytes tunnel_parents
#types time string addr port addr port enum string interval count count string bool bool count string count count count count set[string]
XXXXXXXXXX.XXXXXX ClEkJM2Vm5giqnMf4h 172.16.133.2 8 172.217.11.78 0 icmp - 0.014360 280 280 OTH - - 0 - 5 420 5 420 CHhAvVGS1DHFjwGM9
#close XXXX-XX-XX-XX-XX-XX

View file

@ -0,0 +1,11 @@
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
#separator \x09
#set_separator ,
#empty_field (empty)
#unset_field -
#path tunnel
#open XXXX-XX-XX-XX-XX-XX
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p tunnel_type action
#types time string addr port addr port enum enum
XXXXXXXXXX.XXXXXX CHhAvVGS1DHFjwGM9 192.168.1.1 0 192.168.1.2 0 Tunnel::GRE Tunnel::DISCOVER
#close XXXX-XX-XX-XX-XX-XX

Binary file not shown.

View file

@ -0,0 +1,6 @@
# @TEST-EXEC: zeek -C -b -r $TRACES/erspanI.pcap %INPUT
# @TEST-EXEC: btest-diff tunnel.log
# @TEST-EXEC: btest-diff conn.log
@load base/frameworks/tunnels
@load base/protocols/conn