Commit a8a65311 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files
Daniel Borkmann says:

====================
pull-request: bpf-next 2025-01-07

We've added 7 non-merge commits during the last 32 day(s) which contain
a total of 11 files changed, 190 insertions(+), 103 deletions(-).

The main changes are:

1) Migrate the test_xdp_meta.sh BPF selftest into test_progs
   framework, from Bastien Curutchet.

2) Add ability to configure head/tailroom for netkit devices,
   from Daniel Borkmann.

3) Fixes and improvements to the xdp_hw_metadata selftest,
   from Song Yoong Siang.

* tag 'for-netdev' of https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next:
  selftests/bpf: Extend netkit tests to validate set {head,tail}room
  netkit: Add add netkit {head,tail}room to rt_link.yaml
  netkit: Allow for configuring needed_{head,tail}room
  selftests/bpf: Migrate test_xdp_meta.sh into xdp_context_test_run.c
  selftests/bpf: test_xdp_meta: Rename BPF sections
  selftests/bpf: Enable Tx hwtstamp in xdp_hw_metadata
  selftests/bpf: Actuate tx_metadata_len in xdp_hw_metadata
====================

Link: https://patch.msgid.link/20250107130908.143644-1-daniel@iogearbox.net


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents a1942da8 058268e2
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -2169,6 +2169,12 @@ attribute-sets:
        name: peer-scrub
        type: u32
        enum: netkit-scrub
      -
        name: headroom
        type: u16
      -
        name: tailroom
        type: u16

sub-messages:
  -
+43 −23
Original line number Diff line number Diff line
@@ -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;
	static const 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");
	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_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;
	}

	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,
+2 −0
Original line number Diff line number Diff line
@@ -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 −0
Original line number Diff line number Diff line
@@ -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)
+0 −1
Original line number Diff line number Diff line
@@ -129,7 +129,6 @@ TEST_FILES = xsk_prereqs.sh $(wildcard progs/btf_dump_test_case_*.c)
TEST_PROGS := test_kmod.sh \
	test_xdp_redirect.sh \
	test_xdp_redirect_multi.sh \
	test_xdp_meta.sh \
	test_tunnel.sh \
	test_lwt_seg6local.sh \
	test_lirc_mode2.sh \
Loading