diff options
author | Srivatsa Vaddagiri <svaddagi@qti.qualcomm.com> | 2017-03-27 04:18:03 -0700 |
---|---|---|
committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2017-03-27 04:18:03 -0700 |
commit | 5d73b258df5f6110c447f14aa78f1903d90fa8d9 (patch) | |
tree | cdd8d1f7f8c3a9d363df40c3439c86f7d3fb61d8 | |
parent | 8a7668835ad5e85869c3d860735c6cb914bbcc63 (diff) | |
parent | d64bd3ead74add975329c9bf8f211ca899e788b7 (diff) |
Merge "net: rmnet_data: Add support to configure custom device name" into dev/msm-4.4-8996au
-rw-r--r-- | include/uapi/linux/rmnet_data.h | 15 | ||||
-rw-r--r-- | net/rmnet_data/rmnet_data_config.c | 30 | ||||
-rw-r--r-- | net/rmnet_data/rmnet_data_config.h | 1 | ||||
-rw-r--r-- | net/rmnet_data/rmnet_data_vnd.c | 15 | ||||
-rw-r--r-- | net/rmnet_data/rmnet_data_vnd.h | 4 |
5 files changed, 52 insertions, 13 deletions
diff --git a/include/uapi/linux/rmnet_data.h b/include/uapi/linux/rmnet_data.h index 8cfe0270ef4f..7ddfa20cec32 100644 --- a/include/uapi/linux/rmnet_data.h +++ b/include/uapi/linux/rmnet_data.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2015, 2017 The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -223,8 +223,19 @@ enum rmnet_netlink_message_types_e { * uint32_t MAP Flow Handle * Returns: status code */ - RMNET_NETLINK_DEL_VND_TC_FLOW + RMNET_NETLINK_DEL_VND_TC_FLOW, + + /* + * RMNET_NETLINK_NEW_VND_WITH_NAME - Creates a new virtual network + * device node with the specified + * device name + * Args: int32_t node number + * char[] vnd_name - Use as name + * Returns: status code + */ + RMNET_NETLINK_NEW_VND_WITH_NAME }; +#define RMNET_NETLINK_NEW_VND_WITH_NAME RMNET_NETLINK_NEW_VND_WITH_NAME enum rmnet_config_endpoint_modes_e { /* Pass the frame up the stack with no modifications to skb->dev */ diff --git a/net/rmnet_data/rmnet_data_config.c b/net/rmnet_data/rmnet_data_config.c index fb4c60fc2203..fad084d03854 100644 --- a/net/rmnet_data/rmnet_data_config.c +++ b/net/rmnet_data/rmnet_data_config.c @@ -638,6 +638,13 @@ void rmnet_config_netlink_msg_handler(struct sk_buff *skb) rmnet_header->vnd.vnd_name); break; + case RMNET_NETLINK_NEW_VND_WITH_NAME: + resp_rmnet->crd = RMNET_NETLINK_MSG_RETURNCODE; + resp_rmnet->return_code = rmnet_create_vnd_name( + rmnet_header->vnd.id, + rmnet_header->vnd.vnd_name); + break; + case RMNET_NETLINK_FREE_VND: resp_rmnet->crd = RMNET_NETLINK_MSG_RETURNCODE; /* Please check rmnet_vnd_free_dev documentation regarding @@ -1087,11 +1094,11 @@ int rmnet_create_vnd(int id) struct net_device *dev; ASSERT_RTNL(); LOGL("(%d);", id); - return rmnet_vnd_create_dev(id, &dev, NULL); + return rmnet_vnd_create_dev(id, &dev, NULL, 0); } /** - * rmnet_create_vnd() - Create virtual network device node + * rmnet_create_vnd_prefix() - Create virtual network device node * @id: RmNet virtual device node id * @prefix: String prefix for device name * @@ -1103,7 +1110,24 @@ int rmnet_create_vnd_prefix(int id, const char *prefix) struct net_device *dev; ASSERT_RTNL(); LOGL("(%d, \"%s\");", id, prefix); - return rmnet_vnd_create_dev(id, &dev, prefix); + return rmnet_vnd_create_dev(id, &dev, prefix, 0); +} + +/** + * rmnet_create_vnd_name() - Create virtual network device node + * @id: RmNet virtual device node id + * @prefix: String prefix for device name + * + * Return: + * - result of rmnet_vnd_create_dev() + */ +int rmnet_create_vnd_name(int id, const char *name) +{ + struct net_device *dev; + + ASSERT_RTNL(); + LOGL("(%d, \"%s\");", id, name); + return rmnet_vnd_create_dev(id, &dev, name, 1); } /** diff --git a/net/rmnet_data/rmnet_data_config.h b/net/rmnet_data/rmnet_data_config.h index f19fbb378111..208c3a40c3ae 100644 --- a/net/rmnet_data/rmnet_data_config.h +++ b/net/rmnet_data/rmnet_data_config.h @@ -124,6 +124,7 @@ int rmnet_config_notify_cb(struct notifier_block *nb, unsigned long event, void *data); int rmnet_create_vnd(int id); int rmnet_create_vnd_prefix(int id, const char *name); +int rmnet_create_vnd_name(int id, const char *name); int rmnet_free_vnd(int id); struct rmnet_phys_ep_config *_rmnet_get_phys_ep_config diff --git a/net/rmnet_data/rmnet_data_vnd.c b/net/rmnet_data/rmnet_data_vnd.c index 2819da9ae3f2..ede1a54661cd 100644 --- a/net/rmnet_data/rmnet_data_vnd.c +++ b/net/rmnet_data/rmnet_data_vnd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -565,7 +565,7 @@ int rmnet_vnd_init(void) * - RMNET_CONFIG_UNKNOWN_ERROR if register_netdevice() fails */ int rmnet_vnd_create_dev(int id, struct net_device **new_device, - const char *prefix) + const char *prefix, int use_name) { struct net_device *dev; char dev_prefix[IFNAMSIZ]; @@ -581,12 +581,15 @@ int rmnet_vnd_create_dev(int id, struct net_device **new_device, return RMNET_CONFIG_DEVICE_IN_USE; } - if (!prefix) + if (!prefix && !use_name) p = scnprintf(dev_prefix, IFNAMSIZ, "%s%%d", RMNET_DATA_DEV_NAME_STR); + else if (prefix && use_name) + p = scnprintf(dev_prefix, IFNAMSIZ, "%s", prefix); + else if (prefix && !use_name) + p = scnprintf(dev_prefix, IFNAMSIZ, "%s%%d", prefix); else - p = scnprintf(dev_prefix, IFNAMSIZ, "%s%%d", - prefix); + return RMNET_CONFIG_BAD_ARGUMENTS; if (p >= (IFNAMSIZ-1)) { LOGE("Specified prefix longer than IFNAMSIZ"); return RMNET_CONFIG_BAD_ARGUMENTS; @@ -594,7 +597,7 @@ int rmnet_vnd_create_dev(int id, struct net_device **new_device, dev = alloc_netdev(sizeof(struct rmnet_vnd_private_s), dev_prefix, - NET_NAME_ENUM, + use_name ? NET_NAME_UNKNOWN : NET_NAME_ENUM, rmnet_vnd_setup); if (!dev) { LOGE("Failed to to allocate netdev for id %d", id); diff --git a/net/rmnet_data/rmnet_data_vnd.h b/net/rmnet_data/rmnet_data_vnd.h index 22ffcfc2e08e..7a1af24fa051 100644 --- a/net/rmnet_data/rmnet_data_vnd.h +++ b/net/rmnet_data/rmnet_data_vnd.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -27,7 +27,7 @@ int rmnet_vnd_do_flow_control(struct net_device *dev, struct rmnet_logical_ep_conf_s *rmnet_vnd_get_le_config(struct net_device *dev); int rmnet_vnd_get_name(int id, char *name, int name_len); int rmnet_vnd_create_dev(int id, struct net_device **new_device, - const char *prefix); + const char *prefix, int use_name); int rmnet_vnd_free_dev(int id); int rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev); int rmnet_vnd_tx_fixup(struct sk_buff *skb, struct net_device *dev); |