Skip to content

Commit 8d6e79d

Browse files
Jon Maloydavem330
authored andcommitted
tipc: improve link resiliency when rps is activated
Currently, the TIPC RPS dissector is based only on the incoming packets' source node address, hence steering all traffic from a node to the same core. We have seen that this makes the links vulnerable to starvation and unnecessary resets when we turn down the link tolerance to very low values. To reduce the risk of this happening, we exempt probe and probe replies packets from the convergence to one core per source node. Instead, we do the opposite, - we try to diverge those packets across as many cores as possible, by randomizing the flow selector key. To make such packets identifiable to the dissector, we add a new 'is_keepalive' bit to word 0 of the LINK_PROTOCOL header. This bit is set both for PROBE and PROBE_REPLY messages, and only for those. It should be noted that these packets are not part of any flow anyway, and only constitute a minuscule fraction of all packets sent across a link. Hence, there is no risk that this will affect overall performance. Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 141f575 commit 8d6e79d

5 files changed

Lines changed: 108 additions & 32 deletions

File tree

‎include/net/flow_dissector.h‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ struct flow_dissector_key_ipv6_addrs {
8484
};
8585

8686
/**
87-
* struct flow_dissector_key_tipc_addrs:
88-
* @srcnode: source node address
87+
* struct flow_dissector_key_tipc:
88+
* @key: source node address combined with selector
8989
*/
90-
struct flow_dissector_key_tipc_addrs {
91-
__be32 srcnode;
90+
struct flow_dissector_key_tipc {
91+
__be32 key;
9292
};
9393

9494
/**
@@ -100,7 +100,7 @@ struct flow_dissector_key_addrs {
100100
union {
101101
struct flow_dissector_key_ipv4_addrs v4addrs;
102102
struct flow_dissector_key_ipv6_addrs v6addrs;
103-
struct flow_dissector_key_tipc_addrs tipcaddrs;
103+
struct flow_dissector_key_tipc tipckey;
104104
};
105105
};
106106

@@ -192,7 +192,7 @@ enum flow_dissector_key_id {
192192
FLOW_DISSECTOR_KEY_PORTS, /* struct flow_dissector_key_ports */
193193
FLOW_DISSECTOR_KEY_ICMP, /* struct flow_dissector_key_icmp */
194194
FLOW_DISSECTOR_KEY_ETH_ADDRS, /* struct flow_dissector_key_eth_addrs */
195-
FLOW_DISSECTOR_KEY_TIPC_ADDRS, /* struct flow_dissector_key_tipc_addrs */
195+
FLOW_DISSECTOR_KEY_TIPC, /* struct flow_dissector_key_tipc */
196196
FLOW_DISSECTOR_KEY_ARP, /* struct flow_dissector_key_arp */
197197
FLOW_DISSECTOR_KEY_VLAN, /* struct flow_dissector_key_flow_vlan */
198198
FLOW_DISSECTOR_KEY_FLOW_LABEL, /* struct flow_dissector_key_flow_tags */

‎include/net/tipc.h‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* include/net/tipc.h: Include file for TIPC message header routines
3+
*
4+
* Copyright (c) 2017 Ericsson AB
5+
* All rights reserved.
6+
*
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright
11+
* notice, this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright
13+
* notice, this list of conditions and the following disclaimer in the
14+
* documentation and/or other materials provided with the distribution.
15+
* 3. Neither the names of the copyright holders nor the names of its
16+
* contributors may be used to endorse or promote products derived from
17+
* this software without specific prior written permission.
18+
*
19+
* Alternatively, this software may be distributed under the terms of the
20+
* GNU General Public License ("GPL") version 2 as published by the Free
21+
* Software Foundation.
22+
*
23+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33+
* POSSIBILITY OF SUCH DAMAGE.
34+
*/
35+
36+
#ifndef _TIPC_HDR_H
37+
#define _TIPC_HDR_H
38+
39+
#include <linux/random.h>
40+
41+
#define KEEPALIVE_MSG_MASK 0x0e080000 /* LINK_PROTOCOL + MSG_IS_KEEPALIVE */
42+
43+
struct tipc_basic_hdr {
44+
__be32 w[4];
45+
};
46+
47+
static inline u32 tipc_hdr_rps_key(struct tipc_basic_hdr *hdr)
48+
{
49+
u32 w0 = ntohl(hdr->w[0]);
50+
bool keepalive_msg = (w0 & KEEPALIVE_MSG_MASK) == KEEPALIVE_MSG_MASK;
51+
int key;
52+
53+
/* Return source node identity as key */
54+
if (likely(!keepalive_msg))
55+
return hdr->w[3];
56+
57+
/* Spread PROBE/PROBE_REPLY messages across the cores */
58+
get_random_bytes(&key, sizeof(key));
59+
return key;
60+
}
61+
62+
#endif

‎net/core/flow_dissector.c‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <net/ipv6.h>
1111
#include <net/gre.h>
1212
#include <net/pptp.h>
13+
#include <net/tipc.h>
1314
#include <linux/igmp.h>
1415
#include <linux/icmp.h>
1516
#include <linux/sctp.h>
@@ -772,23 +773,22 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
772773
break;
773774
}
774775
case htons(ETH_P_TIPC): {
775-
struct {
776-
__be32 pre[3];
777-
__be32 srcnode;
778-
} *hdr, _hdr;
779-
hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, hlen, &_hdr);
776+
struct tipc_basic_hdr *hdr, _hdr;
777+
778+
hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr),
779+
data, hlen, &_hdr);
780780
if (!hdr) {
781781
fdret = FLOW_DISSECT_RET_OUT_BAD;
782782
break;
783783
}
784784

