DPDK patches and discussions
 help / color / mirror / Atom feed
From: Don Provan <dprovan@bivio.net>
To: Stephen Hemminger <stephen@networkplumber.org>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] eth_dev: make ether dev_ops const
Date: Tue, 7 Apr 2015 17:21:37 +0000	[thread overview]
Message-ID: <CY1PR0101MB0987C29CCC2BC22B33C77A5AA0FD0@CY1PR0101MB0987.prod.exchangelabs.com> (raw)
In-Reply-To: <1428343496-26532-1-git-send-email-stephen@networkplumber.org>

-----Original Message-----
>From: Stephen Hemminger [mailto:stephen@networkplumber.org] 
>Sent: Monday, April 06, 2015 11:05 AM
>To: dev@dpdk.org
>Subject: [dpdk-dev] [PATCH] eth_dev: make ether dev_ops const
>
>Ethernet device function tables should be immutable for correctness and security. Special case for the test code driver.
...
>diff --git a/app/test/virtual_pmd.c b/app/test/virtual_pmd.c index f163562..f579558 100644
>--- a/app/test/virtual_pmd.c
>+++ b/app/test/virtual_pmd.c
...
>+/* This driver uses private mutable eth_dev_ops for each
>+ * instance so it is safe to override const here.
>+ */
>+#pragma GCC diagnostic push
>+#pragma GCC diagnostic ignored "-Wcast-qual"
> void
> virtual_ethdev_start_fn_set_success(uint8_t port_id, uint8_t success)  {
> 	struct rte_eth_dev *vrtl_eth_dev = &rte_eth_devices[port_id];
>+	struct eth_dev_ops *dev_ops
>+		= (struct eth_dev_ops *) vrtl_eth_dev->dev_ops;
 ...

If this is really safe, then you should be able to accomplish it
without disabling a bunch of protection. I suggest adding a
pointer that isn't const to the private data block and adjusting
the allocated dispatch table through that instead of through
the pointer to the immutable dispatch table you've established
in struct rte_eth_dev. That reinforces the fact that modifying
the dispatch table is a private matter within the driver while
showing structurally exactly why it's safe to change it.

And it's not nearly so ugly.

-don provan
dprovan@bivio.net

  reply	other threads:[~2015-04-07 17:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-06 18:04 Stephen Hemminger
2015-04-07 17:21 ` Don Provan [this message]
2015-04-07 18:46   ` Stephen Hemminger
2015-04-08  5:45     ` [dpdk-dev] working with pthreads and Processes in parallel Nissim Nisimov

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=CY1PR0101MB0987C29CCC2BC22B33C77A5AA0FD0@CY1PR0101MB0987.prod.exchangelabs.com \
    --to=dprovan@bivio.net \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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;
as well as URLs for NNTP newsgroup(s).