DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Ray Kinsella <mdr@ashroe.eu>
Cc: dev@dpdk.org
Subject: [dpdk-dev] RFC - adding filter to packet capture API
Date: Fri, 6 Dec 2019 14:11:14 -0800	[thread overview]
Message-ID: <20191206141114.6b7d6d60@hermes.lan> (raw)

In the process of updating packet capture to take a filter program, there
is one open question about API/ABI.

The example is:

int
rte_pdump_enable(uint16_t port, uint16_t queue, uint32_t flags,
		struct rte_ring *ring,
		struct rte_mempool *mp,
		void *filter);

For the new version want to add ability to pass a BPF (classic) program
from libcap. This is described in most pcap API's as "struct bpf_program".

The filter parameter was left as a placeholder, but in typical YAGNI
fashion. When we do need to use it, it is not going to work out.

Since the existing filter argument was never used, there are a bunch
of options (in order from best to worse).

1. Introduce new API which takes a filter. 

int
rte_pdump_enable_bpf(uint16_t port, uint16_t queue, uint32_t flags,
		struct rte_ring *ring,
		struct rte_mempool *mp,
		const struct bpf_program *filter);

The old API is just the same as calling new API with NULL as filter.
This solution is safe but adds minor bloat.

2. Use API versioning.  This solves the ABI problem but it is still
   an API breakage since program that was passing junk would still
   not compile.

3. Change the function signature of existing API. This risks breaking
   at compile time some program that was passing some other value.
   Similarly, a program could have passed garbage, we never checked.

4. Keep existing function signature, but be type unsafe.
   This keeps API, but still is ABI breakage for programs that passed
   garbage. Plus C is unsafe enough already.






             reply	other threads:[~2019-12-06 22:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-06 22:11 Stephen Hemminger [this message]
2019-12-09 10:24 ` Ray Kinsella
2019-12-09 13:41 ` Ananyev, Konstantin
2019-12-09 16:49   ` Stephen Hemminger
2019-12-11 20:13   ` Morten Brørup

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=20191206141114.6b7d6d60@hermes.lan \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=mdr@ashroe.eu \
    /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).