Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * SUCS NET3: |
| 3 | * |
| 4 | * Generic datagram handling routines. These are generic for all |
| 5 | * protocols. Possibly a generic IP version on top of these would |
| 6 | * make sense. Not tonight however 8-). |
| 7 | * This is used because UDP, RAW, PACKET, DDP, IPX, AX.25 and |
| 8 | * NetROM layer all have identical poll code and mostly |
| 9 | * identical recvmsg() code. So we share it here. The poll was |
| 10 | * shared before but buried in udp.c so I moved it. |
| 11 | * |
Alan Cox | 113aa83 | 2008-10-13 19:01:08 -0700 | [diff] [blame] | 12 | * Authors: Alan Cox <alan@lxorguk.ukuu.org.uk>. (datagram_poll() from old |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * udp.c code) |
| 14 | * |
| 15 | * Fixes: |
| 16 | * Alan Cox : NULL return from skb_peek_copy() |
| 17 | * understood |
| 18 | * Alan Cox : Rewrote skb_read_datagram to avoid the |
| 19 | * skb_peek_copy stuff. |
| 20 | * Alan Cox : Added support for SOCK_SEQPACKET. |
| 21 | * IPX can no longer use the SO_TYPE hack |
| 22 | * but AX.25 now works right, and SPX is |
| 23 | * feasible. |
| 24 | * Alan Cox : Fixed write poll of non IP protocol |
| 25 | * crash. |
| 26 | * Florian La Roche: Changed for my new skbuff handling. |
| 27 | * Darryl Miles : Fixed non-blocking SOCK_SEQPACKET. |
| 28 | * Linus Torvalds : BSD semantic fixes. |
| 29 | * Alan Cox : Datagram iovec handling |
| 30 | * Darryl Miles : Fixed non-blocking SOCK_STREAM. |
| 31 | * Alan Cox : POSIXisms |
| 32 | * Pete Wyckoff : Unconnected accept() fix. |
| 33 | * |
| 34 | */ |
| 35 | |
| 36 | #include <linux/module.h> |
| 37 | #include <linux/types.h> |
| 38 | #include <linux/kernel.h> |
| 39 | #include <asm/uaccess.h> |
| 40 | #include <asm/system.h> |
| 41 | #include <linux/mm.h> |
| 42 | #include <linux/interrupt.h> |
| 43 | #include <linux/errno.h> |
| 44 | #include <linux/sched.h> |
| 45 | #include <linux/inet.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 46 | #include <linux/netdevice.h> |
| 47 | #include <linux/rtnetlink.h> |
| 48 | #include <linux/poll.h> |
| 49 | #include <linux/highmem.h> |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 50 | #include <linux/spinlock.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | #include <net/protocol.h> |
| 53 | #include <linux/skbuff.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | |
Arnaldo Carvalho de Melo | c752f07 | 2005-08-09 20:08:28 -0700 | [diff] [blame] | 55 | #include <net/checksum.h> |
| 56 | #include <net/sock.h> |
| 57 | #include <net/tcp_states.h> |
Neil Horman | e9b3cc1 | 2009-08-13 05:19:44 +0000 | [diff] [blame] | 58 | #include <trace/events/skb.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | /* |
| 61 | * Is a socket 'connection oriented' ? |
| 62 | */ |
| 63 | static inline int connection_based(struct sock *sk) |
| 64 | { |
| 65 | return sk->sk_type == SOCK_SEQPACKET || sk->sk_type == SOCK_STREAM; |
| 66 | } |
| 67 | |
Eric Dumazet | bf368e4 | 2009-04-28 02:24:21 -0700 | [diff] [blame] | 68 | static int receiver_wake_function(wait_queue_t *wait, unsigned mode, int sync, |
| 69 | void *key) |
| 70 | { |
| 71 | unsigned long bits = (unsigned long)key; |
| 72 | |
| 73 | /* |
| 74 | * Avoid a wakeup if event not interesting for us |
| 75 | */ |
| 76 | if (bits && !(bits & (POLLIN | POLLERR))) |
| 77 | return 0; |
| 78 | return autoremove_wake_function(wait, mode, sync, key); |
| 79 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | /* |
| 81 | * Wait for a packet.. |
| 82 | */ |
| 83 | static int wait_for_packet(struct sock *sk, int *err, long *timeo_p) |
| 84 | { |
| 85 | int error; |
Eric Dumazet | bf368e4 | 2009-04-28 02:24:21 -0700 | [diff] [blame] | 86 | DEFINE_WAIT_FUNC(wait, receiver_wake_function); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | prepare_to_wait_exclusive(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
| 89 | |
| 90 | /* Socket errors? */ |
| 91 | error = sock_error(sk); |
| 92 | if (error) |
| 93 | goto out_err; |
| 94 | |
| 95 | if (!skb_queue_empty(&sk->sk_receive_queue)) |
| 96 | goto out; |
| 97 | |
| 98 | /* Socket shut down? */ |
| 99 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
| 100 | goto out_noerr; |
| 101 | |
| 102 | /* Sequenced packets can come disconnected. |
| 103 | * If so we report the problem |
| 104 | */ |
| 105 | error = -ENOTCONN; |
| 106 | if (connection_based(sk) && |
| 107 | !(sk->sk_state == TCP_ESTABLISHED || sk->sk_state == TCP_LISTEN)) |
| 108 | goto out_err; |
| 109 | |
| 110 | /* handle signals */ |
| 111 | if (signal_pending(current)) |
| 112 | goto interrupted; |
| 113 | |
| 114 | error = 0; |
| 115 | *timeo_p = schedule_timeout(*timeo_p); |
| 116 | out: |
| 117 | finish_wait(sk->sk_sleep, &wait); |
| 118 | return error; |
| 119 | interrupted: |
| 120 | error = sock_intr_errno(*timeo_p); |
| 121 | out_err: |
| 122 | *err = error; |
| 123 | goto out; |
| 124 | out_noerr: |
| 125 | *err = 0; |
| 126 | error = 1; |
| 127 | goto out; |
| 128 | } |
| 129 | |
| 130 | /** |
Herbert Xu | a59322b | 2007-12-05 01:53:40 -0800 | [diff] [blame] | 131 | * __skb_recv_datagram - Receive a datagram skbuff |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 132 | * @sk: socket |
| 133 | * @flags: MSG_ flags |
Herbert Xu | a59322b | 2007-12-05 01:53:40 -0800 | [diff] [blame] | 134 | * @peeked: returns non-zero if this packet has been seen before |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 135 | * @err: error code returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | * |
| 137 | * Get a datagram skbuff, understands the peeking, nonblocking wakeups |
| 138 | * and possible races. This replaces identical code in packet, raw and |
| 139 | * udp, as well as the IPX AX.25 and Appletalk. It also finally fixes |
| 140 | * the long standing peek and read race for datagram sockets. If you |
| 141 | * alter this routine remember it must be re-entrant. |
| 142 | * |
| 143 | * This function will lock the socket if a skb is returned, so the caller |
| 144 | * needs to unlock the socket in that case (usually by calling |
| 145 | * skb_free_datagram) |
| 146 | * |
| 147 | * * It does not lock socket since today. This function is |
| 148 | * * free of race conditions. This measure should/can improve |
| 149 | * * significantly datagram socket latencies at high loads, |
| 150 | * * when data copying to user space takes lots of time. |
| 151 | * * (BTW I've just killed the last cli() in IP/IPv6/core/netlink/packet |
| 152 | * * 8) Great win.) |
| 153 | * * --ANK (980729) |
| 154 | * |
| 155 | * The order of the tests when we find no data waiting are specified |
| 156 | * quite explicitly by POSIX 1003.1g, don't change them without having |
| 157 | * the standard around please. |
| 158 | */ |
Herbert Xu | a59322b | 2007-12-05 01:53:40 -0800 | [diff] [blame] | 159 | struct sk_buff *__skb_recv_datagram(struct sock *sk, unsigned flags, |
| 160 | int *peeked, int *err) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | { |
| 162 | struct sk_buff *skb; |
| 163 | long timeo; |
| 164 | /* |
| 165 | * Caller is allowed not to check sk->sk_err before skb_recv_datagram() |
| 166 | */ |
| 167 | int error = sock_error(sk); |
| 168 | |
| 169 | if (error) |
| 170 | goto no_packet; |
| 171 | |
Herbert Xu | a59322b | 2007-12-05 01:53:40 -0800 | [diff] [blame] | 172 | timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
| 174 | do { |
| 175 | /* Again only user level code calls this function, so nothing |
| 176 | * interrupt level will suddenly eat the receive_queue. |
| 177 | * |
| 178 | * Look at current nfs client by the way... |
| 179 | * However, this function was corrent in any case. 8) |
| 180 | */ |
Herbert Xu | a59322b | 2007-12-05 01:53:40 -0800 | [diff] [blame] | 181 | unsigned long cpu_flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | |
Herbert Xu | a59322b | 2007-12-05 01:53:40 -0800 | [diff] [blame] | 183 | spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags); |
| 184 | skb = skb_peek(&sk->sk_receive_queue); |
| 185 | if (skb) { |
| 186 | *peeked = skb->peeked; |
| 187 | if (flags & MSG_PEEK) { |
| 188 | skb->peeked = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | atomic_inc(&skb->users); |
Herbert Xu | a59322b | 2007-12-05 01:53:40 -0800 | [diff] [blame] | 190 | } else |
| 191 | __skb_unlink(skb, &sk->sk_receive_queue); |
| 192 | } |
| 193 | spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | |
| 195 | if (skb) |
| 196 | return skb; |
| 197 | |
| 198 | /* User doesn't want to wait */ |
| 199 | error = -EAGAIN; |
| 200 | if (!timeo) |
| 201 | goto no_packet; |
| 202 | |
| 203 | } while (!wait_for_packet(sk, err, &timeo)); |
| 204 | |
| 205 | return NULL; |
| 206 | |
| 207 | no_packet: |
| 208 | *err = error; |
| 209 | return NULL; |
| 210 | } |
Herbert Xu | a59322b | 2007-12-05 01:53:40 -0800 | [diff] [blame] | 211 | EXPORT_SYMBOL(__skb_recv_datagram); |
| 212 | |
| 213 | struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags, |
| 214 | int noblock, int *err) |
| 215 | { |
| 216 | int peeked; |
| 217 | |
| 218 | return __skb_recv_datagram(sk, flags | (noblock ? MSG_DONTWAIT : 0), |
| 219 | &peeked, err); |
| 220 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | |
| 222 | void skb_free_datagram(struct sock *sk, struct sk_buff *skb) |
| 223 | { |
Neil Horman | ead2ceb | 2009-03-11 09:49:55 +0000 | [diff] [blame] | 224 | consume_skb(skb); |
Eric Dumazet | 270acef | 2008-11-05 01:38:06 -0800 | [diff] [blame] | 225 | sk_mem_reclaim_partial(sk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | } |
| 227 | |
| 228 | /** |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 229 | * skb_kill_datagram - Free a datagram skbuff forcibly |
| 230 | * @sk: socket |
| 231 | * @skb: datagram skbuff |
| 232 | * @flags: MSG_ flags |
| 233 | * |
| 234 | * This function frees a datagram skbuff that was received by |
| 235 | * skb_recv_datagram. The flags argument must match the one |
| 236 | * used for skb_recv_datagram. |
| 237 | * |
| 238 | * If the MSG_PEEK flag is set, and the packet is still on the |
| 239 | * receive queue of the socket, it will be taken off the queue |
| 240 | * before it is freed. |
| 241 | * |
| 242 | * This function currently only disables BH when acquiring the |
| 243 | * sk_receive_queue lock. Therefore it must not be used in a |
| 244 | * context where that lock is acquired in an IRQ context. |
Herbert Xu | 27ab256 | 2007-12-05 01:51:58 -0800 | [diff] [blame] | 245 | * |
| 246 | * It returns 0 if the packet was removed by us. |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 247 | */ |
| 248 | |
Herbert Xu | 27ab256 | 2007-12-05 01:51:58 -0800 | [diff] [blame] | 249 | int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags) |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 250 | { |
Herbert Xu | 27ab256 | 2007-12-05 01:51:58 -0800 | [diff] [blame] | 251 | int err = 0; |
| 252 | |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 253 | if (flags & MSG_PEEK) { |
Herbert Xu | 27ab256 | 2007-12-05 01:51:58 -0800 | [diff] [blame] | 254 | err = -ENOENT; |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 255 | spin_lock_bh(&sk->sk_receive_queue.lock); |
| 256 | if (skb == skb_peek(&sk->sk_receive_queue)) { |
| 257 | __skb_unlink(skb, &sk->sk_receive_queue); |
| 258 | atomic_dec(&skb->users); |
Herbert Xu | 27ab256 | 2007-12-05 01:51:58 -0800 | [diff] [blame] | 259 | err = 0; |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 260 | } |
| 261 | spin_unlock_bh(&sk->sk_receive_queue.lock); |
| 262 | } |
| 263 | |
John Dykstra | 61de71c | 2009-05-08 14:57:01 -0700 | [diff] [blame] | 264 | kfree_skb(skb); |
| 265 | sk_mem_reclaim_partial(sk); |
| 266 | |
Herbert Xu | 27ab256 | 2007-12-05 01:51:58 -0800 | [diff] [blame] | 267 | return err; |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | EXPORT_SYMBOL(skb_kill_datagram); |
| 271 | |
| 272 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | * skb_copy_datagram_iovec - Copy a datagram to an iovec. |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 274 | * @skb: buffer to copy |
| 275 | * @offset: offset in the buffer to start copying from |
Martin Waitz | 67be2dd | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 276 | * @to: io vector to copy to |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 277 | * @len: amount of data to copy from buffer to iovec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | * |
| 279 | * Note: the iovec is modified during the copy. |
| 280 | */ |
| 281 | int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset, |
| 282 | struct iovec *to, int len) |
| 283 | { |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 284 | int start = skb_headlen(skb); |
| 285 | int i, copy = start - offset; |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 286 | struct sk_buff *frag_iter; |
Herbert Xu | c75d721 | 2005-11-02 18:55:00 +1100 | [diff] [blame] | 287 | |
Neil Horman | e9b3cc1 | 2009-08-13 05:19:44 +0000 | [diff] [blame] | 288 | trace_skb_copy_datagram_iovec(skb, len); |
| 289 | |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 290 | /* Copy header. */ |
| 291 | if (copy > 0) { |
| 292 | if (copy > len) |
| 293 | copy = len; |
| 294 | if (memcpy_toiovec(to, skb->data + offset, copy)) |
| 295 | goto fault; |
| 296 | if ((len -= copy) == 0) |
| 297 | return 0; |
| 298 | offset += copy; |
| 299 | } |
Herbert Xu | c75d721 | 2005-11-02 18:55:00 +1100 | [diff] [blame] | 300 | |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 301 | /* Copy paged appendix. Hmm... why does this look so complicated? */ |
| 302 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 303 | int end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 304 | |
Ilpo Järvinen | 547b792 | 2008-07-25 21:43:18 -0700 | [diff] [blame] | 305 | WARN_ON(start > offset + len); |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 306 | |
| 307 | end = start + skb_shinfo(skb)->frags[i].size; |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 308 | if ((copy = end - offset) > 0) { |
| 309 | int err; |
| 310 | u8 *vaddr; |
| 311 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
| 312 | struct page *page = frag->page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | |
| 314 | if (copy > len) |
| 315 | copy = len; |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 316 | vaddr = kmap(page); |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 317 | err = memcpy_toiovec(to, vaddr + frag->page_offset + |
| 318 | offset - start, copy); |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 319 | kunmap(page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | if (err) |
| 321 | goto fault; |
| 322 | if (!(len -= copy)) |
| 323 | return 0; |
| 324 | offset += copy; |
| 325 | } |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 326 | start = end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | } |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 328 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 329 | skb_walk_frags(skb, frag_iter) { |
| 330 | int end; |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 331 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 332 | WARN_ON(start > offset + len); |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 333 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 334 | end = start + frag_iter->len; |
| 335 | if ((copy = end - offset) > 0) { |
| 336 | if (copy > len) |
| 337 | copy = len; |
| 338 | if (skb_copy_datagram_iovec(frag_iter, |
| 339 | offset - start, |
| 340 | to, copy)) |
| 341 | goto fault; |
| 342 | if ((len -= copy) == 0) |
| 343 | return 0; |
| 344 | offset += copy; |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 345 | } |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 346 | start = end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 | } |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 348 | if (!len) |
| 349 | return 0; |
| 350 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | fault: |
| 352 | return -EFAULT; |
| 353 | } |
| 354 | |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 355 | /** |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 356 | * skb_copy_datagram_const_iovec - Copy a datagram to an iovec. |
| 357 | * @skb: buffer to copy |
| 358 | * @offset: offset in the buffer to start copying from |
| 359 | * @to: io vector to copy to |
| 360 | * @to_offset: offset in the io vector to start copying to |
| 361 | * @len: amount of data to copy from buffer to iovec |
| 362 | * |
| 363 | * Returns 0 or -EFAULT. |
| 364 | * Note: the iovec is not modified during the copy. |
| 365 | */ |
| 366 | int skb_copy_datagram_const_iovec(const struct sk_buff *skb, int offset, |
| 367 | const struct iovec *to, int to_offset, |
| 368 | int len) |
| 369 | { |
| 370 | int start = skb_headlen(skb); |
| 371 | int i, copy = start - offset; |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 372 | struct sk_buff *frag_iter; |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 373 | |
| 374 | /* Copy header. */ |
| 375 | if (copy > 0) { |
| 376 | if (copy > len) |
| 377 | copy = len; |
| 378 | if (memcpy_toiovecend(to, skb->data + offset, to_offset, copy)) |
| 379 | goto fault; |
| 380 | if ((len -= copy) == 0) |
| 381 | return 0; |
| 382 | offset += copy; |
| 383 | to_offset += copy; |
| 384 | } |
| 385 | |
| 386 | /* Copy paged appendix. Hmm... why does this look so complicated? */ |
| 387 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
| 388 | int end; |
| 389 | |
| 390 | WARN_ON(start > offset + len); |
| 391 | |
| 392 | end = start + skb_shinfo(skb)->frags[i].size; |
| 393 | if ((copy = end - offset) > 0) { |
| 394 | int err; |
| 395 | u8 *vaddr; |
| 396 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
| 397 | struct page *page = frag->page; |
| 398 | |
| 399 | if (copy > len) |
| 400 | copy = len; |
| 401 | vaddr = kmap(page); |
| 402 | err = memcpy_toiovecend(to, vaddr + frag->page_offset + |
| 403 | offset - start, to_offset, copy); |
| 404 | kunmap(page); |
| 405 | if (err) |
| 406 | goto fault; |
| 407 | if (!(len -= copy)) |
| 408 | return 0; |
| 409 | offset += copy; |
| 410 | to_offset += copy; |
| 411 | } |
| 412 | start = end; |
| 413 | } |
| 414 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 415 | skb_walk_frags(skb, frag_iter) { |
| 416 | int end; |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 417 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 418 | WARN_ON(start > offset + len); |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 419 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 420 | end = start + frag_iter->len; |
| 421 | if ((copy = end - offset) > 0) { |
| 422 | if (copy > len) |
| 423 | copy = len; |
| 424 | if (skb_copy_datagram_const_iovec(frag_iter, |
| 425 | offset - start, |
| 426 | to, to_offset, |
| 427 | copy)) |
| 428 | goto fault; |
| 429 | if ((len -= copy) == 0) |
| 430 | return 0; |
| 431 | offset += copy; |
| 432 | to_offset += copy; |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 433 | } |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 434 | start = end; |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 435 | } |
| 436 | if (!len) |
| 437 | return 0; |
| 438 | |
| 439 | fault: |
| 440 | return -EFAULT; |
| 441 | } |
| 442 | EXPORT_SYMBOL(skb_copy_datagram_const_iovec); |
| 443 | |
| 444 | /** |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 445 | * skb_copy_datagram_from_iovec - Copy a datagram from an iovec. |
| 446 | * @skb: buffer to copy |
| 447 | * @offset: offset in the buffer to start copying to |
| 448 | * @from: io vector to copy to |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 449 | * @from_offset: offset in the io vector to start copying from |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 450 | * @len: amount of data to copy to buffer from iovec |
| 451 | * |
| 452 | * Returns 0 or -EFAULT. |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 453 | * Note: the iovec is not modified during the copy. |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 454 | */ |
| 455 | int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset, |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 456 | const struct iovec *from, int from_offset, |
| 457 | int len) |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 458 | { |
| 459 | int start = skb_headlen(skb); |
| 460 | int i, copy = start - offset; |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 461 | struct sk_buff *frag_iter; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 462 | |
| 463 | /* Copy header. */ |
| 464 | if (copy > 0) { |
| 465 | if (copy > len) |
| 466 | copy = len; |
Sridhar Samudrala | d2d27bf | 2009-06-05 09:35:40 +0000 | [diff] [blame] | 467 | if (memcpy_fromiovecend(skb->data + offset, from, from_offset, |
| 468 | copy)) |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 469 | goto fault; |
| 470 | if ((len -= copy) == 0) |
| 471 | return 0; |
| 472 | offset += copy; |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 473 | from_offset += copy; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | /* Copy paged appendix. Hmm... why does this look so complicated? */ |
| 477 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
| 478 | int end; |
| 479 | |
| 480 | WARN_ON(start > offset + len); |
| 481 | |
| 482 | end = start + skb_shinfo(skb)->frags[i].size; |
| 483 | if ((copy = end - offset) > 0) { |
| 484 | int err; |
| 485 | u8 *vaddr; |
| 486 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
| 487 | struct page *page = frag->page; |
| 488 | |
| 489 | if (copy > len) |
| 490 | copy = len; |
| 491 | vaddr = kmap(page); |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 492 | err = memcpy_fromiovecend(vaddr + frag->page_offset + |
| 493 | offset - start, |
| 494 | from, from_offset, copy); |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 495 | kunmap(page); |
| 496 | if (err) |
| 497 | goto fault; |
| 498 | |
| 499 | if (!(len -= copy)) |
| 500 | return 0; |
| 501 | offset += copy; |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 502 | from_offset += copy; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 503 | } |
| 504 | start = end; |
| 505 | } |
| 506 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 507 | skb_walk_frags(skb, frag_iter) { |
| 508 | int end; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 509 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 510 | WARN_ON(start > offset + len); |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 511 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 512 | end = start + frag_iter->len; |
| 513 | if ((copy = end - offset) > 0) { |
| 514 | if (copy > len) |
| 515 | copy = len; |
| 516 | if (skb_copy_datagram_from_iovec(frag_iter, |
| 517 | offset - start, |
| 518 | from, |
| 519 | from_offset, |
| 520 | copy)) |
| 521 | goto fault; |
| 522 | if ((len -= copy) == 0) |
| 523 | return 0; |
| 524 | offset += copy; |
| 525 | from_offset += copy; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 526 | } |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 527 | start = end; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 528 | } |
| 529 | if (!len) |
| 530 | return 0; |
| 531 | |
| 532 | fault: |
| 533 | return -EFAULT; |
| 534 | } |
| 535 | EXPORT_SYMBOL(skb_copy_datagram_from_iovec); |
| 536 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 537 | static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, |
| 538 | u8 __user *to, int len, |
Al Viro | 5084205 | 2006-11-14 21:36:34 -0800 | [diff] [blame] | 539 | __wsum *csump) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 541 | int start = skb_headlen(skb); |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 542 | int i, copy = start - offset; |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 543 | struct sk_buff *frag_iter; |
| 544 | int pos = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 545 | |
| 546 | /* Copy header. */ |
| 547 | if (copy > 0) { |
| 548 | int err = 0; |
| 549 | if (copy > len) |
| 550 | copy = len; |
| 551 | *csump = csum_and_copy_to_user(skb->data + offset, to, copy, |
| 552 | *csump, &err); |
| 553 | if (err) |
| 554 | goto fault; |
| 555 | if ((len -= copy) == 0) |
| 556 | return 0; |
| 557 | offset += copy; |
| 558 | to += copy; |
| 559 | pos = copy; |
| 560 | } |
| 561 | |
| 562 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 563 | int end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 564 | |
Ilpo Järvinen | 547b792 | 2008-07-25 21:43:18 -0700 | [diff] [blame] | 565 | WARN_ON(start > offset + len); |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 566 | |
| 567 | end = start + skb_shinfo(skb)->frags[i].size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 568 | if ((copy = end - offset) > 0) { |
Al Viro | 5084205 | 2006-11-14 21:36:34 -0800 | [diff] [blame] | 569 | __wsum csum2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 570 | int err = 0; |
| 571 | u8 *vaddr; |
| 572 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
| 573 | struct page *page = frag->page; |
| 574 | |
| 575 | if (copy > len) |
| 576 | copy = len; |
| 577 | vaddr = kmap(page); |
| 578 | csum2 = csum_and_copy_to_user(vaddr + |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 579 | frag->page_offset + |
| 580 | offset - start, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 581 | to, copy, 0, &err); |
| 582 | kunmap(page); |
| 583 | if (err) |
| 584 | goto fault; |
| 585 | *csump = csum_block_add(*csump, csum2, pos); |
| 586 | if (!(len -= copy)) |
| 587 | return 0; |
| 588 | offset += copy; |
| 589 | to += copy; |
| 590 | pos += copy; |
| 591 | } |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 592 | start = end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | } |
| 594 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 595 | skb_walk_frags(skb, frag_iter) { |
| 596 | int end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 597 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 598 | WARN_ON(start > offset + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 600 | end = start + frag_iter->len; |
| 601 | if ((copy = end - offset) > 0) { |
| 602 | __wsum csum2 = 0; |
| 603 | if (copy > len) |
| 604 | copy = len; |
| 605 | if (skb_copy_and_csum_datagram(frag_iter, |
| 606 | offset - start, |
| 607 | to, copy, |
| 608 | &csum2)) |
| 609 | goto fault; |
| 610 | *csump = csum_block_add(*csump, csum2, pos); |
| 611 | if ((len -= copy) == 0) |
| 612 | return 0; |
| 613 | offset += copy; |
| 614 | to += copy; |
| 615 | pos += copy; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | } |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 617 | start = end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | } |
| 619 | if (!len) |
| 620 | return 0; |
| 621 | |
| 622 | fault: |
| 623 | return -EFAULT; |
| 624 | } |
| 625 | |
Herbert Xu | 759e5d0 | 2007-03-25 20:10:56 -0700 | [diff] [blame] | 626 | __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len) |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 627 | { |
Al Viro | d3bc23e | 2006-11-14 21:24:49 -0800 | [diff] [blame] | 628 | __sum16 sum; |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 629 | |
Herbert Xu | 759e5d0 | 2007-03-25 20:10:56 -0700 | [diff] [blame] | 630 | sum = csum_fold(skb_checksum(skb, 0, len, skb->csum)); |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 631 | if (likely(!sum)) { |
Patrick McHardy | 84fa793 | 2006-08-29 16:44:56 -0700 | [diff] [blame] | 632 | if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 633 | netdev_rx_csum_fault(skb->dev); |
| 634 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 635 | } |
| 636 | return sum; |
| 637 | } |
Herbert Xu | 759e5d0 | 2007-03-25 20:10:56 -0700 | [diff] [blame] | 638 | EXPORT_SYMBOL(__skb_checksum_complete_head); |
| 639 | |
| 640 | __sum16 __skb_checksum_complete(struct sk_buff *skb) |
| 641 | { |
| 642 | return __skb_checksum_complete_head(skb, skb->len); |
| 643 | } |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 644 | EXPORT_SYMBOL(__skb_checksum_complete); |
| 645 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 646 | /** |
| 647 | * skb_copy_and_csum_datagram_iovec - Copy and checkum skb to user iovec. |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 648 | * @skb: skbuff |
| 649 | * @hlen: hardware length |
Martin Waitz | 67be2dd | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 650 | * @iov: io vector |
YOSHIFUJI Hideaki | 4ec93ed | 2007-02-09 23:24:36 +0900 | [diff] [blame] | 651 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 652 | * Caller _must_ check that skb will fit to this iovec. |
| 653 | * |
| 654 | * Returns: 0 - success. |
| 655 | * -EINVAL - checksum failure. |
| 656 | * -EFAULT - fault during copy. Beware, in this case iovec |
| 657 | * can be modified! |
| 658 | */ |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 659 | int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | int hlen, struct iovec *iov) |
| 661 | { |
Al Viro | d3bc23e | 2006-11-14 21:24:49 -0800 | [diff] [blame] | 662 | __wsum csum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | int chunk = skb->len - hlen; |
| 664 | |
Herbert Xu | ef8aef5 | 2007-09-06 14:06:35 +0100 | [diff] [blame] | 665 | if (!chunk) |
| 666 | return 0; |
| 667 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 668 | /* Skip filled elements. |
| 669 | * Pretty silly, look at memcpy_toiovec, though 8) |
| 670 | */ |
| 671 | while (!iov->iov_len) |
| 672 | iov++; |
| 673 | |
| 674 | if (iov->iov_len < chunk) { |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 675 | if (__skb_checksum_complete(skb)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 676 | goto csum_error; |
| 677 | if (skb_copy_datagram_iovec(skb, hlen, iov, chunk)) |
| 678 | goto fault; |
| 679 | } else { |
| 680 | csum = csum_partial(skb->data, hlen, skb->csum); |
| 681 | if (skb_copy_and_csum_datagram(skb, hlen, iov->iov_base, |
| 682 | chunk, &csum)) |
| 683 | goto fault; |
Al Viro | d3bc23e | 2006-11-14 21:24:49 -0800 | [diff] [blame] | 684 | if (csum_fold(csum)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | goto csum_error; |
Patrick McHardy | 84fa793 | 2006-08-29 16:44:56 -0700 | [diff] [blame] | 686 | if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 687 | netdev_rx_csum_fault(skb->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 688 | iov->iov_len -= chunk; |
| 689 | iov->iov_base += chunk; |
| 690 | } |
| 691 | return 0; |
| 692 | csum_error: |
| 693 | return -EINVAL; |
| 694 | fault: |
| 695 | return -EFAULT; |
| 696 | } |
| 697 | |
| 698 | /** |
| 699 | * datagram_poll - generic datagram poll |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 700 | * @file: file struct |
| 701 | * @sock: socket |
| 702 | * @wait: poll table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 703 | * |
| 704 | * Datagram poll: Again totally generic. This also handles |
| 705 | * sequenced packet sockets providing the socket receive queue |
| 706 | * is only ever holding data ready to receive. |
| 707 | * |
| 708 | * Note: when you _don't_ use this routine for this protocol, |
| 709 | * and you use a different write policy from sock_writeable() |
| 710 | * then please supply your own write_space callback. |
| 711 | */ |
| 712 | unsigned int datagram_poll(struct file *file, struct socket *sock, |
| 713 | poll_table *wait) |
| 714 | { |
| 715 | struct sock *sk = sock->sk; |
| 716 | unsigned int mask; |
| 717 | |
Jiri Olsa | a57de0b | 2009-07-08 12:09:13 +0000 | [diff] [blame] | 718 | sock_poll_wait(file, sk->sk_sleep, wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | mask = 0; |
| 720 | |
| 721 | /* exceptional events? */ |
| 722 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) |
| 723 | mask |= POLLERR; |
Davide Libenzi | f348d70 | 2006-03-25 03:07:39 -0800 | [diff] [blame] | 724 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
| 725 | mask |= POLLRDHUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | if (sk->sk_shutdown == SHUTDOWN_MASK) |
| 727 | mask |= POLLHUP; |
| 728 | |
| 729 | /* readable? */ |
| 730 | if (!skb_queue_empty(&sk->sk_receive_queue) || |
| 731 | (sk->sk_shutdown & RCV_SHUTDOWN)) |
| 732 | mask |= POLLIN | POLLRDNORM; |
| 733 | |
| 734 | /* Connection-based need to check for termination and startup */ |
| 735 | if (connection_based(sk)) { |
| 736 | if (sk->sk_state == TCP_CLOSE) |
| 737 | mask |= POLLHUP; |
| 738 | /* connection hasn't started yet? */ |
| 739 | if (sk->sk_state == TCP_SYN_SENT) |
| 740 | return mask; |
| 741 | } |
| 742 | |
| 743 | /* writable? */ |
| 744 | if (sock_writeable(sk)) |
| 745 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; |
| 746 | else |
| 747 | set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); |
| 748 | |
| 749 | return mask; |
| 750 | } |
| 751 | |
| 752 | EXPORT_SYMBOL(datagram_poll); |
| 753 | EXPORT_SYMBOL(skb_copy_and_csum_datagram_iovec); |
| 754 | EXPORT_SYMBOL(skb_copy_datagram_iovec); |
| 755 | EXPORT_SYMBOL(skb_free_datagram); |
| 756 | EXPORT_SYMBOL(skb_recv_datagram); |