public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next v2] ppp: add IFLA_PPP_UNIT netlink attribute
@ 2026-03-14  1:14 Martin Olivier
  2026-03-17 23:14 ` Jakub Kicinski
  2026-03-18  1:59 ` Qingfang Deng
  0 siblings, 2 replies; 6+ messages in thread
From: Martin Olivier @ 2026-03-14  1:14 UTC (permalink / raw)
  To: netdev, linux-ppp
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, linux-kernel,
	dqfext, 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>
---
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@PAWP192MB2411.EURP192.PROD.OUTLOOK.COM/
---
 drivers/net/ppp/ppp_generic.c      | 3 ++-
 include/uapi/linux/if_link.h       | 1 +
 tools/include/uapi/linux/if_link.h | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index e9b41777be80..3d5d5fe8bad3 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]		= NLA_POLICY_MIN(NLA_S32, 0),
 };
 
 static int ppp_nl_validate(struct nlattr *tb[], struct nlattr *data[],
@@ -1316,7 +1317,6 @@ static int ppp_nl_newlink(struct net_device *dev,
 	struct nlattr **data = params->data;
 	struct nlattr **tb = params->tb;
 	struct ppp_config conf = {
-		.unit = -1,
 		.ifname_is_set = true,
 	};
 	struct file *file;
@@ -1342,6 +1342,7 @@ static int ppp_nl_newlink(struct net_device *dev,
 	}
 
 	conf.file = file;
+	conf.unit = nla_get_s32_default(data[IFLA_PPP_UNIT], -1);
 
 	/* Don't use device name generated by the rtnetlink layer when ifname
 	 * isn't specified. Let ppp_dev_configure() set the device name using
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] 6+ messages in thread

end of thread, other threads:[~2026-03-18 10:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-14  1:14 [PATCH net-next v2] ppp: add IFLA_PPP_UNIT netlink attribute Martin Olivier
2026-03-17 23:14 ` Jakub Kicinski
2026-03-18  1:59 ` Qingfang Deng
2026-03-18  9:49   ` Guillaume Nault
2026-03-18 10:07   ` Pali Rohár
2026-03-18 10:11     ` Pali Rohár

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox