On Tue, Nov 29, 2016 at 02:21:23PM +0100, Thomas Graf wrote: > Adds a series of test to verify the functionality of attaching > BPF programs at LWT hooks. > > Also adds a sample which collects a histogram of packet sizes which > pass through an LWT hook. > > $ ./lwt_len_hist.sh > Starting netserver with host 'IN(6)ADDR_ANY' port '12865' and family AF_UNSPEC > MIGRATED TCP STREAM TEST from 0.0.0.0 (0.0.0.0) port 0 AF_INET to > 192.168.253.2 () port 0 AF_INET : demo > Recv Send Send > Socket Socket Message Elapsed > Size Size Size Time Throughput > bytes bytes bytes secs. 10^6bits/sec > > 87380 16384 16384 10.00 39857.69
Nice! > + ret = bpf_redirect(ifindex, 0); > + if (ret < 0) { > + printk("bpf_redirect() failed: %d\n", ret); > + return BPF_DROP; > + } this 'if' looks a bit weird. You're passing 0 as flags, so this helper will always succeed. Other sample code often does 'return bpf_redirect(...)' due to this reasoning.