aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/link.c
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-07-09 19:07:35 -0400
committerDavid S. Miller <davem@davemloft.net>2018-07-12 02:06:14 -0400
commit9012de5089560136b849b920ad038b96160ed8f6 (patch)
tree20261a0c6e074ca936878835b64a04294ca3af52 /net/tipc/link.c
parente32f55f373217001187ff171e75c5dfbb251f633 (diff)
tipc: add sequence number check for link STATE messages
Some switch infrastructures produce huge amounts of packet duplicates. This becomes a problem if those messages are STATE/NACK protocol messages, causing unnecessary retransmissions of already accepted packets. We now introduce a unique sequence number per STATE protocol message so that duplicates can be identified and ignored. This will also be useful when tracing such cases, and to avert replay attacks when TIPC is encrypted. For compatibility reasons we have to introduce a new capability flag TIPC_LINK_PROTO_SEQNO to handle this new feature. Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/link.c')
-rw-r--r--net/tipc/link.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/net/tipc/link.c b/net/tipc/link.c
index ec4d28328652..065e9e67da5d 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -130,6 +130,8 @@ struct tipc_link {
130 /* Management and link supervision data */ 130 /* Management and link supervision data */
131 u32 peer_session; 131 u32 peer_session;
132 u32 session; 132 u32 session;
133 u16 snd_nxt_state;
134 u16 rcv_nxt_state;
133 u32 peer_bearer_id; 135 u32 peer_bearer_id;
134 u32 bearer_id; 136 u32 bearer_id;
135 u32 tolerance; 137 u32 tolerance;
@@ -339,6 +341,11 @@ char tipc_link_plane(struct tipc_link *l)
339 return l->net_plane; 341 return l->net_plane;
340} 342}
341 343
344void tipc_link_update_caps(struct tipc_link *l, u16 capabilities)
345{
346 l->peer_caps = capabilities;
347}
348
342void tipc_link_add_bc_peer(struct tipc_link *snd_l, 349void tipc_link_add_bc_peer(struct tipc_link *snd_l,
343 struct tipc_link *uc_l, 350 struct tipc_link *uc_l,
344 struct sk_buff_head *xmitq) 351 struct sk_buff_head *xmitq)
@@ -859,6 +866,8 @@ void tipc_link_reset(struct tipc_link *l)
859 l->rcv_unacked = 0; 866 l->rcv_unacked = 0;
860 l->snd_nxt = 1; 867 l->snd_nxt = 1;
861 l->rcv_nxt = 1; 868 l->rcv_nxt = 1;
869 l->snd_nxt_state = 1;
870 l->rcv_nxt_state = 1;
862 l->acked = 0; 871 l->acked = 0;
863 l->silent_intv_cnt = 0; 872 l->silent_intv_cnt = 0;
864 l->rst_cnt = 0; 873 l->rst_cnt = 0;
@@ -1353,6 +1362,8 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
1353 msg_set_seqno(hdr, l->snd_nxt + U16_MAX / 2); 1362 msg_set_seqno(hdr, l->snd_nxt + U16_MAX / 2);
1354 1363
1355 if (mtyp == STATE_MSG) { 1364 if (mtyp == STATE_MSG) {
1365 if (l->peer_caps & TIPC_LINK_PROTO_SEQNO)
1366 msg_set_seqno(hdr, l->snd_nxt_state++);
1356 msg_set_seq_gap(hdr, rcvgap); 1367 msg_set_seq_gap(hdr, rcvgap);
1357 msg_set_bc_gap(hdr, link_bc_rcv_gap(bcl)); 1368 msg_set_bc_gap(hdr, link_bc_rcv_gap(bcl));
1358 msg_set_probe(hdr, probe); 1369 msg_set_probe(hdr, probe);
@@ -1522,6 +1533,11 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
1522 1533
1523 case STATE_MSG: 1534 case STATE_MSG:
1524 1535
1536 if (l->peer_caps & TIPC_LINK_PROTO_SEQNO &&
1537 less(msg_seqno(hdr), l->rcv_nxt_state))
1538 break;
1539 l->rcv_nxt_state = msg_seqno(hdr) + 1;
1540
1525 /* Update own tolerance if peer indicates a non-zero value */ 1541 /* Update own tolerance if peer indicates a non-zero value */
1526 if (in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL)) 1542 if (in_range(peers_tol, TIPC_MIN_LINK_TOL, TIPC_MAX_LINK_TOL))
1527 l->tolerance = peers_tol; 1543 l->tolerance = peers_tol;