Skip to content

Commit c72fa87

Browse files
Jon Paul Maloydavem330
authored andcommitted
tipc: eliminate link's reference to owner node
With the recent commit series, we have established a one-way dependency between the link aggregation (struct tipc_node) instances and their pertaining tipc_link instances. This has enabled quite significant code and structure simplifications. In this commit, we eliminate the field 'owner', which points to an instance of struct tipc_node, from struct tipc_link, and replace it with a pointer to struct net, which is the only external reference now needed by a link instance. Signed-off-by: Jon Maloy <[email protected]> Reviewed-by: Ying Xue <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7214bcf commit c72fa87

File tree

4 files changed

+29
-22
lines changed

4 files changed

+29
-22
lines changed

net/tipc/bcast.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,7 @@ int tipc_bcast_init(struct net *net)
12261226
spin_lock_init(&tipc_net(net)->bclock);
12271227
bb->node.net = net;
12281228

1229-
if (!tipc_link_bc_create(&bb->node, 0, 0,
1229+
if (!tipc_link_bc_create(net, 0, 0,
12301230
U16_MAX,
12311231
BCLINK_WIN_DEFAULT,
12321232
0,

net/tipc/link.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,12 @@ bool link_is_bc_rcvlink(struct tipc_link *l)
175175

176176
int tipc_link_is_active(struct tipc_link *l)
177177
{
178-
struct tipc_node *n = l->owner;
178+
return l->active;
179+
}
179180

180-
return (node_active_link(n, 0) == l) || (node_active_link(n, 1) == l);
181+
void tipc_link_set_active(struct tipc_link *l, bool active)
182+
{
183+
l->active = active;
181184
}
182185

183186
void tipc_link_add_bc_peer(struct tipc_link *snd_l,
@@ -250,7 +253,7 @@ static u32 link_own_addr(struct tipc_link *l)
250253
*
251254
* Returns true if link was created, otherwise false
252255
*/
253-
bool tipc_link_create(struct tipc_node *n, char *if_name, int bearer_id,
256+
bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
254257
int tolerance, char net_plane, u32 mtu, int priority,
255258
int window, u32 session, u32 ownnode, u32 peer,
256259
u16 peer_caps,
@@ -284,7 +287,7 @@ bool tipc_link_create(struct tipc_node *n, char *if_name, int bearer_id,
284287
l->addr = peer;
285288
l->peer_caps = peer_caps;
286289
l->media_addr = maddr;
287-
l->owner = n;
290+
l->net = net;
288291
l->peer_session = WILDCARD_SESSION;
289292
l->bearer_id = bearer_id;
290293
l->tolerance = tolerance;
@@ -318,7 +321,7 @@ bool tipc_link_create(struct tipc_node *n, char *if_name, int bearer_id,
318321
*
319322
* Returns true if link was created, otherwise false
320323
*/
321-
bool tipc_link_bc_create(struct tipc_node *n, u32 ownnode, u32 peer,
324+
bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
322325
int mtu, int window, u16 peer_caps,
323326
struct sk_buff_head *inputq,
324327
struct sk_buff_head *namedq,
@@ -327,7 +330,7 @@ bool tipc_link_bc_create(struct tipc_node *n, u32 ownnode, u32 peer,
327330
{
328331
struct tipc_link *l;
329332

330-
if (!tipc_link_create(n, "", MAX_BEARERS, 0, 'Z', mtu, 0, window,
333+
if (!tipc_link_create(net, "", MAX_BEARERS, 0, 'Z', mtu, 0, window,
331334
0, ownnode, peer, peer_caps, NULL, bc_sndlink,
332335
NULL, inputq, namedq, link))
333336
return false;
@@ -889,10 +892,10 @@ void tipc_link_push_packets(struct tipc_link *link)
889892
msg_set_ack(msg, ack);
890893
msg_set_seqno(msg, seqno);
891894
seqno = mod(seqno + 1);
892-
msg_set_bcast_ack(msg, link->owner->bclink.last_in);
895+
/* msg_set_bcast_ack(msg, link->owner->bclink.last_in); */
893896
link->rcv_unacked = 0;
894897
__skb_queue_tail(&link->transmq, skb);
895-
tipc_bearer_send(link->owner->net, link->bearer_id,
898+
tipc_bearer_send(link->net, link->bearer_id,
896899
skb, link->media_addr);
897900
}
898901
link->snd_nxt = seqno;
@@ -966,8 +969,8 @@ void tipc_link_retransmit(struct tipc_link *l_ptr, struct sk_buff *skb,
966969
break;
967970
msg = buf_msg(skb);
968971
msg_set_ack(msg, mod(l_ptr->rcv_nxt - 1));
969-
msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in);
970-
tipc_bearer_send(l_ptr->owner->net, l_ptr->bearer_id, skb,
972+
/* msg_set_bcast_ack(msg, l_ptr->owner->bclink.last_in); */
973+
tipc_bearer_send(l_ptr->net, l_ptr->bearer_id, skb,
971974
l_ptr->media_addr);
972975
retransmits--;
973976
l_ptr->stats.retransmitted++;
@@ -1102,9 +1105,9 @@ static int tipc_link_input(struct tipc_link *l, struct sk_buff *skb,
11021105
}
11031106
return 0;
11041107
} else if (usr == BCAST_PROTOCOL) {
1105-
tipc_bcast_lock(l->owner->net);
1108+
tipc_bcast_lock(l->net);
11061109
tipc_link_bc_init_rcv(l->bc_rcvlink, hdr);
1107-
tipc_bcast_unlock(l->owner->net);
1110+
tipc_bcast_unlock(l->net);
11081111
}
11091112
drop:
11101113
kfree_skb(skb);
@@ -1300,7 +1303,7 @@ void tipc_link_proto_xmit(struct tipc_link *l, u32 msg_typ, int probe_msg,
13001303
skb = __skb_dequeue(&xmitq);
13011304
if (!skb)
13021305
return;
1303-
tipc_bearer_xmit_skb(l->owner->net, l->bearer_id, skb, l->media_addr);
1306+
tipc_bearer_xmit_skb(l->net, l->bearer_id, skb, l->media_addr);
13041307
l->rcv_unacked = 0;
13051308
}
13061309

@@ -2004,7 +2007,7 @@ static int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
20042007
if (tipc_link_is_up(link))
20052008
if (nla_put_flag(msg->skb, TIPC_NLA_LINK_UP))
20062009
goto attr_msg_full;
2007-
if (tipc_link_is_active(link))
2010+
if (link->active)
20082011
if (nla_put_flag(msg->skb, TIPC_NLA_LINK_ACTIVE))
20092012
goto attr_msg_full;
20102013

net/tipc/link.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ struct tipc_stats {
111111
* @name: link name character string
112112
* @media_addr: media address to use when sending messages over link
113113
* @timer: link timer
114-
* @owner: pointer to peer node
114+
* @net: pointer to namespace struct
115115
* @refcnt: reference counter for permanent references (owner node & timer)
116116
* @peer_session: link session # being used by peer end of link
117117
* @peer_bearer_id: bearer id used by link's peer endpoint
@@ -154,7 +154,7 @@ struct tipc_link {
154154
u32 addr;
155155
char name[TIPC_MAX_LINK_NAME];
156156
struct tipc_media_addr *media_addr;
157-
struct tipc_node *owner;
157+
struct net *net;
158158

159159
/* Management and link supervision data */
160160
u32 peer_session;
@@ -165,6 +165,7 @@ struct tipc_link {
165165
u32 abort_limit;
166166
u32 state;
167167
u16 peer_caps;
168+
bool active;
168169
u32 silent_intv_cnt;
169170
struct {
170171
unchar hdr[INT_H_SIZE];
@@ -219,7 +220,7 @@ struct tipc_link {
219220
struct tipc_stats stats;
220221
};
221222

222-
bool tipc_link_create(struct tipc_node *n, char *if_name, int bearer_id,
223+
bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
223224
int tolerance, char net_plane, u32 mtu, int priority,
224225
int window, u32 session, u32 ownnode, u32 peer,
225226
u16 peer_caps,
@@ -229,7 +230,7 @@ bool tipc_link_create(struct tipc_node *n, char *if_name, int bearer_id,
229230
struct sk_buff_head *inputq,
230231
struct sk_buff_head *namedq,
231232
struct tipc_link **link);
232-
bool tipc_link_bc_create(struct tipc_node *n, u32 ownnode, u32 peer,
233+
bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer,
233234
int mtu, int window, u16 peer_caps,
234235
struct sk_buff_head *inputq,
235236
struct sk_buff_head *namedq,
@@ -247,7 +248,7 @@ bool tipc_link_is_establishing(struct tipc_link *l);
247248
bool tipc_link_is_synching(struct tipc_link *l);
248249
bool tipc_link_is_failingover(struct tipc_link *l);
249250
bool tipc_link_is_blocked(struct tipc_link *l);
250-
int tipc_link_is_active(struct tipc_link *l_ptr);
251+
void tipc_link_set_active(struct tipc_link *l, bool active);
251252
void tipc_link_purge_queues(struct tipc_link *l_ptr);
252253
void tipc_link_purge_backlog(struct tipc_link *l);
253254
void tipc_link_reset(struct tipc_link *l_ptr);

net/tipc/node.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u16 capabilities)
178178
n_ptr->signature = INVALID_NODE_SIG;
179179
n_ptr->active_links[0] = INVALID_BEARER_ID;
180180
n_ptr->active_links[1] = INVALID_BEARER_ID;
181-
if (!tipc_link_bc_create(n_ptr, tipc_own_addr(net), n_ptr->addr,
181+
if (!tipc_link_bc_create(net, tipc_own_addr(net), n_ptr->addr,
182182
U16_MAX, tipc_bc_sndlink(net)->window,
183183
n_ptr->capabilities,
184184
&n_ptr->bc_entry.inputq1,
@@ -366,7 +366,10 @@ static void __tipc_node_link_up(struct tipc_node *n, int bearer_id,
366366
pr_debug("Old link <%s> becomes standby\n", ol->name);
367367
*slot0 = bearer_id;
368368
*slot1 = bearer_id;
369+
tipc_link_set_active(nl, true);
370+
tipc_link_set_active(ol, false);
369371
} else if (nl->priority == ol->priority) {
372+
tipc_link_set_active(nl, true);
370373
*slot0 = bearer_id;
371374
} else {
372375
pr_debug("New link <%s> is standby\n", nl->name);
@@ -599,7 +602,7 @@ void tipc_node_check_dest(struct net *net, u32 onode,
599602
goto exit;
600603
}
601604
if_name = strchr(b->name, ':') + 1;
602-
if (!tipc_link_create(n, if_name, b->identity, b->tolerance,
605+
if (!tipc_link_create(net, if_name, b->identity, b->tolerance,
603606
b->net_plane, b->mtu, b->priority,
604607
b->window, mod(tipc_net(net)->random),
605608
tipc_own_addr(net), onode,

0 commit comments

Comments
 (0)