Skip to content

Commit ed193ec

Browse files
Jon Paul Maloydavem330
Jon Paul Maloy
authored andcommitted
tipc: simplify link mtu negotiation
When a link is being established, the two endpoints advertise their respective interface MTU in the transmitted RESET and ACTIVATE messages. If there is any difference, the lower of the two MTUs will be selected for use by both endpoints. However, as a remnant of earlier attempts to introduce TIPC level routing. there also exists an MTU discovery mechanism. If an intermediate node has a lower MTU than the two endpoints, they will discover this through a bisectional approach, and finally adopt this MTU for common use. Since there is no TIPC level routing, and probably never will be, this mechanism doesn't make any sense, and only serves to make the link level protocol unecessarily complex. In this commit, we eliminate the MTU discovery algorithm,and fall back to the simple MTU advertising approach. This change is fully backwards compatible. Reviewed-by: Ying Xue <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dff29b1 commit ed193ec

File tree

4 files changed

+43
-111
lines changed

4 files changed

+43
-111
lines changed

net/tipc/bcast.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ static void bclink_accept_pkt(struct tipc_node *node, u32 seqno)
413413
*/
414414
if (((seqno - tn->own_addr) % TIPC_MIN_LINK_WIN) == 0) {
415415
tipc_link_proto_xmit(node->active_links[node->addr & 1],
416-
STATE_MSG, 0, 0, 0, 0, 0);
416+
STATE_MSG, 0, 0, 0, 0);
417417
tn->bcl->stats.sent_acks++;
418418
}
419419
}
@@ -899,7 +899,7 @@ int tipc_bclink_init(struct net *net)
899899
skb_queue_head_init(&bclink->inputq);
900900
bcl->owner = &bclink->node;
901901
bcl->owner->net = net;
902-
bcl->max_pkt = MAX_PKT_DEFAULT_MCAST;
902+
bcl->mtu = MAX_PKT_DEFAULT_MCAST;
903903
tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT);
904904
bcl->bearer_id = MAX_BEARERS;
905905
rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer);

net/tipc/link.c

+32-97
Original file line numberDiff line numberDiff line change
@@ -136,34 +136,6 @@ static struct tipc_link *tipc_parallel_link(struct tipc_link *l)
136136
return l->owner->active_links[1];
137137
}
138138

