* how ip header added in ip_bulid_xmit function?
@ 2004-05-18 6:31 linux lover
2004-05-18 14:23 ` Manu Garg
0 siblings, 1 reply; 9+ messages in thread
From: linux lover @ 2004-05-18 6:31 UTC (permalink / raw)
To: linuxnet; +Cc: netdev, netfilter
hello ,
In ip_output.c file there is ip_build_xmit function
call. when packet comes from tcp layer to IP layer
this function is called. In that i found that
skb = sock_alloc_send_skb(sk, length+hh_len+15
,flags&MSG_DONTWAIT, &err);
staement allocates skb for packet. after that i found
that no iphdr adding statement in ip_build_xmit. i
want to know where is iphdr push to skb? cause skb
works using first alloc_skb to allocate memory then
skb_reserve to reserve headroom then put data in skb
by skb_put or skb_push for pushing headers in skb. so
there i found
skb->nh.iph = iph = (struct iphdr *)skb_put(skb,
length);
statement is this does that iphdr adding?
regards,
linuxlover
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: how ip header added in ip_bulid_xmit function?
2004-05-18 6:31 how ip header added in ip_bulid_xmit function? linux lover
@ 2004-05-18 14:23 ` Manu Garg
2004-05-19 6:20 ` linux lover
0 siblings, 1 reply; 9+ messages in thread
From: Manu Garg @ 2004-05-18 14:23 UTC (permalink / raw)
To: linux lover; +Cc: linuxnet, netdev, netfilter
linux lover wrote:
>hello ,
> In ip_output.c file there is ip_build_xmit function
>call. when packet comes from tcp layer to IP layer
>this function is called. In that i found that
> skb = sock_alloc_send_skb(sk, length+hh_len+15
>,flags&MSG_DONTWAIT, &err);
>staement allocates skb for packet. after that i found
>that no iphdr adding statement in ip_build_xmit. i
>want to know where is iphdr push to skb? cause skb
>works using first alloc_skb to allocate memory then
>skb_reserve to reserve headroom then put data in skb
>by skb_put or skb_push for pushing headers in skb. so
>there i found
> skb->nh.iph = iph = (struct iphdr *)skb_put(skb,
>length);
>statement is this does that iphdr adding?
>
>regards,
>linuxlover
>
>
>
>
>__________________________________
>Do you Yahoo!?
>SBC Yahoo! - Internet access at a great low price.
>http://promo.yahoo.com/sbc/
>-
>To unsubscribe from this list: send the line "unsubscribe linux-net" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at http://vger.kernel.org/majordomo-info.html
>
>
>
A packet comes from TCP layer to IP layer through function call
tp->af_specific->queue_xmit() (in tcp_output.c:tcp_transmit_skb() ). For
IP this function is nothing but ip_queue_xmit() defined in
ip_output.c.
If you'll check this function, it clearly allocates ip header and put
information in it.
----------------------------------------------------
iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ?
opt->optlen : 0));
*((__u16 *)iph) = htons((4 << 12) | (5 << 8) |
(sk->protinfo.af_inet.tos & 0xff));
iph->tot_len = htons(skb->len);
if (ip_dont_fragment(sk, &rt->u.dst))
iph->frag_off = htons(IP_DF);
else
iph->frag_off = 0;
iph->ttl = sk->protinfo.af_inet.ttl;
iph->protocol = sk->protocol;
iph->saddr = rt->rt_src;
iph->daddr = rt->rt_dst;
skb->nh.iph = iph;
---------------------------------------------------
I hope this answers your question.
regards,
Manu Garg
http://manugarg.freezope.org/notes
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: how ip header added in ip_bulid_xmit function?
2004-05-18 14:23 ` Manu Garg
@ 2004-05-19 6:20 ` linux lover
2004-05-24 18:49 ` Mmap problem (VM_DENYWRITE) shanthi kiran pendyala
0 siblings, 1 reply; 9+ messages in thread
From: linux lover @ 2004-05-19 6:20 UTC (permalink / raw)
To: Manu Garg; +Cc: linuxnet, netdev, netfilter
hello,
> A packet comes from TCP layer to IP layer through
> function call
> tp->af_specific->queue_xmit() (in
> tcp_output.c:tcp_transmit_skb() ). For
> IP this function is nothing but ip_queue_xmit()
> defined in ip_output.c.
>
then why ip_build_xmit and ip_build_xmit_slow used?
i think in case of ICMP packet control in icmp.c
alwayes goes to ip_build_xmit?
regards,
linux_lover
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/
^ permalink raw reply [flat|nested] 9+ messages in thread
* Mmap problem (VM_DENYWRITE)
2004-05-19 6:20 ` linux lover
@ 2004-05-24 18:49 ` shanthi kiran pendyala
2004-05-24 18:58 ` Tommy Reynolds
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: shanthi kiran pendyala @ 2004-05-24 18:49 UTC (permalink / raw)
To: linux-kernel
Hi,
<<I am not subscribed to this list b'cos of the volume of emails. Please
include my email in the reply.>>
I am writing a device driver for a fpga device.
I implemented a dummy char device to gain user space access to the device
registers thru mmap.
The kernel is 2.4.18.
The CPU is sibyte (mips64 cpu) with 40 bits of physical addressing and 44
bits of virtual addressing.
After mmaping in userspace any writes to the mmap region is not working.
I think it is b'cos of the protection field in the vma is set to
VM_DENYWRITE.
The complete prot flag is (VM_READ | VM_WRITE | VM_EXEC | VM_GROWSUP |
VM_DENYWRITE)
Why is this happening? I need to have both read and write access to region.
How do I fix this ?
Thanks for you help
Shanthi kiran
Output after running test program
=================================
building page tables for va 0x2aac5000 phy 0x10940000
vsize 0x20000 psize 0x20000 prot 0xa07
===================================================================
My mmap implementation is as follow
#define FPGA_CSR_ADDR_START 0x10940000
#define FPGA_CSR_ADDR_END 0x1095ffff
#define MMAP_SIZE (FPGA_CSR_ADDR_END + 1 - FPGA_CSR_ADDR_START)
int
fpga_mmap(struct file *filp, struct vm_area_struct *vma) {
unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
unsigned long vsize = vma->vm_end - vma->vm_start;
unsigned long phys = FPGA_CSR_ADDR_START + offset;
unsigned long psize = MMAP_SIZE - offset;
if(vsize > psize)
return -EINVAL;
printk("<1> building page tables for va 0x%lx phy 0x%lx \n",
vma->vm_start, phys);
printk("<1> vsize 0x%lx psize 0x%lx prot 0x%lx\n",
vsize, psize, vma->vm_page_prot.pgprot);
/* build new page tables */
if (remap_page_range(vma->vm_start, phys, vsize, vma->vm_page_prot))
return -EAGAIN;
return 0;
}
================================================================
I try to access to the device memory region with this user space test
program
....
fpga_fd = open(FPGA_DEV_FILE_NAME, O_RDWR);
if(cde_fd < 0) {
printf("can't open %s err %d\n", FPGA_DEV_FILE_NAME, fpga_fd);
goto finish;
}
offset = 0;
fpga_csr_start = mmap(0, MMAP_SIZE,
PROT_READ|PROT_WRITE, MAP_SHARED,
fpga_fd, offset);
if (fpga_csr_start < 0 ) {
printf(" error in mmap errno %d", errno);
goto finish;
}
...
============================================================================
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Mmap problem (VM_DENYWRITE)
2004-05-24 18:49 ` Mmap problem (VM_DENYWRITE) shanthi kiran pendyala
@ 2004-05-24 18:58 ` Tommy Reynolds
2004-05-24 20:22 ` Richard B. Johnson
2004-05-24 20:29 ` Chris Wright
2 siblings, 0 replies; 9+ messages in thread
From: Tommy Reynolds @ 2004-05-24 18:58 UTC (permalink / raw)
To: shanthi kiran pendyala; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 650 bytes --]
Uttered "shanthi kiran pendyala" <skiranp@cisco.com>, spake thus:
> After mmaping in userspace any writes to the mmap region is not working.
> I think it is b'cos of the protection field in the vma is set to
> VM_DENYWRITE.
> The complete prot flag is (VM_READ | VM_WRITE | VM_EXEC | VM_GROWSUP |
> VM_DENYWRITE)
>
> Why is this happening? I need to have both read and write access to region.
> How do I fix this ?
Take out the VM_DENYWRITE flag. Duh.
Are you gonna put code in the mapped area? No? Turn off VM_EXEC.
Are you gonna place your stack in the mapped area? No? Turn of
VM_GROWSUP.
Have you read "man mmap"? No? Try it.
Cheers!
[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: Mmap problem (VM_DENYWRITE)
2004-05-24 18:49 ` Mmap problem (VM_DENYWRITE) shanthi kiran pendyala
2004-05-24 18:58 ` Tommy Reynolds
@ 2004-05-24 20:22 ` Richard B. Johnson
2004-05-24 20:29 ` Chris Wright
2 siblings, 0 replies; 9+ messages in thread
From: Richard B. Johnson @ 2004-05-24 20:22 UTC (permalink / raw)
To: shanthi kiran pendyala; +Cc: linux-kernel
On Mon, 24 May 2004, shanthi kiran pendyala wrote:
> Hi,
>
> <<I am not subscribed to this list b'cos of the volume of emails. Please
> include my email in the reply.>>
>
> ===================================================================
> My mmap implementation is as follow
Can't you just use ioremap_nocache(FPGA_CSR_ADDR_START, MMAP_SIZE);
>
> #define FPGA_CSR_ADDR_START 0x10940000
> #define FPGA_CSR_ADDR_END 0x1095ffff
> #define MMAP_SIZE (FPGA_CSR_ADDR_END + 1 - FPGA_CSR_ADDR_START)
>
> }
> ================================================================
> I try to access to the device memory region with this user space test
> program
> ....
> fpga_fd = open("/dev/mem", O_RDWR);
If you want to get the physical address from your driver, just
make an ioctl() to return it. In the meantime, mmap() with this
fd.
>
> if(cde_fd < 0) {
> printf("can't open %s err %d\n", FPGA_DEV_FILE_NAME, fpga_fd);
> goto finish;
> }
>
> hint = 0x10000000;
> fpga_csr_start = mmap(hint, MMAP_SIZE,
> PROT_READ|PROT_WRITE, MAP_SHARED|MAP_FIXED,
> fpga_fd, FPGA_CSR_ADDR_START);
>
> if (fpga_csr_start == (void *)-1 ) {
|_______________ Read docs, don't assume!!
> printf(" error in mmap errno %d", errno);
> goto finish;
> }
close(fpga_fd); // Not needed anymore
>
> ...
> ============================================================================
>
Cheers,
Dick Johnson
Penguin : Linux version 2.4.26 on an i686 machine (5570.56 BogoMips).
Note 96.31% of all statistics are fiction.
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: Mmap problem (VM_DENYWRITE)
2004-05-24 18:49 ` Mmap problem (VM_DENYWRITE) shanthi kiran pendyala
2004-05-24 18:58 ` Tommy Reynolds
2004-05-24 20:22 ` Richard B. Johnson
@ 2004-05-24 20:29 ` Chris Wright
2 siblings, 0 replies; 9+ messages in thread
From: Chris Wright @ 2004-05-24 20:29 UTC (permalink / raw)
To: shanthi kiran pendyala; +Cc: linux-kernel
* shanthi kiran pendyala (skiranp@cisco.com) wrote:
> The complete prot flag is (VM_READ | VM_WRITE | VM_EXEC | VM_GROWSUP |
> VM_DENYWRITE)
[snip]
> Output after running test program
> =================================
> building page tables for va 0x2aac5000 phy 0x10940000
> vsize 0x20000 psize 0x20000 prot 0xa07
>
[snip]
> printk("<1> vsize 0x%lx psize 0x%lx prot 0x%lx\n",
> vsize, psize, vma->vm_page_prot.pgprot);
I believe you've drawn the wrong conclusion. This contains page
protection bits relevant for the page tables. You've decoded
vm_page_prot as if it were vm_flags.
thanks,
-chris
--
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net
^ permalink raw reply [flat|nested] 9+ messages in thread
* RE: how ip header added in ip_bulid_xmit function?
@ 2004-05-19 6:27 Galy Lee
2004-05-19 10:36 ` linux lover
0 siblings, 1 reply; 9+ messages in thread
From: Galy Lee @ 2004-05-19 6:27 UTC (permalink / raw)
To: linux lover; +Cc: linuxnet, netdev, netfilter
[-- Attachment #1: Type: text/plain, Size: 918 bytes --]
It seems that ip_build_xmit_slow is used to send to bulk data, but the
ip_build_xmit is used to send single data packet.
-----Original Message-----
From: netdev-bounce@oss.sgi.com [mailto:netdev-bounce@oss.sgi.com]On
Behalf Of linux lover
Sent: Wednesday, May 19, 2004 2:21 PM
To: Manu Garg
Cc: linuxnet; netdev; netfilter
Subject: Re: how ip header added in ip_bulid_xmit function?
hello,
> A packet comes from TCP layer to IP layer through
> function call
> tp->af_specific->queue_xmit() (in
> tcp_output.c:tcp_transmit_skb() ). For
> IP this function is nothing but ip_queue_xmit()
> defined in ip_output.c.
>
then why ip_build_xmit and ip_build_xmit_slow used?
i think in case of ICMP packet control in icmp.c
alwayes goes to ip_build_xmit?
regards,
linux_lover
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/
[-- Attachment #2: Type: text/html, Size: 2210 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-05-24 20:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-05-18 6:31 how ip header added in ip_bulid_xmit function? linux lover
2004-05-18 14:23 ` Manu Garg
2004-05-19 6:20 ` linux lover
2004-05-24 18:49 ` Mmap problem (VM_DENYWRITE) shanthi kiran pendyala
2004-05-24 18:58 ` Tommy Reynolds
2004-05-24 20:22 ` Richard B. Johnson
2004-05-24 20:29 ` Chris Wright
-- strict thread matches above, loose matches on Subject: below --
2004-05-19 6:27 how ip header added in ip_bulid_xmit function? Galy Lee
2004-05-19 10:36 ` linux lover
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.