Skip to content

Commit f085099

Browse files
authored
Merge pull request #49 from LakshK98/fix-packet-parsing
fix lint err
2 parents cf52089 + 6a96b08 commit f085099

3 files changed

Lines changed: 2 additions & 36 deletions

File tree

pkg/plugin/ebpfwindows/datapath_drop_windows.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const (
2121
// dropNotifyV1Len is the amount of packet data provided in a v0/v1 drop notification.
2222
dropNotifyV1Len = 36
2323
dropPktmonNotifyV1Len = 57
24-
maxCapLength = 128
2524
)
2625

2726
var dropNotifyLengthFromVersion = map[uint16]uint{

pkg/plugin/ebpfwindows/parser_windows.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727

2828
const MaxInt = int(^uint(0) >> 1)
2929
const MessageTypePktmonDrop = 100
30+
const maxCapLength uint16 = 128
3031

3132
// Parser is a parser for L3/L4 payloads
3233
type Parser struct {
@@ -206,7 +207,7 @@ func (p *Parser) decode(data []byte, decoded *pb.Flow) error {
206207
dn.Type = monitorAPI.MessageTypeDrop
207208
dn.Version = pdn.VersionHeader.Version
208209
dn.OrigLen = pdn.PktmonHeader.PacketDescriptor.PacketOriginalLength
209-
dn.CapLen = uint16(min(maxCapLength, dn.OrigLen))
210+
dn.CapLen = uint16(min(uint32(maxCapLength), uint32(dn.OrigLen)))
210211

211212
eventSubType = pdn.PktmonHeader.Metadata.DropReason
212213
if offset > uint(MaxInt) {

test/e2e/tools/event-writer/event_writer.h

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -166,27 +166,6 @@ struct drop_notify {
166166
uint8_t data[128];
167167
};
168168

169-
170-
// struct pktmon_notify {
171-
// uint8_t type;
172-
// uint16_t version;
173-
// uint8_t subtype;
174-
// uint16_t source;
175-
// uint32_t hash;
176-
// uint32_t len_orig;
177-
// uint16_t len_cap;
178-
// uint32_t src_label;
179-
// uint32_t dst_label;
180-
// uint32_t dst_id; /* 0 for egress */
181-
// uint16_t line;
182-
// uint8_t file;
183-
// int8_t ext_error;
184-
// uint32_t ifindex;
185-
// uint8_t data[128];
186-
// };
187-
188-
// _Static_assert(sizeof(struct pktmon_notify) == 168, "pktmon_notify struct size must be 168 bytes");
189-
190169
struct metrics_key {
191170
uint8_t reason; /* 0: forwarded, >0 dropped */
192171
uint8_t dir:2, /* 1: ingress 2: egress */
@@ -210,19 +189,6 @@ struct metrics_value {
210189
uint64_t bytes;
211190
};
212191

213-
214-
215-
enum _PKTMON_DIRECTION_TAG
216-
{
217-
PktMonDirTag_Unspecified = 0,
218-
PktMonDirTag_In,
219-
PktMonDirTag_Out,
220-
PktMonDirTag_Rx,
221-
PktMonDirTag_Tx,
222-
PktMonDirTag_Ingress,
223-
PktMonDirTag_Egress
224-
} PKTMON_DIRECTION_TAG;
225-
226192
typedef struct _netevent_data_header
227193
{
228194
uint8_t type;

0 commit comments

Comments
 (0)