Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a00bf2b8 authored by Mark Starovoytov's avatar Mark Starovoytov Committed by Gerrit - the friendly Code Review server
Browse files

net: macsec: add support for specifying offload upon link creation



This patch adds new netlink attribute to allow a user to (optionally)
specify the desired offload mode immediately upon MACSec link creation.

Separate iproute patch will be required to support this from user space.

Change-Id: I3aa8c9c2eb65763707487267a23ea2e645d1afde
Signed-off-by: default avatarMark Starovoytov <mstarovoitov@marvell.com>
Signed-off-by: default avatarIgor Russkikh <irusskikh@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Git-commit: 791bb3fcafcedd11f9066da9fee9342ecb6904d0
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git


Signed-off-by: default avatarKarthik Rudrapatna <quic_krudrapa@quicinc.com>
parent 8cd841af
Loading
Loading
Loading
Loading
+29 −2
Original line number Diff line number Diff line
@@ -1470,6 +1470,11 @@ static struct net_device *get_dev_from_nl(struct net *net,
	return dev;
}

static enum macsec_offload nla_get_offload(const struct nlattr *nla)
{
	return (__force enum macsec_offload)nla_get_u8(nla);
}

static sci_t nla_get_sci(const struct nlattr *nla)
{
	return (__force sci_t)nla_get_u64(nla);
@@ -3995,9 +4000,17 @@ static int macsec_newlink(struct net *net, struct net_device *dev,

	macsec->real_dev = real_dev;

	if (data && data[IFLA_MACSEC_OFFLOAD])
		macsec->offload = nla_get_offload(data[IFLA_MACSEC_OFFLOAD]);
	else
		/* MACsec offloading is off by default */
		macsec->offload = MACSEC_OFFLOAD_OFF;

	/* Check if the offloading mode is supported by the underlying layers */
	if (macsec->offload != MACSEC_OFFLOAD_OFF &&
	    !macsec_check_offload(macsec->offload, macsec))
		return -EOPNOTSUPP;

	if (data && data[IFLA_MACSEC_ICV_LEN])
		icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
	mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
@@ -4043,6 +4056,20 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
			goto del_dev;
	}

	/* If h/w offloading is available, propagate to the device */
	if (macsec_is_offloaded(macsec)) {
		const struct macsec_ops *ops;
		struct macsec_context ctx;

		ops = macsec_get_ops(macsec, &ctx);
		if (ops) {
			ctx.secy = &macsec->secy;
			err = macsec_offload(ops->mdo_add_secy, &ctx);
			if (err)
				goto del_dev;
		}
	}

	err = register_macsec_dev(real_dev, dev);
	if (err < 0)
		goto del_dev;
+1 −0
Original line number Diff line number Diff line
@@ -460,6 +460,7 @@ enum {
	IFLA_MACSEC_REPLAY_PROTECT,
	IFLA_MACSEC_VALIDATION,
	IFLA_MACSEC_PAD,
	IFLA_MACSEC_OFFLOAD,
	__IFLA_MACSEC_MAX,
};

+1 −0
Original line number Diff line number Diff line
@@ -460,6 +460,7 @@ enum {
	IFLA_MACSEC_REPLAY_PROTECT,
	IFLA_MACSEC_VALIDATION,
	IFLA_MACSEC_PAD,
	IFLA_MACSEC_OFFLOAD,
	__IFLA_MACSEC_MAX,
};