]>
git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blob - net/rxrpc/output.c
1 /* RxRPC packet transmission
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
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.
12 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
14 #include <linux/net.h>
15 #include <linux/gfp.h>
16 #include <linux/skbuff.h>
17 #include <linux/export.h>
19 #include <net/af_rxrpc.h>
20 #include "ar-internal.h"
23 * send a packet through the transport endpoint
25 int rxrpc_send_data_packet(struct rxrpc_connection
*conn
, struct sk_buff
*skb
)
31 _enter(",{%d}", skb
->len
);
33 iov
[0].iov_base
= skb
->head
;
34 iov
[0].iov_len
= skb
->len
;
36 msg
.msg_name
= &conn
->params
.peer
->srx
.transport
;
37 msg
.msg_namelen
= conn
->params
.peer
->srx
.transport_len
;
38 msg
.msg_control
= NULL
;
39 msg
.msg_controllen
= 0;
42 /* send the packet with the don't fragment bit set if we currently
43 * think it's small enough */
44 if (skb
->len
- sizeof(struct rxrpc_wire_header
) < conn
->params
.peer
->maxdata
) {
45 down_read(&conn
->params
.local
->defrag_sem
);
46 /* send the packet by UDP
47 * - returns -EMSGSIZE if UDP would have to fragment the packet
48 * to go out of the interface
49 * - in which case, we'll have processed the ICMP error
50 * message and update the peer record
52 ret
= kernel_sendmsg(conn
->params
.local
->socket
, &msg
, iov
, 1,
55 up_read(&conn
->params
.local
->defrag_sem
);
57 goto send_fragmentable
;
59 _leave(" = %d [%u]", ret
, conn
->params
.peer
->maxdata
);
64 /* attempt to send this message with fragmentation enabled */
65 _debug("send fragment");
67 down_write(&conn
->params
.local
->defrag_sem
);
69 switch (conn
->params
.local
->srx
.transport
.family
) {
71 opt
= IP_PMTUDISC_DONT
;
72 ret
= kernel_setsockopt(conn
->params
.local
->socket
,
73 SOL_IP
, IP_MTU_DISCOVER
,
74 (char *)&opt
, sizeof(opt
));
76 ret
= kernel_sendmsg(conn
->params
.local
->socket
, &msg
, iov
, 1,
80 kernel_setsockopt(conn
->params
.local
->socket
, SOL_IP
,
82 (char *)&opt
, sizeof(opt
));
87 up_write(&conn
->params
.local
->defrag_sem
);
88 _leave(" = %d [frag %u]", ret
, conn
->params
.peer
->maxdata
);