Skip to content

Commit 70a37b9

Browse files
TaeheeYoogregkh
authored andcommitted
macsec: avoid to set wrong mtu
[ Upstream commit 7f32708 ] When a macsec interface is created, the mtu is calculated with the lower interface's mtu value. If the mtu of lower interface is lower than the length, which is needed by macsec interface, macsec's mtu value will be overflowed. So, if the lower interface's mtu is too low, macsec interface's mtu should be set to 0. Test commands: ip link add dummy0 mtu 10 type dummy ip link add macsec0 link dummy0 type macsec ip link show macsec0 Before: 11: macsec0@dummy0: <BROADCAST,MULTICAST,M-DOWN> mtu 4294967274 After: 11: macsec0@dummy0: <BROADCAST,MULTICAST,M-DOWN> mtu 0 Fixes: c09440f ("macsec: introduce IEEE 802.1AE driver") Signed-off-by: Taehee Yoo <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 2d197d8 commit 70a37b9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/net/macsec.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3226,11 +3226,11 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
32263226
struct netlink_ext_ack *extack)
32273227
{
32283228
struct macsec_dev *macsec = macsec_priv(dev);
3229+
rx_handler_func_t *rx_handler;
3230+
u8 icv_len = DEFAULT_ICV_LEN;
32293231
struct net_device *real_dev;
3230-
int err;
3232+
int err, mtu;
32313233
sci_t sci;
3232-
u8 icv_len = DEFAULT_ICV_LEN;
3233-
rx_handler_func_t *rx_handler;
32343234

32353235
if (!tb[IFLA_LINK])
32363236
return -EINVAL;
@@ -3246,7 +3246,11 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
32463246

32473247
if (data && data[IFLA_MACSEC_ICV_LEN])
32483248
icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
3249-
dev->mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
3249+
mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
3250+
if (mtu < 0)
3251+
dev->mtu = 0;
3252+
else
3253+
dev->mtu = mtu;
32503254

32513255
rx_handler = rtnl_dereference(real_dev->rx_handler);
32523256
if (rx_handler && rx_handler != macsec_handle_frame)

0 commit comments

Comments
 (0)