Skip to content

Commit 1df33a1

Browse files
committed
Merge branch 'tipc-next'
Jon Maloy says: ==================== tipc: separate link aggregation from link layer We continue the work on separating the roles of the link aggregation and link layers, as well as making code cleanups in general. This second commit batch focuses on moving the orchestration of link failover and synchronization to the node level, as well as preparing the node lock structure for further future impovements. We also make some changes to message delivery between link and socket layer, in order to make this mechanism safer and less obscure. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 29a3060 + 440d896 commit 1df33a1

File tree

8 files changed

+1009
-1024
lines changed

8 files changed

+1009
-1024
lines changed

net/tipc/bearer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ static int tipc_enable_bearer(struct net *net, const char *name,
343343
static int tipc_reset_bearer(struct net *net, struct tipc_bearer *b_ptr)
344344
{
345345
pr_info("Resetting bearer <%s>\n", b_ptr->name);
346-
tipc_link_delete_list(net, b_ptr->identity);
346+
tipc_node_delete_links(net, b_ptr->identity);
347347
tipc_disc_reset(net, b_ptr);
348348
return 0;
349349
}
@@ -361,7 +361,7 @@ static void bearer_disable(struct net *net, struct tipc_bearer *b_ptr)
361361
pr_info("Disabling bearer <%s>\n", b_ptr->name);
362362
b_ptr->media->disable_media(b_ptr);
363363

364-
tipc_link_delete_list(net, b_ptr->identity);
364+
tipc_node_delete_links(net, b_ptr->identity);
365365
if (b_ptr->link_req)
366366
tipc_disc_delete(b_ptr->link_req);
367367

net/tipc/core.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ struct tipc_net {
109109
atomic_t subscription_count;
110110
};
111111

112+
static inline struct tipc_net *tipc_net(struct net *net)
113+
{
114+
return net_generic(net, tipc_net_id);
115+
}
116+
112117
static inline u16 mod(u16 x)
113118
{
114119
return x & 0xffffu;

net/tipc/discover.c

Lines changed: 20 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -120,29 +120,24 @@ static void disc_dupl_alert(struct tipc_bearer *b_ptr, u32 node_addr,
120120
* @buf: buffer containing message
121121
* @bearer: bearer that message arrived on
122122
*/
123-
void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
123+
void tipc_disc_rcv(struct net *net, struct sk_buff *skb,
124124
struct tipc_bearer *bearer)
125125
{
126126
struct tipc_net *tn = net_generic(net, tipc_net_id);
127-
struct tipc_node *node;
128127
struct tipc_media_addr maddr;
129-
struct sk_buff *rbuf;
130-
struct tipc_msg *msg = buf_msg(buf);
131-
u32 ddom = msg_dest_domain(msg);
132-
u32 onode = msg_prevnode(msg);
133-
u32 net_id = msg_bc_netid(msg);
134-
u32 mtyp = msg_type(msg);
135-
u32 signature = msg_node_sig(msg);
136-
u16 caps = msg_node_capabilities(msg);
137-
bool addr_match = false;
138-
bool sign_match = false;
139-
bool link_up = false;
140-
bool accept_addr = false;
141-
bool accept_sign = false;
128+
struct sk_buff *rskb;
129+
struct tipc_msg *hdr = buf_msg(skb);
130+
u32 ddom = msg_dest_domain(hdr);
131+
u32 onode = msg_prevnode(hdr);
132+
u32 net_id = msg_bc_netid(hdr);
133+
u32 mtyp = msg_type(hdr);
134+
u32 signature = msg_node_sig(hdr);
135+
u16 caps = msg_node_capabilities(hdr);
142136
bool respond = false;
137+
bool dupl_addr = false;
143138

144-
bearer->media->msg2addr(bearer, &maddr, msg_media_addr(msg));
145-
kfree_skb(buf);
139+
bearer->media->msg2addr(bearer, &maddr, msg_media_addr(hdr));
140+
kfree_skb(skb);
146141

147142
/* Ensure message from node is valid and communication is permitted */
148143
if (net_id != tn->net_id)
@@ -164,91 +159,20 @@ void tipc_disc_rcv(struct net *net, struct sk_buff *buf,
164159
if (!tipc_in_scope(bearer->domain, onode))
165160
return;
166161

167-
node = tipc_node_create(net, onode);
168-
if (!node)
169-
return;
170-
tipc_node_lock(node);
171-
node->capabilities = caps;
172-
173-
/* Prepare to validate requesting node's signature and media address */
174-
sign_match = (signature == node->signature);
175-
tipc_node_check_dest(node, bearer, &link_up, &addr_match, &maddr);
176-
177-
/* These three flags give us eight permutations: */
178-
179-
if (sign_match && addr_match && link_up) {
180-
/* All is fine. Do nothing. */
181-
} else if (sign_match && addr_match && !link_up) {
182-
/* Respond. The link will come up in due time */
183-
respond = true;
184-
} else if (sign_match && !addr_match && link_up) {
185-
/* Peer has changed i/f address without rebooting.
186-
* If so, the link will reset soon, and the next
187-
* discovery will be accepted. So we can ignore it.
188-
* It may also be an cloned or malicious peer having
189-
* chosen the same node address and signature as an
190-
* existing one.
191-
* Ignore requests until the link goes down, if ever.
192-
*/
162+
tipc_node_check_dest(net, onode, bearer, caps, signature,
163+
&maddr, &respond, &dupl_addr);
164+
if (dupl_addr)
193165
disc_dupl_alert(bearer, onode, &maddr);
194-
} else if (sign_match && !addr_match && !link_up) {
195-
/* Peer link has changed i/f address without rebooting.
196-
* It may also be a cloned or malicious peer; we can't
197-
* distinguish between the two.
198-
* The signature is correct, so we must accept.
199-
*/
200-
accept_addr = true;
201-
respond = true;
202-
} else if (!sign_match && addr_match && link_up) {
203-
/* Peer node rebooted. Two possibilities:
204-
* - Delayed re-discovery; this link endpoint has already
205-
* reset and re-established contact with the peer, before
206-
* receiving a discovery message from that node.
207-
* (The peer happened to receive one from this node first).
208-
* - The peer came back so fast that our side has not
209-
* discovered it yet. Probing from this side will soon
210-
* reset the link, since there can be no working link
211-
* endpoint at the peer end, and the link will re-establish.
212-
* Accept the signature, since it comes from a known peer.
213-
*/
214-
accept_sign = true;
215-
} else if (!sign_match && addr_match && !link_up) {
216-
/* The peer node has rebooted.
217-
* Accept signature, since it is a known peer.
218-
*/
219-
accept_sign = true;
220-
respond = true;
221-
} else if (!sign_match && !addr_match && link_up) {
222-
/* Peer rebooted with new address, or a new/duplicate peer.
223-
* Ignore until the link goes down, if ever.
224-
*/
225-
disc_dupl_alert(bearer, onode, &maddr);
226-
} else if (!sign_match && !addr_match && !link_up) {
227-
/* Peer rebooted with new address, or it is a new peer.
228-
* Accept signature and address.
229-
*/
230-
accept_sign = true;
231-
accept_addr = true;
232-
respond = true;
233-
}
234-
235-
if (accept_sign)
236-
node->signature = signature;
237-
238-
if (accept_addr && !tipc_node_update_dest(node, bearer, &maddr))
239-
respond = false;
240166

241167
/* Send response, if necessary */
242168
if (respond && (mtyp == DSC_REQ_MSG)) {
243-
rbuf = tipc_buf_acquire(MAX_H_SIZE);
244-
if (rbuf) {
245-
tipc_disc_init_msg(net, rbuf, DSC_RESP_MSG, bearer);
246-
tipc_bearer_send(net, bearer->identity, rbuf, &maddr);
247-
kfree_skb(rbuf);
169+
rskb = tipc_buf_acquire(MAX_H_SIZE);
170+
if (rskb) {
171+
tipc_disc_init_msg(net, rskb, DSC_RESP_MSG, bearer);
172+
tipc_bearer_send(net, bearer->identity, rskb, &maddr);
173+
kfree_skb(rskb);
248174
}
249175
}
250-
tipc_node_unlock(node);
251-
tipc_node_put(node);
252176
}
253177

254178
/**

0 commit comments

Comments
 (0)