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); |
Eric Dumazet | 8edf19c | 2009-10-15 00:12:40 +0000 | [diff] [blame^] | 265 | atomic_inc(&sk->sk_drops); |
John Dykstra | 61de71c | 2009-05-08 14:57:01 -0700 | [diff] [blame] | 266 | sk_mem_reclaim_partial(sk); |
| 267 | |
Herbert Xu | 27ab256 | 2007-12-05 01:51:58 -0800 | [diff] [blame] | 268 | return err; |
Herbert Xu | 3305b80 | 2005-12-13 23:16:37 -0800 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | EXPORT_SYMBOL(skb_kill_datagram); |
| 272 | |
| 273 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | * skb_copy_datagram_iovec - Copy a datagram to an iovec. |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 275 | * @skb: buffer to copy |
| 276 | * @offset: offset in the buffer to start copying from |
Martin Waitz | 67be2dd | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 277 | * @to: io vector to copy to |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 278 | * @len: amount of data to copy from buffer to iovec |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | * |
| 280 | * Note: the iovec is modified during the copy. |
| 281 | */ |
| 282 | int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset, |
| 283 | struct iovec *to, int len) |
| 284 | { |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 285 | int start = skb_headlen(skb); |
| 286 | int i, copy = start - offset; |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 287 | struct sk_buff *frag_iter; |
Herbert Xu | c75d721 | 2005-11-02 18:55:00 +1100 | [diff] [blame] | 288 | |
Neil Horman | e9b3cc1 | 2009-08-13 05:19:44 +0000 | [diff] [blame] | 289 | trace_skb_copy_datagram_iovec(skb, len); |
| 290 | |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 291 | /* Copy header. */ |
| 292 | if (copy > 0) { |
| 293 | if (copy > len) |
| 294 | copy = len; |
| 295 | if (memcpy_toiovec(to, skb->data + offset, copy)) |
| 296 | goto fault; |
| 297 | if ((len -= copy) == 0) |
| 298 | return 0; |
| 299 | offset += copy; |
| 300 | } |
Herbert Xu | c75d721 | 2005-11-02 18:55:00 +1100 | [diff] [blame] | 301 | |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 302 | /* Copy paged appendix. Hmm... why does this look so complicated? */ |
| 303 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 304 | int end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | |
Ilpo Järvinen | 547b792 | 2008-07-25 21:43:18 -0700 | [diff] [blame] | 306 | WARN_ON(start > offset + len); |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 307 | |
| 308 | end = start + skb_shinfo(skb)->frags[i].size; |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 309 | if ((copy = end - offset) > 0) { |
| 310 | int err; |
| 311 | u8 *vaddr; |
| 312 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
| 313 | struct page *page = frag->page; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | |
| 315 | if (copy > len) |
| 316 | copy = len; |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 317 | vaddr = kmap(page); |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 318 | err = memcpy_toiovec(to, vaddr + frag->page_offset + |
| 319 | offset - start, copy); |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 320 | kunmap(page); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | if (err) |
| 322 | goto fault; |
| 323 | if (!(len -= copy)) |
| 324 | return 0; |
| 325 | offset += copy; |
| 326 | } |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 327 | start = end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | } |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 329 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 330 | skb_walk_frags(skb, frag_iter) { |
| 331 | int end; |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 332 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 333 | WARN_ON(start > offset + len); |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 334 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 335 | end = start + frag_iter->len; |
| 336 | if ((copy = end - offset) > 0) { |
| 337 | if (copy > len) |
| 338 | copy = len; |
| 339 | if (skb_copy_datagram_iovec(frag_iter, |
| 340 | offset - start, |
| 341 | to, copy)) |
| 342 | goto fault; |
| 343 | if ((len -= copy) == 0) |
| 344 | return 0; |
| 345 | offset += copy; |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 346 | } |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 347 | start = end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 348 | } |
David S. Miller | b4d9eda | 2006-02-13 16:06:10 -0800 | [diff] [blame] | 349 | if (!len) |
| 350 | return 0; |
| 351 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | fault: |
| 353 | return -EFAULT; |
| 354 | } |
| 355 | |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 356 | /** |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 357 | * skb_copy_datagram_const_iovec - Copy a datagram to an iovec. |
| 358 | * @skb: buffer to copy |
| 359 | * @offset: offset in the buffer to start copying from |
| 360 | * @to: io vector to copy to |
| 361 | * @to_offset: offset in the io vector to start copying to |
| 362 | * @len: amount of data to copy from buffer to iovec |
| 363 | * |
| 364 | * Returns 0 or -EFAULT. |
| 365 | * Note: the iovec is not modified during the copy. |
| 366 | */ |
| 367 | int skb_copy_datagram_const_iovec(const struct sk_buff *skb, int offset, |
| 368 | const struct iovec *to, int to_offset, |
| 369 | int len) |
| 370 | { |
| 371 | int start = skb_headlen(skb); |
| 372 | int i, copy = start - offset; |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 373 | struct sk_buff *frag_iter; |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 374 | |
| 375 | /* Copy header. */ |
| 376 | if (copy > 0) { |
| 377 | if (copy > len) |
| 378 | copy = len; |
| 379 | if (memcpy_toiovecend(to, skb->data + offset, to_offset, copy)) |
| 380 | goto fault; |
| 381 | if ((len -= copy) == 0) |
| 382 | return 0; |
| 383 | offset += copy; |
| 384 | to_offset += copy; |
| 385 | } |
| 386 | |
| 387 | /* Copy paged appendix. Hmm... why does this look so complicated? */ |
| 388 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
| 389 | int end; |
| 390 | |
| 391 | WARN_ON(start > offset + len); |
| 392 | |
| 393 | end = start + skb_shinfo(skb)->frags[i].size; |
| 394 | if ((copy = end - offset) > 0) { |
| 395 | int err; |
| 396 | u8 *vaddr; |
| 397 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
| 398 | struct page *page = frag->page; |
| 399 | |
| 400 | if (copy > len) |
| 401 | copy = len; |
| 402 | vaddr = kmap(page); |
| 403 | err = memcpy_toiovecend(to, vaddr + frag->page_offset + |
| 404 | offset - start, to_offset, copy); |
| 405 | kunmap(page); |
| 406 | if (err) |
| 407 | goto fault; |
| 408 | if (!(len -= copy)) |
| 409 | return 0; |
| 410 | offset += copy; |
| 411 | to_offset += copy; |
| 412 | } |
| 413 | start = end; |
| 414 | } |
| 415 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 416 | skb_walk_frags(skb, frag_iter) { |
| 417 | int end; |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 418 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 419 | WARN_ON(start > offset + len); |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 420 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 421 | end = start + frag_iter->len; |
| 422 | if ((copy = end - offset) > 0) { |
| 423 | if (copy > len) |
| 424 | copy = len; |
| 425 | if (skb_copy_datagram_const_iovec(frag_iter, |
| 426 | offset - start, |
| 427 | to, to_offset, |
| 428 | copy)) |
| 429 | goto fault; |
| 430 | if ((len -= copy) == 0) |
| 431 | return 0; |
| 432 | offset += copy; |
| 433 | to_offset += copy; |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 434 | } |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 435 | start = end; |
Michael S. Tsirkin | 0a1ec07 | 2009-04-20 01:25:46 +0000 | [diff] [blame] | 436 | } |
| 437 | if (!len) |
| 438 | return 0; |
| 439 | |
| 440 | fault: |
| 441 | return -EFAULT; |
| 442 | } |
| 443 | EXPORT_SYMBOL(skb_copy_datagram_const_iovec); |
| 444 | |
| 445 | /** |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 446 | * skb_copy_datagram_from_iovec - Copy a datagram from an iovec. |
| 447 | * @skb: buffer to copy |
| 448 | * @offset: offset in the buffer to start copying to |
| 449 | * @from: io vector to copy to |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 450 | * @from_offset: offset in the io vector to start copying from |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 451 | * @len: amount of data to copy to buffer from iovec |
| 452 | * |
| 453 | * Returns 0 or -EFAULT. |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 454 | * Note: the iovec is not modified during the copy. |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 455 | */ |
| 456 | 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] | 457 | const struct iovec *from, int from_offset, |
| 458 | int len) |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 459 | { |
| 460 | int start = skb_headlen(skb); |
| 461 | int i, copy = start - offset; |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 462 | struct sk_buff *frag_iter; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 463 | |
| 464 | /* Copy header. */ |
| 465 | if (copy > 0) { |
| 466 | if (copy > len) |
| 467 | copy = len; |
Sridhar Samudrala | d2d27bf | 2009-06-05 09:35:40 +0000 | [diff] [blame] | 468 | if (memcpy_fromiovecend(skb->data + offset, from, from_offset, |
| 469 | copy)) |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 470 | goto fault; |
| 471 | if ((len -= copy) == 0) |
| 472 | return 0; |
| 473 | offset += copy; |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 474 | from_offset += copy; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | /* Copy paged appendix. Hmm... why does this look so complicated? */ |
| 478 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
| 479 | int end; |
| 480 | |
| 481 | WARN_ON(start > offset + len); |
| 482 | |
| 483 | end = start + skb_shinfo(skb)->frags[i].size; |
| 484 | if ((copy = end - offset) > 0) { |
| 485 | int err; |
| 486 | u8 *vaddr; |
| 487 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
| 488 | struct page *page = frag->page; |
| 489 | |
| 490 | if (copy > len) |
| 491 | copy = len; |
| 492 | vaddr = kmap(page); |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 493 | err = memcpy_fromiovecend(vaddr + frag->page_offset + |
| 494 | offset - start, |
| 495 | from, from_offset, copy); |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 496 | kunmap(page); |
| 497 | if (err) |
| 498 | goto fault; |
| 499 | |
| 500 | if (!(len -= copy)) |
| 501 | return 0; |
| 502 | offset += copy; |
Michael S. Tsirkin | 6f26c9a | 2009-04-20 01:26:11 +0000 | [diff] [blame] | 503 | from_offset += copy; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 504 | } |
| 505 | start = end; |
| 506 | } |
| 507 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 508 | skb_walk_frags(skb, frag_iter) { |
| 509 | int end; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 510 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 511 | WARN_ON(start > offset + len); |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 512 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 513 | end = start + frag_iter->len; |
| 514 | if ((copy = end - offset) > 0) { |
| 515 | if (copy > len) |
| 516 | copy = len; |
| 517 | if (skb_copy_datagram_from_iovec(frag_iter, |
| 518 | offset - start, |
| 519 | from, |
| 520 | from_offset, |
| 521 | copy)) |
| 522 | goto fault; |
| 523 | if ((len -= copy) == 0) |
| 524 | return 0; |
| 525 | offset += copy; |
| 526 | from_offset += copy; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 527 | } |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 528 | start = end; |
Rusty Russell | db543c1 | 2008-08-15 15:13:53 -0700 | [diff] [blame] | 529 | } |
| 530 | if (!len) |
| 531 | return 0; |
| 532 | |
| 533 | fault: |
| 534 | return -EFAULT; |
| 535 | } |
| 536 | EXPORT_SYMBOL(skb_copy_datagram_from_iovec); |
| 537 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, |
| 539 | u8 __user *to, int len, |
Al Viro | 5084205 | 2006-11-14 21:36:34 -0800 | [diff] [blame] | 540 | __wsum *csump) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 541 | { |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 542 | int start = skb_headlen(skb); |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 543 | int i, copy = start - offset; |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 544 | struct sk_buff *frag_iter; |
| 545 | int pos = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 546 | |
| 547 | /* Copy header. */ |
| 548 | if (copy > 0) { |
| 549 | int err = 0; |
| 550 | if (copy > len) |
| 551 | copy = len; |
| 552 | *csump = csum_and_copy_to_user(skb->data + offset, to, copy, |
| 553 | *csump, &err); |
| 554 | if (err) |
| 555 | goto fault; |
| 556 | if ((len -= copy) == 0) |
| 557 | return 0; |
| 558 | offset += copy; |
| 559 | to += copy; |
| 560 | pos = copy; |
| 561 | } |
| 562 | |
| 563 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 564 | int end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | |
Ilpo Järvinen | 547b792 | 2008-07-25 21:43:18 -0700 | [diff] [blame] | 566 | WARN_ON(start > offset + len); |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 567 | |
| 568 | end = start + skb_shinfo(skb)->frags[i].size; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | if ((copy = end - offset) > 0) { |
Al Viro | 5084205 | 2006-11-14 21:36:34 -0800 | [diff] [blame] | 570 | __wsum csum2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 571 | int err = 0; |
| 572 | u8 *vaddr; |
| 573 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
| 574 | struct page *page = frag->page; |
| 575 | |
| 576 | if (copy > len) |
| 577 | copy = len; |
| 578 | vaddr = kmap(page); |
| 579 | csum2 = csum_and_copy_to_user(vaddr + |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 580 | frag->page_offset + |
| 581 | offset - start, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 582 | to, copy, 0, &err); |
| 583 | kunmap(page); |
| 584 | if (err) |
| 585 | goto fault; |
| 586 | *csump = csum_block_add(*csump, csum2, pos); |
| 587 | if (!(len -= copy)) |
| 588 | return 0; |
| 589 | offset += copy; |
| 590 | to += copy; |
| 591 | pos += copy; |
| 592 | } |
David S. Miller | 1a028e5 | 2007-04-27 15:21:23 -0700 | [diff] [blame] | 593 | start = end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 594 | } |
| 595 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 596 | skb_walk_frags(skb, frag_iter) { |
| 597 | int end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 599 | WARN_ON(start > offset + len); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 601 | end = start + frag_iter->len; |
| 602 | if ((copy = end - offset) > 0) { |
| 603 | __wsum csum2 = 0; |
| 604 | if (copy > len) |
| 605 | copy = len; |
| 606 | if (skb_copy_and_csum_datagram(frag_iter, |
| 607 | offset - start, |
| 608 | to, copy, |
| 609 | &csum2)) |
| 610 | goto fault; |
| 611 | *csump = csum_block_add(*csump, csum2, pos); |
| 612 | if ((len -= copy) == 0) |
| 613 | return 0; |
| 614 | offset += copy; |
| 615 | to += copy; |
| 616 | pos += copy; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 617 | } |
David S. Miller | 5b1a002 | 2009-06-09 00:18:15 -0700 | [diff] [blame] | 618 | start = end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | } |
| 620 | if (!len) |
| 621 | return 0; |
| 622 | |
| 623 | fault: |
| 624 | return -EFAULT; |
| 625 | } |
| 626 | |
Herbert Xu | 759e5d0 | 2007-03-25 20:10:56 -0700 | [diff] [blame] | 627 | __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len) |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 628 | { |
Al Viro | d3bc23e | 2006-11-14 21:24:49 -0800 | [diff] [blame] | 629 | __sum16 sum; |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 630 | |
Herbert Xu | 759e5d0 | 2007-03-25 20:10:56 -0700 | [diff] [blame] | 631 | sum = csum_fold(skb_checksum(skb, 0, len, skb->csum)); |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 632 | if (likely(!sum)) { |
Patrick McHardy | 84fa793 | 2006-08-29 16:44:56 -0700 | [diff] [blame] | 633 | if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 634 | netdev_rx_csum_fault(skb->dev); |
| 635 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
| 636 | } |
| 637 | return sum; |
| 638 | } |
Herbert Xu | 759e5d0 | 2007-03-25 20:10:56 -0700 | [diff] [blame] | 639 | EXPORT_SYMBOL(__skb_checksum_complete_head); |
| 640 | |
| 641 | __sum16 __skb_checksum_complete(struct sk_buff *skb) |
| 642 | { |
| 643 | return __skb_checksum_complete_head(skb, skb->len); |
| 644 | } |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 645 | EXPORT_SYMBOL(__skb_checksum_complete); |
| 646 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 647 | /** |
| 648 | * 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] | 649 | * @skb: skbuff |
| 650 | * @hlen: hardware length |
Martin Waitz | 67be2dd | 2005-05-01 08:59:26 -0700 | [diff] [blame] | 651 | * @iov: io vector |
YOSHIFUJI Hideaki | 4ec93ed | 2007-02-09 23:24:36 +0900 | [diff] [blame] | 652 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | * Caller _must_ check that skb will fit to this iovec. |
| 654 | * |
| 655 | * Returns: 0 - success. |
| 656 | * -EINVAL - checksum failure. |
| 657 | * -EFAULT - fault during copy. Beware, in this case iovec |
| 658 | * can be modified! |
| 659 | */ |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 660 | int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 | int hlen, struct iovec *iov) |
| 662 | { |
Al Viro | d3bc23e | 2006-11-14 21:24:49 -0800 | [diff] [blame] | 663 | __wsum csum; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 664 | int chunk = skb->len - hlen; |
| 665 | |
Herbert Xu | ef8aef5 | 2007-09-06 14:06:35 +0100 | [diff] [blame] | 666 | if (!chunk) |
| 667 | return 0; |
| 668 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | /* Skip filled elements. |
| 670 | * Pretty silly, look at memcpy_toiovec, though 8) |
| 671 | */ |
| 672 | while (!iov->iov_len) |
| 673 | iov++; |
| 674 | |
| 675 | if (iov->iov_len < chunk) { |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 676 | if (__skb_checksum_complete(skb)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 677 | goto csum_error; |
| 678 | if (skb_copy_datagram_iovec(skb, hlen, iov, chunk)) |
| 679 | goto fault; |
| 680 | } else { |
| 681 | csum = csum_partial(skb->data, hlen, skb->csum); |
| 682 | if (skb_copy_and_csum_datagram(skb, hlen, iov->iov_base, |
| 683 | chunk, &csum)) |
| 684 | goto fault; |
Al Viro | d3bc23e | 2006-11-14 21:24:49 -0800 | [diff] [blame] | 685 | if (csum_fold(csum)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 686 | goto csum_error; |
Patrick McHardy | 84fa793 | 2006-08-29 16:44:56 -0700 | [diff] [blame] | 687 | if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE)) |
Herbert Xu | fb286bb | 2005-11-10 13:01:24 -0800 | [diff] [blame] | 688 | netdev_rx_csum_fault(skb->dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | iov->iov_len -= chunk; |
| 690 | iov->iov_base += chunk; |
| 691 | } |
| 692 | return 0; |
| 693 | csum_error: |
| 694 | return -EINVAL; |
| 695 | fault: |
| 696 | return -EFAULT; |
| 697 | } |
| 698 | |
| 699 | /** |
| 700 | * datagram_poll - generic datagram poll |
Pavel Pisa | 4dc3b16 | 2005-05-01 08:59:25 -0700 | [diff] [blame] | 701 | * @file: file struct |
| 702 | * @sock: socket |
| 703 | * @wait: poll table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | * |
| 705 | * Datagram poll: Again totally generic. This also handles |
| 706 | * sequenced packet sockets providing the socket receive queue |
| 707 | * is only ever holding data ready to receive. |
| 708 | * |
| 709 | * Note: when you _don't_ use this routine for this protocol, |
| 710 | * and you use a different write policy from sock_writeable() |
| 711 | * then please supply your own write_space callback. |
| 712 | */ |
| 713 | unsigned int datagram_poll(struct file *file, struct socket *sock, |
| 714 | poll_table *wait) |
| 715 | { |
| 716 | struct sock *sk = sock->sk; |
| 717 | unsigned int mask; |
| 718 | |
Jiri Olsa | a57de0b | 2009-07-08 12:09:13 +0000 | [diff] [blame] | 719 | sock_poll_wait(file, sk->sk_sleep, wait); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | mask = 0; |
| 721 | |
| 722 | /* exceptional events? */ |
| 723 | if (sk->sk_err || !skb_queue_empty(&sk->sk_error_queue)) |
| 724 | mask |= POLLERR; |
Davide Libenzi | f348d70 | 2006-03-25 03:07:39 -0800 | [diff] [blame] | 725 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
| 726 | mask |= POLLRDHUP; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | if (sk->sk_shutdown == SHUTDOWN_MASK) |
| 728 | mask |= POLLHUP; |
| 729 | |
| 730 | /* readable? */ |
| 731 | if (!skb_queue_empty(&sk->sk_receive_queue) || |
| 732 | (sk->sk_shutdown & RCV_SHUTDOWN)) |
| 733 | mask |= POLLIN | POLLRDNORM; |
| 734 | |
| 735 | /* Connection-based need to check for termination and startup */ |
| 736 | if (connection_based(sk)) { |
| 737 | if (sk->sk_state == TCP_CLOSE) |
| 738 | mask |= POLLHUP; |
| 739 | /* connection hasn't started yet? */ |
| 740 | if (sk->sk_state == TCP_SYN_SENT) |
| 741 | return mask; |
| 742 | } |
| 743 | |
| 744 | /* writable? */ |
| 745 | if (sock_writeable(sk)) |
| 746 | mask |= POLLOUT | POLLWRNORM | POLLWRBAND; |
| 747 | else |
| 748 | set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); |
| 749 | |
| 750 | return mask; |
| 751 | } |
| 752 | |
| 753 | EXPORT_SYMBOL(datagram_poll); |
| 754 | EXPORT_SYMBOL(skb_copy_and_csum_datagram_iovec); |
| 755 | EXPORT_SYMBOL(skb_copy_datagram_iovec); |
| 756 | EXPORT_SYMBOL(skb_free_datagram); |
| 757 | EXPORT_SYMBOL(skb_recv_datagram); |