hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/net/tipc/msg.h
....@@ -82,6 +82,7 @@
8282 #define NAME_DISTRIBUTOR 11
8383 #define MSG_FRAGMENTER 12
8484 #define LINK_CONFIG 13
85
+#define MSG_CRYPTO 14
8586 #define SOCK_WAKEUP 14 /* pseudo user */
8687 #define TOP_SRV 15 /* pseudo user */
8788
....@@ -98,23 +99,103 @@
9899 #define MAX_H_SIZE 60 /* Largest possible TIPC header size */
99100
100101 #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE)
101
-#define FB_MTU 3744
102102 #define TIPC_MEDIA_INFO_OFFSET 5
103103
104
+extern const int one_page_mtu;
105
+
104106 struct tipc_skb_cb {
105
- u32 bytes_read;
106
- u32 orig_member;
107
- struct sk_buff *tail;
108
- bool validated;
109
- u16 chain_imp;
110
- u16 ackers;
111
-};
107
+ union {
108
+ struct {
109
+ struct sk_buff *tail;
110
+ unsigned long nxt_retr;
111
+ unsigned long retr_stamp;
112
+ u32 bytes_read;
113
+ u32 orig_member;
114
+ u16 chain_imp;
115
+ u16 ackers;
116
+ u16 retr_cnt;
117
+ } __packed;
118
+#ifdef CONFIG_TIPC_CRYPTO
119
+ struct {
120
+ struct tipc_crypto *rx;
121
+ struct tipc_aead *last;
122
+ u8 recurs;
123
+ } tx_clone_ctx __packed;
124
+#endif
125
+ } __packed;
126
+ union {
127
+ struct {
128
+ u8 validated:1;
129
+#ifdef CONFIG_TIPC_CRYPTO
130
+ u8 encrypted:1;
131
+ u8 decrypted:1;
132
+#define SKB_PROBING 1
133
+#define SKB_GRACING 2
134
+ u8 xmit_type:2;
135
+ u8 tx_clone_deferred:1;
136
+#endif
137
+ };
138
+ u8 flags;
139
+ };
140
+ u8 reserved;
141
+#ifdef CONFIG_TIPC_CRYPTO
142
+ void *crypto_ctx;
143
+#endif
144
+} __packed;
112145
113146 #define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0]))
114147
115148 struct tipc_msg {
116149 __be32 hdr[15];
117150 };
151
+
152
+/* struct tipc_gap_ack - TIPC Gap ACK block
153
+ * @ack: seqno of the last consecutive packet in link deferdq
154
+ * @gap: number of gap packets since the last ack
155
+ *
156
+ * E.g:
157
+ * link deferdq: 1 2 3 4 10 11 13 14 15 20
158
+ * --> Gap ACK blocks: <4, 5>, <11, 1>, <15, 4>, <20, 0>
159
+ */
160
+struct tipc_gap_ack {
161
+ __be16 ack;
162
+ __be16 gap;
163
+};
164
+
165
+/* struct tipc_gap_ack_blks
166
+ * @len: actual length of the record
167
+ * @ugack_cnt: number of Gap ACK blocks for unicast (following the broadcast
168
+ * ones)
169
+ * @start_index: starting index for "valid" broadcast Gap ACK blocks
170
+ * @bgack_cnt: number of Gap ACK blocks for broadcast in the record
171
+ * @gacks: array of Gap ACK blocks
172
+ *
173
+ * 31 16 15 0
174
+ * +-------------+-------------+-------------+-------------+
175
+ * | bgack_cnt | ugack_cnt | len |
176
+ * +-------------+-------------+-------------+-------------+ -
177
+ * | gap | ack | |
178
+ * +-------------+-------------+-------------+-------------+ > bc gacks
179
+ * : : : |
180
+ * +-------------+-------------+-------------+-------------+ -
181
+ * | gap | ack | |
182
+ * +-------------+-------------+-------------+-------------+ > uc gacks
183
+ * : : : |
184
+ * +-------------+-------------+-------------+-------------+ -
185
+ */
186
+struct tipc_gap_ack_blks {
187
+ __be16 len;
188
+ union {
189
+ u8 ugack_cnt;
190
+ u8 start_index;
191
+ };
192
+ u8 bgack_cnt;
193
+ struct tipc_gap_ack gacks[];
194
+};
195
+
196
+#define MAX_GAP_ACK_BLKS 128
197
+#define MAX_GAP_ACK_BLKS_SZ (sizeof(struct tipc_gap_ack_blks) + \
198
+ sizeof(struct tipc_gap_ack) * MAX_GAP_ACK_BLKS)
118199
119200 static inline struct tipc_msg *buf_msg(struct sk_buff *skb)
120201 {
....@@ -216,6 +297,16 @@
216297 msg_set_bits(m, 0, 20, 1, n);
217298 }
218299
300
+static inline int msg_is_syn(struct tipc_msg *m)
301
+{
302
+ return msg_bits(m, 0, 17, 1);
303
+}
304
+
305
+static inline void msg_set_syn(struct tipc_msg *m, u32 d)
306
+{
307
+ msg_set_bits(m, 0, 17, 1, d);
308
+}
309
+
219310 static inline int msg_dest_droppable(struct tipc_msg *m)
220311 {
221312 return msg_bits(m, 0, 19, 1);
....@@ -246,6 +337,36 @@
246337 msg_set_bits(m, 0, 18, 1, d);
247338 }
248339
340
+static inline int msg_ack_required(struct tipc_msg *m)
341
+{
342
+ return msg_bits(m, 0, 18, 1);
343
+}
344
+
345
+static inline void msg_set_ack_required(struct tipc_msg *m)
346
+{
347
+ msg_set_bits(m, 0, 18, 1, 1);
348
+}
349
+
350
+static inline int msg_nagle_ack(struct tipc_msg *m)
351
+{
352
+ return msg_bits(m, 0, 18, 1);
353
+}
354
+
355
+static inline void msg_set_nagle_ack(struct tipc_msg *m)
356
+{
357
+ msg_set_bits(m, 0, 18, 1, 1);
358
+}
359
+
360
+static inline bool msg_is_rcast(struct tipc_msg *m)
361
+{
362
+ return msg_bits(m, 0, 18, 0x1);
363
+}
364
+
365
+static inline void msg_set_is_rcast(struct tipc_msg *m, bool d)
366
+{
367
+ msg_set_bits(m, 0, 18, 0x1, d);
368
+}
369
+
249370 static inline void msg_set_size(struct tipc_msg *m, u32 sz)
250371 {
251372 m->hdr[0] = htonl((msg_word(m, 0) & ~0x1ffff) | sz);
....@@ -256,7 +377,7 @@
256377 return ((unchar *)m) + msg_hdr_sz(m);
257378 }
258379
259
-static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m)
380
+static inline struct tipc_msg *msg_inner_hdr(struct tipc_msg *m)
260381 {
261382 return (struct tipc_msg *)msg_data(m);
262383 }
....@@ -304,6 +425,11 @@
304425 return msg_type(m) == TIPC_CONN_MSG;
305426 }
306427
428
+static inline u32 msg_direct(struct tipc_msg *m)
429
+{
430
+ return msg_type(m) == TIPC_DIRECT_MSG;
431
+}
432
+
307433 static inline u32 msg_errcode(struct tipc_msg *m)
308434 {
309435 return msg_bits(m, 1, 25, 0xf);
....@@ -312,6 +438,36 @@
312438 static inline void msg_set_errcode(struct tipc_msg *m, u32 err)
313439 {
314440 msg_set_bits(m, 1, 25, 0xf, err);
441
+}
442
+
443
+static inline void msg_set_bulk(struct tipc_msg *m)
444
+{
445
+ msg_set_bits(m, 1, 28, 0x1, 1);
446
+}
447
+
448
+static inline u32 msg_is_bulk(struct tipc_msg *m)
449
+{
450
+ return msg_bits(m, 1, 28, 0x1);
451
+}
452
+
453
+static inline void msg_set_last_bulk(struct tipc_msg *m)
454
+{
455
+ msg_set_bits(m, 1, 27, 0x1, 1);
456
+}
457
+
458
+static inline u32 msg_is_last_bulk(struct tipc_msg *m)
459
+{
460
+ return msg_bits(m, 1, 27, 0x1);
461
+}
462
+
463
+static inline void msg_set_non_legacy(struct tipc_msg *m)
464
+{
465
+ msg_set_bits(m, 1, 26, 0x1, 1);
466
+}
467
+
468
+static inline u32 msg_is_legacy(struct tipc_msg *m)
469
+{
470
+ return !msg_bits(m, 1, 26, 0x1);
315471 }
316472
317473 static inline u32 msg_reroute_cnt(struct tipc_msg *m)
....@@ -349,6 +505,28 @@
349505 msg_set_bits(m, 1, 0, 0xffff, n);
350506 }
351507
508
+/* Note: reusing bits in word 1 for ACTIVATE_MSG only, to re-synch
509
+ * link peer session number
510
+ */
511
+static inline bool msg_dest_session_valid(struct tipc_msg *m)
512
+{
513
+ return msg_bits(m, 1, 16, 0x1);
514
+}
515
+
516
+static inline void msg_set_dest_session_valid(struct tipc_msg *m, bool valid)
517
+{
518
+ msg_set_bits(m, 1, 16, 0x1, valid);
519
+}
520
+
521
+static inline u16 msg_dest_session(struct tipc_msg *m)
522
+{
523
+ return msg_bits(m, 1, 0, 0xffff);
524
+}
525
+
526
+static inline void msg_set_dest_session(struct tipc_msg *m, u16 n)
527
+{
528
+ msg_set_bits(m, 1, 0, 0xffff, n);
529
+}
352530
353531 /*
354532 * Word 2
....@@ -412,13 +590,23 @@
412590 static inline u32 msg_origport(struct tipc_msg *m)
413591 {
414592 if (msg_user(m) == MSG_FRAGMENTER)
415
- m = msg_get_wrapped(m);
593
+ m = msg_inner_hdr(m);
416594 return msg_word(m, 4);
417595 }
418596
419597 static inline void msg_set_origport(struct tipc_msg *m, u32 p)
420598 {
421599 msg_set_word(m, 4, p);
600
+}
601
+
602
+static inline u16 msg_named_seqno(struct tipc_msg *m)
603
+{
604
+ return msg_bits(m, 4, 0, 0xffff);
605
+}
606
+
607
+static inline void msg_set_named_seqno(struct tipc_msg *m, u16 n)
608
+{
609
+ msg_set_bits(m, 4, 0, 0xffff, n);
422610 }
423611
424612 static inline u32 msg_destport(struct tipc_msg *m)
....@@ -563,6 +751,9 @@
563751 #define GRP_RECLAIM_MSG 4
564752 #define GRP_REMIT_MSG 5
565753
754
+/* Crypto message types */
755
+#define KEY_DISTR_MSG 0
756
+
566757 /*
567758 * Word 1
568759 */
....@@ -647,11 +838,25 @@
647838 msg_set_bits(m, 4, 16, 0xffff, n);
648839 }
649840
841
+static inline u32 msg_nof_fragms(struct tipc_msg *m)
842
+{
843
+ return msg_bits(m, 4, 0, 0xffff);
844
+}
845
+
846
+static inline void msg_set_nof_fragms(struct tipc_msg *m, u32 n)
847
+{
848
+ msg_set_bits(m, 4, 0, 0xffff, n);
849
+}
850
+
851
+static inline u32 msg_fragm_no(struct tipc_msg *m)
852
+{
853
+ return msg_bits(m, 4, 16, 0xffff);
854
+}
855
+
650856 static inline void msg_set_fragm_no(struct tipc_msg *m, u32 n)
651857 {
652858 msg_set_bits(m, 4, 16, 0xffff, n);
653859 }
654
-
655860
656861 static inline u16 msg_next_sent(struct tipc_msg *m)
657862 {
....@@ -803,6 +1008,16 @@
8031008 msg_set_bits(m, 9, 16, 0xffff, n);
8041009 }
8051010
1011
+static inline u16 msg_syncpt(struct tipc_msg *m)
1012
+{
1013
+ return msg_bits(m, 9, 16, 0xffff);
1014
+}
1015
+
1016
+static inline void msg_set_syncpt(struct tipc_msg *m, u16 n)
1017
+{
1018
+ msg_set_bits(m, 9, 16, 0xffff, n);
1019
+}
1020
+
8061021 static inline u32 msg_conn_ack(struct tipc_msg *m)
8071022 {
8081023 return msg_bits(m, 9, 16, 0xffff);
....@@ -926,6 +1141,20 @@
9261141 return (msg_user(hdr) == LINK_PROTOCOL) && (msg_type(hdr) == RESET_MSG);
9271142 }
9281143
1144
+/* Word 13
1145
+ */
1146
+static inline void msg_set_peer_net_hash(struct tipc_msg *m, u32 n)
1147
+{
1148
+ msg_set_word(m, 13, n);
1149
+}
1150
+
1151
+static inline u32 msg_peer_net_hash(struct tipc_msg *m)
1152
+{
1153
+ return msg_word(m, 13);
1154
+}
1155
+
1156
+/* Word 14
1157
+ */
9291158 static inline u32 msg_sugg_node_addr(struct tipc_msg *m)
9301159 {
9311160 return msg_word(m, 14);
....@@ -957,19 +1186,23 @@
9571186 uint data_sz, u32 dnode, u32 onode,
9581187 u32 dport, u32 oport, int errcode);
9591188 int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf);
960
-bool tipc_msg_bundle(struct sk_buff *skb, struct tipc_msg *msg, u32 mtu);
961
-bool tipc_msg_make_bundle(struct sk_buff **skb, struct tipc_msg *msg,
962
- u32 mtu, u32 dnode);
1189
+bool tipc_msg_try_bundle(struct sk_buff *tskb, struct sk_buff **skb, u32 mss,
1190
+ u32 dnode, bool *new_bundle);
9631191 bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos);
1192
+int tipc_msg_fragment(struct sk_buff *skb, const struct tipc_msg *hdr,
1193
+ int pktmax, struct sk_buff_head *frags);
9641194 int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
9651195 int offset, int dsz, int mtu, struct sk_buff_head *list);
1196
+int tipc_msg_append(struct tipc_msg *hdr, struct msghdr *m, int dlen,
1197
+ int mss, struct sk_buff_head *txq);
9661198 bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err);
9671199 bool tipc_msg_assemble(struct sk_buff_head *list);
9681200 bool tipc_msg_reassemble(struct sk_buff_head *list, struct sk_buff_head *rcvq);
9691201 bool tipc_msg_pskb_copy(u32 dst, struct sk_buff_head *msg,
9701202 struct sk_buff_head *cpy);
971
-void __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno,
1203
+bool __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno,
9721204 struct sk_buff *skb);
1205
+bool tipc_msg_skb_clone(struct sk_buff_head *msg, struct sk_buff_head *cpy);
9731206
9741207 static inline u16 buf_seqno(struct sk_buff *skb)
9751208 {
....@@ -1076,4 +1309,25 @@
10761309 tipc_skb_queue_splice_tail(&tmp, head);
10771310 }
10781311
1312
+/* __tipc_skb_dequeue() - dequeue the head skb according to expected seqno
1313
+ * @list: list to be dequeued from
1314
+ * @seqno: seqno of the expected msg
1315
+ *
1316
+ * returns skb dequeued from the list if its seqno is less than or equal to
1317
+ * the expected one, otherwise the skb is still hold
1318
+ *
1319
+ * Note: must be used with appropriate locks held only
1320
+ */
1321
+static inline struct sk_buff *__tipc_skb_dequeue(struct sk_buff_head *list,
1322
+ u16 seqno)
1323
+{
1324
+ struct sk_buff *skb = skb_peek(list);
1325
+
1326
+ if (skb && less_eq(buf_seqno(skb), seqno)) {
1327
+ __skb_unlink(skb, list);
1328
+ return skb;
1329
+ }
1330
+ return NULL;
1331
+}
1332
+
10791333 #endif