Skip to content

Commit 7f32708

Browse files
TaeheeYoodavem330
authored andcommitted
macsec: avoid to set wrong mtu
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 <ap420073@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent c651b46 commit 7f32708

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
@@ -4002,11 +4002,11 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
40024002
struct netlink_ext_ack *extack)
40034003
{
40044004
struct macsec_dev *macsec = macsec_priv(dev);
4005+
rx_handler_func_t *rx_handler;
4006+
u8 icv_len = DEFAULT_ICV_LEN;
40054007
struct net_device *real_dev;
4006-
int err;
4008+
int err, mtu;
40074009
sci_t sci;
4008-
u8 icv_len = DEFAULT_ICV_LEN;
4009-
rx_handler_func_t *rx_handler;
40104010

40114011
if (!tb[IFLA_LINK])
40124012
return -EINVAL;
@@ -4033,7 +4033,11 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
40334033

40344034
if (data && data[IFLA_MACSEC_ICV_LEN])
40354035
icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
4036-
dev->mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
4036+
mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
4037+
if (mtu < 0)
4038+
dev->mtu = 0;
4039+
else
4040+
dev->mtu = mtu;
40374041

40384042
rx_handler = rtnl_dereference(real_dev->rx_handler);
40394043
if (rx_handler && rx_handler != macsec_handle_frame)

0 commit comments

Comments
 (0)