netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Mikhalitsyn <alexander.mikhalitsyn@virtuozzo.com>
To: Ido Schimmel <idosch@idosch.org>
Cc: netdev@vger.kernel.org, David Miller <davem@davemloft.net>,
	David Ahern <dsahern@gmail.com>,
	Stephen Hemminger <stephen@networkplumber.org>,
	Ido Schimmel <idosch@nvidia.com>,
	Jakub Kicinski <kuba@kernel.org>, Roopa Prabhu <roopa@nvidia.com>,
	Andrei Vagin <avagin@gmail.com>,
	Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
	Alexander Mikhalitsyn <alexander@mihalicyn.com>
Subject: Re: [PATCH net-next] rtnetlink: add RTNH_REJECT_MASK
Date: Tue, 30 Nov 2021 11:18:13 +0300	[thread overview]
Message-ID: <20211130111813.272af77c530a9b13152178ee@virtuozzo.com> (raw)
In-Reply-To: <YaOLt2M1hBnoVFKd@shredder>

On Sun, 28 Nov 2021 16:01:27 +0200
Ido Schimmel <idosch@idosch.org> wrote:

> On Fri, Nov 26, 2021 at 04:43:11PM +0300, Alexander Mikhalitsyn wrote:
> > diff --git a/include/uapi/linux/rtnetlink.h b/include/uapi/linux/rtnetlink.h
> > index 5888492a5257..9c065e2fdef9 100644
> > --- a/include/uapi/linux/rtnetlink.h
> > +++ b/include/uapi/linux/rtnetlink.h
> > @@ -417,6 +417,9 @@ struct rtnexthop {
> >  #define RTNH_COMPARE_MASK	(RTNH_F_DEAD | RTNH_F_LINKDOWN | \
> >  				 RTNH_F_OFFLOAD | RTNH_F_TRAP)
> >  
> > +/* these flags can't be set by the userspace */
> > +#define RTNH_REJECT_MASK	(RTNH_F_DEAD | RTNH_F_LINKDOWN)
> > +
> >  /* Macros to handle hexthops */
> >  
> >  #define RTNH_ALIGNTO	4
> > diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
> > index 4c0c33e4710d..805f5e05b56d 100644
> > --- a/net/ipv4/fib_semantics.c
> > +++ b/net/ipv4/fib_semantics.c
> > @@ -685,7 +685,7 @@ static int fib_get_nhs(struct fib_info *fi, struct rtnexthop *rtnh,
> >  			return -EINVAL;
> >  		}
> >  
> > -		if (rtnh->rtnh_flags & (RTNH_F_DEAD | RTNH_F_LINKDOWN)) {
> > +		if (rtnh->rtnh_flags & RTNH_REJECT_MASK) {
> >  			NL_SET_ERR_MSG(extack,
> >  				       "Invalid flags for nexthop - can not contain DEAD or LINKDOWN");
> >  			return -EINVAL;
> > @@ -1363,7 +1363,7 @@ struct fib_info *fib_create_info(struct fib_config *cfg,
> >  		goto err_inval;
> >  	}
> >  
> > -	if (cfg->fc_flags & (RTNH_F_DEAD | RTNH_F_LINKDOWN)) {
> > +	if (cfg->fc_flags & RTNH_REJECT_MASK) {
> >  		NL_SET_ERR_MSG(extack,
> >  			       "Invalid rtm_flags - can not contain DEAD or LINKDOWN");
> 
> Instead of a deny list as in the legacy nexthop code, the new nexthop
> code has an allow list (from rtm_to_nh_config()):
> 
> ```
> 	if (nhm->nh_flags & ~NEXTHOP_VALID_USER_FLAGS) {
> 		NL_SET_ERR_MSG(extack, "Invalid nexthop flags in ancillary header");
> 		goto out;
> 	}
> ```
> 
> Where:
> 
> ```
> #define NEXTHOP_VALID_USER_FLAGS RTNH_F_ONLINK
> ```
> 
> So while the legacy nexthop code allows setting flags such as
> RTNH_F_OFFLOAD, the new nexthop code denies them. I don't have a use
> case for setting these flags from user space so I don't care if we allow
> or deny them, but I believe the legacy and new nexthop code should be
> consistent.

Dear Ido,

thanks for your attention to the patches and our checkpoint/restore problem.

Yep, I've read nexthop code too and notices some inconsistencies, but
unfortunately I'm newbie here and my first goal is to fix thing and not break
something, that's why my patch is so trivial and not invasive :)

We have some discussion about these flags here:
https://lore.kernel.org/netdev/d7c2d8fa-052e-b941-2ef1-830c1ba655c1@gmail.com/#r

I've noticed, that current iproute2 code not allows us to set RTNH_F_OFFLOAD and
RTNH_F_TRAP directly. And asked If we should prohibit setting these flags from
the userspace. But huge thanks to Roopa and David here - it turned out that some
userspace code usings these flags and sets it.

So, let's decide which flags we should allow to set from the userspace side
and which not. I'm ready to prepare all needed changes for both the kernel and
iproute2 side. ;)

> 
> WDYT? Should we allow these flags in the new nexthop code as well or
> keep denying them?

IMHO, we should try to be consistent between the new nexthop code and the lagacy one.

Regards,
Alex

> 
> >  		goto err_inval;
> > -- 
> > 2.31.1
> > 



  parent reply	other threads:[~2021-11-30  8:18 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-11 16:02 [RFC PATCH iproute2] ip route: save: exclude rtnh_flags which can't be set Alexander Mikhalitsyn
2021-11-11 16:02 ` [RFC PATCH net-next] rtnetlink: add RTNH_F_REJECT_MASK Alexander Mikhalitsyn
2021-11-11 17:48   ` Jakub Kicinski
2021-11-11 17:51     ` Alexander Mikhalitsyn
2021-11-11 17:56       ` Jakub Kicinski
2021-11-11 18:01         ` Alexander Mikhalitsyn
2021-11-11 19:13   ` David Ahern
2021-11-11 19:23     ` Alexander Mikhalitsyn
2021-11-11 22:19       ` David Ahern
2021-11-12  1:02         ` Roopa Prabhu
2021-11-12  2:27           ` David Ahern
2021-11-26 13:43 ` [PATCH iproute2] ip route: save: exclude rtnh_flags which can't be set Alexander Mikhalitsyn
2021-11-26 13:43   ` [PATCH net-next] rtnetlink: add RTNH_REJECT_MASK Alexander Mikhalitsyn
2021-11-28 14:01     ` Ido Schimmel
2021-11-29  0:19       ` David Ahern
2021-11-30  7:59         ` Ido Schimmel
2021-11-30  8:35           ` Alexander Mikhalitsyn
2021-11-30  9:28             ` Ido Schimmel
2021-11-30  9:53               ` Alexander Mikhalitsyn
2021-11-30 10:28                 ` Ido Schimmel
2021-11-30 15:12                   ` David Ahern
2021-11-30  8:18       ` Alexander Mikhalitsyn [this message]
2021-11-28 13:09   ` [PATCH iproute2] ip route: save: exclude rtnh_flags which can't be set Ido Schimmel

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=20211130111813.272af77c530a9b13152178ee@virtuozzo.com \
    --to=alexander.mikhalitsyn@virtuozzo.com \
    --cc=alexander@mihalicyn.com \
    --cc=avagin@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=idosch@idosch.org \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=roopa@nvidia.com \
    --cc=stephen@networkplumber.org \
    /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;
as well as URLs for NNTP newsgroup(s).