linux-stable/arch/mips
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
..
alchemy MIPS: Alchemy: Merge PB1100/1500 support into DB1000 code. 2012-10-11 11:11:20 +02:00
ar7
ath79 MIPS: ath79: Fix CPU/DDR frequency calculation for SRIF PLLs 2012-10-01 11:37:15 +02:00
bcm47xx
bcm63xx Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2012-10-09 16:08:04 +09:00
boot MIPS: Alchemy: Single kernel for DB1200/1300/1550 2012-10-11 11:11:20 +02:00
cavium-octeon Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2012-10-09 16:08:04 +09:00
cobalt
configs MIPS: Alchemy: Merge PB1100/1500 support into DB1000 code. 2012-10-11 11:11:20 +02:00
dec
emma
fw
include sk-filter: Add ability to get socket filter program (v2) 2012-11-01 11:17:15 -04:00
jazz
jz4740 pwm: Add Ingenic JZ4740 support 2012-10-05 20:56:42 +02:00
kernel Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2012-10-14 14:39:05 -07:00
lantiq Merge branch 'master' of git://dev.phrozen.org/mips-next into mips-for-linux-next 2012-10-05 15:56:28 +02:00
lasat
lib
loongson
loongson1
math-emu
mm MIPS: Optimize TLB refill for RI/XI configurations. 2012-10-11 11:11:20 +02:00
mti-malta Merge branch 'ralf-3.7' of git://git.linux-mips.org/pub/scm/sjhill/linux-sjhill into mips-for-linux-next 2012-09-28 16:29:55 +02:00
mti-sead3 MIPS: Add core files for MIPS SEAD-3 development platform. 2012-09-13 15:43:46 -05:00
netlogic
oprofile
pci MIPS: Malta: Fix section mismatch. 2012-10-11 11:14:12 +02:00
pmc-sierra
pnx833x
pnx8550
power
powertv
rb532
sgi-ip22
sgi-ip27
sgi-ip32
sibyte
sni MIPS: SNI: Switch RM400 serial to SCCNXP driver 2012-10-11 11:14:13 +02:00
txx9
vr41xx
wrppmc
Kbuild
Kbuild.platforms Merge branch 'ralf-3.7' of git://git.linux-mips.org/pub/scm/sjhill/linux-sjhill into mips-for-linux-next 2012-09-28 16:29:55 +02:00
Kconfig Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2012-10-14 14:39:05 -07:00
Kconfig.debug
Makefile kbuild: Fix gcc -x syntax 2012-10-03 09:03:24 +02:00