Re: [PATCH v2 net-next 05/13] ipv6: Create init helper for fib6_nh

Alexei Starovoitov
2019-03-28T02:29:55Z

On Wed, Mar 27, 2019 at 08:05:03PM -0600, David Ahern wrote:
> On 3/27/19 7:30 PM, Alexei Starovoitov wrote:
> >>>
> >>> imo it would be cleaner not to mess with cfg.
> >>> Ideally it should be marked 'const'.
> >>
> >> Existing code sets those flags but on a fib6_info. This is not used for
> >> nexthop objects and is kept here to not duplicate this if branch in the
> >> create_info that uses it. This check affects both which device is used
> >> as well as the flags.
> >
> > What stopping you from doing fib6_nh->nh_flags |= RTF_REJECT | RTF_NONEXTHOP ?
> > cfg should really be const.
>
> Because it is not a nexthop flag, it is a prefix flag.

that was a typo. I meant fib6_flags.
why mess with cfg and use it as weird side effect only to
get rt->fib6_flags = cfg->fc_flags; working after fib6_nh_init() returns?
Why not to move that fib6_flags = fc_flags assignment into fib6_nh_init ?
Then cfg can stay constant and no weird side effects from init function.