diff options
Diffstat (limited to 'include/net')
48 files changed, 3530 insertions, 371 deletions
diff --git a/include/net/ax25.h b/include/net/ax25.h index 9dbcd9e51c00..2250a18b0cbb 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h | |||
@@ -171,7 +171,7 @@ typedef struct { | |||
171 | ax25_address calls[AX25_MAX_DIGIS]; | 171 | ax25_address calls[AX25_MAX_DIGIS]; |
172 | unsigned char repeated[AX25_MAX_DIGIS]; | 172 | unsigned char repeated[AX25_MAX_DIGIS]; |
173 | unsigned char ndigi; | 173 | unsigned char ndigi; |
174 | char lastrepeat; | 174 | signed char lastrepeat; |
175 | } ax25_digi; | 175 | } ax25_digi; |
176 | 176 | ||
177 | typedef struct ax25_route { | 177 | typedef struct ax25_route { |
@@ -237,8 +237,7 @@ typedef struct ax25_cb { | |||
237 | static __inline__ void ax25_cb_put(ax25_cb *ax25) | 237 | static __inline__ void ax25_cb_put(ax25_cb *ax25) |
238 | { | 238 | { |
239 | if (atomic_dec_and_test(&ax25->refcount)) { | 239 | if (atomic_dec_and_test(&ax25->refcount)) { |
240 | if (ax25->digipeat) | 240 | kfree(ax25->digipeat); |
241 | kfree(ax25->digipeat); | ||
242 | kfree(ax25); | 241 | kfree(ax25); |
243 | } | 242 | } |
244 | } | 243 | } |
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h index 6dfa4a61ffd0..911ceb5cd263 100644 --- a/include/net/bluetooth/bluetooth.h +++ b/include/net/bluetooth/bluetooth.h | |||
@@ -57,8 +57,6 @@ | |||
57 | #define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __FUNCTION__ , ## arg) | 57 | #define BT_DBG(fmt, arg...) printk(KERN_INFO "%s: " fmt "\n" , __FUNCTION__ , ## arg) |
58 | #define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __FUNCTION__ , ## arg) | 58 | #define BT_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n" , __FUNCTION__ , ## arg) |
59 | 59 | ||
60 | extern struct proc_dir_entry *proc_bt; | ||
61 | |||
62 | /* Connection and socket states */ | 60 | /* Connection and socket states */ |
63 | enum { | 61 | enum { |
64 | BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ | 62 | BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ |
@@ -136,7 +134,7 @@ struct bt_skb_cb { | |||
136 | }; | 134 | }; |
137 | #define bt_cb(skb) ((struct bt_skb_cb *)(skb->cb)) | 135 | #define bt_cb(skb) ((struct bt_skb_cb *)(skb->cb)) |
138 | 136 | ||
139 | static inline struct sk_buff *bt_skb_alloc(unsigned int len, unsigned int __nocast how) | 137 | static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how) |
140 | { | 138 | { |
141 | struct sk_buff *skb; | 139 | struct sk_buff *skb; |
142 | 140 | ||
@@ -171,4 +169,12 @@ static inline int skb_frags_no(struct sk_buff *skb) | |||
171 | 169 | ||
172 | int bt_err(__u16 code); | 170 | int bt_err(__u16 code); |
173 | 171 | ||
172 | extern int hci_sock_init(void); | ||
173 | extern int hci_sock_cleanup(void); | ||
174 | |||
175 | extern int bt_sysfs_init(void); | ||
176 | extern void bt_sysfs_cleanup(void); | ||
177 | |||
178 | extern struct class bt_class; | ||
179 | |||
174 | #endif /* __BLUETOOTH_H */ | 180 | #endif /* __BLUETOOTH_H */ |
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index fa2d12b0579b..b06a2d2f63d2 100644 --- a/include/net/bluetooth/hci.h +++ b/include/net/bluetooth/hci.h | |||
@@ -184,10 +184,10 @@ enum { | |||
184 | struct hci_rp_read_loc_version { | 184 | struct hci_rp_read_loc_version { |
185 | __u8 status; | 185 | __u8 status; |
186 | __u8 hci_ver; | 186 | __u8 hci_ver; |
187 | __u16 hci_rev; | 187 | __le16 hci_rev; |
188 | __u8 lmp_ver; | 188 | __u8 lmp_ver; |
189 | __u16 manufacturer; | 189 | __le16 manufacturer; |
190 | __u16 lmp_subver; | 190 | __le16 lmp_subver; |
191 | } __attribute__ ((packed)); | 191 | } __attribute__ ((packed)); |
192 | 192 | ||
193 | #define OCF_READ_LOCAL_FEATURES 0x0003 | 193 | #define OCF_READ_LOCAL_FEATURES 0x0003 |
@@ -199,10 +199,10 @@ struct hci_rp_read_loc_features { | |||
199 | #define OCF_READ_BUFFER_SIZE 0x0005 | 199 | #define OCF_READ_BUFFER_SIZE 0x0005 |
200 | struct hci_rp_read_buffer_size { | 200 | struct hci_rp_read_buffer_size { |
201 | __u8 status; | 201 | __u8 status; |
202 | __u16 acl_mtu; | 202 | __le16 acl_mtu; |
203 | __u8 sco_mtu; | 203 | __u8 sco_mtu; |
204 | __u16 acl_max_pkt; | 204 | __le16 acl_max_pkt; |
205 | __u16 sco_max_pkt; | 205 | __le16 sco_max_pkt; |
206 | } __attribute__ ((packed)); | 206 | } __attribute__ ((packed)); |
207 | 207 | ||
208 | #define OCF_READ_BD_ADDR 0x0009 | 208 | #define OCF_READ_BD_ADDR 0x0009 |
@@ -267,21 +267,21 @@ struct hci_cp_write_dev_class { | |||
267 | 267 | ||
268 | #define OCF_READ_VOICE_SETTING 0x0025 | 268 | #define OCF_READ_VOICE_SETTING 0x0025 |
269 | struct hci_rp_read_voice_setting { | 269 | struct hci_rp_read_voice_setting { |
270 | __u8 status; | 270 | __u8 status; |
271 | __u16 voice_setting; | 271 | __le16 voice_setting; |
272 | } __attribute__ ((packed)); | 272 | } __attribute__ ((packed)); |
273 | 273 | ||
274 | #define OCF_WRITE_VOICE_SETTING 0x0026 | 274 | #define OCF_WRITE_VOICE_SETTING 0x0026 |
275 | struct hci_cp_write_voice_setting { | 275 | struct hci_cp_write_voice_setting { |
276 | __u16 voice_setting; | 276 | __le16 voice_setting; |
277 | } __attribute__ ((packed)); | 277 | } __attribute__ ((packed)); |
278 | 278 | ||
279 | #define OCF_HOST_BUFFER_SIZE 0x0033 | 279 | #define OCF_HOST_BUFFER_SIZE 0x0033 |
280 | struct hci_cp_host_buffer_size { | 280 | struct hci_cp_host_buffer_size { |
281 | __u16 acl_mtu; | 281 | __le16 acl_mtu; |
282 | __u8 sco_mtu; | 282 | __u8 sco_mtu; |
283 | __u16 acl_max_pkt; | 283 | __le16 acl_max_pkt; |
284 | __u16 sco_max_pkt; | 284 | __le16 sco_max_pkt; |
285 | } __attribute__ ((packed)); | 285 | } __attribute__ ((packed)); |
286 | 286 | ||
287 | /* Link Control */ | 287 | /* Link Control */ |
@@ -289,10 +289,10 @@ struct hci_cp_host_buffer_size { | |||
289 | #define OCF_CREATE_CONN 0x0005 | 289 | #define OCF_CREATE_CONN 0x0005 |
290 | struct hci_cp_create_conn { | 290 | struct hci_cp_create_conn { |
291 | bdaddr_t bdaddr; | 291 | bdaddr_t bdaddr; |
292 | __u16 pkt_type; | 292 | __le16 pkt_type; |
293 | __u8 pscan_rep_mode; | 293 | __u8 pscan_rep_mode; |
294 | __u8 pscan_mode; | 294 | __u8 pscan_mode; |
295 | __u16 clock_offset; | 295 | __le16 clock_offset; |
296 | __u8 role_switch; | 296 | __u8 role_switch; |
297 | } __attribute__ ((packed)); | 297 | } __attribute__ ((packed)); |
298 | 298 | ||
@@ -310,14 +310,14 @@ struct hci_cp_reject_conn_req { | |||
310 | 310 | ||
311 | #define OCF_DISCONNECT 0x0006 | 311 | #define OCF_DISCONNECT 0x0006 |
312 | struct hci_cp_disconnect { | 312 | struct hci_cp_disconnect { |
313 | __u16 handle; | 313 | __le16 handle; |
314 | __u8 reason; | 314 | __u8 reason; |
315 | } __attribute__ ((packed)); | 315 | } __attribute__ ((packed)); |
316 | 316 | ||
317 | #define OCF_ADD_SCO 0x0007 | 317 | #define OCF_ADD_SCO 0x0007 |
318 | struct hci_cp_add_sco { | 318 | struct hci_cp_add_sco { |
319 | __u16 handle; | 319 | __le16 handle; |
320 | __u16 pkt_type; | 320 | __le16 pkt_type; |
321 | } __attribute__ ((packed)); | 321 | } __attribute__ ((packed)); |
322 | 322 | ||
323 | #define OCF_INQUIRY 0x0001 | 323 | #define OCF_INQUIRY 0x0001 |
@@ -354,56 +354,56 @@ struct hci_cp_pin_code_neg_reply { | |||
354 | 354 | ||
355 | #define OCF_CHANGE_CONN_PTYPE 0x000F | 355 | #define OCF_CHANGE_CONN_PTYPE 0x000F |
356 | struct hci_cp_change_conn_ptype { | 356 | struct hci_cp_change_conn_ptype { |
357 | __u16 handle; | 357 | __le16 handle; |
358 | __u16 pkt_type; | 358 | __le16 pkt_type; |
359 | } __attribute__ ((packed)); | 359 | } __attribute__ ((packed)); |
360 | 360 | ||
361 | #define OCF_AUTH_REQUESTED 0x0011 | 361 | #define OCF_AUTH_REQUESTED 0x0011 |
362 | struct hci_cp_auth_requested { | 362 | struct hci_cp_auth_requested { |
363 | __u16 handle; | 363 | __le16 handle; |
364 | } __attribute__ ((packed)); | 364 | } __attribute__ ((packed)); |
365 | 365 | ||
366 | #define OCF_SET_CONN_ENCRYPT 0x0013 | 366 | #define OCF_SET_CONN_ENCRYPT 0x0013 |
367 | struct hci_cp_set_conn_encrypt { | 367 | struct hci_cp_set_conn_encrypt { |
368 | __u16 handle; | 368 | __le16 handle; |
369 | __u8 encrypt; | 369 | __u8 encrypt; |
370 | } __attribute__ ((packed)); | 370 | } __attribute__ ((packed)); |
371 | 371 | ||
372 | #define OCF_CHANGE_CONN_LINK_KEY 0x0015 | 372 | #define OCF_CHANGE_CONN_LINK_KEY 0x0015 |
373 | struct hci_cp_change_conn_link_key { | 373 | struct hci_cp_change_conn_link_key { |
374 | __u16 handle; | 374 | __le16 handle; |
375 | } __attribute__ ((packed)); | 375 | } __attribute__ ((packed)); |
376 | 376 | ||
377 | #define OCF_READ_REMOTE_FEATURES 0x001B | 377 | #define OCF_READ_REMOTE_FEATURES 0x001B |
378 | struct hci_cp_read_rmt_features { | 378 | struct hci_cp_read_rmt_features { |
379 | __u16 handle; | 379 | __le16 handle; |
380 | } __attribute__ ((packed)); | 380 | } __attribute__ ((packed)); |
381 | 381 | ||
382 | #define OCF_READ_REMOTE_VERSION 0x001D | 382 | #define OCF_READ_REMOTE_VERSION 0x001D |
383 | struct hci_cp_read_rmt_version { | 383 | struct hci_cp_read_rmt_version { |
384 | __u16 handle; | 384 | __le16 handle; |
385 | } __attribute__ ((packed)); | 385 | } __attribute__ ((packed)); |
386 | 386 | ||
387 | /* Link Policy */ | 387 | /* Link Policy */ |
388 | #define OGF_LINK_POLICY 0x02 | 388 | #define OGF_LINK_POLICY 0x02 |
389 | #define OCF_ROLE_DISCOVERY 0x0009 | 389 | #define OCF_ROLE_DISCOVERY 0x0009 |
390 | struct hci_cp_role_discovery { | 390 | struct hci_cp_role_discovery { |
391 | __u16 handle; | 391 | __le16 handle; |
392 | } __attribute__ ((packed)); | 392 | } __attribute__ ((packed)); |
393 | struct hci_rp_role_discovery { | 393 | struct hci_rp_role_discovery { |
394 | __u8 status; | 394 | __u8 status; |
395 | __u16 handle; | 395 | __le16 handle; |
396 | __u8 role; | 396 | __u8 role; |
397 | } __attribute__ ((packed)); | 397 | } __attribute__ ((packed)); |
398 | 398 | ||
399 | #define OCF_READ_LINK_POLICY 0x000C | 399 | #define OCF_READ_LINK_POLICY 0x000C |
400 | struct hci_cp_read_link_policy { | 400 | struct hci_cp_read_link_policy { |
401 | __u16 handle; | 401 | __le16 handle; |
402 | } __attribute__ ((packed)); | 402 | } __attribute__ ((packed)); |
403 | struct hci_rp_read_link_policy { | 403 | struct hci_rp_read_link_policy { |
404 | __u8 status; | 404 | __u8 status; |
405 | __u16 handle; | 405 | __le16 handle; |
406 | __u16 policy; | 406 | __le16 policy; |
407 | } __attribute__ ((packed)); | 407 | } __attribute__ ((packed)); |
408 | 408 | ||
409 | #define OCF_SWITCH_ROLE 0x000B | 409 | #define OCF_SWITCH_ROLE 0x000B |
@@ -414,12 +414,12 @@ struct hci_cp_switch_role { | |||
414 | 414 | ||
415 | #define OCF_WRITE_LINK_POLICY 0x000D | 415 | #define OCF_WRITE_LINK_POLICY 0x000D |
416 | struct hci_cp_write_link_policy { | 416 | struct hci_cp_write_link_policy { |
417 | __u16 handle; | 417 | __le16 handle; |
418 | __u16 policy; | 418 | __le16 policy; |
419 | } __attribute__ ((packed)); | 419 | } __attribute__ ((packed)); |
420 | struct hci_rp_write_link_policy { | 420 | struct hci_rp_write_link_policy { |
421 | __u8 status; | 421 | __u8 status; |
422 | __u16 handle; | 422 | __le16 handle; |
423 | } __attribute__ ((packed)); | 423 | } __attribute__ ((packed)); |
424 | 424 | ||
425 | /* Status params */ | 425 | /* Status params */ |
@@ -441,7 +441,7 @@ struct inquiry_info { | |||
441 | __u8 pscan_period_mode; | 441 | __u8 pscan_period_mode; |
442 | __u8 pscan_mode; | 442 | __u8 pscan_mode; |
443 | __u8 dev_class[3]; | 443 | __u8 dev_class[3]; |
444 | __u16 clock_offset; | 444 | __le16 clock_offset; |
445 | } __attribute__ ((packed)); | 445 | } __attribute__ ((packed)); |
446 | 446 | ||
447 | #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22 | 447 | #define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22 |
@@ -450,7 +450,7 @@ struct inquiry_info_with_rssi { | |||
450 | __u8 pscan_rep_mode; | 450 | __u8 pscan_rep_mode; |
451 | __u8 pscan_period_mode; | 451 | __u8 pscan_period_mode; |
452 | __u8 dev_class[3]; | 452 | __u8 dev_class[3]; |
453 | __u16 clock_offset; | 453 | __le16 clock_offset; |
454 | __s8 rssi; | 454 | __s8 rssi; |
455 | } __attribute__ ((packed)); | 455 | } __attribute__ ((packed)); |
456 | struct inquiry_info_with_rssi_and_pscan_mode { | 456 | struct inquiry_info_with_rssi_and_pscan_mode { |
@@ -459,7 +459,7 @@ struct inquiry_info_with_rssi_and_pscan_mode { | |||
459 | __u8 pscan_period_mode; | 459 | __u8 pscan_period_mode; |
460 | __u8 pscan_mode; | 460 | __u8 pscan_mode; |
461 | __u8 dev_class[3]; | 461 | __u8 dev_class[3]; |
462 | __u16 clock_offset; | 462 | __le16 clock_offset; |
463 | __s8 rssi; | 463 | __s8 rssi; |
464 | } __attribute__ ((packed)); | 464 | } __attribute__ ((packed)); |
465 | 465 | ||
@@ -469,7 +469,7 @@ struct extended_inquiry_info { | |||
469 | __u8 pscan_rep_mode; | 469 | __u8 pscan_rep_mode; |
470 | __u8 pscan_period_mode; | 470 | __u8 pscan_period_mode; |
471 | __u8 dev_class[3]; | 471 | __u8 dev_class[3]; |
472 | __u16 clock_offset; | 472 | __le16 clock_offset; |
473 | __s8 rssi; | 473 | __s8 rssi; |
474 | __u8 data[240]; | 474 | __u8 data[240]; |
475 | } __attribute__ ((packed)); | 475 | } __attribute__ ((packed)); |
@@ -477,7 +477,7 @@ struct extended_inquiry_info { | |||
477 | #define HCI_EV_CONN_COMPLETE 0x03 | 477 | #define HCI_EV_CONN_COMPLETE 0x03 |
478 | struct hci_ev_conn_complete { | 478 | struct hci_ev_conn_complete { |
479 | __u8 status; | 479 | __u8 status; |
480 | __u16 handle; | 480 | __le16 handle; |
481 | bdaddr_t bdaddr; | 481 | bdaddr_t bdaddr; |
482 | __u8 link_type; | 482 | __u8 link_type; |
483 | __u8 encr_mode; | 483 | __u8 encr_mode; |
@@ -493,27 +493,27 @@ struct hci_ev_conn_request { | |||
493 | #define HCI_EV_DISCONN_COMPLETE 0x05 | 493 | #define HCI_EV_DISCONN_COMPLETE 0x05 |
494 | struct hci_ev_disconn_complete { | 494 | struct hci_ev_disconn_complete { |
495 | __u8 status; | 495 | __u8 status; |
496 | __u16 handle; | 496 | __le16 handle; |
497 | __u8 reason; | 497 | __u8 reason; |
498 | } __attribute__ ((packed)); | 498 | } __attribute__ ((packed)); |
499 | 499 | ||
500 | #define HCI_EV_AUTH_COMPLETE 0x06 | 500 | #define HCI_EV_AUTH_COMPLETE 0x06 |
501 | struct hci_ev_auth_complete { | 501 | struct hci_ev_auth_complete { |
502 | __u8 status; | 502 | __u8 status; |
503 | __u16 handle; | 503 | __le16 handle; |
504 | } __attribute__ ((packed)); | 504 | } __attribute__ ((packed)); |
505 | 505 | ||
506 | #define HCI_EV_ENCRYPT_CHANGE 0x08 | 506 | #define HCI_EV_ENCRYPT_CHANGE 0x08 |
507 | struct hci_ev_encrypt_change { | 507 | struct hci_ev_encrypt_change { |
508 | __u8 status; | 508 | __u8 status; |
509 | __u16 handle; | 509 | __le16 handle; |
510 | __u8 encrypt; | 510 | __u8 encrypt; |
511 | } __attribute__ ((packed)); | 511 | } __attribute__ ((packed)); |
512 | 512 | ||
513 | #define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 | 513 | #define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09 |
514 | struct hci_ev_change_conn_link_key_complete { | 514 | struct hci_ev_change_conn_link_key_complete { |
515 | __u8 status; | 515 | __u8 status; |
516 | __u16 handle; | 516 | __le16 handle; |
517 | } __attribute__ ((packed)); | 517 | } __attribute__ ((packed)); |
518 | 518 | ||
519 | #define HCI_EV_QOS_SETUP_COMPLETE 0x0D | 519 | #define HCI_EV_QOS_SETUP_COMPLETE 0x0D |
@@ -526,21 +526,21 @@ struct hci_qos { | |||
526 | } __attribute__ ((packed)); | 526 | } __attribute__ ((packed)); |
527 | struct hci_ev_qos_setup_complete { | 527 | struct hci_ev_qos_setup_complete { |
528 | __u8 status; | 528 | __u8 status; |
529 | __u16 handle; | 529 | __le16 handle; |
530 | struct hci_qos qos; | 530 | struct hci_qos qos; |
531 | } __attribute__ ((packed)); | 531 | } __attribute__ ((packed)); |
532 | 532 | ||
533 | #define HCI_EV_CMD_COMPLETE 0x0E | 533 | #define HCI_EV_CMD_COMPLETE 0x0E |
534 | struct hci_ev_cmd_complete { | 534 | struct hci_ev_cmd_complete { |
535 | __u8 ncmd; | 535 | __u8 ncmd; |
536 | __u16 opcode; | 536 | __le16 opcode; |
537 | } __attribute__ ((packed)); | 537 | } __attribute__ ((packed)); |
538 | 538 | ||
539 | #define HCI_EV_CMD_STATUS 0x0F | 539 | #define HCI_EV_CMD_STATUS 0x0F |
540 | struct hci_ev_cmd_status { | 540 | struct hci_ev_cmd_status { |
541 | __u8 status; | 541 | __u8 status; |
542 | __u8 ncmd; | 542 | __u8 ncmd; |
543 | __u16 opcode; | 543 | __le16 opcode; |
544 | } __attribute__ ((packed)); | 544 | } __attribute__ ((packed)); |
545 | 545 | ||
546 | #define HCI_EV_NUM_COMP_PKTS 0x13 | 546 | #define HCI_EV_NUM_COMP_PKTS 0x13 |
@@ -559,9 +559,9 @@ struct hci_ev_role_change { | |||
559 | #define HCI_EV_MODE_CHANGE 0x14 | 559 | #define HCI_EV_MODE_CHANGE 0x14 |
560 | struct hci_ev_mode_change { | 560 | struct hci_ev_mode_change { |
561 | __u8 status; | 561 | __u8 status; |
562 | __u16 handle; | 562 | __le16 handle; |
563 | __u8 mode; | 563 | __u8 mode; |
564 | __u16 interval; | 564 | __le16 interval; |
565 | } __attribute__ ((packed)); | 565 | } __attribute__ ((packed)); |
566 | 566 | ||
567 | #define HCI_EV_PIN_CODE_REQ 0x16 | 567 | #define HCI_EV_PIN_CODE_REQ 0x16 |
@@ -584,24 +584,24 @@ struct hci_ev_link_key_notify { | |||
584 | #define HCI_EV_RMT_FEATURES 0x0B | 584 | #define HCI_EV_RMT_FEATURES 0x0B |
585 | struct hci_ev_rmt_features { | 585 | struct hci_ev_rmt_features { |
586 | __u8 status; | 586 | __u8 status; |
587 | __u16 handle; | 587 | __le16 handle; |
588 | __u8 features[8]; | 588 | __u8 features[8]; |
589 | } __attribute__ ((packed)); | 589 | } __attribute__ ((packed)); |
590 | 590 | ||
591 | #define HCI_EV_RMT_VERSION 0x0C | 591 | #define HCI_EV_RMT_VERSION 0x0C |
592 | struct hci_ev_rmt_version { | 592 | struct hci_ev_rmt_version { |
593 | __u8 status; | 593 | __u8 status; |
594 | __u16 handle; | 594 | __le16 handle; |
595 | __u8 lmp_ver; | 595 | __u8 lmp_ver; |
596 | __u16 manufacturer; | 596 | __le16 manufacturer; |
597 | __u16 lmp_subver; | 597 | __le16 lmp_subver; |
598 | } __attribute__ ((packed)); | 598 | } __attribute__ ((packed)); |
599 | 599 | ||
600 | #define HCI_EV_CLOCK_OFFSET 0x01C | 600 | #define HCI_EV_CLOCK_OFFSET 0x01C |
601 | struct hci_ev_clock_offset { | 601 | struct hci_ev_clock_offset { |
602 | __u8 status; | 602 | __u8 status; |
603 | __u16 handle; | 603 | __le16 handle; |
604 | __u16 clock_offset; | 604 | __le16 clock_offset; |
605 | } __attribute__ ((packed)); | 605 | } __attribute__ ((packed)); |
606 | 606 | ||
607 | #define HCI_EV_PSCAN_REP_MODE 0x20 | 607 | #define HCI_EV_PSCAN_REP_MODE 0x20 |
@@ -638,7 +638,7 @@ struct hci_ev_si_security { | |||
638 | #define HCI_SCO_HDR_SIZE 3 | 638 | #define HCI_SCO_HDR_SIZE 3 |
639 | 639 | ||
640 | struct hci_command_hdr { | 640 | struct hci_command_hdr { |
641 | __u16 opcode; /* OCF & OGF */ | 641 | __le16 opcode; /* OCF & OGF */ |
642 | __u8 plen; | 642 | __u8 plen; |
643 | } __attribute__ ((packed)); | 643 | } __attribute__ ((packed)); |
644 | 644 | ||
@@ -648,22 +648,22 @@ struct hci_event_hdr { | |||
648 | } __attribute__ ((packed)); | 648 | } __attribute__ ((packed)); |
649 | 649 | ||
650 | struct hci_acl_hdr { | 650 | struct hci_acl_hdr { |
651 | __u16 handle; /* Handle & Flags(PB, BC) */ | 651 | __le16 handle; /* Handle & Flags(PB, BC) */ |
652 | __u16 dlen; | 652 | __le16 dlen; |
653 | } __attribute__ ((packed)); | 653 | } __attribute__ ((packed)); |
654 | 654 | ||
655 | struct hci_sco_hdr { | 655 | struct hci_sco_hdr { |
656 | __u16 handle; | 656 | __le16 handle; |
657 | __u8 dlen; | 657 | __u8 dlen; |
658 | } __attribute__ ((packed)); | 658 | } __attribute__ ((packed)); |
659 | 659 | ||
660 | /* Command opcode pack/unpack */ | 660 | /* Command opcode pack/unpack */ |
661 | #define hci_opcode_pack(ogf, ocf) (__u16)((ocf & 0x03ff)|(ogf << 10)) | 661 | #define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) |
662 | #define hci_opcode_ogf(op) (op >> 10) | 662 | #define hci_opcode_ogf(op) (op >> 10) |
663 | #define hci_opcode_ocf(op) (op & 0x03ff) | 663 | #define hci_opcode_ocf(op) (op & 0x03ff) |
664 | 664 | ||
665 | /* ACL handle and flags pack/unpack */ | 665 | /* ACL handle and flags pack/unpack */ |
666 | #define hci_handle_pack(h, f) (__u16)((h & 0x0fff)|(f << 12)) | 666 | #define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12)) |
667 | #define hci_handle(h) (h & 0x0fff) | 667 | #define hci_handle(h) (h & 0x0fff) |
668 | #define hci_flags(h) (h >> 12) | 668 | #define hci_flags(h) (h >> 12) |
669 | 669 | ||
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7f933f302078..bb9f81dc8723 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h | |||
@@ -25,7 +25,6 @@ | |||
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/proc_fs.h> | ||
29 | #include <net/bluetooth/hci.h> | 28 | #include <net/bluetooth/hci.h> |
30 | 29 | ||
31 | /* HCI upper protocols */ | 30 | /* HCI upper protocols */ |
@@ -34,8 +33,6 @@ | |||
34 | 33 | ||
35 | #define HCI_INIT_TIMEOUT (HZ * 10) | 34 | #define HCI_INIT_TIMEOUT (HZ * 10) |
36 | 35 | ||
37 | extern struct proc_dir_entry *proc_bt_hci; | ||
38 | |||
39 | /* HCI Core structures */ | 36 | /* HCI Core structures */ |
40 | 37 | ||
41 | struct inquiry_data { | 38 | struct inquiry_data { |
@@ -44,7 +41,7 @@ struct inquiry_data { | |||
44 | __u8 pscan_period_mode; | 41 | __u8 pscan_period_mode; |
45 | __u8 pscan_mode; | 42 | __u8 pscan_mode; |
46 | __u8 dev_class[3]; | 43 | __u8 dev_class[3]; |
47 | __u16 clock_offset; | 44 | __le16 clock_offset; |
48 | __s8 rssi; | 45 | __s8 rssi; |
49 | }; | 46 | }; |
50 | 47 | ||
@@ -126,10 +123,6 @@ struct hci_dev { | |||
126 | 123 | ||
127 | atomic_t promisc; | 124 | atomic_t promisc; |
128 | 125 | ||
129 | #ifdef CONFIG_PROC_FS | ||
130 | struct proc_dir_entry *proc; | ||
131 | #endif | ||
132 | |||
133 | struct class_device class_dev; | 126 | struct class_device class_dev; |
134 | 127 | ||
135 | struct module *owner; | 128 | struct module *owner; |
diff --git a/include/net/bluetooth/rfcomm.h b/include/net/bluetooth/rfcomm.h index ffea9d54071f..bbfac86734ec 100644 --- a/include/net/bluetooth/rfcomm.h +++ b/include/net/bluetooth/rfcomm.h | |||
@@ -230,7 +230,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci, | |||
230 | u8 xon_char, u8 xoff_char, u16 param_mask); | 230 | u8 xon_char, u8 xoff_char, u16 param_mask); |
231 | 231 | ||
232 | /* ---- RFCOMM DLCs (channels) ---- */ | 232 | /* ---- RFCOMM DLCs (channels) ---- */ |
233 | struct rfcomm_dlc *rfcomm_dlc_alloc(unsigned int __nocast prio); | 233 | struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio); |
234 | void rfcomm_dlc_free(struct rfcomm_dlc *d); | 234 | void rfcomm_dlc_free(struct rfcomm_dlc *d); |
235 | int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel); | 235 | int rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst, u8 channel); |
236 | int rfcomm_dlc_close(struct rfcomm_dlc *d, int reason); | 236 | int rfcomm_dlc_close(struct rfcomm_dlc *d, int reason); |
@@ -275,9 +275,6 @@ static inline void rfcomm_session_hold(struct rfcomm_session *s) | |||
275 | atomic_inc(&s->refcnt); | 275 | atomic_inc(&s->refcnt); |
276 | } | 276 | } |
277 | 277 | ||
278 | /* ---- RFCOMM chechsum ---- */ | ||
279 | extern u8 rfcomm_crc_table[]; | ||
280 | |||
281 | /* ---- RFCOMM sockets ---- */ | 278 | /* ---- RFCOMM sockets ---- */ |
282 | struct sockaddr_rc { | 279 | struct sockaddr_rc { |
283 | sa_family_t rc_family; | 280 | sa_family_t rc_family; |
@@ -354,6 +351,4 @@ int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); | |||
354 | int rfcomm_init_ttys(void); | 351 | int rfcomm_init_ttys(void); |
355 | void rfcomm_cleanup_ttys(void); | 352 | void rfcomm_cleanup_ttys(void); |
356 | 353 | ||
357 | extern struct proc_dir_entry *proc_bt_rfcomm; | ||
358 | |||
359 | #endif /* __RFCOMM_H */ | 354 | #endif /* __RFCOMM_H */ |
diff --git a/include/net/dn_nsp.h b/include/net/dn_nsp.h index 6bbeafa73e8b..1ba03be0af3a 100644 --- a/include/net/dn_nsp.h +++ b/include/net/dn_nsp.h | |||
@@ -19,9 +19,9 @@ extern void dn_nsp_send_data_ack(struct sock *sk); | |||
19 | extern void dn_nsp_send_oth_ack(struct sock *sk); | 19 | extern void dn_nsp_send_oth_ack(struct sock *sk); |
20 | extern void dn_nsp_delayed_ack(struct sock *sk); | 20 | extern void dn_nsp_delayed_ack(struct sock *sk); |
21 | extern void dn_send_conn_ack(struct sock *sk); | 21 | extern void dn_send_conn_ack(struct sock *sk); |
22 | extern void dn_send_conn_conf(struct sock *sk, int gfp); | 22 | extern void dn_send_conn_conf(struct sock *sk, gfp_t gfp); |
23 | extern void dn_nsp_send_disc(struct sock *sk, unsigned char type, | 23 | extern void dn_nsp_send_disc(struct sock *sk, unsigned char type, |
24 | unsigned short reason, int gfp); | 24 | unsigned short reason, gfp_t gfp); |
25 | extern void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type, | 25 | extern void dn_nsp_return_disc(struct sk_buff *skb, unsigned char type, |
26 | unsigned short reason); | 26 | unsigned short reason); |
27 | extern void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval); | 27 | extern void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval); |
@@ -29,14 +29,14 @@ extern void dn_nsp_send_conninit(struct sock *sk, unsigned char flags); | |||
29 | 29 | ||
30 | extern void dn_nsp_output(struct sock *sk); | 30 | extern void dn_nsp_output(struct sock *sk); |
31 | extern int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff_head *q, unsigned short acknum); | 31 | extern int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff_head *q, unsigned short acknum); |
32 | extern void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, int gfp, int oob); | 32 | extern void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, gfp_t gfp, int oob); |
33 | extern unsigned long dn_nsp_persist(struct sock *sk); | 33 | extern unsigned long dn_nsp_persist(struct sock *sk); |
34 | extern int dn_nsp_xmit_timeout(struct sock *sk); | 34 | extern int dn_nsp_xmit_timeout(struct sock *sk); |
35 | 35 | ||
36 | extern int dn_nsp_rx(struct sk_buff *); | 36 | extern int dn_nsp_rx(struct sk_buff *); |
37 | extern int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb); | 37 | extern int dn_nsp_backlog_rcv(struct sock *sk, struct sk_buff *skb); |
38 | 38 | ||
39 | extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri); | 39 | extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri); |
40 | extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err); | 40 | extern struct sk_buff *dn_alloc_send_skb(struct sock *sk, size_t *size, int noblock, long timeo, int *err); |
41 | 41 | ||
42 | #define NSP_REASON_OK 0 /* No error */ | 42 | #define NSP_REASON_OK 0 /* No error */ |
diff --git a/include/net/dn_route.h b/include/net/dn_route.h index d084721db198..5122da3f2eb3 100644 --- a/include/net/dn_route.h +++ b/include/net/dn_route.h | |||
@@ -15,7 +15,7 @@ | |||
15 | GNU General Public License for more details. | 15 | GNU General Public License for more details. |
16 | *******************************************************************************/ | 16 | *******************************************************************************/ |
17 | 17 | ||
18 | extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri); | 18 | extern struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri); |
19 | extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags); | 19 | extern int dn_route_output_sock(struct dst_entry **pprt, struct flowi *, struct sock *sk, int flags); |
20 | extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); | 20 | extern int dn_cache_dump(struct sk_buff *skb, struct netlink_callback *cb); |
21 | extern int dn_cache_getroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); | 21 | extern int dn_cache_getroute(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg); |
diff --git a/include/net/dst.h b/include/net/dst.h index 4a056a682435..6c196a5baf24 100644 --- a/include/net/dst.h +++ b/include/net/dst.h | |||
@@ -94,7 +94,6 @@ struct dst_ops | |||
94 | struct dst_entry * (*negative_advice)(struct dst_entry *); | 94 | struct dst_entry * (*negative_advice)(struct dst_entry *); |
95 | void (*link_failure)(struct sk_buff *); | 95 | void (*link_failure)(struct sk_buff *); |
96 | void (*update_pmtu)(struct dst_entry *dst, u32 mtu); | 96 | void (*update_pmtu)(struct dst_entry *dst, u32 mtu); |
97 | int (*get_mss)(struct dst_entry *dst, u32 mtu); | ||
98 | int entry_size; | 97 | int entry_size; |
99 | 98 | ||
100 | atomic_t entries; | 99 | atomic_t entries; |
diff --git a/include/net/genetlink.h b/include/net/genetlink.h new file mode 100644 index 000000000000..52d8b1a73d52 --- /dev/null +++ b/include/net/genetlink.h | |||
@@ -0,0 +1,154 @@ | |||
1 | #ifndef __NET_GENERIC_NETLINK_H | ||
2 | #define __NET_GENERIC_NETLINK_H | ||
3 | |||
4 | #include <linux/genetlink.h> | ||
5 | #include <net/netlink.h> | ||
6 | |||
7 | /** | ||
8 | * struct genl_family - generic netlink family | ||
9 | * @id: protocol family idenfitier | ||
10 | * @hdrsize: length of user specific header in bytes | ||
11 | * @name: name of family | ||
12 | * @version: protocol version | ||
13 | * @maxattr: maximum number of attributes supported | ||
14 | * @attrbuf: buffer to store parsed attributes | ||
15 | * @ops_list: list of all assigned operations | ||
16 | * @family_list: family list | ||
17 | */ | ||
18 | struct genl_family | ||
19 | { | ||
20 | unsigned int id; | ||
21 | unsigned int hdrsize; | ||
22 | char name[GENL_NAMSIZ]; | ||
23 | unsigned int version; | ||
24 | unsigned int maxattr; | ||
25 | struct module * owner; | ||
26 | struct nlattr ** attrbuf; /* private */ | ||
27 | struct list_head ops_list; /* private */ | ||
28 | struct list_head family_list; /* private */ | ||
29 | }; | ||
30 | |||
31 | #define GENL_ADMIN_PERM 0x01 | ||
32 | |||
33 | /** | ||
34 | * struct genl_info - receiving information | ||
35 | * @snd_seq: sending sequence number | ||
36 | * @snd_pid: netlink pid of sender | ||
37 | * @nlhdr: netlink message header | ||
38 | * @genlhdr: generic netlink message header | ||
39 | * @userhdr: user specific header | ||
40 | * @attrs: netlink attributes | ||
41 | */ | ||
42 | struct genl_info | ||
43 | { | ||
44 | u32 snd_seq; | ||
45 | u32 snd_pid; | ||
46 | struct nlmsghdr * nlhdr; | ||
47 | struct genlmsghdr * genlhdr; | ||
48 | void * userhdr; | ||
49 | struct nlattr ** attrs; | ||
50 | }; | ||
51 | |||
52 | /** | ||
53 | * struct genl_ops - generic netlink operations | ||
54 | * @cmd: command identifier | ||
55 | * @flags: flags | ||
56 | * @policy: attribute validation policy | ||
57 | * @doit: standard command callback | ||
58 | * @dumpit: callback for dumpers | ||
59 | * @ops_list: operations list | ||
60 | */ | ||
61 | struct genl_ops | ||
62 | { | ||
63 | unsigned int cmd; | ||
64 | unsigned int flags; | ||
65 | struct nla_policy *policy; | ||
66 | int (*doit)(struct sk_buff *skb, | ||
67 | struct genl_info *info); | ||
68 | int (*dumpit)(struct sk_buff *skb, | ||
69 | struct netlink_callback *cb); | ||
70 | struct list_head ops_list; | ||
71 | }; | ||
72 | |||
73 | extern int genl_register_family(struct genl_family *family); | ||
74 | extern int genl_unregister_family(struct genl_family *family); | ||
75 | extern int genl_register_ops(struct genl_family *, struct genl_ops *ops); | ||
76 | extern int genl_unregister_ops(struct genl_family *, struct genl_ops *ops); | ||
77 | |||
78 | extern struct sock *genl_sock; | ||
79 | |||
80 | /** | ||
81 | * genlmsg_put - Add generic netlink header to netlink message | ||
82 | * @skb: socket buffer holding the message | ||
83 | * @pid: netlink pid the message is addressed to | ||
84 | * @seq: sequence number (usually the one of the sender) | ||
85 | * @type: netlink message type | ||
86 | * @hdrlen: length of the user specific header | ||
87 | * @flags netlink message flags | ||
88 | * @cmd: generic netlink command | ||
89 | * @version: version | ||
90 | * | ||
91 | * Returns pointer to user specific header | ||
92 | */ | ||
93 | static inline void *genlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, | ||
94 | int type, int hdrlen, int flags, | ||
95 | u8 cmd, u8 version) | ||
96 | { | ||
97 | struct nlmsghdr *nlh; | ||
98 | struct genlmsghdr *hdr; | ||
99 | |||
100 | nlh = nlmsg_put(skb, pid, seq, type, GENL_HDRLEN + hdrlen, flags); | ||
101 | if (nlh == NULL) | ||
102 | return NULL; | ||
103 | |||
104 | hdr = nlmsg_data(nlh); | ||
105 | hdr->cmd = cmd; | ||
106 | hdr->version = version; | ||
107 | hdr->reserved = 0; | ||
108 | |||
109 | return (char *) hdr + GENL_HDRLEN; | ||
110 | } | ||
111 | |||
112 | /** | ||
113 | * genlmsg_end - Finalize a generic netlink message | ||
114 | * @skb: socket buffer the message is stored in | ||
115 | * @hdr: user specific header | ||
116 | */ | ||
117 | static inline int genlmsg_end(struct sk_buff *skb, void *hdr) | ||
118 | { | ||
119 | return nlmsg_end(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); | ||
120 | } | ||
121 | |||
122 | /** | ||
123 | * genlmsg_cancel - Cancel construction of a generic netlink message | ||
124 | * @skb: socket buffer the message is stored in | ||
125 | * @hdr: generic netlink message header | ||
126 | */ | ||
127 | static inline int genlmsg_cancel(struct sk_buff *skb, void *hdr) | ||
128 | { | ||
129 | return nlmsg_cancel(skb, hdr - GENL_HDRLEN - NLMSG_HDRLEN); | ||
130 | } | ||
131 | |||
132 | /** | ||
133 | * genlmsg_multicast - multicast a netlink message | ||
134 | * @skb: netlink message as socket buffer | ||
135 | * @pid: own netlink pid to avoid sending to yourself | ||
136 | * @group: multicast group id | ||
137 | */ | ||
138 | static inline int genlmsg_multicast(struct sk_buff *skb, u32 pid, | ||
139 | unsigned int group) | ||
140 | { | ||
141 | return nlmsg_multicast(genl_sock, skb, pid, group); | ||
142 | } | ||
143 | |||
144 | /** | ||
145 | * genlmsg_unicast - unicast a netlink message | ||
146 | * @skb: netlink message as socket buffer | ||
147 | * @pid: netlink pid of the destination socket | ||
148 | */ | ||
149 | static inline int genlmsg_unicast(struct sk_buff *skb, u32 pid) | ||
150 | { | ||
151 | return nlmsg_unicast(genl_sock, skb, pid); | ||
152 | } | ||
153 | |||
154 | #endif /* __NET_GENERIC_NETLINK_H */ | ||
diff --git a/include/net/ieee80211.h b/include/net/ieee80211.h index dc36b1be6745..cde2f4f4f501 100644 --- a/include/net/ieee80211.h +++ b/include/net/ieee80211.h | |||
@@ -11,19 +11,26 @@ | |||
11 | * | 11 | * |
12 | * Adaption to a generic IEEE 802.11 stack by James Ketrenos | 12 | * Adaption to a generic IEEE 802.11 stack by James Ketrenos |
13 | * <jketreno@linux.intel.com> | 13 | * <jketreno@linux.intel.com> |
14 | * Copyright (c) 2004, Intel Corporation | 14 | * Copyright (c) 2004-2005, Intel Corporation |
15 | * | 15 | * |
16 | * This program is free software; you can redistribute it and/or modify | 16 | * This program is free software; you can redistribute it and/or modify |
17 | * it under the terms of the GNU General Public License version 2 as | 17 | * it under the terms of the GNU General Public License version 2 as |
18 | * published by the Free Software Foundation. See README and COPYING for | 18 | * published by the Free Software Foundation. See README and COPYING for |
19 | * more details. | 19 | * more details. |
20 | * | ||
21 | * API Version History | ||
22 | * 1.0.x -- Initial version | ||
23 | * 1.1.x -- Added radiotap, QoS, TIM, ieee80211_geo APIs, | ||
24 | * various structure changes, and crypto API init method | ||
20 | */ | 25 | */ |
21 | #ifndef IEEE80211_H | 26 | #ifndef IEEE80211_H |
22 | #define IEEE80211_H | 27 | #define IEEE80211_H |
23 | #include <linux/if_ether.h> /* ETH_ALEN */ | 28 | #include <linux/if_ether.h> /* ETH_ALEN */ |
24 | #include <linux/kernel.h> /* ARRAY_SIZE */ | 29 | #include <linux/kernel.h> /* ARRAY_SIZE */ |
25 | #include <linux/wireless.h> | 30 | #include <linux/wireless.h> |
26 | 31 | ||
32 | #define IEEE80211_VERSION "git-1.1.7" | ||
33 | |||
27 | #define IEEE80211_DATA_LEN 2304 | 34 | #define IEEE80211_DATA_LEN 2304 |
28 | /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section | 35 | /* Maximum size for the MA-UNITDATA primitive, 802.11 standard section |
29 | 6.2.1.1.2. | 36 | 6.2.1.1.2. |
@@ -33,34 +40,13 @@ | |||
33 | represents the 2304 bytes of real data, plus a possible 8 bytes of | 40 | represents the 2304 bytes of real data, plus a possible 8 bytes of |
34 | WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ | 41 | WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ |
35 | 42 | ||
36 | |||
37 | #define IEEE80211_HLEN 30 | ||
38 | #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) | ||
39 | |||
40 | struct ieee80211_hdr { | ||
41 | __le16 frame_ctl; | ||
42 | __le16 duration_id; | ||
43 | u8 addr1[ETH_ALEN]; | ||
44 | u8 addr2[ETH_ALEN]; | ||
45 | u8 addr3[ETH_ALEN]; | ||
46 | __le16 seq_ctl; | ||
47 | u8 addr4[ETH_ALEN]; | ||
48 | } __attribute__ ((packed)); | ||
49 | |||
50 | struct ieee80211_hdr_3addr { | ||
51 | __le16 frame_ctl; | ||
52 | __le16 duration_id; | ||
53 | u8 addr1[ETH_ALEN]; | ||
54 | u8 addr2[ETH_ALEN]; | ||
55 | u8 addr3[ETH_ALEN]; | ||
56 | __le16 seq_ctl; | ||
57 | } __attribute__ ((packed)); | ||
58 | |||
59 | #define IEEE80211_1ADDR_LEN 10 | 43 | #define IEEE80211_1ADDR_LEN 10 |
60 | #define IEEE80211_2ADDR_LEN 16 | 44 | #define IEEE80211_2ADDR_LEN 16 |
61 | #define IEEE80211_3ADDR_LEN 24 | 45 | #define IEEE80211_3ADDR_LEN 24 |
62 | #define IEEE80211_4ADDR_LEN 30 | 46 | #define IEEE80211_4ADDR_LEN 30 |
63 | #define IEEE80211_FCS_LEN 4 | 47 | #define IEEE80211_FCS_LEN 4 |
48 | #define IEEE80211_HLEN (IEEE80211_4ADDR_LEN) | ||
49 | #define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) | ||
64 | 50 | ||
65 | #define MIN_FRAG_THRESHOLD 256U | 51 | #define MIN_FRAG_THRESHOLD 256U |
66 | #define MAX_FRAG_THRESHOLD 2346U | 52 | #define MAX_FRAG_THRESHOLD 2346U |
@@ -113,11 +99,11 @@ struct ieee80211_hdr_3addr { | |||
113 | #define IEEE80211_STYPE_CFACK 0x0050 | 99 | #define IEEE80211_STYPE_CFACK 0x0050 |
114 | #define IEEE80211_STYPE_CFPOLL 0x0060 | 100 | #define IEEE80211_STYPE_CFPOLL 0x0060 |
115 | #define IEEE80211_STYPE_CFACKPOLL 0x0070 | 101 | #define IEEE80211_STYPE_CFACKPOLL 0x0070 |
102 | #define IEEE80211_STYPE_QOS_DATA 0x0080 | ||
116 | 103 | ||
117 | #define IEEE80211_SCTL_FRAG 0x000F | 104 | #define IEEE80211_SCTL_FRAG 0x000F |
118 | #define IEEE80211_SCTL_SEQ 0xFFF0 | 105 | #define IEEE80211_SCTL_SEQ 0xFFF0 |
119 | 106 | ||
120 | |||
121 | /* debug macros */ | 107 | /* debug macros */ |
122 | 108 | ||
123 | #ifdef CONFIG_IEEE80211_DEBUG | 109 | #ifdef CONFIG_IEEE80211_DEBUG |
@@ -128,8 +114,7 @@ do { if (ieee80211_debug_level & (level)) \ | |||
128 | in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) | 114 | in_interrupt() ? 'I' : 'U', __FUNCTION__ , ## args); } while (0) |
129 | #else | 115 | #else |
130 | #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) | 116 | #define IEEE80211_DEBUG(level, fmt, args...) do {} while (0) |
131 | #endif /* CONFIG_IEEE80211_DEBUG */ | 117 | #endif /* CONFIG_IEEE80211_DEBUG */ |
132 | |||
133 | 118 | ||
134 | /* debug macros not dependent on CONFIG_IEEE80211_DEBUG */ | 119 | /* debug macros not dependent on CONFIG_IEEE80211_DEBUG */ |
135 | 120 | ||
@@ -140,7 +125,6 @@ do { if (ieee80211_debug_level & (level)) \ | |||
140 | * messages. It should never be used for passing essid to user space. */ | 125 | * messages. It should never be used for passing essid to user space. */ |
141 | const char *escape_essid(const char *essid, u8 essid_len); | 126 | const char *escape_essid(const char *essid, u8 essid_len); |
142 | 127 | ||
143 | |||
144 | /* | 128 | /* |
145 | * To use the debug system: | 129 | * To use the debug system: |
146 | * | 130 | * |
@@ -177,6 +161,7 @@ const char *escape_essid(const char *essid, u8 essid_len); | |||
177 | 161 | ||
178 | #define IEEE80211_DL_TX (1<<8) | 162 | #define IEEE80211_DL_TX (1<<8) |
179 | #define IEEE80211_DL_RX (1<<9) | 163 | #define IEEE80211_DL_RX (1<<9) |
164 | #define IEEE80211_DL_QOS (1<<31) | ||
180 | 165 | ||
181 | #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a) | 166 | #define IEEE80211_ERROR(f, a...) printk(KERN_ERR "ieee80211: " f, ## a) |
182 | #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a) | 167 | #define IEEE80211_WARNING(f, a...) printk(KERN_WARNING "ieee80211: " f, ## a) |
@@ -190,9 +175,10 @@ const char *escape_essid(const char *essid, u8 essid_len); | |||
190 | #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a) | 175 | #define IEEE80211_DEBUG_DROP(f, a...) IEEE80211_DEBUG(IEEE80211_DL_DROP, f, ## a) |
191 | #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a) | 176 | #define IEEE80211_DEBUG_TX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_TX, f, ## a) |
192 | #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a) | 177 | #define IEEE80211_DEBUG_RX(f, a...) IEEE80211_DEBUG(IEEE80211_DL_RX, f, ## a) |
178 | #define IEEE80211_DEBUG_QOS(f, a...) IEEE80211_DEBUG(IEEE80211_DL_QOS, f, ## a) | ||
193 | #include <linux/netdevice.h> | 179 | #include <linux/netdevice.h> |
194 | #include <linux/wireless.h> | 180 | #include <linux/wireless.h> |
195 | #include <linux/if_arp.h> /* ARPHRD_ETHER */ | 181 | #include <linux/if_arp.h> /* ARPHRD_ETHER */ |
196 | 182 | ||
197 | #ifndef WIRELESS_SPY | 183 | #ifndef WIRELESS_SPY |
198 | #define WIRELESS_SPY /* enable iwspy support */ | 184 | #define WIRELESS_SPY /* enable iwspy support */ |
@@ -200,10 +186,10 @@ const char *escape_essid(const char *essid, u8 essid_len); | |||
200 | #include <net/iw_handler.h> /* new driver API */ | 186 | #include <net/iw_handler.h> /* new driver API */ |
201 | 187 | ||
202 | #ifndef ETH_P_PAE | 188 | #ifndef ETH_P_PAE |
203 | #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ | 189 | #define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ |
204 | #endif /* ETH_P_PAE */ | 190 | #endif /* ETH_P_PAE */ |
205 | 191 | ||
206 | #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ | 192 | #define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ |
207 | 193 | ||
208 | #ifndef ETH_P_80211_RAW | 194 | #ifndef ETH_P_80211_RAW |
209 | #define ETH_P_80211_RAW (ETH_P_ECONET + 1) | 195 | #define ETH_P_80211_RAW (ETH_P_ECONET + 1) |
@@ -215,10 +201,10 @@ const char *escape_essid(const char *essid, u8 essid_len); | |||
215 | 201 | ||
216 | struct ieee80211_snap_hdr { | 202 | struct ieee80211_snap_hdr { |
217 | 203 | ||
218 | u8 dsap; /* always 0xAA */ | 204 | u8 dsap; /* always 0xAA */ |
219 | u8 ssap; /* always 0xAA */ | 205 | u8 ssap; /* always 0xAA */ |
220 | u8 ctrl; /* always 0x03 */ | 206 | u8 ctrl; /* always 0x03 */ |
221 | u8 oui[P80211_OUI_LEN]; /* organizational universal id */ | 207 | u8 oui[P80211_OUI_LEN]; /* organizational universal id */ |
222 | 208 | ||
223 | } __attribute__ ((packed)); | 209 | } __attribute__ ((packed)); |
224 | 210 | ||
@@ -246,8 +232,9 @@ struct ieee80211_snap_hdr { | |||
246 | #define WLAN_CAPABILITY_PBCC (1<<6) | 232 | #define WLAN_CAPABILITY_PBCC (1<<6) |
247 | #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) | 233 | #define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) |
248 | #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) | 234 | #define WLAN_CAPABILITY_SPECTRUM_MGMT (1<<8) |
235 | #define WLAN_CAPABILITY_QOS (1<<9) | ||
249 | #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) | 236 | #define WLAN_CAPABILITY_SHORT_SLOT_TIME (1<<10) |
250 | #define WLAN_CAPABILITY_OSSS_OFDM (1<<13) | 237 | #define WLAN_CAPABILITY_DSSS_OFDM (1<<13) |
251 | 238 | ||
252 | /* Status codes */ | 239 | /* Status codes */ |
253 | enum ieee80211_statuscode { | 240 | enum ieee80211_statuscode { |
@@ -312,14 +299,12 @@ enum ieee80211_reasoncode { | |||
312 | WLAN_REASON_CIPHER_SUITE_REJECTED = 24, | 299 | WLAN_REASON_CIPHER_SUITE_REJECTED = 24, |
313 | }; | 300 | }; |
314 | 301 | ||
315 | |||
316 | #define IEEE80211_STATMASK_SIGNAL (1<<0) | 302 | #define IEEE80211_STATMASK_SIGNAL (1<<0) |
317 | #define IEEE80211_STATMASK_RSSI (1<<1) | 303 | #define IEEE80211_STATMASK_RSSI (1<<1) |
318 | #define IEEE80211_STATMASK_NOISE (1<<2) | 304 | #define IEEE80211_STATMASK_NOISE (1<<2) |
319 | #define IEEE80211_STATMASK_RATE (1<<3) | 305 | #define IEEE80211_STATMASK_RATE (1<<3) |
320 | #define IEEE80211_STATMASK_WEMASK 0x7 | 306 | #define IEEE80211_STATMASK_WEMASK 0x7 |
321 | 307 | ||
322 | |||
323 | #define IEEE80211_CCK_MODULATION (1<<0) | 308 | #define IEEE80211_CCK_MODULATION (1<<0) |
324 | #define IEEE80211_OFDM_MODULATION (1<<1) | 309 | #define IEEE80211_OFDM_MODULATION (1<<1) |
325 | 310 | ||
@@ -377,9 +362,6 @@ enum ieee80211_reasoncode { | |||
377 | #define IEEE80211_NUM_CCK_RATES 4 | 362 | #define IEEE80211_NUM_CCK_RATES 4 |
378 | #define IEEE80211_OFDM_SHIFT_MASK_A 4 | 363 | #define IEEE80211_OFDM_SHIFT_MASK_A 4 |
379 | 364 | ||
380 | |||
381 | |||
382 | |||
383 | /* NOTE: This data is for statistical purposes; not all hardware provides this | 365 | /* NOTE: This data is for statistical purposes; not all hardware provides this |
384 | * information for frames received. Not setting these will not cause | 366 | * information for frames received. Not setting these will not cause |
385 | * any adverse affects. */ | 367 | * any adverse affects. */ |
@@ -388,7 +370,7 @@ struct ieee80211_rx_stats { | |||
388 | s8 rssi; | 370 | s8 rssi; |
389 | u8 signal; | 371 | u8 signal; |
390 | u8 noise; | 372 | u8 noise; |
391 | u16 rate; /* in 100 kbps */ | 373 | u16 rate; /* in 100 kbps */ |
392 | u8 received_channel; | 374 | u8 received_channel; |
393 | u8 control; | 375 | u8 control; |
394 | u8 mask; | 376 | u8 mask; |
@@ -439,38 +421,44 @@ struct ieee80211_device; | |||
439 | 421 | ||
440 | #include "ieee80211_crypt.h" | 422 | #include "ieee80211_crypt.h" |
441 | 423 | ||
442 | #define SEC_KEY_1 (1<<0) | 424 | #define SEC_KEY_1 (1<<0) |
443 | #define SEC_KEY_2 (1<<1) | 425 | #define SEC_KEY_2 (1<<1) |
444 | #define SEC_KEY_3 (1<<2) | 426 | #define SEC_KEY_3 (1<<2) |
445 | #define SEC_KEY_4 (1<<3) | 427 | #define SEC_KEY_4 (1<<3) |
446 | #define SEC_ACTIVE_KEY (1<<4) | 428 | #define SEC_ACTIVE_KEY (1<<4) |
447 | #define SEC_AUTH_MODE (1<<5) | 429 | #define SEC_AUTH_MODE (1<<5) |
448 | #define SEC_UNICAST_GROUP (1<<6) | 430 | #define SEC_UNICAST_GROUP (1<<6) |
449 | #define SEC_LEVEL (1<<7) | 431 | #define SEC_LEVEL (1<<7) |
450 | #define SEC_ENABLED (1<<8) | 432 | #define SEC_ENABLED (1<<8) |
451 | 433 | #define SEC_ENCRYPT (1<<9) | |
452 | #define SEC_LEVEL_0 0 /* None */ | 434 | |
453 | #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ | 435 | #define SEC_LEVEL_0 0 /* None */ |
454 | #define SEC_LEVEL_2 2 /* Level 1 + TKIP */ | 436 | #define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ |
455 | #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ | 437 | #define SEC_LEVEL_2 2 /* Level 1 + TKIP */ |
456 | #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ | 438 | #define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ |
457 | 439 | #define SEC_LEVEL_3 4 /* Level 2 + CCMP */ | |
458 | #define WEP_KEYS 4 | 440 | |
459 | #define WEP_KEY_LEN 13 | 441 | #define SEC_ALG_NONE 0 |
442 | #define SEC_ALG_WEP 1 | ||
443 | #define SEC_ALG_TKIP 2 | ||
444 | #define SEC_ALG_CCMP 3 | ||
445 | |||
446 | #define WEP_KEYS 4 | ||
447 | #define WEP_KEY_LEN 13 | ||
448 | #define SCM_KEY_LEN 32 | ||
449 | #define SCM_TEMPORAL_KEY_LENGTH 16 | ||
460 | 450 | ||
461 | struct ieee80211_security { | 451 | struct ieee80211_security { |
462 | u16 active_key:2, | 452 | u16 active_key:2, |
463 | enabled:1, | 453 | enabled:1, |
464 | auth_mode:2, | 454 | auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1; |
465 | auth_algo:4, | 455 | u8 encode_alg[WEP_KEYS]; |
466 | unicast_uses_group:1; | ||
467 | u8 key_sizes[WEP_KEYS]; | 456 | u8 key_sizes[WEP_KEYS]; |
468 | u8 keys[WEP_KEYS][WEP_KEY_LEN]; | 457 | u8 keys[WEP_KEYS][SCM_KEY_LEN]; |
469 | u8 level; | 458 | u8 level; |
470 | u16 flags; | 459 | u16 flags; |
471 | } __attribute__ ((packed)); | 460 | } __attribute__ ((packed)); |
472 | 461 | ||
473 | |||
474 | /* | 462 | /* |
475 | 463 | ||
476 | 802.11 data frame from AP | 464 | 802.11 data frame from AP |
@@ -494,7 +482,7 @@ enum ieee80211_mfie { | |||
494 | MFIE_TYPE_RATES = 1, | 482 | MFIE_TYPE_RATES = 1, |
495 | MFIE_TYPE_FH_SET = 2, | 483 | MFIE_TYPE_FH_SET = 2, |
496 | MFIE_TYPE_DS_SET = 3, | 484 | MFIE_TYPE_DS_SET = 3, |
497 | MFIE_TYPE_CF_SET = 4, | 485 | MFIE_TYPE_CF_SET = 4, |
498 | MFIE_TYPE_TIM = 5, | 486 | MFIE_TYPE_TIM = 5, |
499 | MFIE_TYPE_IBSS_SET = 6, | 487 | MFIE_TYPE_IBSS_SET = 6, |
500 | MFIE_TYPE_COUNTRY = 7, | 488 | MFIE_TYPE_COUNTRY = 7, |
@@ -516,11 +504,75 @@ enum ieee80211_mfie { | |||
516 | MFIE_TYPE_RSN = 48, | 504 | MFIE_TYPE_RSN = 48, |
517 | MFIE_TYPE_RATES_EX = 50, | 505 | MFIE_TYPE_RATES_EX = 50, |
518 | MFIE_TYPE_GENERIC = 221, | 506 | MFIE_TYPE_GENERIC = 221, |
507 | MFIE_TYPE_QOS_PARAMETER = 222, | ||
519 | }; | 508 | }; |
520 | 509 | ||
521 | struct ieee80211_info_element_hdr { | 510 | /* Minimal header; can be used for passing 802.11 frames with sufficient |
522 | u8 id; | 511 | * information to determine what type of underlying data type is actually |
523 | u8 len; | 512 | * stored in the data. */ |
513 | struct ieee80211_hdr { | ||
514 | __le16 frame_ctl; | ||
515 | __le16 duration_id; | ||
516 | u8 payload[0]; | ||
517 | } __attribute__ ((packed)); | ||
518 | |||
519 | struct ieee80211_hdr_1addr { | ||
520 | __le16 frame_ctl; | ||
521 | __le16 duration_id; | ||
522 | u8 addr1[ETH_ALEN]; | ||
523 | u8 payload[0]; | ||
524 | } __attribute__ ((packed)); | ||
525 | |||
526 | struct ieee80211_hdr_2addr { | ||
527 | __le16 frame_ctl; | ||
528 | __le16 duration_id; | ||
529 | u8 addr1[ETH_ALEN]; | ||
530 | u8 addr2[ETH_ALEN]; | ||
531 | u8 payload[0]; | ||
532 | } __attribute__ ((packed)); | ||
533 | |||
534 | struct ieee80211_hdr_3addr { | ||
535 | __le16 frame_ctl; | ||
536 | __le16 duration_id; | ||
537 | u8 addr1[ETH_ALEN]; | ||
538 | u8 addr2[ETH_ALEN]; | ||
539 | u8 addr3[ETH_ALEN]; | ||
540 | __le16 seq_ctl; | ||
541 | u8 payload[0]; | ||
542 | } __attribute__ ((packed)); | ||
543 | |||
544 | struct ieee80211_hdr_4addr { | ||
545 | __le16 frame_ctl; | ||
546 | __le16 duration_id; | ||
547 | u8 addr1[ETH_ALEN]; | ||
548 | u8 addr2[ETH_ALEN]; | ||
549 | u8 addr3[ETH_ALEN]; | ||
550 | __le16 seq_ctl; | ||
551 | u8 addr4[ETH_ALEN]; | ||
552 | u8 payload[0]; | ||
553 | } __attribute__ ((packed)); | ||
554 | |||
555 | struct ieee80211_hdr_3addrqos { | ||
556 | __le16 frame_ctl; | ||
557 | __le16 duration_id; | ||
558 | u8 addr1[ETH_ALEN]; | ||
559 | u8 addr2[ETH_ALEN]; | ||
560 | u8 addr3[ETH_ALEN]; | ||
561 | __le16 seq_ctl; | ||
562 | u8 payload[0]; | ||
563 | __le16 qos_ctl; | ||
564 | } __attribute__ ((packed)); | ||
565 | |||
566 | struct ieee80211_hdr_4addrqos { | ||
567 | __le16 frame_ctl; | ||
568 | __le16 duration_id; | ||
569 | u8 addr1[ETH_ALEN]; | ||
570 | u8 addr2[ETH_ALEN]; | ||
571 | u8 addr3[ETH_ALEN]; | ||
572 | __le16 seq_ctl; | ||
573 | u8 addr4[ETH_ALEN]; | ||
574 | u8 payload[0]; | ||
575 | __le16 qos_ctl; | ||
524 | } __attribute__ ((packed)); | 576 | } __attribute__ ((packed)); |
525 | 577 | ||
526 | struct ieee80211_info_element { | 578 | struct ieee80211_info_element { |
@@ -546,49 +598,77 @@ struct ieee80211_info_element { | |||
546 | u16 status; | 598 | u16 status; |
547 | */ | 599 | */ |
548 | 600 | ||
549 | struct ieee80211_authentication { | 601 | struct ieee80211_auth { |
550 | struct ieee80211_hdr_3addr header; | 602 | struct ieee80211_hdr_3addr header; |
551 | __le16 algorithm; | 603 | __le16 algorithm; |
552 | __le16 transaction; | 604 | __le16 transaction; |
553 | __le16 status; | 605 | __le16 status; |
554 | struct ieee80211_info_element info_element; | 606 | /* challenge */ |
607 | struct ieee80211_info_element info_element[0]; | ||
555 | } __attribute__ ((packed)); | 608 | } __attribute__ ((packed)); |
556 | 609 | ||
610 | struct ieee80211_disassoc { | ||
611 | struct ieee80211_hdr_3addr header; | ||
612 | __le16 reason; | ||
613 | } __attribute__ ((packed)); | ||
614 | |||
615 | /* Alias deauth for disassoc */ | ||
616 | #define ieee80211_deauth ieee80211_disassoc | ||
617 | |||
618 | struct ieee80211_probe_request { | ||
619 | struct ieee80211_hdr_3addr header; | ||
620 | /* SSID, supported rates */ | ||
621 | struct ieee80211_info_element info_element[0]; | ||
622 | } __attribute__ ((packed)); | ||
557 | 623 | ||
558 | struct ieee80211_probe_response { | 624 | struct ieee80211_probe_response { |
559 | struct ieee80211_hdr_3addr header; | 625 | struct ieee80211_hdr_3addr header; |
560 | u32 time_stamp[2]; | 626 | u32 time_stamp[2]; |
561 | __le16 beacon_interval; | 627 | __le16 beacon_interval; |
562 | __le16 capability; | 628 | __le16 capability; |
563 | struct ieee80211_info_element info_element; | 629 | /* SSID, supported rates, FH params, DS params, |
630 | * CF params, IBSS params, TIM (if beacon), RSN */ | ||
631 | struct ieee80211_info_element info_element[0]; | ||
564 | } __attribute__ ((packed)); | 632 | } __attribute__ ((packed)); |
565 | 633 | ||
566 | struct ieee80211_assoc_request_frame { | 634 | /* Alias beacon for probe_response */ |
635 | #define ieee80211_beacon ieee80211_probe_response | ||
636 | |||
637 | struct ieee80211_assoc_request { | ||
638 | struct ieee80211_hdr_3addr header; | ||
639 | __le16 capability; | ||
640 | __le16 listen_interval; | ||
641 | /* SSID, supported rates, RSN */ | ||
642 | struct ieee80211_info_element info_element[0]; | ||
643 | } __attribute__ ((packed)); | ||
644 | |||
645 | struct ieee80211_reassoc_request { | ||
646 | struct ieee80211_hdr_3addr header; | ||
567 | __le16 capability; | 647 | __le16 capability; |
568 | __le16 listen_interval; | 648 | __le16 listen_interval; |
569 | u8 current_ap[ETH_ALEN]; | 649 | u8 current_ap[ETH_ALEN]; |
570 | struct ieee80211_info_element info_element; | 650 | struct ieee80211_info_element info_element[0]; |
571 | } __attribute__ ((packed)); | 651 | } __attribute__ ((packed)); |
572 | 652 | ||
573 | struct ieee80211_assoc_response_frame { | 653 | struct ieee80211_assoc_response { |
574 | struct ieee80211_hdr_3addr header; | 654 | struct ieee80211_hdr_3addr header; |
575 | __le16 capability; | 655 | __le16 capability; |
576 | __le16 status; | 656 | __le16 status; |
577 | __le16 aid; | 657 | __le16 aid; |
578 | struct ieee80211_info_element info_element; /* supported rates */ | 658 | /* supported rates */ |
659 | struct ieee80211_info_element info_element[0]; | ||
579 | } __attribute__ ((packed)); | 660 | } __attribute__ ((packed)); |
580 | 661 | ||
581 | |||
582 | struct ieee80211_txb { | 662 | struct ieee80211_txb { |
583 | u8 nr_frags; | 663 | u8 nr_frags; |
584 | u8 encrypted; | 664 | u8 encrypted; |
585 | u16 reserved; | 665 | u8 rts_included; |
586 | u16 frag_size; | 666 | u8 reserved; |
587 | u16 payload_size; | 667 | __le16 frag_size; |
668 | __le16 payload_size; | ||
588 | struct sk_buff *fragments[0]; | 669 | struct sk_buff *fragments[0]; |
589 | }; | 670 | }; |
590 | 671 | ||
591 | |||
592 | /* SWEEP TABLE ENTRIES NUMBER */ | 672 | /* SWEEP TABLE ENTRIES NUMBER */ |
593 | #define MAX_SWEEP_TAB_ENTRIES 42 | 673 | #define MAX_SWEEP_TAB_ENTRIES 42 |
594 | #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 | 674 | #define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 |
@@ -604,9 +684,68 @@ struct ieee80211_txb { | |||
604 | 684 | ||
605 | #define MAX_WPA_IE_LEN 64 | 685 | #define MAX_WPA_IE_LEN 64 |
606 | 686 | ||
607 | #define NETWORK_EMPTY_ESSID (1<<0) | 687 | #define NETWORK_EMPTY_ESSID (1<<0) |
608 | #define NETWORK_HAS_OFDM (1<<1) | 688 | #define NETWORK_HAS_OFDM (1<<1) |
609 | #define NETWORK_HAS_CCK (1<<2) | 689 | #define NETWORK_HAS_CCK (1<<2) |
690 | |||
691 | /* QoS structure */ | ||
692 | #define NETWORK_HAS_QOS_PARAMETERS (1<<3) | ||
693 | #define NETWORK_HAS_QOS_INFORMATION (1<<4) | ||
694 | #define NETWORK_HAS_QOS_MASK (NETWORK_HAS_QOS_PARAMETERS | NETWORK_HAS_QOS_INFORMATION) | ||
695 | |||
696 | #define QOS_QUEUE_NUM 4 | ||
697 | #define QOS_OUI_LEN 3 | ||
698 | #define QOS_OUI_TYPE 2 | ||
699 | #define QOS_ELEMENT_ID 221 | ||
700 | #define QOS_OUI_INFO_SUB_TYPE 0 | ||
701 | #define QOS_OUI_PARAM_SUB_TYPE 1 | ||
702 | #define QOS_VERSION_1 1 | ||
703 | #define QOS_AIFSN_MIN_VALUE 2 | ||
704 | |||
705 | struct ieee80211_qos_information_element { | ||
706 | u8 elementID; | ||
707 | u8 length; | ||
708 | u8 qui[QOS_OUI_LEN]; | ||
709 | u8 qui_type; | ||
710 | u8 qui_subtype; | ||
711 | u8 version; | ||
712 | u8 ac_info; | ||
713 | } __attribute__ ((packed)); | ||
714 | |||
715 | struct ieee80211_qos_ac_parameter { | ||
716 | u8 aci_aifsn; | ||
717 | u8 ecw_min_max; | ||
718 | __le16 tx_op_limit; | ||
719 | } __attribute__ ((packed)); | ||
720 | |||
721 | struct ieee80211_qos_parameter_info { | ||
722 | struct ieee80211_qos_information_element info_element; | ||
723 | u8 reserved; | ||
724 | struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; | ||
725 | } __attribute__ ((packed)); | ||
726 | |||
727 | struct ieee80211_qos_parameters { | ||
728 | __le16 cw_min[QOS_QUEUE_NUM]; | ||
729 | __le16 cw_max[QOS_QUEUE_NUM]; | ||
730 | u8 aifs[QOS_QUEUE_NUM]; | ||
731 | u8 flag[QOS_QUEUE_NUM]; | ||
732 | __le16 tx_op_limit[QOS_QUEUE_NUM]; | ||
733 | } __attribute__ ((packed)); | ||
734 | |||
735 | struct ieee80211_qos_data { | ||
736 | struct ieee80211_qos_parameters parameters; | ||
737 | int active; | ||
738 | int supported; | ||
739 | u8 param_count; | ||
740 | u8 old_param_count; | ||
741 | }; | ||
742 | |||
743 | struct ieee80211_tim_parameters { | ||
744 | u8 tim_count; | ||
745 | u8 tim_period; | ||
746 | } __attribute__ ((packed)); | ||
747 | |||
748 | /*******************************************************/ | ||
610 | 749 | ||
611 | struct ieee80211_network { | 750 | struct ieee80211_network { |
612 | /* These entries are used to identify a unique network */ | 751 | /* These entries are used to identify a unique network */ |
@@ -616,6 +755,8 @@ struct ieee80211_network { | |||
616 | u8 ssid[IW_ESSID_MAX_SIZE + 1]; | 755 | u8 ssid[IW_ESSID_MAX_SIZE + 1]; |
617 | u8 ssid_len; | 756 | u8 ssid_len; |
618 | 757 | ||
758 | struct ieee80211_qos_data qos_data; | ||
759 | |||
619 | /* These are network statistics */ | 760 | /* These are network statistics */ |
620 | struct ieee80211_rx_stats stats; | 761 | struct ieee80211_rx_stats stats; |
621 | u16 capability; | 762 | u16 capability; |
@@ -631,10 +772,12 @@ struct ieee80211_network { | |||
631 | u16 beacon_interval; | 772 | u16 beacon_interval; |
632 | u16 listen_interval; | 773 | u16 listen_interval; |
633 | u16 atim_window; | 774 | u16 atim_window; |
775 | u8 erp_value; | ||
634 | u8 wpa_ie[MAX_WPA_IE_LEN]; | 776 | u8 wpa_ie[MAX_WPA_IE_LEN]; |
635 | size_t wpa_ie_len; | 777 | size_t wpa_ie_len; |
636 | u8 rsn_ie[MAX_WPA_IE_LEN]; | 778 | u8 rsn_ie[MAX_WPA_IE_LEN]; |
637 | size_t rsn_ie_len; | 779 | size_t rsn_ie_len; |
780 | struct ieee80211_tim_parameters tim; | ||
638 | struct list_head list; | 781 | struct list_head list; |
639 | }; | 782 | }; |
640 | 783 | ||
@@ -651,17 +794,52 @@ enum ieee80211_state { | |||
651 | #define DEFAULT_MAX_SCAN_AGE (15 * HZ) | 794 | #define DEFAULT_MAX_SCAN_AGE (15 * HZ) |
652 | #define DEFAULT_FTS 2346 | 795 | #define DEFAULT_FTS 2346 |
653 | 796 | ||
654 | |||
655 | #define CFG_IEEE80211_RESERVE_FCS (1<<0) | 797 | #define CFG_IEEE80211_RESERVE_FCS (1<<0) |
656 | #define CFG_IEEE80211_COMPUTE_FCS (1<<1) | 798 | #define CFG_IEEE80211_COMPUTE_FCS (1<<1) |
799 | #define CFG_IEEE80211_RTS (1<<2) | ||
800 | |||
801 | #define IEEE80211_24GHZ_MIN_CHANNEL 1 | ||
802 | #define IEEE80211_24GHZ_MAX_CHANNEL 14 | ||
803 | #define IEEE80211_24GHZ_CHANNELS 14 | ||
804 | |||
805 | #define IEEE80211_52GHZ_MIN_CHANNEL 36 | ||
806 | #define IEEE80211_52GHZ_MAX_CHANNEL 165 | ||
807 | #define IEEE80211_52GHZ_CHANNELS 32 | ||
808 | |||
809 | enum { | ||
810 | IEEE80211_CH_PASSIVE_ONLY = (1 << 0), | ||
811 | IEEE80211_CH_B_ONLY = (1 << 2), | ||
812 | IEEE80211_CH_NO_IBSS = (1 << 3), | ||
813 | IEEE80211_CH_UNIFORM_SPREADING = (1 << 4), | ||
814 | IEEE80211_CH_RADAR_DETECT = (1 << 5), | ||
815 | IEEE80211_CH_INVALID = (1 << 6), | ||
816 | }; | ||
817 | |||
818 | struct ieee80211_channel { | ||
819 | u32 freq; | ||
820 | u8 channel; | ||
821 | u8 flags; | ||
822 | u8 max_power; | ||
823 | }; | ||
824 | |||
825 | struct ieee80211_geo { | ||
826 | u8 name[4]; | ||
827 | u8 bg_channels; | ||
828 | u8 a_channels; | ||
829 | struct ieee80211_channel bg[IEEE80211_24GHZ_CHANNELS]; | ||
830 | struct ieee80211_channel a[IEEE80211_52GHZ_CHANNELS]; | ||
831 | }; | ||
657 | 832 | ||
658 | struct ieee80211_device { | 833 | struct ieee80211_device { |
659 | struct net_device *dev; | 834 | struct net_device *dev; |
835 | struct ieee80211_security sec; | ||
660 | 836 | ||
661 | /* Bookkeeping structures */ | 837 | /* Bookkeeping structures */ |
662 | struct net_device_stats stats; | 838 | struct net_device_stats stats; |
663 | struct ieee80211_stats ieee_stats; | 839 | struct ieee80211_stats ieee_stats; |
664 | 840 | ||
841 | struct ieee80211_geo geo; | ||
842 | |||
665 | /* Probe / Beacon management */ | 843 | /* Probe / Beacon management */ |
666 | struct list_head network_free_list; | 844 | struct list_head network_free_list; |
667 | struct list_head network_list; | 845 | struct list_head network_list; |
@@ -669,62 +847,102 @@ struct ieee80211_device { | |||
669 | int scans; | 847 | int scans; |
670 | int scan_age; | 848 | int scan_age; |
671 | 849 | ||
672 | int iw_mode; /* operating mode (IW_MODE_*) */ | 850 | int iw_mode; /* operating mode (IW_MODE_*) */ |
851 | struct iw_spy_data spy_data; /* iwspy support */ | ||
673 | 852 | ||
674 | spinlock_t lock; | 853 | spinlock_t lock; |
675 | 854 | ||
676 | int tx_headroom; /* Set to size of any additional room needed at front | 855 | int tx_headroom; /* Set to size of any additional room needed at front |
677 | * of allocated Tx SKBs */ | 856 | * of allocated Tx SKBs */ |
678 | u32 config; | 857 | u32 config; |
679 | 858 | ||
680 | /* WEP and other encryption related settings at the device level */ | 859 | /* WEP and other encryption related settings at the device level */ |
681 | int open_wep; /* Set to 1 to allow unencrypted frames */ | 860 | int open_wep; /* Set to 1 to allow unencrypted frames */ |
682 | 861 | ||
683 | int reset_on_keychange; /* Set to 1 if the HW needs to be reset on | 862 | int reset_on_keychange; /* Set to 1 if the HW needs to be reset on |
684 | * WEP key changes */ | 863 | * WEP key changes */ |
685 | 864 | ||
686 | /* If the host performs {en,de}cryption, then set to 1 */ | 865 | /* If the host performs {en,de}cryption, then set to 1 */ |
687 | int host_encrypt; | 866 | int host_encrypt; |
867 | int host_encrypt_msdu; | ||
688 | int host_decrypt; | 868 | int host_decrypt; |
689 | int ieee802_1x; /* is IEEE 802.1X used */ | 869 | /* host performs multicast decryption */ |
870 | int host_mc_decrypt; | ||
871 | |||
872 | int host_open_frag; | ||
873 | int host_build_iv; | ||
874 | int ieee802_1x; /* is IEEE 802.1X used */ | ||
690 | 875 | ||
691 | /* WPA data */ | 876 | /* WPA data */ |
692 | int wpa_enabled; | 877 | int wpa_enabled; |
693 | int drop_unencrypted; | 878 | int drop_unencrypted; |
694 | int tkip_countermeasures; | ||
695 | int privacy_invoked; | 879 | int privacy_invoked; |
696 | size_t wpa_ie_len; | 880 | size_t wpa_ie_len; |
697 | u8 *wpa_ie; | 881 | u8 *wpa_ie; |
698 | 882 | ||
699 | struct list_head crypt_deinit_list; | 883 | struct list_head crypt_deinit_list; |
700 | struct ieee80211_crypt_data *crypt[WEP_KEYS]; | 884 | struct ieee80211_crypt_data *crypt[WEP_KEYS]; |
701 | int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ | 885 | int tx_keyidx; /* default TX key index (crypt[tx_keyidx]) */ |
702 | struct timer_list crypt_deinit_timer; | 886 | struct timer_list crypt_deinit_timer; |
887 | int crypt_quiesced; | ||
703 | 888 | ||
704 | int bcrx_sta_key; /* use individual keys to override default keys even | 889 | int bcrx_sta_key; /* use individual keys to override default keys even |
705 | * with RX of broad/multicast frames */ | 890 | * with RX of broad/multicast frames */ |
706 | 891 | ||
707 | /* Fragmentation structures */ | 892 | /* Fragmentation structures */ |
708 | struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN]; | 893 | struct ieee80211_frag_entry frag_cache[IEEE80211_FRAG_CACHE_LEN]; |
709 | unsigned int frag_next_idx; | 894 | unsigned int frag_next_idx; |
710 | u16 fts; /* Fragmentation Threshold */ | 895 | u16 fts; /* Fragmentation Threshold */ |
896 | u16 rts; /* RTS threshold */ | ||
711 | 897 | ||
712 | /* Association info */ | 898 | /* Association info */ |
713 | u8 bssid[ETH_ALEN]; | 899 | u8 bssid[ETH_ALEN]; |
714 | 900 | ||
715 | enum ieee80211_state state; | 901 | enum ieee80211_state state; |
716 | 902 | ||
717 | int mode; /* A, B, G */ | 903 | int mode; /* A, B, G */ |
718 | int modulation; /* CCK, OFDM */ | 904 | int modulation; /* CCK, OFDM */ |
719 | int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ | 905 | int freq_band; /* 2.4Ghz, 5.2Ghz, Mixed */ |
720 | int abg_ture; /* ABG flag */ | 906 | int abg_true; /* ABG flag */ |
907 | |||
908 | int perfect_rssi; | ||
909 | int worst_rssi; | ||
721 | 910 | ||
722 | /* Callback functions */ | 911 | /* Callback functions */ |
723 | void (*set_security)(struct net_device *dev, | 912 | void (*set_security) (struct net_device * dev, |
724 | struct ieee80211_security *sec); | 913 | struct ieee80211_security * sec); |
725 | int (*hard_start_xmit)(struct ieee80211_txb *txb, | 914 | int (*hard_start_xmit) (struct ieee80211_txb * txb, |
726 | struct net_device *dev); | 915 | struct net_device * dev, int pri); |
727 | int (*reset_port)(struct net_device *dev); | 916 | int (*reset_port) (struct net_device * dev); |
917 | int (*is_queue_full) (struct net_device * dev, int pri); | ||
918 | |||
919 | int (*handle_management) (struct net_device * dev, | ||
920 | struct ieee80211_network * network, u16 type); | ||
921 | |||
922 | /* Typical STA methods */ | ||
923 | int (*handle_auth) (struct net_device * dev, | ||
924 | struct ieee80211_auth * auth); | ||
925 | int (*handle_deauth) (struct net_device * dev, | ||
926 | struct ieee80211_auth * auth); | ||
927 | int (*handle_disassoc) (struct net_device * dev, | ||
928 | struct ieee80211_disassoc * assoc); | ||
929 | int (*handle_beacon) (struct net_device * dev, | ||
930 | struct ieee80211_beacon * beacon, | ||
931 | struct ieee80211_network * network); | ||
932 | int (*handle_probe_response) (struct net_device * dev, | ||
933 | struct ieee80211_probe_response * resp, | ||
934 | struct ieee80211_network * network); | ||
935 | int (*handle_probe_request) (struct net_device * dev, | ||
936 | struct ieee80211_probe_request * req, | ||
937 | struct ieee80211_rx_stats * stats); | ||
938 | int (*handle_assoc_response) (struct net_device * dev, | ||
939 | struct ieee80211_assoc_response * resp, | ||
940 | struct ieee80211_network * network); | ||
941 | |||
942 | /* Typical AP methods */ | ||
943 | int (*handle_assoc_request) (struct net_device * dev); | ||
944 | int (*handle_reassoc_request) (struct net_device * dev, | ||
945 | struct ieee80211_reassoc_request * req); | ||
728 | 946 | ||
729 | /* This must be the last item so that it points to the data | 947 | /* This must be the last item so that it points to the data |
730 | * allocated beyond this structure by alloc_ieee80211 */ | 948 | * allocated beyond this structure by alloc_ieee80211 */ |
@@ -736,12 +954,12 @@ struct ieee80211_device { | |||
736 | #define IEEE_G (1<<2) | 954 | #define IEEE_G (1<<2) |
737 | #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) | 955 | #define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) |
738 | 956 | ||
739 | extern inline void *ieee80211_priv(struct net_device *dev) | 957 | static inline void *ieee80211_priv(struct net_device *dev) |
740 | { | 958 | { |
741 | return ((struct ieee80211_device *)netdev_priv(dev))->priv; | 959 | return ((struct ieee80211_device *)netdev_priv(dev))->priv; |
742 | } | 960 | } |
743 | 961 | ||
744 | extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) | 962 | static inline int ieee80211_is_empty_essid(const char *essid, int essid_len) |
745 | { | 963 | { |
746 | /* Single white space is for Linksys APs */ | 964 | /* Single white space is for Linksys APs */ |
747 | if (essid_len == 1 && essid[0] == ' ') | 965 | if (essid_len == 1 && essid[0] == ' ') |
@@ -757,7 +975,8 @@ extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len) | |||
757 | return 1; | 975 | return 1; |
758 | } | 976 | } |
759 | 977 | ||
760 | extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mode) | 978 | static inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, |
979 | int mode) | ||
761 | { | 980 | { |
762 | /* | 981 | /* |
763 | * It is possible for both access points and our device to support | 982 | * It is possible for both access points and our device to support |
@@ -783,14 +1002,17 @@ extern inline int ieee80211_is_valid_mode(struct ieee80211_device *ieee, int mod | |||
783 | return 0; | 1002 | return 0; |
784 | } | 1003 | } |
785 | 1004 | ||
786 | extern inline int ieee80211_get_hdrlen(u16 fc) | 1005 | static inline int ieee80211_get_hdrlen(u16 fc) |
787 | { | 1006 | { |
788 | int hdrlen = IEEE80211_3ADDR_LEN; | 1007 | int hdrlen = IEEE80211_3ADDR_LEN; |
1008 | u16 stype = WLAN_FC_GET_STYPE(fc); | ||
789 | 1009 | ||
790 | switch (WLAN_FC_GET_TYPE(fc)) { | 1010 | switch (WLAN_FC_GET_TYPE(fc)) { |
791 | case IEEE80211_FTYPE_DATA: | 1011 | case IEEE80211_FTYPE_DATA: |
792 | if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) | 1012 | if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) |
793 | hdrlen = IEEE80211_4ADDR_LEN; | 1013 | hdrlen = IEEE80211_4ADDR_LEN; |
1014 | if (stype & IEEE80211_STYPE_QOS_DATA) | ||
1015 | hdrlen += 2; | ||
794 | break; | 1016 | break; |
795 | case IEEE80211_FTYPE_CTL: | 1017 | case IEEE80211_FTYPE_CTL: |
796 | switch (WLAN_FC_GET_STYPE(fc)) { | 1018 | switch (WLAN_FC_GET_STYPE(fc)) { |
@@ -808,7 +1030,48 @@ extern inline int ieee80211_get_hdrlen(u16 fc) | |||
808 | return hdrlen; | 1030 | return hdrlen; |
809 | } | 1031 | } |
810 | 1032 | ||
1033 | static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr) | ||
1034 | { | ||
1035 | switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { | ||
1036 | case IEEE80211_1ADDR_LEN: | ||
1037 | return ((struct ieee80211_hdr_1addr *)hdr)->payload; | ||
1038 | case IEEE80211_2ADDR_LEN: | ||
1039 | return ((struct ieee80211_hdr_2addr *)hdr)->payload; | ||
1040 | case IEEE80211_3ADDR_LEN: | ||
1041 | return ((struct ieee80211_hdr_3addr *)hdr)->payload; | ||
1042 | case IEEE80211_4ADDR_LEN: | ||
1043 | return ((struct ieee80211_hdr_4addr *)hdr)->payload; | ||
1044 | } | ||
1045 | return NULL; | ||
1046 | } | ||
1047 | |||
1048 | static inline int ieee80211_is_ofdm_rate(u8 rate) | ||
1049 | { | ||
1050 | switch (rate & ~IEEE80211_BASIC_RATE_MASK) { | ||
1051 | case IEEE80211_OFDM_RATE_6MB: | ||
1052 | case IEEE80211_OFDM_RATE_9MB: | ||
1053 | case IEEE80211_OFDM_RATE_12MB: | ||
1054 | case IEEE80211_OFDM_RATE_18MB: | ||
1055 | case IEEE80211_OFDM_RATE_24MB: | ||
1056 | case IEEE80211_OFDM_RATE_36MB: | ||
1057 | case IEEE80211_OFDM_RATE_48MB: | ||
1058 | case IEEE80211_OFDM_RATE_54MB: | ||
1059 | return 1; | ||
1060 | } | ||
1061 | return 0; | ||
1062 | } | ||
811 | 1063 | ||
1064 | static inline int ieee80211_is_cck_rate(u8 rate) | ||
1065 | { | ||
1066 | switch (rate & ~IEEE80211_BASIC_RATE_MASK) { | ||
1067 | case IEEE80211_CCK_RATE_1MB: | ||
1068 | case IEEE80211_CCK_RATE_2MB: | ||
1069 | case IEEE80211_CCK_RATE_5MB: | ||
1070 | case IEEE80211_CCK_RATE_11MB: | ||
1071 | return 1; | ||
1072 | } | ||
1073 | return 0; | ||
1074 | } | ||
812 | 1075 | ||
813 | /* ieee80211.c */ | 1076 | /* ieee80211.c */ |
814 | extern void free_ieee80211(struct net_device *dev); | 1077 | extern void free_ieee80211(struct net_device *dev); |
@@ -817,18 +1080,30 @@ extern struct net_device *alloc_ieee80211(int sizeof_priv); | |||
817 | extern int ieee80211_set_encryption(struct ieee80211_device *ieee); | 1080 | extern int ieee80211_set_encryption(struct ieee80211_device *ieee); |
818 | 1081 | ||
819 | /* ieee80211_tx.c */ | 1082 | /* ieee80211_tx.c */ |
820 | extern int ieee80211_xmit(struct sk_buff *skb, | 1083 | extern int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev); |
821 | struct net_device *dev); | ||
822 | extern void ieee80211_txb_free(struct ieee80211_txb *); | 1084 | extern void ieee80211_txb_free(struct ieee80211_txb *); |
823 | 1085 | extern int ieee80211_tx_frame(struct ieee80211_device *ieee, | |
1086 | struct ieee80211_hdr *frame, int len); | ||
824 | 1087 | ||
825 | /* ieee80211_rx.c */ | 1088 | /* ieee80211_rx.c */ |
826 | extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, | 1089 | extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, |
827 | struct ieee80211_rx_stats *rx_stats); | 1090 | struct ieee80211_rx_stats *rx_stats); |
828 | extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, | 1091 | extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, |
829 | struct ieee80211_hdr *header, | 1092 | struct ieee80211_hdr_4addr *header, |
830 | struct ieee80211_rx_stats *stats); | 1093 | struct ieee80211_rx_stats *stats); |
831 | 1094 | ||
1095 | /* ieee80211_geo.c */ | ||
1096 | extern const struct ieee80211_geo *ieee80211_get_geo(struct ieee80211_device | ||
1097 | *ieee); | ||
1098 | extern int ieee80211_set_geo(struct ieee80211_device *ieee, | ||
1099 | const struct ieee80211_geo *geo); | ||
1100 | |||
1101 | extern int ieee80211_is_valid_channel(struct ieee80211_device *ieee, | ||
1102 | u8 channel); | ||
1103 | extern int ieee80211_channel_to_index(struct ieee80211_device *ieee, | ||
1104 | u8 channel); | ||
1105 | extern u8 ieee80211_freq_to_channel(struct ieee80211_device *ieee, u32 freq); | ||
1106 | |||
832 | /* ieee80211_wx.c */ | 1107 | /* ieee80211_wx.c */ |
833 | extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, | 1108 | extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, |
834 | struct iw_request_info *info, | 1109 | struct iw_request_info *info, |
@@ -839,17 +1114,21 @@ extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, | |||
839 | extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, | 1114 | extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, |
840 | struct iw_request_info *info, | 1115 | struct iw_request_info *info, |
841 | union iwreq_data *wrqu, char *key); | 1116 | union iwreq_data *wrqu, char *key); |
842 | 1117 | extern int ieee80211_wx_set_encodeext(struct ieee80211_device *ieee, | |
843 | 1118 | struct iw_request_info *info, | |
844 | extern inline void ieee80211_increment_scans(struct ieee80211_device *ieee) | 1119 | union iwreq_data *wrqu, char *extra); |
1120 | extern int ieee80211_wx_get_encodeext(struct ieee80211_device *ieee, | ||
1121 | struct iw_request_info *info, | ||
1122 | union iwreq_data *wrqu, char *extra); | ||
1123 | |||
1124 | static inline void ieee80211_increment_scans(struct ieee80211_device *ieee) | ||
845 | { | 1125 | { |
846 | ieee->scans++; | 1126 | ieee->scans++; |
847 | } | 1127 | } |
848 | 1128 | ||
849 | extern inline int ieee80211_get_scans(struct ieee80211_device *ieee) | 1129 | static inline int ieee80211_get_scans(struct ieee80211_device *ieee) |
850 | { | 1130 | { |
851 | return ieee->scans; | 1131 | return ieee->scans; |
852 | } | 1132 | } |
853 | 1133 | ||
854 | 1134 | #endif /* IEEE80211_H */ | |
855 | #endif /* IEEE80211_H */ | ||
diff --git a/include/net/ieee80211_crypt.h b/include/net/ieee80211_crypt.h index b58a3bcc0dc0..225fc751d464 100644 --- a/include/net/ieee80211_crypt.h +++ b/include/net/ieee80211_crypt.h | |||
@@ -25,16 +25,23 @@ | |||
25 | 25 | ||
26 | #include <linux/skbuff.h> | 26 | #include <linux/skbuff.h> |
27 | 27 | ||
28 | enum { | ||
29 | IEEE80211_CRYPTO_TKIP_COUNTERMEASURES = (1 << 0), | ||
30 | }; | ||
31 | |||
28 | struct ieee80211_crypto_ops { | 32 | struct ieee80211_crypto_ops { |
29 | const char *name; | 33 | const char *name; |
34 | struct list_head list; | ||
30 | 35 | ||
31 | /* init new crypto context (e.g., allocate private data space, | 36 | /* init new crypto context (e.g., allocate private data space, |
32 | * select IV, etc.); returns NULL on failure or pointer to allocated | 37 | * select IV, etc.); returns NULL on failure or pointer to allocated |
33 | * private data on success */ | 38 | * private data on success */ |
34 | void * (*init)(int keyidx); | 39 | void *(*init) (int keyidx); |
35 | 40 | ||
36 | /* deinitialize crypto context and free allocated private data */ | 41 | /* deinitialize crypto context and free allocated private data */ |
37 | void (*deinit)(void *priv); | 42 | void (*deinit) (void *priv); |
43 | |||
44 | int (*build_iv) (struct sk_buff * skb, int hdr_len, void *priv); | ||
38 | 45 | ||
39 | /* encrypt/decrypt return < 0 on error or >= 0 on success. The return | 46 | /* encrypt/decrypt return < 0 on error or >= 0 on success. The return |
40 | * value from decrypt_mpdu is passed as the keyidx value for | 47 | * value from decrypt_mpdu is passed as the keyidx value for |
@@ -42,34 +49,39 @@ struct ieee80211_crypto_ops { | |||
42 | * encryption; if not, error will be returned; these functions are | 49 | * encryption; if not, error will be returned; these functions are |
43 | * called for all MPDUs (i.e., fragments). | 50 | * called for all MPDUs (i.e., fragments). |
44 | */ | 51 | */ |
45 | int (*encrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv); | 52 | int (*encrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); |
46 | int (*decrypt_mpdu)(struct sk_buff *skb, int hdr_len, void *priv); | 53 | int (*decrypt_mpdu) (struct sk_buff * skb, int hdr_len, void *priv); |
47 | 54 | ||
48 | /* These functions are called for full MSDUs, i.e. full frames. | 55 | /* These functions are called for full MSDUs, i.e. full frames. |
49 | * These can be NULL if full MSDU operations are not needed. */ | 56 | * These can be NULL if full MSDU operations are not needed. */ |
50 | int (*encrypt_msdu)(struct sk_buff *skb, int hdr_len, void *priv); | 57 | int (*encrypt_msdu) (struct sk_buff * skb, int hdr_len, void *priv); |
51 | int (*decrypt_msdu)(struct sk_buff *skb, int keyidx, int hdr_len, | 58 | int (*decrypt_msdu) (struct sk_buff * skb, int keyidx, int hdr_len, |
52 | void *priv); | 59 | void *priv); |
53 | 60 | ||
54 | int (*set_key)(void *key, int len, u8 *seq, void *priv); | 61 | int (*set_key) (void *key, int len, u8 * seq, void *priv); |
55 | int (*get_key)(void *key, int len, u8 *seq, void *priv); | 62 | int (*get_key) (void *key, int len, u8 * seq, void *priv); |
56 | 63 | ||
57 | /* procfs handler for printing out key information and possible | 64 | /* procfs handler for printing out key information and possible |
58 | * statistics */ | 65 | * statistics */ |
59 | char * (*print_stats)(char *p, void *priv); | 66 | char *(*print_stats) (char *p, void *priv); |
67 | |||
68 | /* Crypto specific flag get/set for configuration settings */ | ||
69 | unsigned long (*get_flags) (void *priv); | ||
70 | unsigned long (*set_flags) (unsigned long flags, void *priv); | ||
60 | 71 | ||
61 | /* maximum number of bytes added by encryption; encrypt buf is | 72 | /* maximum number of bytes added by encryption; encrypt buf is |
62 | * allocated with extra_prefix_len bytes, copy of in_buf, and | 73 | * allocated with extra_prefix_len bytes, copy of in_buf, and |
63 | * extra_postfix_len; encrypt need not use all this space, but | 74 | * extra_postfix_len; encrypt need not use all this space, but |
64 | * the result must start at the beginning of the buffer and correct | 75 | * the result must start at the beginning of the buffer and correct |
65 | * length must be returned */ | 76 | * length must be returned */ |
66 | int extra_prefix_len, extra_postfix_len; | 77 | int extra_mpdu_prefix_len, extra_mpdu_postfix_len; |
78 | int extra_msdu_prefix_len, extra_msdu_postfix_len; | ||
67 | 79 | ||
68 | struct module *owner; | 80 | struct module *owner; |
69 | }; | 81 | }; |
70 | 82 | ||
71 | struct ieee80211_crypt_data { | 83 | struct ieee80211_crypt_data { |
72 | struct list_head list; /* delayed deletion list */ | 84 | struct list_head list; /* delayed deletion list */ |
73 | struct ieee80211_crypto_ops *ops; | 85 | struct ieee80211_crypto_ops *ops; |
74 | void *priv; | 86 | void *priv; |
75 | atomic_t refcnt; | 87 | atomic_t refcnt; |
@@ -77,10 +89,11 @@ struct ieee80211_crypt_data { | |||
77 | 89 | ||
78 | int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); | 90 | int ieee80211_register_crypto_ops(struct ieee80211_crypto_ops *ops); |
79 | int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); | 91 | int ieee80211_unregister_crypto_ops(struct ieee80211_crypto_ops *ops); |
80 | struct ieee80211_crypto_ops * ieee80211_get_crypto_ops(const char *name); | 92 | struct ieee80211_crypto_ops *ieee80211_get_crypto_ops(const char *name); |
81 | void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); | 93 | void ieee80211_crypt_deinit_entries(struct ieee80211_device *, int); |
82 | void ieee80211_crypt_deinit_handler(unsigned long); | 94 | void ieee80211_crypt_deinit_handler(unsigned long); |
83 | void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, | 95 | void ieee80211_crypt_delayed_deinit(struct ieee80211_device *ieee, |
84 | struct ieee80211_crypt_data **crypt); | 96 | struct ieee80211_crypt_data **crypt); |
97 | void ieee80211_crypt_quiescing(struct ieee80211_device *ieee); | ||
85 | 98 | ||
86 | #endif | 99 | #endif |
diff --git a/include/net/ieee80211_radiotap.h b/include/net/ieee80211_radiotap.h new file mode 100644 index 000000000000..429b73892a5f --- /dev/null +++ b/include/net/ieee80211_radiotap.h | |||
@@ -0,0 +1,231 @@ | |||
1 | /* $FreeBSD: src/sys/net80211/ieee80211_radiotap.h,v 1.5 2005/01/22 20:12:05 sam Exp $ */ | ||
2 | /* $NetBSD: ieee80211_radiotap.h,v 1.11 2005/06/22 06:16:02 dyoung Exp $ */ | ||
3 | |||
4 | /*- | ||
5 | * Copyright (c) 2003, 2004 David Young. All rights reserved. | ||
6 | * | ||
7 | * Redistribution and use in source and binary forms, with or without | ||
8 | * modification, are permitted provided that the following conditions | ||
9 | * are met: | ||
10 | * 1. Redistributions of source code must retain the above copyright | ||
11 | * notice, this list of conditions and the following disclaimer. | ||
12 | * 2. Redistributions in binary form must reproduce the above copyright | ||
13 | * notice, this list of conditions and the following disclaimer in the | ||
14 | * documentation and/or other materials provided with the distribution. | ||
15 | * 3. The name of David Young may not be used to endorse or promote | ||
16 | * products derived from this software without specific prior | ||
17 | * written permission. | ||
18 | * | ||
19 | * THIS SOFTWARE IS PROVIDED BY DAVID YOUNG ``AS IS'' AND ANY | ||
20 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, | ||
21 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A | ||
22 | * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAVID | ||
23 | * YOUNG BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
24 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | ||
25 | * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
28 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | ||
29 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
30 | * OF SUCH DAMAGE. | ||
31 | */ | ||
32 | |||
33 | /* | ||
34 | * Modifications to fit into the linux IEEE 802.11 stack, | ||
35 | * Mike Kershaw (dragorn@kismetwireless.net) | ||
36 | */ | ||
37 | |||
38 | #ifndef IEEE80211RADIOTAP_H | ||
39 | #define IEEE80211RADIOTAP_H | ||
40 | |||
41 | #include <linux/if_ether.h> | ||
42 | #include <linux/kernel.h> | ||
43 | |||
44 | /* Radiotap header version (from official NetBSD feed) */ | ||
45 | #define IEEE80211RADIOTAP_VERSION "1.5" | ||
46 | /* Base version of the radiotap packet header data */ | ||
47 | #define PKTHDR_RADIOTAP_VERSION 0 | ||
48 | |||
49 | /* A generic radio capture format is desirable. There is one for | ||
50 | * Linux, but it is neither rigidly defined (there were not even | ||
51 | * units given for some fields) nor easily extensible. | ||
52 | * | ||
53 | * I suggest the following extensible radio capture format. It is | ||
54 | * based on a bitmap indicating which fields are present. | ||
55 | * | ||
56 | * I am trying to describe precisely what the application programmer | ||
57 | * should expect in the following, and for that reason I tell the | ||
58 | * units and origin of each measurement (where it applies), or else I | ||
59 | * use sufficiently weaselly language ("is a monotonically nondecreasing | ||
60 | * function of...") that I cannot set false expectations for lawyerly | ||
61 | * readers. | ||
62 | */ | ||
63 | |||
64 | /* XXX tcpdump/libpcap do not tolerate variable-length headers, | ||
65 | * yet, so we pad every radiotap header to 64 bytes. Ugh. | ||
66 | */ | ||
67 | #define IEEE80211_RADIOTAP_HDRLEN 64 | ||
68 | |||
69 | /* The radio capture header precedes the 802.11 header. */ | ||
70 | struct ieee80211_radiotap_header { | ||
71 | u8 it_version; /* Version 0. Only increases | ||
72 | * for drastic changes, | ||
73 | * introduction of compatible | ||
74 | * new fields does not count. | ||
75 | */ | ||
76 | u8 it_pad; | ||
77 | u16 it_len; /* length of the whole | ||
78 | * header in bytes, including | ||
79 | * it_version, it_pad, | ||
80 | * it_len, and data fields. | ||
81 | */ | ||
82 | u32 it_present; /* A bitmap telling which | ||
83 | * fields are present. Set bit 31 | ||
84 | * (0x80000000) to extend the | ||
85 | * bitmap by another 32 bits. | ||
86 | * Additional extensions are made | ||
87 | * by setting bit 31. | ||
88 | */ | ||
89 | }; | ||
90 | |||
91 | /* Name Data type Units | ||
92 | * ---- --------- ----- | ||
93 | * | ||
94 | * IEEE80211_RADIOTAP_TSFT u64 microseconds | ||
95 | * | ||
96 | * Value in microseconds of the MAC's 64-bit 802.11 Time | ||
97 | * Synchronization Function timer when the first bit of the | ||
98 | * MPDU arrived at the MAC. For received frames, only. | ||
99 | * | ||
100 | * IEEE80211_RADIOTAP_CHANNEL 2 x u16 MHz, bitmap | ||
101 | * | ||
102 | * Tx/Rx frequency in MHz, followed by flags (see below). | ||
103 | * | ||
104 | * IEEE80211_RADIOTAP_FHSS u16 see below | ||
105 | * | ||
106 | * For frequency-hopping radios, the hop set (first byte) | ||
107 | * and pattern (second byte). | ||
108 | * | ||
109 | * IEEE80211_RADIOTAP_RATE u8 500kb/s | ||
110 | * | ||
111 | * Tx/Rx data rate | ||
112 | * | ||
113 | * IEEE80211_RADIOTAP_DBM_ANTSIGNAL int8_t decibels from | ||
114 | * one milliwatt (dBm) | ||
115 | * | ||
116 | * RF signal power at the antenna, decibel difference from | ||
117 | * one milliwatt. | ||
118 | * | ||
119 | * IEEE80211_RADIOTAP_DBM_ANTNOISE int8_t decibels from | ||
120 | * one milliwatt (dBm) | ||
121 | * | ||
122 | * RF noise power at the antenna, decibel difference from one | ||
123 | * milliwatt. | ||
124 | * | ||
125 | * IEEE80211_RADIOTAP_DB_ANTSIGNAL u8 decibel (dB) | ||
126 | * | ||
127 | * RF signal power at the antenna, decibel difference from an | ||
128 | * arbitrary, fixed reference. | ||
129 | * | ||
130 | * IEEE80211_RADIOTAP_DB_ANTNOISE u8 decibel (dB) | ||
131 | * | ||
132 | * RF noise power at the antenna, decibel difference from an | ||
133 | * arbitrary, fixed reference point. | ||
134 | * | ||
135 | * IEEE80211_RADIOTAP_LOCK_QUALITY u16 unitless | ||
136 | * | ||
137 | * Quality of Barker code lock. Unitless. Monotonically | ||
138 | * nondecreasing with "better" lock strength. Called "Signal | ||
139 | * Quality" in datasheets. (Is there a standard way to measure | ||
140 | * this?) | ||
141 | * | ||
142 | * IEEE80211_RADIOTAP_TX_ATTENUATION u16 unitless | ||
143 | * | ||
144 | * Transmit power expressed as unitless distance from max | ||
145 | * power set at factory calibration. 0 is max power. | ||
146 | * Monotonically nondecreasing with lower power levels. | ||
147 | * | ||
148 | * IEEE80211_RADIOTAP_DB_TX_ATTENUATION u16 decibels (dB) | ||
149 | * | ||
150 | * Transmit power expressed as decibel distance from max power | ||
151 | * set at factory calibration. 0 is max power. Monotonically | ||
152 | * nondecreasing with lower power levels. | ||
153 | * | ||
154 | * IEEE80211_RADIOTAP_DBM_TX_POWER int8_t decibels from | ||
155 | * one milliwatt (dBm) | ||
156 | * | ||
157 | * Transmit power expressed as dBm (decibels from a 1 milliwatt | ||
158 | * reference). This is the absolute power level measured at | ||
159 | * the antenna port. | ||
160 | * | ||
161 | * IEEE80211_RADIOTAP_FLAGS u8 bitmap | ||
162 | * | ||
163 | * Properties of transmitted and received frames. See flags | ||
164 | * defined below. | ||
165 | * | ||
166 | * IEEE80211_RADIOTAP_ANTENNA u8 antenna index | ||
167 | * | ||
168 | * Unitless indication of the Rx/Tx antenna for this packet. | ||
169 | * The first antenna is antenna 0. | ||
170 | * | ||
171 | * IEEE80211_RADIOTAP_FCS u32 data | ||
172 | * | ||
173 | * FCS from frame in network byte order. | ||
174 | */ | ||
175 | enum ieee80211_radiotap_type { | ||
176 | IEEE80211_RADIOTAP_TSFT = 0, | ||
177 | IEEE80211_RADIOTAP_FLAGS = 1, | ||
178 | IEEE80211_RADIOTAP_RATE = 2, | ||
179 | IEEE80211_RADIOTAP_CHANNEL = 3, | ||
180 | IEEE80211_RADIOTAP_FHSS = 4, | ||
181 | IEEE80211_RADIOTAP_DBM_ANTSIGNAL = 5, | ||
182 | IEEE80211_RADIOTAP_DBM_ANTNOISE = 6, | ||
183 | IEEE80211_RADIOTAP_LOCK_QUALITY = 7, | ||
184 | IEEE80211_RADIOTAP_TX_ATTENUATION = 8, | ||
185 | IEEE80211_RADIOTAP_DB_TX_ATTENUATION = 9, | ||
186 | IEEE80211_RADIOTAP_DBM_TX_POWER = 10, | ||
187 | IEEE80211_RADIOTAP_ANTENNA = 11, | ||
188 | IEEE80211_RADIOTAP_DB_ANTSIGNAL = 12, | ||
189 | IEEE80211_RADIOTAP_DB_ANTNOISE = 13, | ||
190 | IEEE80211_RADIOTAP_EXT = 31, | ||
191 | }; | ||
192 | |||
193 | /* Channel flags. */ | ||
194 | #define IEEE80211_CHAN_TURBO 0x0010 /* Turbo channel */ | ||
195 | #define IEEE80211_CHAN_CCK 0x0020 /* CCK channel */ | ||
196 | #define IEEE80211_CHAN_OFDM 0x0040 /* OFDM channel */ | ||
197 | #define IEEE80211_CHAN_2GHZ 0x0080 /* 2 GHz spectrum channel. */ | ||
198 | #define IEEE80211_CHAN_5GHZ 0x0100 /* 5 GHz spectrum channel */ | ||
199 | #define IEEE80211_CHAN_PASSIVE 0x0200 /* Only passive scan allowed */ | ||
200 | #define IEEE80211_CHAN_DYN 0x0400 /* Dynamic CCK-OFDM channel */ | ||
201 | #define IEEE80211_CHAN_GFSK 0x0800 /* GFSK channel (FHSS PHY) */ | ||
202 | |||
203 | /* For IEEE80211_RADIOTAP_FLAGS */ | ||
204 | #define IEEE80211_RADIOTAP_F_CFP 0x01 /* sent/received | ||
205 | * during CFP | ||
206 | */ | ||
207 | #define IEEE80211_RADIOTAP_F_SHORTPRE 0x02 /* sent/received | ||
208 | * with short | ||
209 | * preamble | ||
210 | */ | ||
211 | #define IEEE80211_RADIOTAP_F_WEP 0x04 /* sent/received | ||
212 | * with WEP encryption | ||
213 | */ | ||
214 | #define IEEE80211_RADIOTAP_F_FRAG 0x08 /* sent/received | ||
215 | * with fragmentation | ||
216 | */ | ||
217 | #define IEEE80211_RADIOTAP_F_FCS 0x10 /* frame includes FCS */ | ||
218 | #define IEEE80211_RADIOTAP_F_DATAPAD 0x20 /* frame has padding between | ||
219 | * 802.11 header and payload | ||
220 | * (to 32-bit boundary) | ||
221 | */ | ||
222 | |||
223 | /* Ugly macro to convert literal channel numbers into their mhz equivalents | ||
224 | * There are certianly some conditions that will break this (like feeding it '30') | ||
225 | * but they shouldn't arise since nothing talks on channel 30. */ | ||
226 | #define ieee80211chan2mhz(x) \ | ||
227 | (((x) <= 14) ? \ | ||
228 | (((x) == 14) ? 2484 : ((x) * 5) + 2407) : \ | ||
229 | ((x) + 1000) * 5) | ||
230 | |||
231 | #endif /* IEEE80211_RADIOTAP_H */ | ||
diff --git a/include/net/inet6_hashtables.h b/include/net/inet6_hashtables.h index 03df3b157960..5a2beed5a770 100644 --- a/include/net/inet6_hashtables.h +++ b/include/net/inet6_hashtables.h | |||
@@ -26,19 +26,18 @@ | |||
26 | struct inet_hashinfo; | 26 | struct inet_hashinfo; |
27 | 27 | ||
28 | /* I have no idea if this is a good hash for v6 or not. -DaveM */ | 28 | /* I have no idea if this is a good hash for v6 or not. -DaveM */ |
29 | static inline int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport, | 29 | static inline unsigned int inet6_ehashfn(const struct in6_addr *laddr, const u16 lport, |
30 | const struct in6_addr *faddr, const u16 fport, | 30 | const struct in6_addr *faddr, const u16 fport) |
31 | const int ehash_size) | ||
32 | { | 31 | { |
33 | int hashent = (lport ^ fport); | 32 | unsigned int hashent = (lport ^ fport); |
34 | 33 | ||
35 | hashent ^= (laddr->s6_addr32[3] ^ faddr->s6_addr32[3]); | 34 | hashent ^= (laddr->s6_addr32[3] ^ faddr->s6_addr32[3]); |
36 | hashent ^= hashent >> 16; | 35 | hashent ^= hashent >> 16; |
37 | hashent ^= hashent >> 8; | 36 | hashent ^= hashent >> 8; |
38 | return (hashent & (ehash_size - 1)); | 37 | return hashent; |
39 | } | 38 | } |
40 | 39 | ||
41 | static inline int inet6_sk_ehashfn(const struct sock *sk, const int ehash_size) | 40 | static inline int inet6_sk_ehashfn(const struct sock *sk) |
42 | { | 41 | { |
43 | const struct inet_sock *inet = inet_sk(sk); | 42 | const struct inet_sock *inet = inet_sk(sk); |
44 | const struct ipv6_pinfo *np = inet6_sk(sk); | 43 | const struct ipv6_pinfo *np = inet6_sk(sk); |
@@ -46,7 +45,7 @@ static inline int inet6_sk_ehashfn(const struct sock *sk, const int ehash_size) | |||
46 | const struct in6_addr *faddr = &np->daddr; | 45 | const struct in6_addr *faddr = &np->daddr; |
47 | const __u16 lport = inet->num; | 46 | const __u16 lport = inet->num; |
48 | const __u16 fport = inet->dport; | 47 | const __u16 fport = inet->dport; |
49 | return inet6_ehashfn(laddr, lport, faddr, fport, ehash_size); | 48 | return inet6_ehashfn(laddr, lport, faddr, fport); |
50 | } | 49 | } |
51 | 50 | ||
52 | /* | 51 | /* |
@@ -69,14 +68,14 @@ static inline struct sock * | |||
69 | /* Optimize here for direct hit, only listening connections can | 68 | /* Optimize here for direct hit, only listening connections can |
70 | * have wildcards anyways. | 69 | * have wildcards anyways. |
71 | */ | 70 | */ |
72 | const int hash = inet6_ehashfn(daddr, hnum, saddr, sport, | 71 | unsigned int hash = inet6_ehashfn(daddr, hnum, saddr, sport); |
73 | hashinfo->ehash_size); | 72 | struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); |
74 | struct inet_ehash_bucket *head = &hashinfo->ehash[hash]; | ||
75 | 73 | ||
74 | prefetch(head->chain.first); | ||
76 | read_lock(&head->lock); | 75 | read_lock(&head->lock); |
77 | sk_for_each(sk, node, &head->chain) { | 76 | sk_for_each(sk, node, &head->chain) { |
78 | /* For IPV6 do the cheaper port and family tests first. */ | 77 | /* For IPV6 do the cheaper port and family tests first. */ |
79 | if (INET6_MATCH(sk, saddr, daddr, ports, dif)) | 78 | if (INET6_MATCH(sk, hash, saddr, daddr, ports, dif)) |
80 | goto hit; /* You sunk my battleship! */ | 79 | goto hit; /* You sunk my battleship! */ |
81 | } | 80 | } |
82 | /* Must check for a TIME_WAIT'er before going to listener hash. */ | 81 | /* Must check for a TIME_WAIT'er before going to listener hash. */ |
diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h index 651f824c1008..b0c99060b78d 100644 --- a/include/net/inet_connection_sock.h +++ b/include/net/inet_connection_sock.h | |||
@@ -94,7 +94,7 @@ static inline void *inet_csk_ca(const struct sock *sk) | |||
94 | 94 | ||
95 | extern struct sock *inet_csk_clone(struct sock *sk, | 95 | extern struct sock *inet_csk_clone(struct sock *sk, |
96 | const struct request_sock *req, | 96 | const struct request_sock *req, |
97 | const unsigned int __nocast priority); | 97 | const gfp_t priority); |
98 | 98 | ||
99 | enum inet_csk_ack_state_t { | 99 | enum inet_csk_ack_state_t { |
100 | ICSK_ACK_SCHED = 1, | 100 | ICSK_ACK_SCHED = 1, |
diff --git a/include/net/inet_ecn.h b/include/net/inet_ecn.h index f87845e2e965..b0c47e2eccf1 100644 --- a/include/net/inet_ecn.h +++ b/include/net/inet_ecn.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define _INET_ECN_H_ | 2 | #define _INET_ECN_H_ |
3 | 3 | ||
4 | #include <linux/ip.h> | 4 | #include <linux/ip.h> |
5 | #include <linux/skbuff.h> | ||
5 | #include <net/dsfield.h> | 6 | #include <net/dsfield.h> |
6 | 7 | ||
7 | enum { | 8 | enum { |
@@ -48,7 +49,7 @@ static inline __u8 INET_ECN_encapsulate(__u8 outer, __u8 inner) | |||
48 | (label) |= __constant_htons(INET_ECN_ECT_0 << 4); \ | 49 | (label) |= __constant_htons(INET_ECN_ECT_0 << 4); \ |
49 | } while (0) | 50 | } while (0) |
50 | 51 | ||
51 | static inline void IP_ECN_set_ce(struct iphdr *iph) | 52 | static inline int IP_ECN_set_ce(struct iphdr *iph) |
52 | { | 53 | { |
53 | u32 check = iph->check; | 54 | u32 check = iph->check; |
54 | u32 ecn = (iph->tos + 1) & INET_ECN_MASK; | 55 | u32 ecn = (iph->tos + 1) & INET_ECN_MASK; |
@@ -61,7 +62,7 @@ static inline void IP_ECN_set_ce(struct iphdr *iph) | |||
61 | * INET_ECN_CE => 00 | 62 | * INET_ECN_CE => 00 |
62 | */ | 63 | */ |
63 | if (!(ecn & 2)) | 64 | if (!(ecn & 2)) |
64 | return; | 65 | return !ecn; |
65 | 66 | ||
66 | /* | 67 | /* |
67 | * The following gives us: | 68 | * The following gives us: |
@@ -72,6 +73,7 @@ static inline void IP_ECN_set_ce(struct iphdr *iph) | |||
72 | 73 | ||
73 | iph->check = check + (check>=0xFFFF); | 74 | iph->check = check + (check>=0xFFFF); |
74 | iph->tos |= INET_ECN_CE; | 75 | iph->tos |= INET_ECN_CE; |
76 | return 1; | ||
75 | } | 77 | } |
76 | 78 | ||
77 | static inline void IP_ECN_clear(struct iphdr *iph) | 79 | static inline void IP_ECN_clear(struct iphdr *iph) |
@@ -87,11 +89,12 @@ static inline void ipv4_copy_dscp(struct iphdr *outer, struct iphdr *inner) | |||
87 | 89 | ||
88 | struct ipv6hdr; | 90 | struct ipv6hdr; |
89 | 91 | ||
90 | static inline void IP6_ECN_set_ce(struct ipv6hdr *iph) | 92 | static inline int IP6_ECN_set_ce(struct ipv6hdr *iph) |
91 | { | 93 | { |
92 | if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph))) | 94 | if (INET_ECN_is_not_ect(ipv6_get_dsfield(iph))) |
93 | return; | 95 | return 0; |
94 | *(u32*)iph |= htonl(INET_ECN_CE << 20); | 96 | *(u32*)iph |= htonl(INET_ECN_CE << 20); |
97 | return 1; | ||
95 | } | 98 | } |
96 | 99 | ||
97 | static inline void IP6_ECN_clear(struct ipv6hdr *iph) | 100 | static inline void IP6_ECN_clear(struct ipv6hdr *iph) |
@@ -105,4 +108,21 @@ static inline void ipv6_copy_dscp(struct ipv6hdr *outer, struct ipv6hdr *inner) | |||
105 | ipv6_change_dsfield(inner, INET_ECN_MASK, dscp); | 108 | ipv6_change_dsfield(inner, INET_ECN_MASK, dscp); |
106 | } | 109 | } |
107 | 110 | ||
111 | static inline int INET_ECN_set_ce(struct sk_buff *skb) | ||
112 | { | ||
113 | switch (skb->protocol) { | ||
114 | case __constant_htons(ETH_P_IP): | ||
115 | if (skb->nh.raw + sizeof(struct iphdr) <= skb->tail) | ||
116 | return IP_ECN_set_ce(skb->nh.iph); | ||
117 | break; | ||
118 | |||
119 | case __constant_htons(ETH_P_IPV6): | ||
120 | if (skb->nh.raw + sizeof(struct ipv6hdr) <= skb->tail) | ||
121 | return IP6_ECN_set_ce(skb->nh.ipv6h); | ||
122 | break; | ||
123 | } | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
108 | #endif | 128 | #endif |
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 646b6ea7fe26..07840baa9341 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
@@ -40,7 +40,7 @@ | |||
40 | struct inet_ehash_bucket { | 40 | struct inet_ehash_bucket { |
41 | rwlock_t lock; | 41 | rwlock_t lock; |
42 | struct hlist_head chain; | 42 | struct hlist_head chain; |
43 | } __attribute__((__aligned__(8))); | 43 | }; |
44 | 44 | ||
45 | /* There are a few simple rules, which allow for local port reuse by | 45 | /* There are a few simple rules, which allow for local port reuse by |
46 | * an application. In essence: | 46 | * an application. In essence: |
@@ -108,7 +108,7 @@ struct inet_hashinfo { | |||
108 | struct inet_bind_hashbucket *bhash; | 108 | struct inet_bind_hashbucket *bhash; |
109 | 109 | ||
110 | int bhash_size; | 110 | int bhash_size; |
111 | int ehash_size; | 111 | unsigned int ehash_size; |
112 | 112 | ||
113 | /* All sockets in TCP_LISTEN state will be in here. This is the only | 113 | /* All sockets in TCP_LISTEN state will be in here. This is the only |
114 | * table where wildcard'd TCP sockets can exist. Hash function here | 114 | * table where wildcard'd TCP sockets can exist. Hash function here |
@@ -125,22 +125,19 @@ struct inet_hashinfo { | |||
125 | rwlock_t lhash_lock ____cacheline_aligned; | 125 | rwlock_t lhash_lock ____cacheline_aligned; |
126 | atomic_t lhash_users; | 126 | atomic_t lhash_users; |
127 | wait_queue_head_t lhash_wait; | 127 | wait_queue_head_t lhash_wait; |
128 | spinlock_t portalloc_lock; | ||
129 | kmem_cache_t *bind_bucket_cachep; | 128 | kmem_cache_t *bind_bucket_cachep; |
130 | int port_rover; | ||
131 | }; | 129 | }; |
132 | 130 | ||
133 | static inline int inet_ehashfn(const __u32 laddr, const __u16 lport, | 131 | static inline unsigned int inet_ehashfn(const __u32 laddr, const __u16 lport, |
134 | const __u32 faddr, const __u16 fport, | 132 | const __u32 faddr, const __u16 fport) |
135 | const int ehash_size) | ||
136 | { | 133 | { |
137 | int h = (laddr ^ lport) ^ (faddr ^ fport); | 134 | unsigned int h = (laddr ^ lport) ^ (faddr ^ fport); |
138 | h ^= h >> 16; | 135 | h ^= h >> 16; |
139 | h ^= h >> 8; | 136 | h ^= h >> 8; |
140 | return h & (ehash_size - 1); | 137 | return h; |
141 | } | 138 | } |
142 | 139 | ||
143 | static inline int inet_sk_ehashfn(const struct sock *sk, const int ehash_size) | 140 | static inline int inet_sk_ehashfn(const struct sock *sk) |
144 | { | 141 | { |
145 | const struct inet_sock *inet = inet_sk(sk); | 142 | const struct inet_sock *inet = inet_sk(sk); |
146 | const __u32 laddr = inet->rcv_saddr; | 143 | const __u32 laddr = inet->rcv_saddr; |
@@ -148,7 +145,14 @@ static inline int inet_sk_ehashfn(const struct sock *sk, const int ehash_size) | |||
148 | const __u32 faddr = inet->daddr; | 145 | const __u32 faddr = inet->daddr; |
149 | const __u16 fport = inet->dport; | 146 | const __u16 fport = inet->dport; |
150 | 147 | ||
151 | return inet_ehashfn(laddr, lport, faddr, fport, ehash_size); | 148 | return inet_ehashfn(laddr, lport, faddr, fport); |
149 | } | ||
150 | |||
151 | static inline struct inet_ehash_bucket *inet_ehash_bucket( | ||
152 | struct inet_hashinfo *hashinfo, | ||
153 | unsigned int hash) | ||
154 | { | ||
155 | return &hashinfo->ehash[hash & (hashinfo->ehash_size - 1)]; | ||
152 | } | 156 | } |
153 | 157 | ||
154 | extern struct inet_bind_bucket * | 158 | extern struct inet_bind_bucket * |
@@ -235,9 +239,11 @@ static inline void __inet_hash(struct inet_hashinfo *hashinfo, | |||
235 | lock = &hashinfo->lhash_lock; | 239 | lock = &hashinfo->lhash_lock; |
236 | inet_listen_wlock(hashinfo); | 240 | inet_listen_wlock(hashinfo); |
237 | } else { | 241 | } else { |
238 | sk->sk_hashent = inet_sk_ehashfn(sk, hashinfo->ehash_size); | 242 | struct inet_ehash_bucket *head; |
239 | list = &hashinfo->ehash[sk->sk_hashent].chain; | 243 | sk->sk_hash = inet_sk_ehashfn(sk); |
240 | lock = &hashinfo->ehash[sk->sk_hashent].lock; | 244 | head = inet_ehash_bucket(hashinfo, sk->sk_hash); |
245 | list = &head->chain; | ||
246 | lock = &head->lock; | ||
241 | write_lock(lock); | 247 | write_lock(lock); |
242 | } | 248 | } |
243 | __sk_add_node(sk, list); | 249 | __sk_add_node(sk, list); |
@@ -268,9 +274,8 @@ static inline void inet_unhash(struct inet_hashinfo *hashinfo, struct sock *sk) | |||
268 | inet_listen_wlock(hashinfo); | 274 | inet_listen_wlock(hashinfo); |
269 | lock = &hashinfo->lhash_lock; | 275 | lock = &hashinfo->lhash_lock; |
270 | } else { | 276 | } else { |
271 | struct inet_ehash_bucket *head = &hashinfo->ehash[sk->sk_hashent]; | 277 | lock = &inet_ehash_bucket(hashinfo, sk->sk_hash)->lock; |
272 | lock = &head->lock; | 278 | write_lock_bh(lock); |
273 | write_lock_bh(&head->lock); | ||
274 | } | 279 | } |
275 | 280 | ||
276 | if (__sk_del_node_init(sk)) | 281 | if (__sk_del_node_init(sk)) |
@@ -337,23 +342,27 @@ sherry_cache: | |||
337 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ | 342 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) \ |
338 | const __u64 __name = (((__u64)(__daddr)) << 32) | ((__u64)(__saddr)); | 343 | const __u64 __name = (((__u64)(__daddr)) << 32) | ((__u64)(__saddr)); |
339 | #endif /* __BIG_ENDIAN */ | 344 | #endif /* __BIG_ENDIAN */ |
340 | #define INET_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\ | 345 | #define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
341 | (((*((__u64 *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ | 346 | (((__sk)->sk_hash == (__hash)) && \ |
347 | ((*((__u64 *)&(inet_sk(__sk)->daddr))) == (__cookie)) && \ | ||
342 | ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 348 | ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
343 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 349 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
344 | #define INET_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif)\ | 350 | #define INET_TW_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif)\ |
345 | (((*((__u64 *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ | 351 | (((__sk)->sk_hash == (__hash)) && \ |
352 | ((*((__u64 *)&(inet_twsk(__sk)->tw_daddr))) == (__cookie)) && \ | ||
346 | ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | 353 | ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
347 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 354 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
348 | #else /* 32-bit arch */ | 355 | #else /* 32-bit arch */ |
349 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) | 356 | #define INET_ADDR_COOKIE(__name, __saddr, __daddr) |
350 | #define INET_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif) \ | 357 | #define INET_MATCH(__sk, __hash, __cookie, __saddr, __daddr, __ports, __dif) \ |
351 | ((inet_sk(__sk)->daddr == (__saddr)) && \ | 358 | (((__sk)->sk_hash == (__hash)) && \ |
359 | (inet_sk(__sk)->daddr == (__saddr)) && \ | ||
352 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ | 360 | (inet_sk(__sk)->rcv_saddr == (__daddr)) && \ |
353 | ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ | 361 | ((*((__u32 *)&(inet_sk(__sk)->dport))) == (__ports)) && \ |
354 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 362 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
355 | #define INET_TW_MATCH(__sk, __cookie, __saddr, __daddr, __ports, __dif) \ | 363 | #define INET_TW_MATCH(__sk, __hash,__cookie, __saddr, __daddr, __ports, __dif) \ |
356 | ((inet_twsk(__sk)->tw_daddr == (__saddr)) && \ | 364 | (((__sk)->sk_hash == (__hash)) && \ |
365 | (inet_twsk(__sk)->tw_daddr == (__saddr)) && \ | ||
357 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ | 366 | (inet_twsk(__sk)->tw_rcv_saddr == (__daddr)) && \ |
358 | ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ | 367 | ((*((__u32 *)&(inet_twsk(__sk)->tw_dport))) == (__ports)) && \ |
359 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) | 368 | (!((__sk)->sk_bound_dev_if) || ((__sk)->sk_bound_dev_if == (__dif)))) |
@@ -378,18 +387,19 @@ static inline struct sock * | |||
378 | /* Optimize here for direct hit, only listening connections can | 387 | /* Optimize here for direct hit, only listening connections can |
379 | * have wildcards anyways. | 388 | * have wildcards anyways. |
380 | */ | 389 | */ |
381 | const int hash = inet_ehashfn(daddr, hnum, saddr, sport, hashinfo->ehash_size); | 390 | unsigned int hash = inet_ehashfn(daddr, hnum, saddr, sport); |
382 | struct inet_ehash_bucket *head = &hashinfo->ehash[hash]; | 391 | struct inet_ehash_bucket *head = inet_ehash_bucket(hashinfo, hash); |
383 | 392 | ||
393 | prefetch(head->chain.first); | ||
384 | read_lock(&head->lock); | 394 | read_lock(&head->lock); |
385 | sk_for_each(sk, node, &head->chain) { | 395 | sk_for_each(sk, node, &head->chain) { |
386 | if (INET_MATCH(sk, acookie, saddr, daddr, ports, dif)) | 396 | if (INET_MATCH(sk, hash, acookie, saddr, daddr, ports, dif)) |
387 | goto hit; /* You sunk my battleship! */ | 397 | goto hit; /* You sunk my battleship! */ |
388 | } | 398 | } |
389 | 399 | ||
390 | /* Must check for a TIME_WAIT'er before going to listener hash. */ | 400 | /* Must check for a TIME_WAIT'er before going to listener hash. */ |
391 | sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) { | 401 | sk_for_each(sk, node, &(head + hashinfo->ehash_size)->chain) { |
392 | if (INET_TW_MATCH(sk, acookie, saddr, daddr, ports, dif)) | 402 | if (INET_TW_MATCH(sk, hash, acookie, saddr, daddr, ports, dif)) |
393 | goto hit; | 403 | goto hit; |
394 | } | 404 | } |
395 | sk = NULL; | 405 | sk = NULL; |
diff --git a/include/net/inet_timewait_sock.h b/include/net/inet_timewait_sock.h index 3b070352e869..28f7b2103505 100644 --- a/include/net/inet_timewait_sock.h +++ b/include/net/inet_timewait_sock.h | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/ip.h> | 20 | #include <linux/ip.h> |
21 | #include <linux/list.h> | 21 | #include <linux/list.h> |
22 | #include <linux/module.h> | ||
22 | #include <linux/timer.h> | 23 | #include <linux/timer.h> |
23 | #include <linux/types.h> | 24 | #include <linux/types.h> |
24 | #include <linux/workqueue.h> | 25 | #include <linux/workqueue.h> |
@@ -112,6 +113,7 @@ struct inet_timewait_sock { | |||
112 | #define tw_node __tw_common.skc_node | 113 | #define tw_node __tw_common.skc_node |
113 | #define tw_bind_node __tw_common.skc_bind_node | 114 | #define tw_bind_node __tw_common.skc_bind_node |
114 | #define tw_refcnt __tw_common.skc_refcnt | 115 | #define tw_refcnt __tw_common.skc_refcnt |
116 | #define tw_hash __tw_common.skc_hash | ||
115 | #define tw_prot __tw_common.skc_prot | 117 | #define tw_prot __tw_common.skc_prot |
116 | volatile unsigned char tw_substate; | 118 | volatile unsigned char tw_substate; |
117 | /* 3 bits hole, try to pack */ | 119 | /* 3 bits hole, try to pack */ |
@@ -126,7 +128,6 @@ struct inet_timewait_sock { | |||
126 | /* And these are ours. */ | 128 | /* And these are ours. */ |
127 | __u8 tw_ipv6only:1; | 129 | __u8 tw_ipv6only:1; |
128 | /* 31 bits hole, try to pack */ | 130 | /* 31 bits hole, try to pack */ |
129 | int tw_hashent; | ||
130 | int tw_timeout; | 131 | int tw_timeout; |
131 | unsigned long tw_ttd; | 132 | unsigned long tw_ttd; |
132 | struct inet_bind_bucket *tw_tb; | 133 | struct inet_bind_bucket *tw_tb; |
@@ -193,11 +194,13 @@ static inline u32 inet_rcv_saddr(const struct sock *sk) | |||
193 | static inline void inet_twsk_put(struct inet_timewait_sock *tw) | 194 | static inline void inet_twsk_put(struct inet_timewait_sock *tw) |
194 | { | 195 | { |
195 | if (atomic_dec_and_test(&tw->tw_refcnt)) { | 196 | if (atomic_dec_and_test(&tw->tw_refcnt)) { |
197 | struct module *owner = tw->tw_prot->owner; | ||
196 | #ifdef SOCK_REFCNT_DEBUG | 198 | #ifdef SOCK_REFCNT_DEBUG |
197 | printk(KERN_DEBUG "%s timewait_sock %p released\n", | 199 | printk(KERN_DEBUG "%s timewait_sock %p released\n", |
198 | tw->tw_prot->name, tw); | 200 | tw->tw_prot->name, tw); |
199 | #endif | 201 | #endif |
200 | kmem_cache_free(tw->tw_prot->twsk_slab, tw); | 202 | kmem_cache_free(tw->tw_prot->twsk_slab, tw); |
203 | module_put(owner); | ||
201 | } | 204 | } |
202 | } | 205 | } |
203 | 206 | ||
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index 06b4235aa016..3b5559a023a4 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -832,7 +832,7 @@ extern void ip_vs_app_inc_put(struct ip_vs_app *inc); | |||
832 | 832 | ||
833 | extern int ip_vs_app_pkt_out(struct ip_vs_conn *, struct sk_buff **pskb); | 833 | extern int ip_vs_app_pkt_out(struct ip_vs_conn *, struct sk_buff **pskb); |
834 | extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff **pskb); | 834 | extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff **pskb); |
835 | extern int ip_vs_skb_replace(struct sk_buff *skb, int pri, | 835 | extern int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri, |
836 | char *o_buf, int o_len, char *n_buf, int n_len); | 836 | char *o_buf, int o_len, char *n_buf, int n_len); |
837 | extern int ip_vs_app_init(void); | 837 | extern int ip_vs_app_init(void); |
838 | extern void ip_vs_app_cleanup(void); | 838 | extern void ip_vs_app_cleanup(void); |
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 65ec86678a08..0a2ad51cff82 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -237,6 +237,8 @@ extern struct ipv6_txoptions * ipv6_renew_options(struct sock *sk, struct ipv6_t | |||
237 | int newtype, | 237 | int newtype, |
238 | struct ipv6_opt_hdr __user *newopt, | 238 | struct ipv6_opt_hdr __user *newopt, |
239 | int newoptlen); | 239 | int newoptlen); |
240 | struct ipv6_txoptions *ipv6_fixup_options(struct ipv6_txoptions *opt_space, | ||
241 | struct ipv6_txoptions *opt); | ||
240 | 242 | ||
241 | extern int ip6_frag_nqueues; | 243 | extern int ip6_frag_nqueues; |
242 | extern atomic_t ip6_frag_mem; | 244 | extern atomic_t ip6_frag_mem; |
@@ -252,12 +254,25 @@ typedef int (*inet_getfrag_t) (const void *data, | |||
252 | char *, | 254 | char *, |
253 | unsigned int, unsigned int); | 255 | unsigned int, unsigned int); |
254 | 256 | ||
255 | 257 | extern int __ipv6_addr_type(const struct in6_addr *addr); | |
256 | extern int ipv6_addr_type(const struct in6_addr *addr); | 258 | static inline int ipv6_addr_type(const struct in6_addr *addr) |
259 | { | ||
260 | return __ipv6_addr_type(addr) & 0xffff; | ||
261 | } | ||
257 | 262 | ||
258 | static inline int ipv6_addr_scope(const struct in6_addr *addr) | 263 | static inline int ipv6_addr_scope(const struct in6_addr *addr) |
259 | { | 264 | { |
260 | return ipv6_addr_type(addr) & IPV6_ADDR_SCOPE_MASK; | 265 | return __ipv6_addr_type(addr) & IPV6_ADDR_SCOPE_MASK; |
266 | } | ||
267 | |||
268 | static inline int __ipv6_addr_src_scope(int type) | ||
269 | { | ||
270 | return (type == IPV6_ADDR_ANY ? __IPV6_ADDR_SCOPE_INVALID : (type >> 16)); | ||
271 | } | ||
272 | |||
273 | static inline int ipv6_addr_src_scope(const struct in6_addr *addr) | ||
274 | { | ||
275 | return __ipv6_addr_src_scope(__ipv6_addr_type(addr)); | ||
261 | } | 276 | } |
262 | 277 | ||
263 | static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2) | 278 | static inline int ipv6_addr_cmp(const struct in6_addr *a1, const struct in6_addr *a2) |
@@ -341,6 +356,54 @@ static inline int ipv6_addr_any(const struct in6_addr *a) | |||
341 | } | 356 | } |
342 | 357 | ||
343 | /* | 358 | /* |
359 | * find the first different bit between two addresses | ||
360 | * length of address must be a multiple of 32bits | ||
361 | */ | ||
362 | static inline int __ipv6_addr_diff(const void *token1, const void *token2, int addrlen) | ||
363 | { | ||
364 | const __u32 *a1 = token1, *a2 = token2; | ||
365 | int i; | ||
366 | |||
367 | addrlen >>= 2; | ||
368 | |||
369 | for (i = 0; i < addrlen; i++) { | ||
370 | __u32 xb = a1[i] ^ a2[i]; | ||
371 | if (xb) { | ||
372 | int j = 31; | ||
373 | |||
374 | xb = ntohl(xb); | ||
375 | while ((xb & (1 << j)) == 0) | ||
376 | j--; | ||
377 | |||
378 | return (i * 32 + 31 - j); | ||
379 | } | ||
380 | } | ||
381 | |||
382 | /* | ||
383 | * we should *never* get to this point since that | ||
384 | * would mean the addrs are equal | ||
385 | * | ||
386 | * However, we do get to it 8) And exacly, when | ||
387 | * addresses are equal 8) | ||
388 | * | ||
389 | * ip route add 1111::/128 via ... | ||
390 | * ip route add 1111::/64 via ... | ||
391 | * and we are here. | ||
392 | * | ||
393 | * Ideally, this function should stop comparison | ||
394 | * at prefix length. It does not, but it is still OK, | ||
395 | * if returned value is greater than prefix length. | ||
396 | * --ANK (980803) | ||
397 | */ | ||
398 | return (addrlen << 5); | ||
399 | } | ||
400 | |||
401 | static inline int ipv6_addr_diff(const struct in6_addr *a1, const struct in6_addr *a2) | ||
402 | { | ||
403 | return __ipv6_addr_diff(a1, a2, sizeof(struct in6_addr)); | ||
404 | } | ||
405 | |||
406 | /* | ||
344 | * Prototypes exported by ipv6 | 407 | * Prototypes exported by ipv6 |
345 | */ | 408 | */ |
346 | 409 | ||
diff --git a/include/net/llc.h b/include/net/llc.h index 71769a5aeef3..1adb2ef3f6f7 100644 --- a/include/net/llc.h +++ b/include/net/llc.h | |||
@@ -17,6 +17,8 @@ | |||
17 | #include <linux/list.h> | 17 | #include <linux/list.h> |
18 | #include <linux/spinlock.h> | 18 | #include <linux/spinlock.h> |
19 | 19 | ||
20 | #include <asm/atomic.h> | ||
21 | |||
20 | struct net_device; | 22 | struct net_device; |
21 | struct packet_type; | 23 | struct packet_type; |
22 | struct sk_buff; | 24 | struct sk_buff; |
@@ -44,6 +46,7 @@ struct llc_sap { | |||
44 | unsigned char state; | 46 | unsigned char state; |
45 | unsigned char p_bit; | 47 | unsigned char p_bit; |
46 | unsigned char f_bit; | 48 | unsigned char f_bit; |
49 | atomic_t refcnt; | ||
47 | int (*rcv_func)(struct sk_buff *skb, | 50 | int (*rcv_func)(struct sk_buff *skb, |
48 | struct net_device *dev, | 51 | struct net_device *dev, |
49 | struct packet_type *pt, | 52 | struct packet_type *pt, |
@@ -81,13 +84,27 @@ extern struct llc_sap *llc_sap_open(unsigned char lsap, | |||
81 | struct net_device *dev, | 84 | struct net_device *dev, |
82 | struct packet_type *pt, | 85 | struct packet_type *pt, |
83 | struct net_device *orig_dev)); | 86 | struct net_device *orig_dev)); |
87 | static inline void llc_sap_hold(struct llc_sap *sap) | ||
88 | { | ||
89 | atomic_inc(&sap->refcnt); | ||
90 | } | ||
91 | |||
84 | extern void llc_sap_close(struct llc_sap *sap); | 92 | extern void llc_sap_close(struct llc_sap *sap); |
85 | 93 | ||
94 | static inline void llc_sap_put(struct llc_sap *sap) | ||
95 | { | ||
96 | if (atomic_dec_and_test(&sap->refcnt)) | ||
97 | llc_sap_close(sap); | ||
98 | } | ||
99 | |||
86 | extern struct llc_sap *llc_sap_find(unsigned char sap_value); | 100 | extern struct llc_sap *llc_sap_find(unsigned char sap_value); |
87 | 101 | ||
88 | extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, | 102 | extern int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, |
89 | unsigned char *dmac, unsigned char dsap); | 103 | unsigned char *dmac, unsigned char dsap); |
90 | 104 | ||
105 | extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb); | ||
106 | extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb); | ||
107 | |||
91 | extern int llc_station_init(void); | 108 | extern int llc_station_init(void); |
92 | extern void llc_station_exit(void); | 109 | extern void llc_station_exit(void); |
93 | 110 | ||
@@ -98,4 +115,17 @@ extern void llc_proc_exit(void); | |||
98 | #define llc_proc_init() (0) | 115 | #define llc_proc_init() (0) |
99 | #define llc_proc_exit() do { } while(0) | 116 | #define llc_proc_exit() do { } while(0) |
100 | #endif /* CONFIG_PROC_FS */ | 117 | #endif /* CONFIG_PROC_FS */ |
118 | #ifdef CONFIG_SYSCTL | ||
119 | extern int llc_sysctl_init(void); | ||
120 | extern void llc_sysctl_exit(void); | ||
121 | |||
122 | extern int sysctl_llc2_ack_timeout; | ||
123 | extern int sysctl_llc2_busy_timeout; | ||
124 | extern int sysctl_llc2_p_timeout; | ||
125 | extern int sysctl_llc2_rej_timeout; | ||
126 | extern int sysctl_llc_station_ack_timeout; | ||
127 | #else | ||
128 | #define llc_sysctl_init() (0) | ||
129 | #define llc_sysctl_exit() do { } while(0) | ||
130 | #endif /* CONFIG_SYSCTL */ | ||
101 | #endif /* LLC_H */ | 131 | #endif /* LLC_H */ |
diff --git a/include/net/llc_conn.h b/include/net/llc_conn.h index 8ad3bc2c23d7..00730d21b522 100644 --- a/include/net/llc_conn.h +++ b/include/net/llc_conn.h | |||
@@ -19,14 +19,14 @@ | |||
19 | #define LLC_EVENT 1 | 19 | #define LLC_EVENT 1 |
20 | #define LLC_PACKET 2 | 20 | #define LLC_PACKET 2 |
21 | 21 | ||
22 | #define LLC_P_TIME 2 | 22 | #define LLC2_P_TIME 2 |
23 | #define LLC_ACK_TIME 1 | 23 | #define LLC2_ACK_TIME 1 |
24 | #define LLC_REJ_TIME 3 | 24 | #define LLC2_REJ_TIME 3 |
25 | #define LLC_BUSY_TIME 3 | 25 | #define LLC2_BUSY_TIME 3 |
26 | 26 | ||
27 | struct llc_timer { | 27 | struct llc_timer { |
28 | struct timer_list timer; | 28 | struct timer_list timer; |
29 | u16 expire; /* timer expire time */ | 29 | unsigned long expire; /* timer expire time */ |
30 | }; | 30 | }; |
31 | 31 | ||
32 | struct llc_sock { | 32 | struct llc_sock { |
@@ -38,6 +38,7 @@ struct llc_sock { | |||
38 | struct llc_addr laddr; /* lsap/mac pair */ | 38 | struct llc_addr laddr; /* lsap/mac pair */ |
39 | struct llc_addr daddr; /* dsap/mac pair */ | 39 | struct llc_addr daddr; /* dsap/mac pair */ |
40 | struct net_device *dev; /* device to send to remote */ | 40 | struct net_device *dev; /* device to send to remote */ |
41 | u32 copied_seq; /* head of yet unread data */ | ||
41 | u8 retry_count; /* number of retries */ | 42 | u8 retry_count; /* number of retries */ |
42 | u8 ack_must_be_send; | 43 | u8 ack_must_be_send; |
43 | u8 first_pdu_Ns; | 44 | u8 first_pdu_Ns; |
@@ -92,7 +93,8 @@ static __inline__ char llc_backlog_type(struct sk_buff *skb) | |||
92 | return skb->cb[sizeof(skb->cb) - 1]; | 93 | return skb->cb[sizeof(skb->cb) - 1]; |
93 | } | 94 | } |
94 | 95 | ||
95 | extern struct sock *llc_sk_alloc(int family, int priority, struct proto *prot); | 96 | extern struct sock *llc_sk_alloc(int family, gfp_t priority, |
97 | struct proto *prot); | ||
96 | extern void llc_sk_free(struct sock *sk); | 98 | extern void llc_sk_free(struct sock *sk); |
97 | 99 | ||
98 | extern void llc_sk_reset(struct sock *sk); | 100 | extern void llc_sk_reset(struct sock *sk); |
@@ -115,5 +117,4 @@ extern void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk); | |||
115 | 117 | ||
116 | extern u8 llc_data_accept_state(u8 state); | 118 | extern u8 llc_data_accept_state(u8 state); |
117 | extern void llc_build_offset_table(void); | 119 | extern void llc_build_offset_table(void); |
118 | extern int llc_release_sockets(struct llc_sap *sap); | ||
119 | #endif /* LLC_CONN_H */ | 120 | #endif /* LLC_CONN_H */ |
diff --git a/include/net/llc_pdu.h b/include/net/llc_pdu.h index f45c37d89cf7..8f6306581fa7 100644 --- a/include/net/llc_pdu.h +++ b/include/net/llc_pdu.h | |||
@@ -254,8 +254,10 @@ static inline void llc_pdu_decode_sa(struct sk_buff *skb, u8 *sa) | |||
254 | { | 254 | { |
255 | if (skb->protocol == ntohs(ETH_P_802_2)) | 255 | if (skb->protocol == ntohs(ETH_P_802_2)) |
256 | memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN); | 256 | memcpy(sa, eth_hdr(skb)->h_source, ETH_ALEN); |
257 | else if (skb->protocol == ntohs(ETH_P_TR_802_2)) | 257 | else if (skb->protocol == ntohs(ETH_P_TR_802_2)) { |
258 | memcpy(sa, tr_hdr(skb)->saddr, ETH_ALEN); | 258 | memcpy(sa, tr_hdr(skb)->saddr, ETH_ALEN); |
259 | *sa &= 0x7F; | ||
260 | } | ||
259 | } | 261 | } |
260 | 262 | ||
261 | /** | 263 | /** |
@@ -355,7 +357,7 @@ static inline void llc_pdu_init_as_test_rsp(struct sk_buff *skb, | |||
355 | 357 | ||
356 | /* LLC Type 1 XID command/response information fields format */ | 358 | /* LLC Type 1 XID command/response information fields format */ |
357 | struct llc_xid_info { | 359 | struct llc_xid_info { |
358 | u8 fmt_id; /* always 0x18 for LLC */ | 360 | u8 fmt_id; /* always 0x81 for LLC */ |
359 | u8 type; /* different if NULL/non-NULL LSAP */ | 361 | u8 type; /* different if NULL/non-NULL LSAP */ |
360 | u8 rw; /* sender receive window */ | 362 | u8 rw; /* sender receive window */ |
361 | }; | 363 | }; |
diff --git a/include/net/llc_sap.h b/include/net/llc_sap.h index 353baaa627f3..2c56dbece729 100644 --- a/include/net/llc_sap.h +++ b/include/net/llc_sap.h | |||
@@ -12,11 +12,15 @@ | |||
12 | * See the GNU General Public License for more details. | 12 | * See the GNU General Public License for more details. |
13 | */ | 13 | */ |
14 | struct llc_sap; | 14 | struct llc_sap; |
15 | struct net_device; | ||
15 | struct sk_buff; | 16 | struct sk_buff; |
17 | struct sock; | ||
16 | 18 | ||
17 | extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb); | 19 | extern void llc_sap_rtn_pdu(struct llc_sap *sap, struct sk_buff *skb); |
18 | extern void llc_save_primitive(struct sk_buff* skb, unsigned char prim); | 20 | extern void llc_save_primitive(struct sock *sk, struct sk_buff* skb, |
19 | extern struct sk_buff *llc_alloc_frame(void); | 21 | unsigned char prim); |
22 | extern struct sk_buff *llc_alloc_frame(struct sock *sk, | ||
23 | struct net_device *dev); | ||
20 | 24 | ||
21 | extern void llc_build_and_send_test_pkt(struct llc_sap *sap, | 25 | extern void llc_build_and_send_test_pkt(struct llc_sap *sap, |
22 | struct sk_buff *skb, | 26 | struct sk_buff *skb, |
diff --git a/include/net/netfilter/ipv4/nf_conntrack_icmp.h b/include/net/netfilter/ipv4/nf_conntrack_icmp.h new file mode 100644 index 000000000000..3dd22cff23ec --- /dev/null +++ b/include/net/netfilter/ipv4/nf_conntrack_icmp.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef _NF_CONNTRACK_ICMP_H | ||
2 | #define _NF_CONNTRACK_ICMP_H | ||
3 | /* ICMP tracking. */ | ||
4 | #include <asm/atomic.h> | ||
5 | |||
6 | struct ip_ct_icmp | ||
7 | { | ||
8 | /* Optimization: when number in == number out, forget immediately. */ | ||
9 | atomic_t count; | ||
10 | }; | ||
11 | #endif /* _NF_CONNTRACK_ICMP_H */ | ||
diff --git a/include/net/netfilter/ipv4/nf_conntrack_ipv4.h b/include/net/netfilter/ipv4/nf_conntrack_ipv4.h new file mode 100644 index 000000000000..25b081a730e6 --- /dev/null +++ b/include/net/netfilter/ipv4/nf_conntrack_ipv4.h | |||
@@ -0,0 +1,43 @@ | |||
1 | /* | ||
2 | * IPv4 support for nf_conntrack. | ||
3 | * | ||
4 | * 23 Mar 2004: Yasuyuki Kozakai @ USAGI <yasuyuki.kozakai@toshiba.co.jp> | ||
5 | * - move L3 protocol dependent part from include/linux/netfilter_ipv4/ | ||
6 | * ip_conntarck.h | ||
7 | */ | ||
8 | |||
9 | #ifndef _NF_CONNTRACK_IPV4_H | ||
10 | #define _NF_CONNTRACK_IPV4_H | ||
11 | |||
12 | #ifdef CONFIG_IP_NF_NAT_NEEDED | ||
13 | #include <linux/netfilter_ipv4/ip_nat.h> | ||
14 | |||
15 | /* per conntrack: nat application helper private data */ | ||
16 | union ip_conntrack_nat_help { | ||
17 | /* insert nat helper private data here */ | ||
18 | }; | ||
19 | |||
20 | struct nf_conntrack_ipv4_nat { | ||
21 | struct ip_nat_info info; | ||
22 | union ip_conntrack_nat_help help; | ||
23 | #if defined(CONFIG_IP_NF_TARGET_MASQUERADE) || \ | ||
24 | defined(CONFIG_IP_NF_TARGET_MASQUERADE_MODULE) | ||
25 | int masq_index; | ||
26 | #endif | ||
27 | }; | ||
28 | #endif /* CONFIG_IP_NF_NAT_NEEDED */ | ||
29 | |||
30 | struct nf_conntrack_ipv4 { | ||
31 | #ifdef CONFIG_IP_NF_NAT_NEEDED | ||
32 | struct nf_conntrack_ipv4_nat *nat; | ||
33 | #endif | ||
34 | }; | ||
35 | |||
36 | /* Returns new sk_buff, or NULL */ | ||
37 | struct sk_buff * | ||
38 | nf_ct_ipv4_ct_gather_frags(struct sk_buff *skb); | ||
39 | |||
40 | /* call to create an explicit dependency on nf_conntrack_l3proto_ipv4. */ | ||
41 | extern void need_ip_conntrack(void); | ||
42 | |||
43 | #endif /*_NF_CONNTRACK_IPV4_H*/ | ||
diff --git a/include/net/netfilter/ipv6/nf_conntrack_icmpv6.h b/include/net/netfilter/ipv6/nf_conntrack_icmpv6.h new file mode 100644 index 000000000000..86591afda29c --- /dev/null +++ b/include/net/netfilter/ipv6/nf_conntrack_icmpv6.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * ICMPv6 tracking. | ||
3 | * | ||
4 | * 21 Apl 2004: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | ||
5 | * - separated from nf_conntrack_icmp.h | ||
6 | * | ||
7 | * Derived from include/linux/netfiter_ipv4/ip_conntrack_icmp.h | ||
8 | */ | ||
9 | |||
10 | #ifndef _NF_CONNTRACK_ICMPV6_H | ||
11 | #define _NF_CONNTRACK_ICMPV6_H | ||
12 | #include <asm/atomic.h> | ||
13 | |||
14 | #ifndef ICMPV6_NI_QUERY | ||
15 | #define ICMPV6_NI_QUERY 139 | ||
16 | #endif | ||
17 | #ifndef ICMPV6_NI_REPLY | ||
18 | #define ICMPV6_NI_REPLY 140 | ||
19 | #endif | ||
20 | |||
21 | struct nf_ct_icmpv6 | ||
22 | { | ||
23 | /* Optimization: when number in == number out, forget immediately. */ | ||
24 | atomic_t count; | ||
25 | }; | ||
26 | |||
27 | #endif /* _NF_CONNTRACK_ICMPV6_H */ | ||
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h new file mode 100644 index 000000000000..cc4825610795 --- /dev/null +++ b/include/net/netfilter/nf_conntrack.h | |||
@@ -0,0 +1,354 @@ | |||
1 | /* | ||
2 | * Connection state tracking for netfilter. This is separated from, | ||
3 | * but required by, the (future) NAT layer; it can also be used by an iptables | ||
4 | * extension. | ||
5 | * | ||
6 | * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | ||
7 | * - generalize L3 protocol dependent part. | ||
8 | * | ||
9 | * Derived from include/linux/netfiter_ipv4/ip_conntrack.h | ||
10 | */ | ||
11 | |||
12 | #ifndef _NF_CONNTRACK_H | ||
13 | #define _NF_CONNTRACK_H | ||
14 | |||
15 | #include <linux/netfilter/nf_conntrack_common.h> | ||
16 | |||
17 | #ifdef __KERNEL__ | ||
18 | #include <linux/config.h> | ||
19 | #include <linux/bitops.h> | ||
20 | #include <linux/compiler.h> | ||
21 | #include <asm/atomic.h> | ||
22 | |||
23 | #include <linux/netfilter/nf_conntrack_tcp.h> | ||
24 | #include <linux/netfilter/nf_conntrack_sctp.h> | ||
25 | #include <net/netfilter/ipv4/nf_conntrack_icmp.h> | ||
26 | #include <net/netfilter/ipv6/nf_conntrack_icmpv6.h> | ||
27 | |||
28 | #include <net/netfilter/nf_conntrack_tuple.h> | ||
29 | |||
30 | /* per conntrack: protocol private data */ | ||
31 | union nf_conntrack_proto { | ||
32 | /* insert conntrack proto private data here */ | ||
33 | struct ip_ct_sctp sctp; | ||
34 | struct ip_ct_tcp tcp; | ||
35 | struct ip_ct_icmp icmp; | ||
36 | struct nf_ct_icmpv6 icmpv6; | ||
37 | }; | ||
38 | |||
39 | union nf_conntrack_expect_proto { | ||
40 | /* insert expect proto private data here */ | ||
41 | }; | ||
42 | |||
43 | /* Add protocol helper include file here */ | ||
44 | #include <linux/netfilter/nf_conntrack_ftp.h> | ||
45 | |||
46 | /* per conntrack: application helper private data */ | ||
47 | union nf_conntrack_help { | ||
48 | /* insert conntrack helper private data (master) here */ | ||
49 | struct ip_ct_ftp_master ct_ftp_info; | ||
50 | }; | ||
51 | |||
52 | #include <linux/types.h> | ||
53 | #include <linux/skbuff.h> | ||
54 | |||
55 | #ifdef CONFIG_NETFILTER_DEBUG | ||
56 | #define NF_CT_ASSERT(x) \ | ||
57 | do { \ | ||
58 | if (!(x)) \ | ||
59 | /* Wooah! I'm tripping my conntrack in a frenzy of \ | ||
60 | netplay... */ \ | ||
61 | printk("NF_CT_ASSERT: %s:%i(%s)\n", \ | ||
62 | __FILE__, __LINE__, __FUNCTION__); \ | ||
63 | } while(0) | ||
64 | #else | ||
65 | #define NF_CT_ASSERT(x) | ||
66 | #endif | ||
67 | |||
68 | struct nf_conntrack_helper; | ||
69 | |||
70 | #include <net/netfilter/ipv4/nf_conntrack_ipv4.h> | ||
71 | struct nf_conn | ||
72 | { | ||
73 | /* Usage count in here is 1 for hash table/destruct timer, 1 per skb, | ||
74 | plus 1 for any connection(s) we are `master' for */ | ||
75 | struct nf_conntrack ct_general; | ||
76 | |||
77 | /* XXX should I move this to the tail ? - Y.K */ | ||
78 | /* These are my tuples; original and reply */ | ||
79 | struct nf_conntrack_tuple_hash tuplehash[IP_CT_DIR_MAX]; | ||
80 | |||
81 | /* Have we seen traffic both ways yet? (bitset) */ | ||
82 | unsigned long status; | ||
83 | |||
84 | /* Timer function; drops refcnt when it goes off. */ | ||
85 | struct timer_list timeout; | ||
86 | |||
87 | #ifdef CONFIG_NF_CT_ACCT | ||
88 | /* Accounting Information (same cache line as other written members) */ | ||
89 | struct ip_conntrack_counter counters[IP_CT_DIR_MAX]; | ||
90 | #endif | ||
91 | /* If we were expected by an expectation, this will be it */ | ||
92 | struct nf_conn *master; | ||
93 | |||
94 | /* Current number of expected connections */ | ||
95 | unsigned int expecting; | ||
96 | |||
97 | /* Helper. if any */ | ||
98 | struct nf_conntrack_helper *helper; | ||
99 | |||
100 | /* features - nat, helper, ... used by allocating system */ | ||
101 | u_int32_t features; | ||
102 | |||
103 | /* Storage reserved for other modules: */ | ||
104 | |||
105 | union nf_conntrack_proto proto; | ||
106 | |||
107 | #if defined(CONFIG_NF_CONNTRACK_MARK) | ||
108 | u_int32_t mark; | ||
109 | #endif | ||
110 | |||
111 | /* These members are dynamically allocated. */ | ||
112 | |||
113 | union nf_conntrack_help *help; | ||
114 | |||
115 | /* Layer 3 dependent members. (ex: NAT) */ | ||
116 | union { | ||
117 | struct nf_conntrack_ipv4 *ipv4; | ||
118 | } l3proto; | ||
119 | void *data[0]; | ||
120 | }; | ||
121 | |||
122 | struct nf_conntrack_expect | ||
123 | { | ||
124 | /* Internal linked list (global expectation list) */ | ||
125 | struct list_head list; | ||
126 | |||
127 | /* We expect this tuple, with the following mask */ | ||
128 | struct nf_conntrack_tuple tuple, mask; | ||
129 | |||
130 | /* Function to call after setup and insertion */ | ||
131 | void (*expectfn)(struct nf_conn *new, | ||
132 | struct nf_conntrack_expect *this); | ||
133 | |||
134 | /* The conntrack of the master connection */ | ||
135 | struct nf_conn *master; | ||
136 | |||
137 | /* Timer function; deletes the expectation. */ | ||
138 | struct timer_list timeout; | ||
139 | |||
140 | /* Usage count. */ | ||
141 | atomic_t use; | ||
142 | |||
143 | /* Flags */ | ||
144 | unsigned int flags; | ||
145 | |||
146 | #ifdef CONFIG_NF_NAT_NEEDED | ||
147 | /* This is the original per-proto part, used to map the | ||
148 | * expected connection the way the recipient expects. */ | ||
149 | union nf_conntrack_manip_proto saved_proto; | ||
150 | /* Direction relative to the master connection. */ | ||
151 | enum ip_conntrack_dir dir; | ||
152 | #endif | ||
153 | }; | ||
154 | |||
155 | #define NF_CT_EXPECT_PERMANENT 0x1 | ||
156 | |||
157 | static inline struct nf_conn * | ||
158 | nf_ct_tuplehash_to_ctrack(const struct nf_conntrack_tuple_hash *hash) | ||
159 | { | ||
160 | return container_of(hash, struct nf_conn, | ||
161 | tuplehash[hash->tuple.dst.dir]); | ||
162 | } | ||
163 | |||
164 | /* get master conntrack via master expectation */ | ||
165 | #define master_ct(conntr) (conntr->master) | ||
166 | |||
167 | /* Alter reply tuple (maybe alter helper). */ | ||
168 | extern void | ||
169 | nf_conntrack_alter_reply(struct nf_conn *conntrack, | ||
170 | const struct nf_conntrack_tuple *newreply); | ||
171 | |||
172 | /* Is this tuple taken? (ignoring any belonging to the given | ||
173 | conntrack). */ | ||
174 | extern int | ||
175 | nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple, | ||
176 | const struct nf_conn *ignored_conntrack); | ||
177 | |||
178 | /* Return conntrack_info and tuple hash for given skb. */ | ||
179 | static inline struct nf_conn * | ||
180 | nf_ct_get(const struct sk_buff *skb, enum ip_conntrack_info *ctinfo) | ||
181 | { | ||
182 | *ctinfo = skb->nfctinfo; | ||
183 | return (struct nf_conn *)skb->nfct; | ||
184 | } | ||
185 | |||
186 | /* decrement reference count on a conntrack */ | ||
187 | static inline void nf_ct_put(struct nf_conn *ct) | ||
188 | { | ||
189 | NF_CT_ASSERT(ct); | ||
190 | nf_conntrack_put(&ct->ct_general); | ||
191 | } | ||
192 | |||
193 | /* call to create an explicit dependency on nf_conntrack. */ | ||
194 | extern void need_nf_conntrack(void); | ||
195 | |||
196 | extern int nf_ct_invert_tuplepr(struct nf_conntrack_tuple *inverse, | ||
197 | const struct nf_conntrack_tuple *orig); | ||
198 | |||
199 | extern void __nf_ct_refresh_acct(struct nf_conn *ct, | ||
200 | enum ip_conntrack_info ctinfo, | ||
201 | const struct sk_buff *skb, | ||
202 | unsigned long extra_jiffies, | ||
203 | int do_acct); | ||
204 | |||
205 | /* Refresh conntrack for this many jiffies and do accounting */ | ||
206 | static inline void nf_ct_refresh_acct(struct nf_conn *ct, | ||
207 | enum ip_conntrack_info ctinfo, | ||
208 | const struct sk_buff *skb, | ||
209 | unsigned long extra_jiffies) | ||
210 | { | ||
211 | __nf_ct_refresh_acct(ct, ctinfo, skb, extra_jiffies, 1); | ||
212 | } | ||
213 | |||
214 | /* Refresh conntrack for this many jiffies */ | ||
215 | static inline void nf_ct_refresh(struct nf_conn *ct, | ||
216 | const struct sk_buff *skb, | ||
217 | unsigned long extra_jiffies) | ||
218 | { | ||
219 | __nf_ct_refresh_acct(ct, 0, skb, extra_jiffies, 0); | ||
220 | } | ||
221 | |||
222 | /* These are for NAT. Icky. */ | ||
223 | /* Update TCP window tracking data when NAT mangles the packet */ | ||
224 | extern void nf_conntrack_tcp_update(struct sk_buff *skb, | ||
225 | unsigned int dataoff, | ||
226 | struct nf_conn *conntrack, | ||
227 | int dir); | ||
228 | |||
229 | /* Call me when a conntrack is destroyed. */ | ||
230 | extern void (*nf_conntrack_destroyed)(struct nf_conn *conntrack); | ||
231 | |||
232 | /* Fake conntrack entry for untracked connections */ | ||
233 | extern struct nf_conn nf_conntrack_untracked; | ||
234 | |||
235 | extern int nf_ct_no_defrag; | ||
236 | |||
237 | /* Iterate over all conntracks: if iter returns true, it's deleted. */ | ||
238 | extern void | ||
239 | nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data); | ||
240 | extern void nf_conntrack_free(struct nf_conn *ct); | ||
241 | extern struct nf_conn * | ||
242 | nf_conntrack_alloc(const struct nf_conntrack_tuple *orig, | ||
243 | const struct nf_conntrack_tuple *repl); | ||
244 | |||
245 | /* It's confirmed if it is, or has been in the hash table. */ | ||
246 | static inline int nf_ct_is_confirmed(struct nf_conn *ct) | ||
247 | { | ||
248 | return test_bit(IPS_CONFIRMED_BIT, &ct->status); | ||
249 | } | ||
250 | |||
251 | static inline int nf_ct_is_dying(struct nf_conn *ct) | ||
252 | { | ||
253 | return test_bit(IPS_DYING_BIT, &ct->status); | ||
254 | } | ||
255 | |||
256 | extern unsigned int nf_conntrack_htable_size; | ||
257 | |||
258 | #define NF_CT_STAT_INC(count) (__get_cpu_var(nf_conntrack_stat).count++) | ||
259 | |||
260 | #ifdef CONFIG_NF_CONNTRACK_EVENTS | ||
261 | #include <linux/notifier.h> | ||
262 | #include <linux/interrupt.h> | ||
263 | |||
264 | struct nf_conntrack_ecache { | ||
265 | struct nf_conn *ct; | ||
266 | unsigned int events; | ||
267 | }; | ||
268 | DECLARE_PER_CPU(struct nf_conntrack_ecache, nf_conntrack_ecache); | ||
269 | |||
270 | #define CONNTRACK_ECACHE(x) (__get_cpu_var(nf_conntrack_ecache).x) | ||
271 | |||
272 | extern struct notifier_block *nf_conntrack_chain; | ||
273 | extern struct notifier_block *nf_conntrack_expect_chain; | ||
274 | |||
275 | static inline int nf_conntrack_register_notifier(struct notifier_block *nb) | ||
276 | { | ||
277 | return notifier_chain_register(&nf_conntrack_chain, nb); | ||
278 | } | ||
279 | |||
280 | static inline int nf_conntrack_unregister_notifier(struct notifier_block *nb) | ||
281 | { | ||
282 | return notifier_chain_unregister(&nf_conntrack_chain, nb); | ||
283 | } | ||
284 | |||
285 | static inline int | ||
286 | nf_conntrack_expect_register_notifier(struct notifier_block *nb) | ||
287 | { | ||
288 | return notifier_chain_register(&nf_conntrack_expect_chain, nb); | ||
289 | } | ||
290 | |||
291 | static inline int | ||
292 | nf_conntrack_expect_unregister_notifier(struct notifier_block *nb) | ||
293 | { | ||
294 | return notifier_chain_unregister(&nf_conntrack_expect_chain, nb); | ||
295 | } | ||
296 | |||
297 | extern void nf_ct_deliver_cached_events(const struct nf_conn *ct); | ||
298 | extern void __nf_ct_event_cache_init(struct nf_conn *ct); | ||
299 | |||
300 | static inline void | ||
301 | nf_conntrack_event_cache(enum ip_conntrack_events event, | ||
302 | const struct sk_buff *skb) | ||
303 | { | ||
304 | struct nf_conn *ct = (struct nf_conn *)skb->nfct; | ||
305 | struct nf_conntrack_ecache *ecache; | ||
306 | |||
307 | local_bh_disable(); | ||
308 | ecache = &__get_cpu_var(nf_conntrack_ecache); | ||
309 | if (ct != ecache->ct) | ||
310 | __nf_ct_event_cache_init(ct); | ||
311 | ecache->events |= event; | ||
312 | local_bh_enable(); | ||
313 | } | ||
314 | |||
315 | static inline void nf_conntrack_event(enum ip_conntrack_events event, | ||
316 | struct nf_conn *ct) | ||
317 | { | ||
318 | if (nf_ct_is_confirmed(ct) && !nf_ct_is_dying(ct)) | ||
319 | notifier_call_chain(&nf_conntrack_chain, event, ct); | ||
320 | } | ||
321 | |||
322 | static inline void | ||
323 | nf_conntrack_expect_event(enum ip_conntrack_expect_events event, | ||
324 | struct nf_conntrack_expect *exp) | ||
325 | { | ||
326 | notifier_call_chain(&nf_conntrack_expect_chain, event, exp); | ||
327 | } | ||
328 | #else /* CONFIG_NF_CONNTRACK_EVENTS */ | ||
329 | static inline void nf_conntrack_event_cache(enum ip_conntrack_events event, | ||
330 | const struct sk_buff *skb) {} | ||
331 | static inline void nf_conntrack_event(enum ip_conntrack_events event, | ||
332 | struct nf_conn *ct) {} | ||
333 | static inline void nf_ct_deliver_cached_events(const struct nf_conn *ct) {} | ||
334 | static inline void | ||
335 | nf_conntrack_expect_event(enum ip_conntrack_expect_events event, | ||
336 | struct nf_conntrack_expect *exp) {} | ||
337 | #endif /* CONFIG_NF_CONNTRACK_EVENTS */ | ||
338 | |||
339 | /* no helper, no nat */ | ||
340 | #define NF_CT_F_BASIC 0 | ||
341 | /* for helper */ | ||
342 | #define NF_CT_F_HELP 1 | ||
343 | /* for nat. */ | ||
344 | #define NF_CT_F_NAT 2 | ||
345 | #define NF_CT_F_NUM 4 | ||
346 | |||
347 | extern int | ||
348 | nf_conntrack_register_cache(u_int32_t features, const char *name, size_t size, | ||
349 | int (*init_conntrack)(struct nf_conn *, u_int32_t)); | ||
350 | extern void | ||
351 | nf_conntrack_unregister_cache(u_int32_t features); | ||
352 | |||
353 | #endif /* __KERNEL__ */ | ||
354 | #endif /* _NF_CONNTRACK_H */ | ||
diff --git a/include/net/netfilter/nf_conntrack_compat.h b/include/net/netfilter/nf_conntrack_compat.h new file mode 100644 index 000000000000..3cac19fb3648 --- /dev/null +++ b/include/net/netfilter/nf_conntrack_compat.h | |||
@@ -0,0 +1,108 @@ | |||
1 | #ifndef _NF_CONNTRACK_COMPAT_H | ||
2 | #define _NF_CONNTRACK_COMPAT_H | ||
3 | |||
4 | #ifdef __KERNEL__ | ||
5 | |||
6 | #if defined(CONFIG_IP_NF_CONNTRACK) || defined(CONFIG_IP_NF_CONNTRACK_MODULE) | ||
7 | |||
8 | #include <linux/netfilter_ipv4/ip_conntrack.h> | ||
9 | |||
10 | #ifdef CONFIG_IP_NF_CONNTRACK_MARK | ||
11 | static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb, | ||
12 | u_int32_t *ctinfo) | ||
13 | { | ||
14 | struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo); | ||
15 | |||
16 | if (ct) | ||
17 | return &ct->mark; | ||
18 | else | ||
19 | return NULL; | ||
20 | } | ||
21 | #endif /* CONFIG_IP_NF_CONNTRACK_MARK */ | ||
22 | |||
23 | #ifdef CONFIG_IP_NF_CT_ACCT | ||
24 | static inline struct ip_conntrack_counter * | ||
25 | nf_ct_get_counters(const struct sk_buff *skb) | ||
26 | { | ||
27 | enum ip_conntrack_info ctinfo; | ||
28 | struct ip_conntrack *ct = ip_conntrack_get(skb, &ctinfo); | ||
29 | |||
30 | if (ct) | ||
31 | return ct->counters; | ||
32 | else | ||
33 | return NULL; | ||
34 | } | ||
35 | #endif /* CONFIG_IP_NF_CT_ACCT */ | ||
36 | |||
37 | static inline int nf_ct_is_untracked(const struct sk_buff *skb) | ||
38 | { | ||
39 | return (skb->nfct == &ip_conntrack_untracked.ct_general); | ||
40 | } | ||
41 | |||
42 | static inline void nf_ct_untrack(struct sk_buff *skb) | ||
43 | { | ||
44 | skb->nfct = &ip_conntrack_untracked.ct_general; | ||
45 | } | ||
46 | |||
47 | static inline int nf_ct_get_ctinfo(const struct sk_buff *skb, | ||
48 | enum ip_conntrack_info *ctinfo) | ||
49 | { | ||
50 | struct ip_conntrack *ct = ip_conntrack_get(skb, ctinfo); | ||
51 | return (ct != NULL); | ||
52 | } | ||
53 | |||
54 | #else /* CONFIG_IP_NF_CONNTRACK */ | ||
55 | |||
56 | #include <net/netfilter/ipv4/nf_conntrack_ipv4.h> | ||
57 | #include <net/netfilter/nf_conntrack.h> | ||
58 | |||
59 | #ifdef CONFIG_NF_CONNTRACK_MARK | ||
60 | |||
61 | static inline u_int32_t *nf_ct_get_mark(const struct sk_buff *skb, | ||
62 | u_int32_t *ctinfo) | ||
63 | { | ||
64 | struct nf_conn *ct = nf_ct_get(skb, ctinfo); | ||
65 | |||
66 | if (ct) | ||
67 | return &ct->mark; | ||
68 | else | ||
69 | return NULL; | ||
70 | } | ||
71 | #endif /* CONFIG_NF_CONNTRACK_MARK */ | ||
72 | |||
73 | #ifdef CONFIG_NF_CT_ACCT | ||
74 | static inline struct ip_conntrack_counter * | ||
75 | nf_ct_get_counters(const struct sk_buff *skb) | ||
76 | { | ||
77 | enum ip_conntrack_info ctinfo; | ||
78 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | ||
79 | |||
80 | if (ct) | ||
81 | return ct->counters; | ||
82 | else | ||
83 | return NULL; | ||
84 | } | ||
85 | #endif /* CONFIG_NF_CT_ACCT */ | ||
86 | |||
87 | static inline int nf_ct_is_untracked(const struct sk_buff *skb) | ||
88 | { | ||
89 | return (skb->nfct == &nf_conntrack_untracked.ct_general); | ||
90 | } | ||
91 | |||
92 | static inline void nf_ct_untrack(struct sk_buff *skb) | ||
93 | { | ||
94 | skb->nfct = &nf_conntrack_untracked.ct_general; | ||
95 | } | ||
96 | |||
97 | static inline int nf_ct_get_ctinfo(const struct sk_buff *skb, | ||
98 | enum ip_conntrack_info *ctinfo) | ||
99 | { | ||
100 | struct nf_conn *ct = nf_ct_get(skb, ctinfo); | ||
101 | return (ct != NULL); | ||
102 | } | ||
103 | |||
104 | #endif /* CONFIG_IP_NF_CONNTRACK */ | ||
105 | |||
106 | #endif /* __KERNEL__ */ | ||
107 | |||
108 | #endif /* _NF_CONNTRACK_COMPAT_H */ | ||
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h new file mode 100644 index 000000000000..da254525a4ce --- /dev/null +++ b/include/net/netfilter/nf_conntrack_core.h | |||
@@ -0,0 +1,76 @@ | |||
1 | /* | ||
2 | * This header is used to share core functionality between the | ||
3 | * standalone connection tracking module, and the compatibility layer's use | ||
4 | * of connection tracking. | ||
5 | * | ||
6 | * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | ||
7 | * - generalize L3 protocol dependent part. | ||
8 | * | ||
9 | * Derived from include/linux/netfiter_ipv4/ip_conntrack_core.h | ||
10 | */ | ||
11 | |||
12 | #ifndef _NF_CONNTRACK_CORE_H | ||
13 | #define _NF_CONNTRACK_CORE_H | ||
14 | |||
15 | #include <linux/netfilter.h> | ||
16 | |||
17 | /* This header is used to share core functionality between the | ||
18 | standalone connection tracking module, and the compatibility layer's use | ||
19 | of connection tracking. */ | ||
20 | extern unsigned int nf_conntrack_in(int pf, | ||
21 | unsigned int hooknum, | ||
22 | struct sk_buff **pskb); | ||
23 | |||
24 | extern int nf_conntrack_init(void); | ||
25 | extern void nf_conntrack_cleanup(void); | ||
26 | |||
27 | struct nf_conntrack_l3proto; | ||
28 | extern struct nf_conntrack_l3proto *nf_ct_find_l3proto(u_int16_t pf); | ||
29 | /* Like above, but you already have conntrack read lock. */ | ||
30 | extern struct nf_conntrack_l3proto *__nf_ct_find_l3proto(u_int16_t l3proto); | ||
31 | |||
32 | struct nf_conntrack_protocol; | ||
33 | |||
34 | extern int | ||
35 | nf_ct_get_tuple(const struct sk_buff *skb, | ||
36 | unsigned int nhoff, | ||
37 | unsigned int dataoff, | ||
38 | u_int16_t l3num, | ||
39 | u_int8_t protonum, | ||
40 | struct nf_conntrack_tuple *tuple, | ||
41 | const struct nf_conntrack_l3proto *l3proto, | ||
42 | const struct nf_conntrack_protocol *protocol); | ||
43 | |||
44 | extern int | ||
45 | nf_ct_invert_tuple(struct nf_conntrack_tuple *inverse, | ||
46 | const struct nf_conntrack_tuple *orig, | ||
47 | const struct nf_conntrack_l3proto *l3proto, | ||
48 | const struct nf_conntrack_protocol *protocol); | ||
49 | |||
50 | /* Find a connection corresponding to a tuple. */ | ||
51 | extern struct nf_conntrack_tuple_hash * | ||
52 | nf_conntrack_find_get(const struct nf_conntrack_tuple *tuple, | ||
53 | const struct nf_conn *ignored_conntrack); | ||
54 | |||
55 | extern int __nf_conntrack_confirm(struct sk_buff **pskb); | ||
56 | |||
57 | /* Confirm a connection: returns NF_DROP if packet must be dropped. */ | ||
58 | static inline int nf_conntrack_confirm(struct sk_buff **pskb) | ||
59 | { | ||
60 | struct nf_conn *ct = (struct nf_conn *)(*pskb)->nfct; | ||
61 | int ret = NF_ACCEPT; | ||
62 | |||
63 | if (ct) { | ||
64 | if (!nf_ct_is_confirmed(ct)) | ||
65 | ret = __nf_conntrack_confirm(pskb); | ||
66 | nf_ct_deliver_cached_events(ct); | ||
67 | } | ||
68 | return ret; | ||
69 | } | ||
70 | |||
71 | extern void __nf_conntrack_attach(struct sk_buff *nskb, struct sk_buff *skb); | ||
72 | |||
73 | extern struct list_head *nf_conntrack_hash; | ||
74 | extern struct list_head nf_conntrack_expect_list; | ||
75 | extern rwlock_t nf_conntrack_lock ; | ||
76 | #endif /* _NF_CONNTRACK_CORE_H */ | ||
diff --git a/include/net/netfilter/nf_conntrack_helper.h b/include/net/netfilter/nf_conntrack_helper.h new file mode 100644 index 000000000000..5a66b2a3a623 --- /dev/null +++ b/include/net/netfilter/nf_conntrack_helper.h | |||
@@ -0,0 +1,51 @@ | |||
1 | /* | ||
2 | * connection tracking helpers. | ||
3 | * | ||
4 | * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | ||
5 | * - generalize L3 protocol dependent part. | ||
6 | * | ||
7 | * Derived from include/linux/netfiter_ipv4/ip_conntrack_helper.h | ||
8 | */ | ||
9 | |||
10 | #ifndef _NF_CONNTRACK_HELPER_H | ||
11 | #define _NF_CONNTRACK_HELPER_H | ||
12 | #include <net/netfilter/nf_conntrack.h> | ||
13 | |||
14 | struct module; | ||
15 | |||
16 | struct nf_conntrack_helper | ||
17 | { | ||
18 | struct list_head list; /* Internal use. */ | ||
19 | |||
20 | const char *name; /* name of the module */ | ||
21 | struct module *me; /* pointer to self */ | ||
22 | unsigned int max_expected; /* Maximum number of concurrent | ||
23 | * expected connections */ | ||
24 | unsigned int timeout; /* timeout for expecteds */ | ||
25 | |||
26 | /* Mask of things we will help (compared against server response) */ | ||
27 | struct nf_conntrack_tuple tuple; | ||
28 | struct nf_conntrack_tuple mask; | ||
29 | |||
30 | /* Function to call when data passes; return verdict, or -1 to | ||
31 | invalidate. */ | ||
32 | int (*help)(struct sk_buff **pskb, | ||
33 | unsigned int protoff, | ||
34 | struct nf_conn *ct, | ||
35 | enum ip_conntrack_info conntrackinfo); | ||
36 | }; | ||
37 | |||
38 | extern int nf_conntrack_helper_register(struct nf_conntrack_helper *); | ||
39 | extern void nf_conntrack_helper_unregister(struct nf_conntrack_helper *); | ||
40 | |||
41 | /* Allocate space for an expectation: this is mandatory before calling | ||
42 | nf_conntrack_expect_related. You will have to call put afterwards. */ | ||
43 | extern struct nf_conntrack_expect * | ||
44 | nf_conntrack_expect_alloc(struct nf_conn *master); | ||
45 | extern void nf_conntrack_expect_put(struct nf_conntrack_expect *exp); | ||
46 | |||
47 | /* Add an expected connection: can have more than one per connection */ | ||
48 | extern int nf_conntrack_expect_related(struct nf_conntrack_expect *exp); | ||
49 | extern void nf_conntrack_unexpect_related(struct nf_conntrack_expect *exp); | ||
50 | |||
51 | #endif /*_NF_CONNTRACK_HELPER_H*/ | ||
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h new file mode 100644 index 000000000000..01663e5b33df --- /dev/null +++ b/include/net/netfilter/nf_conntrack_l3proto.h | |||
@@ -0,0 +1,93 @@ | |||
1 | /* | ||
2 | * Copyright (C)2003,2004 USAGI/WIDE Project | ||
3 | * | ||
4 | * Header for use in defining a given L3 protocol for connection tracking. | ||
5 | * | ||
6 | * Author: | ||
7 | * Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | ||
8 | * | ||
9 | * Derived from include/netfilter_ipv4/ip_conntrack_protocol.h | ||
10 | */ | ||
11 | |||
12 | #ifndef _NF_CONNTRACK_L3PROTO_H | ||
13 | #define _NF_CONNTRACK_L3PROTO_H | ||
14 | #include <linux/seq_file.h> | ||
15 | #include <net/netfilter/nf_conntrack.h> | ||
16 | |||
17 | struct nf_conntrack_l3proto | ||
18 | { | ||
19 | /* Next pointer. */ | ||
20 | struct list_head list; | ||
21 | |||
22 | /* L3 Protocol Family number. ex) PF_INET */ | ||
23 | u_int16_t l3proto; | ||
24 | |||
25 | /* Protocol name */ | ||
26 | const char *name; | ||
27 | |||
28 | /* | ||
29 | * Try to fill in the third arg: nhoff is offset of l3 proto | ||
30 | * hdr. Return true if possible. | ||
31 | */ | ||
32 | int (*pkt_to_tuple)(const struct sk_buff *skb, unsigned int nhoff, | ||
33 | struct nf_conntrack_tuple *tuple); | ||
34 | |||
35 | /* | ||
36 | * Invert the per-proto part of the tuple: ie. turn xmit into reply. | ||
37 | * Some packets can't be inverted: return 0 in that case. | ||
38 | */ | ||
39 | int (*invert_tuple)(struct nf_conntrack_tuple *inverse, | ||
40 | const struct nf_conntrack_tuple *orig); | ||
41 | |||
42 | /* Print out the per-protocol part of the tuple. */ | ||
43 | int (*print_tuple)(struct seq_file *s, | ||
44 | const struct nf_conntrack_tuple *); | ||
45 | |||
46 | /* Print out the private part of the conntrack. */ | ||
47 | int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); | ||
48 | |||
49 | /* Returns verdict for packet, or -1 for invalid. */ | ||
50 | int (*packet)(struct nf_conn *conntrack, | ||
51 | const struct sk_buff *skb, | ||
52 | enum ip_conntrack_info ctinfo); | ||
53 | |||
54 | /* | ||
55 | * Called when a new connection for this protocol found; | ||
56 | * returns TRUE if it's OK. If so, packet() called next. | ||
57 | */ | ||
58 | int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb); | ||
59 | |||
60 | /* Called when a conntrack entry is destroyed */ | ||
61 | void (*destroy)(struct nf_conn *conntrack); | ||
62 | |||
63 | /* | ||
64 | * Called before tracking. | ||
65 | * *dataoff: offset of protocol header (TCP, UDP,...) in *pskb | ||
66 | * *protonum: protocol number | ||
67 | */ | ||
68 | int (*prepare)(struct sk_buff **pskb, unsigned int hooknum, | ||
69 | unsigned int *dataoff, u_int8_t *protonum); | ||
70 | |||
71 | u_int32_t (*get_features)(const struct nf_conntrack_tuple *tuple); | ||
72 | |||
73 | /* Module (if any) which this is connected to. */ | ||
74 | struct module *me; | ||
75 | }; | ||
76 | |||
77 | extern struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX]; | ||
78 | |||
79 | /* Protocol registration. */ | ||
80 | extern int nf_conntrack_l3proto_register(struct nf_conntrack_l3proto *proto); | ||
81 | extern void nf_conntrack_l3proto_unregister(struct nf_conntrack_l3proto *proto); | ||
82 | |||
83 | static inline struct nf_conntrack_l3proto * | ||
84 | nf_ct_find_l3proto(u_int16_t l3proto) | ||
85 | { | ||
86 | return nf_ct_l3protos[l3proto]; | ||
87 | } | ||
88 | |||
89 | /* Existing built-in protocols */ | ||
90 | extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv4; | ||
91 | extern struct nf_conntrack_l3proto nf_conntrack_l3proto_ipv6; | ||
92 | extern struct nf_conntrack_l3proto nf_conntrack_generic_l3proto; | ||
93 | #endif /*_NF_CONNTRACK_L3PROTO_H*/ | ||
diff --git a/include/net/netfilter/nf_conntrack_protocol.h b/include/net/netfilter/nf_conntrack_protocol.h new file mode 100644 index 000000000000..b3afda35397a --- /dev/null +++ b/include/net/netfilter/nf_conntrack_protocol.h | |||
@@ -0,0 +1,105 @@ | |||
1 | /* | ||
2 | * Header for use in defining a given protocol for connection tracking. | ||
3 | * | ||
4 | * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | ||
5 | * - generalized L3 protocol dependent part. | ||
6 | * | ||
7 | * Derived from include/linux/netfiter_ipv4/ip_conntrack_protcol.h | ||
8 | */ | ||
9 | |||
10 | #ifndef _NF_CONNTRACK_PROTOCOL_H | ||
11 | #define _NF_CONNTRACK_PROTOCOL_H | ||
12 | #include <net/netfilter/nf_conntrack.h> | ||
13 | |||
14 | struct seq_file; | ||
15 | |||
16 | struct nf_conntrack_protocol | ||
17 | { | ||
18 | /* Next pointer. */ | ||
19 | struct list_head list; | ||
20 | |||
21 | /* L3 Protocol number. */ | ||
22 | u_int16_t l3proto; | ||
23 | |||
24 | /* Protocol number. */ | ||
25 | u_int8_t proto; | ||
26 | |||
27 | /* Protocol name */ | ||
28 | const char *name; | ||
29 | |||
30 | /* Try to fill in the third arg: dataoff is offset past network protocol | ||
31 | hdr. Return true if possible. */ | ||
32 | int (*pkt_to_tuple)(const struct sk_buff *skb, | ||
33 | unsigned int dataoff, | ||
34 | struct nf_conntrack_tuple *tuple); | ||
35 | |||
36 | /* Invert the per-proto part of the tuple: ie. turn xmit into reply. | ||
37 | * Some packets can't be inverted: return 0 in that case. | ||
38 | */ | ||
39 | int (*invert_tuple)(struct nf_conntrack_tuple *inverse, | ||
40 | const struct nf_conntrack_tuple *orig); | ||
41 | |||
42 | /* Print out the per-protocol part of the tuple. Return like seq_* */ | ||
43 | int (*print_tuple)(struct seq_file *s, | ||
44 | const struct nf_conntrack_tuple *); | ||
45 | |||
46 | /* Print out the private part of the conntrack. */ | ||
47 | int (*print_conntrack)(struct seq_file *s, const struct nf_conn *); | ||
48 | |||
49 | /* Returns verdict for packet, or -1 for invalid. */ | ||
50 | int (*packet)(struct nf_conn *conntrack, | ||
51 | const struct sk_buff *skb, | ||
52 | unsigned int dataoff, | ||
53 | enum ip_conntrack_info ctinfo, | ||
54 | int pf, | ||
55 | unsigned int hooknum); | ||
56 | |||
57 | /* Called when a new connection for this protocol found; | ||
58 | * returns TRUE if it's OK. If so, packet() called next. */ | ||
59 | int (*new)(struct nf_conn *conntrack, const struct sk_buff *skb, | ||
60 | unsigned int dataoff); | ||
61 | |||
62 | /* Called when a conntrack entry is destroyed */ | ||
63 | void (*destroy)(struct nf_conn *conntrack); | ||
64 | |||
65 | int (*error)(struct sk_buff *skb, unsigned int dataoff, | ||
66 | enum ip_conntrack_info *ctinfo, | ||
67 | int pf, unsigned int hooknum); | ||
68 | |||
69 | /* Module (if any) which this is connected to. */ | ||
70 | struct module *me; | ||
71 | }; | ||
72 | |||
73 | /* Existing built-in protocols */ | ||
74 | extern struct nf_conntrack_protocol nf_conntrack_protocol_tcp6; | ||
75 | extern struct nf_conntrack_protocol nf_conntrack_protocol_udp4; | ||
76 | extern struct nf_conntrack_protocol nf_conntrack_protocol_udp6; | ||
77 | extern struct nf_conntrack_protocol nf_conntrack_generic_protocol; | ||
78 | |||
79 | #define MAX_NF_CT_PROTO 256 | ||
80 | extern struct nf_conntrack_protocol **nf_ct_protos[PF_MAX]; | ||
81 | |||
82 | extern struct nf_conntrack_protocol * | ||
83 | nf_ct_find_proto(u_int16_t l3proto, u_int8_t protocol); | ||
84 | |||
85 | /* Protocol registration. */ | ||
86 | extern int nf_conntrack_protocol_register(struct nf_conntrack_protocol *proto); | ||
87 | extern void nf_conntrack_protocol_unregister(struct nf_conntrack_protocol *proto); | ||
88 | |||
89 | /* Log invalid packets */ | ||
90 | extern unsigned int nf_ct_log_invalid; | ||
91 | |||
92 | #ifdef CONFIG_SYSCTL | ||
93 | #ifdef DEBUG_INVALID_PACKETS | ||
94 | #define LOG_INVALID(proto) \ | ||
95 | (nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) | ||
96 | #else | ||
97 | #define LOG_INVALID(proto) \ | ||
98 | ((nf_ct_log_invalid == (proto) || nf_ct_log_invalid == IPPROTO_RAW) \ | ||
99 | && net_ratelimit()) | ||
100 | #endif | ||
101 | #else | ||
102 | #define LOG_INVALID(proto) 0 | ||
103 | #endif /* CONFIG_SYSCTL */ | ||
104 | |||
105 | #endif /*_NF_CONNTRACK_PROTOCOL_H*/ | ||
diff --git a/include/net/netfilter/nf_conntrack_tuple.h b/include/net/netfilter/nf_conntrack_tuple.h new file mode 100644 index 000000000000..14ce790e5c65 --- /dev/null +++ b/include/net/netfilter/nf_conntrack_tuple.h | |||
@@ -0,0 +1,190 @@ | |||
1 | /* | ||
2 | * Definitions and Declarations for tuple. | ||
3 | * | ||
4 | * 16 Dec 2003: Yasuyuki Kozakai @USAGI <yasuyuki.kozakai@toshiba.co.jp> | ||
5 | * - generalize L3 protocol dependent part. | ||
6 | * | ||
7 | * Derived from include/linux/netfiter_ipv4/ip_conntrack_tuple.h | ||
8 | */ | ||
9 | |||
10 | #ifndef _NF_CONNTRACK_TUPLE_H | ||
11 | #define _NF_CONNTRACK_TUPLE_H | ||
12 | |||
13 | #include <linux/netfilter/nf_conntrack_tuple_common.h> | ||
14 | |||
15 | /* A `tuple' is a structure containing the information to uniquely | ||
16 | identify a connection. ie. if two packets have the same tuple, they | ||
17 | are in the same connection; if not, they are not. | ||
18 | |||
19 | We divide the structure along "manipulatable" and | ||
20 | "non-manipulatable" lines, for the benefit of the NAT code. | ||
21 | */ | ||
22 | |||
23 | #define NF_CT_TUPLE_L3SIZE 4 | ||
24 | |||
25 | /* The l3 protocol-specific manipulable parts of the tuple: always in | ||
26 | network order! */ | ||
27 | union nf_conntrack_man_l3proto { | ||
28 | u_int32_t all[NF_CT_TUPLE_L3SIZE]; | ||
29 | u_int32_t ip; | ||
30 | u_int32_t ip6[4]; | ||
31 | }; | ||
32 | |||
33 | /* The protocol-specific manipulable parts of the tuple: always in | ||
34 | network order! */ | ||
35 | union nf_conntrack_man_proto | ||
36 | { | ||
37 | /* Add other protocols here. */ | ||
38 | u_int16_t all; | ||
39 | |||
40 | struct { | ||
41 | u_int16_t port; | ||
42 | } tcp; | ||
43 | struct { | ||
44 | u_int16_t port; | ||
45 | } udp; | ||
46 | struct { | ||
47 | u_int16_t id; | ||
48 | } icmp; | ||
49 | struct { | ||
50 | u_int16_t port; | ||
51 | } sctp; | ||
52 | }; | ||
53 | |||
54 | /* The manipulable part of the tuple. */ | ||
55 | struct nf_conntrack_man | ||
56 | { | ||
57 | union nf_conntrack_man_l3proto u3; | ||
58 | union nf_conntrack_man_proto u; | ||
59 | /* Layer 3 protocol */ | ||
60 | u_int16_t l3num; | ||
61 | }; | ||
62 | |||
63 | /* This contains the information to distinguish a connection. */ | ||
64 | struct nf_conntrack_tuple | ||
65 | { | ||
66 | struct nf_conntrack_man src; | ||
67 | |||
68 | /* These are the parts of the tuple which are fixed. */ | ||
69 | struct { | ||
70 | union { | ||
71 | u_int32_t all[NF_CT_TUPLE_L3SIZE]; | ||
72 | u_int32_t ip; | ||
73 | u_int32_t ip6[4]; | ||
74 | } u3; | ||
75 | union { | ||
76 | /* Add other protocols here. */ | ||
77 | u_int16_t all; | ||
78 | |||
79 | struct { | ||
80 | u_int16_t port; | ||
81 | } tcp; | ||
82 | struct { | ||
83 | u_int16_t port; | ||
84 | } udp; | ||
85 | struct { | ||
86 | u_int8_t type, code; | ||
87 | } icmp; | ||
88 | struct { | ||
89 | u_int16_t port; | ||
90 | } sctp; | ||
91 | } u; | ||
92 | |||
93 | /* The protocol. */ | ||
94 | u_int8_t protonum; | ||
95 | |||
96 | /* The direction (for tuplehash) */ | ||
97 | u_int8_t dir; | ||
98 | } dst; | ||
99 | }; | ||
100 | |||
101 | /* This is optimized opposed to a memset of the whole structure. Everything we | ||
102 | * really care about is the source/destination unions */ | ||
103 | #define NF_CT_TUPLE_U_BLANK(tuple) \ | ||
104 | do { \ | ||
105 | (tuple)->src.u.all = 0; \ | ||
106 | (tuple)->dst.u.all = 0; \ | ||
107 | memset(&(tuple)->src.u3, 0, sizeof((tuple)->src.u3)); \ | ||
108 | memset(&(tuple)->dst.u3, 0, sizeof((tuple)->dst.u3)); \ | ||
109 | } while (0) | ||
110 | |||
111 | #ifdef __KERNEL__ | ||
112 | |||
113 | #define NF_CT_DUMP_TUPLE(tp) \ | ||
114 | DEBUGP("tuple %p: %u %u %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x %hu -> %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x %hu\n", \ | ||
115 | (tp), (tp)->src.l3num, (tp)->dst.protonum, \ | ||
116 | NIP6(*(struct in6_addr *)(tp)->src.u3.all), ntohs((tp)->src.u.all), \ | ||
117 | NIP6(*(struct in6_addr *)(tp)->dst.u3.all), ntohs((tp)->dst.u.all)) | ||
118 | |||
119 | /* If we're the first tuple, it's the original dir. */ | ||
120 | #define NF_CT_DIRECTION(h) \ | ||
121 | ((enum ip_conntrack_dir)(h)->tuple.dst.dir) | ||
122 | |||
123 | /* Connections have two entries in the hash table: one for each way */ | ||
124 | struct nf_conntrack_tuple_hash | ||
125 | { | ||
126 | struct list_head list; | ||
127 | |||
128 | struct nf_conntrack_tuple tuple; | ||
129 | }; | ||
130 | |||
131 | #endif /* __KERNEL__ */ | ||
132 | |||
133 | static inline int nf_ct_tuple_src_equal(const struct nf_conntrack_tuple *t1, | ||
134 | const struct nf_conntrack_tuple *t2) | ||
135 | { | ||
136 | return (t1->src.u3.all[0] == t2->src.u3.all[0] && | ||
137 | t1->src.u3.all[1] == t2->src.u3.all[1] && | ||
138 | t1->src.u3.all[2] == t2->src.u3.all[2] && | ||
139 | t1->src.u3.all[3] == t2->src.u3.all[3] && | ||
140 | t1->src.u.all == t2->src.u.all && | ||
141 | t1->src.l3num == t2->src.l3num && | ||
142 | t1->dst.protonum == t2->dst.protonum); | ||
143 | } | ||
144 | |||
145 | static inline int nf_ct_tuple_dst_equal(const struct nf_conntrack_tuple *t1, | ||
146 | const struct nf_conntrack_tuple *t2) | ||
147 | { | ||
148 | return (t1->dst.u3.all[0] == t2->dst.u3.all[0] && | ||
149 | t1->dst.u3.all[1] == t2->dst.u3.all[1] && | ||
150 | t1->dst.u3.all[2] == t2->dst.u3.all[2] && | ||
151 | t1->dst.u3.all[3] == t2->dst.u3.all[3] && | ||
152 | t1->dst.u.all == t2->dst.u.all && | ||
153 | t1->src.l3num == t2->src.l3num && | ||
154 | t1->dst.protonum == t2->dst.protonum); | ||
155 | } | ||
156 | |||
157 | static inline int nf_ct_tuple_equal(const struct nf_conntrack_tuple *t1, | ||
158 | const struct nf_conntrack_tuple *t2) | ||
159 | { | ||
160 | return nf_ct_tuple_src_equal(t1, t2) && nf_ct_tuple_dst_equal(t1, t2); | ||
161 | } | ||
162 | |||
163 | static inline int nf_ct_tuple_mask_cmp(const struct nf_conntrack_tuple *t, | ||
164 | const struct nf_conntrack_tuple *tuple, | ||
165 | const struct nf_conntrack_tuple *mask) | ||
166 | { | ||
167 | int count = 0; | ||
168 | |||
169 | for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++){ | ||
170 | if ((t->src.u3.all[count] ^ tuple->src.u3.all[count]) & | ||
171 | mask->src.u3.all[count]) | ||
172 | return 0; | ||
173 | } | ||
174 | |||
175 | for (count = 0; count < NF_CT_TUPLE_L3SIZE; count++){ | ||
176 | if ((t->dst.u3.all[count] ^ tuple->dst.u3.all[count]) & | ||
177 | mask->dst.u3.all[count]) | ||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | if ((t->src.u.all ^ tuple->src.u.all) & mask->src.u.all || | ||
182 | (t->dst.u.all ^ tuple->dst.u.all) & mask->dst.u.all || | ||
183 | (t->src.l3num ^ tuple->src.l3num) & mask->src.l3num || | ||
184 | (t->dst.protonum ^ tuple->dst.protonum) & mask->dst.protonum) | ||
185 | return 0; | ||
186 | |||
187 | return 1; | ||
188 | } | ||
189 | |||
190 | #endif /* _NF_CONNTRACK_TUPLE_H */ | ||
diff --git a/include/net/netlink.h b/include/net/netlink.h new file mode 100644 index 000000000000..640c26a90cf1 --- /dev/null +++ b/include/net/netlink.h | |||
@@ -0,0 +1,883 @@ | |||
1 | #ifndef __NET_NETLINK_H | ||
2 | #define __NET_NETLINK_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <linux/netlink.h> | ||
6 | |||
7 | /* ======================================================================== | ||
8 | * Netlink Messages and Attributes Interface (As Seen On TV) | ||
9 | * ------------------------------------------------------------------------ | ||
10 | * Messages Interface | ||
11 | * ------------------------------------------------------------------------ | ||
12 | * | ||
13 | * Message Format: | ||
14 | * <--- nlmsg_total_size(payload) ---> | ||
15 | * <-- nlmsg_msg_size(payload) -> | ||
16 | * +----------+- - -+-------------+- - -+-------- - - | ||
17 | * | nlmsghdr | Pad | Payload | Pad | nlmsghdr | ||
18 | * +----------+- - -+-------------+- - -+-------- - - | ||
19 | * nlmsg_data(nlh)---^ ^ | ||
20 | * nlmsg_next(nlh)-----------------------+ | ||
21 | * | ||
22 | * Payload Format: | ||
23 | * <---------------------- nlmsg_len(nlh) ---------------------> | ||
24 | * <------ hdrlen ------> <- nlmsg_attrlen(nlh, hdrlen) -> | ||
25 | * +----------------------+- - -+--------------------------------+ | ||
26 | * | Family Header | Pad | Attributes | | ||
27 | * +----------------------+- - -+--------------------------------+ | ||
28 | * nlmsg_attrdata(nlh, hdrlen)---^ | ||
29 | * | ||
30 | * Data Structures: | ||
31 | * struct nlmsghdr netlink message header | ||
32 | * | ||
33 | * Message Construction: | ||
34 | * nlmsg_new() create a new netlink message | ||
35 | * nlmsg_put() add a netlink message to an skb | ||
36 | * nlmsg_put_answer() callback based nlmsg_put() | ||
37 | * nlmsg_end() finanlize netlink message | ||
38 | * nlmsg_cancel() cancel message construction | ||
39 | * nlmsg_free() free a netlink message | ||
40 | * | ||
41 | * Message Sending: | ||
42 | * nlmsg_multicast() multicast message to several groups | ||
43 | * nlmsg_unicast() unicast a message to a single socket | ||
44 | * | ||
45 | * Message Length Calculations: | ||
46 | * nlmsg_msg_size(payload) length of message w/o padding | ||
47 | * nlmsg_total_size(payload) length of message w/ padding | ||
48 | * nlmsg_padlen(payload) length of padding at tail | ||
49 | * | ||
50 | * Message Payload Access: | ||
51 | * nlmsg_data(nlh) head of message payload | ||
52 | * nlmsg_len(nlh) length of message payload | ||
53 | * nlmsg_attrdata(nlh, hdrlen) head of attributes data | ||
54 | * nlmsg_attrlen(nlh, hdrlen) length of attributes data | ||
55 | * | ||
56 | * Message Parsing: | ||
57 | * nlmsg_ok(nlh, remaining) does nlh fit into remaining bytes? | ||
58 | * nlmsg_next(nlh, remaining) get next netlink message | ||
59 | * nlmsg_parse() parse attributes of a message | ||
60 | * nlmsg_find_attr() find an attribute in a message | ||
61 | * nlmsg_for_each_msg() loop over all messages | ||
62 | * nlmsg_validate() validate netlink message incl. attrs | ||
63 | * nlmsg_for_each_attr() loop over all attributes | ||
64 | * | ||
65 | * ------------------------------------------------------------------------ | ||
66 | * Attributes Interface | ||
67 | * ------------------------------------------------------------------------ | ||
68 | * | ||
69 | * Attribute Format: | ||
70 | * <------- nla_total_size(payload) -------> | ||
71 | * <---- nla_attr_size(payload) -----> | ||
72 | * +----------+- - -+- - - - - - - - - +- - -+-------- - - | ||
73 | * | Header | Pad | Payload | Pad | Header | ||
74 | * +----------+- - -+- - - - - - - - - +- - -+-------- - - | ||
75 | * <- nla_len(nla) -> ^ | ||
76 | * nla_data(nla)----^ | | ||
77 | * nla_next(nla)-----------------------------' | ||
78 | * | ||
79 | * Data Structures: | ||
80 | * struct nlattr netlink attribtue header | ||
81 | * | ||
82 | * Attribute Construction: | ||
83 | * nla_reserve(skb, type, len) reserve skb tailroom for an attribute | ||
84 | * nla_put(skb, type, len, data) add attribute to skb | ||
85 | * | ||
86 | * Attribute Construction for Basic Types: | ||
87 | * nla_put_u8(skb, type, value) add u8 attribute to skb | ||
88 | * nla_put_u16(skb, type, value) add u16 attribute to skb | ||
89 | * nla_put_u32(skb, type, value) add u32 attribute to skb | ||
90 | * nla_put_u64(skb, type, value) add u64 attribute to skb | ||
91 | * nla_put_string(skb, type, str) add string attribute to skb | ||
92 | * nla_put_flag(skb, type) add flag attribute to skb | ||
93 | * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb | ||
94 | * | ||
95 | * Exceptions Based Attribute Construction: | ||
96 | * NLA_PUT(skb, type, len, data) add attribute to skb | ||
97 | * NLA_PUT_U8(skb, type, value) add u8 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 | ||
100 | * NLA_PUT_U64(skb, type, value) add u64 attribute to skb | ||
101 | * NLA_PUT_STRING(skb, type, str) add string attribute to skb | ||
102 | * NLA_PUT_FLAG(skb, type) add flag attribute to skb | ||
103 | * NLA_PUT_MSECS(skb, type, jiffies) add msecs attribute to skb | ||
104 | * | ||
105 | * The meaning of these functions is equal to their lower case | ||
106 | * variants but they jump to the label nla_put_failure in case | ||
107 | * of a failure. | ||
108 | * | ||
109 | * Nested Attributes Construction: | ||
110 | * nla_nest_start(skb, type) start a nested attribute | ||
111 | * nla_nest_end(skb, nla) finalize a nested attribute | ||
112 | * nla_nest_cancel(skb, nla) cancel nested attribute construction | ||
113 | * | ||
114 | * Attribute Length Calculations: | ||
115 | * nla_attr_size(payload) length of attribute w/o padding | ||
116 | * nla_total_size(payload) length of attribute w/ padding | ||
117 | * nla_padlen(payload) length of padding | ||
118 | * | ||
119 | * Attribute Payload Access: | ||
120 | * nla_data(nla) head of attribute payload | ||
121 | * nla_len(nla) length of attribute payload | ||
122 | * | ||
123 | * Attribute Payload Access for Basic Types: | ||
124 | * nla_get_u8(nla) get payload for a u8 attribute | ||
125 | * nla_get_u16(nla) get payload for a u16 attribute | ||
126 | * nla_get_u32(nla) get payload for a u32 attribute | ||
127 | * nla_get_u64(nla) get payload for a u64 attribute | ||
128 | * nla_get_flag(nla) return 1 if flag is true | ||
129 | * nla_get_msecs(nla) get payload for a msecs attribute | ||
130 | * | ||
131 | * Attribute Misc: | ||
132 | * nla_memcpy(dest, nla, count) copy attribute into memory | ||
133 | * nla_memcmp(nla, data, size) compare attribute with memory area | ||
134 | * nla_strlcpy(dst, nla, size) copy attribute to a sized string | ||
135 | * nla_strcmp(nla, str) compare attribute with string | ||
136 | * | ||
137 | * Attribute Parsing: | ||
138 | * nla_ok(nla, remaining) does nla fit into remaining bytes? | ||
139 | * nla_next(nla, remaining) get next netlink attribute | ||
140 | * nla_validate() validate a stream of attributes | ||
141 | * nla_find() find attribute in stream of attributes | ||
142 | * nla_parse() parse and validate stream of attrs | ||
143 | * nla_parse_nested() parse nested attribuets | ||
144 | * nla_for_each_attr() loop over all attributes | ||
145 | *========================================================================= | ||
146 | */ | ||
147 | |||
148 | /** | ||
149 | * Standard attribute types to specify validation policy | ||
150 | */ | ||
151 | enum { | ||
152 | NLA_UNSPEC, | ||
153 | NLA_U8, | ||
154 | NLA_U16, | ||
155 | NLA_U32, | ||
156 | NLA_U64, | ||
157 | NLA_STRING, | ||
158 | NLA_FLAG, | ||
159 | NLA_MSECS, | ||
160 | NLA_NESTED, | ||
161 | __NLA_TYPE_MAX, | ||
162 | }; | ||
163 | |||
164 | #define NLA_TYPE_MAX (__NLA_TYPE_MAX - 1) | ||
165 | |||
166 | /** | ||
167 | * struct nla_policy - attribute validation policy | ||
168 | * @type: Type of attribute or NLA_UNSPEC | ||
169 | * @minlen: Minimal length of payload required to be available | ||
170 | * | ||
171 | * Policies are defined as arrays of this struct, the array must be | ||
172 | * accessible by attribute type up to the highest identifier to be expected. | ||
173 | * | ||
174 | * Example: | ||
175 | * static struct nla_policy my_policy[ATTR_MAX+1] __read_mostly = { | ||
176 | * [ATTR_FOO] = { .type = NLA_U16 }, | ||
177 | * [ATTR_BAR] = { .type = NLA_STRING }, | ||
178 | * [ATTR_BAZ] = { .minlen = sizeof(struct mystruct) }, | ||
179 | * }; | ||
180 | */ | ||
181 | struct nla_policy { | ||
182 | u16 type; | ||
183 | u16 minlen; | ||
184 | }; | ||
185 | |||
186 | extern void netlink_run_queue(struct sock *sk, unsigned int *qlen, | ||
187 | int (*cb)(struct sk_buff *, | ||
188 | struct nlmsghdr *, int *)); | ||
189 | extern void netlink_queue_skip(struct nlmsghdr *nlh, | ||
190 | struct sk_buff *skb); | ||
191 | |||
192 | extern int nla_validate(struct nlattr *head, int len, int maxtype, | ||
193 | struct nla_policy *policy); | ||
194 | extern int nla_parse(struct nlattr *tb[], int maxtype, | ||
195 | struct nlattr *head, int len, | ||
196 | struct nla_policy *policy); | ||
197 | extern struct nlattr * nla_find(struct nlattr *head, int len, int attrtype); | ||
198 | extern size_t nla_strlcpy(char *dst, const struct nlattr *nla, | ||
199 | size_t dstsize); | ||
200 | extern int nla_memcpy(void *dest, struct nlattr *src, int count); | ||
201 | extern int nla_memcmp(const struct nlattr *nla, const void *data, | ||
202 | size_t size); | ||
203 | extern int nla_strcmp(const struct nlattr *nla, const char *str); | ||
204 | extern struct nlattr * __nla_reserve(struct sk_buff *skb, int attrtype, | ||
205 | int attrlen); | ||
206 | extern struct nlattr * nla_reserve(struct sk_buff *skb, int attrtype, | ||
207 | int attrlen); | ||
208 | extern void __nla_put(struct sk_buff *skb, int attrtype, | ||
209 | int attrlen, const void *data); | ||
210 | extern int nla_put(struct sk_buff *skb, int attrtype, | ||
211 | int attrlen, const void *data); | ||
212 | |||
213 | /************************************************************************** | ||
214 | * Netlink Messages | ||
215 | **************************************************************************/ | ||
216 | |||
217 | /** | ||
218 | * nlmsg_msg_size - length of netlink message not including padding | ||
219 | * @payload: length of message payload | ||
220 | */ | ||
221 | static inline int nlmsg_msg_size(int payload) | ||
222 | { | ||
223 | return NLMSG_HDRLEN + payload; | ||
224 | } | ||
225 | |||
226 | /** | ||
227 | * nlmsg_total_size - length of netlink message including padding | ||
228 | * @payload: length of message payload | ||
229 | */ | ||
230 | static inline int nlmsg_total_size(int payload) | ||
231 | { | ||
232 | return NLMSG_ALIGN(nlmsg_msg_size(payload)); | ||
233 | } | ||
234 | |||
235 | /** | ||
236 | * nlmsg_padlen - length of padding at the message's tail | ||
237 | * @payload: length of message payload | ||
238 | */ | ||
239 | static inline int nlmsg_padlen(int payload) | ||
240 | { | ||
241 | return nlmsg_total_size(payload) - nlmsg_msg_size(payload); | ||
242 | } | ||
243 | |||
244 | /** | ||
245 | * nlmsg_data - head of message payload | ||
246 | * @nlh: netlink messsage header | ||
247 | */ | ||
248 | static inline void *nlmsg_data(const struct nlmsghdr *nlh) | ||
249 | { | ||
250 | return (unsigned char *) nlh + NLMSG_HDRLEN; | ||
251 | } | ||
252 | |||
253 | /** | ||
254 | * nlmsg_len - length of message payload | ||
255 | * @nlh: netlink message header | ||
256 | */ | ||
257 | static inline int nlmsg_len(const struct nlmsghdr *nlh) | ||
258 | { | ||
259 | return nlh->nlmsg_len - NLMSG_HDRLEN; | ||
260 | } | ||
261 | |||
262 | /** | ||
263 | * nlmsg_attrdata - head of attributes data | ||
264 | * @nlh: netlink message header | ||
265 | * @hdrlen: length of family specific header | ||
266 | */ | ||
267 | static inline struct nlattr *nlmsg_attrdata(const struct nlmsghdr *nlh, | ||
268 | int hdrlen) | ||
269 | { | ||
270 | unsigned char *data = nlmsg_data(nlh); | ||
271 | return (struct nlattr *) (data + NLMSG_ALIGN(hdrlen)); | ||
272 | } | ||
273 | |||
274 | /** | ||
275 | * nlmsg_attrlen - length of attributes data | ||
276 | * @nlh: netlink message header | ||
277 | * @hdrlen: length of family specific header | ||
278 | */ | ||
279 | static inline int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen) | ||
280 | { | ||
281 | return nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen); | ||
282 | } | ||
283 | |||
284 | /** | ||
285 | * nlmsg_ok - check if the netlink message fits into the remaining bytes | ||
286 | * @nlh: netlink message header | ||
287 | * @remaining: number of bytes remaining in message stream | ||
288 | */ | ||
289 | static inline int nlmsg_ok(const struct nlmsghdr *nlh, int remaining) | ||
290 | { | ||
291 | return (remaining >= sizeof(struct nlmsghdr) && | ||
292 | nlh->nlmsg_len >= sizeof(struct nlmsghdr) && | ||
293 | nlh->nlmsg_len <= remaining); | ||
294 | } | ||
295 | |||
296 | /** | ||
297 | * nlmsg_next - next netlink message in message stream | ||
298 | * @nlh: netlink message header | ||
299 | * @remaining: number of bytes remaining in message stream | ||
300 | * | ||
301 | * Returns the next netlink message in the message stream and | ||
302 | * decrements remaining by the size of the current message. | ||
303 | */ | ||
304 | static inline struct nlmsghdr *nlmsg_next(struct nlmsghdr *nlh, int *remaining) | ||
305 | { | ||
306 | int totlen = NLMSG_ALIGN(nlh->nlmsg_len); | ||
307 | |||
308 | *remaining -= totlen; | ||
309 | |||
310 | return (struct nlmsghdr *) ((unsigned char *) nlh + totlen); | ||
311 | } | ||
312 | |||
313 | /** | ||
314 | * nlmsg_parse - parse attributes of a netlink message | ||
315 | * @nlh: netlink message header | ||
316 | * @hdrlen: length of family specific header | ||
317 | * @tb: destination array with maxtype+1 elements | ||
318 | * @maxtype: maximum attribute type to be expected | ||
319 | * @policy: validation policy | ||
320 | * | ||
321 | * See nla_parse() | ||
322 | */ | ||
323 | static inline int nlmsg_parse(struct nlmsghdr *nlh, int hdrlen, | ||
324 | struct nlattr *tb[], int maxtype, | ||
325 | struct nla_policy *policy) | ||
326 | { | ||
327 | if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) | ||
328 | return -EINVAL; | ||
329 | |||
330 | return nla_parse(tb, maxtype, nlmsg_attrdata(nlh, hdrlen), | ||
331 | nlmsg_attrlen(nlh, hdrlen), policy); | ||
332 | } | ||
333 | |||
334 | /** | ||
335 | * nlmsg_find_attr - find a specific attribute in a netlink message | ||
336 | * @nlh: netlink message header | ||
337 | * @hdrlen: length of familiy specific header | ||
338 | * @attrtype: type of attribute to look for | ||
339 | * | ||
340 | * Returns the first attribute which matches the specified type. | ||
341 | */ | ||
342 | static inline struct nlattr *nlmsg_find_attr(struct nlmsghdr *nlh, | ||
343 | int hdrlen, int attrtype) | ||
344 | { | ||
345 | return nla_find(nlmsg_attrdata(nlh, hdrlen), | ||
346 | nlmsg_attrlen(nlh, hdrlen), attrtype); | ||
347 | } | ||
348 | |||
349 | /** | ||
350 | * nlmsg_validate - validate a netlink message including attributes | ||
351 | * @nlh: netlinket message header | ||
352 | * @hdrlen: length of familiy specific header | ||
353 | * @maxtype: maximum attribute type to be expected | ||
354 | * @policy: validation policy | ||
355 | */ | ||
356 | static inline int nlmsg_validate(struct nlmsghdr *nlh, int hdrlen, int maxtype, | ||
357 | struct nla_policy *policy) | ||
358 | { | ||
359 | if (nlh->nlmsg_len < nlmsg_msg_size(hdrlen)) | ||
360 | return -EINVAL; | ||
361 | |||
362 | return nla_validate(nlmsg_attrdata(nlh, hdrlen), | ||
363 | nlmsg_attrlen(nlh, hdrlen), maxtype, policy); | ||
364 | } | ||
365 | |||
366 | /** | ||
367 | * nlmsg_for_each_attr - iterate over a stream of attributes | ||
368 | * @pos: loop counter, set to current attribute | ||
369 | * @nlh: netlink message header | ||
370 | * @hdrlen: length of familiy specific header | ||
371 | * @rem: initialized to len, holds bytes currently remaining in stream | ||
372 | */ | ||
373 | #define nlmsg_for_each_attr(pos, nlh, hdrlen, rem) \ | ||
374 | nla_for_each_attr(pos, nlmsg_attrdata(nlh, hdrlen), \ | ||
375 | nlmsg_attrlen(nlh, hdrlen), rem) | ||
376 | |||
377 | #if 0 | ||
378 | /* FIXME: Enable once all users have been converted */ | ||
379 | |||
380 | /** | ||
381 | * __nlmsg_put - Add a new netlink message to an skb | ||
382 | * @skb: socket buffer to store message in | ||
383 | * @pid: netlink process id | ||
384 | * @seq: sequence number of message | ||
385 | * @type: message type | ||
386 | * @payload: length of message payload | ||
387 | * @flags: message flags | ||
388 | * | ||
389 | * The caller is responsible to ensure that the skb provides enough | ||
390 | * tailroom for both the netlink header and payload. | ||
391 | */ | ||
392 | static inline struct nlmsghdr *__nlmsg_put(struct sk_buff *skb, u32 pid, | ||
393 | u32 seq, int type, int payload, | ||
394 | int flags) | ||
395 | { | ||
396 | struct nlmsghdr *nlh; | ||
397 | |||
398 | nlh = (struct nlmsghdr *) skb_put(skb, nlmsg_total_size(payload)); | ||
399 | nlh->nlmsg_type = type; | ||
400 | nlh->nlmsg_len = nlmsg_msg_size(payload); | ||
401 | nlh->nlmsg_flags = flags; | ||
402 | nlh->nlmsg_pid = pid; | ||
403 | nlh->nlmsg_seq = seq; | ||
404 | |||
405 | memset((unsigned char *) nlmsg_data(nlh) + payload, 0, | ||
406 | nlmsg_padlen(payload)); | ||
407 | |||
408 | return nlh; | ||
409 | } | ||
410 | #endif | ||
411 | |||
412 | /** | ||
413 | * nlmsg_put - Add a new netlink message to an skb | ||
414 | * @skb: socket buffer to store message in | ||
415 | * @pid: netlink process id | ||
416 | * @seq: sequence number of message | ||
417 | * @type: message type | ||
418 | * @payload: length of message payload | ||
419 | * @flags: message flags | ||
420 | * | ||
421 | * Returns NULL if the tailroom of the skb is insufficient to store | ||
422 | * the message header and payload. | ||
423 | */ | ||
424 | static inline struct nlmsghdr *nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, | ||
425 | int type, int payload, int flags) | ||
426 | { | ||
427 | if (unlikely(skb_tailroom(skb) < nlmsg_total_size(payload))) | ||
428 | return NULL; | ||
429 | |||
430 | return __nlmsg_put(skb, pid, seq, type, payload, flags); | ||
431 | } | ||
432 | |||
433 | /** | ||
434 | * nlmsg_put_answer - Add a new callback based netlink message to an skb | ||
435 | * @skb: socket buffer to store message in | ||
436 | * @cb: netlink callback | ||
437 | * @type: message type | ||
438 | * @payload: length of message payload | ||
439 | * @flags: message flags | ||
440 | * | ||
441 | * Returns NULL if the tailroom of the skb is insufficient to store | ||
442 | * the message header and payload. | ||
443 | */ | ||
444 | static inline struct nlmsghdr *nlmsg_put_answer(struct sk_buff *skb, | ||
445 | struct netlink_callback *cb, | ||
446 | int type, int payload, | ||
447 | int flags) | ||
448 | { | ||
449 | return nlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, | ||
450 | type, payload, flags); | ||
451 | } | ||
452 | |||
453 | /** | ||
454 | * nlmsg_new - Allocate a new netlink message | ||
455 | * @size: maximum size of message | ||
456 | * | ||
457 | * Use NLMSG_GOODSIZE if size isn't know and you need a good default size. | ||
458 | */ | ||
459 | static inline struct sk_buff *nlmsg_new(int size) | ||
460 | { | ||
461 | return alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL); | ||
462 | } | ||
463 | |||
464 | /** | ||
465 | * nlmsg_end - Finalize a netlink message | ||
466 | * @skb: socket buffer the message is stored in | ||
467 | * @nlh: netlink message header | ||
468 | * | ||
469 | * Corrects the netlink message header to include the appeneded | ||
470 | * attributes. Only necessary if attributes have been added to | ||
471 | * the message. | ||
472 | * | ||
473 | * Returns the total data length of the skb. | ||
474 | */ | ||
475 | static inline int nlmsg_end(struct sk_buff *skb, struct nlmsghdr *nlh) | ||
476 | { | ||
477 | nlh->nlmsg_len = skb->tail - (unsigned char *) nlh; | ||
478 | |||
479 | return skb->len; | ||
480 | } | ||
481 | |||
482 | /** | ||
483 | * nlmsg_cancel - Cancel construction of a netlink message | ||
484 | * @skb: socket buffer the message is stored in | ||
485 | * @nlh: netlink message header | ||
486 | * | ||
487 | * Removes the complete netlink message including all | ||
488 | * attributes from the socket buffer again. Returns -1. | ||
489 | */ | ||
490 | static inline int nlmsg_cancel(struct sk_buff *skb, struct nlmsghdr *nlh) | ||
491 | { | ||
492 | skb_trim(skb, (unsigned char *) nlh - skb->data); | ||
493 | |||
494 | return -1; | ||
495 | } | ||
496 | |||
497 | /** | ||
498 | * nlmsg_free - free a netlink message | ||
499 | * @skb: socket buffer of netlink message | ||
500 | */ | ||
501 | static inline void nlmsg_free(struct sk_buff *skb) | ||
502 | { | ||
503 | kfree_skb(skb); | ||
504 | } | ||
505 | |||
506 | /** | ||
507 | * nlmsg_multicast - multicast a netlink message | ||
508 | * @sk: netlink socket to spread messages to | ||
509 | * @skb: netlink message as socket buffer | ||
510 | * @pid: own netlink pid to avoid sending to yourself | ||
511 | * @group: multicast group id | ||
512 | */ | ||
513 | static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb, | ||
514 | u32 pid, unsigned int group) | ||
515 | { | ||
516 | int err; | ||
517 | |||
518 | NETLINK_CB(skb).dst_group = group; | ||
519 | |||
520 | err = netlink_broadcast(sk, skb, pid, group, GFP_KERNEL); | ||
521 | if (err > 0) | ||
522 | err = 0; | ||
523 | |||
524 | return err; | ||
525 | } | ||
526 | |||
527 | /** | ||
528 | * nlmsg_unicast - unicast a netlink message | ||
529 | * @sk: netlink socket to spread message to | ||
530 | * @skb: netlink message as socket buffer | ||
531 | * @pid: netlink pid of the destination socket | ||
532 | */ | ||
533 | static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 pid) | ||
534 | { | ||
535 | int err; | ||
536 | |||
537 | err = netlink_unicast(sk, skb, pid, MSG_DONTWAIT); | ||
538 | if (err > 0) | ||
539 | err = 0; | ||
540 | |||
541 | return err; | ||
542 | } | ||
543 | |||
544 | /** | ||
545 | * nlmsg_for_each_msg - iterate over a stream of messages | ||
546 | * @pos: loop counter, set to current message | ||
547 | * @head: head of message stream | ||
548 | * @len: length of message stream | ||
549 | * @rem: initialized to len, holds bytes currently remaining in stream | ||
550 | */ | ||
551 | #define nlmsg_for_each_msg(pos, head, len, rem) \ | ||
552 | for (pos = head, rem = len; \ | ||
553 | nlmsg_ok(pos, rem); \ | ||
554 | pos = nlmsg_next(pos, &(rem))) | ||
555 | |||
556 | /************************************************************************** | ||
557 | * Netlink Attributes | ||
558 | **************************************************************************/ | ||
559 | |||
560 | /** | ||
561 | * nla_attr_size - length of attribute not including padding | ||
562 | * @payload: length of payload | ||
563 | */ | ||
564 | static inline int nla_attr_size(int payload) | ||
565 | { | ||
566 | return NLA_HDRLEN + payload; | ||
567 | } | ||
568 | |||
569 | /** | ||
570 | * nla_total_size - total length of attribute including padding | ||
571 | * @payload: length of payload | ||
572 | */ | ||
573 | static inline int nla_total_size(int payload) | ||
574 | { | ||
575 | return NLA_ALIGN(nla_attr_size(payload)); | ||
576 | } | ||
577 | |||
578 | /** | ||
579 | * nla_padlen - length of padding at the tail of attribute | ||
580 | * @payload: length of payload | ||
581 | */ | ||
582 | static inline int nla_padlen(int payload) | ||
583 | { | ||
584 | return nla_total_size(payload) - nla_attr_size(payload); | ||
585 | } | ||
586 | |||
587 | /** | ||
588 | * nla_data - head of payload | ||
589 | * @nla: netlink attribute | ||
590 | */ | ||
591 | static inline void *nla_data(const struct nlattr *nla) | ||
592 | { | ||
593 | return (char *) nla + NLA_HDRLEN; | ||
594 | } | ||
595 | |||
596 | /** | ||
597 | * nla_len - length of payload | ||
598 | * @nla: netlink attribute | ||
599 | */ | ||
600 | static inline int nla_len(const struct nlattr *nla) | ||
601 | { | ||
602 | return nla->nla_len - NLA_HDRLEN; | ||
603 | } | ||
604 | |||
605 | /** | ||
606 | * nla_ok - check if the netlink attribute fits into the remaining bytes | ||
607 | * @nla: netlink attribute | ||
608 | * @remaining: number of bytes remaining in attribute stream | ||
609 | */ | ||
610 | static inline int nla_ok(const struct nlattr *nla, int remaining) | ||
611 | { | ||
612 | return remaining >= sizeof(*nla) && | ||
613 | nla->nla_len >= sizeof(*nla) && | ||
614 | nla->nla_len <= remaining; | ||
615 | } | ||
616 | |||
617 | /** | ||
618 | * nla_next - next netlink attribte in attribute stream | ||
619 | * @nla: netlink attribute | ||
620 | * @remaining: number of bytes remaining in attribute stream | ||
621 | * | ||
622 | * Returns the next netlink attribute in the attribute stream and | ||
623 | * decrements remaining by the size of the current attribute. | ||
624 | */ | ||
625 | static inline struct nlattr *nla_next(const struct nlattr *nla, int *remaining) | ||
626 | { | ||
627 | int totlen = NLA_ALIGN(nla->nla_len); | ||
628 | |||
629 | *remaining -= totlen; | ||
630 | return (struct nlattr *) ((char *) nla + totlen); | ||
631 | } | ||
632 | |||
633 | /** | ||
634 | * nla_parse_nested - parse nested attributes | ||
635 | * @tb: destination array with maxtype+1 elements | ||
636 | * @maxtype: maximum attribute type to be expected | ||
637 | * @nla: attribute containing the nested attributes | ||
638 | * @policy: validation policy | ||
639 | * | ||
640 | * See nla_parse() | ||
641 | */ | ||
642 | static inline int nla_parse_nested(struct nlattr *tb[], int maxtype, | ||
643 | struct nlattr *nla, | ||
644 | struct nla_policy *policy) | ||
645 | { | ||
646 | return nla_parse(tb, maxtype, nla_data(nla), nla_len(nla), policy); | ||
647 | } | ||
648 | /** | ||
649 | * nla_put_u8 - Add a u16 netlink attribute to a socket buffer | ||
650 | * @skb: socket buffer to add attribute to | ||
651 | * @attrtype: attribute type | ||
652 | * @value: numeric value | ||
653 | */ | ||
654 | static inline int nla_put_u8(struct sk_buff *skb, int attrtype, u8 value) | ||
655 | { | ||
656 | return nla_put(skb, attrtype, sizeof(u8), &value); | ||
657 | } | ||
658 | |||
659 | /** | ||
660 | * nla_put_u16 - Add a u16 netlink attribute to a socket buffer | ||
661 | * @skb: socket buffer to add attribute to | ||
662 | * @attrtype: attribute type | ||
663 | * @value: numeric value | ||
664 | */ | ||
665 | static inline int nla_put_u16(struct sk_buff *skb, int attrtype, u16 value) | ||
666 | { | ||
667 | return nla_put(skb, attrtype, sizeof(u16), &value); | ||
668 | } | ||
669 | |||
670 | /** | ||
671 | * nla_put_u32 - Add a u32 netlink attribute to a socket buffer | ||
672 | * @skb: socket buffer to add attribute to | ||
673 | * @attrtype: attribute type | ||
674 | * @value: numeric value | ||
675 | */ | ||
676 | static inline int nla_put_u32(struct sk_buff *skb, int attrtype, u32 value) | ||
677 | { | ||
678 | return nla_put(skb, attrtype, sizeof(u32), &value); | ||
679 | } | ||
680 | |||
681 | /** | ||
682 | * nla_put_64 - Add a u64 netlink attribute to a socket buffer | ||
683 | * @skb: socket buffer to add attribute to | ||
684 | * @attrtype: attribute type | ||
685 | * @value: numeric value | ||
686 | */ | ||
687 | static inline int nla_put_u64(struct sk_buff *skb, int attrtype, u64 value) | ||
688 | { | ||
689 | return nla_put(skb, attrtype, sizeof(u64), &value); | ||
690 | } | ||
691 | |||
692 | /** | ||
693 | * nla_put_string - Add a string netlink attribute to a socket buffer | ||
694 | * @skb: socket buffer to add attribute to | ||
695 | * @attrtype: attribute type | ||
696 | * @str: NUL terminated string | ||
697 | */ | ||
698 | static inline int nla_put_string(struct sk_buff *skb, int attrtype, | ||
699 | const char *str) | ||
700 | { | ||
701 | return nla_put(skb, attrtype, strlen(str) + 1, str); | ||
702 | } | ||
703 | |||
704 | /** | ||
705 | * nla_put_flag - Add a flag netlink attribute to a socket buffer | ||
706 | * @skb: socket buffer to add attribute to | ||
707 | * @attrtype: attribute type | ||
708 | */ | ||
709 | static inline int nla_put_flag(struct sk_buff *skb, int attrtype) | ||
710 | { | ||
711 | return nla_put(skb, attrtype, 0, NULL); | ||
712 | } | ||
713 | |||
714 | /** | ||
715 | * nla_put_msecs - Add a msecs netlink attribute to a socket buffer | ||
716 | * @skb: socket buffer to add attribute to | ||
717 | * @attrtype: attribute type | ||
718 | * @jiffies: number of msecs in jiffies | ||
719 | */ | ||
720 | static inline int nla_put_msecs(struct sk_buff *skb, int attrtype, | ||
721 | unsigned long jiffies) | ||
722 | { | ||
723 | u64 tmp = jiffies_to_msecs(jiffies); | ||
724 | return nla_put(skb, attrtype, sizeof(u64), &tmp); | ||
725 | } | ||
726 | |||
727 | #define NLA_PUT(skb, attrtype, attrlen, data) \ | ||
728 | do { \ | ||
729 | if (nla_put(skb, attrtype, attrlen, data) < 0) \ | ||
730 | goto nla_put_failure; \ | ||
731 | } while(0) | ||
732 | |||
733 | #define NLA_PUT_TYPE(skb, type, attrtype, value) \ | ||
734 | do { \ | ||
735 | type __tmp = value; \ | ||
736 | NLA_PUT(skb, attrtype, sizeof(type), &__tmp); \ | ||
737 | } while(0) | ||
738 | |||
739 | #define NLA_PUT_U8(skb, attrtype, value) \ | ||
740 | NLA_PUT_TYPE(skb, u8, attrtype, value) | ||
741 | |||
742 | #define NLA_PUT_U16(skb, attrtype, value) \ | ||
743 | NLA_PUT_TYPE(skb, u16, attrtype, value) | ||
744 | |||
745 | #define NLA_PUT_U32(skb, attrtype, value) \ | ||
746 | NLA_PUT_TYPE(skb, u32, attrtype, value) | ||
747 | |||
748 | #define NLA_PUT_U64(skb, attrtype, value) \ | ||
749 | NLA_PUT_TYPE(skb, u64, attrtype, value) | ||
750 | |||
751 | #define NLA_PUT_STRING(skb, attrtype, value) \ | ||
752 | NLA_PUT(skb, attrtype, strlen(value) + 1, value) | ||
753 | |||
754 | #define NLA_PUT_FLAG(skb, attrtype, value) \ | ||
755 | NLA_PUT(skb, attrtype, 0, NULL) | ||
756 | |||
757 | #define NLA_PUT_MSECS(skb, attrtype, jiffies) \ | ||
758 | NLA_PUT_U64(skb, attrtype, jiffies_to_msecs(jiffies)) | ||
759 | |||
760 | /** | ||
761 | * nla_get_u32 - return payload of u32 attribute | ||
762 | * @nla: u32 netlink attribute | ||
763 | */ | ||
764 | static inline u32 nla_get_u32(struct nlattr *nla) | ||
765 | { | ||
766 | return *(u32 *) nla_data(nla); | ||
767 | } | ||
768 | |||
769 | /** | ||
770 | * nla_get_u16 - return payload of u16 attribute | ||
771 | * @nla: u16 netlink attribute | ||
772 | */ | ||
773 | static inline u16 nla_get_u16(struct nlattr *nla) | ||
774 | { | ||
775 | return *(u16 *) nla_data(nla); | ||
776 | } | ||
777 | |||
778 | /** | ||
779 | * nla_get_u8 - return payload of u8 attribute | ||
780 | * @nla: u8 netlink attribute | ||
781 | */ | ||
782 | static inline u8 nla_get_u8(struct nlattr *nla) | ||
783 | { | ||
784 | return *(u8 *) nla_data(nla); | ||
785 | } | ||
786 | |||
787 | /** | ||
788 | * nla_get_u64 - return payload of u64 attribute | ||
789 | * @nla: u64 netlink attribute | ||
790 | */ | ||
791 | static inline u64 nla_get_u64(struct nlattr *nla) | ||
792 | { | ||
793 | u64 tmp; | ||
794 | |||
795 | nla_memcpy(&tmp, nla, sizeof(tmp)); | ||
796 | |||
797 | return tmp; | ||
798 | } | ||
799 | |||
800 | /** | ||
801 | * nla_get_flag - return payload of flag attribute | ||
802 | * @nla: flag netlink attribute | ||
803 | */ | ||
804 | static inline int nla_get_flag(struct nlattr *nla) | ||
805 | { | ||
806 | return !!nla; | ||
807 | } | ||
808 | |||
809 | /** | ||
810 | * nla_get_msecs - return payload of msecs attribute | ||
811 | * @nla: msecs netlink attribute | ||
812 | * | ||
813 | * Returns the number of milliseconds in jiffies. | ||
814 | */ | ||
815 | static inline unsigned long nla_get_msecs(struct nlattr *nla) | ||
816 | { | ||
817 | u64 msecs = nla_get_u64(nla); | ||
818 | |||
819 | return msecs_to_jiffies((unsigned long) msecs); | ||
820 | } | ||
821 | |||
822 | /** | ||
823 | * nla_nest_start - Start a new level of nested attributes | ||
824 | * @skb: socket buffer to add attributes to | ||
825 | * @attrtype: attribute type of container | ||
826 | * | ||
827 | * Returns the container attribute | ||
828 | */ | ||
829 | static inline struct nlattr *nla_nest_start(struct sk_buff *skb, int attrtype) | ||
830 | { | ||
831 | struct nlattr *start = (struct nlattr *) skb->tail; | ||
832 | |||
833 | if (nla_put(skb, attrtype, 0, NULL) < 0) | ||
834 | return NULL; | ||
835 | |||
836 | return start; | ||
837 | } | ||
838 | |||
839 | /** | ||
840 | * nla_nest_end - Finalize nesting of attributes | ||
841 | * @skb: socket buffer the attribtues are stored in | ||
842 | * @start: container attribute | ||
843 | * | ||
844 | * Corrects the container attribute header to include the all | ||
845 | * appeneded attributes. | ||
846 | * | ||
847 | * Returns the total data length of the skb. | ||
848 | */ | ||
849 | static inline int nla_nest_end(struct sk_buff *skb, struct nlattr *start) | ||
850 | { | ||
851 | start->nla_len = skb->tail - (unsigned char *) start; | ||
852 | return skb->len; | ||
853 | } | ||
854 | |||
855 | /** | ||
856 | * nla_nest_cancel - Cancel nesting of attributes | ||
857 | * @skb: socket buffer the message is stored in | ||
858 | * @start: container attribute | ||
859 | * | ||
860 | * Removes the container attribute and including all nested | ||
861 | * attributes. Returns -1. | ||
862 | */ | ||
863 | static inline int nla_nest_cancel(struct sk_buff *skb, struct nlattr *start) | ||
864 | { | ||
865 | if (start) | ||
866 | skb_trim(skb, (unsigned char *) start - skb->data); | ||
867 | |||
868 | return -1; | ||
869 | } | ||
870 | |||
871 | /** | ||
872 | * nla_for_each_attr - iterate over a stream of attributes | ||
873 | * @pos: loop counter, set to current attribute | ||
874 | * @head: head of attribute stream | ||
875 | * @len: length of attribute stream | ||
876 | * @rem: initialized to len, holds bytes currently remaining in stream | ||
877 | */ | ||
878 | #define nla_for_each_attr(pos, head, len, rem) \ | ||
879 | for (pos = head, rem = len; \ | ||
880 | nla_ok(pos, rem); \ | ||
881 | pos = nla_next(pos, &(rem))) | ||
882 | |||
883 | #endif | ||
diff --git a/include/net/netrom.h b/include/net/netrom.h index a6bf6e0f606a..a5ee53bce62f 100644 --- a/include/net/netrom.h +++ b/include/net/netrom.h | |||
@@ -136,8 +136,7 @@ static __inline__ void nr_node_put(struct nr_node *nr_node) | |||
136 | static __inline__ void nr_neigh_put(struct nr_neigh *nr_neigh) | 136 | static __inline__ void nr_neigh_put(struct nr_neigh *nr_neigh) |
137 | { | 137 | { |
138 | if (atomic_dec_and_test(&nr_neigh->refcount)) { | 138 | if (atomic_dec_and_test(&nr_neigh->refcount)) { |
139 | if (nr_neigh->digipeat != NULL) | 139 | kfree(nr_neigh->digipeat); |
140 | kfree(nr_neigh->digipeat); | ||
141 | kfree(nr_neigh); | 140 | kfree(nr_neigh); |
142 | } | 141 | } |
143 | } | 142 | } |
diff --git a/include/net/red.h b/include/net/red.h new file mode 100644 index 000000000000..2ed4358e3295 --- /dev/null +++ b/include/net/red.h | |||
@@ -0,0 +1,325 @@ | |||
1 | #ifndef __NET_SCHED_RED_H | ||
2 | #define __NET_SCHED_RED_H | ||
3 | |||
4 | #include <linux/config.h> | ||
5 | #include <linux/types.h> | ||
6 | #include <net/pkt_sched.h> | ||
7 | #include <net/inet_ecn.h> | ||
8 | #include <net/dsfield.h> | ||
9 | |||
10 | /* Random Early Detection (RED) algorithm. | ||
11 | ======================================= | ||
12 | |||
13 | Source: Sally Floyd and Van Jacobson, "Random Early Detection Gateways | ||
14 | for Congestion Avoidance", 1993, IEEE/ACM Transactions on Networking. | ||
15 | |||
16 | This file codes a "divisionless" version of RED algorithm | ||
17 | as written down in Fig.17 of the paper. | ||
18 | |||
19 | Short description. | ||
20 | ------------------ | ||
21 | |||
22 | When a new packet arrives we calculate the average queue length: | ||
23 | |||
24 | avg = (1-W)*avg + W*current_queue_len, | ||
25 | |||
26 | W is the filter time constant (chosen as 2^(-Wlog)), it controls | ||
27 | the inertia of the algorithm. To allow larger bursts, W should be | ||
28 | decreased. | ||
29 | |||
30 | if (avg > th_max) -> packet marked (dropped). | ||
31 | if (avg < th_min) -> packet passes. | ||
32 | if (th_min < avg < th_max) we calculate probability: | ||
33 | |||
34 | Pb = max_P * (avg - th_min)/(th_max-th_min) | ||
35 | |||
36 | and mark (drop) packet with this probability. | ||
37 | Pb changes from 0 (at avg==th_min) to max_P (avg==th_max). | ||
38 | max_P should be small (not 1), usually 0.01..0.02 is good value. | ||
39 | |||
40 | max_P is chosen as a number, so that max_P/(th_max-th_min) | ||
41 | is a negative power of two in order arithmetics to contain | ||
42 | only shifts. | ||
43 | |||
44 | |||
45 | Parameters, settable by user: | ||
46 | ----------------------------- | ||
47 | |||
48 | qth_min - bytes (should be < qth_max/2) | ||
49 | qth_max - bytes (should be at least 2*qth_min and less limit) | ||
50 | Wlog - bits (<32) log(1/W). | ||
51 | Plog - bits (<32) | ||
52 | |||
53 | Plog is related to max_P by formula: | ||
54 | |||
55 | max_P = (qth_max-qth_min)/2^Plog; | ||
56 | |||
57 | F.e. if qth_max=128K and qth_min=32K, then Plog=22 | ||
58 | corresponds to max_P=0.02 | ||
59 | |||
60 | Scell_log | ||
61 | Stab | ||
62 | |||
63 | Lookup table for log((1-W)^(t/t_ave). | ||
64 | |||
65 | |||
66 | NOTES: | ||
67 | |||
68 | Upper bound on W. | ||
69 | ----------------- | ||
70 | |||
71 | If you want to allow bursts of L packets of size S, | ||
72 | you should choose W: | ||
73 | |||
74 | L + 1 - th_min/S < (1-(1-W)^L)/W | ||
75 | |||
76 | th_min/S = 32 th_min/S = 4 | ||
77 | |||
78 | log(W) L | ||
79 | -1 33 | ||
80 | -2 35 | ||
81 | -3 39 | ||
82 | -4 46 | ||
83 | -5 57 | ||
84 | -6 75 | ||
85 | -7 101 | ||
86 | -8 135 | ||
87 | -9 190 | ||
88 | etc. | ||
89 | */ | ||
90 | |||
91 | #define RED_STAB_SIZE 256 | ||
92 | #define RED_STAB_MASK (RED_STAB_SIZE - 1) | ||
93 | |||
94 | struct red_stats | ||
95 | { | ||
96 | u32 prob_drop; /* Early probability drops */ | ||
97 | u32 prob_mark; /* Early probability marks */ | ||
98 | u32 forced_drop; /* Forced drops, qavg > max_thresh */ | ||
99 | u32 forced_mark; /* Forced marks, qavg > max_thresh */ | ||
100 | u32 pdrop; /* Drops due to queue limits */ | ||
101 | u32 other; /* Drops due to drop() calls */ | ||
102 | u32 backlog; | ||
103 | }; | ||
104 | |||
105 | struct red_parms | ||
106 | { | ||
107 | /* Parameters */ | ||
108 | u32 qth_min; /* Min avg length threshold: A scaled */ | ||
109 | u32 qth_max; /* Max avg length threshold: A scaled */ | ||
110 | u32 Scell_max; | ||
111 | u32 Rmask; /* Cached random mask, see red_rmask */ | ||
112 | u8 Scell_log; | ||
113 | u8 Wlog; /* log(W) */ | ||
114 | u8 Plog; /* random number bits */ | ||
115 | u8 Stab[RED_STAB_SIZE]; | ||
116 | |||
117 | /* Variables */ | ||
118 | int qcount; /* Number of packets since last random | ||
119 | number generation */ | ||
120 | u32 qR; /* Cached random number */ | ||
121 | |||
122 | unsigned long qavg; /* Average queue length: A scaled */ | ||
123 | psched_time_t qidlestart; /* Start of current idle period */ | ||
124 | }; | ||
125 | |||
126 | static inline u32 red_rmask(u8 Plog) | ||
127 | { | ||
128 | return Plog < 32 ? ((1 << Plog) - 1) : ~0UL; | ||
129 | } | ||
130 | |||
131 | static inline void red_set_parms(struct red_parms *p, | ||
132 | u32 qth_min, u32 qth_max, u8 Wlog, u8 Plog, | ||
133 | u8 Scell_log, u8 *stab) | ||
134 | { | ||
135 | /* Reset average queue length, the value is strictly bound | ||
136 | * to the parameters below, reseting hurts a bit but leaving | ||
137 | * it might result in an unreasonable qavg for a while. --TGR | ||
138 | */ | ||
139 | p->qavg = 0; | ||
140 | |||
141 | p->qcount = -1; | ||
142 | p->qth_min = qth_min << Wlog; | ||
143 | p->qth_max = qth_max << Wlog; | ||
144 | p->Wlog = Wlog; | ||
145 | p->Plog = Plog; | ||
146 | p->Rmask = red_rmask(Plog); | ||
147 | p->Scell_log = Scell_log; | ||
148 | p->Scell_max = (255 << Scell_log); | ||
149 | |||
150 | memcpy(p->Stab, stab, sizeof(p->Stab)); | ||
151 | } | ||
152 | |||
153 | static inline int red_is_idling(struct red_parms *p) | ||
154 | { | ||
155 | return !PSCHED_IS_PASTPERFECT(p->qidlestart); | ||
156 | } | ||
157 | |||
158 | static inline void red_start_of_idle_period(struct red_parms *p) | ||
159 | { | ||
160 | PSCHED_GET_TIME(p->qidlestart); | ||
161 | } | ||
162 | |||
163 | static inline void red_end_of_idle_period(struct red_parms *p) | ||
164 | { | ||
165 | PSCHED_SET_PASTPERFECT(p->qidlestart); | ||
166 | } | ||
167 | |||
168 | static inline void red_restart(struct red_parms *p) | ||
169 | { | ||
170 | red_end_of_idle_period(p); | ||
171 | p->qavg = 0; | ||
172 | p->qcount = -1; | ||
173 | } | ||
174 | |||
175 | static inline unsigned long red_calc_qavg_from_idle_time(struct red_parms *p) | ||
176 | { | ||
177 | psched_time_t now; | ||
178 | long us_idle; | ||
179 | int shift; | ||
180 | |||
181 | PSCHED_GET_TIME(now); | ||
182 | us_idle = PSCHED_TDIFF_SAFE(now, p->qidlestart, p->Scell_max); | ||
183 | |||
184 | /* | ||
185 | * The problem: ideally, average length queue recalcultion should | ||
186 | * be done over constant clock intervals. This is too expensive, so | ||
187 | * that the calculation is driven by outgoing packets. | ||
188 | * When the queue is idle we have to model this clock by hand. | ||
189 | * | ||
190 | * SF+VJ proposed to "generate": | ||
191 | * | ||
192 | * m = idletime / (average_pkt_size / bandwidth) | ||
193 | * | ||
194 | * dummy packets as a burst after idle time, i.e. | ||
195 | * | ||
196 | * p->qavg *= (1-W)^m | ||
197 | * | ||
198 | * This is an apparently overcomplicated solution (f.e. we have to | ||
199 | * precompute a table to make this calculation in reasonable time) | ||
200 | * I believe that a simpler model may be used here, | ||
201 | * but it is field for experiments. | ||
202 | */ | ||
203 | |||
204 | shift = p->Stab[(us_idle >> p->Scell_log) & RED_STAB_MASK]; | ||
205 | |||
206 | if (shift) | ||
207 | return p->qavg >> shift; | ||
208 | else { | ||
209 | /* Approximate initial part of exponent with linear function: | ||
210 | * | ||
211 | * (1-W)^m ~= 1-mW + ... | ||
212 | * | ||
213 | * Seems, it is the best solution to | ||
214 | * problem of too coarse exponent tabulation. | ||
215 | */ | ||
216 | us_idle = (p->qavg * us_idle) >> p->Scell_log; | ||
217 | |||
218 | if (us_idle < (p->qavg >> 1)) | ||
219 | return p->qavg - us_idle; | ||
220 | else | ||
221 | return p->qavg >> 1; | ||
222 | } | ||
223 | } | ||
224 | |||
225 | static inline unsigned long red_calc_qavg_no_idle_time(struct red_parms *p, | ||
226 | unsigned int backlog) | ||
227 | { | ||
228 | /* | ||
229 | * NOTE: p->qavg is fixed point number with point at Wlog. | ||
230 | * The formula below is equvalent to floating point | ||
231 | * version: | ||
232 | * | ||
233 | * qavg = qavg*(1-W) + backlog*W; | ||
234 | * | ||
235 | * --ANK (980924) | ||
236 | */ | ||
237 | return p->qavg + (backlog - (p->qavg >> p->Wlog)); | ||
238 | } | ||
239 | |||
240 | static inline unsigned long red_calc_qavg(struct red_parms *p, | ||
241 | unsigned int backlog) | ||
242 | { | ||
243 | if (!red_is_idling(p)) | ||
244 | return red_calc_qavg_no_idle_time(p, backlog); | ||
245 | else | ||
246 | return red_calc_qavg_from_idle_time(p); | ||
247 | } | ||
248 | |||
249 | static inline u32 red_random(struct red_parms *p) | ||
250 | { | ||
251 | return net_random() & p->Rmask; | ||
252 | } | ||
253 | |||
254 | static inline int red_mark_probability(struct red_parms *p, unsigned long qavg) | ||
255 | { | ||
256 | /* The formula used below causes questions. | ||
257 | |||
258 | OK. qR is random number in the interval 0..Rmask | ||
259 | i.e. 0..(2^Plog). If we used floating point | ||
260 | arithmetics, it would be: (2^Plog)*rnd_num, | ||
261 | where rnd_num is less 1. | ||
262 | |||
263 | Taking into account, that qavg have fixed | ||
264 | point at Wlog, and Plog is related to max_P by | ||
265 | max_P = (qth_max-qth_min)/2^Plog; two lines | ||
266 | below have the following floating point equivalent: | ||
267 | |||
268 | max_P*(qavg - qth_min)/(qth_max-qth_min) < rnd/qcount | ||
269 | |||
270 | Any questions? --ANK (980924) | ||
271 | */ | ||
272 | return !(((qavg - p->qth_min) >> p->Wlog) * p->qcount < p->qR); | ||
273 | } | ||
274 | |||
275 | enum { | ||
276 | RED_BELOW_MIN_THRESH, | ||
277 | RED_BETWEEN_TRESH, | ||
278 | RED_ABOVE_MAX_TRESH, | ||
279 | }; | ||
280 | |||
281 | static inline int red_cmp_thresh(struct red_parms *p, unsigned long qavg) | ||
282 | { | ||
283 | if (qavg < p->qth_min) | ||
284 | return RED_BELOW_MIN_THRESH; | ||
285 | else if (qavg >= p->qth_max) | ||
286 | return RED_ABOVE_MAX_TRESH; | ||
287 | else | ||
288 | return RED_BETWEEN_TRESH; | ||
289 | } | ||
290 | |||
291 | enum { | ||
292 | RED_DONT_MARK, | ||
293 | RED_PROB_MARK, | ||
294 | RED_HARD_MARK, | ||
295 | }; | ||
296 | |||
297 | static inline int red_action(struct red_parms *p, unsigned long qavg) | ||
298 | { | ||
299 | switch (red_cmp_thresh(p, qavg)) { | ||
300 | case RED_BELOW_MIN_THRESH: | ||
301 | p->qcount = -1; | ||
302 | return RED_DONT_MARK; | ||
303 | |||
304 | case RED_BETWEEN_TRESH: | ||
305 | if (++p->qcount) { | ||
306 | if (red_mark_probability(p, qavg)) { | ||
307 | p->qcount = 0; | ||
308 | p->qR = red_random(p); | ||
309 | return RED_PROB_MARK; | ||
310 | } | ||
311 | } else | ||
312 | p->qR = red_random(p); | ||
313 | |||
314 | return RED_DONT_MARK; | ||
315 | |||
316 | case RED_ABOVE_MAX_TRESH: | ||
317 | p->qcount = -1; | ||
318 | return RED_HARD_MARK; | ||
319 | } | ||
320 | |||
321 | BUG(); | ||
322 | return RED_DONT_MARK; | ||
323 | } | ||
324 | |||
325 | #endif | ||
diff --git a/include/net/route.h b/include/net/route.h index dbe79ca67d31..e3e5436f8017 100644 --- a/include/net/route.h +++ b/include/net/route.h | |||
@@ -126,6 +126,9 @@ extern int ip_rt_ioctl(unsigned int cmd, void __user *arg); | |||
126 | extern void ip_rt_get_source(u8 *src, struct rtable *rt); | 126 | extern void ip_rt_get_source(u8 *src, struct rtable *rt); |
127 | extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); | 127 | extern int ip_rt_dump(struct sk_buff *skb, struct netlink_callback *cb); |
128 | 128 | ||
129 | struct in_ifaddr; | ||
130 | extern void fib_add_ifaddr(struct in_ifaddr *); | ||
131 | |||
129 | static inline void ip_rt_put(struct rtable * rt) | 132 | static inline void ip_rt_put(struct rtable * rt) |
130 | { | 133 | { |
131 | if (rt) | 134 | if (rt) |
diff --git a/include/net/sctp/command.h b/include/net/sctp/command.h index dc107ffad483..34a1a09e5aef 100644 --- a/include/net/sctp/command.h +++ b/include/net/sctp/command.h | |||
@@ -120,6 +120,7 @@ typedef union { | |||
120 | int error; | 120 | int error; |
121 | sctp_state_t state; | 121 | sctp_state_t state; |
122 | sctp_event_timeout_t to; | 122 | sctp_event_timeout_t to; |
123 | unsigned long zero; | ||
123 | void *ptr; | 124 | void *ptr; |
124 | struct sctp_chunk *chunk; | 125 | struct sctp_chunk *chunk; |
125 | struct sctp_association *asoc; | 126 | struct sctp_association *asoc; |
@@ -148,17 +149,17 @@ static inline sctp_arg_t SCTP_NULL(void) | |||
148 | } | 149 | } |
149 | static inline sctp_arg_t SCTP_NOFORCE(void) | 150 | static inline sctp_arg_t SCTP_NOFORCE(void) |
150 | { | 151 | { |
151 | sctp_arg_t retval; retval.i32 = 0; return retval; | 152 | sctp_arg_t retval = {.zero = 0UL}; retval.i32 = 0; return retval; |
152 | } | 153 | } |
153 | static inline sctp_arg_t SCTP_FORCE(void) | 154 | static inline sctp_arg_t SCTP_FORCE(void) |
154 | { | 155 | { |
155 | sctp_arg_t retval; retval.i32 = 1; return retval; | 156 | sctp_arg_t retval = {.zero = 0UL}; retval.i32 = 1; return retval; |
156 | } | 157 | } |
157 | 158 | ||
158 | #define SCTP_ARG_CONSTRUCTOR(name, type, elt) \ | 159 | #define SCTP_ARG_CONSTRUCTOR(name, type, elt) \ |
159 | static inline sctp_arg_t \ | 160 | static inline sctp_arg_t \ |
160 | SCTP_## name (type arg) \ | 161 | SCTP_## name (type arg) \ |
161 | { sctp_arg_t retval; retval.elt = arg; return retval; } | 162 | { sctp_arg_t retval = {.zero = 0UL}; retval.elt = arg; return retval; } |
162 | 163 | ||
163 | SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) | 164 | SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) |
164 | SCTP_ARG_CONSTRUCTOR(U32, __u32, u32) | 165 | SCTP_ARG_CONSTRUCTOR(U32, __u32, u32) |
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h index e1d5ec1c23c0..8f241216f46b 100644 --- a/include/net/sctp/sctp.h +++ b/include/net/sctp/sctp.h | |||
@@ -125,7 +125,7 @@ | |||
125 | */ | 125 | */ |
126 | extern struct sock *sctp_get_ctl_sock(void); | 126 | extern struct sock *sctp_get_ctl_sock(void); |
127 | extern int sctp_copy_local_addr_list(struct sctp_bind_addr *, | 127 | extern int sctp_copy_local_addr_list(struct sctp_bind_addr *, |
128 | sctp_scope_t, unsigned int __nocast gfp, | 128 | sctp_scope_t, gfp_t gfp, |
129 | int flags); | 129 | int flags); |
130 | extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); | 130 | extern struct sctp_pf *sctp_get_pf_specific(sa_family_t family); |
131 | extern int sctp_register_pf(struct sctp_pf *, sa_family_t); | 131 | extern int sctp_register_pf(struct sctp_pf *, sa_family_t); |
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h index 58462164d960..1eac3d0eb7a9 100644 --- a/include/net/sctp/sm.h +++ b/include/net/sctp/sm.h | |||
@@ -181,17 +181,17 @@ const sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t, | |||
181 | int sctp_chunk_iif(const struct sctp_chunk *); | 181 | int sctp_chunk_iif(const struct sctp_chunk *); |
182 | struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *, | 182 | struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *, |
183 | struct sctp_chunk *, | 183 | struct sctp_chunk *, |
184 | unsigned int __nocast gfp); | 184 | gfp_t gfp); |
185 | __u32 sctp_generate_verification_tag(void); | 185 | __u32 sctp_generate_verification_tag(void); |
186 | void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag); | 186 | void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag); |
187 | 187 | ||
188 | /* Prototypes for chunk-building functions. */ | 188 | /* Prototypes for chunk-building functions. */ |
189 | struct sctp_chunk *sctp_make_init(const struct sctp_association *, | 189 | struct sctp_chunk *sctp_make_init(const struct sctp_association *, |
190 | const struct sctp_bind_addr *, | 190 | const struct sctp_bind_addr *, |
191 | unsigned int __nocast gfp, int vparam_len); | 191 | gfp_t gfp, int vparam_len); |
192 | struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *, | 192 | struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *, |
193 | const struct sctp_chunk *, | 193 | const struct sctp_chunk *, |
194 | const unsigned int __nocast gfp, | 194 | const gfp_t gfp, |
195 | const int unkparam_len); | 195 | const int unkparam_len); |
196 | struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *, | 196 | struct sctp_chunk *sctp_make_cookie_echo(const struct sctp_association *, |
197 | const struct sctp_chunk *); | 197 | const struct sctp_chunk *); |
@@ -265,7 +265,7 @@ int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype, | |||
265 | struct sctp_endpoint *, | 265 | struct sctp_endpoint *, |
266 | struct sctp_association *asoc, | 266 | struct sctp_association *asoc, |
267 | void *event_arg, | 267 | void *event_arg, |
268 | unsigned int __nocast gfp); | 268 | gfp_t gfp); |
269 | 269 | ||
270 | /* 2nd level prototypes */ | 270 | /* 2nd level prototypes */ |
271 | void sctp_generate_t3_rtx_event(unsigned long peer); | 271 | void sctp_generate_t3_rtx_event(unsigned long peer); |
@@ -276,7 +276,7 @@ void sctp_ootb_pkt_free(struct sctp_packet *); | |||
276 | struct sctp_association *sctp_unpack_cookie(const struct sctp_endpoint *, | 276 | struct sctp_association *sctp_unpack_cookie(const struct sctp_endpoint *, |
277 | const struct sctp_association *, | 277 | const struct sctp_association *, |
278 | struct sctp_chunk *, | 278 | struct sctp_chunk *, |
279 | unsigned int __nocast gfp, int *err, | 279 | gfp_t gfp, int *err, |
280 | struct sctp_chunk **err_chk_p); | 280 | struct sctp_chunk **err_chk_p); |
281 | int sctp_addip_addr_config(struct sctp_association *, sctp_param_t, | 281 | int sctp_addip_addr_config(struct sctp_association *, sctp_param_t, |
282 | struct sockaddr_storage*, int); | 282 | struct sockaddr_storage*, int); |
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 994009bbe3b4..8e7794ee27ff 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -161,6 +161,13 @@ extern struct sctp_globals { | |||
161 | */ | 161 | */ |
162 | int sndbuf_policy; | 162 | int sndbuf_policy; |
163 | 163 | ||
164 | /* | ||
165 | * Policy for preforming sctp/socket accounting | ||
166 | * 0 - do socket level accounting, all assocs share sk_rcvbuf | ||
167 | * 1 - do sctp accounting, each asoc may use sk_rcvbuf bytes | ||
168 | */ | ||
169 | int rcvbuf_policy; | ||
170 | |||
164 | /* Delayed SACK timeout 200ms default*/ | 171 | /* Delayed SACK timeout 200ms default*/ |
165 | int sack_timeout; | 172 | int sack_timeout; |
166 | 173 | ||
@@ -218,6 +225,7 @@ extern struct sctp_globals { | |||
218 | #define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable) | 225 | #define sctp_cookie_preserve_enable (sctp_globals.cookie_preserve_enable) |
219 | #define sctp_max_retrans_association (sctp_globals.max_retrans_association) | 226 | #define sctp_max_retrans_association (sctp_globals.max_retrans_association) |
220 | #define sctp_sndbuf_policy (sctp_globals.sndbuf_policy) | 227 | #define sctp_sndbuf_policy (sctp_globals.sndbuf_policy) |
228 | #define sctp_rcvbuf_policy (sctp_globals.rcvbuf_policy) | ||
221 | #define sctp_max_retrans_path (sctp_globals.max_retrans_path) | 229 | #define sctp_max_retrans_path (sctp_globals.max_retrans_path) |
222 | #define sctp_max_retrans_init (sctp_globals.max_retrans_init) | 230 | #define sctp_max_retrans_init (sctp_globals.max_retrans_init) |
223 | #define sctp_sack_timeout (sctp_globals.sack_timeout) | 231 | #define sctp_sack_timeout (sctp_globals.sack_timeout) |
@@ -446,7 +454,7 @@ struct sctp_ssnmap { | |||
446 | }; | 454 | }; |
447 | 455 | ||
448 | struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, | 456 | struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, |
449 | unsigned int __nocast gfp); | 457 | gfp_t gfp); |
450 | void sctp_ssnmap_free(struct sctp_ssnmap *map); | 458 | void sctp_ssnmap_free(struct sctp_ssnmap *map); |
451 | void sctp_ssnmap_clear(struct sctp_ssnmap *map); | 459 | void sctp_ssnmap_clear(struct sctp_ssnmap *map); |
452 | 460 | ||
@@ -947,7 +955,7 @@ struct sctp_transport { | |||
947 | }; | 955 | }; |
948 | 956 | ||
949 | struct sctp_transport *sctp_transport_new(const union sctp_addr *, | 957 | struct sctp_transport *sctp_transport_new(const union sctp_addr *, |
950 | unsigned int __nocast); | 958 | gfp_t); |
951 | void sctp_transport_set_owner(struct sctp_transport *, | 959 | void sctp_transport_set_owner(struct sctp_transport *, |
952 | struct sctp_association *); | 960 | struct sctp_association *); |
953 | void sctp_transport_route(struct sctp_transport *, union sctp_addr *, | 961 | void sctp_transport_route(struct sctp_transport *, union sctp_addr *, |
@@ -1095,10 +1103,10 @@ void sctp_bind_addr_init(struct sctp_bind_addr *, __u16 port); | |||
1095 | void sctp_bind_addr_free(struct sctp_bind_addr *); | 1103 | void sctp_bind_addr_free(struct sctp_bind_addr *); |
1096 | int sctp_bind_addr_copy(struct sctp_bind_addr *dest, | 1104 | int sctp_bind_addr_copy(struct sctp_bind_addr *dest, |
1097 | const struct sctp_bind_addr *src, | 1105 | const struct sctp_bind_addr *src, |
1098 | sctp_scope_t scope, unsigned int __nocast gfp, | 1106 | sctp_scope_t scope, gfp_t gfp, |
1099 | int flags); | 1107 | int flags); |
1100 | int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, | 1108 | int sctp_add_bind_addr(struct sctp_bind_addr *, union sctp_addr *, |
1101 | unsigned int __nocast gfp); | 1109 | gfp_t gfp); |
1102 | int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *); | 1110 | int sctp_del_bind_addr(struct sctp_bind_addr *, union sctp_addr *); |
1103 | int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *, | 1111 | int sctp_bind_addr_match(struct sctp_bind_addr *, const union sctp_addr *, |
1104 | struct sctp_sock *); | 1112 | struct sctp_sock *); |
@@ -1108,9 +1116,9 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, | |||
1108 | struct sctp_sock *opt); | 1116 | struct sctp_sock *opt); |
1109 | union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, | 1117 | union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, |
1110 | int *addrs_len, | 1118 | int *addrs_len, |
1111 | unsigned int __nocast gfp); | 1119 | gfp_t gfp); |
1112 | int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len, | 1120 | int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw, int len, |
1113 | __u16 port, unsigned int __nocast gfp); | 1121 | __u16 port, gfp_t gfp); |
1114 | 1122 | ||
1115 | sctp_scope_t sctp_scope(const union sctp_addr *); | 1123 | sctp_scope_t sctp_scope(const union sctp_addr *); |
1116 | int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope); | 1124 | int sctp_in_scope(const union sctp_addr *addr, const sctp_scope_t scope); |
@@ -1222,11 +1230,11 @@ struct sctp_endpoint { | |||
1222 | int last_key; | 1230 | int last_key; |
1223 | int key_changed_at; | 1231 | int key_changed_at; |
1224 | 1232 | ||
1225 | /* Default timeouts. */ | ||
1226 | int timeouts[SCTP_NUM_TIMEOUT_TYPES]; | ||
1227 | |||
1228 | /* sendbuf acct. policy. */ | 1233 | /* sendbuf acct. policy. */ |
1229 | __u32 sndbuf_policy; | 1234 | __u32 sndbuf_policy; |
1235 | |||
1236 | /* rcvbuf acct. policy. */ | ||
1237 | __u32 rcvbuf_policy; | ||
1230 | }; | 1238 | }; |
1231 | 1239 | ||
1232 | /* Recover the outter endpoint structure. */ | 1240 | /* Recover the outter endpoint structure. */ |
@@ -1239,7 +1247,7 @@ static inline struct sctp_endpoint *sctp_ep(struct sctp_ep_common *base) | |||
1239 | } | 1247 | } |
1240 | 1248 | ||
1241 | /* These are function signatures for manipulating endpoints. */ | 1249 | /* These are function signatures for manipulating endpoints. */ |
1242 | struct sctp_endpoint *sctp_endpoint_new(struct sock *, unsigned int __nocast); | 1250 | struct sctp_endpoint *sctp_endpoint_new(struct sock *, gfp_t); |
1243 | void sctp_endpoint_free(struct sctp_endpoint *); | 1251 | void sctp_endpoint_free(struct sctp_endpoint *); |
1244 | void sctp_endpoint_put(struct sctp_endpoint *); | 1252 | void sctp_endpoint_put(struct sctp_endpoint *); |
1245 | void sctp_endpoint_hold(struct sctp_endpoint *); | 1253 | void sctp_endpoint_hold(struct sctp_endpoint *); |
@@ -1260,7 +1268,7 @@ int sctp_verify_init(const struct sctp_association *asoc, sctp_cid_t, | |||
1260 | struct sctp_chunk **err_chunk); | 1268 | struct sctp_chunk **err_chunk); |
1261 | int sctp_process_init(struct sctp_association *, sctp_cid_t cid, | 1269 | int sctp_process_init(struct sctp_association *, sctp_cid_t cid, |
1262 | const union sctp_addr *peer, | 1270 | const union sctp_addr *peer, |
1263 | sctp_init_chunk_t *init, unsigned int __nocast gfp); | 1271 | sctp_init_chunk_t *init, gfp_t gfp); |
1264 | __u32 sctp_generate_tag(const struct sctp_endpoint *); | 1272 | __u32 sctp_generate_tag(const struct sctp_endpoint *); |
1265 | __u32 sctp_generate_tsn(const struct sctp_endpoint *); | 1273 | __u32 sctp_generate_tsn(const struct sctp_endpoint *); |
1266 | 1274 | ||
@@ -1553,6 +1561,11 @@ struct sctp_association { | |||
1553 | */ | 1561 | */ |
1554 | int sndbuf_used; | 1562 | int sndbuf_used; |
1555 | 1563 | ||
1564 | /* This is the amount of memory that this association has allocated | ||
1565 | * in the receive path at any given time. | ||
1566 | */ | ||
1567 | atomic_t rmem_alloc; | ||
1568 | |||
1556 | /* This is the wait queue head for send requests waiting on | 1569 | /* This is the wait queue head for send requests waiting on |
1557 | * the association sndbuf space. | 1570 | * the association sndbuf space. |
1558 | */ | 1571 | */ |
@@ -1723,7 +1736,7 @@ static inline struct sctp_association *sctp_assoc(struct sctp_ep_common *base) | |||
1723 | 1736 | ||
1724 | struct sctp_association * | 1737 | struct sctp_association * |
1725 | sctp_association_new(const struct sctp_endpoint *, const struct sock *, | 1738 | sctp_association_new(const struct sctp_endpoint *, const struct sock *, |
1726 | sctp_scope_t scope, unsigned int __nocast gfp); | 1739 | sctp_scope_t scope, gfp_t gfp); |
1727 | void sctp_association_free(struct sctp_association *); | 1740 | void sctp_association_free(struct sctp_association *); |
1728 | void sctp_association_put(struct sctp_association *); | 1741 | void sctp_association_put(struct sctp_association *); |
1729 | void sctp_association_hold(struct sctp_association *); | 1742 | void sctp_association_hold(struct sctp_association *); |
@@ -1739,7 +1752,7 @@ int sctp_assoc_lookup_laddr(struct sctp_association *asoc, | |||
1739 | const union sctp_addr *laddr); | 1752 | const union sctp_addr *laddr); |
1740 | struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *, | 1753 | struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *, |
1741 | const union sctp_addr *address, | 1754 | const union sctp_addr *address, |
1742 | const unsigned int __nocast gfp, | 1755 | const gfp_t gfp, |
1743 | const int peer_state); | 1756 | const int peer_state); |
1744 | void sctp_assoc_del_peer(struct sctp_association *asoc, | 1757 | void sctp_assoc_del_peer(struct sctp_association *asoc, |
1745 | const union sctp_addr *addr); | 1758 | const union sctp_addr *addr); |
@@ -1764,10 +1777,10 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *, unsigned); | |||
1764 | void sctp_assoc_set_primary(struct sctp_association *, | 1777 | void sctp_assoc_set_primary(struct sctp_association *, |
1765 | struct sctp_transport *); | 1778 | struct sctp_transport *); |
1766 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, | 1779 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *, |
1767 | unsigned int __nocast); | 1780 | gfp_t); |
1768 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, | 1781 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *, |
1769 | struct sctp_cookie*, | 1782 | struct sctp_cookie*, |
1770 | unsigned int __nocast gfp); | 1783 | gfp_t gfp); |
1771 | 1784 | ||
1772 | int sctp_cmp_addr_exact(const union sctp_addr *ss1, | 1785 | int sctp_cmp_addr_exact(const union sctp_addr *ss1, |
1773 | const union sctp_addr *ss2); | 1786 | const union sctp_addr *ss2); |
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h index 90fe4bf6754f..6c40cfc4832d 100644 --- a/include/net/sctp/ulpevent.h +++ b/include/net/sctp/ulpevent.h | |||
@@ -88,7 +88,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( | |||
88 | __u16 error, | 88 | __u16 error, |
89 | __u16 outbound, | 89 | __u16 outbound, |
90 | __u16 inbound, | 90 | __u16 inbound, |
91 | unsigned int __nocast gfp); | 91 | gfp_t gfp); |
92 | 92 | ||
93 | struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( | 93 | struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( |
94 | const struct sctp_association *asoc, | 94 | const struct sctp_association *asoc, |
@@ -96,35 +96,35 @@ struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( | |||
96 | int flags, | 96 | int flags, |
97 | int state, | 97 | int state, |
98 | int error, | 98 | int error, |
99 | unsigned int __nocast gfp); | 99 | gfp_t gfp); |
100 | 100 | ||
101 | struct sctp_ulpevent *sctp_ulpevent_make_remote_error( | 101 | struct sctp_ulpevent *sctp_ulpevent_make_remote_error( |
102 | const struct sctp_association *asoc, | 102 | const struct sctp_association *asoc, |
103 | struct sctp_chunk *chunk, | 103 | struct sctp_chunk *chunk, |
104 | __u16 flags, | 104 | __u16 flags, |
105 | unsigned int __nocast gfp); | 105 | gfp_t gfp); |
106 | struct sctp_ulpevent *sctp_ulpevent_make_send_failed( | 106 | struct sctp_ulpevent *sctp_ulpevent_make_send_failed( |
107 | const struct sctp_association *asoc, | 107 | const struct sctp_association *asoc, |
108 | struct sctp_chunk *chunk, | 108 | struct sctp_chunk *chunk, |
109 | __u16 flags, | 109 | __u16 flags, |
110 | __u32 error, | 110 | __u32 error, |
111 | unsigned int __nocast gfp); | 111 | gfp_t gfp); |
112 | 112 | ||
113 | struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event( | 113 | struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event( |
114 | const struct sctp_association *asoc, | 114 | const struct sctp_association *asoc, |
115 | __u16 flags, | 115 | __u16 flags, |
116 | unsigned int __nocast gfp); | 116 | gfp_t gfp); |
117 | 117 | ||
118 | struct sctp_ulpevent *sctp_ulpevent_make_pdapi( | 118 | struct sctp_ulpevent *sctp_ulpevent_make_pdapi( |
119 | const struct sctp_association *asoc, | 119 | const struct sctp_association *asoc, |
120 | __u32 indication, unsigned int __nocast gfp); | 120 | __u32 indication, gfp_t gfp); |
121 | 121 | ||
122 | struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication( | 122 | struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication( |
123 | const struct sctp_association *asoc, unsigned int __nocast gfp); | 123 | const struct sctp_association *asoc, gfp_t gfp); |
124 | 124 | ||
125 | struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, | 125 | struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, |
126 | struct sctp_chunk *chunk, | 126 | struct sctp_chunk *chunk, |
127 | unsigned int __nocast gfp); | 127 | gfp_t gfp); |
128 | 128 | ||
129 | void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, | 129 | void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, |
130 | struct msghdr *); | 130 | struct msghdr *); |
diff --git a/include/net/sctp/ulpqueue.h b/include/net/sctp/ulpqueue.h index 1a60c6d943c1..a43c8788b650 100644 --- a/include/net/sctp/ulpqueue.h +++ b/include/net/sctp/ulpqueue.h | |||
@@ -62,22 +62,19 @@ struct sctp_ulpq *sctp_ulpq_init(struct sctp_ulpq *, | |||
62 | void sctp_ulpq_free(struct sctp_ulpq *); | 62 | void sctp_ulpq_free(struct sctp_ulpq *); |
63 | 63 | ||
64 | /* Add a new DATA chunk for processing. */ | 64 | /* Add a new DATA chunk for processing. */ |
65 | int sctp_ulpq_tail_data(struct sctp_ulpq *, struct sctp_chunk *, | 65 | int sctp_ulpq_tail_data(struct sctp_ulpq *, struct sctp_chunk *, gfp_t); |
66 | unsigned int __nocast); | ||
67 | 66 | ||
68 | /* Add a new event for propagation to the ULP. */ | 67 | /* Add a new event for propagation to the ULP. */ |
69 | int sctp_ulpq_tail_event(struct sctp_ulpq *, struct sctp_ulpevent *ev); | 68 | int sctp_ulpq_tail_event(struct sctp_ulpq *, struct sctp_ulpevent *ev); |
70 | 69 | ||
71 | /* Renege previously received chunks. */ | 70 | /* Renege previously received chunks. */ |
72 | void sctp_ulpq_renege(struct sctp_ulpq *, struct sctp_chunk *, | 71 | void sctp_ulpq_renege(struct sctp_ulpq *, struct sctp_chunk *, gfp_t); |
73 | unsigned int __nocast); | ||
74 | 72 | ||
75 | /* Perform partial delivery. */ | 73 | /* Perform partial delivery. */ |
76 | void sctp_ulpq_partial_delivery(struct sctp_ulpq *, struct sctp_chunk *, | 74 | void sctp_ulpq_partial_delivery(struct sctp_ulpq *, struct sctp_chunk *, gfp_t); |
77 | unsigned int __nocast); | ||
78 | 75 | ||
79 | /* Abort the partial delivery. */ | 76 | /* Abort the partial delivery. */ |
80 | void sctp_ulpq_abort_pd(struct sctp_ulpq *, unsigned int __nocast); | 77 | void sctp_ulpq_abort_pd(struct sctp_ulpq *, gfp_t); |
81 | 78 | ||
82 | /* Clear the partial data delivery condition on this socket. */ | 79 | /* Clear the partial data delivery condition on this socket. */ |
83 | int sctp_clear_pd(struct sock *sk); | 80 | int sctp_clear_pd(struct sock *sk); |
diff --git a/include/net/sctp/user.h b/include/net/sctp/user.h index f6328aeddcce..f1c3bc54526a 100644 --- a/include/net/sctp/user.h +++ b/include/net/sctp/user.h | |||
@@ -103,16 +103,20 @@ enum sctp_optname { | |||
103 | #define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM | 103 | #define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM |
104 | SCTP_SOCKOPT_PEELOFF, /* peel off association. */ | 104 | SCTP_SOCKOPT_PEELOFF, /* peel off association. */ |
105 | #define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF | 105 | #define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF |
106 | SCTP_GET_PEER_ADDRS_NUM, /* Get number of peer addresss. */ | 106 | SCTP_GET_PEER_ADDRS_NUM_OLD, /* Get number of peer addresss. */ |
107 | #define SCTP_GET_PEER_ADDRS_NUM SCTP_GET_PEER_ADDRS_NUM | 107 | #define SCTP_GET_PEER_ADDRS_NUM_OLD SCTP_GET_PEER_ADDRS_NUM_OLD |
108 | SCTP_GET_PEER_ADDRS_OLD, /* Get all peer addresss. */ | ||
109 | #define SCTP_GET_PEER_ADDRS_OLD SCTP_GET_PEER_ADDRS_OLD | ||
110 | SCTP_GET_LOCAL_ADDRS_NUM_OLD, /* Get number of local addresss. */ | ||
111 | #define SCTP_GET_LOCAL_ADDRS_NUM_OLD SCTP_GET_LOCAL_ADDRS_NUM_OLD | ||
112 | SCTP_GET_LOCAL_ADDRS_OLD, /* Get all local addresss. */ | ||
113 | #define SCTP_GET_LOCAL_ADDRS_OLD SCTP_GET_LOCAL_ADDRS_OLD | ||
114 | SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */ | ||
115 | #define SCTP_SOCKOPT_CONNECTX SCTP_SOCKOPT_CONNECTX | ||
108 | SCTP_GET_PEER_ADDRS, /* Get all peer addresss. */ | 116 | SCTP_GET_PEER_ADDRS, /* Get all peer addresss. */ |
109 | #define SCTP_GET_PEER_ADDRS SCTP_GET_PEER_ADDRS | 117 | #define SCTP_GET_PEER_ADDRS SCTP_GET_PEER_ADDRS |
110 | SCTP_GET_LOCAL_ADDRS_NUM, /* Get number of local addresss. */ | ||
111 | #define SCTP_GET_LOCAL_ADDRS_NUM SCTP_GET_LOCAL_ADDRS_NUM | ||
112 | SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */ | 118 | SCTP_GET_LOCAL_ADDRS, /* Get all local addresss. */ |
113 | #define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS | 119 | #define SCTP_GET_LOCAL_ADDRS SCTP_GET_LOCAL_ADDRS |
114 | SCTP_SOCKOPT_CONNECTX, /* CONNECTX requests. */ | ||
115 | #define SCTP_SOCKOPT_CONNECTX SCTP_SOCKOPT_CONNECTX | ||
116 | }; | 120 | }; |
117 | 121 | ||
118 | /* | 122 | /* |
@@ -167,10 +171,10 @@ struct sctp_sndrcvinfo { | |||
167 | */ | 171 | */ |
168 | 172 | ||
169 | enum sctp_sinfo_flags { | 173 | enum sctp_sinfo_flags { |
170 | MSG_UNORDERED = 1, /* Send/receive message unordered. */ | 174 | SCTP_UNORDERED = 1, /* Send/receive message unordered. */ |
171 | MSG_ADDR_OVER = 2, /* Override the primary destination. */ | 175 | SCTP_ADDR_OVER = 2, /* Override the primary destination. */ |
172 | MSG_ABORT=4, /* Send an ABORT message to the peer. */ | 176 | SCTP_ABORT=4, /* Send an ABORT message to the peer. */ |
173 | /* MSG_EOF is already defined per socket.h */ | 177 | SCTP_EOF=MSG_FIN, /* Initiate graceful shutdown process. */ |
174 | }; | 178 | }; |
175 | 179 | ||
176 | 180 | ||
@@ -239,7 +243,7 @@ struct sctp_paddr_change { | |||
239 | int spc_state; | 243 | int spc_state; |
240 | int spc_error; | 244 | int spc_error; |
241 | sctp_assoc_t spc_assoc_id; | 245 | sctp_assoc_t spc_assoc_id; |
242 | }; | 246 | } __attribute__((packed, aligned(4))); |
243 | 247 | ||
244 | /* | 248 | /* |
245 | * spc_state: 32 bits (signed integer) | 249 | * spc_state: 32 bits (signed integer) |
@@ -464,7 +468,7 @@ struct sctp_assocparams { | |||
464 | struct sctp_setpeerprim { | 468 | struct sctp_setpeerprim { |
465 | sctp_assoc_t sspp_assoc_id; | 469 | sctp_assoc_t sspp_assoc_id; |
466 | struct sockaddr_storage sspp_addr; | 470 | struct sockaddr_storage sspp_addr; |
467 | }; | 471 | } __attribute__((packed, aligned(4))); |
468 | 472 | ||
469 | /* | 473 | /* |
470 | * 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR) | 474 | * 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR) |
@@ -477,7 +481,7 @@ struct sctp_setpeerprim { | |||
477 | struct sctp_prim { | 481 | struct sctp_prim { |
478 | sctp_assoc_t ssp_assoc_id; | 482 | sctp_assoc_t ssp_assoc_id; |
479 | struct sockaddr_storage ssp_addr; | 483 | struct sockaddr_storage ssp_addr; |
480 | }; | 484 | } __attribute__((packed, aligned(4))); |
481 | 485 | ||
482 | /* | 486 | /* |
483 | * 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER) | 487 | * 7.1.11 Set Adaption Layer Indicator (SCTP_ADAPTION_LAYER) |
@@ -504,7 +508,7 @@ struct sctp_paddrparams { | |||
504 | struct sockaddr_storage spp_address; | 508 | struct sockaddr_storage spp_address; |
505 | __u32 spp_hbinterval; | 509 | __u32 spp_hbinterval; |
506 | __u16 spp_pathmaxrxt; | 510 | __u16 spp_pathmaxrxt; |
507 | }; | 511 | } __attribute__((packed, aligned(4))); |
508 | 512 | ||
509 | /* | 513 | /* |
510 | * 7.2.2 Peer Address Information | 514 | * 7.2.2 Peer Address Information |
@@ -523,7 +527,7 @@ struct sctp_paddrinfo { | |||
523 | __u32 spinfo_srtt; | 527 | __u32 spinfo_srtt; |
524 | __u32 spinfo_rto; | 528 | __u32 spinfo_rto; |
525 | __u32 spinfo_mtu; | 529 | __u32 spinfo_mtu; |
526 | }; | 530 | } __attribute__((packed, aligned(4))); |
527 | 531 | ||
528 | /* Peer addresses's state. */ | 532 | /* Peer addresses's state. */ |
529 | enum sctp_spinfo_state { | 533 | enum sctp_spinfo_state { |
@@ -559,11 +563,16 @@ struct sctp_status { | |||
559 | * SCTP_GET_LOCAL_ADDRS socket options used internally to implement | 563 | * SCTP_GET_LOCAL_ADDRS socket options used internally to implement |
560 | * sctp_getpaddrs() and sctp_getladdrs() API. | 564 | * sctp_getpaddrs() and sctp_getladdrs() API. |
561 | */ | 565 | */ |
562 | struct sctp_getaddrs { | 566 | struct sctp_getaddrs_old { |
563 | sctp_assoc_t assoc_id; | 567 | sctp_assoc_t assoc_id; |
564 | int addr_num; | 568 | int addr_num; |
565 | struct sockaddr __user *addrs; | 569 | struct sockaddr __user *addrs; |
566 | }; | 570 | }; |
571 | struct sctp_getaddrs { | ||
572 | sctp_assoc_t assoc_id; /*input*/ | ||
573 | __u32 addr_num; /*output*/ | ||
574 | __u8 addrs[0]; /*output, variable size*/ | ||
575 | }; | ||
567 | 576 | ||
568 | /* These are bit fields for msghdr->msg_flags. See section 5.1. */ | 577 | /* These are bit fields for msghdr->msg_flags. See section 5.1. */ |
569 | /* On user space Linux, these live in <bits/socket.h> as an enum. */ | 578 | /* On user space Linux, these live in <bits/socket.h> as an enum. */ |
diff --git a/include/net/sock.h b/include/net/sock.h index 8c48fbecb7cf..982b4ecd187b 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
@@ -99,6 +99,7 @@ struct proto; | |||
99 | * @skc_node: main hash linkage for various protocol lookup tables | 99 | * @skc_node: main hash linkage for various protocol lookup tables |
100 | * @skc_bind_node: bind hash linkage for various protocol lookup tables | 100 | * @skc_bind_node: bind hash linkage for various protocol lookup tables |
101 | * @skc_refcnt: reference count | 101 | * @skc_refcnt: reference count |
102 | * @skc_hash: hash value used with various protocol lookup tables | ||
102 | * @skc_prot: protocol handlers inside a network family | 103 | * @skc_prot: protocol handlers inside a network family |
103 | * | 104 | * |
104 | * This is the minimal network layer representation of sockets, the header | 105 | * This is the minimal network layer representation of sockets, the header |
@@ -112,6 +113,7 @@ struct sock_common { | |||
112 | struct hlist_node skc_node; | 113 | struct hlist_node skc_node; |
113 | struct hlist_node skc_bind_node; | 114 | struct hlist_node skc_bind_node; |
114 | atomic_t skc_refcnt; | 115 | atomic_t skc_refcnt; |
116 | unsigned int skc_hash; | ||
115 | struct proto *skc_prot; | 117 | struct proto *skc_prot; |
116 | }; | 118 | }; |
117 | 119 | ||
@@ -139,7 +141,6 @@ struct sock_common { | |||
139 | * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets | 141 | * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets |
140 | * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) | 142 | * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) |
141 | * @sk_lingertime: %SO_LINGER l_linger setting | 143 | * @sk_lingertime: %SO_LINGER l_linger setting |
142 | * @sk_hashent: hash entry in several tables (e.g. inet_hashinfo.ehash) | ||
143 | * @sk_backlog: always used with the per-socket spinlock held | 144 | * @sk_backlog: always used with the per-socket spinlock held |
144 | * @sk_callback_lock: used with the callbacks in the end of this struct | 145 | * @sk_callback_lock: used with the callbacks in the end of this struct |
145 | * @sk_error_queue: rarely used | 146 | * @sk_error_queue: rarely used |
@@ -186,6 +187,7 @@ struct sock { | |||
186 | #define sk_node __sk_common.skc_node | 187 | #define sk_node __sk_common.skc_node |
187 | #define sk_bind_node __sk_common.skc_bind_node | 188 | #define sk_bind_node __sk_common.skc_bind_node |
188 | #define sk_refcnt __sk_common.skc_refcnt | 189 | #define sk_refcnt __sk_common.skc_refcnt |
190 | #define sk_hash __sk_common.skc_hash | ||
189 | #define sk_prot __sk_common.skc_prot | 191 | #define sk_prot __sk_common.skc_prot |
190 | unsigned char sk_shutdown : 2, | 192 | unsigned char sk_shutdown : 2, |
191 | sk_no_check : 2, | 193 | sk_no_check : 2, |
@@ -205,10 +207,9 @@ struct sock { | |||
205 | struct sk_buff_head sk_write_queue; | 207 | struct sk_buff_head sk_write_queue; |
206 | int sk_wmem_queued; | 208 | int sk_wmem_queued; |
207 | int sk_forward_alloc; | 209 | int sk_forward_alloc; |
208 | unsigned int sk_allocation; | 210 | gfp_t sk_allocation; |
209 | int sk_sndbuf; | 211 | int sk_sndbuf; |
210 | int sk_route_caps; | 212 | int sk_route_caps; |
211 | int sk_hashent; | ||
212 | unsigned long sk_flags; | 213 | unsigned long sk_flags; |
213 | unsigned long sk_lingertime; | 214 | unsigned long sk_lingertime; |
214 | /* | 215 | /* |
@@ -460,16 +461,16 @@ static inline void sk_stream_free_skb(struct sock *sk, struct sk_buff *skb) | |||
460 | } | 461 | } |
461 | 462 | ||
462 | /* The per-socket spinlock must be held here. */ | 463 | /* The per-socket spinlock must be held here. */ |
463 | #define sk_add_backlog(__sk, __skb) \ | 464 | static inline void sk_add_backlog(struct sock *sk, struct sk_buff *skb) |
464 | do { if (!(__sk)->sk_backlog.tail) { \ | 465 | { |
465 | (__sk)->sk_backlog.head = \ | 466 | if (!sk->sk_backlog.tail) { |
466 | (__sk)->sk_backlog.tail = (__skb); \ | 467 | sk->sk_backlog.head = sk->sk_backlog.tail = skb; |
467 | } else { \ | 468 | } else { |
468 | ((__sk)->sk_backlog.tail)->next = (__skb); \ | 469 | sk->sk_backlog.tail->next = skb; |
469 | (__sk)->sk_backlog.tail = (__skb); \ | 470 | sk->sk_backlog.tail = skb; |
470 | } \ | 471 | } |
471 | (__skb)->next = NULL; \ | 472 | skb->next = NULL; |
472 | } while(0) | 473 | } |
473 | 474 | ||
474 | #define sk_wait_event(__sk, __timeo, __condition) \ | 475 | #define sk_wait_event(__sk, __timeo, __condition) \ |
475 | ({ int rc; \ | 476 | ({ int rc; \ |
@@ -738,18 +739,18 @@ extern void FASTCALL(release_sock(struct sock *sk)); | |||
738 | #define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock)) | 739 | #define bh_unlock_sock(__sk) spin_unlock(&((__sk)->sk_lock.slock)) |
739 | 740 | ||
740 | extern struct sock *sk_alloc(int family, | 741 | extern struct sock *sk_alloc(int family, |
741 | unsigned int __nocast priority, | 742 | gfp_t priority, |
742 | struct proto *prot, int zero_it); | 743 | struct proto *prot, int zero_it); |
743 | extern void sk_free(struct sock *sk); | 744 | extern void sk_free(struct sock *sk); |
744 | extern struct sock *sk_clone(const struct sock *sk, | 745 | extern struct sock *sk_clone(const struct sock *sk, |
745 | const unsigned int __nocast priority); | 746 | const gfp_t priority); |
746 | 747 | ||
747 | extern struct sk_buff *sock_wmalloc(struct sock *sk, | 748 | extern struct sk_buff *sock_wmalloc(struct sock *sk, |
748 | unsigned long size, int force, | 749 | unsigned long size, int force, |
749 | unsigned int __nocast priority); | 750 | gfp_t priority); |
750 | extern struct sk_buff *sock_rmalloc(struct sock *sk, | 751 | extern struct sk_buff *sock_rmalloc(struct sock *sk, |
751 | unsigned long size, int force, | 752 | unsigned long size, int force, |
752 | unsigned int __nocast priority); | 753 | gfp_t priority); |
753 | extern void sock_wfree(struct sk_buff *skb); | 754 | extern void sock_wfree(struct sk_buff *skb); |
754 | extern void sock_rfree(struct sk_buff *skb); | 755 | extern void sock_rfree(struct sk_buff *skb); |
755 | 756 | ||
@@ -765,7 +766,7 @@ extern struct sk_buff *sock_alloc_send_skb(struct sock *sk, | |||
765 | int noblock, | 766 | int noblock, |
766 | int *errcode); | 767 | int *errcode); |
767 | extern void *sock_kmalloc(struct sock *sk, int size, | 768 | extern void *sock_kmalloc(struct sock *sk, int size, |
768 | unsigned int __nocast priority); | 769 | gfp_t priority); |
769 | extern void sock_kfree_s(struct sock *sk, void *mem, int size); | 770 | extern void sock_kfree_s(struct sock *sk, void *mem, int size); |
770 | extern void sk_send_sigurg(struct sock *sk); | 771 | extern void sk_send_sigurg(struct sock *sk); |
771 | 772 | ||
@@ -1200,7 +1201,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk) | |||
1200 | 1201 | ||
1201 | static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, | 1202 | static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, |
1202 | int size, int mem, | 1203 | int size, int mem, |
1203 | unsigned int __nocast gfp) | 1204 | gfp_t gfp) |
1204 | { | 1205 | { |
1205 | struct sk_buff *skb; | 1206 | struct sk_buff *skb; |
1206 | int hdr_len; | 1207 | int hdr_len; |
@@ -1223,7 +1224,7 @@ static inline struct sk_buff *sk_stream_alloc_pskb(struct sock *sk, | |||
1223 | 1224 | ||
1224 | static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk, | 1225 | static inline struct sk_buff *sk_stream_alloc_skb(struct sock *sk, |
1225 | int size, | 1226 | int size, |
1226 | unsigned int __nocast gfp) | 1227 | gfp_t gfp) |
1227 | { | 1228 | { |
1228 | return sk_stream_alloc_pskb(sk, size, 0, gfp); | 1229 | return sk_stream_alloc_pskb(sk, size, 0, gfp); |
1229 | } | 1230 | } |
@@ -1246,6 +1247,12 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk) | |||
1246 | (skb != (struct sk_buff *)&(sk)->sk_write_queue); \ | 1247 | (skb != (struct sk_buff *)&(sk)->sk_write_queue); \ |
1247 | skb = skb->next) | 1248 | skb = skb->next) |
1248 | 1249 | ||
1250 | /*from STCP for fast SACK Process*/ | ||
1251 | #define sk_stream_for_retrans_queue_from(skb, sk) \ | ||
1252 | for (; (skb != (sk)->sk_send_head) && \ | ||
1253 | (skb != (struct sk_buff *)&(sk)->sk_write_queue); \ | ||
1254 | skb = skb->next) | ||
1255 | |||
1249 | /* | 1256 | /* |
1250 | * Default write policy as shown to user space via poll/select/SIGIO | 1257 | * Default write policy as shown to user space via poll/select/SIGIO |
1251 | */ | 1258 | */ |
@@ -1254,7 +1261,7 @@ static inline int sock_writeable(const struct sock *sk) | |||
1254 | return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2); | 1261 | return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf / 2); |
1255 | } | 1262 | } |
1256 | 1263 | ||
1257 | static inline unsigned int __nocast gfp_any(void) | 1264 | static inline gfp_t gfp_any(void) |
1258 | { | 1265 | { |
1259 | return in_softirq() ? GFP_ATOMIC : GFP_KERNEL; | 1266 | return in_softirq() ? GFP_ATOMIC : GFP_KERNEL; |
1260 | } | 1267 | } |
diff --git a/include/net/syncppp.h b/include/net/syncppp.h index 614cb6ba564e..877efa434700 100644 --- a/include/net/syncppp.h +++ b/include/net/syncppp.h | |||
@@ -86,7 +86,6 @@ static inline struct sppp *sppp_of(struct net_device *dev) | |||
86 | 86 | ||
87 | void sppp_attach (struct ppp_device *pd); | 87 | void sppp_attach (struct ppp_device *pd); |
88 | void sppp_detach (struct net_device *dev); | 88 | void sppp_detach (struct net_device *dev); |
89 | void sppp_input (struct net_device *dev, struct sk_buff *m); | ||
90 | int sppp_do_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd); | 89 | int sppp_do_ioctl (struct net_device *dev, struct ifreq *ifr, int cmd); |
91 | struct sk_buff *sppp_dequeue (struct net_device *dev); | 90 | struct sk_buff *sppp_dequeue (struct net_device *dev); |
92 | int sppp_isempty (struct net_device *dev); | 91 | int sppp_isempty (struct net_device *dev); |
diff --git a/include/net/tcp.h b/include/net/tcp.h index 97af77c4d096..d78025f9fbea 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/cache.h> | 28 | #include <linux/cache.h> |
29 | #include <linux/percpu.h> | 29 | #include <linux/percpu.h> |
30 | #include <linux/skbuff.h> | ||
30 | 31 | ||
31 | #include <net/inet_connection_sock.h> | 32 | #include <net/inet_connection_sock.h> |
32 | #include <net/inet_timewait_sock.h> | 33 | #include <net/inet_timewait_sock.h> |
@@ -88,10 +89,10 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
88 | */ | 89 | */ |
89 | 90 | ||
90 | #define TCP_SYN_RETRIES 5 /* number of times to retry active opening a | 91 | #define TCP_SYN_RETRIES 5 /* number of times to retry active opening a |
91 | * connection: ~180sec is RFC minumum */ | 92 | * connection: ~180sec is RFC minimum */ |
92 | 93 | ||
93 | #define TCP_SYNACK_RETRIES 5 /* number of times to retry passive opening a | 94 | #define TCP_SYNACK_RETRIES 5 /* number of times to retry passive opening a |
94 | * connection: ~180sec is RFC minumum */ | 95 | * connection: ~180sec is RFC minimum */ |
95 | 96 | ||
96 | 97 | ||
97 | #define TCP_ORPHAN_RETRIES 7 /* number of times to retry on an orphaned | 98 | #define TCP_ORPHAN_RETRIES 7 /* number of times to retry on an orphaned |
@@ -179,7 +180,7 @@ extern void tcp_time_wait(struct sock *sk, int state, int timeo); | |||
179 | /* Flags in tp->nonagle */ | 180 | /* Flags in tp->nonagle */ |
180 | #define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ | 181 | #define TCP_NAGLE_OFF 1 /* Nagle's algo is disabled */ |
181 | #define TCP_NAGLE_CORK 2 /* Socket is corked */ | 182 | #define TCP_NAGLE_CORK 2 /* Socket is corked */ |
182 | #define TCP_NAGLE_PUSH 4 /* Cork is overriden for already queued data */ | 183 | #define TCP_NAGLE_PUSH 4 /* Cork is overridden for already queued data */ |
183 | 184 | ||
184 | extern struct inet_timewait_death_row tcp_death_row; | 185 | extern struct inet_timewait_death_row tcp_death_row; |
185 | 186 | ||
@@ -217,6 +218,7 @@ extern int sysctl_tcp_low_latency; | |||
217 | extern int sysctl_tcp_nometrics_save; | 218 | extern int sysctl_tcp_nometrics_save; |
218 | extern int sysctl_tcp_moderate_rcvbuf; | 219 | extern int sysctl_tcp_moderate_rcvbuf; |
219 | extern int sysctl_tcp_tso_win_divisor; | 220 | extern int sysctl_tcp_tso_win_divisor; |
221 | extern int sysctl_tcp_abc; | ||
220 | 222 | ||
221 | extern atomic_t tcp_memory_allocated; | 223 | extern atomic_t tcp_memory_allocated; |
222 | extern atomic_t tcp_sockets_allocated; | 224 | extern atomic_t tcp_sockets_allocated; |
@@ -460,8 +462,7 @@ extern void tcp_send_probe0(struct sock *); | |||
460 | extern void tcp_send_partial(struct sock *); | 462 | extern void tcp_send_partial(struct sock *); |
461 | extern int tcp_write_wakeup(struct sock *); | 463 | extern int tcp_write_wakeup(struct sock *); |
462 | extern void tcp_send_fin(struct sock *sk); | 464 | extern void tcp_send_fin(struct sock *sk); |
463 | extern void tcp_send_active_reset(struct sock *sk, | 465 | extern void tcp_send_active_reset(struct sock *sk, gfp_t priority); |
464 | unsigned int __nocast priority); | ||
465 | extern int tcp_send_synack(struct sock *); | 466 | extern int tcp_send_synack(struct sock *); |
466 | extern void tcp_push_one(struct sock *, unsigned int mss_now); | 467 | extern void tcp_push_one(struct sock *, unsigned int mss_now); |
467 | extern void tcp_send_ack(struct sock *sk); | 468 | extern void tcp_send_ack(struct sock *sk); |
@@ -551,13 +552,13 @@ extern u32 __tcp_select_window(struct sock *sk); | |||
551 | 552 | ||
552 | /* TCP timestamps are only 32-bits, this causes a slight | 553 | /* TCP timestamps are only 32-bits, this causes a slight |
553 | * complication on 64-bit systems since we store a snapshot | 554 | * complication on 64-bit systems since we store a snapshot |
554 | * of jiffies in the buffer control blocks below. We decidely | 555 | * of jiffies in the buffer control blocks below. We decided |
555 | * only use of the low 32-bits of jiffies and hide the ugly | 556 | * to use only the low 32-bits of jiffies and hide the ugly |
556 | * casts with the following macro. | 557 | * casts with the following macro. |
557 | */ | 558 | */ |
558 | #define tcp_time_stamp ((__u32)(jiffies)) | 559 | #define tcp_time_stamp ((__u32)(jiffies)) |
559 | 560 | ||
560 | /* This is what the send packet queueing engine uses to pass | 561 | /* This is what the send packet queuing engine uses to pass |
561 | * TCP per-packet control information to the transmission | 562 | * TCP per-packet control information to the transmission |
562 | * code. We also store the host-order sequence numbers in | 563 | * code. We also store the host-order sequence numbers in |
563 | * here too. This is 36 bytes on 32-bit architectures, | 564 | * here too. This is 36 bytes on 32-bit architectures, |
@@ -597,7 +598,7 @@ struct tcp_skb_cb { | |||
597 | #define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */ | 598 | #define TCPCB_EVER_RETRANS 0x80 /* Ever retransmitted frame */ |
598 | #define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS) | 599 | #define TCPCB_RETRANS (TCPCB_SACKED_RETRANS|TCPCB_EVER_RETRANS) |
599 | 600 | ||
600 | #define TCPCB_URG 0x20 /* Urgent pointer advenced here */ | 601 | #define TCPCB_URG 0x20 /* Urgent pointer advanced here */ |
601 | 602 | ||
602 | #define TCPCB_AT_TAIL (TCPCB_URG) | 603 | #define TCPCB_AT_TAIL (TCPCB_URG) |
603 | 604 | ||
@@ -765,6 +766,33 @@ static inline __u32 tcp_current_ssthresh(const struct sock *sk) | |||
765 | (tp->snd_cwnd >> 2))); | 766 | (tp->snd_cwnd >> 2))); |
766 | } | 767 | } |
767 | 768 | ||
769 | /* | ||
770 | * Linear increase during slow start | ||
771 | */ | ||
772 | static inline void tcp_slow_start(struct tcp_sock *tp) | ||
773 | { | ||
774 | if (sysctl_tcp_abc) { | ||
775 | /* RFC3465: Slow Start | ||
776 | * TCP sender SHOULD increase cwnd by the number of | ||
777 | * previously unacknowledged bytes ACKed by each incoming | ||
778 | * acknowledgment, provided the increase is not more than L | ||
779 | */ | ||
780 | if (tp->bytes_acked < tp->mss_cache) | ||
781 | return; | ||
782 | |||
783 | /* We MAY increase by 2 if discovered delayed ack */ | ||
784 | if (sysctl_tcp_abc > 1 && tp->bytes_acked > 2*tp->mss_cache) { | ||
785 | if (tp->snd_cwnd < tp->snd_cwnd_clamp) | ||
786 | tp->snd_cwnd++; | ||
787 | } | ||
788 | } | ||
789 | tp->bytes_acked = 0; | ||
790 | |||
791 | if (tp->snd_cwnd < tp->snd_cwnd_clamp) | ||
792 | tp->snd_cwnd++; | ||
793 | } | ||
794 | |||
795 | |||
768 | static inline void tcp_sync_left_out(struct tcp_sock *tp) | 796 | static inline void tcp_sync_left_out(struct tcp_sock *tp) |
769 | { | 797 | { |
770 | if (tp->rx_opt.sack_ok && | 798 | if (tp->rx_opt.sack_ok && |
@@ -794,6 +822,7 @@ static inline void tcp_enter_cwr(struct sock *sk) | |||
794 | struct tcp_sock *tp = tcp_sk(sk); | 822 | struct tcp_sock *tp = tcp_sk(sk); |
795 | 823 | ||
796 | tp->prior_ssthresh = 0; | 824 | tp->prior_ssthresh = 0; |
825 | tp->bytes_acked = 0; | ||
797 | if (inet_csk(sk)->icsk_ca_state < TCP_CA_CWR) { | 826 | if (inet_csk(sk)->icsk_ca_state < TCP_CA_CWR) { |
798 | __tcp_enter_cwr(sk); | 827 | __tcp_enter_cwr(sk); |
799 | tcp_set_ca_state(sk, TCP_CA_CWR); | 828 | tcp_set_ca_state(sk, TCP_CA_CWR); |
@@ -810,6 +839,27 @@ static __inline__ __u32 tcp_max_burst(const struct tcp_sock *tp) | |||
810 | return 3; | 839 | return 3; |
811 | } | 840 | } |
812 | 841 | ||
842 | /* RFC2861 Check whether we are limited by application or congestion window | ||
843 | * This is the inverse of cwnd check in tcp_tso_should_defer | ||
844 | */ | ||
845 | static inline int tcp_is_cwnd_limited(const struct sock *sk, u32 in_flight) | ||
846 | { | ||
847 | const struct tcp_sock *tp = tcp_sk(sk); | ||
848 | u32 left; | ||
849 | |||
850 | if (in_flight >= tp->snd_cwnd) | ||
851 | return 1; | ||
852 | |||
853 | if (!(sk->sk_route_caps & NETIF_F_TSO)) | ||
854 | return 0; | ||
855 | |||
856 | left = tp->snd_cwnd - in_flight; | ||
857 | if (sysctl_tcp_tso_win_divisor) | ||
858 | return left * sysctl_tcp_tso_win_divisor < tp->snd_cwnd; | ||
859 | else | ||
860 | return left <= tcp_max_burst(tp); | ||
861 | } | ||
862 | |||
813 | static __inline__ void tcp_minshall_update(struct tcp_sock *tp, int mss, | 863 | static __inline__ void tcp_minshall_update(struct tcp_sock *tp, int mss, |
814 | const struct sk_buff *skb) | 864 | const struct sk_buff *skb) |
815 | { | 865 | { |
@@ -853,7 +903,7 @@ static __inline__ u16 tcp_v4_check(struct tcphdr *th, int len, | |||
853 | 903 | ||
854 | static __inline__ int __tcp_checksum_complete(struct sk_buff *skb) | 904 | static __inline__ int __tcp_checksum_complete(struct sk_buff *skb) |
855 | { | 905 | { |
856 | return (unsigned short)csum_fold(skb_checksum(skb, 0, skb->len, skb->csum)); | 906 | return __skb_checksum_complete(skb); |
857 | } | 907 | } |
858 | 908 | ||
859 | static __inline__ int tcp_checksum_complete(struct sk_buff *skb) | 909 | static __inline__ int tcp_checksum_complete(struct sk_buff *skb) |
@@ -1157,6 +1207,15 @@ static inline void tcp_mib_init(void) | |||
1157 | TCP_ADD_STATS_USER(TCP_MIB_MAXCONN, -1); | 1207 | TCP_ADD_STATS_USER(TCP_MIB_MAXCONN, -1); |
1158 | } | 1208 | } |
1159 | 1209 | ||
1210 | /*from STCP */ | ||
1211 | static inline void clear_all_retrans_hints(struct tcp_sock *tp){ | ||
1212 | tp->lost_skb_hint = NULL; | ||
1213 | tp->scoreboard_skb_hint = NULL; | ||
1214 | tp->retransmit_skb_hint = NULL; | ||
1215 | tp->forward_skb_hint = NULL; | ||
1216 | tp->fastpath_skb_hint = NULL; | ||
1217 | } | ||
1218 | |||
1160 | /* /proc */ | 1219 | /* /proc */ |
1161 | enum tcp_seq_states { | 1220 | enum tcp_seq_states { |
1162 | TCP_SEQ_STATE_LISTENING, | 1221 | TCP_SEQ_STATE_LISTENING, |
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index a9d0d8c5dfbf..5beae1ccd574 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -875,7 +875,7 @@ static inline int xfrm_dst_lookup(struct xfrm_dst **dst, struct flowi *fl, unsig | |||
875 | } | 875 | } |
876 | #endif | 876 | #endif |
877 | 877 | ||
878 | struct xfrm_policy *xfrm_policy_alloc(int gfp); | 878 | struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp); |
879 | extern int xfrm_policy_walk(int (*func)(struct xfrm_policy *, int, int, void*), void *); | 879 | extern int xfrm_policy_walk(int (*func)(struct xfrm_policy *, int, int, void*), void *); |
880 | int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); | 880 | int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); |
881 | struct xfrm_policy *xfrm_policy_bysel(int dir, struct xfrm_selector *sel, | 881 | struct xfrm_policy *xfrm_policy_bysel(int dir, struct xfrm_selector *sel, |
@@ -931,4 +931,9 @@ static inline int xfrm_addr_cmp(xfrm_address_t *a, xfrm_address_t *b, | |||
931 | } | 931 | } |
932 | } | 932 | } |
933 | 933 | ||
934 | static inline int xfrm_policy_id2dir(u32 index) | ||
935 | { | ||
936 | return index & 7; | ||
937 | } | ||
938 | |||
934 | #endif /* _NET_XFRM_H */ | 939 | #endif /* _NET_XFRM_H */ |