2004-06-04 00:22:44

by Sharma Sushant

[permalink] [raw]
Subject: modifying struct sk_buff

Hi
I want to add a new member (say uint32_t) in the
struct sk_buff{...}
in the file include/linux/skbuff.h.

If i add this new member and I want to assign it
some value when ever function
struct sk_buff *alloc_skb(unsigned int *size,* int gfp_mask)
in file
net/core/skbuff.c
is called
Do I need to allocate memory for this member
( ie add sizeof(_new-member_) to *size* while doing kmalloc() )
or I should not worry abt that and I can assign some value
to this _new-member_ every time this function is called.

Thanks
Sushant


2004-06-04 12:37:07

by Bart Trojanowski

[permalink] [raw]
Subject: Re: modifying struct sk_buff

* Sushant Sharma <[email protected]> [040603 20:24]:
> Hi
> I want to add a new member (say uint32_t) in the
> struct sk_buff{...}
> in the file include/linux/skbuff.h.
<snip>
> Do I need to allocate memory for this member
> ( ie add sizeof(_new-member_) to *size* while doing kmalloc() )

Hi Sushant,

I think you are confusing the allocation of 'data' with the allocation
of 'skb'.

If you add the uint32_t to struct sk_buff you don't have to modify
alloc_skb. The skbuff_head_cache is informed what size the sk_buff
structure is in skb_init().

-Bart

--
WebSig: http://www.jukie.net/~bart/sig/


Attachments:
(No filename) (607.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments

2004-06-04 18:50:15

by Sharma Sushant

[permalink] [raw]
Subject: Re: modifying struct sk_buff


Hi Bart
thanks for replying.
I was thinking functions calling the alloc_skb will not
consider the size of new variable which I will add, thats
why I thought of adding the size my self while allocating
space.

I am using kernel 2.6.3 and here are few line from skbuff.h

> /*
> * This is the control buffer. It is free to use for every
> * layer. Please put your private variables there. If you
> * want to keep them across layers you have to do a skb_clone()
> * first. This is owned by whoever has the skb queued ATM.
> */
> uint32_t skBufId; /* by sushant */
> char cb[48];

skBufId is the variable i added and I want to assign unique value
to this id whenever alloc_skb is called.
Do you think it will be fine to modify alloc_skb(..)
and just assigning a unique value to this new variable which I added
or will there be some side effects of this.

Thanks
Sushant





On Fri, 4 Jun 2004, Bart Trojanowski wrote:

> * Sushant Sharma <[email protected]> [040603 20:24]:
> > Hi
> > I want to add a new member (say uint32_t) in the
> > struct sk_buff{...}
> > in the file include/linux/skbuff.h.
> <snip>
> > Do I need to allocate memory for this member
> > ( ie add sizeof(_new-member_) to *size* while doing kmalloc() )
>
> Hi Sushant,
>
> I think you are confusing the allocation of 'data' with the allocation
> of 'skb'.
>
> If you add the uint32_t to struct sk_buff you don't have to modify
> alloc_skb. The skbuff_head_cache is informed what size the sk_buff
> structure is in skb_init().
>
> -Bart
>
> --
> WebSig: http://www.jukie.net/~bart/sig/
>

2004-06-04 20:05:35

by Bart Trojanowski

[permalink] [raw]
Subject: Re: modifying struct sk_buff

* Sharma Sushant <[email protected]> [040604 14:48]:
> > uint32_t skBufId; /* by sushant */
> > char cb[48];
>
> skBufId is the variable i added and I want to assign unique value
> to this id whenever alloc_skb is called.
> Do you think it will be fine to modify alloc_skb(..)
> and just assigning a unique value to this new variable which I added
> or will there be some side effects of this.

Looks like you can start using skBufId anytime after memset(skb, ...)
call. I didn't look at the version of the sources you are using. In
2.4.7-rc2 it looks fine.

-Bart

--
WebSig: http://www.jukie.net/~bart/sig/


Attachments:
(No filename) (666.00 B)
signature.asc (189.00 B)
Digital signature
Download all attachments