Netdev List
 help / color / mirror / Atom feed
* Re: [net-next 00/10 v2][pull request] Intel Wired LAN Driver Update
From: David Miller @ 2011-07-22  6:23 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: netdev, gospo, sassmann
In-Reply-To: <1311314951-11142-1-git-send-email-jeffrey.t.kirsher@intel.com>

From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Date: Thu, 21 Jul 2011 23:09:01 -0700

> The following series contains updates to e1000, igb and ixgbe.
> 
> v2: fix my fat finger mess up while reviewing a patch.
> 
> The following are changes since commit 61463a30f65225e19e68f59dbd7b888bb308ec99:
>   can: make function can_get_bittiming static
> and are available in the git repository at:
>   master.kernel.org:/pub/scm/linux/kernel/git/jkirsher/net-next-2.6 master

Looks a lot better, pulled, thanks!

^ permalink raw reply

* Re: [PULL net] vhost-net: zercopy mode fixes
From: David Miller @ 2011-07-22  6:24 UTC (permalink / raw)
  To: mst; +Cc: kvm, virtualization, netdev, linux-kernel, mashirle, xma
In-Reply-To: <20110722060046.GA8876@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Fri, 22 Jul 2011 09:00:46 +0300

> The following includes vhost-net fixes - both in the
> experimental zero copy mode.
> Please pull for 3.1.
> Thanks!
> 

Where is this "the following"?  I don't see any GIT url to pull
from or anything :-)

^ permalink raw reply

* linux-next: build warning after merge of the final tree
From: Stephen Rothwell @ 2011-07-22  6:24 UTC (permalink / raw)
  To: David Miller, netdev; +Cc: linux-next, linux-kernel, Matt Evans

[-- Attachment #1: Type: text/plain, Size: 517 bytes --]

Hi all,

After merging the final tree, today's linux-next build (powerpc64
allnoconfig) produced this warning:

warning: (PPC) selects HAVE_BPF_JIT which has unmet direct dependencies (NET)

Introduced by commit 0ca87f05ba8b ("net: filter: BPF 'JIT' compiler for
PPC64").

I suspect that the fix is to move the

config HAVE_BPF_JIT
        bool

lines to outside the "if NET" in net/Kconfig.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 490 bytes --]

^ permalink raw reply

* Re: [PATCH] acenic: include NET_SKB_PAD headroom to incoming skbs
From: David Miller @ 2011-07-22  6:25 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev
In-Reply-To: <1311312533.3886.2.camel@edumazet-laptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Fri, 22 Jul 2011 07:28:53 +0200

> Some workloads need some headroom (NET_SKB_PAD) to avoid expensive
> reallocations.
> 
> Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>

Applied, thanks Eric.

^ permalink raw reply

* Re: linux-next: build warning after merge of the final tree
From: David Miller @ 2011-07-22  6:26 UTC (permalink / raw)
  To: sfr; +Cc: netdev, linux-next, linux-kernel, matt
In-Reply-To: <20110722162433.a280b3b71cff9c08fe18956f@canb.auug.org.au>

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Fri, 22 Jul 2011 16:24:33 +1000

> warning: (PPC) selects HAVE_BPF_JIT which has unmet direct dependencies (NET)
> 
> Introduced by commit 0ca87f05ba8b ("net: filter: BPF 'JIT' compiler for
> PPC64").
> 
> I suspect that the fix is to move the
> 
> config HAVE_BPF_JIT
>         bool
> 
> lines to outside the "if NET" in net/Kconfig.

I'm going to fix this the way it's dealt with in the x86_64 case
for now, thanks for the report:

--------------------
net: Fix ppc64 BPF JIT dependencies.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 arch/powerpc/Kconfig |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 39860fc..cdf7a0a 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -134,7 +134,7 @@ config PPC
 	select GENERIC_IRQ_SHOW_LEVEL
 	select HAVE_RCU_TABLE_FREE if SMP
 	select HAVE_SYSCALL_TRACEPOINTS
-	select HAVE_BPF_JIT if PPC64
+	select HAVE_BPF_JIT if (PPC64 && NET)
 
 config EARLY_PRINTK
 	bool
-- 
1.7.6

^ permalink raw reply related

* [PULL net (try 2)] vhost-net: zercopy mode fixes
From: Michael S. Tsirkin @ 2011-07-22  6:32 UTC (permalink / raw)
  To: David Miller; +Cc: kvm, virtualization, netdev, linux-kernel, mashirle, xma
In-Reply-To: <20110722060046.GA8876@redhat.com>

Fixing a corrupted pull request sent earlier.
Sorry about the noise!

The following includes vhost-net fixes - both in the
experimental zero copy mode.
Please pull for 3.1.
Thanks!

The following changes since commit fd99beb9375b44309d5ed9c2b62063e23151610b:

  Merge branch 'vhost-net-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost (2011-07-19 10:12:44 -0700)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost.git vhost-net-next

Michael S. Tsirkin (1):
      vhost-net: update used ring on backend change

Shirley Ma (1):
      vhost: handle wrap around in # of bufs math

 drivers/vhost/net.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

^ permalink raw reply

* Re: [PULL net (try 2)] vhost-net: zercopy mode fixes
From: David Miller @ 2011-07-22  6:37 UTC (permalink / raw)
  To: mst; +Cc: kvm, virtualization, netdev, linux-kernel, mashirle, xma
In-Reply-To: <20110722063238.GB9637@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Fri, 22 Jul 2011 09:32:38 +0300

> Fixing a corrupted pull request sent earlier.
> Sorry about the noise!
> 
> The following includes vhost-net fixes - both in the
> experimental zero copy mode.
> Please pull for 3.1.

Pulled, thanks!

^ permalink raw reply

* Re: linux-next: manual merge of the trivial tree with the net tree
From: Francois Romieu @ 2011-07-22  6:42 UTC (permalink / raw)
  To: Stephen Rothwell
  Cc: Jiri Kosina, linux-next, linux-kernel, Phil Carmody, David Miller,
	netdev
In-Reply-To: <20110722141842.963b38d45ebf8cb5d0a25fcf@canb.auug.org.au>

Stephen Rothwell <sfr@canb.auug.org.au> :
[...]
> diff --cc drivers/net/r8169.c
> index 40bcb82,6f36306..0000000
> --- a/drivers/net/r8169.c
> +++ b/drivers/net/r8169.c
> @@@ -682,19 -666,8 +682,19 @@@ struct rtl8169_private 
>   	struct rtl8169_counters counters;
>   	u32 saved_wolopts;
>   
>  -	const struct firmware *fw;
>  +	struct rtl_fw {
>  +		const struct firmware *fw;
>  +
>  +#define RTL_VER_SIZE		32
>  +
>  +		char version[RTL_VER_SIZE];
>  +
>  +		struct rtl_fw_phy_action {
>  +			__le32 *code;
>  +			size_t size;
>  +		} phy_action;
>  +	} *rtl_fw;
> - #define RTL_FIRMWARE_UNKNOWN	ERR_PTR(-EAGAIN);
> + #define RTL_FIRMWARE_UNKNOWN	ERR_PTR(-EAGAIN)

There should not be further conflict in this part of the code until
things get merged with Linus's tree. Do what suits best.

Thanks.

-- 
Ueimor

^ permalink raw reply

* Re: [PATCH net-2.6] jme: Fix unmap error (Causing system freeze)
From: Michał Mirosław @ 2011-07-22  7:45 UTC (permalink / raw)
  To: cooldavid
  Cc: David Miller, linux-netdev, Aries Lee, Devinchiu, Jason Lamb,
	Marcus Becker, Marc Schiffbauer, Jason Long, stable
In-Reply-To: <1311217056-9073-1-git-send-email-cooldavid@cooldavid.org>

2011/7/21  <cooldavid@cooldavid.org>:
> From: Guo-Fu Tseng <cooldavid@cooldavid.org>
>
> This patch add the missing dma_unmap().
> Which solved the critical issue of system freeze on heavy load.
>
> Michal Miroslaw's rejected patch:
> [PATCH v2 10/46] net: jme: convert to generic DMA API
> Pointed out the issue also, thank you Michal.
> But the fix was incorrect. It would unmap needed address
> when low memory.

My patch also fixed another issue - from correctness point of view,
you should not use virt_to_page+dma_map_page here, but dma_map_single.

Best Regards,
Michał Mirosław

^ permalink raw reply

* Re: icmp_route_lookup returns wrong source address information
From: David Miller @ 2011-07-22  7:59 UTC (permalink / raw)
  To: fw; +Cc: netdev
In-Reply-To: <20110720192258.GA21528@Chamillionaire.breakpoint.cc>

From: Florian Westphal <fw@strlen.de>
Date: Wed, 20 Jul 2011 21:22:58 +0200

> With linux-2.6 and net-next trees, whenever an icmp error message is
> sent in response to a to-be-forwarded packet, the destination address
> of the original packet is used as the IP header source address.
> 
> Example:
> $ traceroute breakpoint.cc
> traceroute to breakpoint.cc (85.10.199.196), 30 hops max, 40 byte packets
>  1  chamillionaire.breakpoint.cc (85.10.199.196)  0.476 ms  0.468 ms  0.793 ms
> 
> But the expected 1st hop is 192.168.20.7 in my setup.
> 
> I bisected this down to 77968b78242ee25e2a4d759f0fca8dd52df6d479
> ("ipv4: Pass flow keys down into datagram packet building engine.")
> 
> Specifically, it is caused by this hunk:
 ...
> Problem is that xfrm_decode_session_reverse() may rebuild fl4 from scratch.
> 
> In my setup, "goto relookup_failed" will be hit a bit later on, and fl4->saddr will
> be set to iph->daddr...

Thanks for the detailed report Florian, I'll look into this.

^ permalink raw reply

* Re: [net-next 10/10] ixgbe: convert to ndo_fix_features
From: Michal Miroslaw @ 2011-07-22  8:02 UTC (permalink / raw)
  To: Jeff Kirsher; +Cc: davem, Don Skidmore, netdev, gospo, sassmann
In-Reply-To: <1311314951-11142-11-git-send-email-jeffrey.t.kirsher@intel.com>

On Thu, Jul 21, 2011 at 11:09:11PM -0700, Jeff Kirsher wrote:
> From: Don Skidmore <donald.c.skidmore@intel.com>
> 
> Private rx_csum flags are now duplicate of netdev->features &
> NETIF_F_RXCSUM.  We remove those duplicates and now use the net_device_ops
> ndo_set_features.  This was based on the original patch submitted by
> Michal Miroslaw <mirq-linux@rere.qmqm.pl>.  I also removed the special
> case not requiring a reset for X540 hardware.  It is needed just as it is
> in 82599 hardware.

Looks mostly good now. Minor hints below.

[...]
> +static u32 ixgbe_fix_features(struct net_device *netdev, u32 data)
> +{
[...]
> +	/* Turn off LRO if not RSC capable or invalid ITR settings */
> +	if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) {
> +		data &= ~NETIF_F_LRO;
> +	} else if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) &&
> +		   (adapter->rx_itr_setting != 1 &&
> +		    adapter->rx_itr_setting > IXGBE_MAX_RSC_INT_RATE)) {
> +		data &= ~NETIF_F_LRO;
> +		e_info(probe, "rx-usecs set too low, not enabling RSC\n");
> +	}

Better:

... else if (data & NETIF_F_LRO && adapter->rx_itr_setting != 1 && adapter->rx_itr_setting > IXGBE_MAX_RSC_INT_RATE) {
	e_info(...)
	data &= ~NETIF_F_LRO;
}

