diff options
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/node.c | 27 | ||||
-rw-r--r-- | net/tipc/node.h | 1 | ||||
-rw-r--r-- | net/tipc/socket.c | 29 |
3 files changed, 54 insertions, 3 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c index 3b86a74cb31f..1f938f3dba4b 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -438,3 +438,30 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
438 | rcu_read_unlock(); | 438 | rcu_read_unlock(); |
439 | return buf; | 439 | return buf; |
440 | } | 440 | } |
441 | |||
442 | /** | ||
443 | * tipc_node_get_linkname - get the name of a link | ||
444 | * | ||
445 | * @bearer_id: id of the bearer | ||
446 | * @node: peer node address | ||
447 | * @linkname: link name output buffer | ||
448 | * | ||
449 | * Returns 0 on success | ||
450 | */ | ||
451 | int tipc_node_get_linkname(u32 bearer_id, u32 addr, char *linkname, size_t len) | ||
452 | { | ||
453 | struct tipc_link *link; | ||
454 | struct tipc_node *node = tipc_node_find(addr); | ||
455 | |||
456 | if ((bearer_id > MAX_BEARERS) || !node) | ||
457 | return -EINVAL; | ||
458 | tipc_node_lock(node); | ||
459 | link = node->links[bearer_id]; | ||
460 | if (link) { | ||
461 | strncpy(linkname, link->name, len); | ||
462 | tipc_node_unlock(node); | ||
463 | return 0; | ||
464 | } | ||
465 | tipc_node_unlock(node); | ||
466 | return -EINVAL; | ||
467 | } | ||
diff --git a/net/tipc/node.h b/net/tipc/node.h index 7cbb8cec1a93..411b19114064 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
@@ -118,6 +118,7 @@ int tipc_node_active_links(struct tipc_node *n_ptr); | |||
118 | int tipc_node_is_up(struct tipc_node *n_ptr); | 118 | int tipc_node_is_up(struct tipc_node *n_ptr); |
119 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); | 119 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); |
120 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); | 120 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); |
121 | int tipc_node_get_linkname(u32 bearer_id, u32 node, char *linkname, size_t len); | ||
121 | 122 | ||
122 | static inline void tipc_node_lock(struct tipc_node *n_ptr) | 123 | static inline void tipc_node_lock(struct tipc_node *n_ptr) |
123 | { | 124 | { |
diff --git a/net/tipc/socket.c b/net/tipc/socket.c index 3c0256962f7d..3f9912f87d0d 100644 --- a/net/tipc/socket.c +++ b/net/tipc/socket.c | |||
@@ -36,6 +36,7 @@ | |||
36 | 36 | ||
37 | #include "core.h" | 37 | #include "core.h" |
38 | #include "port.h" | 38 | #include "port.h" |
39 | #include "node.h" | ||
39 | 40 | ||
40 | #include <linux/export.h> | 41 | #include <linux/export.h> |
41 | 42 | ||
@@ -1905,6 +1906,28 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt, | |||
1905 | return put_user(sizeof(value), ol); | 1906 | return put_user(sizeof(value), ol); |
1906 | } | 1907 | } |
1907 | 1908 | ||
1909 | int tipc_ioctl(struct socket *sk, unsigned int cmd, unsigned long arg) | ||
1910 | { | ||
1911 | struct tipc_sioc_ln_req lnr; | ||
1912 | void __user *argp = (void __user *)arg; | ||
1913 | |||
1914 | switch (cmd) { | ||
1915 | case SIOCGETLINKNAME: | ||
1916 | if (copy_from_user(&lnr, argp, sizeof(lnr))) | ||
1917 | return -EFAULT; | ||
1918 | if (!tipc_node_get_linkname(lnr.bearer_id, lnr.peer, | ||
1919 | lnr.linkname, TIPC_MAX_LINK_NAME)) { | ||
1920 | if (copy_to_user(argp, &lnr, sizeof(lnr))) | ||
1921 | return -EFAULT; | ||
1922 | return 0; | ||
1923 | } | ||
1924 | return -EADDRNOTAVAIL; | ||
1925 | break; | ||
1926 | default: | ||
1927 | return -ENOIOCTLCMD; | ||
1928 | } | ||
1929 | } | ||
1930 | |||
1908 | /* Protocol switches for the various types of TIPC sockets */ | 1931 | /* Protocol switches for the various types of TIPC sockets */ |
1909 | 1932 | ||
1910 | static const struct proto_ops msg_ops = { | 1933 | static const struct proto_ops msg_ops = { |
@@ -1917,7 +1940,7 @@ static const struct proto_ops msg_ops = { | |||
1917 | .accept = sock_no_accept, | 1940 | .accept = sock_no_accept, |
1918 | .getname = tipc_getname, | 1941 | .getname = tipc_getname, |
1919 | .poll = tipc_poll, | 1942 | .poll = tipc_poll, |
1920 | .ioctl = sock_no_ioctl, | 1943 | .ioctl = tipc_ioctl, |
1921 | .listen = sock_no_listen, | 1944 | .listen = sock_no_listen, |
1922 | .shutdown = tipc_shutdown, | 1945 | .shutdown = tipc_shutdown, |
1923 | .setsockopt = tipc_setsockopt, | 1946 | .setsockopt = tipc_setsockopt, |
@@ -1938,7 +1961,7 @@ static const struct proto_ops packet_ops = { | |||
1938 | .accept = tipc_accept, | 1961 | .accept = tipc_accept, |
1939 | .getname = tipc_getname, | 1962 | .getname = tipc_getname, |
1940 | .poll = tipc_poll, | 1963 | .poll = tipc_poll, |
1941 | .ioctl = sock_no_ioctl, | 1964 | .ioctl = tipc_ioctl, |
1942 | .listen = tipc_listen, | 1965 | .listen = tipc_listen, |
1943 | .shutdown = tipc_shutdown, | 1966 | .shutdown = tipc_shutdown, |
1944 | .setsockopt = tipc_setsockopt, | 1967 | .setsockopt = tipc_setsockopt, |
@@ -1959,7 +1982,7 @@ static const struct proto_ops stream_ops = { | |||
1959 | .accept = tipc_accept, | 1982 | .accept = tipc_accept, |
1960 | .getname = tipc_getname, | 1983 | .getname = tipc_getname, |
1961 | .poll = tipc_poll, | 1984 | .poll = tipc_poll, |
1962 | .ioctl = sock_no_ioctl, | 1985 | .ioctl = tipc_ioctl, |
1963 | .listen = tipc_listen, | 1986 | .listen = tipc_listen, |
1964 | .shutdown = tipc_shutdown, | 1987 | .shutdown = tipc_shutdown, |
1965 | .setsockopt = tipc_setsockopt, | 1988 | .setsockopt = tipc_setsockopt, |