On Mon, May 10, 2004 at 11:27:49AM -0000, bunty wrote: > > hi, > In skbuff discussion i placed question about where exactly kernel > allocates space for data and all headers. at that time i got very goos respone > but still i unable to locate it. what i want to know where kernel allocates > space for whole packet? Is there any call to alloc_skb in kernel source dir > that does it? if not how kernel knows packet size so that he can create > outgoing packet? > You can find all calls to alloc_skb by going to the top of your kernel tree and doing grep -rsn alloc_skb . As far as I recall things, socket creates a file descriptor for the protocol you requested (which should be linked to the appropriate protocol stack) When you write to that protocol the kernel goes to the interface for that file descriptor to do the actual writing. The tcp interface in this case should in turn at some point break up your data into packets based on the mtu and header size and this is what is supposed to allocated the skbuffs. You should start with the write system call and follow the bread crumbs. kdb or kgdb could help you there. grepping for tcp_alloc_skb results with /net/ipv4/tcp_output.c:433: buff = tcp_alloc_skb(sk, nsize, GFP_ATOMIC); alloc_skb that look relevant to the tcp stack: net/ipv4/tcp_input.c:3161: nskb = alloc_skb(copy+header, GFP_ATOMIC); net/ipv4/tcp_diag.c:238: rep = alloc_skb(NLMSG_SPACE(sizeof(struct tcpdiagmsg)+ net/ipv4/tcp_output.c:1010: skb = alloc_skb(MAX_TCP_HEADER, GFP_KERNEL); net/ipv4/tcp_output.c:1041: skb = alloc_skb(MAX_TCP_HEADER, priority); net/ipv4/tcp_output.c:1219: buff = alloc_skb(MAX_TCP_HEADER + 15, sk->allocation); net/ipv4/tcp_output.c:1315: buff = alloc_skb(MAX_TCP_HEADER, GFP_ATOMIC); net/ipv4/tcp_output.c:1353: skb = alloc_skb(MAX_TCP_HEADER, GFP_ATOMIC); I don't know if the tcp stack also allocates skbbuffs with a different method or in a different place. Incoming skbuffs are allocated at the driver level, but they are probably irrelevant to you. > regards, > parag. > > > >-- > >Kernelnewbies: Help each other learn about the Linux kernel. > >Archive: http://mail.nl.linux.org/kernelnewbies/ > >FAQ: http://kernelnewbies.org/faq/ > > > > > _[_h_t_t_p_:_/_/_a_d_s_._r_e_d_i_f_f_._c_o_m_/_R_e_a_l_M_e_d_i_a_/_a_d_s_/_a_d_s_t_r_e_a_m___n_x_._c_g_i_/_w_w_w_._r_e_d_i_f_f_m_a_i_l_._c_o_m_/ > _i_n_b_o_x_._h_t_m_@_B_o_t_t_o_m_] > +++++++++++++++++++++++++++++++++++++++++++ > This Mail Was Scanned By Mail-seCure System > at the Tel-Aviv University CC. -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/