Netdev List
 help / color / mirror / Atom feed
* Re: [net PATCH V2] net: fix divide by zero in tcp algorithm illinois
From: David Miller @ 2012-11-01 15:56 UTC (permalink / raw)
  To: eric.dumazet; +Cc: brouer, netdev, pmatouse, shemminger
In-Reply-To: <1351703678.32673.414.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 31 Oct 2012 18:14:38 +0100

> On Wed, 2012-10-31 at 13:45 +0100, Jesper Dangaard Brouer wrote:
>> Reading TCP stats when using TCP Illinois congestion control algorithm
>> can cause a divide by zero kernel oops.
>> 
>> The division by zero occur in tcp_illinois_info() at:
>>  do_div(t, ca->cnt_rtt);
>> where ca->cnt_rtt can become zero (when rtt_reset is called)
>> 
> 
>> Cc: Petr Matousek <pmatouse@redhat.com>
>> Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
>> 
>> ---
> 
> Acked-by: Eric Dumazet <edumazet@google.com>

Applied, thanks everyone.

^ permalink raw reply

* Re: [PATCH/Resend] [trivial] net: sctp: Fix typo in net/sctp
From: David Miller @ 2012-11-01 15:55 UTC (permalink / raw)
  To: standby24x7; +Cc: trivial, linux-kernel, netdev
In-Reply-To: <1351698499-15192-1-git-send-email-standby24x7@gmail.com>

From: Masanari Iida <standby24x7@gmail.com>
Date: Thu,  1 Nov 2012 00:48:19 +0900

> Correct spelling typo in net/sctp/socket.c
> 
> Signed-off-by: Masanari Iida <standby24x7@gmail.com>
> Acked-by: Vlad Yasevich <vyasevich@gmail.com>

Applied.

^ permalink raw reply

* Re: [PATCH] bonding: fix off-by-one error
From: David Miller @ 2012-11-01 15:54 UTC (permalink / raw)
  To: nikolay; +Cc: netdev, andy, fubar
In-Reply-To: <1351694571-26369-1-git-send-email-nikolay@redhat.com>

From: Nikolay Aleksandrov <nikolay@redhat.com>
Date: Wed, 31 Oct 2012 15:42:51 +0100

> Fix off-by-one error because IFNAMSIZ == 16 and when this
> code gets executed we stick a NULL byte where we should not.
> 
> How to reproduce:
>  with CONFIG_CC_STACKPROTECTOR=y (otherwise it may pass by silently)
>  modprobe bonding; echo 1 > /sys/class/net/bond0/bonding/mode;
>  echo "AAAAAAAAAAAAAAAA" > /sys/class/net/bond0/bonding/primary;
> 
> Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>

I've applied both of your patches, thanks.

^ permalink raw reply

* Re: [PATCHv2 net-next 1/8] skb: report completion status for zero copy skbs
From: David Miller @ 2012-11-01 15:50 UTC (permalink / raw)
  To: mst
  Cc: vyasevic, edumazet, akpm, alexander.h.duyck, Ian.Campbell, kvm,
	virtualization, netdev, linux-kernel
In-Reply-To: <0dc176ed796ff5ac7164b6c18cc75d64c2a2317e.1351679008.git.mst@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Wed, 31 Oct 2012 12:31:06 +0200

> -void vhost_zerocopy_callback(struct ubuf_info *ubuf)
> +void vhost_zerocopy_callback(struct ubuf_info *ubuf, int zerocopy_status)

If you're only reporting true/false values, even just for now,
please use 'bool' for this.

^ permalink raw reply

* Re: [RFC] back on nf_tables (plus compatibility layer)
From: Jan Engelhardt @ 2012-11-01 15:49 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Netfilter Development Mailing list,
	Linux Networking Developer Mailing List
In-Reply-To: <20121031154216.GB9558@1984>

On Wednesday 2012-10-31 16:42, Pablo Neira Ayuso wrote:
>> >> 
>> >> I have updated to the newest tree, and the first set is
>> >> available in the git repository at:
>> >>   git://git.inai.de/linux xt2-20121025
>> >
>> >If you think this feature is important, checkout nf_tables and think
>> >how to integrate this prototype code that provides atomic table
>> >replacement to it.
>> 
>> I'd rather tinker with xt2.
>
>You're are free spend your time on your pet project, but I warn you:
>it will *extremely hard* to justify its inclusion into mainline.
>As said, I don't think it makes sense to add two firewall
>engines/interfaces for the same thing.

You make it sound like you have already made up your mind and will
not consider xtnl because you are having nft as your pet project.
That would be really sad.

So, what xt2 has of this hour.

(- netlink interface obviously)
 - netns support
 - single table sufficiency
 - is RCU'd
 - atomic whole-table replace
 - atomic chain-level multi-rule replace
   (less to transfer over netlink between kernel<->user)
 - chain-level dump (also relates to transfer size)
 - packed ruleset for cache efficiency
 - already has had some review from community members when it was last posted
 - in-code and external documentation

Certainly there is still something to do - but so would there be for nft.

^ permalink raw reply

* Re: [PATCH v4 00/10] net/macb: driver enhancement concerning GEM support, ring logic and cleanup
From: David Miller @ 2012-11-01 15:46 UTC (permalink / raw)
  To: nicolas.ferre
  Cc: netdev, havard, bhutchings, linux-arm-kernel, plagnioj,
	patrice.vilchez, linux-kernel, manabian, David.Laight
In-Reply-To: <cover.1351690694.git.nicolas.ferre@atmel.com>

From: Nicolas Ferre <nicolas.ferre@atmel.com>
Date: Wed, 31 Oct 2012 17:04:49 +0100

> This is an enhancement work that began several years ago. I try to catchup with
> some performance improvement that has been implemented then by Havard.
> The ring index logic and the TX error path modification are the biggest changes
> but some cleanup/debugging have been added along the way.
> The GEM revision will benefit from the Gigabit support.
> Newer pinctrl infrastructure support is added but it is optional.
> 
> The series has been tested on several Atmel AT91 SoC with the two MACB/GEM
> flavors.
> 
> v4: - remove unneeded device tree header includes
>     - modified the computation of available entries in ring buffer
> v3: - rebased on net-next to take into account current effor to merge
>       at91_ether with macb drivers
>     - add additional patch to use the new pinctrl infrastructure
> v2: - modify the tx error handling: now uses a workqueue
>     - information provided by ethtool -i were not accurate: removed

Series applied to net-next

^ permalink raw reply

* Re: [PATCH V2 net-next 0/4] Convert blackfin to phc and remove timecompare
From: David Miller @ 2012-11-01 15:43 UTC (permalink / raw)
  To: richardcochran
  Cc: netdev, device-drivers-devel, uclinux-dist-devel, lliubbo,
	jacob.e.keller, jeffrey.t.kirsher, john.ronciak, john.stultz,
	vapier, sonic.zhang
In-Reply-To: <cover.1351696541.git.richardcochran@gmail.com>

From: Richard Cochran <richardcochran@gmail.com>
Date: Wed, 31 Oct 2012 17:27:21 +0100

> * Changes in V2:
>   - Correct the wrong direction of the shift when converting time
>     stamps to nanoseconds
>   - Add John Stultz's ack on patch 4
> 
> This patch series takes care of a legacy issue in the time keeping
> core by moving blackfin over to PHC model and removing the dubious
> timecompare code.
> 
> The blackfin is quite similar to the other MAC based PTP hardware
> clocks, and so the implementation is straightforward.
> 
> The first patch is a bug fix that should be merged in any
> case. Pacthes two and three convert the bfin_mac to offer a PHC
> device. The last patch removes the timecompare code.

Series applied.

^ permalink raw reply

* Re: [PATCH V2 net-next 1/1] ptp: add an ioctl to compare PHC time with system time
From: David Miller @ 2012-11-01 15:42 UTC (permalink / raw)
  To: richardcochran; +Cc: netdev, jacob.e.keller, john.stultz, mlichvar
In-Reply-To: <7701f1fd27692810e7948363344238287b9458c2.1351696507.git.richardcochran@gmail.com>

From: Richard Cochran <richardcochran@gmail.com>
Date: Wed, 31 Oct 2012 17:19:07 +0100

> This patch adds an ioctl for PTP Hardware Clock (PHC) devices that allows
> user space to measure the time offset between the PHC and the system
> clock. Rather than hard coding any kind of estimation algorithm into the
> kernel, this patch takes the more flexible approach of just delivering
> an array of raw clock readings. In that way, the user space clock servo
> may be adapted to new and different hardware clocks.
> 
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>
> Acked-by: Jacob Keller <jacob.e.keller@intel.com>

Applied.

^ permalink raw reply

* Re: [PATCH net-next 0/3] Enable PPS and PTP clocks automatically
From: David Miller @ 2012-11-01 15:37 UTC (permalink / raw)
  To: bhutchings; +Cc: giometti, richardcochran, netdev, linux-net-drivers
In-Reply-To: <1351733397.2706.62.camel@bwh-desktop.uk.solarflarecom.com>

From: Ben Hutchings <bhutchings@solarflare.com>
Date: Thu, 1 Nov 2012 01:29:57 +0000

> There are a number of problems with PPS and PTP kconfig options:
> 
> 1. PPS and PTP_1588_CLOCK depend on EXPERIMENTAL, therefore so must the
>    clock drivers.  (And EXPERIMENTAL is deprecated.)
> 2. PTP_1588_CLOCK depends on PPS, so users or clock driver options must
>    explicitly select both.
> 3. In general, users have to enable too many options to get hardware
>    timestamps and PTP working.
> 4. Boolean options for clock drivers combined with net drivers can force
>    the PTP and PPS subsystems to be built-in unnecessarily.
> 
> This series changes the options as follows:
> 
> 1. Nothing depends on EXPERIMENTAL.
> 2. Only PTP_1588_CLOCK selects PPS.
> 3, 4. The boolean options are removed and the net driver options select
>    PTP_1588_CLOCK.  Where a net driver and associated clock driver are
>    separate modules, the clock driver remains optional but is default y.

Looks good, series applied, thanks.

^ permalink raw reply

* Re: [PATCH net 0/7] bnx2x: fixes
From: David Miller @ 2012-11-01 15:33 UTC (permalink / raw)
  To: dmitry; +Cc: ariele, eilong, netdev
In-Reply-To: <1351698418-10005-1-git-send-email-dmitry@broadcom.com>

From: "Dmitry Kravkov" <dmitry@broadcom.com>
Date: Wed, 31 Oct 2012 17:46:51 +0200

> Please consider applying the series of fixes to net.
> 
> Dmitry Kravkov (1):
>       bnx2x: disable FCoE for 57840 since not yet supported by FW
> 
> Yaniv Rosner (6):
>       bnx2x: Fix 57810 1G-KR link against certain switches.
>       bnx2x: Fix link down in 57712 following LFA
>       bnx2x: Restore global registers back to default.
>       bnx2x: Fix potential incorrect link speed provision
>       bnx2x: Fix unrecognized SFP+ module after driver is loaded
>       bnx2x: Fix no link on 577xx 10G-baseT

Series applied, thanks.

^ permalink raw reply

* Re: [net] ixgbe: PTP get_ts_info missing software support
From: David Miller @ 2012-11-01 15:33 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: jacob.e.keller, netdev, gospo, sassmann, stable
In-Reply-To: <1351758654-9718-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Thu,  1 Nov 2012 01:30:54 -0700

