All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/6] WWAN netdev creation framework tweaks
@ 2021-06-03  4:49 Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 1/6] rtnetlink: fix alloc() method introduction Sergey Ryazanov
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Sergey Ryazanov @ 2021-06-03  4:49 UTC (permalink / raw)
  To: Johannes Berg, Loic Poulain; +Cc: M Chetan Kumar, linux-wireless, netdev

This is a follow-up series to the proposed generic WWAN interface
creation framework [1].

The first two patches are small fixes for issues that were spotted
during the original code testing. The 3rd patch completes my suggestion
to make the parent device attribute (IFLA_PARENT_DEV_NAME) generic by
revealing the netdev parent device to userspace using this attribute.
The 4th patch was added to make it easier to test iproute2 changes, in
fact it just copies the definitions from the kernel headers to iproute2.
Finally, 5th and 6th patches provide an example of userspace support for
WWAN links management.

At the moment I do not have access to any WWAN hardware, so the code was
only lightly tested at runtime.

1. https://lore.kernel.org/netdev/20210602082840.85828-1-johannes@sipsolutions.net

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RFC 1/6] rtnetlink: fix alloc() method introduction
  2021-06-03  4:49 [RFC 0/6] WWAN netdev creation framework tweaks Sergey Ryazanov
@ 2021-06-03  4:49 ` Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 2/6] wwan: fix module initialization Sergey Ryazanov
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sergey Ryazanov @ 2021-06-03  4:49 UTC (permalink / raw)
  To: Johannes Berg, Loic Poulain; +Cc: M Chetan Kumar, linux-wireless, netdev

RTNL checks for the setup() callback existing in a few place as a sanity
check. The introduction of the alloc() method makes the setup() method
optional. So allow RTNL families that define at least one alloc() or
setup() method.

Fixes: ???? ("rtnetlink: add alloc() method to rtnl_link_ops")
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
 net/core/rtnetlink.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 49a27bf6e4a7..56ac16abe0ba 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -376,12 +376,12 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
 	if (rtnl_link_ops_get(ops->kind))
 		return -EEXIST;
 
-	/* The check for setup is here because if ops
+	/* The check for alloc/setup is here because if ops
 	 * does not have that filled up, it is not possible
 	 * to use the ops for creating device. So do not
 	 * fill up dellink as well. That disables rtnl_dellink.
 	 */
-	if (ops->setup && !ops->dellink)
+	if ((ops->alloc || ops->setup) && !ops->dellink)
 		ops->dellink = unregister_netdevice_queue;
 
 	list_add_tail(&ops->list, &link_ops);
@@ -3421,7 +3421,7 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,
 		return -EOPNOTSUPP;
 	}
 
-	if (!ops->setup)
+	if (!ops->alloc && !ops->setup)
 		return -EOPNOTSUPP;
 
 	if (!ifname[0]) {
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC 2/6] wwan: fix module initialization
  2021-06-03  4:49 [RFC 0/6] WWAN netdev creation framework tweaks Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 1/6] rtnetlink: fix alloc() method introduction Sergey Ryazanov
@ 2021-06-03  4:49 ` Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 3/6] rtnetlink: fill IFLA_PARENT_DEV_NAME on link dump Sergey Ryazanov
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sergey Ryazanov @ 2021-06-03  4:49 UTC (permalink / raw)
  To: Johannes Berg, Loic Poulain; +Cc: M Chetan Kumar, linux-wireless, netdev

Recover the successful return from the module initialization function
that was accidentally lost during the netdev creation support
integration.

Fixes: ???? ("wwan: add interface creation support")
Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
 drivers/net/wwan/wwan_core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wwan/wwan_core.c b/drivers/net/wwan/wwan_core.c
index e2490c73ac33..32b2096c5036 100644
--- a/drivers/net/wwan/wwan_core.c
+++ b/drivers/net/wwan/wwan_core.c
@@ -737,7 +737,8 @@ static int __init wwan_init(void)
 		goto destroy;
 	}
 
-	err = 0;
+	return 0;
+
 destroy:
 	class_destroy(wwan_class);
 unregister:
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC 3/6] rtnetlink: fill IFLA_PARENT_DEV_NAME on link dump
  2021-06-03  4:49 [RFC 0/6] WWAN netdev creation framework tweaks Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 1/6] rtnetlink: fix alloc() method introduction Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 2/6] wwan: fix module initialization Sergey Ryazanov
