Skip to content

Commit

Permalink
Merge branch 'tipc-some-minor-improvements'
Browse files Browse the repository at this point in the history
Jon Maloy says:

====================
tipc: some minor improvements

We add some improvements that will be useful in future commits.
====================

Link: https://lore.kernel.org/r/20201125182915.711370-1-jmaloy@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Nov 28, 2020
2 parents fff4c74 + b6f88d9 commit 6375da9
Show file tree
Hide file tree
Showing 11 changed files with 87 additions and 76 deletions.
7 changes: 3 additions & 4 deletions net/tipc/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,11 @@ bool tipc_in_scope(bool legacy_format, u32 domain, u32 addr)
void tipc_set_node_id(struct net *net, u8 *id)
{
struct tipc_net *tn = tipc_net(net);
u32 *tmp = (u32 *)id;

memcpy(tn->node_id, id, NODE_ID_LEN);
tipc_nodeid2string(tn->node_id_string, id);
tn->trial_addr = tmp[0] ^ tmp[1] ^ tmp[2] ^ tmp[3];
pr_info("Own node identity %s, cluster identity %u\n",
tn->trial_addr = hash128to32(id);
pr_info("Node identity %s, cluster identity %u\n",
tipc_own_id_string(net), tn->net_id);
}

Expand All @@ -76,7 +75,7 @@ void tipc_set_node_addr(struct net *net, u32 addr)
}
tn->trial_addr = addr;
tn->addr_trial_end = jiffies;
pr_info("32-bit node address hash set to %x\n", addr);
pr_info("Node number set to %u\n", addr);
}

char *tipc_nodeid2string(char *str, u8 *id)
Expand Down
1 change: 1 addition & 0 deletions net/tipc/addr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* Copyright (c) 2000-2006, 2018, Ericsson AB
* Copyright (c) 2004-2005, Wind River Systems
* Copyright (c) 2020, Red Hat Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down
12 changes: 12 additions & 0 deletions net/tipc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* Copyright (c) 2005-2006, 2013-2018 Ericsson AB
* Copyright (c) 2005-2007, 2010-2013, Wind River Systems
* Copyright (c) 2020, Red Hat Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -210,6 +211,17 @@ static inline u32 tipc_net_hash_mixes(struct net *net, int tn_rand)
return net_hash_mix(&init_net) ^ net_hash_mix(net) ^ tn_rand;
}

static inline u32 hash128to32(char *bytes)
{
__be32 *tmp = (__be32 *)bytes;
u32 res;

res = ntohl(tmp[0] ^ tmp[1] ^ tmp[2] ^ tmp[3]);
if (likely(res))
return res;
return ntohl(tmp[0] | tmp[1] | tmp[2] | tmp[3]);
}

#ifdef CONFIG_SYSCTL
int tipc_register_sysctl(void);
void tipc_unregister_sysctl(void);
Expand Down
3 changes: 2 additions & 1 deletion net/tipc/group.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* net/tipc/group.c: TIPC group messaging code
*
* Copyright (c) 2017, Ericsson AB
* Copyright (c) 2020, Red Hat Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -359,7 +360,7 @@ struct tipc_nlist *tipc_group_dests(struct tipc_group *grp)
return &grp->dests;
}

void tipc_group_self(struct tipc_group *grp, struct tipc_name_seq *seq,
void tipc_group_self(struct tipc_group *grp, struct tipc_service_range *seq,
int *scope)
{
seq->type = grp->type;
Expand Down
3 changes: 2 additions & 1 deletion net/tipc/group.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* net/tipc/group.h: Include file for TIPC group unicast/multicast functions
*
* Copyright (c) 2017, Ericsson AB
* Copyright (c) 2020, Red Hat Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -50,7 +51,7 @@ void tipc_group_delete(struct net *net, struct tipc_group *grp);
void tipc_group_add_member(struct tipc_group *grp, u32 node,
u32 port, u32 instance);
struct tipc_nlist *tipc_group_dests(struct tipc_group *grp);
void tipc_group_self(struct tipc_group *grp, struct tipc_name_seq *seq,
void tipc_group_self(struct tipc_group *grp, struct tipc_service_range *seq,
int *scope);
u32 tipc_group_exclude(struct tipc_group *grp);
void tipc_group_filter_msg(struct tipc_group *grp,
Expand Down
11 changes: 6 additions & 5 deletions net/tipc/name_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*
* Copyright (c) 2000-2006, 2014-2018, Ericsson AB
* Copyright (c) 2004-2008, 2010-2014, Wind River Systems
* Copyright (c) 2020, Red Hat Inc
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -403,12 +404,12 @@ static void tipc_service_subscribe(struct tipc_service *service,
struct publication *p, *first, *tmp;
struct list_head publ_list;
struct service_range *sr;
struct tipc_name_seq ns;
struct tipc_service_range r;
u32 filter;

ns.type = tipc_sub_read(sb, seq.type);
ns.lower = tipc_sub_read(sb, seq.lower);
ns.upper = tipc_sub_read(sb, seq.upper);
r.type = tipc_sub_read(sb, seq.type);
r.lower = tipc_sub_read(sb, seq.lower);
r.upper = tipc_sub_read(sb, seq.upper);
filter = tipc_sub_read(sb, filter);

tipc_sub_get(sub);
Expand All @@ -418,7 +419,7 @@ static void tipc_service_subscribe(struct tipc_service *service,
return;

INIT_LIST_HEAD(&publ_list);
service_range_foreach_match(sr, service, ns.lower, ns.upper) {
service_range_foreach_match(sr, service, r.lower, r.upper) {
first = NULL;
list_for_each_entry(p, &sr->all_publ, all_publ) {
if (filter & TIPC_SUB_PORTS)
Expand Down
2 changes: 1 addition & 1 deletion net/tipc/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void tipc_net_finalize(struct net *net, u32 addr)
tipc_named_reinit(net);
tipc_sk_reinit(net);
tipc_mon_reinit_self(net);
tipc_nametbl_publish(net, TIPC_CFG_SRV, addr, addr,
tipc_nametbl_publish(net, TIPC_NODE_STATE, addr, addr,
TIPC_CLUSTER_SCOPE, 0, addr);
}

Expand Down
Loading

0 comments on commit 6375da9

Please sign in to comment.