> From: Jacob Keller <jacob.e.keller@intel.com>
> 
> This patch corrects the ethtool get_ts_info functon which did not state that
> software timestamping was supported, even though it is.
> 
> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> CC: Stable <stable@vger.kernel.org> [3.5]
> Tested-by: Stephen Ko <stephen.s.ko@intel.com>
> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>

Applied.

^ permalink raw reply

* Re: [PATCH v2 RESEND 3/6] net: calxedaxgmac: use relaxed i/o accessors in rx and tx paths
From: David Miller @ 2012-11-01 15:21 UTC (permalink / raw)
  To: robherring2; +Cc: netdev, eric.dumazet, rob.herring
In-Reply-To: <1351766464-27354-4-git-send-email-robherring2@gmail.com>

From: Rob Herring <robherring2@gmail.com>
Date: Thu,  1 Nov 2012 05:41:01 -0500

> From: Rob Herring <rob.herring@calxeda.com>
> 
> The standard readl/writel accessors involve a spinlock and cache sync
> operation on ARM platforms with an outer cache. Only DMA triggering
> accesses need this, so use the relaxed variants instead.
> 
> Signed-off-by: Rob Herring <rob.herring@calxeda.com>
> ---
>  drivers/net/ethernet/calxeda/Kconfig |    2 +-
>  drivers/net/ethernet/calxeda/xgmac.c |   12 ++++++------
>  2 files changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/net/ethernet/calxeda/Kconfig b/drivers/net/ethernet/calxeda/Kconfig
> index aba435c..6a4ddf6 100644
> --- a/drivers/net/ethernet/calxeda/Kconfig
> +++ b/drivers/net/ethernet/calxeda/Kconfig
> @@ -1,6 +1,6 @@
>  config NET_CALXEDA_XGMAC
>  	tristate "Calxeda 1G/10G XGMAC Ethernet driver"
> -	depends on HAS_IOMEM
> +	depends on HAS_IOMEM && ARM
>  	select CRC32
>  	help
>  	  This is the driver for the XGMAC Ethernet IP block found on Calxeda

This is a regression.  Now I can't built test this driver on x86
or sparc.

I'm not applying this series.  You can argue until the cows come home
about why you absolutley have to add this restriction, but I simply
don't care, this issue is too important to me.

^ permalink raw reply

* Re: [PATCH net-next] sk-filter: Add ability to get socket filter program (v2)
From: David Miller @ 2012-11-01 15:17 UTC (permalink / raw)
  To: xemul; +Cc: netdev
In-Reply-To: <509264AC.5090802@parallels.com>

From: Pavel Emelyanov <xemul@parallels.com>
Date: Thu, 01 Nov 2012 16:01:48 +0400

> 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>

Applied, thanks.

^ permalink raw reply

* Re: [net-next 0/6][pull request] Intel Wired LAN Driver Updates
From: David Miller @ 2012-11-01 15:16 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, gospo, sassmann
In-Reply-To: <1351766667-28489-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Thu,  1 Nov 2012 03:44:21 -0700

> This series contains updates to igb, ixgbe and e1000.
> 
> The following are changes since commit 810b6d7638a288216f99bd190470d67061c8bd88:
>   Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next
> and are available in the git repository at:
>   git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next master

Nothing there:

[davem@tempietto net-next]$ git pull git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next master
>From git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/net-next
 * branch            master     -> FETCH_HEAD
Already up-to-date.
[davem@tempietto net-next]$ 

Now is AN EXTREMELY bad period to waste my time like this.

^ permalink raw reply

* Re: [net-next v5 0/7] Multiqueue support in tuntap
From: David Miller @ 2012-11-01 15:14 UTC (permalink / raw)
  To: jasowang
  Cc: mst, netdev, linux-kernel, maxk, edumazet, krkumar2,
	ernesto.martin, haixiao
In-Reply-To: <1351748762-3455-1-git-send-email-jasowang@redhat.com>


Series applied to net-next, thanks.

^ permalink raw reply

* Re: [PATCH net-next v2] packet: tx_ring: allow the user to choose tx data offset
From: David Miller @ 2012-11-01 14:54 UTC (permalink / raw)
  To: paul.chavent; +Cc: Paul.Chavent, netdev
In-Reply-To: <5091967F.9050907@fnac.net>

From: Paul Chavent <paul.chavent@fnac.net>
Date: Wed, 31 Oct 2012 22:22:07 +0100

> It seems that the user can already fire an error msg by simply pass a
> too long tp_len.
> 
> Though, should i remove it from the tpacket_fill_skb function and
> silently return -EINVAL ?

Returning an error is much better than emitting log messages,
always.

^ permalink raw reply

* Re: [PATCH net-next] sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name
From: David Miller @ 2012-11-01 14:52 UTC (permalink / raw)
  To: andi; +Cc: brian.haley, xemul, eric.dumazet, netdev
In-Reply-To: <m2wqy6jrne.fsf@firstfloor.org>

From: Andi Kleen <andi@firstfloor.org>
Date: Wed, 31 Oct 2012 13:47:01 -0700

> Brian Haley <brian.haley@hp.com> writes:
> 
>> Instead of having the getsockopt() of SO_BINDTODEVICE return an index, which
>> will then require another call like if_indextoname() to get the actual interface
>> name, have it return the name directly.
>>
>> This also matches the existing man page description on socket(7) which mentions
>> the argument being an interface name.
>>
>> If the value has not been set, zero is returned and optlen will be set to zero
>> to indicate there is no interface name present.
> 
> That will break all existing programs using the return value, right?
> Better to fix the manpage

It never returned a value before, you could not getsockopt() on
SO_BINDTODEVICE previously.

^ permalink raw reply

* Re: [PATCH v4 00/10] net/macb: driver enhancement concerning GEM support, ring logic and cleanup
From: Jean-Christophe PLAGNIOL-VILLARD @ 2012-11-01 14:47 UTC (permalink / raw)
  To: Nicolas Ferre
  Cc: netdev, davem, havard, bhutchings, linux-arm-kernel,
	patrice.vilchez, linux-kernel, manabian, David.Laight