@ 2021-06-03  4:49 ` Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 4/6 iproute2] Update kernel headers Sergey Ryazanov
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: Sergey Ryazanov @ 2021-06-03  4:49 UTC (permalink / raw)
  To: Johannes Berg, Loic Poulain; +Cc: M Chetan Kumar, linux-wireless, netdev

Return a parent device using the FLA_PARENT_DEV_NAME attribute during
links dump. This should help a user figure out which links belong to a
particular HW device. E.g. what data channels exists on a specific WWAN
modem.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
 net/core/rtnetlink.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 56ac16abe0ba..120887c892de 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1819,6 +1819,11 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb,
 	if (rtnl_fill_prop_list(skb, dev))
 		goto nla_put_failure;
 
+	if (dev->dev.parent &&
+	    nla_put_string(skb, IFLA_PARENT_DEV_NAME,
+			   dev_name(dev->dev.parent)))
+		goto nla_put_failure;
+
 	nlmsg_end(skb, nlh);
 	return 0;
 
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC 4/6 iproute2] Update kernel headers
  2021-06-03  4:49 [RFC 0/6] WWAN netdev creation framework tweaks Sergey Ryazanov
                   ` (2 preceding siblings ...)
  2021-06-03  4:49 ` [RFC 3/6] rtnetlink: fill IFLA_PARENT_DEV_NAME on link dump Sergey Ryazanov
@ 2021-06-03  4:49 ` Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 5/6 iproute2] iplink: add support for parent device Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 6/6 iproute2] iplink: support for WWAN devices Sergey Ryazanov
  5 siblings, 0 replies; 7+ messages in thread
From: Sergey Ryazanov @ 2021-06-03  4:49 UTC (permalink / raw)
  To: Johannes Berg, Loic Poulain; +Cc: M Chetan Kumar, linux-wireless, netdev

A partial headers update that brings WWAN-related attributes. Included
in the series mainly to make it possible to quickly compile and test the
utility.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
 include/uapi/linux/if_link.h |  6 ++++++
 include/uapi/linux/wwan.h    | 16 ++++++++++++++++
 2 files changed, 22 insertions(+)
 create mode 100644 include/uapi/linux/wwan.h

diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index 50193377..1cf48416 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -341,6 +341,12 @@ enum {
 	IFLA_ALT_IFNAME, /* Alternative ifname */
 	IFLA_PERM_ADDRESS,
 	IFLA_PROTO_DOWN_REASON,
+
+	/* device (sysfs) name as parent, used instead
+	 * of IFLA_LINK where there's no parent netdev
+	 */
+	IFLA_PARENT_DEV_NAME,
+
 	__IFLA_MAX
 };
 
diff --git a/include/uapi/linux/wwan.h b/include/uapi/linux/wwan.h
new file mode 100644
index 00000000..32a2720b
--- /dev/null
+++ b/include/uapi/linux/wwan.h
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0-only WITH Linux-syscall-note */
+/*
+ * Copyright (C) 2021 Intel Corporation.
+ */
+#ifndef _UAPI_WWAN_H_
+#define _UAPI_WWAN_H_
+
+enum {
+	IFLA_WWAN_UNSPEC,
+	IFLA_WWAN_LINK_ID, /* u32 */
+
+	__IFLA_WWAN_MAX
+};
+#define IFLA_WWAN_MAX (__IFLA_WWAN_MAX - 1)
+
+#endif /* _UAPI_WWAN_H_ */
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC 5/6 iproute2] iplink: add support for parent device
  2021-06-03  4:49 [RFC 0/6] WWAN netdev creation framework tweaks Sergey Ryazanov
                   ` (3 preceding siblings ...)
  2021-06-03  4:49 ` [RFC 4/6 iproute2] Update kernel headers Sergey Ryazanov
@ 2021-06-03  4:49 ` Sergey Ryazanov
  2021-06-03  4:49 ` [RFC 6/6 iproute2] iplink: support for WWAN devices Sergey Ryazanov
  5 siblings, 0 replies; 7+ messages in thread