> +
> +	return data;
> +}
> +
> +static int ixgbe_set_features(struct net_device *netdev, u32 data)
> +{
> +	struct ixgbe_adapter *adapter = netdev_priv(netdev);
> +	bool need_reset = false;
> +
> +	/* If Rx checksum is disabled, then RSC/LRO should also be disabled */
> +	if (!(data & NETIF_F_RXCSUM))
> +		adapter->flags &= ~IXGBE_FLAG_RX_CSUM_ENABLED;
> +	else
> +		adapter->flags |= IXGBE_FLAG_RX_CSUM_ENABLED;

This exactly mirrors NETIF_F_RXCSUM. Waiting for later cleanup?

[...]
> +	/*
> +	 * Check if Flow Director n-tuple support was enabled or disabled.  If
> +	 * the state changed, we need to reset.
> +	 */
> +	if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) {
> +		/* turn off ATR, enable perfect filters and reset */
> +		if (data & NETIF_F_NTUPLE) {
> +			adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
> +			adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
> +			need_reset = true;
> +		}
> +	} else if (!(data & NETIF_F_NTUPLE)) {
> +		/* turn off Flow Director, set ATR and reset */
> +		adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
> +		if ((adapter->flags &  IXGBE_FLAG_RSS_ENABLED) &&
> +		    !(adapter->flags &  IXGBE_FLAG_DCB_ENABLED))
> +			adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
> +		need_reset = true;
> +	}

You could make this more readable:

old = adapter->flags;
if (data & NETIF_F_NTUPLE) {
	adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
	adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE;
} else {
	adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE;
	if ((adapter->flags &  IXGBE_FLAG_RSS_ENABLED) &&
	    !(adapter->flags &  IXGBE_FLAG_DCB_ENABLED))
		adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE;
}
if (old != adapter->flags)
	need_reset = true;

