Netgraph - ng_bpf help (first experience)

Eduardo Meyer dudu.meyer at gmail.com
Tue Oct 10 16:39:03 UTC 2006


Hello,

I tried asking it on freebsd-ipfw@ but I got no luck. Maybe because
this is related to Netgraph and not ipfw essentially.

I want to use ng_bpf to use ng_tag to use ipfw-tag. Looks like lego,
where I have to assemble my toy, but I liked Lego when I was a child.

Following ng_bpf(4) man page I ran this script:

PATTERN="(ether[40:4]=0x134e5844 &&
         ether[44:4]=0x6f6d6169 &&
         ether[48:4]=0x6e0a)"

 NODEPATH="my_node:"
 INHOOK="hook1"
 MATCHHOOK="hook2"
 NOTMATCHHOOK="hook3"

 cat > /tmp/bpf.awk << xxENDxx
 {
  if (!init) {
    printf "bpf_prog_len=%d bpf_prog=[", \$1;
    init=1;
  } else {
    printf " { code=%d jt=%d jf=%d k=%d }", \$1, \$2, \$3, \$4;
  }
 }
 END {
  print " ]"
 }
 xxENDxx

        BPFPROG=`tcpdump -s 8192 -ddd ${PATTERN} | awk -f /tmp/bpf.awk`
        ngctl msg ${NODEPATH} setprogram { thisHook=\"${INHOOK}\" \
  ifMatch=\"${MATCHHOOK}\" \
  ifNotMatch=\"${NOTMATCHHOOK}\" \
  ${BPFPROG} } }

But I got this message:

ngctl: send msg: No such file or directory

I printed the full commands that returns the error, it is:

ngctl msg setprogram { thisHook="" ifMatch="" ifNotMatch=""
bpf_prog_len=8 bpf_prog=[ { code=32 jt=0 jf=0 k=40 } { code=21 jt=0
jf=5 k=323901508 } { code=32 jt=0 jf=0 k=44 } { code=21 jt=0 jf=3
k=1869439337 } { code=32 jt=0 jf=0 k=48 } { code=21 jt=0 jf=1 k=28170
} { code=6 jt=0 jf=0 k=8192 } { code=6 jt=0 jf=0 k=0 } ] } }

Running  tcpdump -s 8192 -ddd $PATTERN manually I get:

8
32 0 0 40
21 0 5 323901508
32 0 0 44
21 0 3 1869439337
32 0 0 48
21 0 1 28170
6 0 0 8192
6 0 0 0

Which looks that the ngctl data (code, kt, jf and k) are correct. But
the command returns that error for some reason. The script was taken
from ng_blf(4) man page.

I am all new to this netgraph thing.

Can anyone help me to find out what is rong? Thank you.

-- 
===========
Eduardo Meyer
pessoal: dudu.meyer at gmail.com
profissional: ddm.farmaciap at saude.gov.br


More information about the freebsd-stable mailing list