785785
if (dissector_uses_key(flow_dissector,
786-
FLOW_DISSECTOR_KEY_TIPC_ADDRS)) {
786+
FLOW_DISSECTOR_KEY_TIPC)) {
787787
key_addrs = skb_flow_dissector_target(flow_dissector,
788-
FLOW_DISSECTOR_KEY_TIPC_ADDRS,
788+
FLOW_DISSECTOR_KEY_TIPC,
789789
target_container);
790-
key_addrs->tipcaddrs.srcnode = hdr->srcnode;
791-
key_control->addr_type = FLOW_DISSECTOR_KEY_TIPC_ADDRS;
790+
key_addrs->tipckey.key = tipc_hdr_rps_key(hdr);
791+
key_control->addr_type = FLOW_DISSECTOR_KEY_TIPC;
792792
}
793793
fdret = FLOW_DISSECT_RET_OUT_GOOD;
794794
break;
@@ -1024,8 +1024,8 @@ static inline size_t flow_keys_hash_length(const struct flow_keys *flow)
10241024
case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
10251025
diff -= sizeof(flow->addrs.v6addrs);
10261026
break;
1027-
case FLOW_DISSECTOR_KEY_TIPC_ADDRS:
1028-
diff -= sizeof(flow->addrs.tipcaddrs);
1027+
case FLOW_DISSECTOR_KEY_TIPC:
1028+
diff -= sizeof(flow->addrs.tipckey);
10291029
break;
10301030
}
10311031
return (sizeof(*flow) - diff) / sizeof(u32);
@@ -1039,8 +1039,8 @@ __be32 flow_get_u32_src(const struct flow_keys *flow)
10391039
case FLOW_DISSECTOR_KEY_IPV6_ADDRS:
10401040
return (__force __be32)ipv6_addr_hash(
10411041
&flow->addrs.v6addrs.src);
1042-
case FLOW_DISSECTOR_KEY_TIPC_ADDRS:
1043-
return flow->addrs.tipcaddrs.srcnode;
1042+
case FLOW_DISSECTOR_KEY_TIPC:
1043+
return flow->addrs.tipckey.key;
10441044
default:
10451045
return 0;
10461046
}
@@ -1321,8 +1321,8 @@ static const struct flow_dissector_key flow_keys_dissector_keys[] = {
13211321
.offset = offsetof(struct flow_keys, addrs.v6addrs),
13221322
},
13231323
{
1324-
.key_id = FLOW_DISSECTOR_KEY_TIPC_ADDRS,
1325-
.offset = offsetof(struct flow_keys, addrs.tipcaddrs),
1324+
.key_id = FLOW_DISSECTOR_KEY_TIPC,
1325+
.offset = offsetof(struct flow_keys, addrs.tipckey),
13261326
},
13271327
{
13281328
.key_id = FLOW_DISSECTOR_KEY_PORTS,

‎net/tipc/link.c‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,8 @@ static int link_is_up(struct tipc_link *l)
239239
static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
240240
struct sk_buff_head *xmitq);
241241
static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
242-
u16 rcvgap, int tolerance, int priority,
242+
bool probe_reply, u16 rcvgap,
243+
int tolerance, int priority,
243244
struct sk_buff_head *xmitq);
244245
static void link_print(struct tipc_link *l, const char *str);
245246
static int tipc_link_build_nack_msg(struct tipc_link *l,
@@ -773,7 +774,7 @@ int tipc_link_timeout(struct tipc_link *l, struct sk_buff_head *xmitq)
773774
}
774775

775776
if (state || probe || setup)
776-
tipc_link_build_proto_msg(l, mtyp, probe, 0, 0, 0, xmitq);
777+
tipc_link_build_proto_msg(l, mtyp, probe, 0, 0, 0, 0, xmitq);
777778

778779
return rc;
779780
}
@@ -1174,7 +1175,7 @@ int tipc_link_build_state_msg(struct tipc_link *l, struct sk_buff_head *xmitq)
11741175
/* Unicast ACK */
11751176
l->rcv_unacked = 0;
11761177
l->stats.sent_acks++;
1177-
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, xmitq);
1178+
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, 0, xmitq);
11781179
return 0;
11791180
}
11801181

