linux_dsm_epyc7002/arch/s390
Pavel Emelyanov a8fc927780 sk-filter: Add ability to get socket filter program (v2)
The SO_ATTACH_FILTER option is set only. I propose to add the get
ability by using SO_ATTACH_FILTER in getsockopt. To be less
irritating to eyes the SO_GET_FILTER alias to it is declared. This
ability is required by checkpoint-restore project to be able to
save full state of a socket.

There are two issues with getting filter back.

First, kernel modifies the sock_filter->code on filter load, thus in
order to return the filter element back to user we have to decode it
into user-visible constants. Fortunately the modification in question
is interconvertible.

Second, the BPF_S_ALU_DIV_K code modifies the command argument k to
speed up the run-time division by doing kernel_k = reciprocal(user_k).
Bad news is that different user_k may result in same kernel_k, so we
can't get the original user_k back. Good news is that we don't have
to do it. What we need to is calculate a user2_k so, that

  reciprocal(user2_k) == reciprocal(user_k) == kernel_k

i.e. if it's re-loaded back the compiled again value will be exactly
the same as it was. That said, the user2_k can be calculated like this

  user2_k = reciprocal(kernel_k)

with an exception, that if kernel_k == 0, then user2_k == 1.

The optlen argument is treated like this -- when zero, kernel returns
the amount of sock_fprog elements in filter, otherwise it should be
large enough for the sock_fprog array.

changes since v1:
* Declared SO_GET_FILTER in all arch headers
* Added decode of vlan-tag codes

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-11-01 11:17:15 -04:00
..
appldata s390/vtimer: rework virtual timer interface 2012-07-20 11:15:08 +02:00
boot s390/ipl,decrompressor: disable branch profiling 2012-09-26 15:45:21 +02:00
crypto crypto: arch/s390 - cleanup - remove unneeded cra_list initialization 2012-08-01 17:47:29 +08:00
hypfs Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-10-02 20:25:04 -07:00
include sk-filter: Add ability to get socket filter program (v2) 2012-11-01 11:17:15 -04:00
kernel Merge branch 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2012-10-12 22:17:48 +09:00
kvm KVM updates for the 3.7 merge window 2012-10-04 09:30:33 -07:00
lib s390/string: provide asm lib functions for memcpy and memcmp 2012-09-26 15:44:50 +02:00
math-emu s390/comments: unify copyright messages and remove file names 2012-07-20 11:15:04 +02:00
mm s390/mm,vmem: fix vmem_add_mem()/vmem_remove_range() 2012-10-09 14:17:01 +02:00
net s390/bpf,jit: add support for BPF_S_ANC_ALU_XOR_X instruction 2012-09-26 15:45:28 +02:00
oprofile oprofile, s390: Fix uninitialized memory access when writing to oprofilefs 2012-08-27 14:49:23 +02:00
defconfig s390: update defconfig 2012-09-26 15:45:29 +02:00
Kbuild s390/bpf,jit: BPF Just In Time compiler for s390 2012-09-26 15:44:49 +02:00
Kconfig Merge branch 'modules-next' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux 2012-10-14 13:39:34 -07:00
Kconfig.debug s390/mm: add page table dumper 2012-10-09 14:16:58 +02:00
Makefile s390: Use generic init_task 2012-05-05 13:00:25 +02:00