* [PATCH] ppp: add IFLA_PPP_UNIT netlink attribute
@ 2026-03-11 7:35 Martin Olivier
2026-03-13 1:00 ` Jakub Kicinski
2026-03-13 1:01 ` Jakub Kicinski
0 siblings, 2 replies; 3+ messages in thread
From: Martin Olivier @ 2026-03-11 7:35 UTC (permalink / raw)
To: netdev, linux-ppp
Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux-kernel,
Martin Olivier
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@live.fr>
---
drivers/net/ppp/ppp_generic.c | 7 +++++++
include/uapi/linux/if_link.h | 1 +
tools/include/uapi/linux/if_link.h | 1 +
3 files changed, 9 insertions(+)
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index e9b41777be80..57d0124b9f37 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -1292,6 +1292,7 @@ static int ppp_dev_configure(struct net *src_net, struct net_device *dev,
static const struct nla_policy ppp_nl_policy[IFLA_PPP_MAX + 1] = {
[IFLA_PPP_DEV_FD] = { .type = NLA_S32 },
+ [IFLA_PPP_UNIT] = { .type = NLA_S32 },
};
static int ppp_nl_validate(struct nlattr *tb[], struct nlattr *data[],
@@ -1305,6 +1306,9 @@ static int ppp_nl_validate(struct nlattr *tb[], struct nlattr *data[],
if (nla_get_s32(data[IFLA_PPP_DEV_FD]) < 0)
return -EBADF;
+ if (data[IFLA_PPP_UNIT] && nla_get_s32(data[IFLA_PPP_UNIT]) < 0)
+ return -EINVAL;
+
return 0;
}
@@ -1326,6 +1330,9 @@ static int ppp_nl_newlink(struct net_device *dev,
if (!file)
return -EBADF;
+ if (data[IFLA_PPP_UNIT])
+ conf.unit = nla_get_s32(data[IFLA_PPP_UNIT]);
+
/* rtnl_lock is already held here, but ppp_create_interface() locks
* ppp_mutex before holding rtnl_lock. Using mutex_trylock() avoids
* possible deadlock due to lock order inversion, at the cost of
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index e9b5f79e1ee1..40523cd01a8b 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -1477,6 +1477,7 @@ enum {
enum {
IFLA_PPP_UNSPEC,
IFLA_PPP_DEV_FD,
+ IFLA_PPP_UNIT,
__IFLA_PPP_MAX
};
#define IFLA_PPP_MAX (__IFLA_PPP_MAX - 1)
diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h
index 7e46ca4cd31b..150a582ae498 100644
--- a/tools/include/uapi/linux/if_link.h
+++ b/tools/include/uapi/linux/if_link.h
@@ -1465,6 +1465,7 @@ enum {
enum {
IFLA_PPP_UNSPEC,
IFLA_PPP_DEV_FD,
+ IFLA_PPP_UNIT,
__IFLA_PPP_MAX
};
#define IFLA_PPP_MAX (__IFLA_PPP_MAX - 1)
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ppp: add IFLA_PPP_UNIT netlink attribute
2026-03-11 7:35 [PATCH] ppp: add IFLA_PPP_UNIT netlink attribute Martin Olivier
@ 2026-03-13 1:00 ` Jakub Kicinski
2026-03-13 1:01 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2026-03-13 1:00 UTC (permalink / raw)
To: Martin Olivier
Cc: netdev, linux-ppp, andrew+netdev, davem, edumazet, pabeni,
linux-kernel
On Wed, 11 Mar 2026 08:35:26 +0100 Martin Olivier wrote:
> + [IFLA_PPP_UNIT] = { .type = NLA_S32 },
[IFLA_PPP_UNIT] = NLA_POLICY_MIN(NLA_S32, 0)
and then you can remove the manual check in validate?
--
pw-bot: cr
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ppp: add IFLA_PPP_UNIT netlink attribute
2026-03-11 7:35 [PATCH] ppp: add IFLA_PPP_UNIT netlink attribute Martin Olivier
2026-03-13 1:00 ` Jakub Kicinski
@ 2026-03-13 1:01 ` Jakub Kicinski
1 sibling, 0 replies; 3+ messages in thread
From: Jakub Kicinski @ 2026-03-13 1:01 UTC (permalink / raw)
To: Martin Olivier
Cc: netdev, linux-ppp, andrew+netdev, davem, edumazet, pabeni,
linux-kernel
On Wed, 11 Mar 2026 08:35:26 +0100 Martin Olivier wrote:
> + if (data[IFLA_PPP_UNIT])
> + conf.unit = nla_get_s32(data[IFLA_PPP_UNIT]);
You can also use nla_get_s32_default(data[IFLA_PPP_UNIT], 0)
but that one is more of an acquired taste.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-13 1:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 7:35 [PATCH] ppp: add IFLA_PPP_UNIT netlink attribute Martin Olivier
2026-03-13 1:00 ` Jakub Kicinski
2026-03-13 1:01 ` Jakub Kicinski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox