@@ -59,10 +59,15 @@ impl Source for RingBuffer<'_> {
59
59
}
60
60
61
61
impl Ebpf {
62
- pub fn load_ingress ( iface : String , sender : kanal:: Sender < Event > , terminate : Arc < AtomicBool > ) {
62
+ pub fn load_ingress (
63
+ iface : String ,
64
+ notification_sender : kanal:: Sender < Event > ,
65
+ data_sender : kanal:: Sender < [ u8 ; RawPacket :: LEN ] > ,
66
+ terminate : Arc < AtomicBool > ,
67
+ ) {
63
68
thread:: spawn ( {
64
69
let iface = iface. to_owned ( ) ;
65
- let sender = sender . clone ( ) ;
70
+ let notification_sender = notification_sender . clone ( ) ;
66
71
67
72
move || {
68
73
let rlim = libc:: rlimit {
@@ -81,7 +86,7 @@ impl Ebpf {
81
86
Notification :: send (
82
87
format ! ( "Failed to load the ingress eBPF bytecode\n {}" , e) ,
83
88
NotificationLevel :: Error ,
84
- sender ,
89
+ notification_sender ,
85
90
)
86
91
. unwrap ( ) ;
87
92
return ;
@@ -97,7 +102,7 @@ impl Ebpf {
97
102
Notification :: send (
98
103
format ! ( "Failed to load the ingress eBPF bytecode\n {}" , e) ,
99
104
NotificationLevel :: Error ,
100
- sender ,
105
+ notification_sender ,
101
106
)
102
107
. unwrap ( ) ;
103
108
return ;
@@ -116,7 +121,7 @@ impl Ebpf {
116
121
e
117
122
) ,
118
123
NotificationLevel :: Error ,
119
- sender ,
124
+ notification_sender ,
120
125
)
121
126
. unwrap ( ) ;
122
127
return ;
@@ -129,7 +134,7 @@ impl Ebpf {
129
134
e
130
135
) ,
131
136
NotificationLevel :: Error ,
132
- sender ,
137
+ notification_sender ,
133
138
)
134
139
. unwrap ( ) ;
135
140
return ;
@@ -168,7 +173,7 @@ impl Ebpf {
168
173
}
169
174
let packet: [ u8 ; RawPacket :: LEN ] =
170
175
item. to_owned ( ) . try_into ( ) . unwrap ( ) ;
171
- sender . send ( Event :: Packet ( packet) ) . ok ( ) ;
176
+ data_sender . send ( packet) . ok ( ) ;
172
177
}
173
178
}
174
179
}
@@ -181,10 +186,15 @@ impl Ebpf {
181
186
} ) ;
182
187
}
183
188
184
- pub fn load_egress ( iface : String , sender : kanal:: Sender < Event > , terminate : Arc < AtomicBool > ) {
189
+ pub fn load_egress (
190
+ iface : String ,
191
+ notification_sender : kanal:: Sender < Event > ,
192
+ data_sender : kanal:: Sender < [ u8 ; RawPacket :: LEN ] > ,
193
+ terminate : Arc < AtomicBool > ,
194
+ ) {
185
195
thread:: spawn ( {
186
196
let iface = iface. to_owned ( ) ;
187
- let sender = sender . clone ( ) ;
197
+ let notification_sender = notification_sender . clone ( ) ;
188
198
189
199
move || {
190
200
let rlim = libc:: rlimit {
@@ -203,7 +213,7 @@ impl Ebpf {
203
213
Notification :: send (
204
214
format ! ( "Fail to load the egress eBPF bytecode\n {}" , e) ,
205
215
NotificationLevel :: Error ,
206
- sender ,
216
+ notification_sender ,
207
217
)
208
218
. unwrap ( ) ;
209
219
return ;
@@ -219,7 +229,7 @@ impl Ebpf {
219
229
Notification :: send (
220
230
format ! ( "Failed to load the egress eBPF bytecode\n {}" , e) ,
221
231
NotificationLevel :: Error ,
222
- sender ,
232
+ notification_sender ,
223
233
)
224
234
. unwrap ( ) ;
225
235
return ;
@@ -234,7 +244,7 @@ impl Ebpf {
234
244
Notification :: send (
235
245
format ! ( "Fail to load the egress eBPF program to the kernel\n {}" , e) ,
236
246
NotificationLevel :: Error ,
237
- sender ,
247
+ notification_sender ,
238
248
)
239
249
. unwrap ( ) ;
240
250
return ;
@@ -247,7 +257,7 @@ impl Ebpf {
247
257
e
248
258
) ,
249
259
NotificationLevel :: Error ,
250
- sender ,
260
+ notification_sender ,
251
261
)
252
262
. unwrap ( ) ;
253
263
return ;
@@ -286,7 +296,7 @@ impl Ebpf {
286
296
}
287
297
let packet: [ u8 ; RawPacket :: LEN ] =
288
298
item. to_owned ( ) . try_into ( ) . unwrap ( ) ;
289
- sender . send ( Event :: Packet ( packet) ) . ok ( ) ;
299
+ data_sender . send ( packet) . ok ( ) ;
290
300
}
291
301
}
292
302
}
0 commit comments