You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let proto = u8::from_be(ctx.load::<u8>(PROTOCOL_T0TAL_BYTES_OFFSET).map_err(|_| 1)?);
161
-
162
200
163
201
//not logging internal communication packets
164
202
//TODO: do not log internal communications such as minikube dashboard packets or kubectl api packets
165
-
let ip_to_block = u32::from_be_bytes([192,168,49,1]);//inverted requence
166
-
let dst_ip_to_block = u32::from_be_bytes([192,168,49,2]);
167
-
168
-
169
-
// XOR to generate the hash id for the given connection
170
-
let event_id = (src_ip ^ dst_ip ^ (src_port asu32) ^ (dst_port asu32) ^ (proto asu32))asu16;//generate one for every event using a 'byte XOR' operation
203
+
let ip_to_block = u32::from_be_bytes([192,168,49,1]);//inverted requence
204
+
let dst_ip_to_block = u32::from_be_bytes([192,168,49,2]);
171
205
172
-
let connection_id = (src_ip ^ dst_ip ^(proto asu32))asu16;//added host_id to track the host to count every all the different connections
206
+
let key = ConnArray{
207
+
src_ip,
208
+
dst_ip,
209
+
src_port,
210
+
dst_port,
211
+
proto,
212
+
};
173
213
174
-
if src_ip == ip_to_block && dst_ip == dst_ip_to_block {
175
-
returnOk(());
176
-
}
177
-
else{
178
-
//log all other packets
179
-
let log = PacketLog{
180
-
proto,
181
-
src_ip,
182
-
src_port,
183
-
dst_ip,
184
-
dst_port,
185
-
event_id,
186
-
};
187
-
let connections = ConnArray{
188
-
event_id,
189
-
connection_id
190
-
};
191
-
unsafe{
192
-
EVENTS.output(&ctx,&log,0);//output to userspace
193
-
//TODO: add more parameters to better identify the active connection (maybe timestamp?)
194
-
CONNMAP.insert(&proto,&connections,0)//save hash_id to kernel space lru per cpu hashmap
195
-
};
214
+
// XOR to generate the hash id for the given connection
215
+
let event_id = (src_ip ^
216
+
dst_ip ^
217
+
(src_port asu32) ^
218
+
(dst_port asu32) ^
219
+
(proto asu32))asu16;//generate one for every event using a 'byte XOR' operation
220
+
221
+
//let connection_id = (src_ip ^ dst_ip ^(proto as u32)) as u16; //added host_id to track the host to count every all the different connections
222
+
223
+
//if
224
+
// (unsafe { is_kube_internal(src_ip) }) ||
225
+
//(unsafe { is_kube_internal(dst_ip) }) ||
226
+
// src_ip == ip_to_block ||
227
+
// src_ip == dst_ip_to_block
228
+
//{
229
+
// return Ok(());
230
+
//} else {
231
+
//log all other packets
232
+
let log = PacketLog{
233
+
proto,
234
+
src_ip,
235
+
src_port,
236
+
dst_ip,
237
+
dst_port,
238
+
event_id,
239
+
};
240
+
//let connections = ConnArray{
241
+
// event_id,
242
+
//connection_id
243
+
//};
244
+
unsafe{
245
+
EVENTS.output(&ctx,&log,0);//output to userspace
246
+
//TODO: add more parameters to better identify the active connection (maybe timestamp?)
0 commit comments