In-Reply-To: <cover.1351690694.git.nicolas.ferre@atmel.com>

On 17:04 Wed 31 Oct     , Nicolas Ferre wrote:
> This is an enhancement work that began several years ago. I try to catchup with
> some performance improvement that has been implemented then by Havard.
> The ring index logic and the TX error path modification are the biggest changes
> but some cleanup/debugging have been added along the way.
> The GEM revision will benefit from the Gigabit support.
> Newer pinctrl infrastructure support is added but it is optional.
> 
> The series has been tested on several Atmel AT91 SoC with the two MACB/GEM
> flavors.
> 
> v4: - remove unneeded device tree header includes
>     - modified the computation of available entries in ring buffer
> v3: - rebased on net-next to take into account current effor to merge
>       at91_ether with macb drivers
>     - add additional patch to use the new pinctrl infrastructure
> v2: - modify the tx error handling: now uses a workqueue
>     - information provided by ethtool -i were not accurate: removed
> 
> 
> Havard Skinnemoen (4):
>   net/macb: memory barriers cleanup
>   net/macb: change debugging messages
>   net/macb: clean up ring buffer logic
>   net/macb: Offset first RX buffer by two bytes
> 
> Jean-Christophe PLAGNIOL-VILLARD (1):
>   net/macb: add pinctrl consumer support
> 
> Nicolas Ferre (4):
>   net/macb: remove macb_get_drvinfo()
>   net/macb: tx status is more than 8 bits now
>   net/macb: ethtool interface: add register dump feature
>   net/macb: better manage tx errors
> 
> Patrice Vilchez (1):
>   net/macb: Add support for Gigabit Ethernet mode
> 
>  drivers/net/ethernet/cadence/at91_ether.c |   6 +-
>  drivers/net/ethernet/cadence/macb.c       | 448 +++++++++++++++++++++---------
>  drivers/net/ethernet/cadence/macb.h       |  30 +-
>  3 files changed, 337 insertions(+), 147 deletions(-)
Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Best Regards,
J.
> 
> -- 
> 1.8.0
> 

^ permalink raw reply

* Re: [PATCH 4/9] net: openvswitch: use this_cpu_ptr per-cpu helper
From: 单卫 @ 2012-11-01 14:44 UTC (permalink / raw)
  To: Christoph Lameter
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, NetDev, Kernel-Maillist, David Miller
In-Reply-To: <0000013abc646055-30441bd6-241f-436a-a356-9cd462da66ce-000000-p/GC64/jrecnJqMo6gzdpkEOCMrvLtNR@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 311 bytes --]

2012/11/1 Christoph Lameter <cl-vYTEC60ixJUAvxtiuMwx3w@public.gmane.org>

>
> > In addition, following usage of per_cpu_ptr can be replaced by
> this_cpu_read.
> >
> > cpu=get_cpu()
> > ....
> > *per_cpu_ptr(p,cpu)
> > ....
> > ....
> > put_cpu()
>
> Right.
>
>
Thanks very much,
I  will resubmit new patchset.

[-- Attachment #1.2: Type: text/html, Size: 684 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply

* [PATCH net-next] r8169: enable internal ASPM and clock request settings
From: Hayes Wang @ 2012-11-01 14:37 UTC (permalink / raw)
  To: romieu; +Cc: netdev, linux-kernel, Hayes Wang

The following chips need to enable internal settings to let ASPM
and clock request work.

RTL8111E-VL, RTL8111F, RTL8411, RTL8111G
RTL8105, RTL8402, RTL8106

Signed-off-by: Hayes Wang <hayeswang@realtek.com>
---
 drivers/net/ethernet/realtek/r8169.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 123c6a5..87d03f6 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -456,6 +456,7 @@ enum rtl8168_registers {
 #define PWM_EN				(1 << 22)
 #define RXDV_GATED_EN			(1 << 19)
 #define EARLY_TALLY_EN			(1 << 16)
+#define FORCE_CLK			(1 << 15) /* force clock request */
 };
 
 enum rtl_register_content {
@@ -519,6 +520,7 @@ enum rtl_register_content {
 	PMEnable	= (1 << 0),	/* Power Management Enable */
 
 	/* Config2 register p. 25 */
+	ClkReqEn	= (1 << 7),	/* Clock Request Enable */
 	MSIEnable	= (1 << 5),	/* 8169 only. Reserved in the 8168. */
 	PCI_Clock_66MHz = 0x01,
 	PCI_Clock_33MHz = 0x00,
@@ -539,6 +541,7 @@ enum rtl_register_content {
 	Spi_en		= (1 << 3),
 	LanWake		= (1 << 1),	/* LanWake enable/disable */
 	PMEStatus	= (1 << 0),	/* PME status can be reset by PCI RST# */
+	ASPM_en		= (1 << 0),	/* ASPM enable */
 
 	/* TBICSR p.28 */
 	TBIReset	= 0x80000000,
@@ -5046,8 +5049,6 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
 
 	RTL_W8(MaxTxPacketSize, EarlySize);
 
-	rtl_disable_clock_request(pdev);
-
 	RTL_W32(TxConfig, RTL_R32(TxConfig) | TXCFG_AUTO_FIFO);
 	RTL_W8(MCU, RTL_R8(MCU) & ~NOW_IS_OOB);
 
@@ -5056,7 +5057,8 @@ static void rtl_hw_start_8168e_2(struct rtl8169_private *tp)
 
 	RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN);
 	RTL_W32(MISC, RTL_R32(MISC) | PWM_EN);
-	RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
+	RTL_W8(Config5, (RTL_R8(Config5) & ~Spi_en) | ASPM_en);
+	RTL_W8(Config2, RTL_R8(Config2) | ClkReqEn);
 }
 
 static void rtl_hw_start_8168f(struct rtl8169_private *tp)
@@ -5081,13 +5083,12 @@ static void rtl_hw_start_8168f(struct rtl8169_private *tp)
 
 	RTL_W8(MaxTxPacketSize, EarlySize);
 
-	rtl_disable_clock_request(pdev);
-
 	RTL_W32(TxConfig, RTL_R32(TxConfig) | TXCFG_AUTO_FIFO);
 	RTL_W8(MCU, RTL_R8(MCU) & ~NOW_IS_OOB);
 	RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN);
-	RTL_W32(MISC, RTL_R32(MISC) | PWM_EN);
-	RTL_W8(Config5, RTL_R8(Config5) & ~Spi_en);
+	RTL_W32(MISC, RTL_R32(MISC) | PWM_EN | FORCE_CLK);
+	RTL_W8(Config5, (RTL_R8(Config5) & ~Spi_en) | ASPM_en);
+	RTL_W8(Config2, RTL_R8(Config2) | ClkReqEn);
 }
 
 static void rtl_hw_start_8168f_1(struct rtl8169_private *tp)