@@ -1188,7 +1189,7 @@ void tipc_link_build_reset_msg(struct tipc_link *l, struct sk_buff_head *xmitq)
11881189
if (l->state == LINK_ESTABLISHING)
11891190
mtyp = ACTIVATE_MSG;
11901191

1191-
tipc_link_build_proto_msg(l, mtyp, 0, 0, 0, 0, xmitq);
1192+
tipc_link_build_proto_msg(l, mtyp, 0, 0, 0, 0, 0, xmitq);
11921193

11931194
/* Inform peer that this endpoint is going down if applicable */
11941195
skb = skb_peek_tail(xmitq);
@@ -1215,7 +1216,7 @@ static int tipc_link_build_nack_msg(struct tipc_link *l,
12151216
}
12161217

12171218
if ((skb_queue_len(&l->deferdq) == 1) || !(def_cnt % TIPC_NACK_INTV))
1218-
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, xmitq);
1219+
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, 0, xmitq);
12191220
return 0;
12201221
}
12211222

@@ -1289,7 +1290,8 @@ int tipc_link_rcv(struct tipc_link *l, struct sk_buff *skb,
12891290
}
12901291

12911292
static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
1292-
u16 rcvgap, int tolerance, int priority,
1293+
bool probe_reply, u16 rcvgap,
1294+
int tolerance, int priority,
12931295
struct sk_buff_head *xmitq)
12941296
{
12951297
struct tipc_link *bcl = l->bc_rcvlink;
@@ -1337,6 +1339,7 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
13371339
msg_set_seq_gap(hdr, rcvgap);
13381340
msg_set_bc_gap(hdr, link_bc_rcv_gap(bcl));
13391341
msg_set_probe(hdr, probe);
1342+
msg_set_is_keepalive(hdr, probe || probe_reply);
13401343
tipc_mon_prep(l->net, data, &dlen, mstate, l->bearer_id);
13411344
msg_set_size(hdr, INT_H_SIZE + dlen);
13421345
skb_trim(skb, INT_H_SIZE + dlen);
@@ -1442,6 +1445,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
14421445
u16 rcv_nxt = l->rcv_nxt;
14431446
u16 dlen = msg_data_sz(hdr);
14441447
int mtyp = msg_type(hdr);
1448+
bool reply = msg_probe(hdr);
14451449
void *data;
14461450
char *if_name;
14471451
int rc = 0;
@@ -1528,9 +1532,9 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
15281532
/* Send NACK if peer has sent pkts we haven't received yet */
15291533
if (more(peers_snd_nxt, rcv_nxt) && !tipc_link_is_synching(l))
15301534
rcvgap = peers_snd_nxt - l->rcv_nxt;
1531-
if (rcvgap || (msg_probe(hdr)))
1532-
tipc_link_build_proto_msg(l, STATE_MSG, 0, rcvgap,
1533-
0, 0, xmitq);
1535+
if (rcvgap || reply)
1536+
tipc_link_build_proto_msg(l, STATE_MSG, 0, reply,
1537+
rcvgap, 0, 0, xmitq);
15341538
tipc_link_release_pkts(l, ack);
15351539

15361540
/* If NACK, retransmit will now start at right position */
@@ -2122,14 +2126,14 @@ void tipc_link_set_tolerance(struct tipc_link *l, u32 tol,
21222126
struct sk_buff_head *xmitq)
21232127
{
21242128
l->tolerance = tol;
2125-
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, tol, 0, xmitq);
2129+
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, tol, 0, xmitq);
21262130
}
21272131

21282132
void tipc_link_set_prio(struct tipc_link *l, u32 prio,
21292133
struct sk_buff_head *xmitq)
21302134
{
21312135
l->priority = prio;
2132-
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, prio, xmitq);
2136+
tipc_link_build_proto_msg(l, STATE_MSG, 0, 0, 0, 0, prio, xmitq);
21332137
}
21342138

21352139
void tipc_link_set_abort_limit(struct tipc_link *l, u32 limit)

‎net/tipc/msg.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ static inline void msg_set_dest_droppable(struct tipc_msg *m, u32 d)
226226
msg_set_bits(m, 0, 19, 1, d);
227227
}
228228

229+
static inline int msg_is_keepalive(struct tipc_msg *m)
230+
{
231+
return msg_bits(m, 0, 19, 1);
232+
}
233+
234+
static inline void msg_set_is_keepalive(struct tipc_msg *m, u32 d)
235+
{
236+
msg_set_bits(m, 0, 19, 1, d);
237+
}
238+
229239
static inline int msg_src_droppable(struct tipc_msg *m)
230240
{
231241
return msg_bits(m, 0, 18, 1);

0 commit comments

Comments
 (0)