summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorStephen Hemminger <stephen@networkplumber.org>2023-08-01 09:05:00 -0700
committerDavid Marchand <david.marchand@redhat.com>2023-08-04 14:47:55 +0200
commitf78c100bc87119c6a94130a6689d773afdaa9d98 (patch)
treedd67e93f470d8e14f771ed41853a646625d29ffc /examples
parent80a081384e23d26cc0db45bc1826b299e9780e8e (diff)
remove KNI
The KNI driver had design flaws such as calling userspace with kernel mutex held that made it prone to deadlock. The design also introduced security risks because the kernel driver trusted the userspace (DPDK) kni interface. The kernel driver was never reviewed by the upstream kernel community and would never have been accepted. And since the Linux kernel API is not stable, it was a continual source of maintenance issues especially with distribution kernels. There are better ways to inject packets into the kernel such as virtio_user, tap and XDP drivers. All of these do not need out of tree kernel drivers. The deprecation was announced in 22.11 release (see links for the the techboard discussions); and users were directed to alternatives there. Link: https://mails.dpdk.org/archives/dev/2021-January/197077.html Link: https://mails.dpdk.org/archives/dev/2022-June/243596.html Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/ip_pipeline/Makefile1
-rw-r--r--examples/ip_pipeline/cli.c95
-rw-r--r--examples/ip_pipeline/examples/kni.cli69
-rw-r--r--examples/ip_pipeline/kni.c168
-rw-r--r--examples/ip_pipeline/kni.h46
-rw-r--r--examples/ip_pipeline/main.c10
-rw-r--r--examples/ip_pipeline/meson.build1
-rw-r--r--examples/ip_pipeline/pipeline.c57
-rw-r--r--examples/ip_pipeline/pipeline.h2
9 files changed, 0 insertions, 449 deletions
diff --git a/examples/ip_pipeline/Makefile b/examples/ip_pipeline/Makefile
index 785c7ee38c..bc5e0a9f18 100644
--- a/examples/ip_pipeline/Makefile
+++ b/examples/ip_pipeline/Makefile
@@ -8,7 +8,6 @@ APP = ip_pipeline
SRCS-y := action.c
SRCS-y += cli.c
SRCS-y += conn.c
-SRCS-y += kni.c
SRCS-y += link.c
SRCS-y += main.c
SRCS-y += mempool.c
diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index c918f30e06..e8269ea90c 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -14,7 +14,6 @@
#include "cli.h"
#include "cryptodev.h"
-#include "kni.h"
#include "link.h"
#include "mempool.h"
#include "parser.h"
@@ -728,65 +727,6 @@ cmd_tap(char **tokens,
}
}
-static const char cmd_kni_help[] =
-"kni <kni_name>\n"
-" link <link_name>\n"
-" mempool <mempool_name>\n"
-" [thread <thread_id>]\n";
-
-static void
-cmd_kni(char **tokens,
- uint32_t n_tokens,
- char *out,
- size_t out_size)
-{
- struct kni_params p;
- char *name;
- struct kni *kni;
-
- memset(&p, 0, sizeof(p));
- if ((n_tokens != 6) && (n_tokens != 8)) {
- snprintf(out, out_size, MSG_ARG_MISMATCH, tokens[0]);
- return;
- }
-
- name = tokens[1];
-
- if (strcmp(tokens[2], "link") != 0) {
- snprintf(out, out_size, MSG_ARG_NOT_FOUND, "link");
- return;
- }
-
- p.link_name = tokens[3];
-
- if (strcmp(tokens[4], "mempool") != 0) {
- snprintf(out, out_size, MSG_ARG_NOT_FOUND, "mempool");
- return;
- }
-
- p.mempool_name = tokens[5];
-
- if (n_tokens == 8) {
- if (strcmp(tokens[6], "thread") != 0) {
- snprintf(out, out_size, MSG_ARG_NOT_FOUND, "thread");
- return;
- }
-
- if (parser_read_uint32(&p.thread_id, tokens[7]) != 0) {
- snprintf(out, out_size, MSG_ARG_INVALID, "thread_id");
- return;
- }
-
- p.force_bind = 1;
- } else
- p.force_bind = 0;
-
- kni = kni_create(name, &p);
- if (kni == NULL) {
- snprintf(out, out_size, MSG_CMD_FAIL, tokens[0]);
- return;
- }
-}
static const char cmd_cryptodev_help[] =
"cryptodev <cryptodev_name>\n"
@@ -1541,7 +1481,6 @@ static const char cmd_pipeline_port_in_help[] =
" | swq <swq_name>\n"
" | tmgr <tmgr_name>\n"
" | tap <tap_name> mempool <mempool_name> mtu <mtu>\n"
-" | kni <kni_name>\n"
" | source mempool <mempool_name> file <file_name> bpp <n_bytes_per_pkt>\n"
" | cryptodev <cryptodev_name> rxq <queue_id>\n"
" [action <port_in_action_profile_name>]\n"
@@ -1664,18 +1603,6 @@ cmd_pipeline_port_in(char **tokens,
}
t0 += 6;
- } else if (strcmp(tokens[t0], "kni") == 0) {
- if (n_tokens < t0 + 2) {
- snprintf(out, out_size, MSG_ARG_MISMATCH,
- "pipeline port in kni");
- return;
- }
-
- p.type = PORT_IN_KNI;
-
- p.dev_name = tokens[t0 + 1];
-
- t0 += 2;
} else if (strcmp(tokens[t0], "source") == 0) {
if (n_tokens < t0 + 6) {
snprintf(out, out_size, MSG_ARG_MISMATCH,
@@ -1781,7 +1708,6 @@ static const char cmd_pipeline_port_out_help[] =
" | swq <swq_name>\n"
" | tmgr <tmgr_name>\n"
" | tap <tap_name>\n"
-" | kni <kni_name>\n"
" | sink [file <file_name> pkts <max_n_pkts>]\n"
" | cryptodev <cryptodev_name> txq <txq_id> offset <crypto_op_offset>\n";
@@ -1874,16 +1800,6 @@ cmd_pipeline_port_out(char **tokens,
p.type = PORT_OUT_TAP;
p.dev_name = tokens[7];
- } else if (strcmp(tokens[6], "kni") == 0) {
- if (n_tokens != 8) {
- snprintf(out, out_size, MSG_ARG_MISMATCH,
- "pipeline port out kni");
- return;
- }
-
- p.type = PORT_OUT_KNI;
-
- p.dev_name = tokens[7];
} else if (strcmp(tokens[6], "sink") == 0) {
if ((n_tokens != 7) && (n_tokens != 11)) {
snprintf(out, out_size, MSG_ARG_MISMATCH,
@@ -6038,7 +5954,6 @@ cmd_help(char **tokens, uint32_t n_tokens, char *out, size_t out_size)
"\ttmgr subport\n"
"\ttmgr subport pipe\n"
"\ttap\n"
- "\tkni\n"
"\tport in action profile\n"
"\ttable action profile\n"
"\tpipeline\n"
@@ -6124,11 +6039,6 @@ cmd_help(char **tokens, uint32_t n_tokens, char *out, size_t out_size)
return;
}
- if (strcmp(tokens[0], "kni") == 0) {
- snprintf(out, out_size, "\n%s\n", cmd_kni_help);
- return;
- }
-
if (strcmp(tokens[0], "cryptodev") == 0) {
snprintf(out, out_size, "\n%s\n", cmd_cryptodev_help);
return;
@@ -6436,11 +6346,6 @@ cli_process(char *in, char *out, size_t out_size)
return;
}
- if (strcmp(tokens[0], "kni") == 0) {
- cmd_kni(tokens, n_tokens, out, out_size);
- return;
- }
-
if (strcmp(tokens[0], "cryptodev") == 0) {
cmd_cryptodev(tokens, n_tokens, out, out_size);
return;
diff --git a/examples/ip_pipeline/examples/kni.cli b/examples/ip_pipeline/examples/kni.cli
deleted file mode 100644
index 143834093d..0000000000
--- a/examples/ip_pipeline/examples/kni.cli
+++ /dev/null
@@ -1,69 +0,0 @@
-; SPDX-License-Identifier: BSD-3-Clause
-; Copyright(c) 2010-2018 Intel Corporation
-
-; _______________ ______________________
-; | | KNI0 | |
-; LINK0 RXQ0 --->|...............|------->|--+ |
-; | | KNI1 | | br0 |
-; LINK1 TXQ0 <---|...............|<-------|<-+ |
-; | | | Linux Kernel |
-; | PIPELINE0 | | Network Stack |
-; | | KNI1 | |
-; LINK1 RXQ0 --->|...............|------->|--+ |
-; | | KNI0 | | br0 |
-; LINK0 TXQ0 <---|...............|<-------|<-+ |
-; |_______________| |______________________|
-;
-; Insert Linux kernel KNI module:
-; [Linux]$ insmod rte_kni.ko
-;
-; Configure Linux kernel bridge between KNI0 and KNI1 interfaces:
-; [Linux]$ brctl addbr br0
-; [Linux]$ brctl addif br0 KNI0
-; [Linux]$ brctl addif br0 KNI1
-; [Linux]$ ifconfig br0 up
-; [Linux]$ ifconfig KNI0 up
-; [Linux]$ ifconfig KNI1 up
-;
-; Monitor packet forwarding performed by Linux kernel between KNI0 and KNI1:
-; [Linux]$ tcpdump -i KNI0
-; [Linux]$ tcpdump -i KNI1
-
-mempool MEMPOOL0 buffer 2304 pool 32K cache 256 cpu 0
-
-link LINK0 dev 0000:02:00.0 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
-link LINK1 dev 0000:02:00.1 rxq 1 128 MEMPOOL0 txq 1 512 promiscuous on
-
-kni KNI0 link LINK0 mempool MEMPOOL0
-kni KNI1 link LINK1 mempool MEMPOOL0
-
-table action profile AP0 ipv4 offset 270 fwd
-
-pipeline PIPELINE0 period 10 offset_port_id 0 cpu 0
-
-pipeline PIPELINE0 port in bsz 32 link LINK0 rxq 0
-pipeline PIPELINE0 port in bsz 32 kni KNI1
-pipeline PIPELINE0 port in bsz 32 link LINK1 rxq 0
-pipeline PIPELINE0 port in bsz 32 kni KNI0
-
-pipeline PIPELINE0 port out bsz 32 kni KNI0
-pipeline PIPELINE0 port out bsz 32 link LINK1 txq 0
-pipeline PIPELINE0 port out bsz 32 kni KNI1
-pipeline PIPELINE0 port out bsz 32 link LINK0 txq 0
-
-pipeline PIPELINE0 table match stub action AP0
-pipeline PIPELINE0 table match stub action AP0
-pipeline PIPELINE0 table match stub action AP0
-pipeline PIPELINE0 table match stub action AP0
-
-pipeline PIPELINE0 port in 0 table 0
-pipeline PIPELINE0 port in 1 table 1
-pipeline PIPELINE0 port in 2 table 2
-pipeline PIPELINE0 port in 3 table 3
-
-thread 1 pipeline PIPELINE0 enable
-
-pipeline PIPELINE0 table 0 rule add match default action fwd port 0
-pipeline PIPELINE0 table 1 rule add match default action fwd port 1
-pipeline PIPELINE0 table 2 rule add match default action fwd port 2
-pipeline PIPELINE0 table 3 rule add match default action fwd port 3
diff --git a/examples/ip_pipeline/kni.c b/examples/ip_pipeline/kni.c
deleted file mode 100644
index cd02c39478..0000000000
--- a/examples/ip_pipeline/kni.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include <rte_ethdev.h>
-#include <rte_string_fns.h>
-
-#include "kni.h"
-#include "mempool.h"
-#include "link.h"
-
-static struct kni_list kni_list;
-
-#ifndef KNI_MAX
-#define KNI_MAX 16
-#endif
-
-int
-kni_init(void)
-{
- TAILQ_INIT(&kni_list);
-
-#ifdef RTE_LIB_KNI
- rte_kni_init(KNI_MAX);
-#endif
-
- return 0;
-}
-
-struct kni *
-kni_find(const char *name)
-{
- struct kni *kni;
-
- if (name == NULL)
- return NULL;
-
- TAILQ_FOREACH(kni, &kni_list, node)
- if (strcmp(kni->name, name) == 0)
- return kni;
-
- return NULL;
-}
-
-#ifndef RTE_LIB_KNI
-
-struct kni *
-kni_create(const char *name __rte_unused,
- struct kni_params *params __rte_unused)
-{
- return NULL;
-}
-
-void
-kni_handle_request(void)
-{
- return;
-}
-
-#else
-
-static int
-kni_config_network_interface(uint16_t port_id, uint8_t if_up)
-{
- int ret = 0;
-
- if (!rte_eth_dev_is_valid_port(port_id))
- return -EINVAL;
-
- ret = (if_up) ?
- rte_eth_dev_set_link_up(port_id) :
- rte_eth_dev_set_link_down(port_id);
-
- return ret;
-}
-
-static int
-kni_change_mtu(uint16_t port_id, unsigned int new_mtu)
-{
- int ret;
-
- if (!rte_eth_dev_is_valid_port(port_id))
- return -EINVAL;
-
- if (new_mtu > RTE_ETHER_MAX_LEN)
- return -EINVAL;
-
- /* Set new MTU */
- ret = rte_eth_dev_set_mtu(port_id, new_mtu);
- if (ret < 0)
- return ret;
-
- return 0;
-}
-
-struct kni *
-kni_create(const char *name, struct kni_params *params)
-{
- struct rte_eth_dev_info dev_info;
- struct rte_kni_conf kni_conf;
- struct rte_kni_ops kni_ops;
- struct kni *kni;
- struct mempool *mempool;
- struct link *link;
- struct rte_kni *k;
- int ret;
-
- /* Check input params */
- if ((name == NULL) ||
- kni_find(name) ||
- (params == NULL))
- return NULL;
-
- mempool = mempool_find(params->mempool_name);
- link = link_find(params->link_name);
- if ((mempool == NULL) ||
- (link == NULL))
- return NULL;
-
- /* Resource create */
- ret = rte_eth_dev_info_get(link->port_id, &dev_info);
- if (ret != 0)
- return NULL;
-
- memset(&kni_conf, 0, sizeof(kni_conf));
- strlcpy(kni_conf.name, name, RTE_KNI_NAMESIZE);
- kni_conf.force_bind = params->force_bind;
- kni_conf.core_id = params->thread_id;
- kni_conf.group_id = link->port_id;
- kni_conf.mbuf_size = mempool->buffer_size;
-
- memset(&kni_ops, 0, sizeof(kni_ops));
- kni_ops.port_id = link->port_id;
- kni_ops.config_network_if = kni_config_network_interface;
- kni_ops.change_mtu = kni_change_mtu;
-
- k = rte_kni_alloc(mempool->m, &kni_conf, &kni_ops);
- if (k == NULL)
- return NULL;
-
- /* Node allocation */
- kni = calloc(1, sizeof(struct kni));
- if (kni == NULL)
- return NULL;
-
- /* Node fill in */
- strlcpy(kni->name, name, sizeof(kni->name));
- kni->k = k;
-
- /* Node add to list */
- TAILQ_INSERT_TAIL(&kni_list, kni, node);
-
- return kni;
-}
-
-void
-kni_handle_request(void)
-{
- struct kni *kni;
-
- TAILQ_FOREACH(kni, &kni_list, node)
- rte_kni_handle_request(kni->k);
-}
-
-#endif
diff --git a/examples/ip_pipeline/kni.h b/examples/ip_pipeline/kni.h
deleted file mode 100644
index 118f48df73..0000000000
--- a/examples/ip_pipeline/kni.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* SPDX-License-Identifier: BSD-3-Clause
- * Copyright(c) 2010-2018 Intel Corporation
- */
-
-#ifndef _INCLUDE_KNI_H_
-#define _INCLUDE_KNI_H_
-
-#include <stdint.h>
-#include <sys/queue.h>
-
-#ifdef RTE_LIB_KNI
-#include <rte_kni.h>
-#endif
-
-#include "common.h"
-
-struct kni {
- TAILQ_ENTRY(kni) node;
- char name[NAME_SIZE];
-#ifdef RTE_LIB_KNI
- struct rte_kni *k;
-#endif
-};
-
-TAILQ_HEAD(kni_list, kni);
-
-int
-kni_init(void);
-
-struct kni *
-kni_find(const char *name);
-
-struct kni_params {
- const char *link_name;
- const char *mempool_name;
- int force_bind;
- uint32_t thread_id;
-};
-
-struct kni *
-kni_create(const char *name, struct kni_params *params);
-
-void
-kni_handle_request(void);
-
-#endif /* _INCLUDE_KNI_H_ */
diff --git a/examples/ip_pipeline/main.c b/examples/ip_pipeline/main.c
index e35d9bce39..663f538f02 100644
--- a/examples/ip_pipeline/main.c
+++ b/examples/ip_pipeline/main.c
@@ -14,7 +14,6 @@
#include "cli.h"
#include "conn.h"
-#include "kni.h"
#include "cryptodev.h"
#include "link.h"
#include "mempool.h"
@@ -205,13 +204,6 @@ main(int argc, char **argv)
return status;
}
- /* KNI */
- status = kni_init();
- if (status) {
- printf("Error: KNI initialization failed (%d)\n", status);
- return status;
- }
-
/* Sym Crypto */
status = cryptodev_init();
if (status) {
@@ -264,7 +256,5 @@ main(int argc, char **argv)
conn_poll_for_conn(conn);
conn_poll_for_msg(conn);
-
- kni_handle_request();
}
}
diff --git a/examples/ip_pipeline/meson.build b/examples/ip_pipeline/meson.build
index 57f522c24c..68049157e4 100644
--- a/examples/ip_pipeline/meson.build
+++ b/examples/ip_pipeline/meson.build
@@ -18,7 +18,6 @@ sources = files(
'cli.c',
'conn.c',
'cryptodev.c',
- 'kni.c',
'link.c',
'main.c',
'mempool.c',
diff --git a/examples/ip_pipeline/pipeline.c b/examples/ip_pipeline/pipeline.c
index 7ebabcae98..63352257c6 100644
--- a/examples/ip_pipeline/pipeline.c
+++ b/examples/ip_pipeline/pipeline.c
@@ -11,9 +11,6 @@
#include <rte_string_fns.h>
#include <rte_port_ethdev.h>
-#ifdef RTE_LIB_KNI
-#include <rte_port_kni.h>
-#endif
#include <rte_port_ring.h>
#include <rte_port_source_sink.h>
#include <rte_port_fd.h>
@@ -28,9 +25,6 @@
#include <rte_table_lpm_ipv6.h>
#include <rte_table_stub.h>
-#ifdef RTE_LIB_KNI
-#include "kni.h"
-#endif
#include "link.h"
#include "mempool.h"
#include "pipeline.h"
@@ -160,9 +154,6 @@ pipeline_port_in_create(const char *pipeline_name,
struct rte_port_ring_reader_params ring;
struct rte_port_sched_reader_params sched;
struct rte_port_fd_reader_params fd;
-#ifdef RTE_LIB_KNI
- struct rte_port_kni_reader_params kni;
-#endif
struct rte_port_source_params source;
struct rte_port_sym_crypto_reader_params sym_crypto;
} pp;
@@ -264,22 +255,6 @@ pipeline_port_in_create(const char *pipeline_name,
break;
}
-#ifdef RTE_LIB_KNI
- case PORT_IN_KNI:
- {
- struct kni *kni;
-
- kni = kni_find(params->dev_name);
- if (kni == NULL)
- return -1;
-
- pp.kni.kni = kni->k;
-
- p.ops = &rte_port_kni_reader_ops;
- p.arg_create = &pp.kni;
- break;
- }
-#endif
case PORT_IN_SOURCE:
{
@@ -404,9 +379,6 @@ pipeline_port_out_create(const char *pipeline_name,
struct rte_port_ring_writer_params ring;
struct rte_port_sched_writer_params sched;
struct rte_port_fd_writer_params fd;
-#ifdef RTE_LIB_KNI
- struct rte_port_kni_writer_params kni;
-#endif
struct rte_port_sink_params sink;
struct rte_port_sym_crypto_writer_params sym_crypto;
} pp;
@@ -415,9 +387,6 @@ pipeline_port_out_create(const char *pipeline_name,
struct rte_port_ethdev_writer_nodrop_params ethdev;
struct rte_port_ring_writer_nodrop_params ring;
struct rte_port_fd_writer_nodrop_params fd;
-#ifdef RTE_LIB_KNI
- struct rte_port_kni_writer_nodrop_params kni;
-#endif
struct rte_port_sym_crypto_writer_nodrop_params sym_crypto;
} pp_nodrop;
@@ -537,32 +506,6 @@ pipeline_port_out_create(const char *pipeline_name,
break;
}
-#ifdef RTE_LIB_KNI
- case PORT_OUT_KNI:
- {
- struct kni *kni;
-
- kni = kni_find(params->dev_name);
- if (kni == NULL)
- return -1;
-
- pp.kni.kni = kni->k;
- pp.kni.tx_burst_sz = params->burst_size;
-
- pp_nodrop.kni.kni = kni->k;
- pp_nodrop.kni.tx_burst_sz = params->burst_size;
- pp_nodrop.kni.n_retries = params->n_retries;
-
- if (params->retry == 0) {
- p.ops = &rte_port_kni_writer_ops;
- p.arg_create = &pp.kni;
- } else {
- p.ops = &rte_port_kni_writer_nodrop_ops;
- p.arg_create = &pp_nodrop.kni;
- }
- break;
- }
-#endif
case PORT_OUT_SINK:
{
diff --git a/examples/ip_pipeline/pipeline.h b/examples/ip_pipeline/pipeline.h
index 4d2ee29a54..083d5e8524 100644
--- a/examples/ip_pipeline/pipeline.h
+++ b/examples/ip_pipeline/pipeline.h
@@ -25,7 +25,6 @@ enum port_in_type {
PORT_IN_SWQ,
PORT_IN_TMGR,
PORT_IN_TAP,
- PORT_IN_KNI,
PORT_IN_SOURCE,
PORT_IN_CRYPTODEV,
};
@@ -67,7 +66,6 @@ enum port_out_type {
PORT_OUT_SWQ,
PORT_OUT_TMGR,
PORT_OUT_TAP,
- PORT_OUT_KNI,
PORT_OUT_SINK,
PORT_OUT_CRYPTODEV,
};