netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@redhat.com>
To: Joonwoo Park <joonwpark81@gmail.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH 1/3] [LLC]: skb allocation size for responses
Date: Sat, 29 Mar 2008 09:02:23 -0300	[thread overview]
Message-ID: <20080329120223.GZ14945@ghostprotocols.net> (raw)
In-Reply-To: <20080329060655.GA15023@tp64>

Em Sat, Mar 29, 2008 at 03:06:55PM +0900, Joonwoo Park escreveu:
> On Fri, Mar 28, 2008 at 10:12:02AM -0300, Arnaldo Carvalho de Melo wrote:
> > 
> > > +static int llc_mac_header_len(unsigned short devtype)
> > > +{
> > > +	switch (devtype) {
> > > +	case ARPHRD_ETHER:
> > > +	case ARPHRD_LOOPBACK:
> > > +		return sizeof(struct ethhdr);
> > > +	}
> > > +
> > > +	return __llc_tr_mac_header_len(devtype);
> > > +}
> > 
> > Nah, just drop __llc_tr_mac_header_len altogether and have another case
> > entry for ARPHDR_IEEE802_TR.
> > 
> > >  /**
> > >   *	llc_alloc_frame - allocates sk_buff for frame
> > >   *	@dev: network device this skb will be sent over
> > > + *	@type: pdu type to allocate
> > > + *	@data_size: data size to allocate
> > >   *
> > >   *	Allocates an sk_buff for frame and initializes sk_buff fields.
> > >   *	Returns allocated skb or %NULL when out of memory.
> > >   */
> > > -struct sk_buff *llc_alloc_frame(struct sock *sk, struct net_device *dev)
> > > +struct sk_buff *llc_alloc_frame(struct sock *sk, struct net_device *dev,
> > > +				u8 type, u32 data_size)
> > >  {
> > > -	struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC);
> > > +	int hlen = type == LLC_PDU_TYPE_U ? 3 : 4;
> > > +	struct sk_buff *skb;
> > > +
> > > +	hlen += llc_mac_header_len(dev->type);
> > > +	skb = alloc_skb(hlen + data_size, GFP_ATOMIC);
> > >  
> > >  	if (skb) {
> > >  		skb_reset_mac_header(skb);
> > > -		skb_reserve(skb, 50);
> > > +		skb_reserve(skb, hlen);
> > 
> > Well done, now it is better documented (LLC_PDU_TYPE_U passed) and uses
> > less memory, no more magic numbers, good.
> > 
> > - Arnaldo
> 
> 
> I've respined the patch, thanks Arnaldo.
> 
> ---
> [LLC]: skb allocation size for responses
> 
> Allocate the skb for llc responses with the received packet size by
> using the size adjustable llc_frame_alloc.
> Don't allocate useless extra payload.
> Cleanup magic numbers.
> 
> So, this fixes oops.
> Reported by Jim Westfall:
> kernel: skb_over_panic: text:c0541fc7 len:1000 put:997 head:c166ac00 data:c166ac2f tail:0xc166b017 end:0xc166ac80 dev:eth0
> kernel: ------------[ cut here ]------------
> kernel: kernel BUG at net/core/skbuff.c:95!

Perfect, thanks a lot:

Acked-by: Arnaldo Carvalho de Melo <acme@redhat.com>

- Arnaldo

  reply	other threads:[~2008-03-29 12:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1206691159-10872-1-git-send-email-joonwpark81@gmail.com>
2008-03-28 13:12 ` [PATCH 1/3] [LLC]: skb allocation size for responses Arnaldo Carvalho de Melo
2008-03-29  6:06   ` Joonwoo Park
2008-03-29 12:02     ` Arnaldo Carvalho de Melo [this message]
2008-04-01  2:27       ` David Miller
2008-04-01  3:45         ` Joonwoo Park
2008-04-01  4:06           ` David Miller
     [not found] <47e76779.0f98600a.36ef.ffff9c13@mx.google.com>
2008-03-24 17:16 ` Arnaldo Carvalho de Melo
2008-03-25  5:15   ` Joonwoo Park

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=20080329120223.GZ14945@ghostprotocols.net \
    --to=acme@redhat.com \
    --cc=davem@davemloft.net \
    --cc=joonwpark81@gmail.com \
    --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).