139-
static void link_init_max_pkt(struct tipc_link *l_ptr)
140-
{
141-
struct tipc_node *node = l_ptr->owner;
142-
struct tipc_net *tn = net_generic(node->net, tipc_net_id);
143-
struct tipc_bearer *b_ptr;
144-
u32 max_pkt;
145-
146-
rcu_read_lock();
147-
b_ptr = rcu_dereference_rtnl(tn->bearer_list[l_ptr->bearer_id]);
148-
if (!b_ptr) {
149-
rcu_read_unlock();
150-
return;
151-
}
152-
max_pkt = (b_ptr->mtu & ~3);
153-
rcu_read_unlock();
154-
155-
if (max_pkt > MAX_MSG_SIZE)
156-
max_pkt = MAX_MSG_SIZE;
157-
158-
l_ptr->max_pkt_target = max_pkt;
159-
if (l_ptr->max_pkt_target < MAX_PKT_DEFAULT)
160-
l_ptr->max_pkt = l_ptr->max_pkt_target;
161-
else
162-
l_ptr->max_pkt = MAX_PKT_DEFAULT;
163-
164-
l_ptr->max_pkt_probes = 0;
165-
}
166-
167139
/*
168140
* Simple non-static link routines (i.e. referenced outside this file)
169141
*/
@@ -304,7 +276,8 @@ struct tipc_link *tipc_link_create(struct tipc_node *n_ptr,
304276
msg_set_bearer_id(msg, b_ptr->identity);
305277
strcpy((char *)msg_data(msg), if_name);
306278
l_ptr->net_plane = b_ptr->net_plane;
307-
link_init_max_pkt(l_ptr);
279+
l_ptr->advertised_mtu = b_ptr->mtu;
280+
l_ptr->mtu = l_ptr->advertised_mtu;
308281
l_ptr->priority = b_ptr->priority;
309282
tipc_link_set_queue_limits(l_ptr, b_ptr->window);
310283
l_ptr->next_out_no = 1;
@@ -465,8 +438,8 @@ void tipc_link_reset(struct tipc_link *l_ptr)
465438
/* Link is down, accept any session */
466439
l_ptr->peer_session = INVALID_SESSION;
467440

468-
/* Prepare for max packet size negotiation */
469-
link_init_max_pkt(l_ptr);
441+
/* Prepare for renewed mtu size negotiation */
442+
l_ptr->mtu = l_ptr->advertised_mtu;
470443

471444
l_ptr->state = RESET_UNKNOWN;
472445

@@ -563,19 +536,15 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
563536
l_ptr->checkpoint = l_ptr->next_in_no;
564537
if (tipc_bclink_acks_missing(l_ptr->owner)) {
565538
tipc_link_proto_xmit(l_ptr, STATE_MSG,
566-
0, 0, 0, 0, 0);
567-
l_ptr->fsm_msg_cnt++;
568-
} else if (l_ptr->max_pkt < l_ptr->max_pkt_target) {
569-
tipc_link_proto_xmit(l_ptr, STATE_MSG,
570-
1, 0, 0, 0, 0);
539+
0, 0, 0, 0);
571540
l_ptr->fsm_msg_cnt++;
572541
}
573542
link_set_timer(l_ptr, cont_intv);
574543
break;
575544
}
576545
l_ptr->state = WORKING_UNKNOWN;
577546
l_ptr->fsm_msg_cnt = 0;
578-
tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0, 0);
547+
tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0);
579548
l_ptr->fsm_msg_cnt++;
580549
link_set_timer(l_ptr, cont_intv / 4);
581550
break;
@@ -586,7 +555,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
586555
l_ptr->state = RESET_RESET;
587556
l_ptr->fsm_msg_cnt = 0;
588557
tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG,
589-
0, 0, 0, 0, 0);
558+
0, 0, 0, 0);
590559
l_ptr->fsm_msg_cnt++;
591560
link_set_timer(l_ptr, cont_intv);
592561
break;
@@ -609,7 +578,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
609578
l_ptr->state = RESET_RESET;
610579
l_ptr->fsm_msg_cnt = 0;
611580
tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG,
612-
0, 0, 0, 0, 0);
581+
0, 0, 0, 0);
613582
l_ptr->fsm_msg_cnt++;
614583
link_set_timer(l_ptr, cont_intv);
615584
break;
@@ -620,13 +589,13 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
620589
l_ptr->checkpoint = l_ptr->next_in_no;
621590
if (tipc_bclink_acks_missing(l_ptr->owner)) {
622591
tipc_link_proto_xmit(l_ptr, STATE_MSG,
623-
0, 0, 0, 0, 0);
592+
0, 0, 0, 0);
624593
l_ptr->fsm_msg_cnt++;
625594
}
626595
link_set_timer(l_ptr, cont_intv);
627596
} else if (l_ptr->fsm_msg_cnt < l_ptr->abort_limit) {
628597
tipc_link_proto_xmit(l_ptr, STATE_MSG,
629-
1, 0, 0, 0, 0);
598+
1, 0, 0, 0);
630599
l_ptr->fsm_msg_cnt++;
631600
link_set_timer(l_ptr, cont_intv / 4);
632601
} else { /* Link has failed */
@@ -636,7 +605,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
636605
l_ptr->state = RESET_UNKNOWN;
637606
l_ptr->fsm_msg_cnt = 0;
638607
tipc_link_proto_xmit(l_ptr, RESET_MSG,
639-
0, 0, 0, 0, 0);
608+
0, 0, 0, 0);
640609
l_ptr->fsm_msg_cnt++;
641610
link_set_timer(l_ptr, cont_intv);
642611
}
@@ -656,7 +625,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
656625
l_ptr->state = WORKING_WORKING;
657626
l_ptr->fsm_msg_cnt = 0;
658627
link_activate(l_ptr);
659-
tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0, 0);
628+
tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0);
660629
l_ptr->fsm_msg_cnt++;
661630
if (l_ptr->owner->working_links == 1)
662631
tipc_link_sync_xmit(l_ptr);
@@ -666,7 +635,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
666635
l_ptr->state = RESET_RESET;
667636
l_ptr->fsm_msg_cnt = 0;
668637
tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG,
669-
1, 0, 0, 0, 0);
638+
1, 0, 0, 0);
670639
l_ptr->fsm_msg_cnt++;
671640
link_set_timer(l_ptr, cont_intv);
672641
break;
@@ -676,7 +645,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
676645
link_set_timer(l_ptr, cont_intv);
677646
break;
678647
case TIMEOUT_EVT:
679-
tipc_link_proto_xmit(l_ptr, RESET_MSG, 0, 0, 0, 0, 0);
648+
tipc_link_proto_xmit(l_ptr, RESET_MSG, 0, 0, 0, 0);
680649
l_ptr->fsm_msg_cnt++;
681650
link_set_timer(l_ptr, cont_intv);
682651
break;
@@ -694,7 +663,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
694663
l_ptr->state = WORKING_WORKING;
695664
l_ptr->fsm_msg_cnt = 0;
696665
link_activate(l_ptr);
697-
tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0, 0);
666+
tipc_link_proto_xmit(l_ptr, STATE_MSG, 1, 0, 0, 0);
698667
l_ptr->fsm_msg_cnt++;
699668
if (l_ptr->owner->working_links == 1)
700669
tipc_link_sync_xmit(l_ptr);
@@ -704,7 +673,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
704673
break;
705674
case TIMEOUT_EVT:
706675
tipc_link_proto_xmit(l_ptr, ACTIVATE_MSG,
707-
0, 0, 0, 0, 0);
676+
0, 0, 0, 0);
708677
l_ptr->fsm_msg_cnt++;
709678
link_set_timer(l_ptr, cont_intv);
710679
break;
@@ -733,7 +702,7 @@ int __tipc_link_xmit(struct net *net, struct tipc_link *link,
733702
struct tipc_msg *msg = buf_msg(skb_peek(list));
734703
unsigned int maxwin = link->window;
735704
unsigned int imp = msg_importance(msg);
736-
uint mtu = link->max_pkt;
705+
uint mtu = link->mtu;
737706
uint ack = mod(link->next_in_no - 1);
738707
uint seqno = link->next_out_no;
739708
uint bc_last_in = link->owner->bclink.last_in;
@@ -1187,7 +1156,7 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b_ptr)
11871156
link_retrieve_defq(l_ptr, &head);
11881157
if (unlikely(++l_ptr->rcv_unacked >= TIPC_MIN_LINK_WIN)) {
11891158
l_ptr->stats.sent_acks++;
1190-
tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
1159+
tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0);
11911160
}
11921161
tipc_link_input(l_ptr, skb);
11931162
skb = NULL;
@@ -1362,7 +1331,7 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr,
13621331
if (tipc_link_defer_pkt(&l_ptr->deferdq, buf)) {
13631332
l_ptr->stats.deferred_recv++;
13641333
if ((skb_queue_len(&l_ptr->deferdq) % TIPC_MIN_LINK_WIN) == 1)
1365-
tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
1334+
tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, 0, 0, 0);
13661335
} else {
13671336
l_ptr->stats.duplicates++;
13681337
}
@@ -1372,7 +1341,7 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr,
13721341
* Send protocol message to the other endpoint.
13731342
*/
13741343
void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg,
1375-
u32 gap, u32 tolerance, u32 priority, u32 ack_mtu)
1344+
u32 gap, u32 tolerance, u32 priority)
13761345
{
13771346
struct sk_buff *buf = NULL;
13781347
struct tipc_msg *msg = l_ptr->pmsg;
@@ -1410,26 +1379,11 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg,
14101379
l_ptr->stats.sent_nacks++;
14111380
msg_set_link_tolerance(msg, tolerance);
14121381
msg_set_linkprio(msg, priority);
1413-
msg_set_max_pkt(msg, ack_mtu);
1382+
msg_set_max_pkt(msg, l_ptr->mtu);
14141383
msg_set_ack(msg, mod(l_ptr->next_in_no - 1));
14151384
msg_set_probe(msg, probe_msg != 0);
1416-
if (probe_msg) {
1417-
u32 mtu = l_ptr->max_pkt;
1418-
1419-
if ((mtu < l_ptr->max_pkt_target) &&
1420-
link_working_working(l_ptr) &&
1421-
l_ptr->fsm_msg_cnt) {
1422-
msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3;
1423-
if (l_ptr->max_pkt_probes == 10) {
1424-
l_ptr->max_pkt_target = (msg_size - 4);
1425-
l_ptr->max_pkt_probes = 0;
1426-
msg_size = (mtu + (l_ptr->max_pkt_target - mtu)/2 + 2) & ~3;
1427-
}
1428-
l_ptr->max_pkt_probes++;
1429-
}
1430-
1385+
if (probe_msg)
14311386
l_ptr->stats.sent_probes++;
1432-
}
14331387
l_ptr->stats.sent_states++;
14341388
} else { /* RESET_MSG or ACTIVATE_MSG */
14351389
msg_set_ack(msg, mod(l_ptr->failover_checkpt - 1));
@@ -1438,7 +1392,7 @@ void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int probe_msg,
14381392
msg_set_probe(msg, 0);
14391393
msg_set_link_tolerance(msg, l_ptr->tolerance);
14401394
msg_set_linkprio(msg, l_ptr->priority);
1441-
msg_set_max_pkt(msg, l_ptr->max_pkt_target);
1395+
msg_set_max_pkt(msg, l_ptr->advertised_mtu);
14421396
}
14431397

