diff options
Diffstat (limited to 'include/net')
139 files changed, 5239 insertions, 2277 deletions
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index a8de812ccbc8..008711e8e78f 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h | |||
@@ -86,6 +86,8 @@ do { \ | |||
86 | 86 | ||
87 | /** | 87 | /** |
88 | * enum p9_msg_t - 9P message types | 88 | * enum p9_msg_t - 9P message types |
89 | * @P9_TLERROR: not used | ||
90 | * @P9_RLERROR: response for any failed request for 9P2000.L | ||
89 | * @P9_TSTATFS: file system status request | 91 | * @P9_TSTATFS: file system status request |
90 | * @P9_RSTATFS: file system status response | 92 | * @P9_RSTATFS: file system status response |
91 | * @P9_TSYMLINK: make symlink request | 93 | * @P9_TSYMLINK: make symlink request |
@@ -117,7 +119,7 @@ do { \ | |||
117 | * @P9_TREAD: request to transfer data from a file or directory | 119 | * @P9_TREAD: request to transfer data from a file or directory |
118 | * @P9_RREAD: response with data requested | 120 | * @P9_RREAD: response with data requested |
119 | * @P9_TWRITE: reuqest to transfer data to a file | 121 | * @P9_TWRITE: reuqest to transfer data to a file |
120 | * @P9_RWRITE: response with out much data was transfered to file | 122 | * @P9_RWRITE: response with out much data was transferred to file |
121 | * @P9_TCLUNK: forget about a handle to an entity within the file system | 123 | * @P9_TCLUNK: forget about a handle to an entity within the file system |
122 | * @P9_RCLUNK: response when server has forgotten about the handle | 124 | * @P9_RCLUNK: response when server has forgotten about the handle |
123 | * @P9_TREMOVE: request to remove an entity from the hierarchy | 125 | * @P9_TREMOVE: request to remove an entity from the hierarchy |
@@ -137,6 +139,8 @@ do { \ | |||
137 | */ | 139 | */ |
138 | 140 | ||
139 | enum p9_msg_t { | 141 | enum p9_msg_t { |
142 | P9_TLERROR = 6, | ||
143 | P9_RLERROR, | ||
140 | P9_TSTATFS = 8, | 144 | P9_TSTATFS = 8, |
141 | P9_RSTATFS, | 145 | P9_RSTATFS, |
142 | P9_TLOPEN = 12, | 146 | P9_TLOPEN = 12, |
@@ -149,6 +153,8 @@ enum p9_msg_t { | |||
149 | P9_RMKNOD, | 153 | P9_RMKNOD, |
150 | P9_TRENAME = 20, | 154 | P9_TRENAME = 20, |
151 | P9_RRENAME, | 155 | P9_RRENAME, |
156 | P9_TREADLINK = 22, | ||
157 | P9_RREADLINK, | ||
152 | P9_TGETATTR = 24, | 158 | P9_TGETATTR = 24, |
153 | P9_RGETATTR, | 159 | P9_RGETATTR, |
154 | P9_TSETATTR = 26, | 160 | P9_TSETATTR = 26, |
@@ -159,6 +165,12 @@ enum p9_msg_t { | |||
159 | P9_RXATTRCREATE, | 165 | P9_RXATTRCREATE, |
160 | P9_TREADDIR = 40, | 166 | P9_TREADDIR = 40, |
161 | P9_RREADDIR, | 167 | P9_RREADDIR, |
168 | P9_TFSYNC = 50, | ||
169 | P9_RFSYNC, | ||
170 | P9_TLOCK = 52, | ||
171 | P9_RLOCK, | ||
172 | P9_TGETLOCK = 54, | ||
173 | P9_RGETLOCK, | ||
162 | P9_TLINK = 70, | 174 | P9_TLINK = 70, |
163 | P9_RLINK, | 175 | P9_RLINK, |
164 | P9_TMKDIR = 72, | 176 | P9_TMKDIR = 72, |
@@ -229,10 +241,10 @@ enum p9_open_mode_t { | |||
229 | 241 | ||
230 | /** | 242 | /** |
231 | * enum p9_perm_t - 9P permissions | 243 | * enum p9_perm_t - 9P permissions |
232 | * @P9_DMDIR: mode bite for directories | 244 | * @P9_DMDIR: mode bit for directories |
233 | * @P9_DMAPPEND: mode bit for is append-only | 245 | * @P9_DMAPPEND: mode bit for is append-only |
234 | * @P9_DMEXCL: mode bit for excluse use (only one open handle allowed) | 246 | * @P9_DMEXCL: mode bit for excluse use (only one open handle allowed) |
235 | * @P9_DMMOUNT: mode bite for mount points | 247 | * @P9_DMMOUNT: mode bit for mount points |
236 | * @P9_DMAUTH: mode bit for authentication file | 248 | * @P9_DMAUTH: mode bit for authentication file |
237 | * @P9_DMTMP: mode bit for non-backed-up files | 249 | * @P9_DMTMP: mode bit for non-backed-up files |
238 | * @P9_DMSYMLINK: mode bit for symbolic links (9P2000.u) | 250 | * @P9_DMSYMLINK: mode bit for symbolic links (9P2000.u) |
@@ -280,7 +292,7 @@ enum p9_perm_t { | |||
280 | * | 292 | * |
281 | * QID types are a subset of permissions - they are primarily | 293 | * QID types are a subset of permissions - they are primarily |
282 | * used to differentiate semantics for a file system entity via | 294 | * used to differentiate semantics for a file system entity via |
283 | * a jump-table. Their value is also the most signifigant 16 bits | 295 | * a jump-table. Their value is also the most significant 16 bits |
284 | * of the permission_t | 296 | * of the permission_t |
285 | * | 297 | * |
286 | * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat | 298 | * See Also: http://plan9.bell-labs.com/magic/man2html/2/stat |
@@ -350,10 +362,10 @@ struct p9_qid { | |||
350 | }; | 362 | }; |
351 | 363 | ||
352 | /** | 364 | /** |
353 | * struct p9_stat - file system metadata information | 365 | * struct p9_wstat - file system metadata information |
354 | * @size: length prefix for this stat structure instance | 366 | * @size: length prefix for this stat structure instance |
355 | * @type: the type of the server (equivilent to a major number) | 367 | * @type: the type of the server (equivalent to a major number) |
356 | * @dev: the sub-type of the server (equivilent to a minor number) | 368 | * @dev: the sub-type of the server (equivalent to a minor number) |
357 | * @qid: unique id from the server of type &p9_qid | 369 | * @qid: unique id from the server of type &p9_qid |
358 | * @mode: Plan 9 format permissions of type &p9_perm_t | 370 | * @mode: Plan 9 format permissions of type &p9_perm_t |
359 | * @atime: Last access/read time | 371 | * @atime: Last access/read time |
@@ -458,6 +470,48 @@ struct p9_iattr_dotl { | |||
458 | u64 mtime_nsec; | 470 | u64 mtime_nsec; |
459 | }; | 471 | }; |
460 | 472 | ||
473 | #define P9_LOCK_SUCCESS 0 | ||
474 | #define P9_LOCK_BLOCKED 1 | ||
475 | #define P9_LOCK_ERROR 2 | ||
476 | #define P9_LOCK_GRACE 3 | ||
477 | |||
478 | #define P9_LOCK_FLAGS_BLOCK 1 | ||
479 | #define P9_LOCK_FLAGS_RECLAIM 2 | ||
480 | |||
481 | /* struct p9_flock: POSIX lock structure | ||
482 | * @type - type of lock | ||
483 | * @flags - lock flags | ||
484 | * @start - starting offset of the lock | ||
485 | * @length - number of bytes | ||
486 | * @proc_id - process id which wants to take lock | ||
487 | * @client_id - client id | ||
488 | */ | ||
489 | |||
490 | struct p9_flock { | ||
491 | u8 type; | ||
492 | u32 flags; | ||
493 | u64 start; | ||
494 | u64 length; | ||
495 | u32 proc_id; | ||
496 | char *client_id; | ||
497 | }; | ||
498 | |||
499 | /* struct p9_getlock: getlock structure | ||
500 | * @type - type of lock | ||
501 | * @start - starting offset of the lock | ||
502 | * @length - number of bytes | ||
503 | * @proc_id - process id which wants to take lock | ||
504 | * @client_id - client id | ||
505 | */ | ||
506 | |||
507 | struct p9_getlock { | ||
508 | u8 type; | ||
509 | u64 start; | ||
510 | u64 length; | ||
511 | u32 proc_id; | ||
512 | char *client_id; | ||
513 | }; | ||
514 | |||
461 | /* Structures for Protocol Operations */ | 515 | /* Structures for Protocol Operations */ |
462 | struct p9_tstatfs { | 516 | struct p9_tstatfs { |
463 | u32 fid; | 517 | u32 fid; |
@@ -633,8 +687,12 @@ struct p9_rwstat { | |||
633 | * @size: prefixed length of the structure | 687 | * @size: prefixed length of the structure |
634 | * @id: protocol operating identifier of type &p9_msg_t | 688 | * @id: protocol operating identifier of type &p9_msg_t |
635 | * @tag: transaction id of the request | 689 | * @tag: transaction id of the request |
636 | * @offset: used by marshalling routines to track currentposition in buffer | 690 | * @offset: used by marshalling routines to track current position in buffer |
637 | * @capacity: used by marshalling routines to track total capacity | 691 | * @capacity: used by marshalling routines to track total malloc'd capacity |
692 | * @pubuf: Payload user buffer given by the caller | ||
693 | * @pkbuf: Payload kernel buffer given by the caller | ||
694 | * @pbuf_size: pubuf/pkbuf(only one will be !NULL) size to be read/write. | ||
695 | * @private: For transport layer's use. | ||
638 | * @sdata: payload | 696 | * @sdata: payload |
639 | * | 697 | * |
640 | * &p9_fcall represents the structure for all 9P RPC | 698 | * &p9_fcall represents the structure for all 9P RPC |
@@ -651,8 +709,12 @@ struct p9_fcall { | |||
651 | 709 | ||
652 | size_t offset; | 710 | size_t offset; |
653 | size_t capacity; | 711 | size_t capacity; |
712 | char __user *pubuf; | ||
713 | char *pkbuf; | ||
714 | size_t pbuf_size; | ||
715 | void *private; | ||
654 | 716 | ||
655 | uint8_t *sdata; | 717 | u8 *sdata; |
656 | }; | 718 | }; |
657 | 719 | ||
658 | struct p9_idpool; | 720 | struct p9_idpool; |
@@ -666,7 +728,6 @@ void p9_idpool_put(int id, struct p9_idpool *p); | |||
666 | int p9_idpool_check(int id, struct p9_idpool *p); | 728 | int p9_idpool_check(int id, struct p9_idpool *p); |
667 | 729 | ||
668 | int p9_error_init(void); | 730 | int p9_error_init(void); |
669 | int p9_errstr2errno(char *, int); | ||
670 | int p9_trans_fd_init(void); | 731 | int p9_trans_fd_init(void); |
671 | void p9_trans_fd_exit(void); | 732 | void p9_trans_fd_exit(void); |
672 | #endif /* NET_9P_H */ | 733 | #endif /* NET_9P_H */ |
diff --git a/include/net/9p/client.h b/include/net/9p/client.h index d1aa2cfb30f0..d26d5e98a173 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h | |||
@@ -60,7 +60,7 @@ enum p9_trans_status { | |||
60 | }; | 60 | }; |
61 | 61 | ||
62 | /** | 62 | /** |
63 | * enum p9_req_status_t - virtio request status | 63 | * enum p9_req_status_t - status of a request |
64 | * @REQ_STATUS_IDLE: request slot unused | 64 | * @REQ_STATUS_IDLE: request slot unused |
65 | * @REQ_STATUS_ALLOC: request has been allocated but not sent | 65 | * @REQ_STATUS_ALLOC: request has been allocated but not sent |
66 | * @REQ_STATUS_UNSENT: request waiting to be sent | 66 | * @REQ_STATUS_UNSENT: request waiting to be sent |
@@ -101,7 +101,7 @@ enum p9_req_status_t { | |||
101 | * Transport use an array to track outstanding requests | 101 | * Transport use an array to track outstanding requests |
102 | * instead of a list. While this may incurr overhead during initial | 102 | * instead of a list. While this may incurr overhead during initial |
103 | * allocation or expansion, it makes request lookup much easier as the | 103 | * allocation or expansion, it makes request lookup much easier as the |
104 | * tag id is a index into an array. (We use tag+1 so that we can accomodate | 104 | * tag id is a index into an array. (We use tag+1 so that we can accommodate |
105 | * the -1 tag for the T_VERSION request). | 105 | * the -1 tag for the T_VERSION request). |
106 | * This also has the nice effect of only having to allocate wait_queues | 106 | * This also has the nice effect of only having to allocate wait_queues |
107 | * once, instead of constantly allocating and freeing them. Its possible | 107 | * once, instead of constantly allocating and freeing them. Its possible |
@@ -212,17 +212,14 @@ struct p9_dirent { | |||
212 | 212 | ||
213 | int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb); | 213 | int p9_client_statfs(struct p9_fid *fid, struct p9_rstatfs *sb); |
214 | int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name); | 214 | int p9_client_rename(struct p9_fid *fid, struct p9_fid *newdirfid, char *name); |
215 | int p9_client_version(struct p9_client *); | ||
216 | struct p9_client *p9_client_create(const char *dev_name, char *options); | 215 | struct p9_client *p9_client_create(const char *dev_name, char *options); |
217 | void p9_client_destroy(struct p9_client *clnt); | 216 | void p9_client_destroy(struct p9_client *clnt); |
218 | void p9_client_disconnect(struct p9_client *clnt); | 217 | void p9_client_disconnect(struct p9_client *clnt); |
219 | void p9_client_begin_disconnect(struct p9_client *clnt); | 218 | void p9_client_begin_disconnect(struct p9_client *clnt); |
220 | struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, | 219 | struct p9_fid *p9_client_attach(struct p9_client *clnt, struct p9_fid *afid, |
221 | char *uname, u32 n_uname, char *aname); | 220 | char *uname, u32 n_uname, char *aname); |
222 | struct p9_fid *p9_client_auth(struct p9_client *clnt, char *uname, | 221 | struct p9_fid *p9_client_walk(struct p9_fid *oldfid, uint16_t nwname, |
223 | u32 n_uname, char *aname); | 222 | char **wnames, int clone); |
224 | struct p9_fid *p9_client_walk(struct p9_fid *oldfid, int nwname, char **wnames, | ||
225 | int clone); | ||
226 | int p9_client_open(struct p9_fid *fid, int mode); | 223 | int p9_client_open(struct p9_fid *fid, int mode); |
227 | int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, | 224 | int p9_client_fcreate(struct p9_fid *fid, char *name, u32 perm, int mode, |
228 | char *extension); | 225 | char *extension); |
@@ -232,6 +229,7 @@ int p9_client_symlink(struct p9_fid *fid, char *name, char *symname, gid_t gid, | |||
232 | int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode, | 229 | int p9_client_create_dotl(struct p9_fid *ofid, char *name, u32 flags, u32 mode, |
233 | gid_t gid, struct p9_qid *qid); | 230 | gid_t gid, struct p9_qid *qid); |
234 | int p9_client_clunk(struct p9_fid *fid); | 231 | int p9_client_clunk(struct p9_fid *fid); |
232 | int p9_client_fsync(struct p9_fid *fid, int datasync); | ||
235 | int p9_client_remove(struct p9_fid *fid); | 233 | int p9_client_remove(struct p9_fid *fid); |
236 | int p9_client_read(struct p9_fid *fid, char *data, char __user *udata, | 234 | int p9_client_read(struct p9_fid *fid, char *data, char __user *udata, |
237 | u64 offset, u32 count); | 235 | u64 offset, u32 count); |
@@ -251,6 +249,8 @@ int p9_client_mknod_dotl(struct p9_fid *oldfid, char *name, int mode, | |||
251 | dev_t rdev, gid_t gid, struct p9_qid *); | 249 | dev_t rdev, gid_t gid, struct p9_qid *); |
252 | int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode, | 250 | int p9_client_mkdir_dotl(struct p9_fid *fid, char *name, int mode, |
253 | gid_t gid, struct p9_qid *); | 251 | gid_t gid, struct p9_qid *); |
252 | int p9_client_lock_dotl(struct p9_fid *fid, struct p9_flock *flock, u8 *status); | ||
253 | int p9_client_getlock_dotl(struct p9_fid *fid, struct p9_getlock *fl); | ||
254 | struct p9_req_t *p9_tag_lookup(struct p9_client *, u16); | 254 | struct p9_req_t *p9_tag_lookup(struct p9_client *, u16); |
255 | void p9_client_cb(struct p9_client *c, struct p9_req_t *req); | 255 | void p9_client_cb(struct p9_client *c, struct p9_req_t *req); |
256 | 256 | ||
@@ -262,5 +262,6 @@ int p9_is_proto_dotu(struct p9_client *clnt); | |||
262 | int p9_is_proto_dotl(struct p9_client *clnt); | 262 | int p9_is_proto_dotl(struct p9_client *clnt); |
263 | struct p9_fid *p9_client_xattrwalk(struct p9_fid *, const char *, u64 *); | 263 | struct p9_fid *p9_client_xattrwalk(struct p9_fid *, const char *, u64 *); |
264 | int p9_client_xattrcreate(struct p9_fid *, const char *, u64, int); | 264 | int p9_client_xattrcreate(struct p9_fid *, const char *, u64, int); |
265 | int p9_client_readlink(struct p9_fid *fid, char **target); | ||
265 | 266 | ||
266 | #endif /* NET_9P_CLIENT_H */ | 267 | #endif /* NET_9P_CLIENT_H */ |
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h index 6d5886efb102..d8549fb9c742 100644 --- a/include/net/9p/transport.h +++ b/include/net/9p/transport.h | |||
@@ -26,13 +26,22 @@ | |||
26 | #ifndef NET_9P_TRANSPORT_H | 26 | #ifndef NET_9P_TRANSPORT_H |
27 | #define NET_9P_TRANSPORT_H | 27 | #define NET_9P_TRANSPORT_H |
28 | 28 | ||
29 | #define P9_TRANS_PREF_PAYLOAD_MASK 0x1 | ||
30 | |||
31 | /* Default. Add Payload to PDU before sending it down to transport layer */ | ||
32 | #define P9_TRANS_PREF_PAYLOAD_DEF 0x0 | ||
33 | /* Send pay load separately to transport layer along with PDU.*/ | ||
34 | #define P9_TRANS_PREF_PAYLOAD_SEP 0x1 | ||
35 | |||
29 | /** | 36 | /** |
30 | * struct p9_trans_module - transport module interface | 37 | * struct p9_trans_module - transport module interface |
31 | * @list: used to maintain a list of currently available transports | 38 | * @list: used to maintain a list of currently available transports |
32 | * @name: the human-readable name of the transport | 39 | * @name: the human-readable name of the transport |
33 | * @maxsize: transport provided maximum packet size | 40 | * @maxsize: transport provided maximum packet size |
41 | * @pref: Preferences of this transport | ||
34 | * @def: set if this transport should be considered the default | 42 | * @def: set if this transport should be considered the default |
35 | * @create: member function to create a new connection on this transport | 43 | * @create: member function to create a new connection on this transport |
44 | * @close: member function to discard a connection on this transport | ||
36 | * @request: member function to issue a request to the transport | 45 | * @request: member function to issue a request to the transport |
37 | * @cancel: member function to cancel a request (if it hasn't been sent) | 46 | * @cancel: member function to cancel a request (if it hasn't been sent) |
38 | * | 47 | * |
@@ -40,13 +49,14 @@ | |||
40 | * transport module with the 9P core network module and used by the client | 49 | * transport module with the 9P core network module and used by the client |
41 | * to instantiate a new connection on a transport. | 50 | * to instantiate a new connection on a transport. |
42 | * | 51 | * |
43 | * BUGS: the transport module list isn't protected. | 52 | * The transport module list is protected by v9fs_trans_lock. |
44 | */ | 53 | */ |
45 | 54 | ||
46 | struct p9_trans_module { | 55 | struct p9_trans_module { |
47 | struct list_head list; | 56 | struct list_head list; |
48 | char *name; /* name of transport */ | 57 | char *name; /* name of transport */ |
49 | int maxsize; /* max message size of transport */ | 58 | int maxsize; /* max message size of transport */ |
59 | int pref; /* Preferences of this transport */ | ||
50 | int def; /* this transport should be default */ | 60 | int def; /* this transport should be default */ |
51 | struct module *owner; | 61 | struct module *owner; |
52 | int (*create)(struct p9_client *, const char *, char *); | 62 | int (*create)(struct p9_client *, const char *, char *); |
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index 4d40c4d0230b..582e4ae70753 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef _ADDRCONF_H | 1 | #ifndef _ADDRCONF_H |
2 | #define _ADDRCONF_H | 2 | #define _ADDRCONF_H |
3 | 3 | ||
4 | #define RETRANS_TIMER HZ | ||
5 | |||
6 | #define MAX_RTR_SOLICITATIONS 3 | 4 | #define MAX_RTR_SOLICITATIONS 3 |
7 | #define RTR_SOLICITATION_INTERVAL (4*HZ) | 5 | #define RTR_SOLICITATION_INTERVAL (4*HZ) |
8 | 6 | ||
@@ -44,8 +42,6 @@ struct prefix_info { | |||
44 | }; | 42 | }; |
45 | 43 | ||
46 | 44 | ||
47 | #ifdef __KERNEL__ | ||
48 | |||
49 | #include <linux/netdevice.h> | 45 | #include <linux/netdevice.h> |
50 | #include <net/if_inet6.h> | 46 | #include <net/if_inet6.h> |
51 | #include <net/ipv6.h> | 47 | #include <net/ipv6.h> |
@@ -63,16 +59,16 @@ extern int addrconf_set_dstaddr(struct net *net, | |||
63 | void __user *arg); | 59 | void __user *arg); |
64 | 60 | ||
65 | extern int ipv6_chk_addr(struct net *net, | 61 | extern int ipv6_chk_addr(struct net *net, |
66 | struct in6_addr *addr, | 62 | const struct in6_addr *addr, |
67 | struct net_device *dev, | 63 | struct net_device *dev, |
68 | int strict); | 64 | int strict); |
69 | 65 | ||
70 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) | 66 | #if defined(CONFIG_IPV6_MIP6) || defined(CONFIG_IPV6_MIP6_MODULE) |
71 | extern int ipv6_chk_home_addr(struct net *net, | 67 | extern int ipv6_chk_home_addr(struct net *net, |
72 | struct in6_addr *addr); | 68 | const struct in6_addr *addr); |
73 | #endif | 69 | #endif |
74 | 70 | ||
75 | extern int ipv6_chk_prefix(struct in6_addr *addr, | 71 | extern int ipv6_chk_prefix(const struct in6_addr *addr, |
76 | struct net_device *dev); | 72 | struct net_device *dev); |
77 | 73 | ||
78 | extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, | 74 | extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, |
@@ -91,9 +87,9 @@ extern int ipv6_get_lladdr(struct net_device *dev, | |||
91 | extern int ipv6_rcv_saddr_equal(const struct sock *sk, | 87 | extern int ipv6_rcv_saddr_equal(const struct sock *sk, |
92 | const struct sock *sk2); | 88 | const struct sock *sk2); |
93 | extern void addrconf_join_solict(struct net_device *dev, | 89 | extern void addrconf_join_solict(struct net_device *dev, |
94 | struct in6_addr *addr); | 90 | const struct in6_addr *addr); |
95 | extern void addrconf_leave_solict(struct inet6_dev *idev, | 91 | extern void addrconf_leave_solict(struct inet6_dev *idev, |
96 | struct in6_addr *addr); | 92 | const struct in6_addr *addr); |
97 | 93 | ||
98 | static inline unsigned long addrconf_timeout_fixup(u32 timeout, | 94 | static inline unsigned long addrconf_timeout_fixup(u32 timeout, |
99 | unsigned unit) | 95 | unsigned unit) |
@@ -160,35 +156,47 @@ extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len); | |||
160 | /* | 156 | /* |
161 | * anycast prototypes (anycast.c) | 157 | * anycast prototypes (anycast.c) |
162 | */ | 158 | */ |
163 | extern int ipv6_sock_ac_join(struct sock *sk,int ifindex,struct in6_addr *addr); | 159 | extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr); |
164 | extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex,struct in6_addr *addr); | 160 | extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr); |
165 | extern void ipv6_sock_ac_close(struct sock *sk); | 161 | extern void ipv6_sock_ac_close(struct sock *sk); |
166 | extern int inet6_ac_check(struct sock *sk, struct in6_addr *addr, int ifindex); | 162 | extern int inet6_ac_check(struct sock *sk, const struct in6_addr *addr, int ifindex); |
167 | 163 | ||
168 | extern int ipv6_dev_ac_inc(struct net_device *dev, struct in6_addr *addr); | 164 | extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr); |
169 | extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, struct in6_addr *addr); | 165 | extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr); |
170 | extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev, | 166 | extern int ipv6_chk_acast_addr(struct net *net, struct net_device *dev, |
171 | struct in6_addr *addr); | 167 | const struct in6_addr *addr); |
172 | 168 | ||
173 | 169 | ||
174 | /* Device notifier */ | 170 | /* Device notifier */ |
175 | extern int register_inet6addr_notifier(struct notifier_block *nb); | 171 | extern int register_inet6addr_notifier(struct notifier_block *nb); |
176 | extern int unregister_inet6addr_notifier(struct notifier_block *nb); | 172 | extern int unregister_inet6addr_notifier(struct notifier_block *nb); |
177 | 173 | ||
178 | static inline struct inet6_dev * | 174 | /** |
179 | __in6_dev_get(struct net_device *dev) | 175 | * __in6_dev_get - get inet6_dev pointer from netdevice |
176 | * @dev: network device | ||
177 | * | ||
178 | * Caller must hold rcu_read_lock or RTNL, because this function | ||
179 | * does not take a reference on the inet6_dev. | ||
180 | */ | ||
181 | static inline struct inet6_dev *__in6_dev_get(const struct net_device *dev) | ||
180 | { | 182 | { |
181 | return rcu_dereference_check(dev->ip6_ptr, | 183 | return rcu_dereference_rtnl(dev->ip6_ptr); |
182 | rcu_read_lock_held() || | ||
183 | lockdep_rtnl_is_held()); | ||
184 | } | 184 | } |
185 | 185 | ||
186 | static inline struct inet6_dev * | 186 | /** |
187 | in6_dev_get(struct net_device *dev) | 187 | * in6_dev_get - get inet6_dev pointer from netdevice |
188 | * @dev: network device | ||
189 | * | ||
190 | * This version can be used in any context, and takes a reference | ||
191 | * on the inet6_dev. Callers must use in6_dev_put() later to | ||
192 | * release this reference. | ||
193 | */ | ||
194 | static inline struct inet6_dev *in6_dev_get(const struct net_device *dev) | ||
188 | { | 195 | { |
189 | struct inet6_dev *idev = NULL; | 196 | struct inet6_dev *idev; |
197 | |||
190 | rcu_read_lock(); | 198 | rcu_read_lock(); |
191 | idev = __in6_dev_get(dev); | 199 | idev = rcu_dereference(dev->ip6_ptr); |
192 | if (idev) | 200 | if (idev) |
193 | atomic_inc(&idev->refcnt); | 201 | atomic_inc(&idev->refcnt); |
194 | rcu_read_unlock(); | 202 | rcu_read_unlock(); |
@@ -197,16 +205,21 @@ in6_dev_get(struct net_device *dev) | |||
197 | 205 | ||
198 | extern void in6_dev_finish_destroy(struct inet6_dev *idev); | 206 | extern void in6_dev_finish_destroy(struct inet6_dev *idev); |
199 | 207 | ||
200 | static inline void | 208 | static inline void in6_dev_put(struct inet6_dev *idev) |
201 | in6_dev_put(struct inet6_dev *idev) | ||
202 | { | 209 | { |
203 | if (atomic_dec_and_test(&idev->refcnt)) | 210 | if (atomic_dec_and_test(&idev->refcnt)) |
204 | in6_dev_finish_destroy(idev); | 211 | in6_dev_finish_destroy(idev); |
205 | } | 212 | } |
206 | 213 | ||
207 | #define __in6_dev_put(idev) atomic_dec(&(idev)->refcnt) | 214 | static inline void __in6_dev_put(struct inet6_dev *idev) |
208 | #define in6_dev_hold(idev) atomic_inc(&(idev)->refcnt) | 215 | { |
216 | atomic_dec(&idev->refcnt); | ||
217 | } | ||
209 | 218 | ||
219 | static inline void in6_dev_hold(struct inet6_dev *idev) | ||
220 | { | ||
221 | atomic_inc(&idev->refcnt); | ||
222 | } | ||
210 | 223 | ||
211 | extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp); | 224 | extern void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp); |
212 | 225 | ||
@@ -216,9 +229,15 @@ static inline void in6_ifa_put(struct inet6_ifaddr *ifp) | |||
216 | inet6_ifa_finish_destroy(ifp); | 229 | inet6_ifa_finish_destroy(ifp); |
217 | } | 230 | } |
218 | 231 | ||
219 | #define __in6_ifa_put(ifp) atomic_dec(&(ifp)->refcnt) | 232 | static inline void __in6_ifa_put(struct inet6_ifaddr *ifp) |
220 | #define in6_ifa_hold(ifp) atomic_inc(&(ifp)->refcnt) | 233 | { |
234 | atomic_dec(&ifp->refcnt); | ||
235 | } | ||
221 | 236 | ||
237 | static inline void in6_ifa_hold(struct inet6_ifaddr *ifp) | ||
238 | { | ||
239 | atomic_inc(&ifp->refcnt); | ||
240 | } | ||
222 | 241 | ||
223 | 242 | ||
224 | /* | 243 | /* |
@@ -241,23 +260,21 @@ static inline int ipv6_addr_is_multicast(const struct in6_addr *addr) | |||
241 | 260 | ||
242 | static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) | 261 | static inline int ipv6_addr_is_ll_all_nodes(const struct in6_addr *addr) |
243 | { | 262 | { |
244 | return (((addr->s6_addr32[0] ^ htonl(0xff020000)) | | 263 | return ((addr->s6_addr32[0] ^ htonl(0xff020000)) | |
245 | addr->s6_addr32[1] | addr->s6_addr32[2] | | 264 | addr->s6_addr32[1] | addr->s6_addr32[2] | |
246 | (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0); | 265 | (addr->s6_addr32[3] ^ htonl(0x00000001))) == 0; |
247 | } | 266 | } |
248 | 267 | ||
249 | static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) | 268 | static inline int ipv6_addr_is_ll_all_routers(const struct in6_addr *addr) |
250 | { | 269 | { |
251 | return (((addr->s6_addr32[0] ^ htonl(0xff020000)) | | 270 | return ((addr->s6_addr32[0] ^ htonl(0xff020000)) | |
252 | addr->s6_addr32[1] | addr->s6_addr32[2] | | 271 | addr->s6_addr32[1] | addr->s6_addr32[2] | |
253 | (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0); | 272 | (addr->s6_addr32[3] ^ htonl(0x00000002))) == 0; |
254 | } | 273 | } |
255 | 274 | ||
256 | extern int __ipv6_isatap_ifid(u8 *eui, __be32 addr); | ||
257 | |||
258 | static inline int ipv6_addr_is_isatap(const struct in6_addr *addr) | 275 | static inline int ipv6_addr_is_isatap(const struct in6_addr *addr) |
259 | { | 276 | { |
260 | return ((addr->s6_addr32[2] | htonl(0x02000000)) == htonl(0x02005EFE)); | 277 | return (addr->s6_addr32[2] | htonl(0x02000000)) == htonl(0x02005EFE); |
261 | } | 278 | } |
262 | 279 | ||
263 | #ifdef CONFIG_PROC_FS | 280 | #ifdef CONFIG_PROC_FS |
@@ -266,4 +283,3 @@ extern void if6_proc_exit(void); | |||
266 | #endif | 283 | #endif |
267 | 284 | ||
268 | #endif | 285 | #endif |
269 | #endif | ||
diff --git a/include/net/af_rxrpc.h b/include/net/af_rxrpc.h index 00c2eaa07c25..03e6e9453623 100644 --- a/include/net/af_rxrpc.h +++ b/include/net/af_rxrpc.h | |||
@@ -12,8 +12,6 @@ | |||
12 | #ifndef _NET_RXRPC_H | 12 | #ifndef _NET_RXRPC_H |
13 | #define _NET_RXRPC_H | 13 | #define _NET_RXRPC_H |
14 | 14 | ||
15 | #ifdef __KERNEL__ | ||
16 | |||
17 | #include <linux/rxrpc.h> | 15 | #include <linux/rxrpc.h> |
18 | 16 | ||
19 | struct rxrpc_call; | 17 | struct rxrpc_call; |
@@ -53,5 +51,4 @@ extern struct rxrpc_call *rxrpc_kernel_accept_call(struct socket *, | |||
53 | unsigned long); | 51 | unsigned long); |
54 | extern int rxrpc_kernel_reject_call(struct socket *); | 52 | extern int rxrpc_kernel_reject_call(struct socket *); |
55 | 53 | ||
56 | #endif /* __KERNEL__ */ | ||
57 | #endif /* _NET_RXRPC_H */ | 54 | #endif /* _NET_RXRPC_H */ |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 90c9e2872f27..91ab5b01678a 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -10,6 +10,7 @@ extern void unix_inflight(struct file *fp); | |||
10 | extern void unix_notinflight(struct file *fp); | 10 | extern void unix_notinflight(struct file *fp); |
11 | extern void unix_gc(void); | 11 | extern void unix_gc(void); |
12 | extern void wait_for_unix_gc(void); | 12 | extern void wait_for_unix_gc(void); |
13 | extern struct sock *unix_get_socket(struct file *filp); | ||
13 | 14 | ||
14 | #define UNIX_HASH_SIZE 256 | 15 | #define UNIX_HASH_SIZE 256 |
15 | 16 | ||
@@ -40,7 +41,6 @@ struct unix_skb_parms { | |||
40 | spin_lock_nested(&unix_sk(s)->lock, \ | 41 | spin_lock_nested(&unix_sk(s)->lock, \ |
41 | SINGLE_DEPTH_NESTING) | 42 | SINGLE_DEPTH_NESTING) |
42 | 43 | ||
43 | #ifdef __KERNEL__ | ||
44 | /* The AF_UNIX socket */ | 44 | /* The AF_UNIX socket */ |
45 | struct unix_sock { | 45 | struct unix_sock { |
46 | /* WARNING: sk has to be the first member */ | 46 | /* WARNING: sk has to be the first member */ |
@@ -56,6 +56,7 @@ struct unix_sock { | |||
56 | spinlock_t lock; | 56 | spinlock_t lock; |
57 | unsigned int gc_candidate : 1; | 57 | unsigned int gc_candidate : 1; |
58 | unsigned int gc_maybe_cycle : 1; | 58 | unsigned int gc_maybe_cycle : 1; |
59 | unsigned char recursion_level; | ||
59 | struct socket_wq peer_wq; | 60 | struct socket_wq peer_wq; |
60 | }; | 61 | }; |
61 | #define unix_sk(__sk) ((struct unix_sock *)__sk) | 62 | #define unix_sk(__sk) ((struct unix_sock *)__sk) |
@@ -70,4 +71,3 @@ static inline int unix_sysctl_register(struct net *net) { return 0; } | |||
70 | static inline void unix_sysctl_unregister(struct net *net) {} | 71 | static inline void unix_sysctl_unregister(struct net *net) {} |
71 | #endif | 72 | #endif |
72 | #endif | 73 | #endif |
73 | #endif | ||
diff --git a/include/net/ah.h b/include/net/ah.h index f0129f79a31a..ca95b98969dd 100644 --- a/include/net/ah.h +++ b/include/net/ah.h | |||
@@ -4,7 +4,7 @@ | |||
4 | #include <linux/skbuff.h> | 4 | #include <linux/skbuff.h> |
5 | 5 | ||
6 | /* This is the maximum truncated ICV length that we know of. */ | 6 | /* This is the maximum truncated ICV length that we know of. */ |
7 | #define MAX_AH_AUTH_LEN 12 | 7 | #define MAX_AH_AUTH_LEN 64 |
8 | 8 | ||
9 | struct crypto_ahash; | 9 | struct crypto_ahash; |
10 | 10 | ||
diff --git a/include/net/arp.h b/include/net/arp.h index 716f43c5c98e..91f0568a04ef 100644 --- a/include/net/arp.h +++ b/include/net/arp.h | |||
@@ -25,7 +25,6 @@ extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip, | |||
25 | const unsigned char *src_hw, | 25 | const unsigned char *src_hw, |
26 | const unsigned char *target_hw); | 26 | const unsigned char *target_hw); |
27 | extern void arp_xmit(struct sk_buff *skb); | 27 | extern void arp_xmit(struct sk_buff *skb); |
28 | 28 | int arp_invalidate(struct net_device *dev, __be32 ip); | |
29 | extern const struct neigh_ops arp_broken_ops; | ||
30 | 29 | ||
31 | #endif /* _ARP_H */ | 30 | #endif /* _ARP_H */ |
diff --git a/include/net/atmclip.h b/include/net/atmclip.h index 467c531b8a7e..497ef6444a7a 100644 --- a/include/net/atmclip.h +++ b/include/net/atmclip.h | |||
@@ -54,8 +54,6 @@ struct clip_priv { | |||
54 | }; | 54 | }; |
55 | 55 | ||
56 | 56 | ||
57 | #ifdef __KERNEL__ | ||
58 | extern struct neigh_table *clip_tbl_hook; | 57 | extern struct neigh_table *clip_tbl_hook; |
59 | #endif | ||
60 | 58 | ||
61 | #endif | 59 | #endif |
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 30fce0128dd7..43750439c521 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h | |||
@@ -64,6 +64,11 @@ struct bt_security { | |||
64 | 64 | ||
65 | #define BT_DEFER_SETUP 7 | 65 | #define BT_DEFER_SETUP 7 |
66 | 66 | ||
67 | #define BT_FLUSHABLE 8 | ||
68 | |||
69 | #define BT_FLUSHABLE_OFF 0 | ||
70 | #define BT_FLUSHABLE_ON 1 | ||
71 | |||
67 | #define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg) | 72 | #define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg) |
68 | #define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg) | 73 | #define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg) |
69 | #define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg) | 74 | #define BT_DBG(fmt, arg...) pr_debug("%s: " fmt "\n" , __func__ , ## arg) |
@@ -126,6 +131,8 @@ int bt_sock_unregister(int proto); | |||
126 | void bt_sock_link(struct bt_sock_list *l, struct sock *s); | 131 | void bt_sock_link(struct bt_sock_list *l, struct sock *s); |
127 | void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); | 132 | void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); |
128 | int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags); | 133 | int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t len, int flags); |
134 | int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | ||
135 | struct msghdr *msg, size_t len, int flags); | ||
129 | uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); | 136 | uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); |
130 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); | 137 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); |
131 | int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); | 138 | int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); |
@@ -142,6 +149,7 @@ struct bt_skb_cb { | |||
142 | __u8 tx_seq; | 149 | __u8 tx_seq; |
143 | __u8 retries; | 150 | __u8 retries; |
144 | __u8 sar; | 151 | __u8 sar; |
152 | unsigned short channel; | ||
145 | }; | 153 | }; |
146 | #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) | 154 | #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) |
147 | 155 | ||
@@ -197,4 +205,32 @@ extern void bt_sysfs_cleanup(void); | |||
197 | 205 | ||
198 | extern struct dentry *bt_debugfs; | 206 | extern struct dentry *bt_debugfs; |
199 | 207 | ||
208 | #ifdef CONFIG_BT_L2CAP | ||
209 | int l2cap_init(void); | ||
210 | void l2cap_exit(void); | ||
211 | #else | ||
212 | static inline int l2cap_init(void) | ||
213 | { | ||
214 | return 0; | ||
215 | } | ||
216 | |||
217 | static inline void l2cap_exit(void) | ||
218 | { | ||
219 | } | ||
220 | #endif | ||
221 | |||
222 | #ifdef CONFIG_BT_SCO | ||
223 | int sco_init(void); | ||
224 | void sco_exit(void); | ||
225 | #else | ||
226 | static inline int sco_init(void) | ||
227 | { | ||
228 | return 0; | ||
229 | } | ||
230 | |||
231 | static inline void sco_exit(void) | ||
232 | { | ||
233 | } | ||
234 | #endif | ||
235 | |||
200 | #endif /* __BLUETOOTH_H */ | 236 | #endif /* __BLUETOOTH_H */ |
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index bcbdd6d4e6dd..0c20227e57f6 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | 3 | Copyright (C) 2000-2001 Qualcomm Incorporated |
4 | 4 | ||
@@ -12,13 +12,13 @@ | |||
12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | 14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | 15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
19 | 19 | ||
20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | 20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | 21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
22 | SOFTWARE IS DISCLAIMED. | 22 | SOFTWARE IS DISCLAIMED. |
23 | */ | 23 | */ |
24 | 24 | ||
@@ -54,7 +54,7 @@ | |||
54 | 54 | ||
55 | /* HCI controller types */ | 55 | /* HCI controller types */ |
56 | #define HCI_BREDR 0x00 | 56 | #define HCI_BREDR 0x00 |
57 | #define HCI_80211 0x01 | 57 | #define HCI_AMP 0x01 |
58 | 58 | ||
59 | /* HCI device quirks */ | 59 | /* HCI device quirks */ |
60 | enum { | 60 | enum { |
@@ -76,6 +76,16 @@ enum { | |||
76 | HCI_INQUIRY, | 76 | HCI_INQUIRY, |
77 | 77 | ||
78 | HCI_RAW, | 78 | HCI_RAW, |
79 | |||
80 | HCI_SETUP, | ||
81 | HCI_AUTO_OFF, | ||
82 | HCI_MGMT, | ||
83 | HCI_PAIRABLE, | ||
84 | HCI_SERVICE_CACHE, | ||
85 | HCI_LINK_KEYS, | ||
86 | HCI_DEBUG_KEYS, | ||
87 | |||
88 | HCI_RESET, | ||
79 | }; | 89 | }; |
80 | 90 | ||
81 | /* HCI ioctl defines */ | 91 | /* HCI ioctl defines */ |
@@ -111,6 +121,7 @@ enum { | |||
111 | #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ | 121 | #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ |
112 | #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ | 122 | #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ |
113 | #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ | 123 | #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ |
124 | #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */ | ||
114 | 125 | ||
115 | /* HCI data types */ | 126 | /* HCI data types */ |
116 | #define HCI_COMMAND_PKT 0x01 | 127 | #define HCI_COMMAND_PKT 0x01 |
@@ -150,6 +161,7 @@ enum { | |||
150 | #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) | 161 | #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) |
151 | 162 | ||
152 | /* ACL flags */ | 163 | /* ACL flags */ |
164 | #define ACL_START_NO_FLUSH 0x00 | ||
153 | #define ACL_CONT 0x01 | 165 | #define ACL_CONT 0x01 |
154 | #define ACL_START 0x02 | 166 | #define ACL_START 0x02 |
155 | #define ACL_ACTIVE_BCAST 0x04 | 167 | #define ACL_ACTIVE_BCAST 0x04 |
@@ -159,6 +171,8 @@ enum { | |||
159 | #define SCO_LINK 0x00 | 171 | #define SCO_LINK 0x00 |
160 | #define ACL_LINK 0x01 | 172 | #define ACL_LINK 0x01 |
161 | #define ESCO_LINK 0x02 | 173 | #define ESCO_LINK 0x02 |
174 | /* Low Energy links do not have defined link type. Use invented one */ | ||
175 | #define LE_LINK 0x80 | ||
162 | 176 | ||
163 | /* LMP features */ | 177 | /* LMP features */ |
164 | #define LMP_3SLOT 0x01 | 178 | #define LMP_3SLOT 0x01 |
@@ -183,17 +197,25 @@ enum { | |||
183 | #define LMP_PSCHEME 0x02 | 197 | #define LMP_PSCHEME 0x02 |
184 | #define LMP_PCONTROL 0x04 | 198 | #define LMP_PCONTROL 0x04 |
185 | 199 | ||
200 | #define LMP_RSSI_INQ 0x40 | ||
186 | #define LMP_ESCO 0x80 | 201 | #define LMP_ESCO 0x80 |
187 | 202 | ||
188 | #define LMP_EV4 0x01 | 203 | #define LMP_EV4 0x01 |
189 | #define LMP_EV5 0x02 | 204 | #define LMP_EV5 0x02 |
205 | #define LMP_LE 0x40 | ||
190 | 206 | ||
191 | #define LMP_SNIFF_SUBR 0x02 | 207 | #define LMP_SNIFF_SUBR 0x02 |
208 | #define LMP_PAUSE_ENC 0x04 | ||
192 | #define LMP_EDR_ESCO_2M 0x20 | 209 | #define LMP_EDR_ESCO_2M 0x20 |
193 | #define LMP_EDR_ESCO_3M 0x40 | 210 | #define LMP_EDR_ESCO_3M 0x40 |
194 | #define LMP_EDR_3S_ESCO 0x80 | 211 | #define LMP_EDR_3S_ESCO 0x80 |
195 | 212 | ||
213 | #define LMP_EXT_INQ 0x01 | ||
196 | #define LMP_SIMPLE_PAIR 0x08 | 214 | #define LMP_SIMPLE_PAIR 0x08 |
215 | #define LMP_NO_FLUSH 0x40 | ||
216 | |||
217 | #define LMP_LSTO 0x01 | ||
218 | #define LMP_INQ_TX_PWR 0x02 | ||
197 | 219 | ||
198 | /* Connection modes */ | 220 | /* Connection modes */ |
199 | #define HCI_CM_ACTIVE 0x0000 | 221 | #define HCI_CM_ACTIVE 0x0000 |
@@ -224,7 +246,18 @@ enum { | |||
224 | #define HCI_AT_GENERAL_BONDING 0x04 | 246 | #define HCI_AT_GENERAL_BONDING 0x04 |
225 | #define HCI_AT_GENERAL_BONDING_MITM 0x05 | 247 | #define HCI_AT_GENERAL_BONDING_MITM 0x05 |
226 | 248 | ||
249 | /* Link Key types */ | ||
250 | #define HCI_LK_COMBINATION 0x00 | ||
251 | #define HCI_LK_LOCAL_UNIT 0x01 | ||
252 | #define HCI_LK_REMOTE_UNIT 0x02 | ||
253 | #define HCI_LK_DEBUG_COMBINATION 0x03 | ||
254 | #define HCI_LK_UNAUTH_COMBINATION 0x04 | ||
255 | #define HCI_LK_AUTH_COMBINATION 0x05 | ||
256 | #define HCI_LK_CHANGED_COMBINATION 0x06 | ||
257 | |||
227 | /* ----- HCI Commands ---- */ | 258 | /* ----- HCI Commands ---- */ |
259 | #define HCI_OP_NOP 0x0000 | ||
260 | |||
228 | #define HCI_OP_INQUIRY 0x0401 | 261 | #define HCI_OP_INQUIRY 0x0401 |
229 | struct hci_cp_inquiry { | 262 | struct hci_cp_inquiry { |
230 | __u8 lap[3]; | 263 | __u8 lap[3]; |
@@ -292,11 +325,19 @@ struct hci_cp_pin_code_reply { | |||
292 | __u8 pin_len; | 325 | __u8 pin_len; |
293 | __u8 pin_code[16]; | 326 | __u8 pin_code[16]; |
294 | } __packed; | 327 | } __packed; |
328 | struct hci_rp_pin_code_reply { | ||
329 | __u8 status; | ||
330 | bdaddr_t bdaddr; | ||
331 | } __packed; | ||
295 | 332 | ||
296 | #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e | 333 | #define HCI_OP_PIN_CODE_NEG_REPLY 0x040e |
297 | struct hci_cp_pin_code_neg_reply { | 334 | struct hci_cp_pin_code_neg_reply { |
298 | bdaddr_t bdaddr; | 335 | bdaddr_t bdaddr; |
299 | } __packed; | 336 | } __packed; |
337 | struct hci_rp_pin_code_neg_reply { | ||
338 | __u8 status; | ||
339 | bdaddr_t bdaddr; | ||
340 | } __packed; | ||
300 | 341 | ||
301 | #define HCI_OP_CHANGE_CONN_PTYPE 0x040f | 342 | #define HCI_OP_CHANGE_CONN_PTYPE 0x040f |
302 | struct hci_cp_change_conn_ptype { | 343 | struct hci_cp_change_conn_ptype { |
@@ -377,6 +418,43 @@ struct hci_cp_reject_sync_conn_req { | |||
377 | __u8 reason; | 418 | __u8 reason; |
378 | } __packed; | 419 | } __packed; |
379 | 420 | ||
421 | #define HCI_OP_IO_CAPABILITY_REPLY 0x042b | ||
422 | struct hci_cp_io_capability_reply { | ||
423 | bdaddr_t bdaddr; | ||
424 | __u8 capability; | ||
425 | __u8 oob_data; | ||
426 | __u8 authentication; | ||
427 | } __packed; | ||
428 | |||
429 | #define HCI_OP_USER_CONFIRM_REPLY 0x042c | ||
430 | struct hci_cp_user_confirm_reply { | ||
431 | bdaddr_t bdaddr; | ||
432 | } __packed; | ||
433 | struct hci_rp_user_confirm_reply { | ||
434 | __u8 status; | ||
435 | bdaddr_t bdaddr; | ||
436 | } __packed; | ||
437 | |||
438 | #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d | ||
439 | |||
440 | #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430 | ||
441 | struct hci_cp_remote_oob_data_reply { | ||
442 | bdaddr_t bdaddr; | ||
443 | __u8 hash[16]; | ||
444 | __u8 randomizer[16]; | ||
445 | } __packed; | ||
446 | |||
447 | #define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433 | ||
448 | struct hci_cp_remote_oob_data_neg_reply { | ||
449 | bdaddr_t bdaddr; | ||
450 | } __packed; | ||
451 | |||
452 | #define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434 | ||
453 | struct hci_cp_io_capability_neg_reply { | ||
454 | bdaddr_t bdaddr; | ||
455 | __u8 reason; | ||
456 | } __packed; | ||
457 | |||
380 | #define HCI_OP_SNIFF_MODE 0x0803 | 458 | #define HCI_OP_SNIFF_MODE 0x0803 |
381 | struct hci_cp_sniff_mode { | 459 | struct hci_cp_sniff_mode { |
382 | __le16 handle; | 460 | __le16 handle; |
@@ -474,22 +552,30 @@ struct hci_cp_set_event_flt { | |||
474 | #define HCI_CONN_SETUP_AUTO_OFF 0x01 | 552 | #define HCI_CONN_SETUP_AUTO_OFF 0x01 |
475 | #define HCI_CONN_SETUP_AUTO_ON 0x02 | 553 | #define HCI_CONN_SETUP_AUTO_ON 0x02 |
476 | 554 | ||
555 | #define HCI_OP_DELETE_STORED_LINK_KEY 0x0c12 | ||
556 | struct hci_cp_delete_stored_link_key { | ||
557 | bdaddr_t bdaddr; | ||
558 | __u8 delete_all; | ||
559 | } __packed; | ||
560 | |||
561 | #define HCI_MAX_NAME_LENGTH 248 | ||
562 | |||
477 | #define HCI_OP_WRITE_LOCAL_NAME 0x0c13 | 563 | #define HCI_OP_WRITE_LOCAL_NAME 0x0c13 |
478 | struct hci_cp_write_local_name { | 564 | struct hci_cp_write_local_name { |
479 | __u8 name[248]; | 565 | __u8 name[HCI_MAX_NAME_LENGTH]; |
480 | } __packed; | 566 | } __packed; |
481 | 567 | ||
482 | #define HCI_OP_READ_LOCAL_NAME 0x0c14 | 568 | #define HCI_OP_READ_LOCAL_NAME 0x0c14 |
483 | struct hci_rp_read_local_name { | 569 | struct hci_rp_read_local_name { |
484 | __u8 status; | 570 | __u8 status; |
485 | __u8 name[248]; | 571 | __u8 name[HCI_MAX_NAME_LENGTH]; |
486 | } __packed; | 572 | } __packed; |
487 | 573 | ||
488 | #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16 | 574 | #define HCI_OP_WRITE_CA_TIMEOUT 0x0c16 |
489 | 575 | ||
490 | #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18 | 576 | #define HCI_OP_WRITE_PG_TIMEOUT 0x0c18 |
491 | 577 | ||
492 | #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a | 578 | #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a |
493 | #define SCAN_DISABLED 0x00 | 579 | #define SCAN_DISABLED 0x00 |
494 | #define SCAN_INQUIRY 0x01 | 580 | #define SCAN_INQUIRY 0x01 |
495 | #define SCAN_PAGE 0x02 | 581 | #define SCAN_PAGE 0x02 |
@@ -537,6 +623,16 @@ struct hci_cp_host_buffer_size { | |||
537 | __le16 sco_max_pkt; | 623 | __le16 sco_max_pkt; |
538 | } __packed; | 624 | } __packed; |
539 | 625 | ||
626 | #define HCI_OP_WRITE_INQUIRY_MODE 0x0c45 | ||
627 | |||
628 | #define HCI_MAX_EIR_LENGTH 240 | ||
629 | |||
630 | #define HCI_OP_WRITE_EIR 0x0c52 | ||
631 | struct hci_cp_write_eir { | ||
632 | uint8_t fec; | ||
633 | uint8_t data[HCI_MAX_EIR_LENGTH]; | ||
634 | } __packed; | ||
635 | |||
540 | #define HCI_OP_READ_SSP_MODE 0x0c55 | 636 | #define HCI_OP_READ_SSP_MODE 0x0c55 |
541 | struct hci_rp_read_ssp_mode { | 637 | struct hci_rp_read_ssp_mode { |
542 | __u8 status; | 638 | __u8 status; |
@@ -548,6 +644,15 @@ struct hci_cp_write_ssp_mode { | |||
548 | __u8 mode; | 644 | __u8 mode; |
549 | } __packed; | 645 | } __packed; |
550 | 646 | ||
647 | #define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57 | ||
648 | struct hci_rp_read_local_oob_data { | ||
649 | __u8 status; | ||
650 | __u8 hash[16]; | ||
651 | __u8 randomizer[16]; | ||
652 | } __packed; | ||
653 | |||
654 | #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58 | ||
655 | |||
551 | #define HCI_OP_READ_LOCAL_VERSION 0x1001 | 656 | #define HCI_OP_READ_LOCAL_VERSION 0x1001 |
552 | struct hci_rp_read_local_version { | 657 | struct hci_rp_read_local_version { |
553 | __u8 status; | 658 | __u8 status; |
@@ -593,6 +698,47 @@ struct hci_rp_read_bd_addr { | |||
593 | bdaddr_t bdaddr; | 698 | bdaddr_t bdaddr; |
594 | } __packed; | 699 | } __packed; |
595 | 700 | ||
701 | #define HCI_OP_LE_SET_EVENT_MASK 0x2001 | ||
702 | struct hci_cp_le_set_event_mask { | ||
703 | __u8 mask[8]; | ||
704 | } __packed; | ||
705 | |||
706 | #define HCI_OP_LE_READ_BUFFER_SIZE 0x2002 | ||
707 | struct hci_rp_le_read_buffer_size { | ||
708 | __u8 status; | ||
709 | __le16 le_mtu; | ||
710 | __u8 le_max_pkt; | ||
711 | } __packed; | ||
712 | |||
713 | #define HCI_OP_LE_CREATE_CONN 0x200d | ||
714 | struct hci_cp_le_create_conn { | ||
715 | __le16 scan_interval; | ||
716 | __le16 scan_window; | ||
717 | __u8 filter_policy; | ||
718 | __u8 peer_addr_type; | ||
719 | bdaddr_t peer_addr; | ||
720 | __u8 own_address_type; | ||
721 | __le16 conn_interval_min; | ||
722 | __le16 conn_interval_max; | ||
723 | __le16 conn_latency; | ||
724 | __le16 supervision_timeout; | ||
725 | __le16 min_ce_len; | ||
726 | __le16 max_ce_len; | ||
727 | } __packed; | ||
728 | |||
729 | #define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e | ||
730 | |||
731 | #define HCI_OP_LE_CONN_UPDATE 0x2013 | ||
732 | struct hci_cp_le_conn_update { | ||
733 | __le16 handle; | ||
734 | __le16 conn_interval_min; | ||
735 | __le16 conn_interval_max; | ||
736 | __le16 conn_latency; | ||
737 | __le16 supervision_timeout; | ||
738 | __le16 min_ce_len; | ||
739 | __le16 max_ce_len; | ||
740 | } __packed; | ||
741 | |||
596 | /* ---- HCI Events ---- */ | 742 | /* ---- HCI Events ---- */ |
597 | #define HCI_EV_INQUIRY_COMPLETE 0x01 | 743 | #define HCI_EV_INQUIRY_COMPLETE 0x01 |
598 | 744 | ||
@@ -639,7 +785,7 @@ struct hci_ev_auth_complete { | |||
639 | struct hci_ev_remote_name { | 785 | struct hci_ev_remote_name { |
640 | __u8 status; | 786 | __u8 status; |
641 | bdaddr_t bdaddr; | 787 | bdaddr_t bdaddr; |
642 | __u8 name[248]; | 788 | __u8 name[HCI_MAX_NAME_LENGTH]; |
643 | } __packed; | 789 | } __packed; |
644 | 790 | ||
645 | #define HCI_EV_ENCRYPT_CHANGE 0x08 | 791 | #define HCI_EV_ENCRYPT_CHANGE 0x08 |
@@ -833,6 +979,25 @@ struct hci_ev_io_capa_request { | |||
833 | bdaddr_t bdaddr; | 979 | bdaddr_t bdaddr; |
834 | } __packed; | 980 | } __packed; |
835 | 981 | ||
982 | #define HCI_EV_IO_CAPA_REPLY 0x32 | ||
983 | struct hci_ev_io_capa_reply { | ||
984 | bdaddr_t bdaddr; | ||
985 | __u8 capability; | ||
986 | __u8 oob_data; | ||
987 | __u8 authentication; | ||
988 | } __packed; | ||
989 | |||
990 | #define HCI_EV_USER_CONFIRM_REQUEST 0x33 | ||
991 | struct hci_ev_user_confirm_req { | ||
992 | bdaddr_t bdaddr; | ||
993 | __le32 passkey; | ||
994 | } __packed; | ||
995 | |||
996 | #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35 | ||
997 | struct hci_ev_remote_oob_data_request { | ||
998 | bdaddr_t bdaddr; | ||
999 | } __packed; | ||
1000 | |||
836 | #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36 | 1001 | #define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36 |
837 | struct hci_ev_simple_pair_complete { | 1002 | struct hci_ev_simple_pair_complete { |
838 | __u8 status; | 1003 | __u8 status; |
@@ -845,6 +1010,25 @@ struct hci_ev_remote_host_features { | |||
845 | __u8 features[8]; | 1010 | __u8 features[8]; |
846 | } __packed; | 1011 | } __packed; |
847 | 1012 | ||
1013 | #define HCI_EV_LE_META 0x3e | ||
1014 | struct hci_ev_le_meta { | ||
1015 | __u8 subevent; | ||
1016 | } __packed; | ||
1017 | |||
1018 | /* Low energy meta events */ | ||
1019 | #define HCI_EV_LE_CONN_COMPLETE 0x01 | ||
1020 | struct hci_ev_le_conn_complete { | ||
1021 | __u8 status; | ||
1022 | __le16 handle; | ||
1023 | __u8 role; | ||
1024 | __u8 bdaddr_type; | ||
1025 | bdaddr_t bdaddr; | ||
1026 | __le16 interval; | ||
1027 | __le16 latency; | ||
1028 | __le16 supervision_timeout; | ||
1029 | __u8 clk_accurancy; | ||
1030 | } __packed; | ||
1031 | |||
848 | /* Internal events generated by Bluetooth stack */ | 1032 | /* Internal events generated by Bluetooth stack */ |
849 | #define HCI_EV_STACK_INTERNAL 0xfd | 1033 | #define HCI_EV_STACK_INTERNAL 0xfd |
850 | struct hci_ev_stack_internal { | 1034 | struct hci_ev_stack_internal { |
@@ -874,7 +1058,7 @@ struct hci_ev_si_security { | |||
874 | 1058 | ||
875 | struct hci_command_hdr { | 1059 | struct hci_command_hdr { |
876 | __le16 opcode; /* OCF & OGF */ | 1060 | __le16 opcode; /* OCF & OGF */ |
877 | __u8 plen; | 1061 | __u8 plen; |
878 | } __packed; | 1062 | } __packed; |
879 | 1063 | ||
880 | struct hci_event_hdr { | 1064 | struct hci_event_hdr { |
@@ -892,7 +1076,6 @@ struct hci_sco_hdr { | |||
892 | __u8 dlen; | 1076 | __u8 dlen; |
893 | } __packed; | 1077 | } __packed; |
894 | 1078 | ||
895 | #ifdef __KERNEL__ | ||
896 | #include <linux/skbuff.h> | 1079 | #include <linux/skbuff.h> |
897 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) | 1080 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) |
898 | { | 1081 | { |
@@ -908,7 +1091,6 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) | |||
908 | { | 1091 | { |
909 | return (struct hci_sco_hdr *) skb->data; | 1092 | return (struct hci_sco_hdr *) skb->data; |
910 | } | 1093 | } |
911 | #endif | ||
912 | 1094 | ||
913 | /* Command opcode pack/unpack */ | 1095 | /* Command opcode pack/unpack */ |
914 | #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) | 1096 | #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) |
@@ -934,9 +1116,13 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) | |||
934 | struct sockaddr_hci { | 1116 | struct sockaddr_hci { |
935 | sa_family_t hci_family; | 1117 | sa_family_t hci_family; |
936 | unsigned short hci_dev; | 1118 | unsigned short hci_dev; |
1119 | unsigned short hci_channel; | ||
937 | }; | 1120 | }; |
938 | #define HCI_DEV_NONE 0xffff | 1121 | #define HCI_DEV_NONE 0xffff |
939 | 1122 | ||
1123 | #define HCI_CHANNEL_RAW 0 | ||
1124 | #define HCI_CHANNEL_CONTROL 1 | ||
1125 | |||
940 | struct hci_filter { | 1126 | struct hci_filter { |
941 | unsigned long type_mask; | 1127 | unsigned long type_mask; |
942 | unsigned long event_mask[2]; | 1128 | unsigned long event_mask[2]; |
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 4568b938ca35..6c994c004d15 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -44,15 +44,15 @@ struct inquiry_data { | |||
44 | }; | 44 | }; |
45 | 45 | ||
46 | struct inquiry_entry { | 46 | struct inquiry_entry { |
47 | struct inquiry_entry *next; | 47 | struct inquiry_entry *next; |
48 | __u32 timestamp; | 48 | __u32 timestamp; |
49 | struct inquiry_data data; | 49 | struct inquiry_data data; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | struct inquiry_cache { | 52 | struct inquiry_cache { |
53 | spinlock_t lock; | 53 | spinlock_t lock; |
54 | __u32 timestamp; | 54 | __u32 timestamp; |
55 | struct inquiry_entry *list; | 55 | struct inquiry_entry *list; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | struct hci_conn_hash { | 58 | struct hci_conn_hash { |
@@ -60,12 +60,35 @@ struct hci_conn_hash { | |||
60 | spinlock_t lock; | 60 | spinlock_t lock; |
61 | unsigned int acl_num; | 61 | unsigned int acl_num; |
62 | unsigned int sco_num; | 62 | unsigned int sco_num; |
63 | unsigned int le_num; | ||
63 | }; | 64 | }; |
64 | 65 | ||
65 | struct bdaddr_list { | 66 | struct bdaddr_list { |
66 | struct list_head list; | 67 | struct list_head list; |
67 | bdaddr_t bdaddr; | 68 | bdaddr_t bdaddr; |
68 | }; | 69 | }; |
70 | |||
71 | struct bt_uuid { | ||
72 | struct list_head list; | ||
73 | u8 uuid[16]; | ||
74 | u8 svc_hint; | ||
75 | }; | ||
76 | |||
77 | struct link_key { | ||
78 | struct list_head list; | ||
79 | bdaddr_t bdaddr; | ||
80 | u8 type; | ||
81 | u8 val[16]; | ||
82 | u8 pin_len; | ||
83 | }; | ||
84 | |||
85 | struct oob_data { | ||
86 | struct list_head list; | ||
87 | bdaddr_t bdaddr; | ||
88 | u8 hash[16]; | ||
89 | u8 randomizer[16]; | ||
90 | }; | ||
91 | |||
69 | #define NUM_REASSEMBLY 4 | 92 | #define NUM_REASSEMBLY 4 |
70 | struct hci_dev { | 93 | struct hci_dev { |
71 | struct list_head list; | 94 | struct list_head list; |
@@ -78,15 +101,21 @@ struct hci_dev { | |||
78 | __u8 bus; | 101 | __u8 bus; |
79 | __u8 dev_type; | 102 | __u8 dev_type; |
80 | bdaddr_t bdaddr; | 103 | bdaddr_t bdaddr; |
81 | __u8 dev_name[248]; | 104 | __u8 dev_name[HCI_MAX_NAME_LENGTH]; |
105 | __u8 eir[HCI_MAX_EIR_LENGTH]; | ||
82 | __u8 dev_class[3]; | 106 | __u8 dev_class[3]; |
107 | __u8 major_class; | ||
108 | __u8 minor_class; | ||
83 | __u8 features[8]; | 109 | __u8 features[8]; |
84 | __u8 commands[64]; | 110 | __u8 commands[64]; |
85 | __u8 ssp_mode; | 111 | __u8 ssp_mode; |
86 | __u8 hci_ver; | 112 | __u8 hci_ver; |
87 | __u16 hci_rev; | 113 | __u16 hci_rev; |
114 | __u8 lmp_ver; | ||
88 | __u16 manufacturer; | 115 | __u16 manufacturer; |
116 | __le16 lmp_subver; | ||
89 | __u16 voice_setting; | 117 | __u16 voice_setting; |
118 | __u8 io_capability; | ||
90 | 119 | ||
91 | __u16 pkt_type; | 120 | __u16 pkt_type; |
92 | __u16 esco_type; | 121 | __u16 esco_type; |
@@ -97,23 +126,33 @@ struct hci_dev { | |||
97 | __u16 sniff_min_interval; | 126 | __u16 sniff_min_interval; |
98 | __u16 sniff_max_interval; | 127 | __u16 sniff_max_interval; |
99 | 128 | ||
129 | unsigned int auto_accept_delay; | ||
130 | |||
100 | unsigned long quirks; | 131 | unsigned long quirks; |
101 | 132 | ||
102 | atomic_t cmd_cnt; | 133 | atomic_t cmd_cnt; |
103 | unsigned int acl_cnt; | 134 | unsigned int acl_cnt; |
104 | unsigned int sco_cnt; | 135 | unsigned int sco_cnt; |
136 | unsigned int le_cnt; | ||
105 | 137 | ||
106 | unsigned int acl_mtu; | 138 | unsigned int acl_mtu; |
107 | unsigned int sco_mtu; | 139 | unsigned int sco_mtu; |
140 | unsigned int le_mtu; | ||
108 | unsigned int acl_pkts; | 141 | unsigned int acl_pkts; |
109 | unsigned int sco_pkts; | 142 | unsigned int sco_pkts; |
143 | unsigned int le_pkts; | ||
110 | 144 | ||
111 | unsigned long cmd_last_tx; | ||
112 | unsigned long acl_last_tx; | 145 | unsigned long acl_last_tx; |
113 | unsigned long sco_last_tx; | 146 | unsigned long sco_last_tx; |
147 | unsigned long le_last_tx; | ||
114 | 148 | ||
115 | struct workqueue_struct *workqueue; | 149 | struct workqueue_struct *workqueue; |
116 | 150 | ||
151 | struct work_struct power_on; | ||
152 | struct work_struct power_off; | ||
153 | struct timer_list off_timer; | ||
154 | |||
155 | struct timer_list cmd_timer; | ||
117 | struct tasklet_struct cmd_task; | 156 | struct tasklet_struct cmd_task; |
118 | struct tasklet_struct rx_task; | 157 | struct tasklet_struct rx_task; |
119 | struct tasklet_struct tx_task; | 158 | struct tasklet_struct tx_task; |
@@ -130,10 +169,18 @@ struct hci_dev { | |||
130 | __u32 req_status; | 169 | __u32 req_status; |
131 | __u32 req_result; | 170 | __u32 req_result; |
132 | 171 | ||
172 | __u16 init_last_cmd; | ||
173 | |||
133 | struct inquiry_cache inq_cache; | 174 | struct inquiry_cache inq_cache; |
134 | struct hci_conn_hash conn_hash; | 175 | struct hci_conn_hash conn_hash; |
135 | struct list_head blacklist; | 176 | struct list_head blacklist; |
136 | 177 | ||
178 | struct list_head uuids; | ||
179 | |||
180 | struct list_head link_keys; | ||
181 | |||
182 | struct list_head remote_oob_data; | ||
183 | |||
137 | struct hci_dev_stats stat; | 184 | struct hci_dev_stats stat; |
138 | 185 | ||
139 | struct sk_buff_head driver_init; | 186 | struct sk_buff_head driver_init; |
@@ -141,7 +188,7 @@ struct hci_dev { | |||
141 | void *driver_data; | 188 | void *driver_data; |
142 | void *core_data; | 189 | void *core_data; |
143 | 190 | ||
144 | atomic_t promisc; | 191 | atomic_t promisc; |
145 | 192 | ||
146 | struct dentry *debugfs; | 193 | struct dentry *debugfs; |
147 | 194 | ||
@@ -150,7 +197,7 @@ struct hci_dev { | |||
150 | 197 | ||
151 | struct rfkill *rfkill; | 198 | struct rfkill *rfkill; |
152 | 199 | ||
153 | struct module *owner; | 200 | struct module *owner; |
154 | 201 | ||
155 | int (*open)(struct hci_dev *hdev); | 202 | int (*open)(struct hci_dev *hdev); |
156 | int (*close)(struct hci_dev *hdev); | 203 | int (*close)(struct hci_dev *hdev); |
@@ -164,35 +211,44 @@ struct hci_dev { | |||
164 | struct hci_conn { | 211 | struct hci_conn { |
165 | struct list_head list; | 212 | struct list_head list; |
166 | 213 | ||
167 | atomic_t refcnt; | 214 | atomic_t refcnt; |
168 | spinlock_t lock; | 215 | spinlock_t lock; |
169 | 216 | ||
170 | bdaddr_t dst; | 217 | bdaddr_t dst; |
171 | __u16 handle; | 218 | __u16 handle; |
172 | __u16 state; | 219 | __u16 state; |
173 | __u8 mode; | 220 | __u8 mode; |
174 | __u8 type; | 221 | __u8 type; |
175 | __u8 out; | 222 | __u8 out; |
176 | __u8 attempt; | 223 | __u8 attempt; |
177 | __u8 dev_class[3]; | 224 | __u8 dev_class[3]; |
178 | __u8 features[8]; | 225 | __u8 features[8]; |
179 | __u8 ssp_mode; | 226 | __u8 ssp_mode; |
180 | __u16 interval; | 227 | __u16 interval; |
181 | __u16 pkt_type; | 228 | __u16 pkt_type; |
182 | __u16 link_policy; | 229 | __u16 link_policy; |
183 | __u32 link_mode; | 230 | __u32 link_mode; |
184 | __u8 auth_type; | 231 | __u8 key_type; |
185 | __u8 sec_level; | 232 | __u8 auth_type; |
186 | __u8 power_save; | 233 | __u8 sec_level; |
187 | __u16 disc_timeout; | 234 | __u8 pending_sec_level; |
188 | unsigned long pend; | 235 | __u8 pin_length; |
189 | 236 | __u8 io_capability; | |
190 | unsigned int sent; | 237 | __u8 power_save; |
238 | __u16 disc_timeout; | ||
239 | unsigned long pend; | ||
240 | |||
241 | __u8 remote_cap; | ||
242 | __u8 remote_oob; | ||
243 | __u8 remote_auth; | ||
244 | |||
245 | unsigned int sent; | ||
191 | 246 | ||
192 | struct sk_buff_head data_q; | 247 | struct sk_buff_head data_q; |
193 | 248 | ||
194 | struct timer_list disc_timer; | 249 | struct timer_list disc_timer; |
195 | struct timer_list idle_timer; | 250 | struct timer_list idle_timer; |
251 | struct timer_list auto_accept_timer; | ||
196 | 252 | ||
197 | struct work_struct work_add; | 253 | struct work_struct work_add; |
198 | struct work_struct work_del; | 254 | struct work_struct work_del; |
@@ -206,6 +262,10 @@ struct hci_conn { | |||
206 | void *priv; | 262 | void *priv; |
207 | 263 | ||
208 | struct hci_conn *link; | 264 | struct hci_conn *link; |
265 | |||
266 | void (*connect_cfm_cb) (struct hci_conn *conn, u8 status); | ||
267 | void (*security_cfm_cb) (struct hci_conn *conn, u8 status); | ||
268 | void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); | ||
209 | }; | 269 | }; |
210 | 270 | ||
211 | extern struct hci_proto *hci_proto[]; | 271 | extern struct hci_proto *hci_proto[]; |
@@ -215,8 +275,8 @@ extern rwlock_t hci_dev_list_lock; | |||
215 | extern rwlock_t hci_cb_list_lock; | 275 | extern rwlock_t hci_cb_list_lock; |
216 | 276 | ||
217 | /* ----- Inquiry cache ----- */ | 277 | /* ----- Inquiry cache ----- */ |
218 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) // 30 seconds | 278 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ |
219 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) // 60 seconds | 279 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ |
220 | 280 | ||
221 | #define inquiry_cache_lock(c) spin_lock(&c->lock) | 281 | #define inquiry_cache_lock(c) spin_lock(&c->lock) |
222 | #define inquiry_cache_unlock(c) spin_unlock(&c->lock) | 282 | #define inquiry_cache_unlock(c) spin_unlock(&c->lock) |
@@ -233,7 +293,7 @@ static inline void inquiry_cache_init(struct hci_dev *hdev) | |||
233 | static inline int inquiry_cache_empty(struct hci_dev *hdev) | 293 | static inline int inquiry_cache_empty(struct hci_dev *hdev) |
234 | { | 294 | { |
235 | struct inquiry_cache *c = &hdev->inq_cache; | 295 | struct inquiry_cache *c = &hdev->inq_cache; |
236 | return (c->list == NULL); | 296 | return c->list == NULL; |
237 | } | 297 | } |
238 | 298 | ||
239 | static inline long inquiry_cache_age(struct hci_dev *hdev) | 299 | static inline long inquiry_cache_age(struct hci_dev *hdev) |
@@ -272,24 +332,40 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) | |||
272 | { | 332 | { |
273 | struct hci_conn_hash *h = &hdev->conn_hash; | 333 | struct hci_conn_hash *h = &hdev->conn_hash; |
274 | list_add(&c->list, &h->list); | 334 | list_add(&c->list, &h->list); |
275 | if (c->type == ACL_LINK) | 335 | switch (c->type) { |
336 | case ACL_LINK: | ||
276 | h->acl_num++; | 337 | h->acl_num++; |
277 | else | 338 | break; |
339 | case LE_LINK: | ||
340 | h->le_num++; | ||
341 | break; | ||
342 | case SCO_LINK: | ||
343 | case ESCO_LINK: | ||
278 | h->sco_num++; | 344 | h->sco_num++; |
345 | break; | ||
346 | } | ||
279 | } | 347 | } |
280 | 348 | ||
281 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) | 349 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) |
282 | { | 350 | { |
283 | struct hci_conn_hash *h = &hdev->conn_hash; | 351 | struct hci_conn_hash *h = &hdev->conn_hash; |
284 | list_del(&c->list); | 352 | list_del(&c->list); |
285 | if (c->type == ACL_LINK) | 353 | switch (c->type) { |
354 | case ACL_LINK: | ||
286 | h->acl_num--; | 355 | h->acl_num--; |
287 | else | 356 | break; |
357 | case LE_LINK: | ||
358 | h->le_num--; | ||
359 | break; | ||
360 | case SCO_LINK: | ||
361 | case ESCO_LINK: | ||
288 | h->sco_num--; | 362 | h->sco_num--; |
363 | break; | ||
364 | } | ||
289 | } | 365 | } |
290 | 366 | ||
291 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, | 367 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, |
292 | __u16 handle) | 368 | __u16 handle) |
293 | { | 369 | { |
294 | struct hci_conn_hash *h = &hdev->conn_hash; | 370 | struct hci_conn_hash *h = &hdev->conn_hash; |
295 | struct list_head *p; | 371 | struct list_head *p; |
@@ -304,7 +380,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, | |||
304 | } | 380 | } |
305 | 381 | ||
306 | static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, | 382 | static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, |
307 | __u8 type, bdaddr_t *ba) | 383 | __u8 type, bdaddr_t *ba) |
308 | { | 384 | { |
309 | struct hci_conn_hash *h = &hdev->conn_hash; | 385 | struct hci_conn_hash *h = &hdev->conn_hash; |
310 | struct list_head *p; | 386 | struct list_head *p; |
@@ -319,7 +395,7 @@ static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, | |||
319 | } | 395 | } |
320 | 396 | ||
321 | static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, | 397 | static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, |
322 | __u8 type, __u16 state) | 398 | __u8 type, __u16 state) |
323 | { | 399 | { |
324 | struct hci_conn_hash *h = &hdev->conn_hash; | 400 | struct hci_conn_hash *h = &hdev->conn_hash; |
325 | struct list_head *p; | 401 | struct list_head *p; |
@@ -346,6 +422,7 @@ void hci_conn_check_pending(struct hci_dev *hdev); | |||
346 | 422 | ||
347 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type); | 423 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type); |
348 | int hci_conn_check_link_mode(struct hci_conn *conn); | 424 | int hci_conn_check_link_mode(struct hci_conn *conn); |
425 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); | ||
349 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); | 426 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); |
350 | int hci_conn_change_link_key(struct hci_conn *conn); | 427 | int hci_conn_change_link_key(struct hci_conn *conn); |
351 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); | 428 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); |
@@ -435,6 +512,23 @@ int hci_inquiry(void __user *arg); | |||
435 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); | 512 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); |
436 | int hci_blacklist_clear(struct hci_dev *hdev); | 513 | int hci_blacklist_clear(struct hci_dev *hdev); |
437 | 514 | ||
515 | int hci_uuids_clear(struct hci_dev *hdev); | ||
516 | |||
517 | int hci_link_keys_clear(struct hci_dev *hdev); | ||
518 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
519 | int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, | ||
520 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); | ||
521 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
522 | |||
523 | int hci_remote_oob_data_clear(struct hci_dev *hdev); | ||
524 | struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, | ||
525 | bdaddr_t *bdaddr); | ||
526 | int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, | ||
527 | u8 *randomizer); | ||
528 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
529 | |||
530 | void hci_del_off_timer(struct hci_dev *hdev); | ||
531 | |||
438 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); | 532 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); |
439 | 533 | ||
440 | int hci_recv_frame(struct sk_buff *skb); | 534 | int hci_recv_frame(struct sk_buff *skb); |
@@ -456,6 +550,8 @@ void hci_conn_del_sysfs(struct hci_conn *conn); | |||
456 | #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) | 550 | #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) |
457 | #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) | 551 | #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) |
458 | #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) | 552 | #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) |
553 | #define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) | ||
554 | #define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) | ||
459 | 555 | ||
460 | /* ----- HCI protocols ----- */ | 556 | /* ----- HCI protocols ----- */ |
461 | struct hci_proto { | 557 | struct hci_proto { |
@@ -501,6 +597,9 @@ static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) | |||
501 | hp = hci_proto[HCI_PROTO_SCO]; | 597 | hp = hci_proto[HCI_PROTO_SCO]; |
502 | if (hp && hp->connect_cfm) | 598 | if (hp && hp->connect_cfm) |
503 | hp->connect_cfm(conn, status); | 599 | hp->connect_cfm(conn, status); |
600 | |||
601 | if (conn->connect_cfm_cb) | ||
602 | conn->connect_cfm_cb(conn, status); | ||
504 | } | 603 | } |
505 | 604 | ||
506 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) | 605 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) |
@@ -530,6 +629,9 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) | |||
530 | hp = hci_proto[HCI_PROTO_SCO]; | 629 | hp = hci_proto[HCI_PROTO_SCO]; |
531 | if (hp && hp->disconn_cfm) | 630 | if (hp && hp->disconn_cfm) |
532 | hp->disconn_cfm(conn, reason); | 631 | hp->disconn_cfm(conn, reason); |
632 | |||
633 | if (conn->disconn_cfm_cb) | ||
634 | conn->disconn_cfm_cb(conn, reason); | ||
533 | } | 635 | } |
534 | 636 | ||
535 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) | 637 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) |
@@ -549,6 +651,9 @@ static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) | |||
549 | hp = hci_proto[HCI_PROTO_SCO]; | 651 | hp = hci_proto[HCI_PROTO_SCO]; |
550 | if (hp && hp->security_cfm) | 652 | if (hp && hp->security_cfm) |
551 | hp->security_cfm(conn, status, encrypt); | 653 | hp->security_cfm(conn, status, encrypt); |
654 | |||
655 | if (conn->security_cfm_cb) | ||
656 | conn->security_cfm_cb(conn, status); | ||
552 | } | 657 | } |
553 | 658 | ||
554 | static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt) | 659 | static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u8 encrypt) |
@@ -562,6 +667,9 @@ static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, __u | |||
562 | hp = hci_proto[HCI_PROTO_SCO]; | 667 | hp = hci_proto[HCI_PROTO_SCO]; |
563 | if (hp && hp->security_cfm) | 668 | if (hp && hp->security_cfm) |
564 | hp->security_cfm(conn, status, encrypt); | 669 | hp->security_cfm(conn, status, encrypt); |
670 | |||
671 | if (conn->security_cfm_cb) | ||
672 | conn->security_cfm_cb(conn, status); | ||
565 | } | 673 | } |
566 | 674 | ||
567 | int hci_register_proto(struct hci_proto *hproto); | 675 | int hci_register_proto(struct hci_proto *hproto); |
@@ -658,7 +766,37 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); | |||
658 | void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); | 766 | void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); |
659 | 767 | ||
660 | /* ----- HCI Sockets ----- */ | 768 | /* ----- HCI Sockets ----- */ |
661 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); | 769 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, |
770 | struct sock *skip_sk); | ||
771 | |||
772 | /* Management interface */ | ||
773 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); | ||
774 | int mgmt_index_added(u16 index); | ||
775 | int mgmt_index_removed(u16 index); | ||
776 | int mgmt_powered(u16 index, u8 powered); | ||
777 | int mgmt_discoverable(u16 index, u8 discoverable); | ||
778 | int mgmt_connectable(u16 index, u8 connectable); | ||
779 | int mgmt_new_key(u16 index, struct link_key *key, u8 persistent); | ||
780 | int mgmt_connected(u16 index, bdaddr_t *bdaddr); | ||
781 | int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); | ||
782 | int mgmt_disconnect_failed(u16 index); | ||
783 | int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); | ||
784 | int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure); | ||
785 | int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); | ||
786 | int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); | ||
787 | int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, | ||
788 | u8 confirm_hint); | ||
789 | int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); | ||
790 | int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, | ||
791 | u8 status); | ||
792 | int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); | ||
793 | int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); | ||
794 | int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, | ||
795 | u8 status); | ||
796 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, | ||
797 | u8 *eir); | ||
798 | int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); | ||
799 | int mgmt_discovering(u16 index, u8 discovering); | ||
662 | 800 | ||
663 | /* HCI info for socket */ | 801 | /* HCI info for socket */ |
664 | #define hci_pi(sk) ((struct hci_pinfo *) sk) | 802 | #define hci_pi(sk) ((struct hci_pinfo *) sk) |
@@ -668,6 +806,7 @@ struct hci_pinfo { | |||
668 | struct hci_dev *hdev; | 806 | struct hci_dev *hdev; |
669 | struct hci_filter filter; | 807 | struct hci_filter filter; |
670 | __u32 cmsg_mask; | 808 | __u32 cmsg_mask; |
809 | unsigned short channel; | ||
671 | }; | 810 | }; |
672 | 811 | ||
673 | /* HCI security filter */ | 812 | /* HCI security filter */ |
@@ -687,6 +826,8 @@ struct hci_sec_filter { | |||
687 | #define hci_req_lock(d) mutex_lock(&d->req_lock) | 826 | #define hci_req_lock(d) mutex_lock(&d->req_lock) |
688 | #define hci_req_unlock(d) mutex_unlock(&d->req_lock) | 827 | #define hci_req_unlock(d) mutex_unlock(&d->req_lock) |
689 | 828 | ||
690 | void hci_req_complete(struct hci_dev *hdev, int result); | 829 | void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result); |
691 | 830 | ||
831 | void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, | ||
832 | u16 latency, u16 to_multiplier); | ||
692 | #endif /* __HCI_CORE_H */ | 833 | #endif /* __HCI_CORE_H */ |
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 6c241444f902..d09c9b1118e3 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | 3 | Copyright (C) 2000-2001 Qualcomm Incorporated |
4 | Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> | 4 | Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> |
@@ -14,13 +14,13 @@ | |||
14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
16 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | 16 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
17 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | 17 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
19 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 19 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
20 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 20 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 | 21 | ||
22 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | 22 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
23 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | 23 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
24 | SOFTWARE IS DISCLAIMED. | 24 | SOFTWARE IS DISCLAIMED. |
25 | */ | 25 | */ |
26 | 26 | ||
@@ -38,6 +38,7 @@ | |||
38 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ | 38 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ |
39 | #define L2CAP_DEFAULT_ACK_TO 200 | 39 | #define L2CAP_DEFAULT_ACK_TO 200 |
40 | #define L2CAP_LOCAL_BUSY_TRIES 12 | 40 | #define L2CAP_LOCAL_BUSY_TRIES 12 |
41 | #define L2CAP_LE_DEFAULT_MTU 23 | ||
41 | 42 | ||
42 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ | 43 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ |
43 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ | 44 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ |
@@ -88,6 +89,8 @@ struct l2cap_conninfo { | |||
88 | #define L2CAP_ECHO_RSP 0x09 | 89 | #define L2CAP_ECHO_RSP 0x09 |
89 | #define L2CAP_INFO_REQ 0x0a | 90 | #define L2CAP_INFO_REQ 0x0a |
90 | #define L2CAP_INFO_RSP 0x0b | 91 | #define L2CAP_INFO_RSP 0x0b |
92 | #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 | ||
93 | #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 | ||
91 | 94 | ||
92 | /* L2CAP feature mask */ | 95 | /* L2CAP feature mask */ |
93 | #define L2CAP_FEAT_FLOWCTL 0x00000001 | 96 | #define L2CAP_FEAT_FLOWCTL 0x00000001 |
@@ -160,6 +163,9 @@ struct l2cap_conn_rsp { | |||
160 | /* channel indentifier */ | 163 | /* channel indentifier */ |
161 | #define L2CAP_CID_SIGNALING 0x0001 | 164 | #define L2CAP_CID_SIGNALING 0x0001 |
162 | #define L2CAP_CID_CONN_LESS 0x0002 | 165 | #define L2CAP_CID_CONN_LESS 0x0002 |
166 | #define L2CAP_CID_LE_DATA 0x0004 | ||
167 | #define L2CAP_CID_LE_SIGNALING 0x0005 | ||
168 | #define L2CAP_CID_SMP 0x0006 | ||
163 | #define L2CAP_CID_DYN_START 0x0040 | 169 | #define L2CAP_CID_DYN_START 0x0040 |
164 | #define L2CAP_CID_DYN_END 0xffff | 170 | #define L2CAP_CID_DYN_END 0xffff |
165 | 171 | ||
@@ -255,63 +261,32 @@ struct l2cap_info_rsp { | |||
255 | #define L2CAP_IR_SUCCESS 0x0000 | 261 | #define L2CAP_IR_SUCCESS 0x0000 |
256 | #define L2CAP_IR_NOTSUPP 0x0001 | 262 | #define L2CAP_IR_NOTSUPP 0x0001 |
257 | 263 | ||
258 | /* ----- L2CAP connections ----- */ | 264 | struct l2cap_conn_param_update_req { |
259 | struct l2cap_chan_list { | 265 | __le16 min; |
260 | struct sock *head; | 266 | __le16 max; |
261 | rwlock_t lock; | 267 | __le16 latency; |
262 | long num; | 268 | __le16 to_multiplier; |
263 | }; | 269 | } __packed; |
264 | |||
265 | struct l2cap_conn { | ||
266 | struct hci_conn *hcon; | ||
267 | |||
268 | bdaddr_t *dst; | ||
269 | bdaddr_t *src; | ||
270 | |||
271 | unsigned int mtu; | ||
272 | |||
273 | __u32 feat_mask; | ||
274 | |||
275 | __u8 info_state; | ||
276 | __u8 info_ident; | ||
277 | |||
278 | struct timer_list info_timer; | ||
279 | |||
280 | spinlock_t lock; | ||
281 | |||
282 | struct sk_buff *rx_skb; | ||
283 | __u32 rx_len; | ||
284 | __u8 rx_ident; | ||
285 | __u8 tx_ident; | ||
286 | |||
287 | __u8 disc_reason; | ||
288 | |||
289 | struct l2cap_chan_list chan_list; | ||
290 | }; | ||
291 | |||
292 | struct sock_del_list { | ||
293 | struct sock *sk; | ||
294 | struct list_head list; | ||
295 | }; | ||
296 | 270 | ||
297 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | 271 | struct l2cap_conn_param_update_rsp { |
298 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 | 272 | __le16 result; |
299 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 | 273 | } __packed; |
300 | 274 | ||
301 | /* ----- L2CAP channel and socket info ----- */ | 275 | /* Connection Parameters result */ |
302 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 276 | #define L2CAP_CONN_PARAM_ACCEPTED 0x0000 |
303 | #define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) | 277 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 |
304 | #define SREJ_QUEUE(sk) (&l2cap_pi(sk)->srej_queue) | ||
305 | #define BUSY_QUEUE(sk) (&l2cap_pi(sk)->busy_queue) | ||
306 | #define SREJ_LIST(sk) (&l2cap_pi(sk)->srej_l.list) | ||
307 | 278 | ||
279 | /* ----- L2CAP channels and connections ----- */ | ||
308 | struct srej_list { | 280 | struct srej_list { |
309 | __u8 tx_seq; | 281 | __u8 tx_seq; |
310 | struct list_head list; | 282 | struct list_head list; |
311 | }; | 283 | }; |
312 | 284 | ||
313 | struct l2cap_pinfo { | 285 | struct l2cap_chan { |
314 | struct bt_sock bt; | 286 | struct sock *sk; |
287 | |||
288 | struct l2cap_conn *conn; | ||
289 | |||
315 | __le16 psm; | 290 | __le16 psm; |
316 | __u16 dcid; | 291 | __u16 dcid; |
317 | __u16 scid; | 292 | __u16 scid; |
@@ -320,16 +295,29 @@ struct l2cap_pinfo { | |||
320 | __u16 omtu; | 295 | __u16 omtu; |
321 | __u16 flush_to; | 296 | __u16 flush_to; |
322 | __u8 mode; | 297 | __u8 mode; |
323 | __u8 num_conf_req; | ||
324 | __u8 num_conf_rsp; | ||
325 | 298 | ||
326 | __u8 fcs; | 299 | __le16 sport; |
300 | |||
327 | __u8 sec_level; | 301 | __u8 sec_level; |
328 | __u8 role_switch; | 302 | __u8 role_switch; |
329 | __u8 force_reliable; | 303 | __u8 force_reliable; |
304 | __u8 flushable; | ||
305 | |||
306 | __u8 ident; | ||
330 | 307 | ||
331 | __u8 conf_req[64]; | 308 | __u8 conf_req[64]; |
332 | __u8 conf_len; | 309 | __u8 conf_len; |
310 | __u8 num_conf_req; | ||
311 | __u8 num_conf_rsp; | ||
312 | |||
313 | __u8 fcs; | ||
314 | |||
315 | __u8 tx_win; | ||
316 | __u8 max_tx; | ||
317 | __u16 retrans_timeout; | ||
318 | __u16 monitor_timeout; | ||
319 | __u16 mps; | ||
320 | |||
333 | __u8 conf_state; | 321 | __u8 conf_state; |
334 | __u16 conn_state; | 322 | __u16 conn_state; |
335 | 323 | ||
@@ -347,30 +335,61 @@ struct l2cap_pinfo { | |||
347 | __u16 partial_sdu_len; | 335 | __u16 partial_sdu_len; |
348 | struct sk_buff *sdu; | 336 | struct sk_buff *sdu; |
349 | 337 | ||
350 | __u8 ident; | ||
351 | |||
352 | __u8 tx_win; | ||
353 | __u8 max_tx; | ||
354 | __u8 remote_tx_win; | 338 | __u8 remote_tx_win; |
355 | __u8 remote_max_tx; | 339 | __u8 remote_max_tx; |
356 | __u16 retrans_timeout; | ||
357 | __u16 monitor_timeout; | ||
358 | __u16 remote_mps; | 340 | __u16 remote_mps; |
359 | __u16 mps; | ||
360 | |||
361 | __le16 sport; | ||
362 | 341 | ||
363 | struct timer_list retrans_timer; | 342 | struct timer_list retrans_timer; |
364 | struct timer_list monitor_timer; | 343 | struct timer_list monitor_timer; |
365 | struct timer_list ack_timer; | 344 | struct timer_list ack_timer; |
366 | struct sk_buff_head tx_queue; | 345 | struct sk_buff *tx_send_head; |
367 | struct sk_buff_head srej_queue; | 346 | struct sk_buff_head tx_q; |
368 | struct sk_buff_head busy_queue; | 347 | struct sk_buff_head srej_q; |
348 | struct sk_buff_head busy_q; | ||
369 | struct work_struct busy_work; | 349 | struct work_struct busy_work; |
370 | struct srej_list srej_l; | 350 | struct list_head srej_l; |
371 | struct l2cap_conn *conn; | 351 | |
372 | struct sock *next_c; | 352 | struct list_head list; |
373 | struct sock *prev_c; | 353 | struct list_head global_l; |
354 | }; | ||
355 | |||
356 | struct l2cap_conn { | ||
357 | struct hci_conn *hcon; | ||
358 | |||
359 | bdaddr_t *dst; | ||
360 | bdaddr_t *src; | ||
361 | |||
362 | unsigned int mtu; | ||
363 | |||
364 | __u32 feat_mask; | ||
365 | |||
366 | __u8 info_state; | ||
367 | __u8 info_ident; | ||
368 | |||
369 | struct timer_list info_timer; | ||
370 | |||
371 | spinlock_t lock; | ||
372 | |||
373 | struct sk_buff *rx_skb; | ||
374 | __u32 rx_len; | ||
375 | __u8 tx_ident; | ||
376 | |||
377 | __u8 disc_reason; | ||
378 | |||
379 | struct list_head chan_l; | ||
380 | rwlock_t chan_lock; | ||
381 | }; | ||
382 | |||
383 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | ||
384 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04 | ||
385 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08 | ||
386 | |||
387 | /* ----- L2CAP socket info ----- */ | ||
388 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | ||
389 | |||
390 | struct l2cap_pinfo { | ||
391 | struct bt_sock bt; | ||
392 | struct l2cap_chan *chan; | ||
374 | }; | 393 | }; |
375 | 394 | ||
376 | #define L2CAP_CONF_REQ_SENT 0x01 | 395 | #define L2CAP_CONF_REQ_SENT 0x01 |
@@ -397,32 +416,62 @@ struct l2cap_pinfo { | |||
397 | #define L2CAP_CONN_RNR_SENT 0x0200 | 416 | #define L2CAP_CONN_RNR_SENT 0x0200 |
398 | #define L2CAP_CONN_SAR_RETRY 0x0400 | 417 | #define L2CAP_CONN_SAR_RETRY 0x0400 |
399 | 418 | ||
400 | #define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \ | 419 | #define __mod_retrans_timer() mod_timer(&chan->retrans_timer, \ |
401 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); | 420 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); |
402 | #define __mod_monitor_timer() mod_timer(&l2cap_pi(sk)->monitor_timer, \ | 421 | #define __mod_monitor_timer() mod_timer(&chan->monitor_timer, \ |
403 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); | 422 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); |
404 | #define __mod_ack_timer() mod_timer(&l2cap_pi(sk)->ack_timer, \ | 423 | #define __mod_ack_timer() mod_timer(&chan->ack_timer, \ |
405 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); | 424 | jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); |
406 | 425 | ||
407 | static inline int l2cap_tx_window_full(struct sock *sk) | 426 | static inline int l2cap_tx_window_full(struct l2cap_chan *ch) |
408 | { | 427 | { |
409 | struct l2cap_pinfo *pi = l2cap_pi(sk); | ||
410 | int sub; | 428 | int sub; |
411 | 429 | ||
412 | sub = (pi->next_tx_seq - pi->expected_ack_seq) % 64; | 430 | sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; |
413 | 431 | ||
414 | if (sub < 0) | 432 | if (sub < 0) |
415 | sub += 64; | 433 | sub += 64; |
416 | 434 | ||
417 | return (sub == pi->remote_tx_win); | 435 | return sub == ch->remote_tx_win; |
418 | } | 436 | } |
419 | 437 | ||
420 | #define __get_txseq(ctrl) ((ctrl) & L2CAP_CTRL_TXSEQ) >> 1 | 438 | #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) |
421 | #define __get_reqseq(ctrl) ((ctrl) & L2CAP_CTRL_REQSEQ) >> 8 | 439 | #define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) |
422 | #define __is_iframe(ctrl) !((ctrl) & L2CAP_CTRL_FRAME_TYPE) | 440 | #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) |
423 | #define __is_sframe(ctrl) (ctrl) & L2CAP_CTRL_FRAME_TYPE | 441 | #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) |
424 | #define __is_sar_start(ctrl) ((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START | 442 | #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) |
425 | 443 | ||
426 | void l2cap_load(void); | 444 | extern int disable_ertm; |
445 | |||
446 | int l2cap_init_sockets(void); | ||
447 | void l2cap_cleanup_sockets(void); | ||
448 | |||
449 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); | ||
450 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); | ||
451 | int __l2cap_wait_ack(struct sock *sk); | ||
452 | |||
453 | struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); | ||
454 | struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); | ||
455 | struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen); | ||
456 | int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); | ||
457 | void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb); | ||
458 | void l2cap_streaming_send(struct l2cap_chan *chan); | ||
459 | int l2cap_ertm_send(struct l2cap_chan *chan); | ||
460 | |||
461 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); | ||
462 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); | ||
463 | |||
464 | void l2cap_sock_set_timer(struct sock *sk, long timeout); | ||
465 | void l2cap_sock_clear_timer(struct sock *sk); | ||
466 | void __l2cap_sock_close(struct sock *sk, int reason); | ||
467 | void l2cap_sock_kill(struct sock *sk); | ||
468 | void l2cap_sock_init(struct sock *sk, struct sock *parent); | ||
469 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, | ||
470 | int proto, gfp_t prio); | ||
471 | void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err); | ||
472 | struct l2cap_chan *l2cap_chan_create(struct sock *sk); | ||
473 | void l2cap_chan_del(struct l2cap_chan *chan, int err); | ||
474 | void l2cap_chan_destroy(struct l2cap_chan *chan); | ||
475 | int l2cap_chan_connect(struct l2cap_chan *chan); | ||
427 | 476 | ||
428 | #endif /* __L2CAP_H */ | 477 | #endif /* __L2CAP_H */ |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h new file mode 100644 index 000000000000..4899286ed4e4 --- /dev/null +++ b/include/net/bluetooth/mgmt.h | |||
@@ -0,0 +1,291 @@ | |||
1 | /* | ||
2 | BlueZ - Bluetooth protocol stack for Linux | ||
3 | |||
4 | Copyright (C) 2010 Nokia Corporation | ||
5 | |||
6 | This program is free software; you can redistribute it and/or modify | ||
7 | it under the terms of the GNU General Public License version 2 as | ||
8 | published by the Free Software Foundation; | ||
9 | |||
10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | ||
11 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | ||
13 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | ||
14 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | ||
15 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
16 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
17 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
18 | |||
19 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | ||
20 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | ||
21 | SOFTWARE IS DISCLAIMED. | ||
22 | */ | ||
23 | |||
24 | #define MGMT_INDEX_NONE 0xFFFF | ||
25 | |||
26 | struct mgmt_hdr { | ||
27 | __le16 opcode; | ||
28 | __le16 index; | ||
29 | __le16 len; | ||
30 | } __packed; | ||
31 | |||
32 | #define MGMT_OP_READ_VERSION 0x0001 | ||
33 | struct mgmt_rp_read_version { | ||
34 | __u8 version; | ||
35 | __le16 revision; | ||
36 | } __packed; | ||
37 | |||
38 | #define MGMT_OP_READ_INDEX_LIST 0x0003 | ||
39 | struct mgmt_rp_read_index_list { | ||
40 | __le16 num_controllers; | ||
41 | __le16 index[0]; | ||
42 | } __packed; | ||
43 | |||
44 | /* Reserve one extra byte for names in management messages so that they | ||
45 | * are always guaranteed to be nul-terminated */ | ||
46 | #define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1) | ||
47 | |||
48 | #define MGMT_OP_READ_INFO 0x0004 | ||
49 | struct mgmt_rp_read_info { | ||
50 | __u8 type; | ||
51 | __u8 powered; | ||
52 | __u8 connectable; | ||
53 | __u8 discoverable; | ||
54 | __u8 pairable; | ||
55 | __u8 sec_mode; | ||
56 | bdaddr_t bdaddr; | ||
57 | __u8 dev_class[3]; | ||
58 | __u8 features[8]; | ||
59 | __u16 manufacturer; | ||
60 | __u8 hci_ver; | ||
61 | __u16 hci_rev; | ||
62 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
63 | } __packed; | ||
64 | |||
65 | struct mgmt_mode { | ||
66 | __u8 val; | ||
67 | } __packed; | ||
68 | |||
69 | #define MGMT_OP_SET_POWERED 0x0005 | ||
70 | |||
71 | #define MGMT_OP_SET_DISCOVERABLE 0x0006 | ||
72 | |||
73 | #define MGMT_OP_SET_CONNECTABLE 0x0007 | ||
74 | |||
75 | #define MGMT_OP_SET_PAIRABLE 0x0008 | ||
76 | |||
77 | #define MGMT_OP_ADD_UUID 0x0009 | ||
78 | struct mgmt_cp_add_uuid { | ||
79 | __u8 uuid[16]; | ||
80 | __u8 svc_hint; | ||
81 | } __packed; | ||
82 | |||
83 | #define MGMT_OP_REMOVE_UUID 0x000A | ||
84 | struct mgmt_cp_remove_uuid { | ||
85 | __u8 uuid[16]; | ||
86 | } __packed; | ||
87 | |||
88 | #define MGMT_OP_SET_DEV_CLASS 0x000B | ||
89 | struct mgmt_cp_set_dev_class { | ||
90 | __u8 major; | ||
91 | __u8 minor; | ||
92 | } __packed; | ||
93 | |||
94 | #define MGMT_OP_SET_SERVICE_CACHE 0x000C | ||
95 | struct mgmt_cp_set_service_cache { | ||
96 | __u8 enable; | ||
97 | } __packed; | ||
98 | |||
99 | struct mgmt_key_info { | ||
100 | bdaddr_t bdaddr; | ||
101 | u8 type; | ||
102 | u8 val[16]; | ||
103 | u8 pin_len; | ||
104 | } __packed; | ||
105 | |||
106 | #define MGMT_OP_LOAD_KEYS 0x000D | ||
107 | struct mgmt_cp_load_keys { | ||
108 | __u8 debug_keys; | ||
109 | __le16 key_count; | ||
110 | struct mgmt_key_info keys[0]; | ||
111 | } __packed; | ||
112 | |||
113 | #define MGMT_OP_REMOVE_KEY 0x000E | ||
114 | struct mgmt_cp_remove_key { | ||
115 | bdaddr_t bdaddr; | ||
116 | __u8 disconnect; | ||
117 | } __packed; | ||
118 | |||
119 | #define MGMT_OP_DISCONNECT 0x000F | ||
120 | struct mgmt_cp_disconnect { | ||
121 | bdaddr_t bdaddr; | ||
122 | } __packed; | ||
123 | struct mgmt_rp_disconnect { | ||
124 | bdaddr_t bdaddr; | ||
125 | } __packed; | ||
126 | |||
127 | #define MGMT_OP_GET_CONNECTIONS 0x0010 | ||
128 | struct mgmt_rp_get_connections { | ||
129 | __le16 conn_count; | ||
130 | bdaddr_t conn[0]; | ||
131 | } __packed; | ||
132 | |||
133 | #define MGMT_OP_PIN_CODE_REPLY 0x0011 | ||
134 | struct mgmt_cp_pin_code_reply { | ||
135 | bdaddr_t bdaddr; | ||
136 | __u8 pin_len; | ||
137 | __u8 pin_code[16]; | ||
138 | } __packed; | ||
139 | struct mgmt_rp_pin_code_reply { | ||
140 | bdaddr_t bdaddr; | ||
141 | uint8_t status; | ||
142 | } __packed; | ||
143 | |||
144 | #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012 | ||
145 | struct mgmt_cp_pin_code_neg_reply { | ||
146 | bdaddr_t bdaddr; | ||
147 | } __packed; | ||
148 | |||
149 | #define MGMT_OP_SET_IO_CAPABILITY 0x0013 | ||
150 | struct mgmt_cp_set_io_capability { | ||
151 | __u8 io_capability; | ||
152 | } __packed; | ||
153 | |||
154 | #define MGMT_OP_PAIR_DEVICE 0x0014 | ||
155 | struct mgmt_cp_pair_device { | ||
156 | bdaddr_t bdaddr; | ||
157 | __u8 io_cap; | ||
158 | } __packed; | ||
159 | struct mgmt_rp_pair_device { | ||
160 | bdaddr_t bdaddr; | ||
161 | __u8 status; | ||
162 | } __packed; | ||
163 | |||
164 | #define MGMT_OP_USER_CONFIRM_REPLY 0x0015 | ||
165 | struct mgmt_cp_user_confirm_reply { | ||
166 | bdaddr_t bdaddr; | ||
167 | } __packed; | ||
168 | struct mgmt_rp_user_confirm_reply { | ||
169 | bdaddr_t bdaddr; | ||
170 | __u8 status; | ||
171 | } __packed; | ||
172 | |||
173 | #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016 | ||
174 | |||
175 | #define MGMT_OP_SET_LOCAL_NAME 0x0017 | ||
176 | struct mgmt_cp_set_local_name { | ||
177 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
178 | } __packed; | ||
179 | |||
180 | #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018 | ||
181 | struct mgmt_rp_read_local_oob_data { | ||
182 | __u8 hash[16]; | ||
183 | __u8 randomizer[16]; | ||
184 | } __packed; | ||
185 | |||
186 | #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019 | ||
187 | struct mgmt_cp_add_remote_oob_data { | ||
188 | bdaddr_t bdaddr; | ||
189 | __u8 hash[16]; | ||
190 | __u8 randomizer[16]; | ||
191 | } __packed; | ||
192 | |||
193 | #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A | ||
194 | struct mgmt_cp_remove_remote_oob_data { | ||
195 | bdaddr_t bdaddr; | ||
196 | } __packed; | ||
197 | |||
198 | #define MGMT_OP_START_DISCOVERY 0x001B | ||
199 | |||
200 | #define MGMT_OP_STOP_DISCOVERY 0x001C | ||
201 | |||
202 | #define MGMT_EV_CMD_COMPLETE 0x0001 | ||
203 | struct mgmt_ev_cmd_complete { | ||
204 | __le16 opcode; | ||
205 | __u8 data[0]; | ||
206 | } __packed; | ||
207 | |||
208 | #define MGMT_EV_CMD_STATUS 0x0002 | ||
209 | struct mgmt_ev_cmd_status { | ||
210 | __u8 status; | ||
211 | __le16 opcode; | ||
212 | } __packed; | ||
213 | |||
214 | #define MGMT_EV_CONTROLLER_ERROR 0x0003 | ||
215 | struct mgmt_ev_controller_error { | ||
216 | __u8 error_code; | ||
217 | } __packed; | ||
218 | |||
219 | #define MGMT_EV_INDEX_ADDED 0x0004 | ||
220 | |||
221 | #define MGMT_EV_INDEX_REMOVED 0x0005 | ||
222 | |||
223 | #define MGMT_EV_POWERED 0x0006 | ||
224 | |||
225 | #define MGMT_EV_DISCOVERABLE 0x0007 | ||
226 | |||
227 | #define MGMT_EV_CONNECTABLE 0x0008 | ||
228 | |||
229 | #define MGMT_EV_PAIRABLE 0x0009 | ||
230 | |||
231 | #define MGMT_EV_NEW_KEY 0x000A | ||
232 | struct mgmt_ev_new_key { | ||
233 | __u8 store_hint; | ||
234 | struct mgmt_key_info key; | ||
235 | } __packed; | ||
236 | |||
237 | #define MGMT_EV_CONNECTED 0x000B | ||
238 | struct mgmt_ev_connected { | ||
239 | bdaddr_t bdaddr; | ||
240 | } __packed; | ||
241 | |||
242 | #define MGMT_EV_DISCONNECTED 0x000C | ||
243 | struct mgmt_ev_disconnected { | ||
244 | bdaddr_t bdaddr; | ||
245 | } __packed; | ||
246 | |||
247 | #define MGMT_EV_CONNECT_FAILED 0x000D | ||
248 | struct mgmt_ev_connect_failed { | ||
249 | bdaddr_t bdaddr; | ||
250 | __u8 status; | ||
251 | } __packed; | ||
252 | |||
253 | #define MGMT_EV_PIN_CODE_REQUEST 0x000E | ||
254 | struct mgmt_ev_pin_code_request { | ||
255 | bdaddr_t bdaddr; | ||
256 | __u8 secure; | ||
257 | } __packed; | ||
258 | |||
259 | #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F | ||
260 | struct mgmt_ev_user_confirm_request { | ||
261 | bdaddr_t bdaddr; | ||
262 | __u8 confirm_hint; | ||
263 | __le32 value; | ||
264 | } __packed; | ||
265 | |||
266 | #define MGMT_EV_AUTH_FAILED 0x0010 | ||
267 | struct mgmt_ev_auth_failed { | ||
268 | bdaddr_t bdaddr; | ||
269 | __u8 status; | ||
270 | } __packed; | ||
271 | |||
272 | #define MGMT_EV_LOCAL_NAME_CHANGED 0x0011 | ||
273 | struct mgmt_ev_local_name_changed { | ||
274 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
275 | } __packed; | ||
276 | |||
277 | #define MGMT_EV_DEVICE_FOUND 0x0012 | ||
278 | struct mgmt_ev_device_found { | ||
279 | bdaddr_t bdaddr; | ||
280 | __u8 dev_class[3]; | ||
281 | __s8 rssi; | ||
282 | __u8 eir[HCI_MAX_EIR_LENGTH]; | ||
283 | } __packed; | ||
284 | |||
285 | #define MGMT_EV_REMOTE_NAME 0x0013 | ||
286 | struct mgmt_ev_remote_name { | ||
287 | bdaddr_t bdaddr; | ||
288 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
289 | } __packed; | ||
290 | |||
291 | #define MGMT_EV_DISCOVERING 0x0014 | ||
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h index a140847d622c..6eac4a760c3b 100644 --- a/include/net/bluetooth/rfcomm.h +++ b/include/net/bluetooth/rfcomm.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | RFCOMM implementation for Linux Bluetooth stack (BlueZ). | 2 | RFCOMM implementation for Linux Bluetooth stack (BlueZ) |
3 | Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com> | 3 | Copyright (C) 2002 Maxim Krasnyansky <maxk@qualcomm.com> |
4 | Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> | 4 | Copyright (C) 2002 Marcel Holtmann <marcel@holtmann.org> |
5 | 5 | ||
@@ -11,13 +11,13 @@ | |||
11 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 11 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
13 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | 13 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
14 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | 14 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
15 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 15 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
16 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 16 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
17 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 17 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
18 | 18 | ||
19 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | 19 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
20 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | 20 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
21 | SOFTWARE IS DISCLAIMED. | 21 | SOFTWARE IS DISCLAIMED. |
22 | */ | 22 | */ |
23 | 23 | ||
@@ -105,7 +105,7 @@ | |||
105 | struct rfcomm_hdr { | 105 | struct rfcomm_hdr { |
106 | u8 addr; | 106 | u8 addr; |
107 | u8 ctrl; | 107 | u8 ctrl; |
108 | u8 len; // Actual size can be 2 bytes | 108 | u8 len; /* Actual size can be 2 bytes */ |
109 | } __packed; | 109 | } __packed; |
110 | 110 | ||
111 | struct rfcomm_cmd { | 111 | struct rfcomm_cmd { |
@@ -213,11 +213,6 @@ struct rfcomm_dlc { | |||
213 | #define RFCOMM_DEFER_SETUP 8 | 213 | #define RFCOMM_DEFER_SETUP 8 |
214 | 214 | ||
215 | /* Scheduling flags and events */ | 215 | /* Scheduling flags and events */ |
216 | #define RFCOMM_SCHED_STATE 0 | ||
217 | #define RFCOMM_SCHED_RX 1 | ||
218 | #define RFCOMM_SCHED_TX 2 | ||
219 | #define RFCOMM_SCHED_TIMEO 3 | ||
220 | #define RFCOMM_SCHED_AUTH 4 | ||
221 | #define RFCOMM_SCHED_WAKEUP 31 | 216 | #define RFCOMM_SCHED_WAKEUP 31 |
222 | 217 | ||
223 | /* MSC exchange flags */ | 218 | /* MSC exchange flags */ |
@@ -233,7 +228,7 @@ struct rfcomm_dlc { | |||
233 | /* ---- RFCOMM SEND RPN ---- */ | 228 | /* ---- RFCOMM SEND RPN ---- */ |
234 | int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, | 229 | int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, |
235 | u8 bit_rate, u8 data_bits, u8 stop_bits, | 230 | u8 bit_rate, u8 data_bits, u8 stop_bits, |
236 | u8 parity, u8 flow_ctrl_settings, | 231 | u8 parity, u8 flow_ctrl_settings, |
237 | u8 xon_char, u8 xoff_char, u16 param_mask); | 232 | u8 xon_char, u8 xoff_char, u16 param_mask); |
238 | 233 | ||
239 | /* ---- RFCOMM DLCs (channels) ---- */ | 234 | /* ---- RFCOMM DLCs (channels) ---- */ |
diff --git a/include/net/bluetooth/sco.h b/include/net/bluetooth/sco.h index e28a2a771471..1e35c43657c8 100644 --- a/include/net/bluetooth/sco.h +++ b/include/net/bluetooth/sco.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
3 | Copyright (C) 2000-2001 Qualcomm Incorporated | 3 | Copyright (C) 2000-2001 Qualcomm Incorporated |
4 | 4 | ||
@@ -12,13 +12,13 @@ | |||
12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 12 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. |
14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | 14 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY |
15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | 15 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES |
16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 16 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 17 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 18 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
19 | 19 | ||
20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | 20 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, |
21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | 21 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS |
22 | SOFTWARE IS DISCLAIMED. | 22 | SOFTWARE IS DISCLAIMED. |
23 | */ | 23 | */ |
24 | 24 | ||
@@ -55,11 +55,11 @@ struct sco_conninfo { | |||
55 | struct sco_conn { | 55 | struct sco_conn { |
56 | struct hci_conn *hcon; | 56 | struct hci_conn *hcon; |
57 | 57 | ||
58 | bdaddr_t *dst; | 58 | bdaddr_t *dst; |
59 | bdaddr_t *src; | 59 | bdaddr_t *src; |
60 | 60 | ||
61 | spinlock_t lock; | 61 | spinlock_t lock; |
62 | struct sock *sk; | 62 | struct sock *sk; |
63 | 63 | ||
64 | unsigned int mtu; | 64 | unsigned int mtu; |
65 | }; | 65 | }; |
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h new file mode 100644 index 000000000000..8f2edbf979dc --- /dev/null +++ b/include/net/bluetooth/smp.h | |||
@@ -0,0 +1,76 @@ | |||
1 | #ifndef __SMP_H | ||
2 | #define __SMP_H | ||
3 | |||
4 | struct smp_command_hdr { | ||
5 | __u8 code; | ||
6 | } __packed; | ||
7 | |||
8 | #define SMP_CMD_PAIRING_REQ 0x01 | ||
9 | #define SMP_CMD_PAIRING_RSP 0x02 | ||
10 | struct smp_cmd_pairing { | ||
11 | __u8 io_capability; | ||
12 | __u8 oob_flag; | ||
13 | __u8 auth_req; | ||
14 | __u8 max_key_size; | ||
15 | __u8 init_key_dist; | ||
16 | __u8 resp_key_dist; | ||
17 | } __packed; | ||
18 | |||
19 | #define SMP_CMD_PAIRING_CONFIRM 0x03 | ||
20 | struct smp_cmd_pairing_confirm { | ||
21 | __u8 confirm_val[16]; | ||
22 | } __packed; | ||
23 | |||
24 | #define SMP_CMD_PAIRING_RANDOM 0x04 | ||
25 | struct smp_cmd_pairing_random { | ||
26 | __u8 rand_val[16]; | ||
27 | } __packed; | ||
28 | |||
29 | #define SMP_CMD_PAIRING_FAIL 0x05 | ||
30 | struct smp_cmd_pairing_fail { | ||
31 | __u8 reason; | ||
32 | } __packed; | ||
33 | |||
34 | #define SMP_CMD_ENCRYPT_INFO 0x06 | ||
35 | struct smp_cmd_encrypt_info { | ||
36 | __u8 ltk[16]; | ||
37 | } __packed; | ||
38 | |||
39 | #define SMP_CMD_MASTER_IDENT 0x07 | ||
40 | struct smp_cmd_master_ident { | ||
41 | __u16 ediv; | ||
42 | __u8 rand[8]; | ||
43 | } __packed; | ||
44 | |||
45 | #define SMP_CMD_IDENT_INFO 0x08 | ||
46 | struct smp_cmd_ident_info { | ||
47 | __u8 irk[16]; | ||
48 | } __packed; | ||
49 | |||
50 | #define SMP_CMD_IDENT_ADDR_INFO 0x09 | ||
51 | struct smp_cmd_ident_addr_info { | ||
52 | __u8 addr_type; | ||
53 | bdaddr_t bdaddr; | ||
54 | } __packed; | ||
55 | |||
56 | #define SMP_CMD_SIGN_INFO 0x0a | ||
57 | struct smp_cmd_sign_info { | ||
58 | __u8 csrk[16]; | ||
59 | } __packed; | ||
60 | |||
61 | #define SMP_CMD_SECURITY_REQ 0x0b | ||
62 | struct smp_cmd_security_req { | ||
63 | __u8 auth_req; | ||
64 | } __packed; | ||
65 | |||
66 | #define SMP_PASSKEY_ENTRY_FAILED 0x01 | ||
67 | #define SMP_OOB_NOT_AVAIL 0x02 | ||
68 | #define SMP_AUTH_REQUIREMENTS 0x03 | ||
69 | #define SMP_CONFIRM_FAILED 0x04 | ||
70 | #define SMP_PAIRING_NOTSUPP 0x05 | ||
71 | #define SMP_ENC_KEY_SIZE 0x06 | ||
72 | #define SMP_CMD_NOTSUPP 0x07 | ||
73 | #define SMP_UNSPECIFIED 0x08 | ||
74 | #define SMP_REPEATED_ATTEMPTS 0x09 | ||
75 | |||
76 | #endif /* __SMP_H */ | ||
diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h index 6da573c75d54..c011281d92c0 100644 --- a/include/net/caif/caif_dev.h +++ b/include/net/caif/caif_dev.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #include <net/caif/cfcnfg.h> | 11 | #include <net/caif/cfcnfg.h> |
12 | #include <linux/caif/caif_socket.h> | 12 | #include <linux/caif/caif_socket.h> |
13 | #include <linux/if.h> | 13 | #include <linux/if.h> |
14 | #include <linux/net.h> | ||
14 | 15 | ||
15 | /** | 16 | /** |
16 | * struct caif_param - CAIF parameters. | 17 | * struct caif_param - CAIF parameters. |
@@ -28,7 +29,7 @@ struct caif_param { | |||
28 | * @sockaddr: Socket address to connect. | 29 | * @sockaddr: Socket address to connect. |
29 | * @priority: Priority of the connection. | 30 | * @priority: Priority of the connection. |
30 | * @link_selector: Link selector (high bandwidth or low latency) | 31 | * @link_selector: Link selector (high bandwidth or low latency) |
31 | * @link_name: Name of the CAIF Link Layer to use. | 32 | * @ifindex: kernel index of the interface. |
32 | * @param: Connect Request parameters (CAIF_SO_REQ_PARAM). | 33 | * @param: Connect Request parameters (CAIF_SO_REQ_PARAM). |
33 | * | 34 | * |
34 | * This struct is used when connecting a CAIF channel. | 35 | * This struct is used when connecting a CAIF channel. |
@@ -39,7 +40,7 @@ struct caif_connect_request { | |||
39 | struct sockaddr_caif sockaddr; | 40 | struct sockaddr_caif sockaddr; |
40 | enum caif_channel_priority priority; | 41 | enum caif_channel_priority priority; |
41 | enum caif_link_selector link_selector; | 42 | enum caif_link_selector link_selector; |
42 | char link_name[16]; | 43 | int ifindex; |
43 | struct caif_param param; | 44 | struct caif_param param; |
44 | }; | 45 | }; |
45 | 46 | ||
@@ -62,46 +63,45 @@ struct caif_connect_request { | |||
62 | * E.g. CAIF Socket will call this function for each socket it connects | 63 | * E.g. CAIF Socket will call this function for each socket it connects |
63 | * and have one client_layer instance for each socket. | 64 | * and have one client_layer instance for each socket. |
64 | */ | 65 | */ |
65 | int caif_connect_client(struct caif_connect_request *conn_req, | 66 | int caif_connect_client(struct net *net, |
67 | struct caif_connect_request *conn_req, | ||
66 | struct cflayer *client_layer, int *ifindex, | 68 | struct cflayer *client_layer, int *ifindex, |
67 | int *headroom, int *tailroom); | 69 | int *headroom, int *tailroom); |
68 | 70 | ||
69 | /** | 71 | /** |
70 | * caif_disconnect_client - Disconnects a client from the CAIF stack. | 72 | * caif_disconnect_client - Disconnects a client from the CAIF stack. |
71 | * | 73 | * |
72 | * @client_layer: Client layer to be removed. | 74 | * @client_layer: Client layer to be disconnected. |
73 | */ | 75 | */ |
74 | int caif_disconnect_client(struct cflayer *client_layer); | 76 | int caif_disconnect_client(struct net *net, struct cflayer *client_layer); |
77 | |||
75 | 78 | ||
76 | /** | 79 | /** |
77 | * caif_release_client - Release adaptation layer reference to client. | 80 | * caif_client_register_refcnt - register ref-count functions provided by client. |
78 | * | 81 | * |
79 | * @client_layer: Client layer. | 82 | * @adapt_layer: Client layer using CAIF Stack. |
83 | * @hold: Function provided by client layer increasing ref-count | ||
84 | * @put: Function provided by client layer decreasing ref-count | ||
80 | * | 85 | * |
81 | * Releases a client/adaptation layer use of the caif stack. | 86 | * Client of the CAIF Stack must register functions for reference counting. |
82 | * This function must be used after caif_disconnect_client to | 87 | * These functions are called by the CAIF Stack for every upstream packet, |
83 | * decrease the reference count of the service layer. | 88 | * and must therefore be implemented efficiently. |
84 | */ | ||
85 | void caif_release_client(struct cflayer *client_layer); | ||
86 | |||
87 | /** | ||
88 | * connect_req_to_link_param - Translate configuration parameters | ||
89 | * from socket format to internal format. | ||
90 | * @cnfg: Pointer to configuration handler | ||
91 | * @con_req: Configuration parameters supplied in function | ||
92 | * caif_connect_client | ||
93 | * @channel_setup_param: Parameters supplied to the CAIF Core stack for | ||
94 | * setting up channels. | ||
95 | * | 89 | * |
90 | * Client should call caif_free_client when reference count degrease to zero. | ||
96 | */ | 91 | */ |
97 | int connect_req_to_link_param(struct cfcnfg *cnfg, | ||
98 | struct caif_connect_request *con_req, | ||
99 | struct cfctrl_link_param *channel_setup_param); | ||
100 | 92 | ||
93 | void caif_client_register_refcnt(struct cflayer *adapt_layer, | ||
94 | void (*hold)(struct cflayer *lyr), | ||
95 | void (*put)(struct cflayer *lyr)); | ||
101 | /** | 96 | /** |
102 | * get_caif_conf() - Get the configuration handler. | 97 | * caif_free_client - Free memory used to manage the client in the CAIF Stack. |
98 | * | ||
99 | * @client_layer: Client layer to be removed. | ||
100 | * | ||
101 | * This function must be called from client layer in order to free memory. | ||
102 | * Caller must guarantee that no packets are in flight upstream when calling | ||
103 | * this function. | ||
103 | */ | 104 | */ |
104 | struct cfcnfg *get_caif_conf(void); | 105 | void caif_free_client(struct cflayer *adap_layer); |
105 | |||
106 | 106 | ||
107 | #endif /* CAIF_DEV_H_ */ | 107 | #endif /* CAIF_DEV_H_ */ |
diff --git a/include/net/caif/caif_layer.h b/include/net/caif/caif_layer.h index c8b07a904e78..35bc7883cf97 100644 --- a/include/net/caif/caif_layer.h +++ b/include/net/caif/caif_layer.h | |||
@@ -15,7 +15,6 @@ struct cfpktq; | |||
15 | struct caif_payload_info; | 15 | struct caif_payload_info; |
16 | struct caif_packet_funcs; | 16 | struct caif_packet_funcs; |
17 | 17 | ||
18 | |||
19 | #define CAIF_LAYER_NAME_SZ 16 | 18 | #define CAIF_LAYER_NAME_SZ 16 |
20 | 19 | ||
21 | /** | 20 | /** |
@@ -33,7 +32,6 @@ do { \ | |||
33 | } \ | 32 | } \ |
34 | } while (0) | 33 | } while (0) |
35 | 34 | ||
36 | |||
37 | /** | 35 | /** |
38 | * enum caif_ctrlcmd - CAIF Stack Control Signaling sent in layer.ctrlcmd(). | 36 | * enum caif_ctrlcmd - CAIF Stack Control Signaling sent in layer.ctrlcmd(). |
39 | * | 37 | * |
@@ -141,7 +139,7 @@ enum caif_direction { | |||
141 | * - All layers must use this structure. If embedding it, then place this | 139 | * - All layers must use this structure. If embedding it, then place this |
142 | * structure first in the layer specific structure. | 140 | * structure first in the layer specific structure. |
143 | * | 141 | * |
144 | * - Each layer should not depend on any others layer private data. | 142 | * - Each layer should not depend on any others layer's private data. |
145 | * | 143 | * |
146 | * - In order to send data upwards do | 144 | * - In order to send data upwards do |
147 | * layer->up->receive(layer->up, packet); | 145 | * layer->up->receive(layer->up, packet); |
@@ -155,16 +153,23 @@ struct cflayer { | |||
155 | struct list_head node; | 153 | struct list_head node; |
156 | 154 | ||
157 | /* | 155 | /* |
158 | * receive() - Receive Function. | 156 | * receive() - Receive Function (non-blocking). |
159 | * Contract: Each layer must implement a receive function passing the | 157 | * Contract: Each layer must implement a receive function passing the |
160 | * CAIF packets upwards in the stack. | 158 | * CAIF packets upwards in the stack. |
161 | * Packet handling rules: | 159 | * Packet handling rules: |
162 | * - The CAIF packet (cfpkt) cannot be accessed after | 160 | * - The CAIF packet (cfpkt) ownership is passed to the |
163 | * passing it to the next layer using up->receive(). | 161 | * called receive function. This means that the the |
162 | * packet cannot be accessed after passing it to the | ||
163 | * above layer using up->receive(). | ||
164 | * | ||
164 | * - If parsing of the packet fails, the packet must be | 165 | * - If parsing of the packet fails, the packet must be |
165 | * destroyed and -1 returned from the function. | 166 | * destroyed and negative error code returned |
167 | * from the function. | ||
168 | * EXCEPTION: If the framing layer (cffrml) returns | ||
169 | * -EILSEQ, the packet is not freed. | ||
170 | * | ||
166 | * - If parsing succeeds (and above layers return OK) then | 171 | * - If parsing succeeds (and above layers return OK) then |
167 | * the function must return a value > 0. | 172 | * the function must return a value >= 0. |
168 | * | 173 | * |
169 | * Returns result < 0 indicates an error, 0 or positive value | 174 | * Returns result < 0 indicates an error, 0 or positive value |
170 | * indicates success. | 175 | * indicates success. |
@@ -176,7 +181,7 @@ struct cflayer { | |||
176 | int (*receive)(struct cflayer *layr, struct cfpkt *cfpkt); | 181 | int (*receive)(struct cflayer *layr, struct cfpkt *cfpkt); |
177 | 182 | ||
178 | /* | 183 | /* |
179 | * transmit() - Transmit Function. | 184 | * transmit() - Transmit Function (non-blocking). |
180 | * Contract: Each layer must implement a transmit function passing the | 185 | * Contract: Each layer must implement a transmit function passing the |
181 | * CAIF packet downwards in the stack. | 186 | * CAIF packet downwards in the stack. |
182 | * Packet handling rules: | 187 | * Packet handling rules: |
@@ -185,15 +190,16 @@ struct cflayer { | |||
185 | * cannot be accessed after passing it to the below | 190 | * cannot be accessed after passing it to the below |
186 | * layer using dn->transmit(). | 191 | * layer using dn->transmit(). |
187 | * | 192 | * |
188 | * - If transmit fails, however, the ownership is returned | 193 | * - Upon error the packet ownership is still passed on, |
189 | * to thecaller. The caller of "dn->transmit()" must | 194 | * so the packet shall be freed where error is detected. |
190 | * destroy or resend packet. | 195 | * Callers of the transmit function shall not free packets, |
196 | * but errors shall be returned. | ||
191 | * | 197 | * |
192 | * - Return value less than zero means error, zero or | 198 | * - Return value less than zero means error, zero or |
193 | * greater than zero means OK. | 199 | * greater than zero means OK. |
194 | * | 200 | * |
195 | * result < 0 indicates an error, 0 or positive value | 201 | * Returns result < 0 indicates an error, 0 or positive value |
196 | * indicate success. | 202 | * indicates success. |
197 | * | 203 | * |
198 | * @layr: Pointer to the current layer the receive function | 204 | * @layr: Pointer to the current layer the receive function |
199 | * isimplemented for (this pointer). | 205 | * isimplemented for (this pointer). |
@@ -202,7 +208,7 @@ struct cflayer { | |||
202 | int (*transmit) (struct cflayer *layr, struct cfpkt *cfpkt); | 208 | int (*transmit) (struct cflayer *layr, struct cfpkt *cfpkt); |
203 | 209 | ||
204 | /* | 210 | /* |
205 | * cttrlcmd() - Control Function upwards in CAIF Stack. | 211 | * cttrlcmd() - Control Function upwards in CAIF Stack (non-blocking). |
206 | * Used for signaling responses (CAIF_CTRLCMD_*_RSP) | 212 | * Used for signaling responses (CAIF_CTRLCMD_*_RSP) |
207 | * and asynchronous events from the modem (CAIF_CTRLCMD_*_IND) | 213 | * and asynchronous events from the modem (CAIF_CTRLCMD_*_IND) |
208 | * | 214 | * |
diff --git a/include/net/caif/caif_shm.h b/include/net/caif/caif_shm.h new file mode 100644 index 000000000000..5bcce55438cf --- /dev/null +++ b/include/net/caif/caif_shm.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /* | ||
2 | * Copyright (C) ST-Ericsson AB 2010 | ||
3 | * Contact: Sjur Brendeland / sjur.brandeland@stericsson.com | ||
4 | * Author: Amarnath Revanna / amarnath.bangalore.revanna@stericsson.com | ||
5 | * License terms: GNU General Public License (GPL) version 2 | ||
6 | */ | ||
7 | |||
8 | #ifndef CAIF_SHM_H_ | ||
9 | #define CAIF_SHM_H_ | ||
10 | |||
11 | struct shmdev_layer { | ||
12 | u32 shm_base_addr; | ||
13 | u32 shm_total_sz; | ||
14 | u32 shm_id; | ||
15 | u32 shm_loopback; | ||
16 | void *hmbx; | ||
17 | int (*pshmdev_mbxsend) (u32 shm_id, u32 mbx_msg); | ||
18 | int (*pshmdev_mbxsetup) (void *pshmdrv_cb, | ||
19 | struct shmdev_layer *pshm_dev, void *pshm_drv); | ||
20 | struct net_device *pshm_netdev; | ||
21 | }; | ||
22 | |||
23 | extern int caif_shmcore_probe(struct shmdev_layer *pshm_dev); | ||
24 | extern void caif_shmcore_remove(struct net_device *pshm_netdev); | ||
25 | |||
26 | #endif | ||
diff --git a/include/net/caif/caif_spi.h b/include/net/caif/caif_spi.h index ce4570dff020..87c3d11b8e55 100644 --- a/include/net/caif/caif_spi.h +++ b/include/net/caif/caif_spi.h | |||
@@ -121,6 +121,8 @@ struct cfspi { | |||
121 | wait_queue_head_t wait; | 121 | wait_queue_head_t wait; |
122 | spinlock_t lock; | 122 | spinlock_t lock; |
123 | bool flow_stop; | 123 | bool flow_stop; |
124 | bool slave; | ||
125 | bool slave_talked; | ||
124 | #ifdef CONFIG_DEBUG_FS | 126 | #ifdef CONFIG_DEBUG_FS |
125 | enum cfspi_state dbg_state; | 127 | enum cfspi_state dbg_state; |
126 | u16 pcmd; | 128 | u16 pcmd; |
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h index bd646faffa47..3e93a4a4b677 100644 --- a/include/net/caif/cfcnfg.h +++ b/include/net/caif/cfcnfg.h | |||
@@ -46,6 +46,12 @@ enum cfcnfg_phy_preference { | |||
46 | }; | 46 | }; |
47 | 47 | ||
48 | /** | 48 | /** |
49 | * cfcnfg_create() - Get the CAIF configuration object given network. | ||
50 | * @net: Network for the CAIF configuration object. | ||
51 | */ | ||
52 | struct cfcnfg *get_cfcnfg(struct net *net); | ||
53 | |||
54 | /** | ||
49 | * cfcnfg_create() - Create the CAIF configuration object. | 55 | * cfcnfg_create() - Create the CAIF configuration object. |
50 | */ | 56 | */ |
51 | struct cfcnfg *cfcnfg_create(void); | 57 | struct cfcnfg *cfcnfg_create(void); |
@@ -65,8 +71,6 @@ void cfcnfg_remove(struct cfcnfg *cfg); | |||
65 | * @dev: Pointer to link layer device | 71 | * @dev: Pointer to link layer device |
66 | * @phy_layer: Specify the physical layer. The transmit function | 72 | * @phy_layer: Specify the physical layer. The transmit function |
67 | * MUST be set in the structure. | 73 | * MUST be set in the structure. |
68 | * @phyid: The assigned physical ID for this layer, used in | ||
69 | * cfcnfg_add_adapt_layer to specify PHY for the link. | ||
70 | * @pref: The phy (link layer) preference. | 74 | * @pref: The phy (link layer) preference. |
71 | * @fcs: Specify if checksum is used in CAIF Framing Layer. | 75 | * @fcs: Specify if checksum is used in CAIF Framing Layer. |
72 | * @stx: Specify if Start Of Frame eXtention is used. | 76 | * @stx: Specify if Start Of Frame eXtention is used. |
@@ -75,7 +79,7 @@ void cfcnfg_remove(struct cfcnfg *cfg); | |||
75 | void | 79 | void |
76 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, | 80 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, |
77 | struct net_device *dev, struct cflayer *phy_layer, | 81 | struct net_device *dev, struct cflayer *phy_layer, |
78 | u16 *phyid, enum cfcnfg_phy_preference pref, | 82 | enum cfcnfg_phy_preference pref, |
79 | bool fcs, bool stx); | 83 | bool fcs, bool stx); |
80 | 84 | ||
81 | /** | 85 | /** |
@@ -88,61 +92,12 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, | |||
88 | int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer); | 92 | int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer); |
89 | 93 | ||
90 | /** | 94 | /** |
91 | * cfcnfg_disconn_adapt_layer - Disconnects an adaptation layer. | 95 | * cfcnfg_set_phy_state() - Set the state of the physical interface device. |
92 | * | ||
93 | * @cnfg: Pointer to a CAIF configuration object, created by | ||
94 | * cfcnfg_create(). | ||
95 | * @adap_layer: Adaptation layer to be removed. | ||
96 | */ | ||
97 | int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg, | ||
98 | struct cflayer *adap_layer); | ||
99 | |||
100 | /** | ||
101 | * cfcnfg_release_adap_layer - Used by client to release the adaptation layer. | ||
102 | * | ||
103 | * @adap_layer: Adaptation layer. | ||
104 | */ | ||
105 | void cfcnfg_release_adap_layer(struct cflayer *adap_layer); | ||
106 | |||
107 | /** | ||
108 | * cfcnfg_add_adaptation_layer - Add an adaptation layer to the CAIF stack. | ||
109 | * | ||
110 | * The adaptation Layer is where the interface to application or higher-level | ||
111 | * driver functionality is implemented. | ||
112 | * | ||
113 | * @cnfg: Pointer to a CAIF configuration object, created by | ||
114 | * cfcnfg_create(). | ||
115 | * @param: Link setup parameters. | ||
116 | * @adap_layer: Specify the adaptation layer; the receive and | ||
117 | * flow-control functions MUST be set in the structure. | ||
118 | * @ifindex: Link layer interface index used for this connection. | ||
119 | * @proto_head: Protocol head-space needed by CAIF protocol, | ||
120 | * excluding link layer. | ||
121 | * @proto_tail: Protocol tail-space needed by CAIF protocol, | ||
122 | * excluding link layer. | ||
123 | */ | ||
124 | int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, | ||
125 | struct cfctrl_link_param *param, | ||
126 | struct cflayer *adap_layer, | ||
127 | int *ifindex, | ||
128 | int *proto_head, | ||
129 | int *proto_tail); | ||
130 | |||
131 | /** | ||
132 | * cfcnfg_get_phyid() - Get physical ID, given type. | ||
133 | * Returns one of the physical interfaces matching the given type. | ||
134 | * Zero if no match is found. | ||
135 | * @cnfg: Configuration object | ||
136 | * @phy_pref: Caif Link Layer preference | ||
137 | */ | ||
138 | struct dev_info *cfcnfg_get_phyid(struct cfcnfg *cnfg, | ||
139 | enum cfcnfg_phy_preference phy_pref); | ||
140 | |||
141 | /** | ||
142 | * cfcnfg_get_named() - Get the Physical Identifier of CAIF Link Layer | ||
143 | * @cnfg: Configuration object | 96 | * @cnfg: Configuration object |
144 | * @name: Name of the Physical Layer (Caif Link Layer) | 97 | * @phy_layer: Physical Layer representation |
98 | * @up: State of device | ||
145 | */ | 99 | */ |
146 | int cfcnfg_get_named(struct cfcnfg *cnfg, char *name); | 100 | int cfcnfg_set_phy_state(struct cfcnfg *cnfg, struct cflayer *phy_layer, |
101 | bool up); | ||
147 | 102 | ||
148 | #endif /* CFCNFG_H_ */ | 103 | #endif /* CFCNFG_H_ */ |
diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h index 9402543fc20d..9e5425b4a1d7 100644 --- a/include/net/caif/cfctrl.h +++ b/include/net/caif/cfctrl.h | |||
@@ -51,7 +51,7 @@ struct cfctrl_rsp { | |||
51 | void (*restart_rsp)(void); | 51 | void (*restart_rsp)(void); |
52 | void (*radioset_rsp)(void); | 52 | void (*radioset_rsp)(void); |
53 | void (*reject_rsp)(struct cflayer *layer, u8 linkid, | 53 | void (*reject_rsp)(struct cflayer *layer, u8 linkid, |
54 | struct cflayer *client_layer);; | 54 | struct cflayer *client_layer); |
55 | }; | 55 | }; |
56 | 56 | ||
57 | /* Link Setup Parameters for CAIF-Links. */ | 57 | /* Link Setup Parameters for CAIF-Links. */ |
@@ -121,19 +121,10 @@ int cfctrl_linkup_request(struct cflayer *cfctrl, | |||
121 | struct cflayer *user_layer); | 121 | struct cflayer *user_layer); |
122 | int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid, | 122 | int cfctrl_linkdown_req(struct cflayer *cfctrl, u8 linkid, |
123 | struct cflayer *client); | 123 | struct cflayer *client); |
124 | void cfctrl_sleep_req(struct cflayer *cfctrl); | 124 | |
125 | void cfctrl_wake_req(struct cflayer *cfctrl); | ||
126 | void cfctrl_getstartreason_req(struct cflayer *cfctrl); | ||
127 | struct cflayer *cfctrl_create(void); | 125 | struct cflayer *cfctrl_create(void); |
128 | void cfctrl_set_dnlayer(struct cflayer *this, struct cflayer *dn); | ||
129 | void cfctrl_set_uplayer(struct cflayer *this, struct cflayer *up); | ||
130 | struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer); | 126 | struct cfctrl_rsp *cfctrl_get_respfuncs(struct cflayer *layer); |
131 | bool cfctrl_req_eq(struct cfctrl_request_info *r1, | 127 | int cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer); |
132 | struct cfctrl_request_info *r2); | 128 | void cfctrl_remove(struct cflayer *layr); |
133 | void cfctrl_insert_req(struct cfctrl *ctrl, | ||
134 | struct cfctrl_request_info *req); | ||
135 | struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl, | ||
136 | struct cfctrl_request_info *req); | ||
137 | void cfctrl_cancel_req(struct cflayer *layr, struct cflayer *adap_layer); | ||
138 | 129 | ||
139 | #endif /* CFCTRL_H_ */ | 130 | #endif /* CFCTRL_H_ */ |
diff --git a/include/net/caif/cffrml.h b/include/net/caif/cffrml.h index 3f14d2e1ce61..afac1a48cce7 100644 --- a/include/net/caif/cffrml.h +++ b/include/net/caif/cffrml.h | |||
@@ -7,10 +7,15 @@ | |||
7 | #ifndef CFFRML_H_ | 7 | #ifndef CFFRML_H_ |
8 | #define CFFRML_H_ | 8 | #define CFFRML_H_ |
9 | #include <net/caif/caif_layer.h> | 9 | #include <net/caif/caif_layer.h> |
10 | #include <linux/netdevice.h> | ||
10 | 11 | ||
11 | struct cffrml; | 12 | struct cffrml; |
12 | struct cflayer *cffrml_create(u16 phyid, bool DoFCS); | 13 | struct cflayer *cffrml_create(u16 phyid, bool use_fcs); |
14 | void cffrml_free(struct cflayer *layr); | ||
13 | void cffrml_set_uplayer(struct cflayer *this, struct cflayer *up); | 15 | void cffrml_set_uplayer(struct cflayer *this, struct cflayer *up); |
14 | void cffrml_set_dnlayer(struct cflayer *this, struct cflayer *dn); | 16 | void cffrml_set_dnlayer(struct cflayer *this, struct cflayer *dn); |
17 | void cffrml_put(struct cflayer *layr); | ||
18 | void cffrml_hold(struct cflayer *layr); | ||
19 | int cffrml_refcnt_read(struct cflayer *layr); | ||
15 | 20 | ||
16 | #endif /* CFFRML_H_ */ | 21 | #endif /* CFFRML_H_ */ |
diff --git a/include/net/caif/cfmuxl.h b/include/net/caif/cfmuxl.h index 4e1b4f33423e..5847a196b8ad 100644 --- a/include/net/caif/cfmuxl.h +++ b/include/net/caif/cfmuxl.h | |||
@@ -16,7 +16,5 @@ int cfmuxl_set_uplayer(struct cflayer *layr, struct cflayer *up, u8 linkid); | |||
16 | struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid); | 16 | struct cflayer *cfmuxl_remove_dnlayer(struct cflayer *layr, u8 phyid); |
17 | int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid); | 17 | int cfmuxl_set_dnlayer(struct cflayer *layr, struct cflayer *up, u8 phyid); |
18 | struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid); | 18 | struct cflayer *cfmuxl_remove_uplayer(struct cflayer *layr, u8 linkid); |
19 | bool cfmuxl_is_phy_inuse(struct cflayer *layr, u8 phyid); | ||
20 | u8 cfmuxl_get_phyid(struct cflayer *layr, u8 channel_id); | ||
21 | 19 | ||
22 | #endif /* CFMUXL_H_ */ | 20 | #endif /* CFMUXL_H_ */ |
diff --git a/include/net/caif/cfpkt.h b/include/net/caif/cfpkt.h index fbc681beff52..6bd200a4754a 100644 --- a/include/net/caif/cfpkt.h +++ b/include/net/caif/cfpkt.h | |||
@@ -16,12 +16,6 @@ struct cfpkt; | |||
16 | */ | 16 | */ |
17 | struct cfpkt *cfpkt_create(u16 len); | 17 | struct cfpkt *cfpkt_create(u16 len); |
18 | 18 | ||
19 | /* Create a CAIF packet. | ||
20 | * data Data to copy. | ||
21 | * len Length of packet to be created | ||
22 | * @return New packet. | ||
23 | */ | ||
24 | struct cfpkt *cfpkt_create_uplink(const unsigned char *data, unsigned int len); | ||
25 | /* | 19 | /* |
26 | * Destroy a CAIF Packet. | 20 | * Destroy a CAIF Packet. |
27 | * pkt Packet to be destoyed. | 21 | * pkt Packet to be destoyed. |
@@ -181,22 +175,6 @@ u16 cfpkt_iterate(struct cfpkt *pkt, | |||
181 | u16 (*iter_func)(u16 chks, void *buf, u16 len), | 175 | u16 (*iter_func)(u16 chks, void *buf, u16 len), |
182 | u16 data); | 176 | u16 data); |
183 | 177 | ||
184 | /* Append by giving user access to packet buffer | ||
185 | * cfpkt Packet to append to | ||
186 | * buf Buffer inside pkt that user shall copy data into | ||
187 | * buflen Length of buffer and number of bytes added to packet | ||
188 | * @return 0 on error, 1 on success | ||
189 | */ | ||
190 | int cfpkt_raw_append(struct cfpkt *cfpkt, void **buf, unsigned int buflen); | ||
191 | |||
192 | /* Extract by giving user access to packet buffer | ||
193 | * cfpkt Packet to extract from | ||
194 | * buf Buffer inside pkt that user shall copy data from | ||
195 | * buflen Length of buffer and number of bytes removed from packet | ||
196 | * @return 0 on error, 1 on success | ||
197 | */ | ||
198 | int cfpkt_raw_extract(struct cfpkt *cfpkt, void **buf, unsigned int buflen); | ||
199 | |||
200 | /* Map from a "native" packet (e.g. Linux Socket Buffer) to a CAIF packet. | 178 | /* Map from a "native" packet (e.g. Linux Socket Buffer) to a CAIF packet. |
201 | * dir - Direction indicating whether this packet is to be sent or received. | 179 | * dir - Direction indicating whether this packet is to be sent or received. |
202 | * nativepkt - The native packet to be transformed to a CAIF packet | 180 | * nativepkt - The native packet to be transformed to a CAIF packet |
@@ -210,59 +188,6 @@ struct cfpkt *cfpkt_fromnative(enum caif_direction dir, void *nativepkt); | |||
210 | */ | 188 | */ |
211 | void *cfpkt_tonative(struct cfpkt *pkt); | 189 | void *cfpkt_tonative(struct cfpkt *pkt); |
212 | 190 | ||
213 | /* | ||
214 | * Insert a packet in the packet queue. | ||
215 | * pktq Packet queue to insert into | ||
216 | * pkt Packet to be inserted in queue | ||
217 | * prio Priority of packet | ||
218 | */ | ||
219 | void cfpkt_queue(struct cfpktq *pktq, struct cfpkt *pkt, | ||
220 | unsigned short prio); | ||
221 | |||
222 | /* | ||
223 | * Remove a packet from the packet queue. | ||
224 | * pktq Packet queue to fetch packets from. | ||
225 | * @return Dequeued packet. | ||
226 | */ | ||
227 | struct cfpkt *cfpkt_dequeue(struct cfpktq *pktq); | ||
228 | |||
229 | /* | ||
230 | * Peek into a packet from the packet queue. | ||
231 | * pktq Packet queue to fetch packets from. | ||
232 | * @return Peeked packet. | ||
233 | */ | ||
234 | struct cfpkt *cfpkt_qpeek(struct cfpktq *pktq); | ||
235 | |||
236 | /* | ||
237 | * Initiates the packet queue. | ||
238 | * @return Pointer to new packet queue. | ||
239 | */ | ||
240 | struct cfpktq *cfpktq_create(void); | ||
241 | |||
242 | /* | ||
243 | * Get the number of packets in the queue. | ||
244 | * pktq Packet queue to fetch count from. | ||
245 | * @return Number of packets in queue. | ||
246 | */ | ||
247 | int cfpkt_qcount(struct cfpktq *pktq); | ||
248 | |||
249 | /* | ||
250 | * Put content of packet into buffer for debuging purposes. | ||
251 | * pkt Packet to copy data from | ||
252 | * buf Buffer to copy data into | ||
253 | * buflen Length of data to copy | ||
254 | * @return Pointer to copied data | ||
255 | */ | ||
256 | char *cfpkt_log_pkt(struct cfpkt *pkt, char *buf, int buflen); | ||
257 | |||
258 | /* | ||
259 | * Clones a packet and releases the original packet. | ||
260 | * This is used for taking ownership of a packet e.g queueing. | ||
261 | * pkt Packet to clone and release. | ||
262 | * @return Cloned packet. | ||
263 | */ | ||
264 | struct cfpkt *cfpkt_clone_release(struct cfpkt *pkt); | ||
265 | |||
266 | 191 | ||
267 | /* | 192 | /* |
268 | * Returns packet information for a packet. | 193 | * Returns packet information for a packet. |
@@ -270,5 +195,4 @@ struct cfpkt *cfpkt_clone_release(struct cfpkt *pkt); | |||
270 | * @return Packet information | 195 | * @return Packet information |
271 | */ | 196 | */ |
272 | struct caif_payload_info *cfpkt_info(struct cfpkt *pkt); | 197 | struct caif_payload_info *cfpkt_info(struct cfpkt *pkt); |
273 | /*! @} */ | ||
274 | #endif /* CFPKT_H_ */ | 198 | #endif /* CFPKT_H_ */ |
diff --git a/include/net/caif/cfsrvl.h b/include/net/caif/cfsrvl.h index b1fa87ee0992..0f5905241843 100644 --- a/include/net/caif/cfsrvl.h +++ b/include/net/caif/cfsrvl.h | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <linux/stddef.h> | 10 | #include <linux/stddef.h> |
11 | #include <linux/types.h> | 11 | #include <linux/types.h> |
12 | #include <linux/kref.h> | 12 | #include <linux/kref.h> |
13 | #include <linux/rculist.h> | ||
13 | 14 | ||
14 | struct cfsrvl { | 15 | struct cfsrvl { |
15 | struct cflayer layer; | 16 | struct cflayer layer; |
@@ -17,12 +18,13 @@ struct cfsrvl { | |||
17 | bool phy_flow_on; | 18 | bool phy_flow_on; |
18 | bool modem_flow_on; | 19 | bool modem_flow_on; |
19 | bool supports_flowctrl; | 20 | bool supports_flowctrl; |
20 | void (*release)(struct kref *); | 21 | void (*release)(struct cflayer *layer); |
21 | struct dev_info dev_info; | 22 | struct dev_info dev_info; |
22 | struct kref ref; | 23 | void (*hold)(struct cflayer *lyr); |
24 | void (*put)(struct cflayer *lyr); | ||
25 | struct rcu_head rcu; | ||
23 | }; | 26 | }; |
24 | 27 | ||
25 | void cfsrvl_release(struct kref *kref); | ||
26 | struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); | 28 | struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); |
27 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); | 29 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); |
28 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); | 30 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); |
@@ -30,8 +32,12 @@ struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info); | |||
30 | struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, | 32 | struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, |
31 | int mtu_size); | 33 | int mtu_size); |
32 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); | 34 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); |
35 | |||
36 | void cfsrvl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, | ||
37 | int phyid); | ||
38 | |||
33 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); | 39 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); |
34 | void cfservl_destroy(struct cflayer *layer); | 40 | |
35 | void cfsrvl_init(struct cfsrvl *service, | 41 | void cfsrvl_init(struct cfsrvl *service, |
36 | u8 channel_id, | 42 | u8 channel_id, |
37 | struct dev_info *dev_info, | 43 | struct dev_info *dev_info, |
@@ -41,23 +47,19 @@ u8 cfsrvl_getphyid(struct cflayer *layer); | |||
41 | 47 | ||
42 | static inline void cfsrvl_get(struct cflayer *layr) | 48 | static inline void cfsrvl_get(struct cflayer *layr) |
43 | { | 49 | { |
44 | struct cfsrvl *s; | 50 | struct cfsrvl *s = container_of(layr, struct cfsrvl, layer); |
45 | if (layr == NULL) | 51 | if (layr == NULL || layr->up == NULL || s->hold == NULL) |
46 | return; | 52 | return; |
47 | s = container_of(layr, struct cfsrvl, layer); | 53 | |
48 | kref_get(&s->ref); | 54 | s->hold(layr->up); |
49 | } | 55 | } |
50 | 56 | ||
51 | static inline void cfsrvl_put(struct cflayer *layr) | 57 | static inline void cfsrvl_put(struct cflayer *layr) |
52 | { | 58 | { |
53 | struct cfsrvl *s; | 59 | struct cfsrvl *s = container_of(layr, struct cfsrvl, layer); |
54 | if (layr == NULL) | 60 | if (layr == NULL || layr->up == NULL || s->hold == NULL) |
55 | return; | 61 | return; |
56 | s = container_of(layr, struct cfsrvl, layer); | ||
57 | 62 | ||
58 | WARN_ON(!s->release); | 63 | s->put(layr->up); |
59 | if (s->release) | ||
60 | kref_put(&s->ref, s->release); | ||
61 | } | 64 | } |
62 | |||
63 | #endif /* CFSRVL_H_ */ | 65 | #endif /* CFSRVL_H_ */ |
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 2fd06c60ffbb..396e8fc8910e 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -25,6 +25,43 @@ | |||
25 | #include <linux/wireless.h> | 25 | #include <linux/wireless.h> |
26 | 26 | ||
27 | 27 | ||
28 | /** | ||
29 | * DOC: Introduction | ||
30 | * | ||
31 | * cfg80211 is the configuration API for 802.11 devices in Linux. It bridges | ||
32 | * userspace and drivers, and offers some utility functionality associated | ||
33 | * with 802.11. cfg80211 must, directly or indirectly via mac80211, be used | ||
34 | * by all modern wireless drivers in Linux, so that they offer a consistent | ||
35 | * API through nl80211. For backward compatibility, cfg80211 also offers | ||
36 | * wireless extensions to userspace, but hides them from drivers completely. | ||
37 | * | ||
38 | * Additionally, cfg80211 contains code to help enforce regulatory spectrum | ||
39 | * use restrictions. | ||
40 | */ | ||
41 | |||
42 | |||
43 | /** | ||
44 | * DOC: Device registration | ||
45 | * | ||
46 | * In order for a driver to use cfg80211, it must register the hardware device | ||
47 | * with cfg80211. This happens through a number of hardware capability structs | ||
48 | * described below. | ||
49 | * | ||
50 | * The fundamental structure for each device is the 'wiphy', of which each | ||
51 | * instance describes a physical wireless device connected to the system. Each | ||
52 | * such wiphy can have zero, one, or many virtual interfaces associated with | ||
53 | * it, which need to be identified as such by pointing the network interface's | ||
54 | * @ieee80211_ptr pointer to a &struct wireless_dev which further describes | ||
55 | * the wireless part of the interface, normally this struct is embedded in the | ||
56 | * network interface's private data area. Drivers can optionally allow creating | ||
57 | * or destroying virtual interfaces on the fly, but without at least one or the | ||
58 | * ability to create some the wireless device isn't useful. | ||
59 | * | ||
60 | * Each wiphy structure contains device capability information, and also has | ||
61 | * a pointer to the various operations the driver offers. The definitions and | ||
62 | * structures here describe these capabilities in detail. | ||
63 | */ | ||
64 | |||
28 | /* | 65 | /* |
29 | * wireless hardware capability structures | 66 | * wireless hardware capability structures |
30 | */ | 67 | */ |
@@ -205,14 +242,25 @@ struct ieee80211_supported_band { | |||
205 | */ | 242 | */ |
206 | 243 | ||
207 | /** | 244 | /** |
245 | * DOC: Actions and configuration | ||
246 | * | ||
247 | * Each wireless device and each virtual interface offer a set of configuration | ||
248 | * operations and other actions that are invoked by userspace. Each of these | ||
249 | * actions is described in the operations structure, and the parameters these | ||
250 | * operations use are described separately. | ||
251 | * | ||
252 | * Additionally, some operations are asynchronous and expect to get status | ||
253 | * information via some functions that drivers need to call. | ||
254 | * | ||
255 | * Scanning and BSS list handling with its associated functionality is described | ||
256 | * in a separate chapter. | ||
257 | */ | ||
258 | |||
259 | /** | ||
208 | * struct vif_params - describes virtual interface parameters | 260 | * struct vif_params - describes virtual interface parameters |
209 | * @mesh_id: mesh ID to use | ||
210 | * @mesh_id_len: length of the mesh ID | ||
211 | * @use_4addr: use 4-address frames | 261 | * @use_4addr: use 4-address frames |
212 | */ | 262 | */ |
213 | struct vif_params { | 263 | struct vif_params { |
214 | u8 *mesh_id; | ||
215 | int mesh_id_len; | ||
216 | int use_4addr; | 264 | int use_4addr; |
217 | }; | 265 | }; |
218 | 266 | ||
@@ -241,12 +289,24 @@ struct key_params { | |||
241 | * enum survey_info_flags - survey information flags | 289 | * enum survey_info_flags - survey information flags |
242 | * | 290 | * |
243 | * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in | 291 | * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in |
292 | * @SURVEY_INFO_IN_USE: channel is currently being used | ||
293 | * @SURVEY_INFO_CHANNEL_TIME: channel active time (in ms) was filled in | ||
294 | * @SURVEY_INFO_CHANNEL_TIME_BUSY: channel busy time was filled in | ||
295 | * @SURVEY_INFO_CHANNEL_TIME_EXT_BUSY: extension channel busy time was filled in | ||
296 | * @SURVEY_INFO_CHANNEL_TIME_RX: channel receive time was filled in | ||
297 | * @SURVEY_INFO_CHANNEL_TIME_TX: channel transmit time was filled in | ||
244 | * | 298 | * |
245 | * Used by the driver to indicate which info in &struct survey_info | 299 | * Used by the driver to indicate which info in &struct survey_info |
246 | * it has filled in during the get_survey(). | 300 | * it has filled in during the get_survey(). |
247 | */ | 301 | */ |
248 | enum survey_info_flags { | 302 | enum survey_info_flags { |
249 | SURVEY_INFO_NOISE_DBM = 1<<0, | 303 | SURVEY_INFO_NOISE_DBM = 1<<0, |
304 | SURVEY_INFO_IN_USE = 1<<1, | ||
305 | SURVEY_INFO_CHANNEL_TIME = 1<<2, | ||
306 | SURVEY_INFO_CHANNEL_TIME_BUSY = 1<<3, | ||
307 | SURVEY_INFO_CHANNEL_TIME_EXT_BUSY = 1<<4, | ||
308 | SURVEY_INFO_CHANNEL_TIME_RX = 1<<5, | ||
309 | SURVEY_INFO_CHANNEL_TIME_TX = 1<<6, | ||
250 | }; | 310 | }; |
251 | 311 | ||
252 | /** | 312 | /** |
@@ -256,6 +316,11 @@ enum survey_info_flags { | |||
256 | * @filled: bitflag of flags from &enum survey_info_flags | 316 | * @filled: bitflag of flags from &enum survey_info_flags |
257 | * @noise: channel noise in dBm. This and all following fields are | 317 | * @noise: channel noise in dBm. This and all following fields are |
258 | * optional | 318 | * optional |
319 | * @channel_time: amount of time in ms the radio spent on the channel | ||
320 | * @channel_time_busy: amount of time the primary channel was sensed busy | ||
321 | * @channel_time_ext_busy: amount of time the extension channel was sensed busy | ||
322 | * @channel_time_rx: amount of time the radio spent receiving data | ||
323 | * @channel_time_tx: amount of time the radio spent transmitting data | ||
259 | * | 324 | * |
260 | * Used by dump_survey() to report back per-channel survey information. | 325 | * Used by dump_survey() to report back per-channel survey information. |
261 | * | 326 | * |
@@ -264,6 +329,11 @@ enum survey_info_flags { | |||
264 | */ | 329 | */ |
265 | struct survey_info { | 330 | struct survey_info { |
266 | struct ieee80211_channel *channel; | 331 | struct ieee80211_channel *channel; |
332 | u64 channel_time; | ||
333 | u64 channel_time_busy; | ||
334 | u64 channel_time_ext_busy; | ||
335 | u64 channel_time_rx; | ||
336 | u64 channel_time_tx; | ||
267 | u32 filled; | 337 | u32 filled; |
268 | s8 noise; | 338 | s8 noise; |
269 | }; | 339 | }; |
@@ -317,6 +387,7 @@ enum plink_actions { | |||
317 | * @listen_interval: listen interval or -1 for no change | 387 | * @listen_interval: listen interval or -1 for no change |
318 | * @aid: AID or zero for no change | 388 | * @aid: AID or zero for no change |
319 | * @plink_action: plink action to take | 389 | * @plink_action: plink action to take |
390 | * @plink_state: set the peer link state for a station | ||
320 | * @ht_capa: HT capabilities of station | 391 | * @ht_capa: HT capabilities of station |
321 | */ | 392 | */ |
322 | struct station_parameters { | 393 | struct station_parameters { |
@@ -327,6 +398,7 @@ struct station_parameters { | |||
327 | u16 aid; | 398 | u16 aid; |
328 | u8 supported_rates_len; | 399 | u8 supported_rates_len; |
329 | u8 plink_action; | 400 | u8 plink_action; |
401 | u8 plink_state; | ||
330 | struct ieee80211_ht_cap *ht_capa; | 402 | struct ieee80211_ht_cap *ht_capa; |
331 | }; | 403 | }; |
332 | 404 | ||
@@ -343,10 +415,17 @@ struct station_parameters { | |||
343 | * @STATION_INFO_PLID: @plid filled | 415 | * @STATION_INFO_PLID: @plid filled |
344 | * @STATION_INFO_PLINK_STATE: @plink_state filled | 416 | * @STATION_INFO_PLINK_STATE: @plink_state filled |
345 | * @STATION_INFO_SIGNAL: @signal filled | 417 | * @STATION_INFO_SIGNAL: @signal filled |
346 | * @STATION_INFO_TX_BITRATE: @tx_bitrate fields are filled | 418 | * @STATION_INFO_TX_BITRATE: @txrate fields are filled |
347 | * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs) | 419 | * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs) |
348 | * @STATION_INFO_RX_PACKETS: @rx_packets filled | 420 | * @STATION_INFO_RX_PACKETS: @rx_packets filled |
349 | * @STATION_INFO_TX_PACKETS: @tx_packets filled | 421 | * @STATION_INFO_TX_PACKETS: @tx_packets filled |
422 | * @STATION_INFO_TX_RETRIES: @tx_retries filled | ||
423 | * @STATION_INFO_TX_FAILED: @tx_failed filled | ||
424 | * @STATION_INFO_RX_DROP_MISC: @rx_dropped_misc filled | ||
425 | * @STATION_INFO_SIGNAL_AVG: @signal_avg filled | ||
426 | * @STATION_INFO_RX_BITRATE: @rxrate fields are filled | ||
427 | * @STATION_INFO_BSS_PARAM: @bss_param filled | ||
428 | * @STATION_INFO_CONNECTED_TIME: @connected_time filled | ||
350 | */ | 429 | */ |
351 | enum station_info_flags { | 430 | enum station_info_flags { |
352 | STATION_INFO_INACTIVE_TIME = 1<<0, | 431 | STATION_INFO_INACTIVE_TIME = 1<<0, |
@@ -359,6 +438,13 @@ enum station_info_flags { | |||
359 | STATION_INFO_TX_BITRATE = 1<<7, | 438 | STATION_INFO_TX_BITRATE = 1<<7, |
360 | STATION_INFO_RX_PACKETS = 1<<8, | 439 | STATION_INFO_RX_PACKETS = 1<<8, |
361 | STATION_INFO_TX_PACKETS = 1<<9, | 440 | STATION_INFO_TX_PACKETS = 1<<9, |
441 | STATION_INFO_TX_RETRIES = 1<<10, | ||
442 | STATION_INFO_TX_FAILED = 1<<11, | ||
443 | STATION_INFO_RX_DROP_MISC = 1<<12, | ||
444 | STATION_INFO_SIGNAL_AVG = 1<<13, | ||
445 | STATION_INFO_RX_BITRATE = 1<<14, | ||
446 | STATION_INFO_BSS_PARAM = 1<<15, | ||
447 | STATION_INFO_CONNECTED_TIME = 1<<16 | ||
362 | }; | 448 | }; |
363 | 449 | ||
364 | /** | 450 | /** |
@@ -393,11 +479,43 @@ struct rate_info { | |||
393 | }; | 479 | }; |
394 | 480 | ||
395 | /** | 481 | /** |
482 | * enum station_info_rate_flags - bitrate info flags | ||
483 | * | ||
484 | * Used by the driver to indicate the specific rate transmission | ||
485 | * type for 802.11n transmissions. | ||
486 | * | ||
487 | * @BSS_PARAM_FLAGS_CTS_PROT: whether CTS protection is enabled | ||
488 | * @BSS_PARAM_FLAGS_SHORT_PREAMBLE: whether short preamble is enabled | ||
489 | * @BSS_PARAM_FLAGS_SHORT_SLOT_TIME: whether short slot time is enabled | ||
490 | */ | ||
491 | enum bss_param_flags { | ||
492 | BSS_PARAM_FLAGS_CTS_PROT = 1<<0, | ||
493 | BSS_PARAM_FLAGS_SHORT_PREAMBLE = 1<<1, | ||
494 | BSS_PARAM_FLAGS_SHORT_SLOT_TIME = 1<<2, | ||
495 | }; | ||
496 | |||
497 | /** | ||
498 | * struct sta_bss_parameters - BSS parameters for the attached station | ||
499 | * | ||
500 | * Information about the currently associated BSS | ||
501 | * | ||
502 | * @flags: bitflag of flags from &enum bss_param_flags | ||
503 | * @dtim_period: DTIM period for the BSS | ||
504 | * @beacon_interval: beacon interval | ||
505 | */ | ||
506 | struct sta_bss_parameters { | ||
507 | u8 flags; | ||
508 | u8 dtim_period; | ||
509 | u16 beacon_interval; | ||
510 | }; | ||
511 | |||
512 | /** | ||
396 | * struct station_info - station information | 513 | * struct station_info - station information |
397 | * | 514 | * |
398 | * Station information filled by driver for get_station() and dump_station. | 515 | * Station information filled by driver for get_station() and dump_station. |
399 | * | 516 | * |
400 | * @filled: bitflag of flags from &enum station_info_flags | 517 | * @filled: bitflag of flags from &enum station_info_flags |
518 | * @connected_time: time(in secs) since a station is last connected | ||
401 | * @inactive_time: time since last station activity (tx/rx) in milliseconds | 519 | * @inactive_time: time since last station activity (tx/rx) in milliseconds |
402 | * @rx_bytes: bytes received from this station | 520 | * @rx_bytes: bytes received from this station |
403 | * @tx_bytes: bytes transmitted to this station | 521 | * @tx_bytes: bytes transmitted to this station |
@@ -405,9 +523,15 @@ struct rate_info { | |||
405 | * @plid: mesh peer link id | 523 | * @plid: mesh peer link id |
406 | * @plink_state: mesh peer link state | 524 | * @plink_state: mesh peer link state |
407 | * @signal: signal strength of last received packet in dBm | 525 | * @signal: signal strength of last received packet in dBm |
408 | * @txrate: current unicast bitrate to this station | 526 | * @signal_avg: signal strength average in dBm |
527 | * @txrate: current unicast bitrate from this station | ||
528 | * @rxrate: current unicast bitrate to this station | ||
409 | * @rx_packets: packets received from this station | 529 | * @rx_packets: packets received from this station |
410 | * @tx_packets: packets transmitted to this station | 530 | * @tx_packets: packets transmitted to this station |
531 | * @tx_retries: cumulative retry counts | ||
532 | * @tx_failed: number of failed transmissions (retries exceeded, no ACK) | ||
533 | * @rx_dropped_misc: Dropped for un-specified reason. | ||
534 | * @bss_param: current BSS parameters | ||
411 | * @generation: generation number for nl80211 dumps. | 535 | * @generation: generation number for nl80211 dumps. |
412 | * This number should increase every time the list of stations | 536 | * This number should increase every time the list of stations |
413 | * changes, i.e. when a station is added or removed, so that | 537 | * changes, i.e. when a station is added or removed, so that |
@@ -415,6 +539,7 @@ struct rate_info { | |||
415 | */ | 539 | */ |
416 | struct station_info { | 540 | struct station_info { |
417 | u32 filled; | 541 | u32 filled; |
542 | u32 connected_time; | ||
418 | u32 inactive_time; | 543 | u32 inactive_time; |
419 | u32 rx_bytes; | 544 | u32 rx_bytes; |
420 | u32 tx_bytes; | 545 | u32 tx_bytes; |
@@ -422,9 +547,15 @@ struct station_info { | |||
422 | u16 plid; | 547 | u16 plid; |
423 | u8 plink_state; | 548 | u8 plink_state; |
424 | s8 signal; | 549 | s8 signal; |
550 | s8 signal_avg; | ||
425 | struct rate_info txrate; | 551 | struct rate_info txrate; |
552 | struct rate_info rxrate; | ||
426 | u32 rx_packets; | 553 | u32 rx_packets; |
427 | u32 tx_packets; | 554 | u32 tx_packets; |
555 | u32 tx_retries; | ||
556 | u32 tx_failed; | ||
557 | u32 rx_dropped_misc; | ||
558 | struct sta_bss_parameters bss_param; | ||
428 | 559 | ||
429 | int generation; | 560 | int generation; |
430 | }; | 561 | }; |
@@ -519,6 +650,8 @@ struct mpath_info { | |||
519 | * (or NULL for no change) | 650 | * (or NULL for no change) |
520 | * @basic_rates_len: number of basic rates | 651 | * @basic_rates_len: number of basic rates |
521 | * @ap_isolate: do not forward packets between connected stations | 652 | * @ap_isolate: do not forward packets between connected stations |
653 | * @ht_opmode: HT Operation mode | ||
654 | * (u16 = opmode, -1 = do not change) | ||
522 | */ | 655 | */ |
523 | struct bss_parameters { | 656 | struct bss_parameters { |
524 | int use_cts_prot; | 657 | int use_cts_prot; |
@@ -527,8 +660,14 @@ struct bss_parameters { | |||
527 | u8 *basic_rates; | 660 | u8 *basic_rates; |
528 | u8 basic_rates_len; | 661 | u8 basic_rates_len; |
529 | int ap_isolate; | 662 | int ap_isolate; |
663 | int ht_opmode; | ||
530 | }; | 664 | }; |
531 | 665 | ||
666 | /* | ||
667 | * struct mesh_config - 802.11s mesh configuration | ||
668 | * | ||
669 | * These parameters can be changed while the mesh is active. | ||
670 | */ | ||
532 | struct mesh_config { | 671 | struct mesh_config { |
533 | /* Timeouts in ms */ | 672 | /* Timeouts in ms */ |
534 | /* Mesh plink management parameters */ | 673 | /* Mesh plink management parameters */ |
@@ -538,6 +677,8 @@ struct mesh_config { | |||
538 | u16 dot11MeshMaxPeerLinks; | 677 | u16 dot11MeshMaxPeerLinks; |
539 | u8 dot11MeshMaxRetries; | 678 | u8 dot11MeshMaxRetries; |
540 | u8 dot11MeshTTL; | 679 | u8 dot11MeshTTL; |
680 | /* ttl used in path selection information elements */ | ||
681 | u8 element_ttl; | ||
541 | bool auto_open_plinks; | 682 | bool auto_open_plinks; |
542 | /* HWMP parameters */ | 683 | /* HWMP parameters */ |
543 | u8 dot11MeshHWMPmaxPREQretries; | 684 | u8 dot11MeshHWMPmaxPREQretries; |
@@ -550,6 +691,30 @@ struct mesh_config { | |||
550 | }; | 691 | }; |
551 | 692 | ||
552 | /** | 693 | /** |
694 | * struct mesh_setup - 802.11s mesh setup configuration | ||
695 | * @mesh_id: the mesh ID | ||
696 | * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes | ||
697 | * @path_sel_proto: which path selection protocol to use | ||
698 | * @path_metric: which metric to use | ||
699 | * @ie: vendor information elements (optional) | ||
700 | * @ie_len: length of vendor information elements | ||
701 | * @is_authenticated: this mesh requires authentication | ||
702 | * @is_secure: this mesh uses security | ||
703 | * | ||
704 | * These parameters are fixed when the mesh is created. | ||
705 | */ | ||
706 | struct mesh_setup { | ||
707 | const u8 *mesh_id; | ||
708 | u8 mesh_id_len; | ||
709 | u8 path_sel_proto; | ||
710 | u8 path_metric; | ||
711 | const u8 *ie; | ||
712 | u8 ie_len; | ||
713 | bool is_authenticated; | ||
714 | bool is_secure; | ||
715 | }; | ||
716 | |||
717 | /** | ||
553 | * struct ieee80211_txq_params - TX queue parameters | 718 | * struct ieee80211_txq_params - TX queue parameters |
554 | * @queue: TX queue identifier (NL80211_TXQ_Q_*) | 719 | * @queue: TX queue identifier (NL80211_TXQ_Q_*) |
555 | * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled | 720 | * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled |
@@ -570,8 +735,28 @@ struct ieee80211_txq_params { | |||
570 | /* from net/wireless.h */ | 735 | /* from net/wireless.h */ |
571 | struct wiphy; | 736 | struct wiphy; |
572 | 737 | ||
573 | /* from net/ieee80211.h */ | 738 | /** |
574 | struct ieee80211_channel; | 739 | * DOC: Scanning and BSS list handling |
740 | * | ||
741 | * The scanning process itself is fairly simple, but cfg80211 offers quite | ||
742 | * a bit of helper functionality. To start a scan, the scan operation will | ||
743 | * be invoked with a scan definition. This scan definition contains the | ||
744 | * channels to scan, and the SSIDs to send probe requests for (including the | ||
745 | * wildcard, if desired). A passive scan is indicated by having no SSIDs to | ||
746 | * probe. Additionally, a scan request may contain extra information elements | ||
747 | * that should be added to the probe request. The IEs are guaranteed to be | ||
748 | * well-formed, and will not exceed the maximum length the driver advertised | ||
749 | * in the wiphy structure. | ||
750 | * | ||
751 | * When scanning finds a BSS, cfg80211 needs to be notified of that, because | ||
752 | * it is responsible for maintaining the BSS list; the driver should not | ||
753 | * maintain a list itself. For this notification, various functions exist. | ||
754 | * | ||
755 | * Since drivers do not maintain a BSS list, there are also a number of | ||
756 | * functions to search for a BSS and obtain information about it from the | ||
757 | * BSS structure cfg80211 maintains. The BSS list is also made available | ||
758 | * to userspace. | ||
759 | */ | ||
575 | 760 | ||
576 | /** | 761 | /** |
577 | * struct cfg80211_ssid - SSID description | 762 | * struct cfg80211_ssid - SSID description |
@@ -613,6 +798,35 @@ struct cfg80211_scan_request { | |||
613 | }; | 798 | }; |
614 | 799 | ||
615 | /** | 800 | /** |
801 | * struct cfg80211_sched_scan_request - scheduled scan request description | ||
802 | * | ||
803 | * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans) | ||
804 | * @n_ssids: number of SSIDs | ||
805 | * @n_channels: total number of channels to scan | ||
806 | * @interval: interval between each scheduled scan cycle | ||
807 | * @ie: optional information element(s) to add into Probe Request or %NULL | ||
808 | * @ie_len: length of ie in octets | ||
809 | * @wiphy: the wiphy this was for | ||
810 | * @dev: the interface | ||
811 | * @channels: channels to scan | ||
812 | */ | ||
813 | struct cfg80211_sched_scan_request { | ||
814 | struct cfg80211_ssid *ssids; | ||
815 | int n_ssids; | ||
816 | u32 n_channels; | ||
817 | u32 interval; | ||
818 | const u8 *ie; | ||
819 | size_t ie_len; | ||
820 | |||
821 | /* internal */ | ||
822 | struct wiphy *wiphy; | ||
823 | struct net_device *dev; | ||
824 | |||
825 | /* keep last */ | ||
826 | struct ieee80211_channel *channels[0]; | ||
827 | }; | ||
828 | |||
829 | /** | ||
616 | * enum cfg80211_signal_type - signal type | 830 | * enum cfg80211_signal_type - signal type |
617 | * | 831 | * |
618 | * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available | 832 | * @CFG80211_SIGNAL_TYPE_NONE: no signal strength information available |
@@ -691,6 +905,10 @@ const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie); | |||
691 | * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is | 905 | * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is |
692 | * required to assume that the port is unauthorized until authorized by | 906 | * required to assume that the port is unauthorized until authorized by |
693 | * user space. Otherwise, port is marked authorized by default. | 907 | * user space. Otherwise, port is marked authorized by default. |
908 | * @control_port_ethertype: the control port protocol that should be | ||
909 | * allowed through even on unauthorized ports | ||
910 | * @control_port_no_encrypt: TRUE to prevent encryption of control port | ||
911 | * protocol frames. | ||
694 | */ | 912 | */ |
695 | struct cfg80211_crypto_settings { | 913 | struct cfg80211_crypto_settings { |
696 | u32 wpa_versions; | 914 | u32 wpa_versions; |
@@ -700,6 +918,8 @@ struct cfg80211_crypto_settings { | |||
700 | int n_akm_suites; | 918 | int n_akm_suites; |
701 | u32 akm_suites[NL80211_MAX_NR_AKM_SUITES]; | 919 | u32 akm_suites[NL80211_MAX_NR_AKM_SUITES]; |
702 | bool control_port; | 920 | bool control_port; |
921 | __be16 control_port_ethertype; | ||
922 | bool control_port_no_encrypt; | ||
703 | }; | 923 | }; |
704 | 924 | ||
705 | /** | 925 | /** |
@@ -811,6 +1031,7 @@ struct cfg80211_disassoc_request { | |||
811 | * @privacy: this is a protected network, keys will be configured | 1031 | * @privacy: this is a protected network, keys will be configured |
812 | * after joining | 1032 | * after joining |
813 | * @basic_rates: bitmap of basic rates to use when creating the IBSS | 1033 | * @basic_rates: bitmap of basic rates to use when creating the IBSS |
1034 | * @mcast_rate: per-band multicast rate index + 1 (0: disabled) | ||
814 | */ | 1035 | */ |
815 | struct cfg80211_ibss_params { | 1036 | struct cfg80211_ibss_params { |
816 | u8 *ssid; | 1037 | u8 *ssid; |
@@ -822,6 +1043,7 @@ struct cfg80211_ibss_params { | |||
822 | u32 basic_rates; | 1043 | u32 basic_rates; |
823 | bool channel_fixed; | 1044 | bool channel_fixed; |
824 | bool privacy; | 1045 | bool privacy; |
1046 | int mcast_rate[IEEE80211_NUM_BANDS]; | ||
825 | }; | 1047 | }; |
826 | 1048 | ||
827 | /** | 1049 | /** |
@@ -900,6 +1122,38 @@ struct cfg80211_pmksa { | |||
900 | }; | 1122 | }; |
901 | 1123 | ||
902 | /** | 1124 | /** |
1125 | * struct cfg80211_wowlan_trig_pkt_pattern - packet pattern | ||
1126 | * @mask: bitmask where to match pattern and where to ignore bytes, | ||
1127 | * one bit per byte, in same format as nl80211 | ||
1128 | * @pattern: bytes to match where bitmask is 1 | ||
1129 | * @pattern_len: length of pattern (in bytes) | ||
1130 | * | ||
1131 | * Internal note: @mask and @pattern are allocated in one chunk of | ||
1132 | * memory, free @mask only! | ||
1133 | */ | ||
1134 | struct cfg80211_wowlan_trig_pkt_pattern { | ||
1135 | u8 *mask, *pattern; | ||
1136 | int pattern_len; | ||
1137 | }; | ||
1138 | |||
1139 | /** | ||
1140 | * struct cfg80211_wowlan - Wake on Wireless-LAN support info | ||
1141 | * | ||
1142 | * This structure defines the enabled WoWLAN triggers for the device. | ||
1143 | * @any: wake up on any activity -- special trigger if device continues | ||
1144 | * operating as normal during suspend | ||
1145 | * @disconnect: wake up if getting disconnected | ||
1146 | * @magic_pkt: wake up on receiving magic packet | ||
1147 | * @patterns: wake up on receiving packet matching a pattern | ||
1148 | * @n_patterns: number of patterns | ||
1149 | */ | ||
1150 | struct cfg80211_wowlan { | ||
1151 | bool any, disconnect, magic_pkt; | ||
1152 | struct cfg80211_wowlan_trig_pkt_pattern *patterns; | ||
1153 | int n_patterns; | ||
1154 | }; | ||
1155 | |||
1156 | /** | ||
903 | * struct cfg80211_ops - backend description for wireless configuration | 1157 | * struct cfg80211_ops - backend description for wireless configuration |
904 | * | 1158 | * |
905 | * This struct is registered by fullmac card drivers and/or wireless stacks | 1159 | * This struct is registered by fullmac card drivers and/or wireless stacks |
@@ -912,12 +1166,15 @@ struct cfg80211_pmksa { | |||
912 | * wireless extensions but this is subject to reevaluation as soon as this | 1166 | * wireless extensions but this is subject to reevaluation as soon as this |
913 | * code is used more widely and we have a first user without wext. | 1167 | * code is used more widely and we have a first user without wext. |
914 | * | 1168 | * |
915 | * @suspend: wiphy device needs to be suspended | 1169 | * @suspend: wiphy device needs to be suspended. The variable @wow will |
1170 | * be %NULL or contain the enabled Wake-on-Wireless triggers that are | ||
1171 | * configured for the device. | ||
916 | * @resume: wiphy device needs to be resumed | 1172 | * @resume: wiphy device needs to be resumed |
917 | * | 1173 | * |
918 | * @add_virtual_intf: create a new virtual interface with the given name, | 1174 | * @add_virtual_intf: create a new virtual interface with the given name, |
919 | * must set the struct wireless_dev's iftype. Beware: You must create | 1175 | * must set the struct wireless_dev's iftype. Beware: You must create |
920 | * the new netdev in the wiphy's network namespace! | 1176 | * the new netdev in the wiphy's network namespace! Returns the netdev, |
1177 | * or an ERR_PTR. | ||
921 | * | 1178 | * |
922 | * @del_virtual_intf: remove the virtual interface determined by ifindex. | 1179 | * @del_virtual_intf: remove the virtual interface determined by ifindex. |
923 | * | 1180 | * |
@@ -958,10 +1215,12 @@ struct cfg80211_pmksa { | |||
958 | * @change_mpath: change a given mesh path | 1215 | * @change_mpath: change a given mesh path |
959 | * @get_mpath: get a mesh path for the given parameters | 1216 | * @get_mpath: get a mesh path for the given parameters |
960 | * @dump_mpath: dump mesh path callback -- resume dump at index @idx | 1217 | * @dump_mpath: dump mesh path callback -- resume dump at index @idx |
1218 | * @join_mesh: join the mesh network with the specified parameters | ||
1219 | * @leave_mesh: leave the current mesh network | ||
961 | * | 1220 | * |
962 | * @get_mesh_params: Put the current mesh parameters into *params | 1221 | * @get_mesh_config: Get the current mesh configuration |
963 | * | 1222 | * |
964 | * @set_mesh_params: Set mesh parameters. | 1223 | * @update_mesh_config: Update mesh parameters on a running mesh. |
965 | * The mask is a bitfield which tells us which parameters to | 1224 | * The mask is a bitfield which tells us which parameters to |
966 | * set, and which to leave alone. | 1225 | * set, and which to leave alone. |
967 | * | 1226 | * |
@@ -1020,7 +1279,9 @@ struct cfg80211_pmksa { | |||
1020 | * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation. | 1279 | * @cancel_remain_on_channel: Cancel an on-going remain-on-channel operation. |
1021 | * This allows the operation to be terminated prior to timeout based on | 1280 | * This allows the operation to be terminated prior to timeout based on |
1022 | * the duration value. | 1281 | * the duration value. |
1023 | * @action: Transmit an action frame | 1282 | * @mgmt_tx: Transmit a management frame. |
1283 | * @mgmt_tx_cancel_wait: Cancel the wait time from transmitting a management | ||
1284 | * frame on another channel | ||
1024 | * | 1285 | * |
1025 | * @testmode_cmd: run a test mode command | 1286 | * @testmode_cmd: run a test mode command |
1026 | * | 1287 | * |
@@ -1034,15 +1295,35 @@ struct cfg80211_pmksa { | |||
1034 | * @set_power_mgmt: Configure WLAN power management. A timeout value of -1 | 1295 | * @set_power_mgmt: Configure WLAN power management. A timeout value of -1 |
1035 | * allows the driver to adjust the dynamic ps timeout value. | 1296 | * allows the driver to adjust the dynamic ps timeout value. |
1036 | * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold. | 1297 | * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold. |
1298 | * @sched_scan_start: Tell the driver to start a scheduled scan. | ||
1299 | * @sched_scan_stop: Tell the driver to stop an ongoing scheduled | ||
1300 | * scan. The driver_initiated flag specifies whether the driver | ||
1301 | * itself has informed that the scan has stopped. | ||
1302 | * | ||
1303 | * @mgmt_frame_register: Notify driver that a management frame type was | ||
1304 | * registered. Note that this callback may not sleep, and cannot run | ||
1305 | * concurrently with itself. | ||
1037 | * | 1306 | * |
1307 | * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device. | ||
1308 | * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may | ||
1309 | * reject TX/RX mask combinations they cannot support by returning -EINVAL | ||
1310 | * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX). | ||
1311 | * | ||
1312 | * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant). | ||
1313 | * | ||
1314 | * @set_ringparam: Set tx and rx ring sizes. | ||
1315 | * | ||
1316 | * @get_ringparam: Get tx and rx ring current and maximum sizes. | ||
1038 | */ | 1317 | */ |
1039 | struct cfg80211_ops { | 1318 | struct cfg80211_ops { |
1040 | int (*suspend)(struct wiphy *wiphy); | 1319 | int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); |
1041 | int (*resume)(struct wiphy *wiphy); | 1320 | int (*resume)(struct wiphy *wiphy); |
1042 | 1321 | ||
1043 | int (*add_virtual_intf)(struct wiphy *wiphy, char *name, | 1322 | struct net_device * (*add_virtual_intf)(struct wiphy *wiphy, |
1044 | enum nl80211_iftype type, u32 *flags, | 1323 | char *name, |
1045 | struct vif_params *params); | 1324 | enum nl80211_iftype type, |
1325 | u32 *flags, | ||
1326 | struct vif_params *params); | ||
1046 | int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev); | 1327 | int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev); |
1047 | int (*change_virtual_intf)(struct wiphy *wiphy, | 1328 | int (*change_virtual_intf)(struct wiphy *wiphy, |
1048 | struct net_device *dev, | 1329 | struct net_device *dev, |
@@ -1050,16 +1331,17 @@ struct cfg80211_ops { | |||
1050 | struct vif_params *params); | 1331 | struct vif_params *params); |
1051 | 1332 | ||
1052 | int (*add_key)(struct wiphy *wiphy, struct net_device *netdev, | 1333 | int (*add_key)(struct wiphy *wiphy, struct net_device *netdev, |
1053 | u8 key_index, const u8 *mac_addr, | 1334 | u8 key_index, bool pairwise, const u8 *mac_addr, |
1054 | struct key_params *params); | 1335 | struct key_params *params); |
1055 | int (*get_key)(struct wiphy *wiphy, struct net_device *netdev, | 1336 | int (*get_key)(struct wiphy *wiphy, struct net_device *netdev, |
1056 | u8 key_index, const u8 *mac_addr, void *cookie, | 1337 | u8 key_index, bool pairwise, const u8 *mac_addr, |
1338 | void *cookie, | ||
1057 | void (*callback)(void *cookie, struct key_params*)); | 1339 | void (*callback)(void *cookie, struct key_params*)); |
1058 | int (*del_key)(struct wiphy *wiphy, struct net_device *netdev, | 1340 | int (*del_key)(struct wiphy *wiphy, struct net_device *netdev, |
1059 | u8 key_index, const u8 *mac_addr); | 1341 | u8 key_index, bool pairwise, const u8 *mac_addr); |
1060 | int (*set_default_key)(struct wiphy *wiphy, | 1342 | int (*set_default_key)(struct wiphy *wiphy, |
1061 | struct net_device *netdev, | 1343 | struct net_device *netdev, |
1062 | u8 key_index); | 1344 | u8 key_index, bool unicast, bool multicast); |
1063 | int (*set_default_mgmt_key)(struct wiphy *wiphy, | 1345 | int (*set_default_mgmt_key)(struct wiphy *wiphy, |
1064 | struct net_device *netdev, | 1346 | struct net_device *netdev, |
1065 | u8 key_index); | 1347 | u8 key_index); |
@@ -1094,12 +1376,17 @@ struct cfg80211_ops { | |||
1094 | int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev, | 1376 | int (*dump_mpath)(struct wiphy *wiphy, struct net_device *dev, |
1095 | int idx, u8 *dst, u8 *next_hop, | 1377 | int idx, u8 *dst, u8 *next_hop, |
1096 | struct mpath_info *pinfo); | 1378 | struct mpath_info *pinfo); |
1097 | int (*get_mesh_params)(struct wiphy *wiphy, | 1379 | int (*get_mesh_config)(struct wiphy *wiphy, |
1098 | struct net_device *dev, | 1380 | struct net_device *dev, |
1099 | struct mesh_config *conf); | 1381 | struct mesh_config *conf); |
1100 | int (*set_mesh_params)(struct wiphy *wiphy, | 1382 | int (*update_mesh_config)(struct wiphy *wiphy, |
1101 | struct net_device *dev, | 1383 | struct net_device *dev, u32 mask, |
1102 | const struct mesh_config *nconf, u32 mask); | 1384 | const struct mesh_config *nconf); |
1385 | int (*join_mesh)(struct wiphy *wiphy, struct net_device *dev, | ||
1386 | const struct mesh_config *conf, | ||
1387 | const struct mesh_setup *setup); | ||
1388 | int (*leave_mesh)(struct wiphy *wiphy, struct net_device *dev); | ||
1389 | |||
1103 | int (*change_bss)(struct wiphy *wiphy, struct net_device *dev, | 1390 | int (*change_bss)(struct wiphy *wiphy, struct net_device *dev, |
1104 | struct bss_parameters *params); | 1391 | struct bss_parameters *params); |
1105 | 1392 | ||
@@ -1140,7 +1427,7 @@ struct cfg80211_ops { | |||
1140 | int (*get_tx_power)(struct wiphy *wiphy, int *dbm); | 1427 | int (*get_tx_power)(struct wiphy *wiphy, int *dbm); |
1141 | 1428 | ||
1142 | int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, | 1429 | int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, |
1143 | u8 *addr); | 1430 | const u8 *addr); |
1144 | 1431 | ||
1145 | void (*rfkill_poll)(struct wiphy *wiphy); | 1432 | void (*rfkill_poll)(struct wiphy *wiphy); |
1146 | 1433 | ||
@@ -1172,11 +1459,14 @@ struct cfg80211_ops { | |||
1172 | struct net_device *dev, | 1459 | struct net_device *dev, |
1173 | u64 cookie); | 1460 | u64 cookie); |
1174 | 1461 | ||
1175 | int (*action)(struct wiphy *wiphy, struct net_device *dev, | 1462 | int (*mgmt_tx)(struct wiphy *wiphy, struct net_device *dev, |
1176 | struct ieee80211_channel *chan, | 1463 | struct ieee80211_channel *chan, bool offchan, |
1177 | enum nl80211_channel_type channel_type, | 1464 | enum nl80211_channel_type channel_type, |
1178 | bool channel_type_valid, | 1465 | bool channel_type_valid, unsigned int wait, |
1179 | const u8 *buf, size_t len, u64 *cookie); | 1466 | const u8 *buf, size_t len, u64 *cookie); |
1467 | int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy, | ||
1468 | struct net_device *dev, | ||
1469 | u64 cookie); | ||
1180 | 1470 | ||
1181 | int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev, | 1471 | int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev, |
1182 | bool enabled, int timeout); | 1472 | bool enabled, int timeout); |
@@ -1184,6 +1474,22 @@ struct cfg80211_ops { | |||
1184 | int (*set_cqm_rssi_config)(struct wiphy *wiphy, | 1474 | int (*set_cqm_rssi_config)(struct wiphy *wiphy, |
1185 | struct net_device *dev, | 1475 | struct net_device *dev, |
1186 | s32 rssi_thold, u32 rssi_hyst); | 1476 | s32 rssi_thold, u32 rssi_hyst); |
1477 | |||
1478 | void (*mgmt_frame_register)(struct wiphy *wiphy, | ||
1479 | struct net_device *dev, | ||
1480 | u16 frame_type, bool reg); | ||
1481 | |||
1482 | int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant); | ||
1483 | int (*get_antenna)(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant); | ||
1484 | |||
1485 | int (*set_ringparam)(struct wiphy *wiphy, u32 tx, u32 rx); | ||
1486 | void (*get_ringparam)(struct wiphy *wiphy, | ||
1487 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max); | ||
1488 | |||
1489 | int (*sched_scan_start)(struct wiphy *wiphy, | ||
1490 | struct net_device *dev, | ||
1491 | struct cfg80211_sched_scan_request *request); | ||
1492 | int (*sched_scan_stop)(struct wiphy *wiphy, struct net_device *dev); | ||
1187 | }; | 1493 | }; |
1188 | 1494 | ||
1189 | /* | 1495 | /* |
@@ -1201,19 +1507,24 @@ struct cfg80211_ops { | |||
1201 | * initiator is %REGDOM_SET_BY_CORE). | 1507 | * initiator is %REGDOM_SET_BY_CORE). |
1202 | * @WIPHY_FLAG_STRICT_REGULATORY: tells us the driver for this device will | 1508 | * @WIPHY_FLAG_STRICT_REGULATORY: tells us the driver for this device will |
1203 | * ignore regulatory domain settings until it gets its own regulatory | 1509 | * ignore regulatory domain settings until it gets its own regulatory |
1204 | * domain via its regulatory_hint(). After its gets its own regulatory | 1510 | * domain via its regulatory_hint() unless the regulatory hint is |
1205 | * domain it will only allow further regulatory domain settings to | 1511 | * from a country IE. After its gets its own regulatory domain it will |
1206 | * further enhance compliance. For example if channel 13 and 14 are | 1512 | * only allow further regulatory domain settings to further enhance |
1207 | * disabled by this regulatory domain no user regulatory domain can | 1513 | * compliance. For example if channel 13 and 14 are disabled by this |
1208 | * enable these channels at a later time. This can be used for devices | 1514 | * regulatory domain no user regulatory domain can enable these channels |
1209 | * which do not have calibration information gauranteed for frequencies | 1515 | * at a later time. This can be used for devices which do not have |
1210 | * or settings outside of its regulatory domain. | 1516 | * calibration information guaranteed for frequencies or settings |
1517 | * outside of its regulatory domain. | ||
1211 | * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure | 1518 | * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure |
1212 | * that passive scan flags and beaconing flags may not be lifted by | 1519 | * that passive scan flags and beaconing flags may not be lifted by |
1213 | * cfg80211 due to regulatory beacon hints. For more information on beacon | 1520 | * cfg80211 due to regulatory beacon hints. For more information on beacon |
1214 | * hints read the documenation for regulatory_hint_found_beacon() | 1521 | * hints read the documenation for regulatory_hint_found_beacon() |
1215 | * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this | 1522 | * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this |
1216 | * wiphy at all | 1523 | * wiphy at all |
1524 | * @WIPHY_FLAG_ENFORCE_COMBINATIONS: Set this flag to enforce interface | ||
1525 | * combinations for this device. This flag is used for backward | ||
1526 | * compatibility only until all drivers advertise combinations and | ||
1527 | * they will always be enforced. | ||
1217 | * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled | 1528 | * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled |
1218 | * by default -- this flag will be set depending on the kernel's default | 1529 | * by default -- this flag will be set depending on the kernel's default |
1219 | * on wiphy_new(), but can be changed by the driver if it has a good | 1530 | * on wiphy_new(), but can be changed by the driver if it has a good |
@@ -1221,24 +1532,148 @@ struct cfg80211_ops { | |||
1221 | * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station | 1532 | * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station |
1222 | * on a VLAN interface) | 1533 | * on a VLAN interface) |
1223 | * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station | 1534 | * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station |
1535 | * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the | ||
1536 | * control port protocol ethertype. The device also honours the | ||
1537 | * control_port_no_encrypt flag. | ||
1538 | * @WIPHY_FLAG_IBSS_RSN: The device supports IBSS RSN. | ||
1539 | * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing | ||
1540 | * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH. | ||
1541 | * @WIPHY_FLAG_SUPPORTS_SCHED_SCAN: The device supports scheduled scans. | ||
1224 | */ | 1542 | */ |
1225 | enum wiphy_flags { | 1543 | enum wiphy_flags { |
1226 | WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), | 1544 | WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), |
1227 | WIPHY_FLAG_STRICT_REGULATORY = BIT(1), | 1545 | WIPHY_FLAG_STRICT_REGULATORY = BIT(1), |
1228 | WIPHY_FLAG_DISABLE_BEACON_HINTS = BIT(2), | 1546 | WIPHY_FLAG_DISABLE_BEACON_HINTS = BIT(2), |
1229 | WIPHY_FLAG_NETNS_OK = BIT(3), | 1547 | WIPHY_FLAG_NETNS_OK = BIT(3), |
1230 | WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4), | 1548 | WIPHY_FLAG_PS_ON_BY_DEFAULT = BIT(4), |
1231 | WIPHY_FLAG_4ADDR_AP = BIT(5), | 1549 | WIPHY_FLAG_4ADDR_AP = BIT(5), |
1232 | WIPHY_FLAG_4ADDR_STATION = BIT(6), | 1550 | WIPHY_FLAG_4ADDR_STATION = BIT(6), |
1551 | WIPHY_FLAG_CONTROL_PORT_PROTOCOL = BIT(7), | ||
1552 | WIPHY_FLAG_IBSS_RSN = BIT(8), | ||
1553 | WIPHY_FLAG_MESH_AUTH = BIT(10), | ||
1554 | WIPHY_FLAG_SUPPORTS_SCHED_SCAN = BIT(11), | ||
1555 | WIPHY_FLAG_ENFORCE_COMBINATIONS = BIT(12), | ||
1556 | }; | ||
1557 | |||
1558 | /** | ||
1559 | * struct ieee80211_iface_limit - limit on certain interface types | ||
1560 | * @max: maximum number of interfaces of these types | ||
1561 | * @types: interface types (bits) | ||
1562 | */ | ||
1563 | struct ieee80211_iface_limit { | ||
1564 | u16 max; | ||
1565 | u16 types; | ||
1566 | }; | ||
1567 | |||
1568 | /** | ||
1569 | * struct ieee80211_iface_combination - possible interface combination | ||
1570 | * @limits: limits for the given interface types | ||
1571 | * @n_limits: number of limitations | ||
1572 | * @num_different_channels: can use up to this many different channels | ||
1573 | * @max_interfaces: maximum number of interfaces in total allowed in this | ||
1574 | * group | ||
1575 | * @beacon_int_infra_match: In this combination, the beacon intervals | ||
1576 | * between infrastructure and AP types must match. This is required | ||
1577 | * only in special cases. | ||
1578 | * | ||
1579 | * These examples can be expressed as follows: | ||
1580 | * | ||
1581 | * Allow #STA <= 1, #AP <= 1, matching BI, channels = 1, 2 total: | ||
1582 | * | ||
1583 | * struct ieee80211_iface_limit limits1[] = { | ||
1584 | * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, | ||
1585 | * { .max = 1, .types = BIT(NL80211_IFTYPE_AP}, }, | ||
1586 | * }; | ||
1587 | * struct ieee80211_iface_combination combination1 = { | ||
1588 | * .limits = limits1, | ||
1589 | * .n_limits = ARRAY_SIZE(limits1), | ||
1590 | * .max_interfaces = 2, | ||
1591 | * .beacon_int_infra_match = true, | ||
1592 | * }; | ||
1593 | * | ||
1594 | * | ||
1595 | * Allow #{AP, P2P-GO} <= 8, channels = 1, 8 total: | ||
1596 | * | ||
1597 | * struct ieee80211_iface_limit limits2[] = { | ||
1598 | * { .max = 8, .types = BIT(NL80211_IFTYPE_AP) | | ||
1599 | * BIT(NL80211_IFTYPE_P2P_GO), }, | ||
1600 | * }; | ||
1601 | * struct ieee80211_iface_combination combination2 = { | ||
1602 | * .limits = limits2, | ||
1603 | * .n_limits = ARRAY_SIZE(limits2), | ||
1604 | * .max_interfaces = 8, | ||
1605 | * .num_different_channels = 1, | ||
1606 | * }; | ||
1607 | * | ||
1608 | * | ||
1609 | * Allow #STA <= 1, #{P2P-client,P2P-GO} <= 3 on two channels, 4 total. | ||
1610 | * This allows for an infrastructure connection and three P2P connections. | ||
1611 | * | ||
1612 | * struct ieee80211_iface_limit limits3[] = { | ||
1613 | * { .max = 1, .types = BIT(NL80211_IFTYPE_STATION), }, | ||
1614 | * { .max = 3, .types = BIT(NL80211_IFTYPE_P2P_GO) | | ||
1615 | * BIT(NL80211_IFTYPE_P2P_CLIENT), }, | ||
1616 | * }; | ||
1617 | * struct ieee80211_iface_combination combination3 = { | ||
1618 | * .limits = limits3, | ||
1619 | * .n_limits = ARRAY_SIZE(limits3), | ||
1620 | * .max_interfaces = 4, | ||
1621 | * .num_different_channels = 2, | ||
1622 | * }; | ||
1623 | */ | ||
1624 | struct ieee80211_iface_combination { | ||
1625 | const struct ieee80211_iface_limit *limits; | ||
1626 | u32 num_different_channels; | ||
1627 | u16 max_interfaces; | ||
1628 | u8 n_limits; | ||
1629 | bool beacon_int_infra_match; | ||
1233 | }; | 1630 | }; |
1234 | 1631 | ||
1235 | struct mac_address { | 1632 | struct mac_address { |
1236 | u8 addr[ETH_ALEN]; | 1633 | u8 addr[ETH_ALEN]; |
1237 | }; | 1634 | }; |
1238 | 1635 | ||
1636 | struct ieee80211_txrx_stypes { | ||
1637 | u16 tx, rx; | ||
1638 | }; | ||
1639 | |||
1640 | /** | ||
1641 | * enum wiphy_wowlan_support_flags - WoWLAN support flags | ||
1642 | * @WIPHY_WOWLAN_ANY: supports wakeup for the special "any" | ||
1643 | * trigger that keeps the device operating as-is and | ||
1644 | * wakes up the host on any activity, for example a | ||
1645 | * received packet that passed filtering; note that the | ||
1646 | * packet should be preserved in that case | ||
1647 | * @WIPHY_WOWLAN_MAGIC_PKT: supports wakeup on magic packet | ||
1648 | * (see nl80211.h) | ||
1649 | * @WIPHY_WOWLAN_DISCONNECT: supports wakeup on disconnect | ||
1650 | */ | ||
1651 | enum wiphy_wowlan_support_flags { | ||
1652 | WIPHY_WOWLAN_ANY = BIT(0), | ||
1653 | WIPHY_WOWLAN_MAGIC_PKT = BIT(1), | ||
1654 | WIPHY_WOWLAN_DISCONNECT = BIT(2), | ||
1655 | }; | ||
1656 | |||
1657 | /** | ||
1658 | * struct wiphy_wowlan_support - WoWLAN support data | ||
1659 | * @flags: see &enum wiphy_wowlan_support_flags | ||
1660 | * @n_patterns: number of supported wakeup patterns | ||
1661 | * (see nl80211.h for the pattern definition) | ||
1662 | * @pattern_max_len: maximum length of each pattern | ||
1663 | * @pattern_min_len: minimum length of each pattern | ||
1664 | */ | ||
1665 | struct wiphy_wowlan_support { | ||
1666 | u32 flags; | ||
1667 | int n_patterns; | ||
1668 | int pattern_max_len; | ||
1669 | int pattern_min_len; | ||
1670 | }; | ||
1671 | |||
1239 | /** | 1672 | /** |
1240 | * struct wiphy - wireless hardware description | 1673 | * struct wiphy - wireless hardware description |
1241 | * @reg_notifier: the driver's regulatory notification callback | 1674 | * @reg_notifier: the driver's regulatory notification callback, |
1675 | * note that if your driver uses wiphy_apply_custom_regulatory() | ||
1676 | * the reg_notifier's request can be passed as NULL | ||
1242 | * @regd: the driver's regulatory domain, if one was requested via | 1677 | * @regd: the driver's regulatory domain, if one was requested via |
1243 | * the regulatory_hint() API. This can be used by the driver | 1678 | * the regulatory_hint() API. This can be used by the driver |
1244 | * on the reg_notifier() if it chooses to ignore future | 1679 | * on the reg_notifier() if it chooses to ignore future |
@@ -1271,6 +1706,11 @@ struct mac_address { | |||
1271 | * @priv: driver private data (sized according to wiphy_new() parameter) | 1706 | * @priv: driver private data (sized according to wiphy_new() parameter) |
1272 | * @interface_modes: bitmask of interfaces types valid for this wiphy, | 1707 | * @interface_modes: bitmask of interfaces types valid for this wiphy, |
1273 | * must be set by driver | 1708 | * must be set by driver |
1709 | * @iface_combinations: Valid interface combinations array, should not | ||
1710 | * list single interface types. | ||
1711 | * @n_iface_combinations: number of entries in @iface_combinations array. | ||
1712 | * @software_iftypes: bitmask of software interface types, these are not | ||
1713 | * subject to any restrictions since they are purely managed in SW. | ||
1274 | * @flags: wiphy flags, see &enum wiphy_flags | 1714 | * @flags: wiphy flags, see &enum wiphy_flags |
1275 | * @bss_priv_size: each BSS struct has private data allocated with it, | 1715 | * @bss_priv_size: each BSS struct has private data allocated with it, |
1276 | * this variable determines its size | 1716 | * this variable determines its size |
@@ -1286,6 +1726,23 @@ struct mac_address { | |||
1286 | * @privid: a pointer that drivers can use to identify if an arbitrary | 1726 | * @privid: a pointer that drivers can use to identify if an arbitrary |
1287 | * wiphy is theirs, e.g. in global notifiers | 1727 | * wiphy is theirs, e.g. in global notifiers |
1288 | * @bands: information about bands/channels supported by this device | 1728 | * @bands: information about bands/channels supported by this device |
1729 | * | ||
1730 | * @mgmt_stypes: bitmasks of frame subtypes that can be subscribed to or | ||
1731 | * transmitted through nl80211, points to an array indexed by interface | ||
1732 | * type | ||
1733 | * | ||
1734 | * @available_antennas_tx: bitmap of antennas which are available to be | ||
1735 | * configured as TX antennas. Antenna configuration commands will be | ||
1736 | * rejected unless this or @available_antennas_rx is set. | ||
1737 | * | ||
1738 | * @available_antennas_rx: bitmap of antennas which are available to be | ||
1739 | * configured as RX antennas. Antenna configuration commands will be | ||
1740 | * rejected unless this or @available_antennas_tx is set. | ||
1741 | * | ||
1742 | * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation | ||
1743 | * may request, if implemented. | ||
1744 | * | ||
1745 | * @wowlan: WoWLAN support information | ||
1289 | */ | 1746 | */ |
1290 | struct wiphy { | 1747 | struct wiphy { |
1291 | /* assign these fields before you register the wiphy */ | 1748 | /* assign these fields before you register the wiphy */ |
@@ -1294,9 +1751,16 @@ struct wiphy { | |||
1294 | u8 perm_addr[ETH_ALEN]; | 1751 | u8 perm_addr[ETH_ALEN]; |
1295 | u8 addr_mask[ETH_ALEN]; | 1752 | u8 addr_mask[ETH_ALEN]; |
1296 | 1753 | ||
1297 | u16 n_addresses; | ||
1298 | struct mac_address *addresses; | 1754 | struct mac_address *addresses; |
1299 | 1755 | ||
1756 | const struct ieee80211_txrx_stypes *mgmt_stypes; | ||
1757 | |||
1758 | const struct ieee80211_iface_combination *iface_combinations; | ||
1759 | int n_iface_combinations; | ||
1760 | u16 software_iftypes; | ||
1761 | |||
1762 | u16 n_addresses; | ||
1763 | |||
1300 | /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ | 1764 | /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ |
1301 | u16 interface_modes; | 1765 | u16 interface_modes; |
1302 | 1766 | ||
@@ -1320,8 +1784,15 @@ struct wiphy { | |||
1320 | char fw_version[ETHTOOL_BUSINFO_LEN]; | 1784 | char fw_version[ETHTOOL_BUSINFO_LEN]; |
1321 | u32 hw_version; | 1785 | u32 hw_version; |
1322 | 1786 | ||
1787 | struct wiphy_wowlan_support wowlan; | ||
1788 | |||
1789 | u16 max_remain_on_channel_duration; | ||
1790 | |||
1323 | u8 max_num_pmkids; | 1791 | u8 max_num_pmkids; |
1324 | 1792 | ||
1793 | u32 available_antennas_tx; | ||
1794 | u32 available_antennas_rx; | ||
1795 | |||
1325 | /* If multiple wiphys are registered and you're handed e.g. | 1796 | /* If multiple wiphys are registered and you're handed e.g. |
1326 | * a regular netdev with assigned ieee80211_ptr, you won't | 1797 | * a regular netdev with assigned ieee80211_ptr, you won't |
1327 | * know whether it points to a wiphy your driver has registered | 1798 | * know whether it points to a wiphy your driver has registered |
@@ -1487,15 +1958,19 @@ struct cfg80211_cached_keys; | |||
1487 | * @bssid: (private) Used by the internal configuration code | 1958 | * @bssid: (private) Used by the internal configuration code |
1488 | * @ssid: (private) Used by the internal configuration code | 1959 | * @ssid: (private) Used by the internal configuration code |
1489 | * @ssid_len: (private) Used by the internal configuration code | 1960 | * @ssid_len: (private) Used by the internal configuration code |
1961 | * @mesh_id_len: (private) Used by the internal configuration code | ||
1962 | * @mesh_id_up_len: (private) Used by the internal configuration code | ||
1490 | * @wext: (private) Used by the internal wireless extensions compat code | 1963 | * @wext: (private) Used by the internal wireless extensions compat code |
1491 | * @use_4addr: indicates 4addr mode is used on this interface, must be | 1964 | * @use_4addr: indicates 4addr mode is used on this interface, must be |
1492 | * set by driver (if supported) on add_interface BEFORE registering the | 1965 | * set by driver (if supported) on add_interface BEFORE registering the |
1493 | * netdev and may otherwise be used by driver read-only, will be update | 1966 | * netdev and may otherwise be used by driver read-only, will be update |
1494 | * by cfg80211 on change_interface | 1967 | * by cfg80211 on change_interface |
1495 | * @action_registrations: list of registrations for action frames | 1968 | * @mgmt_registrations: list of registrations for management frames |
1496 | * @action_registrations_lock: lock for the list | 1969 | * @mgmt_registrations_lock: lock for the list |
1497 | * @mtx: mutex used to lock data in this struct | 1970 | * @mtx: mutex used to lock data in this struct |
1498 | * @cleanup_work: work struct used for cleanup that can't be done directly | 1971 | * @cleanup_work: work struct used for cleanup that can't be done directly |
1972 | * @beacon_interval: beacon interval used on this device for transmitting | ||
1973 | * beacons, 0 when not valid | ||
1499 | */ | 1974 | */ |
1500 | struct wireless_dev { | 1975 | struct wireless_dev { |
1501 | struct wiphy *wiphy; | 1976 | struct wiphy *wiphy; |
@@ -1505,8 +1980,8 @@ struct wireless_dev { | |||
1505 | struct list_head list; | 1980 | struct list_head list; |
1506 | struct net_device *netdev; | 1981 | struct net_device *netdev; |
1507 | 1982 | ||
1508 | struct list_head action_registrations; | 1983 | struct list_head mgmt_registrations; |
1509 | spinlock_t action_registrations_lock; | 1984 | spinlock_t mgmt_registrations_lock; |
1510 | 1985 | ||
1511 | struct mutex mtx; | 1986 | struct mutex mtx; |
1512 | 1987 | ||
@@ -1516,7 +1991,7 @@ struct wireless_dev { | |||
1516 | 1991 | ||
1517 | /* currently used for IBSS and SME - might be rearranged later */ | 1992 | /* currently used for IBSS and SME - might be rearranged later */ |
1518 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | 1993 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
1519 | u8 ssid_len; | 1994 | u8 ssid_len, mesh_id_len, mesh_id_up_len; |
1520 | enum { | 1995 | enum { |
1521 | CFG80211_SME_IDLE, | 1996 | CFG80211_SME_IDLE, |
1522 | CFG80211_SME_CONNECTING, | 1997 | CFG80211_SME_CONNECTING, |
@@ -1536,6 +2011,8 @@ struct wireless_dev { | |||
1536 | bool ps; | 2011 | bool ps; |
1537 | int ps_timeout; | 2012 | int ps_timeout; |
1538 | 2013 | ||
2014 | int beacon_interval; | ||
2015 | |||
1539 | #ifdef CONFIG_CFG80211_WEXT | 2016 | #ifdef CONFIG_CFG80211_WEXT |
1540 | /* wext data */ | 2017 | /* wext data */ |
1541 | struct { | 2018 | struct { |
@@ -1563,15 +2040,18 @@ static inline void *wdev_priv(struct wireless_dev *wdev) | |||
1563 | return wiphy_priv(wdev->wiphy); | 2040 | return wiphy_priv(wdev->wiphy); |
1564 | } | 2041 | } |
1565 | 2042 | ||
1566 | /* | 2043 | /** |
1567 | * Utility functions | 2044 | * DOC: Utility functions |
2045 | * | ||
2046 | * cfg80211 offers a number of utility functions that can be useful. | ||
1568 | */ | 2047 | */ |
1569 | 2048 | ||
1570 | /** | 2049 | /** |
1571 | * ieee80211_channel_to_frequency - convert channel number to frequency | 2050 | * ieee80211_channel_to_frequency - convert channel number to frequency |
1572 | * @chan: channel number | 2051 | * @chan: channel number |
2052 | * @band: band, necessary due to channel number overlap | ||
1573 | */ | 2053 | */ |
1574 | extern int ieee80211_channel_to_frequency(int chan); | 2054 | extern int ieee80211_channel_to_frequency(int chan, enum ieee80211_band band); |
1575 | 2055 | ||
1576 | /** | 2056 | /** |
1577 | * ieee80211_frequency_to_channel - convert frequency to channel number | 2057 | * ieee80211_frequency_to_channel - convert frequency to channel number |
@@ -1715,7 +2195,15 @@ unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); | |||
1715 | * ieee80211_hdrlen - get header length in bytes from frame control | 2195 | * ieee80211_hdrlen - get header length in bytes from frame control |
1716 | * @fc: frame control field in little-endian format | 2196 | * @fc: frame control field in little-endian format |
1717 | */ | 2197 | */ |
1718 | unsigned int ieee80211_hdrlen(__le16 fc); | 2198 | unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc); |
2199 | |||
2200 | /** | ||
2201 | * DOC: Data path helpers | ||
2202 | * | ||
2203 | * In addition to generic utilities, cfg80211 also offers | ||
2204 | * functions that help implement the data path for devices | ||
2205 | * that do not do the 802.11/802.3 conversion on the device. | ||
2206 | */ | ||
1719 | 2207 | ||
1720 | /** | 2208 | /** |
1721 | * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3 | 2209 | * ieee80211_data_to_8023 - convert an 802.11 data frame to 802.3 |
@@ -1750,10 +2238,12 @@ int ieee80211_data_from_8023(struct sk_buff *skb, const u8 *addr, | |||
1750 | * @addr: The device MAC address. | 2238 | * @addr: The device MAC address. |
1751 | * @iftype: The device interface type. | 2239 | * @iftype: The device interface type. |
1752 | * @extra_headroom: The hardware extra headroom for SKBs in the @list. | 2240 | * @extra_headroom: The hardware extra headroom for SKBs in the @list. |
2241 | * @has_80211_header: Set it true if SKB is with IEEE 802.11 header. | ||
1753 | */ | 2242 | */ |
1754 | void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, | 2243 | void ieee80211_amsdu_to_8023s(struct sk_buff *skb, struct sk_buff_head *list, |
1755 | const u8 *addr, enum nl80211_iftype iftype, | 2244 | const u8 *addr, enum nl80211_iftype iftype, |
1756 | const unsigned int extra_headroom); | 2245 | const unsigned int extra_headroom, |
2246 | bool has_80211_header); | ||
1757 | 2247 | ||
1758 | /** | 2248 | /** |
1759 | * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame | 2249 | * cfg80211_classify8021d - determine the 802.1p/1d tag for a data frame |
@@ -1777,8 +2267,10 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb); | |||
1777 | */ | 2267 | */ |
1778 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len); | 2268 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len); |
1779 | 2269 | ||
1780 | /* | 2270 | /** |
1781 | * Regulatory helper functions for wiphys | 2271 | * DOC: Regulatory enforcement infrastructure |
2272 | * | ||
2273 | * TODO | ||
1782 | */ | 2274 | */ |
1783 | 2275 | ||
1784 | /** | 2276 | /** |
@@ -1971,6 +2463,24 @@ int cfg80211_wext_siwpmksa(struct net_device *dev, | |||
1971 | void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted); | 2463 | void cfg80211_scan_done(struct cfg80211_scan_request *request, bool aborted); |
1972 | 2464 | ||
1973 | /** | 2465 | /** |
2466 | * cfg80211_sched_scan_results - notify that new scan results are available | ||
2467 | * | ||
2468 | * @wiphy: the wiphy which got scheduled scan results | ||
2469 | */ | ||
2470 | void cfg80211_sched_scan_results(struct wiphy *wiphy); | ||
2471 | |||
2472 | /** | ||
2473 | * cfg80211_sched_scan_stopped - notify that the scheduled scan has stopped | ||
2474 | * | ||
2475 | * @wiphy: the wiphy on which the scheduled scan stopped | ||
2476 | * | ||
2477 | * The driver can call this function to inform cfg80211 that the | ||
2478 | * scheduled scan had to be stopped, for whatever reason. The driver | ||
2479 | * is then called back via the sched_scan_stop operation when done. | ||
2480 | */ | ||
2481 | void cfg80211_sched_scan_stopped(struct wiphy *wiphy); | ||
2482 | |||
2483 | /** | ||
1974 | * cfg80211_inform_bss_frame - inform cfg80211 of a received BSS frame | 2484 | * cfg80211_inform_bss_frame - inform cfg80211 of a received BSS frame |
1975 | * | 2485 | * |
1976 | * @wiphy: the wiphy reporting the BSS | 2486 | * @wiphy: the wiphy reporting the BSS |
@@ -2148,11 +2658,37 @@ void __cfg80211_send_disassoc(struct net_device *dev, const u8 *buf, | |||
2148 | size_t len); | 2658 | size_t len); |
2149 | 2659 | ||
2150 | /** | 2660 | /** |
2661 | * cfg80211_send_unprot_deauth - notification of unprotected deauthentication | ||
2662 | * @dev: network device | ||
2663 | * @buf: deauthentication frame (header + body) | ||
2664 | * @len: length of the frame data | ||
2665 | * | ||
2666 | * This function is called whenever a received Deauthentication frame has been | ||
2667 | * dropped in station mode because of MFP being used but the Deauthentication | ||
2668 | * frame was not protected. This function may sleep. | ||
2669 | */ | ||
2670 | void cfg80211_send_unprot_deauth(struct net_device *dev, const u8 *buf, | ||
2671 | size_t len); | ||
2672 | |||
2673 | /** | ||
2674 | * cfg80211_send_unprot_disassoc - notification of unprotected disassociation | ||
2675 | * @dev: network device | ||
2676 | * @buf: disassociation frame (header + body) | ||
2677 | * @len: length of the frame data | ||
2678 | * | ||
2679 | * This function is called whenever a received Disassociation frame has been | ||
2680 | * dropped in station mode because of MFP being used but the Disassociation | ||
2681 | * frame was not protected. This function may sleep. | ||
2682 | */ | ||
2683 | void cfg80211_send_unprot_disassoc(struct net_device *dev, const u8 *buf, | ||
2684 | size_t len); | ||
2685 | |||
2686 | /** | ||
2151 | * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP) | 2687 | * cfg80211_michael_mic_failure - notification of Michael MIC failure (TKIP) |
2152 | * @dev: network device | 2688 | * @dev: network device |
2153 | * @addr: The source MAC address of the frame | 2689 | * @addr: The source MAC address of the frame |
2154 | * @key_type: The key type that the received frame used | 2690 | * @key_type: The key type that the received frame used |
2155 | * @key_id: Key identifier (0..3) | 2691 | * @key_id: Key identifier (0..3). Can be -1 if missing. |
2156 | * @tsc: The TSC value of the frame that generated the MIC failure (6 octets) | 2692 | * @tsc: The TSC value of the frame that generated the MIC failure (6 octets) |
2157 | * @gfp: allocation flags | 2693 | * @gfp: allocation flags |
2158 | * | 2694 | * |
@@ -2181,6 +2717,36 @@ void cfg80211_michael_mic_failure(struct net_device *dev, const u8 *addr, | |||
2181 | void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp); | 2717 | void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, gfp_t gfp); |
2182 | 2718 | ||
2183 | /** | 2719 | /** |
2720 | * cfg80211_notify_new_candidate - notify cfg80211 of a new mesh peer candidate | ||
2721 | * | ||
2722 | * @dev: network device | ||
2723 | * @macaddr: the MAC address of the new candidate | ||
2724 | * @ie: information elements advertised by the peer candidate | ||
2725 | * @ie_len: lenght of the information elements buffer | ||
2726 | * @gfp: allocation flags | ||
2727 | * | ||
2728 | * This function notifies cfg80211 that the mesh peer candidate has been | ||
2729 | * detected, most likely via a beacon or, less likely, via a probe response. | ||
2730 | * cfg80211 then sends a notification to userspace. | ||
2731 | */ | ||
2732 | void cfg80211_notify_new_peer_candidate(struct net_device *dev, | ||
2733 | const u8 *macaddr, const u8 *ie, u8 ie_len, gfp_t gfp); | ||
2734 | |||
2735 | /** | ||
2736 | * DOC: RFkill integration | ||
2737 | * | ||
2738 | * RFkill integration in cfg80211 is almost invisible to drivers, | ||
2739 | * as cfg80211 automatically registers an rfkill instance for each | ||
2740 | * wireless device it knows about. Soft kill is also translated | ||
2741 | * into disconnecting and turning all interfaces off, drivers are | ||
2742 | * expected to turn off the device when all interfaces are down. | ||
2743 | * | ||
2744 | * However, devices may have a hard RFkill line, in which case they | ||
2745 | * also need to interact with the rfkill subsystem, via cfg80211. | ||
2746 | * They can do this with a few helper functions documented here. | ||
2747 | */ | ||
2748 | |||
2749 | /** | ||
2184 | * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state | 2750 | * wiphy_rfkill_set_hw_state - notify cfg80211 about hw block state |
2185 | * @wiphy: the wiphy | 2751 | * @wiphy: the wiphy |
2186 | * @blocked: block status | 2752 | * @blocked: block status |
@@ -2201,6 +2767,17 @@ void wiphy_rfkill_stop_polling(struct wiphy *wiphy); | |||
2201 | 2767 | ||
2202 | #ifdef CONFIG_NL80211_TESTMODE | 2768 | #ifdef CONFIG_NL80211_TESTMODE |
2203 | /** | 2769 | /** |
2770 | * DOC: Test mode | ||
2771 | * | ||
2772 | * Test mode is a set of utility functions to allow drivers to | ||
2773 | * interact with driver-specific tools to aid, for instance, | ||
2774 | * factory programming. | ||
2775 | * | ||
2776 | * This chapter describes how drivers interact with it, for more | ||
2777 | * information see the nl80211 book's chapter on it. | ||
2778 | */ | ||
2779 | |||
2780 | /** | ||
2204 | * cfg80211_testmode_alloc_reply_skb - allocate testmode reply | 2781 | * cfg80211_testmode_alloc_reply_skb - allocate testmode reply |
2205 | * @wiphy: the wiphy | 2782 | * @wiphy: the wiphy |
2206 | * @approxlen: an upper bound of the length of the data that will | 2783 | * @approxlen: an upper bound of the length of the data that will |
@@ -2302,6 +2879,7 @@ void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
2302 | * cfg80211_roamed - notify cfg80211 of roaming | 2879 | * cfg80211_roamed - notify cfg80211 of roaming |
2303 | * | 2880 | * |
2304 | * @dev: network device | 2881 | * @dev: network device |
2882 | * @channel: the channel of the new AP | ||
2305 | * @bssid: the BSSID of the new AP | 2883 | * @bssid: the BSSID of the new AP |
2306 | * @req_ie: association request IEs (maybe be %NULL) | 2884 | * @req_ie: association request IEs (maybe be %NULL) |
2307 | * @req_ie_len: association request IEs length | 2885 | * @req_ie_len: association request IEs length |
@@ -2312,7 +2890,9 @@ void cfg80211_connect_result(struct net_device *dev, const u8 *bssid, | |||
2312 | * It should be called by the underlying driver whenever it roamed | 2890 | * It should be called by the underlying driver whenever it roamed |
2313 | * from one AP to another while connected. | 2891 | * from one AP to another while connected. |
2314 | */ | 2892 | */ |
2315 | void cfg80211_roamed(struct net_device *dev, const u8 *bssid, | 2893 | void cfg80211_roamed(struct net_device *dev, |
2894 | struct ieee80211_channel *channel, | ||
2895 | const u8 *bssid, | ||
2316 | const u8 *req_ie, size_t req_ie_len, | 2896 | const u8 *req_ie, size_t req_ie_len, |
2317 | const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp); | 2897 | const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp); |
2318 | 2898 | ||
@@ -2373,38 +2953,48 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, | |||
2373 | struct station_info *sinfo, gfp_t gfp); | 2953 | struct station_info *sinfo, gfp_t gfp); |
2374 | 2954 | ||
2375 | /** | 2955 | /** |
2376 | * cfg80211_rx_action - notification of received, unprocessed Action frame | 2956 | * cfg80211_del_sta - notify userspace about deletion of a station |
2957 | * | ||
2958 | * @dev: the netdev | ||
2959 | * @mac_addr: the station's address | ||
2960 | * @gfp: allocation flags | ||
2961 | */ | ||
2962 | void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp); | ||
2963 | |||
2964 | /** | ||
2965 | * cfg80211_rx_mgmt - notification of received, unprocessed management frame | ||
2377 | * @dev: network device | 2966 | * @dev: network device |
2378 | * @freq: Frequency on which the frame was received in MHz | 2967 | * @freq: Frequency on which the frame was received in MHz |
2379 | * @buf: Action frame (header + body) | 2968 | * @buf: Management frame (header + body) |
2380 | * @len: length of the frame data | 2969 | * @len: length of the frame data |
2381 | * @gfp: context flags | 2970 | * @gfp: context flags |
2382 | * Returns %true if a user space application is responsible for rejecting the | 2971 | * |
2383 | * unrecognized Action frame; %false if no such application is registered | 2972 | * Returns %true if a user space application has registered for this frame. |
2384 | * (i.e., the driver is responsible for rejecting the unrecognized Action | 2973 | * For action frames, that makes it responsible for rejecting unrecognized |
2385 | * frame) | 2974 | * action frames; %false otherwise, in which case for action frames the |
2975 | * driver is responsible for rejecting the frame. | ||
2386 | * | 2976 | * |
2387 | * This function is called whenever an Action frame is received for a station | 2977 | * This function is called whenever an Action frame is received for a station |
2388 | * mode interface, but is not processed in kernel. | 2978 | * mode interface, but is not processed in kernel. |
2389 | */ | 2979 | */ |
2390 | bool cfg80211_rx_action(struct net_device *dev, int freq, const u8 *buf, | 2980 | bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, |
2391 | size_t len, gfp_t gfp); | 2981 | size_t len, gfp_t gfp); |
2392 | 2982 | ||
2393 | /** | 2983 | /** |
2394 | * cfg80211_action_tx_status - notification of TX status for Action frame | 2984 | * cfg80211_mgmt_tx_status - notification of TX status for management frame |
2395 | * @dev: network device | 2985 | * @dev: network device |
2396 | * @cookie: Cookie returned by cfg80211_ops::action() | 2986 | * @cookie: Cookie returned by cfg80211_ops::mgmt_tx() |
2397 | * @buf: Action frame (header + body) | 2987 | * @buf: Management frame (header + body) |
2398 | * @len: length of the frame data | 2988 | * @len: length of the frame data |
2399 | * @ack: Whether frame was acknowledged | 2989 | * @ack: Whether frame was acknowledged |
2400 | * @gfp: context flags | 2990 | * @gfp: context flags |
2401 | * | 2991 | * |
2402 | * This function is called whenever an Action frame was requested to be | 2992 | * This function is called whenever a management frame was requested to be |
2403 | * transmitted with cfg80211_ops::action() to report the TX status of the | 2993 | * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the |
2404 | * transmission attempt. | 2994 | * transmission attempt. |
2405 | */ | 2995 | */ |
2406 | void cfg80211_action_tx_status(struct net_device *dev, u64 cookie, | 2996 | void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie, |
2407 | const u8 *buf, size_t len, bool ack, gfp_t gfp); | 2997 | const u8 *buf, size_t len, bool ack, gfp_t gfp); |
2408 | 2998 | ||
2409 | 2999 | ||
2410 | /** | 3000 | /** |
@@ -2420,56 +3010,53 @@ void cfg80211_cqm_rssi_notify(struct net_device *dev, | |||
2420 | enum nl80211_cqm_rssi_threshold_event rssi_event, | 3010 | enum nl80211_cqm_rssi_threshold_event rssi_event, |
2421 | gfp_t gfp); | 3011 | gfp_t gfp); |
2422 | 3012 | ||
2423 | #ifdef __KERNEL__ | 3013 | /** |
3014 | * cfg80211_cqm_pktloss_notify - notify userspace about packetloss to peer | ||
3015 | * @dev: network device | ||
3016 | * @peer: peer's MAC address | ||
3017 | * @num_packets: how many packets were lost -- should be a fixed threshold | ||
3018 | * but probably no less than maybe 50, or maybe a throughput dependent | ||
3019 | * threshold (to account for temporary interference) | ||
3020 | * @gfp: context flags | ||
3021 | */ | ||
3022 | void cfg80211_cqm_pktloss_notify(struct net_device *dev, | ||
3023 | const u8 *peer, u32 num_packets, gfp_t gfp); | ||
2424 | 3024 | ||
2425 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ | 3025 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ |
2426 | 3026 | ||
2427 | /* wiphy_printk helpers, similar to dev_printk */ | 3027 | /* wiphy_printk helpers, similar to dev_printk */ |
2428 | 3028 | ||
2429 | #define wiphy_printk(level, wiphy, format, args...) \ | 3029 | #define wiphy_printk(level, wiphy, format, args...) \ |
2430 | printk(level "%s: " format, wiphy_name(wiphy), ##args) | 3030 | dev_printk(level, &(wiphy)->dev, format, ##args) |
2431 | #define wiphy_emerg(wiphy, format, args...) \ | 3031 | #define wiphy_emerg(wiphy, format, args...) \ |
2432 | wiphy_printk(KERN_EMERG, wiphy, format, ##args) | 3032 | dev_emerg(&(wiphy)->dev, format, ##args) |
2433 | #define wiphy_alert(wiphy, format, args...) \ | 3033 | #define wiphy_alert(wiphy, format, args...) \ |
2434 | wiphy_printk(KERN_ALERT, wiphy, format, ##args) | 3034 | dev_alert(&(wiphy)->dev, format, ##args) |
2435 | #define wiphy_crit(wiphy, format, args...) \ | 3035 | #define wiphy_crit(wiphy, format, args...) \ |
2436 | wiphy_printk(KERN_CRIT, wiphy, format, ##args) | 3036 | dev_crit(&(wiphy)->dev, format, ##args) |
2437 | #define wiphy_err(wiphy, format, args...) \ | 3037 | #define wiphy_err(wiphy, format, args...) \ |
2438 | wiphy_printk(KERN_ERR, wiphy, format, ##args) | 3038 | dev_err(&(wiphy)->dev, format, ##args) |
2439 | #define wiphy_warn(wiphy, format, args...) \ | 3039 | #define wiphy_warn(wiphy, format, args...) \ |
2440 | wiphy_printk(KERN_WARNING, wiphy, format, ##args) | 3040 | dev_warn(&(wiphy)->dev, format, ##args) |
2441 | #define wiphy_notice(wiphy, format, args...) \ | 3041 | #define wiphy_notice(wiphy, format, args...) \ |
2442 | wiphy_printk(KERN_NOTICE, wiphy, format, ##args) | 3042 | dev_notice(&(wiphy)->dev, format, ##args) |
2443 | #define wiphy_info(wiphy, format, args...) \ | 3043 | #define wiphy_info(wiphy, format, args...) \ |
2444 | wiphy_printk(KERN_INFO, wiphy, format, ##args) | 3044 | dev_info(&(wiphy)->dev, format, ##args) |
2445 | |||
2446 | int wiphy_debug(const struct wiphy *wiphy, const char *format, ...) | ||
2447 | __attribute__ ((format (printf, 2, 3))); | ||
2448 | 3045 | ||
2449 | #if defined(DEBUG) | 3046 | #define wiphy_debug(wiphy, format, args...) \ |
2450 | #define wiphy_dbg(wiphy, format, args...) \ | ||
2451 | wiphy_printk(KERN_DEBUG, wiphy, format, ##args) | 3047 | wiphy_printk(KERN_DEBUG, wiphy, format, ##args) |
2452 | #elif defined(CONFIG_DYNAMIC_DEBUG) | 3048 | |
2453 | #define wiphy_dbg(wiphy, format, args...) \ | 3049 | #define wiphy_dbg(wiphy, format, args...) \ |
2454 | dynamic_pr_debug("%s: " format, wiphy_name(wiphy), ##args) | 3050 | dev_dbg(&(wiphy)->dev, format, ##args) |
2455 | #else | ||
2456 | #define wiphy_dbg(wiphy, format, args...) \ | ||
2457 | ({ \ | ||
2458 | if (0) \ | ||
2459 | wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \ | ||
2460 | 0; \ | ||
2461 | }) | ||
2462 | #endif | ||
2463 | 3051 | ||
2464 | #if defined(VERBOSE_DEBUG) | 3052 | #if defined(VERBOSE_DEBUG) |
2465 | #define wiphy_vdbg wiphy_dbg | 3053 | #define wiphy_vdbg wiphy_dbg |
2466 | #else | 3054 | #else |
2467 | |||
2468 | #define wiphy_vdbg(wiphy, format, args...) \ | 3055 | #define wiphy_vdbg(wiphy, format, args...) \ |
2469 | ({ \ | 3056 | ({ \ |
2470 | if (0) \ | 3057 | if (0) \ |
2471 | wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \ | 3058 | wiphy_printk(KERN_DEBUG, wiphy, format, ##args); \ |
2472 | 0; \ | 3059 | 0; \ |
2473 | }) | 3060 | }) |
2474 | #endif | 3061 | #endif |
2475 | 3062 | ||
@@ -2481,6 +3068,4 @@ int wiphy_debug(const struct wiphy *wiphy, const char *format, ...) | |||
2481 | #define wiphy_WARN(wiphy, format, args...) \ | 3068 | #define wiphy_WARN(wiphy, format, args...) \ |
2482 | WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args); | 3069 | WARN(1, "wiphy: %s\n" format, wiphy_name(wiphy), ##args); |
2483 | 3070 | ||
2484 | #endif | ||
2485 | |||
2486 | #endif /* __NET_CFG80211_H */ | 3071 | #endif /* __NET_CFG80211_H */ |
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h index ef6c24a529e1..a4dc5b027bd9 100644 --- a/include/net/cls_cgroup.h +++ b/include/net/cls_cgroup.h | |||
@@ -51,7 +51,8 @@ static inline u32 task_cls_classid(struct task_struct *p) | |||
51 | return 0; | 51 | return 0; |
52 | 52 | ||
53 | rcu_read_lock(); | 53 | rcu_read_lock(); |
54 | id = rcu_dereference(net_cls_subsys_id); | 54 | id = rcu_dereference_index_check(net_cls_subsys_id, |
55 | rcu_read_lock_held()); | ||
55 | if (id >= 0) | 56 | if (id >= 0) |
56 | classid = container_of(task_subsys_state(p, id), | 57 | classid = container_of(task_subsys_state(p, id), |
57 | struct cgroup_cls_state, css)->classid; | 58 | struct cgroup_cls_state, css)->classid; |
diff --git a/include/net/compat.h b/include/net/compat.h index 28d5428ec6a2..9ee75edcc295 100644 --- a/include/net/compat.h +++ b/include/net/compat.h | |||
@@ -43,6 +43,8 @@ extern int compat_sock_get_timestampns(struct sock *, struct timespec __user *); | |||
43 | extern int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *); | 43 | extern int get_compat_msghdr(struct msghdr *, struct compat_msghdr __user *); |
44 | extern int verify_compat_iovec(struct msghdr *, struct iovec *, struct sockaddr *, int); | 44 | extern int verify_compat_iovec(struct msghdr *, struct iovec *, struct sockaddr *, int); |
45 | extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr __user *,unsigned); | 45 | extern asmlinkage long compat_sys_sendmsg(int,struct compat_msghdr __user *,unsigned); |
46 | extern asmlinkage long compat_sys_sendmmsg(int, struct compat_mmsghdr __user *, | ||
47 | unsigned, unsigned); | ||
46 | extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned); | 48 | extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned); |
47 | extern asmlinkage long compat_sys_recvmmsg(int, struct compat_mmsghdr __user *, | 49 | extern asmlinkage long compat_sys_recvmmsg(int, struct compat_mmsghdr __user *, |
48 | unsigned, unsigned, | 50 | unsigned, unsigned, |
diff --git a/include/net/dcbevent.h b/include/net/dcbevent.h new file mode 100644 index 000000000000..bc1e7ef40171 --- /dev/null +++ b/include/net/dcbevent.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2010, Intel Corporation. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | * | ||
8 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
9 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
10 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
11 | * more details. | ||
12 | * | ||
13 | * You should have received a copy of the GNU General Public License along with | ||
14 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | ||
15 | * Place - Suite 330, Boston, MA 02111-1307 USA. | ||
16 | * | ||
17 | * Author: John Fastabend <john.r.fastabend@intel.com> | ||
18 | */ | ||
19 | |||
20 | #ifndef _DCB_EVENT_H | ||
21 | #define _DCB_EVENT_H | ||
22 | |||
23 | enum dcbevent_notif_type { | ||
24 | DCB_APP_EVENT = 1, | ||
25 | }; | ||
26 | |||
27 | extern int register_dcbevent_notifier(struct notifier_block *nb); | ||
28 | extern int unregister_dcbevent_notifier(struct notifier_block *nb); | ||
29 | extern int call_dcbevent_notifiers(unsigned long val, void *v); | ||
30 | |||
31 | #endif | ||
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h index b36ac7e0914d..e5983c9053dc 100644 --- a/include/net/dcbnl.h +++ b/include/net/dcbnl.h | |||
@@ -20,11 +20,33 @@ | |||
20 | #ifndef __NET_DCBNL_H__ | 20 | #ifndef __NET_DCBNL_H__ |
21 | #define __NET_DCBNL_H__ | 21 | #define __NET_DCBNL_H__ |
22 | 22 | ||
23 | #include <linux/dcbnl.h> | ||
24 | |||
25 | struct dcb_app_type { | ||
26 | char name[IFNAMSIZ]; | ||
27 | struct dcb_app app; | ||
28 | struct list_head list; | ||
29 | }; | ||
30 | |||
31 | u8 dcb_setapp(struct net_device *, struct dcb_app *); | ||
32 | u8 dcb_getapp(struct net_device *, struct dcb_app *); | ||
33 | |||
23 | /* | 34 | /* |
24 | * Ops struct for the netlink callbacks. Used by DCB-enabled drivers through | 35 | * Ops struct for the netlink callbacks. Used by DCB-enabled drivers through |
25 | * the netdevice struct. | 36 | * the netdevice struct. |
26 | */ | 37 | */ |
27 | struct dcbnl_rtnl_ops { | 38 | struct dcbnl_rtnl_ops { |
39 | /* IEEE 802.1Qaz std */ | ||
40 | int (*ieee_getets) (struct net_device *, struct ieee_ets *); | ||
41 | int (*ieee_setets) (struct net_device *, struct ieee_ets *); | ||
42 | int (*ieee_getpfc) (struct net_device *, struct ieee_pfc *); | ||
43 | int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *); | ||
44 | int (*ieee_getapp) (struct net_device *, struct dcb_app *); | ||
45 | int (*ieee_setapp) (struct net_device *, struct dcb_app *); | ||
46 | int (*ieee_peer_getets) (struct net_device *, struct ieee_ets *); | ||
47 | int (*ieee_peer_getpfc) (struct net_device *, struct ieee_pfc *); | ||
48 | |||
49 | /* CEE std */ | ||
28 | u8 (*getstate)(struct net_device *); | 50 | u8 (*getstate)(struct net_device *); |
29 | u8 (*setstate)(struct net_device *, u8); | 51 | u8 (*setstate)(struct net_device *, u8); |
30 | void (*getpermhwaddr)(struct net_device *, u8 *); | 52 | void (*getpermhwaddr)(struct net_device *, u8 *); |
@@ -50,6 +72,21 @@ struct dcbnl_rtnl_ops { | |||
50 | void (*setbcnrp)(struct net_device *, int, u8); | 72 | void (*setbcnrp)(struct net_device *, int, u8); |
51 | u8 (*setapp)(struct net_device *, u8, u16, u8); | 73 | u8 (*setapp)(struct net_device *, u8, u16, u8); |
52 | u8 (*getapp)(struct net_device *, u8, u16); | 74 | u8 (*getapp)(struct net_device *, u8, u16); |
75 | u8 (*getfeatcfg)(struct net_device *, int, u8 *); | ||
76 | u8 (*setfeatcfg)(struct net_device *, int, u8); | ||
77 | |||
78 | /* DCBX configuration */ | ||
79 | u8 (*getdcbx)(struct net_device *); | ||
80 | u8 (*setdcbx)(struct net_device *, u8); | ||
81 | |||
82 | /* peer apps */ | ||
83 | int (*peer_getappinfo)(struct net_device *, struct dcb_peer_app_info *, | ||
84 | u16 *); | ||
85 | int (*peer_getapptable)(struct net_device *, struct dcb_app *); | ||
86 | |||
87 | /* CEE peer */ | ||
88 | int (*cee_peer_getpg) (struct net_device *, struct cee_pg *); | ||
89 | int (*cee_peer_getpfc) (struct net_device *, struct cee_pfc *); | ||
53 | }; | 90 | }; |
54 | 91 | ||
55 | #endif /* __NET_DCBNL_H__ */ | 92 | #endif /* __NET_DCBNL_H__ */ |
diff --git a/include/net/dn.h b/include/net/dn.h index e5469f7b67a3..298521e0d8a2 100644 --- a/include/net/dn.h +++ b/include/net/dn.h | |||
@@ -192,10 +192,10 @@ static inline void dn_dn2eth(unsigned char *ethaddr, __le16 addr) | |||
192 | ethaddr[5] = (__u8)(a >> 8); | 192 | ethaddr[5] = (__u8)(a >> 8); |
193 | } | 193 | } |
194 | 194 | ||
195 | static inline void dn_sk_ports_copy(struct flowi *fl, struct dn_scp *scp) | 195 | static inline void dn_sk_ports_copy(struct flowidn *fld, struct dn_scp *scp) |
196 | { | 196 | { |
197 | fl->uli_u.dnports.sport = scp->addrloc; | 197 | fld->fld_sport = scp->addrloc; |
198 | fl->uli_u.dnports.dport = scp->addrrem; | 198 | fld->fld_dport = scp->addrrem; |
199 | } | 199 | } |
200 | 200 | ||
201 | extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu); | 201 | extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu); |
@@ -225,7 +225,7 @@ extern int decnet_di_count; | |||
225 | extern int decnet_dr_count; | 225 | extern int decnet_dr_count; |
226 | extern int decnet_no_fc_max_cwnd; | 226 | extern int decnet_no_fc_max_cwnd; |
227 | 227 | ||
228 | extern int sysctl_decnet_mem[3]; | 228 | extern long sysctl_decnet_mem[3]; |
229 | extern int sysctl_decnet_wmem[3]; | 229 | extern int sysctl_decnet_wmem[3]; |
230 | extern int sysctl_decnet_rmem[3]; | 230 | extern int sysctl_decnet_rmem[3]; |
231 | 231 | ||
diff --git a/include/net/dn_dev.h b/include/net/dn_dev.h index 0916bbf3bdff..b9e32db03f20 100644 --- a/include/net/dn_dev.h +++ b/include/net/dn_dev.h | |||
@@ -5,13 +5,14 @@ | |||
5 | struct dn_dev; | 5 | struct dn_dev; |
6 | 6 | ||
7 | struct dn_ifaddr { | 7 | struct dn_ifaddr { |
8 | struct dn_ifaddr *ifa_next; | 8 | struct dn_ifaddr __rcu *ifa_next; |
9 | struct dn_dev *ifa_dev; | 9 | struct dn_dev *ifa_dev; |
10 | __le16 ifa_local; | 10 | __le16 ifa_local; |
11 | __le16 ifa_address; | 11 | __le16 ifa_address; |
12 | __u8 ifa_flags; | 12 | __u8 ifa_flags; |
13 | __u8 ifa_scope; | 13 | __u8 ifa_scope; |
14 | char ifa_label[IFNAMSIZ]; | 14 | char ifa_label[IFNAMSIZ]; |
15 | struct rcu_head rcu; | ||
15 | }; | 16 | }; |
16 | 17 | ||
17 | #define DN_DEV_S_RU 0 /* Run - working normally */ | 18 | #define DN_DEV_S_RU 0 /* Run - working normally */ |
@@ -83,7 +84,7 @@ struct dn_dev_parms { | |||
83 | 84 | ||
84 | 85 | ||
85 | struct dn_dev { | 86 | struct dn_dev { |
86 | struct dn_ifaddr *ifa_list; | 87 | struct dn_ifaddr __rcu *ifa_list; |
87 | struct net_device *dev; | 88 | struct net_device *dev; |
88 | struct dn_dev_parms parms; | 89 | struct dn_dev_parms parms; |
89 | char use_long; | 90 | char use_long; |
@@ -171,19 +172,27 @@ extern int unregister_dnaddr_notifier(struct notifier_block *nb); | |||
171 | 172 | ||
172 | static inline int dn_dev_islocal(struct net_device *dev, __le16 addr) | 173 | static inline int dn_dev_islocal(struct net_device *dev, __le16 addr) |
173 | { | 174 | { |
174 | struct dn_dev *dn_db = dev->dn_ptr; | 175 | struct dn_dev *dn_db; |
175 | struct dn_ifaddr *ifa; | 176 | struct dn_ifaddr *ifa; |
177 | int res = 0; | ||
176 | 178 | ||
179 | rcu_read_lock(); | ||
180 | dn_db = rcu_dereference(dev->dn_ptr); | ||
177 | if (dn_db == NULL) { | 181 | if (dn_db == NULL) { |
178 | printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n"); | 182 | printk(KERN_DEBUG "dn_dev_islocal: Called for non DECnet device\n"); |
179 | return 0; | 183 | goto out; |
180 | } | 184 | } |
181 | 185 | ||
182 | for(ifa = dn_db->ifa_list; ifa; ifa = ifa->ifa_next) | 186 | for (ifa = rcu_dereference(dn_db->ifa_list); |
183 | if ((addr ^ ifa->ifa_local) == 0) | 187 | ifa != NULL; |
184 | return 1; | 188 | ifa = rcu_dereference(ifa->ifa_next)) |
185 | 189 | if ((addr ^ ifa->ifa_local) == 0) { | |
186 | return 0; | 190 | res = 1; |
191 | break; | ||
192 | } | ||
193 | out: | ||
194 | rcu_read_unlock(); | ||
195 | return res; | ||
187 | } | 196 | } |
188 | 197 | ||
189 | #endif /* _NET_DN_DEV_H */ | 198 | #endif /* _NET_DN_DEV_H */ |
diff --git a/include/net/dn_fib.h b/include/net/dn_fib.h index bbcde3238e58..782ef7cb4930 100644 --- a/include/net/dn_fib.h +++ b/include/net/dn_fib.h | |||
@@ -98,7 +98,7 @@ struct dn_fib_table { | |||
98 | int (*delete)(struct dn_fib_table *t, struct rtmsg *r, | 98 | int (*delete)(struct dn_fib_table *t, struct rtmsg *r, |
99 | struct dn_kern_rta *rta, struct nlmsghdr *n, | 99 | struct dn_kern_rta *rta, struct nlmsghdr *n, |
100 | struct netlink_skb_parms *req); | 100 | struct netlink_skb_parms *req); |
101 | int (*lookup)(struct dn_fib_table *t, const struct flowi *fl, | 101 | int (*lookup)(struct dn_fib_table *t, const struct flowidn *fld, |
102 | struct dn_fib_res *res); | 102 | struct dn_fib_res *res); |
103 | int (*flush)(struct dn_fib_table *t); | 103 | int (*flush)(struct dn_fib_table *t); |
104 | int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb); | 104 | int (*dump)(struct dn_fib_table *t, struct sk_buff *skb, struct netlink_callback *cb); |
@@ -119,12 +119,12 @@ extern struct dn_fib_info *dn_fib_create_info(const struct rtmsg *r, | |||
119 | struct dn_kern_rta *rta, | 119 | struct dn_kern_rta *rta, |
120 | const struct nlmsghdr *nlh, int *errp); | 120 | const struct nlmsghdr *nlh, int *errp); |
121 | extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi, | 121 | extern int dn_fib_semantic_match(int type, struct dn_fib_info *fi, |
122 | const struct flowi *fl, | 122 | const struct flowidn *fld, |
123 | struct dn_fib_res *res); | 123 | struct dn_fib_res *res); |
124 | extern void dn_fib_release_info(struct dn_fib_info *fi); | 124 | extern void dn_fib_release_info(struct dn_fib_info *fi); |
125 | extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type); | 125 | extern __le16 dn_fib_get_attr16(struct rtattr *attr, int attrlen, int type); |
126 | extern void dn_fib_flush(void); | 126 | extern void dn_fib_flush(void); |
127 | extern void dn_fib_select_multipath(const struct flowi *fl, | 127 | extern void dn_fib_select_multipath(const struct flowidn *fld, |
128 | struct dn_fib_res *res); | 128 | struct dn_fib_res *res); |
129 | 129 | ||
130 | /* | 130 | /* |
@@ -141,7 +141,7 @@ extern void dn_fib_table_cleanup(void); | |||
141 | extern void dn_fib_rules_init(void); | 141 | extern void dn_fib_rules_init(void); |
142 | extern void dn_fib_rules_cleanup(void); | 142 | extern void dn_fib_rules_cleanup(void); |
143 | extern unsigned dnet_addr_type(__le16 addr); | 143 | extern unsigned dnet_addr_type(__le16 addr); |
144 | extern int dn_fib_lookup(struct flowi *fl, struct dn_fib_res *res); | 144 | extern int dn_fib_lookup(struct flowidn *fld, struct dn_fib_res *res); |
145 | 145 | ||
146 | extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb); | 146 | extern int dn_fib_dump(struct sk_buff *skb, struct netlink_callback *cb); |
147 | 147 | ||
diff --git a/include/net/dn_route.h b/include/net/dn_route.h index ccadab3aa3f6..81712cfa1ddf 100644 --- a/include/net/dn_route.h +++ b/include/net/dn_route.h | |||
@@ -16,7 +16,7 @@ | |||
16 | *******************************************************************************/ | 16 | *******************************************************************************/ |
17 | 17 | ||
18 | extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri); | 18 | extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri); |
19 | extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags); | 19 | extern int dn_route_output_sock(struct dst_entry **pprt, struct flowidn *, struct sock *sk, int flags); |
20 | extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); | 20 | extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); |
21 | extern void dn_rt_cache_flush(int delay); | 21 | extern void dn_rt_cache_flush(int delay); |
22 | 22 | ||
@@ -67,7 +67,7 @@ extern void dn_rt_cache_flush(int delay); | |||
67 | struct dn_route { | 67 | struct dn_route { |
68 | struct dst_entry dst; | 68 | struct dst_entry dst; |
69 | 69 | ||
70 | struct flowi fl; | 70 | struct flowidn fld; |
71 | 71 | ||
72 | __le16 rt_saddr; | 72 | __le16 rt_saddr; |
73 | __le16 rt_daddr; | 73 | __le16 rt_daddr; |
@@ -80,6 +80,16 @@ struct dn_route { | |||
80 | unsigned rt_type; | 80 | unsigned rt_type; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | static inline bool dn_is_input_route(struct dn_route *rt) | ||
84 | { | ||
85 | return rt->fld.flowidn_iif != 0; | ||
86 | } | ||
87 | |||
88 | static inline bool dn_is_output_route(struct dn_route *rt) | ||
89 | { | ||
90 | return rt->fld.flowidn_iif == 0; | ||
91 | } | ||
92 | |||
83 | extern void dn_route_init(void); | 93 | extern void dn_route_init(void); |
84 | extern void dn_route_cleanup(void); | 94 | extern void dn_route_cleanup(void); |
85 | 95 | ||
diff --git a/include/net/dst.h b/include/net/dst.h index 02386505033d..e12ddfb9eb16 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -16,13 +16,6 @@ | |||
16 | #include <net/neighbour.h> | 16 | #include <net/neighbour.h> |
17 | #include <asm/processor.h> | 17 | #include <asm/processor.h> |
18 | 18 | ||
19 | /* | ||
20 | * 0 - no debugging messages | ||
21 | * 1 - rare events and bugs (default) | ||
22 | * 2 - trace mode. | ||
23 | */ | ||
24 | #define RT_CACHE_DEBUG 0 | ||
25 | |||
26 | #define DST_GC_MIN (HZ/10) | 19 | #define DST_GC_MIN (HZ/10) |
27 | #define DST_GC_INC (HZ/2) | 20 | #define DST_GC_INC (HZ/2) |
28 | #define DST_GC_MAX (120*HZ) | 21 | #define DST_GC_MAX (120*HZ) |
@@ -40,23 +33,10 @@ struct dst_entry { | |||
40 | struct rcu_head rcu_head; | 33 | struct rcu_head rcu_head; |
41 | struct dst_entry *child; | 34 | struct dst_entry *child; |
42 | struct net_device *dev; | 35 | struct net_device *dev; |
43 | short error; | 36 | struct dst_ops *ops; |
44 | short obsolete; | 37 | unsigned long _metrics; |
45 | int flags; | ||
46 | #define DST_HOST 1 | ||
47 | #define DST_NOXFRM 2 | ||
48 | #define DST_NOPOLICY 4 | ||
49 | #define DST_NOHASH 8 | ||
50 | unsigned long expires; | 38 | unsigned long expires; |
51 | |||
52 | unsigned short header_len; /* more space at head required */ | ||
53 | unsigned short trailer_len; /* space to reserve at tail */ | ||
54 | |||
55 | unsigned int rate_tokens; | ||
56 | unsigned long rate_last; /* rate limiting for ICMP */ | ||
57 | |||
58 | struct dst_entry *path; | 39 | struct dst_entry *path; |
59 | |||
60 | struct neighbour *neighbour; | 40 | struct neighbour *neighbour; |
61 | struct hh_cache *hh; | 41 | struct hh_cache *hh; |
62 | #ifdef CONFIG_XFRM | 42 | #ifdef CONFIG_XFRM |
@@ -67,17 +47,16 @@ struct dst_entry { | |||
67 | int (*input)(struct sk_buff*); | 47 | int (*input)(struct sk_buff*); |
68 | int (*output)(struct sk_buff*); | 48 | int (*output)(struct sk_buff*); |
69 | 49 | ||
70 | struct dst_ops *ops; | 50 | short error; |
71 | 51 | short obsolete; | |
72 | u32 metrics[RTAX_MAX]; | 52 | unsigned short header_len; /* more space at head required */ |
73 | 53 | unsigned short trailer_len; /* space to reserve at tail */ | |
74 | #ifdef CONFIG_NET_CLS_ROUTE | 54 | #ifdef CONFIG_IP_ROUTE_CLASSID |
75 | __u32 tclassid; | 55 | __u32 tclassid; |
76 | #else | 56 | #else |
77 | __u32 __pad2; | 57 | __u32 __pad2; |
78 | #endif | 58 | #endif |
79 | 59 | ||
80 | |||
81 | /* | 60 | /* |
82 | * Align __refcnt to a 64 bytes alignment | 61 | * Align __refcnt to a 64 bytes alignment |
83 | * (L1_CACHE_SIZE would be too much) | 62 | * (L1_CACHE_SIZE would be too much) |
@@ -92,20 +71,115 @@ struct dst_entry { | |||
92 | atomic_t __refcnt; /* client references */ | 71 | atomic_t __refcnt; /* client references */ |
93 | int __use; | 72 | int __use; |
94 | unsigned long lastuse; | 73 | unsigned long lastuse; |
74 | int flags; | ||
75 | #define DST_HOST 0x0001 | ||
76 | #define DST_NOXFRM 0x0002 | ||
77 | #define DST_NOPOLICY 0x0004 | ||
78 | #define DST_NOHASH 0x0008 | ||
79 | #define DST_NOCACHE 0x0010 | ||
80 | #define DST_NOCOUNT 0x0020 | ||
95 | union { | 81 | union { |
96 | struct dst_entry *next; | 82 | struct dst_entry *next; |
97 | struct rtable *rt_next; | 83 | struct rtable __rcu *rt_next; |
98 | struct rt6_info *rt6_next; | 84 | struct rt6_info *rt6_next; |
99 | struct dn_route *dn_next; | 85 | struct dn_route __rcu *dn_next; |
100 | }; | 86 | }; |
101 | }; | 87 | }; |
102 | 88 | ||
103 | #ifdef __KERNEL__ | 89 | extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old); |
90 | extern const u32 dst_default_metrics[RTAX_MAX]; | ||
91 | |||
92 | #define DST_METRICS_READ_ONLY 0x1UL | ||
93 | #define __DST_METRICS_PTR(Y) \ | ||
94 | ((u32 *)((Y) & ~DST_METRICS_READ_ONLY)) | ||
95 | #define DST_METRICS_PTR(X) __DST_METRICS_PTR((X)->_metrics) | ||
96 | |||
97 | static inline bool dst_metrics_read_only(const struct dst_entry *dst) | ||
98 | { | ||
99 | return dst->_metrics & DST_METRICS_READ_ONLY; | ||
100 | } | ||
101 | |||
102 | extern void __dst_destroy_metrics_generic(struct dst_entry *dst, unsigned long old); | ||
103 | |||
104 | static inline void dst_destroy_metrics_generic(struct dst_entry *dst) | ||
105 | { | ||
106 | unsigned long val = dst->_metrics; | ||
107 | if (!(val & DST_METRICS_READ_ONLY)) | ||
108 | __dst_destroy_metrics_generic(dst, val); | ||
109 | } | ||
110 | |||
111 | static inline u32 *dst_metrics_write_ptr(struct dst_entry *dst) | ||
112 | { | ||
113 | unsigned long p = dst->_metrics; | ||
114 | |||
115 | BUG_ON(!p); | ||
116 | |||
117 | if (p & DST_METRICS_READ_ONLY) | ||
118 | return dst->ops->cow_metrics(dst, p); | ||
119 | return __DST_METRICS_PTR(p); | ||
120 | } | ||
121 | |||
122 | /* This may only be invoked before the entry has reached global | ||
123 | * visibility. | ||
124 | */ | ||
125 | static inline void dst_init_metrics(struct dst_entry *dst, | ||
126 | const u32 *src_metrics, | ||
127 | bool read_only) | ||
128 | { | ||
129 | dst->_metrics = ((unsigned long) src_metrics) | | ||
130 | (read_only ? DST_METRICS_READ_ONLY : 0); | ||
131 | } | ||
132 | |||
133 | static inline void dst_copy_metrics(struct dst_entry *dest, const struct dst_entry *src) | ||
134 | { | ||
135 | u32 *dst_metrics = dst_metrics_write_ptr(dest); | ||
136 | |||
137 | if (dst_metrics) { | ||
138 | u32 *src_metrics = DST_METRICS_PTR(src); | ||
139 | |||
140 | memcpy(dst_metrics, src_metrics, RTAX_MAX * sizeof(u32)); | ||
141 | } | ||
142 | } | ||
143 | |||
144 | static inline u32 *dst_metrics_ptr(struct dst_entry *dst) | ||
145 | { | ||
146 | return DST_METRICS_PTR(dst); | ||
147 | } | ||
148 | |||
149 | static inline u32 | ||
150 | dst_metric_raw(const struct dst_entry *dst, const int metric) | ||
151 | { | ||
152 | u32 *p = DST_METRICS_PTR(dst); | ||
153 | |||
154 | return p[metric-1]; | ||
155 | } | ||
156 | |||
157 | static inline u32 | ||
158 | dst_metric(const struct dst_entry *dst, const int metric) | ||
159 | { | ||
160 | WARN_ON_ONCE(metric == RTAX_HOPLIMIT || | ||
161 | metric == RTAX_ADVMSS || | ||
162 | metric == RTAX_MTU); | ||
163 | return dst_metric_raw(dst, metric); | ||
164 | } | ||
104 | 165 | ||
105 | static inline u32 | 166 | static inline u32 |
106 | dst_metric(const struct dst_entry *dst, int metric) | 167 | dst_metric_advmss(const struct dst_entry *dst) |
107 | { | 168 | { |
108 | return dst->metrics[metric-1]; | 169 | u32 advmss = dst_metric_raw(dst, RTAX_ADVMSS); |
170 | |||
171 | if (!advmss) | ||
172 | advmss = dst->ops->default_advmss(dst); | ||
173 | |||
174 | return advmss; | ||
175 | } | ||
176 | |||
177 | static inline void dst_metric_set(struct dst_entry *dst, int metric, u32 val) | ||
178 | { | ||
179 | u32 *p = dst_metrics_write_ptr(dst); | ||
180 | |||
181 | if (p) | ||
182 | p[metric-1] = val; | ||
109 | } | 183 | } |
110 | 184 | ||
111 | static inline u32 | 185 | static inline u32 |
@@ -116,11 +190,11 @@ dst_feature(const struct dst_entry *dst, u32 feature) | |||
116 | 190 | ||
117 | static inline u32 dst_mtu(const struct dst_entry *dst) | 191 | static inline u32 dst_mtu(const struct dst_entry *dst) |
118 | { | 192 | { |
119 | u32 mtu = dst_metric(dst, RTAX_MTU); | 193 | u32 mtu = dst_metric_raw(dst, RTAX_MTU); |
120 | /* | 194 | |
121 | * Alexey put it here, so ask him about it :) | 195 | if (!mtu) |
122 | */ | 196 | mtu = dst->ops->default_mtu(dst); |
123 | barrier(); | 197 | |
124 | return mtu; | 198 | return mtu; |
125 | } | 199 | } |
126 | 200 | ||
@@ -133,20 +207,18 @@ static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metr | |||
133 | static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric, | 207 | static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric, |
134 | unsigned long rtt) | 208 | unsigned long rtt) |
135 | { | 209 | { |
136 | dst->metrics[metric-1] = jiffies_to_msecs(rtt); | 210 | dst_metric_set(dst, metric, jiffies_to_msecs(rtt)); |
137 | } | 211 | } |
138 | 212 | ||
139 | static inline u32 | 213 | static inline u32 |
140 | dst_allfrag(const struct dst_entry *dst) | 214 | dst_allfrag(const struct dst_entry *dst) |
141 | { | 215 | { |
142 | int ret = dst_feature(dst, RTAX_FEATURE_ALLFRAG); | 216 | int ret = dst_feature(dst, RTAX_FEATURE_ALLFRAG); |
143 | /* Yes, _exactly_. This is paranoia. */ | ||
144 | barrier(); | ||
145 | return ret; | 217 | return ret; |
146 | } | 218 | } |
147 | 219 | ||
148 | static inline int | 220 | static inline int |
149 | dst_metric_locked(struct dst_entry *dst, int metric) | 221 | dst_metric_locked(const struct dst_entry *dst, int metric) |
150 | { | 222 | { |
151 | return dst_metric(dst, RTAX_LOCK) & (1<<metric); | 223 | return dst_metric(dst, RTAX_LOCK) & (1<<metric); |
152 | } | 224 | } |
@@ -228,23 +300,37 @@ static inline void skb_dst_force(struct sk_buff *skb) | |||
228 | 300 | ||
229 | 301 | ||
230 | /** | 302 | /** |
303 | * __skb_tunnel_rx - prepare skb for rx reinsert | ||
304 | * @skb: buffer | ||
305 | * @dev: tunnel device | ||
306 | * | ||
307 | * After decapsulation, packet is going to re-enter (netif_rx()) our stack, | ||
308 | * so make some cleanups. (no accounting done) | ||
309 | */ | ||
310 | static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) | ||
311 | { | ||
312 | skb->dev = dev; | ||
313 | skb->rxhash = 0; | ||
314 | skb_set_queue_mapping(skb, 0); | ||
315 | skb_dst_drop(skb); | ||
316 | nf_reset(skb); | ||
317 | } | ||
318 | |||
319 | /** | ||
231 | * skb_tunnel_rx - prepare skb for rx reinsert | 320 | * skb_tunnel_rx - prepare skb for rx reinsert |
232 | * @skb: buffer | 321 | * @skb: buffer |
233 | * @dev: tunnel device | 322 | * @dev: tunnel device |
234 | * | 323 | * |
235 | * After decapsulation, packet is going to re-enter (netif_rx()) our stack, | 324 | * After decapsulation, packet is going to re-enter (netif_rx()) our stack, |
236 | * so make some cleanups, and perform accounting. | 325 | * so make some cleanups, and perform accounting. |
326 | * Note: this accounting is not SMP safe. | ||
237 | */ | 327 | */ |
238 | static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) | 328 | static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) |
239 | { | 329 | { |
240 | skb->dev = dev; | ||
241 | /* TODO : stats should be SMP safe */ | 330 | /* TODO : stats should be SMP safe */ |
242 | dev->stats.rx_packets++; | 331 | dev->stats.rx_packets++; |
243 | dev->stats.rx_bytes += skb->len; | 332 | dev->stats.rx_bytes += skb->len; |
244 | skb->rxhash = 0; | 333 | __skb_tunnel_rx(skb, dev); |
245 | skb_set_queue_mapping(skb, 0); | ||
246 | skb_dst_drop(skb); | ||
247 | nf_reset(skb); | ||
248 | } | 334 | } |
249 | 335 | ||
250 | /* Children define the path of the packet through the | 336 | /* Children define the path of the packet through the |
@@ -253,14 +339,15 @@ static inline void skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) | |||
253 | 339 | ||
254 | static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb) | 340 | static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb) |
255 | { | 341 | { |
256 | struct dst_entry *child = skb_dst(skb)->child; | 342 | struct dst_entry *child = dst_clone(skb_dst(skb)->child); |
257 | 343 | ||
258 | skb_dst_drop(skb); | 344 | skb_dst_drop(skb); |
259 | return child; | 345 | return child; |
260 | } | 346 | } |
261 | 347 | ||
262 | extern int dst_discard(struct sk_buff *skb); | 348 | extern int dst_discard(struct sk_buff *skb); |
263 | extern void * dst_alloc(struct dst_ops * ops); | 349 | extern void *dst_alloc(struct dst_ops * ops, struct net_device *dev, |
350 | int initial_ref, int initial_obsolete, int flags); | ||
264 | extern void __dst_free(struct dst_entry * dst); | 351 | extern void __dst_free(struct dst_entry * dst); |
265 | extern struct dst_entry *dst_destroy(struct dst_entry * dst); | 352 | extern struct dst_entry *dst_destroy(struct dst_entry * dst); |
266 | 353 | ||
@@ -329,28 +416,22 @@ extern void dst_init(void); | |||
329 | 416 | ||
330 | /* Flags for xfrm_lookup flags argument. */ | 417 | /* Flags for xfrm_lookup flags argument. */ |
331 | enum { | 418 | enum { |
332 | XFRM_LOOKUP_WAIT = 1 << 0, | 419 | XFRM_LOOKUP_ICMP = 1 << 0, |
333 | XFRM_LOOKUP_ICMP = 1 << 1, | ||
334 | }; | 420 | }; |
335 | 421 | ||
336 | struct flowi; | 422 | struct flowi; |
337 | #ifndef CONFIG_XFRM | 423 | #ifndef CONFIG_XFRM |
338 | static inline int xfrm_lookup(struct net *net, struct dst_entry **dst_p, | 424 | static inline struct dst_entry *xfrm_lookup(struct net *net, |
339 | struct flowi *fl, struct sock *sk, int flags) | 425 | struct dst_entry *dst_orig, |
426 | const struct flowi *fl, struct sock *sk, | ||
427 | int flags) | ||
340 | { | 428 | { |
341 | return 0; | 429 | return dst_orig; |
342 | } | 430 | } |
343 | static inline int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, | ||
344 | struct flowi *fl, struct sock *sk, int flags) | ||
345 | { | ||
346 | return 0; | ||
347 | } | ||
348 | #else | 431 | #else |
349 | extern int xfrm_lookup(struct net *net, struct dst_entry **dst_p, | 432 | extern struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, |
350 | struct flowi *fl, struct sock *sk, int flags); | 433 | const struct flowi *fl, struct sock *sk, |
351 | extern int __xfrm_lookup(struct net *net, struct dst_entry **dst_p, | 434 | int flags); |
352 | struct flowi *fl, struct sock *sk, int flags); | ||
353 | #endif | ||
354 | #endif | 435 | #endif |
355 | 436 | ||
356 | #endif /* _NET_DST_H */ | 437 | #endif /* _NET_DST_H */ |
diff --git a/include/net/dst_ops.h b/include/net/dst_ops.h index d1ff9b7e99b8..dc0746328947 100644 --- a/include/net/dst_ops.h +++ b/include/net/dst_ops.h | |||
@@ -1,6 +1,8 @@ | |||
1 | #ifndef _NET_DST_OPS_H | 1 | #ifndef _NET_DST_OPS_H |
2 | #define _NET_DST_OPS_H | 2 | #define _NET_DST_OPS_H |
3 | #include <linux/types.h> | 3 | #include <linux/types.h> |
4 | #include <linux/percpu_counter.h> | ||
5 | #include <linux/cache.h> | ||
4 | 6 | ||
5 | struct dst_entry; | 7 | struct dst_entry; |
6 | struct kmem_cachep; | 8 | struct kmem_cachep; |
@@ -14,6 +16,9 @@ struct dst_ops { | |||
14 | 16 | ||
15 | int (*gc)(struct dst_ops *ops); | 17 | int (*gc)(struct dst_ops *ops); |
16 | struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); | 18 | struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); |
19 | unsigned int (*default_advmss)(const struct dst_entry *); | ||
20 | unsigned int (*default_mtu)(const struct dst_entry *); | ||
21 | u32 * (*cow_metrics)(struct dst_entry *, unsigned long); | ||
17 | void (*destroy)(struct dst_entry *); | 22 | void (*destroy)(struct dst_entry *); |
18 | void (*ifdown)(struct dst_entry *, | 23 | void (*ifdown)(struct dst_entry *, |
19 | struct net_device *dev, int how); | 24 | struct net_device *dev, int how); |
@@ -22,7 +27,41 @@ struct dst_ops { | |||
22 | void (*update_pmtu)(struct dst_entry *dst, u32 mtu); | 27 | void (*update_pmtu)(struct dst_entry *dst, u32 mtu); |
23 | int (*local_out)(struct sk_buff *skb); | 28 | int (*local_out)(struct sk_buff *skb); |
24 | 29 | ||
25 | atomic_t entries; | ||
26 | struct kmem_cache *kmem_cachep; | 30 | struct kmem_cache *kmem_cachep; |
31 | |||
32 | struct percpu_counter pcpuc_entries ____cacheline_aligned_in_smp; | ||
27 | }; | 33 | }; |
34 | |||
35 | static inline int dst_entries_get_fast(struct dst_ops *dst) | ||
36 | { | ||
37 | return percpu_counter_read_positive(&dst->pcpuc_entries); | ||
38 | } | ||
39 | |||
40 | static inline int dst_entries_get_slow(struct dst_ops *dst) | ||
41 | { | ||
42 | int res; | ||
43 | |||
44 | local_bh_disable(); | ||
45 | res = percpu_counter_sum_positive(&dst->pcpuc_entries); | ||
46 | local_bh_enable(); | ||
47 | return res; | ||
48 | } | ||
49 | |||
50 | static inline void dst_entries_add(struct dst_ops *dst, int val) | ||
51 | { | ||
52 | local_bh_disable(); | ||
53 | percpu_counter_add(&dst->pcpuc_entries, val); | ||
54 | local_bh_enable(); | ||
55 | } | ||
56 | |||
57 | static inline int dst_entries_init(struct dst_ops *dst) | ||
58 | { | ||
59 | return percpu_counter_init(&dst->pcpuc_entries, 0); | ||
60 | } | ||
61 | |||
62 | static inline void dst_entries_destroy(struct dst_ops *dst) | ||
63 | { | ||
64 | percpu_counter_destroy(&dst->pcpuc_entries); | ||
65 | } | ||
66 | |||
28 | #endif | 67 | #endif |
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h index e8923bc20f9f..075f1e3a0fed 100644 --- a/include/net/fib_rules.h +++ b/include/net/fib_rules.h | |||
@@ -20,7 +20,7 @@ struct fib_rule { | |||
20 | u32 table; | 20 | u32 table; |
21 | u8 action; | 21 | u8 action; |
22 | u32 target; | 22 | u32 target; |
23 | struct fib_rule * ctarget; | 23 | struct fib_rule __rcu *ctarget; |
24 | char iifname[IFNAMSIZ]; | 24 | char iifname[IFNAMSIZ]; |
25 | char oifname[IFNAMSIZ]; | 25 | char oifname[IFNAMSIZ]; |
26 | struct rcu_head rcu; | 26 | struct rcu_head rcu; |
@@ -31,6 +31,8 @@ struct fib_lookup_arg { | |||
31 | void *lookup_ptr; | 31 | void *lookup_ptr; |
32 | void *result; | 32 | void *result; |
33 | struct fib_rule *rule; | 33 | struct fib_rule *rule; |
34 | int flags; | ||
35 | #define FIB_LOOKUP_NOREF 1 | ||
34 | }; | 36 | }; |
35 | 37 | ||
36 | struct fib_rules_ops { | 38 | struct fib_rules_ops { |
@@ -106,7 +108,6 @@ static inline u32 frh_get_table(struct fib_rule_hdr *frh, struct nlattr **nla) | |||
106 | 108 | ||
107 | extern struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *, struct net *); | 109 | extern struct fib_rules_ops *fib_rules_register(const struct fib_rules_ops *, struct net *); |
108 | extern void fib_rules_unregister(struct fib_rules_ops *); | 110 | extern void fib_rules_unregister(struct fib_rules_ops *); |
109 | extern void fib_rules_cleanup_ops(struct fib_rules_ops *); | ||
110 | 111 | ||
111 | extern int fib_rules_lookup(struct fib_rules_ops *, | 112 | extern int fib_rules_lookup(struct fib_rules_ops *, |
112 | struct flowi *, int flags, | 113 | struct flowi *, int flags, |
diff --git a/include/net/flow.h b/include/net/flow.h index bb08692a20b0..c6d5fe5ec1bf 100644 --- a/include/net/flow.h +++ b/include/net/flow.h | |||
@@ -10,76 +10,157 @@ | |||
10 | #include <linux/in6.h> | 10 | #include <linux/in6.h> |
11 | #include <asm/atomic.h> | 11 | #include <asm/atomic.h> |
12 | 12 | ||
13 | struct flowi { | 13 | struct flowi_common { |
14 | int oif; | 14 | int flowic_oif; |
15 | int iif; | 15 | int flowic_iif; |
16 | __u32 mark; | 16 | __u32 flowic_mark; |
17 | __u8 flowic_tos; | ||
18 | __u8 flowic_scope; | ||
19 | __u8 flowic_proto; | ||
20 | __u8 flowic_flags; | ||
21 | #define FLOWI_FLAG_ANYSRC 0x01 | ||
22 | #define FLOWI_FLAG_PRECOW_METRICS 0x02 | ||
23 | #define FLOWI_FLAG_CAN_SLEEP 0x04 | ||
24 | __u32 flowic_secid; | ||
25 | }; | ||
17 | 26 | ||
27 | union flowi_uli { | ||
28 | struct { | ||
29 | __be16 dport; | ||
30 | __be16 sport; | ||
31 | } ports; | ||
32 | |||
33 | struct { | ||
34 | __u8 type; | ||
35 | __u8 code; | ||
36 | } icmpt; | ||
37 | |||
38 | struct { | ||
39 | __le16 dport; | ||
40 | __le16 sport; | ||
41 | } dnports; | ||
42 | |||
43 | __be32 spi; | ||
44 | __be32 gre_key; | ||
45 | |||
46 | struct { | ||
47 | __u8 type; | ||
48 | } mht; | ||
49 | }; | ||
50 | |||
51 | struct flowi4 { | ||
52 | struct flowi_common __fl_common; | ||
53 | #define flowi4_oif __fl_common.flowic_oif | ||
54 | #define flowi4_iif __fl_common.flowic_iif | ||
55 | #define flowi4_mark __fl_common.flowic_mark | ||
56 | #define flowi4_tos __fl_common.flowic_tos | ||
57 | #define flowi4_scope __fl_common.flowic_scope | ||
58 | #define flowi4_proto __fl_common.flowic_proto | ||
59 | #define flowi4_flags __fl_common.flowic_flags | ||
60 | #define flowi4_secid __fl_common.flowic_secid | ||
61 | __be32 daddr; | ||
62 | __be32 saddr; | ||
63 | union flowi_uli uli; | ||
64 | #define fl4_sport uli.ports.sport | ||
65 | #define fl4_dport uli.ports.dport | ||
66 | #define fl4_icmp_type uli.icmpt.type | ||
67 | #define fl4_icmp_code uli.icmpt.code | ||
68 | #define fl4_ipsec_spi uli.spi | ||
69 | #define fl4_mh_type uli.mht.type | ||
70 | #define fl4_gre_key uli.gre_key | ||
71 | }; | ||
72 | |||
73 | static inline void flowi4_init_output(struct flowi4 *fl4, int oif, | ||
74 | __u32 mark, __u8 tos, __u8 scope, | ||
75 | __u8 proto, __u8 flags, | ||
76 | __be32 daddr, __be32 saddr, | ||
77 | __be16 dport, __be32 sport) | ||
78 | { | ||
79 | fl4->flowi4_oif = oif; | ||
80 | fl4->flowi4_iif = 0; | ||
81 | fl4->flowi4_mark = mark; | ||
82 | fl4->flowi4_tos = tos; | ||
83 | fl4->flowi4_scope = scope; | ||
84 | fl4->flowi4_proto = proto; | ||
85 | fl4->flowi4_flags = flags; | ||
86 | fl4->flowi4_secid = 0; | ||
87 | fl4->daddr = daddr; | ||
88 | fl4->saddr = saddr; | ||
89 | fl4->fl4_dport = dport; | ||
90 | fl4->fl4_sport = sport; | ||
91 | } | ||
92 | |||
93 | |||
94 | struct flowi6 { | ||
95 | struct flowi_common __fl_common; | ||
96 | #define flowi6_oif __fl_common.flowic_oif | ||
97 | #define flowi6_iif __fl_common.flowic_iif | ||
98 | #define flowi6_mark __fl_common.flowic_mark | ||
99 | #define flowi6_tos __fl_common.flowic_tos | ||
100 | #define flowi6_scope __fl_common.flowic_scope | ||
101 | #define flowi6_proto __fl_common.flowic_proto | ||
102 | #define flowi6_flags __fl_common.flowic_flags | ||
103 | #define flowi6_secid __fl_common.flowic_secid | ||
104 | struct in6_addr daddr; | ||
105 | struct in6_addr saddr; | ||
106 | __be32 flowlabel; | ||
107 | union flowi_uli uli; | ||
108 | #define fl6_sport uli.ports.sport | ||
109 | #define fl6_dport uli.ports.dport | ||
110 | #define fl6_icmp_type uli.icmpt.type | ||
111 | #define fl6_icmp_code uli.icmpt.code | ||
112 | #define fl6_ipsec_spi uli.spi | ||
113 | #define fl6_mh_type uli.mht.type | ||
114 | #define fl6_gre_key uli.gre_key | ||
115 | }; | ||
116 | |||
117 | struct flowidn { | ||
118 | struct flowi_common __fl_common; | ||
119 | #define flowidn_oif __fl_common.flowic_oif | ||
120 | #define flowidn_iif __fl_common.flowic_iif | ||
121 | #define flowidn_mark __fl_common.flowic_mark | ||
122 | #define flowidn_scope __fl_common.flowic_scope | ||
123 | #define flowidn_proto __fl_common.flowic_proto | ||
124 | #define flowidn_flags __fl_common.flowic_flags | ||
125 | __le16 daddr; | ||
126 | __le16 saddr; | ||
127 | union flowi_uli uli; | ||
128 | #define fld_sport uli.ports.sport | ||
129 | #define fld_dport uli.ports.dport | ||
130 | }; | ||
131 | |||
132 | struct flowi { | ||
18 | union { | 133 | union { |
19 | struct { | 134 | struct flowi_common __fl_common; |
20 | __be32 daddr; | 135 | struct flowi4 ip4; |
21 | __be32 saddr; | 136 | struct flowi6 ip6; |
22 | __u8 tos; | 137 | struct flowidn dn; |
23 | __u8 scope; | 138 | } u; |
24 | } ip4_u; | 139 | #define flowi_oif u.__fl_common.flowic_oif |
25 | 140 | #define flowi_iif u.__fl_common.flowic_iif | |
26 | struct { | 141 | #define flowi_mark u.__fl_common.flowic_mark |
27 | struct in6_addr daddr; | 142 | #define flowi_tos u.__fl_common.flowic_tos |
28 | struct in6_addr saddr; | 143 | #define flowi_scope u.__fl_common.flowic_scope |
29 | __be32 flowlabel; | 144 | #define flowi_proto u.__fl_common.flowic_proto |
30 | } ip6_u; | 145 | #define flowi_flags u.__fl_common.flowic_flags |
31 | 146 | #define flowi_secid u.__fl_common.flowic_secid | |
32 | struct { | ||
33 | __le16 daddr; | ||
34 | __le16 saddr; | ||
35 | __u8 scope; | ||
36 | } dn_u; | ||
37 | } nl_u; | ||
38 | #define fld_dst nl_u.dn_u.daddr | ||
39 | #define fld_src nl_u.dn_u.saddr | ||
40 | #define fld_scope nl_u.dn_u.scope | ||
41 | #define fl6_dst nl_u.ip6_u.daddr | ||
42 | #define fl6_src nl_u.ip6_u.saddr | ||
43 | #define fl6_flowlabel nl_u.ip6_u.flowlabel | ||
44 | #define fl4_dst nl_u.ip4_u.daddr | ||
45 | #define fl4_src nl_u.ip4_u.saddr | ||
46 | #define fl4_tos nl_u.ip4_u.tos | ||
47 | #define fl4_scope nl_u.ip4_u.scope | ||
48 | |||
49 | __u8 proto; | ||
50 | __u8 flags; | ||
51 | #define FLOWI_FLAG_ANYSRC 0x01 | ||
52 | union { | ||
53 | struct { | ||
54 | __be16 sport; | ||
55 | __be16 dport; | ||
56 | } ports; | ||
57 | |||
58 | struct { | ||
59 | __u8 type; | ||
60 | __u8 code; | ||
61 | } icmpt; | ||
62 | |||
63 | struct { | ||
64 | __le16 sport; | ||
65 | __le16 dport; | ||
66 | } dnports; | ||
67 | |||
68 | __be32 spi; | ||
69 | |||
70 | struct { | ||
71 | __u8 type; | ||
72 | } mht; | ||
73 | } uli_u; | ||
74 | #define fl_ip_sport uli_u.ports.sport | ||
75 | #define fl_ip_dport uli_u.ports.dport | ||
76 | #define fl_icmp_type uli_u.icmpt.type | ||
77 | #define fl_icmp_code uli_u.icmpt.code | ||
78 | #define fl_ipsec_spi uli_u.spi | ||
79 | #define fl_mh_type uli_u.mht.type | ||
80 | __u32 secid; /* used by xfrm; see secid.txt */ | ||
81 | } __attribute__((__aligned__(BITS_PER_LONG/8))); | 147 | } __attribute__((__aligned__(BITS_PER_LONG/8))); |
82 | 148 | ||
149 | static inline struct flowi *flowi4_to_flowi(struct flowi4 *fl4) | ||
150 | { | ||
151 | return container_of(fl4, struct flowi, u.ip4); | ||
152 | } | ||
153 | |||
154 | static inline struct flowi *flowi6_to_flowi(struct flowi6 *fl6) | ||
155 | { | ||
156 | return container_of(fl6, struct flowi, u.ip6); | ||
157 | } | ||
158 | |||
159 | static inline struct flowi *flowidn_to_flowi(struct flowidn *fldn) | ||
160 | { | ||
161 | return container_of(fldn, struct flowi, u.dn); | ||
162 | } | ||
163 | |||
83 | #define FLOW_DIR_IN 0 | 164 | #define FLOW_DIR_IN 0 |
84 | #define FLOW_DIR_OUT 1 | 165 | #define FLOW_DIR_OUT 1 |
85 | #define FLOW_DIR_FWD 2 | 166 | #define FLOW_DIR_FWD 2 |
@@ -99,20 +180,14 @@ struct flow_cache_ops { | |||
99 | }; | 180 | }; |
100 | 181 | ||
101 | typedef struct flow_cache_object *(*flow_resolve_t)( | 182 | typedef struct flow_cache_object *(*flow_resolve_t)( |
102 | struct net *net, struct flowi *key, u16 family, | 183 | struct net *net, const struct flowi *key, u16 family, |
103 | u8 dir, struct flow_cache_object *oldobj, void *ctx); | 184 | u8 dir, struct flow_cache_object *oldobj, void *ctx); |
104 | 185 | ||
105 | extern struct flow_cache_object *flow_cache_lookup( | 186 | extern struct flow_cache_object *flow_cache_lookup( |
106 | struct net *net, struct flowi *key, u16 family, | 187 | struct net *net, const struct flowi *key, u16 family, |
107 | u8 dir, flow_resolve_t resolver, void *ctx); | 188 | u8 dir, flow_resolve_t resolver, void *ctx); |
108 | 189 | ||
109 | extern void flow_cache_flush(void); | 190 | extern void flow_cache_flush(void); |
110 | extern atomic_t flow_cache_genid; | 191 | extern atomic_t flow_cache_genid; |
111 | 192 | ||
112 | static inline int flow_cache_uli_match(struct flowi *fl1, struct flowi *fl2) | ||
113 | { | ||
114 | return (fl1->proto == fl2->proto && | ||
115 | !memcmp(&fl1->uli_u, &fl2->uli_u, sizeof(fl1->uli_u))); | ||
116 | } | ||
117 | |||
118 | #endif | 193 | #endif |
diff --git a/include/net/garp.h b/include/net/garp.h index 825f172caba9..834d8add9e5f 100644 --- a/include/net/garp.h +++ b/include/net/garp.h | |||
@@ -104,10 +104,12 @@ struct garp_applicant { | |||
104 | struct sk_buff_head queue; | 104 | struct sk_buff_head queue; |
105 | struct sk_buff *pdu; | 105 | struct sk_buff *pdu; |
106 | struct rb_root gid; | 106 | struct rb_root gid; |
107 | struct rcu_head rcu; | ||
107 | }; | 108 | }; |
108 | 109 | ||
109 | struct garp_port { | 110 | struct garp_port { |
110 | struct garp_applicant *applicants[GARP_APPLICATION_MAX + 1]; | 111 | struct garp_applicant __rcu *applicants[GARP_APPLICATION_MAX + 1]; |
112 | struct rcu_head rcu; | ||
111 | }; | 113 | }; |
112 | 114 | ||
113 | extern int garp_register_application(struct garp_application *app); | 115 | extern int garp_register_application(struct garp_application *app); |
diff --git a/include/net/gen_stats.h b/include/net/gen_stats.h index fa157712e982..a79b6cfb02a8 100644 --- a/include/net/gen_stats.h +++ b/include/net/gen_stats.h | |||
@@ -11,7 +11,7 @@ struct gnet_dump { | |||
11 | struct sk_buff * skb; | 11 | struct sk_buff * skb; |
12 | struct nlattr * tail; | 12 | struct nlattr * tail; |
13 | 13 | ||
14 | /* Backward compatability */ | 14 | /* Backward compatibility */ |
15 | int compat_tc_stats; | 15 | int compat_tc_stats; |
16 | int compat_xstats; | 16 | int compat_xstats; |
17 | void * xstats; | 17 | void * xstats; |
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index f7dcd2c70412..d420f28b6d60 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
@@ -20,6 +20,9 @@ struct genl_multicast_group { | |||
20 | u32 id; | 20 | u32 id; |
21 | }; | 21 | }; |
22 | 22 | ||
23 | struct genl_ops; | ||
24 | struct genl_info; | ||
25 | |||
23 | /** | 26 | /** |
24 | * struct genl_family - generic netlink family | 27 | * struct genl_family - generic netlink family |
25 | * @id: protocol family idenfitier | 28 | * @id: protocol family idenfitier |
@@ -29,6 +32,10 @@ struct genl_multicast_group { | |||
29 | * @maxattr: maximum number of attributes supported | 32 | * @maxattr: maximum number of attributes supported |
30 | * @netnsok: set to true if the family can handle network | 33 | * @netnsok: set to true if the family can handle network |
31 | * namespaces and should be presented in all of them | 34 | * namespaces and should be presented in all of them |
35 | * @pre_doit: called before an operation's doit callback, it may | ||
36 | * do additional, common, filtering and return an error | ||
37 | * @post_doit: called after an operation's doit callback, it may | ||
38 | * undo operations done by pre_doit, for example release locks | ||
32 | * @attrbuf: buffer to store parsed attributes | 39 | * @attrbuf: buffer to store parsed attributes |
33 | * @ops_list: list of all assigned operations | 40 | * @ops_list: list of all assigned operations |
34 | * @family_list: family list | 41 | * @family_list: family list |
@@ -41,6 +48,12 @@ struct genl_family { | |||
41 | unsigned int version; | 48 | unsigned int version; |
42 | unsigned int maxattr; | 49 | unsigned int maxattr; |
43 | bool netnsok; | 50 | bool netnsok; |
51 | int (*pre_doit)(struct genl_ops *ops, | ||
52 | struct sk_buff *skb, | ||
53 | struct genl_info *info); | ||
54 | void (*post_doit)(struct genl_ops *ops, | ||
55 | struct sk_buff *skb, | ||
56 | struct genl_info *info); | ||
44 | struct nlattr ** attrbuf; /* private */ | 57 | struct nlattr ** attrbuf; /* private */ |
45 | struct list_head ops_list; /* private */ | 58 | struct list_head ops_list; /* private */ |
46 | struct list_head family_list; /* private */ | 59 | struct list_head family_list; /* private */ |
@@ -55,6 +68,8 @@ struct genl_family { | |||
55 | * @genlhdr: generic netlink message header | 68 | * @genlhdr: generic netlink message header |
56 | * @userhdr: user specific header | 69 | * @userhdr: user specific header |
57 | * @attrs: netlink attributes | 70 | * @attrs: netlink attributes |
71 | * @_net: network namespace | ||
72 | * @user_ptr: user pointers | ||
58 | */ | 73 | */ |
59 | struct genl_info { | 74 | struct genl_info { |
60 | u32 snd_seq; | 75 | u32 snd_seq; |
@@ -66,6 +81,7 @@ struct genl_info { | |||
66 | #ifdef CONFIG_NET_NS | 81 | #ifdef CONFIG_NET_NS |
67 | struct net * _net; | 82 | struct net * _net; |
68 | #endif | 83 | #endif |
84 | void * user_ptr[2]; | ||
69 | }; | 85 | }; |
70 | 86 | ||
71 | static inline struct net *genl_info_net(struct genl_info *info) | 87 | static inline struct net *genl_info_net(struct genl_info *info) |
@@ -81,6 +97,7 @@ static inline void genl_info_net_set(struct genl_info *info, struct net *net) | |||
81 | /** | 97 | /** |
82 | * struct genl_ops - generic netlink operations | 98 | * struct genl_ops - generic netlink operations |
83 | * @cmd: command identifier | 99 | * @cmd: command identifier |
100 | * @internal_flags: flags used by the family | ||
84 | * @flags: flags | 101 | * @flags: flags |
85 | * @policy: attribute validation policy | 102 | * @policy: attribute validation policy |
86 | * @doit: standard command callback | 103 | * @doit: standard command callback |
@@ -90,6 +107,7 @@ static inline void genl_info_net_set(struct genl_info *info, struct net *net) | |||
90 | */ | 107 | */ |
91 | struct genl_ops { | 108 | struct genl_ops { |
92 | u8 cmd; | 109 | u8 cmd; |
110 | u8 internal_flags; | ||
93 | unsigned int flags; | 111 | unsigned int flags; |
94 | const struct nla_policy *policy; | 112 | const struct nla_policy *policy; |
95 | int (*doit)(struct sk_buff *skb, | 113 | int (*doit)(struct sk_buff *skb, |
@@ -177,7 +195,8 @@ static inline int genlmsg_end(struct sk_buff *skb, void *hdr) | |||
177 | */ | 195 | */ |
178 | static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr) | 196 | static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr) |
179 | { | 197 | { |
180 | nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); | 198 | if (hdr) |
199 | nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); | ||
181 | } | 200 | } |
182 | 201 | ||
183 | /** | 202 | /** |
@@ -241,7 +260,7 @@ static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info) | |||
241 | 260 | ||
242 | /** | 261 | /** |
243 | * gennlmsg_data - head of message payload | 262 | * gennlmsg_data - head of message payload |
244 | * @gnlh: genetlink messsage header | 263 | * @gnlh: genetlink message header |
245 | */ | 264 | */ |
246 | static inline void *genlmsg_data(const struct genlmsghdr *gnlh) | 265 | static inline void *genlmsg_data(const struct genlmsghdr *gnlh) |
247 | { | 266 | { |
diff --git a/include/net/gre.h b/include/net/gre.h new file mode 100644 index 000000000000..82665474bcb7 --- /dev/null +++ b/include/net/gre.h | |||
@@ -0,0 +1,18 @@ | |||
1 | #ifndef __LINUX_GRE_H | ||
2 | #define __LINUX_GRE_H | ||
3 | |||
4 | #include <linux/skbuff.h> | ||
5 | |||
6 | #define GREPROTO_CISCO 0 | ||
7 | #define GREPROTO_PPTP 1 | ||
8 | #define GREPROTO_MAX 2 | ||
9 | |||
10 | struct gre_protocol { | ||
11 | int (*handler)(struct sk_buff *skb); | ||
12 | void (*err_handler)(struct sk_buff *skb, u32 info); | ||
13 | }; | ||
14 | |||
15 | int gre_add_protocol(const struct gre_protocol *proto, u8 version); | ||
16 | int gre_del_protocol(const struct gre_protocol *proto, u8 version); | ||
17 | |||
18 | #endif | ||
diff --git a/include/net/icmp.h b/include/net/icmp.h index 6e991e0d0d6f..f0698b955b73 100644 --- a/include/net/icmp.h +++ b/include/net/icmp.h | |||
@@ -45,7 +45,4 @@ extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg); | |||
45 | extern int icmp_init(void); | 45 | extern int icmp_init(void); |
46 | extern void icmp_out_count(struct net *net, unsigned char type); | 46 | extern void icmp_out_count(struct net *net, unsigned char type); |
47 | 47 | ||
48 | /* Move into dst.h ? */ | ||
49 | extern int xrlim_allow(struct dst_entry *dst, int timeout); | ||
50 | |||
51 | #endif /* _ICMP_H */ | 48 | #endif /* _ICMP_H */ |
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h index af49f8ab7f81..b0be5fb9de19 100644 --- a/include/net/ieee80211_radiotap.h +++ b/include/net/ieee80211_radiotap.h | |||
@@ -178,6 +178,11 @@ struct ieee80211_radiotap_header { | |||
178 | * | 178 | * |
179 | * Number of unicast retries a transmitted frame used. | 179 | * Number of unicast retries a transmitted frame used. |
180 | * | 180 | * |
181 | * IEEE80211_RADIOTAP_MCS u8, u8, u8 unitless | ||
182 | * | ||
183 | * Contains a bitmap of known fields/flags, the flags, and | ||
184 | * the MCS index. | ||
185 | * | ||
181 | */ | 186 | */ |
182 | enum ieee80211_radiotap_type { | 187 | enum ieee80211_radiotap_type { |
183 | IEEE80211_RADIOTAP_TSFT = 0, | 188 | IEEE80211_RADIOTAP_TSFT = 0, |
@@ -199,6 +204,8 @@ enum ieee80211_radiotap_type { | |||
199 | IEEE80211_RADIOTAP_RTS_RETRIES = 16, | 204 | IEEE80211_RADIOTAP_RTS_RETRIES = 16, |
200 | IEEE80211_RADIOTAP_DATA_RETRIES = 17, | 205 | IEEE80211_RADIOTAP_DATA_RETRIES = 17, |
201 | 206 | ||
207 | IEEE80211_RADIOTAP_MCS = 19, | ||
208 | |||
202 | /* valid in every it_present bitmap, even vendor namespaces */ | 209 | /* valid in every it_present bitmap, even vendor namespaces */ |
203 | IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, | 210 | IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, |
204 | IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, | 211 | IEEE80211_RADIOTAP_VENDOR_NAMESPACE = 30, |
@@ -245,6 +252,24 @@ enum ieee80211_radiotap_type { | |||
245 | #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ | 252 | #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ |
246 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ | 253 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ |
247 | 254 | ||
255 | |||
256 | /* For IEEE80211_RADIOTAP_MCS */ | ||
257 | #define IEEE80211_RADIOTAP_MCS_HAVE_BW 0x01 | ||
258 | #define IEEE80211_RADIOTAP_MCS_HAVE_MCS 0x02 | ||
259 | #define IEEE80211_RADIOTAP_MCS_HAVE_GI 0x04 | ||
260 | #define IEEE80211_RADIOTAP_MCS_HAVE_FMT 0x08 | ||
261 | #define IEEE80211_RADIOTAP_MCS_HAVE_FEC 0x10 | ||
262 | |||
263 | #define IEEE80211_RADIOTAP_MCS_BW_MASK 0x03 | ||
264 | #define IEEE80211_RADIOTAP_MCS_BW_20 0 | ||
265 | #define IEEE80211_RADIOTAP_MCS_BW_40 1 | ||
266 | #define IEEE80211_RADIOTAP_MCS_BW_20L 2 | ||
267 | #define IEEE80211_RADIOTAP_MCS_BW_20U 3 | ||
268 | #define IEEE80211_RADIOTAP_MCS_SGI 0x04 | ||
269 | #define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 | ||
270 | #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 | ||
271 | |||
272 | |||
248 | /* Ugly macro to convert literal channel numbers into their mhz equivalents | 273 | /* Ugly macro to convert literal channel numbers into their mhz equivalents |
249 | * There are certianly some conditions that will break this (like feeding it '30') | 274 | * There are certianly some conditions that will break this (like feeding it '30') |
250 | * but they shouldn't arise since nothing talks on channel 30. */ | 275 | * but they shouldn't arise since nothing talks on channel 30. */ |
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h index f95ff8d9aa47..11cf373970a9 100644 --- a/include/net/if_inet6.h +++ b/include/net/if_inet6.h | |||
@@ -30,8 +30,6 @@ | |||
30 | #define IF_PREFIX_ONLINK 0x01 | 30 | #define IF_PREFIX_ONLINK 0x01 |
31 | #define IF_PREFIX_AUTOCONF 0x02 | 31 | #define IF_PREFIX_AUTOCONF 0x02 |
32 | 32 | ||
33 | #ifdef __KERNEL__ | ||
34 | |||
35 | enum { | 33 | enum { |
36 | INET6_IFADDR_STATE_DAD, | 34 | INET6_IFADDR_STATE_DAD, |
37 | INET6_IFADDR_STATE_POSTDAD, | 35 | INET6_IFADDR_STATE_POSTDAD, |
@@ -89,10 +87,11 @@ struct ip6_sf_socklist { | |||
89 | struct ipv6_mc_socklist { | 87 | struct ipv6_mc_socklist { |
90 | struct in6_addr addr; | 88 | struct in6_addr addr; |
91 | int ifindex; | 89 | int ifindex; |
92 | struct ipv6_mc_socklist *next; | 90 | struct ipv6_mc_socklist __rcu *next; |
93 | rwlock_t sflock; | 91 | rwlock_t sflock; |
94 | unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */ | 92 | unsigned int sfmode; /* MCAST_{INCLUDE,EXCLUDE} */ |
95 | struct ip6_sf_socklist *sflist; | 93 | struct ip6_sf_socklist *sflist; |
94 | struct rcu_head rcu; | ||
96 | }; | 95 | }; |
97 | 96 | ||
98 | struct ip6_sf_list { | 97 | struct ip6_sf_list { |
@@ -155,8 +154,8 @@ struct ifacaddr6 { | |||
155 | struct ipv6_devstat { | 154 | struct ipv6_devstat { |
156 | struct proc_dir_entry *proc_dir_entry; | 155 | struct proc_dir_entry *proc_dir_entry; |
157 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6); | 156 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6); |
158 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6); | 157 | DEFINE_SNMP_STAT_ATOMIC(struct icmpv6_mib_device, icmpv6dev); |
159 | DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg); | 158 | DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib_device, icmpv6msgdev); |
160 | }; | 159 | }; |
161 | 160 | ||
162 | struct inet6_dev { | 161 | struct inet6_dev { |
@@ -195,7 +194,7 @@ struct inet6_dev { | |||
195 | struct rcu_head rcu; | 194 | struct rcu_head rcu; |
196 | }; | 195 | }; |
197 | 196 | ||
198 | static inline void ipv6_eth_mc_map(struct in6_addr *addr, char *buf) | 197 | static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf) |
199 | { | 198 | { |
200 | /* | 199 | /* |
201 | * +-------+-------+-------+-------+-------+-------+ | 200 | * +-------+-------+-------+-------+-------+-------+ |
@@ -209,7 +208,7 @@ static inline void ipv6_eth_mc_map(struct in6_addr *addr, char *buf) | |||
209 | memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32)); | 208 | memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32)); |
210 | } | 209 | } |
211 | 210 | ||
212 | static inline void ipv6_tr_mc_map(struct in6_addr *addr, char *buf) | 211 | static inline void ipv6_tr_mc_map(const struct in6_addr *addr, char *buf) |
213 | { | 212 | { |
214 | /* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */ | 213 | /* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */ |
215 | 214 | ||
@@ -285,5 +284,20 @@ static inline void ipv6_ib_mc_map(const struct in6_addr *addr, | |||
285 | buf[9] = broadcast[9]; | 284 | buf[9] = broadcast[9]; |
286 | memcpy(buf + 10, addr->s6_addr + 6, 10); | 285 | memcpy(buf + 10, addr->s6_addr + 6, 10); |
287 | } | 286 | } |
288 | #endif | 287 | |
288 | static inline int ipv6_ipgre_mc_map(const struct in6_addr *addr, | ||
289 | const unsigned char *broadcast, char *buf) | ||
290 | { | ||
291 | if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0) { | ||
292 | memcpy(buf, broadcast, 4); | ||
293 | } else { | ||
294 | /* v4mapped? */ | ||
295 | if ((addr->s6_addr32[0] | addr->s6_addr32[1] | | ||
296 | (addr->s6_addr32[2] ^ htonl(0x0000ffff))) != 0) | ||
297 | return -EINVAL; | ||
298 | memcpy(buf, &addr->s6_addr32[3], 4); | ||
299 | } | ||
300 | return 0; | ||
301 | } | ||
302 | |||
289 | #endif | 303 | #endif |
diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h index aae08f686633..3207e58ee019 100644 --- a/include/net/inet6_connection_sock.h +++ b/include/net/inet6_connection_sock.h | |||
@@ -25,6 +25,9 @@ struct sockaddr; | |||
25 | extern int inet6_csk_bind_conflict(const struct sock *sk, | 25 | extern int inet6_csk_bind_conflict(const struct sock *sk, |
26 | const struct inet_bind_bucket *tb); | 26 | const struct inet_bind_bucket *tb); |
27 | 27 | ||
28 | extern struct dst_entry* inet6_csk_route_req(struct sock *sk, | ||
29 | const struct request_sock *req); | ||
30 | |||
28 | extern struct request_sock *inet6_csk_search_req(const struct sock *sk, | 31 | extern struct request_sock *inet6_csk_search_req(const struct sock *sk, |
29 | struct request_sock ***prevp, | 32 | struct request_sock ***prevp, |
30 | const __be16 rport, | 33 | const __be16 rport, |
@@ -38,5 +41,5 @@ extern void inet6_csk_reqsk_queue_hash_add(struct sock *sk, | |||
38 | 41 | ||
39 | extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); | 42 | extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); |
40 | 43 | ||
41 | extern int inet6_csk_xmit(struct sk_buff *skb); | 44 | extern int inet6_csk_xmit(struct sk_buff *skb, struct flowi *fl); |
42 | #endif /* _INET6_CONNECTION_SOCK_H */ | 45 | #endif /* _INET6_CONNECTION_SOCK_H */ |
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index b6d3b55da19b..e6db62e756dc 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h | |||
@@ -36,14 +36,14 @@ struct tcp_congestion_ops; | |||
36 | * (i.e. things that depend on the address family) | 36 | * (i.e. things that depend on the address family) |
37 | */ | 37 | */ |
38 | struct inet_connection_sock_af_ops { | 38 | struct inet_connection_sock_af_ops { |
39 | int (*queue_xmit)(struct sk_buff *skb); | 39 | int (*queue_xmit)(struct sk_buff *skb, struct flowi *fl); |
40 | void (*send_check)(struct sock *sk, struct sk_buff *skb); | 40 | void (*send_check)(struct sock *sk, struct sk_buff *skb); |
41 | int (*rebuild_header)(struct sock *sk); | 41 | int (*rebuild_header)(struct sock *sk); |
42 | int (*conn_request)(struct sock *sk, struct sk_buff *skb); | 42 | int (*conn_request)(struct sock *sk, struct sk_buff *skb); |
43 | struct sock *(*syn_recv_sock)(struct sock *sk, struct sk_buff *skb, | 43 | struct sock *(*syn_recv_sock)(struct sock *sk, struct sk_buff *skb, |
44 | struct request_sock *req, | 44 | struct request_sock *req, |
45 | struct dst_entry *dst); | 45 | struct dst_entry *dst); |
46 | int (*remember_stamp)(struct sock *sk); | 46 | struct inet_peer *(*get_peer)(struct sock *sk, bool *release_it); |
47 | u16 net_header_len; | 47 | u16 net_header_len; |
48 | u16 sockaddr_len; | 48 | u16 sockaddr_len; |
49 | int (*setsockopt)(struct sock *sk, int level, int optname, | 49 | int (*setsockopt)(struct sock *sk, int level, int optname, |
@@ -125,13 +125,13 @@ struct inet_connection_sock { | |||
125 | int probe_size; | 125 | int probe_size; |
126 | } icsk_mtup; | 126 | } icsk_mtup; |
127 | u32 icsk_ca_priv[16]; | 127 | u32 icsk_ca_priv[16]; |
128 | u32 icsk_user_timeout; | ||
128 | #define ICSK_CA_PRIV_SIZE (16 * sizeof(u32)) | 129 | #define ICSK_CA_PRIV_SIZE (16 * sizeof(u32)) |
129 | }; | 130 | }; |
130 | 131 | ||
131 | #define ICSK_TIME_RETRANS 1 /* Retransmit timer */ | 132 | #define ICSK_TIME_RETRANS 1 /* Retransmit timer */ |
132 | #define ICSK_TIME_DACK 2 /* Delayed ack timer */ | 133 | #define ICSK_TIME_DACK 2 /* Delayed ack timer */ |
133 | #define ICSK_TIME_PROBE0 3 /* Zero window probe timer */ | 134 | #define ICSK_TIME_PROBE0 3 /* Zero window probe timer */ |
134 | #define ICSK_TIME_KEEPOPEN 4 /* Keepalive timer */ | ||
135 | 135 | ||
136 | static inline struct inet_connection_sock *inet_csk(const struct sock *sk) | 136 | static inline struct inet_connection_sock *inet_csk(const struct sock *sk) |
137 | { | 137 | { |
@@ -249,7 +249,11 @@ extern int inet_csk_bind_conflict(const struct sock *sk, | |||
249 | extern int inet_csk_get_port(struct sock *sk, unsigned short snum); | 249 | extern int inet_csk_get_port(struct sock *sk, unsigned short snum); |
250 | 250 | ||
251 | extern struct dst_entry* inet_csk_route_req(struct sock *sk, | 251 | extern struct dst_entry* inet_csk_route_req(struct sock *sk, |
252 | struct flowi4 *fl4, | ||
252 | const struct request_sock *req); | 253 | const struct request_sock *req); |
254 | extern struct dst_entry* inet_csk_route_child_sock(struct sock *sk, | ||
255 | struct sock *newsk, | ||
256 | const struct request_sock *req); | ||
253 | 257 | ||
254 | static inline void inet_csk_reqsk_queue_add(struct sock *sk, | 258 | static inline void inet_csk_reqsk_queue_add(struct sock *sk, |
255 | struct request_sock *req, | 259 | struct request_sock *req, |
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h index 9b5d08f4f6e8..2fa8d1341a0a 100644 --- a/include/net/inet_ecn.h +++ b/include/net/inet_ecn.h | |||
@@ -27,7 +27,7 @@ static inline int INET_ECN_is_not_ect(__u8 dsfield) | |||
27 | 27 | ||
28 | static inline int INET_ECN_is_capable(__u8 dsfield) | 28 | static inline int INET_ECN_is_capable(__u8 dsfield) |
29 | { | 29 | { |
30 | return (dsfield & INET_ECN_ECT_0); | 30 | return dsfield & INET_ECN_ECT_0; |
31 | } | 31 | } |
32 | 32 | ||
33 | static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) | 33 | static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) |
@@ -38,9 +38,19 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) | |||
38 | return outer; | 38 | return outer; |
39 | } | 39 | } |
40 | 40 | ||
41 | #define INET_ECN_xmit(sk) do { inet_sk(sk)->tos |= INET_ECN_ECT_0; } while (0) | 41 | static inline void INET_ECN_xmit(struct sock *sk) |
42 | #define INET_ECN_dontxmit(sk) \ | 42 | { |
43 | do { inet_sk(sk)->tos &= ~INET_ECN_MASK; } while (0) | 43 | inet_sk(sk)->tos |= INET_ECN_ECT_0; |
44 | if (inet6_sk(sk) != NULL) | ||
45 | inet6_sk(sk)->tclass |= INET_ECN_ECT_0; | ||
46 | } | ||
47 | |||
48 | static inline void INET_ECN_dontxmit(struct sock *sk) | ||
49 | { | ||
50 | inet_sk(sk)->tos &= ~INET_ECN_MASK; | ||
51 | if (inet6_sk(sk) != NULL) | ||
52 | inet6_sk(sk)->tclass &= ~INET_ECN_MASK; | ||
53 | } | ||
44 | 54 | ||
45 | #define IP6_ECN_flow_init(label) do { \ | 55 | #define IP6_ECN_flow_init(label) do { \ |
46 | (label) &= ~htonl(INET_ECN_MASK << 20); \ | 56 | (label) &= ~htonl(INET_ECN_MASK << 20); \ |
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 74358d1b3f43..e9c2ed8af864 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -245,7 +245,7 @@ static inline int inet_sk_listen_hashfn(const struct sock *sk) | |||
245 | } | 245 | } |
246 | 246 | ||
247 | /* Caller must disable local BH processing. */ | 247 | /* Caller must disable local BH processing. */ |
248 | extern void __inet_inherit_port(struct sock *sk, struct sock *child); | 248 | extern int __inet_inherit_port(struct sock *sk, struct sock *child); |
249 | 249 | ||
250 | extern void inet_put_port(struct sock *sk); | 250 | extern void inet_put_port(struct sock *sk); |
251 | 251 | ||
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index 1989cfd7405f..caaff5f5f39f 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h | |||
@@ -57,7 +57,15 @@ struct ip_options { | |||
57 | unsigned char __data[0]; | 57 | unsigned char __data[0]; |
58 | }; | 58 | }; |
59 | 59 | ||
60 | #define optlength(opt) (sizeof(struct ip_options) + opt->optlen) | 60 | struct ip_options_rcu { |
61 | struct rcu_head rcu; | ||
62 | struct ip_options opt; | ||
63 | }; | ||
64 | |||
65 | struct ip_options_data { | ||
66 | struct ip_options_rcu opt; | ||
67 | char data[40]; | ||
68 | }; | ||
61 | 69 | ||
62 | struct inet_request_sock { | 70 | struct inet_request_sock { |
63 | struct request_sock req; | 71 | struct request_sock req; |
@@ -78,7 +86,7 @@ struct inet_request_sock { | |||
78 | acked : 1, | 86 | acked : 1, |
79 | no_srccheck: 1; | 87 | no_srccheck: 1; |
80 | kmemcheck_bitfield_end(flags); | 88 | kmemcheck_bitfield_end(flags); |
81 | struct ip_options *opt; | 89 | struct ip_options_rcu *opt; |
82 | }; | 90 | }; |
83 | 91 | ||
84 | static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk) | 92 | static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk) |
@@ -86,6 +94,23 @@ static inline struct inet_request_sock *inet_rsk(const struct request_sock *sk) | |||
86 | return (struct inet_request_sock *)sk; | 94 | return (struct inet_request_sock *)sk; |
87 | } | 95 | } |
88 | 96 | ||
97 | struct inet_cork { | ||
98 | unsigned int flags; | ||
99 | __be32 addr; | ||
100 | struct ip_options *opt; | ||
101 | unsigned int fragsize; | ||
102 | struct dst_entry *dst; | ||
103 | int length; /* Total length of all frames */ | ||
104 | struct page *page; | ||
105 | u32 off; | ||
106 | u8 tx_flags; | ||
107 | }; | ||
108 | |||
109 | struct inet_cork_full { | ||
110 | struct inet_cork base; | ||
111 | struct flowi fl; | ||
112 | }; | ||
113 | |||
89 | struct ip_mc_socklist; | 114 | struct ip_mc_socklist; |
90 | struct ipv6_pinfo; | 115 | struct ipv6_pinfo; |
91 | struct rtable; | 116 | struct rtable; |
@@ -116,8 +141,9 @@ struct inet_sock { | |||
116 | struct ipv6_pinfo *pinet6; | 141 | struct ipv6_pinfo *pinet6; |
117 | #endif | 142 | #endif |
118 | /* Socket demultiplex comparisons on incoming packets. */ | 143 | /* Socket demultiplex comparisons on incoming packets. */ |
119 | __be32 inet_daddr; | 144 | #define inet_daddr sk.__sk_common.skc_daddr |
120 | __be32 inet_rcv_saddr; | 145 | #define inet_rcv_saddr sk.__sk_common.skc_rcv_saddr |
146 | |||
121 | __be16 inet_dport; | 147 | __be16 inet_dport; |
122 | __u16 inet_num; | 148 | __u16 inet_num; |
123 | __be32 inet_saddr; | 149 | __be32 inet_saddr; |
@@ -126,7 +152,7 @@ struct inet_sock { | |||
126 | __be16 inet_sport; | 152 | __be16 inet_sport; |
127 | __u16 inet_id; | 153 | __u16 inet_id; |
128 | 154 | ||
129 | struct ip_options *opt; | 155 | struct ip_options_rcu __rcu *inet_opt; |
130 | __u8 tos; | 156 | __u8 tos; |
131 | __u8 min_ttl; | 157 | __u8 min_ttl; |
132 | __u8 mc_ttl; | 158 | __u8 mc_ttl; |
@@ -141,16 +167,8 @@ struct inet_sock { | |||
141 | nodefrag:1; | 167 | nodefrag:1; |
142 | int mc_index; | 168 | int mc_index; |
143 | __be32 mc_addr; | 169 | __be32 mc_addr; |
144 | struct ip_mc_socklist *mc_list; | 170 | struct ip_mc_socklist __rcu *mc_list; |
145 | struct { | 171 | struct inet_cork_full cork; |
146 | unsigned int flags; | ||
147 | unsigned int fragsize; | ||
148 | struct ip_options *opt; | ||
149 | struct dst_entry *dst; | ||
150 | int length; /* Total length of all frames */ | ||
151 | __be32 addr; | ||
152 | struct flowi fl; | ||
153 | } cork; | ||
154 | }; | 172 | }; |
155 | 173 | ||
156 | #define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */ | 174 | #define IPCORK_OPT 1 /* ip-options has been held in ipcork.opt */ |
@@ -218,7 +236,13 @@ static inline struct request_sock *inet_reqsk_alloc(struct request_sock_ops *ops | |||
218 | 236 | ||
219 | static inline __u8 inet_sk_flowi_flags(const struct sock *sk) | 237 | static inline __u8 inet_sk_flowi_flags(const struct sock *sk) |
220 | { | 238 | { |
221 | return inet_sk(sk)->transparent ? FLOWI_FLAG_ANYSRC : 0; | 239 | __u8 flags = 0; |
240 | |||
241 | if (inet_sk(sk)->transparent) | ||
242 | flags |= FLOWI_FLAG_ANYSRC; | ||
243 | if (sk->sk_protocol == IPPROTO_TCP) | ||
244 | flags |= FLOWI_FLAG_PRECOW_METRICS; | ||
245 | return flags; | ||
222 | } | 246 | } |
223 | 247 | ||
224 | #endif /* _INET_SOCK_H */ | 248 | #endif /* _INET_SOCK_H */ |
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index a066fdd50da6..17404b5388a7 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h | |||
@@ -88,12 +88,6 @@ extern void inet_twdr_hangman(unsigned long data); | |||
88 | extern void inet_twdr_twkill_work(struct work_struct *work); | 88 | extern void inet_twdr_twkill_work(struct work_struct *work); |
89 | extern void inet_twdr_twcal_tick(unsigned long data); | 89 | extern void inet_twdr_twcal_tick(unsigned long data); |
90 | 90 | ||
91 | #if (BITS_PER_LONG == 64) | ||
92 | #define INET_TIMEWAIT_ADDRCMP_ALIGN_BYTES 8 | ||
93 | #else | ||
94 | #define INET_TIMEWAIT_ADDRCMP_ALIGN_BYTES 4 | ||
95 | #endif | ||
96 | |||
97 | struct inet_bind_bucket; | 91 | struct inet_bind_bucket; |
98 | 92 | ||
99 | /* | 93 | /* |
@@ -117,15 +111,15 @@ struct inet_timewait_sock { | |||
117 | #define tw_hash __tw_common.skc_hash | 111 | #define tw_hash __tw_common.skc_hash |
118 | #define tw_prot __tw_common.skc_prot | 112 | #define tw_prot __tw_common.skc_prot |
119 | #define tw_net __tw_common.skc_net | 113 | #define tw_net __tw_common.skc_net |
114 | #define tw_daddr __tw_common.skc_daddr | ||
115 | #define tw_rcv_saddr __tw_common.skc_rcv_saddr | ||
120 | int tw_timeout; | 116 | int tw_timeout; |
121 | volatile unsigned char tw_substate; | 117 | volatile unsigned char tw_substate; |
122 | /* 3 bits hole, try to pack */ | ||
123 | unsigned char tw_rcv_wscale; | 118 | unsigned char tw_rcv_wscale; |
119 | |||
124 | /* Socket demultiplex comparisons on incoming packets. */ | 120 | /* Socket demultiplex comparisons on incoming packets. */ |
125 | /* these five are in inet_sock */ | 121 | /* these three are in inet_sock */ |
126 | __be16 tw_sport; | 122 | __be16 tw_sport; |
127 | __be32 tw_daddr __attribute__((aligned(INET_TIMEWAIT_ADDRCMP_ALIGN_BYTES))); | ||
128 | __be32 tw_rcv_saddr; | ||
129 | __be16 tw_dport; | 123 | __be16 tw_dport; |
130 | __u16 tw_num; | 124 | __u16 tw_num; |
131 | kmemcheck_bitfield_begin(flags); | 125 | kmemcheck_bitfield_begin(flags); |
@@ -191,10 +185,10 @@ static inline struct inet_timewait_sock *inet_twsk(const struct sock *sk) | |||
191 | return (struct inet_timewait_sock *)sk; | 185 | return (struct inet_timewait_sock *)sk; |
192 | } | 186 | } |
193 | 187 | ||
194 | static inline __be32 inet_rcv_saddr(const struct sock *sk) | 188 | static inline __be32 sk_rcv_saddr(const struct sock *sk) |
195 | { | 189 | { |
196 | return likely(sk->sk_state != TCP_TIME_WAIT) ? | 190 | /* both inet_sk() and inet_twsk() store rcv_saddr in skc_rcv_saddr */ |
197 | inet_sk(sk)->inet_rcv_saddr : inet_twsk(sk)->tw_rcv_saddr; | 191 | return sk->__sk_common.skc_rcv_saddr; |
198 | } | 192 | } |
199 | 193 | ||
200 | extern void inet_twsk_put(struct inet_timewait_sock *tw); | 194 | extern void inet_twsk_put(struct inet_timewait_sock *tw); |
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h index 417d0c894f29..8a159cc3d68b 100644 --- a/include/net/inetpeer.h +++ b/include/net/inetpeer.h | |||
@@ -11,12 +11,26 @@ | |||
11 | #include <linux/init.h> | 11 | #include <linux/init.h> |
12 | #include <linux/jiffies.h> | 12 | #include <linux/jiffies.h> |
13 | #include <linux/spinlock.h> | 13 | #include <linux/spinlock.h> |
14 | #include <linux/rtnetlink.h> | ||
15 | #include <net/ipv6.h> | ||
14 | #include <asm/atomic.h> | 16 | #include <asm/atomic.h> |
15 | 17 | ||
18 | struct inetpeer_addr_base { | ||
19 | union { | ||
20 | __be32 a4; | ||
21 | __be32 a6[4]; | ||
22 | }; | ||
23 | }; | ||
24 | |||
25 | struct inetpeer_addr { | ||
26 | struct inetpeer_addr_base addr; | ||
27 | __u16 family; | ||
28 | }; | ||
29 | |||
16 | struct inet_peer { | 30 | struct inet_peer { |
17 | /* group together avl_left,avl_right,v4daddr to speedup lookups */ | 31 | /* group together avl_left,avl_right,v4daddr to speedup lookups */ |
18 | struct inet_peer *avl_left, *avl_right; | 32 | struct inet_peer __rcu *avl_left, *avl_right; |
19 | __be32 v4daddr; /* peer's address */ | 33 | struct inetpeer_addr daddr; |
20 | __u32 avl_height; | 34 | __u32 avl_height; |
21 | struct list_head unused; | 35 | struct list_head unused; |
22 | __u32 dtime; /* the time of last use of not | 36 | __u32 dtime; /* the time of last use of not |
@@ -24,16 +38,22 @@ struct inet_peer { | |||
24 | atomic_t refcnt; | 38 | atomic_t refcnt; |
25 | /* | 39 | /* |
26 | * Once inet_peer is queued for deletion (refcnt == -1), following fields | 40 | * Once inet_peer is queued for deletion (refcnt == -1), following fields |
27 | * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp | 41 | * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp, metrics |
28 | * We can share memory with rcu_head to keep inet_peer small | 42 | * We can share memory with rcu_head to help keep inet_peer small. |
29 | * (less then 64 bytes) | ||
30 | */ | 43 | */ |
31 | union { | 44 | union { |
32 | struct { | 45 | struct { |
33 | atomic_t rid; /* Frag reception counter */ | 46 | atomic_t rid; /* Frag reception counter */ |
34 | atomic_t ip_id_count; /* IP ID for the next packet */ | 47 | atomic_t ip_id_count; /* IP ID for the next packet */ |
35 | __u32 tcp_ts; | 48 | __u32 tcp_ts; |
36 | __u32 tcp_ts_stamp; | 49 | __u32 tcp_ts_stamp; |
50 | u32 metrics[RTAX_MAX]; | ||
51 | u32 rate_tokens; /* rate limiting for ICMP */ | ||
52 | unsigned long rate_last; | ||
53 | unsigned long pmtu_expires; | ||
54 | u32 pmtu_orig; | ||
55 | u32 pmtu_learned; | ||
56 | struct inetpeer_addr_base redirect_learned; | ||
37 | }; | 57 | }; |
38 | struct rcu_head rcu; | 58 | struct rcu_head rcu; |
39 | }; | 59 | }; |
@@ -41,11 +61,37 @@ struct inet_peer { | |||
41 | 61 | ||
42 | void inet_initpeers(void) __init; | 62 | void inet_initpeers(void) __init; |
43 | 63 | ||
64 | #define INETPEER_METRICS_NEW (~(u32) 0) | ||
65 | |||
66 | static inline bool inet_metrics_new(const struct inet_peer *p) | ||
67 | { | ||
68 | return p->metrics[RTAX_LOCK-1] == INETPEER_METRICS_NEW; | ||
69 | } | ||
70 | |||
44 | /* can be called with or without local BH being disabled */ | 71 | /* can be called with or without local BH being disabled */ |
45 | struct inet_peer *inet_getpeer(__be32 daddr, int create); | 72 | struct inet_peer *inet_getpeer(struct inetpeer_addr *daddr, int create); |
73 | |||
74 | static inline struct inet_peer *inet_getpeer_v4(__be32 v4daddr, int create) | ||
75 | { | ||
76 | struct inetpeer_addr daddr; | ||
77 | |||
78 | daddr.addr.a4 = v4daddr; | ||
79 | daddr.family = AF_INET; | ||
80 | return inet_getpeer(&daddr, create); | ||
81 | } | ||
82 | |||
83 | static inline struct inet_peer *inet_getpeer_v6(const struct in6_addr *v6daddr, int create) | ||
84 | { | ||
85 | struct inetpeer_addr daddr; | ||
86 | |||
87 | ipv6_addr_copy((struct in6_addr *)daddr.addr.a6, v6daddr); | ||
88 | daddr.family = AF_INET6; | ||
89 | return inet_getpeer(&daddr, create); | ||
90 | } | ||
46 | 91 | ||
47 | /* can be called from BH context or outside */ | 92 | /* can be called from BH context or outside */ |
48 | extern void inet_putpeer(struct inet_peer *p); | 93 | extern void inet_putpeer(struct inet_peer *p); |
94 | extern bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout); | ||
49 | 95 | ||
50 | /* | 96 | /* |
51 | * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, | 97 | * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, |
diff --git a/include/net/ip.h b/include/net/ip.h index 890f9725d681..66dd49149208 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -52,14 +52,14 @@ static inline unsigned int ip_hdrlen(const struct sk_buff *skb) | |||
52 | struct ipcm_cookie { | 52 | struct ipcm_cookie { |
53 | __be32 addr; | 53 | __be32 addr; |
54 | int oif; | 54 | int oif; |
55 | struct ip_options *opt; | 55 | struct ip_options_rcu *opt; |
56 | union skb_shared_tx shtx; | 56 | __u8 tx_flags; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | #define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb)) | 59 | #define IPCB(skb) ((struct inet_skb_parm*)((skb)->cb)) |
60 | 60 | ||
61 | struct ip_ra_chain { | 61 | struct ip_ra_chain { |
62 | struct ip_ra_chain *next; | 62 | struct ip_ra_chain __rcu *next; |
63 | struct sock *sk; | 63 | struct sock *sk; |
64 | union { | 64 | union { |
65 | void (*destructor)(struct sock *); | 65 | void (*destructor)(struct sock *); |
@@ -68,7 +68,7 @@ struct ip_ra_chain { | |||
68 | struct rcu_head rcu; | 68 | struct rcu_head rcu; |
69 | }; | 69 | }; |
70 | 70 | ||
71 | extern struct ip_ra_chain *ip_ra_chain; | 71 | extern struct ip_ra_chain __rcu *ip_ra_chain; |
72 | 72 | ||
73 | /* IP flags. */ | 73 | /* IP flags. */ |
74 | #define IP_CE 0x8000 /* Flag: "Congestion" */ | 74 | #define IP_CE 0x8000 /* Flag: "Congestion" */ |
@@ -92,7 +92,7 @@ extern int igmp_mc_proc_init(void); | |||
92 | 92 | ||
93 | extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, | 93 | extern int ip_build_and_send_pkt(struct sk_buff *skb, struct sock *sk, |
94 | __be32 saddr, __be32 daddr, | 94 | __be32 saddr, __be32 daddr, |
95 | struct ip_options *opt); | 95 | struct ip_options_rcu *opt); |
96 | extern int ip_rcv(struct sk_buff *skb, struct net_device *dev, | 96 | extern int ip_rcv(struct sk_buff *skb, struct net_device *dev, |
97 | struct packet_type *pt, struct net_device *orig_dev); | 97 | struct packet_type *pt, struct net_device *orig_dev); |
98 | extern int ip_local_deliver(struct sk_buff *skb); | 98 | extern int ip_local_deliver(struct sk_buff *skb); |
@@ -104,9 +104,9 @@ extern int ip_do_nat(struct sk_buff *skb); | |||
104 | extern void ip_send_check(struct iphdr *ip); | 104 | extern void ip_send_check(struct iphdr *ip); |
105 | extern int __ip_local_out(struct sk_buff *skb); | 105 | extern int __ip_local_out(struct sk_buff *skb); |
106 | extern int ip_local_out(struct sk_buff *skb); | 106 | extern int ip_local_out(struct sk_buff *skb); |
107 | extern int ip_queue_xmit(struct sk_buff *skb); | 107 | extern int ip_queue_xmit(struct sk_buff *skb, struct flowi *fl); |
108 | extern void ip_init(void); | 108 | extern void ip_init(void); |
109 | extern int ip_append_data(struct sock *sk, | 109 | extern int ip_append_data(struct sock *sk, struct flowi4 *fl4, |
110 | int getfrag(void *from, char *to, int offset, int len, | 110 | int getfrag(void *from, char *to, int offset, int len, |
111 | int odd, struct sk_buff *skb), | 111 | int odd, struct sk_buff *skb), |
112 | void *from, int len, int protolen, | 112 | void *from, int len, int protolen, |
@@ -114,10 +114,28 @@ extern int ip_append_data(struct sock *sk, | |||
114 | struct rtable **rt, | 114 | struct rtable **rt, |
115 | unsigned int flags); | 115 | unsigned int flags); |
116 | extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb); | 116 | extern int ip_generic_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb); |
117 | extern ssize_t ip_append_page(struct sock *sk, struct page *page, | 117 | extern ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, |
118 | int offset, size_t size, int flags); | 118 | int offset, size_t size, int flags); |
119 | extern int ip_push_pending_frames(struct sock *sk); | 119 | extern struct sk_buff *__ip_make_skb(struct sock *sk, |
120 | struct flowi4 *fl4, | ||
121 | struct sk_buff_head *queue, | ||
122 | struct inet_cork *cork); | ||
123 | extern int ip_send_skb(struct sk_buff *skb); | ||
124 | extern int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4); | ||
120 | extern void ip_flush_pending_frames(struct sock *sk); | 125 | extern void ip_flush_pending_frames(struct sock *sk); |
126 | extern struct sk_buff *ip_make_skb(struct sock *sk, | ||
127 | struct flowi4 *fl4, | ||
128 | int getfrag(void *from, char *to, int offset, int len, | ||
129 | int odd, struct sk_buff *skb), | ||
130 | void *from, int length, int transhdrlen, | ||
131 | struct ipcm_cookie *ipc, | ||
132 | struct rtable **rtp, | ||
133 | unsigned int flags); | ||
134 | |||
135 | static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4) | ||
136 | { | ||
137 | return __ip_make_skb(sk, fl4, &sk->sk_write_queue, &inet_sk(sk)->cork.base); | ||
138 | } | ||
121 | 139 | ||
122 | /* datagram.c */ | 140 | /* datagram.c */ |
123 | extern int ip4_datagram_connect(struct sock *sk, | 141 | extern int ip4_datagram_connect(struct sock *sk, |
@@ -156,8 +174,8 @@ static inline __u8 ip_reply_arg_flowi_flags(const struct ip_reply_arg *arg) | |||
156 | return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0; | 174 | return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0; |
157 | } | 175 | } |
158 | 176 | ||
159 | void ip_send_reply(struct sock *sk, struct sk_buff *skb, struct ip_reply_arg *arg, | 177 | void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr, |
160 | unsigned int len); | 178 | struct ip_reply_arg *arg, unsigned int len); |
161 | 179 | ||
162 | struct ipv4_config { | 180 | struct ipv4_config { |
163 | int log_martians; | 181 | int log_martians; |
@@ -201,7 +219,6 @@ static inline int inet_is_reserved_local_port(int port) | |||
201 | return test_bit(port, sysctl_local_reserved_ports); | 219 | return test_bit(port, sysctl_local_reserved_ports); |
202 | } | 220 | } |
203 | 221 | ||
204 | extern int sysctl_ip_default_ttl; | ||
205 | extern int sysctl_ip_nonlocal_bind; | 222 | extern int sysctl_ip_nonlocal_bind; |
206 | 223 | ||
207 | extern struct ctl_path net_core_path[]; | 224 | extern struct ctl_path net_core_path[]; |
@@ -238,9 +255,9 @@ int ip_decrease_ttl(struct iphdr *iph) | |||
238 | static inline | 255 | static inline |
239 | int ip_dont_fragment(struct sock *sk, struct dst_entry *dst) | 256 | int ip_dont_fragment(struct sock *sk, struct dst_entry *dst) |
240 | { | 257 | { |
241 | return (inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO || | 258 | return inet_sk(sk)->pmtudisc == IP_PMTUDISC_DO || |
242 | (inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT && | 259 | (inet_sk(sk)->pmtudisc == IP_PMTUDISC_WANT && |
243 | !(dst_metric_locked(dst, RTAX_MTU)))); | 260 | !(dst_metric_locked(dst, RTAX_MTU))); |
244 | } | 261 | } |
245 | 262 | ||
246 | extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more); | 263 | extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more); |
@@ -324,6 +341,14 @@ static inline void ip_ib_mc_map(__be32 naddr, const unsigned char *broadcast, ch | |||
324 | buf[16] = addr & 0x0f; | 341 | buf[16] = addr & 0x0f; |
325 | } | 342 | } |
326 | 343 | ||
344 | static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, char *buf) | ||
345 | { | ||
346 | if ((broadcast[0] | broadcast[1] | broadcast[2] | broadcast[3]) != 0) | ||
347 | memcpy(buf, broadcast, 4); | ||
348 | else | ||
349 | memcpy(buf, &naddr, sizeof(naddr)); | ||
350 | } | ||
351 | |||
327 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 352 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
328 | #include <linux/ipv6.h> | 353 | #include <linux/ipv6.h> |
329 | #endif | 354 | #endif |
@@ -393,14 +418,15 @@ extern int ip_forward(struct sk_buff *skb); | |||
393 | * Functions provided by ip_options.c | 418 | * Functions provided by ip_options.c |
394 | */ | 419 | */ |
395 | 420 | ||
396 | extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, __be32 daddr, struct rtable *rt, int is_frag); | 421 | extern void ip_options_build(struct sk_buff *skb, struct ip_options *opt, |
422 | __be32 daddr, struct rtable *rt, int is_frag); | ||
397 | extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); | 423 | extern int ip_options_echo(struct ip_options *dopt, struct sk_buff *skb); |
398 | extern void ip_options_fragment(struct sk_buff *skb); | 424 | extern void ip_options_fragment(struct sk_buff *skb); |
399 | extern int ip_options_compile(struct net *net, | 425 | extern int ip_options_compile(struct net *net, |
400 | struct ip_options *opt, struct sk_buff *skb); | 426 | struct ip_options *opt, struct sk_buff *skb); |
401 | extern int ip_options_get(struct net *net, struct ip_options **optp, | 427 | extern int ip_options_get(struct net *net, struct ip_options_rcu **optp, |
402 | unsigned char *data, int optlen); | 428 | unsigned char *data, int optlen); |
403 | extern int ip_options_get_from_user(struct net *net, struct ip_options **optp, | 429 | extern int ip_options_get_from_user(struct net *net, struct ip_options_rcu **optp, |
404 | unsigned char __user *data, int optlen); | 430 | unsigned char __user *data, int optlen); |
405 | extern void ip_options_undo(struct ip_options * opt); | 431 | extern void ip_options_undo(struct ip_options * opt); |
406 | extern void ip_forward_options(struct sk_buff *skb); | 432 | extern void ip_forward_options(struct sk_buff *skb); |
@@ -428,15 +454,6 @@ extern void ip_icmp_error(struct sock *sk, struct sk_buff *skb, int err, | |||
428 | extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport, | 454 | extern void ip_local_error(struct sock *sk, int err, __be32 daddr, __be16 dport, |
429 | u32 info); | 455 | u32 info); |
430 | 456 | ||
431 | /* sysctl helpers - any sysctl which holds a value that ends up being | ||
432 | * fed into the routing cache should use these handlers. | ||
433 | */ | ||
434 | int ipv4_doint_and_flush(ctl_table *ctl, int write, | ||
435 | void __user *buffer, | ||
436 | size_t *lenp, loff_t *ppos); | ||
437 | int ipv4_doint_and_flush_strategy(ctl_table *table, | ||
438 | void __user *oldval, size_t __user *oldlenp, | ||
439 | void __user *newval, size_t newlen); | ||
440 | #ifdef CONFIG_PROC_FS | 457 | #ifdef CONFIG_PROC_FS |
441 | extern int ip_misc_proc_init(void); | 458 | extern int ip_misc_proc_init(void); |
442 | #endif | 459 | #endif |
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h index 062a823d311c..477ef75f3873 100644 --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h | |||
@@ -13,14 +13,13 @@ | |||
13 | #ifndef _IP6_FIB_H | 13 | #ifndef _IP6_FIB_H |
14 | #define _IP6_FIB_H | 14 | #define _IP6_FIB_H |
15 | 15 | ||
16 | #ifdef __KERNEL__ | ||
17 | |||
18 | #include <linux/ipv6_route.h> | 16 | #include <linux/ipv6_route.h> |
19 | #include <linux/rtnetlink.h> | 17 | #include <linux/rtnetlink.h> |
20 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
21 | #include <net/dst.h> | 19 | #include <net/dst.h> |
22 | #include <net/flow.h> | 20 | #include <net/flow.h> |
23 | #include <net/netlink.h> | 21 | #include <net/netlink.h> |
22 | #include <net/inetpeer.h> | ||
24 | 23 | ||
25 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 24 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
26 | #define FIB6_TABLE_HASHSZ 256 | 25 | #define FIB6_TABLE_HASHSZ 256 |
@@ -41,6 +40,7 @@ struct fib6_config { | |||
41 | 40 | ||
42 | struct in6_addr fc_dst; | 41 | struct in6_addr fc_dst; |
43 | struct in6_addr fc_src; | 42 | struct in6_addr fc_src; |
43 | struct in6_addr fc_prefsrc; | ||
44 | struct in6_addr fc_gateway; | 44 | struct in6_addr fc_gateway; |
45 | 45 | ||
46 | unsigned long fc_expires; | 46 | unsigned long fc_expires; |
@@ -106,9 +106,12 @@ struct rt6_info { | |||
106 | struct rt6key rt6i_dst ____cacheline_aligned_in_smp; | 106 | struct rt6key rt6i_dst ____cacheline_aligned_in_smp; |
107 | u32 rt6i_flags; | 107 | u32 rt6i_flags; |
108 | struct rt6key rt6i_src; | 108 | struct rt6key rt6i_src; |
109 | struct rt6key rt6i_prefsrc; | ||
109 | u32 rt6i_metric; | 110 | u32 rt6i_metric; |
111 | u32 rt6i_peer_genid; | ||
110 | 112 | ||
111 | struct inet6_dev *rt6i_idev; | 113 | struct inet6_dev *rt6i_idev; |
114 | struct inet_peer *rt6i_peer; | ||
112 | 115 | ||
113 | #ifdef CONFIG_XFRM | 116 | #ifdef CONFIG_XFRM |
114 | u32 rt6i_flow_cache_genid; | 117 | u32 rt6i_flow_cache_genid; |
@@ -180,7 +183,7 @@ struct fib6_table { | |||
180 | 183 | ||
181 | typedef struct rt6_info *(*pol_lookup_t)(struct net *, | 184 | typedef struct rt6_info *(*pol_lookup_t)(struct net *, |
182 | struct fib6_table *, | 185 | struct fib6_table *, |
183 | struct flowi *, int); | 186 | struct flowi6 *, int); |
184 | 187 | ||
185 | /* | 188 | /* |
186 | * exported functions | 189 | * exported functions |
@@ -189,16 +192,16 @@ typedef struct rt6_info *(*pol_lookup_t)(struct net *, | |||
189 | extern struct fib6_table *fib6_get_table(struct net *net, u32 id); | 192 | extern struct fib6_table *fib6_get_table(struct net *net, u32 id); |
190 | extern struct fib6_table *fib6_new_table(struct net *net, u32 id); | 193 | extern struct fib6_table *fib6_new_table(struct net *net, u32 id); |
191 | extern struct dst_entry *fib6_rule_lookup(struct net *net, | 194 | extern struct dst_entry *fib6_rule_lookup(struct net *net, |
192 | struct flowi *fl, int flags, | 195 | struct flowi6 *fl6, int flags, |
193 | pol_lookup_t lookup); | 196 | pol_lookup_t lookup); |
194 | 197 | ||
195 | extern struct fib6_node *fib6_lookup(struct fib6_node *root, | 198 | extern struct fib6_node *fib6_lookup(struct fib6_node *root, |
196 | struct in6_addr *daddr, | 199 | const struct in6_addr *daddr, |
197 | struct in6_addr *saddr); | 200 | const struct in6_addr *saddr); |
198 | 201 | ||
199 | struct fib6_node *fib6_locate(struct fib6_node *root, | 202 | struct fib6_node *fib6_locate(struct fib6_node *root, |
200 | struct in6_addr *daddr, int dst_len, | 203 | const struct in6_addr *daddr, int dst_len, |
201 | struct in6_addr *saddr, int src_len); | 204 | const struct in6_addr *saddr, int src_len); |
202 | 205 | ||
203 | extern void fib6_clean_all(struct net *net, | 206 | extern void fib6_clean_all(struct net *net, |
204 | int (*func)(struct rt6_info *, void *arg), | 207 | int (*func)(struct rt6_info *, void *arg), |
@@ -235,4 +238,3 @@ static inline void fib6_rules_cleanup(void) | |||
235 | } | 238 | } |
236 | #endif | 239 | #endif |
237 | #endif | 240 | #endif |
238 | #endif | ||
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 278312c95f96..5e91b72fc718 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h | |||
@@ -3,7 +3,6 @@ | |||
3 | 3 | ||
4 | #define IP6_RT_PRIO_USER 1024 | 4 | #define IP6_RT_PRIO_USER 1024 |
5 | #define IP6_RT_PRIO_ADDRCONF 256 | 5 | #define IP6_RT_PRIO_ADDRCONF 256 |
6 | #define IP6_RT_PRIO_KERN 512 | ||
7 | 6 | ||
8 | struct route_info { | 7 | struct route_info { |
9 | __u8 type; | 8 | __u8 type; |
@@ -22,8 +21,6 @@ struct route_info { | |||
22 | __u8 prefix[0]; /* 0,8 or 16 */ | 21 | __u8 prefix[0]; /* 0,8 or 16 */ |
23 | }; | 22 | }; |
24 | 23 | ||
25 | #ifdef __KERNEL__ | ||
26 | |||
27 | #include <net/flow.h> | 24 | #include <net/flow.h> |
28 | #include <net/ip6_fib.h> | 25 | #include <net/ip6_fib.h> |
29 | #include <net/sock.h> | 26 | #include <net/sock.h> |
@@ -56,11 +53,23 @@ static inline unsigned int rt6_flags2srcprefs(int flags) | |||
56 | return (flags >> 3) & 7; | 53 | return (flags >> 3) & 7; |
57 | } | 54 | } |
58 | 55 | ||
56 | extern void rt6_bind_peer(struct rt6_info *rt, | ||
57 | int create); | ||
58 | |||
59 | static inline struct inet_peer *rt6_get_peer(struct rt6_info *rt) | ||
60 | { | ||
61 | if (rt->rt6i_peer) | ||
62 | return rt->rt6i_peer; | ||
63 | |||
64 | rt6_bind_peer(rt, 0); | ||
65 | return rt->rt6i_peer; | ||
66 | } | ||
67 | |||
59 | extern void ip6_route_input(struct sk_buff *skb); | 68 | extern void ip6_route_input(struct sk_buff *skb); |
60 | 69 | ||
61 | extern struct dst_entry * ip6_route_output(struct net *net, | 70 | extern struct dst_entry * ip6_route_output(struct net *net, |
62 | struct sock *sk, | 71 | const struct sock *sk, |
63 | struct flowi *fl); | 72 | struct flowi6 *fl6); |
64 | 73 | ||
65 | extern int ip6_route_init(void); | 74 | extern int ip6_route_init(void); |
66 | extern void ip6_route_cleanup(void); | 75 | extern void ip6_route_cleanup(void); |
@@ -73,6 +82,12 @@ extern int ip6_route_add(struct fib6_config *cfg); | |||
73 | extern int ip6_ins_rt(struct rt6_info *); | 82 | extern int ip6_ins_rt(struct rt6_info *); |
74 | extern int ip6_del_rt(struct rt6_info *); | 83 | extern int ip6_del_rt(struct rt6_info *); |
75 | 84 | ||
85 | extern int ip6_route_get_saddr(struct net *net, | ||
86 | struct rt6_info *rt, | ||
87 | const struct in6_addr *daddr, | ||
88 | unsigned int prefs, | ||
89 | struct in6_addr *saddr); | ||
90 | |||
76 | extern struct rt6_info *rt6_lookup(struct net *net, | 91 | extern struct rt6_info *rt6_lookup(struct net *net, |
77 | const struct in6_addr *daddr, | 92 | const struct in6_addr *daddr, |
78 | const struct in6_addr *saddr, | 93 | const struct in6_addr *saddr, |
@@ -95,9 +110,9 @@ extern int ip6_dst_hoplimit(struct dst_entry *dst); | |||
95 | * support functions for ND | 110 | * support functions for ND |
96 | * | 111 | * |
97 | */ | 112 | */ |
98 | extern struct rt6_info * rt6_get_dflt_router(struct in6_addr *addr, | 113 | extern struct rt6_info * rt6_get_dflt_router(const struct in6_addr *addr, |
99 | struct net_device *dev); | 114 | struct net_device *dev); |
100 | extern struct rt6_info * rt6_add_dflt_router(struct in6_addr *gwaddr, | 115 | extern struct rt6_info * rt6_add_dflt_router(const struct in6_addr *gwaddr, |
101 | struct net_device *dev, | 116 | struct net_device *dev, |
102 | unsigned int pref); | 117 | unsigned int pref); |
103 | 118 | ||
@@ -105,17 +120,17 @@ extern void rt6_purge_dflt_routers(struct net *net); | |||
105 | 120 | ||
106 | extern int rt6_route_rcv(struct net_device *dev, | 121 | extern int rt6_route_rcv(struct net_device *dev, |
107 | u8 *opt, int len, | 122 | u8 *opt, int len, |
108 | struct in6_addr *gwaddr); | 123 | const struct in6_addr *gwaddr); |
109 | 124 | ||
110 | extern void rt6_redirect(struct in6_addr *dest, | 125 | extern void rt6_redirect(const struct in6_addr *dest, |
111 | struct in6_addr *src, | 126 | const struct in6_addr *src, |
112 | struct in6_addr *saddr, | 127 | const struct in6_addr *saddr, |
113 | struct neighbour *neigh, | 128 | struct neighbour *neigh, |
114 | u8 *lladdr, | 129 | u8 *lladdr, |
115 | int on_link); | 130 | int on_link); |
116 | 131 | ||
117 | extern void rt6_pmtu_discovery(struct in6_addr *daddr, | 132 | extern void rt6_pmtu_discovery(const struct in6_addr *daddr, |
118 | struct in6_addr *saddr, | 133 | const struct in6_addr *saddr, |
119 | struct net_device *dev, | 134 | struct net_device *dev, |
120 | u32 pmtu); | 135 | u32 pmtu); |
121 | 136 | ||
@@ -130,6 +145,7 @@ struct rt6_rtnl_dump_arg { | |||
130 | extern int rt6_dump_route(struct rt6_info *rt, void *p_arg); | 145 | extern int rt6_dump_route(struct rt6_info *rt, void *p_arg); |
131 | extern void rt6_ifdown(struct net *net, struct net_device *dev); | 146 | extern void rt6_ifdown(struct net *net, struct net_device *dev); |
132 | extern void rt6_mtu_change(struct net_device *dev, unsigned mtu); | 147 | extern void rt6_mtu_change(struct net_device *dev, unsigned mtu); |
148 | extern void rt6_remove_prefsrc(struct inet6_ifaddr *ifp); | ||
133 | 149 | ||
134 | 150 | ||
135 | /* | 151 | /* |
@@ -164,5 +180,14 @@ static inline int ipv6_unicast_destination(struct sk_buff *skb) | |||
164 | return rt->rt6i_flags & RTF_LOCAL; | 180 | return rt->rt6i_flags & RTF_LOCAL; |
165 | } | 181 | } |
166 | 182 | ||
167 | #endif | 183 | int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)); |
184 | |||
185 | static inline int ip6_skb_dst_mtu(struct sk_buff *skb) | ||
186 | { | ||
187 | struct ipv6_pinfo *np = skb->sk ? inet6_sk(skb->sk) : NULL; | ||
188 | |||
189 | return (np && np->pmtudisc == IPV6_PMTUDISC_PROBE) ? | ||
190 | skb_dst(skb)->dev->mtu : dst_mtu(skb_dst(skb)); | ||
191 | } | ||
192 | |||
168 | #endif | 193 | #endif |
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h index fc94ec568a50..fc73e667b50e 100644 --- a/include/net/ip6_tunnel.h +++ b/include/net/ip6_tunnel.h | |||
@@ -13,7 +13,7 @@ | |||
13 | /* IPv6 tunnel */ | 13 | /* IPv6 tunnel */ |
14 | 14 | ||
15 | struct ip6_tnl { | 15 | struct ip6_tnl { |
16 | struct ip6_tnl *next; /* next tunnel in list */ | 16 | struct ip6_tnl __rcu *next; /* next tunnel in list */ |
17 | struct net_device *dev; /* virtual device associated with tunnel */ | 17 | struct net_device *dev; /* virtual device associated with tunnel */ |
18 | struct ip6_tnl_parm parms; /* tunnel configuration parameters */ | 18 | struct ip6_tnl_parm parms; /* tunnel configuration parameters */ |
19 | struct flowi fl; /* flowi template for xmit */ | 19 | struct flowi fl; /* flowi template for xmit */ |
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index c93f94edc610..10422ef14e28 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h | |||
@@ -55,11 +55,13 @@ struct fib_nh { | |||
55 | int nh_weight; | 55 | int nh_weight; |
56 | int nh_power; | 56 | int nh_power; |
57 | #endif | 57 | #endif |
58 | #ifdef CONFIG_NET_CLS_ROUTE | 58 | #ifdef CONFIG_IP_ROUTE_CLASSID |
59 | __u32 nh_tclassid; | 59 | __u32 nh_tclassid; |
60 | #endif | 60 | #endif |
61 | int nh_oif; | 61 | int nh_oif; |
62 | __be32 nh_gw; | 62 | __be32 nh_gw; |
63 | __be32 nh_saddr; | ||
64 | int nh_saddr_genid; | ||
63 | }; | 65 | }; |
64 | 66 | ||
65 | /* | 67 | /* |
@@ -72,12 +74,13 @@ struct fib_info { | |||
72 | struct net *fib_net; | 74 | struct net *fib_net; |
73 | int fib_treeref; | 75 | int fib_treeref; |
74 | atomic_t fib_clntref; | 76 | atomic_t fib_clntref; |
75 | int fib_dead; | ||
76 | unsigned fib_flags; | 77 | unsigned fib_flags; |
77 | int fib_protocol; | 78 | unsigned char fib_dead; |
79 | unsigned char fib_protocol; | ||
80 | unsigned char fib_scope; | ||
78 | __be32 fib_prefsrc; | 81 | __be32 fib_prefsrc; |
79 | u32 fib_priority; | 82 | u32 fib_priority; |
80 | u32 fib_metrics[RTAX_MAX]; | 83 | u32 *fib_metrics; |
81 | #define fib_mtu fib_metrics[RTAX_MTU-1] | 84 | #define fib_mtu fib_metrics[RTAX_MTU-1] |
82 | #define fib_window fib_metrics[RTAX_WINDOW-1] | 85 | #define fib_window fib_metrics[RTAX_WINDOW-1] |
83 | #define fib_rtt fib_metrics[RTAX_RTT-1] | 86 | #define fib_rtt fib_metrics[RTAX_RTT-1] |
@@ -86,6 +89,7 @@ struct fib_info { | |||
86 | #ifdef CONFIG_IP_ROUTE_MULTIPATH | 89 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
87 | int fib_power; | 90 | int fib_power; |
88 | #endif | 91 | #endif |
92 | struct rcu_head rcu; | ||
89 | struct fib_nh fib_nh[0]; | 93 | struct fib_nh fib_nh[0]; |
90 | #define fib_dev fib_nh[0].nh_dev | 94 | #define fib_dev fib_nh[0].nh_dev |
91 | }; | 95 | }; |
@@ -95,12 +99,15 @@ struct fib_info { | |||
95 | struct fib_rule; | 99 | struct fib_rule; |
96 | #endif | 100 | #endif |
97 | 101 | ||
102 | struct fib_table; | ||
98 | struct fib_result { | 103 | struct fib_result { |
99 | unsigned char prefixlen; | 104 | unsigned char prefixlen; |
100 | unsigned char nh_sel; | 105 | unsigned char nh_sel; |
101 | unsigned char type; | 106 | unsigned char type; |
102 | unsigned char scope; | 107 | unsigned char scope; |
103 | struct fib_info *fi; | 108 | struct fib_info *fi; |
109 | struct fib_table *table; | ||
110 | struct list_head *fa_head; | ||
104 | #ifdef CONFIG_IP_MULTIPLE_TABLES | 111 | #ifdef CONFIG_IP_MULTIPLE_TABLES |
105 | struct fib_rule *r; | 112 | struct fib_rule *r; |
106 | #endif | 113 | #endif |
@@ -135,28 +142,37 @@ struct fib_result_nl { | |||
135 | 142 | ||
136 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ | 143 | #endif /* CONFIG_IP_ROUTE_MULTIPATH */ |
137 | 144 | ||
138 | #define FIB_RES_PREFSRC(res) ((res).fi->fib_prefsrc ? : __fib_res_prefsrc(&res)) | 145 | extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh); |
146 | |||
147 | #define FIB_RES_SADDR(net, res) \ | ||
148 | ((FIB_RES_NH(res).nh_saddr_genid == \ | ||
149 | atomic_read(&(net)->ipv4.dev_addr_genid)) ? \ | ||
150 | FIB_RES_NH(res).nh_saddr : \ | ||
151 | fib_info_update_nh_saddr((net), &FIB_RES_NH(res))) | ||
139 | #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw) | 152 | #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw) |
140 | #define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev) | 153 | #define FIB_RES_DEV(res) (FIB_RES_NH(res).nh_dev) |
141 | #define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif) | 154 | #define FIB_RES_OIF(res) (FIB_RES_NH(res).nh_oif) |
142 | 155 | ||
156 | #define FIB_RES_PREFSRC(net, res) ((res).fi->fib_prefsrc ? : \ | ||
157 | FIB_RES_SADDR(net, res)) | ||
158 | |||
143 | struct fib_table { | 159 | struct fib_table { |
144 | struct hlist_node tb_hlist; | 160 | struct hlist_node tb_hlist; |
145 | u32 tb_id; | 161 | u32 tb_id; |
146 | int tb_default; | 162 | int tb_default; |
147 | unsigned char tb_data[0]; | 163 | int tb_num_default; |
164 | unsigned long tb_data[0]; | ||
148 | }; | 165 | }; |
149 | 166 | ||
150 | extern int fib_table_lookup(struct fib_table *tb, const struct flowi *flp, | 167 | extern int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, |
151 | struct fib_result *res); | 168 | struct fib_result *res, int fib_flags); |
152 | extern int fib_table_insert(struct fib_table *, struct fib_config *); | 169 | extern int fib_table_insert(struct fib_table *, struct fib_config *); |
153 | extern int fib_table_delete(struct fib_table *, struct fib_config *); | 170 | extern int fib_table_delete(struct fib_table *, struct fib_config *); |
154 | extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb, | 171 | extern int fib_table_dump(struct fib_table *table, struct sk_buff *skb, |
155 | struct netlink_callback *cb); | 172 | struct netlink_callback *cb); |
156 | extern int fib_table_flush(struct fib_table *table); | 173 | extern int fib_table_flush(struct fib_table *table); |
157 | extern void fib_table_select_default(struct fib_table *table, | 174 | extern void fib_free_table(struct fib_table *tb); |
158 | const struct flowi *flp, | 175 | |
159 | struct fib_result *res); | ||
160 | 176 | ||
161 | 177 | ||
162 | #ifndef CONFIG_IP_MULTIPLE_TABLES | 178 | #ifndef CONFIG_IP_MULTIPLE_TABLES |
@@ -179,17 +195,17 @@ static inline struct fib_table *fib_new_table(struct net *net, u32 id) | |||
179 | return fib_get_table(net, id); | 195 | return fib_get_table(net, id); |
180 | } | 196 | } |
181 | 197 | ||
182 | static inline int fib_lookup(struct net *net, const struct flowi *flp, | 198 | static inline int fib_lookup(struct net *net, const struct flowi4 *flp, |
183 | struct fib_result *res) | 199 | struct fib_result *res) |
184 | { | 200 | { |
185 | struct fib_table *table; | 201 | struct fib_table *table; |
186 | 202 | ||
187 | table = fib_get_table(net, RT_TABLE_LOCAL); | 203 | table = fib_get_table(net, RT_TABLE_LOCAL); |
188 | if (!fib_table_lookup(table, flp, res)) | 204 | if (!fib_table_lookup(table, flp, res, FIB_LOOKUP_NOREF)) |
189 | return 0; | 205 | return 0; |
190 | 206 | ||
191 | table = fib_get_table(net, RT_TABLE_MAIN); | 207 | table = fib_get_table(net, RT_TABLE_MAIN); |
192 | if (!fib_table_lookup(table, flp, res)) | 208 | if (!fib_table_lookup(table, flp, res, FIB_LOOKUP_NOREF)) |
193 | return 0; | 209 | return 0; |
194 | return -ENETUNREACH; | 210 | return -ENETUNREACH; |
195 | } | 211 | } |
@@ -198,11 +214,11 @@ static inline int fib_lookup(struct net *net, const struct flowi *flp, | |||
198 | extern int __net_init fib4_rules_init(struct net *net); | 214 | extern int __net_init fib4_rules_init(struct net *net); |
199 | extern void __net_exit fib4_rules_exit(struct net *net); | 215 | extern void __net_exit fib4_rules_exit(struct net *net); |
200 | 216 | ||
201 | #ifdef CONFIG_NET_CLS_ROUTE | 217 | #ifdef CONFIG_IP_ROUTE_CLASSID |
202 | extern u32 fib_rules_tclass(struct fib_result *res); | 218 | extern u32 fib_rules_tclass(const struct fib_result *res); |
203 | #endif | 219 | #endif |
204 | 220 | ||
205 | extern int fib_lookup(struct net *n, struct flowi *flp, struct fib_result *res); | 221 | extern int fib_lookup(struct net *n, struct flowi4 *flp, struct fib_result *res); |
206 | 222 | ||
207 | extern struct fib_table *fib_new_table(struct net *net, u32 id); | 223 | extern struct fib_table *fib_new_table(struct net *net, u32 id); |
208 | extern struct fib_table *fib_get_table(struct net *net, u32 id); | 224 | extern struct fib_table *fib_get_table(struct net *net, u32 id); |
@@ -212,27 +228,26 @@ extern struct fib_table *fib_get_table(struct net *net, u32 id); | |||
212 | /* Exported by fib_frontend.c */ | 228 | /* Exported by fib_frontend.c */ |
213 | extern const struct nla_policy rtm_ipv4_policy[]; | 229 | extern const struct nla_policy rtm_ipv4_policy[]; |
214 | extern void ip_fib_init(void); | 230 | extern void ip_fib_init(void); |
215 | extern int fib_validate_source(__be32 src, __be32 dst, u8 tos, int oif, | 231 | extern int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, |
216 | struct net_device *dev, __be32 *spec_dst, | 232 | u8 tos, int oif, struct net_device *dev, |
217 | u32 *itag, u32 mark); | 233 | __be32 *spec_dst, u32 *itag); |
218 | extern void fib_select_default(struct net *net, const struct flowi *flp, | 234 | extern void fib_select_default(struct fib_result *res); |
219 | struct fib_result *res); | ||
220 | 235 | ||
221 | /* Exported by fib_semantics.c */ | 236 | /* Exported by fib_semantics.c */ |
222 | extern int ip_fib_check_default(__be32 gw, struct net_device *dev); | 237 | extern int ip_fib_check_default(__be32 gw, struct net_device *dev); |
223 | extern int fib_sync_down_dev(struct net_device *dev, int force); | 238 | extern int fib_sync_down_dev(struct net_device *dev, int force); |
224 | extern int fib_sync_down_addr(struct net *net, __be32 local); | 239 | extern int fib_sync_down_addr(struct net *net, __be32 local); |
240 | extern void fib_update_nh_saddrs(struct net_device *dev); | ||
225 | extern int fib_sync_up(struct net_device *dev); | 241 | extern int fib_sync_up(struct net_device *dev); |
226 | extern __be32 __fib_res_prefsrc(struct fib_result *res); | 242 | extern void fib_select_multipath(struct fib_result *res); |
227 | extern void fib_select_multipath(const struct flowi *flp, struct fib_result *res); | ||
228 | 243 | ||
229 | /* Exported by fib_{hash|trie}.c */ | 244 | /* Exported by fib_trie.c */ |
230 | extern void fib_hash_init(void); | 245 | extern void fib_trie_init(void); |
231 | extern struct fib_table *fib_hash_table(u32 id); | 246 | extern struct fib_table *fib_trie_table(u32 id); |
232 | 247 | ||
233 | static inline void fib_combine_itag(u32 *itag, struct fib_result *res) | 248 | static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) |
234 | { | 249 | { |
235 | #ifdef CONFIG_NET_CLS_ROUTE | 250 | #ifdef CONFIG_IP_ROUTE_CLASSID |
236 | #ifdef CONFIG_IP_MULTIPLE_TABLES | 251 | #ifdef CONFIG_IP_MULTIPLE_TABLES |
237 | u32 rtag; | 252 | u32 rtag; |
238 | #endif | 253 | #endif |
@@ -254,16 +269,6 @@ static inline void fib_info_put(struct fib_info *fi) | |||
254 | free_fib_info(fi); | 269 | free_fib_info(fi); |
255 | } | 270 | } |
256 | 271 | ||
257 | static inline void fib_res_put(struct fib_result *res) | ||
258 | { | ||
259 | if (res->fi) | ||
260 | fib_info_put(res->fi); | ||
261 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
262 | if (res->r) | ||
263 | fib_rule_put(res->r); | ||
264 | #endif | ||
265 | } | ||
266 | |||
267 | #ifdef CONFIG_PROC_FS | 272 | #ifdef CONFIG_PROC_FS |
268 | extern int __net_init fib_proc_init(struct net *net); | 273 | extern int __net_init fib_proc_init(struct net *net); |
269 | extern void __net_exit fib_proc_exit(struct net *net); | 274 | extern void __net_exit fib_proc_exit(struct net *net); |
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index f976885f686f..481f856c650f 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -8,9 +8,6 @@ | |||
8 | 8 | ||
9 | #include <linux/ip_vs.h> /* definitions shared with userland */ | 9 | #include <linux/ip_vs.h> /* definitions shared with userland */ |
10 | 10 | ||
11 | /* old ipvsadm versions still include this file directly */ | ||
12 | #ifdef __KERNEL__ | ||
13 | |||
14 | #include <asm/types.h> /* for __uXX types */ | 11 | #include <asm/types.h> /* for __uXX types */ |
15 | 12 | ||
16 | #include <linux/sysctl.h> /* for ctl_path */ | 13 | #include <linux/sysctl.h> /* for ctl_path */ |
@@ -25,7 +22,83 @@ | |||
25 | #include <linux/ip.h> | 22 | #include <linux/ip.h> |
26 | #include <linux/ipv6.h> /* for struct ipv6hdr */ | 23 | #include <linux/ipv6.h> /* for struct ipv6hdr */ |
27 | #include <net/ipv6.h> /* for ipv6_addr_copy */ | 24 | #include <net/ipv6.h> /* for ipv6_addr_copy */ |
25 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
26 | #include <net/netfilter/nf_conntrack.h> | ||
27 | #endif | ||
28 | #include <net/net_namespace.h> /* Netw namespace */ | ||
28 | 29 | ||
30 | /* | ||
31 | * Generic access of ipvs struct | ||
32 | */ | ||
33 | static inline struct netns_ipvs *net_ipvs(struct net* net) | ||
34 | { | ||
35 | return net->ipvs; | ||
36 | } | ||
37 | /* | ||
38 | * Get net ptr from skb in traffic cases | ||
39 | * use skb_sknet when call is from userland (ioctl or netlink) | ||
40 | */ | ||
41 | static inline struct net *skb_net(const struct sk_buff *skb) | ||
42 | { | ||
43 | #ifdef CONFIG_NET_NS | ||
44 | #ifdef CONFIG_IP_VS_DEBUG | ||
45 | /* | ||
46 | * This is used for debug only. | ||
47 | * Start with the most likely hit | ||
48 | * End with BUG | ||
49 | */ | ||
50 | if (likely(skb->dev && skb->dev->nd_net)) | ||
51 | return dev_net(skb->dev); | ||
52 | if (skb_dst(skb) && skb_dst(skb)->dev) | ||
53 | return dev_net(skb_dst(skb)->dev); | ||
54 | WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n", | ||
55 | __func__, __LINE__); | ||
56 | if (likely(skb->sk && skb->sk->sk_net)) | ||
57 | return sock_net(skb->sk); | ||
58 | pr_err("There is no net ptr to find in the skb in %s() line:%d\n", | ||
59 | __func__, __LINE__); | ||
60 | BUG(); | ||
61 | #else | ||
62 | return dev_net(skb->dev ? : skb_dst(skb)->dev); | ||
63 | #endif | ||
64 | #else | ||
65 | return &init_net; | ||
66 | #endif | ||
67 | } | ||
68 | |||
69 | static inline struct net *skb_sknet(const struct sk_buff *skb) | ||
70 | { | ||
71 | #ifdef CONFIG_NET_NS | ||
72 | #ifdef CONFIG_IP_VS_DEBUG | ||
73 | /* Start with the most likely hit */ | ||
74 | if (likely(skb->sk && skb->sk->sk_net)) | ||
75 | return sock_net(skb->sk); | ||
76 | WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n", | ||
77 | __func__, __LINE__); | ||
78 | if (likely(skb->dev && skb->dev->nd_net)) | ||
79 | return dev_net(skb->dev); | ||
80 | pr_err("There is no net ptr to find in the skb in %s() line:%d\n", | ||
81 | __func__, __LINE__); | ||
82 | BUG(); | ||
83 | #else | ||
84 | return sock_net(skb->sk); | ||
85 | #endif | ||
86 | #else | ||
87 | return &init_net; | ||
88 | #endif | ||
89 | } | ||
90 | /* | ||
91 | * This one needed for single_open_net since net is stored directly in | ||
92 | * private not as a struct i.e. seq_file_net can't be used. | ||
93 | */ | ||
94 | static inline struct net *seq_file_single_net(struct seq_file *seq) | ||
95 | { | ||
96 | #ifdef CONFIG_NET_NS | ||
97 | return (struct net *)seq->private; | ||
98 | #else | ||
99 | return &init_net; | ||
100 | #endif | ||
101 | } | ||
29 | 102 | ||
30 | /* Connections' size value needed by ip_vs_ctl.c */ | 103 | /* Connections' size value needed by ip_vs_ctl.c */ |
31 | extern int ip_vs_conn_tab_size; | 104 | extern int ip_vs_conn_tab_size; |
@@ -134,24 +207,24 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len, | |||
134 | if (net_ratelimit()) \ | 207 | if (net_ratelimit()) \ |
135 | printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \ | 208 | printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \ |
136 | } while (0) | 209 | } while (0) |
137 | #define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) \ | 210 | #define IP_VS_DBG_PKT(level, af, pp, skb, ofs, msg) \ |
138 | do { \ | 211 | do { \ |
139 | if (level <= ip_vs_get_debug_level()) \ | 212 | if (level <= ip_vs_get_debug_level()) \ |
140 | pp->debug_packet(pp, skb, ofs, msg); \ | 213 | pp->debug_packet(af, pp, skb, ofs, msg); \ |
141 | } while (0) | 214 | } while (0) |
142 | #define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) \ | 215 | #define IP_VS_DBG_RL_PKT(level, af, pp, skb, ofs, msg) \ |
143 | do { \ | 216 | do { \ |
144 | if (level <= ip_vs_get_debug_level() && \ | 217 | if (level <= ip_vs_get_debug_level() && \ |
145 | net_ratelimit()) \ | 218 | net_ratelimit()) \ |
146 | pp->debug_packet(pp, skb, ofs, msg); \ | 219 | pp->debug_packet(af, pp, skb, ofs, msg); \ |
147 | } while (0) | 220 | } while (0) |
148 | #else /* NO DEBUGGING at ALL */ | 221 | #else /* NO DEBUGGING at ALL */ |
149 | #define IP_VS_DBG_BUF(level, msg...) do {} while (0) | 222 | #define IP_VS_DBG_BUF(level, msg...) do {} while (0) |
150 | #define IP_VS_ERR_BUF(msg...) do {} while (0) | 223 | #define IP_VS_ERR_BUF(msg...) do {} while (0) |
151 | #define IP_VS_DBG(level, msg...) do {} while (0) | 224 | #define IP_VS_DBG(level, msg...) do {} while (0) |
152 | #define IP_VS_DBG_RL(msg...) do {} while (0) | 225 | #define IP_VS_DBG_RL(msg...) do {} while (0) |
153 | #define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0) | 226 | #define IP_VS_DBG_PKT(level, af, pp, skb, ofs, msg) do {} while (0) |
154 | #define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) do {} while (0) | 227 | #define IP_VS_DBG_RL_PKT(level, af, pp, skb, ofs, msg) do {} while (0) |
155 | #endif | 228 | #endif |
156 | 229 | ||
157 | #define IP_VS_BUG() BUG() | 230 | #define IP_VS_BUG() BUG() |
@@ -256,6 +329,23 @@ struct ip_vs_seq { | |||
256 | before last resized pkt */ | 329 | before last resized pkt */ |
257 | }; | 330 | }; |
258 | 331 | ||
332 | /* | ||
333 | * counters per cpu | ||
334 | */ | ||
335 | struct ip_vs_counters { | ||
336 | __u32 conns; /* connections scheduled */ | ||
337 | __u32 inpkts; /* incoming packets */ | ||
338 | __u32 outpkts; /* outgoing packets */ | ||
339 | __u64 inbytes; /* incoming bytes */ | ||
340 | __u64 outbytes; /* outgoing bytes */ | ||
341 | }; | ||
342 | /* | ||
343 | * Stats per cpu | ||
344 | */ | ||
345 | struct ip_vs_cpu_stats { | ||
346 | struct ip_vs_counters ustats; | ||
347 | struct u64_stats_sync syncp; | ||
348 | }; | ||
259 | 349 | ||
260 | /* | 350 | /* |
261 | * IPVS statistics objects | 351 | * IPVS statistics objects |
@@ -277,10 +367,11 @@ struct ip_vs_estimator { | |||
277 | }; | 367 | }; |
278 | 368 | ||
279 | struct ip_vs_stats { | 369 | struct ip_vs_stats { |
280 | struct ip_vs_stats_user ustats; /* statistics */ | 370 | struct ip_vs_stats_user ustats; /* statistics */ |
281 | struct ip_vs_estimator est; /* estimator */ | 371 | struct ip_vs_estimator est; /* estimator */ |
282 | 372 | struct ip_vs_cpu_stats *cpustats; /* per cpu counters */ | |
283 | spinlock_t lock; /* spin lock */ | 373 | spinlock_t lock; /* spin lock */ |
374 | struct ip_vs_stats_user ustats0; /* reset values */ | ||
284 | }; | 375 | }; |
285 | 376 | ||
286 | struct dst_entry; | 377 | struct dst_entry; |
@@ -288,6 +379,7 @@ struct iphdr; | |||
288 | struct ip_vs_conn; | 379 | struct ip_vs_conn; |
289 | struct ip_vs_app; | 380 | struct ip_vs_app; |
290 | struct sk_buff; | 381 | struct sk_buff; |
382 | struct ip_vs_proto_data; | ||
291 | 383 | ||
292 | struct ip_vs_protocol { | 384 | struct ip_vs_protocol { |
293 | struct ip_vs_protocol *next; | 385 | struct ip_vs_protocol *next; |
@@ -295,21 +387,22 @@ struct ip_vs_protocol { | |||
295 | u16 protocol; | 387 | u16 protocol; |
296 | u16 num_states; | 388 | u16 num_states; |
297 | int dont_defrag; | 389 | int dont_defrag; |
298 | atomic_t appcnt; /* counter of proto app incs */ | ||
299 | int *timeout_table; /* protocol timeout table */ | ||
300 | 390 | ||
301 | void (*init)(struct ip_vs_protocol *pp); | 391 | void (*init)(struct ip_vs_protocol *pp); |
302 | 392 | ||
303 | void (*exit)(struct ip_vs_protocol *pp); | 393 | void (*exit)(struct ip_vs_protocol *pp); |
304 | 394 | ||
395 | void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd); | ||
396 | |||
397 | void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd); | ||
398 | |||
305 | int (*conn_schedule)(int af, struct sk_buff *skb, | 399 | int (*conn_schedule)(int af, struct sk_buff *skb, |
306 | struct ip_vs_protocol *pp, | 400 | struct ip_vs_proto_data *pd, |
307 | int *verdict, struct ip_vs_conn **cpp); | 401 | int *verdict, struct ip_vs_conn **cpp); |
308 | 402 | ||
309 | struct ip_vs_conn * | 403 | struct ip_vs_conn * |
310 | (*conn_in_get)(int af, | 404 | (*conn_in_get)(int af, |
311 | const struct sk_buff *skb, | 405 | const struct sk_buff *skb, |
312 | struct ip_vs_protocol *pp, | ||
313 | const struct ip_vs_iphdr *iph, | 406 | const struct ip_vs_iphdr *iph, |
314 | unsigned int proto_off, | 407 | unsigned int proto_off, |
315 | int inverse); | 408 | int inverse); |
@@ -317,7 +410,6 @@ struct ip_vs_protocol { | |||
317 | struct ip_vs_conn * | 410 | struct ip_vs_conn * |
318 | (*conn_out_get)(int af, | 411 | (*conn_out_get)(int af, |
319 | const struct sk_buff *skb, | 412 | const struct sk_buff *skb, |
320 | struct ip_vs_protocol *pp, | ||
321 | const struct ip_vs_iphdr *iph, | 413 | const struct ip_vs_iphdr *iph, |
322 | unsigned int proto_off, | 414 | unsigned int proto_off, |
323 | int inverse); | 415 | int inverse); |
@@ -335,40 +427,69 @@ struct ip_vs_protocol { | |||
335 | 427 | ||
336 | int (*state_transition)(struct ip_vs_conn *cp, int direction, | 428 | int (*state_transition)(struct ip_vs_conn *cp, int direction, |
337 | const struct sk_buff *skb, | 429 | const struct sk_buff *skb, |
338 | struct ip_vs_protocol *pp); | 430 | struct ip_vs_proto_data *pd); |
339 | 431 | ||
340 | int (*register_app)(struct ip_vs_app *inc); | 432 | int (*register_app)(struct net *net, struct ip_vs_app *inc); |
341 | 433 | ||
342 | void (*unregister_app)(struct ip_vs_app *inc); | 434 | void (*unregister_app)(struct net *net, struct ip_vs_app *inc); |
343 | 435 | ||
344 | int (*app_conn_bind)(struct ip_vs_conn *cp); | 436 | int (*app_conn_bind)(struct ip_vs_conn *cp); |
345 | 437 | ||
346 | void (*debug_packet)(struct ip_vs_protocol *pp, | 438 | void (*debug_packet)(int af, struct ip_vs_protocol *pp, |
347 | const struct sk_buff *skb, | 439 | const struct sk_buff *skb, |
348 | int offset, | 440 | int offset, |
349 | const char *msg); | 441 | const char *msg); |
350 | 442 | ||
351 | void (*timeout_change)(struct ip_vs_protocol *pp, int flags); | 443 | void (*timeout_change)(struct ip_vs_proto_data *pd, int flags); |
444 | }; | ||
352 | 445 | ||
353 | int (*set_state_timeout)(struct ip_vs_protocol *pp, char *sname, int to); | 446 | /* |
447 | * protocol data per netns | ||
448 | */ | ||
449 | struct ip_vs_proto_data { | ||
450 | struct ip_vs_proto_data *next; | ||
451 | struct ip_vs_protocol *pp; | ||
452 | int *timeout_table; /* protocol timeout table */ | ||
453 | atomic_t appcnt; /* counter of proto app incs. */ | ||
454 | struct tcp_states_t *tcp_state_table; | ||
354 | }; | 455 | }; |
355 | 456 | ||
356 | extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto); | 457 | extern struct ip_vs_protocol *ip_vs_proto_get(unsigned short proto); |
458 | extern struct ip_vs_proto_data *ip_vs_proto_data_get(struct net *net, | ||
459 | unsigned short proto); | ||
460 | |||
461 | struct ip_vs_conn_param { | ||
462 | struct net *net; | ||
463 | const union nf_inet_addr *caddr; | ||
464 | const union nf_inet_addr *vaddr; | ||
465 | __be16 cport; | ||
466 | __be16 vport; | ||
467 | __u16 protocol; | ||
468 | u16 af; | ||
469 | |||
470 | const struct ip_vs_pe *pe; | ||
471 | char *pe_data; | ||
472 | __u8 pe_data_len; | ||
473 | }; | ||
357 | 474 | ||
358 | /* | 475 | /* |
359 | * IP_VS structure allocated for each dynamically scheduled connection | 476 | * IP_VS structure allocated for each dynamically scheduled connection |
360 | */ | 477 | */ |
361 | struct ip_vs_conn { | 478 | struct ip_vs_conn { |
362 | struct list_head c_list; /* hashed list heads */ | 479 | struct hlist_node c_list; /* hashed list heads */ |
363 | 480 | #ifdef CONFIG_NET_NS | |
481 | struct net *net; /* Name space */ | ||
482 | #endif | ||
364 | /* Protocol, addresses and port numbers */ | 483 | /* Protocol, addresses and port numbers */ |
365 | u16 af; /* address family */ | 484 | u16 af; /* address family */ |
366 | union nf_inet_addr caddr; /* client address */ | 485 | __be16 cport; |
367 | union nf_inet_addr vaddr; /* virtual address */ | 486 | __be16 vport; |
368 | union nf_inet_addr daddr; /* destination address */ | 487 | __be16 dport; |
369 | __be16 cport; | 488 | __u32 fwmark; /* Fire wall mark from skb */ |
370 | __be16 vport; | 489 | union nf_inet_addr caddr; /* client address */ |
371 | __be16 dport; | 490 | union nf_inet_addr vaddr; /* virtual address */ |
491 | union nf_inet_addr daddr; /* destination address */ | ||
492 | volatile __u32 flags; /* status flags */ | ||
372 | __u16 protocol; /* Which protocol (TCP/UDP) */ | 493 | __u16 protocol; /* Which protocol (TCP/UDP) */ |
373 | 494 | ||
374 | /* counter and timer */ | 495 | /* counter and timer */ |
@@ -378,7 +499,6 @@ struct ip_vs_conn { | |||
378 | 499 | ||
379 | /* Flags and state transition */ | 500 | /* Flags and state transition */ |
380 | spinlock_t lock; /* lock for state transition */ | 501 | spinlock_t lock; /* lock for state transition */ |
381 | volatile __u16 flags; /* status flags */ | ||
382 | volatile __u16 state; /* state info */ | 502 | volatile __u16 state; /* state info */ |
383 | volatile __u16 old_state; /* old state, to be used for | 503 | volatile __u16 old_state; /* old state, to be used for |
384 | * state transition triggerd | 504 | * state transition triggerd |
@@ -394,6 +514,7 @@ struct ip_vs_conn { | |||
394 | /* packet transmitter for different forwarding methods. If it | 514 | /* packet transmitter for different forwarding methods. If it |
395 | mangles the packet, it must return NF_DROP or better NF_STOLEN, | 515 | mangles the packet, it must return NF_DROP or better NF_STOLEN, |
396 | otherwise this must be changed to a sk_buff **. | 516 | otherwise this must be changed to a sk_buff **. |
517 | NF_ACCEPT can be returned when destination is local. | ||
397 | */ | 518 | */ |
398 | int (*packet_xmit)(struct sk_buff *skb, struct ip_vs_conn *cp, | 519 | int (*packet_xmit)(struct sk_buff *skb, struct ip_vs_conn *cp, |
399 | struct ip_vs_protocol *pp); | 520 | struct ip_vs_protocol *pp); |
@@ -405,8 +526,39 @@ struct ip_vs_conn { | |||
405 | void *app_data; /* Application private data */ | 526 | void *app_data; /* Application private data */ |
406 | struct ip_vs_seq in_seq; /* incoming seq. struct */ | 527 | struct ip_vs_seq in_seq; /* incoming seq. struct */ |
407 | struct ip_vs_seq out_seq; /* outgoing seq. struct */ | 528 | struct ip_vs_seq out_seq; /* outgoing seq. struct */ |
529 | |||
530 | const struct ip_vs_pe *pe; | ||
531 | char *pe_data; | ||
532 | __u8 pe_data_len; | ||
408 | }; | 533 | }; |
409 | 534 | ||
535 | /* | ||
536 | * To save some memory in conn table when name space is disabled. | ||
537 | */ | ||
538 | static inline struct net *ip_vs_conn_net(const struct ip_vs_conn *cp) | ||
539 | { | ||
540 | #ifdef CONFIG_NET_NS | ||
541 | return cp->net; | ||
542 | #else | ||
543 | return &init_net; | ||
544 | #endif | ||
545 | } | ||
546 | static inline void ip_vs_conn_net_set(struct ip_vs_conn *cp, struct net *net) | ||
547 | { | ||
548 | #ifdef CONFIG_NET_NS | ||
549 | cp->net = net; | ||
550 | #endif | ||
551 | } | ||
552 | |||
553 | static inline int ip_vs_conn_net_eq(const struct ip_vs_conn *cp, | ||
554 | struct net *net) | ||
555 | { | ||
556 | #ifdef CONFIG_NET_NS | ||
557 | return cp->net == net; | ||
558 | #else | ||
559 | return 1; | ||
560 | #endif | ||
561 | } | ||
410 | 562 | ||
411 | /* | 563 | /* |
412 | * Extended internal versions of struct ip_vs_service_user and | 564 | * Extended internal versions of struct ip_vs_service_user and |
@@ -426,6 +578,7 @@ struct ip_vs_service_user_kern { | |||
426 | 578 | ||
427 | /* virtual service options */ | 579 | /* virtual service options */ |
428 | char *sched_name; | 580 | char *sched_name; |
581 | char *pe_name; | ||
429 | unsigned flags; /* virtual service flags */ | 582 | unsigned flags; /* virtual service flags */ |
430 | unsigned timeout; /* persistent timeout in sec */ | 583 | unsigned timeout; /* persistent timeout in sec */ |
431 | u32 netmask; /* persistent netmask */ | 584 | u32 netmask; /* persistent netmask */ |
@@ -465,6 +618,7 @@ struct ip_vs_service { | |||
465 | unsigned flags; /* service status flags */ | 618 | unsigned flags; /* service status flags */ |
466 | unsigned timeout; /* persistent timeout in ticks */ | 619 | unsigned timeout; /* persistent timeout in ticks */ |
467 | __be32 netmask; /* grouping granularity */ | 620 | __be32 netmask; /* grouping granularity */ |
621 | struct net *net; | ||
468 | 622 | ||
469 | struct list_head destinations; /* real server d-linked list */ | 623 | struct list_head destinations; /* real server d-linked list */ |
470 | __u32 num_dests; /* number of servers */ | 624 | __u32 num_dests; /* number of servers */ |
@@ -475,6 +629,9 @@ struct ip_vs_service { | |||
475 | struct ip_vs_scheduler *scheduler; /* bound scheduler object */ | 629 | struct ip_vs_scheduler *scheduler; /* bound scheduler object */ |
476 | rwlock_t sched_lock; /* lock sched_data */ | 630 | rwlock_t sched_lock; /* lock sched_data */ |
477 | void *sched_data; /* scheduler application data */ | 631 | void *sched_data; /* scheduler application data */ |
632 | |||
633 | /* alternate persistence engine */ | ||
634 | struct ip_vs_pe *pe; | ||
478 | }; | 635 | }; |
479 | 636 | ||
480 | 637 | ||
@@ -487,8 +644,8 @@ struct ip_vs_dest { | |||
487 | struct list_head d_list; /* for table with all the dests */ | 644 | struct list_head d_list; /* for table with all the dests */ |
488 | 645 | ||
489 | u16 af; /* address family */ | 646 | u16 af; /* address family */ |
490 | union nf_inet_addr addr; /* IP address of the server */ | ||
491 | __be16 port; /* port number of the server */ | 647 | __be16 port; /* port number of the server */ |
648 | union nf_inet_addr addr; /* IP address of the server */ | ||
492 | volatile unsigned flags; /* dest status flags */ | 649 | volatile unsigned flags; /* dest status flags */ |
493 | atomic_t conn_flags; /* flags to copy to conn */ | 650 | atomic_t conn_flags; /* flags to copy to conn */ |
494 | atomic_t weight; /* server weight */ | 651 | atomic_t weight; /* server weight */ |
@@ -507,12 +664,14 @@ struct ip_vs_dest { | |||
507 | spinlock_t dst_lock; /* lock of dst_cache */ | 664 | spinlock_t dst_lock; /* lock of dst_cache */ |
508 | struct dst_entry *dst_cache; /* destination cache entry */ | 665 | struct dst_entry *dst_cache; /* destination cache entry */ |
509 | u32 dst_rtos; /* RT_TOS(tos) for dst */ | 666 | u32 dst_rtos; /* RT_TOS(tos) for dst */ |
667 | u32 dst_cookie; | ||
668 | union nf_inet_addr dst_saddr; | ||
510 | 669 | ||
511 | /* for virtual service */ | 670 | /* for virtual service */ |
512 | struct ip_vs_service *svc; /* service it belongs to */ | 671 | struct ip_vs_service *svc; /* service it belongs to */ |
513 | __u16 protocol; /* which protocol (TCP/UDP) */ | 672 | __u16 protocol; /* which protocol (TCP/UDP) */ |
514 | union nf_inet_addr vaddr; /* virtual IP address */ | ||
515 | __be16 vport; /* virtual port number */ | 673 | __be16 vport; /* virtual port number */ |
674 | union nf_inet_addr vaddr; /* virtual IP address */ | ||
516 | __u32 vfwmark; /* firewall mark of service */ | 675 | __u32 vfwmark; /* firewall mark of service */ |
517 | }; | 676 | }; |
518 | 677 | ||
@@ -538,6 +697,21 @@ struct ip_vs_scheduler { | |||
538 | const struct sk_buff *skb); | 697 | const struct sk_buff *skb); |
539 | }; | 698 | }; |
540 | 699 | ||
700 | /* The persistence engine object */ | ||
701 | struct ip_vs_pe { | ||
702 | struct list_head n_list; /* d-linked list head */ | ||
703 | char *name; /* scheduler name */ | ||
704 | atomic_t refcnt; /* reference counter */ | ||
705 | struct module *module; /* THIS_MODULE/NULL */ | ||
706 | |||
707 | /* get the connection template, if any */ | ||
708 | int (*fill_param)(struct ip_vs_conn_param *p, struct sk_buff *skb); | ||
709 | bool (*ct_match)(const struct ip_vs_conn_param *p, | ||
710 | struct ip_vs_conn *ct); | ||
711 | u32 (*hashkey_raw)(const struct ip_vs_conn_param *p, u32 initval, | ||
712 | bool inverse); | ||
713 | int (*show_pe_data)(const struct ip_vs_conn *cp, char *buf); | ||
714 | }; | ||
541 | 715 | ||
542 | /* | 716 | /* |
543 | * The application module object (a.k.a. app incarnation) | 717 | * The application module object (a.k.a. app incarnation) |
@@ -556,11 +730,19 @@ struct ip_vs_app { | |||
556 | __be16 port; /* port number in net order */ | 730 | __be16 port; /* port number in net order */ |
557 | atomic_t usecnt; /* usage counter */ | 731 | atomic_t usecnt; /* usage counter */ |
558 | 732 | ||
559 | /* output hook: return false if can't linearize. diff set for TCP. */ | 733 | /* |
734 | * output hook: Process packet in inout direction, diff set for TCP. | ||
735 | * Return: 0=Error, 1=Payload Not Mangled/Mangled but checksum is ok, | ||
736 | * 2=Mangled but checksum was not updated | ||
737 | */ | ||
560 | int (*pkt_out)(struct ip_vs_app *, struct ip_vs_conn *, | 738 | int (*pkt_out)(struct ip_vs_app *, struct ip_vs_conn *, |
561 | struct sk_buff *, int *diff); | 739 | struct sk_buff *, int *diff); |
562 | 740 | ||
563 | /* input hook: return false if can't linearize. diff set for TCP. */ | 741 | /* |
742 | * input hook: Process packet in outin direction, diff set for TCP. | ||
743 | * Return: 0=Error, 1=Payload Not Mangled/Mangled but checksum is ok, | ||
744 | * 2=Mangled but checksum was not updated | ||
745 | */ | ||
564 | int (*pkt_in)(struct ip_vs_app *, struct ip_vs_conn *, | 746 | int (*pkt_in)(struct ip_vs_app *, struct ip_vs_conn *, |
565 | struct sk_buff *, int *diff); | 747 | struct sk_buff *, int *diff); |
566 | 748 | ||
@@ -601,6 +783,171 @@ struct ip_vs_app { | |||
601 | void (*timeout_change)(struct ip_vs_app *app, int flags); | 783 | void (*timeout_change)(struct ip_vs_app *app, int flags); |
602 | }; | 784 | }; |
603 | 785 | ||
786 | /* IPVS in network namespace */ | ||
787 | struct netns_ipvs { | ||
788 | int gen; /* Generation */ | ||
789 | int enable; /* enable like nf_hooks do */ | ||
790 | /* | ||
791 | * Hash table: for real service lookups | ||
792 | */ | ||
793 | #define IP_VS_RTAB_BITS 4 | ||
794 | #define IP_VS_RTAB_SIZE (1 << IP_VS_RTAB_BITS) | ||
795 | #define IP_VS_RTAB_MASK (IP_VS_RTAB_SIZE - 1) | ||
796 | |||
797 | struct list_head rs_table[IP_VS_RTAB_SIZE]; | ||
798 | /* ip_vs_app */ | ||
799 | struct list_head app_list; | ||
800 | /* ip_vs_ftp */ | ||
801 | struct ip_vs_app *ftp_app; | ||
802 | /* ip_vs_proto */ | ||
803 | #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */ | ||
804 | struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE]; | ||
805 | /* ip_vs_proto_tcp */ | ||
806 | #ifdef CONFIG_IP_VS_PROTO_TCP | ||
807 | #define TCP_APP_TAB_BITS 4 | ||
808 | #define TCP_APP_TAB_SIZE (1 << TCP_APP_TAB_BITS) | ||
809 | #define TCP_APP_TAB_MASK (TCP_APP_TAB_SIZE - 1) | ||
810 | struct list_head tcp_apps[TCP_APP_TAB_SIZE]; | ||
811 | spinlock_t tcp_app_lock; | ||
812 | #endif | ||
813 | /* ip_vs_proto_udp */ | ||
814 | #ifdef CONFIG_IP_VS_PROTO_UDP | ||
815 | #define UDP_APP_TAB_BITS 4 | ||
816 | #define UDP_APP_TAB_SIZE (1 << UDP_APP_TAB_BITS) | ||
817 | #define UDP_APP_TAB_MASK (UDP_APP_TAB_SIZE - 1) | ||
818 | struct list_head udp_apps[UDP_APP_TAB_SIZE]; | ||
819 | spinlock_t udp_app_lock; | ||
820 | #endif | ||
821 | /* ip_vs_proto_sctp */ | ||
822 | #ifdef CONFIG_IP_VS_PROTO_SCTP | ||
823 | #define SCTP_APP_TAB_BITS 4 | ||
824 | #define SCTP_APP_TAB_SIZE (1 << SCTP_APP_TAB_BITS) | ||
825 | #define SCTP_APP_TAB_MASK (SCTP_APP_TAB_SIZE - 1) | ||
826 | /* Hash table for SCTP application incarnations */ | ||
827 | struct list_head sctp_apps[SCTP_APP_TAB_SIZE]; | ||
828 | spinlock_t sctp_app_lock; | ||
829 | #endif | ||
830 | /* ip_vs_conn */ | ||
831 | atomic_t conn_count; /* connection counter */ | ||
832 | |||
833 | /* ip_vs_ctl */ | ||
834 | struct ip_vs_stats tot_stats; /* Statistics & est. */ | ||
835 | |||
836 | int num_services; /* no of virtual services */ | ||
837 | |||
838 | rwlock_t rs_lock; /* real services table */ | ||
839 | /* semaphore for IPVS sockopts. And, [gs]etsockopt may sleep. */ | ||
840 | struct lock_class_key ctl_key; /* ctl_mutex debuging */ | ||
841 | /* Trash for destinations */ | ||
842 | struct list_head dest_trash; | ||
843 | /* Service counters */ | ||
844 | atomic_t ftpsvc_counter; | ||
845 | atomic_t nullsvc_counter; | ||
846 | |||
847 | #ifdef CONFIG_SYSCTL | ||
848 | /* 1/rate drop and drop-entry variables */ | ||
849 | struct delayed_work defense_work; /* Work handler */ | ||
850 | int drop_rate; | ||
851 | int drop_counter; | ||
852 | atomic_t dropentry; | ||
853 | /* locks in ctl.c */ | ||
854 | spinlock_t dropentry_lock; /* drop entry handling */ | ||
855 | spinlock_t droppacket_lock; /* drop packet handling */ | ||
856 | spinlock_t securetcp_lock; /* state and timeout tables */ | ||
857 | |||
858 | /* sys-ctl struct */ | ||
859 | struct ctl_table_header *sysctl_hdr; | ||
860 | struct ctl_table *sysctl_tbl; | ||
861 | #endif | ||
862 | |||
863 | /* sysctl variables */ | ||
864 | int sysctl_amemthresh; | ||
865 | int sysctl_am_droprate; | ||
866 | int sysctl_drop_entry; | ||
867 | int sysctl_drop_packet; | ||
868 | int sysctl_secure_tcp; | ||
869 | #ifdef CONFIG_IP_VS_NFCT | ||
870 | int sysctl_conntrack; | ||
871 | #endif | ||
872 | int sysctl_snat_reroute; | ||
873 | int sysctl_sync_ver; | ||
874 | int sysctl_cache_bypass; | ||
875 | int sysctl_expire_nodest_conn; | ||
876 | int sysctl_expire_quiescent_template; | ||
877 | int sysctl_sync_threshold[2]; | ||
878 | int sysctl_nat_icmp_send; | ||
879 | |||
880 | /* ip_vs_lblc */ | ||
881 | int sysctl_lblc_expiration; | ||
882 | struct ctl_table_header *lblc_ctl_header; | ||
883 | struct ctl_table *lblc_ctl_table; | ||
884 | /* ip_vs_lblcr */ | ||
885 | int sysctl_lblcr_expiration; | ||
886 | struct ctl_table_header *lblcr_ctl_header; | ||
887 | struct ctl_table *lblcr_ctl_table; | ||
888 | /* ip_vs_est */ | ||
889 | struct list_head est_list; /* estimator list */ | ||
890 | spinlock_t est_lock; | ||
891 | struct timer_list est_timer; /* Estimation timer */ | ||
892 | /* ip_vs_sync */ | ||
893 | struct list_head sync_queue; | ||
894 | spinlock_t sync_lock; | ||
895 | struct ip_vs_sync_buff *sync_buff; | ||
896 | spinlock_t sync_buff_lock; | ||
897 | struct sockaddr_in sync_mcast_addr; | ||
898 | struct task_struct *master_thread; | ||
899 | struct task_struct *backup_thread; | ||
900 | int send_mesg_maxlen; | ||
901 | int recv_mesg_maxlen; | ||
902 | volatile int sync_state; | ||
903 | volatile int master_syncid; | ||
904 | volatile int backup_syncid; | ||
905 | /* multicast interface name */ | ||
906 | char master_mcast_ifn[IP_VS_IFNAME_MAXLEN]; | ||
907 | char backup_mcast_ifn[IP_VS_IFNAME_MAXLEN]; | ||
908 | /* net name space ptr */ | ||
909 | struct net *net; /* Needed by timer routines */ | ||
910 | }; | ||
911 | |||
912 | #define DEFAULT_SYNC_THRESHOLD 3 | ||
913 | #define DEFAULT_SYNC_PERIOD 50 | ||
914 | #define DEFAULT_SYNC_VER 1 | ||
915 | |||
916 | #ifdef CONFIG_SYSCTL | ||
917 | |||
918 | static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs) | ||
919 | { | ||
920 | return ipvs->sysctl_sync_threshold[0]; | ||
921 | } | ||
922 | |||
923 | static inline int sysctl_sync_period(struct netns_ipvs *ipvs) | ||
924 | { | ||
925 | return ipvs->sysctl_sync_threshold[1]; | ||
926 | } | ||
927 | |||
928 | static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) | ||
929 | { | ||
930 | return ipvs->sysctl_sync_ver; | ||
931 | } | ||
932 | |||
933 | #else | ||
934 | |||
935 | static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs) | ||
936 | { | ||
937 | return DEFAULT_SYNC_THRESHOLD; | ||
938 | } | ||
939 | |||
940 | static inline int sysctl_sync_period(struct netns_ipvs *ipvs) | ||
941 | { | ||
942 | return DEFAULT_SYNC_PERIOD; | ||
943 | } | ||
944 | |||
945 | static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) | ||
946 | { | ||
947 | return DEFAULT_SYNC_VER; | ||
948 | } | ||
949 | |||
950 | #endif | ||
604 | 951 | ||
605 | /* | 952 | /* |
606 | * IPVS core functions | 953 | * IPVS core functions |
@@ -624,26 +971,35 @@ enum { | |||
624 | IP_VS_DIR_LAST, | 971 | IP_VS_DIR_LAST, |
625 | }; | 972 | }; |
626 | 973 | ||
627 | extern struct ip_vs_conn *ip_vs_conn_in_get | 974 | static inline void ip_vs_conn_fill_param(struct net *net, int af, int protocol, |
628 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, | 975 | const union nf_inet_addr *caddr, |
629 | const union nf_inet_addr *d_addr, __be16 d_port); | 976 | __be16 cport, |
977 | const union nf_inet_addr *vaddr, | ||
978 | __be16 vport, | ||
979 | struct ip_vs_conn_param *p) | ||
980 | { | ||
981 | p->net = net; | ||
982 | p->af = af; | ||
983 | p->protocol = protocol; | ||
984 | p->caddr = caddr; | ||
985 | p->cport = cport; | ||
986 | p->vaddr = vaddr; | ||
987 | p->vport = vport; | ||
988 | p->pe = NULL; | ||
989 | p->pe_data = NULL; | ||
990 | } | ||
630 | 991 | ||
631 | extern struct ip_vs_conn *ip_vs_ct_in_get | 992 | struct ip_vs_conn *ip_vs_conn_in_get(const struct ip_vs_conn_param *p); |
632 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, | 993 | struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p); |
633 | const union nf_inet_addr *d_addr, __be16 d_port); | ||
634 | 994 | ||
635 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, | 995 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, |
636 | struct ip_vs_protocol *pp, | ||
637 | const struct ip_vs_iphdr *iph, | 996 | const struct ip_vs_iphdr *iph, |
638 | unsigned int proto_off, | 997 | unsigned int proto_off, |
639 | int inverse); | 998 | int inverse); |
640 | 999 | ||
641 | extern struct ip_vs_conn *ip_vs_conn_out_get | 1000 | struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p); |
642 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, | ||
643 | const union nf_inet_addr *d_addr, __be16 d_port); | ||
644 | 1001 | ||
645 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, | 1002 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, |
646 | struct ip_vs_protocol *pp, | ||
647 | const struct ip_vs_iphdr *iph, | 1003 | const struct ip_vs_iphdr *iph, |
648 | unsigned int proto_off, | 1004 | unsigned int proto_off, |
649 | int inverse); | 1005 | int inverse); |
@@ -656,18 +1012,17 @@ static inline void __ip_vs_conn_put(struct ip_vs_conn *cp) | |||
656 | extern void ip_vs_conn_put(struct ip_vs_conn *cp); | 1012 | extern void ip_vs_conn_put(struct ip_vs_conn *cp); |
657 | extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); | 1013 | extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); |
658 | 1014 | ||
659 | extern struct ip_vs_conn * | 1015 | struct ip_vs_conn *ip_vs_conn_new(const struct ip_vs_conn_param *p, |
660 | ip_vs_conn_new(int af, int proto, const union nf_inet_addr *caddr, __be16 cport, | 1016 | const union nf_inet_addr *daddr, |
661 | const union nf_inet_addr *vaddr, __be16 vport, | 1017 | __be16 dport, unsigned flags, |
662 | const union nf_inet_addr *daddr, __be16 dport, unsigned flags, | 1018 | struct ip_vs_dest *dest, __u32 fwmark); |
663 | struct ip_vs_dest *dest); | ||
664 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); | 1019 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); |
665 | 1020 | ||
666 | extern const char * ip_vs_state_name(__u16 proto, int state); | 1021 | extern const char * ip_vs_state_name(__u16 proto, int state); |
667 | 1022 | ||
668 | extern void ip_vs_tcp_conn_listen(struct ip_vs_conn *cp); | 1023 | extern void ip_vs_tcp_conn_listen(struct net *net, struct ip_vs_conn *cp); |
669 | extern int ip_vs_check_template(struct ip_vs_conn *ct); | 1024 | extern int ip_vs_check_template(struct ip_vs_conn *ct); |
670 | extern void ip_vs_random_dropentry(void); | 1025 | extern void ip_vs_random_dropentry(struct net *net); |
671 | extern int ip_vs_conn_init(void); | 1026 | extern int ip_vs_conn_init(void); |
672 | extern void ip_vs_conn_cleanup(void); | 1027 | extern void ip_vs_conn_cleanup(void); |
673 | 1028 | ||
@@ -731,18 +1086,34 @@ ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp) | |||
731 | atomic_inc(&ctl_cp->n_control); | 1086 | atomic_inc(&ctl_cp->n_control); |
732 | } | 1087 | } |
733 | 1088 | ||
1089 | /* | ||
1090 | * IPVS netns init & cleanup functions | ||
1091 | */ | ||
1092 | extern int __ip_vs_estimator_init(struct net *net); | ||
1093 | extern int __ip_vs_control_init(struct net *net); | ||
1094 | extern int __ip_vs_protocol_init(struct net *net); | ||
1095 | extern int __ip_vs_app_init(struct net *net); | ||
1096 | extern int __ip_vs_conn_init(struct net *net); | ||
1097 | extern int __ip_vs_sync_init(struct net *net); | ||
1098 | extern void __ip_vs_conn_cleanup(struct net *net); | ||
1099 | extern void __ip_vs_app_cleanup(struct net *net); | ||
1100 | extern void __ip_vs_protocol_cleanup(struct net *net); | ||
1101 | extern void __ip_vs_control_cleanup(struct net *net); | ||
1102 | extern void __ip_vs_estimator_cleanup(struct net *net); | ||
1103 | extern void __ip_vs_sync_cleanup(struct net *net); | ||
1104 | extern void __ip_vs_service_cleanup(struct net *net); | ||
734 | 1105 | ||
735 | /* | 1106 | /* |
736 | * IPVS application functions | 1107 | * IPVS application functions |
737 | * (from ip_vs_app.c) | 1108 | * (from ip_vs_app.c) |
738 | */ | 1109 | */ |
739 | #define IP_VS_APP_MAX_PORTS 8 | 1110 | #define IP_VS_APP_MAX_PORTS 8 |
740 | extern int register_ip_vs_app(struct ip_vs_app *app); | 1111 | extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app); |
741 | extern void unregister_ip_vs_app(struct ip_vs_app *app); | 1112 | extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app); |
742 | extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | 1113 | extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
743 | extern void ip_vs_unbind_app(struct ip_vs_conn *cp); | 1114 | extern void ip_vs_unbind_app(struct ip_vs_conn *cp); |
744 | extern int | 1115 | extern int register_ip_vs_app_inc(struct net *net, struct ip_vs_app *app, |
745 | register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port); | 1116 | __u16 proto, __u16 port); |
746 | extern int ip_vs_app_inc_get(struct ip_vs_app *inc); | 1117 | extern int ip_vs_app_inc_get(struct ip_vs_app *inc); |
747 | extern void ip_vs_app_inc_put(struct ip_vs_app *inc); | 1118 | extern void ip_vs_app_inc_put(struct ip_vs_app *inc); |
748 | 1119 | ||
@@ -751,19 +1122,38 @@ extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff *skb); | |||
751 | extern int ip_vs_app_init(void); | 1122 | extern int ip_vs_app_init(void); |
752 | extern void ip_vs_app_cleanup(void); | 1123 | extern void ip_vs_app_cleanup(void); |
753 | 1124 | ||
1125 | void ip_vs_bind_pe(struct ip_vs_service *svc, struct ip_vs_pe *pe); | ||
1126 | void ip_vs_unbind_pe(struct ip_vs_service *svc); | ||
1127 | int register_ip_vs_pe(struct ip_vs_pe *pe); | ||
1128 | int unregister_ip_vs_pe(struct ip_vs_pe *pe); | ||
1129 | struct ip_vs_pe *ip_vs_pe_getbyname(const char *name); | ||
1130 | struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name); | ||
1131 | |||
1132 | static inline void ip_vs_pe_get(const struct ip_vs_pe *pe) | ||
1133 | { | ||
1134 | if (pe && pe->module) | ||
1135 | __module_get(pe->module); | ||
1136 | } | ||
1137 | |||
1138 | static inline void ip_vs_pe_put(const struct ip_vs_pe *pe) | ||
1139 | { | ||
1140 | if (pe && pe->module) | ||
1141 | module_put(pe->module); | ||
1142 | } | ||
754 | 1143 | ||
755 | /* | 1144 | /* |
756 | * IPVS protocol functions (from ip_vs_proto.c) | 1145 | * IPVS protocol functions (from ip_vs_proto.c) |
757 | */ | 1146 | */ |
758 | extern int ip_vs_protocol_init(void); | 1147 | extern int ip_vs_protocol_init(void); |
759 | extern void ip_vs_protocol_cleanup(void); | 1148 | extern void ip_vs_protocol_cleanup(void); |
760 | extern void ip_vs_protocol_timeout_change(int flags); | 1149 | extern void ip_vs_protocol_timeout_change(struct netns_ipvs *ipvs, int flags); |
761 | extern int *ip_vs_create_timeout_table(int *table, int size); | 1150 | extern int *ip_vs_create_timeout_table(int *table, int size); |
762 | extern int | 1151 | extern int |
763 | ip_vs_set_state_timeout(int *table, int num, const char *const *names, | 1152 | ip_vs_set_state_timeout(int *table, int num, const char *const *names, |
764 | const char *name, int to); | 1153 | const char *name, int to); |
765 | extern void | 1154 | extern void |
766 | ip_vs_tcpudp_debug_packet(struct ip_vs_protocol *pp, const struct sk_buff *skb, | 1155 | ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp, |
1156 | const struct sk_buff *skb, | ||
767 | int offset, const char *msg); | 1157 | int offset, const char *msg); |
768 | 1158 | ||
769 | extern struct ip_vs_protocol ip_vs_protocol_tcp; | 1159 | extern struct ip_vs_protocol ip_vs_protocol_tcp; |
@@ -785,24 +1175,24 @@ extern int ip_vs_unbind_scheduler(struct ip_vs_service *svc); | |||
785 | extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name); | 1175 | extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name); |
786 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); | 1176 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); |
787 | extern struct ip_vs_conn * | 1177 | extern struct ip_vs_conn * |
788 | ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb); | 1178 | ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb, |
1179 | struct ip_vs_proto_data *pd, int *ignored); | ||
789 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, | 1180 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, |
790 | struct ip_vs_protocol *pp); | 1181 | struct ip_vs_proto_data *pd); |
1182 | |||
1183 | extern void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg); | ||
791 | 1184 | ||
792 | 1185 | ||
793 | /* | 1186 | /* |
794 | * IPVS control data and functions (from ip_vs_ctl.c) | 1187 | * IPVS control data and functions (from ip_vs_ctl.c) |
795 | */ | 1188 | */ |
796 | extern int sysctl_ip_vs_cache_bypass; | ||
797 | extern int sysctl_ip_vs_expire_nodest_conn; | ||
798 | extern int sysctl_ip_vs_expire_quiescent_template; | ||
799 | extern int sysctl_ip_vs_sync_threshold[2]; | ||
800 | extern int sysctl_ip_vs_nat_icmp_send; | ||
801 | extern struct ip_vs_stats ip_vs_stats; | 1189 | extern struct ip_vs_stats ip_vs_stats; |
802 | extern const struct ctl_path net_vs_ctl_path[]; | 1190 | extern const struct ctl_path net_vs_ctl_path[]; |
1191 | extern int sysctl_ip_vs_sync_ver; | ||
803 | 1192 | ||
1193 | extern void ip_vs_sync_switch_mode(struct net *net, int mode); | ||
804 | extern struct ip_vs_service * | 1194 | extern struct ip_vs_service * |
805 | ip_vs_service_get(int af, __u32 fwmark, __u16 protocol, | 1195 | ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol, |
806 | const union nf_inet_addr *vaddr, __be16 vport); | 1196 | const union nf_inet_addr *vaddr, __be16 vport); |
807 | 1197 | ||
808 | static inline void ip_vs_service_put(struct ip_vs_service *svc) | 1198 | static inline void ip_vs_service_put(struct ip_vs_service *svc) |
@@ -811,7 +1201,7 @@ static inline void ip_vs_service_put(struct ip_vs_service *svc) | |||
811 | } | 1201 | } |
812 | 1202 | ||
813 | extern struct ip_vs_dest * | 1203 | extern struct ip_vs_dest * |
814 | ip_vs_lookup_real_service(int af, __u16 protocol, | 1204 | ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol, |
815 | const union nf_inet_addr *daddr, __be16 dport); | 1205 | const union nf_inet_addr *daddr, __be16 dport); |
816 | 1206 | ||
817 | extern int ip_vs_use_count_inc(void); | 1207 | extern int ip_vs_use_count_inc(void); |
@@ -819,8 +1209,9 @@ extern void ip_vs_use_count_dec(void); | |||
819 | extern int ip_vs_control_init(void); | 1209 | extern int ip_vs_control_init(void); |
820 | extern void ip_vs_control_cleanup(void); | 1210 | extern void ip_vs_control_cleanup(void); |
821 | extern struct ip_vs_dest * | 1211 | extern struct ip_vs_dest * |
822 | ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport, | 1212 | ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, |
823 | const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol); | 1213 | __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, |
1214 | __u16 protocol, __u32 fwmark); | ||
824 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | 1215 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); |
825 | 1216 | ||
826 | 1217 | ||
@@ -828,14 +1219,12 @@ extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | |||
828 | * IPVS sync daemon data and function prototypes | 1219 | * IPVS sync daemon data and function prototypes |
829 | * (from ip_vs_sync.c) | 1220 | * (from ip_vs_sync.c) |
830 | */ | 1221 | */ |
831 | extern volatile int ip_vs_sync_state; | 1222 | extern int start_sync_thread(struct net *net, int state, char *mcast_ifn, |
832 | extern volatile int ip_vs_master_syncid; | 1223 | __u8 syncid); |
833 | extern volatile int ip_vs_backup_syncid; | 1224 | extern int stop_sync_thread(struct net *net, int state); |
834 | extern char ip_vs_master_mcast_ifn[IP_VS_IFNAME_MAXLEN]; | 1225 | extern void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp); |
835 | extern char ip_vs_backup_mcast_ifn[IP_VS_IFNAME_MAXLEN]; | 1226 | extern int ip_vs_sync_init(void); |
836 | extern int start_sync_thread(int state, char *mcast_ifn, __u8 syncid); | 1227 | extern void ip_vs_sync_cleanup(void); |
837 | extern int stop_sync_thread(int state); | ||
838 | extern void ip_vs_sync_conn(struct ip_vs_conn *cp); | ||
839 | 1228 | ||
840 | 1229 | ||
841 | /* | 1230 | /* |
@@ -843,9 +1232,11 @@ extern void ip_vs_sync_conn(struct ip_vs_conn *cp); | |||
843 | */ | 1232 | */ |
844 | extern int ip_vs_estimator_init(void); | 1233 | extern int ip_vs_estimator_init(void); |
845 | extern void ip_vs_estimator_cleanup(void); | 1234 | extern void ip_vs_estimator_cleanup(void); |
846 | extern void ip_vs_new_estimator(struct ip_vs_stats *stats); | 1235 | extern void ip_vs_start_estimator(struct net *net, struct ip_vs_stats *stats); |
847 | extern void ip_vs_kill_estimator(struct ip_vs_stats *stats); | 1236 | extern void ip_vs_stop_estimator(struct net *net, struct ip_vs_stats *stats); |
848 | extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); | 1237 | extern void ip_vs_zero_estimator(struct ip_vs_stats *stats); |
1238 | extern void ip_vs_read_estimator(struct ip_vs_stats_user *dst, | ||
1239 | struct ip_vs_stats *stats); | ||
849 | 1240 | ||
850 | /* | 1241 | /* |
851 | * Various IPVS packet transmitters (from ip_vs_xmit.c) | 1242 | * Various IPVS packet transmitters (from ip_vs_xmit.c) |
@@ -861,7 +1252,8 @@ extern int ip_vs_tunnel_xmit | |||
861 | extern int ip_vs_dr_xmit | 1252 | extern int ip_vs_dr_xmit |
862 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | 1253 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
863 | extern int ip_vs_icmp_xmit | 1254 | extern int ip_vs_icmp_xmit |
864 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int offset); | 1255 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, |
1256 | int offset, unsigned int hooknum); | ||
865 | extern void ip_vs_dst_reset(struct ip_vs_dest *dest); | 1257 | extern void ip_vs_dst_reset(struct ip_vs_dest *dest); |
866 | 1258 | ||
867 | #ifdef CONFIG_IP_VS_IPV6 | 1259 | #ifdef CONFIG_IP_VS_IPV6 |
@@ -875,24 +1267,28 @@ extern int ip_vs_dr_xmit_v6 | |||
875 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | 1267 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
876 | extern int ip_vs_icmp_xmit_v6 | 1268 | extern int ip_vs_icmp_xmit_v6 |
877 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, | 1269 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, |
878 | int offset); | 1270 | int offset, unsigned int hooknum); |
879 | #endif | 1271 | #endif |
880 | 1272 | ||
1273 | #ifdef CONFIG_SYSCTL | ||
881 | /* | 1274 | /* |
882 | * This is a simple mechanism to ignore packets when | 1275 | * This is a simple mechanism to ignore packets when |
883 | * we are loaded. Just set ip_vs_drop_rate to 'n' and | 1276 | * we are loaded. Just set ip_vs_drop_rate to 'n' and |
884 | * we start to drop 1/rate of the packets | 1277 | * we start to drop 1/rate of the packets |
885 | */ | 1278 | */ |
886 | extern int ip_vs_drop_rate; | ||
887 | extern int ip_vs_drop_counter; | ||
888 | 1279 | ||
889 | static __inline__ int ip_vs_todrop(void) | 1280 | static inline int ip_vs_todrop(struct netns_ipvs *ipvs) |
890 | { | 1281 | { |
891 | if (!ip_vs_drop_rate) return 0; | 1282 | if (!ipvs->drop_rate) |
892 | if (--ip_vs_drop_counter > 0) return 0; | 1283 | return 0; |
893 | ip_vs_drop_counter = ip_vs_drop_rate; | 1284 | if (--ipvs->drop_counter > 0) |
1285 | return 0; | ||
1286 | ipvs->drop_counter = ipvs->drop_rate; | ||
894 | return 1; | 1287 | return 1; |
895 | } | 1288 | } |
1289 | #else | ||
1290 | static inline int ip_vs_todrop(struct netns_ipvs *ipvs) { return 0; } | ||
1291 | #endif | ||
896 | 1292 | ||
897 | /* | 1293 | /* |
898 | * ip_vs_fwd_tag returns the forwarding tag of the connection | 1294 | * ip_vs_fwd_tag returns the forwarding tag of the connection |
@@ -955,9 +1351,82 @@ static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum) | |||
955 | return csum_partial(diff, sizeof(diff), oldsum); | 1351 | return csum_partial(diff, sizeof(diff), oldsum); |
956 | } | 1352 | } |
957 | 1353 | ||
1354 | /* | ||
1355 | * Forget current conntrack (unconfirmed) and attach notrack entry | ||
1356 | */ | ||
1357 | static inline void ip_vs_notrack(struct sk_buff *skb) | ||
1358 | { | ||
1359 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
1360 | enum ip_conntrack_info ctinfo; | ||
1361 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | ||
1362 | |||
1363 | if (!ct || !nf_ct_is_untracked(ct)) { | ||
1364 | nf_reset(skb); | ||
1365 | skb->nfct = &nf_ct_untracked_get()->ct_general; | ||
1366 | skb->nfctinfo = IP_CT_NEW; | ||
1367 | nf_conntrack_get(skb->nfct); | ||
1368 | } | ||
1369 | #endif | ||
1370 | } | ||
1371 | |||
1372 | #ifdef CONFIG_IP_VS_NFCT | ||
1373 | /* | ||
1374 | * Netfilter connection tracking | ||
1375 | * (from ip_vs_nfct.c) | ||
1376 | */ | ||
1377 | static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs) | ||
1378 | { | ||
1379 | #ifdef CONFIG_SYSCTL | ||
1380 | return ipvs->sysctl_conntrack; | ||
1381 | #else | ||
1382 | return 0; | ||
1383 | #endif | ||
1384 | } | ||
1385 | |||
958 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, | 1386 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, |
959 | int outin); | 1387 | int outin); |
1388 | extern int ip_vs_confirm_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp); | ||
1389 | extern void ip_vs_nfct_expect_related(struct sk_buff *skb, struct nf_conn *ct, | ||
1390 | struct ip_vs_conn *cp, u_int8_t proto, | ||
1391 | const __be16 port, int from_rs); | ||
1392 | extern void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp); | ||
1393 | |||
1394 | #else | ||
1395 | |||
1396 | static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs) | ||
1397 | { | ||
1398 | return 0; | ||
1399 | } | ||
960 | 1400 | ||
961 | #endif /* __KERNEL__ */ | 1401 | static inline void ip_vs_update_conntrack(struct sk_buff *skb, |
1402 | struct ip_vs_conn *cp, int outin) | ||
1403 | { | ||
1404 | } | ||
1405 | |||
1406 | static inline int ip_vs_confirm_conntrack(struct sk_buff *skb, | ||
1407 | struct ip_vs_conn *cp) | ||
1408 | { | ||
1409 | return NF_ACCEPT; | ||
1410 | } | ||
1411 | |||
1412 | static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp) | ||
1413 | { | ||
1414 | } | ||
1415 | /* CONFIG_IP_VS_NFCT */ | ||
1416 | #endif | ||
1417 | |||
1418 | static inline unsigned int | ||
1419 | ip_vs_dest_conn_overhead(struct ip_vs_dest *dest) | ||
1420 | { | ||
1421 | /* | ||
1422 | * We think the overhead of processing active connections is 256 | ||
1423 | * times higher than that of inactive connections in average. (This | ||
1424 | * 256 times might not be accurate, we will change it later) We | ||
1425 | * use the following formula to estimate the overhead now: | ||
1426 | * dest->activeconns*256 + dest->inactconns | ||
1427 | */ | ||
1428 | return (atomic_read(&dest->activeconns) << 8) + | ||
1429 | atomic_read(&dest->inactconns); | ||
1430 | } | ||
962 | 1431 | ||
963 | #endif /* _NET_IP_VS_H */ | 1432 | #endif /* _NET_IP_VS_H */ |
diff --git a/include/net/ipip.h b/include/net/ipip.h index 65caea8b414f..a32654d52730 100644 --- a/include/net/ipip.h +++ b/include/net/ipip.h | |||
@@ -16,7 +16,7 @@ struct ip_tunnel_6rd_parm { | |||
16 | }; | 16 | }; |
17 | 17 | ||
18 | struct ip_tunnel { | 18 | struct ip_tunnel { |
19 | struct ip_tunnel *next; | 19 | struct ip_tunnel __rcu *next; |
20 | struct net_device *dev; | 20 | struct net_device *dev; |
21 | 21 | ||
22 | int err_count; /* Number of arrived ICMP errors */ | 22 | int err_count; /* Number of arrived ICMP errors */ |
@@ -34,18 +34,18 @@ struct ip_tunnel { | |||
34 | #ifdef CONFIG_IPV6_SIT_6RD | 34 | #ifdef CONFIG_IPV6_SIT_6RD |
35 | struct ip_tunnel_6rd_parm ip6rd; | 35 | struct ip_tunnel_6rd_parm ip6rd; |
36 | #endif | 36 | #endif |
37 | struct ip_tunnel_prl_entry *prl; /* potential router list */ | 37 | struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */ |
38 | unsigned int prl_count; /* # of entries in PRL */ | 38 | unsigned int prl_count; /* # of entries in PRL */ |
39 | }; | 39 | }; |
40 | 40 | ||
41 | struct ip_tunnel_prl_entry { | 41 | struct ip_tunnel_prl_entry { |
42 | struct ip_tunnel_prl_entry *next; | 42 | struct ip_tunnel_prl_entry __rcu *next; |
43 | __be32 addr; | 43 | __be32 addr; |
44 | u16 flags; | 44 | u16 flags; |
45 | struct rcu_head rcu_head; | 45 | struct rcu_head rcu_head; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #define IPTUNNEL_XMIT() do { \ | 48 | #define __IPTUNNEL_XMIT(stats1, stats2) do { \ |
49 | int err; \ | 49 | int err; \ |
50 | int pkt_len = skb->len - skb_transport_offset(skb); \ | 50 | int pkt_len = skb->len - skb_transport_offset(skb); \ |
51 | \ | 51 | \ |
@@ -54,12 +54,14 @@ struct ip_tunnel_prl_entry { | |||
54 | \ | 54 | \ |
55 | err = ip_local_out(skb); \ | 55 | err = ip_local_out(skb); \ |
56 | if (likely(net_xmit_eval(err) == 0)) { \ | 56 | if (likely(net_xmit_eval(err) == 0)) { \ |
57 | txq->tx_bytes += pkt_len; \ | 57 | (stats1)->tx_bytes += pkt_len; \ |
58 | txq->tx_packets++; \ | 58 | (stats1)->tx_packets++; \ |
59 | } else { \ | 59 | } else { \ |
60 | stats->tx_errors++; \ | 60 | (stats2)->tx_errors++; \ |
61 | stats->tx_aborted_errors++; \ | 61 | (stats2)->tx_aborted_errors++; \ |
62 | } \ | 62 | } \ |
63 | } while (0) | 63 | } while (0) |
64 | 64 | ||
65 | #define IPTUNNEL_XMIT() __IPTUNNEL_XMIT(txq, stats) | ||
66 | |||
65 | #endif | 67 | #endif |
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 1f8412410998..c033ed00df7d 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -77,11 +77,9 @@ | |||
77 | /* | 77 | /* |
78 | * Addr scopes | 78 | * Addr scopes |
79 | */ | 79 | */ |
80 | #ifdef __KERNEL__ | ||
81 | #define IPV6_ADDR_MC_SCOPE(a) \ | 80 | #define IPV6_ADDR_MC_SCOPE(a) \ |
82 | ((a)->s6_addr[1] & 0x0f) /* nonstandard */ | 81 | ((a)->s6_addr[1] & 0x0f) /* nonstandard */ |
83 | #define __IPV6_ADDR_SCOPE_INVALID -1 | 82 | #define __IPV6_ADDR_SCOPE_INVALID -1 |
84 | #endif | ||
85 | #define IPV6_ADDR_SCOPE_NODELOCAL 0x01 | 83 | #define IPV6_ADDR_SCOPE_NODELOCAL 0x01 |
86 | #define IPV6_ADDR_SCOPE_LINKLOCAL 0x02 | 84 | #define IPV6_ADDR_SCOPE_LINKLOCAL 0x02 |
87 | #define IPV6_ADDR_SCOPE_SITELOCAL 0x05 | 85 | #define IPV6_ADDR_SCOPE_SITELOCAL 0x05 |
@@ -89,6 +87,16 @@ | |||
89 | #define IPV6_ADDR_SCOPE_GLOBAL 0x0e | 87 | #define IPV6_ADDR_SCOPE_GLOBAL 0x0e |
90 | 88 | ||
91 | /* | 89 | /* |
90 | * Addr flags | ||
91 | */ | ||
92 | #define IPV6_ADDR_MC_FLAG_TRANSIENT(a) \ | ||
93 | ((a)->s6_addr[1] & 0x10) | ||
94 | #define IPV6_ADDR_MC_FLAG_PREFIX(a) \ | ||
95 | ((a)->s6_addr[1] & 0x20) | ||
96 | #define IPV6_ADDR_MC_FLAG_RENDEZVOUS(a) \ | ||
97 | ((a)->s6_addr[1] & 0x40) | ||
98 | |||
99 | /* | ||
92 | * fragmentation header | 100 | * fragmentation header |
93 | */ | 101 | */ |
94 | 102 | ||
@@ -101,8 +109,6 @@ struct frag_hdr { | |||
101 | 109 | ||
102 | #define IP6_MF 0x0001 | 110 | #define IP6_MF 0x0001 |
103 | 111 | ||
104 | #ifdef __KERNEL__ | ||
105 | |||
106 | #include <net/sock.h> | 112 | #include <net/sock.h> |
107 | 113 | ||
108 | /* sysctls */ | 114 | /* sysctls */ |
@@ -117,6 +123,15 @@ extern struct ctl_path net_ipv6_ctl_path[]; | |||
117 | SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ | 123 | SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ |
118 | }) | 124 | }) |
119 | 125 | ||
126 | /* per device counters are atomic_long_t */ | ||
127 | #define _DEVINCATOMIC(net, statname, modifier, idev, field) \ | ||
128 | ({ \ | ||
129 | struct inet6_dev *_idev = (idev); \ | ||
130 | if (likely(_idev != NULL)) \ | ||
131 | SNMP_INC_STATS_ATOMIC_LONG((_idev)->stats.statname##dev, (field)); \ | ||
132 | SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ | ||
133 | }) | ||
134 | |||
120 | #define _DEVADD(net, statname, modifier, idev, field, val) \ | 135 | #define _DEVADD(net, statname, modifier, idev, field, val) \ |
121 | ({ \ | 136 | ({ \ |
122 | struct inet6_dev *_idev = (idev); \ | 137 | struct inet6_dev *_idev = (idev); \ |
@@ -148,16 +163,16 @@ extern struct ctl_path net_ipv6_ctl_path[]; | |||
148 | #define IP6_UPD_PO_STATS_BH(net, idev,field,val) \ | 163 | #define IP6_UPD_PO_STATS_BH(net, idev,field,val) \ |
149 | _DEVUPD(net, ipv6, 64_BH, idev, field, val) | 164 | _DEVUPD(net, ipv6, 64_BH, idev, field, val) |
150 | #define ICMP6_INC_STATS(net, idev, field) \ | 165 | #define ICMP6_INC_STATS(net, idev, field) \ |
151 | _DEVINC(net, icmpv6, , idev, field) | 166 | _DEVINCATOMIC(net, icmpv6, , idev, field) |
152 | #define ICMP6_INC_STATS_BH(net, idev, field) \ | 167 | #define ICMP6_INC_STATS_BH(net, idev, field) \ |
153 | _DEVINC(net, icmpv6, _BH, idev, field) | 168 | _DEVINCATOMIC(net, icmpv6, _BH, idev, field) |
154 | 169 | ||
155 | #define ICMP6MSGOUT_INC_STATS(net, idev, field) \ | 170 | #define ICMP6MSGOUT_INC_STATS(net, idev, field) \ |
156 | _DEVINC(net, icmpv6msg, , idev, field +256) | 171 | _DEVINCATOMIC(net, icmpv6msg, , idev, field +256) |
157 | #define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \ | 172 | #define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \ |
158 | _DEVINC(net, icmpv6msg, _BH, idev, field +256) | 173 | _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field +256) |
159 | #define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \ | 174 | #define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \ |
160 | _DEVINC(net, icmpv6msg, _BH, idev, field) | 175 | _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field) |
161 | 176 | ||
162 | struct ip6_ra_chain { | 177 | struct ip6_ra_chain { |
163 | struct ip6_ra_chain *next; | 178 | struct ip6_ra_chain *next; |
@@ -262,7 +277,7 @@ static inline int ipv6_addr_scope(const struct in6_addr *addr) | |||
262 | 277 | ||
263 | static inline int __ipv6_addr_src_scope(int type) | 278 | static inline int __ipv6_addr_src_scope(int type) |
264 | { | 279 | { |
265 | return (type == IPV6_ADDR_ANY ? __IPV6_ADDR_SCOPE_INVALID : (type >> 16)); | 280 | return (type == IPV6_ADDR_ANY) ? __IPV6_ADDR_SCOPE_INVALID : (type >> 16); |
266 | } | 281 | } |
267 | 282 | ||
268 | static inline int ipv6_addr_src_scope(const struct in6_addr *addr) | 283 | static inline int ipv6_addr_src_scope(const struct in6_addr *addr) |
@@ -279,10 +294,10 @@ static inline int | |||
279 | ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m, | 294 | ipv6_masked_addr_cmp(const struct in6_addr *a1, const struct in6_addr *m, |
280 | const struct in6_addr *a2) | 295 | const struct in6_addr *a2) |
281 | { | 296 | { |
282 | return (!!(((a1->s6_addr32[0] ^ a2->s6_addr32[0]) & m->s6_addr32[0]) | | 297 | return !!(((a1->s6_addr32[0] ^ a2->s6_addr32[0]) & m->s6_addr32[0]) | |
283 | ((a1->s6_addr32[1] ^ a2->s6_addr32[1]) & m->s6_addr32[1]) | | 298 | ((a1->s6_addr32[1] ^ a2->s6_addr32[1]) & m->s6_addr32[1]) | |
284 | ((a1->s6_addr32[2] ^ a2->s6_addr32[2]) & m->s6_addr32[2]) | | 299 | ((a1->s6_addr32[2] ^ a2->s6_addr32[2]) & m->s6_addr32[2]) | |
285 | ((a1->s6_addr32[3] ^ a2->s6_addr32[3]) & m->s6_addr32[3]))); | 300 | ((a1->s6_addr32[3] ^ a2->s6_addr32[3]) & m->s6_addr32[3])); |
286 | } | 301 | } |
287 | 302 | ||
288 | static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) | 303 | static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) |
@@ -317,10 +332,10 @@ static inline void ipv6_addr_set(struct in6_addr *addr, | |||
317 | static inline int ipv6_addr_equal(const struct in6_addr *a1, | 332 | static inline int ipv6_addr_equal(const struct in6_addr *a1, |
318 | const struct in6_addr *a2) | 333 | const struct in6_addr *a2) |
319 | { | 334 | { |
320 | return (((a1->s6_addr32[0] ^ a2->s6_addr32[0]) | | 335 | return ((a1->s6_addr32[0] ^ a2->s6_addr32[0]) | |
321 | (a1->s6_addr32[1] ^ a2->s6_addr32[1]) | | 336 | (a1->s6_addr32[1] ^ a2->s6_addr32[1]) | |
322 | (a1->s6_addr32[2] ^ a2->s6_addr32[2]) | | 337 | (a1->s6_addr32[2] ^ a2->s6_addr32[2]) | |
323 | (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0); | 338 | (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0; |
324 | } | 339 | } |
325 | 340 | ||
326 | static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, | 341 | static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, |
@@ -364,8 +379,8 @@ enum ip6_defrag_users { | |||
364 | struct ip6_create_arg { | 379 | struct ip6_create_arg { |
365 | __be32 id; | 380 | __be32 id; |
366 | u32 user; | 381 | u32 user; |
367 | struct in6_addr *src; | 382 | const struct in6_addr *src; |
368 | struct in6_addr *dst; | 383 | const struct in6_addr *dst; |
369 | }; | 384 | }; |
370 | 385 | ||
371 | void ip6_frag_init(struct inet_frag_queue *q, void *a); | 386 | void ip6_frag_init(struct inet_frag_queue *q, void *a); |
@@ -373,20 +388,20 @@ int ip6_frag_match(struct inet_frag_queue *q, void *a); | |||
373 | 388 | ||
374 | static inline int ipv6_addr_any(const struct in6_addr *a) | 389 | static inline int ipv6_addr_any(const struct in6_addr *a) |
375 | { | 390 | { |
376 | return ((a->s6_addr32[0] | a->s6_addr32[1] | | 391 | return (a->s6_addr32[0] | a->s6_addr32[1] | |
377 | a->s6_addr32[2] | a->s6_addr32[3] ) == 0); | 392 | a->s6_addr32[2] | a->s6_addr32[3]) == 0; |
378 | } | 393 | } |
379 | 394 | ||
380 | static inline int ipv6_addr_loopback(const struct in6_addr *a) | 395 | static inline int ipv6_addr_loopback(const struct in6_addr *a) |
381 | { | 396 | { |
382 | return ((a->s6_addr32[0] | a->s6_addr32[1] | | 397 | return (a->s6_addr32[0] | a->s6_addr32[1] | |
383 | a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0); | 398 | a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0; |
384 | } | 399 | } |
385 | 400 | ||
386 | static inline int ipv6_addr_v4mapped(const struct in6_addr *a) | 401 | static inline int ipv6_addr_v4mapped(const struct in6_addr *a) |
387 | { | 402 | { |
388 | return ((a->s6_addr32[0] | a->s6_addr32[1] | | 403 | return (a->s6_addr32[0] | a->s6_addr32[1] | |
389 | (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0); | 404 | (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0; |
390 | } | 405 | } |
391 | 406 | ||
392 | /* | 407 | /* |
@@ -395,8 +410,7 @@ static inline int ipv6_addr_v4mapped(const struct in6_addr *a) | |||
395 | */ | 410 | */ |
396 | static inline int ipv6_addr_orchid(const struct in6_addr *a) | 411 | static inline int ipv6_addr_orchid(const struct in6_addr *a) |
397 | { | 412 | { |
398 | return ((a->s6_addr32[0] & htonl(0xfffffff0)) | 413 | return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010); |
399 | == htonl(0x20010010)); | ||
400 | } | 414 | } |
401 | 415 | ||
402 | static inline void ipv6_addr_set_v4mapped(const __be32 addr, | 416 | static inline void ipv6_addr_set_v4mapped(const __be32 addr, |
@@ -441,7 +455,7 @@ static inline int __ipv6_addr_diff(const void *token1, const void *token2, int a | |||
441 | * if returned value is greater than prefix length. | 455 | * if returned value is greater than prefix length. |
442 | * --ANK (980803) | 456 | * --ANK (980803) |
443 | */ | 457 | */ |
444 | return (addrlen << 5); | 458 | return addrlen << 5; |
445 | } | 459 | } |
446 | 460 | ||
447 | static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_addr *a2) | 461 | static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_addr *a2) |
@@ -481,7 +495,7 @@ extern int ip6_rcv_finish(struct sk_buff *skb); | |||
481 | */ | 495 | */ |
482 | extern int ip6_xmit(struct sock *sk, | 496 | extern int ip6_xmit(struct sock *sk, |
483 | struct sk_buff *skb, | 497 | struct sk_buff *skb, |
484 | struct flowi *fl, | 498 | struct flowi6 *fl6, |
485 | struct ipv6_txoptions *opt); | 499 | struct ipv6_txoptions *opt); |
486 | 500 | ||
487 | extern int ip6_nd_hdr(struct sock *sk, | 501 | extern int ip6_nd_hdr(struct sock *sk, |
@@ -501,7 +515,7 @@ extern int ip6_append_data(struct sock *sk, | |||
501 | int hlimit, | 515 | int hlimit, |
502 | int tclass, | 516 | int tclass, |
503 | struct ipv6_txoptions *opt, | 517 | struct ipv6_txoptions *opt, |
504 | struct flowi *fl, | 518 | struct flowi6 *fl6, |
505 | struct rt6_info *rt, | 519 | struct rt6_info *rt, |
506 | unsigned int flags, | 520 | unsigned int flags, |
507 | int dontfrag); | 521 | int dontfrag); |
@@ -512,13 +526,17 @@ extern void ip6_flush_pending_frames(struct sock *sk); | |||
512 | 526 | ||
513 | extern int ip6_dst_lookup(struct sock *sk, | 527 | extern int ip6_dst_lookup(struct sock *sk, |
514 | struct dst_entry **dst, | 528 | struct dst_entry **dst, |
515 | struct flowi *fl); | 529 | struct flowi6 *fl6); |
516 | extern int ip6_dst_blackhole(struct sock *sk, | 530 | extern struct dst_entry * ip6_dst_lookup_flow(struct sock *sk, |
517 | struct dst_entry **dst, | 531 | struct flowi6 *fl6, |
518 | struct flowi *fl); | 532 | const struct in6_addr *final_dst, |
519 | extern int ip6_sk_dst_lookup(struct sock *sk, | 533 | bool can_sleep); |
520 | struct dst_entry **dst, | 534 | extern struct dst_entry * ip6_sk_dst_lookup_flow(struct sock *sk, |
521 | struct flowi *fl); | 535 | struct flowi6 *fl6, |
536 | const struct in6_addr *final_dst, | ||
537 | bool can_sleep); | ||
538 | extern struct dst_entry * ip6_blackhole_route(struct net *net, | ||
539 | struct dst_entry *orig_dst); | ||
522 | 540 | ||
523 | /* | 541 | /* |
524 | * skb processing functions | 542 | * skb processing functions |
@@ -551,7 +569,7 @@ extern int ipv6_ext_hdr(u8 nexthdr); | |||
551 | 569 | ||
552 | extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type); | 570 | extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type); |
553 | 571 | ||
554 | extern struct in6_addr *fl6_update_dst(struct flowi *fl, | 572 | extern struct in6_addr *fl6_update_dst(struct flowi6 *fl6, |
555 | const struct ipv6_txoptions *opt, | 573 | const struct ipv6_txoptions *opt, |
556 | struct in6_addr *orig); | 574 | struct in6_addr *orig); |
557 | 575 | ||
@@ -585,8 +603,8 @@ extern int ipv6_recv_error(struct sock *sk, struct msghdr *msg, int len); | |||
585 | extern int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len); | 603 | extern int ipv6_recv_rxpmtu(struct sock *sk, struct msghdr *msg, int len); |
586 | extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port, | 604 | extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, __be16 port, |
587 | u32 info, u8 *payload); | 605 | u32 info, u8 *payload); |
588 | extern void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info); | 606 | extern void ipv6_local_error(struct sock *sk, int err, struct flowi6 *fl6, u32 info); |
589 | extern void ipv6_local_rxpmtu(struct sock *sk, struct flowi *fl, u32 mtu); | 607 | extern void ipv6_local_rxpmtu(struct sock *sk, struct flowi6 *fl6, u32 mtu); |
590 | 608 | ||
591 | extern int inet6_release(struct socket *sock); | 609 | extern int inet6_release(struct socket *sock); |
592 | extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr, | 610 | extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr, |
@@ -652,5 +670,4 @@ extern int ipv6_static_sysctl_register(void); | |||
652 | extern void ipv6_static_sysctl_unregister(void); | 670 | extern void ipv6_static_sysctl_unregister(void); |
653 | #endif | 671 | #endif |
654 | 672 | ||
655 | #endif /* __KERNEL__ */ | ||
656 | #endif /* _NET_IPV6_H */ | 673 | #endif /* _NET_IPV6_H */ |
diff --git a/include/net/ipx.h b/include/net/ipx.h index 05d7e4a88b49..c1fec6b464cc 100644 --- a/include/net/ipx.h +++ b/include/net/ipx.h | |||
@@ -80,7 +80,6 @@ struct ipx_route { | |||
80 | atomic_t refcnt; | 80 | atomic_t refcnt; |
81 | }; | 81 | }; |
82 | 82 | ||
83 | #ifdef __KERNEL__ | ||
84 | struct ipx_cb { | 83 | struct ipx_cb { |
85 | u8 ipx_tctrl; | 84 | u8 ipx_tctrl; |
86 | __be32 ipx_dest_net; | 85 | __be32 ipx_dest_net; |
@@ -116,7 +115,6 @@ static inline struct ipx_sock *ipx_sk(struct sock *sk) | |||
116 | } | 115 | } |
117 | 116 | ||
118 | #define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0])) | 117 | #define IPX_SKB_CB(__skb) ((struct ipx_cb *)&((__skb)->cb[0])) |
119 | #endif | ||
120 | 118 | ||
121 | #define IPX_MIN_EPHEMERAL_SOCKET 0x4000 | 119 | #define IPX_MIN_EPHEMERAL_SOCKET 0x4000 |
122 | #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff | 120 | #define IPX_MAX_EPHEMERAL_SOCKET 0x7fff |
diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h index eea2e6152389..59ba38bc400f 100644 --- a/include/net/irda/ircomm_tty.h +++ b/include/net/irda/ircomm_tty.h | |||
@@ -120,10 +120,10 @@ struct ircomm_tty_cb { | |||
120 | void ircomm_tty_start(struct tty_struct *tty); | 120 | void ircomm_tty_start(struct tty_struct *tty); |
121 | void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self); | 121 | void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self); |
122 | 122 | ||
123 | extern int ircomm_tty_tiocmget(struct tty_struct *tty, struct file *file); | 123 | extern int ircomm_tty_tiocmget(struct tty_struct *tty); |
124 | extern int ircomm_tty_tiocmset(struct tty_struct *tty, struct file *file, | 124 | extern int ircomm_tty_tiocmset(struct tty_struct *tty, |
125 | unsigned int set, unsigned int clear); | 125 | unsigned int set, unsigned int clear); |
126 | extern int ircomm_tty_ioctl(struct tty_struct *tty, struct file *file, | 126 | extern int ircomm_tty_ioctl(struct tty_struct *tty, |
127 | unsigned int cmd, unsigned long arg); | 127 | unsigned int cmd, unsigned long arg); |
128 | extern void ircomm_tty_set_termios(struct tty_struct *tty, | 128 | extern void ircomm_tty_set_termios(struct tty_struct *tty, |
129 | struct ktermios *old_termios); | 129 | struct ktermios *old_termios); |
diff --git a/include/net/irda/irlan_common.h b/include/net/irda/irlan_common.h index 73cacb3ac16c..0af8b8dfbc22 100644 --- a/include/net/irda/irlan_common.h +++ b/include/net/irda/irlan_common.h | |||
@@ -171,7 +171,6 @@ struct irlan_cb { | |||
171 | int magic; | 171 | int magic; |
172 | struct list_head dev_list; | 172 | struct list_head dev_list; |
173 | struct net_device *dev; /* Ethernet device structure*/ | 173 | struct net_device *dev; /* Ethernet device structure*/ |
174 | struct net_device_stats stats; | ||
175 | 174 | ||
176 | __u32 saddr; /* Source device address */ | 175 | __u32 saddr; /* Source device address */ |
177 | __u32 daddr; /* Destination device address */ | 176 | __u32 daddr; /* Destination device address */ |
diff --git a/include/net/irda/irlan_event.h b/include/net/irda/irlan_event.h index 6d9539f05806..018b5a77e610 100644 --- a/include/net/irda/irlan_event.h +++ b/include/net/irda/irlan_event.h | |||
@@ -67,7 +67,7 @@ typedef enum { | |||
67 | IRLAN_WATCHDOG_TIMEOUT, | 67 | IRLAN_WATCHDOG_TIMEOUT, |
68 | } IRLAN_EVENT; | 68 | } IRLAN_EVENT; |
69 | 69 | ||
70 | extern char *irlan_state[]; | 70 | extern const char * const irlan_state[]; |
71 | 71 | ||
72 | void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event, | 72 | void irlan_do_client_event(struct irlan_cb *self, IRLAN_EVENT event, |
73 | struct sk_buff *skb); | 73 | struct sk_buff *skb); |
diff --git a/include/net/irda/irlap.h b/include/net/irda/irlap.h index 9d0c78ea92f5..fb4b76d5d7f1 100644 --- a/include/net/irda/irlap.h +++ b/include/net/irda/irlap.h | |||
@@ -204,7 +204,7 @@ struct irlap_cb { | |||
204 | 204 | ||
205 | notify_t notify; /* Callbacks to IrLMP */ | 205 | notify_t notify; /* Callbacks to IrLMP */ |
206 | 206 | ||
207 | int mtt_required; /* Minumum turnaround time required */ | 207 | int mtt_required; /* Minimum turnaround time required */ |
208 | int xbofs_delay; /* Nr of XBOF's used to MTT */ | 208 | int xbofs_delay; /* Nr of XBOF's used to MTT */ |
209 | int bofs_count; /* Negotiated extra BOFs */ | 209 | int bofs_count; /* Negotiated extra BOFs */ |
210 | int next_bofs; /* Negotiated extra BOFs after next frame */ | 210 | int next_bofs; /* Negotiated extra BOFs after next frame */ |
@@ -282,7 +282,7 @@ static inline int irlap_is_primary(struct irlap_cb *self) | |||
282 | default: | 282 | default: |
283 | ret = -1; | 283 | ret = -1; |
284 | } | 284 | } |
285 | return(ret); | 285 | return ret; |
286 | } | 286 | } |
287 | 287 | ||
288 | /* Clear a pending IrLAP disconnect. - Jean II */ | 288 | /* Clear a pending IrLAP disconnect. - Jean II */ |
diff --git a/include/net/irda/irlmp.h b/include/net/irda/irlmp.h index 3ffc1d0f93d6..fff11b7fe8a4 100644 --- a/include/net/irda/irlmp.h +++ b/include/net/irda/irlmp.h | |||
@@ -274,7 +274,7 @@ static inline int irlmp_lap_tx_queue_full(struct lsap_cb *self) | |||
274 | if (self->lap->irlap == NULL) | 274 | if (self->lap->irlap == NULL) |
275 | return 0; | 275 | return 0; |
276 | 276 | ||
277 | return(IRLAP_GET_TX_QUEUE_LEN(self->lap->irlap) >= LAP_HIGH_THRESHOLD); | 277 | return IRLAP_GET_TX_QUEUE_LEN(self->lap->irlap) >= LAP_HIGH_THRESHOLD; |
278 | } | 278 | } |
279 | 279 | ||
280 | /* After doing a irlmp_dup(), this get one of the two socket back into | 280 | /* After doing a irlmp_dup(), this get one of the two socket back into |
diff --git a/include/net/irda/irttp.h b/include/net/irda/irttp.h index 11aee7a2972a..af4b87721d13 100644 --- a/include/net/irda/irttp.h +++ b/include/net/irda/irttp.h | |||
@@ -204,7 +204,7 @@ static inline int irttp_is_primary(struct tsap_cb *self) | |||
204 | (self->lsap->lap == NULL) || | 204 | (self->lsap->lap == NULL) || |
205 | (self->lsap->lap->irlap == NULL)) | 205 | (self->lsap->lap->irlap == NULL)) |
206 | return -2; | 206 | return -2; |
207 | return(irlap_is_primary(self->lsap->lap->irlap)); | 207 | return irlap_is_primary(self->lsap->lap->irlap); |
208 | } | 208 | } |
209 | 209 | ||
210 | #endif /* IRTTP_H */ | 210 | #endif /* IRTTP_H */ |
diff --git a/include/net/irda/wrapper.h b/include/net/irda/wrapper.h index 2942ad6ab932..eef53ebe3d76 100644 --- a/include/net/irda/wrapper.h +++ b/include/net/irda/wrapper.h | |||
@@ -42,7 +42,7 @@ | |||
42 | 42 | ||
43 | #define IRDA_TRANS 0x20 /* Asynchronous transparency modifier */ | 43 | #define IRDA_TRANS 0x20 /* Asynchronous transparency modifier */ |
44 | 44 | ||
45 | /* States for receving a frame in async mode */ | 45 | /* States for receiving a frame in async mode */ |
46 | enum { | 46 | enum { |
47 | OUTSIDE_FRAME, | 47 | OUTSIDE_FRAME, |
48 | BEGIN_FRAME, | 48 | BEGIN_FRAME, |
diff --git a/include/net/iucv/iucv.h b/include/net/iucv/iucv.h index 205a3360156e..1121baa9f695 100644 --- a/include/net/iucv/iucv.h +++ b/include/net/iucv/iucv.h | |||
@@ -173,7 +173,7 @@ struct iucv_handler { | |||
173 | /* | 173 | /* |
174 | * The message_pending function is called after an icuv interrupt | 174 | * The message_pending function is called after an icuv interrupt |
175 | * type 0x06 or type 0x07 has been received. A new message is | 175 | * type 0x06 or type 0x07 has been received. A new message is |
176 | * availabe and can be received with iucv_message_receive. | 176 | * available and can be received with iucv_message_receive. |
177 | */ | 177 | */ |
178 | void (*message_pending)(struct iucv_path *, struct iucv_message *); | 178 | void (*message_pending)(struct iucv_path *, struct iucv_message *); |
179 | /* | 179 | /* |
diff --git a/include/net/iw_handler.h b/include/net/iw_handler.h index 3afdb21cc31d..5d5a6a4732ef 100644 --- a/include/net/iw_handler.h +++ b/include/net/iw_handler.h | |||
@@ -91,7 +91,7 @@ | |||
91 | * -------------------- | 91 | * -------------------- |
92 | * The implementation goals were as follow : | 92 | * The implementation goals were as follow : |
93 | * o Obvious : you should not need a PhD to understand what's happening, | 93 | * o Obvious : you should not need a PhD to understand what's happening, |
94 | * the benefit is easier maintainance. | 94 | * the benefit is easier maintenance. |
95 | * o Flexible : it should accommodate a wide variety of driver | 95 | * o Flexible : it should accommodate a wide variety of driver |
96 | * implementations and be as flexible as the old API. | 96 | * implementations and be as flexible as the old API. |
97 | * o Lean : it should be efficient memory wise to minimise the impact | 97 | * o Lean : it should be efficient memory wise to minimise the impact |
@@ -129,7 +129,7 @@ | |||
129 | * | 129 | * |
130 | * Functions prototype uses union iwreq_data | 130 | * Functions prototype uses union iwreq_data |
131 | * ----------------------------------------- | 131 | * ----------------------------------------- |
132 | * Some would have prefered functions defined this way : | 132 | * Some would have preferred functions defined this way : |
133 | * static int mydriver_ioctl_setrate(struct net_device *dev, | 133 | * static int mydriver_ioctl_setrate(struct net_device *dev, |
134 | * long rate, int auto) | 134 | * long rate, int auto) |
135 | * 1) The kernel code doesn't "validate" the content of iwreq_data, and | 135 | * 1) The kernel code doesn't "validate" the content of iwreq_data, and |
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h index 75b8e2968c9b..f57e7d46a453 100644 --- a/include/net/llc_pdu.h +++ b/include/net/llc_pdu.h | |||
@@ -199,7 +199,7 @@ struct llc_pdu_sn { | |||
199 | u8 ssap; | 199 | u8 ssap; |
200 | u8 ctrl_1; | 200 | u8 ctrl_1; |
201 | u8 ctrl_2; | 201 | u8 ctrl_2; |
202 | }; | 202 | } __packed; |
203 | 203 | ||
204 | static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb) | 204 | static inline struct llc_pdu_sn *llc_pdu_sn_hdr(struct sk_buff *skb) |
205 | { | 205 | { |
@@ -211,7 +211,7 @@ struct llc_pdu_un { | |||
211 | u8 dsap; | 211 | u8 dsap; |
212 | u8 ssap; | 212 | u8 ssap; |
213 | u8 ctrl_1; | 213 | u8 ctrl_1; |
214 | }; | 214 | } __packed; |
215 | 215 | ||
216 | static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb) | 216 | static inline struct llc_pdu_un *llc_pdu_un_hdr(struct sk_buff *skb) |
217 | { | 217 | { |
@@ -359,7 +359,7 @@ struct llc_xid_info { | |||
359 | u8 fmt_id; /* always 0x81 for LLC */ | 359 | u8 fmt_id; /* always 0x81 for LLC */ |
360 | u8 type; /* different if NULL/non-NULL LSAP */ | 360 | u8 type; /* different if NULL/non-NULL LSAP */ |
361 | u8 rw; /* sender receive window */ | 361 | u8 rw; /* sender receive window */ |
362 | }; | 362 | } __packed; |
363 | 363 | ||
364 | /** | 364 | /** |
365 | * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID | 365 | * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID |
@@ -415,7 +415,7 @@ struct llc_frmr_info { | |||
415 | u8 curr_ssv; /* current send state variable val */ | 415 | u8 curr_ssv; /* current send state variable val */ |
416 | u8 curr_rsv; /* current receive state variable */ | 416 | u8 curr_rsv; /* current receive state variable */ |
417 | u8 ind_bits; /* indicator bits set with macro */ | 417 | u8 ind_bits; /* indicator bits set with macro */ |
418 | }; | 418 | } __packed; |
419 | 419 | ||
420 | extern void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type); | 420 | extern void llc_pdu_set_cmd_rsp(struct sk_buff *skb, u8 type); |
421 | extern void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value); | 421 | extern void llc_pdu_set_pf_bit(struct sk_buff *skb, u8 bit_value); |
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index b0787a1dea90..e6d6a66a8f71 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -97,6 +97,20 @@ enum ieee80211_max_queues { | |||
97 | }; | 97 | }; |
98 | 98 | ||
99 | /** | 99 | /** |
100 | * enum ieee80211_ac_numbers - AC numbers as used in mac80211 | ||
101 | * @IEEE80211_AC_VO: voice | ||
102 | * @IEEE80211_AC_VI: video | ||
103 | * @IEEE80211_AC_BE: best effort | ||
104 | * @IEEE80211_AC_BK: background | ||
105 | */ | ||
106 | enum ieee80211_ac_numbers { | ||
107 | IEEE80211_AC_VO = 0, | ||
108 | IEEE80211_AC_VI = 1, | ||
109 | IEEE80211_AC_BE = 2, | ||
110 | IEEE80211_AC_BK = 3, | ||
111 | }; | ||
112 | |||
113 | /** | ||
100 | * struct ieee80211_tx_queue_params - transmit queue configuration | 114 | * struct ieee80211_tx_queue_params - transmit queue configuration |
101 | * | 115 | * |
102 | * The information provided in this structure is required for QoS | 116 | * The information provided in this structure is required for QoS |
@@ -149,6 +163,7 @@ struct ieee80211_low_level_stats { | |||
149 | * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed. | 163 | * @BSS_CHANGED_ARP_FILTER: Hardware ARP filter address list or state changed. |
150 | * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note | 164 | * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note |
151 | * that it is only ever disabled for station mode. | 165 | * that it is only ever disabled for station mode. |
166 | * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. | ||
152 | */ | 167 | */ |
153 | enum ieee80211_bss_change { | 168 | enum ieee80211_bss_change { |
154 | BSS_CHANGED_ASSOC = 1<<0, | 169 | BSS_CHANGED_ASSOC = 1<<0, |
@@ -165,6 +180,7 @@ enum ieee80211_bss_change { | |||
165 | BSS_CHANGED_IBSS = 1<<11, | 180 | BSS_CHANGED_IBSS = 1<<11, |
166 | BSS_CHANGED_ARP_FILTER = 1<<12, | 181 | BSS_CHANGED_ARP_FILTER = 1<<12, |
167 | BSS_CHANGED_QOS = 1<<13, | 182 | BSS_CHANGED_QOS = 1<<13, |
183 | BSS_CHANGED_IDLE = 1<<14, | ||
168 | 184 | ||
169 | /* when adding here, make sure to change ieee80211_reconfig */ | 185 | /* when adding here, make sure to change ieee80211_reconfig */ |
170 | }; | 186 | }; |
@@ -203,6 +219,7 @@ enum ieee80211_bss_change { | |||
203 | * @basic_rates: bitmap of basic rates, each bit stands for an | 219 | * @basic_rates: bitmap of basic rates, each bit stands for an |
204 | * index into the rate table configured by the driver in | 220 | * index into the rate table configured by the driver in |
205 | * the current band. | 221 | * the current band. |
222 | * @mcast_rate: per-band multicast rate index + 1 (0: disabled) | ||
206 | * @bssid: The BSSID for this BSS | 223 | * @bssid: The BSSID for this BSS |
207 | * @enable_beacon: whether beaconing should be enabled or not | 224 | * @enable_beacon: whether beaconing should be enabled or not |
208 | * @channel_type: Channel type for this BSS -- the hardware might be | 225 | * @channel_type: Channel type for this BSS -- the hardware might be |
@@ -223,6 +240,9 @@ enum ieee80211_bss_change { | |||
223 | * hardware must not perform any ARP filtering. Note, that the filter will | 240 | * hardware must not perform any ARP filtering. Note, that the filter will |
224 | * be enabled also in promiscuous mode. | 241 | * be enabled also in promiscuous mode. |
225 | * @qos: This is a QoS-enabled BSS. | 242 | * @qos: This is a QoS-enabled BSS. |
243 | * @idle: This interface is idle. There's also a global idle flag in the | ||
244 | * hardware config which may be more appropriate depending on what | ||
245 | * your driver/device needs to do. | ||
226 | */ | 246 | */ |
227 | struct ieee80211_bss_conf { | 247 | struct ieee80211_bss_conf { |
228 | const u8 *bssid; | 248 | const u8 *bssid; |
@@ -239,6 +259,7 @@ struct ieee80211_bss_conf { | |||
239 | u16 assoc_capability; | 259 | u16 assoc_capability; |
240 | u64 timestamp; | 260 | u64 timestamp; |
241 | u32 basic_rates; | 261 | u32 basic_rates; |
262 | int mcast_rate[IEEE80211_NUM_BANDS]; | ||
242 | u16 ht_operation_mode; | 263 | u16 ht_operation_mode; |
243 | s32 cqm_rssi_thold; | 264 | s32 cqm_rssi_thold; |
244 | u32 cqm_rssi_hyst; | 265 | u32 cqm_rssi_hyst; |
@@ -247,6 +268,7 @@ struct ieee80211_bss_conf { | |||
247 | u8 arp_addr_cnt; | 268 | u8 arp_addr_cnt; |
248 | bool arp_filter_enabled; | 269 | bool arp_filter_enabled; |
249 | bool qos; | 270 | bool qos; |
271 | bool idle; | ||
250 | }; | 272 | }; |
251 | 273 | ||
252 | /** | 274 | /** |
@@ -315,6 +337,16 @@ struct ieee80211_bss_conf { | |||
315 | * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame | 337 | * @IEEE80211_TX_CTL_LDPC: tells the driver to use LDPC for this frame |
316 | * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this | 338 | * @IEEE80211_TX_CTL_STBC: Enables Space-Time Block Coding (STBC) for this |
317 | * frame and selects the maximum number of streams that it can use. | 339 | * frame and selects the maximum number of streams that it can use. |
340 | * @IEEE80211_TX_CTL_TX_OFFCHAN: Marks this packet to be transmitted on | ||
341 | * the off-channel channel when a remain-on-channel offload is done | ||
342 | * in hardware -- normal packets still flow and are expected to be | ||
343 | * handled properly by the device. | ||
344 | * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP | ||
345 | * testing. It will be sent out with incorrect Michael MIC key to allow | ||
346 | * TKIP countermeasures to be tested. | ||
347 | * | ||
348 | * Note: If you have to add new flags to the enumeration, then don't | ||
349 | * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary. | ||
318 | */ | 350 | */ |
319 | enum mac80211_tx_control_flags { | 351 | enum mac80211_tx_control_flags { |
320 | IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0), | 352 | IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0), |
@@ -340,10 +372,25 @@ enum mac80211_tx_control_flags { | |||
340 | IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21), | 372 | IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21), |
341 | IEEE80211_TX_CTL_LDPC = BIT(22), | 373 | IEEE80211_TX_CTL_LDPC = BIT(22), |
342 | IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24), | 374 | IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24), |
375 | IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25), | ||
376 | IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26), | ||
343 | }; | 377 | }; |
344 | 378 | ||
345 | #define IEEE80211_TX_CTL_STBC_SHIFT 23 | 379 | #define IEEE80211_TX_CTL_STBC_SHIFT 23 |
346 | 380 | ||
381 | /* | ||
382 | * This definition is used as a mask to clear all temporary flags, which are | ||
383 | * set by the tx handlers for each transmission attempt by the mac80211 stack. | ||
384 | */ | ||
385 | #define IEEE80211_TX_TEMPORARY_FLAGS (IEEE80211_TX_CTL_NO_ACK | \ | ||
386 | IEEE80211_TX_CTL_CLEAR_PS_FILT | IEEE80211_TX_CTL_FIRST_FRAGMENT | \ | ||
387 | IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \ | ||
388 | IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \ | ||
389 | IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \ | ||
390 | IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_PSPOLL_RESPONSE | \ | ||
391 | IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \ | ||
392 | IEEE80211_TX_CTL_STBC) | ||
393 | |||
347 | /** | 394 | /** |
348 | * enum mac80211_rate_control_flags - per-rate flags set by the | 395 | * enum mac80211_rate_control_flags - per-rate flags set by the |
349 | * Rate Control algorithm. | 396 | * Rate Control algorithm. |
@@ -490,6 +537,21 @@ struct ieee80211_tx_info { | |||
490 | }; | 537 | }; |
491 | }; | 538 | }; |
492 | 539 | ||
540 | /** | ||
541 | * struct ieee80211_sched_scan_ies - scheduled scan IEs | ||
542 | * | ||
543 | * This structure is used to pass the appropriate IEs to be used in scheduled | ||
544 | * scans for all bands. It contains both the IEs passed from the userspace | ||
545 | * and the ones generated by mac80211. | ||
546 | * | ||
547 | * @ie: array with the IEs for each supported band | ||
548 | * @len: array with the total length of the IEs for each band | ||
549 | */ | ||
550 | struct ieee80211_sched_scan_ies { | ||
551 | u8 *ie[IEEE80211_NUM_BANDS]; | ||
552 | size_t len[IEEE80211_NUM_BANDS]; | ||
553 | }; | ||
554 | |||
493 | static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb) | 555 | static inline struct ieee80211_tx_info *IEEE80211_SKB_CB(struct sk_buff *skb) |
494 | { | 556 | { |
495 | return (struct ieee80211_tx_info *)skb->cb; | 557 | return (struct ieee80211_tx_info *)skb->cb; |
@@ -552,16 +614,14 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) | |||
552 | * the frame. | 614 | * the frame. |
553 | * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on | 615 | * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on |
554 | * the frame. | 616 | * the frame. |
555 | * @RX_FLAG_TSFT: The timestamp passed in the RX status (@mactime field) | 617 | * @RX_FLAG_MACTIME_MPDU: The timestamp passed in the RX status (@mactime |
556 | * is valid. This is useful in monitor mode and necessary for beacon frames | 618 | * field) is valid and contains the time the first symbol of the MPDU |
557 | * to enable IBSS merging. | 619 | * was received. This is useful in monitor mode and for proper IBSS |
620 | * merging. | ||
558 | * @RX_FLAG_SHORTPRE: Short preamble was used for this frame | 621 | * @RX_FLAG_SHORTPRE: Short preamble was used for this frame |
559 | * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index | 622 | * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index |
560 | * @RX_FLAG_40MHZ: HT40 (40 MHz) was used | 623 | * @RX_FLAG_40MHZ: HT40 (40 MHz) was used |
561 | * @RX_FLAG_SHORT_GI: Short guard interval was used | 624 | * @RX_FLAG_SHORT_GI: Short guard interval was used |
562 | * @RX_FLAG_INTERNAL_CMTR: set internally after frame was reported | ||
563 | * on cooked monitor to avoid double-reporting it for multiple | ||
564 | * virtual interfaces | ||
565 | */ | 625 | */ |
566 | enum mac80211_rx_flags { | 626 | enum mac80211_rx_flags { |
567 | RX_FLAG_MMIC_ERROR = 1<<0, | 627 | RX_FLAG_MMIC_ERROR = 1<<0, |
@@ -570,12 +630,11 @@ enum mac80211_rx_flags { | |||
570 | RX_FLAG_IV_STRIPPED = 1<<4, | 630 | RX_FLAG_IV_STRIPPED = 1<<4, |
571 | RX_FLAG_FAILED_FCS_CRC = 1<<5, | 631 | RX_FLAG_FAILED_FCS_CRC = 1<<5, |
572 | RX_FLAG_FAILED_PLCP_CRC = 1<<6, | 632 | RX_FLAG_FAILED_PLCP_CRC = 1<<6, |
573 | RX_FLAG_TSFT = 1<<7, | 633 | RX_FLAG_MACTIME_MPDU = 1<<7, |
574 | RX_FLAG_SHORTPRE = 1<<8, | 634 | RX_FLAG_SHORTPRE = 1<<8, |
575 | RX_FLAG_HT = 1<<9, | 635 | RX_FLAG_HT = 1<<9, |
576 | RX_FLAG_40MHZ = 1<<10, | 636 | RX_FLAG_40MHZ = 1<<10, |
577 | RX_FLAG_SHORT_GI = 1<<11, | 637 | RX_FLAG_SHORT_GI = 1<<11, |
578 | RX_FLAG_INTERNAL_CMTR = 1<<12, | ||
579 | }; | 638 | }; |
580 | 639 | ||
581 | /** | 640 | /** |
@@ -596,6 +655,7 @@ enum mac80211_rx_flags { | |||
596 | * @rate_idx: index of data rate into band's supported rates or MCS index if | 655 | * @rate_idx: index of data rate into band's supported rates or MCS index if |
597 | * HT rates are use (RX_FLAG_HT) | 656 | * HT rates are use (RX_FLAG_HT) |
598 | * @flag: %RX_FLAG_* | 657 | * @flag: %RX_FLAG_* |
658 | * @rx_flags: internal RX flags for mac80211 | ||
599 | */ | 659 | */ |
600 | struct ieee80211_rx_status { | 660 | struct ieee80211_rx_status { |
601 | u64 mactime; | 661 | u64 mactime; |
@@ -605,6 +665,7 @@ struct ieee80211_rx_status { | |||
605 | int antenna; | 665 | int antenna; |
606 | int rate_idx; | 666 | int rate_idx; |
607 | int flag; | 667 | int flag; |
668 | unsigned int rx_flags; | ||
608 | }; | 669 | }; |
609 | 670 | ||
610 | /** | 671 | /** |
@@ -763,6 +824,8 @@ struct ieee80211_channel_switch { | |||
763 | * @bss_conf: BSS configuration for this interface, either our own | 824 | * @bss_conf: BSS configuration for this interface, either our own |
764 | * or the BSS we're associated to | 825 | * or the BSS we're associated to |
765 | * @addr: address of this interface | 826 | * @addr: address of this interface |
827 | * @p2p: indicates whether this AP or STA interface is a p2p | ||
828 | * interface, i.e. a GO or p2p-sta respectively | ||
766 | * @drv_priv: data area for driver use, will always be aligned to | 829 | * @drv_priv: data area for driver use, will always be aligned to |
767 | * sizeof(void *). | 830 | * sizeof(void *). |
768 | */ | 831 | */ |
@@ -770,6 +833,7 @@ struct ieee80211_vif { | |||
770 | enum nl80211_iftype type; | 833 | enum nl80211_iftype type; |
771 | struct ieee80211_bss_conf bss_conf; | 834 | struct ieee80211_bss_conf bss_conf; |
772 | u8 addr[ETH_ALEN]; | 835 | u8 addr[ETH_ALEN]; |
836 | bool p2p; | ||
773 | /* must be last */ | 837 | /* must be last */ |
774 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); | 838 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); |
775 | }; | 839 | }; |
@@ -783,20 +847,6 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) | |||
783 | } | 847 | } |
784 | 848 | ||
785 | /** | 849 | /** |
786 | * enum ieee80211_key_alg - key algorithm | ||
787 | * @ALG_WEP: WEP40 or WEP104 | ||
788 | * @ALG_TKIP: TKIP | ||
789 | * @ALG_CCMP: CCMP (AES) | ||
790 | * @ALG_AES_CMAC: AES-128-CMAC | ||
791 | */ | ||
792 | enum ieee80211_key_alg { | ||
793 | ALG_WEP, | ||
794 | ALG_TKIP, | ||
795 | ALG_CCMP, | ||
796 | ALG_AES_CMAC, | ||
797 | }; | ||
798 | |||
799 | /** | ||
800 | * enum ieee80211_key_flags - key flags | 850 | * enum ieee80211_key_flags - key flags |
801 | * | 851 | * |
802 | * These flags are used for communication about keys between the driver | 852 | * These flags are used for communication about keys between the driver |
@@ -833,7 +883,7 @@ enum ieee80211_key_flags { | |||
833 | * @hw_key_idx: To be set by the driver, this is the key index the driver | 883 | * @hw_key_idx: To be set by the driver, this is the key index the driver |
834 | * wants to be given when a frame is transmitted and needs to be | 884 | * wants to be given when a frame is transmitted and needs to be |
835 | * encrypted in hardware. | 885 | * encrypted in hardware. |
836 | * @alg: The key algorithm. | 886 | * @cipher: The key's cipher suite selector. |
837 | * @flags: key flags, see &enum ieee80211_key_flags. | 887 | * @flags: key flags, see &enum ieee80211_key_flags. |
838 | * @keyidx: the key index (0-3) | 888 | * @keyidx: the key index (0-3) |
839 | * @keylen: key material length | 889 | * @keylen: key material length |
@@ -846,7 +896,7 @@ enum ieee80211_key_flags { | |||
846 | * @iv_len: The IV length for this key type | 896 | * @iv_len: The IV length for this key type |
847 | */ | 897 | */ |
848 | struct ieee80211_key_conf { | 898 | struct ieee80211_key_conf { |
849 | enum ieee80211_key_alg alg; | 899 | u32 cipher; |
850 | u8 icv_len; | 900 | u8 icv_len; |
851 | u8 iv_len; | 901 | u8 iv_len; |
852 | u8 hw_key_idx; | 902 | u8 hw_key_idx; |
@@ -1032,6 +1082,20 @@ enum ieee80211_tkip_key_type { | |||
1032 | * @IEEE80211_HW_NEED_DTIM_PERIOD: | 1082 | * @IEEE80211_HW_NEED_DTIM_PERIOD: |
1033 | * This device needs to know the DTIM period for the BSS before | 1083 | * This device needs to know the DTIM period for the BSS before |
1034 | * associating. | 1084 | * associating. |
1085 | * | ||
1086 | * @IEEE80211_HW_SUPPORTS_PER_STA_GTK: The device's crypto engine supports | ||
1087 | * per-station GTKs as used by IBSS RSN or during fast transition. If | ||
1088 | * the device doesn't support per-station GTKs, but can be asked not | ||
1089 | * to decrypt group addressed frames, then IBSS RSN support is still | ||
1090 | * possible but software crypto will be used. Advertise the wiphy flag | ||
1091 | * only in that case. | ||
1092 | * | ||
1093 | * @IEEE80211_HW_AP_LINK_PS: When operating in AP mode the device | ||
1094 | * autonomously manages the PS status of connected stations. When | ||
1095 | * this flag is set mac80211 will not trigger PS mode for connected | ||
1096 | * stations based on the PM bit of incoming frames. | ||
1097 | * Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure | ||
1098 | * the PS mode of connected stations. | ||
1035 | */ | 1099 | */ |
1036 | enum ieee80211_hw_flags { | 1100 | enum ieee80211_hw_flags { |
1037 | IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, | 1101 | IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, |
@@ -1055,6 +1119,8 @@ enum ieee80211_hw_flags { | |||
1055 | IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, | 1119 | IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, |
1056 | IEEE80211_HW_CONNECTION_MONITOR = 1<<19, | 1120 | IEEE80211_HW_CONNECTION_MONITOR = 1<<19, |
1057 | IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20, | 1121 | IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20, |
1122 | IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, | ||
1123 | IEEE80211_HW_AP_LINK_PS = 1<<22, | ||
1058 | }; | 1124 | }; |
1059 | 1125 | ||
1060 | /** | 1126 | /** |
@@ -1100,8 +1166,26 @@ enum ieee80211_hw_flags { | |||
1100 | * @sta_data_size: size (in bytes) of the drv_priv data area | 1166 | * @sta_data_size: size (in bytes) of the drv_priv data area |
1101 | * within &struct ieee80211_sta. | 1167 | * within &struct ieee80211_sta. |
1102 | * | 1168 | * |
1103 | * @max_rates: maximum number of alternate rate retry stages | 1169 | * @max_rates: maximum number of alternate rate retry stages the hw |
1170 | * can handle. | ||
1171 | * @max_report_rates: maximum number of alternate rate retry stages | ||
1172 | * the hw can report back. | ||
1104 | * @max_rate_tries: maximum number of tries for each stage | 1173 | * @max_rate_tries: maximum number of tries for each stage |
1174 | * | ||
1175 | * @napi_weight: weight used for NAPI polling. You must specify an | ||
1176 | * appropriate value here if a napi_poll operation is provided | ||
1177 | * by your driver. | ||
1178 | * | ||
1179 | * @max_rx_aggregation_subframes: maximum buffer size (number of | ||
1180 | * sub-frames) to be used for A-MPDU block ack receiver | ||
1181 | * aggregation. | ||
1182 | * This is only relevant if the device has restrictions on the | ||
1183 | * number of subframes, if it relies on mac80211 to do reordering | ||
1184 | * it shouldn't be set. | ||
1185 | * | ||
1186 | * @max_tx_aggregation_subframes: maximum number of subframes in an | ||
1187 | * aggregate an HT driver will transmit, used by the peer as a | ||
1188 | * hint to size its reorder buffer. | ||
1105 | */ | 1189 | */ |
1106 | struct ieee80211_hw { | 1190 | struct ieee80211_hw { |
1107 | struct ieee80211_conf conf; | 1191 | struct ieee80211_conf conf; |
@@ -1113,11 +1197,15 @@ struct ieee80211_hw { | |||
1113 | int channel_change_time; | 1197 | int channel_change_time; |
1114 | int vif_data_size; | 1198 | int vif_data_size; |
1115 | int sta_data_size; | 1199 | int sta_data_size; |
1200 | int napi_weight; | ||
1116 | u16 queues; | 1201 | u16 queues; |
1117 | u16 max_listen_interval; | 1202 | u16 max_listen_interval; |
1118 | s8 max_signal; | 1203 | s8 max_signal; |
1119 | u8 max_rates; | 1204 | u8 max_rates; |
1205 | u8 max_report_rates; | ||
1120 | u8 max_rate_tries; | 1206 | u8 max_rate_tries; |
1207 | u8 max_rx_aggregation_subframes; | ||
1208 | u8 max_tx_aggregation_subframes; | ||
1121 | }; | 1209 | }; |
1122 | 1210 | ||
1123 | /** | 1211 | /** |
@@ -1221,7 +1309,7 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, | |||
1221 | * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key | 1309 | * acceleration (i.e. iwlwifi). Those drivers should provide update_tkip_key |
1222 | * handler. | 1310 | * handler. |
1223 | * The update_tkip_key() call updates the driver with the new phase 1 key. | 1311 | * The update_tkip_key() call updates the driver with the new phase 1 key. |
1224 | * This happens everytime the iv16 wraps around (every 65536 packets). The | 1312 | * This happens every time the iv16 wraps around (every 65536 packets). The |
1225 | * set_key() call will happen only once for each key (unless the AP did | 1313 | * set_key() call will happen only once for each key (unless the AP did |
1226 | * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is | 1314 | * rekeying), it will not include a valid phase 1 key. The valid phase 1 key is |
1227 | * provided by update_tkip_key only. The trigger that makes mac80211 call this | 1315 | * provided by update_tkip_key only. The trigger that makes mac80211 call this |
@@ -1245,8 +1333,8 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, | |||
1245 | * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in | 1333 | * %IEEE80211_CONF_PS flag enabled means that the powersave mode defined in |
1246 | * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused | 1334 | * IEEE 802.11-2007 section 11.2 is enabled. This is not to be confused |
1247 | * with hardware wakeup and sleep states. Driver is responsible for waking | 1335 | * with hardware wakeup and sleep states. Driver is responsible for waking |
1248 | * up the hardware before issueing commands to the hardware and putting it | 1336 | * up the hardware before issuing commands to the hardware and putting it |
1249 | * back to sleep at approriate times. | 1337 | * back to sleep at appropriate times. |
1250 | * | 1338 | * |
1251 | * When PS is enabled, hardware needs to wakeup for beacons and receive the | 1339 | * When PS is enabled, hardware needs to wakeup for beacons and receive the |
1252 | * buffered multicast/broadcast frames after the beacon. Also it must be | 1340 | * buffered multicast/broadcast frames after the beacon. Also it must be |
@@ -1267,7 +1355,7 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, | |||
1267 | * there's data traffic and still saving significantly power in idle | 1355 | * there's data traffic and still saving significantly power in idle |
1268 | * periods. | 1356 | * periods. |
1269 | * | 1357 | * |
1270 | * Dynamic powersave is supported by simply mac80211 enabling and disabling | 1358 | * Dynamic powersave is simply supported by mac80211 enabling and disabling |
1271 | * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS | 1359 | * PS based on traffic. Driver needs to only set %IEEE80211_HW_SUPPORTS_PS |
1272 | * flag and mac80211 will handle everything automatically. Additionally, | 1360 | * flag and mac80211 will handle everything automatically. Additionally, |
1273 | * hardware having support for the dynamic PS feature may set the | 1361 | * hardware having support for the dynamic PS feature may set the |
@@ -1452,12 +1540,14 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, | |||
1452 | * honour this flag if possible. | 1540 | * honour this flag if possible. |
1453 | * | 1541 | * |
1454 | * @FIF_CONTROL: pass control frames (except for PS Poll), if PROMISC_IN_BSS | 1542 | * @FIF_CONTROL: pass control frames (except for PS Poll), if PROMISC_IN_BSS |
1455 | * is not set then only those addressed to this station. | 1543 | * is not set then only those addressed to this station. |
1456 | * | 1544 | * |
1457 | * @FIF_OTHER_BSS: pass frames destined to other BSSes | 1545 | * @FIF_OTHER_BSS: pass frames destined to other BSSes |
1458 | * | 1546 | * |
1459 | * @FIF_PSPOLL: pass PS Poll frames, if PROMISC_IN_BSS is not set then only | 1547 | * @FIF_PSPOLL: pass PS Poll frames, if PROMISC_IN_BSS is not set then only |
1460 | * those addressed to this station. | 1548 | * those addressed to this station. |
1549 | * | ||
1550 | * @FIF_PROBE_REQ: pass probe request frames | ||
1461 | */ | 1551 | */ |
1462 | enum ieee80211_filter_flags { | 1552 | enum ieee80211_filter_flags { |
1463 | FIF_PROMISC_IN_BSS = 1<<0, | 1553 | FIF_PROMISC_IN_BSS = 1<<0, |
@@ -1468,6 +1558,7 @@ enum ieee80211_filter_flags { | |||
1468 | FIF_CONTROL = 1<<5, | 1558 | FIF_CONTROL = 1<<5, |
1469 | FIF_OTHER_BSS = 1<<6, | 1559 | FIF_OTHER_BSS = 1<<6, |
1470 | FIF_PSPOLL = 1<<7, | 1560 | FIF_PSPOLL = 1<<7, |
1561 | FIF_PROBE_REQ = 1<<8, | ||
1471 | }; | 1562 | }; |
1472 | 1563 | ||
1473 | /** | 1564 | /** |
@@ -1530,6 +1621,18 @@ enum ieee80211_ampdu_mlme_action { | |||
1530 | * you should ensure to cancel it on this callback. | 1621 | * you should ensure to cancel it on this callback. |
1531 | * Must be implemented and can sleep. | 1622 | * Must be implemented and can sleep. |
1532 | * | 1623 | * |
1624 | * @suspend: Suspend the device; mac80211 itself will quiesce before and | ||
1625 | * stop transmitting and doing any other configuration, and then | ||
1626 | * ask the device to suspend. This is only invoked when WoWLAN is | ||
1627 | * configured, otherwise the device is deconfigured completely and | ||
1628 | * reconfigured at resume time. | ||
1629 | * | ||
1630 | * @resume: If WoWLAN was configured, this indicates that mac80211 is | ||
1631 | * now resuming its operation, after this the device must be fully | ||
1632 | * functional again. If this returns an error, the only way out is | ||
1633 | * to also unregister the device. If it returns 1, then mac80211 | ||
1634 | * will also go through the regular complete restart on resume. | ||
1635 | * | ||
1533 | * @add_interface: Called when a netdevice attached to the hardware is | 1636 | * @add_interface: Called when a netdevice attached to the hardware is |
1534 | * enabled. Because it is not called for monitor mode devices, @start | 1637 | * enabled. Because it is not called for monitor mode devices, @start |
1535 | * and @stop must be implemented. | 1638 | * and @stop must be implemented. |
@@ -1540,6 +1643,12 @@ enum ieee80211_ampdu_mlme_action { | |||
1540 | * negative error code (which will be seen in userspace.) | 1643 | * negative error code (which will be seen in userspace.) |
1541 | * Must be implemented and can sleep. | 1644 | * Must be implemented and can sleep. |
1542 | * | 1645 | * |
1646 | * @change_interface: Called when a netdevice changes type. This callback | ||
1647 | * is optional, but only if it is supported can interface types be | ||
1648 | * switched while the interface is UP. The callback may sleep. | ||
1649 | * Note that while an interface is being switched, it will not be | ||
1650 | * found by the interface iteration callbacks. | ||
1651 | * | ||
1543 | * @remove_interface: Notifies a driver that an interface is going down. | 1652 | * @remove_interface: Notifies a driver that an interface is going down. |
1544 | * The @stop callback is called after this if it is the last interface | 1653 | * The @stop callback is called after this if it is the last interface |
1545 | * and no monitor interfaces are present. | 1654 | * and no monitor interfaces are present. |
@@ -1599,6 +1708,13 @@ enum ieee80211_ampdu_mlme_action { | |||
1599 | * any error unless this callback returned a negative error code. | 1708 | * any error unless this callback returned a negative error code. |
1600 | * The callback can sleep. | 1709 | * The callback can sleep. |
1601 | * | 1710 | * |
1711 | * @sched_scan_start: Ask the hardware to start scanning repeatedly at | ||
1712 | * specific intervals. The driver must call the | ||
1713 | * ieee80211_sched_scan_results() function whenever it finds results. | ||
1714 | * This process will continue until sched_scan_stop is called. | ||
1715 | * | ||
1716 | * @sched_scan_stop: Tell the hardware to stop an ongoing scheduled scan. | ||
1717 | * | ||
1602 | * @sw_scan_start: Notifier function that is called just before a software scan | 1718 | * @sw_scan_start: Notifier function that is called just before a software scan |
1603 | * is started. Can be NULL, if the driver doesn't need this notification. | 1719 | * is started. Can be NULL, if the driver doesn't need this notification. |
1604 | * The callback can sleep. | 1720 | * The callback can sleep. |
@@ -1617,6 +1733,11 @@ enum ieee80211_ampdu_mlme_action { | |||
1617 | * and IV16) for the given key from hardware. | 1733 | * and IV16) for the given key from hardware. |
1618 | * The callback must be atomic. | 1734 | * The callback must be atomic. |
1619 | * | 1735 | * |
1736 | * @set_frag_threshold: Configuration of fragmentation threshold. Assign this | ||
1737 | * if the device does fragmentation by itself; if this callback is | ||
1738 | * implemented then the stack will not do fragmentation. | ||
1739 | * The callback can sleep. | ||
1740 | * | ||
1620 | * @set_rts_threshold: Configuration of RTS threshold (if device needs it) | 1741 | * @set_rts_threshold: Configuration of RTS threshold (if device needs it) |
1621 | * The callback can sleep. | 1742 | * The callback can sleep. |
1622 | * | 1743 | * |
@@ -1627,7 +1748,9 @@ enum ieee80211_ampdu_mlme_action { | |||
1627 | * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep. | 1748 | * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep. |
1628 | * | 1749 | * |
1629 | * @sta_notify: Notifies low level driver about power state transition of an | 1750 | * @sta_notify: Notifies low level driver about power state transition of an |
1630 | * associated station, AP, IBSS/WDS/mesh peer etc. Must be atomic. | 1751 | * associated station, AP, IBSS/WDS/mesh peer etc. For a VIF operating |
1752 | * in AP mode, this callback will not be called when the flag | ||
1753 | * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic. | ||
1631 | * | 1754 | * |
1632 | * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), | 1755 | * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), |
1633 | * bursting) for a hardware TX queue. | 1756 | * bursting) for a hardware TX queue. |
@@ -1662,6 +1785,21 @@ enum ieee80211_ampdu_mlme_action { | |||
1662 | * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn) | 1785 | * ieee80211_ampdu_mlme_action. Starting sequence number (@ssn) |
1663 | * is the first frame we expect to perform the action on. Notice | 1786 | * is the first frame we expect to perform the action on. Notice |
1664 | * that TX/RX_STOP can pass NULL for this parameter. | 1787 | * that TX/RX_STOP can pass NULL for this parameter. |
1788 | * The @buf_size parameter is only valid when the action is set to | ||
1789 | * %IEEE80211_AMPDU_TX_OPERATIONAL and indicates the peer's reorder | ||
1790 | * buffer size (number of subframes) for this session -- the driver | ||
1791 | * may neither send aggregates containing more subframes than this | ||
1792 | * nor send aggregates in a way that lost frames would exceed the | ||
1793 | * buffer size. If just limiting the aggregate size, this would be | ||
1794 | * possible with a buf_size of 8: | ||
1795 | * - TX: 1.....7 | ||
1796 | * - RX: 2....7 (lost frame #1) | ||
1797 | * - TX: 8..1... | ||
1798 | * which is invalid since #1 was now re-transmitted well past the | ||
1799 | * buffer size of 8. Correct ways to retransmit #1 would be: | ||
1800 | * - TX: 1 or 18 or 81 | ||
1801 | * Even "189" would be wrong since 1 could be lost again. | ||
1802 | * | ||
1665 | * Returns a negative error code on failure. | 1803 | * Returns a negative error code on failure. |
1666 | * The callback can sleep. | 1804 | * The callback can sleep. |
1667 | * | 1805 | * |
@@ -1687,13 +1825,55 @@ enum ieee80211_ampdu_mlme_action { | |||
1687 | * switch operation for CSAs received from the AP may implement this | 1825 | * switch operation for CSAs received from the AP may implement this |
1688 | * callback. They must then call ieee80211_chswitch_done() to indicate | 1826 | * callback. They must then call ieee80211_chswitch_done() to indicate |
1689 | * completion of the channel switch. | 1827 | * completion of the channel switch. |
1828 | * | ||
1829 | * @napi_poll: Poll Rx queue for incoming data frames. | ||
1830 | * | ||
1831 | * @set_antenna: Set antenna configuration (tx_ant, rx_ant) on the device. | ||
1832 | * Parameters are bitmaps of allowed antennas to use for TX/RX. Drivers may | ||
1833 | * reject TX/RX mask combinations they cannot support by returning -EINVAL | ||
1834 | * (also see nl80211.h @NL80211_ATTR_WIPHY_ANTENNA_TX). | ||
1835 | * | ||
1836 | * @get_antenna: Get current antenna configuration from device (tx_ant, rx_ant). | ||
1837 | * | ||
1838 | * @remain_on_channel: Starts an off-channel period on the given channel, must | ||
1839 | * call back to ieee80211_ready_on_channel() when on that channel. Note | ||
1840 | * that normal channel traffic is not stopped as this is intended for hw | ||
1841 | * offload. Frames to transmit on the off-channel channel are transmitted | ||
1842 | * normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the | ||
1843 | * duration (which will always be non-zero) expires, the driver must call | ||
1844 | * ieee80211_remain_on_channel_expired(). This callback may sleep. | ||
1845 | * @cancel_remain_on_channel: Requests that an ongoing off-channel period is | ||
1846 | * aborted before it expires. This callback may sleep. | ||
1847 | * @offchannel_tx: Transmit frame on another channel, wait for a response | ||
1848 | * and return. Reliable TX status must be reported for the frame. If the | ||
1849 | * return value is 1, then the @remain_on_channel will be used with a | ||
1850 | * regular transmission (if supported.) | ||
1851 | * @offchannel_tx_cancel_wait: cancel wait associated with offchannel TX | ||
1852 | * | ||
1853 | * @set_ringparam: Set tx and rx ring sizes. | ||
1854 | * | ||
1855 | * @get_ringparam: Get tx and rx ring current and maximum sizes. | ||
1856 | * | ||
1857 | * @tx_frames_pending: Check if there is any pending frame in the hardware | ||
1858 | * queues before entering power save. | ||
1859 | * | ||
1860 | * @set_bitrate_mask: Set a mask of rates to be used for rate control selection | ||
1861 | * when transmitting a frame. Currently only legacy rates are handled. | ||
1862 | * The callback can sleep. | ||
1690 | */ | 1863 | */ |
1691 | struct ieee80211_ops { | 1864 | struct ieee80211_ops { |
1692 | int (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); | 1865 | void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); |
1693 | int (*start)(struct ieee80211_hw *hw); | 1866 | int (*start)(struct ieee80211_hw *hw); |
1694 | void (*stop)(struct ieee80211_hw *hw); | 1867 | void (*stop)(struct ieee80211_hw *hw); |
1868 | #ifdef CONFIG_PM | ||
1869 | int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); | ||
1870 | int (*resume)(struct ieee80211_hw *hw); | ||
1871 | #endif | ||
1695 | int (*add_interface)(struct ieee80211_hw *hw, | 1872 | int (*add_interface)(struct ieee80211_hw *hw, |
1696 | struct ieee80211_vif *vif); | 1873 | struct ieee80211_vif *vif); |
1874 | int (*change_interface)(struct ieee80211_hw *hw, | ||
1875 | struct ieee80211_vif *vif, | ||
1876 | enum nl80211_iftype new_type, bool p2p); | ||
1697 | void (*remove_interface)(struct ieee80211_hw *hw, | 1877 | void (*remove_interface)(struct ieee80211_hw *hw, |
1698 | struct ieee80211_vif *vif); | 1878 | struct ieee80211_vif *vif); |
1699 | int (*config)(struct ieee80211_hw *hw, u32 changed); | 1879 | int (*config)(struct ieee80211_hw *hw, u32 changed); |
@@ -1719,12 +1899,19 @@ struct ieee80211_ops { | |||
1719 | u32 iv32, u16 *phase1key); | 1899 | u32 iv32, u16 *phase1key); |
1720 | int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1900 | int (*hw_scan)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1721 | struct cfg80211_scan_request *req); | 1901 | struct cfg80211_scan_request *req); |
1902 | int (*sched_scan_start)(struct ieee80211_hw *hw, | ||
1903 | struct ieee80211_vif *vif, | ||
1904 | struct cfg80211_sched_scan_request *req, | ||
1905 | struct ieee80211_sched_scan_ies *ies); | ||
1906 | void (*sched_scan_stop)(struct ieee80211_hw *hw, | ||
1907 | struct ieee80211_vif *vif); | ||
1722 | void (*sw_scan_start)(struct ieee80211_hw *hw); | 1908 | void (*sw_scan_start)(struct ieee80211_hw *hw); |
1723 | void (*sw_scan_complete)(struct ieee80211_hw *hw); | 1909 | void (*sw_scan_complete)(struct ieee80211_hw *hw); |
1724 | int (*get_stats)(struct ieee80211_hw *hw, | 1910 | int (*get_stats)(struct ieee80211_hw *hw, |
1725 | struct ieee80211_low_level_stats *stats); | 1911 | struct ieee80211_low_level_stats *stats); |
1726 | void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx, | 1912 | void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx, |
1727 | u32 *iv32, u16 *iv16); | 1913 | u32 *iv32, u16 *iv16); |
1914 | int (*set_frag_threshold)(struct ieee80211_hw *hw, u32 value); | ||
1728 | int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); | 1915 | int (*set_rts_threshold)(struct ieee80211_hw *hw, u32 value); |
1729 | int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1916 | int (*sta_add)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
1730 | struct ieee80211_sta *sta); | 1917 | struct ieee80211_sta *sta); |
@@ -1741,7 +1928,8 @@ struct ieee80211_ops { | |||
1741 | int (*ampdu_action)(struct ieee80211_hw *hw, | 1928 | int (*ampdu_action)(struct ieee80211_hw *hw, |
1742 | struct ieee80211_vif *vif, | 1929 | struct ieee80211_vif *vif, |
1743 | enum ieee80211_ampdu_mlme_action action, | 1930 | enum ieee80211_ampdu_mlme_action action, |
1744 | struct ieee80211_sta *sta, u16 tid, u16 *ssn); | 1931 | struct ieee80211_sta *sta, u16 tid, u16 *ssn, |
1932 | u8 buf_size); | ||
1745 | int (*get_survey)(struct ieee80211_hw *hw, int idx, | 1933 | int (*get_survey)(struct ieee80211_hw *hw, int idx, |
1746 | struct survey_info *survey); | 1934 | struct survey_info *survey); |
1747 | void (*rfkill_poll)(struct ieee80211_hw *hw); | 1935 | void (*rfkill_poll)(struct ieee80211_hw *hw); |
@@ -1752,6 +1940,26 @@ struct ieee80211_ops { | |||
1752 | void (*flush)(struct ieee80211_hw *hw, bool drop); | 1940 | void (*flush)(struct ieee80211_hw *hw, bool drop); |
1753 | void (*channel_switch)(struct ieee80211_hw *hw, | 1941 | void (*channel_switch)(struct ieee80211_hw *hw, |
1754 | struct ieee80211_channel_switch *ch_switch); | 1942 | struct ieee80211_channel_switch *ch_switch); |
1943 | int (*napi_poll)(struct ieee80211_hw *hw, int budget); | ||
1944 | int (*set_antenna)(struct ieee80211_hw *hw, u32 tx_ant, u32 rx_ant); | ||
1945 | int (*get_antenna)(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant); | ||
1946 | |||
1947 | int (*remain_on_channel)(struct ieee80211_hw *hw, | ||
1948 | struct ieee80211_channel *chan, | ||
1949 | enum nl80211_channel_type channel_type, | ||
1950 | int duration); | ||
1951 | int (*cancel_remain_on_channel)(struct ieee80211_hw *hw); | ||
1952 | int (*offchannel_tx)(struct ieee80211_hw *hw, struct sk_buff *skb, | ||
1953 | struct ieee80211_channel *chan, | ||
1954 | enum nl80211_channel_type channel_type, | ||
1955 | unsigned int wait); | ||
1956 | int (*offchannel_tx_cancel_wait)(struct ieee80211_hw *hw); | ||
1957 | int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx); | ||
1958 | void (*get_ringparam)(struct ieee80211_hw *hw, | ||
1959 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max); | ||
1960 | bool (*tx_frames_pending)(struct ieee80211_hw *hw); | ||
1961 | int (*set_bitrate_mask)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | ||
1962 | const struct cfg80211_bitrate_mask *mask); | ||
1755 | }; | 1963 | }; |
1756 | 1964 | ||
1757 | /** | 1965 | /** |
@@ -1780,11 +1988,39 @@ struct ieee80211_hw *ieee80211_alloc_hw(size_t priv_data_len, | |||
1780 | */ | 1988 | */ |
1781 | int ieee80211_register_hw(struct ieee80211_hw *hw); | 1989 | int ieee80211_register_hw(struct ieee80211_hw *hw); |
1782 | 1990 | ||
1991 | /** | ||
1992 | * struct ieee80211_tpt_blink - throughput blink description | ||
1993 | * @throughput: throughput in Kbit/sec | ||
1994 | * @blink_time: blink time in milliseconds | ||
1995 | * (full cycle, ie. one off + one on period) | ||
1996 | */ | ||
1997 | struct ieee80211_tpt_blink { | ||
1998 | int throughput; | ||
1999 | int blink_time; | ||
2000 | }; | ||
2001 | |||
2002 | /** | ||
2003 | * enum ieee80211_tpt_led_trigger_flags - throughput trigger flags | ||
2004 | * @IEEE80211_TPT_LEDTRIG_FL_RADIO: enable blinking with radio | ||
2005 | * @IEEE80211_TPT_LEDTRIG_FL_WORK: enable blinking when working | ||
2006 | * @IEEE80211_TPT_LEDTRIG_FL_CONNECTED: enable blinking when at least one | ||
2007 | * interface is connected in some way, including being an AP | ||
2008 | */ | ||
2009 | enum ieee80211_tpt_led_trigger_flags { | ||
2010 | IEEE80211_TPT_LEDTRIG_FL_RADIO = BIT(0), | ||
2011 | IEEE80211_TPT_LEDTRIG_FL_WORK = BIT(1), | ||
2012 | IEEE80211_TPT_LEDTRIG_FL_CONNECTED = BIT(2), | ||
2013 | }; | ||
2014 | |||
1783 | #ifdef CONFIG_MAC80211_LEDS | 2015 | #ifdef CONFIG_MAC80211_LEDS |
1784 | extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); | 2016 | extern char *__ieee80211_get_tx_led_name(struct ieee80211_hw *hw); |
1785 | extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); | 2017 | extern char *__ieee80211_get_rx_led_name(struct ieee80211_hw *hw); |
1786 | extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw); | 2018 | extern char *__ieee80211_get_assoc_led_name(struct ieee80211_hw *hw); |
1787 | extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw); | 2019 | extern char *__ieee80211_get_radio_led_name(struct ieee80211_hw *hw); |
2020 | extern char *__ieee80211_create_tpt_led_trigger( | ||
2021 | struct ieee80211_hw *hw, unsigned int flags, | ||
2022 | const struct ieee80211_tpt_blink *blink_table, | ||
2023 | unsigned int blink_table_len); | ||
1788 | #endif | 2024 | #endif |
1789 | /** | 2025 | /** |
1790 | * ieee80211_get_tx_led_name - get name of TX LED | 2026 | * ieee80211_get_tx_led_name - get name of TX LED |
@@ -1863,6 +2099,30 @@ static inline char *ieee80211_get_radio_led_name(struct ieee80211_hw *hw) | |||
1863 | } | 2099 | } |
1864 | 2100 | ||
1865 | /** | 2101 | /** |
2102 | * ieee80211_create_tpt_led_trigger - create throughput LED trigger | ||
2103 | * @hw: the hardware to create the trigger for | ||
2104 | * @flags: trigger flags, see &enum ieee80211_tpt_led_trigger_flags | ||
2105 | * @blink_table: the blink table -- needs to be ordered by throughput | ||
2106 | * @blink_table_len: size of the blink table | ||
2107 | * | ||
2108 | * This function returns %NULL (in case of error, or if no LED | ||
2109 | * triggers are configured) or the name of the new trigger. | ||
2110 | * This function must be called before ieee80211_register_hw(). | ||
2111 | */ | ||
2112 | static inline char * | ||
2113 | ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw, unsigned int flags, | ||
2114 | const struct ieee80211_tpt_blink *blink_table, | ||
2115 | unsigned int blink_table_len) | ||
2116 | { | ||
2117 | #ifdef CONFIG_MAC80211_LEDS | ||
2118 | return __ieee80211_create_tpt_led_trigger(hw, flags, blink_table, | ||
2119 | blink_table_len); | ||
2120 | #else | ||
2121 | return NULL; | ||
2122 | #endif | ||
2123 | } | ||
2124 | |||
2125 | /** | ||
1866 | * ieee80211_unregister_hw - Unregister a hardware device | 2126 | * ieee80211_unregister_hw - Unregister a hardware device |
1867 | * | 2127 | * |
1868 | * This function instructs mac80211 to free allocated resources | 2128 | * This function instructs mac80211 to free allocated resources |
@@ -1897,6 +2157,22 @@ void ieee80211_free_hw(struct ieee80211_hw *hw); | |||
1897 | */ | 2157 | */ |
1898 | void ieee80211_restart_hw(struct ieee80211_hw *hw); | 2158 | void ieee80211_restart_hw(struct ieee80211_hw *hw); |
1899 | 2159 | ||
2160 | /** ieee80211_napi_schedule - schedule NAPI poll | ||
2161 | * | ||
2162 | * Use this function to schedule NAPI polling on a device. | ||
2163 | * | ||
2164 | * @hw: the hardware to start polling | ||
2165 | */ | ||
2166 | void ieee80211_napi_schedule(struct ieee80211_hw *hw); | ||
2167 | |||
2168 | /** ieee80211_napi_complete - complete NAPI polling | ||
2169 | * | ||
2170 | * Use this function to finish NAPI polling on a device. | ||
2171 | * | ||
2172 | * @hw: the hardware to stop polling | ||
2173 | */ | ||
2174 | void ieee80211_napi_complete(struct ieee80211_hw *hw); | ||
2175 | |||
1900 | /** | 2176 | /** |
1901 | * ieee80211_rx - receive frame | 2177 | * ieee80211_rx - receive frame |
1902 | * | 2178 | * |
@@ -1952,6 +2228,48 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw, | |||
1952 | local_bh_enable(); | 2228 | local_bh_enable(); |
1953 | } | 2229 | } |
1954 | 2230 | ||
2231 | /** | ||
2232 | * ieee80211_sta_ps_transition - PS transition for connected sta | ||
2233 | * | ||
2234 | * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS | ||
2235 | * flag set, use this function to inform mac80211 about a connected station | ||
2236 | * entering/leaving PS mode. | ||
2237 | * | ||
2238 | * This function may not be called in IRQ context or with softirqs enabled. | ||
2239 | * | ||
2240 | * Calls to this function for a single hardware must be synchronized against | ||
2241 | * each other. | ||
2242 | * | ||
2243 | * The function returns -EINVAL when the requested PS mode is already set. | ||
2244 | * | ||
2245 | * @sta: currently connected sta | ||
2246 | * @start: start or stop PS | ||
2247 | */ | ||
2248 | int ieee80211_sta_ps_transition(struct ieee80211_sta *sta, bool start); | ||
2249 | |||
2250 | /** | ||
2251 | * ieee80211_sta_ps_transition_ni - PS transition for connected sta | ||
2252 | * (in process context) | ||
2253 | * | ||
2254 | * Like ieee80211_sta_ps_transition() but can be called in process context | ||
2255 | * (internally disables bottom halves). Concurrent call restriction still | ||
2256 | * applies. | ||
2257 | * | ||
2258 | * @sta: currently connected sta | ||
2259 | * @start: start or stop PS | ||
2260 | */ | ||
2261 | static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta, | ||
2262 | bool start) | ||
2263 | { | ||
2264 | int ret; | ||
2265 | |||
2266 | local_bh_disable(); | ||
2267 | ret = ieee80211_sta_ps_transition(sta, start); | ||
2268 | local_bh_enable(); | ||
2269 | |||
2270 | return ret; | ||
2271 | } | ||
2272 | |||
1955 | /* | 2273 | /* |
1956 | * The TX headroom reserved by mac80211 for its own tx_status functions. | 2274 | * The TX headroom reserved by mac80211 for its own tx_status functions. |
1957 | * This is enough for the radiotap header. | 2275 | * This is enough for the radiotap header. |
@@ -1959,6 +2277,19 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw, | |||
1959 | #define IEEE80211_TX_STATUS_HEADROOM 13 | 2277 | #define IEEE80211_TX_STATUS_HEADROOM 13 |
1960 | 2278 | ||
1961 | /** | 2279 | /** |
2280 | * ieee80211_sta_set_tim - set the TIM bit for a sleeping station | ||
2281 | * @sta: &struct ieee80211_sta pointer for the sleeping station | ||
2282 | * | ||
2283 | * If a driver buffers frames for a powersave station instead of passing | ||
2284 | * them back to mac80211 for retransmission, the station needs to be told | ||
2285 | * to wake up using the TIM bitmap in the beacon. | ||
2286 | * | ||
2287 | * This function sets the station's TIM bit - it will be cleared when the | ||
2288 | * station wakes up. | ||
2289 | */ | ||
2290 | void ieee80211_sta_set_tim(struct ieee80211_sta *sta); | ||
2291 | |||
2292 | /** | ||
1962 | * ieee80211_tx_status - transmit status callback | 2293 | * ieee80211_tx_status - transmit status callback |
1963 | * | 2294 | * |
1964 | * Call this function for all transmitted frames after they have been | 2295 | * Call this function for all transmitted frames after they have been |
@@ -1967,8 +2298,8 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw, | |||
1967 | * | 2298 | * |
1968 | * This function may not be called in IRQ context. Calls to this function | 2299 | * This function may not be called in IRQ context. Calls to this function |
1969 | * for a single hardware must be synchronized against each other. Calls | 2300 | * for a single hardware must be synchronized against each other. Calls |
1970 | * to this function and ieee80211_tx_status_irqsafe() may not be mixed | 2301 | * to this function, ieee80211_tx_status_ni() and ieee80211_tx_status_irqsafe() |
1971 | * for a single hardware. | 2302 | * may not be mixed for a single hardware. |
1972 | * | 2303 | * |
1973 | * @hw: the hardware the frame was transmitted by | 2304 | * @hw: the hardware the frame was transmitted by |
1974 | * @skb: the frame that was transmitted, owned by mac80211 after this call | 2305 | * @skb: the frame that was transmitted, owned by mac80211 after this call |
@@ -1977,13 +2308,33 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, | |||
1977 | struct sk_buff *skb); | 2308 | struct sk_buff *skb); |
1978 | 2309 | ||
1979 | /** | 2310 | /** |
2311 | * ieee80211_tx_status_ni - transmit status callback (in process context) | ||
2312 | * | ||
2313 | * Like ieee80211_tx_status() but can be called in process context. | ||
2314 | * | ||
2315 | * Calls to this function, ieee80211_tx_status() and | ||
2316 | * ieee80211_tx_status_irqsafe() may not be mixed | ||
2317 | * for a single hardware. | ||
2318 | * | ||
2319 | * @hw: the hardware the frame was transmitted by | ||
2320 | * @skb: the frame that was transmitted, owned by mac80211 after this call | ||
2321 | */ | ||
2322 | static inline void ieee80211_tx_status_ni(struct ieee80211_hw *hw, | ||
2323 | struct sk_buff *skb) | ||
2324 | { | ||
2325 | local_bh_disable(); | ||
2326 | ieee80211_tx_status(hw, skb); | ||
2327 | local_bh_enable(); | ||
2328 | } | ||
2329 | |||
2330 | /** | ||
1980 | * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback | 2331 | * ieee80211_tx_status_irqsafe - IRQ-safe transmit status callback |
1981 | * | 2332 | * |
1982 | * Like ieee80211_tx_status() but can be called in IRQ context | 2333 | * Like ieee80211_tx_status() but can be called in IRQ context |
1983 | * (internally defers to a tasklet.) | 2334 | * (internally defers to a tasklet.) |
1984 | * | 2335 | * |
1985 | * Calls to this function and ieee80211_tx_status() may not be mixed for a | 2336 | * Calls to this function, ieee80211_tx_status() and |
1986 | * single hardware. | 2337 | * ieee80211_tx_status_ni() may not be mixed for a single hardware. |
1987 | * | 2338 | * |
1988 | * @hw: the hardware the frame was transmitted by | 2339 | * @hw: the hardware the frame was transmitted by |
1989 | * @skb: the frame that was transmitted, owned by mac80211 after this call | 2340 | * @skb: the frame that was transmitted, owned by mac80211 after this call |
@@ -1992,6 +2343,17 @@ void ieee80211_tx_status_irqsafe(struct ieee80211_hw *hw, | |||
1992 | struct sk_buff *skb); | 2343 | struct sk_buff *skb); |
1993 | 2344 | ||
1994 | /** | 2345 | /** |
2346 | * ieee80211_report_low_ack - report non-responding station | ||
2347 | * | ||
2348 | * When operating in AP-mode, call this function to report a non-responding | ||
2349 | * connected STA. | ||
2350 | * | ||
2351 | * @sta: the non-responding connected sta | ||
2352 | * @num_packets: number of packets sent to @sta without a response | ||
2353 | */ | ||
2354 | void ieee80211_report_low_ack(struct ieee80211_sta *sta, u32 num_packets); | ||
2355 | |||
2356 | /** | ||
1995 | * ieee80211_beacon_get_tim - beacon generation function | 2357 | * ieee80211_beacon_get_tim - beacon generation function |
1996 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 2358 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
1997 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 2359 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
@@ -2252,7 +2614,8 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw); | |||
2252 | * | 2614 | * |
2253 | * When hardware scan offload is used (i.e. the hw_scan() callback is | 2615 | * When hardware scan offload is used (i.e. the hw_scan() callback is |
2254 | * assigned) this function needs to be called by the driver to notify | 2616 | * assigned) this function needs to be called by the driver to notify |
2255 | * mac80211 that the scan finished. | 2617 | * mac80211 that the scan finished. This function can be called from |
2618 | * any context, including hardirq context. | ||
2256 | * | 2619 | * |
2257 | * @hw: the hardware that finished the scan | 2620 | * @hw: the hardware that finished the scan |
2258 | * @aborted: set to true if scan was aborted | 2621 | * @aborted: set to true if scan was aborted |
@@ -2260,6 +2623,28 @@ void ieee80211_wake_queues(struct ieee80211_hw *hw); | |||
2260 | void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted); | 2623 | void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted); |
2261 | 2624 | ||
2262 | /** | 2625 | /** |
2626 | * ieee80211_sched_scan_results - got results from scheduled scan | ||
2627 | * | ||
2628 | * When a scheduled scan is running, this function needs to be called by the | ||
2629 | * driver whenever there are new scan results available. | ||
2630 | * | ||
2631 | * @hw: the hardware that is performing scheduled scans | ||
2632 | */ | ||
2633 | void ieee80211_sched_scan_results(struct ieee80211_hw *hw); | ||
2634 | |||
2635 | /** | ||
2636 | * ieee80211_sched_scan_stopped - inform that the scheduled scan has stopped | ||
2637 | * | ||
2638 | * When a scheduled scan is running, this function can be called by | ||
2639 | * the driver if it needs to stop the scan to perform another task. | ||
2640 | * Usual scenarios are drivers that cannot continue the scheduled scan | ||
2641 | * while associating, for instance. | ||
2642 | * | ||
2643 | * @hw: the hardware that is performing scheduled scans | ||
2644 | */ | ||
2645 | void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw); | ||
2646 | |||
2647 | /** | ||
2263 | * ieee80211_iterate_active_interfaces - iterate active interfaces | 2648 | * ieee80211_iterate_active_interfaces - iterate active interfaces |
2264 | * | 2649 | * |
2265 | * This function iterates over the interfaces associated with a given | 2650 | * This function iterates over the interfaces associated with a given |
@@ -2267,6 +2652,7 @@ void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted); | |||
2267 | * This function allows the iterator function to sleep, when the iterator | 2652 | * This function allows the iterator function to sleep, when the iterator |
2268 | * function is atomic @ieee80211_iterate_active_interfaces_atomic can | 2653 | * function is atomic @ieee80211_iterate_active_interfaces_atomic can |
2269 | * be used. | 2654 | * be used. |
2655 | * Does not iterate over a new interface during add_interface() | ||
2270 | * | 2656 | * |
2271 | * @hw: the hardware struct of which the interfaces should be iterated over | 2657 | * @hw: the hardware struct of which the interfaces should be iterated over |
2272 | * @iterator: the iterator function to call | 2658 | * @iterator: the iterator function to call |
@@ -2284,6 +2670,7 @@ void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, | |||
2284 | * hardware that are currently active and calls the callback for them. | 2670 | * hardware that are currently active and calls the callback for them. |
2285 | * This function requires the iterator callback function to be atomic, | 2671 | * This function requires the iterator callback function to be atomic, |
2286 | * if that is not desired, use @ieee80211_iterate_active_interfaces instead. | 2672 | * if that is not desired, use @ieee80211_iterate_active_interfaces instead. |
2673 | * Does not iterate over a new interface during add_interface() | ||
2287 | * | 2674 | * |
2288 | * @hw: the hardware struct of which the interfaces should be iterated over | 2675 | * @hw: the hardware struct of which the interfaces should be iterated over |
2289 | * @iterator: the iterator function to call, cannot sleep | 2676 | * @iterator: the iterator function to call, cannot sleep |
@@ -2324,6 +2711,7 @@ void ieee80211_queue_delayed_work(struct ieee80211_hw *hw, | |||
2324 | * ieee80211_start_tx_ba_session - Start a tx Block Ack session. | 2711 | * ieee80211_start_tx_ba_session - Start a tx Block Ack session. |
2325 | * @sta: the station for which to start a BA session | 2712 | * @sta: the station for which to start a BA session |
2326 | * @tid: the TID to BA on. | 2713 | * @tid: the TID to BA on. |
2714 | * @timeout: session timeout value (in TUs) | ||
2327 | * | 2715 | * |
2328 | * Return: success if addBA request was sent, failure otherwise | 2716 | * Return: success if addBA request was sent, failure otherwise |
2329 | * | 2717 | * |
@@ -2331,7 +2719,8 @@ void ieee80211_queue_delayed_work(struct ieee80211_hw *hw, | |||
2331 | * the need to start aggregation on a certain RA/TID, the session level | 2719 | * the need to start aggregation on a certain RA/TID, the session level |
2332 | * will be managed by the mac80211. | 2720 | * will be managed by the mac80211. |
2333 | */ | 2721 | */ |
2334 | int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid); | 2722 | int ieee80211_start_tx_ba_session(struct ieee80211_sta *sta, u16 tid, |
2723 | u16 timeout); | ||
2335 | 2724 | ||
2336 | /** | 2725 | /** |
2337 | * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate. | 2726 | * ieee80211_start_tx_ba_cb_irqsafe - low level driver ready to aggregate. |
@@ -2385,25 +2774,28 @@ struct ieee80211_sta *ieee80211_find_sta(struct ieee80211_vif *vif, | |||
2385 | const u8 *addr); | 2774 | const u8 *addr); |
2386 | 2775 | ||
2387 | /** | 2776 | /** |
2388 | * ieee80211_find_sta_by_hw - find a station on hardware | 2777 | * ieee80211_find_sta_by_ifaddr - find a station on hardware |
2389 | * | 2778 | * |
2390 | * @hw: pointer as obtained from ieee80211_alloc_hw() | 2779 | * @hw: pointer as obtained from ieee80211_alloc_hw() |
2391 | * @addr: station's address | 2780 | * @addr: remote station's address |
2781 | * @localaddr: local address (vif->sdata->vif.addr). Use NULL for 'any'. | ||
2392 | * | 2782 | * |
2393 | * This function must be called under RCU lock and the | 2783 | * This function must be called under RCU lock and the |
2394 | * resulting pointer is only valid under RCU lock as well. | 2784 | * resulting pointer is only valid under RCU lock as well. |
2395 | * | 2785 | * |
2396 | * NOTE: This function should not be used! When mac80211 is converted | 2786 | * NOTE: You may pass NULL for localaddr, but then you will just get |
2397 | * internally to properly keep track of stations on multiple | 2787 | * the first STA that matches the remote address 'addr'. |
2398 | * virtual interfaces, it will not always know which station to | 2788 | * We can have multiple STA associated with multiple |
2399 | * return here since a single address might be used by multiple | 2789 | * logical stations (e.g. consider a station connecting to another |
2400 | * logical stations (e.g. consider a station connecting to another | 2790 | * BSSID on the same AP hardware without disconnecting first). |
2401 | * BSSID on the same AP hardware without disconnecting first). | 2791 | * In this case, the result of this method with localaddr NULL |
2792 | * is not reliable. | ||
2402 | * | 2793 | * |
2403 | * DO NOT USE THIS FUNCTION. | 2794 | * DO NOT USE THIS FUNCTION with localaddr NULL if at all possible. |
2404 | */ | 2795 | */ |
2405 | struct ieee80211_sta *ieee80211_find_sta_by_hw(struct ieee80211_hw *hw, | 2796 | struct ieee80211_sta *ieee80211_find_sta_by_ifaddr(struct ieee80211_hw *hw, |
2406 | const u8 *addr); | 2797 | const u8 *addr, |
2798 | const u8 *localaddr); | ||
2407 | 2799 | ||
2408 | /** | 2800 | /** |
2409 | * ieee80211_sta_block_awake - block station from waking up | 2801 | * ieee80211_sta_block_awake - block station from waking up |
@@ -2438,11 +2830,26 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw, | |||
2438 | struct ieee80211_sta *pubsta, bool block); | 2830 | struct ieee80211_sta *pubsta, bool block); |
2439 | 2831 | ||
2440 | /** | 2832 | /** |
2833 | * ieee80211_ap_probereq_get - retrieve a Probe Request template | ||
2834 | * @hw: pointer obtained from ieee80211_alloc_hw(). | ||
2835 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | ||
2836 | * | ||
2837 | * Creates a Probe Request template which can, for example, be uploaded to | ||
2838 | * hardware. The template is filled with bssid, ssid and supported rate | ||
2839 | * information. This function must only be called from within the | ||
2840 | * .bss_info_changed callback function and only in managed mode. The function | ||
2841 | * is only useful when the interface is associated, otherwise it will return | ||
2842 | * NULL. | ||
2843 | */ | ||
2844 | struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, | ||
2845 | struct ieee80211_vif *vif); | ||
2846 | |||
2847 | /** | ||
2441 | * ieee80211_beacon_loss - inform hardware does not receive beacons | 2848 | * ieee80211_beacon_loss - inform hardware does not receive beacons |
2442 | * | 2849 | * |
2443 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 2850 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
2444 | * | 2851 | * |
2445 | * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTERING and | 2852 | * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER and |
2446 | * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the | 2853 | * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the |
2447 | * hardware is not receiving beacons with this function. | 2854 | * hardware is not receiving beacons with this function. |
2448 | */ | 2855 | */ |
@@ -2453,7 +2860,7 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif); | |||
2453 | * | 2860 | * |
2454 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 2861 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
2455 | * | 2862 | * |
2456 | * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTERING, and | 2863 | * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER, and |
2457 | * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver | 2864 | * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver |
2458 | * needs to inform if the connection to the AP has been lost. | 2865 | * needs to inform if the connection to the AP has been lost. |
2459 | * | 2866 | * |
@@ -2518,6 +2925,46 @@ void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, | |||
2518 | */ | 2925 | */ |
2519 | void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success); | 2926 | void ieee80211_chswitch_done(struct ieee80211_vif *vif, bool success); |
2520 | 2927 | ||
2928 | /** | ||
2929 | * ieee80211_request_smps - request SM PS transition | ||
2930 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | ||
2931 | * @smps_mode: new SM PS mode | ||
2932 | * | ||
2933 | * This allows the driver to request an SM PS transition in managed | ||
2934 | * mode. This is useful when the driver has more information than | ||
2935 | * the stack about possible interference, for example by bluetooth. | ||
2936 | */ | ||
2937 | void ieee80211_request_smps(struct ieee80211_vif *vif, | ||
2938 | enum ieee80211_smps_mode smps_mode); | ||
2939 | |||
2940 | /** | ||
2941 | * ieee80211_key_removed - disable hw acceleration for key | ||
2942 | * @key_conf: The key hw acceleration should be disabled for | ||
2943 | * | ||
2944 | * This allows drivers to indicate that the given key has been | ||
2945 | * removed from hardware acceleration, due to a new key that | ||
2946 | * was added. Don't use this if the key can continue to be used | ||
2947 | * for TX, if the key restriction is on RX only it is permitted | ||
2948 | * to keep the key for TX only and not call this function. | ||
2949 | * | ||
2950 | * Due to locking constraints, it may only be called during | ||
2951 | * @set_key. This function must be allowed to sleep, and the | ||
2952 | * key it tries to disable may still be used until it returns. | ||
2953 | */ | ||
2954 | void ieee80211_key_removed(struct ieee80211_key_conf *key_conf); | ||
2955 | |||
2956 | /** | ||
2957 | * ieee80211_ready_on_channel - notification of remain-on-channel start | ||
2958 | * @hw: pointer as obtained from ieee80211_alloc_hw() | ||
2959 | */ | ||
2960 | void ieee80211_ready_on_channel(struct ieee80211_hw *hw); | ||
2961 | |||
2962 | /** | ||
2963 | * ieee80211_remain_on_channel_expired - remain_on_channel duration expired | ||
2964 | * @hw: pointer as obtained from ieee80211_alloc_hw() | ||
2965 | */ | ||
2966 | void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw); | ||
2967 | |||
2521 | /* Rate control API */ | 2968 | /* Rate control API */ |
2522 | 2969 | ||
2523 | /** | 2970 | /** |
@@ -2549,7 +2996,7 @@ enum rate_control_changed { | |||
2549 | * @rate_idx_mask: user-requested rate mask (not MCS for now) | 2996 | * @rate_idx_mask: user-requested rate mask (not MCS for now) |
2550 | * @skb: the skb that will be transmitted, the control information in it needs | 2997 | * @skb: the skb that will be transmitted, the control information in it needs |
2551 | * to be filled in | 2998 | * to be filled in |
2552 | * @ap: whether this frame is sent out in AP mode | 2999 | * @bss: whether this frame is sent out in AP or IBSS mode |
2553 | */ | 3000 | */ |
2554 | struct ieee80211_tx_rate_control { | 3001 | struct ieee80211_tx_rate_control { |
2555 | struct ieee80211_hw *hw; | 3002 | struct ieee80211_hw *hw; |
@@ -2560,7 +3007,7 @@ struct ieee80211_tx_rate_control { | |||
2560 | bool rts, short_preamble; | 3007 | bool rts, short_preamble; |
2561 | u8 max_rate_idx; | 3008 | u8 max_rate_idx; |
2562 | u32 rate_idx_mask; | 3009 | u32 rate_idx_mask; |
2563 | bool ap; | 3010 | bool bss; |
2564 | }; | 3011 | }; |
2565 | 3012 | ||
2566 | struct rate_control_ops { | 3013 | struct rate_control_ops { |
@@ -2681,4 +3128,26 @@ conf_is_ht(struct ieee80211_conf *conf) | |||
2681 | return conf->channel_type != NL80211_CHAN_NO_HT; | 3128 | return conf->channel_type != NL80211_CHAN_NO_HT; |
2682 | } | 3129 | } |
2683 | 3130 | ||
3131 | static inline enum nl80211_iftype | ||
3132 | ieee80211_iftype_p2p(enum nl80211_iftype type, bool p2p) | ||
3133 | { | ||
3134 | if (p2p) { | ||
3135 | switch (type) { | ||
3136 | case NL80211_IFTYPE_STATION: | ||
3137 | return NL80211_IFTYPE_P2P_CLIENT; | ||
3138 | case NL80211_IFTYPE_AP: | ||
3139 | return NL80211_IFTYPE_P2P_GO; | ||
3140 | default: | ||
3141 | break; | ||
3142 | } | ||
3143 | } | ||
3144 | return type; | ||
3145 | } | ||
3146 | |||
3147 | static inline enum nl80211_iftype | ||
3148 | ieee80211_vif_type_p2p(struct ieee80211_vif *vif) | ||
3149 | { | ||
3150 | return ieee80211_iftype_p2p(vif->type, vif->p2p); | ||
3151 | } | ||
3152 | |||
2684 | #endif /* MAC80211_H */ | 3153 | #endif /* MAC80211_H */ |
diff --git a/include/net/ndisc.h b/include/net/ndisc.h index 895997bc2ead..62beeb97c4b1 100644 --- a/include/net/ndisc.h +++ b/include/net/ndisc.h | |||
@@ -42,11 +42,6 @@ enum { | |||
42 | #define ND_REACHABLE_TIME (30*HZ) | 42 | #define ND_REACHABLE_TIME (30*HZ) |
43 | #define ND_RETRANS_TIMER HZ | 43 | #define ND_RETRANS_TIMER HZ |
44 | 44 | ||
45 | #define ND_MIN_RANDOM_FACTOR (1/2) | ||
46 | #define ND_MAX_RANDOM_FACTOR (3/2) | ||
47 | |||
48 | #ifdef __KERNEL__ | ||
49 | |||
50 | #include <linux/compiler.h> | 45 | #include <linux/compiler.h> |
51 | #include <linux/icmpv6.h> | 46 | #include <linux/icmpv6.h> |
52 | #include <linux/in6.h> | 47 | #include <linux/in6.h> |
@@ -105,7 +100,8 @@ extern void ndisc_send_redirect(struct sk_buff *skb, | |||
105 | struct neighbour *neigh, | 100 | struct neighbour *neigh, |
106 | const struct in6_addr *target); | 101 | const struct in6_addr *target); |
107 | 102 | ||
108 | extern int ndisc_mc_map(struct in6_addr *addr, char *buf, struct net_device *dev, int dir); | 103 | extern int ndisc_mc_map(const struct in6_addr *addr, char *buf, |
104 | struct net_device *dev, int dir); | ||
109 | 105 | ||
110 | extern struct sk_buff *ndisc_build_skb(struct net_device *dev, | 106 | extern struct sk_buff *ndisc_build_skb(struct net_device *dev, |
111 | const struct in6_addr *daddr, | 107 | const struct in6_addr *daddr, |
@@ -158,8 +154,4 @@ static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, const s | |||
158 | return ERR_PTR(-ENODEV); | 154 | return ERR_PTR(-ENODEV); |
159 | } | 155 | } |
160 | 156 | ||
161 | |||
162 | #endif /* __KERNEL__ */ | ||
163 | |||
164 | |||
165 | #endif | 157 | #endif |
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 242879b6c4df..4014b623880c 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -91,26 +91,28 @@ struct neigh_statistics { | |||
91 | #define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field) | 91 | #define NEIGH_CACHE_STAT_INC(tbl, field) this_cpu_inc((tbl)->stats->field) |
92 | 92 | ||
93 | struct neighbour { | 93 | struct neighbour { |
94 | struct neighbour *next; | 94 | struct neighbour __rcu *next; |
95 | struct neigh_table *tbl; | 95 | struct neigh_table *tbl; |
96 | struct neigh_parms *parms; | 96 | struct neigh_parms *parms; |
97 | struct net_device *dev; | ||
98 | unsigned long used; | ||
99 | unsigned long confirmed; | 97 | unsigned long confirmed; |
100 | unsigned long updated; | 98 | unsigned long updated; |
99 | rwlock_t lock; | ||
100 | atomic_t refcnt; | ||
101 | struct sk_buff_head arp_queue; | ||
102 | struct timer_list timer; | ||
103 | unsigned long used; | ||
104 | atomic_t probes; | ||
101 | __u8 flags; | 105 | __u8 flags; |
102 | __u8 nud_state; | 106 | __u8 nud_state; |
103 | __u8 type; | 107 | __u8 type; |
104 | __u8 dead; | 108 | __u8 dead; |
105 | atomic_t probes; | 109 | seqlock_t ha_lock; |
106 | rwlock_t lock; | ||
107 | unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))]; | 110 | unsigned char ha[ALIGN(MAX_ADDR_LEN, sizeof(unsigned long))]; |
108 | struct hh_cache *hh; | 111 | struct hh_cache *hh; |
109 | atomic_t refcnt; | ||
110 | int (*output)(struct sk_buff *skb); | 112 | int (*output)(struct sk_buff *skb); |
111 | struct sk_buff_head arp_queue; | ||
112 | struct timer_list timer; | ||
113 | const struct neigh_ops *ops; | 113 | const struct neigh_ops *ops; |
114 | struct rcu_head rcu; | ||
115 | struct net_device *dev; | ||
114 | u8 primary_key[0]; | 116 | u8 primary_key[0]; |
115 | }; | 117 | }; |
116 | 118 | ||
@@ -138,13 +140,22 @@ struct pneigh_entry { | |||
138 | * neighbour table manipulation | 140 | * neighbour table manipulation |
139 | */ | 141 | */ |
140 | 142 | ||
143 | struct neigh_hash_table { | ||
144 | struct neighbour __rcu **hash_buckets; | ||
145 | unsigned int hash_mask; | ||
146 | __u32 hash_rnd; | ||
147 | struct rcu_head rcu; | ||
148 | }; | ||
149 | |||
141 | 150 | ||
142 | struct neigh_table { | 151 | struct neigh_table { |
143 | struct neigh_table *next; | 152 | struct neigh_table *next; |
144 | int family; | 153 | int family; |
145 | int entry_size; | 154 | int entry_size; |
146 | int key_len; | 155 | int key_len; |
147 | __u32 (*hash)(const void *pkey, const struct net_device *); | 156 | __u32 (*hash)(const void *pkey, |
157 | const struct net_device *dev, | ||
158 | __u32 hash_rnd); | ||
148 | int (*constructor)(struct neighbour *); | 159 | int (*constructor)(struct neighbour *); |
149 | int (*pconstructor)(struct pneigh_entry *); | 160 | int (*pconstructor)(struct pneigh_entry *); |
150 | void (*pdestructor)(struct pneigh_entry *); | 161 | void (*pdestructor)(struct pneigh_entry *); |
@@ -163,11 +174,9 @@ struct neigh_table { | |||
163 | atomic_t entries; | 174 | atomic_t entries; |
164 | rwlock_t lock; | 175 | rwlock_t lock; |
165 | unsigned long last_rand; | 176 | unsigned long last_rand; |
166 | struct kmem_cache *kmem_cachep; | 177 | struct kmem_cache *kmem_cachep; |
167 | struct neigh_statistics __percpu *stats; | 178 | struct neigh_statistics __percpu *stats; |
168 | struct neighbour **hash_buckets; | 179 | struct neigh_hash_table __rcu *nht; |
169 | unsigned int hash_mask; | ||
170 | __u32 hash_rnd; | ||
171 | struct pneigh_entry **phash_buckets; | 180 | struct pneigh_entry **phash_buckets; |
172 | }; | 181 | }; |
173 | 182 | ||
@@ -237,6 +246,7 @@ extern void pneigh_for_each(struct neigh_table *tbl, void (*cb)(struct pneigh_en | |||
237 | struct neigh_seq_state { | 246 | struct neigh_seq_state { |
238 | struct seq_net_private p; | 247 | struct seq_net_private p; |
239 | struct neigh_table *tbl; | 248 | struct neigh_table *tbl; |
249 | struct neigh_hash_table *nht; | ||
240 | void *(*neigh_sub_iter)(struct neigh_seq_state *state, | 250 | void *(*neigh_sub_iter)(struct neigh_seq_state *state, |
241 | struct neighbour *n, loff_t *pos); | 251 | struct neighbour *n, loff_t *pos); |
242 | unsigned int bucket; | 252 | unsigned int bucket; |
@@ -293,7 +303,10 @@ static inline void neigh_confirm(struct neighbour *neigh) | |||
293 | 303 | ||
294 | static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) | 304 | static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) |
295 | { | 305 | { |
296 | neigh->used = jiffies; | 306 | unsigned long now = jiffies; |
307 | |||
308 | if (neigh->used != now) | ||
309 | neigh->used = now; | ||
297 | if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE))) | 310 | if (!(neigh->nud_state&(NUD_CONNECTED|NUD_DELAY|NUD_PROBE))) |
298 | return __neigh_event_send(neigh, skb); | 311 | return __neigh_event_send(neigh, skb); |
299 | return 0; | 312 | return 0; |
@@ -364,4 +377,14 @@ struct neighbour_cb { | |||
364 | 377 | ||
365 | #define NEIGH_CB(skb) ((struct neighbour_cb *)(skb)->cb) | 378 | #define NEIGH_CB(skb) ((struct neighbour_cb *)(skb)->cb) |
366 | 379 | ||
380 | static inline void neigh_ha_snapshot(char *dst, const struct neighbour *n, | ||
381 | const struct net_device *dev) | ||
382 | { | ||
383 | unsigned int seq; | ||
384 | |||
385 | do { | ||
386 | seq = read_seqbegin(&n->ha_lock); | ||
387 | memcpy(dst, n->ha, dev->addr_len); | ||
388 | } while (read_seqretry(&n->ha_lock, seq)); | ||
389 | } | ||
367 | #endif | 390 | #endif |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index bd10a7908993..aef430d779bd 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <asm/atomic.h> | 7 | #include <asm/atomic.h> |
8 | #include <linux/workqueue.h> | 8 | #include <linux/workqueue.h> |
9 | #include <linux/list.h> | 9 | #include <linux/list.h> |
10 | #include <linux/sysctl.h> | ||
10 | 11 | ||
11 | #include <net/netns/core.h> | 12 | #include <net/netns/core.h> |
12 | #include <net/netns/mib.h> | 13 | #include <net/netns/mib.h> |
@@ -27,20 +28,26 @@ struct sock; | |||
27 | struct ctl_table_header; | 28 | struct ctl_table_header; |
28 | struct net_generic; | 29 | struct net_generic; |
29 | struct sock; | 30 | struct sock; |
31 | struct netns_ipvs; | ||
30 | 32 | ||
31 | 33 | ||
32 | #define NETDEV_HASHBITS 8 | 34 | #define NETDEV_HASHBITS 8 |
33 | #define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS) | 35 | #define NETDEV_HASHENTRIES (1 << NETDEV_HASHBITS) |
34 | 36 | ||
35 | struct net { | 37 | struct net { |
38 | atomic_t passive; /* To decided when the network | ||
39 | * namespace should be freed. | ||
40 | */ | ||
36 | atomic_t count; /* To decided when the network | 41 | atomic_t count; /* To decided when the network |
37 | * namespace should be freed. | 42 | * namespace should be shut down. |
38 | */ | 43 | */ |
39 | #ifdef NETNS_REFCNT_DEBUG | 44 | #ifdef NETNS_REFCNT_DEBUG |
40 | atomic_t use_count; /* To track references we | 45 | atomic_t use_count; /* To track references we |
41 | * destroy on demand | 46 | * destroy on demand |
42 | */ | 47 | */ |
43 | #endif | 48 | #endif |
49 | spinlock_t rules_mod_lock; | ||
50 | |||
44 | struct list_head list; /* list of network namespaces */ | 51 | struct list_head list; /* list of network namespaces */ |
45 | struct list_head cleanup_list; /* namespaces on death row */ | 52 | struct list_head cleanup_list; /* namespaces on death row */ |
46 | struct list_head exit_list; /* Use only net_mutex */ | 53 | struct list_head exit_list; /* Use only net_mutex */ |
@@ -52,7 +59,8 @@ struct net { | |||
52 | struct ctl_table_set sysctls; | 59 | struct ctl_table_set sysctls; |
53 | #endif | 60 | #endif |
54 | 61 | ||
55 | struct net_device *loopback_dev; /* The loopback */ | 62 | struct sock *rtnl; /* rtnetlink socket */ |
63 | struct sock *genl_sock; | ||
56 | 64 | ||
57 | struct list_head dev_base_head; | 65 | struct list_head dev_base_head; |
58 | struct hlist_head *dev_name_head; | 66 | struct hlist_head *dev_name_head; |
@@ -60,11 +68,9 @@ struct net { | |||
60 | 68 | ||
61 | /* core fib_rules */ | 69 | /* core fib_rules */ |
62 | struct list_head rules_ops; | 70 | struct list_head rules_ops; |
63 | spinlock_t rules_mod_lock; | ||
64 | 71 | ||
65 | struct sock *rtnl; /* rtnetlink socket */ | ||
66 | struct sock *genl_sock; | ||
67 | 72 | ||
73 | struct net_device *loopback_dev; /* The loopback */ | ||
68 | struct netns_core core; | 74 | struct netns_core core; |
69 | struct netns_mib mib; | 75 | struct netns_mib mib; |
70 | struct netns_packet packet; | 76 | struct netns_packet packet; |
@@ -84,13 +90,16 @@ struct net { | |||
84 | struct sock *nfnl; | 90 | struct sock *nfnl; |
85 | struct sock *nfnl_stash; | 91 | struct sock *nfnl_stash; |
86 | #endif | 92 | #endif |
87 | #ifdef CONFIG_XFRM | ||
88 | struct netns_xfrm xfrm; | ||
89 | #endif | ||
90 | #ifdef CONFIG_WEXT_CORE | 93 | #ifdef CONFIG_WEXT_CORE |
91 | struct sk_buff_head wext_nlevents; | 94 | struct sk_buff_head wext_nlevents; |
92 | #endif | 95 | #endif |
93 | struct net_generic *gen; | 96 | struct net_generic __rcu *gen; |
97 | |||
98 | /* Note : following structs are cache line aligned */ | ||
99 | #ifdef CONFIG_XFRM | ||
100 | struct netns_xfrm xfrm; | ||
101 | #endif | ||
102 | struct netns_ipvs *ipvs; | ||
94 | }; | 103 | }; |
95 | 104 | ||
96 | 105 | ||
@@ -114,6 +123,7 @@ static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns) | |||
114 | extern struct list_head net_namespace_list; | 123 | extern struct list_head net_namespace_list; |
115 | 124 | ||
116 | extern struct net *get_net_ns_by_pid(pid_t pid); | 125 | extern struct net *get_net_ns_by_pid(pid_t pid); |
126 | extern struct net *get_net_ns_by_fd(int pid); | ||
117 | 127 | ||
118 | #ifdef CONFIG_NET_NS | 128 | #ifdef CONFIG_NET_NS |
119 | extern void __put_net(struct net *net); | 129 | extern void __put_net(struct net *net); |
@@ -147,6 +157,9 @@ int net_eq(const struct net *net1, const struct net *net2) | |||
147 | { | 157 | { |
148 | return net1 == net2; | 158 | return net1 == net2; |
149 | } | 159 | } |
160 | |||
161 | extern void net_drop_ns(void *); | ||
162 | |||
150 | #else | 163 | #else |
151 | 164 | ||
152 | static inline struct net *get_net(struct net *net) | 165 | static inline struct net *get_net(struct net *net) |
@@ -168,6 +181,8 @@ int net_eq(const struct net *net1, const struct net *net2) | |||
168 | { | 181 | { |
169 | return 1; | 182 | return 1; |
170 | } | 183 | } |
184 | |||
185 | #define net_drop_ns NULL | ||
171 | #endif | 186 | #endif |
172 | 187 | ||
173 | 188 | ||
diff --git a/include/net/net_ratelimit.h b/include/net/net_ratelimit.h new file mode 100644 index 000000000000..7727b4247daf --- /dev/null +++ b/include/net/net_ratelimit.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef _LINUX_NET_RATELIMIT_H | ||
2 | #define _LINUX_NET_RATELIMIT_H | ||
3 | |||
4 | #include <linux/ratelimit.h> | ||
5 | |||
6 | extern struct ratelimit_state net_ratelimit_state; | ||
7 | |||
8 | #endif /* _LINUX_NET_RATELIMIT_H */ | ||
diff --git a/include/net/netevent.h b/include/net/netevent.h index e82b7bab3ff3..086f8a5b59dc 100644 --- a/include/net/netevent.h +++ b/include/net/netevent.h | |||
@@ -10,7 +10,6 @@ | |||
10 | * | 10 | * |
11 | * Changes: | 11 | * Changes: |
12 | */ | 12 | */ |
13 | #ifdef __KERNEL__ | ||
14 | 13 | ||
15 | struct dst_entry; | 14 | struct dst_entry; |
16 | 15 | ||
@@ -21,7 +20,6 @@ struct netevent_redirect { | |||
21 | 20 | ||
22 | enum netevent_notif_type { | 21 | enum netevent_notif_type { |
23 | NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */ | 22 | NETEVENT_NEIGH_UPDATE = 1, /* arg is struct neighbour ptr */ |
24 | NETEVENT_PMTU_UPDATE, /* arg is struct dst_entry ptr */ | ||
25 | NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */ | 23 | NETEVENT_REDIRECT, /* arg is struct netevent_redirect ptr */ |
26 | }; | 24 | }; |
27 | 25 | ||
@@ -30,4 +28,3 @@ extern int unregister_netevent_notifier(struct notifier_block *nb); | |||
30 | extern int call_netevent_notifiers(unsigned long val, void *v); | 28 | extern int call_netevent_notifiers(unsigned long val, void *v); |
31 | 29 | ||
32 | #endif | 30 | #endif |
33 | #endif | ||
diff --git a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h index 1ee717eb5b09..a4c993685795 100644 --- a/include/net/netfilter/ipv6/nf_conntrack_ipv6.h +++ b/include/net/netfilter/ipv6/nf_conntrack_ipv6.h | |||
@@ -7,16 +7,6 @@ extern struct nf_conntrack_l4proto nf_conntrack_l4proto_tcp6; | |||
7 | extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6; | 7 | extern struct nf_conntrack_l4proto nf_conntrack_l4proto_udp6; |
8 | extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6; | 8 | extern struct nf_conntrack_l4proto nf_conntrack_l4proto_icmpv6; |
9 | 9 | ||
10 | extern int nf_ct_frag6_init(void); | ||
11 | extern void nf_ct_frag6_cleanup(void); | ||
12 | extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user); | ||
13 | extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb, | ||
14 | struct net_device *in, | ||
15 | struct net_device *out, | ||
16 | int (*okfn)(struct sk_buff *)); | ||
17 | |||
18 | struct inet_frags_ctl; | ||
19 | |||
20 | #include <linux/sysctl.h> | 10 | #include <linux/sysctl.h> |
21 | extern struct ctl_table nf_ct_ipv6_sysctl_table[]; | 11 | extern struct ctl_table nf_ct_ipv6_sysctl_table[]; |
22 | 12 | ||
diff --git a/include/net/netfilter/ipv6/nf_defrag_ipv6.h b/include/net/netfilter/ipv6/nf_defrag_ipv6.h new file mode 100644 index 000000000000..fd79c9a1779d --- /dev/null +++ b/include/net/netfilter/ipv6/nf_defrag_ipv6.h | |||
@@ -0,0 +1,16 @@ | |||
1 | #ifndef _NF_DEFRAG_IPV6_H | ||
2 | #define _NF_DEFRAG_IPV6_H | ||
3 | |||
4 | extern void nf_defrag_ipv6_enable(void); | ||
5 | |||
6 | extern int nf_ct_frag6_init(void); | ||
7 | extern void nf_ct_frag6_cleanup(void); | ||
8 | extern struct sk_buff *nf_ct_frag6_gather(struct sk_buff *skb, u32 user); | ||
9 | extern void nf_ct_frag6_output(unsigned int hooknum, struct sk_buff *skb, | ||
10 | struct net_device *in, | ||
11 | struct net_device *out, | ||
12 | int (*okfn)(struct sk_buff *)); | ||
13 | |||
14 | struct inet_frags_ctl; | ||
15 | |||
16 | #endif /* _NF_DEFRAG_IPV6_H */ | ||
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index e624dae54fa4..5d4f8e586e32 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -14,7 +14,6 @@ | |||
14 | 14 | ||
15 | #include <linux/netfilter/nf_conntrack_common.h> | 15 | #include <linux/netfilter/nf_conntrack_common.h> |
16 | 16 | ||
17 | #ifdef __KERNEL__ | ||
18 | #include <linux/bitops.h> | 17 | #include <linux/bitops.h> |
19 | #include <linux/compiler.h> | 18 | #include <linux/compiler.h> |
20 | #include <asm/atomic.h> | 19 | #include <asm/atomic.h> |
@@ -50,11 +49,24 @@ union nf_conntrack_expect_proto { | |||
50 | /* per conntrack: application helper private data */ | 49 | /* per conntrack: application helper private data */ |
51 | union nf_conntrack_help { | 50 | union nf_conntrack_help { |
52 | /* insert conntrack helper private data (master) here */ | 51 | /* insert conntrack helper private data (master) here */ |
52 | #if defined(CONFIG_NF_CONNTRACK_FTP) || defined(CONFIG_NF_CONNTRACK_FTP_MODULE) | ||
53 | struct nf_ct_ftp_master ct_ftp_info; | 53 | struct nf_ct_ftp_master ct_ftp_info; |
54 | #endif | ||
55 | #if defined(CONFIG_NF_CONNTRACK_PPTP) || \ | ||
56 | defined(CONFIG_NF_CONNTRACK_PPTP_MODULE) | ||
54 | struct nf_ct_pptp_master ct_pptp_info; | 57 | struct nf_ct_pptp_master ct_pptp_info; |
58 | #endif | ||
59 | #if defined(CONFIG_NF_CONNTRACK_H323) || \ | ||
60 | defined(CONFIG_NF_CONNTRACK_H323_MODULE) | ||
55 | struct nf_ct_h323_master ct_h323_info; | 61 | struct nf_ct_h323_master ct_h323_info; |
62 | #endif | ||
63 | #if defined(CONFIG_NF_CONNTRACK_SANE) || \ | ||
64 | defined(CONFIG_NF_CONNTRACK_SANE_MODULE) | ||
56 | struct nf_ct_sane_master ct_sane_info; | 65 | struct nf_ct_sane_master ct_sane_info; |
66 | #endif | ||
67 | #if defined(CONFIG_NF_CONNTRACK_SIP) || defined(CONFIG_NF_CONNTRACK_SIP_MODULE) | ||
57 | struct nf_ct_sip_master ct_sip_info; | 68 | struct nf_ct_sip_master ct_sip_info; |
69 | #endif | ||
58 | }; | 70 | }; |
59 | 71 | ||
60 | #include <linux/types.h> | 72 | #include <linux/types.h> |
@@ -75,7 +87,7 @@ struct nf_conntrack_helper; | |||
75 | /* nf_conn feature for connections that have a helper */ | 87 | /* nf_conn feature for connections that have a helper */ |
76 | struct nf_conn_help { | 88 | struct nf_conn_help { |
77 | /* Helper. if any */ | 89 | /* Helper. if any */ |
78 | struct nf_conntrack_helper *helper; | 90 | struct nf_conntrack_helper __rcu *helper; |
79 | 91 | ||
80 | union nf_conntrack_help help; | 92 | union nf_conntrack_help help; |
81 | 93 | ||
@@ -116,14 +128,14 @@ struct nf_conn { | |||
116 | u_int32_t secmark; | 128 | u_int32_t secmark; |
117 | #endif | 129 | #endif |
118 | 130 | ||
119 | /* Storage reserved for other modules: */ | ||
120 | union nf_conntrack_proto proto; | ||
121 | |||
122 | /* Extensions */ | 131 | /* Extensions */ |
123 | struct nf_ct_ext *ext; | 132 | struct nf_ct_ext *ext; |
124 | #ifdef CONFIG_NET_NS | 133 | #ifdef CONFIG_NET_NS |
125 | struct net *ct_net; | 134 | struct net *ct_net; |
126 | #endif | 135 | #endif |
136 | |||
137 | /* Storage reserved for other modules, must be the last member */ | ||
138 | union nf_conntrack_proto proto; | ||
127 | }; | 139 | }; |
128 | 140 | ||
129 | static inline struct nf_conn * | 141 | static inline struct nf_conn * |
@@ -189,9 +201,9 @@ extern void nf_ct_l3proto_module_put(unsigned short l3proto); | |||
189 | * Allocate a hashtable of hlist_head (if nulls == 0), | 201 | * Allocate a hashtable of hlist_head (if nulls == 0), |
190 | * or hlist_nulls_head (if nulls == 1) | 202 | * or hlist_nulls_head (if nulls == 1) |
191 | */ | 203 | */ |
192 | extern void *nf_ct_alloc_hashtable(unsigned int *sizep, int *vmalloced, int nulls); | 204 | extern void *nf_ct_alloc_hashtable(unsigned int *sizep, int nulls); |
193 | 205 | ||
194 | extern void nf_ct_free_hashtable(void *hash, int vmalloced, unsigned int size); | 206 | extern void nf_ct_free_hashtable(void *hash, unsigned int size); |
195 | 207 | ||
196 | extern struct nf_conntrack_tuple_hash * | 208 | extern struct nf_conntrack_tuple_hash * |
197 | __nf_conntrack_find(struct net *net, u16 zone, | 209 | __nf_conntrack_find(struct net *net, u16 zone, |
@@ -295,9 +307,17 @@ static inline int nf_ct_is_untracked(const struct nf_conn *ct) | |||
295 | return test_bit(IPS_UNTRACKED_BIT, &ct->status); | 307 | return test_bit(IPS_UNTRACKED_BIT, &ct->status); |
296 | } | 308 | } |
297 | 309 | ||
310 | /* Packet is received from loopback */ | ||
311 | static inline bool nf_is_loopback_packet(const struct sk_buff *skb) | ||
312 | { | ||
313 | return skb->dev && skb->skb_iif && skb->dev->flags & IFF_LOOPBACK; | ||
314 | } | ||
315 | |||
298 | extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp); | 316 | extern int nf_conntrack_set_hashsize(const char *val, struct kernel_param *kp); |
299 | extern unsigned int nf_conntrack_htable_size; | 317 | extern unsigned int nf_conntrack_htable_size; |
300 | extern unsigned int nf_conntrack_max; | 318 | extern unsigned int nf_conntrack_max; |
319 | extern unsigned int nf_conntrack_hash_rnd; | ||
320 | void init_nf_conntrack_hash_rnd(void); | ||
301 | 321 | ||
302 | #define NF_CT_STAT_INC(net, count) \ | 322 | #define NF_CT_STAT_INC(net, count) \ |
303 | __this_cpu_inc((net)->ct.stat->count) | 323 | __this_cpu_inc((net)->ct.stat->count) |
@@ -311,5 +331,4 @@ do { \ | |||
311 | #define MODULE_ALIAS_NFCT_HELPER(helper) \ | 331 | #define MODULE_ALIAS_NFCT_HELPER(helper) \ |
312 | MODULE_ALIAS("nfct-helper-" helper) | 332 | MODULE_ALIAS("nfct-helper-" helper) |
313 | 333 | ||
314 | #endif /* __KERNEL__ */ | ||
315 | #endif /* _NF_CONNTRACK_H */ | 334 | #endif /* _NF_CONNTRACK_H */ |
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h index 96ba5f7dcab6..4283508b3e18 100644 --- a/include/net/netfilter/nf_conntrack_ecache.h +++ b/include/net/netfilter/nf_conntrack_ecache.h | |||
@@ -23,12 +23,17 @@ struct nf_conntrack_ecache { | |||
23 | static inline struct nf_conntrack_ecache * | 23 | static inline struct nf_conntrack_ecache * |
24 | nf_ct_ecache_find(const struct nf_conn *ct) | 24 | nf_ct_ecache_find(const struct nf_conn *ct) |
25 | { | 25 | { |
26 | #ifdef CONFIG_NF_CONNTRACK_EVENTS | ||
26 | return nf_ct_ext_find(ct, NF_CT_EXT_ECACHE); | 27 | return nf_ct_ext_find(ct, NF_CT_EXT_ECACHE); |
28 | #else | ||
29 | return NULL; | ||
30 | #endif | ||
27 | } | 31 | } |
28 | 32 | ||
29 | static inline struct nf_conntrack_ecache * | 33 | static inline struct nf_conntrack_ecache * |
30 | nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp) | 34 | nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp) |
31 | { | 35 | { |
36 | #ifdef CONFIG_NF_CONNTRACK_EVENTS | ||
32 | struct net *net = nf_ct_net(ct); | 37 | struct net *net = nf_ct_net(ct); |
33 | struct nf_conntrack_ecache *e; | 38 | struct nf_conntrack_ecache *e; |
34 | 39 | ||
@@ -45,6 +50,9 @@ nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp) | |||
45 | e->expmask = expmask; | 50 | e->expmask = expmask; |
46 | } | 51 | } |
47 | return e; | 52 | return e; |
53 | #else | ||
54 | return NULL; | ||
55 | #endif | ||
48 | }; | 56 | }; |
49 | 57 | ||
50 | #ifdef CONFIG_NF_CONNTRACK_EVENTS | 58 | #ifdef CONFIG_NF_CONNTRACK_EVENTS |
@@ -59,7 +67,7 @@ struct nf_ct_event_notifier { | |||
59 | int (*fcn)(unsigned int events, struct nf_ct_event *item); | 67 | int (*fcn)(unsigned int events, struct nf_ct_event *item); |
60 | }; | 68 | }; |
61 | 69 | ||
62 | extern struct nf_ct_event_notifier *nf_conntrack_event_cb; | 70 | extern struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb; |
63 | extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb); | 71 | extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb); |
64 | extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb); | 72 | extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb); |
65 | 73 | ||
@@ -77,9 +85,6 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct) | |||
77 | if (e == NULL) | 85 | if (e == NULL) |
78 | return; | 86 | return; |
79 | 87 | ||
80 | if (!(e->ctmask & (1 << event))) | ||
81 | return; | ||
82 | |||
83 | set_bit(event, &e->cache); | 88 | set_bit(event, &e->cache); |
84 | } | 89 | } |
85 | 90 | ||
@@ -159,7 +164,7 @@ struct nf_exp_event_notifier { | |||
159 | int (*fcn)(unsigned int events, struct nf_exp_event *item); | 164 | int (*fcn)(unsigned int events, struct nf_exp_event *item); |
160 | }; | 165 | }; |
161 | 166 | ||
162 | extern struct nf_exp_event_notifier *nf_expect_event_cb; | 167 | extern struct nf_exp_event_notifier __rcu *nf_expect_event_cb; |
163 | extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb); | 168 | extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb); |
164 | extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb); | 169 | extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb); |
165 | 170 | ||
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h index 11e815084fcf..0f8a8c587532 100644 --- a/include/net/netfilter/nf_conntrack_expect.h +++ b/include/net/netfilter/nf_conntrack_expect.h | |||
@@ -67,9 +67,6 @@ struct nf_conntrack_expect_policy { | |||
67 | 67 | ||
68 | #define NF_CT_EXPECT_CLASS_DEFAULT 0 | 68 | #define NF_CT_EXPECT_CLASS_DEFAULT 0 |
69 | 69 | ||
70 | #define NF_CT_EXPECT_PERMANENT 0x1 | ||
71 | #define NF_CT_EXPECT_INACTIVE 0x2 | ||
72 | |||
73 | int nf_conntrack_expect_init(struct net *net); | 70 | int nf_conntrack_expect_init(struct net *net); |
74 | void nf_conntrack_expect_fini(struct net *net); | 71 | void nf_conntrack_expect_fini(struct net *net); |
75 | 72 | ||
@@ -85,9 +82,16 @@ struct nf_conntrack_expect * | |||
85 | nf_ct_find_expectation(struct net *net, u16 zone, | 82 | nf_ct_find_expectation(struct net *net, u16 zone, |
86 | const struct nf_conntrack_tuple *tuple); | 83 | const struct nf_conntrack_tuple *tuple); |
87 | 84 | ||
88 | void nf_ct_unlink_expect(struct nf_conntrack_expect *exp); | 85 | void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp, |
86 | u32 pid, int report); | ||
87 | static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp) | ||
88 | { | ||
89 | nf_ct_unlink_expect_report(exp, 0, 0); | ||
90 | } | ||
91 | |||
89 | void nf_ct_remove_expectations(struct nf_conn *ct); | 92 | void nf_ct_remove_expectations(struct nf_conn *ct); |
90 | void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); | 93 | void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); |
94 | void nf_ct_remove_userspace_expectations(void); | ||
91 | 95 | ||
92 | /* Allocate space for an expectation: this is mandatory before calling | 96 | /* Allocate space for an expectation: this is mandatory before calling |
93 | nf_ct_expect_related. You will have to call put afterwards. */ | 97 | nf_ct_expect_related. You will have to call put afterwards. */ |
diff --git a/include/net/netfilter/nf_conntrack_extend.h b/include/net/netfilter/nf_conntrack_extend.h index 0772d296dfdb..2dcf31703acb 100644 --- a/include/net/netfilter/nf_conntrack_extend.h +++ b/include/net/netfilter/nf_conntrack_extend.h | |||
@@ -7,10 +7,19 @@ | |||
7 | 7 | ||
8 | enum nf_ct_ext_id { | 8 | enum nf_ct_ext_id { |
9 | NF_CT_EXT_HELPER, | 9 | NF_CT_EXT_HELPER, |
10 | #if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE) | ||
10 | NF_CT_EXT_NAT, | 11 | NF_CT_EXT_NAT, |
12 | #endif | ||
11 | NF_CT_EXT_ACCT, | 13 | NF_CT_EXT_ACCT, |
14 | #ifdef CONFIG_NF_CONNTRACK_EVENTS | ||
12 | NF_CT_EXT_ECACHE, | 15 | NF_CT_EXT_ECACHE, |
16 | #endif | ||
17 | #ifdef CONFIG_NF_CONNTRACK_ZONES | ||
13 | NF_CT_EXT_ZONE, | 18 | NF_CT_EXT_ZONE, |
19 | #endif | ||
20 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP | ||
21 | NF_CT_EXT_TSTAMP, | ||
22 | #endif | ||
14 | NF_CT_EXT_NUM, | 23 | NF_CT_EXT_NUM, |
15 | }; | 24 | }; |
16 | 25 | ||
@@ -19,6 +28,7 @@ enum nf_ct_ext_id { | |||
19 | #define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter | 28 | #define NF_CT_EXT_ACCT_TYPE struct nf_conn_counter |
20 | #define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache | 29 | #define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache |
21 | #define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone | 30 | #define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone |
31 | #define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp | ||
22 | 32 | ||
23 | /* Extensions: optional stuff which isn't permanently in struct. */ | 33 | /* Extensions: optional stuff which isn't permanently in struct. */ |
24 | struct nf_ct_ext { | 34 | struct nf_ct_ext { |
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h index 32c305dbdab6..f1c1311adc2c 100644 --- a/include/net/netfilter/nf_conntrack_helper.h +++ b/include/net/netfilter/nf_conntrack_helper.h | |||
@@ -63,4 +63,10 @@ static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct) | |||
63 | extern int nf_conntrack_helper_init(void); | 63 | extern int nf_conntrack_helper_init(void); |
64 | extern void nf_conntrack_helper_fini(void); | 64 | extern void nf_conntrack_helper_fini(void); |
65 | 65 | ||
66 | extern int nf_conntrack_broadcast_help(struct sk_buff *skb, | ||
67 | unsigned int protoff, | ||
68 | struct nf_conn *ct, | ||
69 | enum ip_conntrack_info ctinfo, | ||
70 | unsigned int timeout); | ||
71 | |||
66 | #endif /*_NF_CONNTRACK_HELPER_H*/ | 72 | #endif /*_NF_CONNTRACK_HELPER_H*/ |
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h index a7547611e8f1..e8010f445ae1 100644 --- a/include/net/netfilter/nf_conntrack_l3proto.h +++ b/include/net/netfilter/nf_conntrack_l3proto.h | |||
@@ -73,7 +73,7 @@ struct nf_conntrack_l3proto { | |||
73 | struct module *me; | 73 | struct module *me; |
74 | }; | 74 | }; |
75 | 75 | ||
76 | extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX]; | 76 | extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX]; |
77 | 77 | ||
78 | /* Protocol registration. */ | 78 | /* Protocol registration. */ |
79 | extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); | 79 | extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); |
diff --git a/include/net/netfilter/nf_conntrack_timestamp.h b/include/net/netfilter/nf_conntrack_timestamp.h new file mode 100644 index 000000000000..fc9c82b1f06b --- /dev/null +++ b/include/net/netfilter/nf_conntrack_timestamp.h | |||
@@ -0,0 +1,65 @@ | |||
1 | #ifndef _NF_CONNTRACK_TSTAMP_H | ||
2 | #define _NF_CONNTRACK_TSTAMP_H | ||
3 | |||
4 | #include <net/net_namespace.h> | ||
5 | #include <linux/netfilter/nf_conntrack_common.h> | ||
6 | #include <linux/netfilter/nf_conntrack_tuple_common.h> | ||
7 | #include <net/netfilter/nf_conntrack.h> | ||
8 | #include <net/netfilter/nf_conntrack_extend.h> | ||
9 | |||
10 | struct nf_conn_tstamp { | ||
11 | u_int64_t start; | ||
12 | u_int64_t stop; | ||
13 | }; | ||
14 | |||
15 | static inline | ||
16 | struct nf_conn_tstamp *nf_conn_tstamp_find(const struct nf_conn *ct) | ||
17 | { | ||
18 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP | ||
19 | return nf_ct_ext_find(ct, NF_CT_EXT_TSTAMP); | ||
20 | #else | ||
21 | return NULL; | ||
22 | #endif | ||
23 | } | ||
24 | |||
25 | static inline | ||
26 | struct nf_conn_tstamp *nf_ct_tstamp_ext_add(struct nf_conn *ct, gfp_t gfp) | ||
27 | { | ||
28 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP | ||
29 | struct net *net = nf_ct_net(ct); | ||
30 | |||
31 | if (!net->ct.sysctl_tstamp) | ||
32 | return NULL; | ||
33 | |||
34 | return nf_ct_ext_add(ct, NF_CT_EXT_TSTAMP, gfp); | ||
35 | #else | ||
36 | return NULL; | ||
37 | #endif | ||
38 | }; | ||
39 | |||
40 | static inline bool nf_ct_tstamp_enabled(struct net *net) | ||
41 | { | ||
42 | return net->ct.sysctl_tstamp != 0; | ||
43 | } | ||
44 | |||
45 | static inline void nf_ct_set_tstamp(struct net *net, bool enable) | ||
46 | { | ||
47 | net->ct.sysctl_tstamp = enable; | ||
48 | } | ||
49 | |||
50 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP | ||
51 | extern int nf_conntrack_tstamp_init(struct net *net); | ||
52 | extern void nf_conntrack_tstamp_fini(struct net *net); | ||
53 | #else | ||
54 | static inline int nf_conntrack_tstamp_init(struct net *net) | ||
55 | { | ||
56 | return 0; | ||
57 | } | ||
58 | |||
59 | static inline void nf_conntrack_tstamp_fini(struct net *net) | ||
60 | { | ||
61 | return; | ||
62 | } | ||
63 | #endif /* CONFIG_NF_CONNTRACK_TIMESTAMP */ | ||
64 | |||
65 | #endif /* _NF_CONNTRACK_TSTAMP_H */ | ||
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h index 4ee44c84a304..7ca6bdd5bae6 100644 --- a/include/net/netfilter/nf_conntrack_tuple.h +++ b/include/net/netfilter/nf_conntrack_tuple.h | |||
@@ -104,8 +104,6 @@ struct nf_conntrack_tuple_mask { | |||
104 | } src; | 104 | } src; |
105 | }; | 105 | }; |
106 | 106 | ||
107 | #ifdef __KERNEL__ | ||
108 | |||
109 | static inline void nf_ct_dump_tuple_ip(const struct nf_conntrack_tuple *t) | 107 | static inline void nf_ct_dump_tuple_ip(const struct nf_conntrack_tuple *t) |
110 | { | 108 | { |
111 | #ifdef DEBUG | 109 | #ifdef DEBUG |
@@ -148,8 +146,6 @@ struct nf_conntrack_tuple_hash { | |||
148 | struct nf_conntrack_tuple tuple; | 146 | struct nf_conntrack_tuple tuple; |
149 | }; | 147 | }; |
150 | 148 | ||
151 | #endif /* __KERNEL__ */ | ||
152 | |||
153 | static inline bool __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, | 149 | static inline bool __nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, |
154 | const struct nf_conntrack_tuple *t2) | 150 | const struct nf_conntrack_tuple *t2) |
155 | { | 151 | { |
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h index f5f09f032a90..0346b0070864 100644 --- a/include/net/netfilter/nf_nat.h +++ b/include/net/netfilter/nf_nat.h | |||
@@ -48,7 +48,6 @@ struct nf_nat_multi_range_compat { | |||
48 | struct nf_nat_range range[1]; | 48 | struct nf_nat_range range[1]; |
49 | }; | 49 | }; |
50 | 50 | ||
51 | #ifdef __KERNEL__ | ||
52 | #include <linux/list.h> | 51 | #include <linux/list.h> |
53 | #include <linux/netfilter/nf_conntrack_pptp.h> | 52 | #include <linux/netfilter/nf_conntrack_pptp.h> |
54 | #include <net/netfilter/nf_conntrack_extend.h> | 53 | #include <net/netfilter/nf_conntrack_extend.h> |
@@ -56,7 +55,9 @@ struct nf_nat_multi_range_compat { | |||
56 | /* per conntrack: nat application helper private data */ | 55 | /* per conntrack: nat application helper private data */ |
57 | union nf_conntrack_nat_help { | 56 | union nf_conntrack_nat_help { |
58 | /* insert nat helper private data here */ | 57 | /* insert nat helper private data here */ |
58 | #if defined(CONFIG_NF_NAT_PPTP) || defined(CONFIG_NF_NAT_PPTP_MODULE) | ||
59 | struct nf_nat_pptp nat_pptp_info; | 59 | struct nf_nat_pptp nat_pptp_info; |
60 | #endif | ||
60 | }; | 61 | }; |
61 | 62 | ||
62 | struct nf_conn; | 63 | struct nf_conn; |
@@ -84,10 +85,11 @@ extern int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, | |||
84 | 85 | ||
85 | static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct) | 86 | static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct) |
86 | { | 87 | { |
88 | #if defined(CONFIG_NF_NAT) || defined(CONFIG_NF_NAT_MODULE) | ||
87 | return nf_ct_ext_find(ct, NF_CT_EXT_NAT); | 89 | return nf_ct_ext_find(ct, NF_CT_EXT_NAT); |
90 | #else | ||
91 | return NULL; | ||
92 | #endif | ||
88 | } | 93 | } |
89 | 94 | ||
90 | #else /* !__KERNEL__: iptables wants this to compile. */ | ||
91 | #define nf_nat_multi_range nf_nat_multi_range_compat | ||
92 | #endif /*__KERNEL__*/ | ||
93 | #endif | 95 | #endif |
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h index 33602ab66190..3dc7b98effeb 100644 --- a/include/net/netfilter/nf_nat_core.h +++ b/include/net/netfilter/nf_nat_core.h | |||
@@ -21,9 +21,9 @@ static inline int nf_nat_initialized(struct nf_conn *ct, | |||
21 | enum nf_nat_manip_type manip) | 21 | enum nf_nat_manip_type manip) |
22 | { | 22 | { |
23 | if (manip == IP_NAT_MANIP_SRC) | 23 | if (manip == IP_NAT_MANIP_SRC) |
24 | return test_bit(IPS_SRC_NAT_DONE_BIT, &ct->status); | 24 | return ct->status & IPS_SRC_NAT_DONE; |
25 | else | 25 | else |
26 | return test_bit(IPS_DST_NAT_DONE_BIT, &ct->status); | 26 | return ct->status & IPS_DST_NAT_DONE; |
27 | } | 27 | } |
28 | 28 | ||
29 | struct nlattr; | 29 | struct nlattr; |
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h index df17bac46bf5..93cc90d28e66 100644 --- a/include/net/netfilter/nf_nat_protocol.h +++ b/include/net/netfilter/nf_nat_protocol.h | |||
@@ -45,9 +45,6 @@ struct nf_nat_protocol { | |||
45 | extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto); | 45 | extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto); |
46 | extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto); | 46 | extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto); |
47 | 47 | ||
48 | extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol); | ||
49 | extern void nf_nat_proto_put(const struct nf_nat_protocol *proto); | ||
50 | |||
51 | /* Built-in protocols. */ | 48 | /* Built-in protocols. */ |
52 | extern const struct nf_nat_protocol nf_nat_protocol_tcp; | 49 | extern const struct nf_nat_protocol nf_nat_protocol_tcp; |
53 | extern const struct nf_nat_protocol nf_nat_protocol_udp; | 50 | extern const struct nf_nat_protocol nf_nat_protocol_udp; |
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h index 208b46f4d6d2..e505358d8999 100644 --- a/include/net/netfilter/nf_tproxy_core.h +++ b/include/net/netfilter/nf_tproxy_core.h | |||
@@ -5,28 +5,204 @@ | |||
5 | #include <linux/in.h> | 5 | #include <linux/in.h> |
6 | #include <linux/skbuff.h> | 6 | #include <linux/skbuff.h> |
7 | #include <net/sock.h> | 7 | #include <net/sock.h> |
8 | #include <net/inet_sock.h> | 8 | #include <net/inet_hashtables.h> |
9 | #include <net/inet6_hashtables.h> | ||
9 | #include <net/tcp.h> | 10 | #include <net/tcp.h> |
10 | 11 | ||
12 | #define NFT_LOOKUP_ANY 0 | ||
13 | #define NFT_LOOKUP_LISTENER 1 | ||
14 | #define NFT_LOOKUP_ESTABLISHED 2 | ||
15 | |||
11 | /* look up and get a reference to a matching socket */ | 16 | /* look up and get a reference to a matching socket */ |
12 | extern struct sock * | 17 | |
18 | |||
19 | /* This function is used by the 'TPROXY' target and the 'socket' | ||
20 | * match. The following lookups are supported: | ||
21 | * | ||
22 | * Explicit TProxy target rule | ||
23 | * =========================== | ||
24 | * | ||
25 | * This is used when the user wants to intercept a connection matching | ||
26 | * an explicit iptables rule. In this case the sockets are assumed | ||
27 | * matching in preference order: | ||
28 | * | ||
29 | * - match: if there's a fully established connection matching the | ||
30 | * _packet_ tuple, it is returned, assuming the redirection | ||
31 | * already took place and we process a packet belonging to an | ||
32 | * established connection | ||
33 | * | ||
34 | * - match: if there's a listening socket matching the redirection | ||
35 | * (e.g. on-port & on-ip of the connection), it is returned, | ||
36 | * regardless if it was bound to 0.0.0.0 or an explicit | ||
37 | * address. The reasoning is that if there's an explicit rule, it | ||
38 | * does not really matter if the listener is bound to an interface | ||
39 | * or to 0. The user already stated that he wants redirection | ||
40 | * (since he added the rule). | ||
41 | * | ||
42 | * "socket" match based redirection (no specific rule) | ||
43 | * =================================================== | ||
44 | * | ||
45 | * There are connections with dynamic endpoints (e.g. FTP data | ||
46 | * connection) that the user is unable to add explicit rules | ||
47 | * for. These are taken care of by a generic "socket" rule. It is | ||
48 | * assumed that the proxy application is trusted to open such | ||
49 | * connections without explicit iptables rule (except of course the | ||
50 | * generic 'socket' rule). In this case the following sockets are | ||
51 | * matched in preference order: | ||
52 | * | ||
53 | * - match: if there's a fully established connection matching the | ||
54 | * _packet_ tuple | ||
55 | * | ||
56 | * - match: if there's a non-zero bound listener (possibly with a | ||
57 | * non-local address) We don't accept zero-bound listeners, since | ||
58 | * then local services could intercept traffic going through the | ||
59 | * box. | ||
60 | * | ||
61 | * Please note that there's an overlap between what a TPROXY target | ||
62 | * and a socket match will match. Normally if you have both rules the | ||
63 | * "socket" match will be the first one, effectively all packets | ||
64 | * belonging to established connections going through that one. | ||
65 | */ | ||
66 | static inline struct sock * | ||
13 | nf_tproxy_get_sock_v4(struct net *net, const u8 protocol, | 67 | nf_tproxy_get_sock_v4(struct net *net, const u8 protocol, |
14 | const __be32 saddr, const __be32 daddr, | 68 | const __be32 saddr, const __be32 daddr, |
15 | const __be16 sport, const __be16 dport, | 69 | const __be16 sport, const __be16 dport, |
16 | const struct net_device *in, bool listening); | 70 | const struct net_device *in, int lookup_type) |
71 | { | ||
72 | struct sock *sk; | ||
73 | |||
74 | /* look up socket */ | ||
75 | switch (protocol) { | ||
76 | case IPPROTO_TCP: | ||
77 | switch (lookup_type) { | ||
78 | case NFT_LOOKUP_ANY: | ||
79 | sk = __inet_lookup(net, &tcp_hashinfo, | ||
80 | saddr, sport, daddr, dport, | ||
81 | in->ifindex); | ||
82 | break; | ||
83 | case NFT_LOOKUP_LISTENER: | ||
84 | sk = inet_lookup_listener(net, &tcp_hashinfo, | ||
85 | daddr, dport, | ||
86 | in->ifindex); | ||
17 | 87 | ||
18 | static inline void | 88 | /* NOTE: we return listeners even if bound to |
19 | nf_tproxy_put_sock(struct sock *sk) | 89 | * 0.0.0.0, those are filtered out in |
90 | * xt_socket, since xt_TPROXY needs 0 bound | ||
91 | * listeners too */ | ||
92 | |||
93 | break; | ||
94 | case NFT_LOOKUP_ESTABLISHED: | ||
95 | sk = inet_lookup_established(net, &tcp_hashinfo, | ||
96 | saddr, sport, daddr, dport, | ||
97 | in->ifindex); | ||
98 | break; | ||
99 | default: | ||
100 | WARN_ON(1); | ||
101 | sk = NULL; | ||
102 | break; | ||
103 | } | ||
104 | break; | ||
105 | case IPPROTO_UDP: | ||
106 | sk = udp4_lib_lookup(net, saddr, sport, daddr, dport, | ||
107 | in->ifindex); | ||
108 | if (sk && lookup_type != NFT_LOOKUP_ANY) { | ||
109 | int connected = (sk->sk_state == TCP_ESTABLISHED); | ||
110 | int wildcard = (inet_sk(sk)->inet_rcv_saddr == 0); | ||
111 | |||
112 | /* NOTE: we return listeners even if bound to | ||
113 | * 0.0.0.0, those are filtered out in | ||
114 | * xt_socket, since xt_TPROXY needs 0 bound | ||
115 | * listeners too */ | ||
116 | if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) || | ||
117 | (lookup_type == NFT_LOOKUP_LISTENER && connected)) { | ||
118 | sock_put(sk); | ||
119 | sk = NULL; | ||
120 | } | ||
121 | } | ||
122 | break; | ||
123 | default: | ||
124 | WARN_ON(1); | ||
125 | sk = NULL; | ||
126 | } | ||
127 | |||
128 | pr_debug("tproxy socket lookup: proto %u %08x:%u -> %08x:%u, lookup type: %d, sock %p\n", | ||
129 | protocol, ntohl(saddr), ntohs(sport), ntohl(daddr), ntohs(dport), lookup_type, sk); | ||
130 | |||
131 | return sk; | ||
132 | } | ||
133 | |||
134 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
135 | static inline struct sock * | ||
136 | nf_tproxy_get_sock_v6(struct net *net, const u8 protocol, | ||
137 | const struct in6_addr *saddr, const struct in6_addr *daddr, | ||
138 | const __be16 sport, const __be16 dport, | ||
139 | const struct net_device *in, int lookup_type) | ||
20 | { | 140 | { |
21 | /* TIME_WAIT inet sockets have to be handled differently */ | 141 | struct sock *sk; |
22 | if ((sk->sk_protocol == IPPROTO_TCP) && (sk->sk_state == TCP_TIME_WAIT)) | 142 | |
23 | inet_twsk_put(inet_twsk(sk)); | 143 | /* look up socket */ |
24 | else | 144 | switch (protocol) { |
25 | sock_put(sk); | 145 | case IPPROTO_TCP: |
146 | switch (lookup_type) { | ||
147 | case NFT_LOOKUP_ANY: | ||
148 | sk = inet6_lookup(net, &tcp_hashinfo, | ||
149 | saddr, sport, daddr, dport, | ||
150 | in->ifindex); | ||
151 | break; | ||
152 | case NFT_LOOKUP_LISTENER: | ||
153 | sk = inet6_lookup_listener(net, &tcp_hashinfo, | ||
154 | daddr, ntohs(dport), | ||
155 | in->ifindex); | ||
156 | |||
157 | /* NOTE: we return listeners even if bound to | ||
158 | * 0.0.0.0, those are filtered out in | ||
159 | * xt_socket, since xt_TPROXY needs 0 bound | ||
160 | * listeners too */ | ||
161 | |||
162 | break; | ||
163 | case NFT_LOOKUP_ESTABLISHED: | ||
164 | sk = __inet6_lookup_established(net, &tcp_hashinfo, | ||
165 | saddr, sport, daddr, ntohs(dport), | ||
166 | in->ifindex); | ||
167 | break; | ||
168 | default: | ||
169 | WARN_ON(1); | ||
170 | sk = NULL; | ||
171 | break; | ||
172 | } | ||
173 | break; | ||
174 | case IPPROTO_UDP: | ||
175 | sk = udp6_lib_lookup(net, saddr, sport, daddr, dport, | ||
176 | in->ifindex); | ||
177 | if (sk && lookup_type != NFT_LOOKUP_ANY) { | ||
178 | int connected = (sk->sk_state == TCP_ESTABLISHED); | ||
179 | int wildcard = ipv6_addr_any(&inet6_sk(sk)->rcv_saddr); | ||
180 | |||
181 | /* NOTE: we return listeners even if bound to | ||
182 | * 0.0.0.0, those are filtered out in | ||
183 | * xt_socket, since xt_TPROXY needs 0 bound | ||
184 | * listeners too */ | ||
185 | if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) || | ||
186 | (lookup_type == NFT_LOOKUP_LISTENER && connected)) { | ||
187 | sock_put(sk); | ||
188 | sk = NULL; | ||
189 | } | ||
190 | } | ||
191 | break; | ||
192 | default: | ||
193 | WARN_ON(1); | ||
194 | sk = NULL; | ||
195 | } | ||
196 | |||
197 | pr_debug("tproxy socket lookup: proto %u %pI6:%u -> %pI6:%u, lookup type: %d, sock %p\n", | ||
198 | protocol, saddr, ntohs(sport), daddr, ntohs(dport), lookup_type, sk); | ||
199 | |||
200 | return sk; | ||
26 | } | 201 | } |
202 | #endif | ||
27 | 203 | ||
28 | /* assign a socket to the skb -- consumes sk */ | 204 | /* assign a socket to the skb -- consumes sk */ |
29 | int | 205 | void |
30 | nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk); | 206 | nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk); |
31 | 207 | ||
32 | #endif | 208 | #endif |
diff --git a/include/net/netfilter/xt_log.h b/include/net/netfilter/xt_log.h new file mode 100644 index 000000000000..0dfb34a5b53c --- /dev/null +++ b/include/net/netfilter/xt_log.h | |||
@@ -0,0 +1,54 @@ | |||
1 | #define S_SIZE (1024 - (sizeof(unsigned int) + 1)) | ||
2 | |||
3 | struct sbuff { | ||
4 | unsigned int count; | ||
5 | char buf[S_SIZE + 1]; | ||
6 | }; | ||
7 | static struct sbuff emergency, *emergency_ptr = &emergency; | ||
8 | |||
9 | static int sb_add(struct sbuff *m, const char *f, ...) | ||
10 | { | ||
11 | va_list args; | ||
12 | int len; | ||
13 | |||
14 | if (likely(m->count < S_SIZE)) { | ||
15 | va_start(args, f); | ||
16 | len = vsnprintf(m->buf + m->count, S_SIZE - m->count, f, args); | ||
17 | va_end(args); | ||
18 | if (likely(m->count + len < S_SIZE)) { | ||
19 | m->count += len; | ||
20 | return 0; | ||
21 | } | ||
22 | } | ||
23 | m->count = S_SIZE; | ||
24 | printk_once(KERN_ERR KBUILD_MODNAME " please increase S_SIZE\n"); | ||
25 | return -1; | ||
26 | } | ||
27 | |||
28 | static struct sbuff *sb_open(void) | ||
29 | { | ||
30 | struct sbuff *m = kmalloc(sizeof(*m), GFP_ATOMIC); | ||
31 | |||
32 | if (unlikely(!m)) { | ||
33 | local_bh_disable(); | ||
34 | do { | ||
35 | m = xchg(&emergency_ptr, NULL); | ||
36 | } while (!m); | ||
37 | } | ||
38 | m->count = 0; | ||
39 | return m; | ||
40 | } | ||
41 | |||
42 | static void sb_close(struct sbuff *m) | ||
43 | { | ||
44 | m->buf[m->count] = 0; | ||
45 | printk("%s\n", m->buf); | ||
46 | |||
47 | if (likely(m != &emergency)) | ||
48 | kfree(m); | ||
49 | else { | ||
50 | xchg(&emergency_ptr, m); | ||
51 | local_bh_enable(); | ||
52 | } | ||
53 | } | ||
54 | |||
diff --git a/include/net/netlink.h b/include/net/netlink.h index f3b201d335b3..02740a94f108 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -225,13 +225,15 @@ extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb, | |||
225 | u32 pid, unsigned int group, int report, | 225 | u32 pid, unsigned int group, int report, |
226 | gfp_t flags); | 226 | gfp_t flags); |
227 | 227 | ||
228 | extern int nla_validate(struct nlattr *head, int len, int maxtype, | 228 | extern int nla_validate(const struct nlattr *head, |
229 | int len, int maxtype, | ||
229 | const struct nla_policy *policy); | 230 | const struct nla_policy *policy); |
230 | extern int nla_parse(struct nlattr *tb[], int maxtype, | 231 | extern int nla_parse(struct nlattr **tb, int maxtype, |
231 | struct nlattr *head, int len, | 232 | const struct nlattr *head, int len, |
232 | const struct nla_policy *policy); | 233 | const struct nla_policy *policy); |
233 | extern int nla_policy_len(const struct nla_policy *, int); | 234 | extern int nla_policy_len(const struct nla_policy *, int); |
234 | extern struct nlattr * nla_find(struct nlattr *head, int len, int attrtype); | 235 | extern struct nlattr * nla_find(const struct nlattr *head, |
236 | int len, int attrtype); | ||
235 | extern size_t nla_strlcpy(char *dst, const struct nlattr *nla, | 237 | extern size_t nla_strlcpy(char *dst, const struct nlattr *nla, |
236 | size_t dstsize); | 238 | size_t dstsize); |
237 | extern int nla_memcpy(void *dest, const struct nlattr *src, int count); | 239 | extern int nla_memcpy(void *dest, const struct nlattr *src, int count); |
@@ -288,7 +290,7 @@ static inline int nlmsg_padlen(int payload) | |||
288 | 290 | ||
289 | /** | 291 | /** |
290 | * nlmsg_data - head of message payload | 292 | * nlmsg_data - head of message payload |
291 | * @nlh: netlink messsage header | 293 | * @nlh: netlink message header |
292 | */ | 294 | */ |
293 | static inline void *nlmsg_data(const struct nlmsghdr *nlh) | 295 | static inline void *nlmsg_data(const struct nlmsghdr *nlh) |
294 | { | 296 | { |
@@ -346,7 +348,8 @@ static inline int nlmsg_ok(const struct nlmsghdr *nlh, int remaining) | |||
346 | * Returns the next netlink message in the message stream and | 348 | * Returns the next netlink message in the message stream and |
347 | * decrements remaining by the size of the current message. | 349 | * decrements remaining by the size of the current message. |
348 | */ | 350 | */ |
349 | static inline struct nlmsghdr *nlmsg_next(struct nlmsghdr *nlh, int *remaining) | 351 | static inline struct nlmsghdr * |
352 | nlmsg_next(const struct nlmsghdr *nlh, int *remaining) | ||
350 | { | 353 | { |
351 | int totlen = NLMSG_ALIGN(nlh->nlmsg_len); | 354 | int totlen = NLMSG_ALIGN(nlh->nlmsg_len); |
352 | 355 | ||
@@ -384,7 +387,7 @@ static inline int nlmsg_parse(const struct nlmsghdr *nlh, int hdrlen, | |||
384 | * | 387 | * |
385 | * Returns the first attribute which matches the specified type. | 388 | * Returns the first attribute which matches the specified type. |
386 | */ | 389 | */ |
387 | static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, | 390 | static inline struct nlattr *nlmsg_find_attr(const struct nlmsghdr *nlh, |
388 | int hdrlen, int attrtype) | 391 | int hdrlen, int attrtype) |
389 | { | 392 | { |
390 | return nla_find(nlmsg_attrdata(nlh, hdrlen), | 393 | return nla_find(nlmsg_attrdata(nlh, hdrlen), |
@@ -398,7 +401,8 @@ static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, | |||
398 | * @maxtype: maximum attribute type to be expected | 401 | * @maxtype: maximum attribute type to be expected |
399 | * @policy: validation policy | 402 | * @policy: validation policy |
400 | */ | 403 | */ |
401 | static inline int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, | 404 | static inline int nlmsg_validate(const struct nlmsghdr *nlh, |
405 | int hdrlen, int maxtype, | ||
402 | const struct nla_policy *policy) | 406 | const struct nla_policy *policy) |
403 | { | 407 | { |
404 | if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) | 408 | if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) |
@@ -727,7 +731,8 @@ static inline struct nlattr *nla_next(const struct nlattr *nla, int *remaining) | |||
727 | * | 731 | * |
728 | * Returns the first attribute which matches the specified type. | 732 | * Returns the first attribute which matches the specified type. |
729 | */ | 733 | */ |
730 | static inline struct nlattr *nla_find_nested(struct nlattr *nla, int attrtype) | 734 | static inline struct nlattr * |
735 | nla_find_nested(const struct nlattr *nla, int attrtype) | ||
731 | { | 736 | { |
732 | return nla_find(nla_data(nla), nla_len(nla), attrtype); | 737 | return nla_find(nla_data(nla), nla_len(nla), attrtype); |
733 | } | 738 | } |
@@ -851,18 +856,27 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype, | |||
851 | #define NLA_PUT_BE16(skb, attrtype, value) \ | 856 | #define NLA_PUT_BE16(skb, attrtype, value) \ |
852 | NLA_PUT_TYPE(skb, __be16, attrtype, value) | 857 | NLA_PUT_TYPE(skb, __be16, attrtype, value) |
853 | 858 | ||
859 | #define NLA_PUT_NET16(skb, attrtype, value) \ | ||
860 | NLA_PUT_BE16(skb, attrtype | NLA_F_NET_BYTEORDER, value) | ||
861 | |||
854 | #define NLA_PUT_U32(skb, attrtype, value) \ | 862 | #define NLA_PUT_U32(skb, attrtype, value) \ |
855 | NLA_PUT_TYPE(skb, u32, attrtype, value) | 863 | NLA_PUT_TYPE(skb, u32, attrtype, value) |
856 | 864 | ||
857 | #define NLA_PUT_BE32(skb, attrtype, value) \ | 865 | #define NLA_PUT_BE32(skb, attrtype, value) \ |
858 | NLA_PUT_TYPE(skb, __be32, attrtype, value) | 866 | NLA_PUT_TYPE(skb, __be32, attrtype, value) |
859 | 867 | ||
868 | #define NLA_PUT_NET32(skb, attrtype, value) \ | ||
869 | NLA_PUT_BE32(skb, attrtype | NLA_F_NET_BYTEORDER, value) | ||
870 | |||
860 | #define NLA_PUT_U64(skb, attrtype, value) \ | 871 | #define NLA_PUT_U64(skb, attrtype, value) \ |
861 | NLA_PUT_TYPE(skb, u64, attrtype, value) | 872 | NLA_PUT_TYPE(skb, u64, attrtype, value) |
862 | 873 | ||
863 | #define NLA_PUT_BE64(skb, attrtype, value) \ | 874 | #define NLA_PUT_BE64(skb, attrtype, value) \ |
864 | NLA_PUT_TYPE(skb, __be64, attrtype, value) | 875 | NLA_PUT_TYPE(skb, __be64, attrtype, value) |
865 | 876 | ||
877 | #define NLA_PUT_NET64(skb, attrtype, value) \ | ||
878 | NLA_PUT_BE64(skb, attrtype | NLA_F_NET_BYTEORDER, value) | ||
879 | |||
866 | #define NLA_PUT_STRING(skb, attrtype, value) \ | 880 | #define NLA_PUT_STRING(skb, attrtype, value) \ |
867 | NLA_PUT(skb, attrtype, strlen(value) + 1, value) | 881 | NLA_PUT(skb, attrtype, strlen(value) + 1, value) |
868 | 882 | ||
@@ -1032,7 +1046,7 @@ static inline void nla_nest_cancel(struct sk_buff *skb, struct nlattr *start) | |||
1032 | * | 1046 | * |
1033 | * Returns 0 on success or a negative error code. | 1047 | * Returns 0 on success or a negative error code. |
1034 | */ | 1048 | */ |
1035 | static inline int nla_validate_nested(struct nlattr *start, int maxtype, | 1049 | static inline int nla_validate_nested(const struct nlattr *start, int maxtype, |
1036 | const struct nla_policy *policy) | 1050 | const struct nla_policy *policy) |
1037 | { | 1051 | { |
1038 | return nla_validate(nla_data(start), nla_len(start), maxtype, policy); | 1052 | return nla_validate(nla_data(start), nla_len(start), maxtype, policy); |
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h index d4958d4c6574..341eb089349e 100644 --- a/include/net/netns/conntrack.h +++ b/include/net/netns/conntrack.h | |||
@@ -21,15 +21,15 @@ struct netns_ct { | |||
21 | int sysctl_events; | 21 | int sysctl_events; |
22 | unsigned int sysctl_events_retry_timeout; | 22 | unsigned int sysctl_events_retry_timeout; |
23 | int sysctl_acct; | 23 | int sysctl_acct; |
24 | int sysctl_tstamp; | ||
24 | int sysctl_checksum; | 25 | int sysctl_checksum; |
25 | unsigned int sysctl_log_invalid; /* Log invalid packets */ | 26 | unsigned int sysctl_log_invalid; /* Log invalid packets */ |
26 | #ifdef CONFIG_SYSCTL | 27 | #ifdef CONFIG_SYSCTL |
27 | struct ctl_table_header *sysctl_header; | 28 | struct ctl_table_header *sysctl_header; |
28 | struct ctl_table_header *acct_sysctl_header; | 29 | struct ctl_table_header *acct_sysctl_header; |
30 | struct ctl_table_header *tstamp_sysctl_header; | ||
29 | struct ctl_table_header *event_sysctl_header; | 31 | struct ctl_table_header *event_sysctl_header; |
30 | #endif | 32 | #endif |
31 | int hash_vmalloc; | ||
32 | int expect_vmalloc; | ||
33 | char *slabname; | 33 | char *slabname; |
34 | }; | 34 | }; |
35 | #endif | 35 | #endif |
diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h index 81a31c0db3e7..3419bf5cd154 100644 --- a/include/net/netns/generic.h +++ b/include/net/netns/generic.h | |||
@@ -30,7 +30,7 @@ struct net_generic { | |||
30 | void *ptr[0]; | 30 | void *ptr[0]; |
31 | }; | 31 | }; |
32 | 32 | ||
33 | static inline void *net_generic(struct net *net, int id) | 33 | static inline void *net_generic(const struct net *net, int id) |
34 | { | 34 | { |
35 | struct net_generic *ng; | 35 | struct net_generic *ng; |
36 | void *ptr; | 36 | void *ptr; |
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index d68c3f121774..d786b4fc02a4 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h | |||
@@ -43,7 +43,6 @@ struct netns_ipv4 { | |||
43 | struct xt_table *nat_table; | 43 | struct xt_table *nat_table; |
44 | struct hlist_head *nat_bysource; | 44 | struct hlist_head *nat_bysource; |
45 | unsigned int nat_htable_size; | 45 | unsigned int nat_htable_size; |
46 | int nat_vmalloced; | ||
47 | #endif | 46 | #endif |
48 | 47 | ||
49 | int sysctl_icmp_echo_ignore_all; | 48 | int sysctl_icmp_echo_ignore_all; |
@@ -55,7 +54,10 @@ struct netns_ipv4 { | |||
55 | int sysctl_rt_cache_rebuild_count; | 54 | int sysctl_rt_cache_rebuild_count; |
56 | int current_rt_cache_rebuild_count; | 55 | int current_rt_cache_rebuild_count; |
57 | 56 | ||
57 | unsigned int sysctl_ping_group_range[2]; | ||
58 | |||
58 | atomic_t rt_genid; | 59 | atomic_t rt_genid; |
60 | atomic_t dev_addr_genid; | ||
59 | 61 | ||
60 | #ifdef CONFIG_IP_MROUTE | 62 | #ifdef CONFIG_IP_MROUTE |
61 | #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES | 63 | #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES |
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h index 74f119a2829a..748f91f87cd5 100644 --- a/include/net/netns/xfrm.h +++ b/include/net/netns/xfrm.h | |||
@@ -43,10 +43,6 @@ struct netns_xfrm { | |||
43 | unsigned int policy_count[XFRM_POLICY_MAX * 2]; | 43 | unsigned int policy_count[XFRM_POLICY_MAX * 2]; |
44 | struct work_struct policy_hash_work; | 44 | struct work_struct policy_hash_work; |
45 | 45 | ||
46 | struct dst_ops xfrm4_dst_ops; | ||
47 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
48 | struct dst_ops xfrm6_dst_ops; | ||
49 | #endif | ||
50 | 46 | ||
51 | struct sock *nlsk; | 47 | struct sock *nlsk; |
52 | struct sock *nlsk_stash; | 48 | struct sock *nlsk_stash; |
@@ -58,6 +54,11 @@ struct netns_xfrm { | |||
58 | #ifdef CONFIG_SYSCTL | 54 | #ifdef CONFIG_SYSCTL |
59 | struct ctl_table_header *sysctl_hdr; | 55 | struct ctl_table_header *sysctl_hdr; |
60 | #endif | 56 | #endif |
57 | |||
58 | struct dst_ops xfrm4_dst_ops; | ||
59 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
60 | struct dst_ops xfrm6_dst_ops; | ||
61 | #endif | ||
61 | }; | 62 | }; |
62 | 63 | ||
63 | #endif | 64 | #endif |
diff --git a/include/net/phonet/pep.h b/include/net/phonet/pep.h index 35672b1cf44a..b669fe6dbc3b 100644 --- a/include/net/phonet/pep.h +++ b/include/net/phonet/pep.h | |||
@@ -28,7 +28,6 @@ struct pep_sock { | |||
28 | 28 | ||
29 | /* XXX: union-ify listening vs connected stuff ? */ | 29 | /* XXX: union-ify listening vs connected stuff ? */ |
30 | /* Listening socket stuff: */ | 30 | /* Listening socket stuff: */ |
31 | struct hlist_head ackq; | ||
32 | struct hlist_head hlist; | 31 | struct hlist_head hlist; |
33 | 32 | ||
34 | /* Connected socket stuff: */ | 33 | /* Connected socket stuff: */ |
@@ -77,6 +76,11 @@ static inline struct pnpipehdr *pnp_hdr(struct sk_buff *skb) | |||
77 | #define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4) | 76 | #define MAX_PNPIPE_HEADER (MAX_PHONET_HEADER + 4) |
78 | 77 | ||
79 | enum { | 78 | enum { |
79 | PNS_PIPE_CREATE_REQ = 0x00, | ||
80 | PNS_PIPE_CREATE_RESP, | ||
81 | PNS_PIPE_REMOVE_REQ, | ||
82 | PNS_PIPE_REMOVE_RESP, | ||
83 | |||
80 | PNS_PIPE_DATA = 0x20, | 84 | PNS_PIPE_DATA = 0x20, |
81 | PNS_PIPE_ALIGNED_DATA, | 85 | PNS_PIPE_ALIGNED_DATA, |
82 | 86 | ||
@@ -149,6 +153,7 @@ enum { | |||
149 | PN_LEGACY_FLOW_CONTROL, | 153 | PN_LEGACY_FLOW_CONTROL, |
150 | PN_ONE_CREDIT_FLOW_CONTROL, | 154 | PN_ONE_CREDIT_FLOW_CONTROL, |
151 | PN_MULTI_CREDIT_FLOW_CONTROL, | 155 | PN_MULTI_CREDIT_FLOW_CONTROL, |
156 | PN_MAX_FLOW_CONTROL, | ||
152 | }; | 157 | }; |
153 | 158 | ||
154 | #define pn_flow_safe(fc) ((fc) >> 1) | 159 | #define pn_flow_safe(fc) ((fc) >> 1) |
diff --git a/include/net/phonet/phonet.h b/include/net/phonet/phonet.h index 7b114079a51b..68e509750caa 100644 --- a/include/net/phonet/phonet.h +++ b/include/net/phonet/phonet.h | |||
@@ -36,6 +36,7 @@ | |||
36 | struct pn_sock { | 36 | struct pn_sock { |
37 | struct sock sk; | 37 | struct sock sk; |
38 | u16 sobject; | 38 | u16 sobject; |
39 | u16 dobject; | ||
39 | u8 resource; | 40 | u8 resource; |
40 | }; | 41 | }; |
41 | 42 | ||
@@ -54,6 +55,11 @@ void pn_sock_hash(struct sock *sk); | |||
54 | void pn_sock_unhash(struct sock *sk); | 55 | void pn_sock_unhash(struct sock *sk); |
55 | int pn_sock_get_port(struct sock *sk, unsigned short sport); | 56 | int pn_sock_get_port(struct sock *sk, unsigned short sport); |
56 | 57 | ||
58 | struct sock *pn_find_sock_by_res(struct net *net, u8 res); | ||
59 | int pn_sock_bind_res(struct sock *sock, u8 res); | ||
60 | int pn_sock_unbind_res(struct sock *sk, u8 res); | ||
61 | void pn_sock_unbind_all_res(struct sock *sk); | ||
62 | |||
57 | int pn_skb_send(struct sock *sk, struct sk_buff *skb, | 63 | int pn_skb_send(struct sock *sk, struct sk_buff *skb, |
58 | const struct sockaddr_pn *target); | 64 | const struct sockaddr_pn *target); |
59 | 65 | ||
@@ -102,8 +108,8 @@ struct phonet_protocol { | |||
102 | int sock_type; | 108 | int sock_type; |
103 | }; | 109 | }; |
104 | 110 | ||
105 | int phonet_proto_register(int protocol, struct phonet_protocol *pp); | 111 | int phonet_proto_register(unsigned int protocol, struct phonet_protocol *pp); |
106 | void phonet_proto_unregister(int protocol, struct phonet_protocol *pp); | 112 | void phonet_proto_unregister(unsigned int protocol, struct phonet_protocol *pp); |
107 | 113 | ||
108 | int phonet_sysctl_init(void); | 114 | int phonet_sysctl_init(void); |
109 | void phonet_sysctl_exit(void); | 115 | void phonet_sysctl_exit(void); |
diff --git a/include/net/phonet/pn_dev.h b/include/net/phonet/pn_dev.h index 2d16783d5e20..8639de5750f6 100644 --- a/include/net/phonet/pn_dev.h +++ b/include/net/phonet/pn_dev.h | |||
@@ -51,11 +51,12 @@ void phonet_address_notify(int event, struct net_device *dev, u8 addr); | |||
51 | int phonet_route_add(struct net_device *dev, u8 daddr); | 51 | int phonet_route_add(struct net_device *dev, u8 daddr); |
52 | int phonet_route_del(struct net_device *dev, u8 daddr); | 52 | int phonet_route_del(struct net_device *dev, u8 daddr); |
53 | void rtm_phonet_notify(int event, struct net_device *dev, u8 dst); | 53 | void rtm_phonet_notify(int event, struct net_device *dev, u8 dst); |
54 | struct net_device *phonet_route_get(struct net *net, u8 daddr); | 54 | struct net_device *phonet_route_get_rcu(struct net *net, u8 daddr); |
55 | struct net_device *phonet_route_output(struct net *net, u8 daddr); | 55 | struct net_device *phonet_route_output(struct net *net, u8 daddr); |
56 | 56 | ||
57 | #define PN_NO_ADDR 0xff | 57 | #define PN_NO_ADDR 0xff |
58 | 58 | ||
59 | extern const struct file_operations pn_sock_seq_fops; | 59 | extern const struct file_operations pn_sock_seq_fops; |
60 | extern const struct file_operations pn_res_seq_fops; | ||
60 | 61 | ||
61 | #endif | 62 | #endif |
diff --git a/include/net/ping.h b/include/net/ping.h new file mode 100644 index 000000000000..682b5ae9af51 --- /dev/null +++ b/include/net/ping.h | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | * INET An implementation of the TCP/IP protocol suite for the LINUX | ||
3 | * operating system. INET is implemented using the BSD Socket | ||
4 | * interface as the means of communication with the user level. | ||
5 | * | ||
6 | * Definitions for the "ping" module. | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * as published by the Free Software Foundation; either version | ||
11 | * 2 of the License, or (at your option) any later version. | ||
12 | */ | ||
13 | #ifndef _PING_H | ||
14 | #define _PING_H | ||
15 | |||
16 | #include <net/netns/hash.h> | ||
17 | |||
18 | /* PING_HTABLE_SIZE must be power of 2 */ | ||
19 | #define PING_HTABLE_SIZE 64 | ||
20 | #define PING_HTABLE_MASK (PING_HTABLE_SIZE-1) | ||
21 | |||
22 | #define ping_portaddr_for_each_entry(__sk, node, list) \ | ||
23 | hlist_nulls_for_each_entry(__sk, node, list, sk_nulls_node) | ||
24 | |||
25 | /* | ||
26 | * gid_t is either uint or ushort. We want to pass it to | ||
27 | * proc_dointvec_minmax(), so it must not be larger than MAX_INT | ||
28 | */ | ||
29 | #define GID_T_MAX (((gid_t)~0U) >> 1) | ||
30 | |||
31 | struct ping_table { | ||
32 | struct hlist_nulls_head hash[PING_HTABLE_SIZE]; | ||
33 | rwlock_t lock; | ||
34 | }; | ||
35 | |||
36 | struct ping_iter_state { | ||
37 | struct seq_net_private p; | ||
38 | int bucket; | ||
39 | }; | ||
40 | |||
41 | extern struct proto ping_prot; | ||
42 | |||
43 | |||
44 | extern void ping_rcv(struct sk_buff *); | ||
45 | extern void ping_err(struct sk_buff *, u32 info); | ||
46 | |||
47 | #ifdef CONFIG_PROC_FS | ||
48 | extern int __init ping_proc_init(void); | ||
49 | extern void ping_proc_exit(void); | ||
50 | #endif | ||
51 | |||
52 | void __init ping_init(void); | ||
53 | |||
54 | |||
55 | #endif /* _PING_H */ | ||
diff --git a/include/net/pkt_cls.h b/include/net/pkt_cls.h index dd3031aed9d5..9fcc680ab6b9 100644 --- a/include/net/pkt_cls.h +++ b/include/net/pkt_cls.h | |||
@@ -323,7 +323,9 @@ static inline unsigned char * tcf_get_base_ptr(struct sk_buff *skb, int layer) | |||
323 | static inline int tcf_valid_offset(const struct sk_buff *skb, | 323 | static inline int tcf_valid_offset(const struct sk_buff *skb, |
324 | const unsigned char *ptr, const int len) | 324 | const unsigned char *ptr, const int len) |
325 | { | 325 | { |
326 | return unlikely((ptr + len) < skb_tail_pointer(skb) && ptr > skb->head); | 326 | return likely((ptr + len) <= skb_tail_pointer(skb) && |
327 | ptr >= skb->head && | ||
328 | (ptr <= (ptr + len))); | ||
327 | } | 329 | } |
328 | 330 | ||
329 | #ifdef CONFIG_NET_CLS_IND | 331 | #ifdef CONFIG_NET_CLS_IND |
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index d9549af6929a..65afc4966204 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h | |||
@@ -32,7 +32,7 @@ static inline void *qdisc_priv(struct Qdisc *q) | |||
32 | 32 | ||
33 | The result: [34]86 is not good choice for QoS router :-( | 33 | The result: [34]86 is not good choice for QoS router :-( |
34 | 34 | ||
35 | The things are not so bad, because we may use artifical | 35 | The things are not so bad, because we may use artificial |
36 | clock evaluated by integration of network data flow | 36 | clock evaluated by integration of network data flow |
37 | in the most critical places. | 37 | in the most critical places. |
38 | */ | 38 | */ |
diff --git a/include/net/protocol.h b/include/net/protocol.h index f1effdd3c265..6f7eb800974a 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h | |||
@@ -38,7 +38,7 @@ struct net_protocol { | |||
38 | void (*err_handler)(struct sk_buff *skb, u32 info); | 38 | void (*err_handler)(struct sk_buff *skb, u32 info); |
39 | int (*gso_send_check)(struct sk_buff *skb); | 39 | int (*gso_send_check)(struct sk_buff *skb); |
40 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 40 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
41 | int features); | 41 | u32 features); |
42 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | 42 | struct sk_buff **(*gro_receive)(struct sk_buff **head, |
43 | struct sk_buff *skb); | 43 | struct sk_buff *skb); |
44 | int (*gro_complete)(struct sk_buff *skb); | 44 | int (*gro_complete)(struct sk_buff *skb); |
@@ -57,7 +57,7 @@ struct inet6_protocol { | |||
57 | 57 | ||
58 | int (*gso_send_check)(struct sk_buff *skb); | 58 | int (*gso_send_check)(struct sk_buff *skb); |
59 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | 59 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, |
60 | int features); | 60 | u32 features); |
61 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | 61 | struct sk_buff **(*gro_receive)(struct sk_buff **head, |
62 | struct sk_buff *skb); | 62 | struct sk_buff *skb); |
63 | int (*gro_complete)(struct sk_buff *skb); | 63 | int (*gro_complete)(struct sk_buff *skb); |
@@ -89,10 +89,10 @@ struct inet_protosw { | |||
89 | #define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */ | 89 | #define INET_PROTOSW_PERMANENT 0x02 /* Permanent protocols are unremovable. */ |
90 | #define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ | 90 | #define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ |
91 | 91 | ||
92 | extern const struct net_protocol *inet_protos[MAX_INET_PROTOS]; | 92 | extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS]; |
93 | 93 | ||
94 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) | 94 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
95 | extern const struct inet6_protocol *inet6_protos[MAX_INET_PROTOS]; | 95 | extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS]; |
96 | #endif | 96 | #endif |
97 | 97 | ||
98 | extern int inet_add_protocol(const struct net_protocol *prot, unsigned char num); | 98 | extern int inet_add_protocol(const struct net_protocol *prot, unsigned char num); |
diff --git a/include/net/raw.h b/include/net/raw.h index 43c57502659b..42ce6fe7a2d5 100644 --- a/include/net/raw.h +++ b/include/net/raw.h | |||
@@ -45,7 +45,10 @@ struct raw_iter_state { | |||
45 | struct raw_hashinfo *h; | 45 | struct raw_hashinfo *h; |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #define raw_seq_private(seq) ((struct raw_iter_state *)(seq)->private) | 48 | static inline struct raw_iter_state *raw_seq_private(struct seq_file *seq) |
49 | { | ||
50 | return seq->private; | ||
51 | } | ||
49 | void *raw_seq_start(struct seq_file *seq, loff_t *pos); | 52 | void *raw_seq_start(struct seq_file *seq, loff_t *pos); |
50 | void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos); | 53 | void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos); |
51 | void raw_seq_stop(struct seq_file *seq, void *v); | 54 | void raw_seq_stop(struct seq_file *seq, void *v); |
diff --git a/include/net/rawv6.h b/include/net/rawv6.h index f6b9b830df8c..cf7577234457 100644 --- a/include/net/rawv6.h +++ b/include/net/rawv6.h | |||
@@ -1,8 +1,6 @@ | |||
1 | #ifndef _NET_RAWV6_H | 1 | #ifndef _NET_RAWV6_H |
2 | #define _NET_RAWV6_H | 2 | #define _NET_RAWV6_H |
3 | 3 | ||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | #include <net/protocol.h> | 4 | #include <net/protocol.h> |
7 | 5 | ||
8 | void raw6_icmp_error(struct sk_buff *, int nexthdr, | 6 | void raw6_icmp_error(struct sk_buff *, int nexthdr, |
@@ -20,5 +18,3 @@ int rawv6_mh_filter_unregister(int (*filter)(struct sock *sock, | |||
20 | #endif | 18 | #endif |
21 | 19 | ||
22 | #endif | 20 | #endif |
23 | |||
24 | #endif | ||
diff --git a/include/net/red.h b/include/net/red.h index 995108e54d9f..3319f16b3beb 100644 --- a/include/net/red.h +++ b/include/net/red.h | |||
@@ -97,7 +97,6 @@ struct red_stats { | |||
97 | u32 forced_mark; /* Forced marks, qavg > max_thresh */ | 97 | u32 forced_mark; /* Forced marks, qavg > max_thresh */ |
98 | u32 pdrop; /* Drops due to queue limits */ | 98 | u32 pdrop; /* Drops due to queue limits */ |
99 | u32 other; /* Drops due to drop() calls */ | 99 | u32 other; /* Drops due to drop() calls */ |
100 | u32 backlog; | ||
101 | }; | 100 | }; |
102 | 101 | ||
103 | struct red_parms { | 102 | struct red_parms { |
diff --git a/include/net/regulatory.h b/include/net/regulatory.h index 9e103a4e91ee..356d6e3dc20a 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h | |||
@@ -43,6 +43,12 @@ enum environment_cap { | |||
43 | * @intersect: indicates whether the wireless core should intersect | 43 | * @intersect: indicates whether the wireless core should intersect |
44 | * the requested regulatory domain with the presently set regulatory | 44 | * the requested regulatory domain with the presently set regulatory |
45 | * domain. | 45 | * domain. |
46 | * @processed: indicates whether or not this requests has already been | ||
47 | * processed. When the last request is processed it means that the | ||
48 | * currently regulatory domain set on cfg80211 is updated from | ||
49 | * CRDA and can be used by other regulatory requests. When a | ||
50 | * the last request is not yet processed we must yield until it | ||
51 | * is processed before processing any new requests. | ||
46 | * @country_ie_checksum: checksum of the last processed and accepted | 52 | * @country_ie_checksum: checksum of the last processed and accepted |
47 | * country IE | 53 | * country IE |
48 | * @country_ie_env: lets us know if the AP is telling us we are outdoor, | 54 | * @country_ie_env: lets us know if the AP is telling us we are outdoor, |
@@ -54,6 +60,7 @@ struct regulatory_request { | |||
54 | enum nl80211_reg_initiator initiator; | 60 | enum nl80211_reg_initiator initiator; |
55 | char alpha2[2]; | 61 | char alpha2[2]; |
56 | bool intersect; | 62 | bool intersect; |
63 | bool processed; | ||
57 | enum environment_cap country_ie_env; | 64 | enum environment_cap country_ie_env; |
58 | struct list_head list; | 65 | struct list_head list; |
59 | }; | 66 | }; |
diff --git a/include/net/rose.h b/include/net/rose.h index 5ba9f02731eb..555dd198aab7 100644 --- a/include/net/rose.h +++ b/include/net/rose.h | |||
@@ -14,6 +14,12 @@ | |||
14 | 14 | ||
15 | #define ROSE_MIN_LEN 3 | 15 | #define ROSE_MIN_LEN 3 |
16 | 16 | ||
17 | #define ROSE_CALL_REQ_ADDR_LEN_OFF 3 | ||
18 | #define ROSE_CALL_REQ_ADDR_LEN_VAL 0xAA /* each address is 10 digits */ | ||
19 | #define ROSE_CALL_REQ_DEST_ADDR_OFF 4 | ||
20 | #define ROSE_CALL_REQ_SRC_ADDR_OFF 9 | ||
21 | #define ROSE_CALL_REQ_FACILITIES_OFF 14 | ||
22 | |||
17 | #define ROSE_GFI 0x10 | 23 | #define ROSE_GFI 0x10 |
18 | #define ROSE_Q_BIT 0x80 | 24 | #define ROSE_Q_BIT 0x80 |
19 | #define ROSE_D_BIT 0x40 | 25 | #define ROSE_D_BIT 0x40 |
@@ -214,7 +220,7 @@ extern void rose_requeue_frames(struct sock *); | |||
214 | extern int rose_validate_nr(struct sock *, unsigned short); | 220 | extern int rose_validate_nr(struct sock *, unsigned short); |
215 | extern void rose_write_internal(struct sock *, int); | 221 | extern void rose_write_internal(struct sock *, int); |
216 | extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *); | 222 | extern int rose_decode(struct sk_buff *, int *, int *, int *, int *, int *); |
217 | extern int rose_parse_facilities(unsigned char *, struct rose_facilities_struct *); | 223 | extern int rose_parse_facilities(unsigned char *, unsigned int, struct rose_facilities_struct *); |
218 | extern void rose_disconnect(struct sock *, int, int, int); | 224 | extern void rose_disconnect(struct sock *, int, int, int); |
219 | 225 | ||
220 | /* rose_timer.c */ | 226 | /* rose_timer.c */ |
diff --git a/include/net/route.h b/include/net/route.h index 7e5e73bfa4de..db7b3432f07c 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -35,44 +35,52 @@ | |||
35 | #include <linux/cache.h> | 35 | #include <linux/cache.h> |
36 | #include <linux/security.h> | 36 | #include <linux/security.h> |
37 | 37 | ||
38 | #ifndef __KERNEL__ | ||
39 | #warning This file is not supposed to be used outside of kernel. | ||
40 | #endif | ||
41 | |||
42 | #define RTO_ONLINK 0x01 | 38 | #define RTO_ONLINK 0x01 |
43 | 39 | ||
44 | #define RTO_CONN 0 | ||
45 | /* RTO_CONN is not used (being alias for 0), but preserved not to break | ||
46 | * some modules referring to it. */ | ||
47 | |||
48 | #define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE)) | 40 | #define RT_CONN_FLAGS(sk) (RT_TOS(inet_sk(sk)->tos) | sock_flag(sk, SOCK_LOCALROUTE)) |
49 | 41 | ||
50 | struct fib_nh; | 42 | struct fib_nh; |
51 | struct inet_peer; | 43 | struct inet_peer; |
44 | struct fib_info; | ||
52 | struct rtable { | 45 | struct rtable { |
53 | struct dst_entry dst; | 46 | struct dst_entry dst; |
54 | 47 | ||
55 | /* Cache lookup keys */ | 48 | /* Lookup key. */ |
56 | struct flowi fl; | 49 | __be32 rt_key_dst; |
50 | __be32 rt_key_src; | ||
57 | 51 | ||
58 | struct in_device *idev; | ||
59 | |||
60 | int rt_genid; | 52 | int rt_genid; |
61 | unsigned rt_flags; | 53 | unsigned rt_flags; |
62 | __u16 rt_type; | 54 | __u16 rt_type; |
55 | __u8 rt_key_tos; | ||
63 | 56 | ||
64 | __be32 rt_dst; /* Path destination */ | 57 | __be32 rt_dst; /* Path destination */ |
65 | __be32 rt_src; /* Path source */ | 58 | __be32 rt_src; /* Path source */ |
59 | int rt_route_iif; | ||
66 | int rt_iif; | 60 | int rt_iif; |
61 | int rt_oif; | ||
62 | __u32 rt_mark; | ||
67 | 63 | ||
68 | /* Info on neighbour */ | 64 | /* Info on neighbour */ |
69 | __be32 rt_gateway; | 65 | __be32 rt_gateway; |
70 | 66 | ||
71 | /* Miscellaneous cached information */ | 67 | /* Miscellaneous cached information */ |
72 | __be32 rt_spec_dst; /* RFC1122 specific destination */ | 68 | __be32 rt_spec_dst; /* RFC1122 specific destination */ |
69 | u32 rt_peer_genid; | ||
73 | struct inet_peer *peer; /* long-living peer info */ | 70 | struct inet_peer *peer; /* long-living peer info */ |
71 | struct fib_info *fi; /* for client ref to shared metrics */ | ||
74 | }; | 72 | }; |
75 | 73 | ||
74 | static inline bool rt_is_input_route(struct rtable *rt) | ||
75 | { | ||
76 | return rt->rt_route_iif != 0; | ||
77 | } | ||
78 | |||
79 | static inline bool rt_is_output_route(struct rtable *rt) | ||
80 | { | ||
81 | return rt->rt_route_iif == 0; | ||
82 | } | ||
83 | |||
76 | struct ip_rt_acct { | 84 | struct ip_rt_acct { |
77 | __u32 o_bytes; | 85 | __u32 o_bytes; |
78 | __u32 o_packets; | 86 | __u32 o_packets; |
@@ -106,10 +114,57 @@ extern int ip_rt_init(void); | |||
106 | extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw, | 114 | extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw, |
107 | __be32 src, struct net_device *dev); | 115 | __be32 src, struct net_device *dev); |
108 | extern void rt_cache_flush(struct net *net, int how); | 116 | extern void rt_cache_flush(struct net *net, int how); |
109 | extern void rt_cache_flush_batch(void); | 117 | extern void rt_cache_flush_batch(struct net *net); |
110 | extern int __ip_route_output_key(struct net *, struct rtable **, const struct flowi *flp); | 118 | extern struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp); |
111 | extern int ip_route_output_key(struct net *, struct rtable **, struct flowi *flp); | 119 | extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp, |
112 | extern int ip_route_output_flow(struct net *, struct rtable **rp, struct flowi *flp, struct sock *sk, int flags); | 120 | struct sock *sk); |
121 | extern struct dst_entry *ipv4_blackhole_route(struct net *net, struct dst_entry *dst_orig); | ||
122 | |||
123 | static inline struct rtable *ip_route_output_key(struct net *net, struct flowi4 *flp) | ||
124 | { | ||
125 | return ip_route_output_flow(net, flp, NULL); | ||
126 | } | ||
127 | |||
128 | static inline struct rtable *ip_route_output(struct net *net, __be32 daddr, | ||
129 | __be32 saddr, u8 tos, int oif) | ||
130 | { | ||
131 | struct flowi4 fl4 = { | ||
132 | .flowi4_oif = oif, | ||
133 | .daddr = daddr, | ||
134 | .saddr = saddr, | ||
135 | .flowi4_tos = tos, | ||
136 | }; | ||
137 | return ip_route_output_key(net, &fl4); | ||
138 | } | ||
139 | |||
140 | static inline struct rtable *ip_route_output_ports(struct net *net, struct flowi4 *fl4, | ||
141 | struct sock *sk, | ||
142 | __be32 daddr, __be32 saddr, | ||
143 | __be16 dport, __be16 sport, | ||
144 | __u8 proto, __u8 tos, int oif) | ||
145 | { | ||
146 | flowi4_init_output(fl4, oif, sk ? sk->sk_mark : 0, tos, | ||
147 | RT_SCOPE_UNIVERSE, proto, | ||
148 | sk ? inet_sk_flowi_flags(sk) : 0, | ||
149 | daddr, saddr, dport, sport); | ||
150 | if (sk) | ||
151 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); | ||
152 | return ip_route_output_flow(net, fl4, sk); | ||
153 | } | ||
154 | |||
155 | static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4 *fl4, | ||
156 | __be32 daddr, __be32 saddr, | ||
157 | __be32 gre_key, __u8 tos, int oif) | ||
158 | { | ||
159 | memset(fl4, 0, sizeof(*fl4)); | ||
160 | fl4->flowi4_oif = oif; | ||
161 | fl4->daddr = daddr; | ||
162 | fl4->saddr = saddr; | ||
163 | fl4->flowi4_tos = tos; | ||
164 | fl4->flowi4_proto = IPPROTO_GRE; | ||
165 | fl4->fl4_gre_key = gre_key; | ||
166 | return ip_route_output_key(net, fl4); | ||
167 | } | ||
113 | 168 | ||
114 | extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, | 169 | extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, |
115 | u8 tos, struct net_device *devin, bool noref); | 170 | u8 tos, struct net_device *devin, bool noref); |
@@ -126,18 +181,20 @@ static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 s | |||
126 | return ip_route_input_common(skb, dst, src, tos, devin, true); | 181 | return ip_route_input_common(skb, dst, src, tos, devin, true); |
127 | } | 182 | } |
128 | 183 | ||
129 | extern unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, unsigned short new_mtu, struct net_device *dev); | 184 | extern unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph, |
185 | unsigned short new_mtu, struct net_device *dev); | ||
130 | extern void ip_rt_send_redirect(struct sk_buff *skb); | 186 | extern void ip_rt_send_redirect(struct sk_buff *skb); |
131 | 187 | ||
132 | extern unsigned inet_addr_type(struct net *net, __be32 addr); | 188 | extern unsigned inet_addr_type(struct net *net, __be32 addr); |
133 | extern unsigned inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr); | 189 | extern unsigned inet_dev_addr_type(struct net *net, const struct net_device *dev, __be32 addr); |
134 | extern void ip_rt_multicast_event(struct in_device *); | 190 | extern void ip_rt_multicast_event(struct in_device *); |
135 | extern int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg); | 191 | extern int ip_rt_ioctl(struct net *, unsigned int cmd, void __user *arg); |
136 | extern void ip_rt_get_source(u8 *src, struct rtable *rt); | 192 | extern void ip_rt_get_source(u8 *src, struct sk_buff *skb, struct rtable *rt); |
137 | extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); | 193 | extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); |
138 | 194 | ||
139 | struct in_ifaddr; | 195 | struct in_ifaddr; |
140 | extern void fib_add_ifaddr(struct in_ifaddr *); | 196 | extern void fib_add_ifaddr(struct in_ifaddr *); |
197 | extern void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *); | ||
141 | 198 | ||
142 | static inline void ip_rt_put(struct rtable * rt) | 199 | static inline void ip_rt_put(struct rtable * rt) |
143 | { | 200 | { |
@@ -154,69 +211,93 @@ static inline char rt_tos2priority(u8 tos) | |||
154 | return ip_tos2prio[IPTOS_TOS(tos)>>1]; | 211 | return ip_tos2prio[IPTOS_TOS(tos)>>1]; |
155 | } | 212 | } |
156 | 213 | ||
157 | static inline int ip_route_connect(struct rtable **rp, __be32 dst, | 214 | /* ip_route_connect() and ip_route_newports() work in tandem whilst |
158 | __be32 src, u32 tos, int oif, u8 protocol, | 215 | * binding a socket for a new outgoing connection. |
159 | __be16 sport, __be16 dport, struct sock *sk, | 216 | * |
160 | int flags) | 217 | * In order to use IPSEC properly, we must, in the end, have a |
218 | * route that was looked up using all available keys including source | ||
219 | * and destination ports. | ||
220 | * | ||
221 | * However, if a source port needs to be allocated (the user specified | ||
222 | * a wildcard source port) we need to obtain addressing information | ||
223 | * in order to perform that allocation. | ||
224 | * | ||
225 | * So ip_route_connect() looks up a route using wildcarded source and | ||
226 | * destination ports in the key, simply so that we can get a pair of | ||
227 | * addresses to use for port allocation. | ||
228 | * | ||
229 | * Later, once the ports are allocated, ip_route_newports() will make | ||
230 | * another route lookup if needed to make sure we catch any IPSEC | ||
231 | * rules keyed on the port information. | ||
232 | * | ||
233 | * The callers allocate the flow key on their stack, and must pass in | ||
234 | * the same flowi4 object to both the ip_route_connect() and the | ||
235 | * ip_route_newports() calls. | ||
236 | */ | ||
237 | |||
238 | static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32 src, | ||
239 | u32 tos, int oif, u8 protocol, | ||
240 | __be16 sport, __be16 dport, | ||
241 | struct sock *sk, bool can_sleep) | ||
161 | { | 242 | { |
162 | struct flowi fl = { .oif = oif, | 243 | __u8 flow_flags = 0; |
163 | .mark = sk->sk_mark, | 244 | |
164 | .nl_u = { .ip4_u = { .daddr = dst, | 245 | if (inet_sk(sk)->transparent) |
165 | .saddr = src, | 246 | flow_flags |= FLOWI_FLAG_ANYSRC; |
166 | .tos = tos } }, | 247 | if (protocol == IPPROTO_TCP) |
167 | .proto = protocol, | 248 | flow_flags |= FLOWI_FLAG_PRECOW_METRICS; |
168 | .uli_u = { .ports = | 249 | if (can_sleep) |
169 | { .sport = sport, | 250 | flow_flags |= FLOWI_FLAG_CAN_SLEEP; |
170 | .dport = dport } } }; | 251 | |
252 | flowi4_init_output(fl4, oif, sk->sk_mark, tos, RT_SCOPE_UNIVERSE, | ||
253 | protocol, flow_flags, dst, src, dport, sport); | ||
254 | } | ||
171 | 255 | ||
172 | int err; | 256 | static inline struct rtable *ip_route_connect(struct flowi4 *fl4, |
257 | __be32 dst, __be32 src, u32 tos, | ||
258 | int oif, u8 protocol, | ||
259 | __be16 sport, __be16 dport, | ||
260 | struct sock *sk, bool can_sleep) | ||
261 | { | ||
173 | struct net *net = sock_net(sk); | 262 | struct net *net = sock_net(sk); |
263 | struct rtable *rt; | ||
174 | 264 | ||
175 | if (inet_sk(sk)->transparent) | 265 | ip_route_connect_init(fl4, dst, src, tos, oif, protocol, |
176 | fl.flags |= FLOWI_FLAG_ANYSRC; | 266 | sport, dport, sk, can_sleep); |
177 | 267 | ||
178 | if (!dst || !src) { | 268 | if (!dst || !src) { |
179 | err = __ip_route_output_key(net, rp, &fl); | 269 | rt = __ip_route_output_key(net, fl4); |
180 | if (err) | 270 | if (IS_ERR(rt)) |
181 | return err; | 271 | return rt; |
182 | fl.fl4_dst = (*rp)->rt_dst; | 272 | ip_rt_put(rt); |
183 | fl.fl4_src = (*rp)->rt_src; | ||
184 | ip_rt_put(*rp); | ||
185 | *rp = NULL; | ||
186 | } | 273 | } |
187 | security_sk_classify_flow(sk, &fl); | 274 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); |
188 | return ip_route_output_flow(net, rp, &fl, sk, flags); | 275 | return ip_route_output_flow(net, fl4, sk); |
189 | } | 276 | } |
190 | 277 | ||
191 | static inline int ip_route_newports(struct rtable **rp, u8 protocol, | 278 | static inline struct rtable *ip_route_newports(struct flowi4 *fl4, struct rtable *rt, |
192 | __be16 sport, __be16 dport, struct sock *sk) | 279 | __be16 orig_sport, __be16 orig_dport, |
193 | { | 280 | __be16 sport, __be16 dport, |
194 | if (sport != (*rp)->fl.fl_ip_sport || | 281 | struct sock *sk) |
195 | dport != (*rp)->fl.fl_ip_dport) { | 282 | { |
196 | struct flowi fl; | 283 | if (sport != orig_sport || dport != orig_dport) { |
197 | 284 | fl4->fl4_dport = dport; | |
198 | memcpy(&fl, &(*rp)->fl, sizeof(fl)); | 285 | fl4->fl4_sport = sport; |
199 | fl.fl_ip_sport = sport; | 286 | ip_rt_put(rt); |
200 | fl.fl_ip_dport = dport; | 287 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); |
201 | fl.proto = protocol; | 288 | return ip_route_output_flow(sock_net(sk), fl4, sk); |
202 | if (inet_sk(sk)->transparent) | ||
203 | fl.flags |= FLOWI_FLAG_ANYSRC; | ||
204 | ip_rt_put(*rp); | ||
205 | *rp = NULL; | ||
206 | security_sk_classify_flow(sk, &fl); | ||
207 | return ip_route_output_flow(sock_net(sk), rp, &fl, sk, 0); | ||
208 | } | 289 | } |
209 | return 0; | 290 | return rt; |
210 | } | 291 | } |
211 | 292 | ||
212 | extern void rt_bind_peer(struct rtable *rt, int create); | 293 | extern void rt_bind_peer(struct rtable *rt, __be32 daddr, int create); |
213 | 294 | ||
214 | static inline struct inet_peer *rt_get_peer(struct rtable *rt) | 295 | static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr) |
215 | { | 296 | { |
216 | if (rt->peer) | 297 | if (rt->peer) |
217 | return rt->peer; | 298 | return rt->peer; |
218 | 299 | ||
219 | rt_bind_peer(rt, 0); | 300 | rt_bind_peer(rt, daddr, 0); |
220 | return rt->peer; | 301 | return rt->peer; |
221 | } | 302 | } |
222 | 303 | ||
@@ -225,4 +306,15 @@ static inline int inet_iif(const struct sk_buff *skb) | |||
225 | return skb_rtable(skb)->rt_iif; | 306 | return skb_rtable(skb)->rt_iif; |
226 | } | 307 | } |
227 | 308 | ||
309 | extern int sysctl_ip_default_ttl; | ||
310 | |||
311 | static inline int ip4_dst_hoplimit(const struct dst_entry *dst) | ||
312 | { | ||
313 | int hoplimit = dst_metric_raw(dst, RTAX_HOPLIMIT); | ||
314 | |||
315 | if (hoplimit == 0) | ||
316 | hoplimit = sysctl_ip_default_ttl; | ||
317 | return hoplimit; | ||
318 | } | ||
319 | |||
228 | #endif /* _ROUTE_H */ | 320 | #endif /* _ROUTE_H */ |
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h index af60fd050844..4093ca78cf60 100644 --- a/include/net/rtnetlink.h +++ b/include/net/rtnetlink.h | |||
@@ -79,11 +79,45 @@ struct rtnl_link_ops { | |||
79 | 79 | ||
80 | extern int __rtnl_link_register(struct rtnl_link_ops *ops); | 80 | extern int __rtnl_link_register(struct rtnl_link_ops *ops); |
81 | extern void __rtnl_link_unregister(struct rtnl_link_ops *ops); | 81 | extern void __rtnl_link_unregister(struct rtnl_link_ops *ops); |
82 | extern void rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops); | ||
83 | 82 | ||
84 | extern int rtnl_link_register(struct rtnl_link_ops *ops); | 83 | extern int rtnl_link_register(struct rtnl_link_ops *ops); |
85 | extern void rtnl_link_unregister(struct rtnl_link_ops *ops); | 84 | extern void rtnl_link_unregister(struct rtnl_link_ops *ops); |
86 | 85 | ||
86 | /** | ||
87 | * struct rtnl_af_ops - rtnetlink address family operations | ||
88 | * | ||
89 | * @list: Used internally | ||
90 | * @family: Address family | ||
91 | * @fill_link_af: Function to fill IFLA_AF_SPEC with address family | ||
92 | * specific netlink attributes. | ||
93 | * @get_link_af_size: Function to calculate size of address family specific | ||
94 | * netlink attributes exlusive the container attribute. | ||
95 | * @validate_link_af: Validate a IFLA_AF_SPEC attribute, must check attr | ||
96 | * for invalid configuration settings. | ||
97 | * @set_link_af: Function to parse a IFLA_AF_SPEC attribute and modify | ||
98 | * net_device accordingly. | ||
99 | */ | ||
100 | struct rtnl_af_ops { | ||
101 | struct list_head list; | ||
102 | int family; | ||
103 | |||
104 | int (*fill_link_af)(struct sk_buff *skb, | ||
105 | const struct net_device *dev); | ||
106 | size_t (*get_link_af_size)(const struct net_device *dev); | ||
107 | |||
108 | int (*validate_link_af)(const struct net_device *dev, | ||
109 | const struct nlattr *attr); | ||
110 | int (*set_link_af)(struct net_device *dev, | ||
111 | const struct nlattr *attr); | ||
112 | }; | ||
113 | |||
114 | extern int __rtnl_af_register(struct rtnl_af_ops *ops); | ||
115 | extern void __rtnl_af_unregister(struct rtnl_af_ops *ops); | ||
116 | |||
117 | extern int rtnl_af_register(struct rtnl_af_ops *ops); | ||
118 | extern void rtnl_af_unregister(struct rtnl_af_ops *ops); | ||
119 | |||
120 | |||
87 | extern struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]); | 121 | extern struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]); |
88 | extern struct net_device *rtnl_create_link(struct net *src_net, struct net *net, | 122 | extern struct net_device *rtnl_create_link(struct net *src_net, struct net *net, |
89 | char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]); | 123 | char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]); |
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 3c8728aaab4e..b931f021d7ab 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
@@ -25,16 +25,18 @@ struct qdisc_rate_table { | |||
25 | enum qdisc_state_t { | 25 | enum qdisc_state_t { |
26 | __QDISC_STATE_SCHED, | 26 | __QDISC_STATE_SCHED, |
27 | __QDISC_STATE_DEACTIVATED, | 27 | __QDISC_STATE_DEACTIVATED, |
28 | __QDISC_STATE_THROTTLED, | ||
28 | }; | 29 | }; |
29 | 30 | ||
30 | /* | 31 | /* |
31 | * following bits are only changed while qdisc lock is held | 32 | * following bits are only changed while qdisc lock is held |
32 | */ | 33 | */ |
33 | enum qdisc___state_t { | 34 | enum qdisc___state_t { |
34 | __QDISC___STATE_RUNNING, | 35 | __QDISC___STATE_RUNNING = 1, |
35 | }; | 36 | }; |
36 | 37 | ||
37 | struct qdisc_size_table { | 38 | struct qdisc_size_table { |
39 | struct rcu_head rcu; | ||
38 | struct list_head list; | 40 | struct list_head list; |
39 | struct tc_sizespec szopts; | 41 | struct tc_sizespec szopts; |
40 | int refcnt; | 42 | int refcnt; |
@@ -46,14 +48,13 @@ struct Qdisc { | |||
46 | struct sk_buff * (*dequeue)(struct Qdisc *dev); | 48 | struct sk_buff * (*dequeue)(struct Qdisc *dev); |
47 | unsigned flags; | 49 | unsigned flags; |
48 | #define TCQ_F_BUILTIN 1 | 50 | #define TCQ_F_BUILTIN 1 |
49 | #define TCQ_F_THROTTLED 2 | 51 | #define TCQ_F_INGRESS 2 |
50 | #define TCQ_F_INGRESS 4 | 52 | #define TCQ_F_CAN_BYPASS 4 |
51 | #define TCQ_F_CAN_BYPASS 8 | 53 | #define TCQ_F_MQROOT 8 |
52 | #define TCQ_F_MQROOT 16 | ||
53 | #define TCQ_F_WARN_NONWC (1 << 16) | 54 | #define TCQ_F_WARN_NONWC (1 << 16) |
54 | int padded; | 55 | int padded; |
55 | struct Qdisc_ops *ops; | 56 | struct Qdisc_ops *ops; |
56 | struct qdisc_size_table *stab; | 57 | struct qdisc_size_table __rcu *stab; |
57 | struct list_head list; | 58 | struct list_head list; |
58 | u32 handle; | 59 | u32 handle; |
59 | u32 parent; | 60 | u32 parent; |
@@ -78,25 +79,44 @@ struct Qdisc { | |||
78 | unsigned long state; | 79 | unsigned long state; |
79 | struct sk_buff_head q; | 80 | struct sk_buff_head q; |
80 | struct gnet_stats_basic_packed bstats; | 81 | struct gnet_stats_basic_packed bstats; |
81 | unsigned long __state; | 82 | unsigned int __state; |
82 | struct gnet_stats_queue qstats; | 83 | struct gnet_stats_queue qstats; |
83 | struct rcu_head rcu_head; | 84 | struct rcu_head rcu_head; |
84 | spinlock_t busylock; | 85 | spinlock_t busylock; |
86 | u32 limit; | ||
85 | }; | 87 | }; |
86 | 88 | ||
87 | static inline bool qdisc_is_running(struct Qdisc *qdisc) | 89 | static inline bool qdisc_is_running(const struct Qdisc *qdisc) |
88 | { | 90 | { |
89 | return test_bit(__QDISC___STATE_RUNNING, &qdisc->__state); | 91 | return (qdisc->__state & __QDISC___STATE_RUNNING) ? true : false; |
90 | } | 92 | } |
91 | 93 | ||
92 | static inline bool qdisc_run_begin(struct Qdisc *qdisc) | 94 | static inline bool qdisc_run_begin(struct Qdisc *qdisc) |
93 | { | 95 | { |
94 | return !__test_and_set_bit(__QDISC___STATE_RUNNING, &qdisc->__state); | 96 | if (qdisc_is_running(qdisc)) |
97 | return false; | ||
98 | qdisc->__state |= __QDISC___STATE_RUNNING; | ||
99 | return true; | ||
95 | } | 100 | } |
96 | 101 | ||
97 | static inline void qdisc_run_end(struct Qdisc *qdisc) | 102 | static inline void qdisc_run_end(struct Qdisc *qdisc) |
98 | { | 103 | { |
99 | __clear_bit(__QDISC___STATE_RUNNING, &qdisc->__state); | 104 | qdisc->__state &= ~__QDISC___STATE_RUNNING; |
105 | } | ||
106 | |||
107 | static inline bool qdisc_is_throttled(const struct Qdisc *qdisc) | ||
108 | { | ||
109 | return test_bit(__QDISC_STATE_THROTTLED, &qdisc->state) ? true : false; | ||
110 | } | ||
111 | |||
112 | static inline void qdisc_throttled(struct Qdisc *qdisc) | ||
113 | { | ||
114 | set_bit(__QDISC_STATE_THROTTLED, &qdisc->state); | ||
115 | } | ||
116 | |||
117 | static inline void qdisc_unthrottled(struct Qdisc *qdisc) | ||
118 | { | ||
119 | clear_bit(__QDISC_STATE_THROTTLED, &qdisc->state); | ||
100 | } | 120 | } |
101 | 121 | ||
102 | struct Qdisc_class_ops { | 122 | struct Qdisc_class_ops { |
@@ -199,7 +219,7 @@ struct tcf_proto { | |||
199 | 219 | ||
200 | struct qdisc_skb_cb { | 220 | struct qdisc_skb_cb { |
201 | unsigned int pkt_len; | 221 | unsigned int pkt_len; |
202 | char data[]; | 222 | long data[]; |
203 | }; | 223 | }; |
204 | 224 | ||
205 | static inline int qdisc_qlen(struct Qdisc *q) | 225 | static inline int qdisc_qlen(struct Qdisc *q) |
@@ -207,7 +227,7 @@ static inline int qdisc_qlen(struct Qdisc *q) | |||
207 | return q->q.qlen; | 227 | return q->q.qlen; |
208 | } | 228 | } |
209 | 229 | ||
210 | static inline struct qdisc_skb_cb *qdisc_skb_cb(struct sk_buff *skb) | 230 | static inline struct qdisc_skb_cb *qdisc_skb_cb(const struct sk_buff *skb) |
211 | { | 231 | { |
212 | return (struct qdisc_skb_cb *)skb->cb; | 232 | return (struct qdisc_skb_cb *)skb->cb; |
213 | } | 233 | } |
@@ -321,6 +341,7 @@ extern void dev_init_scheduler(struct net_device *dev); | |||
321 | extern void dev_shutdown(struct net_device *dev); | 341 | extern void dev_shutdown(struct net_device *dev); |
322 | extern void dev_activate(struct net_device *dev); | 342 | extern void dev_activate(struct net_device *dev); |
323 | extern void dev_deactivate(struct net_device *dev); | 343 | extern void dev_deactivate(struct net_device *dev); |
344 | extern void dev_deactivate_many(struct list_head *head); | ||
324 | extern struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, | 345 | extern struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, |
325 | struct Qdisc *qdisc); | 346 | struct Qdisc *qdisc); |
326 | extern void qdisc_reset(struct Qdisc *qdisc); | 347 | extern void qdisc_reset(struct Qdisc *qdisc); |
@@ -328,11 +349,10 @@ extern void qdisc_destroy(struct Qdisc *qdisc); | |||
328 | extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n); | 349 | extern void qdisc_tree_decrease_qlen(struct Qdisc *qdisc, unsigned int n); |
329 | extern struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, | 350 | extern struct Qdisc *qdisc_alloc(struct netdev_queue *dev_queue, |
330 | struct Qdisc_ops *ops); | 351 | struct Qdisc_ops *ops); |
331 | extern struct Qdisc *qdisc_create_dflt(struct net_device *dev, | 352 | extern struct Qdisc *qdisc_create_dflt(struct netdev_queue *dev_queue, |
332 | struct netdev_queue *dev_queue, | ||
333 | struct Qdisc_ops *ops, u32 parentid); | 353 | struct Qdisc_ops *ops, u32 parentid); |
334 | extern void qdisc_calculate_pkt_len(struct sk_buff *skb, | 354 | extern void __qdisc_calculate_pkt_len(struct sk_buff *skb, |
335 | struct qdisc_size_table *stab); | 355 | const struct qdisc_size_table *stab); |
336 | extern void tcf_destroy(struct tcf_proto *tp); | 356 | extern void tcf_destroy(struct tcf_proto *tp); |
337 | extern void tcf_destroy_chain(struct tcf_proto **fl); | 357 | extern void tcf_destroy_chain(struct tcf_proto **fl); |
338 | 358 | ||
@@ -394,7 +414,7 @@ static inline bool qdisc_tx_is_noop(const struct net_device *dev) | |||
394 | return true; | 414 | return true; |
395 | } | 415 | } |
396 | 416 | ||
397 | static inline unsigned int qdisc_pkt_len(struct sk_buff *skb) | 417 | static inline unsigned int qdisc_pkt_len(const struct sk_buff *skb) |
398 | { | 418 | { |
399 | return qdisc_skb_cb(skb)->pkt_len; | 419 | return qdisc_skb_cb(skb)->pkt_len; |
400 | } | 420 | } |
@@ -411,12 +431,20 @@ enum net_xmit_qdisc_t { | |||
411 | #define net_xmit_drop_count(e) (1) | 431 | #define net_xmit_drop_count(e) (1) |
412 | #endif | 432 | #endif |
413 | 433 | ||
414 | static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch) | 434 | static inline void qdisc_calculate_pkt_len(struct sk_buff *skb, |
435 | const struct Qdisc *sch) | ||
415 | { | 436 | { |
416 | #ifdef CONFIG_NET_SCHED | 437 | #ifdef CONFIG_NET_SCHED |
417 | if (sch->stab) | 438 | struct qdisc_size_table *stab = rcu_dereference_bh(sch->stab); |
418 | qdisc_calculate_pkt_len(skb, sch->stab); | 439 | |
440 | if (stab) | ||
441 | __qdisc_calculate_pkt_len(skb, stab); | ||
419 | #endif | 442 | #endif |
443 | } | ||
444 | |||
445 | static inline int qdisc_enqueue(struct sk_buff *skb, struct Qdisc *sch) | ||
446 | { | ||
447 | qdisc_calculate_pkt_len(skb, sch); | ||
420 | return sch->enqueue(skb, sch); | 448 | return sch->enqueue(skb, sch); |
421 | } | 449 | } |
422 | 450 | ||
@@ -426,10 +454,18 @@ static inline int qdisc_enqueue_root(struct sk_buff *skb, struct Qdisc *sch) | |||
426 | return qdisc_enqueue(skb, sch) & NET_XMIT_MASK; | 454 | return qdisc_enqueue(skb, sch) & NET_XMIT_MASK; |
427 | } | 455 | } |
428 | 456 | ||
429 | static inline void __qdisc_update_bstats(struct Qdisc *sch, unsigned int len) | 457 | |
458 | static inline void bstats_update(struct gnet_stats_basic_packed *bstats, | ||
459 | const struct sk_buff *skb) | ||
460 | { | ||
461 | bstats->bytes += qdisc_pkt_len(skb); | ||
462 | bstats->packets += skb_is_gso(skb) ? skb_shinfo(skb)->gso_segs : 1; | ||
463 | } | ||
464 | |||
465 | static inline void qdisc_bstats_update(struct Qdisc *sch, | ||
466 | const struct sk_buff *skb) | ||
430 | { | 467 | { |
431 | sch->bstats.bytes += len; | 468 | bstats_update(&sch->bstats, skb); |
432 | sch->bstats.packets++; | ||
433 | } | 469 | } |
434 | 470 | ||
435 | static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch, | 471 | static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch, |
@@ -437,7 +473,6 @@ static inline int __qdisc_enqueue_tail(struct sk_buff *skb, struct Qdisc *sch, | |||
437 | { | 473 | { |
438 | __skb_queue_tail(list, skb); | 474 | __skb_queue_tail(list, skb); |
439 | sch->qstats.backlog += qdisc_pkt_len(skb); | 475 | sch->qstats.backlog += qdisc_pkt_len(skb); |
440 | __qdisc_update_bstats(sch, qdisc_pkt_len(skb)); | ||
441 | 476 | ||
442 | return NET_XMIT_SUCCESS; | 477 | return NET_XMIT_SUCCESS; |
443 | } | 478 | } |
@@ -452,8 +487,10 @@ static inline struct sk_buff *__qdisc_dequeue_head(struct Qdisc *sch, | |||
452 | { | 487 | { |
453 | struct sk_buff *skb = __skb_dequeue(list); | 488 | struct sk_buff *skb = __skb_dequeue(list); |
454 | 489 | ||
455 | if (likely(skb != NULL)) | 490 | if (likely(skb != NULL)) { |
456 | sch->qstats.backlog -= qdisc_pkt_len(skb); | 491 | sch->qstats.backlog -= qdisc_pkt_len(skb); |
492 | qdisc_bstats_update(sch, skb); | ||
493 | } | ||
457 | 494 | ||
458 | return skb; | 495 | return skb; |
459 | } | 496 | } |
@@ -466,10 +503,11 @@ static inline struct sk_buff *qdisc_dequeue_head(struct Qdisc *sch) | |||
466 | static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch, | 503 | static inline unsigned int __qdisc_queue_drop_head(struct Qdisc *sch, |
467 | struct sk_buff_head *list) | 504 | struct sk_buff_head *list) |
468 | { | 505 | { |
469 | struct sk_buff *skb = __qdisc_dequeue_head(sch, list); | 506 | struct sk_buff *skb = __skb_dequeue(list); |
470 | 507 | ||
471 | if (likely(skb != NULL)) { | 508 | if (likely(skb != NULL)) { |
472 | unsigned int len = qdisc_pkt_len(skb); | 509 | unsigned int len = qdisc_pkt_len(skb); |
510 | sch->qstats.backlog -= len; | ||
473 | kfree_skb(skb); | 511 | kfree_skb(skb); |
474 | return len; | 512 | return len; |
475 | } | 513 | } |
@@ -601,7 +639,7 @@ static inline u32 qdisc_l2t(struct qdisc_rate_table* rtab, unsigned int pktlen) | |||
601 | slot = 0; | 639 | slot = 0; |
602 | slot >>= rtab->rate.cell_log; | 640 | slot >>= rtab->rate.cell_log; |
603 | if (slot > 255) | 641 | if (slot > 255) |
604 | return (rtab->data[255]*(slot >> 8) + rtab->data[slot & 0xFF]); | 642 | return rtab->data[255]*(slot >> 8) + rtab->data[slot & 0xFF]; |
605 | return rtab->data[slot]; | 643 | return rtab->data[slot]; |
606 | } | 644 | } |
607 | 645 | ||
@@ -611,11 +649,7 @@ static inline struct sk_buff *skb_act_clone(struct sk_buff *skb, gfp_t gfp_mask, | |||
611 | { | 649 | { |
612 | struct sk_buff *n; | 650 | struct sk_buff *n; |
613 | 651 | ||
614 | if ((action == TC_ACT_STOLEN || action == TC_ACT_QUEUED) && | 652 | n = skb_clone(skb, gfp_mask); |
615 | !skb_shared(skb)) | ||
616 | n = skb_get(skb); | ||
617 | else | ||
618 | n = skb_clone(skb, gfp_mask); | ||
619 | 653 | ||
620 | if (n) { | 654 | if (n) { |
621 | n->tc_verd = SET_TC_VERD(n->tc_verd, 0); | 655 | n->tc_verd = SET_TC_VERD(n->tc_verd, 0); |
diff --git a/include/net/scm.h b/include/net/scm.h index 31656506d967..745460fa2f02 100644 --- a/include/net/scm.h +++ b/include/net/scm.h | |||
@@ -10,11 +10,12 @@ | |||
10 | /* Well, we should have at least one descriptor open | 10 | /* Well, we should have at least one descriptor open |
11 | * to accept passed FDs 8) | 11 | * to accept passed FDs 8) |
12 | */ | 12 | */ |
13 | #define SCM_MAX_FD 255 | 13 | #define SCM_MAX_FD 253 |
14 | 14 | ||
15 | struct scm_fp_list { | 15 | struct scm_fp_list { |
16 | struct list_head list; | 16 | struct list_head list; |
17 | int count; | 17 | short count; |
18 | short max; | ||
18 | struct file *fp[SCM_MAX_FD]; | 19 | struct file *fp[SCM_MAX_FD]; |
19 | }; | 20 | }; |
20 | 21 | ||
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h index 2c55a7ea20af..6506458ccd33 100644 --- a/include/net/sctp/command.h +++ b/include/net/sctp/command.h | |||
@@ -63,6 +63,7 @@ typedef enum { | |||
63 | SCTP_CMD_ECN_ECNE, /* Do delayed ECNE processing. */ | 63 | SCTP_CMD_ECN_ECNE, /* Do delayed ECNE processing. */ |
64 | SCTP_CMD_ECN_CWR, /* Do delayed CWR processing. */ | 64 | SCTP_CMD_ECN_CWR, /* Do delayed CWR processing. */ |
65 | SCTP_CMD_TIMER_START, /* Start a timer. */ | 65 | SCTP_CMD_TIMER_START, /* Start a timer. */ |
66 | SCTP_CMD_TIMER_START_ONCE, /* Start a timer once */ | ||
66 | SCTP_CMD_TIMER_RESTART, /* Restart a timer. */ | 67 | SCTP_CMD_TIMER_RESTART, /* Restart a timer. */ |
67 | SCTP_CMD_TIMER_STOP, /* Stop a timer. */ | 68 | SCTP_CMD_TIMER_STOP, /* Stop a timer. */ |
68 | SCTP_CMD_INIT_CHOOSE_TRANSPORT, /* Choose transport for an INIT. */ | 69 | SCTP_CMD_INIT_CHOOSE_TRANSPORT, /* Choose transport for an INIT. */ |
@@ -73,7 +74,6 @@ typedef enum { | |||
73 | SCTP_CMD_INIT_FAILED, /* High level, do init failure work. */ | 74 | SCTP_CMD_INIT_FAILED, /* High level, do init failure work. */ |
74 | SCTP_CMD_REPORT_DUP, /* Report a duplicate TSN. */ | 75 | SCTP_CMD_REPORT_DUP, /* Report a duplicate TSN. */ |
75 | SCTP_CMD_STRIKE, /* Mark a strike against a transport. */ | 76 | SCTP_CMD_STRIKE, /* Mark a strike against a transport. */ |
76 | SCTP_CMD_TRANSMIT, /* Transmit the outqueue. */ | ||
77 | SCTP_CMD_HB_TIMERS_START, /* Start the heartbeat timers. */ | 77 | SCTP_CMD_HB_TIMERS_START, /* Start the heartbeat timers. */ |
78 | SCTP_CMD_HB_TIMER_UPDATE, /* Update a heartbeat timers. */ | 78 | SCTP_CMD_HB_TIMER_UPDATE, /* Update a heartbeat timers. */ |
79 | SCTP_CMD_HB_TIMERS_STOP, /* Stop the heartbeat timers. */ | 79 | SCTP_CMD_HB_TIMERS_STOP, /* Stop the heartbeat timers. */ |
@@ -108,12 +108,10 @@ typedef enum { | |||
108 | SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */ | 108 | SCTP_CMD_UPDATE_INITTAG, /* Update peer inittag */ |
109 | SCTP_CMD_SEND_MSG, /* Send the whole use message */ | 109 | SCTP_CMD_SEND_MSG, /* Send the whole use message */ |
110 | SCTP_CMD_SEND_NEXT_ASCONF, /* Send the next ASCONF after ACK */ | 110 | SCTP_CMD_SEND_NEXT_ASCONF, /* Send the next ASCONF after ACK */ |
111 | SCTP_CMD_PURGE_ASCONF_QUEUE, /* Purge all asconf queues.*/ | ||
111 | SCTP_CMD_LAST | 112 | SCTP_CMD_LAST |
112 | } sctp_verb_t; | 113 | } sctp_verb_t; |
113 | 114 | ||
114 | #define SCTP_CMD_MAX (SCTP_CMD_LAST - 1) | ||
115 | #define SCTP_CMD_NUM_VERBS (SCTP_CMD_MAX + 1) | ||
116 | |||
117 | /* How many commands can you put in an sctp_cmd_seq_t? | 115 | /* How many commands can you put in an sctp_cmd_seq_t? |
118 | * This is a rather arbitrary number, ideally derived from a careful | 116 | * This is a rather arbitrary number, ideally derived from a careful |
119 | * analysis of the state functions, but in reality just taken from | 117 | * analysis of the state functions, but in reality just taken from |
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h index 63908840eef0..942b864f6135 100644 --- a/include/net/sctp/constants.h +++ b/include/net/sctp/constants.h | |||
@@ -61,7 +61,6 @@ enum { SCTP_DEFAULT_INSTREAMS = SCTP_MAX_STREAM }; | |||
61 | * symbols. CIDs are dense through SCTP_CID_BASE_MAX. | 61 | * symbols. CIDs are dense through SCTP_CID_BASE_MAX. |
62 | */ | 62 | */ |
63 | #define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE | 63 | #define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE |
64 | #define SCTP_CID_MAX SCTP_CID_ASCONF_ACK | ||
65 | 64 | ||
66 | #define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1) | 65 | #define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1) |
67 | 66 | ||
@@ -86,9 +85,6 @@ typedef enum { | |||
86 | 85 | ||
87 | } sctp_event_t; | 86 | } sctp_event_t; |
88 | 87 | ||
89 | #define SCTP_EVENT_T_MAX SCTP_EVENT_T_PRIMITIVE | ||
90 | #define SCTP_EVENT_T_NUM (SCTP_EVENT_T_MAX + 1) | ||
91 | |||
92 | /* As a convenience for the state machine, we append SCTP_EVENT_* and | 88 | /* As a convenience for the state machine, we append SCTP_EVENT_* and |
93 | * SCTP_ULP_* to the list of possible chunks. | 89 | * SCTP_ULP_* to the list of possible chunks. |
94 | */ | 90 | */ |
@@ -154,7 +150,6 @@ SCTP_SUBTYPE_CONSTRUCTOR(OTHER, sctp_event_other_t, other) | |||
154 | SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, sctp_event_primitive_t, primitive) | 150 | SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, sctp_event_primitive_t, primitive) |
155 | 151 | ||
156 | 152 | ||
157 | #define sctp_chunk_is_control(a) (a->chunk_hdr->type != SCTP_CID_DATA) | ||
158 | #define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA) | 153 | #define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA) |
159 | 154 | ||
160 | /* Calculate the actual data size in a data chunk */ | 155 | /* Calculate the actual data size in a data chunk */ |
@@ -162,9 +157,6 @@ SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, sctp_event_primitive_t, primitive) | |||
162 | - (unsigned long)(c->chunk_hdr)\ | 157 | - (unsigned long)(c->chunk_hdr)\ |
163 | - sizeof(sctp_data_chunk_t))) | 158 | - sizeof(sctp_data_chunk_t))) |
164 | 159 | ||
165 | #define SCTP_MAX_ERROR_CAUSE SCTP_ERROR_NONEXIST_IP | ||
166 | #define SCTP_NUM_ERROR_CAUSE 10 | ||
167 | |||
168 | /* Internal error codes */ | 160 | /* Internal error codes */ |
169 | typedef enum { | 161 | typedef enum { |
170 | 162 | ||
@@ -195,15 +187,14 @@ typedef enum { | |||
195 | /* SCTP state defines for internal state machine */ | 187 | /* SCTP state defines for internal state machine */ |
196 | typedef enum { | 188 | typedef enum { |
197 | 189 | ||
198 | SCTP_STATE_EMPTY = 0, | 190 | SCTP_STATE_CLOSED = 0, |
199 | SCTP_STATE_CLOSED = 1, | 191 | SCTP_STATE_COOKIE_WAIT = 1, |
200 | SCTP_STATE_COOKIE_WAIT = 2, | 192 | SCTP_STATE_COOKIE_ECHOED = 2, |
201 | SCTP_STATE_COOKIE_ECHOED = 3, | 193 | SCTP_STATE_ESTABLISHED = 3, |
202 | SCTP_STATE_ESTABLISHED = 4, | 194 | SCTP_STATE_SHUTDOWN_PENDING = 4, |
203 | SCTP_STATE_SHUTDOWN_PENDING = 5, | 195 | SCTP_STATE_SHUTDOWN_SENT = 5, |
204 | SCTP_STATE_SHUTDOWN_SENT = 6, | 196 | SCTP_STATE_SHUTDOWN_RECEIVED = 6, |
205 | SCTP_STATE_SHUTDOWN_RECEIVED = 7, | 197 | SCTP_STATE_SHUTDOWN_ACK_SENT = 7, |
206 | SCTP_STATE_SHUTDOWN_ACK_SENT = 8, | ||
207 | 198 | ||
208 | } sctp_state_t; | 199 | } sctp_state_t; |
209 | 200 | ||
@@ -266,7 +257,6 @@ enum { SCTP_ARBITRARY_COOKIE_ECHO_LEN = 200 }; | |||
266 | #define SCTP_TSN_MAP_INITIAL BITS_PER_LONG | 257 | #define SCTP_TSN_MAP_INITIAL BITS_PER_LONG |
267 | #define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL | 258 | #define SCTP_TSN_MAP_INCREMENT SCTP_TSN_MAP_INITIAL |
268 | #define SCTP_TSN_MAP_SIZE 4096 | 259 | #define SCTP_TSN_MAP_SIZE 4096 |
269 | #define SCTP_TSN_MAX_GAP 65535 | ||
270 | 260 | ||
271 | /* We will not record more than this many duplicate TSNs between two | 261 | /* We will not record more than this many duplicate TSNs between two |
272 | * SACKs. The minimum PMTU is 576. Remove all the headers and there | 262 | * SACKs. The minimum PMTU is 576. Remove all the headers and there |
@@ -301,9 +291,6 @@ enum { SCTP_MAX_GABS = 16 }; | |||
301 | 291 | ||
302 | #define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ | 292 | #define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */ |
303 | 293 | ||
304 | #define SCTP_DEF_MAX_INIT 6 | ||
305 | #define SCTP_DEF_MAX_SEND 10 | ||
306 | |||
307 | #define SCTP_DEFAULT_COOKIE_LIFE (60 * 1000) /* 60 seconds */ | 294 | #define SCTP_DEFAULT_COOKIE_LIFE (60 * 1000) /* 60 seconds */ |
308 | 295 | ||
309 | #define SCTP_DEFAULT_MINWINDOW 1500 /* default minimum rwnd size */ | 296 | #define SCTP_DEFAULT_MINWINDOW 1500 /* default minimum rwnd size */ |
@@ -317,9 +304,6 @@ enum { SCTP_MAX_GABS = 16 }; | |||
317 | */ | 304 | */ |
318 | #define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */ | 305 | #define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */ |
319 | #define SCTP_HOW_MANY_SECRETS 2 /* How many secrets I keep */ | 306 | #define SCTP_HOW_MANY_SECRETS 2 /* How many secrets I keep */ |
320 | #define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* How many seconds the current | ||
321 | * secret will live? | ||
322 | */ | ||
323 | #define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */ | 307 | #define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */ |
324 | 308 | ||
325 | #define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */ | 309 | #define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */ |
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index 65946bc43d00..b2c2366676a7 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
@@ -115,7 +115,6 @@ | |||
115 | * sctp/protocol.c | 115 | * sctp/protocol.c |
116 | */ | 116 | */ |
117 | extern struct sock *sctp_get_ctl_sock(void); | 117 | extern struct sock *sctp_get_ctl_sock(void); |
118 | extern void sctp_local_addr_free(struct rcu_head *head); | ||
119 | extern int sctp_copy_local_addr_list(struct sctp_bind_addr *, | 118 | extern int sctp_copy_local_addr_list(struct sctp_bind_addr *, |
120 | sctp_scope_t, gfp_t gfp, | 119 | sctp_scope_t, gfp_t gfp, |
121 | int flags); | 120 | int flags); |
@@ -275,24 +274,35 @@ struct sctp_mib { | |||
275 | /* Print debugging messages. */ | 274 | /* Print debugging messages. */ |
276 | #if SCTP_DEBUG | 275 | #if SCTP_DEBUG |
277 | extern int sctp_debug_flag; | 276 | extern int sctp_debug_flag; |
278 | #define SCTP_DEBUG_PRINTK(whatever...) \ | 277 | #define SCTP_DEBUG_PRINTK(fmt, args...) \ |
279 | ((void) (sctp_debug_flag && printk(KERN_DEBUG whatever))) | 278 | do { \ |
280 | #define SCTP_DEBUG_PRINTK_IPADDR(lead, trail, leadparm, saddr, otherparms...) \ | 279 | if (sctp_debug_flag) \ |
281 | if (sctp_debug_flag) { \ | 280 | printk(KERN_DEBUG pr_fmt(fmt), ##args); \ |
282 | if (saddr->sa.sa_family == AF_INET6) { \ | 281 | } while (0) |
283 | printk(KERN_DEBUG \ | 282 | #define SCTP_DEBUG_PRINTK_CONT(fmt, args...) \ |
284 | lead "%pI6" trail, \ | 283 | do { \ |
285 | leadparm, \ | 284 | if (sctp_debug_flag) \ |
286 | &saddr->v6.sin6_addr, \ | 285 | pr_cont(fmt, ##args); \ |
287 | otherparms); \ | 286 | } while (0) |
288 | } else { \ | 287 | #define SCTP_DEBUG_PRINTK_IPADDR(fmt_lead, fmt_trail, \ |
289 | printk(KERN_DEBUG \ | 288 | args_lead, saddr, args_trail...) \ |
290 | lead "%pI4" trail, \ | 289 | do { \ |
291 | leadparm, \ | 290 | if (sctp_debug_flag) { \ |
292 | &saddr->v4.sin_addr.s_addr, \ | 291 | if (saddr->sa.sa_family == AF_INET6) { \ |
293 | otherparms); \ | 292 | printk(KERN_DEBUG \ |
294 | } \ | 293 | pr_fmt(fmt_lead "%pI6" fmt_trail), \ |
295 | } | 294 | args_lead, \ |
295 | &saddr->v6.sin6_addr, \ | ||
296 | args_trail); \ | ||
297 | } else { \ | ||
298 | printk(KERN_DEBUG \ | ||
299 | pr_fmt(fmt_lead "%pI4" fmt_trail), \ | ||
300 | args_lead, \ | ||
301 | &saddr->v4.sin_addr.s_addr, \ | ||
302 | args_trail); \ | ||
303 | } \ | ||
304 | } \ | ||
305 | } while (0) | ||
296 | #define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; } | 306 | #define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; } |
297 | #define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; } | 307 | #define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; } |
298 | 308 | ||
@@ -306,6 +316,7 @@ extern int sctp_debug_flag; | |||
306 | #else /* SCTP_DEBUG */ | 316 | #else /* SCTP_DEBUG */ |
307 | 317 | ||
308 | #define SCTP_DEBUG_PRINTK(whatever...) | 318 | #define SCTP_DEBUG_PRINTK(whatever...) |
319 | #define SCTP_DEBUG_PRINTK_CONT(fmt, args...) | ||
309 | #define SCTP_DEBUG_PRINTK_IPADDR(whatever...) | 320 | #define SCTP_DEBUG_PRINTK_IPADDR(whatever...) |
310 | #define SCTP_ENABLE_DEBUG | 321 | #define SCTP_ENABLE_DEBUG |
311 | #define SCTP_DISABLE_DEBUG | 322 | #define SCTP_DISABLE_DEBUG |
@@ -393,7 +404,7 @@ static inline void sctp_v6_del_protocol(void) { return; } | |||
393 | /* Map an association to an assoc_id. */ | 404 | /* Map an association to an assoc_id. */ |
394 | static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc) | 405 | static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc) |
395 | { | 406 | { |
396 | return (asoc?asoc->assoc_id:0); | 407 | return asoc ? asoc->assoc_id : 0; |
397 | } | 408 | } |
398 | 409 | ||
399 | /* Look up the association by its id. */ | 410 | /* Look up the association by its id. */ |
@@ -461,7 +472,7 @@ static inline void sctp_skb_set_owner_r(struct sk_buff *skb, struct sock *sk) | |||
461 | /* Tests if the list has one and only one entry. */ | 472 | /* Tests if the list has one and only one entry. */ |
462 | static inline int sctp_list_single_entry(struct list_head *head) | 473 | static inline int sctp_list_single_entry(struct list_head *head) |
463 | { | 474 | { |
464 | return ((head->next != head) && (head->next == head->prev)); | 475 | return (head->next != head) && (head->next == head->prev); |
465 | } | 476 | } |
466 | 477 | ||
467 | /* Generate a random jitter in the range of -50% ~ +50% of input RTO. */ | 478 | /* Generate a random jitter in the range of -50% ~ +50% of input RTO. */ |
@@ -519,7 +530,6 @@ _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member) | |||
519 | 530 | ||
520 | #define _sctp_walk_params(pos, chunk, end, member)\ | 531 | #define _sctp_walk_params(pos, chunk, end, member)\ |
521 | for (pos.v = chunk->member;\ | 532 | for (pos.v = chunk->member;\ |
522 | pos.v <= (void *)chunk + end - sizeof(sctp_paramhdr_t) &&\ | ||
523 | pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ | 533 | pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ |
524 | ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\ | 534 | ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\ |
525 | pos.v += WORD_ROUND(ntohs(pos.p->length))) | 535 | pos.v += WORD_ROUND(ntohs(pos.p->length))) |
@@ -530,7 +540,6 @@ _sctp_walk_errors((err), (chunk_hdr), ntohs((chunk_hdr)->length)) | |||
530 | #define _sctp_walk_errors(err, chunk_hdr, end)\ | 540 | #define _sctp_walk_errors(err, chunk_hdr, end)\ |
531 | for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ | 541 | for (err = (sctp_errhdr_t *)((void *)chunk_hdr + \ |
532 | sizeof(sctp_chunkhdr_t));\ | 542 | sizeof(sctp_chunkhdr_t));\ |
533 | (void *)err <= (void *)chunk_hdr + end - sizeof(sctp_errhdr_t) &&\ | ||
534 | (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ | 543 | (void *)err <= (void *)chunk_hdr + end - ntohs(err->length) &&\ |
535 | ntohs(err->length) >= sizeof(sctp_errhdr_t); \ | 544 | ntohs(err->length) >= sizeof(sctp_errhdr_t); \ |
536 | err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length)))) | 545 | err = (sctp_errhdr_t *)((void *)err + WORD_ROUND(ntohs(err->length)))) |
@@ -619,13 +628,13 @@ static inline int sctp_sanity_check(void) | |||
619 | /* This is the hash function for the SCTP port hash table. */ | 628 | /* This is the hash function for the SCTP port hash table. */ |
620 | static inline int sctp_phashfn(__u16 lport) | 629 | static inline int sctp_phashfn(__u16 lport) |
621 | { | 630 | { |
622 | return (lport & (sctp_port_hashsize - 1)); | 631 | return lport & (sctp_port_hashsize - 1); |
623 | } | 632 | } |
624 | 633 | ||
625 | /* This is the hash function for the endpoint hash table. */ | 634 | /* This is the hash function for the endpoint hash table. */ |
626 | static inline int sctp_ep_hashfn(__u16 lport) | 635 | static inline int sctp_ep_hashfn(__u16 lport) |
627 | { | 636 | { |
628 | return (lport & (sctp_ep_hashsize - 1)); | 637 | return lport & (sctp_ep_hashsize - 1); |
629 | } | 638 | } |
630 | 639 | ||
631 | /* This is the hash function for the association hash table. */ | 640 | /* This is the hash function for the association hash table. */ |
@@ -633,7 +642,7 @@ static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport) | |||
633 | { | 642 | { |
634 | int h = (lport << 16) + rport; | 643 | int h = (lport << 16) + rport; |
635 | h ^= h>>8; | 644 | h ^= h>>8; |
636 | return (h & (sctp_assoc_hashsize - 1)); | 645 | return h & (sctp_assoc_hashsize - 1); |
637 | } | 646 | } |
638 | 647 | ||
639 | /* This is the hash function for the association hash table. This is | 648 | /* This is the hash function for the association hash table. This is |
@@ -644,7 +653,7 @@ static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag) | |||
644 | { | 653 | { |
645 | int h = (lport << 16) + rport; | 654 | int h = (lport << 16) + rport; |
646 | h ^= vtag; | 655 | h ^= vtag; |
647 | return (h & (sctp_assoc_hashsize-1)); | 656 | return h & (sctp_assoc_hashsize - 1); |
648 | } | 657 | } |
649 | 658 | ||
650 | #define sctp_for_each_hentry(epb, node, head) \ | 659 | #define sctp_for_each_hentry(epb, node, head) \ |
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h index 4088c89a9055..9148632b8204 100644 --- a/include/net/sctp/sm.h +++ b/include/net/sctp/sm.h | |||
@@ -165,6 +165,7 @@ sctp_state_fn_t sctp_sf_do_prm_requestheartbeat; | |||
165 | sctp_state_fn_t sctp_sf_do_prm_asconf; | 165 | sctp_state_fn_t sctp_sf_do_prm_asconf; |
166 | 166 | ||
167 | /* Prototypes for other event state functions. */ | 167 | /* Prototypes for other event state functions. */ |
168 | sctp_state_fn_t sctp_sf_do_no_pending_tsn; | ||
168 | sctp_state_fn_t sctp_sf_do_9_2_start_shutdown; | 169 | sctp_state_fn_t sctp_sf_do_9_2_start_shutdown; |
169 | sctp_state_fn_t sctp_sf_do_9_2_shutdown_ack; | 170 | sctp_state_fn_t sctp_sf_do_9_2_shutdown_ack; |
170 | sctp_state_fn_t sctp_sf_ignore_other; | 171 | sctp_state_fn_t sctp_sf_ignore_other; |
@@ -232,9 +233,7 @@ struct sctp_chunk *sctp_make_violation_paramlen(const struct sctp_association *, | |||
232 | const struct sctp_chunk *, | 233 | const struct sctp_chunk *, |
233 | struct sctp_paramhdr *); | 234 | struct sctp_paramhdr *); |
234 | struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *, | 235 | struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *, |
235 | const struct sctp_transport *, | 236 | const struct sctp_transport *); |
236 | const void *payload, | ||
237 | const size_t paylen); | ||
238 | struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *, | 237 | struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *, |
239 | const struct sctp_chunk *, | 238 | const struct sctp_chunk *, |
240 | const void *payload, | 239 | const void *payload, |
@@ -345,12 +344,12 @@ enum { | |||
345 | 344 | ||
346 | static inline int TSN_lt(__u32 s, __u32 t) | 345 | static inline int TSN_lt(__u32 s, __u32 t) |
347 | { | 346 | { |
348 | return (((s) - (t)) & TSN_SIGN_BIT); | 347 | return ((s) - (t)) & TSN_SIGN_BIT; |
349 | } | 348 | } |
350 | 349 | ||
351 | static inline int TSN_lte(__u32 s, __u32 t) | 350 | static inline int TSN_lte(__u32 s, __u32 t) |
352 | { | 351 | { |
353 | return (((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT)); | 352 | return ((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT); |
354 | } | 353 | } |
355 | 354 | ||
356 | /* Compare two SSNs */ | 355 | /* Compare two SSNs */ |
@@ -369,12 +368,12 @@ enum { | |||
369 | 368 | ||
370 | static inline int SSN_lt(__u16 s, __u16 t) | 369 | static inline int SSN_lt(__u16 s, __u16 t) |
371 | { | 370 | { |
372 | return (((s) - (t)) & SSN_SIGN_BIT); | 371 | return ((s) - (t)) & SSN_SIGN_BIT; |
373 | } | 372 | } |
374 | 373 | ||
375 | static inline int SSN_lte(__u16 s, __u16 t) | 374 | static inline int SSN_lte(__u16 s, __u16 t) |
376 | { | 375 | { |
377 | return (((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT)); | 376 | return ((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT); |
378 | } | 377 | } |
379 | 378 | ||
380 | /* | 379 | /* |
@@ -388,7 +387,7 @@ enum { | |||
388 | 387 | ||
389 | static inline int ADDIP_SERIAL_gte(__u16 s, __u16 t) | 388 | static inline int ADDIP_SERIAL_gte(__u16 s, __u16 t) |
390 | { | 389 | { |
391 | return (((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT)); | 390 | return ((s) == (t)) || (((t) - (s)) & ADDIP_SERIAL_SIGN_BIT); |
392 | } | 391 | } |
393 | 392 | ||
394 | /* Check VTAG of the packet matches the sender's own tag. */ | 393 | /* Check VTAG of the packet matches the sender's own tag. */ |
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index f9e7473613bd..7df327a6d564 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -261,8 +261,6 @@ extern struct sctp_globals { | |||
261 | #define sctp_assoc_hashsize (sctp_globals.assoc_hashsize) | 261 | #define sctp_assoc_hashsize (sctp_globals.assoc_hashsize) |
262 | #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) | 262 | #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) |
263 | #define sctp_port_hashsize (sctp_globals.port_hashsize) | 263 | #define sctp_port_hashsize (sctp_globals.port_hashsize) |
264 | #define sctp_port_rover (sctp_globals.port_rover) | ||
265 | #define sctp_port_alloc_lock (sctp_globals.port_alloc_lock) | ||
266 | #define sctp_port_hashtable (sctp_globals.port_hashtable) | 264 | #define sctp_port_hashtable (sctp_globals.port_hashtable) |
267 | #define sctp_local_addr_list (sctp_globals.local_addr_list) | 265 | #define sctp_local_addr_list (sctp_globals.local_addr_list) |
268 | #define sctp_local_addr_lock (sctp_globals.addr_list_lock) | 266 | #define sctp_local_addr_lock (sctp_globals.addr_list_lock) |
@@ -424,7 +422,7 @@ struct sctp_cookie { | |||
424 | __u32 adaptation_ind; | 422 | __u32 adaptation_ind; |
425 | 423 | ||
426 | __u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH]; | 424 | __u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH]; |
427 | __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS + 2]; | 425 | __u8 auth_hmacs[SCTP_AUTH_NUM_HMACS * sizeof(__u16) + 2]; |
428 | __u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS]; | 426 | __u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS]; |
429 | 427 | ||
430 | /* This is a shim for my peer's INIT packet, followed by | 428 | /* This is a shim for my peer's INIT packet, followed by |
@@ -566,19 +564,15 @@ struct sctp_af { | |||
566 | int optname, | 564 | int optname, |
567 | char __user *optval, | 565 | char __user *optval, |
568 | int __user *optlen); | 566 | int __user *optlen); |
569 | struct dst_entry *(*get_dst) (struct sctp_association *asoc, | 567 | void (*get_dst) (struct sctp_transport *t, |
570 | union sctp_addr *daddr, | 568 | union sctp_addr *saddr, |
571 | union sctp_addr *saddr); | 569 | struct flowi *fl, |
570 | struct sock *sk); | ||
572 | void (*get_saddr) (struct sctp_sock *sk, | 571 | void (*get_saddr) (struct sctp_sock *sk, |
573 | struct sctp_association *asoc, | 572 | struct sctp_transport *t, |
574 | struct dst_entry *dst, | 573 | struct flowi *fl); |
575 | union sctp_addr *daddr, | ||
576 | union sctp_addr *saddr); | ||
577 | void (*copy_addrlist) (struct list_head *, | 574 | void (*copy_addrlist) (struct list_head *, |
578 | struct net_device *); | 575 | struct net_device *); |
579 | void (*dst_saddr) (union sctp_addr *saddr, | ||
580 | struct dst_entry *dst, | ||
581 | __be16 port); | ||
582 | int (*cmp_addr) (const union sctp_addr *addr1, | 576 | int (*cmp_addr) (const union sctp_addr *addr1, |
583 | const union sctp_addr *addr2); | 577 | const union sctp_addr *addr2); |
584 | void (*addr_copy) (union sctp_addr *dst, | 578 | void (*addr_copy) (union sctp_addr *dst, |
@@ -847,7 +841,7 @@ void sctp_packet_free(struct sctp_packet *); | |||
847 | 841 | ||
848 | static inline int sctp_packet_empty(struct sctp_packet *packet) | 842 | static inline int sctp_packet_empty(struct sctp_packet *packet) |
849 | { | 843 | { |
850 | return (packet->size == packet->overhead); | 844 | return packet->size == packet->overhead; |
851 | } | 845 | } |
852 | 846 | ||
853 | /* This represents a remote transport address. | 847 | /* This represents a remote transport address. |
@@ -900,6 +894,7 @@ struct sctp_transport { | |||
900 | /* Is this structure kfree()able? */ | 894 | /* Is this structure kfree()able? */ |
901 | malloced:1; | 895 | malloced:1; |
902 | 896 | ||
897 | struct flowi fl; | ||
903 | 898 | ||
904 | /* This is the peer's IP address and port. */ | 899 | /* This is the peer's IP address and port. */ |
905 | union sctp_addr ipaddr; | 900 | union sctp_addr ipaddr; |
@@ -1063,7 +1058,7 @@ void sctp_transport_set_owner(struct sctp_transport *, | |||
1063 | struct sctp_association *); | 1058 | struct sctp_association *); |
1064 | void sctp_transport_route(struct sctp_transport *, union sctp_addr *, | 1059 | void sctp_transport_route(struct sctp_transport *, union sctp_addr *, |
1065 | struct sctp_sock *); | 1060 | struct sctp_sock *); |
1066 | void sctp_transport_pmtu(struct sctp_transport *); | 1061 | void sctp_transport_pmtu(struct sctp_transport *, struct sock *sk); |
1067 | void sctp_transport_free(struct sctp_transport *); | 1062 | void sctp_transport_free(struct sctp_transport *); |
1068 | void sctp_transport_reset_timers(struct sctp_transport *); | 1063 | void sctp_transport_reset_timers(struct sctp_transport *); |
1069 | void sctp_transport_hold(struct sctp_transport *); | 1064 | void sctp_transport_hold(struct sctp_transport *); |
@@ -1402,7 +1397,7 @@ int sctp_has_association(const union sctp_addr *laddr, | |||
1402 | int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t, | 1397 | int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t, |
1403 | sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk, | 1398 | sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk, |
1404 | struct sctp_chunk **err_chunk); | 1399 | struct sctp_chunk **err_chunk); |
1405 | int sctp_process_init(struct sctp_association *, sctp_cid_t cid, | 1400 | int sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk, |
1406 | const union sctp_addr *peer, | 1401 | const union sctp_addr *peer, |
1407 | sctp_init_chunk_t *init, gfp_t gfp); | 1402 | sctp_init_chunk_t *init, gfp_t gfp); |
1408 | __u32 sctp_generate_tag(const struct sctp_endpoint *); | 1403 | __u32 sctp_generate_tag(const struct sctp_endpoint *); |
@@ -1998,7 +1993,7 @@ void sctp_assoc_clean_asconf_ack_cache(const struct sctp_association *asoc); | |||
1998 | struct sctp_chunk *sctp_assoc_lookup_asconf_ack( | 1993 | struct sctp_chunk *sctp_assoc_lookup_asconf_ack( |
1999 | const struct sctp_association *asoc, | 1994 | const struct sctp_association *asoc, |
2000 | __be32 serial); | 1995 | __be32 serial); |
2001 | 1996 | void sctp_asconf_queue_teardown(struct sctp_association *asoc); | |
2002 | 1997 | ||
2003 | int sctp_cmp_addr_exact(const union sctp_addr *ss1, | 1998 | int sctp_cmp_addr_exact(const union sctp_addr *ss1, |
2004 | const union sctp_addr *ss2); | 1999 | const union sctp_addr *ss2); |
diff --git a/include/net/sctp/tsnmap.h b/include/net/sctp/tsnmap.h index 4aabc5a96cf6..e7728bc14ccf 100644 --- a/include/net/sctp/tsnmap.h +++ b/include/net/sctp/tsnmap.h | |||
@@ -157,7 +157,7 @@ __u16 sctp_tsnmap_pending(struct sctp_tsnmap *map); | |||
157 | /* Is there a gap in the TSN map? */ | 157 | /* Is there a gap in the TSN map? */ |
158 | static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map) | 158 | static inline int sctp_tsnmap_has_gap(const struct sctp_tsnmap *map) |
159 | { | 159 | { |
160 | return (map->cumulative_tsn_ack_point != map->max_tsn_seen); | 160 | return map->cumulative_tsn_ack_point != map->max_tsn_seen; |
161 | } | 161 | } |
162 | 162 | ||
163 | /* Mark a duplicate TSN. Note: limit the storage of duplicate TSN | 163 | /* Mark a duplicate TSN. Note: limit the storage of duplicate TSN |
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h index 7ea12e8e6676..ca4693b4e09e 100644 --- a/include/net/sctp/ulpevent.h +++ b/include/net/sctp/ulpevent.h | |||
@@ -80,7 +80,7 @@ static inline struct sctp_ulpevent *sctp_skb2event(struct sk_buff *skb) | |||
80 | 80 | ||
81 | void sctp_ulpevent_free(struct sctp_ulpevent *); | 81 | void sctp_ulpevent_free(struct sctp_ulpevent *); |
82 | int sctp_ulpevent_is_notification(const struct sctp_ulpevent *); | 82 | int sctp_ulpevent_is_notification(const struct sctp_ulpevent *); |
83 | void sctp_queue_purge_ulpevents(struct sk_buff_head *list); | 83 | unsigned int sctp_queue_purge_ulpevents(struct sk_buff_head *list); |
84 | 84 | ||
85 | struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( | 85 | struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( |
86 | const struct sctp_association *asoc, | 86 | const struct sctp_association *asoc, |
@@ -132,6 +132,9 @@ struct sctp_ulpevent *sctp_ulpevent_make_authkey( | |||
132 | const struct sctp_association *asoc, __u16 key_id, | 132 | const struct sctp_association *asoc, __u16 key_id, |
133 | __u32 indication, gfp_t gfp); | 133 | __u32 indication, gfp_t gfp); |
134 | 134 | ||
135 | struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event( | ||
136 | const struct sctp_association *asoc, gfp_t gfp); | ||
137 | |||
135 | void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, | 138 | void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, |
136 | struct msghdr *); | 139 | struct msghdr *); |
137 | __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event); | 140 | __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event); |
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h index 2b2769c5ca9f..32fd51274037 100644 --- a/include/net/sctp/user.h +++ b/include/net/sctp/user.h | |||
@@ -78,6 +78,7 @@ typedef __s32 sctp_assoc_t; | |||
78 | #define SCTP_GET_PEER_ADDR_INFO 15 | 78 | #define SCTP_GET_PEER_ADDR_INFO 15 |
79 | #define SCTP_DELAYED_ACK_TIME 16 | 79 | #define SCTP_DELAYED_ACK_TIME 16 |
80 | #define SCTP_DELAYED_ACK SCTP_DELAYED_ACK_TIME | 80 | #define SCTP_DELAYED_ACK SCTP_DELAYED_ACK_TIME |
81 | #define SCTP_DELAYED_SACK SCTP_DELAYED_ACK_TIME | ||
81 | #define SCTP_CONTEXT 17 | 82 | #define SCTP_CONTEXT 17 |
82 | #define SCTP_FRAGMENT_INTERLEAVE 18 | 83 | #define SCTP_FRAGMENT_INTERLEAVE 18 |
83 | #define SCTP_PARTIAL_DELIVERY_POINT 19 /* Set/Get partial delivery point */ | 84 | #define SCTP_PARTIAL_DELIVERY_POINT 19 /* Set/Get partial delivery point */ |
@@ -90,6 +91,7 @@ typedef __s32 sctp_assoc_t; | |||
90 | #define SCTP_PEER_AUTH_CHUNKS 26 /* Read only */ | 91 | #define SCTP_PEER_AUTH_CHUNKS 26 /* Read only */ |
91 | #define SCTP_LOCAL_AUTH_CHUNKS 27 /* Read only */ | 92 | #define SCTP_LOCAL_AUTH_CHUNKS 27 /* Read only */ |
92 | #define SCTP_GET_ASSOC_NUMBER 28 /* Read only */ | 93 | #define SCTP_GET_ASSOC_NUMBER 28 /* Read only */ |
94 | #define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */ | ||
93 | 95 | ||
94 | /* Internal Socket Options. Some of the sctp library functions are | 96 | /* Internal Socket Options. Some of the sctp library functions are |
95 | * implemented using these socket options. | 97 | * implemented using these socket options. |
@@ -99,8 +101,8 @@ typedef __s32 sctp_assoc_t; | |||
99 | #define SCTP_SOCKOPT_PEELOFF 102 /* peel off association. */ | 101 | #define SCTP_SOCKOPT_PEELOFF 102 /* peel off association. */ |
100 | /* Options 104-106 are deprecated and removed. Do not use this space */ | 102 | /* Options 104-106 are deprecated and removed. Do not use this space */ |
101 | #define SCTP_SOCKOPT_CONNECTX_OLD 107 /* CONNECTX old requests. */ | 103 | #define SCTP_SOCKOPT_CONNECTX_OLD 107 /* CONNECTX old requests. */ |
102 | #define SCTP_GET_PEER_ADDRS 108 /* Get all peer addresss. */ | 104 | #define SCTP_GET_PEER_ADDRS 108 /* Get all peer address. */ |
103 | #define SCTP_GET_LOCAL_ADDRS 109 /* Get all local addresss. */ | 105 | #define SCTP_GET_LOCAL_ADDRS 109 /* Get all local address. */ |
104 | #define SCTP_SOCKOPT_CONNECTX 110 /* CONNECTX requests. */ | 106 | #define SCTP_SOCKOPT_CONNECTX 110 /* CONNECTX requests. */ |
105 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ | 107 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ |
106 | 108 | ||
@@ -352,6 +354,20 @@ struct sctp_authkey_event { | |||
352 | 354 | ||
353 | enum { SCTP_AUTH_NEWKEY = 0, }; | 355 | enum { SCTP_AUTH_NEWKEY = 0, }; |
354 | 356 | ||
357 | /* | ||
358 | * 6.1.9. SCTP_SENDER_DRY_EVENT | ||
359 | * | ||
360 | * When the SCTP stack has no more user data to send or retransmit, this | ||
361 | * notification is given to the user. Also, at the time when a user app | ||
362 | * subscribes to this event, if there is no data to be sent or | ||
363 | * retransmit, the stack will immediately send up this notification. | ||
364 | */ | ||
365 | struct sctp_sender_dry_event { | ||
366 | __u16 sender_dry_type; | ||
367 | __u16 sender_dry_flags; | ||
368 | __u32 sender_dry_length; | ||
369 | sctp_assoc_t sender_dry_assoc_id; | ||
370 | }; | ||
355 | 371 | ||
356 | /* | 372 | /* |
357 | * Described in Section 7.3 | 373 | * Described in Section 7.3 |
@@ -367,6 +383,7 @@ struct sctp_event_subscribe { | |||
367 | __u8 sctp_partial_delivery_event; | 383 | __u8 sctp_partial_delivery_event; |
368 | __u8 sctp_adaptation_layer_event; | 384 | __u8 sctp_adaptation_layer_event; |
369 | __u8 sctp_authentication_event; | 385 | __u8 sctp_authentication_event; |
386 | __u8 sctp_sender_dry_event; | ||
370 | }; | 387 | }; |
371 | 388 | ||
372 | /* | 389 | /* |
@@ -390,6 +407,7 @@ union sctp_notification { | |||
390 | struct sctp_adaptation_event sn_adaptation_event; | 407 | struct sctp_adaptation_event sn_adaptation_event; |
391 | struct sctp_pdapi_event sn_pdapi_event; | 408 | struct sctp_pdapi_event sn_pdapi_event; |
392 | struct sctp_authkey_event sn_authkey_event; | 409 | struct sctp_authkey_event sn_authkey_event; |
410 | struct sctp_sender_dry_event sn_sender_dry_event; | ||
393 | }; | 411 | }; |
394 | 412 | ||
395 | /* Section 5.3.1 | 413 | /* Section 5.3.1 |
@@ -406,7 +424,9 @@ enum sctp_sn_type { | |||
406 | SCTP_SHUTDOWN_EVENT, | 424 | SCTP_SHUTDOWN_EVENT, |
407 | SCTP_PARTIAL_DELIVERY_EVENT, | 425 | SCTP_PARTIAL_DELIVERY_EVENT, |
408 | SCTP_ADAPTATION_INDICATION, | 426 | SCTP_ADAPTATION_INDICATION, |
409 | SCTP_AUTHENTICATION_INDICATION, | 427 | SCTP_AUTHENTICATION_EVENT, |
428 | #define SCTP_AUTHENTICATION_INDICATION SCTP_AUTHENTICATION_EVENT | ||
429 | SCTP_SENDER_DRY_EVENT, | ||
410 | }; | 430 | }; |
411 | 431 | ||
412 | /* Notification error codes used to fill up the error fields in some | 432 | /* Notification error codes used to fill up the error fields in some |
@@ -668,6 +688,18 @@ struct sctp_authchunks { | |||
668 | }; | 688 | }; |
669 | 689 | ||
670 | /* | 690 | /* |
691 | * 8.2.6. Get the Current Identifiers of Associations | ||
692 | * (SCTP_GET_ASSOC_ID_LIST) | ||
693 | * | ||
694 | * This option gets the current list of SCTP association identifiers of | ||
695 | * the SCTP associations handled by a one-to-many style socket. | ||
696 | */ | ||
697 | struct sctp_assoc_ids { | ||
698 | __u32 gaids_number_of_ids; | ||
699 | sctp_assoc_t gaids_assoc_id[]; | ||
700 | }; | ||
701 | |||
702 | /* | ||
671 | * 8.3, 8.5 get all peer/local addresses in an association. | 703 | * 8.3, 8.5 get all peer/local addresses in an association. |
672 | * This parameter struct is used by SCTP_GET_PEER_ADDRS and | 704 | * This parameter struct is used by SCTP_GET_PEER_ADDRS and |
673 | * SCTP_GET_LOCAL_ADDRS socket options used internally to implement | 705 | * SCTP_GET_LOCAL_ADDRS socket options used internally to implement |
diff --git a/include/net/snmp.h b/include/net/snmp.h index a0e61806d480..479083a78b0c 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h | |||
@@ -60,9 +60,7 @@ struct ipstats_mib { | |||
60 | }; | 60 | }; |
61 | 61 | ||
62 | /* ICMP */ | 62 | /* ICMP */ |
63 | #define ICMP_MIB_DUMMY __ICMP_MIB_MAX | 63 | #define ICMP_MIB_MAX __ICMP_MIB_MAX |
64 | #define ICMP_MIB_MAX (__ICMP_MIB_MAX + 1) | ||
65 | |||
66 | struct icmp_mib { | 64 | struct icmp_mib { |
67 | unsigned long mibs[ICMP_MIB_MAX]; | 65 | unsigned long mibs[ICMP_MIB_MAX]; |
68 | }; | 66 | }; |
@@ -74,14 +72,24 @@ struct icmpmsg_mib { | |||
74 | 72 | ||
75 | /* ICMP6 (IPv6-ICMP) */ | 73 | /* ICMP6 (IPv6-ICMP) */ |
76 | #define ICMP6_MIB_MAX __ICMP6_MIB_MAX | 74 | #define ICMP6_MIB_MAX __ICMP6_MIB_MAX |
75 | /* per network ns counters */ | ||
77 | struct icmpv6_mib { | 76 | struct icmpv6_mib { |
78 | unsigned long mibs[ICMP6_MIB_MAX]; | 77 | unsigned long mibs[ICMP6_MIB_MAX]; |
79 | }; | 78 | }; |
79 | /* per device counters, (shared on all cpus) */ | ||
80 | struct icmpv6_mib_device { | ||
81 | atomic_long_t mibs[ICMP6_MIB_MAX]; | ||
82 | }; | ||
80 | 83 | ||
81 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX | 84 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX |
85 | /* per network ns counters */ | ||
82 | struct icmpv6msg_mib { | 86 | struct icmpv6msg_mib { |
83 | unsigned long mibs[ICMP6MSG_MIB_MAX]; | 87 | unsigned long mibs[ICMP6MSG_MIB_MAX]; |
84 | }; | 88 | }; |
89 | /* per device counters, (shared on all cpus) */ | ||
90 | struct icmpv6msg_mib_device { | ||
91 | atomic_long_t mibs[ICMP6MSG_MIB_MAX]; | ||
92 | }; | ||
85 | 93 | ||
86 | 94 | ||
87 | /* TCP */ | 95 | /* TCP */ |
@@ -116,6 +124,8 @@ struct linux_xfrm_mib { | |||
116 | */ | 124 | */ |
117 | #define DEFINE_SNMP_STAT(type, name) \ | 125 | #define DEFINE_SNMP_STAT(type, name) \ |
118 | __typeof__(type) __percpu *name[2] | 126 | __typeof__(type) __percpu *name[2] |
127 | #define DEFINE_SNMP_STAT_ATOMIC(type, name) \ | ||
128 | __typeof__(type) *name | ||
119 | #define DECLARE_SNMP_STAT(type, name) \ | 129 | #define DECLARE_SNMP_STAT(type, name) \ |
120 | extern __typeof__(type) __percpu *name[2] | 130 | extern __typeof__(type) __percpu *name[2] |
121 | 131 | ||
@@ -126,6 +136,8 @@ struct linux_xfrm_mib { | |||
126 | __this_cpu_inc(mib[0]->mibs[field]) | 136 | __this_cpu_inc(mib[0]->mibs[field]) |
127 | #define SNMP_INC_STATS_USER(mib, field) \ | 137 | #define SNMP_INC_STATS_USER(mib, field) \ |
128 | this_cpu_inc(mib[1]->mibs[field]) | 138 | this_cpu_inc(mib[1]->mibs[field]) |
139 | #define SNMP_INC_STATS_ATOMIC_LONG(mib, field) \ | ||
140 | atomic_long_inc(&mib->mibs[field]) | ||
129 | #define SNMP_INC_STATS(mib, field) \ | 141 | #define SNMP_INC_STATS(mib, field) \ |
130 | this_cpu_inc(mib[!in_softirq()]->mibs[field]) | 142 | this_cpu_inc(mib[!in_softirq()]->mibs[field]) |
131 | #define SNMP_DEC_STATS(mib, field) \ | 143 | #define SNMP_DEC_STATS(mib, field) \ |
@@ -152,7 +164,7 @@ struct linux_xfrm_mib { | |||
152 | #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ | 164 | #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ |
153 | do { \ | 165 | do { \ |
154 | __typeof__(*mib[0]) *ptr = \ | 166 | __typeof__(*mib[0]) *ptr = \ |
155 | __this_cpu_ptr((mib)[!in_softirq()]); \ | 167 | __this_cpu_ptr((mib)[0]); \ |
156 | ptr->mibs[basefield##PKTS]++; \ | 168 | ptr->mibs[basefield##PKTS]++; \ |
157 | ptr->mibs[basefield##OCTETS] += addend;\ | 169 | ptr->mibs[basefield##OCTETS] += addend;\ |
158 | } while (0) | 170 | } while (0) |
@@ -204,7 +216,7 @@ struct linux_xfrm_mib { | |||
204 | #define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \ | 216 | #define SNMP_UPD_PO_STATS64_BH(mib, basefield, addend) \ |
205 | do { \ | 217 | do { \ |
206 | __typeof__(*mib[0]) *ptr; \ | 218 | __typeof__(*mib[0]) *ptr; \ |
207 | ptr = __this_cpu_ptr((mib)[!in_softirq()]); \ | 219 | ptr = __this_cpu_ptr((mib)[0]); \ |
208 | u64_stats_update_begin(&ptr->syncp); \ | 220 | u64_stats_update_begin(&ptr->syncp); \ |
209 | ptr->mibs[basefield##PKTS]++; \ | 221 | ptr->mibs[basefield##PKTS]++; \ |
210 | ptr->mibs[basefield##OCTETS] += addend; \ | 222 | ptr->mibs[basefield##OCTETS] += addend; \ |
diff --git a/include/net/sock.h b/include/net/sock.h index adab9dc58183..c0b938cb4b1a 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -52,12 +52,13 @@ | |||
52 | #include <linux/mm.h> | 52 | #include <linux/mm.h> |
53 | #include <linux/security.h> | 53 | #include <linux/security.h> |
54 | #include <linux/slab.h> | 54 | #include <linux/slab.h> |
55 | #include <linux/uaccess.h> | ||
55 | 56 | ||
56 | #include <linux/filter.h> | 57 | #include <linux/filter.h> |
57 | #include <linux/rculist_nulls.h> | 58 | #include <linux/rculist_nulls.h> |
58 | #include <linux/poll.h> | 59 | #include <linux/poll.h> |
59 | 60 | ||
60 | #include <asm/atomic.h> | 61 | #include <linux/atomic.h> |
61 | #include <net/dst.h> | 62 | #include <net/dst.h> |
62 | #include <net/checksum.h> | 63 | #include <net/checksum.h> |
63 | 64 | ||
@@ -105,10 +106,8 @@ struct net; | |||
105 | 106 | ||
106 | /** | 107 | /** |
107 | * struct sock_common - minimal network layer representation of sockets | 108 | * struct sock_common - minimal network layer representation of sockets |
108 | * @skc_node: main hash linkage for various protocol lookup tables | 109 | * @skc_daddr: Foreign IPv4 addr |
109 | * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol | 110 | * @skc_rcv_saddr: Bound local IPv4 addr |
110 | * @skc_refcnt: reference count | ||
111 | * @skc_tx_queue_mapping: tx queue number for this connection | ||
112 | * @skc_hash: hash value used with various protocol lookup tables | 111 | * @skc_hash: hash value used with various protocol lookup tables |
113 | * @skc_u16hashes: two u16 hash values used by UDP lookup tables | 112 | * @skc_u16hashes: two u16 hash values used by UDP lookup tables |
114 | * @skc_family: network address family | 113 | * @skc_family: network address family |
@@ -119,20 +118,20 @@ struct net; | |||
119 | * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol | 118 | * @skc_portaddr_node: second hash linkage for UDP/UDP-Lite protocol |
120 | * @skc_prot: protocol handlers inside a network family | 119 | * @skc_prot: protocol handlers inside a network family |
121 | * @skc_net: reference to the network namespace of this socket | 120 | * @skc_net: reference to the network namespace of this socket |
121 | * @skc_node: main hash linkage for various protocol lookup tables | ||
122 | * @skc_nulls_node: main hash linkage for TCP/UDP/UDP-Lite protocol | ||
123 | * @skc_tx_queue_mapping: tx queue number for this connection | ||
124 | * @skc_refcnt: reference count | ||
122 | * | 125 | * |
123 | * This is the minimal network layer representation of sockets, the header | 126 | * This is the minimal network layer representation of sockets, the header |
124 | * for struct sock and struct inet_timewait_sock. | 127 | * for struct sock and struct inet_timewait_sock. |
125 | */ | 128 | */ |
126 | struct sock_common { | 129 | struct sock_common { |
127 | /* | 130 | /* skc_daddr and skc_rcv_saddr must be grouped : |
128 | * first fields are not copied in sock_copy() | 131 | * cf INET_MATCH() and INET_TW_MATCH() |
129 | */ | 132 | */ |
130 | union { | 133 | __be32 skc_daddr; |
131 | struct hlist_node skc_node; | 134 | __be32 skc_rcv_saddr; |
132 | struct hlist_nulls_node skc_nulls_node; | ||
133 | }; | ||
134 | atomic_t skc_refcnt; | ||
135 | int skc_tx_queue_mapping; | ||
136 | 135 | ||
137 | union { | 136 | union { |
138 | unsigned int skc_hash; | 137 | unsigned int skc_hash; |
@@ -150,6 +149,22 @@ struct sock_common { | |||
150 | #ifdef CONFIG_NET_NS | 149 | #ifdef CONFIG_NET_NS |
151 | struct net *skc_net; | 150 | struct net *skc_net; |
152 | #endif | 151 | #endif |
152 | /* | ||
153 | * fields between dontcopy_begin/dontcopy_end | ||
154 | * are not copied in sock_copy() | ||
155 | */ | ||
156 | /* private: */ | ||
157 | int skc_dontcopy_begin[0]; | ||
158 | /* public: */ | ||
159 | union { | ||
160 | struct hlist_node skc_node; | ||
161 | struct hlist_nulls_node skc_nulls_node; | ||
162 | }; | ||
163 | int skc_tx_queue_mapping; | ||
164 | atomic_t skc_refcnt; | ||
165 | /* private: */ | ||
166 | int skc_dontcopy_end[0]; | ||
167 | /* public: */ | ||
153 | }; | 168 | }; |
154 | 169 | ||
155 | /** | 170 | /** |
@@ -163,7 +178,6 @@ struct sock_common { | |||
163 | * @sk_dst_cache: destination cache | 178 | * @sk_dst_cache: destination cache |
164 | * @sk_dst_lock: destination cache lock | 179 | * @sk_dst_lock: destination cache lock |
165 | * @sk_policy: flow policy | 180 | * @sk_policy: flow policy |
166 | * @sk_rmem_alloc: receive queue bytes committed | ||
167 | * @sk_receive_queue: incoming packets | 181 | * @sk_receive_queue: incoming packets |
168 | * @sk_wmem_alloc: transmit queue bytes committed | 182 | * @sk_wmem_alloc: transmit queue bytes committed |
169 | * @sk_write_queue: Packet sending queue | 183 | * @sk_write_queue: Packet sending queue |
@@ -232,7 +246,8 @@ struct sock { | |||
232 | #define sk_refcnt __sk_common.skc_refcnt | 246 | #define sk_refcnt __sk_common.skc_refcnt |
233 | #define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping | 247 | #define sk_tx_queue_mapping __sk_common.skc_tx_queue_mapping |
234 | 248 | ||
235 | #define sk_copy_start __sk_common.skc_hash | 249 | #define sk_dontcopy_begin __sk_common.skc_dontcopy_begin |
250 | #define sk_dontcopy_end __sk_common.skc_dontcopy_end | ||
236 | #define sk_hash __sk_common.skc_hash | 251 | #define sk_hash __sk_common.skc_hash |
237 | #define sk_family __sk_common.skc_family | 252 | #define sk_family __sk_common.skc_family |
238 | #define sk_state __sk_common.skc_state | 253 | #define sk_state __sk_common.skc_state |
@@ -241,59 +256,67 @@ struct sock { | |||
241 | #define sk_bind_node __sk_common.skc_bind_node | 256 | #define sk_bind_node __sk_common.skc_bind_node |
242 | #define sk_prot __sk_common.skc_prot | 257 | #define sk_prot __sk_common.skc_prot |
243 | #define sk_net __sk_common.skc_net | 258 | #define sk_net __sk_common.skc_net |
244 | kmemcheck_bitfield_begin(flags); | ||
245 | unsigned int sk_shutdown : 2, | ||
246 | sk_no_check : 2, | ||
247 | sk_userlocks : 4, | ||
248 | sk_protocol : 8, | ||
249 | sk_type : 16; | ||
250 | kmemcheck_bitfield_end(flags); | ||
251 | int sk_rcvbuf; | ||
252 | socket_lock_t sk_lock; | 259 | socket_lock_t sk_lock; |
260 | struct sk_buff_head sk_receive_queue; | ||
253 | /* | 261 | /* |
254 | * The backlog queue is special, it is always used with | 262 | * The backlog queue is special, it is always used with |
255 | * the per-socket spinlock held and requires low latency | 263 | * the per-socket spinlock held and requires low latency |
256 | * access. Therefore we special case it's implementation. | 264 | * access. Therefore we special case it's implementation. |
265 | * Note : rmem_alloc is in this structure to fill a hole | ||
266 | * on 64bit arches, not because its logically part of | ||
267 | * backlog. | ||
257 | */ | 268 | */ |
258 | struct { | 269 | struct { |
259 | struct sk_buff *head; | 270 | atomic_t rmem_alloc; |
260 | struct sk_buff *tail; | 271 | int len; |
261 | int len; | 272 | struct sk_buff *head; |
273 | struct sk_buff *tail; | ||
262 | } sk_backlog; | 274 | } sk_backlog; |
263 | struct socket_wq *sk_wq; | 275 | #define sk_rmem_alloc sk_backlog.rmem_alloc |
264 | struct dst_entry *sk_dst_cache; | 276 | int sk_forward_alloc; |
277 | #ifdef CONFIG_RPS | ||
278 | __u32 sk_rxhash; | ||
279 | #endif | ||
280 | atomic_t sk_drops; | ||
281 | int sk_rcvbuf; | ||
282 | |||
283 | struct sk_filter __rcu *sk_filter; | ||
284 | struct socket_wq __rcu *sk_wq; | ||
285 | |||
286 | #ifdef CONFIG_NET_DMA | ||
287 | struct sk_buff_head sk_async_wait_queue; | ||
288 | #endif | ||
289 | |||
265 | #ifdef CONFIG_XFRM | 290 | #ifdef CONFIG_XFRM |
266 | struct xfrm_policy *sk_policy[2]; | 291 | struct xfrm_policy *sk_policy[2]; |
267 | #endif | 292 | #endif |
293 | unsigned long sk_flags; | ||
294 | struct dst_entry *sk_dst_cache; | ||
268 | spinlock_t sk_dst_lock; | 295 | spinlock_t sk_dst_lock; |
269 | atomic_t sk_rmem_alloc; | ||
270 | atomic_t sk_wmem_alloc; | 296 | atomic_t sk_wmem_alloc; |
271 | atomic_t sk_omem_alloc; | 297 | atomic_t sk_omem_alloc; |
272 | int sk_sndbuf; | 298 | int sk_sndbuf; |
273 | struct sk_buff_head sk_receive_queue; | ||
274 | struct sk_buff_head sk_write_queue; | 299 | struct sk_buff_head sk_write_queue; |
275 | #ifdef CONFIG_NET_DMA | 300 | kmemcheck_bitfield_begin(flags); |
276 | struct sk_buff_head sk_async_wait_queue; | 301 | unsigned int sk_shutdown : 2, |
277 | #endif | 302 | sk_no_check : 2, |
303 | sk_userlocks : 4, | ||
304 | sk_protocol : 8, | ||
305 | sk_type : 16; | ||
306 | kmemcheck_bitfield_end(flags); | ||
278 | int sk_wmem_queued; | 307 | int sk_wmem_queued; |
279 | int sk_forward_alloc; | ||
280 | gfp_t sk_allocation; | 308 | gfp_t sk_allocation; |
281 | int sk_route_caps; | 309 | int sk_route_caps; |
282 | int sk_route_nocaps; | 310 | int sk_route_nocaps; |
283 | int sk_gso_type; | 311 | int sk_gso_type; |
284 | unsigned int sk_gso_max_size; | 312 | unsigned int sk_gso_max_size; |
285 | int sk_rcvlowat; | 313 | int sk_rcvlowat; |
286 | #ifdef CONFIG_RPS | ||
287 | __u32 sk_rxhash; | ||
288 | #endif | ||
289 | unsigned long sk_flags; | ||
290 | unsigned long sk_lingertime; | 314 | unsigned long sk_lingertime; |
291 | struct sk_buff_head sk_error_queue; | 315 | struct sk_buff_head sk_error_queue; |
292 | struct proto *sk_prot_creator; | 316 | struct proto *sk_prot_creator; |
293 | rwlock_t sk_callback_lock; | 317 | rwlock_t sk_callback_lock; |
294 | int sk_err, | 318 | int sk_err, |
295 | sk_err_soft; | 319 | sk_err_soft; |
296 | atomic_t sk_drops; | ||
297 | unsigned short sk_ack_backlog; | 320 | unsigned short sk_ack_backlog; |
298 | unsigned short sk_max_ack_backlog; | 321 | unsigned short sk_max_ack_backlog; |
299 | __u32 sk_priority; | 322 | __u32 sk_priority; |
@@ -301,7 +324,6 @@ struct sock { | |||
301 | const struct cred *sk_peer_cred; | 324 | const struct cred *sk_peer_cred; |
302 | long sk_rcvtimeo; | 325 | long sk_rcvtimeo; |
303 | long sk_sndtimeo; | 326 | long sk_sndtimeo; |
304 | struct sk_filter *sk_filter; | ||
305 | void *sk_protinfo; | 327 | void *sk_protinfo; |
306 | struct timer_list sk_timer; | 328 | struct timer_list sk_timer; |
307 | ktime_t sk_stamp; | 329 | ktime_t sk_stamp; |
@@ -509,9 +531,6 @@ static __inline__ void sk_add_bind_node(struct sock *sk, | |||
509 | #define sk_nulls_for_each_from(__sk, node) \ | 531 | #define sk_nulls_for_each_from(__sk, node) \ |
510 | if (__sk && ({ node = &(__sk)->sk_nulls_node; 1; })) \ | 532 | if (__sk && ({ node = &(__sk)->sk_nulls_node; 1; })) \ |
511 | hlist_nulls_for_each_entry_from(__sk, node, sk_nulls_node) | 533 | hlist_nulls_for_each_entry_from(__sk, node, sk_nulls_node) |
512 | #define sk_for_each_continue(__sk, node) \ | ||
513 | if (__sk && ({ node = &(__sk)->sk_node; 1; })) \ | ||
514 | hlist_for_each_entry_continue(__sk, node, sk_node) | ||
515 | #define sk_for_each_safe(__sk, node, tmp, list) \ | 534 | #define sk_for_each_safe(__sk, node, tmp, list) \ |
516 | hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node) | 535 | hlist_for_each_entry_safe(__sk, node, tmp, list, sk_node) |
517 | #define sk_for_each_bound(__sk, node, list) \ | 536 | #define sk_for_each_bound(__sk, node, list) \ |
@@ -734,6 +753,8 @@ struct proto { | |||
734 | int level, | 753 | int level, |
735 | int optname, char __user *optval, | 754 | int optname, char __user *optval, |
736 | int __user *option); | 755 | int __user *option); |
756 | int (*compat_ioctl)(struct sock *sk, | ||
757 | unsigned int cmd, unsigned long arg); | ||
737 | #endif | 758 | #endif |
738 | int (*sendmsg)(struct kiocb *iocb, struct sock *sk, | 759 | int (*sendmsg)(struct kiocb *iocb, struct sock *sk, |
739 | struct msghdr *msg, size_t len); | 760 | struct msghdr *msg, size_t len); |
@@ -754,6 +775,7 @@ struct proto { | |||
754 | void (*unhash)(struct sock *sk); | 775 | void (*unhash)(struct sock *sk); |
755 | void (*rehash)(struct sock *sk); | 776 | void (*rehash)(struct sock *sk); |
756 | int (*get_port)(struct sock *sk, unsigned short snum); | 777 | int (*get_port)(struct sock *sk, unsigned short snum); |
778 | void (*clear_sk)(struct sock *sk, int size); | ||
757 | 779 | ||
758 | /* Keeping track of sockets in use */ | 780 | /* Keeping track of sockets in use */ |
759 | #ifdef CONFIG_PROC_FS | 781 | #ifdef CONFIG_PROC_FS |
@@ -762,7 +784,7 @@ struct proto { | |||
762 | 784 | ||
763 | /* Memory pressure */ | 785 | /* Memory pressure */ |
764 | void (*enter_memory_pressure)(struct sock *sk); | 786 | void (*enter_memory_pressure)(struct sock *sk); |
765 | atomic_t *memory_allocated; /* Current allocated memory. */ | 787 | atomic_long_t *memory_allocated; /* Current allocated memory. */ |
766 | struct percpu_counter *sockets_allocated; /* Current number of sockets. */ | 788 | struct percpu_counter *sockets_allocated; /* Current number of sockets. */ |
767 | /* | 789 | /* |
768 | * Pressure flag: try to collapse. | 790 | * Pressure flag: try to collapse. |
@@ -771,7 +793,7 @@ struct proto { | |||
771 | * is strict, actions are advisory and have some latency. | 793 | * is strict, actions are advisory and have some latency. |
772 | */ | 794 | */ |
773 | int *memory_pressure; | 795 | int *memory_pressure; |
774 | int *sysctl_mem; | 796 | long *sysctl_mem; |
775 | int *sysctl_wmem; | 797 | int *sysctl_wmem; |
776 | int *sysctl_rmem; | 798 | int *sysctl_rmem; |
777 | int max_header; | 799 | int max_header; |
@@ -852,6 +874,8 @@ static inline void __sk_prot_rehash(struct sock *sk) | |||
852 | sk->sk_prot->hash(sk); | 874 | sk->sk_prot->hash(sk); |
853 | } | 875 | } |
854 | 876 | ||
877 | void sk_prot_clear_portaddr_nulls(struct sock *sk, int size); | ||
878 | |||
855 | /* About 10 seconds */ | 879 | /* About 10 seconds */ |
856 | #define SOCK_DESTROY_TIME (10*HZ) | 880 | #define SOCK_DESTROY_TIME (10*HZ) |
857 | 881 | ||
@@ -1155,6 +1179,8 @@ extern void sk_common_release(struct sock *sk); | |||
1155 | /* Initialise core socket variables */ | 1179 | /* Initialise core socket variables */ |
1156 | extern void sock_init_data(struct socket *sock, struct sock *sk); | 1180 | extern void sock_init_data(struct socket *sock, struct sock *sk); |
1157 | 1181 | ||
1182 | extern void sk_filter_release_rcu(struct rcu_head *rcu); | ||
1183 | |||
1158 | /** | 1184 | /** |
1159 | * sk_filter_release - release a socket filter | 1185 | * sk_filter_release - release a socket filter |
1160 | * @fp: filter to remove | 1186 | * @fp: filter to remove |
@@ -1165,7 +1191,7 @@ extern void sock_init_data(struct socket *sock, struct sock *sk); | |||
1165 | static inline void sk_filter_release(struct sk_filter *fp) | 1191 | static inline void sk_filter_release(struct sk_filter *fp) |
1166 | { | 1192 | { |
1167 | if (atomic_dec_and_test(&fp->refcnt)) | 1193 | if (atomic_dec_and_test(&fp->refcnt)) |
1168 | kfree(fp); | 1194 | call_rcu(&fp->rcu, sk_filter_release_rcu); |
1169 | } | 1195 | } |
1170 | 1196 | ||
1171 | static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp) | 1197 | static inline void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp) |
@@ -1240,7 +1266,8 @@ static inline void sk_set_socket(struct sock *sk, struct socket *sock) | |||
1240 | 1266 | ||
1241 | static inline wait_queue_head_t *sk_sleep(struct sock *sk) | 1267 | static inline wait_queue_head_t *sk_sleep(struct sock *sk) |
1242 | { | 1268 | { |
1243 | return &sk->sk_wq->wait; | 1269 | BUILD_BUG_ON(offsetof(struct socket_wq, wait) != 0); |
1270 | return &rcu_dereference_raw(sk->sk_wq)->wait; | ||
1244 | } | 1271 | } |
1245 | /* Detach socket from process context. | 1272 | /* Detach socket from process context. |
1246 | * Announce socket dead, detach it from wait queue and inode. | 1273 | * Announce socket dead, detach it from wait queue and inode. |
@@ -1261,7 +1288,7 @@ static inline void sock_orphan(struct sock *sk) | |||
1261 | static inline void sock_graft(struct sock *sk, struct socket *parent) | 1288 | static inline void sock_graft(struct sock *sk, struct socket *parent) |
1262 | { | 1289 | { |
1263 | write_lock_bh(&sk->sk_callback_lock); | 1290 | write_lock_bh(&sk->sk_callback_lock); |
1264 | rcu_assign_pointer(sk->sk_wq, parent->wq); | 1291 | sk->sk_wq = parent->wq; |
1265 | parent->sk = sk; | 1292 | parent->sk = sk; |
1266 | sk_set_socket(sk, parent); | 1293 | sk_set_socket(sk, parent); |
1267 | security_sock_graft(sk, parent); | 1294 | security_sock_graft(sk, parent); |
@@ -1362,6 +1389,59 @@ static inline void sk_nocaps_add(struct sock *sk, int flags) | |||
1362 | sk->sk_route_caps &= ~flags; | 1389 | sk->sk_route_caps &= ~flags; |
1363 | } | 1390 | } |
1364 | 1391 | ||
1392 | static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb, | ||
1393 | char __user *from, char *to, | ||
1394 | int copy, int offset) | ||
1395 | { | ||
1396 | if (skb->ip_summed == CHECKSUM_NONE) { | ||
1397 | int err = 0; | ||
1398 | __wsum csum = csum_and_copy_from_user(from, to, copy, 0, &err); | ||
1399 | if (err) | ||
1400 | return err; | ||
1401 | skb->csum = csum_block_add(skb->csum, csum, offset); | ||
1402 | } else if (sk->sk_route_caps & NETIF_F_NOCACHE_COPY) { | ||
1403 | if (!access_ok(VERIFY_READ, from, copy) || | ||
1404 | __copy_from_user_nocache(to, from, copy)) | ||
1405 | return -EFAULT; | ||
1406 | } else if (copy_from_user(to, from, copy)) | ||
1407 | return -EFAULT; | ||
1408 | |||
1409 | return 0; | ||
1410 | } | ||
1411 | |||
1412 | static inline int skb_add_data_nocache(struct sock *sk, struct sk_buff *skb, | ||
1413 | char __user *from, int copy) | ||
1414 | { | ||
1415 | int err, offset = skb->len; | ||
1416 | |||
1417 | err = skb_do_copy_data_nocache(sk, skb, from, skb_put(skb, copy), | ||
1418 | copy, offset); | ||
1419 | if (err) | ||
1420 | __skb_trim(skb, offset); | ||
1421 | |||
1422 | return err; | ||
1423 | } | ||
1424 | |||
1425 | static inline int skb_copy_to_page_nocache(struct sock *sk, char __user *from, | ||
1426 | struct sk_buff *skb, | ||
1427 | struct page *page, | ||
1428 | int off, int copy) | ||
1429 | { | ||
1430 | int err; | ||
1431 | |||
1432 | err = skb_do_copy_data_nocache(sk, skb, from, page_address(page) + off, | ||
1433 | copy, skb->len); | ||
1434 | if (err) | ||
1435 | return err; | ||
1436 | |||
1437 | skb->len += copy; | ||
1438 | skb->data_len += copy; | ||
1439 | skb->truesize += copy; | ||
1440 | sk->sk_wmem_queued += copy; | ||
1441 | sk_mem_charge(sk, copy); | ||
1442 | return 0; | ||
1443 | } | ||
1444 | |||
1365 | static inline int skb_copy_to_page(struct sock *sk, char __user *from, | 1445 | static inline int skb_copy_to_page(struct sock *sk, char __user *from, |
1366 | struct sk_buff *skb, struct page *page, | 1446 | struct sk_buff *skb, struct page *page, |
1367 | int off, int copy) | 1447 | int off, int copy) |
@@ -1558,7 +1638,11 @@ static inline void sk_wake_async(struct sock *sk, int how, int band) | |||
1558 | } | 1638 | } |
1559 | 1639 | ||
1560 | #define SOCK_MIN_SNDBUF 2048 | 1640 | #define SOCK_MIN_SNDBUF 2048 |
1561 | #define SOCK_MIN_RCVBUF 256 | 1641 | /* |
1642 | * Since sk_rmem_alloc sums skb->truesize, even a small frame might need | ||
1643 | * sizeof(sk_buff) + MTU + padding, unless net driver perform copybreak | ||
1644 | */ | ||
1645 | #define SOCK_MIN_RCVBUF (2048 + sizeof(struct sk_buff)) | ||
1562 | 1646 | ||
1563 | static inline void sk_stream_moderate_sndbuf(struct sock *sk) | 1647 | static inline void sk_stream_moderate_sndbuf(struct sock *sk) |
1564 | { | 1648 | { |
@@ -1670,17 +1754,13 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, | |||
1670 | 1754 | ||
1671 | /** | 1755 | /** |
1672 | * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped | 1756 | * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped |
1673 | * @msg: outgoing packet | ||
1674 | * @sk: socket sending this packet | 1757 | * @sk: socket sending this packet |
1675 | * @shtx: filled with instructions for time stamping | 1758 | * @tx_flags: filled with instructions for time stamping |
1676 | * | 1759 | * |
1677 | * Currently only depends on SOCK_TIMESTAMPING* flags. Returns error code if | 1760 | * Currently only depends on SOCK_TIMESTAMPING* flags. Returns error code if |
1678 | * parameters are invalid. | 1761 | * parameters are invalid. |
1679 | */ | 1762 | */ |
1680 | extern int sock_tx_timestamp(struct msghdr *msg, | 1763 | extern int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags); |
1681 | struct sock *sk, | ||
1682 | union skb_shared_tx *shtx); | ||
1683 | |||
1684 | 1764 | ||
1685 | /** | 1765 | /** |
1686 | * sk_eat_skb - Release a skb if it is no longer needed | 1766 | * sk_eat_skb - Release a skb if it is no longer needed |
@@ -1722,7 +1802,7 @@ void sock_net_set(struct sock *sk, struct net *net) | |||
1722 | 1802 | ||
1723 | /* | 1803 | /* |
1724 | * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace. | 1804 | * Kernel sockets, f.e. rtnl or icmp_socket, are a part of a namespace. |
1725 | * They should not hold a referrence to a namespace in order to allow | 1805 | * They should not hold a reference to a namespace in order to allow |
1726 | * to stop it. | 1806 | * to stop it. |
1727 | * Sockets after sk_change_net should be released using sk_release_kernel | 1807 | * Sockets after sk_change_net should be released using sk_release_kernel |
1728 | */ | 1808 | */ |
diff --git a/include/net/tc_act/tc_csum.h b/include/net/tc_act/tc_csum.h new file mode 100644 index 000000000000..9e8710be7a04 --- /dev/null +++ b/include/net/tc_act/tc_csum.h | |||
@@ -0,0 +1,15 @@ | |||
1 | #ifndef __NET_TC_CSUM_H | ||
2 | #define __NET_TC_CSUM_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <net/act_api.h> | ||
6 | |||
7 | struct tcf_csum { | ||
8 | struct tcf_common common; | ||
9 | |||
10 | u32 update_flags; | ||
11 | }; | ||
12 | #define to_tcf_csum(pc) \ | ||
13 | container_of(pc,struct tcf_csum,common) | ||
14 | |||
15 | #endif /* __NET_TC_CSUM_H */ | ||
diff --git a/include/net/tcp.h b/include/net/tcp.h index 3e4b33e36602..cda30ea354a2 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -60,6 +60,9 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
60 | */ | 60 | */ |
61 | #define MAX_TCP_WINDOW 32767U | 61 | #define MAX_TCP_WINDOW 32767U |
62 | 62 | ||
63 | /* Offer an initial receive window of 10 mss. */ | ||
64 | #define TCP_DEFAULT_INIT_RCVWND 10 | ||
65 | |||
63 | /* Minimal accepted MSS. It is (60+60+8) - (20+20). */ | 66 | /* Minimal accepted MSS. It is (60+60+8) - (20+20). */ |
64 | #define TCP_MIN_MSS 88U | 67 | #define TCP_MIN_MSS 88U |
65 | 68 | ||
@@ -100,12 +103,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
100 | #define TCP_SYNACK_RETRIES 5 /* number of times to retry passive opening a | 103 | #define TCP_SYNACK_RETRIES 5 /* number of times to retry passive opening a |
101 | * connection: ~180sec is RFC minimum */ | 104 | * connection: ~180sec is RFC minimum */ |
102 | 105 | ||
103 | |||
104 | #define TCP_ORPHAN_RETRIES 7 /* number of times to retry on an orphaned | ||
105 | * socket. 7 is ~50sec-16min. | ||
106 | */ | ||
107 | |||
108 | |||
109 | #define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT | 106 | #define TCP_TIMEWAIT_LEN (60*HZ) /* how long to wait to destroy TIME-WAIT |
110 | * state, about 60 seconds */ | 107 | * state, about 60 seconds */ |
111 | #define TCP_FIN_TIMEOUT TCP_TIMEWAIT_LEN | 108 | #define TCP_FIN_TIMEOUT TCP_TIMEWAIT_LEN |
@@ -199,6 +196,9 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
199 | /* TCP thin-stream limits */ | 196 | /* TCP thin-stream limits */ |
200 | #define TCP_THIN_LINEAR_RETRIES 6 /* After 6 linear retries, do exp. backoff */ | 197 | #define TCP_THIN_LINEAR_RETRIES 6 /* After 6 linear retries, do exp. backoff */ |
201 | 198 | ||
199 | /* TCP initial congestion window as per draft-hkchu-tcpm-initcwnd-01 */ | ||
200 | #define TCP_INIT_CWND 10 | ||
201 | |||
202 | extern struct inet_timewait_death_row tcp_death_row; | 202 | extern struct inet_timewait_death_row tcp_death_row; |
203 | 203 | ||
204 | /* sysctl variables for tcp */ | 204 | /* sysctl variables for tcp */ |
@@ -224,7 +224,7 @@ extern int sysctl_tcp_fack; | |||
224 | extern int sysctl_tcp_reordering; | 224 | extern int sysctl_tcp_reordering; |
225 | extern int sysctl_tcp_ecn; | 225 | extern int sysctl_tcp_ecn; |
226 | extern int sysctl_tcp_dsack; | 226 | extern int sysctl_tcp_dsack; |
227 | extern int sysctl_tcp_mem[3]; | 227 | extern long sysctl_tcp_mem[3]; |
228 | extern int sysctl_tcp_wmem[3]; | 228 | extern int sysctl_tcp_wmem[3]; |
229 | extern int sysctl_tcp_rmem[3]; | 229 | extern int sysctl_tcp_rmem[3]; |
230 | extern int sysctl_tcp_app_win; | 230 | extern int sysctl_tcp_app_win; |
@@ -247,7 +247,7 @@ extern int sysctl_tcp_cookie_size; | |||
247 | extern int sysctl_tcp_thin_linear_timeouts; | 247 | extern int sysctl_tcp_thin_linear_timeouts; |
248 | extern int sysctl_tcp_thin_dupack; | 248 | extern int sysctl_tcp_thin_dupack; |
249 | 249 | ||
250 | extern atomic_t tcp_memory_allocated; | 250 | extern atomic_long_t tcp_memory_allocated; |
251 | extern struct percpu_counter tcp_sockets_allocated; | 251 | extern struct percpu_counter tcp_sockets_allocated; |
252 | extern int tcp_memory_pressure; | 252 | extern int tcp_memory_pressure; |
253 | 253 | ||
@@ -280,7 +280,7 @@ static inline bool tcp_too_many_orphans(struct sock *sk, int shift) | |||
280 | } | 280 | } |
281 | 281 | ||
282 | if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && | 282 | if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && |
283 | atomic_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]) | 283 | atomic_long_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]) |
284 | return true; | 284 | return true; |
285 | return false; | 285 | return false; |
286 | } | 286 | } |
@@ -312,7 +312,8 @@ extern void tcp_shutdown (struct sock *sk, int how); | |||
312 | 312 | ||
313 | extern int tcp_v4_rcv(struct sk_buff *skb); | 313 | extern int tcp_v4_rcv(struct sk_buff *skb); |
314 | 314 | ||
315 | extern int tcp_v4_remember_stamp(struct sock *sk); | 315 | extern struct inet_peer *tcp_v4_get_peer(struct sock *sk, bool *release_it); |
316 | extern void *tcp_v4_tw_get_peer(struct sock *sk); | ||
316 | extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); | 317 | extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); |
317 | extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | 318 | extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
318 | size_t size); | 319 | size_t size); |
@@ -346,8 +347,6 @@ static inline void tcp_dec_quickack_mode(struct sock *sk, | |||
346 | } | 347 | } |
347 | } | 348 | } |
348 | 349 | ||
349 | extern void tcp_enter_quickack_mode(struct sock *sk); | ||
350 | |||
351 | #define TCP_ECN_OK 1 | 350 | #define TCP_ECN_OK 1 |
352 | #define TCP_ECN_QUEUE_CWR 2 | 351 | #define TCP_ECN_QUEUE_CWR 2 |
353 | #define TCP_ECN_DEMAND_CWR 4 | 352 | #define TCP_ECN_DEMAND_CWR 4 |
@@ -1036,7 +1035,13 @@ static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, | |||
1036 | return 1; | 1035 | return 1; |
1037 | if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)) | 1036 | if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)) |
1038 | return 1; | 1037 | return 1; |
1039 | 1038 | /* | |
1039 | * Some OSes send SYN and SYNACK messages with tsval=0 tsecr=0, | ||
1040 | * then following tcp messages have valid values. Ignore 0 value, | ||
1041 | * or else 'negative' tsval might forbid us to accept their packets. | ||
1042 | */ | ||
1043 | if (!rx_opt->ts_recent) | ||
1044 | return 1; | ||
1040 | return 0; | 1045 | return 0; |
1041 | } | 1046 | } |
1042 | 1047 | ||
@@ -1063,8 +1068,6 @@ static inline int tcp_paws_reject(const struct tcp_options_received *rx_opt, | |||
1063 | return 1; | 1068 | return 1; |
1064 | } | 1069 | } |
1065 | 1070 | ||
1066 | #define TCP_CHECK_TIMER(sk) do { } while (0) | ||
1067 | |||
1068 | static inline void tcp_mib_init(struct net *net) | 1071 | static inline void tcp_mib_init(struct net *net) |
1069 | { | 1072 | { |
1070 | /* See RFC 2012 */ | 1073 | /* See RFC 2012 */ |
@@ -1150,8 +1153,6 @@ struct tcp_md5sig_pool { | |||
1150 | union tcp_md5sum_block md5_blk; | 1153 | union tcp_md5sum_block md5_blk; |
1151 | }; | 1154 | }; |
1152 | 1155 | ||
1153 | #define TCP_MD5SIG_MAXKEYS (~(u32)0) /* really?! */ | ||
1154 | |||
1155 | /* - functions */ | 1156 | /* - functions */ |
1156 | extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, | 1157 | extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, |
1157 | struct sock *sk, struct request_sock *req, | 1158 | struct sock *sk, struct request_sock *req, |
@@ -1395,7 +1396,7 @@ extern struct request_sock_ops tcp6_request_sock_ops; | |||
1395 | extern void tcp_v4_destroy_sock(struct sock *sk); | 1396 | extern void tcp_v4_destroy_sock(struct sock *sk); |
1396 | 1397 | ||
1397 | extern int tcp_v4_gso_send_check(struct sk_buff *skb); | 1398 | extern int tcp_v4_gso_send_check(struct sk_buff *skb); |
1398 | extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, int features); | 1399 | extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, u32 features); |
1399 | extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, | 1400 | extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, |
1400 | struct sk_buff *skb); | 1401 | struct sk_buff *skb); |
1401 | extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, | 1402 | extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, |
diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h index 97c3b14da55d..053b3cf2c66a 100644 --- a/include/net/timewait_sock.h +++ b/include/net/timewait_sock.h | |||
@@ -21,6 +21,7 @@ struct timewait_sock_ops { | |||
21 | int (*twsk_unique)(struct sock *sk, | 21 | int (*twsk_unique)(struct sock *sk, |
22 | struct sock *sktw, void *twp); | 22 | struct sock *sktw, void *twp); |
23 | void (*twsk_destructor)(struct sock *sk); | 23 | void (*twsk_destructor)(struct sock *sk); |
24 | void *(*twsk_getpeer)(struct sock *sk); | ||
24 | }; | 25 | }; |
25 | 26 | ||
26 | static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp) | 27 | static inline int twsk_unique(struct sock *sk, struct sock *sktw, void *twp) |
@@ -39,4 +40,11 @@ static inline void twsk_destructor(struct sock *sk) | |||
39 | sk->sk_prot->twsk_prot->twsk_destructor(sk); | 40 | sk->sk_prot->twsk_prot->twsk_destructor(sk); |
40 | } | 41 | } |
41 | 42 | ||
43 | static inline void *twsk_getpeer(struct sock *sk) | ||
44 | { | ||
45 | if (sk->sk_prot->twsk_prot->twsk_getpeer) | ||
46 | return sk->sk_prot->twsk_prot->twsk_getpeer(sk); | ||
47 | return NULL; | ||
48 | } | ||
49 | |||
42 | #endif /* _TIMEWAIT_SOCK_H */ | 50 | #endif /* _TIMEWAIT_SOCK_H */ |
diff --git a/include/net/tipc/tipc.h b/include/net/tipc/tipc.h deleted file mode 100644 index 15af6dca0b49..000000000000 --- a/include/net/tipc/tipc.h +++ /dev/null | |||
@@ -1,257 +0,0 @@ | |||
1 | /* | ||
2 | * include/net/tipc/tipc.h: Main include file for TIPC users | ||
3 | * | ||
4 | * Copyright (c) 2003-2006, Ericsson AB | ||
5 | * Copyright (c) 2005,2010 Wind River Systems | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions are met: | ||
10 | * | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. Neither the names of the copyright holders nor the names of its | ||
17 | * contributors may be used to endorse or promote products derived from | ||
18 | * this software without specific prior written permission. | ||
19 | * | ||
20 | * Alternatively, this software may be distributed under the terms of the | ||
21 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
22 | * Software Foundation. | ||
23 | * | ||
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
34 | * POSSIBILITY OF SUCH DAMAGE. | ||
35 | */ | ||
36 | |||
37 | #ifndef _NET_TIPC_H_ | ||
38 | #define _NET_TIPC_H_ | ||
39 | |||
40 | #ifdef __KERNEL__ | ||
41 | |||
42 | #include <linux/tipc.h> | ||
43 | #include <linux/skbuff.h> | ||
44 | |||
45 | /* | ||
46 | * Native API | ||
47 | */ | ||
48 | |||
49 | /* | ||
50 | * TIPC operating mode routines | ||
51 | */ | ||
52 | |||
53 | u32 tipc_get_addr(void); | ||
54 | |||
55 | #define TIPC_NOT_RUNNING 0 | ||
56 | #define TIPC_NODE_MODE 1 | ||
57 | #define TIPC_NET_MODE 2 | ||
58 | |||
59 | typedef void (*tipc_mode_event)(void *usr_handle, int mode, u32 addr); | ||
60 | |||
61 | int tipc_attach(unsigned int *userref, tipc_mode_event, void *usr_handle); | ||
62 | |||
63 | void tipc_detach(unsigned int userref); | ||
64 | |||
65 | int tipc_get_mode(void); | ||
66 | |||
67 | /* | ||
68 | * TIPC port manipulation routines | ||
69 | */ | ||
70 | |||
71 | typedef void (*tipc_msg_err_event) (void *usr_handle, | ||
72 | u32 portref, | ||
73 | struct sk_buff **buf, | ||
74 | unsigned char const *data, | ||
75 | unsigned int size, | ||
76 | int reason, | ||
77 | struct tipc_portid const *attmpt_destid); | ||
78 | |||
79 | typedef void (*tipc_named_msg_err_event) (void *usr_handle, | ||
80 | u32 portref, | ||
81 | struct sk_buff **buf, | ||
82 | unsigned char const *data, | ||
83 | unsigned int size, | ||
84 | int reason, | ||
85 | struct tipc_name_seq const *attmpt_dest); | ||
86 | |||
87 | typedef void (*tipc_conn_shutdown_event) (void *usr_handle, | ||
88 | u32 portref, | ||
89 | struct sk_buff **buf, | ||
90 | unsigned char const *data, | ||
91 | unsigned int size, | ||
92 | int reason); | ||
93 | |||
94 | typedef void (*tipc_msg_event) (void *usr_handle, | ||
95 | u32 portref, | ||
96 | struct sk_buff **buf, | ||
97 | unsigned char const *data, | ||
98 | unsigned int size, | ||
99 | unsigned int importance, | ||
100 | struct tipc_portid const *origin); | ||
101 | |||
102 | typedef void (*tipc_named_msg_event) (void *usr_handle, | ||
103 | u32 portref, | ||
104 | struct sk_buff **buf, | ||
105 | unsigned char const *data, | ||
106 | unsigned int size, | ||
107 | unsigned int importance, | ||
108 | struct tipc_portid const *orig, | ||
109 | struct tipc_name_seq const *dest); | ||
110 | |||
111 | typedef void (*tipc_conn_msg_event) (void *usr_handle, | ||
112 | u32 portref, | ||
113 | struct sk_buff **buf, | ||
114 | unsigned char const *data, | ||
115 | unsigned int size); | ||
116 | |||
117 | typedef void (*tipc_continue_event) (void *usr_handle, | ||
118 | u32 portref); | ||
119 | |||
120 | int tipc_createport(unsigned int tipc_user, | ||
121 | void *usr_handle, | ||
122 | unsigned int importance, | ||
123 | tipc_msg_err_event error_cb, | ||
124 | tipc_named_msg_err_event named_error_cb, | ||
125 | tipc_conn_shutdown_event conn_error_cb, | ||
126 | tipc_msg_event message_cb, | ||
127 | tipc_named_msg_event named_message_cb, | ||
128 | tipc_conn_msg_event conn_message_cb, | ||
129 | tipc_continue_event continue_event_cb, | ||
130 | u32 *portref); | ||
131 | |||
132 | int tipc_deleteport(u32 portref); | ||
133 | |||
134 | int tipc_ownidentity(u32 portref, struct tipc_portid *port); | ||
135 | |||
136 | int tipc_portimportance(u32 portref, unsigned int *importance); | ||
137 | int tipc_set_portimportance(u32 portref, unsigned int importance); | ||
138 | |||
139 | int tipc_portunreliable(u32 portref, unsigned int *isunreliable); | ||
140 | int tipc_set_portunreliable(u32 portref, unsigned int isunreliable); | ||
141 | |||
142 | int tipc_portunreturnable(u32 portref, unsigned int *isunreturnable); | ||
143 | int tipc_set_portunreturnable(u32 portref, unsigned int isunreturnable); | ||
144 | |||
145 | int tipc_publish(u32 portref, unsigned int scope, | ||
146 | struct tipc_name_seq const *name_seq); | ||
147 | int tipc_withdraw(u32 portref, unsigned int scope, | ||
148 | struct tipc_name_seq const *name_seq); | ||
149 | |||
150 | int tipc_connect2port(u32 portref, struct tipc_portid const *port); | ||
151 | |||
152 | int tipc_disconnect(u32 portref); | ||
153 | |||
154 | int tipc_shutdown(u32 ref); | ||
155 | |||
156 | int tipc_isconnected(u32 portref, int *isconnected); | ||
157 | |||
158 | int tipc_peer(u32 portref, struct tipc_portid *peer); | ||
159 | |||
160 | int tipc_ref_valid(u32 portref); | ||
161 | |||
162 | /* | ||
163 | * TIPC messaging routines | ||
164 | */ | ||
165 | |||
166 | #define TIPC_PORT_IMPORTANCE 100 /* send using current port setting */ | ||
167 | |||
168 | |||
169 | int tipc_send(u32 portref, | ||
170 | unsigned int num_sect, | ||
171 | struct iovec const *msg_sect); | ||
172 | |||
173 | int tipc_send_buf(u32 portref, | ||
174 | struct sk_buff *buf, | ||
175 | unsigned int dsz); | ||
176 | |||
177 | int tipc_send2name(u32 portref, | ||
178 | struct tipc_name const *name, | ||
179 | u32 domain, | ||
180 | unsigned int num_sect, | ||
181 | struct iovec const *msg_sect); | ||
182 | |||
183 | int tipc_send_buf2name(u32 portref, | ||
184 | struct tipc_name const *name, | ||
185 | u32 domain, | ||
186 | struct sk_buff *buf, | ||
187 | unsigned int dsz); | ||
188 | |||
189 | int tipc_forward2name(u32 portref, | ||
190 | struct tipc_name const *name, | ||
191 | u32 domain, | ||
192 | unsigned int section_count, | ||
193 | struct iovec const *msg_sect, | ||
194 | struct tipc_portid const *origin, | ||
195 | unsigned int importance); | ||
196 | |||
197 | int tipc_forward_buf2name(u32 portref, | ||
198 | struct tipc_name const *name, | ||
199 | u32 domain, | ||
200 | struct sk_buff *buf, | ||
201 | unsigned int dsz, | ||
202 | struct tipc_portid const *orig, | ||
203 | unsigned int importance); | ||
204 | |||
205 | int tipc_send2port(u32 portref, | ||
206 | struct tipc_portid const *dest, | ||
207 | unsigned int num_sect, | ||
208 | struct iovec const *msg_sect); | ||
209 | |||
210 | int tipc_send_buf2port(u32 portref, | ||
211 | struct tipc_portid const *dest, | ||
212 | struct sk_buff *buf, | ||
213 | unsigned int dsz); | ||
214 | |||
215 | int tipc_forward2port(u32 portref, | ||
216 | struct tipc_portid const *dest, | ||
217 | unsigned int num_sect, | ||
218 | struct iovec const *msg_sect, | ||
219 | struct tipc_portid const *origin, | ||
220 | unsigned int importance); | ||
221 | |||
222 | int tipc_forward_buf2port(u32 portref, | ||
223 | struct tipc_portid const *dest, | ||
224 | struct sk_buff *buf, | ||
225 | unsigned int dsz, | ||
226 | struct tipc_portid const *orig, | ||
227 | unsigned int importance); | ||
228 | |||
229 | int tipc_multicast(u32 portref, | ||
230 | struct tipc_name_seq const *seq, | ||
231 | u32 domain, /* currently unused */ | ||
232 | unsigned int section_count, | ||
233 | struct iovec const *msg); | ||
234 | |||
235 | #if 0 | ||
236 | int tipc_multicast_buf(u32 portref, | ||
237 | struct tipc_name_seq const *seq, | ||
238 | u32 domain, | ||
239 | void *buf, | ||
240 | unsigned int size); | ||
241 | #endif | ||
242 | |||
243 | /* | ||
244 | * TIPC subscription routines | ||
245 | */ | ||
246 | |||
247 | int tipc_ispublished(struct tipc_name const *name); | ||
248 | |||
249 | /* | ||
250 | * Get number of available nodes within specified domain (excluding own node) | ||
251 | */ | ||
252 | |||
253 | unsigned int tipc_available_nodes(const u32 domain); | ||
254 | |||
255 | #endif | ||
256 | |||
257 | #endif | ||
diff --git a/include/net/tipc/tipc_bearer.h b/include/net/tipc/tipc_bearer.h deleted file mode 100644 index ee2f304e4919..000000000000 --- a/include/net/tipc/tipc_bearer.h +++ /dev/null | |||
@@ -1,138 +0,0 @@ | |||
1 | /* | ||
2 | * include/net/tipc/tipc_bearer.h: Include file for privileged access to TIPC bearers | ||
3 | * | ||
4 | * Copyright (c) 2003-2006, Ericsson AB | ||
5 | * Copyright (c) 2005, Wind River Systems | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions are met: | ||
10 | * | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. Neither the names of the copyright holders nor the names of its | ||
17 | * contributors may be used to endorse or promote products derived from | ||
18 | * this software without specific prior written permission. | ||
19 | * | ||
20 | * Alternatively, this software may be distributed under the terms of the | ||
21 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
22 | * Software Foundation. | ||
23 | * | ||
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
34 | * POSSIBILITY OF SUCH DAMAGE. | ||
35 | */ | ||
36 | |||
37 | #ifndef _NET_TIPC_BEARER_H_ | ||
38 | #define _NET_TIPC_BEARER_H_ | ||
39 | |||
40 | #ifdef __KERNEL__ | ||
41 | |||
42 | #include <linux/tipc_config.h> | ||
43 | #include <linux/skbuff.h> | ||
44 | #include <linux/spinlock.h> | ||
45 | |||
46 | /* | ||
47 | * Identifiers of supported TIPC media types | ||
48 | */ | ||
49 | |||
50 | #define TIPC_MEDIA_TYPE_ETH 1 | ||
51 | |||
52 | /* | ||
53 | * Destination address structure used by TIPC bearers when sending messages | ||
54 | * | ||
55 | * IMPORTANT: The fields of this structure MUST be stored using the specified | ||
56 | * byte order indicated below, as the structure is exchanged between nodes | ||
57 | * as part of a link setup process. | ||
58 | */ | ||
59 | |||
60 | struct tipc_media_addr { | ||
61 | __be32 type; /* bearer type (network byte order) */ | ||
62 | union { | ||
63 | __u8 eth_addr[6]; /* 48 bit Ethernet addr (byte array) */ | ||
64 | #if 0 | ||
65 | /* Prototypes for other possible bearer types */ | ||
66 | |||
67 | struct { | ||
68 | __u16 sin_family; | ||
69 | __u16 sin_port; | ||
70 | struct { | ||
71 | __u32 s_addr; | ||
72 | } sin_addr; | ||
73 | char pad[4]; | ||
74 | } addr_in; /* IP-based bearer */ | ||
75 | __u16 sock_descr; /* generic socket bearer */ | ||
76 | #endif | ||
77 | } dev_addr; | ||
78 | }; | ||
79 | |||
80 | /** | ||
81 | * struct tipc_bearer - TIPC bearer info available to privileged users | ||
82 | * @usr_handle: pointer to additional user-defined information about bearer | ||
83 | * @mtu: max packet size bearer can support | ||
84 | * @blocked: non-zero if bearer is blocked | ||
85 | * @lock: spinlock for controlling access to bearer | ||
86 | * @addr: media-specific address associated with bearer | ||
87 | * @name: bearer name (format = media:interface) | ||
88 | * | ||
89 | * Note: TIPC initializes "name" and "lock" fields; user is responsible for | ||
90 | * initialization all other fields when a bearer is enabled. | ||
91 | */ | ||
92 | |||
93 | struct tipc_bearer { | ||
94 | void *usr_handle; | ||
95 | u32 mtu; | ||
96 | int blocked; | ||
97 | spinlock_t lock; | ||
98 | struct tipc_media_addr addr; | ||
99 | char name[TIPC_MAX_BEARER_NAME]; | ||
100 | }; | ||
101 | |||
102 | /* | ||
103 | * TIPC routines available to supported media types | ||
104 | */ | ||
105 | |||
106 | int tipc_register_media(u32 media_type, | ||
107 | char *media_name, | ||
108 | int (*enable)(struct tipc_bearer *), | ||
109 | void (*disable)(struct tipc_bearer *), | ||
110 | int (*send_msg)(struct sk_buff *, | ||
111 | struct tipc_bearer *, | ||
112 | struct tipc_media_addr *), | ||
113 | char *(*addr2str)(struct tipc_media_addr *a, | ||
114 | char *str_buf, | ||
115 | int str_size), | ||
116 | struct tipc_media_addr *bcast_addr, | ||
117 | const u32 bearer_priority, | ||
118 | const u32 link_tolerance, /* [ms] */ | ||
119 | const u32 send_window_limit); | ||
120 | |||
121 | void tipc_recv_msg(struct sk_buff *buf, struct tipc_bearer *tb_ptr); | ||
122 | |||
123 | int tipc_block_bearer(const char *name); | ||
124 | void tipc_continue(struct tipc_bearer *tb_ptr); | ||
125 | |||
126 | int tipc_enable_bearer(const char *bearer_name, u32 bcast_scope, u32 priority); | ||
127 | int tipc_disable_bearer(const char *name); | ||
128 | |||
129 | /* | ||
130 | * Routines made available to TIPC by supported media types | ||
131 | */ | ||
132 | |||
133 | int tipc_eth_media_start(void); | ||
134 | void tipc_eth_media_stop(void); | ||
135 | |||
136 | #endif | ||
137 | |||
138 | #endif | ||
diff --git a/include/net/tipc/tipc_msg.h b/include/net/tipc/tipc_msg.h deleted file mode 100644 index 2e159a812f83..000000000000 --- a/include/net/tipc/tipc_msg.h +++ /dev/null | |||
@@ -1,207 +0,0 @@ | |||
1 | /* | ||
2 | * include/net/tipc/tipc_msg.h: Include file for privileged access to TIPC message headers | ||
3 | * | ||
4 | * Copyright (c) 2003-2006, Ericsson AB | ||
5 | * Copyright (c) 2005, Wind River Systems | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions are met: | ||
10 | * | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. Neither the names of the copyright holders nor the names of its | ||
17 | * contributors may be used to endorse or promote products derived from | ||
18 | * this software without specific prior written permission. | ||
19 | * | ||
20 | * Alternatively, this software may be distributed under the terms of the | ||
21 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
22 | * Software Foundation. | ||
23 | * | ||
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
34 | * POSSIBILITY OF SUCH DAMAGE. | ||
35 | */ | ||
36 | |||
37 | #ifndef _NET_TIPC_MSG_H_ | ||
38 | #define _NET_TIPC_MSG_H_ | ||
39 | |||
40 | #ifdef __KERNEL__ | ||
41 | |||
42 | struct tipc_msg { | ||
43 | __be32 hdr[15]; | ||
44 | }; | ||
45 | |||
46 | |||
47 | /* | ||
48 | TIPC user data message header format, version 2: | ||
49 | |||
50 | |||
51 | 1 0 9 8 7 6 5 4|3 2 1 0 9 8 7 6|5 4 3 2 1 0 9 8|7 6 5 4 3 2 1 0 | ||
52 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
53 | w0:|vers | user |hdr sz |n|d|s|-| message size | | ||
54 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
55 | w1:|mstyp| error |rer cnt|lsc|opt p| broadcast ack no | | ||
56 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
57 | w2:| link level ack no | broadcast/link level seq no | | ||
58 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
59 | w3:| previous node | | ||
60 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
61 | w4:| originating port | | ||
62 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
63 | w5:| destination port | | ||
64 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
65 | w6:| originating node | | ||
66 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
67 | w7:| destination node | | ||
68 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
69 | w8:| name type / transport sequence number | | ||
70 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
71 | w9:| name instance/multicast lower bound | | ||
72 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
73 | wA:| multicast upper bound | | ||
74 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
75 | / / | ||
76 | \ options \ | ||
77 | / / | ||
78 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | ||
79 | |||
80 | */ | ||
81 | |||
82 | #define TIPC_CONN_MSG 0 | ||
83 | #define TIPC_MCAST_MSG 1 | ||
84 | #define TIPC_NAMED_MSG 2 | ||
85 | #define TIPC_DIRECT_MSG 3 | ||
86 | |||
87 | |||
88 | static inline u32 msg_word(struct tipc_msg *m, u32 pos) | ||
89 | { | ||
90 | return ntohl(m->hdr[pos]); | ||
91 | } | ||
92 | |||
93 | static inline u32 msg_bits(struct tipc_msg *m, u32 w, u32 pos, u32 mask) | ||
94 | { | ||
95 | return (msg_word(m, w) >> pos) & mask; | ||
96 | } | ||
97 | |||
98 | static inline u32 msg_importance(struct tipc_msg *m) | ||
99 | { | ||
100 | return msg_bits(m, 0, 25, 0xf); | ||
101 | } | ||
102 | |||
103 | static inline u32 msg_hdr_sz(struct tipc_msg *m) | ||
104 | { | ||
105 | return msg_bits(m, 0, 21, 0xf) << 2; | ||
106 | } | ||
107 | |||
108 | static inline int msg_short(struct tipc_msg *m) | ||
109 | { | ||
110 | return (msg_hdr_sz(m) == 24); | ||
111 | } | ||
112 | |||
113 | static inline u32 msg_size(struct tipc_msg *m) | ||
114 | { | ||
115 | return msg_bits(m, 0, 0, 0x1ffff); | ||
116 | } | ||
117 | |||
118 | static inline u32 msg_data_sz(struct tipc_msg *m) | ||
119 | { | ||
120 | return (msg_size(m) - msg_hdr_sz(m)); | ||
121 | } | ||
122 | |||
123 | static inline unchar *msg_data(struct tipc_msg *m) | ||
124 | { | ||
125 | return ((unchar *)m) + msg_hdr_sz(m); | ||
126 | } | ||
127 | |||
128 | static inline u32 msg_type(struct tipc_msg *m) | ||
129 | { | ||
130 | return msg_bits(m, 1, 29, 0x7); | ||
131 | } | ||
132 | |||
133 | static inline u32 msg_named(struct tipc_msg *m) | ||
134 | { | ||
135 | return (msg_type(m) == TIPC_NAMED_MSG); | ||
136 | } | ||
137 | |||
138 | static inline u32 msg_mcast(struct tipc_msg *m) | ||
139 | { | ||
140 | return (msg_type(m) == TIPC_MCAST_MSG); | ||
141 | } | ||
142 | |||
143 | static inline u32 msg_connected(struct tipc_msg *m) | ||
144 | { | ||
145 | return (msg_type(m) == TIPC_CONN_MSG); | ||
146 | } | ||
147 | |||
148 | static inline u32 msg_errcode(struct tipc_msg *m) | ||
149 | { | ||
150 | return msg_bits(m, 1, 25, 0xf); | ||
151 | } | ||
152 | |||
153 | static inline u32 msg_prevnode(struct tipc_msg *m) | ||
154 | { | ||
155 | return msg_word(m, 3); | ||
156 | } | ||
157 | |||
158 | static inline u32 msg_origport(struct tipc_msg *m) | ||
159 | { | ||
160 | return msg_word(m, 4); | ||
161 | } | ||
162 | |||
163 | static inline u32 msg_destport(struct tipc_msg *m) | ||
164 | { | ||
165 | return msg_word(m, 5); | ||
166 | } | ||
167 | |||
168 | static inline u32 msg_mc_netid(struct tipc_msg *m) | ||
169 | { | ||
170 | return msg_word(m, 5); | ||
171 | } | ||
172 | |||
173 | static inline u32 msg_orignode(struct tipc_msg *m) | ||
174 | { | ||
175 | if (likely(msg_short(m))) | ||
176 | return msg_prevnode(m); | ||
177 | return msg_word(m, 6); | ||
178 | } | ||
179 | |||
180 | static inline u32 msg_destnode(struct tipc_msg *m) | ||
181 | { | ||
182 | return msg_word(m, 7); | ||
183 | } | ||
184 | |||
185 | static inline u32 msg_nametype(struct tipc_msg *m) | ||
186 | { | ||
187 | return msg_word(m, 8); | ||
188 | } | ||
189 | |||
190 | static inline u32 msg_nameinst(struct tipc_msg *m) | ||
191 | { | ||
192 | return msg_word(m, 9); | ||
193 | } | ||
194 | |||
195 | static inline u32 msg_namelower(struct tipc_msg *m) | ||
196 | { | ||
197 | return msg_nameinst(m); | ||
198 | } | ||
199 | |||
200 | static inline u32 msg_nameupper(struct tipc_msg *m) | ||
201 | { | ||
202 | return msg_word(m, 10); | ||
203 | } | ||
204 | |||
205 | #endif | ||
206 | |||
207 | #endif | ||
diff --git a/include/net/tipc/tipc_port.h b/include/net/tipc/tipc_port.h deleted file mode 100644 index c54917cbfa48..000000000000 --- a/include/net/tipc/tipc_port.h +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | /* | ||
2 | * include/net/tipc/tipc_port.h: Include file for privileged access to TIPC ports | ||
3 | * | ||
4 | * Copyright (c) 1994-2007, Ericsson AB | ||
5 | * Copyright (c) 2005-2008, Wind River Systems | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions are met: | ||
10 | * | ||
11 | * 1. Redistributions of source code must retain the above copyright | ||
12 | * notice, this list of conditions and the following disclaimer. | ||
13 | * 2. Redistributions in binary form must reproduce the above copyright | ||
14 | * notice, this list of conditions and the following disclaimer in the | ||
15 | * documentation and/or other materials provided with the distribution. | ||
16 | * 3. Neither the names of the copyright holders nor the names of its | ||
17 | * contributors may be used to endorse or promote products derived from | ||
18 | * this software without specific prior written permission. | ||
19 | * | ||
20 | * Alternatively, this software may be distributed under the terms of the | ||
21 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
22 | * Software Foundation. | ||
23 | * | ||
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | ||
28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
34 | * POSSIBILITY OF SUCH DAMAGE. | ||
35 | */ | ||
36 | |||
37 | #ifndef _NET_TIPC_PORT_H_ | ||
38 | #define _NET_TIPC_PORT_H_ | ||
39 | |||
40 | #ifdef __KERNEL__ | ||
41 | |||
42 | #include <linux/tipc.h> | ||
43 | #include <linux/skbuff.h> | ||
44 | #include <net/tipc/tipc_msg.h> | ||
45 | |||
46 | #define TIPC_FLOW_CONTROL_WIN 512 | ||
47 | |||
48 | /** | ||
49 | * struct tipc_port - native TIPC port info available to privileged users | ||
50 | * @usr_handle: pointer to additional user-defined information about port | ||
51 | * @lock: pointer to spinlock for controlling access to port | ||
52 | * @connected: non-zero if port is currently connected to a peer port | ||
53 | * @conn_type: TIPC type used when connection was established | ||
54 | * @conn_instance: TIPC instance used when connection was established | ||
55 | * @conn_unacked: number of unacknowledged messages received from peer port | ||
56 | * @published: non-zero if port has one or more associated names | ||
57 | * @congested: non-zero if cannot send because of link or port congestion | ||
58 | * @max_pkt: maximum packet size "hint" used when building messages sent by port | ||
59 | * @ref: unique reference to port in TIPC object registry | ||
60 | * @phdr: preformatted message header used when sending messages | ||
61 | */ | ||
62 | |||
63 | struct tipc_port { | ||
64 | void *usr_handle; | ||
65 | spinlock_t *lock; | ||
66 | int connected; | ||
67 | u32 conn_type; | ||
68 | u32 conn_instance; | ||
69 | u32 conn_unacked; | ||
70 | int published; | ||
71 | u32 congested; | ||
72 | u32 max_pkt; | ||
73 | u32 ref; | ||
74 | struct tipc_msg phdr; | ||
75 | }; | ||
76 | |||
77 | |||
78 | struct tipc_port *tipc_createport_raw(void *usr_handle, | ||
79 | u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), | ||
80 | void (*wakeup)(struct tipc_port *), | ||
81 | const u32 importance); | ||
82 | |||
83 | int tipc_reject_msg(struct sk_buff *buf, u32 err); | ||
84 | |||
85 | int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode); | ||
86 | |||
87 | void tipc_acknowledge(u32 port_ref,u32 ack); | ||
88 | |||
89 | struct tipc_port *tipc_get_port(const u32 ref); | ||
90 | |||
91 | void *tipc_get_handle(const u32 ref); | ||
92 | |||
93 | /* | ||
94 | * The following routines require that the port be locked on entry | ||
95 | */ | ||
96 | |||
97 | int tipc_disconnect_port(struct tipc_port *tp_ptr); | ||
98 | |||
99 | |||
100 | #endif | ||
101 | |||
102 | #endif | ||
103 | |||
diff --git a/include/net/transp_v6.h b/include/net/transp_v6.h index 42a0eb68b7b6..5271a741c3a3 100644 --- a/include/net/transp_v6.h +++ b/include/net/transp_v6.h | |||
@@ -7,16 +7,14 @@ | |||
7 | * IPv6 transport protocols | 7 | * IPv6 transport protocols |
8 | */ | 8 | */ |
9 | 9 | ||
10 | #ifdef __KERNEL__ | ||
11 | |||
12 | extern struct proto rawv6_prot; | 10 | extern struct proto rawv6_prot; |
13 | extern struct proto udpv6_prot; | 11 | extern struct proto udpv6_prot; |
14 | extern struct proto udplitev6_prot; | 12 | extern struct proto udplitev6_prot; |
15 | extern struct proto tcpv6_prot; | 13 | extern struct proto tcpv6_prot; |
16 | 14 | ||
17 | struct flowi; | 15 | struct flowi6; |
18 | 16 | ||
19 | /* extention headers */ | 17 | /* extension headers */ |
20 | extern int ipv6_exthdrs_init(void); | 18 | extern int ipv6_exthdrs_init(void); |
21 | extern void ipv6_exthdrs_exit(void); | 19 | extern void ipv6_exthdrs_exit(void); |
22 | extern int ipv6_frag_init(void); | 20 | extern int ipv6_frag_init(void); |
@@ -42,7 +40,7 @@ extern int datagram_recv_ctl(struct sock *sk, | |||
42 | 40 | ||
43 | extern int datagram_send_ctl(struct net *net, | 41 | extern int datagram_send_ctl(struct net *net, |
44 | struct msghdr *msg, | 42 | struct msghdr *msg, |
45 | struct flowi *fl, | 43 | struct flowi6 *fl6, |
46 | struct ipv6_txoptions *opt, | 44 | struct ipv6_txoptions *opt, |
47 | int *hlimit, int *tclass, | 45 | int *hlimit, int *tclass, |
48 | int *dontfrag); | 46 | int *dontfrag); |
@@ -57,5 +55,3 @@ extern const struct inet_connection_sock_af_ops ipv4_specific; | |||
57 | extern void inet6_destroy_sock(struct sock *sk); | 55 | extern void inet6_destroy_sock(struct sock *sk); |
58 | 56 | ||
59 | #endif | 57 | #endif |
60 | |||
61 | #endif | ||
diff --git a/include/net/udp.h b/include/net/udp.h index a184d3496b13..67ea6fcb3ec0 100644 --- a/include/net/udp.h +++ b/include/net/udp.h | |||
@@ -105,10 +105,10 @@ static inline struct udp_hslot *udp_hashslot2(struct udp_table *table, | |||
105 | 105 | ||
106 | extern struct proto udp_prot; | 106 | extern struct proto udp_prot; |
107 | 107 | ||
108 | extern atomic_t udp_memory_allocated; | 108 | extern atomic_long_t udp_memory_allocated; |
109 | 109 | ||
110 | /* sysctl variables for udp */ | 110 | /* sysctl variables for udp */ |
111 | extern int sysctl_udp_mem[3]; | 111 | extern long sysctl_udp_mem[3]; |
112 | extern int sysctl_udp_rmem_min; | 112 | extern int sysctl_udp_rmem_min; |
113 | extern int sysctl_udp_wmem_min; | 113 | extern int sysctl_udp_wmem_min; |
114 | 114 | ||
@@ -144,6 +144,17 @@ static inline __wsum udp_csum_outgoing(struct sock *sk, struct sk_buff *skb) | |||
144 | return csum; | 144 | return csum; |
145 | } | 145 | } |
146 | 146 | ||
147 | static inline __wsum udp_csum(struct sk_buff *skb) | ||
148 | { | ||
149 | __wsum csum = csum_partial(skb_transport_header(skb), | ||
150 | sizeof(struct udphdr), skb->csum); | ||
151 | |||
152 | for (skb = skb_shinfo(skb)->frag_list; skb; skb = skb->next) { | ||
153 | csum = csum_add(csum, skb->csum); | ||
154 | } | ||
155 | return csum; | ||
156 | } | ||
157 | |||
147 | /* hash routines shared between UDPv4/6 and UDP-Litev4/6 */ | 158 | /* hash routines shared between UDPv4/6 and UDP-Litev4/6 */ |
148 | static inline void udp_lib_hash(struct sock *sk) | 159 | static inline void udp_lib_hash(struct sock *sk) |
149 | { | 160 | { |
@@ -183,6 +194,9 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
183 | extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, | 194 | extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, |
184 | __be32 daddr, __be16 dport, | 195 | __be32 daddr, __be16 dport, |
185 | int dif); | 196 | int dif); |
197 | extern struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, | ||
198 | const struct in6_addr *daddr, __be16 dport, | ||
199 | int dif); | ||
186 | 200 | ||
187 | /* | 201 | /* |
188 | * SNMP statistics for UDP and UDP-Lite | 202 | * SNMP statistics for UDP and UDP-Lite |
@@ -242,5 +256,5 @@ extern void udp4_proc_exit(void); | |||
242 | extern void udp_init(void); | 256 | extern void udp_init(void); |
243 | 257 | ||
244 | extern int udp4_ufo_send_check(struct sk_buff *skb); | 258 | extern int udp4_ufo_send_check(struct sk_buff *skb); |
245 | extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, int features); | 259 | extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, u32 features); |
246 | #endif /* _UDP_H */ | 260 | #endif /* _UDP_H */ |
diff --git a/include/net/udplite.h b/include/net/udplite.h index afdffe607b24..673a024c6b2a 100644 --- a/include/net/udplite.h +++ b/include/net/udplite.h | |||
@@ -115,6 +115,18 @@ static inline __wsum udplite_csum_outgoing(struct sock *sk, struct sk_buff *skb) | |||
115 | return csum; | 115 | return csum; |
116 | } | 116 | } |
117 | 117 | ||
118 | static inline __wsum udplite_csum(struct sk_buff *skb) | ||
119 | { | ||
120 | struct sock *sk = skb->sk; | ||
121 | int cscov = udplite_sender_cscov(udp_sk(sk), udp_hdr(skb)); | ||
122 | const int off = skb_transport_offset(skb); | ||
123 | const int len = skb->len - off; | ||
124 | |||
125 | skb->ip_summed = CHECKSUM_NONE; /* no HW support for checksumming */ | ||
126 | |||
127 | return skb_checksum(skb, off, min(cscov, len), 0); | ||
128 | } | ||
129 | |||
118 | extern void udplite4_register(void); | 130 | extern void udplite4_register(void); |
119 | extern int udplite_get_port(struct sock *sk, unsigned short snum, | 131 | extern int udplite_get_port(struct sock *sk, unsigned short snum, |
120 | int (*scmp)(const struct sock *, const struct sock *)); | 132 | int (*scmp)(const struct sock *, const struct sock *)); |
diff --git a/include/net/wimax.h b/include/net/wimax.h index 3461aa1df1e0..7328d5019d88 100644 --- a/include/net/wimax.h +++ b/include/net/wimax.h | |||
@@ -250,7 +250,6 @@ | |||
250 | 250 | ||
251 | #ifndef __NET__WIMAX_H__ | 251 | #ifndef __NET__WIMAX_H__ |
252 | #define __NET__WIMAX_H__ | 252 | #define __NET__WIMAX_H__ |
253 | #ifdef __KERNEL__ | ||
254 | 253 | ||
255 | #include <linux/wimax.h> | 254 | #include <linux/wimax.h> |
256 | #include <net/genetlink.h> | 255 | #include <net/genetlink.h> |
@@ -286,7 +285,7 @@ struct wimax_dev; | |||
286 | * does not disconnect the device from the bus and return 0. | 285 | * does not disconnect the device from the bus and return 0. |
287 | * If that fails, it should resort to some sort of cold or bus | 286 | * If that fails, it should resort to some sort of cold or bus |
288 | * reset (even if it implies a bus disconnection and device | 287 | * reset (even if it implies a bus disconnection and device |
289 | * dissapearance). In that case, -ENODEV should be returned to | 288 | * disappearance). In that case, -ENODEV should be returned to |
290 | * indicate the device is gone. | 289 | * indicate the device is gone. |
291 | * This operation has to be synchronous, and return only when the | 290 | * This operation has to be synchronous, and return only when the |
292 | * reset is complete. In case of having had to resort to bus/cold | 291 | * reset is complete. In case of having had to resort to bus/cold |
@@ -518,8 +517,4 @@ extern ssize_t wimax_msg_len(struct sk_buff *); | |||
518 | extern int wimax_rfkill(struct wimax_dev *, enum wimax_rf_state); | 517 | extern int wimax_rfkill(struct wimax_dev *, enum wimax_rf_state); |
519 | extern int wimax_reset(struct wimax_dev *); | 518 | extern int wimax_reset(struct wimax_dev *); |
520 | 519 | ||
521 | #else | ||
522 | /* You might be looking for linux/wimax.h */ | ||
523 | #error This file should not be included from user space. | ||
524 | #endif /* #ifdef __KERNEL__ */ | ||
525 | #endif /* #ifndef __NET__WIMAX_H__ */ | 520 | #endif /* #ifndef __NET__WIMAX_H__ */ |
diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h index 85926231c07a..d86fffd3c03c 100644 --- a/include/net/wpan-phy.h +++ b/include/net/wpan-phy.h | |||
@@ -28,7 +28,7 @@ struct wpan_phy { | |||
28 | struct mutex pib_lock; | 28 | struct mutex pib_lock; |
29 | 29 | ||
30 | /* | 30 | /* |
31 | * This is a PIB acording to 802.15.4-2006. | 31 | * This is a PIB according to 802.15.4-2006. |
32 | * We do not provide timing-related variables, as they | 32 | * We do not provide timing-related variables, as they |
33 | * aren't used outside of driver | 33 | * aren't used outside of driver |
34 | */ | 34 | */ |
diff --git a/include/net/x25.h b/include/net/x25.h index 1479cb4a41fc..a06119a05129 100644 --- a/include/net/x25.h +++ b/include/net/x25.h | |||
@@ -315,6 +315,8 @@ extern struct list_head x25_route_list; | |||
315 | extern rwlock_t x25_route_list_lock; | 315 | extern rwlock_t x25_route_list_lock; |
316 | extern struct list_head x25_forward_list; | 316 | extern struct list_head x25_forward_list; |
317 | extern rwlock_t x25_forward_list_lock; | 317 | extern rwlock_t x25_forward_list_lock; |
318 | extern struct list_head x25_neigh_list; | ||
319 | extern rwlock_t x25_neigh_list_lock; | ||
318 | 320 | ||
319 | extern int x25_proc_init(void); | 321 | extern int x25_proc_init(void); |
320 | extern void x25_proc_exit(void); | 322 | extern void x25_proc_exit(void); |
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 4f53532d4c2f..b203e14d26b7 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -36,6 +36,7 @@ | |||
36 | #define XFRM_PROTO_ROUTING IPPROTO_ROUTING | 36 | #define XFRM_PROTO_ROUTING IPPROTO_ROUTING |
37 | #define XFRM_PROTO_DSTOPTS IPPROTO_DSTOPTS | 37 | #define XFRM_PROTO_DSTOPTS IPPROTO_DSTOPTS |
38 | 38 | ||
39 | #define XFRM_ALIGN4(len) (((len) + 3) & ~3) | ||
39 | #define XFRM_ALIGN8(len) (((len) + 7) & ~7) | 40 | #define XFRM_ALIGN8(len) (((len) + 7) & ~7) |
40 | #define MODULE_ALIAS_XFRM_MODE(family, encap) \ | 41 | #define MODULE_ALIAS_XFRM_MODE(family, encap) \ |
41 | MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap)) | 42 | MODULE_ALIAS("xfrm-mode-" __stringify(family) "-" __stringify(encap)) |
@@ -143,6 +144,7 @@ struct xfrm_state { | |||
143 | struct xfrm_id id; | 144 | struct xfrm_id id; |
144 | struct xfrm_selector sel; | 145 | struct xfrm_selector sel; |
145 | struct xfrm_mark mark; | 146 | struct xfrm_mark mark; |
147 | u32 tfcpad; | ||
146 | 148 | ||
147 | u32 genid; | 149 | u32 genid; |
148 | 150 | ||
@@ -184,9 +186,14 @@ struct xfrm_state { | |||
184 | 186 | ||
185 | /* State for replay detection */ | 187 | /* State for replay detection */ |
186 | struct xfrm_replay_state replay; | 188 | struct xfrm_replay_state replay; |
189 | struct xfrm_replay_state_esn *replay_esn; | ||
187 | 190 | ||
188 | /* Replay detection state at the time we sent the last notification */ | 191 | /* Replay detection state at the time we sent the last notification */ |
189 | struct xfrm_replay_state preplay; | 192 | struct xfrm_replay_state preplay; |
193 | struct xfrm_replay_state_esn *preplay_esn; | ||
194 | |||
195 | /* The functions for replay detection. */ | ||
196 | struct xfrm_replay *repl; | ||
190 | 197 | ||
191 | /* internal flag that only holds state for delayed aevent at the | 198 | /* internal flag that only holds state for delayed aevent at the |
192 | * moment | 199 | * moment |
@@ -257,6 +264,15 @@ struct km_event { | |||
257 | struct net *net; | 264 | struct net *net; |
258 | }; | 265 | }; |
259 | 266 | ||
267 | struct xfrm_replay { | ||
268 | void (*advance)(struct xfrm_state *x, __be32 net_seq); | ||
269 | int (*check)(struct xfrm_state *x, | ||
270 | struct sk_buff *skb, | ||
271 | __be32 net_seq); | ||
272 | void (*notify)(struct xfrm_state *x, int event); | ||
273 | int (*overflow)(struct xfrm_state *x, struct sk_buff *skb); | ||
274 | }; | ||
275 | |||
260 | struct net_device; | 276 | struct net_device; |
261 | struct xfrm_type; | 277 | struct xfrm_type; |
262 | struct xfrm_dst; | 278 | struct xfrm_dst; |
@@ -265,25 +281,26 @@ struct xfrm_policy_afinfo { | |||
265 | struct dst_ops *dst_ops; | 281 | struct dst_ops *dst_ops; |
266 | void (*garbage_collect)(struct net *net); | 282 | void (*garbage_collect)(struct net *net); |
267 | struct dst_entry *(*dst_lookup)(struct net *net, int tos, | 283 | struct dst_entry *(*dst_lookup)(struct net *net, int tos, |
268 | xfrm_address_t *saddr, | 284 | const xfrm_address_t *saddr, |
269 | xfrm_address_t *daddr); | 285 | const xfrm_address_t *daddr); |
270 | int (*get_saddr)(struct net *net, xfrm_address_t *saddr, xfrm_address_t *daddr); | 286 | int (*get_saddr)(struct net *net, xfrm_address_t *saddr, xfrm_address_t *daddr); |
271 | void (*decode_session)(struct sk_buff *skb, | 287 | void (*decode_session)(struct sk_buff *skb, |
272 | struct flowi *fl, | 288 | struct flowi *fl, |
273 | int reverse); | 289 | int reverse); |
274 | int (*get_tos)(struct flowi *fl); | 290 | int (*get_tos)(const struct flowi *fl); |
275 | int (*init_path)(struct xfrm_dst *path, | 291 | int (*init_path)(struct xfrm_dst *path, |
276 | struct dst_entry *dst, | 292 | struct dst_entry *dst, |
277 | int nfheader_len); | 293 | int nfheader_len); |
278 | int (*fill_dst)(struct xfrm_dst *xdst, | 294 | int (*fill_dst)(struct xfrm_dst *xdst, |
279 | struct net_device *dev, | 295 | struct net_device *dev, |
280 | struct flowi *fl); | 296 | const struct flowi *fl); |
297 | struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig); | ||
281 | }; | 298 | }; |
282 | 299 | ||
283 | extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); | 300 | extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo); |
284 | extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo); | 301 | extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo); |
285 | extern void km_policy_notify(struct xfrm_policy *xp, int dir, struct km_event *c); | 302 | extern void km_policy_notify(struct xfrm_policy *xp, int dir, const struct km_event *c); |
286 | extern void km_state_notify(struct xfrm_state *x, struct km_event *c); | 303 | extern void km_state_notify(struct xfrm_state *x, const struct km_event *c); |
287 | 304 | ||
288 | struct xfrm_tmpl; | 305 | struct xfrm_tmpl; |
289 | extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); | 306 | extern int km_query(struct xfrm_state *x, struct xfrm_tmpl *t, struct xfrm_policy *pol); |
@@ -298,12 +315,16 @@ struct xfrm_state_afinfo { | |||
298 | const struct xfrm_type *type_map[IPPROTO_MAX]; | 315 | const struct xfrm_type *type_map[IPPROTO_MAX]; |
299 | struct xfrm_mode *mode_map[XFRM_MODE_MAX]; | 316 | struct xfrm_mode *mode_map[XFRM_MODE_MAX]; |
300 | int (*init_flags)(struct xfrm_state *x); | 317 | int (*init_flags)(struct xfrm_state *x); |
301 | void (*init_tempsel)(struct xfrm_selector *sel, struct flowi *fl); | 318 | void (*init_tempsel)(struct xfrm_selector *sel, |
302 | void (*init_temprop)(struct xfrm_state *x, struct xfrm_tmpl *tmpl, | 319 | const struct flowi *fl); |
303 | xfrm_address_t *daddr, xfrm_address_t *saddr); | 320 | void (*init_temprop)(struct xfrm_state *x, |
321 | const struct xfrm_tmpl *tmpl, | ||
322 | const xfrm_address_t *daddr, | ||
323 | const xfrm_address_t *saddr); | ||
304 | int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); | 324 | int (*tmpl_sort)(struct xfrm_tmpl **dst, struct xfrm_tmpl **src, int n); |
305 | int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); | 325 | int (*state_sort)(struct xfrm_state **dst, struct xfrm_state **src, int n); |
306 | int (*output)(struct sk_buff *skb); | 326 | int (*output)(struct sk_buff *skb); |
327 | int (*output_finish)(struct sk_buff *skb); | ||
307 | int (*extract_input)(struct xfrm_state *x, | 328 | int (*extract_input)(struct xfrm_state *x, |
308 | struct sk_buff *skb); | 329 | struct sk_buff *skb); |
309 | int (*extract_output)(struct xfrm_state *x, | 330 | int (*extract_output)(struct xfrm_state *x, |
@@ -331,7 +352,8 @@ struct xfrm_type { | |||
331 | void (*destructor)(struct xfrm_state *); | 352 | void (*destructor)(struct xfrm_state *); |
332 | int (*input)(struct xfrm_state *, struct sk_buff *skb); | 353 | int (*input)(struct xfrm_state *, struct sk_buff *skb); |
333 | int (*output)(struct xfrm_state *, struct sk_buff *pskb); | 354 | int (*output)(struct xfrm_state *, struct sk_buff *pskb); |
334 | int (*reject)(struct xfrm_state *, struct sk_buff *, struct flowi *); | 355 | int (*reject)(struct xfrm_state *, struct sk_buff *, |
356 | const struct flowi *); | ||
335 | int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); | 357 | int (*hdr_offset)(struct xfrm_state *, struct sk_buff *, u8 **); |
336 | /* Estimate maximal size of result of transformation of a dgram */ | 358 | /* Estimate maximal size of result of transformation of a dgram */ |
337 | u32 (*get_mtu)(struct xfrm_state *, int size); | 359 | u32 (*get_mtu)(struct xfrm_state *, int size); |
@@ -500,7 +522,7 @@ struct xfrm_policy { | |||
500 | struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; | 522 | struct xfrm_tmpl xfrm_vec[XFRM_MAX_DEPTH]; |
501 | }; | 523 | }; |
502 | 524 | ||
503 | static inline struct net *xp_net(struct xfrm_policy *xp) | 525 | static inline struct net *xp_net(const struct xfrm_policy *xp) |
504 | { | 526 | { |
505 | return read_pnet(&xp->xp_net); | 527 | return read_pnet(&xp->xp_net); |
506 | } | 528 | } |
@@ -544,13 +566,17 @@ struct xfrm_migrate { | |||
544 | struct xfrm_mgr { | 566 | struct xfrm_mgr { |
545 | struct list_head list; | 567 | struct list_head list; |
546 | char *id; | 568 | char *id; |
547 | int (*notify)(struct xfrm_state *x, struct km_event *c); | 569 | int (*notify)(struct xfrm_state *x, const struct km_event *c); |
548 | int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); | 570 | int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); |
549 | struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir); | 571 | struct xfrm_policy *(*compile_policy)(struct sock *sk, int opt, u8 *data, int len, int *dir); |
550 | int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); | 572 | int (*new_mapping)(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); |
551 | int (*notify_policy)(struct xfrm_policy *x, int dir, struct km_event *c); | 573 | int (*notify_policy)(struct xfrm_policy *x, int dir, const struct km_event *c); |
552 | int (*report)(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); | 574 | int (*report)(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); |
553 | int (*migrate)(struct xfrm_selector *sel, u8 dir, u8 type, struct xfrm_migrate *m, int num_bundles, struct xfrm_kmaddress *k); | 575 | int (*migrate)(const struct xfrm_selector *sel, |
576 | u8 dir, u8 type, | ||
577 | const struct xfrm_migrate *m, | ||
578 | int num_bundles, | ||
579 | const struct xfrm_kmaddress *k); | ||
554 | }; | 580 | }; |
555 | 581 | ||
556 | extern int xfrm_register_km(struct xfrm_mgr *km); | 582 | extern int xfrm_register_km(struct xfrm_mgr *km); |
@@ -569,8 +595,14 @@ struct xfrm_skb_cb { | |||
569 | 595 | ||
570 | /* Sequence number for replay protection. */ | 596 | /* Sequence number for replay protection. */ |
571 | union { | 597 | union { |
572 | u64 output; | 598 | struct { |
573 | __be32 input; | 599 | __u32 low; |
600 | __u32 hi; | ||
601 | } output; | ||
602 | struct { | ||
603 | __be32 low; | ||
604 | __be32 hi; | ||
605 | } input; | ||
574 | } seq; | 606 | } seq; |
575 | }; | 607 | }; |
576 | 608 | ||
@@ -674,6 +706,8 @@ extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, | |||
674 | u32 auid, u32 ses, u32 secid); | 706 | u32 auid, u32 ses, u32 secid); |
675 | extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, | 707 | extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, |
676 | struct sk_buff *skb); | 708 | struct sk_buff *skb); |
709 | extern void xfrm_audit_state_replay(struct xfrm_state *x, | ||
710 | struct sk_buff *skb, __be32 net_seq); | ||
677 | extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family); | 711 | extern void xfrm_audit_state_notfound_simple(struct sk_buff *skb, u16 family); |
678 | extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family, | 712 | extern void xfrm_audit_state_notfound(struct sk_buff *skb, u16 family, |
679 | __be32 net_spi, __be32 net_seq); | 713 | __be32 net_spi, __be32 net_seq); |
@@ -706,6 +740,11 @@ static inline void xfrm_audit_state_replay_overflow(struct xfrm_state *x, | |||
706 | { | 740 | { |
707 | } | 741 | } |
708 | 742 | ||
743 | static inline void xfrm_audit_state_replay(struct xfrm_state *x, | ||
744 | struct sk_buff *skb, __be32 net_seq) | ||
745 | { | ||
746 | } | ||
747 | |||
709 | static inline void xfrm_audit_state_notfound_simple(struct sk_buff *skb, | 748 | static inline void xfrm_audit_state_notfound_simple(struct sk_buff *skb, |
710 | u16 family) | 749 | u16 family) |
711 | { | 750 | { |
@@ -761,10 +800,11 @@ static inline void xfrm_state_hold(struct xfrm_state *x) | |||
761 | atomic_inc(&x->refcnt); | 800 | atomic_inc(&x->refcnt); |
762 | } | 801 | } |
763 | 802 | ||
764 | static __inline__ int addr_match(void *token1, void *token2, int prefixlen) | 803 | static inline bool addr_match(const void *token1, const void *token2, |
804 | int prefixlen) | ||
765 | { | 805 | { |
766 | __be32 *a1 = token1; | 806 | const __be32 *a1 = token1; |
767 | __be32 *a2 = token2; | 807 | const __be32 *a2 = token2; |
768 | int pdw; | 808 | int pdw; |
769 | int pbi; | 809 | int pbi; |
770 | 810 | ||
@@ -773,7 +813,7 @@ static __inline__ int addr_match(void *token1, void *token2, int prefixlen) | |||
773 | 813 | ||
774 | if (pdw) | 814 | if (pdw) |
775 | if (memcmp(a1, a2, pdw << 2)) | 815 | if (memcmp(a1, a2, pdw << 2)) |
776 | return 0; | 816 | return false; |
777 | 817 | ||
778 | if (pbi) { | 818 | if (pbi) { |
779 | __be32 mask; | 819 | __be32 mask; |
@@ -781,29 +821,32 @@ static __inline__ int addr_match(void *token1, void *token2, int prefixlen) | |||
781 | mask = htonl((0xffffffff) << (32 - pbi)); | 821 | mask = htonl((0xffffffff) << (32 - pbi)); |
782 | 822 | ||
783 | if ((a1[pdw] ^ a2[pdw]) & mask) | 823 | if ((a1[pdw] ^ a2[pdw]) & mask) |
784 | return 0; | 824 | return false; |
785 | } | 825 | } |
786 | 826 | ||
787 | return 1; | 827 | return true; |
788 | } | 828 | } |
789 | 829 | ||
790 | static __inline__ | 830 | static __inline__ |
791 | __be16 xfrm_flowi_sport(struct flowi *fl) | 831 | __be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli) |
792 | { | 832 | { |
793 | __be16 port; | 833 | __be16 port; |
794 | switch(fl->proto) { | 834 | switch(fl->flowi_proto) { |
795 | case IPPROTO_TCP: | 835 | case IPPROTO_TCP: |
796 | case IPPROTO_UDP: | 836 | case IPPROTO_UDP: |
797 | case IPPROTO_UDPLITE: | 837 | case IPPROTO_UDPLITE: |
798 | case IPPROTO_SCTP: | 838 | case IPPROTO_SCTP: |
799 | port = fl->fl_ip_sport; | 839 | port = uli->ports.sport; |
800 | break; | 840 | break; |
801 | case IPPROTO_ICMP: | 841 | case IPPROTO_ICMP: |
802 | case IPPROTO_ICMPV6: | 842 | case IPPROTO_ICMPV6: |
803 | port = htons(fl->fl_icmp_type); | 843 | port = htons(uli->icmpt.type); |
804 | break; | 844 | break; |
805 | case IPPROTO_MH: | 845 | case IPPROTO_MH: |
806 | port = htons(fl->fl_mh_type); | 846 | port = htons(uli->mht.type); |
847 | break; | ||
848 | case IPPROTO_GRE: | ||
849 | port = htons(ntohl(uli->gre_key) >> 16); | ||
807 | break; | 850 | break; |
808 | default: | 851 | default: |
809 | port = 0; /*XXX*/ | 852 | port = 0; /*XXX*/ |
@@ -812,19 +855,22 @@ __be16 xfrm_flowi_sport(struct flowi *fl) | |||
812 | } | 855 | } |
813 | 856 | ||
814 | static __inline__ | 857 | static __inline__ |
815 | __be16 xfrm_flowi_dport(struct flowi *fl) | 858 | __be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli) |
816 | { | 859 | { |
817 | __be16 port; | 860 | __be16 port; |
818 | switch(fl->proto) { | 861 | switch(fl->flowi_proto) { |
819 | case IPPROTO_TCP: | 862 | case IPPROTO_TCP: |
820 | case IPPROTO_UDP: | 863 | case IPPROTO_UDP: |
821 | case IPPROTO_UDPLITE: | 864 | case IPPROTO_UDPLITE: |
822 | case IPPROTO_SCTP: | 865 | case IPPROTO_SCTP: |
823 | port = fl->fl_ip_dport; | 866 | port = uli->ports.dport; |
824 | break; | 867 | break; |
825 | case IPPROTO_ICMP: | 868 | case IPPROTO_ICMP: |
826 | case IPPROTO_ICMPV6: | 869 | case IPPROTO_ICMPV6: |
827 | port = htons(fl->fl_icmp_code); | 870 | port = htons(uli->icmpt.code); |
871 | break; | ||
872 | case IPPROTO_GRE: | ||
873 | port = htons(ntohl(uli->gre_key) & 0xffff); | ||
828 | break; | 874 | break; |
829 | default: | 875 | default: |
830 | port = 0; /*XXX*/ | 876 | port = 0; /*XXX*/ |
@@ -832,7 +878,8 @@ __be16 xfrm_flowi_dport(struct flowi *fl) | |||
832 | return port; | 878 | return port; |
833 | } | 879 | } |
834 | 880 | ||
835 | extern int xfrm_selector_match(struct xfrm_selector *sel, struct flowi *fl, | 881 | extern int xfrm_selector_match(const struct xfrm_selector *sel, |
882 | const struct flowi *fl, | ||
836 | unsigned short family); | 883 | unsigned short family); |
837 | 884 | ||
838 | #ifdef CONFIG_SECURITY_NETWORK_XFRM | 885 | #ifdef CONFIG_SECURITY_NETWORK_XFRM |
@@ -911,6 +958,15 @@ struct sec_path { | |||
911 | struct xfrm_state *xvec[XFRM_MAX_DEPTH]; | 958 | struct xfrm_state *xvec[XFRM_MAX_DEPTH]; |
912 | }; | 959 | }; |
913 | 960 | ||
961 | static inline int secpath_exists(struct sk_buff *skb) | ||
962 | { | ||
963 | #ifdef CONFIG_XFRM | ||
964 | return skb->sp != NULL; | ||
965 | #else | ||
966 | return 0; | ||
967 | #endif | ||
968 | } | ||
969 | |||
914 | static inline struct sec_path * | 970 | static inline struct sec_path * |
915 | secpath_get(struct sec_path *sp) | 971 | secpath_get(struct sec_path *sp) |
916 | { | 972 | { |
@@ -940,7 +996,7 @@ secpath_reset(struct sk_buff *skb) | |||
940 | } | 996 | } |
941 | 997 | ||
942 | static inline int | 998 | static inline int |
943 | xfrm_addr_any(xfrm_address_t *addr, unsigned short family) | 999 | xfrm_addr_any(const xfrm_address_t *addr, unsigned short family) |
944 | { | 1000 | { |
945 | switch (family) { | 1001 | switch (family) { |
946 | case AF_INET: | 1002 | case AF_INET: |
@@ -952,21 +1008,21 @@ xfrm_addr_any(xfrm_address_t *addr, unsigned short family) | |||
952 | } | 1008 | } |
953 | 1009 | ||
954 | static inline int | 1010 | static inline int |
955 | __xfrm4_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x) | 1011 | __xfrm4_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x) |
956 | { | 1012 | { |
957 | return (tmpl->saddr.a4 && | 1013 | return (tmpl->saddr.a4 && |
958 | tmpl->saddr.a4 != x->props.saddr.a4); | 1014 | tmpl->saddr.a4 != x->props.saddr.a4); |
959 | } | 1015 | } |
960 | 1016 | ||
961 | static inline int | 1017 | static inline int |
962 | __xfrm6_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x) | 1018 | __xfrm6_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x) |
963 | { | 1019 | { |
964 | return (!ipv6_addr_any((struct in6_addr*)&tmpl->saddr) && | 1020 | return (!ipv6_addr_any((struct in6_addr*)&tmpl->saddr) && |
965 | ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr)); | 1021 | ipv6_addr_cmp((struct in6_addr *)&tmpl->saddr, (struct in6_addr*)&x->props.saddr)); |
966 | } | 1022 | } |
967 | 1023 | ||
968 | static inline int | 1024 | static inline int |
969 | xfrm_state_addr_cmp(struct xfrm_tmpl *tmpl, struct xfrm_state *x, unsigned short family) | 1025 | xfrm_state_addr_cmp(const struct xfrm_tmpl *tmpl, const struct xfrm_state *x, unsigned short family) |
970 | { | 1026 | { |
971 | switch (family) { | 1027 | switch (family) { |
972 | case AF_INET: | 1028 | case AF_INET: |
@@ -1119,49 +1175,49 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir, | |||
1119 | #endif | 1175 | #endif |
1120 | 1176 | ||
1121 | static __inline__ | 1177 | static __inline__ |
1122 | xfrm_address_t *xfrm_flowi_daddr(struct flowi *fl, unsigned short family) | 1178 | xfrm_address_t *xfrm_flowi_daddr(const struct flowi *fl, unsigned short family) |
1123 | { | 1179 | { |
1124 | switch (family){ | 1180 | switch (family){ |
1125 | case AF_INET: | 1181 | case AF_INET: |
1126 | return (xfrm_address_t *)&fl->fl4_dst; | 1182 | return (xfrm_address_t *)&fl->u.ip4.daddr; |
1127 | case AF_INET6: | 1183 | case AF_INET6: |
1128 | return (xfrm_address_t *)&fl->fl6_dst; | 1184 | return (xfrm_address_t *)&fl->u.ip6.daddr; |
1129 | } | 1185 | } |
1130 | return NULL; | 1186 | return NULL; |
1131 | } | 1187 | } |
1132 | 1188 | ||
1133 | static __inline__ | 1189 | static __inline__ |
1134 | xfrm_address_t *xfrm_flowi_saddr(struct flowi *fl, unsigned short family) | 1190 | xfrm_address_t *xfrm_flowi_saddr(const struct flowi *fl, unsigned short family) |
1135 | { | 1191 | { |
1136 | switch (family){ | 1192 | switch (family){ |
1137 | case AF_INET: | 1193 | case AF_INET: |
1138 | return (xfrm_address_t *)&fl->fl4_src; | 1194 | return (xfrm_address_t *)&fl->u.ip4.saddr; |
1139 | case AF_INET6: | 1195 | case AF_INET6: |
1140 | return (xfrm_address_t *)&fl->fl6_src; | 1196 | return (xfrm_address_t *)&fl->u.ip6.saddr; |
1141 | } | 1197 | } |
1142 | return NULL; | 1198 | return NULL; |
1143 | } | 1199 | } |
1144 | 1200 | ||
1145 | static __inline__ | 1201 | static __inline__ |
1146 | void xfrm_flowi_addr_get(struct flowi *fl, | 1202 | void xfrm_flowi_addr_get(const struct flowi *fl, |
1147 | xfrm_address_t *saddr, xfrm_address_t *daddr, | 1203 | xfrm_address_t *saddr, xfrm_address_t *daddr, |
1148 | unsigned short family) | 1204 | unsigned short family) |
1149 | { | 1205 | { |
1150 | switch(family) { | 1206 | switch(family) { |
1151 | case AF_INET: | 1207 | case AF_INET: |
1152 | memcpy(&saddr->a4, &fl->fl4_src, sizeof(saddr->a4)); | 1208 | memcpy(&saddr->a4, &fl->u.ip4.saddr, sizeof(saddr->a4)); |
1153 | memcpy(&daddr->a4, &fl->fl4_dst, sizeof(daddr->a4)); | 1209 | memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4)); |
1154 | break; | 1210 | break; |
1155 | case AF_INET6: | 1211 | case AF_INET6: |
1156 | ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->fl6_src); | 1212 | ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->u.ip6.saddr); |
1157 | ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->fl6_dst); | 1213 | ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->u.ip6.daddr); |
1158 | break; | 1214 | break; |
1159 | } | 1215 | } |
1160 | } | 1216 | } |
1161 | 1217 | ||
1162 | static __inline__ int | 1218 | static __inline__ int |
1163 | __xfrm4_state_addr_check(struct xfrm_state *x, | 1219 | __xfrm4_state_addr_check(const struct xfrm_state *x, |
1164 | xfrm_address_t *daddr, xfrm_address_t *saddr) | 1220 | const xfrm_address_t *daddr, const xfrm_address_t *saddr) |
1165 | { | 1221 | { |
1166 | if (daddr->a4 == x->id.daddr.a4 && | 1222 | if (daddr->a4 == x->id.daddr.a4 && |
1167 | (saddr->a4 == x->props.saddr.a4 || !saddr->a4 || !x->props.saddr.a4)) | 1223 | (saddr->a4 == x->props.saddr.a4 || !saddr->a4 || !x->props.saddr.a4)) |
@@ -1170,8 +1226,8 @@ __xfrm4_state_addr_check(struct xfrm_state *x, | |||
1170 | } | 1226 | } |
1171 | 1227 | ||
1172 | static __inline__ int | 1228 | static __inline__ int |
1173 | __xfrm6_state_addr_check(struct xfrm_state *x, | 1229 | __xfrm6_state_addr_check(const struct xfrm_state *x, |
1174 | xfrm_address_t *daddr, xfrm_address_t *saddr) | 1230 | const xfrm_address_t *daddr, const xfrm_address_t *saddr) |
1175 | { | 1231 | { |
1176 | if (!ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)&x->id.daddr) && | 1232 | if (!ipv6_addr_cmp((struct in6_addr *)daddr, (struct in6_addr *)&x->id.daddr) && |
1177 | (!ipv6_addr_cmp((struct in6_addr *)saddr, (struct in6_addr *)&x->props.saddr)|| | 1233 | (!ipv6_addr_cmp((struct in6_addr *)saddr, (struct in6_addr *)&x->props.saddr)|| |
@@ -1182,8 +1238,8 @@ __xfrm6_state_addr_check(struct xfrm_state *x, | |||
1182 | } | 1238 | } |
1183 | 1239 | ||
1184 | static __inline__ int | 1240 | static __inline__ int |
1185 | xfrm_state_addr_check(struct xfrm_state *x, | 1241 | xfrm_state_addr_check(const struct xfrm_state *x, |
1186 | xfrm_address_t *daddr, xfrm_address_t *saddr, | 1242 | const xfrm_address_t *daddr, const xfrm_address_t *saddr, |
1187 | unsigned short family) | 1243 | unsigned short family) |
1188 | { | 1244 | { |
1189 | switch (family) { | 1245 | switch (family) { |
@@ -1196,23 +1252,23 @@ xfrm_state_addr_check(struct xfrm_state *x, | |||
1196 | } | 1252 | } |
1197 | 1253 | ||
1198 | static __inline__ int | 1254 | static __inline__ int |
1199 | xfrm_state_addr_flow_check(struct xfrm_state *x, struct flowi *fl, | 1255 | xfrm_state_addr_flow_check(const struct xfrm_state *x, const struct flowi *fl, |
1200 | unsigned short family) | 1256 | unsigned short family) |
1201 | { | 1257 | { |
1202 | switch (family) { | 1258 | switch (family) { |
1203 | case AF_INET: | 1259 | case AF_INET: |
1204 | return __xfrm4_state_addr_check(x, | 1260 | return __xfrm4_state_addr_check(x, |
1205 | (xfrm_address_t *)&fl->fl4_dst, | 1261 | (const xfrm_address_t *)&fl->u.ip4.daddr, |
1206 | (xfrm_address_t *)&fl->fl4_src); | 1262 | (const xfrm_address_t *)&fl->u.ip4.saddr); |
1207 | case AF_INET6: | 1263 | case AF_INET6: |
1208 | return __xfrm6_state_addr_check(x, | 1264 | return __xfrm6_state_addr_check(x, |
1209 | (xfrm_address_t *)&fl->fl6_dst, | 1265 | (const xfrm_address_t *)&fl->u.ip6.daddr, |
1210 | (xfrm_address_t *)&fl->fl6_src); | 1266 | (const xfrm_address_t *)&fl->u.ip6.saddr); |
1211 | } | 1267 | } |
1212 | return 0; | 1268 | return 0; |
1213 | } | 1269 | } |
1214 | 1270 | ||
1215 | static inline int xfrm_state_kern(struct xfrm_state *x) | 1271 | static inline int xfrm_state_kern(const struct xfrm_state *x) |
1216 | { | 1272 | { |
1217 | return atomic_read(&x->tunnel_users); | 1273 | return atomic_read(&x->tunnel_users); |
1218 | } | 1274 | } |
@@ -1264,7 +1320,7 @@ struct xfrm_tunnel { | |||
1264 | int (*handler)(struct sk_buff *skb); | 1320 | int (*handler)(struct sk_buff *skb); |
1265 | int (*err_handler)(struct sk_buff *skb, u32 info); | 1321 | int (*err_handler)(struct sk_buff *skb, u32 info); |
1266 | 1322 | ||
1267 | struct xfrm_tunnel *next; | 1323 | struct xfrm_tunnel __rcu *next; |
1268 | int priority; | 1324 | int priority; |
1269 | }; | 1325 | }; |
1270 | 1326 | ||
@@ -1272,7 +1328,7 @@ struct xfrm6_tunnel { | |||
1272 | int (*handler)(struct sk_buff *skb); | 1328 | int (*handler)(struct sk_buff *skb); |
1273 | int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt, | 1329 | int (*err_handler)(struct sk_buff *skb, struct inet6_skb_parm *opt, |
1274 | u8 type, u8 code, int offset, __be32 info); | 1330 | u8 type, u8 code, int offset, __be32 info); |
1275 | struct xfrm6_tunnel *next; | 1331 | struct xfrm6_tunnel __rcu *next; |
1276 | int priority; | 1332 | int priority; |
1277 | }; | 1333 | }; |
1278 | 1334 | ||
@@ -1316,8 +1372,10 @@ extern int xfrm_state_walk(struct net *net, struct xfrm_state_walk *walk, | |||
1316 | int (*func)(struct xfrm_state *, int, void*), void *); | 1372 | int (*func)(struct xfrm_state *, int, void*), void *); |
1317 | extern void xfrm_state_walk_done(struct xfrm_state_walk *walk); | 1373 | extern void xfrm_state_walk_done(struct xfrm_state_walk *walk); |
1318 | extern struct xfrm_state *xfrm_state_alloc(struct net *net); | 1374 | extern struct xfrm_state *xfrm_state_alloc(struct net *net); |
1319 | extern struct xfrm_state *xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | 1375 | extern struct xfrm_state *xfrm_state_find(const xfrm_address_t *daddr, |
1320 | struct flowi *fl, struct xfrm_tmpl *tmpl, | 1376 | const xfrm_address_t *saddr, |
1377 | const struct flowi *fl, | ||
1378 | struct xfrm_tmpl *tmpl, | ||
1321 | struct xfrm_policy *pol, int *err, | 1379 | struct xfrm_policy *pol, int *err, |
1322 | unsigned short family); | 1380 | unsigned short family); |
1323 | extern struct xfrm_state *xfrm_stateonly_find(struct net *net, u32 mark, | 1381 | extern struct xfrm_state *xfrm_stateonly_find(struct net *net, u32 mark, |
@@ -1330,11 +1388,11 @@ extern void xfrm_state_insert(struct xfrm_state *x); | |||
1330 | extern int xfrm_state_add(struct xfrm_state *x); | 1388 | extern int xfrm_state_add(struct xfrm_state *x); |
1331 | extern int xfrm_state_update(struct xfrm_state *x); | 1389 | extern int xfrm_state_update(struct xfrm_state *x); |
1332 | extern struct xfrm_state *xfrm_state_lookup(struct net *net, u32 mark, | 1390 | extern struct xfrm_state *xfrm_state_lookup(struct net *net, u32 mark, |
1333 | xfrm_address_t *daddr, __be32 spi, | 1391 | const xfrm_address_t *daddr, __be32 spi, |
1334 | u8 proto, unsigned short family); | 1392 | u8 proto, unsigned short family); |
1335 | extern struct xfrm_state *xfrm_state_lookup_byaddr(struct net *net, u32 mark, | 1393 | extern struct xfrm_state *xfrm_state_lookup_byaddr(struct net *net, u32 mark, |
1336 | xfrm_address_t *daddr, | 1394 | const xfrm_address_t *daddr, |
1337 | xfrm_address_t *saddr, | 1395 | const xfrm_address_t *saddr, |
1338 | u8 proto, | 1396 | u8 proto, |
1339 | unsigned short family); | 1397 | unsigned short family); |
1340 | #ifdef CONFIG_XFRM_SUB_POLICY | 1398 | #ifdef CONFIG_XFRM_SUB_POLICY |
@@ -1379,11 +1437,10 @@ extern int xfrm_state_delete(struct xfrm_state *x); | |||
1379 | extern int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info); | 1437 | extern int xfrm_state_flush(struct net *net, u8 proto, struct xfrm_audit *audit_info); |
1380 | extern void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si); | 1438 | extern void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si); |
1381 | extern void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si); | 1439 | extern void xfrm_spd_getinfo(struct net *net, struct xfrmk_spdinfo *si); |
1382 | extern int xfrm_replay_check(struct xfrm_state *x, | 1440 | extern u32 xfrm_replay_seqhi(struct xfrm_state *x, __be32 net_seq); |
1383 | struct sk_buff *skb, __be32 seq); | 1441 | extern int xfrm_init_replay(struct xfrm_state *x); |
1384 | extern void xfrm_replay_advance(struct xfrm_state *x, __be32 seq); | ||
1385 | extern void xfrm_replay_notify(struct xfrm_state *x, int event); | ||
1386 | extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); | 1442 | extern int xfrm_state_mtu(struct xfrm_state *x, int mtu); |
1443 | extern int __xfrm_init_state(struct xfrm_state *x, bool init_replay); | ||
1387 | extern int xfrm_init_state(struct xfrm_state *x); | 1444 | extern int xfrm_init_state(struct xfrm_state *x); |
1388 | extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb); | 1445 | extern int xfrm_prepare_input(struct xfrm_state *x, struct sk_buff *skb); |
1389 | extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, | 1446 | extern int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, |
@@ -1407,6 +1464,7 @@ static inline int xfrm4_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi) | |||
1407 | extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); | 1464 | extern int xfrm4_extract_output(struct xfrm_state *x, struct sk_buff *skb); |
1408 | extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); | 1465 | extern int xfrm4_prepare_output(struct xfrm_state *x, struct sk_buff *skb); |
1409 | extern int xfrm4_output(struct sk_buff *skb); | 1466 | extern int xfrm4_output(struct sk_buff *skb); |
1467 | extern int xfrm4_output_finish(struct sk_buff *skb); | ||
1410 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); | 1468 | extern int xfrm4_tunnel_register(struct xfrm_tunnel *handler, unsigned short family); |
1411 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); | 1469 | extern int xfrm4_tunnel_deregister(struct xfrm_tunnel *handler, unsigned short family); |
1412 | extern int xfrm6_extract_header(struct sk_buff *skb); | 1470 | extern int xfrm6_extract_header(struct sk_buff *skb); |
@@ -1419,11 +1477,11 @@ extern int xfrm6_input_addr(struct sk_buff *skb, xfrm_address_t *daddr, | |||
1419 | extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family); | 1477 | extern int xfrm6_tunnel_register(struct xfrm6_tunnel *handler, unsigned short family); |
1420 | extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family); | 1478 | extern int xfrm6_tunnel_deregister(struct xfrm6_tunnel *handler, unsigned short family); |
1421 | extern __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr); | 1479 | extern __be32 xfrm6_tunnel_alloc_spi(struct net *net, xfrm_address_t *saddr); |
1422 | extern void xfrm6_tunnel_free_spi(struct net *net, xfrm_address_t *saddr); | 1480 | extern __be32 xfrm6_tunnel_spi_lookup(struct net *net, const xfrm_address_t *saddr); |
1423 | extern __be32 xfrm6_tunnel_spi_lookup(struct net *net, xfrm_address_t *saddr); | ||
1424 | extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); | 1481 | extern int xfrm6_extract_output(struct xfrm_state *x, struct sk_buff *skb); |
1425 | extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); | 1482 | extern int xfrm6_prepare_output(struct xfrm_state *x, struct sk_buff *skb); |
1426 | extern int xfrm6_output(struct sk_buff *skb); | 1483 | extern int xfrm6_output(struct sk_buff *skb); |
1484 | extern int xfrm6_output_finish(struct sk_buff *skb); | ||
1427 | extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, | 1485 | extern int xfrm6_find_1stfragopt(struct xfrm_state *x, struct sk_buff *skb, |
1428 | u8 **prevhdr); | 1486 | u8 **prevhdr); |
1429 | 1487 | ||
@@ -1462,21 +1520,19 @@ u32 xfrm_get_acqseq(void); | |||
1462 | extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); | 1520 | extern int xfrm_alloc_spi(struct xfrm_state *x, u32 minspi, u32 maxspi); |
1463 | struct xfrm_state *xfrm_find_acq(struct net *net, struct xfrm_mark *mark, | 1521 | struct xfrm_state *xfrm_find_acq(struct net *net, struct xfrm_mark *mark, |
1464 | u8 mode, u32 reqid, u8 proto, | 1522 | u8 mode, u32 reqid, u8 proto, |
1465 | xfrm_address_t *daddr, | 1523 | const xfrm_address_t *daddr, |
1466 | xfrm_address_t *saddr, int create, | 1524 | const xfrm_address_t *saddr, int create, |
1467 | unsigned short family); | 1525 | unsigned short family); |
1468 | extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); | 1526 | extern int xfrm_sk_policy_insert(struct sock *sk, int dir, struct xfrm_policy *pol); |
1469 | extern int xfrm_bundle_ok(struct xfrm_policy *pol, struct xfrm_dst *xdst, | ||
1470 | struct flowi *fl, int family, int strict); | ||
1471 | 1527 | ||
1472 | #ifdef CONFIG_XFRM_MIGRATE | 1528 | #ifdef CONFIG_XFRM_MIGRATE |
1473 | extern int km_migrate(struct xfrm_selector *sel, u8 dir, u8 type, | 1529 | extern int km_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, |
1474 | struct xfrm_migrate *m, int num_bundles, | 1530 | const struct xfrm_migrate *m, int num_bundles, |
1475 | struct xfrm_kmaddress *k); | 1531 | const struct xfrm_kmaddress *k); |
1476 | extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m); | 1532 | extern struct xfrm_state * xfrm_migrate_state_find(struct xfrm_migrate *m); |
1477 | extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x, | 1533 | extern struct xfrm_state * xfrm_state_migrate(struct xfrm_state *x, |
1478 | struct xfrm_migrate *m); | 1534 | struct xfrm_migrate *m); |
1479 | extern int xfrm_migrate(struct xfrm_selector *sel, u8 dir, u8 type, | 1535 | extern int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, |
1480 | struct xfrm_migrate *m, int num_bundles, | 1536 | struct xfrm_migrate *m, int num_bundles, |
1481 | struct xfrm_kmaddress *k); | 1537 | struct xfrm_kmaddress *k); |
1482 | #endif | 1538 | #endif |
@@ -1496,10 +1552,10 @@ extern struct xfrm_algo_desc *xfrm_ealg_get_byidx(unsigned int idx); | |||
1496 | extern struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id); | 1552 | extern struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id); |
1497 | extern struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id); | 1553 | extern struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id); |
1498 | extern struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id); | 1554 | extern struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id); |
1499 | extern struct xfrm_algo_desc *xfrm_aalg_get_byname(char *name, int probe); | 1555 | extern struct xfrm_algo_desc *xfrm_aalg_get_byname(const char *name, int probe); |
1500 | extern struct xfrm_algo_desc *xfrm_ealg_get_byname(char *name, int probe); | 1556 | extern struct xfrm_algo_desc *xfrm_ealg_get_byname(const char *name, int probe); |
1501 | extern struct xfrm_algo_desc *xfrm_calg_get_byname(char *name, int probe); | 1557 | extern struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe); |
1502 | extern struct xfrm_algo_desc *xfrm_aead_get_byname(char *name, int icv_len, | 1558 | extern struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len, |
1503 | int probe); | 1559 | int probe); |
1504 | 1560 | ||
1505 | struct hash_desc; | 1561 | struct hash_desc; |
@@ -1507,7 +1563,8 @@ struct scatterlist; | |||
1507 | typedef int (icv_update_fn_t)(struct hash_desc *, struct scatterlist *, | 1563 | typedef int (icv_update_fn_t)(struct hash_desc *, struct scatterlist *, |
1508 | unsigned int); | 1564 | unsigned int); |
1509 | 1565 | ||
1510 | static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b, | 1566 | static inline int xfrm_addr_cmp(const xfrm_address_t *a, |
1567 | const xfrm_address_t *b, | ||
1511 | int family) | 1568 | int family) |
1512 | { | 1569 | { |
1513 | switch (family) { | 1570 | switch (family) { |
@@ -1515,8 +1572,8 @@ static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b, | |||
1515 | case AF_INET: | 1572 | case AF_INET: |
1516 | return (__force u32)a->a4 - (__force u32)b->a4; | 1573 | return (__force u32)a->a4 - (__force u32)b->a4; |
1517 | case AF_INET6: | 1574 | case AF_INET6: |
1518 | return ipv6_addr_cmp((struct in6_addr *)a, | 1575 | return ipv6_addr_cmp((const struct in6_addr *)a, |
1519 | (struct in6_addr *)b); | 1576 | (const struct in6_addr *)b); |
1520 | } | 1577 | } |
1521 | } | 1578 | } |
1522 | 1579 | ||
@@ -1540,17 +1597,44 @@ static inline int xfrm_aevent_is_on(struct net *net) | |||
1540 | } | 1597 | } |
1541 | #endif | 1598 | #endif |
1542 | 1599 | ||
1543 | static inline int xfrm_alg_len(struct xfrm_algo *alg) | 1600 | static inline int xfrm_alg_len(const struct xfrm_algo *alg) |
1544 | { | 1601 | { |
1545 | return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); | 1602 | return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); |
1546 | } | 1603 | } |
1547 | 1604 | ||
1548 | static inline int xfrm_alg_auth_len(struct xfrm_algo_auth *alg) | 1605 | static inline int xfrm_alg_auth_len(const struct xfrm_algo_auth *alg) |
1549 | { | 1606 | { |
1550 | return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); | 1607 | return sizeof(*alg) + ((alg->alg_key_len + 7) / 8); |
1551 | } | 1608 | } |
1552 | 1609 | ||
1610 | static inline int xfrm_replay_state_esn_len(struct xfrm_replay_state_esn *replay_esn) | ||
1611 | { | ||
1612 | return sizeof(*replay_esn) + replay_esn->bmp_len * sizeof(__u32); | ||
1613 | } | ||
1614 | |||
1553 | #ifdef CONFIG_XFRM_MIGRATE | 1615 | #ifdef CONFIG_XFRM_MIGRATE |
1616 | static inline int xfrm_replay_clone(struct xfrm_state *x, | ||
1617 | struct xfrm_state *orig) | ||
1618 | { | ||
1619 | x->replay_esn = kzalloc(xfrm_replay_state_esn_len(orig->replay_esn), | ||
1620 | GFP_KERNEL); | ||
1621 | if (!x->replay_esn) | ||
1622 | return -ENOMEM; | ||
1623 | |||
1624 | x->replay_esn->bmp_len = orig->replay_esn->bmp_len; | ||
1625 | x->replay_esn->replay_window = orig->replay_esn->replay_window; | ||
1626 | |||
1627 | x->preplay_esn = kmemdup(x->replay_esn, | ||
1628 | xfrm_replay_state_esn_len(x->replay_esn), | ||
1629 | GFP_KERNEL); | ||
1630 | if (!x->preplay_esn) { | ||
1631 | kfree(x->replay_esn); | ||
1632 | return -ENOMEM; | ||
1633 | } | ||
1634 | |||
1635 | return 0; | ||
1636 | } | ||
1637 | |||
1554 | static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) | 1638 | static inline struct xfrm_algo *xfrm_algo_clone(struct xfrm_algo *orig) |
1555 | { | 1639 | { |
1556 | return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL); | 1640 | return kmemdup(orig, xfrm_alg_len(orig), GFP_KERNEL); |
@@ -1593,7 +1677,7 @@ static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m) | |||
1593 | return m->v & m->m; | 1677 | return m->v & m->m; |
1594 | } | 1678 | } |
1595 | 1679 | ||
1596 | static inline int xfrm_mark_put(struct sk_buff *skb, struct xfrm_mark *m) | 1680 | static inline int xfrm_mark_put(struct sk_buff *skb, const struct xfrm_mark *m) |
1597 | { | 1681 | { |
1598 | if (m->m | m->v) | 1682 | if (m->m | m->v) |
1599 | NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m); | 1683 | NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m); |