From: Sergey Ryazanov @ 2021-06-03  4:49 UTC (permalink / raw)
  To: Johannes Berg, Loic Poulain; +Cc: M Chetan Kumar, linux-wireless, netdev

Add support for specifying a parent device (struct device) by its name
during the link creation and printing parent name in the links list.
This option will be used to create WWAN links and possibly by other
device classes that do not have a "natural parent netdev".

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
 ip/ipaddress.c | 7 +++++++
 ip/iplink.c    | 6 +++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index cfb24f5c..98f25a5b 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1176,6 +1176,13 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
 						   RTA_PAYLOAD(tb[IFLA_PHYS_SWITCH_ID]),
 						   b1, sizeof(b1)));
 		}
+
+		if (tb[IFLA_PARENT_DEV_NAME]) {
+			print_string(PRINT_ANY,
+				     "parentdev_name",
+				     "parentdev-name %s ",
+				     rta_getattr_str(tb[IFLA_PARENT_DEV_NAME]));
+		}
 	}
 
 	if ((do_link || show_details) && tb[IFLA_IFALIAS]) {
diff --git a/ip/iplink.c b/ip/iplink.c
index faafd7e8..190ce7d9 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -63,7 +63,7 @@ void iplink_usage(void)
 {
 	if (iplink_have_newlink()) {
 		fprintf(stderr,
-			"Usage: ip link add [link DEV] [ name ] NAME\n"
+			"Usage: ip link add [link DEV | parentdev-name NAME] [ name ] NAME\n"
 			"		    [ txqueuelen PACKETS ]\n"
 			"		    [ address LLADDR ]\n"
 			"		    [ broadcast LLADDR ]\n"
@@ -938,6 +938,10 @@ int iplink_parse(int argc, char **argv, struct iplink_req *req, char **type)
 				       *argv);
 			addattr32(&req->n, sizeof(*req),
 				  IFLA_GSO_MAX_SEGS, max_segs);
+		} else if (strcmp(*argv, "parentdev-name") == 0) {
+			NEXT_ARG();
+			addattr_l(&req->n, sizeof(*req), IFLA_PARENT_DEV_NAME,
+				  *argv, strlen(*argv) + 1);
 		} else {
 			if (matches(*argv, "help") == 0)
 				usage();
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RFC 6/6 iproute2] iplink: support for WWAN devices
  2021-06-03  4:49 [RFC 0/6] WWAN netdev creation framework tweaks Sergey Ryazanov
                   ` (4 preceding siblings ...)
  2021-06-03  4:49 ` [RFC 5/6 iproute2] iplink: add support for parent device Sergey Ryazanov
@ 2021-06-03  4:49 ` Sergey Ryazanov
  5 siblings, 0 replies; 7+ messages in thread
From: Sergey Ryazanov @ 2021-06-03  4:49 UTC (permalink / raw)
  To: Johannes Berg, Loic Poulain; +Cc: M Chetan Kumar, linux-wireless, netdev

The WWAN subsystem has been extended to generalize the per data channel
network interfaces management. This change implements support for WWAN
links handling. And actively uses the earlier introduced ip-link
capability to specify the parent by its device name.

The WWAN interface for a new data channel should be created with a
command like this:

ip link add dev wwan0-2 parentdev-name wwan0 type wwan linkid 2

Where: wwan0 is the modem HW device name (should be taken from
/sys/class/wwan) and linkid is an identifier of the opened data
channel.

Signed-off-by: Sergey Ryazanov <ryazanov.s.a@gmail.com>
---
 ip/Makefile      |  2 +-
 ip/iplink.c      |  3 +-
 ip/iplink_wwan.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 75 insertions(+), 2 deletions(-)
 create mode 100644 ip/iplink_wwan.c

diff --git a/ip/Makefile b/ip/Makefile
index 4cad619c..b03af29b 100644
--- a/ip/Makefile
+++ b/ip/Makefile
@@ -11,7 +11,7 @@ IPOBJ=ip.o ipaddress.o ipaddrlabel.o iproute.o iprule.o ipnetns.o \
     iplink_bridge.o iplink_bridge_slave.o ipfou.o iplink_ipvlan.o \
     iplink_geneve.o iplink_vrf.o iproute_lwtunnel.o ipmacsec.o ipila.o \
     ipvrf.o iplink_xstats.o ipseg6.o iplink_netdevsim.o iplink_rmnet.o \
-    ipnexthop.o ipmptcp.o iplink_bareudp.o
+    ipnexthop.o ipmptcp.o iplink_bareudp.o iplink_wwan.o
 
 RTMONOBJ=rtmon.o
 
diff --git a/ip/iplink.c b/ip/iplink.c
index 190ce7d9..4073d6e8 100644
--- a/ip/iplink.c
+++ b/ip/iplink.c
@@ -56,7 +56,8 @@ void iplink_types_usage(void)
 		"          ipip | ipoib | ipvlan | ipvtap |\n"
 		"          macsec | macvlan | macvtap |\n"
 		"          netdevsim | nlmon | rmnet | sit | team | team_slave |\n"
-		"          vcan | veth | vlan | vrf | vti | vxcan | vxlan | xfrm }\n");
+		"          vcan | veth | vlan | vrf | vti | vxcan | vxlan | wwan |\n"
+		"          xfrm }\n");
 }
 
 void iplink_usage(void)
diff --git a/ip/iplink_wwan.c b/ip/iplink_wwan.c
new file mode 100644
index 00000000..3510477a
--- /dev/null
+++ b/ip/iplink_wwan.c
@@ -0,0 +1,72 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#include <stdio.h>
+#include <linux/netlink.h>
+#include <linux/wwan.h>
+
+#include "utils.h"
+#include "ip_common.h"
+
+static void print_explain(FILE *f)
+{
+	fprintf(f,
+		"Usage: ... wwan linkid LINKID\n"
+		"\n"
+		"Where: LINKID := 0-4294967295\n"
+	);
+}
+
+static void explain(void)
+{
+	print_explain(stderr);
+}
+
+static int wwan_parse_opt(struct link_util *lu, int argc, char **argv,
+			  struct nlmsghdr *n)
+{
+	while (argc > 0) {
+		if (matches(*argv, "linkid") == 0) {
+			__u32 linkid;
+
+			NEXT_ARG();
+			if (get_u32(&linkid, *argv, 0))
+				invarg("linkid", *argv);
+			addattr32(n, 1024, IFLA_WWAN_LINK_ID, linkid);
+		} else if (matches(*argv, "help") == 0) {
+			explain();
+			return -1;
+		} else {
+			fprintf(stderr, "wwan: unknown command \"%s\"?\n",
+				*argv);
+			explain();
+			return -1;
+		}
+		argc--, argv++;
+	}
+
+	return 0;
+}
+
+static void wwan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
+{
+	if (!tb)
+		return;
+
+	if (tb[IFLA_WWAN_LINK_ID])
+		print_uint(PRINT_ANY, "linkid", "linkid %u ",
+			   rta_getattr_u32(tb[IFLA_WWAN_LINK_ID]));
+}
+
+static void wwan_print_help(struct link_util *lu, int argc, char **argv,
+			    FILE *f)
+{
+	print_explain(f);
+}
+
+struct link_util wwan_link_util = {
+	.id		= "wwan",
+	.maxattr	= IFLA_WWAN_MAX,
+	.parse_opt	= wwan_parse_opt,
+	.print_opt	= wwan_print_opt,
+	.print_help	= wwan_print_help,
+};
-- 
2.26.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-03  4:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-03  4:49 [RFC 0/6] WWAN netdev creation framework tweaks Sergey Ryazanov
2021-06-03  4:49 ` [RFC 1/6] rtnetlink: fix alloc() method introduction Sergey Ryazanov
2021-06-03  4:49 ` [RFC 2/6] wwan: fix module initialization Sergey Ryazanov
2021-06-03  4:49 ` [RFC 3/6] rtnetlink: fill IFLA_PARENT_DEV_NAME on link dump Sergey Ryazanov
2021-06-03  4:49 ` [RFC 4/6 iproute2] Update kernel headers Sergey Ryazanov
2021-06-03  4:49 ` [RFC 5/6 iproute2] iplink: add support for parent device Sergey Ryazanov
2021-06-03  4:49 ` [RFC 6/6 iproute2] iplink: support for WWAN devices Sergey Ryazanov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.