> +
> +	if (need_reset)
> +		ixgbe_do_reset(netdev);
> +
> +	return 0;
> +
> +}
> +
>  static const struct net_device_ops ixgbe_netdev_ops = {
>  	.ndo_open		= ixgbe_open,
>  	.ndo_stop		= ixgbe_close,
> @@ -7153,6 +7228,8 @@ static const struct net_device_ops ixgbe_netdev_ops = {
>  	.ndo_fcoe_disable = ixgbe_fcoe_disable,
>  	.ndo_fcoe_get_wwn = ixgbe_fcoe_get_wwn,
>  #endif /* IXGBE_FCOE */
> +	.ndo_set_features = ixgbe_set_features,
> +	.ndo_fix_features = ixgbe_fix_features,
>  };
>  
>  static void __devinit ixgbe_probe_vf(struct ixgbe_adapter *adapter,
> @@ -7420,20 +7497,24 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
>  
>  	netdev->features = NETIF_F_SG |
>  			   NETIF_F_IP_CSUM |
> +			   NETIF_F_IPV6_CSUM |
>  			   NETIF_F_HW_VLAN_TX |
>  			   NETIF_F_HW_VLAN_RX |
> -			   NETIF_F_HW_VLAN_FILTER;
> +			   NETIF_F_HW_VLAN_FILTER |
> +			   NETIF_F_TSO |
> +			   NETIF_F_TSO6 |
> +			   NETIF_F_GRO |
> +			   NETIF_F_RXHASH |
> +			   NETIF_F_RXCSUM;

Drop NETIF_F_GRO here, as its always set by network core now.

> -	netdev->features |= NETIF_F_IPV6_CSUM;
> -	netdev->features |= NETIF_F_TSO;
> -	netdev->features |= NETIF_F_TSO6;
> -	netdev->features |= NETIF_F_GRO;
> -	netdev->features |= NETIF_F_RXHASH;
> +	netdev->hw_features = netdev->features;
>  
>  	switch (adapter->hw.mac.type) {
>  	case ixgbe_mac_82599EB:
>  	case ixgbe_mac_X540:
>  		netdev->features |= NETIF_F_SCTP_CSUM;
> +		netdev->hw_features |= NETIF_F_SCTP_CSUM |
> +				       NETIF_F_NTUPLE;

NTUPLE disabled by default. That's the idea?

Best Regards,
Michał Mirosław

^ permalink raw reply

* Re: IPv6: autoconfiguration and suspend/resume or link down/up
From: David Miller @ 2011-07-22  8:06 UTC (permalink / raw)
  To: jbohac; +Cc: netdev, herbert, shemminger
In-Reply-To: <20110719180222.GA7509@midget.suse.cz>

From: Jiri Bohac <jbohac@suse.cz>
Date: Tue, 19 Jul 2011 20:02:53 +0200

> When the cable is unplugged and plugged in again, we already get
> notified through linkwatch -> netdev_state_change ->
>   -> call_netdevice_notifiers(NETDEV_CHANGE, ...)
> However, if the device has already been autoconfigured,
> addrconf_notify() only handles this event by printing a
> message.
> 
> So my idea was to:
> - handle link up/down in addrconf_notify() similarly to
>   NETDEV_UP/NETDEV_DOWN
> 
> - on suspend, faking a link down event; on resume, faking a link up event
>   (or better, having a special event type for suspend/resume)
> 
> This would cause autoconfiguration to be restarted on resume as
> well as cable plug/unplug, solving both the above problems.
> 
> Or do we want to completely rely on userspace tools
> (networkmanager/ifplug) and expect them to do NETDEV_DOWN on
> unplug/suspend and NETDEV_UP on plug/resume?
> 
> Any thoughts?

This is an oft-reocurring discussion, what to do on link up/down
events wrt. all sorts of autoconfiguration.

My gut instinct is that on any link state change (physical link down,
suspend) we should be prepared to renegotiate everything and anything
since as you state we could be on a different physical network.

Suspend is even more important because while we were suspended we
could be on the same network but the routers present and available
might have changed completely.

In userspace I've noticed that we've grown an ecosystem of stupid
tools and facilities, none (or very few) of which monitor link status
in order to do handle things intelligently.  DHCP servers are a great
example.  DHCP servers spit out broadcast discover packets before we
even have a link up.

Filling this void is NetworkManager, which does listen on a netlink
socket for device state changes, hotplug, etc.  And in response it
explicitly tells various facilities to reprobe the network.

This is why I'm reluctant to give NetworkManager a hard time, because
whilst it's a huge beast, it is at least trying to do the right thing.
:-)

^ permalink raw reply

* tcp/udp checksum on loopback interface
From: Pierre Louis Aublin @ 2011-07-22  8:01 UTC (permalink / raw)
  To: netdev

Hello everybody

I am interested in the reliability of TCP and UDP using the loopback 
interface.
I found that there is no checksum verification on the body of packets 
transmitted through the loopback interface : 
http://kerneltrap.org/mailarchive/linux-netdev/2007/10/2/327241
I ran a simple test using iperf and wireshark and I indeed found the 
validation of the checksum is disabled at packets reception.

At the reception, I guess the piece of code responsible for this 
behaviour is (line 1196 of net/ipv4/udp.c, in udp_recvmsg() for UDP) :
if (skb_csum_unnecessary(skb))
     err = skb_copy_datagram_iovec(skb, sizeof(struct udphdr), 
msg->msg_iov, len);
Is this the responsible piece of code? If yes, where does the 
CHECKSUM_UNNECESSARY flag is set?

However, I am not sure whether the checksum is computed on the whole 
packet at emission.
In __ip_append_data (net/ipv4/ip_output.c), I found the flag csummode is 
at the beginning at CHECKSUM_NONE.
Then, it is augmented using the dev->features flag of the network device 
(e.g. the loopback interface).
As the loopback interface has the NETIF_F_NO_CSUM flag, csummode stays 
at CHECKSUM_NONE and the checksum is not computed on the body of the 
message.
Can you confirm the checksum is computed only on the header of the 
packet when sending it through the loopback interface?

Finally, why this behaviour? Is it because you assume message can not 
get corrupted while staying on the same machine?

Thank you in advance
Pierre Louis Aublin

^ permalink raw reply

* Re: [PATCH net-2.6] jme: Fix unmap error (Causing system freeze)
From: Guo-Fu Tseng @ 2011-07-22  8:49 UTC (permalink / raw)
  To: Michał Mirosław 
  Cc: Jason Lamb, linux-netdev, Jason Long, stable, Marcus Becker,
	Aries Lee, Devinchiu, Marc Schiffbauer, David Miller
In-Reply-To: <CAHXqBF+1aJ0O9WxrZTKfYMm57emysfPUnA-=M9DZN5kUGnhW8g@mail.gmail.com>

On Fri, 22 Jul 2011 09:45:42 +0200, Michał Mirosław wrote
> 2011/7/21  <cooldavid@cooldavid.org>:
> > From: Guo-Fu Tseng <cooldavid@cooldavid.org>
> >
> > This patch add the missing dma_unmap().
> > Which solved the critical issue of system freeze on heavy load.
> >
> > Michal Miroslaw's rejected patch:
> > [PATCH v2 10/46] net: jme: convert to generic DMA API
> > Pointed out the issue also, thank you Michal.
> > But the fix was incorrect. It would unmap needed address
> > when low memory.
> 
> My patch also fixed another issue - from correctness point of view,
> you should not use virt_to_page+dma_map_page here, but dma_map_single.
> 
> Best Regards,
> Michał Mirosław
Hi Michał:

Yes, I did noticed that. :)

And I agreed that using {dma|pci}_map_single is better than
calling virt_to_page in driver.

It's just that I'm not sure if it is really preferred to use
dma_map_single over pci_map_single for PCI device driver?

You are very welcome to send another patch for converting the
DMA API using.

Guo-Fu Tseng

_______________________________________________
stable mailing list
stable@linux.kernel.org
http://linux.kernel.org/mailman/listinfo/stable

^ permalink raw reply

* Re: IPv6: autoconfiguration and suspend/resume or link down/up
From: Herbert Xu @ 2011-07-22  9:21 UTC (permalink / raw)
  To: David Miller; +Cc: jbohac, netdev, shemminger
In-Reply-To: <20110722.010628.1678943945721626312.davem@davemloft.net>

On Fri, Jul 22, 2011 at 01:06:28AM -0700, David Miller wrote:
> 
> Suspend is even more important because while we were suspended we
> could be on the same network but the routers present and available
> might have changed completely.

Unfortunately virtual machine live migration also uses the suspend
& resume mechanism.  In that case we don't wish to renegotiate
everything, since the goal is to minimise the outage window.

This would suggest that putting the policy in user-space may be the
best option.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply

* [PATCH net-2.6] gre: fix improper error handling
From: Dmitry Kozlov @ 2011-07-22  9:26 UTC (permalink / raw)
  To: davem; +Cc: netdev

Fix improper protocol err_handler, current implementation is fully 
unapplicable and may cause kernel crash due to double kfree_skb.

Signed-off-by: Dmitry Kozlov <xeb@mail.ru>
--
 net/ipv4/gre.c |   23 +++++++----------------
 1 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c
index c6933f2..a8126fe 100644
--- a/net/ipv4/gre.c
+++ b/net/ipv4/gre.c
@@ -15,6 +15,7 @@
 #include <linux/kmod.h>
 #include <linux/skbuff.h>
 #include <linux/in.h>
+#include <linux/ip.h>
 #include <linux/netdevice.h>
 #include <linux/version.h>
 #include <linux/spinlock.h>
@@ -97,27 +98,17 @@ drop:
 static void gre_err(struct sk_buff *skb, u32 info)
 {
        const struct gre_protocol *proto;
-       u8 ver;
-
-       if (!pskb_may_pull(skb, 12))
-               goto drop;
-
-       ver = skb->data[1]&0x7f;
+       const struct iphdr *iph = (const struct iphdr *)skb->data;
+       u8 ver = skb->data[(iph->ihl<<2) + 1]&0x7f;
+
        if (ver >= GREPROTO_MAX)
-               goto drop;
+               return;
 
        rcu_read_lock();
        proto = rcu_dereference(gre_proto[ver]);
-       if (!proto || !proto->err_handler)
-               goto drop_unlock;
-       proto->err_handler(skb, info);
-       rcu_read_unlock();
-       return;
-
-drop_unlock:
+       if (proto && proto->err_handler)
+           proto->err_handler(skb, info);
        rcu_read_unlock();
-drop:
-       kfree_skb(skb);
 }
 
 static const struct net_protocol net_gre_protocol = {

^ permalink raw reply related

* Question regarding sendmmsg().
From: Tetsuo Handa @ 2011-07-22 11:41 UTC (permalink / raw)
  To: netdev; +Cc: paul.moore, linux-security-module
In-Reply-To: <201107211721.14511.paul.moore@hp.com>

TOMOYO was about to add support for permission checks for
PF_INET/PF_INET6/PF_UNIX socket's bind()/listen()/connect()/send() operations
( http://www.spinics.net/linux/fedora/linux-security-module/msg11496.html ).

According to http://ozlabs.org/~anton/junkcode/sendmmsg_test.c , the sendmmsg()
introduced by commit 228e548e "net: Add sendmmsg socket system call" is capable
of sending to multiple different destinations with single sendmmsg(), isn't it?

If yes, my plan (restricting sendmsg() based on destination's address) became
impossible since security_socket_sendmsg() (which receives the destination's
address) is called for only once even if there are multiple different
destinations.

^ permalink raw reply

* Re: Question regarding sendmmsg().
From: Tetsuo Handa @ 2011-07-22 12:27 UTC (permalink / raw)
  To: casey; +Cc: netdev, linux-security-module
In-Reply-To: <201107222041.FGG51092.OOQFFLOtMVFJHS@I-love.SAKURA.ne.jp>

Tetsuo Handa wrote:
> According to http://ozlabs.org/~anton/junkcode/sendmmsg_test.c , the sendmmsg()
> introduced by commit 228e548e "net: Add sendmmsg socket system call" is capable
> of sending to multiple different destinations with single sendmmsg(), isn't it?
> 
> If yes, my plan (restricting sendmsg() based on destination's address) became
> impossible since security_socket_sendmsg() (which receives the destination's
> address) is called for only once even if there are multiple different
> destinations.

It seems to me that sendmmsg() caused a regression for SMACK.
SMACK implements security_socket_sendmsg() which uses destination address.

static int smack_socket_sendmsg(struct socket *sock, struct msghdr *msg,
                                int size)
{
        struct sockaddr_in *sip = (struct sockaddr_in *) msg->msg_name;

        /*
         * Perfectly reasonable for this to be NULL
         */
        if (sip == NULL || sip->sin_family != AF_INET)
                return 0;

        return smack_netlabel_send(sock->sk, sip);
}

I think SMACK wants to know all destination addresses as with TOMOYO.

^ permalink raw reply

* Re: [PATCH net-2.6] gre: fix improper error handling
From: David Miller @ 2011-07-22 13:01 UTC (permalink / raw)
  To: xeb; +Cc: netdev
In-Reply-To: <201107221326.10597.xeb@mail.ru>

From: Dmitry Kozlov <xeb@mail.ru>
Date: Fri, 22 Jul 2011 13:26:10 +0400

> Fix improper protocol err_handler, current implementation is fully 
> unapplicable and may cause kernel crash due to double kfree_skb.
> 
> Signed-off-by: Dmitry Kozlov <xeb@mail.ru>

Your patch has been corrupted by your email client.

For example, it has changed tab characters into sequences of spaces.

This makes your patch unusable.

Please read Documentation/email-clients.txt to learn how to fix this,
and after fixing your setup send a test patch to yourself and try
to apply it just as we would when you post it here.

Only after this self-test passes, should you try to resubmit your
patch.

Thank you.

^ permalink raw reply

* [ANNOUNCE]: Release of iptables-1.4.12
From: Patrick McHardy @ 2011-07-22 13:02 UTC (permalink / raw)
  To: Netfilter Development Mailinglist
  Cc: Linux Netdev List, netfilter-announce,
	'netfilter@vger.kernel.org'

[-- Attachment #1: Type: text/plain, Size: 607 bytes --]

The netfilter coreteam presents:

    iptables version 1.4.12

the iptables release for the 3.0.0 kernel. Changes include:

- regression fixes for problems reported for the 1.4.11.1 release

- more conversions to the guided option parser

- fixes for problems detected by the coverity scanner

- documentation updates

See the attached changelogs for the full list of changes.

Version 1.4.12 can be obtained from:

http://www.netfilter.org/projects/iptables/downloads.html
ftp://ftp.netfilter.org/pub/iptables/
git://git.netfilter.org/iptables.git

On behalf of the Netfilter Core Team,
Happy firewalling!

[-- Attachment #2: changes-iptables-1.4.12.txt --]
[-- Type: text/plain, Size: 2038 bytes --]

Fernando Luis Vazquez Cao (1):
      doc: document IPv6 TOS mangling bug in old Linux kernels

Jakub Zawadzki (1):
      doc: fix group range in libxt_NFLOG's man

Jan Engelhardt (23):
      doc: include matches/targets in manpage again
      libipt_LOG: fix ignoring all but last flags
      libxt_RATEEST: use guided option parser
      iptables: consolidate target/match init call
      extensions: support for per-extension instance "global" variable space
      libxt_rateest: abolish global variables
      libxt_RATEEST: abolish global variables
      libip6t_HL: fix option names from ttl -> hl
      libxt_state: fix regression about inversion of main option
      libxt_hashlimit: use a more obvious expiry value by default
      build: bump soversion for recent data structure change
      build: attempt to fix building under Linux 2.4
      doc: mention multiple verbosity flags
      build: install modules in arch-dependent location
      doc: fix version string in ip6tables.8
      doc: the -m option cannot be inverted
      iptables: restore negation for -f
      libxtables: properly reject empty hostnames
      libxtables: ignore whitespace in the multiaddress argument parser
      option: remove last traces of intrapositional negation
      libxtables: set clone's initial data to NULL
      libxt_conntrack: restore network-byte order for v1,v2
      libxt_conntrack: move more data into the xt_option_entry

Jiri Popelka (5):
      iptables: Coverity: DEADCODE
      iptables: Coverity: NEGATIVE_RETURNS
      iptables: Coverity: REVERSE_INULL
      iptables: Coverity: VARARGS
      iptables: Coverity: RESOURCE_LEAK

Martin F. Krafft (1):
      iptables-apply: select default rule file depending on call name

Massimo Maggi (1):
      libxt_RATEEST: fix userspacesize field

Patrick McHardy (4):
      Merge branch 'master' of git://dev.medozas.de/iptables
      Merge branch 'master' of git://dev.medozas.de/iptables
      Merge branch 'master' of git://dev.medozas.de/iptables
      Bump version to 1.4.12


^ permalink raw reply

* [PATCH/RFC v2 0/13] enable SKB paged fragment lifetime visibility
From: Ian Campbell @ 2011-07-22 13:08 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA, linux-nfs-u79uwXL29TY76Z2rM5mHXA

Hi,

This is v2 of my series to enable visibility into SKB paged fragment's
lifecycles, v1 is at [0] and contains some more background and rationale
but basically the series allows entities which inject pages into the
networking stack to receive a notification when the stack has really
finished with those pages (i.e. including retransmissions, clones,
pull-ups etc) and not just when the original skb is finished with, which
is beneficial to many subsystems which wish to inject pages into the
network stack without giving up full ownership of those page's
lifecycle. It implements something broadly along the lines of what was
described in [1].

I have updated based on the feedback from last time. In particular:
      * Added destructor directly to sendpage() protocol hooks instead
        of inventing sendpage_destructor() (David Miller)
      * Dropped skb_frag_pci_map in favour of skb_frag_dma_map on Michał
        Mirosław's advice
      * Pushed the NFS fix down into the RPC layer. (Trond)

I also split out the patches to make protocols use the new interface
into per-protocol patches. I held back on splitting up the patch to
drivers/* (since that will cause an explosion in the series length) --
I'll do this split for v3.

FYI I'm travelling for the next two weeks, although I expect to have
good access to mail next week I'm less sure about the following week.

Cheers,
Ian.

[0] http://marc.info/?l=linux-netdev&m=131072801125521&w=2
[1] http://marc.info/?l=linux-netdev&m=130925719513084&w=2

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH 01/13] mm: Make some struct page's const.
From: Ian Campbell @ 2011-07-22 13:17 UTC (permalink / raw)
  To: netdev, linux-nfs
  Cc: Ian Campbell, Andrew Morton, Rik van Riel, Andrea Arcangeli,
	Mel Gorman, Michel Lespinasse, linux-mm, linux-kernel
In-Reply-To: <1311340095.12772.57.camel@zakaz.uk.xensource.com>

These uses are read-only and in a subsequent patch I have a const struct page
in my hand...

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Michel Lespinasse <walken@google.com>
Cc: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org
---
 include/linux/mm.h |   10 +++++-----
 mm/sparse.c        |    2 +-
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/linux/mm.h b/include/linux/mm.h
index 9670f71..550ec8f 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -636,7 +636,7 @@ static inline pte_t maybe_mkwrite(pte_t pte, struct vm_area_struct *vma)
 #define SECTIONS_MASK		((1UL << SECTIONS_WIDTH) - 1)
 #define ZONEID_MASK		((1UL << ZONEID_SHIFT) - 1)
 
-static inline enum zone_type page_zonenum(struct page *page)
+static inline enum zone_type page_zonenum(const struct page *page)
 {
 	return (page->flags >> ZONES_PGSHIFT) & ZONES_MASK;
 }
@@ -664,15 +664,15 @@ static inline int zone_to_nid(struct zone *zone)
 }
 
 #ifdef NODE_NOT_IN_PAGE_FLAGS
-extern int page_to_nid(struct page *page);
+extern int page_to_nid(const struct page *page);
 #else
-static inline int page_to_nid(struct page *page)
+static inline int page_to_nid(const struct page *page)
 {
 	return (page->flags >> NODES_PGSHIFT) & NODES_MASK;
 }
 #endif
 
-static inline struct zone *page_zone(struct page *page)
+static inline struct zone *page_zone(const struct page *page)
 {
 	return &NODE_DATA(page_to_nid(page))->node_zones[page_zonenum(page)];
 }
@@ -717,7 +717,7 @@ static inline void set_page_links(struct page *page, enum zone_type zone,
  */
 #include <linux/vmstat.h>
 
-static __always_inline void *lowmem_page_address(struct page *page)
+static __always_inline void *lowmem_page_address(const struct page *page)
 {
 	return __va(PFN_PHYS(page_to_pfn(page)));
 }
diff --git a/mm/sparse.c b/mm/sparse.c
index aa64b12..858e1df 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -40,7 +40,7 @@ static u8 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
 static u16 section_to_node_table[NR_MEM_SECTIONS] __cacheline_aligned;
 #endif
 
-int page_to_nid(struct page *page)
+int page_to_nid(const struct page *page)
 {
 	return section_to_node_table[page_to_section(page)];
 }
-- 
1.7.2.5

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related

* [PATCH 02/13] mm: use const struct page for r/o page-flag accessor methods
From: Ian Campbell @ 2011-07-22 13:17 UTC (permalink / raw)
  To: netdev, linux-nfs
  Cc: Ian Campbell, Andrew Morton, Andrea Arcangeli, Rik van Riel,
	Martin Schwidefsky, Michel Lespinasse, linux-kernel
In-Reply-To: <1311340095.12772.57.camel@zakaz.uk.xensource.com>

In a subsquent patch I have a const struct page in my hand...

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: linux-kernel@vger.kernel.org
---
 include/linux/page-flags.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index 6081493..7d632cc 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -135,7 +135,7 @@ enum pageflags {
  * Macros to create function definitions for page flags
  */
 #define TESTPAGEFLAG(uname, lname)					\
-static inline int Page##uname(struct page *page) 			\
+static inline int Page##uname(const struct page *page) 			\
 			{ return test_bit(PG_##lname, &page->flags); }
 
 #define SETPAGEFLAG(uname, lname)					\
@@ -173,7 +173,7 @@ static inline int __TestClearPage##uname(struct page *page)		\
 	__SETPAGEFLAG(uname, lname)  __CLEARPAGEFLAG(uname, lname)
 
 #define PAGEFLAG_FALSE(uname) 						\
-static inline int Page##uname(struct page *page) 			\
+static inline int Page##uname(const struct page *page) 			\
 			{ return 0; }
 
 #define TESTSCFLAG(uname, lname)					\
-- 
1.7.2.5

^ permalink raw reply related

* [PATCH 07/13] net: xfrm: convert to SKB frag APIs
From: Ian Campbell @ 2011-07-22 13:17 UTC (permalink / raw)
  To: netdev-u79uwXL29TY76Z2rM5mHXA, linux-nfs-u79uwXL29TY76Z2rM5mHXA
  Cc: Ian Campbell, David S. Miller
In-Reply-To: <1311340095.12772.57.camel-o4Be2W7LfRlXesXXhkcM7miJhflN2719@public.gmane.org>

Signed-off-by: Ian Campbell <ian.campbell-Sxgqhf6Nn4DQT0dZR+AlfA@public.gmane.org>
Cc: "David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
 net/xfrm/xfrm_ipcomp.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/net/xfrm/xfrm_ipcomp.c b/net/xfrm/xfrm_ipcomp.c
index fc91ad7..f781b9a 100644
--- a/net/xfrm/xfrm_ipcomp.c
+++ b/net/xfrm/xfrm_ipcomp.c
@@ -70,26 +70,29 @@ static int ipcomp_decompress(struct xfrm_state *x, struct sk_buff *skb)
 
 	while ((scratch += len, dlen -= len) > 0) {
 		skb_frag_t *frag;
+		struct page *page;
 
 		err = -EMSGSIZE;
 		if (WARN_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS))
 			goto out;
 
 		frag = skb_shinfo(skb)->frags + skb_shinfo(skb)->nr_frags;
-		frag->page = alloc_page(GFP_ATOMIC);
+		page = alloc_page(GFP_ATOMIC);
 
 		err = -ENOMEM;
-		if (!frag->page)
+		if (!page)
 			goto out;
 
+		__skb_frag_set_page(frag, page);
+
 		len = PAGE_SIZE;
 		if (dlen < len)
 			len = dlen;
 
-		memcpy(page_address(frag->page), scratch, len);
-
 		frag->page_offset = 0;
 		frag->size = len;
+		memcpy(skb_frag_address(frag), scratch, len);
+
 		skb->truesize += len;
 		skb->data_len += len;
 		skb->len += len;
-- 
1.7.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related

* [PATCH 03/13] net: add APIs for manipulating skb page fragments.
From: Ian Campbell @ 2011-07-22 13:17 UTC (permalink / raw)
  To: netdev, linux-nfs
  Cc: Ian Campbell, David S. Miller, Eric Dumazet,
	Michał Mirosław
In-Reply-To: <1311340095.12772.57.camel@zakaz.uk.xensource.com>

The primary aim is to add skb_frag_(ref|unref) in order to remove the use of
bare get/put_page on SKB pages fragments and to isolate users from subsequent
changes to the skb_frag_t data structure.

The API also includes an accessor for the struct page itself. The default
variant of this returns a *const* struct page in an attempt to catch bare uses
of get/put_page (which take a non-const struct page).

Also included are helper APIs for passing a paged fragment to kmap and
dma_map_page since I was seeing the same pattern a lot. A helper for
pci_map_page is ommitted due to Michał Mirosław's recommendation that users
should transition to pci_map_page instead.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: "Michał Mirosław" <mirq-linux@rere.qmqm.pl>
Cc: netdev@vger.kernel.org
---
 include/linux/skbuff.h |  204 +++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 202 insertions(+), 2 deletions(-)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c0a4f3a..f4034af 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -29,6 +29,8 @@
 #include <linux/rcupdate.h>
 #include <linux/dmaengine.h>
 #include <linux/hrtimer.h>
+#include <linux/highmem.h>
+#include <linux/pci.h>
 
 /* Don't change this without changing skb_csum_unnecessary! */
 #define CHECKSUM_NONE 0
@@ -1109,14 +1111,47 @@ static inline int skb_pagelen(const struct sk_buff *skb)
 	return len + skb_headlen(skb);
 }
 
-static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
-				      struct page *page, int off, int size)
+/**
+ * __skb_fill_page_desc - initialise a paged fragment in an skb
+ * @skb: buffer containing fragment to be initialised
+ * @i: paged fragment index to initialise
+ * @page: the page to use for this fragment
+ * @off: the offset to the data with @page
+ * @size: the length of the data
+ *
+ * Initialises the @i'th fragment of @skb to point to &size bytes at
+ * offset @off within @page.
+ *
+ * Does not take any additional reference on the fragment.
+ */
+static inline void __skb_fill_page_desc(struct sk_buff *skb, int i,
+					struct page *page, int off, int size)
 {
 	skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
 
 	frag->page		  = page;
 	frag->page_offset	  = off;
 	frag->size		  = size;
+}
+
+/**
+ * skb_fill_page_desc - initialise a paged fragment in an skb
+ * @skb: buffer containing fragment to be initialised
+ * @i: paged fragment index to initialise
+ * @page: the page to use for this fragment
+ * @off: the offset to the data with @page
+ * @size: the length of the data
+ *
+ * As per __skb_fill_page_desc() -- initialises the @i'th fragment of
+ * @skb to point to &size bytes at offset @off within @page. In
+ * addition updates @skb such that @i is the last fragment.
+ *
+ * Does not take any additional reference on the fragment.
+ */
+static inline void skb_fill_page_desc(struct sk_buff *skb, int i,
+				      struct page *page, int off, int size)
+{
+	__skb_fill_page_desc(skb, i, page, off, size);
 	skb_shinfo(skb)->nr_frags = i + 1;
 }
 
@@ -1605,6 +1640,171 @@ static inline void netdev_free_page(struct net_device *dev, struct page *page)
 }
 
 /**
+ * __skb_frag_page - retrieve the page refered to by a paged fragment
+ * @frag: the paged fragment
+ *
+ * Returns the &struct page associated with @frag. Where possible you
+ * should use skb_frag_page() which returns a const &struct page.
+ */
+static inline struct page *__skb_frag_page(const skb_frag_t *frag)
+{
+	return frag->page;
+}
+
+/**
+ * __skb_frag_page - retrieve the page refered to by a paged fragment
+ * @frag: the paged fragment
+ *
+ * Returns the &struct page associated with @frag as a const.
+ */
+static inline const struct page *skb_frag_page(const skb_frag_t *frag)
+{
+	return frag->page;
+}
+
+/**
+ * __skb_frag_ref - take an addition reference on a paged fragment.
+ * @frag: the paged fragment
+ *
+ * Takes an additional reference on the paged fragment @frag.
+ */
+static inline void __skb_frag_ref(skb_frag_t *frag)
+{
+	get_page(__skb_frag_page(frag));
+}
+
+/**
+ * skb_frag_ref - take an addition reference on a paged fragment of an skb.
+ * @skb: the buffer
+ * @f: the fragment offset.
+ *
+ * Takes an additional reference on the @f'th paged fragment of @skb.
+ */
+static inline void skb_frag_ref(struct sk_buff *skb, int f)
+{
+	__skb_frag_ref(&skb_shinfo(skb)->frags[f]);
+}
+
+/**
+ * __skb_frag_unref - release a reference on a paged fragment.
+ * @frag: the paged fragment
+ *
+ * Releases a reference on the paged fragment @frag.
+ */
+static inline void __skb_frag_unref(skb_frag_t *frag)
+{
+	put_page(__skb_frag_page(frag));
+}
+
+/**
+ * skb_frag_unref - release a reference on a paged fragment of an skb.
+ * @skb: the buffer
+ * @f: the fragment offset
+ *
+ * Releases a reference on the @f'th paged fragment of @skb.
+ */
+static inline void skb_frag_unref(struct sk_buff *skb, int f)
+{
+	__skb_frag_unref(&skb_shinfo(skb)->frags[f]);
+}
+
+/**
+ * skb_frag_address - gets the address of the data contained in a paged fragment
+ * @frag: the paged fragment buffer
+ *
+ * Returns the address of the data within @frag. The page must already
+ * be mapped.
+ */
+static inline void *skb_frag_address(const skb_frag_t *frag)
+{
+	return page_address(skb_frag_page(frag)) + frag->page_offset;
+}
+
+/**
+ * skb_frag_address_safe - gets the address of the data contained in a paged fragment
+ * @frag: the paged fragment buffer
+ *
+ * Returns the address of the data within @frag. Checks that the page
+ * is mapped and returns %NULL otherwise.
+ */
+static inline void *skb_frag_address_safe(const skb_frag_t *frag)
+{
+	void *ptr = page_address(skb_frag_page(frag));
+	if (unlikely(!ptr))
+		return NULL;
+
+	return ptr + frag->page_offset;
+}
+
+/**
+ * __skb_frag_set_page - sets the page contained in a paged fragment
+ * @frag: the paged fragment
+ * @page: the page to set
+ *
+ * Sets the fragment @frag to contain @page.
+ */
+static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
+{
+	frag->page = page;
+	__skb_frag_ref(frag);
+}
+
+/**
+ * skb_frag_set_page - sets the page contained in a paged fragment of an skb
+ * @skb: the buffer
+ * @f: the fragment offset
+ * @page: the page to set
+ *
+ * Sets the @f'th fragment of @skb to contain @page.
+ */
+static inline void skb_frag_set_page(struct sk_buff *skb, int f,
+				     struct page *page)
+{
+	__skb_frag_set_page(&skb_shinfo(skb)->frags[f], page);
+}
+
+/**
+ * skb_frag_kmap - kmaps a paged fragment
+ * @frag: the paged fragment
+ *
+ * kmap()s the paged fragment @frag and returns the virtual address.
+ */
+static inline void *skb_frag_kmap(skb_frag_t *frag)
+{
+	return kmap(__skb_frag_page(frag));
+}
+
+/**
+ * skb_frag_kmap - kunmaps a paged fragment
+ * @frag: the paged fragment
+ *
+ * kunmap()s the paged fragment @frag.
+ */
+static inline void skb_frag_kunmap(skb_frag_t *frag)
+{
+	kunmap(__skb_frag_page(frag));
+}
+
+/**
+ * skb_frag_dma_map - maps a paged fragment via the DMA API
+ * @device: the device to map the fragment to
+ * @frag: the paged fragment to map
+ * @offset: the offset within the fragment (starting at the fragments own offset)
+ * @size: the number of bytes to map
+ * @direction: the direction of the mapping (%PCI_DMA_*)
+ *
+ * Maps the page associated with @frag to @device.
+ */
+static inline dma_addr_t skb_frag_dma_map(struct device *dev,
+					  const skb_frag_t *frag,
+					  size_t offset, size_t size,
+					  enum dma_data_direction dir)
+{
+	return dma_map_page(dev, __skb_frag_page(frag),
+			    frag->page_offset + offset, size, dir);
+}
+
+/**
  *	skb_clone_writable - is the header of a clone writable
  *	@skb: buffer to check
  *	@len: length up to which to write
-- 
1.7.2.5


^ 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