From: Patrick Ohly <patrick.ohly@intel.com>
To: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
John Stultz <johnstul@us.ibm.com>,
linux-api@vger.kernel.org, Patrick Ohly <patrick.ohly@intel.com>
Subject: [RFC PATCH 04/12] sockets: allow allocating skb with optional structures
Date: Mon, 15 Dec 2008 15:54:51 +0100 [thread overview]
Message-ID: <1229352899-31330-5-git-send-email-patrick.ohly@intel.com> (raw)
In-Reply-To: <1229352899-31330-4-git-send-email-patrick.ohly@intel.com>
The internal sock_alloc_send_pskb() is now exposed
as sock_alloc_send_skb_flags() and takes a flags
parameter with additional instructions for how the
skb is to be allocated. This is necessary for adding
send time stamping information to outgoing packets.
sock_alloc_send_skb() is turned into a simple wrapper
which preserves compatibility with code that
passes a boolean "nblock" instead of the flags
bitmask.
sock_alloc_send_pskb() was never called with non-zero
data_len, therefore the obsolete code and parameter
were removed.
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
---
include/net/sock.h | 17 +++++++++++++----
net/core/sock.c | 50 +++++++-------------------------------------------
2 files changed, 20 insertions(+), 47 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 36807e4..6cb120c 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -948,10 +948,19 @@ extern int sock_setsockopt(struct socket *sock, int level,
extern int sock_getsockopt(struct socket *sock, int level,
int op, char __user *optval,
int __user *optlen);
-extern struct sk_buff *sock_alloc_send_skb(struct sock *sk,
- unsigned long size,
- int noblock,
- int *errcode);
+extern struct sk_buff *sock_alloc_send_skb_flags(struct sock *sk,
+ unsigned long size,
+ int flags,
+ int *errcode);
+inline static struct sk_buff *sock_alloc_send_skb(struct sock *sk,
+ unsigned long size,
+ int noblock,
+ int *errcode)
+{
+ return sock_alloc_send_skb_flags(sk, size,
+ noblock ? SKB_FLAGS_NOBLOCK : 0,
+ errcode);
+}
extern void *sock_kmalloc(struct sock *sk, int size,
gfp_t priority);
extern void sock_kfree_s(struct sock *sk, void *mem, int size);
diff --git a/net/core/sock.c b/net/core/sock.c
index 35b4f4c..64f959e 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1304,10 +1304,9 @@ static long sock_wait_for_wmem(struct sock * sk, long timeo)
* Generic send/receive buffer handlers
*/
-static struct sk_buff *sock_alloc_send_pskb(struct sock *sk,
+struct sk_buff *sock_alloc_send_skb_flags(struct sock *sk,
unsigned long header_len,
- unsigned long data_len,
- int noblock, int *errcode)
+ int flags, int *errcode)
{
struct sk_buff *skb;
gfp_t gfp_mask;
@@ -1318,7 +1317,9 @@ static struct sk_buff *sock_alloc_send_pskb(struct sock *sk,
if (gfp_mask & __GFP_WAIT)
gfp_mask |= __GFP_REPEAT;
- timeo = sock_sndtimeo(sk, noblock);
+ timeo = sock_sndtimeo(sk,
+ (flags & SKB_FLAGS_NOBLOCK) ?
+ MSG_DONTWAIT : 0);
while (1) {
err = sock_error(sk);
if (err != 0)
@@ -1329,39 +1330,8 @@ static struct sk_buff *sock_alloc_send_pskb(struct sock *sk,
goto failure;
if (atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) {
- skb = alloc_skb(header_len, gfp_mask);
+ skb = __alloc_skb_flags(header_len, gfp_mask, flags, -1);
if (skb) {
- int npages;
- int i;
-
- /* No pages, we're done... */
- if (!data_len)
- break;
-
- npages = (data_len + (PAGE_SIZE - 1)) >> PAGE_SHIFT;
- skb->truesize += data_len;
- skb_shinfo(skb)->nr_frags = npages;
- for (i = 0; i < npages; i++) {
- struct page *page;
- skb_frag_t *frag;
-
- page = alloc_pages(sk->sk_allocation, 0);
- if (!page) {
- err = -ENOBUFS;
- skb_shinfo(skb)->nr_frags = i;
- kfree_skb(skb);
- goto failure;
- }
-
- frag = &skb_shinfo(skb)->frags[i];
- frag->page = page;
- frag->page_offset = 0;
- frag->size = (data_len >= PAGE_SIZE ?
- PAGE_SIZE :
- data_len);
- data_len -= PAGE_SIZE;
- }
-
/* Full success... */
break;
}
@@ -1388,12 +1358,6 @@ failure:
return NULL;
}
-struct sk_buff *sock_alloc_send_skb(struct sock *sk, unsigned long size,
- int noblock, int *errcode)
-{
- return sock_alloc_send_pskb(sk, size, 0, noblock, errcode);
-}
-
static void __lock_sock(struct sock *sk)
{
DEFINE_WAIT(wait);
@@ -2327,7 +2291,7 @@ subsys_initcall(proto_init);
EXPORT_SYMBOL(sk_alloc);
EXPORT_SYMBOL(sk_free);
EXPORT_SYMBOL(sk_send_sigurg);
-EXPORT_SYMBOL(sock_alloc_send_skb);
+EXPORT_SYMBOL(sock_alloc_send_skb_flags);
EXPORT_SYMBOL(sock_init_data);
EXPORT_SYMBOL(sock_kfree_s);
EXPORT_SYMBOL(sock_kmalloc);
--
1.5.5.3
next prev parent reply other threads:[~2008-12-15 14:54 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-15 14:54 hardware time stamping with optional structs in data area Patrick Ohly
2008-12-15 14:54 ` [RFC PATCH 01/12] net: new user space API for time stamping of incoming and outgoing packets Patrick Ohly
2008-12-15 14:54 ` [RFC PATCH 02/12] net: infrastructure for hardware time stamping Patrick Ohly
[not found] ` <1229352899-31330-3-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-12-15 14:54 ` [RFC PATCH 03/12] net: socket infrastructure for SO_TIMESTAMPING Patrick Ohly
2008-12-15 14:54 ` Patrick Ohly [this message]
2008-12-15 14:54 ` [RFC PATCH 05/12] ip: support for TX timestamps on UDP and RAW sockets Patrick Ohly
[not found] ` <1229352899-31330-6-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-12-15 14:54 ` [RFC PATCH 06/12] debug: NULL pointer check in ip_output Patrick Ohly
2008-12-15 14:54 ` [RFC PATCH 07/12] net: pass new SIOCSHWTSTAMP through to device drivers Patrick Ohly
[not found] ` <1229352899-31330-8-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-12-15 14:54 ` [RFC PATCH 08/12] igb: stub support for SIOCSHWTSTAMP Patrick Ohly
[not found] ` <1229352899-31330-9-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-12-15 14:54 ` [RFC PATCH 09/12] clocksource: allow usage independent of timekeeping.c Patrick Ohly
[not found] ` <1229352899-31330-10-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-12-15 14:54 ` [RFC PATCH 10/12] igb: access to NIC time Patrick Ohly
[not found] ` <1229352899-31330-11-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2008-12-15 14:54 ` [RFC PATCH 11/12] time sync: generic infrastructure to map between time stamps generated by a time counter and system time Patrick Ohly
2008-12-15 14:54 ` [RFC PATCH 12/12] igb: use clocksync to implement hardware time stamping Patrick Ohly
2008-12-15 16:26 ` [RFC PATCH 09/12] clocksource: allow usage independent of timekeeping.c John Stultz
2008-12-15 16:45 ` Patrick Ohly
2009-02-04 14:29 ` Daniel Walker
2009-02-04 15:00 ` Patrick Ohly
2008-12-15 21:53 ` [RFC PATCH 02/12] net: infrastructure for hardware time stamping Herbert Xu
[not found] ` <E1LCLNV-0001EW-CN-XQvu0L+U/CjiRBuR/1fSEKKkPtS2pBon@public.gmane.org>
2008-12-16 7:56 ` Patrick Ohly
[not found] ` <1229352899-31330-1-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-16 10:36 ` hardware time stamping with optional structs in data area Patrick Ohly
2009-01-16 19:00 ` David Miller
[not found] ` <20090116.110033.163815590.davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
2009-01-21 10:07 ` Patrick Ohly
2009-01-21 10:10 ` [PATCH NET-NEXT 01/12] net: new user space API for time stamping of incoming and outgoing packets Patrick Ohly
2009-01-21 10:10 ` [PATCH NET-NEXT 02/12] net: infrastructure for hardware time stamping Patrick Ohly
2009-01-21 10:10 ` [PATCH NET-NEXT 03/12] net: socket infrastructure for SO_TIMESTAMPING Patrick Ohly
[not found] ` <1232532612-10382-3-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-21 10:10 ` [PATCH NET-NEXT 04/12] sockets: allow allocating skb with optional structures Patrick Ohly
[not found] ` <1232532612-10382-4-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-21 10:10 ` [PATCH NET-NEXT 05/12] ip: support for TX timestamps on UDP and RAW sockets Patrick Ohly
[not found] ` <1232532612-10382-5-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-21 10:10 ` [PATCH NET-NEXT 06/12] debug: NULL pointer check in ip_output Patrick Ohly
[not found] ` <1232532612-10382-6-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-21 10:10 ` [PATCH NET-NEXT 07/12] net: pass new SIOCSHWTSTAMP through to device drivers Patrick Ohly
[not found] ` <1232532612-10382-7-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-21 10:10 ` [PATCH NET-NEXT 08/12] igb: stub support for SIOCSHWTSTAMP Patrick Ohly
[not found] ` <1232532612-10382-8-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-21 10:10 ` [PATCH NET-NEXT 09/12] clocksource: allow usage independent of timekeeping.c Patrick Ohly
[not found] ` <1232532612-10382-9-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-21 10:10 ` [PATCH NET-NEXT 10/12] igb: access to NIC time Patrick Ohly
2009-01-21 10:10 ` [PATCH NET-NEXT 11/12] time sync: generic infrastructure to map between time stamps generated by a time counter and system time Patrick Ohly
2009-01-21 10:10 ` [PATCH NET-NEXT 12/12] igb: use clocksync to implement hardware time stamping Patrick Ohly
[not found] ` <1232532612-10382-11-git-send-email-patrick.ohly-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2009-01-21 10:33 ` [PATCH NET-NEXT 11/12] time sync: generic infrastructure to map between time stamps generated by a time counter and system time Ingo Molnar
2009-01-21 14:42 ` Patrick Ohly
2009-01-26 5:04 ` hardware time stamping with optional structs in data area David Miller
2009-01-26 20:39 ` Patrick Ohly
2009-01-27 1:22 ` David Miller
2009-01-27 15:23 ` Patrick Ohly
2009-01-28 9:08 ` Herbert Xu
[not found] ` <20090128090821.GA15770-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
2009-01-28 9:52 ` Patrick Ohly
2009-01-28 9:54 ` Herbert Xu
2009-02-01 8:14 ` David Miller
2009-02-04 13:02 ` Patrick Ohly
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1229352899-31330-5-git-send-email-patrick.ohly@intel.com \
--to=patrick.ohly@intel.com \
--cc=davem@davemloft.net \
--cc=johnstul@us.ibm.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).