mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 23:32:14 +00:00
tipc: introduce ioctl for fetching node identity
After the introduction of a 128-bit node identity it may be difficult for a user to correlate between this identity and the generated node hash address. We now try to make this easier by introducing a new ioctl() call for fetching a node identity by using the hash value as key. This will be particularly useful when we extend some of the commands in the 'tipc' tool, but we also expect regular user applications to need this feature. Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
79741a38b4
commit
3e5cf362c3
4 changed files with 41 additions and 6 deletions
|
@ -2973,7 +2973,8 @@ static int tipc_getsockopt(struct socket *sock, int lvl, int opt,
|
|||
|
||||
static int tipc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
||||
{
|
||||
struct sock *sk = sock->sk;
|
||||
struct net *net = sock_net(sock->sk);
|
||||
struct tipc_sioc_nodeid_req nr = {0};
|
||||
struct tipc_sioc_ln_req lnr;
|
||||
void __user *argp = (void __user *)arg;
|
||||
|
||||
|
@ -2981,7 +2982,7 @@ static int tipc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
|||
case SIOCGETLINKNAME:
|
||||
if (copy_from_user(&lnr, argp, sizeof(lnr)))
|
||||
return -EFAULT;
|
||||
if (!tipc_node_get_linkname(sock_net(sk),
|
||||
if (!tipc_node_get_linkname(net,
|
||||
lnr.bearer_id & 0xffff, lnr.peer,
|
||||
lnr.linkname, TIPC_MAX_LINK_NAME)) {
|
||||
if (copy_to_user(argp, &lnr, sizeof(lnr)))
|
||||
|
@ -2989,6 +2990,14 @@ static int tipc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
|
|||
return 0;
|
||||
}
|
||||
return -EADDRNOTAVAIL;
|
||||
case SIOCGETNODEID:
|
||||
if (copy_from_user(&nr, argp, sizeof(nr)))
|
||||
return -EFAULT;
|
||||
if (!tipc_node_get_id(net, nr.peer, nr.node_id))
|
||||
return -EADDRNOTAVAIL;
|
||||
if (copy_to_user(argp, &nr, sizeof(nr)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
default:
|
||||
return -ENOIOCTLCMD;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue