diff --git a/ansible/cndp-config/templates/fwd.jsonc.j2 b/ansible/cndp-config/templates/fwd.jsonc.j2 index 8f76bc20..b814aafc 100644 --- a/ansible/cndp-config/templates/fwd.jsonc.j2 +++ b/ansible/cndp-config/templates/fwd.jsonc.j2 @@ -90,6 +90,7 @@ // skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false // description - (O) the description, 'desc' can be used as well // xsk_pin_path - (O) Path to pinned bpf map + // uds_path - (O) Path to unix domain socket to get xsk map fd "lports": { {% for i in range(num_lports) %} "{{iface}}:{{i}}": { @@ -129,7 +130,6 @@ // no-restapi - (O) Disable RestAPI support // cli - (O) Enable/Disable CLI supported // mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, acl-strict, acl-permissive - // uds_path - (O) Path to unix domain socket to get xsk map fd "options": { "pkt_api": "xskdev", "no-metrics": false, diff --git a/doc/guides/rel_notes/known_issues.rst b/doc/guides/rel_notes/known_issues.rst index 6bf34040..9bd2bfc0 100644 --- a/doc/guides/rel_notes/known_issues.rst +++ b/doc/guides/rel_notes/known_issues.rst @@ -1,7 +1,12 @@ .. SPDX-License-Identifier: BSD-3-Clause - Copyright (c) 2010-2023 Intel Corporation. + Copyright (c) 2010-2024 Intel Corporation. Known Issues and Limitations in Legacy Releases =============================================== This section describes known issues with the CNDP software that aren't covered in the version specific release notes sections. + +* `uds_path`` not supported through lport-group configuration. Support needs to be added for `uds_base_dir` and `uds_name` + so that the `uds_path` can be generated on a per port basis. +* `xsk_pin_path` not supported through lport-group configuration. Support needs to be added for `pin_path_base_dir` and `map_name` + so that the `xsk_pin_path` can be generated on a per port basis. diff --git a/doc/guides/sample_app_ug/cndpfwd.rst b/doc/guides/sample_app_ug/cndpfwd.rst index 936e443a..a23672fd 100644 --- a/doc/guides/sample_app_ug/cndpfwd.rst +++ b/doc/guides/sample_app_ug/cndpfwd.rst @@ -161,6 +161,7 @@ The configuration json file is located in the ``cndpfwd`` example sub-directory // skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false // description - (O) the description, 'desc' can be used as well // xsk_pin_path - (O) Path to pinned xsk map for this port + // uds_path - (0) Path to unix domain socket to get xsk map fd "lports": { "eth0:0": { "pmd": "net_af_xdp", @@ -200,8 +201,7 @@ The configuration json file is located in the ``cndpfwd`` example sub-directory // no-restapi - (O) Disable RestAPI support // cli - (O) Enable/Disable CLI supported // mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, tx-only-rx - // acl-strict, acl-permissive - // uds_path - (0) Path to unix domain socket to get xsk map fd + // acl-strict, acl-permissiv "options": { "pkt_api": "xskdev", "no-metrics": false, diff --git a/examples/cndp-frr/docker/cnetfrr-graph.jsonc b/examples/cndp-frr/docker/cnetfrr-graph.jsonc index 85683010..0548adf7 100644 --- a/examples/cndp-frr/docker/cnetfrr-graph.jsonc +++ b/examples/cndp-frr/docker/cnetfrr-graph.jsonc @@ -83,6 +83,7 @@ // force_wakeup - (O) force TX wakeup calls for CVL NIC, default false // skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false // xsk_pin_path - (O) Path to pinned xsk map for this port + // uds_path - (0) Path to unix domain socket to get xsk map fd // description - (O) the description, 'desc' can be used as well "lports": { "eth0:0": { @@ -125,7 +126,6 @@ // no-restapi - (O) Disable RestAPI support // cli - (O) Enable/Disable CLI supported // mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, acl-strict, acl-permissive - // uds_path - (O) Path to unix domain socket to get xsk map fd "options": { "no-metrics": false, "no-restapi": false, diff --git a/examples/cndpfwd/fwd.jsonc b/examples/cndpfwd/fwd.jsonc index 8444e6ba..6ce1d02f 100644 --- a/examples/cndpfwd/fwd.jsonc +++ b/examples/cndpfwd/fwd.jsonc @@ -82,6 +82,7 @@ // force_wakeup - (O) force TX wakeup calls for CVL NIC, default false // skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false // xsk_pin_path - (O) Path to pinned xsk map for this port + // uds_path - (O) Path to unix domain socket to get xsk map fd // description - (O) the description, 'desc' can be used as well "lports": { "eth0:0": { diff --git a/examples/cndpfwd/main.h b/examples/cndpfwd/main.h index be9c2b5a..36623105 100644 --- a/examples/cndpfwd/main.h +++ b/examples/cndpfwd/main.h @@ -60,7 +60,6 @@ enum { #define NO_RESTAPI_TAG "no-restapi" /**< json tag for no-restapi */ #define ENABLE_CLI_TAG "cli" /**< json tag to enable/disable CLI */ #define MODE_TAG "mode" /**< json tag to set the mode flag */ -#define UDS_PATH_TAG "uds_path" /**< json tag for UDS to get xsk map fd */ #define FIB_RULES_TAG "l3fwd-fib-rules" /**< json tag to set up static FIB entries */ #define HS_PATTERN_TAG "hs-patterns" /**< json tag for Hyperscan patterns */ diff --git a/examples/cndpfwd/parse-args.c b/examples/cndpfwd/parse-args.c index c8471562..b2d88362 100644 --- a/examples/cndpfwd/parse-args.c +++ b/examples/cndpfwd/parse-args.c @@ -75,12 +75,6 @@ process_callback(jcfg_info_t *j __cne_unused, void *_obj, void *arg, int idx) if (f->test == UNKNOWN_TEST) f->test = get_app_mode(f->opts.mode); } - } else if (!strncmp(obj.opt->name, UDS_PATH_TAG, nlen)) { - if (obj.opt->val.type == STRING_OPT_TYPE) { - f->xdp_uds = udsc_handshake(obj.opt->val.str); - if (f->xdp_uds == NULL) - CNE_ERR_RET("UDS handshake failed %s\n", strerror(errno)); - } } else if (!strncmp(obj.opt->name, FIB_RULES_TAG, nlen)) { if (obj.opt->val.type == ARRAY_OPT_TYPE) { f->fib_rules = calloc(obj.opt->val.array_sz, sizeof(char *)); @@ -201,10 +195,13 @@ process_callback(jcfg_info_t *j __cne_unused, void *_obj, void *arg, int idx) pcfg.xsk_map_path = lport->xsk_map_path; } - if (f->xdp_uds) { + if (lport->uds_path) { cne_printf("[yellow]**** [green]UDS is [red]enabled[]\n"); - pcfg.xsk_uds = f->xdp_uds; - pcfg.flags |= LPORT_UNPRIVILEGED; + pcfg.xsk_uds = f->xdp_uds = udsc_handshake(lport->uds_path); + if (pcfg.xsk_uds == NULL) { + pd->xsk = NULL; + CNE_ERR_RET("UDS handshake failed %s\n", strerror(errno)); + } } pcfg.addr = jcfg_lport_region(lport, &pcfg.bufcnt); diff --git a/examples/cnet-graph/cnetfwd-graph.jsonc b/examples/cnet-graph/cnetfwd-graph.jsonc index b40cabbb..a4c56ce3 100644 --- a/examples/cnet-graph/cnetfwd-graph.jsonc +++ b/examples/cnet-graph/cnetfwd-graph.jsonc @@ -83,6 +83,7 @@ // force_wakeup - (O) force TX wakeup calls for CVL NIC, default false // skb_mode - (O) Enable XDP_FLAGS_SKB_MODE when creating af_xdp socket, forces copy mode, default false // xsk_pin_path - (O) Path to pinned xsk map for this port + // uds_path - (O) Path to unix domain socket to get xsk map fd // description - (O) the description, 'desc' can be used as well "lports": { "eth0:0": { @@ -124,7 +125,6 @@ // no-restapi - (O) Disable RestAPI support // cli - (O) Enable/Disable CLI supported // mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, acl-strict, acl-permissive - // uds_path - (O) Path to unix domain socket to get xsk map fd "options": { "no-metrics": false, "no-restapi": false, diff --git a/lib/common/uds_connect/uds_connect.c b/lib/common/uds_connect/uds_connect.c index 8dcac5fc..7f70d25b 100644 --- a/lib/common/uds_connect/uds_connect.c +++ b/lib/common/uds_connect/uds_connect.c @@ -106,6 +106,7 @@ udsc_handshake(const char *uds_name) * to register protocol commands with and process information * exchanged on the UDS. */ + info = uds_connect(uds_name, &err_msg, NULL); if (!info) return NULL; diff --git a/lib/core/xskdev/xskdev.c b/lib/core/xskdev/xskdev.c index e679b47a..4f25beda 100644 --- a/lib/core/xskdev/xskdev.c +++ b/lib/core/xskdev/xskdev.c @@ -930,10 +930,11 @@ xskdev_socket_destroy(xskdev_info_t *xi) uint32_t curr_prog_id = 0; if (xi) { - CNE_DEBUG("ifindex %d, %s, prog_id %u\n", xi->if_index, xi->ifname, xi->prog_id); if (xi->if_index) { if (!xi->xsk_map_fd) { // Don't unload programs we didn't load. if (xi->unprivileged == 0) { + CNE_DEBUG("ifindex %d, %s, prog_id %u\n", xi->if_index, xi->ifname, + xi->prog_id); #if USE_LIBBPF_8 if (bpf_xdp_query_id(xi->if_index, xi->xdp_flags, &curr_prog_id)) #else diff --git a/lib/usr/app/jcfg/jcfg.h b/lib/usr/app/jcfg/jcfg.h index 0102e1e1..aff71571 100644 --- a/lib/usr/app/jcfg/jcfg.h +++ b/lib/usr/app/jcfg/jcfg.h @@ -30,7 +30,7 @@ #define DEFAULT_CHUNK_SIZE 1024 #define UMEM_MAX_REGIONS 128 -#define JCFG_MAX_STRING_SIZE 32 +#define JCFG_MAX_STRING_SIZE 64 #ifdef __cplusplus extern "C" { @@ -173,6 +173,7 @@ typedef struct jcfg_lport { uint16_t busy_budget; /**< busy budget 0xFFFF disabled, 0 use default, >0 budget */ uint16_t flags; /**< Flags to configure lport in lport_cfg_t.flags in cne_lport.h */ char *xsk_map_path; /**< The path to the pinned xsk_map for this port */ + char *uds_path; /**< The path to the pinned xsk_map for this port */ } jcfg_lport_t; /** JCFG lport configuration names */ @@ -187,6 +188,7 @@ typedef struct jcfg_lport { #define JCFG_LPORT_BUSY_TIMEOUT_NAME "busy_timeout" #define JCFG_LPORT_BUSY_BUDGET_NAME "busy_budget" #define JCFG_PINNED_XSK_MAP_NAME "xsk_pin_path" +#define JCFG_UDS_NAME "uds_path" #define JCFG_LPORT_FORCE_WAKEUP_NAME "force_wakeup" #define JCFG_LPORT_SKB_MODE_NAME "skb_mode" diff --git a/lib/usr/app/jcfg/jcfg_lport.c b/lib/usr/app/jcfg/jcfg_lport.c index f1b3b89f..bdb064db 100644 --- a/lib/usr/app/jcfg/jcfg_lport.c +++ b/lib/usr/app/jcfg/jcfg_lport.c @@ -111,6 +111,9 @@ _lport(struct json_object *obj, int flags, struct json_object *parent __cne_unus } else if (!strncmp(key, JCFG_PINNED_XSK_MAP_NAME, keylen)) { lport->xsk_map_path = strndup(json_object_get_string(obj), JCFG_MAX_STRING_SIZE); lport->flags |= LPORT_UNPRIVILEGED; + } else if (!strncmp(key, JCFG_UDS_NAME, keylen)) { + lport->uds_path = strndup(json_object_get_string(obj), JCFG_MAX_STRING_SIZE); + lport->flags |= LPORT_UNPRIVILEGED; } else if (!strncmp(key, JCFG_LPORT_FORCE_WAKEUP_NAME, keylen)) lport->flags |= json_object_get_boolean(obj) ? LPORT_FORCE_WAKEUP : 0; else if (!strncmp(key, JCFG_LPORT_SKB_MODE_NAME, keylen)) diff --git a/meson.build b/meson.build index bf03147c..88043f6e 100644 --- a/meson.build +++ b/meson.build @@ -168,7 +168,7 @@ if nl_cli_dep.found() endif nl_route_dep = dependency('libnl-route-3.0', required: true, method: 'pkg-config', static: use_static_libs) -if nl_cli_dep.found() +if nl_route_dep.found() add_project_link_arguments('-lnl-route-3', language: 'c') extra_ldflags += '-lnl-route-3' endif diff --git a/tools/cndp.schema b/tools/cndp.schema index 4c9ece0b..100650ab 100644 --- a/tools/cndp.schema +++ b/tools/cndp.schema @@ -166,6 +166,11 @@ "description": "The path to which the xskmap has been pinned outside of cndp", "type": "string", "default": false + }, + "uds_path": { + "description": "The path to socket cndp can connect to to retrieve the xskmap fd", + "type": "string", + "default": false } }, "patternProperties": { @@ -339,11 +344,6 @@ "description": "Enable XDP_FLAGS_SKB_MODE to force copy mode", "type": "boolean", "default": false - }, - "xsk_pin_path": { - "description": "The path to which the xskmap has been pinned outside of cndp", - "type": "string", - "default": false } }, "patternProperties": { diff --git a/tools/jsonc_gen.sh b/tools/jsonc_gen.sh index 15ba4190..2f9a3c21 100755 --- a/tools/jsonc_gen.sh +++ b/tools/jsonc_gen.sh @@ -10,12 +10,14 @@ # would populate the AFXDP_DEVICES environment variable. # The available cores to the application are determined by # the 'lscpu' command. - +num_of_devs=0 KIND=false PINNED_BPF_MAP=false -config_file=config.jsonc -AFXDP_DEVICES=${AFXDP_DEVICES:-net1} AFXDP_COPY_MODE=${AFXDP_COPY_MODE:-false} +config_file=config.jsonc +declare -a AFXDP_DEVICES +declare -a MAP_OR_UDS_PATH=() +declare -a MAP_OR_UDS=() while getopts "kp" flag; do case $flag in @@ -32,16 +34,28 @@ else DEFAULT_QID=0 # For kind using veth use queue 0 fi -if [ ${PINNED_BPF_MAP} = false ] ; then - UDS_PATH="uds_path" - UDS="/tmp/afxdp.sock" - UDS_CFG=("\"$UDS_PATH\": \"$UDS\",") - unset "${MAP_CFG[@]}" -else - MAP_PATH="xsk_pin_path" - MAP="/tmp/xsks_map" - MAP_CFG=("\"$MAP_PATH\": \"$MAP\",") - unset "${UDS_CFG[@]}" +for device in "${!AFXDP_DEVICES_@}"; +do + AFXDP_DEVICES[num_of_devs]="${!device}" + if [ ${PINNED_BPF_MAP} = false ] ; then + MAP_OR_UDS[num_of_devs]="\"uds_path\"" + MAP_OR_UDS_PATH[num_of_devs]="\"/tmp/afxdp_dp/${!device}/afxdp.sock\"" + else + MAP_OR_UDS[num_of_devs]="\"xsk_pin_path\"" + MAP_OR_UDS_PATH[num_of_devs]="\"/tmp/afxdp_dp/${!device}/xsks_map\"" + fi + num_of_devs=$((num_of_devs+1)) +done + +if [ $num_of_devs == 0 ] ; then + AFXDP_DEVICES+=("net1") + if [ ${PINNED_BPF_MAP} = false ] ; then + MAP_OR_UDS[num_of_devs]="uds_path" + MAP_OR_UDS_PATH[num_of_devs]="/tmp/afxdp_dp/${AFXDP_DEVICES[num_of_devs]}/afxdp.sock" + else + MAP_OR_UDS[num_of_devs]="xsk_pin_path" + MAP_OR_UDS_PATH[num_of_devs]="/tmp/afxdp_dp//${AFXDP_DEVICES[num_of_devs]}/xsks_map" + fi fi num_of_interfaces=0 @@ -54,7 +68,7 @@ declare -a num_of_cores_in_each_numa_node declare -a LCORE # get list of interfaces -for net in $AFXDP_DEVICES +for net in "${AFXDP_DEVICES[@]}" do NET[num_of_interfaces++]=$net QID[num_of_qids++]=${DEFAULT_QID} @@ -129,7 +143,7 @@ EOF "umem": "umem0", "region": ${i}, "skb_mode": ${AFXDP_COPY_MODE}, - ${MAP_CFG[@]} + ${MAP_OR_UDS[i]} : ${MAP_OR_UDS_PATH[i]}, "description": "LAN ${i} port" } EOF @@ -273,13 +287,11 @@ cat <<-EOF > ${config_file} // no-restapi - (O) Disable RestAPI support // cli - (O) Enable/Disable CLI supported // mode - (O) Mode type [drop | rx-only], tx-only, [lb | loopback], fwd, acl-strict, acl-permissive - // uds_path - (O) Path to unix domain socket to get xsk map fd "options": { "pkt_api": "xskdev", "no-metrics": false, "no-restapi": false, "cli": false, - ${UDS_CFG[@]} "mode": "drop", // FIB rules ,, "l3fwd-fib-rules": [ diff --git a/tools/jsonc_gen_lport_groups.sh b/tools/jsonc_gen_lport_groups.sh index 12bf2fef..9dadc668 100755 --- a/tools/jsonc_gen_lport_groups.sh +++ b/tools/jsonc_gen_lport_groups.sh @@ -111,7 +111,6 @@ function emit_jsonc_options cat <<-EOF >> $config_file "options": { - "uds_path": "/tmp/cndp.sock", "mode": "drop" } } diff --git a/usrtools/xskmap_load_send/README.md b/usrtools/xskmap_load_send/README.md index 203133d9..199fe367 100644 --- a/usrtools/xskmap_load_send/README.md +++ b/usrtools/xskmap_load_send/README.md @@ -22,6 +22,7 @@ application to be used alongside this utility is shown below: "umem": "umem0", "region": 0, "description": "LAN 0 port", + "uds_path": "/var/run/cndp/app_socket.580113" } }, ... @@ -31,7 +32,6 @@ application to be used alongside this utility is shown below: "no-restapi": false, "cli": true, "mode": "drop", - "uds_path": "/var/run/cndp/app_socket.580113" }, ... ```