output.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622
  1. /* RxRPC packet transmission
  2. *
  3. * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
  4. * Written by David Howells (dhowells@redhat.com)
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version
  9. * 2 of the License, or (at your option) any later version.
  10. */
  11. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  12. #include <linux/net.h>
  13. #include <linux/gfp.h>
  14. #include <linux/skbuff.h>
  15. #include <linux/export.h>
  16. #include <net/sock.h>
  17. #include <net/af_rxrpc.h>
  18. #include "ar-internal.h"
  19. struct rxrpc_ack_buffer {
  20. struct rxrpc_wire_header whdr;
  21. struct rxrpc_ackpacket ack;
  22. u8 acks[255];
  23. u8 pad[3];
  24. struct rxrpc_ackinfo ackinfo;
  25. };
  26. struct rxrpc_abort_buffer {
  27. struct rxrpc_wire_header whdr;
  28. __be32 abort_code;
  29. };
  30. static const char rxrpc_keepalive_string[] = "";
  31. /*
  32. * Arrange for a keepalive ping a certain time after we last transmitted. This
  33. * lets the far side know we're still interested in this call and helps keep
  34. * the route through any intervening firewall open.
  35. *
  36. * Receiving a response to the ping will prevent the ->expect_rx_by timer from
  37. * expiring.
  38. */
  39. static void rxrpc_set_keepalive(struct rxrpc_call *call)
  40. {
  41. unsigned long now = jiffies, keepalive_at = call->next_rx_timo / 6;
  42. keepalive_at += now;
  43. WRITE_ONCE(call->keepalive_at, keepalive_at);
  44. rxrpc_reduce_call_timer(call, keepalive_at, now,
  45. rxrpc_timer_set_for_keepalive);
  46. }
  47. /*
  48. * Fill out an ACK packet.
  49. */
  50. static size_t rxrpc_fill_out_ack(struct rxrpc_connection *conn,
  51. struct rxrpc_call *call,
  52. struct rxrpc_ack_buffer *pkt,
  53. rxrpc_seq_t *_hard_ack,
  54. rxrpc_seq_t *_top,
  55. u8 reason)
  56. {
  57. rxrpc_serial_t serial;
  58. rxrpc_seq_t hard_ack, top, seq;
  59. int ix;
  60. u32 mtu, jmax;
  61. u8 *ackp = pkt->acks;
  62. /* Barrier against rxrpc_input_data(). */
  63. serial = call->ackr_serial;
  64. hard_ack = READ_ONCE(call->rx_hard_ack);
  65. top = smp_load_acquire(&call->rx_top);
  66. *_hard_ack = hard_ack;
  67. *_top = top;
  68. pkt->ack.bufferSpace = htons(8);
  69. pkt->ack.maxSkew = htons(call->ackr_skew);
  70. pkt->ack.firstPacket = htonl(hard_ack + 1);
  71. pkt->ack.previousPacket = htonl(call->ackr_prev_seq);
  72. pkt->ack.serial = htonl(serial);
  73. pkt->ack.reason = reason;
  74. pkt->ack.nAcks = top - hard_ack;
  75. if (reason == RXRPC_ACK_PING)
  76. pkt->whdr.flags |= RXRPC_REQUEST_ACK;
  77. if (after(top, hard_ack)) {
  78. seq = hard_ack + 1;
  79. do {
  80. ix = seq & RXRPC_RXTX_BUFF_MASK;
  81. if (call->rxtx_buffer[ix])
  82. *ackp++ = RXRPC_ACK_TYPE_ACK;
  83. else
  84. *ackp++ = RXRPC_ACK_TYPE_NACK;
  85. seq++;
  86. } while (before_eq(seq, top));
  87. }
  88. mtu = conn->params.peer->if_mtu;
  89. mtu -= conn->params.peer->hdrsize;
  90. jmax = (call->nr_jumbo_bad > 3) ? 1 : rxrpc_rx_jumbo_max;
  91. pkt->ackinfo.rxMTU = htonl(rxrpc_rx_mtu);
  92. pkt->ackinfo.maxMTU = htonl(mtu);
  93. pkt->ackinfo.rwind = htonl(call->rx_winsize);
  94. pkt->ackinfo.jumbo_max = htonl(jmax);
  95. *ackp++ = 0;
  96. *ackp++ = 0;
  97. *ackp++ = 0;
  98. return top - hard_ack + 3;
  99. }
  100. /*
  101. * Send an ACK call packet.
  102. */
  103. int rxrpc_send_ack_packet(struct rxrpc_call *call, bool ping,
  104. rxrpc_serial_t *_serial)
  105. {
  106. struct rxrpc_connection *conn = NULL;
  107. struct rxrpc_ack_buffer *pkt;
  108. struct msghdr msg;
  109. struct kvec iov[2];
  110. rxrpc_serial_t serial;
  111. rxrpc_seq_t hard_ack, top;
  112. ktime_t now;
  113. size_t len, n;
  114. int ret;
  115. u8 reason;
  116. spin_lock_bh(&call->lock);
  117. if (call->conn)
  118. conn = rxrpc_get_connection_maybe(call->conn);
  119. spin_unlock_bh(&call->lock);
  120. if (!conn)
  121. return -ECONNRESET;
  122. pkt = kzalloc(sizeof(*pkt), GFP_KERNEL);
  123. if (!pkt) {
  124. rxrpc_put_connection(conn);
  125. return -ENOMEM;
  126. }
  127. msg.msg_name = &call->peer->srx.transport;
  128. msg.msg_namelen = call->peer->srx.transport_len;
  129. msg.msg_control = NULL;
  130. msg.msg_controllen = 0;
  131. msg.msg_flags = 0;
  132. pkt->whdr.epoch = htonl(conn->proto.epoch);
  133. pkt->whdr.cid = htonl(call->cid);
  134. pkt->whdr.callNumber = htonl(call->call_id);
  135. pkt->whdr.seq = 0;
  136. pkt->whdr.type = RXRPC_PACKET_TYPE_ACK;
  137. pkt->whdr.flags = RXRPC_SLOW_START_OK | conn->out_clientflag;
  138. pkt->whdr.userStatus = 0;
  139. pkt->whdr.securityIndex = call->security_ix;
  140. pkt->whdr._rsvd = 0;
  141. pkt->whdr.serviceId = htons(call->service_id);
  142. spin_lock_bh(&call->lock);
  143. if (ping) {
  144. reason = RXRPC_ACK_PING;
  145. } else {
  146. reason = call->ackr_reason;
  147. if (!call->ackr_reason) {
  148. spin_unlock_bh(&call->lock);
  149. ret = 0;
  150. goto out;
  151. }
  152. call->ackr_reason = 0;
  153. }
  154. n = rxrpc_fill_out_ack(conn, call, pkt, &hard_ack, &top, reason);
  155. spin_unlock_bh(&call->lock);
  156. iov[0].iov_base = pkt;
  157. iov[0].iov_len = sizeof(pkt->whdr) + sizeof(pkt->ack) + n;
  158. iov[1].iov_base = &pkt->ackinfo;
  159. iov[1].iov_len = sizeof(pkt->ackinfo);
  160. len = iov[0].iov_len + iov[1].iov_len;
  161. serial = atomic_inc_return(&conn->serial);
  162. pkt->whdr.serial = htonl(serial);
  163. trace_rxrpc_tx_ack(call->debug_id, serial,
  164. ntohl(pkt->ack.firstPacket),
  165. ntohl(pkt->ack.serial),
  166. pkt->ack.reason, pkt->ack.nAcks);
  167. if (_serial)
  168. *_serial = serial;
  169. if (ping) {
  170. call->ping_serial = serial;
  171. smp_wmb();
  172. /* We need to stick a time in before we send the packet in case
  173. * the reply gets back before kernel_sendmsg() completes - but
  174. * asking UDP to send the packet can take a relatively long
  175. * time, so we update the time after, on the assumption that
  176. * the packet transmission is more likely to happen towards the
  177. * end of the kernel_sendmsg() call.
  178. */
  179. call->ping_time = ktime_get_real();
  180. set_bit(RXRPC_CALL_PINGING, &call->flags);
  181. trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_ping, serial);
  182. }
  183. ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
  184. now = ktime_get_real();
  185. if (ping)
  186. call->ping_time = now;
  187. conn->params.peer->last_tx_at = ktime_get_seconds();
  188. if (ret < 0)
  189. trace_rxrpc_tx_fail(call->debug_id, serial, ret,
  190. rxrpc_tx_point_call_ack);
  191. else
  192. trace_rxrpc_tx_packet(call->debug_id, &pkt->whdr,
  193. rxrpc_tx_point_call_ack);
  194. if (call->state < RXRPC_CALL_COMPLETE) {
  195. if (ret < 0) {
  196. if (ping)
  197. clear_bit(RXRPC_CALL_PINGING, &call->flags);
  198. rxrpc_propose_ACK(call, pkt->ack.reason,
  199. ntohs(pkt->ack.maxSkew),
  200. ntohl(pkt->ack.serial),
  201. true, true,
  202. rxrpc_propose_ack_retry_tx);
  203. } else {
  204. spin_lock_bh(&call->lock);
  205. if (after(hard_ack, call->ackr_consumed))
  206. call->ackr_consumed = hard_ack;
  207. if (after(top, call->ackr_seen))
  208. call->ackr_seen = top;
  209. spin_unlock_bh(&call->lock);
  210. }
  211. rxrpc_set_keepalive(call);
  212. }
  213. out:
  214. rxrpc_put_connection(conn);
  215. kfree(pkt);
  216. return ret;
  217. }
  218. /*
  219. * Send an ABORT call packet.
  220. */
  221. int rxrpc_send_abort_packet(struct rxrpc_call *call)
  222. {
  223. struct rxrpc_connection *conn = NULL;
  224. struct rxrpc_abort_buffer pkt;
  225. struct msghdr msg;
  226. struct kvec iov[1];
  227. rxrpc_serial_t serial;
  228. int ret;
  229. /* Don't bother sending aborts for a client call once the server has
  230. * hard-ACK'd all of its request data. After that point, we're not
  231. * going to stop the operation proceeding, and whilst we might limit
  232. * the reply, it's not worth it if we can send a new call on the same
  233. * channel instead, thereby closing off this call.
  234. */
  235. if (rxrpc_is_client_call(call) &&
  236. test_bit(RXRPC_CALL_TX_LAST, &call->flags))
  237. return 0;
  238. spin_lock_bh(&call->lock);
  239. if (call->conn)
  240. conn = rxrpc_get_connection_maybe(call->conn);
  241. spin_unlock_bh(&call->lock);
  242. if (!conn)
  243. return -ECONNRESET;
  244. msg.msg_name = &call->peer->srx.transport;
  245. msg.msg_namelen = call->peer->srx.transport_len;
  246. msg.msg_control = NULL;
  247. msg.msg_controllen = 0;
  248. msg.msg_flags = 0;
  249. pkt.whdr.epoch = htonl(conn->proto.epoch);
  250. pkt.whdr.cid = htonl(call->cid);
  251. pkt.whdr.callNumber = htonl(call->call_id);
  252. pkt.whdr.seq = 0;
  253. pkt.whdr.type = RXRPC_PACKET_TYPE_ABORT;
  254. pkt.whdr.flags = conn->out_clientflag;
  255. pkt.whdr.userStatus = 0;
  256. pkt.whdr.securityIndex = call->security_ix;
  257. pkt.whdr._rsvd = 0;
  258. pkt.whdr.serviceId = htons(call->service_id);
  259. pkt.abort_code = htonl(call->abort_code);
  260. iov[0].iov_base = &pkt;
  261. iov[0].iov_len = sizeof(pkt);
  262. serial = atomic_inc_return(&conn->serial);
  263. pkt.whdr.serial = htonl(serial);
  264. ret = kernel_sendmsg(conn->params.local->socket,
  265. &msg, iov, 1, sizeof(pkt));
  266. conn->params.peer->last_tx_at = ktime_get_seconds();
  267. if (ret < 0)
  268. trace_rxrpc_tx_fail(call->debug_id, serial, ret,
  269. rxrpc_tx_point_call_abort);
  270. else
  271. trace_rxrpc_tx_packet(call->debug_id, &pkt.whdr,
  272. rxrpc_tx_point_call_abort);
  273. rxrpc_put_connection(conn);
  274. return ret;
  275. }
  276. /*
  277. * send a packet through the transport endpoint
  278. */
  279. int rxrpc_send_data_packet(struct rxrpc_call *call, struct sk_buff *skb,
  280. bool retrans)
  281. {
  282. struct rxrpc_connection *conn = call->conn;
  283. struct rxrpc_wire_header whdr;
  284. struct rxrpc_skb_priv *sp = rxrpc_skb(skb);
  285. struct msghdr msg;
  286. struct kvec iov[2];
  287. rxrpc_serial_t serial;
  288. size_t len;
  289. bool lost = false;
  290. int ret, opt;
  291. _enter(",{%d}", skb->len);
  292. /* Each transmission of a Tx packet needs a new serial number */
  293. serial = atomic_inc_return(&conn->serial);
  294. whdr.epoch = htonl(conn->proto.epoch);
  295. whdr.cid = htonl(call->cid);
  296. whdr.callNumber = htonl(call->call_id);
  297. whdr.seq = htonl(sp->hdr.seq);
  298. whdr.serial = htonl(serial);
  299. whdr.type = RXRPC_PACKET_TYPE_DATA;
  300. whdr.flags = sp->hdr.flags;
  301. whdr.userStatus = 0;
  302. whdr.securityIndex = call->security_ix;
  303. whdr._rsvd = htons(sp->hdr._rsvd);
  304. whdr.serviceId = htons(call->service_id);
  305. if (test_bit(RXRPC_CONN_PROBING_FOR_UPGRADE, &conn->flags) &&
  306. sp->hdr.seq == 1)
  307. whdr.userStatus = RXRPC_USERSTATUS_SERVICE_UPGRADE;
  308. iov[0].iov_base = &whdr;
  309. iov[0].iov_len = sizeof(whdr);
  310. iov[1].iov_base = skb->head;
  311. iov[1].iov_len = skb->len;
  312. len = iov[0].iov_len + iov[1].iov_len;
  313. msg.msg_name = &call->peer->srx.transport;
  314. msg.msg_namelen = call->peer->srx.transport_len;
  315. msg.msg_control = NULL;
  316. msg.msg_controllen = 0;
  317. msg.msg_flags = 0;
  318. /* If our RTT cache needs working on, request an ACK. Also request
  319. * ACKs if a DATA packet appears to have been lost.
  320. */
  321. if (!(sp->hdr.flags & RXRPC_LAST_PACKET) &&
  322. (test_and_clear_bit(RXRPC_CALL_EV_ACK_LOST, &call->events) ||
  323. retrans ||
  324. call->cong_mode == RXRPC_CALL_SLOW_START ||
  325. (call->peer->rtt_usage < 3 && sp->hdr.seq & 1) ||
  326. ktime_before(ktime_add_ms(call->peer->rtt_last_req, 1000),
  327. ktime_get_real())))
  328. whdr.flags |= RXRPC_REQUEST_ACK;
  329. if (IS_ENABLED(CONFIG_AF_RXRPC_INJECT_LOSS)) {
  330. static int lose;
  331. if ((lose++ & 7) == 7) {
  332. ret = 0;
  333. lost = true;
  334. goto done;
  335. }
  336. }
  337. _proto("Tx DATA %%%u { #%u }", serial, sp->hdr.seq);
  338. /* send the packet with the don't fragment bit set if we currently
  339. * think it's small enough */
  340. if (iov[1].iov_len >= call->peer->maxdata)
  341. goto send_fragmentable;
  342. down_read(&conn->params.local->defrag_sem);
  343. /* send the packet by UDP
  344. * - returns -EMSGSIZE if UDP would have to fragment the packet
  345. * to go out of the interface
  346. * - in which case, we'll have processed the ICMP error
  347. * message and update the peer record
  348. */
  349. ret = kernel_sendmsg(conn->params.local->socket, &msg, iov, 2, len);
  350. conn->params.peer->last_tx_at = ktime_get_seconds();
  351. up_read(&conn->params.local->defrag_sem);
  352. if (ret < 0)
  353. trace_rxrpc_tx_fail(call->debug_id, serial, ret,
  354. rxrpc_tx_point_call_data_nofrag);
  355. else
  356. trace_rxrpc_tx_packet(call->debug_id, &whdr,
  357. rxrpc_tx_point_call_data_nofrag);
  358. if (ret == -EMSGSIZE)
  359. goto send_fragmentable;
  360. done:
  361. trace_rxrpc_tx_data(call, sp->hdr.seq, serial, whdr.flags,
  362. retrans, lost);
  363. if (ret >= 0) {
  364. ktime_t now = ktime_get_real();
  365. skb->tstamp = now;
  366. smp_wmb();
  367. sp->hdr.serial = serial;
  368. if (whdr.flags & RXRPC_REQUEST_ACK) {
  369. call->peer->rtt_last_req = now;
  370. trace_rxrpc_rtt_tx(call, rxrpc_rtt_tx_data, serial);
  371. if (call->peer->rtt_usage > 1) {
  372. unsigned long nowj = jiffies, ack_lost_at;
  373. ack_lost_at = nsecs_to_jiffies(2 * call->peer->rtt);
  374. if (ack_lost_at < 1)
  375. ack_lost_at = 1;
  376. ack_lost_at += nowj;
  377. WRITE_ONCE(call->ack_lost_at, ack_lost_at);
  378. rxrpc_reduce_call_timer(call, ack_lost_at, nowj,
  379. rxrpc_timer_set_for_lost_ack);
  380. }
  381. }
  382. if (sp->hdr.seq == 1 &&
  383. !test_and_set_bit(RXRPC_CALL_BEGAN_RX_TIMER,
  384. &call->flags)) {
  385. unsigned long nowj = jiffies, expect_rx_by;
  386. expect_rx_by = nowj + call->next_rx_timo;
  387. WRITE_ONCE(call->expect_rx_by, expect_rx_by);
  388. rxrpc_reduce_call_timer(call, expect_rx_by, nowj,
  389. rxrpc_timer_set_for_normal);
  390. }
  391. }
  392. rxrpc_set_keepalive(call);
  393. _leave(" = %d [%u]", ret, call->peer->maxdata);
  394. return ret;
  395. send_fragmentable:
  396. /* attempt to send this message with fragmentation enabled */
  397. _debug("send fragment");
  398. down_write(&conn->params.local->defrag_sem);
  399. switch (conn->params.local->srx.transport.family) {
  400. case AF_INET:
  401. opt = IP_PMTUDISC_DONT;
  402. ret = kernel_setsockopt(conn->params.local->socket,
  403. SOL_IP, IP_MTU_DISCOVER,
  404. (char *)&opt, sizeof(opt));
  405. if (ret == 0) {
  406. ret = kernel_sendmsg(conn->params.local->socket, &msg,
  407. iov, 2, len);
  408. conn->params.peer->last_tx_at = ktime_get_seconds();
  409. opt = IP_PMTUDISC_DO;
  410. kernel_setsockopt(conn->params.local->socket, SOL_IP,
  411. IP_MTU_DISCOVER,
  412. (char *)&opt, sizeof(opt));
  413. }
  414. break;
  415. #ifdef CONFIG_AF_RXRPC_IPV6
  416. case AF_INET6:
  417. opt = IPV6_PMTUDISC_DONT;
  418. ret = kernel_setsockopt(conn->params.local->socket,
  419. SOL_IPV6, IPV6_MTU_DISCOVER,
  420. (char *)&opt, sizeof(opt));
  421. if (ret == 0) {
  422. ret = kernel_sendmsg(conn->params.local->socket, &msg,
  423. iov, 2, len);
  424. conn->params.peer->last_tx_at = ktime_get_seconds();
  425. opt = IPV6_PMTUDISC_DO;
  426. kernel_setsockopt(conn->params.local->socket,
  427. SOL_IPV6, IPV6_MTU_DISCOVER,
  428. (char *)&opt, sizeof(opt));
  429. }
  430. break;
  431. #endif
  432. }
  433. if (ret < 0)
  434. trace_rxrpc_tx_fail(call->debug_id, serial, ret,
  435. rxrpc_tx_point_call_data_frag);
  436. else
  437. trace_rxrpc_tx_packet(call->debug_id, &whdr,
  438. rxrpc_tx_point_call_data_frag);
  439. up_write(&conn->params.local->defrag_sem);
  440. goto done;
  441. }
  442. /*
  443. * reject packets through the local endpoint
  444. */
  445. void rxrpc_reject_packets(struct rxrpc_local *local)
  446. {
  447. struct sockaddr_rxrpc srx;
  448. struct rxrpc_skb_priv *sp;
  449. struct rxrpc_wire_header whdr;
  450. struct sk_buff *skb;
  451. struct msghdr msg;
  452. struct kvec iov[2];
  453. size_t size;
  454. __be32 code;
  455. int ret;
  456. _enter("%d", local->debug_id);
  457. iov[0].iov_base = &whdr;
  458. iov[0].iov_len = sizeof(whdr);
  459. iov[1].iov_base = &code;
  460. iov[1].iov_len = sizeof(code);
  461. size = sizeof(whdr) + sizeof(code);
  462. msg.msg_name = &srx.transport;
  463. msg.msg_control = NULL;
  464. msg.msg_controllen = 0;
  465. msg.msg_flags = 0;
  466. memset(&whdr, 0, sizeof(whdr));
  467. whdr.type = RXRPC_PACKET_TYPE_ABORT;
  468. while ((skb = skb_dequeue(&local->reject_queue))) {
  469. rxrpc_see_skb(skb, rxrpc_skb_rx_seen);
  470. sp = rxrpc_skb(skb);
  471. if (rxrpc_extract_addr_from_skb(local, &srx, skb) == 0) {
  472. msg.msg_namelen = srx.transport_len;
  473. code = htonl(skb->priority);
  474. whdr.epoch = htonl(sp->hdr.epoch);
  475. whdr.cid = htonl(sp->hdr.cid);
  476. whdr.callNumber = htonl(sp->hdr.callNumber);
  477. whdr.serviceId = htons(sp->hdr.serviceId);
  478. whdr.flags = sp->hdr.flags;
  479. whdr.flags ^= RXRPC_CLIENT_INITIATED;
  480. whdr.flags &= RXRPC_CLIENT_INITIATED;
  481. ret = kernel_sendmsg(local->socket, &msg, iov, 2, size);
  482. if (ret < 0)
  483. trace_rxrpc_tx_fail(local->debug_id, 0, ret,
  484. rxrpc_tx_point_reject);
  485. else
  486. trace_rxrpc_tx_packet(local->debug_id, &whdr,
  487. rxrpc_tx_point_reject);
  488. }
  489. rxrpc_free_skb(skb, rxrpc_skb_rx_freed);
  490. }
  491. _leave("");
  492. }
  493. /*
  494. * Send a VERSION reply to a peer as a keepalive.
  495. */
  496. void rxrpc_send_keepalive(struct rxrpc_peer *peer)
  497. {
  498. struct rxrpc_wire_header whdr;
  499. struct msghdr msg;
  500. struct kvec iov[2];
  501. size_t len;
  502. int ret;
  503. _enter("");
  504. msg.msg_name = &peer->srx.transport;
  505. msg.msg_namelen = peer->srx.transport_len;
  506. msg.msg_control = NULL;
  507. msg.msg_controllen = 0;
  508. msg.msg_flags = 0;
  509. whdr.epoch = htonl(peer->local->rxnet->epoch);
  510. whdr.cid = 0;
  511. whdr.callNumber = 0;
  512. whdr.seq = 0;
  513. whdr.serial = 0;
  514. whdr.type = RXRPC_PACKET_TYPE_VERSION; /* Not client-initiated */
  515. whdr.flags = RXRPC_LAST_PACKET;
  516. whdr.userStatus = 0;
  517. whdr.securityIndex = 0;
  518. whdr._rsvd = 0;
  519. whdr.serviceId = 0;
  520. iov[0].iov_base = &whdr;
  521. iov[0].iov_len = sizeof(whdr);
  522. iov[1].iov_base = (char *)rxrpc_keepalive_string;
  523. iov[1].iov_len = sizeof(rxrpc_keepalive_string);
  524. len = iov[0].iov_len + iov[1].iov_len;
  525. _proto("Tx VERSION (keepalive)");
  526. ret = kernel_sendmsg(peer->local->socket, &msg, iov, 2, len);
  527. if (ret < 0)
  528. trace_rxrpc_tx_fail(peer->debug_id, 0, ret,
  529. rxrpc_tx_point_version_keepalive);
  530. else
  531. trace_rxrpc_tx_packet(peer->debug_id, &whdr,
  532. rxrpc_tx_point_version_keepalive);
  533. peer->last_tx_at = ktime_get_seconds();
  534. _leave("");
  535. }