@@ -5145,7 +5146,10 @@ static void rtl_hw_start_8168g_1(struct rtl8169_private *tp)
 
 	RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb);
 	RTL_W32(MISC, RTL_R32(MISC) & ~RXDV_GATED_EN);
+	RTL_W32(MISC, RTL_R32(MISC) | FORCE_CLK);
 	RTL_W8(MaxTxPacketSize, EarlySize);
+	RTL_W8(Config5, RTL_R8(Config5) | ASPM_en);
+	RTL_W8(Config2, RTL_R8(Config2) | ClkReqEn);
 
 	rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
 	rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC);
@@ -5361,6 +5365,9 @@ static void rtl_hw_start_8105e_1(struct rtl8169_private *tp)
 
 	RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET);
 	RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN);
+	RTL_W8(Config5, RTL_R8(Config5) | ASPM_en);
+	RTL_W8(Config2, RTL_R8(Config2) | ClkReqEn);
+	RTL_W32(MISC, RTL_R32(MISC) | FORCE_CLK);
 
 	rtl_ephy_init(tp, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1));
 }
@@ -5386,6 +5393,9 @@ static void rtl_hw_start_8402(struct rtl8169_private *tp)
 
 	RTL_W32(TxConfig, RTL_R32(TxConfig) | TXCFG_AUTO_FIFO);
 	RTL_W8(MCU, RTL_R8(MCU) & ~NOW_IS_OOB);
+	RTL_W8(Config5, RTL_R8(Config5) | ASPM_en);
+	RTL_W8(Config2, RTL_R8(Config2) | ClkReqEn);
+	RTL_W32(MISC, RTL_R32(MISC) | FORCE_CLK);
 
 	rtl_ephy_init(tp, e_info_8402, ARRAY_SIZE(e_info_8402));
 
@@ -5407,7 +5417,10 @@ static void rtl_hw_start_8106(struct rtl8169_private *tp)
 	/* Force LAN exit from ASPM if Rx/Tx are not idle */
 	RTL_W32(FuncEvent, RTL_R32(FuncEvent) | 0x002800);
 
-	RTL_W32(MISC, (RTL_R32(MISC) | DISABLE_LAN_EN) & ~EARLY_TALLY_EN);
+	RTL_W32(MISC, RTL_R32(MISC) & ~EARLY_TALLY_EN);
+	RTL_W32(MISC, RTL_R32(MISC) | DISABLE_LAN_EN | FORCE_CLK);
+	RTL_W8(Config5, RTL_R8(Config5) | ASPM_en);
+	RTL_W8(Config2, RTL_R8(Config2) | ClkReqEn);
 	RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET);
 	RTL_W8(DLLPR, RTL_R8(DLLPR) & ~PFM_EN);
 }
-- 
1.7.11.4

^ permalink raw reply related

* Re: [PATCH 4/9] net: openvswitch: use this_cpu_ptr per-cpu helper
From: Christoph Lameter @ 2012-11-01 14:33 UTC (permalink / raw)
  To: Shan Wei
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, NetDev, Kernel-Maillist, David Miller
In-Reply-To: <509249C7.3080000-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

On Thu, 1 Nov 2012, Shan Wei wrote:

> But for different field in same per-cpu variable, how to guarantee n_missed
> and n_hit are from same cpu?
> this_cpu_read(dp->stats_percpu->n_missed);
> [processor changed]
> this_cpu_read(dp->stats_percpu->n_hit);

What does current guarantee that? If it is guaranteed then you can use the
__this_cpu_xxx ops.

> In addition, following usage of per_cpu_ptr can be replaced by this_cpu_read.
>
> cpu=get_cpu()
> ....
> *per_cpu_ptr(p,cpu)
> ....
> ....
> put_cpu()

Right.

^ permalink raw reply

* Re: [PATCH v2 2/3] pppoatm: fix race condition with destroying of vcc
From: chas williams - CONTRACTOR @ 2012-11-01 14:26 UTC (permalink / raw)
  To: Krzysztof Mazur; +Cc: davem, dwmw2, netdev, linux-kernel
In-Reply-To: <20121031220435.GA25157@shrek.podlesie.net>

On Wed, 31 Oct 2012 23:04:35 +0100
Krzysztof Mazur <krzysiek@podlesie.net> wrote:

> There are also some minor potential issues in pppoatm driver:
> 
> 	- locking issues, but now only between pppoatm_send() and
> 	  vcc_sendmsg() and maybe some other functions,

these have been around for a while.  i agree that something should be
done about it.  just not sure what should be synchronizing this mess.

> 	- missing check for SS_CONNECTED in pppoatm_ioctl,

