WWAN netdev creation framework tweaks
Subsystems (3)
Sergey Ryazanov
maintainercover WWAN netdev creation framework tweaks
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.
Sergey Ryazanov
maintainerRFC 1/6 rtnetlink: fix alloc() method introduction
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.
--- net/core/rtnetlink.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
net/core/rtnetlink.c +3 -3
@@ -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 ]) {
Signature · 1 line
2.26.3
Sergey Ryazanov
maintainerRFC 2/6 wwan: fix module initialization
In reply to Sergey RyazanovRecover the successful return from the module initialization function that was accidentally lost during the netdev creation support integration.
--- drivers/net/wwan/wwan_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/wwan/wwan_core.c +2 -1
@@ -737,7 +737,8 @@ static int __init wwan_init(void) goto destroy; } - err =0 ; +return 0 ; + destroy:class_destroy (wwan_class); unregister:
Signature · 1 line
2.26.3
Sergey Ryazanov
maintainerRFC 3/6 rtnetlink: fill IFLA_PARENT_DEV_NAME on link dump
In reply to Sergey RyazanovReturn 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.
--- net/core/rtnetlink.c | 5 +++++ 1 file changed, 5 insertions(+)
net/core/rtnetlink.c +5 -0
@@ -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 ;
Signature · 1 line
2.26.3
Sergey Ryazanov
maintainerRFC 4/6 Update kernel headers
In reply to Sergey RyazanovA partial headers update that brings WWAN-related attributes. Included in the series mainly to make it possible to quickly compile and test the utility.
--- 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
include/uapi/linux/if_link.h +6 -0
@@ -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 };
include/uapi/linux/wwan.h new file +16 -0
@@ -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_ */
Signature · 1 line
2.26.3
Sergey Ryazanov
maintainerRFC 5/6 iplink: add support for parent device
In reply to Sergey RyazanovAdd 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".
--- ip/ipaddress.c | 7 +++++++ ip/iplink.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-)
ip/ipaddress.c +7 -0
@@ -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 ]) {
ip/iplink.c +5 -1
@@ -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 ();
Signature · 1 line
2.26.3
Sergey Ryazanov
maintainerRFC 6/6 iplink: support for WWAN devices
In reply to Sergey RyazanovThe 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.
--- 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
@@ -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
@@ -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