14441398
r_flag = (l_ptr->owner->working_links > tipc_link_is_up(l_ptr));
@@ -1469,8 +1423,6 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
14691423
struct sk_buff *buf)
14701424
{
14711425
u32 rec_gap = 0;
1472-
u32 max_pkt_info;
1473-
u32 max_pkt_ack;
14741426
u32 msg_tol;
14751427
struct tipc_msg *msg = buf_msg(buf);
14761428

@@ -1513,15 +1465,8 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
15131465
if (msg_linkprio(msg) > l_ptr->priority)
15141466
l_ptr->priority = msg_linkprio(msg);
15151467

1516-
max_pkt_info = msg_max_pkt(msg);
1517-
if (max_pkt_info) {
1518-
if (max_pkt_info < l_ptr->max_pkt_target)
1519-
l_ptr->max_pkt_target = max_pkt_info;
1520-
if (l_ptr->max_pkt > l_ptr->max_pkt_target)
1521-
l_ptr->max_pkt = l_ptr->max_pkt_target;
1522-
} else {
1523-
l_ptr->max_pkt = l_ptr->max_pkt_target;
1524-
}
1468+
if (l_ptr->mtu > msg_max_pkt(msg))
1469+
l_ptr->mtu = msg_max_pkt(msg);
15251470

15261471
/* Synchronize broadcast link info, if not done previously */
15271472
if (!tipc_node_is_up(l_ptr->owner)) {
@@ -1566,27 +1511,17 @@ static void tipc_link_proto_rcv(struct tipc_link *l_ptr,
15661511
mod(l_ptr->next_in_no));
15671512
}
15681513

1569-
max_pkt_ack = msg_max_pkt(msg);
1570-
if (max_pkt_ack > l_ptr->max_pkt) {
1571-
l_ptr->max_pkt = max_pkt_ack;
1572-
l_ptr->max_pkt_probes = 0;
1573-
}
1574-
1575-
max_pkt_ack = 0;
1576-
if (msg_probe(msg)) {
1514+
if (msg_probe(msg))
15771515
l_ptr->stats.recv_probes++;
1578-
if (msg_size(msg) > sizeof(l_ptr->proto_msg))
1579-
max_pkt_ack = msg_size(msg);
1580-
}
15811516

15821517
/* Protocol message before retransmits, reduce loss risk */
15831518
if (l_ptr->owner->bclink.recv_permitted)
15841519
tipc_bclink_update_link_state(l_ptr->owner,
15851520
msg_last_bcast(msg));
15861521

15871522
if (rec_gap || (msg_probe(msg))) {
1588-
tipc_link_proto_xmit(l_ptr, STATE_MSG, 0, rec_gap, 0,
1589-
0, max_pkt_ack);
1523+
tipc_link_proto_xmit(l_ptr, STATE_MSG, 0,
1524+
rec_gap, 0, 0);
15901525
}
15911526
if (msg_seq_gap(msg)) {
15921527
l_ptr->stats.recv_nacks++;
@@ -1816,7 +1751,7 @@ static void link_set_supervision_props(struct tipc_link *l_ptr, u32 tol)
18161751

18171752
void tipc_link_set_queue_limits(struct tipc_link *l, u32 win)
18181753
{
1819-
int max_bulk = TIPC_MAX_PUBLICATIONS / (l->max_pkt / ITEM_SIZE);
1754+
int max_bulk = TIPC_MAX_PUBLICATIONS / (l->mtu / ITEM_SIZE);
18201755

18211756
l->window = win;
18221757
l->backlog[TIPC_LOW_IMPORTANCE].limit = win / 2;
@@ -1988,14 +1923,14 @@ int tipc_nl_link_set(struct sk_buff *skb, struct genl_info *info)
19881923

19891924
tol = nla_get_u32(props[TIPC_NLA_PROP_TOL]);
19901925
link_set_supervision_props(link, tol);
1991-
tipc_link_proto_xmit(link, STATE_MSG, 0, 0, tol, 0, 0);
1926+
tipc_link_proto_xmit(link, STATE_MSG, 0, 0, tol, 0);
19921927
}
19931928
if (props[TIPC_NLA_PROP_PRIO]) {
19941929
u32 prio;
19951930

19961931
prio = nla_get_u32(props[TIPC_NLA_PROP_PRIO]);
19971932
link->priority = prio;
1998-
tipc_link_proto_xmit(link, STATE_MSG, 0, 0, 0, prio, 0);
1933+
tipc_link_proto_xmit(link, STATE_MSG, 0, 0, 0, prio);
19991934
}
20001935
if (props[TIPC_NLA_PROP_WIN]) {
20011936
u32 win;
@@ -2100,7 +2035,7 @@ static int __tipc_nl_add_link(struct net *net, struct tipc_nl_msg *msg,
21002035
if (nla_put_u32(msg->skb, TIPC_NLA_LINK_DEST,
21012036
tipc_cluster_mask(tn->own_addr)))
21022037
goto attr_msg_full;
2103-
if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->max_pkt))
2038+
if (nla_put_u32(msg->skb, TIPC_NLA_LINK_MTU, link->mtu))
21042039
goto attr_msg_full;
21052040
if (nla_put_u32(msg->skb, TIPC_NLA_LINK_RX, link->next_in_no))
21062041
goto attr_msg_full;

net/tipc/link.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,8 @@ struct tipc_stats {
123123
* @backlog_limit: backlog queue congestion thresholds (indexed by importance)
124124
* @exp_msg_count: # of tunnelled messages expected during link changeover
125125
* @reset_checkpoint: seq # of last acknowledged message at time of link reset
126-
* @max_pkt: current maximum packet size for this link
127-
* @max_pkt_target: desired maximum packet size for this link
128-
* @max_pkt_probes: # of probes based on current (max_pkt, max_pkt_target)
126+
* @mtu: current maximum packet size for this link
127+
* @advertised_mtu: advertised own mtu when link is being established
129128
* @transmitq: queue for sent, non-acked messages
130129
* @backlogq: queue for messages waiting to be sent
131130
* @next_out_no: next sequence number to use for outbound messages
@@ -176,9 +175,8 @@ struct tipc_link {
176175
struct sk_buff *failover_skb;
177176

178177
/* Max packet negotiation */
179-
u32 max_pkt;
180-
u32 max_pkt_target;
181-
u32 max_pkt_probes;
178+
u16 mtu;
179+
u16 advertised_mtu;
182180

183181
/* Sending */
184182
struct sk_buff_head transmq;
@@ -233,7 +231,7 @@ int tipc_link_xmit(struct net *net, struct sk_buff_head *list, u32 dest,
233231
int __tipc_link_xmit(struct net *net, struct tipc_link *link,
234232
struct sk_buff_head *list);
235233
void tipc_link_proto_xmit(struct tipc_link *l_ptr, u32 msg_typ, int prob,
236-
u32 gap, u32 tolerance, u32 priority, u32 acked_mtu);
234+
u32 gap, u32 tolerance, u32 priority);
237235
void tipc_link_push_packets(struct tipc_link *l_ptr);
238236
u32 tipc_link_defer_pkt(struct sk_buff_head *list, struct sk_buff *buf);
239237
void tipc_link_set_queue_limits(struct tipc_link *l_ptr, u32 window);

0 commit comments

Comments
 (0)