in practice you will never run into this because a pvc is immediately
put into SS_CONNECTED mode (right before the userspace open()
returns).  however, should it check?  yes.  i dont see anything
preventing you from running ppp on svc's.

^ permalink raw reply

* Re: [PATCH net-next] sockopt: Change getsockopt() of SO_BINDTODEVICE to return an interface name
From: Brian Haley @ 2012-11-01 14:02 UTC (permalink / raw)
  To: Andi Kleen
  Cc: David Miller, Pavel Emelyanov, Eric Dumazet,
	netdev@vger.kernel.org
In-Reply-To: <m2wqy6jrne.fsf@firstfloor.org>

On 10/31/2012 04:47 PM, Andi Kleen wrote:
> Brian Haley <brian.haley@hp.com> writes:
> 
>> Instead of having the getsockopt() of SO_BINDTODEVICE return an index, which
>> will then require another call like if_indextoname() to get the actual interface
>> name, have it return the name directly.
>>
>> This also matches the existing man page description on socket(7) which mentions
>> the argument being an interface name.
>>
>> If the value has not been set, zero is returned and optlen will be set to zero
>> to indicate there is no interface name present.
> 
> That will break all existing programs using the return value, right?
> Better to fix the manpage

Dave just accepted the original code for this into net-next last week, so I
don't think it's too late to change it to be correct.

-Brian

^ permalink raw reply

* RE: [PATCH 3/9] net: xfrm: use this_cpu_ptr per-cpu helper
From: David Laight @ 2012-11-01 12:15 UTC (permalink / raw)
  To: Shan Wei, Christoph Lameter
  Cc: steffen.klassert, David Miller, NetDev, Herbert Xu,
	Kernel-Maillist
In-Reply-To: <50923956.5090206@gmail.com>

> this_cpu_read
> |-----_this_cpu_generic_read
> 
> #define _this_cpu_generic_read(pcp)                                     \
> ({      typeof(pcp) ret__;                                              \
>         preempt_disable();                                              \
>         ret__ = *this_cpu_ptr(&(pcp));                                  \
>         preempt_enable();                                               \
>         ret__;                                                          \
> })
> 
> 
> this_cpu_read operations locate per-cpu variable with preemption safe, not
> disable interrupts. why is it atomic vs interrupts?

Hmmm...  what effect do those preemt_dis/enable() actually have?
Since a pre-empt can happen either side of them, the value
the caller sees can be for the wrong cpu anyway.

The only time I could see them being necessary is if
*this_cpu_ptr() itself needs mutex protection in order to
function correctly - and that is likely to be port specific.
On i386/amd64 where (I guess) it is an access offset by fs/gs
this isn't necessary and just wastes cpu cycles.

If the caller cares which cpu the value comes from (eg to
increment a counter) then the caller would need to disable
pre-emption across the whole operation.

	David


^ permalink raw reply

* [PATCH net-next] sk-filter: Add ability to get socket filter program (v2)
From: Pavel Emelyanov @ 2012-11-01 12:01 UTC (permalink / raw)
  To: David Miller, Linux Netdev List

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>

---

diff --git a/arch/alpha/include/asm/socket.h b/arch/alpha/include/asm/socket.h
index 7d2f75b..0087d05 100644
--- a/arch/alpha/include/asm/socket.h
+++ b/arch/alpha/include/asm/socket.h
@@ -47,6 +47,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/arch/avr32/include/uapi/asm/socket.h b/arch/avr32/include/uapi/asm/socket.h
index a473f8c..486df68 100644
--- a/arch/avr32/include/uapi/asm/socket.h
+++ b/arch/avr32/include/uapi/asm/socket.h
@@ -40,6 +40,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/arch/cris/include/asm/socket.h b/arch/cris/include/asm/socket.h
index ae52825..b681b04 100644
--- a/arch/cris/include/asm/socket.h
+++ b/arch/cris/include/asm/socket.h
@@ -42,6 +42,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP           29
diff --git a/arch/frv/include/uapi/asm/socket.h b/arch/frv/include/uapi/asm/socket.h
index a5b1d7d..871f89b 100644
--- a/arch/frv/include/uapi/asm/socket.h
+++ b/arch/frv/include/uapi/asm/socket.h
@@ -40,6 +40,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME             28
 #define SO_TIMESTAMP		29
diff --git a/arch/h8300/include/asm/socket.h b/arch/h8300/include/asm/socket.h
index ec4554e..90a2e57 100644
--- a/arch/h8300/include/asm/socket.h
+++ b/arch/h8300/include/asm/socket.h
@@ -40,6 +40,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME             28
 #define SO_TIMESTAMP		29
diff --git a/arch/ia64/include/uapi/asm/socket.h b/arch/ia64/include/uapi/asm/socket.h
index 41fc28a..23d6759 100644
--- a/arch/ia64/include/uapi/asm/socket.h
+++ b/arch/ia64/include/uapi/asm/socket.h
@@ -49,6 +49,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER	26
 #define SO_DETACH_FILTER	27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/arch/m32r/include/asm/socket.h b/arch/m32r/include/asm/socket.h
index a15f40b..5e7088a 100644
--- a/arch/m32r/include/asm/socket.h
+++ b/arch/m32r/include/asm/socket.h
@@ -40,6 +40,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/arch/m68k/include/asm/socket.h b/arch/m68k/include/asm/socket.h
index d1be684..285da3b 100644
--- a/arch/m68k/include/asm/socket.h
+++ b/arch/m68k/include/asm/socket.h
@@ -40,6 +40,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME             28
 #define SO_TIMESTAMP		29
diff --git a/arch/mips/include/uapi/asm/socket.h b/arch/mips/include/uapi/asm/socket.h
index c5ed595..17307ab 100644
--- a/arch/mips/include/uapi/asm/socket.h
+++ b/arch/mips/include/uapi/asm/socket.h
@@ -63,6 +63,7 @@ To add: #define SO_REUSEPORT 0x0200	/* Allow local address and port reuse.  */
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME             28
 #define SO_TIMESTAMP		29
