diff options
author | Jiri Pirko <jiri@resnulli.us> | 2014-06-26 03:58:25 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-01 17:40:17 -0400 |
commit | b0ab2fabb5b91da99c189db02e91ae10bc8355c5 (patch) | |
tree | d3d9aa5bb93078b5fcf027c38a18fba652e5007b /net/core/rtnetlink.c | |
parent | 9bf2b8c280b5c02ca8a9e75263bf3ca998fed144 (diff) |
rtnetlink: allow to register ops without ops->setup set
So far, it is assumed that ops->setup is filled up. But there might be
case that ops might make sense even without ->setup. In that case,
forbid to newlink and dellink.
This allows to register simple rtnl link ops containing only ->kind.
That allows consistent way of passing device kind (either device-kind or
slave-kind) to userspace.
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r-- | net/core/rtnetlink.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 1063996f8317..27acaf7ff6d7 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c | |||
@@ -299,7 +299,12 @@ int __rtnl_link_register(struct rtnl_link_ops *ops) | |||
299 | if (rtnl_link_ops_get(ops->kind)) | 299 | if (rtnl_link_ops_get(ops->kind)) |
300 | return -EEXIST; | 300 | return -EEXIST; |
301 | 301 | ||
302 | if (!ops->dellink) | 302 | /* The check for setup is here because if ops |
303 | * does not have that filled up, it is not possible | ||
304 | * to use the ops for creating device. So do not | ||
305 | * fill up dellink as well. That disables rtnl_dellink. | ||
306 | */ | ||
307 | if (ops->setup && !ops->dellink) | ||
303 | ops->dellink = unregister_netdevice_queue; | 308 | ops->dellink = unregister_netdevice_queue; |
304 | 309 | ||
305 | list_add_tail(&ops->list, &link_ops); | 310 | list_add_tail(&ops->list, &link_ops); |
@@ -1777,7 +1782,7 @@ static int rtnl_dellink(struct sk_buff *skb, struct nlmsghdr *nlh) | |||
1777 | return -ENODEV; | 1782 | return -ENODEV; |
1778 | 1783 | ||
1779 | ops = dev->rtnl_link_ops; | 1784 | ops = dev->rtnl_link_ops; |
1780 | if (!ops) | 1785 | if (!ops || !ops->dellink) |
1781 | return -EOPNOTSUPP; | 1786 | return -EOPNOTSUPP; |
1782 | 1787 | ||
1783 | ops->dellink(dev, &list_kill); | 1788 | ops->dellink(dev, &list_kill); |
@@ -2038,6 +2043,9 @@ replay: | |||
2038 | return -EOPNOTSUPP; | 2043 | return -EOPNOTSUPP; |
2039 | } | 2044 | } |
2040 | 2045 | ||
2046 | if (!ops->setup) | ||
2047 | return -EOPNOTSUPP; | ||
2048 | |||
2041 | if (!ifname[0]) | 2049 | if (!ifname[0]) |
2042 | snprintf(ifname, IFNAMSIZ, "%s%%d", ops->kind); | 2050 | snprintf(ifname, IFNAMSIZ, "%s%%d", ops->kind); |
2043 | 2051 | ||