Re: [mpls-linux-general] regarding sk_buff structure....
Status: Beta
Brought to you by:
jleu
From: Abhijit G. <gab...@ee...> - 2002-01-09 03:41:36
|
If you want to send the packet to user-space application, mpls_sendmsg is perhaps not the way you shd to it. Well what i think is happening is (its most likely like that, i m not sure) mpls_sendmsg or subsequent calls from it (if any) are refering to skb->dev or skb->dst somewhere. And its likely that these are not set properly. Also you can have a look at the sources of tun-tap device in drivers/net/ to check how to send packets to userspace. (Excellent stuff! I have seen so far). hth -abhijit vvk...@hs... wrote : > > >Hi Experts ! > > I have come across with one problem that , i want to get the packet and >send it to an application , >running in user space .......... My objective is to get the SHIM ,src,dest >address and packet data ........ > > I am following style.......................of code. > >#define MPLS_MAX_BUFF_SIZE 1500 >#define MPLS_MAX_DATA_SIZE 1500 - 4* sizeof ( unsigned long ) -1 > >int mpls_get_packet_data( struct sk_buff *skb, unsigned long shim, > int type ) >{ > char *fname="mpls_get_packet_data"; > mpls_info_t *buff=NULL; > > printk(KERN_ALERT"%s : entering .....\n",fname); > > buff=(mpls_info_t *)kmalloc(sizeof(mpls_info_t), GFP_KERNEL); > if ( buff == NULL ) > { > printk(KERN_ALERT"%s: kmalloc error",fname); > return -ENOMEM; > } > > if ( skb == NULL ) > { > printk(KERN_ALERT"%s: skb NULL argument error",fname); > kfree(buff); > return -EINVAL; > } > > /* Now get the "src", "fec ..i.e dest address", > * "data" from sk_buff structure ......... > * Fill it in the "mpls_info_t" structure... > * and place the msg in the queue ....... > */ > > > buff->type = type; /* Label Type ...IN or OUT Label */ > buff->shim = shim; /* fill the SHIM info .......*/ > buff->src = skb->nh.iph->saddr; /* src address from sk_buff */ > buff->fec = skb->nh.iph->daddr; /* dest address from sk_buff */ > memset(buff->data, 0, MPLS_MAX_DATA_SIZE-1); > > if ( skb->data != NULL ) > { > printk(KERN_ALERT"%s: skb data length [%d]\n",fname,skb->len); > memcpy(buff->data, skb->data, skb->len); > } > > return mpls_sendmsg(buff, MPLS_MAX_BUFF_SIZE); > } > >This function i am calling in the "mpls_output2" function in the file : " >mpls_output.c" file of mpls >src for kinux............ > >here problem is ......... after some time kernel panic msg arriving and >system is hanging up .... >no response ............ Error is : invalid operand : 00000 > >Is the way i am following is correct or not ? >Can you please guide me , how to retrieve the data............from "sk_buff" >structure ...............? > >Please guide me in this .............. > >I am following the Linux Device Drivers book by oerilly .. by alessandro >rubini............ > >Thanks in advance........ >Regards,Ramki kvv. > >Hughes Software Systems |