diff --git a/arch/mn10300/include/uapi/asm/socket.h b/arch/mn10300/include/uapi/asm/socket.h
index 820463a..af5366b 100644
--- a/arch/mn10300/include/uapi/asm/socket.h
+++ b/arch/mn10300/include/uapi/asm/socket.h
@@ -40,6 +40,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/arch/parisc/include/asm/socket.h b/arch/parisc/include/asm/socket.h
index 1b52c2c..d9ff473 100644
--- a/arch/parisc/include/asm/socket.h
+++ b/arch/parisc/include/asm/socket.h
@@ -48,6 +48,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        0x401a
 #define SO_DETACH_FILTER        0x401b
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_ACCEPTCONN		0x401c
 
diff --git a/arch/powerpc/include/uapi/asm/socket.h b/arch/powerpc/include/uapi/asm/socket.h
index 3d5179b..eb0b186 100644
--- a/arch/powerpc/include/uapi/asm/socket.h
+++ b/arch/powerpc/include/uapi/asm/socket.h
@@ -47,6 +47,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER	26
 #define SO_DETACH_FILTER	27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/arch/s390/include/uapi/asm/socket.h b/arch/s390/include/uapi/asm/socket.h
index 69718cd..436d07c 100644
--- a/arch/s390/include/uapi/asm/socket.h
+++ b/arch/s390/include/uapi/asm/socket.h
@@ -46,6 +46,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/arch/sparc/include/uapi/asm/socket.h b/arch/sparc/include/uapi/asm/socket.h
index bea1568..c83a937 100644
--- a/arch/sparc/include/uapi/asm/socket.h
+++ b/arch/sparc/include/uapi/asm/socket.h
@@ -41,6 +41,7 @@
 
 #define SO_ATTACH_FILTER	0x001a
 #define SO_DETACH_FILTER        0x001b
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		0x001c
 #define SO_TIMESTAMP		0x001d
diff --git a/arch/xtensa/include/asm/socket.h b/arch/xtensa/include/asm/socket.h
index e36c681..38079be 100644
--- a/arch/xtensa/include/asm/socket.h
+++ b/arch/xtensa/include/asm/socket.h
@@ -52,6 +52,7 @@
 
 #define SO_ATTACH_FILTER        26
 #define SO_DETACH_FILTER        27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/include/linux/filter.h b/include/linux/filter.h
index c9f0005..c45eabc 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -45,6 +45,7 @@ extern void sk_unattached_filter_destroy(struct sk_filter *fp);
 extern int sk_attach_filter(struct sock_fprog *fprog, struct sock *sk);
 extern int sk_detach_filter(struct sock *sk);
 extern int sk_chk_filter(struct sock_filter *filter, unsigned int flen);
+extern int sk_get_filter(struct sock *sk, struct sock_filter __user *filter, unsigned len);
 
 #ifdef CONFIG_BPF_JIT
 extern void bpf_jit_compile(struct sk_filter *fp);
diff --git a/include/uapi/asm-generic/socket.h b/include/uapi/asm-generic/socket.h
index b1bea03..2d32d07 100644
--- a/include/uapi/asm-generic/socket.h
+++ b/include/uapi/asm-generic/socket.h
@@ -43,6 +43,7 @@
 /* Socket filtering */
 #define SO_ATTACH_FILTER	26
 #define SO_DETACH_FILTER	27
+#define SO_GET_FILTER		SO_ATTACH_FILTER
 
 #define SO_PEERNAME		28
 #define SO_TIMESTAMP		29
diff --git a/net/core/filter.c b/net/core/filter.c
index 5a114d4..c23543c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -760,3 +760,133 @@ int sk_detach_filter(struct sock *sk)
 	return ret;
 }
 EXPORT_SYMBOL_GPL(sk_detach_filter);
