.. | .. |
---|
82 | 82 | #define NAME_DISTRIBUTOR 11 |
---|
83 | 83 | #define MSG_FRAGMENTER 12 |
---|
84 | 84 | #define LINK_CONFIG 13 |
---|
| 85 | +#define MSG_CRYPTO 14 |
---|
85 | 86 | #define SOCK_WAKEUP 14 /* pseudo user */ |
---|
86 | 87 | #define TOP_SRV 15 /* pseudo user */ |
---|
87 | 88 | |
---|
.. | .. |
---|
98 | 99 | #define MAX_H_SIZE 60 /* Largest possible TIPC header size */ |
---|
99 | 100 | |
---|
100 | 101 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) |
---|
101 | | -#define FB_MTU 3744 |
---|
102 | 102 | #define TIPC_MEDIA_INFO_OFFSET 5 |
---|
103 | 103 | |
---|
| 104 | +extern const int one_page_mtu; |
---|
| 105 | + |
---|
104 | 106 | 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; |
---|
112 | 145 | |
---|
113 | 146 | #define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0])) |
---|
114 | 147 | |
---|
115 | 148 | struct tipc_msg { |
---|
116 | 149 | __be32 hdr[15]; |
---|
117 | 150 | }; |
---|
| 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) |
---|
118 | 199 | |
---|
119 | 200 | static inline struct tipc_msg *buf_msg(struct sk_buff *skb) |
---|
120 | 201 | { |
---|
.. | .. |
---|
216 | 297 | msg_set_bits(m, 0, 20, 1, n); |
---|
217 | 298 | } |
---|
218 | 299 | |
---|
| 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 | + |
---|
219 | 310 | static inline int msg_dest_droppable(struct tipc_msg *m) |
---|
220 | 311 | { |
---|
221 | 312 | return msg_bits(m, 0, 19, 1); |
---|
.. | .. |
---|
246 | 337 | msg_set_bits(m, 0, 18, 1, d); |
---|
247 | 338 | } |
---|
248 | 339 | |
---|
| 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 | + |
---|
249 | 370 | static inline void msg_set_size(struct tipc_msg *m, u32 sz) |
---|
250 | 371 | { |
---|
251 | 372 | m->hdr[0] = htonl((msg_word(m, 0) & ~0x1ffff) | sz); |
---|
.. | .. |
---|
256 | 377 | return ((unchar *)m) + msg_hdr_sz(m); |
---|
257 | 378 | } |
---|
258 | 379 | |
---|
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) |
---|
260 | 381 | { |
---|
261 | 382 | return (struct tipc_msg *)msg_data(m); |
---|
262 | 383 | } |
---|
.. | .. |
---|
304 | 425 | return msg_type(m) == TIPC_CONN_MSG; |
---|
305 | 426 | } |
---|
306 | 427 | |
---|
| 428 | +static inline u32 msg_direct(struct tipc_msg *m) |
---|
| 429 | +{ |
---|
| 430 | + return msg_type(m) == TIPC_DIRECT_MSG; |
---|
| 431 | +} |
---|
| 432 | + |
---|
307 | 433 | static inline u32 msg_errcode(struct tipc_msg *m) |
---|
308 | 434 | { |
---|
309 | 435 | return msg_bits(m, 1, 25, 0xf); |
---|
.. | .. |
---|
312 | 438 | static inline void msg_set_errcode(struct tipc_msg *m, u32 err) |
---|
313 | 439 | { |
---|
314 | 440 | 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); |
---|
315 | 471 | } |
---|
316 | 472 | |
---|
317 | 473 | static inline u32 msg_reroute_cnt(struct tipc_msg *m) |
---|
.. | .. |
---|
349 | 505 | msg_set_bits(m, 1, 0, 0xffff, n); |
---|
350 | 506 | } |
---|
351 | 507 | |
---|
| 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 | +} |
---|
352 | 530 | |
---|
353 | 531 | /* |
---|
354 | 532 | * Word 2 |
---|
.. | .. |
---|
412 | 590 | static inline u32 msg_origport(struct tipc_msg *m) |
---|
413 | 591 | { |
---|
414 | 592 | if (msg_user(m) == MSG_FRAGMENTER) |
---|
415 | | - m = msg_get_wrapped(m); |
---|
| 593 | + m = msg_inner_hdr(m); |
---|
416 | 594 | return msg_word(m, 4); |
---|
417 | 595 | } |
---|
418 | 596 | |
---|
419 | 597 | static inline void msg_set_origport(struct tipc_msg *m, u32 p) |
---|
420 | 598 | { |
---|
421 | 599 | 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); |
---|
422 | 610 | } |
---|
423 | 611 | |
---|
424 | 612 | static inline u32 msg_destport(struct tipc_msg *m) |
---|
.. | .. |
---|
563 | 751 | #define GRP_RECLAIM_MSG 4 |
---|
564 | 752 | #define GRP_REMIT_MSG 5 |
---|
565 | 753 | |
---|
| 754 | +/* Crypto message types */ |
---|
| 755 | +#define KEY_DISTR_MSG 0 |
---|
| 756 | + |
---|
566 | 757 | /* |
---|
567 | 758 | * Word 1 |
---|
568 | 759 | */ |
---|
.. | .. |
---|
647 | 838 | msg_set_bits(m, 4, 16, 0xffff, n); |
---|
648 | 839 | } |
---|
649 | 840 | |
---|
| 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 | + |
---|
650 | 856 | static inline void msg_set_fragm_no(struct tipc_msg *m, u32 n) |
---|
651 | 857 | { |
---|
652 | 858 | msg_set_bits(m, 4, 16, 0xffff, n); |
---|
653 | 859 | } |
---|
654 | | - |
---|
655 | 860 | |
---|
656 | 861 | static inline u16 msg_next_sent(struct tipc_msg *m) |
---|
657 | 862 | { |
---|
.. | .. |
---|
803 | 1008 | msg_set_bits(m, 9, 16, 0xffff, n); |
---|
804 | 1009 | } |
---|
805 | 1010 | |
---|
| 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 | + |
---|
806 | 1021 | static inline u32 msg_conn_ack(struct tipc_msg *m) |
---|
807 | 1022 | { |
---|
808 | 1023 | return msg_bits(m, 9, 16, 0xffff); |
---|
.. | .. |
---|
926 | 1141 | return (msg_user(hdr) == LINK_PROTOCOL) && (msg_type(hdr) == RESET_MSG); |
---|
927 | 1142 | } |
---|
928 | 1143 | |
---|
| 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 | + */ |
---|
929 | 1158 | static inline u32 msg_sugg_node_addr(struct tipc_msg *m) |
---|
930 | 1159 | { |
---|
931 | 1160 | return msg_word(m, 14); |
---|
.. | .. |
---|
957 | 1186 | uint data_sz, u32 dnode, u32 onode, |
---|
958 | 1187 | u32 dport, u32 oport, int errcode); |
---|
959 | 1188 | 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); |
---|
963 | 1191 | 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); |
---|
964 | 1194 | int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m, |
---|
965 | 1195 | 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); |
---|
966 | 1198 | bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err); |
---|
967 | 1199 | bool tipc_msg_assemble(struct sk_buff_head *list); |
---|
968 | 1200 | bool tipc_msg_reassemble(struct sk_buff_head *list, struct sk_buff_head *rcvq); |
---|
969 | 1201 | bool tipc_msg_pskb_copy(u32 dst, struct sk_buff_head *msg, |
---|
970 | 1202 | 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, |
---|
972 | 1204 | struct sk_buff *skb); |
---|
| 1205 | +bool tipc_msg_skb_clone(struct sk_buff_head *msg, struct sk_buff_head *cpy); |
---|
973 | 1206 | |
---|
974 | 1207 | static inline u16 buf_seqno(struct sk_buff *skb) |
---|
975 | 1208 | { |
---|
.. | .. |
---|
1076 | 1309 | tipc_skb_queue_splice_tail(&tmp, head); |
---|
1077 | 1310 | } |
---|
1078 | 1311 | |
---|
| 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 | + |
---|
1079 | 1333 | #endif |
---|