Skip to content

Commit ed65f8e

Browse files
committed
Check for equality between connections checks for protocol
1 parent 832ed55 commit ed65f8e

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

integration-tests/pkg/mock_sensor/expect_conn.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package mock_sensor
22

33
import (
4+
"fmt"
45
"testing"
56
"time"
67

@@ -88,7 +89,7 @@ func (s *MockSensor) ExpectSameElementsConnections(t *testing.T, containerID str
8889
types.SortConnections(expected)
8990

9091
equal := func(c1, c2 *sensorAPI.NetworkConnection) bool {
91-
return types.Equal(c1, c2)
92+
return types.EqualNetworkConnection(c1, c2)
9293
}
9394

9495
connections := s.Connections(containerID)
@@ -125,7 +126,7 @@ func (s *MockSensor) ExpectSameElementsConnectionsScrapes(t *testing.T, containe
125126
types.SortConnections(c2)
126127

127128
for i := range c2 {
128-
if !types.Equal(c1[i], c2[i]) {
129+
if !types.EqualNetworkConnection(c1[i], c2[i]) {
129130
return false
130131
}
131132
}

integration-tests/pkg/mock_sensor/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (m *MockSensor) HasConnection(containerID string, conn *sensorAPI.NetworkCo
192192
conns := m.Connections(containerID)
193193
if len(conns) > 0 {
194194
return slices.ContainsFunc(conns, func(c *sensorAPI.NetworkConnection) bool {
195-
return types.Equal(c, conn)
195+
return types.EqualNetworkConnection(c, conn)
196196
})
197197
}
198198

integration-tests/pkg/types/network.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ func IsActive(conn *sensorAPI.NetworkConnection) bool {
4949
return conn.GetCloseTimestamp() == nil
5050
}
5151

52-
func Equal(conn1 *sensorAPI.NetworkConnection, conn2 *sensorAPI.NetworkConnection) bool {
52+
func EqualNetworkConnection(conn1 *sensorAPI.NetworkConnection, conn2 *sensorAPI.NetworkConnection) bool {
5353
return EqualNetworkAddress(conn1.LocalAddress, conn2.LocalAddress) &&
5454
EqualNetworkAddress(conn1.RemoteAddress, conn2.RemoteAddress) &&
55+
conn1.Protocol == conn2.Protocol &&
5556
conn1.Role == conn2.Role &&
5657
conn1.SocketFamily == conn2.SocketFamily &&
5758
IsActive(conn1) == IsActive(conn2)

integration-tests/suites/udp_networkflow.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ func (s *UdpNetworkFlow) runTest(image, recv, send string, port uint32) {
121121
clientConnection := &sensorAPI.NetworkConnection{
122122
LocalAddress: types.CreateNetworkAddress("", "", 0),
123123
RemoteAddress: types.CreateNetworkAddress(server.ip, "", server.port),
124+
Protocol: storage.L4Protocol_L4_PROTOCOL_UDP,
124125
Role: sensorAPI.ClientServerRole_ROLE_CLIENT,
125126
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN,
126127
CloseTimestamp: nil,
@@ -130,6 +131,7 @@ func (s *UdpNetworkFlow) runTest(image, recv, send string, port uint32) {
130131
serverConnection := &sensorAPI.NetworkConnection{
131132
LocalAddress: types.CreateNetworkAddress("", "", server.port),
132133
RemoteAddress: types.CreateNetworkAddress(client.ip, "", 0),
134+
Protocol: storage.L4Protocol_L4_PROTOCOL_UDP,
133135
Role: sensorAPI.ClientServerRole_ROLE_SERVER,
134136
SocketFamily: sensorAPI.SocketFamily_SOCKET_FAMILY_UNKNOWN,
135137
CloseTimestamp: nil,

0 commit comments

Comments
 (0)