Identify GRE tunnels as Tunnel::GRE, not Tunnel::IP.

BIT-1311 #close
This commit is contained in:
Jon Siwek 2015-03-13 13:01:57 -05:00
parent 51010eccd4
commit 6fbceb6a98
6 changed files with 18 additions and 7 deletions

3
NEWS
View file

@ -94,6 +94,9 @@ Changed Functionality
- conn.log gained a new field local_resp that works like local_orig, - conn.log gained a new field local_resp that works like local_orig,
just for the responder address of the connection. just for the responder address of the connection.
- GRE tunnels are now identified as ``Tunnel::GRE`` instead of
``Tunnel::IP``.
- [TODO] Add changed BroControl features. - [TODO] Add changed BroControl features.
Deprecated Functionality Deprecated Functionality

View file

@ -466,6 +466,7 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr,
id.src_addr = ip_hdr->SrcAddr(); id.src_addr = ip_hdr->SrcAddr();
id.dst_addr = ip_hdr->DstAddr(); id.dst_addr = ip_hdr->DstAddr();
Dictionary* d = 0; Dictionary* d = 0;
BifEnum::Tunnel::Type tunnel_type = BifEnum::Tunnel::IP;
switch ( proto ) { switch ( proto ) {
case IPPROTO_TCP: case IPPROTO_TCP:
@ -606,6 +607,8 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr,
// Treat GRE tunnel like IP tunnels, fallthrough to logic below now // Treat GRE tunnel like IP tunnels, fallthrough to logic below now
// that GRE header is stripped and only payload packet remains. // that GRE header is stripped and only payload packet remains.
// The only thing different is the tunnel type enum value to use.
tunnel_type = BifEnum::Tunnel::GRE;
} }
case IPPROTO_IPV4: case IPPROTO_IPV4:
@ -653,7 +656,8 @@ void NetSessions::DoNextPacket(double t, const struct pcap_pkthdr* hdr,
if ( it == ip_tunnels.end() ) if ( it == ip_tunnels.end() )
{ {
EncapsulatingConn ec(ip_hdr->SrcAddr(), ip_hdr->DstAddr()); EncapsulatingConn ec(ip_hdr->SrcAddr(), ip_hdr->DstAddr(),
tunnel_type);
ip_tunnels[tunnel_idx] = TunnelActivity(ec, network_time); ip_tunnels[tunnel_idx] = TunnelActivity(ec, network_time);
timer_mgr->Add(new IPTunnelTimer(network_time, tunnel_idx)); timer_mgr->Add(new IPTunnelTimer(network_time, tunnel_idx));
} }

View file

@ -37,10 +37,12 @@ public:
* *
* @param s The tunnel source address, likely taken from an IP header. * @param s The tunnel source address, likely taken from an IP header.
* @param d The tunnel destination address, likely taken from an IP header. * @param d The tunnel destination address, likely taken from an IP header.
* @param t The type of IP tunnel.
*/ */
EncapsulatingConn(const IPAddr& s, const IPAddr& d) EncapsulatingConn(const IPAddr& s, const IPAddr& d,
BifEnum::Tunnel::Type t = BifEnum::Tunnel::IP)
: src_addr(s), dst_addr(d), src_port(0), dst_port(0), : src_addr(s), dst_addr(d), src_port(0), dst_port(0),
proto(TRANSPORT_UNKNOWN), type(BifEnum::Tunnel::IP), proto(TRANSPORT_UNKNOWN), type(t),
uid(Bro::UID(bits_per_uid)) uid(Bro::UID(bits_per_uid))
{ {
} }
@ -85,7 +87,8 @@ public:
if ( ec1.type != ec2.type ) if ( ec1.type != ec2.type )
return false; return false;
if ( ec1.type == BifEnum::Tunnel::IP ) if ( ec1.type == BifEnum::Tunnel::IP ||
ec1.type == BifEnum::Tunnel::GRE )
// Reversing endpoints is still same tunnel. // Reversing endpoints is still same tunnel.
return ec1.uid == ec2.uid && ec1.proto == ec2.proto && return ec1.uid == ec2.uid && ec1.proto == ec2.proto &&
((ec1.src_addr == ec2.src_addr && ec1.dst_addr == ec2.dst_addr) || ((ec1.src_addr == ec2.src_addr && ec1.dst_addr == ec2.dst_addr) ||

View file

@ -172,6 +172,7 @@ enum Type %{
SOCKS, SOCKS,
GTPv1, GTPv1,
HTTP, HTTP,
GRE,
%} %}
type EncapsulatingConn: record; type EncapsulatingConn: record;

View file

@ -6,6 +6,6 @@
#open 2014-01-16-21-51-36 #open 2014-01-16-21-51-36
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p tunnel_type action #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 #types time string addr port addr port enum enum
1341436424.204043 CXWv6p3arKYeMETxOg 72.205.54.70 0 86.106.164.150 0 Tunnel::IP Tunnel::DISCOVER 1341436424.204043 CXWv6p3arKYeMETxOg 72.205.54.70 0 86.106.164.150 0 Tunnel::GRE Tunnel::DISCOVER
1341436424.204043 CjhGID4nQcgTWjvg4c 10.10.11.2 0 10.10.13.2 0 Tunnel::IP Tunnel::DISCOVER 1341436424.204043 CjhGID4nQcgTWjvg4c 10.10.11.2 0 10.10.13.2 0 Tunnel::GRE Tunnel::DISCOVER
#close 2014-01-16-21-51-36 #close 2014-01-16-21-51-36

View file

@ -6,5 +6,5 @@
#open 2014-01-16-21-51-12 #open 2014-01-16-21-51-12
#fields ts uid id.orig_h id.orig_p id.resp_h id.resp_p tunnel_type action #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 #types time string addr port addr port enum enum
1055289968.793044 CXWv6p3arKYeMETxOg 172.27.1.66 0 66.59.109.137 0 Tunnel::IP Tunnel::DISCOVER 1055289968.793044 CXWv6p3arKYeMETxOg 172.27.1.66 0 66.59.109.137 0 Tunnel::GRE Tunnel::DISCOVER
#close 2014-01-16-21-51-12 #close 2014-01-16-21-51-12