psp: Add support for dev-assoc/disassoc
Subsystems (5)
v3 cover psp: Add support for dev-assoc/disassoc
From: Wei Wang <[email protected]>
The main purpose of this feature is to associate virtual devices like veth or netkit with a real PSP device, so we could provide PSP functionality to the application running with virtual devices.
A typical deployment that works with this feature is as follows:
Host Namespace:
psp_dev_local ←──physically linked──→ psp_dev_peer
(PSP device)
│
│ BPF on psp_dev_local ingress: bpf_redirect_peer() to nk_guest │
nk_host / veth_host
│
│ BPF on nk_host ingress: bpf_redirect_neigh() to psp_dev_local │
Guest Namespace (netns):
│
nk_guest / veth_guest
★ PSP application run here
Remote Namespace (_netns):
psp_dev_peer
★ PSP server application runs here
Note:
The general requirement for this feature to work:
For PSP to work correctly, the egress device at validate_xmit_skb() time must have psp_dev matching the association's psd. Any device stacking or traffic redirection that changes the egress device will cause either:
1. TX validation failure (SKB_DROP_REASON_PSP_OUTPUT) - fail-safe
2. RX policy failure after tx-assoc - packets without PSP extension are rejected by receiver expecting encrypted traffic
Here are a few examples that this feature would not work:
- Bonding with load balancing in round-robin, XOR, 802.3ad mode across multiple PSP devices, or mixed PSP and non-PSP devices
- Bonding with active-backup mode might work without PSP migration for failover case.
- ipvlan/macvlan in bridge mode would not work given packets are loopbacked locally without going through the PSP device.
Changes since v2:
- Change the newly added parameter to psp_device_get_and_lock() to admin in patch 1. Introduce 2 device check functions:
- psp_device_get_locked_admin() for dev-set and key-rotate
- psp_device_get_locked() for all other operations
Flip the logic for checking the dev_assoc_list accordingly in patch 2.
- Move psp_nl_notify_dev() before removing the dev from assoc_dev_list in psp_nl_dev_disassoc_doit() and correct the typo in commit msg in patch 2.
- Remove the threading and subprocess and some comment updates in patch 5.
Changes since v1:
- Update the first 4 patches to reflect the latest changes in
https://lore.kernel.org/netdev/[email protected]/
- Update patch 9 to add a param to NetDrvContEnv to control the loading of the tx forwarding bpf program
Wei Wang (5):
psp: add admin/non-admin version of psp_device_get_locked
psp: add new netlink cmd for dev-assoc and dev-disassoc
psp: add a new netdev event for dev unregister selftests/net: Add bpf skb forwarding program selftest/net: psp: Add test for dev-assoc/disassoc
Documentation/netlink/specs/psp.yaml | 68 ++- include/net/psp/types.h | 15 + include/uapi/linux/psp.h | 13 + net/psp/psp-nl-gen.c | 36 +- net/psp/psp-nl-gen.h | 4 + net/psp/psp.h | 2 +- net/psp/psp_main.c | 90 +++- net/psp/psp_nl.c | 298 +++++++++++++- .../drivers/net/hw/nk_redirect.bpf.c | 60 +++ .../selftests/drivers/net/lib/py/env.py | 54 ++- tools/testing/selftests/drivers/net/psp.py | 387 +++++++++++++++++- 11 files changed, 997 insertions(+), 30 deletions(-) create mode 100644 tools/testing/selftests/drivers/net/hw/nk_redirect.bpf.c
Signature · 1 line
2.52.0
PATCH v3 1/5 psp: add admin/non-admin version of psp_device_get_locked
From: Wei Wang <[email protected]>
Introduce 2 versions of psp_device_get_locked:
1. psp_device_get_locked_admin(): This version is used for operations that would change the status of the psd, and are currently used for dev-set nad key-rotation.
2. psp_device_get_locked(): This is the non-admin version, which are used for broader user issued operations including: dev-get, rx-assoc, tx-assoc, get-stats.
Following commit will be implementing both of the checks.
--- Documentation/netlink/specs/psp.yaml | 4 ++-- net/psp/psp-nl-gen.c | 4 ++-- net/psp/psp-nl-gen.h | 2 ++ net/psp/psp.h | 2 +- net/psp/psp_main.c | 7 ++++++- net/psp/psp_nl.c | 28 +++++++++++++++++++++------- 6 files changed, 34 insertions(+), 13 deletions(-)
Documentation/netlink/specs/psp.yaml +2 -2
@@ -195,7 +195,7 @@ operations: - psp-versions-ena reply: attributes: [] - pre: psp-device-get-locked + pre: psp-device-get-locked-admin post: psp-device-unlock - name: dev-change-ntf
@@ -214,7 +214,7 @@ operations: reply: attributes: - id - pre: psp-device-get-locked + pre: psp-device-get-locked-admin post: psp-device-unlock - name: key-rotate-ntf
net/psp/psp-nl-gen.c +2 -2
@@ -71,7 +71,7 @@ static const struct genl_split_ops psp_nl_ops[] = { }, { .cmd = PSP_CMD_DEV_SET, - .pre_doit = psp_device_get_locked, + .pre_doit = psp_device_get_locked_admin, .doit = psp_nl_dev_set_doit, .post_doit = psp_device_unlock, .policy = psp_dev_set_nl_policy,
@@ -80,7 +80,7 @@ static const struct genl_split_ops psp_nl_ops[] = { }, { .cmd = PSP_CMD_KEY_ROTATE, - .pre_doit = psp_device_get_locked, + .pre_doit = psp_device_get_locked_admin, .doit = psp_nl_key_rotate_doit, .post_doit = psp_device_unlock, .policy = psp_key_rotate_nl_policy,
net/psp/psp-nl-gen.h +2 -0
@@ -17,6 +17,8 @@ extern const struct nla_policy psp_keys_nl_policy[PSP_A_KEYS_SPI + 1];int psp_device_get_locked (const struct genl_split_ops *ops,struct sk_buff *skb,struct genl_info *info); +int psp_device_get_locked_admin (const struct genl_split_ops *ops, +struct sk_buff *skb,struct genl_info *info);int psp_assoc_device_get_locked (const struct genl_split_ops *ops,struct sk_buff *skb,struct genl_info *info);void
net/psp/psp.h +1 -1
@@ -14,7 +14,7 @@ extern struct xarray psp_devs;extern struct mutex psp_devs_lock;void psp_dev_free (struct psp_dev *psd); -int psp_dev_check_access (struct psp_dev *psd,struct net *net); +int psp_dev_check_access (struct psp_dev *psd,struct net *net,bool admin);void psp_nl_notify_dev (struct psp_dev *psd,u32 cmd);
net/psp/psp_main.c +6 -1
@@ -27,10 +27,15 @@ struct mutex psp_devs_lock;* psp_dev_check_access() - check if user in a given net ns can access PSP dev * @psd: PSP device structure user is trying to access * @net: net namespace user is in +* @admin: If true, only allow access from @psd's main device's netns, +* for admin operations like config changes and key rotation. +* If false, also allow access from network namespaces that have +* an associated device with @psd, for read-only and association +* management operations. * * Return: 0 if PSP device should be visible in @net, errno otherwise. */ -int psp_dev_check_access (struct psp_dev *psd,struct net *net) +int psp_dev_check_access (struct psp_dev *psd,struct net *net,bool admin) {if (dev_net (psd->main_netdev) == net)return 0 ;
net/psp/psp_nl.c +21 -7
@@ -41,7 +41,8 @@ static int psp_nl_reply_send(struct sk_buff *rsp, struct genl_info *info)/* Device stuff */ static struct psp_dev * -psp_device_get_and_lock (struct net *net,struct nlattr *dev_id) +psp_device_get_and_lock (struct net *net,struct nlattr *dev_id, +bool admin) {struct psp_dev *psd;int err;
@@ -56,7 +57,7 @@ psp_device_get_and_lock(struct net *net, struct nlattr *dev_id)mutex_lock (&psd->lock);mutex_unlock (&psp_devs_lock); - err =psp_dev_check_access (psd, net); + err =psp_dev_check_access (psd, net, admin);if (err) {mutex_unlock (&psd->lock);return ERR_PTR (err);
@@ -65,6 +66,18 @@ psp_device_get_and_lock(struct net *net, struct nlattr *dev_id)return psd; } +int psp_device_get_locked_admin (const struct genl_split_ops *ops, +struct sk_buff *skb,struct genl_info *info) +{ +if (GENL_REQ_ATTR_CHECK (info,PSP_A_DEV_ID )) +return -EINVAL ; + + info->user_ptr[0 ] =psp_device_get_and_lock (genl_info_net (info), + info->attrs[PSP_A_DEV_ID ], + true); +return PTR_ERR_OR_ZERO (info->user_ptr[0 ]); +} +int psp_device_get_locked (const struct genl_split_ops *ops,struct sk_buff *skb,struct genl_info *info) {
@@ -72,7 +85,8 @@ int psp_device_get_locked(const struct genl_split_ops *ops,return -EINVAL ; info->user_ptr[0 ] =psp_device_get_and_lock (genl_info_net (info), - info->attrs[PSP_A_DEV_ID ]); + info->attrs[PSP_A_DEV_ID ], + false);return PTR_ERR_OR_ZERO (info->user_ptr[0 ]); }
@@ -160,7 +174,7 @@ static int psp_nl_dev_get_dumpit_one(struct sk_buff *rsp, struct netlink_callback *cb, struct psp_dev *psd) { - if (psp_dev_check_access(psd, sock_net(rsp->sk))) + if (psp_dev_check_access(psd, sock_net(rsp->sk), false)) return 0; return psp_nl_dev_fill(psd, rsp, genl_info_dump(cb));
@@ -305,7 +319,7 @@ int psp_assoc_device_get_locked(const struct genl_split_ops *ops, psd =psp_dev_get_for_sock (socket->sk);if (psd) { - err =psp_dev_check_access (psd,genl_info_net (info)); + err =psp_dev_check_access (psd,genl_info_net (info), false);if (err) {psp_dev_put (psd); psd =NULL ;
@@ -330,7 +344,7 @@ int psp_assoc_device_get_locked(const struct genl_split_ops *ops,psp_dev_put (psd); }else { - psd =psp_device_get_and_lock (genl_info_net (info), id); + psd =psp_device_get_and_lock (genl_info_net (info), id, false);if (IS_ERR (psd)) { err =PTR_ERR (psd); goto err_sock_put;
@@ -573,7 +587,7 @@ static int psp_nl_stats_get_dumpit_one(struct sk_buff *rsp, struct netlink_callback *cb, struct psp_dev *psd) { - if (psp_dev_check_access(psd, sock_net(rsp->sk))) + if (psp_dev_check_access(psd, sock_net(rsp->sk), false)) return 0; return psp_nl_stats_fill(psd, rsp, genl_info_dump(cb));
Signature · 1 line
2.52.0
PATCH v3 2/5 psp: add new netlink cmd for dev-assoc and dev-disassoc
In reply to Wei WangFrom: Wei Wang <[email protected]>
The main purpose of this cmd is to be able to associate a non-psp-capable device (e.g. veth) with a psp device.
One use case is if we create a pair of veth/netkit, and assign 1 end inside a netns, while leaving the other end within the default netns, with a real PSP device, e.g. netdevsim or a physical PSP-capable NIC. With this command, we could associate the veth/netkit inside the netns with PSP device, so the virtual device could act as PSP-capable device to initiate PSP connections, and performs PSP encryption/decryption on the real PSP device.
--- Documentation/netlink/specs/psp.yaml | 64 ++++++- include/net/psp/types.h | 15 ++ include/uapi/linux/psp.h | 13 ++ net/psp/psp-nl-gen.c | 32 ++++ net/psp/psp-nl-gen.h | 2 + net/psp/psp_main.c | 21 ++- net/psp/psp_nl.c | 270 ++++++++++++++++++++++++++- 7 files changed, 408 insertions(+), 9 deletions(-)
Documentation/netlink/specs/psp.yaml +63 -1
@@ -13,6 +13,17 @@ definitions: hdr0-aes-gmac-128, hdr0-aes-gmac-256] attribute-sets: + - + name: assoc-dev-info + attributes: + - + name: ifindex + doc: ifindex of an associated network device. + type: u32 + - + name: nsid + doc: Network namespace ID of the associated device. + type: s32 - name: dev attributes:
@@ -24,7 +35,9 @@ attribute-sets: min: 1 - name: ifindex - doc: ifindex of the main netdevice linked to the PSP device. + doc: | + ifindex of the main netdevice linked to the PSP device, + or the ifindex to associate with the PSP device. type: u32 - name: psp-versions-cap
@@ -38,6 +51,25 @@ attribute-sets: type: u32 enum: version enum-as-flags: true + - + name: assoc-list + doc: List of associated virtual devices. + type: nest + nested-attributes: assoc-dev-info + multi-attr: true + - + name: nsid + doc: Network namespace ID for the device to associate/disassociate. + type: s32 + - + name: by-association + doc: | + Flag indicating the PSP device is an associated device from a + different network namespace. + Present when in associated namespace, absent when in primary/host + namespace. + type: flag + - name: assoc attributes:
@@ -170,6 +202,8 @@ operations: - ifindex - psp-versions-cap - psp-versions-ena + - assoc-list + - by-association pre: psp-device-get-locked post: psp-device-unlock dump:
@@ -271,6 +305,34 @@ operations: post: psp-device-unlock dump: reply: *stats-all + - + name: dev-assoc + doc: Associate a network device with a PSP device. + attribute-set: dev + do: + request: + attributes: + - id + - ifindex + - nsid + reply: + attributes: [] + pre: psp-device-get-locked + post: psp-device-unlock + - + name: dev-disassoc + doc: Disassociate a network device from a PSP device. + attribute-set: dev + do: + request: + attributes: + - id + - ifindex + - nsid + reply: + attributes: [] + pre: psp-device-get-locked + post: psp-device-unlock mcast-groups: list:
include/net/psp/types.h +15 -0
@@ -5,6 +5,7 @@#include <linux/mutex.h> #include <linux/refcount.h> +#include <net/net_trackers.h> struct netlink_ext_ack ;
@@ -43,9 +44,22 @@ struct psp_dev_config {u32 versions; }; +/** +* struct psp_assoc_dev - wrapper for associated net_device +* @dev_list: list node for psp_dev::assoc_dev_list +* @assoc_dev: the associated net_device +* @dev_tracker: tracker for the net_device reference +*/ +struct psp_assoc_dev { +struct list_head dev_list; +struct net_device *assoc_dev; +netdevice_tracker dev_tracker; +}; +/** * struct psp_dev - PSP device struct * @main_netdev: original netdevice of this PSP device +* @assoc_dev_list: list of psp_assoc_dev entries associated with this PSP device * @ops: driver callbacks * @caps: device capabilities * @drv_priv: driver priv pointer
@@ -67,6 +81,7 @@ struct psp_dev_config {*/ struct psp_dev {struct net_device *main_netdev; +struct list_head assoc_dev_list;struct psp_dev_ops *ops;struct psp_dev_caps *caps;
include/uapi/linux/psp.h +13 -0
@@ -17,11 +17,22 @@ enum psp_version { PSP_VERSION_HDR0_AES_GMAC_256, }; +enum { +PSP_A_ASSOC_DEV_INFO_IFINDEX =1 , +PSP_A_ASSOC_DEV_INFO_NSID , + + __PSP_A_ASSOC_DEV_INFO_MAX, +PSP_A_ASSOC_DEV_INFO_MAX = (__PSP_A_ASSOC_DEV_INFO_MAX -1 ) +}; +enum {PSP_A_DEV_ID =1 ,PSP_A_DEV_IFINDEX ,PSP_A_DEV_PSP_VERSIONS_CAP ,PSP_A_DEV_PSP_VERSIONS_ENA , +PSP_A_DEV_ASSOC_LIST , +PSP_A_DEV_NSID , +PSP_A_DEV_BY_ASSOCIATION , __PSP_A_DEV_MAX,PSP_A_DEV_MAX = (__PSP_A_DEV_MAX -1 )
@@ -74,6 +85,8 @@ enum {PSP_CMD_RX_ASSOC ,PSP_CMD_TX_ASSOC ,PSP_CMD_GET_STATS , +PSP_CMD_DEV_ASSOC , +PSP_CMD_DEV_DISASSOC , __PSP_CMD_MAX,PSP_CMD_MAX = (__PSP_CMD_MAX -1 )
net/psp/psp-nl-gen.c +32 -0
@@ -53,6 +53,20 @@ static const struct nla_policy psp_get_stats_nl_policy[PSP_A_STATS_DEV_ID + 1] = [PSP_A_STATS_DEV_ID] = NLA_POLICY_MIN(NLA_U32, 1), }; +/* PSP_CMD_DEV_ASSOC - do */ +static const struct nla_policy psp_dev_assoc_nl_policy[PSP_A_DEV_NSID +1 ] = { + [PSP_A_DEV_ID ] =NLA_POLICY_MIN (NLA_U32 ,1 ), + [PSP_A_DEV_IFINDEX ] = { .type =NLA_U32 , }, + [PSP_A_DEV_NSID ] = { .type =NLA_S32 , }, +}; + +/* PSP_CMD_DEV_DISASSOC - do */ +static const struct nla_policy psp_dev_disassoc_nl_policy[PSP_A_DEV_NSID +1 ] = { + [PSP_A_DEV_ID ] =NLA_POLICY_MIN (NLA_U32 ,1 ), + [PSP_A_DEV_IFINDEX ] = { .type =NLA_U32 , }, + [PSP_A_DEV_NSID ] = { .type =NLA_S32 , }, +}; +/* Ops table for psp */ static const struct genl_split_ops psp_nl_ops[] = { {
@@ -119,6 +133,24 @@ static const struct genl_split_ops psp_nl_ops[] = { .dumpit = psp_nl_get_stats_dumpit, .flags = GENL_CMD_CAP_DUMP, }, + { + .cmd = PSP_CMD_DEV_ASSOC, + .pre_doit = psp_device_get_locked, + .doit = psp_nl_dev_assoc_doit, + .post_doit = psp_device_unlock, + .policy = psp_dev_assoc_nl_policy, + .maxattr = PSP_A_DEV_NSID, + .flags = GENL_CMD_CAP_DO, + }, + { + .cmd = PSP_CMD_DEV_DISASSOC, + .pre_doit = psp_device_get_locked, + .doit = psp_nl_dev_disassoc_doit, + .post_doit = psp_device_unlock, + .policy = psp_dev_disassoc_nl_policy, + .maxattr = PSP_A_DEV_NSID, + .flags = GENL_CMD_CAP_DO, + }, }; static const struct genl_multicast_group psp_nl_mcgrps[] = {
net/psp/psp-nl-gen.h +2 -0
@@ -33,6 +33,8 @@ int psp_nl_rx_assoc_doit(struct sk_buff *skb, struct genl_info *info);int psp_nl_tx_assoc_doit (struct sk_buff *skb,struct genl_info *info);int psp_nl_get_stats_doit (struct sk_buff *skb,struct genl_info *info);int psp_nl_get_stats_dumpit (struct sk_buff *skb,struct netlink_callback *cb); +int psp_nl_dev_assoc_doit (struct sk_buff *skb,struct genl_info *info); +int psp_nl_dev_disassoc_doit (struct sk_buff *skb,struct genl_info *info);enum {PSP_NLGRP_MGMT ,
net/psp/psp_main.c +20 -1
@@ -37,8 +37,18 @@ struct mutex psp_devs_lock;*/ int psp_dev_check_access (struct psp_dev *psd,struct net *net,bool admin) { +struct psp_assoc_dev *entry; +if (dev_net (psd->main_netdev) == net)return 0 ; + +if (!admin) { +list_for_each_entry (entry, &psd->assoc_dev_list, dev_list) { +if (dev_net (entry->assoc_dev) == net) +return 0 ; + } + } +return -ENOENT ; }
@@ -74,6 +84,7 @@ psp_dev_create(struct net_device *netdev,return ERR_PTR (-ENOMEM ); psd->main_netdev = netdev; +INIT_LIST_HEAD (&psd->assoc_dev_list); psd->ops = psd_ops; psd->caps = psd_caps; psd->drv_priv = priv_ptr;
@@ -121,6 +132,7 @@ void psp_dev_free(struct psp_dev *psd)*/ void psp_dev_unregister (struct psp_dev *psd) { +struct psp_assoc_dev *entry, *entry_tmp;struct psp_assoc *pas, *next;mutex_lock (&psp_devs_lock);
@@ -140,6 +152,14 @@ void psp_dev_unregister(struct psp_dev *psd)list_for_each_entry_safe (pas, next, &psd->stale_assocs, assocs_list)psp_dev_tx_key_del (psd, pas); +list_for_each_entry_safe (entry, entry_tmp, &psd->assoc_dev_list, + dev_list) { +list_del (&entry->dev_list); +rcu_assign_pointer (entry->assoc_dev->psp_dev,NULL ); +netdev_put (entry->assoc_dev, &entry->dev_tracker); +kfree (entry); + } +rcu_assign_pointer (psd->main_netdev->psp_dev,NULL ); psd->ops =NULL ;
@@ -361,5 +381,4 @@ static int __init psp_init(void)return genl_register_family (&psp_nl_family); } -subsys_initcall (psp_init);
net/psp/psp_nl.c +263 -7
335 lines not on this page · raw message
Signature · 1 line
2.52.0
PATCH v3 3/5 psp: add a new netdev event for dev unregister
In reply to Wei WangFrom: Wei Wang <[email protected]>
Add a new netdev event for dev unregister and handle the removal of this dev from psp->assoc_dev_list.
--- net/psp/psp_main.c | 64 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)
net/psp/psp_main.c +63 -1
@@ -375,10 +375,72 @@ int psp_dev_rcv(struct sk_buff *skb, u16 dev_id, u8 generation, bool strip_icv) }EXPORT_SYMBOL (psp_dev_rcv); +static void psp_dev_disassoc_one (struct psp_dev *psd,struct net_device *dev) +{ +struct psp_assoc_dev *entry, *tmp; + +list_for_each_entry_safe (entry, tmp, &psd->assoc_dev_list, dev_list) { +if (entry->assoc_dev == dev) { +list_del (&entry->dev_list); +rcu_assign_pointer (entry->assoc_dev->psp_dev,NULL ); +netdev_put (entry->assoc_dev, &entry->dev_tracker); +kfree (entry); +return ; + } + } +} + +static int psp_netdev_event (struct notifier_block *nb,unsigned long event, +void *ptr) +{ +struct net_device *dev =netdev_notifier_info_to_dev (ptr); +struct psp_dev *psd; + +if (event !=NETDEV_UNREGISTER ) +return NOTIFY_DONE ; + +rcu_read_lock (); + psd =rcu_dereference (dev->psp_dev); +if (psd &&psp_dev_tryget (psd)) { +rcu_read_unlock (); +mutex_lock (&psd->lock); +psp_dev_disassoc_one (psd, dev); +mutex_unlock (&psd->lock); +psp_dev_put (psd); + }else { +rcu_read_unlock (); + } + +return NOTIFY_DONE ; +} + +static struct notifier_block psp_netdev_notifier = { + .notifier_call = psp_netdev_event, +}; +static int __init psp_init (void ) { +int err; +mutex_init (&psp_devs_lock); + err =register_netdevice_notifier (&psp_netdev_notifier); +if (err) +return err; + + err =genl_register_family (&psp_nl_family); +if (err) { +unregister_netdevice_notifier (&psp_netdev_notifier); +return err; + } + +return 0 ; +} -return genl_register_family (&psp_nl_family); +static void __exit psp_exit(void) +{ +genl_unregister_family (&psp_nl_family); +unregister_netdevice_notifier (&psp_netdev_notifier); } +subsys_initcall (psp_init); +module_exit (psp_exit);
Signature · 1 line
2.52.0
PATCH v3 4/5 selftests/net: Add bpf skb forwarding program
In reply to Wei WangFrom: Wei Wang <[email protected]>
Add nk_redirect.bpf.c, a BPF program that forwards skbs matching some IPv6 prefix received on eth0 ifindex to a specified dev ifindex. bpf_redirect_neigh() is used to make sure neighbor lookup is performed and proper MAC addr is being used.
--- .../drivers/net/hw/nk_redirect.bpf.c | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tools/testing/selftests/drivers/net/hw/nk_redirect.bpf.c
tools/testing/selftests/drivers/net/hw/nk_redirect.bpf.c new file +60 -0
@@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* BPF program for redirecting traffic using bpf_redirect_neigh(). +* Unlike bpf_redirect() which preserves L2 headers, bpf_redirect_neigh() +* performs neighbor lookup and fills in the correct L2 addresses for the +* target interface. This is necessary when redirecting across different +* device types (e.g., from netdevsim to netkit). +*/ +#include <linux/bpf.h> +#include <linux/pkt_cls.h> +#include <linux/if_ether.h> +#include <linux/ipv6.h> +#include <linux/in6.h> +#include <bpf/bpf_endian.h> +#include <bpf/bpf_helpers.h> + +#define TC_ACT_OK 0 +#define ETH_P_IPV6 0x86DD + +#define ctx_ptr (field) ((void *)(long)(field)) + +#define v6_p64_equal (a, b) (a.s6_addr32[0] == b.s6_addr32[0] && \ + a.s6_addr32[1] == b.s6_addr32[1]) + +volatile __u32 redirect_ifindex; +volatile __u8 ipv6_prefix[16 ]; + +SEC("tc/ingress") +int tc_redirect (struct __sk_buff *skb) +{ +void *data_end =ctx_ptr (skb->data_end); +void *data =ctx_ptr (skb->data); +struct in6_addr *match_prefix; +struct ipv6hdr *ip6h; +struct ethhdr *eth; + + match_prefix = (struct in6_addr *)ipv6_prefix; + +if (skb->protocol !=bpf_htons (ETH_P_IPV6 )) +return TC_ACT_OK ; + + eth = data; +if ((void *)(eth +1 ) > data_end) +return TC_ACT_OK ; + + ip6h = data +sizeof (struct ethhdr ); +if ((void *)(ip6h +1 ) > data_end) +return TC_ACT_OK ; + +if (!v6_p64_equal (ip6h->daddr, (*match_prefix))) +return TC_ACT_OK ; + +/* +* Use bpf_redirect_neigh() to perform neighbor lookup and fill in +* correct L2 addresses for the target interface. +*/ +return bpf_redirect_neigh (redirect_ifindex,NULL ,0 ,0 ); +} + +char __license[] SEC("license") = "GPL";
Signature · 1 line
2.52.0
PATCH v3 5/5 selftest/net: psp: Add test for dev-assoc/disassoc
In reply to Wei WangFrom: Wei Wang <[email protected]>
Add a new param to NetDrvContEnv to add an additional bpf redirect program on nk_host to redirect traffic to the psp_dev_local. The topology looks like this:
Host NS: psp_dev_local <---> nk_host
| |
| | (netkit pair)
| |
Remote NS: psp_dev_peer Guest NS: nk_guest
(responder) (PSP tests)Add following tests for dev-assoc/dev-disassoc functionality:
1. Test the output of ./tools/net/ynl/pyynl/cli.py --spec Documentation/netlink/specs/psp.yaml --dump dev-get in both default and the guest netns.
2. Test the case where we associate netkit with psp_dev_local, and send PSP traffic from nk_guest to psp_dev_peer in 2 different netns.
3. Test to make sure the key rotation notification is sent to the netns for associated dev as well
4. Test to make sure the dev change notification is sent to the netns for associated dev as well
5. Test the deletion of nk_guest in client netns, and proper cleanup in the assoc-list for psp dev.
--- .../selftests/drivers/net/lib/py/env.py | 54 ++- tools/testing/selftests/drivers/net/psp.py | 387 +++++++++++++++++- 2 files changed, 433 insertions(+), 8 deletions(-)
tools/testing/selftests/drivers/net/lib/py/env.py +53 -1
@@ -2,6 +2,7 @@ import ipaddress import os +import re import time import json from pathlib import Path
@@ -327,7 +328,7 @@ class NetDrvContEnv(NetDrvEpEnv): +---------------+ """ - def __init__(self, src_path, rxqueues=1, **kwargs): + def __init__(self, src_path, rxqueues=1, install_tx_redirect_bpf=False, **kwargs): self.netns = None self._nk_host_ifname = None self._nk_guest_ifname = None
@@ -338,6 +339,8 @@ class NetDrvContEnv(NetDrvEpEnv): self._init_ns_attached = False self._old_fwd = None self._old_accept_ra = None + self._nk_host_tc_attached = False + self._nk_host_bpf_prog_pref = None super().__init__(src_path, **kwargs)
@@ -388,7 +391,13 @@ class NetDrvContEnv(NetDrvEpEnv): self._setup_ns() self._attach_bpf() + if install_tx_redirect_bpf: + self._attach_tx_redirect_bpf() + def __del__(self): + if self._nk_host_tc_attached: + cmd(f"tc filter del dev {self._nk_host_ifname} ingress pref {self._nk_host_bpf_prog_pref}", fail=False) + self._nk_host_tc_attached = False if self._tc_attached: cmd(f"tc filter del dev {self.ifname} ingress pref {self._bpf_prog_pref}") self._tc_attached = False
@@ -496,3 +505,46 @@ class NetDrvContEnv(NetDrvEpEnv): value = ipv6_bytes + ifindex_bytes value_hex = ' '.join(f'{b:02x}' for b in value) bpftool(f"map update id {bss_map_id} key hex 00 00 00 00 value hex {value_hex}") + + def _attach_tx_redirect_bpf(self): + """ + Attach BPF program on nk_host ingress to redirect TX traffic. + + Packets from nk_guest destined for the nsim network arrive at nk_host + via the netkit pair. This BPF program redirects them to the physical + interface so they can reach the remote peer. + """ + bpf_obj = self.test_dir / "nk_redirect.bpf.o" + if not bpf_obj.exists(): + raise KsftSkipEx("BPF prog nk_redirect.bpf.o not found") + + cmd(f"tc qdisc add dev {self._nk_host_ifname} clsact") + + cmd(f"tc filter add dev {self._nk_host_ifname} ingress bpf obj {bpf_obj} sec tc/ingress direct-action") + self._nk_host_tc_attached = True + + tc_info = cmd(f"tc filter show dev {self._nk_host_ifname} ingress").stdout + match = re.search(r'pref (\d+).*nk_redirect\.bpf.*id (\d+)', tc_info) + if not match: + raise Exception("Failed to get TX redirect BPF prog ID") + self._nk_host_bpf_prog_pref = int(match.group(1)) + nk_host_bpf_prog_id = int(match.group(2)) + + prog_info = bpftool(f"prog show id {nk_host_bpf_prog_id}", json=True) + map_ids = prog_info.get("map_ids", []) + + bss_map_id = None + for map_id in map_ids: + map_info = bpftool(f"map show id {map_id}", json=True) + if map_info.get("name").endswith("bss"): + bss_map_id = map_id + + if bss_map_id is None: + raise Exception("Failed to find TX redirect BPF .bss map") + + ipv6_addr = ipaddress.IPv6Address(self.nsim_v6_pfx) + ipv6_bytes = ipv6_addr.packed + ifindex_bytes = self.ifindex.to_bytes(4, byteorder='little') + value = ipv6_bytes + ifindex_bytes + value_hex = ' '.join(f'{b:02x}' for b in value) + bpftool(f"map update id {bss_map_id} key hex 00 00 00 00 value hex {value_hex}")
tools/testing/selftests/drivers/net/psp.py +380 -7
434 lines not on this page · raw message
Signature · 1 line
2.52.0
Jakub Kicinski
maintainerRe: [PATCH v3 net-next 5/5] selftest/net: psp: Add test for dev-assoc/disassoc
tools/testing/selftests/drivers/net/psp.py def ipver_test_builder(name, test_func, ipver): · line 931
Quoted 11 lines · On Mon, 9 Mar 2026 11:34:53 -0700 Wei Wang wrote:
tools/testing/selftests/drivers/net/psp.py +10
-1- with NetDrvEpEnv(__file__) as cfg: + # Use a different prefix for netkit guest to avoid conflict with dev prefix + nk_v6_pfx = "2001:db9::" + + # Set LOCAL_PREFIX_V6 to a DIFFERENT prefix than the dev prefix to avoid BPF + # redirecting psp_responder traffic. The BPF only redirects traffic + # matching LOCAL_PREFIX_V6, so dev traffic (2001:db8::) won't be affected. + if "LOCAL_PREFIX_V6" not in os.environ: + os.environ["LOCAL_PREFIX_V6"] = nk_v6_pfx + + with NetDrvContEnv(__file__, install_tx_redirect_bpf=True) as cfg:
NETKIT needs to be added to the driver/net's config (it's only in drivers/net/hw/config now)
Can we also add some code to handle NetDrvContEnv() creation failing and falling back to NetDrvEpEnv() ? Skipping just the test cases that need cont?
Last but not least let's use variants instead of the test builder?
Signature · 1 line
pw-bot: cr
Willem de Bruijn
maintainerRe: [PATCH v3 net-next 3/5] psp: add a new netdev event for dev unregister
In reply to Wei WangQuoted 59 lines · Wei Wang
From: Wei Wang <[email protected]>
Add a new netdev event for dev unregister and handle the removal of this dev from
psp->assoc_dev_list.Signed-off-by Wei Wang <[email protected]>--- net/psp/psp_main.c | 64 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)net/psp/psp_main.c +41
-0@@ -375,10 +375,72 @@ int psp_dev_rcv(struct sk_buff *skb, u16 dev_id, u8 generation, bool strip_icv) }EXPORT_SYMBOL (psp_dev_rcv); +static void psp_dev_disassoc_one (struct psp_dev *psd,struct net_device *dev) +{ +struct psp_assoc_dev *entry, *tmp; + +list_for_each_entry_safe (entry, tmp, &psd->assoc_dev_list, dev_list) { +if (entry->assoc_dev == dev) { +list_del (&entry->dev_list); +rcu_assign_pointer (entry->assoc_dev->psp_dev,NULL ); +netdev_put (entry->assoc_dev, &entry->dev_tracker); +kfree (entry); +return ; + } + } +} + +static int psp_netdev_event (struct notifier_block *nb,unsigned long event, +void *ptr) +{ +struct net_device *dev =netdev_notifier_info_to_dev (ptr); +struct psp_dev *psd; + +if (event !=NETDEV_UNREGISTER ) +return NOTIFY_DONE ; + +rcu_read_lock (); + psd =rcu_dereference (dev->psp_dev); +if (psd &&psp_dev_tryget (psd)) { +rcu_read_unlock (); +mutex_lock (&psd->lock); +psp_dev_disassoc_one (psd, dev); +mutex_unlock (&psd->lock); +psp_dev_put (psd); + }else { +rcu_read_unlock (); + } + +return NOTIFY_DONE ; +} + +static struct notifier_block psp_netdev_notifier = { + .notifier_call = psp_netdev_event,
net/psp/psp_main.c int psp_dev_rcv(struct sk_buff *skb, u16 dev_id, u8 generation, bool strip_icv) · line 428
Quoted 10 lines
net/psp/psp_main.c +7
-0+}; +static int __init psp_init (void ) { +int err; +mutex_init (&psp_devs_lock); + err =register_netdevice_notifier (&psp_netdev_notifier); +if (err) +return err;
Defer this until an associated device is actually created?
In many installations it won't be and this notifier won't be needed.
Quoted 9 lines
net/psp/psp_main.c +9
-0+ + err =genl_register_family (&psp_nl_family); +if (err) { +unregister_netdevice_notifier (&psp_netdev_notifier); +return err; + } + +return 0 ; +}
Re: [PATCH v3 net-next 2/5] psp: add new netlink cmd for dev-assoc and dev-disassoc
In reply to Wei WangQuoted 12 lines · Wei Wang
From: Wei Wang <[email protected]>
The main purpose of this cmd is to be able to associate a non-psp-capable device (e.g. veth) with a psp device.
One use case is if we create a pair of veth/netkit, and assign 1 end inside a netns, while leaving the other end within the default netns, with a real PSP device, e.g. netdevsim or a physical PSP-capable NIC. With this command, we could associate the veth/netkit inside the netns with PSP device, so the virtual device could act as PSP-capable device to initiate PSP connections, and performs PSP encryption/decryption on the real PSP device.
Quoted 1 line
Signed-off-by Wei Wang <[email protected]>
We'll need to follow in your footsteps for TCP devmem + netkit. I wonder if it is possible to decouple this API from PSP?
I have a hack POC that works similarly to the psp associated dev list here, but is implicit. It teaches the devmem TX path to allow skbs land on netkit_xmit() when that nk has been leased a queue from a device that has the support needed (namely, netmem_tx)... but I expect that if there is this explicit API, it'll probably be best for devmem to follow suite instead of the implicit approach.
Best,
Bobby
Daniel Zahka
maintainerRe: [PATCH v3 net-next 2/5] psp: add new netlink cmd for dev-assoc and dev-disassoc
In reply to Wei WangQuoted 10 lines · Wei Wang
+int
psp_nl_dev_assoc_doit(struct sk_buff *skb, struct genl_info *info)net/psp/psp_nl.c +9
-0+{ +struct psp_dev *psd = info->user_ptr[0 ]; +struct psp_assoc_dev *psp_assoc_dev; +struct net_device *assoc_dev; +u32 assoc_ifindex; +struct sk_buff *rsp; +struct net *net; +int nsid; +
net/psp/psp_nl.c int psp_nl_key_rotate_doit(struct sk_buff *skb, struct genl_info *info) · line 445
Quoted 10 lines
net/psp/psp_nl.c +10
-0+if (GENL_REQ_ATTR_CHECK (info,PSP_A_DEV_IFINDEX ) || +GENL_REQ_ATTR_CHECK (info,PSP_A_DEV_NSID )) +return -EINVAL ; + + nsid =nla_get_s32 (info->attrs[PSP_A_DEV_NSID ]); + net =get_net_ns_by_id (genl_info_net (info), nsid); +if (!net) { +NL_SET_BAD_ATTR (info->extack, info->attrs[PSP_A_DEV_NSID ]); +return -EINVAL ; + }
hmm, well I guess I still have the same comment from v2. If assoc_dev is in the same netns as genl_info_net(info), then userspace would need to create a self-referencing nsid to link them together. It might be a better uapi to change PSP_A_DEV_NSID to an optional attribute, and if not present then look for PSP_A_DEV_IFINDEX inside of genl_info_net(info).
Daniel Zahka
maintainerRe: [PATCH v3 net-next 2/5] psp: add new netlink cmd for dev-assoc and dev-disassoc
In reply to Wei WangQuoted 14 lines · Wei Wang
net/psp/psp_nl.c +1
-2@@ -131,8 +263,7 @@ void psp_nl_notify_dev(struct psp_dev *psd, u32 cmd)struct genl_info info;struct sk_buff *ntf; -if (!genl_has_listeners (&psp_nl_family,dev_net (psd->main_netdev), -PSP_NLGRP_MGMT )) +if (!psp_nl_has_listeners_any_ns (psd,PSP_NLGRP_MGMT ))return ; ntf =genlmsg_new (GENLMSG_DEFAULT_SIZE ,GFP_KERNEL );@@ -140,13 +271,13 @@ void psp_nl_notify_dev(struct psp_dev *psd, u32 cmd)return ;genl_info_init_ntf (&info, &psp_nl_family, cmd);
net/psp/psp_nl.c void psp_nl_notify_dev(struct psp_dev *psd, u32 cmd) · line 281
Quoted 10 lines
net/psp/psp_nl.c +2
-2+genl_info_net_set (&info,dev_net (psd->main_netdev));if (psp_nl_dev_fill (psd, ntf, &info)) {nlmsg_free (ntf);return ; } -genlmsg_multicast_netns (&psp_nl_family,dev_net (psd->main_netdev), ntf, -0 ,PSP_NLGRP_MGMT ,GFP_KERNEL ); +psp_nl_multicast_all_ns (psd, ntf,PSP_NLGRP_MGMT ); }
I don't think this will work correctly when there are listeners outside of dev_net(psd->main_netdev). psp_nl_dev_fill() will prepare a notification containing the unfiltered assoc list, but then that will be broadcast out to all listeners regardless of netns, so those listeners will see peer nsids relative to a different netns.
Re: [PATCH v3 net-next 2/5] psp: add new netlink cmd for dev-assoc and dev-disassoc
In reply to Bobby EshlemanQuoted 19 lines · Bobby Eshleman
Quoted 12 lines · Wei Wang
From: Wei Wang <[email protected]>
The main purpose of this cmd is to be able to associate a non-psp-capable device (e.g. veth) with a psp device.
One use case is if we create a pair of veth/netkit, and assign 1 end inside a netns, while leaving the other end within the default netns, with a real PSP device, e.g. netdevsim or a physical PSP-capable NIC. With this command, we could associate the veth/netkit inside the netns with PSP device, so the virtual device could act as PSP-capable device to initiate PSP connections, and performs PSP encryption/decryption on the real PSP device.Quoted 1 line
Signed-off-by Wei Wang <[email protected]>We'll need to follow in your footsteps for TCP devmem + netkit. I wonder if it is possible to decouple this API from PSP?
Quoted 6 lines
I have a hack POC that works similarly to the psp associated dev list here, but is implicit. It teaches the devmem TX path to allow skbs land on
netkit_xmit()when that nk has been leased a queue from a device that has the support needed (namely,netmem_tx)... but I expect that if there is this explicit API, it'll probably be best for devmem to follow suite instead of the implicit approach.
Hmm...
The current PSP API looks like this for associating:./tools/net/ynl/cli.py \
--spec Documentation/netlink/specs/psp.yaml \
--do dev-assoc \
--json '{"id": 1, "assoc-ifindex": 2, "nsid": 0}'
I would guess what could be shared is the last line above where for PSP, it specifies a PSP dev id, the nk ifindex and nsid. Maybe the id could be a queue id as well?
But all these are defined in the specific psp.yaml for now. Where do you envision your devmem API will live?
Quoted 3 lines
Best,
Bobby
Re: [PATCH v3 net-next 2/5] psp: add new netlink cmd for dev-assoc and dev-disassoc
In reply to Daniel ZahkaQuoted 22 lines · Daniel Zahka
Quoted 18 lines · Wei Wang
+int
psp_nl_dev_assoc_doit(struct sk_buff *skb, struct genl_info *info)net/psp/psp_nl.c +17
-0+{ +struct psp_dev *psd = info->user_ptr[0 ]; +struct psp_assoc_dev *psp_assoc_dev; +struct net_device *assoc_dev; +u32 assoc_ifindex; +struct sk_buff *rsp; +struct net *net; +int nsid; + +if (GENL_REQ_ATTR_CHECK (info,PSP_A_DEV_IFINDEX ) || +GENL_REQ_ATTR_CHECK (info,PSP_A_DEV_NSID )) +return -EINVAL ; + + nsid =nla_get_s32 (info->attrs[PSP_A_DEV_NSID ]); + net =get_net_ns_by_id (genl_info_net (info), nsid); +if (!net) { +NL_SET_BAD_ATTR (info->extack, info->attrs[PSP_A_DEV_NSID ]);
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ return -EINVAL; + }hmm, well I guess I still have the same comment from v2. If
assoc_devis in the same netns asgenl_info_net(info), then userspace would need to create a self-referencing nsid to link them together. It might be a better uapi to changePSP_A_DEV_NSIDto an optional attribute, and if not present then look forPSP_A_DEV_IFINDEXinside ofgenl_info_net(info).
Ack. I probably missed this in the previous round. Making NSID optional to just refer to the current user net-ns sounds good. Will update.
Re: [PATCH v3 net-next 2/5] psp: add new netlink cmd for dev-assoc and dev-disassoc
In reply to Daniel ZahkaQuoted 24 lines · Daniel Zahka
Quoted 20 lines · Wei Wang
net/psp/psp_nl.c +2
-2@@ -131,8 +263,7 @@ void psp_nl_notify_dev(struct psp_dev *psd, u32 cmd)struct genl_info info;struct sk_buff *ntf; -if (!genl_has_listeners (&psp_nl_family,dev_net (psd->main_netdev), -PSP_NLGRP_MGMT )) +if (!psp_nl_has_listeners_any_ns (psd,PSP_NLGRP_MGMT ))return ; ntf =genlmsg_new (GENLMSG_DEFAULT_SIZE ,GFP_KERNEL );@@ -140,13 +271,13 @@ void psp_nl_notify_dev(struct psp_dev *psd, u32 cmd)return ;genl_info_init_ntf (&info, &psp_nl_family, cmd); +genl_info_net_set (&info,dev_net (psd->main_netdev));if (psp_nl_dev_fill (psd, ntf, &info)) {nlmsg_free (ntf);return ; }
Quoted 10 lines
net/psp/psp_nl.c void psp_nl_notify_dev(struct psp_dev *psd, u32 cmd) · line 281
Quoted 4 lines
net/psp/psp_nl.c +1
-2-genlmsg_multicast_netns (&psp_nl_family,dev_net (psd->main_netdev), ntf, -0 ,PSP_NLGRP_MGMT ,GFP_KERNEL ); +psp_nl_multicast_all_ns (psd, ntf,PSP_NLGRP_MGMT ); }I don't think this will work correctly when there are listeners outside of
dev_net(psd->main_netdev).psp_nl_dev_fill()will prepare a notification containing the unfiltered assoc list, but then that will be broadcast out to all listeners regardless of netns, so those listeners will see peer nsids relative to a different netns.
Yea. That's true. I can't just set genl_info_net to dev_net(psd->main_netdev). And I have to compute nsid relative to the netns of the listener instead of just using the same passed in netns. Let me see how to fix this.
Re: [PATCH v3 net-next 3/5] psp: add a new netdev event for dev unregister
In reply to Willem de BruijnQuoted 74 lines · Willem de Bruijn
Quoted 59 lines · Wei Wang
From: Wei Wang <[email protected]>
Add a new netdev event for dev unregister and handle the removal of this dev from
psp->assoc_dev_list.Signed-off-by Wei Wang <[email protected]>--- net/psp/psp_main.c | 64 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-)net/psp/psp_main.c +41
-0@@ -375,10 +375,72 @@ int psp_dev_rcv(struct sk_buff *skb, u16 dev_id, u8 generation, bool strip_icv) }EXPORT_SYMBOL (psp_dev_rcv); +static void psp_dev_disassoc_one (struct psp_dev *psd,struct net_device *dev) +{ +struct psp_assoc_dev *entry, *tmp; + +list_for_each_entry_safe (entry, tmp, &psd->assoc_dev_list, dev_list) { +if (entry->assoc_dev == dev) { +list_del (&entry->dev_list); +rcu_assign_pointer (entry->assoc_dev->psp_dev,NULL ); +netdev_put (entry->assoc_dev, &entry->dev_tracker); +kfree (entry); +return ; + } + } +} + +static int psp_netdev_event (struct notifier_block *nb,unsigned long event, +void *ptr) +{ +struct net_device *dev =netdev_notifier_info_to_dev (ptr); +struct psp_dev *psd; + +if (event !=NETDEV_UNREGISTER ) +return NOTIFY_DONE ; + +rcu_read_lock (); + psd =rcu_dereference (dev->psp_dev); +if (psd &&psp_dev_tryget (psd)) { +rcu_read_unlock (); +mutex_lock (&psd->lock); +psp_dev_disassoc_one (psd, dev); +mutex_unlock (&psd->lock); +psp_dev_put (psd); + }else { +rcu_read_unlock (); + } + +return NOTIFY_DONE ; +} + +static struct notifier_block psp_netdev_notifier = { + .notifier_call = psp_netdev_event,net/psp/psp_main.c int psp_dev_rcv(struct sk_buff *skb, u16 dev_id, u8 generation, bool strip_icv) · line 428
Quoted 10 lines
net/psp/psp_main.c +7
-0+}; +static int __init psp_init (void ) { +int err; +mutex_init (&psp_devs_lock); + err =register_netdevice_notifier (&psp_netdev_notifier); +if (err) +return err;Defer this until an associated device is actually created?
Quoted 1 line
In many installations it won't be and this notifier won't be needed.
Ack. Thanks. Will fix in the next version.
Quoted 10 lines
Quoted 9 lines
net/psp/psp_main.c +9
-0+ + err =genl_register_family (&psp_nl_family); +if (err) { +unregister_netdevice_notifier (&psp_netdev_notifier); +return err; + } + +return 0 ; +}
Re: [PATCH v3 net-next 5/5] selftest/net: psp: Add test for dev-assoc/disassoc
In reply to Jakub KicinskiQuoted 17 lines · Jakub Kicinski
tools/testing/selftests/drivers/net/psp.py def ipver_test_builder(name, test_func, ipver): · line 931
Quoted 11 lines · On Mon, 9 Mar 2026 11:34:53 -0700 Wei Wang wrote:
tools/testing/selftests/drivers/net/psp.py +10
-1- with NetDrvEpEnv(__file__) as cfg: + # Use a different prefix for netkit guest to avoid conflict with dev prefix + nk_v6_pfx = "2001:db9::" + + # Set LOCAL_PREFIX_V6 to a DIFFERENT prefix than the dev prefix to avoid BPF + # redirecting psp_responder traffic. The BPF only redirects traffic + # matching LOCAL_PREFIX_V6, so dev traffic (2001:db8::) won't be affected. + if "LOCAL_PREFIX_V6" not in os.environ: + os.environ["LOCAL_PREFIX_V6"] = nk_v6_pfx + + with NetDrvContEnv(__file__, install_tx_redirect_bpf=True) as cfg:NETKIT needs to be added to the driver/net's config (it's only in
drivers/net/hw/confignow)
Quoted 7 lines
Can we also add some code to handle
NetDrvContEnv()creation failing and falling back toNetDrvEpEnv()? Skipping just the test cases that need cont?Last but not least let's use variants instead of the test builder? --
pw-bot: cr
Ack on all 3. Fixing them in the next version.