Netdev List
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Cc: davem@davemloft.net, willemb@google.com, netdev@vger.kernel.org
Subject: Re: [net-next 2/2] ifb: add device MTU validation check
Date: Thu, 21 Sep 2017 08:10:10 -0700	[thread overview]
Message-ID: <20170921081010.4d6f5731@xeon-e3> (raw)
In-Reply-To: <1506000722-40095-3-git-send-email-zhangshengju@cmss.chinamobile.com>

On Thu, 21 Sep 2017 21:32:02 +0800
Zhang Shengju <zhangshengju@cmss.chinamobile.com> wrote:

> Currently, any mtu value can be assigned when adding a new ifb device:
> [~]# ip link add name ifb2 mtu 100000 type ifb
> [~]# ip link show ifb2
> 18: ifb2: <BROADCAST,NOARP> mtu 100000 qdisc noop state DOWN mode DEFAULT group default qlen 32
>     link/ether 7a:bf:f4:63:da:d1 brd ff:ff:ff:ff:ff:ff
> 
> This patch adds device MTU validation check.
> 
> Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
> ---
>  drivers/net/ifb.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
> index 8870bd2..ce84ad2 100644
> --- a/drivers/net/ifb.c
> +++ b/drivers/net/ifb.c
> @@ -282,6 +282,14 @@ static int ifb_validate(struct nlattr *tb[], struct nlattr *data[],
>  		if (!is_valid_ether_addr(nla_data(tb[IFLA_ADDRESS])))
>  			return -EADDRNOTAVAIL;
>  	}
> +
> +	if (tb[IFLA_MTU]) {
> +		u32 mtu = nla_get_u32(tb[IFLA_MTU]);
> +
> +		if (mtu < ETH_MIN_MTU || mtu > ETH_DATA_LEN)
> +			return -EINVAL;
> +	}
> +
>  	return 0;
>  }
>  

What about running ifb with packets coming from devices with jumbo frames?
Also since ifb is an input only device, MTU doesn't matter.

  reply	other threads:[~2017-09-21 15:10 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 13:32 [net-next 0/2] add device MTU validation check Zhang Shengju
2017-09-21 13:32 ` [net-next 1/2] dummy: " Zhang Shengju
2017-09-21 15:02   ` Eric Dumazet
2017-09-22  3:28     ` 张胜举
2017-09-22  8:56     ` Sabrina Dubroca
2017-09-22 11:05       ` Eric Dumazet
2017-09-22 12:23         ` Sabrina Dubroca
2017-09-22 12:59           ` 张胜举
2017-09-21 13:32 ` [net-next 2/2] ifb: " Zhang Shengju
2017-09-21 15:10   ` Stephen Hemminger [this message]
2017-09-22  3:35     ` 张胜举

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170921081010.4d6f5731@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=willemb@google.com \
    --cc=zhangshengju@cmss.chinamobile.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox