Skip to contentSkip to conversation

ip: wwan links management support

PATCH Applied Sergey Ryazanov 2 participants 4 messages Jun 22, 2021 – Jun 26, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover ip: wwan links management support

This short series introduces support for WWAN links support.

First patch adds support for new common attributes: parent device name and parent device bus name. The former attribute required to create a new WWAN link. Finally, the second patch introduces support for a new 'wwan' link type.

Changelong:
v1 -> v2
* shorten the 'parentdevbus' parameter to 'parentbus', as Parav suggested and Loic recalled
RFC -> v1
* drop the kernel headers update patch
* add a parent device bus attribute support
* shorten the 'parentdev-name' parameter to just 'parentdev'

Sergey Ryazanov (2):
iplink: add support for parent device
iplink: support for WWAN devices

 ip/Makefile      |  2 +-
 ip/ipaddress.c   | 14 ++++++++++
 ip/iplink.c      |  9 ++++--
 ip/iplink_wwan.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+), 3 deletions(-)
 create mode 100644 ip/iplink_wwan.c
Signature · 1 line
2.26.3
#1 lore raw

PATCH v2 1/2 iplink: add support for parent device

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".

Add the parent device bus name printing for links list info completeness. But do not add a corresponding command line argument, as we do not have a use case for this attribute.

---
Changes since v1:
* shorten the 'parentdevbus' parameter to 'parentbus', as Parav suggested and Loic recalled

Changes since RFC:
* add a parent device bus attribute support
* shorten the 'parentdev-name' parameter to just 'parentdev'

 ip/ipaddress.c | 14 ++++++++++++++
 ip/iplink.c    |  6 +++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
ip/ipaddress.c +14 -0
index 06ca7273..85534aaf 100644
@@ -1242,6 +1242,20 @@ int print_linkinfo(struct nlmsghdr *n, void *arg)
 						   RTA_PAYLOAD(tb[IFLA_PHYS_SWITCH_ID]),
 						   b1, sizeof(b1)));
 		}
+
+		if (tb[IFLA_PARENT_DEV_BUS_NAME]) {
+			print_string(PRINT_ANY,
+				     "parentbus",
+				     "parentbus %s ",
+				     rta_getattr_str(tb[IFLA_PARENT_DEV_BUS_NAME]));
+		}
+
+		if (tb[IFLA_PARENT_DEV_NAME]) {
+			print_string(PRINT_ANY,
+				     "parentdev",
+				     "parentdev %s ",
+				     rta_getattr_str(tb[IFLA_PARENT_DEV_NAME]));
+		}
 	}
 
 	if ((do_link || show_details) && tb[IFLA_IFALIAS]) {
ip/iplink.c +5 -1
index faafd7e8..33b7be30 100644
@@ -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\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") == 0) {
+			NEXT_ARG();
+			addattr_l(&req->n, sizeof(*req), IFLA_PARENT_DEV_NAME,
+				  *argv, strlen(*argv) + 1);
 		} else {
 			if (matches(*argv, "help") == 0)
 				usage();
Signature · 1 line
2.26.3
#2 lore raw

PATCH v2 2/2 iplink: support for WWAN devices

In reply to Sergey Ryazanov

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 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.

---
To compile this, a new uapi/linux/wwan.h header file should be copied from the kernel sources.

Changes since v1:
* no changes

Changes since RFC:
* no changes

 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
ip/Makefile +1 -1
index 4cad619c..b03af29b 100644
@@ -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
 
ip/iplink.c +2 -1
index 33b7be30..18b2ea25 100644
@@ -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)
ip/iplink_wwan.c new file +72 -0

72 lines not on this page · raw message

Signature · 1 line
2.26.3
Applied
#3 lore raw
In reply to Sergey Ryazanov
Quoted 20 lines · Sergey Ryazanov

This short series introduces support for WWAN links support.

First patch adds support for new common attributes: parent device name and parent device bus name. The former attribute required to create a new WWAN link. Finally, the second patch introduces support for a new 'wwan' link type.

Changelong:
v1 -> v2
* shorten the 'parentdevbus' parameter to 'parentbus', as Parav suggested and Loic recalled
RFC -> v1
* drop the kernel headers update patch
* add a parent device bus attribute support
* shorten the 'parentdev-name' parameter to just 'parentdev'

Sergey Ryazanov (2):
iplink: add support for parent device
iplink: support for WWAN devices

Quoted 7 lines
 ip/Makefile      |  2 +-
 ip/ipaddress.c   | 14 ++++++++++
 ip/iplink.c      |  9 ++++--
 ip/iplink_wwan.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+), 3 deletions(-)
 create mode 100644 ip/iplink_wwan.c

applied to iproute2-next. Thanks,