@@ -285,74 +285,76 @@ DEFINE_KPROBE_SKB_TARGET(ipt_do_table_legacy, ipt_do_table, 1)
285285 struct nf_hook_state * state = nt_regs_ctx (ctx , 2 );
286286 struct xt_table * table = nt_regs_ctx (ctx , 3 );
287287
288- return bpf_ipt_do_table (ctx , table , state );
288+ bpf_ipt_do_table (ctx , table , state );
289+ return 0 ;
289290}
290291
291292DEFINE_KPROBE_SKB (ipt_do_table , 2 )
292293{
293294 struct nf_hook_state * state = nt_regs_ctx (ctx , 3 );
294295 struct xt_table * table = nt_regs_ctx (ctx , 1 );
295296
296- return bpf_ipt_do_table (ctx , table , state );
297+ bpf_ipt_do_table (ctx , table , state );
298+ return 0 ;
297299}
298300
299- // DEFINE_KPROBE_SKB(nf_hook_slow, 1)
300- // {
301- // struct nf_hook_state *state;
302- // size_t size;
303- // int num;
304-
305- // state = nt_regs_ctx(ctx, 2);
306- // if (ctx->args->hooks)
307- // goto on_hooks;
308-
309- // DECLARE_EVENT(nf_event_t, e)
310-
311- // size = ctx->size;
312- // ctx->size = 0;
313- // if (handle_entry(ctx))
314- // return 0;
315-
316- // e->hook = _C(state, hook);
317- // e->pf = _C(state, pf);
318- // EVENT_OUTPUT_PTR(ctx->regs, ctx->e, size);
319- // return 0;
320-
321- // on_hooks:;
322- // struct nf_hook_entries *entries = nt_regs_ctx(ctx, 3);
323- // __DECLARE_EVENT(hooks, nf_hooks_event_t, hooks_event)
324-
325- // size = ctx->size;
326- // ctx->size = 0;
327- // if (handle_entry(ctx))
328- // return 0;
329-
330- // hooks_event->hook = _C(state, hook);
331- // hooks_event->pf = _C(state, pf);
332- // num = _(entries->num_hook_entries);
333-
334- // #define COPY_HOOK(i) do { \
335- // if (i >= num) goto out; \
336- // hooks_event->hooks[i] = (u64)_(entries->hooks[i].hook); \
337- // } while (0)
338-
339- // COPY_HOOK(0);
340- // COPY_HOOK(1);
341- // COPY_HOOK(2);
342- // COPY_HOOK(3);
343- // COPY_HOOK(4);
344- // COPY_HOOK(5);
345-
346- // /* following code can't unroll, don't know why......:
347- // *
348- // * #pragma clang loop unroll(full)
349- // * for (i = 0; i < 8; i++)
350- // * COPY_HOOK(i);
351- // */
352- // out:
353- // EVENT_OUTPUT_PTR(ctx->regs, ctx->e, size);
354- // return 0;
355- // }
301+ DEFINE_KPROBE_SKB (nf_hook_slow , 1 )
302+ {
303+ struct nf_hook_state * state ;
304+ size_t size ;
305+ int num ;
306+
307+ state = nt_regs_ctx (ctx , 2 );
308+ if (ctx -> args -> hooks )
309+ goto on_hooks ;
310+
311+ DECLARE_EVENT (nf_event_t , e )
312+
313+ size = ctx -> size ;
314+ ctx -> size = 0 ;
315+ if (handle_entry (ctx ))
316+ return 0 ;
317+
318+ e -> hook = _C (state , hook );
319+ e -> pf = _C (state , pf );
320+ EVENT_OUTPUT_PTR (ctx -> regs , ctx -> e , size );
321+ return 0 ;
322+
323+ on_hooks :;
324+ struct nf_hook_entries * entries = nt_regs_ctx (ctx , 3 );
325+ __DECLARE_EVENT (hooks , nf_hooks_event_t , hooks_event )
326+
327+ size = ctx -> size ;
328+ ctx -> size = 0 ;
329+ if (handle_entry (ctx ))
330+ return 0 ;
331+
332+ hooks_event -> hook = _C (state , hook );
333+ hooks_event -> pf = _C (state , pf );
334+ num = _ (entries -> num_hook_entries );
335+
336+ #define COPY_HOOK (i ) do { \
337+ if (i >= num) goto out; \
338+ hooks_event->hooks[i] = (u64)_(entries->hooks[i].hook); \
339+ } while (0)
340+
341+ COPY_HOOK (0 );
342+ COPY_HOOK (1 );
343+ COPY_HOOK (2 );
344+ COPY_HOOK (3 );
345+ COPY_HOOK (4 );
346+ COPY_HOOK (5 );
347+
348+ /* following code can't unroll, don't know why......:
349+ *
350+ * #pragma clang loop unroll(full)
351+ * for (i = 0; i < 8; i++)
352+ * COPY_HOOK(i);
353+ */
354+ out :
355+ EVENT_OUTPUT_PTR (ctx -> regs , ctx -> e , size );
356+ return 0 ;
357+ }
356358
357359static __always_inline int
358360bpf_qdisc_handle (context_t * ctx , struct Qdisc * q )
@@ -378,12 +380,16 @@ bpf_qdisc_handle(context_t *ctx, struct Qdisc *q)
378380
379381DEFINE_KPROBE_SKB (sch_direct_xmit , 1 ) {
380382 struct Qdisc * q = nt_regs_ctx (ctx , 2 );
381- return bpf_qdisc_handle (ctx , q );
383+ bpf_qdisc_handle (ctx , q );
384+
385+ return 0 ;
382386}
383387
384388DEFINE_KPROBE_SKB (pfifo_enqueue , 1 ) {
385389 struct Qdisc * q = nt_regs_ctx (ctx , 2 );
386- return bpf_qdisc_handle (ctx , q );
390+ bpf_qdisc_handle (ctx , q );
391+
392+ return 0 ;
387393}
388394
389395#ifndef NT_DISABLE_NFT
0 commit comments