URN Logo
UNIX Resources » Linux » Linux Forum » Linux Kernel Support » Page.4 » Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
announcement The content of this page is collected from Linux Forum, All copyrights and other associated rights are reserved by the original authors of the articles.
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.com
  LinuxForum General Chat
  Linux Advocacy
  LinuxForum Polls
  Introductions
  Linux Kernel Support
  Patch Management
  Development Release
  Linux Programming
  Linux Security
  Linux Software
  Linux Hardware Problems
    Linux Video Problems
    Linux Sound Problems
  Linux Networking Support
  Linux Printing Support
  Linux Human Interface Devices Support
  Linux Data Storage Support
  Linux Applications Support
  Linux Installation Support
  Linux Laptops Support
  Linux Motherboard, Chipsets, CPU, Memory
  Miscellaneous
  Debian Linux Support
  Ubuntu Linux Support
  LiveCD Discussions
  Gentoo Linux Support
  Mandrake Linux Support
  Redhat / Fedora Linux Support
  Slackware Linux Support
  SuSE Linux Support
  CentOS Linux Support
  Linux Web Servers
  Linux DNS Servers
  Linux Database Servers
  Linux Email Servers
  Linux FTP Servers
  Linux Squid Proxy Server
  Linux Samba Help
  Linux cPanel Help
  Linux Ensim Help
  Linux Plesk Help
  Linux Webmin / Usermin Help
  Qmail Toaster Help
  Linux Games
  Windows Game Emulation
  Linux Discussions
  General Linux Discussions
  Red Hat Linux Discussions
  More Red Hat Linux Discussions
  Mandrake Linux Discussions
  Slackware Linux Discussions
  SuSE Linux Discussions
  Debian Discussions
  Samba Help
  Linux Security
  Linux Networking
  Gentoo Help
  Operating System Rant Forum
  Hardware Rants
   
Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
Subject: Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
Author: sunbirdmoon    Posted: 2006-06-13 01:23:56    Length: 802 byte(s)
[Original] [Print] [Top]
I want to deal with every ipv6 packet passing the net device. So i changed the pointer of the hard_start_xmit(struct sk_buff *skb,struct net_device *dev) to my own function my_function, and in the last of my function I call the original function hard_start_xmit to translate the skb1 which is maked in my function . In my funtion i will make a new sk_buff skb1 base on the skb which comes from the up protocol such as ipv6/ipv4. when i have the done the skb1, i free the original skb,but my computer can`t work and die out. I know the reason is the sentence "kfree_skb(skb);"  . Although i know the reason, i can`t resolve this ,because i must free the skb which came from up protocol . DO you know how to free the skb which came from the up protocol and sent my own skb1??
[Original] [Print] [Top]
Subject: Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
Author: Dhanashekar    Posted: 2006-06-15 06:49:26    Length: 183 byte(s)
[Original] [Print] [Top]
Have you tried using skb_clone ?.  

else

unshare your skb using skb_unshare and try kfree_skb, but that too only
after xmit done.
[Original] [Print] [Top]
Subject: Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
Author: sunbirdmoon    Posted: 2006-06-15 09:01:56    Length: 823 byte(s)
[Original] [Print] [Top]
[div class='quotetop']QUOTE(Dhanashekar @ Jun 15 2006, 06:49 AM) [snapback]765463[/snapback][/div][div class='quotemain']
Have you tried using skb_clone ?.  

else

unshare your skb using skb_unshare and try kfree_skb, but that too only
after xmit done.
[/quote]

Thank you for your help.but the skb1 is kmalloced for a new sk_buff and didn`t generate it by skb_clone().
whether in the system the skb which comes from up layer will be used in the low function or for some interruption in the function??

I am very tied for this question, i have two weeks for dealing with this question but also can`t pass.
how should i do?
[Original] [Print] [Top]
Subject: Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
Author: Dhanashekar    Posted: 2006-06-16 01:15:22    Length: 843 byte(s)
[Original] [Print] [Top]
Hi,
The usual code for hard_start_xmit is like this :

my_hard_start_xmit(...)
{
 malloc new skb - skb_new ;
 unshare the skb - skb_old ;
 process and send the skb_new ;
}

my_xmit_done_process(...)
{
  free the skb;
}

Freeing of the skb is only in the xmit done interrupt routine.
I havent seen any code that frees the skb in the hard_start_xmit.
May be because the skb reference is held until the hard_start_xmit() returns.
If you free the skb in in this place itself then any reference to it upon the function return would lead to a crash.

To exactly debug your code i will want to see your debug/crash message,
You can do this by using serial console, or just using the command line tty.



