/* * netsniff-ng - the packet sniffing beast * Copyright 2013 Daniel Borkmann. * Subject to the GPL, version 2. */ #include #include #include "xmalloc.h" #include "config.h" #include "bpf.h" #include "die.h" void bpf_try_compile(const char *rulefile, struct sock_fprog *bpf, uint32_t link_type) { int i, ret; const struct bpf_insn *ins; struct sock_filter *out; struct bpf_program _bpf; ret = pcap_compile_nopcap(65535, link_type, &_bpf, rulefile, 1, 0xffffffff); if (ret < 0) panic("Cannot compile filter %s\n", rulefile); bpf->len = _bpf.bf_len; bpf->filter = xrealloc(bpf->filter, bpf->len * sizeof(*out)); for (i = 0, ins = _bpf.bf_insns, out = bpf->filter; i < bpf->len; ++i, ++ins, ++out) { out->code = ins->code; out->jt = ins->jt; out->jf = ins->jf; out->k = ins->k; if (out->code == 0x06 && out->k > 0) out->k = 0xFFFFFFFF; } pcap_freecode(&_bpf); if (__bpf_validate(bpf) == 0) panic("This is not a valid BPF program!\n"); } ' onchange='this.form.submit();'> net-next plumbingsTobias Klauser
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Khlebnikov <khlebnikov@yandex-team.ru>2016-06-22 21:42:16 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-08-31 15:14:44 +0200
commit17d0774f80681020eccc9638d925a23f1fc4f671 (patch)
treefb44854ba2ae18413b567fc0fec3f612f43580e0
parent96b0af4b729cabd44e237c5a6b9bd4e0ea4ed457 (diff)
sysfs: correctly handle read offset on PREALLOC attrs
Attributes declared with __ATTR_PREALLOC use sysfs_kf_read() which returns zero bytes for non-zero offset. This breaks script checkarray in mdadm tool in debian where /bin/sh is 'dash' because its builtin 'read' reads only one byte at a time. Script gets 'i' instead of 'idle' when reads current action from /sys/block/$dev/md/sync_action and as a result does nothing. This patch adds trivial implementation of partial read: generate whole string and move required part into buffer head. Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru> Fixes: 4ef67a8c95f3 ("sysfs/kernfs: make read requests on pre-alloc files use the buffer.") Link: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=787950 Cc: Stable <stable@vger.kernel.org> # v3.19+ Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>