* [PATCH net] macsec: avoid to set wrong mtu
@ 2020-04-23 13:40 Taehee Yoo
2020-04-24 23:43 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Taehee Yoo @ 2020-04-23 13:40 UTC (permalink / raw)
To: davem, kuba, sd, netdev; +Cc: ap420073
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: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
drivers/net/macsec.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index a183250ff66a..758baf7cb8a1 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -4002,11 +4002,11 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
struct netlink_ext_ack *extack)
{
struct macsec_dev *macsec = macsec_priv(dev);
+ rx_handler_func_t *rx_handler;
+ u8 icv_len = DEFAULT_ICV_LEN;
struct net_device *real_dev;
- int err;
+ int err, mtu;
sci_t sci;
- u8 icv_len = DEFAULT_ICV_LEN;
- rx_handler_func_t *rx_handler;
if (!tb[IFLA_LINK])
return -EINVAL;
@@ -4033,7 +4033,11 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
if (data && data[IFLA_MACSEC_ICV_LEN])
icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
- dev->mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
+ mtu = real_dev->mtu - icv_len - macsec_extra_len(true);
+ if (mtu < 0)
+ dev->mtu = 0;
+ else
+ dev->mtu = mtu;
rx_handler = rtnl_dereference(real_dev->rx_handler);
if (rx_handler && rx_handler != macsec_handle_frame)
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] macsec: avoid to set wrong mtu
2020-04-23 13:40 [PATCH net] macsec: avoid to set wrong mtu Taehee Yoo
@ 2020-04-24 23:43 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-04-24 23:43 UTC (permalink / raw)
To: ap420073; +Cc: kuba, sd, netdev
From: Taehee Yoo <ap420073@gmail.com>
Date: Thu, 23 Apr 2020 13:40:47 +0000
> 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: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-24 23:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-23 13:40 [PATCH net] macsec: avoid to set wrong mtu Taehee Yoo
2020-04-24 23:43 ` David Miller
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).