diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/net | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'include/net')
155 files changed, 2931 insertions, 10048 deletions
diff --git a/include/net/9p/9p.h b/include/net/9p/9p.h index 7184853ca36..a6326ef8ade 100644 --- a/include/net/9p/9p.h +++ b/include/net/9p/9p.h | |||
@@ -63,16 +63,33 @@ enum p9_debug_flags { | |||
63 | 63 | ||
64 | #ifdef CONFIG_NET_9P_DEBUG | 64 | #ifdef CONFIG_NET_9P_DEBUG |
65 | extern unsigned int p9_debug_level; | 65 | extern unsigned int p9_debug_level; |
66 | __printf(3, 4) | 66 | |
67 | void _p9_debug(enum p9_debug_flags level, const char *func, | 67 | #define P9_DPRINTK(level, format, arg...) \ |
68 | const char *fmt, ...); | 68 | do { \ |
69 | #define p9_debug(level, fmt, ...) \ | 69 | if ((p9_debug_level & level) == level) {\ |
70 | _p9_debug(level, __func__, fmt, ##__VA_ARGS__) | 70 | if (level == P9_DEBUG_9P) \ |
71 | printk(KERN_NOTICE "(%8.8d) " \ | ||
72 | format , task_pid_nr(current) , ## arg); \ | ||
73 | else \ | ||
74 | printk(KERN_NOTICE "-- %s (%d): " \ | ||
75 | format , __func__, task_pid_nr(current) , ## arg); \ | ||
76 | } \ | ||
77 | } while (0) | ||
78 | |||
79 | #define P9_DUMP_PKT(way, pdu) p9pdu_dump(way, pdu) | ||
80 | |||
71 | #else | 81 | #else |
72 | #define p9_debug(level, fmt, ...) \ | 82 | #define P9_DPRINTK(level, format, arg...) do { } while (0) |
73 | no_printk(fmt, ##__VA_ARGS__) | 83 | #define P9_DUMP_PKT(way, pdu) do { } while (0) |
74 | #endif | 84 | #endif |
75 | 85 | ||
86 | |||
87 | #define P9_EPRINTK(level, format, arg...) \ | ||
88 | do { \ | ||
89 | printk(level "9p: %s (%d): " \ | ||
90 | format , __func__, task_pid_nr(current), ## arg); \ | ||
91 | } while (0) | ||
92 | |||
76 | /** | 93 | /** |
77 | * enum p9_msg_t - 9P message types | 94 | * enum p9_msg_t - 9P message types |
78 | * @P9_TLERROR: not used | 95 | * @P9_TLERROR: not used |
@@ -342,9 +359,6 @@ enum p9_qid_t { | |||
342 | /* Room for readdir header */ | 359 | /* Room for readdir header */ |
343 | #define P9_READDIRHDRSZ 24 | 360 | #define P9_READDIRHDRSZ 24 |
344 | 361 | ||
345 | /* size of header for zero copy read/write */ | ||
346 | #define P9_ZC_HDR_SZ 4096 | ||
347 | |||
348 | /** | 362 | /** |
349 | * struct p9_qid - file system entity information | 363 | * struct p9_qid - file system entity information |
350 | * @type: 8-bit type &p9_qid_t | 364 | * @type: 8-bit type &p9_qid_t |
@@ -541,6 +555,10 @@ struct p9_rstatfs { | |||
541 | * @tag: transaction id of the request | 555 | * @tag: transaction id of the request |
542 | * @offset: used by marshalling routines to track current position in buffer | 556 | * @offset: used by marshalling routines to track current position in buffer |
543 | * @capacity: used by marshalling routines to track total malloc'd capacity | 557 | * @capacity: used by marshalling routines to track total malloc'd capacity |
558 | * @pubuf: Payload user buffer given by the caller | ||
559 | * @pkbuf: Payload kernel buffer given by the caller | ||
560 | * @pbuf_size: pubuf/pkbuf(only one will be !NULL) size to be read/write. | ||
561 | * @private: For transport layer's use. | ||
544 | * @sdata: payload | 562 | * @sdata: payload |
545 | * | 563 | * |
546 | * &p9_fcall represents the structure for all 9P RPC | 564 | * &p9_fcall represents the structure for all 9P RPC |
@@ -557,6 +575,10 @@ struct p9_fcall { | |||
557 | 575 | ||
558 | size_t offset; | 576 | size_t offset; |
559 | size_t capacity; | 577 | size_t capacity; |
578 | char __user *pubuf; | ||
579 | char *pkbuf; | ||
580 | size_t pbuf_size; | ||
581 | void *private; | ||
560 | 582 | ||
561 | u8 *sdata; | 583 | u8 *sdata; |
562 | }; | 584 | }; |
diff --git a/include/net/9p/client.h b/include/net/9p/client.h index fc9b90b0c05..55ce72ce986 100644 --- a/include/net/9p/client.h +++ b/include/net/9p/client.h | |||
@@ -151,7 +151,7 @@ struct p9_req_t { | |||
151 | 151 | ||
152 | struct p9_client { | 152 | struct p9_client { |
153 | spinlock_t lock; /* protect client structure */ | 153 | spinlock_t lock; /* protect client structure */ |
154 | unsigned int msize; | 154 | int msize; |
155 | unsigned char proto_version; | 155 | unsigned char proto_version; |
156 | struct p9_trans_module *trans_mod; | 156 | struct p9_trans_module *trans_mod; |
157 | enum p9_trans_status status; | 157 | enum p9_trans_status status; |
@@ -240,8 +240,8 @@ int p9_client_read(struct p9_fid *fid, char *data, char __user *udata, | |||
240 | int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, | 240 | int p9_client_write(struct p9_fid *fid, char *data, const char __user *udata, |
241 | u64 offset, u32 count); | 241 | u64 offset, u32 count); |
242 | int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset); | 242 | int p9_client_readdir(struct p9_fid *fid, char *data, u32 count, u64 offset); |
243 | int p9dirent_read(struct p9_client *clnt, char *buf, int len, | 243 | int p9dirent_read(char *buf, int len, struct p9_dirent *dirent, |
244 | struct p9_dirent *dirent); | 244 | int proto_version); |
245 | struct p9_wstat *p9_client_stat(struct p9_fid *fid); | 245 | struct p9_wstat *p9_client_stat(struct p9_fid *fid); |
246 | int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst); | 246 | int p9_client_wstat(struct p9_fid *fid, struct p9_wstat *wst); |
247 | int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr); | 247 | int p9_client_setattr(struct p9_fid *fid, struct p9_iattr_dotl *attr); |
@@ -259,7 +259,7 @@ struct p9_req_t *p9_tag_lookup(struct p9_client *, u16); | |||
259 | void p9_client_cb(struct p9_client *c, struct p9_req_t *req); | 259 | void p9_client_cb(struct p9_client *c, struct p9_req_t *req); |
260 | 260 | ||
261 | int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int); | 261 | int p9_parse_header(struct p9_fcall *, int32_t *, int8_t *, int16_t *, int); |
262 | int p9stat_read(struct p9_client *, char *, int, struct p9_wstat *); | 262 | int p9stat_read(char *, int, struct p9_wstat *, int); |
263 | void p9stat_free(struct p9_wstat *); | 263 | void p9stat_free(struct p9_wstat *); |
264 | 264 | ||
265 | int p9_is_proto_dotu(struct p9_client *clnt); | 265 | int p9_is_proto_dotu(struct p9_client *clnt); |
diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h index adcbb20f651..83531ebeee9 100644 --- a/include/net/9p/transport.h +++ b/include/net/9p/transport.h | |||
@@ -26,6 +26,13 @@ | |||
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 |
@@ -49,14 +56,13 @@ struct p9_trans_module { | |||
49 | struct list_head list; | 56 | struct list_head list; |
50 | char *name; /* name of transport */ | 57 | char *name; /* name of transport */ |
51 | int maxsize; /* max message size of transport */ | 58 | int maxsize; /* max message size of transport */ |
59 | int pref; /* Preferences of this transport */ | ||
52 | int def; /* this transport should be default */ | 60 | int def; /* this transport should be default */ |
53 | struct module *owner; | 61 | struct module *owner; |
54 | int (*create)(struct p9_client *, const char *, char *); | 62 | int (*create)(struct p9_client *, const char *, char *); |
55 | void (*close) (struct p9_client *); | 63 | void (*close) (struct p9_client *); |
56 | int (*request) (struct p9_client *, struct p9_req_t *req); | 64 | int (*request) (struct p9_client *, struct p9_req_t *req); |
57 | int (*cancel) (struct p9_client *, struct p9_req_t *req); | 65 | int (*cancel) (struct p9_client *, struct p9_req_t *req); |
58 | int (*zc_request)(struct p9_client *, struct p9_req_t *, | ||
59 | char *, char *, int , int, int, int); | ||
60 | }; | 66 | }; |
61 | 67 | ||
62 | void v9fs_register_trans(struct p9_trans_module *m); | 68 | void v9fs_register_trans(struct p9_trans_module *m); |
diff --git a/include/net/addrconf.h b/include/net/addrconf.h index df4ef945338..cbc6bb0a683 100644 --- a/include/net/addrconf.h +++ b/include/net/addrconf.h | |||
@@ -46,8 +46,7 @@ struct prefix_info { | |||
46 | #include <net/if_inet6.h> | 46 | #include <net/if_inet6.h> |
47 | #include <net/ipv6.h> | 47 | #include <net/ipv6.h> |
48 | 48 | ||
49 | #define IN6_ADDR_HSIZE_SHIFT 4 | 49 | #define IN6_ADDR_HSIZE 16 |
50 | #define IN6_ADDR_HSIZE (1 << IN6_ADDR_HSIZE_SHIFT) | ||
51 | 50 | ||
52 | extern int addrconf_init(void); | 51 | extern int addrconf_init(void); |
53 | extern void addrconf_cleanup(void); | 52 | extern void addrconf_cleanup(void); |
@@ -78,7 +77,7 @@ extern struct inet6_ifaddr *ipv6_get_ifaddr(struct net *net, | |||
78 | int strict); | 77 | int strict); |
79 | 78 | ||
80 | extern int ipv6_dev_get_saddr(struct net *net, | 79 | extern int ipv6_dev_get_saddr(struct net *net, |
81 | const struct net_device *dev, | 80 | struct net_device *dev, |
82 | const struct in6_addr *daddr, | 81 | const struct in6_addr *daddr, |
83 | unsigned int srcprefs, | 82 | unsigned int srcprefs, |
84 | struct in6_addr *saddr); | 83 | struct in6_addr *saddr); |
@@ -93,7 +92,7 @@ extern void addrconf_leave_solict(struct inet6_dev *idev, | |||
93 | const struct in6_addr *addr); | 92 | const struct in6_addr *addr); |
94 | 93 | ||
95 | static inline unsigned long addrconf_timeout_fixup(u32 timeout, | 94 | static inline unsigned long addrconf_timeout_fixup(u32 timeout, |
96 | unsigned int unit) | 95 | unsigned unit) |
97 | { | 96 | { |
98 | if (timeout == 0xffffffff) | 97 | if (timeout == 0xffffffff) |
99 | return ~0UL; | 98 | return ~0UL; |
@@ -132,9 +131,9 @@ extern int ipv6_sock_mc_join(struct sock *sk, int ifindex, | |||
132 | extern int ipv6_sock_mc_drop(struct sock *sk, int ifindex, | 131 | extern int ipv6_sock_mc_drop(struct sock *sk, int ifindex, |
133 | const struct in6_addr *addr); | 132 | const struct in6_addr *addr); |
134 | extern void ipv6_sock_mc_close(struct sock *sk); | 133 | extern void ipv6_sock_mc_close(struct sock *sk); |
135 | extern bool inet6_mc_check(struct sock *sk, | 134 | extern int inet6_mc_check(struct sock *sk, |
136 | const struct in6_addr *mc_addr, | 135 | const struct in6_addr *mc_addr, |
137 | const struct in6_addr *src_addr); | 136 | const struct in6_addr *src_addr); |
138 | 137 | ||
139 | extern int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr); | 138 | extern int ipv6_dev_mc_inc(struct net_device *dev, const struct in6_addr *addr); |
140 | extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr); | 139 | extern int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr); |
@@ -147,13 +146,12 @@ extern void ipv6_mc_init_dev(struct inet6_dev *idev); | |||
147 | extern void ipv6_mc_destroy_dev(struct inet6_dev *idev); | 146 | extern void ipv6_mc_destroy_dev(struct inet6_dev *idev); |
148 | extern void addrconf_dad_failure(struct inet6_ifaddr *ifp); | 147 | extern void addrconf_dad_failure(struct inet6_ifaddr *ifp); |
149 | 148 | ||
150 | extern bool ipv6_chk_mcast_addr(struct net_device *dev, | 149 | extern int ipv6_chk_mcast_addr(struct net_device *dev, |
151 | const struct in6_addr *group, | 150 | const struct in6_addr *group, |
152 | const struct in6_addr *src_addr); | 151 | const struct in6_addr *src_addr); |
153 | extern bool ipv6_is_mld(struct sk_buff *skb, int nexthdr); | 152 | extern int ipv6_is_mld(struct sk_buff *skb, int nexthdr); |
154 | 153 | ||
155 | extern void addrconf_prefix_rcv(struct net_device *dev, | 154 | extern void addrconf_prefix_rcv(struct net_device *dev, u8 *opt, int len); |
156 | u8 *opt, int len, bool sllao); | ||
157 | 155 | ||
158 | /* | 156 | /* |
159 | * anycast prototypes (anycast.c) | 157 | * anycast prototypes (anycast.c) |
@@ -161,20 +159,18 @@ extern void addrconf_prefix_rcv(struct net_device *dev, | |||
161 | extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr); | 159 | extern int ipv6_sock_ac_join(struct sock *sk,int ifindex, const struct in6_addr *addr); |
162 | extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr); | 160 | extern int ipv6_sock_ac_drop(struct sock *sk,int ifindex, const struct in6_addr *addr); |
163 | extern void ipv6_sock_ac_close(struct sock *sk); | 161 | extern void ipv6_sock_ac_close(struct sock *sk); |
162 | extern int inet6_ac_check(struct sock *sk, const struct in6_addr *addr, int ifindex); | ||
164 | 163 | ||
165 | extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr); | 164 | extern int ipv6_dev_ac_inc(struct net_device *dev, const struct in6_addr *addr); |
166 | extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr); | 165 | extern int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr); |
167 | extern bool 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, |
168 | const struct in6_addr *addr); | 167 | const struct in6_addr *addr); |
169 | 168 | ||
170 | 169 | ||
171 | /* Device notifier */ | 170 | /* Device notifier */ |
172 | extern int register_inet6addr_notifier(struct notifier_block *nb); | 171 | extern int register_inet6addr_notifier(struct notifier_block *nb); |
173 | extern int unregister_inet6addr_notifier(struct notifier_block *nb); | 172 | extern int unregister_inet6addr_notifier(struct notifier_block *nb); |
174 | 173 | ||
175 | extern void inet6_netconf_notify_devconf(struct net *net, int type, int ifindex, | ||
176 | struct ipv6_devconf *devconf); | ||
177 | |||
178 | /** | 174 | /** |
179 | * __in6_dev_get - get inet6_dev pointer from netdevice | 175 | * __in6_dev_get - get inet6_dev pointer from netdevice |
180 | * @dev: network device | 176 | * @dev: network device |
diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 0a996a3517e..91ab5b01678 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h | |||
@@ -11,19 +11,15 @@ 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 | extern struct sock *unix_get_socket(struct file *filp); |
14 | extern struct sock *unix_peer_get(struct sock *); | ||
15 | 14 | ||
16 | #define UNIX_HASH_SIZE 256 | 15 | #define UNIX_HASH_SIZE 256 |
17 | #define UNIX_HASH_BITS 8 | ||
18 | 16 | ||
19 | extern unsigned int unix_tot_inflight; | 17 | extern unsigned int unix_tot_inflight; |
20 | extern spinlock_t unix_table_lock; | ||
21 | extern struct hlist_head unix_socket_table[2 * UNIX_HASH_SIZE]; | ||
22 | 18 | ||
23 | struct unix_address { | 19 | struct unix_address { |
24 | atomic_t refcnt; | 20 | atomic_t refcnt; |
25 | int len; | 21 | int len; |
26 | unsigned int hash; | 22 | unsigned hash; |
27 | struct sockaddr_un name[0]; | 23 | struct sockaddr_un name[0]; |
28 | }; | 24 | }; |
29 | 25 | ||
@@ -50,9 +46,11 @@ struct unix_sock { | |||
50 | /* WARNING: sk has to be the first member */ | 46 | /* WARNING: sk has to be the first member */ |
51 | struct sock sk; | 47 | struct sock sk; |
52 | struct unix_address *addr; | 48 | struct unix_address *addr; |
53 | struct path path; | 49 | struct dentry *dentry; |
50 | struct vfsmount *mnt; | ||
54 | struct mutex readlock; | 51 | struct mutex readlock; |
55 | struct sock *peer; | 52 | struct sock *peer; |
53 | struct sock *other; | ||
56 | struct list_head link; | 54 | struct list_head link; |
57 | atomic_long_t inflight; | 55 | atomic_long_t inflight; |
58 | spinlock_t lock; | 56 | spinlock_t lock; |
@@ -65,9 +63,6 @@ struct unix_sock { | |||
65 | 63 | ||
66 | #define peer_wait peer_wq.wait | 64 | #define peer_wait peer_wq.wait |
67 | 65 | ||
68 | long unix_inq_len(struct sock *sk); | ||
69 | long unix_outq_len(struct sock *sk); | ||
70 | |||
71 | #ifdef CONFIG_SYSCTL | 66 | #ifdef CONFIG_SYSCTL |
72 | extern int unix_sysctl_register(struct net *net); | 67 | extern int unix_sysctl_register(struct net *net); |
73 | extern void unix_sysctl_unregister(struct net *net); | 68 | extern void unix_sysctl_unregister(struct net *net); |
diff --git a/include/net/arp.h b/include/net/arp.h index b630dae0341..4979af8b155 100644 --- a/include/net/arp.h +++ b/include/net/arp.h | |||
@@ -3,7 +3,6 @@ | |||
3 | #define _ARP_H | 3 | #define _ARP_H |
4 | 4 | ||
5 | #include <linux/if_arp.h> | 5 | #include <linux/if_arp.h> |
6 | #include <linux/hash.h> | ||
7 | #include <net/neighbour.h> | 6 | #include <net/neighbour.h> |
8 | 7 | ||
9 | 8 | ||
@@ -11,36 +10,29 @@ extern struct neigh_table arp_tbl; | |||
11 | 10 | ||
12 | static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) | 11 | static inline u32 arp_hashfn(u32 key, const struct net_device *dev, u32 hash_rnd) |
13 | { | 12 | { |
14 | u32 val = key ^ hash32_ptr(dev); | 13 | u32 val = key ^ dev->ifindex; |
15 | 14 | ||
16 | return val * hash_rnd; | 15 | return val * hash_rnd; |
17 | } | 16 | } |
18 | 17 | ||
19 | static inline struct neighbour *__ipv4_neigh_lookup_noref(struct net_device *dev, u32 key) | 18 | static inline struct neighbour *__ipv4_neigh_lookup(struct neigh_table *tbl, struct net_device *dev, u32 key) |
20 | { | 19 | { |
21 | struct neigh_hash_table *nht = rcu_dereference_bh(arp_tbl.nht); | 20 | struct neigh_hash_table *nht; |
22 | struct neighbour *n; | 21 | struct neighbour *n; |
23 | u32 hash_val; | 22 | u32 hash_val; |
24 | 23 | ||
25 | hash_val = arp_hashfn(key, dev, nht->hash_rnd[0]) >> (32 - nht->hash_shift); | 24 | rcu_read_lock_bh(); |
25 | nht = rcu_dereference_bh(tbl->nht); | ||
26 | hash_val = arp_hashfn(key, dev, nht->hash_rnd) >> (32 - nht->hash_shift); | ||
26 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); | 27 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); |
27 | n != NULL; | 28 | n != NULL; |
28 | n = rcu_dereference_bh(n->next)) { | 29 | n = rcu_dereference_bh(n->next)) { |
29 | if (n->dev == dev && *(u32 *)n->primary_key == key) | 30 | if (n->dev == dev && *(u32 *)n->primary_key == key) { |
30 | return n; | 31 | if (!atomic_inc_not_zero(&n->refcnt)) |
32 | n = NULL; | ||
33 | break; | ||
34 | } | ||
31 | } | 35 | } |
32 | |||
33 | return NULL; | ||
34 | } | ||
35 | |||
36 | static inline struct neighbour *__ipv4_neigh_lookup(struct net_device *dev, u32 key) | ||
37 | { | ||
38 | struct neighbour *n; | ||
39 | |||
40 | rcu_read_lock_bh(); | ||
41 | n = __ipv4_neigh_lookup_noref(dev, key); | ||
42 | if (n && !atomic_inc_not_zero(&n->refcnt)) | ||
43 | n = NULL; | ||
44 | rcu_read_unlock_bh(); | 36 | rcu_read_unlock_bh(); |
45 | 37 | ||
46 | return n; | 38 | return n; |
diff --git a/include/net/atmclip.h b/include/net/atmclip.h index 5865924d4aa..497ef6444a7 100644 --- a/include/net/atmclip.h +++ b/include/net/atmclip.h | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | 16 | ||
17 | #define CLIP_VCC(vcc) ((struct clip_vcc *) ((vcc)->user_back)) | 17 | #define CLIP_VCC(vcc) ((struct clip_vcc *) ((vcc)->user_back)) |
18 | #define NEIGH2ENTRY(neigh) ((struct atmarp_entry *) (neigh)->primary_key) | ||
18 | 19 | ||
19 | struct sk_buff; | 20 | struct sk_buff; |
20 | 21 | ||
@@ -35,18 +36,24 @@ struct clip_vcc { | |||
35 | 36 | ||
36 | 37 | ||
37 | struct atmarp_entry { | 38 | struct atmarp_entry { |
39 | __be32 ip; /* IP address */ | ||
38 | struct clip_vcc *vccs; /* active VCCs; NULL if resolution is | 40 | struct clip_vcc *vccs; /* active VCCs; NULL if resolution is |
39 | pending */ | 41 | pending */ |
40 | unsigned long expires; /* entry expiration time */ | 42 | unsigned long expires; /* entry expiration time */ |
41 | struct neighbour *neigh; /* neighbour back-pointer */ | 43 | struct neighbour *neigh; /* neighbour back-pointer */ |
42 | }; | 44 | }; |
43 | 45 | ||
46 | |||
44 | #define PRIV(dev) ((struct clip_priv *) netdev_priv(dev)) | 47 | #define PRIV(dev) ((struct clip_priv *) netdev_priv(dev)) |
45 | 48 | ||
49 | |||
46 | struct clip_priv { | 50 | struct clip_priv { |
47 | int number; /* for convenience ... */ | 51 | int number; /* for convenience ... */ |
48 | spinlock_t xoff_lock; /* ensures that pop is atomic (SMP) */ | 52 | spinlock_t xoff_lock; /* ensures that pop is atomic (SMP) */ |
49 | struct net_device *next; /* next CLIP interface */ | 53 | struct net_device *next; /* next CLIP interface */ |
50 | }; | 54 | }; |
51 | 55 | ||
56 | |||
57 | extern struct neigh_table *clip_tbl_hook; | ||
58 | |||
52 | #endif | 59 | #endif |
diff --git a/include/net/ax25.h b/include/net/ax25.h index 53539acbd81..94e09d361bb 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h | |||
@@ -157,7 +157,7 @@ enum { | |||
157 | typedef struct ax25_uid_assoc { | 157 | typedef struct ax25_uid_assoc { |
158 | struct hlist_node uid_node; | 158 | struct hlist_node uid_node; |
159 | atomic_t refcount; | 159 | atomic_t refcount; |
160 | kuid_t uid; | 160 | uid_t uid; |
161 | ax25_address call; | 161 | ax25_address call; |
162 | } ax25_uid_assoc; | 162 | } ax25_uid_assoc; |
163 | 163 | ||
@@ -215,7 +215,7 @@ typedef struct ax25_dev { | |||
215 | struct ax25_dev *next; | 215 | struct ax25_dev *next; |
216 | struct net_device *dev; | 216 | struct net_device *dev; |
217 | struct net_device *forward; | 217 | struct net_device *forward; |
218 | struct ctl_table_header *sysheader; | 218 | struct ctl_table *systable; |
219 | int values[AX25_MAX_VALUES]; | 219 | int values[AX25_MAX_VALUES]; |
220 | #if defined(CONFIG_AX25_DAMA_SLAVE) || defined(CONFIG_AX25_DAMA_MASTER) | 220 | #if defined(CONFIG_AX25_DAMA_SLAVE) || defined(CONFIG_AX25_DAMA_MASTER) |
221 | ax25_dama_info dama; | 221 | ax25_dama_info dama; |
@@ -434,18 +434,18 @@ extern unsigned long ax25_display_timer(struct timer_list *); | |||
434 | 434 | ||
435 | /* ax25_uid.c */ | 435 | /* ax25_uid.c */ |
436 | extern int ax25_uid_policy; | 436 | extern int ax25_uid_policy; |
437 | extern ax25_uid_assoc *ax25_findbyuid(kuid_t); | 437 | extern ax25_uid_assoc *ax25_findbyuid(uid_t); |
438 | extern int __must_check ax25_uid_ioctl(int, struct sockaddr_ax25 *); | 438 | extern int __must_check ax25_uid_ioctl(int, struct sockaddr_ax25 *); |
439 | extern const struct file_operations ax25_uid_fops; | 439 | extern const struct file_operations ax25_uid_fops; |
440 | extern void ax25_uid_free(void); | 440 | extern void ax25_uid_free(void); |
441 | 441 | ||
442 | /* sysctl_net_ax25.c */ | 442 | /* sysctl_net_ax25.c */ |
443 | #ifdef CONFIG_SYSCTL | 443 | #ifdef CONFIG_SYSCTL |
444 | extern int ax25_register_dev_sysctl(ax25_dev *ax25_dev); | 444 | extern void ax25_register_sysctl(void); |
445 | extern void ax25_unregister_dev_sysctl(ax25_dev *ax25_dev); | 445 | extern void ax25_unregister_sysctl(void); |
446 | #else | 446 | #else |
447 | static inline int ax25_register_dev_sysctl(ax25_dev *ax25_dev) { return 0; } | 447 | static inline void ax25_register_sysctl(void) {}; |
448 | static inline void ax25_unregister_dev_sysctl(ax25_dev *ax25_dev) {} | 448 | static inline void ax25_unregister_sysctl(void) {}; |
449 | #endif /* CONFIG_SYSCTL */ | 449 | #endif /* CONFIG_SYSCTL */ |
450 | 450 | ||
451 | #endif | 451 | #endif |
diff --git a/include/net/bluetooth/a2mp.h b/include/net/bluetooth/a2mp.h deleted file mode 100644 index 42f21766c53..00000000000 --- a/include/net/bluetooth/a2mp.h +++ /dev/null | |||
@@ -1,148 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2010,2011 Code Aurora Forum. All rights reserved. | ||
3 | Copyright (c) 2011,2012 Intel Corp. | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License version 2 and | ||
7 | only version 2 as published by the Free Software Foundation. | ||
8 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #ifndef __A2MP_H | ||
16 | #define __A2MP_H | ||
17 | |||
18 | #include <net/bluetooth/l2cap.h> | ||
19 | |||
20 | #define A2MP_FEAT_EXT 0x8000 | ||
21 | |||
22 | enum amp_mgr_state { | ||
23 | READ_LOC_AMP_INFO, | ||
24 | READ_LOC_AMP_ASSOC, | ||
25 | READ_LOC_AMP_ASSOC_FINAL, | ||
26 | }; | ||
27 | |||
28 | struct amp_mgr { | ||
29 | struct list_head list; | ||
30 | struct l2cap_conn *l2cap_conn; | ||
31 | struct l2cap_chan *a2mp_chan; | ||
32 | struct l2cap_chan *bredr_chan; | ||
33 | struct kref kref; | ||
34 | __u8 ident; | ||
35 | __u8 handle; | ||
36 | enum amp_mgr_state state; | ||
37 | unsigned long flags; | ||
38 | |||
39 | struct list_head amp_ctrls; | ||
40 | struct mutex amp_ctrls_lock; | ||
41 | }; | ||
42 | |||
43 | struct a2mp_cmd { | ||
44 | __u8 code; | ||
45 | __u8 ident; | ||
46 | __le16 len; | ||
47 | __u8 data[0]; | ||
48 | } __packed; | ||
49 | |||
50 | /* A2MP command codes */ | ||
51 | #define A2MP_COMMAND_REJ 0x01 | ||
52 | struct a2mp_cmd_rej { | ||
53 | __le16 reason; | ||
54 | __u8 data[0]; | ||
55 | } __packed; | ||
56 | |||
57 | #define A2MP_DISCOVER_REQ 0x02 | ||
58 | struct a2mp_discov_req { | ||
59 | __le16 mtu; | ||
60 | __le16 ext_feat; | ||
61 | } __packed; | ||
62 | |||
63 | struct a2mp_cl { | ||
64 | __u8 id; | ||
65 | __u8 type; | ||
66 | __u8 status; | ||
67 | } __packed; | ||
68 | |||
69 | #define A2MP_DISCOVER_RSP 0x03 | ||
70 | struct a2mp_discov_rsp { | ||
71 | __le16 mtu; | ||
72 | __le16 ext_feat; | ||
73 | struct a2mp_cl cl[0]; | ||
74 | } __packed; | ||
75 | |||
76 | #define A2MP_CHANGE_NOTIFY 0x04 | ||
77 | #define A2MP_CHANGE_RSP 0x05 | ||
78 | |||
79 | #define A2MP_GETINFO_REQ 0x06 | ||
80 | struct a2mp_info_req { | ||
81 | __u8 id; | ||
82 | } __packed; | ||
83 | |||
84 | #define A2MP_GETINFO_RSP 0x07 | ||
85 | struct a2mp_info_rsp { | ||
86 | __u8 id; | ||
87 | __u8 status; | ||
88 | __le32 total_bw; | ||
89 | __le32 max_bw; | ||
90 | __le32 min_latency; | ||
91 | __le16 pal_cap; | ||
92 | __le16 assoc_size; | ||
93 | } __packed; | ||
94 | |||
95 | #define A2MP_GETAMPASSOC_REQ 0x08 | ||
96 | struct a2mp_amp_assoc_req { | ||
97 | __u8 id; | ||
98 | } __packed; | ||
99 | |||
100 | #define A2MP_GETAMPASSOC_RSP 0x09 | ||
101 | struct a2mp_amp_assoc_rsp { | ||
102 | __u8 id; | ||
103 | __u8 status; | ||
104 | __u8 amp_assoc[0]; | ||
105 | } __packed; | ||
106 | |||
107 | #define A2MP_CREATEPHYSLINK_REQ 0x0A | ||
108 | #define A2MP_DISCONNPHYSLINK_REQ 0x0C | ||
109 | struct a2mp_physlink_req { | ||
110 | __u8 local_id; | ||
111 | __u8 remote_id; | ||
112 | __u8 amp_assoc[0]; | ||
113 | } __packed; | ||
114 | |||
115 | #define A2MP_CREATEPHYSLINK_RSP 0x0B | ||
116 | #define A2MP_DISCONNPHYSLINK_RSP 0x0D | ||
117 | struct a2mp_physlink_rsp { | ||
118 | __u8 local_id; | ||
119 | __u8 remote_id; | ||
120 | __u8 status; | ||
121 | } __packed; | ||
122 | |||
123 | /* A2MP response status */ | ||
124 | #define A2MP_STATUS_SUCCESS 0x00 | ||
125 | #define A2MP_STATUS_INVALID_CTRL_ID 0x01 | ||
126 | #define A2MP_STATUS_UNABLE_START_LINK_CREATION 0x02 | ||
127 | #define A2MP_STATUS_NO_PHYSICAL_LINK_EXISTS 0x02 | ||
128 | #define A2MP_STATUS_COLLISION_OCCURED 0x03 | ||
129 | #define A2MP_STATUS_DISCONN_REQ_RECVD 0x04 | ||
130 | #define A2MP_STATUS_PHYS_LINK_EXISTS 0x05 | ||
131 | #define A2MP_STATUS_SECURITY_VIOLATION 0x06 | ||
132 | |||
133 | extern struct list_head amp_mgr_list; | ||
134 | extern struct mutex amp_mgr_list_lock; | ||
135 | |||
136 | struct amp_mgr *amp_mgr_get(struct amp_mgr *mgr); | ||
137 | int amp_mgr_put(struct amp_mgr *mgr); | ||
138 | u8 __next_ident(struct amp_mgr *mgr); | ||
139 | struct l2cap_chan *a2mp_channel_create(struct l2cap_conn *conn, | ||
140 | struct sk_buff *skb); | ||
141 | struct amp_mgr *amp_mgr_lookup_by_state(u8 state); | ||
142 | void a2mp_send(struct amp_mgr *mgr, u8 code, u8 ident, u16 len, void *data); | ||
143 | void a2mp_discover_amp(struct l2cap_chan *chan); | ||
144 | void a2mp_send_getinfo_rsp(struct hci_dev *hdev); | ||
145 | void a2mp_send_getampassoc_rsp(struct hci_dev *hdev, u8 status); | ||
146 | void a2mp_send_create_phy_link_req(struct hci_dev *hdev, u8 status); | ||
147 | |||
148 | #endif /* __A2MP_H */ | ||
diff --git a/include/net/bluetooth/amp.h b/include/net/bluetooth/amp.h deleted file mode 100644 index 7ea3db77ba8..00000000000 --- a/include/net/bluetooth/amp.h +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (c) 2011,2012 Intel Corp. | ||
3 | |||
4 | This program is free software; you can redistribute it and/or modify | ||
5 | it under the terms of the GNU General Public License version 2 and | ||
6 | only version 2 as published by the Free Software Foundation. | ||
7 | |||
8 | This program is distributed in the hope that it will be useful, | ||
9 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
10 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #ifndef __AMP_H | ||
15 | #define __AMP_H | ||
16 | |||
17 | struct amp_ctrl { | ||
18 | struct list_head list; | ||
19 | struct kref kref; | ||
20 | __u8 id; | ||
21 | __u16 assoc_len_so_far; | ||
22 | __u16 assoc_rem_len; | ||
23 | __u16 assoc_len; | ||
24 | __u8 *assoc; | ||
25 | }; | ||
26 | |||
27 | int amp_ctrl_put(struct amp_ctrl *ctrl); | ||
28 | void amp_ctrl_get(struct amp_ctrl *ctrl); | ||
29 | struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr, u8 id); | ||
30 | struct amp_ctrl *amp_ctrl_lookup(struct amp_mgr *mgr, u8 id); | ||
31 | void amp_ctrl_list_flush(struct amp_mgr *mgr); | ||
32 | |||
33 | struct hci_conn *phylink_add(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
34 | u8 remote_id, bool out); | ||
35 | |||
36 | int phylink_gen_key(struct hci_conn *hcon, u8 *data, u8 *len, u8 *type); | ||
37 | |||
38 | void amp_read_loc_info(struct hci_dev *hdev, struct amp_mgr *mgr); | ||
39 | void amp_read_loc_assoc_frag(struct hci_dev *hdev, u8 phy_handle); | ||
40 | void amp_read_loc_assoc(struct hci_dev *hdev, struct amp_mgr *mgr); | ||
41 | void amp_read_loc_assoc_final_data(struct hci_dev *hdev, | ||
42 | struct hci_conn *hcon); | ||
43 | void amp_create_phylink(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
44 | struct hci_conn *hcon); | ||
45 | void amp_accept_phylink(struct hci_dev *hdev, struct amp_mgr *mgr, | ||
46 | struct hci_conn *hcon); | ||
47 | void amp_write_remote_assoc(struct hci_dev *hdev, u8 handle); | ||
48 | void amp_write_rem_assoc_continue(struct hci_dev *hdev, u8 handle); | ||
49 | void amp_physical_cfm(struct hci_conn *bredr_hcon, struct hci_conn *hs_hcon); | ||
50 | void amp_create_logical_link(struct l2cap_chan *chan); | ||
51 | void amp_disconnect_logical_link(struct hci_chan *hchan); | ||
52 | void amp_destroy_logical_link(struct hci_chan *hchan, u8 reason); | ||
53 | |||
54 | #endif /* __AMP_H */ | ||
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 2554b3f5222..e727555d4ee 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.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,33 +12,30 @@ | |||
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 | ||
25 | #ifndef __BLUETOOTH_H | 25 | #ifndef __BLUETOOTH_H |
26 | #define __BLUETOOTH_H | 26 | #define __BLUETOOTH_H |
27 | 27 | ||
28 | #include <asm/types.h> | ||
29 | #include <asm/byteorder.h> | ||
30 | #include <linux/list.h> | ||
28 | #include <linux/poll.h> | 31 | #include <linux/poll.h> |
29 | #include <net/sock.h> | 32 | #include <net/sock.h> |
30 | #include <linux/seq_file.h> | ||
31 | 33 | ||
32 | #ifndef AF_BLUETOOTH | 34 | #ifndef AF_BLUETOOTH |
33 | #define AF_BLUETOOTH 31 | 35 | #define AF_BLUETOOTH 31 |
34 | #define PF_BLUETOOTH AF_BLUETOOTH | 36 | #define PF_BLUETOOTH AF_BLUETOOTH |
35 | #endif | 37 | #endif |
36 | 38 | ||
37 | /* Bluetooth versions */ | ||
38 | #define BLUETOOTH_VER_1_1 1 | ||
39 | #define BLUETOOTH_VER_1_2 2 | ||
40 | #define BLUETOOTH_VER_2_0 3 | ||
41 | |||
42 | /* Reserv for core and drivers use */ | 39 | /* Reserv for core and drivers use */ |
43 | #define BT_SKB_RESERVE 8 | 40 | #define BT_SKB_RESERVE 8 |
44 | 41 | ||
@@ -80,41 +77,12 @@ struct bt_power { | |||
80 | #define BT_POWER_FORCE_ACTIVE_OFF 0 | 77 | #define BT_POWER_FORCE_ACTIVE_OFF 0 |
81 | #define BT_POWER_FORCE_ACTIVE_ON 1 | 78 | #define BT_POWER_FORCE_ACTIVE_ON 1 |
82 | 79 | ||
83 | #define BT_CHANNEL_POLICY 10 | 80 | __attribute__((format (printf, 2, 3))) |
84 | 81 | int bt_printk(const char *level, const char *fmt, ...); | |
85 | /* BR/EDR only (default policy) | 82 | |
86 | * AMP controllers cannot be used. | 83 | #define BT_INFO(fmt, arg...) bt_printk(KERN_INFO, pr_fmt(fmt), ##arg) |
87 | * Channel move requests from the remote device are denied. | 84 | #define BT_ERR(fmt, arg...) bt_printk(KERN_ERR, pr_fmt(fmt), ##arg) |
88 | * If the L2CAP channel is currently using AMP, move the channel to BR/EDR. | 85 | #define BT_DBG(fmt, arg...) pr_debug(fmt "\n", ##arg) |
89 | */ | ||
90 | #define BT_CHANNEL_POLICY_BREDR_ONLY 0 | ||
91 | |||
92 | /* BR/EDR Preferred | ||
93 | * Allow use of AMP controllers. | ||
94 | * If the L2CAP channel is currently on AMP, move it to BR/EDR. | ||
95 | * Channel move requests from the remote device are allowed. | ||
96 | */ | ||
97 | #define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 | ||
98 | |||
99 | /* AMP Preferred | ||
100 | * Allow use of AMP controllers | ||
101 | * If the L2CAP channel is currently on BR/EDR and AMP controller | ||
102 | * resources are available, initiate a channel move to AMP. | ||
103 | * Channel move requests from the remote device are allowed. | ||
104 | * If the L2CAP socket has not been connected yet, try to create | ||
105 | * and configure the channel directly on an AMP controller rather | ||
106 | * than BR/EDR. | ||
107 | */ | ||
108 | #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 | ||
109 | |||
110 | __printf(1, 2) | ||
111 | int bt_info(const char *fmt, ...); | ||
112 | __printf(1, 2) | ||
113 | int bt_err(const char *fmt, ...); | ||
114 | |||
115 | #define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) | ||
116 | #define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) | ||
117 | #define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) | ||
118 | 86 | ||
119 | /* Connection and socket states */ | 87 | /* Connection and socket states */ |
120 | enum { | 88 | enum { |
@@ -129,45 +97,13 @@ enum { | |||
129 | BT_CLOSED | 97 | BT_CLOSED |
130 | }; | 98 | }; |
131 | 99 | ||
132 | /* If unused will be removed by compiler */ | ||
133 | static inline const char *state_to_string(int state) | ||
134 | { | ||
135 | switch (state) { | ||
136 | case BT_CONNECTED: | ||
137 | return "BT_CONNECTED"; | ||
138 | case BT_OPEN: | ||
139 | return "BT_OPEN"; | ||
140 | case BT_BOUND: | ||
141 | return "BT_BOUND"; | ||
142 | case BT_LISTEN: | ||
143 | return "BT_LISTEN"; | ||
144 | case BT_CONNECT: | ||
145 | return "BT_CONNECT"; | ||
146 | case BT_CONNECT2: | ||
147 | return "BT_CONNECT2"; | ||
148 | case BT_CONFIG: | ||
149 | return "BT_CONFIG"; | ||
150 | case BT_DISCONN: | ||
151 | return "BT_DISCONN"; | ||
152 | case BT_CLOSED: | ||
153 | return "BT_CLOSED"; | ||
154 | } | ||
155 | |||
156 | return "invalid state"; | ||
157 | } | ||
158 | |||
159 | /* BD Address */ | 100 | /* BD Address */ |
160 | typedef struct { | 101 | typedef struct { |
161 | __u8 b[6]; | 102 | __u8 b[6]; |
162 | } __packed bdaddr_t; | 103 | } __packed bdaddr_t; |
163 | 104 | ||
164 | /* BD Address type */ | 105 | #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0}}) |
165 | #define BDADDR_BREDR 0x00 | 106 | #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff}}) |
166 | #define BDADDR_LE_PUBLIC 0x01 | ||
167 | #define BDADDR_LE_RANDOM 0x02 | ||
168 | |||
169 | #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0} }) | ||
170 | #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} }) | ||
171 | 107 | ||
172 | /* Copy, swap, convert BD Address */ | 108 | /* Copy, swap, convert BD Address */ |
173 | static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) | 109 | static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) |
@@ -180,6 +116,8 @@ static inline void bacpy(bdaddr_t *dst, bdaddr_t *src) | |||
180 | } | 116 | } |
181 | 117 | ||
182 | void baswap(bdaddr_t *dst, bdaddr_t *src); | 118 | void baswap(bdaddr_t *dst, bdaddr_t *src); |
119 | char *batostr(bdaddr_t *ba); | ||
120 | bdaddr_t *strtoba(char *str); | ||
183 | 121 | ||
184 | /* Common socket structures and functions */ | 122 | /* Common socket structures and functions */ |
185 | 123 | ||
@@ -191,21 +129,12 @@ struct bt_sock { | |||
191 | bdaddr_t dst; | 129 | bdaddr_t dst; |
192 | struct list_head accept_q; | 130 | struct list_head accept_q; |
193 | struct sock *parent; | 131 | struct sock *parent; |
194 | unsigned long flags; | 132 | u32 defer_setup; |
195 | }; | ||
196 | |||
197 | enum { | ||
198 | BT_SK_DEFER_SETUP, | ||
199 | BT_SK_SUSPEND, | ||
200 | }; | 133 | }; |
201 | 134 | ||
202 | struct bt_sock_list { | 135 | struct bt_sock_list { |
203 | struct hlist_head head; | 136 | struct hlist_head head; |
204 | rwlock_t lock; | 137 | rwlock_t lock; |
205 | #ifdef CONFIG_PROC_FS | ||
206 | struct file_operations fops; | ||
207 | int (* custom_seq_show)(struct seq_file *, void *); | ||
208 | #endif | ||
209 | }; | 138 | }; |
210 | 139 | ||
211 | int bt_sock_register(int proto, const struct net_proto_family *ops); | 140 | int bt_sock_register(int proto, const struct net_proto_family *ops); |
@@ -216,7 +145,7 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
216 | struct msghdr *msg, size_t len, int flags); | 145 | struct msghdr *msg, size_t len, int flags); |
217 | int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, | 146 | int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, |
218 | struct msghdr *msg, size_t len, int flags); | 147 | struct msghdr *msg, size_t len, int flags); |
219 | uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait); | 148 | uint bt_sock_poll(struct file * file, struct socket *sock, poll_table *wait); |
220 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); | 149 | int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); |
221 | int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); | 150 | int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); |
222 | 151 | ||
@@ -225,24 +154,15 @@ void bt_accept_unlink(struct sock *sk); | |||
225 | struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock); | 154 | struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock); |
226 | 155 | ||
227 | /* Skb helpers */ | 156 | /* Skb helpers */ |
228 | struct l2cap_ctrl { | ||
229 | unsigned int sframe:1, | ||
230 | poll:1, | ||
231 | final:1, | ||
232 | fcs:1, | ||
233 | sar:2, | ||
234 | super:2; | ||
235 | __u16 reqseq; | ||
236 | __u16 txseq; | ||
237 | __u8 retries; | ||
238 | }; | ||
239 | |||
240 | struct bt_skb_cb { | 157 | struct bt_skb_cb { |
241 | __u8 pkt_type; | 158 | __u8 pkt_type; |
242 | __u8 incoming; | 159 | __u8 incoming; |
243 | __u16 expect; | 160 | __u16 expect; |
161 | __u8 tx_seq; | ||
162 | __u8 retries; | ||
163 | __u8 sar; | ||
164 | unsigned short channel; | ||
244 | __u8 force_active; | 165 | __u8 force_active; |
245 | struct l2cap_ctrl control; | ||
246 | }; | 166 | }; |
247 | #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) | 167 | #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) |
248 | 168 | ||
@@ -250,8 +170,7 @@ static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how) | |||
250 | { | 170 | { |
251 | struct sk_buff *skb; | 171 | struct sk_buff *skb; |
252 | 172 | ||
253 | skb = alloc_skb(len + BT_SKB_RESERVE, how); | 173 | if ((skb = alloc_skb(len + BT_SKB_RESERVE, how))) { |
254 | if (skb) { | ||
255 | skb_reserve(skb, BT_SKB_RESERVE); | 174 | skb_reserve(skb, BT_SKB_RESERVE); |
256 | bt_cb(skb)->incoming = 0; | 175 | bt_cb(skb)->incoming = 0; |
257 | } | 176 | } |
@@ -263,11 +182,12 @@ static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, | |||
263 | { | 182 | { |
264 | struct sk_buff *skb; | 183 | struct sk_buff *skb; |
265 | 184 | ||
266 | skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err); | 185 | release_sock(sk); |
267 | if (skb) { | 186 | if ((skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err))) { |
268 | skb_reserve(skb, BT_SKB_RESERVE); | 187 | skb_reserve(skb, BT_SKB_RESERVE); |
269 | bt_cb(skb)->incoming = 0; | 188 | bt_cb(skb)->incoming = 0; |
270 | } | 189 | } |
190 | lock_sock(sk); | ||
271 | 191 | ||
272 | if (!skb && *err) | 192 | if (!skb && *err) |
273 | return NULL; | 193 | return NULL; |
@@ -296,19 +216,34 @@ extern void hci_sock_cleanup(void); | |||
296 | extern int bt_sysfs_init(void); | 216 | extern int bt_sysfs_init(void); |
297 | extern void bt_sysfs_cleanup(void); | 217 | extern void bt_sysfs_cleanup(void); |
298 | 218 | ||
299 | extern int bt_procfs_init(struct module* module, struct net *net, const char *name, | ||
300 | struct bt_sock_list* sk_list, | ||
301 | int (* seq_show)(struct seq_file *, void *)); | ||
302 | extern void bt_procfs_cleanup(struct net *net, const char *name); | ||
303 | |||
304 | extern struct dentry *bt_debugfs; | 219 | extern struct dentry *bt_debugfs; |
305 | 220 | ||
221 | #ifdef CONFIG_BT_L2CAP | ||
306 | int l2cap_init(void); | 222 | int l2cap_init(void); |
307 | void l2cap_exit(void); | 223 | void l2cap_exit(void); |
224 | #else | ||
225 | static inline int l2cap_init(void) | ||
226 | { | ||
227 | return 0; | ||
228 | } | ||
308 | 229 | ||
230 | static inline void l2cap_exit(void) | ||
231 | { | ||
232 | } | ||
233 | #endif | ||
234 | |||
235 | #ifdef CONFIG_BT_SCO | ||
309 | int sco_init(void); | 236 | int sco_init(void); |
310 | void sco_exit(void); | 237 | void sco_exit(void); |
238 | #else | ||
239 | static inline int sco_init(void) | ||
240 | { | ||
241 | return 0; | ||
242 | } | ||
311 | 243 | ||
312 | void bt_sock_reclassify_lock(struct sock *sk, int proto); | 244 | static inline void sco_exit(void) |
245 | { | ||
246 | } | ||
247 | #endif | ||
313 | 248 | ||
314 | #endif /* __BLUETOOTH_H */ | 249 | #endif /* __BLUETOOTH_H */ |
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 45eee08157b..915d7ae527b 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -30,11 +30,6 @@ | |||
30 | #define HCI_MAX_EVENT_SIZE 260 | 30 | #define HCI_MAX_EVENT_SIZE 260 |
31 | #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) | 31 | #define HCI_MAX_FRAME_SIZE (HCI_MAX_ACL_SIZE + 4) |
32 | 32 | ||
33 | #define HCI_LINK_KEY_SIZE 16 | ||
34 | #define HCI_AMP_LINK_KEY_SIZE (2 * HCI_LINK_KEY_SIZE) | ||
35 | |||
36 | #define HCI_MAX_AMP_ASSOC_SIZE 672 | ||
37 | |||
38 | /* HCI dev events */ | 33 | /* HCI dev events */ |
39 | #define HCI_DEV_REG 1 | 34 | #define HCI_DEV_REG 1 |
40 | #define HCI_DEV_UNREG 2 | 35 | #define HCI_DEV_UNREG 2 |
@@ -42,6 +37,7 @@ | |||
42 | #define HCI_DEV_DOWN 4 | 37 | #define HCI_DEV_DOWN 4 |
43 | #define HCI_DEV_SUSPEND 5 | 38 | #define HCI_DEV_SUSPEND 5 |
44 | #define HCI_DEV_RESUME 6 | 39 | #define HCI_DEV_RESUME 6 |
40 | #define HCI_DEV_WRITE 7 | ||
45 | 41 | ||
46 | /* HCI notify events */ | 42 | /* HCI notify events */ |
47 | #define HCI_NOTIFY_CONN_ADD 1 | 43 | #define HCI_NOTIFY_CONN_ADD 1 |
@@ -61,21 +57,9 @@ | |||
61 | #define HCI_BREDR 0x00 | 57 | #define HCI_BREDR 0x00 |
62 | #define HCI_AMP 0x01 | 58 | #define HCI_AMP 0x01 |
63 | 59 | ||
64 | /* First BR/EDR Controller shall have ID = 0 */ | ||
65 | #define HCI_BREDR_ID 0 | ||
66 | |||
67 | /* AMP controller status */ | ||
68 | #define AMP_CTRL_POWERED_DOWN 0x00 | ||
69 | #define AMP_CTRL_BLUETOOTH_ONLY 0x01 | ||
70 | #define AMP_CTRL_NO_CAPACITY 0x02 | ||
71 | #define AMP_CTRL_LOW_CAPACITY 0x03 | ||
72 | #define AMP_CTRL_MEDIUM_CAPACITY 0x04 | ||
73 | #define AMP_CTRL_HIGH_CAPACITY 0x05 | ||
74 | #define AMP_CTRL_FULL_CAPACITY 0x06 | ||
75 | |||
76 | /* HCI device quirks */ | 60 | /* HCI device quirks */ |
77 | enum { | 61 | enum { |
78 | HCI_QUIRK_RESET_ON_CLOSE, | 62 | HCI_QUIRK_NO_RESET, |
79 | HCI_QUIRK_RAW_DEVICE, | 63 | HCI_QUIRK_RAW_DEVICE, |
80 | HCI_QUIRK_FIXUP_BUFFER_SIZE | 64 | HCI_QUIRK_FIXUP_BUFFER_SIZE |
81 | }; | 65 | }; |
@@ -94,14 +78,6 @@ enum { | |||
94 | 78 | ||
95 | HCI_RAW, | 79 | HCI_RAW, |
96 | 80 | ||
97 | HCI_RESET, | ||
98 | }; | ||
99 | |||
100 | /* | ||
101 | * BR/EDR and/or LE controller flags: the flags defined here should represent | ||
102 | * states from the controller. | ||
103 | */ | ||
104 | enum { | ||
105 | HCI_SETUP, | 81 | HCI_SETUP, |
106 | HCI_AUTO_OFF, | 82 | HCI_AUTO_OFF, |
107 | HCI_MGMT, | 83 | HCI_MGMT, |
@@ -109,18 +85,8 @@ enum { | |||
109 | HCI_SERVICE_CACHE, | 85 | HCI_SERVICE_CACHE, |
110 | HCI_LINK_KEYS, | 86 | HCI_LINK_KEYS, |
111 | HCI_DEBUG_KEYS, | 87 | HCI_DEBUG_KEYS, |
112 | HCI_UNREGISTER, | 88 | |
113 | 89 | HCI_RESET, | |
114 | HCI_LE_SCAN, | ||
115 | HCI_SSP_ENABLED, | ||
116 | HCI_HS_ENABLED, | ||
117 | HCI_LE_ENABLED, | ||
118 | HCI_LE_PERIPHERAL, | ||
119 | HCI_CONNECTABLE, | ||
120 | HCI_DISCOVERABLE, | ||
121 | HCI_LINK_SECURITY, | ||
122 | HCI_PENDING_CLASS, | ||
123 | HCI_PERIODIC_INQ, | ||
124 | }; | 90 | }; |
125 | 91 | ||
126 | /* HCI ioctl defines */ | 92 | /* HCI ioctl defines */ |
@@ -151,12 +117,12 @@ enum { | |||
151 | #define HCIINQUIRY _IOR('H', 240, int) | 117 | #define HCIINQUIRY _IOR('H', 240, int) |
152 | 118 | ||
153 | /* HCI timeouts */ | 119 | /* HCI timeouts */ |
154 | #define HCI_DISCONN_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ | 120 | #define HCI_CONNECT_TIMEOUT (40000) /* 40 seconds */ |
155 | #define HCI_PAIRING_TIMEOUT msecs_to_jiffies(60000) /* 60 seconds */ | 121 | #define HCI_DISCONN_TIMEOUT (2000) /* 2 seconds */ |
156 | #define HCI_INIT_TIMEOUT msecs_to_jiffies(10000) /* 10 seconds */ | 122 | #define HCI_PAIRING_TIMEOUT (60000) /* 60 seconds */ |
157 | #define HCI_CMD_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ | 123 | #define HCI_IDLE_TIMEOUT (6000) /* 6 seconds */ |
158 | #define HCI_ACL_TX_TIMEOUT msecs_to_jiffies(45000) /* 45 seconds */ | 124 | #define HCI_INIT_TIMEOUT (10000) /* 10 seconds */ |
159 | #define HCI_AUTO_OFF_TIMEOUT msecs_to_jiffies(2000) /* 2 seconds */ | 125 | #define HCI_CMD_TIMEOUT (1000) /* 1 seconds */ |
160 | 126 | ||
161 | /* HCI data types */ | 127 | /* HCI data types */ |
162 | #define HCI_COMMAND_PKT 0x01 | 128 | #define HCI_COMMAND_PKT 0x01 |
@@ -192,14 +158,15 @@ enum { | |||
192 | #define ESCO_2EV5 0x0100 | 158 | #define ESCO_2EV5 0x0100 |
193 | #define ESCO_3EV5 0x0200 | 159 | #define ESCO_3EV5 0x0200 |
194 | 160 | ||
195 | #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3) | 161 | #define SCO_ESCO_MASK (ESCO_HV1 | ESCO_HV2 | ESCO_HV3) |
196 | #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) | 162 | #define EDR_ESCO_MASK (ESCO_2EV3 | ESCO_3EV3 | ESCO_2EV5 | ESCO_3EV5) |
163 | #define ALL_ESCO_MASK (SCO_ESCO_MASK | ESCO_EV3 | ESCO_EV4 | ESCO_EV5 | \ | ||
164 | EDR_ESCO_MASK) | ||
197 | 165 | ||
198 | /* ACL flags */ | 166 | /* ACL flags */ |
199 | #define ACL_START_NO_FLUSH 0x00 | 167 | #define ACL_START_NO_FLUSH 0x00 |
200 | #define ACL_CONT 0x01 | 168 | #define ACL_CONT 0x01 |
201 | #define ACL_START 0x02 | 169 | #define ACL_START 0x02 |
202 | #define ACL_COMPLETE 0x03 | ||
203 | #define ACL_ACTIVE_BCAST 0x04 | 170 | #define ACL_ACTIVE_BCAST 0x04 |
204 | #define ACL_PICO_BCAST 0x08 | 171 | #define ACL_PICO_BCAST 0x08 |
205 | 172 | ||
@@ -209,7 +176,6 @@ enum { | |||
209 | #define ESCO_LINK 0x02 | 176 | #define ESCO_LINK 0x02 |
210 | /* Low Energy links do not have defined link type. Use invented one */ | 177 | /* Low Energy links do not have defined link type. Use invented one */ |
211 | #define LE_LINK 0x80 | 178 | #define LE_LINK 0x80 |
212 | #define AMP_LINK 0x81 | ||
213 | 179 | ||
214 | /* LMP features */ | 180 | /* LMP features */ |
215 | #define LMP_3SLOT 0x01 | 181 | #define LMP_3SLOT 0x01 |
@@ -239,7 +205,6 @@ enum { | |||
239 | 205 | ||
240 | #define LMP_EV4 0x01 | 206 | #define LMP_EV4 0x01 |
241 | #define LMP_EV5 0x02 | 207 | #define LMP_EV5 0x02 |
242 | #define LMP_NO_BREDR 0x20 | ||
243 | #define LMP_LE 0x40 | 208 | #define LMP_LE 0x40 |
244 | 209 | ||
245 | #define LMP_SNIFF_SUBR 0x02 | 210 | #define LMP_SNIFF_SUBR 0x02 |
@@ -258,9 +223,7 @@ enum { | |||
258 | #define LMP_EXTFEATURES 0x80 | 223 | #define LMP_EXTFEATURES 0x80 |
259 | 224 | ||
260 | /* Extended LMP features */ | 225 | /* Extended LMP features */ |
261 | #define LMP_HOST_SSP 0x01 | 226 | #define LMP_HOST_LE 0x02 |
262 | #define LMP_HOST_LE 0x02 | ||
263 | #define LMP_HOST_LE_BREDR 0x04 | ||
264 | 227 | ||
265 | /* Connection modes */ | 228 | /* Connection modes */ |
266 | #define HCI_CM_ACTIVE 0x0000 | 229 | #define HCI_CM_ACTIVE 0x0000 |
@@ -299,51 +262,10 @@ enum { | |||
299 | #define HCI_LK_UNAUTH_COMBINATION 0x04 | 262 | #define HCI_LK_UNAUTH_COMBINATION 0x04 |
300 | #define HCI_LK_AUTH_COMBINATION 0x05 | 263 | #define HCI_LK_AUTH_COMBINATION 0x05 |
301 | #define HCI_LK_CHANGED_COMBINATION 0x06 | 264 | #define HCI_LK_CHANGED_COMBINATION 0x06 |
302 | /* The spec doesn't define types for SMP keys, the _MASTER suffix is implied */ | 265 | /* The spec doesn't define types for SMP keys */ |
303 | #define HCI_SMP_STK 0x80 | 266 | #define HCI_LK_SMP_LTK 0x81 |
304 | #define HCI_SMP_STK_SLAVE 0x81 | 267 | #define HCI_LK_SMP_IRK 0x82 |
305 | #define HCI_SMP_LTK 0x82 | 268 | #define HCI_LK_SMP_CSRK 0x83 |
306 | #define HCI_SMP_LTK_SLAVE 0x83 | ||
307 | |||
308 | /* ---- HCI Error Codes ---- */ | ||
309 | #define HCI_ERROR_AUTH_FAILURE 0x05 | ||
310 | #define HCI_ERROR_CONNECTION_TIMEOUT 0x08 | ||
311 | #define HCI_ERROR_REJ_BAD_ADDR 0x0f | ||
312 | #define HCI_ERROR_REMOTE_USER_TERM 0x13 | ||
313 | #define HCI_ERROR_REMOTE_LOW_RESOURCES 0x14 | ||
314 | #define HCI_ERROR_REMOTE_POWER_OFF 0x15 | ||
315 | #define HCI_ERROR_LOCAL_HOST_TERM 0x16 | ||
316 | #define HCI_ERROR_PAIRING_NOT_ALLOWED 0x18 | ||
317 | |||
318 | /* Flow control modes */ | ||
319 | #define HCI_FLOW_CTL_MODE_PACKET_BASED 0x00 | ||
320 | #define HCI_FLOW_CTL_MODE_BLOCK_BASED 0x01 | ||
321 | |||
322 | /* The core spec defines 127 as the "not available" value */ | ||
323 | #define HCI_TX_POWER_INVALID 127 | ||
324 | |||
325 | /* Extended Inquiry Response field types */ | ||
326 | #define EIR_FLAGS 0x01 /* flags */ | ||
327 | #define EIR_UUID16_SOME 0x02 /* 16-bit UUID, more available */ | ||
328 | #define EIR_UUID16_ALL 0x03 /* 16-bit UUID, all listed */ | ||
329 | #define EIR_UUID32_SOME 0x04 /* 32-bit UUID, more available */ | ||
330 | #define EIR_UUID32_ALL 0x05 /* 32-bit UUID, all listed */ | ||
331 | #define EIR_UUID128_SOME 0x06 /* 128-bit UUID, more available */ | ||
332 | #define EIR_UUID128_ALL 0x07 /* 128-bit UUID, all listed */ | ||
333 | #define EIR_NAME_SHORT 0x08 /* shortened local name */ | ||
334 | #define EIR_NAME_COMPLETE 0x09 /* complete local name */ | ||
335 | #define EIR_TX_POWER 0x0A /* transmit power level */ | ||
336 | #define EIR_CLASS_OF_DEV 0x0D /* Class of Device */ | ||
337 | #define EIR_SSP_HASH_C 0x0E /* Simple Pairing Hash C */ | ||
338 | #define EIR_SSP_RAND_R 0x0F /* Simple Pairing Randomizer R */ | ||
339 | #define EIR_DEVICE_ID 0x10 /* device ID */ | ||
340 | |||
341 | /* Low Energy Advertising Flags */ | ||
342 | #define LE_AD_LIMITED 0x01 /* Limited Discoverable */ | ||
343 | #define LE_AD_GENERAL 0x02 /* General Discoverable */ | ||
344 | #define LE_AD_NO_BREDR 0x04 /* BR/EDR not supported */ | ||
345 | #define LE_AD_SIM_LE_BREDR_CTRL 0x08 /* Simultaneous LE & BR/EDR Controller */ | ||
346 | #define LE_AD_SIM_LE_BREDR_HOST 0x10 /* Simultaneous LE & BR/EDR Host */ | ||
347 | 269 | ||
348 | /* ----- HCI Commands ---- */ | 270 | /* ----- HCI Commands ---- */ |
349 | #define HCI_OP_NOP 0x0000 | 271 | #define HCI_OP_NOP 0x0000 |
@@ -357,8 +279,6 @@ struct hci_cp_inquiry { | |||
357 | 279 | ||
358 | #define HCI_OP_INQUIRY_CANCEL 0x0402 | 280 | #define HCI_OP_INQUIRY_CANCEL 0x0402 |
359 | 281 | ||
360 | #define HCI_OP_PERIODIC_INQ 0x0403 | ||
361 | |||
362 | #define HCI_OP_EXIT_PERIODIC_INQ 0x0404 | 282 | #define HCI_OP_EXIT_PERIODIC_INQ 0x0404 |
363 | 283 | ||
364 | #define HCI_OP_CREATE_CONN 0x0405 | 284 | #define HCI_OP_CREATE_CONN 0x0405 |
@@ -403,7 +323,7 @@ struct hci_cp_reject_conn_req { | |||
403 | #define HCI_OP_LINK_KEY_REPLY 0x040b | 323 | #define HCI_OP_LINK_KEY_REPLY 0x040b |
404 | struct hci_cp_link_key_reply { | 324 | struct hci_cp_link_key_reply { |
405 | bdaddr_t bdaddr; | 325 | bdaddr_t bdaddr; |
406 | __u8 link_key[HCI_LINK_KEY_SIZE]; | 326 | __u8 link_key[16]; |
407 | } __packed; | 327 | } __packed; |
408 | 328 | ||
409 | #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c | 329 | #define HCI_OP_LINK_KEY_NEG_REPLY 0x040c |
@@ -529,14 +449,6 @@ struct hci_rp_user_confirm_reply { | |||
529 | 449 | ||
530 | #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d | 450 | #define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d |
531 | 451 | ||
532 | #define HCI_OP_USER_PASSKEY_REPLY 0x042e | ||
533 | struct hci_cp_user_passkey_reply { | ||
534 | bdaddr_t bdaddr; | ||
535 | __le32 passkey; | ||
536 | } __packed; | ||
537 | |||
538 | #define HCI_OP_USER_PASSKEY_NEG_REPLY 0x042f | ||
539 | |||
540 | #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430 | 452 | #define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430 |
541 | struct hci_cp_remote_oob_data_reply { | 453 | struct hci_cp_remote_oob_data_reply { |
542 | bdaddr_t bdaddr; | 454 | bdaddr_t bdaddr; |
@@ -555,62 +467,6 @@ struct hci_cp_io_capability_neg_reply { | |||
555 | __u8 reason; | 467 | __u8 reason; |
556 | } __packed; | 468 | } __packed; |
557 | 469 | ||
558 | #define HCI_OP_CREATE_PHY_LINK 0x0435 | ||
559 | struct hci_cp_create_phy_link { | ||
560 | __u8 phy_handle; | ||
561 | __u8 key_len; | ||
562 | __u8 key_type; | ||
563 | __u8 key[HCI_AMP_LINK_KEY_SIZE]; | ||
564 | } __packed; | ||
565 | |||
566 | #define HCI_OP_ACCEPT_PHY_LINK 0x0436 | ||
567 | struct hci_cp_accept_phy_link { | ||
568 | __u8 phy_handle; | ||
569 | __u8 key_len; | ||
570 | __u8 key_type; | ||
571 | __u8 key[HCI_AMP_LINK_KEY_SIZE]; | ||
572 | } __packed; | ||
573 | |||
574 | #define HCI_OP_DISCONN_PHY_LINK 0x0437 | ||
575 | struct hci_cp_disconn_phy_link { | ||
576 | __u8 phy_handle; | ||
577 | __u8 reason; | ||
578 | } __packed; | ||
579 | |||
580 | struct ext_flow_spec { | ||
581 | __u8 id; | ||
582 | __u8 stype; | ||
583 | __le16 msdu; | ||
584 | __le32 sdu_itime; | ||
585 | __le32 acc_lat; | ||
586 | __le32 flush_to; | ||
587 | } __packed; | ||
588 | |||
589 | #define HCI_OP_CREATE_LOGICAL_LINK 0x0438 | ||
590 | #define HCI_OP_ACCEPT_LOGICAL_LINK 0x0439 | ||
591 | struct hci_cp_create_accept_logical_link { | ||
592 | __u8 phy_handle; | ||
593 | struct ext_flow_spec tx_flow_spec; | ||
594 | struct ext_flow_spec rx_flow_spec; | ||
595 | } __packed; | ||
596 | |||
597 | #define HCI_OP_DISCONN_LOGICAL_LINK 0x043a | ||
598 | struct hci_cp_disconn_logical_link { | ||
599 | __le16 log_handle; | ||
600 | } __packed; | ||
601 | |||
602 | #define HCI_OP_LOGICAL_LINK_CANCEL 0x043b | ||
603 | struct hci_cp_logical_link_cancel { | ||
604 | __u8 phy_handle; | ||
605 | __u8 flow_spec_id; | ||
606 | } __packed; | ||
607 | |||
608 | struct hci_rp_logical_link_cancel { | ||
609 | __u8 status; | ||
610 | __u8 phy_handle; | ||
611 | __u8 flow_spec_id; | ||
612 | } __packed; | ||
613 | |||
614 | #define HCI_OP_SNIFF_MODE 0x0803 | 470 | #define HCI_OP_SNIFF_MODE 0x0803 |
615 | struct hci_cp_sniff_mode { | 471 | struct hci_cp_sniff_mode { |
616 | __le16 handle; | 472 | __le16 handle; |
@@ -785,8 +641,8 @@ struct hci_cp_host_buffer_size { | |||
785 | 641 | ||
786 | #define HCI_OP_WRITE_EIR 0x0c52 | 642 | #define HCI_OP_WRITE_EIR 0x0c52 |
787 | struct hci_cp_write_eir { | 643 | struct hci_cp_write_eir { |
788 | __u8 fec; | 644 | uint8_t fec; |
789 | __u8 data[HCI_MAX_EIR_LENGTH]; | 645 | uint8_t data[HCI_MAX_EIR_LENGTH]; |
790 | } __packed; | 646 | } __packed; |
791 | 647 | ||
792 | #define HCI_OP_READ_SSP_MODE 0x0c55 | 648 | #define HCI_OP_READ_SSP_MODE 0x0c55 |
@@ -808,21 +664,11 @@ struct hci_rp_read_local_oob_data { | |||
808 | } __packed; | 664 | } __packed; |
809 | 665 | ||
810 | #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58 | 666 | #define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58 |
811 | struct hci_rp_read_inq_rsp_tx_power { | ||
812 | __u8 status; | ||
813 | __s8 tx_power; | ||
814 | } __packed; | ||
815 | |||
816 | #define HCI_OP_READ_FLOW_CONTROL_MODE 0x0c66 | ||
817 | struct hci_rp_read_flow_control_mode { | ||
818 | __u8 status; | ||
819 | __u8 mode; | ||
820 | } __packed; | ||
821 | 667 | ||
822 | #define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d | 668 | #define HCI_OP_WRITE_LE_HOST_SUPPORTED 0x0c6d |
823 | struct hci_cp_write_le_host_supported { | 669 | struct hci_cp_write_le_host_supported { |
824 | __u8 le; | 670 | __u8 le; |
825 | __u8 simul; | 671 | __u8 simul; |
826 | } __packed; | 672 | } __packed; |
827 | 673 | ||
828 | #define HCI_OP_READ_LOCAL_VERSION 0x1001 | 674 | #define HCI_OP_READ_LOCAL_VERSION 0x1001 |
@@ -873,64 +719,6 @@ struct hci_rp_read_bd_addr { | |||
873 | bdaddr_t bdaddr; | 719 | bdaddr_t bdaddr; |
874 | } __packed; | 720 | } __packed; |
875 | 721 | ||
876 | #define HCI_OP_READ_DATA_BLOCK_SIZE 0x100a | ||
877 | struct hci_rp_read_data_block_size { | ||
878 | __u8 status; | ||
879 | __le16 max_acl_len; | ||
880 | __le16 block_len; | ||
881 | __le16 num_blocks; | ||
882 | } __packed; | ||
883 | |||
884 | #define HCI_OP_WRITE_PAGE_SCAN_ACTIVITY 0x0c1c | ||
885 | struct hci_cp_write_page_scan_activity { | ||
886 | __le16 interval; | ||
887 | __le16 window; | ||
888 | } __packed; | ||
889 | |||
890 | #define HCI_OP_WRITE_PAGE_SCAN_TYPE 0x0c47 | ||
891 | #define PAGE_SCAN_TYPE_STANDARD 0x00 | ||
892 | #define PAGE_SCAN_TYPE_INTERLACED 0x01 | ||
893 | |||
894 | #define HCI_OP_READ_LOCAL_AMP_INFO 0x1409 | ||
895 | struct hci_rp_read_local_amp_info { | ||
896 | __u8 status; | ||
897 | __u8 amp_status; | ||
898 | __le32 total_bw; | ||
899 | __le32 max_bw; | ||
900 | __le32 min_latency; | ||
901 | __le32 max_pdu; | ||
902 | __u8 amp_type; | ||
903 | __le16 pal_cap; | ||
904 | __le16 max_assoc_size; | ||
905 | __le32 max_flush_to; | ||
906 | __le32 be_flush_to; | ||
907 | } __packed; | ||
908 | |||
909 | #define HCI_OP_READ_LOCAL_AMP_ASSOC 0x140a | ||
910 | struct hci_cp_read_local_amp_assoc { | ||
911 | __u8 phy_handle; | ||
912 | __le16 len_so_far; | ||
913 | __le16 max_len; | ||
914 | } __packed; | ||
915 | struct hci_rp_read_local_amp_assoc { | ||
916 | __u8 status; | ||
917 | __u8 phy_handle; | ||
918 | __le16 rem_len; | ||
919 | __u8 frag[0]; | ||
920 | } __packed; | ||
921 | |||
922 | #define HCI_OP_WRITE_REMOTE_AMP_ASSOC 0x140b | ||
923 | struct hci_cp_write_remote_amp_assoc { | ||
924 | __u8 phy_handle; | ||
925 | __le16 len_so_far; | ||
926 | __le16 rem_len; | ||
927 | __u8 frag[0]; | ||
928 | } __packed; | ||
929 | struct hci_rp_write_remote_amp_assoc { | ||
930 | __u8 status; | ||
931 | __u8 phy_handle; | ||
932 | } __packed; | ||
933 | |||
934 | #define HCI_OP_LE_SET_EVENT_MASK 0x2001 | 722 | #define HCI_OP_LE_SET_EVENT_MASK 0x2001 |
935 | struct hci_cp_le_set_event_mask { | 723 | struct hci_cp_le_set_event_mask { |
936 | __u8 mask[8]; | 724 | __u8 mask[8]; |
@@ -943,34 +731,6 @@ struct hci_rp_le_read_buffer_size { | |||
943 | __u8 le_max_pkt; | 731 | __u8 le_max_pkt; |
944 | } __packed; | 732 | } __packed; |
945 | 733 | ||
946 | #define HCI_OP_LE_READ_ADV_TX_POWER 0x2007 | ||
947 | struct hci_rp_le_read_adv_tx_power { | ||
948 | __u8 status; | ||
949 | __s8 tx_power; | ||
950 | } __packed; | ||
951 | |||
952 | #define HCI_MAX_AD_LENGTH 31 | ||
953 | |||
954 | #define HCI_OP_LE_SET_ADV_DATA 0x2008 | ||
955 | struct hci_cp_le_set_adv_data { | ||
956 | __u8 length; | ||
957 | __u8 data[HCI_MAX_AD_LENGTH]; | ||
958 | } __packed; | ||
959 | |||
960 | #define HCI_OP_LE_SET_ADV_ENABLE 0x200a | ||
961 | |||
962 | #define HCI_OP_LE_SET_SCAN_PARAM 0x200b | ||
963 | struct hci_cp_le_set_scan_param { | ||
964 | __u8 type; | ||
965 | __le16 interval; | ||
966 | __le16 window; | ||
967 | __u8 own_address_type; | ||
968 | __u8 filter_policy; | ||
969 | } __packed; | ||
970 | |||
971 | #define LE_SCANNING_DISABLED 0x00 | ||
972 | #define LE_SCANNING_ENABLED 0x01 | ||
973 | |||
974 | #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c | 734 | #define HCI_OP_LE_SET_SCAN_ENABLE 0x200c |
975 | struct hci_cp_le_set_scan_enable { | 735 | struct hci_cp_le_set_scan_enable { |
976 | __u8 enable; | 736 | __u8 enable; |
@@ -1146,14 +906,9 @@ struct hci_ev_role_change { | |||
1146 | } __packed; | 906 | } __packed; |
1147 | 907 | ||
1148 | #define HCI_EV_NUM_COMP_PKTS 0x13 | 908 | #define HCI_EV_NUM_COMP_PKTS 0x13 |
1149 | struct hci_comp_pkts_info { | ||
1150 | __le16 handle; | ||
1151 | __le16 count; | ||
1152 | } __packed; | ||
1153 | |||
1154 | struct hci_ev_num_comp_pkts { | 909 | struct hci_ev_num_comp_pkts { |
1155 | __u8 num_hndl; | 910 | __u8 num_hndl; |
1156 | struct hci_comp_pkts_info handles[0]; | 911 | /* variable length part */ |
1157 | } __packed; | 912 | } __packed; |
1158 | 913 | ||
1159 | #define HCI_EV_MODE_CHANGE 0x14 | 914 | #define HCI_EV_MODE_CHANGE 0x14 |
@@ -1177,7 +932,7 @@ struct hci_ev_link_key_req { | |||
1177 | #define HCI_EV_LINK_KEY_NOTIFY 0x18 | 932 | #define HCI_EV_LINK_KEY_NOTIFY 0x18 |
1178 | struct hci_ev_link_key_notify { | 933 | struct hci_ev_link_key_notify { |
1179 | bdaddr_t bdaddr; | 934 | bdaddr_t bdaddr; |
1180 | __u8 link_key[HCI_LINK_KEY_SIZE]; | 935 | __u8 link_key[16]; |
1181 | __u8 key_type; | 936 | __u8 key_type; |
1182 | } __packed; | 937 | } __packed; |
1183 | 938 | ||
@@ -1273,12 +1028,6 @@ struct extended_inquiry_info { | |||
1273 | __u8 data[240]; | 1028 | __u8 data[240]; |
1274 | } __packed; | 1029 | } __packed; |
1275 | 1030 | ||
1276 | #define HCI_EV_KEY_REFRESH_COMPLETE 0x30 | ||
1277 | struct hci_ev_key_refresh_complete { | ||
1278 | __u8 status; | ||
1279 | __le16 handle; | ||
1280 | } __packed; | ||
1281 | |||
1282 | #define HCI_EV_IO_CAPA_REQUEST 0x31 | 1031 | #define HCI_EV_IO_CAPA_REQUEST 0x31 |
1283 | struct hci_ev_io_capa_request { | 1032 | struct hci_ev_io_capa_request { |
1284 | bdaddr_t bdaddr; | 1033 | bdaddr_t bdaddr; |
@@ -1298,11 +1047,6 @@ struct hci_ev_user_confirm_req { | |||
1298 | __le32 passkey; | 1047 | __le32 passkey; |
1299 | } __packed; | 1048 | } __packed; |
1300 | 1049 | ||
1301 | #define HCI_EV_USER_PASSKEY_REQUEST 0x34 | ||
1302 | struct hci_ev_user_passkey_req { | ||
1303 | bdaddr_t bdaddr; | ||
1304 | } __packed; | ||
1305 | |||
1306 | #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35 | 1050 | #define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35 |
1307 | struct hci_ev_remote_oob_data_request { | 1051 | struct hci_ev_remote_oob_data_request { |
1308 | bdaddr_t bdaddr; | 1052 | bdaddr_t bdaddr; |
@@ -1314,24 +1058,6 @@ struct hci_ev_simple_pair_complete { | |||
1314 | bdaddr_t bdaddr; | 1058 | bdaddr_t bdaddr; |
1315 | } __packed; | 1059 | } __packed; |
1316 | 1060 | ||
1317 | #define HCI_EV_USER_PASSKEY_NOTIFY 0x3b | ||
1318 | struct hci_ev_user_passkey_notify { | ||
1319 | bdaddr_t bdaddr; | ||
1320 | __le32 passkey; | ||
1321 | } __packed; | ||
1322 | |||
1323 | #define HCI_KEYPRESS_STARTED 0 | ||
1324 | #define HCI_KEYPRESS_ENTERED 1 | ||
1325 | #define HCI_KEYPRESS_ERASED 2 | ||
1326 | #define HCI_KEYPRESS_CLEARED 3 | ||
1327 | #define HCI_KEYPRESS_COMPLETED 4 | ||
1328 | |||
1329 | #define HCI_EV_KEYPRESS_NOTIFY 0x3c | ||
1330 | struct hci_ev_keypress_notify { | ||
1331 | bdaddr_t bdaddr; | ||
1332 | __u8 type; | ||
1333 | } __packed; | ||
1334 | |||
1335 | #define HCI_EV_REMOTE_HOST_FEATURES 0x3d | 1061 | #define HCI_EV_REMOTE_HOST_FEATURES 0x3d |
1336 | struct hci_ev_remote_host_features { | 1062 | struct hci_ev_remote_host_features { |
1337 | bdaddr_t bdaddr; | 1063 | bdaddr_t bdaddr; |
@@ -1343,55 +1069,7 @@ struct hci_ev_le_meta { | |||
1343 | __u8 subevent; | 1069 | __u8 subevent; |
1344 | } __packed; | 1070 | } __packed; |
1345 | 1071 | ||
1346 | #define HCI_EV_PHY_LINK_COMPLETE 0x40 | ||
1347 | struct hci_ev_phy_link_complete { | ||
1348 | __u8 status; | ||
1349 | __u8 phy_handle; | ||
1350 | } __packed; | ||
1351 | |||
1352 | #define HCI_EV_CHANNEL_SELECTED 0x41 | ||
1353 | struct hci_ev_channel_selected { | ||
1354 | __u8 phy_handle; | ||
1355 | } __packed; | ||
1356 | |||
1357 | #define HCI_EV_DISCONN_PHY_LINK_COMPLETE 0x42 | ||
1358 | struct hci_ev_disconn_phy_link_complete { | ||
1359 | __u8 status; | ||
1360 | __u8 phy_handle; | ||
1361 | __u8 reason; | ||
1362 | } __packed; | ||
1363 | |||
1364 | #define HCI_EV_LOGICAL_LINK_COMPLETE 0x45 | ||
1365 | struct hci_ev_logical_link_complete { | ||
1366 | __u8 status; | ||
1367 | __le16 handle; | ||
1368 | __u8 phy_handle; | ||
1369 | __u8 flow_spec_id; | ||
1370 | } __packed; | ||
1371 | |||
1372 | #define HCI_EV_DISCONN_LOGICAL_LINK_COMPLETE 0x46 | ||
1373 | struct hci_ev_disconn_logical_link_complete { | ||
1374 | __u8 status; | ||
1375 | __le16 handle; | ||
1376 | __u8 reason; | ||
1377 | } __packed; | ||
1378 | |||
1379 | #define HCI_EV_NUM_COMP_BLOCKS 0x48 | ||
1380 | struct hci_comp_blocks_info { | ||
1381 | __le16 handle; | ||
1382 | __le16 pkts; | ||
1383 | __le16 blocks; | ||
1384 | } __packed; | ||
1385 | |||
1386 | struct hci_ev_num_comp_blocks { | ||
1387 | __le16 num_blocks; | ||
1388 | __u8 num_hndl; | ||
1389 | struct hci_comp_blocks_info handles[0]; | ||
1390 | } __packed; | ||
1391 | |||
1392 | /* Low energy meta events */ | 1072 | /* Low energy meta events */ |
1393 | #define LE_CONN_ROLE_MASTER 0x00 | ||
1394 | |||
1395 | #define HCI_EV_LE_CONN_COMPLETE 0x01 | 1073 | #define HCI_EV_LE_CONN_COMPLETE 0x01 |
1396 | struct hci_ev_le_conn_complete { | 1074 | struct hci_ev_le_conn_complete { |
1397 | __u8 status; | 1075 | __u8 status; |
@@ -1478,6 +1156,7 @@ struct hci_sco_hdr { | |||
1478 | __u8 dlen; | 1156 | __u8 dlen; |
1479 | } __packed; | 1157 | } __packed; |
1480 | 1158 | ||
1159 | #include <linux/skbuff.h> | ||
1481 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) | 1160 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) |
1482 | { | 1161 | { |
1483 | return (struct hci_event_hdr *) skb->data; | 1162 | return (struct hci_event_hdr *) skb->data; |
@@ -1494,12 +1173,12 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb) | |||
1494 | } | 1173 | } |
1495 | 1174 | ||
1496 | /* Command opcode pack/unpack */ | 1175 | /* Command opcode pack/unpack */ |
1497 | #define hci_opcode_pack(ogf, ocf) ((__u16) ((ocf & 0x03ff)|(ogf << 10))) | 1176 | #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) |
1498 | #define hci_opcode_ogf(op) (op >> 10) | 1177 | #define hci_opcode_ogf(op) (op >> 10) |
1499 | #define hci_opcode_ocf(op) (op & 0x03ff) | 1178 | #define hci_opcode_ocf(op) (op & 0x03ff) |
1500 | 1179 | ||
1501 | /* ACL handle and flags pack/unpack */ | 1180 | /* ACL handle and flags pack/unpack */ |
1502 | #define hci_handle_pack(h, f) ((__u16) ((h & 0x0fff)|(f << 12))) | 1181 | #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12)) |
1503 | #define hci_handle(h) (h & 0x0fff) | 1182 | #define hci_handle(h) (h & 0x0fff) |
1504 | #define hci_flags(h) (h >> 12) | 1183 | #define hci_flags(h) (h >> 12) |
1505 | 1184 | ||
@@ -1522,8 +1201,7 @@ struct sockaddr_hci { | |||
1522 | #define HCI_DEV_NONE 0xffff | 1201 | #define HCI_DEV_NONE 0xffff |
1523 | 1202 | ||
1524 | #define HCI_CHANNEL_RAW 0 | 1203 | #define HCI_CHANNEL_RAW 0 |
1525 | #define HCI_CHANNEL_MONITOR 2 | 1204 | #define HCI_CHANNEL_CONTROL 1 |
1526 | #define HCI_CHANNEL_CONTROL 3 | ||
1527 | 1205 | ||
1528 | struct hci_filter { | 1206 | struct hci_filter { |
1529 | unsigned long type_mask; | 1207 | unsigned long type_mask; |
@@ -1586,6 +1264,9 @@ struct hci_conn_info { | |||
1586 | __u8 out; | 1264 | __u8 out; |
1587 | __u16 state; | 1265 | __u16 state; |
1588 | __u32 link_mode; | 1266 | __u32 link_mode; |
1267 | __u32 mtu; | ||
1268 | __u32 cnt; | ||
1269 | __u32 pkts; | ||
1589 | }; | 1270 | }; |
1590 | 1271 | ||
1591 | struct hci_dev_req { | 1272 | struct hci_dev_req { |
@@ -1624,6 +1305,4 @@ struct hci_inquiry_req { | |||
1624 | }; | 1305 | }; |
1625 | #define IREQ_CACHE_FLUSH 0x0001 | 1306 | #define IREQ_CACHE_FLUSH 0x0001 |
1626 | 1307 | ||
1627 | extern bool enable_hs; | ||
1628 | |||
1629 | #endif /* __HCI_H */ | 1308 | #endif /* __HCI_H */ |
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 014a2eaa538..626f8b0a679 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -25,10 +25,12 @@ | |||
25 | #ifndef __HCI_CORE_H | 25 | #ifndef __HCI_CORE_H |
26 | #define __HCI_CORE_H | 26 | #define __HCI_CORE_H |
27 | 27 | ||
28 | #include <linux/interrupt.h> | ||
28 | #include <net/bluetooth/hci.h> | 29 | #include <net/bluetooth/hci.h> |
29 | 30 | ||
30 | /* HCI priority */ | 31 | /* HCI upper protocols */ |
31 | #define HCI_PRIO_MAX 7 | 32 | #define HCI_PROTO_L2CAP 0 |
33 | #define HCI_PROTO_SCO 1 | ||
32 | 34 | ||
33 | /* HCI Core structures */ | 35 | /* HCI Core structures */ |
34 | struct inquiry_data { | 36 | struct inquiry_data { |
@@ -43,37 +45,21 @@ struct inquiry_data { | |||
43 | }; | 45 | }; |
44 | 46 | ||
45 | struct inquiry_entry { | 47 | struct inquiry_entry { |
46 | struct list_head all; /* inq_cache.all */ | 48 | struct inquiry_entry *next; |
47 | struct list_head list; /* unknown or resolve */ | ||
48 | enum { | ||
49 | NAME_NOT_KNOWN, | ||
50 | NAME_NEEDED, | ||
51 | NAME_PENDING, | ||
52 | NAME_KNOWN, | ||
53 | } name_state; | ||
54 | __u32 timestamp; | 49 | __u32 timestamp; |
55 | struct inquiry_data data; | 50 | struct inquiry_data data; |
56 | }; | 51 | }; |
57 | 52 | ||
58 | struct discovery_state { | 53 | struct inquiry_cache { |
59 | int type; | 54 | spinlock_t lock; |
60 | enum { | ||
61 | DISCOVERY_STOPPED, | ||
62 | DISCOVERY_STARTING, | ||
63 | DISCOVERY_FINDING, | ||
64 | DISCOVERY_RESOLVING, | ||
65 | DISCOVERY_STOPPING, | ||
66 | } state; | ||
67 | struct list_head all; /* All devices found during inquiry */ | ||
68 | struct list_head unknown; /* Name state not known */ | ||
69 | struct list_head resolve; /* Name needs to be resolved */ | ||
70 | __u32 timestamp; | 55 | __u32 timestamp; |
56 | struct inquiry_entry *list; | ||
71 | }; | 57 | }; |
72 | 58 | ||
73 | struct hci_conn_hash { | 59 | struct hci_conn_hash { |
74 | struct list_head list; | 60 | struct list_head list; |
61 | spinlock_t lock; | ||
75 | unsigned int acl_num; | 62 | unsigned int acl_num; |
76 | unsigned int amp_num; | ||
77 | unsigned int sco_num; | 63 | unsigned int sco_num; |
78 | unsigned int le_num; | 64 | unsigned int le_num; |
79 | }; | 65 | }; |
@@ -89,24 +75,28 @@ struct bt_uuid { | |||
89 | u8 svc_hint; | 75 | u8 svc_hint; |
90 | }; | 76 | }; |
91 | 77 | ||
92 | struct smp_ltk { | 78 | struct key_master_id { |
93 | struct list_head list; | ||
94 | bdaddr_t bdaddr; | ||
95 | u8 bdaddr_type; | ||
96 | u8 authenticated; | ||
97 | u8 type; | ||
98 | u8 enc_size; | ||
99 | __le16 ediv; | 79 | __le16 ediv; |
100 | u8 rand[8]; | 80 | u8 rand[8]; |
81 | } __packed; | ||
82 | |||
83 | struct link_key_data { | ||
84 | bdaddr_t bdaddr; | ||
85 | u8 type; | ||
101 | u8 val[16]; | 86 | u8 val[16]; |
87 | u8 pin_len; | ||
88 | u8 dlen; | ||
89 | u8 data[0]; | ||
102 | } __packed; | 90 | } __packed; |
103 | 91 | ||
104 | struct link_key { | 92 | struct link_key { |
105 | struct list_head list; | 93 | struct list_head list; |
106 | bdaddr_t bdaddr; | 94 | bdaddr_t bdaddr; |
107 | u8 type; | 95 | u8 type; |
108 | u8 val[HCI_LINK_KEY_SIZE]; | 96 | u8 val[16]; |
109 | u8 pin_len; | 97 | u8 pin_len; |
98 | u8 dlen; | ||
99 | u8 data[0]; | ||
110 | }; | 100 | }; |
111 | 101 | ||
112 | struct oob_data { | 102 | struct oob_data { |
@@ -116,27 +106,17 @@ struct oob_data { | |||
116 | u8 randomizer[16]; | 106 | u8 randomizer[16]; |
117 | }; | 107 | }; |
118 | 108 | ||
119 | struct le_scan_params { | 109 | struct adv_entry { |
120 | u8 type; | 110 | struct list_head list; |
121 | u16 interval; | 111 | bdaddr_t bdaddr; |
122 | u16 window; | 112 | u8 bdaddr_type; |
123 | int timeout; | ||
124 | }; | ||
125 | |||
126 | #define HCI_MAX_SHORT_NAME_LENGTH 10 | ||
127 | |||
128 | struct amp_assoc { | ||
129 | __u16 len; | ||
130 | __u16 offset; | ||
131 | __u16 rem_len; | ||
132 | __u16 len_so_far; | ||
133 | __u8 data[HCI_MAX_AMP_ASSOC_SIZE]; | ||
134 | }; | 113 | }; |
135 | 114 | ||
136 | #define NUM_REASSEMBLY 4 | 115 | #define NUM_REASSEMBLY 4 |
137 | struct hci_dev { | 116 | struct hci_dev { |
138 | struct list_head list; | 117 | struct list_head list; |
139 | struct mutex lock; | 118 | spinlock_t lock; |
119 | atomic_t refcnt; | ||
140 | 120 | ||
141 | char name[8]; | 121 | char name[8]; |
142 | unsigned long flags; | 122 | unsigned long flags; |
@@ -145,26 +125,21 @@ struct hci_dev { | |||
145 | __u8 dev_type; | 125 | __u8 dev_type; |
146 | bdaddr_t bdaddr; | 126 | bdaddr_t bdaddr; |
147 | __u8 dev_name[HCI_MAX_NAME_LENGTH]; | 127 | __u8 dev_name[HCI_MAX_NAME_LENGTH]; |
148 | __u8 short_name[HCI_MAX_SHORT_NAME_LENGTH]; | ||
149 | __u8 eir[HCI_MAX_EIR_LENGTH]; | 128 | __u8 eir[HCI_MAX_EIR_LENGTH]; |
150 | __u8 dev_class[3]; | 129 | __u8 dev_class[3]; |
151 | __u8 major_class; | 130 | __u8 major_class; |
152 | __u8 minor_class; | 131 | __u8 minor_class; |
153 | __u8 features[8]; | 132 | __u8 features[8]; |
154 | __u8 host_features[8]; | 133 | __u8 extfeatures[8]; |
155 | __u8 commands[64]; | 134 | __u8 commands[64]; |
135 | __u8 ssp_mode; | ||
156 | __u8 hci_ver; | 136 | __u8 hci_ver; |
157 | __u16 hci_rev; | 137 | __u16 hci_rev; |
158 | __u8 lmp_ver; | 138 | __u8 lmp_ver; |
159 | __u16 manufacturer; | 139 | __u16 manufacturer; |
160 | __u16 lmp_subver; | 140 | __le16 lmp_subver; |
161 | __u16 voice_setting; | 141 | __u16 voice_setting; |
162 | __u8 io_capability; | 142 | __u8 io_capability; |
163 | __s8 inq_tx_power; | ||
164 | __u16 devid_source; | ||
165 | __u16 devid_vendor; | ||
166 | __u16 devid_product; | ||
167 | __u16 devid_version; | ||
168 | 143 | ||
169 | __u16 pkt_type; | 144 | __u16 pkt_type; |
170 | __u16 esco_type; | 145 | __u16 esco_type; |
@@ -175,21 +150,6 @@ struct hci_dev { | |||
175 | __u16 sniff_min_interval; | 150 | __u16 sniff_min_interval; |
176 | __u16 sniff_max_interval; | 151 | __u16 sniff_max_interval; |
177 | 152 | ||
178 | __u8 amp_status; | ||
179 | __u32 amp_total_bw; | ||
180 | __u32 amp_max_bw; | ||
181 | __u32 amp_min_latency; | ||
182 | __u32 amp_max_pdu; | ||
183 | __u8 amp_type; | ||
184 | __u16 amp_pal_cap; | ||
185 | __u16 amp_assoc_size; | ||
186 | __u32 amp_max_flush_to; | ||
187 | __u32 amp_be_flush_to; | ||
188 | |||
189 | struct amp_assoc loc_assoc; | ||
190 | |||
191 | __u8 flow_ctl_mode; | ||
192 | |||
193 | unsigned int auto_accept_delay; | 153 | unsigned int auto_accept_delay; |
194 | 154 | ||
195 | unsigned long quirks; | 155 | unsigned long quirks; |
@@ -206,11 +166,6 @@ struct hci_dev { | |||
206 | unsigned int sco_pkts; | 166 | unsigned int sco_pkts; |
207 | unsigned int le_pkts; | 167 | unsigned int le_pkts; |
208 | 168 | ||
209 | __u16 block_len; | ||
210 | __u16 block_mtu; | ||
211 | __u16 num_blocks; | ||
212 | __u16 block_cnt; | ||
213 | |||
214 | unsigned long acl_last_tx; | 169 | unsigned long acl_last_tx; |
215 | unsigned long sco_last_tx; | 170 | unsigned long sco_last_tx; |
216 | unsigned long le_last_tx; | 171 | unsigned long le_last_tx; |
@@ -218,18 +173,13 @@ struct hci_dev { | |||
218 | struct workqueue_struct *workqueue; | 173 | struct workqueue_struct *workqueue; |
219 | 174 | ||
220 | struct work_struct power_on; | 175 | struct work_struct power_on; |
221 | struct delayed_work power_off; | 176 | struct work_struct power_off; |
222 | 177 | struct timer_list off_timer; | |
223 | __u16 discov_timeout; | ||
224 | struct delayed_work discov_off; | ||
225 | |||
226 | struct delayed_work service_cache; | ||
227 | 178 | ||
228 | struct timer_list cmd_timer; | 179 | struct timer_list cmd_timer; |
229 | 180 | struct tasklet_struct cmd_task; | |
230 | struct work_struct rx_work; | 181 | struct tasklet_struct rx_task; |
231 | struct work_struct cmd_work; | 182 | struct tasklet_struct tx_task; |
232 | struct work_struct tx_work; | ||
233 | 183 | ||
234 | struct sk_buff_head rx_q; | 184 | struct sk_buff_head rx_q; |
235 | struct sk_buff_head raw_q; | 185 | struct sk_buff_head raw_q; |
@@ -245,9 +195,9 @@ struct hci_dev { | |||
245 | 195 | ||
246 | __u16 init_last_cmd; | 196 | __u16 init_last_cmd; |
247 | 197 | ||
248 | struct list_head mgmt_pending; | 198 | struct crypto_blkcipher *tfm; |
249 | 199 | ||
250 | struct discovery_state discovery; | 200 | struct inquiry_cache inq_cache; |
251 | struct hci_conn_hash conn_hash; | 201 | struct hci_conn_hash conn_hash; |
252 | struct list_head blacklist; | 202 | struct list_head blacklist; |
253 | 203 | ||
@@ -255,43 +205,38 @@ struct hci_dev { | |||
255 | 205 | ||
256 | struct list_head link_keys; | 206 | struct list_head link_keys; |
257 | 207 | ||
258 | struct list_head long_term_keys; | ||
259 | |||
260 | struct list_head remote_oob_data; | 208 | struct list_head remote_oob_data; |
261 | 209 | ||
210 | struct list_head adv_entries; | ||
211 | struct timer_list adv_timer; | ||
212 | |||
262 | struct hci_dev_stats stat; | 213 | struct hci_dev_stats stat; |
263 | 214 | ||
264 | struct sk_buff_head driver_init; | 215 | struct sk_buff_head driver_init; |
265 | 216 | ||
217 | void *driver_data; | ||
218 | void *core_data; | ||
219 | |||
266 | atomic_t promisc; | 220 | atomic_t promisc; |
267 | 221 | ||
268 | struct dentry *debugfs; | 222 | struct dentry *debugfs; |
269 | 223 | ||
224 | struct device *parent; | ||
270 | struct device dev; | 225 | struct device dev; |
271 | 226 | ||
272 | struct rfkill *rfkill; | 227 | struct rfkill *rfkill; |
273 | 228 | ||
274 | unsigned long dev_flags; | 229 | struct module *owner; |
275 | |||
276 | struct delayed_work le_scan_disable; | ||
277 | |||
278 | struct work_struct le_scan; | ||
279 | struct le_scan_params le_scan_params; | ||
280 | |||
281 | __s8 adv_tx_power; | ||
282 | __u8 adv_data[HCI_MAX_AD_LENGTH]; | ||
283 | __u8 adv_data_len; | ||
284 | 230 | ||
285 | int (*open)(struct hci_dev *hdev); | 231 | int (*open)(struct hci_dev *hdev); |
286 | int (*close)(struct hci_dev *hdev); | 232 | int (*close)(struct hci_dev *hdev); |
287 | int (*flush)(struct hci_dev *hdev); | 233 | int (*flush)(struct hci_dev *hdev); |
288 | int (*send)(struct sk_buff *skb); | 234 | int (*send)(struct sk_buff *skb); |
235 | void (*destruct)(struct hci_dev *hdev); | ||
289 | void (*notify)(struct hci_dev *hdev, unsigned int evt); | 236 | void (*notify)(struct hci_dev *hdev, unsigned int evt); |
290 | int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); | 237 | int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg); |
291 | }; | 238 | }; |
292 | 239 | ||
293 | #define HCI_PHY_HANDLE(handle) (handle & 0xff) | ||
294 | |||
295 | struct hci_conn { | 240 | struct hci_conn { |
296 | struct list_head list; | 241 | struct list_head list; |
297 | 242 | ||
@@ -303,10 +248,11 @@ struct hci_conn { | |||
303 | __u16 state; | 248 | __u16 state; |
304 | __u8 mode; | 249 | __u8 mode; |
305 | __u8 type; | 250 | __u8 type; |
306 | bool out; | 251 | __u8 out; |
307 | __u8 attempt; | 252 | __u8 attempt; |
308 | __u8 dev_class[3]; | 253 | __u8 dev_class[3]; |
309 | __u8 features[8]; | 254 | __u8 features[8]; |
255 | __u8 ssp_mode; | ||
310 | __u16 interval; | 256 | __u16 interval; |
311 | __u16 pkt_type; | 257 | __u16 pkt_type; |
312 | __u16 link_policy; | 258 | __u16 link_policy; |
@@ -318,33 +264,31 @@ struct hci_conn { | |||
318 | __u8 pin_length; | 264 | __u8 pin_length; |
319 | __u8 enc_key_size; | 265 | __u8 enc_key_size; |
320 | __u8 io_capability; | 266 | __u8 io_capability; |
321 | __u32 passkey_notify; | 267 | __u8 power_save; |
322 | __u8 passkey_entered; | ||
323 | __u16 disc_timeout; | 268 | __u16 disc_timeout; |
324 | unsigned long flags; | 269 | unsigned long pend; |
325 | 270 | ||
326 | __u8 remote_cap; | 271 | __u8 remote_cap; |
272 | __u8 remote_oob; | ||
327 | __u8 remote_auth; | 273 | __u8 remote_auth; |
328 | __u8 remote_id; | ||
329 | bool flush_key; | ||
330 | 274 | ||
331 | unsigned int sent; | 275 | unsigned int sent; |
332 | 276 | ||
333 | struct sk_buff_head data_q; | 277 | struct sk_buff_head data_q; |
334 | struct list_head chan_list; | ||
335 | 278 | ||
336 | struct delayed_work disc_work; | 279 | struct timer_list disc_timer; |
337 | struct timer_list idle_timer; | 280 | struct timer_list idle_timer; |
338 | struct timer_list auto_accept_timer; | 281 | struct timer_list auto_accept_timer; |
339 | 282 | ||
283 | struct work_struct work_add; | ||
284 | struct work_struct work_del; | ||
285 | |||
340 | struct device dev; | 286 | struct device dev; |
341 | atomic_t devref; | 287 | atomic_t devref; |
342 | 288 | ||
343 | struct hci_dev *hdev; | 289 | struct hci_dev *hdev; |
344 | void *l2cap_data; | 290 | void *l2cap_data; |
345 | void *sco_data; | 291 | void *sco_data; |
346 | void *smp_conn; | ||
347 | struct amp_mgr *amp_mgr; | ||
348 | 292 | ||
349 | struct hci_conn *link; | 293 | struct hci_conn *link; |
350 | 294 | ||
@@ -353,58 +297,37 @@ struct hci_conn { | |||
353 | void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); | 297 | void (*disconn_cfm_cb) (struct hci_conn *conn, u8 reason); |
354 | }; | 298 | }; |
355 | 299 | ||
356 | struct hci_chan { | 300 | extern struct hci_proto *hci_proto[]; |
357 | struct list_head list; | ||
358 | __u16 handle; | ||
359 | struct hci_conn *conn; | ||
360 | struct sk_buff_head data_q; | ||
361 | unsigned int sent; | ||
362 | __u8 state; | ||
363 | }; | ||
364 | |||
365 | extern struct list_head hci_dev_list; | 301 | extern struct list_head hci_dev_list; |
366 | extern struct list_head hci_cb_list; | 302 | extern struct list_head hci_cb_list; |
367 | extern rwlock_t hci_dev_list_lock; | 303 | extern rwlock_t hci_dev_list_lock; |
368 | extern rwlock_t hci_cb_list_lock; | 304 | extern rwlock_t hci_cb_list_lock; |
369 | 305 | ||
370 | /* ----- HCI interface to upper protocols ----- */ | ||
371 | extern int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
372 | extern void l2cap_connect_cfm(struct hci_conn *hcon, u8 status); | ||
373 | extern int l2cap_disconn_ind(struct hci_conn *hcon); | ||
374 | extern void l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason); | ||
375 | extern int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt); | ||
376 | extern int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, | ||
377 | u16 flags); | ||
378 | |||
379 | extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags); | ||
380 | extern void sco_connect_cfm(struct hci_conn *hcon, __u8 status); | ||
381 | extern void sco_disconn_cfm(struct hci_conn *hcon, __u8 reason); | ||
382 | extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb); | ||
383 | |||
384 | /* ----- Inquiry cache ----- */ | 306 | /* ----- Inquiry cache ----- */ |
385 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ | 307 | #define INQUIRY_CACHE_AGE_MAX (HZ*30) /* 30 seconds */ |
386 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ | 308 | #define INQUIRY_ENTRY_AGE_MAX (HZ*60) /* 60 seconds */ |
387 | 309 | ||
388 | static inline void discovery_init(struct hci_dev *hdev) | 310 | #define inquiry_cache_lock(c) spin_lock(&c->lock) |
311 | #define inquiry_cache_unlock(c) spin_unlock(&c->lock) | ||
312 | #define inquiry_cache_lock_bh(c) spin_lock_bh(&c->lock) | ||
313 | #define inquiry_cache_unlock_bh(c) spin_unlock_bh(&c->lock) | ||
314 | |||
315 | static inline void inquiry_cache_init(struct hci_dev *hdev) | ||
389 | { | 316 | { |
390 | hdev->discovery.state = DISCOVERY_STOPPED; | 317 | struct inquiry_cache *c = &hdev->inq_cache; |
391 | INIT_LIST_HEAD(&hdev->discovery.all); | 318 | spin_lock_init(&c->lock); |
392 | INIT_LIST_HEAD(&hdev->discovery.unknown); | 319 | c->list = NULL; |
393 | INIT_LIST_HEAD(&hdev->discovery.resolve); | ||
394 | } | 320 | } |
395 | 321 | ||
396 | bool hci_discovery_active(struct hci_dev *hdev); | ||
397 | |||
398 | void hci_discovery_set_state(struct hci_dev *hdev, int state); | ||
399 | |||
400 | static inline int inquiry_cache_empty(struct hci_dev *hdev) | 322 | static inline int inquiry_cache_empty(struct hci_dev *hdev) |
401 | { | 323 | { |
402 | return list_empty(&hdev->discovery.all); | 324 | struct inquiry_cache *c = &hdev->inq_cache; |
325 | return c->list == NULL; | ||
403 | } | 326 | } |
404 | 327 | ||
405 | static inline long inquiry_cache_age(struct hci_dev *hdev) | 328 | static inline long inquiry_cache_age(struct hci_dev *hdev) |
406 | { | 329 | { |
407 | struct discovery_state *c = &hdev->discovery; | 330 | struct inquiry_cache *c = &hdev->inq_cache; |
408 | return jiffies - c->timestamp; | 331 | return jiffies - c->timestamp; |
409 | } | 332 | } |
410 | 333 | ||
@@ -414,16 +337,8 @@ static inline long inquiry_entry_age(struct inquiry_entry *e) | |||
414 | } | 337 | } |
415 | 338 | ||
416 | struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, | 339 | struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, |
417 | bdaddr_t *bdaddr); | 340 | bdaddr_t *bdaddr); |
418 | struct inquiry_entry *hci_inquiry_cache_lookup_unknown(struct hci_dev *hdev, | 341 | void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data); |
419 | bdaddr_t *bdaddr); | ||
420 | struct inquiry_entry *hci_inquiry_cache_lookup_resolve(struct hci_dev *hdev, | ||
421 | bdaddr_t *bdaddr, | ||
422 | int state); | ||
423 | void hci_inquiry_cache_update_resolve(struct hci_dev *hdev, | ||
424 | struct inquiry_entry *ie); | ||
425 | bool hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data, | ||
426 | bool name_known, bool *ssp); | ||
427 | 342 | ||
428 | /* ----- HCI Connections ----- */ | 343 | /* ----- HCI Connections ----- */ |
429 | enum { | 344 | enum { |
@@ -433,31 +348,25 @@ enum { | |||
433 | HCI_CONN_RSWITCH_PEND, | 348 | HCI_CONN_RSWITCH_PEND, |
434 | HCI_CONN_MODE_CHANGE_PEND, | 349 | HCI_CONN_MODE_CHANGE_PEND, |
435 | HCI_CONN_SCO_SETUP_PEND, | 350 | HCI_CONN_SCO_SETUP_PEND, |
436 | HCI_CONN_LE_SMP_PEND, | ||
437 | HCI_CONN_MGMT_CONNECTED, | ||
438 | HCI_CONN_SSP_ENABLED, | ||
439 | HCI_CONN_POWER_SAVE, | ||
440 | HCI_CONN_REMOTE_OOB, | ||
441 | }; | 351 | }; |
442 | 352 | ||
443 | static inline bool hci_conn_ssp_enabled(struct hci_conn *conn) | 353 | static inline void hci_conn_hash_init(struct hci_dev *hdev) |
444 | { | 354 | { |
445 | struct hci_dev *hdev = conn->hdev; | 355 | struct hci_conn_hash *h = &hdev->conn_hash; |
446 | return test_bit(HCI_SSP_ENABLED, &hdev->dev_flags) && | 356 | INIT_LIST_HEAD(&h->list); |
447 | test_bit(HCI_CONN_SSP_ENABLED, &conn->flags); | 357 | spin_lock_init(&h->lock); |
358 | h->acl_num = 0; | ||
359 | h->sco_num = 0; | ||
448 | } | 360 | } |
449 | 361 | ||
450 | static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) | 362 | static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) |
451 | { | 363 | { |
452 | struct hci_conn_hash *h = &hdev->conn_hash; | 364 | struct hci_conn_hash *h = &hdev->conn_hash; |
453 | list_add_rcu(&c->list, &h->list); | 365 | list_add(&c->list, &h->list); |
454 | switch (c->type) { | 366 | switch (c->type) { |
455 | case ACL_LINK: | 367 | case ACL_LINK: |
456 | h->acl_num++; | 368 | h->acl_num++; |
457 | break; | 369 | break; |
458 | case AMP_LINK: | ||
459 | h->amp_num++; | ||
460 | break; | ||
461 | case LE_LINK: | 370 | case LE_LINK: |
462 | h->le_num++; | 371 | h->le_num++; |
463 | break; | 372 | break; |
@@ -471,17 +380,11 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c) | |||
471 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) | 380 | static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) |
472 | { | 381 | { |
473 | struct hci_conn_hash *h = &hdev->conn_hash; | 382 | struct hci_conn_hash *h = &hdev->conn_hash; |
474 | 383 | list_del(&c->list); | |
475 | list_del_rcu(&c->list); | ||
476 | synchronize_rcu(); | ||
477 | |||
478 | switch (c->type) { | 384 | switch (c->type) { |
479 | case ACL_LINK: | 385 | case ACL_LINK: |
480 | h->acl_num--; | 386 | h->acl_num--; |
481 | break; | 387 | break; |
482 | case AMP_LINK: | ||
483 | h->amp_num--; | ||
484 | break; | ||
485 | case LE_LINK: | 388 | case LE_LINK: |
486 | h->le_num--; | 389 | h->le_num--; |
487 | break; | 390 | break; |
@@ -492,40 +395,18 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c) | |||
492 | } | 395 | } |
493 | } | 396 | } |
494 | 397 | ||
495 | static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type) | ||
496 | { | ||
497 | struct hci_conn_hash *h = &hdev->conn_hash; | ||
498 | switch (type) { | ||
499 | case ACL_LINK: | ||
500 | return h->acl_num; | ||
501 | case AMP_LINK: | ||
502 | return h->amp_num; | ||
503 | case LE_LINK: | ||
504 | return h->le_num; | ||
505 | case SCO_LINK: | ||
506 | case ESCO_LINK: | ||
507 | return h->sco_num; | ||
508 | default: | ||
509 | return 0; | ||
510 | } | ||
511 | } | ||
512 | |||
513 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, | 398 | static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev, |
514 | __u16 handle) | 399 | __u16 handle) |
515 | { | 400 | { |
516 | struct hci_conn_hash *h = &hdev->conn_hash; | 401 | struct hci_conn_hash *h = &hdev->conn_hash; |
402 | struct list_head *p; | ||
517 | struct hci_conn *c; | 403 | struct hci_conn *c; |
518 | 404 | ||
519 | rcu_read_lock(); | 405 | list_for_each(p, &h->list) { |
520 | 406 | c = list_entry(p, struct hci_conn, list); | |
521 | list_for_each_entry_rcu(c, &h->list, list) { | 407 | if (c->handle == handle) |
522 | if (c->handle == handle) { | ||
523 | rcu_read_unlock(); | ||
524 | return c; | 408 | return c; |
525 | } | ||
526 | } | 409 | } |
527 | rcu_read_unlock(); | ||
528 | |||
529 | return NULL; | 410 | return NULL; |
530 | } | 411 | } |
531 | 412 | ||
@@ -533,19 +414,14 @@ static inline struct hci_conn *hci_conn_hash_lookup_ba(struct hci_dev *hdev, | |||
533 | __u8 type, bdaddr_t *ba) | 414 | __u8 type, bdaddr_t *ba) |
534 | { | 415 | { |
535 | struct hci_conn_hash *h = &hdev->conn_hash; | 416 | struct hci_conn_hash *h = &hdev->conn_hash; |
417 | struct list_head *p; | ||
536 | struct hci_conn *c; | 418 | struct hci_conn *c; |
537 | 419 | ||
538 | rcu_read_lock(); | 420 | list_for_each(p, &h->list) { |
539 | 421 | c = list_entry(p, struct hci_conn, list); | |
540 | list_for_each_entry_rcu(c, &h->list, list) { | 422 | if (c->type == type && !bacmp(&c->dst, ba)) |
541 | if (c->type == type && !bacmp(&c->dst, ba)) { | ||
542 | rcu_read_unlock(); | ||
543 | return c; | 423 | return c; |
544 | } | ||
545 | } | 424 | } |
546 | |||
547 | rcu_read_unlock(); | ||
548 | |||
549 | return NULL; | 425 | return NULL; |
550 | } | 426 | } |
551 | 427 | ||
@@ -553,39 +429,32 @@ static inline struct hci_conn *hci_conn_hash_lookup_state(struct hci_dev *hdev, | |||
553 | __u8 type, __u16 state) | 429 | __u8 type, __u16 state) |
554 | { | 430 | { |
555 | struct hci_conn_hash *h = &hdev->conn_hash; | 431 | struct hci_conn_hash *h = &hdev->conn_hash; |
432 | struct list_head *p; | ||
556 | struct hci_conn *c; | 433 | struct hci_conn *c; |
557 | 434 | ||
558 | rcu_read_lock(); | 435 | list_for_each(p, &h->list) { |
559 | 436 | c = list_entry(p, struct hci_conn, list); | |
560 | list_for_each_entry_rcu(c, &h->list, list) { | 437 | if (c->type == type && c->state == state) |
561 | if (c->type == type && c->state == state) { | ||
562 | rcu_read_unlock(); | ||
563 | return c; | 438 | return c; |
564 | } | ||
565 | } | 439 | } |
566 | |||
567 | rcu_read_unlock(); | ||
568 | |||
569 | return NULL; | 440 | return NULL; |
570 | } | 441 | } |
571 | 442 | ||
443 | void hci_acl_connect(struct hci_conn *conn); | ||
572 | void hci_acl_disconn(struct hci_conn *conn, __u8 reason); | 444 | void hci_acl_disconn(struct hci_conn *conn, __u8 reason); |
445 | void hci_add_sco(struct hci_conn *conn, __u16 handle); | ||
573 | void hci_setup_sync(struct hci_conn *conn, __u16 handle); | 446 | void hci_setup_sync(struct hci_conn *conn, __u16 handle); |
574 | void hci_sco_setup(struct hci_conn *conn, __u8 status); | 447 | void hci_sco_setup(struct hci_conn *conn, __u8 status); |
575 | 448 | ||
576 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst); | 449 | struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, |
450 | __u16 pkt_type, bdaddr_t *dst); | ||
577 | int hci_conn_del(struct hci_conn *conn); | 451 | int hci_conn_del(struct hci_conn *conn); |
578 | void hci_conn_hash_flush(struct hci_dev *hdev); | 452 | void hci_conn_hash_flush(struct hci_dev *hdev); |
579 | void hci_conn_check_pending(struct hci_dev *hdev); | 453 | void hci_conn_check_pending(struct hci_dev *hdev); |
580 | void hci_conn_accept(struct hci_conn *conn, int mask); | ||
581 | |||
582 | struct hci_chan *hci_chan_create(struct hci_conn *conn); | ||
583 | void hci_chan_del(struct hci_chan *chan); | ||
584 | void hci_chan_list_flush(struct hci_conn *conn); | ||
585 | struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); | ||
586 | 454 | ||
587 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, | 455 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, |
588 | __u8 dst_type, __u8 sec_level, __u8 auth_type); | 456 | __u16 pkt_type, bdaddr_t *dst, |
457 | __u8 sec_level, __u8 auth_type); | ||
589 | int hci_conn_check_link_mode(struct hci_conn *conn); | 458 | int hci_conn_check_link_mode(struct hci_conn *conn); |
590 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); | 459 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); |
591 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); | 460 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); |
@@ -593,107 +462,75 @@ int hci_conn_change_link_key(struct hci_conn *conn); | |||
593 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); | 462 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); |
594 | 463 | ||
595 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); | 464 | void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active); |
465 | void hci_conn_enter_sniff_mode(struct hci_conn *conn); | ||
596 | 466 | ||
597 | void hci_conn_hold_device(struct hci_conn *conn); | 467 | void hci_conn_hold_device(struct hci_conn *conn); |
598 | void hci_conn_put_device(struct hci_conn *conn); | 468 | void hci_conn_put_device(struct hci_conn *conn); |
599 | 469 | ||
600 | static inline void hci_conn_hold(struct hci_conn *conn) | 470 | static inline void hci_conn_hold(struct hci_conn *conn) |
601 | { | 471 | { |
602 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); | ||
603 | |||
604 | atomic_inc(&conn->refcnt); | 472 | atomic_inc(&conn->refcnt); |
605 | cancel_delayed_work(&conn->disc_work); | 473 | del_timer(&conn->disc_timer); |
606 | } | 474 | } |
607 | 475 | ||
608 | static inline void hci_conn_put(struct hci_conn *conn) | 476 | static inline void hci_conn_put(struct hci_conn *conn) |
609 | { | 477 | { |
610 | BT_DBG("hcon %p orig refcnt %d", conn, atomic_read(&conn->refcnt)); | ||
611 | |||
612 | if (atomic_dec_and_test(&conn->refcnt)) { | 478 | if (atomic_dec_and_test(&conn->refcnt)) { |
613 | unsigned long timeo; | 479 | unsigned long timeo; |
614 | 480 | if (conn->type == ACL_LINK) { | |
615 | switch (conn->type) { | ||
616 | case ACL_LINK: | ||
617 | case LE_LINK: | ||
618 | del_timer(&conn->idle_timer); | 481 | del_timer(&conn->idle_timer); |
619 | if (conn->state == BT_CONNECTED) { | 482 | if (conn->state == BT_CONNECTED) { |
620 | timeo = conn->disc_timeout; | 483 | timeo = msecs_to_jiffies(conn->disc_timeout); |
621 | if (!conn->out) | 484 | if (!conn->out) |
622 | timeo *= 2; | 485 | timeo *= 20; |
623 | } else { | 486 | } else { |
624 | timeo = msecs_to_jiffies(10); | 487 | timeo = msecs_to_jiffies(10); |
625 | } | 488 | } |
626 | break; | 489 | } else { |
627 | |||
628 | case AMP_LINK: | ||
629 | timeo = conn->disc_timeout; | ||
630 | break; | ||
631 | |||
632 | default: | ||
633 | timeo = msecs_to_jiffies(10); | 490 | timeo = msecs_to_jiffies(10); |
634 | break; | ||
635 | } | 491 | } |
636 | 492 | mod_timer(&conn->disc_timer, jiffies + timeo); | |
637 | cancel_delayed_work(&conn->disc_work); | ||
638 | queue_delayed_work(conn->hdev->workqueue, | ||
639 | &conn->disc_work, timeo); | ||
640 | } | 493 | } |
641 | } | 494 | } |
642 | 495 | ||
643 | /* ----- HCI Devices ----- */ | 496 | /* ----- HCI Devices ----- */ |
644 | static inline void hci_dev_put(struct hci_dev *d) | 497 | static inline void __hci_dev_put(struct hci_dev *d) |
645 | { | 498 | { |
646 | BT_DBG("%s orig refcnt %d", d->name, | 499 | if (atomic_dec_and_test(&d->refcnt)) |
647 | atomic_read(&d->dev.kobj.kref.refcount)); | 500 | d->destruct(d); |
648 | |||
649 | put_device(&d->dev); | ||
650 | } | 501 | } |
651 | 502 | ||
652 | static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) | 503 | static inline void hci_dev_put(struct hci_dev *d) |
653 | { | 504 | { |
654 | BT_DBG("%s orig refcnt %d", d->name, | 505 | __hci_dev_put(d); |
655 | atomic_read(&d->dev.kobj.kref.refcount)); | 506 | module_put(d->owner); |
656 | |||
657 | get_device(&d->dev); | ||
658 | return d; | ||
659 | } | 507 | } |
660 | 508 | ||
661 | #define hci_dev_lock(d) mutex_lock(&d->lock) | 509 | static inline struct hci_dev *__hci_dev_hold(struct hci_dev *d) |
662 | #define hci_dev_unlock(d) mutex_unlock(&d->lock) | ||
663 | |||
664 | #define to_hci_dev(d) container_of(d, struct hci_dev, dev) | ||
665 | #define to_hci_conn(c) container_of(c, struct hci_conn, dev) | ||
666 | |||
667 | static inline void *hci_get_drvdata(struct hci_dev *hdev) | ||
668 | { | 510 | { |
669 | return dev_get_drvdata(&hdev->dev); | 511 | atomic_inc(&d->refcnt); |
512 | return d; | ||
670 | } | 513 | } |
671 | 514 | ||
672 | static inline void hci_set_drvdata(struct hci_dev *hdev, void *data) | 515 | static inline struct hci_dev *hci_dev_hold(struct hci_dev *d) |
673 | { | 516 | { |
674 | dev_set_drvdata(&hdev->dev, data); | 517 | if (try_module_get(d->owner)) |
518 | return __hci_dev_hold(d); | ||
519 | return NULL; | ||
675 | } | 520 | } |
676 | 521 | ||
677 | /* hci_dev_list shall be locked */ | 522 | #define hci_dev_lock(d) spin_lock(&d->lock) |
678 | static inline uint8_t __hci_num_ctrl(void) | 523 | #define hci_dev_unlock(d) spin_unlock(&d->lock) |
679 | { | 524 | #define hci_dev_lock_bh(d) spin_lock_bh(&d->lock) |
680 | uint8_t count = 0; | 525 | #define hci_dev_unlock_bh(d) spin_unlock_bh(&d->lock) |
681 | struct list_head *p; | ||
682 | |||
683 | list_for_each(p, &hci_dev_list) { | ||
684 | count++; | ||
685 | } | ||
686 | |||
687 | return count; | ||
688 | } | ||
689 | 526 | ||
690 | struct hci_dev *hci_dev_get(int index); | 527 | struct hci_dev *hci_dev_get(int index); |
691 | struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src); | 528 | struct hci_dev *hci_get_route(bdaddr_t *src, bdaddr_t *dst); |
692 | 529 | ||
693 | struct hci_dev *hci_alloc_dev(void); | 530 | struct hci_dev *hci_alloc_dev(void); |
694 | void hci_free_dev(struct hci_dev *hdev); | 531 | void hci_free_dev(struct hci_dev *hdev); |
695 | int hci_register_dev(struct hci_dev *hdev); | 532 | int hci_register_dev(struct hci_dev *hdev); |
696 | void hci_unregister_dev(struct hci_dev *hdev); | 533 | int hci_unregister_dev(struct hci_dev *hdev); |
697 | int hci_suspend_dev(struct hci_dev *hdev); | 534 | int hci_suspend_dev(struct hci_dev *hdev); |
698 | int hci_resume_dev(struct hci_dev *hdev); | 535 | int hci_resume_dev(struct hci_dev *hdev); |
699 | int hci_dev_open(__u16 dev); | 536 | int hci_dev_open(__u16 dev); |
@@ -708,26 +545,22 @@ int hci_get_conn_info(struct hci_dev *hdev, void __user *arg); | |||
708 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); | 545 | int hci_get_auth_info(struct hci_dev *hdev, void __user *arg); |
709 | int hci_inquiry(void __user *arg); | 546 | int hci_inquiry(void __user *arg); |
710 | 547 | ||
711 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, | 548 | struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); |
712 | bdaddr_t *bdaddr); | ||
713 | int hci_blacklist_clear(struct hci_dev *hdev); | 549 | int hci_blacklist_clear(struct hci_dev *hdev); |
714 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | 550 | int hci_blacklist_add(struct hci_dev *hdev, bdaddr_t *bdaddr); |
715 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | 551 | int hci_blacklist_del(struct hci_dev *hdev, bdaddr_t *bdaddr); |
716 | 552 | ||
717 | int hci_uuids_clear(struct hci_dev *hdev); | 553 | int hci_uuids_clear(struct hci_dev *hdev); |
718 | 554 | ||
719 | int hci_link_keys_clear(struct hci_dev *hdev); | 555 | int hci_link_keys_clear(struct hci_dev *hdev); |
720 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | 556 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
721 | int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, | 557 | int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key, |
722 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); | 558 | bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len); |
723 | struct smp_ltk *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); | 559 | struct link_key *hci_find_ltk(struct hci_dev *hdev, __le16 ediv, u8 rand[8]); |
724 | int hci_add_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 addr_type, u8 type, | 560 | struct link_key *hci_find_link_key_type(struct hci_dev *hdev, |
725 | int new_key, u8 authenticated, u8 tk[16], u8 enc_size, | 561 | bdaddr_t *bdaddr, u8 type); |
726 | __le16 ediv, u8 rand[8]); | 562 | int hci_add_ltk(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, |
727 | struct smp_ltk *hci_find_ltk_by_addr(struct hci_dev *hdev, bdaddr_t *bdaddr, | 563 | u8 key_size, __le16 ediv, u8 rand[8], u8 ltk[16]); |
728 | u8 addr_type); | ||
729 | int hci_remove_ltk(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
730 | int hci_smp_ltks_clear(struct hci_dev *hdev); | ||
731 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | 564 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
732 | 565 | ||
733 | int hci_remote_oob_data_clear(struct hci_dev *hdev); | 566 | int hci_remote_oob_data_clear(struct hci_dev *hdev); |
@@ -737,7 +570,13 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, | |||
737 | u8 *randomizer); | 570 | u8 *randomizer); |
738 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); | 571 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); |
739 | 572 | ||
740 | int hci_update_ad(struct hci_dev *hdev); | 573 | #define ADV_CLEAR_TIMEOUT (3*60*HZ) /* Three minutes */ |
574 | int hci_adv_entries_clear(struct hci_dev *hdev); | ||
575 | struct adv_entry *hci_find_adv_entry(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
576 | int hci_add_adv_entry(struct hci_dev *hdev, | ||
577 | struct hci_ev_le_advertising_info *ev); | ||
578 | |||
579 | void hci_del_off_timer(struct hci_dev *hdev); | ||
741 | 580 | ||
742 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); | 581 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); |
743 | 582 | ||
@@ -745,93 +584,75 @@ int hci_recv_frame(struct sk_buff *skb); | |||
745 | int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); | 584 | int hci_recv_fragment(struct hci_dev *hdev, int type, void *data, int count); |
746 | int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); | 585 | int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count); |
747 | 586 | ||
748 | void hci_init_sysfs(struct hci_dev *hdev); | 587 | int hci_register_sysfs(struct hci_dev *hdev); |
749 | int hci_add_sysfs(struct hci_dev *hdev); | 588 | void hci_unregister_sysfs(struct hci_dev *hdev); |
750 | void hci_del_sysfs(struct hci_dev *hdev); | ||
751 | void hci_conn_init_sysfs(struct hci_conn *conn); | 589 | void hci_conn_init_sysfs(struct hci_conn *conn); |
752 | void hci_conn_add_sysfs(struct hci_conn *conn); | 590 | void hci_conn_add_sysfs(struct hci_conn *conn); |
753 | void hci_conn_del_sysfs(struct hci_conn *conn); | 591 | void hci_conn_del_sysfs(struct hci_conn *conn); |
754 | 592 | ||
755 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->dev.parent = (pdev)) | 593 | #define SET_HCIDEV_DEV(hdev, pdev) ((hdev)->parent = (pdev)) |
756 | 594 | ||
757 | /* ----- LMP capabilities ----- */ | 595 | /* ----- LMP capabilities ----- */ |
758 | #define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT) | ||
759 | #define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH) | 596 | #define lmp_rswitch_capable(dev) ((dev)->features[0] & LMP_RSWITCH) |
760 | #define lmp_hold_capable(dev) ((dev)->features[0] & LMP_HOLD) | 597 | #define lmp_encrypt_capable(dev) ((dev)->features[0] & LMP_ENCRYPT) |
761 | #define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF) | 598 | #define lmp_sniff_capable(dev) ((dev)->features[0] & LMP_SNIFF) |
762 | #define lmp_park_capable(dev) ((dev)->features[1] & LMP_PARK) | ||
763 | #define lmp_inq_rssi_capable(dev) ((dev)->features[3] & LMP_RSSI_INQ) | ||
764 | #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) | ||
765 | #define lmp_bredr_capable(dev) (!((dev)->features[4] & LMP_NO_BREDR)) | ||
766 | #define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) | ||
767 | #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) | 599 | #define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR) |
768 | #define lmp_pause_enc_capable(dev) ((dev)->features[5] & LMP_PAUSE_ENC) | 600 | #define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO) |
769 | #define lmp_ext_inq_capable(dev) ((dev)->features[6] & LMP_EXT_INQ) | ||
770 | #define lmp_le_br_capable(dev) !!((dev)->features[6] & LMP_SIMUL_LE_BR) | ||
771 | #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) | 601 | #define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR) |
772 | #define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) | 602 | #define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH) |
773 | #define lmp_lsto_capable(dev) ((dev)->features[7] & LMP_LSTO) | 603 | #define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE) |
774 | #define lmp_inq_tx_pwr_capable(dev) ((dev)->features[7] & LMP_INQ_TX_PWR) | ||
775 | #define lmp_ext_feat_capable(dev) ((dev)->features[7] & LMP_EXTFEATURES) | ||
776 | 604 | ||
777 | /* ----- Extended LMP capabilities ----- */ | 605 | /* ----- Extended LMP capabilities ----- */ |
778 | #define lmp_host_ssp_capable(dev) ((dev)->host_features[0] & LMP_HOST_SSP) | 606 | #define lmp_host_le_capable(dev) ((dev)->extfeatures[0] & LMP_HOST_LE) |
779 | #define lmp_host_le_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE) | ||
780 | #define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR) | ||
781 | |||
782 | /* returns true if at least one AMP active */ | ||
783 | static inline bool hci_amp_capable(void) | ||
784 | { | ||
785 | struct hci_dev *hdev; | ||
786 | bool ret = false; | ||
787 | |||
788 | read_lock(&hci_dev_list_lock); | ||
789 | list_for_each_entry(hdev, &hci_dev_list, list) | ||
790 | if (hdev->amp_type == HCI_AMP && | ||
791 | test_bit(HCI_UP, &hdev->flags)) | ||
792 | ret = true; | ||
793 | read_unlock(&hci_dev_list_lock); | ||
794 | |||
795 | return ret; | ||
796 | } | ||
797 | 607 | ||
798 | /* ----- HCI protocols ----- */ | 608 | /* ----- HCI protocols ----- */ |
799 | #define HCI_PROTO_DEFER 0x01 | 609 | struct hci_proto { |
610 | char *name; | ||
611 | unsigned int id; | ||
612 | unsigned long flags; | ||
613 | |||
614 | void *priv; | ||
615 | |||
616 | int (*connect_ind) (struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
617 | __u8 type); | ||
618 | int (*connect_cfm) (struct hci_conn *conn, __u8 status); | ||
619 | int (*disconn_ind) (struct hci_conn *conn); | ||
620 | int (*disconn_cfm) (struct hci_conn *conn, __u8 reason); | ||
621 | int (*recv_acldata) (struct hci_conn *conn, struct sk_buff *skb, | ||
622 | __u16 flags); | ||
623 | int (*recv_scodata) (struct hci_conn *conn, struct sk_buff *skb); | ||
624 | int (*security_cfm) (struct hci_conn *conn, __u8 status, | ||
625 | __u8 encrypt); | ||
626 | }; | ||
800 | 627 | ||
801 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, | 628 | static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, |
802 | __u8 type, __u8 *flags) | 629 | __u8 type) |
803 | { | 630 | { |
804 | switch (type) { | 631 | register struct hci_proto *hp; |
805 | case ACL_LINK: | 632 | int mask = 0; |
806 | return l2cap_connect_ind(hdev, bdaddr); | ||
807 | 633 | ||
808 | case SCO_LINK: | 634 | hp = hci_proto[HCI_PROTO_L2CAP]; |
809 | case ESCO_LINK: | 635 | if (hp && hp->connect_ind) |
810 | return sco_connect_ind(hdev, bdaddr, flags); | 636 | mask |= hp->connect_ind(hdev, bdaddr, type); |
811 | 637 | ||
812 | default: | 638 | hp = hci_proto[HCI_PROTO_SCO]; |
813 | BT_ERR("unknown link type %d", type); | 639 | if (hp && hp->connect_ind) |
814 | return -EINVAL; | 640 | mask |= hp->connect_ind(hdev, bdaddr, type); |
815 | } | 641 | |
642 | return mask; | ||
816 | } | 643 | } |
817 | 644 | ||
818 | static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) | 645 | static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) |
819 | { | 646 | { |
820 | switch (conn->type) { | 647 | register struct hci_proto *hp; |
821 | case ACL_LINK: | ||
822 | case LE_LINK: | ||
823 | l2cap_connect_cfm(conn, status); | ||
824 | break; | ||
825 | 648 | ||
826 | case SCO_LINK: | 649 | hp = hci_proto[HCI_PROTO_L2CAP]; |
827 | case ESCO_LINK: | 650 | if (hp && hp->connect_cfm) |
828 | sco_connect_cfm(conn, status); | 651 | hp->connect_cfm(conn, status); |
829 | break; | ||
830 | 652 | ||
831 | default: | 653 | hp = hci_proto[HCI_PROTO_SCO]; |
832 | BT_ERR("unknown link type %d", conn->type); | 654 | if (hp && hp->connect_cfm) |
833 | break; | 655 | hp->connect_cfm(conn, status); |
834 | } | ||
835 | 656 | ||
836 | if (conn->connect_cfm_cb) | 657 | if (conn->connect_cfm_cb) |
837 | conn->connect_cfm_cb(conn, status); | 658 | conn->connect_cfm_cb(conn, status); |
@@ -839,33 +660,31 @@ static inline void hci_proto_connect_cfm(struct hci_conn *conn, __u8 status) | |||
839 | 660 | ||
840 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) | 661 | static inline int hci_proto_disconn_ind(struct hci_conn *conn) |
841 | { | 662 | { |
842 | if (conn->type != ACL_LINK && conn->type != LE_LINK) | 663 | register struct hci_proto *hp; |
843 | return HCI_ERROR_REMOTE_USER_TERM; | 664 | int reason = 0x13; |
665 | |||
666 | hp = hci_proto[HCI_PROTO_L2CAP]; | ||
667 | if (hp && hp->disconn_ind) | ||
668 | reason = hp->disconn_ind(conn); | ||
669 | |||
670 | hp = hci_proto[HCI_PROTO_SCO]; | ||
671 | if (hp && hp->disconn_ind) | ||
672 | reason = hp->disconn_ind(conn); | ||
844 | 673 | ||
845 | return l2cap_disconn_ind(conn); | 674 | return reason; |
846 | } | 675 | } |
847 | 676 | ||
848 | static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) | 677 | static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) |
849 | { | 678 | { |
850 | switch (conn->type) { | 679 | register struct hci_proto *hp; |
851 | case ACL_LINK: | ||
852 | case LE_LINK: | ||
853 | l2cap_disconn_cfm(conn, reason); | ||
854 | break; | ||
855 | |||
856 | case SCO_LINK: | ||
857 | case ESCO_LINK: | ||
858 | sco_disconn_cfm(conn, reason); | ||
859 | break; | ||
860 | 680 | ||
861 | /* L2CAP would be handled for BREDR chan */ | 681 | hp = hci_proto[HCI_PROTO_L2CAP]; |
862 | case AMP_LINK: | 682 | if (hp && hp->disconn_cfm) |
863 | break; | 683 | hp->disconn_cfm(conn, reason); |
864 | 684 | ||
865 | default: | 685 | hp = hci_proto[HCI_PROTO_SCO]; |
866 | BT_ERR("unknown link type %d", conn->type); | 686 | if (hp && hp->disconn_cfm) |
867 | break; | 687 | hp->disconn_cfm(conn, reason); |
868 | } | ||
869 | 688 | ||
870 | if (conn->disconn_cfm_cb) | 689 | if (conn->disconn_cfm_cb) |
871 | conn->disconn_cfm_cb(conn, reason); | 690 | conn->disconn_cfm_cb(conn, reason); |
@@ -873,16 +692,21 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason) | |||
873 | 692 | ||
874 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) | 693 | static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) |
875 | { | 694 | { |
695 | register struct hci_proto *hp; | ||
876 | __u8 encrypt; | 696 | __u8 encrypt; |
877 | 697 | ||
878 | if (conn->type != ACL_LINK && conn->type != LE_LINK) | 698 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) |
879 | return; | ||
880 | |||
881 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) | ||
882 | return; | 699 | return; |
883 | 700 | ||
884 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; | 701 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; |
885 | l2cap_security_cfm(conn, status, encrypt); | 702 | |
703 | hp = hci_proto[HCI_PROTO_L2CAP]; | ||
704 | if (hp && hp->security_cfm) | ||
705 | hp->security_cfm(conn, status, encrypt); | ||
706 | |||
707 | hp = hci_proto[HCI_PROTO_SCO]; | ||
708 | if (hp && hp->security_cfm) | ||
709 | hp->security_cfm(conn, status, encrypt); | ||
886 | 710 | ||
887 | if (conn->security_cfm_cb) | 711 | if (conn->security_cfm_cb) |
888 | conn->security_cfm_cb(conn, status); | 712 | conn->security_cfm_cb(conn, status); |
@@ -891,15 +715,23 @@ static inline void hci_proto_auth_cfm(struct hci_conn *conn, __u8 status) | |||
891 | static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, | 715 | static inline void hci_proto_encrypt_cfm(struct hci_conn *conn, __u8 status, |
892 | __u8 encrypt) | 716 | __u8 encrypt) |
893 | { | 717 | { |
894 | if (conn->type != ACL_LINK && conn->type != LE_LINK) | 718 | register struct hci_proto *hp; |
895 | return; | 719 | |
720 | hp = hci_proto[HCI_PROTO_L2CAP]; | ||
721 | if (hp && hp->security_cfm) | ||
722 | hp->security_cfm(conn, status, encrypt); | ||
896 | 723 | ||
897 | l2cap_security_cfm(conn, status, encrypt); | 724 | hp = hci_proto[HCI_PROTO_SCO]; |
725 | if (hp && hp->security_cfm) | ||
726 | hp->security_cfm(conn, status, encrypt); | ||
898 | 727 | ||
899 | if (conn->security_cfm_cb) | 728 | if (conn->security_cfm_cb) |
900 | conn->security_cfm_cb(conn, status); | 729 | conn->security_cfm_cb(conn, status); |
901 | } | 730 | } |
902 | 731 | ||
732 | int hci_register_proto(struct hci_proto *hproto); | ||
733 | int hci_unregister_proto(struct hci_proto *hproto); | ||
734 | |||
903 | /* ----- HCI callbacks ----- */ | 735 | /* ----- HCI callbacks ----- */ |
904 | struct hci_cb { | 736 | struct hci_cb { |
905 | struct list_head list; | 737 | struct list_head list; |
@@ -914,28 +746,29 @@ struct hci_cb { | |||
914 | 746 | ||
915 | static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) | 747 | static inline void hci_auth_cfm(struct hci_conn *conn, __u8 status) |
916 | { | 748 | { |
917 | struct hci_cb *cb; | 749 | struct list_head *p; |
918 | __u8 encrypt; | 750 | __u8 encrypt; |
919 | 751 | ||
920 | hci_proto_auth_cfm(conn, status); | 752 | hci_proto_auth_cfm(conn, status); |
921 | 753 | ||
922 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->flags)) | 754 | if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) |
923 | return; | 755 | return; |
924 | 756 | ||
925 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; | 757 | encrypt = (conn->link_mode & HCI_LM_ENCRYPT) ? 0x01 : 0x00; |
926 | 758 | ||
927 | read_lock(&hci_cb_list_lock); | 759 | read_lock_bh(&hci_cb_list_lock); |
928 | list_for_each_entry(cb, &hci_cb_list, list) { | 760 | list_for_each(p, &hci_cb_list) { |
761 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | ||
929 | if (cb->security_cfm) | 762 | if (cb->security_cfm) |
930 | cb->security_cfm(conn, status, encrypt); | 763 | cb->security_cfm(conn, status, encrypt); |
931 | } | 764 | } |
932 | read_unlock(&hci_cb_list_lock); | 765 | read_unlock_bh(&hci_cb_list_lock); |
933 | } | 766 | } |
934 | 767 | ||
935 | static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, | 768 | static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, |
936 | __u8 encrypt) | 769 | __u8 encrypt) |
937 | { | 770 | { |
938 | struct hci_cb *cb; | 771 | struct list_head *p; |
939 | 772 | ||
940 | if (conn->sec_level == BT_SECURITY_SDP) | 773 | if (conn->sec_level == BT_SECURITY_SDP) |
941 | conn->sec_level = BT_SECURITY_LOW; | 774 | conn->sec_level = BT_SECURITY_LOW; |
@@ -945,180 +778,88 @@ static inline void hci_encrypt_cfm(struct hci_conn *conn, __u8 status, | |||
945 | 778 | ||
946 | hci_proto_encrypt_cfm(conn, status, encrypt); | 779 | hci_proto_encrypt_cfm(conn, status, encrypt); |
947 | 780 | ||
948 | read_lock(&hci_cb_list_lock); | 781 | read_lock_bh(&hci_cb_list_lock); |
949 | list_for_each_entry(cb, &hci_cb_list, list) { | 782 | list_for_each(p, &hci_cb_list) { |
783 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | ||
950 | if (cb->security_cfm) | 784 | if (cb->security_cfm) |
951 | cb->security_cfm(conn, status, encrypt); | 785 | cb->security_cfm(conn, status, encrypt); |
952 | } | 786 | } |
953 | read_unlock(&hci_cb_list_lock); | 787 | read_unlock_bh(&hci_cb_list_lock); |
954 | } | 788 | } |
955 | 789 | ||
956 | static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) | 790 | static inline void hci_key_change_cfm(struct hci_conn *conn, __u8 status) |
957 | { | 791 | { |
958 | struct hci_cb *cb; | 792 | struct list_head *p; |
959 | 793 | ||
960 | read_lock(&hci_cb_list_lock); | 794 | read_lock_bh(&hci_cb_list_lock); |
961 | list_for_each_entry(cb, &hci_cb_list, list) { | 795 | list_for_each(p, &hci_cb_list) { |
796 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | ||
962 | if (cb->key_change_cfm) | 797 | if (cb->key_change_cfm) |
963 | cb->key_change_cfm(conn, status); | 798 | cb->key_change_cfm(conn, status); |
964 | } | 799 | } |
965 | read_unlock(&hci_cb_list_lock); | 800 | read_unlock_bh(&hci_cb_list_lock); |
966 | } | 801 | } |
967 | 802 | ||
968 | static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, | 803 | static inline void hci_role_switch_cfm(struct hci_conn *conn, __u8 status, |
969 | __u8 role) | 804 | __u8 role) |
970 | { | 805 | { |
971 | struct hci_cb *cb; | 806 | struct list_head *p; |
972 | 807 | ||
973 | read_lock(&hci_cb_list_lock); | 808 | read_lock_bh(&hci_cb_list_lock); |
974 | list_for_each_entry(cb, &hci_cb_list, list) { | 809 | list_for_each(p, &hci_cb_list) { |
810 | struct hci_cb *cb = list_entry(p, struct hci_cb, list); | ||
975 | if (cb->role_switch_cfm) | 811 | if (cb->role_switch_cfm) |
976 | cb->role_switch_cfm(conn, status, role); | 812 | cb->role_switch_cfm(conn, status, role); |
977 | } | 813 | } |
978 | read_unlock(&hci_cb_list_lock); | 814 | read_unlock_bh(&hci_cb_list_lock); |
979 | } | ||
980 | |||
981 | static inline bool eir_has_data_type(u8 *data, size_t data_len, u8 type) | ||
982 | { | ||
983 | size_t parsed = 0; | ||
984 | |||
985 | if (data_len < 2) | ||
986 | return false; | ||
987 | |||
988 | while (parsed < data_len - 1) { | ||
989 | u8 field_len = data[0]; | ||
990 | |||
991 | if (field_len == 0) | ||
992 | break; | ||
993 | |||
994 | parsed += field_len + 1; | ||
995 | |||
996 | if (parsed > data_len) | ||
997 | break; | ||
998 | |||
999 | if (data[1] == type) | ||
1000 | return true; | ||
1001 | |||
1002 | data += field_len + 1; | ||
1003 | } | ||
1004 | |||
1005 | return false; | ||
1006 | } | ||
1007 | |||
1008 | static inline size_t eir_get_length(u8 *eir, size_t eir_len) | ||
1009 | { | ||
1010 | size_t parsed = 0; | ||
1011 | |||
1012 | while (parsed < eir_len) { | ||
1013 | u8 field_len = eir[0]; | ||
1014 | |||
1015 | if (field_len == 0) | ||
1016 | return parsed; | ||
1017 | |||
1018 | parsed += field_len + 1; | ||
1019 | eir += field_len + 1; | ||
1020 | } | ||
1021 | |||
1022 | return eir_len; | ||
1023 | } | ||
1024 | |||
1025 | static inline u16 eir_append_data(u8 *eir, u16 eir_len, u8 type, u8 *data, | ||
1026 | u8 data_len) | ||
1027 | { | ||
1028 | eir[eir_len++] = sizeof(type) + data_len; | ||
1029 | eir[eir_len++] = type; | ||
1030 | memcpy(&eir[eir_len], data, data_len); | ||
1031 | eir_len += data_len; | ||
1032 | |||
1033 | return eir_len; | ||
1034 | } | 815 | } |
1035 | 816 | ||
1036 | int hci_register_cb(struct hci_cb *hcb); | 817 | int hci_register_cb(struct hci_cb *hcb); |
1037 | int hci_unregister_cb(struct hci_cb *hcb); | 818 | int hci_unregister_cb(struct hci_cb *hcb); |
1038 | 819 | ||
820 | int hci_register_notifier(struct notifier_block *nb); | ||
821 | int hci_unregister_notifier(struct notifier_block *nb); | ||
822 | |||
1039 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); | 823 | int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param); |
1040 | void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags); | 824 | void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags); |
1041 | void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); | 825 | void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb); |
1042 | 826 | ||
1043 | void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); | 827 | void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode); |
1044 | 828 | ||
1045 | /* ----- HCI Sockets ----- */ | 829 | void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data); |
1046 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb); | ||
1047 | void hci_send_to_control(struct sk_buff *skb, struct sock *skip_sk); | ||
1048 | void hci_send_to_monitor(struct hci_dev *hdev, struct sk_buff *skb); | ||
1049 | 830 | ||
1050 | void hci_sock_dev_event(struct hci_dev *hdev, int event); | 831 | /* ----- HCI Sockets ----- */ |
832 | void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb, | ||
833 | struct sock *skip_sk); | ||
1051 | 834 | ||
1052 | /* Management interface */ | 835 | /* Management interface */ |
1053 | #define DISCOV_TYPE_BREDR (BIT(BDADDR_BREDR)) | ||
1054 | #define DISCOV_TYPE_LE (BIT(BDADDR_LE_PUBLIC) | \ | ||
1055 | BIT(BDADDR_LE_RANDOM)) | ||
1056 | #define DISCOV_TYPE_INTERLEAVED (BIT(BDADDR_BREDR) | \ | ||
1057 | BIT(BDADDR_LE_PUBLIC) | \ | ||
1058 | BIT(BDADDR_LE_RANDOM)) | ||
1059 | |||
1060 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); | 836 | int mgmt_control(struct sock *sk, struct msghdr *msg, size_t len); |
1061 | int mgmt_index_added(struct hci_dev *hdev); | 837 | int mgmt_index_added(u16 index); |
1062 | int mgmt_index_removed(struct hci_dev *hdev); | 838 | int mgmt_index_removed(u16 index); |
1063 | int mgmt_powered(struct hci_dev *hdev, u8 powered); | 839 | int mgmt_powered(u16 index, u8 powered); |
1064 | int mgmt_discoverable(struct hci_dev *hdev, u8 discoverable); | 840 | int mgmt_discoverable(u16 index, u8 discoverable); |
1065 | int mgmt_connectable(struct hci_dev *hdev, u8 connectable); | 841 | int mgmt_connectable(u16 index, u8 connectable); |
1066 | int mgmt_write_scan_failed(struct hci_dev *hdev, u8 scan, u8 status); | 842 | int mgmt_new_key(u16 index, struct link_key *key, u8 persistent); |
1067 | int mgmt_new_link_key(struct hci_dev *hdev, struct link_key *key, | 843 | int mgmt_connected(u16 index, bdaddr_t *bdaddr); |
1068 | bool persistent); | 844 | int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); |
1069 | int mgmt_device_connected(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | 845 | int mgmt_disconnect_failed(u16 index); |
1070 | u8 addr_type, u32 flags, u8 *name, u8 name_len, | 846 | int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); |
1071 | u8 *dev_class); | 847 | int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure); |
1072 | int mgmt_device_disconnected(struct hci_dev *hdev, bdaddr_t *bdaddr, | 848 | int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
1073 | u8 link_type, u8 addr_type, u8 reason); | 849 | int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
1074 | int mgmt_disconnect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, | 850 | int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, |
1075 | u8 link_type, u8 addr_type, u8 status); | 851 | u8 confirm_hint); |
1076 | int mgmt_connect_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | 852 | int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
1077 | u8 addr_type, u8 status); | 853 | int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, |
1078 | int mgmt_pin_code_request(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 secure); | 854 | u8 status); |
1079 | int mgmt_pin_code_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | 855 | int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); |
1080 | u8 status); | 856 | int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); |
1081 | int mgmt_pin_code_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | 857 | int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, |
1082 | u8 status); | 858 | u8 status); |
1083 | int mgmt_user_confirm_request(struct hci_dev *hdev, bdaddr_t *bdaddr, | 859 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, |
1084 | u8 link_type, u8 addr_type, __le32 value, | 860 | u8 *eir); |
1085 | u8 confirm_hint); | 861 | int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); |
1086 | int mgmt_user_confirm_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | 862 | int mgmt_discovering(u16 index, u8 discovering); |
1087 | u8 link_type, u8 addr_type, u8 status); | ||
1088 | int mgmt_user_confirm_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
1089 | u8 link_type, u8 addr_type, u8 status); | ||
1090 | int mgmt_user_passkey_request(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
1091 | u8 link_type, u8 addr_type); | ||
1092 | int mgmt_user_passkey_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
1093 | u8 link_type, u8 addr_type, u8 status); | ||
1094 | int mgmt_user_passkey_neg_reply_complete(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
1095 | u8 link_type, u8 addr_type, u8 status); | ||
1096 | int mgmt_user_passkey_notify(struct hci_dev *hdev, bdaddr_t *bdaddr, | ||
1097 | u8 link_type, u8 addr_type, u32 passkey, | ||
1098 | u8 entered); | ||
1099 | int mgmt_auth_failed(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | ||
1100 | u8 addr_type, u8 status); | ||
1101 | int mgmt_auth_enable_complete(struct hci_dev *hdev, u8 status); | ||
1102 | int mgmt_ssp_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); | ||
1103 | int mgmt_set_class_of_dev_complete(struct hci_dev *hdev, u8 *dev_class, | ||
1104 | u8 status); | ||
1105 | int mgmt_set_local_name_complete(struct hci_dev *hdev, u8 *name, u8 status); | ||
1106 | int mgmt_read_local_oob_data_reply_complete(struct hci_dev *hdev, u8 *hash, | ||
1107 | u8 *randomizer, u8 status); | ||
1108 | int mgmt_le_enable_complete(struct hci_dev *hdev, u8 enable, u8 status); | ||
1109 | int mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | ||
1110 | u8 addr_type, u8 *dev_class, s8 rssi, u8 cfm_name, | ||
1111 | u8 ssp, u8 *eir, u16 eir_len); | ||
1112 | int mgmt_remote_name(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, | ||
1113 | u8 addr_type, s8 rssi, u8 *name, u8 name_len); | ||
1114 | int mgmt_start_discovery_failed(struct hci_dev *hdev, u8 status); | ||
1115 | int mgmt_stop_discovery_failed(struct hci_dev *hdev, u8 status); | ||
1116 | int mgmt_discovering(struct hci_dev *hdev, u8 discovering); | ||
1117 | int mgmt_interleaved_discovery(struct hci_dev *hdev); | ||
1118 | int mgmt_device_blocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | ||
1119 | int mgmt_device_unblocked(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type); | ||
1120 | bool mgmt_valid_hdev(struct hci_dev *hdev); | ||
1121 | int mgmt_new_ltk(struct hci_dev *hdev, struct smp_ltk *key, u8 persistent); | ||
1122 | 863 | ||
1123 | /* HCI info for socket */ | 864 | /* HCI info for socket */ |
1124 | #define hci_pi(sk) ((struct hci_pinfo *) sk) | 865 | #define hci_pi(sk) ((struct hci_pinfo *) sk) |
@@ -1154,12 +895,7 @@ void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max, | |||
1154 | u16 latency, u16 to_multiplier); | 895 | u16 latency, u16 to_multiplier); |
1155 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], | 896 | void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8], |
1156 | __u8 ltk[16]); | 897 | __u8 ltk[16]); |
1157 | int hci_do_inquiry(struct hci_dev *hdev, u8 length); | 898 | void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]); |
1158 | int hci_cancel_inquiry(struct hci_dev *hdev); | 899 | void hci_le_ltk_neg_reply(struct hci_conn *conn); |
1159 | int hci_le_scan(struct hci_dev *hdev, u8 type, u16 interval, u16 window, | ||
1160 | int timeout); | ||
1161 | int hci_cancel_le_scan(struct hci_dev *hdev); | ||
1162 | |||
1163 | u8 bdaddr_to_le(u8 bdaddr_type); | ||
1164 | 900 | ||
1165 | #endif /* __HCI_CORE_H */ | 901 | #endif /* __HCI_CORE_H */ |
diff --git a/include/net/bluetooth/hci_mon.h b/include/net/bluetooth/hci_mon.h deleted file mode 100644 index 77d1e576418..00000000000 --- a/include/net/bluetooth/hci_mon.h +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | /* | ||
2 | BlueZ - Bluetooth protocol stack for Linux | ||
3 | |||
4 | Copyright (C) 2011-2012 Intel 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 | #ifndef __HCI_MON_H | ||
25 | #define __HCI_MON_H | ||
26 | |||
27 | struct hci_mon_hdr { | ||
28 | __le16 opcode; | ||
29 | __le16 index; | ||
30 | __le16 len; | ||
31 | } __packed; | ||
32 | #define HCI_MON_HDR_SIZE 6 | ||
33 | |||
34 | #define HCI_MON_NEW_INDEX 0 | ||
35 | #define HCI_MON_DEL_INDEX 1 | ||
36 | #define HCI_MON_COMMAND_PKT 2 | ||
37 | #define HCI_MON_EVENT_PKT 3 | ||
38 | #define HCI_MON_ACL_TX_PKT 4 | ||
39 | #define HCI_MON_ACL_RX_PKT 5 | ||
40 | #define HCI_MON_SCO_TX_PKT 6 | ||
41 | #define HCI_MON_SCO_RX_PKT 7 | ||
42 | |||
43 | struct hci_mon_new_index { | ||
44 | __u8 type; | ||
45 | __u8 bus; | ||
46 | bdaddr_t bdaddr; | ||
47 | char name[8]; | ||
48 | } __packed; | ||
49 | #define HCI_MON_NEW_INDEX_SIZE 16 | ||
50 | |||
51 | #endif /* __HCI_MON_H */ | ||
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index 7588ef44eba..4f34ad25e75 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h | |||
@@ -27,35 +27,20 @@ | |||
27 | #ifndef __L2CAP_H | 27 | #ifndef __L2CAP_H |
28 | #define __L2CAP_H | 28 | #define __L2CAP_H |
29 | 29 | ||
30 | #include <asm/unaligned.h> | ||
31 | |||
32 | /* L2CAP defaults */ | 30 | /* L2CAP defaults */ |
33 | #define L2CAP_DEFAULT_MTU 672 | 31 | #define L2CAP_DEFAULT_MTU 672 |
34 | #define L2CAP_DEFAULT_MIN_MTU 48 | 32 | #define L2CAP_DEFAULT_MIN_MTU 48 |
35 | #define L2CAP_DEFAULT_FLUSH_TO 0xFFFF | 33 | #define L2CAP_DEFAULT_FLUSH_TO 0xffff |
36 | #define L2CAP_EFS_DEFAULT_FLUSH_TO 0xFFFFFFFF | ||
37 | #define L2CAP_DEFAULT_TX_WINDOW 63 | 34 | #define L2CAP_DEFAULT_TX_WINDOW 63 |
38 | #define L2CAP_DEFAULT_EXT_WINDOW 0x3FFF | ||
39 | #define L2CAP_DEFAULT_MAX_TX 3 | 35 | #define L2CAP_DEFAULT_MAX_TX 3 |
40 | #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ | 36 | #define L2CAP_DEFAULT_RETRANS_TO 2000 /* 2 seconds */ |
41 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ | 37 | #define L2CAP_DEFAULT_MONITOR_TO 12000 /* 12 seconds */ |
42 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1492 /* Sized for AMP packet */ | 38 | #define L2CAP_DEFAULT_MAX_PDU_SIZE 1009 /* Sized for 3-DH5 packet */ |
43 | #define L2CAP_DEFAULT_ACK_TO 200 | 39 | #define L2CAP_DEFAULT_ACK_TO 200 |
44 | #define L2CAP_DEFAULT_MAX_SDU_SIZE 0xFFFF | 40 | #define L2CAP_LE_DEFAULT_MTU 23 |
45 | #define L2CAP_DEFAULT_SDU_ITIME 0xFFFFFFFF | 41 | |
46 | #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF | 42 | #define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ |
47 | #define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */ | 43 | #define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ |
48 | #define L2CAP_LE_MIN_MTU 23 | ||
49 | |||
50 | #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100) | ||
51 | #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000) | ||
52 | #define L2CAP_ENC_TIMEOUT msecs_to_jiffies(5000) | ||
53 | #define L2CAP_CONN_TIMEOUT msecs_to_jiffies(40000) | ||
54 | #define L2CAP_INFO_TIMEOUT msecs_to_jiffies(4000) | ||
55 | #define L2CAP_MOVE_TIMEOUT msecs_to_jiffies(4000) | ||
56 | #define L2CAP_MOVE_ERTX_TIMEOUT msecs_to_jiffies(60000) | ||
57 | |||
58 | #define L2CAP_A2MP_DEFAULT_MTU 670 | ||
59 | 44 | ||
60 | /* L2CAP socket address */ | 45 | /* L2CAP socket address */ |
61 | struct sockaddr_l2 { | 46 | struct sockaddr_l2 { |
@@ -63,7 +48,6 @@ struct sockaddr_l2 { | |||
63 | __le16 l2_psm; | 48 | __le16 l2_psm; |
64 | bdaddr_t l2_bdaddr; | 49 | bdaddr_t l2_bdaddr; |
65 | __le16 l2_cid; | 50 | __le16 l2_cid; |
66 | __u8 l2_bdaddr_type; | ||
67 | }; | 51 | }; |
68 | 52 | ||
69 | /* L2CAP socket options */ | 53 | /* L2CAP socket options */ |
@@ -104,86 +88,52 @@ struct l2cap_conninfo { | |||
104 | #define L2CAP_ECHO_RSP 0x09 | 88 | #define L2CAP_ECHO_RSP 0x09 |
105 | #define L2CAP_INFO_REQ 0x0a | 89 | #define L2CAP_INFO_REQ 0x0a |
106 | #define L2CAP_INFO_RSP 0x0b | 90 | #define L2CAP_INFO_RSP 0x0b |
107 | #define L2CAP_CREATE_CHAN_REQ 0x0c | ||
108 | #define L2CAP_CREATE_CHAN_RSP 0x0d | ||
109 | #define L2CAP_MOVE_CHAN_REQ 0x0e | ||
110 | #define L2CAP_MOVE_CHAN_RSP 0x0f | ||
111 | #define L2CAP_MOVE_CHAN_CFM 0x10 | ||
112 | #define L2CAP_MOVE_CHAN_CFM_RSP 0x11 | ||
113 | #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 | 91 | #define L2CAP_CONN_PARAM_UPDATE_REQ 0x12 |
114 | #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 | 92 | #define L2CAP_CONN_PARAM_UPDATE_RSP 0x13 |
115 | 93 | ||
116 | /* L2CAP extended feature mask */ | 94 | /* L2CAP feature mask */ |
117 | #define L2CAP_FEAT_FLOWCTL 0x00000001 | 95 | #define L2CAP_FEAT_FLOWCTL 0x00000001 |
118 | #define L2CAP_FEAT_RETRANS 0x00000002 | 96 | #define L2CAP_FEAT_RETRANS 0x00000002 |
119 | #define L2CAP_FEAT_BIDIR_QOS 0x00000004 | ||
120 | #define L2CAP_FEAT_ERTM 0x00000008 | 97 | #define L2CAP_FEAT_ERTM 0x00000008 |
121 | #define L2CAP_FEAT_STREAMING 0x00000010 | 98 | #define L2CAP_FEAT_STREAMING 0x00000010 |
122 | #define L2CAP_FEAT_FCS 0x00000020 | 99 | #define L2CAP_FEAT_FCS 0x00000020 |
123 | #define L2CAP_FEAT_EXT_FLOW 0x00000040 | ||
124 | #define L2CAP_FEAT_FIXED_CHAN 0x00000080 | 100 | #define L2CAP_FEAT_FIXED_CHAN 0x00000080 |
125 | #define L2CAP_FEAT_EXT_WINDOW 0x00000100 | ||
126 | #define L2CAP_FEAT_UCD 0x00000200 | ||
127 | 101 | ||
128 | /* L2CAP checksum option */ | 102 | /* L2CAP checksum option */ |
129 | #define L2CAP_FCS_NONE 0x00 | 103 | #define L2CAP_FCS_NONE 0x00 |
130 | #define L2CAP_FCS_CRC16 0x01 | 104 | #define L2CAP_FCS_CRC16 0x01 |
131 | 105 | ||
132 | /* L2CAP fixed channels */ | ||
133 | #define L2CAP_FC_L2CAP 0x02 | ||
134 | #define L2CAP_FC_A2MP 0x08 | ||
135 | |||
136 | /* L2CAP Control Field bit masks */ | 106 | /* L2CAP Control Field bit masks */ |
137 | #define L2CAP_CTRL_SAR 0xC000 | 107 | #define L2CAP_CTRL_SAR 0xC000 |
138 | #define L2CAP_CTRL_REQSEQ 0x3F00 | 108 | #define L2CAP_CTRL_REQSEQ 0x3F00 |
139 | #define L2CAP_CTRL_TXSEQ 0x007E | 109 | #define L2CAP_CTRL_TXSEQ 0x007E |
140 | #define L2CAP_CTRL_SUPERVISE 0x000C | 110 | #define L2CAP_CTRL_RETRANS 0x0080 |
141 | 111 | #define L2CAP_CTRL_FINAL 0x0080 | |
142 | #define L2CAP_CTRL_RETRANS 0x0080 | 112 | #define L2CAP_CTRL_POLL 0x0010 |
143 | #define L2CAP_CTRL_FINAL 0x0080 | 113 | #define L2CAP_CTRL_SUPERVISE 0x000C |
144 | #define L2CAP_CTRL_POLL 0x0010 | 114 | #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ |
145 | #define L2CAP_CTRL_FRAME_TYPE 0x0001 /* I- or S-Frame */ | 115 | |
146 | 116 | #define L2CAP_CTRL_TXSEQ_SHIFT 1 | |
147 | #define L2CAP_CTRL_TXSEQ_SHIFT 1 | 117 | #define L2CAP_CTRL_REQSEQ_SHIFT 8 |
148 | #define L2CAP_CTRL_SUPER_SHIFT 2 | 118 | #define L2CAP_CTRL_SAR_SHIFT 14 |
149 | #define L2CAP_CTRL_POLL_SHIFT 4 | ||
150 | #define L2CAP_CTRL_FINAL_SHIFT 7 | ||
151 | #define L2CAP_CTRL_REQSEQ_SHIFT 8 | ||
152 | #define L2CAP_CTRL_SAR_SHIFT 14 | ||
153 | |||
154 | /* L2CAP Extended Control Field bit mask */ | ||
155 | #define L2CAP_EXT_CTRL_TXSEQ 0xFFFC0000 | ||
156 | #define L2CAP_EXT_CTRL_SAR 0x00030000 | ||
157 | #define L2CAP_EXT_CTRL_SUPERVISE 0x00030000 | ||
158 | #define L2CAP_EXT_CTRL_REQSEQ 0x0000FFFC | ||
159 | |||
160 | #define L2CAP_EXT_CTRL_POLL 0x00040000 | ||
161 | #define L2CAP_EXT_CTRL_FINAL 0x00000002 | ||
162 | #define L2CAP_EXT_CTRL_FRAME_TYPE 0x00000001 /* I- or S-Frame */ | ||
163 | |||
164 | #define L2CAP_EXT_CTRL_FINAL_SHIFT 1 | ||
165 | #define L2CAP_EXT_CTRL_REQSEQ_SHIFT 2 | ||
166 | #define L2CAP_EXT_CTRL_SAR_SHIFT 16 | ||
167 | #define L2CAP_EXT_CTRL_SUPER_SHIFT 16 | ||
168 | #define L2CAP_EXT_CTRL_POLL_SHIFT 18 | ||
169 | #define L2CAP_EXT_CTRL_TXSEQ_SHIFT 18 | ||
170 | 119 | ||
171 | /* L2CAP Supervisory Function */ | 120 | /* L2CAP Supervisory Function */ |
172 | #define L2CAP_SUPER_RR 0x00 | 121 | #define L2CAP_SUPER_RCV_READY 0x0000 |
173 | #define L2CAP_SUPER_REJ 0x01 | 122 | #define L2CAP_SUPER_REJECT 0x0004 |
174 | #define L2CAP_SUPER_RNR 0x02 | 123 | #define L2CAP_SUPER_RCV_NOT_READY 0x0008 |
175 | #define L2CAP_SUPER_SREJ 0x03 | 124 | #define L2CAP_SUPER_SELECT_REJECT 0x000C |
176 | 125 | ||
177 | /* L2CAP Segmentation and Reassembly */ | 126 | /* L2CAP Segmentation and Reassembly */ |
178 | #define L2CAP_SAR_UNSEGMENTED 0x00 | 127 | #define L2CAP_SDU_UNSEGMENTED 0x0000 |
179 | #define L2CAP_SAR_START 0x01 | 128 | #define L2CAP_SDU_START 0x4000 |
180 | #define L2CAP_SAR_END 0x02 | 129 | #define L2CAP_SDU_END 0x8000 |
181 | #define L2CAP_SAR_CONTINUE 0x03 | 130 | #define L2CAP_SDU_CONTINUE 0xC000 |
182 | 131 | ||
183 | /* L2CAP Command rej. reasons */ | 132 | /* L2CAP Command rej. reasons */ |
184 | #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 | 133 | #define L2CAP_REJ_NOT_UNDERSTOOD 0x0000 |
185 | #define L2CAP_REJ_MTU_EXCEEDED 0x0001 | 134 | #define L2CAP_REJ_MTU_EXCEEDED 0x0001 |
186 | #define L2CAP_REJ_INVALID_CID 0x0002 | 135 | #define L2CAP_REJ_INVALID_CID 0x0002 |
136 | |||
187 | 137 | ||
188 | /* L2CAP structures */ | 138 | /* L2CAP structures */ |
189 | struct l2cap_hdr { | 139 | struct l2cap_hdr { |
@@ -191,14 +141,6 @@ struct l2cap_hdr { | |||
191 | __le16 cid; | 141 | __le16 cid; |
192 | } __packed; | 142 | } __packed; |
193 | #define L2CAP_HDR_SIZE 4 | 143 | #define L2CAP_HDR_SIZE 4 |
194 | #define L2CAP_ENH_HDR_SIZE 6 | ||
195 | #define L2CAP_EXT_HDR_SIZE 8 | ||
196 | |||
197 | #define L2CAP_FCS_SIZE 2 | ||
198 | #define L2CAP_SDULEN_SIZE 2 | ||
199 | #define L2CAP_PSMLEN_SIZE 2 | ||
200 | #define L2CAP_ENH_CTRL_SIZE 2 | ||
201 | #define L2CAP_EXT_CTRL_SIZE 4 | ||
202 | 144 | ||
203 | struct l2cap_cmd_hdr { | 145 | struct l2cap_cmd_hdr { |
204 | __u8 code; | 146 | __u8 code; |
@@ -234,29 +176,23 @@ struct l2cap_conn_rsp { | |||
234 | __le16 status; | 176 | __le16 status; |
235 | } __packed; | 177 | } __packed; |
236 | 178 | ||
237 | /* protocol/service multiplexer (PSM) */ | ||
238 | #define L2CAP_PSM_SDP 0x0001 | ||
239 | #define L2CAP_PSM_RFCOMM 0x0003 | ||
240 | |||
241 | /* channel indentifier */ | 179 | /* channel indentifier */ |
242 | #define L2CAP_CID_SIGNALING 0x0001 | 180 | #define L2CAP_CID_SIGNALING 0x0001 |
243 | #define L2CAP_CID_CONN_LESS 0x0002 | 181 | #define L2CAP_CID_CONN_LESS 0x0002 |
244 | #define L2CAP_CID_A2MP 0x0003 | ||
245 | #define L2CAP_CID_LE_DATA 0x0004 | 182 | #define L2CAP_CID_LE_DATA 0x0004 |
246 | #define L2CAP_CID_LE_SIGNALING 0x0005 | 183 | #define L2CAP_CID_LE_SIGNALING 0x0005 |
247 | #define L2CAP_CID_SMP 0x0006 | 184 | #define L2CAP_CID_SMP 0x0006 |
248 | #define L2CAP_CID_DYN_START 0x0040 | 185 | #define L2CAP_CID_DYN_START 0x0040 |
249 | #define L2CAP_CID_DYN_END 0xffff | 186 | #define L2CAP_CID_DYN_END 0xffff |
250 | 187 | ||
251 | /* connect/create channel results */ | 188 | /* connect result */ |
252 | #define L2CAP_CR_SUCCESS 0x0000 | 189 | #define L2CAP_CR_SUCCESS 0x0000 |
253 | #define L2CAP_CR_PEND 0x0001 | 190 | #define L2CAP_CR_PEND 0x0001 |
254 | #define L2CAP_CR_BAD_PSM 0x0002 | 191 | #define L2CAP_CR_BAD_PSM 0x0002 |
255 | #define L2CAP_CR_SEC_BLOCK 0x0003 | 192 | #define L2CAP_CR_SEC_BLOCK 0x0003 |
256 | #define L2CAP_CR_NO_MEM 0x0004 | 193 | #define L2CAP_CR_NO_MEM 0x0004 |
257 | #define L2CAP_CR_BAD_AMP 0x0005 | ||
258 | 194 | ||
259 | /* connect/create channel status */ | 195 | /* connect status */ |
260 | #define L2CAP_CS_NO_INFO 0x0000 | 196 | #define L2CAP_CS_NO_INFO 0x0000 |
261 | #define L2CAP_CS_AUTHEN_PEND 0x0001 | 197 | #define L2CAP_CS_AUTHEN_PEND 0x0001 |
262 | #define L2CAP_CS_AUTHOR_PEND 0x0002 | 198 | #define L2CAP_CS_AUTHOR_PEND 0x0002 |
@@ -278,11 +214,6 @@ struct l2cap_conf_rsp { | |||
278 | #define L2CAP_CONF_UNACCEPT 0x0001 | 214 | #define L2CAP_CONF_UNACCEPT 0x0001 |
279 | #define L2CAP_CONF_REJECT 0x0002 | 215 | #define L2CAP_CONF_REJECT 0x0002 |
280 | #define L2CAP_CONF_UNKNOWN 0x0003 | 216 | #define L2CAP_CONF_UNKNOWN 0x0003 |
281 | #define L2CAP_CONF_PENDING 0x0004 | ||
282 | #define L2CAP_CONF_EFS_REJECT 0x0005 | ||
283 | |||
284 | /* configuration req/rsp continuation flag */ | ||
285 | #define L2CAP_CONF_FLAG_CONTINUATION 0x0001 | ||
286 | 217 | ||
287 | struct l2cap_conf_opt { | 218 | struct l2cap_conf_opt { |
288 | __u8 type; | 219 | __u8 type; |
@@ -299,8 +230,6 @@ struct l2cap_conf_opt { | |||
299 | #define L2CAP_CONF_QOS 0x03 | 230 | #define L2CAP_CONF_QOS 0x03 |
300 | #define L2CAP_CONF_RFC 0x04 | 231 | #define L2CAP_CONF_RFC 0x04 |
301 | #define L2CAP_CONF_FCS 0x05 | 232 | #define L2CAP_CONF_FCS 0x05 |
302 | #define L2CAP_CONF_EFS 0x06 | ||
303 | #define L2CAP_CONF_EWS 0x07 | ||
304 | 233 | ||
305 | #define L2CAP_CONF_MAX_SIZE 22 | 234 | #define L2CAP_CONF_MAX_SIZE 22 |
306 | 235 | ||
@@ -319,21 +248,6 @@ struct l2cap_conf_rfc { | |||
319 | #define L2CAP_MODE_ERTM 0x03 | 248 | #define L2CAP_MODE_ERTM 0x03 |
320 | #define L2CAP_MODE_STREAMING 0x04 | 249 | #define L2CAP_MODE_STREAMING 0x04 |
321 | 250 | ||
322 | struct l2cap_conf_efs { | ||
323 | __u8 id; | ||
324 | __u8 stype; | ||
325 | __le16 msdu; | ||
326 | __le32 sdu_itime; | ||
327 | __le32 acc_lat; | ||
328 | __le32 flush_to; | ||
329 | } __packed; | ||
330 | |||
331 | #define L2CAP_SERV_NOTRAFIC 0x00 | ||
332 | #define L2CAP_SERV_BESTEFFORT 0x01 | ||
333 | #define L2CAP_SERV_GUARANTEED 0x02 | ||
334 | |||
335 | #define L2CAP_BESTEFFORT_ID 0x01 | ||
336 | |||
337 | struct l2cap_disconn_req { | 251 | struct l2cap_disconn_req { |
338 | __le16 dcid; | 252 | __le16 dcid; |
339 | __le16 scid; | 253 | __le16 scid; |
@@ -354,57 +268,14 @@ struct l2cap_info_rsp { | |||
354 | __u8 data[0]; | 268 | __u8 data[0]; |
355 | } __packed; | 269 | } __packed; |
356 | 270 | ||
357 | struct l2cap_create_chan_req { | ||
358 | __le16 psm; | ||
359 | __le16 scid; | ||
360 | __u8 amp_id; | ||
361 | } __packed; | ||
362 | |||
363 | struct l2cap_create_chan_rsp { | ||
364 | __le16 dcid; | ||
365 | __le16 scid; | ||
366 | __le16 result; | ||
367 | __le16 status; | ||
368 | } __packed; | ||
369 | |||
370 | struct l2cap_move_chan_req { | ||
371 | __le16 icid; | ||
372 | __u8 dest_amp_id; | ||
373 | } __packed; | ||
374 | |||
375 | struct l2cap_move_chan_rsp { | ||
376 | __le16 icid; | ||
377 | __le16 result; | ||
378 | } __packed; | ||
379 | |||
380 | #define L2CAP_MR_SUCCESS 0x0000 | ||
381 | #define L2CAP_MR_PEND 0x0001 | ||
382 | #define L2CAP_MR_BAD_ID 0x0002 | ||
383 | #define L2CAP_MR_SAME_ID 0x0003 | ||
384 | #define L2CAP_MR_NOT_SUPP 0x0004 | ||
385 | #define L2CAP_MR_COLLISION 0x0005 | ||
386 | #define L2CAP_MR_NOT_ALLOWED 0x0006 | ||
387 | |||
388 | struct l2cap_move_chan_cfm { | ||
389 | __le16 icid; | ||
390 | __le16 result; | ||
391 | } __packed; | ||
392 | |||
393 | #define L2CAP_MC_CONFIRMED 0x0000 | ||
394 | #define L2CAP_MC_UNCONFIRMED 0x0001 | ||
395 | |||
396 | struct l2cap_move_chan_cfm_rsp { | ||
397 | __le16 icid; | ||
398 | } __packed; | ||
399 | |||
400 | /* info type */ | 271 | /* info type */ |
401 | #define L2CAP_IT_CL_MTU 0x0001 | 272 | #define L2CAP_IT_CL_MTU 0x0001 |
402 | #define L2CAP_IT_FEAT_MASK 0x0002 | 273 | #define L2CAP_IT_FEAT_MASK 0x0002 |
403 | #define L2CAP_IT_FIXED_CHAN 0x0003 | 274 | #define L2CAP_IT_FIXED_CHAN 0x0003 |
404 | 275 | ||
405 | /* info result */ | 276 | /* info result */ |
406 | #define L2CAP_IR_SUCCESS 0x0000 | 277 | #define L2CAP_IR_SUCCESS 0x0000 |
407 | #define L2CAP_IR_NOTSUPP 0x0001 | 278 | #define L2CAP_IR_NOTSUPP 0x0001 |
408 | 279 | ||
409 | struct l2cap_conn_param_update_req { | 280 | struct l2cap_conn_param_update_req { |
410 | __le16 min; | 281 | __le16 min; |
@@ -422,26 +293,20 @@ struct l2cap_conn_param_update_rsp { | |||
422 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 | 293 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 |
423 | 294 | ||
424 | /* ----- L2CAP channels and connections ----- */ | 295 | /* ----- L2CAP channels and connections ----- */ |
425 | struct l2cap_seq_list { | 296 | struct srej_list { |
426 | __u16 head; | 297 | __u8 tx_seq; |
427 | __u16 tail; | 298 | struct list_head list; |
428 | __u16 mask; | ||
429 | __u16 *list; | ||
430 | }; | 299 | }; |
431 | 300 | ||
432 | #define L2CAP_SEQ_LIST_CLEAR 0xFFFF | ||
433 | #define L2CAP_SEQ_LIST_TAIL 0x8000 | ||
434 | |||
435 | struct l2cap_chan { | 301 | struct l2cap_chan { |
436 | struct sock *sk; | 302 | struct sock *sk; |
437 | 303 | ||
438 | struct l2cap_conn *conn; | 304 | struct l2cap_conn *conn; |
439 | struct hci_conn *hs_hcon; | ||
440 | struct hci_chan *hs_hchan; | ||
441 | struct kref kref; | ||
442 | 305 | ||
443 | __u8 state; | 306 | __u8 state; |
444 | 307 | ||
308 | atomic_t refcnt; | ||
309 | |||
445 | __le16 psm; | 310 | __le16 psm; |
446 | __u16 dcid; | 311 | __u16 dcid; |
447 | __u16 scid; | 312 | __u16 scid; |
@@ -451,11 +316,14 @@ struct l2cap_chan { | |||
451 | __u16 flush_to; | 316 | __u16 flush_to; |
452 | __u8 mode; | 317 | __u8 mode; |
453 | __u8 chan_type; | 318 | __u8 chan_type; |
454 | __u8 chan_policy; | ||
455 | 319 | ||
456 | __le16 sport; | 320 | __le16 sport; |
457 | 321 | ||
458 | __u8 sec_level; | 322 | __u8 sec_level; |
323 | __u8 role_switch; | ||
324 | __u8 force_reliable; | ||
325 | __u8 flushable; | ||
326 | __u8 force_active; | ||
459 | 327 | ||
460 | __u8 ident; | 328 | __u8 ident; |
461 | 329 | ||
@@ -466,124 +334,92 @@ struct l2cap_chan { | |||
466 | 334 | ||
467 | __u8 fcs; | 335 | __u8 fcs; |
468 | 336 | ||
469 | __u16 tx_win; | 337 | __u8 tx_win; |
470 | __u16 tx_win_max; | ||
471 | __u16 ack_win; | ||
472 | __u8 max_tx; | 338 | __u8 max_tx; |
473 | __u16 retrans_timeout; | 339 | __u16 retrans_timeout; |
474 | __u16 monitor_timeout; | 340 | __u16 monitor_timeout; |
475 | __u16 mps; | 341 | __u16 mps; |
476 | 342 | ||
477 | __u8 tx_state; | ||
478 | __u8 rx_state; | ||
479 | |||
480 | unsigned long conf_state; | 343 | unsigned long conf_state; |
481 | unsigned long conn_state; | 344 | unsigned long conn_state; |
482 | unsigned long flags; | 345 | |
483 | 346 | __u8 next_tx_seq; | |
484 | __u8 remote_amp_id; | 347 | __u8 expected_ack_seq; |
485 | __u8 local_amp_id; | 348 | __u8 expected_tx_seq; |
486 | __u8 move_id; | 349 | __u8 buffer_seq; |
487 | __u8 move_state; | 350 | __u8 buffer_seq_srej; |
488 | __u8 move_role; | 351 | __u8 srej_save_reqseq; |
489 | 352 | __u8 frames_sent; | |
490 | __u16 next_tx_seq; | 353 | __u8 unacked_frames; |
491 | __u16 expected_ack_seq; | ||
492 | __u16 expected_tx_seq; | ||
493 | __u16 buffer_seq; | ||
494 | __u16 srej_save_reqseq; | ||
495 | __u16 last_acked_seq; | ||
496 | __u16 frames_sent; | ||
497 | __u16 unacked_frames; | ||
498 | __u8 retry_count; | 354 | __u8 retry_count; |
499 | __u16 srej_queue_next; | 355 | __u8 num_acked; |
500 | __u16 sdu_len; | 356 | __u16 sdu_len; |
357 | __u16 partial_sdu_len; | ||
501 | struct sk_buff *sdu; | 358 | struct sk_buff *sdu; |
502 | struct sk_buff *sdu_last_frag; | ||
503 | 359 | ||
504 | __u16 remote_tx_win; | 360 | __u8 remote_tx_win; |
505 | __u8 remote_max_tx; | 361 | __u8 remote_max_tx; |
506 | __u16 remote_mps; | 362 | __u16 remote_mps; |
507 | 363 | ||
508 | __u8 local_id; | 364 | struct timer_list chan_timer; |
509 | __u8 local_stype; | 365 | struct timer_list retrans_timer; |
510 | __u16 local_msdu; | 366 | struct timer_list monitor_timer; |
511 | __u32 local_sdu_itime; | 367 | struct timer_list ack_timer; |
512 | __u32 local_acc_lat; | ||
513 | __u32 local_flush_to; | ||
514 | |||
515 | __u8 remote_id; | ||
516 | __u8 remote_stype; | ||
517 | __u16 remote_msdu; | ||
518 | __u32 remote_sdu_itime; | ||
519 | __u32 remote_acc_lat; | ||
520 | __u32 remote_flush_to; | ||
521 | |||
522 | struct delayed_work chan_timer; | ||
523 | struct delayed_work retrans_timer; | ||
524 | struct delayed_work monitor_timer; | ||
525 | struct delayed_work ack_timer; | ||
526 | |||
527 | struct sk_buff *tx_send_head; | 368 | struct sk_buff *tx_send_head; |
528 | struct sk_buff_head tx_q; | 369 | struct sk_buff_head tx_q; |
529 | struct sk_buff_head srej_q; | 370 | struct sk_buff_head srej_q; |
530 | struct l2cap_seq_list srej_list; | 371 | struct list_head srej_l; |
531 | struct l2cap_seq_list retrans_list; | ||
532 | 372 | ||
533 | struct list_head list; | 373 | struct list_head list; |
534 | struct list_head global_l; | 374 | struct list_head global_l; |
535 | 375 | ||
536 | void *data; | 376 | void *data; |
537 | struct l2cap_ops *ops; | 377 | struct l2cap_ops *ops; |
538 | struct mutex lock; | ||
539 | }; | 378 | }; |
540 | 379 | ||
541 | struct l2cap_ops { | 380 | struct l2cap_ops { |
542 | char *name; | 381 | char *name; |
543 | 382 | ||
544 | struct l2cap_chan *(*new_connection) (struct l2cap_chan *chan); | 383 | struct l2cap_chan *(*new_connection) (void *data); |
545 | int (*recv) (struct l2cap_chan * chan, | 384 | int (*recv) (void *data, struct sk_buff *skb); |
546 | struct sk_buff *skb); | 385 | void (*close) (void *data); |
547 | void (*teardown) (struct l2cap_chan *chan, int err); | 386 | void (*state_change) (void *data, int state); |
548 | void (*close) (struct l2cap_chan *chan); | ||
549 | void (*state_change) (struct l2cap_chan *chan, | ||
550 | int state); | ||
551 | void (*ready) (struct l2cap_chan *chan); | ||
552 | void (*defer) (struct l2cap_chan *chan); | ||
553 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, | ||
554 | unsigned long len, int nb); | ||
555 | }; | 387 | }; |
556 | 388 | ||
557 | struct l2cap_conn { | 389 | struct l2cap_conn { |
558 | struct hci_conn *hcon; | 390 | struct hci_conn *hcon; |
559 | struct hci_chan *hchan; | 391 | |
392 | bdaddr_t *dst; | ||
393 | bdaddr_t *src; | ||
560 | 394 | ||
561 | bdaddr_t *dst; | 395 | unsigned int mtu; |
562 | bdaddr_t *src; | ||
563 | 396 | ||
564 | unsigned int mtu; | 397 | __u32 feat_mask; |
565 | 398 | ||
566 | __u32 feat_mask; | 399 | __u8 info_state; |
567 | __u8 fixed_chan_mask; | 400 | __u8 info_ident; |
568 | 401 | ||
569 | __u8 info_state; | 402 | struct timer_list info_timer; |
570 | __u8 info_ident; | ||
571 | 403 | ||
572 | struct delayed_work info_timer; | 404 | spinlock_t lock; |
573 | 405 | ||
574 | spinlock_t lock; | 406 | struct sk_buff *rx_skb; |
407 | __u32 rx_len; | ||
408 | __u8 tx_ident; | ||
575 | 409 | ||
576 | struct sk_buff *rx_skb; | 410 | __u8 disc_reason; |
577 | __u32 rx_len; | ||
578 | __u8 tx_ident; | ||
579 | 411 | ||
580 | __u8 disc_reason; | 412 | __u8 preq[7]; /* SMP Pairing Request */ |
413 | __u8 prsp[7]; /* SMP Pairing Response */ | ||
414 | __u8 prnd[16]; /* SMP Pairing Random */ | ||
415 | __u8 pcnf[16]; /* SMP Pairing Confirm */ | ||
416 | __u8 tk[16]; /* SMP Temporary Key */ | ||
417 | __u8 smp_key_size; | ||
581 | 418 | ||
582 | struct delayed_work security_timer; | 419 | struct timer_list security_timer; |
583 | struct smp_chan *smp_chan; | ||
584 | 420 | ||
585 | struct list_head chan_l; | 421 | struct list_head chan_l; |
586 | struct mutex chan_lock; | 422 | rwlock_t chan_lock; |
587 | }; | 423 | }; |
588 | 424 | ||
589 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 | 425 | #define L2CAP_INFO_CL_MTU_REQ_SENT 0x01 |
@@ -593,15 +429,14 @@ struct l2cap_conn { | |||
593 | #define L2CAP_CHAN_RAW 1 | 429 | #define L2CAP_CHAN_RAW 1 |
594 | #define L2CAP_CHAN_CONN_LESS 2 | 430 | #define L2CAP_CHAN_CONN_LESS 2 |
595 | #define L2CAP_CHAN_CONN_ORIENTED 3 | 431 | #define L2CAP_CHAN_CONN_ORIENTED 3 |
596 | #define L2CAP_CHAN_CONN_FIX_A2MP 4 | ||
597 | 432 | ||
598 | /* ----- L2CAP socket info ----- */ | 433 | /* ----- L2CAP socket info ----- */ |
599 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 434 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) |
600 | 435 | ||
601 | struct l2cap_pinfo { | 436 | struct l2cap_pinfo { |
602 | struct bt_sock bt; | 437 | struct bt_sock bt; |
603 | struct l2cap_chan *chan; | 438 | struct l2cap_chan *chan; |
604 | struct sk_buff *rx_busy_skb; | 439 | struct sk_buff *rx_busy_skb; |
605 | }; | 440 | }; |
606 | 441 | ||
607 | enum { | 442 | enum { |
@@ -611,18 +446,15 @@ enum { | |||
611 | CONF_MTU_DONE, | 446 | CONF_MTU_DONE, |
612 | CONF_MODE_DONE, | 447 | CONF_MODE_DONE, |
613 | CONF_CONNECT_PEND, | 448 | CONF_CONNECT_PEND, |
614 | CONF_RECV_NO_FCS, | 449 | CONF_NO_FCS_RECV, |
615 | CONF_STATE2_DEVICE, | 450 | CONF_STATE2_DEVICE, |
616 | CONF_EWS_RECV, | ||
617 | CONF_LOC_CONF_PEND, | ||
618 | CONF_REM_CONF_PEND, | ||
619 | CONF_NOT_COMPLETE, | ||
620 | }; | 451 | }; |
621 | 452 | ||
622 | #define L2CAP_CONF_MAX_CONF_REQ 2 | 453 | #define L2CAP_CONF_MAX_CONF_REQ 2 |
623 | #define L2CAP_CONF_MAX_CONF_RSP 2 | 454 | #define L2CAP_CONF_MAX_CONF_RSP 2 |
624 | 455 | ||
625 | enum { | 456 | enum { |
457 | CONN_SAR_SDU, | ||
626 | CONN_SREJ_SENT, | 458 | CONN_SREJ_SENT, |
627 | CONN_WAIT_F, | 459 | CONN_WAIT_F, |
628 | CONN_SREJ_ACT, | 460 | CONN_SREJ_ACT, |
@@ -634,156 +466,37 @@ enum { | |||
634 | CONN_RNR_SENT, | 466 | CONN_RNR_SENT, |
635 | }; | 467 | }; |
636 | 468 | ||
637 | /* Definitions for flags in l2cap_chan */ | ||
638 | enum { | ||
639 | FLAG_ROLE_SWITCH, | ||
640 | FLAG_FORCE_ACTIVE, | ||
641 | FLAG_FORCE_RELIABLE, | ||
642 | FLAG_FLUSHABLE, | ||
643 | FLAG_EXT_CTRL, | ||
644 | FLAG_EFS_ENABLE, | ||
645 | }; | ||
646 | |||
647 | enum { | ||
648 | L2CAP_TX_STATE_XMIT, | ||
649 | L2CAP_TX_STATE_WAIT_F, | ||
650 | }; | ||
651 | |||
652 | enum { | ||
653 | L2CAP_RX_STATE_RECV, | ||
654 | L2CAP_RX_STATE_SREJ_SENT, | ||
655 | L2CAP_RX_STATE_MOVE, | ||
656 | L2CAP_RX_STATE_WAIT_P, | ||
657 | L2CAP_RX_STATE_WAIT_F, | ||
658 | }; | ||
659 | |||
660 | enum { | ||
661 | L2CAP_TXSEQ_EXPECTED, | ||
662 | L2CAP_TXSEQ_EXPECTED_SREJ, | ||
663 | L2CAP_TXSEQ_UNEXPECTED, | ||
664 | L2CAP_TXSEQ_UNEXPECTED_SREJ, | ||
665 | L2CAP_TXSEQ_DUPLICATE, | ||
666 | L2CAP_TXSEQ_DUPLICATE_SREJ, | ||
667 | L2CAP_TXSEQ_INVALID, | ||
668 | L2CAP_TXSEQ_INVALID_IGNORE, | ||
669 | }; | ||
670 | |||
671 | enum { | ||
672 | L2CAP_EV_DATA_REQUEST, | ||
673 | L2CAP_EV_LOCAL_BUSY_DETECTED, | ||
674 | L2CAP_EV_LOCAL_BUSY_CLEAR, | ||
675 | L2CAP_EV_RECV_REQSEQ_AND_FBIT, | ||
676 | L2CAP_EV_RECV_FBIT, | ||
677 | L2CAP_EV_RETRANS_TO, | ||
678 | L2CAP_EV_MONITOR_TO, | ||
679 | L2CAP_EV_EXPLICIT_POLL, | ||
680 | L2CAP_EV_RECV_IFRAME, | ||
681 | L2CAP_EV_RECV_RR, | ||
682 | L2CAP_EV_RECV_REJ, | ||
683 | L2CAP_EV_RECV_RNR, | ||
684 | L2CAP_EV_RECV_SREJ, | ||
685 | L2CAP_EV_RECV_FRAME, | ||
686 | }; | ||
687 | |||
688 | enum { | ||
689 | L2CAP_MOVE_ROLE_NONE, | ||
690 | L2CAP_MOVE_ROLE_INITIATOR, | ||
691 | L2CAP_MOVE_ROLE_RESPONDER, | ||
692 | }; | ||
693 | |||
694 | enum { | ||
695 | L2CAP_MOVE_STABLE, | ||
696 | L2CAP_MOVE_WAIT_REQ, | ||
697 | L2CAP_MOVE_WAIT_RSP, | ||
698 | L2CAP_MOVE_WAIT_RSP_SUCCESS, | ||
699 | L2CAP_MOVE_WAIT_CONFIRM, | ||
700 | L2CAP_MOVE_WAIT_CONFIRM_RSP, | ||
701 | L2CAP_MOVE_WAIT_LOGICAL_COMP, | ||
702 | L2CAP_MOVE_WAIT_LOGICAL_CFM, | ||
703 | L2CAP_MOVE_WAIT_LOCAL_BUSY, | ||
704 | L2CAP_MOVE_WAIT_PREPARE, | ||
705 | }; | ||
706 | |||
707 | void l2cap_chan_hold(struct l2cap_chan *c); | ||
708 | void l2cap_chan_put(struct l2cap_chan *c); | ||
709 | |||
710 | static inline void l2cap_chan_lock(struct l2cap_chan *chan) | ||
711 | { | ||
712 | mutex_lock(&chan->lock); | ||
713 | } | ||
714 | |||
715 | static inline void l2cap_chan_unlock(struct l2cap_chan *chan) | ||
716 | { | ||
717 | mutex_unlock(&chan->lock); | ||
718 | } | ||
719 | |||
720 | static inline void l2cap_set_timer(struct l2cap_chan *chan, | ||
721 | struct delayed_work *work, long timeout) | ||
722 | { | ||
723 | BT_DBG("chan %p state %s timeout %ld", chan, | ||
724 | state_to_string(chan->state), timeout); | ||
725 | |||
726 | /* If delayed work cancelled do not hold(chan) | ||
727 | since it is already done with previous set_timer */ | ||
728 | if (!cancel_delayed_work(work)) | ||
729 | l2cap_chan_hold(chan); | ||
730 | |||
731 | schedule_delayed_work(work, timeout); | ||
732 | } | ||
733 | |||
734 | static inline bool l2cap_clear_timer(struct l2cap_chan *chan, | ||
735 | struct delayed_work *work) | ||
736 | { | ||
737 | bool ret; | ||
738 | |||
739 | /* put(chan) if delayed work cancelled otherwise it | ||
740 | is done in delayed work function */ | ||
741 | ret = cancel_delayed_work(work); | ||
742 | if (ret) | ||
743 | l2cap_chan_put(chan); | ||
744 | |||
745 | return ret; | ||
746 | } | ||
747 | |||
748 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) | 469 | #define __set_chan_timer(c, t) l2cap_set_timer(c, &c->chan_timer, (t)) |
749 | #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) | 470 | #define __clear_chan_timer(c) l2cap_clear_timer(c, &c->chan_timer) |
471 | #define __set_retrans_timer(c) l2cap_set_timer(c, &c->retrans_timer, \ | ||
472 | L2CAP_DEFAULT_RETRANS_TO); | ||
750 | #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) | 473 | #define __clear_retrans_timer(c) l2cap_clear_timer(c, &c->retrans_timer) |
474 | #define __set_monitor_timer(c) l2cap_set_timer(c, &c->monitor_timer, \ | ||
475 | L2CAP_DEFAULT_MONITOR_TO); | ||
751 | #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) | 476 | #define __clear_monitor_timer(c) l2cap_clear_timer(c, &c->monitor_timer) |
752 | #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ | 477 | #define __set_ack_timer(c) l2cap_set_timer(c, &chan->ack_timer, \ |
753 | msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); | 478 | L2CAP_DEFAULT_ACK_TO); |
754 | #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) | 479 | #define __clear_ack_timer(c) l2cap_clear_timer(c, &c->ack_timer) |
755 | 480 | ||
756 | static inline int __seq_offset(struct l2cap_chan *chan, __u16 seq1, __u16 seq2) | 481 | static inline int l2cap_tx_window_full(struct l2cap_chan *ch) |
757 | { | 482 | { |
758 | if (seq1 >= seq2) | 483 | int sub; |
759 | return seq1 - seq2; | ||
760 | else | ||
761 | return chan->tx_win_max + 1 - seq2 + seq1; | ||
762 | } | ||
763 | 484 | ||
764 | static inline __u16 __next_seq(struct l2cap_chan *chan, __u16 seq) | 485 | sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64; |
765 | { | ||
766 | return (seq + 1) % (chan->tx_win_max + 1); | ||
767 | } | ||
768 | |||
769 | static inline struct l2cap_chan *l2cap_chan_no_new_connection(struct l2cap_chan *chan) | ||
770 | { | ||
771 | return NULL; | ||
772 | } | ||
773 | 486 | ||
774 | static inline void l2cap_chan_no_teardown(struct l2cap_chan *chan, int err) | 487 | if (sub < 0) |
775 | { | 488 | sub += 64; |
776 | } | ||
777 | 489 | ||
778 | static inline void l2cap_chan_no_ready(struct l2cap_chan *chan) | 490 | return sub == ch->remote_tx_win; |
779 | { | ||
780 | } | 491 | } |
781 | 492 | ||
782 | static inline void l2cap_chan_no_defer(struct l2cap_chan *chan) | 493 | #define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) |
783 | { | 494 | #define __get_reqseq(ctrl) (((ctrl) & L2CAP_CTRL_REQSEQ) >> 8) |
784 | } | 495 | #define __is_iframe(ctrl) (!((ctrl) & L2CAP_CTRL_FRAME_TYPE)) |
496 | #define __is_sframe(ctrl) ((ctrl) & L2CAP_CTRL_FRAME_TYPE) | ||
497 | #define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) | ||
785 | 498 | ||
786 | extern bool disable_ertm; | 499 | extern int disable_ertm; |
787 | 500 | ||
788 | int l2cap_init_sockets(void); | 501 | int l2cap_init_sockets(void); |
789 | void l2cap_cleanup_sockets(void); | 502 | void l2cap_cleanup_sockets(void); |
@@ -794,23 +507,11 @@ int __l2cap_wait_ack(struct sock *sk); | |||
794 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); | 507 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); |
795 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); | 508 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); |
796 | 509 | ||
797 | struct l2cap_chan *l2cap_chan_create(void); | 510 | struct l2cap_chan *l2cap_chan_create(struct sock *sk); |
798 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); | 511 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); |
799 | int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, | 512 | void l2cap_chan_destroy(struct l2cap_chan *chan); |
800 | bdaddr_t *dst, u8 dst_type); | 513 | int l2cap_chan_connect(struct l2cap_chan *chan); |
801 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len, | 514 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
802 | u32 priority); | ||
803 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); | 515 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); |
804 | int l2cap_chan_check_security(struct l2cap_chan *chan); | ||
805 | void l2cap_chan_set_defaults(struct l2cap_chan *chan); | ||
806 | int l2cap_ertm_init(struct l2cap_chan *chan); | ||
807 | void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); | ||
808 | void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); | ||
809 | void l2cap_chan_del(struct l2cap_chan *chan, int err); | ||
810 | void l2cap_send_conn_req(struct l2cap_chan *chan); | ||
811 | void l2cap_move_start(struct l2cap_chan *chan); | ||
812 | void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan, | ||
813 | u8 status); | ||
814 | void __l2cap_physical_cfm(struct l2cap_chan *chan, int result); | ||
815 | 516 | ||
816 | #endif /* __L2CAP_H */ | 517 | #endif /* __L2CAP_H */ |
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h index 22980a7c387..5428fd32cce 100644 --- a/include/net/bluetooth/mgmt.h +++ b/include/net/bluetooth/mgmt.h | |||
@@ -2,7 +2,6 @@ | |||
2 | BlueZ - Bluetooth protocol stack for Linux | 2 | BlueZ - Bluetooth protocol stack for Linux |
3 | 3 | ||
4 | Copyright (C) 2010 Nokia Corporation | 4 | Copyright (C) 2010 Nokia Corporation |
5 | Copyright (C) 2011-2012 Intel Corporation | ||
6 | 5 | ||
7 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License version 2 as | 7 | it under the terms of the GNU General Public License version 2 as |
@@ -24,464 +23,281 @@ | |||
24 | 23 | ||
25 | #define MGMT_INDEX_NONE 0xFFFF | 24 | #define MGMT_INDEX_NONE 0xFFFF |
26 | 25 | ||
27 | #define MGMT_STATUS_SUCCESS 0x00 | ||
28 | #define MGMT_STATUS_UNKNOWN_COMMAND 0x01 | ||
29 | #define MGMT_STATUS_NOT_CONNECTED 0x02 | ||
30 | #define MGMT_STATUS_FAILED 0x03 | ||
31 | #define MGMT_STATUS_CONNECT_FAILED 0x04 | ||
32 | #define MGMT_STATUS_AUTH_FAILED 0x05 | ||
33 | #define MGMT_STATUS_NOT_PAIRED 0x06 | ||
34 | #define MGMT_STATUS_NO_RESOURCES 0x07 | ||
35 | #define MGMT_STATUS_TIMEOUT 0x08 | ||
36 | #define MGMT_STATUS_ALREADY_CONNECTED 0x09 | ||
37 | #define MGMT_STATUS_BUSY 0x0a | ||
38 | #define MGMT_STATUS_REJECTED 0x0b | ||
39 | #define MGMT_STATUS_NOT_SUPPORTED 0x0c | ||
40 | #define MGMT_STATUS_INVALID_PARAMS 0x0d | ||
41 | #define MGMT_STATUS_DISCONNECTED 0x0e | ||
42 | #define MGMT_STATUS_NOT_POWERED 0x0f | ||
43 | #define MGMT_STATUS_CANCELLED 0x10 | ||
44 | #define MGMT_STATUS_INVALID_INDEX 0x11 | ||
45 | |||
46 | struct mgmt_hdr { | 26 | struct mgmt_hdr { |
47 | __le16 opcode; | 27 | __le16 opcode; |
48 | __le16 index; | 28 | __le16 index; |
49 | __le16 len; | 29 | __le16 len; |
50 | } __packed; | ||
51 | |||
52 | struct mgmt_addr_info { | ||
53 | bdaddr_t bdaddr; | ||
54 | __u8 type; | ||
55 | } __packed; | 30 | } __packed; |
56 | #define MGMT_ADDR_INFO_SIZE 7 | ||
57 | 31 | ||
58 | #define MGMT_OP_READ_VERSION 0x0001 | 32 | #define MGMT_OP_READ_VERSION 0x0001 |
59 | #define MGMT_READ_VERSION_SIZE 0 | ||
60 | struct mgmt_rp_read_version { | 33 | struct mgmt_rp_read_version { |
61 | __u8 version; | 34 | __u8 version; |
62 | __le16 revision; | 35 | __le16 revision; |
63 | } __packed; | ||
64 | |||
65 | #define MGMT_OP_READ_COMMANDS 0x0002 | ||
66 | #define MGMT_READ_COMMANDS_SIZE 0 | ||
67 | struct mgmt_rp_read_commands { | ||
68 | __le16 num_commands; | ||
69 | __le16 num_events; | ||
70 | __le16 opcodes[0]; | ||
71 | } __packed; | 36 | } __packed; |
72 | 37 | ||
73 | #define MGMT_OP_READ_INDEX_LIST 0x0003 | 38 | #define MGMT_OP_READ_INDEX_LIST 0x0003 |
74 | #define MGMT_READ_INDEX_LIST_SIZE 0 | ||
75 | struct mgmt_rp_read_index_list { | 39 | struct mgmt_rp_read_index_list { |
76 | __le16 num_controllers; | 40 | __le16 num_controllers; |
77 | __le16 index[0]; | 41 | __le16 index[0]; |
78 | } __packed; | 42 | } __packed; |
79 | 43 | ||
80 | /* Reserve one extra byte for names in management messages so that they | 44 | /* Reserve one extra byte for names in management messages so that they |
81 | * are always guaranteed to be nul-terminated */ | 45 | * are always guaranteed to be nul-terminated */ |
82 | #define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1) | 46 | #define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1) |
83 | #define MGMT_MAX_SHORT_NAME_LENGTH (HCI_MAX_SHORT_NAME_LENGTH + 1) | ||
84 | |||
85 | #define MGMT_SETTING_POWERED 0x00000001 | ||
86 | #define MGMT_SETTING_CONNECTABLE 0x00000002 | ||
87 | #define MGMT_SETTING_FAST_CONNECTABLE 0x00000004 | ||
88 | #define MGMT_SETTING_DISCOVERABLE 0x00000008 | ||
89 | #define MGMT_SETTING_PAIRABLE 0x00000010 | ||
90 | #define MGMT_SETTING_LINK_SECURITY 0x00000020 | ||
91 | #define MGMT_SETTING_SSP 0x00000040 | ||
92 | #define MGMT_SETTING_BREDR 0x00000080 | ||
93 | #define MGMT_SETTING_HS 0x00000100 | ||
94 | #define MGMT_SETTING_LE 0x00000200 | ||
95 | 47 | ||
96 | #define MGMT_OP_READ_INFO 0x0004 | 48 | #define MGMT_OP_READ_INFO 0x0004 |
97 | #define MGMT_READ_INFO_SIZE 0 | ||
98 | struct mgmt_rp_read_info { | 49 | struct mgmt_rp_read_info { |
99 | bdaddr_t bdaddr; | 50 | __u8 type; |
100 | __u8 version; | 51 | __u8 powered; |
101 | __le16 manufacturer; | 52 | __u8 connectable; |
102 | __le32 supported_settings; | 53 | __u8 discoverable; |
103 | __le32 current_settings; | 54 | __u8 pairable; |
104 | __u8 dev_class[3]; | 55 | __u8 sec_mode; |
105 | __u8 name[MGMT_MAX_NAME_LENGTH]; | 56 | bdaddr_t bdaddr; |
106 | __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; | 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]; | ||
107 | } __packed; | 63 | } __packed; |
108 | 64 | ||
109 | struct mgmt_mode { | 65 | struct mgmt_mode { |
110 | __u8 val; | 66 | __u8 val; |
111 | } __packed; | 67 | } __packed; |
112 | 68 | ||
113 | #define MGMT_SETTING_SIZE 1 | ||
114 | |||
115 | #define MGMT_OP_SET_POWERED 0x0005 | 69 | #define MGMT_OP_SET_POWERED 0x0005 |
116 | 70 | ||
117 | #define MGMT_OP_SET_DISCOVERABLE 0x0006 | 71 | #define MGMT_OP_SET_DISCOVERABLE 0x0006 |
118 | struct mgmt_cp_set_discoverable { | ||
119 | __u8 val; | ||
120 | __le16 timeout; | ||
121 | } __packed; | ||
122 | #define MGMT_SET_DISCOVERABLE_SIZE 3 | ||
123 | 72 | ||
124 | #define MGMT_OP_SET_CONNECTABLE 0x0007 | 73 | #define MGMT_OP_SET_CONNECTABLE 0x0007 |
125 | 74 | ||
126 | #define MGMT_OP_SET_FAST_CONNECTABLE 0x0008 | 75 | #define MGMT_OP_SET_PAIRABLE 0x0008 |
127 | |||
128 | #define MGMT_OP_SET_PAIRABLE 0x0009 | ||
129 | |||
130 | #define MGMT_OP_SET_LINK_SECURITY 0x000A | ||
131 | |||
132 | #define MGMT_OP_SET_SSP 0x000B | ||
133 | |||
134 | #define MGMT_OP_SET_HS 0x000C | ||
135 | |||
136 | #define MGMT_OP_SET_LE 0x000D | ||
137 | #define MGMT_OP_SET_DEV_CLASS 0x000E | ||
138 | struct mgmt_cp_set_dev_class { | ||
139 | __u8 major; | ||
140 | __u8 minor; | ||
141 | } __packed; | ||
142 | #define MGMT_SET_DEV_CLASS_SIZE 2 | ||
143 | |||
144 | #define MGMT_OP_SET_LOCAL_NAME 0x000F | ||
145 | struct mgmt_cp_set_local_name { | ||
146 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
147 | __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; | ||
148 | } __packed; | ||
149 | #define MGMT_SET_LOCAL_NAME_SIZE 260 | ||
150 | 76 | ||
151 | #define MGMT_OP_ADD_UUID 0x0010 | 77 | #define MGMT_OP_ADD_UUID 0x0009 |
152 | struct mgmt_cp_add_uuid { | 78 | struct mgmt_cp_add_uuid { |
153 | __u8 uuid[16]; | 79 | __u8 uuid[16]; |
154 | __u8 svc_hint; | 80 | __u8 svc_hint; |
155 | } __packed; | 81 | } __packed; |
156 | #define MGMT_ADD_UUID_SIZE 17 | ||
157 | 82 | ||
158 | #define MGMT_OP_REMOVE_UUID 0x0011 | 83 | #define MGMT_OP_REMOVE_UUID 0x000A |
159 | struct mgmt_cp_remove_uuid { | 84 | struct mgmt_cp_remove_uuid { |
160 | __u8 uuid[16]; | 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; | ||
161 | } __packed; | 92 | } __packed; |
162 | #define MGMT_REMOVE_UUID_SIZE 16 | ||
163 | 93 | ||
164 | struct mgmt_link_key_info { | 94 | #define MGMT_OP_SET_SERVICE_CACHE 0x000C |
165 | struct mgmt_addr_info addr; | 95 | struct mgmt_cp_set_service_cache { |
166 | __u8 type; | 96 | __u8 enable; |
167 | __u8 val[16]; | ||
168 | __u8 pin_len; | ||
169 | } __packed; | 97 | } __packed; |
170 | 98 | ||
171 | #define MGMT_OP_LOAD_LINK_KEYS 0x0012 | 99 | struct mgmt_key_info { |
172 | struct mgmt_cp_load_link_keys { | 100 | bdaddr_t bdaddr; |
173 | __u8 debug_keys; | 101 | u8 type; |
174 | __le16 key_count; | 102 | u8 val[16]; |
175 | struct mgmt_link_key_info keys[0]; | 103 | u8 pin_len; |
104 | u8 dlen; | ||
105 | u8 data[0]; | ||
176 | } __packed; | 106 | } __packed; |
177 | #define MGMT_LOAD_LINK_KEYS_SIZE 3 | ||
178 | 107 | ||
179 | struct mgmt_ltk_info { | 108 | #define MGMT_OP_LOAD_KEYS 0x000D |
180 | struct mgmt_addr_info addr; | 109 | struct mgmt_cp_load_keys { |
181 | __u8 authenticated; | 110 | __u8 debug_keys; |
182 | __u8 master; | 111 | __le16 key_count; |
183 | __u8 enc_size; | 112 | struct mgmt_key_info keys[0]; |
184 | __le16 ediv; | ||
185 | __u8 rand[8]; | ||
186 | __u8 val[16]; | ||
187 | } __packed; | 113 | } __packed; |
188 | 114 | ||
189 | #define MGMT_OP_LOAD_LONG_TERM_KEYS 0x0013 | 115 | #define MGMT_OP_REMOVE_KEY 0x000E |
190 | struct mgmt_cp_load_long_term_keys { | 116 | struct mgmt_cp_remove_key { |
191 | __le16 key_count; | 117 | bdaddr_t bdaddr; |
192 | struct mgmt_ltk_info keys[0]; | 118 | __u8 disconnect; |
193 | } __packed; | 119 | } __packed; |
194 | #define MGMT_LOAD_LONG_TERM_KEYS_SIZE 2 | ||
195 | 120 | ||
196 | #define MGMT_OP_DISCONNECT 0x0014 | 121 | #define MGMT_OP_DISCONNECT 0x000F |
197 | struct mgmt_cp_disconnect { | 122 | struct mgmt_cp_disconnect { |
198 | struct mgmt_addr_info addr; | 123 | bdaddr_t bdaddr; |
199 | } __packed; | 124 | } __packed; |
200 | #define MGMT_DISCONNECT_SIZE MGMT_ADDR_INFO_SIZE | ||
201 | struct mgmt_rp_disconnect { | 125 | struct mgmt_rp_disconnect { |
202 | struct mgmt_addr_info addr; | 126 | bdaddr_t bdaddr; |
203 | } __packed; | 127 | } __packed; |
204 | 128 | ||
205 | #define MGMT_OP_GET_CONNECTIONS 0x0015 | 129 | #define MGMT_OP_GET_CONNECTIONS 0x0010 |
206 | #define MGMT_GET_CONNECTIONS_SIZE 0 | ||
207 | struct mgmt_rp_get_connections { | 130 | struct mgmt_rp_get_connections { |
208 | __le16 conn_count; | 131 | __le16 conn_count; |
209 | struct mgmt_addr_info addr[0]; | 132 | bdaddr_t conn[0]; |
210 | } __packed; | 133 | } __packed; |
211 | 134 | ||
212 | #define MGMT_OP_PIN_CODE_REPLY 0x0016 | 135 | #define MGMT_OP_PIN_CODE_REPLY 0x0011 |
213 | struct mgmt_cp_pin_code_reply { | 136 | struct mgmt_cp_pin_code_reply { |
214 | struct mgmt_addr_info addr; | 137 | bdaddr_t bdaddr; |
215 | __u8 pin_len; | 138 | __u8 pin_len; |
216 | __u8 pin_code[16]; | 139 | __u8 pin_code[16]; |
217 | } __packed; | 140 | } __packed; |
218 | #define MGMT_PIN_CODE_REPLY_SIZE (MGMT_ADDR_INFO_SIZE + 17) | ||
219 | struct mgmt_rp_pin_code_reply { | 141 | struct mgmt_rp_pin_code_reply { |
220 | struct mgmt_addr_info addr; | 142 | bdaddr_t bdaddr; |
143 | uint8_t status; | ||
221 | } __packed; | 144 | } __packed; |
222 | 145 | ||
223 | #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0017 | 146 | #define MGMT_OP_PIN_CODE_NEG_REPLY 0x0012 |
224 | struct mgmt_cp_pin_code_neg_reply { | 147 | struct mgmt_cp_pin_code_neg_reply { |
225 | struct mgmt_addr_info addr; | 148 | bdaddr_t bdaddr; |
226 | } __packed; | 149 | } __packed; |
227 | #define MGMT_PIN_CODE_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE | ||
228 | 150 | ||
229 | #define MGMT_OP_SET_IO_CAPABILITY 0x0018 | 151 | #define MGMT_OP_SET_IO_CAPABILITY 0x0013 |
230 | struct mgmt_cp_set_io_capability { | 152 | struct mgmt_cp_set_io_capability { |
231 | __u8 io_capability; | 153 | __u8 io_capability; |
232 | } __packed; | 154 | } __packed; |
233 | #define MGMT_SET_IO_CAPABILITY_SIZE 1 | ||
234 | 155 | ||
235 | #define MGMT_OP_PAIR_DEVICE 0x0019 | 156 | #define MGMT_OP_PAIR_DEVICE 0x0014 |
236 | struct mgmt_cp_pair_device { | 157 | struct mgmt_cp_pair_device { |
237 | struct mgmt_addr_info addr; | 158 | bdaddr_t bdaddr; |
238 | __u8 io_cap; | 159 | __u8 io_cap; |
239 | } __packed; | 160 | } __packed; |
240 | #define MGMT_PAIR_DEVICE_SIZE (MGMT_ADDR_INFO_SIZE + 1) | ||
241 | struct mgmt_rp_pair_device { | 161 | struct mgmt_rp_pair_device { |
242 | struct mgmt_addr_info addr; | 162 | bdaddr_t bdaddr; |
163 | __u8 status; | ||
243 | } __packed; | 164 | } __packed; |
244 | 165 | ||
245 | #define MGMT_OP_CANCEL_PAIR_DEVICE 0x001A | 166 | #define MGMT_OP_USER_CONFIRM_REPLY 0x0015 |
246 | #define MGMT_CANCEL_PAIR_DEVICE_SIZE MGMT_ADDR_INFO_SIZE | ||
247 | |||
248 | #define MGMT_OP_UNPAIR_DEVICE 0x001B | ||
249 | struct mgmt_cp_unpair_device { | ||
250 | struct mgmt_addr_info addr; | ||
251 | __u8 disconnect; | ||
252 | } __packed; | ||
253 | #define MGMT_UNPAIR_DEVICE_SIZE (MGMT_ADDR_INFO_SIZE + 1) | ||
254 | struct mgmt_rp_unpair_device { | ||
255 | struct mgmt_addr_info addr; | ||
256 | }; | ||
257 | |||
258 | #define MGMT_OP_USER_CONFIRM_REPLY 0x001C | ||
259 | struct mgmt_cp_user_confirm_reply { | 167 | struct mgmt_cp_user_confirm_reply { |
260 | struct mgmt_addr_info addr; | 168 | bdaddr_t bdaddr; |
261 | } __packed; | 169 | } __packed; |
262 | #define MGMT_USER_CONFIRM_REPLY_SIZE MGMT_ADDR_INFO_SIZE | ||
263 | struct mgmt_rp_user_confirm_reply { | 170 | struct mgmt_rp_user_confirm_reply { |
264 | struct mgmt_addr_info addr; | 171 | bdaddr_t bdaddr; |
172 | __u8 status; | ||
265 | } __packed; | 173 | } __packed; |
266 | 174 | ||
267 | #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x001D | 175 | #define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016 |
268 | struct mgmt_cp_user_confirm_neg_reply { | ||
269 | struct mgmt_addr_info addr; | ||
270 | } __packed; | ||
271 | #define MGMT_USER_CONFIRM_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE | ||
272 | 176 | ||
273 | #define MGMT_OP_USER_PASSKEY_REPLY 0x001E | 177 | #define MGMT_OP_SET_LOCAL_NAME 0x0017 |
274 | struct mgmt_cp_user_passkey_reply { | 178 | struct mgmt_cp_set_local_name { |
275 | struct mgmt_addr_info addr; | 179 | __u8 name[MGMT_MAX_NAME_LENGTH]; |
276 | __le32 passkey; | ||
277 | } __packed; | ||
278 | #define MGMT_USER_PASSKEY_REPLY_SIZE (MGMT_ADDR_INFO_SIZE + 4) | ||
279 | struct mgmt_rp_user_passkey_reply { | ||
280 | struct mgmt_addr_info addr; | ||
281 | } __packed; | ||
282 | |||
283 | #define MGMT_OP_USER_PASSKEY_NEG_REPLY 0x001F | ||
284 | struct mgmt_cp_user_passkey_neg_reply { | ||
285 | struct mgmt_addr_info addr; | ||
286 | } __packed; | 180 | } __packed; |
287 | #define MGMT_USER_PASSKEY_NEG_REPLY_SIZE MGMT_ADDR_INFO_SIZE | ||
288 | 181 | ||
289 | #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0020 | 182 | #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018 |
290 | #define MGMT_READ_LOCAL_OOB_DATA_SIZE 0 | ||
291 | struct mgmt_rp_read_local_oob_data { | 183 | struct mgmt_rp_read_local_oob_data { |
292 | __u8 hash[16]; | 184 | __u8 hash[16]; |
293 | __u8 randomizer[16]; | 185 | __u8 randomizer[16]; |
294 | } __packed; | 186 | } __packed; |
295 | 187 | ||
296 | #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0021 | 188 | #define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019 |
297 | struct mgmt_cp_add_remote_oob_data { | 189 | struct mgmt_cp_add_remote_oob_data { |
298 | struct mgmt_addr_info addr; | 190 | bdaddr_t bdaddr; |
299 | __u8 hash[16]; | 191 | __u8 hash[16]; |
300 | __u8 randomizer[16]; | 192 | __u8 randomizer[16]; |
301 | } __packed; | 193 | } __packed; |
302 | #define MGMT_ADD_REMOTE_OOB_DATA_SIZE (MGMT_ADDR_INFO_SIZE + 32) | ||
303 | 194 | ||
304 | #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x0022 | 195 | #define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A |
305 | struct mgmt_cp_remove_remote_oob_data { | 196 | struct mgmt_cp_remove_remote_oob_data { |
306 | struct mgmt_addr_info addr; | 197 | bdaddr_t bdaddr; |
307 | } __packed; | 198 | } __packed; |
308 | #define MGMT_REMOVE_REMOTE_OOB_DATA_SIZE MGMT_ADDR_INFO_SIZE | ||
309 | 199 | ||
310 | #define MGMT_OP_START_DISCOVERY 0x0023 | 200 | #define MGMT_OP_START_DISCOVERY 0x001B |
311 | struct mgmt_cp_start_discovery { | ||
312 | __u8 type; | ||
313 | } __packed; | ||
314 | #define MGMT_START_DISCOVERY_SIZE 1 | ||
315 | |||
316 | #define MGMT_OP_STOP_DISCOVERY 0x0024 | ||
317 | struct mgmt_cp_stop_discovery { | ||
318 | __u8 type; | ||
319 | } __packed; | ||
320 | #define MGMT_STOP_DISCOVERY_SIZE 1 | ||
321 | 201 | ||
322 | #define MGMT_OP_CONFIRM_NAME 0x0025 | 202 | #define MGMT_OP_STOP_DISCOVERY 0x001C |
323 | struct mgmt_cp_confirm_name { | ||
324 | struct mgmt_addr_info addr; | ||
325 | __u8 name_known; | ||
326 | } __packed; | ||
327 | #define MGMT_CONFIRM_NAME_SIZE (MGMT_ADDR_INFO_SIZE + 1) | ||
328 | struct mgmt_rp_confirm_name { | ||
329 | struct mgmt_addr_info addr; | ||
330 | } __packed; | ||
331 | 203 | ||
332 | #define MGMT_OP_BLOCK_DEVICE 0x0026 | 204 | #define MGMT_OP_BLOCK_DEVICE 0x001D |
333 | struct mgmt_cp_block_device { | 205 | struct mgmt_cp_block_device { |
334 | struct mgmt_addr_info addr; | 206 | bdaddr_t bdaddr; |
335 | } __packed; | 207 | } __packed; |
336 | #define MGMT_BLOCK_DEVICE_SIZE MGMT_ADDR_INFO_SIZE | ||
337 | 208 | ||
338 | #define MGMT_OP_UNBLOCK_DEVICE 0x0027 | 209 | #define MGMT_OP_UNBLOCK_DEVICE 0x001E |
339 | struct mgmt_cp_unblock_device { | 210 | struct mgmt_cp_unblock_device { |
340 | struct mgmt_addr_info addr; | 211 | bdaddr_t bdaddr; |
341 | } __packed; | 212 | } __packed; |
342 | #define MGMT_UNBLOCK_DEVICE_SIZE MGMT_ADDR_INFO_SIZE | ||
343 | |||
344 | #define MGMT_OP_SET_DEVICE_ID 0x0028 | ||
345 | struct mgmt_cp_set_device_id { | ||
346 | __le16 source; | ||
347 | __le16 vendor; | ||
348 | __le16 product; | ||
349 | __le16 version; | ||
350 | } __packed; | ||
351 | #define MGMT_SET_DEVICE_ID_SIZE 8 | ||
352 | 213 | ||
353 | #define MGMT_EV_CMD_COMPLETE 0x0001 | 214 | #define MGMT_EV_CMD_COMPLETE 0x0001 |
354 | struct mgmt_ev_cmd_complete { | 215 | struct mgmt_ev_cmd_complete { |
355 | __le16 opcode; | 216 | __le16 opcode; |
356 | __u8 status; | 217 | __u8 data[0]; |
357 | __u8 data[0]; | ||
358 | } __packed; | 218 | } __packed; |
359 | 219 | ||
360 | #define MGMT_EV_CMD_STATUS 0x0002 | 220 | #define MGMT_EV_CMD_STATUS 0x0002 |
361 | struct mgmt_ev_cmd_status { | 221 | struct mgmt_ev_cmd_status { |
362 | __le16 opcode; | 222 | __u8 status; |
363 | __u8 status; | 223 | __le16 opcode; |
364 | } __packed; | 224 | } __packed; |
365 | 225 | ||
366 | #define MGMT_EV_CONTROLLER_ERROR 0x0003 | 226 | #define MGMT_EV_CONTROLLER_ERROR 0x0003 |
367 | struct mgmt_ev_controller_error { | 227 | struct mgmt_ev_controller_error { |
368 | __u8 error_code; | 228 | __u8 error_code; |
369 | } __packed; | 229 | } __packed; |
370 | 230 | ||
371 | #define MGMT_EV_INDEX_ADDED 0x0004 | 231 | #define MGMT_EV_INDEX_ADDED 0x0004 |
372 | 232 | ||
373 | #define MGMT_EV_INDEX_REMOVED 0x0005 | 233 | #define MGMT_EV_INDEX_REMOVED 0x0005 |
374 | 234 | ||
375 | #define MGMT_EV_NEW_SETTINGS 0x0006 | 235 | #define MGMT_EV_POWERED 0x0006 |
376 | 236 | ||
377 | #define MGMT_EV_CLASS_OF_DEV_CHANGED 0x0007 | 237 | #define MGMT_EV_DISCOVERABLE 0x0007 |
378 | struct mgmt_ev_class_of_dev_changed { | ||
379 | __u8 dev_class[3]; | ||
380 | }; | ||
381 | 238 | ||
382 | #define MGMT_EV_LOCAL_NAME_CHANGED 0x0008 | 239 | #define MGMT_EV_CONNECTABLE 0x0008 |
383 | struct mgmt_ev_local_name_changed { | ||
384 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
385 | __u8 short_name[MGMT_MAX_SHORT_NAME_LENGTH]; | ||
386 | } __packed; | ||
387 | 240 | ||
388 | #define MGMT_EV_NEW_LINK_KEY 0x0009 | 241 | #define MGMT_EV_PAIRABLE 0x0009 |
389 | struct mgmt_ev_new_link_key { | ||
390 | __u8 store_hint; | ||
391 | struct mgmt_link_key_info key; | ||
392 | } __packed; | ||
393 | 242 | ||
394 | #define MGMT_EV_NEW_LONG_TERM_KEY 0x000A | 243 | #define MGMT_EV_NEW_KEY 0x000A |
395 | struct mgmt_ev_new_long_term_key { | 244 | struct mgmt_ev_new_key { |
396 | __u8 store_hint; | 245 | __u8 store_hint; |
397 | struct mgmt_ltk_info key; | 246 | struct mgmt_key_info key; |
398 | } __packed; | 247 | } __packed; |
399 | 248 | ||
400 | #define MGMT_EV_DEVICE_CONNECTED 0x000B | 249 | #define MGMT_EV_CONNECTED 0x000B |
401 | struct mgmt_ev_device_connected { | 250 | struct mgmt_ev_connected { |
402 | struct mgmt_addr_info addr; | 251 | bdaddr_t bdaddr; |
403 | __le32 flags; | ||
404 | __le16 eir_len; | ||
405 | __u8 eir[0]; | ||
406 | } __packed; | 252 | } __packed; |
407 | 253 | ||
408 | #define MGMT_DEV_DISCONN_UNKNOWN 0x00 | 254 | #define MGMT_EV_DISCONNECTED 0x000C |
409 | #define MGMT_DEV_DISCONN_TIMEOUT 0x01 | 255 | struct mgmt_ev_disconnected { |
410 | #define MGMT_DEV_DISCONN_LOCAL_HOST 0x02 | 256 | bdaddr_t bdaddr; |
411 | #define MGMT_DEV_DISCONN_REMOTE 0x03 | ||
412 | |||
413 | #define MGMT_EV_DEVICE_DISCONNECTED 0x000C | ||
414 | struct mgmt_ev_device_disconnected { | ||
415 | struct mgmt_addr_info addr; | ||
416 | __u8 reason; | ||
417 | } __packed; | 257 | } __packed; |
418 | 258 | ||
419 | #define MGMT_EV_CONNECT_FAILED 0x000D | 259 | #define MGMT_EV_CONNECT_FAILED 0x000D |
420 | struct mgmt_ev_connect_failed { | 260 | struct mgmt_ev_connect_failed { |
421 | struct mgmt_addr_info addr; | 261 | bdaddr_t bdaddr; |
422 | __u8 status; | 262 | __u8 status; |
423 | } __packed; | 263 | } __packed; |
424 | 264 | ||
425 | #define MGMT_EV_PIN_CODE_REQUEST 0x000E | 265 | #define MGMT_EV_PIN_CODE_REQUEST 0x000E |
426 | struct mgmt_ev_pin_code_request { | 266 | struct mgmt_ev_pin_code_request { |
427 | struct mgmt_addr_info addr; | 267 | bdaddr_t bdaddr; |
428 | __u8 secure; | 268 | __u8 secure; |
429 | } __packed; | 269 | } __packed; |
430 | 270 | ||
431 | #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F | 271 | #define MGMT_EV_USER_CONFIRM_REQUEST 0x000F |
432 | struct mgmt_ev_user_confirm_request { | 272 | struct mgmt_ev_user_confirm_request { |
433 | struct mgmt_addr_info addr; | 273 | bdaddr_t bdaddr; |
434 | __u8 confirm_hint; | 274 | __u8 confirm_hint; |
435 | __le32 value; | 275 | __le32 value; |
436 | } __packed; | ||
437 | |||
438 | #define MGMT_EV_USER_PASSKEY_REQUEST 0x0010 | ||
439 | struct mgmt_ev_user_passkey_request { | ||
440 | struct mgmt_addr_info addr; | ||
441 | } __packed; | 276 | } __packed; |
442 | 277 | ||
443 | #define MGMT_EV_AUTH_FAILED 0x0011 | 278 | #define MGMT_EV_AUTH_FAILED 0x0010 |
444 | struct mgmt_ev_auth_failed { | 279 | struct mgmt_ev_auth_failed { |
445 | struct mgmt_addr_info addr; | 280 | bdaddr_t bdaddr; |
446 | __u8 status; | 281 | __u8 status; |
447 | } __packed; | 282 | } __packed; |
448 | 283 | ||
449 | #define MGMT_DEV_FOUND_CONFIRM_NAME 0x01 | 284 | #define MGMT_EV_LOCAL_NAME_CHANGED 0x0011 |
450 | #define MGMT_DEV_FOUND_LEGACY_PAIRING 0x02 | 285 | struct mgmt_ev_local_name_changed { |
286 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
287 | } __packed; | ||
451 | 288 | ||
452 | #define MGMT_EV_DEVICE_FOUND 0x0012 | 289 | #define MGMT_EV_DEVICE_FOUND 0x0012 |
453 | struct mgmt_ev_device_found { | 290 | struct mgmt_ev_device_found { |
454 | struct mgmt_addr_info addr; | 291 | bdaddr_t bdaddr; |
455 | __s8 rssi; | 292 | __u8 dev_class[3]; |
456 | __le32 flags; | 293 | __s8 rssi; |
457 | __le16 eir_len; | 294 | __u8 eir[HCI_MAX_EIR_LENGTH]; |
458 | __u8 eir[0]; | ||
459 | } __packed; | 295 | } __packed; |
460 | 296 | ||
461 | #define MGMT_EV_DISCOVERING 0x0013 | 297 | #define MGMT_EV_REMOTE_NAME 0x0013 |
462 | struct mgmt_ev_discovering { | 298 | struct mgmt_ev_remote_name { |
463 | __u8 type; | 299 | bdaddr_t bdaddr; |
464 | __u8 discovering; | 300 | __u8 name[MGMT_MAX_NAME_LENGTH]; |
465 | } __packed; | 301 | } __packed; |
466 | 302 | ||
467 | #define MGMT_EV_DEVICE_BLOCKED 0x0014 | 303 | #define MGMT_EV_DISCOVERING 0x0014 |
468 | struct mgmt_ev_device_blocked { | ||
469 | struct mgmt_addr_info addr; | ||
470 | } __packed; | ||
471 | |||
472 | #define MGMT_EV_DEVICE_UNBLOCKED 0x0015 | ||
473 | struct mgmt_ev_device_unblocked { | ||
474 | struct mgmt_addr_info addr; | ||
475 | } __packed; | ||
476 | |||
477 | #define MGMT_EV_DEVICE_UNPAIRED 0x0016 | ||
478 | struct mgmt_ev_device_unpaired { | ||
479 | struct mgmt_addr_info addr; | ||
480 | } __packed; | ||
481 | |||
482 | #define MGMT_EV_PASSKEY_NOTIFY 0x0017 | ||
483 | struct mgmt_ev_passkey_notify { | ||
484 | struct mgmt_addr_info addr; | ||
485 | __le32 passkey; | ||
486 | __u8 entered; | ||
487 | } __packed; | ||
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h index e2e3ecad100..d5eee2093b1 100644 --- a/include/net/bluetooth/rfcomm.h +++ b/include/net/bluetooth/rfcomm.h | |||
@@ -211,7 +211,6 @@ struct rfcomm_dlc { | |||
211 | #define RFCOMM_AUTH_ACCEPT 6 | 211 | #define RFCOMM_AUTH_ACCEPT 6 |
212 | #define RFCOMM_AUTH_REJECT 7 | 212 | #define RFCOMM_AUTH_REJECT 7 |
213 | #define RFCOMM_DEFER_SETUP 8 | 213 | #define RFCOMM_DEFER_SETUP 8 |
214 | #define RFCOMM_ENC_DROP 9 | ||
215 | 214 | ||
216 | /* Scheduling flags and events */ | 215 | /* Scheduling flags and events */ |
217 | #define RFCOMM_SCHED_WAKEUP 31 | 216 | #define RFCOMM_SCHED_WAKEUP 31 |
diff --git a/include/net/bluetooth/sco.h b/include/net/bluetooth/sco.h index 1e35c43657c..6d1857ab8e5 100644 --- a/include/net/bluetooth/sco.h +++ b/include/net/bluetooth/sco.h | |||
@@ -37,6 +37,7 @@ | |||
37 | struct sockaddr_sco { | 37 | struct sockaddr_sco { |
38 | sa_family_t sco_family; | 38 | sa_family_t sco_family; |
39 | bdaddr_t sco_bdaddr; | 39 | bdaddr_t sco_bdaddr; |
40 | __u16 sco_pkt_type; | ||
40 | }; | 41 | }; |
41 | 42 | ||
42 | /* SCO socket options */ | 43 | /* SCO socket options */ |
@@ -72,7 +73,8 @@ struct sco_conn { | |||
72 | 73 | ||
73 | struct sco_pinfo { | 74 | struct sco_pinfo { |
74 | struct bt_sock bt; | 75 | struct bt_sock bt; |
75 | __u32 flags; | 76 | __u16 pkt_type; |
77 | |||
76 | struct sco_conn *conn; | 78 | struct sco_conn *conn; |
77 | }; | 79 | }; |
78 | 80 | ||
diff --git a/include/net/bluetooth/smp.h b/include/net/bluetooth/smp.h index f8ba07f3e5f..46c45761230 100644 --- a/include/net/bluetooth/smp.h +++ b/include/net/bluetooth/smp.h | |||
@@ -77,7 +77,7 @@ struct smp_cmd_encrypt_info { | |||
77 | 77 | ||
78 | #define SMP_CMD_MASTER_IDENT 0x07 | 78 | #define SMP_CMD_MASTER_IDENT 0x07 |
79 | struct smp_cmd_master_ident { | 79 | struct smp_cmd_master_ident { |
80 | __le16 ediv; | 80 | __u16 ediv; |
81 | __u8 rand[8]; | 81 | __u8 rand[8]; |
82 | } __packed; | 82 | } __packed; |
83 | 83 | ||
@@ -108,39 +108,16 @@ struct smp_cmd_security_req { | |||
108 | #define SMP_CONFIRM_FAILED 0x04 | 108 | #define SMP_CONFIRM_FAILED 0x04 |
109 | #define SMP_PAIRING_NOTSUPP 0x05 | 109 | #define SMP_PAIRING_NOTSUPP 0x05 |
110 | #define SMP_ENC_KEY_SIZE 0x06 | 110 | #define SMP_ENC_KEY_SIZE 0x06 |
111 | #define SMP_CMD_NOTSUPP 0x07 | 111 | #define SMP_CMD_NOTSUPP 0x07 |
112 | #define SMP_UNSPECIFIED 0x08 | 112 | #define SMP_UNSPECIFIED 0x08 |
113 | #define SMP_REPEATED_ATTEMPTS 0x09 | 113 | #define SMP_REPEATED_ATTEMPTS 0x09 |
114 | 114 | ||
115 | #define SMP_MIN_ENC_KEY_SIZE 7 | 115 | #define SMP_MIN_ENC_KEY_SIZE 7 |
116 | #define SMP_MAX_ENC_KEY_SIZE 16 | 116 | #define SMP_MAX_ENC_KEY_SIZE 16 |
117 | 117 | ||
118 | #define SMP_FLAG_TK_VALID 1 | ||
119 | #define SMP_FLAG_CFM_PENDING 2 | ||
120 | #define SMP_FLAG_MITM_AUTH 3 | ||
121 | |||
122 | struct smp_chan { | ||
123 | struct l2cap_conn *conn; | ||
124 | u8 preq[7]; /* SMP Pairing Request */ | ||
125 | u8 prsp[7]; /* SMP Pairing Response */ | ||
126 | u8 prnd[16]; /* SMP Pairing Random (local) */ | ||
127 | u8 rrnd[16]; /* SMP Pairing Random (remote) */ | ||
128 | u8 pcnf[16]; /* SMP Pairing Confirm */ | ||
129 | u8 tk[16]; /* SMP Temporary Key */ | ||
130 | u8 enc_key_size; | ||
131 | unsigned long smp_flags; | ||
132 | struct crypto_blkcipher *tfm; | ||
133 | struct work_struct confirm; | ||
134 | struct work_struct random; | ||
135 | |||
136 | }; | ||
137 | |||
138 | /* SMP Commands */ | 118 | /* SMP Commands */ |
139 | int smp_conn_security(struct hci_conn *hcon, __u8 sec_level); | 119 | int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level); |
140 | int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb); | 120 | int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb); |
141 | int smp_distribute_keys(struct l2cap_conn *conn, __u8 force); | 121 | int smp_distribute_keys(struct l2cap_conn *conn, __u8 force); |
142 | int smp_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, __le32 passkey); | ||
143 | |||
144 | void smp_chan_destroy(struct l2cap_conn *conn); | ||
145 | 122 | ||
146 | #endif /* __SMP_H */ | 123 | #endif /* __SMP_H */ |
diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h index ef2dd9438bb..c011281d92c 100644 --- a/include/net/caif/caif_dev.h +++ b/include/net/caif/caif_dev.h | |||
@@ -9,7 +9,6 @@ | |||
9 | 9 | ||
10 | #include <net/caif/caif_layer.h> | 10 | #include <net/caif/caif_layer.h> |
11 | #include <net/caif/cfcnfg.h> | 11 | #include <net/caif/cfcnfg.h> |
12 | #include <net/caif/caif_device.h> | ||
13 | #include <linux/caif/caif_socket.h> | 12 | #include <linux/caif/caif_socket.h> |
14 | #include <linux/if.h> | 13 | #include <linux/if.h> |
15 | #include <linux/net.h> | 14 | #include <linux/net.h> |
@@ -105,24 +104,4 @@ void caif_client_register_refcnt(struct cflayer *adapt_layer, | |||
105 | */ | 104 | */ |
106 | void caif_free_client(struct cflayer *adap_layer); | 105 | void caif_free_client(struct cflayer *adap_layer); |
107 | 106 | ||
108 | /** | ||
109 | * struct caif_enroll_dev - Enroll a net-device as a CAIF Link layer | ||
110 | * @dev: Network device to enroll. | ||
111 | * @caifdev: Configuration information from CAIF Link Layer | ||
112 | * @link_support: Link layer support layer | ||
113 | * @head_room: Head room needed by link support layer | ||
114 | * @layer: Lowest layer in CAIF stack | ||
115 | * @rcv_fun: Receive function for CAIF stack. | ||
116 | * | ||
117 | * This function enroll a CAIF link layer into CAIF Stack and | ||
118 | * expects the interface to be able to handle CAIF payload. | ||
119 | * The link_support layer is used to add any Link Layer specific | ||
120 | * framing. | ||
121 | */ | ||
122 | void caif_enroll_dev(struct net_device *dev, struct caif_dev_common *caifdev, | ||
123 | struct cflayer *link_support, int head_room, | ||
124 | struct cflayer **layer, int (**rcv_func)( | ||
125 | struct sk_buff *, struct net_device *, | ||
126 | struct packet_type *, struct net_device *)); | ||
127 | |||
128 | #endif /* CAIF_DEV_H_ */ | 107 | #endif /* CAIF_DEV_H_ */ |
diff --git a/include/net/caif/caif_hsi.h b/include/net/caif/caif_hsi.h index bcb9cc3ce98..c5dedd87b4c 100644 --- a/include/net/caif/caif_hsi.h +++ b/include/net/caif/caif_hsi.h | |||
@@ -52,9 +52,8 @@ struct cfhsi_desc { | |||
52 | /* | 52 | /* |
53 | * Maximum bytes transferred in one transfer. | 53 | * Maximum bytes transferred in one transfer. |
54 | */ | 54 | */ |
55 | #define CFHSI_MAX_CAIF_FRAME_SZ 4096 | 55 | /* TODO: 4096 is temporary... */ |
56 | 56 | #define CFHSI_MAX_PAYLOAD_SZ (CFHSI_MAX_PKTS * 4096) | |
57 | #define CFHSI_MAX_PAYLOAD_SZ (CFHSI_MAX_PKTS * CFHSI_MAX_CAIF_FRAME_SZ) | ||
58 | 57 | ||
59 | /* Size of the complete HSI TX buffer. */ | 58 | /* Size of the complete HSI TX buffer. */ |
60 | #define CFHSI_BUF_SZ_TX (CFHSI_DESC_SZ + CFHSI_MAX_PAYLOAD_SZ) | 59 | #define CFHSI_BUF_SZ_TX (CFHSI_DESC_SZ + CFHSI_MAX_PAYLOAD_SZ) |
@@ -76,69 +75,38 @@ struct cfhsi_desc { | |||
76 | #define CFHSI_WAKE_UP_ACK 1 | 75 | #define CFHSI_WAKE_UP_ACK 1 |
77 | #define CFHSI_WAKE_DOWN_ACK 2 | 76 | #define CFHSI_WAKE_DOWN_ACK 2 |
78 | #define CFHSI_AWAKE 3 | 77 | #define CFHSI_AWAKE 3 |
79 | #define CFHSI_WAKELOCK_HELD 4 | 78 | #define CFHSI_PENDING_RX 4 |
80 | #define CFHSI_SHUTDOWN 5 | 79 | #define CFHSI_SHUTDOWN 6 |
81 | #define CFHSI_FLUSH_FIFO 6 | 80 | #define CFHSI_FLUSH_FIFO 7 |
82 | 81 | ||
83 | #ifndef CFHSI_INACTIVITY_TOUT | 82 | #ifndef CFHSI_INACTIVITY_TOUT |
84 | #define CFHSI_INACTIVITY_TOUT (1 * HZ) | 83 | #define CFHSI_INACTIVITY_TOUT (1 * HZ) |
85 | #endif /* CFHSI_INACTIVITY_TOUT */ | 84 | #endif /* CFHSI_INACTIVITY_TOUT */ |
86 | 85 | ||
87 | #ifndef CFHSI_WAKE_TOUT | 86 | #ifndef CFHSI_WAKEUP_TOUT |
88 | #define CFHSI_WAKE_TOUT (3 * HZ) | 87 | #define CFHSI_WAKEUP_TOUT (3 * HZ) |
89 | #endif /* CFHSI_WAKE_TOUT */ | 88 | #endif /* CFHSI_WAKEUP_TOUT */ |
90 | 89 | ||
91 | #ifndef CFHSI_MAX_RX_RETRIES | ||
92 | #define CFHSI_MAX_RX_RETRIES (10 * HZ) | ||
93 | #endif | ||
94 | 90 | ||
95 | /* Structure implemented by the CAIF HSI driver. */ | 91 | /* Structure implemented by the CAIF HSI driver. */ |
96 | struct cfhsi_cb_ops { | 92 | struct cfhsi_drv { |
97 | void (*tx_done_cb) (struct cfhsi_cb_ops *drv); | 93 | void (*tx_done_cb) (struct cfhsi_drv *drv); |
98 | void (*rx_done_cb) (struct cfhsi_cb_ops *drv); | 94 | void (*rx_done_cb) (struct cfhsi_drv *drv); |
99 | void (*wake_up_cb) (struct cfhsi_cb_ops *drv); | 95 | void (*wake_up_cb) (struct cfhsi_drv *drv); |
100 | void (*wake_down_cb) (struct cfhsi_cb_ops *drv); | 96 | void (*wake_down_cb) (struct cfhsi_drv *drv); |
101 | }; | 97 | }; |
102 | 98 | ||
103 | /* Structure implemented by HSI device. */ | 99 | /* Structure implemented by HSI device. */ |
104 | struct cfhsi_ops { | 100 | struct cfhsi_dev { |
105 | int (*cfhsi_up) (struct cfhsi_ops *dev); | 101 | int (*cfhsi_up) (struct cfhsi_dev *dev); |
106 | int (*cfhsi_down) (struct cfhsi_ops *dev); | 102 | int (*cfhsi_down) (struct cfhsi_dev *dev); |
107 | int (*cfhsi_tx) (u8 *ptr, int len, struct cfhsi_ops *dev); | 103 | int (*cfhsi_tx) (u8 *ptr, int len, struct cfhsi_dev *dev); |
108 | int (*cfhsi_rx) (u8 *ptr, int len, struct cfhsi_ops *dev); | 104 | int (*cfhsi_rx) (u8 *ptr, int len, struct cfhsi_dev *dev); |
109 | int (*cfhsi_wake_up) (struct cfhsi_ops *dev); | 105 | int (*cfhsi_wake_up) (struct cfhsi_dev *dev); |
110 | int (*cfhsi_wake_down) (struct cfhsi_ops *dev); | 106 | int (*cfhsi_wake_down) (struct cfhsi_dev *dev); |
111 | int (*cfhsi_get_peer_wake) (struct cfhsi_ops *dev, bool *status); | 107 | int (*cfhsi_fifo_occupancy)(struct cfhsi_dev *dev, size_t *occupancy); |
112 | int (*cfhsi_fifo_occupancy) (struct cfhsi_ops *dev, size_t *occupancy); | 108 | int (*cfhsi_rx_cancel)(struct cfhsi_dev *dev); |
113 | int (*cfhsi_rx_cancel)(struct cfhsi_ops *dev); | 109 | struct cfhsi_drv *drv; |
114 | struct cfhsi_cb_ops *cb_ops; | ||
115 | }; | ||
116 | |||
117 | /* Structure holds status of received CAIF frames processing */ | ||
118 | struct cfhsi_rx_state { | ||
119 | int state; | ||
120 | int nfrms; | ||
121 | int pld_len; | ||
122 | int retries; | ||
123 | bool piggy_desc; | ||
124 | }; | ||
125 | |||
126 | /* Priority mapping */ | ||
127 | enum { | ||
128 | CFHSI_PRIO_CTL = 0, | ||
129 | CFHSI_PRIO_VI, | ||
130 | CFHSI_PRIO_VO, | ||
131 | CFHSI_PRIO_BEBK, | ||
132 | CFHSI_PRIO_LAST, | ||
133 | }; | ||
134 | |||
135 | struct cfhsi_config { | ||
136 | u32 inactivity_timeout; | ||
137 | u32 aggregation_timeout; | ||
138 | u32 head_align; | ||
139 | u32 tail_align; | ||
140 | u32 q_high_mark; | ||
141 | u32 q_low_mark; | ||
142 | }; | 110 | }; |
143 | 111 | ||
144 | /* Structure implemented by CAIF HSI drivers. */ | 112 | /* Structure implemented by CAIF HSI drivers. */ |
@@ -146,56 +114,32 @@ struct cfhsi { | |||
146 | struct caif_dev_common cfdev; | 114 | struct caif_dev_common cfdev; |
147 | struct net_device *ndev; | 115 | struct net_device *ndev; |
148 | struct platform_device *pdev; | 116 | struct platform_device *pdev; |
149 | struct sk_buff_head qhead[CFHSI_PRIO_LAST]; | 117 | struct sk_buff_head qhead; |
150 | struct cfhsi_cb_ops cb_ops; | 118 | struct cfhsi_drv drv; |
151 | struct cfhsi_ops *ops; | 119 | struct cfhsi_dev *dev; |
152 | int tx_state; | 120 | int tx_state; |
153 | struct cfhsi_rx_state rx_state; | 121 | int rx_state; |
154 | struct cfhsi_config cfg; | ||
155 | int rx_len; | 122 | int rx_len; |
156 | u8 *rx_ptr; | 123 | u8 *rx_ptr; |
157 | u8 *tx_buf; | 124 | u8 *tx_buf; |
158 | u8 *rx_buf; | 125 | u8 *rx_buf; |
159 | u8 *rx_flip_buf; | ||
160 | spinlock_t lock; | 126 | spinlock_t lock; |
161 | int flow_off_sent; | 127 | int flow_off_sent; |
128 | u32 q_low_mark; | ||
129 | u32 q_high_mark; | ||
162 | struct list_head list; | 130 | struct list_head list; |
163 | struct work_struct wake_up_work; | 131 | struct work_struct wake_up_work; |
164 | struct work_struct wake_down_work; | 132 | struct work_struct wake_down_work; |
165 | struct work_struct out_of_sync_work; | 133 | struct work_struct rx_done_work; |
134 | struct work_struct tx_done_work; | ||
166 | struct workqueue_struct *wq; | 135 | struct workqueue_struct *wq; |
167 | wait_queue_head_t wake_up_wait; | 136 | wait_queue_head_t wake_up_wait; |
168 | wait_queue_head_t wake_down_wait; | 137 | wait_queue_head_t wake_down_wait; |
169 | wait_queue_head_t flush_fifo_wait; | 138 | wait_queue_head_t flush_fifo_wait; |
170 | struct timer_list inactivity_timer; | 139 | struct timer_list timer; |
171 | struct timer_list rx_slowpath_timer; | ||
172 | |||
173 | /* TX aggregation */ | ||
174 | int aggregation_len; | ||
175 | struct timer_list aggregation_timer; | ||
176 | |||
177 | unsigned long bits; | 140 | unsigned long bits; |
178 | }; | 141 | }; |
179 | extern struct platform_driver cfhsi_driver; | ||
180 | 142 | ||
181 | /** | 143 | extern struct platform_driver cfhsi_driver; |
182 | * enum ifla_caif_hsi - CAIF HSI NetlinkRT parameters. | ||
183 | * @IFLA_CAIF_HSI_INACTIVITY_TOUT: Inactivity timeout before | ||
184 | * taking the HSI wakeline down, in milliseconds. | ||
185 | * When using RT Netlink to create, destroy or configure a CAIF HSI interface, | ||
186 | * enum ifla_caif_hsi is used to specify the configuration attributes. | ||
187 | */ | ||
188 | enum ifla_caif_hsi { | ||
189 | __IFLA_CAIF_HSI_UNSPEC, | ||
190 | __IFLA_CAIF_HSI_INACTIVITY_TOUT, | ||
191 | __IFLA_CAIF_HSI_AGGREGATION_TOUT, | ||
192 | __IFLA_CAIF_HSI_HEAD_ALIGN, | ||
193 | __IFLA_CAIF_HSI_TAIL_ALIGN, | ||
194 | __IFLA_CAIF_HSI_QHIGH_WATERMARK, | ||
195 | __IFLA_CAIF_HSI_QLOW_WATERMARK, | ||
196 | __IFLA_CAIF_HSI_MAX | ||
197 | }; | ||
198 | |||
199 | extern struct cfhsi_ops *cfhsi_get_ops(void); | ||
200 | 144 | ||
201 | #endif /* CAIF_HSI_H_ */ | 145 | #endif /* CAIF_HSI_H_ */ |
diff --git a/include/net/caif/caif_layer.h b/include/net/caif/caif_layer.h index 0f3a39125f9..35bc7883cf9 100644 --- a/include/net/caif/caif_layer.h +++ b/include/net/caif/caif_layer.h | |||
@@ -121,7 +121,9 @@ enum caif_direction { | |||
121 | * @transmit: Packet transmit funciton. | 121 | * @transmit: Packet transmit funciton. |
122 | * @ctrlcmd: Used for control signalling upwards in the stack. | 122 | * @ctrlcmd: Used for control signalling upwards in the stack. |
123 | * @modemcmd: Used for control signaling downwards in the stack. | 123 | * @modemcmd: Used for control signaling downwards in the stack. |
124 | * @prio: Priority of this layer. | ||
124 | * @id: The identity of this layer | 125 | * @id: The identity of this layer |
126 | * @type: The type of this layer | ||
125 | * @name: Name of the layer. | 127 | * @name: Name of the layer. |
126 | * | 128 | * |
127 | * This structure defines the layered structure in CAIF. | 129 | * This structure defines the layered structure in CAIF. |
@@ -228,7 +230,9 @@ struct cflayer { | |||
228 | */ | 230 | */ |
229 | int (*modemcmd) (struct cflayer *layr, enum caif_modemcmd ctrl); | 231 | int (*modemcmd) (struct cflayer *layr, enum caif_modemcmd ctrl); |
230 | 232 | ||
233 | unsigned short prio; | ||
231 | unsigned int id; | 234 | unsigned int id; |
235 | unsigned int type; | ||
232 | char name[CAIF_LAYER_NAME_SZ]; | 236 | char name[CAIF_LAYER_NAME_SZ]; |
233 | }; | 237 | }; |
234 | 238 | ||
diff --git a/include/net/caif/caif_spi.h b/include/net/caif/caif_spi.h index aa6a485b054..87c3d11b8e5 100644 --- a/include/net/caif/caif_spi.h +++ b/include/net/caif/caif_spi.h | |||
@@ -55,8 +55,8 @@ | |||
55 | struct cfspi_xfer { | 55 | struct cfspi_xfer { |
56 | u16 tx_dma_len; | 56 | u16 tx_dma_len; |
57 | u16 rx_dma_len; | 57 | u16 rx_dma_len; |
58 | void *va_tx[2]; | 58 | void *va_tx; |
59 | dma_addr_t pa_tx[2]; | 59 | dma_addr_t pa_tx; |
60 | void *va_rx; | 60 | void *va_rx; |
61 | dma_addr_t pa_rx; | 61 | dma_addr_t pa_rx; |
62 | }; | 62 | }; |
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h index 90b4ff8bad8..3e93a4a4b67 100644 --- a/include/net/caif/cfcnfg.h +++ b/include/net/caif/cfcnfg.h | |||
@@ -14,6 +14,18 @@ | |||
14 | struct cfcnfg; | 14 | struct cfcnfg; |
15 | 15 | ||
16 | /** | 16 | /** |
17 | * enum cfcnfg_phy_type - Types of physical layers defined in CAIF Stack | ||
18 | * | ||
19 | * @CFPHYTYPE_FRAG: Fragmented frames physical interface. | ||
20 | * @CFPHYTYPE_CAIF: Generic CAIF physical interface | ||
21 | */ | ||
22 | enum cfcnfg_phy_type { | ||
23 | CFPHYTYPE_FRAG = 1, | ||
24 | CFPHYTYPE_CAIF, | ||
25 | CFPHYTYPE_MAX | ||
26 | }; | ||
27 | |||
28 | /** | ||
17 | * enum cfcnfg_phy_preference - Physical preference HW Abstraction | 29 | * enum cfcnfg_phy_preference - Physical preference HW Abstraction |
18 | * | 30 | * |
19 | * @CFPHYPREF_UNSPECIFIED: Default physical interface | 31 | * @CFPHYPREF_UNSPECIFIED: Default physical interface |
@@ -54,20 +66,21 @@ void cfcnfg_remove(struct cfcnfg *cfg); | |||
54 | * cfcnfg_add_phy_layer() - Adds a physical layer to the CAIF stack. | 66 | * cfcnfg_add_phy_layer() - Adds a physical layer to the CAIF stack. |
55 | * @cnfg: Pointer to a CAIF configuration object, created by | 67 | * @cnfg: Pointer to a CAIF configuration object, created by |
56 | * cfcnfg_create(). | 68 | * cfcnfg_create(). |
69 | * @phy_type: Specifies the type of physical interface, e.g. | ||
70 | * CFPHYTYPE_FRAG. | ||
57 | * @dev: Pointer to link layer device | 71 | * @dev: Pointer to link layer device |
58 | * @phy_layer: Specify the physical layer. The transmit function | 72 | * @phy_layer: Specify the physical layer. The transmit function |
59 | * MUST be set in the structure. | 73 | * MUST be set in the structure. |
60 | * @pref: The phy (link layer) preference. | 74 | * @pref: The phy (link layer) preference. |
61 | * @link_support: Protocol implementation for link layer specific protocol. | ||
62 | * @fcs: Specify if checksum is used in CAIF Framing Layer. | 75 | * @fcs: Specify if checksum is used in CAIF Framing Layer. |
63 | * @head_room: Head space needed by link specific protocol. | 76 | * @stx: Specify if Start Of Frame eXtention is used. |
64 | */ | 77 | */ |
78 | |||
65 | void | 79 | void |
66 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, | 80 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, |
67 | struct net_device *dev, struct cflayer *phy_layer, | 81 | struct net_device *dev, struct cflayer *phy_layer, |
68 | enum cfcnfg_phy_preference pref, | 82 | enum cfcnfg_phy_preference pref, |
69 | struct cflayer *link_support, | 83 | bool fcs, bool stx); |
70 | bool fcs, int head_room); | ||
71 | 84 | ||
72 | /** | 85 | /** |
73 | * cfcnfg_del_phy_layer - Deletes an phy layer from the CAIF stack. | 86 | * cfcnfg_del_phy_layer - Deletes an phy layer from the CAIF stack. |
diff --git a/include/net/caif/cfpkt.h b/include/net/caif/cfpkt.h index 83a89ba3005..6bd200a4754 100644 --- a/include/net/caif/cfpkt.h +++ b/include/net/caif/cfpkt.h | |||
@@ -188,18 +188,11 @@ struct cfpkt *cfpkt_fromnative(enum caif_direction dir, void *nativepkt); | |||
188 | */ | 188 | */ |
189 | void *cfpkt_tonative(struct cfpkt *pkt); | 189 | void *cfpkt_tonative(struct cfpkt *pkt); |
190 | 190 | ||
191 | |||
191 | /* | 192 | /* |
192 | * Returns packet information for a packet. | 193 | * Returns packet information for a packet. |
193 | * pkt Packet to get info from; | 194 | * pkt Packet to get info from; |
194 | * @return Packet information | 195 | * @return Packet information |
195 | */ | 196 | */ |
196 | struct caif_payload_info *cfpkt_info(struct cfpkt *pkt); | 197 | struct caif_payload_info *cfpkt_info(struct cfpkt *pkt); |
197 | |||
198 | /** cfpkt_set_prio - set priority for a CAIF packet. | ||
199 | * | ||
200 | * @pkt: The CAIF packet to be adjusted. | ||
201 | * @prio: one of TC_PRIO_ constants. | ||
202 | */ | ||
203 | void cfpkt_set_prio(struct cfpkt *pkt, int prio); | ||
204 | |||
205 | #endif /* CFPKT_H_ */ | 198 | #endif /* CFPKT_H_ */ |
diff --git a/include/net/caif/cfserl.h b/include/net/caif/cfserl.h index f121299a342..b8374321b36 100644 --- a/include/net/caif/cfserl.h +++ b/include/net/caif/cfserl.h | |||
@@ -8,5 +8,5 @@ | |||
8 | #define CFSERL_H_ | 8 | #define CFSERL_H_ |
9 | #include <net/caif/caif_layer.h> | 9 | #include <net/caif/caif_layer.h> |
10 | 10 | ||
11 | struct cflayer *cfserl_create(int instance, bool use_stx); | 11 | struct cflayer *cfserl_create(int type, int instance, bool use_stx); |
12 | #endif | 12 | #endif /* CFSERL_H_ */ |
diff --git a/include/net/cfg80211-wext.h b/include/net/cfg80211-wext.h deleted file mode 100644 index 25baddc4fbe..00000000000 --- a/include/net/cfg80211-wext.h +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | #ifndef __NET_CFG80211_WEXT_H | ||
2 | #define __NET_CFG80211_WEXT_H | ||
3 | /* | ||
4 | * 802.11 device and configuration interface -- wext handlers | ||
5 | * | ||
6 | * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License version 2 as | ||
10 | * published by the Free Software Foundation. | ||
11 | */ | ||
12 | |||
13 | #include <linux/netdevice.h> | ||
14 | #include <linux/wireless.h> | ||
15 | #include <net/iw_handler.h> | ||
16 | |||
17 | /* | ||
18 | * Temporary wext handlers & helper functions | ||
19 | * | ||
20 | * These are used only by drivers that aren't yet fully | ||
21 | * converted to cfg80211. | ||
22 | */ | ||
23 | int cfg80211_wext_giwname(struct net_device *dev, | ||
24 | struct iw_request_info *info, | ||
25 | char *name, char *extra); | ||
26 | int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info, | ||
27 | u32 *mode, char *extra); | ||
28 | int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info, | ||
29 | u32 *mode, char *extra); | ||
30 | int cfg80211_wext_siwscan(struct net_device *dev, | ||
31 | struct iw_request_info *info, | ||
32 | union iwreq_data *wrqu, char *extra); | ||
33 | int cfg80211_wext_giwscan(struct net_device *dev, | ||
34 | struct iw_request_info *info, | ||
35 | struct iw_point *data, char *extra); | ||
36 | int cfg80211_wext_giwrange(struct net_device *dev, | ||
37 | struct iw_request_info *info, | ||
38 | struct iw_point *data, char *extra); | ||
39 | int cfg80211_wext_siwrts(struct net_device *dev, | ||
40 | struct iw_request_info *info, | ||
41 | struct iw_param *rts, char *extra); | ||
42 | int cfg80211_wext_giwrts(struct net_device *dev, | ||
43 | struct iw_request_info *info, | ||
44 | struct iw_param *rts, char *extra); | ||
45 | int cfg80211_wext_siwfrag(struct net_device *dev, | ||
46 | struct iw_request_info *info, | ||
47 | struct iw_param *frag, char *extra); | ||
48 | int cfg80211_wext_giwfrag(struct net_device *dev, | ||
49 | struct iw_request_info *info, | ||
50 | struct iw_param *frag, char *extra); | ||
51 | int cfg80211_wext_giwretry(struct net_device *dev, | ||
52 | struct iw_request_info *info, | ||
53 | struct iw_param *retry, char *extra); | ||
54 | |||
55 | #endif /* __NET_CFG80211_WEXT_H */ | ||
diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h index 8e6a6b73b9c..ffa8aedd70f 100644 --- a/include/net/cfg80211.h +++ b/include/net/cfg80211.h | |||
@@ -13,7 +13,6 @@ | |||
13 | #include <linux/netdevice.h> | 13 | #include <linux/netdevice.h> |
14 | #include <linux/debugfs.h> | 14 | #include <linux/debugfs.h> |
15 | #include <linux/list.h> | 15 | #include <linux/list.h> |
16 | #include <linux/bug.h> | ||
17 | #include <linux/netlink.h> | 16 | #include <linux/netlink.h> |
18 | #include <linux/skbuff.h> | 17 | #include <linux/skbuff.h> |
19 | #include <linux/nl80211.h> | 18 | #include <linux/nl80211.h> |
@@ -21,6 +20,11 @@ | |||
21 | #include <linux/ieee80211.h> | 20 | #include <linux/ieee80211.h> |
22 | #include <net/regulatory.h> | 21 | #include <net/regulatory.h> |
23 | 22 | ||
23 | /* remove once we remove the wext stuff */ | ||
24 | #include <net/iw_handler.h> | ||
25 | #include <linux/wireless.h> | ||
26 | |||
27 | |||
24 | /** | 28 | /** |
25 | * DOC: Introduction | 29 | * DOC: Introduction |
26 | * | 30 | * |
@@ -58,8 +62,6 @@ | |||
58 | * structures here describe these capabilities in detail. | 62 | * structures here describe these capabilities in detail. |
59 | */ | 63 | */ |
60 | 64 | ||
61 | struct wiphy; | ||
62 | |||
63 | /* | 65 | /* |
64 | * wireless hardware capability structures | 66 | * wireless hardware capability structures |
65 | */ | 67 | */ |
@@ -72,13 +74,11 @@ struct wiphy; | |||
72 | * | 74 | * |
73 | * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band | 75 | * @IEEE80211_BAND_2GHZ: 2.4GHz ISM band |
74 | * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7) | 76 | * @IEEE80211_BAND_5GHZ: around 5GHz band (4.9-5.7) |
75 | * @IEEE80211_BAND_60GHZ: around 60 GHz band (58.32 - 64.80 GHz) | ||
76 | * @IEEE80211_NUM_BANDS: number of defined bands | 77 | * @IEEE80211_NUM_BANDS: number of defined bands |
77 | */ | 78 | */ |
78 | enum ieee80211_band { | 79 | enum ieee80211_band { |
79 | IEEE80211_BAND_2GHZ = NL80211_BAND_2GHZ, | 80 | IEEE80211_BAND_2GHZ = NL80211_BAND_2GHZ, |
80 | IEEE80211_BAND_5GHZ = NL80211_BAND_5GHZ, | 81 | IEEE80211_BAND_5GHZ = NL80211_BAND_5GHZ, |
81 | IEEE80211_BAND_60GHZ = NL80211_BAND_60GHZ, | ||
82 | 82 | ||
83 | /* keep last */ | 83 | /* keep last */ |
84 | IEEE80211_NUM_BANDS | 84 | IEEE80211_NUM_BANDS |
@@ -98,7 +98,6 @@ enum ieee80211_band { | |||
98 | * is not permitted. | 98 | * is not permitted. |
99 | * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel | 99 | * @IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel |
100 | * is not permitted. | 100 | * is not permitted. |
101 | * @IEEE80211_CHAN_NO_OFDM: OFDM is not allowed on this channel. | ||
102 | */ | 101 | */ |
103 | enum ieee80211_channel_flags { | 102 | enum ieee80211_channel_flags { |
104 | IEEE80211_CHAN_DISABLED = 1<<0, | 103 | IEEE80211_CHAN_DISABLED = 1<<0, |
@@ -107,7 +106,6 @@ enum ieee80211_channel_flags { | |||
107 | IEEE80211_CHAN_RADAR = 1<<3, | 106 | IEEE80211_CHAN_RADAR = 1<<3, |
108 | IEEE80211_CHAN_NO_HT40PLUS = 1<<4, | 107 | IEEE80211_CHAN_NO_HT40PLUS = 1<<4, |
109 | IEEE80211_CHAN_NO_HT40MINUS = 1<<5, | 108 | IEEE80211_CHAN_NO_HT40MINUS = 1<<5, |
110 | IEEE80211_CHAN_NO_OFDM = 1<<6, | ||
111 | }; | 109 | }; |
112 | 110 | ||
113 | #define IEEE80211_CHAN_NO_HT40 \ | 111 | #define IEEE80211_CHAN_NO_HT40 \ |
@@ -127,7 +125,6 @@ enum ieee80211_channel_flags { | |||
127 | * @band: band this channel belongs to. | 125 | * @band: band this channel belongs to. |
128 | * @max_antenna_gain: maximum antenna gain in dBi | 126 | * @max_antenna_gain: maximum antenna gain in dBi |
129 | * @max_power: maximum transmission power (in dBm) | 127 | * @max_power: maximum transmission power (in dBm) |
130 | * @max_reg_power: maximum regulatory transmission power (in dBm) | ||
131 | * @beacon_found: helper to regulatory code to indicate when a beacon | 128 | * @beacon_found: helper to regulatory code to indicate when a beacon |
132 | * has been found on this channel. Use regulatory_hint_found_beacon() | 129 | * has been found on this channel. Use regulatory_hint_found_beacon() |
133 | * to enable this, this is useful only on 5 GHz band. | 130 | * to enable this, this is useful only on 5 GHz band. |
@@ -141,7 +138,6 @@ struct ieee80211_channel { | |||
141 | u32 flags; | 138 | u32 flags; |
142 | int max_antenna_gain; | 139 | int max_antenna_gain; |
143 | int max_power; | 140 | int max_power; |
144 | int max_reg_power; | ||
145 | bool beacon_found; | 141 | bool beacon_found; |
146 | u32 orig_flags; | 142 | u32 orig_flags; |
147 | int orig_mag, orig_mpwr; | 143 | int orig_mag, orig_mpwr; |
@@ -217,22 +213,6 @@ struct ieee80211_sta_ht_cap { | |||
217 | }; | 213 | }; |
218 | 214 | ||
219 | /** | 215 | /** |
220 | * struct ieee80211_sta_vht_cap - STA's VHT capabilities | ||
221 | * | ||
222 | * This structure describes most essential parameters needed | ||
223 | * to describe 802.11ac VHT capabilities for an STA. | ||
224 | * | ||
225 | * @vht_supported: is VHT supported by the STA | ||
226 | * @cap: VHT capabilities map as described in 802.11ac spec | ||
227 | * @vht_mcs: Supported VHT MCS rates | ||
228 | */ | ||
229 | struct ieee80211_sta_vht_cap { | ||
230 | bool vht_supported; | ||
231 | u32 cap; /* use IEEE80211_VHT_CAP_ */ | ||
232 | struct ieee80211_vht_mcs_info vht_mcs; | ||
233 | }; | ||
234 | |||
235 | /** | ||
236 | * struct ieee80211_supported_band - frequency band definition | 216 | * struct ieee80211_supported_band - frequency band definition |
237 | * | 217 | * |
238 | * This structure describes a frequency band a wiphy | 218 | * This structure describes a frequency band a wiphy |
@@ -247,7 +227,6 @@ struct ieee80211_sta_vht_cap { | |||
247 | * rates" IE, i.e. CCK rates first, then OFDM. | 227 | * rates" IE, i.e. CCK rates first, then OFDM. |
248 | * @n_bitrates: Number of bitrates in @bitrates | 228 | * @n_bitrates: Number of bitrates in @bitrates |
249 | * @ht_cap: HT capabilities in this band | 229 | * @ht_cap: HT capabilities in this band |
250 | * @vht_cap: VHT capabilities in this band | ||
251 | */ | 230 | */ |
252 | struct ieee80211_supported_band { | 231 | struct ieee80211_supported_band { |
253 | struct ieee80211_channel *channels; | 232 | struct ieee80211_channel *channels; |
@@ -256,7 +235,6 @@ struct ieee80211_supported_band { | |||
256 | int n_channels; | 235 | int n_channels; |
257 | int n_bitrates; | 236 | int n_bitrates; |
258 | struct ieee80211_sta_ht_cap ht_cap; | 237 | struct ieee80211_sta_ht_cap ht_cap; |
259 | struct ieee80211_sta_vht_cap vht_cap; | ||
260 | }; | 238 | }; |
261 | 239 | ||
262 | /* | 240 | /* |
@@ -308,104 +286,6 @@ struct key_params { | |||
308 | }; | 286 | }; |
309 | 287 | ||
310 | /** | 288 | /** |
311 | * struct cfg80211_chan_def - channel definition | ||
312 | * @chan: the (control) channel | ||
313 | * @width: channel width | ||
314 | * @center_freq1: center frequency of first segment | ||
315 | * @center_freq2: center frequency of second segment | ||
316 | * (only with 80+80 MHz) | ||
317 | */ | ||
318 | struct cfg80211_chan_def { | ||
319 | struct ieee80211_channel *chan; | ||
320 | enum nl80211_chan_width width; | ||
321 | u32 center_freq1; | ||
322 | u32 center_freq2; | ||
323 | }; | ||
324 | |||
325 | /** | ||
326 | * cfg80211_get_chandef_type - return old channel type from chandef | ||
327 | * @chandef: the channel definition | ||
328 | * | ||
329 | * Returns the old channel type (NOHT, HT20, HT40+/-) from a given | ||
330 | * chandef, which must have a bandwidth allowing this conversion. | ||
331 | */ | ||
332 | static inline enum nl80211_channel_type | ||
333 | cfg80211_get_chandef_type(const struct cfg80211_chan_def *chandef) | ||
334 | { | ||
335 | switch (chandef->width) { | ||
336 | case NL80211_CHAN_WIDTH_20_NOHT: | ||
337 | return NL80211_CHAN_NO_HT; | ||
338 | case NL80211_CHAN_WIDTH_20: | ||
339 | return NL80211_CHAN_HT20; | ||
340 | case NL80211_CHAN_WIDTH_40: | ||
341 | if (chandef->center_freq1 > chandef->chan->center_freq) | ||
342 | return NL80211_CHAN_HT40PLUS; | ||
343 | return NL80211_CHAN_HT40MINUS; | ||
344 | default: | ||
345 | WARN_ON(1); | ||
346 | return NL80211_CHAN_NO_HT; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | /** | ||
351 | * cfg80211_chandef_create - create channel definition using channel type | ||
352 | * @chandef: the channel definition struct to fill | ||
353 | * @channel: the control channel | ||
354 | * @chantype: the channel type | ||
355 | * | ||
356 | * Given a channel type, create a channel definition. | ||
357 | */ | ||
358 | void cfg80211_chandef_create(struct cfg80211_chan_def *chandef, | ||
359 | struct ieee80211_channel *channel, | ||
360 | enum nl80211_channel_type chantype); | ||
361 | |||
362 | /** | ||
363 | * cfg80211_chandef_identical - check if two channel definitions are identical | ||
364 | * @chandef1: first channel definition | ||
365 | * @chandef2: second channel definition | ||
366 | * | ||
367 | * Returns %true if the channels defined by the channel definitions are | ||
368 | * identical, %false otherwise. | ||
369 | */ | ||
370 | static inline bool | ||
371 | cfg80211_chandef_identical(const struct cfg80211_chan_def *chandef1, | ||
372 | const struct cfg80211_chan_def *chandef2) | ||
373 | { | ||
374 | return (chandef1->chan == chandef2->chan && | ||
375 | chandef1->width == chandef2->width && | ||
376 | chandef1->center_freq1 == chandef2->center_freq1 && | ||
377 | chandef1->center_freq2 == chandef2->center_freq2); | ||
378 | } | ||
379 | |||
380 | /** | ||
381 | * cfg80211_chandef_compatible - check if two channel definitions are compatible | ||
382 | * @chandef1: first channel definition | ||
383 | * @chandef2: second channel definition | ||
384 | * | ||
385 | * Returns %NULL if the given channel definitions are incompatible, | ||
386 | * chandef1 or chandef2 otherwise. | ||
387 | */ | ||
388 | const struct cfg80211_chan_def * | ||
389 | cfg80211_chandef_compatible(const struct cfg80211_chan_def *chandef1, | ||
390 | const struct cfg80211_chan_def *chandef2); | ||
391 | |||
392 | /** | ||
393 | * cfg80211_chandef_valid - check if a channel definition is valid | ||
394 | * @chandef: the channel definition to check | ||
395 | */ | ||
396 | bool cfg80211_chandef_valid(const struct cfg80211_chan_def *chandef); | ||
397 | |||
398 | /** | ||
399 | * cfg80211_chandef_usable - check if secondary channels can be used | ||
400 | * @wiphy: the wiphy to validate against | ||
401 | * @chandef: the channel definition to check | ||
402 | * @prohibited_flags: the regulatory chanenl flags that must not be set | ||
403 | */ | ||
404 | bool cfg80211_chandef_usable(struct wiphy *wiphy, | ||
405 | const struct cfg80211_chan_def *chandef, | ||
406 | u32 prohibited_flags); | ||
407 | |||
408 | /** | ||
409 | * enum survey_info_flags - survey information flags | 289 | * enum survey_info_flags - survey information flags |
410 | * | 290 | * |
411 | * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in | 291 | * @SURVEY_INFO_NOISE_DBM: noise (in dBm) was filled in |
@@ -459,103 +339,23 @@ struct survey_info { | |||
459 | }; | 339 | }; |
460 | 340 | ||
461 | /** | 341 | /** |
462 | * struct cfg80211_crypto_settings - Crypto settings | 342 | * struct beacon_parameters - beacon parameters |
463 | * @wpa_versions: indicates which, if any, WPA versions are enabled | 343 | * |
464 | * (from enum nl80211_wpa_versions) | 344 | * Used to configure the beacon for an interface. |
465 | * @cipher_group: group key cipher suite (or 0 if unset) | 345 | * |
466 | * @n_ciphers_pairwise: number of AP supported unicast ciphers | ||
467 | * @ciphers_pairwise: unicast key cipher suites | ||
468 | * @n_akm_suites: number of AKM suites | ||
469 | * @akm_suites: AKM suites | ||
470 | * @control_port: Whether user space controls IEEE 802.1X port, i.e., | ||
471 | * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is | ||
472 | * required to assume that the port is unauthorized until authorized by | ||
473 | * user space. Otherwise, port is marked authorized by default. | ||
474 | * @control_port_ethertype: the control port protocol that should be | ||
475 | * allowed through even on unauthorized ports | ||
476 | * @control_port_no_encrypt: TRUE to prevent encryption of control port | ||
477 | * protocol frames. | ||
478 | */ | ||
479 | struct cfg80211_crypto_settings { | ||
480 | u32 wpa_versions; | ||
481 | u32 cipher_group; | ||
482 | int n_ciphers_pairwise; | ||
483 | u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES]; | ||
484 | int n_akm_suites; | ||
485 | u32 akm_suites[NL80211_MAX_NR_AKM_SUITES]; | ||
486 | bool control_port; | ||
487 | __be16 control_port_ethertype; | ||
488 | bool control_port_no_encrypt; | ||
489 | }; | ||
490 | |||
491 | /** | ||
492 | * struct cfg80211_beacon_data - beacon data | ||
493 | * @head: head portion of beacon (before TIM IE) | 346 | * @head: head portion of beacon (before TIM IE) |
494 | * or %NULL if not changed | 347 | * or %NULL if not changed |
495 | * @tail: tail portion of beacon (after TIM IE) | 348 | * @tail: tail portion of beacon (after TIM IE) |
496 | * or %NULL if not changed | 349 | * or %NULL if not changed |
350 | * @interval: beacon interval or zero if not changed | ||
351 | * @dtim_period: DTIM period or zero if not changed | ||
497 | * @head_len: length of @head | 352 | * @head_len: length of @head |
498 | * @tail_len: length of @tail | 353 | * @tail_len: length of @tail |
499 | * @beacon_ies: extra information element(s) to add into Beacon frames or %NULL | ||
500 | * @beacon_ies_len: length of beacon_ies in octets | ||
501 | * @proberesp_ies: extra information element(s) to add into Probe Response | ||
502 | * frames or %NULL | ||
503 | * @proberesp_ies_len: length of proberesp_ies in octets | ||
504 | * @assocresp_ies: extra information element(s) to add into (Re)Association | ||
505 | * Response frames or %NULL | ||
506 | * @assocresp_ies_len: length of assocresp_ies in octets | ||
507 | * @probe_resp_len: length of probe response template (@probe_resp) | ||
508 | * @probe_resp: probe response template (AP mode only) | ||
509 | */ | ||
510 | struct cfg80211_beacon_data { | ||
511 | const u8 *head, *tail; | ||
512 | const u8 *beacon_ies; | ||
513 | const u8 *proberesp_ies; | ||
514 | const u8 *assocresp_ies; | ||
515 | const u8 *probe_resp; | ||
516 | |||
517 | size_t head_len, tail_len; | ||
518 | size_t beacon_ies_len; | ||
519 | size_t proberesp_ies_len; | ||
520 | size_t assocresp_ies_len; | ||
521 | size_t probe_resp_len; | ||
522 | }; | ||
523 | |||
524 | /** | ||
525 | * struct cfg80211_ap_settings - AP configuration | ||
526 | * | ||
527 | * Used to configure an AP interface. | ||
528 | * | ||
529 | * @chandef: defines the channel to use | ||
530 | * @beacon: beacon data | ||
531 | * @beacon_interval: beacon interval | ||
532 | * @dtim_period: DTIM period | ||
533 | * @ssid: SSID to be used in the BSS (note: may be %NULL if not provided from | ||
534 | * user space) | ||
535 | * @ssid_len: length of @ssid | ||
536 | * @hidden_ssid: whether to hide the SSID in Beacon/Probe Response frames | ||
537 | * @crypto: crypto settings | ||
538 | * @privacy: the BSS uses privacy | ||
539 | * @auth_type: Authentication type (algorithm) | ||
540 | * @inactivity_timeout: time in seconds to determine station's inactivity. | ||
541 | * @p2p_ctwindow: P2P CT Window | ||
542 | * @p2p_opp_ps: P2P opportunistic PS | ||
543 | */ | 354 | */ |
544 | struct cfg80211_ap_settings { | 355 | struct beacon_parameters { |
545 | struct cfg80211_chan_def chandef; | 356 | u8 *head, *tail; |
546 | 357 | int interval, dtim_period; | |
547 | struct cfg80211_beacon_data beacon; | 358 | int head_len, tail_len; |
548 | |||
549 | int beacon_interval, dtim_period; | ||
550 | const u8 *ssid; | ||
551 | size_t ssid_len; | ||
552 | enum nl80211_hidden_ssid hidden_ssid; | ||
553 | struct cfg80211_crypto_settings crypto; | ||
554 | bool privacy; | ||
555 | enum nl80211_auth_type auth_type; | ||
556 | int inactivity_timeout; | ||
557 | u8 p2p_ctwindow; | ||
558 | bool p2p_opp_ps; | ||
559 | }; | 359 | }; |
560 | 360 | ||
561 | /** | 361 | /** |
@@ -572,17 +372,6 @@ enum plink_actions { | |||
572 | }; | 372 | }; |
573 | 373 | ||
574 | /** | 374 | /** |
575 | * enum station_parameters_apply_mask - station parameter values to apply | ||
576 | * @STATION_PARAM_APPLY_UAPSD: apply new uAPSD parameters (uapsd_queues, max_sp) | ||
577 | * | ||
578 | * Not all station parameters have in-band "no change" signalling, | ||
579 | * for those that don't these flags will are used. | ||
580 | */ | ||
581 | enum station_parameters_apply_mask { | ||
582 | STATION_PARAM_APPLY_UAPSD = BIT(0), | ||
583 | }; | ||
584 | |||
585 | /** | ||
586 | * struct station_parameters - station parameters | 375 | * struct station_parameters - station parameters |
587 | * | 376 | * |
588 | * Used to change and create a new station. | 377 | * Used to change and create a new station. |
@@ -600,29 +389,17 @@ enum station_parameters_apply_mask { | |||
600 | * @plink_action: plink action to take | 389 | * @plink_action: plink action to take |
601 | * @plink_state: set the peer link state for a station | 390 | * @plink_state: set the peer link state for a station |
602 | * @ht_capa: HT capabilities of station | 391 | * @ht_capa: HT capabilities of station |
603 | * @vht_capa: VHT capabilities of station | ||
604 | * @uapsd_queues: bitmap of queues configured for uapsd. same format | ||
605 | * as the AC bitmap in the QoS info field | ||
606 | * @max_sp: max Service Period. same format as the MAX_SP in the | ||
607 | * QoS info field (but already shifted down) | ||
608 | * @sta_modify_mask: bitmap indicating which parameters changed | ||
609 | * (for those that don't have a natural "no change" value), | ||
610 | * see &enum station_parameters_apply_mask | ||
611 | */ | 392 | */ |
612 | struct station_parameters { | 393 | struct station_parameters { |
613 | u8 *supported_rates; | 394 | u8 *supported_rates; |
614 | struct net_device *vlan; | 395 | struct net_device *vlan; |
615 | u32 sta_flags_mask, sta_flags_set; | 396 | u32 sta_flags_mask, sta_flags_set; |
616 | u32 sta_modify_mask; | ||
617 | int listen_interval; | 397 | int listen_interval; |
618 | u16 aid; | 398 | u16 aid; |
619 | u8 supported_rates_len; | 399 | u8 supported_rates_len; |
620 | u8 plink_action; | 400 | u8 plink_action; |
621 | u8 plink_state; | 401 | u8 plink_state; |
622 | struct ieee80211_ht_cap *ht_capa; | 402 | struct ieee80211_ht_cap *ht_capa; |
623 | struct ieee80211_vht_cap *vht_capa; | ||
624 | u8 uapsd_queues; | ||
625 | u8 max_sp; | ||
626 | }; | 403 | }; |
627 | 404 | ||
628 | /** | 405 | /** |
@@ -649,10 +426,6 @@ struct station_parameters { | |||
649 | * @STATION_INFO_RX_BITRATE: @rxrate fields are filled | 426 | * @STATION_INFO_RX_BITRATE: @rxrate fields are filled |
650 | * @STATION_INFO_BSS_PARAM: @bss_param filled | 427 | * @STATION_INFO_BSS_PARAM: @bss_param filled |
651 | * @STATION_INFO_CONNECTED_TIME: @connected_time filled | 428 | * @STATION_INFO_CONNECTED_TIME: @connected_time filled |
652 | * @STATION_INFO_ASSOC_REQ_IES: @assoc_req_ies filled | ||
653 | * @STATION_INFO_STA_FLAGS: @sta_flags filled | ||
654 | * @STATION_INFO_BEACON_LOSS_COUNT: @beacon_loss_count filled | ||
655 | * @STATION_INFO_T_OFFSET: @t_offset filled | ||
656 | */ | 429 | */ |
657 | enum station_info_flags { | 430 | enum station_info_flags { |
658 | STATION_INFO_INACTIVE_TIME = 1<<0, | 431 | STATION_INFO_INACTIVE_TIME = 1<<0, |
@@ -671,11 +444,7 @@ enum station_info_flags { | |||
671 | STATION_INFO_SIGNAL_AVG = 1<<13, | 444 | STATION_INFO_SIGNAL_AVG = 1<<13, |
672 | STATION_INFO_RX_BITRATE = 1<<14, | 445 | STATION_INFO_RX_BITRATE = 1<<14, |
673 | STATION_INFO_BSS_PARAM = 1<<15, | 446 | STATION_INFO_BSS_PARAM = 1<<15, |
674 | STATION_INFO_CONNECTED_TIME = 1<<16, | 447 | STATION_INFO_CONNECTED_TIME = 1<<16 |
675 | STATION_INFO_ASSOC_REQ_IES = 1<<17, | ||
676 | STATION_INFO_STA_FLAGS = 1<<18, | ||
677 | STATION_INFO_BEACON_LOSS_COUNT = 1<<19, | ||
678 | STATION_INFO_T_OFFSET = 1<<20, | ||
679 | }; | 448 | }; |
680 | 449 | ||
681 | /** | 450 | /** |
@@ -684,24 +453,14 @@ enum station_info_flags { | |||
684 | * Used by the driver to indicate the specific rate transmission | 453 | * Used by the driver to indicate the specific rate transmission |
685 | * type for 802.11n transmissions. | 454 | * type for 802.11n transmissions. |
686 | * | 455 | * |
687 | * @RATE_INFO_FLAGS_MCS: mcs field filled with HT MCS | 456 | * @RATE_INFO_FLAGS_MCS: @tx_bitrate_mcs filled |
688 | * @RATE_INFO_FLAGS_VHT_MCS: mcs field filled with VHT MCS | 457 | * @RATE_INFO_FLAGS_40_MHZ_WIDTH: 40 Mhz width transmission |
689 | * @RATE_INFO_FLAGS_40_MHZ_WIDTH: 40 MHz width transmission | ||
690 | * @RATE_INFO_FLAGS_80_MHZ_WIDTH: 80 MHz width transmission | ||
691 | * @RATE_INFO_FLAGS_80P80_MHZ_WIDTH: 80+80 MHz width transmission | ||
692 | * @RATE_INFO_FLAGS_160_MHZ_WIDTH: 160 MHz width transmission | ||
693 | * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval | 458 | * @RATE_INFO_FLAGS_SHORT_GI: 400ns guard interval |
694 | * @RATE_INFO_FLAGS_60G: 60GHz MCS | ||
695 | */ | 459 | */ |
696 | enum rate_info_flags { | 460 | enum rate_info_flags { |
697 | RATE_INFO_FLAGS_MCS = BIT(0), | 461 | RATE_INFO_FLAGS_MCS = 1<<0, |
698 | RATE_INFO_FLAGS_VHT_MCS = BIT(1), | 462 | RATE_INFO_FLAGS_40_MHZ_WIDTH = 1<<1, |
699 | RATE_INFO_FLAGS_40_MHZ_WIDTH = BIT(2), | 463 | RATE_INFO_FLAGS_SHORT_GI = 1<<2, |
700 | RATE_INFO_FLAGS_80_MHZ_WIDTH = BIT(3), | ||
701 | RATE_INFO_FLAGS_80P80_MHZ_WIDTH = BIT(4), | ||
702 | RATE_INFO_FLAGS_160_MHZ_WIDTH = BIT(5), | ||
703 | RATE_INFO_FLAGS_SHORT_GI = BIT(6), | ||
704 | RATE_INFO_FLAGS_60G = BIT(7), | ||
705 | }; | 464 | }; |
706 | 465 | ||
707 | /** | 466 | /** |
@@ -712,13 +471,11 @@ enum rate_info_flags { | |||
712 | * @flags: bitflag of flags from &enum rate_info_flags | 471 | * @flags: bitflag of flags from &enum rate_info_flags |
713 | * @mcs: mcs index if struct describes a 802.11n bitrate | 472 | * @mcs: mcs index if struct describes a 802.11n bitrate |
714 | * @legacy: bitrate in 100kbit/s for 802.11abg | 473 | * @legacy: bitrate in 100kbit/s for 802.11abg |
715 | * @nss: number of streams (VHT only) | ||
716 | */ | 474 | */ |
717 | struct rate_info { | 475 | struct rate_info { |
718 | u8 flags; | 476 | u8 flags; |
719 | u8 mcs; | 477 | u8 mcs; |
720 | u16 legacy; | 478 | u16 legacy; |
721 | u8 nss; | ||
722 | }; | 479 | }; |
723 | 480 | ||
724 | /** | 481 | /** |
@@ -765,10 +522,8 @@ struct sta_bss_parameters { | |||
765 | * @llid: mesh local link id | 522 | * @llid: mesh local link id |
766 | * @plid: mesh peer link id | 523 | * @plid: mesh peer link id |
767 | * @plink_state: mesh peer link state | 524 | * @plink_state: mesh peer link state |
768 | * @signal: The signal strength, type depends on the wiphy's signal_type. | 525 | * @signal: signal strength of last received packet in dBm |
769 | * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_. | 526 | * @signal_avg: signal strength average in dBm |
770 | * @signal_avg: Average signal strength, type depends on the wiphy's signal_type. | ||
771 | * For CFG80211_SIGNAL_TYPE_MBM, value is expressed in _dBm_. | ||
772 | * @txrate: current unicast bitrate from this station | 527 | * @txrate: current unicast bitrate from this station |
773 | * @rxrate: current unicast bitrate to this station | 528 | * @rxrate: current unicast bitrate to this station |
774 | * @rx_packets: packets received from this station | 529 | * @rx_packets: packets received from this station |
@@ -786,9 +541,6 @@ struct sta_bss_parameters { | |||
786 | * user space MLME/SME implementation. The information is provided for | 541 | * user space MLME/SME implementation. The information is provided for |
787 | * the cfg80211_new_sta() calls to notify user space of the IEs. | 542 | * the cfg80211_new_sta() calls to notify user space of the IEs. |
788 | * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets. | 543 | * @assoc_req_ies_len: Length of assoc_req_ies buffer in octets. |
789 | * @sta_flags: station flags mask & values | ||
790 | * @beacon_loss_count: Number of times beacon loss event has triggered. | ||
791 | * @t_offset: Time offset of the station relative to this host. | ||
792 | */ | 544 | */ |
793 | struct station_info { | 545 | struct station_info { |
794 | u32 filled; | 546 | u32 filled; |
@@ -809,16 +561,12 @@ struct station_info { | |||
809 | u32 tx_failed; | 561 | u32 tx_failed; |
810 | u32 rx_dropped_misc; | 562 | u32 rx_dropped_misc; |
811 | struct sta_bss_parameters bss_param; | 563 | struct sta_bss_parameters bss_param; |
812 | struct nl80211_sta_flag_update sta_flags; | ||
813 | 564 | ||
814 | int generation; | 565 | int generation; |
815 | 566 | ||
816 | const u8 *assoc_req_ies; | 567 | const u8 *assoc_req_ies; |
817 | size_t assoc_req_ies_len; | 568 | size_t assoc_req_ies_len; |
818 | 569 | ||
819 | u32 beacon_loss_count; | ||
820 | s64 t_offset; | ||
821 | |||
822 | /* | 570 | /* |
823 | * Note: Add a new enum station_info_flags value for each new field and | 571 | * Note: Add a new enum station_info_flags value for each new field and |
824 | * use it to check which fields are initialized. | 572 | * use it to check which fields are initialized. |
@@ -917,8 +665,6 @@ struct mpath_info { | |||
917 | * @ap_isolate: do not forward packets between connected stations | 665 | * @ap_isolate: do not forward packets between connected stations |
918 | * @ht_opmode: HT Operation mode | 666 | * @ht_opmode: HT Operation mode |
919 | * (u16 = opmode, -1 = do not change) | 667 | * (u16 = opmode, -1 = do not change) |
920 | * @p2p_ctwindow: P2P CT Window (-1 = no change) | ||
921 | * @p2p_opp_ps: P2P opportunistic PS (-1 = no change) | ||
922 | */ | 668 | */ |
923 | struct bss_parameters { | 669 | struct bss_parameters { |
924 | int use_cts_prot; | 670 | int use_cts_prot; |
@@ -928,133 +674,62 @@ struct bss_parameters { | |||
928 | u8 basic_rates_len; | 674 | u8 basic_rates_len; |
929 | int ap_isolate; | 675 | int ap_isolate; |
930 | int ht_opmode; | 676 | int ht_opmode; |
931 | s8 p2p_ctwindow, p2p_opp_ps; | ||
932 | }; | 677 | }; |
933 | 678 | ||
934 | /** | 679 | /* |
935 | * struct mesh_config - 802.11s mesh configuration | 680 | * struct mesh_config - 802.11s mesh configuration |
936 | * | 681 | * |
937 | * These parameters can be changed while the mesh is active. | 682 | * These parameters can be changed while the mesh is active. |
938 | * | ||
939 | * @dot11MeshRetryTimeout: the initial retry timeout in millisecond units used | ||
940 | * by the Mesh Peering Open message | ||
941 | * @dot11MeshConfirmTimeout: the initial retry timeout in millisecond units | ||
942 | * used by the Mesh Peering Open message | ||
943 | * @dot11MeshHoldingTimeout: the confirm timeout in millisecond units used by | ||
944 | * the mesh peering management to close a mesh peering | ||
945 | * @dot11MeshMaxPeerLinks: the maximum number of peer links allowed on this | ||
946 | * mesh interface | ||
947 | * @dot11MeshMaxRetries: the maximum number of peer link open retries that can | ||
948 | * be sent to establish a new peer link instance in a mesh | ||
949 | * @dot11MeshTTL: the value of TTL field set at a source mesh STA | ||
950 | * @element_ttl: the value of TTL field set at a mesh STA for path selection | ||
951 | * elements | ||
952 | * @auto_open_plinks: whether we should automatically open peer links when we | ||
953 | * detect compatible mesh peers | ||
954 | * @dot11MeshNbrOffsetMaxNeighbor: the maximum number of neighbors to | ||
955 | * synchronize to for 11s default synchronization method | ||
956 | * @dot11MeshHWMPmaxPREQretries: the number of action frames containing a PREQ | ||
957 | * that an originator mesh STA can send to a particular path target | ||
958 | * @path_refresh_time: how frequently to refresh mesh paths in milliseconds | ||
959 | * @min_discovery_timeout: the minimum length of time to wait until giving up on | ||
960 | * a path discovery in milliseconds | ||
961 | * @dot11MeshHWMPactivePathTimeout: the time (in TUs) for which mesh STAs | ||
962 | * receiving a PREQ shall consider the forwarding information from the | ||
963 | * root to be valid. (TU = time unit) | ||
964 | * @dot11MeshHWMPpreqMinInterval: the minimum interval of time (in TUs) during | ||
965 | * which a mesh STA can send only one action frame containing a PREQ | ||
966 | * element | ||
967 | * @dot11MeshHWMPperrMinInterval: the minimum interval of time (in TUs) during | ||
968 | * which a mesh STA can send only one Action frame containing a PERR | ||
969 | * element | ||
970 | * @dot11MeshHWMPnetDiameterTraversalTime: the interval of time (in TUs) that | ||
971 | * it takes for an HWMP information element to propagate across the mesh | ||
972 | * @dot11MeshHWMPRootMode: the configuration of a mesh STA as root mesh STA | ||
973 | * @dot11MeshHWMPRannInterval: the interval of time (in TUs) between root | ||
974 | * announcements are transmitted | ||
975 | * @dot11MeshGateAnnouncementProtocol: whether to advertise that this mesh | ||
976 | * station has access to a broader network beyond the MBSS. (This is | ||
977 | * missnamed in draft 12.0: dot11MeshGateAnnouncementProtocol set to true | ||
978 | * only means that the station will announce others it's a mesh gate, but | ||
979 | * not necessarily using the gate announcement protocol. Still keeping the | ||
980 | * same nomenclature to be in sync with the spec) | ||
981 | * @dot11MeshForwarding: whether the Mesh STA is forwarding or non-forwarding | ||
982 | * entity (default is TRUE - forwarding entity) | ||
983 | * @rssi_threshold: the threshold for average signal strength of candidate | ||
984 | * station to establish a peer link | ||
985 | * @ht_opmode: mesh HT protection mode | ||
986 | * | ||
987 | * @dot11MeshHWMPactivePathToRootTimeout: The time (in TUs) for which mesh STAs | ||
988 | * receiving a proactive PREQ shall consider the forwarding information to | ||
989 | * the root mesh STA to be valid. | ||
990 | * | ||
991 | * @dot11MeshHWMProotInterval: The interval of time (in TUs) between proactive | ||
992 | * PREQs are transmitted. | ||
993 | * @dot11MeshHWMPconfirmationInterval: The minimum interval of time (in TUs) | ||
994 | * during which a mesh STA can send only one Action frame containing | ||
995 | * a PREQ element for root path confirmation. | ||
996 | */ | 683 | */ |
997 | struct mesh_config { | 684 | struct mesh_config { |
685 | /* Timeouts in ms */ | ||
686 | /* Mesh plink management parameters */ | ||
998 | u16 dot11MeshRetryTimeout; | 687 | u16 dot11MeshRetryTimeout; |
999 | u16 dot11MeshConfirmTimeout; | 688 | u16 dot11MeshConfirmTimeout; |
1000 | u16 dot11MeshHoldingTimeout; | 689 | u16 dot11MeshHoldingTimeout; |
1001 | u16 dot11MeshMaxPeerLinks; | 690 | u16 dot11MeshMaxPeerLinks; |
1002 | u8 dot11MeshMaxRetries; | 691 | u8 dot11MeshMaxRetries; |
1003 | u8 dot11MeshTTL; | 692 | u8 dot11MeshTTL; |
1004 | u8 element_ttl; | 693 | /* ttl used in path selection information elements */ |
694 | u8 element_ttl; | ||
1005 | bool auto_open_plinks; | 695 | bool auto_open_plinks; |
1006 | u32 dot11MeshNbrOffsetMaxNeighbor; | 696 | /* HWMP parameters */ |
1007 | u8 dot11MeshHWMPmaxPREQretries; | 697 | u8 dot11MeshHWMPmaxPREQretries; |
1008 | u32 path_refresh_time; | 698 | u32 path_refresh_time; |
1009 | u16 min_discovery_timeout; | 699 | u16 min_discovery_timeout; |
1010 | u32 dot11MeshHWMPactivePathTimeout; | 700 | u32 dot11MeshHWMPactivePathTimeout; |
1011 | u16 dot11MeshHWMPpreqMinInterval; | 701 | u16 dot11MeshHWMPpreqMinInterval; |
1012 | u16 dot11MeshHWMPperrMinInterval; | ||
1013 | u16 dot11MeshHWMPnetDiameterTraversalTime; | 702 | u16 dot11MeshHWMPnetDiameterTraversalTime; |
1014 | u8 dot11MeshHWMPRootMode; | 703 | u8 dot11MeshHWMPRootMode; |
1015 | u16 dot11MeshHWMPRannInterval; | ||
1016 | bool dot11MeshGateAnnouncementProtocol; | ||
1017 | bool dot11MeshForwarding; | ||
1018 | s32 rssi_threshold; | ||
1019 | u16 ht_opmode; | ||
1020 | u32 dot11MeshHWMPactivePathToRootTimeout; | ||
1021 | u16 dot11MeshHWMProotInterval; | ||
1022 | u16 dot11MeshHWMPconfirmationInterval; | ||
1023 | }; | 704 | }; |
1024 | 705 | ||
1025 | /** | 706 | /** |
1026 | * struct mesh_setup - 802.11s mesh setup configuration | 707 | * struct mesh_setup - 802.11s mesh setup configuration |
1027 | * @chandef: defines the channel to use | ||
1028 | * @mesh_id: the mesh ID | 708 | * @mesh_id: the mesh ID |
1029 | * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes | 709 | * @mesh_id_len: length of the mesh ID, at least 1 and at most 32 bytes |
1030 | * @sync_method: which synchronization method to use | ||
1031 | * @path_sel_proto: which path selection protocol to use | 710 | * @path_sel_proto: which path selection protocol to use |
1032 | * @path_metric: which metric to use | 711 | * @path_metric: which metric to use |
1033 | * @ie: vendor information elements (optional) | 712 | * @ie: vendor information elements (optional) |
1034 | * @ie_len: length of vendor information elements | 713 | * @ie_len: length of vendor information elements |
1035 | * @is_authenticated: this mesh requires authentication | 714 | * @is_authenticated: this mesh requires authentication |
1036 | * @is_secure: this mesh uses security | 715 | * @is_secure: this mesh uses security |
1037 | * @mcast_rate: multicat rate for Mesh Node [6Mbps is the default for 802.11a] | ||
1038 | * | 716 | * |
1039 | * These parameters are fixed when the mesh is created. | 717 | * These parameters are fixed when the mesh is created. |
1040 | */ | 718 | */ |
1041 | struct mesh_setup { | 719 | struct mesh_setup { |
1042 | struct cfg80211_chan_def chandef; | ||
1043 | const u8 *mesh_id; | 720 | const u8 *mesh_id; |
1044 | u8 mesh_id_len; | 721 | u8 mesh_id_len; |
1045 | u8 sync_method; | 722 | u8 path_sel_proto; |
1046 | u8 path_sel_proto; | 723 | u8 path_metric; |
1047 | u8 path_metric; | ||
1048 | const u8 *ie; | 724 | const u8 *ie; |
1049 | u8 ie_len; | 725 | u8 ie_len; |
1050 | bool is_authenticated; | 726 | bool is_authenticated; |
1051 | bool is_secure; | 727 | bool is_secure; |
1052 | int mcast_rate[IEEE80211_NUM_BANDS]; | ||
1053 | }; | 728 | }; |
1054 | 729 | ||
1055 | /** | 730 | /** |
1056 | * struct ieee80211_txq_params - TX queue parameters | 731 | * struct ieee80211_txq_params - TX queue parameters |
1057 | * @ac: AC identifier | 732 | * @queue: TX queue identifier (NL80211_TXQ_Q_*) |
1058 | * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled | 733 | * @txop: Maximum burst time in units of 32 usecs, 0 meaning disabled |
1059 | * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range | 734 | * @cwmin: Minimum contention window [a value of the form 2^n-1 in the range |
1060 | * 1..32767] | 735 | * 1..32767] |
@@ -1063,13 +738,16 @@ struct mesh_setup { | |||
1063 | * @aifs: Arbitration interframe space [0..255] | 738 | * @aifs: Arbitration interframe space [0..255] |
1064 | */ | 739 | */ |
1065 | struct ieee80211_txq_params { | 740 | struct ieee80211_txq_params { |
1066 | enum nl80211_ac ac; | 741 | enum nl80211_txq_q queue; |
1067 | u16 txop; | 742 | u16 txop; |
1068 | u16 cwmin; | 743 | u16 cwmin; |
1069 | u16 cwmax; | 744 | u16 cwmax; |
1070 | u8 aifs; | 745 | u8 aifs; |
1071 | }; | 746 | }; |
1072 | 747 | ||
748 | /* from net/wireless.h */ | ||
749 | struct wiphy; | ||
750 | |||
1073 | /** | 751 | /** |
1074 | * DOC: Scanning and BSS list handling | 752 | * DOC: Scanning and BSS list handling |
1075 | * | 753 | * |
@@ -1112,13 +790,10 @@ struct cfg80211_ssid { | |||
1112 | * @n_channels: total number of channels to scan | 790 | * @n_channels: total number of channels to scan |
1113 | * @ie: optional information element(s) to add into Probe Request or %NULL | 791 | * @ie: optional information element(s) to add into Probe Request or %NULL |
1114 | * @ie_len: length of ie in octets | 792 | * @ie_len: length of ie in octets |
1115 | * @flags: bit field of flags controlling operation | ||
1116 | * @rates: bitmap of rates to advertise for each band | 793 | * @rates: bitmap of rates to advertise for each band |
1117 | * @wiphy: the wiphy this was for | 794 | * @wiphy: the wiphy this was for |
1118 | * @scan_start: time (in jiffies) when the scan started | 795 | * @dev: the interface |
1119 | * @wdev: the wireless device to scan for | ||
1120 | * @aborted: (internal) scan request was notified as aborted | 796 | * @aborted: (internal) scan request was notified as aborted |
1121 | * @no_cck: used to send probe requests at non CCK rate in 2GHz band | ||
1122 | */ | 797 | */ |
1123 | struct cfg80211_scan_request { | 798 | struct cfg80211_scan_request { |
1124 | struct cfg80211_ssid *ssids; | 799 | struct cfg80211_ssid *ssids; |
@@ -1126,32 +801,19 @@ struct cfg80211_scan_request { | |||
1126 | u32 n_channels; | 801 | u32 n_channels; |
1127 | const u8 *ie; | 802 | const u8 *ie; |
1128 | size_t ie_len; | 803 | size_t ie_len; |
1129 | u32 flags; | ||
1130 | 804 | ||
1131 | u32 rates[IEEE80211_NUM_BANDS]; | 805 | u32 rates[IEEE80211_NUM_BANDS]; |
1132 | 806 | ||
1133 | struct wireless_dev *wdev; | ||
1134 | |||
1135 | /* internal */ | 807 | /* internal */ |
1136 | struct wiphy *wiphy; | 808 | struct wiphy *wiphy; |
1137 | unsigned long scan_start; | 809 | struct net_device *dev; |
1138 | bool aborted; | 810 | bool aborted; |
1139 | bool no_cck; | ||
1140 | 811 | ||
1141 | /* keep last */ | 812 | /* keep last */ |
1142 | struct ieee80211_channel *channels[0]; | 813 | struct ieee80211_channel *channels[0]; |
1143 | }; | 814 | }; |
1144 | 815 | ||
1145 | /** | 816 | /** |
1146 | * struct cfg80211_match_set - sets of attributes to match | ||
1147 | * | ||
1148 | * @ssid: SSID to be matched | ||
1149 | */ | ||
1150 | struct cfg80211_match_set { | ||
1151 | struct cfg80211_ssid ssid; | ||
1152 | }; | ||
1153 | |||
1154 | /** | ||
1155 | * struct cfg80211_sched_scan_request - scheduled scan request description | 817 | * struct cfg80211_sched_scan_request - scheduled scan request description |
1156 | * | 818 | * |
1157 | * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans) | 819 | * @ssids: SSIDs to scan for (passed in the probe_reqs in active scans) |
@@ -1160,16 +822,9 @@ struct cfg80211_match_set { | |||
1160 | * @interval: interval between each scheduled scan cycle | 822 | * @interval: interval between each scheduled scan cycle |
1161 | * @ie: optional information element(s) to add into Probe Request or %NULL | 823 | * @ie: optional information element(s) to add into Probe Request or %NULL |
1162 | * @ie_len: length of ie in octets | 824 | * @ie_len: length of ie in octets |
1163 | * @flags: bit field of flags controlling operation | ||
1164 | * @match_sets: sets of parameters to be matched for a scan result | ||
1165 | * entry to be considered valid and to be passed to the host | ||
1166 | * (others are filtered out). | ||
1167 | * If ommited, all results are passed. | ||
1168 | * @n_match_sets: number of match sets | ||
1169 | * @wiphy: the wiphy this was for | 825 | * @wiphy: the wiphy this was for |
1170 | * @dev: the interface | 826 | * @dev: the interface |
1171 | * @channels: channels to scan | 827 | * @channels: channels to scan |
1172 | * @rssi_thold: don't report scan results below this threshold (in s32 dBm) | ||
1173 | */ | 828 | */ |
1174 | struct cfg80211_sched_scan_request { | 829 | struct cfg80211_sched_scan_request { |
1175 | struct cfg80211_ssid *ssids; | 830 | struct cfg80211_ssid *ssids; |
@@ -1178,15 +833,10 @@ struct cfg80211_sched_scan_request { | |||
1178 | u32 interval; | 833 | u32 interval; |
1179 | const u8 *ie; | 834 | const u8 *ie; |
1180 | size_t ie_len; | 835 | size_t ie_len; |
1181 | u32 flags; | ||
1182 | struct cfg80211_match_set *match_sets; | ||
1183 | int n_match_sets; | ||
1184 | s32 rssi_thold; | ||
1185 | 836 | ||
1186 | /* internal */ | 837 | /* internal */ |
1187 | struct wiphy *wiphy; | 838 | struct wiphy *wiphy; |
1188 | struct net_device *dev; | 839 | struct net_device *dev; |
1189 | unsigned long scan_start; | ||
1190 | 840 | ||
1191 | /* keep last */ | 841 | /* keep last */ |
1192 | struct ieee80211_channel *channels[0]; | 842 | struct ieee80211_channel *channels[0]; |
@@ -1206,18 +856,6 @@ enum cfg80211_signal_type { | |||
1206 | }; | 856 | }; |
1207 | 857 | ||
1208 | /** | 858 | /** |
1209 | * struct cfg80211_bss_ie_data - BSS entry IE data | ||
1210 | * @rcu_head: internal use, for freeing | ||
1211 | * @len: length of the IEs | ||
1212 | * @data: IE data | ||
1213 | */ | ||
1214 | struct cfg80211_bss_ies { | ||
1215 | struct rcu_head rcu_head; | ||
1216 | int len; | ||
1217 | u8 data[]; | ||
1218 | }; | ||
1219 | |||
1220 | /** | ||
1221 | * struct cfg80211_bss - BSS description | 859 | * struct cfg80211_bss - BSS description |
1222 | * | 860 | * |
1223 | * This structure describes a BSS (which may also be a mesh network) | 861 | * This structure describes a BSS (which may also be a mesh network) |
@@ -1228,34 +866,36 @@ struct cfg80211_bss_ies { | |||
1228 | * @tsf: timestamp of last received update | 866 | * @tsf: timestamp of last received update |
1229 | * @beacon_interval: the beacon interval as from the frame | 867 | * @beacon_interval: the beacon interval as from the frame |
1230 | * @capability: the capability field in host byte order | 868 | * @capability: the capability field in host byte order |
1231 | * @ies: the information elements (Note that there | 869 | * @information_elements: the information elements (Note that there |
1232 | * is no guarantee that these are well-formed!); this is a pointer to | 870 | * is no guarantee that these are well-formed!); this is a pointer to |
1233 | * either the beacon_ies or proberesp_ies depending on whether Probe | 871 | * either the beacon_ies or proberesp_ies depending on whether Probe |
1234 | * Response frame has been received | 872 | * Response frame has been received |
873 | * @len_information_elements: total length of the information elements | ||
1235 | * @beacon_ies: the information elements from the last Beacon frame | 874 | * @beacon_ies: the information elements from the last Beacon frame |
875 | * @len_beacon_ies: total length of the beacon_ies | ||
1236 | * @proberesp_ies: the information elements from the last Probe Response frame | 876 | * @proberesp_ies: the information elements from the last Probe Response frame |
877 | * @len_proberesp_ies: total length of the proberesp_ies | ||
1237 | * @signal: signal strength value (type depends on the wiphy's signal_type) | 878 | * @signal: signal strength value (type depends on the wiphy's signal_type) |
1238 | * @free_priv: function pointer to free private data | 879 | * @free_priv: function pointer to free private data |
1239 | * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes | 880 | * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes |
1240 | */ | 881 | */ |
1241 | struct cfg80211_bss { | 882 | struct cfg80211_bss { |
1242 | u64 tsf; | ||
1243 | |||
1244 | struct ieee80211_channel *channel; | 883 | struct ieee80211_channel *channel; |
1245 | 884 | ||
1246 | const struct cfg80211_bss_ies __rcu *ies; | 885 | u8 bssid[ETH_ALEN]; |
1247 | const struct cfg80211_bss_ies __rcu *beacon_ies; | 886 | u64 tsf; |
1248 | const struct cfg80211_bss_ies __rcu *proberesp_ies; | ||
1249 | |||
1250 | void (*free_priv)(struct cfg80211_bss *bss); | ||
1251 | |||
1252 | s32 signal; | ||
1253 | |||
1254 | u16 beacon_interval; | 887 | u16 beacon_interval; |
1255 | u16 capability; | 888 | u16 capability; |
889 | u8 *information_elements; | ||
890 | size_t len_information_elements; | ||
891 | u8 *beacon_ies; | ||
892 | size_t len_beacon_ies; | ||
893 | u8 *proberesp_ies; | ||
894 | size_t len_proberesp_ies; | ||
1256 | 895 | ||
1257 | u8 bssid[ETH_ALEN]; | 896 | s32 signal; |
1258 | 897 | ||
898 | void (*free_priv)(struct cfg80211_bss *bss); | ||
1259 | u8 priv[0] __attribute__((__aligned__(sizeof(void *)))); | 899 | u8 priv[0] __attribute__((__aligned__(sizeof(void *)))); |
1260 | }; | 900 | }; |
1261 | 901 | ||
@@ -1263,15 +903,42 @@ struct cfg80211_bss { | |||
1263 | * ieee80211_bss_get_ie - find IE with given ID | 903 | * ieee80211_bss_get_ie - find IE with given ID |
1264 | * @bss: the bss to search | 904 | * @bss: the bss to search |
1265 | * @ie: the IE ID | 905 | * @ie: the IE ID |
1266 | * | ||
1267 | * Note that the return value is an RCU-protected pointer, so | ||
1268 | * rcu_read_lock() must be held when calling this function. | ||
1269 | * Returns %NULL if not found. | 906 | * Returns %NULL if not found. |
1270 | */ | 907 | */ |
1271 | const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie); | 908 | const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie); |
1272 | 909 | ||
1273 | 910 | ||
1274 | /** | 911 | /** |
912 | * struct cfg80211_crypto_settings - Crypto settings | ||
913 | * @wpa_versions: indicates which, if any, WPA versions are enabled | ||
914 | * (from enum nl80211_wpa_versions) | ||
915 | * @cipher_group: group key cipher suite (or 0 if unset) | ||
916 | * @n_ciphers_pairwise: number of AP supported unicast ciphers | ||
917 | * @ciphers_pairwise: unicast key cipher suites | ||
918 | * @n_akm_suites: number of AKM suites | ||
919 | * @akm_suites: AKM suites | ||
920 | * @control_port: Whether user space controls IEEE 802.1X port, i.e., | ||
921 | * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is | ||
922 | * required to assume that the port is unauthorized until authorized by | ||
923 | * user space. Otherwise, port is marked authorized by default. | ||
924 | * @control_port_ethertype: the control port protocol that should be | ||
925 | * allowed through even on unauthorized ports | ||
926 | * @control_port_no_encrypt: TRUE to prevent encryption of control port | ||
927 | * protocol frames. | ||
928 | */ | ||
929 | struct cfg80211_crypto_settings { | ||
930 | u32 wpa_versions; | ||
931 | u32 cipher_group; | ||
932 | int n_ciphers_pairwise; | ||
933 | u32 ciphers_pairwise[NL80211_MAX_NR_CIPHER_SUITES]; | ||
934 | int n_akm_suites; | ||
935 | u32 akm_suites[NL80211_MAX_NR_AKM_SUITES]; | ||
936 | bool control_port; | ||
937 | __be16 control_port_ethertype; | ||
938 | bool control_port_no_encrypt; | ||
939 | }; | ||
940 | |||
941 | /** | ||
1275 | * struct cfg80211_auth_request - Authentication request data | 942 | * struct cfg80211_auth_request - Authentication request data |
1276 | * | 943 | * |
1277 | * This structure provides information needed to complete IEEE 802.11 | 944 | * This structure provides information needed to complete IEEE 802.11 |
@@ -1284,9 +951,10 @@ const u8 *ieee80211_bss_get_ie(struct cfg80211_bss *bss, u8 ie); | |||
1284 | * @key_len: length of WEP key for shared key authentication | 951 | * @key_len: length of WEP key for shared key authentication |
1285 | * @key_idx: index of WEP key for shared key authentication | 952 | * @key_idx: index of WEP key for shared key authentication |
1286 | * @key: WEP key for shared key authentication | 953 | * @key: WEP key for shared key authentication |
1287 | * @sae_data: Non-IE data to use with SAE or %NULL. This starts with | 954 | * @local_state_change: This is a request for a local state only, i.e., no |
1288 | * Authentication transaction sequence number field. | 955 | * Authentication frame is to be transmitted and authentication state is |
1289 | * @sae_data_len: Length of sae_data buffer in octets | 956 | * to be changed without having to wait for a response from the peer STA |
957 | * (AP). | ||
1290 | */ | 958 | */ |
1291 | struct cfg80211_auth_request { | 959 | struct cfg80211_auth_request { |
1292 | struct cfg80211_bss *bss; | 960 | struct cfg80211_bss *bss; |
@@ -1295,17 +963,7 @@ struct cfg80211_auth_request { | |||
1295 | enum nl80211_auth_type auth_type; | 963 | enum nl80211_auth_type auth_type; |
1296 | const u8 *key; | 964 | const u8 *key; |
1297 | u8 key_len, key_idx; | 965 | u8 key_len, key_idx; |
1298 | const u8 *sae_data; | 966 | bool local_state_change; |
1299 | size_t sae_data_len; | ||
1300 | }; | ||
1301 | |||
1302 | /** | ||
1303 | * enum cfg80211_assoc_req_flags - Over-ride default behaviour in association. | ||
1304 | * | ||
1305 | * @ASSOC_REQ_DISABLE_HT: Disable HT (802.11n) | ||
1306 | */ | ||
1307 | enum cfg80211_assoc_req_flags { | ||
1308 | ASSOC_REQ_DISABLE_HT = BIT(0), | ||
1309 | }; | 967 | }; |
1310 | 968 | ||
1311 | /** | 969 | /** |
@@ -1313,20 +971,12 @@ enum cfg80211_assoc_req_flags { | |||
1313 | * | 971 | * |
1314 | * This structure provides information needed to complete IEEE 802.11 | 972 | * This structure provides information needed to complete IEEE 802.11 |
1315 | * (re)association. | 973 | * (re)association. |
1316 | * @bss: The BSS to associate with. If the call is successful the driver | 974 | * @bss: The BSS to associate with. |
1317 | * is given a reference that it must release, normally via a call to | ||
1318 | * cfg80211_send_rx_assoc(), or, if association timed out, with a | ||
1319 | * call to cfg80211_put_bss() (in addition to calling | ||
1320 | * cfg80211_send_assoc_timeout()) | ||
1321 | * @ie: Extra IEs to add to (Re)Association Request frame or %NULL | 975 | * @ie: Extra IEs to add to (Re)Association Request frame or %NULL |
1322 | * @ie_len: Length of ie buffer in octets | 976 | * @ie_len: Length of ie buffer in octets |
1323 | * @use_mfp: Use management frame protection (IEEE 802.11w) in this association | 977 | * @use_mfp: Use management frame protection (IEEE 802.11w) in this association |
1324 | * @crypto: crypto settings | 978 | * @crypto: crypto settings |
1325 | * @prev_bssid: previous BSSID, if not %NULL use reassociate frame | 979 | * @prev_bssid: previous BSSID, if not %NULL use reassociate frame |
1326 | * @flags: See &enum cfg80211_assoc_req_flags | ||
1327 | * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask | ||
1328 | * will be used in ht_capa. Un-supported values will be ignored. | ||
1329 | * @ht_capa_mask: The bits of ht_capa which are to be used. | ||
1330 | */ | 980 | */ |
1331 | struct cfg80211_assoc_request { | 981 | struct cfg80211_assoc_request { |
1332 | struct cfg80211_bss *bss; | 982 | struct cfg80211_bss *bss; |
@@ -1334,9 +984,6 @@ struct cfg80211_assoc_request { | |||
1334 | size_t ie_len; | 984 | size_t ie_len; |
1335 | struct cfg80211_crypto_settings crypto; | 985 | struct cfg80211_crypto_settings crypto; |
1336 | bool use_mfp; | 986 | bool use_mfp; |
1337 | u32 flags; | ||
1338 | struct ieee80211_ht_cap ht_capa; | ||
1339 | struct ieee80211_ht_cap ht_capa_mask; | ||
1340 | }; | 987 | }; |
1341 | 988 | ||
1342 | /** | 989 | /** |
@@ -1345,13 +992,15 @@ struct cfg80211_assoc_request { | |||
1345 | * This structure provides information needed to complete IEEE 802.11 | 992 | * This structure provides information needed to complete IEEE 802.11 |
1346 | * deauthentication. | 993 | * deauthentication. |
1347 | * | 994 | * |
1348 | * @bssid: the BSSID of the BSS to deauthenticate from | 995 | * @bss: the BSS to deauthenticate from |
1349 | * @ie: Extra IEs to add to Deauthentication frame or %NULL | 996 | * @ie: Extra IEs to add to Deauthentication frame or %NULL |
1350 | * @ie_len: Length of ie buffer in octets | 997 | * @ie_len: Length of ie buffer in octets |
1351 | * @reason_code: The reason code for the deauthentication | 998 | * @reason_code: The reason code for the deauthentication |
999 | * @local_state_change: This is a request for a local state only, i.e., no | ||
1000 | * Deauthentication frame is to be transmitted. | ||
1352 | */ | 1001 | */ |
1353 | struct cfg80211_deauth_request { | 1002 | struct cfg80211_deauth_request { |
1354 | const u8 *bssid; | 1003 | struct cfg80211_bss *bss; |
1355 | const u8 *ie; | 1004 | const u8 *ie; |
1356 | size_t ie_len; | 1005 | size_t ie_len; |
1357 | u16 reason_code; | 1006 | u16 reason_code; |
@@ -1389,7 +1038,7 @@ struct cfg80211_disassoc_request { | |||
1389 | * @ssid_len: The length of the SSID, will always be non-zero. | 1038 | * @ssid_len: The length of the SSID, will always be non-zero. |
1390 | * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not | 1039 | * @bssid: Fixed BSSID requested, maybe be %NULL, if set do not |
1391 | * search for IBSSs with a different BSSID. | 1040 | * search for IBSSs with a different BSSID. |
1392 | * @chandef: defines the channel to use if no other IBSS to join can be found | 1041 | * @channel: The channel to use if no IBSS can be found to join. |
1393 | * @channel_fixed: The channel should be fixed -- do not search for | 1042 | * @channel_fixed: The channel should be fixed -- do not search for |
1394 | * IBSSs to join on other channels. | 1043 | * IBSSs to join on other channels. |
1395 | * @ie: information element(s) to include in the beacon | 1044 | * @ie: information element(s) to include in the beacon |
@@ -1397,24 +1046,19 @@ struct cfg80211_disassoc_request { | |||
1397 | * @beacon_interval: beacon interval to use | 1046 | * @beacon_interval: beacon interval to use |
1398 | * @privacy: this is a protected network, keys will be configured | 1047 | * @privacy: this is a protected network, keys will be configured |
1399 | * after joining | 1048 | * after joining |
1400 | * @control_port: whether user space controls IEEE 802.1X port, i.e., | ||
1401 | * sets/clears %NL80211_STA_FLAG_AUTHORIZED. If true, the driver is | ||
1402 | * required to assume that the port is unauthorized until authorized by | ||
1403 | * user space. Otherwise, port is marked authorized by default. | ||
1404 | * @basic_rates: bitmap of basic rates to use when creating the IBSS | 1049 | * @basic_rates: bitmap of basic rates to use when creating the IBSS |
1405 | * @mcast_rate: per-band multicast rate index + 1 (0: disabled) | 1050 | * @mcast_rate: per-band multicast rate index + 1 (0: disabled) |
1406 | */ | 1051 | */ |
1407 | struct cfg80211_ibss_params { | 1052 | struct cfg80211_ibss_params { |
1408 | u8 *ssid; | 1053 | u8 *ssid; |
1409 | u8 *bssid; | 1054 | u8 *bssid; |
1410 | struct cfg80211_chan_def chandef; | 1055 | struct ieee80211_channel *channel; |
1411 | u8 *ie; | 1056 | u8 *ie; |
1412 | u8 ssid_len, ie_len; | 1057 | u8 ssid_len, ie_len; |
1413 | u16 beacon_interval; | 1058 | u16 beacon_interval; |
1414 | u32 basic_rates; | 1059 | u32 basic_rates; |
1415 | bool channel_fixed; | 1060 | bool channel_fixed; |
1416 | bool privacy; | 1061 | bool privacy; |
1417 | bool control_port; | ||
1418 | int mcast_rate[IEEE80211_NUM_BANDS]; | 1062 | int mcast_rate[IEEE80211_NUM_BANDS]; |
1419 | }; | 1063 | }; |
1420 | 1064 | ||
@@ -1438,12 +1082,6 @@ struct cfg80211_ibss_params { | |||
1438 | * @key_len: length of WEP key for shared key authentication | 1082 | * @key_len: length of WEP key for shared key authentication |
1439 | * @key_idx: index of WEP key for shared key authentication | 1083 | * @key_idx: index of WEP key for shared key authentication |
1440 | * @key: WEP key for shared key authentication | 1084 | * @key: WEP key for shared key authentication |
1441 | * @flags: See &enum cfg80211_assoc_req_flags | ||
1442 | * @bg_scan_period: Background scan period in seconds | ||
1443 | * or -1 to indicate that default value is to be used. | ||
1444 | * @ht_capa: HT Capabilities over-rides. Values set in ht_capa_mask | ||
1445 | * will be used in ht_capa. Un-supported values will be ignored. | ||
1446 | * @ht_capa_mask: The bits of ht_capa which are to be used. | ||
1447 | */ | 1085 | */ |
1448 | struct cfg80211_connect_params { | 1086 | struct cfg80211_connect_params { |
1449 | struct ieee80211_channel *channel; | 1087 | struct ieee80211_channel *channel; |
@@ -1457,10 +1095,6 @@ struct cfg80211_connect_params { | |||
1457 | struct cfg80211_crypto_settings crypto; | 1095 | struct cfg80211_crypto_settings crypto; |
1458 | const u8 *key; | 1096 | const u8 *key; |
1459 | u8 key_len, key_idx; | 1097 | u8 key_len, key_idx; |
1460 | u32 flags; | ||
1461 | int bg_scan_period; | ||
1462 | struct ieee80211_ht_cap ht_capa; | ||
1463 | struct ieee80211_ht_cap ht_capa_mask; | ||
1464 | }; | 1098 | }; |
1465 | 1099 | ||
1466 | /** | 1100 | /** |
@@ -1485,7 +1119,8 @@ enum wiphy_params_flags { | |||
1485 | struct cfg80211_bitrate_mask { | 1119 | struct cfg80211_bitrate_mask { |
1486 | struct { | 1120 | struct { |
1487 | u32 legacy; | 1121 | u32 legacy; |
1488 | u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; | 1122 | /* TODO: add support for masking MCS rates; e.g.: */ |
1123 | /* u8 mcs[IEEE80211_HT_MCS_MASK_LEN]; */ | ||
1489 | } control[IEEE80211_NUM_BANDS]; | 1124 | } control[IEEE80211_NUM_BANDS]; |
1490 | }; | 1125 | }; |
1491 | /** | 1126 | /** |
@@ -1569,17 +1204,13 @@ struct cfg80211_gtk_rekey_data { | |||
1569 | * be %NULL or contain the enabled Wake-on-Wireless triggers that are | 1204 | * be %NULL or contain the enabled Wake-on-Wireless triggers that are |
1570 | * configured for the device. | 1205 | * configured for the device. |
1571 | * @resume: wiphy device needs to be resumed | 1206 | * @resume: wiphy device needs to be resumed |
1572 | * @set_wakeup: Called when WoWLAN is enabled/disabled, use this callback | ||
1573 | * to call device_set_wakeup_enable() to enable/disable wakeup from | ||
1574 | * the device. | ||
1575 | * | 1207 | * |
1576 | * @add_virtual_intf: create a new virtual interface with the given name, | 1208 | * @add_virtual_intf: create a new virtual interface with the given name, |
1577 | * must set the struct wireless_dev's iftype. Beware: You must create | 1209 | * must set the struct wireless_dev's iftype. Beware: You must create |
1578 | * the new netdev in the wiphy's network namespace! Returns the struct | 1210 | * the new netdev in the wiphy's network namespace! Returns the netdev, |
1579 | * wireless_dev, or an ERR_PTR. For P2P device wdevs, the driver must | 1211 | * or an ERR_PTR. |
1580 | * also set the address member in the wdev. | ||
1581 | * | 1212 | * |
1582 | * @del_virtual_intf: remove the virtual interface | 1213 | * @del_virtual_intf: remove the virtual interface determined by ifindex. |
1583 | * | 1214 | * |
1584 | * @change_virtual_intf: change type/configuration of virtual interface, | 1215 | * @change_virtual_intf: change type/configuration of virtual interface, |
1585 | * keep the struct wireless_dev's iftype updated. | 1216 | * keep the struct wireless_dev's iftype updated. |
@@ -1602,19 +1233,16 @@ struct cfg80211_gtk_rekey_data { | |||
1602 | * | 1233 | * |
1603 | * @set_rekey_data: give the data necessary for GTK rekeying to the driver | 1234 | * @set_rekey_data: give the data necessary for GTK rekeying to the driver |
1604 | * | 1235 | * |
1605 | * @start_ap: Start acting in AP mode defined by the parameters. | 1236 | * @add_beacon: Add a beacon with given parameters, @head, @interval |
1606 | * @change_beacon: Change the beacon parameters for an access point mode | 1237 | * and @dtim_period will be valid, @tail is optional. |
1607 | * interface. This should reject the call when AP mode wasn't started. | 1238 | * @set_beacon: Change the beacon parameters for an access point mode |
1608 | * @stop_ap: Stop being an AP, including stopping beaconing. | 1239 | * interface. This should reject the call when no beacon has been |
1240 | * configured. | ||
1241 | * @del_beacon: Remove beacon configuration and stop sending the beacon. | ||
1609 | * | 1242 | * |
1610 | * @add_station: Add a new station. | 1243 | * @add_station: Add a new station. |
1611 | * @del_station: Remove a station; @mac may be NULL to remove all stations. | 1244 | * @del_station: Remove a station; @mac may be NULL to remove all stations. |
1612 | * @change_station: Modify a given station. Note that flags changes are not much | 1245 | * @change_station: Modify a given station. |
1613 | * validated in cfg80211, in particular the auth/assoc/authorized flags | ||
1614 | * might come to the driver in invalid combinations -- make sure to check | ||
1615 | * them, also against the existing state! Also, supported_rates changes are | ||
1616 | * not checked in station mode -- drivers need to reject (or ignore) them | ||
1617 | * for anything but TDLS peers. | ||
1618 | * @get_station: get station information for the station identified by @mac | 1246 | * @get_station: get station information for the station identified by @mac |
1619 | * @dump_station: dump station callback -- resume dump at index @idx | 1247 | * @dump_station: dump station callback -- resume dump at index @idx |
1620 | * | 1248 | * |
@@ -1636,14 +1264,11 @@ struct cfg80211_gtk_rekey_data { | |||
1636 | * | 1264 | * |
1637 | * @set_txq_params: Set TX queue parameters | 1265 | * @set_txq_params: Set TX queue parameters |
1638 | * | 1266 | * |
1639 | * @libertas_set_mesh_channel: Only for backward compatibility for libertas, | 1267 | * @set_channel: Set channel for a given wireless interface. Some devices |
1640 | * as it doesn't implement join_mesh and needs to set the channel to | 1268 | * may support multi-channel operation (by channel hopping) so cfg80211 |
1641 | * join the mesh instead. | 1269 | * doesn't verify much. Note, however, that the passed netdev may be |
1642 | * | 1270 | * %NULL as well if the user requested changing the channel for the |
1643 | * @set_monitor_channel: Set the monitor mode channel for the device. If other | 1271 | * device itself, or for a monitor interface. |
1644 | * interfaces are active this callback should reject the configuration. | ||
1645 | * If no interfaces are active or the device is down, the channel should | ||
1646 | * be stored for when a monitor interface becomes active. | ||
1647 | * | 1272 | * |
1648 | * @scan: Request to do a scan. If returning zero, the scan request is given | 1273 | * @scan: Request to do a scan. If returning zero, the scan request is given |
1649 | * the driver, and will be valid until passed to cfg80211_scan_done(). | 1274 | * the driver, and will be valid until passed to cfg80211_scan_done(). |
@@ -1666,19 +1291,12 @@ struct cfg80211_gtk_rekey_data { | |||
1666 | * to a merge. | 1291 | * to a merge. |
1667 | * @leave_ibss: Leave the IBSS. | 1292 | * @leave_ibss: Leave the IBSS. |
1668 | * | 1293 | * |
1669 | * @set_mcast_rate: Set the specified multicast rate (only if vif is in ADHOC or | ||
1670 | * MESH mode) | ||
1671 | * | ||
1672 | * @set_wiphy_params: Notify that wiphy parameters have changed; | 1294 | * @set_wiphy_params: Notify that wiphy parameters have changed; |
1673 | * @changed bitfield (see &enum wiphy_params_flags) describes which values | 1295 | * @changed bitfield (see &enum wiphy_params_flags) describes which values |
1674 | * have changed. The actual parameter values are available in | 1296 | * have changed. The actual parameter values are available in |
1675 | * struct wiphy. If returning an error, no value should be changed. | 1297 | * struct wiphy. If returning an error, no value should be changed. |
1676 | * | 1298 | * |
1677 | * @set_tx_power: set the transmit power according to the parameters, | 1299 | * @set_tx_power: set the transmit power according to the parameters |
1678 | * the power passed is in mBm, to get dBm use MBM_TO_DBM(). The | ||
1679 | * wdev may be %NULL if power was set for the wiphy, and will | ||
1680 | * always be %NULL unless the driver supports per-vif TX power | ||
1681 | * (as advertised by the nl80211 feature flag.) | ||
1682 | * @get_tx_power: store the current TX power into the dbm variable; | 1300 | * @get_tx_power: store the current TX power into the dbm variable; |
1683 | * return 0 if successful | 1301 | * return 0 if successful |
1684 | * | 1302 | * |
@@ -1719,10 +1337,10 @@ struct cfg80211_gtk_rekey_data { | |||
1719 | * @set_power_mgmt: Configure WLAN power management. A timeout value of -1 | 1337 | * @set_power_mgmt: Configure WLAN power management. A timeout value of -1 |
1720 | * allows the driver to adjust the dynamic ps timeout value. | 1338 | * allows the driver to adjust the dynamic ps timeout value. |
1721 | * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold. | 1339 | * @set_cqm_rssi_config: Configure connection quality monitor RSSI threshold. |
1722 | * @set_cqm_txe_config: Configure connection quality monitor TX error | ||
1723 | * thresholds. | ||
1724 | * @sched_scan_start: Tell the driver to start a scheduled scan. | 1340 | * @sched_scan_start: Tell the driver to start a scheduled scan. |
1725 | * @sched_scan_stop: Tell the driver to stop an ongoing scheduled scan. | 1341 | * @sched_scan_stop: Tell the driver to stop an ongoing scheduled |
1342 | * scan. The driver_initiated flag specifies whether the driver | ||
1343 | * itself has informed that the scan has stopped. | ||
1726 | * | 1344 | * |
1727 | * @mgmt_frame_register: Notify driver that a management frame type was | 1345 | * @mgmt_frame_register: Notify driver that a management frame type was |
1728 | * registered. Note that this callback may not sleep, and cannot run | 1346 | * registered. Note that this callback may not sleep, and cannot run |
@@ -1738,44 +1356,17 @@ struct cfg80211_gtk_rekey_data { | |||
1738 | * @set_ringparam: Set tx and rx ring sizes. | 1356 | * @set_ringparam: Set tx and rx ring sizes. |
1739 | * | 1357 | * |
1740 | * @get_ringparam: Get tx and rx ring current and maximum sizes. | 1358 | * @get_ringparam: Get tx and rx ring current and maximum sizes. |
1741 | * | ||
1742 | * @tdls_mgmt: Transmit a TDLS management frame. | ||
1743 | * @tdls_oper: Perform a high-level TDLS operation (e.g. TDLS link setup). | ||
1744 | * | ||
1745 | * @probe_client: probe an associated client, must return a cookie that it | ||
1746 | * later passes to cfg80211_probe_status(). | ||
1747 | * | ||
1748 | * @set_noack_map: Set the NoAck Map for the TIDs. | ||
1749 | * | ||
1750 | * @get_et_sset_count: Ethtool API to get string-set count. | ||
1751 | * See @ethtool_ops.get_sset_count | ||
1752 | * | ||
1753 | * @get_et_stats: Ethtool API to get a set of u64 stats. | ||
1754 | * See @ethtool_ops.get_ethtool_stats | ||
1755 | * | ||
1756 | * @get_et_strings: Ethtool API to get a set of strings to describe stats | ||
1757 | * and perhaps other supported types of ethtool data-sets. | ||
1758 | * See @ethtool_ops.get_strings | ||
1759 | * | ||
1760 | * @get_channel: Get the current operating channel for the virtual interface. | ||
1761 | * For monitor interfaces, it should return %NULL unless there's a single | ||
1762 | * current monitoring channel. | ||
1763 | * | ||
1764 | * @start_p2p_device: Start the given P2P device. | ||
1765 | * @stop_p2p_device: Stop the given P2P device. | ||
1766 | */ | 1359 | */ |
1767 | struct cfg80211_ops { | 1360 | struct cfg80211_ops { |
1768 | int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); | 1361 | int (*suspend)(struct wiphy *wiphy, struct cfg80211_wowlan *wow); |
1769 | int (*resume)(struct wiphy *wiphy); | 1362 | int (*resume)(struct wiphy *wiphy); |
1770 | void (*set_wakeup)(struct wiphy *wiphy, bool enabled); | 1363 | |
1771 | 1364 | struct net_device * (*add_virtual_intf)(struct wiphy *wiphy, | |
1772 | struct wireless_dev * (*add_virtual_intf)(struct wiphy *wiphy, | 1365 | char *name, |
1773 | const char *name, | 1366 | enum nl80211_iftype type, |
1774 | enum nl80211_iftype type, | 1367 | u32 *flags, |
1775 | u32 *flags, | 1368 | struct vif_params *params); |
1776 | struct vif_params *params); | 1369 | int (*del_virtual_intf)(struct wiphy *wiphy, struct net_device *dev); |
1777 | int (*del_virtual_intf)(struct wiphy *wiphy, | ||
1778 | struct wireless_dev *wdev); | ||
1779 | int (*change_virtual_intf)(struct wiphy *wiphy, | 1370 | int (*change_virtual_intf)(struct wiphy *wiphy, |
1780 | struct net_device *dev, | 1371 | struct net_device *dev, |
1781 | enum nl80211_iftype type, u32 *flags, | 1372 | enum nl80211_iftype type, u32 *flags, |
@@ -1797,11 +1388,11 @@ struct cfg80211_ops { | |||
1797 | struct net_device *netdev, | 1388 | struct net_device *netdev, |
1798 | u8 key_index); | 1389 | u8 key_index); |
1799 | 1390 | ||
1800 | int (*start_ap)(struct wiphy *wiphy, struct net_device *dev, | 1391 | int (*add_beacon)(struct wiphy *wiphy, struct net_device *dev, |
1801 | struct cfg80211_ap_settings *settings); | 1392 | struct beacon_parameters *info); |
1802 | int (*change_beacon)(struct wiphy *wiphy, struct net_device *dev, | 1393 | int (*set_beacon)(struct wiphy *wiphy, struct net_device *dev, |
1803 | struct cfg80211_beacon_data *info); | 1394 | struct beacon_parameters *info); |
1804 | int (*stop_ap)(struct wiphy *wiphy, struct net_device *dev); | 1395 | int (*del_beacon)(struct wiphy *wiphy, struct net_device *dev); |
1805 | 1396 | ||
1806 | 1397 | ||
1807 | int (*add_station)(struct wiphy *wiphy, struct net_device *dev, | 1398 | int (*add_station)(struct wiphy *wiphy, struct net_device *dev, |
@@ -1841,17 +1432,14 @@ struct cfg80211_ops { | |||
1841 | int (*change_bss)(struct wiphy *wiphy, struct net_device *dev, | 1432 | int (*change_bss)(struct wiphy *wiphy, struct net_device *dev, |
1842 | struct bss_parameters *params); | 1433 | struct bss_parameters *params); |
1843 | 1434 | ||
1844 | int (*set_txq_params)(struct wiphy *wiphy, struct net_device *dev, | 1435 | int (*set_txq_params)(struct wiphy *wiphy, |
1845 | struct ieee80211_txq_params *params); | 1436 | struct ieee80211_txq_params *params); |
1846 | 1437 | ||
1847 | int (*libertas_set_mesh_channel)(struct wiphy *wiphy, | 1438 | int (*set_channel)(struct wiphy *wiphy, struct net_device *dev, |
1848 | struct net_device *dev, | 1439 | struct ieee80211_channel *chan, |
1849 | struct ieee80211_channel *chan); | 1440 | enum nl80211_channel_type channel_type); |
1850 | |||
1851 | int (*set_monitor_channel)(struct wiphy *wiphy, | ||
1852 | struct cfg80211_chan_def *chandef); | ||
1853 | 1441 | ||
1854 | int (*scan)(struct wiphy *wiphy, | 1442 | int (*scan)(struct wiphy *wiphy, struct net_device *dev, |
1855 | struct cfg80211_scan_request *request); | 1443 | struct cfg80211_scan_request *request); |
1856 | 1444 | ||
1857 | int (*auth)(struct wiphy *wiphy, struct net_device *dev, | 1445 | int (*auth)(struct wiphy *wiphy, struct net_device *dev, |
@@ -1859,9 +1447,11 @@ struct cfg80211_ops { | |||
1859 | int (*assoc)(struct wiphy *wiphy, struct net_device *dev, | 1447 | int (*assoc)(struct wiphy *wiphy, struct net_device *dev, |
1860 | struct cfg80211_assoc_request *req); | 1448 | struct cfg80211_assoc_request *req); |
1861 | int (*deauth)(struct wiphy *wiphy, struct net_device *dev, | 1449 | int (*deauth)(struct wiphy *wiphy, struct net_device *dev, |
1862 | struct cfg80211_deauth_request *req); | 1450 | struct cfg80211_deauth_request *req, |
1451 | void *cookie); | ||
1863 | int (*disassoc)(struct wiphy *wiphy, struct net_device *dev, | 1452 | int (*disassoc)(struct wiphy *wiphy, struct net_device *dev, |
1864 | struct cfg80211_disassoc_request *req); | 1453 | struct cfg80211_disassoc_request *req, |
1454 | void *cookie); | ||
1865 | 1455 | ||
1866 | int (*connect)(struct wiphy *wiphy, struct net_device *dev, | 1456 | int (*connect)(struct wiphy *wiphy, struct net_device *dev, |
1867 | struct cfg80211_connect_params *sme); | 1457 | struct cfg80211_connect_params *sme); |
@@ -1872,15 +1462,11 @@ struct cfg80211_ops { | |||
1872 | struct cfg80211_ibss_params *params); | 1462 | struct cfg80211_ibss_params *params); |
1873 | int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev); | 1463 | int (*leave_ibss)(struct wiphy *wiphy, struct net_device *dev); |
1874 | 1464 | ||
1875 | int (*set_mcast_rate)(struct wiphy *wiphy, struct net_device *dev, | ||
1876 | int rate[IEEE80211_NUM_BANDS]); | ||
1877 | |||
1878 | int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed); | 1465 | int (*set_wiphy_params)(struct wiphy *wiphy, u32 changed); |
1879 | 1466 | ||
1880 | int (*set_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev, | 1467 | int (*set_tx_power)(struct wiphy *wiphy, |
1881 | enum nl80211_tx_power_setting type, int mbm); | 1468 | enum nl80211_tx_power_setting type, int mbm); |
1882 | int (*get_tx_power)(struct wiphy *wiphy, struct wireless_dev *wdev, | 1469 | int (*get_tx_power)(struct wiphy *wiphy, int *dbm); |
1883 | int *dbm); | ||
1884 | 1470 | ||
1885 | int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, | 1471 | int (*set_wds_peer)(struct wiphy *wiphy, struct net_device *dev, |
1886 | const u8 *addr); | 1472 | const u8 *addr); |
@@ -1909,20 +1495,22 @@ struct cfg80211_ops { | |||
1909 | int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev); | 1495 | int (*flush_pmksa)(struct wiphy *wiphy, struct net_device *netdev); |
1910 | 1496 | ||
1911 | int (*remain_on_channel)(struct wiphy *wiphy, | 1497 | int (*remain_on_channel)(struct wiphy *wiphy, |
1912 | struct wireless_dev *wdev, | 1498 | struct net_device *dev, |
1913 | struct ieee80211_channel *chan, | 1499 | struct ieee80211_channel *chan, |
1500 | enum nl80211_channel_type channel_type, | ||
1914 | unsigned int duration, | 1501 | unsigned int duration, |
1915 | u64 *cookie); | 1502 | u64 *cookie); |
1916 | int (*cancel_remain_on_channel)(struct wiphy *wiphy, | 1503 | int (*cancel_remain_on_channel)(struct wiphy *wiphy, |
1917 | struct wireless_dev *wdev, | 1504 | struct net_device *dev, |
1918 | u64 cookie); | 1505 | u64 cookie); |
1919 | 1506 | ||
1920 | int (*mgmt_tx)(struct wiphy *wiphy, struct wireless_dev *wdev, | 1507 | int (*mgmt_tx)(struct wiphy *wiphy, struct net_device *dev, |
1921 | struct ieee80211_channel *chan, bool offchan, | 1508 | struct ieee80211_channel *chan, bool offchan, |
1922 | unsigned int wait, const u8 *buf, size_t len, | 1509 | enum nl80211_channel_type channel_type, |
1923 | bool no_cck, bool dont_wait_for_ack, u64 *cookie); | 1510 | bool channel_type_valid, unsigned int wait, |
1511 | const u8 *buf, size_t len, u64 *cookie); | ||
1924 | int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy, | 1512 | int (*mgmt_tx_cancel_wait)(struct wiphy *wiphy, |
1925 | struct wireless_dev *wdev, | 1513 | struct net_device *dev, |
1926 | u64 cookie); | 1514 | u64 cookie); |
1927 | 1515 | ||
1928 | int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev, | 1516 | int (*set_power_mgmt)(struct wiphy *wiphy, struct net_device *dev, |
@@ -1932,12 +1520,8 @@ struct cfg80211_ops { | |||
1932 | struct net_device *dev, | 1520 | struct net_device *dev, |
1933 | s32 rssi_thold, u32 rssi_hyst); | 1521 | s32 rssi_thold, u32 rssi_hyst); |
1934 | 1522 | ||
1935 | int (*set_cqm_txe_config)(struct wiphy *wiphy, | ||
1936 | struct net_device *dev, | ||
1937 | u32 rate, u32 pkts, u32 intvl); | ||
1938 | |||
1939 | void (*mgmt_frame_register)(struct wiphy *wiphy, | 1523 | void (*mgmt_frame_register)(struct wiphy *wiphy, |
1940 | struct wireless_dev *wdev, | 1524 | struct net_device *dev, |
1941 | u16 frame_type, bool reg); | 1525 | u16 frame_type, bool reg); |
1942 | 1526 | ||
1943 | int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant); | 1527 | int (*set_antenna)(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant); |
@@ -1954,35 +1538,6 @@ struct cfg80211_ops { | |||
1954 | 1538 | ||
1955 | int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev, | 1539 | int (*set_rekey_data)(struct wiphy *wiphy, struct net_device *dev, |
1956 | struct cfg80211_gtk_rekey_data *data); | 1540 | struct cfg80211_gtk_rekey_data *data); |
1957 | |||
1958 | int (*tdls_mgmt)(struct wiphy *wiphy, struct net_device *dev, | ||
1959 | u8 *peer, u8 action_code, u8 dialog_token, | ||
1960 | u16 status_code, const u8 *buf, size_t len); | ||
1961 | int (*tdls_oper)(struct wiphy *wiphy, struct net_device *dev, | ||
1962 | u8 *peer, enum nl80211_tdls_operation oper); | ||
1963 | |||
1964 | int (*probe_client)(struct wiphy *wiphy, struct net_device *dev, | ||
1965 | const u8 *peer, u64 *cookie); | ||
1966 | |||
1967 | int (*set_noack_map)(struct wiphy *wiphy, | ||
1968 | struct net_device *dev, | ||
1969 | u16 noack_map); | ||
1970 | |||
1971 | int (*get_et_sset_count)(struct wiphy *wiphy, | ||
1972 | struct net_device *dev, int sset); | ||
1973 | void (*get_et_stats)(struct wiphy *wiphy, struct net_device *dev, | ||
1974 | struct ethtool_stats *stats, u64 *data); | ||
1975 | void (*get_et_strings)(struct wiphy *wiphy, struct net_device *dev, | ||
1976 | u32 sset, u8 *data); | ||
1977 | |||
1978 | int (*get_channel)(struct wiphy *wiphy, | ||
1979 | struct wireless_dev *wdev, | ||
1980 | struct cfg80211_chan_def *chandef); | ||
1981 | |||
1982 | int (*start_p2p_device)(struct wiphy *wiphy, | ||
1983 | struct wireless_dev *wdev); | ||
1984 | void (*stop_p2p_device)(struct wiphy *wiphy, | ||
1985 | struct wireless_dev *wdev); | ||
1986 | }; | 1541 | }; |
1987 | 1542 | ||
1988 | /* | 1543 | /* |
@@ -2007,15 +1562,17 @@ struct cfg80211_ops { | |||
2007 | * regulatory domain no user regulatory domain can enable these channels | 1562 | * regulatory domain no user regulatory domain can enable these channels |
2008 | * at a later time. This can be used for devices which do not have | 1563 | * at a later time. This can be used for devices which do not have |
2009 | * calibration information guaranteed for frequencies or settings | 1564 | * calibration information guaranteed for frequencies or settings |
2010 | * outside of its regulatory domain. If used in combination with | 1565 | * outside of its regulatory domain. |
2011 | * WIPHY_FLAG_CUSTOM_REGULATORY the inspected country IE power settings | ||
2012 | * will be followed. | ||
2013 | * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure | 1566 | * @WIPHY_FLAG_DISABLE_BEACON_HINTS: enable this if your driver needs to ensure |
2014 | * that passive scan flags and beaconing flags may not be lifted by | 1567 | * that passive scan flags and beaconing flags may not be lifted by |
2015 | * cfg80211 due to regulatory beacon hints. For more information on beacon | 1568 | * cfg80211 due to regulatory beacon hints. For more information on beacon |
2016 | * hints read the documenation for regulatory_hint_found_beacon() | 1569 | * hints read the documenation for regulatory_hint_found_beacon() |
2017 | * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this | 1570 | * @WIPHY_FLAG_NETNS_OK: if not set, do not allow changing the netns of this |
2018 | * wiphy at all | 1571 | * wiphy at all |
1572 | * @WIPHY_FLAG_ENFORCE_COMBINATIONS: Set this flag to enforce interface | ||
1573 | * combinations for this device. This flag is used for backward | ||
1574 | * compatibility only until all drivers advertise combinations and | ||
1575 | * they will always be enforced. | ||
2019 | * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled | 1576 | * @WIPHY_FLAG_PS_ON_BY_DEFAULT: if set to true, powersave will be enabled |
2020 | * by default -- this flag will be set depending on the kernel's default | 1577 | * by default -- this flag will be set depending on the kernel's default |
2021 | * on wiphy_new(), but can be changed by the driver if it has a good | 1578 | * on wiphy_new(), but can be changed by the driver if it has a good |
@@ -2030,23 +1587,6 @@ struct cfg80211_ops { | |||
2030 | * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing | 1587 | * @WIPHY_FLAG_MESH_AUTH: The device supports mesh authentication by routing |
2031 | * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH. | 1588 | * auth frames to userspace. See @NL80211_MESH_SETUP_USERSPACE_AUTH. |
2032 | * @WIPHY_FLAG_SUPPORTS_SCHED_SCAN: The device supports scheduled scans. | 1589 | * @WIPHY_FLAG_SUPPORTS_SCHED_SCAN: The device supports scheduled scans. |
2033 | * @WIPHY_FLAG_SUPPORTS_FW_ROAM: The device supports roaming feature in the | ||
2034 | * firmware. | ||
2035 | * @WIPHY_FLAG_AP_UAPSD: The device supports uapsd on AP. | ||
2036 | * @WIPHY_FLAG_SUPPORTS_TDLS: The device supports TDLS (802.11z) operation. | ||
2037 | * @WIPHY_FLAG_TDLS_EXTERNAL_SETUP: The device does not handle TDLS (802.11z) | ||
2038 | * link setup/discovery operations internally. Setup, discovery and | ||
2039 | * teardown packets should be sent through the @NL80211_CMD_TDLS_MGMT | ||
2040 | * command. When this flag is not set, @NL80211_CMD_TDLS_OPER should be | ||
2041 | * used for asking the driver/firmware to perform a TDLS operation. | ||
2042 | * @WIPHY_FLAG_HAVE_AP_SME: device integrates AP SME | ||
2043 | * @WIPHY_FLAG_REPORTS_OBSS: the device will report beacons from other BSSes | ||
2044 | * when there are virtual interfaces in AP mode by calling | ||
2045 | * cfg80211_report_obss_beacon(). | ||
2046 | * @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD: When operating as an AP, the device | ||
2047 | * responds to probe-requests in hardware. | ||
2048 | * @WIPHY_FLAG_OFFCHAN_TX: Device supports direct off-channel TX. | ||
2049 | * @WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL: Device supports remain-on-channel call. | ||
2050 | */ | 1590 | */ |
2051 | enum wiphy_flags { | 1591 | enum wiphy_flags { |
2052 | WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), | 1592 | WIPHY_FLAG_CUSTOM_REGULATORY = BIT(0), |
@@ -2060,16 +1600,7 @@ enum wiphy_flags { | |||
2060 | WIPHY_FLAG_IBSS_RSN = BIT(8), | 1600 | WIPHY_FLAG_IBSS_RSN = BIT(8), |
2061 | WIPHY_FLAG_MESH_AUTH = BIT(10), | 1601 | WIPHY_FLAG_MESH_AUTH = BIT(10), |
2062 | WIPHY_FLAG_SUPPORTS_SCHED_SCAN = BIT(11), | 1602 | WIPHY_FLAG_SUPPORTS_SCHED_SCAN = BIT(11), |
2063 | /* use hole at 12 */ | 1603 | WIPHY_FLAG_ENFORCE_COMBINATIONS = BIT(12), |
2064 | WIPHY_FLAG_SUPPORTS_FW_ROAM = BIT(13), | ||
2065 | WIPHY_FLAG_AP_UAPSD = BIT(14), | ||
2066 | WIPHY_FLAG_SUPPORTS_TDLS = BIT(15), | ||
2067 | WIPHY_FLAG_TDLS_EXTERNAL_SETUP = BIT(16), | ||
2068 | WIPHY_FLAG_HAVE_AP_SME = BIT(17), | ||
2069 | WIPHY_FLAG_REPORTS_OBSS = BIT(18), | ||
2070 | WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD = BIT(19), | ||
2071 | WIPHY_FLAG_OFFCHAN_TX = BIT(20), | ||
2072 | WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL = BIT(21), | ||
2073 | }; | 1604 | }; |
2074 | 1605 | ||
2075 | /** | 1606 | /** |
@@ -2231,7 +1762,6 @@ struct wiphy_wowlan_support { | |||
2231 | * @debugfsdir: debugfs directory used for this wiphy, will be renamed | 1762 | * @debugfsdir: debugfs directory used for this wiphy, will be renamed |
2232 | * automatically on wiphy renames | 1763 | * automatically on wiphy renames |
2233 | * @dev: (virtual) struct device for this wiphy | 1764 | * @dev: (virtual) struct device for this wiphy |
2234 | * @registered: helps synchronize suspend/resume with wiphy unregister | ||
2235 | * @wext: wireless extension handlers | 1765 | * @wext: wireless extension handlers |
2236 | * @priv: driver private data (sized according to wiphy_new() parameter) | 1766 | * @priv: driver private data (sized according to wiphy_new() parameter) |
2237 | * @interface_modes: bitmask of interfaces types valid for this wiphy, | 1767 | * @interface_modes: bitmask of interfaces types valid for this wiphy, |
@@ -2242,16 +1772,12 @@ struct wiphy_wowlan_support { | |||
2242 | * @software_iftypes: bitmask of software interface types, these are not | 1772 | * @software_iftypes: bitmask of software interface types, these are not |
2243 | * subject to any restrictions since they are purely managed in SW. | 1773 | * subject to any restrictions since they are purely managed in SW. |
2244 | * @flags: wiphy flags, see &enum wiphy_flags | 1774 | * @flags: wiphy flags, see &enum wiphy_flags |
2245 | * @features: features advertised to nl80211, see &enum nl80211_feature_flags. | ||
2246 | * @bss_priv_size: each BSS struct has private data allocated with it, | 1775 | * @bss_priv_size: each BSS struct has private data allocated with it, |
2247 | * this variable determines its size | 1776 | * this variable determines its size |
2248 | * @max_scan_ssids: maximum number of SSIDs the device can scan for in | 1777 | * @max_scan_ssids: maximum number of SSIDs the device can scan for in |
2249 | * any given scan | 1778 | * any given scan |
2250 | * @max_sched_scan_ssids: maximum number of SSIDs the device can scan | 1779 | * @max_sched_scan_ssids: maximum number of SSIDs the device can scan |
2251 | * for in any given scheduled scan | 1780 | * for in any given scheduled scan |
2252 | * @max_match_sets: maximum number of match sets the device can handle | ||
2253 | * when performing a scheduled scan, 0 if filtering is not | ||
2254 | * supported. | ||
2255 | * @max_scan_ie_len: maximum length of user-controlled IEs device can | 1781 | * @max_scan_ie_len: maximum length of user-controlled IEs device can |
2256 | * add to probe request frames transmitted during a scan, must not | 1782 | * add to probe request frames transmitted during a scan, must not |
2257 | * include fixed IEs like supported rates | 1783 | * include fixed IEs like supported rates |
@@ -2277,19 +1803,10 @@ struct wiphy_wowlan_support { | |||
2277 | * configured as RX antennas. Antenna configuration commands will be | 1803 | * configured as RX antennas. Antenna configuration commands will be |
2278 | * rejected unless this or @available_antennas_tx is set. | 1804 | * rejected unless this or @available_antennas_tx is set. |
2279 | * | 1805 | * |
2280 | * @probe_resp_offload: | ||
2281 | * Bitmap of supported protocols for probe response offloading. | ||
2282 | * See &enum nl80211_probe_resp_offload_support_attr. Only valid | ||
2283 | * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set. | ||
2284 | * | ||
2285 | * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation | 1806 | * @max_remain_on_channel_duration: Maximum time a remain-on-channel operation |
2286 | * may request, if implemented. | 1807 | * may request, if implemented. |
2287 | * | 1808 | * |
2288 | * @wowlan: WoWLAN support information | 1809 | * @wowlan: WoWLAN support information |
2289 | * | ||
2290 | * @ap_sme_capa: AP SME capabilities, flags from &enum nl80211_ap_sme_features. | ||
2291 | * @ht_capa_mod_mask: Specify what ht_cap values can be over-ridden. | ||
2292 | * If null, then none can be over-ridden. | ||
2293 | */ | 1810 | */ |
2294 | struct wiphy { | 1811 | struct wiphy { |
2295 | /* assign these fields before you register the wiphy */ | 1812 | /* assign these fields before you register the wiphy */ |
@@ -2311,16 +1828,13 @@ struct wiphy { | |||
2311 | /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ | 1828 | /* Supported interface modes, OR together BIT(NL80211_IFTYPE_...) */ |
2312 | u16 interface_modes; | 1829 | u16 interface_modes; |
2313 | 1830 | ||
2314 | u32 flags, features; | 1831 | u32 flags; |
2315 | |||
2316 | u32 ap_sme_capa; | ||
2317 | 1832 | ||
2318 | enum cfg80211_signal_type signal_type; | 1833 | enum cfg80211_signal_type signal_type; |
2319 | 1834 | ||
2320 | int bss_priv_size; | 1835 | int bss_priv_size; |
2321 | u8 max_scan_ssids; | 1836 | u8 max_scan_ssids; |
2322 | u8 max_sched_scan_ssids; | 1837 | u8 max_sched_scan_ssids; |
2323 | u8 max_match_sets; | ||
2324 | u16 max_scan_ie_len; | 1838 | u16 max_scan_ie_len; |
2325 | u16 max_sched_scan_ie_len; | 1839 | u16 max_sched_scan_ie_len; |
2326 | 1840 | ||
@@ -2336,9 +1850,7 @@ struct wiphy { | |||
2336 | char fw_version[ETHTOOL_BUSINFO_LEN]; | 1850 | char fw_version[ETHTOOL_BUSINFO_LEN]; |
2337 | u32 hw_version; | 1851 | u32 hw_version; |
2338 | 1852 | ||
2339 | #ifdef CONFIG_PM | ||
2340 | struct wiphy_wowlan_support wowlan; | 1853 | struct wiphy_wowlan_support wowlan; |
2341 | #endif | ||
2342 | 1854 | ||
2343 | u16 max_remain_on_channel_duration; | 1855 | u16 max_remain_on_channel_duration; |
2344 | 1856 | ||
@@ -2347,13 +1859,6 @@ struct wiphy { | |||
2347 | u32 available_antennas_tx; | 1859 | u32 available_antennas_tx; |
2348 | u32 available_antennas_rx; | 1860 | u32 available_antennas_rx; |
2349 | 1861 | ||
2350 | /* | ||
2351 | * Bitmap of supported protocols for probe response offloading | ||
2352 | * see &enum nl80211_probe_resp_offload_support_attr. Only valid | ||
2353 | * when the wiphy flag @WIPHY_FLAG_AP_PROBE_RESP_OFFLOAD is set. | ||
2354 | */ | ||
2355 | u32 probe_resp_offload; | ||
2356 | |||
2357 | /* If multiple wiphys are registered and you're handed e.g. | 1862 | /* If multiple wiphys are registered and you're handed e.g. |
2358 | * a regular netdev with assigned ieee80211_ptr, you won't | 1863 | * a regular netdev with assigned ieee80211_ptr, you won't |
2359 | * know whether it points to a wiphy your driver has registered | 1864 | * know whether it points to a wiphy your driver has registered |
@@ -2381,8 +1886,6 @@ struct wiphy { | |||
2381 | /* dir in debugfs: ieee80211/<wiphyname> */ | 1886 | /* dir in debugfs: ieee80211/<wiphyname> */ |
2382 | struct dentry *debugfsdir; | 1887 | struct dentry *debugfsdir; |
2383 | 1888 | ||
2384 | const struct ieee80211_ht_cap *ht_capa_mod_mask; | ||
2385 | |||
2386 | #ifdef CONFIG_NET_NS | 1889 | #ifdef CONFIG_NET_NS |
2387 | /* the network namespace this phy lives in currently */ | 1890 | /* the network namespace this phy lives in currently */ |
2388 | struct net *_net; | 1891 | struct net *_net; |
@@ -2504,32 +2007,23 @@ struct cfg80211_conn; | |||
2504 | struct cfg80211_internal_bss; | 2007 | struct cfg80211_internal_bss; |
2505 | struct cfg80211_cached_keys; | 2008 | struct cfg80211_cached_keys; |
2506 | 2009 | ||
2010 | #define MAX_AUTH_BSSES 4 | ||
2011 | |||
2507 | /** | 2012 | /** |
2508 | * struct wireless_dev - wireless device state | 2013 | * struct wireless_dev - wireless per-netdev state |
2509 | * | 2014 | * |
2510 | * For netdevs, this structure must be allocated by the driver | 2015 | * This structure must be allocated by the driver/stack |
2511 | * that uses the ieee80211_ptr field in struct net_device (this | 2016 | * that uses the ieee80211_ptr field in struct net_device |
2512 | * is intentional so it can be allocated along with the netdev.) | 2017 | * (this is intentional so it can be allocated along with |
2513 | * It need not be registered then as netdev registration will | 2018 | * the netdev.) |
2514 | * be intercepted by cfg80211 to see the new wireless device. | ||
2515 | * | ||
2516 | * For non-netdev uses, it must also be allocated by the driver | ||
2517 | * in response to the cfg80211 callbacks that require it, as | ||
2518 | * there's no netdev registration in that case it may not be | ||
2519 | * allocated outside of callback operations that return it. | ||
2520 | * | 2019 | * |
2521 | * @wiphy: pointer to hardware description | 2020 | * @wiphy: pointer to hardware description |
2522 | * @iftype: interface type | 2021 | * @iftype: interface type |
2523 | * @list: (private) Used to collect the interfaces | 2022 | * @list: (private) Used to collect the interfaces |
2524 | * @netdev: (private) Used to reference back to the netdev, may be %NULL | 2023 | * @netdev: (private) Used to reference back to the netdev |
2525 | * @identifier: (private) Identifier used in nl80211 to identify this | ||
2526 | * wireless device if it has no netdev | ||
2527 | * @current_bss: (private) Used by the internal configuration code | 2024 | * @current_bss: (private) Used by the internal configuration code |
2528 | * @channel: (private) Used by the internal configuration code to track | 2025 | * @channel: (private) Used by the internal configuration code to track |
2529 | * the user-set AP, monitor and WDS channel | 2026 | * user-set AP, monitor and WDS channels for wireless extensions |
2530 | * @preset_chan: (private) Used by the internal configuration code to | ||
2531 | * track the channel to be used for AP later | ||
2532 | * @preset_chantype: (private) the corresponding channel type | ||
2533 | * @bssid: (private) Used by the internal configuration code | 2027 | * @bssid: (private) Used by the internal configuration code |
2534 | * @ssid: (private) Used by the internal configuration code | 2028 | * @ssid: (private) Used by the internal configuration code |
2535 | * @ssid_len: (private) Used by the internal configuration code | 2029 | * @ssid_len: (private) Used by the internal configuration code |
@@ -2546,8 +2040,6 @@ struct cfg80211_cached_keys; | |||
2546 | * @cleanup_work: work struct used for cleanup that can't be done directly | 2040 | * @cleanup_work: work struct used for cleanup that can't be done directly |
2547 | * @beacon_interval: beacon interval used on this device for transmitting | 2041 | * @beacon_interval: beacon interval used on this device for transmitting |
2548 | * beacons, 0 when not valid | 2042 | * beacons, 0 when not valid |
2549 | * @address: The address for this device, valid only if @netdev is %NULL | ||
2550 | * @p2p_started: true if this is a P2P Device that has been started | ||
2551 | */ | 2043 | */ |
2552 | struct wireless_dev { | 2044 | struct wireless_dev { |
2553 | struct wiphy *wiphy; | 2045 | struct wiphy *wiphy; |
@@ -2557,8 +2049,6 @@ struct wireless_dev { | |||
2557 | struct list_head list; | 2049 | struct list_head list; |
2558 | struct net_device *netdev; | 2050 | struct net_device *netdev; |
2559 | 2051 | ||
2560 | u32 identifier; | ||
2561 | |||
2562 | struct list_head mgmt_registrations; | 2052 | struct list_head mgmt_registrations; |
2563 | spinlock_t mgmt_registrations_lock; | 2053 | spinlock_t mgmt_registrations_lock; |
2564 | 2054 | ||
@@ -2566,9 +2056,7 @@ struct wireless_dev { | |||
2566 | 2056 | ||
2567 | struct work_struct cleanup_work; | 2057 | struct work_struct cleanup_work; |
2568 | 2058 | ||
2569 | bool use_4addr, p2p_started; | 2059 | bool use_4addr; |
2570 | |||
2571 | u8 address[ETH_ALEN] __aligned(sizeof(u16)); | ||
2572 | 2060 | ||
2573 | /* currently used for IBSS and SME - might be rearranged later */ | 2061 | /* currently used for IBSS and SME - might be rearranged later */ |
2574 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | 2062 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
@@ -2584,21 +2072,16 @@ struct wireless_dev { | |||
2584 | struct list_head event_list; | 2072 | struct list_head event_list; |
2585 | spinlock_t event_lock; | 2073 | spinlock_t event_lock; |
2586 | 2074 | ||
2075 | struct cfg80211_internal_bss *authtry_bsses[MAX_AUTH_BSSES]; | ||
2076 | struct cfg80211_internal_bss *auth_bsses[MAX_AUTH_BSSES]; | ||
2587 | struct cfg80211_internal_bss *current_bss; /* associated / joined */ | 2077 | struct cfg80211_internal_bss *current_bss; /* associated / joined */ |
2588 | struct cfg80211_chan_def preset_chandef; | ||
2589 | |||
2590 | /* for AP and mesh channel tracking */ | ||
2591 | struct ieee80211_channel *channel; | 2078 | struct ieee80211_channel *channel; |
2592 | 2079 | ||
2593 | bool ibss_fixed; | ||
2594 | |||
2595 | bool ps; | 2080 | bool ps; |
2596 | int ps_timeout; | 2081 | int ps_timeout; |
2597 | 2082 | ||
2598 | int beacon_interval; | 2083 | int beacon_interval; |
2599 | 2084 | ||
2600 | u32 ap_unexpected_nlportid; | ||
2601 | |||
2602 | #ifdef CONFIG_CFG80211_WEXT | 2085 | #ifdef CONFIG_CFG80211_WEXT |
2603 | /* wext data */ | 2086 | /* wext data */ |
2604 | struct { | 2087 | struct { |
@@ -2615,13 +2098,6 @@ struct wireless_dev { | |||
2615 | #endif | 2098 | #endif |
2616 | }; | 2099 | }; |
2617 | 2100 | ||
2618 | static inline u8 *wdev_address(struct wireless_dev *wdev) | ||
2619 | { | ||
2620 | if (wdev->netdev) | ||
2621 | return wdev->netdev->dev_addr; | ||
2622 | return wdev->address; | ||
2623 | } | ||
2624 | |||
2625 | /** | 2101 | /** |
2626 | * wdev_priv - return wiphy priv from wireless_dev | 2102 | * wdev_priv - return wiphy priv from wireless_dev |
2627 | * | 2103 | * |
@@ -2791,15 +2267,6 @@ unsigned int ieee80211_get_hdrlen_from_skb(const struct sk_buff *skb); | |||
2791 | unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc); | 2267 | unsigned int __attribute_const__ ieee80211_hdrlen(__le16 fc); |
2792 | 2268 | ||
2793 | /** | 2269 | /** |
2794 | * ieee80211_get_mesh_hdrlen - get mesh extension header length | ||
2795 | * @meshhdr: the mesh extension header, only the flags field | ||
2796 | * (first byte) will be accessed | ||
2797 | * Returns the length of the extension header, which is always at | ||
2798 | * least 6 bytes and at most 18 if address 5 and 6 are present. | ||
2799 | */ | ||
2800 | unsigned int ieee80211_get_mesh_hdrlen(struct ieee80211s_hdr *meshhdr); | ||
2801 | |||
2802 | /** | ||
2803 | * DOC: Data path helpers | 2270 | * DOC: Data path helpers |
2804 | * | 2271 | * |
2805 | * In addition to generic utilities, cfg80211 also offers | 2272 | * In addition to generic utilities, cfg80211 also offers |
@@ -2870,24 +2337,6 @@ unsigned int cfg80211_classify8021d(struct sk_buff *skb); | |||
2870 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len); | 2337 | const u8 *cfg80211_find_ie(u8 eid, const u8 *ies, int len); |
2871 | 2338 | ||
2872 | /** | 2339 | /** |
2873 | * cfg80211_find_vendor_ie - find vendor specific information element in data | ||
2874 | * | ||
2875 | * @oui: vendor OUI | ||
2876 | * @oui_type: vendor-specific OUI type | ||
2877 | * @ies: data consisting of IEs | ||
2878 | * @len: length of data | ||
2879 | * | ||
2880 | * This function will return %NULL if the vendor specific element ID | ||
2881 | * could not be found or if the element is invalid (claims to be | ||
2882 | * longer than the given data), or a pointer to the first byte | ||
2883 | * of the requested element, that is the byte containing the | ||
2884 | * element ID. There are no checks on the element length | ||
2885 | * other than having to fit into the given data. | ||
2886 | */ | ||
2887 | const u8 *cfg80211_find_vendor_ie(unsigned int oui, u8 oui_type, | ||
2888 | const u8 *ies, int len); | ||
2889 | |||
2890 | /** | ||
2891 | * DOC: Regulatory enforcement infrastructure | 2340 | * DOC: Regulatory enforcement infrastructure |
2892 | * | 2341 | * |
2893 | * TODO | 2342 | * TODO |
@@ -2962,6 +2411,113 @@ extern int freq_reg_info(struct wiphy *wiphy, | |||
2962 | const struct ieee80211_reg_rule **reg_rule); | 2411 | const struct ieee80211_reg_rule **reg_rule); |
2963 | 2412 | ||
2964 | /* | 2413 | /* |
2414 | * Temporary wext handlers & helper functions | ||
2415 | * | ||
2416 | * In the future cfg80211 will simply assign the entire wext handler | ||
2417 | * structure to netdevs it manages, but we're not there yet. | ||
2418 | */ | ||
2419 | int cfg80211_wext_giwname(struct net_device *dev, | ||
2420 | struct iw_request_info *info, | ||
2421 | char *name, char *extra); | ||
2422 | int cfg80211_wext_siwmode(struct net_device *dev, struct iw_request_info *info, | ||
2423 | u32 *mode, char *extra); | ||
2424 | int cfg80211_wext_giwmode(struct net_device *dev, struct iw_request_info *info, | ||
2425 | u32 *mode, char *extra); | ||
2426 | int cfg80211_wext_siwscan(struct net_device *dev, | ||
2427 | struct iw_request_info *info, | ||
2428 | union iwreq_data *wrqu, char *extra); | ||
2429 | int cfg80211_wext_giwscan(struct net_device *dev, | ||
2430 | struct iw_request_info *info, | ||
2431 | struct iw_point *data, char *extra); | ||
2432 | int cfg80211_wext_siwmlme(struct net_device *dev, | ||
2433 | struct iw_request_info *info, | ||
2434 | struct iw_point *data, char *extra); | ||
2435 | int cfg80211_wext_giwrange(struct net_device *dev, | ||
2436 | struct iw_request_info *info, | ||
2437 | struct iw_point *data, char *extra); | ||
2438 | int cfg80211_wext_siwgenie(struct net_device *dev, | ||
2439 | struct iw_request_info *info, | ||
2440 | struct iw_point *data, char *extra); | ||
2441 | int cfg80211_wext_siwauth(struct net_device *dev, | ||
2442 | struct iw_request_info *info, | ||
2443 | struct iw_param *data, char *extra); | ||
2444 | int cfg80211_wext_giwauth(struct net_device *dev, | ||
2445 | struct iw_request_info *info, | ||
2446 | struct iw_param *data, char *extra); | ||
2447 | |||
2448 | int cfg80211_wext_siwfreq(struct net_device *dev, | ||
2449 | struct iw_request_info *info, | ||
2450 | struct iw_freq *freq, char *extra); | ||
2451 | int cfg80211_wext_giwfreq(struct net_device *dev, | ||
2452 | struct iw_request_info *info, | ||
2453 | struct iw_freq *freq, char *extra); | ||
2454 | int cfg80211_wext_siwessid(struct net_device *dev, | ||
2455 | struct iw_request_info *info, | ||
2456 | struct iw_point *data, char *ssid); | ||
2457 | int cfg80211_wext_giwessid(struct net_device *dev, | ||
2458 | struct iw_request_info *info, | ||
2459 | struct iw_point *data, char *ssid); | ||
2460 | int cfg80211_wext_siwrate(struct net_device *dev, | ||
2461 | struct iw_request_info *info, | ||
2462 | struct iw_param *rate, char *extra); | ||
2463 | int cfg80211_wext_giwrate(struct net_device *dev, | ||
2464 | struct iw_request_info *info, | ||
2465 | struct iw_param *rate, char *extra); | ||
2466 | |||
2467 | int cfg80211_wext_siwrts(struct net_device *dev, | ||
2468 | struct iw_request_info *info, | ||
2469 | struct iw_param *rts, char *extra); | ||
2470 | int cfg80211_wext_giwrts(struct net_device *dev, | ||
2471 | struct iw_request_info *info, | ||
2472 | struct iw_param *rts, char *extra); | ||
2473 | int cfg80211_wext_siwfrag(struct net_device *dev, | ||
2474 | struct iw_request_info *info, | ||
2475 | struct iw_param *frag, char *extra); | ||
2476 | int cfg80211_wext_giwfrag(struct net_device *dev, | ||
2477 | struct iw_request_info *info, | ||
2478 | struct iw_param *frag, char *extra); | ||
2479 | int cfg80211_wext_siwretry(struct net_device *dev, | ||
2480 | struct iw_request_info *info, | ||
2481 | struct iw_param *retry, char *extra); | ||
2482 | int cfg80211_wext_giwretry(struct net_device *dev, | ||
2483 | struct iw_request_info *info, | ||
2484 | struct iw_param *retry, char *extra); | ||
2485 | int cfg80211_wext_siwencodeext(struct net_device *dev, | ||
2486 | struct iw_request_info *info, | ||
2487 | struct iw_point *erq, char *extra); | ||
2488 | int cfg80211_wext_siwencode(struct net_device *dev, | ||
2489 | struct iw_request_info *info, | ||
2490 | struct iw_point *erq, char *keybuf); | ||
2491 | int cfg80211_wext_giwencode(struct net_device *dev, | ||
2492 | struct iw_request_info *info, | ||
2493 | struct iw_point *erq, char *keybuf); | ||
2494 | int cfg80211_wext_siwtxpower(struct net_device *dev, | ||
2495 | struct iw_request_info *info, | ||
2496 | union iwreq_data *data, char *keybuf); | ||
2497 | int cfg80211_wext_giwtxpower(struct net_device *dev, | ||
2498 | struct iw_request_info *info, | ||
2499 | union iwreq_data *data, char *keybuf); | ||
2500 | struct iw_statistics *cfg80211_wireless_stats(struct net_device *dev); | ||
2501 | |||
2502 | int cfg80211_wext_siwpower(struct net_device *dev, | ||
2503 | struct iw_request_info *info, | ||
2504 | struct iw_param *wrq, char *extra); | ||
2505 | int cfg80211_wext_giwpower(struct net_device *dev, | ||
2506 | struct iw_request_info *info, | ||
2507 | struct iw_param *wrq, char *extra); | ||
2508 | |||
2509 | int cfg80211_wext_siwap(struct net_device *dev, | ||
2510 | struct iw_request_info *info, | ||
2511 | struct sockaddr *ap_addr, char *extra); | ||
2512 | int cfg80211_wext_giwap(struct net_device *dev, | ||
2513 | struct iw_request_info *info, | ||
2514 | struct sockaddr *ap_addr, char *extra); | ||
2515 | |||
2516 | int cfg80211_wext_siwpmksa(struct net_device *dev, | ||
2517 | struct iw_request_info *info, | ||
2518 | struct iw_point *data, char *extra); | ||
2519 | |||
2520 | /* | ||
2965 | * callbacks for asynchronous cfg80211 methods, notification | 2521 | * callbacks for asynchronous cfg80211 methods, notification |
2966 | * functions and BSS handling helpers | 2522 | * functions and BSS handling helpers |
2967 | */ | 2523 | */ |
@@ -3005,10 +2561,8 @@ void cfg80211_sched_scan_stopped(struct wiphy *wiphy); | |||
3005 | * | 2561 | * |
3006 | * This informs cfg80211 that BSS information was found and | 2562 | * This informs cfg80211 that BSS information was found and |
3007 | * the BSS should be updated/added. | 2563 | * the BSS should be updated/added. |
3008 | * | ||
3009 | * NOTE: Returns a referenced struct, must be released with cfg80211_put_bss()! | ||
3010 | */ | 2564 | */ |
3011 | struct cfg80211_bss * __must_check | 2565 | struct cfg80211_bss* |
3012 | cfg80211_inform_bss_frame(struct wiphy *wiphy, | 2566 | cfg80211_inform_bss_frame(struct wiphy *wiphy, |
3013 | struct ieee80211_channel *channel, | 2567 | struct ieee80211_channel *channel, |
3014 | struct ieee80211_mgmt *mgmt, size_t len, | 2568 | struct ieee80211_mgmt *mgmt, size_t len, |
@@ -3020,7 +2574,7 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, | |||
3020 | * @wiphy: the wiphy reporting the BSS | 2574 | * @wiphy: the wiphy reporting the BSS |
3021 | * @channel: The channel the frame was received on | 2575 | * @channel: The channel the frame was received on |
3022 | * @bssid: the BSSID of the BSS | 2576 | * @bssid: the BSSID of the BSS |
3023 | * @tsf: the TSF sent by the peer in the beacon/probe response (or 0) | 2577 | * @timestamp: the TSF timestamp sent by the peer |
3024 | * @capability: the capability field sent by the peer | 2578 | * @capability: the capability field sent by the peer |
3025 | * @beacon_interval: the beacon interval announced by the peer | 2579 | * @beacon_interval: the beacon interval announced by the peer |
3026 | * @ie: additional IEs sent by the peer | 2580 | * @ie: additional IEs sent by the peer |
@@ -3030,14 +2584,13 @@ cfg80211_inform_bss_frame(struct wiphy *wiphy, | |||
3030 | * | 2584 | * |
3031 | * This informs cfg80211 that BSS information was found and | 2585 | * This informs cfg80211 that BSS information was found and |
3032 | * the BSS should be updated/added. | 2586 | * the BSS should be updated/added. |
3033 | * | ||
3034 | * NOTE: Returns a referenced struct, must be released with cfg80211_put_bss()! | ||
3035 | */ | 2587 | */ |
3036 | struct cfg80211_bss * __must_check | 2588 | struct cfg80211_bss* |
3037 | cfg80211_inform_bss(struct wiphy *wiphy, | 2589 | cfg80211_inform_bss(struct wiphy *wiphy, |
3038 | struct ieee80211_channel *channel, | 2590 | struct ieee80211_channel *channel, |
3039 | const u8 *bssid, u64 tsf, u16 capability, | 2591 | const u8 *bssid, |
3040 | u16 beacon_interval, const u8 *ie, size_t ielen, | 2592 | u64 timestamp, u16 capability, u16 beacon_interval, |
2593 | const u8 *ie, size_t ielen, | ||
3041 | s32 signal, gfp_t gfp); | 2594 | s32 signal, gfp_t gfp); |
3042 | 2595 | ||
3043 | struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, | 2596 | struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, |
@@ -3058,20 +2611,6 @@ struct cfg80211_bss *cfg80211_get_mesh(struct wiphy *wiphy, | |||
3058 | struct ieee80211_channel *channel, | 2611 | struct ieee80211_channel *channel, |
3059 | const u8 *meshid, size_t meshidlen, | 2612 | const u8 *meshid, size_t meshidlen, |
3060 | const u8 *meshcfg); | 2613 | const u8 *meshcfg); |
3061 | /** | ||
3062 | * cfg80211_ref_bss - reference BSS struct | ||
3063 | * @bss: the BSS struct to reference | ||
3064 | * | ||
3065 | * Increments the refcount of the given BSS struct. | ||
3066 | */ | ||
3067 | void cfg80211_ref_bss(struct cfg80211_bss *bss); | ||
3068 | |||
3069 | /** | ||
3070 | * cfg80211_put_bss - unref BSS struct | ||
3071 | * @bss: the BSS struct | ||
3072 | * | ||
3073 | * Decrements the refcount of the given BSS struct. | ||
3074 | */ | ||
3075 | void cfg80211_put_bss(struct cfg80211_bss *bss); | 2614 | void cfg80211_put_bss(struct cfg80211_bss *bss); |
3076 | 2615 | ||
3077 | /** | 2616 | /** |
@@ -3109,10 +2648,20 @@ void cfg80211_send_rx_auth(struct net_device *dev, const u8 *buf, size_t len); | |||
3109 | void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr); | 2648 | void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr); |
3110 | 2649 | ||
3111 | /** | 2650 | /** |
2651 | * __cfg80211_auth_canceled - notify cfg80211 that authentication was canceled | ||
2652 | * @dev: network device | ||
2653 | * @addr: The MAC address of the device with which the authentication timed out | ||
2654 | * | ||
2655 | * When a pending authentication had no action yet, the driver may decide | ||
2656 | * to not send a deauth frame, but in that case must calls this function | ||
2657 | * to tell cfg80211 about this decision. It is only valid to call this | ||
2658 | * function within the deauth() callback. | ||
2659 | */ | ||
2660 | void __cfg80211_auth_canceled(struct net_device *dev, const u8 *addr); | ||
2661 | |||
2662 | /** | ||
3112 | * cfg80211_send_rx_assoc - notification of processed association | 2663 | * cfg80211_send_rx_assoc - notification of processed association |
3113 | * @dev: network device | 2664 | * @dev: network device |
3114 | * @bss: the BSS struct association was requested for, the struct reference | ||
3115 | * is owned by cfg80211 after this call | ||
3116 | * @buf: (re)association response frame (header + body) | 2665 | * @buf: (re)association response frame (header + body) |
3117 | * @len: length of the frame data | 2666 | * @len: length of the frame data |
3118 | * | 2667 | * |
@@ -3121,8 +2670,7 @@ void cfg80211_send_auth_timeout(struct net_device *dev, const u8 *addr); | |||
3121 | * function or cfg80211_send_assoc_timeout() to indicate the result of | 2670 | * function or cfg80211_send_assoc_timeout() to indicate the result of |
3122 | * cfg80211_ops::assoc() call. This function may sleep. | 2671 | * cfg80211_ops::assoc() call. This function may sleep. |
3123 | */ | 2672 | */ |
3124 | void cfg80211_send_rx_assoc(struct net_device *dev, struct cfg80211_bss *bss, | 2673 | void cfg80211_send_rx_assoc(struct net_device *dev, const u8 *buf, size_t len); |
3125 | const u8 *buf, size_t len); | ||
3126 | 2674 | ||
3127 | /** | 2675 | /** |
3128 | * cfg80211_send_assoc_timeout - notification of timed out association | 2676 | * cfg80211_send_assoc_timeout - notification of timed out association |
@@ -3420,32 +2968,6 @@ void cfg80211_roamed(struct net_device *dev, | |||
3420 | const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp); | 2968 | const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp); |
3421 | 2969 | ||
3422 | /** | 2970 | /** |
3423 | * cfg80211_roamed_bss - notify cfg80211 of roaming | ||
3424 | * | ||
3425 | * @dev: network device | ||
3426 | * @bss: entry of bss to which STA got roamed | ||
3427 | * @req_ie: association request IEs (maybe be %NULL) | ||
3428 | * @req_ie_len: association request IEs length | ||
3429 | * @resp_ie: association response IEs (may be %NULL) | ||
3430 | * @resp_ie_len: assoc response IEs length | ||
3431 | * @gfp: allocation flags | ||
3432 | * | ||
3433 | * This is just a wrapper to notify cfg80211 of roaming event with driver | ||
3434 | * passing bss to avoid a race in timeout of the bss entry. It should be | ||
3435 | * called by the underlying driver whenever it roamed from one AP to another | ||
3436 | * while connected. Drivers which have roaming implemented in firmware | ||
3437 | * may use this function to avoid a race in bss entry timeout where the bss | ||
3438 | * entry of the new AP is seen in the driver, but gets timed out by the time | ||
3439 | * it is accessed in __cfg80211_roamed() due to delay in scheduling | ||
3440 | * rdev->event_work. In case of any failures, the reference is released | ||
3441 | * either in cfg80211_roamed_bss() or in __cfg80211_romed(), Otherwise, | ||
3442 | * it will be released while diconneting from the current bss. | ||
3443 | */ | ||
3444 | void cfg80211_roamed_bss(struct net_device *dev, struct cfg80211_bss *bss, | ||
3445 | const u8 *req_ie, size_t req_ie_len, | ||
3446 | const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp); | ||
3447 | |||
3448 | /** | ||
3449 | * cfg80211_disconnected - notify cfg80211 that connection was dropped | 2971 | * cfg80211_disconnected - notify cfg80211 that connection was dropped |
3450 | * | 2972 | * |
3451 | * @dev: network device | 2973 | * @dev: network device |
@@ -3462,26 +2984,31 @@ void cfg80211_disconnected(struct net_device *dev, u16 reason, | |||
3462 | 2984 | ||
3463 | /** | 2985 | /** |
3464 | * cfg80211_ready_on_channel - notification of remain_on_channel start | 2986 | * cfg80211_ready_on_channel - notification of remain_on_channel start |
3465 | * @wdev: wireless device | 2987 | * @dev: network device |
3466 | * @cookie: the request cookie | 2988 | * @cookie: the request cookie |
3467 | * @chan: The current channel (from remain_on_channel request) | 2989 | * @chan: The current channel (from remain_on_channel request) |
2990 | * @channel_type: Channel type | ||
3468 | * @duration: Duration in milliseconds that the driver intents to remain on the | 2991 | * @duration: Duration in milliseconds that the driver intents to remain on the |
3469 | * channel | 2992 | * channel |
3470 | * @gfp: allocation flags | 2993 | * @gfp: allocation flags |
3471 | */ | 2994 | */ |
3472 | void cfg80211_ready_on_channel(struct wireless_dev *wdev, u64 cookie, | 2995 | void cfg80211_ready_on_channel(struct net_device *dev, u64 cookie, |
3473 | struct ieee80211_channel *chan, | 2996 | struct ieee80211_channel *chan, |
2997 | enum nl80211_channel_type channel_type, | ||
3474 | unsigned int duration, gfp_t gfp); | 2998 | unsigned int duration, gfp_t gfp); |
3475 | 2999 | ||
3476 | /** | 3000 | /** |
3477 | * cfg80211_remain_on_channel_expired - remain_on_channel duration expired | 3001 | * cfg80211_remain_on_channel_expired - remain_on_channel duration expired |
3478 | * @wdev: wireless device | 3002 | * @dev: network device |
3479 | * @cookie: the request cookie | 3003 | * @cookie: the request cookie |
3480 | * @chan: The current channel (from remain_on_channel request) | 3004 | * @chan: The current channel (from remain_on_channel request) |
3005 | * @channel_type: Channel type | ||
3481 | * @gfp: allocation flags | 3006 | * @gfp: allocation flags |
3482 | */ | 3007 | */ |
3483 | void cfg80211_remain_on_channel_expired(struct wireless_dev *wdev, u64 cookie, | 3008 | void cfg80211_remain_on_channel_expired(struct net_device *dev, |
3009 | u64 cookie, | ||
3484 | struct ieee80211_channel *chan, | 3010 | struct ieee80211_channel *chan, |
3011 | enum nl80211_channel_type channel_type, | ||
3485 | gfp_t gfp); | 3012 | gfp_t gfp); |
3486 | 3013 | ||
3487 | 3014 | ||
@@ -3506,29 +3033,9 @@ void cfg80211_new_sta(struct net_device *dev, const u8 *mac_addr, | |||
3506 | void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp); | 3033 | void cfg80211_del_sta(struct net_device *dev, const u8 *mac_addr, gfp_t gfp); |
3507 | 3034 | ||
3508 | /** | 3035 | /** |
3509 | * cfg80211_conn_failed - connection request failed notification | ||
3510 | * | ||
3511 | * @dev: the netdev | ||
3512 | * @mac_addr: the station's address | ||
3513 | * @reason: the reason for connection failure | ||
3514 | * @gfp: allocation flags | ||
3515 | * | ||
3516 | * Whenever a station tries to connect to an AP and if the station | ||
3517 | * could not connect to the AP as the AP has rejected the connection | ||
3518 | * for some reasons, this function is called. | ||
3519 | * | ||
3520 | * The reason for connection failure can be any of the value from | ||
3521 | * nl80211_connect_failed_reason enum | ||
3522 | */ | ||
3523 | void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, | ||
3524 | enum nl80211_connect_failed_reason reason, | ||
3525 | gfp_t gfp); | ||
3526 | |||
3527 | /** | ||
3528 | * cfg80211_rx_mgmt - notification of received, unprocessed management frame | 3036 | * cfg80211_rx_mgmt - notification of received, unprocessed management frame |
3529 | * @wdev: wireless device receiving the frame | 3037 | * @dev: network device |
3530 | * @freq: Frequency on which the frame was received in MHz | 3038 | * @freq: Frequency on which the frame was received in MHz |
3531 | * @sig_dbm: signal strength in mBm, or 0 if unknown | ||
3532 | * @buf: Management frame (header + body) | 3039 | * @buf: Management frame (header + body) |
3533 | * @len: length of the frame data | 3040 | * @len: length of the frame data |
3534 | * @gfp: context flags | 3041 | * @gfp: context flags |
@@ -3541,12 +3048,12 @@ void cfg80211_conn_failed(struct net_device *dev, const u8 *mac_addr, | |||
3541 | * This function is called whenever an Action frame is received for a station | 3048 | * This function is called whenever an Action frame is received for a station |
3542 | * mode interface, but is not processed in kernel. | 3049 | * mode interface, but is not processed in kernel. |
3543 | */ | 3050 | */ |
3544 | bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm, | 3051 | bool cfg80211_rx_mgmt(struct net_device *dev, int freq, const u8 *buf, |
3545 | const u8 *buf, size_t len, gfp_t gfp); | 3052 | size_t len, gfp_t gfp); |
3546 | 3053 | ||
3547 | /** | 3054 | /** |
3548 | * cfg80211_mgmt_tx_status - notification of TX status for management frame | 3055 | * cfg80211_mgmt_tx_status - notification of TX status for management frame |
3549 | * @wdev: wireless device receiving the frame | 3056 | * @dev: network device |
3550 | * @cookie: Cookie returned by cfg80211_ops::mgmt_tx() | 3057 | * @cookie: Cookie returned by cfg80211_ops::mgmt_tx() |
3551 | * @buf: Management frame (header + body) | 3058 | * @buf: Management frame (header + body) |
3552 | * @len: length of the frame data | 3059 | * @len: length of the frame data |
@@ -3557,7 +3064,7 @@ bool cfg80211_rx_mgmt(struct wireless_dev *wdev, int freq, int sig_dbm, | |||
3557 | * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the | 3064 | * transmitted with cfg80211_ops::mgmt_tx() to report the TX status of the |
3558 | * transmission attempt. | 3065 | * transmission attempt. |
3559 | */ | 3066 | */ |
3560 | void cfg80211_mgmt_tx_status(struct wireless_dev *wdev, u64 cookie, | 3067 | void cfg80211_mgmt_tx_status(struct net_device *dev, u64 cookie, |
3561 | const u8 *buf, size_t len, bool ack, gfp_t gfp); | 3068 | const u8 *buf, size_t len, bool ack, gfp_t gfp); |
3562 | 3069 | ||
3563 | 3070 | ||
@@ -3587,21 +3094,6 @@ void cfg80211_cqm_pktloss_notify(struct net_device *dev, | |||
3587 | const u8 *peer, u32 num_packets, gfp_t gfp); | 3094 | const u8 *peer, u32 num_packets, gfp_t gfp); |
3588 | 3095 | ||
3589 | /** | 3096 | /** |
3590 | * cfg80211_cqm_txe_notify - TX error rate event | ||
3591 | * @dev: network device | ||
3592 | * @peer: peer's MAC address | ||
3593 | * @num_packets: how many packets were lost | ||
3594 | * @rate: % of packets which failed transmission | ||
3595 | * @intvl: interval (in s) over which the TX failure threshold was breached. | ||
3596 | * @gfp: context flags | ||
3597 | * | ||
3598 | * Notify userspace when configured % TX failures over number of packets in a | ||
3599 | * given interval is exceeded. | ||
3600 | */ | ||
3601 | void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer, | ||
3602 | u32 num_packets, u32 rate, u32 intvl, gfp_t gfp); | ||
3603 | |||
3604 | /** | ||
3605 | * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying | 3097 | * cfg80211_gtk_rekey_notify - notify userspace about driver rekeying |
3606 | * @dev: network device | 3098 | * @dev: network device |
3607 | * @bssid: BSSID of AP (to avoid races) | 3099 | * @bssid: BSSID of AP (to avoid races) |
@@ -3611,159 +3103,6 @@ void cfg80211_cqm_txe_notify(struct net_device *dev, const u8 *peer, | |||
3611 | void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, | 3103 | void cfg80211_gtk_rekey_notify(struct net_device *dev, const u8 *bssid, |
3612 | const u8 *replay_ctr, gfp_t gfp); | 3104 | const u8 *replay_ctr, gfp_t gfp); |
3613 | 3105 | ||
3614 | /** | ||
3615 | * cfg80211_pmksa_candidate_notify - notify about PMKSA caching candidate | ||
3616 | * @dev: network device | ||
3617 | * @index: candidate index (the smaller the index, the higher the priority) | ||
3618 | * @bssid: BSSID of AP | ||
3619 | * @preauth: Whether AP advertises support for RSN pre-authentication | ||
3620 | * @gfp: allocation flags | ||
3621 | */ | ||
3622 | void cfg80211_pmksa_candidate_notify(struct net_device *dev, int index, | ||
3623 | const u8 *bssid, bool preauth, gfp_t gfp); | ||
3624 | |||
3625 | /** | ||
3626 | * cfg80211_rx_spurious_frame - inform userspace about a spurious frame | ||
3627 | * @dev: The device the frame matched to | ||
3628 | * @addr: the transmitter address | ||
3629 | * @gfp: context flags | ||
3630 | * | ||
3631 | * This function is used in AP mode (only!) to inform userspace that | ||
3632 | * a spurious class 3 frame was received, to be able to deauth the | ||
3633 | * sender. | ||
3634 | * Returns %true if the frame was passed to userspace (or this failed | ||
3635 | * for a reason other than not having a subscription.) | ||
3636 | */ | ||
3637 | bool cfg80211_rx_spurious_frame(struct net_device *dev, | ||
3638 | const u8 *addr, gfp_t gfp); | ||
3639 | |||
3640 | /** | ||
3641 | * cfg80211_rx_unexpected_4addr_frame - inform about unexpected WDS frame | ||
3642 | * @dev: The device the frame matched to | ||
3643 | * @addr: the transmitter address | ||
3644 | * @gfp: context flags | ||
3645 | * | ||
3646 | * This function is used in AP mode (only!) to inform userspace that | ||
3647 | * an associated station sent a 4addr frame but that wasn't expected. | ||
3648 | * It is allowed and desirable to send this event only once for each | ||
3649 | * station to avoid event flooding. | ||
3650 | * Returns %true if the frame was passed to userspace (or this failed | ||
3651 | * for a reason other than not having a subscription.) | ||
3652 | */ | ||
3653 | bool cfg80211_rx_unexpected_4addr_frame(struct net_device *dev, | ||
3654 | const u8 *addr, gfp_t gfp); | ||
3655 | |||
3656 | /** | ||
3657 | * cfg80211_probe_status - notify userspace about probe status | ||
3658 | * @dev: the device the probe was sent on | ||
3659 | * @addr: the address of the peer | ||
3660 | * @cookie: the cookie filled in @probe_client previously | ||
3661 | * @acked: indicates whether probe was acked or not | ||
3662 | * @gfp: allocation flags | ||
3663 | */ | ||
3664 | void cfg80211_probe_status(struct net_device *dev, const u8 *addr, | ||
3665 | u64 cookie, bool acked, gfp_t gfp); | ||
3666 | |||
3667 | /** | ||
3668 | * cfg80211_report_obss_beacon - report beacon from other APs | ||
3669 | * @wiphy: The wiphy that received the beacon | ||
3670 | * @frame: the frame | ||
3671 | * @len: length of the frame | ||
3672 | * @freq: frequency the frame was received on | ||
3673 | * @sig_dbm: signal strength in mBm, or 0 if unknown | ||
3674 | * | ||
3675 | * Use this function to report to userspace when a beacon was | ||
3676 | * received. It is not useful to call this when there is no | ||
3677 | * netdev that is in AP/GO mode. | ||
3678 | */ | ||
3679 | void cfg80211_report_obss_beacon(struct wiphy *wiphy, | ||
3680 | const u8 *frame, size_t len, | ||
3681 | int freq, int sig_dbm); | ||
3682 | |||
3683 | /** | ||
3684 | * cfg80211_reg_can_beacon - check if beaconing is allowed | ||
3685 | * @wiphy: the wiphy | ||
3686 | * @chandef: the channel definition | ||
3687 | * | ||
3688 | * This function returns true if there is no secondary channel or the secondary | ||
3689 | * channel(s) can be used for beaconing (i.e. is not a radar channel etc.) | ||
3690 | */ | ||
3691 | bool cfg80211_reg_can_beacon(struct wiphy *wiphy, | ||
3692 | struct cfg80211_chan_def *chandef); | ||
3693 | |||
3694 | /* | ||
3695 | * cfg80211_ch_switch_notify - update wdev channel and notify userspace | ||
3696 | * @dev: the device which switched channels | ||
3697 | * @chandef: the new channel definition | ||
3698 | * | ||
3699 | * Acquires wdev_lock, so must only be called from sleepable driver context! | ||
3700 | */ | ||
3701 | void cfg80211_ch_switch_notify(struct net_device *dev, | ||
3702 | struct cfg80211_chan_def *chandef); | ||
3703 | |||
3704 | /* | ||
3705 | * cfg80211_tdls_oper_request - request userspace to perform TDLS operation | ||
3706 | * @dev: the device on which the operation is requested | ||
3707 | * @peer: the MAC address of the peer device | ||
3708 | * @oper: the requested TDLS operation (NL80211_TDLS_SETUP or | ||
3709 | * NL80211_TDLS_TEARDOWN) | ||
3710 | * @reason_code: the reason code for teardown request | ||
3711 | * @gfp: allocation flags | ||
3712 | * | ||
3713 | * This function is used to request userspace to perform TDLS operation that | ||
3714 | * requires knowledge of keys, i.e., link setup or teardown when the AP | ||
3715 | * connection uses encryption. This is optional mechanism for the driver to use | ||
3716 | * if it can automatically determine when a TDLS link could be useful (e.g., | ||
3717 | * based on traffic and signal strength for a peer). | ||
3718 | */ | ||
3719 | void cfg80211_tdls_oper_request(struct net_device *dev, const u8 *peer, | ||
3720 | enum nl80211_tdls_operation oper, | ||
3721 | u16 reason_code, gfp_t gfp); | ||
3722 | |||
3723 | /* | ||
3724 | * cfg80211_calculate_bitrate - calculate actual bitrate (in 100Kbps units) | ||
3725 | * @rate: given rate_info to calculate bitrate from | ||
3726 | * | ||
3727 | * return 0 if MCS index >= 32 | ||
3728 | */ | ||
3729 | u32 cfg80211_calculate_bitrate(struct rate_info *rate); | ||
3730 | |||
3731 | /** | ||
3732 | * cfg80211_unregister_wdev - remove the given wdev | ||
3733 | * @wdev: struct wireless_dev to remove | ||
3734 | * | ||
3735 | * Call this function only for wdevs that have no netdev assigned, | ||
3736 | * e.g. P2P Devices. It removes the device from the list so that | ||
3737 | * it can no longer be used. It is necessary to call this function | ||
3738 | * even when cfg80211 requests the removal of the interface by | ||
3739 | * calling the del_virtual_intf() callback. The function must also | ||
3740 | * be called when the driver wishes to unregister the wdev, e.g. | ||
3741 | * when the device is unbound from the driver. | ||
3742 | * | ||
3743 | * Requires the RTNL to be held. | ||
3744 | */ | ||
3745 | void cfg80211_unregister_wdev(struct wireless_dev *wdev); | ||
3746 | |||
3747 | /** | ||
3748 | * cfg80211_get_p2p_attr - find and copy a P2P attribute from IE buffer | ||
3749 | * @ies: the input IE buffer | ||
3750 | * @len: the input length | ||
3751 | * @attr: the attribute ID to find | ||
3752 | * @buf: output buffer, can be %NULL if the data isn't needed, e.g. | ||
3753 | * if the function is only called to get the needed buffer size | ||
3754 | * @bufsize: size of the output buffer | ||
3755 | * | ||
3756 | * The function finds a given P2P attribute in the (vendor) IEs and | ||
3757 | * copies its contents to the given buffer. | ||
3758 | * | ||
3759 | * The return value is a negative error code (-%EILSEQ or -%ENOENT) if | ||
3760 | * the data is malformed or the attribute can't be found (respectively), | ||
3761 | * or the length of the found attribute (which can be zero). | ||
3762 | */ | ||
3763 | int cfg80211_get_p2p_attr(const u8 *ies, unsigned int len, | ||
3764 | enum ieee80211_p2p_attr_id attr, | ||
3765 | u8 *buf, unsigned int bufsize); | ||
3766 | |||
3767 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ | 3106 | /* Logging, debugging and troubleshooting/diagnostic helpers. */ |
3768 | 3107 | ||
3769 | /* wiphy_printk helpers, similar to dev_printk */ | 3108 | /* wiphy_printk helpers, similar to dev_printk */ |
diff --git a/include/net/checksum.h b/include/net/checksum.h index 600d1d705bb..ba55d8b8c87 100644 --- a/include/net/checksum.h +++ b/include/net/checksum.h | |||
@@ -109,9 +109,6 @@ static inline void csum_replace2(__sum16 *sum, __be16 from, __be16 to) | |||
109 | struct sk_buff; | 109 | struct sk_buff; |
110 | extern void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, | 110 | extern void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, |
111 | __be32 from, __be32 to, int pseudohdr); | 111 | __be32 from, __be32 to, int pseudohdr); |
112 | extern void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, | ||
113 | const __be32 *from, const __be32 *to, | ||
114 | int pseudohdr); | ||
115 | 112 | ||
116 | static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb, | 113 | static inline void inet_proto_csum_replace2(__sum16 *sum, struct sk_buff *skb, |
117 | __be16 from, __be16 to, | 114 | __be16 from, __be16 to, |
diff --git a/include/net/cipso_ipv4.h b/include/net/cipso_ipv4.h index a7a683e30b6..9808877c2ab 100644 --- a/include/net/cipso_ipv4.h +++ b/include/net/cipso_ipv4.h | |||
@@ -42,7 +42,6 @@ | |||
42 | #include <net/netlabel.h> | 42 | #include <net/netlabel.h> |
43 | #include <net/request_sock.h> | 43 | #include <net/request_sock.h> |
44 | #include <linux/atomic.h> | 44 | #include <linux/atomic.h> |
45 | #include <asm/unaligned.h> | ||
46 | 45 | ||
47 | /* known doi values */ | 46 | /* known doi values */ |
48 | #define CIPSO_V4_DOI_UNKNOWN 0x00000000 | 47 | #define CIPSO_V4_DOI_UNKNOWN 0x00000000 |
@@ -286,33 +285,7 @@ static inline int cipso_v4_skbuff_getattr(const struct sk_buff *skb, | |||
286 | static inline int cipso_v4_validate(const struct sk_buff *skb, | 285 | static inline int cipso_v4_validate(const struct sk_buff *skb, |
287 | unsigned char **option) | 286 | unsigned char **option) |
288 | { | 287 | { |
289 | unsigned char *opt = *option; | 288 | return -ENOSYS; |
290 | unsigned char err_offset = 0; | ||
291 | u8 opt_len = opt[1]; | ||
292 | u8 opt_iter; | ||
293 | |||
294 | if (opt_len < 8) { | ||
295 | err_offset = 1; | ||
296 | goto out; | ||
297 | } | ||
298 | |||
299 | if (get_unaligned_be32(&opt[2]) == 0) { | ||
300 | err_offset = 2; | ||
301 | goto out; | ||
302 | } | ||
303 | |||
304 | for (opt_iter = 6; opt_iter < opt_len;) { | ||
305 | if (opt[opt_iter + 1] > (opt_len - opt_iter)) { | ||
306 | err_offset = opt_iter + 1; | ||
307 | goto out; | ||
308 | } | ||
309 | opt_iter += opt[opt_iter + 1]; | ||
310 | } | ||
311 | |||
312 | out: | ||
313 | *option = opt + err_offset; | ||
314 | return err_offset; | ||
315 | |||
316 | } | 289 | } |
317 | #endif /* CONFIG_NETLABEL */ | 290 | #endif /* CONFIG_NETLABEL */ |
318 | 291 | ||
diff --git a/include/net/cls_cgroup.h b/include/net/cls_cgroup.h index 2581638f4a3..a4dc5b027bd 100644 --- a/include/net/cls_cgroup.h +++ b/include/net/cls_cgroup.h | |||
@@ -17,19 +17,17 @@ | |||
17 | #include <linux/hardirq.h> | 17 | #include <linux/hardirq.h> |
18 | #include <linux/rcupdate.h> | 18 | #include <linux/rcupdate.h> |
19 | 19 | ||
20 | #if IS_ENABLED(CONFIG_NET_CLS_CGROUP) | 20 | #ifdef CONFIG_CGROUPS |
21 | struct cgroup_cls_state | 21 | struct cgroup_cls_state |
22 | { | 22 | { |
23 | struct cgroup_subsys_state css; | 23 | struct cgroup_subsys_state css; |
24 | u32 classid; | 24 | u32 classid; |
25 | }; | 25 | }; |
26 | 26 | ||
27 | extern void sock_update_classid(struct sock *sk, struct task_struct *task); | 27 | #ifdef CONFIG_NET_CLS_CGROUP |
28 | |||
29 | #if IS_BUILTIN(CONFIG_NET_CLS_CGROUP) | ||
30 | static inline u32 task_cls_classid(struct task_struct *p) | 28 | static inline u32 task_cls_classid(struct task_struct *p) |
31 | { | 29 | { |
32 | u32 classid; | 30 | int classid; |
33 | 31 | ||
34 | if (in_interrupt()) | 32 | if (in_interrupt()) |
35 | return 0; | 33 | return 0; |
@@ -41,33 +39,32 @@ static inline u32 task_cls_classid(struct task_struct *p) | |||
41 | 39 | ||
42 | return classid; | 40 | return classid; |
43 | } | 41 | } |
44 | #elif IS_MODULE(CONFIG_NET_CLS_CGROUP) | 42 | #else |
43 | extern int net_cls_subsys_id; | ||
44 | |||
45 | static inline u32 task_cls_classid(struct task_struct *p) | 45 | static inline u32 task_cls_classid(struct task_struct *p) |
46 | { | 46 | { |
47 | struct cgroup_subsys_state *css; | 47 | int id; |
48 | u32 classid = 0; | 48 | u32 classid = 0; |
49 | 49 | ||
50 | if (in_interrupt()) | 50 | if (in_interrupt()) |
51 | return 0; | 51 | return 0; |
52 | 52 | ||
53 | rcu_read_lock(); | 53 | rcu_read_lock(); |
54 | css = task_subsys_state(p, net_cls_subsys_id); | 54 | id = rcu_dereference_index_check(net_cls_subsys_id, |
55 | if (css) | 55 | rcu_read_lock_held()); |
56 | classid = container_of(css, | 56 | if (id >= 0) |
57 | classid = container_of(task_subsys_state(p, id), | ||
57 | struct cgroup_cls_state, css)->classid; | 58 | struct cgroup_cls_state, css)->classid; |
58 | rcu_read_unlock(); | 59 | rcu_read_unlock(); |
59 | 60 | ||
60 | return classid; | 61 | return classid; |
61 | } | 62 | } |
62 | #endif | 63 | #endif |
63 | #else /* !CGROUP_NET_CLS_CGROUP */ | 64 | #else |
64 | static inline void sock_update_classid(struct sock *sk, struct task_struct *task) | ||
65 | { | ||
66 | } | ||
67 | |||
68 | static inline u32 task_cls_classid(struct task_struct *p) | 65 | static inline u32 task_cls_classid(struct task_struct *p) |
69 | { | 66 | { |
70 | return 0; | 67 | return 0; |
71 | } | 68 | } |
72 | #endif /* CGROUP_NET_CLS_CGROUP */ | 69 | #endif |
73 | #endif /* _NET_CLS_CGROUP_H */ | 70 | #endif /* _NET_CLS_CGROUP_H */ |
diff --git a/include/net/codel.h b/include/net/codel.h deleted file mode 100644 index 389cf621161..00000000000 --- a/include/net/codel.h +++ /dev/null | |||
@@ -1,346 +0,0 @@ | |||
1 | #ifndef __NET_SCHED_CODEL_H | ||
2 | #define __NET_SCHED_CODEL_H | ||
3 | |||
4 | /* | ||
5 | * Codel - The Controlled-Delay Active Queue Management algorithm | ||
6 | * | ||
7 | * Copyright (C) 2011-2012 Kathleen Nichols <nichols@pollere.com> | ||
8 | * Copyright (C) 2011-2012 Van Jacobson <van@pollere.net> | ||
9 | * Copyright (C) 2012 Michael D. Taht <dave.taht@bufferbloat.net> | ||
10 | * Copyright (C) 2012 Eric Dumazet <edumazet@google.com> | ||
11 | * | ||
12 | * Redistribution and use in source and binary forms, with or without | ||
13 | * modification, are permitted provided that the following conditions | ||
14 | * are met: | ||
15 | * 1. Redistributions of source code must retain the above copyright | ||
16 | * notice, this list of conditions, and the following disclaimer, | ||
17 | * without modification. | ||
18 | * 2. Redistributions in binary form must reproduce the above copyright | ||
19 | * notice, this list of conditions and the following disclaimer in the | ||
20 | * documentation and/or other materials provided with the distribution. | ||
21 | * 3. The names of the authors may not be used to endorse or promote products | ||
22 | * derived from this software without specific prior written permission. | ||
23 | * | ||
24 | * Alternatively, provided that this notice is retained in full, this | ||
25 | * software may be distributed under the terms of the GNU General | ||
26 | * Public License ("GPL") version 2, in which case the provisions of the | ||
27 | * GPL apply INSTEAD OF those given above. | ||
28 | * | ||
29 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
30 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
31 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
32 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
33 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
34 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
35 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
36 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
37 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
38 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
39 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | ||
40 | * DAMAGE. | ||
41 | * | ||
42 | */ | ||
43 | |||
44 | #include <linux/types.h> | ||
45 | #include <linux/ktime.h> | ||
46 | #include <linux/skbuff.h> | ||
47 | #include <net/pkt_sched.h> | ||
48 | #include <net/inet_ecn.h> | ||
49 | #include <linux/reciprocal_div.h> | ||
50 | |||
51 | /* Controlling Queue Delay (CoDel) algorithm | ||
52 | * ========================================= | ||
53 | * Source : Kathleen Nichols and Van Jacobson | ||
54 | * http://queue.acm.org/detail.cfm?id=2209336 | ||
55 | * | ||
56 | * Implemented on linux by Dave Taht and Eric Dumazet | ||
57 | */ | ||
58 | |||
59 | |||
60 | /* CoDel uses a 1024 nsec clock, encoded in u32 | ||
61 | * This gives a range of 2199 seconds, because of signed compares | ||
62 | */ | ||
63 | typedef u32 codel_time_t; | ||
64 | typedef s32 codel_tdiff_t; | ||
65 | #define CODEL_SHIFT 10 | ||
66 | #define MS2TIME(a) ((a * NSEC_PER_MSEC) >> CODEL_SHIFT) | ||
67 | |||
68 | static inline codel_time_t codel_get_time(void) | ||
69 | { | ||
70 | u64 ns = ktime_to_ns(ktime_get()); | ||
71 | |||
72 | return ns >> CODEL_SHIFT; | ||
73 | } | ||
74 | |||
75 | #define codel_time_after(a, b) ((s32)(a) - (s32)(b) > 0) | ||
76 | #define codel_time_after_eq(a, b) ((s32)(a) - (s32)(b) >= 0) | ||
77 | #define codel_time_before(a, b) ((s32)(a) - (s32)(b) < 0) | ||
78 | #define codel_time_before_eq(a, b) ((s32)(a) - (s32)(b) <= 0) | ||
79 | |||
80 | /* Qdiscs using codel plugin must use codel_skb_cb in their own cb[] */ | ||
81 | struct codel_skb_cb { | ||
82 | codel_time_t enqueue_time; | ||
83 | }; | ||
84 | |||
85 | static struct codel_skb_cb *get_codel_cb(const struct sk_buff *skb) | ||
86 | { | ||
87 | qdisc_cb_private_validate(skb, sizeof(struct codel_skb_cb)); | ||
88 | return (struct codel_skb_cb *)qdisc_skb_cb(skb)->data; | ||
89 | } | ||
90 | |||
91 | static codel_time_t codel_get_enqueue_time(const struct sk_buff *skb) | ||
92 | { | ||
93 | return get_codel_cb(skb)->enqueue_time; | ||
94 | } | ||
95 | |||
96 | static void codel_set_enqueue_time(struct sk_buff *skb) | ||
97 | { | ||
98 | get_codel_cb(skb)->enqueue_time = codel_get_time(); | ||
99 | } | ||
100 | |||
101 | static inline u32 codel_time_to_us(codel_time_t val) | ||
102 | { | ||
103 | u64 valns = ((u64)val << CODEL_SHIFT); | ||
104 | |||
105 | do_div(valns, NSEC_PER_USEC); | ||
106 | return (u32)valns; | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * struct codel_params - contains codel parameters | ||
111 | * @target: target queue size (in time units) | ||
112 | * @interval: width of moving time window | ||
113 | * @ecn: is Explicit Congestion Notification enabled | ||
114 | */ | ||
115 | struct codel_params { | ||
116 | codel_time_t target; | ||
117 | codel_time_t interval; | ||
118 | bool ecn; | ||
119 | }; | ||
120 | |||
121 | /** | ||
122 | * struct codel_vars - contains codel variables | ||
123 | * @count: how many drops we've done since the last time we | ||
124 | * entered dropping state | ||
125 | * @lastcount: count at entry to dropping state | ||
126 | * @dropping: set to true if in dropping state | ||
127 | * @rec_inv_sqrt: reciprocal value of sqrt(count) >> 1 | ||
128 | * @first_above_time: when we went (or will go) continuously above target | ||
129 | * for interval | ||
130 | * @drop_next: time to drop next packet, or when we dropped last | ||
131 | * @ldelay: sojourn time of last dequeued packet | ||
132 | */ | ||
133 | struct codel_vars { | ||
134 | u32 count; | ||
135 | u32 lastcount; | ||
136 | bool dropping; | ||
137 | u16 rec_inv_sqrt; | ||
138 | codel_time_t first_above_time; | ||
139 | codel_time_t drop_next; | ||
140 | codel_time_t ldelay; | ||
141 | }; | ||
142 | |||
143 | #define REC_INV_SQRT_BITS (8 * sizeof(u16)) /* or sizeof_in_bits(rec_inv_sqrt) */ | ||
144 | /* needed shift to get a Q0.32 number from rec_inv_sqrt */ | ||
145 | #define REC_INV_SQRT_SHIFT (32 - REC_INV_SQRT_BITS) | ||
146 | |||
147 | /** | ||
148 | * struct codel_stats - contains codel shared variables and stats | ||
149 | * @maxpacket: largest packet we've seen so far | ||
150 | * @drop_count: temp count of dropped packets in dequeue() | ||
151 | * ecn_mark: number of packets we ECN marked instead of dropping | ||
152 | */ | ||
153 | struct codel_stats { | ||
154 | u32 maxpacket; | ||
155 | u32 drop_count; | ||
156 | u32 ecn_mark; | ||
157 | }; | ||
158 | |||
159 | static void codel_params_init(struct codel_params *params) | ||
160 | { | ||
161 | params->interval = MS2TIME(100); | ||
162 | params->target = MS2TIME(5); | ||
163 | params->ecn = false; | ||
164 | } | ||
165 | |||
166 | static void codel_vars_init(struct codel_vars *vars) | ||
167 | { | ||
168 | memset(vars, 0, sizeof(*vars)); | ||
169 | } | ||
170 | |||
171 | static void codel_stats_init(struct codel_stats *stats) | ||
172 | { | ||
173 | stats->maxpacket = 256; | ||
174 | } | ||
175 | |||
176 | /* | ||
177 | * http://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Iterative_methods_for_reciprocal_square_roots | ||
178 | * new_invsqrt = (invsqrt / 2) * (3 - count * invsqrt^2) | ||
179 | * | ||
180 | * Here, invsqrt is a fixed point number (< 1.0), 32bit mantissa, aka Q0.32 | ||
181 | */ | ||
182 | static void codel_Newton_step(struct codel_vars *vars) | ||
183 | { | ||
184 | u32 invsqrt = ((u32)vars->rec_inv_sqrt) << REC_INV_SQRT_SHIFT; | ||
185 | u32 invsqrt2 = ((u64)invsqrt * invsqrt) >> 32; | ||
186 | u64 val = (3LL << 32) - ((u64)vars->count * invsqrt2); | ||
187 | |||
188 | val >>= 2; /* avoid overflow in following multiply */ | ||
189 | val = (val * invsqrt) >> (32 - 2 + 1); | ||
190 | |||
191 | vars->rec_inv_sqrt = val >> REC_INV_SQRT_SHIFT; | ||
192 | } | ||
193 | |||
194 | /* | ||
195 | * CoDel control_law is t + interval/sqrt(count) | ||
196 | * We maintain in rec_inv_sqrt the reciprocal value of sqrt(count) to avoid | ||
197 | * both sqrt() and divide operation. | ||
198 | */ | ||
199 | static codel_time_t codel_control_law(codel_time_t t, | ||
200 | codel_time_t interval, | ||
201 | u32 rec_inv_sqrt) | ||
202 | { | ||
203 | return t + reciprocal_divide(interval, rec_inv_sqrt << REC_INV_SQRT_SHIFT); | ||
204 | } | ||
205 | |||
206 | |||
207 | static bool codel_should_drop(const struct sk_buff *skb, | ||
208 | struct Qdisc *sch, | ||
209 | struct codel_vars *vars, | ||
210 | struct codel_params *params, | ||
211 | struct codel_stats *stats, | ||
212 | codel_time_t now) | ||
213 | { | ||
214 | bool ok_to_drop; | ||
215 | |||
216 | if (!skb) { | ||
217 | vars->first_above_time = 0; | ||
218 | return false; | ||
219 | } | ||
220 | |||
221 | vars->ldelay = now - codel_get_enqueue_time(skb); | ||
222 | sch->qstats.backlog -= qdisc_pkt_len(skb); | ||
223 | |||
224 | if (unlikely(qdisc_pkt_len(skb) > stats->maxpacket)) | ||
225 | stats->maxpacket = qdisc_pkt_len(skb); | ||
226 | |||
227 | if (codel_time_before(vars->ldelay, params->target) || | ||
228 | sch->qstats.backlog <= stats->maxpacket) { | ||
229 | /* went below - stay below for at least interval */ | ||
230 | vars->first_above_time = 0; | ||
231 | return false; | ||
232 | } | ||
233 | ok_to_drop = false; | ||
234 | if (vars->first_above_time == 0) { | ||
235 | /* just went above from below. If we stay above | ||
236 | * for at least interval we'll say it's ok to drop | ||
237 | */ | ||
238 | vars->first_above_time = now + params->interval; | ||
239 | } else if (codel_time_after(now, vars->first_above_time)) { | ||
240 | ok_to_drop = true; | ||
241 | } | ||
242 | return ok_to_drop; | ||
243 | } | ||
244 | |||
245 | typedef struct sk_buff * (*codel_skb_dequeue_t)(struct codel_vars *vars, | ||
246 | struct Qdisc *sch); | ||
247 | |||
248 | static struct sk_buff *codel_dequeue(struct Qdisc *sch, | ||
249 | struct codel_params *params, | ||
250 | struct codel_vars *vars, | ||
251 | struct codel_stats *stats, | ||
252 | codel_skb_dequeue_t dequeue_func) | ||
253 | { | ||
254 | struct sk_buff *skb = dequeue_func(vars, sch); | ||
255 | codel_time_t now; | ||
256 | bool drop; | ||
257 | |||
258 | if (!skb) { | ||
259 | vars->dropping = false; | ||
260 | return skb; | ||
261 | } | ||
262 | now = codel_get_time(); | ||
263 | drop = codel_should_drop(skb, sch, vars, params, stats, now); | ||
264 | if (vars->dropping) { | ||
265 | if (!drop) { | ||
266 | /* sojourn time below target - leave dropping state */ | ||
267 | vars->dropping = false; | ||
268 | } else if (codel_time_after_eq(now, vars->drop_next)) { | ||
269 | /* It's time for the next drop. Drop the current | ||
270 | * packet and dequeue the next. The dequeue might | ||
271 | * take us out of dropping state. | ||
272 | * If not, schedule the next drop. | ||
273 | * A large backlog might result in drop rates so high | ||
274 | * that the next drop should happen now, | ||
275 | * hence the while loop. | ||
276 | */ | ||
277 | while (vars->dropping && | ||
278 | codel_time_after_eq(now, vars->drop_next)) { | ||
279 | vars->count++; /* dont care of possible wrap | ||
280 | * since there is no more divide | ||
281 | */ | ||
282 | codel_Newton_step(vars); | ||
283 | if (params->ecn && INET_ECN_set_ce(skb)) { | ||
284 | stats->ecn_mark++; | ||
285 | vars->drop_next = | ||
286 | codel_control_law(vars->drop_next, | ||
287 | params->interval, | ||
288 | vars->rec_inv_sqrt); | ||
289 | goto end; | ||
290 | } | ||
291 | qdisc_drop(skb, sch); | ||
292 | stats->drop_count++; | ||
293 | skb = dequeue_func(vars, sch); | ||
294 | if (!codel_should_drop(skb, sch, | ||
295 | vars, params, stats, now)) { | ||
296 | /* leave dropping state */ | ||
297 | vars->dropping = false; | ||
298 | } else { | ||
299 | /* and schedule the next drop */ | ||
300 | vars->drop_next = | ||
301 | codel_control_law(vars->drop_next, | ||
302 | params->interval, | ||
303 | vars->rec_inv_sqrt); | ||
304 | } | ||
305 | } | ||
306 | } | ||
307 | } else if (drop) { | ||
308 | u32 delta; | ||
309 | |||
310 | if (params->ecn && INET_ECN_set_ce(skb)) { | ||
311 | stats->ecn_mark++; | ||
312 | } else { | ||
313 | qdisc_drop(skb, sch); | ||
314 | stats->drop_count++; | ||
315 | |||
316 | skb = dequeue_func(vars, sch); | ||
317 | drop = codel_should_drop(skb, sch, vars, params, | ||
318 | stats, now); | ||
319 | } | ||
320 | vars->dropping = true; | ||
321 | /* if min went above target close to when we last went below it | ||
322 | * assume that the drop rate that controlled the queue on the | ||
323 | * last cycle is a good starting point to control it now. | ||
324 | */ | ||
325 | delta = vars->count - vars->lastcount; | ||
326 | if (delta > 1 && | ||
327 | codel_time_before(now - vars->drop_next, | ||
328 | 16 * params->interval)) { | ||
329 | vars->count = delta; | ||
330 | /* we dont care if rec_inv_sqrt approximation | ||
331 | * is not very precise : | ||
332 | * Next Newton steps will correct it quadratically. | ||
333 | */ | ||
334 | codel_Newton_step(vars); | ||
335 | } else { | ||
336 | vars->count = 1; | ||
337 | vars->rec_inv_sqrt = ~0U >> REC_INV_SQRT_SHIFT; | ||
338 | } | ||
339 | vars->lastcount = vars->count; | ||
340 | vars->drop_next = codel_control_law(now, params->interval, | ||
341 | vars->rec_inv_sqrt); | ||
342 | } | ||
343 | end: | ||
344 | return skb; | ||
345 | } | ||
346 | #endif | ||
diff --git a/include/net/compat.h b/include/net/compat.h index 6e956532498..9ee75edcc29 100644 --- a/include/net/compat.h +++ b/include/net/compat.h | |||
@@ -41,13 +41,13 @@ extern int compat_sock_get_timestampns(struct sock *, struct timespec __user *); | |||
41 | #endif /* defined(CONFIG_COMPAT) */ | 41 | #endif /* defined(CONFIG_COMPAT) */ |
42 | 42 | ||
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_storage *, 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 int); | 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 *, | 46 | extern asmlinkage long compat_sys_sendmmsg(int, struct compat_mmsghdr __user *, |
47 | unsigned int, unsigned int); | 47 | unsigned, unsigned); |
48 | extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned int); | 48 | extern asmlinkage long compat_sys_recvmsg(int,struct compat_msghdr __user *,unsigned); |
49 | extern asmlinkage long compat_sys_recvmmsg(int, struct compat_mmsghdr __user *, | 49 | extern asmlinkage long compat_sys_recvmmsg(int, struct compat_mmsghdr __user *, |
50 | unsigned int, unsigned int, | 50 | unsigned, unsigned, |
51 | struct compat_timespec __user *); | 51 | struct compat_timespec __user *); |
52 | extern asmlinkage long compat_sys_getsockopt(int, int, int, char __user *, int __user *); | 52 | extern asmlinkage long compat_sys_getsockopt(int, int, int, char __user *, int __user *); |
53 | extern int put_cmsg_compat(struct msghdr*, int, int, int, void *); | 53 | extern int put_cmsg_compat(struct msghdr*, int, int, int, void *); |
diff --git a/include/net/dcbevent.h b/include/net/dcbevent.h index 443626ed4cb..bc1e7ef4017 100644 --- a/include/net/dcbevent.h +++ b/include/net/dcbevent.h | |||
@@ -24,26 +24,8 @@ enum dcbevent_notif_type { | |||
24 | DCB_APP_EVENT = 1, | 24 | DCB_APP_EVENT = 1, |
25 | }; | 25 | }; |
26 | 26 | ||
27 | #ifdef CONFIG_DCB | ||
28 | extern int register_dcbevent_notifier(struct notifier_block *nb); | 27 | extern int register_dcbevent_notifier(struct notifier_block *nb); |
29 | extern int unregister_dcbevent_notifier(struct notifier_block *nb); | 28 | extern int unregister_dcbevent_notifier(struct notifier_block *nb); |
30 | extern int call_dcbevent_notifiers(unsigned long val, void *v); | 29 | extern int call_dcbevent_notifiers(unsigned long val, void *v); |
31 | #else | ||
32 | static inline int | ||
33 | register_dcbevent_notifier(struct notifier_block *nb) | ||
34 | { | ||
35 | return 0; | ||
36 | } | ||
37 | |||
38 | static inline int unregister_dcbevent_notifier(struct notifier_block *nb) | ||
39 | { | ||
40 | return 0; | ||
41 | } | ||
42 | |||
43 | static inline int call_dcbevent_notifiers(unsigned long val, void *v) | ||
44 | { | ||
45 | return 0; | ||
46 | } | ||
47 | #endif /* CONFIG_DCB */ | ||
48 | 30 | ||
49 | #endif | 31 | #endif |
diff --git a/include/net/dcbnl.h b/include/net/dcbnl.h index fc5d5dcebb0..f5aa39997f0 100644 --- a/include/net/dcbnl.h +++ b/include/net/dcbnl.h | |||
@@ -23,10 +23,9 @@ | |||
23 | #include <linux/dcbnl.h> | 23 | #include <linux/dcbnl.h> |
24 | 24 | ||
25 | struct dcb_app_type { | 25 | struct dcb_app_type { |
26 | int ifindex; | 26 | char name[IFNAMSIZ]; |
27 | struct dcb_app app; | 27 | struct dcb_app app; |
28 | struct list_head list; | 28 | struct list_head list; |
29 | u8 dcbx; | ||
30 | }; | 29 | }; |
31 | 30 | ||
32 | int dcb_setapp(struct net_device *, struct dcb_app *); | 31 | int dcb_setapp(struct net_device *, struct dcb_app *); |
@@ -48,8 +47,6 @@ struct dcbnl_rtnl_ops { | |||
48 | /* IEEE 802.1Qaz std */ | 47 | /* IEEE 802.1Qaz std */ |
49 | int (*ieee_getets) (struct net_device *, struct ieee_ets *); | 48 | int (*ieee_getets) (struct net_device *, struct ieee_ets *); |
50 | int (*ieee_setets) (struct net_device *, struct ieee_ets *); | 49 | int (*ieee_setets) (struct net_device *, struct ieee_ets *); |
51 | int (*ieee_getmaxrate) (struct net_device *, struct ieee_maxrate *); | ||
52 | int (*ieee_setmaxrate) (struct net_device *, struct ieee_maxrate *); | ||
53 | int (*ieee_getpfc) (struct net_device *, struct ieee_pfc *); | 50 | int (*ieee_getpfc) (struct net_device *, struct ieee_pfc *); |
54 | int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *); | 51 | int (*ieee_setpfc) (struct net_device *, struct ieee_pfc *); |
55 | int (*ieee_getapp) (struct net_device *, struct dcb_app *); | 52 | int (*ieee_getapp) (struct net_device *, struct dcb_app *); |
@@ -74,8 +71,8 @@ struct dcbnl_rtnl_ops { | |||
74 | void (*getpfccfg)(struct net_device *, int, u8 *); | 71 | void (*getpfccfg)(struct net_device *, int, u8 *); |
75 | u8 (*setall)(struct net_device *); | 72 | u8 (*setall)(struct net_device *); |
76 | u8 (*getcap)(struct net_device *, int, u8 *); | 73 | u8 (*getcap)(struct net_device *, int, u8 *); |
77 | int (*getnumtcs)(struct net_device *, int, u8 *); | 74 | u8 (*getnumtcs)(struct net_device *, int, u8 *); |
78 | int (*setnumtcs)(struct net_device *, int, u8); | 75 | u8 (*setnumtcs)(struct net_device *, int, u8); |
79 | u8 (*getpfcstate)(struct net_device *); | 76 | u8 (*getpfcstate)(struct net_device *); |
80 | void (*setpfcstate)(struct net_device *, u8); | 77 | void (*setpfcstate)(struct net_device *, u8); |
81 | void (*getbcncfg)(struct net_device *, int, u32 *); | 78 | void (*getbcncfg)(struct net_device *, int, u32 *); |
diff --git a/include/net/dn.h b/include/net/dn.h index c88bf4ebd33..298521e0d8a 100644 --- a/include/net/dn.h +++ b/include/net/dn.h | |||
@@ -3,7 +3,6 @@ | |||
3 | 3 | ||
4 | #include <linux/dn.h> | 4 | #include <linux/dn.h> |
5 | #include <net/sock.h> | 5 | #include <net/sock.h> |
6 | #include <net/flow.h> | ||
7 | #include <asm/byteorder.h> | 6 | #include <asm/byteorder.h> |
8 | #include <asm/unaligned.h> | 7 | #include <asm/unaligned.h> |
9 | 8 | ||
@@ -199,7 +198,7 @@ static inline void dn_sk_ports_copy(struct flowidn *fld, struct dn_scp *scp) | |||
199 | fld->fld_dport = scp->addrrem; | 198 | fld->fld_dport = scp->addrrem; |
200 | } | 199 | } |
201 | 200 | ||
202 | extern unsigned int dn_mss_from_pmtu(struct net_device *dev, int mtu); | 201 | extern unsigned dn_mss_from_pmtu(struct net_device *dev, int mtu); |
203 | 202 | ||
204 | #define DN_MENUVER_ACC 0x01 | 203 | #define DN_MENUVER_ACC 0x01 |
205 | #define DN_MENUVER_USR 0x02 | 204 | #define DN_MENUVER_USR 0x02 |
diff --git a/include/net/dn_fib.h b/include/net/dn_fib.h index 1ee9d4bda30..782ef7cb493 100644 --- a/include/net/dn_fib.h +++ b/include/net/dn_fib.h | |||
@@ -31,7 +31,7 @@ struct dn_fib_res { | |||
31 | 31 | ||
32 | struct dn_fib_nh { | 32 | struct dn_fib_nh { |
33 | struct net_device *nh_dev; | 33 | struct net_device *nh_dev; |
34 | unsigned int nh_flags; | 34 | unsigned nh_flags; |
35 | unsigned char nh_scope; | 35 | unsigned char nh_scope; |
36 | int nh_weight; | 36 | int nh_weight; |
37 | int nh_power; | 37 | int nh_power; |
@@ -45,7 +45,7 @@ struct dn_fib_info { | |||
45 | int fib_treeref; | 45 | int fib_treeref; |
46 | atomic_t fib_clntref; | 46 | atomic_t fib_clntref; |
47 | int fib_dead; | 47 | int fib_dead; |
48 | unsigned int fib_flags; | 48 | unsigned fib_flags; |
49 | int fib_protocol; | 49 | int fib_protocol; |
50 | __le16 fib_prefsrc; | 50 | __le16 fib_prefsrc; |
51 | __u32 fib_priority; | 51 | __u32 fib_priority; |
@@ -140,7 +140,7 @@ extern void dn_fib_table_cleanup(void); | |||
140 | */ | 140 | */ |
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 int dnet_addr_type(__le16 addr); | 143 | extern unsigned dnet_addr_type(__le16 addr); |
144 | extern int dn_fib_lookup(struct flowidn *fld, 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); |
diff --git a/include/net/dn_route.h b/include/net/dn_route.h index 4f7d6a18238..81712cfa1dd 100644 --- a/include/net/dn_route.h +++ b/include/net/dn_route.h | |||
@@ -67,8 +67,6 @@ 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 neighbour *n; | ||
71 | |||
72 | struct flowidn fld; | 70 | struct flowidn fld; |
73 | 71 | ||
74 | __le16 rt_saddr; | 72 | __le16 rt_saddr; |
@@ -78,8 +76,8 @@ struct dn_route { | |||
78 | __le16 rt_src_map; | 76 | __le16 rt_src_map; |
79 | __le16 rt_dst_map; | 77 | __le16 rt_dst_map; |
80 | 78 | ||
81 | unsigned int rt_flags; | 79 | unsigned rt_flags; |
82 | unsigned int rt_type; | 80 | unsigned rt_type; |
83 | }; | 81 | }; |
84 | 82 | ||
85 | static inline bool dn_is_input_route(struct dn_route *rt) | 83 | static inline bool dn_is_input_route(struct dn_route *rt) |
diff --git a/include/net/dsa.h b/include/net/dsa.h index 7828ebf99ee..839f768f9e3 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h | |||
@@ -11,11 +11,6 @@ | |||
11 | #ifndef __LINUX_NET_DSA_H | 11 | #ifndef __LINUX_NET_DSA_H |
12 | #define __LINUX_NET_DSA_H | 12 | #define __LINUX_NET_DSA_H |
13 | 13 | ||
14 | #include <linux/if_ether.h> | ||
15 | #include <linux/list.h> | ||
16 | #include <linux/timer.h> | ||
17 | #include <linux/workqueue.h> | ||
18 | |||
19 | #define DSA_MAX_SWITCHES 4 | 14 | #define DSA_MAX_SWITCHES 4 |
20 | #define DSA_MAX_PORTS 12 | 15 | #define DSA_MAX_PORTS 12 |
21 | 16 | ||
@@ -59,143 +54,8 @@ struct dsa_platform_data { | |||
59 | struct dsa_chip_data *chip; | 54 | struct dsa_chip_data *chip; |
60 | }; | 55 | }; |
61 | 56 | ||
62 | struct dsa_switch_tree { | 57 | extern bool dsa_uses_dsa_tags(void *dsa_ptr); |
63 | /* | 58 | extern bool dsa_uses_trailer_tags(void *dsa_ptr); |
64 | * Configuration data for the platform device that owns | ||
65 | * this dsa switch tree instance. | ||
66 | */ | ||
67 | struct dsa_platform_data *pd; | ||
68 | |||
69 | /* | ||
70 | * Reference to network device to use, and which tagging | ||
71 | * protocol to use. | ||
72 | */ | ||
73 | struct net_device *master_netdev; | ||
74 | __be16 tag_protocol; | ||
75 | |||
76 | /* | ||
77 | * The switch and port to which the CPU is attached. | ||
78 | */ | ||
79 | s8 cpu_switch; | ||
80 | s8 cpu_port; | ||
81 | |||
82 | /* | ||
83 | * Link state polling. | ||
84 | */ | ||
85 | int link_poll_needed; | ||
86 | struct work_struct link_poll_work; | ||
87 | struct timer_list link_poll_timer; | ||
88 | |||
89 | /* | ||
90 | * Data for the individual switch chips. | ||
91 | */ | ||
92 | struct dsa_switch *ds[DSA_MAX_SWITCHES]; | ||
93 | }; | ||
94 | |||
95 | struct dsa_switch { | ||
96 | /* | ||
97 | * Parent switch tree, and switch index. | ||
98 | */ | ||
99 | struct dsa_switch_tree *dst; | ||
100 | int index; | ||
101 | |||
102 | /* | ||
103 | * Configuration data for this switch. | ||
104 | */ | ||
105 | struct dsa_chip_data *pd; | ||
106 | |||
107 | /* | ||
108 | * The used switch driver. | ||
109 | */ | ||
110 | struct dsa_switch_driver *drv; | ||
111 | |||
112 | /* | ||
113 | * Reference to mii bus to use. | ||
114 | */ | ||
115 | struct mii_bus *master_mii_bus; | ||
116 | |||
117 | /* | ||
118 | * Slave mii_bus and devices for the individual ports. | ||
119 | */ | ||
120 | u32 dsa_port_mask; | ||
121 | u32 phys_port_mask; | ||
122 | struct mii_bus *slave_mii_bus; | ||
123 | struct net_device *ports[DSA_MAX_PORTS]; | ||
124 | }; | ||
125 | |||
126 | static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p) | ||
127 | { | ||
128 | return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port); | ||
129 | } | ||
130 | |||
131 | static inline u8 dsa_upstream_port(struct dsa_switch *ds) | ||
132 | { | ||
133 | struct dsa_switch_tree *dst = ds->dst; | ||
134 | |||
135 | /* | ||
136 | * If this is the root switch (i.e. the switch that connects | ||
137 | * to the CPU), return the cpu port number on this switch. | ||
138 | * Else return the (DSA) port number that connects to the | ||
139 | * switch that is one hop closer to the cpu. | ||
140 | */ | ||
141 | if (dst->cpu_switch == ds->index) | ||
142 | return dst->cpu_port; | ||
143 | else | ||
144 | return ds->pd->rtable[dst->cpu_switch]; | ||
145 | } | ||
146 | |||
147 | struct dsa_switch_driver { | ||
148 | struct list_head list; | ||
149 | |||
150 | __be16 tag_protocol; | ||
151 | int priv_size; | ||
152 | |||
153 | /* | ||
154 | * Probing and setup. | ||
155 | */ | ||
156 | char *(*probe)(struct mii_bus *bus, int sw_addr); | ||
157 | int (*setup)(struct dsa_switch *ds); | ||
158 | int (*set_addr)(struct dsa_switch *ds, u8 *addr); | ||
159 | |||
160 | /* | ||
161 | * Access to the switch's PHY registers. | ||
162 | */ | ||
163 | int (*phy_read)(struct dsa_switch *ds, int port, int regnum); | ||
164 | int (*phy_write)(struct dsa_switch *ds, int port, | ||
165 | int regnum, u16 val); | ||
166 | |||
167 | /* | ||
168 | * Link state polling and IRQ handling. | ||
169 | */ | ||
170 | void (*poll_link)(struct dsa_switch *ds); | ||
171 | |||
172 | /* | ||
173 | * ethtool hardware statistics. | ||
174 | */ | ||
175 | void (*get_strings)(struct dsa_switch *ds, int port, uint8_t *data); | ||
176 | void (*get_ethtool_stats)(struct dsa_switch *ds, | ||
177 | int port, uint64_t *data); | ||
178 | int (*get_sset_count)(struct dsa_switch *ds); | ||
179 | }; | ||
180 | |||
181 | void register_switch_driver(struct dsa_switch_driver *type); | ||
182 | void unregister_switch_driver(struct dsa_switch_driver *type); | ||
183 | |||
184 | /* | ||
185 | * The original DSA tag format and some other tag formats have no | ||
186 | * ethertype, which means that we need to add a little hack to the | ||
187 | * networking receive path to make sure that received frames get | ||
188 | * the right ->protocol assigned to them when one of those tag | ||
189 | * formats is in use. | ||
190 | */ | ||
191 | static inline bool dsa_uses_dsa_tags(struct dsa_switch_tree *dst) | ||
192 | { | ||
193 | return !!(dst->tag_protocol == htons(ETH_P_DSA)); | ||
194 | } | ||
195 | 59 | ||
196 | static inline bool dsa_uses_trailer_tags(struct dsa_switch_tree *dst) | ||
197 | { | ||
198 | return !!(dst->tag_protocol == htons(ETH_P_TRAILER)); | ||
199 | } | ||
200 | 60 | ||
201 | #endif | 61 | #endif |
diff --git a/include/net/dst.h b/include/net/dst.h index 9a7881066fb..82952498b63 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/netdevice.h> | 12 | #include <linux/netdevice.h> |
13 | #include <linux/rtnetlink.h> | 13 | #include <linux/rtnetlink.h> |
14 | #include <linux/rcupdate.h> | 14 | #include <linux/rcupdate.h> |
15 | #include <linux/bug.h> | ||
16 | #include <linux/jiffies.h> | 15 | #include <linux/jiffies.h> |
17 | #include <net/neighbour.h> | 16 | #include <net/neighbour.h> |
18 | #include <asm/processor.h> | 17 | #include <asm/processor.h> |
@@ -36,22 +35,18 @@ struct dst_entry { | |||
36 | struct net_device *dev; | 35 | struct net_device *dev; |
37 | struct dst_ops *ops; | 36 | struct dst_ops *ops; |
38 | unsigned long _metrics; | 37 | unsigned long _metrics; |
39 | union { | 38 | unsigned long expires; |
40 | unsigned long expires; | ||
41 | /* point to where the dst_entry copied from */ | ||
42 | struct dst_entry *from; | ||
43 | }; | ||
44 | struct dst_entry *path; | 39 | struct dst_entry *path; |
45 | void *__pad0; | 40 | struct neighbour __rcu *_neighbour; |
46 | #ifdef CONFIG_XFRM | 41 | #ifdef CONFIG_XFRM |
47 | struct xfrm_state *xfrm; | 42 | struct xfrm_state *xfrm; |
48 | #else | 43 | #else |
49 | void *__pad1; | 44 | void *__pad1; |
50 | #endif | 45 | #endif |
51 | int (*input)(struct sk_buff *); | 46 | int (*input)(struct sk_buff*); |
52 | int (*output)(struct sk_buff *); | 47 | int (*output)(struct sk_buff*); |
53 | 48 | ||
54 | unsigned short flags; | 49 | int flags; |
55 | #define DST_HOST 0x0001 | 50 | #define DST_HOST 0x0001 |
56 | #define DST_NOXFRM 0x0002 | 51 | #define DST_NOXFRM 0x0002 |
57 | #define DST_NOPOLICY 0x0004 | 52 | #define DST_NOPOLICY 0x0004 |
@@ -59,26 +54,9 @@ struct dst_entry { | |||
59 | #define DST_NOCACHE 0x0010 | 54 | #define DST_NOCACHE 0x0010 |
60 | #define DST_NOCOUNT 0x0020 | 55 | #define DST_NOCOUNT 0x0020 |
61 | #define DST_NOPEER 0x0040 | 56 | #define DST_NOPEER 0x0040 |
62 | #define DST_FAKE_RTABLE 0x0080 | ||
63 | #define DST_XFRM_TUNNEL 0x0100 | ||
64 | |||
65 | unsigned short pending_confirm; | ||
66 | 57 | ||
67 | short error; | 58 | short error; |
68 | |||
69 | /* A non-zero value of dst->obsolete forces by-hand validation | ||
70 | * of the route entry. Positive values are set by the generic | ||
71 | * dst layer to indicate that the entry has been forcefully | ||
72 | * destroyed. | ||
73 | * | ||
74 | * Negative values are used by the implementation layer code to | ||
75 | * force invocation of the dst_ops->check() method. | ||
76 | */ | ||
77 | short obsolete; | 59 | short obsolete; |
78 | #define DST_OBSOLETE_NONE 0 | ||
79 | #define DST_OBSOLETE_DEAD 2 | ||
80 | #define DST_OBSOLETE_FORCE_CHK -1 | ||
81 | #define DST_OBSOLETE_KILL -2 | ||
82 | unsigned short header_len; /* more space at head required */ | 60 | unsigned short header_len; /* more space at head required */ |
83 | unsigned short trailer_len; /* space to reserve at tail */ | 61 | unsigned short trailer_len; /* space to reserve at tail */ |
84 | #ifdef CONFIG_IP_ROUTE_CLASSID | 62 | #ifdef CONFIG_IP_ROUTE_CLASSID |
@@ -109,8 +87,23 @@ struct dst_entry { | |||
109 | }; | 87 | }; |
110 | }; | 88 | }; |
111 | 89 | ||
90 | static inline struct neighbour *dst_get_neighbour(struct dst_entry *dst) | ||
91 | { | ||
92 | return rcu_dereference(dst->_neighbour); | ||
93 | } | ||
94 | |||
95 | static inline struct neighbour *dst_get_neighbour_raw(struct dst_entry *dst) | ||
96 | { | ||
97 | return rcu_dereference_raw(dst->_neighbour); | ||
98 | } | ||
99 | |||
100 | static inline void dst_set_neighbour(struct dst_entry *dst, struct neighbour *neigh) | ||
101 | { | ||
102 | rcu_assign_pointer(dst->_neighbour, neigh); | ||
103 | } | ||
104 | |||
112 | extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old); | 105 | extern u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old); |
113 | extern const u32 dst_default_metrics[]; | 106 | extern const u32 dst_default_metrics[RTAX_MAX]; |
114 | 107 | ||
115 | #define DST_METRICS_READ_ONLY 0x1UL | 108 | #define DST_METRICS_READ_ONLY 0x1UL |
116 | #define __DST_METRICS_PTR(Y) \ | 109 | #define __DST_METRICS_PTR(Y) \ |
@@ -213,7 +206,12 @@ dst_feature(const struct dst_entry *dst, u32 feature) | |||
213 | 206 | ||
214 | static inline u32 dst_mtu(const struct dst_entry *dst) | 207 | static inline u32 dst_mtu(const struct dst_entry *dst) |
215 | { | 208 | { |
216 | return dst->ops->mtu(dst); | 209 | u32 mtu = dst_metric_raw(dst, RTAX_MTU); |
210 | |||
211 | if (!mtu) | ||
212 | mtu = dst->ops->default_mtu(dst); | ||
213 | |||
214 | return mtu; | ||
217 | } | 215 | } |
218 | 216 | ||
219 | /* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */ | 217 | /* RTT metrics are stored in milliseconds for user ABI, but used as jiffies */ |
@@ -222,6 +220,12 @@ static inline unsigned long dst_metric_rtt(const struct dst_entry *dst, int metr | |||
222 | return msecs_to_jiffies(dst_metric(dst, metric)); | 220 | return msecs_to_jiffies(dst_metric(dst, metric)); |
223 | } | 221 | } |
224 | 222 | ||
223 | static inline void set_dst_metric_rtt(struct dst_entry *dst, int metric, | ||
224 | unsigned long rtt) | ||
225 | { | ||
226 | dst_metric_set(dst, metric, jiffies_to_msecs(rtt)); | ||
227 | } | ||
228 | |||
225 | static inline u32 | 229 | static inline u32 |
226 | dst_allfrag(const struct dst_entry *dst) | 230 | dst_allfrag(const struct dst_entry *dst) |
227 | { | 231 | { |
@@ -235,7 +239,7 @@ dst_metric_locked(const struct dst_entry *dst, int metric) | |||
235 | return dst_metric(dst, RTAX_LOCK) & (1<<metric); | 239 | return dst_metric(dst, RTAX_LOCK) & (1<<metric); |
236 | } | 240 | } |
237 | 241 | ||
238 | static inline void dst_hold(struct dst_entry *dst) | 242 | static inline void dst_hold(struct dst_entry * dst) |
239 | { | 243 | { |
240 | /* | 244 | /* |
241 | * If your kernel compilation stops here, please check | 245 | * If your kernel compilation stops here, please check |
@@ -258,7 +262,8 @@ static inline void dst_use_noref(struct dst_entry *dst, unsigned long time) | |||
258 | dst->lastuse = time; | 262 | dst->lastuse = time; |
259 | } | 263 | } |
260 | 264 | ||
261 | static inline struct dst_entry *dst_clone(struct dst_entry *dst) | 265 | static inline |
266 | struct dst_entry * dst_clone(struct dst_entry * dst) | ||
262 | { | 267 | { |
263 | if (dst) | 268 | if (dst) |
264 | atomic_inc(&dst->__refcnt); | 269 | atomic_inc(&dst->__refcnt); |
@@ -321,14 +326,7 @@ static inline void skb_dst_force(struct sk_buff *skb) | |||
321 | static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) | 326 | static inline void __skb_tunnel_rx(struct sk_buff *skb, struct net_device *dev) |
322 | { | 327 | { |
323 | skb->dev = dev; | 328 | skb->dev = dev; |
324 | 329 | skb->rxhash = 0; | |
325 | /* | ||
326 | * Clear rxhash so that we can recalulate the hash for the | ||
327 | * encapsulated packet, unless we have already determine the hash | ||
328 | * over the L4 4-tuple. | ||
329 | */ | ||
330 | if (!skb->l4_rxhash) | ||
331 | skb->rxhash = 0; | ||
332 | skb_set_queue_mapping(skb, 0); | 330 | skb_set_queue_mapping(skb, 0); |
333 | skb_dst_drop(skb); | 331 | skb_dst_drop(skb); |
334 | nf_reset(skb); | 332 | nf_reset(skb); |
@@ -364,15 +362,14 @@ static inline struct dst_entry *skb_dst_pop(struct sk_buff *skb) | |||
364 | } | 362 | } |
365 | 363 | ||
366 | extern int dst_discard(struct sk_buff *skb); | 364 | extern int dst_discard(struct sk_buff *skb); |
367 | extern void *dst_alloc(struct dst_ops *ops, struct net_device *dev, | 365 | extern void *dst_alloc(struct dst_ops * ops, struct net_device *dev, |
368 | int initial_ref, int initial_obsolete, | 366 | int initial_ref, int initial_obsolete, int flags); |
369 | unsigned short flags); | 367 | extern void __dst_free(struct dst_entry * dst); |
370 | extern void __dst_free(struct dst_entry *dst); | 368 | extern struct dst_entry *dst_destroy(struct dst_entry * dst); |
371 | extern struct dst_entry *dst_destroy(struct dst_entry *dst); | ||
372 | 369 | ||
373 | static inline void dst_free(struct dst_entry *dst) | 370 | static inline void dst_free(struct dst_entry * dst) |
374 | { | 371 | { |
375 | if (dst->obsolete > 0) | 372 | if (dst->obsolete > 1) |
376 | return; | 373 | return; |
377 | if (!atomic_read(&dst->__refcnt)) { | 374 | if (!atomic_read(&dst->__refcnt)) { |
378 | dst = dst_destroy(dst); | 375 | dst = dst_destroy(dst); |
@@ -390,39 +387,19 @@ static inline void dst_rcu_free(struct rcu_head *head) | |||
390 | 387 | ||
391 | static inline void dst_confirm(struct dst_entry *dst) | 388 | static inline void dst_confirm(struct dst_entry *dst) |
392 | { | 389 | { |
393 | dst->pending_confirm = 1; | 390 | if (dst) { |
394 | } | 391 | struct neighbour *n; |
395 | 392 | ||
396 | static inline int dst_neigh_output(struct dst_entry *dst, struct neighbour *n, | 393 | rcu_read_lock(); |
397 | struct sk_buff *skb) | 394 | n = dst_get_neighbour(dst); |
398 | { | 395 | neigh_confirm(n); |
399 | const struct hh_cache *hh; | 396 | rcu_read_unlock(); |
400 | |||
401 | if (dst->pending_confirm) { | ||
402 | unsigned long now = jiffies; | ||
403 | |||
404 | dst->pending_confirm = 0; | ||
405 | /* avoid dirtying neighbour */ | ||
406 | if (n->confirmed != now) | ||
407 | n->confirmed = now; | ||
408 | } | 397 | } |
409 | |||
410 | hh = &n->hh; | ||
411 | if ((n->nud_state & NUD_CONNECTED) && hh->hh_len) | ||
412 | return neigh_hh_output(hh, skb); | ||
413 | else | ||
414 | return n->output(n, skb); | ||
415 | } | 398 | } |
416 | 399 | ||
417 | static inline struct neighbour *dst_neigh_lookup(const struct dst_entry *dst, const void *daddr) | 400 | static inline struct neighbour *dst_neigh_lookup(const struct dst_entry *dst, const void *daddr) |
418 | { | 401 | { |
419 | return dst->ops->neigh_lookup(dst, NULL, daddr); | 402 | return dst->ops->neigh_lookup(dst, daddr); |
420 | } | ||
421 | |||
422 | static inline struct neighbour *dst_neigh_lookup_skb(const struct dst_entry *dst, | ||
423 | struct sk_buff *skb) | ||
424 | { | ||
425 | return dst->ops->neigh_lookup(dst, skb, NULL); | ||
426 | } | 403 | } |
427 | 404 | ||
428 | static inline void dst_link_failure(struct sk_buff *skb) | 405 | static inline void dst_link_failure(struct sk_buff *skb) |
diff --git a/include/net/dst_ops.h b/include/net/dst_ops.h index 2f26dfb8450..9adb99845a5 100644 --- a/include/net/dst_ops.h +++ b/include/net/dst_ops.h | |||
@@ -8,31 +8,25 @@ struct dst_entry; | |||
8 | struct kmem_cachep; | 8 | struct kmem_cachep; |
9 | struct net_device; | 9 | struct net_device; |
10 | struct sk_buff; | 10 | struct sk_buff; |
11 | struct sock; | ||
12 | 11 | ||
13 | struct dst_ops { | 12 | struct dst_ops { |
14 | unsigned short family; | 13 | unsigned short family; |
15 | __be16 protocol; | 14 | __be16 protocol; |
16 | unsigned int gc_thresh; | 15 | unsigned gc_thresh; |
17 | 16 | ||
18 | int (*gc)(struct dst_ops *ops); | 17 | int (*gc)(struct dst_ops *ops); |
19 | struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); | 18 | struct dst_entry * (*check)(struct dst_entry *, __u32 cookie); |
20 | unsigned int (*default_advmss)(const struct dst_entry *); | 19 | unsigned int (*default_advmss)(const struct dst_entry *); |
21 | unsigned int (*mtu)(const struct dst_entry *); | 20 | unsigned int (*default_mtu)(const struct dst_entry *); |
22 | u32 * (*cow_metrics)(struct dst_entry *, unsigned long); | 21 | u32 * (*cow_metrics)(struct dst_entry *, unsigned long); |
23 | void (*destroy)(struct dst_entry *); | 22 | void (*destroy)(struct dst_entry *); |
24 | void (*ifdown)(struct dst_entry *, | 23 | void (*ifdown)(struct dst_entry *, |
25 | struct net_device *dev, int how); | 24 | struct net_device *dev, int how); |
26 | struct dst_entry * (*negative_advice)(struct dst_entry *); | 25 | struct dst_entry * (*negative_advice)(struct dst_entry *); |
27 | void (*link_failure)(struct sk_buff *); | 26 | void (*link_failure)(struct sk_buff *); |
28 | void (*update_pmtu)(struct dst_entry *dst, struct sock *sk, | 27 | void (*update_pmtu)(struct dst_entry *dst, u32 mtu); |
29 | struct sk_buff *skb, u32 mtu); | ||
30 | void (*redirect)(struct dst_entry *dst, struct sock *sk, | ||
31 | struct sk_buff *skb); | ||
32 | int (*local_out)(struct sk_buff *skb); | 28 | int (*local_out)(struct sk_buff *skb); |
33 | struct neighbour * (*neigh_lookup)(const struct dst_entry *dst, | 29 | struct neighbour * (*neigh_lookup)(const struct dst_entry *dst, const void *daddr); |
34 | struct sk_buff *skb, | ||
35 | const void *daddr); | ||
36 | 30 | ||
37 | struct kmem_cache *kmem_cachep; | 31 | struct kmem_cache *kmem_cachep; |
38 | 32 | ||
diff --git a/include/net/fib_rules.h b/include/net/fib_rules.h index e361f488242..075f1e3a0fe 100644 --- a/include/net/fib_rules.h +++ b/include/net/fib_rules.h | |||
@@ -52,7 +52,6 @@ struct fib_rules_ops { | |||
52 | struct sk_buff *, | 52 | struct sk_buff *, |
53 | struct fib_rule_hdr *, | 53 | struct fib_rule_hdr *, |
54 | struct nlattr **); | 54 | struct nlattr **); |
55 | void (*delete)(struct fib_rule *); | ||
56 | int (*compare)(struct fib_rule *, | 55 | int (*compare)(struct fib_rule *, |
57 | struct fib_rule_hdr *, | 56 | struct fib_rule_hdr *, |
58 | struct nlattr **); | 57 | struct nlattr **); |
diff --git a/include/net/flow.h b/include/net/flow.h index 628e11b98c5..57f15a7f1cd 100644 --- a/include/net/flow.h +++ b/include/net/flow.h | |||
@@ -20,8 +20,8 @@ struct flowi_common { | |||
20 | __u8 flowic_proto; | 20 | __u8 flowic_proto; |
21 | __u8 flowic_flags; | 21 | __u8 flowic_flags; |
22 | #define FLOWI_FLAG_ANYSRC 0x01 | 22 | #define FLOWI_FLAG_ANYSRC 0x01 |
23 | #define FLOWI_FLAG_CAN_SLEEP 0x02 | 23 | #define FLOWI_FLAG_PRECOW_METRICS 0x02 |
24 | #define FLOWI_FLAG_KNOWN_NH 0x04 | 24 | #define FLOWI_FLAG_CAN_SLEEP 0x04 |
25 | __u32 flowic_secid; | 25 | __u32 flowic_secid; |
26 | }; | 26 | }; |
27 | 27 | ||
@@ -59,11 +59,8 @@ struct flowi4 { | |||
59 | #define flowi4_proto __fl_common.flowic_proto | 59 | #define flowi4_proto __fl_common.flowic_proto |
60 | #define flowi4_flags __fl_common.flowic_flags | 60 | #define flowi4_flags __fl_common.flowic_flags |
61 | #define flowi4_secid __fl_common.flowic_secid | 61 | #define flowi4_secid __fl_common.flowic_secid |
62 | |||
63 | /* (saddr,daddr) must be grouped, same order as in IP header */ | ||
64 | __be32 saddr; | ||
65 | __be32 daddr; | 62 | __be32 daddr; |
66 | 63 | __be32 saddr; | |
67 | union flowi_uli uli; | 64 | union flowi_uli uli; |
68 | #define fl4_sport uli.ports.sport | 65 | #define fl4_sport uli.ports.sport |
69 | #define fl4_dport uli.ports.dport | 66 | #define fl4_dport uli.ports.dport |
@@ -78,7 +75,7 @@ static inline void flowi4_init_output(struct flowi4 *fl4, int oif, | |||
78 | __u32 mark, __u8 tos, __u8 scope, | 75 | __u32 mark, __u8 tos, __u8 scope, |
79 | __u8 proto, __u8 flags, | 76 | __u8 proto, __u8 flags, |
80 | __be32 daddr, __be32 saddr, | 77 | __be32 daddr, __be32 saddr, |
81 | __be16 dport, __be16 sport) | 78 | __be16 dport, __be32 sport) |
82 | { | 79 | { |
83 | fl4->flowi4_oif = oif; | 80 | fl4->flowi4_oif = oif; |
84 | fl4->flowi4_iif = 0; | 81 | fl4->flowi4_iif = 0; |
@@ -93,16 +90,6 @@ static inline void flowi4_init_output(struct flowi4 *fl4, int oif, | |||
93 | fl4->fl4_dport = dport; | 90 | fl4->fl4_dport = dport; |
94 | fl4->fl4_sport = sport; | 91 | fl4->fl4_sport = sport; |
95 | } | 92 | } |
96 | |||
97 | /* Reset some input parameters after previous lookup */ | ||
98 | static inline void flowi4_update_output(struct flowi4 *fl4, int oif, __u8 tos, | ||
99 | __be32 daddr, __be32 saddr) | ||
100 | { | ||
101 | fl4->flowi4_oif = oif; | ||
102 | fl4->flowi4_tos = tos; | ||
103 | fl4->daddr = daddr; | ||
104 | fl4->saddr = saddr; | ||
105 | } | ||
106 | 93 | ||
107 | 94 | ||
108 | struct flowi6 { | 95 | struct flowi6 { |
diff --git a/include/net/flow_keys.h b/include/net/flow_keys.h deleted file mode 100644 index 80461c1ae9e..00000000000 --- a/include/net/flow_keys.h +++ /dev/null | |||
@@ -1,16 +0,0 @@ | |||
1 | #ifndef _NET_FLOW_KEYS_H | ||
2 | #define _NET_FLOW_KEYS_H | ||
3 | |||
4 | struct flow_keys { | ||
5 | /* (src,dst) must be grouped, in the same way than in IP header */ | ||
6 | __be32 src; | ||
7 | __be32 dst; | ||
8 | union { | ||
9 | __be32 ports; | ||
10 | __be16 port16[2]; | ||
11 | }; | ||
12 | u8 ip_proto; | ||
13 | }; | ||
14 | |||
15 | extern bool skb_flow_dissect(const struct sk_buff *skb, struct flow_keys *flow); | ||
16 | #endif | ||
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index bdfbe68c1c3..82d8d09faa4 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
@@ -5,8 +5,6 @@ | |||
5 | #include <net/netlink.h> | 5 | #include <net/netlink.h> |
6 | #include <net/net_namespace.h> | 6 | #include <net/net_namespace.h> |
7 | 7 | ||
8 | #define GENLMSG_DEFAULT_SIZE (NLMSG_DEFAULT_SIZE - GENL_HDRLEN) | ||
9 | |||
10 | /** | 8 | /** |
11 | * struct genl_multicast_group - generic netlink multicast group | 9 | * struct genl_multicast_group - generic netlink multicast group |
12 | * @name: name of the multicast group, names are per-family | 10 | * @name: name of the multicast group, names are per-family |
@@ -65,7 +63,7 @@ struct genl_family { | |||
65 | /** | 63 | /** |
66 | * struct genl_info - receiving information | 64 | * struct genl_info - receiving information |
67 | * @snd_seq: sending sequence number | 65 | * @snd_seq: sending sequence number |
68 | * @snd_portid: netlink portid of sender | 66 | * @snd_pid: netlink pid of sender |
69 | * @nlhdr: netlink message header | 67 | * @nlhdr: netlink message header |
70 | * @genlhdr: generic netlink message header | 68 | * @genlhdr: generic netlink message header |
71 | * @userhdr: user specific header | 69 | * @userhdr: user specific header |
@@ -75,7 +73,7 @@ struct genl_family { | |||
75 | */ | 73 | */ |
76 | struct genl_info { | 74 | struct genl_info { |
77 | u32 snd_seq; | 75 | u32 snd_seq; |
78 | u32 snd_portid; | 76 | u32 snd_pid; |
79 | struct nlmsghdr * nlhdr; | 77 | struct nlmsghdr * nlhdr; |
80 | struct genlmsghdr * genlhdr; | 78 | struct genlmsghdr * genlhdr; |
81 | void * userhdr; | 79 | void * userhdr; |
@@ -130,11 +128,36 @@ extern int genl_register_mc_group(struct genl_family *family, | |||
130 | struct genl_multicast_group *grp); | 128 | struct genl_multicast_group *grp); |
131 | extern void genl_unregister_mc_group(struct genl_family *family, | 129 | extern void genl_unregister_mc_group(struct genl_family *family, |
132 | struct genl_multicast_group *grp); | 130 | struct genl_multicast_group *grp); |
133 | extern void genl_notify(struct sk_buff *skb, struct net *net, u32 portid, | ||
134 | u32 group, struct nlmsghdr *nlh, gfp_t flags); | ||
135 | 131 | ||
136 | void *genlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, | 132 | /** |
137 | struct genl_family *family, int flags, u8 cmd); | 133 | * genlmsg_put - Add generic netlink header to netlink message |
134 | * @skb: socket buffer holding the message | ||
135 | * @pid: netlink pid the message is addressed to | ||
136 | * @seq: sequence number (usually the one of the sender) | ||
137 | * @family: generic netlink family | ||
138 | * @flags netlink message flags | ||
139 | * @cmd: generic netlink command | ||
140 | * | ||
141 | * Returns pointer to user specific header | ||
142 | */ | ||
143 | static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, | ||
144 | struct genl_family *family, int flags, u8 cmd) | ||
145 | { | ||
146 | struct nlmsghdr *nlh; | ||
147 | struct genlmsghdr *hdr; | ||
148 | |||
149 | nlh = nlmsg_put(skb, pid, seq, family->id, GENL_HDRLEN + | ||
150 | family->hdrsize, flags); | ||
151 | if (nlh == NULL) | ||
152 | return NULL; | ||
153 | |||
154 | hdr = nlmsg_data(nlh); | ||
155 | hdr->cmd = cmd; | ||
156 | hdr->version = family->version; | ||
157 | hdr->reserved = 0; | ||
158 | |||
159 | return (char *) hdr + GENL_HDRLEN; | ||
160 | } | ||
138 | 161 | ||
139 | /** | 162 | /** |
140 | * genlmsg_nlhdr - Obtain netlink header from user specified header | 163 | * genlmsg_nlhdr - Obtain netlink header from user specified header |
@@ -183,7 +206,7 @@ static inline void *genlmsg_put_reply(struct sk_buff *skb, | |||
183 | struct genl_family *family, | 206 | struct genl_family *family, |
184 | int flags, u8 cmd) | 207 | int flags, u8 cmd) |
185 | { | 208 | { |
186 | return genlmsg_put(skb, info->snd_portid, info->snd_seq, family, | 209 | return genlmsg_put(skb, info->snd_pid, info->snd_seq, family, |
187 | flags, cmd); | 210 | flags, cmd); |
188 | } | 211 | } |
189 | 212 | ||
@@ -212,49 +235,49 @@ static inline void genlmsg_cancel(struct sk_buff *skb, void *hdr) | |||
212 | * genlmsg_multicast_netns - multicast a netlink message to a specific netns | 235 | * genlmsg_multicast_netns - multicast a netlink message to a specific netns |
213 | * @net: the net namespace | 236 | * @net: the net namespace |
214 | * @skb: netlink message as socket buffer | 237 | * @skb: netlink message as socket buffer |
215 | * @portid: own netlink portid to avoid sending to yourself | 238 | * @pid: own netlink pid to avoid sending to yourself |
216 | * @group: multicast group id | 239 | * @group: multicast group id |
217 | * @flags: allocation flags | 240 | * @flags: allocation flags |
218 | */ | 241 | */ |
219 | static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb, | 242 | static inline int genlmsg_multicast_netns(struct net *net, struct sk_buff *skb, |
220 | u32 portid, unsigned int group, gfp_t flags) | 243 | u32 pid, unsigned int group, gfp_t flags) |
221 | { | 244 | { |
222 | return nlmsg_multicast(net->genl_sock, skb, portid, group, flags); | 245 | return nlmsg_multicast(net->genl_sock, skb, pid, group, flags); |
223 | } | 246 | } |
224 | 247 | ||
225 | /** | 248 | /** |
226 | * genlmsg_multicast - multicast a netlink message to the default netns | 249 | * genlmsg_multicast - multicast a netlink message to the default netns |
227 | * @skb: netlink message as socket buffer | 250 | * @skb: netlink message as socket buffer |
228 | * @portid: own netlink portid to avoid sending to yourself | 251 | * @pid: own netlink pid to avoid sending to yourself |
229 | * @group: multicast group id | 252 | * @group: multicast group id |
230 | * @flags: allocation flags | 253 | * @flags: allocation flags |
231 | */ | 254 | */ |
232 | static inline int genlmsg_multicast(struct sk_buff *skb, u32 portid, | 255 | static inline int genlmsg_multicast(struct sk_buff *skb, u32 pid, |
233 | unsigned int group, gfp_t flags) | 256 | unsigned int group, gfp_t flags) |
234 | { | 257 | { |
235 | return genlmsg_multicast_netns(&init_net, skb, portid, group, flags); | 258 | return genlmsg_multicast_netns(&init_net, skb, pid, group, flags); |
236 | } | 259 | } |
237 | 260 | ||
238 | /** | 261 | /** |
239 | * genlmsg_multicast_allns - multicast a netlink message to all net namespaces | 262 | * genlmsg_multicast_allns - multicast a netlink message to all net namespaces |
240 | * @skb: netlink message as socket buffer | 263 | * @skb: netlink message as socket buffer |
241 | * @portid: own netlink portid to avoid sending to yourself | 264 | * @pid: own netlink pid to avoid sending to yourself |
242 | * @group: multicast group id | 265 | * @group: multicast group id |
243 | * @flags: allocation flags | 266 | * @flags: allocation flags |
244 | * | 267 | * |
245 | * This function must hold the RTNL or rcu_read_lock(). | 268 | * This function must hold the RTNL or rcu_read_lock(). |
246 | */ | 269 | */ |
247 | int genlmsg_multicast_allns(struct sk_buff *skb, u32 portid, | 270 | int genlmsg_multicast_allns(struct sk_buff *skb, u32 pid, |
248 | unsigned int group, gfp_t flags); | 271 | unsigned int group, gfp_t flags); |
249 | 272 | ||
250 | /** | 273 | /** |
251 | * genlmsg_unicast - unicast a netlink message | 274 | * genlmsg_unicast - unicast a netlink message |
252 | * @skb: netlink message as socket buffer | 275 | * @skb: netlink message as socket buffer |
253 | * @portid: netlink portid of the destination socket | 276 | * @pid: netlink pid of the destination socket |
254 | */ | 277 | */ |
255 | static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 portid) | 278 | static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 pid) |
256 | { | 279 | { |
257 | return nlmsg_unicast(net->genl_sock, skb, portid); | 280 | return nlmsg_unicast(net->genl_sock, skb, pid); |
258 | } | 281 | } |
259 | 282 | ||
260 | /** | 283 | /** |
@@ -264,7 +287,7 @@ static inline int genlmsg_unicast(struct net *net, struct sk_buff *skb, u32 port | |||
264 | */ | 287 | */ |
265 | static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info) | 288 | static inline int genlmsg_reply(struct sk_buff *skb, struct genl_info *info) |
266 | { | 289 | { |
267 | return genlmsg_unicast(genl_info_net(info), skb, info->snd_portid); | 290 | return genlmsg_unicast(genl_info_net(info), skb, info->snd_pid); |
268 | } | 291 | } |
269 | 292 | ||
270 | /** | 293 | /** |
diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h deleted file mode 100644 index e5062c955ea..00000000000 --- a/include/net/gro_cells.h +++ /dev/null | |||
@@ -1,107 +0,0 @@ | |||
1 | #ifndef _NET_GRO_CELLS_H | ||
2 | #define _NET_GRO_CELLS_H | ||
3 | |||
4 | #include <linux/skbuff.h> | ||
5 | #include <linux/slab.h> | ||
6 | #include <linux/netdevice.h> | ||
7 | |||
8 | struct gro_cell { | ||
9 | struct sk_buff_head napi_skbs; | ||
10 | struct napi_struct napi; | ||
11 | } ____cacheline_aligned_in_smp; | ||
12 | |||
13 | struct gro_cells { | ||
14 | unsigned int gro_cells_mask; | ||
15 | struct gro_cell *cells; | ||
16 | }; | ||
17 | |||
18 | static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb) | ||
19 | { | ||
20 | struct gro_cell *cell = gcells->cells; | ||
21 | struct net_device *dev = skb->dev; | ||
22 | |||
23 | if (!cell || skb_cloned(skb) || !(dev->features & NETIF_F_GRO)) { | ||
24 | netif_rx(skb); | ||
25 | return; | ||
26 | } | ||
27 | |||
28 | if (skb_rx_queue_recorded(skb)) | ||
29 | cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask; | ||
30 | |||
31 | if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) { | ||
32 | atomic_long_inc(&dev->rx_dropped); | ||
33 | kfree_skb(skb); | ||
34 | return; | ||
35 | } | ||
36 | |||
37 | /* We run in BH context */ | ||
38 | spin_lock(&cell->napi_skbs.lock); | ||
39 | |||
40 | __skb_queue_tail(&cell->napi_skbs, skb); | ||
41 | if (skb_queue_len(&cell->napi_skbs) == 1) | ||
42 | napi_schedule(&cell->napi); | ||
43 | |||
44 | spin_unlock(&cell->napi_skbs.lock); | ||
45 | } | ||
46 | |||
47 | /* called unser BH context */ | ||
48 | static inline int gro_cell_poll(struct napi_struct *napi, int budget) | ||
49 | { | ||
50 | struct gro_cell *cell = container_of(napi, struct gro_cell, napi); | ||
51 | struct sk_buff *skb; | ||
52 | int work_done = 0; | ||
53 | |||
54 | spin_lock(&cell->napi_skbs.lock); | ||
55 | while (work_done < budget) { | ||
56 | skb = __skb_dequeue(&cell->napi_skbs); | ||
57 | if (!skb) | ||
58 | break; | ||
59 | spin_unlock(&cell->napi_skbs.lock); | ||
60 | napi_gro_receive(napi, skb); | ||
61 | work_done++; | ||
62 | spin_lock(&cell->napi_skbs.lock); | ||
63 | } | ||
64 | |||
65 | if (work_done < budget) | ||
66 | napi_complete(napi); | ||
67 | spin_unlock(&cell->napi_skbs.lock); | ||
68 | return work_done; | ||
69 | } | ||
70 | |||
71 | static inline int gro_cells_init(struct gro_cells *gcells, struct net_device *dev) | ||
72 | { | ||
73 | int i; | ||
74 | |||
75 | gcells->gro_cells_mask = roundup_pow_of_two(netif_get_num_default_rss_queues()) - 1; | ||
76 | gcells->cells = kcalloc(sizeof(struct gro_cell), | ||
77 | gcells->gro_cells_mask + 1, | ||
78 | GFP_KERNEL); | ||
79 | if (!gcells->cells) | ||
80 | return -ENOMEM; | ||
81 | |||
82 | for (i = 0; i <= gcells->gro_cells_mask; i++) { | ||
83 | struct gro_cell *cell = gcells->cells + i; | ||
84 | |||
85 | skb_queue_head_init(&cell->napi_skbs); | ||
86 | netif_napi_add(dev, &cell->napi, gro_cell_poll, 64); | ||
87 | napi_enable(&cell->napi); | ||
88 | } | ||
89 | return 0; | ||
90 | } | ||
91 | |||
92 | static inline void gro_cells_destroy(struct gro_cells *gcells) | ||
93 | { | ||
94 | struct gro_cell *cell = gcells->cells; | ||
95 | int i; | ||
96 | |||
97 | if (!cell) | ||
98 | return; | ||
99 | for (i = 0; i <= gcells->gro_cells_mask; i++,cell++) { | ||
100 | netif_napi_del(&cell->napi); | ||
101 | skb_queue_purge(&cell->napi_skbs); | ||
102 | } | ||
103 | kfree(gcells->cells); | ||
104 | gcells->cells = NULL; | ||
105 | } | ||
106 | |||
107 | #endif | ||
diff --git a/include/net/icmp.h b/include/net/icmp.h index 9ac2524d140..f0698b955b7 100644 --- a/include/net/icmp.h +++ b/include/net/icmp.h | |||
@@ -25,14 +25,14 @@ | |||
25 | 25 | ||
26 | struct icmp_err { | 26 | struct icmp_err { |
27 | int errno; | 27 | int errno; |
28 | unsigned int fatal:1; | 28 | unsigned fatal:1; |
29 | }; | 29 | }; |
30 | 30 | ||
31 | extern const struct icmp_err icmp_err_convert[]; | 31 | extern const struct icmp_err icmp_err_convert[]; |
32 | #define ICMP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field) | 32 | #define ICMP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field) |
33 | #define ICMP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field) | 33 | #define ICMP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field) |
34 | #define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field+256) | 34 | #define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmpmsg_statistics, field+256) |
35 | #define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_ATOMIC_LONG((net)->mib.icmpmsg_statistics, field) | 35 | #define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmpmsg_statistics, field) |
36 | 36 | ||
37 | struct dst_entry; | 37 | struct dst_entry; |
38 | struct net_proto_family; | 38 | struct net_proto_family; |
@@ -41,6 +41,7 @@ struct net; | |||
41 | 41 | ||
42 | extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info); | 42 | extern void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info); |
43 | extern int icmp_rcv(struct sk_buff *skb); | 43 | extern int icmp_rcv(struct sk_buff *skb); |
44 | extern int icmp_ioctl(struct sock *sk, int cmd, unsigned long arg); | ||
44 | extern int icmp_init(void); | 45 | extern int icmp_init(void); |
45 | extern void icmp_out_count(struct net *net, unsigned char type); | 46 | extern void icmp_out_count(struct net *net, unsigned char type); |
46 | 47 | ||
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h index c3999632e61..b0be5fb9de1 100644 --- a/include/net/ieee80211_radiotap.h +++ b/include/net/ieee80211_radiotap.h | |||
@@ -183,13 +183,6 @@ struct ieee80211_radiotap_header { | |||
183 | * Contains a bitmap of known fields/flags, the flags, and | 183 | * Contains a bitmap of known fields/flags, the flags, and |
184 | * the MCS index. | 184 | * the MCS index. |
185 | * | 185 | * |
186 | * IEEE80211_RADIOTAP_AMPDU_STATUS u32, u16, u8, u8 unitless | ||
187 | * | ||
188 | * Contains the AMPDU information for the subframe. | ||
189 | * | ||
190 | * IEEE80211_RADIOTAP_VHT u16, u8, u8, u8[4], u8, u8, u16 | ||
191 | * | ||
192 | * Contains VHT information about this frame. | ||
193 | */ | 186 | */ |
194 | enum ieee80211_radiotap_type { | 187 | enum ieee80211_radiotap_type { |
195 | IEEE80211_RADIOTAP_TSFT = 0, | 188 | IEEE80211_RADIOTAP_TSFT = 0, |
@@ -212,8 +205,6 @@ enum ieee80211_radiotap_type { | |||
212 | IEEE80211_RADIOTAP_DATA_RETRIES = 17, | 205 | IEEE80211_RADIOTAP_DATA_RETRIES = 17, |
213 | 206 | ||
214 | IEEE80211_RADIOTAP_MCS = 19, | 207 | IEEE80211_RADIOTAP_MCS = 19, |
215 | IEEE80211_RADIOTAP_AMPDU_STATUS = 20, | ||
216 | IEEE80211_RADIOTAP_VHT = 21, | ||
217 | 208 | ||
218 | /* valid in every it_present bitmap, even vendor namespaces */ | 209 | /* valid in every it_present bitmap, even vendor namespaces */ |
219 | IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, | 210 | IEEE80211_RADIOTAP_RADIOTAP_NAMESPACE = 29, |
@@ -260,7 +251,6 @@ enum ieee80211_radiotap_type { | |||
260 | * retries */ | 251 | * retries */ |
261 | #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ | 252 | #define IEEE80211_RADIOTAP_F_TX_CTS 0x0002 /* used cts 'protection' */ |
262 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ | 253 | #define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */ |
263 | #define IEEE80211_RADIOTAP_F_TX_NOACK 0x0008 /* don't expect an ack */ | ||
264 | 254 | ||
265 | 255 | ||
266 | /* For IEEE80211_RADIOTAP_MCS */ | 256 | /* For IEEE80211_RADIOTAP_MCS */ |
@@ -279,32 +269,14 @@ enum ieee80211_radiotap_type { | |||
279 | #define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 | 269 | #define IEEE80211_RADIOTAP_MCS_FMT_GF 0x08 |
280 | #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 | 270 | #define IEEE80211_RADIOTAP_MCS_FEC_LDPC 0x10 |
281 | 271 | ||
282 | /* For IEEE80211_RADIOTAP_AMPDU_STATUS */ | ||
283 | #define IEEE80211_RADIOTAP_AMPDU_REPORT_ZEROLEN 0x0001 | ||
284 | #define IEEE80211_RADIOTAP_AMPDU_IS_ZEROLEN 0x0002 | ||
285 | #define IEEE80211_RADIOTAP_AMPDU_LAST_KNOWN 0x0004 | ||
286 | #define IEEE80211_RADIOTAP_AMPDU_IS_LAST 0x0008 | ||
287 | #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_ERR 0x0010 | ||
288 | #define IEEE80211_RADIOTAP_AMPDU_DELIM_CRC_KNOWN 0x0020 | ||
289 | |||
290 | /* For IEEE80211_RADIOTAP_VHT */ | ||
291 | #define IEEE80211_RADIOTAP_VHT_KNOWN_STBC 0x0001 | ||
292 | #define IEEE80211_RADIOTAP_VHT_KNOWN_TXOP_PS_NA 0x0002 | ||
293 | #define IEEE80211_RADIOTAP_VHT_KNOWN_GI 0x0004 | ||
294 | #define IEEE80211_RADIOTAP_VHT_KNOWN_SGI_NSYM_DIS 0x0008 | ||
295 | #define IEEE80211_RADIOTAP_VHT_KNOWN_LDPC_EXTRA_OFDM_SYM 0x0010 | ||
296 | #define IEEE80211_RADIOTAP_VHT_KNOWN_BEAMFORMED 0x0020 | ||
297 | #define IEEE80211_RADIOTAP_VHT_KNOWN_BANDWIDTH 0x0040 | ||
298 | #define IEEE80211_RADIOTAP_VHT_KNOWN_GROUP_ID 0x0080 | ||
299 | #define IEEE80211_RADIOTAP_VHT_KNOWN_PARTIAL_AID 0x0100 | ||
300 | |||
301 | #define IEEE80211_RADIOTAP_VHT_FLAG_STBC 0x01 | ||
302 | #define IEEE80211_RADIOTAP_VHT_FLAG_TXOP_PS_NA 0x02 | ||
303 | #define IEEE80211_RADIOTAP_VHT_FLAG_SGI 0x04 | ||
304 | #define IEEE80211_RADIOTAP_VHT_FLAG_SGI_NSYM_M10_9 0x08 | ||
305 | #define IEEE80211_RADIOTAP_VHT_FLAG_LDPC_EXTRA_OFDM_SYM 0x10 | ||
306 | #define IEEE80211_RADIOTAP_VHT_FLAG_BEAMFORMED 0x20 | ||
307 | 272 | ||
273 | /* Ugly macro to convert literal channel numbers into their mhz equivalents | ||
274 | * There are certianly some conditions that will break this (like feeding it '30') | ||
275 | * but they shouldn't arise since nothing talks on channel 30. */ | ||
276 | #define ieee80211chan2mhz(x) \ | ||
277 | (((x) <= 14) ? \ | ||
278 | (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ | ||
279 | ((x) + 1000) * 5) | ||
308 | 280 | ||
309 | /* helpers */ | 281 | /* helpers */ |
310 | static inline int ieee80211_get_radiotap_len(unsigned char *data) | 282 | static inline int ieee80211_get_radiotap_len(unsigned char *data) |
diff --git a/include/net/ieee802154.h b/include/net/ieee802154.h index ee59f8b188d..d52685defb1 100644 --- a/include/net/ieee802154.h +++ b/include/net/ieee802154.h | |||
@@ -21,14 +21,11 @@ | |||
21 | * Maxim Gorbachyov <maxim.gorbachev@siemens.com> | 21 | * Maxim Gorbachyov <maxim.gorbachev@siemens.com> |
22 | * Maxim Osipov <maxim.osipov@siemens.com> | 22 | * Maxim Osipov <maxim.osipov@siemens.com> |
23 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 23 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
24 | * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> | ||
25 | */ | 24 | */ |
26 | 25 | ||
27 | #ifndef NET_IEEE802154_H | 26 | #ifndef NET_IEEE802154_H |
28 | #define NET_IEEE802154_H | 27 | #define NET_IEEE802154_H |
29 | 28 | ||
30 | #define IEEE802154_MTU 127 | ||
31 | |||
32 | #define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */ | 29 | #define IEEE802154_FC_TYPE_BEACON 0x0 /* Frame is beacon */ |
33 | #define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */ | 30 | #define IEEE802154_FC_TYPE_DATA 0x1 /* Frame is data */ |
34 | #define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */ | 31 | #define IEEE802154_FC_TYPE_ACK 0x2 /* Frame is acknowledgment */ |
@@ -59,9 +56,6 @@ | |||
59 | (((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT) | 56 | (((x) & IEEE802154_FC_DAMODE_MASK) >> IEEE802154_FC_DAMODE_SHIFT) |
60 | 57 | ||
61 | 58 | ||
62 | /* MAC footer size */ | ||
63 | #define IEEE802154_MFR_SIZE 2 /* 2 octets */ | ||
64 | |||
65 | /* MAC's Command Frames Identifiers */ | 59 | /* MAC's Command Frames Identifiers */ |
66 | #define IEEE802154_CMD_ASSOCIATION_REQ 0x01 | 60 | #define IEEE802154_CMD_ASSOCIATION_REQ 0x01 |
67 | #define IEEE802154_CMD_ASSOCIATION_RESP 0x02 | 61 | #define IEEE802154_CMD_ASSOCIATION_RESP 0x02 |
diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h index d104c882fc2..57430555487 100644 --- a/include/net/ieee802154_netdev.h +++ b/include/net/ieee802154_netdev.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * An interface between IEEE802.15.4 device and rest of the kernel. | 2 | * An interface between IEEE802.15.4 device and rest of the kernel. |
3 | * | 3 | * |
4 | * Copyright (C) 2007-2012 Siemens AG | 4 | * Copyright (C) 2007, 2008, 2009 Siemens AG |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 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 | 7 | * it under the terms of the GNU General Public License version 2 |
@@ -21,14 +21,11 @@ | |||
21 | * Maxim Gorbachyov <maxim.gorbachev@siemens.com> | 21 | * Maxim Gorbachyov <maxim.gorbachev@siemens.com> |
22 | * Maxim Osipov <maxim.osipov@siemens.com> | 22 | * Maxim Osipov <maxim.osipov@siemens.com> |
23 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 23 | * Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
24 | * Alexander Smirnov <alex.bluesman.smirnov@gmail.com> | ||
25 | */ | 24 | */ |
26 | 25 | ||
27 | #ifndef IEEE802154_NETDEVICE_H | 26 | #ifndef IEEE802154_NETDEVICE_H |
28 | #define IEEE802154_NETDEVICE_H | 27 | #define IEEE802154_NETDEVICE_H |
29 | 28 | ||
30 | #include <net/af_ieee802154.h> | ||
31 | |||
32 | /* | 29 | /* |
33 | * A control block of skb passed between the ARPHRD_IEEE802154 device | 30 | * A control block of skb passed between the ARPHRD_IEEE802154 device |
34 | * and other stack parts. | 31 | * and other stack parts. |
@@ -113,26 +110,12 @@ struct ieee802154_mlme_ops { | |||
113 | u8 (*get_bsn)(const struct net_device *dev); | 110 | u8 (*get_bsn)(const struct net_device *dev); |
114 | }; | 111 | }; |
115 | 112 | ||
116 | /* The IEEE 802.15.4 standard defines 2 type of the devices: | 113 | static inline struct ieee802154_mlme_ops *ieee802154_mlme_ops( |
117 | * - FFD - full functionality device | 114 | const struct net_device *dev) |
118 | * - RFD - reduce functionality device | ||
119 | * | ||
120 | * So 2 sets of mlme operations are needed | ||
121 | */ | ||
122 | struct ieee802154_reduced_mlme_ops { | ||
123 | struct wpan_phy *(*get_phy)(const struct net_device *dev); | ||
124 | }; | ||
125 | |||
126 | static inline struct ieee802154_mlme_ops * | ||
127 | ieee802154_mlme_ops(const struct net_device *dev) | ||
128 | { | ||
129 | return dev->ml_priv; | ||
130 | } | ||
131 | |||
132 | static inline struct ieee802154_reduced_mlme_ops * | ||
133 | ieee802154_reduced_mlme_ops(const struct net_device *dev) | ||
134 | { | 115 | { |
135 | return dev->ml_priv; | 116 | return dev->ml_priv; |
136 | } | 117 | } |
137 | 118 | ||
138 | #endif | 119 | #endif |
120 | |||
121 | |||
diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h index 93563221d29..51a7031b4aa 100644 --- a/include/net/if_inet6.h +++ b/include/net/if_inet6.h | |||
@@ -120,7 +120,7 @@ struct ifmcaddr6 { | |||
120 | unsigned char mca_crcount; | 120 | unsigned char mca_crcount; |
121 | unsigned long mca_sfcount[2]; | 121 | unsigned long mca_sfcount[2]; |
122 | struct timer_list mca_timer; | 122 | struct timer_list mca_timer; |
123 | unsigned int mca_flags; | 123 | unsigned mca_flags; |
124 | int mca_users; | 124 | int mca_users; |
125 | atomic_t mca_refcnt; | 125 | atomic_t mca_refcnt; |
126 | spinlock_t mca_lock; | 126 | spinlock_t mca_lock; |
@@ -209,6 +209,60 @@ static inline void ipv6_eth_mc_map(const struct in6_addr *addr, char *buf) | |||
209 | memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32)); | 209 | memcpy(buf + 2, &addr->s6_addr32[3], sizeof(__u32)); |
210 | } | 210 | } |
211 | 211 | ||
212 | static inline void ipv6_tr_mc_map(const struct in6_addr *addr, char *buf) | ||
213 | { | ||
214 | /* All nodes FF01::1, FF02::1, FF02::1:FFxx:xxxx */ | ||
215 | |||
216 | if (((addr->s6_addr[0] == 0xFF) && | ||
217 | ((addr->s6_addr[1] == 0x01) || (addr->s6_addr[1] == 0x02)) && | ||
218 | (addr->s6_addr16[1] == 0) && | ||
219 | (addr->s6_addr32[1] == 0) && | ||
220 | (addr->s6_addr32[2] == 0) && | ||
221 | (addr->s6_addr16[6] == 0) && | ||
222 | (addr->s6_addr[15] == 1)) || | ||
223 | ((addr->s6_addr[0] == 0xFF) && | ||
224 | (addr->s6_addr[1] == 0x02) && | ||
225 | (addr->s6_addr16[1] == 0) && | ||
226 | (addr->s6_addr32[1] == 0) && | ||
227 | (addr->s6_addr16[4] == 0) && | ||
228 | (addr->s6_addr[10] == 0) && | ||
229 | (addr->s6_addr[11] == 1) && | ||
230 | (addr->s6_addr[12] == 0xff))) | ||
231 | { | ||
232 | buf[0]=0xC0; | ||
233 | buf[1]=0x00; | ||
234 | buf[2]=0x01; | ||
235 | buf[3]=0x00; | ||
236 | buf[4]=0x00; | ||
237 | buf[5]=0x00; | ||
238 | /* All routers FF0x::2 */ | ||
239 | } else if ((addr->s6_addr[0] ==0xff) && | ||
240 | ((addr->s6_addr[1] & 0xF0) == 0) && | ||
241 | (addr->s6_addr16[1] == 0) && | ||
242 | (addr->s6_addr32[1] == 0) && | ||
243 | (addr->s6_addr32[2] == 0) && | ||
244 | (addr->s6_addr16[6] == 0) && | ||
245 | (addr->s6_addr[15] == 2)) | ||
246 | { | ||
247 | buf[0]=0xC0; | ||
248 | buf[1]=0x00; | ||
249 | buf[2]=0x02; | ||
250 | buf[3]=0x00; | ||
251 | buf[4]=0x00; | ||
252 | buf[5]=0x00; | ||
253 | } else { | ||
254 | unsigned char i ; | ||
255 | |||
256 | i = addr->s6_addr[15] & 7 ; | ||
257 | buf[0]=0xC0; | ||
258 | buf[1]=0x00; | ||
259 | buf[2]=0x00; | ||
260 | buf[3]=0x01 << i ; | ||
261 | buf[4]=0x00; | ||
262 | buf[5]=0x00; | ||
263 | } | ||
264 | } | ||
265 | |||
212 | static inline void ipv6_arcnet_mc_map(const struct in6_addr *addr, char *buf) | 266 | static inline void ipv6_arcnet_mc_map(const struct in6_addr *addr, char *buf) |
213 | { | 267 | { |
214 | buf[0] = 0x00; | 268 | buf[0] = 0x00; |
diff --git a/include/net/inet6_connection_sock.h b/include/net/inet6_connection_sock.h index 04642c92043..3207e58ee01 100644 --- a/include/net/inet6_connection_sock.h +++ b/include/net/inet6_connection_sock.h | |||
@@ -23,10 +23,9 @@ struct sock; | |||
23 | struct sockaddr; | 23 | struct sockaddr; |
24 | 24 | ||
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, bool relax); | 26 | const struct inet_bind_bucket *tb); |
27 | 27 | ||
28 | extern struct dst_entry* inet6_csk_route_req(struct sock *sk, | 28 | extern struct dst_entry* inet6_csk_route_req(struct sock *sk, |
29 | struct flowi6 *fl6, | ||
30 | const struct request_sock *req); | 29 | const struct request_sock *req); |
31 | 30 | ||
32 | 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, |
@@ -43,6 +42,4 @@ extern void inet6_csk_reqsk_queue_hash_add(struct sock *sk, | |||
43 | extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); | 42 | extern void inet6_csk_addr2sockaddr(struct sock *sk, struct sockaddr *uaddr); |
44 | 43 | ||
45 | extern int inet6_csk_xmit(struct sk_buff *skb, struct flowi *fl); | 44 | extern int inet6_csk_xmit(struct sk_buff *skb, struct flowi *fl); |
46 | |||
47 | extern struct dst_entry *inet6_csk_update_pmtu(struct sock *sk, u32 mtu); | ||
48 | #endif /* _INET6_CONNECTION_SOCK_H */ | 45 | #endif /* _INET6_CONNECTION_SOCK_H */ |
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 9e34c877a77..e46674d5dae 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h | |||
@@ -15,7 +15,7 @@ | |||
15 | #define _INET6_HASHTABLES_H | 15 | #define _INET6_HASHTABLES_H |
16 | 16 | ||
17 | 17 | ||
18 | #if IS_ENABLED(CONFIG_IPV6) | 18 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
19 | #include <linux/in6.h> | 19 | #include <linux/in6.h> |
20 | #include <linux/ipv6.h> | 20 | #include <linux/ipv6.h> |
21 | #include <linux/types.h> | 21 | #include <linux/types.h> |
@@ -96,20 +96,19 @@ static inline struct sock *__inet6_lookup_skb(struct inet_hashinfo *hashinfo, | |||
96 | const __be16 sport, | 96 | const __be16 sport, |
97 | const __be16 dport) | 97 | const __be16 dport) |
98 | { | 98 | { |
99 | struct sock *sk = skb_steal_sock(skb); | 99 | struct sock *sk; |
100 | 100 | ||
101 | if (sk) | 101 | if (unlikely(sk = skb_steal_sock(skb))) |
102 | return sk; | 102 | return sk; |
103 | 103 | else return __inet6_lookup(dev_net(skb_dst(skb)->dev), hashinfo, | |
104 | return __inet6_lookup(dev_net(skb_dst(skb)->dev), hashinfo, | 104 | &ipv6_hdr(skb)->saddr, sport, |
105 | &ipv6_hdr(skb)->saddr, sport, | 105 | &ipv6_hdr(skb)->daddr, ntohs(dport), |
106 | &ipv6_hdr(skb)->daddr, ntohs(dport), | 106 | inet6_iif(skb)); |
107 | inet6_iif(skb)); | ||
108 | } | 107 | } |
109 | 108 | ||
110 | extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, | 109 | extern struct sock *inet6_lookup(struct net *net, struct inet_hashinfo *hashinfo, |
111 | const struct in6_addr *saddr, const __be16 sport, | 110 | const struct in6_addr *saddr, const __be16 sport, |
112 | const struct in6_addr *daddr, const __be16 dport, | 111 | const struct in6_addr *daddr, const __be16 dport, |
113 | const int dif); | 112 | const int dif); |
114 | #endif /* IS_ENABLED(CONFIG_IPV6) */ | 113 | #endif /* defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) */ |
115 | #endif /* _INET6_HASHTABLES_H */ | 114 | #endif /* _INET6_HASHTABLES_H */ |
diff --git a/include/net/inet_common.h b/include/net/inet_common.h index 234008782c8..22fac9892b1 100644 --- a/include/net/inet_common.h +++ b/include/net/inet_common.h | |||
@@ -14,11 +14,9 @@ struct sockaddr; | |||
14 | struct socket; | 14 | struct socket; |
15 | 15 | ||
16 | extern int inet_release(struct socket *sock); | 16 | extern int inet_release(struct socket *sock); |
17 | extern int inet_stream_connect(struct socket *sock, struct sockaddr *uaddr, | 17 | extern int inet_stream_connect(struct socket *sock, struct sockaddr * uaddr, |
18 | int addr_len, int flags); | 18 | int addr_len, int flags); |
19 | extern int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr, | 19 | extern int inet_dgram_connect(struct socket *sock, struct sockaddr * uaddr, |
20 | int addr_len, int flags); | ||
21 | extern int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr, | ||
22 | int addr_len, int flags); | 20 | int addr_len, int flags); |
23 | extern int inet_accept(struct socket *sock, struct socket *newsock, int flags); | 21 | extern int inet_accept(struct socket *sock, struct socket *newsock, int flags); |
24 | extern int inet_sendmsg(struct kiocb *iocb, struct socket *sock, | 22 | extern int inet_sendmsg(struct kiocb *iocb, struct socket *sock, |
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 183292722f6..e6db62e756d 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h | |||
@@ -39,13 +39,12 @@ struct inet_connection_sock_af_ops { | |||
39 | int (*queue_xmit)(struct sk_buff *skb, struct flowi *fl); | 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 | void (*sk_rx_dst_set)(struct sock *sk, const struct sk_buff *skb); | ||
43 | int (*conn_request)(struct sock *sk, struct sk_buff *skb); | 42 | int (*conn_request)(struct sock *sk, struct sk_buff *skb); |
44 | 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, |
45 | struct request_sock *req, | 44 | struct request_sock *req, |
46 | struct dst_entry *dst); | 45 | struct dst_entry *dst); |
46 | struct inet_peer *(*get_peer)(struct sock *sk, bool *release_it); | ||
47 | u16 net_header_len; | 47 | u16 net_header_len; |
48 | u16 net_frag_header_len; | ||
49 | u16 sockaddr_len; | 48 | u16 sockaddr_len; |
50 | int (*setsockopt)(struct sock *sk, int level, int optname, | 49 | int (*setsockopt)(struct sock *sk, int level, int optname, |
51 | char __user *optval, unsigned int optlen); | 50 | char __user *optval, unsigned int optlen); |
@@ -61,7 +60,7 @@ struct inet_connection_sock_af_ops { | |||
61 | #endif | 60 | #endif |
62 | void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); | 61 | void (*addr2sockaddr)(struct sock *sk, struct sockaddr *); |
63 | int (*bind_conflict)(const struct sock *sk, | 62 | int (*bind_conflict)(const struct sock *sk, |
64 | const struct inet_bind_bucket *tb, bool relax); | 63 | const struct inet_bind_bucket *tb); |
65 | }; | 64 | }; |
66 | 65 | ||
67 | /** inet_connection_sock - INET connection oriented sock | 66 | /** inet_connection_sock - INET connection oriented sock |
@@ -144,9 +143,9 @@ static inline void *inet_csk_ca(const struct sock *sk) | |||
144 | return (void *)inet_csk(sk)->icsk_ca_priv; | 143 | return (void *)inet_csk(sk)->icsk_ca_priv; |
145 | } | 144 | } |
146 | 145 | ||
147 | extern struct sock *inet_csk_clone_lock(const struct sock *sk, | 146 | extern struct sock *inet_csk_clone(struct sock *sk, |
148 | const struct request_sock *req, | 147 | const struct request_sock *req, |
149 | const gfp_t priority); | 148 | const gfp_t priority); |
150 | 149 | ||
151 | enum inet_csk_ack_state_t { | 150 | enum inet_csk_ack_state_t { |
152 | ICSK_ACK_SCHED = 1, | 151 | ICSK_ACK_SCHED = 1, |
@@ -246,7 +245,7 @@ extern struct request_sock *inet_csk_search_req(const struct sock *sk, | |||
246 | const __be32 raddr, | 245 | const __be32 raddr, |
247 | const __be32 laddr); | 246 | const __be32 laddr); |
248 | extern int inet_csk_bind_conflict(const struct sock *sk, | 247 | extern int inet_csk_bind_conflict(const struct sock *sk, |
249 | const struct inet_bind_bucket *tb, bool relax); | 248 | const struct inet_bind_bucket *tb); |
250 | 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); |
251 | 250 | ||
252 | extern struct dst_entry* inet_csk_route_req(struct sock *sk, | 251 | extern struct dst_entry* inet_csk_route_req(struct sock *sk, |
@@ -318,7 +317,6 @@ extern void inet_csk_reqsk_queue_prune(struct sock *parent, | |||
318 | const unsigned long max_rto); | 317 | const unsigned long max_rto); |
319 | 318 | ||
320 | extern void inet_csk_destroy_sock(struct sock *sk); | 319 | extern void inet_csk_destroy_sock(struct sock *sk); |
321 | extern void inet_csk_prepare_forced_close(struct sock *sk); | ||
322 | 320 | ||
323 | /* | 321 | /* |
324 | * LISTEN is a special case for poll.. | 322 | * LISTEN is a special case for poll.. |
@@ -338,6 +336,4 @@ extern int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname, | |||
338 | char __user *optval, int __user *optlen); | 336 | char __user *optval, int __user *optlen); |
339 | extern int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, | 337 | extern int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname, |
340 | char __user *optval, unsigned int optlen); | 338 | char __user *optval, unsigned int optlen); |
341 | |||
342 | extern struct dst_entry *inet_csk_update_pmtu(struct sock *sk, u32 mtu); | ||
343 | #endif /* _INET_CONNECTION_SOCK_H */ | 339 | #endif /* _INET_CONNECTION_SOCK_H */ |
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h index aab73757bc4..2fa8d1341a0 100644 --- a/include/net/inet_ecn.h +++ b/include/net/inet_ecn.h | |||
@@ -15,8 +15,6 @@ enum { | |||
15 | INET_ECN_MASK = 3, | 15 | INET_ECN_MASK = 3, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | extern int sysctl_tunnel_ecn_log; | ||
19 | |||
20 | static inline int INET_ECN_is_ce(__u8 dsfield) | 18 | static inline int INET_ECN_is_ce(__u8 dsfield) |
21 | { | 19 | { |
22 | return (dsfield & INET_ECN_MASK) == INET_ECN_CE; | 20 | return (dsfield & INET_ECN_MASK) == INET_ECN_CE; |
@@ -32,14 +30,6 @@ static inline int INET_ECN_is_capable(__u8 dsfield) | |||
32 | return dsfield & INET_ECN_ECT_0; | 30 | return dsfield & INET_ECN_ECT_0; |
33 | } | 31 | } |
34 | 32 | ||
35 | /* | ||
36 | * RFC 3168 9.1.1 | ||
37 | * The full-functionality option for ECN encapsulation is to copy the | ||
38 | * ECN codepoint of the inside header to the outside header on | ||
39 | * encapsulation if the inside header is not-ECT or ECT, and to set the | ||
40 | * ECN codepoint of the outside header to ECT(0) if the ECN codepoint of | ||
41 | * the inside header is CE. | ||
42 | */ | ||
43 | static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) | 33 | static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) |
44 | { | 34 | { |
45 | outer &= ~INET_ECN_MASK; | 35 | outer &= ~INET_ECN_MASK; |
@@ -147,78 +137,4 @@ static inline int INET_ECN_set_ce(struct sk_buff *skb) | |||
147 | return 0; | 137 | return 0; |
148 | } | 138 | } |
149 | 139 | ||
150 | /* | ||
151 | * RFC 6080 4.2 | ||
152 | * To decapsulate the inner header at the tunnel egress, a compliant | ||
153 | * tunnel egress MUST set the outgoing ECN field to the codepoint at the | ||
154 | * intersection of the appropriate arriving inner header (row) and outer | ||
155 | * header (column) in Figure 4 | ||
156 | * | ||
157 | * +---------+------------------------------------------------+ | ||
158 | * |Arriving | Arriving Outer Header | | ||
159 | * | Inner +---------+------------+------------+------------+ | ||
160 | * | Header | Not-ECT | ECT(0) | ECT(1) | CE | | ||
161 | * +---------+---------+------------+------------+------------+ | ||
162 | * | Not-ECT | Not-ECT |Not-ECT(!!!)|Not-ECT(!!!)| <drop>(!!!)| | ||
163 | * | ECT(0) | ECT(0) | ECT(0) | ECT(1) | CE | | ||
164 | * | ECT(1) | ECT(1) | ECT(1) (!) | ECT(1) | CE | | ||
165 | * | CE | CE | CE | CE(!!!)| CE | | ||
166 | * +---------+---------+------------+------------+------------+ | ||
167 | * | ||
168 | * Figure 4: New IP in IP Decapsulation Behaviour | ||
169 | * | ||
170 | * returns 0 on success | ||
171 | * 1 if something is broken and should be logged (!!! above) | ||
172 | * 2 if packet should be dropped | ||
173 | */ | ||
174 | static inline int INET_ECN_decapsulate(struct sk_buff *skb, | ||
175 | __u8 outer, __u8 inner) | ||
176 | { | ||
177 | if (INET_ECN_is_not_ect(inner)) { | ||
178 | switch (outer & INET_ECN_MASK) { | ||
179 | case INET_ECN_NOT_ECT: | ||
180 | return 0; | ||
181 | case INET_ECN_ECT_0: | ||
182 | case INET_ECN_ECT_1: | ||
183 | return 1; | ||
184 | case INET_ECN_CE: | ||
185 | return 2; | ||
186 | } | ||
187 | } | ||
188 | |||
189 | if (INET_ECN_is_ce(outer)) | ||
190 | INET_ECN_set_ce(skb); | ||
191 | |||
192 | return 0; | ||
193 | } | ||
194 | |||
195 | static inline int IP_ECN_decapsulate(const struct iphdr *oiph, | ||
196 | struct sk_buff *skb) | ||
197 | { | ||
198 | __u8 inner; | ||
199 | |||
200 | if (skb->protocol == htons(ETH_P_IP)) | ||
201 | inner = ip_hdr(skb)->tos; | ||
202 | else if (skb->protocol == htons(ETH_P_IPV6)) | ||
203 | inner = ipv6_get_dsfield(ipv6_hdr(skb)); | ||
204 | else | ||
205 | return 0; | ||
206 | |||
207 | return INET_ECN_decapsulate(skb, oiph->tos, inner); | ||
208 | } | ||
209 | |||
210 | static inline int IP6_ECN_decapsulate(const struct ipv6hdr *oipv6h, | ||
211 | struct sk_buff *skb) | ||
212 | { | ||
213 | __u8 inner; | ||
214 | |||
215 | if (skb->protocol == htons(ETH_P_IP)) | ||
216 | inner = ip_hdr(skb)->tos; | ||
217 | else if (skb->protocol == htons(ETH_P_IPV6)) | ||
218 | inner = ipv6_get_dsfield(ipv6_hdr(skb)); | ||
219 | else | ||
220 | return 0; | ||
221 | |||
222 | return INET_ECN_decapsulate(skb, ipv6_get_dsfield(oipv6h), inner); | ||
223 | } | ||
224 | #endif | 140 | #endif |
diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index 32786a04471..16ff29a7bb3 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h | |||
@@ -29,8 +29,6 @@ struct inet_frag_queue { | |||
29 | #define INET_FRAG_COMPLETE 4 | 29 | #define INET_FRAG_COMPLETE 4 |
30 | #define INET_FRAG_FIRST_IN 2 | 30 | #define INET_FRAG_FIRST_IN 2 |
31 | #define INET_FRAG_LAST_IN 1 | 31 | #define INET_FRAG_LAST_IN 1 |
32 | |||
33 | u16 max_size; | ||
34 | }; | 32 | }; |
35 | 33 | ||
36 | #define INETFRAGS_HASHSZ 64 | 34 | #define INETFRAGS_HASHSZ 64 |
@@ -48,7 +46,8 @@ struct inet_frags { | |||
48 | void *arg); | 46 | void *arg); |
49 | void (*destructor)(struct inet_frag_queue *); | 47 | void (*destructor)(struct inet_frag_queue *); |
50 | void (*skb_free)(struct sk_buff *); | 48 | void (*skb_free)(struct sk_buff *); |
51 | bool (*match)(struct inet_frag_queue *q, void *arg); | 49 | int (*match)(struct inet_frag_queue *q, |
50 | void *arg); | ||
52 | void (*frag_expire)(unsigned long data); | 51 | void (*frag_expire)(unsigned long data); |
53 | }; | 52 | }; |
54 | 53 | ||
@@ -61,7 +60,7 @@ void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f); | |||
61 | void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); | 60 | void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); |
62 | void inet_frag_destroy(struct inet_frag_queue *q, | 61 | void inet_frag_destroy(struct inet_frag_queue *q, |
63 | struct inet_frags *f, int *work); | 62 | struct inet_frags *f, int *work); |
64 | int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f, bool force); | 63 | int inet_frag_evictor(struct netns_frags *nf, struct inet_frags *f); |
65 | struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, | 64 | struct inet_frag_queue *inet_frag_find(struct netns_frags *nf, |
66 | struct inet_frags *f, void *key, unsigned int hash) | 65 | struct inet_frags *f, void *key, unsigned int hash) |
67 | __releases(&f->lock); | 66 | __releases(&f->lock); |
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 67a8fa098e3..808fc5f76b0 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -277,6 +277,7 @@ static inline struct sock *inet_lookup_listener(struct net *net, | |||
277 | On 64bit targets we combine comparisons with pair of adjacent __be32 | 277 | On 64bit targets we combine comparisons with pair of adjacent __be32 |
278 | fields in the same way. | 278 | fields in the same way. |
279 | */ | 279 | */ |
280 | typedef __u32 __bitwise __portpair; | ||
280 | #ifdef __BIG_ENDIAN | 281 | #ifdef __BIG_ENDIAN |
281 | #define INET_COMBINED_PORTS(__sport, __dport) \ | 282 | #define INET_COMBINED_PORTS(__sport, __dport) \ |
282 | ((__force __portpair)(((__force __u32)(__be16)(__sport) << 16) | (__u32)(__dport))) | 283 | ((__force __portpair)(((__force __u32)(__be16)(__sport) << 16) | (__u32)(__dport))) |
@@ -286,6 +287,7 @@ static inline struct sock *inet_lookup_listener(struct net *net, | |||
286 | #endif | 287 | #endif |
287 | 288 | ||
288 | #if (BITS_PER_LONG == 64) | 289 | #if (BITS_PER_LONG == 64) |
290 | typedef __u64 __bitwise __addrpair; | ||
289 | #ifdef __BIG_ENDIAN | 291 | #ifdef __BIG_ENDIAN |
290 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ | 292 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ |
291 | const __addrpair __name = (__force __addrpair) ( \ | 293 | const __addrpair __name = (__force __addrpair) ( \ |
@@ -297,34 +299,30 @@ static inline struct sock *inet_lookup_listener(struct net *net, | |||
297 | (((__force __u64)(__be32)(__daddr)) << 32) | \ | 299 | (((__force __u64)(__be32)(__daddr)) << 32) | \ |
298 | ((__force __u64)(__be32)(__saddr))); | 300 | ((__force __u64)(__be32)(__saddr))); |
299 | #endif /* __BIG_ENDIAN */ | 301 | #endif /* __BIG_ENDIAN */ |
300 | #define INET_MATCH(__sk, __net, __cookie, __saddr, __daddr, __ports, __dif) \ | 302 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
301 | ((inet_sk(__sk)->inet_portpair == (__ports)) && \ | 303 | (((__sk)->sk_hash == (__hash)) && net_eq(sock_net(__sk), (__net)) && \ |
302 | (inet_sk(__sk)->inet_addrpair == (__cookie)) && \ | 304 | ((*((__addrpair *)&(inet_sk(__sk)->inet_daddr))) == (__cookie)) && \ |
303 | (!(__sk)->sk_bound_dev_if || \ | 305 | ((*((__portpair *)&(inet_sk(__sk)->inet_dport))) == (__ports)) && \ |
304 | ((__sk)->sk_bound_dev_if == (__dif))) && \ | 306 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
305 | net_eq(sock_net(__sk), (__net))) | 307 | #define INET_TW_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
306 | #define INET_TW_MATCH(__sk, __net, __cookie, __saddr, __daddr, __ports, __dif)\ | 308 | (((__sk)->sk_hash == (__hash)) && net_eq(sock_net(__sk), (__net)) && \ |
307 | ((inet_twsk(__sk)->tw_portpair == (__ports)) && \ | 309 | ((*((__addrpair *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ |
308 | (inet_twsk(__sk)->tw_addrpair == (__cookie)) && \ | 310 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
309 | (!(__sk)->sk_bound_dev_if || \ | 311 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
310 | ((__sk)->sk_bound_dev_if == (__dif))) && \ | ||
311 | net_eq(sock_net(__sk), (__net))) | ||
312 | #else /* 32-bit arch */ | 312 | #else /* 32-bit arch */ |
313 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) | 313 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) |
314 | #define INET_MATCH(__sk, __net, __cookie, __saddr, __daddr, __ports, __dif) \ | 314 | #define INET_MATCH(__sk, __net, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ |
315 | ((inet_sk(__sk)->inet_portpair == (__ports)) && \ | 315 | (((__sk)->sk_hash == (__hash)) && net_eq(sock_net(__sk), (__net)) && \ |
316 | (inet_sk(__sk)->inet_daddr == (__saddr)) && \ | 316 | (inet_sk(__sk)->inet_daddr == (__saddr)) && \ |
317 | (inet_sk(__sk)->inet_rcv_saddr == (__daddr)) && \ | 317 | (inet_sk(__sk)->inet_rcv_saddr == (__daddr)) && \ |
318 | (!(__sk)->sk_bound_dev_if || \ | 318 | ((*((__portpair *)&(inet_sk(__sk)->inet_dport))) == (__ports)) && \ |
319 | ((__sk)->sk_bound_dev_if == (__dif))) && \ | 319 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
320 | net_eq(sock_net(__sk), (__net))) | 320 | #define INET_TW_MATCH(__sk, __net, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ |
321 | #define INET_TW_MATCH(__sk, __net, __cookie, __saddr, __daddr, __ports, __dif) \ | 321 | (((__sk)->sk_hash == (__hash)) && net_eq(sock_net(__sk), (__net)) && \ |
322 | ((inet_twsk(__sk)->tw_portpair == (__ports)) && \ | 322 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ |
323 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ | 323 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ |
324 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ | 324 | ((*((__portpair *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
325 | (!(__sk)->sk_bound_dev_if || \ | 325 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
326 | ((__sk)->sk_bound_dev_if == (__dif))) && \ | ||
327 | net_eq(sock_net(__sk), (__net))) | ||
328 | #endif /* 64-bit arch */ | 326 | #endif /* 64-bit arch */ |
329 | 327 | ||
330 | /* | 328 | /* |
@@ -381,10 +379,10 @@ static inline struct sock *__inet_lookup_skb(struct inet_hashinfo *hashinfo, | |||
381 | const __be16 sport, | 379 | const __be16 sport, |
382 | const __be16 dport) | 380 | const __be16 dport) |
383 | { | 381 | { |
384 | struct sock *sk = skb_steal_sock(skb); | 382 | struct sock *sk; |
385 | const struct iphdr *iph = ip_hdr(skb); | 383 | const struct iphdr *iph = ip_hdr(skb); |
386 | 384 | ||
387 | if (sk) | 385 | if (unlikely(sk = skb_steal_sock(skb))) |
388 | return sk; | 386 | return sk; |
389 | else | 387 | else |
390 | return __inet_lookup(dev_net(skb_dst(skb)->dev), hashinfo, | 388 | return __inet_lookup(dev_net(skb_dst(skb)->dev), hashinfo, |
diff --git a/include/net/inet_sock.h b/include/net/inet_sock.h index a4196cbc84e..b897d6e6d0a 100644 --- a/include/net/inet_sock.h +++ b/include/net/inet_sock.h | |||
@@ -31,7 +31,6 @@ | |||
31 | /** struct ip_options - IP Options | 31 | /** struct ip_options - IP Options |
32 | * | 32 | * |
33 | * @faddr - Saved first hop address | 33 | * @faddr - Saved first hop address |
34 | * @nexthop - Saved nexthop address in LSRR and SSRR | ||
35 | * @is_data - Options in __data, rather than skb | 34 | * @is_data - Options in __data, rather than skb |
36 | * @is_strictroute - Strict source route | 35 | * @is_strictroute - Strict source route |
37 | * @srr_is_hit - Packet destination addr was our one | 36 | * @srr_is_hit - Packet destination addr was our one |
@@ -42,7 +41,6 @@ | |||
42 | */ | 41 | */ |
43 | struct ip_options { | 42 | struct ip_options { |
44 | __be32 faddr; | 43 | __be32 faddr; |
45 | __be32 nexthop; | ||
46 | unsigned char optlen; | 44 | unsigned char optlen; |
47 | unsigned char srr; | 45 | unsigned char srr; |
48 | unsigned char rr; | 46 | unsigned char rr; |
@@ -71,7 +69,7 @@ struct ip_options_data { | |||
71 | 69 | ||
72 | struct inet_request_sock { | 70 | struct inet_request_sock { |
73 | struct request_sock req; | 71 | struct request_sock req; |
74 | #if IS_ENABLED(CONFIG_IPV6) | 72 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
75 | u16 inet6_rsk_offset; | 73 | u16 inet6_rsk_offset; |
76 | #endif | 74 | #endif |
77 | __be16 loc_port; | 75 | __be16 loc_port; |
@@ -101,8 +99,10 @@ struct inet_cork { | |||
101 | __be32 addr; | 99 | __be32 addr; |
102 | struct ip_options *opt; | 100 | struct ip_options *opt; |
103 | unsigned int fragsize; | 101 | unsigned int fragsize; |
104 | int length; /* Total length of all frames */ | ||
105 | struct dst_entry *dst; | 102 | struct dst_entry *dst; |
103 | int length; /* Total length of all frames */ | ||
104 | struct page *page; | ||
105 | u32 off; | ||
106 | u8 tx_flags; | 106 | u8 tx_flags; |
107 | }; | 107 | }; |
108 | 108 | ||
@@ -130,7 +130,6 @@ struct rtable; | |||
130 | * @tos - TOS | 130 | * @tos - TOS |
131 | * @mc_ttl - Multicasting TTL | 131 | * @mc_ttl - Multicasting TTL |
132 | * @is_icsk - is this an inet_connection_sock? | 132 | * @is_icsk - is this an inet_connection_sock? |
133 | * @uc_index - Unicast outgoing device index | ||
134 | * @mc_index - Multicast device index | 133 | * @mc_index - Multicast device index |
135 | * @mc_list - Group array | 134 | * @mc_list - Group array |
136 | * @cork - info to build ip hdr on each ip frag while socket is corked | 135 | * @cork - info to build ip hdr on each ip frag while socket is corked |
@@ -138,17 +137,15 @@ struct rtable; | |||
138 | struct inet_sock { | 137 | struct inet_sock { |
139 | /* sk and pinet6 has to be the first two members of inet_sock */ | 138 | /* sk and pinet6 has to be the first two members of inet_sock */ |
140 | struct sock sk; | 139 | struct sock sk; |
141 | #if IS_ENABLED(CONFIG_IPV6) | 140 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
142 | struct ipv6_pinfo *pinet6; | 141 | struct ipv6_pinfo *pinet6; |
143 | #endif | 142 | #endif |
144 | /* Socket demultiplex comparisons on incoming packets. */ | 143 | /* Socket demultiplex comparisons on incoming packets. */ |
145 | #define inet_daddr sk.__sk_common.skc_daddr | 144 | #define inet_daddr sk.__sk_common.skc_daddr |
146 | #define inet_rcv_saddr sk.__sk_common.skc_rcv_saddr | 145 | #define inet_rcv_saddr sk.__sk_common.skc_rcv_saddr |
147 | #define inet_addrpair sk.__sk_common.skc_addrpair | ||
148 | #define inet_dport sk.__sk_common.skc_dport | ||
149 | #define inet_num sk.__sk_common.skc_num | ||
150 | #define inet_portpair sk.__sk_common.skc_portpair | ||
151 | 146 | ||
147 | __be16 inet_dport; | ||
148 | __u16 inet_num; | ||
152 | __be32 inet_saddr; | 149 | __be32 inet_saddr; |
153 | __s16 uc_ttl; | 150 | __s16 uc_ttl; |
154 | __u16 cmsg_flags; | 151 | __u16 cmsg_flags; |
@@ -156,7 +153,6 @@ struct inet_sock { | |||
156 | __u16 inet_id; | 153 | __u16 inet_id; |
157 | 154 | ||
158 | struct ip_options_rcu __rcu *inet_opt; | 155 | struct ip_options_rcu __rcu *inet_opt; |
159 | int rx_dst_ifindex; | ||
160 | __u8 tos; | 156 | __u8 tos; |
161 | __u8 min_ttl; | 157 | __u8 min_ttl; |
162 | __u8 mc_ttl; | 158 | __u8 mc_ttl; |
@@ -169,8 +165,6 @@ struct inet_sock { | |||
169 | transparent:1, | 165 | transparent:1, |
170 | mc_all:1, | 166 | mc_all:1, |
171 | nodefrag:1; | 167 | nodefrag:1; |
172 | __u8 rcv_tos; | ||
173 | int uc_index; | ||
174 | int mc_index; | 168 | int mc_index; |
175 | __be32 mc_addr; | 169 | __be32 mc_addr; |
176 | struct ip_mc_socklist __rcu *mc_list; | 170 | struct ip_mc_socklist __rcu *mc_list; |
@@ -192,7 +186,7 @@ static inline void __inet_sk_copy_descendant(struct sock *sk_to, | |||
192 | memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1, | 186 | memcpy(inet_sk(sk_to) + 1, inet_sk(sk_from) + 1, |
193 | sk_from->sk_prot->obj_size - ancestor_size); | 187 | sk_from->sk_prot->obj_size - ancestor_size); |
194 | } | 188 | } |
195 | #if !(IS_ENABLED(CONFIG_IPV6)) | 189 | #if !(defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)) |
196 | static inline void inet_sk_copy_descendant(struct sock *sk_to, | 190 | static inline void inet_sk_copy_descendant(struct sock *sk_to, |
197 | const struct sock *sk_from) | 191 | const struct sock *sk_from) |
198 | { | 192 | { |
@@ -246,6 +240,8 @@ static inline __u8 inet_sk_flowi_flags(const struct sock *sk) | |||
246 | 240 | ||
247 | if (inet_sk(sk)->transparent || inet_sk(sk)->hdrincl) | 241 | if (inet_sk(sk)->transparent || inet_sk(sk)->hdrincl) |
248 | flags |= FLOWI_FLAG_ANYSRC; | 242 | flags |= FLOWI_FLAG_ANYSRC; |
243 | if (sk->sk_protocol == IPPROTO_TCP) | ||
244 | flags |= FLOWI_FLAG_PRECOW_METRICS; | ||
249 | return flags; | 245 | return flags; |
250 | } | 246 | } |
251 | 247 | ||
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 7d658d57736..f1a770977c4 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h | |||
@@ -18,6 +18,7 @@ | |||
18 | 18 | ||
19 | #include <linux/kmemcheck.h> | 19 | #include <linux/kmemcheck.h> |
20 | #include <linux/list.h> | 20 | #include <linux/list.h> |
21 | #include <linux/module.h> | ||
21 | #include <linux/timer.h> | 22 | #include <linux/timer.h> |
22 | #include <linux/types.h> | 23 | #include <linux/types.h> |
23 | #include <linux/workqueue.h> | 24 | #include <linux/workqueue.h> |
@@ -112,11 +113,6 @@ struct inet_timewait_sock { | |||
112 | #define tw_net __tw_common.skc_net | 113 | #define tw_net __tw_common.skc_net |
113 | #define tw_daddr __tw_common.skc_daddr | 114 | #define tw_daddr __tw_common.skc_daddr |
114 | #define tw_rcv_saddr __tw_common.skc_rcv_saddr | 115 | #define tw_rcv_saddr __tw_common.skc_rcv_saddr |
115 | #define tw_addrpair __tw_common.skc_addrpair | ||
116 | #define tw_dport __tw_common.skc_dport | ||
117 | #define tw_num __tw_common.skc_num | ||
118 | #define tw_portpair __tw_common.skc_portpair | ||
119 | |||
120 | int tw_timeout; | 116 | int tw_timeout; |
121 | volatile unsigned char tw_substate; | 117 | volatile unsigned char tw_substate; |
122 | unsigned char tw_rcv_wscale; | 118 | unsigned char tw_rcv_wscale; |
@@ -124,19 +120,19 @@ struct inet_timewait_sock { | |||
124 | /* Socket demultiplex comparisons on incoming packets. */ | 120 | /* Socket demultiplex comparisons on incoming packets. */ |
125 | /* these three are in inet_sock */ | 121 | /* these three are in inet_sock */ |
126 | __be16 tw_sport; | 122 | __be16 tw_sport; |
123 | __be16 tw_dport; | ||
124 | __u16 tw_num; | ||
127 | kmemcheck_bitfield_begin(flags); | 125 | kmemcheck_bitfield_begin(flags); |
128 | /* And these are ours. */ | 126 | /* And these are ours. */ |
129 | unsigned int tw_ipv6only : 1, | 127 | unsigned int tw_ipv6only : 1, |
130 | tw_transparent : 1, | 128 | tw_transparent : 1, |
131 | tw_pad : 6, /* 6 bits hole */ | 129 | tw_pad : 14, /* 14 bits hole */ |
132 | tw_tos : 8, | ||
133 | tw_ipv6_offset : 16; | 130 | tw_ipv6_offset : 16; |
134 | kmemcheck_bitfield_end(flags); | 131 | kmemcheck_bitfield_end(flags); |
135 | unsigned long tw_ttd; | 132 | unsigned long tw_ttd; |
136 | struct inet_bind_bucket *tw_tb; | 133 | struct inet_bind_bucket *tw_tb; |
137 | struct hlist_node tw_death_node; | 134 | struct hlist_node tw_death_node; |
138 | }; | 135 | }; |
139 | #define tw_tclass tw_tos | ||
140 | 136 | ||
141 | static inline void inet_twsk_add_node_rcu(struct inet_timewait_sock *tw, | 137 | static inline void inet_twsk_add_node_rcu(struct inet_timewait_sock *tw, |
142 | struct hlist_nulls_head *list) | 138 | struct hlist_nulls_head *list) |
@@ -221,12 +217,20 @@ extern void inet_twsk_purge(struct inet_hashinfo *hashinfo, | |||
221 | static inline | 217 | static inline |
222 | struct net *twsk_net(const struct inet_timewait_sock *twsk) | 218 | struct net *twsk_net(const struct inet_timewait_sock *twsk) |
223 | { | 219 | { |
224 | return read_pnet(&twsk->tw_net); | 220 | #ifdef CONFIG_NET_NS |
221 | return rcu_dereference_raw(twsk->tw_net); /* protected by locking, */ | ||
222 | /* reference counting, */ | ||
223 | /* initialization, or RCU. */ | ||
224 | #else | ||
225 | return &init_net; | ||
226 | #endif | ||
225 | } | 227 | } |
226 | 228 | ||
227 | static inline | 229 | static inline |
228 | void twsk_net_set(struct inet_timewait_sock *twsk, struct net *net) | 230 | void twsk_net_set(struct inet_timewait_sock *twsk, struct net *net) |
229 | { | 231 | { |
230 | write_pnet(&twsk->tw_net, net); | 232 | #ifdef CONFIG_NET_NS |
233 | rcu_assign_pointer(twsk->tw_net, net); | ||
234 | #endif | ||
231 | } | 235 | } |
232 | #endif /* _INET_TIMEWAIT_SOCK_ */ | 236 | #endif /* _INET_TIMEWAIT_SOCK_ */ |
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h index 53f464d7cdd..e9ff3fc5e68 100644 --- a/include/net/inetpeer.h +++ b/include/net/inetpeer.h | |||
@@ -35,20 +35,23 @@ struct inet_peer { | |||
35 | 35 | ||
36 | u32 metrics[RTAX_MAX]; | 36 | u32 metrics[RTAX_MAX]; |
37 | u32 rate_tokens; /* rate limiting for ICMP */ | 37 | u32 rate_tokens; /* rate limiting for ICMP */ |
38 | int redirect_genid; | ||
38 | unsigned long rate_last; | 39 | unsigned long rate_last; |
39 | union { | 40 | unsigned long pmtu_expires; |
40 | struct list_head gc_list; | 41 | u32 pmtu_orig; |
41 | struct rcu_head gc_rcu; | 42 | u32 pmtu_learned; |
42 | }; | 43 | struct inetpeer_addr_base redirect_learned; |
43 | /* | 44 | /* |
44 | * Once inet_peer is queued for deletion (refcnt == -1), following fields | 45 | * Once inet_peer is queued for deletion (refcnt == -1), following fields |
45 | * are not available: rid, ip_id_count | 46 | * are not available: rid, ip_id_count, tcp_ts, tcp_ts_stamp |
46 | * We can share memory with rcu_head to help keep inet_peer small. | 47 | * We can share memory with rcu_head to help keep inet_peer small. |
47 | */ | 48 | */ |
48 | union { | 49 | union { |
49 | struct { | 50 | struct { |
50 | atomic_t rid; /* Frag reception counter */ | 51 | atomic_t rid; /* Frag reception counter */ |
51 | atomic_t ip_id_count; /* IP ID for the next packet */ | 52 | atomic_t ip_id_count; /* IP ID for the next packet */ |
53 | __u32 tcp_ts; | ||
54 | __u32 tcp_ts_stamp; | ||
52 | }; | 55 | }; |
53 | struct rcu_head rcu; | 56 | struct rcu_head rcu; |
54 | struct inet_peer *gc_next; | 57 | struct inet_peer *gc_next; |
@@ -59,69 +62,6 @@ struct inet_peer { | |||
59 | atomic_t refcnt; | 62 | atomic_t refcnt; |
60 | }; | 63 | }; |
61 | 64 | ||
62 | struct inet_peer_base { | ||
63 | struct inet_peer __rcu *root; | ||
64 | seqlock_t lock; | ||
65 | u32 flush_seq; | ||
66 | int total; | ||
67 | }; | ||
68 | |||
69 | #define INETPEER_BASE_BIT 0x1UL | ||
70 | |||
71 | static inline struct inet_peer *inetpeer_ptr(unsigned long val) | ||
72 | { | ||
73 | BUG_ON(val & INETPEER_BASE_BIT); | ||
74 | return (struct inet_peer *) val; | ||
75 | } | ||
76 | |||
77 | static inline struct inet_peer_base *inetpeer_base_ptr(unsigned long val) | ||
78 | { | ||
79 | if (!(val & INETPEER_BASE_BIT)) | ||
80 | return NULL; | ||
81 | val &= ~INETPEER_BASE_BIT; | ||
82 | return (struct inet_peer_base *) val; | ||
83 | } | ||
84 | |||
85 | static inline bool inetpeer_ptr_is_peer(unsigned long val) | ||
86 | { | ||
87 | return !(val & INETPEER_BASE_BIT); | ||
88 | } | ||
89 | |||
90 | static inline void __inetpeer_ptr_set_peer(unsigned long *val, struct inet_peer *peer) | ||
91 | { | ||
92 | /* This implicitly clears INETPEER_BASE_BIT */ | ||
93 | *val = (unsigned long) peer; | ||
94 | } | ||
95 | |||
96 | static inline bool inetpeer_ptr_set_peer(unsigned long *ptr, struct inet_peer *peer) | ||
97 | { | ||
98 | unsigned long val = (unsigned long) peer; | ||
99 | unsigned long orig = *ptr; | ||
100 | |||
101 | if (!(orig & INETPEER_BASE_BIT) || | ||
102 | cmpxchg(ptr, orig, val) != orig) | ||
103 | return false; | ||
104 | return true; | ||
105 | } | ||
106 | |||
107 | static inline void inetpeer_init_ptr(unsigned long *ptr, struct inet_peer_base *base) | ||
108 | { | ||
109 | *ptr = (unsigned long) base | INETPEER_BASE_BIT; | ||
110 | } | ||
111 | |||
112 | static inline void inetpeer_transfer_peer(unsigned long *to, unsigned long *from) | ||
113 | { | ||
114 | unsigned long val = *from; | ||
115 | |||
116 | *to = val; | ||
117 | if (inetpeer_ptr_is_peer(val)) { | ||
118 | struct inet_peer *peer = inetpeer_ptr(val); | ||
119 | atomic_inc(&peer->refcnt); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | extern void inet_peer_base_init(struct inet_peer_base *); | ||
124 | |||
125 | void inet_initpeers(void) __init; | 65 | void inet_initpeers(void) __init; |
126 | 66 | ||
127 | #define INETPEER_METRICS_NEW (~(u32) 0) | 67 | #define INETPEER_METRICS_NEW (~(u32) 0) |
@@ -132,39 +72,30 @@ static inline bool inet_metrics_new(const struct inet_peer *p) | |||
132 | } | 72 | } |
133 | 73 | ||
134 | /* can be called with or without local BH being disabled */ | 74 | /* can be called with or without local BH being disabled */ |
135 | struct inet_peer *inet_getpeer(struct inet_peer_base *base, | 75 | struct inet_peer *inet_getpeer(const struct inetpeer_addr *daddr, int create); |
136 | const struct inetpeer_addr *daddr, | ||
137 | int create); | ||
138 | 76 | ||
139 | static inline struct inet_peer *inet_getpeer_v4(struct inet_peer_base *base, | 77 | static inline struct inet_peer *inet_getpeer_v4(__be32 v4daddr, int create) |
140 | __be32 v4daddr, | ||
141 | int create) | ||
142 | { | 78 | { |
143 | struct inetpeer_addr daddr; | 79 | struct inetpeer_addr daddr; |
144 | 80 | ||
145 | daddr.addr.a4 = v4daddr; | 81 | daddr.addr.a4 = v4daddr; |
146 | daddr.family = AF_INET; | 82 | daddr.family = AF_INET; |
147 | return inet_getpeer(base, &daddr, create); | 83 | return inet_getpeer(&daddr, create); |
148 | } | 84 | } |
149 | 85 | ||
150 | static inline struct inet_peer *inet_getpeer_v6(struct inet_peer_base *base, | 86 | static inline struct inet_peer *inet_getpeer_v6(const struct in6_addr *v6daddr, int create) |
151 | const struct in6_addr *v6daddr, | ||
152 | int create) | ||
153 | { | 87 | { |
154 | struct inetpeer_addr daddr; | 88 | struct inetpeer_addr daddr; |
155 | 89 | ||
156 | *(struct in6_addr *)daddr.addr.a6 = *v6daddr; | 90 | ipv6_addr_copy((struct in6_addr *)daddr.addr.a6, v6daddr); |
157 | daddr.family = AF_INET6; | 91 | daddr.family = AF_INET6; |
158 | return inet_getpeer(base, &daddr, create); | 92 | return inet_getpeer(&daddr, create); |
159 | } | 93 | } |
160 | 94 | ||
161 | /* can be called from BH context or outside */ | 95 | /* can be called from BH context or outside */ |
162 | extern void inet_putpeer(struct inet_peer *p); | 96 | extern void inet_putpeer(struct inet_peer *p); |
163 | extern bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout); | 97 | extern bool inet_peer_xrlim_allow(struct inet_peer *peer, int timeout); |
164 | 98 | ||
165 | extern void inetpeer_invalidate_tree(struct inet_peer_base *); | ||
166 | extern void inetpeer_invalidate_family(int family); | ||
167 | |||
168 | /* | 99 | /* |
169 | * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, | 100 | * temporary check to make sure we dont access rid, ip_id_count, tcp_ts, |
170 | * tcp_ts_stamp if no refcount is taken on inet_peer | 101 | * tcp_ts_stamp if no refcount is taken on inet_peer |
diff --git a/include/net/ip.h b/include/net/ip.h index 0707fb9551a..aa76c7a4d9c 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -42,8 +42,6 @@ struct inet_skb_parm { | |||
42 | #define IPSKB_XFRM_TRANSFORMED 4 | 42 | #define IPSKB_XFRM_TRANSFORMED 4 |
43 | #define IPSKB_FRAG_COMPLETE 8 | 43 | #define IPSKB_FRAG_COMPLETE 8 |
44 | #define IPSKB_REROUTED 16 | 44 | #define IPSKB_REROUTED 16 |
45 | |||
46 | u16 frag_max_size; | ||
47 | }; | 45 | }; |
48 | 46 | ||
49 | static inline unsigned int ip_hdrlen(const struct sk_buff *skb) | 47 | static inline unsigned int ip_hdrlen(const struct sk_buff *skb) |
@@ -122,7 +120,7 @@ extern struct sk_buff *__ip_make_skb(struct sock *sk, | |||
122 | struct flowi4 *fl4, | 120 | struct flowi4 *fl4, |
123 | struct sk_buff_head *queue, | 121 | struct sk_buff_head *queue, |
124 | struct inet_cork *cork); | 122 | struct inet_cork *cork); |
125 | extern int ip_send_skb(struct net *net, struct sk_buff *skb); | 123 | extern int ip_send_skb(struct sk_buff *skb); |
126 | extern int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4); | 124 | extern int ip_push_pending_frames(struct sock *sk, struct flowi4 *fl4); |
127 | extern void ip_flush_pending_frames(struct sock *sk); | 125 | extern void ip_flush_pending_frames(struct sock *sk); |
128 | extern struct sk_buff *ip_make_skb(struct sock *sk, | 126 | extern struct sk_buff *ip_make_skb(struct sock *sk, |
@@ -143,6 +141,23 @@ static inline struct sk_buff *ip_finish_skb(struct sock *sk, struct flowi4 *fl4) | |||
143 | extern int ip4_datagram_connect(struct sock *sk, | 141 | extern int ip4_datagram_connect(struct sock *sk, |
144 | struct sockaddr *uaddr, int addr_len); | 142 | struct sockaddr *uaddr, int addr_len); |
145 | 143 | ||
144 | /* | ||
145 | * Map a multicast IP onto multicast MAC for type Token Ring. | ||
146 | * This conforms to RFC1469 Option 2 Multicasting i.e. | ||
147 | * using a functional address to transmit / receive | ||
148 | * multicast packets. | ||
149 | */ | ||
150 | |||
151 | static inline void ip_tr_mc_map(__be32 addr, char *buf) | ||
152 | { | ||
153 | buf[0]=0xC0; | ||
154 | buf[1]=0x00; | ||
155 | buf[2]=0x00; | ||
156 | buf[3]=0x04; | ||
157 | buf[4]=0x00; | ||
158 | buf[5]=0x00; | ||
159 | } | ||
160 | |||
146 | struct ip_reply_arg { | 161 | struct ip_reply_arg { |
147 | struct kvec iov[1]; | 162 | struct kvec iov[1]; |
148 | int flags; | 163 | int flags; |
@@ -150,7 +165,6 @@ struct ip_reply_arg { | |||
150 | int csumoffset; /* u16 offset of csum in iov[0].iov_base */ | 165 | int csumoffset; /* u16 offset of csum in iov[0].iov_base */ |
151 | /* -1 if not needed */ | 166 | /* -1 if not needed */ |
152 | int bound_dev_if; | 167 | int bound_dev_if; |
153 | u8 tos; | ||
154 | }; | 168 | }; |
155 | 169 | ||
156 | #define IP_REPLY_ARG_NOSRCCHECK 1 | 170 | #define IP_REPLY_ARG_NOSRCCHECK 1 |
@@ -160,9 +174,8 @@ static inline __u8 ip_reply_arg_flowi_flags(const struct ip_reply_arg *arg) | |||
160 | return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0; | 174 | return (arg->flags & IP_REPLY_ARG_NOSRCCHECK) ? FLOWI_FLAG_ANYSRC : 0; |
161 | } | 175 | } |
162 | 176 | ||
163 | void ip_send_unicast_reply(struct net *net, struct sk_buff *skb, __be32 daddr, | 177 | void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr, |
164 | __be32 saddr, const struct ip_reply_arg *arg, | 178 | struct ip_reply_arg *arg, unsigned int len); |
165 | unsigned int len); | ||
166 | 179 | ||
167 | struct ipv4_config { | 180 | struct ipv4_config { |
168 | int log_martians; | 181 | int log_martians; |
@@ -208,14 +221,14 @@ static inline int inet_is_reserved_local_port(int port) | |||
208 | 221 | ||
209 | extern int sysctl_ip_nonlocal_bind; | 222 | extern int sysctl_ip_nonlocal_bind; |
210 | 223 | ||
224 | extern struct ctl_path net_core_path[]; | ||
225 | extern struct ctl_path net_ipv4_ctl_path[]; | ||
226 | |||
211 | /* From inetpeer.c */ | 227 | /* From inetpeer.c */ |
212 | extern int inet_peer_threshold; | 228 | extern int inet_peer_threshold; |
213 | extern int inet_peer_minttl; | 229 | extern int inet_peer_minttl; |
214 | extern int inet_peer_maxttl; | 230 | extern int inet_peer_maxttl; |
215 | 231 | ||
216 | /* From ip_input.c */ | ||
217 | extern int sysctl_ip_early_demux; | ||
218 | |||
219 | /* From ip_output.c */ | 232 | /* From ip_output.c */ |
220 | extern int sysctl_ip_dynaddr; | 233 | extern int sysctl_ip_dynaddr; |
221 | 234 | ||
@@ -339,14 +352,14 @@ static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast, | |||
339 | memcpy(buf, &naddr, sizeof(naddr)); | 352 | memcpy(buf, &naddr, sizeof(naddr)); |
340 | } | 353 | } |
341 | 354 | ||
342 | #if IS_ENABLED(CONFIG_IPV6) | 355 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
343 | #include <linux/ipv6.h> | 356 | #include <linux/ipv6.h> |
344 | #endif | 357 | #endif |
345 | 358 | ||
346 | static __inline__ void inet_reset_saddr(struct sock *sk) | 359 | static __inline__ void inet_reset_saddr(struct sock *sk) |
347 | { | 360 | { |
348 | inet_sk(sk)->inet_rcv_saddr = inet_sk(sk)->inet_saddr = 0; | 361 | inet_sk(sk)->inet_rcv_saddr = inet_sk(sk)->inet_saddr = 0; |
349 | #if IS_ENABLED(CONFIG_IPV6) | 362 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
350 | if (sk->sk_family == PF_INET6) { | 363 | if (sk->sk_family == PF_INET6) { |
351 | struct ipv6_pinfo *np = inet6_sk(sk); | 364 | struct ipv6_pinfo *np = inet6_sk(sk); |
352 | 365 | ||
@@ -365,7 +378,7 @@ static inline int sk_mc_loop(struct sock *sk) | |||
365 | switch (sk->sk_family) { | 378 | switch (sk->sk_family) { |
366 | case AF_INET: | 379 | case AF_INET: |
367 | return inet_sk(sk)->mc_loop; | 380 | return inet_sk(sk)->mc_loop; |
368 | #if IS_ENABLED(CONFIG_IPV6) | 381 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
369 | case AF_INET6: | 382 | case AF_INET6: |
370 | return inet6_sk(sk)->mc_loop; | 383 | return inet6_sk(sk)->mc_loop; |
371 | #endif | 384 | #endif |
@@ -374,7 +387,7 @@ static inline int sk_mc_loop(struct sock *sk) | |||
374 | return 1; | 387 | return 1; |
375 | } | 388 | } |
376 | 389 | ||
377 | extern bool ip_call_ra_chain(struct sk_buff *skb); | 390 | extern int ip_call_ra_chain(struct sk_buff *skb); |
378 | 391 | ||
379 | /* | 392 | /* |
380 | * Functions provided by ip_fragment.c | 393 | * Functions provided by ip_fragment.c |
@@ -393,18 +406,9 @@ enum ip_defrag_users { | |||
393 | IP_DEFRAG_VS_OUT, | 406 | IP_DEFRAG_VS_OUT, |
394 | IP_DEFRAG_VS_FWD, | 407 | IP_DEFRAG_VS_FWD, |
395 | IP_DEFRAG_AF_PACKET, | 408 | IP_DEFRAG_AF_PACKET, |
396 | IP_DEFRAG_MACVLAN, | ||
397 | }; | 409 | }; |
398 | 410 | ||
399 | int ip_defrag(struct sk_buff *skb, u32 user); | 411 | int ip_defrag(struct sk_buff *skb, u32 user); |
400 | #ifdef CONFIG_INET | ||
401 | struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user); | ||
402 | #else | ||
403 | static inline struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user) | ||
404 | { | ||
405 | return skb; | ||
406 | } | ||
407 | #endif | ||
408 | int ip_frag_mem(struct net *net); | 412 | int ip_frag_mem(struct net *net); |
409 | int ip_frag_nqueues(struct net *net); | 413 | int ip_frag_nqueues(struct net *net); |
410 | 414 | ||
@@ -436,7 +440,7 @@ extern int ip_options_rcv_srr(struct sk_buff *skb); | |||
436 | * Functions provided by ip_sockglue.c | 440 | * Functions provided by ip_sockglue.c |
437 | */ | 441 | */ |
438 | 442 | ||
439 | extern void ipv4_pktinfo_prepare(struct sk_buff *skb); | 443 | extern int ip_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); |
440 | extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); | 444 | extern void ip_cmsg_recv(struct msghdr *msg, struct sk_buff *skb); |
441 | extern int ip_cmsg_send(struct net *net, | 445 | extern int ip_cmsg_send(struct net *net, |
442 | struct msghdr *msg, struct ipcm_cookie *ipc); | 446 | struct msghdr *msg, struct ipcm_cookie *ipc); |
diff --git a/include/net/ip6_checksum.h b/include/net/ip6_checksum.h index 652d3d30935..bc1b0fda2b0 100644 --- a/include/net/ip6_checksum.h +++ b/include/net/ip6_checksum.h | |||
@@ -31,8 +31,6 @@ | |||
31 | #include <net/ip.h> | 31 | #include <net/ip.h> |
32 | #include <asm/checksum.h> | 32 | #include <asm/checksum.h> |
33 | #include <linux/in6.h> | 33 | #include <linux/in6.h> |
34 | #include <linux/tcp.h> | ||
35 | #include <linux/ipv6.h> | ||
36 | 34 | ||
37 | #ifndef _HAVE_ARCH_IPV6_CSUM | 35 | #ifndef _HAVE_ARCH_IPV6_CSUM |
38 | 36 | ||
@@ -93,37 +91,4 @@ static __inline__ __sum16 csum_ipv6_magic(const struct in6_addr *saddr, | |||
93 | } | 91 | } |
94 | 92 | ||
95 | #endif | 93 | #endif |
96 | |||
97 | static __inline__ __sum16 tcp_v6_check(int len, | ||
98 | const struct in6_addr *saddr, | ||
99 | const struct in6_addr *daddr, | ||
100 | __wsum base) | ||
101 | { | ||
102 | return csum_ipv6_magic(saddr, daddr, len, IPPROTO_TCP, base); | ||
103 | } | ||
104 | |||
105 | static inline void __tcp_v6_send_check(struct sk_buff *skb, | ||
106 | const struct in6_addr *saddr, | ||
107 | const struct in6_addr *daddr) | ||
108 | { | ||
109 | struct tcphdr *th = tcp_hdr(skb); | ||
110 | |||
111 | if (skb->ip_summed == CHECKSUM_PARTIAL) { | ||
112 | th->check = ~tcp_v6_check(skb->len, saddr, daddr, 0); | ||
113 | skb->csum_start = skb_transport_header(skb) - skb->head; | ||
114 | skb->csum_offset = offsetof(struct tcphdr, check); | ||
115 | } else { | ||
116 | th->check = tcp_v6_check(skb->len, saddr, daddr, | ||
117 | csum_partial(th, th->doff << 2, | ||
118 | skb->csum)); | ||
119 | } | ||
120 | } | ||
121 | |||
122 | static inline void tcp_v6_send_check(struct sock *sk, struct sk_buff *skb) | ||
123 | { | ||
124 | struct ipv6_pinfo *np = inet6_sk(sk); | ||
125 | |||
126 | __tcp_v6_send_check(skb, &np->saddr, &np->daddr); | ||
127 | } | ||
128 | |||
129 | #endif | 94 | #endif |
diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h index fdc48a94a06..5735a0f979c 100644 --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h | |||
@@ -37,7 +37,6 @@ struct fib6_config { | |||
37 | int fc_ifindex; | 37 | int fc_ifindex; |
38 | u32 fc_flags; | 38 | u32 fc_flags; |
39 | u32 fc_protocol; | 39 | u32 fc_protocol; |
40 | u32 fc_type; /* only 8 bits are used */ | ||
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; |
@@ -47,8 +46,6 @@ struct fib6_config { | |||
47 | unsigned long fc_expires; | 46 | unsigned long fc_expires; |
48 | struct nlattr *fc_mx; | 47 | struct nlattr *fc_mx; |
49 | int fc_mx_len; | 48 | int fc_mx_len; |
50 | int fc_mp_len; | ||
51 | struct nlattr *fc_mp; | ||
52 | 49 | ||
53 | struct nl_info fc_nlinfo; | 50 | struct nl_info fc_nlinfo; |
54 | }; | 51 | }; |
@@ -89,7 +86,8 @@ struct fib6_table; | |||
89 | struct rt6_info { | 86 | struct rt6_info { |
90 | struct dst_entry dst; | 87 | struct dst_entry dst; |
91 | 88 | ||
92 | struct neighbour *n; | 89 | #define rt6i_dev dst.dev |
90 | #define rt6i_expires dst.expires | ||
93 | 91 | ||
94 | /* | 92 | /* |
95 | * Tail elements of dst_entry (__refcnt etc.) | 93 | * Tail elements of dst_entry (__refcnt etc.) |
@@ -101,14 +99,6 @@ struct rt6_info { | |||
101 | 99 | ||
102 | struct in6_addr rt6i_gateway; | 100 | struct in6_addr rt6i_gateway; |
103 | 101 | ||
104 | /* Multipath routes: | ||
105 | * siblings is a list of rt6_info that have the the same metric/weight, | ||
106 | * destination, but not the same gateway. nsiblings is just a cache | ||
107 | * to speed up lookup. | ||
108 | */ | ||
109 | struct list_head rt6i_siblings; | ||
110 | unsigned int rt6i_nsiblings; | ||
111 | |||
112 | atomic_t rt6i_ref; | 102 | atomic_t rt6i_ref; |
113 | 103 | ||
114 | /* These are in a separate cache line. */ | 104 | /* These are in a separate cache line. */ |
@@ -117,110 +107,25 @@ struct rt6_info { | |||
117 | struct rt6key rt6i_src; | 107 | struct rt6key rt6i_src; |
118 | struct rt6key rt6i_prefsrc; | 108 | struct rt6key rt6i_prefsrc; |
119 | u32 rt6i_metric; | 109 | u32 rt6i_metric; |
110 | u32 rt6i_peer_genid; | ||
120 | 111 | ||
121 | struct inet6_dev *rt6i_idev; | 112 | struct inet6_dev *rt6i_idev; |
122 | unsigned long _rt6i_peer; | 113 | struct inet_peer *rt6i_peer; |
123 | |||
124 | u32 rt6i_genid; | ||
125 | 114 | ||
115 | #ifdef CONFIG_XFRM | ||
116 | u32 rt6i_flow_cache_genid; | ||
117 | #endif | ||
126 | /* more non-fragment space at head required */ | 118 | /* more non-fragment space at head required */ |
127 | unsigned short rt6i_nfheader_len; | 119 | unsigned short rt6i_nfheader_len; |
128 | 120 | ||
129 | u8 rt6i_protocol; | 121 | u8 rt6i_protocol; |
130 | }; | 122 | }; |
131 | 123 | ||
132 | static inline struct inet_peer *rt6_peer_ptr(struct rt6_info *rt) | ||
133 | { | ||
134 | return inetpeer_ptr(rt->_rt6i_peer); | ||
135 | } | ||
136 | |||
137 | static inline bool rt6_has_peer(struct rt6_info *rt) | ||
138 | { | ||
139 | return inetpeer_ptr_is_peer(rt->_rt6i_peer); | ||
140 | } | ||
141 | |||
142 | static inline void __rt6_set_peer(struct rt6_info *rt, struct inet_peer *peer) | ||
143 | { | ||
144 | __inetpeer_ptr_set_peer(&rt->_rt6i_peer, peer); | ||
145 | } | ||
146 | |||
147 | static inline bool rt6_set_peer(struct rt6_info *rt, struct inet_peer *peer) | ||
148 | { | ||
149 | return inetpeer_ptr_set_peer(&rt->_rt6i_peer, peer); | ||
150 | } | ||
151 | |||
152 | static inline void rt6_init_peer(struct rt6_info *rt, struct inet_peer_base *base) | ||
153 | { | ||
154 | inetpeer_init_ptr(&rt->_rt6i_peer, base); | ||
155 | } | ||
156 | |||
157 | static inline void rt6_transfer_peer(struct rt6_info *rt, struct rt6_info *ort) | ||
158 | { | ||
159 | inetpeer_transfer_peer(&rt->_rt6i_peer, &ort->_rt6i_peer); | ||
160 | } | ||
161 | |||
162 | static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst) | 124 | static inline struct inet6_dev *ip6_dst_idev(struct dst_entry *dst) |
163 | { | 125 | { |
164 | return ((struct rt6_info *)dst)->rt6i_idev; | 126 | return ((struct rt6_info *)dst)->rt6i_idev; |
165 | } | 127 | } |
166 | 128 | ||
167 | static inline void rt6_clean_expires(struct rt6_info *rt) | ||
168 | { | ||
169 | if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from) | ||
170 | dst_release(rt->dst.from); | ||
171 | |||
172 | rt->rt6i_flags &= ~RTF_EXPIRES; | ||
173 | rt->dst.from = NULL; | ||
174 | } | ||
175 | |||
176 | static inline void rt6_set_expires(struct rt6_info *rt, unsigned long expires) | ||
177 | { | ||
178 | if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from) | ||
179 | dst_release(rt->dst.from); | ||
180 | |||
181 | rt->rt6i_flags |= RTF_EXPIRES; | ||
182 | rt->dst.expires = expires; | ||
183 | } | ||
184 | |||
185 | static inline void rt6_update_expires(struct rt6_info *rt, int timeout) | ||
186 | { | ||
187 | if (!(rt->rt6i_flags & RTF_EXPIRES)) { | ||
188 | if (rt->dst.from) | ||
189 | dst_release(rt->dst.from); | ||
190 | /* dst_set_expires relies on expires == 0 | ||
191 | * if it has not been set previously. | ||
192 | */ | ||
193 | rt->dst.expires = 0; | ||
194 | } | ||
195 | |||
196 | dst_set_expires(&rt->dst, timeout); | ||
197 | rt->rt6i_flags |= RTF_EXPIRES; | ||
198 | } | ||
199 | |||
200 | static inline void rt6_set_from(struct rt6_info *rt, struct rt6_info *from) | ||
201 | { | ||
202 | struct dst_entry *new = (struct dst_entry *) from; | ||
203 | |||
204 | if (!(rt->rt6i_flags & RTF_EXPIRES) && rt->dst.from) { | ||
205 | if (new == rt->dst.from) | ||
206 | return; | ||
207 | dst_release(rt->dst.from); | ||
208 | } | ||
209 | |||
210 | rt->rt6i_flags &= ~RTF_EXPIRES; | ||
211 | rt->dst.from = new; | ||
212 | dst_hold(new); | ||
213 | } | ||
214 | |||
215 | static inline void ip6_rt_put(struct rt6_info *rt) | ||
216 | { | ||
217 | /* dst_release() accepts a NULL parameter. | ||
218 | * We rely on dst being first structure in struct rt6_info | ||
219 | */ | ||
220 | BUILD_BUG_ON(offsetof(struct rt6_info, dst) != 0); | ||
221 | dst_release(&rt->dst); | ||
222 | } | ||
223 | |||
224 | struct fib6_walker_t { | 129 | struct fib6_walker_t { |
225 | struct list_head lh; | 130 | struct list_head lh; |
226 | struct fib6_node *root, *node; | 131 | struct fib6_node *root, *node; |
@@ -257,7 +162,6 @@ struct fib6_table { | |||
257 | u32 tb6_id; | 162 | u32 tb6_id; |
258 | rwlock_t tb6_lock; | 163 | rwlock_t tb6_lock; |
259 | struct fib6_node tb6_root; | 164 | struct fib6_node tb6_root; |
260 | struct inet_peer_base tb6_peers; | ||
261 | }; | 165 | }; |
262 | 166 | ||
263 | #define RT6_TABLE_UNSPEC RT_TABLE_UNSPEC | 167 | #define RT6_TABLE_UNSPEC RT_TABLE_UNSPEC |
@@ -298,10 +202,6 @@ struct fib6_node *fib6_locate(struct fib6_node *root, | |||
298 | const struct in6_addr *daddr, int dst_len, | 202 | const struct in6_addr *daddr, int dst_len, |
299 | const struct in6_addr *saddr, int src_len); | 203 | const struct in6_addr *saddr, int src_len); |
300 | 204 | ||
301 | extern void fib6_clean_all_ro(struct net *net, | ||
302 | int (*func)(struct rt6_info *, void *arg), | ||
303 | int prune, void *arg); | ||
304 | |||
305 | extern void fib6_clean_all(struct net *net, | 205 | extern void fib6_clean_all(struct net *net, |
306 | int (*func)(struct rt6_info *, void *arg), | 206 | int (*func)(struct rt6_info *, void *arg), |
307 | int prune, void *arg); | 207 | int prune, void *arg); |
diff --git a/include/net/ip6_route.h b/include/net/ip6_route.h index 27d83183e61..5e91b72fc71 100644 --- a/include/net/ip6_route.h +++ b/include/net/ip6_route.h | |||
@@ -1,6 +1,9 @@ | |||
1 | #ifndef _NET_IP6_ROUTE_H | 1 | #ifndef _NET_IP6_ROUTE_H |
2 | #define _NET_IP6_ROUTE_H | 2 | #define _NET_IP6_ROUTE_H |
3 | 3 | ||
4 | #define IP6_RT_PRIO_USER 1024 | ||
5 | #define IP6_RT_PRIO_ADDRCONF 256 | ||
6 | |||
4 | struct route_info { | 7 | struct route_info { |
5 | __u8 type; | 8 | __u8 type; |
6 | __u8 length; | 9 | __u8 length; |
@@ -50,25 +53,16 @@ static inline unsigned int rt6_flags2srcprefs(int flags) | |||
50 | return (flags >> 3) & 7; | 53 | return (flags >> 3) & 7; |
51 | } | 54 | } |
52 | 55 | ||
53 | extern void rt6_bind_peer(struct rt6_info *rt, int create); | 56 | extern void rt6_bind_peer(struct rt6_info *rt, |
54 | 57 | int create); | |
55 | static inline struct inet_peer *__rt6_get_peer(struct rt6_info *rt, int create) | ||
56 | { | ||
57 | if (rt6_has_peer(rt)) | ||
58 | return rt6_peer_ptr(rt); | ||
59 | |||
60 | rt6_bind_peer(rt, create); | ||
61 | return (rt6_has_peer(rt) ? rt6_peer_ptr(rt) : NULL); | ||
62 | } | ||
63 | 58 | ||
64 | static inline struct inet_peer *rt6_get_peer(struct rt6_info *rt) | 59 | static inline struct inet_peer *rt6_get_peer(struct rt6_info *rt) |
65 | { | 60 | { |
66 | return __rt6_get_peer(rt, 0); | 61 | if (rt->rt6i_peer) |
67 | } | 62 | return rt->rt6i_peer; |
68 | 63 | ||
69 | static inline struct inet_peer *rt6_get_peer_create(struct rt6_info *rt) | 64 | rt6_bind_peer(rt, 0); |
70 | { | 65 | return rt->rt6i_peer; |
71 | return __rt6_get_peer(rt, 1); | ||
72 | } | 66 | } |
73 | 67 | ||
74 | extern void ip6_route_input(struct sk_buff *skb); | 68 | extern void ip6_route_input(struct sk_buff *skb); |
@@ -76,8 +70,6 @@ extern void ip6_route_input(struct sk_buff *skb); | |||
76 | extern struct dst_entry * ip6_route_output(struct net *net, | 70 | extern struct dst_entry * ip6_route_output(struct net *net, |
77 | const struct sock *sk, | 71 | const struct sock *sk, |
78 | struct flowi6 *fl6); | 72 | struct flowi6 *fl6); |
79 | extern struct dst_entry * ip6_route_lookup(struct net *net, | ||
80 | struct flowi6 *fl6, int flags); | ||
81 | 73 | ||
82 | extern int ip6_route_init(void); | 74 | extern int ip6_route_init(void); |
83 | extern void ip6_route_cleanup(void); | 75 | extern void ip6_route_cleanup(void); |
@@ -103,14 +95,14 @@ extern struct rt6_info *rt6_lookup(struct net *net, | |||
103 | 95 | ||
104 | extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev, | 96 | extern struct dst_entry *icmp6_dst_alloc(struct net_device *dev, |
105 | struct neighbour *neigh, | 97 | struct neighbour *neigh, |
106 | struct flowi6 *fl6); | 98 | const struct in6_addr *addr); |
107 | extern int icmp6_dst_gc(void); | 99 | extern int icmp6_dst_gc(void); |
108 | 100 | ||
109 | extern void fib6_force_start_gc(struct net *net); | 101 | extern void fib6_force_start_gc(struct net *net); |
110 | 102 | ||
111 | extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, | 103 | extern struct rt6_info *addrconf_dst_alloc(struct inet6_dev *idev, |
112 | const struct in6_addr *addr, | 104 | const struct in6_addr *addr, |
113 | bool anycast); | 105 | int anycast); |
114 | 106 | ||
115 | extern int ip6_dst_hoplimit(struct dst_entry *dst); | 107 | extern int ip6_dst_hoplimit(struct dst_entry *dst); |
116 | 108 | ||
@@ -130,12 +122,17 @@ extern int rt6_route_rcv(struct net_device *dev, | |||
130 | u8 *opt, int len, | 122 | u8 *opt, int len, |
131 | const struct in6_addr *gwaddr); | 123 | const struct in6_addr *gwaddr); |
132 | 124 | ||
133 | extern void ip6_update_pmtu(struct sk_buff *skb, struct net *net, __be32 mtu, | 125 | extern void rt6_redirect(const struct in6_addr *dest, |
134 | int oif, u32 mark); | 126 | const struct in6_addr *src, |
135 | extern void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, | 127 | const struct in6_addr *saddr, |
136 | __be32 mtu); | 128 | struct neighbour *neigh, |
137 | extern void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark); | 129 | u8 *lladdr, |
138 | extern void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk); | 130 | int on_link); |
131 | |||
132 | extern void rt6_pmtu_discovery(const struct in6_addr *daddr, | ||
133 | const struct in6_addr *saddr, | ||
134 | struct net_device *dev, | ||
135 | u32 pmtu); | ||
139 | 136 | ||
140 | struct netlink_callback; | 137 | struct netlink_callback; |
141 | 138 | ||
@@ -147,7 +144,7 @@ struct rt6_rtnl_dump_arg { | |||
147 | 144 | ||
148 | 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); |
149 | extern void rt6_ifdown(struct net *net, struct net_device *dev); | 146 | extern void rt6_ifdown(struct net *net, struct net_device *dev); |
150 | extern void rt6_mtu_change(struct net_device *dev, unsigned int mtu); | 147 | extern void rt6_mtu_change(struct net_device *dev, unsigned mtu); |
151 | extern void rt6_remove_prefsrc(struct inet6_ifaddr *ifp); | 148 | extern void rt6_remove_prefsrc(struct inet6_ifaddr *ifp); |
152 | 149 | ||
153 | 150 | ||
@@ -155,8 +152,7 @@ extern void rt6_remove_prefsrc(struct inet6_ifaddr *ifp); | |||
155 | * Store a destination cache entry in a socket | 152 | * Store a destination cache entry in a socket |
156 | */ | 153 | */ |
157 | static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst, | 154 | static inline void __ip6_dst_store(struct sock *sk, struct dst_entry *dst, |
158 | const struct in6_addr *daddr, | 155 | struct in6_addr *daddr, struct in6_addr *saddr) |
159 | const struct in6_addr *saddr) | ||
160 | { | 156 | { |
161 | struct ipv6_pinfo *np = inet6_sk(sk); | 157 | struct ipv6_pinfo *np = inet6_sk(sk); |
162 | struct rt6_info *rt = (struct rt6_info *) dst; | 158 | struct rt6_info *rt = (struct rt6_info *) dst; |
@@ -177,7 +173,7 @@ static inline void ip6_dst_store(struct sock *sk, struct dst_entry *dst, | |||
177 | spin_unlock(&sk->sk_dst_lock); | 173 | spin_unlock(&sk->sk_dst_lock); |
178 | } | 174 | } |
179 | 175 | ||
180 | static inline bool ipv6_unicast_destination(const struct sk_buff *skb) | 176 | static inline int ipv6_unicast_destination(struct sk_buff *skb) |
181 | { | 177 | { |
182 | struct rt6_info *rt = (struct rt6_info *) skb_dst(skb); | 178 | struct rt6_info *rt = (struct rt6_info *) skb_dst(skb); |
183 | 179 | ||
diff --git a/include/net/ip6_tunnel.h b/include/net/ip6_tunnel.h index e03047f7090..fc73e667b50 100644 --- a/include/net/ip6_tunnel.h +++ b/include/net/ip6_tunnel.h | |||
@@ -5,49 +5,20 @@ | |||
5 | #include <linux/netdevice.h> | 5 | #include <linux/netdevice.h> |
6 | #include <linux/ip6_tunnel.h> | 6 | #include <linux/ip6_tunnel.h> |
7 | 7 | ||
8 | #define IP6TUNNEL_ERR_TIMEO (30*HZ) | ||
9 | |||
10 | /* capable of sending packets */ | 8 | /* capable of sending packets */ |
11 | #define IP6_TNL_F_CAP_XMIT 0x10000 | 9 | #define IP6_TNL_F_CAP_XMIT 0x10000 |
12 | /* capable of receiving packets */ | 10 | /* capable of receiving packets */ |
13 | #define IP6_TNL_F_CAP_RCV 0x20000 | 11 | #define IP6_TNL_F_CAP_RCV 0x20000 |
14 | /* determine capability on a per-packet basis */ | ||
15 | #define IP6_TNL_F_CAP_PER_PACKET 0x40000 | ||
16 | |||
17 | struct __ip6_tnl_parm { | ||
18 | char name[IFNAMSIZ]; /* name of tunnel device */ | ||
19 | int link; /* ifindex of underlying L2 interface */ | ||
20 | __u8 proto; /* tunnel protocol */ | ||
21 | __u8 encap_limit; /* encapsulation limit for tunnel */ | ||
22 | __u8 hop_limit; /* hop limit for tunnel */ | ||
23 | __be32 flowinfo; /* traffic class and flowlabel for tunnel */ | ||
24 | __u32 flags; /* tunnel flags */ | ||
25 | struct in6_addr laddr; /* local tunnel end-point address */ | ||
26 | struct in6_addr raddr; /* remote tunnel end-point address */ | ||
27 | |||
28 | __be16 i_flags; | ||
29 | __be16 o_flags; | ||
30 | __be32 i_key; | ||
31 | __be32 o_key; | ||
32 | }; | ||
33 | 12 | ||
34 | /* IPv6 tunnel */ | 13 | /* IPv6 tunnel */ |
14 | |||
35 | struct ip6_tnl { | 15 | struct ip6_tnl { |
36 | struct ip6_tnl __rcu *next; /* next tunnel in list */ | 16 | struct ip6_tnl __rcu *next; /* next tunnel in list */ |
37 | struct net_device *dev; /* virtual device associated with tunnel */ | 17 | struct net_device *dev; /* virtual device associated with tunnel */ |
38 | struct __ip6_tnl_parm parms; /* tunnel configuration parameters */ | 18 | struct ip6_tnl_parm parms; /* tunnel configuration parameters */ |
39 | struct flowi fl; /* flowi template for xmit */ | 19 | struct flowi fl; /* flowi template for xmit */ |
40 | struct dst_entry *dst_cache; /* cached dst */ | 20 | struct dst_entry *dst_cache; /* cached dst */ |
41 | u32 dst_cookie; | 21 | u32 dst_cookie; |
42 | |||
43 | int err_count; | ||
44 | unsigned long err_time; | ||
45 | |||
46 | /* These fields used only by GRE */ | ||
47 | __u32 i_seqno; /* The last seen seqno */ | ||
48 | __u32 o_seqno; /* The last output seqno */ | ||
49 | int hlen; /* Precalculated GRE header length */ | ||
50 | int mlink; | ||
51 | }; | 22 | }; |
52 | 23 | ||
53 | /* Tunnel encapsulation limit destination sub-option */ | 24 | /* Tunnel encapsulation limit destination sub-option */ |
@@ -58,14 +29,4 @@ struct ipv6_tlv_tnl_enc_lim { | |||
58 | __u8 encap_limit; /* tunnel encapsulation limit */ | 29 | __u8 encap_limit; /* tunnel encapsulation limit */ |
59 | } __packed; | 30 | } __packed; |
60 | 31 | ||
61 | struct dst_entry *ip6_tnl_dst_check(struct ip6_tnl *t); | ||
62 | void ip6_tnl_dst_reset(struct ip6_tnl *t); | ||
63 | void ip6_tnl_dst_store(struct ip6_tnl *t, struct dst_entry *dst); | ||
64 | int ip6_tnl_rcv_ctl(struct ip6_tnl *t, const struct in6_addr *laddr, | ||
65 | const struct in6_addr *raddr); | ||
66 | int ip6_tnl_xmit_ctl(struct ip6_tnl *t); | ||
67 | __u16 ip6_tnl_parse_tlv_enc_lim(struct sk_buff *skb, __u8 *raw); | ||
68 | __u32 ip6_tnl_get_cap(struct ip6_tnl *t, const struct in6_addr *laddr, | ||
69 | const struct in6_addr *raddr); | ||
70 | |||
71 | #endif | 32 | #endif |
diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h index 9497be1ad4c..10422ef14e2 100644 --- a/include/net/ip_fib.h +++ b/include/net/ip_fib.h | |||
@@ -18,10 +18,7 @@ | |||
18 | 18 | ||
19 | #include <net/flow.h> | 19 | #include <net/flow.h> |
20 | #include <linux/seq_file.h> | 20 | #include <linux/seq_file.h> |
21 | #include <linux/rcupdate.h> | ||
22 | #include <net/fib_rules.h> | 21 | #include <net/fib_rules.h> |
23 | #include <net/inetpeer.h> | ||
24 | #include <linux/percpu.h> | ||
25 | 22 | ||
26 | struct fib_config { | 23 | struct fib_config { |
27 | u8 fc_dst_len; | 24 | u8 fc_dst_len; |
@@ -47,30 +44,12 @@ struct fib_config { | |||
47 | }; | 44 | }; |
48 | 45 | ||
49 | struct fib_info; | 46 | struct fib_info; |
50 | struct rtable; | ||
51 | |||
52 | struct fib_nh_exception { | ||
53 | struct fib_nh_exception __rcu *fnhe_next; | ||
54 | __be32 fnhe_daddr; | ||
55 | u32 fnhe_pmtu; | ||
56 | __be32 fnhe_gw; | ||
57 | unsigned long fnhe_expires; | ||
58 | struct rtable __rcu *fnhe_rth; | ||
59 | unsigned long fnhe_stamp; | ||
60 | }; | ||
61 | |||
62 | struct fnhe_hash_bucket { | ||
63 | struct fib_nh_exception __rcu *chain; | ||
64 | }; | ||
65 | |||
66 | #define FNHE_HASH_SIZE 2048 | ||
67 | #define FNHE_RECLAIM_DEPTH 5 | ||
68 | 47 | ||
69 | struct fib_nh { | 48 | struct fib_nh { |
70 | struct net_device *nh_dev; | 49 | struct net_device *nh_dev; |
71 | struct hlist_node nh_hash; | 50 | struct hlist_node nh_hash; |
72 | struct fib_info *nh_parent; | 51 | struct fib_info *nh_parent; |
73 | unsigned int nh_flags; | 52 | unsigned nh_flags; |
74 | unsigned char nh_scope; | 53 | unsigned char nh_scope; |
75 | #ifdef CONFIG_IP_ROUTE_MULTIPATH | 54 | #ifdef CONFIG_IP_ROUTE_MULTIPATH |
76 | int nh_weight; | 55 | int nh_weight; |
@@ -83,9 +62,6 @@ struct fib_nh { | |||
83 | __be32 nh_gw; | 62 | __be32 nh_gw; |
84 | __be32 nh_saddr; | 63 | __be32 nh_saddr; |
85 | int nh_saddr_genid; | 64 | int nh_saddr_genid; |
86 | struct rtable __rcu * __percpu *nh_pcpu_rth_output; | ||
87 | struct rtable __rcu *nh_rth_input; | ||
88 | struct fnhe_hash_bucket *nh_exceptions; | ||
89 | }; | 65 | }; |
90 | 66 | ||
91 | /* | 67 | /* |
@@ -98,11 +74,10 @@ struct fib_info { | |||
98 | struct net *fib_net; | 74 | struct net *fib_net; |
99 | int fib_treeref; | 75 | int fib_treeref; |
100 | atomic_t fib_clntref; | 76 | atomic_t fib_clntref; |
101 | unsigned int fib_flags; | 77 | unsigned fib_flags; |
102 | unsigned char fib_dead; | 78 | unsigned char fib_dead; |
103 | unsigned char fib_protocol; | 79 | unsigned char fib_protocol; |
104 | unsigned char fib_scope; | 80 | unsigned char fib_scope; |
105 | unsigned char fib_type; | ||
106 | __be32 fib_prefsrc; | 81 | __be32 fib_prefsrc; |
107 | u32 fib_priority; | 82 | u32 fib_priority; |
108 | u32 *fib_metrics; | 83 | u32 *fib_metrics; |
@@ -130,10 +105,12 @@ struct fib_result { | |||
130 | unsigned char nh_sel; | 105 | unsigned char nh_sel; |
131 | unsigned char type; | 106 | unsigned char type; |
132 | unsigned char scope; | 107 | unsigned char scope; |
133 | u32 tclassid; | ||
134 | struct fib_info *fi; | 108 | struct fib_info *fi; |
135 | struct fib_table *table; | 109 | struct fib_table *table; |
136 | struct list_head *fa_head; | 110 | struct list_head *fa_head; |
111 | #ifdef CONFIG_IP_MULTIPLE_TABLES | ||
112 | struct fib_rule *r; | ||
113 | #endif | ||
137 | }; | 114 | }; |
138 | 115 | ||
139 | struct fib_result_nl { | 116 | struct fib_result_nl { |
@@ -180,11 +157,11 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh); | |||
180 | FIB_RES_SADDR(net, res)) | 157 | FIB_RES_SADDR(net, res)) |
181 | 158 | ||
182 | struct fib_table { | 159 | struct fib_table { |
183 | struct hlist_node tb_hlist; | 160 | struct hlist_node tb_hlist; |
184 | u32 tb_id; | 161 | u32 tb_id; |
185 | int tb_default; | 162 | int tb_default; |
186 | int tb_num_default; | 163 | int tb_num_default; |
187 | unsigned long tb_data[0]; | 164 | unsigned long tb_data[0]; |
188 | }; | 165 | }; |
189 | 166 | ||
190 | extern int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, | 167 | extern int fib_table_lookup(struct fib_table *tb, const struct flowi4 *flp, |
@@ -237,55 +214,24 @@ static inline int fib_lookup(struct net *net, const struct flowi4 *flp, | |||
237 | extern int __net_init fib4_rules_init(struct net *net); | 214 | extern int __net_init fib4_rules_init(struct net *net); |
238 | extern void __net_exit fib4_rules_exit(struct net *net); | 215 | extern void __net_exit fib4_rules_exit(struct net *net); |
239 | 216 | ||
240 | extern struct fib_table *fib_new_table(struct net *net, u32 id); | 217 | #ifdef CONFIG_IP_ROUTE_CLASSID |
241 | extern struct fib_table *fib_get_table(struct net *net, u32 id); | 218 | extern u32 fib_rules_tclass(const struct fib_result *res); |
219 | #endif | ||
242 | 220 | ||
243 | extern int __fib_lookup(struct net *net, struct flowi4 *flp, | 221 | extern int fib_lookup(struct net *n, struct flowi4 *flp, struct fib_result *res); |
244 | struct fib_result *res); | ||
245 | 222 | ||
246 | static inline int fib_lookup(struct net *net, struct flowi4 *flp, | 223 | extern struct fib_table *fib_new_table(struct net *net, u32 id); |
247 | struct fib_result *res) | 224 | extern struct fib_table *fib_get_table(struct net *net, u32 id); |
248 | { | ||
249 | if (!net->ipv4.fib_has_custom_rules) { | ||
250 | res->tclassid = 0; | ||
251 | if (net->ipv4.fib_local && | ||
252 | !fib_table_lookup(net->ipv4.fib_local, flp, res, | ||
253 | FIB_LOOKUP_NOREF)) | ||
254 | return 0; | ||
255 | if (net->ipv4.fib_main && | ||
256 | !fib_table_lookup(net->ipv4.fib_main, flp, res, | ||
257 | FIB_LOOKUP_NOREF)) | ||
258 | return 0; | ||
259 | if (net->ipv4.fib_default && | ||
260 | !fib_table_lookup(net->ipv4.fib_default, flp, res, | ||
261 | FIB_LOOKUP_NOREF)) | ||
262 | return 0; | ||
263 | return -ENETUNREACH; | ||
264 | } | ||
265 | return __fib_lookup(net, flp, res); | ||
266 | } | ||
267 | 225 | ||
268 | #endif /* CONFIG_IP_MULTIPLE_TABLES */ | 226 | #endif /* CONFIG_IP_MULTIPLE_TABLES */ |
269 | 227 | ||
270 | /* Exported by fib_frontend.c */ | 228 | /* Exported by fib_frontend.c */ |
271 | extern const struct nla_policy rtm_ipv4_policy[]; | 229 | extern const struct nla_policy rtm_ipv4_policy[]; |
272 | extern void ip_fib_init(void); | 230 | extern void ip_fib_init(void); |
273 | extern __be32 fib_compute_spec_dst(struct sk_buff *skb); | ||
274 | extern int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, | 231 | extern int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, |
275 | u8 tos, int oif, struct net_device *dev, | 232 | u8 tos, int oif, struct net_device *dev, |
276 | struct in_device *idev, u32 *itag); | 233 | __be32 *spec_dst, u32 *itag); |
277 | extern void fib_select_default(struct fib_result *res); | 234 | extern void fib_select_default(struct fib_result *res); |
278 | #ifdef CONFIG_IP_ROUTE_CLASSID | ||
279 | static inline int fib_num_tclassid_users(struct net *net) | ||
280 | { | ||
281 | return net->ipv4.fib_num_tclassid_users; | ||
282 | } | ||
283 | #else | ||
284 | static inline int fib_num_tclassid_users(struct net *net) | ||
285 | { | ||
286 | return 0; | ||
287 | } | ||
288 | #endif | ||
289 | 235 | ||
290 | /* Exported by fib_semantics.c */ | 236 | /* Exported by fib_semantics.c */ |
291 | 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); |
@@ -307,7 +253,7 @@ static inline void fib_combine_itag(u32 *itag, const struct fib_result *res) | |||
307 | #endif | 253 | #endif |
308 | *itag = FIB_RES_NH(*res).nh_tclassid<<16; | 254 | *itag = FIB_RES_NH(*res).nh_tclassid<<16; |
309 | #ifdef CONFIG_IP_MULTIPLE_TABLES | 255 | #ifdef CONFIG_IP_MULTIPLE_TABLES |
310 | rtag = res->tclassid; | 256 | rtag = fib_rules_tclass(res); |
311 | if (*itag == 0) | 257 | if (*itag == 0) |
312 | *itag = (rtag<<16); | 258 | *itag = (rtag<<16); |
313 | *itag |= (rtag>>16); | 259 | *itag |= (rtag>>16); |
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 68c69d54d39..8fa4430f99c 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -10,22 +10,19 @@ | |||
10 | 10 | ||
11 | #include <asm/types.h> /* for __uXX types */ | 11 | #include <asm/types.h> /* for __uXX types */ |
12 | 12 | ||
13 | #include <linux/sysctl.h> /* for ctl_path */ | ||
13 | #include <linux/list.h> /* for struct list_head */ | 14 | #include <linux/list.h> /* for struct list_head */ |
14 | #include <linux/spinlock.h> /* for struct rwlock_t */ | 15 | #include <linux/spinlock.h> /* for struct rwlock_t */ |
15 | #include <linux/atomic.h> /* for struct atomic_t */ | 16 | #include <linux/atomic.h> /* for struct atomic_t */ |
16 | #include <linux/compiler.h> | 17 | #include <linux/compiler.h> |
17 | #include <linux/timer.h> | 18 | #include <linux/timer.h> |
18 | #include <linux/bug.h> | ||
19 | 19 | ||
20 | #include <net/checksum.h> | 20 | #include <net/checksum.h> |
21 | #include <linux/netfilter.h> /* for union nf_inet_addr */ | 21 | #include <linux/netfilter.h> /* for union nf_inet_addr */ |
22 | #include <linux/ip.h> | 22 | #include <linux/ip.h> |
23 | #include <linux/ipv6.h> /* for struct ipv6hdr */ | 23 | #include <linux/ipv6.h> /* for struct ipv6hdr */ |
24 | #include <net/ipv6.h> | 24 | #include <net/ipv6.h> /* for ipv6_addr_copy */ |
25 | #if IS_ENABLED(CONFIG_IP_VS_IPV6) | 25 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
26 | #include <linux/netfilter_ipv6/ip6_tables.h> | ||
27 | #endif | ||
28 | #if IS_ENABLED(CONFIG_NF_CONNTRACK) | ||
29 | #include <net/netfilter/nf_conntrack.h> | 26 | #include <net/netfilter/nf_conntrack.h> |
30 | #endif | 27 | #endif |
31 | #include <net/net_namespace.h> /* Netw namespace */ | 28 | #include <net/net_namespace.h> /* Netw namespace */ |
@@ -106,117 +103,30 @@ static inline struct net *seq_file_single_net(struct seq_file *seq) | |||
106 | /* Connections' size value needed by ip_vs_ctl.c */ | 103 | /* Connections' size value needed by ip_vs_ctl.c */ |
107 | extern int ip_vs_conn_tab_size; | 104 | extern int ip_vs_conn_tab_size; |
108 | 105 | ||
106 | |||
109 | struct ip_vs_iphdr { | 107 | struct ip_vs_iphdr { |
110 | __u32 len; /* IPv4 simply where L4 starts | 108 | int len; |
111 | IPv6 where L4 Transport Header starts */ | 109 | __u8 protocol; |
112 | __u32 thoff_reasm; /* Transport Header Offset in nfct_reasm skb */ | ||
113 | __u16 fragoffs; /* IPv6 fragment offset, 0 if first frag (or not frag)*/ | ||
114 | __s16 protocol; | ||
115 | __s32 flags; | ||
116 | union nf_inet_addr saddr; | 110 | union nf_inet_addr saddr; |
117 | union nf_inet_addr daddr; | 111 | union nf_inet_addr daddr; |
118 | }; | 112 | }; |
119 | 113 | ||
120 | /* Dependency to module: nf_defrag_ipv6 */ | ||
121 | #if defined(CONFIG_NF_DEFRAG_IPV6) || defined(CONFIG_NF_DEFRAG_IPV6_MODULE) | ||
122 | static inline struct sk_buff *skb_nfct_reasm(const struct sk_buff *skb) | ||
123 | { | ||
124 | return skb->nfct_reasm; | ||
125 | } | ||
126 | static inline void *frag_safe_skb_hp(const struct sk_buff *skb, int offset, | ||
127 | int len, void *buffer, | ||
128 | const struct ip_vs_iphdr *ipvsh) | ||
129 | { | ||
130 | if (unlikely(ipvsh->fragoffs && skb_nfct_reasm(skb))) | ||
131 | return skb_header_pointer(skb_nfct_reasm(skb), | ||
132 | ipvsh->thoff_reasm, len, buffer); | ||
133 | |||
134 | return skb_header_pointer(skb, offset, len, buffer); | ||
135 | } | ||
136 | #else | ||
137 | static inline struct sk_buff *skb_nfct_reasm(const struct sk_buff *skb) | ||
138 | { | ||
139 | return NULL; | ||
140 | } | ||
141 | static inline void *frag_safe_skb_hp(const struct sk_buff *skb, int offset, | ||
142 | int len, void *buffer, | ||
143 | const struct ip_vs_iphdr *ipvsh) | ||
144 | { | ||
145 | return skb_header_pointer(skb, offset, len, buffer); | ||
146 | } | ||
147 | #endif | ||
148 | |||
149 | static inline void | 114 | static inline void |
150 | ip_vs_fill_ip4hdr(const void *nh, struct ip_vs_iphdr *iphdr) | 115 | ip_vs_fill_iphdr(int af, const void *nh, struct ip_vs_iphdr *iphdr) |
151 | { | ||
152 | const struct iphdr *iph = nh; | ||
153 | |||
154 | iphdr->len = iph->ihl * 4; | ||
155 | iphdr->fragoffs = 0; | ||
156 | iphdr->protocol = iph->protocol; | ||
157 | iphdr->saddr.ip = iph->saddr; | ||
158 | iphdr->daddr.ip = iph->daddr; | ||
159 | } | ||
160 | |||
161 | /* This function handles filling *ip_vs_iphdr, both for IPv4 and IPv6. | ||
162 | * IPv6 requires some extra work, as finding proper header position, | ||
163 | * depend on the IPv6 extension headers. | ||
164 | */ | ||
165 | static inline void | ||
166 | ip_vs_fill_iph_skb(int af, const struct sk_buff *skb, struct ip_vs_iphdr *iphdr) | ||
167 | { | 116 | { |
168 | #ifdef CONFIG_IP_VS_IPV6 | 117 | #ifdef CONFIG_IP_VS_IPV6 |
169 | if (af == AF_INET6) { | 118 | if (af == AF_INET6) { |
170 | const struct ipv6hdr *iph = | 119 | const struct ipv6hdr *iph = nh; |
171 | (struct ipv6hdr *)skb_network_header(skb); | 120 | iphdr->len = sizeof(struct ipv6hdr); |
172 | iphdr->saddr.in6 = iph->saddr; | 121 | iphdr->protocol = iph->nexthdr; |
173 | iphdr->daddr.in6 = iph->daddr; | 122 | ipv6_addr_copy(&iphdr->saddr.in6, &iph->saddr); |
174 | /* ipv6_find_hdr() updates len, flags, thoff_reasm */ | 123 | ipv6_addr_copy(&iphdr->daddr.in6, &iph->daddr); |
175 | iphdr->thoff_reasm = 0; | ||
176 | iphdr->len = 0; | ||
177 | iphdr->flags = 0; | ||
178 | iphdr->protocol = ipv6_find_hdr(skb, &iphdr->len, -1, | ||
179 | &iphdr->fragoffs, | ||
180 | &iphdr->flags); | ||
181 | /* get proto from re-assembled packet and it's offset */ | ||
182 | if (skb_nfct_reasm(skb)) | ||
183 | iphdr->protocol = ipv6_find_hdr(skb_nfct_reasm(skb), | ||
184 | &iphdr->thoff_reasm, | ||
185 | -1, NULL, NULL); | ||
186 | |||
187 | } else | 124 | } else |
188 | #endif | 125 | #endif |
189 | { | 126 | { |
190 | const struct iphdr *iph = | 127 | const struct iphdr *iph = nh; |
191 | (struct iphdr *)skb_network_header(skb); | 128 | iphdr->len = iph->ihl * 4; |
192 | iphdr->len = iph->ihl * 4; | 129 | iphdr->protocol = iph->protocol; |
193 | iphdr->fragoffs = 0; | ||
194 | iphdr->protocol = iph->protocol; | ||
195 | iphdr->saddr.ip = iph->saddr; | ||
196 | iphdr->daddr.ip = iph->daddr; | ||
197 | } | ||
198 | } | ||
199 | |||
200 | /* This function is a faster version of ip_vs_fill_iph_skb(). | ||
201 | * Where we only populate {s,d}addr (and avoid calling ipv6_find_hdr()). | ||
202 | * This is used by the some of the ip_vs_*_schedule() functions. | ||
203 | * (Mostly done to avoid ABI breakage of external schedulers) | ||
204 | */ | ||
205 | static inline void | ||
206 | ip_vs_fill_iph_addr_only(int af, const struct sk_buff *skb, | ||
207 | struct ip_vs_iphdr *iphdr) | ||
208 | { | ||
209 | #ifdef CONFIG_IP_VS_IPV6 | ||
210 | if (af == AF_INET6) { | ||
211 | const struct ipv6hdr *iph = | ||
212 | (struct ipv6hdr *)skb_network_header(skb); | ||
213 | iphdr->saddr.in6 = iph->saddr; | ||
214 | iphdr->daddr.in6 = iph->daddr; | ||
215 | } else | ||
216 | #endif | ||
217 | { | ||
218 | const struct iphdr *iph = | ||
219 | (struct iphdr *)skb_network_header(skb); | ||
220 | iphdr->saddr.ip = iph->saddr; | 130 | iphdr->saddr.ip = iph->saddr; |
221 | iphdr->daddr.ip = iph->daddr; | 131 | iphdr->daddr.ip = iph->daddr; |
222 | } | 132 | } |
@@ -227,7 +137,7 @@ static inline void ip_vs_addr_copy(int af, union nf_inet_addr *dst, | |||
227 | { | 137 | { |
228 | #ifdef CONFIG_IP_VS_IPV6 | 138 | #ifdef CONFIG_IP_VS_IPV6 |
229 | if (af == AF_INET6) | 139 | if (af == AF_INET6) |
230 | dst->in6 = src->in6; | 140 | ipv6_addr_copy(&dst->in6, &src->in6); |
231 | else | 141 | else |
232 | #endif | 142 | #endif |
233 | dst->ip = src->ip; | 143 | dst->ip = src->ip; |
@@ -255,7 +165,7 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len, | |||
255 | int len; | 165 | int len; |
256 | #ifdef CONFIG_IP_VS_IPV6 | 166 | #ifdef CONFIG_IP_VS_IPV6 |
257 | if (af == AF_INET6) | 167 | if (af == AF_INET6) |
258 | len = snprintf(&buf[*idx], buf_len - *idx, "[%pI6c]", | 168 | len = snprintf(&buf[*idx], buf_len - *idx, "[%pI6]", |
259 | &addr->in6) + 1; | 169 | &addr->in6) + 1; |
260 | else | 170 | else |
261 | #endif | 171 | #endif |
@@ -482,41 +392,42 @@ struct ip_vs_protocol { | |||
482 | 392 | ||
483 | void (*exit)(struct ip_vs_protocol *pp); | 393 | void (*exit)(struct ip_vs_protocol *pp); |
484 | 394 | ||
485 | int (*init_netns)(struct net *net, struct ip_vs_proto_data *pd); | 395 | void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd); |
486 | 396 | ||
487 | void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd); | 397 | void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd); |
488 | 398 | ||
489 | int (*conn_schedule)(int af, struct sk_buff *skb, | 399 | int (*conn_schedule)(int af, struct sk_buff *skb, |
490 | struct ip_vs_proto_data *pd, | 400 | struct ip_vs_proto_data *pd, |
491 | int *verdict, struct ip_vs_conn **cpp, | 401 | int *verdict, struct ip_vs_conn **cpp); |
492 | struct ip_vs_iphdr *iph); | ||
493 | 402 | ||
494 | struct ip_vs_conn * | 403 | struct ip_vs_conn * |
495 | (*conn_in_get)(int af, | 404 | (*conn_in_get)(int af, |
496 | const struct sk_buff *skb, | 405 | const struct sk_buff *skb, |
497 | const struct ip_vs_iphdr *iph, | 406 | const struct ip_vs_iphdr *iph, |
407 | unsigned int proto_off, | ||
498 | int inverse); | 408 | int inverse); |
499 | 409 | ||
500 | struct ip_vs_conn * | 410 | struct ip_vs_conn * |
501 | (*conn_out_get)(int af, | 411 | (*conn_out_get)(int af, |
502 | const struct sk_buff *skb, | 412 | const struct sk_buff *skb, |
503 | const struct ip_vs_iphdr *iph, | 413 | const struct ip_vs_iphdr *iph, |
414 | unsigned int proto_off, | ||
504 | int inverse); | 415 | int inverse); |
505 | 416 | ||
506 | int (*snat_handler)(struct sk_buff *skb, struct ip_vs_protocol *pp, | 417 | int (*snat_handler)(struct sk_buff *skb, |
507 | struct ip_vs_conn *cp, struct ip_vs_iphdr *iph); | 418 | struct ip_vs_protocol *pp, struct ip_vs_conn *cp); |
508 | 419 | ||
509 | int (*dnat_handler)(struct sk_buff *skb, struct ip_vs_protocol *pp, | 420 | int (*dnat_handler)(struct sk_buff *skb, |
510 | struct ip_vs_conn *cp, struct ip_vs_iphdr *iph); | 421 | struct ip_vs_protocol *pp, struct ip_vs_conn *cp); |
511 | 422 | ||
512 | int (*csum_check)(int af, struct sk_buff *skb, | 423 | int (*csum_check)(int af, struct sk_buff *skb, |
513 | struct ip_vs_protocol *pp); | 424 | struct ip_vs_protocol *pp); |
514 | 425 | ||
515 | const char *(*state_name)(int state); | 426 | const char *(*state_name)(int state); |
516 | 427 | ||
517 | void (*state_transition)(struct ip_vs_conn *cp, int direction, | 428 | int (*state_transition)(struct ip_vs_conn *cp, int direction, |
518 | const struct sk_buff *skb, | 429 | const struct sk_buff *skb, |
519 | struct ip_vs_proto_data *pd); | 430 | struct ip_vs_proto_data *pd); |
520 | 431 | ||
521 | int (*register_app)(struct net *net, struct ip_vs_app *inc); | 432 | int (*register_app)(struct net *net, struct ip_vs_app *inc); |
522 | 433 | ||
@@ -593,7 +504,6 @@ struct ip_vs_conn { | |||
593 | * state transition triggerd | 504 | * state transition triggerd |
594 | * synchronization | 505 | * synchronization |
595 | */ | 506 | */ |
596 | unsigned long sync_endtime; /* jiffies + sent_retries */ | ||
597 | 507 | ||
598 | /* Control members */ | 508 | /* Control members */ |
599 | struct ip_vs_conn *control; /* Master control connection */ | 509 | struct ip_vs_conn *control; /* Master control connection */ |
@@ -607,7 +517,7 @@ struct ip_vs_conn { | |||
607 | NF_ACCEPT can be returned when destination is local. | 517 | NF_ACCEPT can be returned when destination is local. |
608 | */ | 518 | */ |
609 | 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, |
610 | struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph); | 520 | struct ip_vs_protocol *pp); |
611 | 521 | ||
612 | /* Note: we can group the following members into a structure, | 522 | /* Note: we can group the following members into a structure, |
613 | in order to save more space, and the following members are | 523 | in order to save more space, and the following members are |
@@ -669,8 +579,8 @@ struct ip_vs_service_user_kern { | |||
669 | /* virtual service options */ | 579 | /* virtual service options */ |
670 | char *sched_name; | 580 | char *sched_name; |
671 | char *pe_name; | 581 | char *pe_name; |
672 | unsigned int flags; /* virtual service flags */ | 582 | unsigned flags; /* virtual service flags */ |
673 | unsigned int timeout; /* persistent timeout in sec */ | 583 | unsigned timeout; /* persistent timeout in sec */ |
674 | u32 netmask; /* persistent netmask */ | 584 | u32 netmask; /* persistent netmask */ |
675 | }; | 585 | }; |
676 | 586 | ||
@@ -681,7 +591,7 @@ struct ip_vs_dest_user_kern { | |||
681 | u16 port; | 591 | u16 port; |
682 | 592 | ||
683 | /* real server options */ | 593 | /* real server options */ |
684 | unsigned int conn_flags; /* connection flags */ | 594 | unsigned conn_flags; /* connection flags */ |
685 | int weight; /* destination weight */ | 595 | int weight; /* destination weight */ |
686 | 596 | ||
687 | /* thresholds for active connections */ | 597 | /* thresholds for active connections */ |
@@ -705,8 +615,8 @@ struct ip_vs_service { | |||
705 | union nf_inet_addr addr; /* IP address for virtual service */ | 615 | union nf_inet_addr addr; /* IP address for virtual service */ |
706 | __be16 port; /* port number for the service */ | 616 | __be16 port; /* port number for the service */ |
707 | __u32 fwmark; /* firewall mark of the service */ | 617 | __u32 fwmark; /* firewall mark of the service */ |
708 | unsigned int flags; /* service status flags */ | 618 | unsigned flags; /* service status flags */ |
709 | unsigned int timeout; /* persistent timeout in ticks */ | 619 | unsigned timeout; /* persistent timeout in ticks */ |
710 | __be32 netmask; /* grouping granularity */ | 620 | __be32 netmask; /* grouping granularity */ |
711 | struct net *net; | 621 | struct net *net; |
712 | 622 | ||
@@ -736,7 +646,7 @@ struct ip_vs_dest { | |||
736 | u16 af; /* address family */ | 646 | u16 af; /* address family */ |
737 | __be16 port; /* port number of the server */ | 647 | __be16 port; /* port number of the server */ |
738 | union nf_inet_addr addr; /* IP address of the server */ | 648 | union nf_inet_addr addr; /* IP address of the server */ |
739 | volatile unsigned int flags; /* dest status flags */ | 649 | volatile unsigned flags; /* dest status flags */ |
740 | atomic_t conn_flags; /* flags to copy to conn */ | 650 | atomic_t conn_flags; /* flags to copy to conn */ |
741 | atomic_t weight; /* server weight */ | 651 | atomic_t weight; /* server weight */ |
742 | 652 | ||
@@ -858,11 +768,13 @@ struct ip_vs_app { | |||
858 | 768 | ||
859 | struct ip_vs_conn * | 769 | struct ip_vs_conn * |
860 | (*conn_in_get)(const struct sk_buff *skb, struct ip_vs_app *app, | 770 | (*conn_in_get)(const struct sk_buff *skb, struct ip_vs_app *app, |
861 | const struct iphdr *iph, int inverse); | 771 | const struct iphdr *iph, unsigned int proto_off, |
772 | int inverse); | ||
862 | 773 | ||
863 | struct ip_vs_conn * | 774 | struct ip_vs_conn * |
864 | (*conn_out_get)(const struct sk_buff *skb, struct ip_vs_app *app, | 775 | (*conn_out_get)(const struct sk_buff *skb, struct ip_vs_app *app, |
865 | const struct iphdr *iph, int inverse); | 776 | const struct iphdr *iph, unsigned int proto_off, |
777 | int inverse); | ||
866 | 778 | ||
867 | int (*state_transition)(struct ip_vs_conn *cp, int direction, | 779 | int (*state_transition)(struct ip_vs_conn *cp, int direction, |
868 | const struct sk_buff *skb, | 780 | const struct sk_buff *skb, |
@@ -871,16 +783,6 @@ struct ip_vs_app { | |||
871 | void (*timeout_change)(struct ip_vs_app *app, int flags); | 783 | void (*timeout_change)(struct ip_vs_app *app, int flags); |
872 | }; | 784 | }; |
873 | 785 | ||
874 | struct ipvs_master_sync_state { | ||
875 | struct list_head sync_queue; | ||
876 | struct ip_vs_sync_buff *sync_buff; | ||
877 | int sync_queue_len; | ||
878 | unsigned int sync_queue_delay; | ||
879 | struct task_struct *master_thread; | ||
880 | struct delayed_work master_wakeup_work; | ||
881 | struct netns_ipvs *ipvs; | ||
882 | }; | ||
883 | |||
884 | /* IPVS in network namespace */ | 786 | /* IPVS in network namespace */ |
885 | struct netns_ipvs { | 787 | struct netns_ipvs { |
886 | int gen; /* Generation */ | 788 | int gen; /* Generation */ |
@@ -895,6 +797,8 @@ struct netns_ipvs { | |||
895 | struct list_head rs_table[IP_VS_RTAB_SIZE]; | 797 | struct list_head rs_table[IP_VS_RTAB_SIZE]; |
896 | /* ip_vs_app */ | 798 | /* ip_vs_app */ |
897 | struct list_head app_list; | 799 | struct list_head app_list; |
800 | /* ip_vs_ftp */ | ||
801 | struct ip_vs_app *ftp_app; | ||
898 | /* ip_vs_proto */ | 802 | /* ip_vs_proto */ |
899 | #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */ | 803 | #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */ |
900 | struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE]; | 804 | struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE]; |
@@ -965,17 +869,11 @@ struct netns_ipvs { | |||
965 | #endif | 869 | #endif |
966 | int sysctl_snat_reroute; | 870 | int sysctl_snat_reroute; |
967 | int sysctl_sync_ver; | 871 | int sysctl_sync_ver; |
968 | int sysctl_sync_ports; | ||
969 | int sysctl_sync_qlen_max; | ||
970 | int sysctl_sync_sock_size; | ||
971 | int sysctl_cache_bypass; | 872 | int sysctl_cache_bypass; |
972 | int sysctl_expire_nodest_conn; | 873 | int sysctl_expire_nodest_conn; |
973 | int sysctl_expire_quiescent_template; | 874 | int sysctl_expire_quiescent_template; |
974 | int sysctl_sync_threshold[2]; | 875 | int sysctl_sync_threshold[2]; |
975 | unsigned int sysctl_sync_refresh_period; | ||
976 | int sysctl_sync_retries; | ||
977 | int sysctl_nat_icmp_send; | 876 | int sysctl_nat_icmp_send; |
978 | int sysctl_pmtu_disc; | ||
979 | 877 | ||
980 | /* ip_vs_lblc */ | 878 | /* ip_vs_lblc */ |
981 | int sysctl_lblc_expiration; | 879 | int sysctl_lblc_expiration; |
@@ -990,11 +888,13 @@ struct netns_ipvs { | |||
990 | spinlock_t est_lock; | 888 | spinlock_t est_lock; |
991 | struct timer_list est_timer; /* Estimation timer */ | 889 | struct timer_list est_timer; /* Estimation timer */ |
992 | /* ip_vs_sync */ | 890 | /* ip_vs_sync */ |
891 | struct list_head sync_queue; | ||
993 | spinlock_t sync_lock; | 892 | spinlock_t sync_lock; |
994 | struct ipvs_master_sync_state *ms; | 893 | struct ip_vs_sync_buff *sync_buff; |
995 | spinlock_t sync_buff_lock; | 894 | spinlock_t sync_buff_lock; |
996 | struct task_struct **backup_threads; | 895 | struct sockaddr_in sync_mcast_addr; |
997 | int threads_mask; | 896 | struct task_struct *master_thread; |
897 | struct task_struct *backup_thread; | ||
998 | int send_mesg_maxlen; | 898 | int send_mesg_maxlen; |
999 | int recv_mesg_maxlen; | 899 | int recv_mesg_maxlen; |
1000 | volatile int sync_state; | 900 | volatile int sync_state; |
@@ -1011,14 +911,6 @@ struct netns_ipvs { | |||
1011 | #define DEFAULT_SYNC_THRESHOLD 3 | 911 | #define DEFAULT_SYNC_THRESHOLD 3 |
1012 | #define DEFAULT_SYNC_PERIOD 50 | 912 | #define DEFAULT_SYNC_PERIOD 50 |
1013 | #define DEFAULT_SYNC_VER 1 | 913 | #define DEFAULT_SYNC_VER 1 |
1014 | #define DEFAULT_SYNC_REFRESH_PERIOD (0U * HZ) | ||
1015 | #define DEFAULT_SYNC_RETRIES 0 | ||
1016 | #define IPVS_SYNC_WAKEUP_RATE 8 | ||
1017 | #define IPVS_SYNC_QLEN_MAX (IPVS_SYNC_WAKEUP_RATE * 4) | ||
1018 | #define IPVS_SYNC_SEND_DELAY (HZ / 50) | ||
1019 | #define IPVS_SYNC_CHECK_PERIOD HZ | ||
1020 | #define IPVS_SYNC_FLUSH_TIME (HZ * 2) | ||
1021 | #define IPVS_SYNC_PORTS_MAX (1 << 6) | ||
1022 | 914 | ||
1023 | #ifdef CONFIG_SYSCTL | 915 | #ifdef CONFIG_SYSCTL |
1024 | 916 | ||
@@ -1029,17 +921,7 @@ static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs) | |||
1029 | 921 | ||
1030 | static inline int sysctl_sync_period(struct netns_ipvs *ipvs) | 922 | static inline int sysctl_sync_period(struct netns_ipvs *ipvs) |
1031 | { | 923 | { |
1032 | return ACCESS_ONCE(ipvs->sysctl_sync_threshold[1]); | 924 | return ipvs->sysctl_sync_threshold[1]; |
1033 | } | ||
1034 | |||
1035 | static inline unsigned int sysctl_sync_refresh_period(struct netns_ipvs *ipvs) | ||
1036 | { | ||
1037 | return ACCESS_ONCE(ipvs->sysctl_sync_refresh_period); | ||
1038 | } | ||
1039 | |||
1040 | static inline int sysctl_sync_retries(struct netns_ipvs *ipvs) | ||
1041 | { | ||
1042 | return ipvs->sysctl_sync_retries; | ||
1043 | } | 925 | } |
1044 | 926 | ||
1045 | static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) | 927 | static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) |
@@ -1047,26 +929,6 @@ static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) | |||
1047 | return ipvs->sysctl_sync_ver; | 929 | return ipvs->sysctl_sync_ver; |
1048 | } | 930 | } |
1049 | 931 | ||
1050 | static inline int sysctl_sync_ports(struct netns_ipvs *ipvs) | ||
1051 | { | ||
1052 | return ACCESS_ONCE(ipvs->sysctl_sync_ports); | ||
1053 | } | ||
1054 | |||
1055 | static inline int sysctl_sync_qlen_max(struct netns_ipvs *ipvs) | ||
1056 | { | ||
1057 | return ipvs->sysctl_sync_qlen_max; | ||
1058 | } | ||
1059 | |||
1060 | static inline int sysctl_sync_sock_size(struct netns_ipvs *ipvs) | ||
1061 | { | ||
1062 | return ipvs->sysctl_sync_sock_size; | ||
1063 | } | ||
1064 | |||
1065 | static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs) | ||
1066 | { | ||
1067 | return ipvs->sysctl_pmtu_disc; | ||
1068 | } | ||
1069 | |||
1070 | #else | 932 | #else |
1071 | 933 | ||
1072 | static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs) | 934 | static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs) |
@@ -1079,48 +941,18 @@ static inline int sysctl_sync_period(struct netns_ipvs *ipvs) | |||
1079 | return DEFAULT_SYNC_PERIOD; | 941 | return DEFAULT_SYNC_PERIOD; |
1080 | } | 942 | } |
1081 | 943 | ||
1082 | static inline unsigned int sysctl_sync_refresh_period(struct netns_ipvs *ipvs) | ||
1083 | { | ||
1084 | return DEFAULT_SYNC_REFRESH_PERIOD; | ||
1085 | } | ||
1086 | |||
1087 | static inline int sysctl_sync_retries(struct netns_ipvs *ipvs) | ||
1088 | { | ||
1089 | return DEFAULT_SYNC_RETRIES & 3; | ||
1090 | } | ||
1091 | |||
1092 | static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) | 944 | static inline int sysctl_sync_ver(struct netns_ipvs *ipvs) |
1093 | { | 945 | { |
1094 | return DEFAULT_SYNC_VER; | 946 | return DEFAULT_SYNC_VER; |
1095 | } | 947 | } |
1096 | 948 | ||
1097 | static inline int sysctl_sync_ports(struct netns_ipvs *ipvs) | ||
1098 | { | ||
1099 | return 1; | ||
1100 | } | ||
1101 | |||
1102 | static inline int sysctl_sync_qlen_max(struct netns_ipvs *ipvs) | ||
1103 | { | ||
1104 | return IPVS_SYNC_QLEN_MAX; | ||
1105 | } | ||
1106 | |||
1107 | static inline int sysctl_sync_sock_size(struct netns_ipvs *ipvs) | ||
1108 | { | ||
1109 | return 0; | ||
1110 | } | ||
1111 | |||
1112 | static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs) | ||
1113 | { | ||
1114 | return 1; | ||
1115 | } | ||
1116 | |||
1117 | #endif | 949 | #endif |
1118 | 950 | ||
1119 | /* | 951 | /* |
1120 | * IPVS core functions | 952 | * IPVS core functions |
1121 | * (from ip_vs_core.c) | 953 | * (from ip_vs_core.c) |
1122 | */ | 954 | */ |
1123 | extern const char *ip_vs_proto_name(unsigned int proto); | 955 | extern const char *ip_vs_proto_name(unsigned proto); |
1124 | extern void ip_vs_init_hash_table(struct list_head *table, int rows); | 956 | extern void ip_vs_init_hash_table(struct list_head *table, int rows); |
1125 | #define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table((t), ARRAY_SIZE((t))) | 957 | #define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table((t), ARRAY_SIZE((t))) |
1126 | 958 | ||
@@ -1161,12 +993,14 @@ struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p); | |||
1161 | 993 | ||
1162 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, | 994 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, |
1163 | const struct ip_vs_iphdr *iph, | 995 | const struct ip_vs_iphdr *iph, |
996 | unsigned int proto_off, | ||
1164 | int inverse); | 997 | int inverse); |
1165 | 998 | ||
1166 | struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p); | 999 | struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p); |
1167 | 1000 | ||
1168 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, | 1001 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, |
1169 | const struct ip_vs_iphdr *iph, | 1002 | const struct ip_vs_iphdr *iph, |
1003 | unsigned int proto_off, | ||
1170 | int inverse); | 1004 | int inverse); |
1171 | 1005 | ||
1172 | /* put back the conn without restarting its timer */ | 1006 | /* put back the conn without restarting its timer */ |
@@ -1179,7 +1013,7 @@ extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); | |||
1179 | 1013 | ||
1180 | struct ip_vs_conn *ip_vs_conn_new(const struct ip_vs_conn_param *p, | 1014 | struct ip_vs_conn *ip_vs_conn_new(const struct ip_vs_conn_param *p, |
1181 | const union nf_inet_addr *daddr, | 1015 | const union nf_inet_addr *daddr, |
1182 | __be16 dport, unsigned int flags, | 1016 | __be16 dport, unsigned flags, |
1183 | struct ip_vs_dest *dest, __u32 fwmark); | 1017 | struct ip_vs_dest *dest, __u32 fwmark); |
1184 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); | 1018 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); |
1185 | 1019 | ||
@@ -1273,8 +1107,7 @@ extern void ip_vs_service_net_cleanup(struct net *net); | |||
1273 | * (from ip_vs_app.c) | 1107 | * (from ip_vs_app.c) |
1274 | */ | 1108 | */ |
1275 | #define IP_VS_APP_MAX_PORTS 8 | 1109 | #define IP_VS_APP_MAX_PORTS 8 |
1276 | extern struct ip_vs_app *register_ip_vs_app(struct net *net, | 1110 | extern int register_ip_vs_app(struct net *net, struct ip_vs_app *app); |
1277 | struct ip_vs_app *app); | ||
1278 | extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app); | 1111 | extern void unregister_ip_vs_app(struct net *net, struct ip_vs_app *app); |
1279 | extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); | 1112 | extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1280 | extern void ip_vs_unbind_app(struct ip_vs_conn *cp); | 1113 | extern void ip_vs_unbind_app(struct ip_vs_conn *cp); |
@@ -1293,16 +1126,17 @@ int unregister_ip_vs_pe(struct ip_vs_pe *pe); | |||
1293 | struct ip_vs_pe *ip_vs_pe_getbyname(const char *name); | 1126 | struct ip_vs_pe *ip_vs_pe_getbyname(const char *name); |
1294 | struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name); | 1127 | struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name); |
1295 | 1128 | ||
1296 | /* | 1129 | static inline void ip_vs_pe_get(const struct ip_vs_pe *pe) |
1297 | * Use a #define to avoid all of module.h just for these trivial ops | 1130 | { |
1298 | */ | 1131 | if (pe && pe->module) |
1299 | #define ip_vs_pe_get(pe) \ | ||
1300 | if (pe && pe->module) \ | ||
1301 | __module_get(pe->module); | 1132 | __module_get(pe->module); |
1133 | } | ||
1302 | 1134 | ||
1303 | #define ip_vs_pe_put(pe) \ | 1135 | static inline void ip_vs_pe_put(const struct ip_vs_pe *pe) |
1304 | if (pe && pe->module) \ | 1136 | { |
1137 | if (pe && pe->module) | ||
1305 | module_put(pe->module); | 1138 | module_put(pe->module); |
1139 | } | ||
1306 | 1140 | ||
1307 | /* | 1141 | /* |
1308 | * IPVS protocol functions (from ip_vs_proto.c) | 1142 | * IPVS protocol functions (from ip_vs_proto.c) |
@@ -1339,10 +1173,9 @@ extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name); | |||
1339 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); | 1173 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); |
1340 | extern struct ip_vs_conn * | 1174 | extern struct ip_vs_conn * |
1341 | ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb, | 1175 | ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb, |
1342 | struct ip_vs_proto_data *pd, int *ignored, | 1176 | struct ip_vs_proto_data *pd, int *ignored); |
1343 | struct ip_vs_iphdr *iph); | ||
1344 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, | 1177 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, |
1345 | struct ip_vs_proto_data *pd, struct ip_vs_iphdr *iph); | 1178 | struct ip_vs_proto_data *pd); |
1346 | 1179 | ||
1347 | extern void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg); | 1180 | extern void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg); |
1348 | 1181 | ||
@@ -1351,8 +1184,10 @@ extern void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg); | |||
1351 | * IPVS control data and functions (from ip_vs_ctl.c) | 1184 | * IPVS control data and functions (from ip_vs_ctl.c) |
1352 | */ | 1185 | */ |
1353 | extern struct ip_vs_stats ip_vs_stats; | 1186 | extern struct ip_vs_stats ip_vs_stats; |
1187 | extern const struct ctl_path net_vs_ctl_path[]; | ||
1354 | extern int sysctl_ip_vs_sync_ver; | 1188 | extern int sysctl_ip_vs_sync_ver; |
1355 | 1189 | ||
1190 | extern void ip_vs_sync_switch_mode(struct net *net, int mode); | ||
1356 | extern struct ip_vs_service * | 1191 | extern struct ip_vs_service * |
1357 | ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol, | 1192 | ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol, |
1358 | const union nf_inet_addr *vaddr, __be16 vport); | 1193 | const union nf_inet_addr *vaddr, __be16 vport); |
@@ -1368,14 +1203,12 @@ ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol, | |||
1368 | 1203 | ||
1369 | extern int ip_vs_use_count_inc(void); | 1204 | extern int ip_vs_use_count_inc(void); |
1370 | extern void ip_vs_use_count_dec(void); | 1205 | extern void ip_vs_use_count_dec(void); |
1371 | extern int ip_vs_register_nl_ioctl(void); | ||
1372 | extern void ip_vs_unregister_nl_ioctl(void); | ||
1373 | extern int ip_vs_control_init(void); | 1206 | extern int ip_vs_control_init(void); |
1374 | extern void ip_vs_control_cleanup(void); | 1207 | extern void ip_vs_control_cleanup(void); |
1375 | extern struct ip_vs_dest * | 1208 | extern struct ip_vs_dest * |
1376 | ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, | 1209 | ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, |
1377 | __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, | 1210 | __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, |
1378 | __u16 protocol, __u32 fwmark, __u32 flags); | 1211 | __u16 protocol, __u32 fwmark); |
1379 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | 1212 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); |
1380 | 1213 | ||
1381 | 1214 | ||
@@ -1386,7 +1219,7 @@ extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | |||
1386 | extern int start_sync_thread(struct net *net, int state, char *mcast_ifn, | 1219 | extern int start_sync_thread(struct net *net, int state, char *mcast_ifn, |
1387 | __u8 syncid); | 1220 | __u8 syncid); |
1388 | extern int stop_sync_thread(struct net *net, int state); | 1221 | extern int stop_sync_thread(struct net *net, int state); |
1389 | extern void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp, int pkts); | 1222 | extern void ip_vs_sync_conn(struct net *net, struct ip_vs_conn *cp); |
1390 | 1223 | ||
1391 | 1224 | ||
1392 | /* | 1225 | /* |
@@ -1401,38 +1234,33 @@ extern void ip_vs_read_estimator(struct ip_vs_stats_user *dst, | |||
1401 | /* | 1234 | /* |
1402 | * Various IPVS packet transmitters (from ip_vs_xmit.c) | 1235 | * Various IPVS packet transmitters (from ip_vs_xmit.c) |
1403 | */ | 1236 | */ |
1404 | extern int ip_vs_null_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, | 1237 | extern int ip_vs_null_xmit |
1405 | struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph); | 1238 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1406 | extern int ip_vs_bypass_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, | 1239 | extern int ip_vs_bypass_xmit |
1407 | struct ip_vs_protocol *pp, | 1240 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1408 | struct ip_vs_iphdr *iph); | 1241 | extern int ip_vs_nat_xmit |
1409 | extern int ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, | 1242 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1410 | struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph); | 1243 | extern int ip_vs_tunnel_xmit |
1411 | extern int ip_vs_tunnel_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, | 1244 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1412 | struct ip_vs_protocol *pp, | 1245 | extern int ip_vs_dr_xmit |
1413 | struct ip_vs_iphdr *iph); | 1246 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1414 | extern int ip_vs_dr_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, | 1247 | extern int ip_vs_icmp_xmit |
1415 | struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph); | 1248 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, |
1416 | extern int ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp, | 1249 | int offset, unsigned int hooknum); |
1417 | struct ip_vs_protocol *pp, int offset, | ||
1418 | unsigned int hooknum, struct ip_vs_iphdr *iph); | ||
1419 | extern void ip_vs_dst_reset(struct ip_vs_dest *dest); | 1250 | extern void ip_vs_dst_reset(struct ip_vs_dest *dest); |
1420 | 1251 | ||
1421 | #ifdef CONFIG_IP_VS_IPV6 | 1252 | #ifdef CONFIG_IP_VS_IPV6 |
1422 | extern int ip_vs_bypass_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, | 1253 | extern int ip_vs_bypass_xmit_v6 |
1423 | struct ip_vs_protocol *pp, | 1254 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1424 | struct ip_vs_iphdr *iph); | 1255 | extern int ip_vs_nat_xmit_v6 |
1425 | extern int ip_vs_nat_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, | 1256 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1426 | struct ip_vs_protocol *pp, | 1257 | extern int ip_vs_tunnel_xmit_v6 |
1427 | struct ip_vs_iphdr *iph); | 1258 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1428 | extern int ip_vs_tunnel_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, | 1259 | extern int ip_vs_dr_xmit_v6 |
1429 | struct ip_vs_protocol *pp, | 1260 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp); |
1430 | struct ip_vs_iphdr *iph); | 1261 | extern int ip_vs_icmp_xmit_v6 |
1431 | extern int ip_vs_dr_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, | 1262 | (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, |
1432 | struct ip_vs_protocol *pp, struct ip_vs_iphdr *iph); | 1263 | int offset, unsigned int hooknum); |
1433 | extern int ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp, | ||
1434 | struct ip_vs_protocol *pp, int offset, | ||
1435 | unsigned int hooknum, struct ip_vs_iphdr *iph); | ||
1436 | #endif | 1264 | #endif |
1437 | 1265 | ||
1438 | #ifdef CONFIG_SYSCTL | 1266 | #ifdef CONFIG_SYSCTL |
@@ -1526,7 +1354,7 @@ static inline void ip_vs_notrack(struct sk_buff *skb) | |||
1526 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 1354 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
1527 | 1355 | ||
1528 | if (!ct || !nf_ct_is_untracked(ct)) { | 1356 | if (!ct || !nf_ct_is_untracked(ct)) { |
1529 | nf_conntrack_put(skb->nfct); | 1357 | nf_reset(skb); |
1530 | skb->nfct = &nf_ct_untracked_get()->ct_general; | 1358 | skb->nfct = &nf_ct_untracked_get()->ct_general; |
1531 | skb->nfctinfo = IP_CT_NEW; | 1359 | skb->nfctinfo = IP_CT_NEW; |
1532 | nf_conntrack_get(skb->nfct); | 1360 | nf_conntrack_get(skb->nfct); |
@@ -1550,7 +1378,7 @@ static inline int ip_vs_conntrack_enabled(struct netns_ipvs *ipvs) | |||
1550 | 1378 | ||
1551 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, | 1379 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, |
1552 | int outin); | 1380 | int outin); |
1553 | extern int ip_vs_confirm_conntrack(struct sk_buff *skb); | 1381 | extern int ip_vs_confirm_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp); |
1554 | extern void ip_vs_nfct_expect_related(struct sk_buff *skb, struct nf_conn *ct, | 1382 | extern void ip_vs_nfct_expect_related(struct sk_buff *skb, struct nf_conn *ct, |
1555 | struct ip_vs_conn *cp, u_int8_t proto, | 1383 | struct ip_vs_conn *cp, u_int8_t proto, |
1556 | const __be16 port, int from_rs); | 1384 | const __be16 port, int from_rs); |
@@ -1568,7 +1396,8 @@ static inline void ip_vs_update_conntrack(struct sk_buff *skb, | |||
1568 | { | 1396 | { |
1569 | } | 1397 | } |
1570 | 1398 | ||
1571 | static inline int ip_vs_confirm_conntrack(struct sk_buff *skb) | 1399 | static inline int ip_vs_confirm_conntrack(struct sk_buff *skb, |
1400 | struct ip_vs_conn *cp) | ||
1572 | { | 1401 | { |
1573 | return NF_ACCEPT; | 1402 | return NF_ACCEPT; |
1574 | } | 1403 | } |
diff --git a/include/net/ipip.h b/include/net/ipip.h index 21947cf4fa4..a32654d5273 100644 --- a/include/net/ipip.h +++ b/include/net/ipip.h | |||
@@ -2,7 +2,6 @@ | |||
2 | #define __NET_IPIP_H 1 | 2 | #define __NET_IPIP_H 1 |
3 | 3 | ||
4 | #include <linux/if_tunnel.h> | 4 | #include <linux/if_tunnel.h> |
5 | #include <net/gro_cells.h> | ||
6 | #include <net/ip.h> | 5 | #include <net/ip.h> |
7 | 6 | ||
8 | /* Keep error state on tunnel for 30 sec */ | 7 | /* Keep error state on tunnel for 30 sec */ |
@@ -37,8 +36,6 @@ struct ip_tunnel { | |||
37 | #endif | 36 | #endif |
38 | struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */ | 37 | struct ip_tunnel_prl_entry __rcu *prl; /* potential router list */ |
39 | unsigned int prl_count; /* # of entries in PRL */ | 38 | unsigned int prl_count; /* # of entries in PRL */ |
40 | |||
41 | struct gro_cells gro_cells; | ||
42 | }; | 39 | }; |
43 | 40 | ||
44 | struct ip_tunnel_prl_entry { | 41 | struct ip_tunnel_prl_entry { |
@@ -48,27 +45,23 @@ struct ip_tunnel_prl_entry { | |||
48 | struct rcu_head rcu_head; | 45 | struct rcu_head rcu_head; |
49 | }; | 46 | }; |
50 | 47 | ||
51 | static inline void iptunnel_xmit(struct sk_buff *skb, struct net_device *dev) | 48 | #define __IPTUNNEL_XMIT(stats1, stats2) do { \ |
52 | { | 49 | int err; \ |
53 | int err; | 50 | int pkt_len = skb->len - skb_transport_offset(skb); \ |
54 | struct iphdr *iph = ip_hdr(skb); | 51 | \ |
55 | int pkt_len = skb->len - skb_transport_offset(skb); | 52 | skb->ip_summed = CHECKSUM_NONE; \ |
56 | struct pcpu_tstats *tstats = this_cpu_ptr(dev->tstats); | 53 | ip_select_ident(iph, &rt->dst, NULL); \ |
57 | 54 | \ | |
58 | nf_reset(skb); | 55 | err = ip_local_out(skb); \ |
59 | skb->ip_summed = CHECKSUM_NONE; | 56 | if (likely(net_xmit_eval(err) == 0)) { \ |
60 | ip_select_ident(iph, skb_dst(skb), NULL); | 57 | (stats1)->tx_bytes += pkt_len; \ |
58 | (stats1)->tx_packets++; \ | ||
59 | } else { \ | ||
60 | (stats2)->tx_errors++; \ | ||
61 | (stats2)->tx_aborted_errors++; \ | ||
62 | } \ | ||
63 | } while (0) | ||
61 | 64 | ||
62 | err = ip_local_out(skb); | 65 | #define IPTUNNEL_XMIT() __IPTUNNEL_XMIT(txq, stats) |
63 | if (likely(net_xmit_eval(err) == 0)) { | ||
64 | u64_stats_update_begin(&tstats->syncp); | ||
65 | tstats->tx_bytes += pkt_len; | ||
66 | tstats->tx_packets++; | ||
67 | u64_stats_update_end(&tstats->syncp); | ||
68 | } else { | ||
69 | dev->stats.tx_errors++; | ||
70 | dev->stats.tx_aborted_errors++; | ||
71 | } | ||
72 | } | ||
73 | 66 | ||
74 | #endif | 67 | #endif |
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 5af66b26ebd..3b5ac1fbff3 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -34,7 +34,6 @@ | |||
34 | #define NEXTHDR_IPV6 41 /* IPv6 in IPv6 */ | 34 | #define NEXTHDR_IPV6 41 /* IPv6 in IPv6 */ |
35 | #define NEXTHDR_ROUTING 43 /* Routing header. */ | 35 | #define NEXTHDR_ROUTING 43 /* Routing header. */ |
36 | #define NEXTHDR_FRAGMENT 44 /* Fragmentation/reassembly header. */ | 36 | #define NEXTHDR_FRAGMENT 44 /* Fragmentation/reassembly header. */ |
37 | #define NEXTHDR_GRE 47 /* GRE header. */ | ||
38 | #define NEXTHDR_ESP 50 /* Encapsulating security payload. */ | 37 | #define NEXTHDR_ESP 50 /* Encapsulating security payload. */ |
39 | #define NEXTHDR_AUTH 51 /* Authentication header. */ | 38 | #define NEXTHDR_AUTH 51 /* Authentication header. */ |
40 | #define NEXTHDR_ICMP 58 /* ICMP for IPv6. */ | 39 | #define NEXTHDR_ICMP 58 /* ICMP for IPv6. */ |
@@ -114,6 +113,7 @@ struct frag_hdr { | |||
114 | 113 | ||
115 | /* sysctls */ | 114 | /* sysctls */ |
116 | extern int sysctl_mld_max_msf; | 115 | extern int sysctl_mld_max_msf; |
116 | extern struct ctl_path net_ipv6_ctl_path[]; | ||
117 | 117 | ||
118 | #define _DEVINC(net, statname, modifier, idev, field) \ | 118 | #define _DEVINC(net, statname, modifier, idev, field) \ |
119 | ({ \ | 119 | ({ \ |
@@ -132,15 +132,6 @@ extern int sysctl_mld_max_msf; | |||
132 | SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ | 132 | SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ |
133 | }) | 133 | }) |
134 | 134 | ||
135 | /* per device and per net counters are atomic_long_t */ | ||
136 | #define _DEVINC_ATOMIC_ATOMIC(net, statname, idev, field) \ | ||
137 | ({ \ | ||
138 | struct inet6_dev *_idev = (idev); \ | ||
139 | if (likely(_idev != NULL)) \ | ||
140 | SNMP_INC_STATS_ATOMIC_LONG((_idev)->stats.statname##dev, (field)); \ | ||
141 | SNMP_INC_STATS_ATOMIC_LONG((net)->mib.statname##_statistics, (field));\ | ||
142 | }) | ||
143 | |||
144 | #define _DEVADD(net, statname, modifier, idev, field, val) \ | 135 | #define _DEVADD(net, statname, modifier, idev, field, val) \ |
145 | ({ \ | 136 | ({ \ |
146 | struct inet6_dev *_idev = (idev); \ | 137 | struct inet6_dev *_idev = (idev); \ |
@@ -177,11 +168,11 @@ extern int sysctl_mld_max_msf; | |||
177 | _DEVINCATOMIC(net, icmpv6, _BH, idev, field) | 168 | _DEVINCATOMIC(net, icmpv6, _BH, idev, field) |
178 | 169 | ||
179 | #define ICMP6MSGOUT_INC_STATS(net, idev, field) \ | 170 | #define ICMP6MSGOUT_INC_STATS(net, idev, field) \ |
180 | _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field +256) | 171 | _DEVINCATOMIC(net, icmpv6msg, , idev, field +256) |
181 | #define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \ | 172 | #define ICMP6MSGOUT_INC_STATS_BH(net, idev, field) \ |
182 | _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field +256) | 173 | _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field +256) |
183 | #define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \ | 174 | #define ICMP6MSGIN_INC_STATS_BH(net, idev, field) \ |
184 | _DEVINC_ATOMIC_ATOMIC(net, icmpv6msg, idev, field) | 175 | _DEVINCATOMIC(net, icmpv6msg, _BH, idev, field) |
185 | 176 | ||
186 | struct ip6_ra_chain { | 177 | struct ip6_ra_chain { |
187 | struct ip6_ra_chain *next; | 178 | struct ip6_ra_chain *next; |
@@ -223,10 +214,7 @@ struct ip6_flowlabel { | |||
223 | struct ipv6_txoptions *opt; | 214 | struct ipv6_txoptions *opt; |
224 | unsigned long linger; | 215 | unsigned long linger; |
225 | u8 share; | 216 | u8 share; |
226 | union { | 217 | u32 owner; |
227 | struct pid *pid; | ||
228 | kuid_t uid; | ||
229 | } owner; | ||
230 | unsigned long lastuse; | 218 | unsigned long lastuse; |
231 | unsigned long expires; | 219 | unsigned long expires; |
232 | struct net *fl_net; | 220 | struct net *fl_net; |
@@ -255,8 +243,6 @@ static inline void fl6_sock_release(struct ip6_flowlabel *fl) | |||
255 | atomic_dec(&fl->users); | 243 | atomic_dec(&fl->users); |
256 | } | 244 | } |
257 | 245 | ||
258 | extern void icmpv6_notify(struct sk_buff *skb, u8 type, u8 code, __be32 info); | ||
259 | |||
260 | extern int ip6_ra_control(struct sock *sk, int sel); | 246 | extern int ip6_ra_control(struct sock *sk, int sel); |
261 | 247 | ||
262 | extern int ipv6_parse_hopopts(struct sk_buff *skb); | 248 | extern int ipv6_parse_hopopts(struct sk_buff *skb); |
@@ -269,28 +255,10 @@ extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_t | |||
269 | struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, | 255 | struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, |
270 | struct ipv6_txoptions *opt); | 256 | struct ipv6_txoptions *opt); |
271 | 257 | ||
272 | extern bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb); | 258 | extern int ipv6_opt_accepted(struct sock *sk, struct sk_buff *skb); |
273 | 259 | ||
274 | static inline bool ipv6_accept_ra(struct inet6_dev *idev) | 260 | int ip6_frag_nqueues(struct net *net); |
275 | { | 261 | int ip6_frag_mem(struct net *net); |
276 | /* If forwarding is enabled, RA are not accepted unless the special | ||
277 | * hybrid mode (accept_ra=2) is enabled. | ||
278 | */ | ||
279 | return idev->cnf.forwarding ? idev->cnf.accept_ra == 2 : | ||
280 | idev->cnf.accept_ra; | ||
281 | } | ||
282 | |||
283 | #if IS_ENABLED(CONFIG_IPV6) | ||
284 | static inline int ip6_frag_nqueues(struct net *net) | ||
285 | { | ||
286 | return net->ipv6.frags.nqueues; | ||
287 | } | ||
288 | |||
289 | static inline int ip6_frag_mem(struct net *net) | ||
290 | { | ||
291 | return atomic_read(&net->ipv6.frags.mem); | ||
292 | } | ||
293 | #endif | ||
294 | 262 | ||
295 | #define IPV6_FRAG_HIGH_THRESH (256 * 1024) /* 262144 */ | 263 | #define IPV6_FRAG_HIGH_THRESH (256 * 1024) /* 262144 */ |
296 | #define IPV6_FRAG_LOW_THRESH (192 * 1024) /* 196608 */ | 264 | #define IPV6_FRAG_LOW_THRESH (192 * 1024) /* 196608 */ |
@@ -322,23 +290,19 @@ static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr | |||
322 | return memcmp(a1, a2, sizeof(struct in6_addr)); | 290 | return memcmp(a1, a2, sizeof(struct in6_addr)); |
323 | } | 291 | } |
324 | 292 | ||
325 | static inline bool | 293 | static inline int |
326 | 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, |
327 | const struct in6_addr *a2) | 295 | const struct in6_addr *a2) |
328 | { | 296 | { |
329 | #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 | ||
330 | const unsigned long *ul1 = (const unsigned long *)a1; | ||
331 | const unsigned long *ulm = (const unsigned long *)m; | ||
332 | const unsigned long *ul2 = (const unsigned long *)a2; | ||
333 | |||
334 | return !!(((ul1[0] ^ ul2[0]) & ulm[0]) | | ||
335 | ((ul1[1] ^ ul2[1]) & ulm[1])); | ||
336 | #else | ||
337 | 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]) | |
338 | ((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]) | |
339 | ((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]) | |
340 | ((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])); |
341 | #endif | 301 | } |
302 | |||
303 | static inline void ipv6_addr_copy(struct in6_addr *a1, const struct in6_addr *a2) | ||
304 | { | ||
305 | memcpy(a1, a2, sizeof(struct in6_addr)); | ||
342 | } | 306 | } |
343 | 307 | ||
344 | static inline void ipv6_addr_prefix(struct in6_addr *pfx, | 308 | static inline void ipv6_addr_prefix(struct in6_addr *pfx, |
@@ -365,43 +329,36 @@ static inline void ipv6_addr_set(struct in6_addr *addr, | |||
365 | addr->s6_addr32[3] = w4; | 329 | addr->s6_addr32[3] = w4; |
366 | } | 330 | } |
367 | 331 | ||
368 | static inline bool ipv6_addr_equal(const struct in6_addr *a1, | 332 | static inline int ipv6_addr_equal(const struct in6_addr *a1, |
369 | const struct in6_addr *a2) | 333 | const struct in6_addr *a2) |
370 | { | 334 | { |
371 | #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 | ||
372 | const unsigned long *ul1 = (const unsigned long *)a1; | ||
373 | const unsigned long *ul2 = (const unsigned long *)a2; | ||
374 | |||
375 | return ((ul1[0] ^ ul2[0]) | (ul1[1] ^ ul2[1])) == 0UL; | ||
376 | #else | ||
377 | return ((a1->s6_addr32[0] ^ a2->s6_addr32[0]) | | 335 | return ((a1->s6_addr32[0] ^ a2->s6_addr32[0]) | |
378 | (a1->s6_addr32[1] ^ a2->s6_addr32[1]) | | 336 | (a1->s6_addr32[1] ^ a2->s6_addr32[1]) | |
379 | (a1->s6_addr32[2] ^ a2->s6_addr32[2]) | | 337 | (a1->s6_addr32[2] ^ a2->s6_addr32[2]) | |
380 | (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0; | 338 | (a1->s6_addr32[3] ^ a2->s6_addr32[3])) == 0; |
381 | #endif | ||
382 | } | 339 | } |
383 | 340 | ||
384 | static inline bool __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, | 341 | static inline int __ipv6_prefix_equal(const __be32 *a1, const __be32 *a2, |
385 | unsigned int prefixlen) | 342 | unsigned int prefixlen) |
386 | { | 343 | { |
387 | unsigned int pdw, pbi; | 344 | unsigned pdw, pbi; |
388 | 345 | ||
389 | /* check complete u32 in prefix */ | 346 | /* check complete u32 in prefix */ |
390 | pdw = prefixlen >> 5; | 347 | pdw = prefixlen >> 5; |
391 | if (pdw && memcmp(a1, a2, pdw << 2)) | 348 | if (pdw && memcmp(a1, a2, pdw << 2)) |
392 | return false; | 349 | return 0; |
393 | 350 | ||
394 | /* check incomplete u32 in prefix */ | 351 | /* check incomplete u32 in prefix */ |
395 | pbi = prefixlen & 0x1f; | 352 | pbi = prefixlen & 0x1f; |
396 | if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi)))) | 353 | if (pbi && ((a1[pdw] ^ a2[pdw]) & htonl((0xffffffff) << (32 - pbi)))) |
397 | return false; | 354 | return 0; |
398 | 355 | ||
399 | return true; | 356 | return 1; |
400 | } | 357 | } |
401 | 358 | ||
402 | static inline bool ipv6_prefix_equal(const struct in6_addr *a1, | 359 | static inline int ipv6_prefix_equal(const struct in6_addr *a1, |
403 | const struct in6_addr *a2, | 360 | const struct in6_addr *a2, |
404 | unsigned int prefixlen) | 361 | unsigned int prefixlen) |
405 | { | 362 | { |
406 | return __ipv6_prefix_equal(a1->s6_addr32, a2->s6_addr32, | 363 | return __ipv6_prefix_equal(a1->s6_addr32, a2->s6_addr32, |
407 | prefixlen); | 364 | prefixlen); |
@@ -427,59 +384,21 @@ struct ip6_create_arg { | |||
427 | }; | 384 | }; |
428 | 385 | ||
429 | void ip6_frag_init(struct inet_frag_queue *q, void *a); | 386 | void ip6_frag_init(struct inet_frag_queue *q, void *a); |
430 | bool ip6_frag_match(struct inet_frag_queue *q, void *a); | 387 | int ip6_frag_match(struct inet_frag_queue *q, void *a); |
431 | |||
432 | /* | ||
433 | * Equivalent of ipv4 struct ip | ||
434 | */ | ||
435 | struct frag_queue { | ||
436 | struct inet_frag_queue q; | ||
437 | 388 | ||
438 | __be32 id; /* fragment id */ | 389 | static inline int ipv6_addr_any(const struct in6_addr *a) |
439 | u32 user; | ||
440 | struct in6_addr saddr; | ||
441 | struct in6_addr daddr; | ||
442 | |||
443 | int iif; | ||
444 | unsigned int csum; | ||
445 | __u16 nhoffset; | ||
446 | }; | ||
447 | |||
448 | void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq, | ||
449 | struct inet_frags *frags); | ||
450 | |||
451 | static inline bool ipv6_addr_any(const struct in6_addr *a) | ||
452 | { | 390 | { |
453 | #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 | ||
454 | const unsigned long *ul = (const unsigned long *)a; | ||
455 | |||
456 | return (ul[0] | ul[1]) == 0UL; | ||
457 | #else | ||
458 | return (a->s6_addr32[0] | a->s6_addr32[1] | | 391 | return (a->s6_addr32[0] | a->s6_addr32[1] | |
459 | a->s6_addr32[2] | a->s6_addr32[3]) == 0; | 392 | a->s6_addr32[2] | a->s6_addr32[3]) == 0; |
460 | #endif | ||
461 | } | 393 | } |
462 | 394 | ||
463 | static inline u32 ipv6_addr_hash(const struct in6_addr *a) | 395 | static inline int ipv6_addr_loopback(const struct in6_addr *a) |
464 | { | ||
465 | #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) && BITS_PER_LONG == 64 | ||
466 | const unsigned long *ul = (const unsigned long *)a; | ||
467 | unsigned long x = ul[0] ^ ul[1]; | ||
468 | |||
469 | return (u32)(x ^ (x >> 32)); | ||
470 | #else | ||
471 | return (__force u32)(a->s6_addr32[0] ^ a->s6_addr32[1] ^ | ||
472 | a->s6_addr32[2] ^ a->s6_addr32[3]); | ||
473 | #endif | ||
474 | } | ||
475 | |||
476 | static inline bool ipv6_addr_loopback(const struct in6_addr *a) | ||
477 | { | 396 | { |
478 | return (a->s6_addr32[0] | a->s6_addr32[1] | | 397 | return (a->s6_addr32[0] | a->s6_addr32[1] | |
479 | a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0; | 398 | a->s6_addr32[2] | (a->s6_addr32[3] ^ htonl(1))) == 0; |
480 | } | 399 | } |
481 | 400 | ||
482 | static inline bool ipv6_addr_v4mapped(const struct in6_addr *a) | 401 | static inline int ipv6_addr_v4mapped(const struct in6_addr *a) |
483 | { | 402 | { |
484 | return (a->s6_addr32[0] | a->s6_addr32[1] | | 403 | return (a->s6_addr32[0] | a->s6_addr32[1] | |
485 | (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0; | 404 | (a->s6_addr32[2] ^ htonl(0x0000ffff))) == 0; |
@@ -489,7 +408,7 @@ static inline bool ipv6_addr_v4mapped(const struct in6_addr *a) | |||
489 | * Check for a RFC 4843 ORCHID address | 408 | * Check for a RFC 4843 ORCHID address |
490 | * (Overlay Routable Cryptographic Hash Identifiers) | 409 | * (Overlay Routable Cryptographic Hash Identifiers) |
491 | */ | 410 | */ |
492 | static inline bool ipv6_addr_orchid(const struct in6_addr *a) | 411 | static inline int ipv6_addr_orchid(const struct in6_addr *a) |
493 | { | 412 | { |
494 | return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010); | 413 | return (a->s6_addr32[0] & htonl(0xfffffff0)) == htonl(0x20010010); |
495 | } | 414 | } |
@@ -567,8 +486,7 @@ extern int ip6_rcv_finish(struct sk_buff *skb); | |||
567 | extern int ip6_xmit(struct sock *sk, | 486 | extern int ip6_xmit(struct sock *sk, |
568 | struct sk_buff *skb, | 487 | struct sk_buff *skb, |
569 | struct flowi6 *fl6, | 488 | struct flowi6 *fl6, |
570 | struct ipv6_txoptions *opt, | 489 | struct ipv6_txoptions *opt); |
571 | int tclass); | ||
572 | 490 | ||
573 | extern int ip6_nd_hdr(struct sock *sk, | 491 | extern int ip6_nd_hdr(struct sock *sk, |
574 | struct sk_buff *skb, | 492 | struct sk_buff *skb, |
@@ -635,19 +553,9 @@ extern void ipv6_push_frag_opts(struct sk_buff *skb, | |||
635 | u8 *proto); | 553 | u8 *proto); |
636 | 554 | ||
637 | extern int ipv6_skip_exthdr(const struct sk_buff *, int start, | 555 | extern int ipv6_skip_exthdr(const struct sk_buff *, int start, |
638 | u8 *nexthdrp, __be16 *frag_offp); | 556 | u8 *nexthdrp); |
639 | |||
640 | extern bool ipv6_ext_hdr(u8 nexthdr); | ||
641 | |||
642 | enum { | ||
643 | IP6_FH_F_FRAG = (1 << 0), | ||
644 | IP6_FH_F_AUTH = (1 << 1), | ||
645 | IP6_FH_F_SKIP_RH = (1 << 2), | ||
646 | }; | ||
647 | 557 | ||
648 | /* find specified header and get offset to it */ | 558 | extern int ipv6_ext_hdr(u8 nexthdr); |
649 | extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, | ||
650 | int target, unsigned short *fragoff, int *fragflg); | ||
651 | 559 | ||
652 | extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type); | 560 | extern int ipv6_find_tlv(struct sk_buff *skb, int offset, int type); |
653 | 561 | ||
@@ -748,6 +656,8 @@ extern struct ctl_table *ipv6_icmp_sysctl_init(struct net *net); | |||
748 | extern struct ctl_table *ipv6_route_sysctl_init(struct net *net); | 656 | extern struct ctl_table *ipv6_route_sysctl_init(struct net *net); |
749 | extern int ipv6_sysctl_register(void); | 657 | extern int ipv6_sysctl_register(void); |
750 | extern void ipv6_sysctl_unregister(void); | 658 | extern void ipv6_sysctl_unregister(void); |
659 | extern int ipv6_static_sysctl_register(void); | ||
660 | extern void ipv6_static_sysctl_unregister(void); | ||
751 | #endif | 661 | #endif |
752 | 662 | ||
753 | #endif /* _NET_IPV6_H */ | 663 | #endif /* _NET_IPV6_H */ |
diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h index 80ffde3bb16..59ba38bc400 100644 --- a/include/net/irda/ircomm_tty.h +++ b/include/net/irda/ircomm_tty.h | |||
@@ -52,16 +52,21 @@ | |||
52 | /* Same for payload size. See qos.c for the smallest max data size */ | 52 | /* Same for payload size. See qos.c for the smallest max data size */ |
53 | #define IRCOMM_TTY_DATA_UNINITIALISED (64 - IRCOMM_TTY_HDR_UNINITIALISED) | 53 | #define IRCOMM_TTY_DATA_UNINITIALISED (64 - IRCOMM_TTY_HDR_UNINITIALISED) |
54 | 54 | ||
55 | /* Those are really defined in include/linux/serial.h - Jean II */ | ||
56 | #define ASYNC_B_INITIALIZED 31 /* Serial port was initialized */ | ||
57 | #define ASYNC_B_NORMAL_ACTIVE 29 /* Normal device is active */ | ||
58 | #define ASYNC_B_CLOSING 27 /* Serial port is closing */ | ||
59 | |||
55 | /* | 60 | /* |
56 | * IrCOMM TTY driver state | 61 | * IrCOMM TTY driver state |
57 | */ | 62 | */ |
58 | struct ircomm_tty_cb { | 63 | struct ircomm_tty_cb { |
59 | irda_queue_t queue; /* Must be first */ | 64 | irda_queue_t queue; /* Must be first */ |
60 | struct tty_port port; | ||
61 | magic_t magic; | 65 | magic_t magic; |
62 | 66 | ||
63 | int state; /* Connect state */ | 67 | int state; /* Connect state */ |
64 | 68 | ||
69 | struct tty_struct *tty; | ||
65 | struct ircomm_cb *ircomm; /* IrCOMM layer instance */ | 70 | struct ircomm_cb *ircomm; /* IrCOMM layer instance */ |
66 | 71 | ||
67 | struct sk_buff *tx_skb; /* Transmit buffer */ | 72 | struct sk_buff *tx_skb; /* Transmit buffer */ |
@@ -75,6 +80,7 @@ struct ircomm_tty_cb { | |||
75 | LOCAL_FLOW flow; /* IrTTP flow status */ | 80 | LOCAL_FLOW flow; /* IrTTP flow status */ |
76 | 81 | ||
77 | int line; | 82 | int line; |
83 | unsigned long flags; | ||
78 | 84 | ||
79 | __u8 dlsap_sel; | 85 | __u8 dlsap_sel; |
80 | __u8 slsap_sel; | 86 | __u8 slsap_sel; |
@@ -91,10 +97,19 @@ struct ircomm_tty_cb { | |||
91 | void *skey; | 97 | void *skey; |
92 | void *ckey; | 98 | void *ckey; |
93 | 99 | ||
100 | wait_queue_head_t open_wait; | ||
101 | wait_queue_head_t close_wait; | ||
94 | struct timer_list watchdog_timer; | 102 | struct timer_list watchdog_timer; |
95 | struct work_struct tqueue; | 103 | struct work_struct tqueue; |
96 | 104 | ||
105 | unsigned short close_delay; | ||
106 | unsigned short closing_wait; /* time to wait before closing */ | ||
107 | |||
108 | int open_count; | ||
109 | int blocked_open; /* # of blocked opens */ | ||
110 | |||
97 | /* Protect concurent access to : | 111 | /* Protect concurent access to : |
112 | * o self->open_count | ||
98 | * o self->ctrl_skb | 113 | * o self->ctrl_skb |
99 | * o self->tx_skb | 114 | * o self->tx_skb |
100 | * Maybe other things may gain to be protected as well... | 115 | * Maybe other things may gain to be protected as well... |
diff --git a/include/net/irda/irlmp.h b/include/net/irda/irlmp.h index 591f78631f1..fff11b7fe8a 100644 --- a/include/net/irda/irlmp.h +++ b/include/net/irda/irlmp.h | |||
@@ -134,7 +134,7 @@ typedef struct { | |||
134 | } CACHE_ENTRY; | 134 | } CACHE_ENTRY; |
135 | 135 | ||
136 | /* | 136 | /* |
137 | * Information about each registered IrLAP layer | 137 | * Information about each registred IrLAP layer |
138 | */ | 138 | */ |
139 | struct lap_cb { | 139 | struct lap_cb { |
140 | irda_queue_t queue; /* Must be first */ | 140 | irda_queue_t queue; /* Must be first */ |
diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h index cc7c1973238..f82a1e87737 100644 --- a/include/net/iucv/af_iucv.h +++ b/include/net/iucv/af_iucv.h | |||
@@ -14,7 +14,6 @@ | |||
14 | #include <linux/list.h> | 14 | #include <linux/list.h> |
15 | #include <linux/poll.h> | 15 | #include <linux/poll.h> |
16 | #include <linux/socket.h> | 16 | #include <linux/socket.h> |
17 | #include <net/iucv/iucv.h> | ||
18 | 17 | ||
19 | #ifndef AF_IUCV | 18 | #ifndef AF_IUCV |
20 | #define AF_IUCV 32 | 19 | #define AF_IUCV 32 |
@@ -27,13 +26,13 @@ enum { | |||
27 | IUCV_OPEN, | 26 | IUCV_OPEN, |
28 | IUCV_BOUND, | 27 | IUCV_BOUND, |
29 | IUCV_LISTEN, | 28 | IUCV_LISTEN, |
29 | IUCV_SEVERED, | ||
30 | IUCV_DISCONN, | 30 | IUCV_DISCONN, |
31 | IUCV_CLOSING, | 31 | IUCV_CLOSING, |
32 | IUCV_CLOSED | 32 | IUCV_CLOSED |
33 | }; | 33 | }; |
34 | 34 | ||
35 | #define IUCV_QUEUELEN_DEFAULT 65535 | 35 | #define IUCV_QUEUELEN_DEFAULT 65535 |
36 | #define IUCV_HIPER_MSGLIM_DEFAULT 128 | ||
37 | #define IUCV_CONN_TIMEOUT (HZ * 40) | 36 | #define IUCV_CONN_TIMEOUT (HZ * 40) |
38 | #define IUCV_DISCONN_TIMEOUT (HZ * 2) | 37 | #define IUCV_DISCONN_TIMEOUT (HZ * 2) |
39 | #define IUCV_CONN_IDLE_TIMEOUT (HZ * 60) | 38 | #define IUCV_CONN_IDLE_TIMEOUT (HZ * 60) |
@@ -58,52 +57,8 @@ struct sock_msg_q { | |||
58 | spinlock_t lock; | 57 | spinlock_t lock; |
59 | }; | 58 | }; |
60 | 59 | ||
61 | #define AF_IUCV_FLAG_ACK 0x1 | ||
62 | #define AF_IUCV_FLAG_SYN 0x2 | ||
63 | #define AF_IUCV_FLAG_FIN 0x4 | ||
64 | #define AF_IUCV_FLAG_WIN 0x8 | ||
65 | #define AF_IUCV_FLAG_SHT 0x10 | ||
66 | |||
67 | struct af_iucv_trans_hdr { | ||
68 | u16 magic; | ||
69 | u8 version; | ||
70 | u8 flags; | ||
71 | u16 window; | ||
72 | char destNodeID[8]; | ||
73 | char destUserID[8]; | ||
74 | char destAppName[16]; | ||
75 | char srcNodeID[8]; | ||
76 | char srcUserID[8]; | ||
77 | char srcAppName[16]; /* => 70 bytes */ | ||
78 | struct iucv_message iucv_hdr; /* => 33 bytes */ | ||
79 | u8 pad; /* total 104 bytes */ | ||
80 | } __packed; | ||
81 | |||
82 | enum iucv_tx_notify { | ||
83 | /* transmission of skb is completed and was successful */ | ||
84 | TX_NOTIFY_OK = 0, | ||
85 | /* target is unreachable */ | ||
86 | TX_NOTIFY_UNREACHABLE = 1, | ||
87 | /* transfer pending queue full */ | ||
88 | TX_NOTIFY_TPQFULL = 2, | ||
89 | /* general error */ | ||
90 | TX_NOTIFY_GENERALERROR = 3, | ||
91 | /* transmission of skb is pending - may interleave | ||
92 | * with TX_NOTIFY_DELAYED_* */ | ||
93 | TX_NOTIFY_PENDING = 4, | ||
94 | /* transmission of skb was done successfully (delayed) */ | ||
95 | TX_NOTIFY_DELAYED_OK = 5, | ||
96 | /* target unreachable (detected delayed) */ | ||
97 | TX_NOTIFY_DELAYED_UNREACHABLE = 6, | ||
98 | /* general error (detected delayed) */ | ||
99 | TX_NOTIFY_DELAYED_GENERALERROR = 7, | ||
100 | }; | ||
101 | |||
102 | #define iucv_sk(__sk) ((struct iucv_sock *) __sk) | 60 | #define iucv_sk(__sk) ((struct iucv_sock *) __sk) |
103 | 61 | ||
104 | #define AF_IUCV_TRANS_IUCV 0 | ||
105 | #define AF_IUCV_TRANS_HIPER 1 | ||
106 | |||
107 | struct iucv_sock { | 62 | struct iucv_sock { |
108 | struct sock sk; | 63 | struct sock sk; |
109 | char src_user_id[8]; | 64 | char src_user_id[8]; |
@@ -114,26 +69,17 @@ struct iucv_sock { | |||
114 | spinlock_t accept_q_lock; | 69 | spinlock_t accept_q_lock; |
115 | struct sock *parent; | 70 | struct sock *parent; |
116 | struct iucv_path *path; | 71 | struct iucv_path *path; |
117 | struct net_device *hs_dev; | ||
118 | struct sk_buff_head send_skb_q; | 72 | struct sk_buff_head send_skb_q; |
119 | struct sk_buff_head backlog_skb_q; | 73 | struct sk_buff_head backlog_skb_q; |
120 | struct sock_msg_q message_q; | 74 | struct sock_msg_q message_q; |
121 | unsigned int send_tag; | 75 | unsigned int send_tag; |
122 | u8 flags; | 76 | u8 flags; |
123 | u16 msglimit; | 77 | u16 msglimit; |
124 | u16 msglimit_peer; | ||
125 | atomic_t msg_sent; | ||
126 | atomic_t msg_recv; | ||
127 | atomic_t pendings; | ||
128 | int transport; | ||
129 | void (*sk_txnotify)(struct sk_buff *skb, | ||
130 | enum iucv_tx_notify n); | ||
131 | }; | 78 | }; |
132 | 79 | ||
133 | /* iucv socket options (SOL_IUCV) */ | 80 | /* iucv socket options (SOL_IUCV) */ |
134 | #define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */ | 81 | #define SO_IPRMDATA_MSG 0x0080 /* send/recv IPRM_DATA msgs */ |
135 | #define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */ | 82 | #define SO_MSGLIMIT 0x1000 /* get/set IUCV MSGLIMIT */ |
136 | #define SO_MSGSIZE 0x0800 /* get maximum msgsize */ | ||
137 | 83 | ||
138 | /* iucv related control messages (scm) */ | 84 | /* iucv related control messages (scm) */ |
139 | #define SCM_IUCV_TRGCLS 0x0001 /* target class control message */ | 85 | #define SCM_IUCV_TRGCLS 0x0001 /* target class control message */ |
@@ -148,6 +94,7 @@ unsigned int iucv_sock_poll(struct file *file, struct socket *sock, | |||
148 | poll_table *wait); | 94 | poll_table *wait); |
149 | void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); | 95 | void iucv_sock_link(struct iucv_sock_list *l, struct sock *s); |
150 | void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); | 96 | void iucv_sock_unlink(struct iucv_sock_list *l, struct sock *s); |
97 | int iucv_sock_wait_cnt(struct sock *sk, unsigned long timeo); | ||
151 | void iucv_accept_enqueue(struct sock *parent, struct sock *sk); | 98 | void iucv_accept_enqueue(struct sock *parent, struct sock *sk); |
152 | void iucv_accept_unlink(struct sock *sk); | 99 | void iucv_accept_unlink(struct sock *sk); |
153 | struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); | 100 | struct sock *iucv_accept_dequeue(struct sock *parent, struct socket *newsock); |
diff --git a/include/net/iucv/iucv.h b/include/net/iucv/iucv.h index 0894ced3195..1121baa9f69 100644 --- a/include/net/iucv/iucv.h +++ b/include/net/iucv/iucv.h | |||
@@ -120,7 +120,7 @@ struct iucv_message { | |||
120 | u32 reply_size; | 120 | u32 reply_size; |
121 | u8 rmmsg[8]; | 121 | u8 rmmsg[8]; |
122 | u8 flags; | 122 | u8 flags; |
123 | } __packed; | 123 | }; |
124 | 124 | ||
125 | /* | 125 | /* |
126 | * struct iucv_handler | 126 | * struct iucv_handler |
@@ -459,37 +459,3 @@ int __iucv_message_send(struct iucv_path *path, struct iucv_message *msg, | |||
459 | int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg, | 459 | int iucv_message_send2way(struct iucv_path *path, struct iucv_message *msg, |
460 | u8 flags, u32 srccls, void *buffer, size_t size, | 460 | u8 flags, u32 srccls, void *buffer, size_t size, |
461 | void *answer, size_t asize, size_t *residual); | 461 | void *answer, size_t asize, size_t *residual); |
462 | |||
463 | struct iucv_interface { | ||
464 | int (*message_receive)(struct iucv_path *path, struct iucv_message *msg, | ||
465 | u8 flags, void *buffer, size_t size, size_t *residual); | ||
466 | int (*__message_receive)(struct iucv_path *path, | ||
467 | struct iucv_message *msg, u8 flags, void *buffer, size_t size, | ||
468 | size_t *residual); | ||
469 | int (*message_reply)(struct iucv_path *path, struct iucv_message *msg, | ||
470 | u8 flags, void *reply, size_t size); | ||
471 | int (*message_reject)(struct iucv_path *path, struct iucv_message *msg); | ||
472 | int (*message_send)(struct iucv_path *path, struct iucv_message *msg, | ||
473 | u8 flags, u32 srccls, void *buffer, size_t size); | ||
474 | int (*__message_send)(struct iucv_path *path, struct iucv_message *msg, | ||
475 | u8 flags, u32 srccls, void *buffer, size_t size); | ||
476 | int (*message_send2way)(struct iucv_path *path, | ||
477 | struct iucv_message *msg, u8 flags, u32 srccls, void *buffer, | ||
478 | size_t size, void *answer, size_t asize, size_t *residual); | ||
479 | int (*message_purge)(struct iucv_path *path, struct iucv_message *msg, | ||
480 | u32 srccls); | ||
481 | int (*path_accept)(struct iucv_path *path, struct iucv_handler *handler, | ||
482 | u8 userdata[16], void *private); | ||
483 | int (*path_connect)(struct iucv_path *path, | ||
484 | struct iucv_handler *handler, | ||
485 | u8 userid[8], u8 system[8], u8 userdata[16], void *private); | ||
486 | int (*path_quiesce)(struct iucv_path *path, u8 userdata[16]); | ||
487 | int (*path_resume)(struct iucv_path *path, u8 userdata[16]); | ||
488 | int (*path_sever)(struct iucv_path *path, u8 userdata[16]); | ||
489 | int (*iucv_register)(struct iucv_handler *handler, int smp); | ||
490 | void (*iucv_unregister)(struct iucv_handler *handler, int smp); | ||
491 | struct bus_type *bus; | ||
492 | struct device *root; | ||
493 | }; | ||
494 | |||
495 | extern struct iucv_interface iucv_if; | ||
diff --git a/include/net/lapb.h b/include/net/lapb.h index df892a94f2c..96cb5ddaa9f 100644 --- a/include/net/lapb.h +++ b/include/net/lapb.h | |||
@@ -95,7 +95,7 @@ struct lapb_cb { | |||
95 | struct sk_buff_head write_queue; | 95 | struct sk_buff_head write_queue; |
96 | struct sk_buff_head ack_queue; | 96 | struct sk_buff_head ack_queue; |
97 | unsigned char window; | 97 | unsigned char window; |
98 | const struct lapb_register_struct *callbacks; | 98 | struct lapb_register_struct callbacks; |
99 | 99 | ||
100 | /* FRMR control information */ | 100 | /* FRMR control information */ |
101 | struct lapb_frame frmr_data; | 101 | struct lapb_frame frmr_data; |
@@ -149,10 +149,4 @@ extern int lapb_t1timer_running(struct lapb_cb *lapb); | |||
149 | */ | 149 | */ |
150 | #define LAPB_DEBUG 0 | 150 | #define LAPB_DEBUG 0 |
151 | 151 | ||
152 | #define lapb_dbg(level, fmt, ...) \ | ||
153 | do { \ | ||
154 | if (level < LAPB_DEBUG) \ | ||
155 | pr_debug(fmt, ##__VA_ARGS__); \ | ||
156 | } while (0) | ||
157 | |||
158 | #endif | 152 | #endif |
diff --git a/include/net/lib80211.h b/include/net/lib80211.h index d178c26a555..b95bbb083ee 100644 --- a/include/net/lib80211.h +++ b/include/net/lib80211.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/types.h> | 26 | #include <linux/types.h> |
27 | #include <linux/list.h> | 27 | #include <linux/list.h> |
28 | #include <linux/module.h> | ||
28 | #include <linux/atomic.h> | 29 | #include <linux/atomic.h> |
29 | #include <linux/if.h> | 30 | #include <linux/if.h> |
30 | #include <linux/skbuff.h> | 31 | #include <linux/skbuff.h> |
@@ -41,8 +42,6 @@ enum { | |||
41 | IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), | 42 | IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), |
42 | }; | 43 | }; |
43 | 44 | ||
44 | struct module; | ||
45 | |||
46 | struct lib80211_crypto_ops { | 45 | struct lib80211_crypto_ops { |
47 | const char *name; | 46 | const char *name; |
48 | struct list_head list; | 47 | struct list_head list; |
@@ -118,7 +117,10 @@ void lib80211_crypt_info_free(struct lib80211_crypt_info *info); | |||
118 | int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops); | 117 | int lib80211_register_crypto_ops(struct lib80211_crypto_ops *ops); |
119 | int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops); | 118 | int lib80211_unregister_crypto_ops(struct lib80211_crypto_ops *ops); |
120 | struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name); | 119 | struct lib80211_crypto_ops *lib80211_get_crypto_ops(const char *name); |
120 | void lib80211_crypt_deinit_entries(struct lib80211_crypt_info *, int); | ||
121 | void lib80211_crypt_deinit_handler(unsigned long); | ||
121 | void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info, | 122 | void lib80211_crypt_delayed_deinit(struct lib80211_crypt_info *info, |
122 | struct lib80211_crypt_data **crypt); | 123 | struct lib80211_crypt_data **crypt); |
124 | void lib80211_crypt_quiescing(struct lib80211_crypt_info *info); | ||
123 | 125 | ||
124 | #endif /* LIB80211_H */ | 126 | #endif /* LIB80211_H */ |
diff --git a/include/net/llc.h b/include/net/llc.h index 9e7d7f08ef7..226c846cab0 100644 --- a/include/net/llc.h +++ b/include/net/llc.h | |||
@@ -133,7 +133,7 @@ extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, | |||
133 | extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb); | 133 | extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb); |
134 | extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb); | 134 | extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb); |
135 | 135 | ||
136 | extern void llc_station_init(void); | 136 | extern int llc_station_init(void); |
137 | extern void llc_station_exit(void); | 137 | extern void llc_station_exit(void); |
138 | 138 | ||
139 | #ifdef CONFIG_PROC_FS | 139 | #ifdef CONFIG_PROC_FS |
@@ -151,6 +151,7 @@ extern int sysctl_llc2_ack_timeout; | |||
151 | extern int sysctl_llc2_busy_timeout; | 151 | extern int sysctl_llc2_busy_timeout; |
152 | extern int sysctl_llc2_p_timeout; | 152 | extern int sysctl_llc2_p_timeout; |
153 | extern int sysctl_llc2_rej_timeout; | 153 | extern int sysctl_llc2_rej_timeout; |
154 | extern int sysctl_llc_station_ack_timeout; | ||
154 | #else | 155 | #else |
155 | #define llc_sysctl_init() (0) | 156 | #define llc_sysctl_init() (0) |
156 | #define llc_sysctl_exit() do { } while(0) | 157 | #define llc_sysctl_exit() do { } while(0) |
diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h index 6ca3113df39..23a409381fa 100644 --- a/include/net/llc_c_ev.h +++ b/include/net/llc_c_ev.h | |||
@@ -264,6 +264,6 @@ extern int llc_conn_ev_qlfy_set_status_rst_done(struct sock *sk, | |||
264 | static __inline__ int llc_conn_space(struct sock *sk, struct sk_buff *skb) | 264 | static __inline__ int llc_conn_space(struct sock *sk, struct sk_buff *skb) |
265 | { | 265 | { |
266 | return atomic_read(&sk->sk_rmem_alloc) + skb->truesize < | 266 | return atomic_read(&sk->sk_rmem_alloc) + skb->truesize < |
267 | (unsigned int)sk->sk_rcvbuf; | 267 | (unsigned)sk->sk_rcvbuf; |
268 | } | 268 | } |
269 | #endif /* LLC_C_EV_H */ | 269 | #endif /* LLC_C_EV_H */ |
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h index 5a93d13ac95..f57e7d46a45 100644 --- a/include/net/llc_pdu.h +++ b/include/net/llc_pdu.h | |||
@@ -13,6 +13,7 @@ | |||
13 | */ | 13 | */ |
14 | 14 | ||
15 | #include <linux/if_ether.h> | 15 | #include <linux/if_ether.h> |
16 | #include <linux/if_tr.h> | ||
16 | 17 | ||
17 | /* Lengths of frame formats */ | 18 | /* Lengths of frame formats */ |
18 | #define LLC_PDU_LEN_I 4 /* header and 2 control bytes */ | 19 | #define LLC_PDU_LEN_I 4 /* header and 2 control bytes */ |
@@ -252,6 +253,10 @@ static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa) | |||
252 | { | 253 | { |
253 | if (skb->protocol == htons(ETH_P_802_2)) | 254 | if (skb->protocol == htons(ETH_P_802_2)) |
254 | memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN); | 255 | memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN); |
256 | else if (skb->protocol == htons(ETH_P_TR_802_2)) { | ||
257 | memcpy(sa, tr_hdr(skb)->saddr, ETH_ALEN); | ||
258 | *sa &= 0x7F; | ||
259 | } | ||
255 | } | 260 | } |
256 | 261 | ||
257 | /** | 262 | /** |
@@ -265,6 +270,8 @@ static inline void llc_pdu_decode_da(struct sk_buff *skb, u8 *da) | |||
265 | { | 270 | { |
266 | if (skb->protocol == htons(ETH_P_802_2)) | 271 | if (skb->protocol == htons(ETH_P_802_2)) |
267 | memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN); | 272 | memcpy(da, eth_hdr(skb)->h_dest, ETH_ALEN); |
273 | else if (skb->protocol == htons(ETH_P_TR_802_2)) | ||
274 | memcpy(da, tr_hdr(skb)->daddr, ETH_ALEN); | ||
268 | } | 275 | } |
269 | 276 | ||
270 | /** | 277 | /** |
diff --git a/include/net/mac80211.h b/include/net/mac80211.h index ee50c5eba50..9259e97864d 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h | |||
@@ -13,10 +13,11 @@ | |||
13 | #ifndef MAC80211_H | 13 | #ifndef MAC80211_H |
14 | #define MAC80211_H | 14 | #define MAC80211_H |
15 | 15 | ||
16 | #include <linux/bug.h> | ||
17 | #include <linux/kernel.h> | 16 | #include <linux/kernel.h> |
18 | #include <linux/if_ether.h> | 17 | #include <linux/if_ether.h> |
19 | #include <linux/skbuff.h> | 18 | #include <linux/skbuff.h> |
19 | #include <linux/wireless.h> | ||
20 | #include <linux/device.h> | ||
20 | #include <linux/ieee80211.h> | 21 | #include <linux/ieee80211.h> |
21 | #include <net/cfg80211.h> | 22 | #include <net/cfg80211.h> |
22 | #include <asm/unaligned.h> | 23 | #include <asm/unaligned.h> |
@@ -87,19 +88,15 @@ | |||
87 | * | 88 | * |
88 | */ | 89 | */ |
89 | 90 | ||
90 | struct device; | ||
91 | |||
92 | /** | 91 | /** |
93 | * enum ieee80211_max_queues - maximum number of queues | 92 | * enum ieee80211_max_queues - maximum number of queues |
94 | * | 93 | * |
95 | * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues. | 94 | * @IEEE80211_MAX_QUEUES: Maximum number of regular device queues. |
96 | */ | 95 | */ |
97 | enum ieee80211_max_queues { | 96 | enum ieee80211_max_queues { |
98 | IEEE80211_MAX_QUEUES = 16, | 97 | IEEE80211_MAX_QUEUES = 4, |
99 | }; | 98 | }; |
100 | 99 | ||
101 | #define IEEE80211_INVAL_HW_QUEUE 0xff | ||
102 | |||
103 | /** | 100 | /** |
104 | * enum ieee80211_ac_numbers - AC numbers as used in mac80211 | 101 | * enum ieee80211_ac_numbers - AC numbers as used in mac80211 |
105 | * @IEEE80211_AC_VO: voice | 102 | * @IEEE80211_AC_VO: voice |
@@ -113,7 +110,6 @@ enum ieee80211_ac_numbers { | |||
113 | IEEE80211_AC_BE = 2, | 110 | IEEE80211_AC_BE = 2, |
114 | IEEE80211_AC_BK = 3, | 111 | IEEE80211_AC_BK = 3, |
115 | }; | 112 | }; |
116 | #define IEEE80211_NUM_ACS 4 | ||
117 | 113 | ||
118 | /** | 114 | /** |
119 | * struct ieee80211_tx_queue_params - transmit queue configuration | 115 | * struct ieee80211_tx_queue_params - transmit queue configuration |
@@ -144,39 +140,6 @@ struct ieee80211_low_level_stats { | |||
144 | }; | 140 | }; |
145 | 141 | ||
146 | /** | 142 | /** |
147 | * enum ieee80211_chanctx_change - change flag for channel context | ||
148 | * @IEEE80211_CHANCTX_CHANGE_WIDTH: The channel width changed | ||
149 | * @IEEE80211_CHANCTX_CHANGE_RX_CHAINS: The number of RX chains changed | ||
150 | */ | ||
151 | enum ieee80211_chanctx_change { | ||
152 | IEEE80211_CHANCTX_CHANGE_WIDTH = BIT(0), | ||
153 | IEEE80211_CHANCTX_CHANGE_RX_CHAINS = BIT(1), | ||
154 | }; | ||
155 | |||
156 | /** | ||
157 | * struct ieee80211_chanctx_conf - channel context that vifs may be tuned to | ||
158 | * | ||
159 | * This is the driver-visible part. The ieee80211_chanctx | ||
160 | * that contains it is visible in mac80211 only. | ||
161 | * | ||
162 | * @def: the channel definition | ||
163 | * @rx_chains_static: The number of RX chains that must always be | ||
164 | * active on the channel to receive MIMO transmissions | ||
165 | * @rx_chains_dynamic: The number of RX chains that must be enabled | ||
166 | * after RTS/CTS handshake to receive SMPS MIMO transmissions; | ||
167 | * this will always be >= @rx_chains_static. | ||
168 | * @drv_priv: data area for driver use, will always be aligned to | ||
169 | * sizeof(void *), size is determined in hw information. | ||
170 | */ | ||
171 | struct ieee80211_chanctx_conf { | ||
172 | struct cfg80211_chan_def def; | ||
173 | |||
174 | u8 rx_chains_static, rx_chains_dynamic; | ||
175 | |||
176 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); | ||
177 | }; | ||
178 | |||
179 | /** | ||
180 | * enum ieee80211_bss_change - BSS change notification flags | 143 | * enum ieee80211_bss_change - BSS change notification flags |
181 | * | 144 | * |
182 | * These flags are used with the bss_info_changed() callback | 145 | * These flags are used with the bss_info_changed() callback |
@@ -202,19 +165,13 @@ struct ieee80211_chanctx_conf { | |||
202 | * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note | 165 | * @BSS_CHANGED_QOS: QoS for this association was enabled/disabled. Note |
203 | * that it is only ever disabled for station mode. | 166 | * that it is only ever disabled for station mode. |
204 | * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. | 167 | * @BSS_CHANGED_IDLE: Idle changed for this BSS/interface. |
205 | * @BSS_CHANGED_SSID: SSID changed for this BSS (AP mode) | ||
206 | * @BSS_CHANGED_AP_PROBE_RESP: Probe Response changed for this BSS (AP mode) | ||
207 | * @BSS_CHANGED_PS: PS changed for this BSS (STA mode) | ||
208 | * @BSS_CHANGED_TXPOWER: TX power setting changed for this interface | ||
209 | * @BSS_CHANGED_P2P_PS: P2P powersave settings (CTWindow, opportunistic PS) | ||
210 | * changed (currently only in P2P client mode, GO mode will be later) | ||
211 | */ | 168 | */ |
212 | enum ieee80211_bss_change { | 169 | enum ieee80211_bss_change { |
213 | BSS_CHANGED_ASSOC = 1<<0, | 170 | BSS_CHANGED_ASSOC = 1<<0, |
214 | BSS_CHANGED_ERP_CTS_PROT = 1<<1, | 171 | BSS_CHANGED_ERP_CTS_PROT = 1<<1, |
215 | BSS_CHANGED_ERP_PREAMBLE = 1<<2, | 172 | BSS_CHANGED_ERP_PREAMBLE = 1<<2, |
216 | BSS_CHANGED_ERP_SLOT = 1<<3, | 173 | BSS_CHANGED_ERP_SLOT = 1<<3, |
217 | BSS_CHANGED_HT = 1<<4, | 174 | BSS_CHANGED_HT = 1<<4, |
218 | BSS_CHANGED_BASIC_RATES = 1<<5, | 175 | BSS_CHANGED_BASIC_RATES = 1<<5, |
219 | BSS_CHANGED_BEACON_INT = 1<<6, | 176 | BSS_CHANGED_BEACON_INT = 1<<6, |
220 | BSS_CHANGED_BSSID = 1<<7, | 177 | BSS_CHANGED_BSSID = 1<<7, |
@@ -225,11 +182,6 @@ enum ieee80211_bss_change { | |||
225 | BSS_CHANGED_ARP_FILTER = 1<<12, | 182 | BSS_CHANGED_ARP_FILTER = 1<<12, |
226 | BSS_CHANGED_QOS = 1<<13, | 183 | BSS_CHANGED_QOS = 1<<13, |
227 | BSS_CHANGED_IDLE = 1<<14, | 184 | BSS_CHANGED_IDLE = 1<<14, |
228 | BSS_CHANGED_SSID = 1<<15, | ||
229 | BSS_CHANGED_AP_PROBE_RESP = 1<<16, | ||
230 | BSS_CHANGED_PS = 1<<17, | ||
231 | BSS_CHANGED_TXPOWER = 1<<18, | ||
232 | BSS_CHANGED_P2P_PS = 1<<19, | ||
233 | 185 | ||
234 | /* when adding here, make sure to change ieee80211_reconfig */ | 186 | /* when adding here, make sure to change ieee80211_reconfig */ |
235 | }; | 187 | }; |
@@ -261,7 +213,6 @@ enum ieee80211_rssi_event { | |||
261 | * @assoc: association status | 213 | * @assoc: association status |
262 | * @ibss_joined: indicates whether this station is part of an IBSS | 214 | * @ibss_joined: indicates whether this station is part of an IBSS |
263 | * or not | 215 | * or not |
264 | * @ibss_creator: indicates if a new IBSS network is being created | ||
265 | * @aid: association ID number, valid only when @assoc is true | 216 | * @aid: association ID number, valid only when @assoc is true |
266 | * @use_cts_prot: use CTS protection | 217 | * @use_cts_prot: use CTS protection |
267 | * @use_short_preamble: use 802.11b short preamble; | 218 | * @use_short_preamble: use 802.11b short preamble; |
@@ -274,10 +225,7 @@ enum ieee80211_rssi_event { | |||
274 | * valid in station mode only while @assoc is true and if also | 225 | * valid in station mode only while @assoc is true and if also |
275 | * requested by %IEEE80211_HW_NEED_DTIM_PERIOD (cf. also hw conf | 226 | * requested by %IEEE80211_HW_NEED_DTIM_PERIOD (cf. also hw conf |
276 | * @ps_dtim_period) | 227 | * @ps_dtim_period) |
277 | * @sync_tsf: last beacon's/probe response's TSF timestamp (could be old | 228 | * @timestamp: beacon timestamp |
278 | * as it may have been received during scanning long ago) | ||
279 | * @sync_device_ts: the device timestamp corresponding to the sync_tsf, | ||
280 | * the driver/device can use this to calculate synchronisation | ||
281 | * @beacon_int: beacon interval | 229 | * @beacon_int: beacon interval |
282 | * @assoc_capability: capabilities taken from assoc resp | 230 | * @assoc_capability: capabilities taken from assoc resp |
283 | * @basic_rates: bitmap of basic rates, each bit stands for an | 231 | * @basic_rates: bitmap of basic rates, each bit stands for an |
@@ -286,9 +234,10 @@ enum ieee80211_rssi_event { | |||
286 | * @mcast_rate: per-band multicast rate index + 1 (0: disabled) | 234 | * @mcast_rate: per-band multicast rate index + 1 (0: disabled) |
287 | * @bssid: The BSSID for this BSS | 235 | * @bssid: The BSSID for this BSS |
288 | * @enable_beacon: whether beaconing should be enabled or not | 236 | * @enable_beacon: whether beaconing should be enabled or not |
289 | * @chandef: Channel definition for this BSS -- the hardware might be | 237 | * @channel_type: Channel type for this BSS -- the hardware might be |
290 | * configured a higher bandwidth than this BSS uses, for example. | 238 | * configured for HT40+ while this BSS only uses no-HT, for |
291 | * @ht_operation_mode: HT operation mode like in &struct ieee80211_ht_operation. | 239 | * example. |
240 | * @ht_operation_mode: HT operation mode (like in &struct ieee80211_ht_info). | ||
292 | * This field is only valid when the channel type is one of the HT types. | 241 | * This field is only valid when the channel type is one of the HT types. |
293 | * @cqm_rssi_thold: Connection quality monitor RSSI threshold, a zero value | 242 | * @cqm_rssi_thold: Connection quality monitor RSSI threshold, a zero value |
294 | * implies disabled | 243 | * implies disabled |
@@ -306,20 +255,11 @@ enum ieee80211_rssi_event { | |||
306 | * @idle: This interface is idle. There's also a global idle flag in the | 255 | * @idle: This interface is idle. There's also a global idle flag in the |
307 | * hardware config which may be more appropriate depending on what | 256 | * hardware config which may be more appropriate depending on what |
308 | * your driver/device needs to do. | 257 | * your driver/device needs to do. |
309 | * @ps: power-save mode (STA only). This flag is NOT affected by | ||
310 | * offchannel/dynamic_ps operations. | ||
311 | * @ssid: The SSID of the current vif. Only valid in AP-mode. | ||
312 | * @ssid_len: Length of SSID given in @ssid. | ||
313 | * @hidden_ssid: The SSID of the current vif is hidden. Only valid in AP-mode. | ||
314 | * @txpower: TX power in dBm | ||
315 | * @p2p_ctwindow: P2P CTWindow, only for P2P client interfaces | ||
316 | * @p2p_oppps: P2P opportunistic PS is enabled | ||
317 | */ | 258 | */ |
318 | struct ieee80211_bss_conf { | 259 | struct ieee80211_bss_conf { |
319 | const u8 *bssid; | 260 | const u8 *bssid; |
320 | /* association related data */ | 261 | /* association related data */ |
321 | bool assoc, ibss_joined; | 262 | bool assoc, ibss_joined; |
322 | bool ibss_creator; | ||
323 | u16 aid; | 263 | u16 aid; |
324 | /* erp related data */ | 264 | /* erp related data */ |
325 | bool use_cts_prot; | 265 | bool use_cts_prot; |
@@ -329,26 +269,18 @@ struct ieee80211_bss_conf { | |||
329 | u8 dtim_period; | 269 | u8 dtim_period; |
330 | u16 beacon_int; | 270 | u16 beacon_int; |
331 | u16 assoc_capability; | 271 | u16 assoc_capability; |
332 | u64 sync_tsf; | 272 | u64 timestamp; |
333 | u32 sync_device_ts; | ||
334 | u32 basic_rates; | 273 | u32 basic_rates; |
335 | int mcast_rate[IEEE80211_NUM_BANDS]; | 274 | int mcast_rate[IEEE80211_NUM_BANDS]; |
336 | u16 ht_operation_mode; | 275 | u16 ht_operation_mode; |
337 | s32 cqm_rssi_thold; | 276 | s32 cqm_rssi_thold; |
338 | u32 cqm_rssi_hyst; | 277 | u32 cqm_rssi_hyst; |
339 | struct cfg80211_chan_def chandef; | 278 | enum nl80211_channel_type channel_type; |
340 | __be32 arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN]; | 279 | __be32 arp_addr_list[IEEE80211_BSS_ARP_ADDR_LIST_LEN]; |
341 | u8 arp_addr_cnt; | 280 | u8 arp_addr_cnt; |
342 | bool arp_filter_enabled; | 281 | bool arp_filter_enabled; |
343 | bool qos; | 282 | bool qos; |
344 | bool idle; | 283 | bool idle; |
345 | bool ps; | ||
346 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | ||
347 | size_t ssid_len; | ||
348 | bool hidden_ssid; | ||
349 | int txpower; | ||
350 | u8 p2p_ctwindow; | ||
351 | bool p2p_oppps; | ||
352 | }; | 284 | }; |
353 | 285 | ||
354 | /** | 286 | /** |
@@ -399,9 +331,9 @@ struct ieee80211_bss_conf { | |||
399 | * used to indicate that a frame was already retried due to PS | 331 | * used to indicate that a frame was already retried due to PS |
400 | * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211, | 332 | * @IEEE80211_TX_INTFL_DONT_ENCRYPT: completely internal to mac80211, |
401 | * used to indicate frame should not be encrypted | 333 | * used to indicate frame should not be encrypted |
402 | * @IEEE80211_TX_CTL_NO_PS_BUFFER: This frame is a response to a poll | 334 | * @IEEE80211_TX_CTL_PSPOLL_RESPONSE: (internal?) |
403 | * frame (PS-Poll or uAPSD) or a non-bufferable MMPDU and must | 335 | * This frame is a response to a PS-poll frame and should be sent |
404 | * be sent although the station is in powersave mode. | 336 | * although the station is in powersave mode. |
405 | * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the | 337 | * @IEEE80211_TX_CTL_MORE_FRAMES: More frames will be passed to the |
406 | * transmit function after the current frame, this can be used | 338 | * transmit function after the current frame, this can be used |
407 | * by drivers to kick the DMA queue only if unset or when the | 339 | * by drivers to kick the DMA queue only if unset or when the |
@@ -409,6 +341,8 @@ struct ieee80211_bss_conf { | |||
409 | * @IEEE80211_TX_INTFL_RETRANSMISSION: This frame is being retransmitted | 341 | * @IEEE80211_TX_INTFL_RETRANSMISSION: This frame is being retransmitted |
410 | * after TX status because the destination was asleep, it must not | 342 | * after TX status because the destination was asleep, it must not |
411 | * be modified again (no seqno assignment, crypto, etc.) | 343 | * be modified again (no seqno assignment, crypto, etc.) |
344 | * @IEEE80211_TX_INTFL_HAS_RADIOTAP: This frame was injected and still | ||
345 | * has a radiotap header at skb->data. | ||
412 | * @IEEE80211_TX_INTFL_NL80211_FRAME_TX: Frame was requested through nl80211 | 346 | * @IEEE80211_TX_INTFL_NL80211_FRAME_TX: Frame was requested through nl80211 |
413 | * MLME command (internal to mac80211 to figure out whether to send TX | 347 | * MLME command (internal to mac80211 to figure out whether to send TX |
414 | * status to user space) | 348 | * status to user space) |
@@ -422,20 +356,6 @@ struct ieee80211_bss_conf { | |||
422 | * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP | 356 | * @IEEE80211_TX_INTFL_TKIP_MIC_FAILURE: Marks this packet to be used for TKIP |
423 | * testing. It will be sent out with incorrect Michael MIC key to allow | 357 | * testing. It will be sent out with incorrect Michael MIC key to allow |
424 | * TKIP countermeasures to be tested. | 358 | * TKIP countermeasures to be tested. |
425 | * @IEEE80211_TX_CTL_NO_CCK_RATE: This frame will be sent at non CCK rate. | ||
426 | * This flag is actually used for management frame especially for P2P | ||
427 | * frames not being sent at CCK rate in 2GHz band. | ||
428 | * @IEEE80211_TX_STATUS_EOSP: This packet marks the end of service period, | ||
429 | * when its status is reported the service period ends. For frames in | ||
430 | * an SP that mac80211 transmits, it is already set; for driver frames | ||
431 | * the driver may set this flag. It is also used to do the same for | ||
432 | * PS-Poll responses. | ||
433 | * @IEEE80211_TX_CTL_USE_MINRATE: This frame will be sent at lowest rate. | ||
434 | * This flag is used to send nullfunc frame at minimum rate when | ||
435 | * the nullfunc is used for connection monitoring purpose. | ||
436 | * @IEEE80211_TX_CTL_DONTFRAG: Don't fragment this packet even if it | ||
437 | * would be fragmented by size (this is optional, only used for | ||
438 | * monitor injection). | ||
439 | * | 359 | * |
440 | * Note: If you have to add new flags to the enumeration, then don't | 360 | * Note: If you have to add new flags to the enumeration, then don't |
441 | * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary. | 361 | * forget to update %IEEE80211_TX_TEMPORARY_FLAGS when necessary. |
@@ -457,19 +377,15 @@ enum mac80211_tx_control_flags { | |||
457 | IEEE80211_TX_INTFL_NEED_TXPROCESSING = BIT(14), | 377 | IEEE80211_TX_INTFL_NEED_TXPROCESSING = BIT(14), |
458 | IEEE80211_TX_INTFL_RETRIED = BIT(15), | 378 | IEEE80211_TX_INTFL_RETRIED = BIT(15), |
459 | IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16), | 379 | IEEE80211_TX_INTFL_DONT_ENCRYPT = BIT(16), |
460 | IEEE80211_TX_CTL_NO_PS_BUFFER = BIT(17), | 380 | IEEE80211_TX_CTL_PSPOLL_RESPONSE = BIT(17), |
461 | IEEE80211_TX_CTL_MORE_FRAMES = BIT(18), | 381 | IEEE80211_TX_CTL_MORE_FRAMES = BIT(18), |
462 | IEEE80211_TX_INTFL_RETRANSMISSION = BIT(19), | 382 | IEEE80211_TX_INTFL_RETRANSMISSION = BIT(19), |
463 | /* hole at 20, use later */ | 383 | IEEE80211_TX_INTFL_HAS_RADIOTAP = BIT(20), |
464 | IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21), | 384 | IEEE80211_TX_INTFL_NL80211_FRAME_TX = BIT(21), |
465 | IEEE80211_TX_CTL_LDPC = BIT(22), | 385 | IEEE80211_TX_CTL_LDPC = BIT(22), |
466 | IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24), | 386 | IEEE80211_TX_CTL_STBC = BIT(23) | BIT(24), |
467 | IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25), | 387 | IEEE80211_TX_CTL_TX_OFFCHAN = BIT(25), |
468 | IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26), | 388 | IEEE80211_TX_INTFL_TKIP_MIC_FAILURE = BIT(26), |
469 | IEEE80211_TX_CTL_NO_CCK_RATE = BIT(27), | ||
470 | IEEE80211_TX_STATUS_EOSP = BIT(28), | ||
471 | IEEE80211_TX_CTL_USE_MINRATE = BIT(29), | ||
472 | IEEE80211_TX_CTL_DONTFRAG = BIT(30), | ||
473 | }; | 389 | }; |
474 | 390 | ||
475 | #define IEEE80211_TX_CTL_STBC_SHIFT 23 | 391 | #define IEEE80211_TX_CTL_STBC_SHIFT 23 |
@@ -483,9 +399,9 @@ enum mac80211_tx_control_flags { | |||
483 | IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \ | 399 | IEEE80211_TX_CTL_SEND_AFTER_DTIM | IEEE80211_TX_CTL_AMPDU | \ |
484 | IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \ | 400 | IEEE80211_TX_STAT_TX_FILTERED | IEEE80211_TX_STAT_ACK | \ |
485 | IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \ | 401 | IEEE80211_TX_STAT_AMPDU | IEEE80211_TX_STAT_AMPDU_NO_BACK | \ |
486 | IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_NO_PS_BUFFER | \ | 402 | IEEE80211_TX_CTL_RATE_CTRL_PROBE | IEEE80211_TX_CTL_PSPOLL_RESPONSE | \ |
487 | IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \ | 403 | IEEE80211_TX_CTL_MORE_FRAMES | IEEE80211_TX_CTL_LDPC | \ |
488 | IEEE80211_TX_CTL_STBC | IEEE80211_TX_STATUS_EOSP) | 404 | IEEE80211_TX_CTL_STBC) |
489 | 405 | ||
490 | /** | 406 | /** |
491 | * enum mac80211_rate_control_flags - per-rate flags set by the | 407 | * enum mac80211_rate_control_flags - per-rate flags set by the |
@@ -499,14 +415,9 @@ enum mac80211_tx_control_flags { | |||
499 | * This is set if the current BSS requires ERP protection. | 415 | * This is set if the current BSS requires ERP protection. |
500 | * @IEEE80211_TX_RC_USE_SHORT_PREAMBLE: Use short preamble. | 416 | * @IEEE80211_TX_RC_USE_SHORT_PREAMBLE: Use short preamble. |
501 | * @IEEE80211_TX_RC_MCS: HT rate. | 417 | * @IEEE80211_TX_RC_MCS: HT rate. |
502 | * @IEEE80211_TX_RC_VHT_MCS: VHT MCS rate, in this case the idx field is split | ||
503 | * into a higher 4 bits (Nss) and lower 4 bits (MCS number) | ||
504 | * @IEEE80211_TX_RC_GREEN_FIELD: Indicates whether this rate should be used in | 418 | * @IEEE80211_TX_RC_GREEN_FIELD: Indicates whether this rate should be used in |
505 | * Greenfield mode. | 419 | * Greenfield mode. |
506 | * @IEEE80211_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be 40 MHz. | 420 | * @IEEE80211_TX_RC_40_MHZ_WIDTH: Indicates if the Channel Width should be 40 MHz. |
507 | * @IEEE80211_TX_RC_80_MHZ_WIDTH: Indicates 80 MHz transmission | ||
508 | * @IEEE80211_TX_RC_160_MHZ_WIDTH: Indicates 160 MHz transmission | ||
509 | * (80+80 isn't supported yet) | ||
510 | * @IEEE80211_TX_RC_DUP_DATA: The frame should be transmitted on both of the | 421 | * @IEEE80211_TX_RC_DUP_DATA: The frame should be transmitted on both of the |
511 | * adjacent 20 MHz channels, if the current channel type is | 422 | * adjacent 20 MHz channels, if the current channel type is |
512 | * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS. | 423 | * NL80211_CHAN_HT40MINUS or NL80211_CHAN_HT40PLUS. |
@@ -517,15 +428,12 @@ enum mac80211_rate_control_flags { | |||
517 | IEEE80211_TX_RC_USE_CTS_PROTECT = BIT(1), | 428 | IEEE80211_TX_RC_USE_CTS_PROTECT = BIT(1), |
518 | IEEE80211_TX_RC_USE_SHORT_PREAMBLE = BIT(2), | 429 | IEEE80211_TX_RC_USE_SHORT_PREAMBLE = BIT(2), |
519 | 430 | ||
520 | /* rate index is an HT/VHT MCS instead of an index */ | 431 | /* rate index is an MCS rate number instead of an index */ |
521 | IEEE80211_TX_RC_MCS = BIT(3), | 432 | IEEE80211_TX_RC_MCS = BIT(3), |
522 | IEEE80211_TX_RC_GREEN_FIELD = BIT(4), | 433 | IEEE80211_TX_RC_GREEN_FIELD = BIT(4), |
523 | IEEE80211_TX_RC_40_MHZ_WIDTH = BIT(5), | 434 | IEEE80211_TX_RC_40_MHZ_WIDTH = BIT(5), |
524 | IEEE80211_TX_RC_DUP_DATA = BIT(6), | 435 | IEEE80211_TX_RC_DUP_DATA = BIT(6), |
525 | IEEE80211_TX_RC_SHORT_GI = BIT(7), | 436 | IEEE80211_TX_RC_SHORT_GI = BIT(7), |
526 | IEEE80211_TX_RC_VHT_MCS = BIT(8), | ||
527 | IEEE80211_TX_RC_80_MHZ_WIDTH = BIT(9), | ||
528 | IEEE80211_TX_RC_160_MHZ_WIDTH = BIT(10), | ||
529 | }; | 437 | }; |
530 | 438 | ||
531 | 439 | ||
@@ -536,7 +444,7 @@ enum mac80211_rate_control_flags { | |||
536 | #define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24 | 444 | #define IEEE80211_TX_INFO_RATE_DRIVER_DATA_SIZE 24 |
537 | 445 | ||
538 | /* maximum number of rate stages */ | 446 | /* maximum number of rate stages */ |
539 | #define IEEE80211_TX_MAX_RATES 4 | 447 | #define IEEE80211_TX_MAX_RATES 5 |
540 | 448 | ||
541 | /** | 449 | /** |
542 | * struct ieee80211_tx_rate - rate selection/status | 450 | * struct ieee80211_tx_rate - rate selection/status |
@@ -568,32 +476,10 @@ enum mac80211_rate_control_flags { | |||
568 | */ | 476 | */ |
569 | struct ieee80211_tx_rate { | 477 | struct ieee80211_tx_rate { |
570 | s8 idx; | 478 | s8 idx; |
571 | u16 count:5, | 479 | u8 count; |
572 | flags:11; | 480 | u8 flags; |
573 | } __packed; | 481 | } __packed; |
574 | 482 | ||
575 | #define IEEE80211_MAX_TX_RETRY 31 | ||
576 | |||
577 | static inline void ieee80211_rate_set_vht(struct ieee80211_tx_rate *rate, | ||
578 | u8 mcs, u8 nss) | ||
579 | { | ||
580 | WARN_ON(mcs & ~0xF); | ||
581 | WARN_ON(nss & ~0x7); | ||
582 | rate->idx = (nss << 4) | mcs; | ||
583 | } | ||
584 | |||
585 | static inline u8 | ||
586 | ieee80211_rate_get_vht_mcs(const struct ieee80211_tx_rate *rate) | ||
587 | { | ||
588 | return rate->idx & 0xF; | ||
589 | } | ||
590 | |||
591 | static inline u8 | ||
592 | ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate) | ||
593 | { | ||
594 | return rate->idx >> 4; | ||
595 | } | ||
596 | |||
597 | /** | 483 | /** |
598 | * struct ieee80211_tx_info - skb transmit information | 484 | * struct ieee80211_tx_info - skb transmit information |
599 | * | 485 | * |
@@ -602,10 +488,13 @@ ieee80211_rate_get_vht_nss(const struct ieee80211_tx_rate *rate) | |||
602 | * (2) driver internal use (if applicable) | 488 | * (2) driver internal use (if applicable) |
603 | * (3) TX status information - driver tells mac80211 what happened | 489 | * (3) TX status information - driver tells mac80211 what happened |
604 | * | 490 | * |
491 | * The TX control's sta pointer is only valid during the ->tx call, | ||
492 | * it may be NULL. | ||
493 | * | ||
605 | * @flags: transmit info flags, defined above | 494 | * @flags: transmit info flags, defined above |
606 | * @band: the band to transmit on (use for checking for races) | 495 | * @band: the band to transmit on (use for checking for races) |
607 | * @hw_queue: HW queue to put the frame on, skb_get_queue_mapping() gives the AC | 496 | * @antenna_sel_tx: antenna to use, 0 for automatic diversity |
608 | * @ack_frame_id: internal frame ID for TX status, used internally | 497 | * @pad: padding, ignore |
609 | * @control: union for control data | 498 | * @control: union for control data |
610 | * @status: union for status data | 499 | * @status: union for status data |
611 | * @driver_data: array of driver_data pointers | 500 | * @driver_data: array of driver_data pointers |
@@ -620,9 +509,10 @@ struct ieee80211_tx_info { | |||
620 | u32 flags; | 509 | u32 flags; |
621 | u8 band; | 510 | u8 band; |
622 | 511 | ||
623 | u8 hw_queue; | 512 | u8 antenna_sel_tx; |
624 | 513 | ||
625 | u16 ack_frame_id; | 514 | /* 2 byte hole */ |
515 | u8 pad[2]; | ||
626 | 516 | ||
627 | union { | 517 | union { |
628 | struct { | 518 | struct { |
@@ -632,7 +522,6 @@ struct ieee80211_tx_info { | |||
632 | struct ieee80211_tx_rate rates[ | 522 | struct ieee80211_tx_rate rates[ |
633 | IEEE80211_TX_MAX_RATES]; | 523 | IEEE80211_TX_MAX_RATES]; |
634 | s8 rts_cts_rate_idx; | 524 | s8 rts_cts_rate_idx; |
635 | /* 3 bytes free */ | ||
636 | }; | 525 | }; |
637 | /* only needed before rate control */ | 526 | /* only needed before rate control */ |
638 | unsigned long jiffies; | 527 | unsigned long jiffies; |
@@ -640,15 +529,14 @@ struct ieee80211_tx_info { | |||
640 | /* NB: vif can be NULL for injected frames */ | 529 | /* NB: vif can be NULL for injected frames */ |
641 | struct ieee80211_vif *vif; | 530 | struct ieee80211_vif *vif; |
642 | struct ieee80211_key_conf *hw_key; | 531 | struct ieee80211_key_conf *hw_key; |
643 | /* 8 bytes free */ | 532 | struct ieee80211_sta *sta; |
644 | } control; | 533 | } control; |
645 | struct { | 534 | struct { |
646 | struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES]; | 535 | struct ieee80211_tx_rate rates[IEEE80211_TX_MAX_RATES]; |
647 | int ack_signal; | ||
648 | u8 ampdu_ack_len; | 536 | u8 ampdu_ack_len; |
537 | int ack_signal; | ||
649 | u8 ampdu_len; | 538 | u8 ampdu_len; |
650 | u8 antenna; | 539 | /* 15 bytes free */ |
651 | /* 21 bytes free */ | ||
652 | } status; | 540 | } status; |
653 | struct { | 541 | struct { |
654 | struct ieee80211_tx_rate driver_rates[ | 542 | struct ieee80211_tx_rate driver_rates[ |
@@ -715,7 +603,7 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) | |||
715 | info->status.rates[i].count = 0; | 603 | info->status.rates[i].count = 0; |
716 | 604 | ||
717 | BUILD_BUG_ON( | 605 | BUILD_BUG_ON( |
718 | offsetof(struct ieee80211_tx_info, status.ack_signal) != 20); | 606 | offsetof(struct ieee80211_tx_info, status.ampdu_ack_len) != 23); |
719 | memset(&info->status.ampdu_ack_len, 0, | 607 | memset(&info->status.ampdu_ack_len, 0, |
720 | sizeof(struct ieee80211_tx_info) - | 608 | sizeof(struct ieee80211_tx_info) - |
721 | offsetof(struct ieee80211_tx_info, status.ampdu_ack_len)); | 609 | offsetof(struct ieee80211_tx_info, status.ampdu_ack_len)); |
@@ -738,66 +626,27 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) | |||
738 | * the frame. | 626 | * the frame. |
739 | * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on | 627 | * @RX_FLAG_FAILED_PLCP_CRC: Set this flag if the PCLP check failed on |
740 | * the frame. | 628 | * the frame. |
741 | * @RX_FLAG_MACTIME_START: The timestamp passed in the RX status (@mactime | 629 | * @RX_FLAG_MACTIME_MPDU: The timestamp passed in the RX status (@mactime |
742 | * field) is valid and contains the time the first symbol of the MPDU | 630 | * field) is valid and contains the time the first symbol of the MPDU |
743 | * was received. This is useful in monitor mode and for proper IBSS | 631 | * was received. This is useful in monitor mode and for proper IBSS |
744 | * merging. | 632 | * merging. |
745 | * @RX_FLAG_MACTIME_END: The timestamp passed in the RX status (@mactime | ||
746 | * field) is valid and contains the time the last symbol of the MPDU | ||
747 | * (including FCS) was received. | ||
748 | * @RX_FLAG_SHORTPRE: Short preamble was used for this frame | 633 | * @RX_FLAG_SHORTPRE: Short preamble was used for this frame |
749 | * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index | 634 | * @RX_FLAG_HT: HT MCS was used and rate_idx is MCS index |
750 | * @RX_FLAG_VHT: VHT MCS was used and rate_index is MCS index | ||
751 | * @RX_FLAG_40MHZ: HT40 (40 MHz) was used | 635 | * @RX_FLAG_40MHZ: HT40 (40 MHz) was used |
752 | * @RX_FLAG_80MHZ: 80 MHz was used | ||
753 | * @RX_FLAG_80P80MHZ: 80+80 MHz was used | ||
754 | * @RX_FLAG_160MHZ: 160 MHz was used | ||
755 | * @RX_FLAG_SHORT_GI: Short guard interval was used | 636 | * @RX_FLAG_SHORT_GI: Short guard interval was used |
756 | * @RX_FLAG_NO_SIGNAL_VAL: The signal strength value is not present. | ||
757 | * Valid only for data frames (mainly A-MPDU) | ||
758 | * @RX_FLAG_HT_GF: This frame was received in a HT-greenfield transmission, if | ||
759 | * the driver fills this value it should add %IEEE80211_RADIOTAP_MCS_HAVE_FMT | ||
760 | * to hw.radiotap_mcs_details to advertise that fact | ||
761 | * @RX_FLAG_AMPDU_DETAILS: A-MPDU details are known, in particular the reference | ||
762 | * number (@ampdu_reference) must be populated and be a distinct number for | ||
763 | * each A-MPDU | ||
764 | * @RX_FLAG_AMPDU_REPORT_ZEROLEN: driver reports 0-length subframes | ||
765 | * @RX_FLAG_AMPDU_IS_ZEROLEN: This is a zero-length subframe, for | ||
766 | * monitoring purposes only | ||
767 | * @RX_FLAG_AMPDU_LAST_KNOWN: last subframe is known, should be set on all | ||
768 | * subframes of a single A-MPDU | ||
769 | * @RX_FLAG_AMPDU_IS_LAST: this subframe is the last subframe of the A-MPDU | ||
770 | * @RX_FLAG_AMPDU_DELIM_CRC_ERROR: A delimiter CRC error has been detected | ||
771 | * on this subframe | ||
772 | * @RX_FLAG_AMPDU_DELIM_CRC_KNOWN: The delimiter CRC field is known (the CRC | ||
773 | * is stored in the @ampdu_delimiter_crc field) | ||
774 | */ | 637 | */ |
775 | enum mac80211_rx_flags { | 638 | enum mac80211_rx_flags { |
776 | RX_FLAG_MMIC_ERROR = BIT(0), | 639 | RX_FLAG_MMIC_ERROR = 1<<0, |
777 | RX_FLAG_DECRYPTED = BIT(1), | 640 | RX_FLAG_DECRYPTED = 1<<1, |
778 | RX_FLAG_MMIC_STRIPPED = BIT(3), | 641 | RX_FLAG_MMIC_STRIPPED = 1<<3, |
779 | RX_FLAG_IV_STRIPPED = BIT(4), | 642 | RX_FLAG_IV_STRIPPED = 1<<4, |
780 | RX_FLAG_FAILED_FCS_CRC = BIT(5), | 643 | RX_FLAG_FAILED_FCS_CRC = 1<<5, |
781 | RX_FLAG_FAILED_PLCP_CRC = BIT(6), | 644 | RX_FLAG_FAILED_PLCP_CRC = 1<<6, |
782 | RX_FLAG_MACTIME_START = BIT(7), | 645 | RX_FLAG_MACTIME_MPDU = 1<<7, |
783 | RX_FLAG_SHORTPRE = BIT(8), | 646 | RX_FLAG_SHORTPRE = 1<<8, |
784 | RX_FLAG_HT = BIT(9), | 647 | RX_FLAG_HT = 1<<9, |
785 | RX_FLAG_40MHZ = BIT(10), | 648 | RX_FLAG_40MHZ = 1<<10, |
786 | RX_FLAG_SHORT_GI = BIT(11), | 649 | RX_FLAG_SHORT_GI = 1<<11, |
787 | RX_FLAG_NO_SIGNAL_VAL = BIT(12), | ||
788 | RX_FLAG_HT_GF = BIT(13), | ||
789 | RX_FLAG_AMPDU_DETAILS = BIT(14), | ||
790 | RX_FLAG_AMPDU_REPORT_ZEROLEN = BIT(15), | ||
791 | RX_FLAG_AMPDU_IS_ZEROLEN = BIT(16), | ||
792 | RX_FLAG_AMPDU_LAST_KNOWN = BIT(17), | ||
793 | RX_FLAG_AMPDU_IS_LAST = BIT(18), | ||
794 | RX_FLAG_AMPDU_DELIM_CRC_ERROR = BIT(19), | ||
795 | RX_FLAG_AMPDU_DELIM_CRC_KNOWN = BIT(20), | ||
796 | RX_FLAG_MACTIME_END = BIT(21), | ||
797 | RX_FLAG_VHT = BIT(22), | ||
798 | RX_FLAG_80MHZ = BIT(23), | ||
799 | RX_FLAG_80P80MHZ = BIT(24), | ||
800 | RX_FLAG_160MHZ = BIT(25), | ||
801 | }; | 650 | }; |
802 | 651 | ||
803 | /** | 652 | /** |
@@ -809,8 +658,6 @@ enum mac80211_rx_flags { | |||
809 | * | 658 | * |
810 | * @mactime: value in microseconds of the 64-bit Time Synchronization Function | 659 | * @mactime: value in microseconds of the 64-bit Time Synchronization Function |
811 | * (TSF) timer when the first data symbol (MPDU) arrived at the hardware. | 660 | * (TSF) timer when the first data symbol (MPDU) arrived at the hardware. |
812 | * @device_timestamp: arbitrary timestamp for the device, mac80211 doesn't use | ||
813 | * it but can store it and pass it back to the driver for synchronisation | ||
814 | * @band: the active band when this frame was received | 661 | * @band: the active band when this frame was received |
815 | * @freq: frequency the radio was tuned to when receiving this frame, in MHz | 662 | * @freq: frequency the radio was tuned to when receiving this frame, in MHz |
816 | * @signal: signal strength when receiving this frame, either in dBm, in dB or | 663 | * @signal: signal strength when receiving this frame, either in dBm, in dB or |
@@ -818,39 +665,19 @@ enum mac80211_rx_flags { | |||
818 | * @IEEE80211_HW_SIGNAL_* | 665 | * @IEEE80211_HW_SIGNAL_* |
819 | * @antenna: antenna used | 666 | * @antenna: antenna used |
820 | * @rate_idx: index of data rate into band's supported rates or MCS index if | 667 | * @rate_idx: index of data rate into band's supported rates or MCS index if |
821 | * HT or VHT is used (%RX_FLAG_HT/%RX_FLAG_VHT) | 668 | * HT rates are use (RX_FLAG_HT) |
822 | * @vht_nss: number of streams (VHT only) | ||
823 | * @flag: %RX_FLAG_* | 669 | * @flag: %RX_FLAG_* |
824 | * @rx_flags: internal RX flags for mac80211 | 670 | * @rx_flags: internal RX flags for mac80211 |
825 | * @ampdu_reference: A-MPDU reference number, must be a different value for | ||
826 | * each A-MPDU but the same for each subframe within one A-MPDU | ||
827 | * @ampdu_delimiter_crc: A-MPDU delimiter CRC | ||
828 | * @vendor_radiotap_bitmap: radiotap vendor namespace presence bitmap | ||
829 | * @vendor_radiotap_len: radiotap vendor namespace length | ||
830 | * @vendor_radiotap_align: radiotap vendor namespace alignment. Note | ||
831 | * that the actual data must be at the start of the SKB data | ||
832 | * already. | ||
833 | * @vendor_radiotap_oui: radiotap vendor namespace OUI | ||
834 | * @vendor_radiotap_subns: radiotap vendor sub namespace | ||
835 | */ | 671 | */ |
836 | struct ieee80211_rx_status { | 672 | struct ieee80211_rx_status { |
837 | u64 mactime; | 673 | u64 mactime; |
838 | u32 device_timestamp; | 674 | enum ieee80211_band band; |
839 | u32 ampdu_reference; | 675 | int freq; |
840 | u32 flag; | 676 | int signal; |
841 | u32 vendor_radiotap_bitmap; | 677 | int antenna; |
842 | u16 vendor_radiotap_len; | 678 | int rate_idx; |
843 | u16 freq; | 679 | int flag; |
844 | u8 rate_idx; | 680 | unsigned int rx_flags; |
845 | u8 vht_nss; | ||
846 | u8 rx_flags; | ||
847 | u8 band; | ||
848 | u8 antenna; | ||
849 | s8 signal; | ||
850 | u8 ampdu_delimiter_crc; | ||
851 | u8 vendor_radiotap_align; | ||
852 | u8 vendor_radiotap_oui[3]; | ||
853 | u8 vendor_radiotap_subns; | ||
854 | }; | 681 | }; |
855 | 682 | ||
856 | /** | 683 | /** |
@@ -895,8 +722,6 @@ enum ieee80211_conf_flags { | |||
895 | * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed | 722 | * @IEEE80211_CONF_CHANGE_RETRY_LIMITS: retry limits changed |
896 | * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed | 723 | * @IEEE80211_CONF_CHANGE_IDLE: Idle flag changed |
897 | * @IEEE80211_CONF_CHANGE_SMPS: Spatial multiplexing powersave mode changed | 724 | * @IEEE80211_CONF_CHANGE_SMPS: Spatial multiplexing powersave mode changed |
898 | * Note that this is only valid if channel contexts are not used, | ||
899 | * otherwise each channel context has the number of chains listed. | ||
900 | */ | 725 | */ |
901 | enum ieee80211_conf_changed { | 726 | enum ieee80211_conf_changed { |
902 | IEEE80211_CONF_CHANGE_SMPS = BIT(1), | 727 | IEEE80211_CONF_CHANGE_SMPS = BIT(1), |
@@ -948,8 +773,7 @@ enum ieee80211_smps_mode { | |||
948 | * powersave documentation below. This variable is valid only when | 773 | * powersave documentation below. This variable is valid only when |
949 | * the CONF_PS flag is set. | 774 | * the CONF_PS flag is set. |
950 | * | 775 | * |
951 | * @power_level: requested transmit power (in dBm), backward compatibility | 776 | * @power_level: requested transmit power (in dBm) |
952 | * value only that is set to the minimum of all interfaces | ||
953 | * | 777 | * |
954 | * @channel: the channel to tune to | 778 | * @channel: the channel to tune to |
955 | * @channel_type: the channel (HT) type | 779 | * @channel_type: the channel (HT) type |
@@ -963,9 +787,7 @@ enum ieee80211_smps_mode { | |||
963 | * | 787 | * |
964 | * @smps_mode: spatial multiplexing powersave mode; note that | 788 | * @smps_mode: spatial multiplexing powersave mode; note that |
965 | * %IEEE80211_SMPS_STATIC is used when the device is not | 789 | * %IEEE80211_SMPS_STATIC is used when the device is not |
966 | * configured for an HT channel. | 790 | * configured for an HT channel |
967 | * Note that this is only valid if channel contexts are not used, | ||
968 | * otherwise each channel context has the number of chains listed. | ||
969 | */ | 791 | */ |
970 | struct ieee80211_conf { | 792 | struct ieee80211_conf { |
971 | u32 flags; | 793 | u32 flags; |
@@ -1005,21 +827,6 @@ struct ieee80211_channel_switch { | |||
1005 | }; | 827 | }; |
1006 | 828 | ||
1007 | /** | 829 | /** |
1008 | * enum ieee80211_vif_flags - virtual interface flags | ||
1009 | * | ||
1010 | * @IEEE80211_VIF_BEACON_FILTER: the device performs beacon filtering | ||
1011 | * on this virtual interface to avoid unnecessary CPU wakeups | ||
1012 | * @IEEE80211_VIF_SUPPORTS_CQM_RSSI: the device can do connection quality | ||
1013 | * monitoring on this virtual interface -- i.e. it can monitor | ||
1014 | * connection quality related parameters, such as the RSSI level and | ||
1015 | * provide notifications if configured trigger levels are reached. | ||
1016 | */ | ||
1017 | enum ieee80211_vif_flags { | ||
1018 | IEEE80211_VIF_BEACON_FILTER = BIT(0), | ||
1019 | IEEE80211_VIF_SUPPORTS_CQM_RSSI = BIT(1), | ||
1020 | }; | ||
1021 | |||
1022 | /** | ||
1023 | * struct ieee80211_vif - per-interface data | 830 | * struct ieee80211_vif - per-interface data |
1024 | * | 831 | * |
1025 | * Data in this structure is continually present for driver | 832 | * Data in this structure is continually present for driver |
@@ -1031,17 +838,6 @@ enum ieee80211_vif_flags { | |||
1031 | * @addr: address of this interface | 838 | * @addr: address of this interface |
1032 | * @p2p: indicates whether this AP or STA interface is a p2p | 839 | * @p2p: indicates whether this AP or STA interface is a p2p |
1033 | * interface, i.e. a GO or p2p-sta respectively | 840 | * interface, i.e. a GO or p2p-sta respectively |
1034 | * @driver_flags: flags/capabilities the driver has for this interface, | ||
1035 | * these need to be set (or cleared) when the interface is added | ||
1036 | * or, if supported by the driver, the interface type is changed | ||
1037 | * at runtime, mac80211 will never touch this field | ||
1038 | * @hw_queue: hardware queue for each AC | ||
1039 | * @cab_queue: content-after-beacon (DTIM beacon really) queue, AP mode only | ||
1040 | * @chanctx_conf: The channel context this interface is assigned to, or %NULL | ||
1041 | * when it is not assigned. This pointer is RCU-protected due to the TX | ||
1042 | * path needing to access it; even though the netdev carrier will always | ||
1043 | * be off when it is %NULL there can still be races and packets could be | ||
1044 | * processed after it switches back to %NULL. | ||
1045 | * @drv_priv: data area for driver use, will always be aligned to | 841 | * @drv_priv: data area for driver use, will always be aligned to |
1046 | * sizeof(void *). | 842 | * sizeof(void *). |
1047 | */ | 843 | */ |
@@ -1050,14 +846,6 @@ struct ieee80211_vif { | |||
1050 | struct ieee80211_bss_conf bss_conf; | 846 | struct ieee80211_bss_conf bss_conf; |
1051 | u8 addr[ETH_ALEN]; | 847 | u8 addr[ETH_ALEN]; |
1052 | bool p2p; | 848 | bool p2p; |
1053 | |||
1054 | u8 cab_queue; | ||
1055 | u8 hw_queue[IEEE80211_NUM_ACS]; | ||
1056 | |||
1057 | struct ieee80211_chanctx_conf __rcu *chanctx_conf; | ||
1058 | |||
1059 | u32 driver_flags; | ||
1060 | |||
1061 | /* must be last */ | 849 | /* must be last */ |
1062 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); | 850 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); |
1063 | }; | 851 | }; |
@@ -1086,29 +874,16 @@ static inline bool ieee80211_vif_is_mesh(struct ieee80211_vif *vif) | |||
1086 | * generation in software. | 874 | * generation in software. |
1087 | * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates | 875 | * @IEEE80211_KEY_FLAG_PAIRWISE: Set by mac80211, this flag indicates |
1088 | * that the key is pairwise rather then a shared key. | 876 | * that the key is pairwise rather then a shared key. |
1089 | * @IEEE80211_KEY_FLAG_SW_MGMT_TX: This flag should be set by the driver for a | 877 | * @IEEE80211_KEY_FLAG_SW_MGMT: This flag should be set by the driver for a |
1090 | * CCMP key if it requires CCMP encryption of management frames (MFP) to | 878 | * CCMP key if it requires CCMP encryption of management frames (MFP) to |
1091 | * be done in software. | 879 | * be done in software. |
1092 | * @IEEE80211_KEY_FLAG_PUT_IV_SPACE: This flag should be set by the driver | ||
1093 | * if space should be prepared for the IV, but the IV | ||
1094 | * itself should not be generated. Do not set together with | ||
1095 | * @IEEE80211_KEY_FLAG_GENERATE_IV on the same key. | ||
1096 | * @IEEE80211_KEY_FLAG_RX_MGMT: This key will be used to decrypt received | ||
1097 | * management frames. The flag can help drivers that have a hardware | ||
1098 | * crypto implementation that doesn't deal with management frames | ||
1099 | * properly by allowing them to not upload the keys to hardware and | ||
1100 | * fall back to software crypto. Note that this flag deals only with | ||
1101 | * RX, if your crypto engine can't deal with TX you can also set the | ||
1102 | * %IEEE80211_KEY_FLAG_SW_MGMT_TX flag to encrypt such frames in SW. | ||
1103 | */ | 880 | */ |
1104 | enum ieee80211_key_flags { | 881 | enum ieee80211_key_flags { |
1105 | IEEE80211_KEY_FLAG_WMM_STA = 1<<0, | 882 | IEEE80211_KEY_FLAG_WMM_STA = 1<<0, |
1106 | IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1, | 883 | IEEE80211_KEY_FLAG_GENERATE_IV = 1<<1, |
1107 | IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, | 884 | IEEE80211_KEY_FLAG_GENERATE_MMIC= 1<<2, |
1108 | IEEE80211_KEY_FLAG_PAIRWISE = 1<<3, | 885 | IEEE80211_KEY_FLAG_PAIRWISE = 1<<3, |
1109 | IEEE80211_KEY_FLAG_SW_MGMT_TX = 1<<4, | 886 | IEEE80211_KEY_FLAG_SW_MGMT = 1<<4, |
1110 | IEEE80211_KEY_FLAG_PUT_IV_SPACE = 1<<5, | ||
1111 | IEEE80211_KEY_FLAG_RX_MGMT = 1<<6, | ||
1112 | }; | 887 | }; |
1113 | 888 | ||
1114 | /** | 889 | /** |
@@ -1157,25 +932,6 @@ enum set_key_cmd { | |||
1157 | }; | 932 | }; |
1158 | 933 | ||
1159 | /** | 934 | /** |
1160 | * enum ieee80211_sta_state - station state | ||
1161 | * | ||
1162 | * @IEEE80211_STA_NOTEXIST: station doesn't exist at all, | ||
1163 | * this is a special state for add/remove transitions | ||
1164 | * @IEEE80211_STA_NONE: station exists without special state | ||
1165 | * @IEEE80211_STA_AUTH: station is authenticated | ||
1166 | * @IEEE80211_STA_ASSOC: station is associated | ||
1167 | * @IEEE80211_STA_AUTHORIZED: station is authorized (802.1X) | ||
1168 | */ | ||
1169 | enum ieee80211_sta_state { | ||
1170 | /* NOTE: These need to be ordered correctly! */ | ||
1171 | IEEE80211_STA_NOTEXIST, | ||
1172 | IEEE80211_STA_NONE, | ||
1173 | IEEE80211_STA_AUTH, | ||
1174 | IEEE80211_STA_ASSOC, | ||
1175 | IEEE80211_STA_AUTHORIZED, | ||
1176 | }; | ||
1177 | |||
1178 | /** | ||
1179 | * struct ieee80211_sta - station table entry | 935 | * struct ieee80211_sta - station table entry |
1180 | * | 936 | * |
1181 | * A station table entry represents a station we are possibly | 937 | * A station table entry represents a station we are possibly |
@@ -1189,24 +945,16 @@ enum ieee80211_sta_state { | |||
1189 | * @aid: AID we assigned to the station if we're an AP | 945 | * @aid: AID we assigned to the station if we're an AP |
1190 | * @supp_rates: Bitmap of supported rates (per band) | 946 | * @supp_rates: Bitmap of supported rates (per band) |
1191 | * @ht_cap: HT capabilities of this STA; restricted to our own TX capabilities | 947 | * @ht_cap: HT capabilities of this STA; restricted to our own TX capabilities |
1192 | * @vht_cap: VHT capabilities of this STA; Not restricting any capabilities | ||
1193 | * of remote STA. Taking as is. | ||
1194 | * @wme: indicates whether the STA supports WME. Only valid during AP-mode. | 948 | * @wme: indicates whether the STA supports WME. Only valid during AP-mode. |
1195 | * @drv_priv: data area for driver use, will always be aligned to | 949 | * @drv_priv: data area for driver use, will always be aligned to |
1196 | * sizeof(void *), size is determined in hw information. | 950 | * sizeof(void *), size is determined in hw information. |
1197 | * @uapsd_queues: bitmap of queues configured for uapsd. Only valid | ||
1198 | * if wme is supported. | ||
1199 | * @max_sp: max Service Period. Only valid if wme is supported. | ||
1200 | */ | 951 | */ |
1201 | struct ieee80211_sta { | 952 | struct ieee80211_sta { |
1202 | u32 supp_rates[IEEE80211_NUM_BANDS]; | 953 | u32 supp_rates[IEEE80211_NUM_BANDS]; |
1203 | u8 addr[ETH_ALEN]; | 954 | u8 addr[ETH_ALEN]; |
1204 | u16 aid; | 955 | u16 aid; |
1205 | struct ieee80211_sta_ht_cap ht_cap; | 956 | struct ieee80211_sta_ht_cap ht_cap; |
1206 | struct ieee80211_sta_vht_cap vht_cap; | ||
1207 | bool wme; | 957 | bool wme; |
1208 | u8 uapsd_queues; | ||
1209 | u8 max_sp; | ||
1210 | 958 | ||
1211 | /* must be last */ | 959 | /* must be last */ |
1212 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); | 960 | u8 drv_priv[0] __attribute__((__aligned__(sizeof(void *)))); |
@@ -1226,16 +974,6 @@ enum sta_notify_cmd { | |||
1226 | }; | 974 | }; |
1227 | 975 | ||
1228 | /** | 976 | /** |
1229 | * struct ieee80211_tx_control - TX control data | ||
1230 | * | ||
1231 | * @sta: station table entry, this sta pointer may be NULL and | ||
1232 | * it is not allowed to copy the pointer, due to RCU. | ||
1233 | */ | ||
1234 | struct ieee80211_tx_control { | ||
1235 | struct ieee80211_sta *sta; | ||
1236 | }; | ||
1237 | |||
1238 | /** | ||
1239 | * enum ieee80211_hw_flags - hardware flags | 977 | * enum ieee80211_hw_flags - hardware flags |
1240 | * | 978 | * |
1241 | * These flags are used to indicate hardware capabilities to | 979 | * These flags are used to indicate hardware capabilities to |
@@ -1306,6 +1044,10 @@ struct ieee80211_tx_control { | |||
1306 | * @IEEE80211_HW_MFP_CAPABLE: | 1044 | * @IEEE80211_HW_MFP_CAPABLE: |
1307 | * Hardware supports management frame protection (MFP, IEEE 802.11w). | 1045 | * Hardware supports management frame protection (MFP, IEEE 802.11w). |
1308 | * | 1046 | * |
1047 | * @IEEE80211_HW_BEACON_FILTER: | ||
1048 | * Hardware supports dropping of irrelevant beacon frames to | ||
1049 | * avoid waking up cpu. | ||
1050 | * | ||
1309 | * @IEEE80211_HW_SUPPORTS_STATIC_SMPS: | 1051 | * @IEEE80211_HW_SUPPORTS_STATIC_SMPS: |
1310 | * Hardware supports static spatial multiplexing powersave, | 1052 | * Hardware supports static spatial multiplexing powersave, |
1311 | * ie. can turn off all but one chain even on HT connections | 1053 | * ie. can turn off all but one chain even on HT connections |
@@ -1331,6 +1073,11 @@ struct ieee80211_tx_control { | |||
1331 | * When this flag is set, signaling beacon-loss will cause an immediate | 1073 | * When this flag is set, signaling beacon-loss will cause an immediate |
1332 | * change to disassociated state. | 1074 | * change to disassociated state. |
1333 | * | 1075 | * |
1076 | * @IEEE80211_HW_SUPPORTS_CQM_RSSI: | ||
1077 | * Hardware can do connection quality monitoring - i.e. it can monitor | ||
1078 | * connection quality related parameters, such as the RSSI level and | ||
1079 | * provide notifications if configured trigger levels are reached. | ||
1080 | * | ||
1334 | * @IEEE80211_HW_NEED_DTIM_PERIOD: | 1081 | * @IEEE80211_HW_NEED_DTIM_PERIOD: |
1335 | * This device needs to know the DTIM period for the BSS before | 1082 | * This device needs to know the DTIM period for the BSS before |
1336 | * associating. | 1083 | * associating. |
@@ -1348,31 +1095,6 @@ struct ieee80211_tx_control { | |||
1348 | * stations based on the PM bit of incoming frames. | 1095 | * stations based on the PM bit of incoming frames. |
1349 | * Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure | 1096 | * Use ieee80211_start_ps()/ieee8021_end_ps() to manually configure |
1350 | * the PS mode of connected stations. | 1097 | * the PS mode of connected stations. |
1351 | * | ||
1352 | * @IEEE80211_HW_TX_AMPDU_SETUP_IN_HW: The device handles TX A-MPDU session | ||
1353 | * setup strictly in HW. mac80211 should not attempt to do this in | ||
1354 | * software. | ||
1355 | * | ||
1356 | * @IEEE80211_HW_SCAN_WHILE_IDLE: The device can do hw scan while | ||
1357 | * being idle (i.e. mac80211 doesn't have to go idle-off during the | ||
1358 | * the scan). | ||
1359 | * | ||
1360 | * @IEEE80211_HW_WANT_MONITOR_VIF: The driver would like to be informed of | ||
1361 | * a virtual monitor interface when monitor interfaces are the only | ||
1362 | * active interfaces. | ||
1363 | * | ||
1364 | * @IEEE80211_HW_QUEUE_CONTROL: The driver wants to control per-interface | ||
1365 | * queue mapping in order to use different queues (not just one per AC) | ||
1366 | * for different virtual interfaces. See the doc section on HW queue | ||
1367 | * control for more details. | ||
1368 | * | ||
1369 | * @IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF: Use the P2P Device address for any | ||
1370 | * P2P Interface. This will be honoured even if more than one interface | ||
1371 | * is supported. | ||
1372 | * | ||
1373 | * @IEEE80211_HW_TEARDOWN_AGGR_ON_BAR_FAIL: On this hardware TX BA session | ||
1374 | * should be tear down once BAR frame will not be acked. | ||
1375 | * | ||
1376 | */ | 1098 | */ |
1377 | enum ieee80211_hw_flags { | 1099 | enum ieee80211_hw_flags { |
1378 | IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, | 1100 | IEEE80211_HW_HAS_RATE_CONTROL = 1<<0, |
@@ -1389,19 +1111,15 @@ enum ieee80211_hw_flags { | |||
1389 | IEEE80211_HW_PS_NULLFUNC_STACK = 1<<11, | 1111 | IEEE80211_HW_PS_NULLFUNC_STACK = 1<<11, |
1390 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 1<<12, | 1112 | IEEE80211_HW_SUPPORTS_DYNAMIC_PS = 1<<12, |
1391 | IEEE80211_HW_MFP_CAPABLE = 1<<13, | 1113 | IEEE80211_HW_MFP_CAPABLE = 1<<13, |
1392 | IEEE80211_HW_WANT_MONITOR_VIF = 1<<14, | 1114 | IEEE80211_HW_BEACON_FILTER = 1<<14, |
1393 | IEEE80211_HW_SUPPORTS_STATIC_SMPS = 1<<15, | 1115 | IEEE80211_HW_SUPPORTS_STATIC_SMPS = 1<<15, |
1394 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS = 1<<16, | 1116 | IEEE80211_HW_SUPPORTS_DYNAMIC_SMPS = 1<<16, |
1395 | IEEE80211_HW_SUPPORTS_UAPSD = 1<<17, | 1117 | IEEE80211_HW_SUPPORTS_UAPSD = 1<<17, |
1396 | IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, | 1118 | IEEE80211_HW_REPORTS_TX_ACK_STATUS = 1<<18, |
1397 | IEEE80211_HW_CONNECTION_MONITOR = 1<<19, | 1119 | IEEE80211_HW_CONNECTION_MONITOR = 1<<19, |
1398 | IEEE80211_HW_QUEUE_CONTROL = 1<<20, | 1120 | IEEE80211_HW_SUPPORTS_CQM_RSSI = 1<<20, |
1399 | IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, | 1121 | IEEE80211_HW_SUPPORTS_PER_STA_GTK = 1<<21, |
1400 | IEEE80211_HW_AP_LINK_PS = 1<<22, | 1122 | IEEE80211_HW_AP_LINK_PS = 1<<22, |
1401 | IEEE80211_HW_TX_AMPDU_SETUP_IN_HW = 1<<23, | ||
1402 | IEEE80211_HW_SCAN_WHILE_IDLE = 1<<24, | ||
1403 | IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF = 1<<25, | ||
1404 | IEEE80211_HW_TEARDOWN_AGGR_ON_BAR_FAIL = 1<<26, | ||
1405 | }; | 1123 | }; |
1406 | 1124 | ||
1407 | /** | 1125 | /** |
@@ -1446,8 +1164,6 @@ enum ieee80211_hw_flags { | |||
1446 | * within &struct ieee80211_vif. | 1164 | * within &struct ieee80211_vif. |
1447 | * @sta_data_size: size (in bytes) of the drv_priv data area | 1165 | * @sta_data_size: size (in bytes) of the drv_priv data area |
1448 | * within &struct ieee80211_sta. | 1166 | * within &struct ieee80211_sta. |
1449 | * @chanctx_data_size: size (in bytes) of the drv_priv data area | ||
1450 | * within &struct ieee80211_chanctx_conf. | ||
1451 | * | 1167 | * |
1452 | * @max_rates: maximum number of alternate rate retry stages the hw | 1168 | * @max_rates: maximum number of alternate rate retry stages the hw |
1453 | * can handle. | 1169 | * can handle. |
@@ -1469,22 +1185,6 @@ enum ieee80211_hw_flags { | |||
1469 | * @max_tx_aggregation_subframes: maximum number of subframes in an | 1185 | * @max_tx_aggregation_subframes: maximum number of subframes in an |
1470 | * aggregate an HT driver will transmit, used by the peer as a | 1186 | * aggregate an HT driver will transmit, used by the peer as a |
1471 | * hint to size its reorder buffer. | 1187 | * hint to size its reorder buffer. |
1472 | * | ||
1473 | * @offchannel_tx_hw_queue: HW queue ID to use for offchannel TX | ||
1474 | * (if %IEEE80211_HW_QUEUE_CONTROL is set) | ||
1475 | * | ||
1476 | * @radiotap_mcs_details: lists which MCS information can the HW | ||
1477 | * reports, by default it is set to _MCS, _GI and _BW but doesn't | ||
1478 | * include _FMT. Use %IEEE80211_RADIOTAP_MCS_HAVE_* values, only | ||
1479 | * adding _BW is supported today. | ||
1480 | * | ||
1481 | * @radiotap_vht_details: lists which VHT MCS information the HW reports, | ||
1482 | * the default is _GI | _BANDWIDTH. | ||
1483 | * Use the %IEEE80211_RADIOTAP_VHT_KNOWN_* values. | ||
1484 | * | ||
1485 | * @netdev_features: netdev features to be set in each netdev created | ||
1486 | * from this HW. Note only HW checksum features are currently | ||
1487 | * compatible with mac80211. Other feature bits will be rejected. | ||
1488 | */ | 1188 | */ |
1489 | struct ieee80211_hw { | 1189 | struct ieee80211_hw { |
1490 | struct ieee80211_conf conf; | 1190 | struct ieee80211_conf conf; |
@@ -1496,7 +1196,6 @@ struct ieee80211_hw { | |||
1496 | int channel_change_time; | 1196 | int channel_change_time; |
1497 | int vif_data_size; | 1197 | int vif_data_size; |
1498 | int sta_data_size; | 1198 | int sta_data_size; |
1499 | int chanctx_data_size; | ||
1500 | int napi_weight; | 1199 | int napi_weight; |
1501 | u16 queues; | 1200 | u16 queues; |
1502 | u16 max_listen_interval; | 1201 | u16 max_listen_interval; |
@@ -1506,10 +1205,6 @@ struct ieee80211_hw { | |||
1506 | u8 max_rate_tries; | 1205 | u8 max_rate_tries; |
1507 | u8 max_rx_aggregation_subframes; | 1206 | u8 max_rx_aggregation_subframes; |
1508 | u8 max_tx_aggregation_subframes; | 1207 | u8 max_tx_aggregation_subframes; |
1509 | u8 offchannel_tx_hw_queue; | ||
1510 | u8 radiotap_mcs_details; | ||
1511 | u16 radiotap_vht_details; | ||
1512 | netdev_features_t netdev_features; | ||
1513 | }; | 1208 | }; |
1514 | 1209 | ||
1515 | /** | 1210 | /** |
@@ -1551,7 +1246,7 @@ static inline struct ieee80211_rate * | |||
1551 | ieee80211_get_tx_rate(const struct ieee80211_hw *hw, | 1246 | ieee80211_get_tx_rate(const struct ieee80211_hw *hw, |
1552 | const struct ieee80211_tx_info *c) | 1247 | const struct ieee80211_tx_info *c) |
1553 | { | 1248 | { |
1554 | if (WARN_ON_ONCE(c->control.rates[0].idx < 0)) | 1249 | if (WARN_ON(c->control.rates[0].idx < 0)) |
1555 | return NULL; | 1250 | return NULL; |
1556 | return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx]; | 1251 | return &hw->wiphy->bands[c->band]->bitrates[c->control.rates[0].idx]; |
1557 | } | 1252 | } |
@@ -1575,16 +1270,6 @@ ieee80211_get_alt_retry_rate(const struct ieee80211_hw *hw, | |||
1575 | } | 1270 | } |
1576 | 1271 | ||
1577 | /** | 1272 | /** |
1578 | * ieee80211_free_txskb - free TX skb | ||
1579 | * @hw: the hardware | ||
1580 | * @skb: the skb | ||
1581 | * | ||
1582 | * Free a transmit skb. Use this funtion when some failure | ||
1583 | * to transmit happened and thus status cannot be reported. | ||
1584 | */ | ||
1585 | void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); | ||
1586 | |||
1587 | /** | ||
1588 | * DOC: Hardware crypto acceleration | 1273 | * DOC: Hardware crypto acceleration |
1589 | * | 1274 | * |
1590 | * mac80211 is capable of taking advantage of many hardware | 1275 | * mac80211 is capable of taking advantage of many hardware |
@@ -1704,15 +1389,15 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); | |||
1704 | * DOC: Beacon filter support | 1389 | * DOC: Beacon filter support |
1705 | * | 1390 | * |
1706 | * Some hardware have beacon filter support to reduce host cpu wakeups | 1391 | * Some hardware have beacon filter support to reduce host cpu wakeups |
1707 | * which will reduce system power consumption. It usually works so that | 1392 | * which will reduce system power consumption. It usuallly works so that |
1708 | * the firmware creates a checksum of the beacon but omits all constantly | 1393 | * the firmware creates a checksum of the beacon but omits all constantly |
1709 | * changing elements (TSF, TIM etc). Whenever the checksum changes the | 1394 | * changing elements (TSF, TIM etc). Whenever the checksum changes the |
1710 | * beacon is forwarded to the host, otherwise it will be just dropped. That | 1395 | * beacon is forwarded to the host, otherwise it will be just dropped. That |
1711 | * way the host will only receive beacons where some relevant information | 1396 | * way the host will only receive beacons where some relevant information |
1712 | * (for example ERP protection or WMM settings) have changed. | 1397 | * (for example ERP protection or WMM settings) have changed. |
1713 | * | 1398 | * |
1714 | * Beacon filter support is advertised with the %IEEE80211_VIF_BEACON_FILTER | 1399 | * Beacon filter support is advertised with the %IEEE80211_HW_BEACON_FILTER |
1715 | * interface capability. The driver needs to enable beacon filter support | 1400 | * hardware capability. The driver needs to enable beacon filter support |
1716 | * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When | 1401 | * whenever power save is enabled, that is %IEEE80211_CONF_PS is set. When |
1717 | * power save is enabled, the stack will not check for beacon loss and the | 1402 | * power save is enabled, the stack will not check for beacon loss and the |
1718 | * driver needs to notify about loss of beacons with ieee80211_beacon_loss(). | 1403 | * driver needs to notify about loss of beacons with ieee80211_beacon_loss(). |
@@ -1826,153 +1511,6 @@ void ieee80211_free_txskb(struct ieee80211_hw *hw, struct sk_buff *skb); | |||
1826 | */ | 1511 | */ |
1827 | 1512 | ||
1828 | /** | 1513 | /** |
1829 | * DOC: AP support for powersaving clients | ||
1830 | * | ||
1831 | * In order to implement AP and P2P GO modes, mac80211 has support for | ||
1832 | * client powersaving, both "legacy" PS (PS-Poll/null data) and uAPSD. | ||
1833 | * There currently is no support for sAPSD. | ||
1834 | * | ||
1835 | * There is one assumption that mac80211 makes, namely that a client | ||
1836 | * will not poll with PS-Poll and trigger with uAPSD at the same time. | ||
1837 | * Both are supported, and both can be used by the same client, but | ||
1838 | * they can't be used concurrently by the same client. This simplifies | ||
1839 | * the driver code. | ||
1840 | * | ||
1841 | * The first thing to keep in mind is that there is a flag for complete | ||
1842 | * driver implementation: %IEEE80211_HW_AP_LINK_PS. If this flag is set, | ||
1843 | * mac80211 expects the driver to handle most of the state machine for | ||
1844 | * powersaving clients and will ignore the PM bit in incoming frames. | ||
1845 | * Drivers then use ieee80211_sta_ps_transition() to inform mac80211 of | ||
1846 | * stations' powersave transitions. In this mode, mac80211 also doesn't | ||
1847 | * handle PS-Poll/uAPSD. | ||
1848 | * | ||
1849 | * In the mode without %IEEE80211_HW_AP_LINK_PS, mac80211 will check the | ||
1850 | * PM bit in incoming frames for client powersave transitions. When a | ||
1851 | * station goes to sleep, we will stop transmitting to it. There is, | ||
1852 | * however, a race condition: a station might go to sleep while there is | ||
1853 | * data buffered on hardware queues. If the device has support for this | ||
1854 | * it will reject frames, and the driver should give the frames back to | ||
1855 | * mac80211 with the %IEEE80211_TX_STAT_TX_FILTERED flag set which will | ||
1856 | * cause mac80211 to retry the frame when the station wakes up. The | ||
1857 | * driver is also notified of powersave transitions by calling its | ||
1858 | * @sta_notify callback. | ||
1859 | * | ||
1860 | * When the station is asleep, it has three choices: it can wake up, | ||
1861 | * it can PS-Poll, or it can possibly start a uAPSD service period. | ||
1862 | * Waking up is implemented by simply transmitting all buffered (and | ||
1863 | * filtered) frames to the station. This is the easiest case. When | ||
1864 | * the station sends a PS-Poll or a uAPSD trigger frame, mac80211 | ||
1865 | * will inform the driver of this with the @allow_buffered_frames | ||
1866 | * callback; this callback is optional. mac80211 will then transmit | ||
1867 | * the frames as usual and set the %IEEE80211_TX_CTL_NO_PS_BUFFER | ||
1868 | * on each frame. The last frame in the service period (or the only | ||
1869 | * response to a PS-Poll) also has %IEEE80211_TX_STATUS_EOSP set to | ||
1870 | * indicate that it ends the service period; as this frame must have | ||
1871 | * TX status report it also sets %IEEE80211_TX_CTL_REQ_TX_STATUS. | ||
1872 | * When TX status is reported for this frame, the service period is | ||
1873 | * marked has having ended and a new one can be started by the peer. | ||
1874 | * | ||
1875 | * Additionally, non-bufferable MMPDUs can also be transmitted by | ||
1876 | * mac80211 with the %IEEE80211_TX_CTL_NO_PS_BUFFER set in them. | ||
1877 | * | ||
1878 | * Another race condition can happen on some devices like iwlwifi | ||
1879 | * when there are frames queued for the station and it wakes up | ||
1880 | * or polls; the frames that are already queued could end up being | ||
1881 | * transmitted first instead, causing reordering and/or wrong | ||
1882 | * processing of the EOSP. The cause is that allowing frames to be | ||
1883 | * transmitted to a certain station is out-of-band communication to | ||
1884 | * the device. To allow this problem to be solved, the driver can | ||
1885 | * call ieee80211_sta_block_awake() if frames are buffered when it | ||
1886 | * is notified that the station went to sleep. When all these frames | ||
1887 | * have been filtered (see above), it must call the function again | ||
1888 | * to indicate that the station is no longer blocked. | ||
1889 | * | ||
1890 | * If the driver buffers frames in the driver for aggregation in any | ||
1891 | * way, it must use the ieee80211_sta_set_buffered() call when it is | ||
1892 | * notified of the station going to sleep to inform mac80211 of any | ||
1893 | * TIDs that have frames buffered. Note that when a station wakes up | ||
1894 | * this information is reset (hence the requirement to call it when | ||
1895 | * informed of the station going to sleep). Then, when a service | ||
1896 | * period starts for any reason, @release_buffered_frames is called | ||
1897 | * with the number of frames to be released and which TIDs they are | ||
1898 | * to come from. In this case, the driver is responsible for setting | ||
1899 | * the EOSP (for uAPSD) and MORE_DATA bits in the released frames, | ||
1900 | * to help the @more_data paramter is passed to tell the driver if | ||
1901 | * there is more data on other TIDs -- the TIDs to release frames | ||
1902 | * from are ignored since mac80211 doesn't know how many frames the | ||
1903 | * buffers for those TIDs contain. | ||
1904 | * | ||
1905 | * If the driver also implement GO mode, where absence periods may | ||
1906 | * shorten service periods (or abort PS-Poll responses), it must | ||
1907 | * filter those response frames except in the case of frames that | ||
1908 | * are buffered in the driver -- those must remain buffered to avoid | ||
1909 | * reordering. Because it is possible that no frames are released | ||
1910 | * in this case, the driver must call ieee80211_sta_eosp_irqsafe() | ||
1911 | * to indicate to mac80211 that the service period ended anyway. | ||
1912 | * | ||
1913 | * Finally, if frames from multiple TIDs are released from mac80211 | ||
1914 | * but the driver might reorder them, it must clear & set the flags | ||
1915 | * appropriately (only the last frame may have %IEEE80211_TX_STATUS_EOSP) | ||
1916 | * and also take care of the EOSP and MORE_DATA bits in the frame. | ||
1917 | * The driver may also use ieee80211_sta_eosp_irqsafe() in this case. | ||
1918 | */ | ||
1919 | |||
1920 | /** | ||
1921 | * DOC: HW queue control | ||
1922 | * | ||
1923 | * Before HW queue control was introduced, mac80211 only had a single static | ||
1924 | * assignment of per-interface AC software queues to hardware queues. This | ||
1925 | * was problematic for a few reasons: | ||
1926 | * 1) off-channel transmissions might get stuck behind other frames | ||
1927 | * 2) multiple virtual interfaces couldn't be handled correctly | ||
1928 | * 3) after-DTIM frames could get stuck behind other frames | ||
1929 | * | ||
1930 | * To solve this, hardware typically uses multiple different queues for all | ||
1931 | * the different usages, and this needs to be propagated into mac80211 so it | ||
1932 | * won't have the same problem with the software queues. | ||
1933 | * | ||
1934 | * Therefore, mac80211 now offers the %IEEE80211_HW_QUEUE_CONTROL capability | ||
1935 | * flag that tells it that the driver implements its own queue control. To do | ||
1936 | * so, the driver will set up the various queues in each &struct ieee80211_vif | ||
1937 | * and the offchannel queue in &struct ieee80211_hw. In response, mac80211 will | ||
1938 | * use those queue IDs in the hw_queue field of &struct ieee80211_tx_info and | ||
1939 | * if necessary will queue the frame on the right software queue that mirrors | ||
1940 | * the hardware queue. | ||
1941 | * Additionally, the driver has to then use these HW queue IDs for the queue | ||
1942 | * management functions (ieee80211_stop_queue() et al.) | ||
1943 | * | ||
1944 | * The driver is free to set up the queue mappings as needed, multiple virtual | ||
1945 | * interfaces may map to the same hardware queues if needed. The setup has to | ||
1946 | * happen during add_interface or change_interface callbacks. For example, a | ||
1947 | * driver supporting station+station and station+AP modes might decide to have | ||
1948 | * 10 hardware queues to handle different scenarios: | ||
1949 | * | ||
1950 | * 4 AC HW queues for 1st vif: 0, 1, 2, 3 | ||
1951 | * 4 AC HW queues for 2nd vif: 4, 5, 6, 7 | ||
1952 | * after-DTIM queue for AP: 8 | ||
1953 | * off-channel queue: 9 | ||
1954 | * | ||
1955 | * It would then set up the hardware like this: | ||
1956 | * hw.offchannel_tx_hw_queue = 9 | ||
1957 | * | ||
1958 | * and the first virtual interface that is added as follows: | ||
1959 | * vif.hw_queue[IEEE80211_AC_VO] = 0 | ||
1960 | * vif.hw_queue[IEEE80211_AC_VI] = 1 | ||
1961 | * vif.hw_queue[IEEE80211_AC_BE] = 2 | ||
1962 | * vif.hw_queue[IEEE80211_AC_BK] = 3 | ||
1963 | * vif.cab_queue = 8 // if AP mode, otherwise %IEEE80211_INVAL_HW_QUEUE | ||
1964 | * and the second virtual interface with 4-7. | ||
1965 | * | ||
1966 | * If queue 6 gets full, for example, mac80211 would only stop the second | ||
1967 | * virtual interface's BE queue since virtual interface queues are per AC. | ||
1968 | * | ||
1969 | * Note that the vif.cab_queue value should be set to %IEEE80211_INVAL_HW_QUEUE | ||
1970 | * whenever the queue is not used (i.e. the interface is not in AP mode) if the | ||
1971 | * queue could potentially be shared since mac80211 will look at cab_queue when | ||
1972 | * a queue is stopped/woken even if the interface is not in AP mode. | ||
1973 | */ | ||
1974 | |||
1975 | /** | ||
1976 | * enum ieee80211_filter_flags - hardware filter flags | 1514 | * enum ieee80211_filter_flags - hardware filter flags |
1977 | * | 1515 | * |
1978 | * These flags determine what the filter in hardware should be | 1516 | * These flags determine what the filter in hardware should be |
@@ -2048,30 +1586,17 @@ enum ieee80211_ampdu_mlme_action { | |||
2048 | }; | 1586 | }; |
2049 | 1587 | ||
2050 | /** | 1588 | /** |
2051 | * enum ieee80211_frame_release_type - frame release reason | 1589 | * enum ieee80211_tx_sync_type - TX sync type |
2052 | * @IEEE80211_FRAME_RELEASE_PSPOLL: frame released for PS-Poll | 1590 | * @IEEE80211_TX_SYNC_AUTH: sync TX for authentication |
2053 | * @IEEE80211_FRAME_RELEASE_UAPSD: frame(s) released due to | 1591 | * (and possibly also before direct probe) |
2054 | * frame received on trigger-enabled AC | 1592 | * @IEEE80211_TX_SYNC_ASSOC: sync TX for association |
2055 | */ | 1593 | * @IEEE80211_TX_SYNC_ACTION: sync TX for action frame |
2056 | enum ieee80211_frame_release_type { | 1594 | * (not implemented yet) |
2057 | IEEE80211_FRAME_RELEASE_PSPOLL, | 1595 | */ |
2058 | IEEE80211_FRAME_RELEASE_UAPSD, | 1596 | enum ieee80211_tx_sync_type { |
2059 | }; | 1597 | IEEE80211_TX_SYNC_AUTH, |
2060 | 1598 | IEEE80211_TX_SYNC_ASSOC, | |
2061 | /** | 1599 | IEEE80211_TX_SYNC_ACTION, |
2062 | * enum ieee80211_rate_control_changed - flags to indicate what changed | ||
2063 | * | ||
2064 | * @IEEE80211_RC_BW_CHANGED: The bandwidth that can be used to transmit | ||
2065 | * to this station changed. | ||
2066 | * @IEEE80211_RC_SMPS_CHANGED: The SMPS state of the station changed. | ||
2067 | * @IEEE80211_RC_SUPP_RATES_CHANGED: The supported rate set of this peer | ||
2068 | * changed (in IBSS mode) due to discovering more information about | ||
2069 | * the peer. | ||
2070 | */ | ||
2071 | enum ieee80211_rate_control_changed { | ||
2072 | IEEE80211_RC_BW_CHANGED = BIT(0), | ||
2073 | IEEE80211_RC_SMPS_CHANGED = BIT(1), | ||
2074 | IEEE80211_RC_SUPP_RATES_CHANGED = BIT(2), | ||
2075 | }; | 1600 | }; |
2076 | 1601 | ||
2077 | /** | 1602 | /** |
@@ -2085,8 +1610,11 @@ enum ieee80211_rate_control_changed { | |||
2085 | * skb contains the buffer starting from the IEEE 802.11 header. | 1610 | * skb contains the buffer starting from the IEEE 802.11 header. |
2086 | * The low-level driver should send the frame out based on | 1611 | * The low-level driver should send the frame out based on |
2087 | * configuration in the TX control data. This handler should, | 1612 | * configuration in the TX control data. This handler should, |
2088 | * preferably, never fail and stop queues appropriately. | 1613 | * preferably, never fail and stop queues appropriately, more |
2089 | * Must be atomic. | 1614 | * importantly, however, it must never fail for A-MPDU-queues. |
1615 | * This function should return NETDEV_TX_OK except in very | ||
1616 | * limited cases. | ||
1617 | * Must be implemented and atomic. | ||
2090 | * | 1618 | * |
2091 | * @start: Called before the first netdevice attached to the hardware | 1619 | * @start: Called before the first netdevice attached to the hardware |
2092 | * is enabled. This should turn on the hardware and must turn on | 1620 | * is enabled. This should turn on the hardware and must turn on |
@@ -2122,11 +1650,6 @@ enum ieee80211_rate_control_changed { | |||
2122 | * to also unregister the device. If it returns 1, then mac80211 | 1650 | * to also unregister the device. If it returns 1, then mac80211 |
2123 | * will also go through the regular complete restart on resume. | 1651 | * will also go through the regular complete restart on resume. |
2124 | * | 1652 | * |
2125 | * @set_wakeup: Enable or disable wakeup when WoWLAN configuration is | ||
2126 | * modified. The reason is that device_set_wakeup_enable() is | ||
2127 | * supposed to be called when the configuration changes, not only | ||
2128 | * in suspend(). | ||
2129 | * | ||
2130 | * @add_interface: Called when a netdevice attached to the hardware is | 1653 | * @add_interface: Called when a netdevice attached to the hardware is |
2131 | * enabled. Because it is not called for monitor mode devices, @start | 1654 | * enabled. Because it is not called for monitor mode devices, @start |
2132 | * and @stop must be implemented. | 1655 | * and @stop must be implemented. |
@@ -2165,6 +1688,26 @@ enum ieee80211_rate_control_changed { | |||
2165 | * of the bss parameters has changed when a call is made. The callback | 1688 | * of the bss parameters has changed when a call is made. The callback |
2166 | * can sleep. | 1689 | * can sleep. |
2167 | * | 1690 | * |
1691 | * @tx_sync: Called before a frame is sent to an AP/GO. In the GO case, the | ||
1692 | * driver should sync with the GO's powersaving so the device doesn't | ||
1693 | * transmit the frame while the GO is asleep. In the regular AP case | ||
1694 | * it may be used by drivers for devices implementing other restrictions | ||
1695 | * on talking to APs, e.g. due to regulatory enforcement or just HW | ||
1696 | * restrictions. | ||
1697 | * This function is called for every authentication, association and | ||
1698 | * action frame separately since applications might attempt to auth | ||
1699 | * with multiple APs before chosing one to associate to. If it returns | ||
1700 | * an error, the corresponding authentication, association or frame | ||
1701 | * transmission is aborted and reported as having failed. It is always | ||
1702 | * called after tuning to the correct channel. | ||
1703 | * The callback might be called multiple times before @finish_tx_sync | ||
1704 | * (but @finish_tx_sync will be called once for each) but in practice | ||
1705 | * this is unlikely to happen. It can also refuse in that case if the | ||
1706 | * driver cannot handle that situation. | ||
1707 | * This callback can sleep. | ||
1708 | * @finish_tx_sync: Called as a counterpart to @tx_sync, unless that returned | ||
1709 | * an error. This callback can sleep. | ||
1710 | * | ||
2168 | * @prepare_multicast: Prepare for multicast filter configuration. | 1711 | * @prepare_multicast: Prepare for multicast filter configuration. |
2169 | * This callback is optional, and its return value is passed | 1712 | * This callback is optional, and its return value is passed |
2170 | * to configure_filter(). This callback must be atomic. | 1713 | * to configure_filter(). This callback must be atomic. |
@@ -2255,34 +1798,11 @@ enum ieee80211_rate_control_changed { | |||
2255 | * @sta_remove: Notifies low level driver about removal of an associated | 1798 | * @sta_remove: Notifies low level driver about removal of an associated |
2256 | * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep. | 1799 | * station, AP, IBSS/WDS/mesh peer etc. This callback can sleep. |
2257 | * | 1800 | * |
2258 | * @sta_add_debugfs: Drivers can use this callback to add debugfs files | ||
2259 | * when a station is added to mac80211's station list. This callback | ||
2260 | * and @sta_remove_debugfs should be within a CONFIG_MAC80211_DEBUGFS | ||
2261 | * conditional. This callback can sleep. | ||
2262 | * | ||
2263 | * @sta_remove_debugfs: Remove the debugfs files which were added using | ||
2264 | * @sta_add_debugfs. This callback can sleep. | ||
2265 | * | ||
2266 | * @sta_notify: Notifies low level driver about power state transition of an | 1801 | * @sta_notify: Notifies low level driver about power state transition of an |
2267 | * associated station, AP, IBSS/WDS/mesh peer etc. For a VIF operating | 1802 | * associated station, AP, IBSS/WDS/mesh peer etc. For a VIF operating |
2268 | * in AP mode, this callback will not be called when the flag | 1803 | * in AP mode, this callback will not be called when the flag |
2269 | * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic. | 1804 | * %IEEE80211_HW_AP_LINK_PS is set. Must be atomic. |
2270 | * | 1805 | * |
2271 | * @sta_state: Notifies low level driver about state transition of a | ||
2272 | * station (which can be the AP, a client, IBSS/WDS/mesh peer etc.) | ||
2273 | * This callback is mutually exclusive with @sta_add/@sta_remove. | ||
2274 | * It must not fail for down transitions but may fail for transitions | ||
2275 | * up the list of states. | ||
2276 | * The callback can sleep. | ||
2277 | * | ||
2278 | * @sta_rc_update: Notifies the driver of changes to the bitrates that can be | ||
2279 | * used to transmit to the station. The changes are advertised with bits | ||
2280 | * from &enum ieee80211_rate_control_changed and the values are reflected | ||
2281 | * in the station data. This callback should only be used when the driver | ||
2282 | * uses hardware rate control (%IEEE80211_HW_HAS_RATE_CONTROL) since | ||
2283 | * otherwise the rate control algorithm is notified directly. | ||
2284 | * Must be atomic. | ||
2285 | * | ||
2286 | * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), | 1806 | * @conf_tx: Configure TX queue parameters (EDCF (aifs, cw_min, cw_max), |
2287 | * bursting) for a hardware TX queue. | 1807 | * bursting) for a hardware TX queue. |
2288 | * Returns a negative error code on failure. | 1808 | * Returns a negative error code on failure. |
@@ -2373,12 +1893,14 @@ enum ieee80211_rate_control_changed { | |||
2373 | * offload. Frames to transmit on the off-channel channel are transmitted | 1893 | * offload. Frames to transmit on the off-channel channel are transmitted |
2374 | * normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the | 1894 | * normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the |
2375 | * duration (which will always be non-zero) expires, the driver must call | 1895 | * duration (which will always be non-zero) expires, the driver must call |
2376 | * ieee80211_remain_on_channel_expired(). | 1896 | * ieee80211_remain_on_channel_expired(). This callback may sleep. |
2377 | * Note that this callback may be called while the device is in IDLE and | ||
2378 | * must be accepted in this case. | ||
2379 | * This callback may sleep. | ||
2380 | * @cancel_remain_on_channel: Requests that an ongoing off-channel period is | 1897 | * @cancel_remain_on_channel: Requests that an ongoing off-channel period is |
2381 | * aborted before it expires. This callback may sleep. | 1898 | * aborted before it expires. This callback may sleep. |
1899 | * @offchannel_tx: Transmit frame on another channel, wait for a response | ||
1900 | * and return. Reliable TX status must be reported for the frame. If the | ||
1901 | * return value is 1, then the @remain_on_channel will be used with a | ||
1902 | * regular transmission (if supported.) | ||
1903 | * @offchannel_tx_cancel_wait: cancel wait associated with offchannel TX | ||
2382 | * | 1904 | * |
2383 | * @set_ringparam: Set tx and rx ring sizes. | 1905 | * @set_ringparam: Set tx and rx ring sizes. |
2384 | * | 1906 | * |
@@ -2392,100 +1914,14 @@ enum ieee80211_rate_control_changed { | |||
2392 | * The callback can sleep. | 1914 | * The callback can sleep. |
2393 | * @rssi_callback: Notify driver when the average RSSI goes above/below | 1915 | * @rssi_callback: Notify driver when the average RSSI goes above/below |
2394 | * thresholds that were registered previously. The callback can sleep. | 1916 | * thresholds that were registered previously. The callback can sleep. |
2395 | * | ||
2396 | * @release_buffered_frames: Release buffered frames according to the given | ||
2397 | * parameters. In the case where the driver buffers some frames for | ||
2398 | * sleeping stations mac80211 will use this callback to tell the driver | ||
2399 | * to release some frames, either for PS-poll or uAPSD. | ||
2400 | * Note that if the @more_data paramter is %false the driver must check | ||
2401 | * if there are more frames on the given TIDs, and if there are more than | ||
2402 | * the frames being released then it must still set the more-data bit in | ||
2403 | * the frame. If the @more_data parameter is %true, then of course the | ||
2404 | * more-data bit must always be set. | ||
2405 | * The @tids parameter tells the driver which TIDs to release frames | ||
2406 | * from, for PS-poll it will always have only a single bit set. | ||
2407 | * In the case this is used for a PS-poll initiated release, the | ||
2408 | * @num_frames parameter will always be 1 so code can be shared. In | ||
2409 | * this case the driver must also set %IEEE80211_TX_STATUS_EOSP flag | ||
2410 | * on the TX status (and must report TX status) so that the PS-poll | ||
2411 | * period is properly ended. This is used to avoid sending multiple | ||
2412 | * responses for a retried PS-poll frame. | ||
2413 | * In the case this is used for uAPSD, the @num_frames parameter may be | ||
2414 | * bigger than one, but the driver may send fewer frames (it must send | ||
2415 | * at least one, however). In this case it is also responsible for | ||
2416 | * setting the EOSP flag in the QoS header of the frames. Also, when the | ||
2417 | * service period ends, the driver must set %IEEE80211_TX_STATUS_EOSP | ||
2418 | * on the last frame in the SP. Alternatively, it may call the function | ||
2419 | * ieee80211_sta_eosp_irqsafe() to inform mac80211 of the end of the SP. | ||
2420 | * This callback must be atomic. | ||
2421 | * @allow_buffered_frames: Prepare device to allow the given number of frames | ||
2422 | * to go out to the given station. The frames will be sent by mac80211 | ||
2423 | * via the usual TX path after this call. The TX information for frames | ||
2424 | * released will also have the %IEEE80211_TX_CTL_NO_PS_BUFFER flag set | ||
2425 | * and the last one will also have %IEEE80211_TX_STATUS_EOSP set. In case | ||
2426 | * frames from multiple TIDs are released and the driver might reorder | ||
2427 | * them between the TIDs, it must set the %IEEE80211_TX_STATUS_EOSP flag | ||
2428 | * on the last frame and clear it on all others and also handle the EOSP | ||
2429 | * bit in the QoS header correctly. Alternatively, it can also call the | ||
2430 | * ieee80211_sta_eosp_irqsafe() function. | ||
2431 | * The @tids parameter is a bitmap and tells the driver which TIDs the | ||
2432 | * frames will be on; it will at most have two bits set. | ||
2433 | * This callback must be atomic. | ||
2434 | * | ||
2435 | * @get_et_sset_count: Ethtool API to get string-set count. | ||
2436 | * | ||
2437 | * @get_et_stats: Ethtool API to get a set of u64 stats. | ||
2438 | * | ||
2439 | * @get_et_strings: Ethtool API to get a set of strings to describe stats | ||
2440 | * and perhaps other supported types of ethtool data-sets. | ||
2441 | * | ||
2442 | * @get_rssi: Get current signal strength in dBm, the function is optional | ||
2443 | * and can sleep. | ||
2444 | * | ||
2445 | * @mgd_prepare_tx: Prepare for transmitting a management frame for association | ||
2446 | * before associated. In multi-channel scenarios, a virtual interface is | ||
2447 | * bound to a channel before it is associated, but as it isn't associated | ||
2448 | * yet it need not necessarily be given airtime, in particular since any | ||
2449 | * transmission to a P2P GO needs to be synchronized against the GO's | ||
2450 | * powersave state. mac80211 will call this function before transmitting a | ||
2451 | * management frame prior to having successfully associated to allow the | ||
2452 | * driver to give it channel time for the transmission, to get a response | ||
2453 | * and to be able to synchronize with the GO. | ||
2454 | * The callback will be called before each transmission and upon return | ||
2455 | * mac80211 will transmit the frame right away. | ||
2456 | * The callback is optional and can (should!) sleep. | ||
2457 | * | ||
2458 | * @add_chanctx: Notifies device driver about new channel context creation. | ||
2459 | * @remove_chanctx: Notifies device driver about channel context destruction. | ||
2460 | * @change_chanctx: Notifies device driver about channel context changes that | ||
2461 | * may happen when combining different virtual interfaces on the same | ||
2462 | * channel context with different settings | ||
2463 | * @assign_vif_chanctx: Notifies device driver about channel context being bound | ||
2464 | * to vif. Possible use is for hw queue remapping. | ||
2465 | * @unassign_vif_chanctx: Notifies device driver about channel context being | ||
2466 | * unbound from vif. | ||
2467 | * @start_ap: Start operation on the AP interface, this is called after all the | ||
2468 | * information in bss_conf is set and beacon can be retrieved. A channel | ||
2469 | * context is bound before this is called. Note that if the driver uses | ||
2470 | * software scan or ROC, this (and @stop_ap) isn't called when the AP is | ||
2471 | * just "paused" for scanning/ROC, which is indicated by the beacon being | ||
2472 | * disabled/enabled via @bss_info_changed. | ||
2473 | * @stop_ap: Stop operation on the AP interface. | ||
2474 | * | ||
2475 | * @restart_complete: Called after a call to ieee80211_restart_hw(), when the | ||
2476 | * reconfiguration has completed. This can help the driver implement the | ||
2477 | * reconfiguration step. This callback may sleep. | ||
2478 | */ | 1917 | */ |
2479 | struct ieee80211_ops { | 1918 | struct ieee80211_ops { |
2480 | void (*tx)(struct ieee80211_hw *hw, | 1919 | void (*tx)(struct ieee80211_hw *hw, struct sk_buff *skb); |
2481 | struct ieee80211_tx_control *control, | ||
2482 | struct sk_buff *skb); | ||
2483 | int (*start)(struct ieee80211_hw *hw); | 1920 | int (*start)(struct ieee80211_hw *hw); |
2484 | void (*stop)(struct ieee80211_hw *hw); | 1921 | void (*stop)(struct ieee80211_hw *hw); |
2485 | #ifdef CONFIG_PM | 1922 | #ifdef CONFIG_PM |
2486 | int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); | 1923 | int (*suspend)(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan); |
2487 | int (*resume)(struct ieee80211_hw *hw); | 1924 | int (*resume)(struct ieee80211_hw *hw); |
2488 | void (*set_wakeup)(struct ieee80211_hw *hw, bool enabled); | ||
2489 | #endif | 1925 | #endif |
2490 | int (*add_interface)(struct ieee80211_hw *hw, | 1926 | int (*add_interface)(struct ieee80211_hw *hw, |
2491 | struct ieee80211_vif *vif); | 1927 | struct ieee80211_vif *vif); |
@@ -2500,8 +1936,12 @@ struct ieee80211_ops { | |||
2500 | struct ieee80211_bss_conf *info, | 1936 | struct ieee80211_bss_conf *info, |
2501 | u32 changed); | 1937 | u32 changed); |
2502 | 1938 | ||
2503 | int (*start_ap)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); | 1939 | int (*tx_sync)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
2504 | void (*stop_ap)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); | 1940 | const u8 *bssid, enum ieee80211_tx_sync_type type); |
1941 | void (*finish_tx_sync)(struct ieee80211_hw *hw, | ||
1942 | struct ieee80211_vif *vif, | ||
1943 | const u8 *bssid, | ||
1944 | enum ieee80211_tx_sync_type type); | ||
2505 | 1945 | ||
2506 | u64 (*prepare_multicast)(struct ieee80211_hw *hw, | 1946 | u64 (*prepare_multicast)(struct ieee80211_hw *hw, |
2507 | struct netdev_hw_addr_list *mc_list); | 1947 | struct netdev_hw_addr_list *mc_list); |
@@ -2544,33 +1984,13 @@ struct ieee80211_ops { | |||
2544 | struct ieee80211_sta *sta); | 1984 | struct ieee80211_sta *sta); |
2545 | int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1985 | int (*sta_remove)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
2546 | struct ieee80211_sta *sta); | 1986 | struct ieee80211_sta *sta); |
2547 | #ifdef CONFIG_MAC80211_DEBUGFS | ||
2548 | void (*sta_add_debugfs)(struct ieee80211_hw *hw, | ||
2549 | struct ieee80211_vif *vif, | ||
2550 | struct ieee80211_sta *sta, | ||
2551 | struct dentry *dir); | ||
2552 | void (*sta_remove_debugfs)(struct ieee80211_hw *hw, | ||
2553 | struct ieee80211_vif *vif, | ||
2554 | struct ieee80211_sta *sta, | ||
2555 | struct dentry *dir); | ||
2556 | #endif | ||
2557 | void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1987 | void (*sta_notify)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, |
2558 | enum sta_notify_cmd, struct ieee80211_sta *sta); | 1988 | enum sta_notify_cmd, struct ieee80211_sta *sta); |
2559 | int (*sta_state)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1989 | int (*conf_tx)(struct ieee80211_hw *hw, u16 queue, |
2560 | struct ieee80211_sta *sta, | ||
2561 | enum ieee80211_sta_state old_state, | ||
2562 | enum ieee80211_sta_state new_state); | ||
2563 | void (*sta_rc_update)(struct ieee80211_hw *hw, | ||
2564 | struct ieee80211_vif *vif, | ||
2565 | struct ieee80211_sta *sta, | ||
2566 | u32 changed); | ||
2567 | int (*conf_tx)(struct ieee80211_hw *hw, | ||
2568 | struct ieee80211_vif *vif, u16 ac, | ||
2569 | const struct ieee80211_tx_queue_params *params); | 1990 | const struct ieee80211_tx_queue_params *params); |
2570 | u64 (*get_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); | 1991 | u64 (*get_tsf)(struct ieee80211_hw *hw); |
2571 | void (*set_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | 1992 | void (*set_tsf)(struct ieee80211_hw *hw, u64 tsf); |
2572 | u64 tsf); | 1993 | void (*reset_tsf)(struct ieee80211_hw *hw); |
2573 | void (*reset_tsf)(struct ieee80211_hw *hw, struct ieee80211_vif *vif); | ||
2574 | int (*tx_last_beacon)(struct ieee80211_hw *hw); | 1994 | int (*tx_last_beacon)(struct ieee80211_hw *hw); |
2575 | int (*ampdu_action)(struct ieee80211_hw *hw, | 1995 | int (*ampdu_action)(struct ieee80211_hw *hw, |
2576 | struct ieee80211_vif *vif, | 1996 | struct ieee80211_vif *vif, |
@@ -2595,10 +2015,15 @@ struct ieee80211_ops { | |||
2595 | int (*get_antenna)(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant); | 2015 | int (*get_antenna)(struct ieee80211_hw *hw, u32 *tx_ant, u32 *rx_ant); |
2596 | 2016 | ||
2597 | int (*remain_on_channel)(struct ieee80211_hw *hw, | 2017 | int (*remain_on_channel)(struct ieee80211_hw *hw, |
2598 | struct ieee80211_vif *vif, | ||
2599 | struct ieee80211_channel *chan, | 2018 | struct ieee80211_channel *chan, |
2019 | enum nl80211_channel_type channel_type, | ||
2600 | int duration); | 2020 | int duration); |
2601 | int (*cancel_remain_on_channel)(struct ieee80211_hw *hw); | 2021 | int (*cancel_remain_on_channel)(struct ieee80211_hw *hw); |
2022 | int (*offchannel_tx)(struct ieee80211_hw *hw, struct sk_buff *skb, | ||
2023 | struct ieee80211_channel *chan, | ||
2024 | enum nl80211_channel_type channel_type, | ||
2025 | unsigned int wait); | ||
2026 | int (*offchannel_tx_cancel_wait)(struct ieee80211_hw *hw); | ||
2602 | int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx); | 2027 | int (*set_ringparam)(struct ieee80211_hw *hw, u32 tx, u32 rx); |
2603 | void (*get_ringparam)(struct ieee80211_hw *hw, | 2028 | void (*get_ringparam)(struct ieee80211_hw *hw, |
2604 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max); | 2029 | u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max); |
@@ -2607,47 +2032,6 @@ struct ieee80211_ops { | |||
2607 | const struct cfg80211_bitrate_mask *mask); | 2032 | const struct cfg80211_bitrate_mask *mask); |
2608 | void (*rssi_callback)(struct ieee80211_hw *hw, | 2033 | void (*rssi_callback)(struct ieee80211_hw *hw, |
2609 | enum ieee80211_rssi_event rssi_event); | 2034 | enum ieee80211_rssi_event rssi_event); |
2610 | |||
2611 | void (*allow_buffered_frames)(struct ieee80211_hw *hw, | ||
2612 | struct ieee80211_sta *sta, | ||
2613 | u16 tids, int num_frames, | ||
2614 | enum ieee80211_frame_release_type reason, | ||
2615 | bool more_data); | ||
2616 | void (*release_buffered_frames)(struct ieee80211_hw *hw, | ||
2617 | struct ieee80211_sta *sta, | ||
2618 | u16 tids, int num_frames, | ||
2619 | enum ieee80211_frame_release_type reason, | ||
2620 | bool more_data); | ||
2621 | |||
2622 | int (*get_et_sset_count)(struct ieee80211_hw *hw, | ||
2623 | struct ieee80211_vif *vif, int sset); | ||
2624 | void (*get_et_stats)(struct ieee80211_hw *hw, | ||
2625 | struct ieee80211_vif *vif, | ||
2626 | struct ethtool_stats *stats, u64 *data); | ||
2627 | void (*get_et_strings)(struct ieee80211_hw *hw, | ||
2628 | struct ieee80211_vif *vif, | ||
2629 | u32 sset, u8 *data); | ||
2630 | int (*get_rssi)(struct ieee80211_hw *hw, struct ieee80211_vif *vif, | ||
2631 | struct ieee80211_sta *sta, s8 *rssi_dbm); | ||
2632 | |||
2633 | void (*mgd_prepare_tx)(struct ieee80211_hw *hw, | ||
2634 | struct ieee80211_vif *vif); | ||
2635 | |||
2636 | int (*add_chanctx)(struct ieee80211_hw *hw, | ||
2637 | struct ieee80211_chanctx_conf *ctx); | ||
2638 | void (*remove_chanctx)(struct ieee80211_hw *hw, | ||
2639 | struct ieee80211_chanctx_conf *ctx); | ||
2640 | void (*change_chanctx)(struct ieee80211_hw *hw, | ||
2641 | struct ieee80211_chanctx_conf *ctx, | ||
2642 | u32 changed); | ||
2643 | int (*assign_vif_chanctx)(struct ieee80211_hw *hw, | ||
2644 | struct ieee80211_vif *vif, | ||
2645 | struct ieee80211_chanctx_conf *ctx); | ||
2646 | void (*unassign_vif_chanctx)(struct ieee80211_hw *hw, | ||
2647 | struct ieee80211_vif *vif, | ||
2648 | struct ieee80211_chanctx_conf *ctx); | ||
2649 | |||
2650 | void (*restart_complete)(struct ieee80211_hw *hw); | ||
2651 | }; | 2035 | }; |
2652 | 2036 | ||
2653 | /** | 2037 | /** |
@@ -2962,38 +2346,20 @@ static inline int ieee80211_sta_ps_transition_ni(struct ieee80211_sta *sta, | |||
2962 | * The TX headroom reserved by mac80211 for its own tx_status functions. | 2346 | * The TX headroom reserved by mac80211 for its own tx_status functions. |
2963 | * This is enough for the radiotap header. | 2347 | * This is enough for the radiotap header. |
2964 | */ | 2348 | */ |
2965 | #define IEEE80211_TX_STATUS_HEADROOM 14 | 2349 | #define IEEE80211_TX_STATUS_HEADROOM 13 |
2966 | 2350 | ||
2967 | /** | 2351 | /** |
2968 | * ieee80211_sta_set_buffered - inform mac80211 about driver-buffered frames | 2352 | * ieee80211_sta_set_tim - set the TIM bit for a sleeping station |
2969 | * @sta: &struct ieee80211_sta pointer for the sleeping station | 2353 | * @sta: &struct ieee80211_sta pointer for the sleeping station |
2970 | * @tid: the TID that has buffered frames | ||
2971 | * @buffered: indicates whether or not frames are buffered for this TID | ||
2972 | * | 2354 | * |
2973 | * If a driver buffers frames for a powersave station instead of passing | 2355 | * If a driver buffers frames for a powersave station instead of passing |
2974 | * them back to mac80211 for retransmission, the station may still need | 2356 | * them back to mac80211 for retransmission, the station needs to be told |
2975 | * to be told that there are buffered frames via the TIM bit. | 2357 | * to wake up using the TIM bitmap in the beacon. |
2976 | * | 2358 | * |
2977 | * This function informs mac80211 whether or not there are frames that are | 2359 | * This function sets the station's TIM bit - it will be cleared when the |
2978 | * buffered in the driver for a given TID; mac80211 can then use this data | 2360 | * station wakes up. |
2979 | * to set the TIM bit (NOTE: This may call back into the driver's set_tim | 2361 | */ |
2980 | * call! Beware of the locking!) | 2362 | void ieee80211_sta_set_tim(struct ieee80211_sta *sta); |
2981 | * | ||
2982 | * If all frames are released to the station (due to PS-poll or uAPSD) | ||
2983 | * then the driver needs to inform mac80211 that there no longer are | ||
2984 | * frames buffered. However, when the station wakes up mac80211 assumes | ||
2985 | * that all buffered frames will be transmitted and clears this data, | ||
2986 | * drivers need to make sure they inform mac80211 about all buffered | ||
2987 | * frames on the sleep transition (sta_notify() with %STA_NOTIFY_SLEEP). | ||
2988 | * | ||
2989 | * Note that technically mac80211 only needs to know this per AC, not per | ||
2990 | * TID, but since driver buffering will inevitably happen per TID (since | ||
2991 | * it is related to aggregation) it is easier to make mac80211 map the | ||
2992 | * TID to the AC as required instead of keeping track in all drivers that | ||
2993 | * use this API. | ||
2994 | */ | ||
2995 | void ieee80211_sta_set_buffered(struct ieee80211_sta *sta, | ||
2996 | u8 tid, bool buffered); | ||
2997 | 2363 | ||
2998 | /** | 2364 | /** |
2999 | * ieee80211_tx_status - transmit status callback | 2365 | * ieee80211_tx_status - transmit status callback |
@@ -3101,19 +2467,6 @@ static inline struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
3101 | } | 2467 | } |
3102 | 2468 | ||
3103 | /** | 2469 | /** |
3104 | * ieee80211_proberesp_get - retrieve a Probe Response template | ||
3105 | * @hw: pointer obtained from ieee80211_alloc_hw(). | ||
3106 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | ||
3107 | * | ||
3108 | * Creates a Probe Response template which can, for example, be uploaded to | ||
3109 | * hardware. The destination address should be set by the caller. | ||
3110 | * | ||
3111 | * Can only be called in AP mode. | ||
3112 | */ | ||
3113 | struct sk_buff *ieee80211_proberesp_get(struct ieee80211_hw *hw, | ||
3114 | struct ieee80211_vif *vif); | ||
3115 | |||
3116 | /** | ||
3117 | * ieee80211_pspoll_get - retrieve a PS Poll template | 2470 | * ieee80211_pspoll_get - retrieve a PS Poll template |
3118 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 2471 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
3119 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 2472 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
@@ -3149,7 +2502,8 @@ struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw, | |||
3149 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 2502 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
3150 | * @ssid: SSID buffer | 2503 | * @ssid: SSID buffer |
3151 | * @ssid_len: length of SSID | 2504 | * @ssid_len: length of SSID |
3152 | * @tailroom: tailroom to reserve at end of SKB for IEs | 2505 | * @ie: buffer containing all IEs except SSID for the template |
2506 | * @ie_len: length of the IE buffer | ||
3153 | * | 2507 | * |
3154 | * Creates a Probe Request template which can, for example, be uploaded to | 2508 | * Creates a Probe Request template which can, for example, be uploaded to |
3155 | * hardware. | 2509 | * hardware. |
@@ -3157,7 +2511,7 @@ struct sk_buff *ieee80211_nullfunc_get(struct ieee80211_hw *hw, | |||
3157 | struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, | 2511 | struct sk_buff *ieee80211_probereq_get(struct ieee80211_hw *hw, |
3158 | struct ieee80211_vif *vif, | 2512 | struct ieee80211_vif *vif, |
3159 | const u8 *ssid, size_t ssid_len, | 2513 | const u8 *ssid, size_t ssid_len, |
3160 | size_t tailroom); | 2514 | const u8 *ie, size_t ie_len); |
3161 | 2515 | ||
3162 | /** | 2516 | /** |
3163 | * ieee80211_rts_get - RTS frame generation function | 2517 | * ieee80211_rts_get - RTS frame generation function |
@@ -3233,7 +2587,6 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, | |||
3233 | * ieee80211_generic_frame_duration - Calculate the duration field for a frame | 2587 | * ieee80211_generic_frame_duration - Calculate the duration field for a frame |
3234 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 2588 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
3235 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 2589 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
3236 | * @band: the band to calculate the frame duration on | ||
3237 | * @frame_len: the length of the frame. | 2590 | * @frame_len: the length of the frame. |
3238 | * @rate: the rate at which the frame is going to be transmitted. | 2591 | * @rate: the rate at which the frame is going to be transmitted. |
3239 | * | 2592 | * |
@@ -3242,7 +2595,6 @@ __le16 ieee80211_ctstoself_duration(struct ieee80211_hw *hw, | |||
3242 | */ | 2595 | */ |
3243 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, | 2596 | __le16 ieee80211_generic_frame_duration(struct ieee80211_hw *hw, |
3244 | struct ieee80211_vif *vif, | 2597 | struct ieee80211_vif *vif, |
3245 | enum ieee80211_band band, | ||
3246 | size_t frame_len, | 2598 | size_t frame_len, |
3247 | struct ieee80211_rate *rate); | 2599 | struct ieee80211_rate *rate); |
3248 | 2600 | ||
@@ -3331,19 +2683,6 @@ void ieee80211_get_tkip_p2k(struct ieee80211_key_conf *keyconf, | |||
3331 | struct sk_buff *skb, u8 *p2k); | 2683 | struct sk_buff *skb, u8 *p2k); |
3332 | 2684 | ||
3333 | /** | 2685 | /** |
3334 | * ieee80211_aes_cmac_calculate_k1_k2 - calculate the AES-CMAC sub keys | ||
3335 | * | ||
3336 | * This function computes the two AES-CMAC sub-keys, based on the | ||
3337 | * previously installed master key. | ||
3338 | * | ||
3339 | * @keyconf: the parameter passed with the set key | ||
3340 | * @k1: a buffer to be filled with the 1st sub-key | ||
3341 | * @k2: a buffer to be filled with the 2nd sub-key | ||
3342 | */ | ||
3343 | void ieee80211_aes_cmac_calculate_k1_k2(struct ieee80211_key_conf *keyconf, | ||
3344 | u8 *k1, u8 *k2); | ||
3345 | |||
3346 | /** | ||
3347 | * struct ieee80211_key_seq - key sequence counter | 2686 | * struct ieee80211_key_seq - key sequence counter |
3348 | * | 2687 | * |
3349 | * @tkip: TKIP data, containing IV32 and IV16 in host byte order | 2688 | * @tkip: TKIP data, containing IV32 and IV16 in host byte order |
@@ -3493,21 +2832,6 @@ void ieee80211_sched_scan_results(struct ieee80211_hw *hw); | |||
3493 | void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw); | 2832 | void ieee80211_sched_scan_stopped(struct ieee80211_hw *hw); |
3494 | 2833 | ||
3495 | /** | 2834 | /** |
3496 | * enum ieee80211_interface_iteration_flags - interface iteration flags | ||
3497 | * @IEEE80211_IFACE_ITER_NORMAL: Iterate over all interfaces that have | ||
3498 | * been added to the driver; However, note that during hardware | ||
3499 | * reconfiguration (after restart_hw) it will iterate over a new | ||
3500 | * interface and over all the existing interfaces even if they | ||
3501 | * haven't been re-added to the driver yet. | ||
3502 | * @IEEE80211_IFACE_ITER_RESUME_ALL: During resume, iterate over all | ||
3503 | * interfaces, even if they haven't been re-added to the driver yet. | ||
3504 | */ | ||
3505 | enum ieee80211_interface_iteration_flags { | ||
3506 | IEEE80211_IFACE_ITER_NORMAL = 0, | ||
3507 | IEEE80211_IFACE_ITER_RESUME_ALL = BIT(0), | ||
3508 | }; | ||
3509 | |||
3510 | /** | ||
3511 | * ieee80211_iterate_active_interfaces - iterate active interfaces | 2835 | * ieee80211_iterate_active_interfaces - iterate active interfaces |
3512 | * | 2836 | * |
3513 | * This function iterates over the interfaces associated with a given | 2837 | * This function iterates over the interfaces associated with a given |
@@ -3515,15 +2839,13 @@ enum ieee80211_interface_iteration_flags { | |||
3515 | * This function allows the iterator function to sleep, when the iterator | 2839 | * This function allows the iterator function to sleep, when the iterator |
3516 | * function is atomic @ieee80211_iterate_active_interfaces_atomic can | 2840 | * function is atomic @ieee80211_iterate_active_interfaces_atomic can |
3517 | * be used. | 2841 | * be used. |
3518 | * Does not iterate over a new interface during add_interface(). | 2842 | * Does not iterate over a new interface during add_interface() |
3519 | * | 2843 | * |
3520 | * @hw: the hardware struct of which the interfaces should be iterated over | 2844 | * @hw: the hardware struct of which the interfaces should be iterated over |
3521 | * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags | ||
3522 | * @iterator: the iterator function to call | 2845 | * @iterator: the iterator function to call |
3523 | * @data: first argument of the iterator function | 2846 | * @data: first argument of the iterator function |
3524 | */ | 2847 | */ |
3525 | void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, | 2848 | void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, |
3526 | u32 iter_flags, | ||
3527 | void (*iterator)(void *data, u8 *mac, | 2849 | void (*iterator)(void *data, u8 *mac, |
3528 | struct ieee80211_vif *vif), | 2850 | struct ieee80211_vif *vif), |
3529 | void *data); | 2851 | void *data); |
@@ -3535,15 +2857,13 @@ void ieee80211_iterate_active_interfaces(struct ieee80211_hw *hw, | |||
3535 | * hardware that are currently active and calls the callback for them. | 2857 | * hardware that are currently active and calls the callback for them. |
3536 | * This function requires the iterator callback function to be atomic, | 2858 | * This function requires the iterator callback function to be atomic, |
3537 | * if that is not desired, use @ieee80211_iterate_active_interfaces instead. | 2859 | * if that is not desired, use @ieee80211_iterate_active_interfaces instead. |
3538 | * Does not iterate over a new interface during add_interface(). | 2860 | * Does not iterate over a new interface during add_interface() |
3539 | * | 2861 | * |
3540 | * @hw: the hardware struct of which the interfaces should be iterated over | 2862 | * @hw: the hardware struct of which the interfaces should be iterated over |
3541 | * @iter_flags: iteration flags, see &enum ieee80211_interface_iteration_flags | ||
3542 | * @iterator: the iterator function to call, cannot sleep | 2863 | * @iterator: the iterator function to call, cannot sleep |
3543 | * @data: first argument of the iterator function | 2864 | * @data: first argument of the iterator function |
3544 | */ | 2865 | */ |
3545 | void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw, | 2866 | void ieee80211_iterate_active_interfaces_atomic(struct ieee80211_hw *hw, |
3546 | u32 iter_flags, | ||
3547 | void (*iterator)(void *data, | 2867 | void (*iterator)(void *data, |
3548 | u8 *mac, | 2868 | u8 *mac, |
3549 | struct ieee80211_vif *vif), | 2869 | struct ieee80211_vif *vif), |
@@ -3697,24 +3017,6 @@ void ieee80211_sta_block_awake(struct ieee80211_hw *hw, | |||
3697 | struct ieee80211_sta *pubsta, bool block); | 3017 | struct ieee80211_sta *pubsta, bool block); |
3698 | 3018 | ||
3699 | /** | 3019 | /** |
3700 | * ieee80211_sta_eosp - notify mac80211 about end of SP | ||
3701 | * @pubsta: the station | ||
3702 | * | ||
3703 | * When a device transmits frames in a way that it can't tell | ||
3704 | * mac80211 in the TX status about the EOSP, it must clear the | ||
3705 | * %IEEE80211_TX_STATUS_EOSP bit and call this function instead. | ||
3706 | * This applies for PS-Poll as well as uAPSD. | ||
3707 | * | ||
3708 | * Note that there is no non-_irqsafe version right now as | ||
3709 | * it wasn't needed, but just like _tx_status() and _rx() | ||
3710 | * must not be mixed in irqsafe/non-irqsafe versions, this | ||
3711 | * function must not be mixed with those either. Use the | ||
3712 | * all irqsafe, or all non-irqsafe, don't mix! If you need | ||
3713 | * the non-irqsafe version of this, you need to add it. | ||
3714 | */ | ||
3715 | void ieee80211_sta_eosp_irqsafe(struct ieee80211_sta *pubsta); | ||
3716 | |||
3717 | /** | ||
3718 | * ieee80211_iter_keys - iterate keys programmed into the device | 3020 | * ieee80211_iter_keys - iterate keys programmed into the device |
3719 | * @hw: pointer obtained from ieee80211_alloc_hw() | 3021 | * @hw: pointer obtained from ieee80211_alloc_hw() |
3720 | * @vif: virtual interface to iterate, may be %NULL for all | 3022 | * @vif: virtual interface to iterate, may be %NULL for all |
@@ -3742,27 +3044,6 @@ void ieee80211_iter_keys(struct ieee80211_hw *hw, | |||
3742 | void *iter_data); | 3044 | void *iter_data); |
3743 | 3045 | ||
3744 | /** | 3046 | /** |
3745 | * ieee80211_iter_chan_contexts_atomic - iterate channel contexts | ||
3746 | * @hw: pointre obtained from ieee80211_alloc_hw(). | ||
3747 | * @iter: iterator function | ||
3748 | * @iter_data: data passed to iterator function | ||
3749 | * | ||
3750 | * Iterate all active channel contexts. This function is atomic and | ||
3751 | * doesn't acquire any locks internally that might be held in other | ||
3752 | * places while calling into the driver. | ||
3753 | * | ||
3754 | * The iterator will not find a context that's being added (during | ||
3755 | * the driver callback to add it) but will find it while it's being | ||
3756 | * removed. | ||
3757 | */ | ||
3758 | void ieee80211_iter_chan_contexts_atomic( | ||
3759 | struct ieee80211_hw *hw, | ||
3760 | void (*iter)(struct ieee80211_hw *hw, | ||
3761 | struct ieee80211_chanctx_conf *chanctx_conf, | ||
3762 | void *data), | ||
3763 | void *iter_data); | ||
3764 | |||
3765 | /** | ||
3766 | * ieee80211_ap_probereq_get - retrieve a Probe Request template | 3047 | * ieee80211_ap_probereq_get - retrieve a Probe Request template |
3767 | * @hw: pointer obtained from ieee80211_alloc_hw(). | 3048 | * @hw: pointer obtained from ieee80211_alloc_hw(). |
3768 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 3049 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
@@ -3782,7 +3063,7 @@ struct sk_buff *ieee80211_ap_probereq_get(struct ieee80211_hw *hw, | |||
3782 | * | 3063 | * |
3783 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 3064 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
3784 | * | 3065 | * |
3785 | * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER and | 3066 | * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER and |
3786 | * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the | 3067 | * %IEEE80211_CONF_PS is set, the driver needs to inform whenever the |
3787 | * hardware is not receiving beacons with this function. | 3068 | * hardware is not receiving beacons with this function. |
3788 | */ | 3069 | */ |
@@ -3793,7 +3074,7 @@ void ieee80211_beacon_loss(struct ieee80211_vif *vif); | |||
3793 | * | 3074 | * |
3794 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 3075 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
3795 | * | 3076 | * |
3796 | * When beacon filtering is enabled with %IEEE80211_VIF_BEACON_FILTER, and | 3077 | * When beacon filtering is enabled with %IEEE80211_HW_BEACON_FILTER, and |
3797 | * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver | 3078 | * %IEEE80211_CONF_PS and %IEEE80211_HW_CONNECTION_MONITOR are set, the driver |
3798 | * needs to inform if the connection to the AP has been lost. | 3079 | * needs to inform if the connection to the AP has been lost. |
3799 | * | 3080 | * |
@@ -3863,7 +3144,7 @@ void ieee80211_enable_dyn_ps(struct ieee80211_vif *vif); | |||
3863 | * @rssi_event: the RSSI trigger event type | 3144 | * @rssi_event: the RSSI trigger event type |
3864 | * @gfp: context flags | 3145 | * @gfp: context flags |
3865 | * | 3146 | * |
3866 | * When the %IEEE80211_VIF_SUPPORTS_CQM_RSSI is set, and a connection quality | 3147 | * When the %IEEE80211_HW_SUPPORTS_CQM_RSSI is set, and a connection quality |
3867 | * monitoring is configured with an rssi threshold, the driver will inform | 3148 | * monitoring is configured with an rssi threshold, the driver will inform |
3868 | * whenever the rssi level reaches the threshold. | 3149 | * whenever the rssi level reaches the threshold. |
3869 | */ | 3150 | */ |
@@ -3872,6 +3153,16 @@ void ieee80211_cqm_rssi_notify(struct ieee80211_vif *vif, | |||
3872 | gfp_t gfp); | 3153 | gfp_t gfp); |
3873 | 3154 | ||
3874 | /** | 3155 | /** |
3156 | * ieee80211_get_operstate - get the operstate of the vif | ||
3157 | * | ||
3158 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | ||
3159 | * | ||
3160 | * The driver might need to know the operstate of the net_device | ||
3161 | * (specifically, whether the link is IF_OPER_UP after resume) | ||
3162 | */ | ||
3163 | unsigned char ieee80211_get_operstate(struct ieee80211_vif *vif); | ||
3164 | |||
3165 | /** | ||
3875 | * ieee80211_chswitch_done - Complete channel switch process | 3166 | * ieee80211_chswitch_done - Complete channel switch process |
3876 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 3167 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. |
3877 | * @success: make the channel switch successful or not | 3168 | * @success: make the channel switch successful or not |
@@ -3894,6 +3185,22 @@ void ieee80211_request_smps(struct ieee80211_vif *vif, | |||
3894 | enum ieee80211_smps_mode smps_mode); | 3185 | enum ieee80211_smps_mode smps_mode); |
3895 | 3186 | ||
3896 | /** | 3187 | /** |
3188 | * ieee80211_key_removed - disable hw acceleration for key | ||
3189 | * @key_conf: The key hw acceleration should be disabled for | ||
3190 | * | ||
3191 | * This allows drivers to indicate that the given key has been | ||
3192 | * removed from hardware acceleration, due to a new key that | ||
3193 | * was added. Don't use this if the key can continue to be used | ||
3194 | * for TX, if the key restriction is on RX only it is permitted | ||
3195 | * to keep the key for TX only and not call this function. | ||
3196 | * | ||
3197 | * Due to locking constraints, it may only be called during | ||
3198 | * @set_key. This function must be allowed to sleep, and the | ||
3199 | * key it tries to disable may still be used until it returns. | ||
3200 | */ | ||
3201 | void ieee80211_key_removed(struct ieee80211_key_conf *key_conf); | ||
3202 | |||
3203 | /** | ||
3897 | * ieee80211_ready_on_channel - notification of remain-on-channel start | 3204 | * ieee80211_ready_on_channel - notification of remain-on-channel start |
3898 | * @hw: pointer as obtained from ieee80211_alloc_hw() | 3205 | * @hw: pointer as obtained from ieee80211_alloc_hw() |
3899 | */ | 3206 | */ |
@@ -3922,20 +3229,17 @@ void ieee80211_remain_on_channel_expired(struct ieee80211_hw *hw); | |||
3922 | void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap, | 3229 | void ieee80211_stop_rx_ba_session(struct ieee80211_vif *vif, u16 ba_rx_bitmap, |
3923 | const u8 *addr); | 3230 | const u8 *addr); |
3924 | 3231 | ||
3232 | /* Rate control API */ | ||
3233 | |||
3925 | /** | 3234 | /** |
3926 | * ieee80211_send_bar - send a BlockAckReq frame | 3235 | * enum rate_control_changed - flags to indicate which parameter changed |
3927 | * | ||
3928 | * can be used to flush pending frames from the peer's aggregation reorder | ||
3929 | * buffer. | ||
3930 | * | 3236 | * |
3931 | * @vif: &struct ieee80211_vif pointer from the add_interface callback. | 3237 | * @IEEE80211_RC_HT_CHANGED: The HT parameters of the operating channel have |
3932 | * @ra: the peer's destination address | 3238 | * changed, rate control algorithm can update its internal state if needed. |
3933 | * @tid: the TID of the aggregation session | ||
3934 | * @ssn: the new starting sequence number for the receiver | ||
3935 | */ | 3239 | */ |
3936 | void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn); | 3240 | enum rate_control_changed { |
3937 | 3241 | IEEE80211_RC_HT_CHANGED = BIT(0) | |
3938 | /* Rate control API */ | 3242 | }; |
3939 | 3243 | ||
3940 | /** | 3244 | /** |
3941 | * struct ieee80211_tx_rate_control - rate control information for/from RC algo | 3245 | * struct ieee80211_tx_rate_control - rate control information for/from RC algo |
@@ -3943,8 +3247,6 @@ void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn); | |||
3943 | * @hw: The hardware the algorithm is invoked for. | 3247 | * @hw: The hardware the algorithm is invoked for. |
3944 | * @sband: The band this frame is being transmitted on. | 3248 | * @sband: The band this frame is being transmitted on. |
3945 | * @bss_conf: the current BSS configuration | 3249 | * @bss_conf: the current BSS configuration |
3946 | * @skb: the skb that will be transmitted, the control information in it needs | ||
3947 | * to be filled in | ||
3948 | * @reported_rate: The rate control algorithm can fill this in to indicate | 3250 | * @reported_rate: The rate control algorithm can fill this in to indicate |
3949 | * which rate should be reported to userspace as the current rate and | 3251 | * which rate should be reported to userspace as the current rate and |
3950 | * used for rate calculations in the mesh network. | 3252 | * used for rate calculations in the mesh network. |
@@ -3952,11 +3254,12 @@ void ieee80211_send_bar(struct ieee80211_vif *vif, u8 *ra, u16 tid, u16 ssn); | |||
3952 | * RTS threshold | 3254 | * RTS threshold |
3953 | * @short_preamble: whether mac80211 will request short-preamble transmission | 3255 | * @short_preamble: whether mac80211 will request short-preamble transmission |
3954 | * if the selected rate supports it | 3256 | * if the selected rate supports it |
3955 | * @max_rate_idx: user-requested maximum (legacy) rate | 3257 | * @max_rate_idx: user-requested maximum rate (not MCS for now) |
3956 | * (deprecated; this will be removed once drivers get updated to use | 3258 | * (deprecated; this will be removed once drivers get updated to use |
3957 | * rate_idx_mask) | 3259 | * rate_idx_mask) |
3958 | * @rate_idx_mask: user-requested (legacy) rate mask | 3260 | * @rate_idx_mask: user-requested rate mask (not MCS for now) |
3959 | * @rate_idx_mcs_mask: user-requested MCS rate mask | 3261 | * @skb: the skb that will be transmitted, the control information in it needs |
3262 | * to be filled in | ||
3960 | * @bss: whether this frame is sent out in AP or IBSS mode | 3263 | * @bss: whether this frame is sent out in AP or IBSS mode |
3961 | */ | 3264 | */ |
3962 | struct ieee80211_tx_rate_control { | 3265 | struct ieee80211_tx_rate_control { |
@@ -3968,7 +3271,6 @@ struct ieee80211_tx_rate_control { | |||
3968 | bool rts, short_preamble; | 3271 | bool rts, short_preamble; |
3969 | u8 max_rate_idx; | 3272 | u8 max_rate_idx; |
3970 | u32 rate_idx_mask; | 3273 | u32 rate_idx_mask; |
3971 | u8 rate_idx_mcs_mask[IEEE80211_HT_MCS_MASK_LEN]; | ||
3972 | bool bss; | 3274 | bool bss; |
3973 | }; | 3275 | }; |
3974 | 3276 | ||
@@ -3982,8 +3284,9 @@ struct rate_control_ops { | |||
3982 | void (*rate_init)(void *priv, struct ieee80211_supported_band *sband, | 3284 | void (*rate_init)(void *priv, struct ieee80211_supported_band *sband, |
3983 | struct ieee80211_sta *sta, void *priv_sta); | 3285 | struct ieee80211_sta *sta, void *priv_sta); |
3984 | void (*rate_update)(void *priv, struct ieee80211_supported_band *sband, | 3286 | void (*rate_update)(void *priv, struct ieee80211_supported_band *sband, |
3985 | struct ieee80211_sta *sta, void *priv_sta, | 3287 | struct ieee80211_sta *sta, |
3986 | u32 changed); | 3288 | void *priv_sta, u32 changed, |
3289 | enum nl80211_channel_type oper_chan_type); | ||
3987 | void (*free_sta)(void *priv, struct ieee80211_sta *sta, | 3290 | void (*free_sta)(void *priv, struct ieee80211_sta *sta, |
3988 | void *priv_sta); | 3291 | void *priv_sta); |
3989 | 3292 | ||
@@ -4039,9 +3342,8 @@ rate_lowest_index(struct ieee80211_supported_band *sband, | |||
4039 | return i; | 3342 | return i; |
4040 | 3343 | ||
4041 | /* warn when we cannot find a rate. */ | 3344 | /* warn when we cannot find a rate. */ |
4042 | WARN_ON_ONCE(1); | 3345 | WARN_ON(1); |
4043 | 3346 | ||
4044 | /* and return 0 (the lowest index) */ | ||
4045 | return 0; | 3347 | return 0; |
4046 | } | 3348 | } |
4047 | 3349 | ||
@@ -4117,15 +3419,4 @@ void ieee80211_enable_rssi_reports(struct ieee80211_vif *vif, | |||
4117 | int rssi_max_thold); | 3419 | int rssi_max_thold); |
4118 | 3420 | ||
4119 | void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif); | 3421 | void ieee80211_disable_rssi_reports(struct ieee80211_vif *vif); |
4120 | |||
4121 | /** | ||
4122 | * ieee80211_ave_rssi - report the average rssi for the specified interface | ||
4123 | * | ||
4124 | * @vif: the specified virtual interface | ||
4125 | * | ||
4126 | * This function return the average rssi value for the requested interface. | ||
4127 | * It assumes that the given vif is valid. | ||
4128 | */ | ||
4129 | int ieee80211_ave_rssi(struct ieee80211_vif *vif); | ||
4130 | |||
4131 | #endif /* MAC80211_H */ | 3422 | #endif /* MAC80211_H */ |
diff --git a/include/net/mac802154.h b/include/net/mac802154.h deleted file mode 100644 index d0d11df9cba..00000000000 --- a/include/net/mac802154.h +++ /dev/null | |||
@@ -1,144 +0,0 @@ | |||
1 | /* | ||
2 | * IEEE802.15.4-2003 specification | ||
3 | * | ||
4 | * Copyright (C) 2007-2012 Siemens AG | ||
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 | ||
8 | * as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License along | ||
16 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #ifndef NET_MAC802154_H | ||
20 | #define NET_MAC802154_H | ||
21 | |||
22 | #include <net/af_ieee802154.h> | ||
23 | |||
24 | /* General MAC frame format: | ||
25 | * 2 bytes: Frame Control | ||
26 | * 1 byte: Sequence Number | ||
27 | * 20 bytes: Addressing fields | ||
28 | * 14 bytes: Auxiliary Security Header | ||
29 | */ | ||
30 | #define MAC802154_FRAME_HARD_HEADER_LEN (2 + 1 + 20 + 14) | ||
31 | |||
32 | /* The following flags are used to indicate changed address settings from | ||
33 | * the stack to the hardware. | ||
34 | */ | ||
35 | |||
36 | /* indicates that the Short Address changed */ | ||
37 | #define IEEE802515_AFILT_SADDR_CHANGED 0x00000001 | ||
38 | /* indicates that the IEEE Address changed */ | ||
39 | #define IEEE802515_AFILT_IEEEADDR_CHANGED 0x00000002 | ||
40 | /* indicates that the PAN ID changed */ | ||
41 | #define IEEE802515_AFILT_PANID_CHANGED 0x00000004 | ||
42 | /* indicates that PAN Coordinator status changed */ | ||
43 | #define IEEE802515_AFILT_PANC_CHANGED 0x00000008 | ||
44 | |||
45 | struct ieee802154_hw_addr_filt { | ||
46 | __le16 pan_id; /* Each independent PAN selects a unique | ||
47 | * identifier. This PAN id allows communication | ||
48 | * between devices within a network using short | ||
49 | * addresses and enables transmissions between | ||
50 | * devices across independent networks. | ||
51 | */ | ||
52 | __le16 short_addr; | ||
53 | u8 ieee_addr[IEEE802154_ADDR_LEN]; | ||
54 | u8 pan_coord; | ||
55 | }; | ||
56 | |||
57 | struct ieee802154_dev { | ||
58 | /* filled by the driver */ | ||
59 | int extra_tx_headroom; | ||
60 | u32 flags; | ||
61 | struct device *parent; | ||
62 | |||
63 | /* filled by mac802154 core */ | ||
64 | struct ieee802154_hw_addr_filt hw_filt; | ||
65 | void *priv; | ||
66 | struct wpan_phy *phy; | ||
67 | }; | ||
68 | |||
69 | /* Checksum is in hardware and is omitted from a packet | ||
70 | * | ||
71 | * These following flags are used to indicate hardware capabilities to | ||
72 | * the stack. Generally, flags here should have their meaning | ||
73 | * done in a way that the simplest hardware doesn't need setting | ||
74 | * any particular flags. There are some exceptions to this rule, | ||
75 | * however, so you are advised to review these flags carefully. | ||
76 | */ | ||
77 | |||
78 | /* Indicates that receiver omits FCS and xmitter will add FCS on it's own. */ | ||
79 | #define IEEE802154_HW_OMIT_CKSUM 0x00000001 | ||
80 | /* Indicates that receiver will autorespond with ACK frames. */ | ||
81 | #define IEEE802154_HW_AACK 0x00000002 | ||
82 | |||
83 | /* struct ieee802154_ops - callbacks from mac802154 to the driver | ||
84 | * | ||
85 | * This structure contains various callbacks that the driver may | ||
86 | * handle or, in some cases, must handle, for example to transmit | ||
87 | * a frame. | ||
88 | * | ||
89 | * start: Handler that 802.15.4 module calls for device initialization. | ||
90 | * This function is called before the first interface is attached. | ||
91 | * | ||
92 | * stop: Handler that 802.15.4 module calls for device cleanup. | ||
93 | * This function is called after the last interface is removed. | ||
94 | * | ||
95 | * xmit: Handler that 802.15.4 module calls for each transmitted frame. | ||
96 | * skb cntains the buffer starting from the IEEE 802.15.4 header. | ||
97 | * The low-level driver should send the frame based on available | ||
98 | * configuration. | ||
99 | * This function should return zero or negative errno. Called with | ||
100 | * pib_lock held. | ||
101 | * | ||
102 | * ed: Handler that 802.15.4 module calls for Energy Detection. | ||
103 | * This function should place the value for detected energy | ||
104 | * (usually device-dependant) in the level pointer and return | ||
105 | * either zero or negative errno. Called with pib_lock held. | ||
106 | * | ||
107 | * set_channel: | ||
108 | * Set radio for listening on specific channel. | ||
109 | * Set the device for listening on specified channel. | ||
110 | * Returns either zero, or negative errno. Called with pib_lock held. | ||
111 | * | ||
112 | * set_hw_addr_filt: | ||
113 | * Set radio for listening on specific address. | ||
114 | * Set the device for listening on specified address. | ||
115 | * Returns either zero, or negative errno. | ||
116 | */ | ||
117 | struct ieee802154_ops { | ||
118 | struct module *owner; | ||
119 | int (*start)(struct ieee802154_dev *dev); | ||
120 | void (*stop)(struct ieee802154_dev *dev); | ||
121 | int (*xmit)(struct ieee802154_dev *dev, | ||
122 | struct sk_buff *skb); | ||
123 | int (*ed)(struct ieee802154_dev *dev, u8 *level); | ||
124 | int (*set_channel)(struct ieee802154_dev *dev, | ||
125 | int page, | ||
126 | int channel); | ||
127 | int (*set_hw_addr_filt)(struct ieee802154_dev *dev, | ||
128 | struct ieee802154_hw_addr_filt *filt, | ||
129 | unsigned long changed); | ||
130 | int (*ieee_addr)(struct ieee802154_dev *dev, | ||
131 | u8 addr[IEEE802154_ADDR_LEN]); | ||
132 | }; | ||
133 | |||
134 | /* Basic interface to register ieee802154 device */ | ||
135 | struct ieee802154_dev * | ||
136 | ieee802154_alloc_device(size_t priv_data_lex, struct ieee802154_ops *ops); | ||
137 | void ieee802154_free_device(struct ieee802154_dev *dev); | ||
138 | int ieee802154_register_device(struct ieee802154_dev *dev); | ||
139 | void ieee802154_unregister_device(struct ieee802154_dev *dev); | ||
140 | |||
141 | void ieee802154_rx_irqsafe(struct ieee802154_dev *dev, struct sk_buff *skb, | ||
142 | u8 lqi); | ||
143 | |||
144 | #endif /* NET_MAC802154_H */ | ||
diff --git a/include/net/ndisc.h b/include/net/ndisc.h index 23b3a7c5878..62beeb97c4b 100644 --- a/include/net/ndisc.h +++ b/include/net/ndisc.h | |||
@@ -34,7 +34,6 @@ enum { | |||
34 | __ND_OPT_ARRAY_MAX, | 34 | __ND_OPT_ARRAY_MAX, |
35 | ND_OPT_ROUTE_INFO = 24, /* RFC4191 */ | 35 | ND_OPT_ROUTE_INFO = 24, /* RFC4191 */ |
36 | ND_OPT_RDNSS = 25, /* RFC5006 */ | 36 | ND_OPT_RDNSS = 25, /* RFC5006 */ |
37 | ND_OPT_DNSSL = 31, /* RFC6106 */ | ||
38 | __ND_OPT_MAX | 37 | __ND_OPT_MAX |
39 | }; | 38 | }; |
40 | 39 | ||
@@ -47,9 +46,6 @@ enum { | |||
47 | #include <linux/icmpv6.h> | 46 | #include <linux/icmpv6.h> |
48 | #include <linux/in6.h> | 47 | #include <linux/in6.h> |
49 | #include <linux/types.h> | 48 | #include <linux/types.h> |
50 | #include <linux/if_arp.h> | ||
51 | #include <linux/netdevice.h> | ||
52 | #include <linux/hash.h> | ||
53 | 49 | ||
54 | #include <net/neighbour.h> | 50 | #include <net/neighbour.h> |
55 | 51 | ||
@@ -78,102 +74,11 @@ struct ra_msg { | |||
78 | __be32 retrans_timer; | 74 | __be32 retrans_timer; |
79 | }; | 75 | }; |
80 | 76 | ||
81 | struct rd_msg { | ||
82 | struct icmp6hdr icmph; | ||
83 | struct in6_addr target; | ||
84 | struct in6_addr dest; | ||
85 | __u8 opt[0]; | ||
86 | }; | ||
87 | |||
88 | struct nd_opt_hdr { | 77 | struct nd_opt_hdr { |
89 | __u8 nd_opt_type; | 78 | __u8 nd_opt_type; |
90 | __u8 nd_opt_len; | 79 | __u8 nd_opt_len; |
91 | } __packed; | 80 | } __packed; |
92 | 81 | ||
93 | /* ND options */ | ||
94 | struct ndisc_options { | ||
95 | struct nd_opt_hdr *nd_opt_array[__ND_OPT_ARRAY_MAX]; | ||
96 | #ifdef CONFIG_IPV6_ROUTE_INFO | ||
97 | struct nd_opt_hdr *nd_opts_ri; | ||
98 | struct nd_opt_hdr *nd_opts_ri_end; | ||
99 | #endif | ||
100 | struct nd_opt_hdr *nd_useropts; | ||
101 | struct nd_opt_hdr *nd_useropts_end; | ||
102 | }; | ||
103 | |||
104 | #define nd_opts_src_lladdr nd_opt_array[ND_OPT_SOURCE_LL_ADDR] | ||
105 | #define nd_opts_tgt_lladdr nd_opt_array[ND_OPT_TARGET_LL_ADDR] | ||
106 | #define nd_opts_pi nd_opt_array[ND_OPT_PREFIX_INFO] | ||
107 | #define nd_opts_pi_end nd_opt_array[__ND_OPT_PREFIX_INFO_END] | ||
108 | #define nd_opts_rh nd_opt_array[ND_OPT_REDIRECT_HDR] | ||
109 | #define nd_opts_mtu nd_opt_array[ND_OPT_MTU] | ||
110 | |||
111 | #define NDISC_OPT_SPACE(len) (((len)+2+7)&~7) | ||
112 | |||
113 | extern struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len, | ||
114 | struct ndisc_options *ndopts); | ||
115 | |||
116 | /* | ||
117 | * Return the padding between the option length and the start of the | ||
118 | * link addr. Currently only IP-over-InfiniBand needs this, although | ||
119 | * if RFC 3831 IPv6-over-Fibre Channel is ever implemented it may | ||
120 | * also need a pad of 2. | ||
121 | */ | ||
122 | static int ndisc_addr_option_pad(unsigned short type) | ||
123 | { | ||
124 | switch (type) { | ||
125 | case ARPHRD_INFINIBAND: return 2; | ||
126 | default: return 0; | ||
127 | } | ||
128 | } | ||
129 | |||
130 | static inline u8 *ndisc_opt_addr_data(struct nd_opt_hdr *p, | ||
131 | struct net_device *dev) | ||
132 | { | ||
133 | u8 *lladdr = (u8 *)(p + 1); | ||
134 | int lladdrlen = p->nd_opt_len << 3; | ||
135 | int prepad = ndisc_addr_option_pad(dev->type); | ||
136 | if (lladdrlen != NDISC_OPT_SPACE(dev->addr_len + prepad)) | ||
137 | return NULL; | ||
138 | return lladdr + prepad; | ||
139 | } | ||
140 | |||
141 | static inline u32 ndisc_hashfn(const void *pkey, const struct net_device *dev, __u32 *hash_rnd) | ||
142 | { | ||
143 | const u32 *p32 = pkey; | ||
144 | |||
145 | return (((p32[0] ^ hash32_ptr(dev)) * hash_rnd[0]) + | ||
146 | (p32[1] * hash_rnd[1]) + | ||
147 | (p32[2] * hash_rnd[2]) + | ||
148 | (p32[3] * hash_rnd[3])); | ||
149 | } | ||
150 | |||
151 | static inline struct neighbour *__ipv6_neigh_lookup(struct neigh_table *tbl, struct net_device *dev, const void *pkey) | ||
152 | { | ||
153 | struct neigh_hash_table *nht; | ||
154 | const u32 *p32 = pkey; | ||
155 | struct neighbour *n; | ||
156 | u32 hash_val; | ||
157 | |||
158 | rcu_read_lock_bh(); | ||
159 | nht = rcu_dereference_bh(tbl->nht); | ||
160 | hash_val = ndisc_hashfn(pkey, dev, nht->hash_rnd) >> (32 - nht->hash_shift); | ||
161 | for (n = rcu_dereference_bh(nht->hash_buckets[hash_val]); | ||
162 | n != NULL; | ||
163 | n = rcu_dereference_bh(n->next)) { | ||
164 | u32 *n32 = (u32 *) n->primary_key; | ||
165 | if (n->dev == dev && | ||
166 | ((n32[0] ^ p32[0]) | (n32[1] ^ p32[1]) | | ||
167 | (n32[2] ^ p32[2]) | (n32[3] ^ p32[3])) == 0) { | ||
168 | if (!atomic_inc_not_zero(&n->refcnt)) | ||
169 | n = NULL; | ||
170 | break; | ||
171 | } | ||
172 | } | ||
173 | rcu_read_unlock_bh(); | ||
174 | |||
175 | return n; | ||
176 | } | ||
177 | 82 | ||
178 | extern int ndisc_init(void); | 83 | extern int ndisc_init(void); |
179 | 84 | ||
@@ -192,11 +97,27 @@ extern void ndisc_send_rs(struct net_device *dev, | |||
192 | const struct in6_addr *daddr); | 97 | const struct in6_addr *daddr); |
193 | 98 | ||
194 | extern void ndisc_send_redirect(struct sk_buff *skb, | 99 | extern void ndisc_send_redirect(struct sk_buff *skb, |
100 | struct neighbour *neigh, | ||
195 | const struct in6_addr *target); | 101 | const struct in6_addr *target); |
196 | 102 | ||
197 | extern int ndisc_mc_map(const struct in6_addr *addr, char *buf, | 103 | extern int ndisc_mc_map(const struct in6_addr *addr, char *buf, |
198 | struct net_device *dev, int dir); | 104 | struct net_device *dev, int dir); |
199 | 105 | ||
106 | extern struct sk_buff *ndisc_build_skb(struct net_device *dev, | ||
107 | const struct in6_addr *daddr, | ||
108 | const struct in6_addr *saddr, | ||
109 | struct icmp6hdr *icmp6h, | ||
110 | const struct in6_addr *target, | ||
111 | int llinfo); | ||
112 | |||
113 | extern void ndisc_send_skb(struct sk_buff *skb, | ||
114 | struct net_device *dev, | ||
115 | struct neighbour *neigh, | ||
116 | const struct in6_addr *daddr, | ||
117 | const struct in6_addr *saddr, | ||
118 | struct icmp6hdr *icmp6h); | ||
119 | |||
120 | |||
200 | 121 | ||
201 | /* | 122 | /* |
202 | * IGMP | 123 | * IGMP |
@@ -224,4 +145,13 @@ int ndisc_ifinfo_sysctl_strategy(ctl_table *ctl, | |||
224 | extern void inet6_ifinfo_notify(int event, | 145 | extern void inet6_ifinfo_notify(int event, |
225 | struct inet6_dev *idev); | 146 | struct inet6_dev *idev); |
226 | 147 | ||
148 | static inline struct neighbour * ndisc_get_neigh(struct net_device *dev, const struct in6_addr *addr) | ||
149 | { | ||
150 | |||
151 | if (dev) | ||
152 | return __neigh_lookup_errno(&nd_tbl, addr, dev); | ||
153 | |||
154 | return ERR_PTR(-ENODEV); | ||
155 | } | ||
156 | |||
227 | #endif | 157 | #endif |
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 0dab173e27d..2720884287c 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
@@ -59,7 +59,7 @@ struct neigh_parms { | |||
59 | int reachable_time; | 59 | int reachable_time; |
60 | int delay_probe_time; | 60 | int delay_probe_time; |
61 | 61 | ||
62 | int queue_len_bytes; | 62 | int queue_len; |
63 | int ucast_probes; | 63 | int ucast_probes; |
64 | int app_probes; | 64 | int app_probes; |
65 | int mcast_probes; | 65 | int mcast_probes; |
@@ -99,7 +99,6 @@ struct neighbour { | |||
99 | rwlock_t lock; | 99 | rwlock_t lock; |
100 | atomic_t refcnt; | 100 | atomic_t refcnt; |
101 | struct sk_buff_head arp_queue; | 101 | struct sk_buff_head arp_queue; |
102 | unsigned int arp_queue_len_bytes; | ||
103 | struct timer_list timer; | 102 | struct timer_list timer; |
104 | unsigned long used; | 103 | unsigned long used; |
105 | atomic_t probes; | 104 | atomic_t probes; |
@@ -139,12 +138,10 @@ struct pneigh_entry { | |||
139 | * neighbour table manipulation | 138 | * neighbour table manipulation |
140 | */ | 139 | */ |
141 | 140 | ||
142 | #define NEIGH_NUM_HASH_RND 4 | ||
143 | |||
144 | struct neigh_hash_table { | 141 | struct neigh_hash_table { |
145 | struct neighbour __rcu **hash_buckets; | 142 | struct neighbour __rcu **hash_buckets; |
146 | unsigned int hash_shift; | 143 | unsigned int hash_shift; |
147 | __u32 hash_rnd[NEIGH_NUM_HASH_RND]; | 144 | __u32 hash_rnd; |
148 | struct rcu_head rcu; | 145 | struct rcu_head rcu; |
149 | }; | 146 | }; |
150 | 147 | ||
@@ -156,7 +153,7 @@ struct neigh_table { | |||
156 | int key_len; | 153 | int key_len; |
157 | __u32 (*hash)(const void *pkey, | 154 | __u32 (*hash)(const void *pkey, |
158 | const struct net_device *dev, | 155 | const struct net_device *dev, |
159 | __u32 *hash_rnd); | 156 | __u32 hash_rnd); |
160 | int (*constructor)(struct neighbour *); | 157 | int (*constructor)(struct neighbour *); |
161 | int (*pconstructor)(struct pneigh_entry *); | 158 | int (*pconstructor)(struct pneigh_entry *); |
162 | void (*pdestructor)(struct pneigh_entry *); | 159 | void (*pdestructor)(struct pneigh_entry *); |
@@ -175,18 +172,12 @@ struct neigh_table { | |||
175 | atomic_t entries; | 172 | atomic_t entries; |
176 | rwlock_t lock; | 173 | rwlock_t lock; |
177 | unsigned long last_rand; | 174 | unsigned long last_rand; |
175 | struct kmem_cache *kmem_cachep; | ||
178 | struct neigh_statistics __percpu *stats; | 176 | struct neigh_statistics __percpu *stats; |
179 | struct neigh_hash_table __rcu *nht; | 177 | struct neigh_hash_table __rcu *nht; |
180 | struct pneigh_entry **phash_buckets; | 178 | struct pneigh_entry **phash_buckets; |
181 | }; | 179 | }; |
182 | 180 | ||
183 | #define NEIGH_PRIV_ALIGN sizeof(long long) | ||
184 | |||
185 | static inline void *neighbour_priv(const struct neighbour *n) | ||
186 | { | ||
187 | return (char *)n + ALIGN(sizeof(*n) + n->tbl->key_len, NEIGH_PRIV_ALIGN); | ||
188 | } | ||
189 | |||
190 | /* flags for neigh_update() */ | 181 | /* flags for neigh_update() */ |
191 | #define NEIGH_UPDATE_F_OVERRIDE 0x00000001 | 182 | #define NEIGH_UPDATE_F_OVERRIDE 0x00000001 |
192 | #define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002 | 183 | #define NEIGH_UPDATE_F_WEAK_OVERRIDE 0x00000002 |
@@ -195,6 +186,7 @@ static inline void *neighbour_priv(const struct neighbour *n) | |||
195 | #define NEIGH_UPDATE_F_ADMIN 0x80000000 | 186 | #define NEIGH_UPDATE_F_ADMIN 0x80000000 |
196 | 187 | ||
197 | extern void neigh_table_init(struct neigh_table *tbl); | 188 | extern void neigh_table_init(struct neigh_table *tbl); |
189 | extern void neigh_table_init_no_netlink(struct neigh_table *tbl); | ||
198 | extern int neigh_table_clear(struct neigh_table *tbl); | 190 | extern int neigh_table_clear(struct neigh_table *tbl); |
199 | extern struct neighbour * neigh_lookup(struct neigh_table *tbl, | 191 | extern struct neighbour * neigh_lookup(struct neigh_table *tbl, |
200 | const void *pkey, | 192 | const void *pkey, |
@@ -202,16 +194,9 @@ extern struct neighbour * neigh_lookup(struct neigh_table *tbl, | |||
202 | extern struct neighbour * neigh_lookup_nodev(struct neigh_table *tbl, | 194 | extern struct neighbour * neigh_lookup_nodev(struct neigh_table *tbl, |
203 | struct net *net, | 195 | struct net *net, |
204 | const void *pkey); | 196 | const void *pkey); |
205 | extern struct neighbour * __neigh_create(struct neigh_table *tbl, | 197 | extern struct neighbour * neigh_create(struct neigh_table *tbl, |
206 | const void *pkey, | ||
207 | struct net_device *dev, | ||
208 | bool want_ref); | ||
209 | static inline struct neighbour *neigh_create(struct neigh_table *tbl, | ||
210 | const void *pkey, | 198 | const void *pkey, |
211 | struct net_device *dev) | 199 | struct net_device *dev); |
212 | { | ||
213 | return __neigh_create(tbl, pkey, dev, true); | ||
214 | } | ||
215 | extern void neigh_destroy(struct neighbour *neigh); | 200 | extern void neigh_destroy(struct neighbour *neigh); |
216 | extern int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb); | 201 | extern int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb); |
217 | extern int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, | 202 | extern int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, |
@@ -309,6 +294,12 @@ static inline struct neighbour * neigh_clone(struct neighbour *neigh) | |||
309 | 294 | ||
310 | #define neigh_hold(n) atomic_inc(&(n)->refcnt) | 295 | #define neigh_hold(n) atomic_inc(&(n)->refcnt) |
311 | 296 | ||
297 | static inline void neigh_confirm(struct neighbour *neigh) | ||
298 | { | ||
299 | if (neigh) | ||
300 | neigh->confirmed = jiffies; | ||
301 | } | ||
302 | |||
312 | static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) | 303 | static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) |
313 | { | 304 | { |
314 | unsigned long now = jiffies; | 305 | unsigned long now = jiffies; |
@@ -323,7 +314,7 @@ static inline int neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) | |||
323 | #ifdef CONFIG_BRIDGE_NETFILTER | 314 | #ifdef CONFIG_BRIDGE_NETFILTER |
324 | static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb) | 315 | static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb) |
325 | { | 316 | { |
326 | unsigned int seq, hh_alen; | 317 | unsigned seq, hh_alen; |
327 | 318 | ||
328 | do { | 319 | do { |
329 | seq = read_seqbegin(&hh->hh_lock); | 320 | seq = read_seqbegin(&hh->hh_lock); |
@@ -334,28 +325,33 @@ static inline int neigh_hh_bridge(struct hh_cache *hh, struct sk_buff *skb) | |||
334 | } | 325 | } |
335 | #endif | 326 | #endif |
336 | 327 | ||
337 | static inline int neigh_hh_output(const struct hh_cache *hh, struct sk_buff *skb) | 328 | static inline int neigh_hh_output(struct hh_cache *hh, struct sk_buff *skb) |
338 | { | 329 | { |
339 | unsigned int seq; | 330 | unsigned seq; |
340 | int hh_len; | 331 | int hh_len; |
341 | 332 | ||
342 | do { | 333 | do { |
334 | int hh_alen; | ||
335 | |||
343 | seq = read_seqbegin(&hh->hh_lock); | 336 | seq = read_seqbegin(&hh->hh_lock); |
344 | hh_len = hh->hh_len; | 337 | hh_len = hh->hh_len; |
345 | if (likely(hh_len <= HH_DATA_MOD)) { | 338 | hh_alen = HH_DATA_ALIGN(hh_len); |
346 | /* this is inlined by gcc */ | 339 | memcpy(skb->data - hh_alen, hh->hh_data, hh_alen); |
347 | memcpy(skb->data - HH_DATA_MOD, hh->hh_data, HH_DATA_MOD); | ||
348 | } else { | ||
349 | int hh_alen = HH_DATA_ALIGN(hh_len); | ||
350 | |||
351 | memcpy(skb->data - hh_alen, hh->hh_data, hh_alen); | ||
352 | } | ||
353 | } while (read_seqretry(&hh->hh_lock, seq)); | 340 | } while (read_seqretry(&hh->hh_lock, seq)); |
354 | 341 | ||
355 | skb_push(skb, hh_len); | 342 | skb_push(skb, hh_len); |
356 | return dev_queue_xmit(skb); | 343 | return dev_queue_xmit(skb); |
357 | } | 344 | } |
358 | 345 | ||
346 | static inline int neigh_output(struct neighbour *n, struct sk_buff *skb) | ||
347 | { | ||
348 | struct hh_cache *hh = &n->hh; | ||
349 | if ((n->nud_state & NUD_CONNECTED) && hh->hh_len) | ||
350 | return neigh_hh_output(hh, skb); | ||
351 | else | ||
352 | return n->output(n, skb); | ||
353 | } | ||
354 | |||
359 | static inline struct neighbour * | 355 | static inline struct neighbour * |
360 | __neigh_lookup(struct neigh_table *tbl, const void *pkey, struct net_device *dev, int creat) | 356 | __neigh_lookup(struct neigh_table *tbl, const void *pkey, struct net_device *dev, int creat) |
361 | { | 357 | { |
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index de644bcd861..3bb6fa0eace 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -15,7 +15,6 @@ | |||
15 | #include <net/netns/packet.h> | 15 | #include <net/netns/packet.h> |
16 | #include <net/netns/ipv4.h> | 16 | #include <net/netns/ipv4.h> |
17 | #include <net/netns/ipv6.h> | 17 | #include <net/netns/ipv6.h> |
18 | #include <net/netns/sctp.h> | ||
19 | #include <net/netns/dccp.h> | 18 | #include <net/netns/dccp.h> |
20 | #include <net/netns/x_tables.h> | 19 | #include <net/netns/x_tables.h> |
21 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 20 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
@@ -23,7 +22,6 @@ | |||
23 | #endif | 22 | #endif |
24 | #include <net/netns/xfrm.h> | 23 | #include <net/netns/xfrm.h> |
25 | 24 | ||
26 | struct user_namespace; | ||
27 | struct proc_dir_entry; | 25 | struct proc_dir_entry; |
28 | struct net_device; | 26 | struct net_device; |
29 | struct sock; | 27 | struct sock; |
@@ -54,10 +52,6 @@ struct net { | |||
54 | struct list_head cleanup_list; /* namespaces on death row */ | 52 | struct list_head cleanup_list; /* namespaces on death row */ |
55 | struct list_head exit_list; /* Use only net_mutex */ | 53 | struct list_head exit_list; /* Use only net_mutex */ |
56 | 54 | ||
57 | struct user_namespace *user_ns; /* Owning user namespace */ | ||
58 | |||
59 | unsigned int proc_inum; | ||
60 | |||
61 | struct proc_dir_entry *proc_net; | 55 | struct proc_dir_entry *proc_net; |
62 | struct proc_dir_entry *proc_net_stat; | 56 | struct proc_dir_entry *proc_net_stat; |
63 | 57 | ||
@@ -72,7 +66,6 @@ struct net { | |||
72 | struct hlist_head *dev_name_head; | 66 | struct hlist_head *dev_name_head; |
73 | struct hlist_head *dev_index_head; | 67 | struct hlist_head *dev_index_head; |
74 | unsigned int dev_base_seq; /* protected by rtnl_mutex */ | 68 | unsigned int dev_base_seq; /* protected by rtnl_mutex */ |
75 | int ifindex; | ||
76 | 69 | ||
77 | /* core fib_rules */ | 70 | /* core fib_rules */ |
78 | struct list_head rules_ops; | 71 | struct list_head rules_ops; |
@@ -84,12 +77,9 @@ struct net { | |||
84 | struct netns_packet packet; | 77 | struct netns_packet packet; |
85 | struct netns_unix unx; | 78 | struct netns_unix unx; |
86 | struct netns_ipv4 ipv4; | 79 | struct netns_ipv4 ipv4; |
87 | #if IS_ENABLED(CONFIG_IPV6) | 80 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
88 | struct netns_ipv6 ipv6; | 81 | struct netns_ipv6 ipv6; |
89 | #endif | 82 | #endif |
90 | #if defined(CONFIG_IP_SCTP) || defined(CONFIG_IP_SCTP_MODULE) | ||
91 | struct netns_sctp sctp; | ||
92 | #endif | ||
93 | #if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE) | 83 | #if defined(CONFIG_IP_DCCP) || defined(CONFIG_IP_DCCP_MODULE) |
94 | struct netns_dccp dccp; | 84 | struct netns_dccp dccp; |
95 | #endif | 85 | #endif |
@@ -98,9 +88,6 @@ struct net { | |||
98 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 88 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
99 | struct netns_ct ct; | 89 | struct netns_ct ct; |
100 | #endif | 90 | #endif |
101 | #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) | ||
102 | struct netns_nf_frag nf_frag; | ||
103 | #endif | ||
104 | struct sock *nfnl; | 91 | struct sock *nfnl; |
105 | struct sock *nfnl_stash; | 92 | struct sock *nfnl_stash; |
106 | #endif | 93 | #endif |
@@ -114,38 +101,24 @@ struct net { | |||
114 | struct netns_xfrm xfrm; | 101 | struct netns_xfrm xfrm; |
115 | #endif | 102 | #endif |
116 | struct netns_ipvs *ipvs; | 103 | struct netns_ipvs *ipvs; |
117 | struct sock *diag_nlsk; | ||
118 | atomic_t rt_genid; | ||
119 | }; | 104 | }; |
120 | 105 | ||
121 | /* | ||
122 | * ifindex generation is per-net namespace, and loopback is | ||
123 | * always the 1st device in ns (see net_dev_init), thus any | ||
124 | * loopback device should get ifindex 1 | ||
125 | */ | ||
126 | |||
127 | #define LOOPBACK_IFINDEX 1 | ||
128 | 106 | ||
129 | #include <linux/seq_file_net.h> | 107 | #include <linux/seq_file_net.h> |
130 | 108 | ||
131 | /* Init's network namespace */ | 109 | /* Init's network namespace */ |
132 | extern struct net init_net; | 110 | extern struct net init_net; |
133 | 111 | ||
134 | #ifdef CONFIG_NET_NS | 112 | #ifdef CONFIG_NET |
135 | extern struct net *copy_net_ns(unsigned long flags, | 113 | extern struct net *copy_net_ns(unsigned long flags, struct net *net_ns); |
136 | struct user_namespace *user_ns, struct net *old_net); | 114 | |
137 | 115 | #else /* CONFIG_NET */ | |
138 | #else /* CONFIG_NET_NS */ | 116 | static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns) |
139 | #include <linux/sched.h> | ||
140 | #include <linux/nsproxy.h> | ||
141 | static inline struct net *copy_net_ns(unsigned long flags, | ||
142 | struct user_namespace *user_ns, struct net *old_net) | ||
143 | { | 117 | { |
144 | if (flags & CLONE_NEWNET) | 118 | /* There is nothing to copy so this is a noop */ |
145 | return ERR_PTR(-EINVAL); | 119 | return net_ns; |
146 | return old_net; | ||
147 | } | 120 | } |
148 | #endif /* CONFIG_NET_NS */ | 121 | #endif /* CONFIG_NET */ |
149 | 122 | ||
150 | 123 | ||
151 | extern struct list_head net_namespace_list; | 124 | extern struct list_head net_namespace_list; |
@@ -267,12 +240,10 @@ static inline struct net *read_pnet(struct net * const *pnet) | |||
267 | #define __net_init | 240 | #define __net_init |
268 | #define __net_exit | 241 | #define __net_exit |
269 | #define __net_initdata | 242 | #define __net_initdata |
270 | #define __net_initconst | ||
271 | #else | 243 | #else |
272 | #define __net_init __init | 244 | #define __net_init __init |
273 | #define __net_exit __exit_refok | 245 | #define __net_exit __exit_refok |
274 | #define __net_initdata __initdata | 246 | #define __net_initdata __initdata |
275 | #define __net_initconst __initconst | ||
276 | #endif | 247 | #endif |
277 | 248 | ||
278 | struct pernet_operations { | 249 | struct pernet_operations { |
@@ -308,34 +279,14 @@ extern void unregister_pernet_subsys(struct pernet_operations *); | |||
308 | extern int register_pernet_device(struct pernet_operations *); | 279 | extern int register_pernet_device(struct pernet_operations *); |
309 | extern void unregister_pernet_device(struct pernet_operations *); | 280 | extern void unregister_pernet_device(struct pernet_operations *); |
310 | 281 | ||
282 | struct ctl_path; | ||
311 | struct ctl_table; | 283 | struct ctl_table; |
312 | struct ctl_table_header; | 284 | struct ctl_table_header; |
313 | 285 | ||
314 | #ifdef CONFIG_SYSCTL | 286 | extern struct ctl_table_header *register_net_sysctl_table(struct net *net, |
315 | extern int net_sysctl_init(void); | 287 | const struct ctl_path *path, struct ctl_table *table); |
316 | extern struct ctl_table_header *register_net_sysctl(struct net *net, | 288 | extern struct ctl_table_header *register_net_sysctl_rotable( |
317 | const char *path, struct ctl_table *table); | 289 | const struct ctl_path *path, struct ctl_table *table); |
318 | extern void unregister_net_sysctl_table(struct ctl_table_header *header); | 290 | extern void unregister_net_sysctl_table(struct ctl_table_header *header); |
319 | #else | ||
320 | static inline int net_sysctl_init(void) { return 0; } | ||
321 | static inline struct ctl_table_header *register_net_sysctl(struct net *net, | ||
322 | const char *path, struct ctl_table *table) | ||
323 | { | ||
324 | return NULL; | ||
325 | } | ||
326 | static inline void unregister_net_sysctl_table(struct ctl_table_header *header) | ||
327 | { | ||
328 | } | ||
329 | #endif | ||
330 | |||
331 | static inline int rt_genid(struct net *net) | ||
332 | { | ||
333 | return atomic_read(&net->rt_genid); | ||
334 | } | ||
335 | |||
336 | static inline void rt_genid_bump(struct net *net) | ||
337 | { | ||
338 | atomic_inc(&net->rt_genid); | ||
339 | } | ||
340 | 291 | ||
341 | #endif /* __NET_NET_NAMESPACE_H */ | 292 | #endif /* __NET_NET_NAMESPACE_H */ |
diff --git a/include/net/netevent.h b/include/net/netevent.h index 3ce4988c9c0..086f8a5b59d 100644 --- a/include/net/netevent.h +++ b/include/net/netevent.h | |||
@@ -12,14 +12,10 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | struct dst_entry; | 14 | struct dst_entry; |
15 | struct neighbour; | ||
16 | 15 | ||
17 | struct netevent_redirect { | 16 | struct netevent_redirect { |
18 | struct dst_entry *old; | 17 | struct dst_entry *old; |
19 | struct neighbour *old_neigh; | ||
20 | struct dst_entry *new; | 18 | struct dst_entry *new; |
21 | struct neighbour *new_neigh; | ||
22 | const void *daddr; | ||
23 | }; | 19 | }; |
24 | 20 | ||
25 | enum netevent_notif_type { | 21 | enum netevent_notif_type { |
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h index caca0c4d6b4..0b7f05e4a92 100644 --- a/include/net/netfilter/nf_conntrack.h +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -39,6 +39,36 @@ union nf_conntrack_expect_proto { | |||
39 | /* insert expect proto private data here */ | 39 | /* insert expect proto private data here */ |
40 | }; | 40 | }; |
41 | 41 | ||
42 | /* Add protocol helper include file here */ | ||
43 | #include <linux/netfilter/nf_conntrack_ftp.h> | ||
44 | #include <linux/netfilter/nf_conntrack_pptp.h> | ||
45 | #include <linux/netfilter/nf_conntrack_h323.h> | ||
46 | #include <linux/netfilter/nf_conntrack_sane.h> | ||
47 | #include <linux/netfilter/nf_conntrack_sip.h> | ||
48 | |||
49 | /* per conntrack: application helper private data */ | ||
50 | union nf_conntrack_help { | ||
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; | ||
54 | #endif | ||
55 | #if defined(CONFIG_NF_CONNTRACK_PPTP) || \ | ||
56 | defined(CONFIG_NF_CONNTRACK_PPTP_MODULE) | ||
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) | ||
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) | ||
65 | struct nf_ct_sane_master ct_sane_info; | ||
66 | #endif | ||
67 | #if defined(CONFIG_NF_CONNTRACK_SIP) || defined(CONFIG_NF_CONNTRACK_SIP_MODULE) | ||
68 | struct nf_ct_sip_master ct_sip_info; | ||
69 | #endif | ||
70 | }; | ||
71 | |||
42 | #include <linux/types.h> | 72 | #include <linux/types.h> |
43 | #include <linux/skbuff.h> | 73 | #include <linux/skbuff.h> |
44 | #include <linux/timer.h> | 74 | #include <linux/timer.h> |
@@ -59,13 +89,12 @@ struct nf_conn_help { | |||
59 | /* Helper. if any */ | 89 | /* Helper. if any */ |
60 | struct nf_conntrack_helper __rcu *helper; | 90 | struct nf_conntrack_helper __rcu *helper; |
61 | 91 | ||
92 | union nf_conntrack_help help; | ||
93 | |||
62 | struct hlist_head expectations; | 94 | struct hlist_head expectations; |
63 | 95 | ||
64 | /* Current number of expected connections */ | 96 | /* Current number of expected connections */ |
65 | u8 expecting[NF_CT_MAX_EXPECT_CLASSES]; | 97 | u8 expecting[NF_CT_MAX_EXPECT_CLASSES]; |
66 | |||
67 | /* private helper information. */ | ||
68 | char data[]; | ||
69 | }; | 98 | }; |
70 | 99 | ||
71 | #include <net/netfilter/ipv4/nf_conntrack_ipv4.h> | 100 | #include <net/netfilter/ipv4/nf_conntrack_ipv4.h> |
@@ -180,9 +209,9 @@ extern struct nf_conntrack_tuple_hash * | |||
180 | __nf_conntrack_find(struct net *net, u16 zone, | 209 | __nf_conntrack_find(struct net *net, u16 zone, |
181 | const struct nf_conntrack_tuple *tuple); | 210 | const struct nf_conntrack_tuple *tuple); |
182 | 211 | ||
183 | extern int nf_conntrack_hash_check_insert(struct nf_conn *ct); | 212 | extern void nf_conntrack_hash_insert(struct nf_conn *ct); |
184 | extern void nf_ct_delete_from_lists(struct nf_conn *ct); | 213 | extern void nf_ct_delete_from_lists(struct nf_conn *ct); |
185 | extern void nf_ct_dying_timeout(struct nf_conn *ct); | 214 | extern void nf_ct_insert_dying_list(struct nf_conn *ct); |
186 | 215 | ||
187 | extern void nf_conntrack_flush_report(struct net *net, u32 pid, int report); | 216 | extern void nf_conntrack_flush_report(struct net *net, u32 pid, int report); |
188 | 217 | ||
@@ -284,16 +313,20 @@ static inline bool nf_is_loopback_packet(const struct sk_buff *skb) | |||
284 | return skb->dev && skb->skb_iif && skb->dev->flags & IFF_LOOPBACK; | 313 | return skb->dev && skb->skb_iif && skb->dev->flags & IFF_LOOPBACK; |
285 | } | 314 | } |
286 | 315 | ||
287 | struct kernel_param; | ||
288 | |||
289 | 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); |
290 | extern unsigned int nf_conntrack_htable_size; | 317 | extern unsigned int nf_conntrack_htable_size; |
291 | extern unsigned int nf_conntrack_max; | 318 | extern unsigned int nf_conntrack_max; |
292 | extern unsigned int nf_conntrack_hash_rnd; | 319 | extern unsigned int nf_conntrack_hash_rnd; |
293 | void init_nf_conntrack_hash_rnd(void); | 320 | void init_nf_conntrack_hash_rnd(void); |
294 | 321 | ||
295 | #define NF_CT_STAT_INC(net, count) __this_cpu_inc((net)->ct.stat->count) | 322 | #define NF_CT_STAT_INC(net, count) \ |
296 | #define NF_CT_STAT_INC_ATOMIC(net, count) this_cpu_inc((net)->ct.stat->count) | 323 | __this_cpu_inc((net)->ct.stat->count) |
324 | #define NF_CT_STAT_INC_ATOMIC(net, count) \ | ||
325 | do { \ | ||
326 | local_bh_disable(); \ | ||
327 | __this_cpu_inc((net)->ct.stat->count); \ | ||
328 | local_bh_enable(); \ | ||
329 | } while (0) | ||
297 | 330 | ||
298 | #define MODULE_ALIAS_NFCT_HELPER(helper) \ | 331 | #define MODULE_ALIAS_NFCT_HELPER(helper) \ |
299 | MODULE_ALIAS("nfct-helper-" helper) | 332 | MODULE_ALIAS("nfct-helper-" helper) |
diff --git a/include/net/netfilter/nf_conntrack_acct.h b/include/net/netfilter/nf_conntrack_acct.h index 463ae8e1669..4e9c63a20db 100644 --- a/include/net/netfilter/nf_conntrack_acct.h +++ b/include/net/netfilter/nf_conntrack_acct.h | |||
@@ -15,8 +15,8 @@ | |||
15 | #include <net/netfilter/nf_conntrack_extend.h> | 15 | #include <net/netfilter/nf_conntrack_extend.h> |
16 | 16 | ||
17 | struct nf_conn_counter { | 17 | struct nf_conn_counter { |
18 | atomic64_t packets; | 18 | u_int64_t packets; |
19 | atomic64_t bytes; | 19 | u_int64_t bytes; |
20 | }; | 20 | }; |
21 | 21 | ||
22 | static inline | 22 | static inline |
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h index d8f5b9f5216..aced085132e 100644 --- a/include/net/netfilter/nf_conntrack_core.h +++ b/include/net/netfilter/nf_conntrack_core.h | |||
@@ -28,8 +28,8 @@ extern unsigned int nf_conntrack_in(struct net *net, | |||
28 | extern int nf_conntrack_init(struct net *net); | 28 | extern int nf_conntrack_init(struct net *net); |
29 | extern void nf_conntrack_cleanup(struct net *net); | 29 | extern void nf_conntrack_cleanup(struct net *net); |
30 | 30 | ||
31 | extern int nf_conntrack_proto_init(struct net *net); | 31 | extern int nf_conntrack_proto_init(void); |
32 | extern void nf_conntrack_proto_fini(struct net *net); | 32 | extern void nf_conntrack_proto_fini(void); |
33 | 33 | ||
34 | extern bool | 34 | extern bool |
35 | nf_ct_get_tuple(const struct sk_buff *skb, | 35 | nf_ct_get_tuple(const struct sk_buff *skb, |
diff --git a/include/net/netfilter/nf_conntrack_ecache.h b/include/net/netfilter/nf_conntrack_ecache.h index 5654d292efd..4283508b3e1 100644 --- a/include/net/netfilter/nf_conntrack_ecache.h +++ b/include/net/netfilter/nf_conntrack_ecache.h | |||
@@ -17,8 +17,7 @@ struct nf_conntrack_ecache { | |||
17 | unsigned long missed; /* missed events */ | 17 | unsigned long missed; /* missed events */ |
18 | u16 ctmask; /* bitmask of ct events to be delivered */ | 18 | u16 ctmask; /* bitmask of ct events to be delivered */ |
19 | u16 expmask; /* bitmask of expect events to be delivered */ | 19 | u16 expmask; /* bitmask of expect events to be delivered */ |
20 | u32 portid; /* netlink portid of destroyer */ | 20 | u32 pid; /* netlink pid of destroyer */ |
21 | struct timer_list timeout; | ||
22 | }; | 21 | }; |
23 | 22 | ||
24 | static inline struct nf_conntrack_ecache * | 23 | static inline struct nf_conntrack_ecache * |
@@ -60,7 +59,7 @@ nf_ct_ecache_ext_add(struct nf_conn *ct, u16 ctmask, u16 expmask, gfp_t gfp) | |||
60 | /* This structure is passed to event handler */ | 59 | /* This structure is passed to event handler */ |
61 | struct nf_ct_event { | 60 | struct nf_ct_event { |
62 | struct nf_conn *ct; | 61 | struct nf_conn *ct; |
63 | u32 portid; | 62 | u32 pid; |
64 | int report; | 63 | int report; |
65 | }; | 64 | }; |
66 | 65 | ||
@@ -68,18 +67,18 @@ struct nf_ct_event_notifier { | |||
68 | int (*fcn)(unsigned int events, struct nf_ct_event *item); | 67 | int (*fcn)(unsigned int events, struct nf_ct_event *item); |
69 | }; | 68 | }; |
70 | 69 | ||
71 | extern int nf_conntrack_register_notifier(struct net *net, struct nf_ct_event_notifier *nb); | 70 | extern struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb; |
72 | extern void nf_conntrack_unregister_notifier(struct net *net, struct nf_ct_event_notifier *nb); | 71 | extern int nf_conntrack_register_notifier(struct nf_ct_event_notifier *nb); |
72 | extern void nf_conntrack_unregister_notifier(struct nf_ct_event_notifier *nb); | ||
73 | 73 | ||
74 | extern void nf_ct_deliver_cached_events(struct nf_conn *ct); | 74 | extern void nf_ct_deliver_cached_events(struct nf_conn *ct); |
75 | 75 | ||
76 | static inline void | 76 | static inline void |
77 | nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct) | 77 | nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct) |
78 | { | 78 | { |
79 | struct net *net = nf_ct_net(ct); | ||
80 | struct nf_conntrack_ecache *e; | 79 | struct nf_conntrack_ecache *e; |
81 | 80 | ||
82 | if (!rcu_access_pointer(net->ct.nf_conntrack_event_cb)) | 81 | if (nf_conntrack_event_cb == NULL) |
83 | return; | 82 | return; |
84 | 83 | ||
85 | e = nf_ct_ecache_find(ct); | 84 | e = nf_ct_ecache_find(ct); |
@@ -92,16 +91,15 @@ nf_conntrack_event_cache(enum ip_conntrack_events event, struct nf_conn *ct) | |||
92 | static inline int | 91 | static inline int |
93 | nf_conntrack_eventmask_report(unsigned int eventmask, | 92 | nf_conntrack_eventmask_report(unsigned int eventmask, |
94 | struct nf_conn *ct, | 93 | struct nf_conn *ct, |
95 | u32 portid, | 94 | u32 pid, |
96 | int report) | 95 | int report) |
97 | { | 96 | { |
98 | int ret = 0; | 97 | int ret = 0; |
99 | struct net *net = nf_ct_net(ct); | ||
100 | struct nf_ct_event_notifier *notify; | 98 | struct nf_ct_event_notifier *notify; |
101 | struct nf_conntrack_ecache *e; | 99 | struct nf_conntrack_ecache *e; |
102 | 100 | ||
103 | rcu_read_lock(); | 101 | rcu_read_lock(); |
104 | notify = rcu_dereference(net->ct.nf_conntrack_event_cb); | 102 | notify = rcu_dereference(nf_conntrack_event_cb); |
105 | if (notify == NULL) | 103 | if (notify == NULL) |
106 | goto out_unlock; | 104 | goto out_unlock; |
107 | 105 | ||
@@ -112,11 +110,11 @@ nf_conntrack_eventmask_report(unsigned int eventmask, | |||
112 | if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) { | 110 | if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) { |
113 | struct nf_ct_event item = { | 111 | struct nf_ct_event item = { |
114 | .ct = ct, | 112 | .ct = ct, |
115 | .portid = e->portid ? e->portid : portid, | 113 | .pid = e->pid ? e->pid : pid, |
116 | .report = report | 114 | .report = report |
117 | }; | 115 | }; |
118 | /* This is a resent of a destroy event? If so, skip missed */ | 116 | /* This is a resent of a destroy event? If so, skip missed */ |
119 | unsigned long missed = e->portid ? 0 : e->missed; | 117 | unsigned long missed = e->pid ? 0 : e->missed; |
120 | 118 | ||
121 | if (!((eventmask | missed) & e->ctmask)) | 119 | if (!((eventmask | missed) & e->ctmask)) |
122 | goto out_unlock; | 120 | goto out_unlock; |
@@ -126,11 +124,11 @@ nf_conntrack_eventmask_report(unsigned int eventmask, | |||
126 | spin_lock_bh(&ct->lock); | 124 | spin_lock_bh(&ct->lock); |
127 | if (ret < 0) { | 125 | if (ret < 0) { |
128 | /* This is a destroy event that has been | 126 | /* This is a destroy event that has been |
129 | * triggered by a process, we store the PORTID | 127 | * triggered by a process, we store the PID |
130 | * to include it in the retransmission. */ | 128 | * to include it in the retransmission. */ |
131 | if (eventmask & (1 << IPCT_DESTROY) && | 129 | if (eventmask & (1 << IPCT_DESTROY) && |
132 | e->portid == 0 && portid != 0) | 130 | e->pid == 0 && pid != 0) |
133 | e->portid = portid; | 131 | e->pid = pid; |
134 | else | 132 | else |
135 | e->missed |= eventmask; | 133 | e->missed |= eventmask; |
136 | } else | 134 | } else |
@@ -145,9 +143,9 @@ out_unlock: | |||
145 | 143 | ||
146 | static inline int | 144 | static inline int |
147 | nf_conntrack_event_report(enum ip_conntrack_events event, struct nf_conn *ct, | 145 | nf_conntrack_event_report(enum ip_conntrack_events event, struct nf_conn *ct, |
148 | u32 portid, int report) | 146 | u32 pid, int report) |
149 | { | 147 | { |
150 | return nf_conntrack_eventmask_report(1 << event, ct, portid, report); | 148 | return nf_conntrack_eventmask_report(1 << event, ct, pid, report); |
151 | } | 149 | } |
152 | 150 | ||
153 | static inline int | 151 | static inline int |
@@ -158,7 +156,7 @@ nf_conntrack_event(enum ip_conntrack_events event, struct nf_conn *ct) | |||
158 | 156 | ||
159 | struct nf_exp_event { | 157 | struct nf_exp_event { |
160 | struct nf_conntrack_expect *exp; | 158 | struct nf_conntrack_expect *exp; |
161 | u32 portid; | 159 | u32 pid; |
162 | int report; | 160 | int report; |
163 | }; | 161 | }; |
164 | 162 | ||
@@ -166,21 +164,21 @@ struct nf_exp_event_notifier { | |||
166 | int (*fcn)(unsigned int events, struct nf_exp_event *item); | 164 | int (*fcn)(unsigned int events, struct nf_exp_event *item); |
167 | }; | 165 | }; |
168 | 166 | ||
169 | extern int nf_ct_expect_register_notifier(struct net *net, struct nf_exp_event_notifier *nb); | 167 | extern struct nf_exp_event_notifier __rcu *nf_expect_event_cb; |
170 | extern void nf_ct_expect_unregister_notifier(struct net *net, struct nf_exp_event_notifier *nb); | 168 | extern int nf_ct_expect_register_notifier(struct nf_exp_event_notifier *nb); |
169 | extern void nf_ct_expect_unregister_notifier(struct nf_exp_event_notifier *nb); | ||
171 | 170 | ||
172 | static inline void | 171 | static inline void |
173 | nf_ct_expect_event_report(enum ip_conntrack_expect_events event, | 172 | nf_ct_expect_event_report(enum ip_conntrack_expect_events event, |
174 | struct nf_conntrack_expect *exp, | 173 | struct nf_conntrack_expect *exp, |
175 | u32 portid, | 174 | u32 pid, |
176 | int report) | 175 | int report) |
177 | { | 176 | { |
178 | struct net *net = nf_ct_exp_net(exp); | ||
179 | struct nf_exp_event_notifier *notify; | 177 | struct nf_exp_event_notifier *notify; |
180 | struct nf_conntrack_ecache *e; | 178 | struct nf_conntrack_ecache *e; |
181 | 179 | ||
182 | rcu_read_lock(); | 180 | rcu_read_lock(); |
183 | notify = rcu_dereference(net->ct.nf_expect_event_cb); | 181 | notify = rcu_dereference(nf_expect_event_cb); |
184 | if (notify == NULL) | 182 | if (notify == NULL) |
185 | goto out_unlock; | 183 | goto out_unlock; |
186 | 184 | ||
@@ -191,7 +189,7 @@ nf_ct_expect_event_report(enum ip_conntrack_expect_events event, | |||
191 | if (e->expmask & (1 << event)) { | 189 | if (e->expmask & (1 << event)) { |
192 | struct nf_exp_event item = { | 190 | struct nf_exp_event item = { |
193 | .exp = exp, | 191 | .exp = exp, |
194 | .portid = portid, | 192 | .pid = pid, |
195 | .report = report | 193 | .report = report |
196 | }; | 194 | }; |
197 | notify->fcn(1 << event, &item); | 195 | notify->fcn(1 << event, &item); |
@@ -216,20 +214,20 @@ static inline void nf_conntrack_event_cache(enum ip_conntrack_events event, | |||
216 | struct nf_conn *ct) {} | 214 | struct nf_conn *ct) {} |
217 | static inline int nf_conntrack_eventmask_report(unsigned int eventmask, | 215 | static inline int nf_conntrack_eventmask_report(unsigned int eventmask, |
218 | struct nf_conn *ct, | 216 | struct nf_conn *ct, |
219 | u32 portid, | 217 | u32 pid, |
220 | int report) { return 0; } | 218 | int report) { return 0; } |
221 | static inline int nf_conntrack_event(enum ip_conntrack_events event, | 219 | static inline int nf_conntrack_event(enum ip_conntrack_events event, |
222 | struct nf_conn *ct) { return 0; } | 220 | struct nf_conn *ct) { return 0; } |
223 | static inline int nf_conntrack_event_report(enum ip_conntrack_events event, | 221 | static inline int nf_conntrack_event_report(enum ip_conntrack_events event, |
224 | struct nf_conn *ct, | 222 | struct nf_conn *ct, |
225 | u32 portid, | 223 | u32 pid, |
226 | int report) { return 0; } | 224 | int report) { return 0; } |
227 | static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {} | 225 | static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {} |
228 | static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event, | 226 | static inline void nf_ct_expect_event(enum ip_conntrack_expect_events event, |
229 | struct nf_conntrack_expect *exp) {} | 227 | struct nf_conntrack_expect *exp) {} |
230 | static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e, | 228 | static inline void nf_ct_expect_event_report(enum ip_conntrack_expect_events e, |
231 | struct nf_conntrack_expect *exp, | 229 | struct nf_conntrack_expect *exp, |
232 | u32 portid, | 230 | u32 pid, |
233 | int report) {} | 231 | int report) {} |
234 | 232 | ||
235 | static inline int nf_conntrack_ecache_init(struct net *net) | 233 | static inline int nf_conntrack_ecache_init(struct net *net) |
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h index cc13f377a70..0f8a8c58753 100644 --- a/include/net/netfilter/nf_conntrack_expect.h +++ b/include/net/netfilter/nf_conntrack_expect.h | |||
@@ -43,7 +43,7 @@ struct nf_conntrack_expect { | |||
43 | unsigned int class; | 43 | unsigned int class; |
44 | 44 | ||
45 | #ifdef CONFIG_NF_NAT_NEEDED | 45 | #ifdef CONFIG_NF_NAT_NEEDED |
46 | union nf_inet_addr saved_addr; | 46 | __be32 saved_ip; |
47 | /* This is the original per-proto part, used to map the | 47 | /* This is the original per-proto part, used to map the |
48 | * expected connection the way the recipient expects. */ | 48 | * expected connection the way the recipient expects. */ |
49 | union nf_conntrack_man_proto saved_proto; | 49 | union nf_conntrack_man_proto saved_proto; |
@@ -59,12 +59,10 @@ static inline struct net *nf_ct_exp_net(struct nf_conntrack_expect *exp) | |||
59 | return nf_ct_net(exp->master); | 59 | return nf_ct_net(exp->master); |
60 | } | 60 | } |
61 | 61 | ||
62 | #define NF_CT_EXP_POLICY_NAME_LEN 16 | ||
63 | |||
64 | struct nf_conntrack_expect_policy { | 62 | struct nf_conntrack_expect_policy { |
65 | unsigned int max_expected; | 63 | unsigned int max_expected; |
66 | unsigned int timeout; | 64 | unsigned int timeout; |
67 | char name[NF_CT_EXP_POLICY_NAME_LEN]; | 65 | const char *name; |
68 | }; | 66 | }; |
69 | 67 | ||
70 | #define NF_CT_EXPECT_CLASS_DEFAULT 0 | 68 | #define NF_CT_EXPECT_CLASS_DEFAULT 0 |
@@ -93,6 +91,7 @@ static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp) | |||
93 | 91 | ||
94 | void nf_ct_remove_expectations(struct nf_conn *ct); | 92 | void nf_ct_remove_expectations(struct nf_conn *ct); |
95 | 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); | ||
96 | 95 | ||
97 | /* Allocate space for an expectation: this is mandatory before calling | 96 | /* Allocate space for an expectation: this is mandatory before calling |
98 | 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 8b4d1fc2909..2dcf31703ac 100644 --- a/include/net/netfilter/nf_conntrack_extend.h +++ b/include/net/netfilter/nf_conntrack_extend.h | |||
@@ -20,9 +20,6 @@ enum nf_ct_ext_id { | |||
20 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP | 20 | #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP |
21 | NF_CT_EXT_TSTAMP, | 21 | NF_CT_EXT_TSTAMP, |
22 | #endif | 22 | #endif |
23 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT | ||
24 | NF_CT_EXT_TIMEOUT, | ||
25 | #endif | ||
26 | NF_CT_EXT_NUM, | 23 | NF_CT_EXT_NUM, |
27 | }; | 24 | }; |
28 | 25 | ||
@@ -32,7 +29,6 @@ enum nf_ct_ext_id { | |||
32 | #define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache | 29 | #define NF_CT_EXT_ECACHE_TYPE struct nf_conntrack_ecache |
33 | #define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone | 30 | #define NF_CT_EXT_ZONE_TYPE struct nf_conntrack_zone |
34 | #define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp | 31 | #define NF_CT_EXT_TSTAMP_TYPE struct nf_conn_tstamp |
35 | #define NF_CT_EXT_TIMEOUT_TYPE struct nf_conn_timeout | ||
36 | 32 | ||
37 | /* Extensions: optional stuff which isn't permanently in struct. */ | 33 | /* Extensions: optional stuff which isn't permanently in struct. */ |
38 | struct nf_ct_ext { | 34 | struct nf_ct_ext { |
@@ -80,13 +76,10 @@ static inline void nf_ct_ext_free(struct nf_conn *ct) | |||
80 | } | 76 | } |
81 | 77 | ||
82 | /* Add this type, returns pointer to data or NULL. */ | 78 | /* Add this type, returns pointer to data or NULL. */ |
83 | void *__nf_ct_ext_add_length(struct nf_conn *ct, enum nf_ct_ext_id id, | 79 | void * |
84 | size_t var_alloc_len, gfp_t gfp); | 80 | __nf_ct_ext_add(struct nf_conn *ct, enum nf_ct_ext_id id, gfp_t gfp); |
85 | |||
86 | #define nf_ct_ext_add(ct, id, gfp) \ | 81 | #define nf_ct_ext_add(ct, id, gfp) \ |
87 | ((id##_TYPE *)__nf_ct_ext_add_length((ct), (id), 0, (gfp))) | 82 | ((id##_TYPE *)__nf_ct_ext_add((ct), (id), (gfp))) |
88 | #define nf_ct_ext_add_length(ct, id, len, gfp) \ | ||
89 | ((id##_TYPE *)__nf_ct_ext_add_length((ct), (id), (len), (gfp))) | ||
90 | 83 | ||
91 | #define NF_CT_EXT_F_PREALLOC 0x0001 | 84 | #define NF_CT_EXT_F_PREALLOC 0x0001 |
92 | 85 | ||
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h index 9aad956d100..f1c1311adc2 100644 --- a/include/net/netfilter/nf_conntrack_helper.h +++ b/include/net/netfilter/nf_conntrack_helper.h | |||
@@ -11,27 +11,18 @@ | |||
11 | #define _NF_CONNTRACK_HELPER_H | 11 | #define _NF_CONNTRACK_HELPER_H |
12 | #include <net/netfilter/nf_conntrack.h> | 12 | #include <net/netfilter/nf_conntrack.h> |
13 | #include <net/netfilter/nf_conntrack_extend.h> | 13 | #include <net/netfilter/nf_conntrack_extend.h> |
14 | #include <net/netfilter/nf_conntrack_expect.h> | ||
15 | 14 | ||
16 | struct module; | 15 | struct module; |
17 | 16 | ||
18 | enum nf_ct_helper_flags { | ||
19 | NF_CT_HELPER_F_USERSPACE = (1 << 0), | ||
20 | NF_CT_HELPER_F_CONFIGURED = (1 << 1), | ||
21 | }; | ||
22 | |||
23 | #define NF_CT_HELPER_NAME_LEN 16 | 17 | #define NF_CT_HELPER_NAME_LEN 16 |
24 | 18 | ||
25 | struct nf_conntrack_helper { | 19 | struct nf_conntrack_helper { |
26 | struct hlist_node hnode; /* Internal use. */ | 20 | struct hlist_node hnode; /* Internal use. */ |
27 | 21 | ||
28 | char name[NF_CT_HELPER_NAME_LEN]; /* name of the module */ | 22 | const char *name; /* name of the module */ |
29 | struct module *me; /* pointer to self */ | 23 | struct module *me; /* pointer to self */ |
30 | const struct nf_conntrack_expect_policy *expect_policy; | 24 | const struct nf_conntrack_expect_policy *expect_policy; |
31 | 25 | ||
32 | /* length of internal data, ie. sizeof(struct nf_ct_*_master) */ | ||
33 | size_t data_len; | ||
34 | |||
35 | /* Tuple of things we will help (compared against server response) */ | 26 | /* Tuple of things we will help (compared against server response) */ |
36 | struct nf_conntrack_tuple tuple; | 27 | struct nf_conntrack_tuple tuple; |
37 | 28 | ||
@@ -44,12 +35,8 @@ struct nf_conntrack_helper { | |||
44 | 35 | ||
45 | void (*destroy)(struct nf_conn *ct); | 36 | void (*destroy)(struct nf_conn *ct); |
46 | 37 | ||
47 | int (*from_nlattr)(struct nlattr *attr, struct nf_conn *ct); | ||
48 | int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct); | 38 | int (*to_nlattr)(struct sk_buff *skb, const struct nf_conn *ct); |
49 | unsigned int expect_class_max; | 39 | unsigned int expect_class_max; |
50 | |||
51 | unsigned int flags; | ||
52 | unsigned int queue_num; /* For user-space helpers. */ | ||
53 | }; | 40 | }; |
54 | 41 | ||
55 | extern struct nf_conntrack_helper * | 42 | extern struct nf_conntrack_helper * |
@@ -61,7 +48,7 @@ nf_conntrack_helper_try_module_get(const char *name, u16 l3num, u8 protonum); | |||
61 | extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); | 48 | extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); |
62 | extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *); | 49 | extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *); |
63 | 50 | ||
64 | extern struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, struct nf_conntrack_helper *helper, gfp_t gfp); | 51 | extern struct nf_conn_help *nf_ct_helper_ext_add(struct nf_conn *ct, gfp_t gfp); |
65 | 52 | ||
66 | extern int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl, | 53 | extern int __nf_ct_try_assign_helper(struct nf_conn *ct, struct nf_conn *tmpl, |
67 | gfp_t flags); | 54 | gfp_t flags); |
@@ -73,17 +60,8 @@ static inline struct nf_conn_help *nfct_help(const struct nf_conn *ct) | |||
73 | return nf_ct_ext_find(ct, NF_CT_EXT_HELPER); | 60 | return nf_ct_ext_find(ct, NF_CT_EXT_HELPER); |
74 | } | 61 | } |
75 | 62 | ||
76 | static inline void *nfct_help_data(const struct nf_conn *ct) | 63 | extern int nf_conntrack_helper_init(void); |
77 | { | 64 | extern void nf_conntrack_helper_fini(void); |
78 | struct nf_conn_help *help; | ||
79 | |||
80 | help = nf_ct_ext_find(ct, NF_CT_EXT_HELPER); | ||
81 | |||
82 | return (void *)help->data; | ||
83 | } | ||
84 | |||
85 | extern int nf_conntrack_helper_init(struct net *net); | ||
86 | extern void nf_conntrack_helper_fini(struct net *net); | ||
87 | 65 | ||
88 | extern int nf_conntrack_broadcast_help(struct sk_buff *skb, | 66 | extern int nf_conntrack_broadcast_help(struct sk_buff *skb, |
89 | unsigned int protoff, | 67 | unsigned int protoff, |
@@ -91,20 +69,4 @@ extern int nf_conntrack_broadcast_help(struct sk_buff *skb, | |||
91 | enum ip_conntrack_info ctinfo, | 69 | enum ip_conntrack_info ctinfo, |
92 | unsigned int timeout); | 70 | unsigned int timeout); |
93 | 71 | ||
94 | struct nf_ct_helper_expectfn { | ||
95 | struct list_head head; | ||
96 | const char *name; | ||
97 | void (*expectfn)(struct nf_conn *ct, struct nf_conntrack_expect *exp); | ||
98 | }; | ||
99 | |||
100 | void nf_ct_helper_expectfn_register(struct nf_ct_helper_expectfn *n); | ||
101 | void nf_ct_helper_expectfn_unregister(struct nf_ct_helper_expectfn *n); | ||
102 | struct nf_ct_helper_expectfn * | ||
103 | nf_ct_helper_expectfn_find_by_name(const char *name); | ||
104 | struct nf_ct_helper_expectfn * | ||
105 | nf_ct_helper_expectfn_find_by_symbol(const void *symbol); | ||
106 | |||
107 | extern struct hlist_head *nf_ct_helper_hash; | ||
108 | extern unsigned int nf_ct_helper_hsize; | ||
109 | |||
110 | #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 6f7c13f4ac0..e8010f445ae 100644 --- a/include/net/netfilter/nf_conntrack_l3proto.h +++ b/include/net/netfilter/nf_conntrack_l3proto.h | |||
@@ -64,12 +64,11 @@ struct nf_conntrack_l3proto { | |||
64 | size_t nla_size; | 64 | size_t nla_size; |
65 | 65 | ||
66 | #ifdef CONFIG_SYSCTL | 66 | #ifdef CONFIG_SYSCTL |
67 | const char *ctl_table_path; | 67 | struct ctl_table_header *ctl_table_header; |
68 | struct ctl_path *ctl_table_path; | ||
69 | struct ctl_table *ctl_table; | ||
68 | #endif /* CONFIG_SYSCTL */ | 70 | #endif /* CONFIG_SYSCTL */ |
69 | 71 | ||
70 | /* Init l3proto pernet data */ | ||
71 | int (*init_net)(struct net *net); | ||
72 | |||
73 | /* Module (if any) which this is connected to. */ | 72 | /* Module (if any) which this is connected to. */ |
74 | struct module *me; | 73 | struct module *me; |
75 | }; | 74 | }; |
@@ -77,10 +76,8 @@ struct nf_conntrack_l3proto { | |||
77 | extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX]; | 76 | extern struct nf_conntrack_l3proto __rcu *nf_ct_l3protos[AF_MAX]; |
78 | 77 | ||
79 | /* Protocol registration. */ | 78 | /* Protocol registration. */ |
80 | extern int nf_conntrack_l3proto_register(struct net *net, | 79 | extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); |
81 | struct nf_conntrack_l3proto *proto); | 80 | extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto); |
82 | extern void nf_conntrack_l3proto_unregister(struct net *net, | ||
83 | struct nf_conntrack_l3proto *proto); | ||
84 | extern struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto); | 81 | extern struct nf_conntrack_l3proto *nf_ct_l3proto_find_get(u_int16_t l3proto); |
85 | extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p); | 82 | extern void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p); |
86 | 83 | ||
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h index c3be4aef6bf..e3d3ee3c06a 100644 --- a/include/net/netfilter/nf_conntrack_l4proto.h +++ b/include/net/netfilter/nf_conntrack_l4proto.h | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/netlink.h> | 12 | #include <linux/netlink.h> |
13 | #include <net/netlink.h> | 13 | #include <net/netlink.h> |
14 | #include <net/netfilter/nf_conntrack.h> | 14 | #include <net/netfilter/nf_conntrack.h> |
15 | #include <net/netns/generic.h> | ||
16 | 15 | ||
17 | struct seq_file; | 16 | struct seq_file; |
18 | 17 | ||
@@ -40,13 +39,12 @@ struct nf_conntrack_l4proto { | |||
40 | unsigned int dataoff, | 39 | unsigned int dataoff, |
41 | enum ip_conntrack_info ctinfo, | 40 | enum ip_conntrack_info ctinfo, |
42 | u_int8_t pf, | 41 | u_int8_t pf, |
43 | unsigned int hooknum, | 42 | unsigned int hooknum); |
44 | unsigned int *timeouts); | ||
45 | 43 | ||
46 | /* Called when a new connection for this protocol found; | 44 | /* Called when a new connection for this protocol found; |
47 | * returns TRUE if it's OK. If so, packet() called next. */ | 45 | * returns TRUE if it's OK. If so, packet() called next. */ |
48 | bool (*new)(struct nf_conn *ct, const struct sk_buff *skb, | 46 | bool (*new)(struct nf_conn *ct, const struct sk_buff *skb, |
49 | unsigned int dataoff, unsigned int *timeouts); | 47 | unsigned int dataoff); |
50 | 48 | ||
51 | /* Called when a conntrack entry is destroyed */ | 49 | /* Called when a conntrack entry is destroyed */ |
52 | void (*destroy)(struct nf_conn *ct); | 50 | void (*destroy)(struct nf_conn *ct); |
@@ -62,9 +60,6 @@ struct nf_conntrack_l4proto { | |||
62 | /* Print out the private part of the conntrack. */ | 60 | /* Print out the private part of the conntrack. */ |
63 | int (*print_conntrack)(struct seq_file *s, struct nf_conn *); | 61 | int (*print_conntrack)(struct seq_file *s, struct nf_conn *); |
64 | 62 | ||
65 | /* Return the array of timeouts for this protocol. */ | ||
66 | unsigned int *(*get_timeouts)(struct net *net); | ||
67 | |||
68 | /* convert protoinfo to nfnetink attributes */ | 63 | /* convert protoinfo to nfnetink attributes */ |
69 | int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla, | 64 | int (*to_nlattr)(struct sk_buff *skb, struct nlattr *nla, |
70 | struct nf_conn *ct); | 65 | struct nf_conn *ct); |
@@ -84,24 +79,15 @@ struct nf_conntrack_l4proto { | |||
84 | 79 | ||
85 | size_t nla_size; | 80 | size_t nla_size; |
86 | 81 | ||
87 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) | 82 | #ifdef CONFIG_SYSCTL |
88 | struct { | 83 | struct ctl_table_header **ctl_table_header; |
89 | size_t obj_size; | 84 | struct ctl_table *ctl_table; |
90 | int (*nlattr_to_obj)(struct nlattr *tb[], | 85 | unsigned int *ctl_table_users; |
91 | struct net *net, void *data); | 86 | #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT |
92 | int (*obj_to_nlattr)(struct sk_buff *skb, const void *data); | 87 | struct ctl_table_header *ctl_compat_table_header; |
93 | 88 | struct ctl_table *ctl_compat_table; | |
94 | unsigned int nlattr_max; | 89 | #endif |
95 | const struct nla_policy *nla_policy; | ||
96 | } ctnl_timeout; | ||
97 | #endif | 90 | #endif |
98 | int *net_id; | ||
99 | /* Init l4proto pernet data */ | ||
100 | int (*init_net)(struct net *net, u_int16_t proto); | ||
101 | |||
102 | /* Return the per-net protocol part. */ | ||
103 | struct nf_proto_net *(*get_net_proto)(struct net *net); | ||
104 | |||
105 | /* Protocol name */ | 91 | /* Protocol name */ |
106 | const char *name; | 92 | const char *name; |
107 | 93 | ||
@@ -117,23 +103,9 @@ extern struct nf_conntrack_l4proto nf_conntrack_l4proto_generic; | |||
117 | extern struct nf_conntrack_l4proto * | 103 | extern struct nf_conntrack_l4proto * |
118 | __nf_ct_l4proto_find(u_int16_t l3proto, u_int8_t l4proto); | 104 | __nf_ct_l4proto_find(u_int16_t l3proto, u_int8_t l4proto); |
119 | 105 | ||
120 | extern struct nf_conntrack_l4proto * | ||
121 | nf_ct_l4proto_find_get(u_int16_t l3proto, u_int8_t l4proto); | ||
122 | extern void nf_ct_l4proto_put(struct nf_conntrack_l4proto *p); | ||
123 | |||
124 | /* Protocol registration. */ | 106 | /* Protocol registration. */ |
125 | extern int nf_conntrack_l4proto_register(struct net *net, | 107 | extern int nf_conntrack_l4proto_register(struct nf_conntrack_l4proto *proto); |
126 | struct nf_conntrack_l4proto *proto); | 108 | extern void nf_conntrack_l4proto_unregister(struct nf_conntrack_l4proto *proto); |
127 | extern void nf_conntrack_l4proto_unregister(struct net *net, | ||
128 | struct nf_conntrack_l4proto *proto); | ||
129 | |||
130 | static inline void nf_ct_kfree_compat_sysctl_table(struct nf_proto_net *pn) | ||
131 | { | ||
132 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) | ||
133 | kfree(pn->ctl_compat_table); | ||
134 | pn->ctl_compat_table = NULL; | ||
135 | #endif | ||
136 | } | ||
137 | 109 | ||
138 | /* Generic netlink helpers */ | 110 | /* Generic netlink helpers */ |
139 | extern int nf_ct_port_tuple_to_nlattr(struct sk_buff *skb, | 111 | extern int nf_ct_port_tuple_to_nlattr(struct sk_buff *skb, |
diff --git a/include/net/netfilter/nf_conntrack_timeout.h b/include/net/netfilter/nf_conntrack_timeout.h deleted file mode 100644 index e41e472d08f..00000000000 --- a/include/net/netfilter/nf_conntrack_timeout.h +++ /dev/null | |||
@@ -1,98 +0,0 @@ | |||
1 | #ifndef _NF_CONNTRACK_TIMEOUT_H | ||
2 | #define _NF_CONNTRACK_TIMEOUT_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 | #define CTNL_TIMEOUT_NAME_MAX 32 | ||
11 | |||
12 | struct ctnl_timeout { | ||
13 | struct list_head head; | ||
14 | struct rcu_head rcu_head; | ||
15 | atomic_t refcnt; | ||
16 | char name[CTNL_TIMEOUT_NAME_MAX]; | ||
17 | __u16 l3num; | ||
18 | struct nf_conntrack_l4proto *l4proto; | ||
19 | char data[0]; | ||
20 | }; | ||
21 | |||
22 | struct nf_conn_timeout { | ||
23 | struct ctnl_timeout *timeout; | ||
24 | }; | ||
25 | |||
26 | #define NF_CT_TIMEOUT_EXT_DATA(__t) (unsigned int *) &((__t)->timeout->data) | ||
27 | |||
28 | static inline | ||
29 | struct nf_conn_timeout *nf_ct_timeout_find(const struct nf_conn *ct) | ||
30 | { | ||
31 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT | ||
32 | return nf_ct_ext_find(ct, NF_CT_EXT_TIMEOUT); | ||
33 | #else | ||
34 | return NULL; | ||
35 | #endif | ||
36 | } | ||
37 | |||
38 | static inline | ||
39 | struct nf_conn_timeout *nf_ct_timeout_ext_add(struct nf_conn *ct, | ||
40 | struct ctnl_timeout *timeout, | ||
41 | gfp_t gfp) | ||
42 | { | ||
43 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT | ||
44 | struct nf_conn_timeout *timeout_ext; | ||
45 | |||
46 | timeout_ext = nf_ct_ext_add(ct, NF_CT_EXT_TIMEOUT, gfp); | ||
47 | if (timeout_ext == NULL) | ||
48 | return NULL; | ||
49 | |||
50 | timeout_ext->timeout = timeout; | ||
51 | |||
52 | return timeout_ext; | ||
53 | #else | ||
54 | return NULL; | ||
55 | #endif | ||
56 | }; | ||
57 | |||
58 | static inline unsigned int * | ||
59 | nf_ct_timeout_lookup(struct net *net, struct nf_conn *ct, | ||
60 | struct nf_conntrack_l4proto *l4proto) | ||
61 | { | ||
62 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT | ||
63 | struct nf_conn_timeout *timeout_ext; | ||
64 | unsigned int *timeouts; | ||
65 | |||
66 | timeout_ext = nf_ct_timeout_find(ct); | ||
67 | if (timeout_ext) | ||
68 | timeouts = NF_CT_TIMEOUT_EXT_DATA(timeout_ext); | ||
69 | else | ||
70 | timeouts = l4proto->get_timeouts(net); | ||
71 | |||
72 | return timeouts; | ||
73 | #else | ||
74 | return l4proto->get_timeouts(net); | ||
75 | #endif | ||
76 | } | ||
77 | |||
78 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT | ||
79 | extern int nf_conntrack_timeout_init(struct net *net); | ||
80 | extern void nf_conntrack_timeout_fini(struct net *net); | ||
81 | #else | ||
82 | static inline int nf_conntrack_timeout_init(struct net *net) | ||
83 | { | ||
84 | return 0; | ||
85 | } | ||
86 | |||
87 | static inline void nf_conntrack_timeout_fini(struct net *net) | ||
88 | { | ||
89 | return; | ||
90 | } | ||
91 | #endif /* CONFIG_NF_CONNTRACK_TIMEOUT */ | ||
92 | |||
93 | #ifdef CONFIG_NF_CONNTRACK_TIMEOUT | ||
94 | extern struct ctnl_timeout *(*nf_ct_timeout_find_get_hook)(const char *name); | ||
95 | extern void (*nf_ct_timeout_put_hook)(struct ctnl_timeout *timeout); | ||
96 | #endif | ||
97 | |||
98 | #endif /* _NF_CONNTRACK_TIMEOUT_H */ | ||
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h index aea3f8221be..7ca6bdd5bae 100644 --- a/include/net/netfilter/nf_conntrack_tuple.h +++ b/include/net/netfilter/nf_conntrack_tuple.h | |||
@@ -24,6 +24,32 @@ | |||
24 | 24 | ||
25 | #define NF_CT_TUPLE_L3SIZE ARRAY_SIZE(((union nf_inet_addr *)NULL)->all) | 25 | #define NF_CT_TUPLE_L3SIZE ARRAY_SIZE(((union nf_inet_addr *)NULL)->all) |
26 | 26 | ||
27 | /* The protocol-specific manipulable parts of the tuple: always in | ||
28 | network order! */ | ||
29 | union nf_conntrack_man_proto { | ||
30 | /* Add other protocols here. */ | ||
31 | __be16 all; | ||
32 | |||
33 | struct { | ||
34 | __be16 port; | ||
35 | } tcp; | ||
36 | struct { | ||
37 | __be16 port; | ||
38 | } udp; | ||
39 | struct { | ||
40 | __be16 id; | ||
41 | } icmp; | ||
42 | struct { | ||
43 | __be16 port; | ||
44 | } dccp; | ||
45 | struct { | ||
46 | __be16 port; | ||
47 | } sctp; | ||
48 | struct { | ||
49 | __be16 key; /* GRE key is 32bit, PPtP only uses 16bit */ | ||
50 | } gre; | ||
51 | }; | ||
52 | |||
27 | /* The manipulable part of the tuple. */ | 53 | /* The manipulable part of the tuple. */ |
28 | struct nf_conntrack_man { | 54 | struct nf_conntrack_man { |
29 | union nf_inet_addr u3; | 55 | union nf_inet_addr u3; |
diff --git a/include/net/netfilter/nf_log.h b/include/net/netfilter/nf_log.h index e991bd0a27a..920997f1aff 100644 --- a/include/net/netfilter/nf_log.h +++ b/include/net/netfilter/nf_log.h | |||
@@ -53,13 +53,12 @@ int nf_log_bind_pf(u_int8_t pf, const struct nf_logger *logger); | |||
53 | void nf_log_unbind_pf(u_int8_t pf); | 53 | void nf_log_unbind_pf(u_int8_t pf); |
54 | 54 | ||
55 | /* Calls the registered backend logging function */ | 55 | /* Calls the registered backend logging function */ |
56 | __printf(7, 8) | ||
57 | void nf_log_packet(u_int8_t pf, | 56 | void nf_log_packet(u_int8_t pf, |
58 | unsigned int hooknum, | 57 | unsigned int hooknum, |
59 | const struct sk_buff *skb, | 58 | const struct sk_buff *skb, |
60 | const struct net_device *in, | 59 | const struct net_device *in, |
61 | const struct net_device *out, | 60 | const struct net_device *out, |
62 | const struct nf_loginfo *li, | 61 | const struct nf_loginfo *li, |
63 | const char *fmt, ...); | 62 | const char *fmt, ...) __attribute__ ((format(printf,7,8))); |
64 | 63 | ||
65 | #endif /* _NF_LOG_H */ | 64 | #endif /* _NF_LOG_H */ |
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h index ad14a799fd2..0346b007086 100644 --- a/include/net/netfilter/nf_nat.h +++ b/include/net/netfilter/nf_nat.h | |||
@@ -1,18 +1,24 @@ | |||
1 | #ifndef _NF_NAT_H | 1 | #ifndef _NF_NAT_H |
2 | #define _NF_NAT_H | 2 | #define _NF_NAT_H |
3 | #include <linux/netfilter_ipv4.h> | 3 | #include <linux/netfilter_ipv4.h> |
4 | #include <linux/netfilter/nf_nat.h> | ||
5 | #include <net/netfilter/nf_conntrack_tuple.h> | 4 | #include <net/netfilter/nf_conntrack_tuple.h> |
6 | 5 | ||
6 | #define NF_NAT_MAPPING_TYPE_MAX_NAMELEN 16 | ||
7 | |||
7 | enum nf_nat_manip_type { | 8 | enum nf_nat_manip_type { |
8 | NF_NAT_MANIP_SRC, | 9 | IP_NAT_MANIP_SRC, |
9 | NF_NAT_MANIP_DST | 10 | IP_NAT_MANIP_DST |
10 | }; | 11 | }; |
11 | 12 | ||
12 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ | 13 | /* SRC manip occurs POST_ROUTING or LOCAL_IN */ |
13 | #define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \ | 14 | #define HOOK2MANIP(hooknum) ((hooknum) != NF_INET_POST_ROUTING && \ |
14 | (hooknum) != NF_INET_LOCAL_IN) | 15 | (hooknum) != NF_INET_LOCAL_IN) |
15 | 16 | ||
17 | #define IP_NAT_RANGE_MAP_IPS 1 | ||
18 | #define IP_NAT_RANGE_PROTO_SPECIFIED 2 | ||
19 | #define IP_NAT_RANGE_PROTO_RANDOM 4 | ||
20 | #define IP_NAT_RANGE_PERSISTENT 8 | ||
21 | |||
16 | /* NAT sequence number modifications */ | 22 | /* NAT sequence number modifications */ |
17 | struct nf_nat_seq { | 23 | struct nf_nat_seq { |
18 | /* position of the last TCP sequence number modification (if any) */ | 24 | /* position of the last TCP sequence number modification (if any) */ |
@@ -22,6 +28,26 @@ struct nf_nat_seq { | |||
22 | int16_t offset_before, offset_after; | 28 | int16_t offset_before, offset_after; |
23 | }; | 29 | }; |
24 | 30 | ||
31 | /* Single range specification. */ | ||
32 | struct nf_nat_range { | ||
33 | /* Set to OR of flags above. */ | ||
34 | unsigned int flags; | ||
35 | |||
36 | /* Inclusive: network order. */ | ||
37 | __be32 min_ip, max_ip; | ||
38 | |||
39 | /* Inclusive: network order */ | ||
40 | union nf_conntrack_man_proto min, max; | ||
41 | }; | ||
42 | |||
43 | /* For backwards compat: don't use in modern code. */ | ||
44 | struct nf_nat_multi_range_compat { | ||
45 | unsigned int rangesize; /* Must be 1. */ | ||
46 | |||
47 | /* hangs off end. */ | ||
48 | struct nf_nat_range range[1]; | ||
49 | }; | ||
50 | |||
25 | #include <linux/list.h> | 51 | #include <linux/list.h> |
26 | #include <linux/netfilter/nf_conntrack_pptp.h> | 52 | #include <linux/netfilter/nf_conntrack_pptp.h> |
27 | #include <net/netfilter/nf_conntrack_extend.h> | 53 | #include <net/netfilter/nf_conntrack_extend.h> |
@@ -43,9 +69,7 @@ struct nf_conn_nat { | |||
43 | struct nf_conn *ct; | 69 | struct nf_conn *ct; |
44 | union nf_conntrack_nat_help help; | 70 | union nf_conntrack_nat_help help; |
45 | #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ | 71 | #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ |
46 | defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) || \ | 72 | defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) |
47 | defined(CONFIG_IP6_NF_TARGET_MASQUERADE) || \ | ||
48 | defined(CONFIG_IP6_NF_TARGET_MASQUERADE_MODULE) | ||
49 | int masq_index; | 73 | int masq_index; |
50 | #endif | 74 | #endif |
51 | }; | 75 | }; |
@@ -68,19 +92,4 @@ static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct) | |||
68 | #endif | 92 | #endif |
69 | } | 93 | } |
70 | 94 | ||
71 | static inline bool nf_nat_oif_changed(unsigned int hooknum, | ||
72 | enum ip_conntrack_info ctinfo, | ||
73 | struct nf_conn_nat *nat, | ||
74 | const struct net_device *out) | ||
75 | { | ||
76 | #if IS_ENABLED(CONFIG_IP_NF_TARGET_MASQUERADE) || \ | ||
77 | IS_ENABLED(CONFIG_IP6_NF_TARGET_MASQUERADE) | ||
78 | return nat->masq_index && hooknum == NF_INET_POST_ROUTING && | ||
79 | CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL && | ||
80 | nat->masq_index != out->ifindex; | ||
81 | #else | ||
82 | return false; | ||
83 | #endif | ||
84 | } | ||
85 | |||
86 | #endif | 95 | #endif |
diff --git a/include/net/netfilter/nf_nat_core.h b/include/net/netfilter/nf_nat_core.h index 972e1e47ec7..3dc7b98effe 100644 --- a/include/net/netfilter/nf_nat_core.h +++ b/include/net/netfilter/nf_nat_core.h | |||
@@ -12,12 +12,15 @@ extern unsigned int nf_nat_packet(struct nf_conn *ct, | |||
12 | unsigned int hooknum, | 12 | unsigned int hooknum, |
13 | struct sk_buff *skb); | 13 | struct sk_buff *skb); |
14 | 14 | ||
15 | extern int nf_xfrm_me_harder(struct sk_buff *skb, unsigned int family); | 15 | extern int nf_nat_icmp_reply_translation(struct nf_conn *ct, |
16 | enum ip_conntrack_info ctinfo, | ||
17 | unsigned int hooknum, | ||
18 | struct sk_buff *skb); | ||
16 | 19 | ||
17 | static inline int nf_nat_initialized(struct nf_conn *ct, | 20 | static inline int nf_nat_initialized(struct nf_conn *ct, |
18 | enum nf_nat_manip_type manip) | 21 | enum nf_nat_manip_type manip) |
19 | { | 22 | { |
20 | if (manip == NF_NAT_MANIP_SRC) | 23 | if (manip == IP_NAT_MANIP_SRC) |
21 | return ct->status & IPS_SRC_NAT_DONE; | 24 | return ct->status & IPS_SRC_NAT_DONE; |
22 | else | 25 | else |
23 | return ct->status & IPS_DST_NAT_DONE; | 26 | return ct->status & IPS_DST_NAT_DONE; |
diff --git a/include/net/netfilter/nf_nat_helper.h b/include/net/netfilter/nf_nat_helper.h index b4d6bfc2af0..02bb6c29dc3 100644 --- a/include/net/netfilter/nf_nat_helper.h +++ b/include/net/netfilter/nf_nat_helper.h | |||
@@ -10,7 +10,6 @@ struct sk_buff; | |||
10 | extern int __nf_nat_mangle_tcp_packet(struct sk_buff *skb, | 10 | extern int __nf_nat_mangle_tcp_packet(struct sk_buff *skb, |
11 | struct nf_conn *ct, | 11 | struct nf_conn *ct, |
12 | enum ip_conntrack_info ctinfo, | 12 | enum ip_conntrack_info ctinfo, |
13 | unsigned int protoff, | ||
14 | unsigned int match_offset, | 13 | unsigned int match_offset, |
15 | unsigned int match_len, | 14 | unsigned int match_len, |
16 | const char *rep_buffer, | 15 | const char *rep_buffer, |
@@ -19,13 +18,12 @@ extern int __nf_nat_mangle_tcp_packet(struct sk_buff *skb, | |||
19 | static inline int nf_nat_mangle_tcp_packet(struct sk_buff *skb, | 18 | static inline int nf_nat_mangle_tcp_packet(struct sk_buff *skb, |
20 | struct nf_conn *ct, | 19 | struct nf_conn *ct, |
21 | enum ip_conntrack_info ctinfo, | 20 | enum ip_conntrack_info ctinfo, |
22 | unsigned int protoff, | ||
23 | unsigned int match_offset, | 21 | unsigned int match_offset, |
24 | unsigned int match_len, | 22 | unsigned int match_len, |
25 | const char *rep_buffer, | 23 | const char *rep_buffer, |
26 | unsigned int rep_len) | 24 | unsigned int rep_len) |
27 | { | 25 | { |
28 | return __nf_nat_mangle_tcp_packet(skb, ct, ctinfo, protoff, | 26 | return __nf_nat_mangle_tcp_packet(skb, ct, ctinfo, |
29 | match_offset, match_len, | 27 | match_offset, match_len, |
30 | rep_buffer, rep_len, true); | 28 | rep_buffer, rep_len, true); |
31 | } | 29 | } |
@@ -33,7 +31,6 @@ static inline int nf_nat_mangle_tcp_packet(struct sk_buff *skb, | |||
33 | extern int nf_nat_mangle_udp_packet(struct sk_buff *skb, | 31 | extern int nf_nat_mangle_udp_packet(struct sk_buff *skb, |
34 | struct nf_conn *ct, | 32 | struct nf_conn *ct, |
35 | enum ip_conntrack_info ctinfo, | 33 | enum ip_conntrack_info ctinfo, |
36 | unsigned int protoff, | ||
37 | unsigned int match_offset, | 34 | unsigned int match_offset, |
38 | unsigned int match_len, | 35 | unsigned int match_len, |
39 | const char *rep_buffer, | 36 | const char *rep_buffer, |
@@ -44,12 +41,10 @@ extern void nf_nat_set_seq_adjust(struct nf_conn *ct, | |||
44 | __be32 seq, s16 off); | 41 | __be32 seq, s16 off); |
45 | extern int nf_nat_seq_adjust(struct sk_buff *skb, | 42 | extern int nf_nat_seq_adjust(struct sk_buff *skb, |
46 | struct nf_conn *ct, | 43 | struct nf_conn *ct, |
47 | enum ip_conntrack_info ctinfo, | 44 | enum ip_conntrack_info ctinfo); |
48 | unsigned int protoff); | ||
49 | extern int (*nf_nat_seq_adjust_hook)(struct sk_buff *skb, | 45 | extern int (*nf_nat_seq_adjust_hook)(struct sk_buff *skb, |
50 | struct nf_conn *ct, | 46 | struct nf_conn *ct, |
51 | enum ip_conntrack_info ctinfo, | 47 | enum ip_conntrack_info ctinfo); |
52 | unsigned int protoff); | ||
53 | 48 | ||
54 | /* Setup NAT on this expected conntrack so it follows master, but goes | 49 | /* Setup NAT on this expected conntrack so it follows master, but goes |
55 | * to port ct->master->saved_proto. */ | 50 | * to port ct->master->saved_proto. */ |
@@ -59,8 +54,4 @@ extern void nf_nat_follow_master(struct nf_conn *ct, | |||
59 | extern s16 nf_nat_get_offset(const struct nf_conn *ct, | 54 | extern s16 nf_nat_get_offset(const struct nf_conn *ct, |
60 | enum ip_conntrack_dir dir, | 55 | enum ip_conntrack_dir dir, |
61 | u32 seq); | 56 | u32 seq); |
62 | |||
63 | extern void nf_nat_tcp_seq_adjust(struct sk_buff *skb, struct nf_conn *ct, | ||
64 | u32 dir, int off); | ||
65 | |||
66 | #endif | 57 | #endif |
diff --git a/include/net/netfilter/nf_nat_l3proto.h b/include/net/netfilter/nf_nat_l3proto.h deleted file mode 100644 index bd3b97e02c8..00000000000 --- a/include/net/netfilter/nf_nat_l3proto.h +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | #ifndef _NF_NAT_L3PROTO_H | ||
2 | #define _NF_NAT_L3PROTO_H | ||
3 | |||
4 | struct nf_nat_l4proto; | ||
5 | struct nf_nat_l3proto { | ||
6 | u8 l3proto; | ||
7 | |||
8 | bool (*in_range)(const struct nf_conntrack_tuple *t, | ||
9 | const struct nf_nat_range *range); | ||
10 | |||
11 | u32 (*secure_port)(const struct nf_conntrack_tuple *t, __be16); | ||
12 | |||
13 | bool (*manip_pkt)(struct sk_buff *skb, | ||
14 | unsigned int iphdroff, | ||
15 | const struct nf_nat_l4proto *l4proto, | ||
16 | const struct nf_conntrack_tuple *target, | ||
17 | enum nf_nat_manip_type maniptype); | ||
18 | |||
19 | void (*csum_update)(struct sk_buff *skb, unsigned int iphdroff, | ||
20 | __sum16 *check, | ||
21 | const struct nf_conntrack_tuple *t, | ||
22 | enum nf_nat_manip_type maniptype); | ||
23 | |||
24 | void (*csum_recalc)(struct sk_buff *skb, u8 proto, | ||
25 | void *data, __sum16 *check, | ||
26 | int datalen, int oldlen); | ||
27 | |||
28 | void (*decode_session)(struct sk_buff *skb, | ||
29 | const struct nf_conn *ct, | ||
30 | enum ip_conntrack_dir dir, | ||
31 | unsigned long statusbit, | ||
32 | struct flowi *fl); | ||
33 | |||
34 | int (*nlattr_to_range)(struct nlattr *tb[], | ||
35 | struct nf_nat_range *range); | ||
36 | }; | ||
37 | |||
38 | extern int nf_nat_l3proto_register(const struct nf_nat_l3proto *); | ||
39 | extern void nf_nat_l3proto_unregister(const struct nf_nat_l3proto *); | ||
40 | extern const struct nf_nat_l3proto *__nf_nat_l3proto_find(u8 l3proto); | ||
41 | |||
42 | extern int nf_nat_icmp_reply_translation(struct sk_buff *skb, | ||
43 | struct nf_conn *ct, | ||
44 | enum ip_conntrack_info ctinfo, | ||
45 | unsigned int hooknum); | ||
46 | extern int nf_nat_icmpv6_reply_translation(struct sk_buff *skb, | ||
47 | struct nf_conn *ct, | ||
48 | enum ip_conntrack_info ctinfo, | ||
49 | unsigned int hooknum, | ||
50 | unsigned int hdrlen); | ||
51 | |||
52 | #endif /* _NF_NAT_L3PROTO_H */ | ||
diff --git a/include/net/netfilter/nf_nat_l4proto.h b/include/net/netfilter/nf_nat_l4proto.h deleted file mode 100644 index 24feb68d1bc..00000000000 --- a/include/net/netfilter/nf_nat_l4proto.h +++ /dev/null | |||
@@ -1,72 +0,0 @@ | |||
1 | /* Header for use in defining a given protocol. */ | ||
2 | #ifndef _NF_NAT_L4PROTO_H | ||
3 | #define _NF_NAT_L4PROTO_H | ||
4 | #include <net/netfilter/nf_nat.h> | ||
5 | #include <linux/netfilter/nfnetlink_conntrack.h> | ||
6 | |||
7 | struct nf_nat_range; | ||
8 | struct nf_nat_l3proto; | ||
9 | |||
10 | struct nf_nat_l4proto { | ||
11 | /* Protocol number. */ | ||
12 | u8 l4proto; | ||
13 | |||
14 | /* Translate a packet to the target according to manip type. | ||
15 | * Return true if succeeded. | ||
16 | */ | ||
17 | bool (*manip_pkt)(struct sk_buff *skb, | ||
18 | const struct nf_nat_l3proto *l3proto, | ||
19 | unsigned int iphdroff, unsigned int hdroff, | ||
20 | const struct nf_conntrack_tuple *tuple, | ||
21 | enum nf_nat_manip_type maniptype); | ||
22 | |||
23 | /* Is the manipable part of the tuple between min and max incl? */ | ||
24 | bool (*in_range)(const struct nf_conntrack_tuple *tuple, | ||
25 | enum nf_nat_manip_type maniptype, | ||
26 | const union nf_conntrack_man_proto *min, | ||
27 | const union nf_conntrack_man_proto *max); | ||
28 | |||
29 | /* Alter the per-proto part of the tuple (depending on | ||
30 | * maniptype), to give a unique tuple in the given range if | ||
31 | * possible. Per-protocol part of tuple is initialized to the | ||
32 | * incoming packet. | ||
33 | */ | ||
34 | void (*unique_tuple)(const struct nf_nat_l3proto *l3proto, | ||
35 | struct nf_conntrack_tuple *tuple, | ||
36 | const struct nf_nat_range *range, | ||
37 | enum nf_nat_manip_type maniptype, | ||
38 | const struct nf_conn *ct); | ||
39 | |||
40 | int (*nlattr_to_range)(struct nlattr *tb[], | ||
41 | struct nf_nat_range *range); | ||
42 | }; | ||
43 | |||
44 | /* Protocol registration. */ | ||
45 | extern int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto); | ||
46 | extern void nf_nat_l4proto_unregister(u8 l3proto, const struct nf_nat_l4proto *l4proto); | ||
47 | |||
48 | extern const struct nf_nat_l4proto *__nf_nat_l4proto_find(u8 l3proto, u8 l4proto); | ||
49 | |||
50 | /* Built-in protocols. */ | ||
51 | extern const struct nf_nat_l4proto nf_nat_l4proto_tcp; | ||
52 | extern const struct nf_nat_l4proto nf_nat_l4proto_udp; | ||
53 | extern const struct nf_nat_l4proto nf_nat_l4proto_icmp; | ||
54 | extern const struct nf_nat_l4proto nf_nat_l4proto_icmpv6; | ||
55 | extern const struct nf_nat_l4proto nf_nat_l4proto_unknown; | ||
56 | |||
57 | extern bool nf_nat_l4proto_in_range(const struct nf_conntrack_tuple *tuple, | ||
58 | enum nf_nat_manip_type maniptype, | ||
59 | const union nf_conntrack_man_proto *min, | ||
60 | const union nf_conntrack_man_proto *max); | ||
61 | |||
62 | extern void nf_nat_l4proto_unique_tuple(const struct nf_nat_l3proto *l3proto, | ||
63 | struct nf_conntrack_tuple *tuple, | ||
64 | const struct nf_nat_range *range, | ||
65 | enum nf_nat_manip_type maniptype, | ||
66 | const struct nf_conn *ct, | ||
67 | u16 *rover); | ||
68 | |||
69 | extern int nf_nat_l4proto_nlattr_to_range(struct nlattr *tb[], | ||
70 | struct nf_nat_range *range); | ||
71 | |||
72 | #endif /*_NF_NAT_L4PROTO_H*/ | ||
diff --git a/include/net/netfilter/nf_queue.h b/include/net/netfilter/nf_queue.h index fb1c0be38b6..252fd1010b7 100644 --- a/include/net/netfilter/nf_queue.h +++ b/include/net/netfilter/nf_queue.h | |||
@@ -21,10 +21,14 @@ struct nf_queue_entry { | |||
21 | struct nf_queue_handler { | 21 | struct nf_queue_handler { |
22 | int (*outfn)(struct nf_queue_entry *entry, | 22 | int (*outfn)(struct nf_queue_entry *entry, |
23 | unsigned int queuenum); | 23 | unsigned int queuenum); |
24 | char *name; | ||
24 | }; | 25 | }; |
25 | 26 | ||
26 | void nf_register_queue_handler(const struct nf_queue_handler *qh); | 27 | extern int nf_register_queue_handler(u_int8_t pf, |
27 | void nf_unregister_queue_handler(void); | 28 | const struct nf_queue_handler *qh); |
29 | extern int nf_unregister_queue_handler(u_int8_t pf, | ||
30 | const struct nf_queue_handler *qh); | ||
31 | extern void nf_unregister_queue_handlers(const struct nf_queue_handler *qh); | ||
28 | extern void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict); | 32 | extern void nf_reinject(struct nf_queue_entry *entry, unsigned int verdict); |
29 | 33 | ||
30 | #endif /* _NF_QUEUE_H */ | 34 | #endif /* _NF_QUEUE_H */ |
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h index 75ca9291cf2..e505358d899 100644 --- a/include/net/netfilter/nf_tproxy_core.h +++ b/include/net/netfilter/nf_tproxy_core.h | |||
@@ -131,7 +131,7 @@ nf_tproxy_get_sock_v4(struct net *net, const u8 protocol, | |||
131 | return sk; | 131 | return sk; |
132 | } | 132 | } |
133 | 133 | ||
134 | #if IS_ENABLED(CONFIG_IPV6) | 134 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
135 | static inline struct sock * | 135 | static inline struct sock * |
136 | nf_tproxy_get_sock_v6(struct net *net, const u8 protocol, | 136 | nf_tproxy_get_sock_v6(struct net *net, const u8 protocol, |
137 | const struct in6_addr *saddr, const struct in6_addr *daddr, | 137 | const struct in6_addr *saddr, const struct in6_addr *daddr, |
diff --git a/include/net/netfilter/nfnetlink_queue.h b/include/net/netfilter/nfnetlink_queue.h deleted file mode 100644 index 86267a52951..00000000000 --- a/include/net/netfilter/nfnetlink_queue.h +++ /dev/null | |||
@@ -1,43 +0,0 @@ | |||
1 | #ifndef _NET_NFNL_QUEUE_H_ | ||
2 | #define _NET_NFNL_QUEUE_H_ | ||
3 | |||
4 | #include <linux/netfilter/nf_conntrack_common.h> | ||
5 | |||
6 | struct nf_conn; | ||
7 | |||
8 | #ifdef CONFIG_NETFILTER_NETLINK_QUEUE_CT | ||
9 | struct nf_conn *nfqnl_ct_get(struct sk_buff *entskb, size_t *size, | ||
10 | enum ip_conntrack_info *ctinfo); | ||
11 | struct nf_conn *nfqnl_ct_parse(const struct sk_buff *skb, | ||
12 | const struct nlattr *attr, | ||
13 | enum ip_conntrack_info *ctinfo); | ||
14 | int nfqnl_ct_put(struct sk_buff *skb, struct nf_conn *ct, | ||
15 | enum ip_conntrack_info ctinfo); | ||
16 | void nfqnl_ct_seq_adjust(struct sk_buff *skb, struct nf_conn *ct, | ||
17 | enum ip_conntrack_info ctinfo, int diff); | ||
18 | #else | ||
19 | inline struct nf_conn * | ||
20 | nfqnl_ct_get(struct sk_buff *entskb, size_t *size, enum ip_conntrack_info *ctinfo) | ||
21 | { | ||
22 | return NULL; | ||
23 | } | ||
24 | |||
25 | inline struct nf_conn *nfqnl_ct_parse(const struct sk_buff *skb, | ||
26 | const struct nlattr *attr, | ||
27 | enum ip_conntrack_info *ctinfo) | ||
28 | { | ||
29 | return NULL; | ||
30 | } | ||
31 | |||
32 | inline int | ||
33 | nfqnl_ct_put(struct sk_buff *skb, struct nf_conn *ct, enum ip_conntrack_info ctinfo) | ||
34 | { | ||
35 | return 0; | ||
36 | } | ||
37 | |||
38 | inline void nfqnl_ct_seq_adjust(struct sk_buff *skb, struct nf_conn *ct, | ||
39 | enum ip_conntrack_info ctinfo, int diff) | ||
40 | { | ||
41 | } | ||
42 | #endif /* NF_CONNTRACK */ | ||
43 | #endif | ||
diff --git a/include/net/netfilter/xt_log.h b/include/net/netfilter/xt_log.h index 9d9756cca01..0dfb34a5b53 100644 --- a/include/net/netfilter/xt_log.h +++ b/include/net/netfilter/xt_log.h | |||
@@ -6,7 +6,7 @@ struct sbuff { | |||
6 | }; | 6 | }; |
7 | static struct sbuff emergency, *emergency_ptr = &emergency; | 7 | static struct sbuff emergency, *emergency_ptr = &emergency; |
8 | 8 | ||
9 | static __printf(2, 3) int sb_add(struct sbuff *m, const char *f, ...) | 9 | static int sb_add(struct sbuff *m, const char *f, ...) |
10 | { | 10 | { |
11 | va_list args; | 11 | va_list args; |
12 | int len; | 12 | int len; |
@@ -47,7 +47,7 @@ static void sb_close(struct sbuff *m) | |||
47 | if (likely(m != &emergency)) | 47 | if (likely(m != &emergency)) |
48 | kfree(m); | 48 | kfree(m); |
49 | else { | 49 | else { |
50 | emergency_ptr = m; | 50 | xchg(&emergency_ptr, m); |
51 | local_bh_enable(); | 51 | local_bh_enable(); |
52 | } | 52 | } |
53 | } | 53 | } |
diff --git a/include/net/netlabel.h b/include/net/netlabel.h index 2c95d55f791..f67440970d7 100644 --- a/include/net/netlabel.h +++ b/include/net/netlabel.h | |||
@@ -110,7 +110,7 @@ struct cipso_v4_doi; | |||
110 | /* NetLabel audit information */ | 110 | /* NetLabel audit information */ |
111 | struct netlbl_audit { | 111 | struct netlbl_audit { |
112 | u32 secid; | 112 | u32 secid; |
113 | kuid_t loginuid; | 113 | uid_t loginuid; |
114 | u32 sessionid; | 114 | u32 sessionid; |
115 | }; | 115 | }; |
116 | 116 | ||
diff --git a/include/net/netlink.h b/include/net/netlink.h index 9690b0f6698..98c185441be 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -98,14 +98,24 @@ | |||
98 | * nla_put_u16(skb, type, value) add u16 attribute to skb | 98 | * nla_put_u16(skb, type, value) add u16 attribute to skb |
99 | * nla_put_u32(skb, type, value) add u32 attribute to skb | 99 | * nla_put_u32(skb, type, value) add u32 attribute to skb |
100 | * nla_put_u64(skb, type, value) add u64 attribute to skb | 100 | * nla_put_u64(skb, type, value) add u64 attribute to skb |
101 | * nla_put_s8(skb, type, value) add s8 attribute to skb | ||
102 | * nla_put_s16(skb, type, value) add s16 attribute to skb | ||
103 | * nla_put_s32(skb, type, value) add s32 attribute to skb | ||
104 | * nla_put_s64(skb, type, value) add s64 attribute to skb | ||
105 | * nla_put_string(skb, type, str) add string attribute to skb | 101 | * nla_put_string(skb, type, str) add string attribute to skb |
106 | * nla_put_flag(skb, type) add flag attribute to skb | 102 | * nla_put_flag(skb, type) add flag attribute to skb |
107 | * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb | 103 | * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb |
108 | * | 104 | * |
105 | * Exceptions Based Attribute Construction: | ||
106 | * NLA_PUT(skb, type, len, data) add attribute to skb | ||
107 | * NLA_PUT_U8(skb, type, value) add u8 attribute to skb | ||
108 | * NLA_PUT_U16(skb, type, value) add u16 attribute to skb | ||
109 | * NLA_PUT_U32(skb, type, value) add u32 attribute to skb | ||
110 | * NLA_PUT_U64(skb, type, value) add u64 attribute to skb | ||
111 | * NLA_PUT_STRING(skb, type, str) add string attribute to skb | ||
112 | * NLA_PUT_FLAG(skb, type) add flag attribute to skb | ||
113 | * NLA_PUT_MSECS(skb, type, jiffies) add msecs attribute to skb | ||
114 | * | ||
115 | * The meaning of these functions is equal to their lower case | ||
116 | * variants but they jump to the label nla_put_failure in case | ||
117 | * of a failure. | ||
118 | * | ||
109 | * Nested Attributes Construction: | 119 | * Nested Attributes Construction: |
110 | * nla_nest_start(skb, type) start a nested attribute | 120 | * nla_nest_start(skb, type) start a nested attribute |
111 | * nla_nest_end(skb, nla) finalize a nested attribute | 121 | * nla_nest_end(skb, nla) finalize a nested attribute |
@@ -125,10 +135,6 @@ | |||
125 | * nla_get_u16(nla) get payload for a u16 attribute | 135 | * nla_get_u16(nla) get payload for a u16 attribute |
126 | * nla_get_u32(nla) get payload for a u32 attribute | 136 | * nla_get_u32(nla) get payload for a u32 attribute |
127 | * nla_get_u64(nla) get payload for a u64 attribute | 137 | * nla_get_u64(nla) get payload for a u64 attribute |
128 | * nla_get_s8(nla) get payload for a s8 attribute | ||
129 | * nla_get_s16(nla) get payload for a s16 attribute | ||
130 | * nla_get_s32(nla) get payload for a s32 attribute | ||
131 | * nla_get_s64(nla) get payload for a s64 attribute | ||
132 | * nla_get_flag(nla) return 1 if flag is true | 138 | * nla_get_flag(nla) return 1 if flag is true |
133 | * nla_get_msecs(nla) get payload for a msecs attribute | 139 | * nla_get_msecs(nla) get payload for a msecs attribute |
134 | * | 140 | * |
@@ -168,10 +174,6 @@ enum { | |||
168 | NLA_NESTED_COMPAT, | 174 | NLA_NESTED_COMPAT, |
169 | NLA_NUL_STRING, | 175 | NLA_NUL_STRING, |
170 | NLA_BINARY, | 176 | NLA_BINARY, |
171 | NLA_S8, | ||
172 | NLA_S16, | ||
173 | NLA_S32, | ||
174 | NLA_S64, | ||
175 | __NLA_TYPE_MAX, | 177 | __NLA_TYPE_MAX, |
176 | }; | 178 | }; |
177 | 179 | ||
@@ -190,17 +192,8 @@ enum { | |||
190 | * NLA_NUL_STRING Maximum length of string (excluding NUL) | 192 | * NLA_NUL_STRING Maximum length of string (excluding NUL) |
191 | * NLA_FLAG Unused | 193 | * NLA_FLAG Unused |
192 | * NLA_BINARY Maximum length of attribute payload | 194 | * NLA_BINARY Maximum length of attribute payload |
193 | * NLA_NESTED Don't use `len' field -- length verification is | 195 | * NLA_NESTED_COMPAT Exact length of structure payload |
194 | * done by checking len of nested header (or empty) | 196 | * All other Exact length of attribute payload |
195 | * NLA_NESTED_COMPAT Minimum length of structure payload | ||
196 | * NLA_U8, NLA_U16, | ||
197 | * NLA_U32, NLA_U64, | ||
198 | * NLA_S8, NLA_S16, | ||
199 | * NLA_S32, NLA_S64, | ||
200 | * NLA_MSECS Leaving the length field zero will verify the | ||
201 | * given type fits, using it verifies minimum length | ||
202 | * just like "All other" | ||
203 | * All other Minimum length of attribute payload | ||
204 | * | 197 | * |
205 | * Example: | 198 | * Example: |
206 | * static const struct nla_policy my_policy[ATTR_MAX+1] = { | 199 | * static const struct nla_policy my_policy[ATTR_MAX+1] = { |
@@ -217,19 +210,19 @@ struct nla_policy { | |||
217 | /** | 210 | /** |
218 | * struct nl_info - netlink source information | 211 | * struct nl_info - netlink source information |
219 | * @nlh: Netlink message header of original request | 212 | * @nlh: Netlink message header of original request |
220 | * @portid: Netlink PORTID of requesting application | 213 | * @pid: Netlink PID of requesting application |
221 | */ | 214 | */ |
222 | struct nl_info { | 215 | struct nl_info { |
223 | struct nlmsghdr *nlh; | 216 | struct nlmsghdr *nlh; |
224 | struct net *nl_net; | 217 | struct net *nl_net; |
225 | u32 portid; | 218 | u32 pid; |
226 | }; | 219 | }; |
227 | 220 | ||
228 | extern int netlink_rcv_skb(struct sk_buff *skb, | 221 | extern int netlink_rcv_skb(struct sk_buff *skb, |
229 | int (*cb)(struct sk_buff *, | 222 | int (*cb)(struct sk_buff *, |
230 | struct nlmsghdr *)); | 223 | struct nlmsghdr *)); |
231 | extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb, | 224 | extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb, |
232 | u32 portid, unsigned int group, int report, | 225 | u32 pid, unsigned int group, int report, |
233 | gfp_t flags); | 226 | gfp_t flags); |
234 | 227 | ||
235 | extern int nla_validate(const struct nlattr *head, | 228 | extern int nla_validate(const struct nlattr *head, |
@@ -441,10 +434,45 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh) | |||
441 | nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \ | 434 | nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \ |
442 | nlmsg_attrlen(nlh, hdrlen), rem) | 435 | nlmsg_attrlen(nlh, hdrlen), rem) |
443 | 436 | ||
437 | #if 0 | ||
438 | /* FIXME: Enable once all users have been converted */ | ||
439 | |||
440 | /** | ||
441 | * __nlmsg_put - Add a new netlink message to an skb | ||
442 | * @skb: socket buffer to store message in | ||
443 | * @pid: netlink process id | ||
444 | * @seq: sequence number of message | ||
445 | * @type: message type | ||
446 | * @payload: length of message payload | ||
447 | * @flags: message flags | ||
448 | * | ||
449 | * The caller is responsible to ensure that the skb provides enough | ||
450 | * tailroom for both the netlink header and payload. | ||
451 | */ | ||
452 | static inline struct nlmsghdr *__nlmsg_put(struct sk_buff *skb, u32 pid, | ||
453 | u32 seq, int type, int payload, | ||
454 | int flags) | ||
455 | { | ||
456 | struct nlmsghdr *nlh; | ||
457 | |||
458 | nlh = (struct nlmsghdr *) skb_put(skb, nlmsg_total_size(payload)); | ||
459 | nlh->nlmsg_type = type; | ||
460 | nlh->nlmsg_len = nlmsg_msg_size(payload); | ||
461 | nlh->nlmsg_flags = flags; | ||
462 | nlh->nlmsg_pid = pid; | ||
463 | nlh->nlmsg_seq = seq; | ||
464 | |||
465 | memset((unsigned char *) nlmsg_data(nlh) + payload, 0, | ||
466 | nlmsg_padlen(payload)); | ||
467 | |||
468 | return nlh; | ||
469 | } | ||
470 | #endif | ||
471 | |||
444 | /** | 472 | /** |
445 | * nlmsg_put - Add a new netlink message to an skb | 473 | * nlmsg_put - Add a new netlink message to an skb |
446 | * @skb: socket buffer to store message in | 474 | * @skb: socket buffer to store message in |
447 | * @portid: netlink process id | 475 | * @pid: netlink process id |
448 | * @seq: sequence number of message | 476 | * @seq: sequence number of message |
449 | * @type: message type | 477 | * @type: message type |
450 | * @payload: length of message payload | 478 | * @payload: length of message payload |
@@ -453,13 +481,13 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh) | |||
453 | * Returns NULL if the tailroom of the skb is insufficient to store | 481 | * Returns NULL if the tailroom of the skb is insufficient to store |
454 | * the message header and payload. | 482 | * the message header and payload. |
455 | */ | 483 | */ |
456 | static inline struct nlmsghdr *nlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, | 484 | static inline struct nlmsghdr *nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, |
457 | int type, int payload, int flags) | 485 | int type, int payload, int flags) |
458 | { | 486 | { |
459 | if (unlikely(skb_tailroom(skb) < nlmsg_total_size(payload))) | 487 | if (unlikely(skb_tailroom(skb) < nlmsg_total_size(payload))) |
460 | return NULL; | 488 | return NULL; |
461 | 489 | ||
462 | return __nlmsg_put(skb, portid, seq, type, payload, flags); | 490 | return __nlmsg_put(skb, pid, seq, type, payload, flags); |
463 | } | 491 | } |
464 | 492 | ||
465 | /** | 493 | /** |
@@ -478,7 +506,7 @@ static inline struct nlmsghdr *nlmsg_put_answer(struct sk_buff *skb, | |||
478 | int type, int payload, | 506 | int type, int payload, |
479 | int flags) | 507 | int flags) |
480 | { | 508 | { |
481 | return nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, | 509 | return nlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, |
482 | type, payload, flags); | 510 | type, payload, flags); |
483 | } | 511 | } |
484 | 512 | ||
@@ -563,18 +591,18 @@ static inline void nlmsg_free(struct sk_buff *skb) | |||
563 | * nlmsg_multicast - multicast a netlink message | 591 | * nlmsg_multicast - multicast a netlink message |
564 | * @sk: netlink socket to spread messages to | 592 | * @sk: netlink socket to spread messages to |
565 | * @skb: netlink message as socket buffer | 593 | * @skb: netlink message as socket buffer |
566 | * @portid: own netlink portid to avoid sending to yourself | 594 | * @pid: own netlink pid to avoid sending to yourself |
567 | * @group: multicast group id | 595 | * @group: multicast group id |
568 | * @flags: allocation flags | 596 | * @flags: allocation flags |
569 | */ | 597 | */ |
570 | static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb, | 598 | static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb, |
571 | u32 portid, unsigned int group, gfp_t flags) | 599 | u32 pid, unsigned int group, gfp_t flags) |
572 | { | 600 | { |
573 | int err; | 601 | int err; |
574 | 602 | ||
575 | NETLINK_CB(skb).dst_group = group; | 603 | NETLINK_CB(skb).dst_group = group; |
576 | 604 | ||
577 | err = netlink_broadcast(sk, skb, portid, group, flags); | 605 | err = netlink_broadcast(sk, skb, pid, group, flags); |
578 | if (err > 0) | 606 | if (err > 0) |
579 | err = 0; | 607 | err = 0; |
580 | 608 | ||
@@ -585,13 +613,13 @@ static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb, | |||
585 | * nlmsg_unicast - unicast a netlink message | 613 | * nlmsg_unicast - unicast a netlink message |
586 | * @sk: netlink socket to spread message to | 614 | * @sk: netlink socket to spread message to |
587 | * @skb: netlink message as socket buffer | 615 | * @skb: netlink message as socket buffer |
588 | * @portid: netlink portid of the destination socket | 616 | * @pid: netlink pid of the destination socket |
589 | */ | 617 | */ |
590 | static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 portid) | 618 | static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 pid) |
591 | { | 619 | { |
592 | int err; | 620 | int err; |
593 | 621 | ||
594 | err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT); | 622 | err = netlink_unicast(sk, skb, pid, MSG_DONTWAIT); |
595 | if (err > 0) | 623 | if (err > 0) |
596 | err = 0; | 624 | err = 0; |
597 | 625 | ||
@@ -772,39 +800,6 @@ static inline int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value) | |||
772 | } | 800 | } |
773 | 801 | ||
774 | /** | 802 | /** |
775 | * nla_put_be16 - Add a __be16 netlink attribute to a socket buffer | ||
776 | * @skb: socket buffer to add attribute to | ||
777 | * @attrtype: attribute type | ||
778 | * @value: numeric value | ||
779 | */ | ||
780 | static inline int nla_put_be16(struct sk_buff *skb, int attrtype, __be16 value) | ||
781 | { | ||
782 | return nla_put(skb, attrtype, sizeof(__be16), &value); | ||
783 | } | ||
784 | |||
785 | /** | ||
786 | * nla_put_net16 - Add 16-bit network byte order netlink attribute to a socket buffer | ||
787 | * @skb: socket buffer to add attribute to | ||
788 | * @attrtype: attribute type | ||
789 | * @value: numeric value | ||
790 | */ | ||
791 | static inline int nla_put_net16(struct sk_buff *skb, int attrtype, __be16 value) | ||
792 | { | ||
793 | return nla_put_be16(skb, attrtype | NLA_F_NET_BYTEORDER, value); | ||
794 | } | ||
795 | |||
796 | /** | ||
797 | * nla_put_le16 - Add a __le16 netlink attribute to a socket buffer | ||
798 | * @skb: socket buffer to add attribute to | ||
799 | * @attrtype: attribute type | ||
800 | * @value: numeric value | ||
801 | */ | ||
802 | static inline int nla_put_le16(struct sk_buff *skb, int attrtype, __le16 value) | ||
803 | { | ||
804 | return nla_put(skb, attrtype, sizeof(__le16), &value); | ||
805 | } | ||
806 | |||
807 | /** | ||
808 | * nla_put_u32 - Add a u32 netlink attribute to a socket buffer | 803 | * nla_put_u32 - Add a u32 netlink attribute to a socket buffer |
809 | * @skb: socket buffer to add attribute to | 804 | * @skb: socket buffer to add attribute to |
810 | * @attrtype: attribute type | 805 | * @attrtype: attribute type |
@@ -816,40 +811,7 @@ static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value) | |||
816 | } | 811 | } |
817 | 812 | ||
818 | /** | 813 | /** |
819 | * nla_put_be32 - Add a __be32 netlink attribute to a socket buffer | 814 | * nla_put_64 - Add a u64 netlink attribute to a socket buffer |
820 | * @skb: socket buffer to add attribute to | ||
821 | * @attrtype: attribute type | ||
822 | * @value: numeric value | ||
823 | */ | ||
824 | static inline int nla_put_be32(struct sk_buff *skb, int attrtype, __be32 value) | ||
825 | { | ||
826 | return nla_put(skb, attrtype, sizeof(__be32), &value); | ||
827 | } | ||
828 | |||
829 | /** | ||
830 | * nla_put_net32 - Add 32-bit network byte order netlink attribute to a socket buffer | ||
831 | * @skb: socket buffer to add attribute to | ||
832 | * @attrtype: attribute type | ||
833 | * @value: numeric value | ||
834 | */ | ||
835 | static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value) | ||
836 | { | ||
837 | return nla_put_be32(skb, attrtype | NLA_F_NET_BYTEORDER, value); | ||
838 | } | ||
839 | |||
840 | /** | ||
841 | * nla_put_le32 - Add a __le32 netlink attribute to a socket buffer | ||
842 | * @skb: socket buffer to add attribute to | ||
843 | * @attrtype: attribute type | ||
844 | * @value: numeric value | ||
845 | */ | ||
846 | static inline int nla_put_le32(struct sk_buff *skb, int attrtype, __le32 value) | ||
847 | { | ||
848 | return nla_put(skb, attrtype, sizeof(__le32), &value); | ||
849 | } | ||
850 | |||
851 | /** | ||
852 | * nla_put_u64 - Add a u64 netlink attribute to a socket buffer | ||
853 | * @skb: socket buffer to add attribute to | 815 | * @skb: socket buffer to add attribute to |
854 | * @attrtype: attribute type | 816 | * @attrtype: attribute type |
855 | * @value: numeric value | 817 | * @value: numeric value |
@@ -860,83 +822,6 @@ static inline int nla_put_u64(struct sk_buff *skb, int attrtype, u64 value) | |||
860 | } | 822 | } |
861 | 823 | ||
862 | /** | 824 | /** |
863 | * nla_put_be64 - Add a __be64 netlink attribute to a socket buffer | ||
864 | * @skb: socket buffer to add attribute to | ||
865 | * @attrtype: attribute type | ||
866 | * @value: numeric value | ||
867 | */ | ||
868 | static inline int nla_put_be64(struct sk_buff *skb, int attrtype, __be64 value) | ||
869 | { | ||
870 | return nla_put(skb, attrtype, sizeof(__be64), &value); | ||
871 | } | ||
872 | |||
873 | /** | ||
874 | * nla_put_net64 - Add 64-bit network byte order netlink attribute to a socket buffer | ||
875 | * @skb: socket buffer to add attribute to | ||
876 | * @attrtype: attribute type | ||
877 | * @value: numeric value | ||
878 | */ | ||
879 | static inline int nla_put_net64(struct sk_buff *skb, int attrtype, __be64 value) | ||
880 | { | ||
881 | return nla_put_be64(skb, attrtype | NLA_F_NET_BYTEORDER, value); | ||
882 | } | ||
883 | |||
884 | /** | ||
885 | * nla_put_le64 - Add a __le64 netlink attribute to a socket buffer | ||
886 | * @skb: socket buffer to add attribute to | ||
887 | * @attrtype: attribute type | ||
888 | * @value: numeric value | ||
889 | */ | ||
890 | static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value) | ||
891 | { | ||
892 | return nla_put(skb, attrtype, sizeof(__le64), &value); | ||
893 | } | ||
894 | |||
895 | /** | ||
896 | * nla_put_s8 - Add a s8 netlink attribute to a socket buffer | ||
897 | * @skb: socket buffer to add attribute to | ||
898 | * @attrtype: attribute type | ||
899 | * @value: numeric value | ||
900 | */ | ||
901 | static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value) | ||
902 | { | ||
903 | return nla_put(skb, attrtype, sizeof(s8), &value); | ||
904 | } | ||
905 | |||
906 | /** | ||
907 | * nla_put_s16 - Add a s16 netlink attribute to a socket buffer | ||
908 | * @skb: socket buffer to add attribute to | ||
909 | * @attrtype: attribute type | ||
910 | * @value: numeric value | ||
911 | */ | ||
912 | static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value) | ||
913 | { | ||
914 | return nla_put(skb, attrtype, sizeof(s16), &value); | ||
915 | } | ||
916 | |||
917 | /** | ||
918 | * nla_put_s32 - Add a s32 netlink attribute to a socket buffer | ||
919 | * @skb: socket buffer to add attribute to | ||
920 | * @attrtype: attribute type | ||
921 | * @value: numeric value | ||
922 | */ | ||
923 | static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value) | ||
924 | { | ||
925 | return nla_put(skb, attrtype, sizeof(s32), &value); | ||
926 | } | ||
927 | |||
928 | /** | ||
929 | * nla_put_s64 - Add a s64 netlink attribute to a socket buffer | ||
930 | * @skb: socket buffer to add attribute to | ||
931 | * @attrtype: attribute type | ||
932 | * @value: numeric value | ||
933 | */ | ||
934 | static inline int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value) | ||
935 | { | ||
936 | return nla_put(skb, attrtype, sizeof(s64), &value); | ||
937 | } | ||
938 | |||
939 | /** | ||
940 | * nla_put_string - Add a string netlink attribute to a socket buffer | 825 | * nla_put_string - Add a string netlink attribute to a socket buffer |
941 | * @skb: socket buffer to add attribute to | 826 | * @skb: socket buffer to add attribute to |
942 | * @attrtype: attribute type | 827 | * @attrtype: attribute type |
@@ -971,6 +856,60 @@ static inline int nla_put_msecs(struct sk_buff *skb, int attrtype, | |||
971 | return nla_put(skb, attrtype, sizeof(u64), &tmp); | 856 | return nla_put(skb, attrtype, sizeof(u64), &tmp); |
972 | } | 857 | } |
973 | 858 | ||
859 | #define NLA_PUT(skb, attrtype, attrlen, data) \ | ||
860 | do { \ | ||
861 | if (unlikely(nla_put(skb, attrtype, attrlen, data) < 0)) \ | ||
862 | goto nla_put_failure; \ | ||
863 | } while(0) | ||
864 | |||
865 | #define NLA_PUT_TYPE(skb, type, attrtype, value) \ | ||
866 | do { \ | ||
867 | type __tmp = value; \ | ||
868 | NLA_PUT(skb, attrtype, sizeof(type), &__tmp); \ | ||
869 | } while(0) | ||
870 | |||
871 | #define NLA_PUT_U8(skb, attrtype, value) \ | ||
872 | NLA_PUT_TYPE(skb, u8, attrtype, value) | ||
873 | |||
874 | #define NLA_PUT_U16(skb, attrtype, value) \ | ||
875 | NLA_PUT_TYPE(skb, u16, attrtype, value) | ||
876 | |||
877 | #define NLA_PUT_LE16(skb, attrtype, value) \ | ||
878 | NLA_PUT_TYPE(skb, __le16, attrtype, value) | ||
879 | |||
880 | #define NLA_PUT_BE16(skb, attrtype, value) \ | ||
881 | NLA_PUT_TYPE(skb, __be16, attrtype, value) | ||
882 | |||
883 | #define NLA_PUT_NET16(skb, attrtype, value) \ | ||
884 | NLA_PUT_BE16(skb, attrtype | NLA_F_NET_BYTEORDER, value) | ||
885 | |||
886 | #define NLA_PUT_U32(skb, attrtype, value) \ | ||
887 | NLA_PUT_TYPE(skb, u32, attrtype, value) | ||
888 | |||
889 | #define NLA_PUT_BE32(skb, attrtype, value) \ | ||
890 | NLA_PUT_TYPE(skb, __be32, attrtype, value) | ||
891 | |||
892 | #define NLA_PUT_NET32(skb, attrtype, value) \ | ||
893 | NLA_PUT_BE32(skb, attrtype | NLA_F_NET_BYTEORDER, value) | ||
894 | |||
895 | #define NLA_PUT_U64(skb, attrtype, value) \ | ||
896 | NLA_PUT_TYPE(skb, u64, attrtype, value) | ||
897 | |||
898 | #define NLA_PUT_BE64(skb, attrtype, value) \ | ||
899 | NLA_PUT_TYPE(skb, __be64, attrtype, value) | ||
900 | |||
901 | #define NLA_PUT_NET64(skb, attrtype, value) \ | ||
902 | NLA_PUT_BE64(skb, attrtype | NLA_F_NET_BYTEORDER, value) | ||
903 | |||
904 | #define NLA_PUT_STRING(skb, attrtype, value) \ | ||
905 | NLA_PUT(skb, attrtype, strlen(value) + 1, value) | ||
906 | |||
907 | #define NLA_PUT_FLAG(skb, attrtype) \ | ||
908 | NLA_PUT(skb, attrtype, 0, NULL) | ||
909 | |||
910 | #define NLA_PUT_MSECS(skb, attrtype, jiffies) \ | ||
911 | NLA_PUT_U64(skb, attrtype, jiffies_to_msecs(jiffies)) | ||
912 | |||
974 | /** | 913 | /** |
975 | * nla_get_u32 - return payload of u32 attribute | 914 | * nla_get_u32 - return payload of u32 attribute |
976 | * @nla: u32 netlink attribute | 915 | * @nla: u32 netlink attribute |
@@ -1052,46 +991,6 @@ static inline __be64 nla_get_be64(const struct nlattr *nla) | |||
1052 | } | 991 | } |
1053 | 992 | ||
1054 | /** | 993 | /** |
1055 | * nla_get_s32 - return payload of s32 attribute | ||
1056 | * @nla: s32 netlink attribute | ||
1057 | */ | ||
1058 | static inline s32 nla_get_s32(const struct nlattr *nla) | ||
1059 | { | ||
1060 | return *(s32 *) nla_data(nla); | ||
1061 | } | ||
1062 | |||
1063 | /** | ||
1064 | * nla_get_s16 - return payload of s16 attribute | ||
1065 | * @nla: s16 netlink attribute | ||
1066 | */ | ||
1067 | static inline s16 nla_get_s16(const struct nlattr *nla) | ||
1068 | { | ||
1069 | return *(s16 *) nla_data(nla); | ||
1070 | } | ||
1071 | |||
1072 | /** | ||
1073 | * nla_get_s8 - return payload of s8 attribute | ||
1074 | * @nla: s8 netlink attribute | ||
1075 | */ | ||
1076 | static inline s8 nla_get_s8(const struct nlattr *nla) | ||
1077 | { | ||
1078 | return *(s8 *) nla_data(nla); | ||
1079 | } | ||
1080 | |||
1081 | /** | ||
1082 | * nla_get_s64 - return payload of s64 attribute | ||
1083 | * @nla: s64 netlink attribute | ||
1084 | */ | ||
1085 | static inline s64 nla_get_s64(const struct nlattr *nla) | ||
1086 | { | ||
1087 | s64 tmp; | ||
1088 | |||
1089 | nla_memcpy(&tmp, nla, sizeof(tmp)); | ||
1090 | |||
1091 | return tmp; | ||
1092 | } | ||
1093 | |||
1094 | /** | ||
1095 | * nla_get_flag - return payload of flag attribute | 994 | * nla_get_flag - return payload of flag attribute |
1096 | * @nla: flag netlink attribute | 995 | * @nla: flag netlink attribute |
1097 | */ | 996 | */ |
diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h index 923cb20051e..0249399e51a 100644 --- a/include/net/netns/conntrack.h +++ b/include/net/netns/conntrack.h | |||
@@ -4,64 +4,10 @@ | |||
4 | #include <linux/list.h> | 4 | #include <linux/list.h> |
5 | #include <linux/list_nulls.h> | 5 | #include <linux/list_nulls.h> |
6 | #include <linux/atomic.h> | 6 | #include <linux/atomic.h> |
7 | #include <linux/netfilter/nf_conntrack_tcp.h> | ||
8 | 7 | ||
9 | struct ctl_table_header; | 8 | struct ctl_table_header; |
10 | struct nf_conntrack_ecache; | 9 | struct nf_conntrack_ecache; |
11 | 10 | ||
12 | struct nf_proto_net { | ||
13 | #ifdef CONFIG_SYSCTL | ||
14 | struct ctl_table_header *ctl_table_header; | ||
15 | struct ctl_table *ctl_table; | ||
16 | #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT | ||
17 | struct ctl_table_header *ctl_compat_header; | ||
18 | struct ctl_table *ctl_compat_table; | ||
19 | #endif | ||
20 | #endif | ||
21 | unsigned int users; | ||
22 | }; | ||
23 | |||
24 | struct nf_generic_net { | ||
25 | struct nf_proto_net pn; | ||
26 | unsigned int timeout; | ||
27 | }; | ||
28 | |||
29 | struct nf_tcp_net { | ||
30 | struct nf_proto_net pn; | ||
31 | unsigned int timeouts[TCP_CONNTRACK_TIMEOUT_MAX]; | ||
32 | unsigned int tcp_loose; | ||
33 | unsigned int tcp_be_liberal; | ||
34 | unsigned int tcp_max_retrans; | ||
35 | }; | ||
36 | |||
37 | enum udp_conntrack { | ||
38 | UDP_CT_UNREPLIED, | ||
39 | UDP_CT_REPLIED, | ||
40 | UDP_CT_MAX | ||
41 | }; | ||
42 | |||
43 | struct nf_udp_net { | ||
44 | struct nf_proto_net pn; | ||
45 | unsigned int timeouts[UDP_CT_MAX]; | ||
46 | }; | ||
47 | |||
48 | struct nf_icmp_net { | ||
49 | struct nf_proto_net pn; | ||
50 | unsigned int timeout; | ||
51 | }; | ||
52 | |||
53 | struct nf_ip_net { | ||
54 | struct nf_generic_net generic; | ||
55 | struct nf_tcp_net tcp; | ||
56 | struct nf_udp_net udp; | ||
57 | struct nf_icmp_net icmp; | ||
58 | struct nf_icmp_net icmpv6; | ||
59 | #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT) | ||
60 | struct ctl_table_header *ctl_table_header; | ||
61 | struct ctl_table *ctl_table; | ||
62 | #endif | ||
63 | }; | ||
64 | |||
65 | struct netns_ct { | 11 | struct netns_ct { |
66 | atomic_t count; | 12 | atomic_t count; |
67 | unsigned int expect_count; | 13 | unsigned int expect_count; |
@@ -71,29 +17,18 @@ struct netns_ct { | |||
71 | struct hlist_head *expect_hash; | 17 | struct hlist_head *expect_hash; |
72 | struct hlist_nulls_head unconfirmed; | 18 | struct hlist_nulls_head unconfirmed; |
73 | struct hlist_nulls_head dying; | 19 | struct hlist_nulls_head dying; |
74 | struct hlist_nulls_head tmpl; | ||
75 | struct ip_conntrack_stat __percpu *stat; | 20 | struct ip_conntrack_stat __percpu *stat; |
76 | struct nf_ct_event_notifier __rcu *nf_conntrack_event_cb; | ||
77 | struct nf_exp_event_notifier __rcu *nf_expect_event_cb; | ||
78 | int sysctl_events; | 21 | int sysctl_events; |
79 | unsigned int sysctl_events_retry_timeout; | 22 | unsigned int sysctl_events_retry_timeout; |
80 | int sysctl_acct; | 23 | int sysctl_acct; |
81 | int sysctl_tstamp; | 24 | int sysctl_tstamp; |
82 | int sysctl_checksum; | 25 | int sysctl_checksum; |
83 | unsigned int sysctl_log_invalid; /* Log invalid packets */ | 26 | unsigned int sysctl_log_invalid; /* Log invalid packets */ |
84 | int sysctl_auto_assign_helper; | ||
85 | bool auto_assign_helper_warned; | ||
86 | struct nf_ip_net nf_ct_proto; | ||
87 | #ifdef CONFIG_NF_NAT_NEEDED | ||
88 | struct hlist_head *nat_bysource; | ||
89 | unsigned int nat_htable_size; | ||
90 | #endif | ||
91 | #ifdef CONFIG_SYSCTL | 27 | #ifdef CONFIG_SYSCTL |
92 | struct ctl_table_header *sysctl_header; | 28 | struct ctl_table_header *sysctl_header; |
93 | struct ctl_table_header *acct_sysctl_header; | 29 | struct ctl_table_header *acct_sysctl_header; |
94 | struct ctl_table_header *tstamp_sysctl_header; | 30 | struct ctl_table_header *tstamp_sysctl_header; |
95 | struct ctl_table_header *event_sysctl_header; | 31 | struct ctl_table_header *event_sysctl_header; |
96 | struct ctl_table_header *helper_sysctl_header; | ||
97 | #endif | 32 | #endif |
98 | char *slabname; | 33 | char *slabname; |
99 | }; | 34 | }; |
diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h index 0931618c0f7..d55f4344333 100644 --- a/include/net/netns/generic.h +++ b/include/net/netns/generic.h | |||
@@ -5,7 +5,6 @@ | |||
5 | #ifndef __NET_GENERIC_H__ | 5 | #ifndef __NET_GENERIC_H__ |
6 | #define __NET_GENERIC_H__ | 6 | #define __NET_GENERIC_H__ |
7 | 7 | ||
8 | #include <linux/bug.h> | ||
9 | #include <linux/rcupdate.h> | 8 | #include <linux/rcupdate.h> |
10 | 9 | ||
11 | /* | 10 | /* |
diff --git a/include/net/netns/hash.h b/include/net/netns/hash.h index c06ac58ca10..548d78f2cc4 100644 --- a/include/net/netns/hash.h +++ b/include/net/netns/hash.h | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | struct net; | 6 | struct net; |
7 | 7 | ||
8 | static inline unsigned int net_hash_mix(struct net *net) | 8 | static inline unsigned net_hash_mix(struct net *net) |
9 | { | 9 | { |
10 | #ifdef CONFIG_NET_NS | 10 | #ifdef CONFIG_NET_NS |
11 | /* | 11 | /* |
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index 2ae2b8372cf..d786b4fc02a 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h | |||
@@ -5,15 +5,12 @@ | |||
5 | #ifndef __NETNS_IPV4_H__ | 5 | #ifndef __NETNS_IPV4_H__ |
6 | #define __NETNS_IPV4_H__ | 6 | #define __NETNS_IPV4_H__ |
7 | 7 | ||
8 | #include <linux/uidgid.h> | ||
9 | #include <net/inet_frag.h> | 8 | #include <net/inet_frag.h> |
10 | 9 | ||
11 | struct tcpm_hash_bucket; | ||
12 | struct ctl_table_header; | 10 | struct ctl_table_header; |
13 | struct ipv4_devconf; | 11 | struct ipv4_devconf; |
14 | struct fib_rules_ops; | 12 | struct fib_rules_ops; |
15 | struct hlist_head; | 13 | struct hlist_head; |
16 | struct fib_table; | ||
17 | struct sock; | 14 | struct sock; |
18 | 15 | ||
19 | struct netns_ipv4 { | 16 | struct netns_ipv4 { |
@@ -27,21 +24,13 @@ struct netns_ipv4 { | |||
27 | struct ipv4_devconf *devconf_dflt; | 24 | struct ipv4_devconf *devconf_dflt; |
28 | #ifdef CONFIG_IP_MULTIPLE_TABLES | 25 | #ifdef CONFIG_IP_MULTIPLE_TABLES |
29 | struct fib_rules_ops *rules_ops; | 26 | struct fib_rules_ops *rules_ops; |
30 | bool fib_has_custom_rules; | ||
31 | struct fib_table *fib_local; | ||
32 | struct fib_table *fib_main; | ||
33 | struct fib_table *fib_default; | ||
34 | #endif | ||
35 | #ifdef CONFIG_IP_ROUTE_CLASSID | ||
36 | int fib_num_tclassid_users; | ||
37 | #endif | 27 | #endif |
38 | struct hlist_head *fib_table_hash; | 28 | struct hlist_head *fib_table_hash; |
39 | struct sock *fibnl; | 29 | struct sock *fibnl; |
40 | 30 | ||
41 | struct sock **icmp_sk; | 31 | struct sock **icmp_sk; |
42 | struct inet_peer_base *peers; | 32 | struct sock *tcp_sock; |
43 | struct tcpm_hash_bucket *tcp_metrics_hash; | 33 | |
44 | unsigned int tcp_metrics_hash_log; | ||
45 | struct netns_frags frags; | 34 | struct netns_frags frags; |
46 | #ifdef CONFIG_NETFILTER | 35 | #ifdef CONFIG_NETFILTER |
47 | struct xt_table *iptable_filter; | 36 | struct xt_table *iptable_filter; |
@@ -52,6 +41,8 @@ struct netns_ipv4 { | |||
52 | struct xt_table *iptable_security; | 41 | struct xt_table *iptable_security; |
53 | #endif | 42 | #endif |
54 | struct xt_table *nat_table; | 43 | struct xt_table *nat_table; |
44 | struct hlist_head *nat_bysource; | ||
45 | unsigned int nat_htable_size; | ||
55 | #endif | 46 | #endif |
56 | 47 | ||
57 | int sysctl_icmp_echo_ignore_all; | 48 | int sysctl_icmp_echo_ignore_all; |
@@ -60,10 +51,12 @@ struct netns_ipv4 { | |||
60 | int sysctl_icmp_ratelimit; | 51 | int sysctl_icmp_ratelimit; |
61 | int sysctl_icmp_ratemask; | 52 | int sysctl_icmp_ratemask; |
62 | int sysctl_icmp_errors_use_inbound_ifaddr; | 53 | int sysctl_icmp_errors_use_inbound_ifaddr; |
54 | int sysctl_rt_cache_rebuild_count; | ||
55 | int current_rt_cache_rebuild_count; | ||
63 | 56 | ||
64 | kgid_t sysctl_ping_group_range[2]; | 57 | unsigned int sysctl_ping_group_range[2]; |
65 | long sysctl_tcp_mem[3]; | ||
66 | 58 | ||
59 | atomic_t rt_genid; | ||
67 | atomic_t dev_addr_genid; | 60 | atomic_t dev_addr_genid; |
68 | 61 | ||
69 | #ifdef CONFIG_IP_MROUTE | 62 | #ifdef CONFIG_IP_MROUTE |
diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h index 214cb0a5335..81abfcb2eb4 100644 --- a/include/net/netns/ipv6.h +++ b/include/net/netns/ipv6.h | |||
@@ -12,9 +12,7 @@ struct ctl_table_header; | |||
12 | 12 | ||
13 | struct netns_sysctl_ipv6 { | 13 | struct netns_sysctl_ipv6 { |
14 | #ifdef CONFIG_SYSCTL | 14 | #ifdef CONFIG_SYSCTL |
15 | struct ctl_table_header *hdr; | 15 | struct ctl_table_header *table; |
16 | struct ctl_table_header *route_hdr; | ||
17 | struct ctl_table_header *icmp_hdr; | ||
18 | struct ctl_table_header *frags_hdr; | 16 | struct ctl_table_header *frags_hdr; |
19 | #endif | 17 | #endif |
20 | int bindv6only; | 18 | int bindv6only; |
@@ -33,7 +31,6 @@ struct netns_ipv6 { | |||
33 | struct netns_sysctl_ipv6 sysctl; | 31 | struct netns_sysctl_ipv6 sysctl; |
34 | struct ipv6_devconf *devconf_all; | 32 | struct ipv6_devconf *devconf_all; |
35 | struct ipv6_devconf *devconf_dflt; | 33 | struct ipv6_devconf *devconf_dflt; |
36 | struct inet_peer_base *peers; | ||
37 | struct netns_frags frags; | 34 | struct netns_frags frags; |
38 | #ifdef CONFIG_NETFILTER | 35 | #ifdef CONFIG_NETFILTER |
39 | struct xt_table *ip6table_filter; | 36 | struct xt_table *ip6table_filter; |
@@ -42,7 +39,6 @@ struct netns_ipv6 { | |||
42 | #ifdef CONFIG_SECURITY | 39 | #ifdef CONFIG_SECURITY |
43 | struct xt_table *ip6table_security; | 40 | struct xt_table *ip6table_security; |
44 | #endif | 41 | #endif |
45 | struct xt_table *ip6table_nat; | ||
46 | #endif | 42 | #endif |
47 | struct rt6_info *ip6_null_entry; | 43 | struct rt6_info *ip6_null_entry; |
48 | struct rt6_statistics *rt6_stats; | 44 | struct rt6_statistics *rt6_stats; |
@@ -71,12 +67,4 @@ struct netns_ipv6 { | |||
71 | #endif | 67 | #endif |
72 | #endif | 68 | #endif |
73 | }; | 69 | }; |
74 | |||
75 | #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6) | ||
76 | struct netns_nf_frag { | ||
77 | struct netns_sysctl_ipv6 sysctl; | ||
78 | struct netns_frags frags; | ||
79 | }; | ||
80 | #endif | ||
81 | |||
82 | #endif | 70 | #endif |
diff --git a/include/net/netns/mib.h b/include/net/netns/mib.h index d542a4b28cc..0b44112e236 100644 --- a/include/net/netns/mib.h +++ b/include/net/netns/mib.h | |||
@@ -10,15 +10,15 @@ struct netns_mib { | |||
10 | DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); | 10 | DEFINE_SNMP_STAT(struct udp_mib, udp_statistics); |
11 | DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); | 11 | DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics); |
12 | DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); | 12 | DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics); |
13 | DEFINE_SNMP_STAT_ATOMIC(struct icmpmsg_mib, icmpmsg_statistics); | 13 | DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics); |
14 | 14 | ||
15 | #if IS_ENABLED(CONFIG_IPV6) | 15 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
16 | struct proc_dir_entry *proc_net_devsnmp6; | 16 | struct proc_dir_entry *proc_net_devsnmp6; |
17 | DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); | 17 | DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); |
18 | DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); | 18 | DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); |
19 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); | 19 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); |
20 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); | 20 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); |
21 | DEFINE_SNMP_STAT_ATOMIC(struct icmpv6msg_mib, icmpv6msg_statistics); | 21 | DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); |
22 | #endif | 22 | #endif |
23 | #ifdef CONFIG_XFRM_STATISTICS | 23 | #ifdef CONFIG_XFRM_STATISTICS |
24 | DEFINE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); | 24 | DEFINE_SNMP_STAT(struct linux_xfrm_mib, xfrm_statistics); |
diff --git a/include/net/netns/packet.h b/include/net/netns/packet.h index 17ec2b95c06..cb4e894c0f8 100644 --- a/include/net/netns/packet.h +++ b/include/net/netns/packet.h | |||
@@ -5,10 +5,10 @@ | |||
5 | #define __NETNS_PACKET_H__ | 5 | #define __NETNS_PACKET_H__ |
6 | 6 | ||
7 | #include <linux/rculist.h> | 7 | #include <linux/rculist.h> |
8 | #include <linux/mutex.h> | 8 | #include <linux/spinlock.h> |
9 | 9 | ||
10 | struct netns_packet { | 10 | struct netns_packet { |
11 | struct mutex sklist_lock; | 11 | spinlock_t sklist_lock; |
12 | struct hlist_head sklist; | 12 | struct hlist_head sklist; |
13 | }; | 13 | }; |
14 | 14 | ||
diff --git a/include/net/netns/sctp.h b/include/net/netns/sctp.h deleted file mode 100644 index 3573a81815a..00000000000 --- a/include/net/netns/sctp.h +++ /dev/null | |||
@@ -1,134 +0,0 @@ | |||
1 | #ifndef __NETNS_SCTP_H__ | ||
2 | #define __NETNS_SCTP_H__ | ||
3 | |||
4 | struct sock; | ||
5 | struct proc_dir_entry; | ||
6 | struct sctp_mib; | ||
7 | struct ctl_table_header; | ||
8 | |||
9 | struct netns_sctp { | ||
10 | DEFINE_SNMP_STAT(struct sctp_mib, sctp_statistics); | ||
11 | |||
12 | #ifdef CONFIG_PROC_FS | ||
13 | struct proc_dir_entry *proc_net_sctp; | ||
14 | #endif | ||
15 | #ifdef CONFIG_SYSCTL | ||
16 | struct ctl_table_header *sysctl_header; | ||
17 | #endif | ||
18 | /* This is the global socket data structure used for responding to | ||
19 | * the Out-of-the-blue (OOTB) packets. A control sock will be created | ||
20 | * for this socket at the initialization time. | ||
21 | */ | ||
22 | struct sock *ctl_sock; | ||
23 | |||
24 | /* This is the global local address list. | ||
25 | * We actively maintain this complete list of addresses on | ||
26 | * the system by catching address add/delete events. | ||
27 | * | ||
28 | * It is a list of sctp_sockaddr_entry. | ||
29 | */ | ||
30 | struct list_head local_addr_list; | ||
31 | struct list_head addr_waitq; | ||
32 | struct timer_list addr_wq_timer; | ||
33 | struct list_head auto_asconf_splist; | ||
34 | spinlock_t addr_wq_lock; | ||
35 | |||
36 | /* Lock that protects the local_addr_list writers */ | ||
37 | spinlock_t local_addr_lock; | ||
38 | |||
39 | /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values | ||
40 | * | ||
41 | * The following protocol parameters are RECOMMENDED: | ||
42 | * | ||
43 | * RTO.Initial - 3 seconds | ||
44 | * RTO.Min - 1 second | ||
45 | * RTO.Max - 60 seconds | ||
46 | * RTO.Alpha - 1/8 (3 when converted to right shifts.) | ||
47 | * RTO.Beta - 1/4 (2 when converted to right shifts.) | ||
48 | */ | ||
49 | unsigned int rto_initial; | ||
50 | unsigned int rto_min; | ||
51 | unsigned int rto_max; | ||
52 | |||
53 | /* Note: rto_alpha and rto_beta are really defined as inverse | ||
54 | * powers of two to facilitate integer operations. | ||
55 | */ | ||
56 | int rto_alpha; | ||
57 | int rto_beta; | ||
58 | |||
59 | /* Max.Burst - 4 */ | ||
60 | int max_burst; | ||
61 | |||
62 | /* Whether Cookie Preservative is enabled(1) or not(0) */ | ||
63 | int cookie_preserve_enable; | ||
64 | |||
65 | /* The namespace default hmac alg */ | ||
66 | char *sctp_hmac_alg; | ||
67 | |||
68 | /* Valid.Cookie.Life - 60 seconds */ | ||
69 | unsigned int valid_cookie_life; | ||
70 | |||
71 | /* Delayed SACK timeout 200ms default*/ | ||
72 | unsigned int sack_timeout; | ||
73 | |||
74 | /* HB.interval - 30 seconds */ | ||
75 | unsigned int hb_interval; | ||
76 | |||
77 | /* Association.Max.Retrans - 10 attempts | ||
78 | * Path.Max.Retrans - 5 attempts (per destination address) | ||
79 | * Max.Init.Retransmits - 8 attempts | ||
80 | */ | ||
81 | int max_retrans_association; | ||
82 | int max_retrans_path; | ||
83 | int max_retrans_init; | ||
84 | /* Potentially-Failed.Max.Retrans sysctl value | ||
85 | * taken from: | ||
86 | * http://tools.ietf.org/html/draft-nishida-tsvwg-sctp-failover-05 | ||
87 | */ | ||
88 | int pf_retrans; | ||
89 | |||
90 | /* | ||
91 | * Policy for preforming sctp/socket accounting | ||
92 | * 0 - do socket level accounting, all assocs share sk_sndbuf | ||
93 | * 1 - do sctp accounting, each asoc may use sk_sndbuf bytes | ||
94 | */ | ||
95 | int sndbuf_policy; | ||
96 | |||
97 | /* | ||
98 | * Policy for preforming sctp/socket accounting | ||
99 | * 0 - do socket level accounting, all assocs share sk_rcvbuf | ||
100 | * 1 - do sctp accounting, each asoc may use sk_rcvbuf bytes | ||
101 | */ | ||
102 | int rcvbuf_policy; | ||
103 | |||
104 | int default_auto_asconf; | ||
105 | |||
106 | /* Flag to indicate if addip is enabled. */ | ||
107 | int addip_enable; | ||
108 | int addip_noauth; | ||
109 | |||
110 | /* Flag to indicate if PR-SCTP is enabled. */ | ||
111 | int prsctp_enable; | ||
112 | |||
113 | /* Flag to idicate if SCTP-AUTH is enabled */ | ||
114 | int auth_enable; | ||
115 | |||
116 | /* | ||
117 | * Policy to control SCTP IPv4 address scoping | ||
118 | * 0 - Disable IPv4 address scoping | ||
119 | * 1 - Enable IPv4 address scoping | ||
120 | * 2 - Selectively allow only IPv4 private addresses | ||
121 | * 3 - Selectively allow only IPv4 link local address | ||
122 | */ | ||
123 | int scope_policy; | ||
124 | |||
125 | /* Threshold for rwnd update SACKS. Receive buffer shifted this many | ||
126 | * bits is an indicator of when to send and window update SACK. | ||
127 | */ | ||
128 | int rwnd_upd_shift; | ||
129 | |||
130 | /* Threshold for autoclose timeout, in seconds. */ | ||
131 | unsigned long max_autoclose; | ||
132 | }; | ||
133 | |||
134 | #endif /* __NETNS_SCTP_H__ */ | ||
diff --git a/include/net/netns/x_tables.h b/include/net/netns/x_tables.h index c24060ee411..591db7d657a 100644 --- a/include/net/netns/x_tables.h +++ b/include/net/netns/x_tables.h | |||
@@ -8,7 +8,6 @@ struct ebt_table; | |||
8 | 8 | ||
9 | struct netns_xt { | 9 | struct netns_xt { |
10 | struct list_head tables[NFPROTO_NUMPROTO]; | 10 | struct list_head tables[NFPROTO_NUMPROTO]; |
11 | bool notrack_deprecated_warning; | ||
12 | #if defined(CONFIG_BRIDGE_NF_EBTABLES) || \ | 11 | #if defined(CONFIG_BRIDGE_NF_EBTABLES) || \ |
13 | defined(CONFIG_BRIDGE_NF_EBTABLES_MODULE) | 12 | defined(CONFIG_BRIDGE_NF_EBTABLES_MODULE) |
14 | struct ebt_table *broute_table; | 13 | struct ebt_table *broute_table; |
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h index 5299e69a32a..748f91f87cd 100644 --- a/include/net/netns/xfrm.h +++ b/include/net/netns/xfrm.h | |||
@@ -56,7 +56,7 @@ struct netns_xfrm { | |||
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | struct dst_ops xfrm4_dst_ops; | 58 | struct dst_ops xfrm4_dst_ops; |
59 | #if IS_ENABLED(CONFIG_IPV6) | 59 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
60 | struct dst_ops xfrm6_dst_ops; | 60 | struct dst_ops xfrm6_dst_ops; |
61 | #endif | 61 | #endif |
62 | }; | 62 | }; |
diff --git a/include/net/netprio_cgroup.h b/include/net/netprio_cgroup.h deleted file mode 100644 index 1d04b6f0fbd..00000000000 --- a/include/net/netprio_cgroup.h +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | /* | ||
2 | * netprio_cgroup.h Control Group Priority set | ||
3 | * | ||
4 | * | ||
5 | * Authors: Neil Horman <nhorman@tuxdriver.com> | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the Free | ||
9 | * Software Foundation; either version 2 of the License, or (at your option) | ||
10 | * any later version. | ||
11 | * | ||
12 | */ | ||
13 | |||
14 | #ifndef _NETPRIO_CGROUP_H | ||
15 | #define _NETPRIO_CGROUP_H | ||
16 | #include <linux/cgroup.h> | ||
17 | #include <linux/hardirq.h> | ||
18 | #include <linux/rcupdate.h> | ||
19 | |||
20 | |||
21 | #if IS_ENABLED(CONFIG_NETPRIO_CGROUP) | ||
22 | struct netprio_map { | ||
23 | struct rcu_head rcu; | ||
24 | u32 priomap_len; | ||
25 | u32 priomap[]; | ||
26 | }; | ||
27 | |||
28 | struct cgroup_netprio_state { | ||
29 | struct cgroup_subsys_state css; | ||
30 | }; | ||
31 | |||
32 | extern void sock_update_netprioidx(struct sock *sk, struct task_struct *task); | ||
33 | |||
34 | #if IS_BUILTIN(CONFIG_NETPRIO_CGROUP) | ||
35 | |||
36 | static inline u32 task_netprioidx(struct task_struct *p) | ||
37 | { | ||
38 | struct cgroup_subsys_state *css; | ||
39 | u32 idx; | ||
40 | |||
41 | rcu_read_lock(); | ||
42 | css = task_subsys_state(p, net_prio_subsys_id); | ||
43 | idx = css->cgroup->id; | ||
44 | rcu_read_unlock(); | ||
45 | return idx; | ||
46 | } | ||
47 | |||
48 | #elif IS_MODULE(CONFIG_NETPRIO_CGROUP) | ||
49 | |||
50 | static inline u32 task_netprioidx(struct task_struct *p) | ||
51 | { | ||
52 | struct cgroup_subsys_state *css; | ||
53 | u32 idx = 0; | ||
54 | |||
55 | rcu_read_lock(); | ||
56 | css = task_subsys_state(p, net_prio_subsys_id); | ||
57 | if (css) | ||
58 | idx = css->cgroup->id; | ||
59 | rcu_read_unlock(); | ||
60 | return idx; | ||
61 | } | ||
62 | #endif | ||
63 | |||
64 | #else /* !CONFIG_NETPRIO_CGROUP */ | ||
65 | |||
66 | static inline u32 task_netprioidx(struct task_struct *p) | ||
67 | { | ||
68 | return 0; | ||
69 | } | ||
70 | |||
71 | #define sock_update_netprioidx(sk, task) | ||
72 | |||
73 | #endif /* CONFIG_NETPRIO_CGROUP */ | ||
74 | |||
75 | #endif /* _NET_CLS_CGROUP_H */ | ||
diff --git a/include/net/nfc/hci.h b/include/net/nfc/hci.h deleted file mode 100644 index 671953e1157..00000000000 --- a/include/net/nfc/hci.h +++ /dev/null | |||
@@ -1,242 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Intel Corporation. All rights reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | */ | ||
19 | |||
20 | #ifndef __NET_HCI_H | ||
21 | #define __NET_HCI_H | ||
22 | |||
23 | #include <linux/skbuff.h> | ||
24 | |||
25 | #include <net/nfc/nfc.h> | ||
26 | |||
27 | struct nfc_phy_ops { | ||
28 | int (*write)(void *dev_id, struct sk_buff *skb); | ||
29 | int (*enable)(void *dev_id); | ||
30 | void (*disable)(void *dev_id); | ||
31 | }; | ||
32 | |||
33 | struct nfc_hci_dev; | ||
34 | |||
35 | struct nfc_hci_ops { | ||
36 | int (*open) (struct nfc_hci_dev *hdev); | ||
37 | void (*close) (struct nfc_hci_dev *hdev); | ||
38 | int (*hci_ready) (struct nfc_hci_dev *hdev); | ||
39 | /* | ||
40 | * xmit must always send the complete buffer before | ||
41 | * returning. Returned result must be 0 for success | ||
42 | * or negative for failure. | ||
43 | */ | ||
44 | int (*xmit) (struct nfc_hci_dev *hdev, struct sk_buff *skb); | ||
45 | int (*start_poll) (struct nfc_hci_dev *hdev, | ||
46 | u32 im_protocols, u32 tm_protocols); | ||
47 | int (*dep_link_up)(struct nfc_hci_dev *hdev, struct nfc_target *target, | ||
48 | u8 comm_mode, u8 *gb, size_t gb_len); | ||
49 | int (*dep_link_down)(struct nfc_hci_dev *hdev); | ||
50 | int (*target_from_gate) (struct nfc_hci_dev *hdev, u8 gate, | ||
51 | struct nfc_target *target); | ||
52 | int (*complete_target_discovered) (struct nfc_hci_dev *hdev, u8 gate, | ||
53 | struct nfc_target *target); | ||
54 | int (*im_transceive) (struct nfc_hci_dev *hdev, | ||
55 | struct nfc_target *target, struct sk_buff *skb, | ||
56 | data_exchange_cb_t cb, void *cb_context); | ||
57 | int (*tm_send)(struct nfc_hci_dev *hdev, struct sk_buff *skb); | ||
58 | int (*check_presence)(struct nfc_hci_dev *hdev, | ||
59 | struct nfc_target *target); | ||
60 | void (*event_received)(struct nfc_hci_dev *hdev, u8 gate, u8 event, | ||
61 | struct sk_buff *skb); | ||
62 | }; | ||
63 | |||
64 | /* Pipes */ | ||
65 | #define NFC_HCI_INVALID_PIPE 0x80 | ||
66 | #define NFC_HCI_LINK_MGMT_PIPE 0x00 | ||
67 | #define NFC_HCI_ADMIN_PIPE 0x01 | ||
68 | |||
69 | struct nfc_hci_gate { | ||
70 | u8 gate; | ||
71 | u8 pipe; | ||
72 | }; | ||
73 | |||
74 | #define NFC_HCI_MAX_CUSTOM_GATES 50 | ||
75 | struct nfc_hci_init_data { | ||
76 | u8 gate_count; | ||
77 | struct nfc_hci_gate gates[NFC_HCI_MAX_CUSTOM_GATES]; | ||
78 | char session_id[9]; | ||
79 | }; | ||
80 | |||
81 | typedef int (*xmit) (struct sk_buff *skb, void *cb_data); | ||
82 | |||
83 | #define NFC_HCI_MAX_GATES 256 | ||
84 | |||
85 | struct nfc_hci_dev { | ||
86 | struct nfc_dev *ndev; | ||
87 | |||
88 | u32 max_data_link_payload; | ||
89 | |||
90 | struct mutex msg_tx_mutex; | ||
91 | |||
92 | struct list_head msg_tx_queue; | ||
93 | |||
94 | struct work_struct msg_tx_work; | ||
95 | |||
96 | struct timer_list cmd_timer; | ||
97 | struct hci_msg *cmd_pending_msg; | ||
98 | |||
99 | struct sk_buff_head rx_hcp_frags; | ||
100 | |||
101 | struct work_struct msg_rx_work; | ||
102 | |||
103 | struct sk_buff_head msg_rx_queue; | ||
104 | |||
105 | struct nfc_hci_ops *ops; | ||
106 | |||
107 | struct nfc_llc *llc; | ||
108 | |||
109 | struct nfc_hci_init_data init_data; | ||
110 | |||
111 | void *clientdata; | ||
112 | |||
113 | u8 gate2pipe[NFC_HCI_MAX_GATES]; | ||
114 | |||
115 | u8 sw_romlib; | ||
116 | u8 sw_patch; | ||
117 | u8 sw_flashlib_major; | ||
118 | u8 sw_flashlib_minor; | ||
119 | |||
120 | u8 hw_derivative; | ||
121 | u8 hw_version; | ||
122 | u8 hw_mpw; | ||
123 | u8 hw_software; | ||
124 | u8 hw_bsid; | ||
125 | |||
126 | int async_cb_type; | ||
127 | data_exchange_cb_t async_cb; | ||
128 | void *async_cb_context; | ||
129 | |||
130 | u8 *gb; | ||
131 | size_t gb_len; | ||
132 | }; | ||
133 | |||
134 | /* hci device allocation */ | ||
135 | struct nfc_hci_dev *nfc_hci_allocate_device(struct nfc_hci_ops *ops, | ||
136 | struct nfc_hci_init_data *init_data, | ||
137 | u32 protocols, | ||
138 | const char *llc_name, | ||
139 | int tx_headroom, | ||
140 | int tx_tailroom, | ||
141 | int max_link_payload); | ||
142 | void nfc_hci_free_device(struct nfc_hci_dev *hdev); | ||
143 | |||
144 | int nfc_hci_register_device(struct nfc_hci_dev *hdev); | ||
145 | void nfc_hci_unregister_device(struct nfc_hci_dev *hdev); | ||
146 | |||
147 | void nfc_hci_set_clientdata(struct nfc_hci_dev *hdev, void *clientdata); | ||
148 | void *nfc_hci_get_clientdata(struct nfc_hci_dev *hdev); | ||
149 | |||
150 | void nfc_hci_driver_failure(struct nfc_hci_dev *hdev, int err); | ||
151 | |||
152 | int nfc_hci_result_to_errno(u8 result); | ||
153 | |||
154 | /* Host IDs */ | ||
155 | #define NFC_HCI_HOST_CONTROLLER_ID 0x00 | ||
156 | #define NFC_HCI_TERMINAL_HOST_ID 0x01 | ||
157 | #define NFC_HCI_UICC_HOST_ID 0x02 | ||
158 | |||
159 | /* Host Controller Gates and registry indexes */ | ||
160 | #define NFC_HCI_ADMIN_GATE 0x00 | ||
161 | #define NFC_HCI_ADMIN_SESSION_IDENTITY 0x01 | ||
162 | #define NFC_HCI_ADMIN_MAX_PIPE 0x02 | ||
163 | #define NFC_HCI_ADMIN_WHITELIST 0x03 | ||
164 | #define NFC_HCI_ADMIN_HOST_LIST 0x04 | ||
165 | |||
166 | #define NFC_HCI_LOOPBACK_GATE 0x04 | ||
167 | |||
168 | #define NFC_HCI_ID_MGMT_GATE 0x05 | ||
169 | #define NFC_HCI_ID_MGMT_VERSION_SW 0x01 | ||
170 | #define NFC_HCI_ID_MGMT_VERSION_HW 0x03 | ||
171 | #define NFC_HCI_ID_MGMT_VENDOR_NAME 0x04 | ||
172 | #define NFC_HCI_ID_MGMT_MODEL_ID 0x05 | ||
173 | #define NFC_HCI_ID_MGMT_HCI_VERSION 0x02 | ||
174 | #define NFC_HCI_ID_MGMT_GATES_LIST 0x06 | ||
175 | |||
176 | #define NFC_HCI_LINK_MGMT_GATE 0x06 | ||
177 | #define NFC_HCI_LINK_MGMT_REC_ERROR 0x01 | ||
178 | |||
179 | #define NFC_HCI_RF_READER_B_GATE 0x11 | ||
180 | #define NFC_HCI_RF_READER_B_PUPI 0x03 | ||
181 | #define NFC_HCI_RF_READER_B_APPLICATION_DATA 0x04 | ||
182 | #define NFC_HCI_RF_READER_B_AFI 0x02 | ||
183 | #define NFC_HCI_RF_READER_B_HIGHER_LAYER_RESPONSE 0x01 | ||
184 | #define NFC_HCI_RF_READER_B_HIGHER_LAYER_DATA 0x05 | ||
185 | |||
186 | #define NFC_HCI_RF_READER_A_GATE 0x13 | ||
187 | #define NFC_HCI_RF_READER_A_UID 0x02 | ||
188 | #define NFC_HCI_RF_READER_A_ATQA 0x04 | ||
189 | #define NFC_HCI_RF_READER_A_APPLICATION_DATA 0x05 | ||
190 | #define NFC_HCI_RF_READER_A_SAK 0x03 | ||
191 | #define NFC_HCI_RF_READER_A_FWI_SFGT 0x06 | ||
192 | #define NFC_HCI_RF_READER_A_DATARATE_MAX 0x01 | ||
193 | |||
194 | #define NFC_HCI_TYPE_A_SEL_PROT(x) (((x) & 0x60) >> 5) | ||
195 | #define NFC_HCI_TYPE_A_SEL_PROT_MIFARE 0 | ||
196 | #define NFC_HCI_TYPE_A_SEL_PROT_ISO14443 1 | ||
197 | #define NFC_HCI_TYPE_A_SEL_PROT_DEP 2 | ||
198 | #define NFC_HCI_TYPE_A_SEL_PROT_ISO14443_DEP 3 | ||
199 | |||
200 | /* Generic events */ | ||
201 | #define NFC_HCI_EVT_HCI_END_OF_OPERATION 0x01 | ||
202 | #define NFC_HCI_EVT_POST_DATA 0x02 | ||
203 | #define NFC_HCI_EVT_HOT_PLUG 0x03 | ||
204 | |||
205 | /* Reader RF gates events */ | ||
206 | #define NFC_HCI_EVT_READER_REQUESTED 0x10 | ||
207 | #define NFC_HCI_EVT_END_OPERATION 0x11 | ||
208 | |||
209 | /* Reader Application gate events */ | ||
210 | #define NFC_HCI_EVT_TARGET_DISCOVERED 0x10 | ||
211 | |||
212 | /* receiving messages from lower layer */ | ||
213 | void nfc_hci_resp_received(struct nfc_hci_dev *hdev, u8 result, | ||
214 | struct sk_buff *skb); | ||
215 | void nfc_hci_cmd_received(struct nfc_hci_dev *hdev, u8 pipe, u8 cmd, | ||
216 | struct sk_buff *skb); | ||
217 | void nfc_hci_event_received(struct nfc_hci_dev *hdev, u8 pipe, u8 event, | ||
218 | struct sk_buff *skb); | ||
219 | void nfc_hci_recv_frame(struct nfc_hci_dev *hdev, struct sk_buff *skb); | ||
220 | |||
221 | /* connecting to gates and sending hci instructions */ | ||
222 | int nfc_hci_connect_gate(struct nfc_hci_dev *hdev, u8 dest_host, u8 dest_gate, | ||
223 | u8 pipe); | ||
224 | int nfc_hci_disconnect_gate(struct nfc_hci_dev *hdev, u8 gate); | ||
225 | int nfc_hci_disconnect_all_gates(struct nfc_hci_dev *hdev); | ||
226 | int nfc_hci_get_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx, | ||
227 | struct sk_buff **skb); | ||
228 | int nfc_hci_set_param(struct nfc_hci_dev *hdev, u8 gate, u8 idx, | ||
229 | const u8 *param, size_t param_len); | ||
230 | int nfc_hci_send_cmd(struct nfc_hci_dev *hdev, u8 gate, u8 cmd, | ||
231 | const u8 *param, size_t param_len, struct sk_buff **skb); | ||
232 | int nfc_hci_send_cmd_async(struct nfc_hci_dev *hdev, u8 gate, u8 cmd, | ||
233 | const u8 *param, size_t param_len, | ||
234 | data_exchange_cb_t cb, void *cb_context); | ||
235 | int nfc_hci_send_response(struct nfc_hci_dev *hdev, u8 gate, u8 response, | ||
236 | const u8 *param, size_t param_len); | ||
237 | int nfc_hci_send_event(struct nfc_hci_dev *hdev, u8 gate, u8 event, | ||
238 | const u8 *param, size_t param_len); | ||
239 | int nfc_hci_target_discovered(struct nfc_hci_dev *hdev, u8 gate); | ||
240 | u32 nfc_hci_sak_to_protocol(u8 sak); | ||
241 | |||
242 | #endif /* __NET_HCI_H */ | ||
diff --git a/include/net/nfc/llc.h b/include/net/nfc/llc.h deleted file mode 100644 index 400ab7ae749..00000000000 --- a/include/net/nfc/llc.h +++ /dev/null | |||
@@ -1,54 +0,0 @@ | |||
1 | /* | ||
2 | * Link Layer Control manager public interface | ||
3 | * | ||
4 | * Copyright (C) 2012 Intel Corporation. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, | ||
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | * GNU General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the | ||
17 | * Free Software Foundation, Inc., | ||
18 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | #ifndef __NFC_LLC_H_ | ||
22 | #define __NFC_LLC_H_ | ||
23 | |||
24 | #include <net/nfc/hci.h> | ||
25 | #include <linux/skbuff.h> | ||
26 | |||
27 | #define LLC_NOP_NAME "nop" | ||
28 | #define LLC_SHDLC_NAME "shdlc" | ||
29 | |||
30 | typedef void (*rcv_to_hci_t) (struct nfc_hci_dev *hdev, struct sk_buff *skb); | ||
31 | typedef int (*xmit_to_drv_t) (struct nfc_hci_dev *hdev, struct sk_buff *skb); | ||
32 | typedef void (*llc_failure_t) (struct nfc_hci_dev *hdev, int err); | ||
33 | |||
34 | struct nfc_llc; | ||
35 | |||
36 | struct nfc_llc *nfc_llc_allocate(const char *name, struct nfc_hci_dev *hdev, | ||
37 | xmit_to_drv_t xmit_to_drv, | ||
38 | rcv_to_hci_t rcv_to_hci, int tx_headroom, | ||
39 | int tx_tailroom, llc_failure_t llc_failure); | ||
40 | void nfc_llc_free(struct nfc_llc *llc); | ||
41 | |||
42 | void nfc_llc_get_rx_head_tail_room(struct nfc_llc *llc, int *rx_headroom, | ||
43 | int *rx_tailroom); | ||
44 | |||
45 | |||
46 | int nfc_llc_start(struct nfc_llc *llc); | ||
47 | int nfc_llc_stop(struct nfc_llc *llc); | ||
48 | void nfc_llc_rcv_from_drv(struct nfc_llc *llc, struct sk_buff *skb); | ||
49 | int nfc_llc_xmit_from_hci(struct nfc_llc *llc, struct sk_buff *skb); | ||
50 | |||
51 | int nfc_llc_init(void); | ||
52 | void nfc_llc_exit(void); | ||
53 | |||
54 | #endif /* __NFC_LLC_H_ */ | ||
diff --git a/include/net/nfc/nci.h b/include/net/nfc/nci.h deleted file mode 100644 index 88785e5c6b2..00000000000 --- a/include/net/nfc/nci.h +++ /dev/null | |||
@@ -1,393 +0,0 @@ | |||
1 | /* | ||
2 | * The NFC Controller Interface is the communication protocol between an | ||
3 | * NFC Controller (NFCC) and a Device Host (DH). | ||
4 | * | ||
5 | * Copyright (C) 2011 Texas Instruments, Inc. | ||
6 | * | ||
7 | * Written by Ilan Elias <ilane@ti.com> | ||
8 | * | ||
9 | * Acknowledgements: | ||
10 | * This file is based on hci.h, which was written | ||
11 | * by Maxim Krasnyansky. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License version 2 | ||
15 | * as published by the Free Software Foundation | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #ifndef __NCI_H | ||
29 | #define __NCI_H | ||
30 | |||
31 | /* NCI constants */ | ||
32 | #define NCI_MAX_NUM_MAPPING_CONFIGS 10 | ||
33 | #define NCI_MAX_NUM_RF_CONFIGS 10 | ||
34 | #define NCI_MAX_NUM_CONN 10 | ||
35 | #define NCI_MAX_PARAM_LEN 251 | ||
36 | |||
37 | /* NCI Status Codes */ | ||
38 | #define NCI_STATUS_OK 0x00 | ||
39 | #define NCI_STATUS_REJECTED 0x01 | ||
40 | #define NCI_STATUS_RF_FRAME_CORRUPTED 0x02 | ||
41 | #define NCI_STATUS_FAILED 0x03 | ||
42 | #define NCI_STATUS_NOT_INITIALIZED 0x04 | ||
43 | #define NCI_STATUS_SYNTAX_ERROR 0x05 | ||
44 | #define NCI_STATUS_SEMANTIC_ERROR 0x06 | ||
45 | #define NCI_STATUS_UNKNOWN_GID 0x07 | ||
46 | #define NCI_STATUS_UNKNOWN_OID 0x08 | ||
47 | #define NCI_STATUS_INVALID_PARAM 0x09 | ||
48 | #define NCI_STATUS_MESSAGE_SIZE_EXCEEDED 0x0a | ||
49 | /* Discovery Specific Status Codes */ | ||
50 | #define NCI_STATUS_DISCOVERY_ALREADY_STARTED 0xa0 | ||
51 | #define NCI_STATUS_DISCOVERY_TARGET_ACTIVATION_FAILED 0xa1 | ||
52 | #define NCI_STATUS_DISCOVERY_TEAR_DOWN 0xa2 | ||
53 | /* RF Interface Specific Status Codes */ | ||
54 | #define NCI_STATUS_RF_TRANSMISSION_ERROR 0xb0 | ||
55 | #define NCI_STATUS_RF_PROTOCOL_ERROR 0xb1 | ||
56 | #define NCI_STATUS_RF_TIMEOUT_ERROR 0xb2 | ||
57 | /* NFCEE Interface Specific Status Codes */ | ||
58 | #define NCI_STATUS_NFCEE_INTERFACE_ACTIVATION_FAILED 0xc0 | ||
59 | #define NCI_STATUS_NFCEE_TRANSMISSION_ERROR 0xc1 | ||
60 | #define NCI_STATUS_NFCEE_PROTOCOL_ERROR 0xc2 | ||
61 | #define NCI_STATUS_NFCEE_TIMEOUT_ERROR 0xc3 | ||
62 | |||
63 | /* NCI RF Technology and Mode */ | ||
64 | #define NCI_NFC_A_PASSIVE_POLL_MODE 0x00 | ||
65 | #define NCI_NFC_B_PASSIVE_POLL_MODE 0x01 | ||
66 | #define NCI_NFC_F_PASSIVE_POLL_MODE 0x02 | ||
67 | #define NCI_NFC_A_ACTIVE_POLL_MODE 0x03 | ||
68 | #define NCI_NFC_F_ACTIVE_POLL_MODE 0x05 | ||
69 | #define NCI_NFC_15693_PASSIVE_POLL_MODE 0x06 | ||
70 | #define NCI_NFC_A_PASSIVE_LISTEN_MODE 0x80 | ||
71 | #define NCI_NFC_B_PASSIVE_LISTEN_MODE 0x81 | ||
72 | #define NCI_NFC_F_PASSIVE_LISTEN_MODE 0x82 | ||
73 | #define NCI_NFC_A_ACTIVE_LISTEN_MODE 0x83 | ||
74 | #define NCI_NFC_F_ACTIVE_LISTEN_MODE 0x85 | ||
75 | #define NCI_NFC_15693_PASSIVE_LISTEN_MODE 0x86 | ||
76 | |||
77 | /* NCI RF Technologies */ | ||
78 | #define NCI_NFC_RF_TECHNOLOGY_A 0x00 | ||
79 | #define NCI_NFC_RF_TECHNOLOGY_B 0x01 | ||
80 | #define NCI_NFC_RF_TECHNOLOGY_F 0x02 | ||
81 | #define NCI_NFC_RF_TECHNOLOGY_15693 0x03 | ||
82 | |||
83 | /* NCI Bit Rates */ | ||
84 | #define NCI_NFC_BIT_RATE_106 0x00 | ||
85 | #define NCI_NFC_BIT_RATE_212 0x01 | ||
86 | #define NCI_NFC_BIT_RATE_424 0x02 | ||
87 | #define NCI_NFC_BIT_RATE_848 0x03 | ||
88 | #define NCI_NFC_BIT_RATE_1695 0x04 | ||
89 | #define NCI_NFC_BIT_RATE_3390 0x05 | ||
90 | #define NCI_NFC_BIT_RATE_6780 0x06 | ||
91 | |||
92 | /* NCI RF Protocols */ | ||
93 | #define NCI_RF_PROTOCOL_UNKNOWN 0x00 | ||
94 | #define NCI_RF_PROTOCOL_T1T 0x01 | ||
95 | #define NCI_RF_PROTOCOL_T2T 0x02 | ||
96 | #define NCI_RF_PROTOCOL_T3T 0x03 | ||
97 | #define NCI_RF_PROTOCOL_ISO_DEP 0x04 | ||
98 | #define NCI_RF_PROTOCOL_NFC_DEP 0x05 | ||
99 | |||
100 | /* NCI RF Interfaces */ | ||
101 | #define NCI_RF_INTERFACE_NFCEE_DIRECT 0x00 | ||
102 | #define NCI_RF_INTERFACE_FRAME 0x01 | ||
103 | #define NCI_RF_INTERFACE_ISO_DEP 0x02 | ||
104 | #define NCI_RF_INTERFACE_NFC_DEP 0x03 | ||
105 | |||
106 | /* NCI Configuration Parameter Tags */ | ||
107 | #define NCI_PN_ATR_REQ_GEN_BYTES 0x29 | ||
108 | |||
109 | /* NCI Reset types */ | ||
110 | #define NCI_RESET_TYPE_KEEP_CONFIG 0x00 | ||
111 | #define NCI_RESET_TYPE_RESET_CONFIG 0x01 | ||
112 | |||
113 | /* NCI Static RF connection ID */ | ||
114 | #define NCI_STATIC_RF_CONN_ID 0x00 | ||
115 | |||
116 | /* NCI Data Flow Control */ | ||
117 | #define NCI_DATA_FLOW_CONTROL_NOT_USED 0xff | ||
118 | |||
119 | /* NCI RF_DISCOVER_MAP_CMD modes */ | ||
120 | #define NCI_DISC_MAP_MODE_POLL 0x01 | ||
121 | #define NCI_DISC_MAP_MODE_LISTEN 0x02 | ||
122 | |||
123 | /* NCI Discover Notification Type */ | ||
124 | #define NCI_DISCOVER_NTF_TYPE_LAST 0x00 | ||
125 | #define NCI_DISCOVER_NTF_TYPE_LAST_NFCC 0x01 | ||
126 | #define NCI_DISCOVER_NTF_TYPE_MORE 0x02 | ||
127 | |||
128 | /* NCI Deactivation Type */ | ||
129 | #define NCI_DEACTIVATE_TYPE_IDLE_MODE 0x00 | ||
130 | #define NCI_DEACTIVATE_TYPE_SLEEP_MODE 0x01 | ||
131 | #define NCI_DEACTIVATE_TYPE_SLEEP_AF_MODE 0x02 | ||
132 | #define NCI_DEACTIVATE_TYPE_DISCOVERY 0x03 | ||
133 | |||
134 | /* Message Type (MT) */ | ||
135 | #define NCI_MT_DATA_PKT 0x00 | ||
136 | #define NCI_MT_CMD_PKT 0x01 | ||
137 | #define NCI_MT_RSP_PKT 0x02 | ||
138 | #define NCI_MT_NTF_PKT 0x03 | ||
139 | |||
140 | #define nci_mt(hdr) (((hdr)[0]>>5)&0x07) | ||
141 | #define nci_mt_set(hdr, mt) ((hdr)[0] |= (__u8)(((mt)&0x07)<<5)) | ||
142 | |||
143 | /* Packet Boundary Flag (PBF) */ | ||
144 | #define NCI_PBF_LAST 0x00 | ||
145 | #define NCI_PBF_CONT 0x01 | ||
146 | |||
147 | #define nci_pbf(hdr) (__u8)(((hdr)[0]>>4)&0x01) | ||
148 | #define nci_pbf_set(hdr, pbf) ((hdr)[0] |= (__u8)(((pbf)&0x01)<<4)) | ||
149 | |||
150 | /* Control Opcode manipulation */ | ||
151 | #define nci_opcode_pack(gid, oid) (__u16)((((__u16)((gid)&0x0f))<<8)|\ | ||
152 | ((__u16)((oid)&0x3f))) | ||
153 | #define nci_opcode(hdr) nci_opcode_pack(hdr[0], hdr[1]) | ||
154 | #define nci_opcode_gid(op) (__u8)(((op)&0x0f00)>>8) | ||
155 | #define nci_opcode_oid(op) (__u8)((op)&0x003f) | ||
156 | |||
157 | /* Payload Length */ | ||
158 | #define nci_plen(hdr) (__u8)((hdr)[2]) | ||
159 | |||
160 | /* Connection ID */ | ||
161 | #define nci_conn_id(hdr) (__u8)(((hdr)[0])&0x0f) | ||
162 | |||
163 | /* GID values */ | ||
164 | #define NCI_GID_CORE 0x0 | ||
165 | #define NCI_GID_RF_MGMT 0x1 | ||
166 | #define NCI_GID_NFCEE_MGMT 0x2 | ||
167 | #define NCI_GID_PROPRIETARY 0xf | ||
168 | |||
169 | /* ---- NCI Packet structures ---- */ | ||
170 | #define NCI_CTRL_HDR_SIZE 3 | ||
171 | #define NCI_DATA_HDR_SIZE 3 | ||
172 | |||
173 | struct nci_ctrl_hdr { | ||
174 | __u8 gid; /* MT & PBF & GID */ | ||
175 | __u8 oid; | ||
176 | __u8 plen; | ||
177 | } __packed; | ||
178 | |||
179 | struct nci_data_hdr { | ||
180 | __u8 conn_id; /* MT & PBF & ConnID */ | ||
181 | __u8 rfu; | ||
182 | __u8 plen; | ||
183 | } __packed; | ||
184 | |||
185 | /* ------------------------ */ | ||
186 | /* ----- NCI Commands ---- */ | ||
187 | /* ------------------------ */ | ||
188 | #define NCI_OP_CORE_RESET_CMD nci_opcode_pack(NCI_GID_CORE, 0x00) | ||
189 | struct nci_core_reset_cmd { | ||
190 | __u8 reset_type; | ||
191 | } __packed; | ||
192 | |||
193 | #define NCI_OP_CORE_INIT_CMD nci_opcode_pack(NCI_GID_CORE, 0x01) | ||
194 | |||
195 | #define NCI_OP_CORE_SET_CONFIG_CMD nci_opcode_pack(NCI_GID_CORE, 0x02) | ||
196 | struct set_config_param { | ||
197 | __u8 id; | ||
198 | __u8 len; | ||
199 | __u8 val[NCI_MAX_PARAM_LEN]; | ||
200 | } __packed; | ||
201 | |||
202 | struct nci_core_set_config_cmd { | ||
203 | __u8 num_params; | ||
204 | struct set_config_param param; /* support 1 param per cmd is enough */ | ||
205 | } __packed; | ||
206 | |||
207 | #define NCI_OP_RF_DISCOVER_MAP_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) | ||
208 | struct disc_map_config { | ||
209 | __u8 rf_protocol; | ||
210 | __u8 mode; | ||
211 | __u8 rf_interface; | ||
212 | } __packed; | ||
213 | |||
214 | struct nci_rf_disc_map_cmd { | ||
215 | __u8 num_mapping_configs; | ||
216 | struct disc_map_config mapping_configs | ||
217 | [NCI_MAX_NUM_MAPPING_CONFIGS]; | ||
218 | } __packed; | ||
219 | |||
220 | #define NCI_OP_RF_DISCOVER_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) | ||
221 | struct disc_config { | ||
222 | __u8 rf_tech_and_mode; | ||
223 | __u8 frequency; | ||
224 | } __packed; | ||
225 | |||
226 | struct nci_rf_disc_cmd { | ||
227 | __u8 num_disc_configs; | ||
228 | struct disc_config disc_configs[NCI_MAX_NUM_RF_CONFIGS]; | ||
229 | } __packed; | ||
230 | |||
231 | #define NCI_OP_RF_DISCOVER_SELECT_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x04) | ||
232 | struct nci_rf_discover_select_cmd { | ||
233 | __u8 rf_discovery_id; | ||
234 | __u8 rf_protocol; | ||
235 | __u8 rf_interface; | ||
236 | } __packed; | ||
237 | |||
238 | #define NCI_OP_RF_DEACTIVATE_CMD nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) | ||
239 | struct nci_rf_deactivate_cmd { | ||
240 | __u8 type; | ||
241 | } __packed; | ||
242 | |||
243 | /* ----------------------- */ | ||
244 | /* ---- NCI Responses ---- */ | ||
245 | /* ----------------------- */ | ||
246 | #define NCI_OP_CORE_RESET_RSP nci_opcode_pack(NCI_GID_CORE, 0x00) | ||
247 | struct nci_core_reset_rsp { | ||
248 | __u8 status; | ||
249 | __u8 nci_ver; | ||
250 | __u8 config_status; | ||
251 | } __packed; | ||
252 | |||
253 | #define NCI_OP_CORE_INIT_RSP nci_opcode_pack(NCI_GID_CORE, 0x01) | ||
254 | struct nci_core_init_rsp_1 { | ||
255 | __u8 status; | ||
256 | __le32 nfcc_features; | ||
257 | __u8 num_supported_rf_interfaces; | ||
258 | __u8 supported_rf_interfaces[0]; /* variable size array */ | ||
259 | /* continuted in nci_core_init_rsp_2 */ | ||
260 | } __packed; | ||
261 | |||
262 | struct nci_core_init_rsp_2 { | ||
263 | __u8 max_logical_connections; | ||
264 | __le16 max_routing_table_size; | ||
265 | __u8 max_ctrl_pkt_payload_len; | ||
266 | __le16 max_size_for_large_params; | ||
267 | __u8 manufact_id; | ||
268 | __le32 manufact_specific_info; | ||
269 | } __packed; | ||
270 | |||
271 | #define NCI_OP_CORE_SET_CONFIG_RSP nci_opcode_pack(NCI_GID_CORE, 0x02) | ||
272 | struct nci_core_set_config_rsp { | ||
273 | __u8 status; | ||
274 | __u8 num_params; | ||
275 | __u8 params_id[0]; /* variable size array */ | ||
276 | } __packed; | ||
277 | |||
278 | #define NCI_OP_RF_DISCOVER_MAP_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x00) | ||
279 | |||
280 | #define NCI_OP_RF_DISCOVER_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) | ||
281 | |||
282 | #define NCI_OP_RF_DISCOVER_SELECT_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x04) | ||
283 | |||
284 | #define NCI_OP_RF_DEACTIVATE_RSP nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) | ||
285 | |||
286 | /* --------------------------- */ | ||
287 | /* ---- NCI Notifications ---- */ | ||
288 | /* --------------------------- */ | ||
289 | #define NCI_OP_CORE_CONN_CREDITS_NTF nci_opcode_pack(NCI_GID_CORE, 0x06) | ||
290 | struct conn_credit_entry { | ||
291 | __u8 conn_id; | ||
292 | __u8 credits; | ||
293 | } __packed; | ||
294 | |||
295 | struct nci_core_conn_credit_ntf { | ||
296 | __u8 num_entries; | ||
297 | struct conn_credit_entry conn_entries[NCI_MAX_NUM_CONN]; | ||
298 | } __packed; | ||
299 | |||
300 | #define NCI_OP_CORE_GENERIC_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x07) | ||
301 | |||
302 | #define NCI_OP_CORE_INTF_ERROR_NTF nci_opcode_pack(NCI_GID_CORE, 0x08) | ||
303 | struct nci_core_intf_error_ntf { | ||
304 | __u8 status; | ||
305 | __u8 conn_id; | ||
306 | } __packed; | ||
307 | |||
308 | #define NCI_OP_RF_DISCOVER_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x03) | ||
309 | struct rf_tech_specific_params_nfca_poll { | ||
310 | __u16 sens_res; | ||
311 | __u8 nfcid1_len; /* 0, 4, 7, or 10 Bytes */ | ||
312 | __u8 nfcid1[10]; | ||
313 | __u8 sel_res_len; /* 0 or 1 Bytes */ | ||
314 | __u8 sel_res; | ||
315 | } __packed; | ||
316 | |||
317 | struct rf_tech_specific_params_nfcb_poll { | ||
318 | __u8 sensb_res_len; | ||
319 | __u8 sensb_res[12]; /* 11 or 12 Bytes */ | ||
320 | } __packed; | ||
321 | |||
322 | struct rf_tech_specific_params_nfcf_poll { | ||
323 | __u8 bit_rate; | ||
324 | __u8 sensf_res_len; | ||
325 | __u8 sensf_res[18]; /* 16 or 18 Bytes */ | ||
326 | } __packed; | ||
327 | |||
328 | struct nci_rf_discover_ntf { | ||
329 | __u8 rf_discovery_id; | ||
330 | __u8 rf_protocol; | ||
331 | __u8 rf_tech_and_mode; | ||
332 | __u8 rf_tech_specific_params_len; | ||
333 | |||
334 | union { | ||
335 | struct rf_tech_specific_params_nfca_poll nfca_poll; | ||
336 | struct rf_tech_specific_params_nfcb_poll nfcb_poll; | ||
337 | struct rf_tech_specific_params_nfcf_poll nfcf_poll; | ||
338 | } rf_tech_specific_params; | ||
339 | |||
340 | __u8 ntf_type; | ||
341 | } __packed; | ||
342 | |||
343 | #define NCI_OP_RF_INTF_ACTIVATED_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x05) | ||
344 | struct activation_params_nfca_poll_iso_dep { | ||
345 | __u8 rats_res_len; | ||
346 | __u8 rats_res[20]; | ||
347 | }; | ||
348 | |||
349 | struct activation_params_nfcb_poll_iso_dep { | ||
350 | __u8 attrib_res_len; | ||
351 | __u8 attrib_res[50]; | ||
352 | }; | ||
353 | |||
354 | struct activation_params_poll_nfc_dep { | ||
355 | __u8 atr_res_len; | ||
356 | __u8 atr_res[63]; | ||
357 | }; | ||
358 | |||
359 | struct nci_rf_intf_activated_ntf { | ||
360 | __u8 rf_discovery_id; | ||
361 | __u8 rf_interface; | ||
362 | __u8 rf_protocol; | ||
363 | __u8 activation_rf_tech_and_mode; | ||
364 | __u8 max_data_pkt_payload_size; | ||
365 | __u8 initial_num_credits; | ||
366 | __u8 rf_tech_specific_params_len; | ||
367 | |||
368 | union { | ||
369 | struct rf_tech_specific_params_nfca_poll nfca_poll; | ||
370 | struct rf_tech_specific_params_nfcb_poll nfcb_poll; | ||
371 | struct rf_tech_specific_params_nfcf_poll nfcf_poll; | ||
372 | } rf_tech_specific_params; | ||
373 | |||
374 | __u8 data_exch_rf_tech_and_mode; | ||
375 | __u8 data_exch_tx_bit_rate; | ||
376 | __u8 data_exch_rx_bit_rate; | ||
377 | __u8 activation_params_len; | ||
378 | |||
379 | union { | ||
380 | struct activation_params_nfca_poll_iso_dep nfca_poll_iso_dep; | ||
381 | struct activation_params_nfcb_poll_iso_dep nfcb_poll_iso_dep; | ||
382 | struct activation_params_poll_nfc_dep poll_nfc_dep; | ||
383 | } activation_params; | ||
384 | |||
385 | } __packed; | ||
386 | |||
387 | #define NCI_OP_RF_DEACTIVATE_NTF nci_opcode_pack(NCI_GID_RF_MGMT, 0x06) | ||
388 | struct nci_rf_deactivate_ntf { | ||
389 | __u8 type; | ||
390 | __u8 reason; | ||
391 | } __packed; | ||
392 | |||
393 | #endif /* __NCI_H */ | ||
diff --git a/include/net/nfc/nci_core.h b/include/net/nfc/nci_core.h deleted file mode 100644 index d705d867494..00000000000 --- a/include/net/nfc/nci_core.h +++ /dev/null | |||
@@ -1,204 +0,0 @@ | |||
1 | /* | ||
2 | * The NFC Controller Interface is the communication protocol between an | ||
3 | * NFC Controller (NFCC) and a Device Host (DH). | ||
4 | * | ||
5 | * Copyright (C) 2011 Texas Instruments, Inc. | ||
6 | * | ||
7 | * Written by Ilan Elias <ilane@ti.com> | ||
8 | * | ||
9 | * Acknowledgements: | ||
10 | * This file is based on hci_core.h, which was written | ||
11 | * by Maxim Krasnyansky. | ||
12 | * | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License version 2 | ||
15 | * as published by the Free Software Foundation | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU General Public License | ||
23 | * along with this program; if not, write to the Free Software | ||
24 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
25 | * | ||
26 | */ | ||
27 | |||
28 | #ifndef __NCI_CORE_H | ||
29 | #define __NCI_CORE_H | ||
30 | |||
31 | #include <linux/interrupt.h> | ||
32 | #include <linux/skbuff.h> | ||
33 | |||
34 | #include <net/nfc/nfc.h> | ||
35 | #include <net/nfc/nci.h> | ||
36 | |||
37 | /* NCI device flags */ | ||
38 | enum nci_flag { | ||
39 | NCI_INIT, | ||
40 | NCI_UP, | ||
41 | NCI_DATA_EXCHANGE, | ||
42 | NCI_DATA_EXCHANGE_TO, | ||
43 | }; | ||
44 | |||
45 | /* NCI device states */ | ||
46 | enum nci_state { | ||
47 | NCI_IDLE, | ||
48 | NCI_DISCOVERY, | ||
49 | NCI_W4_ALL_DISCOVERIES, | ||
50 | NCI_W4_HOST_SELECT, | ||
51 | NCI_POLL_ACTIVE, | ||
52 | }; | ||
53 | |||
54 | /* NCI timeouts */ | ||
55 | #define NCI_RESET_TIMEOUT 5000 | ||
56 | #define NCI_INIT_TIMEOUT 5000 | ||
57 | #define NCI_SET_CONFIG_TIMEOUT 5000 | ||
58 | #define NCI_RF_DISC_TIMEOUT 5000 | ||
59 | #define NCI_RF_DISC_SELECT_TIMEOUT 5000 | ||
60 | #define NCI_RF_DEACTIVATE_TIMEOUT 30000 | ||
61 | #define NCI_CMD_TIMEOUT 5000 | ||
62 | #define NCI_DATA_TIMEOUT 700 | ||
63 | |||
64 | struct nci_dev; | ||
65 | |||
66 | struct nci_ops { | ||
67 | int (*open)(struct nci_dev *ndev); | ||
68 | int (*close)(struct nci_dev *ndev); | ||
69 | int (*send)(struct sk_buff *skb); | ||
70 | }; | ||
71 | |||
72 | #define NCI_MAX_SUPPORTED_RF_INTERFACES 4 | ||
73 | #define NCI_MAX_DISCOVERED_TARGETS 10 | ||
74 | |||
75 | /* NCI Core structures */ | ||
76 | struct nci_dev { | ||
77 | struct nfc_dev *nfc_dev; | ||
78 | struct nci_ops *ops; | ||
79 | |||
80 | int tx_headroom; | ||
81 | int tx_tailroom; | ||
82 | |||
83 | atomic_t state; | ||
84 | unsigned long flags; | ||
85 | |||
86 | atomic_t cmd_cnt; | ||
87 | atomic_t credits_cnt; | ||
88 | |||
89 | struct timer_list cmd_timer; | ||
90 | struct timer_list data_timer; | ||
91 | |||
92 | struct workqueue_struct *cmd_wq; | ||
93 | struct work_struct cmd_work; | ||
94 | |||
95 | struct workqueue_struct *rx_wq; | ||
96 | struct work_struct rx_work; | ||
97 | |||
98 | struct workqueue_struct *tx_wq; | ||
99 | struct work_struct tx_work; | ||
100 | |||
101 | struct sk_buff_head cmd_q; | ||
102 | struct sk_buff_head rx_q; | ||
103 | struct sk_buff_head tx_q; | ||
104 | |||
105 | struct mutex req_lock; | ||
106 | struct completion req_completion; | ||
107 | __u32 req_status; | ||
108 | __u32 req_result; | ||
109 | |||
110 | void *driver_data; | ||
111 | |||
112 | __u32 poll_prots; | ||
113 | __u32 target_active_prot; | ||
114 | |||
115 | struct nfc_target targets[NCI_MAX_DISCOVERED_TARGETS]; | ||
116 | int n_targets; | ||
117 | |||
118 | /* received during NCI_OP_CORE_RESET_RSP */ | ||
119 | __u8 nci_ver; | ||
120 | |||
121 | /* received during NCI_OP_CORE_INIT_RSP */ | ||
122 | __u32 nfcc_features; | ||
123 | __u8 num_supported_rf_interfaces; | ||
124 | __u8 supported_rf_interfaces | ||
125 | [NCI_MAX_SUPPORTED_RF_INTERFACES]; | ||
126 | __u8 max_logical_connections; | ||
127 | __u16 max_routing_table_size; | ||
128 | __u8 max_ctrl_pkt_payload_len; | ||
129 | __u16 max_size_for_large_params; | ||
130 | __u8 manufact_id; | ||
131 | __u32 manufact_specific_info; | ||
132 | |||
133 | /* received during NCI_OP_RF_INTF_ACTIVATED_NTF */ | ||
134 | __u8 max_data_pkt_payload_size; | ||
135 | __u8 initial_num_credits; | ||
136 | |||
137 | /* stored during nci_data_exchange */ | ||
138 | data_exchange_cb_t data_exchange_cb; | ||
139 | void *data_exchange_cb_context; | ||
140 | struct sk_buff *rx_data_reassembly; | ||
141 | |||
142 | /* stored during intf_activated_ntf */ | ||
143 | __u8 remote_gb[NFC_MAX_GT_LEN]; | ||
144 | __u8 remote_gb_len; | ||
145 | }; | ||
146 | |||
147 | /* ----- NCI Devices ----- */ | ||
148 | struct nci_dev *nci_allocate_device(struct nci_ops *ops, | ||
149 | __u32 supported_protocols, | ||
150 | int tx_headroom, | ||
151 | int tx_tailroom); | ||
152 | void nci_free_device(struct nci_dev *ndev); | ||
153 | int nci_register_device(struct nci_dev *ndev); | ||
154 | void nci_unregister_device(struct nci_dev *ndev); | ||
155 | int nci_recv_frame(struct sk_buff *skb); | ||
156 | |||
157 | static inline struct sk_buff *nci_skb_alloc(struct nci_dev *ndev, | ||
158 | unsigned int len, | ||
159 | gfp_t how) | ||
160 | { | ||
161 | struct sk_buff *skb; | ||
162 | |||
163 | skb = alloc_skb(len + ndev->tx_headroom + ndev->tx_tailroom, how); | ||
164 | if (skb) | ||
165 | skb_reserve(skb, ndev->tx_headroom); | ||
166 | |||
167 | return skb; | ||
168 | } | ||
169 | |||
170 | static inline void nci_set_parent_dev(struct nci_dev *ndev, struct device *dev) | ||
171 | { | ||
172 | nfc_set_parent_dev(ndev->nfc_dev, dev); | ||
173 | } | ||
174 | |||
175 | static inline void nci_set_drvdata(struct nci_dev *ndev, void *data) | ||
176 | { | ||
177 | ndev->driver_data = data; | ||
178 | } | ||
179 | |||
180 | static inline void *nci_get_drvdata(struct nci_dev *ndev) | ||
181 | { | ||
182 | return ndev->driver_data; | ||
183 | } | ||
184 | |||
185 | void nci_rsp_packet(struct nci_dev *ndev, struct sk_buff *skb); | ||
186 | void nci_ntf_packet(struct nci_dev *ndev, struct sk_buff *skb); | ||
187 | void nci_rx_data_packet(struct nci_dev *ndev, struct sk_buff *skb); | ||
188 | int nci_send_cmd(struct nci_dev *ndev, __u16 opcode, __u8 plen, void *payload); | ||
189 | int nci_send_data(struct nci_dev *ndev, __u8 conn_id, struct sk_buff *skb); | ||
190 | void nci_data_exchange_complete(struct nci_dev *ndev, struct sk_buff *skb, | ||
191 | int err); | ||
192 | void nci_clear_target_list(struct nci_dev *ndev); | ||
193 | |||
194 | /* ----- NCI requests ----- */ | ||
195 | #define NCI_REQ_DONE 0 | ||
196 | #define NCI_REQ_PEND 1 | ||
197 | #define NCI_REQ_CANCELED 2 | ||
198 | |||
199 | void nci_req_complete(struct nci_dev *ndev, int result); | ||
200 | |||
201 | /* ----- NCI status code ----- */ | ||
202 | int nci_to_errno(__u8 code); | ||
203 | |||
204 | #endif /* __NCI_CORE_H */ | ||
diff --git a/include/net/nfc/nfc.h b/include/net/nfc/nfc.h deleted file mode 100644 index fce80b2f9be..00000000000 --- a/include/net/nfc/nfc.h +++ /dev/null | |||
@@ -1,209 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2011 Instituto Nokia de Tecnologia | ||
3 | * | ||
4 | * Authors: | ||
5 | * Lauro Ramos Venancio <lauro.venancio@openbossa.org> | ||
6 | * Aloisio Almeida Jr <aloisio.almeida@openbossa.org> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or modify | ||
9 | * it under the terms of the GNU General Public License as published by | ||
10 | * the Free Software Foundation; either version 2 of the License, or | ||
11 | * (at your option) any later version. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the | ||
20 | * Free Software Foundation, Inc., | ||
21 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
22 | */ | ||
23 | |||
24 | #ifndef __NET_NFC_H | ||
25 | #define __NET_NFC_H | ||
26 | |||
27 | #include <linux/nfc.h> | ||
28 | #include <linux/device.h> | ||
29 | #include <linux/skbuff.h> | ||
30 | |||
31 | #define nfc_dev_info(dev, fmt, arg...) dev_info((dev), "NFC: " fmt "\n", ## arg) | ||
32 | #define nfc_dev_err(dev, fmt, arg...) dev_err((dev), "NFC: " fmt "\n", ## arg) | ||
33 | #define nfc_dev_dbg(dev, fmt, arg...) dev_dbg((dev), fmt "\n", ## arg) | ||
34 | |||
35 | struct nfc_dev; | ||
36 | |||
37 | /** | ||
38 | * data_exchange_cb_t - Definition of nfc_data_exchange callback | ||
39 | * | ||
40 | * @context: nfc_data_exchange cb_context parameter | ||
41 | * @skb: response data | ||
42 | * @err: If an error has occurred during data exchange, it is the | ||
43 | * error number. Zero means no error. | ||
44 | * | ||
45 | * When a rx or tx package is lost or corrupted or the target gets out | ||
46 | * of the operating field, err is -EIO. | ||
47 | */ | ||
48 | typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb, | ||
49 | int err); | ||
50 | |||
51 | struct nfc_target; | ||
52 | |||
53 | struct nfc_ops { | ||
54 | int (*dev_up)(struct nfc_dev *dev); | ||
55 | int (*dev_down)(struct nfc_dev *dev); | ||
56 | int (*start_poll)(struct nfc_dev *dev, | ||
57 | u32 im_protocols, u32 tm_protocols); | ||
58 | void (*stop_poll)(struct nfc_dev *dev); | ||
59 | int (*dep_link_up)(struct nfc_dev *dev, struct nfc_target *target, | ||
60 | u8 comm_mode, u8 *gb, size_t gb_len); | ||
61 | int (*dep_link_down)(struct nfc_dev *dev); | ||
62 | int (*activate_target)(struct nfc_dev *dev, struct nfc_target *target, | ||
63 | u32 protocol); | ||
64 | void (*deactivate_target)(struct nfc_dev *dev, | ||
65 | struct nfc_target *target); | ||
66 | int (*im_transceive)(struct nfc_dev *dev, struct nfc_target *target, | ||
67 | struct sk_buff *skb, data_exchange_cb_t cb, | ||
68 | void *cb_context); | ||
69 | int (*tm_send)(struct nfc_dev *dev, struct sk_buff *skb); | ||
70 | int (*check_presence)(struct nfc_dev *dev, struct nfc_target *target); | ||
71 | }; | ||
72 | |||
73 | #define NFC_TARGET_IDX_ANY -1 | ||
74 | #define NFC_MAX_GT_LEN 48 | ||
75 | #define NFC_ATR_RES_GT_OFFSET 15 | ||
76 | |||
77 | struct nfc_target { | ||
78 | u32 idx; | ||
79 | u32 supported_protocols; | ||
80 | u16 sens_res; | ||
81 | u8 sel_res; | ||
82 | u8 nfcid1_len; | ||
83 | u8 nfcid1[NFC_NFCID1_MAXSIZE]; | ||
84 | u8 sensb_res_len; | ||
85 | u8 sensb_res[NFC_SENSB_RES_MAXSIZE]; | ||
86 | u8 sensf_res_len; | ||
87 | u8 sensf_res[NFC_SENSF_RES_MAXSIZE]; | ||
88 | u8 hci_reader_gate; | ||
89 | u8 logical_idx; | ||
90 | }; | ||
91 | |||
92 | struct nfc_genl_data { | ||
93 | u32 poll_req_portid; | ||
94 | struct mutex genl_data_mutex; | ||
95 | }; | ||
96 | |||
97 | struct nfc_dev { | ||
98 | int idx; | ||
99 | u32 target_next_idx; | ||
100 | struct nfc_target *targets; | ||
101 | int n_targets; | ||
102 | int targets_generation; | ||
103 | struct device dev; | ||
104 | bool dev_up; | ||
105 | u8 rf_mode; | ||
106 | bool polling; | ||
107 | struct nfc_target *active_target; | ||
108 | bool dep_link_up; | ||
109 | struct nfc_genl_data genl_data; | ||
110 | u32 supported_protocols; | ||
111 | |||
112 | int tx_headroom; | ||
113 | int tx_tailroom; | ||
114 | |||
115 | struct timer_list check_pres_timer; | ||
116 | struct work_struct check_pres_work; | ||
117 | |||
118 | struct nfc_ops *ops; | ||
119 | }; | ||
120 | #define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev) | ||
121 | |||
122 | extern struct class nfc_class; | ||
123 | |||
124 | struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops, | ||
125 | u32 supported_protocols, | ||
126 | int tx_headroom, | ||
127 | int tx_tailroom); | ||
128 | |||
129 | /** | ||
130 | * nfc_free_device - free nfc device | ||
131 | * | ||
132 | * @dev: The nfc device to free | ||
133 | */ | ||
134 | static inline void nfc_free_device(struct nfc_dev *dev) | ||
135 | { | ||
136 | put_device(&dev->dev); | ||
137 | } | ||
138 | |||
139 | int nfc_register_device(struct nfc_dev *dev); | ||
140 | |||
141 | void nfc_unregister_device(struct nfc_dev *dev); | ||
142 | |||
143 | /** | ||
144 | * nfc_set_parent_dev - set the parent device | ||
145 | * | ||
146 | * @nfc_dev: The nfc device whose parent is being set | ||
147 | * @dev: The parent device | ||
148 | */ | ||
149 | static inline void nfc_set_parent_dev(struct nfc_dev *nfc_dev, | ||
150 | struct device *dev) | ||
151 | { | ||
152 | nfc_dev->dev.parent = dev; | ||
153 | } | ||
154 | |||
155 | /** | ||
156 | * nfc_set_drvdata - set driver specifc data | ||
157 | * | ||
158 | * @dev: The nfc device | ||
159 | * @data: Pointer to driver specifc data | ||
160 | */ | ||
161 | static inline void nfc_set_drvdata(struct nfc_dev *dev, void *data) | ||
162 | { | ||
163 | dev_set_drvdata(&dev->dev, data); | ||
164 | } | ||
165 | |||
166 | /** | ||
167 | * nfc_get_drvdata - get driver specifc data | ||
168 | * | ||
169 | * @dev: The nfc device | ||
170 | */ | ||
171 | static inline void *nfc_get_drvdata(struct nfc_dev *dev) | ||
172 | { | ||
173 | return dev_get_drvdata(&dev->dev); | ||
174 | } | ||
175 | |||
176 | /** | ||
177 | * nfc_device_name - get the nfc device name | ||
178 | * | ||
179 | * @dev: The nfc device whose name to return | ||
180 | */ | ||
181 | static inline const char *nfc_device_name(struct nfc_dev *dev) | ||
182 | { | ||
183 | return dev_name(&dev->dev); | ||
184 | } | ||
185 | |||
186 | struct sk_buff *nfc_alloc_send_skb(struct nfc_dev *dev, struct sock *sk, | ||
187 | unsigned int flags, unsigned int size, | ||
188 | unsigned int *err); | ||
189 | struct sk_buff *nfc_alloc_recv_skb(unsigned int size, gfp_t gfp); | ||
190 | |||
191 | int nfc_set_remote_general_bytes(struct nfc_dev *dev, | ||
192 | u8 *gt, u8 gt_len); | ||
193 | u8 *nfc_get_local_general_bytes(struct nfc_dev *dev, size_t *gb_len); | ||
194 | |||
195 | int nfc_targets_found(struct nfc_dev *dev, | ||
196 | struct nfc_target *targets, int ntargets); | ||
197 | int nfc_target_lost(struct nfc_dev *dev, u32 target_idx); | ||
198 | |||
199 | int nfc_dep_link_is_up(struct nfc_dev *dev, u32 target_idx, | ||
200 | u8 comm_mode, u8 rf_mode); | ||
201 | |||
202 | int nfc_tm_activated(struct nfc_dev *dev, u32 protocol, u8 comm_mode, | ||
203 | u8 *gb, size_t gb_len); | ||
204 | int nfc_tm_deactivated(struct nfc_dev *dev); | ||
205 | int nfc_tm_data_received(struct nfc_dev *dev, struct sk_buff *skb); | ||
206 | |||
207 | void nfc_driver_failure(struct nfc_dev *dev, int err); | ||
208 | |||
209 | #endif /* __NET_NFC_H */ | ||
diff --git a/include/net/phonet/gprs.h b/include/net/phonet/gprs.h index bcd525e39a0..928daf595be 100644 --- a/include/net/phonet/gprs.h +++ b/include/net/phonet/gprs.h | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2008 Nokia Corporation. | 6 | * Copyright (C) 2008 Nokia Corporation. |
7 | * | 7 | * |
8 | * Author: Rémi Denis-Courmont | 8 | * Author: Rémi Denis-Courmont <remi.denis-courmont@nokia.com> |
9 | * | 9 | * |
10 | * This program is free software; you can redistribute it and/or | 10 | * This program is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU General Public License | 11 | * modify it under the terms of the GNU General Public License |
diff --git a/include/net/pkt_sched.h b/include/net/pkt_sched.h index 66f5ac370f9..fffdc603f4c 100644 --- a/include/net/pkt_sched.h +++ b/include/net/pkt_sched.h | |||
@@ -107,7 +107,7 @@ extern int tc_classify(struct sk_buff *skb, const struct tcf_proto *tp, | |||
107 | /* Calculate maximal size of packet seen by hard_start_xmit | 107 | /* Calculate maximal size of packet seen by hard_start_xmit |
108 | routine of this device. | 108 | routine of this device. |
109 | */ | 109 | */ |
110 | static inline unsigned int psched_mtu(const struct net_device *dev) | 110 | static inline unsigned psched_mtu(const struct net_device *dev) |
111 | { | 111 | { |
112 | return dev->mtu + dev->hard_header_len; | 112 | return dev->mtu + dev->hard_header_len; |
113 | } | 113 | } |
diff --git a/include/net/protocol.h b/include/net/protocol.h index 047c0476c0a..6f7eb800974 100644 --- a/include/net/protocol.h +++ b/include/net/protocol.h | |||
@@ -25,50 +25,51 @@ | |||
25 | #define _PROTOCOL_H | 25 | #define _PROTOCOL_H |
26 | 26 | ||
27 | #include <linux/in6.h> | 27 | #include <linux/in6.h> |
28 | #include <linux/skbuff.h> | 28 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
29 | #if IS_ENABLED(CONFIG_IPV6) | ||
30 | #include <linux/ipv6.h> | 29 | #include <linux/ipv6.h> |
31 | #endif | 30 | #endif |
32 | #include <linux/netdevice.h> | ||
33 | 31 | ||
34 | /* This is one larger than the largest protocol value that can be | 32 | #define MAX_INET_PROTOS 256 /* Must be a power of 2 */ |
35 | * found in an ipv4 or ipv6 header. Since in both cases the protocol | 33 | |
36 | * value is presented in a __u8, this is defined to be 256. | ||
37 | */ | ||
38 | #define MAX_INET_PROTOS 256 | ||
39 | 34 | ||
40 | /* This is used to register protocols. */ | 35 | /* This is used to register protocols. */ |
41 | struct net_protocol { | 36 | struct net_protocol { |
42 | void (*early_demux)(struct sk_buff *skb); | ||
43 | int (*handler)(struct sk_buff *skb); | 37 | int (*handler)(struct sk_buff *skb); |
44 | 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); | ||
40 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | ||
41 | u32 features); | ||
42 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | ||
43 | struct sk_buff *skb); | ||
44 | int (*gro_complete)(struct sk_buff *skb); | ||
45 | unsigned int no_policy:1, | 45 | unsigned int no_policy:1, |
46 | netns_ok:1; | 46 | netns_ok:1; |
47 | }; | 47 | }; |
48 | 48 | ||
49 | #if IS_ENABLED(CONFIG_IPV6) | 49 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
50 | struct inet6_protocol { | 50 | struct inet6_protocol { |
51 | void (*early_demux)(struct sk_buff *skb); | ||
52 | |||
53 | int (*handler)(struct sk_buff *skb); | 51 | int (*handler)(struct sk_buff *skb); |
54 | 52 | ||
55 | void (*err_handler)(struct sk_buff *skb, | 53 | void (*err_handler)(struct sk_buff *skb, |
56 | struct inet6_skb_parm *opt, | 54 | struct inet6_skb_parm *opt, |
57 | u8 type, u8 code, int offset, | 55 | u8 type, u8 code, int offset, |
58 | __be32 info); | 56 | __be32 info); |
57 | |||
58 | int (*gso_send_check)(struct sk_buff *skb); | ||
59 | struct sk_buff *(*gso_segment)(struct sk_buff *skb, | ||
60 | u32 features); | ||
61 | struct sk_buff **(*gro_receive)(struct sk_buff **head, | ||
62 | struct sk_buff *skb); | ||
63 | int (*gro_complete)(struct sk_buff *skb); | ||
64 | |||
59 | unsigned int flags; /* INET6_PROTO_xxx */ | 65 | unsigned int flags; /* INET6_PROTO_xxx */ |
60 | }; | 66 | }; |
61 | 67 | ||
62 | #define INET6_PROTO_NOPOLICY 0x1 | 68 | #define INET6_PROTO_NOPOLICY 0x1 |
63 | #define INET6_PROTO_FINAL 0x2 | 69 | #define INET6_PROTO_FINAL 0x2 |
64 | #endif | ||
65 | |||
66 | struct net_offload { | ||
67 | struct offload_callbacks callbacks; | ||
68 | unsigned int flags; /* Flags used by IPv6 for now */ | ||
69 | }; | ||
70 | /* This should be set for any extension header which is compatible with GSO. */ | 70 | /* This should be set for any extension header which is compatible with GSO. */ |
71 | #define INET6_PROTO_GSO_EXTHDR 0x1 | 71 | #define INET6_PROTO_GSO_EXTHDR 0x4 |
72 | #endif | ||
72 | 73 | ||
73 | /* This is used to register socket interfaces for IP protocols. */ | 74 | /* This is used to register socket interfaces for IP protocols. */ |
74 | struct inet_protosw { | 75 | struct inet_protosw { |
@@ -89,27 +90,21 @@ struct inet_protosw { | |||
89 | #define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ | 90 | #define INET_PROTOSW_ICSK 0x04 /* Is this an inet_connection_sock? */ |
90 | 91 | ||
91 | extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS]; | 92 | extern const struct net_protocol __rcu *inet_protos[MAX_INET_PROTOS]; |
92 | extern const struct net_offload __rcu *inet_offloads[MAX_INET_PROTOS]; | ||
93 | extern const struct net_offload __rcu *inet6_offloads[MAX_INET_PROTOS]; | ||
94 | 93 | ||
95 | #if IS_ENABLED(CONFIG_IPV6) | 94 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
96 | extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS]; | 95 | extern const struct inet6_protocol __rcu *inet6_protos[MAX_INET_PROTOS]; |
97 | #endif | 96 | #endif |
98 | 97 | ||
99 | 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); |
100 | extern int inet_del_protocol(const struct net_protocol *prot, unsigned char num); | 99 | extern int inet_del_protocol(const struct net_protocol *prot, unsigned char num); |
101 | extern int inet_add_offload(const struct net_offload *prot, unsigned char num); | ||
102 | extern int inet_del_offload(const struct net_offload *prot, unsigned char num); | ||
103 | extern void inet_register_protosw(struct inet_protosw *p); | 100 | extern void inet_register_protosw(struct inet_protosw *p); |
104 | extern void inet_unregister_protosw(struct inet_protosw *p); | 101 | extern void inet_unregister_protosw(struct inet_protosw *p); |
105 | 102 | ||
106 | #if IS_ENABLED(CONFIG_IPV6) | 103 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
107 | extern int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num); | 104 | extern int inet6_add_protocol(const struct inet6_protocol *prot, unsigned char num); |
108 | extern int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num); | 105 | extern int inet6_del_protocol(const struct inet6_protocol *prot, unsigned char num); |
109 | extern int inet6_register_protosw(struct inet_protosw *p); | 106 | extern int inet6_register_protosw(struct inet_protosw *p); |
110 | extern void inet6_unregister_protosw(struct inet_protosw *p); | 107 | extern void inet6_unregister_protosw(struct inet_protosw *p); |
111 | #endif | 108 | #endif |
112 | extern int inet6_add_offload(const struct net_offload *prot, unsigned char num); | ||
113 | extern int inet6_del_offload(const struct net_offload *prot, unsigned char num); | ||
114 | 109 | ||
115 | #endif /* _PROTOCOL_H */ | 110 | #endif /* _PROTOCOL_H */ |
diff --git a/include/net/rawv6.h b/include/net/rawv6.h index e7ea660e4db..cf757723445 100644 --- a/include/net/rawv6.h +++ b/include/net/rawv6.h | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | void raw6_icmp_error(struct sk_buff *, int nexthdr, | 6 | void raw6_icmp_error(struct sk_buff *, int nexthdr, |
7 | u8 type, u8 code, int inner_offset, __be32); | 7 | u8 type, u8 code, int inner_offset, __be32); |
8 | bool raw6_local_deliver(struct sk_buff *, int); | 8 | int raw6_local_deliver(struct sk_buff *, int); |
9 | 9 | ||
10 | extern int rawv6_rcv(struct sock *sk, | 10 | extern int rawv6_rcv(struct sock *sk, |
11 | struct sk_buff *skb); | 11 | struct sk_buff *skb); |
diff --git a/include/net/red.h b/include/net/red.h index ef46058d35b..b72a3b83393 100644 --- a/include/net/red.h +++ b/include/net/red.h | |||
@@ -2,11 +2,9 @@ | |||
2 | #define __NET_SCHED_RED_H | 2 | #define __NET_SCHED_RED_H |
3 | 3 | ||
4 | #include <linux/types.h> | 4 | #include <linux/types.h> |
5 | #include <linux/bug.h> | ||
6 | #include <net/pkt_sched.h> | 5 | #include <net/pkt_sched.h> |
7 | #include <net/inet_ecn.h> | 6 | #include <net/inet_ecn.h> |
8 | #include <net/dsfield.h> | 7 | #include <net/dsfield.h> |
9 | #include <linux/reciprocal_div.h> | ||
10 | 8 | ||
11 | /* Random Early Detection (RED) algorithm. | 9 | /* Random Early Detection (RED) algorithm. |
12 | ======================================= | 10 | ======================================= |
@@ -89,29 +87,6 @@ | |||
89 | etc. | 87 | etc. |
90 | */ | 88 | */ |
91 | 89 | ||
92 | /* | ||
93 | * Adaptative RED : An Algorithm for Increasing the Robustness of RED's AQM | ||
94 | * (Sally FLoyd, Ramakrishna Gummadi, and Scott Shenker) August 2001 | ||
95 | * | ||
96 | * Every 500 ms: | ||
97 | * if (avg > target and max_p <= 0.5) | ||
98 | * increase max_p : max_p += alpha; | ||
99 | * else if (avg < target and max_p >= 0.01) | ||
100 | * decrease max_p : max_p *= beta; | ||
101 | * | ||
102 | * target :[qth_min + 0.4*(qth_min - qth_max), | ||
103 | * qth_min + 0.6*(qth_min - qth_max)]. | ||
104 | * alpha : min(0.01, max_p / 4) | ||
105 | * beta : 0.9 | ||
106 | * max_P is a Q0.32 fixed point number (with 32 bits mantissa) | ||
107 | * max_P between 0.01 and 0.5 (1% - 50%) [ Its no longer a negative power of two ] | ||
108 | */ | ||
109 | #define RED_ONE_PERCENT ((u32)DIV_ROUND_CLOSEST(1ULL<<32, 100)) | ||
110 | |||
111 | #define MAX_P_MIN (1 * RED_ONE_PERCENT) | ||
112 | #define MAX_P_MAX (50 * RED_ONE_PERCENT) | ||
113 | #define MAX_P_ALPHA(val) min(MAX_P_MIN, val / 4) | ||
114 | |||
115 | #define RED_STAB_SIZE 256 | 90 | #define RED_STAB_SIZE 256 |
116 | #define RED_STAB_MASK (RED_STAB_SIZE - 1) | 91 | #define RED_STAB_MASK (RED_STAB_SIZE - 1) |
117 | 92 | ||
@@ -126,110 +101,76 @@ struct red_stats { | |||
126 | 101 | ||
127 | struct red_parms { | 102 | struct red_parms { |
128 | /* Parameters */ | 103 | /* Parameters */ |
129 | u32 qth_min; /* Min avg length threshold: Wlog scaled */ | 104 | u32 qth_min; /* Min avg length threshold: A scaled */ |
130 | u32 qth_max; /* Max avg length threshold: Wlog scaled */ | 105 | u32 qth_max; /* Max avg length threshold: A scaled */ |
131 | u32 Scell_max; | 106 | u32 Scell_max; |
132 | u32 max_P; /* probability, [0 .. 1.0] 32 scaled */ | 107 | u32 Rmask; /* Cached random mask, see red_rmask */ |
133 | u32 max_P_reciprocal; /* reciprocal_value(max_P / qth_delta) */ | ||
134 | u32 qth_delta; /* max_th - min_th */ | ||
135 | u32 target_min; /* min_th + 0.4*(max_th - min_th) */ | ||
136 | u32 target_max; /* min_th + 0.6*(max_th - min_th) */ | ||
137 | u8 Scell_log; | 108 | u8 Scell_log; |
138 | u8 Wlog; /* log(W) */ | 109 | u8 Wlog; /* log(W) */ |
139 | u8 Plog; /* random number bits */ | 110 | u8 Plog; /* random number bits */ |
140 | u8 Stab[RED_STAB_SIZE]; | 111 | u8 Stab[RED_STAB_SIZE]; |
141 | }; | ||
142 | 112 | ||
143 | struct red_vars { | ||
144 | /* Variables */ | 113 | /* Variables */ |
145 | int qcount; /* Number of packets since last random | 114 | int qcount; /* Number of packets since last random |
146 | number generation */ | 115 | number generation */ |
147 | u32 qR; /* Cached random number */ | 116 | u32 qR; /* Cached random number */ |
148 | 117 | ||
149 | unsigned long qavg; /* Average queue length: Wlog scaled */ | 118 | unsigned long qavg; /* Average queue length: A scaled */ |
150 | ktime_t qidlestart; /* Start of current idle period */ | 119 | ktime_t qidlestart; /* Start of current idle period */ |
151 | }; | 120 | }; |
152 | 121 | ||
153 | static inline u32 red_maxp(u8 Plog) | 122 | static inline u32 red_rmask(u8 Plog) |
154 | { | 123 | { |
155 | return Plog < 32 ? (~0U >> Plog) : ~0U; | 124 | return Plog < 32 ? ((1 << Plog) - 1) : ~0UL; |
156 | } | 125 | } |
157 | 126 | ||
158 | static inline void red_set_vars(struct red_vars *v) | 127 | static inline void red_set_parms(struct red_parms *p, |
128 | u32 qth_min, u32 qth_max, u8 Wlog, u8 Plog, | ||
129 | u8 Scell_log, u8 *stab) | ||
159 | { | 130 | { |
160 | /* Reset average queue length, the value is strictly bound | 131 | /* Reset average queue length, the value is strictly bound |
161 | * to the parameters below, reseting hurts a bit but leaving | 132 | * to the parameters below, reseting hurts a bit but leaving |
162 | * it might result in an unreasonable qavg for a while. --TGR | 133 | * it might result in an unreasonable qavg for a while. --TGR |
163 | */ | 134 | */ |
164 | v->qavg = 0; | 135 | p->qavg = 0; |
165 | |||
166 | v->qcount = -1; | ||
167 | } | ||
168 | |||
169 | static inline void red_set_parms(struct red_parms *p, | ||
170 | u32 qth_min, u32 qth_max, u8 Wlog, u8 Plog, | ||
171 | u8 Scell_log, u8 *stab, u32 max_P) | ||
172 | { | ||
173 | int delta = qth_max - qth_min; | ||
174 | u32 max_p_delta; | ||
175 | 136 | ||
137 | p->qcount = -1; | ||
176 | p->qth_min = qth_min << Wlog; | 138 | p->qth_min = qth_min << Wlog; |
177 | p->qth_max = qth_max << Wlog; | 139 | p->qth_max = qth_max << Wlog; |
178 | p->Wlog = Wlog; | 140 | p->Wlog = Wlog; |
179 | p->Plog = Plog; | 141 | p->Plog = Plog; |
180 | if (delta < 0) | 142 | p->Rmask = red_rmask(Plog); |
181 | delta = 1; | ||
182 | p->qth_delta = delta; | ||
183 | if (!max_P) { | ||
184 | max_P = red_maxp(Plog); | ||
185 | max_P *= delta; /* max_P = (qth_max - qth_min)/2^Plog */ | ||
186 | } | ||
187 | p->max_P = max_P; | ||
188 | max_p_delta = max_P / delta; | ||
189 | max_p_delta = max(max_p_delta, 1U); | ||
190 | p->max_P_reciprocal = reciprocal_value(max_p_delta); | ||
191 | |||
192 | /* RED Adaptative target : | ||
193 | * [min_th + 0.4*(min_th - max_th), | ||
194 | * min_th + 0.6*(min_th - max_th)]. | ||
195 | */ | ||
196 | delta /= 5; | ||
197 | p->target_min = qth_min + 2*delta; | ||
198 | p->target_max = qth_min + 3*delta; | ||
199 | |||
200 | p->Scell_log = Scell_log; | 143 | p->Scell_log = Scell_log; |
201 | p->Scell_max = (255 << Scell_log); | 144 | p->Scell_max = (255 << Scell_log); |
202 | 145 | ||
203 | if (stab) | 146 | memcpy(p->Stab, stab, sizeof(p->Stab)); |
204 | memcpy(p->Stab, stab, sizeof(p->Stab)); | ||
205 | } | 147 | } |
206 | 148 | ||
207 | static inline int red_is_idling(const struct red_vars *v) | 149 | static inline int red_is_idling(struct red_parms *p) |
208 | { | 150 | { |
209 | return v->qidlestart.tv64 != 0; | 151 | return p->qidlestart.tv64 != 0; |
210 | } | 152 | } |
211 | 153 | ||
212 | static inline void red_start_of_idle_period(struct red_vars *v) | 154 | static inline void red_start_of_idle_period(struct red_parms *p) |
213 | { | 155 | { |
214 | v->qidlestart = ktime_get(); | 156 | p->qidlestart = ktime_get(); |
215 | } | 157 | } |
216 | 158 | ||
217 | static inline void red_end_of_idle_period(struct red_vars *v) | 159 | static inline void red_end_of_idle_period(struct red_parms *p) |
218 | { | 160 | { |
219 | v->qidlestart.tv64 = 0; | 161 | p->qidlestart.tv64 = 0; |
220 | } | 162 | } |
221 | 163 | ||
222 | static inline void red_restart(struct red_vars *v) | 164 | static inline void red_restart(struct red_parms *p) |
223 | { | 165 | { |
224 | red_end_of_idle_period(v); | 166 | red_end_of_idle_period(p); |
225 | v->qavg = 0; | 167 | p->qavg = 0; |
226 | v->qcount = -1; | 168 | p->qcount = -1; |
227 | } | 169 | } |
228 | 170 | ||
229 | static inline unsigned long red_calc_qavg_from_idle_time(const struct red_parms *p, | 171 | static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p) |
230 | const struct red_vars *v) | ||
231 | { | 172 | { |
232 | s64 delta = ktime_us_delta(ktime_get(), v->qidlestart); | 173 | s64 delta = ktime_us_delta(ktime_get(), p->qidlestart); |
233 | long us_idle = min_t(s64, delta, p->Scell_max); | 174 | long us_idle = min_t(s64, delta, p->Scell_max); |
234 | int shift; | 175 | int shift; |
235 | 176 | ||
@@ -245,7 +186,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(const struct red_parms | |||
245 | * | 186 | * |
246 | * dummy packets as a burst after idle time, i.e. | 187 | * dummy packets as a burst after idle time, i.e. |
247 | * | 188 | * |
248 | * v->qavg *= (1-W)^m | 189 | * p->qavg *= (1-W)^m |
249 | * | 190 | * |
250 | * This is an apparently overcomplicated solution (f.e. we have to | 191 | * This is an apparently overcomplicated solution (f.e. we have to |
251 | * precompute a table to make this calculation in reasonable time) | 192 | * precompute a table to make this calculation in reasonable time) |
@@ -256,7 +197,7 @@ static inline unsigned long red_calc_qavg_from_idle_time(const struct red_parms | |||
256 | shift = p->Stab[(us_idle >> p->Scell_log) & RED_STAB_MASK]; | 197 | shift = p->Stab[(us_idle >> p->Scell_log) & RED_STAB_MASK]; |
257 | 198 | ||
258 | if (shift) | 199 | if (shift) |
259 | return v->qavg >> shift; | 200 | return p->qavg >> shift; |
260 | else { | 201 | else { |
261 | /* Approximate initial part of exponent with linear function: | 202 | /* Approximate initial part of exponent with linear function: |
262 | * | 203 | * |
@@ -265,21 +206,20 @@ static inline unsigned long red_calc_qavg_from_idle_time(const struct red_parms | |||
265 | * Seems, it is the best solution to | 206 | * Seems, it is the best solution to |
266 | * problem of too coarse exponent tabulation. | 207 | * problem of too coarse exponent tabulation. |
267 | */ | 208 | */ |
268 | us_idle = (v->qavg * (u64)us_idle) >> p->Scell_log; | 209 | us_idle = (p->qavg * (u64)us_idle) >> p->Scell_log; |
269 | 210 | ||
270 | if (us_idle < (v->qavg >> 1)) | 211 | if (us_idle < (p->qavg >> 1)) |
271 | return v->qavg - us_idle; | 212 | return p->qavg - us_idle; |
272 | else | 213 | else |
273 | return v->qavg >> 1; | 214 | return p->qavg >> 1; |
274 | } | 215 | } |
275 | } | 216 | } |
276 | 217 | ||
277 | static inline unsigned long red_calc_qavg_no_idle_time(const struct red_parms *p, | 218 | static inline unsigned long red_calc_qavg_no_idle_time(struct red_parms *p, |
278 | const struct red_vars *v, | ||
279 | unsigned int backlog) | 219 | unsigned int backlog) |
280 | { | 220 | { |
281 | /* | 221 | /* |
282 | * NOTE: v->qavg is fixed point number with point at Wlog. | 222 | * NOTE: p->qavg is fixed point number with point at Wlog. |
283 | * The formula below is equvalent to floating point | 223 | * The formula below is equvalent to floating point |
284 | * version: | 224 | * version: |
285 | * | 225 | * |
@@ -287,46 +227,42 @@ static inline unsigned long red_calc_qavg_no_idle_time(const struct red_parms *p | |||
287 | * | 227 | * |
288 | * --ANK (980924) | 228 | * --ANK (980924) |
289 | */ | 229 | */ |
290 | return v->qavg + (backlog - (v->qavg >> p->Wlog)); | 230 | return p->qavg + (backlog - (p->qavg >> p->Wlog)); |
291 | } | 231 | } |
292 | 232 | ||
293 | static inline unsigned long red_calc_qavg(const struct red_parms *p, | 233 | static inline unsigned long red_calc_qavg(struct red_parms *p, |
294 | const struct red_vars *v, | ||
295 | unsigned int backlog) | 234 | unsigned int backlog) |
296 | { | 235 | { |
297 | if (!red_is_idling(v)) | 236 | if (!red_is_idling(p)) |
298 | return red_calc_qavg_no_idle_time(p, v, backlog); | 237 | return red_calc_qavg_no_idle_time(p, backlog); |
299 | else | 238 | else |
300 | return red_calc_qavg_from_idle_time(p, v); | 239 | return red_calc_qavg_from_idle_time(p); |
301 | } | 240 | } |
302 | 241 | ||
303 | 242 | static inline u32 red_random(struct red_parms *p) | |
304 | static inline u32 red_random(const struct red_parms *p) | ||
305 | { | 243 | { |
306 | return reciprocal_divide(net_random(), p->max_P_reciprocal); | 244 | return net_random() & p->Rmask; |
307 | } | 245 | } |
308 | 246 | ||
309 | static inline int red_mark_probability(const struct red_parms *p, | 247 | static inline int red_mark_probability(struct red_parms *p, unsigned long qavg) |
310 | const struct red_vars *v, | ||
311 | unsigned long qavg) | ||
312 | { | 248 | { |
313 | /* The formula used below causes questions. | 249 | /* The formula used below causes questions. |
314 | 250 | ||
315 | OK. qR is random number in the interval | 251 | OK. qR is random number in the interval 0..Rmask |
316 | (0..1/max_P)*(qth_max-qth_min) | ||
317 | i.e. 0..(2^Plog). If we used floating point | 252 | i.e. 0..(2^Plog). If we used floating point |
318 | arithmetics, it would be: (2^Plog)*rnd_num, | 253 | arithmetics, it would be: (2^Plog)*rnd_num, |
319 | where rnd_num is less 1. | 254 | where rnd_num is less 1. |
320 | 255 | ||
321 | Taking into account, that qavg have fixed | 256 | Taking into account, that qavg have fixed |
322 | point at Wlog, two lines | 257 | point at Wlog, and Plog is related to max_P by |
258 | max_P = (qth_max-qth_min)/2^Plog; two lines | ||
323 | below have the following floating point equivalent: | 259 | below have the following floating point equivalent: |
324 | 260 | ||
325 | max_P*(qavg - qth_min)/(qth_max-qth_min) < rnd/qcount | 261 | max_P*(qavg - qth_min)/(qth_max-qth_min) < rnd/qcount |
326 | 262 | ||
327 | Any questions? --ANK (980924) | 263 | Any questions? --ANK (980924) |
328 | */ | 264 | */ |
329 | return !(((qavg - p->qth_min) >> p->Wlog) * v->qcount < v->qR); | 265 | return !(((qavg - p->qth_min) >> p->Wlog) * p->qcount < p->qR); |
330 | } | 266 | } |
331 | 267 | ||
332 | enum { | 268 | enum { |
@@ -335,7 +271,7 @@ enum { | |||
335 | RED_ABOVE_MAX_TRESH, | 271 | RED_ABOVE_MAX_TRESH, |
336 | }; | 272 | }; |
337 | 273 | ||
338 | static inline int red_cmp_thresh(const struct red_parms *p, unsigned long qavg) | 274 | static inline int red_cmp_thresh(struct red_parms *p, unsigned long qavg) |
339 | { | 275 | { |
340 | if (qavg < p->qth_min) | 276 | if (qavg < p->qth_min) |
341 | return RED_BELOW_MIN_THRESH; | 277 | return RED_BELOW_MIN_THRESH; |
@@ -351,29 +287,27 @@ enum { | |||
351 | RED_HARD_MARK, | 287 | RED_HARD_MARK, |
352 | }; | 288 | }; |
353 | 289 | ||
354 | static inline int red_action(const struct red_parms *p, | 290 | static inline int red_action(struct red_parms *p, unsigned long qavg) |
355 | struct red_vars *v, | ||
356 | unsigned long qavg) | ||
357 | { | 291 | { |
358 | switch (red_cmp_thresh(p, qavg)) { | 292 | switch (red_cmp_thresh(p, qavg)) { |
359 | case RED_BELOW_MIN_THRESH: | 293 | case RED_BELOW_MIN_THRESH: |
360 | v->qcount = -1; | 294 | p->qcount = -1; |
361 | return RED_DONT_MARK; | 295 | return RED_DONT_MARK; |
362 | 296 | ||
363 | case RED_BETWEEN_TRESH: | 297 | case RED_BETWEEN_TRESH: |
364 | if (++v->qcount) { | 298 | if (++p->qcount) { |
365 | if (red_mark_probability(p, v, qavg)) { | 299 | if (red_mark_probability(p, qavg)) { |
366 | v->qcount = 0; | 300 | p->qcount = 0; |
367 | v->qR = red_random(p); | 301 | p->qR = red_random(p); |
368 | return RED_PROB_MARK; | 302 | return RED_PROB_MARK; |
369 | } | 303 | } |
370 | } else | 304 | } else |
371 | v->qR = red_random(p); | 305 | p->qR = red_random(p); |
372 | 306 | ||
373 | return RED_DONT_MARK; | 307 | return RED_DONT_MARK; |
374 | 308 | ||
375 | case RED_ABOVE_MAX_TRESH: | 309 | case RED_ABOVE_MAX_TRESH: |
376 | v->qcount = -1; | 310 | p->qcount = -1; |
377 | return RED_HARD_MARK; | 311 | return RED_HARD_MARK; |
378 | } | 312 | } |
379 | 313 | ||
@@ -381,25 +315,4 @@ static inline int red_action(const struct red_parms *p, | |||
381 | return RED_DONT_MARK; | 315 | return RED_DONT_MARK; |
382 | } | 316 | } |
383 | 317 | ||
384 | static inline void red_adaptative_algo(struct red_parms *p, struct red_vars *v) | ||
385 | { | ||
386 | unsigned long qavg; | ||
387 | u32 max_p_delta; | ||
388 | |||
389 | qavg = v->qavg; | ||
390 | if (red_is_idling(v)) | ||
391 | qavg = red_calc_qavg_from_idle_time(p, v); | ||
392 | |||
393 | /* v->qavg is fixed point number with point at Wlog */ | ||
394 | qavg >>= p->Wlog; | ||
395 | |||
396 | if (qavg > p->target_max && p->max_P <= MAX_P_MAX) | ||
397 | p->max_P += MAX_P_ALPHA(p->max_P); /* maxp = maxp + alpha */ | ||
398 | else if (qavg < p->target_min && p->max_P >= MAX_P_MIN) | ||
399 | p->max_P = (p->max_P/10)*9; /* maxp = maxp * Beta */ | ||
400 | |||
401 | max_p_delta = DIV_ROUND_CLOSEST(p->max_P, p->qth_delta); | ||
402 | max_p_delta = max(max_p_delta, 1U); | ||
403 | p->max_P_reciprocal = reciprocal_value(max_p_delta); | ||
404 | } | ||
405 | #endif | 318 | #endif |
diff --git a/include/net/regulatory.h b/include/net/regulatory.h index 7dcaa2794fd..356d6e3dc20 100644 --- a/include/net/regulatory.h +++ b/include/net/regulatory.h | |||
@@ -3,19 +3,11 @@ | |||
3 | /* | 3 | /* |
4 | * regulatory support structures | 4 | * regulatory support structures |
5 | * | 5 | * |
6 | * Copyright 2008-2009 Luis R. Rodriguez <mcgrof@qca.qualcomm.com> | 6 | * Copyright 2008-2009 Luis R. Rodriguez <lrodriguez@atheros.com> |
7 | * | 7 | * |
8 | * Permission to use, copy, modify, and/or distribute this software for any | 8 | * This program is free software; you can redistribute it and/or modify |
9 | * purpose with or without fee is hereby granted, provided that the above | 9 | * it under the terms of the GNU General Public License version 2 as |
10 | * copyright notice and this permission notice appear in all copies. | 10 | * published by the Free Software Foundation. |
11 | * | ||
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
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 | ||
18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
19 | */ | 11 | */ |
20 | 12 | ||
21 | 13 | ||
@@ -48,14 +40,6 @@ enum environment_cap { | |||
48 | * 99 - built by driver but a specific alpha2 cannot be determined | 40 | * 99 - built by driver but a specific alpha2 cannot be determined |
49 | * 98 - result of an intersection between two regulatory domains | 41 | * 98 - result of an intersection between two regulatory domains |
50 | * 97 - regulatory domain has not yet been configured | 42 | * 97 - regulatory domain has not yet been configured |
51 | * @dfs_region: If CRDA responded with a regulatory domain that requires | ||
52 | * DFS master operation on a known DFS region (NL80211_DFS_*), | ||
53 | * dfs_region represents that region. Drivers can use this and the | ||
54 | * @alpha2 to adjust their device's DFS parameters as required. | ||
55 | * @user_reg_hint_type: if the @initiator was of type | ||
56 | * %NL80211_REGDOM_SET_BY_USER, this classifies the type | ||
57 | * of hint passed. This could be any of the %NL80211_USER_REG_HINT_* | ||
58 | * types. | ||
59 | * @intersect: indicates whether the wireless core should intersect | 43 | * @intersect: indicates whether the wireless core should intersect |
60 | * the requested regulatory domain with the presently set regulatory | 44 | * the requested regulatory domain with the presently set regulatory |
61 | * domain. | 45 | * domain. |
@@ -74,9 +58,7 @@ enum environment_cap { | |||
74 | struct regulatory_request { | 58 | struct regulatory_request { |
75 | int wiphy_idx; | 59 | int wiphy_idx; |
76 | enum nl80211_reg_initiator initiator; | 60 | enum nl80211_reg_initiator initiator; |
77 | enum nl80211_user_reg_hint_type user_reg_hint_type; | ||
78 | char alpha2[2]; | 61 | char alpha2[2]; |
79 | u8 dfs_region; | ||
80 | bool intersect; | 62 | bool intersect; |
81 | bool processed; | 63 | bool processed; |
82 | enum environment_cap country_ie_env; | 64 | enum environment_cap country_ie_env; |
@@ -103,7 +85,6 @@ struct ieee80211_reg_rule { | |||
103 | struct ieee80211_regdomain { | 85 | struct ieee80211_regdomain { |
104 | u32 n_reg_rules; | 86 | u32 n_reg_rules; |
105 | char alpha2[2]; | 87 | char alpha2[2]; |
106 | u8 dfs_region; | ||
107 | struct ieee80211_reg_rule reg_rules[]; | 88 | struct ieee80211_reg_rule reg_rules[]; |
108 | }; | 89 | }; |
109 | 90 | ||
diff --git a/include/net/request_sock.h b/include/net/request_sock.h index a51dbd17c2d..4c0766e201e 100644 --- a/include/net/request_sock.h +++ b/include/net/request_sock.h | |||
@@ -49,16 +49,13 @@ struct request_sock_ops { | |||
49 | struct request_sock *req); | 49 | struct request_sock *req); |
50 | }; | 50 | }; |
51 | 51 | ||
52 | extern int inet_rtx_syn_ack(struct sock *parent, struct request_sock *req); | ||
53 | |||
54 | /* struct request_sock - mini sock to represent a connection request | 52 | /* struct request_sock - mini sock to represent a connection request |
55 | */ | 53 | */ |
56 | struct request_sock { | 54 | struct request_sock { |
57 | struct request_sock *dl_next; /* Must be first member! */ | 55 | struct request_sock *dl_next; /* Must be first member! */ |
58 | u16 mss; | 56 | u16 mss; |
59 | u8 num_retrans; /* number of retransmits */ | 57 | u8 retrans; |
60 | u8 cookie_ts:1; /* syncookie: encode tcpopts in timestamp */ | 58 | u8 cookie_ts; /* syncookie: encode tcpopts in timestamp */ |
61 | u8 num_timeout:7; /* number of timeouts */ | ||
62 | /* The following two fields can be easily recomputed I think -AK */ | 59 | /* The following two fields can be easily recomputed I think -AK */ |
63 | u32 window_clamp; /* window clamp at creation time */ | 60 | u32 window_clamp; /* window clamp at creation time */ |
64 | u32 rcv_wnd; /* rcv_wnd offered first time */ | 61 | u32 rcv_wnd; /* rcv_wnd offered first time */ |
@@ -109,34 +106,6 @@ struct listen_sock { | |||
109 | struct request_sock *syn_table[0]; | 106 | struct request_sock *syn_table[0]; |
110 | }; | 107 | }; |
111 | 108 | ||
112 | /* | ||
113 | * For a TCP Fast Open listener - | ||
114 | * lock - protects the access to all the reqsk, which is co-owned by | ||
115 | * the listener and the child socket. | ||
116 | * qlen - pending TFO requests (still in TCP_SYN_RECV). | ||
117 | * max_qlen - max TFO reqs allowed before TFO is disabled. | ||
118 | * | ||
119 | * XXX (TFO) - ideally these fields can be made as part of "listen_sock" | ||
120 | * structure above. But there is some implementation difficulty due to | ||
121 | * listen_sock being part of request_sock_queue hence will be freed when | ||
122 | * a listener is stopped. But TFO related fields may continue to be | ||
123 | * accessed even after a listener is closed, until its sk_refcnt drops | ||
124 | * to 0 implying no more outstanding TFO reqs. One solution is to keep | ||
125 | * listen_opt around until sk_refcnt drops to 0. But there is some other | ||
126 | * complexity that needs to be resolved. E.g., a listener can be disabled | ||
127 | * temporarily through shutdown()->tcp_disconnect(), and re-enabled later. | ||
128 | */ | ||
129 | struct fastopen_queue { | ||
130 | struct request_sock *rskq_rst_head; /* Keep track of past TFO */ | ||
131 | struct request_sock *rskq_rst_tail; /* requests that caused RST. | ||
132 | * This is part of the defense | ||
133 | * against spoofing attack. | ||
134 | */ | ||
135 | spinlock_t lock; | ||
136 | int qlen; /* # of pending (TCP_SYN_RECV) reqs */ | ||
137 | int max_qlen; /* != 0 iff TFO is currently enabled */ | ||
138 | }; | ||
139 | |||
140 | /** struct request_sock_queue - queue of request_socks | 109 | /** struct request_sock_queue - queue of request_socks |
141 | * | 110 | * |
142 | * @rskq_accept_head - FIFO head of established children | 111 | * @rskq_accept_head - FIFO head of established children |
@@ -160,12 +129,6 @@ struct request_sock_queue { | |||
160 | u8 rskq_defer_accept; | 129 | u8 rskq_defer_accept; |
161 | /* 3 bytes hole, try to pack */ | 130 | /* 3 bytes hole, try to pack */ |
162 | struct listen_sock *listen_opt; | 131 | struct listen_sock *listen_opt; |
163 | struct fastopen_queue *fastopenq; /* This is non-NULL iff TFO has been | ||
164 | * enabled on this listener. Check | ||
165 | * max_qlen != 0 in fastopen_queue | ||
166 | * to determine if TFO is enabled | ||
167 | * right at this moment. | ||
168 | */ | ||
169 | }; | 132 | }; |
170 | 133 | ||
171 | extern int reqsk_queue_alloc(struct request_sock_queue *queue, | 134 | extern int reqsk_queue_alloc(struct request_sock_queue *queue, |
@@ -173,8 +136,6 @@ extern int reqsk_queue_alloc(struct request_sock_queue *queue, | |||
173 | 136 | ||
174 | extern void __reqsk_queue_destroy(struct request_sock_queue *queue); | 137 | extern void __reqsk_queue_destroy(struct request_sock_queue *queue); |
175 | extern void reqsk_queue_destroy(struct request_sock_queue *queue); | 138 | extern void reqsk_queue_destroy(struct request_sock_queue *queue); |
176 | extern void reqsk_fastopen_remove(struct sock *sk, | ||
177 | struct request_sock *req, bool reset); | ||
178 | 139 | ||
179 | static inline struct request_sock * | 140 | static inline struct request_sock * |
180 | reqsk_queue_yank_acceptq(struct request_sock_queue *queue) | 141 | reqsk_queue_yank_acceptq(struct request_sock_queue *queue) |
@@ -229,12 +190,25 @@ static inline struct request_sock *reqsk_queue_remove(struct request_sock_queue | |||
229 | return req; | 190 | return req; |
230 | } | 191 | } |
231 | 192 | ||
193 | static inline struct sock *reqsk_queue_get_child(struct request_sock_queue *queue, | ||
194 | struct sock *parent) | ||
195 | { | ||
196 | struct request_sock *req = reqsk_queue_remove(queue); | ||
197 | struct sock *child = req->sk; | ||
198 | |||
199 | WARN_ON(child == NULL); | ||
200 | |||
201 | sk_acceptq_removed(parent); | ||
202 | __reqsk_free(req); | ||
203 | return child; | ||
204 | } | ||
205 | |||
232 | static inline int reqsk_queue_removed(struct request_sock_queue *queue, | 206 | static inline int reqsk_queue_removed(struct request_sock_queue *queue, |
233 | struct request_sock *req) | 207 | struct request_sock *req) |
234 | { | 208 | { |
235 | struct listen_sock *lopt = queue->listen_opt; | 209 | struct listen_sock *lopt = queue->listen_opt; |
236 | 210 | ||
237 | if (req->num_timeout == 0) | 211 | if (req->retrans == 0) |
238 | --lopt->qlen_young; | 212 | --lopt->qlen_young; |
239 | 213 | ||
240 | return --lopt->qlen; | 214 | return --lopt->qlen; |
@@ -272,8 +246,7 @@ static inline void reqsk_queue_hash_req(struct request_sock_queue *queue, | |||
272 | struct listen_sock *lopt = queue->listen_opt; | 246 | struct listen_sock *lopt = queue->listen_opt; |
273 | 247 | ||
274 | req->expires = jiffies + timeout; | 248 | req->expires = jiffies + timeout; |
275 | req->num_retrans = 0; | 249 | req->retrans = 0; |
276 | req->num_timeout = 0; | ||
277 | req->sk = NULL; | 250 | req->sk = NULL; |
278 | req->dl_next = lopt->syn_table[hash]; | 251 | req->dl_next = lopt->syn_table[hash]; |
279 | 252 | ||
diff --git a/include/net/route.h b/include/net/route.h index 2ea40c1b5e0..db7b3432f07 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -30,7 +30,6 @@ | |||
30 | #include <net/inet_sock.h> | 30 | #include <net/inet_sock.h> |
31 | #include <linux/in_route.h> | 31 | #include <linux/in_route.h> |
32 | #include <linux/rtnetlink.h> | 32 | #include <linux/rtnetlink.h> |
33 | #include <linux/rcupdate.h> | ||
34 | #include <linux/route.h> | 33 | #include <linux/route.h> |
35 | #include <linux/ip.h> | 34 | #include <linux/ip.h> |
36 | #include <linux/cache.h> | 35 | #include <linux/cache.h> |
@@ -41,42 +40,45 @@ | |||
41 | #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)) |
42 | 41 | ||
43 | struct fib_nh; | 42 | struct fib_nh; |
43 | struct inet_peer; | ||
44 | struct fib_info; | 44 | struct fib_info; |
45 | struct rtable { | 45 | struct rtable { |
46 | struct dst_entry dst; | 46 | struct dst_entry dst; |
47 | 47 | ||
48 | /* Lookup key. */ | ||
49 | __be32 rt_key_dst; | ||
50 | __be32 rt_key_src; | ||
51 | |||
48 | int rt_genid; | 52 | int rt_genid; |
49 | unsigned int rt_flags; | 53 | unsigned rt_flags; |
50 | __u16 rt_type; | 54 | __u16 rt_type; |
51 | __u8 rt_is_input; | 55 | __u8 rt_key_tos; |
52 | __u8 rt_uses_gateway; | ||
53 | 56 | ||
57 | __be32 rt_dst; /* Path destination */ | ||
58 | __be32 rt_src; /* Path source */ | ||
59 | int rt_route_iif; | ||
54 | int rt_iif; | 60 | int rt_iif; |
61 | int rt_oif; | ||
62 | __u32 rt_mark; | ||
55 | 63 | ||
56 | /* Info on neighbour */ | 64 | /* Info on neighbour */ |
57 | __be32 rt_gateway; | 65 | __be32 rt_gateway; |
58 | 66 | ||
59 | /* Miscellaneous cached information */ | 67 | /* Miscellaneous cached information */ |
60 | u32 rt_pmtu; | 68 | __be32 rt_spec_dst; /* RFC1122 specific destination */ |
61 | 69 | u32 rt_peer_genid; | |
62 | struct list_head rt_uncached; | 70 | struct inet_peer *peer; /* long-living peer info */ |
71 | struct fib_info *fi; /* for client ref to shared metrics */ | ||
63 | }; | 72 | }; |
64 | 73 | ||
65 | static inline bool rt_is_input_route(const struct rtable *rt) | 74 | static inline bool rt_is_input_route(struct rtable *rt) |
66 | { | ||
67 | return rt->rt_is_input != 0; | ||
68 | } | ||
69 | |||
70 | static inline bool rt_is_output_route(const struct rtable *rt) | ||
71 | { | 75 | { |
72 | return rt->rt_is_input == 0; | 76 | return rt->rt_route_iif != 0; |
73 | } | 77 | } |
74 | 78 | ||
75 | static inline __be32 rt_nexthop(const struct rtable *rt, __be32 daddr) | 79 | static inline bool rt_is_output_route(struct rtable *rt) |
76 | { | 80 | { |
77 | if (rt->rt_gateway) | 81 | return rt->rt_route_iif == 0; |
78 | return rt->rt_gateway; | ||
79 | return daddr; | ||
80 | } | 82 | } |
81 | 83 | ||
82 | struct ip_rt_acct { | 84 | struct ip_rt_acct { |
@@ -109,8 +111,10 @@ extern struct ip_rt_acct __percpu *ip_rt_acct; | |||
109 | 111 | ||
110 | struct in_device; | 112 | struct in_device; |
111 | extern int ip_rt_init(void); | 113 | extern int ip_rt_init(void); |
112 | extern void rt_cache_flush(struct net *net); | 114 | extern void ip_rt_redirect(__be32 old_gw, __be32 dst, __be32 new_gw, |
113 | extern void rt_flush_dev(struct net_device *dev); | 115 | __be32 src, struct net_device *dev); |
116 | extern void rt_cache_flush(struct net *net, int how); | ||
117 | extern void rt_cache_flush_batch(struct net *net); | ||
114 | extern struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp); | 118 | extern struct rtable *__ip_route_output_key(struct net *, struct flowi4 *flp); |
115 | extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp, | 119 | extern struct rtable *ip_route_output_flow(struct net *, struct flowi4 *flp, |
116 | struct sock *sk); | 120 | struct sock *sk); |
@@ -126,9 +130,9 @@ static inline struct rtable *ip_route_output(struct net *net, __be32 daddr, | |||
126 | { | 130 | { |
127 | struct flowi4 fl4 = { | 131 | struct flowi4 fl4 = { |
128 | .flowi4_oif = oif, | 132 | .flowi4_oif = oif, |
129 | .flowi4_tos = tos, | ||
130 | .daddr = daddr, | 133 | .daddr = daddr, |
131 | .saddr = saddr, | 134 | .saddr = saddr, |
135 | .flowi4_tos = tos, | ||
132 | }; | 136 | }; |
133 | return ip_route_output_key(net, &fl4); | 137 | return ip_route_output_key(net, &fl4); |
134 | } | 138 | } |
@@ -162,33 +166,27 @@ static inline struct rtable *ip_route_output_gre(struct net *net, struct flowi4 | |||
162 | return ip_route_output_key(net, fl4); | 166 | return ip_route_output_key(net, fl4); |
163 | } | 167 | } |
164 | 168 | ||
165 | extern int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src, | 169 | extern int ip_route_input_common(struct sk_buff *skb, __be32 dst, __be32 src, |
166 | u8 tos, struct net_device *devin); | 170 | u8 tos, struct net_device *devin, bool noref); |
167 | 171 | ||
168 | static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src, | 172 | static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src, |
169 | u8 tos, struct net_device *devin) | 173 | u8 tos, struct net_device *devin) |
170 | { | 174 | { |
171 | int err; | 175 | return ip_route_input_common(skb, dst, src, tos, devin, false); |
172 | 176 | } | |
173 | rcu_read_lock(); | ||
174 | err = ip_route_input_noref(skb, dst, src, tos, devin); | ||
175 | if (!err) | ||
176 | skb_dst_force(skb); | ||
177 | rcu_read_unlock(); | ||
178 | 177 | ||
179 | return err; | 178 | static inline int ip_route_input_noref(struct sk_buff *skb, __be32 dst, __be32 src, |
179 | u8 tos, struct net_device *devin) | ||
180 | { | ||
181 | return ip_route_input_common(skb, dst, src, tos, devin, true); | ||
180 | } | 182 | } |
181 | 183 | ||
182 | extern void ipv4_update_pmtu(struct sk_buff *skb, struct net *net, u32 mtu, | 184 | extern unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph, |
183 | int oif, u32 mark, u8 protocol, int flow_flags); | 185 | unsigned short new_mtu, struct net_device *dev); |
184 | extern void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu); | 186 | extern void ip_rt_send_redirect(struct sk_buff *skb); |
185 | extern void ipv4_redirect(struct sk_buff *skb, struct net *net, | ||
186 | int oif, u32 mark, u8 protocol, int flow_flags); | ||
187 | extern void ipv4_sk_redirect(struct sk_buff *skb, struct sock *sk); | ||
188 | extern void ip_rt_send_redirect(struct sk_buff *skb); | ||
189 | 187 | ||
190 | extern unsigned int inet_addr_type(struct net *net, __be32 addr); | 188 | extern unsigned inet_addr_type(struct net *net, __be32 addr); |
191 | extern unsigned int 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); |
192 | extern void ip_rt_multicast_event(struct in_device *); | 190 | extern void ip_rt_multicast_event(struct in_device *); |
193 | 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); |
194 | extern void ip_rt_get_source(u8 *src, struct sk_buff *skb, struct rtable *rt); | 192 | extern void ip_rt_get_source(u8 *src, struct sk_buff *skb, struct rtable *rt); |
@@ -198,13 +196,10 @@ struct in_ifaddr; | |||
198 | extern void fib_add_ifaddr(struct in_ifaddr *); | 196 | extern void fib_add_ifaddr(struct in_ifaddr *); |
199 | extern void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *); | 197 | extern void fib_del_ifaddr(struct in_ifaddr *, struct in_ifaddr *); |
200 | 198 | ||
201 | static inline void ip_rt_put(struct rtable *rt) | 199 | static inline void ip_rt_put(struct rtable * rt) |
202 | { | 200 | { |
203 | /* dst_release() accepts a NULL parameter. | 201 | if (rt) |
204 | * We rely on dst being first structure in struct rtable | 202 | dst_release(&rt->dst); |
205 | */ | ||
206 | BUILD_BUG_ON(offsetof(struct rtable, dst) != 0); | ||
207 | dst_release(&rt->dst); | ||
208 | } | 203 | } |
209 | 204 | ||
210 | #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3) | 205 | #define IPTOS_RT_MASK (IPTOS_TOS_MASK & ~3) |
@@ -249,6 +244,8 @@ static inline void ip_route_connect_init(struct flowi4 *fl4, __be32 dst, __be32 | |||
249 | 244 | ||
250 | if (inet_sk(sk)->transparent) | 245 | if (inet_sk(sk)->transparent) |
251 | flow_flags |= FLOWI_FLAG_ANYSRC; | 246 | flow_flags |= FLOWI_FLAG_ANYSRC; |
247 | if (protocol == IPPROTO_TCP) | ||
248 | flow_flags |= FLOWI_FLAG_PRECOW_METRICS; | ||
252 | if (can_sleep) | 249 | if (can_sleep) |
253 | flow_flags |= FLOWI_FLAG_CAN_SLEEP; | 250 | flow_flags |= FLOWI_FLAG_CAN_SLEEP; |
254 | 251 | ||
@@ -273,7 +270,6 @@ static inline struct rtable *ip_route_connect(struct flowi4 *fl4, | |||
273 | if (IS_ERR(rt)) | 270 | if (IS_ERR(rt)) |
274 | return rt; | 271 | return rt; |
275 | ip_rt_put(rt); | 272 | ip_rt_put(rt); |
276 | flowi4_update_output(fl4, oif, tos, fl4->daddr, fl4->saddr); | ||
277 | } | 273 | } |
278 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); | 274 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); |
279 | return ip_route_output_flow(net, fl4, sk); | 275 | return ip_route_output_flow(net, fl4, sk); |
@@ -288,22 +284,26 @@ static inline struct rtable *ip_route_newports(struct flowi4 *fl4, struct rtable | |||
288 | fl4->fl4_dport = dport; | 284 | fl4->fl4_dport = dport; |
289 | fl4->fl4_sport = sport; | 285 | fl4->fl4_sport = sport; |
290 | ip_rt_put(rt); | 286 | ip_rt_put(rt); |
291 | flowi4_update_output(fl4, sk->sk_bound_dev_if, | ||
292 | RT_CONN_FLAGS(sk), fl4->daddr, | ||
293 | fl4->saddr); | ||
294 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); | 287 | security_sk_classify_flow(sk, flowi4_to_flowi(fl4)); |
295 | return ip_route_output_flow(sock_net(sk), fl4, sk); | 288 | return ip_route_output_flow(sock_net(sk), fl4, sk); |
296 | } | 289 | } |
297 | return rt; | 290 | return rt; |
298 | } | 291 | } |
299 | 292 | ||
300 | static inline int inet_iif(const struct sk_buff *skb) | 293 | extern void rt_bind_peer(struct rtable *rt, __be32 daddr, int create); |
294 | |||
295 | static inline struct inet_peer *rt_get_peer(struct rtable *rt, __be32 daddr) | ||
301 | { | 296 | { |
302 | int iif = skb_rtable(skb)->rt_iif; | 297 | if (rt->peer) |
298 | return rt->peer; | ||
303 | 299 | ||
304 | if (iif) | 300 | rt_bind_peer(rt, daddr, 0); |
305 | return iif; | 301 | return rt->peer; |
306 | return skb->skb_iif; | 302 | } |
303 | |||
304 | static inline int inet_iif(const struct sk_buff *skb) | ||
305 | { | ||
306 | return skb_rtable(skb)->rt_iif; | ||
307 | } | 307 | } |
308 | 308 | ||
309 | extern int sysctl_ip_default_ttl; | 309 | extern int sysctl_ip_default_ttl; |
diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h index 5a15fabd6a7..678f1ffaf84 100644 --- a/include/net/rtnetlink.h +++ b/include/net/rtnetlink.h | |||
@@ -6,7 +6,7 @@ | |||
6 | 6 | ||
7 | typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *); | 7 | typedef int (*rtnl_doit_func)(struct sk_buff *, struct nlmsghdr *, void *); |
8 | typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *); | 8 | typedef int (*rtnl_dumpit_func)(struct sk_buff *, struct netlink_callback *); |
9 | typedef u16 (*rtnl_calcit_func)(struct sk_buff *, struct nlmsghdr *); | 9 | typedef u16 (*rtnl_calcit_func)(struct sk_buff *); |
10 | 10 | ||
11 | extern int __rtnl_register(int protocol, int msgtype, | 11 | extern int __rtnl_register(int protocol, int msgtype, |
12 | rtnl_doit_func, rtnl_dumpit_func, | 12 | rtnl_doit_func, rtnl_dumpit_func, |
@@ -41,13 +41,9 @@ static inline int rtnl_msg_family(const struct nlmsghdr *nlh) | |||
41 | * @get_size: Function to calculate required room for dumping device | 41 | * @get_size: Function to calculate required room for dumping device |
42 | * specific netlink attributes | 42 | * specific netlink attributes |
43 | * @fill_info: Function to dump device specific netlink attributes | 43 | * @fill_info: Function to dump device specific netlink attributes |
44 | * @get_xstats_size: Function to calculate required room for dumping device | 44 | * @get_xstats_size: Function to calculate required room for dumping devic |
45 | * specific statistics | 45 | * specific statistics |
46 | * @fill_xstats: Function to dump device specific statistics | 46 | * @fill_xstats: Function to dump device specific statistics |
47 | * @get_num_tx_queues: Function to determine number of transmit queues | ||
48 | * to create when creating a new device. | ||
49 | * @get_num_rx_queues: Function to determine number of receive queues | ||
50 | * to create when creating a new device. | ||
51 | */ | 47 | */ |
52 | struct rtnl_link_ops { | 48 | struct rtnl_link_ops { |
53 | struct list_head list; | 49 | struct list_head list; |
@@ -79,8 +75,9 @@ struct rtnl_link_ops { | |||
79 | size_t (*get_xstats_size)(const struct net_device *dev); | 75 | size_t (*get_xstats_size)(const struct net_device *dev); |
80 | int (*fill_xstats)(struct sk_buff *skb, | 76 | int (*fill_xstats)(struct sk_buff *skb, |
81 | const struct net_device *dev); | 77 | const struct net_device *dev); |
82 | unsigned int (*get_num_tx_queues)(void); | 78 | int (*get_tx_queues)(struct net *net, struct nlattr *tb[], |
83 | unsigned int (*get_num_rx_queues)(void); | 79 | unsigned int *tx_queues, |
80 | unsigned int *real_tx_queues); | ||
84 | }; | 81 | }; |
85 | 82 | ||
86 | extern int __rtnl_link_register(struct rtnl_link_ops *ops); | 83 | extern int __rtnl_link_register(struct rtnl_link_ops *ops); |
@@ -97,7 +94,7 @@ extern void rtnl_link_unregister(struct rtnl_link_ops *ops); | |||
97 | * @fill_link_af: Function to fill IFLA_AF_SPEC with address family | 94 | * @fill_link_af: Function to fill IFLA_AF_SPEC with address family |
98 | * specific netlink attributes. | 95 | * specific netlink attributes. |
99 | * @get_link_af_size: Function to calculate size of address family specific | 96 | * @get_link_af_size: Function to calculate size of address family specific |
100 | * netlink attributes. | 97 | * netlink attributes exlusive the container attribute. |
101 | * @validate_link_af: Validate a IFLA_AF_SPEC attribute, must check attr | 98 | * @validate_link_af: Validate a IFLA_AF_SPEC attribute, must check attr |
102 | * for invalid configuration settings. | 99 | * for invalid configuration settings. |
103 | * @set_link_af: Function to parse a IFLA_AF_SPEC attribute and modify | 100 | * @set_link_af: Function to parse a IFLA_AF_SPEC attribute and modify |
@@ -125,7 +122,7 @@ extern void rtnl_af_unregister(struct rtnl_af_ops *ops); | |||
125 | 122 | ||
126 | 123 | ||
127 | extern struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]); | 124 | extern struct net *rtnl_link_get_net(struct net *src_net, struct nlattr *tb[]); |
128 | extern struct net_device *rtnl_create_link(struct net *net, | 125 | extern struct net_device *rtnl_create_link(struct net *src_net, struct net *net, |
129 | char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]); | 126 | char *ifname, const struct rtnl_link_ops *ops, struct nlattr *tb[]); |
130 | extern int rtnl_configure_link(struct net_device *dev, | 127 | extern int rtnl_configure_link(struct net_device *dev, |
131 | const struct ifinfomsg *ifm); | 128 | const struct ifinfomsg *ifm); |
diff --git a/include/net/sch_generic.h b/include/net/sch_generic.h index 1540f9c2fcf..4fc88f3ccd5 100644 --- a/include/net/sch_generic.h +++ b/include/net/sch_generic.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <linux/netdevice.h> | 4 | #include <linux/netdevice.h> |
5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
6 | #include <linux/rcupdate.h> | 6 | #include <linux/rcupdate.h> |
7 | #include <linux/module.h> | ||
7 | #include <linux/pkt_sched.h> | 8 | #include <linux/pkt_sched.h> |
8 | #include <linux/pkt_cls.h> | 9 | #include <linux/pkt_cls.h> |
9 | #include <net/gen_stats.h> | 10 | #include <net/gen_stats.h> |
@@ -45,21 +46,14 @@ struct qdisc_size_table { | |||
45 | struct Qdisc { | 46 | struct Qdisc { |
46 | int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev); | 47 | int (*enqueue)(struct sk_buff *skb, struct Qdisc *dev); |
47 | struct sk_buff * (*dequeue)(struct Qdisc *dev); | 48 | struct sk_buff * (*dequeue)(struct Qdisc *dev); |
48 | unsigned int flags; | 49 | unsigned flags; |
49 | #define TCQ_F_BUILTIN 1 | 50 | #define TCQ_F_BUILTIN 1 |
50 | #define TCQ_F_INGRESS 2 | 51 | #define TCQ_F_INGRESS 2 |
51 | #define TCQ_F_CAN_BYPASS 4 | 52 | #define TCQ_F_CAN_BYPASS 4 |
52 | #define TCQ_F_MQROOT 8 | 53 | #define TCQ_F_MQROOT 8 |
53 | #define TCQ_F_ONETXQUEUE 0x10 /* dequeue_skb() can assume all skbs are for | ||
54 | * q->dev_queue : It can test | ||
55 | * netif_xmit_frozen_or_stopped() before | ||
56 | * dequeueing next packet. | ||
57 | * Its true for MQ/MQPRIO slaves, or non | ||
58 | * multiqueue device. | ||
59 | */ | ||
60 | #define TCQ_F_WARN_NONWC (1 << 16) | 54 | #define TCQ_F_WARN_NONWC (1 << 16) |
61 | int padded; | 55 | int padded; |
62 | const struct Qdisc_ops *ops; | 56 | struct Qdisc_ops *ops; |
63 | struct qdisc_size_table __rcu *stab; | 57 | struct qdisc_size_table __rcu *stab; |
64 | struct list_head list; | 58 | struct list_head list; |
65 | u32 handle; | 59 | u32 handle; |
@@ -195,8 +189,7 @@ struct tcf_proto_ops { | |||
195 | 189 | ||
196 | unsigned long (*get)(struct tcf_proto*, u32 handle); | 190 | unsigned long (*get)(struct tcf_proto*, u32 handle); |
197 | void (*put)(struct tcf_proto*, unsigned long); | 191 | void (*put)(struct tcf_proto*, unsigned long); |
198 | int (*change)(struct sk_buff *, | 192 | int (*change)(struct tcf_proto*, unsigned long, |
199 | struct tcf_proto*, unsigned long, | ||
200 | u32 handle, struct nlattr **, | 193 | u32 handle, struct nlattr **, |
201 | unsigned long *); | 194 | unsigned long *); |
202 | int (*delete)(struct tcf_proto*, unsigned long); | 195 | int (*delete)(struct tcf_proto*, unsigned long); |
@@ -228,20 +221,10 @@ struct tcf_proto { | |||
228 | 221 | ||
229 | struct qdisc_skb_cb { | 222 | struct qdisc_skb_cb { |
230 | unsigned int pkt_len; | 223 | unsigned int pkt_len; |
231 | u16 slave_dev_queue_mapping; | 224 | long data[]; |
232 | u16 _pad; | ||
233 | unsigned char data[20]; | ||
234 | }; | 225 | }; |
235 | 226 | ||
236 | static inline void qdisc_cb_private_validate(const struct sk_buff *skb, int sz) | 227 | static inline int qdisc_qlen(struct Qdisc *q) |
237 | { | ||
238 | struct qdisc_skb_cb *qcb; | ||
239 | |||
240 | BUILD_BUG_ON(sizeof(skb->cb) < offsetof(struct qdisc_skb_cb, data) + sz); | ||
241 | BUILD_BUG_ON(sizeof(qcb->data) < sz); | ||
242 | } | ||
243 | |||
244 | static inline int qdisc_qlen(const struct Qdisc *q) | ||
245 | { | 228 | { |
246 | return q->q.qlen; | 229 | return q->q.qlen; |
247 | } | 230 | } |
@@ -256,12 +239,12 @@ static inline spinlock_t *qdisc_lock(struct Qdisc *qdisc) | |||
256 | return &qdisc->q.lock; | 239 | return &qdisc->q.lock; |
257 | } | 240 | } |
258 | 241 | ||
259 | static inline struct Qdisc *qdisc_root(const struct Qdisc *qdisc) | 242 | static inline struct Qdisc *qdisc_root(struct Qdisc *qdisc) |
260 | { | 243 | { |
261 | return qdisc->dev_queue->qdisc; | 244 | return qdisc->dev_queue->qdisc; |
262 | } | 245 | } |
263 | 246 | ||
264 | static inline struct Qdisc *qdisc_root_sleeping(const struct Qdisc *qdisc) | 247 | static inline struct Qdisc *qdisc_root_sleeping(struct Qdisc *qdisc) |
265 | { | 248 | { |
266 | return qdisc->dev_queue->qdisc_sleeping; | 249 | return qdisc->dev_queue->qdisc_sleeping; |
267 | } | 250 | } |
@@ -277,7 +260,7 @@ static inline struct Qdisc *qdisc_root_sleeping(const struct Qdisc *qdisc) | |||
277 | * root. This is enforced by holding the RTNL semaphore, which | 260 | * root. This is enforced by holding the RTNL semaphore, which |
278 | * all users of this lock accessor must do. | 261 | * all users of this lock accessor must do. |
279 | */ | 262 | */ |
280 | static inline spinlock_t *qdisc_root_lock(const struct Qdisc *qdisc) | 263 | static inline spinlock_t *qdisc_root_lock(struct Qdisc *qdisc) |
281 | { | 264 | { |
282 | struct Qdisc *root = qdisc_root(qdisc); | 265 | struct Qdisc *root = qdisc_root(qdisc); |
283 | 266 | ||
@@ -285,7 +268,7 @@ static inline spinlock_t *qdisc_root_lock(const struct Qdisc *qdisc) | |||
285 | return qdisc_lock(root); | 268 | return qdisc_lock(root); |
286 | } | 269 | } |
287 | 270 | ||
288 | static inline spinlock_t *qdisc_root_sleeping_lock(const struct Qdisc *qdisc) | 271 | static inline spinlock_t *qdisc_root_sleeping_lock(struct Qdisc *qdisc) |
289 | { | 272 | { |
290 | struct Qdisc *root = qdisc_root_sleeping(qdisc); | 273 | struct Qdisc *root = qdisc_root_sleeping(qdisc); |
291 | 274 | ||
@@ -293,17 +276,17 @@ static inline spinlock_t *qdisc_root_sleeping_lock(const struct Qdisc *qdisc) | |||
293 | return qdisc_lock(root); | 276 | return qdisc_lock(root); |
294 | } | 277 | } |
295 | 278 | ||
296 | static inline struct net_device *qdisc_dev(const struct Qdisc *qdisc) | 279 | static inline struct net_device *qdisc_dev(struct Qdisc *qdisc) |
297 | { | 280 | { |
298 | return qdisc->dev_queue->dev; | 281 | return qdisc->dev_queue->dev; |
299 | } | 282 | } |
300 | 283 | ||
301 | static inline void sch_tree_lock(const struct Qdisc *q) | 284 | static inline void sch_tree_lock(struct Qdisc *q) |
302 | { | 285 | { |
303 | spin_lock_bh(qdisc_root_sleeping_lock(q)); | 286 | spin_lock_bh(qdisc_root_sleeping_lock(q)); |
304 | } | 287 | } |
305 | 288 | ||
306 | static inline void sch_tree_unlock(const struct Qdisc *q) | 289 | static inline void sch_tree_unlock(struct Qdisc *q) |
307 | { | 290 | { |
308 | spin_unlock_bh(qdisc_root_sleeping_lock(q)); | 291 | spin_unlock_bh(qdisc_root_sleeping_lock(q)); |
309 | } | 292 | } |
@@ -336,7 +319,7 @@ static inline unsigned int qdisc_class_hash(u32 id, u32 mask) | |||
336 | } | 319 | } |
337 | 320 | ||
338 | static inline struct Qdisc_class_common * | 321 | static inline struct Qdisc_class_common * |
339 | qdisc_class_find(const struct Qdisc_class_hash *hash, u32 id) | 322 | qdisc_class_find(struct Qdisc_class_hash *hash, u32 id) |
340 | { | 323 | { |
341 | struct Qdisc_class_common *cl; | 324 | struct Qdisc_class_common *cl; |
342 | struct hlist_node *n; | 325 | struct hlist_node *n; |
@@ -410,7 +393,7 @@ static inline bool qdisc_all_tx_empty(const struct net_device *dev) | |||
410 | } | 393 | } |
411 | 394 | ||
412 | /* Are any of the TX qdiscs changing? */ | 395 | /* Are any of the TX qdiscs changing? */ |
413 | static inline bool qdisc_tx_changing(const struct net_device *dev) | 396 | static inline bool qdisc_tx_changing(struct net_device *dev) |
414 | { | 397 | { |
415 | unsigned int i; | 398 | unsigned int i; |
416 | for (i = 0; i < dev->num_tx_queues; i++) { | 399 | for (i = 0; i < dev->num_tx_queues; i++) { |
diff --git a/include/net/scm.h b/include/net/scm.h index 975cca01048..745460fa2f0 100644 --- a/include/net/scm.h +++ b/include/net/scm.h | |||
@@ -12,13 +12,8 @@ | |||
12 | */ | 12 | */ |
13 | #define SCM_MAX_FD 253 | 13 | #define SCM_MAX_FD 253 |
14 | 14 | ||
15 | struct scm_creds { | ||
16 | u32 pid; | ||
17 | kuid_t uid; | ||
18 | kgid_t gid; | ||
19 | }; | ||
20 | |||
21 | struct scm_fp_list { | 15 | struct scm_fp_list { |
16 | struct list_head list; | ||
22 | short count; | 17 | short count; |
23 | short max; | 18 | short max; |
24 | struct file *fp[SCM_MAX_FD]; | 19 | struct file *fp[SCM_MAX_FD]; |
@@ -28,7 +23,7 @@ struct scm_cookie { | |||
28 | struct pid *pid; /* Skb credentials */ | 23 | struct pid *pid; /* Skb credentials */ |
29 | const struct cred *cred; | 24 | const struct cred *cred; |
30 | struct scm_fp_list *fp; /* Passed files */ | 25 | struct scm_fp_list *fp; /* Passed files */ |
31 | struct scm_creds creds; /* Skb credentials */ | 26 | struct ucred creds; /* Skb credentials */ |
32 | #ifdef CONFIG_SECURITY_NETWORK | 27 | #ifdef CONFIG_SECURITY_NETWORK |
33 | u32 secid; /* Passed security ID */ | 28 | u32 secid; /* Passed security ID */ |
34 | #endif | 29 | #endif |
@@ -54,10 +49,8 @@ static __inline__ void scm_set_cred(struct scm_cookie *scm, | |||
54 | struct pid *pid, const struct cred *cred) | 49 | struct pid *pid, const struct cred *cred) |
55 | { | 50 | { |
56 | scm->pid = get_pid(pid); | 51 | scm->pid = get_pid(pid); |
57 | scm->cred = cred ? get_cred(cred) : NULL; | 52 | scm->cred = get_cred(cred); |
58 | scm->creds.pid = pid_vnr(pid); | 53 | cred_to_ucred(pid, cred, &scm->creds); |
59 | scm->creds.uid = cred ? cred->euid : INVALID_UID; | ||
60 | scm->creds.gid = cred ? cred->egid : INVALID_GID; | ||
61 | } | 54 | } |
62 | 55 | ||
63 | static __inline__ void scm_destroy_cred(struct scm_cookie *scm) | 56 | static __inline__ void scm_destroy_cred(struct scm_cookie *scm) |
@@ -73,16 +66,15 @@ static __inline__ void scm_destroy_cred(struct scm_cookie *scm) | |||
73 | static __inline__ void scm_destroy(struct scm_cookie *scm) | 66 | static __inline__ void scm_destroy(struct scm_cookie *scm) |
74 | { | 67 | { |
75 | scm_destroy_cred(scm); | 68 | scm_destroy_cred(scm); |
76 | if (scm->fp) | 69 | if (scm && scm->fp) |
77 | __scm_destroy(scm); | 70 | __scm_destroy(scm); |
78 | } | 71 | } |
79 | 72 | ||
80 | static __inline__ int scm_send(struct socket *sock, struct msghdr *msg, | 73 | static __inline__ int scm_send(struct socket *sock, struct msghdr *msg, |
81 | struct scm_cookie *scm, bool forcecreds) | 74 | struct scm_cookie *scm) |
82 | { | 75 | { |
83 | memset(scm, 0, sizeof(*scm)); | 76 | scm_set_cred(scm, task_tgid(current), current_cred()); |
84 | if (forcecreds) | 77 | scm->fp = NULL; |
85 | scm_set_cred(scm, task_tgid(current), current_cred()); | ||
86 | unix_get_peersec_dgram(sock, scm); | 78 | unix_get_peersec_dgram(sock, scm); |
87 | if (msg->msg_controllen <= 0) | 79 | if (msg->msg_controllen <= 0) |
88 | return 0; | 80 | return 0; |
@@ -120,15 +112,8 @@ static __inline__ void scm_recv(struct socket *sock, struct msghdr *msg, | |||
120 | return; | 112 | return; |
121 | } | 113 | } |
122 | 114 | ||
123 | if (test_bit(SOCK_PASSCRED, &sock->flags)) { | 115 | if (test_bit(SOCK_PASSCRED, &sock->flags)) |
124 | struct user_namespace *current_ns = current_user_ns(); | 116 | put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(scm->creds), &scm->creds); |
125 | struct ucred ucreds = { | ||
126 | .pid = scm->creds.pid, | ||
127 | .uid = from_kuid_munged(current_ns, scm->creds.uid), | ||
128 | .gid = from_kgid_munged(current_ns, scm->creds.gid), | ||
129 | }; | ||
130 | put_cmsg(msg, SOL_SOCKET, SCM_CREDENTIALS, sizeof(ucreds), &ucreds); | ||
131 | } | ||
132 | 117 | ||
133 | scm_destroy_cred(scm); | 118 | scm_destroy_cred(scm); |
134 | 119 | ||
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h index 35247271e55..712b3bebeda 100644 --- a/include/net/sctp/command.h +++ b/include/net/sctp/command.h | |||
@@ -130,6 +130,8 @@ typedef union { | |||
130 | __be16 err; | 130 | __be16 err; |
131 | sctp_state_t state; | 131 | sctp_state_t state; |
132 | sctp_event_timeout_t to; | 132 | sctp_event_timeout_t to; |
133 | unsigned long zero; | ||
134 | void *ptr; | ||
133 | struct sctp_chunk *chunk; | 135 | struct sctp_chunk *chunk; |
134 | struct sctp_association *asoc; | 136 | struct sctp_association *asoc; |
135 | struct sctp_transport *transport; | 137 | struct sctp_transport *transport; |
@@ -152,15 +154,23 @@ typedef union { | |||
152 | * which takes an __s32 and returns a sctp_arg_t containing the | 154 | * which takes an __s32 and returns a sctp_arg_t containing the |
153 | * __s32. So, after foo = SCTP_I32(arg), foo.i32 == arg. | 155 | * __s32. So, after foo = SCTP_I32(arg), foo.i32 == arg. |
154 | */ | 156 | */ |
157 | static inline sctp_arg_t SCTP_NULL(void) | ||
158 | { | ||
159 | sctp_arg_t retval; retval.ptr = NULL; return retval; | ||
160 | } | ||
161 | static inline sctp_arg_t SCTP_NOFORCE(void) | ||
162 | { | ||
163 | sctp_arg_t retval = {.zero = 0UL}; retval.i32 = 0; return retval; | ||
164 | } | ||
165 | static inline sctp_arg_t SCTP_FORCE(void) | ||
166 | { | ||
167 | sctp_arg_t retval = {.zero = 0UL}; retval.i32 = 1; return retval; | ||
168 | } | ||
155 | 169 | ||
156 | #define SCTP_ARG_CONSTRUCTOR(name, type, elt) \ | 170 | #define SCTP_ARG_CONSTRUCTOR(name, type, elt) \ |
157 | static inline sctp_arg_t \ | 171 | static inline sctp_arg_t \ |
158 | SCTP_## name (type arg) \ | 172 | SCTP_## name (type arg) \ |
159 | { sctp_arg_t retval;\ | 173 | { sctp_arg_t retval = {.zero = 0UL}; retval.elt = arg; return retval; } |
160 | memset(&retval, 0, sizeof(sctp_arg_t));\ | ||
161 | retval.elt = arg;\ | ||
162 | return retval;\ | ||
163 | } | ||
164 | 174 | ||
165 | SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) | 175 | SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) |
166 | SCTP_ARG_CONSTRUCTOR(U32, __u32, u32) | 176 | SCTP_ARG_CONSTRUCTOR(U32, __u32, u32) |
@@ -171,6 +181,7 @@ SCTP_ARG_CONSTRUCTOR(ERROR, int, error) | |||
171 | SCTP_ARG_CONSTRUCTOR(PERR, __be16, err) /* protocol error */ | 181 | SCTP_ARG_CONSTRUCTOR(PERR, __be16, err) /* protocol error */ |
172 | SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state) | 182 | SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state) |
173 | SCTP_ARG_CONSTRUCTOR(TO, sctp_event_timeout_t, to) | 183 | SCTP_ARG_CONSTRUCTOR(TO, sctp_event_timeout_t, to) |
184 | SCTP_ARG_CONSTRUCTOR(PTR, void *, ptr) | ||
174 | SCTP_ARG_CONSTRUCTOR(CHUNK, struct sctp_chunk *, chunk) | 185 | SCTP_ARG_CONSTRUCTOR(CHUNK, struct sctp_chunk *, chunk) |
175 | SCTP_ARG_CONSTRUCTOR(ASOC, struct sctp_association *, asoc) | 186 | SCTP_ARG_CONSTRUCTOR(ASOC, struct sctp_association *, asoc) |
176 | SCTP_ARG_CONSTRUCTOR(TRANSPORT, struct sctp_transport *, transport) | 187 | SCTP_ARG_CONSTRUCTOR(TRANSPORT, struct sctp_transport *, transport) |
@@ -181,23 +192,6 @@ SCTP_ARG_CONSTRUCTOR(PACKET, struct sctp_packet *, packet) | |||
181 | SCTP_ARG_CONSTRUCTOR(SACKH, sctp_sackhdr_t *, sackh) | 192 | SCTP_ARG_CONSTRUCTOR(SACKH, sctp_sackhdr_t *, sackh) |
182 | SCTP_ARG_CONSTRUCTOR(DATAMSG, struct sctp_datamsg *, msg) | 193 | SCTP_ARG_CONSTRUCTOR(DATAMSG, struct sctp_datamsg *, msg) |
183 | 194 | ||
184 | static inline sctp_arg_t SCTP_FORCE(void) | ||
185 | { | ||
186 | return SCTP_I32(1); | ||
187 | } | ||
188 | |||
189 | static inline sctp_arg_t SCTP_NOFORCE(void) | ||
190 | { | ||
191 | return SCTP_I32(0); | ||
192 | } | ||
193 | |||
194 | static inline sctp_arg_t SCTP_NULL(void) | ||
195 | { | ||
196 | sctp_arg_t retval; | ||
197 | memset(&retval, 0, sizeof(sctp_arg_t)); | ||
198 | return retval; | ||
199 | } | ||
200 | |||
201 | typedef struct { | 195 | typedef struct { |
202 | sctp_arg_t obj; | 196 | sctp_arg_t obj; |
203 | sctp_verb_t verb; | 197 | sctp_verb_t verb; |
diff --git a/include/net/sctp/constants.h b/include/net/sctp/constants.h index c29707d654c..942b864f613 100644 --- a/include/net/sctp/constants.h +++ b/include/net/sctp/constants.h | |||
@@ -312,6 +312,14 @@ enum { SCTP_MAX_GABS = 16 }; | |||
312 | * functions simpler to write. | 312 | * functions simpler to write. |
313 | */ | 313 | */ |
314 | 314 | ||
315 | #if defined (CONFIG_SCTP_HMAC_MD5) | ||
316 | #define SCTP_COOKIE_HMAC_ALG "hmac(md5)" | ||
317 | #elif defined (CONFIG_SCTP_HMAC_SHA1) | ||
318 | #define SCTP_COOKIE_HMAC_ALG "hmac(sha1)" | ||
319 | #else | ||
320 | #define SCTP_COOKIE_HMAC_ALG NULL | ||
321 | #endif | ||
322 | |||
315 | /* These return values describe the success or failure of a number of | 323 | /* These return values describe the success or failure of a number of |
316 | * routines which form the lower interface to SCTP_outqueue. | 324 | * routines which form the lower interface to SCTP_outqueue. |
317 | */ | 325 | */ |
@@ -326,7 +334,6 @@ typedef enum { | |||
326 | typedef enum { | 334 | typedef enum { |
327 | SCTP_TRANSPORT_UP, | 335 | SCTP_TRANSPORT_UP, |
328 | SCTP_TRANSPORT_DOWN, | 336 | SCTP_TRANSPORT_DOWN, |
329 | SCTP_TRANSPORT_PF, | ||
330 | } sctp_transport_cmd_t; | 337 | } sctp_transport_cmd_t; |
331 | 338 | ||
332 | /* These are the address scopes defined mainly for IPv4 addresses | 339 | /* These are the address scopes defined mainly for IPv4 addresses |
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index 7fdf298a47e..6a72a58cde5 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
@@ -71,7 +71,7 @@ | |||
71 | #include <linux/jiffies.h> | 71 | #include <linux/jiffies.h> |
72 | #include <linux/idr.h> | 72 | #include <linux/idr.h> |
73 | 73 | ||
74 | #if IS_ENABLED(CONFIG_IPV6) | 74 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
75 | #include <net/ipv6.h> | 75 | #include <net/ipv6.h> |
76 | #include <net/ip6_route.h> | 76 | #include <net/ip6_route.h> |
77 | #endif | 77 | #endif |
@@ -114,12 +114,13 @@ | |||
114 | /* | 114 | /* |
115 | * sctp/protocol.c | 115 | * sctp/protocol.c |
116 | */ | 116 | */ |
117 | extern int sctp_copy_local_addr_list(struct net *, struct sctp_bind_addr *, | 117 | extern struct sock *sctp_get_ctl_sock(void); |
118 | extern int sctp_copy_local_addr_list(struct sctp_bind_addr *, | ||
118 | sctp_scope_t, gfp_t gfp, | 119 | sctp_scope_t, gfp_t gfp, |
119 | int flags); | 120 | int flags); |
120 | extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); | 121 | extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); |
121 | extern int sctp_register_pf(struct sctp_pf *, sa_family_t); | 122 | extern int sctp_register_pf(struct sctp_pf *, sa_family_t); |
122 | extern void sctp_addr_wq_mgmt(struct net *, struct sctp_sockaddr_entry *, int); | 123 | extern void sctp_addr_wq_mgmt(struct sctp_sockaddr_entry *, int); |
123 | 124 | ||
124 | /* | 125 | /* |
125 | * sctp/socket.c | 126 | * sctp/socket.c |
@@ -139,12 +140,12 @@ extern int sctp_asconf_mgmt(struct sctp_sock *, struct sctp_sockaddr_entry *); | |||
139 | /* | 140 | /* |
140 | * sctp/primitive.c | 141 | * sctp/primitive.c |
141 | */ | 142 | */ |
142 | int sctp_primitive_ASSOCIATE(struct net *, struct sctp_association *, void *arg); | 143 | int sctp_primitive_ASSOCIATE(struct sctp_association *, void *arg); |
143 | int sctp_primitive_SHUTDOWN(struct net *, struct sctp_association *, void *arg); | 144 | int sctp_primitive_SHUTDOWN(struct sctp_association *, void *arg); |
144 | int sctp_primitive_ABORT(struct net *, struct sctp_association *, void *arg); | 145 | int sctp_primitive_ABORT(struct sctp_association *, void *arg); |
145 | int sctp_primitive_SEND(struct net *, struct sctp_association *, void *arg); | 146 | int sctp_primitive_SEND(struct sctp_association *, void *arg); |
146 | int sctp_primitive_REQUESTHEARTBEAT(struct net *, struct sctp_association *, void *arg); | 147 | int sctp_primitive_REQUESTHEARTBEAT(struct sctp_association *, void *arg); |
147 | int sctp_primitive_ASCONF(struct net *, struct sctp_association *, void *arg); | 148 | int sctp_primitive_ASCONF(struct sctp_association *, void *arg); |
148 | 149 | ||
149 | /* | 150 | /* |
150 | * sctp/input.c | 151 | * sctp/input.c |
@@ -155,14 +156,12 @@ void sctp_hash_established(struct sctp_association *); | |||
155 | void sctp_unhash_established(struct sctp_association *); | 156 | void sctp_unhash_established(struct sctp_association *); |
156 | void sctp_hash_endpoint(struct sctp_endpoint *); | 157 | void sctp_hash_endpoint(struct sctp_endpoint *); |
157 | void sctp_unhash_endpoint(struct sctp_endpoint *); | 158 | void sctp_unhash_endpoint(struct sctp_endpoint *); |
158 | struct sock *sctp_err_lookup(struct net *net, int family, struct sk_buff *, | 159 | struct sock *sctp_err_lookup(int family, struct sk_buff *, |
159 | struct sctphdr *, struct sctp_association **, | 160 | struct sctphdr *, struct sctp_association **, |
160 | struct sctp_transport **); | 161 | struct sctp_transport **); |
161 | void sctp_err_finish(struct sock *, struct sctp_association *); | 162 | void sctp_err_finish(struct sock *, struct sctp_association *); |
162 | void sctp_icmp_frag_needed(struct sock *, struct sctp_association *, | 163 | void sctp_icmp_frag_needed(struct sock *, struct sctp_association *, |
163 | struct sctp_transport *t, __u32 pmtu); | 164 | struct sctp_transport *t, __u32 pmtu); |
164 | void sctp_icmp_redirect(struct sock *, struct sctp_transport *, | ||
165 | struct sk_buff *); | ||
166 | void sctp_icmp_proto_unreachable(struct sock *sk, | 165 | void sctp_icmp_proto_unreachable(struct sock *sk, |
167 | struct sctp_association *asoc, | 166 | struct sctp_association *asoc, |
168 | struct sctp_transport *t); | 167 | struct sctp_transport *t); |
@@ -172,14 +171,14 @@ void sctp_backlog_migrate(struct sctp_association *assoc, | |||
172 | /* | 171 | /* |
173 | * sctp/proc.c | 172 | * sctp/proc.c |
174 | */ | 173 | */ |
175 | int sctp_snmp_proc_init(struct net *net); | 174 | int sctp_snmp_proc_init(void); |
176 | void sctp_snmp_proc_exit(struct net *net); | 175 | void sctp_snmp_proc_exit(void); |
177 | int sctp_eps_proc_init(struct net *net); | 176 | int sctp_eps_proc_init(void); |
178 | void sctp_eps_proc_exit(struct net *net); | 177 | void sctp_eps_proc_exit(void); |
179 | int sctp_assocs_proc_init(struct net *net); | 178 | int sctp_assocs_proc_init(void); |
180 | void sctp_assocs_proc_exit(struct net *net); | 179 | void sctp_assocs_proc_exit(void); |
181 | int sctp_remaddr_proc_init(struct net *net); | 180 | int sctp_remaddr_proc_init(void); |
182 | void sctp_remaddr_proc_exit(struct net *net); | 181 | void sctp_remaddr_proc_exit(void); |
183 | 182 | ||
184 | 183 | ||
185 | /* | 184 | /* |
@@ -221,10 +220,11 @@ extern struct kmem_cache *sctp_bucket_cachep __read_mostly; | |||
221 | #define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk) | 220 | #define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk) |
222 | 221 | ||
223 | /* SCTP SNMP MIB stats handlers */ | 222 | /* SCTP SNMP MIB stats handlers */ |
224 | #define SCTP_INC_STATS(net, field) SNMP_INC_STATS((net)->sctp.sctp_statistics, field) | 223 | DECLARE_SNMP_STAT(struct sctp_mib, sctp_statistics); |
225 | #define SCTP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->sctp.sctp_statistics, field) | 224 | #define SCTP_INC_STATS(field) SNMP_INC_STATS(sctp_statistics, field) |
226 | #define SCTP_INC_STATS_USER(net, field) SNMP_INC_STATS_USER((net)->sctp.sctp_statistics, field) | 225 | #define SCTP_INC_STATS_BH(field) SNMP_INC_STATS_BH(sctp_statistics, field) |
227 | #define SCTP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->sctp.sctp_statistics, field) | 226 | #define SCTP_INC_STATS_USER(field) SNMP_INC_STATS_USER(sctp_statistics, field) |
227 | #define SCTP_DEC_STATS(field) SNMP_DEC_STATS(sctp_statistics, field) | ||
228 | 228 | ||
229 | #endif /* !TEST_FRAME */ | 229 | #endif /* !TEST_FRAME */ |
230 | 230 | ||
@@ -272,18 +272,6 @@ struct sctp_mib { | |||
272 | unsigned long mibs[SCTP_MIB_MAX]; | 272 | unsigned long mibs[SCTP_MIB_MAX]; |
273 | }; | 273 | }; |
274 | 274 | ||
275 | /* helper function to track stats about max rto and related transport */ | ||
276 | static inline void sctp_max_rto(struct sctp_association *asoc, | ||
277 | struct sctp_transport *trans) | ||
278 | { | ||
279 | if (asoc->stats.max_obs_rto < (__u64)trans->rto) { | ||
280 | asoc->stats.max_obs_rto = trans->rto; | ||
281 | memset(&asoc->stats.obs_rto_ipaddr, 0, | ||
282 | sizeof(struct sockaddr_storage)); | ||
283 | memcpy(&asoc->stats.obs_rto_ipaddr, &trans->ipaddr, | ||
284 | trans->af_specific->sockaddr_len); | ||
285 | } | ||
286 | } | ||
287 | 275 | ||
288 | /* Print debugging messages. */ | 276 | /* Print debugging messages. */ |
289 | #if SCTP_DEBUG | 277 | #if SCTP_DEBUG |
@@ -371,35 +359,31 @@ atomic_t sctp_dbg_objcnt_## name = ATOMIC_INIT(0) | |||
371 | #define SCTP_DBG_OBJCNT_ENTRY(name) \ | 359 | #define SCTP_DBG_OBJCNT_ENTRY(name) \ |
372 | {.label= #name, .counter= &sctp_dbg_objcnt_## name} | 360 | {.label= #name, .counter= &sctp_dbg_objcnt_## name} |
373 | 361 | ||
374 | void sctp_dbg_objcnt_init(struct net *); | 362 | void sctp_dbg_objcnt_init(void); |
375 | void sctp_dbg_objcnt_exit(struct net *); | 363 | void sctp_dbg_objcnt_exit(void); |
376 | 364 | ||
377 | #else | 365 | #else |
378 | 366 | ||
379 | #define SCTP_DBG_OBJCNT_INC(name) | 367 | #define SCTP_DBG_OBJCNT_INC(name) |
380 | #define SCTP_DBG_OBJCNT_DEC(name) | 368 | #define SCTP_DBG_OBJCNT_DEC(name) |
381 | 369 | ||
382 | static inline void sctp_dbg_objcnt_init(struct net *net) { return; } | 370 | static inline void sctp_dbg_objcnt_init(void) { return; } |
383 | static inline void sctp_dbg_objcnt_exit(struct net *net) { return; } | 371 | static inline void sctp_dbg_objcnt_exit(void) { return; } |
384 | 372 | ||
385 | #endif /* CONFIG_SCTP_DBG_OBJCOUNT */ | 373 | #endif /* CONFIG_SCTP_DBG_OBJCOUNT */ |
386 | 374 | ||
387 | #if defined CONFIG_SYSCTL | 375 | #if defined CONFIG_SYSCTL |
388 | void sctp_sysctl_register(void); | 376 | void sctp_sysctl_register(void); |
389 | void sctp_sysctl_unregister(void); | 377 | void sctp_sysctl_unregister(void); |
390 | int sctp_sysctl_net_register(struct net *net); | ||
391 | void sctp_sysctl_net_unregister(struct net *net); | ||
392 | #else | 378 | #else |
393 | static inline void sctp_sysctl_register(void) { return; } | 379 | static inline void sctp_sysctl_register(void) { return; } |
394 | static inline void sctp_sysctl_unregister(void) { return; } | 380 | static inline void sctp_sysctl_unregister(void) { return; } |
395 | static inline int sctp_sysctl_net_register(struct net *net) { return 0; } | ||
396 | static inline void sctp_sysctl_net_unregister(struct net *net) { return; } | ||
397 | #endif | 381 | #endif |
398 | 382 | ||
399 | /* Size of Supported Address Parameter for 'x' address types. */ | 383 | /* Size of Supported Address Parameter for 'x' address types. */ |
400 | #define SCTP_SAT_LEN(x) (sizeof(struct sctp_paramhdr) + (x) * sizeof(__u16)) | 384 | #define SCTP_SAT_LEN(x) (sizeof(struct sctp_paramhdr) + (x) * sizeof(__u16)) |
401 | 385 | ||
402 | #if IS_ENABLED(CONFIG_IPV6) | 386 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
403 | 387 | ||
404 | void sctp_v6_pf_init(void); | 388 | void sctp_v6_pf_init(void); |
405 | void sctp_v6_pf_exit(void); | 389 | void sctp_v6_pf_exit(void); |
@@ -429,7 +413,6 @@ static inline sctp_assoc_t sctp_assoc2id(const struct sctp_association *asoc) | |||
429 | /* Look up the association by its id. */ | 413 | /* Look up the association by its id. */ |
430 | struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id); | 414 | struct sctp_association *sctp_id2assoc(struct sock *sk, sctp_assoc_t id); |
431 | 415 | ||
432 | int sctp_do_peeloff(struct sock *sk, sctp_assoc_t id, struct socket **sockp); | ||
433 | 416 | ||
434 | /* A macro to walk a list of skbs. */ | 417 | /* A macro to walk a list of skbs. */ |
435 | #define sctp_skb_for_each(pos, head, tmp) \ | 418 | #define sctp_skb_for_each(pos, head, tmp) \ |
@@ -533,10 +516,10 @@ static inline int sctp_frag_point(const struct sctp_association *asoc, int pmtu) | |||
533 | return frag; | 516 | return frag; |
534 | } | 517 | } |
535 | 518 | ||
536 | static inline void sctp_assoc_pending_pmtu(struct sock *sk, struct sctp_association *asoc) | 519 | static inline void sctp_assoc_pending_pmtu(struct sctp_association *asoc) |
537 | { | 520 | { |
538 | 521 | ||
539 | sctp_assoc_sync_pmtu(sk, asoc); | 522 | sctp_assoc_sync_pmtu(asoc); |
540 | asoc->pmtu_pending = 0; | 523 | asoc->pmtu_pending = 0; |
541 | } | 524 | } |
542 | 525 | ||
@@ -600,6 +583,7 @@ for (pos = chunk->subh.fwdtsn_hdr->skip;\ | |||
600 | 583 | ||
601 | extern struct proto sctp_prot; | 584 | extern struct proto sctp_prot; |
602 | extern struct proto sctpv6_prot; | 585 | extern struct proto sctpv6_prot; |
586 | extern struct proc_dir_entry *proc_net_sctp; | ||
603 | void sctp_put_port(struct sock *sk); | 587 | void sctp_put_port(struct sock *sk); |
604 | 588 | ||
605 | extern struct idr sctp_assocs_id; | 589 | extern struct idr sctp_assocs_id; |
@@ -645,21 +629,21 @@ static inline int sctp_sanity_check(void) | |||
645 | 629 | ||
646 | /* Warning: The following hash functions assume a power of two 'size'. */ | 630 | /* Warning: The following hash functions assume a power of two 'size'. */ |
647 | /* This is the hash function for the SCTP port hash table. */ | 631 | /* This is the hash function for the SCTP port hash table. */ |
648 | static inline int sctp_phashfn(struct net *net, __u16 lport) | 632 | static inline int sctp_phashfn(__u16 lport) |
649 | { | 633 | { |
650 | return (net_hash_mix(net) + lport) & (sctp_port_hashsize - 1); | 634 | return lport & (sctp_port_hashsize - 1); |
651 | } | 635 | } |
652 | 636 | ||
653 | /* This is the hash function for the endpoint hash table. */ | 637 | /* This is the hash function for the endpoint hash table. */ |
654 | static inline int sctp_ep_hashfn(struct net *net, __u16 lport) | 638 | static inline int sctp_ep_hashfn(__u16 lport) |
655 | { | 639 | { |
656 | return (net_hash_mix(net) + lport) & (sctp_ep_hashsize - 1); | 640 | return lport & (sctp_ep_hashsize - 1); |
657 | } | 641 | } |
658 | 642 | ||
659 | /* This is the hash function for the association hash table. */ | 643 | /* This is the hash function for the association hash table. */ |
660 | static inline int sctp_assoc_hashfn(struct net *net, __u16 lport, __u16 rport) | 644 | static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport) |
661 | { | 645 | { |
662 | int h = (lport << 16) + rport + net_hash_mix(net); | 646 | int h = (lport << 16) + rport; |
663 | h ^= h>>8; | 647 | h ^= h>>8; |
664 | return h & (sctp_assoc_hashsize - 1); | 648 | return h & (sctp_assoc_hashsize - 1); |
665 | } | 649 | } |
@@ -719,17 +703,4 @@ static inline void sctp_v4_map_v6(union sctp_addr *addr) | |||
719 | addr->v6.sin6_addr.s6_addr32[2] = htonl(0x0000ffff); | 703 | addr->v6.sin6_addr.s6_addr32[2] = htonl(0x0000ffff); |
720 | } | 704 | } |
721 | 705 | ||
722 | /* The cookie is always 0 since this is how it's used in the | ||
723 | * pmtu code. | ||
724 | */ | ||
725 | static inline struct dst_entry *sctp_transport_dst_check(struct sctp_transport *t) | ||
726 | { | ||
727 | if (t->dst && !dst_check(t->dst, 0)) { | ||
728 | dst_release(t->dst); | ||
729 | t->dst = NULL; | ||
730 | } | ||
731 | |||
732 | return t->dst; | ||
733 | } | ||
734 | |||
735 | #endif /* __net_sctp_h__ */ | 706 | #endif /* __net_sctp_h__ */ |
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h index 2a82d138470..9148632b820 100644 --- a/include/net/sctp/sm.h +++ b/include/net/sctp/sm.h | |||
@@ -77,8 +77,7 @@ typedef struct { | |||
77 | int action; | 77 | int action; |
78 | } sctp_sm_command_t; | 78 | } sctp_sm_command_t; |
79 | 79 | ||
80 | typedef sctp_disposition_t (sctp_state_fn_t) (struct net *, | 80 | typedef sctp_disposition_t (sctp_state_fn_t) (const struct sctp_endpoint *, |
81 | const struct sctp_endpoint *, | ||
82 | const struct sctp_association *, | 81 | const struct sctp_association *, |
83 | const sctp_subtype_t type, | 82 | const sctp_subtype_t type, |
84 | void *arg, | 83 | void *arg, |
@@ -179,8 +178,7 @@ sctp_state_fn_t sctp_sf_autoclose_timer_expire; | |||
179 | 178 | ||
180 | /* Prototypes for utility support functions. */ | 179 | /* Prototypes for utility support functions. */ |
181 | __u8 sctp_get_chunk_type(struct sctp_chunk *chunk); | 180 | __u8 sctp_get_chunk_type(struct sctp_chunk *chunk); |
182 | const sctp_sm_table_entry_t *sctp_sm_lookup_event(struct net *, | 181 | const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t, |
183 | sctp_event_t, | ||
184 | sctp_state_t, | 182 | sctp_state_t, |
185 | sctp_subtype_t); | 183 | sctp_subtype_t); |
186 | int sctp_chunk_iif(const struct sctp_chunk *); | 184 | int sctp_chunk_iif(const struct sctp_chunk *); |
@@ -234,8 +232,6 @@ struct sctp_chunk *sctp_make_abort_violation(const struct sctp_association *, | |||
234 | struct sctp_chunk *sctp_make_violation_paramlen(const struct sctp_association *, | 232 | struct sctp_chunk *sctp_make_violation_paramlen(const struct sctp_association *, |
235 | const struct sctp_chunk *, | 233 | const struct sctp_chunk *, |
236 | struct sctp_paramhdr *); | 234 | struct sctp_paramhdr *); |
237 | struct sctp_chunk *sctp_make_violation_max_retrans(const struct sctp_association *, | ||
238 | const struct sctp_chunk *); | ||
239 | struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *, | 235 | struct sctp_chunk *sctp_make_heartbeat(const struct sctp_association *, |
240 | const struct sctp_transport *); | 236 | const struct sctp_transport *); |
241 | struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *, | 237 | struct sctp_chunk *sctp_make_heartbeat_ack(const struct sctp_association *, |
@@ -272,7 +268,7 @@ void sctp_chunk_assign_ssn(struct sctp_chunk *); | |||
272 | 268 | ||
273 | /* Prototypes for statetable processing. */ | 269 | /* Prototypes for statetable processing. */ |
274 | 270 | ||
275 | int sctp_do_sm(struct net *net, sctp_event_t event_type, sctp_subtype_t subtype, | 271 | int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype, |
276 | sctp_state_t state, | 272 | sctp_state_t state, |
277 | struct sctp_endpoint *, | 273 | struct sctp_endpoint *, |
278 | struct sctp_association *asoc, | 274 | struct sctp_association *asoc, |
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index fdeb85a970f..ec86952fb57 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -102,7 +102,6 @@ struct sctp_bind_bucket { | |||
102 | unsigned short fastreuse; | 102 | unsigned short fastreuse; |
103 | struct hlist_node node; | 103 | struct hlist_node node; |
104 | struct hlist_head owner; | 104 | struct hlist_head owner; |
105 | struct net *net; | ||
106 | }; | 105 | }; |
107 | 106 | ||
108 | struct sctp_bind_hashbucket { | 107 | struct sctp_bind_hashbucket { |
@@ -119,6 +118,63 @@ struct sctp_hashbucket { | |||
119 | 118 | ||
120 | /* The SCTP globals structure. */ | 119 | /* The SCTP globals structure. */ |
121 | extern struct sctp_globals { | 120 | extern struct sctp_globals { |
121 | /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values | ||
122 | * | ||
123 | * The following protocol parameters are RECOMMENDED: | ||
124 | * | ||
125 | * RTO.Initial - 3 seconds | ||
126 | * RTO.Min - 1 second | ||
127 | * RTO.Max - 60 seconds | ||
128 | * RTO.Alpha - 1/8 (3 when converted to right shifts.) | ||
129 | * RTO.Beta - 1/4 (2 when converted to right shifts.) | ||
130 | */ | ||
131 | unsigned int rto_initial; | ||
132 | unsigned int rto_min; | ||
133 | unsigned int rto_max; | ||
134 | |||
135 | /* Note: rto_alpha and rto_beta are really defined as inverse | ||
136 | * powers of two to facilitate integer operations. | ||
137 | */ | ||
138 | int rto_alpha; | ||
139 | int rto_beta; | ||
140 | |||
141 | /* Max.Burst - 4 */ | ||
142 | int max_burst; | ||
143 | |||
144 | /* Whether Cookie Preservative is enabled(1) or not(0) */ | ||
145 | int cookie_preserve_enable; | ||
146 | |||
147 | /* Valid.Cookie.Life - 60 seconds */ | ||
148 | unsigned int valid_cookie_life; | ||
149 | |||
150 | /* Delayed SACK timeout 200ms default*/ | ||
151 | unsigned int sack_timeout; | ||
152 | |||
153 | /* HB.interval - 30 seconds */ | ||
154 | unsigned int hb_interval; | ||
155 | |||
156 | /* Association.Max.Retrans - 10 attempts | ||
157 | * Path.Max.Retrans - 5 attempts (per destination address) | ||
158 | * Max.Init.Retransmits - 8 attempts | ||
159 | */ | ||
160 | int max_retrans_association; | ||
161 | int max_retrans_path; | ||
162 | int max_retrans_init; | ||
163 | |||
164 | /* | ||
165 | * Policy for preforming sctp/socket accounting | ||
166 | * 0 - do socket level accounting, all assocs share sk_sndbuf | ||
167 | * 1 - do sctp accounting, each asoc may use sk_sndbuf bytes | ||
168 | */ | ||
169 | int sndbuf_policy; | ||
170 | |||
171 | /* | ||
172 | * Policy for preforming sctp/socket accounting | ||
173 | * 0 - do socket level accounting, all assocs share sk_rcvbuf | ||
174 | * 1 - do sctp accounting, each asoc may use sk_rcvbuf bytes | ||
175 | */ | ||
176 | int rcvbuf_policy; | ||
177 | |||
122 | /* The following variables are implementation specific. */ | 178 | /* The following variables are implementation specific. */ |
123 | 179 | ||
124 | /* Default initialization values to be applied to new associations. */ | 180 | /* Default initialization values to be applied to new associations. */ |
@@ -142,11 +198,69 @@ extern struct sctp_globals { | |||
142 | int port_hashsize; | 198 | int port_hashsize; |
143 | struct sctp_bind_hashbucket *port_hashtable; | 199 | struct sctp_bind_hashbucket *port_hashtable; |
144 | 200 | ||
201 | /* This is the global local address list. | ||
202 | * We actively maintain this complete list of addresses on | ||
203 | * the system by catching address add/delete events. | ||
204 | * | ||
205 | * It is a list of sctp_sockaddr_entry. | ||
206 | */ | ||
207 | struct list_head local_addr_list; | ||
208 | int default_auto_asconf; | ||
209 | struct list_head addr_waitq; | ||
210 | struct timer_list addr_wq_timer; | ||
211 | struct list_head auto_asconf_splist; | ||
212 | spinlock_t addr_wq_lock; | ||
213 | |||
214 | /* Lock that protects the local_addr_list writers */ | ||
215 | spinlock_t addr_list_lock; | ||
216 | |||
217 | /* Flag to indicate if addip is enabled. */ | ||
218 | int addip_enable; | ||
219 | int addip_noauth_enable; | ||
220 | |||
221 | /* Flag to indicate if PR-SCTP is enabled. */ | ||
222 | int prsctp_enable; | ||
223 | |||
224 | /* Flag to idicate if SCTP-AUTH is enabled */ | ||
225 | int auth_enable; | ||
226 | |||
227 | /* | ||
228 | * Policy to control SCTP IPv4 address scoping | ||
229 | * 0 - Disable IPv4 address scoping | ||
230 | * 1 - Enable IPv4 address scoping | ||
231 | * 2 - Selectively allow only IPv4 private addresses | ||
232 | * 3 - Selectively allow only IPv4 link local address | ||
233 | */ | ||
234 | int ipv4_scope_policy; | ||
235 | |||
145 | /* Flag to indicate whether computing and verifying checksum | 236 | /* Flag to indicate whether computing and verifying checksum |
146 | * is disabled. */ | 237 | * is disabled. */ |
147 | bool checksum_disable; | 238 | int checksum_disable; |
239 | |||
240 | /* Threshold for rwnd update SACKS. Receive buffer shifted this many | ||
241 | * bits is an indicator of when to send and window update SACK. | ||
242 | */ | ||
243 | int rwnd_update_shift; | ||
244 | |||
245 | /* Threshold for autoclose timeout, in seconds. */ | ||
246 | unsigned long max_autoclose; | ||
148 | } sctp_globals; | 247 | } sctp_globals; |
149 | 248 | ||
249 | #define sctp_rto_initial (sctp_globals.rto_initial) | ||
250 | #define sctp_rto_min (sctp_globals.rto_min) | ||
251 | #define sctp_rto_max (sctp_globals.rto_max) | ||
252 | #define sctp_rto_alpha (sctp_globals.rto_alpha) | ||
253 | #define sctp_rto_beta (sctp_globals.rto_beta) | ||
254 | #define sctp_max_burst (sctp_globals.max_burst) | ||
255 | #define sctp_valid_cookie_life (sctp_globals.valid_cookie_life) | ||
256 | #define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable) | ||
257 | #define sctp_max_retrans_association (sctp_globals.max_retrans_association) | ||
258 | #define sctp_sndbuf_policy (sctp_globals.sndbuf_policy) | ||
259 | #define sctp_rcvbuf_policy (sctp_globals.rcvbuf_policy) | ||
260 | #define sctp_max_retrans_path (sctp_globals.max_retrans_path) | ||
261 | #define sctp_max_retrans_init (sctp_globals.max_retrans_init) | ||
262 | #define sctp_sack_timeout (sctp_globals.sack_timeout) | ||
263 | #define sctp_hb_interval (sctp_globals.hb_interval) | ||
150 | #define sctp_max_instreams (sctp_globals.max_instreams) | 264 | #define sctp_max_instreams (sctp_globals.max_instreams) |
151 | #define sctp_max_outstreams (sctp_globals.max_outstreams) | 265 | #define sctp_max_outstreams (sctp_globals.max_outstreams) |
152 | #define sctp_address_families (sctp_globals.address_families) | 266 | #define sctp_address_families (sctp_globals.address_families) |
@@ -156,7 +270,21 @@ extern struct sctp_globals { | |||
156 | #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) | 270 | #define sctp_assoc_hashtable (sctp_globals.assoc_hashtable) |
157 | #define sctp_port_hashsize (sctp_globals.port_hashsize) | 271 | #define sctp_port_hashsize (sctp_globals.port_hashsize) |
158 | #define sctp_port_hashtable (sctp_globals.port_hashtable) | 272 | #define sctp_port_hashtable (sctp_globals.port_hashtable) |
273 | #define sctp_local_addr_list (sctp_globals.local_addr_list) | ||
274 | #define sctp_local_addr_lock (sctp_globals.addr_list_lock) | ||
275 | #define sctp_auto_asconf_splist (sctp_globals.auto_asconf_splist) | ||
276 | #define sctp_addr_waitq (sctp_globals.addr_waitq) | ||
277 | #define sctp_addr_wq_timer (sctp_globals.addr_wq_timer) | ||
278 | #define sctp_addr_wq_lock (sctp_globals.addr_wq_lock) | ||
279 | #define sctp_default_auto_asconf (sctp_globals.default_auto_asconf) | ||
280 | #define sctp_scope_policy (sctp_globals.ipv4_scope_policy) | ||
281 | #define sctp_addip_enable (sctp_globals.addip_enable) | ||
282 | #define sctp_addip_noauth (sctp_globals.addip_noauth_enable) | ||
283 | #define sctp_prsctp_enable (sctp_globals.prsctp_enable) | ||
284 | #define sctp_auth_enable (sctp_globals.auth_enable) | ||
159 | #define sctp_checksum_disable (sctp_globals.checksum_disable) | 285 | #define sctp_checksum_disable (sctp_globals.checksum_disable) |
286 | #define sctp_rwnd_upd_shift (sctp_globals.rwnd_update_shift) | ||
287 | #define sctp_max_autoclose (sctp_globals.max_autoclose) | ||
160 | 288 | ||
161 | /* SCTP Socket type: UDP or TCP style. */ | 289 | /* SCTP Socket type: UDP or TCP style. */ |
162 | typedef enum { | 290 | typedef enum { |
@@ -177,7 +305,6 @@ struct sctp_sock { | |||
177 | 305 | ||
178 | /* Access to HMAC transform. */ | 306 | /* Access to HMAC transform. */ |
179 | struct crypto_hash *hmac; | 307 | struct crypto_hash *hmac; |
180 | char *sctp_hmac_alg; | ||
181 | 308 | ||
182 | /* What is our base endpointer? */ | 309 | /* What is our base endpointer? */ |
183 | struct sctp_endpoint *ep; | 310 | struct sctp_endpoint *ep; |
@@ -242,7 +369,7 @@ static inline struct sock *sctp_opt2sk(const struct sctp_sock *sp) | |||
242 | return (struct sock *)sp; | 369 | return (struct sock *)sp; |
243 | } | 370 | } |
244 | 371 | ||
245 | #if IS_ENABLED(CONFIG_IPV6) | 372 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
246 | struct sctp6_sock { | 373 | struct sctp6_sock { |
247 | struct sctp_sock sctp; | 374 | struct sctp_sock sctp; |
248 | struct ipv6_pinfo inet6; | 375 | struct ipv6_pinfo inet6; |
@@ -785,9 +912,6 @@ struct sctp_transport { | |||
785 | /* Is this structure kfree()able? */ | 912 | /* Is this structure kfree()able? */ |
786 | malloced:1; | 913 | malloced:1; |
787 | 914 | ||
788 | /* Has this transport moved the ctsn since we last sacked */ | ||
789 | __u32 sack_generation; | ||
790 | |||
791 | struct flowi fl; | 915 | struct flowi fl; |
792 | 916 | ||
793 | /* This is the peer's IP address and port. */ | 917 | /* This is the peer's IP address and port. */ |
@@ -863,15 +987,10 @@ struct sctp_transport { | |||
863 | 987 | ||
864 | /* This is the max_retrans value for the transport and will | 988 | /* This is the max_retrans value for the transport and will |
865 | * be initialized from the assocs value. This can be changed | 989 | * be initialized from the assocs value. This can be changed |
866 | * using the SCTP_SET_PEER_ADDR_PARAMS socket option. | 990 | * using SCTP_SET_PEER_ADDR_PARAMS socket option. |
867 | */ | 991 | */ |
868 | __u16 pathmaxrxt; | 992 | __u16 pathmaxrxt; |
869 | 993 | ||
870 | /* This is the partially failed retrans value for the transport | ||
871 | * and will be initialized from the assocs value. This can be changed | ||
872 | * using the SCTP_PEER_ADDR_THLDS socket option | ||
873 | */ | ||
874 | int pf_retrans; | ||
875 | /* PMTU : The current known path MTU. */ | 994 | /* PMTU : The current known path MTU. */ |
876 | __u32 pathmtu; | 995 | __u32 pathmtu; |
877 | 996 | ||
@@ -949,11 +1068,9 @@ struct sctp_transport { | |||
949 | 1068 | ||
950 | /* 64-bit random number sent with heartbeat. */ | 1069 | /* 64-bit random number sent with heartbeat. */ |
951 | __u64 hb_nonce; | 1070 | __u64 hb_nonce; |
952 | |||
953 | struct rcu_head rcu; | ||
954 | }; | 1071 | }; |
955 | 1072 | ||
956 | struct sctp_transport *sctp_transport_new(struct net *, const union sctp_addr *, | 1073 | struct sctp_transport *sctp_transport_new(const union sctp_addr *, |
957 | gfp_t); | 1074 | gfp_t); |
958 | void sctp_transport_set_owner(struct sctp_transport *, | 1075 | void sctp_transport_set_owner(struct sctp_transport *, |
959 | struct sctp_association *); | 1076 | struct sctp_association *); |
@@ -971,8 +1088,7 @@ void sctp_transport_burst_limited(struct sctp_transport *); | |||
971 | void sctp_transport_burst_reset(struct sctp_transport *); | 1088 | void sctp_transport_burst_reset(struct sctp_transport *); |
972 | unsigned long sctp_transport_timeout(struct sctp_transport *); | 1089 | unsigned long sctp_transport_timeout(struct sctp_transport *); |
973 | void sctp_transport_reset(struct sctp_transport *); | 1090 | void sctp_transport_reset(struct sctp_transport *); |
974 | void sctp_transport_update_pmtu(struct sock *, struct sctp_transport *, u32); | 1091 | void sctp_transport_update_pmtu(struct sctp_transport *, u32); |
975 | void sctp_transport_immediate_rtx(struct sctp_transport *); | ||
976 | 1092 | ||
977 | 1093 | ||
978 | /* This is the structure we use to queue packets as they come into | 1094 | /* This is the structure we use to queue packets as they come into |
@@ -1028,10 +1144,10 @@ struct sctp_outq { | |||
1028 | /* Data pending that has never been transmitted. */ | 1144 | /* Data pending that has never been transmitted. */ |
1029 | struct list_head out_chunk_list; | 1145 | struct list_head out_chunk_list; |
1030 | 1146 | ||
1031 | unsigned int out_qlen; /* Total length of queued data chunks. */ | 1147 | unsigned out_qlen; /* Total length of queued data chunks. */ |
1032 | 1148 | ||
1033 | /* Error of send failed, may used in SCTP_SEND_FAILED event. */ | 1149 | /* Error of send failed, may used in SCTP_SEND_FAILED event. */ |
1034 | unsigned int error; | 1150 | unsigned error; |
1035 | 1151 | ||
1036 | /* These are control chunks we want to send. */ | 1152 | /* These are control chunks we want to send. */ |
1037 | struct list_head control_chunk_list; | 1153 | struct list_head control_chunk_list; |
@@ -1071,7 +1187,7 @@ void sctp_outq_init(struct sctp_association *, struct sctp_outq *); | |||
1071 | void sctp_outq_teardown(struct sctp_outq *); | 1187 | void sctp_outq_teardown(struct sctp_outq *); |
1072 | void sctp_outq_free(struct sctp_outq*); | 1188 | void sctp_outq_free(struct sctp_outq*); |
1073 | int sctp_outq_tail(struct sctp_outq *, struct sctp_chunk *chunk); | 1189 | int sctp_outq_tail(struct sctp_outq *, struct sctp_chunk *chunk); |
1074 | int sctp_outq_sack(struct sctp_outq *, struct sctp_chunk *); | 1190 | int sctp_outq_sack(struct sctp_outq *, struct sctp_sackhdr *); |
1075 | int sctp_outq_is_empty(const struct sctp_outq *); | 1191 | int sctp_outq_is_empty(const struct sctp_outq *); |
1076 | void sctp_outq_restart(struct sctp_outq *); | 1192 | void sctp_outq_restart(struct sctp_outq *); |
1077 | 1193 | ||
@@ -1108,7 +1224,7 @@ struct sctp_bind_addr { | |||
1108 | 1224 | ||
1109 | void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port); | 1225 | void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port); |
1110 | void sctp_bind_addr_free(struct sctp_bind_addr *); | 1226 | void sctp_bind_addr_free(struct sctp_bind_addr *); |
1111 | int sctp_bind_addr_copy(struct net *net, struct sctp_bind_addr *dest, | 1227 | int sctp_bind_addr_copy(struct sctp_bind_addr *dest, |
1112 | const struct sctp_bind_addr *src, | 1228 | const struct sctp_bind_addr *src, |
1113 | sctp_scope_t scope, gfp_t gfp, | 1229 | sctp_scope_t scope, gfp_t gfp, |
1114 | int flags); | 1230 | int flags); |
@@ -1135,7 +1251,7 @@ int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len, | |||
1135 | __u16 port, gfp_t gfp); | 1251 | __u16 port, gfp_t gfp); |
1136 | 1252 | ||
1137 | sctp_scope_t sctp_scope(const union sctp_addr *); | 1253 | sctp_scope_t sctp_scope(const union sctp_addr *); |
1138 | int sctp_in_scope(struct net *net, const union sctp_addr *addr, const sctp_scope_t scope); | 1254 | int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope); |
1139 | int sctp_is_any(struct sock *sk, const union sctp_addr *addr); | 1255 | int sctp_is_any(struct sock *sk, const union sctp_addr *addr); |
1140 | int sctp_addr_is_valid(const union sctp_addr *addr); | 1256 | int sctp_addr_is_valid(const union sctp_addr *addr); |
1141 | int sctp_is_ep_boundall(struct sock *sk); | 1257 | int sctp_is_ep_boundall(struct sock *sk); |
@@ -1293,13 +1409,13 @@ struct sctp_association *sctp_endpoint_lookup_assoc( | |||
1293 | int sctp_endpoint_is_peeled_off(struct sctp_endpoint *, | 1409 | int sctp_endpoint_is_peeled_off(struct sctp_endpoint *, |
1294 | const union sctp_addr *); | 1410 | const union sctp_addr *); |
1295 | struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *, | 1411 | struct sctp_endpoint *sctp_endpoint_is_match(struct sctp_endpoint *, |
1296 | struct net *, const union sctp_addr *); | 1412 | const union sctp_addr *); |
1297 | int sctp_has_association(struct net *net, const union sctp_addr *laddr, | 1413 | int sctp_has_association(const union sctp_addr *laddr, |
1298 | const union sctp_addr *paddr); | 1414 | const union sctp_addr *paddr); |
1299 | 1415 | ||
1300 | int sctp_verify_init(struct net *net, const struct sctp_association *asoc, | 1416 | int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t, |
1301 | sctp_cid_t, sctp_init_chunk_t *peer_init, | 1417 | sctp_init_chunk_t *peer_init, struct sctp_chunk *chunk, |
1302 | struct sctp_chunk *chunk, struct sctp_chunk **err_chunk); | 1418 | struct sctp_chunk **err_chunk); |
1303 | int sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk, | 1419 | int sctp_process_init(struct sctp_association *, struct sctp_chunk *chunk, |
1304 | const union sctp_addr *peer, | 1420 | const union sctp_addr *peer, |
1305 | sctp_init_chunk_t *init, gfp_t gfp); | 1421 | sctp_init_chunk_t *init, gfp_t gfp); |
@@ -1314,40 +1430,6 @@ struct sctp_inithdr_host { | |||
1314 | __u32 initial_tsn; | 1430 | __u32 initial_tsn; |
1315 | }; | 1431 | }; |
1316 | 1432 | ||
1317 | /* SCTP_GET_ASSOC_STATS counters */ | ||
1318 | struct sctp_priv_assoc_stats { | ||
1319 | /* Maximum observed rto in the association during subsequent | ||
1320 | * observations. Value is set to 0 if no RTO measurement took place | ||
1321 | * The transport where the max_rto was observed is returned in | ||
1322 | * obs_rto_ipaddr | ||
1323 | */ | ||
1324 | struct sockaddr_storage obs_rto_ipaddr; | ||
1325 | __u64 max_obs_rto; | ||
1326 | /* Total In and Out SACKs received and sent */ | ||
1327 | __u64 isacks; | ||
1328 | __u64 osacks; | ||
1329 | /* Total In and Out packets received and sent */ | ||
1330 | __u64 opackets; | ||
1331 | __u64 ipackets; | ||
1332 | /* Total retransmitted chunks */ | ||
1333 | __u64 rtxchunks; | ||
1334 | /* TSN received > next expected */ | ||
1335 | __u64 outofseqtsns; | ||
1336 | /* Duplicate Chunks received */ | ||
1337 | __u64 idupchunks; | ||
1338 | /* Gap Ack Blocks received */ | ||
1339 | __u64 gapcnt; | ||
1340 | /* Unordered data chunks sent and received */ | ||
1341 | __u64 ouodchunks; | ||
1342 | __u64 iuodchunks; | ||
1343 | /* Ordered data chunks sent and received */ | ||
1344 | __u64 oodchunks; | ||
1345 | __u64 iodchunks; | ||
1346 | /* Control chunks sent and received */ | ||
1347 | __u64 octrlchunks; | ||
1348 | __u64 ictrlchunks; | ||
1349 | }; | ||
1350 | |||
1351 | /* RFC2960 | 1433 | /* RFC2960 |
1352 | * | 1434 | * |
1353 | * 12. Recommended Transmission Control Block (TCB) Parameters | 1435 | * 12. Recommended Transmission Control Block (TCB) Parameters |
@@ -1501,7 +1583,6 @@ struct sctp_association { | |||
1501 | */ | 1583 | */ |
1502 | __u8 sack_needed; /* Do we need to sack the peer? */ | 1584 | __u8 sack_needed; /* Do we need to sack the peer? */ |
1503 | __u32 sack_cnt; | 1585 | __u32 sack_cnt; |
1504 | __u32 sack_generation; | ||
1505 | 1586 | ||
1506 | /* These are capabilities which our peer advertised. */ | 1587 | /* These are capabilities which our peer advertised. */ |
1507 | __u8 ecn_capable:1, /* Can peer do ECN? */ | 1588 | __u8 ecn_capable:1, /* Can peer do ECN? */ |
@@ -1578,12 +1659,6 @@ struct sctp_association { | |||
1578 | */ | 1659 | */ |
1579 | int max_retrans; | 1660 | int max_retrans; |
1580 | 1661 | ||
1581 | /* This is the partially failed retrans value for the transport | ||
1582 | * and will be initialized from the assocs value. This can be | ||
1583 | * changed using the SCTP_PEER_ADDR_THLDS socket option | ||
1584 | */ | ||
1585 | int pf_retrans; | ||
1586 | |||
1587 | /* Maximum number of times the endpoint will retransmit INIT */ | 1662 | /* Maximum number of times the endpoint will retransmit INIT */ |
1588 | __u16 max_init_attempts; | 1663 | __u16 max_init_attempts; |
1589 | 1664 | ||
@@ -1844,7 +1919,6 @@ struct sctp_association { | |||
1844 | __u32 addip_serial; | 1919 | __u32 addip_serial; |
1845 | union sctp_addr *asconf_addr_del_pending; | 1920 | union sctp_addr *asconf_addr_del_pending; |
1846 | int src_out_of_asoc_ok; | 1921 | int src_out_of_asoc_ok; |
1847 | struct sctp_transport *new_transport; | ||
1848 | 1922 | ||
1849 | /* SCTP AUTH: list of the endpoint shared keys. These | 1923 | /* SCTP AUTH: list of the endpoint shared keys. These |
1850 | * keys are provided out of band by the user applicaton | 1924 | * keys are provided out of band by the user applicaton |
@@ -1866,8 +1940,6 @@ struct sctp_association { | |||
1866 | 1940 | ||
1867 | __u8 need_ecne:1, /* Need to send an ECNE Chunk? */ | 1941 | __u8 need_ecne:1, /* Need to send an ECNE Chunk? */ |
1868 | temp:1; /* Is it a temporary association? */ | 1942 | temp:1; /* Is it a temporary association? */ |
1869 | |||
1870 | struct sctp_priv_assoc_stats stats; | ||
1871 | }; | 1943 | }; |
1872 | 1944 | ||
1873 | 1945 | ||
@@ -1917,7 +1989,6 @@ void sctp_assoc_control_transport(struct sctp_association *, | |||
1917 | sctp_transport_cmd_t, sctp_sn_error_t); | 1989 | sctp_transport_cmd_t, sctp_sn_error_t); |
1918 | struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *, __u32); | 1990 | struct sctp_transport *sctp_assoc_lookup_tsn(struct sctp_association *, __u32); |
1919 | struct sctp_transport *sctp_assoc_is_match(struct sctp_association *, | 1991 | struct sctp_transport *sctp_assoc_is_match(struct sctp_association *, |
1920 | struct net *, | ||
1921 | const union sctp_addr *, | 1992 | const union sctp_addr *, |
1922 | const union sctp_addr *); | 1993 | const union sctp_addr *); |
1923 | void sctp_assoc_migrate(struct sctp_association *, struct sock *); | 1994 | void sctp_assoc_migrate(struct sctp_association *, struct sock *); |
@@ -1926,9 +1997,9 @@ void sctp_assoc_update(struct sctp_association *old, | |||
1926 | 1997 | ||
1927 | __u32 sctp_association_get_next_tsn(struct sctp_association *); | 1998 | __u32 sctp_association_get_next_tsn(struct sctp_association *); |
1928 | 1999 | ||
1929 | void sctp_assoc_sync_pmtu(struct sock *, struct sctp_association *); | 2000 | void sctp_assoc_sync_pmtu(struct sctp_association *); |
1930 | void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned int); | 2001 | void sctp_assoc_rwnd_increase(struct sctp_association *, unsigned); |
1931 | void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned int); | 2002 | void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned); |
1932 | void sctp_assoc_set_primary(struct sctp_association *, | 2003 | void sctp_assoc_set_primary(struct sctp_association *, |
1933 | struct sctp_transport *); | 2004 | struct sctp_transport *); |
1934 | void sctp_assoc_del_nonprimary_peers(struct sctp_association *, | 2005 | void sctp_assoc_del_nonprimary_peers(struct sctp_association *, |
diff --git a/include/net/sctp/tsnmap.h b/include/net/sctp/tsnmap.h index 2c5d2b4d5d1..e7728bc14cc 100644 --- a/include/net/sctp/tsnmap.h +++ b/include/net/sctp/tsnmap.h | |||
@@ -117,8 +117,7 @@ void sctp_tsnmap_free(struct sctp_tsnmap *map); | |||
117 | int sctp_tsnmap_check(const struct sctp_tsnmap *, __u32 tsn); | 117 | int sctp_tsnmap_check(const struct sctp_tsnmap *, __u32 tsn); |
118 | 118 | ||
119 | /* Mark this TSN as seen. */ | 119 | /* Mark this TSN as seen. */ |
120 | int sctp_tsnmap_mark(struct sctp_tsnmap *, __u32 tsn, | 120 | int sctp_tsnmap_mark(struct sctp_tsnmap *, __u32 tsn); |
121 | struct sctp_transport *trans); | ||
122 | 121 | ||
123 | /* Mark this TSN and all lower as seen. */ | 122 | /* Mark this TSN and all lower as seen. */ |
124 | void sctp_tsnmap_skip(struct sctp_tsnmap *map, __u32 tsn); | 123 | void sctp_tsnmap_skip(struct sctp_tsnmap *map, __u32 tsn); |
diff --git a/include/net/sctp/ulpqueue.h b/include/net/sctp/ulpqueue.h index ff1b8ba73ab..2e5ee0d8458 100644 --- a/include/net/sctp/ulpqueue.h +++ b/include/net/sctp/ulpqueue.h | |||
@@ -72,7 +72,7 @@ int sctp_ulpq_tail_event(struct sctp_ulpq *, struct sctp_ulpevent *ev); | |||
72 | void sctp_ulpq_renege(struct sctp_ulpq *, struct sctp_chunk *, gfp_t); | 72 | void sctp_ulpq_renege(struct sctp_ulpq *, struct sctp_chunk *, gfp_t); |
73 | 73 | ||
74 | /* Perform partial delivery. */ | 74 | /* Perform partial delivery. */ |
75 | void sctp_ulpq_partial_delivery(struct sctp_ulpq *, gfp_t); | 75 | void sctp_ulpq_partial_delivery(struct sctp_ulpq *, struct sctp_chunk *, gfp_t); |
76 | 76 | ||
77 | /* Abort the partial delivery. */ | 77 | /* Abort the partial delivery. */ |
78 | void sctp_ulpq_abort_pd(struct sctp_ulpq *, gfp_t); | 78 | void sctp_ulpq_abort_pd(struct sctp_ulpq *, gfp_t); |
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h index 9a0ae091366..0842ef00b2f 100644 --- a/include/net/sctp/user.h +++ b/include/net/sctp/user.h | |||
@@ -93,7 +93,6 @@ typedef __s32 sctp_assoc_t; | |||
93 | #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 */ | 94 | #define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */ |
95 | #define SCTP_AUTO_ASCONF 30 | 95 | #define SCTP_AUTO_ASCONF 30 |
96 | #define SCTP_PEER_ADDR_THLDS 31 | ||
97 | 96 | ||
98 | /* Internal Socket Options. Some of the sctp library functions are | 97 | /* Internal Socket Options. Some of the sctp library functions are |
99 | * implemented using these socket options. | 98 | * implemented using these socket options. |
@@ -107,7 +106,6 @@ typedef __s32 sctp_assoc_t; | |||
107 | #define SCTP_GET_LOCAL_ADDRS 109 /* Get all local address. */ | 106 | #define SCTP_GET_LOCAL_ADDRS 109 /* Get all local address. */ |
108 | #define SCTP_SOCKOPT_CONNECTX 110 /* CONNECTX requests. */ | 107 | #define SCTP_SOCKOPT_CONNECTX 110 /* CONNECTX requests. */ |
109 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ | 108 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ |
110 | #define SCTP_GET_ASSOC_STATS 112 /* Read only */ | ||
111 | 109 | ||
112 | /* | 110 | /* |
113 | * 5.2.1 SCTP Initiation Structure (SCTP_INIT) | 111 | * 5.2.1 SCTP Initiation Structure (SCTP_INIT) |
@@ -651,7 +649,6 @@ struct sctp_paddrinfo { | |||
651 | */ | 649 | */ |
652 | enum sctp_spinfo_state { | 650 | enum sctp_spinfo_state { |
653 | SCTP_INACTIVE, | 651 | SCTP_INACTIVE, |
654 | SCTP_PF, | ||
655 | SCTP_ACTIVE, | 652 | SCTP_ACTIVE, |
656 | SCTP_UNCONFIRMED, | 653 | SCTP_UNCONFIRMED, |
657 | SCTP_UNKNOWN = 0xffff /* Value used for transport state unknown */ | 654 | SCTP_UNKNOWN = 0xffff /* Value used for transport state unknown */ |
@@ -720,32 +717,6 @@ struct sctp_getaddrs { | |||
720 | __u8 addrs[0]; /*output, variable size*/ | 717 | __u8 addrs[0]; /*output, variable size*/ |
721 | }; | 718 | }; |
722 | 719 | ||
723 | /* A socket user request obtained via SCTP_GET_ASSOC_STATS that retrieves | ||
724 | * association stats. All stats are counts except sas_maxrto and | ||
725 | * sas_obs_rto_ipaddr. maxrto is the max observed rto + transport since | ||
726 | * the last call. Will return 0 when RTO was not update since last call | ||
727 | */ | ||
728 | struct sctp_assoc_stats { | ||
729 | sctp_assoc_t sas_assoc_id; /* Input */ | ||
730 | /* Transport of observed max RTO */ | ||
731 | struct sockaddr_storage sas_obs_rto_ipaddr; | ||
732 | __u64 sas_maxrto; /* Maximum Observed RTO for period */ | ||
733 | __u64 sas_isacks; /* SACKs received */ | ||
734 | __u64 sas_osacks; /* SACKs sent */ | ||
735 | __u64 sas_opackets; /* Packets sent */ | ||
736 | __u64 sas_ipackets; /* Packets received */ | ||
737 | __u64 sas_rtxchunks; /* Retransmitted Chunks */ | ||
738 | __u64 sas_outofseqtsns;/* TSN received > next expected */ | ||
739 | __u64 sas_idupchunks; /* Dups received (ordered+unordered) */ | ||
740 | __u64 sas_gapcnt; /* Gap Acknowledgements Received */ | ||
741 | __u64 sas_ouodchunks; /* Unordered data chunks sent */ | ||
742 | __u64 sas_iuodchunks; /* Unordered data chunks received */ | ||
743 | __u64 sas_oodchunks; /* Ordered data chunks sent */ | ||
744 | __u64 sas_iodchunks; /* Ordered data chunks received */ | ||
745 | __u64 sas_octrlchunks; /* Control chunks sent */ | ||
746 | __u64 sas_ictrlchunks; /* Control chunks received */ | ||
747 | }; | ||
748 | |||
749 | /* These are bit fields for msghdr->msg_flags. See section 5.1. */ | 720 | /* These are bit fields for msghdr->msg_flags. See section 5.1. */ |
750 | /* On user space Linux, these live in <bits/socket.h> as an enum. */ | 721 | /* On user space Linux, these live in <bits/socket.h> as an enum. */ |
751 | enum sctp_msg_flags { | 722 | enum sctp_msg_flags { |
@@ -770,13 +741,4 @@ typedef struct { | |||
770 | int sd; | 741 | int sd; |
771 | } sctp_peeloff_arg_t; | 742 | } sctp_peeloff_arg_t; |
772 | 743 | ||
773 | /* | ||
774 | * Peer Address Thresholds socket option | ||
775 | */ | ||
776 | struct sctp_paddrthlds { | ||
777 | sctp_assoc_t spt_assoc_id; | ||
778 | struct sockaddr_storage spt_address; | ||
779 | __u16 spt_pathmaxrxt; | ||
780 | __u16 spt_pathpfthld; | ||
781 | }; | ||
782 | #endif /* __net_sctp_user_h__ */ | 744 | #endif /* __net_sctp_user_h__ */ |
diff --git a/include/net/secure_seq.h b/include/net/secure_seq.h index c2e542b27a5..d97f6892c01 100644 --- a/include/net/secure_seq.h +++ b/include/net/secure_seq.h | |||
@@ -10,7 +10,7 @@ extern u32 secure_ipv6_port_ephemeral(const __be32 *saddr, const __be32 *daddr, | |||
10 | __be16 dport); | 10 | __be16 dport); |
11 | extern __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, | 11 | extern __u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr, |
12 | __be16 sport, __be16 dport); | 12 | __be16 sport, __be16 dport); |
13 | extern __u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr, | 13 | extern __u32 secure_tcpv6_sequence_number(__be32 *saddr, __be32 *daddr, |
14 | __be16 sport, __be16 dport); | 14 | __be16 sport, __be16 dport); |
15 | extern u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, | 15 | extern u64 secure_dccp_sequence_number(__be32 saddr, __be32 daddr, |
16 | __be16 sport, __be16 dport); | 16 | __be16 sport, __be16 dport); |
diff --git a/include/net/snmp.h b/include/net/snmp.h index 71596261fa9..8f0f9ac0307 100644 --- a/include/net/snmp.h +++ b/include/net/snmp.h | |||
@@ -67,7 +67,7 @@ struct icmp_mib { | |||
67 | 67 | ||
68 | #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX | 68 | #define ICMPMSG_MIB_MAX __ICMPMSG_MIB_MAX |
69 | struct icmpmsg_mib { | 69 | struct icmpmsg_mib { |
70 | atomic_long_t mibs[ICMPMSG_MIB_MAX]; | 70 | unsigned long mibs[ICMPMSG_MIB_MAX]; |
71 | }; | 71 | }; |
72 | 72 | ||
73 | /* ICMP6 (IPv6-ICMP) */ | 73 | /* ICMP6 (IPv6-ICMP) */ |
@@ -84,7 +84,7 @@ struct icmpv6_mib_device { | |||
84 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX | 84 | #define ICMP6MSG_MIB_MAX __ICMP6MSG_MIB_MAX |
85 | /* per network ns counters */ | 85 | /* per network ns counters */ |
86 | struct icmpv6msg_mib { | 86 | struct icmpv6msg_mib { |
87 | atomic_long_t mibs[ICMP6MSG_MIB_MAX]; | 87 | unsigned long mibs[ICMP6MSG_MIB_MAX]; |
88 | }; | 88 | }; |
89 | /* per device counters, (shared on all cpus) */ | 89 | /* per device counters, (shared on all cpus) */ |
90 | struct icmpv6msg_mib_device { | 90 | struct icmpv6msg_mib_device { |
@@ -129,40 +129,38 @@ struct linux_xfrm_mib { | |||
129 | __this_cpu_inc(mib[0]->mibs[field]) | 129 | __this_cpu_inc(mib[0]->mibs[field]) |
130 | 130 | ||
131 | #define SNMP_INC_STATS_USER(mib, field) \ | 131 | #define SNMP_INC_STATS_USER(mib, field) \ |
132 | this_cpu_inc(mib[0]->mibs[field]) | 132 | irqsafe_cpu_inc(mib[0]->mibs[field]) |
133 | 133 | ||
134 | #define SNMP_INC_STATS_ATOMIC_LONG(mib, field) \ | 134 | #define SNMP_INC_STATS_ATOMIC_LONG(mib, field) \ |
135 | atomic_long_inc(&mib->mibs[field]) | 135 | atomic_long_inc(&mib->mibs[field]) |
136 | 136 | ||
137 | #define SNMP_INC_STATS(mib, field) \ | 137 | #define SNMP_INC_STATS(mib, field) \ |
138 | this_cpu_inc(mib[0]->mibs[field]) | 138 | irqsafe_cpu_inc(mib[0]->mibs[field]) |
139 | 139 | ||
140 | #define SNMP_DEC_STATS(mib, field) \ | 140 | #define SNMP_DEC_STATS(mib, field) \ |
141 | this_cpu_dec(mib[0]->mibs[field]) | 141 | irqsafe_cpu_dec(mib[0]->mibs[field]) |
142 | 142 | ||
143 | #define SNMP_ADD_STATS_BH(mib, field, addend) \ | 143 | #define SNMP_ADD_STATS_BH(mib, field, addend) \ |
144 | __this_cpu_add(mib[0]->mibs[field], addend) | 144 | __this_cpu_add(mib[0]->mibs[field], addend) |
145 | 145 | ||
146 | #define SNMP_ADD_STATS_USER(mib, field, addend) \ | 146 | #define SNMP_ADD_STATS_USER(mib, field, addend) \ |
147 | this_cpu_add(mib[0]->mibs[field], addend) | 147 | irqsafe_cpu_add(mib[0]->mibs[field], addend) |
148 | 148 | ||
149 | #define SNMP_ADD_STATS(mib, field, addend) \ | 149 | #define SNMP_ADD_STATS(mib, field, addend) \ |
150 | this_cpu_add(mib[0]->mibs[field], addend) | 150 | irqsafe_cpu_add(mib[0]->mibs[field], addend) |
151 | /* | 151 | /* |
152 | * Use "__typeof__(*mib[0]) *ptr" instead of "__typeof__(mib[0]) ptr" | 152 | * Use "__typeof__(*mib[0]) *ptr" instead of "__typeof__(mib[0]) ptr" |
153 | * to make @ptr a non-percpu pointer. | 153 | * to make @ptr a non-percpu pointer. |
154 | */ | 154 | */ |
155 | #define SNMP_UPD_PO_STATS(mib, basefield, addend) \ | 155 | #define SNMP_UPD_PO_STATS(mib, basefield, addend) \ |
156 | do { \ | 156 | do { \ |
157 | __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \ | 157 | irqsafe_cpu_inc(mib[0]->mibs[basefield##PKTS]); \ |
158 | this_cpu_inc(ptr[basefield##PKTS]); \ | 158 | irqsafe_cpu_add(mib[0]->mibs[basefield##OCTETS], addend); \ |
159 | this_cpu_add(ptr[basefield##OCTETS], addend); \ | ||
160 | } while (0) | 159 | } while (0) |
161 | #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ | 160 | #define SNMP_UPD_PO_STATS_BH(mib, basefield, addend) \ |
162 | do { \ | 161 | do { \ |
163 | __typeof__(*mib[0]->mibs) *ptr = mib[0]->mibs; \ | 162 | __this_cpu_inc(mib[0]->mibs[basefield##PKTS]); \ |
164 | __this_cpu_inc(ptr[basefield##PKTS]); \ | 163 | __this_cpu_add(mib[0]->mibs[basefield##OCTETS], addend); \ |
165 | __this_cpu_add(ptr[basefield##OCTETS], addend); \ | ||
166 | } while (0) | 164 | } while (0) |
167 | 165 | ||
168 | 166 | ||
diff --git a/include/net/sock.h b/include/net/sock.h index 182ca99405a..8e4062f165b 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -46,7 +46,7 @@ | |||
46 | #include <linux/list_nulls.h> | 46 | #include <linux/list_nulls.h> |
47 | #include <linux/timer.h> | 47 | #include <linux/timer.h> |
48 | #include <linux/cache.h> | 48 | #include <linux/cache.h> |
49 | #include <linux/bitops.h> | 49 | #include <linux/module.h> |
50 | #include <linux/lockdep.h> | 50 | #include <linux/lockdep.h> |
51 | #include <linux/netdevice.h> | 51 | #include <linux/netdevice.h> |
52 | #include <linux/skbuff.h> /* struct sk_buff */ | 52 | #include <linux/skbuff.h> /* struct sk_buff */ |
@@ -54,11 +54,6 @@ | |||
54 | #include <linux/security.h> | 54 | #include <linux/security.h> |
55 | #include <linux/slab.h> | 55 | #include <linux/slab.h> |
56 | #include <linux/uaccess.h> | 56 | #include <linux/uaccess.h> |
57 | #include <linux/memcontrol.h> | ||
58 | #include <linux/res_counter.h> | ||
59 | #include <linux/static_key.h> | ||
60 | #include <linux/aio.h> | ||
61 | #include <linux/sched.h> | ||
62 | 57 | ||
63 | #include <linux/filter.h> | 58 | #include <linux/filter.h> |
64 | #include <linux/rculist_nulls.h> | 59 | #include <linux/rculist_nulls.h> |
@@ -68,22 +63,6 @@ | |||
68 | #include <net/dst.h> | 63 | #include <net/dst.h> |
69 | #include <net/checksum.h> | 64 | #include <net/checksum.h> |
70 | 65 | ||
71 | struct cgroup; | ||
72 | struct cgroup_subsys; | ||
73 | #ifdef CONFIG_NET | ||
74 | int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss); | ||
75 | void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg); | ||
76 | #else | ||
77 | static inline | ||
78 | int mem_cgroup_sockets_init(struct mem_cgroup *memcg, struct cgroup_subsys *ss) | ||
79 | { | ||
80 | return 0; | ||
81 | } | ||
82 | static inline | ||
83 | void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg) | ||
84 | { | ||
85 | } | ||
86 | #endif | ||
87 | /* | 66 | /* |
88 | * This structure really needs to be cleaned up. | 67 | * This structure really needs to be cleaned up. |
89 | * Most of it is for TCP, and not used by any of | 68 | * Most of it is for TCP, and not used by any of |
@@ -97,8 +76,8 @@ void mem_cgroup_sockets_destroy(struct mem_cgroup *memcg) | |||
97 | printk(KERN_DEBUG msg); } while (0) | 76 | printk(KERN_DEBUG msg); } while (0) |
98 | #else | 77 | #else |
99 | /* Validate arguments and do nothing */ | 78 | /* Validate arguments and do nothing */ |
100 | static inline __printf(2, 3) | 79 | static inline void __attribute__ ((format (printf, 2, 3))) |
101 | void SOCK_DEBUG(const struct sock *sk, const char *msg, ...) | 80 | SOCK_DEBUG(struct sock *sk, const char *msg, ...) |
102 | { | 81 | { |
103 | } | 82 | } |
104 | #endif | 83 | #endif |
@@ -126,17 +105,12 @@ struct sock; | |||
126 | struct proto; | 105 | struct proto; |
127 | struct net; | 106 | struct net; |
128 | 107 | ||
129 | typedef __u32 __bitwise __portpair; | ||
130 | typedef __u64 __bitwise __addrpair; | ||
131 | |||
132 | /** | 108 | /** |
133 | * struct sock_common - minimal network layer representation of sockets | 109 | * struct sock_common - minimal network layer representation of sockets |
134 | * @skc_daddr: Foreign IPv4 addr | 110 | * @skc_daddr: Foreign IPv4 addr |
135 | * @skc_rcv_saddr: Bound local IPv4 addr | 111 | * @skc_rcv_saddr: Bound local IPv4 addr |
136 | * @skc_hash: hash value used with various protocol lookup tables | 112 | * @skc_hash: hash value used with various protocol lookup tables |
137 | * @skc_u16hashes: two u16 hash values used by UDP lookup tables | 113 | * @skc_u16hashes: two u16 hash values used by UDP lookup tables |
138 | * @skc_dport: placeholder for inet_dport/tw_dport | ||
139 | * @skc_num: placeholder for inet_num/tw_num | ||
140 | * @skc_family: network address family | 114 | * @skc_family: network address family |
141 | * @skc_state: Connection state | 115 | * @skc_state: Connection state |
142 | * @skc_reuse: %SO_REUSEADDR setting | 116 | * @skc_reuse: %SO_REUSEADDR setting |
@@ -154,29 +128,16 @@ typedef __u64 __bitwise __addrpair; | |||
154 | * for struct sock and struct inet_timewait_sock. | 128 | * for struct sock and struct inet_timewait_sock. |
155 | */ | 129 | */ |
156 | struct sock_common { | 130 | struct sock_common { |
157 | /* skc_daddr and skc_rcv_saddr must be grouped on a 8 bytes aligned | 131 | /* skc_daddr and skc_rcv_saddr must be grouped : |
158 | * address on 64bit arches : cf INET_MATCH() and INET_TW_MATCH() | 132 | * cf INET_MATCH() and INET_TW_MATCH() |
159 | */ | 133 | */ |
160 | union { | 134 | __be32 skc_daddr; |
161 | __addrpair skc_addrpair; | 135 | __be32 skc_rcv_saddr; |
162 | struct { | 136 | |
163 | __be32 skc_daddr; | ||
164 | __be32 skc_rcv_saddr; | ||
165 | }; | ||
166 | }; | ||
167 | union { | 137 | union { |
168 | unsigned int skc_hash; | 138 | unsigned int skc_hash; |
169 | __u16 skc_u16hashes[2]; | 139 | __u16 skc_u16hashes[2]; |
170 | }; | 140 | }; |
171 | /* skc_dport && skc_num must be grouped as well */ | ||
172 | union { | ||
173 | __portpair skc_portpair; | ||
174 | struct { | ||
175 | __be16 skc_dport; | ||
176 | __u16 skc_num; | ||
177 | }; | ||
178 | }; | ||
179 | |||
180 | unsigned short skc_family; | 141 | unsigned short skc_family; |
181 | volatile unsigned char skc_state; | 142 | volatile unsigned char skc_state; |
182 | unsigned char skc_reuse; | 143 | unsigned char skc_reuse; |
@@ -207,7 +168,6 @@ struct sock_common { | |||
207 | /* public: */ | 168 | /* public: */ |
208 | }; | 169 | }; |
209 | 170 | ||
210 | struct cg_proto; | ||
211 | /** | 171 | /** |
212 | * struct sock - network layer representation of sockets | 172 | * struct sock - network layer representation of sockets |
213 | * @__sk_common: shared layout with inet_timewait_sock | 173 | * @__sk_common: shared layout with inet_timewait_sock |
@@ -216,7 +176,6 @@ struct cg_proto; | |||
216 | * @sk_lock: synchronizer | 176 | * @sk_lock: synchronizer |
217 | * @sk_rcvbuf: size of receive buffer in bytes | 177 | * @sk_rcvbuf: size of receive buffer in bytes |
218 | * @sk_wq: sock wait queue and async head | 178 | * @sk_wq: sock wait queue and async head |
219 | * @sk_rx_dst: receive input route used by early tcp demux | ||
220 | * @sk_dst_cache: destination cache | 179 | * @sk_dst_cache: destination cache |
221 | * @sk_dst_lock: destination cache lock | 180 | * @sk_dst_lock: destination cache lock |
222 | * @sk_policy: flow policy | 181 | * @sk_policy: flow policy |
@@ -231,12 +190,11 @@ struct cg_proto; | |||
231 | * @sk_sndbuf: size of send buffer in bytes | 190 | * @sk_sndbuf: size of send buffer in bytes |
232 | * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, | 191 | * @sk_flags: %SO_LINGER (l_onoff), %SO_BROADCAST, %SO_KEEPALIVE, |
233 | * %SO_OOBINLINE settings, %SO_TIMESTAMPING settings | 192 | * %SO_OOBINLINE settings, %SO_TIMESTAMPING settings |
234 | * @sk_no_check: %SO_NO_CHECK setting, whether or not checkup packets | 193 | * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets |
235 | * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) | 194 | * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) |
236 | * @sk_route_nocaps: forbidden route capabilities (e.g NETIF_F_GSO_MASK) | 195 | * @sk_route_nocaps: forbidden route capabilities (e.g NETIF_F_GSO_MASK) |
237 | * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4) | 196 | * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4) |
238 | * @sk_gso_max_size: Maximum GSO segment size to build | 197 | * @sk_gso_max_size: Maximum GSO segment size to build |
239 | * @sk_gso_max_segs: Maximum number of GSO segments | ||
240 | * @sk_lingertime: %SO_LINGER l_linger setting | 198 | * @sk_lingertime: %SO_LINGER l_linger setting |
241 | * @sk_backlog: always used with the per-socket spinlock held | 199 | * @sk_backlog: always used with the per-socket spinlock held |
242 | * @sk_callback_lock: used with the callbacks in the end of this struct | 200 | * @sk_callback_lock: used with the callbacks in the end of this struct |
@@ -250,7 +208,6 @@ struct cg_proto; | |||
250 | * @sk_ack_backlog: current listen backlog | 208 | * @sk_ack_backlog: current listen backlog |
251 | * @sk_max_ack_backlog: listen backlog set in listen() | 209 | * @sk_max_ack_backlog: listen backlog set in listen() |
252 | * @sk_priority: %SO_PRIORITY setting | 210 | * @sk_priority: %SO_PRIORITY setting |
253 | * @sk_cgrp_prioidx: socket group's priority map index | ||
254 | * @sk_type: socket type (%SOCK_STREAM, etc) | 211 | * @sk_type: socket type (%SOCK_STREAM, etc) |
255 | * @sk_protocol: which protocol this socket belongs in this network family | 212 | * @sk_protocol: which protocol this socket belongs in this network family |
256 | * @sk_peer_pid: &struct pid for this socket's peer | 213 | * @sk_peer_pid: &struct pid for this socket's peer |
@@ -265,13 +222,12 @@ struct cg_proto; | |||
265 | * @sk_stamp: time stamp of last packet received | 222 | * @sk_stamp: time stamp of last packet received |
266 | * @sk_socket: Identd and reporting IO signals | 223 | * @sk_socket: Identd and reporting IO signals |
267 | * @sk_user_data: RPC layer private data | 224 | * @sk_user_data: RPC layer private data |
268 | * @sk_frag: cached page frag | 225 | * @sk_sndmsg_page: cached page for sendmsg |
269 | * @sk_peek_off: current peek_offset value | 226 | * @sk_sndmsg_off: cached offset for sendmsg |
270 | * @sk_send_head: front of stuff to transmit | 227 | * @sk_send_head: front of stuff to transmit |
271 | * @sk_security: used by security modules | 228 | * @sk_security: used by security modules |
272 | * @sk_mark: generic packet mark | 229 | * @sk_mark: generic packet mark |
273 | * @sk_classid: this socket's cgroup classid | 230 | * @sk_classid: this socket's cgroup classid |
274 | * @sk_cgrp: this socket's cgroup-specific proto data | ||
275 | * @sk_write_pending: a write to stream socket waits to start | 231 | * @sk_write_pending: a write to stream socket waits to start |
276 | * @sk_state_change: callback to indicate change in the state of the sock | 232 | * @sk_state_change: callback to indicate change in the state of the sock |
277 | * @sk_data_ready: callback to indicate there is data to be processed | 233 | * @sk_data_ready: callback to indicate there is data to be processed |
@@ -336,7 +292,6 @@ struct sock { | |||
336 | struct xfrm_policy *sk_policy[2]; | 292 | struct xfrm_policy *sk_policy[2]; |
337 | #endif | 293 | #endif |
338 | unsigned long sk_flags; | 294 | unsigned long sk_flags; |
339 | struct dst_entry *sk_rx_dst; | ||
340 | struct dst_entry *sk_dst_cache; | 295 | struct dst_entry *sk_dst_cache; |
341 | spinlock_t sk_dst_lock; | 296 | spinlock_t sk_dst_lock; |
342 | atomic_t sk_wmem_alloc; | 297 | atomic_t sk_wmem_alloc; |
@@ -352,11 +307,10 @@ struct sock { | |||
352 | kmemcheck_bitfield_end(flags); | 307 | kmemcheck_bitfield_end(flags); |
353 | int sk_wmem_queued; | 308 | int sk_wmem_queued; |
354 | gfp_t sk_allocation; | 309 | gfp_t sk_allocation; |
355 | netdev_features_t sk_route_caps; | 310 | int sk_route_caps; |
356 | netdev_features_t sk_route_nocaps; | 311 | int sk_route_nocaps; |
357 | int sk_gso_type; | 312 | int sk_gso_type; |
358 | unsigned int sk_gso_max_size; | 313 | unsigned int sk_gso_max_size; |
359 | u16 sk_gso_max_segs; | ||
360 | int sk_rcvlowat; | 314 | int sk_rcvlowat; |
361 | unsigned long sk_lingertime; | 315 | unsigned long sk_lingertime; |
362 | struct sk_buff_head sk_error_queue; | 316 | struct sk_buff_head sk_error_queue; |
@@ -367,9 +321,6 @@ struct sock { | |||
367 | unsigned short sk_ack_backlog; | 321 | unsigned short sk_ack_backlog; |
368 | unsigned short sk_max_ack_backlog; | 322 | unsigned short sk_max_ack_backlog; |
369 | __u32 sk_priority; | 323 | __u32 sk_priority; |
370 | #if IS_ENABLED(CONFIG_NETPRIO_CGROUP) | ||
371 | __u32 sk_cgrp_prioidx; | ||
372 | #endif | ||
373 | struct pid *sk_peer_pid; | 324 | struct pid *sk_peer_pid; |
374 | const struct cred *sk_peer_cred; | 325 | const struct cred *sk_peer_cred; |
375 | long sk_rcvtimeo; | 326 | long sk_rcvtimeo; |
@@ -379,61 +330,25 @@ struct sock { | |||
379 | ktime_t sk_stamp; | 330 | ktime_t sk_stamp; |
380 | struct socket *sk_socket; | 331 | struct socket *sk_socket; |
381 | void *sk_user_data; | 332 | void *sk_user_data; |
382 | struct page_frag sk_frag; | 333 | struct page *sk_sndmsg_page; |
383 | struct sk_buff *sk_send_head; | 334 | struct sk_buff *sk_send_head; |
384 | __s32 sk_peek_off; | 335 | __u32 sk_sndmsg_off; |
385 | int sk_write_pending; | 336 | int sk_write_pending; |
386 | #ifdef CONFIG_SECURITY | 337 | #ifdef CONFIG_SECURITY |
387 | void *sk_security; | 338 | void *sk_security; |
388 | #endif | 339 | #endif |
389 | __u32 sk_mark; | 340 | __u32 sk_mark; |
390 | u32 sk_classid; | 341 | u32 sk_classid; |
391 | struct cg_proto *sk_cgrp; | ||
392 | void (*sk_state_change)(struct sock *sk); | 342 | void (*sk_state_change)(struct sock *sk); |
393 | void (*sk_data_ready)(struct sock *sk, int bytes); | 343 | void (*sk_data_ready)(struct sock *sk, int bytes); |
394 | void (*sk_write_space)(struct sock *sk); | 344 | void (*sk_write_space)(struct sock *sk); |
395 | void (*sk_error_report)(struct sock *sk); | 345 | void (*sk_error_report)(struct sock *sk); |
396 | int (*sk_backlog_rcv)(struct sock *sk, | 346 | int (*sk_backlog_rcv)(struct sock *sk, |
397 | struct sk_buff *skb); | 347 | struct sk_buff *skb); |
398 | void (*sk_destruct)(struct sock *sk); | 348 | void (*sk_destruct)(struct sock *sk); |
399 | }; | 349 | }; |
400 | 350 | ||
401 | /* | 351 | /* |
402 | * SK_CAN_REUSE and SK_NO_REUSE on a socket mean that the socket is OK | ||
403 | * or not whether his port will be reused by someone else. SK_FORCE_REUSE | ||
404 | * on a socket means that the socket will reuse everybody else's port | ||
405 | * without looking at the other's sk_reuse value. | ||
406 | */ | ||
407 | |||
408 | #define SK_NO_REUSE 0 | ||
409 | #define SK_CAN_REUSE 1 | ||
410 | #define SK_FORCE_REUSE 2 | ||
411 | |||
412 | static inline int sk_peek_offset(struct sock *sk, int flags) | ||
413 | { | ||
414 | if ((flags & MSG_PEEK) && (sk->sk_peek_off >= 0)) | ||
415 | return sk->sk_peek_off; | ||
416 | else | ||
417 | return 0; | ||
418 | } | ||
419 | |||
420 | static inline void sk_peek_offset_bwd(struct sock *sk, int val) | ||
421 | { | ||
422 | if (sk->sk_peek_off >= 0) { | ||
423 | if (sk->sk_peek_off >= val) | ||
424 | sk->sk_peek_off -= val; | ||
425 | else | ||
426 | sk->sk_peek_off = 0; | ||
427 | } | ||
428 | } | ||
429 | |||
430 | static inline void sk_peek_offset_fwd(struct sock *sk, int val) | ||
431 | { | ||
432 | if (sk->sk_peek_off >= 0) | ||
433 | sk->sk_peek_off += val; | ||
434 | } | ||
435 | |||
436 | /* | ||
437 | * Hashed lists helper routines | 352 | * Hashed lists helper routines |
438 | */ | 353 | */ |
439 | static inline struct sock *sk_entry(const struct hlist_node *node) | 354 | static inline struct sock *sk_entry(const struct hlist_node *node) |
@@ -475,40 +390,40 @@ static inline struct sock *sk_nulls_next(const struct sock *sk) | |||
475 | NULL; | 390 | NULL; |
476 | } | 391 | } |
477 | 392 | ||
478 | static inline bool sk_unhashed(const struct sock *sk) | 393 | static inline int sk_unhashed(const struct sock *sk) |
479 | { | 394 | { |
480 | return hlist_unhashed(&sk->sk_node); | 395 | return hlist_unhashed(&sk->sk_node); |
481 | } | 396 | } |
482 | 397 | ||
483 | static inline bool sk_hashed(const struct sock *sk) | 398 | static inline int sk_hashed(const struct sock *sk) |
484 | { | 399 | { |
485 | return !sk_unhashed(sk); | 400 | return !sk_unhashed(sk); |
486 | } | 401 | } |
487 | 402 | ||
488 | static inline void sk_node_init(struct hlist_node *node) | 403 | static __inline__ void sk_node_init(struct hlist_node *node) |
489 | { | 404 | { |
490 | node->pprev = NULL; | 405 | node->pprev = NULL; |
491 | } | 406 | } |
492 | 407 | ||
493 | static inline void sk_nulls_node_init(struct hlist_nulls_node *node) | 408 | static __inline__ void sk_nulls_node_init(struct hlist_nulls_node *node) |
494 | { | 409 | { |
495 | node->pprev = NULL; | 410 | node->pprev = NULL; |
496 | } | 411 | } |
497 | 412 | ||
498 | static inline void __sk_del_node(struct sock *sk) | 413 | static __inline__ void __sk_del_node(struct sock *sk) |
499 | { | 414 | { |
500 | __hlist_del(&sk->sk_node); | 415 | __hlist_del(&sk->sk_node); |
501 | } | 416 | } |
502 | 417 | ||
503 | /* NB: equivalent to hlist_del_init_rcu */ | 418 | /* NB: equivalent to hlist_del_init_rcu */ |
504 | static inline bool __sk_del_node_init(struct sock *sk) | 419 | static __inline__ int __sk_del_node_init(struct sock *sk) |
505 | { | 420 | { |
506 | if (sk_hashed(sk)) { | 421 | if (sk_hashed(sk)) { |
507 | __sk_del_node(sk); | 422 | __sk_del_node(sk); |
508 | sk_node_init(&sk->sk_node); | 423 | sk_node_init(&sk->sk_node); |
509 | return true; | 424 | return 1; |
510 | } | 425 | } |
511 | return false; | 426 | return 0; |
512 | } | 427 | } |
513 | 428 | ||
514 | /* Grab socket reference count. This operation is valid only | 429 | /* Grab socket reference count. This operation is valid only |
@@ -530,9 +445,9 @@ static inline void __sock_put(struct sock *sk) | |||
530 | atomic_dec(&sk->sk_refcnt); | 445 | atomic_dec(&sk->sk_refcnt); |
531 | } | 446 | } |
532 | 447 | ||
533 | static inline bool sk_del_node_init(struct sock *sk) | 448 | static __inline__ int sk_del_node_init(struct sock *sk) |
534 | { | 449 | { |
535 | bool rc = __sk_del_node_init(sk); | 450 | int rc = __sk_del_node_init(sk); |
536 | 451 | ||
537 | if (rc) { | 452 | if (rc) { |
538 | /* paranoid for a while -acme */ | 453 | /* paranoid for a while -acme */ |
@@ -543,18 +458,18 @@ static inline bool sk_del_node_init(struct sock *sk) | |||
543 | } | 458 | } |
544 | #define sk_del_node_init_rcu(sk) sk_del_node_init(sk) | 459 | #define sk_del_node_init_rcu(sk) sk_del_node_init(sk) |
545 | 460 | ||
546 | static inline bool __sk_nulls_del_node_init_rcu(struct sock *sk) | 461 | static __inline__ int __sk_nulls_del_node_init_rcu(struct sock *sk) |
547 | { | 462 | { |
548 | if (sk_hashed(sk)) { | 463 | if (sk_hashed(sk)) { |
549 | hlist_nulls_del_init_rcu(&sk->sk_nulls_node); | 464 | hlist_nulls_del_init_rcu(&sk->sk_nulls_node); |
550 | return true; | 465 | return 1; |
551 | } | 466 | } |
552 | return false; | 467 | return 0; |
553 | } | 468 | } |
554 | 469 | ||
555 | static inline bool sk_nulls_del_node_init_rcu(struct sock *sk) | 470 | static __inline__ int sk_nulls_del_node_init_rcu(struct sock *sk) |
556 | { | 471 | { |
557 | bool rc = __sk_nulls_del_node_init_rcu(sk); | 472 | int rc = __sk_nulls_del_node_init_rcu(sk); |
558 | 473 | ||
559 | if (rc) { | 474 | if (rc) { |
560 | /* paranoid for a while -acme */ | 475 | /* paranoid for a while -acme */ |
@@ -564,40 +479,40 @@ static inline bool sk_nulls_del_node_init_rcu(struct sock *sk) | |||
564 | return rc; | 479 | return rc; |
565 | } | 480 | } |
566 | 481 | ||
567 | static inline void __sk_add_node(struct sock *sk, struct hlist_head *list) | 482 | static __inline__ void __sk_add_node(struct sock *sk, struct hlist_head *list) |
568 | { | 483 | { |
569 | hlist_add_head(&sk->sk_node, list); | 484 | hlist_add_head(&sk->sk_node, list); |
570 | } | 485 | } |
571 | 486 | ||
572 | static inline void sk_add_node(struct sock *sk, struct hlist_head *list) | 487 | static __inline__ void sk_add_node(struct sock *sk, struct hlist_head *list) |
573 | { | 488 | { |
574 | sock_hold(sk); | 489 | sock_hold(sk); |
575 | __sk_add_node(sk, list); | 490 | __sk_add_node(sk, list); |
576 | } | 491 | } |
577 | 492 | ||
578 | static inline void sk_add_node_rcu(struct sock *sk, struct hlist_head *list) | 493 | static __inline__ void sk_add_node_rcu(struct sock *sk, struct hlist_head *list) |
579 | { | 494 | { |
580 | sock_hold(sk); | 495 | sock_hold(sk); |
581 | hlist_add_head_rcu(&sk->sk_node, list); | 496 | hlist_add_head_rcu(&sk->sk_node, list); |
582 | } | 497 | } |
583 | 498 | ||
584 | static inline void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list) | 499 | static __inline__ void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list) |
585 | { | 500 | { |
586 | hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list); | 501 | hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list); |
587 | } | 502 | } |
588 | 503 | ||
589 | static inline void sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list) | 504 | static __inline__ void sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list) |
590 | { | 505 | { |
591 | sock_hold(sk); | 506 | sock_hold(sk); |
592 | __sk_nulls_add_node_rcu(sk, list); | 507 | __sk_nulls_add_node_rcu(sk, list); |
593 | } | 508 | } |
594 | 509 | ||
595 | static inline void __sk_del_bind_node(struct sock *sk) | 510 | static __inline__ void __sk_del_bind_node(struct sock *sk) |
596 | { | 511 | { |
597 | __hlist_del(&sk->sk_bind_node); | 512 | __hlist_del(&sk->sk_bind_node); |
598 | } | 513 | } |
599 | 514 | ||
600 | static inline void sk_add_bind_node(struct sock *sk, | 515 | static __inline__ void sk_add_bind_node(struct sock *sk, |
601 | struct hlist_head *list) | 516 | struct hlist_head *list) |
602 | { | 517 | { |
603 | hlist_add_head(&sk->sk_bind_node, list); | 518 | hlist_add_head(&sk->sk_bind_node, list); |
@@ -622,15 +537,6 @@ static inline void sk_add_bind_node(struct sock *sk, | |||
622 | #define sk_for_each_bound(__sk, node, list) \ | 537 | #define sk_for_each_bound(__sk, node, list) \ |
623 | hlist_for_each_entry(__sk, node, list, sk_bind_node) | 538 | hlist_for_each_entry(__sk, node, list, sk_bind_node) |
624 | 539 | ||
625 | static inline struct user_namespace *sk_user_ns(struct sock *sk) | ||
626 | { | ||
627 | /* Careful only use this in a context where these parameters | ||
628 | * can not change and must all be valid, such as recvmsg from | ||
629 | * userspace. | ||
630 | */ | ||
631 | return sk->sk_socket->file->f_cred->user_ns; | ||
632 | } | ||
633 | |||
634 | /* Sock flags */ | 540 | /* Sock flags */ |
635 | enum sock_flags { | 541 | enum sock_flags { |
636 | SOCK_DEAD, | 542 | SOCK_DEAD, |
@@ -648,7 +554,6 @@ enum sock_flags { | |||
648 | SOCK_RCVTSTAMPNS, /* %SO_TIMESTAMPNS setting */ | 554 | SOCK_RCVTSTAMPNS, /* %SO_TIMESTAMPNS setting */ |
649 | SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */ | 555 | SOCK_LOCALROUTE, /* route locally only, %SO_DONTROUTE setting */ |
650 | SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ | 556 | SOCK_QUEUE_SHRUNK, /* write queue has been shrunk recently */ |
651 | SOCK_MEMALLOC, /* VM depends on this socket for swapping */ | ||
652 | SOCK_TIMESTAMPING_TX_HARDWARE, /* %SOF_TIMESTAMPING_TX_HARDWARE */ | 557 | SOCK_TIMESTAMPING_TX_HARDWARE, /* %SOF_TIMESTAMPING_TX_HARDWARE */ |
653 | SOCK_TIMESTAMPING_TX_SOFTWARE, /* %SOF_TIMESTAMPING_TX_SOFTWARE */ | 558 | SOCK_TIMESTAMPING_TX_SOFTWARE, /* %SOF_TIMESTAMPING_TX_SOFTWARE */ |
654 | SOCK_TIMESTAMPING_RX_HARDWARE, /* %SOF_TIMESTAMPING_RX_HARDWARE */ | 559 | SOCK_TIMESTAMPING_RX_HARDWARE, /* %SOF_TIMESTAMPING_RX_HARDWARE */ |
@@ -659,11 +564,6 @@ enum sock_flags { | |||
659 | SOCK_FASYNC, /* fasync() active */ | 564 | SOCK_FASYNC, /* fasync() active */ |
660 | SOCK_RXQ_OVFL, | 565 | SOCK_RXQ_OVFL, |
661 | SOCK_ZEROCOPY, /* buffers from userspace */ | 566 | SOCK_ZEROCOPY, /* buffers from userspace */ |
662 | SOCK_WIFI_STATUS, /* push wifi status to userspace */ | ||
663 | SOCK_NOFCS, /* Tell NIC not to do the Ethernet FCS. | ||
664 | * Will use last 4 bytes of packet sent from | ||
665 | * user-space instead. | ||
666 | */ | ||
667 | }; | 567 | }; |
668 | 568 | ||
669 | static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) | 569 | static inline void sock_copy_flags(struct sock *nsk, struct sock *osk) |
@@ -681,31 +581,11 @@ static inline void sock_reset_flag(struct sock *sk, enum sock_flags flag) | |||
681 | __clear_bit(flag, &sk->sk_flags); | 581 | __clear_bit(flag, &sk->sk_flags); |
682 | } | 582 | } |
683 | 583 | ||
684 | static inline bool sock_flag(const struct sock *sk, enum sock_flags flag) | 584 | static inline int sock_flag(struct sock *sk, enum sock_flags flag) |
685 | { | 585 | { |
686 | return test_bit(flag, &sk->sk_flags); | 586 | return test_bit(flag, &sk->sk_flags); |
687 | } | 587 | } |
688 | 588 | ||
689 | #ifdef CONFIG_NET | ||
690 | extern struct static_key memalloc_socks; | ||
691 | static inline int sk_memalloc_socks(void) | ||
692 | { | ||
693 | return static_key_false(&memalloc_socks); | ||
694 | } | ||
695 | #else | ||
696 | |||
697 | static inline int sk_memalloc_socks(void) | ||
698 | { | ||
699 | return 0; | ||
700 | } | ||
701 | |||
702 | #endif | ||
703 | |||
704 | static inline gfp_t sk_gfp_atomic(struct sock *sk, gfp_t gfp_mask) | ||
705 | { | ||
706 | return GFP_ATOMIC | (sk->sk_allocation & __GFP_MEMALLOC); | ||
707 | } | ||
708 | |||
709 | static inline void sk_acceptq_removed(struct sock *sk) | 589 | static inline void sk_acceptq_removed(struct sock *sk) |
710 | { | 590 | { |
711 | sk->sk_ack_backlog--; | 591 | sk->sk_ack_backlog--; |
@@ -716,7 +596,7 @@ static inline void sk_acceptq_added(struct sock *sk) | |||
716 | sk->sk_ack_backlog++; | 596 | sk->sk_ack_backlog++; |
717 | } | 597 | } |
718 | 598 | ||
719 | static inline bool sk_acceptq_is_full(const struct sock *sk) | 599 | static inline int sk_acceptq_is_full(struct sock *sk) |
720 | { | 600 | { |
721 | return sk->sk_ack_backlog > sk->sk_max_ack_backlog; | 601 | return sk->sk_ack_backlog > sk->sk_max_ack_backlog; |
722 | } | 602 | } |
@@ -724,19 +604,19 @@ static inline bool sk_acceptq_is_full(const struct sock *sk) | |||
724 | /* | 604 | /* |
725 | * Compute minimal free write space needed to queue new packets. | 605 | * Compute minimal free write space needed to queue new packets. |
726 | */ | 606 | */ |
727 | static inline int sk_stream_min_wspace(const struct sock *sk) | 607 | static inline int sk_stream_min_wspace(struct sock *sk) |
728 | { | 608 | { |
729 | return sk->sk_wmem_queued >> 1; | 609 | return sk->sk_wmem_queued >> 1; |
730 | } | 610 | } |
731 | 611 | ||
732 | static inline int sk_stream_wspace(const struct sock *sk) | 612 | static inline int sk_stream_wspace(struct sock *sk) |
733 | { | 613 | { |
734 | return sk->sk_sndbuf - sk->sk_wmem_queued; | 614 | return sk->sk_sndbuf - sk->sk_wmem_queued; |
735 | } | 615 | } |
736 | 616 | ||
737 | extern void sk_stream_write_space(struct sock *sk); | 617 | extern void sk_stream_write_space(struct sock *sk); |
738 | 618 | ||
739 | static inline bool sk_stream_memory_free(const struct sock *sk) | 619 | static inline int sk_stream_memory_free(struct sock *sk) |
740 | { | 620 | { |
741 | return sk->sk_wmem_queued < sk->sk_sndbuf; | 621 | return sk->sk_wmem_queued < sk->sk_sndbuf; |
742 | } | 622 | } |
@@ -758,22 +638,18 @@ static inline void __sk_add_backlog(struct sock *sk, struct sk_buff *skb) | |||
758 | 638 | ||
759 | /* | 639 | /* |
760 | * Take into account size of receive queue and backlog queue | 640 | * Take into account size of receive queue and backlog queue |
761 | * Do not take into account this skb truesize, | ||
762 | * to allow even a single big packet to come. | ||
763 | */ | 641 | */ |
764 | static inline bool sk_rcvqueues_full(const struct sock *sk, const struct sk_buff *skb, | 642 | static inline bool sk_rcvqueues_full(const struct sock *sk, const struct sk_buff *skb) |
765 | unsigned int limit) | ||
766 | { | 643 | { |
767 | unsigned int qsize = sk->sk_backlog.len + atomic_read(&sk->sk_rmem_alloc); | 644 | unsigned int qsize = sk->sk_backlog.len + atomic_read(&sk->sk_rmem_alloc); |
768 | 645 | ||
769 | return qsize > limit; | 646 | return qsize + skb->truesize > sk->sk_rcvbuf; |
770 | } | 647 | } |
771 | 648 | ||
772 | /* The per-socket spinlock must be held here. */ | 649 | /* The per-socket spinlock must be held here. */ |
773 | static inline __must_check int sk_add_backlog(struct sock *sk, struct sk_buff *skb, | 650 | static inline __must_check int sk_add_backlog(struct sock *sk, struct sk_buff *skb) |
774 | unsigned int limit) | ||
775 | { | 651 | { |
776 | if (sk_rcvqueues_full(sk, skb, limit)) | 652 | if (sk_rcvqueues_full(sk, skb)) |
777 | return -ENOBUFS; | 653 | return -ENOBUFS; |
778 | 654 | ||
779 | __sk_add_backlog(sk, skb); | 655 | __sk_add_backlog(sk, skb); |
@@ -781,13 +657,8 @@ static inline __must_check int sk_add_backlog(struct sock *sk, struct sk_buff *s | |||
781 | return 0; | 657 | return 0; |
782 | } | 658 | } |
783 | 659 | ||
784 | extern int __sk_backlog_rcv(struct sock *sk, struct sk_buff *skb); | ||
785 | |||
786 | static inline int sk_backlog_rcv(struct sock *sk, struct sk_buff *skb) | 660 | static inline int sk_backlog_rcv(struct sock *sk, struct sk_buff *skb) |
787 | { | 661 | { |
788 | if (sk_memalloc_socks() && skb_pfmemalloc(skb)) | ||
789 | return __sk_backlog_rcv(sk, skb); | ||
790 | |||
791 | return sk->sk_backlog_rcv(sk, skb); | 662 | return sk->sk_backlog_rcv(sk, skb); |
792 | } | 663 | } |
793 | 664 | ||
@@ -815,25 +686,16 @@ static inline void sock_rps_reset_flow(const struct sock *sk) | |||
815 | #endif | 686 | #endif |
816 | } | 687 | } |
817 | 688 | ||
818 | static inline void sock_rps_save_rxhash(struct sock *sk, | 689 | static inline void sock_rps_save_rxhash(struct sock *sk, u32 rxhash) |
819 | const struct sk_buff *skb) | ||
820 | { | 690 | { |
821 | #ifdef CONFIG_RPS | 691 | #ifdef CONFIG_RPS |
822 | if (unlikely(sk->sk_rxhash != skb->rxhash)) { | 692 | if (unlikely(sk->sk_rxhash != rxhash)) { |
823 | sock_rps_reset_flow(sk); | 693 | sock_rps_reset_flow(sk); |
824 | sk->sk_rxhash = skb->rxhash; | 694 | sk->sk_rxhash = rxhash; |
825 | } | 695 | } |
826 | #endif | 696 | #endif |
827 | } | 697 | } |
828 | 698 | ||
829 | static inline void sock_rps_reset_rxhash(struct sock *sk) | ||
830 | { | ||
831 | #ifdef CONFIG_RPS | ||
832 | sock_rps_reset_flow(sk); | ||
833 | sk->sk_rxhash = 0; | ||
834 | #endif | ||
835 | } | ||
836 | |||
837 | #define sk_wait_event(__sk, __timeo, __condition) \ | 699 | #define sk_wait_event(__sk, __timeo, __condition) \ |
838 | ({ int __rc; \ | 700 | ({ int __rc; \ |
839 | release_sock(__sk); \ | 701 | release_sock(__sk); \ |
@@ -851,8 +713,6 @@ extern int sk_stream_wait_memory(struct sock *sk, long *timeo_p); | |||
851 | extern void sk_stream_wait_close(struct sock *sk, long timeo_p); | 713 | extern void sk_stream_wait_close(struct sock *sk, long timeo_p); |
852 | extern int sk_stream_error(struct sock *sk, int flags, int err); | 714 | extern int sk_stream_error(struct sock *sk, int flags, int err); |
853 | extern void sk_stream_kill_queues(struct sock *sk); | 715 | extern void sk_stream_kill_queues(struct sock *sk); |
854 | extern void sk_set_memalloc(struct sock *sk); | ||
855 | extern void sk_clear_memalloc(struct sock *sk); | ||
856 | 716 | ||
857 | extern int sk_wait_data(struct sock *sk, long *timeo); | 717 | extern int sk_wait_data(struct sock *sk, long *timeo); |
858 | 718 | ||
@@ -860,33 +720,32 @@ struct request_sock_ops; | |||
860 | struct timewait_sock_ops; | 720 | struct timewait_sock_ops; |
861 | struct inet_hashinfo; | 721 | struct inet_hashinfo; |
862 | struct raw_hashinfo; | 722 | struct raw_hashinfo; |
863 | struct module; | ||
864 | 723 | ||
865 | /* Networking protocol blocks we attach to sockets. | 724 | /* Networking protocol blocks we attach to sockets. |
866 | * socket layer -> transport layer interface | 725 | * socket layer -> transport layer interface |
867 | * transport -> network interface is defined by struct inet_proto | 726 | * transport -> network interface is defined by struct inet_proto |
868 | */ | 727 | */ |
869 | struct proto { | 728 | struct proto { |
870 | void (*close)(struct sock *sk, | 729 | void (*close)(struct sock *sk, |
871 | long timeout); | 730 | long timeout); |
872 | int (*connect)(struct sock *sk, | 731 | int (*connect)(struct sock *sk, |
873 | struct sockaddr *uaddr, | 732 | struct sockaddr *uaddr, |
874 | int addr_len); | 733 | int addr_len); |
875 | int (*disconnect)(struct sock *sk, int flags); | 734 | int (*disconnect)(struct sock *sk, int flags); |
876 | 735 | ||
877 | struct sock * (*accept)(struct sock *sk, int flags, int *err); | 736 | struct sock * (*accept) (struct sock *sk, int flags, int *err); |
878 | 737 | ||
879 | int (*ioctl)(struct sock *sk, int cmd, | 738 | int (*ioctl)(struct sock *sk, int cmd, |
880 | unsigned long arg); | 739 | unsigned long arg); |
881 | int (*init)(struct sock *sk); | 740 | int (*init)(struct sock *sk); |
882 | void (*destroy)(struct sock *sk); | 741 | void (*destroy)(struct sock *sk); |
883 | void (*shutdown)(struct sock *sk, int how); | 742 | void (*shutdown)(struct sock *sk, int how); |
884 | int (*setsockopt)(struct sock *sk, int level, | 743 | int (*setsockopt)(struct sock *sk, int level, |
885 | int optname, char __user *optval, | 744 | int optname, char __user *optval, |
886 | unsigned int optlen); | 745 | unsigned int optlen); |
887 | int (*getsockopt)(struct sock *sk, int level, | 746 | int (*getsockopt)(struct sock *sk, int level, |
888 | int optname, char __user *optval, | 747 | int optname, char __user *optval, |
889 | int __user *option); | 748 | int __user *option); |
890 | #ifdef CONFIG_COMPAT | 749 | #ifdef CONFIG_COMPAT |
891 | int (*compat_setsockopt)(struct sock *sk, | 750 | int (*compat_setsockopt)(struct sock *sk, |
892 | int level, | 751 | int level, |
@@ -903,19 +762,16 @@ struct proto { | |||
903 | struct msghdr *msg, size_t len); | 762 | struct msghdr *msg, size_t len); |
904 | int (*recvmsg)(struct kiocb *iocb, struct sock *sk, | 763 | int (*recvmsg)(struct kiocb *iocb, struct sock *sk, |
905 | struct msghdr *msg, | 764 | struct msghdr *msg, |
906 | size_t len, int noblock, int flags, | 765 | size_t len, int noblock, int flags, |
907 | int *addr_len); | 766 | int *addr_len); |
908 | int (*sendpage)(struct sock *sk, struct page *page, | 767 | int (*sendpage)(struct sock *sk, struct page *page, |
909 | int offset, size_t size, int flags); | 768 | int offset, size_t size, int flags); |
910 | int (*bind)(struct sock *sk, | 769 | int (*bind)(struct sock *sk, |
911 | struct sockaddr *uaddr, int addr_len); | 770 | struct sockaddr *uaddr, int addr_len); |
912 | 771 | ||
913 | int (*backlog_rcv) (struct sock *sk, | 772 | int (*backlog_rcv) (struct sock *sk, |
914 | struct sk_buff *skb); | 773 | struct sk_buff *skb); |
915 | 774 | ||
916 | void (*release_cb)(struct sock *sk); | ||
917 | void (*mtu_reduced)(struct sock *sk); | ||
918 | |||
919 | /* Keeping track of sk's, looking them up, and port selection methods. */ | 775 | /* Keeping track of sk's, looking them up, and port selection methods. */ |
920 | void (*hash)(struct sock *sk); | 776 | void (*hash)(struct sock *sk); |
921 | void (*unhash)(struct sock *sk); | 777 | void (*unhash)(struct sock *sk); |
@@ -968,62 +824,11 @@ struct proto { | |||
968 | #ifdef SOCK_REFCNT_DEBUG | 824 | #ifdef SOCK_REFCNT_DEBUG |
969 | atomic_t socks; | 825 | atomic_t socks; |
970 | #endif | 826 | #endif |
971 | #ifdef CONFIG_MEMCG_KMEM | ||
972 | /* | ||
973 | * cgroup specific init/deinit functions. Called once for all | ||
974 | * protocols that implement it, from cgroups populate function. | ||
975 | * This function has to setup any files the protocol want to | ||
976 | * appear in the kmem cgroup filesystem. | ||
977 | */ | ||
978 | int (*init_cgroup)(struct mem_cgroup *memcg, | ||
979 | struct cgroup_subsys *ss); | ||
980 | void (*destroy_cgroup)(struct mem_cgroup *memcg); | ||
981 | struct cg_proto *(*proto_cgroup)(struct mem_cgroup *memcg); | ||
982 | #endif | ||
983 | }; | ||
984 | |||
985 | /* | ||
986 | * Bits in struct cg_proto.flags | ||
987 | */ | ||
988 | enum cg_proto_flags { | ||
989 | /* Currently active and new sockets should be assigned to cgroups */ | ||
990 | MEMCG_SOCK_ACTIVE, | ||
991 | /* It was ever activated; we must disarm static keys on destruction */ | ||
992 | MEMCG_SOCK_ACTIVATED, | ||
993 | }; | ||
994 | |||
995 | struct cg_proto { | ||
996 | void (*enter_memory_pressure)(struct sock *sk); | ||
997 | struct res_counter *memory_allocated; /* Current allocated memory. */ | ||
998 | struct percpu_counter *sockets_allocated; /* Current number of sockets. */ | ||
999 | int *memory_pressure; | ||
1000 | long *sysctl_mem; | ||
1001 | unsigned long flags; | ||
1002 | /* | ||
1003 | * memcg field is used to find which memcg we belong directly | ||
1004 | * Each memcg struct can hold more than one cg_proto, so container_of | ||
1005 | * won't really cut. | ||
1006 | * | ||
1007 | * The elegant solution would be having an inverse function to | ||
1008 | * proto_cgroup in struct proto, but that means polluting the structure | ||
1009 | * for everybody, instead of just for memcg users. | ||
1010 | */ | ||
1011 | struct mem_cgroup *memcg; | ||
1012 | }; | 827 | }; |
1013 | 828 | ||
1014 | extern int proto_register(struct proto *prot, int alloc_slab); | 829 | extern int proto_register(struct proto *prot, int alloc_slab); |
1015 | extern void proto_unregister(struct proto *prot); | 830 | extern void proto_unregister(struct proto *prot); |
1016 | 831 | ||
1017 | static inline bool memcg_proto_active(struct cg_proto *cg_proto) | ||
1018 | { | ||
1019 | return test_bit(MEMCG_SOCK_ACTIVE, &cg_proto->flags); | ||
1020 | } | ||
1021 | |||
1022 | static inline bool memcg_proto_activated(struct cg_proto *cg_proto) | ||
1023 | { | ||
1024 | return test_bit(MEMCG_SOCK_ACTIVATED, &cg_proto->flags); | ||
1025 | } | ||
1026 | |||
1027 | #ifdef SOCK_REFCNT_DEBUG | 832 | #ifdef SOCK_REFCNT_DEBUG |
1028 | static inline void sk_refcnt_debug_inc(struct sock *sk) | 833 | static inline void sk_refcnt_debug_inc(struct sock *sk) |
1029 | { | 834 | { |
@@ -1037,7 +842,7 @@ static inline void sk_refcnt_debug_dec(struct sock *sk) | |||
1037 | sk->sk_prot->name, sk, atomic_read(&sk->sk_prot->socks)); | 842 | sk->sk_prot->name, sk, atomic_read(&sk->sk_prot->socks)); |
1038 | } | 843 | } |
1039 | 844 | ||
1040 | inline void sk_refcnt_debug_release(const struct sock *sk) | 845 | static inline void sk_refcnt_debug_release(const struct sock *sk) |
1041 | { | 846 | { |
1042 | if (atomic_read(&sk->sk_refcnt) != 1) | 847 | if (atomic_read(&sk->sk_refcnt) != 1) |
1043 | printk(KERN_DEBUG "Destruction of the %s socket %p delayed, refcnt=%d\n", | 848 | printk(KERN_DEBUG "Destruction of the %s socket %p delayed, refcnt=%d\n", |
@@ -1049,213 +854,13 @@ inline void sk_refcnt_debug_release(const struct sock *sk) | |||
1049 | #define sk_refcnt_debug_release(sk) do { } while (0) | 854 | #define sk_refcnt_debug_release(sk) do { } while (0) |
1050 | #endif /* SOCK_REFCNT_DEBUG */ | 855 | #endif /* SOCK_REFCNT_DEBUG */ |
1051 | 856 | ||
1052 | #if defined(CONFIG_MEMCG_KMEM) && defined(CONFIG_NET) | ||
1053 | extern struct static_key memcg_socket_limit_enabled; | ||
1054 | static inline struct cg_proto *parent_cg_proto(struct proto *proto, | ||
1055 | struct cg_proto *cg_proto) | ||
1056 | { | ||
1057 | return proto->proto_cgroup(parent_mem_cgroup(cg_proto->memcg)); | ||
1058 | } | ||
1059 | #define mem_cgroup_sockets_enabled static_key_false(&memcg_socket_limit_enabled) | ||
1060 | #else | ||
1061 | #define mem_cgroup_sockets_enabled 0 | ||
1062 | static inline struct cg_proto *parent_cg_proto(struct proto *proto, | ||
1063 | struct cg_proto *cg_proto) | ||
1064 | { | ||
1065 | return NULL; | ||
1066 | } | ||
1067 | #endif | ||
1068 | |||
1069 | |||
1070 | static inline bool sk_has_memory_pressure(const struct sock *sk) | ||
1071 | { | ||
1072 | return sk->sk_prot->memory_pressure != NULL; | ||
1073 | } | ||
1074 | |||
1075 | static inline bool sk_under_memory_pressure(const struct sock *sk) | ||
1076 | { | ||
1077 | if (!sk->sk_prot->memory_pressure) | ||
1078 | return false; | ||
1079 | |||
1080 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
1081 | return !!*sk->sk_cgrp->memory_pressure; | ||
1082 | |||
1083 | return !!*sk->sk_prot->memory_pressure; | ||
1084 | } | ||
1085 | |||
1086 | static inline void sk_leave_memory_pressure(struct sock *sk) | ||
1087 | { | ||
1088 | int *memory_pressure = sk->sk_prot->memory_pressure; | ||
1089 | |||
1090 | if (!memory_pressure) | ||
1091 | return; | ||
1092 | |||
1093 | if (*memory_pressure) | ||
1094 | *memory_pressure = 0; | ||
1095 | |||
1096 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
1097 | struct cg_proto *cg_proto = sk->sk_cgrp; | ||
1098 | struct proto *prot = sk->sk_prot; | ||
1099 | |||
1100 | for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) | ||
1101 | if (*cg_proto->memory_pressure) | ||
1102 | *cg_proto->memory_pressure = 0; | ||
1103 | } | ||
1104 | |||
1105 | } | ||
1106 | |||
1107 | static inline void sk_enter_memory_pressure(struct sock *sk) | ||
1108 | { | ||
1109 | if (!sk->sk_prot->enter_memory_pressure) | ||
1110 | return; | ||
1111 | |||
1112 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
1113 | struct cg_proto *cg_proto = sk->sk_cgrp; | ||
1114 | struct proto *prot = sk->sk_prot; | ||
1115 | |||
1116 | for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) | ||
1117 | cg_proto->enter_memory_pressure(sk); | ||
1118 | } | ||
1119 | |||
1120 | sk->sk_prot->enter_memory_pressure(sk); | ||
1121 | } | ||
1122 | |||
1123 | static inline long sk_prot_mem_limits(const struct sock *sk, int index) | ||
1124 | { | ||
1125 | long *prot = sk->sk_prot->sysctl_mem; | ||
1126 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
1127 | prot = sk->sk_cgrp->sysctl_mem; | ||
1128 | return prot[index]; | ||
1129 | } | ||
1130 | |||
1131 | static inline void memcg_memory_allocated_add(struct cg_proto *prot, | ||
1132 | unsigned long amt, | ||
1133 | int *parent_status) | ||
1134 | { | ||
1135 | struct res_counter *fail; | ||
1136 | int ret; | ||
1137 | |||
1138 | ret = res_counter_charge_nofail(prot->memory_allocated, | ||
1139 | amt << PAGE_SHIFT, &fail); | ||
1140 | if (ret < 0) | ||
1141 | *parent_status = OVER_LIMIT; | ||
1142 | } | ||
1143 | |||
1144 | static inline void memcg_memory_allocated_sub(struct cg_proto *prot, | ||
1145 | unsigned long amt) | ||
1146 | { | ||
1147 | res_counter_uncharge(prot->memory_allocated, amt << PAGE_SHIFT); | ||
1148 | } | ||
1149 | |||
1150 | static inline u64 memcg_memory_allocated_read(struct cg_proto *prot) | ||
1151 | { | ||
1152 | u64 ret; | ||
1153 | ret = res_counter_read_u64(prot->memory_allocated, RES_USAGE); | ||
1154 | return ret >> PAGE_SHIFT; | ||
1155 | } | ||
1156 | |||
1157 | static inline long | ||
1158 | sk_memory_allocated(const struct sock *sk) | ||
1159 | { | ||
1160 | struct proto *prot = sk->sk_prot; | ||
1161 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
1162 | return memcg_memory_allocated_read(sk->sk_cgrp); | ||
1163 | |||
1164 | return atomic_long_read(prot->memory_allocated); | ||
1165 | } | ||
1166 | |||
1167 | static inline long | ||
1168 | sk_memory_allocated_add(struct sock *sk, int amt, int *parent_status) | ||
1169 | { | ||
1170 | struct proto *prot = sk->sk_prot; | ||
1171 | |||
1172 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
1173 | memcg_memory_allocated_add(sk->sk_cgrp, amt, parent_status); | ||
1174 | /* update the root cgroup regardless */ | ||
1175 | atomic_long_add_return(amt, prot->memory_allocated); | ||
1176 | return memcg_memory_allocated_read(sk->sk_cgrp); | ||
1177 | } | ||
1178 | |||
1179 | return atomic_long_add_return(amt, prot->memory_allocated); | ||
1180 | } | ||
1181 | |||
1182 | static inline void | ||
1183 | sk_memory_allocated_sub(struct sock *sk, int amt) | ||
1184 | { | ||
1185 | struct proto *prot = sk->sk_prot; | ||
1186 | |||
1187 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
1188 | memcg_memory_allocated_sub(sk->sk_cgrp, amt); | ||
1189 | |||
1190 | atomic_long_sub(amt, prot->memory_allocated); | ||
1191 | } | ||
1192 | |||
1193 | static inline void sk_sockets_allocated_dec(struct sock *sk) | ||
1194 | { | ||
1195 | struct proto *prot = sk->sk_prot; | ||
1196 | |||
1197 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
1198 | struct cg_proto *cg_proto = sk->sk_cgrp; | ||
1199 | |||
1200 | for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) | ||
1201 | percpu_counter_dec(cg_proto->sockets_allocated); | ||
1202 | } | ||
1203 | |||
1204 | percpu_counter_dec(prot->sockets_allocated); | ||
1205 | } | ||
1206 | |||
1207 | static inline void sk_sockets_allocated_inc(struct sock *sk) | ||
1208 | { | ||
1209 | struct proto *prot = sk->sk_prot; | ||
1210 | |||
1211 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) { | ||
1212 | struct cg_proto *cg_proto = sk->sk_cgrp; | ||
1213 | |||
1214 | for (; cg_proto; cg_proto = parent_cg_proto(prot, cg_proto)) | ||
1215 | percpu_counter_inc(cg_proto->sockets_allocated); | ||
1216 | } | ||
1217 | |||
1218 | percpu_counter_inc(prot->sockets_allocated); | ||
1219 | } | ||
1220 | |||
1221 | static inline int | ||
1222 | sk_sockets_allocated_read_positive(struct sock *sk) | ||
1223 | { | ||
1224 | struct proto *prot = sk->sk_prot; | ||
1225 | |||
1226 | if (mem_cgroup_sockets_enabled && sk->sk_cgrp) | ||
1227 | return percpu_counter_read_positive(sk->sk_cgrp->sockets_allocated); | ||
1228 | |||
1229 | return percpu_counter_read_positive(prot->sockets_allocated); | ||
1230 | } | ||
1231 | |||
1232 | static inline int | ||
1233 | proto_sockets_allocated_sum_positive(struct proto *prot) | ||
1234 | { | ||
1235 | return percpu_counter_sum_positive(prot->sockets_allocated); | ||
1236 | } | ||
1237 | |||
1238 | static inline long | ||
1239 | proto_memory_allocated(struct proto *prot) | ||
1240 | { | ||
1241 | return atomic_long_read(prot->memory_allocated); | ||
1242 | } | ||
1243 | |||
1244 | static inline bool | ||
1245 | proto_memory_pressure(struct proto *prot) | ||
1246 | { | ||
1247 | if (!prot->memory_pressure) | ||
1248 | return false; | ||
1249 | return !!*prot->memory_pressure; | ||
1250 | } | ||
1251 | |||
1252 | 857 | ||
1253 | #ifdef CONFIG_PROC_FS | 858 | #ifdef CONFIG_PROC_FS |
1254 | /* Called with local bh disabled */ | 859 | /* Called with local bh disabled */ |
1255 | extern void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc); | 860 | extern void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc); |
1256 | extern int sock_prot_inuse_get(struct net *net, struct proto *proto); | 861 | extern int sock_prot_inuse_get(struct net *net, struct proto *proto); |
1257 | #else | 862 | #else |
1258 | static inline void sock_prot_inuse_add(struct net *net, struct proto *prot, | 863 | static void inline sock_prot_inuse_add(struct net *net, struct proto *prot, |
1259 | int inc) | 864 | int inc) |
1260 | { | 865 | { |
1261 | } | 866 | } |
@@ -1342,28 +947,26 @@ static inline int sk_mem_pages(int amt) | |||
1342 | return (amt + SK_MEM_QUANTUM - 1) >> SK_MEM_QUANTUM_SHIFT; | 947 | return (amt + SK_MEM_QUANTUM - 1) >> SK_MEM_QUANTUM_SHIFT; |
1343 | } | 948 | } |
1344 | 949 | ||
1345 | static inline bool sk_has_account(struct sock *sk) | 950 | static inline int sk_has_account(struct sock *sk) |
1346 | { | 951 | { |
1347 | /* return true if protocol supports memory accounting */ | 952 | /* return true if protocol supports memory accounting */ |
1348 | return !!sk->sk_prot->memory_allocated; | 953 | return !!sk->sk_prot->memory_allocated; |
1349 | } | 954 | } |
1350 | 955 | ||
1351 | static inline bool sk_wmem_schedule(struct sock *sk, int size) | 956 | static inline int sk_wmem_schedule(struct sock *sk, int size) |
1352 | { | 957 | { |
1353 | if (!sk_has_account(sk)) | 958 | if (!sk_has_account(sk)) |
1354 | return true; | 959 | return 1; |
1355 | return size <= sk->sk_forward_alloc || | 960 | return size <= sk->sk_forward_alloc || |
1356 | __sk_mem_schedule(sk, size, SK_MEM_SEND); | 961 | __sk_mem_schedule(sk, size, SK_MEM_SEND); |
1357 | } | 962 | } |
1358 | 963 | ||
1359 | static inline bool | 964 | static inline int sk_rmem_schedule(struct sock *sk, int size) |
1360 | sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size) | ||
1361 | { | 965 | { |
1362 | if (!sk_has_account(sk)) | 966 | if (!sk_has_account(sk)) |
1363 | return true; | 967 | return 1; |
1364 | return size<= sk->sk_forward_alloc || | 968 | return size <= sk->sk_forward_alloc || |
1365 | __sk_mem_schedule(sk, size, SK_MEM_RECV) || | 969 | __sk_mem_schedule(sk, size, SK_MEM_RECV); |
1366 | skb_pfmemalloc(skb); | ||
1367 | } | 970 | } |
1368 | 971 | ||
1369 | static inline void sk_mem_reclaim(struct sock *sk) | 972 | static inline void sk_mem_reclaim(struct sock *sk) |
@@ -1426,7 +1029,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb) | |||
1426 | * Mark both the sk_lock and the sk_lock.slock as a | 1029 | * Mark both the sk_lock and the sk_lock.slock as a |
1427 | * per-address-family lock class. | 1030 | * per-address-family lock class. |
1428 | */ | 1031 | */ |
1429 | #define sock_lock_init_class_and_name(sk, sname, skey, name, key) \ | 1032 | #define sock_lock_init_class_and_name(sk, sname, skey, name, key) \ |
1430 | do { \ | 1033 | do { \ |
1431 | sk->sk_lock.owned = 0; \ | 1034 | sk->sk_lock.owned = 0; \ |
1432 | init_waitqueue_head(&sk->sk_lock.wq); \ | 1035 | init_waitqueue_head(&sk->sk_lock.wq); \ |
@@ -1434,7 +1037,7 @@ do { \ | |||
1434 | debug_check_no_locks_freed((void *)&(sk)->sk_lock, \ | 1037 | debug_check_no_locks_freed((void *)&(sk)->sk_lock, \ |
1435 | sizeof((sk)->sk_lock)); \ | 1038 | sizeof((sk)->sk_lock)); \ |
1436 | lockdep_set_class_and_name(&(sk)->sk_lock.slock, \ | 1039 | lockdep_set_class_and_name(&(sk)->sk_lock.slock, \ |
1437 | (skey), (sname)); \ | 1040 | (skey), (sname)); \ |
1438 | lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \ | 1041 | lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0); \ |
1439 | } while (0) | 1042 | } while (0) |
1440 | 1043 | ||
@@ -1477,8 +1080,8 @@ extern struct sock *sk_alloc(struct net *net, int family, | |||
1477 | struct proto *prot); | 1080 | struct proto *prot); |
1478 | extern void sk_free(struct sock *sk); | 1081 | extern void sk_free(struct sock *sk); |
1479 | extern void sk_release_kernel(struct sock *sk); | 1082 | extern void sk_release_kernel(struct sock *sk); |
1480 | extern struct sock *sk_clone_lock(const struct sock *sk, | 1083 | extern struct sock *sk_clone(const struct sock *sk, |
1481 | const gfp_t priority); | 1084 | const gfp_t priority); |
1482 | 1085 | ||
1483 | extern struct sk_buff *sock_wmalloc(struct sock *sk, | 1086 | extern struct sk_buff *sock_wmalloc(struct sock *sk, |
1484 | unsigned long size, int force, | 1087 | unsigned long size, int force, |
@@ -1488,20 +1091,19 @@ extern struct sk_buff *sock_rmalloc(struct sock *sk, | |||
1488 | gfp_t priority); | 1091 | gfp_t priority); |
1489 | extern void sock_wfree(struct sk_buff *skb); | 1092 | extern void sock_wfree(struct sk_buff *skb); |
1490 | extern void sock_rfree(struct sk_buff *skb); | 1093 | extern void sock_rfree(struct sk_buff *skb); |
1491 | extern void sock_edemux(struct sk_buff *skb); | ||
1492 | 1094 | ||
1493 | extern int sock_setsockopt(struct socket *sock, int level, | 1095 | extern int sock_setsockopt(struct socket *sock, int level, |
1494 | int op, char __user *optval, | 1096 | int op, char __user *optval, |
1495 | unsigned int optlen); | 1097 | unsigned int optlen); |
1496 | 1098 | ||
1497 | extern int sock_getsockopt(struct socket *sock, int level, | 1099 | extern int sock_getsockopt(struct socket *sock, int level, |
1498 | int op, char __user *optval, | 1100 | int op, char __user *optval, |
1499 | int __user *optlen); | 1101 | int __user *optlen); |
1500 | extern struct sk_buff *sock_alloc_send_skb(struct sock *sk, | 1102 | extern struct sk_buff *sock_alloc_send_skb(struct sock *sk, |
1501 | unsigned long size, | 1103 | unsigned long size, |
1502 | int noblock, | 1104 | int noblock, |
1503 | int *errcode); | 1105 | int *errcode); |
1504 | extern struct sk_buff *sock_alloc_send_pskb(struct sock *sk, | 1106 | extern struct sk_buff *sock_alloc_send_pskb(struct sock *sk, |
1505 | unsigned long header_len, | 1107 | unsigned long header_len, |
1506 | unsigned long data_len, | 1108 | unsigned long data_len, |
1507 | int noblock, | 1109 | int noblock, |
@@ -1511,11 +1113,19 @@ extern void *sock_kmalloc(struct sock *sk, int size, | |||
1511 | extern void sock_kfree_s(struct sock *sk, void *mem, int size); | 1113 | extern void sock_kfree_s(struct sock *sk, void *mem, int size); |
1512 | extern void sk_send_sigurg(struct sock *sk); | 1114 | extern void sk_send_sigurg(struct sock *sk); |
1513 | 1115 | ||
1116 | #ifdef CONFIG_CGROUPS | ||
1117 | extern void sock_update_classid(struct sock *sk); | ||
1118 | #else | ||
1119 | static inline void sock_update_classid(struct sock *sk) | ||
1120 | { | ||
1121 | } | ||
1122 | #endif | ||
1123 | |||
1514 | /* | 1124 | /* |
1515 | * Functions to fill in entries in struct proto_ops when a protocol | 1125 | * Functions to fill in entries in struct proto_ops when a protocol |
1516 | * does not implement a particular function. | 1126 | * does not implement a particular function. |
1517 | */ | 1127 | */ |
1518 | extern int sock_no_bind(struct socket *, | 1128 | extern int sock_no_bind(struct socket *, |
1519 | struct sockaddr *, int); | 1129 | struct sockaddr *, int); |
1520 | extern int sock_no_connect(struct socket *, | 1130 | extern int sock_no_connect(struct socket *, |
1521 | struct sockaddr *, int, int); | 1131 | struct sockaddr *, int, int); |
@@ -1544,7 +1154,7 @@ extern int sock_no_mmap(struct file *file, | |||
1544 | struct vm_area_struct *vma); | 1154 | struct vm_area_struct *vma); |
1545 | extern ssize_t sock_no_sendpage(struct socket *sock, | 1155 | extern ssize_t sock_no_sendpage(struct socket *sock, |
1546 | struct page *page, | 1156 | struct page *page, |
1547 | int offset, size_t size, | 1157 | int offset, size_t size, |
1548 | int flags); | 1158 | int flags); |
1549 | 1159 | ||
1550 | /* | 1160 | /* |
@@ -1567,7 +1177,7 @@ extern void sk_common_release(struct sock *sk); | |||
1567 | /* | 1177 | /* |
1568 | * Default socket callbacks and setup code | 1178 | * Default socket callbacks and setup code |
1569 | */ | 1179 | */ |
1570 | 1180 | ||
1571 | /* Initialise core socket variables */ | 1181 | /* Initialise core socket variables */ |
1572 | extern void sock_init_data(struct socket *sock, struct sock *sk); | 1182 | extern void sock_init_data(struct socket *sock, struct sock *sk); |
1573 | 1183 | ||
@@ -1687,7 +1297,7 @@ static inline void sock_graft(struct sock *sk, struct socket *parent) | |||
1687 | write_unlock_bh(&sk->sk_callback_lock); | 1297 | write_unlock_bh(&sk->sk_callback_lock); |
1688 | } | 1298 | } |
1689 | 1299 | ||
1690 | extern kuid_t sock_i_uid(struct sock *sk); | 1300 | extern int sock_i_uid(struct sock *sk); |
1691 | extern unsigned long sock_i_ino(struct sock *sk); | 1301 | extern unsigned long sock_i_ino(struct sock *sk); |
1692 | 1302 | ||
1693 | static inline struct dst_entry * | 1303 | static inline struct dst_entry * |
@@ -1767,14 +1377,14 @@ extern struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie); | |||
1767 | 1377 | ||
1768 | extern struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie); | 1378 | extern struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie); |
1769 | 1379 | ||
1770 | static inline bool sk_can_gso(const struct sock *sk) | 1380 | static inline int sk_can_gso(const struct sock *sk) |
1771 | { | 1381 | { |
1772 | return net_gso_ok(sk->sk_route_caps, sk->sk_gso_type); | 1382 | return net_gso_ok(sk->sk_route_caps, sk->sk_gso_type); |
1773 | } | 1383 | } |
1774 | 1384 | ||
1775 | extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); | 1385 | extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); |
1776 | 1386 | ||
1777 | static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags) | 1387 | static inline void sk_nocaps_add(struct sock *sk, int flags) |
1778 | { | 1388 | { |
1779 | sk->sk_route_nocaps |= flags; | 1389 | sk->sk_route_nocaps |= flags; |
1780 | sk->sk_route_caps &= ~flags; | 1390 | sk->sk_route_caps &= ~flags; |
@@ -1884,7 +1494,7 @@ static inline int sk_rmem_alloc_get(const struct sock *sk) | |||
1884 | * | 1494 | * |
1885 | * Returns true if socket has write or read allocations | 1495 | * Returns true if socket has write or read allocations |
1886 | */ | 1496 | */ |
1887 | static inline bool sk_has_allocations(const struct sock *sk) | 1497 | static inline int sk_has_allocations(const struct sock *sk) |
1888 | { | 1498 | { |
1889 | return sk_wmem_alloc_get(sk) || sk_rmem_alloc_get(sk); | 1499 | return sk_wmem_alloc_get(sk) || sk_rmem_alloc_get(sk); |
1890 | } | 1500 | } |
@@ -1923,7 +1533,9 @@ static inline bool sk_has_allocations(const struct sock *sk) | |||
1923 | */ | 1533 | */ |
1924 | static inline bool wq_has_sleeper(struct socket_wq *wq) | 1534 | static inline bool wq_has_sleeper(struct socket_wq *wq) |
1925 | { | 1535 | { |
1926 | /* We need to be sure we are in sync with the | 1536 | |
1537 | /* | ||
1538 | * We need to be sure we are in sync with the | ||
1927 | * add_wait_queue modifications to the wait queue. | 1539 | * add_wait_queue modifications to the wait queue. |
1928 | * | 1540 | * |
1929 | * This memory barrier is paired in the sock_poll_wait. | 1541 | * This memory barrier is paired in the sock_poll_wait. |
@@ -1943,23 +1555,24 @@ static inline bool wq_has_sleeper(struct socket_wq *wq) | |||
1943 | static inline void sock_poll_wait(struct file *filp, | 1555 | static inline void sock_poll_wait(struct file *filp, |
1944 | wait_queue_head_t *wait_address, poll_table *p) | 1556 | wait_queue_head_t *wait_address, poll_table *p) |
1945 | { | 1557 | { |
1946 | if (!poll_does_not_wait(p) && wait_address) { | 1558 | if (p && wait_address) { |
1947 | poll_wait(filp, wait_address, p); | 1559 | poll_wait(filp, wait_address, p); |
1948 | /* We need to be sure we are in sync with the | 1560 | /* |
1561 | * We need to be sure we are in sync with the | ||
1949 | * socket flags modification. | 1562 | * socket flags modification. |
1950 | * | 1563 | * |
1951 | * This memory barrier is paired in the wq_has_sleeper. | 1564 | * This memory barrier is paired in the wq_has_sleeper. |
1952 | */ | 1565 | */ |
1953 | smp_mb(); | 1566 | smp_mb(); |
1954 | } | 1567 | } |
1955 | } | 1568 | } |
1956 | 1569 | ||
1957 | /* | 1570 | /* |
1958 | * Queue a received datagram if it will fit. Stream and sequenced | 1571 | * Queue a received datagram if it will fit. Stream and sequenced |
1959 | * protocols can't normally use this as they need to fit buffers in | 1572 | * protocols can't normally use this as they need to fit buffers in |
1960 | * and play with them. | 1573 | * and play with them. |
1961 | * | 1574 | * |
1962 | * Inlined as it's very short and called for pretty much every | 1575 | * Inlined as it's very short and called for pretty much every |
1963 | * packet ever received. | 1576 | * packet ever received. |
1964 | */ | 1577 | */ |
1965 | 1578 | ||
@@ -1985,10 +1598,10 @@ static inline void skb_set_owner_r(struct sk_buff *skb, struct sock *sk) | |||
1985 | sk_mem_charge(sk, skb->truesize); | 1598 | sk_mem_charge(sk, skb->truesize); |
1986 | } | 1599 | } |
1987 | 1600 | ||
1988 | extern void sk_reset_timer(struct sock *sk, struct timer_list *timer, | 1601 | extern void sk_reset_timer(struct sock *sk, struct timer_list* timer, |
1989 | unsigned long expires); | 1602 | unsigned long expires); |
1990 | 1603 | ||
1991 | extern void sk_stop_timer(struct sock *sk, struct timer_list *timer); | 1604 | extern void sk_stop_timer(struct sock *sk, struct timer_list* timer); |
1992 | 1605 | ||
1993 | extern int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); | 1606 | extern int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb); |
1994 | 1607 | ||
@@ -1997,7 +1610,7 @@ extern int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb); | |||
1997 | /* | 1610 | /* |
1998 | * Recover an error report and clear atomically | 1611 | * Recover an error report and clear atomically |
1999 | */ | 1612 | */ |
2000 | 1613 | ||
2001 | static inline int sock_error(struct sock *sk) | 1614 | static inline int sock_error(struct sock *sk) |
2002 | { | 1615 | { |
2003 | int err; | 1616 | int err; |
@@ -2013,7 +1626,7 @@ static inline unsigned long sock_wspace(struct sock *sk) | |||
2013 | 1626 | ||
2014 | if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { | 1627 | if (!(sk->sk_shutdown & SEND_SHUTDOWN)) { |
2015 | amt = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); | 1628 | amt = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc); |
2016 | if (amt < 0) | 1629 | if (amt < 0) |
2017 | amt = 0; | 1630 | amt = 0; |
2018 | } | 1631 | } |
2019 | return amt; | 1632 | return amt; |
@@ -2042,27 +1655,22 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk) | |||
2042 | 1655 | ||
2043 | struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp); | 1656 | struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp); |
2044 | 1657 | ||
2045 | /** | 1658 | static inline struct page *sk_stream_alloc_page(struct sock *sk) |
2046 | * sk_page_frag - return an appropriate page_frag | ||
2047 | * @sk: socket | ||
2048 | * | ||
2049 | * If socket allocation mode allows current thread to sleep, it means its | ||
2050 | * safe to use the per task page_frag instead of the per socket one. | ||
2051 | */ | ||
2052 | static inline struct page_frag *sk_page_frag(struct sock *sk) | ||
2053 | { | 1659 | { |
2054 | if (sk->sk_allocation & __GFP_WAIT) | 1660 | struct page *page = NULL; |
2055 | return ¤t->task_frag; | ||
2056 | 1661 | ||
2057 | return &sk->sk_frag; | 1662 | page = alloc_pages(sk->sk_allocation, 0); |
1663 | if (!page) { | ||
1664 | sk->sk_prot->enter_memory_pressure(sk); | ||
1665 | sk_stream_moderate_sndbuf(sk); | ||
1666 | } | ||
1667 | return page; | ||
2058 | } | 1668 | } |
2059 | 1669 | ||
2060 | extern bool sk_page_frag_refill(struct sock *sk, struct page_frag *pfrag); | ||
2061 | |||
2062 | /* | 1670 | /* |
2063 | * Default write policy as shown to user space via poll/select/SIGIO | 1671 | * Default write policy as shown to user space via poll/select/SIGIO |
2064 | */ | 1672 | */ |
2065 | static inline bool sock_writeable(const struct sock *sk) | 1673 | static inline int sock_writeable(const struct sock *sk) |
2066 | { | 1674 | { |
2067 | return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf >> 1); | 1675 | return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf >> 1); |
2068 | } | 1676 | } |
@@ -2072,12 +1680,12 @@ static inline gfp_t gfp_any(void) | |||
2072 | return in_softirq() ? GFP_ATOMIC : GFP_KERNEL; | 1680 | return in_softirq() ? GFP_ATOMIC : GFP_KERNEL; |
2073 | } | 1681 | } |
2074 | 1682 | ||
2075 | static inline long sock_rcvtimeo(const struct sock *sk, bool noblock) | 1683 | static inline long sock_rcvtimeo(const struct sock *sk, int noblock) |
2076 | { | 1684 | { |
2077 | return noblock ? 0 : sk->sk_rcvtimeo; | 1685 | return noblock ? 0 : sk->sk_rcvtimeo; |
2078 | } | 1686 | } |
2079 | 1687 | ||
2080 | static inline long sock_sndtimeo(const struct sock *sk, bool noblock) | 1688 | static inline long sock_sndtimeo(const struct sock *sk, int noblock) |
2081 | { | 1689 | { |
2082 | return noblock ? 0 : sk->sk_sndtimeo; | 1690 | return noblock ? 0 : sk->sk_sndtimeo; |
2083 | } | 1691 | } |
@@ -2097,10 +1705,8 @@ static inline int sock_intr_errno(long timeo) | |||
2097 | 1705 | ||
2098 | extern void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, | 1706 | extern void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk, |
2099 | struct sk_buff *skb); | 1707 | struct sk_buff *skb); |
2100 | extern void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk, | ||
2101 | struct sk_buff *skb); | ||
2102 | 1708 | ||
2103 | static inline void | 1709 | static __inline__ void |
2104 | sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) | 1710 | sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) |
2105 | { | 1711 | { |
2106 | ktime_t kt = skb->tstamp; | 1712 | ktime_t kt = skb->tstamp; |
@@ -2126,9 +1732,6 @@ sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb) | |||
2126 | __sock_recv_timestamp(msg, sk, skb); | 1732 | __sock_recv_timestamp(msg, sk, skb); |
2127 | else | 1733 | else |
2128 | sk->sk_stamp = kt; | 1734 | sk->sk_stamp = kt; |
2129 | |||
2130 | if (sock_flag(sk, SOCK_WIFI_STATUS) && skb->wifi_acked_valid) | ||
2131 | __sock_recv_wifi_status(msg, sk, skb); | ||
2132 | } | 1735 | } |
2133 | 1736 | ||
2134 | extern void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, | 1737 | extern void __sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, |
@@ -2141,7 +1744,7 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk, | |||
2141 | (1UL << SOCK_RCVTSTAMP) | \ | 1744 | (1UL << SOCK_RCVTSTAMP) | \ |
2142 | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE) | \ | 1745 | (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE) | \ |
2143 | (1UL << SOCK_TIMESTAMPING_SOFTWARE) | \ | 1746 | (1UL << SOCK_TIMESTAMPING_SOFTWARE) | \ |
2144 | (1UL << SOCK_TIMESTAMPING_RAW_HARDWARE) | \ | 1747 | (1UL << SOCK_TIMESTAMPING_RAW_HARDWARE) | \ |
2145 | (1UL << SOCK_TIMESTAMPING_SYS_HARDWARE)) | 1748 | (1UL << SOCK_TIMESTAMPING_SYS_HARDWARE)) |
2146 | 1749 | ||
2147 | if (sk->sk_flags & FLAGS_TS_OR_DROPS) | 1750 | if (sk->sk_flags & FLAGS_TS_OR_DROPS) |
@@ -2170,7 +1773,7 @@ extern int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags); | |||
2170 | * locked so that the sk_buff queue operation is ok. | 1773 | * locked so that the sk_buff queue operation is ok. |
2171 | */ | 1774 | */ |
2172 | #ifdef CONFIG_NET_DMA | 1775 | #ifdef CONFIG_NET_DMA |
2173 | static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, bool copied_early) | 1776 | static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early) |
2174 | { | 1777 | { |
2175 | __skb_unlink(skb, &sk->sk_receive_queue); | 1778 | __skb_unlink(skb, &sk->sk_receive_queue); |
2176 | if (!copied_early) | 1779 | if (!copied_early) |
@@ -2179,7 +1782,7 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, bool copied_ | |||
2179 | __skb_queue_tail(&sk->sk_async_wait_queue, skb); | 1782 | __skb_queue_tail(&sk->sk_async_wait_queue, skb); |
2180 | } | 1783 | } |
2181 | #else | 1784 | #else |
2182 | static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, bool copied_early) | 1785 | static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early) |
2183 | { | 1786 | { |
2184 | __skb_unlink(skb, &sk->sk_receive_queue); | 1787 | __skb_unlink(skb, &sk->sk_receive_queue); |
2185 | __kfree_skb(skb); | 1788 | __kfree_skb(skb); |
@@ -2212,7 +1815,7 @@ static inline void sk_change_net(struct sock *sk, struct net *net) | |||
2212 | 1815 | ||
2213 | static inline struct sock *skb_steal_sock(struct sk_buff *skb) | 1816 | static inline struct sock *skb_steal_sock(struct sk_buff *skb) |
2214 | { | 1817 | { |
2215 | if (skb->sk) { | 1818 | if (unlikely(skb->sk)) { |
2216 | struct sock *sk = skb->sk; | 1819 | struct sock *sk = skb->sk; |
2217 | 1820 | ||
2218 | skb->destructor = NULL; | 1821 | skb->destructor = NULL; |
@@ -2226,8 +1829,8 @@ extern void sock_enable_timestamp(struct sock *sk, int flag); | |||
2226 | extern int sock_get_timestamp(struct sock *, struct timeval __user *); | 1829 | extern int sock_get_timestamp(struct sock *, struct timeval __user *); |
2227 | extern int sock_get_timestampns(struct sock *, struct timespec __user *); | 1830 | extern int sock_get_timestampns(struct sock *, struct timespec __user *); |
2228 | 1831 | ||
2229 | /* | 1832 | /* |
2230 | * Enable debug/info messages | 1833 | * Enable debug/info messages |
2231 | */ | 1834 | */ |
2232 | extern int net_msg_warn; | 1835 | extern int net_msg_warn; |
2233 | #define NETDEBUG(fmt, args...) \ | 1836 | #define NETDEBUG(fmt, args...) \ |
@@ -2239,6 +1842,8 @@ extern int net_msg_warn; | |||
2239 | extern __u32 sysctl_wmem_max; | 1842 | extern __u32 sysctl_wmem_max; |
2240 | extern __u32 sysctl_rmem_max; | 1843 | extern __u32 sysctl_rmem_max; |
2241 | 1844 | ||
1845 | extern void sk_init(void); | ||
1846 | |||
2242 | extern int sysctl_optmem_max; | 1847 | extern int sysctl_optmem_max; |
2243 | 1848 | ||
2244 | extern __u32 sysctl_wmem_default; | 1849 | extern __u32 sysctl_wmem_default; |
diff --git a/include/net/tcp.h b/include/net/tcp.h index aed42c78515..4fcd77af405 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -18,11 +18,11 @@ | |||
18 | #ifndef _TCP_H | 18 | #ifndef _TCP_H |
19 | #define _TCP_H | 19 | #define _TCP_H |
20 | 20 | ||
21 | #define TCP_DEBUG 1 | ||
21 | #define FASTRETRANS_DEBUG 1 | 22 | #define FASTRETRANS_DEBUG 1 |
22 | 23 | ||
23 | #include <linux/list.h> | 24 | #include <linux/list.h> |
24 | #include <linux/tcp.h> | 25 | #include <linux/tcp.h> |
25 | #include <linux/bug.h> | ||
26 | #include <linux/slab.h> | 26 | #include <linux/slab.h> |
27 | #include <linux/cache.h> | 27 | #include <linux/cache.h> |
28 | #include <linux/percpu.h> | 28 | #include <linux/percpu.h> |
@@ -45,7 +45,6 @@ | |||
45 | #include <net/dst.h> | 45 | #include <net/dst.h> |
46 | 46 | ||
47 | #include <linux/seq_file.h> | 47 | #include <linux/seq_file.h> |
48 | #include <linux/memcontrol.h> | ||
49 | 48 | ||
50 | extern struct inet_hashinfo tcp_hashinfo; | 49 | extern struct inet_hashinfo tcp_hashinfo; |
51 | 50 | ||
@@ -98,21 +97,11 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
98 | * 15 is ~13-30min depending on RTO. | 97 | * 15 is ~13-30min depending on RTO. |
99 | */ | 98 | */ |
100 | 99 | ||
101 | #define TCP_SYN_RETRIES 6 /* This is how many retries are done | 100 | #define TCP_SYN_RETRIES 5 /* number of times to retry active opening a |
102 | * when active opening a connection. | 101 | * connection: ~180sec is RFC minimum */ |
103 | * RFC1122 says the minimum retry MUST | ||
104 | * be at least 180secs. Nevertheless | ||
105 | * this value is corresponding to | ||
106 | * 63secs of retransmission with the | ||
107 | * current initial RTO. | ||
108 | */ | ||
109 | 102 | ||
110 | #define TCP_SYNACK_RETRIES 5 /* This is how may retries are done | 103 | #define TCP_SYNACK_RETRIES 5 /* number of times to retry passive opening a |
111 | * when passive opening a connection. | 104 | * connection: ~180sec is RFC minimum */ |
112 | * This is corresponding to 31secs of | ||
113 | * retransmission with the current | ||
114 | * initial RTO. | ||
115 | */ | ||
116 | 105 | ||
117 | #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 |
118 | * state, about 60 seconds */ | 107 | * state, about 60 seconds */ |
@@ -133,7 +122,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
133 | #endif | 122 | #endif |
134 | #define TCP_RTO_MAX ((unsigned)(120*HZ)) | 123 | #define TCP_RTO_MAX ((unsigned)(120*HZ)) |
135 | #define TCP_RTO_MIN ((unsigned)(HZ/5)) | 124 | #define TCP_RTO_MIN ((unsigned)(HZ/5)) |
136 | #define TCP_TIMEOUT_INIT ((unsigned)(1*HZ)) /* RFC6298 2.1 initial RTO value */ | 125 | #define TCP_TIMEOUT_INIT ((unsigned)(1*HZ)) /* RFC2988bis initial RTO value */ |
137 | #define TCP_TIMEOUT_FALLBACK ((unsigned)(3*HZ)) /* RFC 1122 initial RTO value, now | 126 | #define TCP_TIMEOUT_FALLBACK ((unsigned)(3*HZ)) /* RFC 1122 initial RTO value, now |
138 | * used as a fallback RTO for the | 127 | * used as a fallback RTO for the |
139 | * initial data transmission if no | 128 | * initial data transmission if no |
@@ -180,11 +169,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
180 | #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ | 169 | #define TCPOPT_TIMESTAMP 8 /* Better RTT estimations/PAWS */ |
181 | #define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */ | 170 | #define TCPOPT_MD5SIG 19 /* MD5 Signature (RFC2385) */ |
182 | #define TCPOPT_COOKIE 253 /* Cookie extension (experimental) */ | 171 | #define TCPOPT_COOKIE 253 /* Cookie extension (experimental) */ |
183 | #define TCPOPT_EXP 254 /* Experimental */ | ||
184 | /* Magic number to be after the option value for sharing TCP | ||
185 | * experimental options. See draft-ietf-tcpm-experimental-options-00.txt | ||
186 | */ | ||
187 | #define TCPOPT_FASTOPEN_MAGIC 0xF989 | ||
188 | 172 | ||
189 | /* | 173 | /* |
190 | * TCP option lengths | 174 | * TCP option lengths |
@@ -195,7 +179,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
195 | #define TCPOLEN_SACK_PERM 2 | 179 | #define TCPOLEN_SACK_PERM 2 |
196 | #define TCPOLEN_TIMESTAMP 10 | 180 | #define TCPOLEN_TIMESTAMP 10 |
197 | #define TCPOLEN_MD5SIG 18 | 181 | #define TCPOLEN_MD5SIG 18 |
198 | #define TCPOLEN_EXP_FASTOPEN_BASE 4 | ||
199 | #define TCPOLEN_COOKIE_BASE 2 /* Cookie-less header extension */ | 182 | #define TCPOLEN_COOKIE_BASE 2 /* Cookie-less header extension */ |
200 | #define TCPOLEN_COOKIE_PAIR 3 /* Cookie pair header extension */ | 183 | #define TCPOLEN_COOKIE_PAIR 3 /* Cookie pair header extension */ |
201 | #define TCPOLEN_COOKIE_MIN (TCPOLEN_COOKIE_BASE+TCP_COOKIE_MIN) | 184 | #define TCPOLEN_COOKIE_MIN (TCPOLEN_COOKIE_BASE+TCP_COOKIE_MIN) |
@@ -222,26 +205,6 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
222 | /* TCP initial congestion window as per draft-hkchu-tcpm-initcwnd-01 */ | 205 | /* TCP initial congestion window as per draft-hkchu-tcpm-initcwnd-01 */ |
223 | #define TCP_INIT_CWND 10 | 206 | #define TCP_INIT_CWND 10 |
224 | 207 | ||
225 | /* Bit Flags for sysctl_tcp_fastopen */ | ||
226 | #define TFO_CLIENT_ENABLE 1 | ||
227 | #define TFO_SERVER_ENABLE 2 | ||
228 | #define TFO_CLIENT_NO_COOKIE 4 /* Data in SYN w/o cookie option */ | ||
229 | |||
230 | /* Process SYN data but skip cookie validation */ | ||
231 | #define TFO_SERVER_COOKIE_NOT_CHKED 0x100 | ||
232 | /* Accept SYN data w/o any cookie option */ | ||
233 | #define TFO_SERVER_COOKIE_NOT_REQD 0x200 | ||
234 | |||
235 | /* Force enable TFO on all listeners, i.e., not requiring the | ||
236 | * TCP_FASTOPEN socket option. SOCKOPT1/2 determine how to set max_qlen. | ||
237 | */ | ||
238 | #define TFO_SERVER_WO_SOCKOPT1 0x400 | ||
239 | #define TFO_SERVER_WO_SOCKOPT2 0x800 | ||
240 | /* Always create TFO child sockets on a TFO listener even when | ||
241 | * cookie/data not present. (For testing purpose!) | ||
242 | */ | ||
243 | #define TFO_SERVER_ALWAYS 0x1000 | ||
244 | |||
245 | extern struct inet_timewait_death_row tcp_death_row; | 208 | extern struct inet_timewait_death_row tcp_death_row; |
246 | 209 | ||
247 | /* sysctl variables for tcp */ | 210 | /* sysctl variables for tcp */ |
@@ -258,7 +221,6 @@ extern int sysctl_tcp_retries1; | |||
258 | extern int sysctl_tcp_retries2; | 221 | extern int sysctl_tcp_retries2; |
259 | extern int sysctl_tcp_orphan_retries; | 222 | extern int sysctl_tcp_orphan_retries; |
260 | extern int sysctl_tcp_syncookies; | 223 | extern int sysctl_tcp_syncookies; |
261 | extern int sysctl_tcp_fastopen; | ||
262 | extern int sysctl_tcp_retrans_collapse; | 224 | extern int sysctl_tcp_retrans_collapse; |
263 | extern int sysctl_tcp_stdurg; | 225 | extern int sysctl_tcp_stdurg; |
264 | extern int sysctl_tcp_rfc1337; | 226 | extern int sysctl_tcp_rfc1337; |
@@ -268,6 +230,7 @@ extern int sysctl_tcp_fack; | |||
268 | extern int sysctl_tcp_reordering; | 230 | extern int sysctl_tcp_reordering; |
269 | extern int sysctl_tcp_ecn; | 231 | extern int sysctl_tcp_ecn; |
270 | extern int sysctl_tcp_dsack; | 232 | extern int sysctl_tcp_dsack; |
233 | extern long sysctl_tcp_mem[3]; | ||
271 | extern int sysctl_tcp_wmem[3]; | 234 | extern int sysctl_tcp_wmem[3]; |
272 | extern int sysctl_tcp_rmem[3]; | 235 | extern int sysctl_tcp_rmem[3]; |
273 | extern int sysctl_tcp_app_win; | 236 | extern int sysctl_tcp_app_win; |
@@ -289,9 +252,6 @@ extern int sysctl_tcp_max_ssthresh; | |||
289 | extern int sysctl_tcp_cookie_size; | 252 | extern int sysctl_tcp_cookie_size; |
290 | extern int sysctl_tcp_thin_linear_timeouts; | 253 | extern int sysctl_tcp_thin_linear_timeouts; |
291 | extern int sysctl_tcp_thin_dupack; | 254 | extern int sysctl_tcp_thin_dupack; |
292 | extern int sysctl_tcp_early_retrans; | ||
293 | extern int sysctl_tcp_limit_output_bytes; | ||
294 | extern int sysctl_tcp_challenge_ack_limit; | ||
295 | 255 | ||
296 | extern atomic_long_t tcp_memory_allocated; | 256 | extern atomic_long_t tcp_memory_allocated; |
297 | extern struct percpu_counter tcp_sockets_allocated; | 257 | extern struct percpu_counter tcp_sockets_allocated; |
@@ -302,26 +262,18 @@ extern int tcp_memory_pressure; | |||
302 | * and worry about wraparound (automatic with unsigned arithmetic). | 262 | * and worry about wraparound (automatic with unsigned arithmetic). |
303 | */ | 263 | */ |
304 | 264 | ||
305 | static inline bool before(__u32 seq1, __u32 seq2) | 265 | static inline int before(__u32 seq1, __u32 seq2) |
306 | { | 266 | { |
307 | return (__s32)(seq1-seq2) < 0; | 267 | return (__s32)(seq1-seq2) < 0; |
308 | } | 268 | } |
309 | #define after(seq2, seq1) before(seq1, seq2) | 269 | #define after(seq2, seq1) before(seq1, seq2) |
310 | 270 | ||
311 | /* is s2<=s1<=s3 ? */ | 271 | /* is s2<=s1<=s3 ? */ |
312 | static inline bool between(__u32 seq1, __u32 seq2, __u32 seq3) | 272 | static inline int between(__u32 seq1, __u32 seq2, __u32 seq3) |
313 | { | 273 | { |
314 | return seq3 - seq2 >= seq1 - seq2; | 274 | return seq3 - seq2 >= seq1 - seq2; |
315 | } | 275 | } |
316 | 276 | ||
317 | static inline bool tcp_out_of_memory(struct sock *sk) | ||
318 | { | ||
319 | if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && | ||
320 | sk_memory_allocated(sk) > sk_prot_mem_limits(sk, 2)) | ||
321 | return true; | ||
322 | return false; | ||
323 | } | ||
324 | |||
325 | static inline bool tcp_too_many_orphans(struct sock *sk, int shift) | 277 | static inline bool tcp_too_many_orphans(struct sock *sk, int shift) |
326 | { | 278 | { |
327 | struct percpu_counter *ocp = sk->sk_prot->orphan_count; | 279 | struct percpu_counter *ocp = sk->sk_prot->orphan_count; |
@@ -332,11 +284,13 @@ static inline bool tcp_too_many_orphans(struct sock *sk, int shift) | |||
332 | if (orphans << shift > sysctl_tcp_max_orphans) | 284 | if (orphans << shift > sysctl_tcp_max_orphans) |
333 | return true; | 285 | return true; |
334 | } | 286 | } |
287 | |||
288 | if (sk->sk_wmem_queued > SOCK_MIN_SNDBUF && | ||
289 | atomic_long_read(&tcp_memory_allocated) > sysctl_tcp_mem[2]) | ||
290 | return true; | ||
335 | return false; | 291 | return false; |
336 | } | 292 | } |
337 | 293 | ||
338 | extern bool tcp_check_oom(struct sock *sk, int shift); | ||
339 | |||
340 | /* syncookies: remember time of last synqueue overflow */ | 294 | /* syncookies: remember time of last synqueue overflow */ |
341 | static inline void tcp_synq_overflow(struct sock *sk) | 295 | static inline void tcp_synq_overflow(struct sock *sk) |
342 | { | 296 | { |
@@ -344,7 +298,7 @@ static inline void tcp_synq_overflow(struct sock *sk) | |||
344 | } | 298 | } |
345 | 299 | ||
346 | /* syncookies: no recent synqueue overflow on this listening socket? */ | 300 | /* syncookies: no recent synqueue overflow on this listening socket? */ |
347 | static inline bool tcp_synq_no_recent_overflow(const struct sock *sk) | 301 | static inline int tcp_synq_no_recent_overflow(const struct sock *sk) |
348 | { | 302 | { |
349 | unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp; | 303 | unsigned long last_overflow = tcp_sk(sk)->rx_opt.ts_recent_stamp; |
350 | return time_after(jiffies, last_overflow + TCP_TIMEOUT_FALLBACK); | 304 | return time_after(jiffies, last_overflow + TCP_TIMEOUT_FALLBACK); |
@@ -358,30 +312,24 @@ extern struct proto tcp_prot; | |||
358 | #define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val) | 312 | #define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val) |
359 | #define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val) | 313 | #define TCP_ADD_STATS(net, field, val) SNMP_ADD_STATS((net)->mib.tcp_statistics, field, val) |
360 | 314 | ||
361 | extern void tcp_init_mem(struct net *net); | ||
362 | |||
363 | extern void tcp_tasklet_init(void); | ||
364 | |||
365 | extern void tcp_v4_err(struct sk_buff *skb, u32); | 315 | extern void tcp_v4_err(struct sk_buff *skb, u32); |
366 | 316 | ||
367 | extern void tcp_shutdown (struct sock *sk, int how); | 317 | extern void tcp_shutdown (struct sock *sk, int how); |
368 | 318 | ||
369 | extern void tcp_v4_early_demux(struct sk_buff *skb); | ||
370 | extern int tcp_v4_rcv(struct sk_buff *skb); | 319 | extern int tcp_v4_rcv(struct sk_buff *skb); |
371 | 320 | ||
321 | extern struct inet_peer *tcp_v4_get_peer(struct sock *sk, bool *release_it); | ||
322 | extern void *tcp_v4_tw_get_peer(struct sock *sk); | ||
372 | extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); | 323 | extern int tcp_v4_tw_remember_stamp(struct inet_timewait_sock *tw); |
373 | extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | 324 | extern int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
374 | size_t size); | 325 | size_t size); |
375 | extern int tcp_sendpage(struct sock *sk, struct page *page, int offset, | 326 | extern int tcp_sendpage(struct sock *sk, struct page *page, int offset, |
376 | size_t size, int flags); | 327 | size_t size, int flags); |
377 | extern void tcp_release_cb(struct sock *sk); | ||
378 | extern void tcp_write_timer_handler(struct sock *sk); | ||
379 | extern void tcp_delack_timer_handler(struct sock *sk); | ||
380 | extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg); | 328 | extern int tcp_ioctl(struct sock *sk, int cmd, unsigned long arg); |
381 | extern int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | 329 | extern int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, |
382 | const struct tcphdr *th, unsigned int len); | 330 | struct tcphdr *th, unsigned len); |
383 | extern int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | 331 | extern int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, |
384 | const struct tcphdr *th, unsigned int len); | 332 | struct tcphdr *th, unsigned len); |
385 | extern void tcp_rcv_space_adjust(struct sock *sk); | 333 | extern void tcp_rcv_space_adjust(struct sock *sk); |
386 | extern void tcp_cleanup_rbuf(struct sock *sk, int copied); | 334 | extern void tcp_cleanup_rbuf(struct sock *sk, int copied); |
387 | extern int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp); | 335 | extern int tcp_twsk_unique(struct sock *sk, struct sock *sktw, void *twp); |
@@ -408,7 +356,13 @@ static inline void tcp_dec_quickack_mode(struct sock *sk, | |||
408 | #define TCP_ECN_OK 1 | 356 | #define TCP_ECN_OK 1 |
409 | #define TCP_ECN_QUEUE_CWR 2 | 357 | #define TCP_ECN_QUEUE_CWR 2 |
410 | #define TCP_ECN_DEMAND_CWR 4 | 358 | #define TCP_ECN_DEMAND_CWR 4 |
411 | #define TCP_ECN_SEEN 8 | 359 | |
360 | static __inline__ void | ||
361 | TCP_ECN_create_request(struct request_sock *req, struct tcphdr *th) | ||
362 | { | ||
363 | if (sysctl_tcp_ecn && th->ece && th->cwr) | ||
364 | inet_rsk(req)->ecn_ok = 1; | ||
365 | } | ||
412 | 366 | ||
413 | enum tcp_tw_status { | 367 | enum tcp_tw_status { |
414 | TCP_TW_SUCCESS = 0, | 368 | TCP_TW_SUCCESS = 0, |
@@ -423,24 +377,15 @@ extern enum tcp_tw_status tcp_timewait_state_process(struct inet_timewait_sock * | |||
423 | const struct tcphdr *th); | 377 | const struct tcphdr *th); |
424 | extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb, | 378 | extern struct sock * tcp_check_req(struct sock *sk,struct sk_buff *skb, |
425 | struct request_sock *req, | 379 | struct request_sock *req, |
426 | struct request_sock **prev, | 380 | struct request_sock **prev); |
427 | bool fastopen); | ||
428 | extern int tcp_child_process(struct sock *parent, struct sock *child, | 381 | extern int tcp_child_process(struct sock *parent, struct sock *child, |
429 | struct sk_buff *skb); | 382 | struct sk_buff *skb); |
430 | extern bool tcp_use_frto(struct sock *sk); | 383 | extern int tcp_use_frto(struct sock *sk); |
431 | extern void tcp_enter_frto(struct sock *sk); | 384 | extern void tcp_enter_frto(struct sock *sk); |
432 | extern void tcp_enter_loss(struct sock *sk, int how); | 385 | extern void tcp_enter_loss(struct sock *sk, int how); |
433 | extern void tcp_clear_retrans(struct tcp_sock *tp); | 386 | extern void tcp_clear_retrans(struct tcp_sock *tp); |
434 | extern void tcp_update_metrics(struct sock *sk); | 387 | extern void tcp_update_metrics(struct sock *sk); |
435 | extern void tcp_init_metrics(struct sock *sk); | ||
436 | extern void tcp_metrics_init(void); | ||
437 | extern bool tcp_peer_is_proven(struct request_sock *req, struct dst_entry *dst, bool paws_check); | ||
438 | extern bool tcp_remember_stamp(struct sock *sk); | ||
439 | extern bool tcp_tw_remember_stamp(struct inet_timewait_sock *tw); | ||
440 | extern void tcp_fetch_timewait_stamp(struct sock *sk, struct dst_entry *dst); | ||
441 | extern void tcp_disable_fack(struct tcp_sock *tp); | ||
442 | extern void tcp_close(struct sock *sk, long timeout); | 388 | extern void tcp_close(struct sock *sk, long timeout); |
443 | extern void tcp_init_sock(struct sock *sk); | ||
444 | extern unsigned int tcp_poll(struct file * file, struct socket *sock, | 389 | extern unsigned int tcp_poll(struct file * file, struct socket *sock, |
445 | struct poll_table_struct *wait); | 390 | struct poll_table_struct *wait); |
446 | extern int tcp_getsockopt(struct sock *sk, int level, int optname, | 391 | extern int tcp_getsockopt(struct sock *sk, int level, int optname, |
@@ -455,10 +400,10 @@ extern void tcp_set_keepalive(struct sock *sk, int val); | |||
455 | extern void tcp_syn_ack_timeout(struct sock *sk, struct request_sock *req); | 400 | extern void tcp_syn_ack_timeout(struct sock *sk, struct request_sock *req); |
456 | extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | 401 | extern int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, |
457 | size_t len, int nonblock, int flags, int *addr_len); | 402 | size_t len, int nonblock, int flags, int *addr_len); |
458 | extern void tcp_parse_options(const struct sk_buff *skb, | 403 | extern void tcp_parse_options(struct sk_buff *skb, |
459 | struct tcp_options_received *opt_rx, const u8 **hvpp, | 404 | struct tcp_options_received *opt_rx, u8 **hvpp, |
460 | int estab, struct tcp_fastopen_cookie *foc); | 405 | int estab); |
461 | extern const u8 *tcp_parse_md5sig_option(const struct tcphdr *th); | 406 | extern u8 *tcp_parse_md5sig_option(struct tcphdr *th); |
462 | 407 | ||
463 | /* | 408 | /* |
464 | * TCP v4 functions exported for the inet6 API | 409 | * TCP v4 functions exported for the inet6 API |
@@ -478,14 +423,9 @@ extern int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, | |||
478 | extern int tcp_connect(struct sock *sk); | 423 | extern int tcp_connect(struct sock *sk); |
479 | extern struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, | 424 | extern struct sk_buff * tcp_make_synack(struct sock *sk, struct dst_entry *dst, |
480 | struct request_sock *req, | 425 | struct request_sock *req, |
481 | struct request_values *rvp, | 426 | struct request_values *rvp); |
482 | struct tcp_fastopen_cookie *foc); | ||
483 | extern int tcp_disconnect(struct sock *sk, int flags); | 427 | extern int tcp_disconnect(struct sock *sk, int flags); |
484 | 428 | ||
485 | void tcp_connect_init(struct sock *sk); | ||
486 | void tcp_finish_connect(struct sock *sk, struct sk_buff *skb); | ||
487 | int tcp_send_rcvq(struct sock *sk, struct msghdr *msg, size_t size); | ||
488 | void inet_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb); | ||
489 | 429 | ||
490 | /* From syncookies.c */ | 430 | /* From syncookies.c */ |
491 | extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS]; | 431 | extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS]; |
@@ -509,7 +449,7 @@ extern bool cookie_check_timestamp(struct tcp_options_received *opt, bool *); | |||
509 | /* From net/ipv6/syncookies.c */ | 449 | /* From net/ipv6/syncookies.c */ |
510 | extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb); | 450 | extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb); |
511 | #ifdef CONFIG_SYN_COOKIES | 451 | #ifdef CONFIG_SYN_COOKIES |
512 | extern __u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb, | 452 | extern __u32 cookie_v6_init_sequence(struct sock *sk, struct sk_buff *skb, |
513 | __u16 *mss); | 453 | __u16 *mss); |
514 | #else | 454 | #else |
515 | static inline __u32 cookie_v6_init_sequence(struct sock *sk, | 455 | static inline __u32 cookie_v6_init_sequence(struct sock *sk, |
@@ -523,8 +463,7 @@ static inline __u32 cookie_v6_init_sequence(struct sock *sk, | |||
523 | 463 | ||
524 | extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, | 464 | extern void __tcp_push_pending_frames(struct sock *sk, unsigned int cur_mss, |
525 | int nonagle); | 465 | int nonagle); |
526 | extern bool tcp_may_send_now(struct sock *sk); | 466 | extern int tcp_may_send_now(struct sock *sk); |
527 | extern int __tcp_retransmit_skb(struct sock *, struct sk_buff *); | ||
528 | extern int tcp_retransmit_skb(struct sock *, struct sk_buff *); | 467 | extern int tcp_retransmit_skb(struct sock *, struct sk_buff *); |
529 | extern void tcp_retransmit_timer(struct sock *sk); | 468 | extern void tcp_retransmit_timer(struct sock *sk); |
530 | extern void tcp_xmit_retransmit_queue(struct sock *); | 469 | extern void tcp_xmit_retransmit_queue(struct sock *); |
@@ -538,18 +477,15 @@ extern int tcp_write_wakeup(struct sock *); | |||
538 | extern void tcp_send_fin(struct sock *sk); | 477 | extern void tcp_send_fin(struct sock *sk); |
539 | extern void tcp_send_active_reset(struct sock *sk, gfp_t priority); | 478 | extern void tcp_send_active_reset(struct sock *sk, gfp_t priority); |
540 | extern int tcp_send_synack(struct sock *); | 479 | extern int tcp_send_synack(struct sock *); |
541 | extern bool tcp_syn_flood_action(struct sock *sk, | 480 | extern int tcp_syn_flood_action(struct sock *sk, |
542 | const struct sk_buff *skb, | 481 | const struct sk_buff *skb, |
543 | const char *proto); | 482 | const char *proto); |
544 | extern void tcp_push_one(struct sock *, unsigned int mss_now); | 483 | extern void tcp_push_one(struct sock *, unsigned int mss_now); |
545 | extern void tcp_send_ack(struct sock *sk); | 484 | extern void tcp_send_ack(struct sock *sk); |
546 | extern void tcp_send_delayed_ack(struct sock *sk); | 485 | extern void tcp_send_delayed_ack(struct sock *sk); |
547 | 486 | ||
548 | /* tcp_input.c */ | 487 | /* tcp_input.c */ |
549 | extern void tcp_cwnd_application_limited(struct sock *sk); | 488 | extern void tcp_cwnd_application_limited(struct sock *sk); |
550 | extern void tcp_resume_early_retransmit(struct sock *sk); | ||
551 | extern void tcp_rearm_rto(struct sock *sk); | ||
552 | extern void tcp_reset(struct sock *sk); | ||
553 | 489 | ||
554 | /* tcp_timer.c */ | 490 | /* tcp_timer.c */ |
555 | extern void tcp_init_xmit_timers(struct sock *); | 491 | extern void tcp_init_xmit_timers(struct sock *); |
@@ -585,7 +521,7 @@ static inline int tcp_bound_to_half_wnd(struct tcp_sock *tp, int pktsize) | |||
585 | } | 521 | } |
586 | 522 | ||
587 | /* tcp.c */ | 523 | /* tcp.c */ |
588 | extern void tcp_get_info(const struct sock *, struct tcp_info *); | 524 | extern void tcp_get_info(struct sock *, struct tcp_info *); |
589 | 525 | ||
590 | /* Read 'sendfile()'-style from a TCP socket */ | 526 | /* Read 'sendfile()'-style from a TCP socket */ |
591 | typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, | 527 | typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, |
@@ -599,7 +535,6 @@ extern int tcp_mtu_to_mss(struct sock *sk, int pmtu); | |||
599 | extern int tcp_mss_to_mtu(struct sock *sk, int mss); | 535 | extern int tcp_mss_to_mtu(struct sock *sk, int mss); |
600 | extern void tcp_mtup_init(struct sock *sk); | 536 | extern void tcp_mtup_init(struct sock *sk); |
601 | extern void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt); | 537 | extern void tcp_valid_rtt_meas(struct sock *sk, u32 seq_rtt); |
602 | extern void tcp_init_buffer_space(struct sock *sk); | ||
603 | 538 | ||
604 | static inline void tcp_bound_rto(const struct sock *sk) | 539 | static inline void tcp_bound_rto(const struct sock *sk) |
605 | { | 540 | { |
@@ -612,8 +547,6 @@ static inline u32 __tcp_set_rto(const struct tcp_sock *tp) | |||
612 | return (tp->srtt >> 3) + tp->rttvar; | 547 | return (tp->srtt >> 3) + tp->rttvar; |
613 | } | 548 | } |
614 | 549 | ||
615 | extern void tcp_set_rto(struct sock *sk); | ||
616 | |||
617 | static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd) | 550 | static inline void __tcp_fast_path_on(struct tcp_sock *tp, u32 snd_wnd) |
618 | { | 551 | { |
619 | tp->pred_flags = htonl((tp->tcp_header_len << 26) | | 552 | tp->pred_flags = htonl((tp->tcp_header_len << 26) | |
@@ -640,7 +573,7 @@ static inline void tcp_fast_path_check(struct sock *sk) | |||
640 | /* Compute the actual rto_min value */ | 573 | /* Compute the actual rto_min value */ |
641 | static inline u32 tcp_rto_min(struct sock *sk) | 574 | static inline u32 tcp_rto_min(struct sock *sk) |
642 | { | 575 | { |
643 | const struct dst_entry *dst = __sk_dst_get(sk); | 576 | struct dst_entry *dst = __sk_dst_get(sk); |
644 | u32 rto_min = TCP_RTO_MIN; | 577 | u32 rto_min = TCP_RTO_MIN; |
645 | 578 | ||
646 | if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) | 579 | if (dst && dst_metric_locked(dst, RTAX_RTO_MIN)) |
@@ -667,8 +600,6 @@ static inline u32 tcp_receive_window(const struct tcp_sock *tp) | |||
667 | */ | 600 | */ |
668 | extern u32 __tcp_select_window(struct sock *sk); | 601 | extern u32 __tcp_select_window(struct sock *sk); |
669 | 602 | ||
670 | void tcp_send_window_probe(struct sock *sk); | ||
671 | |||
672 | /* TCP timestamps are only 32-bits, this causes a slight | 603 | /* TCP timestamps are only 32-bits, this causes a slight |
673 | * complication on 64-bit systems since we store a snapshot | 604 | * complication on 64-bit systems since we store a snapshot |
674 | * of jiffies in the buffer control blocks below. We decided | 605 | * of jiffies in the buffer control blocks below. We decided |
@@ -697,46 +628,28 @@ void tcp_send_window_probe(struct sock *sk); | |||
697 | struct tcp_skb_cb { | 628 | struct tcp_skb_cb { |
698 | union { | 629 | union { |
699 | struct inet_skb_parm h4; | 630 | struct inet_skb_parm h4; |
700 | #if IS_ENABLED(CONFIG_IPV6) | 631 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
701 | struct inet6_skb_parm h6; | 632 | struct inet6_skb_parm h6; |
702 | #endif | 633 | #endif |
703 | } header; /* For incoming frames */ | 634 | } header; /* For incoming frames */ |
704 | __u32 seq; /* Starting sequence number */ | 635 | __u32 seq; /* Starting sequence number */ |
705 | __u32 end_seq; /* SEQ + FIN + SYN + datalen */ | 636 | __u32 end_seq; /* SEQ + FIN + SYN + datalen */ |
706 | __u32 when; /* used to compute rtt's */ | 637 | __u32 when; /* used to compute rtt's */ |
707 | __u8 tcp_flags; /* TCP header flags. (tcp[13]) */ | 638 | __u8 flags; /* TCP header flags. */ |
708 | |||
709 | __u8 sacked; /* State flags for SACK/FACK. */ | 639 | __u8 sacked; /* State flags for SACK/FACK. */ |
710 | #define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */ | 640 | #define TCPCB_SACKED_ACKED 0x01 /* SKB ACK'd by a SACK block */ |
711 | #define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */ | 641 | #define TCPCB_SACKED_RETRANS 0x02 /* SKB retransmitted */ |
712 | #define TCPCB_LOST 0x04 /* SKB is lost */ | 642 | #define TCPCB_LOST 0x04 /* SKB is lost */ |
713 | #define TCPCB_TAGBITS 0x07 /* All tag bits */ | 643 | #define TCPCB_TAGBITS 0x07 /* All tag bits */ |
644 | |||
714 | #define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */ | 645 | #define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */ |
715 | #define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS) | 646 | #define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS) |
716 | 647 | ||
717 | __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */ | ||
718 | /* 1 byte hole */ | ||
719 | __u32 ack_seq; /* Sequence number ACK'd */ | 648 | __u32 ack_seq; /* Sequence number ACK'd */ |
720 | }; | 649 | }; |
721 | 650 | ||
722 | #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) | 651 | #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0])) |
723 | 652 | ||
724 | /* RFC3168 : 6.1.1 SYN packets must not have ECT/ECN bits set | ||
725 | * | ||
726 | * If we receive a SYN packet with these bits set, it means a network is | ||
727 | * playing bad games with TOS bits. In order to avoid possible false congestion | ||
728 | * notifications, we disable TCP ECN negociation. | ||
729 | */ | ||
730 | static inline void | ||
731 | TCP_ECN_create_request(struct request_sock *req, const struct sk_buff *skb) | ||
732 | { | ||
733 | const struct tcphdr *th = tcp_hdr(skb); | ||
734 | |||
735 | if (sysctl_tcp_ecn && th->ece && th->cwr && | ||
736 | INET_ECN_is_not_ect(TCP_SKB_CB(skb)->ip_dsfield)) | ||
737 | inet_rsk(req)->ecn_ok = 1; | ||
738 | } | ||
739 | |||
740 | /* Due to TSO, an SKB can be composed of multiple actual | 653 | /* Due to TSO, an SKB can be composed of multiple actual |
741 | * packets. To keep these tracked properly, we use this. | 654 | * packets. To keep these tracked properly, we use this. |
742 | */ | 655 | */ |
@@ -852,34 +765,19 @@ static inline int tcp_is_sack(const struct tcp_sock *tp) | |||
852 | return tp->rx_opt.sack_ok; | 765 | return tp->rx_opt.sack_ok; |
853 | } | 766 | } |
854 | 767 | ||
855 | static inline bool tcp_is_reno(const struct tcp_sock *tp) | 768 | static inline int tcp_is_reno(const struct tcp_sock *tp) |
856 | { | 769 | { |
857 | return !tcp_is_sack(tp); | 770 | return !tcp_is_sack(tp); |
858 | } | 771 | } |
859 | 772 | ||
860 | static inline bool tcp_is_fack(const struct tcp_sock *tp) | 773 | static inline int tcp_is_fack(const struct tcp_sock *tp) |
861 | { | 774 | { |
862 | return tp->rx_opt.sack_ok & TCP_FACK_ENABLED; | 775 | return tp->rx_opt.sack_ok & 2; |
863 | } | 776 | } |
864 | 777 | ||
865 | static inline void tcp_enable_fack(struct tcp_sock *tp) | 778 | static inline void tcp_enable_fack(struct tcp_sock *tp) |
866 | { | 779 | { |
867 | tp->rx_opt.sack_ok |= TCP_FACK_ENABLED; | 780 | tp->rx_opt.sack_ok |= 2; |
868 | } | ||
869 | |||
870 | /* TCP early-retransmit (ER) is similar to but more conservative than | ||
871 | * the thin-dupack feature. Enable ER only if thin-dupack is disabled. | ||
872 | */ | ||
873 | static inline void tcp_enable_early_retrans(struct tcp_sock *tp) | ||
874 | { | ||
875 | tp->do_early_retrans = sysctl_tcp_early_retrans && | ||
876 | !sysctl_tcp_thin_dupack && sysctl_tcp_reordering == 3; | ||
877 | tp->early_retrans_delayed = 0; | ||
878 | } | ||
879 | |||
880 | static inline void tcp_disable_early_retrans(struct tcp_sock *tp) | ||
881 | { | ||
882 | tp->do_early_retrans = 0; | ||
883 | } | 781 | } |
884 | 782 | ||
885 | static inline unsigned int tcp_left_out(const struct tcp_sock *tp) | 783 | static inline unsigned int tcp_left_out(const struct tcp_sock *tp) |
@@ -913,21 +811,14 @@ static inline bool tcp_in_initial_slowstart(const struct tcp_sock *tp) | |||
913 | return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH; | 811 | return tp->snd_ssthresh >= TCP_INFINITE_SSTHRESH; |
914 | } | 812 | } |
915 | 813 | ||
916 | static inline bool tcp_in_cwnd_reduction(const struct sock *sk) | ||
917 | { | ||
918 | return (TCPF_CA_CWR | TCPF_CA_Recovery) & | ||
919 | (1 << inet_csk(sk)->icsk_ca_state); | ||
920 | } | ||
921 | |||
922 | /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. | 814 | /* If cwnd > ssthresh, we may raise ssthresh to be half-way to cwnd. |
923 | * The exception is cwnd reduction phase, when cwnd is decreasing towards | 815 | * The exception is rate halving phase, when cwnd is decreasing towards |
924 | * ssthresh. | 816 | * ssthresh. |
925 | */ | 817 | */ |
926 | static inline __u32 tcp_current_ssthresh(const struct sock *sk) | 818 | static inline __u32 tcp_current_ssthresh(const struct sock *sk) |
927 | { | 819 | { |
928 | const struct tcp_sock *tp = tcp_sk(sk); | 820 | const struct tcp_sock *tp = tcp_sk(sk); |
929 | 821 | if ((1 << inet_csk(sk)->icsk_ca_state) & (TCPF_CA_CWR | TCPF_CA_Recovery)) | |
930 | if (tcp_in_cwnd_reduction(sk)) | ||
931 | return tp->snd_ssthresh; | 822 | return tp->snd_ssthresh; |
932 | else | 823 | else |
933 | return max(tp->snd_ssthresh, | 824 | return max(tp->snd_ssthresh, |
@@ -939,15 +830,7 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk) | |||
939 | #define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out) | 830 | #define tcp_verify_left_out(tp) WARN_ON(tcp_left_out(tp) > tp->packets_out) |
940 | 831 | ||
941 | extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); | 832 | extern void tcp_enter_cwr(struct sock *sk, const int set_ssthresh); |
942 | extern __u32 tcp_init_cwnd(const struct tcp_sock *tp, const struct dst_entry *dst); | 833 | extern __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst); |
943 | |||
944 | /* The maximum number of MSS of available cwnd for which TSO defers | ||
945 | * sending if not using sysctl_tcp_tso_win_divisor. | ||
946 | */ | ||
947 | static inline __u32 tcp_max_tso_deferred_mss(const struct tcp_sock *tp) | ||
948 | { | ||
949 | return 3; | ||
950 | } | ||
951 | 834 | ||
952 | /* Slow start with delack produces 3 packets of burst, so that | 835 | /* Slow start with delack produces 3 packets of burst, so that |
953 | * it is safe "de facto". This will be the default - same as | 836 | * it is safe "de facto". This will be the default - same as |
@@ -965,7 +848,7 @@ static inline u32 tcp_wnd_end(const struct tcp_sock *tp) | |||
965 | { | 848 | { |
966 | return tp->snd_una + tp->snd_wnd; | 849 | return tp->snd_una + tp->snd_wnd; |
967 | } | 850 | } |
968 | extern bool tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight); | 851 | extern int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight); |
969 | 852 | ||
970 | static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss, | 853 | static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss, |
971 | const struct sk_buff *skb) | 854 | const struct sk_buff *skb) |
@@ -976,7 +859,7 @@ static inline void tcp_minshall_update(struct tcp_sock *tp, unsigned int mss, | |||
976 | 859 | ||
977 | static inline void tcp_check_probe_timer(struct sock *sk) | 860 | static inline void tcp_check_probe_timer(struct sock *sk) |
978 | { | 861 | { |
979 | const struct tcp_sock *tp = tcp_sk(sk); | 862 | struct tcp_sock *tp = tcp_sk(sk); |
980 | const struct inet_connection_sock *icsk = inet_csk(sk); | 863 | const struct inet_connection_sock *icsk = inet_csk(sk); |
981 | 864 | ||
982 | if (!tp->packets_out && !icsk->icsk_pending) | 865 | if (!tp->packets_out && !icsk->icsk_pending) |
@@ -1008,7 +891,7 @@ static inline __sum16 __tcp_checksum_complete(struct sk_buff *skb) | |||
1008 | return __skb_checksum_complete(skb); | 891 | return __skb_checksum_complete(skb); |
1009 | } | 892 | } |
1010 | 893 | ||
1011 | static inline bool tcp_checksum_complete(struct sk_buff *skb) | 894 | static inline int tcp_checksum_complete(struct sk_buff *skb) |
1012 | { | 895 | { |
1013 | return !skb_csum_unnecessary(skb) && | 896 | return !skb_csum_unnecessary(skb) && |
1014 | __tcp_checksum_complete(skb); | 897 | __tcp_checksum_complete(skb); |
@@ -1038,12 +921,12 @@ static inline void tcp_prequeue_init(struct tcp_sock *tp) | |||
1038 | * | 921 | * |
1039 | * NOTE: is this not too big to inline? | 922 | * NOTE: is this not too big to inline? |
1040 | */ | 923 | */ |
1041 | static inline bool tcp_prequeue(struct sock *sk, struct sk_buff *skb) | 924 | static inline int tcp_prequeue(struct sock *sk, struct sk_buff *skb) |
1042 | { | 925 | { |
1043 | struct tcp_sock *tp = tcp_sk(sk); | 926 | struct tcp_sock *tp = tcp_sk(sk); |
1044 | 927 | ||
1045 | if (sysctl_tcp_low_latency || !tp->ucopy.task) | 928 | if (sysctl_tcp_low_latency || !tp->ucopy.task) |
1046 | return false; | 929 | return 0; |
1047 | 930 | ||
1048 | __skb_queue_tail(&tp->ucopy.prequeue, skb); | 931 | __skb_queue_tail(&tp->ucopy.prequeue, skb); |
1049 | tp->ucopy.memory += skb->truesize; | 932 | tp->ucopy.memory += skb->truesize; |
@@ -1067,7 +950,7 @@ static inline bool tcp_prequeue(struct sock *sk, struct sk_buff *skb) | |||
1067 | (3 * tcp_rto_min(sk)) / 4, | 950 | (3 * tcp_rto_min(sk)) / 4, |
1068 | TCP_RTO_MAX); | 951 | TCP_RTO_MAX); |
1069 | } | 952 | } |
1070 | return true; | 953 | return 1; |
1071 | } | 954 | } |
1072 | 955 | ||
1073 | 956 | ||
@@ -1124,8 +1007,6 @@ static inline void tcp_openreq_init(struct request_sock *req, | |||
1124 | req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */ | 1007 | req->rcv_wnd = 0; /* So that tcp_send_synack() knows! */ |
1125 | req->cookie_ts = 0; | 1008 | req->cookie_ts = 0; |
1126 | tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq; | 1009 | tcp_rsk(req)->rcv_isn = TCP_SKB_CB(skb)->seq; |
1127 | tcp_rsk(req)->rcv_nxt = TCP_SKB_CB(skb)->seq + 1; | ||
1128 | tcp_rsk(req)->snt_synack = 0; | ||
1129 | req->mss = rx_opt->mss_clamp; | 1010 | req->mss = rx_opt->mss_clamp; |
1130 | req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; | 1011 | req->ts_recent = rx_opt->saw_tstamp ? rx_opt->rcv_tsval : 0; |
1131 | ireq->tstamp_ok = rx_opt->tstamp_ok; | 1012 | ireq->tstamp_ok = rx_opt->tstamp_ok; |
@@ -1138,15 +1019,6 @@ static inline void tcp_openreq_init(struct request_sock *req, | |||
1138 | ireq->loc_port = tcp_hdr(skb)->dest; | 1019 | ireq->loc_port = tcp_hdr(skb)->dest; |
1139 | } | 1020 | } |
1140 | 1021 | ||
1141 | /* Compute time elapsed between SYNACK and the ACK completing 3WHS */ | ||
1142 | static inline void tcp_synack_rtt_meas(struct sock *sk, | ||
1143 | struct request_sock *req) | ||
1144 | { | ||
1145 | if (tcp_rsk(req)->snt_synack) | ||
1146 | tcp_valid_rtt_meas(sk, | ||
1147 | tcp_time_stamp - tcp_rsk(req)->snt_synack); | ||
1148 | } | ||
1149 | |||
1150 | extern void tcp_enter_memory_pressure(struct sock *sk); | 1022 | extern void tcp_enter_memory_pressure(struct sock *sk); |
1151 | 1023 | ||
1152 | static inline int keepalive_intvl_when(const struct tcp_sock *tp) | 1024 | static inline int keepalive_intvl_when(const struct tcp_sock *tp) |
@@ -1183,28 +1055,28 @@ static inline int tcp_fin_time(const struct sock *sk) | |||
1183 | return fin_timeout; | 1055 | return fin_timeout; |
1184 | } | 1056 | } |
1185 | 1057 | ||
1186 | static inline bool tcp_paws_check(const struct tcp_options_received *rx_opt, | 1058 | static inline int tcp_paws_check(const struct tcp_options_received *rx_opt, |
1187 | int paws_win) | 1059 | int paws_win) |
1188 | { | 1060 | { |
1189 | if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win) | 1061 | if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win) |
1190 | return true; | 1062 | return 1; |
1191 | if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)) | 1063 | if (unlikely(get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)) |
1192 | return true; | 1064 | return 1; |
1193 | /* | 1065 | /* |
1194 | * Some OSes send SYN and SYNACK messages with tsval=0 tsecr=0, | 1066 | * Some OSes send SYN and SYNACK messages with tsval=0 tsecr=0, |
1195 | * then following tcp messages have valid values. Ignore 0 value, | 1067 | * then following tcp messages have valid values. Ignore 0 value, |
1196 | * or else 'negative' tsval might forbid us to accept their packets. | 1068 | * or else 'negative' tsval might forbid us to accept their packets. |
1197 | */ | 1069 | */ |
1198 | if (!rx_opt->ts_recent) | 1070 | if (!rx_opt->ts_recent) |
1199 | return true; | 1071 | return 1; |
1200 | return false; | 1072 | return 0; |
1201 | } | 1073 | } |
1202 | 1074 | ||
1203 | static inline bool tcp_paws_reject(const struct tcp_options_received *rx_opt, | 1075 | static inline int tcp_paws_reject(const struct tcp_options_received *rx_opt, |
1204 | int rst) | 1076 | int rst) |
1205 | { | 1077 | { |
1206 | if (tcp_paws_check(rx_opt, 0)) | 1078 | if (tcp_paws_check(rx_opt, 0)) |
1207 | return false; | 1079 | return 0; |
1208 | 1080 | ||
1209 | /* RST segments are not recommended to carry timestamp, | 1081 | /* RST segments are not recommended to carry timestamp, |
1210 | and, if they do, it is recommended to ignore PAWS because | 1082 | and, if they do, it is recommended to ignore PAWS because |
@@ -1219,8 +1091,8 @@ static inline bool tcp_paws_reject(const struct tcp_options_received *rx_opt, | |||
1219 | However, we can relax time bounds for RST segments to MSL. | 1091 | However, we can relax time bounds for RST segments to MSL. |
1220 | */ | 1092 | */ |
1221 | if (rst && get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_MSL) | 1093 | if (rst && get_seconds() >= rx_opt->ts_recent_stamp + TCP_PAWS_MSL) |
1222 | return false; | 1094 | return 0; |
1223 | return true; | 1095 | return 1; |
1224 | } | 1096 | } |
1225 | 1097 | ||
1226 | static inline void tcp_mib_init(struct net *net) | 1098 | static inline void tcp_mib_init(struct net *net) |
@@ -1248,27 +1120,35 @@ static inline void tcp_clear_all_retrans_hints(struct tcp_sock *tp) | |||
1248 | /* MD5 Signature */ | 1120 | /* MD5 Signature */ |
1249 | struct crypto_hash; | 1121 | struct crypto_hash; |
1250 | 1122 | ||
1251 | union tcp_md5_addr { | ||
1252 | struct in_addr a4; | ||
1253 | #if IS_ENABLED(CONFIG_IPV6) | ||
1254 | struct in6_addr a6; | ||
1255 | #endif | ||
1256 | }; | ||
1257 | |||
1258 | /* - key database */ | 1123 | /* - key database */ |
1259 | struct tcp_md5sig_key { | 1124 | struct tcp_md5sig_key { |
1260 | struct hlist_node node; | 1125 | u8 *key; |
1261 | u8 keylen; | 1126 | u8 keylen; |
1262 | u8 family; /* AF_INET or AF_INET6 */ | 1127 | }; |
1263 | union tcp_md5_addr addr; | 1128 | |
1264 | u8 key[TCP_MD5SIG_MAXKEYLEN]; | 1129 | struct tcp4_md5sig_key { |
1265 | struct rcu_head rcu; | 1130 | struct tcp_md5sig_key base; |
1131 | __be32 addr; | ||
1132 | }; | ||
1133 | |||
1134 | struct tcp6_md5sig_key { | ||
1135 | struct tcp_md5sig_key base; | ||
1136 | #if 0 | ||
1137 | u32 scope_id; /* XXX */ | ||
1138 | #endif | ||
1139 | struct in6_addr addr; | ||
1266 | }; | 1140 | }; |
1267 | 1141 | ||
1268 | /* - sock block */ | 1142 | /* - sock block */ |
1269 | struct tcp_md5sig_info { | 1143 | struct tcp_md5sig_info { |
1270 | struct hlist_head head; | 1144 | struct tcp4_md5sig_key *keys4; |
1271 | struct rcu_head rcu; | 1145 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
1146 | struct tcp6_md5sig_key *keys6; | ||
1147 | u32 entries6; | ||
1148 | u32 alloced6; | ||
1149 | #endif | ||
1150 | u32 entries4; | ||
1151 | u32 alloced4; | ||
1272 | }; | 1152 | }; |
1273 | 1153 | ||
1274 | /* - pseudo header */ | 1154 | /* - pseudo header */ |
@@ -1289,7 +1169,7 @@ struct tcp6_pseudohdr { | |||
1289 | 1169 | ||
1290 | union tcp_md5sum_block { | 1170 | union tcp_md5sum_block { |
1291 | struct tcp4_pseudohdr ip4; | 1171 | struct tcp4_pseudohdr ip4; |
1292 | #if IS_ENABLED(CONFIG_IPV6) | 1172 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
1293 | struct tcp6_pseudohdr ip6; | 1173 | struct tcp6_pseudohdr ip6; |
1294 | #endif | 1174 | #endif |
1295 | }; | 1175 | }; |
@@ -1302,70 +1182,35 @@ struct tcp_md5sig_pool { | |||
1302 | 1182 | ||
1303 | /* - functions */ | 1183 | /* - functions */ |
1304 | extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, | 1184 | extern int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, |
1305 | const struct sock *sk, | 1185 | struct sock *sk, struct request_sock *req, |
1306 | const struct request_sock *req, | 1186 | struct sk_buff *skb); |
1307 | const struct sk_buff *skb); | 1187 | extern struct tcp_md5sig_key * tcp_v4_md5_lookup(struct sock *sk, |
1308 | extern int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr, | 1188 | struct sock *addr_sk); |
1309 | int family, const u8 *newkey, | 1189 | extern int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, u8 *newkey, |
1310 | u8 newkeylen, gfp_t gfp); | 1190 | u8 newkeylen); |
1311 | extern int tcp_md5_do_del(struct sock *sk, const union tcp_md5_addr *addr, | 1191 | extern int tcp_v4_md5_do_del(struct sock *sk, __be32 addr); |
1312 | int family); | ||
1313 | extern struct tcp_md5sig_key *tcp_v4_md5_lookup(struct sock *sk, | ||
1314 | struct sock *addr_sk); | ||
1315 | 1192 | ||
1316 | #ifdef CONFIG_TCP_MD5SIG | 1193 | #ifdef CONFIG_TCP_MD5SIG |
1317 | extern struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, | 1194 | #define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_keylen ? \ |
1318 | const union tcp_md5_addr *addr, int family); | 1195 | &(struct tcp_md5sig_key) { \ |
1319 | #define tcp_twsk_md5_key(twsk) ((twsk)->tw_md5_key) | 1196 | .key = (twsk)->tw_md5_key, \ |
1197 | .keylen = (twsk)->tw_md5_keylen, \ | ||
1198 | } : NULL) | ||
1320 | #else | 1199 | #else |
1321 | static inline struct tcp_md5sig_key *tcp_md5_do_lookup(struct sock *sk, | ||
1322 | const union tcp_md5_addr *addr, | ||
1323 | int family) | ||
1324 | { | ||
1325 | return NULL; | ||
1326 | } | ||
1327 | #define tcp_twsk_md5_key(twsk) NULL | 1200 | #define tcp_twsk_md5_key(twsk) NULL |
1328 | #endif | 1201 | #endif |
1329 | 1202 | ||
1330 | extern struct tcp_md5sig_pool __percpu *tcp_alloc_md5sig_pool(struct sock *); | 1203 | extern struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *); |
1331 | extern void tcp_free_md5sig_pool(void); | 1204 | extern void tcp_free_md5sig_pool(void); |
1332 | 1205 | ||
1333 | extern struct tcp_md5sig_pool *tcp_get_md5sig_pool(void); | 1206 | extern struct tcp_md5sig_pool *tcp_get_md5sig_pool(void); |
1334 | extern void tcp_put_md5sig_pool(void); | 1207 | extern void tcp_put_md5sig_pool(void); |
1335 | 1208 | ||
1336 | extern int tcp_md5_hash_header(struct tcp_md5sig_pool *, const struct tcphdr *); | 1209 | extern int tcp_md5_hash_header(struct tcp_md5sig_pool *, struct tcphdr *); |
1337 | extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, const struct sk_buff *, | 1210 | extern int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *, struct sk_buff *, |
1338 | unsigned int header_len); | 1211 | unsigned header_len); |
1339 | extern int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, | 1212 | extern int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, |
1340 | const struct tcp_md5sig_key *key); | 1213 | struct tcp_md5sig_key *key); |
1341 | |||
1342 | /* From tcp_fastopen.c */ | ||
1343 | extern void tcp_fastopen_cache_get(struct sock *sk, u16 *mss, | ||
1344 | struct tcp_fastopen_cookie *cookie, | ||
1345 | int *syn_loss, unsigned long *last_syn_loss); | ||
1346 | extern void tcp_fastopen_cache_set(struct sock *sk, u16 mss, | ||
1347 | struct tcp_fastopen_cookie *cookie, | ||
1348 | bool syn_lost); | ||
1349 | struct tcp_fastopen_request { | ||
1350 | /* Fast Open cookie. Size 0 means a cookie request */ | ||
1351 | struct tcp_fastopen_cookie cookie; | ||
1352 | struct msghdr *data; /* data in MSG_FASTOPEN */ | ||
1353 | u16 copied; /* queued in tcp_connect() */ | ||
1354 | }; | ||
1355 | void tcp_free_fastopen_req(struct tcp_sock *tp); | ||
1356 | |||
1357 | extern struct tcp_fastopen_context __rcu *tcp_fastopen_ctx; | ||
1358 | int tcp_fastopen_reset_cipher(void *key, unsigned int len); | ||
1359 | void tcp_fastopen_cookie_gen(__be32 addr, struct tcp_fastopen_cookie *foc); | ||
1360 | |||
1361 | #define TCP_FASTOPEN_KEY_LENGTH 16 | ||
1362 | |||
1363 | /* Fastopen key context */ | ||
1364 | struct tcp_fastopen_context { | ||
1365 | struct crypto_cipher __rcu *tfm; | ||
1366 | __u8 key[TCP_FASTOPEN_KEY_LENGTH]; | ||
1367 | struct rcu_head rcu; | ||
1368 | }; | ||
1369 | 1214 | ||
1370 | /* write queue abstraction */ | 1215 | /* write queue abstraction */ |
1371 | static inline void tcp_write_queue_purge(struct sock *sk) | 1216 | static inline void tcp_write_queue_purge(struct sock *sk) |
@@ -1378,24 +1223,22 @@ static inline void tcp_write_queue_purge(struct sock *sk) | |||
1378 | tcp_clear_all_retrans_hints(tcp_sk(sk)); | 1223 | tcp_clear_all_retrans_hints(tcp_sk(sk)); |
1379 | } | 1224 | } |
1380 | 1225 | ||
1381 | static inline struct sk_buff *tcp_write_queue_head(const struct sock *sk) | 1226 | static inline struct sk_buff *tcp_write_queue_head(struct sock *sk) |
1382 | { | 1227 | { |
1383 | return skb_peek(&sk->sk_write_queue); | 1228 | return skb_peek(&sk->sk_write_queue); |
1384 | } | 1229 | } |
1385 | 1230 | ||
1386 | static inline struct sk_buff *tcp_write_queue_tail(const struct sock *sk) | 1231 | static inline struct sk_buff *tcp_write_queue_tail(struct sock *sk) |
1387 | { | 1232 | { |
1388 | return skb_peek_tail(&sk->sk_write_queue); | 1233 | return skb_peek_tail(&sk->sk_write_queue); |
1389 | } | 1234 | } |
1390 | 1235 | ||
1391 | static inline struct sk_buff *tcp_write_queue_next(const struct sock *sk, | 1236 | static inline struct sk_buff *tcp_write_queue_next(struct sock *sk, struct sk_buff *skb) |
1392 | const struct sk_buff *skb) | ||
1393 | { | 1237 | { |
1394 | return skb_queue_next(&sk->sk_write_queue, skb); | 1238 | return skb_queue_next(&sk->sk_write_queue, skb); |
1395 | } | 1239 | } |
1396 | 1240 | ||
1397 | static inline struct sk_buff *tcp_write_queue_prev(const struct sock *sk, | 1241 | static inline struct sk_buff *tcp_write_queue_prev(struct sock *sk, struct sk_buff *skb) |
1398 | const struct sk_buff *skb) | ||
1399 | { | 1242 | { |
1400 | return skb_queue_prev(&sk->sk_write_queue, skb); | 1243 | return skb_queue_prev(&sk->sk_write_queue, skb); |
1401 | } | 1244 | } |
@@ -1409,7 +1252,7 @@ static inline struct sk_buff *tcp_write_queue_prev(const struct sock *sk, | |||
1409 | #define tcp_for_write_queue_from_safe(skb, tmp, sk) \ | 1252 | #define tcp_for_write_queue_from_safe(skb, tmp, sk) \ |
1410 | skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) | 1253 | skb_queue_walk_from_safe(&(sk)->sk_write_queue, skb, tmp) |
1411 | 1254 | ||
1412 | static inline struct sk_buff *tcp_send_head(const struct sock *sk) | 1255 | static inline struct sk_buff *tcp_send_head(struct sock *sk) |
1413 | { | 1256 | { |
1414 | return sk->sk_send_head; | 1257 | return sk->sk_send_head; |
1415 | } | 1258 | } |
@@ -1420,7 +1263,7 @@ static inline bool tcp_skb_is_last(const struct sock *sk, | |||
1420 | return skb_queue_is_last(&sk->sk_write_queue, skb); | 1263 | return skb_queue_is_last(&sk->sk_write_queue, skb); |
1421 | } | 1264 | } |
1422 | 1265 | ||
1423 | static inline void tcp_advance_send_head(struct sock *sk, const struct sk_buff *skb) | 1266 | static inline void tcp_advance_send_head(struct sock *sk, struct sk_buff *skb) |
1424 | { | 1267 | { |
1425 | if (tcp_skb_is_last(sk, skb)) | 1268 | if (tcp_skb_is_last(sk, skb)) |
1426 | sk->sk_send_head = NULL; | 1269 | sk->sk_send_head = NULL; |
@@ -1486,7 +1329,7 @@ static inline void tcp_unlink_write_queue(struct sk_buff *skb, struct sock *sk) | |||
1486 | __skb_unlink(skb, &sk->sk_write_queue); | 1329 | __skb_unlink(skb, &sk->sk_write_queue); |
1487 | } | 1330 | } |
1488 | 1331 | ||
1489 | static inline bool tcp_write_queue_empty(struct sock *sk) | 1332 | static inline int tcp_write_queue_empty(struct sock *sk) |
1490 | { | 1333 | { |
1491 | return skb_queue_empty(&sk->sk_write_queue); | 1334 | return skb_queue_empty(&sk->sk_write_queue); |
1492 | } | 1335 | } |
@@ -1500,9 +1343,8 @@ static inline void tcp_push_pending_frames(struct sock *sk) | |||
1500 | } | 1343 | } |
1501 | } | 1344 | } |
1502 | 1345 | ||
1503 | /* Start sequence of the skb just after the highest skb with SACKed | 1346 | /* Start sequence of the highest skb with SACKed bit, valid only if |
1504 | * bit, valid only if sacked_out > 0 or when the caller has ensured | 1347 | * sacked > 0 or when the caller has ensured validity by itself. |
1505 | * validity by itself. | ||
1506 | */ | 1348 | */ |
1507 | static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp) | 1349 | static inline u32 tcp_highest_sack_seq(struct tcp_sock *tp) |
1508 | { | 1350 | { |
@@ -1543,7 +1385,7 @@ static inline void tcp_highest_sack_combine(struct sock *sk, | |||
1543 | /* Determines whether this is a thin stream (which may suffer from | 1385 | /* Determines whether this is a thin stream (which may suffer from |
1544 | * increased latency). Used to trigger latency-reducing mechanisms. | 1386 | * increased latency). Used to trigger latency-reducing mechanisms. |
1545 | */ | 1387 | */ |
1546 | static inline bool tcp_stream_is_thin(struct tcp_sock *tp) | 1388 | static inline unsigned int tcp_stream_is_thin(struct tcp_sock *tp) |
1547 | { | 1389 | { |
1548 | return tp->packets_out < 4 && !tcp_in_initial_slowstart(tp); | 1390 | return tp->packets_out < 4 && !tcp_in_initial_slowstart(tp); |
1549 | } | 1391 | } |
@@ -1556,13 +1398,11 @@ enum tcp_seq_states { | |||
1556 | TCP_SEQ_STATE_TIME_WAIT, | 1398 | TCP_SEQ_STATE_TIME_WAIT, |
1557 | }; | 1399 | }; |
1558 | 1400 | ||
1559 | int tcp_seq_open(struct inode *inode, struct file *file); | ||
1560 | |||
1561 | struct tcp_seq_afinfo { | 1401 | struct tcp_seq_afinfo { |
1562 | char *name; | 1402 | char *name; |
1563 | sa_family_t family; | 1403 | sa_family_t family; |
1564 | const struct file_operations *seq_fops; | 1404 | struct file_operations seq_fops; |
1565 | struct seq_operations seq_ops; | 1405 | struct seq_operations seq_ops; |
1566 | }; | 1406 | }; |
1567 | 1407 | ||
1568 | struct tcp_iter_state { | 1408 | struct tcp_iter_state { |
@@ -1570,8 +1410,7 @@ struct tcp_iter_state { | |||
1570 | sa_family_t family; | 1410 | sa_family_t family; |
1571 | enum tcp_seq_states state; | 1411 | enum tcp_seq_states state; |
1572 | struct sock *syn_wait_sk; | 1412 | struct sock *syn_wait_sk; |
1573 | int bucket, offset, sbucket, num; | 1413 | int bucket, offset, sbucket, num, uid; |
1574 | kuid_t uid; | ||
1575 | loff_t last_pos; | 1414 | loff_t last_pos; |
1576 | }; | 1415 | }; |
1577 | 1416 | ||
@@ -1584,8 +1423,7 @@ extern struct request_sock_ops tcp6_request_sock_ops; | |||
1584 | extern void tcp_v4_destroy_sock(struct sock *sk); | 1423 | extern void tcp_v4_destroy_sock(struct sock *sk); |
1585 | 1424 | ||
1586 | extern int tcp_v4_gso_send_check(struct sk_buff *skb); | 1425 | extern int tcp_v4_gso_send_check(struct sk_buff *skb); |
1587 | extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, | 1426 | extern struct sk_buff *tcp_tso_segment(struct sk_buff *skb, u32 features); |
1588 | netdev_features_t features); | ||
1589 | extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, | 1427 | extern struct sk_buff **tcp_gro_receive(struct sk_buff **head, |
1590 | struct sk_buff *skb); | 1428 | struct sk_buff *skb); |
1591 | extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, | 1429 | extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, |
@@ -1593,6 +1431,8 @@ extern struct sk_buff **tcp4_gro_receive(struct sk_buff **head, | |||
1593 | extern int tcp_gro_complete(struct sk_buff *skb); | 1431 | extern int tcp_gro_complete(struct sk_buff *skb); |
1594 | extern int tcp4_gro_complete(struct sk_buff *skb); | 1432 | extern int tcp4_gro_complete(struct sk_buff *skb); |
1595 | 1433 | ||
1434 | extern int tcp_nuke_addr(struct net *net, struct sockaddr *addr); | ||
1435 | |||
1596 | #ifdef CONFIG_PROC_FS | 1436 | #ifdef CONFIG_PROC_FS |
1597 | extern int tcp4_proc_init(void); | 1437 | extern int tcp4_proc_init(void); |
1598 | extern void tcp4_proc_exit(void); | 1438 | extern void tcp4_proc_exit(void); |
@@ -1605,9 +1445,13 @@ struct tcp_sock_af_ops { | |||
1605 | struct sock *addr_sk); | 1445 | struct sock *addr_sk); |
1606 | int (*calc_md5_hash) (char *location, | 1446 | int (*calc_md5_hash) (char *location, |
1607 | struct tcp_md5sig_key *md5, | 1447 | struct tcp_md5sig_key *md5, |
1608 | const struct sock *sk, | 1448 | struct sock *sk, |
1609 | const struct request_sock *req, | 1449 | struct request_sock *req, |
1610 | const struct sk_buff *skb); | 1450 | struct sk_buff *skb); |
1451 | int (*md5_add) (struct sock *sk, | ||
1452 | struct sock *addr_sk, | ||
1453 | u8 *newkey, | ||
1454 | u8 len); | ||
1611 | int (*md5_parse) (struct sock *sk, | 1455 | int (*md5_parse) (struct sock *sk, |
1612 | char __user *optval, | 1456 | char __user *optval, |
1613 | int optlen); | 1457 | int optlen); |
@@ -1620,9 +1464,9 @@ struct tcp_request_sock_ops { | |||
1620 | struct request_sock *req); | 1464 | struct request_sock *req); |
1621 | int (*calc_md5_hash) (char *location, | 1465 | int (*calc_md5_hash) (char *location, |
1622 | struct tcp_md5sig_key *md5, | 1466 | struct tcp_md5sig_key *md5, |
1623 | const struct sock *sk, | 1467 | struct sock *sk, |
1624 | const struct request_sock *req, | 1468 | struct request_sock *req, |
1625 | const struct sk_buff *skb); | 1469 | struct sk_buff *skb); |
1626 | #endif | 1470 | #endif |
1627 | }; | 1471 | }; |
1628 | 1472 | ||
diff --git a/include/net/tcp_memcontrol.h b/include/net/tcp_memcontrol.h deleted file mode 100644 index 7df18bc43a9..00000000000 --- a/include/net/tcp_memcontrol.h +++ /dev/null | |||
@@ -1,19 +0,0 @@ | |||
1 | #ifndef _TCP_MEMCG_H | ||
2 | #define _TCP_MEMCG_H | ||
3 | |||
4 | struct tcp_memcontrol { | ||
5 | struct cg_proto cg_proto; | ||
6 | /* per-cgroup tcp memory pressure knobs */ | ||
7 | struct res_counter tcp_memory_allocated; | ||
8 | struct percpu_counter tcp_sockets_allocated; | ||
9 | /* those two are read-mostly, leave them at the end */ | ||
10 | long tcp_prot_mem[3]; | ||
11 | int tcp_memory_pressure; | ||
12 | }; | ||
13 | |||
14 | struct cg_proto *tcp_proto_cgroup(struct mem_cgroup *memcg); | ||
15 | int tcp_init_cgroup(struct mem_cgroup *memcg, struct cgroup_subsys *ss); | ||
16 | void tcp_destroy_cgroup(struct mem_cgroup *memcg); | ||
17 | unsigned long long tcp_max_memory(const struct mem_cgroup *memcg); | ||
18 | void tcp_prot_mem(struct mem_cgroup *memcg, long val, int idx); | ||
19 | #endif /* _TCP_MEMCG_H */ | ||
diff --git a/include/net/timewait_sock.h b/include/net/timewait_sock.h index 68f0ecad6c6..053b3cf2c66 100644 --- a/include/net/timewait_sock.h +++ b/include/net/timewait_sock.h | |||
@@ -12,7 +12,6 @@ | |||
12 | #define _TIMEWAIT_SOCK_H | 12 | #define _TIMEWAIT_SOCK_H |
13 | 13 | ||
14 | #include <linux/slab.h> | 14 | #include <linux/slab.h> |
15 | #include <linux/bug.h> | ||
16 | #include <net/sock.h> | 15 | #include <net/sock.h> |
17 | 16 | ||
18 | struct timewait_sock_ops { | 17 | struct timewait_sock_ops { |
@@ -22,6 +21,7 @@ struct timewait_sock_ops { | |||
22 | int (*twsk_unique)(struct sock *sk, | 21 | int (*twsk_unique)(struct sock *sk, |
23 | struct sock *sktw, void *twp); | 22 | struct sock *sktw, void *twp); |
24 | void (*twsk_destructor)(struct sock *sk); | 23 | void (*twsk_destructor)(struct sock *sk); |
24 | void *(*twsk_getpeer)(struct sock *sk); | ||
25 | }; | 25 | }; |
26 | 26 | ||
27 | 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) |
@@ -40,4 +40,11 @@ static inline void twsk_destructor(struct sock *sk) | |||
40 | sk->sk_prot->twsk_prot->twsk_destructor(sk); | 40 | sk->sk_prot->twsk_prot->twsk_destructor(sk); |
41 | } | 41 | } |
42 | 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 | |||
43 | #endif /* _TIMEWAIT_SOCK_H */ | 50 | #endif /* _TIMEWAIT_SOCK_H */ |
diff --git a/include/net/udp.h b/include/net/udp.h index 065f379c650..67ea6fcb3ec 100644 --- a/include/net/udp.h +++ b/include/net/udp.h | |||
@@ -23,7 +23,6 @@ | |||
23 | #define _UDP_H | 23 | #define _UDP_H |
24 | 24 | ||
25 | #include <linux/list.h> | 25 | #include <linux/list.h> |
26 | #include <linux/bug.h> | ||
27 | #include <net/inet_sock.h> | 26 | #include <net/inet_sock.h> |
28 | #include <net/sock.h> | 27 | #include <net/sock.h> |
29 | #include <net/snmp.h> | 28 | #include <net/snmp.h> |
@@ -42,7 +41,7 @@ | |||
42 | struct udp_skb_cb { | 41 | struct udp_skb_cb { |
43 | union { | 42 | union { |
44 | struct inet_skb_parm h4; | 43 | struct inet_skb_parm h4; |
45 | #if IS_ENABLED(CONFIG_IPV6) | 44 | #if defined(CONFIG_IPV6) || defined (CONFIG_IPV6_MODULE) |
46 | struct inet6_skb_parm h6; | 45 | struct inet6_skb_parm h6; |
47 | #endif | 46 | #endif |
48 | } header; | 47 | } header; |
@@ -81,7 +80,7 @@ struct udp_table { | |||
81 | extern struct udp_table udp_table; | 80 | extern struct udp_table udp_table; |
82 | extern void udp_table_init(struct udp_table *, const char *); | 81 | extern void udp_table_init(struct udp_table *, const char *); |
83 | static inline struct udp_hslot *udp_hashslot(struct udp_table *table, | 82 | static inline struct udp_hslot *udp_hashslot(struct udp_table *table, |
84 | struct net *net, unsigned int num) | 83 | struct net *net, unsigned num) |
85 | { | 84 | { |
86 | return &table->hash[udp_hashfn(net, num, table->mask)]; | 85 | return &table->hash[udp_hashfn(net, num, table->mask)]; |
87 | } | 86 | } |
@@ -195,15 +194,9 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
195 | 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, |
196 | __be32 daddr, __be16 dport, | 195 | __be32 daddr, __be16 dport, |
197 | int dif); | 196 | int dif); |
198 | extern struct sock *__udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, | ||
199 | __be32 daddr, __be16 dport, | ||
200 | int dif, struct udp_table *tbl); | ||
201 | extern struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, | 197 | extern struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, |
202 | const struct in6_addr *daddr, __be16 dport, | 198 | const struct in6_addr *daddr, __be16 dport, |
203 | int dif); | 199 | int dif); |
204 | extern struct sock *__udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, | ||
205 | const struct in6_addr *daddr, __be16 dport, | ||
206 | int dif, struct udp_table *tbl); | ||
207 | 200 | ||
208 | /* | 201 | /* |
209 | * SNMP statistics for UDP and UDP-Lite | 202 | * SNMP statistics for UDP and UDP-Lite |
@@ -224,7 +217,7 @@ extern struct sock *__udp6_lib_lookup(struct net *net, const struct in6_addr *sa | |||
224 | else SNMP_INC_STATS_USER((net)->mib.udp_stats_in6, field); \ | 217 | else SNMP_INC_STATS_USER((net)->mib.udp_stats_in6, field); \ |
225 | } while(0) | 218 | } while(0) |
226 | 219 | ||
227 | #if IS_ENABLED(CONFIG_IPV6) | 220 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
228 | #define UDPX_INC_STATS_BH(sk, field) \ | 221 | #define UDPX_INC_STATS_BH(sk, field) \ |
229 | do { \ | 222 | do { \ |
230 | if ((sk)->sk_family == AF_INET) \ | 223 | if ((sk)->sk_family == AF_INET) \ |
@@ -237,14 +230,12 @@ extern struct sock *__udp6_lib_lookup(struct net *net, const struct in6_addr *sa | |||
237 | #endif | 230 | #endif |
238 | 231 | ||
239 | /* /proc */ | 232 | /* /proc */ |
240 | int udp_seq_open(struct inode *inode, struct file *file); | ||
241 | |||
242 | struct udp_seq_afinfo { | 233 | struct udp_seq_afinfo { |
243 | char *name; | 234 | char *name; |
244 | sa_family_t family; | 235 | sa_family_t family; |
245 | struct udp_table *udp_table; | 236 | struct udp_table *udp_table; |
246 | const struct file_operations *seq_fops; | 237 | struct file_operations seq_fops; |
247 | struct seq_operations seq_ops; | 238 | struct seq_operations seq_ops; |
248 | }; | 239 | }; |
249 | 240 | ||
250 | struct udp_iter_state { | 241 | struct udp_iter_state { |
@@ -265,10 +256,5 @@ extern void udp4_proc_exit(void); | |||
265 | extern void udp_init(void); | 256 | extern void udp_init(void); |
266 | 257 | ||
267 | extern int udp4_ufo_send_check(struct sk_buff *skb); | 258 | extern int udp4_ufo_send_check(struct sk_buff *skb); |
268 | extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, | 259 | extern struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb, u32 features); |
269 | netdev_features_t features); | ||
270 | extern void udp_encap_enable(void); | ||
271 | #if IS_ENABLED(CONFIG_IPV6) | ||
272 | extern void udpv6_encap_enable(void); | ||
273 | #endif | ||
274 | #endif /* _UDP_H */ | 260 | #endif /* _UDP_H */ |
diff --git a/include/net/udplite.h b/include/net/udplite.h index 71375459a88..5f097ca7d5c 100644 --- a/include/net/udplite.h +++ b/include/net/udplite.h | |||
@@ -40,7 +40,7 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh) | |||
40 | * checksum. UDP-Lite (like IPv6) mandates checksums, hence packets | 40 | * checksum. UDP-Lite (like IPv6) mandates checksums, hence packets |
41 | * with a zero checksum field are illegal. */ | 41 | * with a zero checksum field are illegal. */ |
42 | if (uh->check == 0) { | 42 | if (uh->check == 0) { |
43 | LIMIT_NETDEBUG(KERN_DEBUG "UDPLite: zeroed checksum field\n"); | 43 | LIMIT_NETDEBUG(KERN_DEBUG "UDPLITE: zeroed checksum field\n"); |
44 | return 1; | 44 | return 1; |
45 | } | 45 | } |
46 | 46 | ||
@@ -52,7 +52,7 @@ static inline int udplite_checksum_init(struct sk_buff *skb, struct udphdr *uh) | |||
52 | /* | 52 | /* |
53 | * Coverage length violates RFC 3828: log and discard silently. | 53 | * Coverage length violates RFC 3828: log and discard silently. |
54 | */ | 54 | */ |
55 | LIMIT_NETDEBUG(KERN_DEBUG "UDPLite: bad csum coverage %d/%d\n", | 55 | LIMIT_NETDEBUG(KERN_DEBUG "UDPLITE: bad csum coverage %d/%d\n", |
56 | cscov, skb->len); | 56 | cscov, skb->len); |
57 | return 1; | 57 | return 1; |
58 | 58 | ||
diff --git a/include/net/wimax.h b/include/net/wimax.h index bbb74f990ca..322ff4fbdb4 100644 --- a/include/net/wimax.h +++ b/include/net/wimax.h | |||
@@ -423,8 +423,8 @@ struct wimax_dev { | |||
423 | int (*op_reset)(struct wimax_dev *wimax_dev); | 423 | int (*op_reset)(struct wimax_dev *wimax_dev); |
424 | 424 | ||
425 | struct rfkill *rfkill; | 425 | struct rfkill *rfkill; |
426 | unsigned int rf_hw; | 426 | unsigned rf_hw; |
427 | unsigned int rf_sw; | 427 | unsigned rf_sw; |
428 | char name[32]; | 428 | char name[32]; |
429 | 429 | ||
430 | struct dentry *debugfs_dentry; | 430 | struct dentry *debugfs_dentry; |
diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h index b52bda8d13b..d86fffd3c03 100644 --- a/include/net/wpan-phy.h +++ b/include/net/wpan-phy.h | |||
@@ -23,15 +23,6 @@ | |||
23 | 23 | ||
24 | #include <linux/netdevice.h> | 24 | #include <linux/netdevice.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/bug.h> | ||
27 | |||
28 | /* According to the IEEE 802.15.4 stadard the upper most significant bits of | ||
29 | * the 32-bit channel bitmaps shall be used as an integer value to specify 32 | ||
30 | * possible channel pages. The lower 27 bits of the channel bit map shall be | ||
31 | * used as a bit mask to specify channel numbers within a channel page. | ||
32 | */ | ||
33 | #define WPAN_NUM_CHANNELS 27 | ||
34 | #define WPAN_NUM_PAGES 32 | ||
35 | 26 | ||
36 | struct wpan_phy { | 27 | struct wpan_phy { |
37 | struct mutex pib_lock; | 28 | struct mutex pib_lock; |
@@ -51,7 +42,7 @@ struct wpan_phy { | |||
51 | int idx; | 42 | int idx; |
52 | 43 | ||
53 | struct net_device *(*add_iface)(struct wpan_phy *phy, | 44 | struct net_device *(*add_iface)(struct wpan_phy *phy, |
54 | const char *name, int type); | 45 | const char *name); |
55 | void (*del_iface)(struct wpan_phy *phy, struct net_device *dev); | 46 | void (*del_iface)(struct wpan_phy *phy, struct net_device *dev); |
56 | 47 | ||
57 | char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); | 48 | char priv[0] __attribute__((__aligned__(NETDEV_ALIGN))); |
diff --git a/include/net/x25.h b/include/net/x25.h index b4a8a892312..a06119a0512 100644 --- a/include/net/x25.h +++ b/include/net/x25.h | |||
@@ -305,7 +305,7 @@ static inline void x25_unregister_sysctl(void) {}; | |||
305 | #endif /* CONFIG_SYSCTL */ | 305 | #endif /* CONFIG_SYSCTL */ |
306 | 306 | ||
307 | struct x25_skb_cb { | 307 | struct x25_skb_cb { |
308 | unsigned int flags; | 308 | unsigned flags; |
309 | }; | 309 | }; |
310 | #define X25_SKB_CB(s) ((struct x25_skb_cb *) ((s)->cb)) | 310 | #define X25_SKB_CB(s) ((struct x25_skb_cb *) ((s)->cb)) |
311 | 311 | ||
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 63445ede48b..b203e14d26b 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -213,9 +213,6 @@ struct xfrm_state { | |||
213 | struct xfrm_lifetime_cur curlft; | 213 | struct xfrm_lifetime_cur curlft; |
214 | struct tasklet_hrtimer mtimer; | 214 | struct tasklet_hrtimer mtimer; |
215 | 215 | ||
216 | /* used to fix curlft->add_time when changing date */ | ||
217 | long saved_tmo; | ||
218 | |||
219 | /* Last used time */ | 216 | /* Last used time */ |
220 | unsigned long lastused; | 217 | unsigned long lastused; |
221 | 218 | ||
@@ -241,7 +238,6 @@ static inline struct net *xs_net(struct xfrm_state *x) | |||
241 | 238 | ||
242 | /* xflags - make enum if more show up */ | 239 | /* xflags - make enum if more show up */ |
243 | #define XFRM_TIME_DEFER 1 | 240 | #define XFRM_TIME_DEFER 1 |
244 | #define XFRM_SOFT_EXPIRE 2 | ||
245 | 241 | ||
246 | enum { | 242 | enum { |
247 | XFRM_STATE_VOID, | 243 | XFRM_STATE_VOID, |
@@ -263,7 +259,7 @@ struct km_event { | |||
263 | } data; | 259 | } data; |
264 | 260 | ||
265 | u32 seq; | 261 | u32 seq; |
266 | u32 portid; | 262 | u32 pid; |
267 | u32 event; | 263 | u32 event; |
268 | struct net *net; | 264 | struct net *net; |
269 | }; | 265 | }; |
@@ -273,9 +269,6 @@ struct xfrm_replay { | |||
273 | int (*check)(struct xfrm_state *x, | 269 | int (*check)(struct xfrm_state *x, |
274 | struct sk_buff *skb, | 270 | struct sk_buff *skb, |
275 | __be32 net_seq); | 271 | __be32 net_seq); |
276 | int (*recheck)(struct xfrm_state *x, | ||
277 | struct sk_buff *skb, | ||
278 | __be32 net_seq); | ||
279 | void (*notify)(struct xfrm_state *x, int event); | 272 | void (*notify)(struct xfrm_state *x, int event); |
280 | int (*overflow)(struct xfrm_state *x, struct sk_buff *skb); | 273 | int (*overflow)(struct xfrm_state *x, struct sk_buff *skb); |
281 | }; | 274 | }; |
@@ -295,8 +288,6 @@ struct xfrm_policy_afinfo { | |||
295 | struct flowi *fl, | 288 | struct flowi *fl, |
296 | int reverse); | 289 | int reverse); |
297 | int (*get_tos)(const struct flowi *fl); | 290 | int (*get_tos)(const struct flowi *fl); |
298 | void (*init_dst)(struct net *net, | ||
299 | struct xfrm_dst *dst); | ||
300 | int (*init_path)(struct xfrm_dst *path, | 291 | int (*init_path)(struct xfrm_dst *path, |
301 | struct dst_entry *dst, | 292 | struct dst_entry *dst, |
302 | int nfheader_len); | 293 | int nfheader_len); |
@@ -313,7 +304,7 @@ extern void km_state_notify(struct xfrm_state *x, const struct km_event *c); | |||
313 | 304 | ||
314 | struct xfrm_tmpl; | 305 | struct xfrm_tmpl; |
315 | 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); |
316 | extern void km_state_expired(struct xfrm_state *x, int hard, u32 portid); | 307 | extern void km_state_expired(struct xfrm_state *x, int hard, u32 pid); |
317 | extern int __xfrm_state_delete(struct xfrm_state *x); | 308 | extern int __xfrm_state_delete(struct xfrm_state *x); |
318 | 309 | ||
319 | struct xfrm_state_afinfo { | 310 | struct xfrm_state_afinfo { |
@@ -576,7 +567,7 @@ struct xfrm_mgr { | |||
576 | struct list_head list; | 567 | struct list_head list; |
577 | char *id; | 568 | char *id; |
578 | int (*notify)(struct xfrm_state *x, const struct km_event *c); | 569 | int (*notify)(struct xfrm_state *x, const struct km_event *c); |
579 | int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp); | 570 | int (*acquire)(struct xfrm_state *x, struct xfrm_tmpl *, struct xfrm_policy *xp, int dir); |
580 | 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); |
581 | 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); |
582 | int (*notify_policy)(struct xfrm_policy *x, int dir, const struct km_event *c); | 573 | int (*notify_policy)(struct xfrm_policy *x, int dir, const struct km_event *c); |
@@ -671,7 +662,7 @@ struct xfrm_spi_skb_cb { | |||
671 | /* Audit Information */ | 662 | /* Audit Information */ |
672 | struct xfrm_audit { | 663 | struct xfrm_audit { |
673 | u32 secid; | 664 | u32 secid; |
674 | kuid_t loginuid; | 665 | uid_t loginuid; |
675 | u32 sessionid; | 666 | u32 sessionid; |
676 | }; | 667 | }; |
677 | 668 | ||
@@ -690,14 +681,13 @@ static inline struct audit_buffer *xfrm_audit_start(const char *op) | |||
690 | return audit_buf; | 681 | return audit_buf; |
691 | } | 682 | } |
692 | 683 | ||
693 | static inline void xfrm_audit_helper_usrinfo(kuid_t auid, u32 ses, u32 secid, | 684 | static inline void xfrm_audit_helper_usrinfo(uid_t auid, u32 ses, u32 secid, |
694 | struct audit_buffer *audit_buf) | 685 | struct audit_buffer *audit_buf) |
695 | { | 686 | { |
696 | char *secctx; | 687 | char *secctx; |
697 | u32 secctx_len; | 688 | u32 secctx_len; |
698 | 689 | ||
699 | audit_log_format(audit_buf, " auid=%u ses=%u", | 690 | audit_log_format(audit_buf, " auid=%u ses=%u", auid, ses); |
700 | from_kuid(&init_user_ns, auid), ses); | ||
701 | if (secid != 0 && | 691 | if (secid != 0 && |
702 | security_secid_to_secctx(secid, &secctx, &secctx_len) == 0) { | 692 | security_secid_to_secctx(secid, &secctx, &secctx_len) == 0) { |
703 | audit_log_format(audit_buf, " subj=%s", secctx); | 693 | audit_log_format(audit_buf, " subj=%s", secctx); |
@@ -707,13 +697,13 @@ static inline void xfrm_audit_helper_usrinfo(kuid_t auid, u32 ses, u32 secid, | |||
707 | } | 697 | } |
708 | 698 | ||
709 | extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, | 699 | extern void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, |
710 | kuid_t auid, u32 ses, u32 secid); | 700 | u32 auid, u32 ses, u32 secid); |
711 | extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, | 701 | extern void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, |
712 | kuid_t auid, u32 ses, u32 secid); | 702 | u32 auid, u32 ses, u32 secid); |
713 | extern void xfrm_audit_state_add(struct xfrm_state *x, int result, | 703 | extern void xfrm_audit_state_add(struct xfrm_state *x, int result, |
714 | kuid_t auid, u32 ses, u32 secid); | 704 | u32 auid, u32 ses, u32 secid); |
715 | extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, | 705 | extern void xfrm_audit_state_delete(struct xfrm_state *x, int result, |
716 | kuid_t auid, u32 ses, u32 secid); | 706 | u32 auid, u32 ses, u32 secid); |
717 | extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, | 707 | extern void xfrm_audit_state_replay_overflow(struct xfrm_state *x, |
718 | struct sk_buff *skb); | 708 | struct sk_buff *skb); |
719 | extern void xfrm_audit_state_replay(struct xfrm_state *x, | 709 | extern void xfrm_audit_state_replay(struct xfrm_state *x, |
@@ -726,22 +716,22 @@ extern void xfrm_audit_state_icvfail(struct xfrm_state *x, | |||
726 | #else | 716 | #else |
727 | 717 | ||
728 | static inline void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, | 718 | static inline void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, |
729 | kuid_t auid, u32 ses, u32 secid) | 719 | u32 auid, u32 ses, u32 secid) |
730 | { | 720 | { |
731 | } | 721 | } |
732 | 722 | ||
733 | static inline void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, | 723 | static inline void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, |
734 | kuid_t auid, u32 ses, u32 secid) | 724 | u32 auid, u32 ses, u32 secid) |
735 | { | 725 | { |
736 | } | 726 | } |
737 | 727 | ||
738 | static inline void xfrm_audit_state_add(struct xfrm_state *x, int result, | 728 | static inline void xfrm_audit_state_add(struct xfrm_state *x, int result, |
739 | kuid_t auid, u32 ses, u32 secid) | 729 | u32 auid, u32 ses, u32 secid) |
740 | { | 730 | { |
741 | } | 731 | } |
742 | 732 | ||
743 | static inline void xfrm_audit_state_delete(struct xfrm_state *x, int result, | 733 | static inline void xfrm_audit_state_delete(struct xfrm_state *x, int result, |
744 | kuid_t auid, u32 ses, u32 secid) | 734 | u32 auid, u32 ses, u32 secid) |
745 | { | 735 | { |
746 | } | 736 | } |
747 | 737 | ||
@@ -837,14 +827,6 @@ static inline bool addr_match(const void *token1, const void *token2, | |||
837 | return true; | 827 | return true; |
838 | } | 828 | } |
839 | 829 | ||
840 | static inline bool addr4_match(__be32 a1, __be32 a2, u8 prefixlen) | ||
841 | { | ||
842 | /* C99 6.5.7 (3): u32 << 32 is undefined behaviour */ | ||
843 | if (prefixlen == 0) | ||
844 | return true; | ||
845 | return !((a1 ^ a2) & htonl(0xFFFFFFFFu << (32 - prefixlen))); | ||
846 | } | ||
847 | |||
848 | static __inline__ | 830 | static __inline__ |
849 | __be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli) | 831 | __be16 xfrm_flowi_sport(const struct flowi *fl, const union flowi_uli *uli) |
850 | { | 832 | { |
@@ -896,15 +878,15 @@ __be16 xfrm_flowi_dport(const struct flowi *fl, const union flowi_uli *uli) | |||
896 | return port; | 878 | return port; |
897 | } | 879 | } |
898 | 880 | ||
899 | extern bool xfrm_selector_match(const struct xfrm_selector *sel, | 881 | extern int xfrm_selector_match(const struct xfrm_selector *sel, |
900 | const struct flowi *fl, | 882 | const struct flowi *fl, |
901 | unsigned short family); | 883 | unsigned short family); |
902 | 884 | ||
903 | #ifdef CONFIG_SECURITY_NETWORK_XFRM | 885 | #ifdef CONFIG_SECURITY_NETWORK_XFRM |
904 | /* If neither has a context --> match | 886 | /* If neither has a context --> match |
905 | * Otherwise, both must have a context and the sids, doi, alg must match | 887 | * Otherwise, both must have a context and the sids, doi, alg must match |
906 | */ | 888 | */ |
907 | static inline bool xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2) | 889 | static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2) |
908 | { | 890 | { |
909 | return ((!s1 && !s2) || | 891 | return ((!s1 && !s2) || |
910 | (s1 && s2 && | 892 | (s1 && s2 && |
@@ -913,9 +895,9 @@ static inline bool xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_c | |||
913 | (s1->ctx_alg == s2->ctx_alg))); | 895 | (s1->ctx_alg == s2->ctx_alg))); |
914 | } | 896 | } |
915 | #else | 897 | #else |
916 | static inline bool xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2) | 898 | static inline int xfrm_sec_ctx_match(struct xfrm_sec_ctx *s1, struct xfrm_sec_ctx *s2) |
917 | { | 899 | { |
918 | return true; | 900 | return 1; |
919 | } | 901 | } |
920 | #endif | 902 | #endif |
921 | 903 | ||
@@ -1227,8 +1209,8 @@ void xfrm_flowi_addr_get(const struct flowi *fl, | |||
1227 | memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4)); | 1209 | memcpy(&daddr->a4, &fl->u.ip4.daddr, sizeof(daddr->a4)); |
1228 | break; | 1210 | break; |
1229 | case AF_INET6: | 1211 | case AF_INET6: |
1230 | *(struct in6_addr *)saddr->a6 = fl->u.ip6.saddr; | 1212 | ipv6_addr_copy((struct in6_addr *)&saddr->a6, &fl->u.ip6.saddr); |
1231 | *(struct in6_addr *)daddr->a6 = fl->u.ip6.daddr; | 1213 | ipv6_addr_copy((struct in6_addr *)&daddr->a6, &fl->u.ip6.daddr); |
1232 | break; | 1214 | break; |
1233 | } | 1215 | } |
1234 | } | 1216 | } |
@@ -1351,7 +1333,7 @@ struct xfrm6_tunnel { | |||
1351 | }; | 1333 | }; |
1352 | 1334 | ||
1353 | extern void xfrm_init(void); | 1335 | extern void xfrm_init(void); |
1354 | extern void xfrm4_init(void); | 1336 | extern void xfrm4_init(int rt_hash_size); |
1355 | extern int xfrm_state_init(struct net *net); | 1337 | extern int xfrm_state_init(struct net *net); |
1356 | extern void xfrm_state_fini(struct net *net); | 1338 | extern void xfrm_state_fini(struct net *net); |
1357 | extern void xfrm4_state_init(void); | 1339 | extern void xfrm4_state_init(void); |
@@ -1485,8 +1467,6 @@ extern int xfrm4_output(struct sk_buff *skb); | |||
1485 | extern int xfrm4_output_finish(struct sk_buff *skb); | 1467 | extern int xfrm4_output_finish(struct sk_buff *skb); |
1486 | 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); |
1487 | 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); |
1488 | extern int xfrm4_mode_tunnel_input_register(struct xfrm_tunnel *handler); | ||
1489 | extern int xfrm4_mode_tunnel_input_deregister(struct xfrm_tunnel *handler); | ||
1490 | extern int xfrm6_extract_header(struct sk_buff *skb); | 1470 | extern int xfrm6_extract_header(struct sk_buff *skb); |
1491 | extern int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb); | 1471 | extern int xfrm6_extract_input(struct xfrm_state *x, struct sk_buff *skb); |
1492 | extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi); | 1472 | extern int xfrm6_rcv_spi(struct sk_buff *skb, int nexthdr, __be32 spi); |
@@ -1558,7 +1538,7 @@ extern int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type, | |||
1558 | #endif | 1538 | #endif |
1559 | 1539 | ||
1560 | extern int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); | 1540 | extern int km_new_mapping(struct xfrm_state *x, xfrm_address_t *ipaddr, __be16 sport); |
1561 | extern void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 portid); | 1541 | extern void km_policy_expired(struct xfrm_policy *pol, int dir, int hard, u32 pid); |
1562 | extern int km_report(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); | 1542 | extern int km_report(struct net *net, u8 proto, struct xfrm_selector *sel, xfrm_address_t *addr); |
1563 | 1543 | ||
1564 | extern void xfrm_input_init(void); | 1544 | extern void xfrm_input_init(void); |
@@ -1578,6 +1558,11 @@ extern struct xfrm_algo_desc *xfrm_calg_get_byname(const char *name, int probe); | |||
1578 | extern struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len, | 1558 | extern struct xfrm_algo_desc *xfrm_aead_get_byname(const char *name, int icv_len, |
1579 | int probe); | 1559 | int probe); |
1580 | 1560 | ||
1561 | struct hash_desc; | ||
1562 | struct scatterlist; | ||
1563 | typedef int (icv_update_fn_t)(struct hash_desc *, struct scatterlist *, | ||
1564 | unsigned int); | ||
1565 | |||
1581 | static inline int xfrm_addr_cmp(const xfrm_address_t *a, | 1566 | static inline int xfrm_addr_cmp(const xfrm_address_t *a, |
1582 | const xfrm_address_t *b, | 1567 | const xfrm_address_t *b, |
1583 | int family) | 1568 | int family) |
@@ -1694,11 +1679,12 @@ static inline int xfrm_mark_get(struct nlattr **attrs, struct xfrm_mark *m) | |||
1694 | 1679 | ||
1695 | static inline int xfrm_mark_put(struct sk_buff *skb, const struct xfrm_mark *m) | 1680 | static inline int xfrm_mark_put(struct sk_buff *skb, const struct xfrm_mark *m) |
1696 | { | 1681 | { |
1697 | int ret = 0; | ||
1698 | |||
1699 | if (m->m | m->v) | 1682 | if (m->m | m->v) |
1700 | ret = nla_put(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m); | 1683 | NLA_PUT(skb, XFRMA_MARK, sizeof(struct xfrm_mark), m); |
1701 | return ret; | 1684 | return 0; |
1685 | |||
1686 | nla_put_failure: | ||
1687 | return -1; | ||
1702 | } | 1688 | } |
1703 | 1689 | ||
1704 | #endif /* _NET_XFRM_H */ | 1690 | #endif /* _NET_XFRM_H */ |