Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 23fd3eac authored by Jon Maloy's avatar Jon Maloy Committed by David S. Miller
Browse files

tipc: remove direct accesses to own_addr field in struct tipc_net



As a preparation to changing the addressing structure of TIPC we replace
all direct accesses to the tipc_net::own_addr field with the function
dedicated for this, tipc_own_addr().

There are no changes to program logics in this commit.

Acked-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b89afb11
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -43,9 +43,7 @@
 */
 */
int in_own_node(struct net *net, u32 addr)
int in_own_node(struct net *net, u32 addr)
{
{
	struct tipc_net *tn = net_generic(net, tipc_net_id);
	return addr == tipc_own_addr(net) || !addr;

	return (addr == tn->own_addr) || !addr;
}
}


bool tipc_in_scope(bool legacy_format, u32 domain, u32 addr)
bool tipc_in_scope(bool legacy_format, u32 domain, u32 addr)
@@ -56,6 +54,8 @@ bool tipc_in_scope(bool legacy_format, u32 domain, u32 addr)
		return false;
		return false;
	if (domain == tipc_cluster_mask(addr)) /* domain <Z.C.0> */
	if (domain == tipc_cluster_mask(addr)) /* domain <Z.C.0> */
		return true;
		return true;
	if (domain == (addr & TIPC_ZONE_CLUSTER_MASK)) /* domain <Z.C.0> */
		return true;
	if (domain == (addr & TIPC_ZONE_MASK)) /* domain <Z.0.0> */
	if (domain == (addr & TIPC_ZONE_MASK)) /* domain <Z.0.0> */
		return true;
		return true;
	return false;
	return false;
+1 −1
Original line number Original line Diff line number Diff line
@@ -45,7 +45,7 @@


static inline u32 tipc_own_addr(struct net *net)
static inline u32 tipc_own_addr(struct net *net)
{
{
	struct tipc_net *tn = net_generic(net, tipc_net_id);
	struct tipc_net *tn = tipc_net(net);


	return tn->own_addr;
	return tn->own_addr;
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -81,11 +81,12 @@ static void tipc_disc_init_msg(struct net *net, struct sk_buff *skb,
			       u32 mtyp, struct tipc_bearer *b)
			       u32 mtyp, struct tipc_bearer *b)
{
{
	struct tipc_net *tn = tipc_net(net);
	struct tipc_net *tn = tipc_net(net);
	u32 self = tipc_own_addr(net);
	u32 dest_domain = b->domain;
	u32 dest_domain = b->domain;
	struct tipc_msg *hdr;
	struct tipc_msg *hdr;


	hdr = buf_msg(skb);
	hdr = buf_msg(skb);
	tipc_msg_init(tn->own_addr, hdr, LINK_CONFIG, mtyp,
	tipc_msg_init(self, hdr, LINK_CONFIG, mtyp,
		      MAX_H_SIZE, dest_domain);
		      MAX_H_SIZE, dest_domain);
	msg_set_non_seq(hdr, 1);
	msg_set_non_seq(hdr, 1);
	msg_set_node_sig(hdr, tn->random);
	msg_set_node_sig(hdr, tn->random);
+4 −5
Original line number Original line Diff line number Diff line
@@ -1936,11 +1936,11 @@ static int __tipc_nl_add_stats(struct sk_buff *skb, struct tipc_stats *s)
int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
		       struct tipc_link *link, int nlflags)
		       struct tipc_link *link, int nlflags)
{
{
	int err;
	u32 self = tipc_own_addr(net);
	void *hdr;
	struct nlattr *attrs;
	struct nlattr *attrs;
	struct nlattr *prop;
	struct nlattr *prop;
	struct tipc_net *tn = net_generic(net, tipc_net_id);
	void *hdr;
	int err;


	hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
	hdr = genlmsg_put(msg->skb, msg->portid, msg->seq, &tipc_genl_family,
			  nlflags, TIPC_NL_LINK_GET);
			  nlflags, TIPC_NL_LINK_GET);
@@ -1953,8 +1953,7 @@ int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,


	if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name))
	if (nla_put_string(msg->skb, TIPC_NLA_LINK_NAME, link->name))
		goto attr_msg_full;
		goto attr_msg_full;
	if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST,
	if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST, tipc_cluster_mask(self)))
			tipc_cluster_mask(tn->own_addr)))
		goto attr_msg_full;
		goto attr_msg_full;
	if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu))
	if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu))
		goto attr_msg_full;
		goto attr_msg_full;
+6 −5
Original line number Original line Diff line number Diff line
@@ -68,14 +68,14 @@ static void publ_to_item(struct distr_item *i, struct publication *p)
static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size,
static struct sk_buff *named_prepare_buf(struct net *net, u32 type, u32 size,
					 u32 dest)
					 u32 dest)
{
{
	struct tipc_net *tn = net_generic(net, tipc_net_id);
	struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size, GFP_ATOMIC);
	struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE + size, GFP_ATOMIC);
	u32 self = tipc_own_addr(net);
	struct tipc_msg *msg;
	struct tipc_msg *msg;


	if (buf != NULL) {
	if (buf != NULL) {
		msg = buf_msg(buf);
		msg = buf_msg(buf);
		tipc_msg_init(tn->own_addr, msg, NAME_DISTRIBUTOR, type,
		tipc_msg_init(self, msg, NAME_DISTRIBUTOR,
			      INT_H_SIZE, dest);
			      type, INT_H_SIZE, dest);
		msg_set_size(msg, INT_H_SIZE + size);
		msg_set_size(msg, INT_H_SIZE + size);
	}
	}
	return buf;
	return buf;
@@ -382,13 +382,14 @@ void tipc_named_reinit(struct net *net)
	struct name_table *nt = tipc_name_table(net);
	struct name_table *nt = tipc_name_table(net);
	struct tipc_net *tn = tipc_net(net);
	struct tipc_net *tn = tipc_net(net);
	struct publication *publ;
	struct publication *publ;
	u32 self = tipc_own_addr(net);


	spin_lock_bh(&tn->nametbl_lock);
	spin_lock_bh(&tn->nametbl_lock);


	list_for_each_entry_rcu(publ, &nt->node_scope, binding_node)
	list_for_each_entry_rcu(publ, &nt->node_scope, binding_node)
		publ->node = tn->own_addr;
		publ->node = self;
	list_for_each_entry_rcu(publ, &nt->cluster_scope, binding_node)
	list_for_each_entry_rcu(publ, &nt->cluster_scope, binding_node)
		publ->node = tn->own_addr;
		publ->node = self;


	spin_unlock_bh(&tn->nametbl_lock);
	spin_unlock_bh(&tn->nametbl_lock);
}
}
Loading