diff options
author | Jakub Kicinski <kuba@kernel.org> | 2022-04-29 16:55:07 -0700 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2022-05-02 15:14:20 +0200 |
commit | 63105e83987a08f73accfba78602a073bf219b69 (patch) | |
tree | 1e7f6d182164d30551406ed11f72dfe76fd07853 /net | |
parent | c92bf26ccebc8501863b38c4a4f65b8fef28ce5e (diff) | |
download | lwn-63105e83987a08f73accfba78602a073bf219b69.tar.gz lwn-63105e83987a08f73accfba78602a073bf219b69.zip |
rtnl: split __rtnl_newlink() into two functions
__rtnl_newlink() is 250LoC, but has a few clear sections.
Move the part which creates a new netdev to a separate
function.
For ease of review code will be moved in the next change.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net')
-rw-r--r-- | net/core/rtnetlink.c | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 33919fd5c202..1deef11c6b4d 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -3302,6 +3302,11 @@ static int rtnl_group_changelink(const struct sk_buff *skb, return 0; } +static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm, + const struct rtnl_link_ops *ops, + struct nlattr **tb, struct nlattr **data, + struct netlink_ext_ack *extack); + struct rtnl_newlink_tbs { struct nlattr *tb[IFLA_MAX + 1]; struct nlattr *attr[RTNL_MAX_TYPE + 1]; @@ -3312,19 +3317,16 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh, struct rtnl_newlink_tbs *tbs, struct netlink_ext_ack *extack) { - unsigned char name_assign_type = NET_NAME_USER; struct nlattr *linkinfo[IFLA_INFO_MAX + 1]; struct nlattr ** const tb = tbs->tb; const struct rtnl_link_ops *m_ops; struct net_device *master_dev; struct net *net = sock_net(skb->sk); const struct rtnl_link_ops *ops; - struct net *dest_net, *link_net; struct nlattr **slave_data; char kind[MODULE_NAME_LEN]; struct net_device *dev; struct ifinfomsg *ifm; - char ifname[IFNAMSIZ]; struct nlattr **data; bool link_specified; int err; @@ -3484,6 +3486,21 @@ replay: return -EOPNOTSUPP; } + return rtnl_newlink_create(skb, ifm, ops, tb, data, extack); +} + +static int rtnl_newlink_create(struct sk_buff *skb, struct ifinfomsg *ifm, + const struct rtnl_link_ops *ops, + struct nlattr **tb, struct nlattr **data, + struct netlink_ext_ack *extack) +{ + unsigned char name_assign_type = NET_NAME_USER; + struct net *net = sock_net(skb->sk); + struct net *dest_net, *link_net; + struct net_device *dev; + char ifname[IFNAMSIZ]; + int err; + if (!ops->alloc && !ops->setup) return -EOPNOTSUPP; |