Re: [PATCH net-next v2] ppp: add IFLA_PPP_UNIT netlink attribute

From: Pali Rohár

Date: Fri Apr 03 2026 - 11:02:31 EST


On Wednesday 18 March 2026 11:07:38 Pali Rohár wrote:
> On Wednesday 18 March 2026 09:59:29 Qingfang Deng wrote:
> > On Sat, 14 Mar 2026 02:14:29 +0100, Martin Olivier wrote:
> > > Currently, the PPP rtnetlink API allows creating a new network interface
> > > with a custom ifname, but it lacks the ability to specify a custom PPP
> > > unit id.
> > >
> > > Setting a specific unit id is currently only possible with the
> > > PPPIOCNEWUNIT ioctl. If a user-space program also requires a custom
> > > interface name, it must create the interface first with PPPIOCNEWUNIT
> > > and then rename it.
> > >
> > > Resolve this by introducing the IFLA_PPP_UNIT netlink attribute. This
> > > allows user-space programs to atomically request both a custom ifname
> > > and a specific PPP unit id during the RTM_NEWLINK creation process,
> > > eliminating the post-creation renaming for this use case.
> > >
> > > Signed-off-by: Martin Olivier <martin.olivier@xxxxxxx>
> > > ---
> > > Changes in v2:
> > > - use nl policy to set IFLA_PPP_UNIT min allowed value instead of a manual check in ppp_nl_validate()
> > > - use of nla_get_s32_default() to collect IFLA_PPP_UNIT value
> > > Link to v1: https://lore.kernel.org/netdev/PAWP192MB2411A5E7D3BE1B55E155A92F9747A@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/
> >
> > The patch itself looks good to me, but I would like to check the
> > userspace changes too. Please create a pull request at
> > https://github.com/ppp-project/ppp/pulls
> >
> > +Cc: Paul Mackerras, Guillaume Nault, Pali Rohár
> >
> > Regards,
> > Qingfang
>
> Hello Martin, in past I have sent similar change:
> https://lore.kernel.org/linux-ppp/20210807163749.18316-1-pali@xxxxxxxxxx/T/#u
> Look at the discussion, it can be useful to understand why the change
> was not accepted.

Anyway, if you want to continue on this patch, here are my points for review:

- I would suggest to use IFLA_PPP_UNIT_ID name for consistency. We
already have IFLA_PPP_DEV_FD value where is FD suffix which is saying
what it is. So for naming consistency is the suffix "_ID" useful.

- Allow to specify -1 as an valid input. Currently the
NLA_POLICY_MIN(NLA_S32, 0) does not allow -1.
-1 should work as a default value, like if the value is not specified
at all.

- Add #define IFLA_PPP_UNIT_ID ifla_ppp_unit_id into the enum { ... } in
if_link.h. This is for userspace compatibility, which can check fi
the IFLA_PPP_UNIT_ID is provided or not (via #ifdef).

- Do not rewrite error to -EEXIST when calling the ppp_dev_configure()
from the ppp_nl_newlink() with specified unit_id. ppp_nl_newlink() is
a new code path which will allow to specify unit_id, and hence it is
not useful to hide a real error and replace it by -EEXIST.

All of these points I have already handled in my version of the patch
which I sent and is available in the above link. So you can use it as an
inspiration how to easily handle them.

Pali