+
+static void sk_decode_filter(struct sock_filter *filt, struct sock_filter *to)
+{
+	static const u16 decodes[] = {
+		[BPF_S_ALU_ADD_K]	= BPF_ALU|BPF_ADD|BPF_K,
+		[BPF_S_ALU_ADD_X]	= BPF_ALU|BPF_ADD|BPF_X,
+		[BPF_S_ALU_SUB_K]	= BPF_ALU|BPF_SUB|BPF_K,
+		[BPF_S_ALU_SUB_X]	= BPF_ALU|BPF_SUB|BPF_X,
+		[BPF_S_ALU_MUL_K]	= BPF_ALU|BPF_MUL|BPF_K,
+		[BPF_S_ALU_MUL_X]	= BPF_ALU|BPF_MUL|BPF_X,
+		[BPF_S_ALU_DIV_X]	= BPF_ALU|BPF_DIV|BPF_X,
+		[BPF_S_ALU_MOD_K]	= BPF_ALU|BPF_MOD|BPF_K,
+		[BPF_S_ALU_MOD_X]	= BPF_ALU|BPF_MOD|BPF_X,
+		[BPF_S_ALU_AND_K]	= BPF_ALU|BPF_AND|BPF_K,
+		[BPF_S_ALU_AND_X]	= BPF_ALU|BPF_AND|BPF_X,
+		[BPF_S_ALU_OR_K]	= BPF_ALU|BPF_OR|BPF_K,
+		[BPF_S_ALU_OR_X]	= BPF_ALU|BPF_OR|BPF_X,
+		[BPF_S_ALU_XOR_K]	= BPF_ALU|BPF_XOR|BPF_K,
+		[BPF_S_ALU_XOR_X]	= BPF_ALU|BPF_XOR|BPF_X,
+		[BPF_S_ALU_LSH_K]	= BPF_ALU|BPF_LSH|BPF_K,
+		[BPF_S_ALU_LSH_X]	= BPF_ALU|BPF_LSH|BPF_X,
+		[BPF_S_ALU_RSH_K]	= BPF_ALU|BPF_RSH|BPF_K,
+		[BPF_S_ALU_RSH_X]	= BPF_ALU|BPF_RSH|BPF_X,
+		[BPF_S_ALU_NEG]		= BPF_ALU|BPF_NEG,
+		[BPF_S_LD_W_ABS]	= BPF_LD|BPF_W|BPF_ABS,
+		[BPF_S_LD_H_ABS]	= BPF_LD|BPF_H|BPF_ABS,
+		[BPF_S_LD_B_ABS]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_PROTOCOL]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_PKTTYPE]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_IFINDEX]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_NLATTR]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_NLATTR_NEST]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_MARK]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_QUEUE]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_HATYPE]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_RXHASH]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_CPU]		= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_ALU_XOR_X]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_SECCOMP_LD_W] = BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_VLAN_TAG]	= BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_ANC_VLAN_TAG_PRESENT] = BPF_LD|BPF_B|BPF_ABS,
+		[BPF_S_LD_W_LEN]	= BPF_LD|BPF_W|BPF_LEN,
+		[BPF_S_LD_W_IND]	= BPF_LD|BPF_W|BPF_IND,
+		[BPF_S_LD_H_IND]	= BPF_LD|BPF_H|BPF_IND,
+		[BPF_S_LD_B_IND]	= BPF_LD|BPF_B|BPF_IND,
+		[BPF_S_LD_IMM]		= BPF_LD|BPF_IMM,
+		[BPF_S_LDX_W_LEN]	= BPF_LDX|BPF_W|BPF_LEN,
+		[BPF_S_LDX_B_MSH]	= BPF_LDX|BPF_B|BPF_MSH,
+		[BPF_S_LDX_IMM]		= BPF_LDX|BPF_IMM,
+		[BPF_S_MISC_TAX]	= BPF_MISC|BPF_TAX,
+		[BPF_S_MISC_TXA]	= BPF_MISC|BPF_TXA,
+		[BPF_S_RET_K]		= BPF_RET|BPF_K,
+		[BPF_S_RET_A]		= BPF_RET|BPF_A,
+		[BPF_S_ALU_DIV_K]	= BPF_ALU|BPF_DIV|BPF_K,
+		[BPF_S_LD_MEM]		= BPF_LD|BPF_MEM,
+		[BPF_S_LDX_MEM]		= BPF_LDX|BPF_MEM,
+		[BPF_S_ST]		= BPF_ST,
+		[BPF_S_STX]		= BPF_STX,
+		[BPF_S_JMP_JA]		= BPF_JMP|BPF_JA,
+		[BPF_S_JMP_JEQ_K]	= BPF_JMP|BPF_JEQ|BPF_K,
+		[BPF_S_JMP_JEQ_X]	= BPF_JMP|BPF_JEQ|BPF_X,
+		[BPF_S_JMP_JGE_K]	= BPF_JMP|BPF_JGE|BPF_K,
+		[BPF_S_JMP_JGE_X]	= BPF_JMP|BPF_JGE|BPF_X,
+		[BPF_S_JMP_JGT_K]	= BPF_JMP|BPF_JGT|BPF_K,
+		[BPF_S_JMP_JGT_X]	= BPF_JMP|BPF_JGT|BPF_X,
+		[BPF_S_JMP_JSET_K]	= BPF_JMP|BPF_JSET|BPF_K,
+		[BPF_S_JMP_JSET_X]	= BPF_JMP|BPF_JSET|BPF_X,
+	};
+	u16 code;
+
+	code = filt->code;
+
+	to->code = decodes[code];
+	to->jt = filt->jt;
+	to->jf = filt->jf;
+
+	if (code == BPF_S_ALU_DIV_K) {
+		/*
+		 * When loaded this rule user gave us X, which was
+		 * translated into R = r(X). Now we calculate the
+		 * RR = r(R) and report it back. If next time this
+		 * value is loaded and RRR = r(RR) is calculated
+		 * then the R == RRR will be true.
+		 *
+		 * One exception. X == 1 translates into R == 0 and
+		 * we can't calculate RR out of it with r().
+		 */
+
+		if (filt->k == 0)
+			to->k = 1;
+		else
+			to->k = reciprocal_value(filt->k);
+
+		BUG_ON(reciprocal_value(to->k) != filt->k);
+	} else
+		to->k = filt->k;
+}
+
+int sk_get_filter(struct sock *sk, struct sock_filter __user *ubuf, unsigned int len)
+{
+	struct sk_filter *filter;
+	int i, ret;
+
+	lock_sock(sk);
+	filter = rcu_dereference_protected(sk->sk_filter,
+			sock_owned_by_user(sk));
+	ret = 0;
+	if (!filter)
+		goto out;
+	ret = filter->len;
+	if (!len)
+		goto out;
+	ret = -EINVAL;
+	if (len < filter->len)
+		goto out;
+
+	ret = -EFAULT;
+	for (i = 0; i < filter->len; i++) {
+		struct sock_filter fb;
+
+		sk_decode_filter(&filter->insns[i], &fb);
+		if (copy_to_user(&ubuf[i], &fb, sizeof(fb)))
+			goto out;
+	}
+
+	ret = filter->len;
+out:
+	release_sock(sk);
+	return ret;
+}
diff --git a/net/core/sock.c b/net/core/sock.c
index 0a023b8..0628600 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1077,6 +1077,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
 	case SO_BINDTODEVICE:
 		v.val = sk->sk_bound_dev_if;
 		break;
+	case SO_GET_FILTER:
+		len = sk_get_filter(sk, (struct sock_filter __user *)optval, len);
+		if (len < 0)
+			return len;
+
+		goto lenout;
 	default:
 		return -ENOPROTOOPT;
 	}

^ permalink raw reply related


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox