From: Eric Dumazet <eric.dumazet@gmail.com>
To: Daniel Turull <daniel.turull@gmail.com>
Cc: netdev@vger.kernel.org, robert@herjulf.net, jens.laas@its.uu.se
Subject: Re: [PATCH 2/2] pktgen: receive packets and process incoming rate
Date: Wed, 02 Jun 2010 15:00:50 +0200 [thread overview]
Message-ID: <1275483650.2725.173.camel@edumazet-laptop> (raw)
In-Reply-To: <4C06453B.1080801@gmail.com>
Le mercredi 02 juin 2010 à 13:49 +0200, Daniel Turull a écrit :
> This patch adds receiver part to pktgen taking advantages of SMP systems
> with multiple rx queues:
> - Creation of new proc file /proc/net/pktgen/pgrx to control and display the receiver.
> - It uses PER-CPU variable to store the results per each CPU.
> - Results displayed per CPU and aggregated.
> - The packet handler is add in the protocols handlers (dev_Add_pack())
> - Available statistics: packets and bytes received, work time and rate
> - Only process pktgen packets
> - It is possible to select the incoming interface
> - Documentation updated with the new commands to control the receiver part.
>
Interesting, but does it belongs to pktgen ?
other comments included :)
> Signed-off-by: Daniel Turull <daniel.turull@gmail.com>
>
>
> +/*Recevier parameters per cpu*/
> +struct pktgen_rx {
> + u64 rx_packets; /*packets arrived*/
unsigned long rx_packets ?
> + u64 rx_bytes; /*bytes arrived*/
> +
> + ktime_t start_time; /*first time stamp of a packet*/
> + ktime_t last_time; /*last packet arrival */
> +};
> +int pktgen_rcv_basic(struct sk_buff *skb, struct net_device *dev,
> + struct packet_type *pt, struct net_device *orig_dev)
> +{
> + /* Check magic*/
> + struct iphdr *iph = ip_hdr(skb);
> + struct pktgen_hdr *pgh;
> + void *vaddr;
Following code is ... well ... interesting... But ...
1) Is it IPV6 compatable ? pktgen can be ipv6 or ipv4
2) Is it resistant to malicious packets ? (very small ones)
3) No checksum ?
I think you should use standard mechanisms... (pskb_may_pull(), ...)
Take a look at __netpoll_rx() for an example.
> + if (skb_is_nonlinear(skb)) {
> + vaddr = kmap_skb_frag(&skb_shinfo(skb)->frags[0]);
> + pgh = (struct pktgen_hdr *)
> + (vaddr+skb_shinfo(skb)->frags[0].page_offset);
> + } else {
> + pgh = (struct pktgen_hdr *)(((char *)(iph)) + 28);
> + }
> +
> + if (unlikely(pgh->pgh_magic != PKTGEN_MAGIC_NET))
> + goto end;
> +
> + if (unlikely(!__get_cpu_var(pktgen_rx_data).rx_packets))
> + __get_cpu_var(pktgen_rx_data).start_time = ktime_now();
> +
> + __get_cpu_var(pktgen_rx_data).last_time = ktime_now();
> +
Its a bit suboptimal to use __get_cpu_var several time. Take a look at
disassembly code :)
Use a pointer instead
> + /* Update counter of packets*/
> + __get_cpu_var(pktgen_rx_data).rx_packets++;
> + __get_cpu_var(pktgen_rx_data).rx_bytes += skb->len+14;
This +14 seems suspect (what about vlan tags ?)
Use ETH_HLEN instead at a very minimum?
> +end:
> + if (skb_is_nonlinear(skb))
> + kunmap_skb_frag(vaddr);
Should not recognised packets be allowed to flight in other parts of
kernel stack ? This way, we could use ssh to remotely control this
pktgen session ;)
> + kfree_skb(skb);
> + return 0;
> +}
> +
next prev parent reply other threads:[~2010-06-04 20:55 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-02 11:49 [PATCH 2/2] pktgen: receive packets and process incoming rate Daniel Turull
2010-06-02 13:00 ` Eric Dumazet [this message]
2010-06-02 13:28 ` Daniel Turull
2010-06-10 14:04 ` Daniel Turull
2010-06-10 14:05 ` Daniel Turull
2010-06-15 21:59 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1275483650.2725.173.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=daniel.turull@gmail.com \
--cc=jens.laas@its.uu.se \
--cc=netdev@vger.kernel.org \
--cc=robert@herjulf.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox