linux-sg2042/arch/m68k
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
..
amiga m68k/amiga: Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR 2012-08-18 15:15:57 +02:00
apollo m68k/apollo: Rename "timer" to "apollo_timer" 2012-07-22 16:55:49 +02:00
atari m68k/atari: Change VME irq numbers from unsigned long to unsigned int 2012-04-22 20:16:49 +02:00
bvme6000 Disintegrate asm/system.h for M68K 2012-03-28 18:30:02 +01:00
configs netfilter: remove xt_NOTRACK 2012-09-03 13:36:40 +02:00
emu TTY: nfcon, add tty_port and link it 2012-08-13 16:50:20 -07:00
fpsp040 Fix common misspellings 2011-03-31 11:26:23 -03:00
hp300 Disintegrate asm/system.h for M68K 2012-03-28 18:30:02 +01:00
ifpsp060 Fix common misspellings 2011-03-31 11:26:23 -03:00
include sk-filter: Add ability to get socket filter program (v2) 2012-11-01 11:17:15 -04:00
kernel Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal 2012-10-12 10:49:08 +09:00
lib m68k: delay, muldi3 - Use CONFIG_CPU_HAS_NO_MULDIV64 2012-06-10 10:18:30 +02:00
mac m68k/mac: Add missing platform check before registering platform devices 2012-04-01 22:57:51 +02:00
math-emu m68k/math-emu: Remove unnecessary code 2011-07-30 21:21:40 +02:00
mm readahead: fault retry breaks mmap file read random detection 2012-10-09 16:22:47 +09:00
mvme16x Disintegrate asm/system.h for M68K 2012-03-28 18:30:02 +01:00
mvme147 Disintegrate asm/system.h for M68K 2012-03-28 18:30:02 +01:00
platform m68knommu: clean up ColdFire 54xx General Timer definitions 2012-09-27 23:34:03 +10:00
q40 m68k/q40: Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR 2012-08-18 15:15:58 +02:00
sun3 m68k/sun3: Remove unselectable code in prom_init() 2012-06-27 09:59:44 +02:00
sun3x Disintegrate asm/system.h for M68K 2012-03-28 18:30:02 +01:00
tools/amiga Convert files to UTF-8 and some cleanups 2007-10-19 23:21:04 +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.bus m68k: allow PCI bus to be enabled for ColdFire m54xx CPUs 2012-07-17 15:49:45 +10:00
Kconfig.cpu m68k: select CONFIG_GENERIC_ATOMIC64 for all m68k CPU types 2012-08-17 10:04:24 +10:00
Kconfig.debug Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k 2012-01-06 18:28:12 -08:00
Kconfig.devices m68k/mac: Make CONFIG_HEARTBEAT unavailable on Mac 2012-01-04 22:23:50 +01:00
Kconfig.machine m68k/Kconfig: Separate classic m68k and coldfire early 2011-12-30 10:20:49 +10:00
Makefile m68knommu: Add support for the Coldfire m5441x. 2012-07-16 09:59:21 +10:00
install.sh kbuild: use INSTALLKERNEL to select customized installkernel script 2009-09-20 12:18:14 +02:00