* [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room
@ 2024-12-19 17:39 Daniel Borkmann
2024-12-19 17:39 ` [PATCH bpf-next 2/3] netkit: Add add netkit {head,tail}room to rt_link.yaml Daniel Borkmann
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Daniel Borkmann @ 2024-12-19 17:39 UTC (permalink / raw)
To: martin.lau; +Cc: razor, pabeni, bpf, netdev
Allow the user to configure needed_{head,tail}room for both netkit
devices. The idea is similar to 163e529200af ("veth: implement
ndo_set_rx_headroom") with the difference that the two parameters
can be specified upon device creation. By default the current behavior
stays as is which is needed_{head,tail}room is 0.
In case of Cilium, for example, the netkit devices are not enslaved
into a bridge or openvswitch device (rather, BPF-based redirection
is used out of tcx), and as such these parameters are not propagated
into the Pod's netns via peer device.
Given Cilium can run in vxlan/geneve tunneling mode (needed_headroom)
and/or be used in combination with WireGuard (needed_{head,tail}room),
allow the Cilium CNI plugin to specify these two upon netkit device
creation.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Nikolay Aleksandrov <razor@blackwall.org>
---
drivers/net/netkit.c | 66 +++++++++++++++++++-----------
include/uapi/linux/if_link.h | 2 +
tools/include/uapi/linux/if_link.h | 2 +
3 files changed, 47 insertions(+), 23 deletions(-)
diff --git a/drivers/net/netkit.c b/drivers/net/netkit.c
index c1d881dc6409..fb290dcfbc96 100644
--- a/drivers/net/netkit.c
+++ b/drivers/net/netkit.c
@@ -338,6 +338,7 @@ static int netkit_new_link(struct net *peer_net, struct net_device *dev,
enum netkit_scrub scrub_peer = NETKIT_SCRUB_DEFAULT;
enum netkit_mode mode = NETKIT_L3;
unsigned char ifname_assign_type;
+ u16 headroom = 0, tailroom = 0;
struct ifinfomsg *ifmp = NULL;
struct net_device *peer;
char ifname[IFNAMSIZ];
@@ -371,6 +372,10 @@ static int netkit_new_link(struct net *peer_net, struct net_device *dev,
if (err < 0)
return err;
}
+ if (data[IFLA_NETKIT_HEADROOM])
+ headroom = nla_get_u16(data[IFLA_NETKIT_HEADROOM]);
+ if (data[IFLA_NETKIT_TAILROOM])
+ tailroom = nla_get_u16(data[IFLA_NETKIT_TAILROOM]);
}
if (ifmp && tbp[IFLA_IFNAME]) {
@@ -390,6 +395,14 @@ static int netkit_new_link(struct net *peer_net, struct net_device *dev,
return PTR_ERR(peer);
netif_inherit_tso_max(peer, dev);
+ if (headroom) {
+ peer->needed_headroom = headroom;
+ dev->needed_headroom = headroom;
+ }
+ if (tailroom) {
+ peer->needed_tailroom = tailroom;
+ dev->needed_tailroom = tailroom;
+ }
if (mode == NETKIT_L2 && !(ifmp && tbp[IFLA_ADDRESS]))
eth_hw_addr_random(peer);
@@ -401,6 +414,7 @@ static int netkit_new_link(struct net *peer_net, struct net_device *dev,
nk->policy = policy_peer;
nk->scrub = scrub_peer;
nk->mode = mode;
+ nk->headroom = headroom;
bpf_mprog_bundle_init(&nk->bundle);
err = register_netdevice(peer);
@@ -426,6 +440,7 @@ static int netkit_new_link(struct net *peer_net, struct net_device *dev,
nk->policy = policy_prim;
nk->scrub = scrub_prim;
nk->mode = mode;
+ nk->headroom = headroom;
bpf_mprog_bundle_init(&nk->bundle);
err = register_netdevice(dev);
@@ -850,7 +865,18 @@ static int netkit_change_link(struct net_device *dev, struct nlattr *tb[],
struct net_device *peer = rtnl_dereference(nk->peer);
enum netkit_action policy;
struct nlattr *attr;
- int err;
+ int err, i;
+ struct {
+ u32 attr;
+ char *name;
+ } fixed_params[] = {
+ { IFLA_NETKIT_MODE, "operating mode" },
+ { IFLA_NETKIT_SCRUB, "scrubbing" },
+ { IFLA_NETKIT_PEER_SCRUB, "peer scrubbing" },
+ { IFLA_NETKIT_PEER_INFO, "peer info" },
+ { IFLA_NETKIT_HEADROOM, "headroom" },
+ { IFLA_NETKIT_TAILROOM, "tailroom" },
+ };
if (!nk->primary) {
NL_SET_ERR_MSG(extack,
@@ -858,28 +884,14 @@ static int netkit_change_link(struct net_device *dev, struct nlattr *tb[],
return -EACCES;
}
- if (data[IFLA_NETKIT_MODE]) {
- NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_MODE],
- "netkit link operating mode cannot be changed after device creation");
- return -EACCES;
- }
-
- if (data[IFLA_NETKIT_SCRUB]) {
- NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_SCRUB],
- "netkit scrubbing cannot be changed after device creation");
- return -EACCES;
- }
-
- if (data[IFLA_NETKIT_PEER_SCRUB]) {
- NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_PEER_SCRUB],
- "netkit scrubbing cannot be changed after device creation");
- return -EACCES;
- }
-
- if (data[IFLA_NETKIT_PEER_INFO]) {
- NL_SET_ERR_MSG_ATTR(extack, data[IFLA_NETKIT_PEER_INFO],
- "netkit peer info cannot be changed after device creation");
- return -EINVAL;
+ for (i = 0; i < ARRAY_SIZE(fixed_params); i++) {
+ attr = data[fixed_params[i].attr];
+ if (attr) {
+ NL_SET_ERR_MSG_ATTR_FMT(extack, attr,
+ "netkit link %s cannot be changed after device creation",
+ fixed_params[i].name);
+ return -EACCES;
+ }
}
if (data[IFLA_NETKIT_POLICY]) {
@@ -914,6 +926,8 @@ static size_t netkit_get_size(const struct net_device *dev)
nla_total_size(sizeof(u32)) + /* IFLA_NETKIT_PEER_SCRUB */
nla_total_size(sizeof(u32)) + /* IFLA_NETKIT_MODE */
nla_total_size(sizeof(u8)) + /* IFLA_NETKIT_PRIMARY */
+ nla_total_size(sizeof(u16)) + /* IFLA_NETKIT_HEADROOM */
+ nla_total_size(sizeof(u16)) + /* IFLA_NETKIT_TAILROOM */
0;
}
@@ -930,6 +944,10 @@ static int netkit_fill_info(struct sk_buff *skb, const struct net_device *dev)
return -EMSGSIZE;
if (nla_put_u32(skb, IFLA_NETKIT_SCRUB, nk->scrub))
return -EMSGSIZE;
+ if (nla_put_u16(skb, IFLA_NETKIT_HEADROOM, dev->needed_headroom))
+ return -EMSGSIZE;
+ if (nla_put_u16(skb, IFLA_NETKIT_TAILROOM, dev->needed_tailroom))
+ return -EMSGSIZE;
if (peer) {
nk = netkit_priv(peer);
@@ -947,6 +965,8 @@ static const struct nla_policy netkit_policy[IFLA_NETKIT_MAX + 1] = {
[IFLA_NETKIT_MODE] = NLA_POLICY_MAX(NLA_U32, NETKIT_L3),
[IFLA_NETKIT_POLICY] = { .type = NLA_U32 },
[IFLA_NETKIT_PEER_POLICY] = { .type = NLA_U32 },
+ [IFLA_NETKIT_HEADROOM] = { .type = NLA_U16 },
+ [IFLA_NETKIT_TAILROOM] = { .type = NLA_U16 },
[IFLA_NETKIT_SCRUB] = NLA_POLICY_MAX(NLA_U32, NETKIT_SCRUB_DEFAULT),
[IFLA_NETKIT_PEER_SCRUB] = NLA_POLICY_MAX(NLA_U32, NETKIT_SCRUB_DEFAULT),
[IFLA_NETKIT_PRIMARY] = { .type = NLA_REJECT,
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 2575e0cd9b48..2fa2c265dcba 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -1315,6 +1315,8 @@ enum {
IFLA_NETKIT_MODE,
IFLA_NETKIT_SCRUB,
IFLA_NETKIT_PEER_SCRUB,
+ IFLA_NETKIT_HEADROOM,
+ IFLA_NETKIT_TAILROOM,
__IFLA_NETKIT_MAX,
};
#define IFLA_NETKIT_MAX (__IFLA_NETKIT_MAX - 1)
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h
index 8516c1ccd57a..7e46ca4cd31b 100644
--- a/tools/include/uapi/linux/if_link.h
+++ b/tools/include/uapi/linux/if_link.h
@@ -1315,6 +1315,8 @@ enum {
IFLA_NETKIT_MODE,
IFLA_NETKIT_SCRUB,
IFLA_NETKIT_PEER_SCRUB,
+ IFLA_NETKIT_HEADROOM,
+ IFLA_NETKIT_TAILROOM,
__IFLA_NETKIT_MAX,
};
#define IFLA_NETKIT_MAX (__IFLA_NETKIT_MAX - 1)
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH bpf-next 2/3] netkit: Add add netkit {head,tail}room to rt_link.yaml
2024-12-19 17:39 [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Daniel Borkmann
@ 2024-12-19 17:39 ` Daniel Borkmann
2024-12-21 7:22 ` Nikolay Aleksandrov
2024-12-19 17:39 ` [PATCH bpf-next 3/3] selftests/bpf: Extend netkit tests to validate set {head,tail}room Daniel Borkmann
` (2 subsequent siblings)
3 siblings, 1 reply; 9+ messages in thread
From: Daniel Borkmann @ 2024-12-19 17:39 UTC (permalink / raw)
To: martin.lau; +Cc: razor, pabeni, bpf, netdev
Add netkit {head,tail}room attribute support to the rt_link.yaml spec file.
Example:
# ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/rt_link.yaml \
--do getlink --json '{"ifname": "nk0"}' --output-json | jq
[...]
"linkinfo": {
"kind": "netkit",
"data": {
}
},
[...]
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Nikolay Aleksandrov <razor@blackwall.org>
---
Documentation/netlink/specs/rt_link.yaml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/Documentation/netlink/specs/rt_link.yaml b/Documentation/netlink/specs/rt_link.yaml
index 9ffa13b77dcf..dbeae6b1c548 100644
--- a/Documentation/netlink/specs/rt_link.yaml
+++ b/Documentation/netlink/specs/rt_link.yaml
@@ -2166,6 +2166,12 @@ attribute-sets:
name: peer-scrub
type: u32
enum: netkit-scrub
+ -
+ name: headroom
+ type: u16
+ -
+ name: tailroom
+ type: u16
sub-messages:
-
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH bpf-next 3/3] selftests/bpf: Extend netkit tests to validate set {head,tail}room
2024-12-19 17:39 [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Daniel Borkmann
2024-12-19 17:39 ` [PATCH bpf-next 2/3] netkit: Add add netkit {head,tail}room to rt_link.yaml Daniel Borkmann
@ 2024-12-19 17:39 ` Daniel Borkmann
2024-12-21 7:22 ` Nikolay Aleksandrov
2024-12-20 2:23 ` [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Jakub Kicinski
2024-12-21 7:22 ` Nikolay Aleksandrov
3 siblings, 1 reply; 9+ messages in thread
From: Daniel Borkmann @ 2024-12-19 17:39 UTC (permalink / raw)
To: martin.lau; +Cc: razor, pabeni, bpf, netdev
Extend the netkit selftests to specify and validate the {head,tail}room
on the netdevice:
# ./vmtest.sh -- ./test_progs -t netkit
[...]
./test_progs -t netkit
[ 1.174147] bpf_testmod: loading out-of-tree module taints kernel.
[ 1.174585] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
[ 1.422307] tsc: Refined TSC clocksource calibration: 3407.983 MHz
[ 1.424511] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fc3e5084, max_idle_ns: 440795359833 ns
[ 1.428092] clocksource: Switched to clocksource tsc
#363 tc_netkit_basic:OK
#364 tc_netkit_device:OK
#365 tc_netkit_multi_links:OK
#366 tc_netkit_multi_opts:OK
#367 tc_netkit_neigh_links:OK
#368 tc_netkit_pkt_type:OK
#369 tc_netkit_scrub:OK
Summary: 7/0 PASSED, 0 SKIPPED, 0 FAILED
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Nikolay Aleksandrov <razor@blackwall.org>
---
.../selftests/bpf/prog_tests/tc_netkit.c | 31 ++++++++++++-------
.../selftests/bpf/progs/test_tc_link.c | 15 +++++++++
2 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/tc_netkit.c b/tools/testing/selftests/bpf/prog_tests/tc_netkit.c
index 151a4210028f..7e41dceec58d 100644
--- a/tools/testing/selftests/bpf/prog_tests/tc_netkit.c
+++ b/tools/testing/selftests/bpf/prog_tests/tc_netkit.c
@@ -14,6 +14,9 @@
#include "netlink_helpers.h"
#include "tc_helpers.h"
+#define NETKIT_HEADROOM 32
+#define NETKIT_TAILROOM 8
+
#define MARK 42
#define PRIO 0xeb9f
#define ICMP_ECHO 8
@@ -35,7 +38,7 @@ struct iplink_req {
};
static int create_netkit(int mode, int policy, int peer_policy, int *ifindex,
- bool same_netns, int scrub, int peer_scrub)
+ bool same_netns, int scrub, int peer_scrub, bool room)
{
struct rtnl_handle rth = { .fd = -1 };
struct iplink_req req = {};
@@ -63,6 +66,10 @@ static int create_netkit(int mode, int policy, int peer_policy, int *ifindex,
addattr32(&req.n, sizeof(req), IFLA_NETKIT_SCRUB, scrub);
addattr32(&req.n, sizeof(req), IFLA_NETKIT_PEER_SCRUB, peer_scrub);
addattr32(&req.n, sizeof(req), IFLA_NETKIT_MODE, mode);
+ if (room) {
+ addattr16(&req.n, sizeof(req), IFLA_NETKIT_HEADROOM, NETKIT_HEADROOM);
+ addattr16(&req.n, sizeof(req), IFLA_NETKIT_TAILROOM, NETKIT_TAILROOM);
+ }
addattr_nest_end(&req.n, data);
addattr_nest_end(&req.n, linkinfo);
@@ -185,7 +192,7 @@ void serial_test_tc_netkit_basic(void)
err = create_netkit(NETKIT_L2, NETKIT_PASS, NETKIT_PASS,
&ifindex, false, NETKIT_SCRUB_DEFAULT,
- NETKIT_SCRUB_DEFAULT);
+ NETKIT_SCRUB_DEFAULT, false);
if (err)
return;
@@ -300,7 +307,7 @@ static void serial_test_tc_netkit_multi_links_target(int mode, int target)
err = create_netkit(mode, NETKIT_PASS, NETKIT_PASS,
&ifindex, false, NETKIT_SCRUB_DEFAULT,
- NETKIT_SCRUB_DEFAULT);
+ NETKIT_SCRUB_DEFAULT, false);
if (err)
return;
@@ -429,7 +436,7 @@ static void serial_test_tc_netkit_multi_opts_target(int mode, int target)
err = create_netkit(mode, NETKIT_PASS, NETKIT_PASS,
&ifindex, false, NETKIT_SCRUB_DEFAULT,
- NETKIT_SCRUB_DEFAULT);
+ NETKIT_SCRUB_DEFAULT, false);
if (err)
return;
@@ -544,7 +551,7 @@ void serial_test_tc_netkit_device(void)
err = create_netkit(NETKIT_L3, NETKIT_PASS, NETKIT_PASS,
&ifindex, true, NETKIT_SCRUB_DEFAULT,
- NETKIT_SCRUB_DEFAULT);
+ NETKIT_SCRUB_DEFAULT, false);
if (err)
return;
@@ -656,7 +663,7 @@ static void serial_test_tc_netkit_neigh_links_target(int mode, int target)
err = create_netkit(mode, NETKIT_PASS, NETKIT_PASS,
&ifindex, false, NETKIT_SCRUB_DEFAULT,
- NETKIT_SCRUB_DEFAULT);
+ NETKIT_SCRUB_DEFAULT, false);
if (err)
return;
@@ -734,7 +741,7 @@ static void serial_test_tc_netkit_pkt_type_mode(int mode)
err = create_netkit(mode, NETKIT_PASS, NETKIT_PASS,
&ifindex, true, NETKIT_SCRUB_DEFAULT,
- NETKIT_SCRUB_DEFAULT);
+ NETKIT_SCRUB_DEFAULT, false);
if (err)
return;
@@ -799,7 +806,7 @@ void serial_test_tc_netkit_pkt_type(void)
serial_test_tc_netkit_pkt_type_mode(NETKIT_L3);
}
-static void serial_test_tc_netkit_scrub_type(int scrub)
+static void serial_test_tc_netkit_scrub_type(int scrub, bool room)
{
LIBBPF_OPTS(bpf_netkit_opts, optl);
struct test_tc_link *skel;
@@ -807,7 +814,7 @@ static void serial_test_tc_netkit_scrub_type(int scrub)
int err, ifindex;
err = create_netkit(NETKIT_L2, NETKIT_PASS, NETKIT_PASS,
- &ifindex, false, scrub, scrub);
+ &ifindex, false, scrub, scrub, room);
if (err)
return;
@@ -842,6 +849,8 @@ static void serial_test_tc_netkit_scrub_type(int scrub)
ASSERT_EQ(skel->bss->seen_tc8, true, "seen_tc8");
ASSERT_EQ(skel->bss->mark, scrub == NETKIT_SCRUB_NONE ? MARK : 0, "mark");
ASSERT_EQ(skel->bss->prio, scrub == NETKIT_SCRUB_NONE ? PRIO : 0, "prio");
+ ASSERT_EQ(skel->bss->headroom, room ? NETKIT_HEADROOM : 0, "headroom");
+ ASSERT_EQ(skel->bss->tailroom, room ? NETKIT_TAILROOM : 0, "tailroom");
cleanup:
test_tc_link__destroy(skel);
@@ -852,6 +861,6 @@ static void serial_test_tc_netkit_scrub_type(int scrub)
void serial_test_tc_netkit_scrub(void)
{
- serial_test_tc_netkit_scrub_type(NETKIT_SCRUB_DEFAULT);
- serial_test_tc_netkit_scrub_type(NETKIT_SCRUB_NONE);
+ serial_test_tc_netkit_scrub_type(NETKIT_SCRUB_DEFAULT, false);
+ serial_test_tc_netkit_scrub_type(NETKIT_SCRUB_NONE, true);
}
diff --git a/tools/testing/selftests/bpf/progs/test_tc_link.c b/tools/testing/selftests/bpf/progs/test_tc_link.c
index 10d825928499..630f12e51b07 100644
--- a/tools/testing/selftests/bpf/progs/test_tc_link.c
+++ b/tools/testing/selftests/bpf/progs/test_tc_link.c
@@ -8,6 +8,7 @@
#include <linux/if_packet.h>
#include <bpf/bpf_endian.h>
#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_core_read.h>
char LICENSE[] SEC("license") = "GPL";
@@ -27,6 +28,7 @@ bool seen_host;
bool seen_mcast;
int mark, prio;
+unsigned short headroom, tailroom;
SEC("tc/ingress")
int tc1(struct __sk_buff *skb)
@@ -104,11 +106,24 @@ int tc7(struct __sk_buff *skb)
return TCX_PASS;
}
+struct sk_buff {
+ struct net_device *dev;
+};
+
+struct net_device {
+ unsigned short needed_headroom;
+ unsigned short needed_tailroom;
+};
+
SEC("tc/egress")
int tc8(struct __sk_buff *skb)
{
+ struct net_device *dev = BPF_CORE_READ((struct sk_buff *)skb, dev);
+
seen_tc8 = true;
mark = skb->mark;
prio = skb->priority;
+ headroom = BPF_CORE_READ(dev, needed_headroom);
+ tailroom = BPF_CORE_READ(dev, needed_tailroom);
return TCX_PASS;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room
2024-12-19 17:39 [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Daniel Borkmann
2024-12-19 17:39 ` [PATCH bpf-next 2/3] netkit: Add add netkit {head,tail}room to rt_link.yaml Daniel Borkmann
2024-12-19 17:39 ` [PATCH bpf-next 3/3] selftests/bpf: Extend netkit tests to validate set {head,tail}room Daniel Borkmann
@ 2024-12-20 2:23 ` Jakub Kicinski
2024-12-20 9:06 ` Daniel Borkmann
2024-12-21 7:22 ` Nikolay Aleksandrov
3 siblings, 1 reply; 9+ messages in thread
From: Jakub Kicinski @ 2024-12-20 2:23 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: martin.lau, razor, pabeni, bpf, netdev
On Thu, 19 Dec 2024 18:39:26 +0100 Daniel Borkmann wrote:
> + if (headroom) {
> + peer->needed_headroom = headroom;
> + dev->needed_headroom = headroom;
> + }
> + if (tailroom) {
> + peer->needed_tailroom = tailroom;
> + dev->needed_tailroom = tailroom;
> + }
Since you use the same one for main dev and peer should there be
something rejecting the use of the new attr in the peer attrs?
(IFLA_NETKIT_PEER_INFO)
> + struct {
static const?
I wish more userspace learned how to do reverse parsing.
We wouldn't have to bother injecting the attr names to all the messages,
NL_SET_ERR_MSG_ATTR() already points to the attr :|
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room
2024-12-20 2:23 ` [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Jakub Kicinski
@ 2024-12-20 9:06 ` Daniel Borkmann
2024-12-21 0:04 ` Daniel Borkmann
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Borkmann @ 2024-12-20 9:06 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: martin.lau, razor, pabeni, bpf, netdev
On 12/20/24 3:23 AM, Jakub Kicinski wrote:
> On Thu, 19 Dec 2024 18:39:26 +0100 Daniel Borkmann wrote:
>> + if (headroom) {
>> + peer->needed_headroom = headroom;
>> + dev->needed_headroom = headroom;
>> + }
>> + if (tailroom) {
>> + peer->needed_tailroom = tailroom;
>> + dev->needed_tailroom = tailroom;
>> + }
>
> Since you use the same one for main dev and peer should there be
> something rejecting the use of the new attr in the peer attrs?
> (IFLA_NETKIT_PEER_INFO)
The peer info is parsed via rtnl_nla_parse_ifinfomsg() which internally
uses ifla_policy filter where IFLA_INFO_DATA is not part of, but to be
sure I can add one more selftest case to confirm.
>> + struct {
>
> static const?
Ack, will change.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room
2024-12-20 9:06 ` Daniel Borkmann
@ 2024-12-21 0:04 ` Daniel Borkmann
0 siblings, 0 replies; 9+ messages in thread
From: Daniel Borkmann @ 2024-12-21 0:04 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: martin.lau, razor, pabeni, bpf, netdev
On 12/20/24 10:06 AM, Daniel Borkmann wrote:
> On 12/20/24 3:23 AM, Jakub Kicinski wrote:
>> On Thu, 19 Dec 2024 18:39:26 +0100 Daniel Borkmann wrote:
>>> + if (headroom) {
>>> + peer->needed_headroom = headroom;
>>> + dev->needed_headroom = headroom;
>>> + }
>>> + if (tailroom) {
>>> + peer->needed_tailroom = tailroom;
>>> + dev->needed_tailroom = tailroom;
>>> + }
>>
>> Since you use the same one for main dev and peer should there be
>> something rejecting the use of the new attr in the peer attrs?
>> (IFLA_NETKIT_PEER_INFO)
>
> The peer info is parsed via rtnl_nla_parse_ifinfomsg() which internally
> uses ifla_policy filter where IFLA_INFO_DATA is not part of, but to be
> sure I can add one more selftest case to confirm.
Looks like we don't bail out anymore after the conversion in fefd5d082172
("netkit: Set IFLA_NETKIT_PEER_INFO to netkit_link_ops.peer_type."), so I
left it out for now from the series.. need to experiment some more whether
fefd5d082172 dropping the error has any unintended side-effects. But I'm
currently not seeing how it would be much different to, for example, the
preceding netif_inherit_tso_max() call.
Thanks,
Daniel
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room
2024-12-19 17:39 [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Daniel Borkmann
` (2 preceding siblings ...)
2024-12-20 2:23 ` [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Jakub Kicinski
@ 2024-12-21 7:22 ` Nikolay Aleksandrov
3 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2024-12-21 7:22 UTC (permalink / raw)
To: Daniel Borkmann, martin.lau; +Cc: pabeni, bpf, netdev
On 12/19/24 19:39, Daniel Borkmann wrote:
> Allow the user to configure needed_{head,tail}room for both netkit
> devices. The idea is similar to 163e529200af ("veth: implement
> ndo_set_rx_headroom") with the difference that the two parameters
> can be specified upon device creation. By default the current behavior
> stays as is which is needed_{head,tail}room is 0.
>
> In case of Cilium, for example, the netkit devices are not enslaved
> into a bridge or openvswitch device (rather, BPF-based redirection
> is used out of tcx), and as such these parameters are not propagated
> into the Pod's netns via peer device.
>
> Given Cilium can run in vxlan/geneve tunneling mode (needed_headroom)
> and/or be used in combination with WireGuard (needed_{head,tail}room),
> allow the Cilium CNI plugin to specify these two upon netkit device
> creation.
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Nikolay Aleksandrov <razor@blackwall.org>
> ---
> drivers/net/netkit.c | 66 +++++++++++++++++++-----------
> include/uapi/linux/if_link.h | 2 +
> tools/include/uapi/linux/if_link.h | 2 +
> 3 files changed, 47 insertions(+), 23 deletions(-)
>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH bpf-next 2/3] netkit: Add add netkit {head,tail}room to rt_link.yaml
2024-12-19 17:39 ` [PATCH bpf-next 2/3] netkit: Add add netkit {head,tail}room to rt_link.yaml Daniel Borkmann
@ 2024-12-21 7:22 ` Nikolay Aleksandrov
0 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2024-12-21 7:22 UTC (permalink / raw)
To: Daniel Borkmann, martin.lau; +Cc: pabeni, bpf, netdev
On 12/19/24 19:39, Daniel Borkmann wrote:
> Add netkit {head,tail}room attribute support to the rt_link.yaml spec file.
>
> Example:
>
> # ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/rt_link.yaml \
> --do getlink --json '{"ifname": "nk0"}' --output-json | jq
> [...]
> "linkinfo": {
> "kind": "netkit",
> "data": {
> }
> },
> [...]
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Nikolay Aleksandrov <razor@blackwall.org>
> ---
> Documentation/netlink/specs/rt_link.yaml | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/Documentation/netlink/specs/rt_link.yaml b/Documentation/netlink/specs/rt_link.yaml
> index 9ffa13b77dcf..dbeae6b1c548 100644
> --- a/Documentation/netlink/specs/rt_link.yaml
> +++ b/Documentation/netlink/specs/rt_link.yaml
> @@ -2166,6 +2166,12 @@ attribute-sets:
> name: peer-scrub
> type: u32
> enum: netkit-scrub
> + -
> + name: headroom
> + type: u16
> + -
> + name: tailroom
> + type: u16
>
> sub-messages:
> -
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH bpf-next 3/3] selftests/bpf: Extend netkit tests to validate set {head,tail}room
2024-12-19 17:39 ` [PATCH bpf-next 3/3] selftests/bpf: Extend netkit tests to validate set {head,tail}room Daniel Borkmann
@ 2024-12-21 7:22 ` Nikolay Aleksandrov
0 siblings, 0 replies; 9+ messages in thread
From: Nikolay Aleksandrov @ 2024-12-21 7:22 UTC (permalink / raw)
To: Daniel Borkmann, martin.lau; +Cc: pabeni, bpf, netdev
On 12/19/24 19:39, Daniel Borkmann wrote:
> Extend the netkit selftests to specify and validate the {head,tail}room
> on the netdevice:
>
> # ./vmtest.sh -- ./test_progs -t netkit
> [...]
> ./test_progs -t netkit
> [ 1.174147] bpf_testmod: loading out-of-tree module taints kernel.
> [ 1.174585] bpf_testmod: module verification failed: signature and/or required key missing - tainting kernel
> [ 1.422307] tsc: Refined TSC clocksource calibration: 3407.983 MHz
> [ 1.424511] clocksource: tsc: mask: 0xffffffffffffffff max_cycles: 0x311fc3e5084, max_idle_ns: 440795359833 ns
> [ 1.428092] clocksource: Switched to clocksource tsc
> #363 tc_netkit_basic:OK
> #364 tc_netkit_device:OK
> #365 tc_netkit_multi_links:OK
> #366 tc_netkit_multi_opts:OK
> #367 tc_netkit_neigh_links:OK
> #368 tc_netkit_pkt_type:OK
> #369 tc_netkit_scrub:OK
> Summary: 7/0 PASSED, 0 SKIPPED, 0 FAILED
>
> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
> Cc: Nikolay Aleksandrov <razor@blackwall.org>
> ---
> .../selftests/bpf/prog_tests/tc_netkit.c | 31 ++++++++++++-------
> .../selftests/bpf/progs/test_tc_link.c | 15 +++++++++
> 2 files changed, 35 insertions(+), 11 deletions(-)
>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-12-21 7:22 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-19 17:39 [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Daniel Borkmann
2024-12-19 17:39 ` [PATCH bpf-next 2/3] netkit: Add add netkit {head,tail}room to rt_link.yaml Daniel Borkmann
2024-12-21 7:22 ` Nikolay Aleksandrov
2024-12-19 17:39 ` [PATCH bpf-next 3/3] selftests/bpf: Extend netkit tests to validate set {head,tail}room Daniel Borkmann
2024-12-21 7:22 ` Nikolay Aleksandrov
2024-12-20 2:23 ` [PATCH bpf-next 1/3] netkit: Allow for configuring needed_{head,tail}room Jakub Kicinski
2024-12-20 9:06 ` Daniel Borkmann
2024-12-21 0:04 ` Daniel Borkmann
2024-12-21 7:22 ` Nikolay Aleksandrov
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).