We add the support to remove a specific node down with 128bit
node identifier, as an alternative to legacy 32-bit node address.

Signed-off-by: Hoang Le <hoang.h...@dektech.com.au>
---
 net/tipc/node.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/net/tipc/node.c b/net/tipc/node.c
index c8f6177dd5a2..152b98b2e8f5 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1926,8 +1926,11 @@ int tipc_nl_peer_rm(struct sk_buff *skb, struct 
genl_info *info)
        struct net *net = sock_net(skb->sk);
        struct tipc_net *tn = net_generic(net, tipc_net_id);
        struct nlattr *attrs[TIPC_NLA_NET_MAX + 1];
+       u8 node_id[NODE_ID_LEN];
+       u64 *w0 = (u64 *)&node_id[0];
+       u64 *w1 = (u64 *)&node_id[8];
        struct tipc_node *peer;
-       u32 addr;
+       u32 addr = 0;
        int err;
 
        /* We identify the peer by its net */
@@ -1940,16 +1943,26 @@ int tipc_nl_peer_rm(struct sk_buff *skb, struct 
genl_info *info)
        if (err)
                return err;
 
-       if (!attrs[TIPC_NLA_NET_ADDR])
-               return -EINVAL;
-
-       addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]);
+       if (attrs[TIPC_NLA_NET_ADDR]) {
+               addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]);
+               if (!addr)
+                       return -EINVAL;
+               if (in_own_node(net, addr))
+                       return -ENOTSUPP;
+       }
 
-       if (in_own_node(net, addr))
-               return -ENOTSUPP;
+       if (attrs[TIPC_NLA_NET_NODEID]) {
+               if (!attrs[TIPC_NLA_NET_NODEID_W1])
+                       return -EINVAL;
+               *w0 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID]);
+               *w1 = nla_get_u64(attrs[TIPC_NLA_NET_NODEID_W1]);
+       }
 
        spin_lock_bh(&tn->node_list_lock);
-       peer = tipc_node_find(net, addr);
+       if (!addr)
+               peer = tipc_node_find_by_id(net, node_id);
+       else
+               peer = tipc_node_find(net, addr);
        if (!peer) {
                spin_unlock_bh(&tn->node_list_lock);
                return -ENXIO;
-- 
2.20.1



_______________________________________________
tipc-discussion mailing list
tipc-discussion@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tipc-discussion

Reply via email to