[Original] [Print] [Top]
Subject: Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
Author: sunbirdmoon    Posted: 2006-06-17 20:26:14    Length: 2,876 byte(s)
[Original] [Print] [Top]
my_hard_start_xmit(...)
{
 malloc new skb - skb_new ;
 unshare the skb - skb_old ;
 process and send the skb_new ;
}

my_xmit_done_process(...)
{
  free the skb;
}



thank you very much for your help. hop you happy everyday. i am very glad for your help.

you said the "free skb" shouldn`t do in the my_hard_start_xmit() function. but i want to free the skb, So where i can do this inorder to free the skb? And which you give me the function my_xmit_done_process() should be where and how to do the interface with the linux kernel? I know that my_hard_start_xmit() function should do likely this :dev->hard_start_xmit=my_hard_start_xmit();But how to do the  function my_xmit_done_process()  ?  
  below is my funtion which is concisied
Code:
br /]int my_hard_start_xmit(struct sk_buff *skb, struct net_device *dev)
{      
 if (skb->protocol !=htons(ETH_P_IPV6))
 goto doneout;
 skb_cm->dev=skb->dev;
 skb_cm->protocol=htons(ETH_P_AAA);
 skb_cm->ip_summed = CHECKSUM_NONE;
 skb_cm->pkt_type = skb->pkt_type;
 skb_cm->priority = skb->priority;
 skb_cm->dst = dst_clone(skb->dst);
 skb_cm->csum = 0;
 skb_put(skb_cm, len);
 skb_cm->mac.raw=skb_cm->data;
 memcpy(skb_cm->mac.raw, skb->mac.raw, ETH_HLEN);
 eth=(struct ethhdr *)skb_cm->mac.raw;
 eth->h_proto=htons(ETH_P_AAA);
 skb_cm->nh.raw=skb_cm->data+ETH_HLEN;
 counter=ETH_HLEN;
 memcpy(skb_cm->nh.raw, (unsigned char *)ip, ntohs(ip->payload_len));
 counter+=(ntohs(ip->payload_len));
 data=skb->data;
 skb_cm->len=counter;
 skb_cm->tail=data+counter;
 
 kfree_skb(skb);  
  
 return dev_p->back_hard_start_xmit(skb_cm, dev);
 doneout:return dev_p->back_hard_start_xmit(skb,dev);
}

  when my computer come to the free_skb() sentence , my computer`s CAPS LOCK and SCROLL LOCK light  glitter for all the time and i can`t do anything and my computer is died, there is nothing in my consol  so I must reboot it.  
  I have study linux not long ,so some debug tools don`t know a lot.i ususally used printk() to find the debug and this is very slowly. Can you commend a tool for LKM programe test?
[Original] [Print] [Top]
Subject: Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
Author: sunbirdmoon    Posted: 2006-06-20 01:10:37    Length: 291 byte(s)
[Original] [Print] [Top]
Hi, can you tell me the function my_xmit_done_process() where can i put??
 I know that my_hard_start_xmit() function should do likely this :dev->hard_start_xmit=my_hard_start_xmit();But how to do the function my_xmit_done_process() ?
below is my funtion which is concisied
[Original] [Print] [Top]
Subject: Hi,everyone, How To Deal With Freeing Sk_buff In Hard_start_xmit() Fun
Author: Dhanashekar    Posted: 2006-06-20 03:54:04    Length: 1,081 byte(s)
[Original] [Print] [Top]
[div class='quotetop']QUOTE[/div][div class='quotemain']
....
 counter+=(ntohs(ip->payload_len));
data=skb->data;
skb_cm->len=counter;
skb_cm->tail=data+counter;

kfree_skb(skb);  -> Wrong Sequence
 
return dev_p->back_hard_start_xmit(skb_cm, dev);

what is dev_p ? Is this net_dev ? if so then what is back_hard_start_xmit ?


doneout:return dev_p->back_hard_start_xmit(skb,dev);
}
 [/quote]

my_xmit_done_process is my own function which is basically called by interrupt(Transmit Done)
you can Ref e100_main.c interrupt handler from linux source or any network drivers

[div class='quotetop']QUOTE[/div][div class='quotemain']
/* clean up after tx'ed packets */
   if (intr_status & (SCB_STATUS_ACK_CNA | SCB_STATUS_ACK_CX)) {
      e100_tx_srv(bdp);
   }
[/quote]
[Original] [Print] [Top]
« Previous thread
Hi.....i Have A Question Regarding Linux's General Working....
Linux Kernel Support
Page. 4
Next thread »
Modules Or Kernel Component
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
Powered by FreeBSD    webmaster: webmaster@unixresources.net
This page created on 2007-08-01 11:42:53, cost 0.042279005050659 ms.