diff options
author | Ingo Molnar <mingo@elte.hu> | 2008-09-14 12:24:00 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-14 12:24:00 -0400 |
commit | 83bd6998b04fc1bb7280b14f16b2bdbdc07c914b (patch) | |
tree | af1bbe2bac5752b69b1ac58bf5d822c735da439b /net | |
parent | e7250b8ae3870f37f660c2f65cafcaba85e3bfd3 (diff) | |
parent | adee14b2e1557d0a8559f29681732d05a89dfc35 (diff) |
Merge commit 'v2.6.27-rc6' into timers/hpet
Diffstat (limited to 'net')
158 files changed, 2323 insertions, 1605 deletions
diff --git a/net/Kconfig b/net/Kconfig index b98668751749..7612cc8c337c 100644 --- a/net/Kconfig +++ b/net/Kconfig | |||
@@ -2,9 +2,7 @@ | |||
2 | # Network configuration | 2 | # Network configuration |
3 | # | 3 | # |
4 | 4 | ||
5 | menu "Networking" | 5 | menuconfig NET |
6 | |||
7 | config NET | ||
8 | bool "Networking support" | 6 | bool "Networking support" |
9 | ---help--- | 7 | ---help--- |
10 | Unless you really know what you are doing, you should say Y here. | 8 | Unless you really know what you are doing, you should say Y here. |
@@ -22,7 +20,6 @@ config NET | |||
22 | recommended to read the NET-HOWTO, available from | 20 | recommended to read the NET-HOWTO, available from |
23 | <http://www.tldp.org/docs.html#howto>. | 21 | <http://www.tldp.org/docs.html#howto>. |
24 | 22 | ||
25 | # Make sure that all config symbols are dependent on NET | ||
26 | if NET | 23 | if NET |
27 | 24 | ||
28 | menu "Networking options" | 25 | menu "Networking options" |
@@ -252,5 +249,3 @@ source "net/rfkill/Kconfig" | |||
252 | source "net/9p/Kconfig" | 249 | source "net/9p/Kconfig" |
253 | 250 | ||
254 | endif # if NET | 251 | endif # if NET |
255 | endmenu # Networking | ||
256 | |||
diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 4fccaa1e07be..11b16d16661c 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c | |||
@@ -62,11 +62,13 @@ static void MPOA_cache_impos_rcvd(struct k_message *msg, struct mpoa_client *mpc | |||
62 | static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc); | 62 | static void set_mpc_ctrl_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc); |
63 | static void set_mps_mac_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc); | 63 | static void set_mps_mac_addr_rcvd(struct k_message *mesg, struct mpoa_client *mpc); |
64 | 64 | ||
65 | static uint8_t *copy_macs(struct mpoa_client *mpc, uint8_t *router_mac, | 65 | static const uint8_t *copy_macs(struct mpoa_client *mpc, |
66 | uint8_t *tlvs, uint8_t mps_macs, uint8_t device_type); | 66 | const uint8_t *router_mac, |
67 | const uint8_t *tlvs, uint8_t mps_macs, | ||
68 | uint8_t device_type); | ||
67 | static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry); | 69 | static void purge_egress_shortcut(struct atm_vcc *vcc, eg_cache_entry *entry); |
68 | 70 | ||
69 | static void send_set_mps_ctrl_addr(char *addr, struct mpoa_client *mpc); | 71 | static void send_set_mps_ctrl_addr(const char *addr, struct mpoa_client *mpc); |
70 | static void mpoad_close(struct atm_vcc *vcc); | 72 | static void mpoad_close(struct atm_vcc *vcc); |
71 | static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb); | 73 | static int msg_from_mpoad(struct atm_vcc *vcc, struct sk_buff *skb); |
72 | 74 | ||
@@ -351,12 +353,12 @@ static const char *mpoa_device_type_string(char type) | |||
351 | * lec sees a TLV it uses the pointer to call this function. | 353 | * lec sees a TLV it uses the pointer to call this function. |
352 | * | 354 | * |
353 | */ | 355 | */ |
354 | static void lane2_assoc_ind(struct net_device *dev, uint8_t *mac_addr, | 356 | static void lane2_assoc_ind(struct net_device *dev, const u8 *mac_addr, |
355 | uint8_t *tlvs, uint32_t sizeoftlvs) | 357 | const u8 *tlvs, u32 sizeoftlvs) |
356 | { | 358 | { |
357 | uint32_t type; | 359 | uint32_t type; |
358 | uint8_t length, mpoa_device_type, number_of_mps_macs; | 360 | uint8_t length, mpoa_device_type, number_of_mps_macs; |
359 | uint8_t *end_of_tlvs; | 361 | const uint8_t *end_of_tlvs; |
360 | struct mpoa_client *mpc; | 362 | struct mpoa_client *mpc; |
361 | 363 | ||
362 | mpoa_device_type = number_of_mps_macs = 0; /* silence gcc */ | 364 | mpoa_device_type = number_of_mps_macs = 0; /* silence gcc */ |
@@ -430,8 +432,10 @@ static void lane2_assoc_ind(struct net_device *dev, uint8_t *mac_addr, | |||
430 | * plus the possible MAC address(es) to mpc->mps_macs. | 432 | * plus the possible MAC address(es) to mpc->mps_macs. |
431 | * For a freshly allocated MPOA client mpc->mps_macs == 0. | 433 | * For a freshly allocated MPOA client mpc->mps_macs == 0. |
432 | */ | 434 | */ |
433 | static uint8_t *copy_macs(struct mpoa_client *mpc, uint8_t *router_mac, | 435 | static const uint8_t *copy_macs(struct mpoa_client *mpc, |
434 | uint8_t *tlvs, uint8_t mps_macs, uint8_t device_type) | 436 | const uint8_t *router_mac, |
437 | const uint8_t *tlvs, uint8_t mps_macs, | ||
438 | uint8_t device_type) | ||
435 | { | 439 | { |
436 | int num_macs; | 440 | int num_macs; |
437 | num_macs = (mps_macs > 1) ? mps_macs : 1; | 441 | num_macs = (mps_macs > 1) ? mps_macs : 1; |
@@ -811,7 +815,7 @@ static int atm_mpoa_mpoad_attach (struct atm_vcc *vcc, int arg) | |||
811 | return arg; | 815 | return arg; |
812 | } | 816 | } |
813 | 817 | ||
814 | static void send_set_mps_ctrl_addr(char *addr, struct mpoa_client *mpc) | 818 | static void send_set_mps_ctrl_addr(const char *addr, struct mpoa_client *mpc) |
815 | { | 819 | { |
816 | struct k_message mesg; | 820 | struct k_message mesg; |
817 | 821 | ||
diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c index f597987b2424..f288fc4aef9b 100644 --- a/net/ax25/sysctl_net_ax25.c +++ b/net/ax25/sysctl_net_ax25.c | |||
@@ -36,6 +36,7 @@ static struct ctl_path ax25_path[] = { | |||
36 | { .procname = "ax25", .ctl_name = NET_AX25, }, | 36 | { .procname = "ax25", .ctl_name = NET_AX25, }, |
37 | { } | 37 | { } |
38 | }; | 38 | }; |
39 | |||
39 | static const ctl_table ax25_param_table[] = { | 40 | static const ctl_table ax25_param_table[] = { |
40 | { | 41 | { |
41 | .ctl_name = NET_AX25_IP_DEFAULT_MODE, | 42 | .ctl_name = NET_AX25_IP_DEFAULT_MODE, |
@@ -167,6 +168,7 @@ static const ctl_table ax25_param_table[] = { | |||
167 | .extra1 = &min_proto, | 168 | .extra1 = &min_proto, |
168 | .extra2 = &max_proto | 169 | .extra2 = &max_proto |
169 | }, | 170 | }, |
171 | #ifdef CONFIG_AX25_DAMA_SLAVE | ||
170 | { | 172 | { |
171 | .ctl_name = NET_AX25_DAMA_SLAVE_TIMEOUT, | 173 | .ctl_name = NET_AX25_DAMA_SLAVE_TIMEOUT, |
172 | .procname = "dama_slave_timeout", | 174 | .procname = "dama_slave_timeout", |
@@ -177,6 +179,8 @@ static const ctl_table ax25_param_table[] = { | |||
177 | .extra1 = &min_ds_timeout, | 179 | .extra1 = &min_ds_timeout, |
178 | .extra2 = &max_ds_timeout | 180 | .extra2 = &max_ds_timeout |
179 | }, | 181 | }, |
182 | #endif | ||
183 | |||
180 | { .ctl_name = 0 } /* that's all, folks! */ | 184 | { .ctl_name = 0 } /* that's all, folks! */ |
181 | }; | 185 | }; |
182 | 186 | ||
@@ -210,16 +214,6 @@ void ax25_register_sysctl(void) | |||
210 | ax25_table[n].procname = ax25_dev->dev->name; | 214 | ax25_table[n].procname = ax25_dev->dev->name; |
211 | ax25_table[n].mode = 0555; | 215 | ax25_table[n].mode = 0555; |
212 | 216 | ||
213 | #ifndef CONFIG_AX25_DAMA_SLAVE | ||
214 | /* | ||
215 | * We do not wish to have a representation of this parameter | ||
216 | * in /proc/sys/ when configured *not* to include the | ||
217 | * AX.25 DAMA slave code, do we? | ||
218 | */ | ||
219 | |||
220 | child[AX25_VALUES_DS_TIMEOUT].procname = NULL; | ||
221 | #endif | ||
222 | |||
223 | child[AX25_MAX_VALUES].ctl_name = 0; /* just in case... */ | 217 | child[AX25_MAX_VALUES].ctl_name = 0; /* just in case... */ |
224 | 218 | ||
225 | for (k = 0; k < AX25_MAX_VALUES; k++) | 219 | for (k = 0; k < AX25_MAX_VALUES; k++) |
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 4e59df5f8e05..f6348e078aa4 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -49,7 +49,7 @@ | |||
49 | #define BT_DBG(D...) | 49 | #define BT_DBG(D...) |
50 | #endif | 50 | #endif |
51 | 51 | ||
52 | #define VERSION "2.12" | 52 | #define VERSION "2.13" |
53 | 53 | ||
54 | /* Bluetooth sockets */ | 54 | /* Bluetooth sockets */ |
55 | #define BT_MAX_PROTO 8 | 55 | #define BT_MAX_PROTO 8 |
@@ -456,7 +456,7 @@ static void __exit bt_exit(void) | |||
456 | subsys_initcall(bt_init); | 456 | subsys_initcall(bt_init); |
457 | module_exit(bt_exit); | 457 | module_exit(bt_exit); |
458 | 458 | ||
459 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 459 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
460 | MODULE_DESCRIPTION("Bluetooth Core ver " VERSION); | 460 | MODULE_DESCRIPTION("Bluetooth Core ver " VERSION); |
461 | MODULE_VERSION(VERSION); | 461 | MODULE_VERSION(VERSION); |
462 | MODULE_LICENSE("GPL"); | 462 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c index 021172c0e666..80ba30cf4b68 100644 --- a/net/bluetooth/bnep/core.c +++ b/net/bluetooth/bnep/core.c | |||
@@ -57,7 +57,10 @@ | |||
57 | #define BT_DBG(D...) | 57 | #define BT_DBG(D...) |
58 | #endif | 58 | #endif |
59 | 59 | ||
60 | #define VERSION "1.2" | 60 | #define VERSION "1.3" |
61 | |||
62 | static int compress_src = 1; | ||
63 | static int compress_dst = 1; | ||
61 | 64 | ||
62 | static LIST_HEAD(bnep_session_list); | 65 | static LIST_HEAD(bnep_session_list); |
63 | static DECLARE_RWSEM(bnep_session_sem); | 66 | static DECLARE_RWSEM(bnep_session_sem); |
@@ -418,10 +421,10 @@ static inline int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb) | |||
418 | iv[il++] = (struct kvec) { &type, 1 }; | 421 | iv[il++] = (struct kvec) { &type, 1 }; |
419 | len++; | 422 | len++; |
420 | 423 | ||
421 | if (!compare_ether_addr(eh->h_dest, s->eh.h_source)) | 424 | if (compress_src && !compare_ether_addr(eh->h_dest, s->eh.h_source)) |
422 | type |= 0x01; | 425 | type |= 0x01; |
423 | 426 | ||
424 | if (!compare_ether_addr(eh->h_source, s->eh.h_dest)) | 427 | if (compress_dst && !compare_ether_addr(eh->h_source, s->eh.h_dest)) |
425 | type |= 0x02; | 428 | type |= 0x02; |
426 | 429 | ||
427 | if (type) | 430 | if (type) |
@@ -727,7 +730,13 @@ static void __exit bnep_exit(void) | |||
727 | module_init(bnep_init); | 730 | module_init(bnep_init); |
728 | module_exit(bnep_exit); | 731 | module_exit(bnep_exit); |
729 | 732 | ||
730 | MODULE_AUTHOR("David Libault <david.libault@inventel.fr>, Maxim Krasnyansky <maxk@qualcomm.com>"); | 733 | module_param(compress_src, bool, 0644); |
734 | MODULE_PARM_DESC(compress_src, "Compress sources headers"); | ||
735 | |||
736 | module_param(compress_dst, bool, 0644); | ||
737 | MODULE_PARM_DESC(compress_dst, "Compress destination headers"); | ||
738 | |||
739 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); | ||
731 | MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION); | 740 | MODULE_DESCRIPTION("Bluetooth BNEP ver " VERSION); |
732 | MODULE_VERSION(VERSION); | 741 | MODULE_VERSION(VERSION); |
733 | MODULE_LICENSE("GPL"); | 742 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index ca8d05245ca0..b7002429f152 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
@@ -330,7 +330,7 @@ EXPORT_SYMBOL(hci_get_route); | |||
330 | 330 | ||
331 | /* Create SCO or ACL connection. | 331 | /* Create SCO or ACL connection. |
332 | * Device _must_ be locked */ | 332 | * Device _must_ be locked */ |
333 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst) | 333 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 auth_type) |
334 | { | 334 | { |
335 | struct hci_conn *acl; | 335 | struct hci_conn *acl; |
336 | struct hci_conn *sco; | 336 | struct hci_conn *sco; |
@@ -344,8 +344,10 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst) | |||
344 | 344 | ||
345 | hci_conn_hold(acl); | 345 | hci_conn_hold(acl); |
346 | 346 | ||
347 | if (acl->state == BT_OPEN || acl->state == BT_CLOSED) | 347 | if (acl->state == BT_OPEN || acl->state == BT_CLOSED) { |
348 | acl->auth_type = auth_type; | ||
348 | hci_acl_connect(acl); | 349 | hci_acl_connect(acl); |
350 | } | ||
349 | 351 | ||
350 | if (type == ACL_LINK) | 352 | if (type == ACL_LINK) |
351 | return acl; | 353 | return acl; |
@@ -374,6 +376,19 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst) | |||
374 | } | 376 | } |
375 | EXPORT_SYMBOL(hci_connect); | 377 | EXPORT_SYMBOL(hci_connect); |
376 | 378 | ||
379 | /* Check link security requirement */ | ||
380 | int hci_conn_check_link_mode(struct hci_conn *conn) | ||
381 | { | ||
382 | BT_DBG("conn %p", conn); | ||
383 | |||
384 | if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0 && | ||
385 | !(conn->link_mode & HCI_LM_ENCRYPT)) | ||
386 | return 0; | ||
387 | |||
388 | return 1; | ||
389 | } | ||
390 | EXPORT_SYMBOL(hci_conn_check_link_mode); | ||
391 | |||
377 | /* Authenticate remote device */ | 392 | /* Authenticate remote device */ |
378 | int hci_conn_auth(struct hci_conn *conn) | 393 | int hci_conn_auth(struct hci_conn *conn) |
379 | { | 394 | { |
@@ -381,7 +396,7 @@ int hci_conn_auth(struct hci_conn *conn) | |||
381 | 396 | ||
382 | if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0) { | 397 | if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0) { |
383 | if (!(conn->auth_type & 0x01)) { | 398 | if (!(conn->auth_type & 0x01)) { |
384 | conn->auth_type = HCI_AT_GENERAL_BONDING_MITM; | 399 | conn->auth_type |= 0x01; |
385 | conn->link_mode &= ~HCI_LM_AUTH; | 400 | conn->link_mode &= ~HCI_LM_AUTH; |
386 | } | 401 | } |
387 | } | 402 | } |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 0e3db289f4be..ad7a553d7713 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -1605,14 +1605,11 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b | |||
1605 | 1605 | ||
1606 | if (conn->state == BT_CONFIG) { | 1606 | if (conn->state == BT_CONFIG) { |
1607 | if (!ev->status && hdev->ssp_mode > 0 && | 1607 | if (!ev->status && hdev->ssp_mode > 0 && |
1608 | conn->ssp_mode > 0) { | 1608 | conn->ssp_mode > 0 && conn->out) { |
1609 | if (conn->out) { | 1609 | struct hci_cp_auth_requested cp; |
1610 | struct hci_cp_auth_requested cp; | 1610 | cp.handle = ev->handle; |
1611 | cp.handle = ev->handle; | 1611 | hci_send_cmd(hdev, HCI_OP_AUTH_REQUESTED, |
1612 | hci_send_cmd(hdev, | ||
1613 | HCI_OP_AUTH_REQUESTED, | ||
1614 | sizeof(cp), &cp); | 1612 | sizeof(cp), &cp); |
1615 | } | ||
1616 | } else { | 1613 | } else { |
1617 | conn->state = BT_CONNECTED; | 1614 | conn->state = BT_CONNECTED; |
1618 | hci_proto_connect_cfm(conn, ev->status); | 1615 | hci_proto_connect_cfm(conn, ev->status); |
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c index c85bf8f678dc..f4f6615cad9f 100644 --- a/net/bluetooth/hci_sysfs.c +++ b/net/bluetooth/hci_sysfs.c | |||
@@ -3,8 +3,6 @@ | |||
3 | #include <linux/kernel.h> | 3 | #include <linux/kernel.h> |
4 | #include <linux/init.h> | 4 | #include <linux/init.h> |
5 | 5 | ||
6 | #include <linux/platform_device.h> | ||
7 | |||
8 | #include <net/bluetooth/bluetooth.h> | 6 | #include <net/bluetooth/bluetooth.h> |
9 | #include <net/bluetooth/hci_core.h> | 7 | #include <net/bluetooth/hci_core.h> |
10 | 8 | ||
@@ -12,10 +10,164 @@ | |||
12 | #undef BT_DBG | 10 | #undef BT_DBG |
13 | #define BT_DBG(D...) | 11 | #define BT_DBG(D...) |
14 | #endif | 12 | #endif |
13 | |||
14 | struct class *bt_class = NULL; | ||
15 | EXPORT_SYMBOL_GPL(bt_class); | ||
16 | |||
15 | static struct workqueue_struct *btaddconn; | 17 | static struct workqueue_struct *btaddconn; |
16 | static struct workqueue_struct *btdelconn; | 18 | static struct workqueue_struct *btdelconn; |
17 | 19 | ||
18 | static inline char *typetostr(int type) | 20 | static inline char *link_typetostr(int type) |
21 | { | ||
22 | switch (type) { | ||
23 | case ACL_LINK: | ||
24 | return "ACL"; | ||
25 | case SCO_LINK: | ||
26 | return "SCO"; | ||
27 | case ESCO_LINK: | ||
28 | return "eSCO"; | ||
29 | default: | ||
30 | return "UNKNOWN"; | ||
31 | } | ||
32 | } | ||
33 | |||
34 | static ssize_t show_link_type(struct device *dev, struct device_attribute *attr, char *buf) | ||
35 | { | ||
36 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
37 | return sprintf(buf, "%s\n", link_typetostr(conn->type)); | ||
38 | } | ||
39 | |||
40 | static ssize_t show_link_address(struct device *dev, struct device_attribute *attr, char *buf) | ||
41 | { | ||
42 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
43 | bdaddr_t bdaddr; | ||
44 | baswap(&bdaddr, &conn->dst); | ||
45 | return sprintf(buf, "%s\n", batostr(&bdaddr)); | ||
46 | } | ||
47 | |||
48 | static ssize_t show_link_features(struct device *dev, struct device_attribute *attr, char *buf) | ||
49 | { | ||
50 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
51 | |||
52 | return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", | ||
53 | conn->features[0], conn->features[1], | ||
54 | conn->features[2], conn->features[3], | ||
55 | conn->features[4], conn->features[5], | ||
56 | conn->features[6], conn->features[7]); | ||
57 | } | ||
58 | |||
59 | #define LINK_ATTR(_name,_mode,_show,_store) \ | ||
60 | struct device_attribute link_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
61 | |||
62 | static LINK_ATTR(type, S_IRUGO, show_link_type, NULL); | ||
63 | static LINK_ATTR(address, S_IRUGO, show_link_address, NULL); | ||
64 | static LINK_ATTR(features, S_IRUGO, show_link_features, NULL); | ||
65 | |||
66 | static struct attribute *bt_link_attrs[] = { | ||
67 | &link_attr_type.attr, | ||
68 | &link_attr_address.attr, | ||
69 | &link_attr_features.attr, | ||
70 | NULL | ||
71 | }; | ||
72 | |||
73 | static struct attribute_group bt_link_group = { | ||
74 | .attrs = bt_link_attrs, | ||
75 | }; | ||
76 | |||
77 | static struct attribute_group *bt_link_groups[] = { | ||
78 | &bt_link_group, | ||
79 | NULL | ||
80 | }; | ||
81 | |||
82 | static void bt_link_release(struct device *dev) | ||
83 | { | ||
84 | void *data = dev_get_drvdata(dev); | ||
85 | kfree(data); | ||
86 | } | ||
87 | |||
88 | static struct device_type bt_link = { | ||
89 | .name = "link", | ||
90 | .groups = bt_link_groups, | ||
91 | .release = bt_link_release, | ||
92 | }; | ||
93 | |||
94 | static void add_conn(struct work_struct *work) | ||
95 | { | ||
96 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
97 | |||
98 | flush_workqueue(btdelconn); | ||
99 | |||
100 | if (device_add(&conn->dev) < 0) { | ||
101 | BT_ERR("Failed to register connection device"); | ||
102 | return; | ||
103 | } | ||
104 | } | ||
105 | |||
106 | void hci_conn_add_sysfs(struct hci_conn *conn) | ||
107 | { | ||
108 | struct hci_dev *hdev = conn->hdev; | ||
109 | |||
110 | BT_DBG("conn %p", conn); | ||
111 | |||
112 | conn->dev.type = &bt_link; | ||
113 | conn->dev.class = bt_class; | ||
114 | conn->dev.parent = &hdev->dev; | ||
115 | |||
116 | snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d", | ||
117 | hdev->name, conn->handle); | ||
118 | |||
119 | dev_set_drvdata(&conn->dev, conn); | ||
120 | |||
121 | device_initialize(&conn->dev); | ||
122 | |||
123 | INIT_WORK(&conn->work, add_conn); | ||
124 | |||
125 | queue_work(btaddconn, &conn->work); | ||
126 | } | ||
127 | |||
128 | /* | ||
129 | * The rfcomm tty device will possibly retain even when conn | ||
130 | * is down, and sysfs doesn't support move zombie device, | ||
131 | * so we should move the device before conn device is destroyed. | ||
132 | */ | ||
133 | static int __match_tty(struct device *dev, void *data) | ||
134 | { | ||
135 | return !strncmp(dev->bus_id, "rfcomm", 6); | ||
136 | } | ||
137 | |||
138 | static void del_conn(struct work_struct *work) | ||
139 | { | ||
140 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
141 | struct hci_dev *hdev = conn->hdev; | ||
142 | |||
143 | while (1) { | ||
144 | struct device *dev; | ||
145 | |||
146 | dev = device_find_child(&conn->dev, NULL, __match_tty); | ||
147 | if (!dev) | ||
148 | break; | ||
149 | device_move(dev, NULL); | ||
150 | put_device(dev); | ||
151 | } | ||
152 | |||
153 | device_del(&conn->dev); | ||
154 | put_device(&conn->dev); | ||
155 | hci_dev_put(hdev); | ||
156 | } | ||
157 | |||
158 | void hci_conn_del_sysfs(struct hci_conn *conn) | ||
159 | { | ||
160 | BT_DBG("conn %p", conn); | ||
161 | |||
162 | if (!device_is_registered(&conn->dev)) | ||
163 | return; | ||
164 | |||
165 | INIT_WORK(&conn->work, del_conn); | ||
166 | |||
167 | queue_work(btdelconn, &conn->work); | ||
168 | } | ||
169 | |||
170 | static inline char *host_typetostr(int type) | ||
19 | { | 171 | { |
20 | switch (type) { | 172 | switch (type) { |
21 | case HCI_VIRTUAL: | 173 | case HCI_VIRTUAL: |
@@ -40,7 +192,7 @@ static inline char *typetostr(int type) | |||
40 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) | 192 | static ssize_t show_type(struct device *dev, struct device_attribute *attr, char *buf) |
41 | { | 193 | { |
42 | struct hci_dev *hdev = dev_get_drvdata(dev); | 194 | struct hci_dev *hdev = dev_get_drvdata(dev); |
43 | return sprintf(buf, "%s\n", typetostr(hdev->type)); | 195 | return sprintf(buf, "%s\n", host_typetostr(hdev->type)); |
44 | } | 196 | } |
45 | 197 | ||
46 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) | 198 | static ssize_t show_name(struct device *dev, struct device_attribute *attr, char *buf) |
@@ -221,183 +373,62 @@ static DEVICE_ATTR(sniff_max_interval, S_IRUGO | S_IWUSR, | |||
221 | static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR, | 373 | static DEVICE_ATTR(sniff_min_interval, S_IRUGO | S_IWUSR, |
222 | show_sniff_min_interval, store_sniff_min_interval); | 374 | show_sniff_min_interval, store_sniff_min_interval); |
223 | 375 | ||
224 | static struct device_attribute *bt_attrs[] = { | 376 | static struct attribute *bt_host_attrs[] = { |
225 | &dev_attr_type, | 377 | &dev_attr_type.attr, |
226 | &dev_attr_name, | 378 | &dev_attr_name.attr, |
227 | &dev_attr_class, | 379 | &dev_attr_class.attr, |
228 | &dev_attr_address, | 380 | &dev_attr_address.attr, |
229 | &dev_attr_features, | 381 | &dev_attr_features.attr, |
230 | &dev_attr_manufacturer, | 382 | &dev_attr_manufacturer.attr, |
231 | &dev_attr_hci_version, | 383 | &dev_attr_hci_version.attr, |
232 | &dev_attr_hci_revision, | 384 | &dev_attr_hci_revision.attr, |
233 | &dev_attr_inquiry_cache, | 385 | &dev_attr_inquiry_cache.attr, |
234 | &dev_attr_idle_timeout, | 386 | &dev_attr_idle_timeout.attr, |
235 | &dev_attr_sniff_max_interval, | 387 | &dev_attr_sniff_max_interval.attr, |
236 | &dev_attr_sniff_min_interval, | 388 | &dev_attr_sniff_min_interval.attr, |
237 | NULL | 389 | NULL |
238 | }; | 390 | }; |
239 | 391 | ||
240 | static ssize_t show_conn_type(struct device *dev, struct device_attribute *attr, char *buf) | 392 | static struct attribute_group bt_host_group = { |
241 | { | 393 | .attrs = bt_host_attrs, |
242 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
243 | return sprintf(buf, "%s\n", conn->type == ACL_LINK ? "ACL" : "SCO"); | ||
244 | } | ||
245 | |||
246 | static ssize_t show_conn_address(struct device *dev, struct device_attribute *attr, char *buf) | ||
247 | { | ||
248 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
249 | bdaddr_t bdaddr; | ||
250 | baswap(&bdaddr, &conn->dst); | ||
251 | return sprintf(buf, "%s\n", batostr(&bdaddr)); | ||
252 | } | ||
253 | |||
254 | static ssize_t show_conn_features(struct device *dev, struct device_attribute *attr, char *buf) | ||
255 | { | ||
256 | struct hci_conn *conn = dev_get_drvdata(dev); | ||
257 | |||
258 | return sprintf(buf, "0x%02x%02x%02x%02x%02x%02x%02x%02x\n", | ||
259 | conn->features[0], conn->features[1], | ||
260 | conn->features[2], conn->features[3], | ||
261 | conn->features[4], conn->features[5], | ||
262 | conn->features[6], conn->features[7]); | ||
263 | } | ||
264 | |||
265 | #define CONN_ATTR(_name,_mode,_show,_store) \ | ||
266 | struct device_attribute conn_attr_##_name = __ATTR(_name,_mode,_show,_store) | ||
267 | |||
268 | static CONN_ATTR(type, S_IRUGO, show_conn_type, NULL); | ||
269 | static CONN_ATTR(address, S_IRUGO, show_conn_address, NULL); | ||
270 | static CONN_ATTR(features, S_IRUGO, show_conn_features, NULL); | ||
271 | |||
272 | static struct device_attribute *conn_attrs[] = { | ||
273 | &conn_attr_type, | ||
274 | &conn_attr_address, | ||
275 | &conn_attr_features, | ||
276 | NULL | ||
277 | }; | 394 | }; |
278 | 395 | ||
279 | struct class *bt_class = NULL; | 396 | static struct attribute_group *bt_host_groups[] = { |
280 | EXPORT_SYMBOL_GPL(bt_class); | 397 | &bt_host_group, |
281 | 398 | NULL | |
282 | static struct bus_type bt_bus = { | ||
283 | .name = "bluetooth", | ||
284 | }; | 399 | }; |
285 | 400 | ||
286 | static struct platform_device *bt_platform; | 401 | static void bt_host_release(struct device *dev) |
287 | |||
288 | static void bt_release(struct device *dev) | ||
289 | { | 402 | { |
290 | void *data = dev_get_drvdata(dev); | 403 | void *data = dev_get_drvdata(dev); |
291 | kfree(data); | 404 | kfree(data); |
292 | } | 405 | } |
293 | 406 | ||
294 | static void add_conn(struct work_struct *work) | 407 | static struct device_type bt_host = { |
295 | { | 408 | .name = "host", |
296 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | 409 | .groups = bt_host_groups, |
297 | int i; | 410 | .release = bt_host_release, |
298 | 411 | }; | |
299 | flush_workqueue(btdelconn); | ||
300 | |||
301 | if (device_add(&conn->dev) < 0) { | ||
302 | BT_ERR("Failed to register connection device"); | ||
303 | return; | ||
304 | } | ||
305 | |||
306 | for (i = 0; conn_attrs[i]; i++) | ||
307 | if (device_create_file(&conn->dev, conn_attrs[i]) < 0) | ||
308 | BT_ERR("Failed to create connection attribute"); | ||
309 | } | ||
310 | |||
311 | void hci_conn_add_sysfs(struct hci_conn *conn) | ||
312 | { | ||
313 | struct hci_dev *hdev = conn->hdev; | ||
314 | |||
315 | BT_DBG("conn %p", conn); | ||
316 | |||
317 | conn->dev.bus = &bt_bus; | ||
318 | conn->dev.parent = &hdev->dev; | ||
319 | |||
320 | conn->dev.release = bt_release; | ||
321 | |||
322 | snprintf(conn->dev.bus_id, BUS_ID_SIZE, "%s:%d", | ||
323 | hdev->name, conn->handle); | ||
324 | |||
325 | dev_set_drvdata(&conn->dev, conn); | ||
326 | |||
327 | device_initialize(&conn->dev); | ||
328 | |||
329 | INIT_WORK(&conn->work, add_conn); | ||
330 | |||
331 | queue_work(btaddconn, &conn->work); | ||
332 | } | ||
333 | |||
334 | /* | ||
335 | * The rfcomm tty device will possibly retain even when conn | ||
336 | * is down, and sysfs doesn't support move zombie device, | ||
337 | * so we should move the device before conn device is destroyed. | ||
338 | */ | ||
339 | static int __match_tty(struct device *dev, void *data) | ||
340 | { | ||
341 | return !strncmp(dev->bus_id, "rfcomm", 6); | ||
342 | } | ||
343 | |||
344 | static void del_conn(struct work_struct *work) | ||
345 | { | ||
346 | struct hci_conn *conn = container_of(work, struct hci_conn, work); | ||
347 | struct hci_dev *hdev = conn->hdev; | ||
348 | |||
349 | while (1) { | ||
350 | struct device *dev; | ||
351 | |||
352 | dev = device_find_child(&conn->dev, NULL, __match_tty); | ||
353 | if (!dev) | ||
354 | break; | ||
355 | device_move(dev, NULL); | ||
356 | put_device(dev); | ||
357 | } | ||
358 | |||
359 | device_del(&conn->dev); | ||
360 | put_device(&conn->dev); | ||
361 | hci_dev_put(hdev); | ||
362 | } | ||
363 | |||
364 | void hci_conn_del_sysfs(struct hci_conn *conn) | ||
365 | { | ||
366 | BT_DBG("conn %p", conn); | ||
367 | |||
368 | if (!device_is_registered(&conn->dev)) | ||
369 | return; | ||
370 | |||
371 | INIT_WORK(&conn->work, del_conn); | ||
372 | |||
373 | queue_work(btdelconn, &conn->work); | ||
374 | } | ||
375 | 412 | ||
376 | int hci_register_sysfs(struct hci_dev *hdev) | 413 | int hci_register_sysfs(struct hci_dev *hdev) |
377 | { | 414 | { |
378 | struct device *dev = &hdev->dev; | 415 | struct device *dev = &hdev->dev; |
379 | unsigned int i; | ||
380 | int err; | 416 | int err; |
381 | 417 | ||
382 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); | 418 | BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type); |
383 | 419 | ||
384 | dev->bus = &bt_bus; | 420 | dev->type = &bt_host; |
421 | dev->class = bt_class; | ||
385 | dev->parent = hdev->parent; | 422 | dev->parent = hdev->parent; |
386 | 423 | ||
387 | strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); | 424 | strlcpy(dev->bus_id, hdev->name, BUS_ID_SIZE); |
388 | 425 | ||
389 | dev->release = bt_release; | ||
390 | |||
391 | dev_set_drvdata(dev, hdev); | 426 | dev_set_drvdata(dev, hdev); |
392 | 427 | ||
393 | err = device_register(dev); | 428 | err = device_register(dev); |
394 | if (err < 0) | 429 | if (err < 0) |
395 | return err; | 430 | return err; |
396 | 431 | ||
397 | for (i = 0; bt_attrs[i]; i++) | ||
398 | if (device_create_file(dev, bt_attrs[i]) < 0) | ||
399 | BT_ERR("Failed to create device attribute"); | ||
400 | |||
401 | return 0; | 432 | return 0; |
402 | } | 433 | } |
403 | 434 | ||
@@ -410,59 +441,30 @@ void hci_unregister_sysfs(struct hci_dev *hdev) | |||
410 | 441 | ||
411 | int __init bt_sysfs_init(void) | 442 | int __init bt_sysfs_init(void) |
412 | { | 443 | { |
413 | int err; | ||
414 | |||
415 | btaddconn = create_singlethread_workqueue("btaddconn"); | 444 | btaddconn = create_singlethread_workqueue("btaddconn"); |
416 | if (!btaddconn) { | 445 | if (!btaddconn) |
417 | err = -ENOMEM; | 446 | return -ENOMEM; |
418 | goto out; | ||
419 | } | ||
420 | 447 | ||
421 | btdelconn = create_singlethread_workqueue("btdelconn"); | 448 | btdelconn = create_singlethread_workqueue("btdelconn"); |
422 | if (!btdelconn) { | 449 | if (!btdelconn) { |
423 | err = -ENOMEM; | 450 | destroy_workqueue(btaddconn); |
424 | goto out_del; | 451 | return -ENOMEM; |
425 | } | ||
426 | |||
427 | bt_platform = platform_device_register_simple("bluetooth", -1, NULL, 0); | ||
428 | if (IS_ERR(bt_platform)) { | ||
429 | err = PTR_ERR(bt_platform); | ||
430 | goto out_platform; | ||
431 | } | 452 | } |
432 | 453 | ||
433 | err = bus_register(&bt_bus); | ||
434 | if (err < 0) | ||
435 | goto out_bus; | ||
436 | |||
437 | bt_class = class_create(THIS_MODULE, "bluetooth"); | 454 | bt_class = class_create(THIS_MODULE, "bluetooth"); |
438 | if (IS_ERR(bt_class)) { | 455 | if (IS_ERR(bt_class)) { |
439 | err = PTR_ERR(bt_class); | 456 | destroy_workqueue(btdelconn); |
440 | goto out_class; | 457 | destroy_workqueue(btaddconn); |
458 | return PTR_ERR(bt_class); | ||
441 | } | 459 | } |
442 | 460 | ||
443 | return 0; | 461 | return 0; |
444 | |||
445 | out_class: | ||
446 | bus_unregister(&bt_bus); | ||
447 | out_bus: | ||
448 | platform_device_unregister(bt_platform); | ||
449 | out_platform: | ||
450 | destroy_workqueue(btdelconn); | ||
451 | out_del: | ||
452 | destroy_workqueue(btaddconn); | ||
453 | out: | ||
454 | return err; | ||
455 | } | 462 | } |
456 | 463 | ||
457 | void bt_sysfs_cleanup(void) | 464 | void bt_sysfs_cleanup(void) |
458 | { | 465 | { |
459 | destroy_workqueue(btaddconn); | 466 | destroy_workqueue(btaddconn); |
460 | |||
461 | destroy_workqueue(btdelconn); | 467 | destroy_workqueue(btdelconn); |
462 | 468 | ||
463 | class_destroy(bt_class); | 469 | class_destroy(bt_class); |
464 | |||
465 | bus_unregister(&bt_bus); | ||
466 | |||
467 | platform_device_unregister(bt_platform); | ||
468 | } | 470 | } |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index c1239852834a..9610a9c85b98 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -55,7 +55,7 @@ | |||
55 | #define BT_DBG(D...) | 55 | #define BT_DBG(D...) |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #define VERSION "2.10" | 58 | #define VERSION "2.11" |
59 | 59 | ||
60 | static u32 l2cap_feat_mask = 0x0000; | 60 | static u32 l2cap_feat_mask = 0x0000; |
61 | 61 | ||
@@ -778,6 +778,7 @@ static int l2cap_do_connect(struct sock *sk) | |||
778 | struct l2cap_conn *conn; | 778 | struct l2cap_conn *conn; |
779 | struct hci_conn *hcon; | 779 | struct hci_conn *hcon; |
780 | struct hci_dev *hdev; | 780 | struct hci_dev *hdev; |
781 | __u8 auth_type; | ||
781 | int err = 0; | 782 | int err = 0; |
782 | 783 | ||
783 | BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst), l2cap_pi(sk)->psm); | 784 | BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst), l2cap_pi(sk)->psm); |
@@ -789,7 +790,21 @@ static int l2cap_do_connect(struct sock *sk) | |||
789 | 790 | ||
790 | err = -ENOMEM; | 791 | err = -ENOMEM; |
791 | 792 | ||
792 | hcon = hci_connect(hdev, ACL_LINK, dst); | 793 | if (l2cap_pi(sk)->link_mode & L2CAP_LM_AUTH || |
794 | l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT || | ||
795 | l2cap_pi(sk)->link_mode & L2CAP_LM_SECURE) { | ||
796 | if (l2cap_pi(sk)->psm == cpu_to_le16(0x0001)) | ||
797 | auth_type = HCI_AT_NO_BONDING_MITM; | ||
798 | else | ||
799 | auth_type = HCI_AT_GENERAL_BONDING_MITM; | ||
800 | } else { | ||
801 | if (l2cap_pi(sk)->psm == cpu_to_le16(0x0001)) | ||
802 | auth_type = HCI_AT_NO_BONDING; | ||
803 | else | ||
804 | auth_type = HCI_AT_GENERAL_BONDING; | ||
805 | } | ||
806 | |||
807 | hcon = hci_connect(hdev, ACL_LINK, dst, auth_type); | ||
793 | if (!hcon) | 808 | if (!hcon) |
794 | goto done; | 809 | goto done; |
795 | 810 | ||
@@ -1553,10 +1568,10 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
1553 | struct l2cap_conn_req *req = (struct l2cap_conn_req *) data; | 1568 | struct l2cap_conn_req *req = (struct l2cap_conn_req *) data; |
1554 | struct l2cap_conn_rsp rsp; | 1569 | struct l2cap_conn_rsp rsp; |
1555 | struct sock *sk, *parent; | 1570 | struct sock *sk, *parent; |
1556 | int result, status = 0; | 1571 | int result, status = L2CAP_CS_NO_INFO; |
1557 | 1572 | ||
1558 | u16 dcid = 0, scid = __le16_to_cpu(req->scid); | 1573 | u16 dcid = 0, scid = __le16_to_cpu(req->scid); |
1559 | __le16 psm = req->psm; | 1574 | __le16 psm = req->psm; |
1560 | 1575 | ||
1561 | BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid); | 1576 | BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid); |
1562 | 1577 | ||
@@ -1567,6 +1582,13 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
1567 | goto sendresp; | 1582 | goto sendresp; |
1568 | } | 1583 | } |
1569 | 1584 | ||
1585 | /* Check if the ACL is secure enough (if not SDP) */ | ||
1586 | if (psm != cpu_to_le16(0x0001) && | ||
1587 | !hci_conn_check_link_mode(conn->hcon)) { | ||
1588 | result = L2CAP_CR_SEC_BLOCK; | ||
1589 | goto response; | ||
1590 | } | ||
1591 | |||
1570 | result = L2CAP_CR_NO_MEM; | 1592 | result = L2CAP_CR_NO_MEM; |
1571 | 1593 | ||
1572 | /* Check for backlog size */ | 1594 | /* Check for backlog size */ |
@@ -2224,7 +2246,7 @@ static int l2cap_auth_cfm(struct hci_conn *hcon, u8 status) | |||
2224 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); | 2246 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); |
2225 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); | 2247 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); |
2226 | rsp.result = cpu_to_le16(result); | 2248 | rsp.result = cpu_to_le16(result); |
2227 | rsp.status = cpu_to_le16(0); | 2249 | rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); |
2228 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, | 2250 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, |
2229 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | 2251 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); |
2230 | } | 2252 | } |
@@ -2296,7 +2318,7 @@ static int l2cap_encrypt_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) | |||
2296 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); | 2318 | rsp.scid = cpu_to_le16(l2cap_pi(sk)->dcid); |
2297 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); | 2319 | rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); |
2298 | rsp.result = cpu_to_le16(result); | 2320 | rsp.result = cpu_to_le16(result); |
2299 | rsp.status = cpu_to_le16(0); | 2321 | rsp.status = cpu_to_le16(L2CAP_CS_NO_INFO); |
2300 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, | 2322 | l2cap_send_cmd(conn, l2cap_pi(sk)->ident, |
2301 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); | 2323 | L2CAP_CONN_RSP, sizeof(rsp), &rsp); |
2302 | } | 2324 | } |
@@ -2516,7 +2538,7 @@ EXPORT_SYMBOL(l2cap_load); | |||
2516 | module_init(l2cap_init); | 2538 | module_init(l2cap_init); |
2517 | module_exit(l2cap_exit); | 2539 | module_exit(l2cap_exit); |
2518 | 2540 | ||
2519 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 2541 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
2520 | MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION); | 2542 | MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION); |
2521 | MODULE_VERSION(VERSION); | 2543 | MODULE_VERSION(VERSION); |
2522 | MODULE_LICENSE("GPL"); | 2544 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 6cfc7ba611b3..ba537fae0a4c 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -2115,7 +2115,7 @@ MODULE_PARM_DESC(channel_mtu, "Default MTU for the RFCOMM channel"); | |||
2115 | module_param(l2cap_mtu, uint, 0644); | 2115 | module_param(l2cap_mtu, uint, 0644); |
2116 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); | 2116 | MODULE_PARM_DESC(l2cap_mtu, "Default MTU for the L2CAP connection"); |
2117 | 2117 | ||
2118 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 2118 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
2119 | MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION); | 2119 | MODULE_DESCRIPTION("Bluetooth RFCOMM ver " VERSION); |
2120 | MODULE_VERSION(VERSION); | 2120 | MODULE_VERSION(VERSION); |
2121 | MODULE_LICENSE("GPL"); | 2121 | MODULE_LICENSE("GPL"); |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index 8cda49874868..0cc91e6da76d 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -200,7 +200,7 @@ static int sco_connect(struct sock *sk) | |||
200 | else | 200 | else |
201 | type = SCO_LINK; | 201 | type = SCO_LINK; |
202 | 202 | ||
203 | hcon = hci_connect(hdev, type, dst); | 203 | hcon = hci_connect(hdev, type, dst, HCI_AT_NO_BONDING); |
204 | if (!hcon) | 204 | if (!hcon) |
205 | goto done; | 205 | goto done; |
206 | 206 | ||
@@ -1002,7 +1002,7 @@ module_exit(sco_exit); | |||
1002 | module_param(disable_esco, bool, 0644); | 1002 | module_param(disable_esco, bool, 0644); |
1003 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); | 1003 | MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation"); |
1004 | 1004 | ||
1005 | MODULE_AUTHOR("Maxim Krasnyansky <maxk@qualcomm.com>, Marcel Holtmann <marcel@holtmann.org>"); | 1005 | MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); |
1006 | MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION); | 1006 | MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION); |
1007 | MODULE_VERSION(VERSION); | 1007 | MODULE_VERSION(VERSION); |
1008 | MODULE_LICENSE("GPL"); | 1008 | MODULE_LICENSE("GPL"); |
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index d9449df7cad5..4f52c3d50ebe 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c | |||
@@ -68,10 +68,17 @@ static int br_dev_stop(struct net_device *dev) | |||
68 | 68 | ||
69 | static int br_change_mtu(struct net_device *dev, int new_mtu) | 69 | static int br_change_mtu(struct net_device *dev, int new_mtu) |
70 | { | 70 | { |
71 | if (new_mtu < 68 || new_mtu > br_min_mtu(netdev_priv(dev))) | 71 | struct net_bridge *br = netdev_priv(dev); |
72 | if (new_mtu < 68 || new_mtu > br_min_mtu(br)) | ||
72 | return -EINVAL; | 73 | return -EINVAL; |
73 | 74 | ||
74 | dev->mtu = new_mtu; | 75 | dev->mtu = new_mtu; |
76 | |||
77 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
78 | /* remember the MTU in the rtable for PMTU */ | ||
79 | br->fake_rtable.u.dst.metrics[RTAX_MTU - 1] = new_mtu; | ||
80 | #endif | ||
81 | |||
75 | return 0; | 82 | return 0; |
76 | } | 83 | } |
77 | 84 | ||
@@ -141,11 +148,16 @@ static int br_set_tx_csum(struct net_device *dev, u32 data) | |||
141 | } | 148 | } |
142 | 149 | ||
143 | static struct ethtool_ops br_ethtool_ops = { | 150 | static struct ethtool_ops br_ethtool_ops = { |
144 | .get_drvinfo = br_getinfo, | 151 | .get_drvinfo = br_getinfo, |
145 | .get_link = ethtool_op_get_link, | 152 | .get_link = ethtool_op_get_link, |
146 | .set_sg = br_set_sg, | 153 | .get_tx_csum = ethtool_op_get_tx_csum, |
147 | .set_tx_csum = br_set_tx_csum, | 154 | .set_tx_csum = br_set_tx_csum, |
148 | .set_tso = br_set_tso, | 155 | .get_sg = ethtool_op_get_sg, |
156 | .set_sg = br_set_sg, | ||
157 | .get_tso = ethtool_op_get_tso, | ||
158 | .set_tso = br_set_tso, | ||
159 | .get_ufo = ethtool_op_get_ufo, | ||
160 | .get_flags = ethtool_op_get_flags, | ||
149 | }; | 161 | }; |
150 | 162 | ||
151 | void br_dev_setup(struct net_device *dev) | 163 | void br_dev_setup(struct net_device *dev) |
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index a072ea5ca6f5..63c18aacde8c 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -202,6 +202,9 @@ static struct net_device *new_bridge_dev(const char *name) | |||
202 | br->topology_change = 0; | 202 | br->topology_change = 0; |
203 | br->topology_change_detected = 0; | 203 | br->topology_change_detected = 0; |
204 | br->ageing_time = 300 * HZ; | 204 | br->ageing_time = 300 * HZ; |
205 | |||
206 | br_netfilter_rtable_init(br); | ||
207 | |||
205 | INIT_LIST_HEAD(&br->age_list); | 208 | INIT_LIST_HEAD(&br->age_list); |
206 | 209 | ||
207 | br_stp_timer_init(br); | 210 | br_stp_timer_init(br); |
diff --git a/net/bridge/br_ioctl.c b/net/bridge/br_ioctl.c index eeee218eed80..5bbf07362172 100644 --- a/net/bridge/br_ioctl.c +++ b/net/bridge/br_ioctl.c | |||
@@ -188,15 +188,21 @@ static int old_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
188 | return 0; | 188 | return 0; |
189 | 189 | ||
190 | case BRCTL_SET_BRIDGE_HELLO_TIME: | 190 | case BRCTL_SET_BRIDGE_HELLO_TIME: |
191 | { | ||
192 | unsigned long t = clock_t_to_jiffies(args[1]); | ||
191 | if (!capable(CAP_NET_ADMIN)) | 193 | if (!capable(CAP_NET_ADMIN)) |
192 | return -EPERM; | 194 | return -EPERM; |
193 | 195 | ||
196 | if (t < HZ) | ||
197 | return -EINVAL; | ||
198 | |||
194 | spin_lock_bh(&br->lock); | 199 | spin_lock_bh(&br->lock); |
195 | br->bridge_hello_time = clock_t_to_jiffies(args[1]); | 200 | br->bridge_hello_time = t; |
196 | if (br_is_root_bridge(br)) | 201 | if (br_is_root_bridge(br)) |
197 | br->hello_time = br->bridge_hello_time; | 202 | br->hello_time = br->bridge_hello_time; |
198 | spin_unlock_bh(&br->lock); | 203 | spin_unlock_bh(&br->lock); |
199 | return 0; | 204 | return 0; |
205 | } | ||
200 | 206 | ||
201 | case BRCTL_SET_BRIDGE_MAX_AGE: | 207 | case BRCTL_SET_BRIDGE_MAX_AGE: |
202 | if (!capable(CAP_NET_ADMIN)) | 208 | if (!capable(CAP_NET_ADMIN)) |
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c index bb90cd7bace3..6a9a6cd74b1e 100644 --- a/net/bridge/br_netfilter.c +++ b/net/bridge/br_netfilter.c | |||
@@ -101,33 +101,30 @@ static inline __be16 pppoe_proto(const struct sk_buff *skb) | |||
101 | pppoe_proto(skb) == htons(PPP_IPV6) && \ | 101 | pppoe_proto(skb) == htons(PPP_IPV6) && \ |
102 | brnf_filter_pppoe_tagged) | 102 | brnf_filter_pppoe_tagged) |
103 | 103 | ||
104 | /* We need these fake structures to make netfilter happy -- | 104 | /* |
105 | * lots of places assume that skb->dst != NULL, which isn't | 105 | * Initialize bogus route table used to keep netfilter happy. |
106 | * all that unreasonable. | ||
107 | * | ||
108 | * Currently, we fill in the PMTU entry because netfilter | 106 | * Currently, we fill in the PMTU entry because netfilter |
109 | * refragmentation needs it, and the rt_flags entry because | 107 | * refragmentation needs it, and the rt_flags entry because |
110 | * ipt_REJECT needs it. Future netfilter modules might | 108 | * ipt_REJECT needs it. Future netfilter modules might |
111 | * require us to fill additional fields. */ | 109 | * require us to fill additional fields. |
112 | static struct net_device __fake_net_device = { | 110 | */ |
113 | .hard_header_len = ETH_HLEN, | 111 | void br_netfilter_rtable_init(struct net_bridge *br) |
114 | #ifdef CONFIG_NET_NS | 112 | { |
115 | .nd_net = &init_net, | 113 | struct rtable *rt = &br->fake_rtable; |
116 | #endif | ||
117 | }; | ||
118 | 114 | ||
119 | static struct rtable __fake_rtable = { | 115 | atomic_set(&rt->u.dst.__refcnt, 1); |
120 | .u = { | 116 | rt->u.dst.dev = br->dev; |
121 | .dst = { | 117 | rt->u.dst.path = &rt->u.dst; |
122 | .__refcnt = ATOMIC_INIT(1), | 118 | rt->u.dst.metrics[RTAX_MTU - 1] = 1500; |
123 | .dev = &__fake_net_device, | 119 | rt->u.dst.flags = DST_NOXFRM; |
124 | .path = &__fake_rtable.u.dst, | 120 | } |
125 | .metrics = {[RTAX_MTU - 1] = 1500}, | 121 | |
126 | .flags = DST_NOXFRM, | 122 | static inline struct rtable *bridge_parent_rtable(const struct net_device *dev) |
127 | } | 123 | { |
128 | }, | 124 | struct net_bridge_port *port = rcu_dereference(dev->br_port); |
129 | .rt_flags = 0, | 125 | |
130 | }; | 126 | return port ? &port->br->fake_rtable : NULL; |
127 | } | ||
131 | 128 | ||
132 | static inline struct net_device *bridge_parent(const struct net_device *dev) | 129 | static inline struct net_device *bridge_parent(const struct net_device *dev) |
133 | { | 130 | { |
@@ -226,8 +223,12 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb) | |||
226 | } | 223 | } |
227 | nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; | 224 | nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; |
228 | 225 | ||
229 | skb->rtable = &__fake_rtable; | 226 | skb->rtable = bridge_parent_rtable(nf_bridge->physindev); |
230 | dst_hold(&__fake_rtable.u.dst); | 227 | if (!skb->rtable) { |
228 | kfree_skb(skb); | ||
229 | return 0; | ||
230 | } | ||
231 | dst_hold(&skb->rtable->u.dst); | ||
231 | 232 | ||
232 | skb->dev = nf_bridge->physindev; | 233 | skb->dev = nf_bridge->physindev; |
233 | nf_bridge_push_encap_header(skb); | 234 | nf_bridge_push_encap_header(skb); |
@@ -391,8 +392,12 @@ bridged_dnat: | |||
391 | skb->pkt_type = PACKET_HOST; | 392 | skb->pkt_type = PACKET_HOST; |
392 | } | 393 | } |
393 | } else { | 394 | } else { |
394 | skb->rtable = &__fake_rtable; | 395 | skb->rtable = bridge_parent_rtable(nf_bridge->physindev); |
395 | dst_hold(&__fake_rtable.u.dst); | 396 | if (!skb->rtable) { |
397 | kfree_skb(skb); | ||
398 | return 0; | ||
399 | } | ||
400 | dst_hold(&skb->rtable->u.dst); | ||
396 | } | 401 | } |
397 | 402 | ||
398 | skb->dev = nf_bridge->physindev; | 403 | skb->dev = nf_bridge->physindev; |
@@ -611,8 +616,8 @@ static unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb, | |||
611 | const struct net_device *out, | 616 | const struct net_device *out, |
612 | int (*okfn)(struct sk_buff *)) | 617 | int (*okfn)(struct sk_buff *)) |
613 | { | 618 | { |
614 | if (skb->rtable == &__fake_rtable) { | 619 | if (skb->rtable && skb->rtable == bridge_parent_rtable(in)) { |
615 | dst_release(&__fake_rtable.u.dst); | 620 | dst_release(&skb->rtable->u.dst); |
616 | skb->rtable = NULL; | 621 | skb->rtable = NULL; |
617 | } | 622 | } |
618 | 623 | ||
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 815ed38925b2..c3dc18ddc043 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h | |||
@@ -15,6 +15,7 @@ | |||
15 | 15 | ||
16 | #include <linux/netdevice.h> | 16 | #include <linux/netdevice.h> |
17 | #include <linux/if_bridge.h> | 17 | #include <linux/if_bridge.h> |
18 | #include <net/route.h> | ||
18 | 19 | ||
19 | #define BR_HASH_BITS 8 | 20 | #define BR_HASH_BITS 8 |
20 | #define BR_HASH_SIZE (1 << BR_HASH_BITS) | 21 | #define BR_HASH_SIZE (1 << BR_HASH_BITS) |
@@ -92,6 +93,9 @@ struct net_bridge | |||
92 | struct hlist_head hash[BR_HASH_SIZE]; | 93 | struct hlist_head hash[BR_HASH_SIZE]; |
93 | struct list_head age_list; | 94 | struct list_head age_list; |
94 | unsigned long feature_mask; | 95 | unsigned long feature_mask; |
96 | #ifdef CONFIG_BRIDGE_NETFILTER | ||
97 | struct rtable fake_rtable; | ||
98 | #endif | ||
95 | unsigned long flags; | 99 | unsigned long flags; |
96 | #define BR_SET_MAC_ADDR 0x00000001 | 100 | #define BR_SET_MAC_ADDR 0x00000001 |
97 | 101 | ||
@@ -197,9 +201,11 @@ extern int br_ioctl_deviceless_stub(struct net *net, unsigned int cmd, void __us | |||
197 | #ifdef CONFIG_BRIDGE_NETFILTER | 201 | #ifdef CONFIG_BRIDGE_NETFILTER |
198 | extern int br_netfilter_init(void); | 202 | extern int br_netfilter_init(void); |
199 | extern void br_netfilter_fini(void); | 203 | extern void br_netfilter_fini(void); |
204 | extern void br_netfilter_rtable_init(struct net_bridge *); | ||
200 | #else | 205 | #else |
201 | #define br_netfilter_init() (0) | 206 | #define br_netfilter_init() (0) |
202 | #define br_netfilter_fini() do { } while(0) | 207 | #define br_netfilter_fini() do { } while(0) |
208 | #define br_netfilter_rtable_init(x) | ||
203 | #endif | 209 | #endif |
204 | 210 | ||
205 | /* br_stp.c */ | 211 | /* br_stp.c */ |
diff --git a/net/bridge/br_stp.c b/net/bridge/br_stp.c index 921bbe5cb94a..6e63ec3f1fcf 100644 --- a/net/bridge/br_stp.c +++ b/net/bridge/br_stp.c | |||
@@ -368,14 +368,25 @@ static void br_make_blocking(struct net_bridge_port *p) | |||
368 | /* called under bridge lock */ | 368 | /* called under bridge lock */ |
369 | static void br_make_forwarding(struct net_bridge_port *p) | 369 | static void br_make_forwarding(struct net_bridge_port *p) |
370 | { | 370 | { |
371 | if (p->state == BR_STATE_BLOCKING) { | 371 | struct net_bridge *br = p->br; |
372 | if (p->br->stp_enabled == BR_KERNEL_STP) | ||
373 | p->state = BR_STATE_LISTENING; | ||
374 | else | ||
375 | p->state = BR_STATE_LEARNING; | ||
376 | 372 | ||
377 | br_log_state(p); | 373 | if (p->state != BR_STATE_BLOCKING) |
378 | mod_timer(&p->forward_delay_timer, jiffies + p->br->forward_delay); } | 374 | return; |
375 | |||
376 | if (br->forward_delay == 0) { | ||
377 | p->state = BR_STATE_FORWARDING; | ||
378 | br_topology_change_detection(br); | ||
379 | del_timer(&p->forward_delay_timer); | ||
380 | } | ||
381 | else if (p->br->stp_enabled == BR_KERNEL_STP) | ||
382 | p->state = BR_STATE_LISTENING; | ||
383 | else | ||
384 | p->state = BR_STATE_LEARNING; | ||
385 | |||
386 | br_log_state(p); | ||
387 | |||
388 | if (br->forward_delay != 0) | ||
389 | mod_timer(&p->forward_delay_timer, jiffies + br->forward_delay); | ||
379 | } | 390 | } |
380 | 391 | ||
381 | /* called under bridge lock */ | 392 | /* called under bridge lock */ |
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c index 27d6a511c8c1..158dee8b4965 100644 --- a/net/bridge/br_sysfs_br.c +++ b/net/bridge/br_sysfs_br.c | |||
@@ -29,11 +29,12 @@ | |||
29 | */ | 29 | */ |
30 | static ssize_t store_bridge_parm(struct device *d, | 30 | static ssize_t store_bridge_parm(struct device *d, |
31 | const char *buf, size_t len, | 31 | const char *buf, size_t len, |
32 | void (*set)(struct net_bridge *, unsigned long)) | 32 | int (*set)(struct net_bridge *, unsigned long)) |
33 | { | 33 | { |
34 | struct net_bridge *br = to_bridge(d); | 34 | struct net_bridge *br = to_bridge(d); |
35 | char *endp; | 35 | char *endp; |
36 | unsigned long val; | 36 | unsigned long val; |
37 | int err; | ||
37 | 38 | ||
38 | if (!capable(CAP_NET_ADMIN)) | 39 | if (!capable(CAP_NET_ADMIN)) |
39 | return -EPERM; | 40 | return -EPERM; |
@@ -43,9 +44,9 @@ static ssize_t store_bridge_parm(struct device *d, | |||
43 | return -EINVAL; | 44 | return -EINVAL; |
44 | 45 | ||
45 | spin_lock_bh(&br->lock); | 46 | spin_lock_bh(&br->lock); |
46 | (*set)(br, val); | 47 | err = (*set)(br, val); |
47 | spin_unlock_bh(&br->lock); | 48 | spin_unlock_bh(&br->lock); |
48 | return len; | 49 | return err ? err : len; |
49 | } | 50 | } |
50 | 51 | ||
51 | 52 | ||
@@ -56,12 +57,13 @@ static ssize_t show_forward_delay(struct device *d, | |||
56 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay)); | 57 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->forward_delay)); |
57 | } | 58 | } |
58 | 59 | ||
59 | static void set_forward_delay(struct net_bridge *br, unsigned long val) | 60 | static int set_forward_delay(struct net_bridge *br, unsigned long val) |
60 | { | 61 | { |
61 | unsigned long delay = clock_t_to_jiffies(val); | 62 | unsigned long delay = clock_t_to_jiffies(val); |
62 | br->forward_delay = delay; | 63 | br->forward_delay = delay; |
63 | if (br_is_root_bridge(br)) | 64 | if (br_is_root_bridge(br)) |
64 | br->bridge_forward_delay = delay; | 65 | br->bridge_forward_delay = delay; |
66 | return 0; | ||
65 | } | 67 | } |
66 | 68 | ||
67 | static ssize_t store_forward_delay(struct device *d, | 69 | static ssize_t store_forward_delay(struct device *d, |
@@ -80,12 +82,17 @@ static ssize_t show_hello_time(struct device *d, struct device_attribute *attr, | |||
80 | jiffies_to_clock_t(to_bridge(d)->hello_time)); | 82 | jiffies_to_clock_t(to_bridge(d)->hello_time)); |
81 | } | 83 | } |
82 | 84 | ||
83 | static void set_hello_time(struct net_bridge *br, unsigned long val) | 85 | static int set_hello_time(struct net_bridge *br, unsigned long val) |
84 | { | 86 | { |
85 | unsigned long t = clock_t_to_jiffies(val); | 87 | unsigned long t = clock_t_to_jiffies(val); |
88 | |||
89 | if (t < HZ) | ||
90 | return -EINVAL; | ||
91 | |||
86 | br->hello_time = t; | 92 | br->hello_time = t; |
87 | if (br_is_root_bridge(br)) | 93 | if (br_is_root_bridge(br)) |
88 | br->bridge_hello_time = t; | 94 | br->bridge_hello_time = t; |
95 | return 0; | ||
89 | } | 96 | } |
90 | 97 | ||
91 | static ssize_t store_hello_time(struct device *d, | 98 | static ssize_t store_hello_time(struct device *d, |
@@ -104,12 +111,13 @@ static ssize_t show_max_age(struct device *d, struct device_attribute *attr, | |||
104 | jiffies_to_clock_t(to_bridge(d)->max_age)); | 111 | jiffies_to_clock_t(to_bridge(d)->max_age)); |
105 | } | 112 | } |
106 | 113 | ||
107 | static void set_max_age(struct net_bridge *br, unsigned long val) | 114 | static int set_max_age(struct net_bridge *br, unsigned long val) |
108 | { | 115 | { |
109 | unsigned long t = clock_t_to_jiffies(val); | 116 | unsigned long t = clock_t_to_jiffies(val); |
110 | br->max_age = t; | 117 | br->max_age = t; |
111 | if (br_is_root_bridge(br)) | 118 | if (br_is_root_bridge(br)) |
112 | br->bridge_max_age = t; | 119 | br->bridge_max_age = t; |
120 | return 0; | ||
113 | } | 121 | } |
114 | 122 | ||
115 | static ssize_t store_max_age(struct device *d, struct device_attribute *attr, | 123 | static ssize_t store_max_age(struct device *d, struct device_attribute *attr, |
@@ -126,9 +134,10 @@ static ssize_t show_ageing_time(struct device *d, | |||
126 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->ageing_time)); | 134 | return sprintf(buf, "%lu\n", jiffies_to_clock_t(br->ageing_time)); |
127 | } | 135 | } |
128 | 136 | ||
129 | static void set_ageing_time(struct net_bridge *br, unsigned long val) | 137 | static int set_ageing_time(struct net_bridge *br, unsigned long val) |
130 | { | 138 | { |
131 | br->ageing_time = clock_t_to_jiffies(val); | 139 | br->ageing_time = clock_t_to_jiffies(val); |
140 | return 0; | ||
132 | } | 141 | } |
133 | 142 | ||
134 | static ssize_t store_ageing_time(struct device *d, | 143 | static ssize_t store_ageing_time(struct device *d, |
@@ -180,9 +189,10 @@ static ssize_t show_priority(struct device *d, struct device_attribute *attr, | |||
180 | (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]); | 189 | (br->bridge_id.prio[0] << 8) | br->bridge_id.prio[1]); |
181 | } | 190 | } |
182 | 191 | ||
183 | static void set_priority(struct net_bridge *br, unsigned long val) | 192 | static int set_priority(struct net_bridge *br, unsigned long val) |
184 | { | 193 | { |
185 | br_stp_set_bridge_priority(br, (u16) val); | 194 | br_stp_set_bridge_priority(br, (u16) val); |
195 | return 0; | ||
186 | } | 196 | } |
187 | 197 | ||
188 | static ssize_t store_priority(struct device *d, struct device_attribute *attr, | 198 | static ssize_t store_priority(struct device *d, struct device_attribute *attr, |
diff --git a/net/core/datagram.c b/net/core/datagram.c index dd61dcad6019..52f577a0f544 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -339,6 +339,93 @@ fault: | |||
339 | return -EFAULT; | 339 | return -EFAULT; |
340 | } | 340 | } |
341 | 341 | ||
342 | /** | ||
343 | * skb_copy_datagram_from_iovec - Copy a datagram from an iovec. | ||
344 | * @skb: buffer to copy | ||
345 | * @offset: offset in the buffer to start copying to | ||
346 | * @from: io vector to copy to | ||
347 | * @len: amount of data to copy to buffer from iovec | ||
348 | * | ||
349 | * Returns 0 or -EFAULT. | ||
350 | * Note: the iovec is modified during the copy. | ||
351 | */ | ||
352 | int skb_copy_datagram_from_iovec(struct sk_buff *skb, int offset, | ||
353 | struct iovec *from, int len) | ||
354 | { | ||
355 | int start = skb_headlen(skb); | ||
356 | int i, copy = start - offset; | ||
357 | |||
358 | /* Copy header. */ | ||
359 | if (copy > 0) { | ||
360 | if (copy > len) | ||
361 | copy = len; | ||
362 | if (memcpy_fromiovec(skb->data + offset, from, copy)) | ||
363 | goto fault; | ||
364 | if ((len -= copy) == 0) | ||
365 | return 0; | ||
366 | offset += copy; | ||
367 | } | ||
368 | |||
369 | /* Copy paged appendix. Hmm... why does this look so complicated? */ | ||
370 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | ||
371 | int end; | ||
372 | |||
373 | WARN_ON(start > offset + len); | ||
374 | |||
375 | end = start + skb_shinfo(skb)->frags[i].size; | ||
376 | if ((copy = end - offset) > 0) { | ||
377 | int err; | ||
378 | u8 *vaddr; | ||
379 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
380 | struct page *page = frag->page; | ||
381 | |||
382 | if (copy > len) | ||
383 | copy = len; | ||
384 | vaddr = kmap(page); | ||
385 | err = memcpy_fromiovec(vaddr + frag->page_offset + | ||
386 | offset - start, from, copy); | ||
387 | kunmap(page); | ||
388 | if (err) | ||
389 | goto fault; | ||
390 | |||
391 | if (!(len -= copy)) | ||
392 | return 0; | ||
393 | offset += copy; | ||
394 | } | ||
395 | start = end; | ||
396 | } | ||
397 | |||
398 | if (skb_shinfo(skb)->frag_list) { | ||
399 | struct sk_buff *list = skb_shinfo(skb)->frag_list; | ||
400 | |||
401 | for (; list; list = list->next) { | ||
402 | int end; | ||
403 | |||
404 | WARN_ON(start > offset + len); | ||
405 | |||
406 | end = start + list->len; | ||
407 | if ((copy = end - offset) > 0) { | ||
408 | if (copy > len) | ||
409 | copy = len; | ||
410 | if (skb_copy_datagram_from_iovec(list, | ||
411 | offset - start, | ||
412 | from, copy)) | ||
413 | goto fault; | ||
414 | if ((len -= copy) == 0) | ||
415 | return 0; | ||
416 | offset += copy; | ||
417 | } | ||
418 | start = end; | ||
419 | } | ||
420 | } | ||
421 | if (!len) | ||
422 | return 0; | ||
423 | |||
424 | fault: | ||
425 | return -EFAULT; | ||
426 | } | ||
427 | EXPORT_SYMBOL(skb_copy_datagram_from_iovec); | ||
428 | |||
342 | static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, | 429 | static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, |
343 | u8 __user *to, int len, | 430 | u8 __user *to, int len, |
344 | __wsum *csump) | 431 | __wsum *csump) |
diff --git a/net/core/dev.c b/net/core/dev.c index 8d13a9b9f1df..e719ed29310f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1339,19 +1339,23 @@ static void dev_queue_xmit_nit(struct sk_buff *skb, struct net_device *dev) | |||
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | 1341 | ||
1342 | void __netif_schedule(struct Qdisc *q) | 1342 | static inline void __netif_reschedule(struct Qdisc *q) |
1343 | { | 1343 | { |
1344 | if (!test_and_set_bit(__QDISC_STATE_SCHED, &q->state)) { | 1344 | struct softnet_data *sd; |
1345 | struct softnet_data *sd; | 1345 | unsigned long flags; |
1346 | unsigned long flags; | ||
1347 | 1346 | ||
1348 | local_irq_save(flags); | 1347 | local_irq_save(flags); |
1349 | sd = &__get_cpu_var(softnet_data); | 1348 | sd = &__get_cpu_var(softnet_data); |
1350 | q->next_sched = sd->output_queue; | 1349 | q->next_sched = sd->output_queue; |
1351 | sd->output_queue = q; | 1350 | sd->output_queue = q; |
1352 | raise_softirq_irqoff(NET_TX_SOFTIRQ); | 1351 | raise_softirq_irqoff(NET_TX_SOFTIRQ); |
1353 | local_irq_restore(flags); | 1352 | local_irq_restore(flags); |
1354 | } | 1353 | } |
1354 | |||
1355 | void __netif_schedule(struct Qdisc *q) | ||
1356 | { | ||
1357 | if (!test_and_set_bit(__QDISC_STATE_SCHED, &q->state)) | ||
1358 | __netif_reschedule(q); | ||
1355 | } | 1359 | } |
1356 | EXPORT_SYMBOL(__netif_schedule); | 1360 | EXPORT_SYMBOL(__netif_schedule); |
1357 | 1361 | ||
@@ -1796,16 +1800,19 @@ gso: | |||
1796 | skb->tc_verd = SET_TC_AT(skb->tc_verd,AT_EGRESS); | 1800 | skb->tc_verd = SET_TC_AT(skb->tc_verd,AT_EGRESS); |
1797 | #endif | 1801 | #endif |
1798 | if (q->enqueue) { | 1802 | if (q->enqueue) { |
1799 | spinlock_t *root_lock = qdisc_root_lock(q); | 1803 | spinlock_t *root_lock = qdisc_lock(q); |
1800 | 1804 | ||
1801 | spin_lock(root_lock); | 1805 | spin_lock(root_lock); |
1802 | 1806 | ||
1803 | rc = qdisc_enqueue_root(skb, q); | 1807 | if (unlikely(test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) { |
1804 | qdisc_run(q); | 1808 | kfree_skb(skb); |
1805 | 1809 | rc = NET_XMIT_DROP; | |
1810 | } else { | ||
1811 | rc = qdisc_enqueue_root(skb, q); | ||
1812 | qdisc_run(q); | ||
1813 | } | ||
1806 | spin_unlock(root_lock); | 1814 | spin_unlock(root_lock); |
1807 | 1815 | ||
1808 | rc = rc == NET_XMIT_BYPASS ? NET_XMIT_SUCCESS : rc; | ||
1809 | goto out; | 1816 | goto out; |
1810 | } | 1817 | } |
1811 | 1818 | ||
@@ -1909,7 +1916,6 @@ int netif_rx(struct sk_buff *skb) | |||
1909 | if (queue->input_pkt_queue.qlen <= netdev_max_backlog) { | 1916 | if (queue->input_pkt_queue.qlen <= netdev_max_backlog) { |
1910 | if (queue->input_pkt_queue.qlen) { | 1917 | if (queue->input_pkt_queue.qlen) { |
1911 | enqueue: | 1918 | enqueue: |
1912 | dev_hold(skb->dev); | ||
1913 | __skb_queue_tail(&queue->input_pkt_queue, skb); | 1919 | __skb_queue_tail(&queue->input_pkt_queue, skb); |
1914 | local_irq_restore(flags); | 1920 | local_irq_restore(flags); |
1915 | return NET_RX_SUCCESS; | 1921 | return NET_RX_SUCCESS; |
@@ -1941,22 +1947,6 @@ int netif_rx_ni(struct sk_buff *skb) | |||
1941 | 1947 | ||
1942 | EXPORT_SYMBOL(netif_rx_ni); | 1948 | EXPORT_SYMBOL(netif_rx_ni); |
1943 | 1949 | ||
1944 | static inline struct net_device *skb_bond(struct sk_buff *skb) | ||
1945 | { | ||
1946 | struct net_device *dev = skb->dev; | ||
1947 | |||
1948 | if (dev->master) { | ||
1949 | if (skb_bond_should_drop(skb)) { | ||
1950 | kfree_skb(skb); | ||
1951 | return NULL; | ||
1952 | } | ||
1953 | skb->dev = dev->master; | ||
1954 | } | ||
1955 | |||
1956 | return dev; | ||
1957 | } | ||
1958 | |||
1959 | |||
1960 | static void net_tx_action(struct softirq_action *h) | 1950 | static void net_tx_action(struct softirq_action *h) |
1961 | { | 1951 | { |
1962 | struct softnet_data *sd = &__get_cpu_var(softnet_data); | 1952 | struct softnet_data *sd = &__get_cpu_var(softnet_data); |
@@ -1992,15 +1982,22 @@ static void net_tx_action(struct softirq_action *h) | |||
1992 | 1982 | ||
1993 | head = head->next_sched; | 1983 | head = head->next_sched; |
1994 | 1984 | ||
1995 | smp_mb__before_clear_bit(); | 1985 | root_lock = qdisc_lock(q); |
1996 | clear_bit(__QDISC_STATE_SCHED, &q->state); | ||
1997 | |||
1998 | root_lock = qdisc_root_lock(q); | ||
1999 | if (spin_trylock(root_lock)) { | 1986 | if (spin_trylock(root_lock)) { |
1987 | smp_mb__before_clear_bit(); | ||
1988 | clear_bit(__QDISC_STATE_SCHED, | ||
1989 | &q->state); | ||
2000 | qdisc_run(q); | 1990 | qdisc_run(q); |
2001 | spin_unlock(root_lock); | 1991 | spin_unlock(root_lock); |
2002 | } else { | 1992 | } else { |
2003 | __netif_schedule(q); | 1993 | if (!test_bit(__QDISC_STATE_DEACTIVATED, |
1994 | &q->state)) { | ||
1995 | __netif_reschedule(q); | ||
1996 | } else { | ||
1997 | smp_mb__before_clear_bit(); | ||
1998 | clear_bit(__QDISC_STATE_SCHED, | ||
1999 | &q->state); | ||
2000 | } | ||
2004 | } | 2001 | } |
2005 | } | 2002 | } |
2006 | } | 2003 | } |
@@ -2100,9 +2097,10 @@ static int ing_filter(struct sk_buff *skb) | |||
2100 | rxq = &dev->rx_queue; | 2097 | rxq = &dev->rx_queue; |
2101 | 2098 | ||
2102 | q = rxq->qdisc; | 2099 | q = rxq->qdisc; |
2103 | if (q) { | 2100 | if (q != &noop_qdisc) { |
2104 | spin_lock(qdisc_lock(q)); | 2101 | spin_lock(qdisc_lock(q)); |
2105 | result = qdisc_enqueue_root(skb, q); | 2102 | if (likely(!test_bit(__QDISC_STATE_DEACTIVATED, &q->state))) |
2103 | result = qdisc_enqueue_root(skb, q); | ||
2106 | spin_unlock(qdisc_lock(q)); | 2104 | spin_unlock(qdisc_lock(q)); |
2107 | } | 2105 | } |
2108 | 2106 | ||
@@ -2113,7 +2111,7 @@ static inline struct sk_buff *handle_ing(struct sk_buff *skb, | |||
2113 | struct packet_type **pt_prev, | 2111 | struct packet_type **pt_prev, |
2114 | int *ret, struct net_device *orig_dev) | 2112 | int *ret, struct net_device *orig_dev) |
2115 | { | 2113 | { |
2116 | if (!skb->dev->rx_queue.qdisc) | 2114 | if (skb->dev->rx_queue.qdisc == &noop_qdisc) |
2117 | goto out; | 2115 | goto out; |
2118 | 2116 | ||
2119 | if (*pt_prev) { | 2117 | if (*pt_prev) { |
@@ -2183,6 +2181,7 @@ int netif_receive_skb(struct sk_buff *skb) | |||
2183 | { | 2181 | { |
2184 | struct packet_type *ptype, *pt_prev; | 2182 | struct packet_type *ptype, *pt_prev; |
2185 | struct net_device *orig_dev; | 2183 | struct net_device *orig_dev; |
2184 | struct net_device *null_or_orig; | ||
2186 | int ret = NET_RX_DROP; | 2185 | int ret = NET_RX_DROP; |
2187 | __be16 type; | 2186 | __be16 type; |
2188 | 2187 | ||
@@ -2196,10 +2195,14 @@ int netif_receive_skb(struct sk_buff *skb) | |||
2196 | if (!skb->iif) | 2195 | if (!skb->iif) |
2197 | skb->iif = skb->dev->ifindex; | 2196 | skb->iif = skb->dev->ifindex; |
2198 | 2197 | ||
2199 | orig_dev = skb_bond(skb); | 2198 | null_or_orig = NULL; |
2200 | 2199 | orig_dev = skb->dev; | |
2201 | if (!orig_dev) | 2200 | if (orig_dev->master) { |
2202 | return NET_RX_DROP; | 2201 | if (skb_bond_should_drop(skb)) |
2202 | null_or_orig = orig_dev; /* deliver only exact match */ | ||
2203 | else | ||
2204 | skb->dev = orig_dev->master; | ||
2205 | } | ||
2203 | 2206 | ||
2204 | __get_cpu_var(netdev_rx_stat).total++; | 2207 | __get_cpu_var(netdev_rx_stat).total++; |
2205 | 2208 | ||
@@ -2223,7 +2226,8 @@ int netif_receive_skb(struct sk_buff *skb) | |||
2223 | #endif | 2226 | #endif |
2224 | 2227 | ||
2225 | list_for_each_entry_rcu(ptype, &ptype_all, list) { | 2228 | list_for_each_entry_rcu(ptype, &ptype_all, list) { |
2226 | if (!ptype->dev || ptype->dev == skb->dev) { | 2229 | if (ptype->dev == null_or_orig || ptype->dev == skb->dev || |
2230 | ptype->dev == orig_dev) { | ||
2227 | if (pt_prev) | 2231 | if (pt_prev) |
2228 | ret = deliver_skb(skb, pt_prev, orig_dev); | 2232 | ret = deliver_skb(skb, pt_prev, orig_dev); |
2229 | pt_prev = ptype; | 2233 | pt_prev = ptype; |
@@ -2248,7 +2252,8 @@ ncls: | |||
2248 | list_for_each_entry_rcu(ptype, | 2252 | list_for_each_entry_rcu(ptype, |
2249 | &ptype_base[ntohs(type) & PTYPE_HASH_MASK], list) { | 2253 | &ptype_base[ntohs(type) & PTYPE_HASH_MASK], list) { |
2250 | if (ptype->type == type && | 2254 | if (ptype->type == type && |
2251 | (!ptype->dev || ptype->dev == skb->dev)) { | 2255 | (ptype->dev == null_or_orig || ptype->dev == skb->dev || |
2256 | ptype->dev == orig_dev)) { | ||
2252 | if (pt_prev) | 2257 | if (pt_prev) |
2253 | ret = deliver_skb(skb, pt_prev, orig_dev); | 2258 | ret = deliver_skb(skb, pt_prev, orig_dev); |
2254 | pt_prev = ptype; | 2259 | pt_prev = ptype; |
@@ -2270,6 +2275,20 @@ out: | |||
2270 | return ret; | 2275 | return ret; |
2271 | } | 2276 | } |
2272 | 2277 | ||
2278 | /* Network device is going away, flush any packets still pending */ | ||
2279 | static void flush_backlog(void *arg) | ||
2280 | { | ||
2281 | struct net_device *dev = arg; | ||
2282 | struct softnet_data *queue = &__get_cpu_var(softnet_data); | ||
2283 | struct sk_buff *skb, *tmp; | ||
2284 | |||
2285 | skb_queue_walk_safe(&queue->input_pkt_queue, skb, tmp) | ||
2286 | if (skb->dev == dev) { | ||
2287 | __skb_unlink(skb, &queue->input_pkt_queue); | ||
2288 | kfree_skb(skb); | ||
2289 | } | ||
2290 | } | ||
2291 | |||
2273 | static int process_backlog(struct napi_struct *napi, int quota) | 2292 | static int process_backlog(struct napi_struct *napi, int quota) |
2274 | { | 2293 | { |
2275 | int work = 0; | 2294 | int work = 0; |
@@ -2279,7 +2298,6 @@ static int process_backlog(struct napi_struct *napi, int quota) | |||
2279 | napi->weight = weight_p; | 2298 | napi->weight = weight_p; |
2280 | do { | 2299 | do { |
2281 | struct sk_buff *skb; | 2300 | struct sk_buff *skb; |
2282 | struct net_device *dev; | ||
2283 | 2301 | ||
2284 | local_irq_disable(); | 2302 | local_irq_disable(); |
2285 | skb = __skb_dequeue(&queue->input_pkt_queue); | 2303 | skb = __skb_dequeue(&queue->input_pkt_queue); |
@@ -2288,14 +2306,9 @@ static int process_backlog(struct napi_struct *napi, int quota) | |||
2288 | local_irq_enable(); | 2306 | local_irq_enable(); |
2289 | break; | 2307 | break; |
2290 | } | 2308 | } |
2291 | |||
2292 | local_irq_enable(); | 2309 | local_irq_enable(); |
2293 | 2310 | ||
2294 | dev = skb->dev; | ||
2295 | |||
2296 | netif_receive_skb(skb); | 2311 | netif_receive_skb(skb); |
2297 | |||
2298 | dev_put(dev); | ||
2299 | } while (++work < quota && jiffies == start_time); | 2312 | } while (++work < quota && jiffies == start_time); |
2300 | 2313 | ||
2301 | return work; | 2314 | return work; |
@@ -3988,6 +4001,10 @@ int register_netdevice(struct net_device *dev) | |||
3988 | } | 4001 | } |
3989 | } | 4002 | } |
3990 | 4003 | ||
4004 | /* Enable software GSO if SG is supported. */ | ||
4005 | if (dev->features & NETIF_F_SG) | ||
4006 | dev->features |= NETIF_F_GSO; | ||
4007 | |||
3991 | netdev_initialize_kobject(dev); | 4008 | netdev_initialize_kobject(dev); |
3992 | ret = netdev_register_kobject(dev); | 4009 | ret = netdev_register_kobject(dev); |
3993 | if (ret) | 4010 | if (ret) |
@@ -4165,6 +4182,8 @@ void netdev_run_todo(void) | |||
4165 | 4182 | ||
4166 | dev->reg_state = NETREG_UNREGISTERED; | 4183 | dev->reg_state = NETREG_UNREGISTERED; |
4167 | 4184 | ||
4185 | on_each_cpu(flush_backlog, dev, 1); | ||
4186 | |||
4168 | netdev_wait_allrefs(dev); | 4187 | netdev_wait_allrefs(dev); |
4169 | 4188 | ||
4170 | /* paranoia */ | 4189 | /* paranoia */ |
@@ -4200,6 +4219,7 @@ static void netdev_init_queues(struct net_device *dev) | |||
4200 | { | 4219 | { |
4201 | netdev_init_one_queue(dev, &dev->rx_queue, NULL); | 4220 | netdev_init_one_queue(dev, &dev->rx_queue, NULL); |
4202 | netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL); | 4221 | netdev_for_each_tx_queue(dev, netdev_init_one_queue, NULL); |
4222 | spin_lock_init(&dev->tx_global_lock); | ||
4203 | } | 4223 | } |
4204 | 4224 | ||
4205 | /** | 4225 | /** |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index f62c8af85d38..9d92e41826e7 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -2281,6 +2281,7 @@ static struct neighbour *neigh_get_idx(struct seq_file *seq, loff_t *pos) | |||
2281 | struct neighbour *n = neigh_get_first(seq); | 2281 | struct neighbour *n = neigh_get_first(seq); |
2282 | 2282 | ||
2283 | if (n) { | 2283 | if (n) { |
2284 | --(*pos); | ||
2284 | while (*pos) { | 2285 | while (*pos) { |
2285 | n = neigh_get_next(seq, n, pos); | 2286 | n = neigh_get_next(seq, n, pos); |
2286 | if (!n) | 2287 | if (!n) |
@@ -2341,6 +2342,7 @@ static struct pneigh_entry *pneigh_get_idx(struct seq_file *seq, loff_t *pos) | |||
2341 | struct pneigh_entry *pn = pneigh_get_first(seq); | 2342 | struct pneigh_entry *pn = pneigh_get_first(seq); |
2342 | 2343 | ||
2343 | if (pn) { | 2344 | if (pn) { |
2345 | --(*pos); | ||
2344 | while (*pos) { | 2346 | while (*pos) { |
2345 | pn = pneigh_get_next(seq, pn, pos); | 2347 | pn = pneigh_get_next(seq, pn, pos); |
2346 | if (!pn) | 2348 | if (!pn) |
@@ -2354,10 +2356,11 @@ static void *neigh_get_idx_any(struct seq_file *seq, loff_t *pos) | |||
2354 | { | 2356 | { |
2355 | struct neigh_seq_state *state = seq->private; | 2357 | struct neigh_seq_state *state = seq->private; |
2356 | void *rc; | 2358 | void *rc; |
2359 | loff_t idxpos = *pos; | ||
2357 | 2360 | ||
2358 | rc = neigh_get_idx(seq, pos); | 2361 | rc = neigh_get_idx(seq, &idxpos); |
2359 | if (!rc && !(state->flags & NEIGH_SEQ_NEIGH_ONLY)) | 2362 | if (!rc && !(state->flags & NEIGH_SEQ_NEIGH_ONLY)) |
2360 | rc = pneigh_get_idx(seq, pos); | 2363 | rc = pneigh_get_idx(seq, &idxpos); |
2361 | 2364 | ||
2362 | return rc; | 2365 | return rc; |
2363 | } | 2366 | } |
@@ -2366,7 +2369,6 @@ void *neigh_seq_start(struct seq_file *seq, loff_t *pos, struct neigh_table *tbl | |||
2366 | __acquires(tbl->lock) | 2369 | __acquires(tbl->lock) |
2367 | { | 2370 | { |
2368 | struct neigh_seq_state *state = seq->private; | 2371 | struct neigh_seq_state *state = seq->private; |
2369 | loff_t pos_minus_one; | ||
2370 | 2372 | ||
2371 | state->tbl = tbl; | 2373 | state->tbl = tbl; |
2372 | state->bucket = 0; | 2374 | state->bucket = 0; |
@@ -2374,8 +2376,7 @@ void *neigh_seq_start(struct seq_file *seq, loff_t *pos, struct neigh_table *tbl | |||
2374 | 2376 | ||
2375 | read_lock_bh(&tbl->lock); | 2377 | read_lock_bh(&tbl->lock); |
2376 | 2378 | ||
2377 | pos_minus_one = *pos - 1; | 2379 | return *pos ? neigh_get_idx_any(seq, pos) : SEQ_START_TOKEN; |
2378 | return *pos ? neigh_get_idx_any(seq, &pos_minus_one) : SEQ_START_TOKEN; | ||
2379 | } | 2380 | } |
2380 | EXPORT_SYMBOL(neigh_seq_start); | 2381 | EXPORT_SYMBOL(neigh_seq_start); |
2381 | 2382 | ||
@@ -2385,7 +2386,7 @@ void *neigh_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
2385 | void *rc; | 2386 | void *rc; |
2386 | 2387 | ||
2387 | if (v == SEQ_START_TOKEN) { | 2388 | if (v == SEQ_START_TOKEN) { |
2388 | rc = neigh_get_idx(seq, pos); | 2389 | rc = neigh_get_first(seq); |
2389 | goto out; | 2390 | goto out; |
2390 | } | 2391 | } |
2391 | 2392 | ||
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index c12720895ecf..6c7af390be0a 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -70,6 +70,7 @@ static void queue_process(struct work_struct *work) | |||
70 | local_irq_save(flags); | 70 | local_irq_save(flags); |
71 | __netif_tx_lock(txq, smp_processor_id()); | 71 | __netif_tx_lock(txq, smp_processor_id()); |
72 | if (netif_tx_queue_stopped(txq) || | 72 | if (netif_tx_queue_stopped(txq) || |
73 | netif_tx_queue_frozen(txq) || | ||
73 | dev->hard_start_xmit(skb, dev) != NETDEV_TX_OK) { | 74 | dev->hard_start_xmit(skb, dev) != NETDEV_TX_OK) { |
74 | skb_queue_head(&npinfo->txq, skb); | 75 | skb_queue_head(&npinfo->txq, skb); |
75 | __netif_tx_unlock(txq); | 76 | __netif_tx_unlock(txq); |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index c7d484f7e1c4..a756847e3814 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -168,7 +168,7 @@ | |||
168 | #include <asm/div64.h> /* do_div */ | 168 | #include <asm/div64.h> /* do_div */ |
169 | #include <asm/timex.h> | 169 | #include <asm/timex.h> |
170 | 170 | ||
171 | #define VERSION "pktgen v2.69: Packet Generator for packet performance testing.\n" | 171 | #define VERSION "pktgen v2.70: Packet Generator for packet performance testing.\n" |
172 | 172 | ||
173 | #define IP_NAME_SZ 32 | 173 | #define IP_NAME_SZ 32 |
174 | #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */ | 174 | #define MAX_MPLS_LABELS 16 /* This is the max label stack depth */ |
@@ -189,6 +189,7 @@ | |||
189 | #define F_FLOW_SEQ (1<<11) /* Sequential flows */ | 189 | #define F_FLOW_SEQ (1<<11) /* Sequential flows */ |
190 | #define F_IPSEC_ON (1<<12) /* ipsec on for flows */ | 190 | #define F_IPSEC_ON (1<<12) /* ipsec on for flows */ |
191 | #define F_QUEUE_MAP_RND (1<<13) /* queue map Random */ | 191 | #define F_QUEUE_MAP_RND (1<<13) /* queue map Random */ |
192 | #define F_QUEUE_MAP_CPU (1<<14) /* queue map mirrors smp_processor_id() */ | ||
192 | 193 | ||
193 | /* Thread control flag bits */ | 194 | /* Thread control flag bits */ |
194 | #define T_TERMINATE (1<<0) | 195 | #define T_TERMINATE (1<<0) |
@@ -621,6 +622,9 @@ static int pktgen_if_show(struct seq_file *seq, void *v) | |||
621 | if (pkt_dev->flags & F_QUEUE_MAP_RND) | 622 | if (pkt_dev->flags & F_QUEUE_MAP_RND) |
622 | seq_printf(seq, "QUEUE_MAP_RND "); | 623 | seq_printf(seq, "QUEUE_MAP_RND "); |
623 | 624 | ||
625 | if (pkt_dev->flags & F_QUEUE_MAP_CPU) | ||
626 | seq_printf(seq, "QUEUE_MAP_CPU "); | ||
627 | |||
624 | if (pkt_dev->cflows) { | 628 | if (pkt_dev->cflows) { |
625 | if (pkt_dev->flags & F_FLOW_SEQ) | 629 | if (pkt_dev->flags & F_FLOW_SEQ) |
626 | seq_printf(seq, "FLOW_SEQ "); /*in sequence flows*/ | 630 | seq_printf(seq, "FLOW_SEQ "); /*in sequence flows*/ |
@@ -1134,6 +1138,12 @@ static ssize_t pktgen_if_write(struct file *file, | |||
1134 | 1138 | ||
1135 | else if (strcmp(f, "!QUEUE_MAP_RND") == 0) | 1139 | else if (strcmp(f, "!QUEUE_MAP_RND") == 0) |
1136 | pkt_dev->flags &= ~F_QUEUE_MAP_RND; | 1140 | pkt_dev->flags &= ~F_QUEUE_MAP_RND; |
1141 | |||
1142 | else if (strcmp(f, "QUEUE_MAP_CPU") == 0) | ||
1143 | pkt_dev->flags |= F_QUEUE_MAP_CPU; | ||
1144 | |||
1145 | else if (strcmp(f, "!QUEUE_MAP_CPU") == 0) | ||
1146 | pkt_dev->flags &= ~F_QUEUE_MAP_CPU; | ||
1137 | #ifdef CONFIG_XFRM | 1147 | #ifdef CONFIG_XFRM |
1138 | else if (strcmp(f, "IPSEC") == 0) | 1148 | else if (strcmp(f, "IPSEC") == 0) |
1139 | pkt_dev->flags |= F_IPSEC_ON; | 1149 | pkt_dev->flags |= F_IPSEC_ON; |
@@ -1895,6 +1905,23 @@ static int pktgen_device_event(struct notifier_block *unused, | |||
1895 | return NOTIFY_DONE; | 1905 | return NOTIFY_DONE; |
1896 | } | 1906 | } |
1897 | 1907 | ||
1908 | static struct net_device *pktgen_dev_get_by_name(struct pktgen_dev *pkt_dev, const char *ifname) | ||
1909 | { | ||
1910 | char b[IFNAMSIZ+5]; | ||
1911 | int i = 0; | ||
1912 | |||
1913 | for(i=0; ifname[i] != '@'; i++) { | ||
1914 | if(i == IFNAMSIZ) | ||
1915 | break; | ||
1916 | |||
1917 | b[i] = ifname[i]; | ||
1918 | } | ||
1919 | b[i] = 0; | ||
1920 | |||
1921 | return dev_get_by_name(&init_net, b); | ||
1922 | } | ||
1923 | |||
1924 | |||
1898 | /* Associate pktgen_dev with a device. */ | 1925 | /* Associate pktgen_dev with a device. */ |
1899 | 1926 | ||
1900 | static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname) | 1927 | static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname) |
@@ -1908,7 +1935,7 @@ static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname) | |||
1908 | pkt_dev->odev = NULL; | 1935 | pkt_dev->odev = NULL; |
1909 | } | 1936 | } |
1910 | 1937 | ||
1911 | odev = dev_get_by_name(&init_net, ifname); | 1938 | odev = pktgen_dev_get_by_name(pkt_dev, ifname); |
1912 | if (!odev) { | 1939 | if (!odev) { |
1913 | printk(KERN_ERR "pktgen: no such netdevice: \"%s\"\n", ifname); | 1940 | printk(KERN_ERR "pktgen: no such netdevice: \"%s\"\n", ifname); |
1914 | return -ENODEV; | 1941 | return -ENODEV; |
@@ -1934,6 +1961,8 @@ static int pktgen_setup_dev(struct pktgen_dev *pkt_dev, const char *ifname) | |||
1934 | */ | 1961 | */ |
1935 | static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | 1962 | static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) |
1936 | { | 1963 | { |
1964 | int ntxq; | ||
1965 | |||
1937 | if (!pkt_dev->odev) { | 1966 | if (!pkt_dev->odev) { |
1938 | printk(KERN_ERR "pktgen: ERROR: pkt_dev->odev == NULL in " | 1967 | printk(KERN_ERR "pktgen: ERROR: pkt_dev->odev == NULL in " |
1939 | "setup_inject.\n"); | 1968 | "setup_inject.\n"); |
@@ -1942,6 +1971,33 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | |||
1942 | return; | 1971 | return; |
1943 | } | 1972 | } |
1944 | 1973 | ||
1974 | /* make sure that we don't pick a non-existing transmit queue */ | ||
1975 | ntxq = pkt_dev->odev->real_num_tx_queues; | ||
1976 | if (ntxq <= num_online_cpus() && (pkt_dev->flags & F_QUEUE_MAP_CPU)) { | ||
1977 | printk(KERN_WARNING "pktgen: WARNING: QUEUE_MAP_CPU " | ||
1978 | "disabled because CPU count (%d) exceeds number ", | ||
1979 | num_online_cpus()); | ||
1980 | printk(KERN_WARNING "pktgen: WARNING: of tx queues " | ||
1981 | "(%d) on %s \n", ntxq, pkt_dev->odev->name); | ||
1982 | pkt_dev->flags &= ~F_QUEUE_MAP_CPU; | ||
1983 | } | ||
1984 | if (ntxq <= pkt_dev->queue_map_min) { | ||
1985 | printk(KERN_WARNING "pktgen: WARNING: Requested " | ||
1986 | "queue_map_min (%d) exceeds number of tx\n", | ||
1987 | pkt_dev->queue_map_min); | ||
1988 | printk(KERN_WARNING "pktgen: WARNING: queues (%d) on " | ||
1989 | "%s, resetting\n", ntxq, pkt_dev->odev->name); | ||
1990 | pkt_dev->queue_map_min = ntxq - 1; | ||
1991 | } | ||
1992 | if (ntxq <= pkt_dev->queue_map_max) { | ||
1993 | printk(KERN_WARNING "pktgen: WARNING: Requested " | ||
1994 | "queue_map_max (%d) exceeds number of tx\n", | ||
1995 | pkt_dev->queue_map_max); | ||
1996 | printk(KERN_WARNING "pktgen: WARNING: queues (%d) on " | ||
1997 | "%s, resetting\n", ntxq, pkt_dev->odev->name); | ||
1998 | pkt_dev->queue_map_max = ntxq - 1; | ||
1999 | } | ||
2000 | |||
1945 | /* Default to the interface's mac if not explicitly set. */ | 2001 | /* Default to the interface's mac if not explicitly set. */ |
1946 | 2002 | ||
1947 | if (is_zero_ether_addr(pkt_dev->src_mac)) | 2003 | if (is_zero_ether_addr(pkt_dev->src_mac)) |
@@ -2085,15 +2141,19 @@ static inline int f_pick(struct pktgen_dev *pkt_dev) | |||
2085 | if (pkt_dev->flows[flow].count >= pkt_dev->lflow) { | 2141 | if (pkt_dev->flows[flow].count >= pkt_dev->lflow) { |
2086 | /* reset time */ | 2142 | /* reset time */ |
2087 | pkt_dev->flows[flow].count = 0; | 2143 | pkt_dev->flows[flow].count = 0; |
2144 | pkt_dev->flows[flow].flags = 0; | ||
2088 | pkt_dev->curfl += 1; | 2145 | pkt_dev->curfl += 1; |
2089 | if (pkt_dev->curfl >= pkt_dev->cflows) | 2146 | if (pkt_dev->curfl >= pkt_dev->cflows) |
2090 | pkt_dev->curfl = 0; /*reset */ | 2147 | pkt_dev->curfl = 0; /*reset */ |
2091 | } | 2148 | } |
2092 | } else { | 2149 | } else { |
2093 | flow = random32() % pkt_dev->cflows; | 2150 | flow = random32() % pkt_dev->cflows; |
2151 | pkt_dev->curfl = flow; | ||
2094 | 2152 | ||
2095 | if (pkt_dev->flows[flow].count > pkt_dev->lflow) | 2153 | if (pkt_dev->flows[flow].count > pkt_dev->lflow) { |
2096 | pkt_dev->flows[flow].count = 0; | 2154 | pkt_dev->flows[flow].count = 0; |
2155 | pkt_dev->flows[flow].flags = 0; | ||
2156 | } | ||
2097 | } | 2157 | } |
2098 | 2158 | ||
2099 | return pkt_dev->curfl; | 2159 | return pkt_dev->curfl; |
@@ -2125,7 +2185,11 @@ static void get_ipsec_sa(struct pktgen_dev *pkt_dev, int flow) | |||
2125 | #endif | 2185 | #endif |
2126 | static void set_cur_queue_map(struct pktgen_dev *pkt_dev) | 2186 | static void set_cur_queue_map(struct pktgen_dev *pkt_dev) |
2127 | { | 2187 | { |
2128 | if (pkt_dev->queue_map_min < pkt_dev->queue_map_max) { | 2188 | |
2189 | if (pkt_dev->flags & F_QUEUE_MAP_CPU) | ||
2190 | pkt_dev->cur_queue_map = smp_processor_id(); | ||
2191 | |||
2192 | else if (pkt_dev->queue_map_min < pkt_dev->queue_map_max) { | ||
2129 | __u16 t; | 2193 | __u16 t; |
2130 | if (pkt_dev->flags & F_QUEUE_MAP_RND) { | 2194 | if (pkt_dev->flags & F_QUEUE_MAP_RND) { |
2131 | t = random32() % | 2195 | t = random32() % |
@@ -2162,7 +2226,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2162 | mc = random32() % pkt_dev->src_mac_count; | 2226 | mc = random32() % pkt_dev->src_mac_count; |
2163 | else { | 2227 | else { |
2164 | mc = pkt_dev->cur_src_mac_offset++; | 2228 | mc = pkt_dev->cur_src_mac_offset++; |
2165 | if (pkt_dev->cur_src_mac_offset > | 2229 | if (pkt_dev->cur_src_mac_offset >= |
2166 | pkt_dev->src_mac_count) | 2230 | pkt_dev->src_mac_count) |
2167 | pkt_dev->cur_src_mac_offset = 0; | 2231 | pkt_dev->cur_src_mac_offset = 0; |
2168 | } | 2232 | } |
@@ -2189,7 +2253,7 @@ static void mod_cur_headers(struct pktgen_dev *pkt_dev) | |||
2189 | 2253 | ||
2190 | else { | 2254 | else { |
2191 | mc = pkt_dev->cur_dst_mac_offset++; | 2255 | mc = pkt_dev->cur_dst_mac_offset++; |
2192 | if (pkt_dev->cur_dst_mac_offset > | 2256 | if (pkt_dev->cur_dst_mac_offset >= |
2193 | pkt_dev->dst_mac_count) { | 2257 | pkt_dev->dst_mac_count) { |
2194 | pkt_dev->cur_dst_mac_offset = 0; | 2258 | pkt_dev->cur_dst_mac_offset = 0; |
2195 | } | 2259 | } |
@@ -3305,6 +3369,7 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev) | |||
3305 | 3369 | ||
3306 | txq = netdev_get_tx_queue(odev, queue_map); | 3370 | txq = netdev_get_tx_queue(odev, queue_map); |
3307 | if (netif_tx_queue_stopped(txq) || | 3371 | if (netif_tx_queue_stopped(txq) || |
3372 | netif_tx_queue_frozen(txq) || | ||
3308 | need_resched()) { | 3373 | need_resched()) { |
3309 | idle_start = getCurUs(); | 3374 | idle_start = getCurUs(); |
3310 | 3375 | ||
@@ -3320,7 +3385,8 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev) | |||
3320 | 3385 | ||
3321 | pkt_dev->idle_acc += getCurUs() - idle_start; | 3386 | pkt_dev->idle_acc += getCurUs() - idle_start; |
3322 | 3387 | ||
3323 | if (netif_tx_queue_stopped(txq)) { | 3388 | if (netif_tx_queue_stopped(txq) || |
3389 | netif_tx_queue_frozen(txq)) { | ||
3324 | pkt_dev->next_tx_us = getCurUs(); /* TODO */ | 3390 | pkt_dev->next_tx_us = getCurUs(); /* TODO */ |
3325 | pkt_dev->next_tx_ns = 0; | 3391 | pkt_dev->next_tx_ns = 0; |
3326 | goto out; /* Try the next interface */ | 3392 | goto out; /* Try the next interface */ |
@@ -3352,7 +3418,8 @@ static __inline__ void pktgen_xmit(struct pktgen_dev *pkt_dev) | |||
3352 | txq = netdev_get_tx_queue(odev, queue_map); | 3418 | txq = netdev_get_tx_queue(odev, queue_map); |
3353 | 3419 | ||
3354 | __netif_tx_lock_bh(txq); | 3420 | __netif_tx_lock_bh(txq); |
3355 | if (!netif_tx_queue_stopped(txq)) { | 3421 | if (!netif_tx_queue_stopped(txq) && |
3422 | !netif_tx_queue_frozen(txq)) { | ||
3356 | 3423 | ||
3357 | atomic_inc(&(pkt_dev->skb->users)); | 3424 | atomic_inc(&(pkt_dev->skb->users)); |
3358 | retry_now: | 3425 | retry_now: |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 4e0c92274189..ca1ccdf1ef76 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -485,6 +485,9 @@ static struct sk_buff *__skb_clone(struct sk_buff *n, struct sk_buff *skb) | |||
485 | C(head); | 485 | C(head); |
486 | C(data); | 486 | C(data); |
487 | C(truesize); | 487 | C(truesize); |
488 | #if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE) | ||
489 | C(do_not_encrypt); | ||
490 | #endif | ||
488 | atomic_set(&n->users, 1); | 491 | atomic_set(&n->users, 1); |
489 | 492 | ||
490 | atomic_inc(&(skb_shinfo(skb)->dataref)); | 493 | atomic_inc(&(skb_shinfo(skb)->dataref)); |
@@ -2253,14 +2256,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) | |||
2253 | segs = nskb; | 2256 | segs = nskb; |
2254 | tail = nskb; | 2257 | tail = nskb; |
2255 | 2258 | ||
2256 | nskb->dev = skb->dev; | 2259 | __copy_skb_header(nskb, skb); |
2257 | skb_copy_queue_mapping(nskb, skb); | ||
2258 | nskb->priority = skb->priority; | ||
2259 | nskb->protocol = skb->protocol; | ||
2260 | nskb->vlan_tci = skb->vlan_tci; | ||
2261 | nskb->dst = dst_clone(skb->dst); | ||
2262 | memcpy(nskb->cb, skb->cb, sizeof(skb->cb)); | ||
2263 | nskb->pkt_type = skb->pkt_type; | ||
2264 | nskb->mac_len = skb->mac_len; | 2260 | nskb->mac_len = skb->mac_len; |
2265 | 2261 | ||
2266 | skb_reserve(nskb, headroom); | 2262 | skb_reserve(nskb, headroom); |
@@ -2271,6 +2267,7 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) | |||
2271 | skb_copy_from_linear_data(skb, skb_put(nskb, doffset), | 2267 | skb_copy_from_linear_data(skb, skb_put(nskb, doffset), |
2272 | doffset); | 2268 | doffset); |
2273 | if (!sg) { | 2269 | if (!sg) { |
2270 | nskb->ip_summed = CHECKSUM_NONE; | ||
2274 | nskb->csum = skb_copy_and_csum_bits(skb, offset, | 2271 | nskb->csum = skb_copy_and_csum_bits(skb, offset, |
2275 | skb_put(nskb, len), | 2272 | skb_put(nskb, len), |
2276 | len, 0); | 2273 | len, 0); |
@@ -2280,8 +2277,6 @@ struct sk_buff *skb_segment(struct sk_buff *skb, int features) | |||
2280 | frag = skb_shinfo(nskb)->frags; | 2277 | frag = skb_shinfo(nskb)->frags; |
2281 | k = 0; | 2278 | k = 0; |
2282 | 2279 | ||
2283 | nskb->ip_summed = CHECKSUM_PARTIAL; | ||
2284 | nskb->csum = skb->csum; | ||
2285 | skb_copy_from_linear_data_offset(skb, offset, | 2280 | skb_copy_from_linear_data_offset(skb, offset, |
2286 | skb_put(nskb, hsize), hsize); | 2281 | skb_put(nskb, hsize), hsize); |
2287 | 2282 | ||
diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 1c2e3ec2eb57..b4bc6e095a0e 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h | |||
@@ -229,7 +229,8 @@ extern void dccp_v4_send_check(struct sock *sk, int len, struct sk_buff *skb); | |||
229 | extern int dccp_retransmit_skb(struct sock *sk); | 229 | extern int dccp_retransmit_skb(struct sock *sk); |
230 | 230 | ||
231 | extern void dccp_send_ack(struct sock *sk); | 231 | extern void dccp_send_ack(struct sock *sk); |
232 | extern void dccp_reqsk_send_ack(struct sk_buff *sk, struct request_sock *rsk); | 232 | extern void dccp_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, |
233 | struct request_sock *rsk); | ||
233 | 234 | ||
234 | extern void dccp_send_sync(struct sock *sk, const u64 seq, | 235 | extern void dccp_send_sync(struct sock *sk, const u64 seq, |
235 | const enum dccp_pkt_type pkt_type); | 236 | const enum dccp_pkt_type pkt_type); |
diff --git a/net/dccp/input.c b/net/dccp/input.c index df2f110df94a..803933ab396d 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
@@ -411,12 +411,6 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, | |||
411 | struct dccp_sock *dp = dccp_sk(sk); | 411 | struct dccp_sock *dp = dccp_sk(sk); |
412 | long tstamp = dccp_timestamp(); | 412 | long tstamp = dccp_timestamp(); |
413 | 413 | ||
414 | /* Stop the REQUEST timer */ | ||
415 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); | ||
416 | WARN_ON(sk->sk_send_head == NULL); | ||
417 | __kfree_skb(sk->sk_send_head); | ||
418 | sk->sk_send_head = NULL; | ||
419 | |||
420 | if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, | 414 | if (!between48(DCCP_SKB_CB(skb)->dccpd_ack_seq, |
421 | dp->dccps_awl, dp->dccps_awh)) { | 415 | dp->dccps_awl, dp->dccps_awh)) { |
422 | dccp_pr_debug("invalid ackno: S.AWL=%llu, " | 416 | dccp_pr_debug("invalid ackno: S.AWL=%llu, " |
@@ -441,6 +435,12 @@ static int dccp_rcv_request_sent_state_process(struct sock *sk, | |||
441 | DCCP_ACKVEC_STATE_RECEIVED)) | 435 | DCCP_ACKVEC_STATE_RECEIVED)) |
442 | goto out_invalid_packet; /* FIXME: change error code */ | 436 | goto out_invalid_packet; /* FIXME: change error code */ |
443 | 437 | ||
438 | /* Stop the REQUEST timer */ | ||
439 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); | ||
440 | WARN_ON(sk->sk_send_head == NULL); | ||
441 | kfree_skb(sk->sk_send_head); | ||
442 | sk->sk_send_head = NULL; | ||
443 | |||
444 | dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq; | 444 | dp->dccps_isr = DCCP_SKB_CB(skb)->dccpd_seq; |
445 | dccp_update_gsr(sk, dp->dccps_isr); | 445 | dccp_update_gsr(sk, dp->dccps_isr); |
446 | /* | 446 | /* |
diff --git a/net/dccp/minisocks.c b/net/dccp/minisocks.c index 66dca5bba858..b2804e2d1b8c 100644 --- a/net/dccp/minisocks.c +++ b/net/dccp/minisocks.c | |||
@@ -296,7 +296,8 @@ int dccp_child_process(struct sock *parent, struct sock *child, | |||
296 | 296 | ||
297 | EXPORT_SYMBOL_GPL(dccp_child_process); | 297 | EXPORT_SYMBOL_GPL(dccp_child_process); |
298 | 298 | ||
299 | void dccp_reqsk_send_ack(struct sk_buff *skb, struct request_sock *rsk) | 299 | void dccp_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, |
300 | struct request_sock *rsk) | ||
300 | { | 301 | { |
301 | DCCP_BUG("DCCP-ACK packets are never sent in LISTEN/RESPOND state"); | 302 | DCCP_BUG("DCCP-ACK packets are never sent in LISTEN/RESPOND state"); |
302 | } | 303 | } |
diff --git a/net/dccp/proto.c b/net/dccp/proto.c index b622d9744856..1ca3b26eed0f 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c | |||
@@ -474,6 +474,11 @@ static int dccp_setsockopt_change(struct sock *sk, int type, | |||
474 | 474 | ||
475 | if (copy_from_user(&opt, optval, sizeof(opt))) | 475 | if (copy_from_user(&opt, optval, sizeof(opt))) |
476 | return -EFAULT; | 476 | return -EFAULT; |
477 | /* | ||
478 | * rfc4340: 6.1. Change Options | ||
479 | */ | ||
480 | if (opt.dccpsf_len < 1) | ||
481 | return -EINVAL; | ||
477 | 482 | ||
478 | val = kmalloc(opt.dccpsf_len, GFP_KERNEL); | 483 | val = kmalloc(opt.dccpsf_len, GFP_KERNEL); |
479 | if (!val) | 484 | if (!val) |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index 91d3d96805d0..b12dae2b0b2d 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -1029,6 +1029,11 @@ skip: | |||
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | static inline bool inetdev_valid_mtu(unsigned mtu) | ||
1033 | { | ||
1034 | return mtu >= 68; | ||
1035 | } | ||
1036 | |||
1032 | /* Called only under RTNL semaphore */ | 1037 | /* Called only under RTNL semaphore */ |
1033 | 1038 | ||
1034 | static int inetdev_event(struct notifier_block *this, unsigned long event, | 1039 | static int inetdev_event(struct notifier_block *this, unsigned long event, |
@@ -1048,6 +1053,10 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1048 | IN_DEV_CONF_SET(in_dev, NOXFRM, 1); | 1053 | IN_DEV_CONF_SET(in_dev, NOXFRM, 1); |
1049 | IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); | 1054 | IN_DEV_CONF_SET(in_dev, NOPOLICY, 1); |
1050 | } | 1055 | } |
1056 | } else if (event == NETDEV_CHANGEMTU) { | ||
1057 | /* Re-enabling IP */ | ||
1058 | if (inetdev_valid_mtu(dev->mtu)) | ||
1059 | in_dev = inetdev_init(dev); | ||
1051 | } | 1060 | } |
1052 | goto out; | 1061 | goto out; |
1053 | } | 1062 | } |
@@ -1058,7 +1067,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1058 | dev->ip_ptr = NULL; | 1067 | dev->ip_ptr = NULL; |
1059 | break; | 1068 | break; |
1060 | case NETDEV_UP: | 1069 | case NETDEV_UP: |
1061 | if (dev->mtu < 68) | 1070 | if (!inetdev_valid_mtu(dev->mtu)) |
1062 | break; | 1071 | break; |
1063 | if (dev->flags & IFF_LOOPBACK) { | 1072 | if (dev->flags & IFF_LOOPBACK) { |
1064 | struct in_ifaddr *ifa; | 1073 | struct in_ifaddr *ifa; |
@@ -1080,9 +1089,9 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1080 | ip_mc_down(in_dev); | 1089 | ip_mc_down(in_dev); |
1081 | break; | 1090 | break; |
1082 | case NETDEV_CHANGEMTU: | 1091 | case NETDEV_CHANGEMTU: |
1083 | if (dev->mtu >= 68) | 1092 | if (inetdev_valid_mtu(dev->mtu)) |
1084 | break; | 1093 | break; |
1085 | /* MTU falled under 68, disable IP */ | 1094 | /* disable IP when MTU is not enough */ |
1086 | case NETDEV_UNREGISTER: | 1095 | case NETDEV_UNREGISTER: |
1087 | inetdev_destroy(in_dev); | 1096 | inetdev_destroy(in_dev); |
1088 | break; | 1097 | break; |
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c index 4e73e5708e70..21515d4c49eb 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c | |||
@@ -575,7 +575,7 @@ static int esp_init_state(struct xfrm_state *x) | |||
575 | crypto_aead_ivsize(aead); | 575 | crypto_aead_ivsize(aead); |
576 | if (x->props.mode == XFRM_MODE_TUNNEL) | 576 | if (x->props.mode == XFRM_MODE_TUNNEL) |
577 | x->props.header_len += sizeof(struct iphdr); | 577 | x->props.header_len += sizeof(struct iphdr); |
578 | else if (x->props.mode == XFRM_MODE_BEET) | 578 | else if (x->props.mode == XFRM_MODE_BEET && x->sel.family != AF_INET6) |
579 | x->props.header_len += IPV4_BEET_PHMAXLEN; | 579 | x->props.header_len += IPV4_BEET_PHMAXLEN; |
580 | if (x->encap) { | 580 | if (x->encap) { |
581 | struct xfrm_encap_tmpl *encap = x->encap; | 581 | struct xfrm_encap_tmpl *encap = x->encap; |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 860558633b2c..55c355e63234 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -204,18 +204,22 @@ static struct sock *icmp_sk(struct net *net) | |||
204 | return net->ipv4.icmp_sk[smp_processor_id()]; | 204 | return net->ipv4.icmp_sk[smp_processor_id()]; |
205 | } | 205 | } |
206 | 206 | ||
207 | static inline int icmp_xmit_lock(struct sock *sk) | 207 | static inline struct sock *icmp_xmit_lock(struct net *net) |
208 | { | 208 | { |
209 | struct sock *sk; | ||
210 | |||
209 | local_bh_disable(); | 211 | local_bh_disable(); |
210 | 212 | ||
213 | sk = icmp_sk(net); | ||
214 | |||
211 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { | 215 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { |
212 | /* This can happen if the output path signals a | 216 | /* This can happen if the output path signals a |
213 | * dst_link_failure() for an outgoing ICMP packet. | 217 | * dst_link_failure() for an outgoing ICMP packet. |
214 | */ | 218 | */ |
215 | local_bh_enable(); | 219 | local_bh_enable(); |
216 | return 1; | 220 | return NULL; |
217 | } | 221 | } |
218 | return 0; | 222 | return sk; |
219 | } | 223 | } |
220 | 224 | ||
221 | static inline void icmp_xmit_unlock(struct sock *sk) | 225 | static inline void icmp_xmit_unlock(struct sock *sk) |
@@ -354,15 +358,17 @@ static void icmp_reply(struct icmp_bxm *icmp_param, struct sk_buff *skb) | |||
354 | struct ipcm_cookie ipc; | 358 | struct ipcm_cookie ipc; |
355 | struct rtable *rt = skb->rtable; | 359 | struct rtable *rt = skb->rtable; |
356 | struct net *net = dev_net(rt->u.dst.dev); | 360 | struct net *net = dev_net(rt->u.dst.dev); |
357 | struct sock *sk = icmp_sk(net); | 361 | struct sock *sk; |
358 | struct inet_sock *inet = inet_sk(sk); | 362 | struct inet_sock *inet; |
359 | __be32 daddr; | 363 | __be32 daddr; |
360 | 364 | ||
361 | if (ip_options_echo(&icmp_param->replyopts, skb)) | 365 | if (ip_options_echo(&icmp_param->replyopts, skb)) |
362 | return; | 366 | return; |
363 | 367 | ||
364 | if (icmp_xmit_lock(sk)) | 368 | sk = icmp_xmit_lock(net); |
369 | if (sk == NULL) | ||
365 | return; | 370 | return; |
371 | inet = inet_sk(sk); | ||
366 | 372 | ||
367 | icmp_param->data.icmph.checksum = 0; | 373 | icmp_param->data.icmph.checksum = 0; |
368 | 374 | ||
@@ -419,7 +425,6 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
419 | if (!rt) | 425 | if (!rt) |
420 | goto out; | 426 | goto out; |
421 | net = dev_net(rt->u.dst.dev); | 427 | net = dev_net(rt->u.dst.dev); |
422 | sk = icmp_sk(net); | ||
423 | 428 | ||
424 | /* | 429 | /* |
425 | * Find the original header. It is expected to be valid, of course. | 430 | * Find the original header. It is expected to be valid, of course. |
@@ -483,7 +488,8 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info) | |||
483 | } | 488 | } |
484 | } | 489 | } |
485 | 490 | ||
486 | if (icmp_xmit_lock(sk)) | 491 | sk = icmp_xmit_lock(net); |
492 | if (sk == NULL) | ||
487 | return; | 493 | return; |
488 | 494 | ||
489 | /* | 495 | /* |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 6203ece53606..f70fac612596 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -289,6 +289,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) | |||
289 | struct rtable *rt; | 289 | struct rtable *rt; |
290 | struct iphdr *pip; | 290 | struct iphdr *pip; |
291 | struct igmpv3_report *pig; | 291 | struct igmpv3_report *pig; |
292 | struct net *net = dev_net(dev); | ||
292 | 293 | ||
293 | skb = alloc_skb(size + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); | 294 | skb = alloc_skb(size + LL_ALLOCATED_SPACE(dev), GFP_ATOMIC); |
294 | if (skb == NULL) | 295 | if (skb == NULL) |
@@ -299,7 +300,7 @@ static struct sk_buff *igmpv3_newpack(struct net_device *dev, int size) | |||
299 | .nl_u = { .ip4_u = { | 300 | .nl_u = { .ip4_u = { |
300 | .daddr = IGMPV3_ALL_MCR } }, | 301 | .daddr = IGMPV3_ALL_MCR } }, |
301 | .proto = IPPROTO_IGMP }; | 302 | .proto = IPPROTO_IGMP }; |
302 | if (ip_route_output_key(&init_net, &rt, &fl)) { | 303 | if (ip_route_output_key(net, &rt, &fl)) { |
303 | kfree_skb(skb); | 304 | kfree_skb(skb); |
304 | return NULL; | 305 | return NULL; |
305 | } | 306 | } |
@@ -629,6 +630,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, | |||
629 | struct igmphdr *ih; | 630 | struct igmphdr *ih; |
630 | struct rtable *rt; | 631 | struct rtable *rt; |
631 | struct net_device *dev = in_dev->dev; | 632 | struct net_device *dev = in_dev->dev; |
633 | struct net *net = dev_net(dev); | ||
632 | __be32 group = pmc ? pmc->multiaddr : 0; | 634 | __be32 group = pmc ? pmc->multiaddr : 0; |
633 | __be32 dst; | 635 | __be32 dst; |
634 | 636 | ||
@@ -643,7 +645,7 @@ static int igmp_send_report(struct in_device *in_dev, struct ip_mc_list *pmc, | |||
643 | struct flowi fl = { .oif = dev->ifindex, | 645 | struct flowi fl = { .oif = dev->ifindex, |
644 | .nl_u = { .ip4_u = { .daddr = dst } }, | 646 | .nl_u = { .ip4_u = { .daddr = dst } }, |
645 | .proto = IPPROTO_IGMP }; | 647 | .proto = IPPROTO_IGMP }; |
646 | if (ip_route_output_key(&init_net, &rt, &fl)) | 648 | if (ip_route_output_key(net, &rt, &fl)) |
647 | return -1; | 649 | return -1; |
648 | } | 650 | } |
649 | if (rt->rt_src == 0) { | 651 | if (rt->rt_src == 0) { |
@@ -1196,9 +1198,6 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) | |||
1196 | 1198 | ||
1197 | ASSERT_RTNL(); | 1199 | ASSERT_RTNL(); |
1198 | 1200 | ||
1199 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1200 | return; | ||
1201 | |||
1202 | for (im=in_dev->mc_list; im; im=im->next) { | 1201 | for (im=in_dev->mc_list; im; im=im->next) { |
1203 | if (im->multiaddr == addr) { | 1202 | if (im->multiaddr == addr) { |
1204 | im->users++; | 1203 | im->users++; |
@@ -1278,9 +1277,6 @@ void ip_mc_dec_group(struct in_device *in_dev, __be32 addr) | |||
1278 | 1277 | ||
1279 | ASSERT_RTNL(); | 1278 | ASSERT_RTNL(); |
1280 | 1279 | ||
1281 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1282 | return; | ||
1283 | |||
1284 | for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) { | 1280 | for (ip=&in_dev->mc_list; (i=*ip)!=NULL; ip=&i->next) { |
1285 | if (i->multiaddr==addr) { | 1281 | if (i->multiaddr==addr) { |
1286 | if (--i->users == 0) { | 1282 | if (--i->users == 0) { |
@@ -1308,9 +1304,6 @@ void ip_mc_down(struct in_device *in_dev) | |||
1308 | 1304 | ||
1309 | ASSERT_RTNL(); | 1305 | ASSERT_RTNL(); |
1310 | 1306 | ||
1311 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1312 | return; | ||
1313 | |||
1314 | for (i=in_dev->mc_list; i; i=i->next) | 1307 | for (i=in_dev->mc_list; i; i=i->next) |
1315 | igmp_group_dropped(i); | 1308 | igmp_group_dropped(i); |
1316 | 1309 | ||
@@ -1331,9 +1324,6 @@ void ip_mc_init_dev(struct in_device *in_dev) | |||
1331 | { | 1324 | { |
1332 | ASSERT_RTNL(); | 1325 | ASSERT_RTNL(); |
1333 | 1326 | ||
1334 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1335 | return; | ||
1336 | |||
1337 | in_dev->mc_tomb = NULL; | 1327 | in_dev->mc_tomb = NULL; |
1338 | #ifdef CONFIG_IP_MULTICAST | 1328 | #ifdef CONFIG_IP_MULTICAST |
1339 | in_dev->mr_gq_running = 0; | 1329 | in_dev->mr_gq_running = 0; |
@@ -1357,9 +1347,6 @@ void ip_mc_up(struct in_device *in_dev) | |||
1357 | 1347 | ||
1358 | ASSERT_RTNL(); | 1348 | ASSERT_RTNL(); |
1359 | 1349 | ||
1360 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1361 | return; | ||
1362 | |||
1363 | ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); | 1350 | ip_mc_inc_group(in_dev, IGMP_ALL_HOSTS); |
1364 | 1351 | ||
1365 | for (i=in_dev->mc_list; i; i=i->next) | 1352 | for (i=in_dev->mc_list; i; i=i->next) |
@@ -1376,9 +1363,6 @@ void ip_mc_destroy_dev(struct in_device *in_dev) | |||
1376 | 1363 | ||
1377 | ASSERT_RTNL(); | 1364 | ASSERT_RTNL(); |
1378 | 1365 | ||
1379 | if (!net_eq(dev_net(in_dev->dev), &init_net)) | ||
1380 | return; | ||
1381 | |||
1382 | /* Deactivate timers */ | 1366 | /* Deactivate timers */ |
1383 | ip_mc_down(in_dev); | 1367 | ip_mc_down(in_dev); |
1384 | 1368 | ||
@@ -1395,7 +1379,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev) | |||
1395 | write_unlock_bh(&in_dev->mc_list_lock); | 1379 | write_unlock_bh(&in_dev->mc_list_lock); |
1396 | } | 1380 | } |
1397 | 1381 | ||
1398 | static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr) | 1382 | static struct in_device *ip_mc_find_dev(struct net *net, struct ip_mreqn *imr) |
1399 | { | 1383 | { |
1400 | struct flowi fl = { .nl_u = { .ip4_u = | 1384 | struct flowi fl = { .nl_u = { .ip4_u = |
1401 | { .daddr = imr->imr_multiaddr.s_addr } } }; | 1385 | { .daddr = imr->imr_multiaddr.s_addr } } }; |
@@ -1404,19 +1388,19 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr) | |||
1404 | struct in_device *idev = NULL; | 1388 | struct in_device *idev = NULL; |
1405 | 1389 | ||
1406 | if (imr->imr_ifindex) { | 1390 | if (imr->imr_ifindex) { |
1407 | idev = inetdev_by_index(&init_net, imr->imr_ifindex); | 1391 | idev = inetdev_by_index(net, imr->imr_ifindex); |
1408 | if (idev) | 1392 | if (idev) |
1409 | __in_dev_put(idev); | 1393 | __in_dev_put(idev); |
1410 | return idev; | 1394 | return idev; |
1411 | } | 1395 | } |
1412 | if (imr->imr_address.s_addr) { | 1396 | if (imr->imr_address.s_addr) { |
1413 | dev = ip_dev_find(&init_net, imr->imr_address.s_addr); | 1397 | dev = ip_dev_find(net, imr->imr_address.s_addr); |
1414 | if (!dev) | 1398 | if (!dev) |
1415 | return NULL; | 1399 | return NULL; |
1416 | dev_put(dev); | 1400 | dev_put(dev); |
1417 | } | 1401 | } |
1418 | 1402 | ||
1419 | if (!dev && !ip_route_output_key(&init_net, &rt, &fl)) { | 1403 | if (!dev && !ip_route_output_key(net, &rt, &fl)) { |
1420 | dev = rt->u.dst.dev; | 1404 | dev = rt->u.dst.dev; |
1421 | ip_rt_put(rt); | 1405 | ip_rt_put(rt); |
1422 | } | 1406 | } |
@@ -1754,18 +1738,16 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr) | |||
1754 | struct ip_mc_socklist *iml=NULL, *i; | 1738 | struct ip_mc_socklist *iml=NULL, *i; |
1755 | struct in_device *in_dev; | 1739 | struct in_device *in_dev; |
1756 | struct inet_sock *inet = inet_sk(sk); | 1740 | struct inet_sock *inet = inet_sk(sk); |
1741 | struct net *net = sock_net(sk); | ||
1757 | int ifindex; | 1742 | int ifindex; |
1758 | int count = 0; | 1743 | int count = 0; |
1759 | 1744 | ||
1760 | if (!ipv4_is_multicast(addr)) | 1745 | if (!ipv4_is_multicast(addr)) |
1761 | return -EINVAL; | 1746 | return -EINVAL; |
1762 | 1747 | ||
1763 | if (!net_eq(sock_net(sk), &init_net)) | ||
1764 | return -EPROTONOSUPPORT; | ||
1765 | |||
1766 | rtnl_lock(); | 1748 | rtnl_lock(); |
1767 | 1749 | ||
1768 | in_dev = ip_mc_find_dev(imr); | 1750 | in_dev = ip_mc_find_dev(net, imr); |
1769 | 1751 | ||
1770 | if (!in_dev) { | 1752 | if (!in_dev) { |
1771 | iml = NULL; | 1753 | iml = NULL; |
@@ -1827,15 +1809,13 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr) | |||
1827 | struct inet_sock *inet = inet_sk(sk); | 1809 | struct inet_sock *inet = inet_sk(sk); |
1828 | struct ip_mc_socklist *iml, **imlp; | 1810 | struct ip_mc_socklist *iml, **imlp; |
1829 | struct in_device *in_dev; | 1811 | struct in_device *in_dev; |
1812 | struct net *net = sock_net(sk); | ||
1830 | __be32 group = imr->imr_multiaddr.s_addr; | 1813 | __be32 group = imr->imr_multiaddr.s_addr; |
1831 | u32 ifindex; | 1814 | u32 ifindex; |
1832 | int ret = -EADDRNOTAVAIL; | 1815 | int ret = -EADDRNOTAVAIL; |
1833 | 1816 | ||
1834 | if (!net_eq(sock_net(sk), &init_net)) | ||
1835 | return -EPROTONOSUPPORT; | ||
1836 | |||
1837 | rtnl_lock(); | 1817 | rtnl_lock(); |
1838 | in_dev = ip_mc_find_dev(imr); | 1818 | in_dev = ip_mc_find_dev(net, imr); |
1839 | ifindex = imr->imr_ifindex; | 1819 | ifindex = imr->imr_ifindex; |
1840 | for (imlp = &inet->mc_list; (iml = *imlp) != NULL; imlp = &iml->next) { | 1820 | for (imlp = &inet->mc_list; (iml = *imlp) != NULL; imlp = &iml->next) { |
1841 | if (iml->multi.imr_multiaddr.s_addr != group) | 1821 | if (iml->multi.imr_multiaddr.s_addr != group) |
@@ -1873,21 +1853,19 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct | |||
1873 | struct in_device *in_dev = NULL; | 1853 | struct in_device *in_dev = NULL; |
1874 | struct inet_sock *inet = inet_sk(sk); | 1854 | struct inet_sock *inet = inet_sk(sk); |
1875 | struct ip_sf_socklist *psl; | 1855 | struct ip_sf_socklist *psl; |
1856 | struct net *net = sock_net(sk); | ||
1876 | int leavegroup = 0; | 1857 | int leavegroup = 0; |
1877 | int i, j, rv; | 1858 | int i, j, rv; |
1878 | 1859 | ||
1879 | if (!ipv4_is_multicast(addr)) | 1860 | if (!ipv4_is_multicast(addr)) |
1880 | return -EINVAL; | 1861 | return -EINVAL; |
1881 | 1862 | ||
1882 | if (!net_eq(sock_net(sk), &init_net)) | ||
1883 | return -EPROTONOSUPPORT; | ||
1884 | |||
1885 | rtnl_lock(); | 1863 | rtnl_lock(); |
1886 | 1864 | ||
1887 | imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr; | 1865 | imr.imr_multiaddr.s_addr = mreqs->imr_multiaddr; |
1888 | imr.imr_address.s_addr = mreqs->imr_interface; | 1866 | imr.imr_address.s_addr = mreqs->imr_interface; |
1889 | imr.imr_ifindex = ifindex; | 1867 | imr.imr_ifindex = ifindex; |
1890 | in_dev = ip_mc_find_dev(&imr); | 1868 | in_dev = ip_mc_find_dev(net, &imr); |
1891 | 1869 | ||
1892 | if (!in_dev) { | 1870 | if (!in_dev) { |
1893 | err = -ENODEV; | 1871 | err = -ENODEV; |
@@ -2007,6 +1985,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex) | |||
2007 | struct in_device *in_dev; | 1985 | struct in_device *in_dev; |
2008 | struct inet_sock *inet = inet_sk(sk); | 1986 | struct inet_sock *inet = inet_sk(sk); |
2009 | struct ip_sf_socklist *newpsl, *psl; | 1987 | struct ip_sf_socklist *newpsl, *psl; |
1988 | struct net *net = sock_net(sk); | ||
2010 | int leavegroup = 0; | 1989 | int leavegroup = 0; |
2011 | 1990 | ||
2012 | if (!ipv4_is_multicast(addr)) | 1991 | if (!ipv4_is_multicast(addr)) |
@@ -2015,15 +1994,12 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex) | |||
2015 | msf->imsf_fmode != MCAST_EXCLUDE) | 1994 | msf->imsf_fmode != MCAST_EXCLUDE) |
2016 | return -EINVAL; | 1995 | return -EINVAL; |
2017 | 1996 | ||
2018 | if (!net_eq(sock_net(sk), &init_net)) | ||
2019 | return -EPROTONOSUPPORT; | ||
2020 | |||
2021 | rtnl_lock(); | 1997 | rtnl_lock(); |
2022 | 1998 | ||
2023 | imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; | 1999 | imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; |
2024 | imr.imr_address.s_addr = msf->imsf_interface; | 2000 | imr.imr_address.s_addr = msf->imsf_interface; |
2025 | imr.imr_ifindex = ifindex; | 2001 | imr.imr_ifindex = ifindex; |
2026 | in_dev = ip_mc_find_dev(&imr); | 2002 | in_dev = ip_mc_find_dev(net, &imr); |
2027 | 2003 | ||
2028 | if (!in_dev) { | 2004 | if (!in_dev) { |
2029 | err = -ENODEV; | 2005 | err = -ENODEV; |
@@ -2094,19 +2070,17 @@ int ip_mc_msfget(struct sock *sk, struct ip_msfilter *msf, | |||
2094 | struct in_device *in_dev; | 2070 | struct in_device *in_dev; |
2095 | struct inet_sock *inet = inet_sk(sk); | 2071 | struct inet_sock *inet = inet_sk(sk); |
2096 | struct ip_sf_socklist *psl; | 2072 | struct ip_sf_socklist *psl; |
2073 | struct net *net = sock_net(sk); | ||
2097 | 2074 | ||
2098 | if (!ipv4_is_multicast(addr)) | 2075 | if (!ipv4_is_multicast(addr)) |
2099 | return -EINVAL; | 2076 | return -EINVAL; |
2100 | 2077 | ||
2101 | if (!net_eq(sock_net(sk), &init_net)) | ||
2102 | return -EPROTONOSUPPORT; | ||
2103 | |||
2104 | rtnl_lock(); | 2078 | rtnl_lock(); |
2105 | 2079 | ||
2106 | imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; | 2080 | imr.imr_multiaddr.s_addr = msf->imsf_multiaddr; |
2107 | imr.imr_address.s_addr = msf->imsf_interface; | 2081 | imr.imr_address.s_addr = msf->imsf_interface; |
2108 | imr.imr_ifindex = 0; | 2082 | imr.imr_ifindex = 0; |
2109 | in_dev = ip_mc_find_dev(&imr); | 2083 | in_dev = ip_mc_find_dev(net, &imr); |
2110 | 2084 | ||
2111 | if (!in_dev) { | 2085 | if (!in_dev) { |
2112 | err = -ENODEV; | 2086 | err = -ENODEV; |
@@ -2163,9 +2137,6 @@ int ip_mc_gsfget(struct sock *sk, struct group_filter *gsf, | |||
2163 | if (!ipv4_is_multicast(addr)) | 2137 | if (!ipv4_is_multicast(addr)) |
2164 | return -EINVAL; | 2138 | return -EINVAL; |
2165 | 2139 | ||
2166 | if (!net_eq(sock_net(sk), &init_net)) | ||
2167 | return -EPROTONOSUPPORT; | ||
2168 | |||
2169 | rtnl_lock(); | 2140 | rtnl_lock(); |
2170 | 2141 | ||
2171 | err = -EADDRNOTAVAIL; | 2142 | err = -EADDRNOTAVAIL; |
@@ -2246,19 +2217,17 @@ void ip_mc_drop_socket(struct sock *sk) | |||
2246 | { | 2217 | { |
2247 | struct inet_sock *inet = inet_sk(sk); | 2218 | struct inet_sock *inet = inet_sk(sk); |
2248 | struct ip_mc_socklist *iml; | 2219 | struct ip_mc_socklist *iml; |
2220 | struct net *net = sock_net(sk); | ||
2249 | 2221 | ||
2250 | if (inet->mc_list == NULL) | 2222 | if (inet->mc_list == NULL) |
2251 | return; | 2223 | return; |
2252 | 2224 | ||
2253 | if (!net_eq(sock_net(sk), &init_net)) | ||
2254 | return; | ||
2255 | |||
2256 | rtnl_lock(); | 2225 | rtnl_lock(); |
2257 | while ((iml = inet->mc_list) != NULL) { | 2226 | while ((iml = inet->mc_list) != NULL) { |
2258 | struct in_device *in_dev; | 2227 | struct in_device *in_dev; |
2259 | inet->mc_list = iml->next; | 2228 | inet->mc_list = iml->next; |
2260 | 2229 | ||
2261 | in_dev = inetdev_by_index(&init_net, iml->multi.imr_ifindex); | 2230 | in_dev = inetdev_by_index(net, iml->multi.imr_ifindex); |
2262 | (void) ip_mc_leave_src(sk, iml, in_dev); | 2231 | (void) ip_mc_leave_src(sk, iml, in_dev); |
2263 | if (in_dev != NULL) { | 2232 | if (in_dev != NULL) { |
2264 | ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr); | 2233 | ip_mc_dec_group(in_dev, iml->multi.imr_multiaddr.s_addr); |
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index d985bd613d25..743f011b9a84 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
@@ -409,3 +409,38 @@ out: | |||
409 | } | 409 | } |
410 | 410 | ||
411 | EXPORT_SYMBOL_GPL(inet_twdr_twcal_tick); | 411 | EXPORT_SYMBOL_GPL(inet_twdr_twcal_tick); |
412 | |||
413 | void inet_twsk_purge(struct net *net, struct inet_hashinfo *hashinfo, | ||
414 | struct inet_timewait_death_row *twdr, int family) | ||
415 | { | ||
416 | struct inet_timewait_sock *tw; | ||
417 | struct sock *sk; | ||
418 | struct hlist_node *node; | ||
419 | int h; | ||
420 | |||
421 | local_bh_disable(); | ||
422 | for (h = 0; h < (hashinfo->ehash_size); h++) { | ||
423 | struct inet_ehash_bucket *head = | ||
424 | inet_ehash_bucket(hashinfo, h); | ||
425 | rwlock_t *lock = inet_ehash_lockp(hashinfo, h); | ||
426 | restart: | ||
427 | write_lock(lock); | ||
428 | sk_for_each(sk, node, &head->twchain) { | ||
429 | |||
430 | tw = inet_twsk(sk); | ||
431 | if (!net_eq(twsk_net(tw), net) || | ||
432 | tw->tw_family != family) | ||
433 | continue; | ||
434 | |||
435 | atomic_inc(&tw->tw_refcnt); | ||
436 | write_unlock(lock); | ||
437 | inet_twsk_deschedule(tw, twdr); | ||
438 | inet_twsk_put(tw); | ||
439 | |||
440 | goto restart; | ||
441 | } | ||
442 | write_unlock(lock); | ||
443 | } | ||
444 | local_bh_enable(); | ||
445 | } | ||
446 | EXPORT_SYMBOL_GPL(inet_twsk_purge); | ||
diff --git a/net/ipv4/ipvs/ip_vs_app.c b/net/ipv4/ipvs/ip_vs_app.c index 1f1897a1a702..201b8ea3020d 100644 --- a/net/ipv4/ipvs/ip_vs_app.c +++ b/net/ipv4/ipvs/ip_vs_app.c | |||
@@ -608,7 +608,7 @@ int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri, | |||
608 | } | 608 | } |
609 | 609 | ||
610 | 610 | ||
611 | int ip_vs_app_init(void) | 611 | int __init ip_vs_app_init(void) |
612 | { | 612 | { |
613 | /* we will replace it with proc_net_ipvs_create() soon */ | 613 | /* we will replace it with proc_net_ipvs_create() soon */ |
614 | proc_net_fops_create(&init_net, "ip_vs_app", 0, &ip_vs_app_fops); | 614 | proc_net_fops_create(&init_net, "ip_vs_app", 0, &ip_vs_app_fops); |
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c index f8bdae47a77f..44a6872dc245 100644 --- a/net/ipv4/ipvs/ip_vs_conn.c +++ b/net/ipv4/ipvs/ip_vs_conn.c | |||
@@ -965,7 +965,7 @@ static void ip_vs_conn_flush(void) | |||
965 | } | 965 | } |
966 | 966 | ||
967 | 967 | ||
968 | int ip_vs_conn_init(void) | 968 | int __init ip_vs_conn_init(void) |
969 | { | 969 | { |
970 | int idx; | 970 | int idx; |
971 | 971 | ||
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c index 9a5ace0b4dd6..6379705a8dcb 100644 --- a/net/ipv4/ipvs/ip_vs_ctl.c +++ b/net/ipv4/ipvs/ip_vs_ctl.c | |||
@@ -683,9 +683,22 @@ static void | |||
683 | ip_vs_zero_stats(struct ip_vs_stats *stats) | 683 | ip_vs_zero_stats(struct ip_vs_stats *stats) |
684 | { | 684 | { |
685 | spin_lock_bh(&stats->lock); | 685 | spin_lock_bh(&stats->lock); |
686 | memset(stats, 0, (char *)&stats->lock - (char *)stats); | 686 | |
687 | spin_unlock_bh(&stats->lock); | 687 | stats->conns = 0; |
688 | stats->inpkts = 0; | ||
689 | stats->outpkts = 0; | ||
690 | stats->inbytes = 0; | ||
691 | stats->outbytes = 0; | ||
692 | |||
693 | stats->cps = 0; | ||
694 | stats->inpps = 0; | ||
695 | stats->outpps = 0; | ||
696 | stats->inbps = 0; | ||
697 | stats->outbps = 0; | ||
698 | |||
688 | ip_vs_zero_estimator(stats); | 699 | ip_vs_zero_estimator(stats); |
700 | |||
701 | spin_unlock_bh(&stats->lock); | ||
689 | } | 702 | } |
690 | 703 | ||
691 | /* | 704 | /* |
@@ -1589,7 +1602,7 @@ static struct ctl_table vs_vars[] = { | |||
1589 | { .ctl_name = 0 } | 1602 | { .ctl_name = 0 } |
1590 | }; | 1603 | }; |
1591 | 1604 | ||
1592 | struct ctl_path net_vs_ctl_path[] = { | 1605 | const struct ctl_path net_vs_ctl_path[] = { |
1593 | { .procname = "net", .ctl_name = CTL_NET, }, | 1606 | { .procname = "net", .ctl_name = CTL_NET, }, |
1594 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, | 1607 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, |
1595 | { .procname = "vs", }, | 1608 | { .procname = "vs", }, |
@@ -1784,7 +1797,9 @@ static const struct file_operations ip_vs_info_fops = { | |||
1784 | 1797 | ||
1785 | #endif | 1798 | #endif |
1786 | 1799 | ||
1787 | struct ip_vs_stats ip_vs_stats; | 1800 | struct ip_vs_stats ip_vs_stats = { |
1801 | .lock = __SPIN_LOCK_UNLOCKED(ip_vs_stats.lock), | ||
1802 | }; | ||
1788 | 1803 | ||
1789 | #ifdef CONFIG_PROC_FS | 1804 | #ifdef CONFIG_PROC_FS |
1790 | static int ip_vs_stats_show(struct seq_file *seq, void *v) | 1805 | static int ip_vs_stats_show(struct seq_file *seq, void *v) |
@@ -2306,7 +2321,7 @@ static struct nf_sockopt_ops ip_vs_sockopts = { | |||
2306 | }; | 2321 | }; |
2307 | 2322 | ||
2308 | 2323 | ||
2309 | int ip_vs_control_init(void) | 2324 | int __init ip_vs_control_init(void) |
2310 | { | 2325 | { |
2311 | int ret; | 2326 | int ret; |
2312 | int idx; | 2327 | int idx; |
@@ -2333,8 +2348,6 @@ int ip_vs_control_init(void) | |||
2333 | INIT_LIST_HEAD(&ip_vs_rtable[idx]); | 2348 | INIT_LIST_HEAD(&ip_vs_rtable[idx]); |
2334 | } | 2349 | } |
2335 | 2350 | ||
2336 | memset(&ip_vs_stats, 0, sizeof(ip_vs_stats)); | ||
2337 | spin_lock_init(&ip_vs_stats.lock); | ||
2338 | ip_vs_new_estimator(&ip_vs_stats); | 2351 | ip_vs_new_estimator(&ip_vs_stats); |
2339 | 2352 | ||
2340 | /* Hook the defense timer */ | 2353 | /* Hook the defense timer */ |
diff --git a/net/ipv4/ipvs/ip_vs_dh.c b/net/ipv4/ipvs/ip_vs_dh.c index 8afc1503ed20..fa66824d264f 100644 --- a/net/ipv4/ipvs/ip_vs_dh.c +++ b/net/ipv4/ipvs/ip_vs_dh.c | |||
@@ -233,6 +233,7 @@ static struct ip_vs_scheduler ip_vs_dh_scheduler = | |||
233 | .name = "dh", | 233 | .name = "dh", |
234 | .refcnt = ATOMIC_INIT(0), | 234 | .refcnt = ATOMIC_INIT(0), |
235 | .module = THIS_MODULE, | 235 | .module = THIS_MODULE, |
236 | .n_list = LIST_HEAD_INIT(ip_vs_dh_scheduler.n_list), | ||
236 | .init_service = ip_vs_dh_init_svc, | 237 | .init_service = ip_vs_dh_init_svc, |
237 | .done_service = ip_vs_dh_done_svc, | 238 | .done_service = ip_vs_dh_done_svc, |
238 | .update_service = ip_vs_dh_update_svc, | 239 | .update_service = ip_vs_dh_update_svc, |
@@ -242,7 +243,6 @@ static struct ip_vs_scheduler ip_vs_dh_scheduler = | |||
242 | 243 | ||
243 | static int __init ip_vs_dh_init(void) | 244 | static int __init ip_vs_dh_init(void) |
244 | { | 245 | { |
245 | INIT_LIST_HEAD(&ip_vs_dh_scheduler.n_list); | ||
246 | return register_ip_vs_scheduler(&ip_vs_dh_scheduler); | 246 | return register_ip_vs_scheduler(&ip_vs_dh_scheduler); |
247 | } | 247 | } |
248 | 248 | ||
diff --git a/net/ipv4/ipvs/ip_vs_est.c b/net/ipv4/ipvs/ip_vs_est.c index bc04eedd6dbb..5a20f93bd7f9 100644 --- a/net/ipv4/ipvs/ip_vs_est.c +++ b/net/ipv4/ipvs/ip_vs_est.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/types.h> | 17 | #include <linux/types.h> |
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/sysctl.h> | 19 | #include <linux/sysctl.h> |
20 | #include <linux/list.h> | ||
20 | 21 | ||
21 | #include <net/ip_vs.h> | 22 | #include <net/ip_vs.h> |
22 | 23 | ||
@@ -44,28 +45,11 @@ | |||
44 | */ | 45 | */ |
45 | 46 | ||
46 | 47 | ||
47 | struct ip_vs_estimator | 48 | static void estimation_timer(unsigned long arg); |
48 | { | ||
49 | struct ip_vs_estimator *next; | ||
50 | struct ip_vs_stats *stats; | ||
51 | |||
52 | u32 last_conns; | ||
53 | u32 last_inpkts; | ||
54 | u32 last_outpkts; | ||
55 | u64 last_inbytes; | ||
56 | u64 last_outbytes; | ||
57 | |||
58 | u32 cps; | ||
59 | u32 inpps; | ||
60 | u32 outpps; | ||
61 | u32 inbps; | ||
62 | u32 outbps; | ||
63 | }; | ||
64 | |||
65 | 49 | ||
66 | static struct ip_vs_estimator *est_list = NULL; | 50 | static LIST_HEAD(est_list); |
67 | static DEFINE_RWLOCK(est_lock); | 51 | static DEFINE_SPINLOCK(est_lock); |
68 | static struct timer_list est_timer; | 52 | static DEFINE_TIMER(est_timer, estimation_timer, 0, 0); |
69 | 53 | ||
70 | static void estimation_timer(unsigned long arg) | 54 | static void estimation_timer(unsigned long arg) |
71 | { | 55 | { |
@@ -76,9 +60,9 @@ static void estimation_timer(unsigned long arg) | |||
76 | u64 n_inbytes, n_outbytes; | 60 | u64 n_inbytes, n_outbytes; |
77 | u32 rate; | 61 | u32 rate; |
78 | 62 | ||
79 | read_lock(&est_lock); | 63 | spin_lock(&est_lock); |
80 | for (e = est_list; e; e = e->next) { | 64 | list_for_each_entry(e, &est_list, list) { |
81 | s = e->stats; | 65 | s = container_of(e, struct ip_vs_stats, est); |
82 | 66 | ||
83 | spin_lock(&s->lock); | 67 | spin_lock(&s->lock); |
84 | n_conns = s->conns; | 68 | n_conns = s->conns; |
@@ -114,19 +98,16 @@ static void estimation_timer(unsigned long arg) | |||
114 | s->outbps = (e->outbps+0xF)>>5; | 98 | s->outbps = (e->outbps+0xF)>>5; |
115 | spin_unlock(&s->lock); | 99 | spin_unlock(&s->lock); |
116 | } | 100 | } |
117 | read_unlock(&est_lock); | 101 | spin_unlock(&est_lock); |
118 | mod_timer(&est_timer, jiffies + 2*HZ); | 102 | mod_timer(&est_timer, jiffies + 2*HZ); |
119 | } | 103 | } |
120 | 104 | ||
121 | int ip_vs_new_estimator(struct ip_vs_stats *stats) | 105 | void ip_vs_new_estimator(struct ip_vs_stats *stats) |
122 | { | 106 | { |
123 | struct ip_vs_estimator *est; | 107 | struct ip_vs_estimator *est = &stats->est; |
124 | 108 | ||
125 | est = kzalloc(sizeof(*est), GFP_KERNEL); | 109 | INIT_LIST_HEAD(&est->list); |
126 | if (est == NULL) | ||
127 | return -ENOMEM; | ||
128 | 110 | ||
129 | est->stats = stats; | ||
130 | est->last_conns = stats->conns; | 111 | est->last_conns = stats->conns; |
131 | est->cps = stats->cps<<10; | 112 | est->cps = stats->cps<<10; |
132 | 113 | ||
@@ -142,59 +123,40 @@ int ip_vs_new_estimator(struct ip_vs_stats *stats) | |||
142 | est->last_outbytes = stats->outbytes; | 123 | est->last_outbytes = stats->outbytes; |
143 | est->outbps = stats->outbps<<5; | 124 | est->outbps = stats->outbps<<5; |
144 | 125 | ||
145 | write_lock_bh(&est_lock); | 126 | spin_lock_bh(&est_lock); |
146 | est->next = est_list; | 127 | if (list_empty(&est_list)) |
147 | if (est->next == NULL) { | 128 | mod_timer(&est_timer, jiffies + 2 * HZ); |
148 | setup_timer(&est_timer, estimation_timer, 0); | 129 | list_add(&est->list, &est_list); |
149 | est_timer.expires = jiffies + 2*HZ; | 130 | spin_unlock_bh(&est_lock); |
150 | add_timer(&est_timer); | ||
151 | } | ||
152 | est_list = est; | ||
153 | write_unlock_bh(&est_lock); | ||
154 | return 0; | ||
155 | } | 131 | } |
156 | 132 | ||
157 | void ip_vs_kill_estimator(struct ip_vs_stats *stats) | 133 | void ip_vs_kill_estimator(struct ip_vs_stats *stats) |
158 | { | 134 | { |
159 | struct ip_vs_estimator *est, **pest; | 135 | struct ip_vs_estimator *est = &stats->est; |
160 | int killed = 0; | 136 | |
161 | 137 | spin_lock_bh(&est_lock); | |
162 | write_lock_bh(&est_lock); | 138 | list_del(&est->list); |
163 | pest = &est_list; | 139 | while (list_empty(&est_list) && try_to_del_timer_sync(&est_timer) < 0) { |
164 | while ((est=*pest) != NULL) { | 140 | spin_unlock_bh(&est_lock); |
165 | if (est->stats != stats) { | 141 | cpu_relax(); |
166 | pest = &est->next; | 142 | spin_lock_bh(&est_lock); |
167 | continue; | ||
168 | } | ||
169 | *pest = est->next; | ||
170 | kfree(est); | ||
171 | killed++; | ||
172 | } | 143 | } |
173 | if (killed && est_list == NULL) | 144 | spin_unlock_bh(&est_lock); |
174 | del_timer_sync(&est_timer); | ||
175 | write_unlock_bh(&est_lock); | ||
176 | } | 145 | } |
177 | 146 | ||
178 | void ip_vs_zero_estimator(struct ip_vs_stats *stats) | 147 | void ip_vs_zero_estimator(struct ip_vs_stats *stats) |
179 | { | 148 | { |
180 | struct ip_vs_estimator *e; | 149 | struct ip_vs_estimator *est = &stats->est; |
181 | 150 | ||
182 | write_lock_bh(&est_lock); | 151 | /* set counters zero, caller must hold the stats->lock lock */ |
183 | for (e = est_list; e; e = e->next) { | 152 | est->last_inbytes = 0; |
184 | if (e->stats != stats) | 153 | est->last_outbytes = 0; |
185 | continue; | 154 | est->last_conns = 0; |
186 | 155 | est->last_inpkts = 0; | |
187 | /* set counters zero */ | 156 | est->last_outpkts = 0; |
188 | e->last_conns = 0; | 157 | est->cps = 0; |
189 | e->last_inpkts = 0; | 158 | est->inpps = 0; |
190 | e->last_outpkts = 0; | 159 | est->outpps = 0; |
191 | e->last_inbytes = 0; | 160 | est->inbps = 0; |
192 | e->last_outbytes = 0; | 161 | est->outbps = 0; |
193 | e->cps = 0; | ||
194 | e->inpps = 0; | ||
195 | e->outpps = 0; | ||
196 | e->inbps = 0; | ||
197 | e->outbps = 0; | ||
198 | } | ||
199 | write_unlock_bh(&est_lock); | ||
200 | } | 162 | } |
diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c index 0efa3db4b180..7a6a319f544a 100644 --- a/net/ipv4/ipvs/ip_vs_lblc.c +++ b/net/ipv4/ipvs/ip_vs_lblc.c | |||
@@ -539,6 +539,7 @@ static struct ip_vs_scheduler ip_vs_lblc_scheduler = | |||
539 | .name = "lblc", | 539 | .name = "lblc", |
540 | .refcnt = ATOMIC_INIT(0), | 540 | .refcnt = ATOMIC_INIT(0), |
541 | .module = THIS_MODULE, | 541 | .module = THIS_MODULE, |
542 | .n_list = LIST_HEAD_INIT(ip_vs_lblc_scheduler.n_list), | ||
542 | .init_service = ip_vs_lblc_init_svc, | 543 | .init_service = ip_vs_lblc_init_svc, |
543 | .done_service = ip_vs_lblc_done_svc, | 544 | .done_service = ip_vs_lblc_done_svc, |
544 | .update_service = ip_vs_lblc_update_svc, | 545 | .update_service = ip_vs_lblc_update_svc, |
@@ -550,7 +551,6 @@ static int __init ip_vs_lblc_init(void) | |||
550 | { | 551 | { |
551 | int ret; | 552 | int ret; |
552 | 553 | ||
553 | INIT_LIST_HEAD(&ip_vs_lblc_scheduler.n_list); | ||
554 | sysctl_header = register_sysctl_paths(net_vs_ctl_path, vs_vars_table); | 554 | sysctl_header = register_sysctl_paths(net_vs_ctl_path, vs_vars_table); |
555 | ret = register_ip_vs_scheduler(&ip_vs_lblc_scheduler); | 555 | ret = register_ip_vs_scheduler(&ip_vs_lblc_scheduler); |
556 | if (ret) | 556 | if (ret) |
diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c index 8e3bbeb45138..c234e73968a6 100644 --- a/net/ipv4/ipvs/ip_vs_lblcr.c +++ b/net/ipv4/ipvs/ip_vs_lblcr.c | |||
@@ -728,6 +728,7 @@ static struct ip_vs_scheduler ip_vs_lblcr_scheduler = | |||
728 | .name = "lblcr", | 728 | .name = "lblcr", |
729 | .refcnt = ATOMIC_INIT(0), | 729 | .refcnt = ATOMIC_INIT(0), |
730 | .module = THIS_MODULE, | 730 | .module = THIS_MODULE, |
731 | .n_list = LIST_HEAD_INIT(ip_vs_lblcr_scheduler.n_list), | ||
731 | .init_service = ip_vs_lblcr_init_svc, | 732 | .init_service = ip_vs_lblcr_init_svc, |
732 | .done_service = ip_vs_lblcr_done_svc, | 733 | .done_service = ip_vs_lblcr_done_svc, |
733 | .update_service = ip_vs_lblcr_update_svc, | 734 | .update_service = ip_vs_lblcr_update_svc, |
@@ -739,7 +740,6 @@ static int __init ip_vs_lblcr_init(void) | |||
739 | { | 740 | { |
740 | int ret; | 741 | int ret; |
741 | 742 | ||
742 | INIT_LIST_HEAD(&ip_vs_lblcr_scheduler.n_list); | ||
743 | sysctl_header = register_sysctl_paths(net_vs_ctl_path, vs_vars_table); | 743 | sysctl_header = register_sysctl_paths(net_vs_ctl_path, vs_vars_table); |
744 | ret = register_ip_vs_scheduler(&ip_vs_lblcr_scheduler); | 744 | ret = register_ip_vs_scheduler(&ip_vs_lblcr_scheduler); |
745 | if (ret) | 745 | if (ret) |
diff --git a/net/ipv4/ipvs/ip_vs_lc.c b/net/ipv4/ipvs/ip_vs_lc.c index ac9f08e065d5..ebcdbf75ac65 100644 --- a/net/ipv4/ipvs/ip_vs_lc.c +++ b/net/ipv4/ipvs/ip_vs_lc.c | |||
@@ -98,6 +98,7 @@ static struct ip_vs_scheduler ip_vs_lc_scheduler = { | |||
98 | .name = "lc", | 98 | .name = "lc", |
99 | .refcnt = ATOMIC_INIT(0), | 99 | .refcnt = ATOMIC_INIT(0), |
100 | .module = THIS_MODULE, | 100 | .module = THIS_MODULE, |
101 | .n_list = LIST_HEAD_INIT(ip_vs_lc_scheduler.n_list), | ||
101 | .init_service = ip_vs_lc_init_svc, | 102 | .init_service = ip_vs_lc_init_svc, |
102 | .done_service = ip_vs_lc_done_svc, | 103 | .done_service = ip_vs_lc_done_svc, |
103 | .update_service = ip_vs_lc_update_svc, | 104 | .update_service = ip_vs_lc_update_svc, |
@@ -107,7 +108,6 @@ static struct ip_vs_scheduler ip_vs_lc_scheduler = { | |||
107 | 108 | ||
108 | static int __init ip_vs_lc_init(void) | 109 | static int __init ip_vs_lc_init(void) |
109 | { | 110 | { |
110 | INIT_LIST_HEAD(&ip_vs_lc_scheduler.n_list); | ||
111 | return register_ip_vs_scheduler(&ip_vs_lc_scheduler) ; | 111 | return register_ip_vs_scheduler(&ip_vs_lc_scheduler) ; |
112 | } | 112 | } |
113 | 113 | ||
diff --git a/net/ipv4/ipvs/ip_vs_nq.c b/net/ipv4/ipvs/ip_vs_nq.c index a46bf258d420..92f3a6770031 100644 --- a/net/ipv4/ipvs/ip_vs_nq.c +++ b/net/ipv4/ipvs/ip_vs_nq.c | |||
@@ -136,6 +136,7 @@ static struct ip_vs_scheduler ip_vs_nq_scheduler = | |||
136 | .name = "nq", | 136 | .name = "nq", |
137 | .refcnt = ATOMIC_INIT(0), | 137 | .refcnt = ATOMIC_INIT(0), |
138 | .module = THIS_MODULE, | 138 | .module = THIS_MODULE, |
139 | .n_list = LIST_HEAD_INIT(ip_vs_nq_scheduler.n_list), | ||
139 | .init_service = ip_vs_nq_init_svc, | 140 | .init_service = ip_vs_nq_init_svc, |
140 | .done_service = ip_vs_nq_done_svc, | 141 | .done_service = ip_vs_nq_done_svc, |
141 | .update_service = ip_vs_nq_update_svc, | 142 | .update_service = ip_vs_nq_update_svc, |
@@ -145,7 +146,6 @@ static struct ip_vs_scheduler ip_vs_nq_scheduler = | |||
145 | 146 | ||
146 | static int __init ip_vs_nq_init(void) | 147 | static int __init ip_vs_nq_init(void) |
147 | { | 148 | { |
148 | INIT_LIST_HEAD(&ip_vs_nq_scheduler.n_list); | ||
149 | return register_ip_vs_scheduler(&ip_vs_nq_scheduler); | 149 | return register_ip_vs_scheduler(&ip_vs_nq_scheduler); |
150 | } | 150 | } |
151 | 151 | ||
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c index 876714f23d65..6099a88fc200 100644 --- a/net/ipv4/ipvs/ip_vs_proto.c +++ b/net/ipv4/ipvs/ip_vs_proto.c | |||
@@ -43,7 +43,7 @@ static struct ip_vs_protocol *ip_vs_proto_table[IP_VS_PROTO_TAB_SIZE]; | |||
43 | /* | 43 | /* |
44 | * register an ipvs protocol | 44 | * register an ipvs protocol |
45 | */ | 45 | */ |
46 | static int __used register_ip_vs_protocol(struct ip_vs_protocol *pp) | 46 | static int __used __init register_ip_vs_protocol(struct ip_vs_protocol *pp) |
47 | { | 47 | { |
48 | unsigned hash = IP_VS_PROTO_HASH(pp->protocol); | 48 | unsigned hash = IP_VS_PROTO_HASH(pp->protocol); |
49 | 49 | ||
@@ -190,7 +190,7 @@ ip_vs_tcpudp_debug_packet(struct ip_vs_protocol *pp, | |||
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | int ip_vs_protocol_init(void) | 193 | int __init ip_vs_protocol_init(void) |
194 | { | 194 | { |
195 | char protocols[64]; | 195 | char protocols[64]; |
196 | #define REGISTER_PROTOCOL(p) \ | 196 | #define REGISTER_PROTOCOL(p) \ |
diff --git a/net/ipv4/ipvs/ip_vs_rr.c b/net/ipv4/ipvs/ip_vs_rr.c index c8db12d39e61..358110d17e59 100644 --- a/net/ipv4/ipvs/ip_vs_rr.c +++ b/net/ipv4/ipvs/ip_vs_rr.c | |||
@@ -94,6 +94,7 @@ static struct ip_vs_scheduler ip_vs_rr_scheduler = { | |||
94 | .name = "rr", /* name */ | 94 | .name = "rr", /* name */ |
95 | .refcnt = ATOMIC_INIT(0), | 95 | .refcnt = ATOMIC_INIT(0), |
96 | .module = THIS_MODULE, | 96 | .module = THIS_MODULE, |
97 | .n_list = LIST_HEAD_INIT(ip_vs_rr_scheduler.n_list), | ||
97 | .init_service = ip_vs_rr_init_svc, | 98 | .init_service = ip_vs_rr_init_svc, |
98 | .done_service = ip_vs_rr_done_svc, | 99 | .done_service = ip_vs_rr_done_svc, |
99 | .update_service = ip_vs_rr_update_svc, | 100 | .update_service = ip_vs_rr_update_svc, |
@@ -102,7 +103,6 @@ static struct ip_vs_scheduler ip_vs_rr_scheduler = { | |||
102 | 103 | ||
103 | static int __init ip_vs_rr_init(void) | 104 | static int __init ip_vs_rr_init(void) |
104 | { | 105 | { |
105 | INIT_LIST_HEAD(&ip_vs_rr_scheduler.n_list); | ||
106 | return register_ip_vs_scheduler(&ip_vs_rr_scheduler); | 106 | return register_ip_vs_scheduler(&ip_vs_rr_scheduler); |
107 | } | 107 | } |
108 | 108 | ||
diff --git a/net/ipv4/ipvs/ip_vs_sched.c b/net/ipv4/ipvs/ip_vs_sched.c index b64767309855..a46ad9e35016 100644 --- a/net/ipv4/ipvs/ip_vs_sched.c +++ b/net/ipv4/ipvs/ip_vs_sched.c | |||
@@ -184,7 +184,7 @@ int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler) | |||
184 | 184 | ||
185 | write_lock_bh(&__ip_vs_sched_lock); | 185 | write_lock_bh(&__ip_vs_sched_lock); |
186 | 186 | ||
187 | if (scheduler->n_list.next != &scheduler->n_list) { | 187 | if (!list_empty(&scheduler->n_list)) { |
188 | write_unlock_bh(&__ip_vs_sched_lock); | 188 | write_unlock_bh(&__ip_vs_sched_lock); |
189 | ip_vs_use_count_dec(); | 189 | ip_vs_use_count_dec(); |
190 | IP_VS_ERR("register_ip_vs_scheduler(): [%s] scheduler " | 190 | IP_VS_ERR("register_ip_vs_scheduler(): [%s] scheduler " |
@@ -229,7 +229,7 @@ int unregister_ip_vs_scheduler(struct ip_vs_scheduler *scheduler) | |||
229 | } | 229 | } |
230 | 230 | ||
231 | write_lock_bh(&__ip_vs_sched_lock); | 231 | write_lock_bh(&__ip_vs_sched_lock); |
232 | if (scheduler->n_list.next == &scheduler->n_list) { | 232 | if (list_empty(&scheduler->n_list)) { |
233 | write_unlock_bh(&__ip_vs_sched_lock); | 233 | write_unlock_bh(&__ip_vs_sched_lock); |
234 | IP_VS_ERR("unregister_ip_vs_scheduler(): [%s] scheduler " | 234 | IP_VS_ERR("unregister_ip_vs_scheduler(): [%s] scheduler " |
235 | "is not in the list. failed\n", scheduler->name); | 235 | "is not in the list. failed\n", scheduler->name); |
diff --git a/net/ipv4/ipvs/ip_vs_sed.c b/net/ipv4/ipvs/ip_vs_sed.c index 2a7d31358181..77663d84cbd1 100644 --- a/net/ipv4/ipvs/ip_vs_sed.c +++ b/net/ipv4/ipvs/ip_vs_sed.c | |||
@@ -138,6 +138,7 @@ static struct ip_vs_scheduler ip_vs_sed_scheduler = | |||
138 | .name = "sed", | 138 | .name = "sed", |
139 | .refcnt = ATOMIC_INIT(0), | 139 | .refcnt = ATOMIC_INIT(0), |
140 | .module = THIS_MODULE, | 140 | .module = THIS_MODULE, |
141 | .n_list = LIST_HEAD_INIT(ip_vs_sed_scheduler.n_list), | ||
141 | .init_service = ip_vs_sed_init_svc, | 142 | .init_service = ip_vs_sed_init_svc, |
142 | .done_service = ip_vs_sed_done_svc, | 143 | .done_service = ip_vs_sed_done_svc, |
143 | .update_service = ip_vs_sed_update_svc, | 144 | .update_service = ip_vs_sed_update_svc, |
@@ -147,7 +148,6 @@ static struct ip_vs_scheduler ip_vs_sed_scheduler = | |||
147 | 148 | ||
148 | static int __init ip_vs_sed_init(void) | 149 | static int __init ip_vs_sed_init(void) |
149 | { | 150 | { |
150 | INIT_LIST_HEAD(&ip_vs_sed_scheduler.n_list); | ||
151 | return register_ip_vs_scheduler(&ip_vs_sed_scheduler); | 151 | return register_ip_vs_scheduler(&ip_vs_sed_scheduler); |
152 | } | 152 | } |
153 | 153 | ||
diff --git a/net/ipv4/ipvs/ip_vs_sh.c b/net/ipv4/ipvs/ip_vs_sh.c index b8fdfac65001..7b979e228056 100644 --- a/net/ipv4/ipvs/ip_vs_sh.c +++ b/net/ipv4/ipvs/ip_vs_sh.c | |||
@@ -230,6 +230,7 @@ static struct ip_vs_scheduler ip_vs_sh_scheduler = | |||
230 | .name = "sh", | 230 | .name = "sh", |
231 | .refcnt = ATOMIC_INIT(0), | 231 | .refcnt = ATOMIC_INIT(0), |
232 | .module = THIS_MODULE, | 232 | .module = THIS_MODULE, |
233 | .n_list = LIST_HEAD_INIT(ip_vs_sh_scheduler.n_list), | ||
233 | .init_service = ip_vs_sh_init_svc, | 234 | .init_service = ip_vs_sh_init_svc, |
234 | .done_service = ip_vs_sh_done_svc, | 235 | .done_service = ip_vs_sh_done_svc, |
235 | .update_service = ip_vs_sh_update_svc, | 236 | .update_service = ip_vs_sh_update_svc, |
@@ -239,7 +240,6 @@ static struct ip_vs_scheduler ip_vs_sh_scheduler = | |||
239 | 240 | ||
240 | static int __init ip_vs_sh_init(void) | 241 | static int __init ip_vs_sh_init(void) |
241 | { | 242 | { |
242 | INIT_LIST_HEAD(&ip_vs_sh_scheduler.n_list); | ||
243 | return register_ip_vs_scheduler(&ip_vs_sh_scheduler); | 243 | return register_ip_vs_scheduler(&ip_vs_sh_scheduler); |
244 | } | 244 | } |
245 | 245 | ||
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c index 45e9bd96c286..a652da2c3200 100644 --- a/net/ipv4/ipvs/ip_vs_sync.c +++ b/net/ipv4/ipvs/ip_vs_sync.c | |||
@@ -904,9 +904,9 @@ int stop_sync_thread(int state) | |||
904 | * progress of stopping the master sync daemon. | 904 | * progress of stopping the master sync daemon. |
905 | */ | 905 | */ |
906 | 906 | ||
907 | spin_lock(&ip_vs_sync_lock); | 907 | spin_lock_bh(&ip_vs_sync_lock); |
908 | ip_vs_sync_state &= ~IP_VS_STATE_MASTER; | 908 | ip_vs_sync_state &= ~IP_VS_STATE_MASTER; |
909 | spin_unlock(&ip_vs_sync_lock); | 909 | spin_unlock_bh(&ip_vs_sync_lock); |
910 | kthread_stop(sync_master_thread); | 910 | kthread_stop(sync_master_thread); |
911 | sync_master_thread = NULL; | 911 | sync_master_thread = NULL; |
912 | } else if (state == IP_VS_STATE_BACKUP) { | 912 | } else if (state == IP_VS_STATE_BACKUP) { |
diff --git a/net/ipv4/ipvs/ip_vs_wlc.c b/net/ipv4/ipvs/ip_vs_wlc.c index 772c3cb4eca1..9b0ef86bb1f7 100644 --- a/net/ipv4/ipvs/ip_vs_wlc.c +++ b/net/ipv4/ipvs/ip_vs_wlc.c | |||
@@ -126,6 +126,7 @@ static struct ip_vs_scheduler ip_vs_wlc_scheduler = | |||
126 | .name = "wlc", | 126 | .name = "wlc", |
127 | .refcnt = ATOMIC_INIT(0), | 127 | .refcnt = ATOMIC_INIT(0), |
128 | .module = THIS_MODULE, | 128 | .module = THIS_MODULE, |
129 | .n_list = LIST_HEAD_INIT(ip_vs_wlc_scheduler.n_list), | ||
129 | .init_service = ip_vs_wlc_init_svc, | 130 | .init_service = ip_vs_wlc_init_svc, |
130 | .done_service = ip_vs_wlc_done_svc, | 131 | .done_service = ip_vs_wlc_done_svc, |
131 | .update_service = ip_vs_wlc_update_svc, | 132 | .update_service = ip_vs_wlc_update_svc, |
@@ -135,7 +136,6 @@ static struct ip_vs_scheduler ip_vs_wlc_scheduler = | |||
135 | 136 | ||
136 | static int __init ip_vs_wlc_init(void) | 137 | static int __init ip_vs_wlc_init(void) |
137 | { | 138 | { |
138 | INIT_LIST_HEAD(&ip_vs_wlc_scheduler.n_list); | ||
139 | return register_ip_vs_scheduler(&ip_vs_wlc_scheduler); | 139 | return register_ip_vs_scheduler(&ip_vs_wlc_scheduler); |
140 | } | 140 | } |
141 | 141 | ||
diff --git a/net/ipv4/ipvs/ip_vs_wrr.c b/net/ipv4/ipvs/ip_vs_wrr.c index 1d6932d7dc97..0d86a79b87b5 100644 --- a/net/ipv4/ipvs/ip_vs_wrr.c +++ b/net/ipv4/ipvs/ip_vs_wrr.c | |||
@@ -212,6 +212,7 @@ static struct ip_vs_scheduler ip_vs_wrr_scheduler = { | |||
212 | .name = "wrr", | 212 | .name = "wrr", |
213 | .refcnt = ATOMIC_INIT(0), | 213 | .refcnt = ATOMIC_INIT(0), |
214 | .module = THIS_MODULE, | 214 | .module = THIS_MODULE, |
215 | .n_list = LIST_HEAD_INIT(ip_vs_wrr_scheduler.n_list), | ||
215 | .init_service = ip_vs_wrr_init_svc, | 216 | .init_service = ip_vs_wrr_init_svc, |
216 | .done_service = ip_vs_wrr_done_svc, | 217 | .done_service = ip_vs_wrr_done_svc, |
217 | .update_service = ip_vs_wrr_update_svc, | 218 | .update_service = ip_vs_wrr_update_svc, |
@@ -220,7 +221,6 @@ static struct ip_vs_scheduler ip_vs_wrr_scheduler = { | |||
220 | 221 | ||
221 | static int __init ip_vs_wrr_init(void) | 222 | static int __init ip_vs_wrr_init(void) |
222 | { | 223 | { |
223 | INIT_LIST_HEAD(&ip_vs_wrr_scheduler.n_list); | ||
224 | return register_ip_vs_scheduler(&ip_vs_wrr_scheduler) ; | 224 | return register_ip_vs_scheduler(&ip_vs_wrr_scheduler) ; |
225 | } | 225 | } |
226 | 226 | ||
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index 1819ad7ab910..fafe8ebb4c55 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c | |||
@@ -475,11 +475,10 @@ static void arp_print(struct arp_payload *payload) | |||
475 | #define HBUFFERLEN 30 | 475 | #define HBUFFERLEN 30 |
476 | char hbuffer[HBUFFERLEN]; | 476 | char hbuffer[HBUFFERLEN]; |
477 | int j,k; | 477 | int j,k; |
478 | const char hexbuf[]= "0123456789abcdef"; | ||
479 | 478 | ||
480 | for (k=0, j=0; k < HBUFFERLEN-3 && j < ETH_ALEN; j++) { | 479 | for (k=0, j=0; k < HBUFFERLEN-3 && j < ETH_ALEN; j++) { |
481 | hbuffer[k++]=hexbuf[(payload->src_hw[j]>>4)&15]; | 480 | hbuffer[k++] = hex_asc_hi(payload->src_hw[j]); |
482 | hbuffer[k++]=hexbuf[payload->src_hw[j]&15]; | 481 | hbuffer[k++] = hex_asc_lo(payload->src_hw[j]); |
483 | hbuffer[k++]=':'; | 482 | hbuffer[k++]=':'; |
484 | } | 483 | } |
485 | hbuffer[--k]='\0'; | 484 | hbuffer[--k]='\0'; |
diff --git a/net/ipv4/netfilter/ipt_addrtype.c b/net/ipv4/netfilter/ipt_addrtype.c index 49587a497229..462a22c97877 100644 --- a/net/ipv4/netfilter/ipt_addrtype.c +++ b/net/ipv4/netfilter/ipt_addrtype.c | |||
@@ -70,7 +70,7 @@ addrtype_mt_v1(const struct sk_buff *skb, const struct net_device *in, | |||
70 | (info->flags & IPT_ADDRTYPE_INVERT_SOURCE); | 70 | (info->flags & IPT_ADDRTYPE_INVERT_SOURCE); |
71 | if (ret && info->dest) | 71 | if (ret && info->dest) |
72 | ret &= match_type(dev, iph->daddr, info->dest) ^ | 72 | ret &= match_type(dev, iph->daddr, info->dest) ^ |
73 | (info->flags & IPT_ADDRTYPE_INVERT_DEST); | 73 | !!(info->flags & IPT_ADDRTYPE_INVERT_DEST); |
74 | return ret; | 74 | return ret; |
75 | } | 75 | } |
76 | 76 | ||
diff --git a/net/ipv4/netfilter/ipt_recent.c b/net/ipv4/netfilter/ipt_recent.c index 21cb053f5d7d..3974d7cae5c0 100644 --- a/net/ipv4/netfilter/ipt_recent.c +++ b/net/ipv4/netfilter/ipt_recent.c | |||
@@ -305,10 +305,10 @@ static void recent_mt_destroy(const struct xt_match *match, void *matchinfo) | |||
305 | spin_lock_bh(&recent_lock); | 305 | spin_lock_bh(&recent_lock); |
306 | list_del(&t->list); | 306 | list_del(&t->list); |
307 | spin_unlock_bh(&recent_lock); | 307 | spin_unlock_bh(&recent_lock); |
308 | recent_table_flush(t); | ||
309 | #ifdef CONFIG_PROC_FS | 308 | #ifdef CONFIG_PROC_FS |
310 | remove_proc_entry(t->name, proc_dir); | 309 | remove_proc_entry(t->name, proc_dir); |
311 | #endif | 310 | #endif |
311 | recent_table_flush(t); | ||
312 | kfree(t); | 312 | kfree(t); |
313 | } | 313 | } |
314 | mutex_unlock(&recent_mutex); | 314 | mutex_unlock(&recent_mutex); |
diff --git a/net/ipv4/netfilter/nf_nat_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c index 91537f11273f..6c4f11f51446 100644 --- a/net/ipv4/netfilter/nf_nat_proto_common.c +++ b/net/ipv4/netfilter/nf_nat_proto_common.c | |||
@@ -73,9 +73,13 @@ bool nf_nat_proto_unique_tuple(struct nf_conntrack_tuple *tuple, | |||
73 | range_size = ntohs(range->max.all) - min + 1; | 73 | range_size = ntohs(range->max.all) - min + 1; |
74 | } | 74 | } |
75 | 75 | ||
76 | off = *rover; | ||
77 | if (range->flags & IP_NAT_RANGE_PROTO_RANDOM) | 76 | if (range->flags & IP_NAT_RANGE_PROTO_RANDOM) |
78 | off = net_random(); | 77 | off = secure_ipv4_port_ephemeral(tuple->src.u3.ip, tuple->dst.u3.ip, |
78 | maniptype == IP_NAT_MANIP_SRC | ||
79 | ? tuple->dst.u.all | ||
80 | : tuple->src.u.all); | ||
81 | else | ||
82 | off = *rover; | ||
79 | 83 | ||
80 | for (i = 0; i < range_size; i++, off++) { | 84 | for (i = 0; i < range_size; i++, off++) { |
81 | *portptr = htons(min + off % range_size); | 85 | *portptr = htons(min + off % range_size); |
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 834356ea99df..8f5a403f6f6b 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -232,6 +232,8 @@ static const struct snmp_mib snmp4_net_list[] = { | |||
232 | SNMP_MIB_ITEM("TCPDSACKIgnoredOld", LINUX_MIB_TCPDSACKIGNOREDOLD), | 232 | SNMP_MIB_ITEM("TCPDSACKIgnoredOld", LINUX_MIB_TCPDSACKIGNOREDOLD), |
233 | SNMP_MIB_ITEM("TCPDSACKIgnoredNoUndo", LINUX_MIB_TCPDSACKIGNOREDNOUNDO), | 233 | SNMP_MIB_ITEM("TCPDSACKIgnoredNoUndo", LINUX_MIB_TCPDSACKIGNOREDNOUNDO), |
234 | SNMP_MIB_ITEM("TCPSpuriousRTOs", LINUX_MIB_TCPSPURIOUSRTOS), | 234 | SNMP_MIB_ITEM("TCPSpuriousRTOs", LINUX_MIB_TCPSPURIOUSRTOS), |
235 | SNMP_MIB_ITEM("TCPMD5NotFound", LINUX_MIB_TCPMD5NOTFOUND), | ||
236 | SNMP_MIB_ITEM("TCPMD5Unexpected", LINUX_MIB_TCPMD5UNEXPECTED), | ||
235 | SNMP_MIB_SENTINEL | 237 | SNMP_MIB_SENTINEL |
236 | }; | 238 | }; |
237 | 239 | ||
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 380d6474cf66..6ee5354c9aa1 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1509,14 +1509,14 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, | |||
1509 | 1509 | ||
1510 | /* BSD 4.2 compatibility hack :-( */ | 1510 | /* BSD 4.2 compatibility hack :-( */ |
1511 | if (mtu == 0 && | 1511 | if (mtu == 0 && |
1512 | old_mtu >= dst_metric(&rth->u.dst, RTAX_MTU) && | 1512 | old_mtu >= dst_mtu(&rth->u.dst) && |
1513 | old_mtu >= 68 + (iph->ihl << 2)) | 1513 | old_mtu >= 68 + (iph->ihl << 2)) |
1514 | old_mtu -= iph->ihl << 2; | 1514 | old_mtu -= iph->ihl << 2; |
1515 | 1515 | ||
1516 | mtu = guess_mtu(old_mtu); | 1516 | mtu = guess_mtu(old_mtu); |
1517 | } | 1517 | } |
1518 | if (mtu <= dst_metric(&rth->u.dst, RTAX_MTU)) { | 1518 | if (mtu <= dst_mtu(&rth->u.dst)) { |
1519 | if (mtu < dst_metric(&rth->u.dst, RTAX_MTU)) { | 1519 | if (mtu < dst_mtu(&rth->u.dst)) { |
1520 | dst_confirm(&rth->u.dst); | 1520 | dst_confirm(&rth->u.dst); |
1521 | if (mtu < ip_rt_min_pmtu) { | 1521 | if (mtu < ip_rt_min_pmtu) { |
1522 | mtu = ip_rt_min_pmtu; | 1522 | mtu = ip_rt_min_pmtu; |
@@ -1538,7 +1538,7 @@ unsigned short ip_rt_frag_needed(struct net *net, struct iphdr *iph, | |||
1538 | 1538 | ||
1539 | static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | 1539 | static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) |
1540 | { | 1540 | { |
1541 | if (dst_metric(dst, RTAX_MTU) > mtu && mtu >= 68 && | 1541 | if (dst_mtu(dst) > mtu && mtu >= 68 && |
1542 | !(dst_metric_locked(dst, RTAX_MTU))) { | 1542 | !(dst_metric_locked(dst, RTAX_MTU))) { |
1543 | if (mtu < ip_rt_min_pmtu) { | 1543 | if (mtu < ip_rt_min_pmtu) { |
1544 | mtu = ip_rt_min_pmtu; | 1544 | mtu = ip_rt_min_pmtu; |
@@ -1667,7 +1667,7 @@ static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag) | |||
1667 | 1667 | ||
1668 | if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0) | 1668 | if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0) |
1669 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl; | 1669 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = sysctl_ip_default_ttl; |
1670 | if (dst_metric(&rt->u.dst, RTAX_MTU) > IP_MAX_MTU) | 1670 | if (dst_mtu(&rt->u.dst) > IP_MAX_MTU) |
1671 | rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU; | 1671 | rt->u.dst.metrics[RTAX_MTU-1] = IP_MAX_MTU; |
1672 | if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0) | 1672 | if (dst_metric(&rt->u.dst, RTAX_ADVMSS) == 0) |
1673 | rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40, | 1673 | rt->u.dst.metrics[RTAX_ADVMSS-1] = max_t(unsigned int, rt->u.dst.dev->mtu - 40, |
@@ -2914,6 +2914,68 @@ static int ipv4_sysctl_rtcache_flush_strategy(ctl_table *table, | |||
2914 | return 0; | 2914 | return 0; |
2915 | } | 2915 | } |
2916 | 2916 | ||
2917 | static void rt_secret_reschedule(int old) | ||
2918 | { | ||
2919 | struct net *net; | ||
2920 | int new = ip_rt_secret_interval; | ||
2921 | int diff = new - old; | ||
2922 | |||
2923 | if (!diff) | ||
2924 | return; | ||
2925 | |||
2926 | rtnl_lock(); | ||
2927 | for_each_net(net) { | ||
2928 | int deleted = del_timer_sync(&net->ipv4.rt_secret_timer); | ||
2929 | |||
2930 | if (!new) | ||
2931 | continue; | ||
2932 | |||
2933 | if (deleted) { | ||
2934 | long time = net->ipv4.rt_secret_timer.expires - jiffies; | ||
2935 | |||
2936 | if (time <= 0 || (time += diff) <= 0) | ||
2937 | time = 0; | ||
2938 | |||
2939 | net->ipv4.rt_secret_timer.expires = time; | ||
2940 | } else | ||
2941 | net->ipv4.rt_secret_timer.expires = new; | ||
2942 | |||
2943 | net->ipv4.rt_secret_timer.expires += jiffies; | ||
2944 | add_timer(&net->ipv4.rt_secret_timer); | ||
2945 | } | ||
2946 | rtnl_unlock(); | ||
2947 | } | ||
2948 | |||
2949 | static int ipv4_sysctl_rt_secret_interval(ctl_table *ctl, int write, | ||
2950 | struct file *filp, | ||
2951 | void __user *buffer, size_t *lenp, | ||
2952 | loff_t *ppos) | ||
2953 | { | ||
2954 | int old = ip_rt_secret_interval; | ||
2955 | int ret = proc_dointvec_jiffies(ctl, write, filp, buffer, lenp, ppos); | ||
2956 | |||
2957 | rt_secret_reschedule(old); | ||
2958 | |||
2959 | return ret; | ||
2960 | } | ||
2961 | |||
2962 | static int ipv4_sysctl_rt_secret_interval_strategy(ctl_table *table, | ||
2963 | int __user *name, | ||
2964 | int nlen, | ||
2965 | void __user *oldval, | ||
2966 | size_t __user *oldlenp, | ||
2967 | void __user *newval, | ||
2968 | size_t newlen) | ||
2969 | { | ||
2970 | int old = ip_rt_secret_interval; | ||
2971 | int ret = sysctl_jiffies(table, name, nlen, oldval, oldlenp, newval, | ||
2972 | newlen); | ||
2973 | |||
2974 | rt_secret_reschedule(old); | ||
2975 | |||
2976 | return ret; | ||
2977 | } | ||
2978 | |||
2917 | static ctl_table ipv4_route_table[] = { | 2979 | static ctl_table ipv4_route_table[] = { |
2918 | { | 2980 | { |
2919 | .ctl_name = NET_IPV4_ROUTE_GC_THRESH, | 2981 | .ctl_name = NET_IPV4_ROUTE_GC_THRESH, |
@@ -3048,20 +3110,29 @@ static ctl_table ipv4_route_table[] = { | |||
3048 | .data = &ip_rt_secret_interval, | 3110 | .data = &ip_rt_secret_interval, |
3049 | .maxlen = sizeof(int), | 3111 | .maxlen = sizeof(int), |
3050 | .mode = 0644, | 3112 | .mode = 0644, |
3051 | .proc_handler = &proc_dointvec_jiffies, | 3113 | .proc_handler = &ipv4_sysctl_rt_secret_interval, |
3052 | .strategy = &sysctl_jiffies, | 3114 | .strategy = &ipv4_sysctl_rt_secret_interval_strategy, |
3053 | }, | 3115 | }, |
3054 | { .ctl_name = 0 } | 3116 | { .ctl_name = 0 } |
3055 | }; | 3117 | }; |
3056 | 3118 | ||
3057 | static __net_initdata struct ctl_path ipv4_route_path[] = { | 3119 | static struct ctl_table empty[1]; |
3120 | |||
3121 | static struct ctl_table ipv4_skeleton[] = | ||
3122 | { | ||
3123 | { .procname = "route", .ctl_name = NET_IPV4_ROUTE, | ||
3124 | .mode = 0555, .child = ipv4_route_table}, | ||
3125 | { .procname = "neigh", .ctl_name = NET_IPV4_NEIGH, | ||
3126 | .mode = 0555, .child = empty}, | ||
3127 | { } | ||
3128 | }; | ||
3129 | |||
3130 | static __net_initdata struct ctl_path ipv4_path[] = { | ||
3058 | { .procname = "net", .ctl_name = CTL_NET, }, | 3131 | { .procname = "net", .ctl_name = CTL_NET, }, |
3059 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, | 3132 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, |
3060 | { .procname = "route", .ctl_name = NET_IPV4_ROUTE, }, | ||
3061 | { }, | 3133 | { }, |
3062 | }; | 3134 | }; |
3063 | 3135 | ||
3064 | |||
3065 | static struct ctl_table ipv4_route_flush_table[] = { | 3136 | static struct ctl_table ipv4_route_flush_table[] = { |
3066 | { | 3137 | { |
3067 | .ctl_name = NET_IPV4_ROUTE_FLUSH, | 3138 | .ctl_name = NET_IPV4_ROUTE_FLUSH, |
@@ -3074,6 +3145,13 @@ static struct ctl_table ipv4_route_flush_table[] = { | |||
3074 | { .ctl_name = 0 }, | 3145 | { .ctl_name = 0 }, |
3075 | }; | 3146 | }; |
3076 | 3147 | ||
3148 | static __net_initdata struct ctl_path ipv4_route_path[] = { | ||
3149 | { .procname = "net", .ctl_name = CTL_NET, }, | ||
3150 | { .procname = "ipv4", .ctl_name = NET_IPV4, }, | ||
3151 | { .procname = "route", .ctl_name = NET_IPV4_ROUTE, }, | ||
3152 | { }, | ||
3153 | }; | ||
3154 | |||
3077 | static __net_init int sysctl_route_net_init(struct net *net) | 3155 | static __net_init int sysctl_route_net_init(struct net *net) |
3078 | { | 3156 | { |
3079 | struct ctl_table *tbl; | 3157 | struct ctl_table *tbl; |
@@ -3126,10 +3204,12 @@ static __net_init int rt_secret_timer_init(struct net *net) | |||
3126 | net->ipv4.rt_secret_timer.data = (unsigned long)net; | 3204 | net->ipv4.rt_secret_timer.data = (unsigned long)net; |
3127 | init_timer_deferrable(&net->ipv4.rt_secret_timer); | 3205 | init_timer_deferrable(&net->ipv4.rt_secret_timer); |
3128 | 3206 | ||
3129 | net->ipv4.rt_secret_timer.expires = | 3207 | if (ip_rt_secret_interval) { |
3130 | jiffies + net_random() % ip_rt_secret_interval + | 3208 | net->ipv4.rt_secret_timer.expires = |
3131 | ip_rt_secret_interval; | 3209 | jiffies + net_random() % ip_rt_secret_interval + |
3132 | add_timer(&net->ipv4.rt_secret_timer); | 3210 | ip_rt_secret_interval; |
3211 | add_timer(&net->ipv4.rt_secret_timer); | ||
3212 | } | ||
3133 | return 0; | 3213 | return 0; |
3134 | } | 3214 | } |
3135 | 3215 | ||
@@ -3216,14 +3296,16 @@ int __init ip_rt_init(void) | |||
3216 | return rc; | 3296 | return rc; |
3217 | } | 3297 | } |
3218 | 3298 | ||
3299 | #ifdef CONFIG_SYSCTL | ||
3219 | /* | 3300 | /* |
3220 | * We really need to sanitize the damn ipv4 init order, then all | 3301 | * We really need to sanitize the damn ipv4 init order, then all |
3221 | * this nonsense will go away. | 3302 | * this nonsense will go away. |
3222 | */ | 3303 | */ |
3223 | void __init ip_static_sysctl_init(void) | 3304 | void __init ip_static_sysctl_init(void) |
3224 | { | 3305 | { |
3225 | register_sysctl_paths(ipv4_route_path, ipv4_route_table); | 3306 | register_sysctl_paths(ipv4_path, ipv4_skeleton); |
3226 | } | 3307 | } |
3308 | #endif | ||
3227 | 3309 | ||
3228 | EXPORT_SYMBOL(__ip_select_ident); | 3310 | EXPORT_SYMBOL(__ip_select_ident); |
3229 | EXPORT_SYMBOL(ip_route_input); | 3311 | EXPORT_SYMBOL(ip_route_input); |
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c index 770d827f5ab8..e0689fd7b798 100644 --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c | |||
@@ -232,6 +232,7 @@ static struct ctl_table ipv4_table[] = { | |||
232 | .mode = 0644, | 232 | .mode = 0644, |
233 | .proc_handler = &ipv4_doint_and_flush, | 233 | .proc_handler = &ipv4_doint_and_flush, |
234 | .strategy = &ipv4_doint_and_flush_strategy, | 234 | .strategy = &ipv4_doint_and_flush_strategy, |
235 | .extra2 = &init_net, | ||
235 | }, | 236 | }, |
236 | { | 237 | { |
237 | .ctl_name = NET_IPV4_NO_PMTU_DISC, | 238 | .ctl_name = NET_IPV4_NO_PMTU_DISC, |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index a2b06d0cc26b..1b4fee20fc93 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -655,8 +655,8 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, | |||
655 | rep.th.doff = arg.iov[0].iov_len/4; | 655 | rep.th.doff = arg.iov[0].iov_len/4; |
656 | 656 | ||
657 | tcp_v4_md5_hash_hdr((__u8 *) &rep.opt[offset], | 657 | tcp_v4_md5_hash_hdr((__u8 *) &rep.opt[offset], |
658 | key, ip_hdr(skb)->daddr, | 658 | key, ip_hdr(skb)->saddr, |
659 | ip_hdr(skb)->saddr, &rep.th); | 659 | ip_hdr(skb)->daddr, &rep.th); |
660 | } | 660 | } |
661 | #endif | 661 | #endif |
662 | arg.csum = csum_tcpudp_nofold(ip_hdr(skb)->daddr, | 662 | arg.csum = csum_tcpudp_nofold(ip_hdr(skb)->daddr, |
@@ -687,14 +687,14 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) | |||
687 | inet_twsk_put(tw); | 687 | inet_twsk_put(tw); |
688 | } | 688 | } |
689 | 689 | ||
690 | static void tcp_v4_reqsk_send_ack(struct sk_buff *skb, | 690 | static void tcp_v4_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, |
691 | struct request_sock *req) | 691 | struct request_sock *req) |
692 | { | 692 | { |
693 | tcp_v4_send_ack(skb, tcp_rsk(req)->snt_isn + 1, | 693 | tcp_v4_send_ack(skb, tcp_rsk(req)->snt_isn + 1, |
694 | tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, | 694 | tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, |
695 | req->ts_recent, | 695 | req->ts_recent, |
696 | 0, | 696 | 0, |
697 | tcp_v4_md5_do_lookup(skb->sk, ip_hdr(skb)->daddr)); | 697 | tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr)); |
698 | } | 698 | } |
699 | 699 | ||
700 | /* | 700 | /* |
@@ -1116,18 +1116,12 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb) | |||
1116 | return 0; | 1116 | return 0; |
1117 | 1117 | ||
1118 | if (hash_expected && !hash_location) { | 1118 | if (hash_expected && !hash_location) { |
1119 | LIMIT_NETDEBUG(KERN_INFO "MD5 Hash expected but NOT found " | 1119 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND); |
1120 | "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)\n", | ||
1121 | NIPQUAD(iph->saddr), ntohs(th->source), | ||
1122 | NIPQUAD(iph->daddr), ntohs(th->dest)); | ||
1123 | return 1; | 1120 | return 1; |
1124 | } | 1121 | } |
1125 | 1122 | ||
1126 | if (!hash_expected && hash_location) { | 1123 | if (!hash_expected && hash_location) { |
1127 | LIMIT_NETDEBUG(KERN_INFO "MD5 Hash NOT expected but found " | 1124 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED); |
1128 | "(" NIPQUAD_FMT ", %d)->(" NIPQUAD_FMT ", %d)\n", | ||
1129 | NIPQUAD(iph->saddr), ntohs(th->source), | ||
1130 | NIPQUAD(iph->daddr), ntohs(th->dest)); | ||
1131 | return 1; | 1125 | return 1; |
1132 | } | 1126 | } |
1133 | 1127 | ||
@@ -2382,6 +2376,7 @@ static int __net_init tcp_sk_init(struct net *net) | |||
2382 | static void __net_exit tcp_sk_exit(struct net *net) | 2376 | static void __net_exit tcp_sk_exit(struct net *net) |
2383 | { | 2377 | { |
2384 | inet_ctl_sock_destroy(net->ipv4.tcp_sock); | 2378 | inet_ctl_sock_destroy(net->ipv4.tcp_sock); |
2379 | inet_twsk_purge(net, &tcp_hashinfo, &tcp_death_row, AF_INET); | ||
2385 | } | 2380 | } |
2386 | 2381 | ||
2387 | static struct pernet_operations __net_initdata tcp_sk_ops = { | 2382 | static struct pernet_operations __net_initdata tcp_sk_ops = { |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 204c42162660..f976fc57892c 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -609,7 +609,7 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
609 | tcp_rsk(req)->rcv_isn + 1, tcp_rsk(req)->rcv_isn + 1 + req->rcv_wnd)) { | 609 | tcp_rsk(req)->rcv_isn + 1, tcp_rsk(req)->rcv_isn + 1 + req->rcv_wnd)) { |
610 | /* Out of window: send ACK and drop. */ | 610 | /* Out of window: send ACK and drop. */ |
611 | if (!(flg & TCP_FLAG_RST)) | 611 | if (!(flg & TCP_FLAG_RST)) |
612 | req->rsk_ops->send_ack(skb, req); | 612 | req->rsk_ops->send_ack(sk, skb, req); |
613 | if (paws_reject) | 613 | if (paws_reject) |
614 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED); | 614 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_PAWSESTABREJECTED); |
615 | return NULL; | 615 | return NULL; |
@@ -618,89 +618,87 @@ struct sock *tcp_check_req(struct sock *sk,struct sk_buff *skb, | |||
618 | /* In sequence, PAWS is OK. */ | 618 | /* In sequence, PAWS is OK. */ |
619 | 619 | ||
620 | if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq, tcp_rsk(req)->rcv_isn + 1)) | 620 | if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq, tcp_rsk(req)->rcv_isn + 1)) |
621 | req->ts_recent = tmp_opt.rcv_tsval; | 621 | req->ts_recent = tmp_opt.rcv_tsval; |
622 | 622 | ||
623 | if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn) { | 623 | if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn) { |
624 | /* Truncate SYN, it is out of window starting | 624 | /* Truncate SYN, it is out of window starting |
625 | at tcp_rsk(req)->rcv_isn + 1. */ | 625 | at tcp_rsk(req)->rcv_isn + 1. */ |
626 | flg &= ~TCP_FLAG_SYN; | 626 | flg &= ~TCP_FLAG_SYN; |
627 | } | 627 | } |
628 | 628 | ||
629 | /* RFC793: "second check the RST bit" and | 629 | /* RFC793: "second check the RST bit" and |
630 | * "fourth, check the SYN bit" | 630 | * "fourth, check the SYN bit" |
631 | */ | 631 | */ |
632 | if (flg & (TCP_FLAG_RST|TCP_FLAG_SYN)) { | 632 | if (flg & (TCP_FLAG_RST|TCP_FLAG_SYN)) { |
633 | TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_ATTEMPTFAILS); | 633 | TCP_INC_STATS_BH(sock_net(sk), TCP_MIB_ATTEMPTFAILS); |
634 | goto embryonic_reset; | 634 | goto embryonic_reset; |
635 | } | 635 | } |
636 | 636 | ||
637 | /* ACK sequence verified above, just make sure ACK is | 637 | /* ACK sequence verified above, just make sure ACK is |
638 | * set. If ACK not set, just silently drop the packet. | 638 | * set. If ACK not set, just silently drop the packet. |
639 | */ | 639 | */ |
640 | if (!(flg & TCP_FLAG_ACK)) | 640 | if (!(flg & TCP_FLAG_ACK)) |
641 | return NULL; | 641 | return NULL; |
642 | |||
643 | /* If TCP_DEFER_ACCEPT is set, drop bare ACK. */ | ||
644 | if (inet_csk(sk)->icsk_accept_queue.rskq_defer_accept && | ||
645 | TCP_SKB_CB(skb)->end_seq == tcp_rsk(req)->rcv_isn + 1) { | ||
646 | inet_rsk(req)->acked = 1; | ||
647 | return NULL; | ||
648 | } | ||
649 | 642 | ||
650 | /* OK, ACK is valid, create big socket and | 643 | /* If TCP_DEFER_ACCEPT is set, drop bare ACK. */ |
651 | * feed this segment to it. It will repeat all | 644 | if (inet_csk(sk)->icsk_accept_queue.rskq_defer_accept && |
652 | * the tests. THIS SEGMENT MUST MOVE SOCKET TO | 645 | TCP_SKB_CB(skb)->end_seq == tcp_rsk(req)->rcv_isn + 1) { |
653 | * ESTABLISHED STATE. If it will be dropped after | 646 | inet_rsk(req)->acked = 1; |
654 | * socket is created, wait for troubles. | 647 | return NULL; |
655 | */ | 648 | } |
656 | child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, | 649 | |
657 | req, NULL); | 650 | /* OK, ACK is valid, create big socket and |
658 | if (child == NULL) | 651 | * feed this segment to it. It will repeat all |
659 | goto listen_overflow; | 652 | * the tests. THIS SEGMENT MUST MOVE SOCKET TO |
653 | * ESTABLISHED STATE. If it will be dropped after | ||
654 | * socket is created, wait for troubles. | ||
655 | */ | ||
656 | child = inet_csk(sk)->icsk_af_ops->syn_recv_sock(sk, skb, req, NULL); | ||
657 | if (child == NULL) | ||
658 | goto listen_overflow; | ||
660 | #ifdef CONFIG_TCP_MD5SIG | 659 | #ifdef CONFIG_TCP_MD5SIG |
661 | else { | 660 | else { |
662 | /* Copy over the MD5 key from the original socket */ | 661 | /* Copy over the MD5 key from the original socket */ |
663 | struct tcp_md5sig_key *key; | 662 | struct tcp_md5sig_key *key; |
664 | struct tcp_sock *tp = tcp_sk(sk); | 663 | struct tcp_sock *tp = tcp_sk(sk); |
665 | key = tp->af_specific->md5_lookup(sk, child); | 664 | key = tp->af_specific->md5_lookup(sk, child); |
666 | if (key != NULL) { | 665 | if (key != NULL) { |
667 | /* | 666 | /* |
668 | * We're using one, so create a matching key on the | 667 | * We're using one, so create a matching key on the |
669 | * newsk structure. If we fail to get memory then we | 668 | * newsk structure. If we fail to get memory then we |
670 | * end up not copying the key across. Shucks. | 669 | * end up not copying the key across. Shucks. |
671 | */ | 670 | */ |
672 | char *newkey = kmemdup(key->key, key->keylen, | 671 | char *newkey = kmemdup(key->key, key->keylen, |
673 | GFP_ATOMIC); | 672 | GFP_ATOMIC); |
674 | if (newkey) { | 673 | if (newkey) { |
675 | if (!tcp_alloc_md5sig_pool()) | 674 | if (!tcp_alloc_md5sig_pool()) |
676 | BUG(); | 675 | BUG(); |
677 | tp->af_specific->md5_add(child, child, | 676 | tp->af_specific->md5_add(child, child, newkey, |
678 | newkey, | 677 | key->keylen); |
679 | key->keylen); | ||
680 | } | ||
681 | } | 678 | } |
682 | } | 679 | } |
680 | } | ||
683 | #endif | 681 | #endif |
684 | 682 | ||
685 | inet_csk_reqsk_queue_unlink(sk, req, prev); | 683 | inet_csk_reqsk_queue_unlink(sk, req, prev); |
686 | inet_csk_reqsk_queue_removed(sk, req); | 684 | inet_csk_reqsk_queue_removed(sk, req); |
687 | 685 | ||
688 | inet_csk_reqsk_queue_add(sk, req, child); | 686 | inet_csk_reqsk_queue_add(sk, req, child); |
689 | return child; | 687 | return child; |
690 | 688 | ||
691 | listen_overflow: | 689 | listen_overflow: |
692 | if (!sysctl_tcp_abort_on_overflow) { | 690 | if (!sysctl_tcp_abort_on_overflow) { |
693 | inet_rsk(req)->acked = 1; | 691 | inet_rsk(req)->acked = 1; |
694 | return NULL; | 692 | return NULL; |
695 | } | 693 | } |
696 | 694 | ||
697 | embryonic_reset: | 695 | embryonic_reset: |
698 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_EMBRYONICRSTS); | 696 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_EMBRYONICRSTS); |
699 | if (!(flg & TCP_FLAG_RST)) | 697 | if (!(flg & TCP_FLAG_RST)) |
700 | req->rsk_ops->send_reset(sk, skb); | 698 | req->rsk_ops->send_reset(sk, skb); |
701 | 699 | ||
702 | inet_csk_reqsk_queue_drop(sk, req, prev); | 700 | inet_csk_reqsk_queue_drop(sk, req, prev); |
703 | return NULL; | 701 | return NULL; |
704 | } | 702 | } |
705 | 703 | ||
706 | /* | 704 | /* |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index a00532de2a8c..8165f5aa8c71 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -468,7 +468,8 @@ static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, | |||
468 | } | 468 | } |
469 | if (likely(sysctl_tcp_window_scaling)) { | 469 | if (likely(sysctl_tcp_window_scaling)) { |
470 | opts->ws = tp->rx_opt.rcv_wscale; | 470 | opts->ws = tp->rx_opt.rcv_wscale; |
471 | size += TCPOLEN_WSCALE_ALIGNED; | 471 | if(likely(opts->ws)) |
472 | size += TCPOLEN_WSCALE_ALIGNED; | ||
472 | } | 473 | } |
473 | if (likely(sysctl_tcp_sack)) { | 474 | if (likely(sysctl_tcp_sack)) { |
474 | opts->options |= OPTION_SACK_ADVERTISE; | 475 | opts->options |= OPTION_SACK_ADVERTISE; |
@@ -509,7 +510,8 @@ static unsigned tcp_synack_options(struct sock *sk, | |||
509 | 510 | ||
510 | if (likely(ireq->wscale_ok)) { | 511 | if (likely(ireq->wscale_ok)) { |
511 | opts->ws = ireq->rcv_wscale; | 512 | opts->ws = ireq->rcv_wscale; |
512 | size += TCPOLEN_WSCALE_ALIGNED; | 513 | if(likely(opts->ws)) |
514 | size += TCPOLEN_WSCALE_ALIGNED; | ||
513 | } | 515 | } |
514 | if (likely(doing_ts)) { | 516 | if (likely(doing_ts)) { |
515 | opts->options |= OPTION_TS; | 517 | opts->options |= OPTION_TS; |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 383d17359d01..8e42fbbd5761 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -989,7 +989,9 @@ int udp_queue_rcv_skb(struct sock * sk, struct sk_buff *skb) | |||
989 | up->encap_rcv != NULL) { | 989 | up->encap_rcv != NULL) { |
990 | int ret; | 990 | int ret; |
991 | 991 | ||
992 | bh_unlock_sock(sk); | ||
992 | ret = (*up->encap_rcv)(sk, skb); | 993 | ret = (*up->encap_rcv)(sk, skb); |
994 | bh_lock_sock(sk); | ||
993 | if (ret <= 0) { | 995 | if (ret <= 0) { |
994 | UDP_INC_STATS_BH(sock_net(sk), | 996 | UDP_INC_STATS_BH(sock_net(sk), |
995 | UDP_MIB_INDATAGRAMS, | 997 | UDP_MIB_INDATAGRAMS, |
@@ -1092,7 +1094,7 @@ static int __udp4_lib_mcast_deliver(struct net *net, struct sk_buff *skb, | |||
1092 | if (skb1) { | 1094 | if (skb1) { |
1093 | int ret = 0; | 1095 | int ret = 0; |
1094 | 1096 | ||
1095 | bh_lock_sock_nested(sk); | 1097 | bh_lock_sock(sk); |
1096 | if (!sock_owned_by_user(sk)) | 1098 | if (!sock_owned_by_user(sk)) |
1097 | ret = udp_queue_rcv_skb(sk, skb1); | 1099 | ret = udp_queue_rcv_skb(sk, skb1); |
1098 | else | 1100 | else |
@@ -1194,7 +1196,7 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
1194 | 1196 | ||
1195 | if (sk != NULL) { | 1197 | if (sk != NULL) { |
1196 | int ret = 0; | 1198 | int ret = 0; |
1197 | bh_lock_sock_nested(sk); | 1199 | bh_lock_sock(sk); |
1198 | if (!sock_owned_by_user(sk)) | 1200 | if (!sock_owned_by_user(sk)) |
1199 | ret = udp_queue_rcv_skb(sk, skb); | 1201 | ret = udp_queue_rcv_skb(sk, skb); |
1200 | else | 1202 | else |
diff --git a/net/ipv4/xfrm4_mode_beet.c b/net/ipv4/xfrm4_mode_beet.c index 9c798abce736..63418185f524 100644 --- a/net/ipv4/xfrm4_mode_beet.c +++ b/net/ipv4/xfrm4_mode_beet.c | |||
@@ -47,8 +47,10 @@ static int xfrm4_beet_output(struct xfrm_state *x, struct sk_buff *skb) | |||
47 | if (unlikely(optlen)) | 47 | if (unlikely(optlen)) |
48 | hdrlen += IPV4_BEET_PHMAXLEN - (optlen & 4); | 48 | hdrlen += IPV4_BEET_PHMAXLEN - (optlen & 4); |
49 | 49 | ||
50 | skb_set_network_header(skb, IPV4_BEET_PHMAXLEN - x->props.header_len - | 50 | skb_set_network_header(skb, -x->props.header_len - |
51 | hdrlen); | 51 | hdrlen + (XFRM_MODE_SKB_CB(skb)->ihl - sizeof(*top_iph))); |
52 | if (x->sel.family != AF_INET6) | ||
53 | skb->network_header += IPV4_BEET_PHMAXLEN; | ||
52 | skb->mac_header = skb->network_header + | 54 | skb->mac_header = skb->network_header + |
53 | offsetof(struct iphdr, protocol); | 55 | offsetof(struct iphdr, protocol); |
54 | skb->transport_header = skb->network_header + sizeof(*top_iph); | 56 | skb->transport_header = skb->network_header + sizeof(*top_iph); |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index a7842c54f58a..7b6a584b62dd 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -1106,13 +1106,12 @@ out: | |||
1106 | return ret; | 1106 | return ret; |
1107 | } | 1107 | } |
1108 | 1108 | ||
1109 | int ipv6_dev_get_saddr(struct net_device *dst_dev, | 1109 | int ipv6_dev_get_saddr(struct net *net, struct net_device *dst_dev, |
1110 | const struct in6_addr *daddr, unsigned int prefs, | 1110 | const struct in6_addr *daddr, unsigned int prefs, |
1111 | struct in6_addr *saddr) | 1111 | struct in6_addr *saddr) |
1112 | { | 1112 | { |
1113 | struct ipv6_saddr_score scores[2], | 1113 | struct ipv6_saddr_score scores[2], |
1114 | *score = &scores[0], *hiscore = &scores[1]; | 1114 | *score = &scores[0], *hiscore = &scores[1]; |
1115 | struct net *net = dev_net(dst_dev); | ||
1116 | struct ipv6_saddr_dst dst; | 1115 | struct ipv6_saddr_dst dst; |
1117 | struct net_device *dev; | 1116 | struct net_device *dev; |
1118 | int dst_type; | 1117 | int dst_type; |
@@ -1689,6 +1688,7 @@ addrconf_prefix_route(struct in6_addr *pfx, int plen, struct net_device *dev, | |||
1689 | .fc_dst_len = plen, | 1688 | .fc_dst_len = plen, |
1690 | .fc_flags = RTF_UP | flags, | 1689 | .fc_flags = RTF_UP | flags, |
1691 | .fc_nlinfo.nl_net = dev_net(dev), | 1690 | .fc_nlinfo.nl_net = dev_net(dev), |
1691 | .fc_protocol = RTPROT_KERNEL, | ||
1692 | }; | 1692 | }; |
1693 | 1693 | ||
1694 | ipv6_addr_copy(&cfg.fc_dst, pfx); | 1694 | ipv6_addr_copy(&cfg.fc_dst, pfx); |
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c index f7b535dec860..410046a8cc91 100644 --- a/net/ipv6/datagram.c +++ b/net/ipv6/datagram.c | |||
@@ -732,7 +732,7 @@ int datagram_send_ctl(struct net *net, | |||
732 | LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", | 732 | LIMIT_NETDEBUG(KERN_DEBUG "invalid cmsg type: %d\n", |
733 | cmsg->cmsg_type); | 733 | cmsg->cmsg_type); |
734 | err = -EINVAL; | 734 | err = -EINVAL; |
735 | break; | 735 | goto exit_f; |
736 | } | 736 | } |
737 | } | 737 | } |
738 | 738 | ||
diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c index c6bb4c6d24b3..b181b08fb761 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c | |||
@@ -521,6 +521,10 @@ static int esp6_init_state(struct xfrm_state *x) | |||
521 | crypto_aead_ivsize(aead); | 521 | crypto_aead_ivsize(aead); |
522 | switch (x->props.mode) { | 522 | switch (x->props.mode) { |
523 | case XFRM_MODE_BEET: | 523 | case XFRM_MODE_BEET: |
524 | if (x->sel.family != AF_INET6) | ||
525 | x->props.header_len += IPV4_BEET_PHMAXLEN + | ||
526 | (sizeof(struct ipv6hdr) - sizeof(struct iphdr)); | ||
527 | break; | ||
524 | case XFRM_MODE_TRANSPORT: | 528 | case XFRM_MODE_TRANSPORT: |
525 | break; | 529 | break; |
526 | case XFRM_MODE_TUNNEL: | 530 | case XFRM_MODE_TUNNEL: |
diff --git a/net/ipv6/fib6_rules.c b/net/ipv6/fib6_rules.c index 8d05527524e3..f5de3f9dc692 100644 --- a/net/ipv6/fib6_rules.c +++ b/net/ipv6/fib6_rules.c | |||
@@ -93,7 +93,8 @@ static int fib6_rule_action(struct fib_rule *rule, struct flowi *flp, | |||
93 | if (flags & RT6_LOOKUP_F_SRCPREF_COA) | 93 | if (flags & RT6_LOOKUP_F_SRCPREF_COA) |
94 | srcprefs |= IPV6_PREFER_SRC_COA; | 94 | srcprefs |= IPV6_PREFER_SRC_COA; |
95 | 95 | ||
96 | if (ipv6_dev_get_saddr(ip6_dst_idev(&rt->u.dst)->dev, | 96 | if (ipv6_dev_get_saddr(net, |
97 | ip6_dst_idev(&rt->u.dst)->dev, | ||
97 | &flp->fl6_dst, srcprefs, | 98 | &flp->fl6_dst, srcprefs, |
98 | &saddr)) | 99 | &saddr)) |
99 | goto again; | 100 | goto again; |
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index abedf95fdf2d..b3157a0cc15d 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
@@ -91,19 +91,22 @@ static struct inet6_protocol icmpv6_protocol = { | |||
91 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, | 91 | .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL, |
92 | }; | 92 | }; |
93 | 93 | ||
94 | static __inline__ int icmpv6_xmit_lock(struct sock *sk) | 94 | static __inline__ struct sock *icmpv6_xmit_lock(struct net *net) |
95 | { | 95 | { |
96 | struct sock *sk; | ||
97 | |||
96 | local_bh_disable(); | 98 | local_bh_disable(); |
97 | 99 | ||
100 | sk = icmpv6_sk(net); | ||
98 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { | 101 | if (unlikely(!spin_trylock(&sk->sk_lock.slock))) { |
99 | /* This can happen if the output path (f.e. SIT or | 102 | /* This can happen if the output path (f.e. SIT or |
100 | * ip6ip6 tunnel) signals dst_link_failure() for an | 103 | * ip6ip6 tunnel) signals dst_link_failure() for an |
101 | * outgoing ICMP6 packet. | 104 | * outgoing ICMP6 packet. |
102 | */ | 105 | */ |
103 | local_bh_enable(); | 106 | local_bh_enable(); |
104 | return 1; | 107 | return NULL; |
105 | } | 108 | } |
106 | return 0; | 109 | return sk; |
107 | } | 110 | } |
108 | 111 | ||
109 | static __inline__ void icmpv6_xmit_unlock(struct sock *sk) | 112 | static __inline__ void icmpv6_xmit_unlock(struct sock *sk) |
@@ -392,11 +395,10 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info, | |||
392 | fl.fl_icmp_code = code; | 395 | fl.fl_icmp_code = code; |
393 | security_skb_classify_flow(skb, &fl); | 396 | security_skb_classify_flow(skb, &fl); |
394 | 397 | ||
395 | sk = icmpv6_sk(net); | 398 | sk = icmpv6_xmit_lock(net); |
396 | np = inet6_sk(sk); | 399 | if (sk == NULL) |
397 | |||
398 | if (icmpv6_xmit_lock(sk)) | ||
399 | return; | 400 | return; |
401 | np = inet6_sk(sk); | ||
400 | 402 | ||
401 | if (!icmpv6_xrlim_allow(sk, type, &fl)) | 403 | if (!icmpv6_xrlim_allow(sk, type, &fl)) |
402 | goto out; | 404 | goto out; |
@@ -539,11 +541,10 @@ static void icmpv6_echo_reply(struct sk_buff *skb) | |||
539 | fl.fl_icmp_type = ICMPV6_ECHO_REPLY; | 541 | fl.fl_icmp_type = ICMPV6_ECHO_REPLY; |
540 | security_skb_classify_flow(skb, &fl); | 542 | security_skb_classify_flow(skb, &fl); |
541 | 543 | ||
542 | sk = icmpv6_sk(net); | 544 | sk = icmpv6_xmit_lock(net); |
543 | np = inet6_sk(sk); | 545 | if (sk == NULL) |
544 | |||
545 | if (icmpv6_xmit_lock(sk)) | ||
546 | return; | 546 | return; |
547 | np = inet6_sk(sk); | ||
547 | 548 | ||
548 | if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) | 549 | if (!fl.oif && ipv6_addr_is_multicast(&fl.fl6_dst)) |
549 | fl.oif = np->mcast_oif; | 550 | fl.oif = np->mcast_oif; |
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 52dddc25d3e6..29c7c99e69f7 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -378,6 +378,7 @@ static int inet6_dump_fib(struct sk_buff *skb, struct netlink_callback *cb) | |||
378 | 378 | ||
379 | arg.skb = skb; | 379 | arg.skb = skb; |
380 | arg.cb = cb; | 380 | arg.cb = cb; |
381 | arg.net = net; | ||
381 | w->args = &arg; | 382 | w->args = &arg; |
382 | 383 | ||
383 | for (h = s_h; h < FIB_TABLE_HASHSZ; h++, s_e = 0) { | 384 | for (h = s_h; h < FIB_TABLE_HASHSZ; h++, s_e = 0) { |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 6811901e6b1e..3df2c442d90b 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -236,6 +236,10 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | |||
236 | skb_reset_network_header(skb); | 236 | skb_reset_network_header(skb); |
237 | hdr = ipv6_hdr(skb); | 237 | hdr = ipv6_hdr(skb); |
238 | 238 | ||
239 | /* Allow local fragmentation. */ | ||
240 | if (ipfragok) | ||
241 | skb->local_df = 1; | ||
242 | |||
239 | /* | 243 | /* |
240 | * Fill in the IPv6 header | 244 | * Fill in the IPv6 header |
241 | */ | 245 | */ |
@@ -265,7 +269,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl, | |||
265 | skb->mark = sk->sk_mark; | 269 | skb->mark = sk->sk_mark; |
266 | 270 | ||
267 | mtu = dst_mtu(dst); | 271 | mtu = dst_mtu(dst); |
268 | if ((skb->len <= mtu) || ipfragok || skb_is_gso(skb)) { | 272 | if ((skb->len <= mtu) || skb->local_df || skb_is_gso(skb)) { |
269 | IP6_INC_STATS(ip6_dst_idev(skb->dst), | 273 | IP6_INC_STATS(ip6_dst_idev(skb->dst), |
270 | IPSTATS_MIB_OUTREQUESTS); | 274 | IPSTATS_MIB_OUTREQUESTS); |
271 | return NF_HOOK(PF_INET6, NF_INET_LOCAL_OUT, skb, NULL, dst->dev, | 275 | return NF_HOOK(PF_INET6, NF_INET_LOCAL_OUT, skb, NULL, dst->dev, |
@@ -930,7 +934,7 @@ static int ip6_dst_lookup_tail(struct sock *sk, | |||
930 | goto out_err_release; | 934 | goto out_err_release; |
931 | 935 | ||
932 | if (ipv6_addr_any(&fl->fl6_src)) { | 936 | if (ipv6_addr_any(&fl->fl6_src)) { |
933 | err = ipv6_dev_get_saddr(ip6_dst_idev(*dst)->dev, | 937 | err = ipv6_dev_get_saddr(net, ip6_dst_idev(*dst)->dev, |
934 | &fl->fl6_dst, | 938 | &fl->fl6_dst, |
935 | sk ? inet6_sk(sk)->srcprefs : 0, | 939 | sk ? inet6_sk(sk)->srcprefs : 0, |
936 | &fl->fl6_src); | 940 | &fl->fl6_src); |
@@ -939,39 +943,39 @@ static int ip6_dst_lookup_tail(struct sock *sk, | |||
939 | } | 943 | } |
940 | 944 | ||
941 | #ifdef CONFIG_IPV6_OPTIMISTIC_DAD | 945 | #ifdef CONFIG_IPV6_OPTIMISTIC_DAD |
942 | /* | 946 | /* |
943 | * Here if the dst entry we've looked up | 947 | * Here if the dst entry we've looked up |
944 | * has a neighbour entry that is in the INCOMPLETE | 948 | * has a neighbour entry that is in the INCOMPLETE |
945 | * state and the src address from the flow is | 949 | * state and the src address from the flow is |
946 | * marked as OPTIMISTIC, we release the found | 950 | * marked as OPTIMISTIC, we release the found |
947 | * dst entry and replace it instead with the | 951 | * dst entry and replace it instead with the |
948 | * dst entry of the nexthop router | 952 | * dst entry of the nexthop router |
949 | */ | 953 | */ |
950 | if (!((*dst)->neighbour->nud_state & NUD_VALID)) { | 954 | if ((*dst)->neighbour && !((*dst)->neighbour->nud_state & NUD_VALID)) { |
951 | struct inet6_ifaddr *ifp; | 955 | struct inet6_ifaddr *ifp; |
952 | struct flowi fl_gw; | 956 | struct flowi fl_gw; |
953 | int redirect; | 957 | int redirect; |
954 | 958 | ||
955 | ifp = ipv6_get_ifaddr(net, &fl->fl6_src, | 959 | ifp = ipv6_get_ifaddr(net, &fl->fl6_src, |
956 | (*dst)->dev, 1); | 960 | (*dst)->dev, 1); |
957 | 961 | ||
958 | redirect = (ifp && ifp->flags & IFA_F_OPTIMISTIC); | 962 | redirect = (ifp && ifp->flags & IFA_F_OPTIMISTIC); |
959 | if (ifp) | 963 | if (ifp) |
960 | in6_ifa_put(ifp); | 964 | in6_ifa_put(ifp); |
961 | 965 | ||
962 | if (redirect) { | 966 | if (redirect) { |
963 | /* | 967 | /* |
964 | * We need to get the dst entry for the | 968 | * We need to get the dst entry for the |
965 | * default router instead | 969 | * default router instead |
966 | */ | 970 | */ |
967 | dst_release(*dst); | 971 | dst_release(*dst); |
968 | memcpy(&fl_gw, fl, sizeof(struct flowi)); | 972 | memcpy(&fl_gw, fl, sizeof(struct flowi)); |
969 | memset(&fl_gw.fl6_dst, 0, sizeof(struct in6_addr)); | 973 | memset(&fl_gw.fl6_dst, 0, sizeof(struct in6_addr)); |
970 | *dst = ip6_route_output(net, sk, &fl_gw); | 974 | *dst = ip6_route_output(net, sk, &fl_gw); |
971 | if ((err = (*dst)->error)) | 975 | if ((err = (*dst)->error)) |
972 | goto out_err_release; | 976 | goto out_err_release; |
973 | } | ||
974 | } | 977 | } |
978 | } | ||
975 | #endif | 979 | #endif |
976 | 980 | ||
977 | return 0; | 981 | return 0; |
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c index ea33b26512c2..4e5eac301f91 100644 --- a/net/ipv6/ipv6_sockglue.c +++ b/net/ipv6/ipv6_sockglue.c | |||
@@ -346,6 +346,8 @@ static int do_ipv6_setsockopt(struct sock *sk, int level, int optname, | |||
346 | */ | 346 | */ |
347 | if (optlen == 0) | 347 | if (optlen == 0) |
348 | optval = NULL; | 348 | optval = NULL; |
349 | else if (optval == NULL) | ||
350 | goto e_inval; | ||
349 | else if (optlen < sizeof(struct ipv6_opt_hdr) || | 351 | else if (optlen < sizeof(struct ipv6_opt_hdr) || |
350 | optlen & 0x7 || optlen > 8 * 255) | 352 | optlen & 0x7 || optlen > 8 * 255) |
351 | goto e_inval; | 353 | goto e_inval; |
@@ -909,7 +911,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
909 | } else { | 911 | } else { |
910 | if (np->rxopt.bits.rxinfo) { | 912 | if (np->rxopt.bits.rxinfo) { |
911 | struct in6_pktinfo src_info; | 913 | struct in6_pktinfo src_info; |
912 | src_info.ipi6_ifindex = np->mcast_oif; | 914 | src_info.ipi6_ifindex = np->mcast_oif ? np->mcast_oif : sk->sk_bound_dev_if; |
913 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); | 915 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); |
914 | put_cmsg(&msg, SOL_IPV6, IPV6_PKTINFO, sizeof(src_info), &src_info); | 916 | put_cmsg(&msg, SOL_IPV6, IPV6_PKTINFO, sizeof(src_info), &src_info); |
915 | } | 917 | } |
@@ -919,7 +921,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname, | |||
919 | } | 921 | } |
920 | if (np->rxopt.bits.rxoinfo) { | 922 | if (np->rxopt.bits.rxoinfo) { |
921 | struct in6_pktinfo src_info; | 923 | struct in6_pktinfo src_info; |
922 | src_info.ipi6_ifindex = np->mcast_oif; | 924 | src_info.ipi6_ifindex = np->mcast_oif ? np->mcast_oif : sk->sk_bound_dev_if; |
923 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); | 925 | ipv6_addr_copy(&src_info.ipi6_addr, &np->daddr); |
924 | put_cmsg(&msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); | 926 | put_cmsg(&msg, SOL_IPV6, IPV6_2292PKTINFO, sizeof(src_info), &src_info); |
925 | } | 927 | } |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index beb48e3f038a..f1c62ba0f56b 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -549,7 +549,7 @@ static void ndisc_send_na(struct net_device *dev, struct neighbour *neigh, | |||
549 | override = 0; | 549 | override = 0; |
550 | in6_ifa_put(ifp); | 550 | in6_ifa_put(ifp); |
551 | } else { | 551 | } else { |
552 | if (ipv6_dev_get_saddr(dev, daddr, | 552 | if (ipv6_dev_get_saddr(dev_net(dev), dev, daddr, |
553 | inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs, | 553 | inet6_sk(dev_net(dev)->ipv6.ndisc_sk)->srcprefs, |
554 | &tmpaddr)) | 554 | &tmpaddr)) |
555 | return; | 555 | return; |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index f82f6074cf85..0179b66864f1 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -286,7 +286,6 @@ proc_net_fail: | |||
286 | 286 | ||
287 | void ipv6_misc_proc_exit(void) | 287 | void ipv6_misc_proc_exit(void) |
288 | { | 288 | { |
289 | proc_net_remove(&init_net, "sockstat6"); | ||
290 | proc_net_remove(&init_net, "dev_snmp6"); | 289 | proc_net_remove(&init_net, "dev_snmp6"); |
291 | proc_net_remove(&init_net, "snmp6"); | 290 | proc_net_remove(&init_net, "snmp6"); |
292 | unregister_pernet_subsys(&ipv6_proc_ops); | 291 | unregister_pernet_subsys(&ipv6_proc_ops); |
diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c index 01d47674f7e5..e53e493606c5 100644 --- a/net/ipv6/raw.c +++ b/net/ipv6/raw.c | |||
@@ -377,14 +377,14 @@ static inline int rawv6_rcv_skb(struct sock * sk, struct sk_buff * skb) | |||
377 | skb_checksum_complete(skb)) { | 377 | skb_checksum_complete(skb)) { |
378 | atomic_inc(&sk->sk_drops); | 378 | atomic_inc(&sk->sk_drops); |
379 | kfree_skb(skb); | 379 | kfree_skb(skb); |
380 | return 0; | 380 | return NET_RX_DROP; |
381 | } | 381 | } |
382 | 382 | ||
383 | /* Charge it to the socket. */ | 383 | /* Charge it to the socket. */ |
384 | if (sock_queue_rcv_skb(sk,skb)<0) { | 384 | if (sock_queue_rcv_skb(sk,skb)<0) { |
385 | atomic_inc(&sk->sk_drops); | 385 | atomic_inc(&sk->sk_drops); |
386 | kfree_skb(skb); | 386 | kfree_skb(skb); |
387 | return 0; | 387 | return NET_RX_DROP; |
388 | } | 388 | } |
389 | 389 | ||
390 | return 0; | 390 | return 0; |
@@ -429,7 +429,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb) | |||
429 | if (skb_checksum_complete(skb)) { | 429 | if (skb_checksum_complete(skb)) { |
430 | atomic_inc(&sk->sk_drops); | 430 | atomic_inc(&sk->sk_drops); |
431 | kfree_skb(skb); | 431 | kfree_skb(skb); |
432 | return 0; | 432 | return NET_RX_DROP; |
433 | } | 433 | } |
434 | } | 434 | } |
435 | 435 | ||
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 86540b24b27c..9af6115f0f50 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1249,7 +1249,7 @@ install_route: | |||
1249 | 1249 | ||
1250 | if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0) | 1250 | if (dst_metric(&rt->u.dst, RTAX_HOPLIMIT) == 0) |
1251 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; | 1251 | rt->u.dst.metrics[RTAX_HOPLIMIT-1] = -1; |
1252 | if (!dst_metric(&rt->u.dst, RTAX_MTU)) | 1252 | if (!dst_mtu(&rt->u.dst)) |
1253 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); | 1253 | rt->u.dst.metrics[RTAX_MTU-1] = ipv6_get_mtu(dev); |
1254 | if (!dst_metric(&rt->u.dst, RTAX_ADVMSS)) | 1254 | if (!dst_metric(&rt->u.dst, RTAX_ADVMSS)) |
1255 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); | 1255 | rt->u.dst.metrics[RTAX_ADVMSS-1] = ipv6_advmss(net, dst_mtu(&rt->u.dst)); |
@@ -2106,7 +2106,8 @@ static inline size_t rt6_nlmsg_size(void) | |||
2106 | + nla_total_size(sizeof(struct rta_cacheinfo)); | 2106 | + nla_total_size(sizeof(struct rta_cacheinfo)); |
2107 | } | 2107 | } |
2108 | 2108 | ||
2109 | static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | 2109 | static int rt6_fill_node(struct net *net, |
2110 | struct sk_buff *skb, struct rt6_info *rt, | ||
2110 | struct in6_addr *dst, struct in6_addr *src, | 2111 | struct in6_addr *dst, struct in6_addr *src, |
2111 | int iif, int type, u32 pid, u32 seq, | 2112 | int iif, int type, u32 pid, u32 seq, |
2112 | int prefix, int nowait, unsigned int flags) | 2113 | int prefix, int nowait, unsigned int flags) |
@@ -2187,8 +2188,9 @@ static int rt6_fill_node(struct sk_buff *skb, struct rt6_info *rt, | |||
2187 | #endif | 2188 | #endif |
2188 | NLA_PUT_U32(skb, RTA_IIF, iif); | 2189 | NLA_PUT_U32(skb, RTA_IIF, iif); |
2189 | } else if (dst) { | 2190 | } else if (dst) { |
2191 | struct inet6_dev *idev = ip6_dst_idev(&rt->u.dst); | ||
2190 | struct in6_addr saddr_buf; | 2192 | struct in6_addr saddr_buf; |
2191 | if (ipv6_dev_get_saddr(ip6_dst_idev(&rt->u.dst)->dev, | 2193 | if (ipv6_dev_get_saddr(net, idev ? idev->dev : NULL, |
2192 | dst, 0, &saddr_buf) == 0) | 2194 | dst, 0, &saddr_buf) == 0) |
2193 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); | 2195 | NLA_PUT(skb, RTA_PREFSRC, 16, &saddr_buf); |
2194 | } | 2196 | } |
@@ -2233,7 +2235,8 @@ int rt6_dump_route(struct rt6_info *rt, void *p_arg) | |||
2233 | } else | 2235 | } else |
2234 | prefix = 0; | 2236 | prefix = 0; |
2235 | 2237 | ||
2236 | return rt6_fill_node(arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE, | 2238 | return rt6_fill_node(arg->net, |
2239 | arg->skb, rt, NULL, NULL, 0, RTM_NEWROUTE, | ||
2237 | NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq, | 2240 | NETLINK_CB(arg->cb->skb).pid, arg->cb->nlh->nlmsg_seq, |
2238 | prefix, 0, NLM_F_MULTI); | 2241 | prefix, 0, NLM_F_MULTI); |
2239 | } | 2242 | } |
@@ -2299,7 +2302,7 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr* nlh, void | |||
2299 | rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl); | 2302 | rt = (struct rt6_info*) ip6_route_output(net, NULL, &fl); |
2300 | skb->dst = &rt->u.dst; | 2303 | skb->dst = &rt->u.dst; |
2301 | 2304 | ||
2302 | err = rt6_fill_node(skb, rt, &fl.fl6_dst, &fl.fl6_src, iif, | 2305 | err = rt6_fill_node(net, skb, rt, &fl.fl6_dst, &fl.fl6_src, iif, |
2303 | RTM_NEWROUTE, NETLINK_CB(in_skb).pid, | 2306 | RTM_NEWROUTE, NETLINK_CB(in_skb).pid, |
2304 | nlh->nlmsg_seq, 0, 0, 0); | 2307 | nlh->nlmsg_seq, 0, 0, 0); |
2305 | if (err < 0) { | 2308 | if (err < 0) { |
@@ -2326,7 +2329,7 @@ void inet6_rt_notify(int event, struct rt6_info *rt, struct nl_info *info) | |||
2326 | if (skb == NULL) | 2329 | if (skb == NULL) |
2327 | goto errout; | 2330 | goto errout; |
2328 | 2331 | ||
2329 | err = rt6_fill_node(skb, rt, NULL, NULL, 0, | 2332 | err = rt6_fill_node(net, skb, rt, NULL, NULL, 0, |
2330 | event, info->pid, seq, 0, 0, 0); | 2333 | event, info->pid, seq, 0, 0, 0); |
2331 | if (err < 0) { | 2334 | if (err < 0) { |
2332 | /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ | 2335 | /* -EMSGSIZE implies BUG in rt6_nlmsg_size() */ |
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index a46badd1082d..ec394cf5a19b 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c | |||
@@ -199,10 +199,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
199 | ireq6 = inet6_rsk(req); | 199 | ireq6 = inet6_rsk(req); |
200 | treq = tcp_rsk(req); | 200 | treq = tcp_rsk(req); |
201 | 201 | ||
202 | if (security_inet_conn_request(sk, skb, req)) { | 202 | if (security_inet_conn_request(sk, skb, req)) |
203 | reqsk_free(req); | 203 | goto out_free; |
204 | goto out; | ||
205 | } | ||
206 | 204 | ||
207 | req->mss = mss; | 205 | req->mss = mss; |
208 | ireq->rmt_port = th->source; | 206 | ireq->rmt_port = th->source; |
@@ -255,14 +253,13 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
255 | fl.fl_ip_dport = inet_rsk(req)->rmt_port; | 253 | fl.fl_ip_dport = inet_rsk(req)->rmt_port; |
256 | fl.fl_ip_sport = inet_sk(sk)->sport; | 254 | fl.fl_ip_sport = inet_sk(sk)->sport; |
257 | security_req_classify_flow(req, &fl); | 255 | security_req_classify_flow(req, &fl); |
258 | if (ip6_dst_lookup(sk, &dst, &fl)) { | 256 | if (ip6_dst_lookup(sk, &dst, &fl)) |
259 | reqsk_free(req); | 257 | goto out_free; |
260 | goto out; | 258 | |
261 | } | ||
262 | if (final_p) | 259 | if (final_p) |
263 | ipv6_addr_copy(&fl.fl6_dst, final_p); | 260 | ipv6_addr_copy(&fl.fl6_dst, final_p); |
264 | if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0) | 261 | if ((xfrm_lookup(&dst, &fl, sk, 0)) < 0) |
265 | goto out; | 262 | goto out_free; |
266 | } | 263 | } |
267 | 264 | ||
268 | req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); | 265 | req->window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW); |
@@ -273,7 +270,10 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) | |||
273 | ireq->rcv_wscale = rcv_wscale; | 270 | ireq->rcv_wscale = rcv_wscale; |
274 | 271 | ||
275 | ret = get_cookie_sock(sk, skb, req, dst); | 272 | ret = get_cookie_sock(sk, skb, req, dst); |
276 | 273 | out: | |
277 | out: return ret; | 274 | return ret; |
275 | out_free: | ||
276 | reqsk_free(req); | ||
277 | return NULL; | ||
278 | } | 278 | } |
279 | 279 | ||
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c index e6dfaeac6be3..587f8f60c489 100644 --- a/net/ipv6/sysctl_net_ipv6.c +++ b/net/ipv6/sysctl_net_ipv6.c | |||
@@ -156,7 +156,7 @@ static struct ctl_table_header *ip6_base; | |||
156 | int ipv6_static_sysctl_register(void) | 156 | int ipv6_static_sysctl_register(void) |
157 | { | 157 | { |
158 | static struct ctl_table empty[1]; | 158 | static struct ctl_table empty[1]; |
159 | ip6_base = register_net_sysctl_rotable(net_ipv6_ctl_path, empty); | 159 | ip6_base = register_sysctl_paths(net_ipv6_ctl_path, empty); |
160 | if (ip6_base == NULL) | 160 | if (ip6_base == NULL) |
161 | return -ENOMEM; | 161 | return -ENOMEM; |
162 | return 0; | 162 | return 0; |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index cff778b23a7f..b585c850a89a 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -69,7 +69,8 @@ | |||
69 | #include <linux/scatterlist.h> | 69 | #include <linux/scatterlist.h> |
70 | 70 | ||
71 | static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb); | 71 | static void tcp_v6_send_reset(struct sock *sk, struct sk_buff *skb); |
72 | static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req); | 72 | static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, |
73 | struct request_sock *req); | ||
73 | 74 | ||
74 | static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb); | 75 | static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb); |
75 | 76 | ||
@@ -748,7 +749,7 @@ static int tcp_v6_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, | |||
748 | ipv6_addr_copy(&bp->saddr, saddr); | 749 | ipv6_addr_copy(&bp->saddr, saddr); |
749 | ipv6_addr_copy(&bp->daddr, daddr); | 750 | ipv6_addr_copy(&bp->daddr, daddr); |
750 | bp->protocol = cpu_to_be32(IPPROTO_TCP); | 751 | bp->protocol = cpu_to_be32(IPPROTO_TCP); |
751 | bp->len = cpu_to_be16(nbytes); | 752 | bp->len = cpu_to_be32(nbytes); |
752 | 753 | ||
753 | sg_init_one(&sg, bp, sizeof(*bp)); | 754 | sg_init_one(&sg, bp, sizeof(*bp)); |
754 | return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp)); | 755 | return crypto_hash_update(&hp->md5_desc, &sg, sizeof(*bp)); |
@@ -849,28 +850,17 @@ static int tcp_v6_inbound_md5_hash (struct sock *sk, struct sk_buff *skb) | |||
849 | hash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr); | 850 | hash_expected = tcp_v6_md5_do_lookup(sk, &ip6h->saddr); |
850 | hash_location = tcp_parse_md5sig_option(th); | 851 | hash_location = tcp_parse_md5sig_option(th); |
851 | 852 | ||
852 | /* do we have a hash as expected? */ | 853 | /* We've parsed the options - do we have a hash? */ |
853 | if (!hash_expected) { | 854 | if (!hash_expected && !hash_location) |
854 | if (!hash_location) | 855 | return 0; |
855 | return 0; | 856 | |
856 | if (net_ratelimit()) { | 857 | if (hash_expected && !hash_location) { |
857 | printk(KERN_INFO "MD5 Hash NOT expected but found " | 858 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPMD5NOTFOUND); |
858 | "(" NIP6_FMT ", %u)->" | ||
859 | "(" NIP6_FMT ", %u)\n", | ||
860 | NIP6(ip6h->saddr), ntohs(th->source), | ||
861 | NIP6(ip6h->daddr), ntohs(th->dest)); | ||
862 | } | ||
863 | return 1; | 859 | return 1; |
864 | } | 860 | } |
865 | 861 | ||
866 | if (!hash_location) { | 862 | if (!hash_expected && hash_location) { |
867 | if (net_ratelimit()) { | 863 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPMD5UNEXPECTED); |
868 | printk(KERN_INFO "MD5 Hash expected but NOT found " | ||
869 | "(" NIP6_FMT ", %u)->" | ||
870 | "(" NIP6_FMT ", %u)\n", | ||
871 | NIP6(ip6h->saddr), ntohs(th->source), | ||
872 | NIP6(ip6h->daddr), ntohs(th->dest)); | ||
873 | } | ||
874 | return 1; | 864 | return 1; |
875 | } | 865 | } |
876 | 866 | ||
@@ -1105,8 +1095,8 @@ static void tcp_v6_send_ack(struct sk_buff *skb, u32 seq, u32 ack, u32 win, u32 | |||
1105 | *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | | 1095 | *topt++ = htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | |
1106 | (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); | 1096 | (TCPOPT_MD5SIG << 8) | TCPOLEN_MD5SIG); |
1107 | tcp_v6_md5_hash_hdr((__u8 *)topt, key, | 1097 | tcp_v6_md5_hash_hdr((__u8 *)topt, key, |
1108 | &ipv6_hdr(skb)->daddr, | 1098 | &ipv6_hdr(skb)->saddr, |
1109 | &ipv6_hdr(skb)->saddr, t1); | 1099 | &ipv6_hdr(skb)->daddr, t1); |
1110 | } | 1100 | } |
1111 | #endif | 1101 | #endif |
1112 | 1102 | ||
@@ -1149,10 +1139,11 @@ static void tcp_v6_timewait_ack(struct sock *sk, struct sk_buff *skb) | |||
1149 | inet_twsk_put(tw); | 1139 | inet_twsk_put(tw); |
1150 | } | 1140 | } |
1151 | 1141 | ||
1152 | static void tcp_v6_reqsk_send_ack(struct sk_buff *skb, struct request_sock *req) | 1142 | static void tcp_v6_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, |
1143 | struct request_sock *req) | ||
1153 | { | 1144 | { |
1154 | tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent, | 1145 | tcp_v6_send_ack(skb, tcp_rsk(req)->snt_isn + 1, tcp_rsk(req)->rcv_isn + 1, req->rcv_wnd, req->ts_recent, |
1155 | tcp_v6_md5_do_lookup(skb->sk, &ipv6_hdr(skb)->daddr)); | 1146 | tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->daddr)); |
1156 | } | 1147 | } |
1157 | 1148 | ||
1158 | 1149 | ||
@@ -2157,6 +2148,7 @@ static int tcpv6_net_init(struct net *net) | |||
2157 | static void tcpv6_net_exit(struct net *net) | 2148 | static void tcpv6_net_exit(struct net *net) |
2158 | { | 2149 | { |
2159 | inet_ctl_sock_destroy(net->ipv6.tcp_sk); | 2150 | inet_ctl_sock_destroy(net->ipv6.tcp_sk); |
2151 | inet_twsk_purge(net, &tcp_hashinfo, &tcp_death_row, AF_INET6); | ||
2160 | } | 2152 | } |
2161 | 2153 | ||
2162 | static struct pernet_operations tcpv6_net_ops = { | 2154 | static struct pernet_operations tcpv6_net_ops = { |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index d1477b350f76..a6aecf76a71b 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -379,7 +379,7 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb, | |||
379 | uh->source, saddr, dif))) { | 379 | uh->source, saddr, dif))) { |
380 | struct sk_buff *buff = skb_clone(skb, GFP_ATOMIC); | 380 | struct sk_buff *buff = skb_clone(skb, GFP_ATOMIC); |
381 | if (buff) { | 381 | if (buff) { |
382 | bh_lock_sock_nested(sk2); | 382 | bh_lock_sock(sk2); |
383 | if (!sock_owned_by_user(sk2)) | 383 | if (!sock_owned_by_user(sk2)) |
384 | udpv6_queue_rcv_skb(sk2, buff); | 384 | udpv6_queue_rcv_skb(sk2, buff); |
385 | else | 385 | else |
@@ -387,7 +387,7 @@ static int __udp6_lib_mcast_deliver(struct net *net, struct sk_buff *skb, | |||
387 | bh_unlock_sock(sk2); | 387 | bh_unlock_sock(sk2); |
388 | } | 388 | } |
389 | } | 389 | } |
390 | bh_lock_sock_nested(sk); | 390 | bh_lock_sock(sk); |
391 | if (!sock_owned_by_user(sk)) | 391 | if (!sock_owned_by_user(sk)) |
392 | udpv6_queue_rcv_skb(sk, skb); | 392 | udpv6_queue_rcv_skb(sk, skb); |
393 | else | 393 | else |
@@ -508,7 +508,7 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct hlist_head udptable[], | |||
508 | 508 | ||
509 | /* deliver */ | 509 | /* deliver */ |
510 | 510 | ||
511 | bh_lock_sock_nested(sk); | 511 | bh_lock_sock(sk); |
512 | if (!sock_owned_by_user(sk)) | 512 | if (!sock_owned_by_user(sk)) |
513 | udpv6_queue_rcv_skb(sk, skb); | 513 | udpv6_queue_rcv_skb(sk, skb); |
514 | else | 514 | else |
diff --git a/net/ipv6/xfrm6_mode_beet.c b/net/ipv6/xfrm6_mode_beet.c index d6ce400f585f..bbd48b101bae 100644 --- a/net/ipv6/xfrm6_mode_beet.c +++ b/net/ipv6/xfrm6_mode_beet.c | |||
@@ -40,16 +40,39 @@ static void xfrm6_beet_make_header(struct sk_buff *skb) | |||
40 | static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb) | 40 | static int xfrm6_beet_output(struct xfrm_state *x, struct sk_buff *skb) |
41 | { | 41 | { |
42 | struct ipv6hdr *top_iph; | 42 | struct ipv6hdr *top_iph; |
43 | 43 | struct ip_beet_phdr *ph; | |
44 | skb_set_network_header(skb, -x->props.header_len); | 44 | struct iphdr *iphv4; |
45 | int optlen, hdr_len; | ||
46 | |||
47 | iphv4 = ip_hdr(skb); | ||
48 | hdr_len = 0; | ||
49 | optlen = XFRM_MODE_SKB_CB(skb)->optlen; | ||
50 | if (unlikely(optlen)) | ||
51 | hdr_len += IPV4_BEET_PHMAXLEN - (optlen & 4); | ||
52 | |||
53 | skb_set_network_header(skb, -x->props.header_len - hdr_len); | ||
54 | if (x->sel.family != AF_INET6) | ||
55 | skb->network_header += IPV4_BEET_PHMAXLEN; | ||
45 | skb->mac_header = skb->network_header + | 56 | skb->mac_header = skb->network_header + |
46 | offsetof(struct ipv6hdr, nexthdr); | 57 | offsetof(struct ipv6hdr, nexthdr); |
47 | skb->transport_header = skb->network_header + sizeof(*top_iph); | 58 | skb->transport_header = skb->network_header + sizeof(*top_iph); |
48 | __skb_pull(skb, XFRM_MODE_SKB_CB(skb)->ihl); | 59 | ph = (struct ip_beet_phdr *)__skb_pull(skb, XFRM_MODE_SKB_CB(skb)->ihl-hdr_len); |
49 | 60 | ||
50 | xfrm6_beet_make_header(skb); | 61 | xfrm6_beet_make_header(skb); |
51 | 62 | ||
52 | top_iph = ipv6_hdr(skb); | 63 | top_iph = ipv6_hdr(skb); |
64 | if (unlikely(optlen)) { | ||
65 | |||
66 | BUG_ON(optlen < 0); | ||
67 | |||
68 | ph->padlen = 4 - (optlen & 4); | ||
69 | ph->hdrlen = optlen / 8; | ||
70 | ph->nexthdr = top_iph->nexthdr; | ||
71 | if (ph->padlen) | ||
72 | memset(ph + 1, IPOPT_NOP, ph->padlen); | ||
73 | |||
74 | top_iph->nexthdr = IPPROTO_BEETPH; | ||
75 | } | ||
53 | 76 | ||
54 | ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr); | 77 | ipv6_addr_copy(&top_iph->saddr, (struct in6_addr *)&x->props.saddr); |
55 | ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr); | 78 | ipv6_addr_copy(&top_iph->daddr, (struct in6_addr *)&x->id.daddr); |
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c index 8f1e0543b3c4..08e4cbbe3f04 100644 --- a/net/ipv6/xfrm6_policy.c +++ b/net/ipv6/xfrm6_policy.c | |||
@@ -52,12 +52,14 @@ static struct dst_entry *xfrm6_dst_lookup(int tos, xfrm_address_t *saddr, | |||
52 | static int xfrm6_get_saddr(xfrm_address_t *saddr, xfrm_address_t *daddr) | 52 | static int xfrm6_get_saddr(xfrm_address_t *saddr, xfrm_address_t *daddr) |
53 | { | 53 | { |
54 | struct dst_entry *dst; | 54 | struct dst_entry *dst; |
55 | struct net_device *dev; | ||
55 | 56 | ||
56 | dst = xfrm6_dst_lookup(0, NULL, daddr); | 57 | dst = xfrm6_dst_lookup(0, NULL, daddr); |
57 | if (IS_ERR(dst)) | 58 | if (IS_ERR(dst)) |
58 | return -EHOSTUNREACH; | 59 | return -EHOSTUNREACH; |
59 | 60 | ||
60 | ipv6_dev_get_saddr(ip6_dst_idev(dst)->dev, | 61 | dev = ip6_dst_idev(dst)->dev; |
62 | ipv6_dev_get_saddr(dev_net(dev), dev, | ||
61 | (struct in6_addr *)&daddr->a6, 0, | 63 | (struct in6_addr *)&daddr->a6, 0, |
62 | (struct in6_addr *)&saddr->a6); | 64 | (struct in6_addr *)&saddr->a6); |
63 | dst_release(dst); | 65 | dst_release(dst); |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index 8e7ba0e62cf5..297c257864c7 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -81,6 +81,7 @@ static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, | |||
81 | enum nl80211_iftype type, u32 *flags, | 81 | enum nl80211_iftype type, u32 *flags, |
82 | struct vif_params *params) | 82 | struct vif_params *params) |
83 | { | 83 | { |
84 | struct ieee80211_local *local = wiphy_priv(wiphy); | ||
84 | struct net_device *dev; | 85 | struct net_device *dev; |
85 | enum ieee80211_if_types itype; | 86 | enum ieee80211_if_types itype; |
86 | struct ieee80211_sub_if_data *sdata; | 87 | struct ieee80211_sub_if_data *sdata; |
@@ -95,6 +96,9 @@ static int ieee80211_change_iface(struct wiphy *wiphy, int ifindex, | |||
95 | if (itype == IEEE80211_IF_TYPE_INVALID) | 96 | if (itype == IEEE80211_IF_TYPE_INVALID) |
96 | return -EINVAL; | 97 | return -EINVAL; |
97 | 98 | ||
99 | if (dev == local->mdev) | ||
100 | return -EOPNOTSUPP; | ||
101 | |||
98 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 102 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
99 | 103 | ||
100 | ret = ieee80211_if_change_type(sdata, itype); | 104 | ret = ieee80211_if_change_type(sdata, itype); |
@@ -117,12 +121,16 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
117 | u8 key_idx, u8 *mac_addr, | 121 | u8 key_idx, u8 *mac_addr, |
118 | struct key_params *params) | 122 | struct key_params *params) |
119 | { | 123 | { |
124 | struct ieee80211_local *local = wiphy_priv(wiphy); | ||
120 | struct ieee80211_sub_if_data *sdata; | 125 | struct ieee80211_sub_if_data *sdata; |
121 | struct sta_info *sta = NULL; | 126 | struct sta_info *sta = NULL; |
122 | enum ieee80211_key_alg alg; | 127 | enum ieee80211_key_alg alg; |
123 | struct ieee80211_key *key; | 128 | struct ieee80211_key *key; |
124 | int err; | 129 | int err; |
125 | 130 | ||
131 | if (dev == local->mdev) | ||
132 | return -EOPNOTSUPP; | ||
133 | |||
126 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 134 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
127 | 135 | ||
128 | switch (params->cipher) { | 136 | switch (params->cipher) { |
@@ -167,10 +175,14 @@ static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev, | |||
167 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, | 175 | static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, |
168 | u8 key_idx, u8 *mac_addr) | 176 | u8 key_idx, u8 *mac_addr) |
169 | { | 177 | { |
178 | struct ieee80211_local *local = wiphy_priv(wiphy); | ||
170 | struct ieee80211_sub_if_data *sdata; | 179 | struct ieee80211_sub_if_data *sdata; |
171 | struct sta_info *sta; | 180 | struct sta_info *sta; |
172 | int ret; | 181 | int ret; |
173 | 182 | ||
183 | if (dev == local->mdev) | ||
184 | return -EOPNOTSUPP; | ||
185 | |||
174 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 186 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
175 | 187 | ||
176 | rcu_read_lock(); | 188 | rcu_read_lock(); |
@@ -211,7 +223,8 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, | |||
211 | void (*callback)(void *cookie, | 223 | void (*callback)(void *cookie, |
212 | struct key_params *params)) | 224 | struct key_params *params)) |
213 | { | 225 | { |
214 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 226 | struct ieee80211_local *local = wiphy_priv(wiphy); |
227 | struct ieee80211_sub_if_data *sdata; | ||
215 | struct sta_info *sta = NULL; | 228 | struct sta_info *sta = NULL; |
216 | u8 seq[6] = {0}; | 229 | u8 seq[6] = {0}; |
217 | struct key_params params; | 230 | struct key_params params; |
@@ -220,6 +233,11 @@ static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev, | |||
220 | u16 iv16; | 233 | u16 iv16; |
221 | int err = -ENOENT; | 234 | int err = -ENOENT; |
222 | 235 | ||
236 | if (dev == local->mdev) | ||
237 | return -EOPNOTSUPP; | ||
238 | |||
239 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
240 | |||
223 | rcu_read_lock(); | 241 | rcu_read_lock(); |
224 | 242 | ||
225 | if (mac_addr) { | 243 | if (mac_addr) { |
@@ -293,8 +311,12 @@ static int ieee80211_config_default_key(struct wiphy *wiphy, | |||
293 | struct net_device *dev, | 311 | struct net_device *dev, |
294 | u8 key_idx) | 312 | u8 key_idx) |
295 | { | 313 | { |
314 | struct ieee80211_local *local = wiphy_priv(wiphy); | ||
296 | struct ieee80211_sub_if_data *sdata; | 315 | struct ieee80211_sub_if_data *sdata; |
297 | 316 | ||
317 | if (dev == local->mdev) | ||
318 | return -EOPNOTSUPP; | ||
319 | |||
298 | rcu_read_lock(); | 320 | rcu_read_lock(); |
299 | 321 | ||
300 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 322 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
@@ -475,9 +497,15 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata, | |||
475 | static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, | 497 | static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, |
476 | struct beacon_parameters *params) | 498 | struct beacon_parameters *params) |
477 | { | 499 | { |
478 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 500 | struct ieee80211_local *local = wiphy_priv(wiphy); |
501 | struct ieee80211_sub_if_data *sdata; | ||
479 | struct beacon_data *old; | 502 | struct beacon_data *old; |
480 | 503 | ||
504 | if (dev == local->mdev) | ||
505 | return -EOPNOTSUPP; | ||
506 | |||
507 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
508 | |||
481 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) | 509 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
482 | return -EINVAL; | 510 | return -EINVAL; |
483 | 511 | ||
@@ -492,9 +520,15 @@ static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, | |||
492 | static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, | 520 | static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, |
493 | struct beacon_parameters *params) | 521 | struct beacon_parameters *params) |
494 | { | 522 | { |
495 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 523 | struct ieee80211_local *local = wiphy_priv(wiphy); |
524 | struct ieee80211_sub_if_data *sdata; | ||
496 | struct beacon_data *old; | 525 | struct beacon_data *old; |
497 | 526 | ||
527 | if (dev == local->mdev) | ||
528 | return -EOPNOTSUPP; | ||
529 | |||
530 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
531 | |||
498 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) | 532 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
499 | return -EINVAL; | 533 | return -EINVAL; |
500 | 534 | ||
@@ -508,9 +542,15 @@ static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, | |||
508 | 542 | ||
509 | static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) | 543 | static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) |
510 | { | 544 | { |
511 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 545 | struct ieee80211_local *local = wiphy_priv(wiphy); |
546 | struct ieee80211_sub_if_data *sdata; | ||
512 | struct beacon_data *old; | 547 | struct beacon_data *old; |
513 | 548 | ||
549 | if (dev == local->mdev) | ||
550 | return -EOPNOTSUPP; | ||
551 | |||
552 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
553 | |||
514 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) | 554 | if (sdata->vif.type != IEEE80211_IF_TYPE_AP) |
515 | return -EINVAL; | 555 | return -EINVAL; |
516 | 556 | ||
@@ -646,11 +686,14 @@ static void sta_apply_parameters(struct ieee80211_local *local, | |||
646 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | 686 | static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, |
647 | u8 *mac, struct station_parameters *params) | 687 | u8 *mac, struct station_parameters *params) |
648 | { | 688 | { |
649 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 689 | struct ieee80211_local *local = wiphy_priv(wiphy); |
650 | struct sta_info *sta; | 690 | struct sta_info *sta; |
651 | struct ieee80211_sub_if_data *sdata; | 691 | struct ieee80211_sub_if_data *sdata; |
652 | int err; | 692 | int err; |
653 | 693 | ||
694 | if (dev == local->mdev || params->vlan == local->mdev) | ||
695 | return -EOPNOTSUPP; | ||
696 | |||
654 | /* Prevent a race with changing the rate control algorithm */ | 697 | /* Prevent a race with changing the rate control algorithm */ |
655 | if (!netif_running(dev)) | 698 | if (!netif_running(dev)) |
656 | return -ENETDOWN; | 699 | return -ENETDOWN; |
@@ -701,10 +744,15 @@ static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, | |||
701 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, | 744 | static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, |
702 | u8 *mac) | 745 | u8 *mac) |
703 | { | 746 | { |
704 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 747 | struct ieee80211_local *local = wiphy_priv(wiphy); |
705 | struct ieee80211_local *local = sdata->local; | 748 | struct ieee80211_sub_if_data *sdata; |
706 | struct sta_info *sta; | 749 | struct sta_info *sta; |
707 | 750 | ||
751 | if (dev == local->mdev) | ||
752 | return -EOPNOTSUPP; | ||
753 | |||
754 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
755 | |||
708 | if (mac) { | 756 | if (mac) { |
709 | rcu_read_lock(); | 757 | rcu_read_lock(); |
710 | 758 | ||
@@ -730,10 +778,13 @@ static int ieee80211_change_station(struct wiphy *wiphy, | |||
730 | u8 *mac, | 778 | u8 *mac, |
731 | struct station_parameters *params) | 779 | struct station_parameters *params) |
732 | { | 780 | { |
733 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 781 | struct ieee80211_local *local = wiphy_priv(wiphy); |
734 | struct sta_info *sta; | 782 | struct sta_info *sta; |
735 | struct ieee80211_sub_if_data *vlansdata; | 783 | struct ieee80211_sub_if_data *vlansdata; |
736 | 784 | ||
785 | if (dev == local->mdev || params->vlan == local->mdev) | ||
786 | return -EOPNOTSUPP; | ||
787 | |||
737 | rcu_read_lock(); | 788 | rcu_read_lock(); |
738 | 789 | ||
739 | /* XXX: get sta belonging to dev */ | 790 | /* XXX: get sta belonging to dev */ |
@@ -752,7 +803,7 @@ static int ieee80211_change_station(struct wiphy *wiphy, | |||
752 | return -EINVAL; | 803 | return -EINVAL; |
753 | } | 804 | } |
754 | 805 | ||
755 | sta->sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); | 806 | sta->sdata = vlansdata; |
756 | ieee80211_send_layer2_update(sta); | 807 | ieee80211_send_layer2_update(sta); |
757 | } | 808 | } |
758 | 809 | ||
@@ -767,15 +818,20 @@ static int ieee80211_change_station(struct wiphy *wiphy, | |||
767 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, | 818 | static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, |
768 | u8 *dst, u8 *next_hop) | 819 | u8 *dst, u8 *next_hop) |
769 | { | 820 | { |
770 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 821 | struct ieee80211_local *local = wiphy_priv(wiphy); |
771 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 822 | struct ieee80211_sub_if_data *sdata; |
772 | struct mesh_path *mpath; | 823 | struct mesh_path *mpath; |
773 | struct sta_info *sta; | 824 | struct sta_info *sta; |
774 | int err; | 825 | int err; |
775 | 826 | ||
827 | if (dev == local->mdev) | ||
828 | return -EOPNOTSUPP; | ||
829 | |||
776 | if (!netif_running(dev)) | 830 | if (!netif_running(dev)) |
777 | return -ENETDOWN; | 831 | return -ENETDOWN; |
778 | 832 | ||
833 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
834 | |||
779 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) | 835 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
780 | return -ENOTSUPP; | 836 | return -ENOTSUPP; |
781 | 837 | ||
@@ -817,14 +873,19 @@ static int ieee80211_change_mpath(struct wiphy *wiphy, | |||
817 | struct net_device *dev, | 873 | struct net_device *dev, |
818 | u8 *dst, u8 *next_hop) | 874 | u8 *dst, u8 *next_hop) |
819 | { | 875 | { |
820 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 876 | struct ieee80211_local *local = wiphy_priv(wiphy); |
821 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 877 | struct ieee80211_sub_if_data *sdata; |
822 | struct mesh_path *mpath; | 878 | struct mesh_path *mpath; |
823 | struct sta_info *sta; | 879 | struct sta_info *sta; |
824 | 880 | ||
881 | if (dev == local->mdev) | ||
882 | return -EOPNOTSUPP; | ||
883 | |||
825 | if (!netif_running(dev)) | 884 | if (!netif_running(dev)) |
826 | return -ENETDOWN; | 885 | return -ENETDOWN; |
827 | 886 | ||
887 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
888 | |||
828 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) | 889 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
829 | return -ENOTSUPP; | 890 | return -ENOTSUPP; |
830 | 891 | ||
@@ -891,9 +952,15 @@ static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
891 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) | 952 | u8 *dst, u8 *next_hop, struct mpath_info *pinfo) |
892 | 953 | ||
893 | { | 954 | { |
894 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 955 | struct ieee80211_local *local = wiphy_priv(wiphy); |
956 | struct ieee80211_sub_if_data *sdata; | ||
895 | struct mesh_path *mpath; | 957 | struct mesh_path *mpath; |
896 | 958 | ||
959 | if (dev == local->mdev) | ||
960 | return -EOPNOTSUPP; | ||
961 | |||
962 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
963 | |||
897 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) | 964 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
898 | return -ENOTSUPP; | 965 | return -ENOTSUPP; |
899 | 966 | ||
@@ -913,9 +980,15 @@ static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev, | |||
913 | int idx, u8 *dst, u8 *next_hop, | 980 | int idx, u8 *dst, u8 *next_hop, |
914 | struct mpath_info *pinfo) | 981 | struct mpath_info *pinfo) |
915 | { | 982 | { |
916 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 983 | struct ieee80211_local *local = wiphy_priv(wiphy); |
984 | struct ieee80211_sub_if_data *sdata; | ||
917 | struct mesh_path *mpath; | 985 | struct mesh_path *mpath; |
918 | 986 | ||
987 | if (dev == local->mdev) | ||
988 | return -EOPNOTSUPP; | ||
989 | |||
990 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | ||
991 | |||
919 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) | 992 | if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) |
920 | return -ENOTSUPP; | 993 | return -ENOTSUPP; |
921 | 994 | ||
diff --git a/net/mac80211/debugfs_key.c b/net/mac80211/debugfs_key.c index 7439b63df5d0..cf82acec913a 100644 --- a/net/mac80211/debugfs_key.c +++ b/net/mac80211/debugfs_key.c | |||
@@ -265,7 +265,7 @@ void ieee80211_debugfs_key_add_default(struct ieee80211_sub_if_data *sdata) | |||
265 | key = sdata->default_key; | 265 | key = sdata->default_key; |
266 | if (key) { | 266 | if (key) { |
267 | sprintf(buf, "../keys/%d", key->debugfs.cnt); | 267 | sprintf(buf, "../keys/%d", key->debugfs.cnt); |
268 | sdata->debugfs.default_key = | 268 | sdata->common_debugfs.default_key = |
269 | debugfs_create_symlink("default_key", | 269 | debugfs_create_symlink("default_key", |
270 | sdata->debugfsdir, buf); | 270 | sdata->debugfsdir, buf); |
271 | } else | 271 | } else |
@@ -277,8 +277,8 @@ void ieee80211_debugfs_key_remove_default(struct ieee80211_sub_if_data *sdata) | |||
277 | if (!sdata) | 277 | if (!sdata) |
278 | return; | 278 | return; |
279 | 279 | ||
280 | debugfs_remove(sdata->debugfs.default_key); | 280 | debugfs_remove(sdata->common_debugfs.default_key); |
281 | sdata->debugfs.default_key = NULL; | 281 | sdata->common_debugfs.default_key = NULL; |
282 | } | 282 | } |
283 | 283 | ||
284 | void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, | 284 | void ieee80211_debugfs_key_sta_del(struct ieee80211_key *key, |
diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c index 475f89a8aee1..8165df578c92 100644 --- a/net/mac80211/debugfs_netdev.c +++ b/net/mac80211/debugfs_netdev.c | |||
@@ -248,8 +248,8 @@ IEEE80211_IF_WFILE(min_discovery_timeout, | |||
248 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) | 248 | static void add_sta_files(struct ieee80211_sub_if_data *sdata) |
249 | { | 249 | { |
250 | DEBUGFS_ADD(drop_unencrypted, sta); | 250 | DEBUGFS_ADD(drop_unencrypted, sta); |
251 | DEBUGFS_ADD(force_unicast_rateidx, ap); | 251 | DEBUGFS_ADD(force_unicast_rateidx, sta); |
252 | DEBUGFS_ADD(max_ratectrl_rateidx, ap); | 252 | DEBUGFS_ADD(max_ratectrl_rateidx, sta); |
253 | 253 | ||
254 | DEBUGFS_ADD(state, sta); | 254 | DEBUGFS_ADD(state, sta); |
255 | DEBUGFS_ADD(bssid, sta); | 255 | DEBUGFS_ADD(bssid, sta); |
@@ -283,8 +283,8 @@ static void add_ap_files(struct ieee80211_sub_if_data *sdata) | |||
283 | static void add_wds_files(struct ieee80211_sub_if_data *sdata) | 283 | static void add_wds_files(struct ieee80211_sub_if_data *sdata) |
284 | { | 284 | { |
285 | DEBUGFS_ADD(drop_unencrypted, wds); | 285 | DEBUGFS_ADD(drop_unencrypted, wds); |
286 | DEBUGFS_ADD(force_unicast_rateidx, ap); | 286 | DEBUGFS_ADD(force_unicast_rateidx, wds); |
287 | DEBUGFS_ADD(max_ratectrl_rateidx, ap); | 287 | DEBUGFS_ADD(max_ratectrl_rateidx, wds); |
288 | 288 | ||
289 | DEBUGFS_ADD(peer, wds); | 289 | DEBUGFS_ADD(peer, wds); |
290 | } | 290 | } |
@@ -292,8 +292,8 @@ static void add_wds_files(struct ieee80211_sub_if_data *sdata) | |||
292 | static void add_vlan_files(struct ieee80211_sub_if_data *sdata) | 292 | static void add_vlan_files(struct ieee80211_sub_if_data *sdata) |
293 | { | 293 | { |
294 | DEBUGFS_ADD(drop_unencrypted, vlan); | 294 | DEBUGFS_ADD(drop_unencrypted, vlan); |
295 | DEBUGFS_ADD(force_unicast_rateidx, ap); | 295 | DEBUGFS_ADD(force_unicast_rateidx, vlan); |
296 | DEBUGFS_ADD(max_ratectrl_rateidx, ap); | 296 | DEBUGFS_ADD(max_ratectrl_rateidx, vlan); |
297 | } | 297 | } |
298 | 298 | ||
299 | static void add_monitor_files(struct ieee80211_sub_if_data *sdata) | 299 | static void add_monitor_files(struct ieee80211_sub_if_data *sdata) |
@@ -381,8 +381,8 @@ static void add_files(struct ieee80211_sub_if_data *sdata) | |||
381 | static void del_sta_files(struct ieee80211_sub_if_data *sdata) | 381 | static void del_sta_files(struct ieee80211_sub_if_data *sdata) |
382 | { | 382 | { |
383 | DEBUGFS_DEL(drop_unencrypted, sta); | 383 | DEBUGFS_DEL(drop_unencrypted, sta); |
384 | DEBUGFS_DEL(force_unicast_rateidx, ap); | 384 | DEBUGFS_DEL(force_unicast_rateidx, sta); |
385 | DEBUGFS_DEL(max_ratectrl_rateidx, ap); | 385 | DEBUGFS_DEL(max_ratectrl_rateidx, sta); |
386 | 386 | ||
387 | DEBUGFS_DEL(state, sta); | 387 | DEBUGFS_DEL(state, sta); |
388 | DEBUGFS_DEL(bssid, sta); | 388 | DEBUGFS_DEL(bssid, sta); |
@@ -416,8 +416,8 @@ static void del_ap_files(struct ieee80211_sub_if_data *sdata) | |||
416 | static void del_wds_files(struct ieee80211_sub_if_data *sdata) | 416 | static void del_wds_files(struct ieee80211_sub_if_data *sdata) |
417 | { | 417 | { |
418 | DEBUGFS_DEL(drop_unencrypted, wds); | 418 | DEBUGFS_DEL(drop_unencrypted, wds); |
419 | DEBUGFS_DEL(force_unicast_rateidx, ap); | 419 | DEBUGFS_DEL(force_unicast_rateidx, wds); |
420 | DEBUGFS_DEL(max_ratectrl_rateidx, ap); | 420 | DEBUGFS_DEL(max_ratectrl_rateidx, wds); |
421 | 421 | ||
422 | DEBUGFS_DEL(peer, wds); | 422 | DEBUGFS_DEL(peer, wds); |
423 | } | 423 | } |
@@ -425,8 +425,8 @@ static void del_wds_files(struct ieee80211_sub_if_data *sdata) | |||
425 | static void del_vlan_files(struct ieee80211_sub_if_data *sdata) | 425 | static void del_vlan_files(struct ieee80211_sub_if_data *sdata) |
426 | { | 426 | { |
427 | DEBUGFS_DEL(drop_unencrypted, vlan); | 427 | DEBUGFS_DEL(drop_unencrypted, vlan); |
428 | DEBUGFS_DEL(force_unicast_rateidx, ap); | 428 | DEBUGFS_DEL(force_unicast_rateidx, vlan); |
429 | DEBUGFS_DEL(max_ratectrl_rateidx, ap); | 429 | DEBUGFS_DEL(max_ratectrl_rateidx, vlan); |
430 | } | 430 | } |
431 | 431 | ||
432 | static void del_monitor_files(struct ieee80211_sub_if_data *sdata) | 432 | static void del_monitor_files(struct ieee80211_sub_if_data *sdata) |
diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h index a4f9a832722a..4498d8713652 100644 --- a/net/mac80211/ieee80211_i.h +++ b/net/mac80211/ieee80211_i.h | |||
@@ -82,6 +82,7 @@ struct ieee80211_sta_bss { | |||
82 | 82 | ||
83 | u8 bssid[ETH_ALEN]; | 83 | u8 bssid[ETH_ALEN]; |
84 | u8 ssid[IEEE80211_MAX_SSID_LEN]; | 84 | u8 ssid[IEEE80211_MAX_SSID_LEN]; |
85 | u8 dtim_period; | ||
85 | u16 capability; /* host byte order */ | 86 | u16 capability; /* host byte order */ |
86 | enum ieee80211_band band; | 87 | enum ieee80211_band band; |
87 | int freq; | 88 | int freq; |
@@ -469,6 +470,8 @@ struct ieee80211_sub_if_data { | |||
469 | struct dentry *auth_transaction; | 470 | struct dentry *auth_transaction; |
470 | struct dentry *flags; | 471 | struct dentry *flags; |
471 | struct dentry *num_beacons_sta; | 472 | struct dentry *num_beacons_sta; |
473 | struct dentry *force_unicast_rateidx; | ||
474 | struct dentry *max_ratectrl_rateidx; | ||
472 | } sta; | 475 | } sta; |
473 | struct { | 476 | struct { |
474 | struct dentry *drop_unencrypted; | 477 | struct dentry *drop_unencrypted; |
@@ -482,15 +485,21 @@ struct ieee80211_sub_if_data { | |||
482 | struct { | 485 | struct { |
483 | struct dentry *drop_unencrypted; | 486 | struct dentry *drop_unencrypted; |
484 | struct dentry *peer; | 487 | struct dentry *peer; |
488 | struct dentry *force_unicast_rateidx; | ||
489 | struct dentry *max_ratectrl_rateidx; | ||
485 | } wds; | 490 | } wds; |
486 | struct { | 491 | struct { |
487 | struct dentry *drop_unencrypted; | 492 | struct dentry *drop_unencrypted; |
493 | struct dentry *force_unicast_rateidx; | ||
494 | struct dentry *max_ratectrl_rateidx; | ||
488 | } vlan; | 495 | } vlan; |
489 | struct { | 496 | struct { |
490 | struct dentry *mode; | 497 | struct dentry *mode; |
491 | } monitor; | 498 | } monitor; |
492 | struct dentry *default_key; | ||
493 | } debugfs; | 499 | } debugfs; |
500 | struct { | ||
501 | struct dentry *default_key; | ||
502 | } common_debugfs; | ||
494 | 503 | ||
495 | #ifdef CONFIG_MAC80211_MESH | 504 | #ifdef CONFIG_MAC80211_MESH |
496 | struct dentry *mesh_stats_dir; | 505 | struct dentry *mesh_stats_dir; |
@@ -586,6 +595,7 @@ struct ieee80211_local { | |||
586 | struct timer_list sta_cleanup; | 595 | struct timer_list sta_cleanup; |
587 | 596 | ||
588 | unsigned long queues_pending[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)]; | 597 | unsigned long queues_pending[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)]; |
598 | unsigned long queues_pending_run[BITS_TO_LONGS(IEEE80211_MAX_QUEUES)]; | ||
589 | struct ieee80211_tx_stored_packet pending_packet[IEEE80211_MAX_QUEUES]; | 599 | struct ieee80211_tx_stored_packet pending_packet[IEEE80211_MAX_QUEUES]; |
590 | struct tasklet_struct tx_pending_tasklet; | 600 | struct tasklet_struct tx_pending_tasklet; |
591 | 601 | ||
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index f1a83d450ea0..aa5a191598c9 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
@@ -245,10 +245,13 @@ static int ieee80211_open(struct net_device *dev) | |||
245 | case IEEE80211_IF_TYPE_AP: | 245 | case IEEE80211_IF_TYPE_AP: |
246 | sdata->bss = &sdata->u.ap; | 246 | sdata->bss = &sdata->u.ap; |
247 | break; | 247 | break; |
248 | case IEEE80211_IF_TYPE_MESH_POINT: | ||
249 | /* mesh ifaces must set allmulti to forward mcast traffic */ | ||
250 | atomic_inc(&local->iff_allmultis); | ||
251 | break; | ||
248 | case IEEE80211_IF_TYPE_STA: | 252 | case IEEE80211_IF_TYPE_STA: |
249 | case IEEE80211_IF_TYPE_MNTR: | 253 | case IEEE80211_IF_TYPE_MNTR: |
250 | case IEEE80211_IF_TYPE_IBSS: | 254 | case IEEE80211_IF_TYPE_IBSS: |
251 | case IEEE80211_IF_TYPE_MESH_POINT: | ||
252 | /* no special treatment */ | 255 | /* no special treatment */ |
253 | break; | 256 | break; |
254 | case IEEE80211_IF_TYPE_INVALID: | 257 | case IEEE80211_IF_TYPE_INVALID: |
@@ -495,6 +498,9 @@ static int ieee80211_stop(struct net_device *dev) | |||
495 | netif_addr_unlock_bh(local->mdev); | 498 | netif_addr_unlock_bh(local->mdev); |
496 | break; | 499 | break; |
497 | case IEEE80211_IF_TYPE_MESH_POINT: | 500 | case IEEE80211_IF_TYPE_MESH_POINT: |
501 | /* allmulti is always set on mesh ifaces */ | ||
502 | atomic_dec(&local->iff_allmultis); | ||
503 | /* fall through */ | ||
498 | case IEEE80211_IF_TYPE_STA: | 504 | case IEEE80211_IF_TYPE_STA: |
499 | case IEEE80211_IF_TYPE_IBSS: | 505 | case IEEE80211_IF_TYPE_IBSS: |
500 | sdata->u.sta.state = IEEE80211_DISABLED; | 506 | sdata->u.sta.state = IEEE80211_DISABLED; |
@@ -1233,18 +1239,12 @@ static void ieee80211_tasklet_handler(unsigned long data) | |||
1233 | /* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to | 1239 | /* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to |
1234 | * make a prepared TX frame (one that has been given to hw) to look like brand | 1240 | * make a prepared TX frame (one that has been given to hw) to look like brand |
1235 | * new IEEE 802.11 frame that is ready to go through TX processing again. | 1241 | * new IEEE 802.11 frame that is ready to go through TX processing again. |
1236 | * Also, tx_packet_data in cb is restored from tx_control. */ | 1242 | */ |
1237 | static void ieee80211_remove_tx_extra(struct ieee80211_local *local, | 1243 | static void ieee80211_remove_tx_extra(struct ieee80211_local *local, |
1238 | struct ieee80211_key *key, | 1244 | struct ieee80211_key *key, |
1239 | struct sk_buff *skb) | 1245 | struct sk_buff *skb) |
1240 | { | 1246 | { |
1241 | int hdrlen, iv_len, mic_len; | 1247 | int hdrlen, iv_len, mic_len; |
1242 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1243 | |||
1244 | info->flags &= IEEE80211_TX_CTL_REQ_TX_STATUS | | ||
1245 | IEEE80211_TX_CTL_DO_NOT_ENCRYPT | | ||
1246 | IEEE80211_TX_CTL_REQUEUE | | ||
1247 | IEEE80211_TX_CTL_EAPOL_FRAME; | ||
1248 | 1248 | ||
1249 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | 1249 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); |
1250 | 1250 | ||
@@ -1695,6 +1695,11 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
1695 | if (local->hw.conf.beacon_int < 10) | 1695 | if (local->hw.conf.beacon_int < 10) |
1696 | local->hw.conf.beacon_int = 100; | 1696 | local->hw.conf.beacon_int = 100; |
1697 | 1697 | ||
1698 | if (local->hw.max_listen_interval == 0) | ||
1699 | local->hw.max_listen_interval = 1; | ||
1700 | |||
1701 | local->hw.conf.listen_interval = local->hw.max_listen_interval; | ||
1702 | |||
1698 | local->wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC | | 1703 | local->wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC | |
1699 | IEEE80211_HW_SIGNAL_DB | | 1704 | IEEE80211_HW_SIGNAL_DB | |
1700 | IEEE80211_HW_SIGNAL_DBM) ? | 1705 | IEEE80211_HW_SIGNAL_DBM) ? |
@@ -1731,8 +1736,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) | |||
1731 | result = ieee80211_wep_init(local); | 1736 | result = ieee80211_wep_init(local); |
1732 | 1737 | ||
1733 | if (result < 0) { | 1738 | if (result < 0) { |
1734 | printk(KERN_DEBUG "%s: Failed to initialize wep\n", | 1739 | printk(KERN_DEBUG "%s: Failed to initialize wep: %d\n", |
1735 | wiphy_name(local->hw.wiphy)); | 1740 | wiphy_name(local->hw.wiphy), result); |
1736 | goto fail_wep; | 1741 | goto fail_wep; |
1737 | } | 1742 | } |
1738 | 1743 | ||
diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index b5933b271491..35f2f95f2fa7 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c | |||
@@ -383,7 +383,7 @@ errcopy: | |||
383 | hlist_for_each_safe(p, q, &newtbl->hash_buckets[i]) | 383 | hlist_for_each_safe(p, q, &newtbl->hash_buckets[i]) |
384 | tbl->free_node(p, 0); | 384 | tbl->free_node(p, 0); |
385 | } | 385 | } |
386 | __mesh_table_free(tbl); | 386 | __mesh_table_free(newtbl); |
387 | endgrow: | 387 | endgrow: |
388 | return NULL; | 388 | return NULL; |
389 | } | 389 | } |
diff --git a/net/mac80211/mesh.h b/net/mac80211/mesh.h index 669eafafe497..7495fbb0d211 100644 --- a/net/mac80211/mesh.h +++ b/net/mac80211/mesh.h | |||
@@ -214,8 +214,7 @@ void ieee80211s_stop(void); | |||
214 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); | 214 | void ieee80211_mesh_init_sdata(struct ieee80211_sub_if_data *sdata); |
215 | 215 | ||
216 | /* Mesh paths */ | 216 | /* Mesh paths */ |
217 | int mesh_nexthop_lookup(u8 *next_hop, struct sk_buff *skb, | 217 | int mesh_nexthop_lookup(struct sk_buff *skb, struct net_device *dev); |
218 | struct net_device *dev); | ||
219 | void mesh_path_start_discovery(struct net_device *dev); | 218 | void mesh_path_start_discovery(struct net_device *dev); |
220 | struct mesh_path *mesh_path_lookup(u8 *dst, struct net_device *dev); | 219 | struct mesh_path *mesh_path_lookup(u8 *dst, struct net_device *dev); |
221 | struct mesh_path *mesh_path_lookup_by_idx(int idx, struct net_device *dev); | 220 | struct mesh_path *mesh_path_lookup_by_idx(int idx, struct net_device *dev); |
@@ -286,6 +285,4 @@ static inline void mesh_path_activate(struct mesh_path *mpath) | |||
286 | #define mesh_allocated 0 | 285 | #define mesh_allocated 0 |
287 | #endif | 286 | #endif |
288 | 287 | ||
289 | #define MESH_PREQ(skb) (skb->cb + 30) | ||
290 | |||
291 | #endif /* IEEE80211S_H */ | 288 | #endif /* IEEE80211S_H */ |
diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c index 7fa149e230e6..08aca446ca01 100644 --- a/net/mac80211/mesh_hwmp.c +++ b/net/mac80211/mesh_hwmp.c | |||
@@ -758,29 +758,30 @@ enddiscovery: | |||
758 | /** | 758 | /** |
759 | * ieee80211s_lookup_nexthop - put the appropriate next hop on a mesh frame | 759 | * ieee80211s_lookup_nexthop - put the appropriate next hop on a mesh frame |
760 | * | 760 | * |
761 | * @next_hop: output argument for next hop address | 761 | * @skb: 802.11 frame to be sent |
762 | * @skb: frame to be sent | ||
763 | * @dev: network device the frame will be sent through | 762 | * @dev: network device the frame will be sent through |
763 | * @fwd_frame: true if this frame was originally from a different host | ||
764 | * | 764 | * |
765 | * Returns: 0 if the next hop was found. Nonzero otherwise. If no next hop is | 765 | * Returns: 0 if the next hop was found. Nonzero otherwise. If no next hop is |
766 | * found, the function will start a path discovery and queue the frame so it is | 766 | * found, the function will start a path discovery and queue the frame so it is |
767 | * sent when the path is resolved. This means the caller must not free the skb | 767 | * sent when the path is resolved. This means the caller must not free the skb |
768 | * in this case. | 768 | * in this case. |
769 | */ | 769 | */ |
770 | int mesh_nexthop_lookup(u8 *next_hop, struct sk_buff *skb, | 770 | int mesh_nexthop_lookup(struct sk_buff *skb, struct net_device *dev) |
771 | struct net_device *dev) | ||
772 | { | 771 | { |
773 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 772 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
774 | struct sk_buff *skb_to_free = NULL; | 773 | struct sk_buff *skb_to_free = NULL; |
775 | struct mesh_path *mpath; | 774 | struct mesh_path *mpath; |
775 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
776 | u8 *dst_addr = hdr->addr3; | ||
776 | int err = 0; | 777 | int err = 0; |
777 | 778 | ||
778 | rcu_read_lock(); | 779 | rcu_read_lock(); |
779 | mpath = mesh_path_lookup(skb->data, dev); | 780 | mpath = mesh_path_lookup(dst_addr, dev); |
780 | 781 | ||
781 | if (!mpath) { | 782 | if (!mpath) { |
782 | mesh_path_add(skb->data, dev); | 783 | mesh_path_add(dst_addr, dev); |
783 | mpath = mesh_path_lookup(skb->data, dev); | 784 | mpath = mesh_path_lookup(dst_addr, dev); |
784 | if (!mpath) { | 785 | if (!mpath) { |
785 | dev_kfree_skb(skb); | 786 | dev_kfree_skb(skb); |
786 | sdata->u.sta.mshstats.dropped_frames_no_route++; | 787 | sdata->u.sta.mshstats.dropped_frames_no_route++; |
@@ -792,13 +793,13 @@ int mesh_nexthop_lookup(u8 *next_hop, struct sk_buff *skb, | |||
792 | if (mpath->flags & MESH_PATH_ACTIVE) { | 793 | if (mpath->flags & MESH_PATH_ACTIVE) { |
793 | if (time_after(jiffies, mpath->exp_time - | 794 | if (time_after(jiffies, mpath->exp_time - |
794 | msecs_to_jiffies(sdata->u.sta.mshcfg.path_refresh_time)) | 795 | msecs_to_jiffies(sdata->u.sta.mshcfg.path_refresh_time)) |
795 | && skb->pkt_type != PACKET_OTHERHOST | 796 | && !memcmp(dev->dev_addr, hdr->addr4, ETH_ALEN) |
796 | && !(mpath->flags & MESH_PATH_RESOLVING) | 797 | && !(mpath->flags & MESH_PATH_RESOLVING) |
797 | && !(mpath->flags & MESH_PATH_FIXED)) { | 798 | && !(mpath->flags & MESH_PATH_FIXED)) { |
798 | mesh_queue_preq(mpath, | 799 | mesh_queue_preq(mpath, |
799 | PREQ_Q_F_START | PREQ_Q_F_REFRESH); | 800 | PREQ_Q_F_START | PREQ_Q_F_REFRESH); |
800 | } | 801 | } |
801 | memcpy(next_hop, mpath->next_hop->addr, | 802 | memcpy(hdr->addr1, mpath->next_hop->addr, |
802 | ETH_ALEN); | 803 | ETH_ALEN); |
803 | } else { | 804 | } else { |
804 | if (!(mpath->flags & MESH_PATH_RESOLVING)) { | 805 | if (!(mpath->flags & MESH_PATH_RESOLVING)) { |
diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c index 5f88a2e6ee50..838ee60492ad 100644 --- a/net/mac80211/mesh_pathtbl.c +++ b/net/mac80211/mesh_pathtbl.c | |||
@@ -388,18 +388,15 @@ void mesh_path_tx_pending(struct mesh_path *mpath) | |||
388 | void mesh_path_discard_frame(struct sk_buff *skb, struct net_device *dev) | 388 | void mesh_path_discard_frame(struct sk_buff *skb, struct net_device *dev) |
389 | { | 389 | { |
390 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 390 | struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
391 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
391 | struct mesh_path *mpath; | 392 | struct mesh_path *mpath; |
392 | u32 dsn = 0; | 393 | u32 dsn = 0; |
393 | 394 | ||
394 | if (skb->pkt_type == PACKET_OTHERHOST) { | 395 | if (memcmp(hdr->addr4, dev->dev_addr, ETH_ALEN) != 0) { |
395 | struct ieee80211s_hdr *prev_meshhdr; | ||
396 | int mshhdrlen; | ||
397 | u8 *ra, *da; | 396 | u8 *ra, *da; |
398 | 397 | ||
399 | prev_meshhdr = ((struct ieee80211s_hdr *)skb->cb); | 398 | da = hdr->addr3; |
400 | mshhdrlen = ieee80211_get_mesh_hdrlen(prev_meshhdr); | 399 | ra = hdr->addr2; |
401 | da = skb->data; | ||
402 | ra = MESH_PREQ(skb); | ||
403 | mpath = mesh_path_lookup(da, dev); | 400 | mpath = mesh_path_lookup(da, dev); |
404 | if (mpath) | 401 | if (mpath) |
405 | dsn = ++mpath->dsn; | 402 | dsn = ++mpath->dsn; |
diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index d7c371e36bf0..902cac1bd246 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c | |||
@@ -551,6 +551,7 @@ static void ieee80211_set_associated(struct net_device *dev, | |||
551 | /* set timing information */ | 551 | /* set timing information */ |
552 | sdata->bss_conf.beacon_int = bss->beacon_int; | 552 | sdata->bss_conf.beacon_int = bss->beacon_int; |
553 | sdata->bss_conf.timestamp = bss->timestamp; | 553 | sdata->bss_conf.timestamp = bss->timestamp; |
554 | sdata->bss_conf.dtim_period = bss->dtim_period; | ||
554 | 555 | ||
555 | changed |= ieee80211_handle_bss_capability(sdata, bss); | 556 | changed |= ieee80211_handle_bss_capability(sdata, bss); |
556 | 557 | ||
@@ -606,7 +607,6 @@ void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb, | |||
606 | int encrypt) | 607 | int encrypt) |
607 | { | 608 | { |
608 | struct ieee80211_sub_if_data *sdata; | 609 | struct ieee80211_sub_if_data *sdata; |
609 | struct ieee80211_tx_info *info; | ||
610 | 610 | ||
611 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); | 611 | sdata = IEEE80211_DEV_TO_SUB_IF(dev); |
612 | skb->dev = sdata->local->mdev; | 612 | skb->dev = sdata->local->mdev; |
@@ -614,11 +614,8 @@ void ieee80211_sta_tx(struct net_device *dev, struct sk_buff *skb, | |||
614 | skb_set_network_header(skb, 0); | 614 | skb_set_network_header(skb, 0); |
615 | skb_set_transport_header(skb, 0); | 615 | skb_set_transport_header(skb, 0); |
616 | 616 | ||
617 | info = IEEE80211_SKB_CB(skb); | 617 | skb->iif = sdata->dev->ifindex; |
618 | memset(info, 0, sizeof(struct ieee80211_tx_info)); | 618 | skb->do_not_encrypt = !encrypt; |
619 | info->control.ifindex = sdata->dev->ifindex; | ||
620 | if (!encrypt) | ||
621 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; | ||
622 | 619 | ||
623 | dev_queue_xmit(skb); | 620 | dev_queue_xmit(skb); |
624 | } | 621 | } |
@@ -777,7 +774,8 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
777 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, | 774 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, |
778 | IEEE80211_STYPE_REASSOC_REQ); | 775 | IEEE80211_STYPE_REASSOC_REQ); |
779 | mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); | 776 | mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); |
780 | mgmt->u.reassoc_req.listen_interval = cpu_to_le16(1); | 777 | mgmt->u.reassoc_req.listen_interval = |
778 | cpu_to_le16(local->hw.conf.listen_interval); | ||
781 | memcpy(mgmt->u.reassoc_req.current_ap, ifsta->prev_bssid, | 779 | memcpy(mgmt->u.reassoc_req.current_ap, ifsta->prev_bssid, |
782 | ETH_ALEN); | 780 | ETH_ALEN); |
783 | } else { | 781 | } else { |
@@ -785,7 +783,8 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
785 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, | 783 | mgmt->frame_control = IEEE80211_FC(IEEE80211_FTYPE_MGMT, |
786 | IEEE80211_STYPE_ASSOC_REQ); | 784 | IEEE80211_STYPE_ASSOC_REQ); |
787 | mgmt->u.assoc_req.capab_info = cpu_to_le16(capab); | 785 | mgmt->u.assoc_req.capab_info = cpu_to_le16(capab); |
788 | mgmt->u.assoc_req.listen_interval = cpu_to_le16(1); | 786 | mgmt->u.reassoc_req.listen_interval = |
787 | cpu_to_le16(local->hw.conf.listen_interval); | ||
789 | } | 788 | } |
790 | 789 | ||
791 | /* SSID */ | 790 | /* SSID */ |
@@ -814,7 +813,7 @@ static void ieee80211_send_assoc(struct net_device *dev, | |||
814 | } | 813 | } |
815 | } | 814 | } |
816 | 815 | ||
817 | if (count == 8) { | 816 | if (rates_len > count) { |
818 | pos = skb_put(skb, rates_len - count + 2); | 817 | pos = skb_put(skb, rates_len - count + 2); |
819 | *pos++ = WLAN_EID_EXT_SUPP_RATES; | 818 | *pos++ = WLAN_EID_EXT_SUPP_RATES; |
820 | *pos++ = rates_len - count; | 819 | *pos++ = rates_len - count; |
@@ -2104,6 +2103,8 @@ static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, | |||
2104 | rcu_read_unlock(); | 2103 | rcu_read_unlock(); |
2105 | return; | 2104 | return; |
2106 | } | 2105 | } |
2106 | /* update new sta with its last rx activity */ | ||
2107 | sta->last_rx = jiffies; | ||
2107 | } | 2108 | } |
2108 | 2109 | ||
2109 | /* | 2110 | /* |
@@ -2692,6 +2693,16 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2692 | bss->beacon_int = le16_to_cpu(mgmt->u.beacon.beacon_int); | 2693 | bss->beacon_int = le16_to_cpu(mgmt->u.beacon.beacon_int); |
2693 | bss->capability = le16_to_cpu(mgmt->u.beacon.capab_info); | 2694 | bss->capability = le16_to_cpu(mgmt->u.beacon.capab_info); |
2694 | 2695 | ||
2696 | if (elems->tim) { | ||
2697 | struct ieee80211_tim_ie *tim_ie = | ||
2698 | (struct ieee80211_tim_ie *)elems->tim; | ||
2699 | bss->dtim_period = tim_ie->dtim_period; | ||
2700 | } | ||
2701 | |||
2702 | /* set default value for buggy APs */ | ||
2703 | if (!elems->tim || bss->dtim_period == 0) | ||
2704 | bss->dtim_period = 1; | ||
2705 | |||
2695 | bss->supp_rates_len = 0; | 2706 | bss->supp_rates_len = 0; |
2696 | if (elems->supp_rates) { | 2707 | if (elems->supp_rates) { |
2697 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; | 2708 | clen = IEEE80211_MAX_SUPP_RATES - bss->supp_rates_len; |
@@ -2857,7 +2868,7 @@ static void ieee80211_rx_bss_info(struct net_device *dev, | |||
2857 | jiffies); | 2868 | jiffies); |
2858 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 2869 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
2859 | if (beacon_timestamp > rx_timestamp) { | 2870 | if (beacon_timestamp > rx_timestamp) { |
2860 | #ifndef CONFIG_MAC80211_IBSS_DEBUG | 2871 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
2861 | printk(KERN_DEBUG "%s: beacon TSF higher than " | 2872 | printk(KERN_DEBUG "%s: beacon TSF higher than " |
2862 | "local TSF - IBSS merge with BSSID %s\n", | 2873 | "local TSF - IBSS merge with BSSID %s\n", |
2863 | dev->name, print_mac(mac, mgmt->bssid)); | 2874 | dev->name, print_mac(mac, mgmt->bssid)); |
@@ -3303,6 +3314,7 @@ void ieee80211_start_mesh(struct net_device *dev) | |||
3303 | ifsta = &sdata->u.sta; | 3314 | ifsta = &sdata->u.sta; |
3304 | ifsta->state = IEEE80211_MESH_UP; | 3315 | ifsta->state = IEEE80211_MESH_UP; |
3305 | ieee80211_sta_timer((unsigned long)sdata); | 3316 | ieee80211_sta_timer((unsigned long)sdata); |
3317 | ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); | ||
3306 | } | 3318 | } |
3307 | #endif | 3319 | #endif |
3308 | 3320 | ||
@@ -3653,11 +3665,21 @@ static int ieee80211_sta_find_ibss(struct net_device *dev, | |||
3653 | "%s\n", print_mac(mac, bssid), | 3665 | "%s\n", print_mac(mac, bssid), |
3654 | print_mac(mac2, ifsta->bssid)); | 3666 | print_mac(mac2, ifsta->bssid)); |
3655 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 3667 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
3656 | if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0 && | 3668 | |
3657 | (bss = ieee80211_rx_bss_get(dev, bssid, | 3669 | if (found && memcmp(ifsta->bssid, bssid, ETH_ALEN) != 0) { |
3658 | local->hw.conf.channel->center_freq, | ||
3659 | ifsta->ssid, ifsta->ssid_len))) { | ||
3660 | int ret; | 3670 | int ret; |
3671 | int search_freq; | ||
3672 | |||
3673 | if (ifsta->flags & IEEE80211_STA_AUTO_CHANNEL_SEL) | ||
3674 | search_freq = bss->freq; | ||
3675 | else | ||
3676 | search_freq = local->hw.conf.channel->center_freq; | ||
3677 | |||
3678 | bss = ieee80211_rx_bss_get(dev, bssid, search_freq, | ||
3679 | ifsta->ssid, ifsta->ssid_len); | ||
3680 | if (!bss) | ||
3681 | goto dont_join; | ||
3682 | |||
3661 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %s" | 3683 | printk(KERN_DEBUG "%s: Selected IBSS BSSID %s" |
3662 | " based on configured SSID\n", | 3684 | " based on configured SSID\n", |
3663 | dev->name, print_mac(mac, bssid)); | 3685 | dev->name, print_mac(mac, bssid)); |
@@ -3665,6 +3687,8 @@ static int ieee80211_sta_find_ibss(struct net_device *dev, | |||
3665 | ieee80211_rx_bss_put(local, bss); | 3687 | ieee80211_rx_bss_put(local, bss); |
3666 | return ret; | 3688 | return ret; |
3667 | } | 3689 | } |
3690 | |||
3691 | dont_join: | ||
3668 | #ifdef CONFIG_MAC80211_IBSS_DEBUG | 3692 | #ifdef CONFIG_MAC80211_IBSS_DEBUG |
3669 | printk(KERN_DEBUG " did not try to join ibss\n"); | 3693 | printk(KERN_DEBUG " did not try to join ibss\n"); |
3670 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ | 3694 | #endif /* CONFIG_MAC80211_IBSS_DEBUG */ |
@@ -3898,7 +3922,7 @@ done: | |||
3898 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { | 3922 | if (sdata->vif.type == IEEE80211_IF_TYPE_IBSS) { |
3899 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; | 3923 | struct ieee80211_if_sta *ifsta = &sdata->u.sta; |
3900 | if (!(ifsta->flags & IEEE80211_STA_BSSID_SET) || | 3924 | if (!(ifsta->flags & IEEE80211_STA_BSSID_SET) || |
3901 | (!ifsta->state == IEEE80211_IBSS_JOINED && | 3925 | (!(ifsta->state == IEEE80211_IBSS_JOINED) && |
3902 | !ieee80211_sta_active_ibss(dev))) | 3926 | !ieee80211_sta_active_ibss(dev))) |
3903 | ieee80211_sta_find_ibss(dev, ifsta); | 3927 | ieee80211_sta_find_ibss(dev, ifsta); |
3904 | } | 3928 | } |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index 6d9ae67c27ca..6db854505193 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
@@ -1109,20 +1109,9 @@ ieee80211_data_to_8023(struct ieee80211_rx_data *rx) | |||
1109 | 1109 | ||
1110 | hdrlen = ieee80211_get_hdrlen(fc); | 1110 | hdrlen = ieee80211_get_hdrlen(fc); |
1111 | 1111 | ||
1112 | if (ieee80211_vif_is_mesh(&sdata->vif)) { | 1112 | if (ieee80211_vif_is_mesh(&sdata->vif)) |
1113 | int meshhdrlen = ieee80211_get_mesh_hdrlen( | 1113 | hdrlen += ieee80211_get_mesh_hdrlen( |
1114 | (struct ieee80211s_hdr *) (skb->data + hdrlen)); | 1114 | (struct ieee80211s_hdr *) (skb->data + hdrlen)); |
1115 | /* Copy on cb: | ||
1116 | * - mesh header: to be used for mesh forwarding | ||
1117 | * decision. It will also be used as mesh header template at | ||
1118 | * tx.c:ieee80211_subif_start_xmit() if interface | ||
1119 | * type is mesh and skb->pkt_type == PACKET_OTHERHOST | ||
1120 | * - ta: to be used if a RERR needs to be sent. | ||
1121 | */ | ||
1122 | memcpy(skb->cb, skb->data + hdrlen, meshhdrlen); | ||
1123 | memcpy(MESH_PREQ(skb), hdr->addr2, ETH_ALEN); | ||
1124 | hdrlen += meshhdrlen; | ||
1125 | } | ||
1126 | 1115 | ||
1127 | /* convert IEEE 802.11 header + possible LLC headers into Ethernet | 1116 | /* convert IEEE 802.11 header + possible LLC headers into Ethernet |
1128 | * header | 1117 | * header |
@@ -1269,38 +1258,6 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) | |||
1269 | } | 1258 | } |
1270 | } | 1259 | } |
1271 | 1260 | ||
1272 | /* Mesh forwarding */ | ||
1273 | if (ieee80211_vif_is_mesh(&sdata->vif)) { | ||
1274 | u8 *mesh_ttl = &((struct ieee80211s_hdr *)skb->cb)->ttl; | ||
1275 | (*mesh_ttl)--; | ||
1276 | |||
1277 | if (is_multicast_ether_addr(skb->data)) { | ||
1278 | if (*mesh_ttl > 0) { | ||
1279 | xmit_skb = skb_copy(skb, GFP_ATOMIC); | ||
1280 | if (xmit_skb) | ||
1281 | xmit_skb->pkt_type = PACKET_OTHERHOST; | ||
1282 | else if (net_ratelimit()) | ||
1283 | printk(KERN_DEBUG "%s: failed to clone " | ||
1284 | "multicast frame\n", dev->name); | ||
1285 | } else | ||
1286 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, | ||
1287 | dropped_frames_ttl); | ||
1288 | } else if (skb->pkt_type != PACKET_OTHERHOST && | ||
1289 | compare_ether_addr(dev->dev_addr, skb->data) != 0) { | ||
1290 | if (*mesh_ttl == 0) { | ||
1291 | IEEE80211_IFSTA_MESH_CTR_INC(&sdata->u.sta, | ||
1292 | dropped_frames_ttl); | ||
1293 | dev_kfree_skb(skb); | ||
1294 | skb = NULL; | ||
1295 | } else { | ||
1296 | xmit_skb = skb; | ||
1297 | xmit_skb->pkt_type = PACKET_OTHERHOST; | ||
1298 | if (!(dev->flags & IFF_PROMISC)) | ||
1299 | skb = NULL; | ||
1300 | } | ||
1301 | } | ||
1302 | } | ||
1303 | |||
1304 | if (skb) { | 1261 | if (skb) { |
1305 | /* deliver to local stack */ | 1262 | /* deliver to local stack */ |
1306 | skb->protocol = eth_type_trans(skb, dev); | 1263 | skb->protocol = eth_type_trans(skb, dev); |
@@ -1431,6 +1388,63 @@ ieee80211_rx_h_amsdu(struct ieee80211_rx_data *rx) | |||
1431 | } | 1388 | } |
1432 | 1389 | ||
1433 | static ieee80211_rx_result debug_noinline | 1390 | static ieee80211_rx_result debug_noinline |
1391 | ieee80211_rx_h_mesh_fwding(struct ieee80211_rx_data *rx) | ||
1392 | { | ||
1393 | struct ieee80211_hdr *hdr; | ||
1394 | struct ieee80211s_hdr *mesh_hdr; | ||
1395 | unsigned int hdrlen; | ||
1396 | struct sk_buff *skb = rx->skb, *fwd_skb; | ||
1397 | |||
1398 | hdr = (struct ieee80211_hdr *) skb->data; | ||
1399 | hdrlen = ieee80211_hdrlen(hdr->frame_control); | ||
1400 | mesh_hdr = (struct ieee80211s_hdr *) (skb->data + hdrlen); | ||
1401 | |||
1402 | if (!ieee80211_is_data(hdr->frame_control)) | ||
1403 | return RX_CONTINUE; | ||
1404 | |||
1405 | if (!mesh_hdr->ttl) | ||
1406 | /* illegal frame */ | ||
1407 | return RX_DROP_MONITOR; | ||
1408 | |||
1409 | if (compare_ether_addr(rx->dev->dev_addr, hdr->addr3) == 0) | ||
1410 | return RX_CONTINUE; | ||
1411 | |||
1412 | mesh_hdr->ttl--; | ||
1413 | |||
1414 | if (rx->flags & IEEE80211_RX_RA_MATCH) { | ||
1415 | if (!mesh_hdr->ttl) | ||
1416 | IEEE80211_IFSTA_MESH_CTR_INC(&rx->sdata->u.sta, | ||
1417 | dropped_frames_ttl); | ||
1418 | else { | ||
1419 | struct ieee80211_hdr *fwd_hdr; | ||
1420 | fwd_skb = skb_copy(skb, GFP_ATOMIC); | ||
1421 | |||
1422 | if (!fwd_skb && net_ratelimit()) | ||
1423 | printk(KERN_DEBUG "%s: failed to clone mesh frame\n", | ||
1424 | rx->dev->name); | ||
1425 | |||
1426 | fwd_hdr = (struct ieee80211_hdr *) fwd_skb->data; | ||
1427 | /* | ||
1428 | * Save TA to addr1 to send TA a path error if a | ||
1429 | * suitable next hop is not found | ||
1430 | */ | ||
1431 | memcpy(fwd_hdr->addr1, fwd_hdr->addr2, ETH_ALEN); | ||
1432 | memcpy(fwd_hdr->addr2, rx->dev->dev_addr, ETH_ALEN); | ||
1433 | fwd_skb->dev = rx->local->mdev; | ||
1434 | fwd_skb->iif = rx->dev->ifindex; | ||
1435 | dev_queue_xmit(fwd_skb); | ||
1436 | } | ||
1437 | } | ||
1438 | |||
1439 | if (is_multicast_ether_addr(hdr->addr3) || | ||
1440 | rx->dev->flags & IFF_PROMISC) | ||
1441 | return RX_CONTINUE; | ||
1442 | else | ||
1443 | return RX_DROP_MONITOR; | ||
1444 | } | ||
1445 | |||
1446 | |||
1447 | static ieee80211_rx_result debug_noinline | ||
1434 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) | 1448 | ieee80211_rx_h_data(struct ieee80211_rx_data *rx) |
1435 | { | 1449 | { |
1436 | struct net_device *dev = rx->dev; | 1450 | struct net_device *dev = rx->dev; |
@@ -1663,10 +1677,12 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | |||
1663 | rx->sdata = sdata; | 1677 | rx->sdata = sdata; |
1664 | rx->dev = sdata->dev; | 1678 | rx->dev = sdata->dev; |
1665 | 1679 | ||
1666 | #define CALL_RXH(rxh) \ | 1680 | #define CALL_RXH(rxh) \ |
1667 | res = rxh(rx); \ | 1681 | do { \ |
1668 | if (res != RX_CONTINUE) \ | 1682 | res = rxh(rx); \ |
1669 | goto rxh_done; | 1683 | if (res != RX_CONTINUE) \ |
1684 | goto rxh_done; \ | ||
1685 | } while (0); | ||
1670 | 1686 | ||
1671 | CALL_RXH(ieee80211_rx_h_passive_scan) | 1687 | CALL_RXH(ieee80211_rx_h_passive_scan) |
1672 | CALL_RXH(ieee80211_rx_h_check) | 1688 | CALL_RXH(ieee80211_rx_h_check) |
@@ -1678,6 +1694,8 @@ static void ieee80211_invoke_rx_handlers(struct ieee80211_sub_if_data *sdata, | |||
1678 | /* must be after MMIC verify so header is counted in MPDU mic */ | 1694 | /* must be after MMIC verify so header is counted in MPDU mic */ |
1679 | CALL_RXH(ieee80211_rx_h_remove_qos_control) | 1695 | CALL_RXH(ieee80211_rx_h_remove_qos_control) |
1680 | CALL_RXH(ieee80211_rx_h_amsdu) | 1696 | CALL_RXH(ieee80211_rx_h_amsdu) |
1697 | if (ieee80211_vif_is_mesh(&sdata->vif)) | ||
1698 | CALL_RXH(ieee80211_rx_h_mesh_fwding); | ||
1681 | CALL_RXH(ieee80211_rx_h_data) | 1699 | CALL_RXH(ieee80211_rx_h_data) |
1682 | CALL_RXH(ieee80211_rx_h_ctrl) | 1700 | CALL_RXH(ieee80211_rx_h_ctrl) |
1683 | CALL_RXH(ieee80211_rx_h_mgmt) | 1701 | CALL_RXH(ieee80211_rx_h_mgmt) |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 0fbadd8b983c..4788f7b91f49 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
@@ -305,7 +305,7 @@ static void purge_old_ps_buffers(struct ieee80211_local *local) | |||
305 | rcu_read_unlock(); | 305 | rcu_read_unlock(); |
306 | 306 | ||
307 | local->total_ps_buffered = total; | 307 | local->total_ps_buffered = total; |
308 | #ifdef MAC80211_VERBOSE_PS_DEBUG | 308 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
309 | printk(KERN_DEBUG "%s: PS buffers full - purged %d frames\n", | 309 | printk(KERN_DEBUG "%s: PS buffers full - purged %d frames\n", |
310 | wiphy_name(local->hw.wiphy), purged); | 310 | wiphy_name(local->hw.wiphy), purged); |
311 | #endif | 311 | #endif |
@@ -342,7 +342,7 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | |||
342 | purge_old_ps_buffers(tx->local); | 342 | purge_old_ps_buffers(tx->local); |
343 | if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >= | 343 | if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >= |
344 | AP_MAX_BC_BUFFER) { | 344 | AP_MAX_BC_BUFFER) { |
345 | #ifdef MAC80211_VERBOSE_PS_DEBUG | 345 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
346 | if (net_ratelimit()) { | 346 | if (net_ratelimit()) { |
347 | printk(KERN_DEBUG "%s: BC TX buffer full - " | 347 | printk(KERN_DEBUG "%s: BC TX buffer full - " |
348 | "dropping the oldest frame\n", | 348 | "dropping the oldest frame\n", |
@@ -389,7 +389,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
389 | purge_old_ps_buffers(tx->local); | 389 | purge_old_ps_buffers(tx->local); |
390 | if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) { | 390 | if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) { |
391 | struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf); | 391 | struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf); |
392 | #ifdef MAC80211_VERBOSE_PS_DEBUG | 392 | #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG |
393 | if (net_ratelimit()) { | 393 | if (net_ratelimit()) { |
394 | printk(KERN_DEBUG "%s: STA %s TX " | 394 | printk(KERN_DEBUG "%s: STA %s TX " |
395 | "buffer full - dropping oldest frame\n", | 395 | "buffer full - dropping oldest frame\n", |
@@ -439,14 +439,14 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | |||
439 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | 439 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); |
440 | u16 fc = tx->fc; | 440 | u16 fc = tx->fc; |
441 | 441 | ||
442 | if (unlikely(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) | 442 | if (unlikely(tx->skb->do_not_encrypt)) |
443 | tx->key = NULL; | 443 | tx->key = NULL; |
444 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) | 444 | else if (tx->sta && (key = rcu_dereference(tx->sta->key))) |
445 | tx->key = key; | 445 | tx->key = key; |
446 | else if ((key = rcu_dereference(tx->sdata->default_key))) | 446 | else if ((key = rcu_dereference(tx->sdata->default_key))) |
447 | tx->key = key; | 447 | tx->key = key; |
448 | else if (tx->sdata->drop_unencrypted && | 448 | else if (tx->sdata->drop_unencrypted && |
449 | !(info->flags & IEEE80211_TX_CTL_EAPOL_FRAME) && | 449 | (tx->skb->protocol != cpu_to_be16(ETH_P_PAE)) && |
450 | !(info->flags & IEEE80211_TX_CTL_INJECTED)) { | 450 | !(info->flags & IEEE80211_TX_CTL_INJECTED)) { |
451 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); | 451 | I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); |
452 | return TX_DROP; | 452 | return TX_DROP; |
@@ -476,7 +476,7 @@ ieee80211_tx_h_select_key(struct ieee80211_tx_data *tx) | |||
476 | } | 476 | } |
477 | 477 | ||
478 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) | 478 | if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) |
479 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; | 479 | tx->skb->do_not_encrypt = 1; |
480 | 480 | ||
481 | return TX_CONTINUE; | 481 | return TX_CONTINUE; |
482 | } | 482 | } |
@@ -732,6 +732,7 @@ ieee80211_tx_h_fragment(struct ieee80211_tx_data *tx) | |||
732 | memcpy(skb_put(frag, copylen), pos, copylen); | 732 | memcpy(skb_put(frag, copylen), pos, copylen); |
733 | memcpy(frag->cb, first->cb, sizeof(frag->cb)); | 733 | memcpy(frag->cb, first->cb, sizeof(frag->cb)); |
734 | skb_copy_queue_mapping(frag, first); | 734 | skb_copy_queue_mapping(frag, first); |
735 | frag->do_not_encrypt = first->do_not_encrypt; | ||
735 | 736 | ||
736 | pos += copylen; | 737 | pos += copylen; |
737 | left -= copylen; | 738 | left -= copylen; |
@@ -852,7 +853,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
852 | 853 | ||
853 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; | 854 | sband = tx->local->hw.wiphy->bands[tx->channel->band]; |
854 | 855 | ||
855 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; | 856 | skb->do_not_encrypt = 1; |
856 | info->flags |= IEEE80211_TX_CTL_INJECTED; | 857 | info->flags |= IEEE80211_TX_CTL_INJECTED; |
857 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; | 858 | tx->flags &= ~IEEE80211_TX_FRAGMENTED; |
858 | 859 | ||
@@ -925,8 +926,7 @@ __ieee80211_parse_tx_radiotap(struct ieee80211_tx_data *tx, | |||
925 | skb_trim(skb, skb->len - FCS_LEN); | 926 | skb_trim(skb, skb->len - FCS_LEN); |
926 | } | 927 | } |
927 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) | 928 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) |
928 | info->flags &= | 929 | tx->skb->do_not_encrypt = 0; |
929 | ~IEEE80211_TX_CTL_DO_NOT_ENCRYPT; | ||
930 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) | 930 | if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) |
931 | tx->flags |= IEEE80211_TX_FRAGMENTED; | 931 | tx->flags |= IEEE80211_TX_FRAGMENTED; |
932 | break; | 932 | break; |
@@ -1042,10 +1042,9 @@ static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1042 | struct sk_buff *skb, | 1042 | struct sk_buff *skb, |
1043 | struct net_device *mdev) | 1043 | struct net_device *mdev) |
1044 | { | 1044 | { |
1045 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1046 | struct net_device *dev; | 1045 | struct net_device *dev; |
1047 | 1046 | ||
1048 | dev = dev_get_by_index(&init_net, info->control.ifindex); | 1047 | dev = dev_get_by_index(&init_net, skb->iif); |
1049 | if (unlikely(dev && !is_ieee80211_device(dev, mdev))) { | 1048 | if (unlikely(dev && !is_ieee80211_device(dev, mdev))) { |
1050 | dev_put(dev); | 1049 | dev_put(dev); |
1051 | dev = NULL; | 1050 | dev = NULL; |
@@ -1061,13 +1060,14 @@ static int ieee80211_tx_prepare(struct ieee80211_tx_data *tx, | |||
1061 | static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb, | 1060 | static int __ieee80211_tx(struct ieee80211_local *local, struct sk_buff *skb, |
1062 | struct ieee80211_tx_data *tx) | 1061 | struct ieee80211_tx_data *tx) |
1063 | { | 1062 | { |
1064 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1063 | struct ieee80211_tx_info *info; |
1065 | int ret, i; | 1064 | int ret, i; |
1066 | 1065 | ||
1067 | if (netif_subqueue_stopped(local->mdev, skb)) | ||
1068 | return IEEE80211_TX_AGAIN; | ||
1069 | |||
1070 | if (skb) { | 1066 | if (skb) { |
1067 | if (netif_subqueue_stopped(local->mdev, skb)) | ||
1068 | return IEEE80211_TX_AGAIN; | ||
1069 | info = IEEE80211_SKB_CB(skb); | ||
1070 | |||
1071 | ieee80211_dump_frame(wiphy_name(local->hw.wiphy), | 1071 | ieee80211_dump_frame(wiphy_name(local->hw.wiphy), |
1072 | "TX to low-level driver", skb); | 1072 | "TX to low-level driver", skb); |
1073 | ret = local->ops->tx(local_to_hw(local), skb); | 1073 | ret = local->ops->tx(local_to_hw(local), skb); |
@@ -1216,6 +1216,7 @@ retry: | |||
1216 | 1216 | ||
1217 | if (ret == IEEE80211_TX_FRAG_AGAIN) | 1217 | if (ret == IEEE80211_TX_FRAG_AGAIN) |
1218 | skb = NULL; | 1218 | skb = NULL; |
1219 | |||
1219 | set_bit(queue, local->queues_pending); | 1220 | set_bit(queue, local->queues_pending); |
1220 | smp_mb(); | 1221 | smp_mb(); |
1221 | /* | 1222 | /* |
@@ -1300,14 +1301,15 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, | |||
1300 | struct net_device *dev) | 1301 | struct net_device *dev) |
1301 | { | 1302 | { |
1302 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1303 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
1304 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; | ||
1303 | struct net_device *odev = NULL; | 1305 | struct net_device *odev = NULL; |
1304 | struct ieee80211_sub_if_data *osdata; | 1306 | struct ieee80211_sub_if_data *osdata; |
1305 | int headroom; | 1307 | int headroom; |
1306 | bool may_encrypt; | 1308 | bool may_encrypt; |
1307 | int ret; | 1309 | int ret; |
1308 | 1310 | ||
1309 | if (info->control.ifindex) | 1311 | if (skb->iif) |
1310 | odev = dev_get_by_index(&init_net, info->control.ifindex); | 1312 | odev = dev_get_by_index(&init_net, skb->iif); |
1311 | if (unlikely(odev && !is_ieee80211_device(odev, dev))) { | 1313 | if (unlikely(odev && !is_ieee80211_device(odev, dev))) { |
1312 | dev_put(odev); | 1314 | dev_put(odev); |
1313 | odev = NULL; | 1315 | odev = NULL; |
@@ -1321,9 +1323,27 @@ int ieee80211_master_start_xmit(struct sk_buff *skb, | |||
1321 | return 0; | 1323 | return 0; |
1322 | } | 1324 | } |
1323 | 1325 | ||
1326 | memset(info, 0, sizeof(*info)); | ||
1327 | |||
1328 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; | ||
1329 | |||
1324 | osdata = IEEE80211_DEV_TO_SUB_IF(odev); | 1330 | osdata = IEEE80211_DEV_TO_SUB_IF(odev); |
1325 | 1331 | ||
1326 | may_encrypt = !(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT); | 1332 | if (ieee80211_vif_is_mesh(&osdata->vif) && |
1333 | ieee80211_is_data(hdr->frame_control)) { | ||
1334 | if (ieee80211_is_data(hdr->frame_control)) { | ||
1335 | if (is_multicast_ether_addr(hdr->addr3)) | ||
1336 | memcpy(hdr->addr1, hdr->addr3, ETH_ALEN); | ||
1337 | else | ||
1338 | if (mesh_nexthop_lookup(skb, odev)) | ||
1339 | return 0; | ||
1340 | if (memcmp(odev->dev_addr, hdr->addr4, ETH_ALEN) != 0) | ||
1341 | IEEE80211_IFSTA_MESH_CTR_INC(&osdata->u.sta, | ||
1342 | fwded_frames); | ||
1343 | } | ||
1344 | } | ||
1345 | |||
1346 | may_encrypt = !skb->do_not_encrypt; | ||
1327 | 1347 | ||
1328 | headroom = osdata->local->tx_headroom; | 1348 | headroom = osdata->local->tx_headroom; |
1329 | if (may_encrypt) | 1349 | if (may_encrypt) |
@@ -1348,7 +1368,6 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1348 | struct net_device *dev) | 1368 | struct net_device *dev) |
1349 | { | 1369 | { |
1350 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1370 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1351 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1352 | struct ieee80211_radiotap_header *prthdr = | 1371 | struct ieee80211_radiotap_header *prthdr = |
1353 | (struct ieee80211_radiotap_header *)skb->data; | 1372 | (struct ieee80211_radiotap_header *)skb->data; |
1354 | u16 len_rthdr; | 1373 | u16 len_rthdr; |
@@ -1371,11 +1390,11 @@ int ieee80211_monitor_start_xmit(struct sk_buff *skb, | |||
1371 | skb->dev = local->mdev; | 1390 | skb->dev = local->mdev; |
1372 | 1391 | ||
1373 | /* needed because we set skb device to master */ | 1392 | /* needed because we set skb device to master */ |
1374 | info->control.ifindex = dev->ifindex; | 1393 | skb->iif = dev->ifindex; |
1375 | 1394 | ||
1376 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; | 1395 | /* sometimes we do encrypt injected frames, will be fixed |
1377 | /* Interfaces should always request a status report */ | 1396 | * up in radiotap parser if not wanted */ |
1378 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; | 1397 | skb->do_not_encrypt = 0; |
1379 | 1398 | ||
1380 | /* | 1399 | /* |
1381 | * fix up the pointers accounting for the radiotap | 1400 | * fix up the pointers accounting for the radiotap |
@@ -1419,7 +1438,6 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1419 | struct net_device *dev) | 1438 | struct net_device *dev) |
1420 | { | 1439 | { |
1421 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 1440 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
1422 | struct ieee80211_tx_info *info; | ||
1423 | struct ieee80211_sub_if_data *sdata; | 1441 | struct ieee80211_sub_if_data *sdata; |
1424 | int ret = 1, head_need; | 1442 | int ret = 1, head_need; |
1425 | u16 ethertype, hdrlen, meshhdrlen = 0; | 1443 | u16 ethertype, hdrlen, meshhdrlen = 0; |
@@ -1469,30 +1487,17 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1469 | case IEEE80211_IF_TYPE_MESH_POINT: | 1487 | case IEEE80211_IF_TYPE_MESH_POINT: |
1470 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); | 1488 | fc |= cpu_to_le16(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS); |
1471 | /* RA TA DA SA */ | 1489 | /* RA TA DA SA */ |
1472 | if (is_multicast_ether_addr(skb->data)) | 1490 | memset(hdr.addr1, 0, ETH_ALEN); |
1473 | memcpy(hdr.addr1, skb->data, ETH_ALEN); | ||
1474 | else if (mesh_nexthop_lookup(hdr.addr1, skb, dev)) | ||
1475 | return 0; | ||
1476 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); | 1491 | memcpy(hdr.addr2, dev->dev_addr, ETH_ALEN); |
1477 | memcpy(hdr.addr3, skb->data, ETH_ALEN); | 1492 | memcpy(hdr.addr3, skb->data, ETH_ALEN); |
1478 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); | 1493 | memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); |
1479 | if (skb->pkt_type == PACKET_OTHERHOST) { | 1494 | if (!sdata->u.sta.mshcfg.dot11MeshTTL) { |
1480 | /* Forwarded frame, keep mesh ttl and seqnum */ | 1495 | /* Do not send frames with mesh_ttl == 0 */ |
1481 | struct ieee80211s_hdr *prev_meshhdr; | 1496 | sdata->u.sta.mshstats.dropped_frames_ttl++; |
1482 | prev_meshhdr = ((struct ieee80211s_hdr *)skb->cb); | 1497 | ret = 0; |
1483 | meshhdrlen = ieee80211_get_mesh_hdrlen(prev_meshhdr); | 1498 | goto fail; |
1484 | memcpy(&mesh_hdr, prev_meshhdr, meshhdrlen); | ||
1485 | sdata->u.sta.mshstats.fwded_frames++; | ||
1486 | } else { | ||
1487 | if (!sdata->u.sta.mshcfg.dot11MeshTTL) { | ||
1488 | /* Do not send frames with mesh_ttl == 0 */ | ||
1489 | sdata->u.sta.mshstats.dropped_frames_ttl++; | ||
1490 | ret = 0; | ||
1491 | goto fail; | ||
1492 | } | ||
1493 | meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, | ||
1494 | sdata); | ||
1495 | } | 1499 | } |
1500 | meshhdrlen = ieee80211_new_mesh_header(&mesh_hdr, sdata); | ||
1496 | hdrlen = 30; | 1501 | hdrlen = 30; |
1497 | break; | 1502 | break; |
1498 | #endif | 1503 | #endif |
@@ -1540,7 +1545,8 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1540 | * Drop unicast frames to unauthorised stations unless they are | 1545 | * Drop unicast frames to unauthorised stations unless they are |
1541 | * EAPOL frames from the local station. | 1546 | * EAPOL frames from the local station. |
1542 | */ | 1547 | */ |
1543 | if (unlikely(!is_multicast_ether_addr(hdr.addr1) && | 1548 | if (!ieee80211_vif_is_mesh(&sdata->vif) && |
1549 | unlikely(!is_multicast_ether_addr(hdr.addr1) && | ||
1544 | !(sta_flags & WLAN_STA_AUTHORIZED) && | 1550 | !(sta_flags & WLAN_STA_AUTHORIZED) && |
1545 | !(ethertype == ETH_P_PAE && | 1551 | !(ethertype == ETH_P_PAE && |
1546 | compare_ether_addr(dev->dev_addr, | 1552 | compare_ether_addr(dev->dev_addr, |
@@ -1645,14 +1651,7 @@ int ieee80211_subif_start_xmit(struct sk_buff *skb, | |||
1645 | nh_pos += hdrlen; | 1651 | nh_pos += hdrlen; |
1646 | h_pos += hdrlen; | 1652 | h_pos += hdrlen; |
1647 | 1653 | ||
1648 | info = IEEE80211_SKB_CB(skb); | 1654 | skb->iif = dev->ifindex; |
1649 | memset(info, 0, sizeof(*info)); | ||
1650 | info->control.ifindex = dev->ifindex; | ||
1651 | if (ethertype == ETH_P_PAE) | ||
1652 | info->flags |= IEEE80211_TX_CTL_EAPOL_FRAME; | ||
1653 | |||
1654 | /* Interfaces should always request a status report */ | ||
1655 | info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; | ||
1656 | 1655 | ||
1657 | skb->dev = local->mdev; | 1656 | skb->dev = local->mdev; |
1658 | dev->stats.tx_packets++; | 1657 | dev->stats.tx_packets++; |
@@ -1714,14 +1713,19 @@ void ieee80211_tx_pending(unsigned long data) | |||
1714 | netif_tx_lock_bh(dev); | 1713 | netif_tx_lock_bh(dev); |
1715 | for (i = 0; i < ieee80211_num_regular_queues(&local->hw); i++) { | 1714 | for (i = 0; i < ieee80211_num_regular_queues(&local->hw); i++) { |
1716 | /* Check that this queue is ok */ | 1715 | /* Check that this queue is ok */ |
1717 | if (__netif_subqueue_stopped(local->mdev, i)) | 1716 | if (__netif_subqueue_stopped(local->mdev, i) && |
1717 | !test_bit(i, local->queues_pending_run)) | ||
1718 | continue; | 1718 | continue; |
1719 | 1719 | ||
1720 | if (!test_bit(i, local->queues_pending)) { | 1720 | if (!test_bit(i, local->queues_pending)) { |
1721 | clear_bit(i, local->queues_pending_run); | ||
1721 | ieee80211_wake_queue(&local->hw, i); | 1722 | ieee80211_wake_queue(&local->hw, i); |
1722 | continue; | 1723 | continue; |
1723 | } | 1724 | } |
1724 | 1725 | ||
1726 | clear_bit(i, local->queues_pending_run); | ||
1727 | netif_start_subqueue(local->mdev, i); | ||
1728 | |||
1725 | store = &local->pending_packet[i]; | 1729 | store = &local->pending_packet[i]; |
1726 | tx.extra_frag = store->extra_frag; | 1730 | tx.extra_frag = store->extra_frag; |
1727 | tx.num_extra_frag = store->num_extra_frag; | 1731 | tx.num_extra_frag = store->num_extra_frag; |
@@ -1922,6 +1926,8 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1922 | 1926 | ||
1923 | info = IEEE80211_SKB_CB(skb); | 1927 | info = IEEE80211_SKB_CB(skb); |
1924 | 1928 | ||
1929 | skb->do_not_encrypt = 1; | ||
1930 | |||
1925 | info->band = band; | 1931 | info->band = band; |
1926 | rate_control_get_rate(local->mdev, sband, skb, &rsel); | 1932 | rate_control_get_rate(local->mdev, sband, skb, &rsel); |
1927 | 1933 | ||
@@ -1931,7 +1937,7 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1931 | "no rate found\n", | 1937 | "no rate found\n", |
1932 | wiphy_name(local->hw.wiphy)); | 1938 | wiphy_name(local->hw.wiphy)); |
1933 | } | 1939 | } |
1934 | dev_kfree_skb(skb); | 1940 | dev_kfree_skb_any(skb); |
1935 | skb = NULL; | 1941 | skb = NULL; |
1936 | goto out; | 1942 | goto out; |
1937 | } | 1943 | } |
@@ -1940,7 +1946,6 @@ struct sk_buff *ieee80211_beacon_get(struct ieee80211_hw *hw, | |||
1940 | info->tx_rate_idx = rsel.rate_idx; | 1946 | info->tx_rate_idx = rsel.rate_idx; |
1941 | 1947 | ||
1942 | info->flags |= IEEE80211_TX_CTL_NO_ACK; | 1948 | info->flags |= IEEE80211_TX_CTL_NO_ACK; |
1943 | info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; | ||
1944 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; | 1949 | info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; |
1945 | info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; | 1950 | info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; |
1946 | if (sdata->bss_conf.use_short_preamble && | 1951 | if (sdata->bss_conf.use_short_preamble && |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 19f85e1b3695..0d463c80c404 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
@@ -361,6 +361,7 @@ void ieee80211_wake_queue(struct ieee80211_hw *hw, int queue) | |||
361 | struct ieee80211_local *local = hw_to_local(hw); | 361 | struct ieee80211_local *local = hw_to_local(hw); |
362 | 362 | ||
363 | if (test_bit(queue, local->queues_pending)) { | 363 | if (test_bit(queue, local->queues_pending)) { |
364 | set_bit(queue, local->queues_pending_run); | ||
364 | tasklet_schedule(&local->tx_pending_tasklet); | 365 | tasklet_schedule(&local->tx_pending_tasklet); |
365 | } else { | 366 | } else { |
366 | netif_wake_subqueue(local->mdev, queue); | 367 | netif_wake_subqueue(local->mdev, queue); |
diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c index 872d2fcd1a5b..5c2bf0a3d4db 100644 --- a/net/mac80211/wep.c +++ b/net/mac80211/wep.c | |||
@@ -31,13 +31,13 @@ int ieee80211_wep_init(struct ieee80211_local *local) | |||
31 | local->wep_tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, | 31 | local->wep_tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, |
32 | CRYPTO_ALG_ASYNC); | 32 | CRYPTO_ALG_ASYNC); |
33 | if (IS_ERR(local->wep_tx_tfm)) | 33 | if (IS_ERR(local->wep_tx_tfm)) |
34 | return -ENOMEM; | 34 | return PTR_ERR(local->wep_tx_tfm); |
35 | 35 | ||
36 | local->wep_rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, | 36 | local->wep_rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, |
37 | CRYPTO_ALG_ASYNC); | 37 | CRYPTO_ALG_ASYNC); |
38 | if (IS_ERR(local->wep_rx_tfm)) { | 38 | if (IS_ERR(local->wep_rx_tfm)) { |
39 | crypto_free_blkcipher(local->wep_tx_tfm); | 39 | crypto_free_blkcipher(local->wep_tx_tfm); |
40 | return -ENOMEM; | 40 | return PTR_ERR(local->wep_rx_tfm); |
41 | } | 41 | } |
42 | 42 | ||
43 | return 0; | 43 | return 0; |
diff --git a/net/mac80211/wme.c b/net/mac80211/wme.c index 07edda0b8a5c..4310e2f65661 100644 --- a/net/mac80211/wme.c +++ b/net/mac80211/wme.c | |||
@@ -188,6 +188,9 @@ int ieee80211_ht_agg_queue_add(struct ieee80211_local *local, | |||
188 | { | 188 | { |
189 | int i; | 189 | int i; |
190 | 190 | ||
191 | /* XXX: currently broken due to cb/requeue use */ | ||
192 | return -EPERM; | ||
193 | |||
191 | /* prepare the filter and save it for the SW queue | 194 | /* prepare the filter and save it for the SW queue |
192 | * matching the received HW queue */ | 195 | * matching the received HW queue */ |
193 | 196 | ||
@@ -238,12 +241,14 @@ void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local, | |||
238 | } else { | 241 | } else { |
239 | struct netdev_queue *txq; | 242 | struct netdev_queue *txq; |
240 | spinlock_t *root_lock; | 243 | spinlock_t *root_lock; |
244 | struct Qdisc *q; | ||
241 | 245 | ||
242 | txq = netdev_get_tx_queue(local->mdev, agg_queue); | 246 | txq = netdev_get_tx_queue(local->mdev, agg_queue); |
243 | root_lock = qdisc_root_lock(txq->qdisc); | 247 | q = rcu_dereference(txq->qdisc); |
248 | root_lock = qdisc_lock(q); | ||
244 | 249 | ||
245 | spin_lock_bh(root_lock); | 250 | spin_lock_bh(root_lock); |
246 | qdisc_reset(txq->qdisc); | 251 | qdisc_reset(q); |
247 | spin_unlock_bh(root_lock); | 252 | spin_unlock_bh(root_lock); |
248 | } | 253 | } |
249 | } | 254 | } |
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c index c519d090bdb9..9d1830da8e84 100644 --- a/net/netfilter/nf_conntrack_core.c +++ b/net/netfilter/nf_conntrack_core.c | |||
@@ -1032,10 +1032,10 @@ void nf_conntrack_cleanup(void) | |||
1032 | nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_vmalloc, | 1032 | nf_ct_free_hashtable(nf_conntrack_hash, nf_conntrack_vmalloc, |
1033 | nf_conntrack_htable_size); | 1033 | nf_conntrack_htable_size); |
1034 | 1034 | ||
1035 | nf_conntrack_proto_fini(); | ||
1036 | nf_conntrack_helper_fini(); | ||
1037 | nf_conntrack_expect_fini(); | ||
1038 | nf_conntrack_acct_fini(); | 1035 | nf_conntrack_acct_fini(); |
1036 | nf_conntrack_expect_fini(); | ||
1037 | nf_conntrack_helper_fini(); | ||
1038 | nf_conntrack_proto_fini(); | ||
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | struct hlist_head *nf_ct_alloc_hashtable(unsigned int *sizep, int *vmalloced) | 1041 | struct hlist_head *nf_ct_alloc_hashtable(unsigned int *sizep, int *vmalloced) |
diff --git a/net/netfilter/nf_conntrack_irc.c b/net/netfilter/nf_conntrack_irc.c index 1b1226d6653f..20633fdf7e6b 100644 --- a/net/netfilter/nf_conntrack_irc.c +++ b/net/netfilter/nf_conntrack_irc.c | |||
@@ -68,11 +68,21 @@ static const char *const dccprotos[] = { | |||
68 | static int parse_dcc(char *data, const char *data_end, u_int32_t *ip, | 68 | static int parse_dcc(char *data, const char *data_end, u_int32_t *ip, |
69 | u_int16_t *port, char **ad_beg_p, char **ad_end_p) | 69 | u_int16_t *port, char **ad_beg_p, char **ad_end_p) |
70 | { | 70 | { |
71 | char *tmp; | ||
72 | |||
71 | /* at least 12: "AAAAAAAA P\1\n" */ | 73 | /* at least 12: "AAAAAAAA P\1\n" */ |
72 | while (*data++ != ' ') | 74 | while (*data++ != ' ') |
73 | if (data > data_end - 12) | 75 | if (data > data_end - 12) |
74 | return -1; | 76 | return -1; |
75 | 77 | ||
78 | /* Make sure we have a newline character within the packet boundaries | ||
79 | * because simple_strtoul parses until the first invalid character. */ | ||
80 | for (tmp = data; tmp <= data_end; tmp++) | ||
81 | if (*tmp == '\n') | ||
82 | break; | ||
83 | if (tmp > data_end || *tmp != '\n') | ||
84 | return -1; | ||
85 | |||
76 | *ad_beg_p = data; | 86 | *ad_beg_p = data; |
77 | *ip = simple_strtoul(data, &data, 10); | 87 | *ip = simple_strtoul(data, &data, 10); |
78 | 88 | ||
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c index 105a616c5c78..a8752031adcb 100644 --- a/net/netfilter/nf_conntrack_netlink.c +++ b/net/netfilter/nf_conntrack_netlink.c | |||
@@ -968,7 +968,7 @@ ctnetlink_change_helper(struct nf_conn *ct, struct nlattr *cda[]) | |||
968 | /* need to zero data of old helper */ | 968 | /* need to zero data of old helper */ |
969 | memset(&help->help, 0, sizeof(help->help)); | 969 | memset(&help->help, 0, sizeof(help->help)); |
970 | } else { | 970 | } else { |
971 | help = nf_ct_helper_ext_add(ct, GFP_KERNEL); | 971 | help = nf_ct_helper_ext_add(ct, GFP_ATOMIC); |
972 | if (help == NULL) | 972 | if (help == NULL) |
973 | return -ENOMEM; | 973 | return -ENOMEM; |
974 | } | 974 | } |
@@ -1136,16 +1136,33 @@ ctnetlink_create_conntrack(struct nlattr *cda[], | |||
1136 | ct->timeout.expires = jiffies + ct->timeout.expires * HZ; | 1136 | ct->timeout.expires = jiffies + ct->timeout.expires * HZ; |
1137 | ct->status |= IPS_CONFIRMED; | 1137 | ct->status |= IPS_CONFIRMED; |
1138 | 1138 | ||
1139 | rcu_read_lock(); | ||
1140 | helper = __nf_ct_helper_find(rtuple); | ||
1141 | if (helper) { | ||
1142 | help = nf_ct_helper_ext_add(ct, GFP_ATOMIC); | ||
1143 | if (help == NULL) { | ||
1144 | rcu_read_unlock(); | ||
1145 | err = -ENOMEM; | ||
1146 | goto err; | ||
1147 | } | ||
1148 | /* not in hash table yet so not strictly necessary */ | ||
1149 | rcu_assign_pointer(help->helper, helper); | ||
1150 | } | ||
1151 | |||
1139 | if (cda[CTA_STATUS]) { | 1152 | if (cda[CTA_STATUS]) { |
1140 | err = ctnetlink_change_status(ct, cda); | 1153 | err = ctnetlink_change_status(ct, cda); |
1141 | if (err < 0) | 1154 | if (err < 0) { |
1155 | rcu_read_unlock(); | ||
1142 | goto err; | 1156 | goto err; |
1157 | } | ||
1143 | } | 1158 | } |
1144 | 1159 | ||
1145 | if (cda[CTA_PROTOINFO]) { | 1160 | if (cda[CTA_PROTOINFO]) { |
1146 | err = ctnetlink_change_protoinfo(ct, cda); | 1161 | err = ctnetlink_change_protoinfo(ct, cda); |
1147 | if (err < 0) | 1162 | if (err < 0) { |
1163 | rcu_read_unlock(); | ||
1148 | goto err; | 1164 | goto err; |
1165 | } | ||
1149 | } | 1166 | } |
1150 | 1167 | ||
1151 | nf_ct_acct_ext_add(ct, GFP_KERNEL); | 1168 | nf_ct_acct_ext_add(ct, GFP_KERNEL); |
@@ -1155,19 +1172,6 @@ ctnetlink_create_conntrack(struct nlattr *cda[], | |||
1155 | ct->mark = ntohl(nla_get_be32(cda[CTA_MARK])); | 1172 | ct->mark = ntohl(nla_get_be32(cda[CTA_MARK])); |
1156 | #endif | 1173 | #endif |
1157 | 1174 | ||
1158 | rcu_read_lock(); | ||
1159 | helper = __nf_ct_helper_find(rtuple); | ||
1160 | if (helper) { | ||
1161 | help = nf_ct_helper_ext_add(ct, GFP_KERNEL); | ||
1162 | if (help == NULL) { | ||
1163 | rcu_read_unlock(); | ||
1164 | err = -ENOMEM; | ||
1165 | goto err; | ||
1166 | } | ||
1167 | /* not in hash table yet so not strictly necessary */ | ||
1168 | rcu_assign_pointer(help->helper, helper); | ||
1169 | } | ||
1170 | |||
1171 | /* setup master conntrack: this is a confirmed expectation */ | 1175 | /* setup master conntrack: this is a confirmed expectation */ |
1172 | if (master_ct) { | 1176 | if (master_ct) { |
1173 | __set_bit(IPS_EXPECTED_BIT, &ct->status); | 1177 | __set_bit(IPS_EXPECTED_BIT, &ct->status); |
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c index 654a4f7f12c6..9bd03967fea4 100644 --- a/net/netfilter/nf_conntrack_proto_gre.c +++ b/net/netfilter/nf_conntrack_proto_gre.c | |||
@@ -45,12 +45,12 @@ static LIST_HEAD(gre_keymap_list); | |||
45 | 45 | ||
46 | void nf_ct_gre_keymap_flush(void) | 46 | void nf_ct_gre_keymap_flush(void) |
47 | { | 47 | { |
48 | struct list_head *pos, *n; | 48 | struct nf_ct_gre_keymap *km, *tmp; |
49 | 49 | ||
50 | write_lock_bh(&nf_ct_gre_lock); | 50 | write_lock_bh(&nf_ct_gre_lock); |
51 | list_for_each_safe(pos, n, &gre_keymap_list) { | 51 | list_for_each_entry_safe(km, tmp, &gre_keymap_list, list) { |
52 | list_del(pos); | 52 | list_del(&km->list); |
53 | kfree(pos); | 53 | kfree(km); |
54 | } | 54 | } |
55 | write_unlock_bh(&nf_ct_gre_lock); | 55 | write_unlock_bh(&nf_ct_gre_lock); |
56 | } | 56 | } |
@@ -97,10 +97,14 @@ int nf_ct_gre_keymap_add(struct nf_conn *ct, enum ip_conntrack_dir dir, | |||
97 | kmp = &help->help.ct_pptp_info.keymap[dir]; | 97 | kmp = &help->help.ct_pptp_info.keymap[dir]; |
98 | if (*kmp) { | 98 | if (*kmp) { |
99 | /* check whether it's a retransmission */ | 99 | /* check whether it's a retransmission */ |
100 | read_lock_bh(&nf_ct_gre_lock); | ||
100 | list_for_each_entry(km, &gre_keymap_list, list) { | 101 | list_for_each_entry(km, &gre_keymap_list, list) { |
101 | if (gre_key_cmpfn(km, t) && km == *kmp) | 102 | if (gre_key_cmpfn(km, t) && km == *kmp) { |
103 | read_unlock_bh(&nf_ct_gre_lock); | ||
102 | return 0; | 104 | return 0; |
105 | } | ||
103 | } | 106 | } |
107 | read_unlock_bh(&nf_ct_gre_lock); | ||
104 | pr_debug("trying to override keymap_%s for ct %p\n", | 108 | pr_debug("trying to override keymap_%s for ct %p\n", |
105 | dir == IP_CT_DIR_REPLY ? "reply" : "orig", ct); | 109 | dir == IP_CT_DIR_REPLY ? "reply" : "orig", ct); |
106 | return -EEXIST; | 110 | return -EEXIST; |
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c index 420a10d8eb1e..6f61261888ef 100644 --- a/net/netfilter/nf_conntrack_proto_tcp.c +++ b/net/netfilter/nf_conntrack_proto_tcp.c | |||
@@ -67,7 +67,8 @@ static const char *const tcp_conntrack_names[] = { | |||
67 | /* RFC1122 says the R2 limit should be at least 100 seconds. | 67 | /* RFC1122 says the R2 limit should be at least 100 seconds. |
68 | Linux uses 15 packets as limit, which corresponds | 68 | Linux uses 15 packets as limit, which corresponds |
69 | to ~13-30min depending on RTO. */ | 69 | to ~13-30min depending on RTO. */ |
70 | static unsigned int nf_ct_tcp_timeout_max_retrans __read_mostly = 5 MINS; | 70 | static unsigned int nf_ct_tcp_timeout_max_retrans __read_mostly = 5 MINS; |
71 | static unsigned int nf_ct_tcp_timeout_unacknowledged __read_mostly = 5 MINS; | ||
71 | 72 | ||
72 | static unsigned int tcp_timeouts[TCP_CONNTRACK_MAX] __read_mostly = { | 73 | static unsigned int tcp_timeouts[TCP_CONNTRACK_MAX] __read_mostly = { |
73 | [TCP_CONNTRACK_SYN_SENT] = 2 MINS, | 74 | [TCP_CONNTRACK_SYN_SENT] = 2 MINS, |
@@ -625,8 +626,10 @@ static bool tcp_in_window(const struct nf_conn *ct, | |||
625 | swin = win + (sack - ack); | 626 | swin = win + (sack - ack); |
626 | if (sender->td_maxwin < swin) | 627 | if (sender->td_maxwin < swin) |
627 | sender->td_maxwin = swin; | 628 | sender->td_maxwin = swin; |
628 | if (after(end, sender->td_end)) | 629 | if (after(end, sender->td_end)) { |
629 | sender->td_end = end; | 630 | sender->td_end = end; |
631 | sender->flags |= IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED; | ||
632 | } | ||
630 | /* | 633 | /* |
631 | * Update receiver data. | 634 | * Update receiver data. |
632 | */ | 635 | */ |
@@ -637,6 +640,8 @@ static bool tcp_in_window(const struct nf_conn *ct, | |||
637 | if (win == 0) | 640 | if (win == 0) |
638 | receiver->td_maxend++; | 641 | receiver->td_maxend++; |
639 | } | 642 | } |
643 | if (ack == receiver->td_end) | ||
644 | receiver->flags &= ~IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED; | ||
640 | 645 | ||
641 | /* | 646 | /* |
642 | * Check retransmissions. | 647 | * Check retransmissions. |
@@ -951,9 +956,16 @@ static int tcp_packet(struct nf_conn *ct, | |||
951 | if (old_state != new_state | 956 | if (old_state != new_state |
952 | && new_state == TCP_CONNTRACK_FIN_WAIT) | 957 | && new_state == TCP_CONNTRACK_FIN_WAIT) |
953 | ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT; | 958 | ct->proto.tcp.seen[dir].flags |= IP_CT_TCP_FLAG_CLOSE_INIT; |
954 | timeout = ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans | 959 | |
955 | && tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans | 960 | if (ct->proto.tcp.retrans >= nf_ct_tcp_max_retrans && |
956 | ? nf_ct_tcp_timeout_max_retrans : tcp_timeouts[new_state]; | 961 | tcp_timeouts[new_state] > nf_ct_tcp_timeout_max_retrans) |
962 | timeout = nf_ct_tcp_timeout_max_retrans; | ||
963 | else if ((ct->proto.tcp.seen[0].flags | ct->proto.tcp.seen[1].flags) & | ||
964 | IP_CT_TCP_FLAG_DATA_UNACKNOWLEDGED && | ||
965 | tcp_timeouts[new_state] > nf_ct_tcp_timeout_unacknowledged) | ||
966 | timeout = nf_ct_tcp_timeout_unacknowledged; | ||
967 | else | ||
968 | timeout = tcp_timeouts[new_state]; | ||
957 | write_unlock_bh(&tcp_lock); | 969 | write_unlock_bh(&tcp_lock); |
958 | 970 | ||
959 | nf_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, skb); | 971 | nf_conntrack_event_cache(IPCT_PROTOINFO_VOLATILE, skb); |
@@ -1236,6 +1248,13 @@ static struct ctl_table tcp_sysctl_table[] = { | |||
1236 | .proc_handler = &proc_dointvec_jiffies, | 1248 | .proc_handler = &proc_dointvec_jiffies, |
1237 | }, | 1249 | }, |
1238 | { | 1250 | { |
1251 | .procname = "nf_conntrack_tcp_timeout_unacknowledged", | ||
1252 | .data = &nf_ct_tcp_timeout_unacknowledged, | ||
1253 | .maxlen = sizeof(unsigned int), | ||
1254 | .mode = 0644, | ||
1255 | .proc_handler = &proc_dointvec_jiffies, | ||
1256 | }, | ||
1257 | { | ||
1239 | .ctl_name = NET_NF_CONNTRACK_TCP_LOOSE, | 1258 | .ctl_name = NET_NF_CONNTRACK_TCP_LOOSE, |
1240 | .procname = "nf_conntrack_tcp_loose", | 1259 | .procname = "nf_conntrack_tcp_loose", |
1241 | .data = &nf_ct_tcp_loose, | 1260 | .data = &nf_ct_tcp_loose, |
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index 2f9bbc058b48..1fa306be60fb 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c | |||
@@ -1193,7 +1193,6 @@ static const struct sip_handler sip_handlers[] = { | |||
1193 | static int process_sip_response(struct sk_buff *skb, | 1193 | static int process_sip_response(struct sk_buff *skb, |
1194 | const char **dptr, unsigned int *datalen) | 1194 | const char **dptr, unsigned int *datalen) |
1195 | { | 1195 | { |
1196 | static const struct sip_handler *handler; | ||
1197 | enum ip_conntrack_info ctinfo; | 1196 | enum ip_conntrack_info ctinfo; |
1198 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 1197 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
1199 | unsigned int matchoff, matchlen; | 1198 | unsigned int matchoff, matchlen; |
@@ -1214,6 +1213,8 @@ static int process_sip_response(struct sk_buff *skb, | |||
1214 | dataoff = matchoff + matchlen + 1; | 1213 | dataoff = matchoff + matchlen + 1; |
1215 | 1214 | ||
1216 | for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) { | 1215 | for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) { |
1216 | const struct sip_handler *handler; | ||
1217 | |||
1217 | handler = &sip_handlers[i]; | 1218 | handler = &sip_handlers[i]; |
1218 | if (handler->response == NULL) | 1219 | if (handler->response == NULL) |
1219 | continue; | 1220 | continue; |
@@ -1228,13 +1229,14 @@ static int process_sip_response(struct sk_buff *skb, | |||
1228 | static int process_sip_request(struct sk_buff *skb, | 1229 | static int process_sip_request(struct sk_buff *skb, |
1229 | const char **dptr, unsigned int *datalen) | 1230 | const char **dptr, unsigned int *datalen) |
1230 | { | 1231 | { |
1231 | static const struct sip_handler *handler; | ||
1232 | enum ip_conntrack_info ctinfo; | 1232 | enum ip_conntrack_info ctinfo; |
1233 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); | 1233 | struct nf_conn *ct = nf_ct_get(skb, &ctinfo); |
1234 | unsigned int matchoff, matchlen; | 1234 | unsigned int matchoff, matchlen; |
1235 | unsigned int cseq, i; | 1235 | unsigned int cseq, i; |
1236 | 1236 | ||
1237 | for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) { | 1237 | for (i = 0; i < ARRAY_SIZE(sip_handlers); i++) { |
1238 | const struct sip_handler *handler; | ||
1239 | |||
1238 | handler = &sip_handlers[i]; | 1240 | handler = &sip_handlers[i]; |
1239 | if (handler->request == NULL) | 1241 | if (handler->request == NULL) |
1240 | continue; | 1242 | continue; |
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c index 869ef9349d0f..8509db14670b 100644 --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c | |||
@@ -324,6 +324,7 @@ static int log_invalid_proto_min = 0; | |||
324 | static int log_invalid_proto_max = 255; | 324 | static int log_invalid_proto_max = 255; |
325 | 325 | ||
326 | static struct ctl_table_header *nf_ct_sysctl_header; | 326 | static struct ctl_table_header *nf_ct_sysctl_header; |
327 | static struct ctl_table_header *nf_ct_netfilter_header; | ||
327 | 328 | ||
328 | static ctl_table nf_ct_sysctl_table[] = { | 329 | static ctl_table nf_ct_sysctl_table[] = { |
329 | { | 330 | { |
@@ -384,12 +385,6 @@ static ctl_table nf_ct_sysctl_table[] = { | |||
384 | 385 | ||
385 | static ctl_table nf_ct_netfilter_table[] = { | 386 | static ctl_table nf_ct_netfilter_table[] = { |
386 | { | 387 | { |
387 | .ctl_name = NET_NETFILTER, | ||
388 | .procname = "netfilter", | ||
389 | .mode = 0555, | ||
390 | .child = nf_ct_sysctl_table, | ||
391 | }, | ||
392 | { | ||
393 | .ctl_name = NET_NF_CONNTRACK_MAX, | 388 | .ctl_name = NET_NF_CONNTRACK_MAX, |
394 | .procname = "nf_conntrack_max", | 389 | .procname = "nf_conntrack_max", |
395 | .data = &nf_conntrack_max, | 390 | .data = &nf_conntrack_max, |
@@ -409,18 +404,29 @@ EXPORT_SYMBOL_GPL(nf_ct_log_invalid); | |||
409 | 404 | ||
410 | static int nf_conntrack_standalone_init_sysctl(void) | 405 | static int nf_conntrack_standalone_init_sysctl(void) |
411 | { | 406 | { |
412 | nf_ct_sysctl_header = | 407 | nf_ct_netfilter_header = |
413 | register_sysctl_paths(nf_ct_path, nf_ct_netfilter_table); | 408 | register_sysctl_paths(nf_ct_path, nf_ct_netfilter_table); |
414 | if (nf_ct_sysctl_header == NULL) { | 409 | if (!nf_ct_netfilter_header) |
415 | printk("nf_conntrack: can't register to sysctl.\n"); | 410 | goto out; |
416 | return -ENOMEM; | 411 | |
417 | } | 412 | nf_ct_sysctl_header = |
413 | register_sysctl_paths(nf_net_netfilter_sysctl_path, | ||
414 | nf_ct_sysctl_table); | ||
415 | if (!nf_ct_sysctl_header) | ||
416 | goto out_unregister_netfilter; | ||
417 | |||
418 | return 0; | 418 | return 0; |
419 | 419 | ||
420 | out_unregister_netfilter: | ||
421 | unregister_sysctl_table(nf_ct_netfilter_header); | ||
422 | out: | ||
423 | printk("nf_conntrack: can't register to sysctl.\n"); | ||
424 | return -ENOMEM; | ||
420 | } | 425 | } |
421 | 426 | ||
422 | static void nf_conntrack_standalone_fini_sysctl(void) | 427 | static void nf_conntrack_standalone_fini_sysctl(void) |
423 | { | 428 | { |
429 | unregister_sysctl_table(nf_ct_netfilter_header); | ||
424 | unregister_sysctl_table(nf_ct_sysctl_header); | 430 | unregister_sysctl_table(nf_ct_sysctl_header); |
425 | } | 431 | } |
426 | #else | 432 | #else |
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c index 6809af542a2c..d9418a267812 100644 --- a/net/netfilter/xt_hashlimit.c +++ b/net/netfilter/xt_hashlimit.c | |||
@@ -367,9 +367,7 @@ static void htable_gc(unsigned long htlong) | |||
367 | 367 | ||
368 | static void htable_destroy(struct xt_hashlimit_htable *hinfo) | 368 | static void htable_destroy(struct xt_hashlimit_htable *hinfo) |
369 | { | 369 | { |
370 | /* remove timer, if it is pending */ | 370 | del_timer_sync(&hinfo->timer); |
371 | if (timer_pending(&hinfo->timer)) | ||
372 | del_timer(&hinfo->timer); | ||
373 | 371 | ||
374 | /* remove proc entry */ | 372 | /* remove proc entry */ |
375 | remove_proc_entry(hinfo->pde->name, | 373 | remove_proc_entry(hinfo->pde->name, |
diff --git a/net/rfkill/rfkill-input.c b/net/rfkill/rfkill-input.c index 8aa822730145..e5b69556bb5b 100644 --- a/net/rfkill/rfkill-input.c +++ b/net/rfkill/rfkill-input.c | |||
@@ -109,6 +109,25 @@ static DEFINE_RFKILL_TASK(rfkill_uwb, RFKILL_TYPE_UWB); | |||
109 | static DEFINE_RFKILL_TASK(rfkill_wimax, RFKILL_TYPE_WIMAX); | 109 | static DEFINE_RFKILL_TASK(rfkill_wimax, RFKILL_TYPE_WIMAX); |
110 | static DEFINE_RFKILL_TASK(rfkill_wwan, RFKILL_TYPE_WWAN); | 110 | static DEFINE_RFKILL_TASK(rfkill_wwan, RFKILL_TYPE_WWAN); |
111 | 111 | ||
112 | static void rfkill_schedule_evsw_rfkillall(int state) | ||
113 | { | ||
114 | /* EVERY radio type. state != 0 means radios ON */ | ||
115 | /* handle EPO (emergency power off) through shortcut */ | ||
116 | if (state) { | ||
117 | rfkill_schedule_set(&rfkill_wwan, | ||
118 | RFKILL_STATE_UNBLOCKED); | ||
119 | rfkill_schedule_set(&rfkill_wimax, | ||
120 | RFKILL_STATE_UNBLOCKED); | ||
121 | rfkill_schedule_set(&rfkill_uwb, | ||
122 | RFKILL_STATE_UNBLOCKED); | ||
123 | rfkill_schedule_set(&rfkill_bt, | ||
124 | RFKILL_STATE_UNBLOCKED); | ||
125 | rfkill_schedule_set(&rfkill_wlan, | ||
126 | RFKILL_STATE_UNBLOCKED); | ||
127 | } else | ||
128 | rfkill_schedule_epo(); | ||
129 | } | ||
130 | |||
112 | static void rfkill_event(struct input_handle *handle, unsigned int type, | 131 | static void rfkill_event(struct input_handle *handle, unsigned int type, |
113 | unsigned int code, int data) | 132 | unsigned int code, int data) |
114 | { | 133 | { |
@@ -132,21 +151,7 @@ static void rfkill_event(struct input_handle *handle, unsigned int type, | |||
132 | } else if (type == EV_SW) { | 151 | } else if (type == EV_SW) { |
133 | switch (code) { | 152 | switch (code) { |
134 | case SW_RFKILL_ALL: | 153 | case SW_RFKILL_ALL: |
135 | /* EVERY radio type. data != 0 means radios ON */ | 154 | rfkill_schedule_evsw_rfkillall(data); |
136 | /* handle EPO (emergency power off) through shortcut */ | ||
137 | if (data) { | ||
138 | rfkill_schedule_set(&rfkill_wwan, | ||
139 | RFKILL_STATE_UNBLOCKED); | ||
140 | rfkill_schedule_set(&rfkill_wimax, | ||
141 | RFKILL_STATE_UNBLOCKED); | ||
142 | rfkill_schedule_set(&rfkill_uwb, | ||
143 | RFKILL_STATE_UNBLOCKED); | ||
144 | rfkill_schedule_set(&rfkill_bt, | ||
145 | RFKILL_STATE_UNBLOCKED); | ||
146 | rfkill_schedule_set(&rfkill_wlan, | ||
147 | RFKILL_STATE_UNBLOCKED); | ||
148 | } else | ||
149 | rfkill_schedule_epo(); | ||
150 | break; | 155 | break; |
151 | default: | 156 | default: |
152 | break; | 157 | break; |
@@ -168,6 +173,7 @@ static int rfkill_connect(struct input_handler *handler, struct input_dev *dev, | |||
168 | handle->handler = handler; | 173 | handle->handler = handler; |
169 | handle->name = "rfkill"; | 174 | handle->name = "rfkill"; |
170 | 175 | ||
176 | /* causes rfkill_start() to be called */ | ||
171 | error = input_register_handle(handle); | 177 | error = input_register_handle(handle); |
172 | if (error) | 178 | if (error) |
173 | goto err_free_handle; | 179 | goto err_free_handle; |
@@ -185,6 +191,23 @@ static int rfkill_connect(struct input_handler *handler, struct input_dev *dev, | |||
185 | return error; | 191 | return error; |
186 | } | 192 | } |
187 | 193 | ||
194 | static void rfkill_start(struct input_handle *handle) | ||
195 | { | ||
196 | /* Take event_lock to guard against configuration changes, we | ||
197 | * should be able to deal with concurrency with rfkill_event() | ||
198 | * just fine (which event_lock will also avoid). */ | ||
199 | spin_lock_irq(&handle->dev->event_lock); | ||
200 | |||
201 | if (test_bit(EV_SW, handle->dev->evbit)) { | ||
202 | if (test_bit(SW_RFKILL_ALL, handle->dev->swbit)) | ||
203 | rfkill_schedule_evsw_rfkillall(test_bit(SW_RFKILL_ALL, | ||
204 | handle->dev->sw)); | ||
205 | /* add resync for further EV_SW events here */ | ||
206 | } | ||
207 | |||
208 | spin_unlock_irq(&handle->dev->event_lock); | ||
209 | } | ||
210 | |||
188 | static void rfkill_disconnect(struct input_handle *handle) | 211 | static void rfkill_disconnect(struct input_handle *handle) |
189 | { | 212 | { |
190 | input_close_device(handle); | 213 | input_close_device(handle); |
@@ -225,6 +248,7 @@ static struct input_handler rfkill_handler = { | |||
225 | .event = rfkill_event, | 248 | .event = rfkill_event, |
226 | .connect = rfkill_connect, | 249 | .connect = rfkill_connect, |
227 | .disconnect = rfkill_disconnect, | 250 | .disconnect = rfkill_disconnect, |
251 | .start = rfkill_start, | ||
228 | .name = "rfkill", | 252 | .name = "rfkill", |
229 | .id_table = rfkill_ids, | 253 | .id_table = rfkill_ids, |
230 | }; | 254 | }; |
diff --git a/net/rfkill/rfkill.c b/net/rfkill/rfkill.c index 7a560b785097..74aecc098bad 100644 --- a/net/rfkill/rfkill.c +++ b/net/rfkill/rfkill.c | |||
@@ -105,6 +105,16 @@ static void rfkill_led_trigger(struct rfkill *rfkill, | |||
105 | #endif /* CONFIG_RFKILL_LEDS */ | 105 | #endif /* CONFIG_RFKILL_LEDS */ |
106 | } | 106 | } |
107 | 107 | ||
108 | #ifdef CONFIG_RFKILL_LEDS | ||
109 | static void rfkill_led_trigger_activate(struct led_classdev *led) | ||
110 | { | ||
111 | struct rfkill *rfkill = container_of(led->trigger, | ||
112 | struct rfkill, led_trigger); | ||
113 | |||
114 | rfkill_led_trigger(rfkill, rfkill->state); | ||
115 | } | ||
116 | #endif /* CONFIG_RFKILL_LEDS */ | ||
117 | |||
108 | static void notify_rfkill_state_change(struct rfkill *rfkill) | 118 | static void notify_rfkill_state_change(struct rfkill *rfkill) |
109 | { | 119 | { |
110 | blocking_notifier_call_chain(&rfkill_notifier_list, | 120 | blocking_notifier_call_chain(&rfkill_notifier_list, |
@@ -130,7 +140,6 @@ static void update_rfkill_state(struct rfkill *rfkill) | |||
130 | 140 | ||
131 | /** | 141 | /** |
132 | * rfkill_toggle_radio - wrapper for toggle_radio hook | 142 | * rfkill_toggle_radio - wrapper for toggle_radio hook |
133 | * | ||
134 | * @rfkill: the rfkill struct to use | 143 | * @rfkill: the rfkill struct to use |
135 | * @force: calls toggle_radio even if cache says it is not needed, | 144 | * @force: calls toggle_radio even if cache says it is not needed, |
136 | * and also makes sure notifications of the state will be | 145 | * and also makes sure notifications of the state will be |
@@ -141,8 +150,10 @@ static void update_rfkill_state(struct rfkill *rfkill) | |||
141 | * calls and handling all the red tape such as issuing notifications | 150 | * calls and handling all the red tape such as issuing notifications |
142 | * if the call is successful. | 151 | * if the call is successful. |
143 | * | 152 | * |
144 | * Note that @force cannot override a (possibly cached) state of | 153 | * Suspended devices are not touched at all, and -EAGAIN is returned. |
145 | * RFKILL_STATE_HARD_BLOCKED. Any device making use of | 154 | * |
155 | * Note that the @force parameter cannot override a (possibly cached) | ||
156 | * state of RFKILL_STATE_HARD_BLOCKED. Any device making use of | ||
146 | * RFKILL_STATE_HARD_BLOCKED implements either get_state() or | 157 | * RFKILL_STATE_HARD_BLOCKED implements either get_state() or |
147 | * rfkill_force_state(), so the cache either is bypassed or valid. | 158 | * rfkill_force_state(), so the cache either is bypassed or valid. |
148 | * | 159 | * |
@@ -150,7 +161,7 @@ static void update_rfkill_state(struct rfkill *rfkill) | |||
150 | * even if the radio is in RFKILL_STATE_HARD_BLOCKED state, so as to | 161 | * even if the radio is in RFKILL_STATE_HARD_BLOCKED state, so as to |
151 | * give the driver a hint that it should double-BLOCK the transmitter. | 162 | * give the driver a hint that it should double-BLOCK the transmitter. |
152 | * | 163 | * |
153 | * Caller must have aquired rfkill_mutex. | 164 | * Caller must have acquired rfkill->mutex. |
154 | */ | 165 | */ |
155 | static int rfkill_toggle_radio(struct rfkill *rfkill, | 166 | static int rfkill_toggle_radio(struct rfkill *rfkill, |
156 | enum rfkill_state state, | 167 | enum rfkill_state state, |
@@ -159,6 +170,9 @@ static int rfkill_toggle_radio(struct rfkill *rfkill, | |||
159 | int retval = 0; | 170 | int retval = 0; |
160 | enum rfkill_state oldstate, newstate; | 171 | enum rfkill_state oldstate, newstate; |
161 | 172 | ||
173 | if (unlikely(rfkill->dev.power.power_state.event & PM_EVENT_SLEEP)) | ||
174 | return -EBUSY; | ||
175 | |||
162 | oldstate = rfkill->state; | 176 | oldstate = rfkill->state; |
163 | 177 | ||
164 | if (rfkill->get_state && !force && | 178 | if (rfkill->get_state && !force && |
@@ -200,12 +214,12 @@ static int rfkill_toggle_radio(struct rfkill *rfkill, | |||
200 | 214 | ||
201 | /** | 215 | /** |
202 | * rfkill_switch_all - Toggle state of all switches of given type | 216 | * rfkill_switch_all - Toggle state of all switches of given type |
203 | * @type: type of interfaces to be affeceted | 217 | * @type: type of interfaces to be affected |
204 | * @state: the new state | 218 | * @state: the new state |
205 | * | 219 | * |
206 | * This function toggles state of all switches of given type unless | 220 | * This function toggles the state of all switches of given type, |
207 | * a specific switch is claimed by userspace in which case it is | 221 | * unless a specific switch is claimed by userspace (in which case, |
208 | * left alone. | 222 | * that switch is left alone) or suspended. |
209 | */ | 223 | */ |
210 | void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state) | 224 | void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state) |
211 | { | 225 | { |
@@ -216,8 +230,11 @@ void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state) | |||
216 | rfkill_states[type] = state; | 230 | rfkill_states[type] = state; |
217 | 231 | ||
218 | list_for_each_entry(rfkill, &rfkill_list, node) { | 232 | list_for_each_entry(rfkill, &rfkill_list, node) { |
219 | if ((!rfkill->user_claim) && (rfkill->type == type)) | 233 | if ((!rfkill->user_claim) && (rfkill->type == type)) { |
234 | mutex_lock(&rfkill->mutex); | ||
220 | rfkill_toggle_radio(rfkill, state, 0); | 235 | rfkill_toggle_radio(rfkill, state, 0); |
236 | mutex_unlock(&rfkill->mutex); | ||
237 | } | ||
221 | } | 238 | } |
222 | 239 | ||
223 | mutex_unlock(&rfkill_mutex); | 240 | mutex_unlock(&rfkill_mutex); |
@@ -227,8 +244,8 @@ EXPORT_SYMBOL(rfkill_switch_all); | |||
227 | /** | 244 | /** |
228 | * rfkill_epo - emergency power off all transmitters | 245 | * rfkill_epo - emergency power off all transmitters |
229 | * | 246 | * |
230 | * This kicks all rfkill devices to RFKILL_STATE_SOFT_BLOCKED, ignoring | 247 | * This kicks all non-suspended rfkill devices to RFKILL_STATE_SOFT_BLOCKED, |
231 | * everything in its path but rfkill_mutex. | 248 | * ignoring everything in its path but rfkill_mutex and rfkill->mutex. |
232 | */ | 249 | */ |
233 | void rfkill_epo(void) | 250 | void rfkill_epo(void) |
234 | { | 251 | { |
@@ -236,7 +253,9 @@ void rfkill_epo(void) | |||
236 | 253 | ||
237 | mutex_lock(&rfkill_mutex); | 254 | mutex_lock(&rfkill_mutex); |
238 | list_for_each_entry(rfkill, &rfkill_list, node) { | 255 | list_for_each_entry(rfkill, &rfkill_list, node) { |
256 | mutex_lock(&rfkill->mutex); | ||
239 | rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); | 257 | rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); |
258 | mutex_unlock(&rfkill->mutex); | ||
240 | } | 259 | } |
241 | mutex_unlock(&rfkill_mutex); | 260 | mutex_unlock(&rfkill_mutex); |
242 | } | 261 | } |
@@ -252,7 +271,12 @@ EXPORT_SYMBOL_GPL(rfkill_epo); | |||
252 | * a notification by the firmware/hardware of the current *real* | 271 | * a notification by the firmware/hardware of the current *real* |
253 | * state of the radio rfkill switch. | 272 | * state of the radio rfkill switch. |
254 | * | 273 | * |
255 | * It may not be called from an atomic context. | 274 | * Devices which are subject to external changes on their rfkill |
275 | * state (such as those caused by a hardware rfkill line) MUST | ||
276 | * have their driver arrange to call rfkill_force_state() as soon | ||
277 | * as possible after such a change. | ||
278 | * | ||
279 | * This function may not be called from an atomic context. | ||
256 | */ | 280 | */ |
257 | int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state) | 281 | int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state) |
258 | { | 282 | { |
@@ -353,7 +377,7 @@ static ssize_t rfkill_claim_show(struct device *dev, | |||
353 | { | 377 | { |
354 | struct rfkill *rfkill = to_rfkill(dev); | 378 | struct rfkill *rfkill = to_rfkill(dev); |
355 | 379 | ||
356 | return sprintf(buf, "%d", rfkill->user_claim); | 380 | return sprintf(buf, "%d\n", rfkill->user_claim); |
357 | } | 381 | } |
358 | 382 | ||
359 | static ssize_t rfkill_claim_store(struct device *dev, | 383 | static ssize_t rfkill_claim_store(struct device *dev, |
@@ -367,6 +391,9 @@ static ssize_t rfkill_claim_store(struct device *dev, | |||
367 | if (!capable(CAP_NET_ADMIN)) | 391 | if (!capable(CAP_NET_ADMIN)) |
368 | return -EPERM; | 392 | return -EPERM; |
369 | 393 | ||
394 | if (rfkill->user_claim_unsupported) | ||
395 | return -EOPNOTSUPP; | ||
396 | |||
370 | /* | 397 | /* |
371 | * Take the global lock to make sure the kernel is not in | 398 | * Take the global lock to make sure the kernel is not in |
372 | * the middle of rfkill_switch_all | 399 | * the middle of rfkill_switch_all |
@@ -375,19 +402,17 @@ static ssize_t rfkill_claim_store(struct device *dev, | |||
375 | if (error) | 402 | if (error) |
376 | return error; | 403 | return error; |
377 | 404 | ||
378 | if (rfkill->user_claim_unsupported) { | ||
379 | error = -EOPNOTSUPP; | ||
380 | goto out_unlock; | ||
381 | } | ||
382 | if (rfkill->user_claim != claim) { | 405 | if (rfkill->user_claim != claim) { |
383 | if (!claim) | 406 | if (!claim) { |
407 | mutex_lock(&rfkill->mutex); | ||
384 | rfkill_toggle_radio(rfkill, | 408 | rfkill_toggle_radio(rfkill, |
385 | rfkill_states[rfkill->type], | 409 | rfkill_states[rfkill->type], |
386 | 0); | 410 | 0); |
411 | mutex_unlock(&rfkill->mutex); | ||
412 | } | ||
387 | rfkill->user_claim = claim; | 413 | rfkill->user_claim = claim; |
388 | } | 414 | } |
389 | 415 | ||
390 | out_unlock: | ||
391 | mutex_unlock(&rfkill_mutex); | 416 | mutex_unlock(&rfkill_mutex); |
392 | 417 | ||
393 | return error ? error : count; | 418 | return error ? error : count; |
@@ -438,13 +463,14 @@ static int rfkill_resume(struct device *dev) | |||
438 | if (dev->power.power_state.event != PM_EVENT_ON) { | 463 | if (dev->power.power_state.event != PM_EVENT_ON) { |
439 | mutex_lock(&rfkill->mutex); | 464 | mutex_lock(&rfkill->mutex); |
440 | 465 | ||
466 | dev->power.power_state.event = PM_EVENT_ON; | ||
467 | |||
441 | /* restore radio state AND notify everybody */ | 468 | /* restore radio state AND notify everybody */ |
442 | rfkill_toggle_radio(rfkill, rfkill->state, 1); | 469 | rfkill_toggle_radio(rfkill, rfkill->state, 1); |
443 | 470 | ||
444 | mutex_unlock(&rfkill->mutex); | 471 | mutex_unlock(&rfkill->mutex); |
445 | } | 472 | } |
446 | 473 | ||
447 | dev->power.power_state = PMSG_ON; | ||
448 | return 0; | 474 | return 0; |
449 | } | 475 | } |
450 | #else | 476 | #else |
@@ -516,8 +542,11 @@ static void rfkill_remove_switch(struct rfkill *rfkill) | |||
516 | { | 542 | { |
517 | mutex_lock(&rfkill_mutex); | 543 | mutex_lock(&rfkill_mutex); |
518 | list_del_init(&rfkill->node); | 544 | list_del_init(&rfkill->node); |
519 | rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); | ||
520 | mutex_unlock(&rfkill_mutex); | 545 | mutex_unlock(&rfkill_mutex); |
546 | |||
547 | mutex_lock(&rfkill->mutex); | ||
548 | rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); | ||
549 | mutex_unlock(&rfkill->mutex); | ||
521 | } | 550 | } |
522 | 551 | ||
523 | /** | 552 | /** |
@@ -526,9 +555,10 @@ static void rfkill_remove_switch(struct rfkill *rfkill) | |||
526 | * @type: type of the switch (RFKILL_TYPE_*) | 555 | * @type: type of the switch (RFKILL_TYPE_*) |
527 | * | 556 | * |
528 | * This function should be called by the network driver when it needs | 557 | * This function should be called by the network driver when it needs |
529 | * rfkill structure. Once the structure is allocated the driver shoud | 558 | * rfkill structure. Once the structure is allocated the driver should |
530 | * finish its initialization by setting name, private data, enable_radio | 559 | * finish its initialization by setting the name, private data, enable_radio |
531 | * and disable_radio methods and then register it with rfkill_register(). | 560 | * and disable_radio methods and then register it with rfkill_register(). |
561 | * | ||
532 | * NOTE: If registration fails the structure shoudl be freed by calling | 562 | * NOTE: If registration fails the structure shoudl be freed by calling |
533 | * rfkill_free() otherwise rfkill_unregister() should be used. | 563 | * rfkill_free() otherwise rfkill_unregister() should be used. |
534 | */ | 564 | */ |
@@ -560,7 +590,7 @@ EXPORT_SYMBOL(rfkill_allocate); | |||
560 | * rfkill_free - Mark rfkill structure for deletion | 590 | * rfkill_free - Mark rfkill structure for deletion |
561 | * @rfkill: rfkill structure to be destroyed | 591 | * @rfkill: rfkill structure to be destroyed |
562 | * | 592 | * |
563 | * Decrements reference count of rfkill structure so it is destroyed. | 593 | * Decrements reference count of the rfkill structure so it is destroyed. |
564 | * Note that rfkill_free() should _not_ be called after rfkill_unregister(). | 594 | * Note that rfkill_free() should _not_ be called after rfkill_unregister(). |
565 | */ | 595 | */ |
566 | void rfkill_free(struct rfkill *rfkill) | 596 | void rfkill_free(struct rfkill *rfkill) |
@@ -575,7 +605,10 @@ static void rfkill_led_trigger_register(struct rfkill *rfkill) | |||
575 | #ifdef CONFIG_RFKILL_LEDS | 605 | #ifdef CONFIG_RFKILL_LEDS |
576 | int error; | 606 | int error; |
577 | 607 | ||
578 | rfkill->led_trigger.name = rfkill->dev.bus_id; | 608 | if (!rfkill->led_trigger.name) |
609 | rfkill->led_trigger.name = rfkill->dev.bus_id; | ||
610 | if (!rfkill->led_trigger.activate) | ||
611 | rfkill->led_trigger.activate = rfkill_led_trigger_activate; | ||
579 | error = led_trigger_register(&rfkill->led_trigger); | 612 | error = led_trigger_register(&rfkill->led_trigger); |
580 | if (error) | 613 | if (error) |
581 | rfkill->led_trigger.name = NULL; | 614 | rfkill->led_trigger.name = NULL; |
@@ -585,8 +618,10 @@ static void rfkill_led_trigger_register(struct rfkill *rfkill) | |||
585 | static void rfkill_led_trigger_unregister(struct rfkill *rfkill) | 618 | static void rfkill_led_trigger_unregister(struct rfkill *rfkill) |
586 | { | 619 | { |
587 | #ifdef CONFIG_RFKILL_LEDS | 620 | #ifdef CONFIG_RFKILL_LEDS |
588 | if (rfkill->led_trigger.name) | 621 | if (rfkill->led_trigger.name) { |
589 | led_trigger_unregister(&rfkill->led_trigger); | 622 | led_trigger_unregister(&rfkill->led_trigger); |
623 | rfkill->led_trigger.name = NULL; | ||
624 | } | ||
590 | #endif | 625 | #endif |
591 | } | 626 | } |
592 | 627 | ||
@@ -622,8 +657,8 @@ int rfkill_register(struct rfkill *rfkill) | |||
622 | 657 | ||
623 | error = device_add(dev); | 658 | error = device_add(dev); |
624 | if (error) { | 659 | if (error) { |
625 | rfkill_led_trigger_unregister(rfkill); | ||
626 | rfkill_remove_switch(rfkill); | 660 | rfkill_remove_switch(rfkill); |
661 | rfkill_led_trigger_unregister(rfkill); | ||
627 | return error; | 662 | return error; |
628 | } | 663 | } |
629 | 664 | ||
diff --git a/net/rxrpc/ar-accept.c b/net/rxrpc/ar-accept.c index bdfb77417794..77228f28fa36 100644 --- a/net/rxrpc/ar-accept.c +++ b/net/rxrpc/ar-accept.c | |||
@@ -100,7 +100,7 @@ static int rxrpc_accept_incoming_call(struct rxrpc_local *local, | |||
100 | 100 | ||
101 | trans = rxrpc_get_transport(local, peer, GFP_NOIO); | 101 | trans = rxrpc_get_transport(local, peer, GFP_NOIO); |
102 | rxrpc_put_peer(peer); | 102 | rxrpc_put_peer(peer); |
103 | if (!trans) { | 103 | if (IS_ERR(trans)) { |
104 | _debug("no trans"); | 104 | _debug("no trans"); |
105 | ret = -EBUSY; | 105 | ret = -EBUSY; |
106 | goto error; | 106 | goto error; |
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index d308c19aa3f9..9974b3f04f05 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -205,10 +205,9 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind, | |||
205 | { | 205 | { |
206 | struct tcf_common *p = NULL; | 206 | struct tcf_common *p = NULL; |
207 | if (index && (p = tcf_hash_lookup(index, hinfo)) != NULL) { | 207 | if (index && (p = tcf_hash_lookup(index, hinfo)) != NULL) { |
208 | if (bind) { | 208 | if (bind) |
209 | p->tcfc_bindcnt++; | 209 | p->tcfc_bindcnt++; |
210 | p->tcfc_refcnt++; | 210 | p->tcfc_refcnt++; |
211 | } | ||
212 | a->priv = p; | 211 | a->priv = p; |
213 | } | 212 | } |
214 | return p; | 213 | return p; |
@@ -752,7 +751,7 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | |||
752 | struct nlattr *tb[TCA_ACT_MAX+1]; | 751 | struct nlattr *tb[TCA_ACT_MAX+1]; |
753 | struct nlattr *kind; | 752 | struct nlattr *kind; |
754 | struct tc_action *a = create_a(0); | 753 | struct tc_action *a = create_a(0); |
755 | int err = -EINVAL; | 754 | int err = -ENOMEM; |
756 | 755 | ||
757 | if (a == NULL) { | 756 | if (a == NULL) { |
758 | printk("tca_action_flush: couldnt create tc_action\n"); | 757 | printk("tca_action_flush: couldnt create tc_action\n"); |
@@ -763,7 +762,7 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | |||
763 | if (!skb) { | 762 | if (!skb) { |
764 | printk("tca_action_flush: failed skb alloc\n"); | 763 | printk("tca_action_flush: failed skb alloc\n"); |
765 | kfree(a); | 764 | kfree(a); |
766 | return -ENOBUFS; | 765 | return err; |
767 | } | 766 | } |
768 | 767 | ||
769 | b = skb_tail_pointer(skb); | 768 | b = skb_tail_pointer(skb); |
@@ -791,6 +790,8 @@ static int tca_action_flush(struct nlattr *nla, struct nlmsghdr *n, u32 pid) | |||
791 | err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); | 790 | err = a->ops->walk(skb, &dcb, RTM_DELACTION, a); |
792 | if (err < 0) | 791 | if (err < 0) |
793 | goto nla_put_failure; | 792 | goto nla_put_failure; |
793 | if (err == 0) | ||
794 | goto noflush_out; | ||
794 | 795 | ||
795 | nla_nest_end(skb, nest); | 796 | nla_nest_end(skb, nest); |
796 | 797 | ||
@@ -808,6 +809,7 @@ nla_put_failure: | |||
808 | nlmsg_failure: | 809 | nlmsg_failure: |
809 | module_put(a->ops->owner); | 810 | module_put(a->ops->owner); |
810 | err_out: | 811 | err_out: |
812 | noflush_out: | ||
811 | kfree_skb(skb); | 813 | kfree_skb(skb); |
812 | kfree(a); | 814 | kfree(a); |
813 | return err; | 815 | return err; |
@@ -825,8 +827,10 @@ tca_action_gd(struct nlattr *nla, struct nlmsghdr *n, u32 pid, int event) | |||
825 | return ret; | 827 | return ret; |
826 | 828 | ||
827 | if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { | 829 | if (event == RTM_DELACTION && n->nlmsg_flags&NLM_F_ROOT) { |
828 | if (tb[0] != NULL && tb[1] == NULL) | 830 | if (tb[1] != NULL) |
829 | return tca_action_flush(tb[0], n, pid); | 831 | return tca_action_flush(tb[1], n, pid); |
832 | else | ||
833 | return -EINVAL; | ||
830 | } | 834 | } |
831 | 835 | ||
832 | for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { | 836 | for (i = 1; i <= TCA_ACT_MAX_PRIO && tb[i]; i++) { |
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index d2b6f54a6261..8eb79e92e94c 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -205,7 +205,7 @@ replay: | |||
205 | } | 205 | } |
206 | } | 206 | } |
207 | 207 | ||
208 | root_lock = qdisc_root_lock(q); | 208 | root_lock = qdisc_root_sleeping_lock(q); |
209 | 209 | ||
210 | if (tp == NULL) { | 210 | if (tp == NULL) { |
211 | /* Proto-tcf does not exist, create new one */ | 211 | /* Proto-tcf does not exist, create new one */ |
@@ -280,7 +280,7 @@ replay: | |||
280 | if (n->nlmsg_type == RTM_DELTFILTER && t->tcm_handle == 0) { | 280 | if (n->nlmsg_type == RTM_DELTFILTER && t->tcm_handle == 0) { |
281 | spin_lock_bh(root_lock); | 281 | spin_lock_bh(root_lock); |
282 | *back = tp->next; | 282 | *back = tp->next; |
283 | spin_lock_bh(root_lock); | 283 | spin_unlock_bh(root_lock); |
284 | 284 | ||
285 | tfilter_notify(skb, n, tp, fh, RTM_DELTFILTER); | 285 | tfilter_notify(skb, n, tp, fh, RTM_DELTFILTER); |
286 | tcf_destroy(tp); | 286 | tcf_destroy(tp); |
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index 481260a4f10f..e3d8455eebc2 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c | |||
@@ -75,7 +75,7 @@ static __inline__ int route4_fastmap_hash(u32 id, int iif) | |||
75 | static inline | 75 | static inline |
76 | void route4_reset_fastmap(struct Qdisc *q, struct route4_head *head, u32 id) | 76 | void route4_reset_fastmap(struct Qdisc *q, struct route4_head *head, u32 id) |
77 | { | 77 | { |
78 | spinlock_t *root_lock = qdisc_root_lock(q); | 78 | spinlock_t *root_lock = qdisc_root_sleeping_lock(q); |
79 | 79 | ||
80 | spin_lock_bh(root_lock); | 80 | spin_lock_bh(root_lock); |
81 | memset(head->fastmap, 0, sizeof(head->fastmap)); | 81 | memset(head->fastmap, 0, sizeof(head->fastmap)); |
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c index b0601642e227..1122c952aa99 100644 --- a/net/sched/sch_api.c +++ b/net/sched/sch_api.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/kmod.h> | 27 | #include <linux/kmod.h> |
28 | #include <linux/list.h> | 28 | #include <linux/list.h> |
29 | #include <linux/hrtimer.h> | 29 | #include <linux/hrtimer.h> |
30 | #include <linux/lockdep.h> | ||
30 | 31 | ||
31 | #include <net/net_namespace.h> | 32 | #include <net/net_namespace.h> |
32 | #include <net/sock.h> | 33 | #include <net/sock.h> |
@@ -183,24 +184,68 @@ EXPORT_SYMBOL(unregister_qdisc); | |||
183 | (root qdisc, all its children, children of children etc.) | 184 | (root qdisc, all its children, children of children etc.) |
184 | */ | 185 | */ |
185 | 186 | ||
187 | struct Qdisc *qdisc_match_from_root(struct Qdisc *root, u32 handle) | ||
188 | { | ||
189 | struct Qdisc *q; | ||
190 | |||
191 | if (!(root->flags & TCQ_F_BUILTIN) && | ||
192 | root->handle == handle) | ||
193 | return root; | ||
194 | |||
195 | list_for_each_entry(q, &root->list, list) { | ||
196 | if (q->handle == handle) | ||
197 | return q; | ||
198 | } | ||
199 | return NULL; | ||
200 | } | ||
201 | |||
202 | /* | ||
203 | * This lock is needed until some qdiscs stop calling qdisc_tree_decrease_qlen() | ||
204 | * without rtnl_lock(); currently hfsc_dequeue(), netem_dequeue(), tbf_dequeue() | ||
205 | */ | ||
206 | static DEFINE_SPINLOCK(qdisc_list_lock); | ||
207 | |||
208 | static void qdisc_list_add(struct Qdisc *q) | ||
209 | { | ||
210 | if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) { | ||
211 | spin_lock_bh(&qdisc_list_lock); | ||
212 | list_add_tail(&q->list, &qdisc_root_sleeping(q)->list); | ||
213 | spin_unlock_bh(&qdisc_list_lock); | ||
214 | } | ||
215 | } | ||
216 | |||
217 | void qdisc_list_del(struct Qdisc *q) | ||
218 | { | ||
219 | if ((q->parent != TC_H_ROOT) && !(q->flags & TCQ_F_INGRESS)) { | ||
220 | spin_lock_bh(&qdisc_list_lock); | ||
221 | list_del(&q->list); | ||
222 | spin_unlock_bh(&qdisc_list_lock); | ||
223 | } | ||
224 | } | ||
225 | EXPORT_SYMBOL(qdisc_list_del); | ||
226 | |||
186 | struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle) | 227 | struct Qdisc *qdisc_lookup(struct net_device *dev, u32 handle) |
187 | { | 228 | { |
188 | unsigned int i; | 229 | unsigned int i; |
230 | struct Qdisc *q; | ||
231 | |||
232 | spin_lock_bh(&qdisc_list_lock); | ||
189 | 233 | ||
190 | for (i = 0; i < dev->num_tx_queues; i++) { | 234 | for (i = 0; i < dev->num_tx_queues; i++) { |
191 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); | 235 | struct netdev_queue *txq = netdev_get_tx_queue(dev, i); |
192 | struct Qdisc *q, *txq_root = txq->qdisc; | 236 | struct Qdisc *txq_root = txq->qdisc_sleeping; |
193 | |||
194 | if (!(txq_root->flags & TCQ_F_BUILTIN) && | ||
195 | txq_root->handle == handle) | ||
196 | return txq_root; | ||
197 | 237 | ||
198 | list_for_each_entry(q, &txq_root->list, list) { | 238 | q = qdisc_match_from_root(txq_root, handle); |
199 | if (q->handle == handle) | 239 | if (q) |
200 | return q; | 240 | goto unlock; |
201 | } | ||
202 | } | 241 | } |
203 | return NULL; | 242 | |
243 | q = qdisc_match_from_root(dev->rx_queue.qdisc_sleeping, handle); | ||
244 | |||
245 | unlock: | ||
246 | spin_unlock_bh(&qdisc_list_lock); | ||
247 | |||
248 | return q; | ||
204 | } | 249 | } |
205 | 250 | ||
206 | static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid) | 251 | static struct Qdisc *qdisc_leaf(struct Qdisc *p, u32 classid) |
@@ -416,7 +461,7 @@ static enum hrtimer_restart qdisc_watchdog(struct hrtimer *timer) | |||
416 | 461 | ||
417 | wd->qdisc->flags &= ~TCQ_F_THROTTLED; | 462 | wd->qdisc->flags &= ~TCQ_F_THROTTLED; |
418 | smp_wmb(); | 463 | smp_wmb(); |
419 | __netif_schedule(wd->qdisc); | 464 | __netif_schedule(qdisc_root(wd->qdisc)); |
420 | 465 | ||
421 | return HRTIMER_NORESTART; | 466 | return HRTIMER_NORESTART; |
422 | } | 467 | } |
@@ -433,6 +478,10 @@ void qdisc_watchdog_schedule(struct qdisc_watchdog *wd, psched_time_t expires) | |||
433 | { | 478 | { |
434 | ktime_t time; | 479 | ktime_t time; |
435 | 480 | ||
481 | if (test_bit(__QDISC_STATE_DEACTIVATED, | ||
482 | &qdisc_root_sleeping(wd->qdisc)->state)) | ||
483 | return; | ||
484 | |||
436 | wd->qdisc->flags |= TCQ_F_THROTTLED; | 485 | wd->qdisc->flags |= TCQ_F_THROTTLED; |
437 | time = ktime_set(0, 0); | 486 | time = ktime_set(0, 0); |
438 | time = ktime_add_ns(time, PSCHED_US2NS(expires)); | 487 | time = ktime_add_ns(time, PSCHED_US2NS(expires)); |
@@ -572,44 +621,21 @@ static u32 qdisc_alloc_handle(struct net_device *dev) | |||
572 | static struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, | 621 | static struct Qdisc *dev_graft_qdisc(struct netdev_queue *dev_queue, |
573 | struct Qdisc *qdisc) | 622 | struct Qdisc *qdisc) |
574 | { | 623 | { |
624 | struct Qdisc *oqdisc = dev_queue->qdisc_sleeping; | ||
575 | spinlock_t *root_lock; | 625 | spinlock_t *root_lock; |
576 | struct Qdisc *oqdisc; | ||
577 | int ingress; | ||
578 | |||
579 | ingress = 0; | ||
580 | if (qdisc && qdisc->flags&TCQ_F_INGRESS) | ||
581 | ingress = 1; | ||
582 | 626 | ||
583 | if (ingress) { | 627 | root_lock = qdisc_lock(oqdisc); |
584 | oqdisc = dev_queue->qdisc; | ||
585 | } else { | ||
586 | oqdisc = dev_queue->qdisc_sleeping; | ||
587 | } | ||
588 | |||
589 | root_lock = qdisc_root_lock(oqdisc); | ||
590 | spin_lock_bh(root_lock); | 628 | spin_lock_bh(root_lock); |
591 | 629 | ||
592 | if (ingress) { | 630 | /* Prune old scheduler */ |
593 | /* Prune old scheduler */ | 631 | if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1) |
594 | if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1) { | 632 | qdisc_reset(oqdisc); |
595 | /* delete */ | ||
596 | qdisc_reset(oqdisc); | ||
597 | dev_queue->qdisc = NULL; | ||
598 | } else { /* new */ | ||
599 | dev_queue->qdisc = qdisc; | ||
600 | } | ||
601 | 633 | ||
602 | } else { | 634 | /* ... and graft new one */ |
603 | /* Prune old scheduler */ | 635 | if (qdisc == NULL) |
604 | if (oqdisc && atomic_read(&oqdisc->refcnt) <= 1) | 636 | qdisc = &noop_qdisc; |
605 | qdisc_reset(oqdisc); | 637 | dev_queue->qdisc_sleeping = qdisc; |
606 | 638 | rcu_assign_pointer(dev_queue->qdisc, &noop_qdisc); | |
607 | /* ... and graft new one */ | ||
608 | if (qdisc == NULL) | ||
609 | qdisc = &noop_qdisc; | ||
610 | dev_queue->qdisc_sleeping = qdisc; | ||
611 | dev_queue->qdisc = &noop_qdisc; | ||
612 | } | ||
613 | 639 | ||
614 | spin_unlock_bh(root_lock); | 640 | spin_unlock_bh(root_lock); |
615 | 641 | ||
@@ -650,11 +676,8 @@ static void notify_and_destroy(struct sk_buff *skb, struct nlmsghdr *n, u32 clid | |||
650 | if (new || old) | 676 | if (new || old) |
651 | qdisc_notify(skb, n, clid, old, new); | 677 | qdisc_notify(skb, n, clid, old, new); |
652 | 678 | ||
653 | if (old) { | 679 | if (old) |
654 | spin_lock_bh(&old->q.lock); | ||
655 | qdisc_destroy(old); | 680 | qdisc_destroy(old); |
656 | spin_unlock_bh(&old->q.lock); | ||
657 | } | ||
658 | } | 681 | } |
659 | 682 | ||
660 | /* Graft qdisc "new" to class "classid" of qdisc "parent" or | 683 | /* Graft qdisc "new" to class "classid" of qdisc "parent" or |
@@ -678,7 +701,8 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, | |||
678 | 701 | ||
679 | ingress = 0; | 702 | ingress = 0; |
680 | num_q = dev->num_tx_queues; | 703 | num_q = dev->num_tx_queues; |
681 | if (q && q->flags & TCQ_F_INGRESS) { | 704 | if ((q && q->flags & TCQ_F_INGRESS) || |
705 | (new && new->flags & TCQ_F_INGRESS)) { | ||
682 | num_q = 1; | 706 | num_q = 1; |
683 | ingress = 1; | 707 | ingress = 1; |
684 | } | 708 | } |
@@ -692,13 +716,10 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, | |||
692 | if (!ingress) | 716 | if (!ingress) |
693 | dev_queue = netdev_get_tx_queue(dev, i); | 717 | dev_queue = netdev_get_tx_queue(dev, i); |
694 | 718 | ||
695 | if (ingress) { | 719 | old = dev_graft_qdisc(dev_queue, new); |
696 | old = dev_graft_qdisc(dev_queue, q); | 720 | if (new && i > 0) |
697 | } else { | 721 | atomic_inc(&new->refcnt); |
698 | old = dev_graft_qdisc(dev_queue, new); | 722 | |
699 | if (new && i > 0) | ||
700 | atomic_inc(&new->refcnt); | ||
701 | } | ||
702 | notify_and_destroy(skb, n, classid, old, new); | 723 | notify_and_destroy(skb, n, classid, old, new); |
703 | } | 724 | } |
704 | 725 | ||
@@ -722,6 +743,10 @@ static int qdisc_graft(struct net_device *dev, struct Qdisc *parent, | |||
722 | return err; | 743 | return err; |
723 | } | 744 | } |
724 | 745 | ||
746 | /* lockdep annotation is needed for ingress; egress gets it only for name */ | ||
747 | static struct lock_class_key qdisc_tx_lock; | ||
748 | static struct lock_class_key qdisc_rx_lock; | ||
749 | |||
725 | /* | 750 | /* |
726 | Allocate and initialize new qdisc. | 751 | Allocate and initialize new qdisc. |
727 | 752 | ||
@@ -782,6 +807,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
782 | if (handle == TC_H_INGRESS) { | 807 | if (handle == TC_H_INGRESS) { |
783 | sch->flags |= TCQ_F_INGRESS; | 808 | sch->flags |= TCQ_F_INGRESS; |
784 | handle = TC_H_MAKE(TC_H_INGRESS, 0); | 809 | handle = TC_H_MAKE(TC_H_INGRESS, 0); |
810 | lockdep_set_class(qdisc_lock(sch), &qdisc_rx_lock); | ||
785 | } else { | 811 | } else { |
786 | if (handle == 0) { | 812 | if (handle == 0) { |
787 | handle = qdisc_alloc_handle(dev); | 813 | handle = qdisc_alloc_handle(dev); |
@@ -789,6 +815,7 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
789 | if (handle == 0) | 815 | if (handle == 0) |
790 | goto err_out3; | 816 | goto err_out3; |
791 | } | 817 | } |
818 | lockdep_set_class(qdisc_lock(sch), &qdisc_tx_lock); | ||
792 | } | 819 | } |
793 | 820 | ||
794 | sch->handle = handle; | 821 | sch->handle = handle; |
@@ -803,9 +830,16 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
803 | sch->stab = stab; | 830 | sch->stab = stab; |
804 | } | 831 | } |
805 | if (tca[TCA_RATE]) { | 832 | if (tca[TCA_RATE]) { |
833 | spinlock_t *root_lock; | ||
834 | |||
835 | if ((sch->parent != TC_H_ROOT) && | ||
836 | !(sch->flags & TCQ_F_INGRESS)) | ||
837 | root_lock = qdisc_root_sleeping_lock(sch); | ||
838 | else | ||
839 | root_lock = qdisc_lock(sch); | ||
840 | |||
806 | err = gen_new_estimator(&sch->bstats, &sch->rate_est, | 841 | err = gen_new_estimator(&sch->bstats, &sch->rate_est, |
807 | qdisc_root_lock(sch), | 842 | root_lock, tca[TCA_RATE]); |
808 | tca[TCA_RATE]); | ||
809 | if (err) { | 843 | if (err) { |
810 | /* | 844 | /* |
811 | * Any broken qdiscs that would require | 845 | * Any broken qdiscs that would require |
@@ -817,8 +851,8 @@ qdisc_create(struct net_device *dev, struct netdev_queue *dev_queue, | |||
817 | goto err_out3; | 851 | goto err_out3; |
818 | } | 852 | } |
819 | } | 853 | } |
820 | if (parent) | 854 | |
821 | list_add_tail(&sch->list, &dev_queue->qdisc->list); | 855 | qdisc_list_add(sch); |
822 | 856 | ||
823 | return sch; | 857 | return sch; |
824 | } | 858 | } |
@@ -857,7 +891,8 @@ static int qdisc_change(struct Qdisc *sch, struct nlattr **tca) | |||
857 | 891 | ||
858 | if (tca[TCA_RATE]) | 892 | if (tca[TCA_RATE]) |
859 | gen_replace_estimator(&sch->bstats, &sch->rate_est, | 893 | gen_replace_estimator(&sch->bstats, &sch->rate_est, |
860 | qdisc_root_lock(sch), tca[TCA_RATE]); | 894 | qdisc_root_sleeping_lock(sch), |
895 | tca[TCA_RATE]); | ||
861 | return 0; | 896 | return 0; |
862 | } | 897 | } |
863 | 898 | ||
@@ -933,7 +968,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n, void *arg) | |||
933 | return -ENOENT; | 968 | return -ENOENT; |
934 | q = qdisc_leaf(p, clid); | 969 | q = qdisc_leaf(p, clid); |
935 | } else { /* ingress */ | 970 | } else { /* ingress */ |
936 | q = dev->rx_queue.qdisc; | 971 | q = dev->rx_queue.qdisc_sleeping; |
937 | } | 972 | } |
938 | } else { | 973 | } else { |
939 | struct netdev_queue *dev_queue; | 974 | struct netdev_queue *dev_queue; |
@@ -1003,7 +1038,7 @@ replay: | |||
1003 | return -ENOENT; | 1038 | return -ENOENT; |
1004 | q = qdisc_leaf(p, clid); | 1039 | q = qdisc_leaf(p, clid); |
1005 | } else { /*ingress */ | 1040 | } else { /*ingress */ |
1006 | q = dev->rx_queue.qdisc; | 1041 | q = dev->rx_queue.qdisc_sleeping; |
1007 | } | 1042 | } |
1008 | } else { | 1043 | } else { |
1009 | struct netdev_queue *dev_queue; | 1044 | struct netdev_queue *dev_queue; |
@@ -1099,20 +1134,13 @@ create_n_graft: | |||
1099 | } | 1134 | } |
1100 | 1135 | ||
1101 | graft: | 1136 | graft: |
1102 | if (1) { | 1137 | err = qdisc_graft(dev, p, skb, n, clid, q, NULL); |
1103 | spinlock_t *root_lock; | 1138 | if (err) { |
1104 | 1139 | if (q) | |
1105 | err = qdisc_graft(dev, p, skb, n, clid, q, NULL); | 1140 | qdisc_destroy(q); |
1106 | if (err) { | 1141 | return err; |
1107 | if (q) { | ||
1108 | root_lock = qdisc_root_lock(q); | ||
1109 | spin_lock_bh(root_lock); | ||
1110 | qdisc_destroy(q); | ||
1111 | spin_unlock_bh(root_lock); | ||
1112 | } | ||
1113 | return err; | ||
1114 | } | ||
1115 | } | 1142 | } |
1143 | |||
1116 | return 0; | 1144 | return 0; |
1117 | } | 1145 | } |
1118 | 1146 | ||
@@ -1141,8 +1169,8 @@ static int tc_fill_qdisc(struct sk_buff *skb, struct Qdisc *q, u32 clid, | |||
1141 | if (q->stab && qdisc_dump_stab(skb, q->stab) < 0) | 1169 | if (q->stab && qdisc_dump_stab(skb, q->stab) < 0) |
1142 | goto nla_put_failure; | 1170 | goto nla_put_failure; |
1143 | 1171 | ||
1144 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, | 1172 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, TCA_XSTATS, |
1145 | TCA_XSTATS, qdisc_root_lock(q), &d) < 0) | 1173 | qdisc_root_sleeping_lock(q), &d) < 0) |
1146 | goto nla_put_failure; | 1174 | goto nla_put_failure; |
1147 | 1175 | ||
1148 | if (q->ops->dump_stats && q->ops->dump_stats(q, &d) < 0) | 1176 | if (q->ops->dump_stats && q->ops->dump_stats(q, &d) < 0) |
@@ -1261,11 +1289,11 @@ static int tc_dump_qdisc(struct sk_buff *skb, struct netlink_callback *cb) | |||
1261 | q_idx = 0; | 1289 | q_idx = 0; |
1262 | 1290 | ||
1263 | dev_queue = netdev_get_tx_queue(dev, 0); | 1291 | dev_queue = netdev_get_tx_queue(dev, 0); |
1264 | if (tc_dump_qdisc_root(dev_queue->qdisc, skb, cb, &q_idx, s_q_idx) < 0) | 1292 | if (tc_dump_qdisc_root(dev_queue->qdisc_sleeping, skb, cb, &q_idx, s_q_idx) < 0) |
1265 | goto done; | 1293 | goto done; |
1266 | 1294 | ||
1267 | dev_queue = &dev->rx_queue; | 1295 | dev_queue = &dev->rx_queue; |
1268 | if (tc_dump_qdisc_root(dev_queue->qdisc, skb, cb, &q_idx, s_q_idx) < 0) | 1296 | if (tc_dump_qdisc_root(dev_queue->qdisc_sleeping, skb, cb, &q_idx, s_q_idx) < 0) |
1269 | goto done; | 1297 | goto done; |
1270 | 1298 | ||
1271 | cont: | 1299 | cont: |
@@ -1433,8 +1461,8 @@ static int tc_fill_tclass(struct sk_buff *skb, struct Qdisc *q, | |||
1433 | if (cl_ops->dump && cl_ops->dump(q, cl, skb, tcm) < 0) | 1461 | if (cl_ops->dump && cl_ops->dump(q, cl, skb, tcm) < 0) |
1434 | goto nla_put_failure; | 1462 | goto nla_put_failure; |
1435 | 1463 | ||
1436 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, | 1464 | if (gnet_stats_start_copy_compat(skb, TCA_STATS2, TCA_STATS, TCA_XSTATS, |
1437 | TCA_XSTATS, qdisc_root_lock(q), &d) < 0) | 1465 | qdisc_root_sleeping_lock(q), &d) < 0) |
1438 | goto nla_put_failure; | 1466 | goto nla_put_failure; |
1439 | 1467 | ||
1440 | if (cl_ops->dump_stats && cl_ops->dump_stats(q, cl, &d) < 0) | 1468 | if (cl_ops->dump_stats && cl_ops->dump_stats(q, cl, &d) < 0) |
@@ -1554,11 +1582,11 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb) | |||
1554 | t = 0; | 1582 | t = 0; |
1555 | 1583 | ||
1556 | dev_queue = netdev_get_tx_queue(dev, 0); | 1584 | dev_queue = netdev_get_tx_queue(dev, 0); |
1557 | if (tc_dump_tclass_root(dev_queue->qdisc, skb, tcm, cb, &t, s_t) < 0) | 1585 | if (tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb, &t, s_t) < 0) |
1558 | goto done; | 1586 | goto done; |
1559 | 1587 | ||
1560 | dev_queue = &dev->rx_queue; | 1588 | dev_queue = &dev->rx_queue; |
1561 | if (tc_dump_tclass_root(dev_queue->qdisc, skb, tcm, cb, &t, s_t) < 0) | 1589 | if (tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb, &t, s_t) < 0) |
1562 | goto done; | 1590 | goto done; |
1563 | 1591 | ||
1564 | done: | 1592 | done: |
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c index 6b517b9dac5b..43d37256c15e 100644 --- a/net/sched/sch_atm.c +++ b/net/sched/sch_atm.c | |||
@@ -415,7 +415,7 @@ static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
415 | case TC_ACT_QUEUED: | 415 | case TC_ACT_QUEUED: |
416 | case TC_ACT_STOLEN: | 416 | case TC_ACT_STOLEN: |
417 | kfree_skb(skb); | 417 | kfree_skb(skb); |
418 | return NET_XMIT_SUCCESS; | 418 | return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
419 | case TC_ACT_SHOT: | 419 | case TC_ACT_SHOT: |
420 | kfree_skb(skb); | 420 | kfree_skb(skb); |
421 | goto drop; | 421 | goto drop; |
@@ -432,9 +432,11 @@ static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
432 | ret = qdisc_enqueue(skb, flow->q); | 432 | ret = qdisc_enqueue(skb, flow->q); |
433 | if (ret != 0) { | 433 | if (ret != 0) { |
434 | drop: __maybe_unused | 434 | drop: __maybe_unused |
435 | sch->qstats.drops++; | 435 | if (net_xmit_drop_count(ret)) { |
436 | if (flow) | 436 | sch->qstats.drops++; |
437 | flow->qstats.drops++; | 437 | if (flow) |
438 | flow->qstats.drops++; | ||
439 | } | ||
438 | return ret; | 440 | return ret; |
439 | } | 441 | } |
440 | sch->bstats.bytes += qdisc_pkt_len(skb); | 442 | sch->bstats.bytes += qdisc_pkt_len(skb); |
@@ -455,7 +457,7 @@ drop: __maybe_unused | |||
455 | return 0; | 457 | return 0; |
456 | } | 458 | } |
457 | tasklet_schedule(&p->task); | 459 | tasklet_schedule(&p->task); |
458 | return NET_XMIT_BYPASS; | 460 | return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
459 | } | 461 | } |
460 | 462 | ||
461 | /* | 463 | /* |
@@ -530,7 +532,7 @@ static int atm_tc_requeue(struct sk_buff *skb, struct Qdisc *sch) | |||
530 | if (!ret) { | 532 | if (!ret) { |
531 | sch->q.qlen++; | 533 | sch->q.qlen++; |
532 | sch->qstats.requeues++; | 534 | sch->qstats.requeues++; |
533 | } else { | 535 | } else if (net_xmit_drop_count(ret)) { |
534 | sch->qstats.drops++; | 536 | sch->qstats.drops++; |
535 | p->link.qstats.drops++; | 537 | p->link.qstats.drops++; |
536 | } | 538 | } |
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c index 14954bf4a683..8b06fa900482 100644 --- a/net/sched/sch_cbq.c +++ b/net/sched/sch_cbq.c | |||
@@ -230,7 +230,7 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) | |||
230 | (cl = cbq_class_lookup(q, prio)) != NULL) | 230 | (cl = cbq_class_lookup(q, prio)) != NULL) |
231 | return cl; | 231 | return cl; |
232 | 232 | ||
233 | *qerr = NET_XMIT_BYPASS; | 233 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
234 | for (;;) { | 234 | for (;;) { |
235 | int result = 0; | 235 | int result = 0; |
236 | defmap = head->defaults; | 236 | defmap = head->defaults; |
@@ -256,7 +256,7 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) | |||
256 | switch (result) { | 256 | switch (result) { |
257 | case TC_ACT_QUEUED: | 257 | case TC_ACT_QUEUED: |
258 | case TC_ACT_STOLEN: | 258 | case TC_ACT_STOLEN: |
259 | *qerr = NET_XMIT_SUCCESS; | 259 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
260 | case TC_ACT_SHOT: | 260 | case TC_ACT_SHOT: |
261 | return NULL; | 261 | return NULL; |
262 | case TC_ACT_RECLASSIFY: | 262 | case TC_ACT_RECLASSIFY: |
@@ -377,7 +377,7 @@ cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
377 | q->rx_class = cl; | 377 | q->rx_class = cl; |
378 | #endif | 378 | #endif |
379 | if (cl == NULL) { | 379 | if (cl == NULL) { |
380 | if (ret == NET_XMIT_BYPASS) | 380 | if (ret & __NET_XMIT_BYPASS) |
381 | sch->qstats.drops++; | 381 | sch->qstats.drops++; |
382 | kfree_skb(skb); | 382 | kfree_skb(skb); |
383 | return ret; | 383 | return ret; |
@@ -397,9 +397,11 @@ cbq_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
397 | return ret; | 397 | return ret; |
398 | } | 398 | } |
399 | 399 | ||
400 | sch->qstats.drops++; | 400 | if (net_xmit_drop_count(ret)) { |
401 | cbq_mark_toplevel(q, cl); | 401 | sch->qstats.drops++; |
402 | cl->qstats.drops++; | 402 | cbq_mark_toplevel(q, cl); |
403 | cl->qstats.drops++; | ||
404 | } | ||
403 | return ret; | 405 | return ret; |
404 | } | 406 | } |
405 | 407 | ||
@@ -430,8 +432,10 @@ cbq_requeue(struct sk_buff *skb, struct Qdisc *sch) | |||
430 | cbq_activate_class(cl); | 432 | cbq_activate_class(cl); |
431 | return 0; | 433 | return 0; |
432 | } | 434 | } |
433 | sch->qstats.drops++; | 435 | if (net_xmit_drop_count(ret)) { |
434 | cl->qstats.drops++; | 436 | sch->qstats.drops++; |
437 | cl->qstats.drops++; | ||
438 | } | ||
435 | return ret; | 439 | return ret; |
436 | } | 440 | } |
437 | 441 | ||
@@ -517,6 +521,10 @@ static void cbq_ovl_delay(struct cbq_class *cl) | |||
517 | struct cbq_sched_data *q = qdisc_priv(cl->qdisc); | 521 | struct cbq_sched_data *q = qdisc_priv(cl->qdisc); |
518 | psched_tdiff_t delay = cl->undertime - q->now; | 522 | psched_tdiff_t delay = cl->undertime - q->now; |
519 | 523 | ||
524 | if (test_bit(__QDISC_STATE_DEACTIVATED, | ||
525 | &qdisc_root_sleeping(cl->qdisc)->state)) | ||
526 | return; | ||
527 | |||
520 | if (!cl->delayed) { | 528 | if (!cl->delayed) { |
521 | psched_time_t sched = q->now; | 529 | psched_time_t sched = q->now; |
522 | ktime_t expires; | 530 | ktime_t expires; |
@@ -650,7 +658,7 @@ static enum hrtimer_restart cbq_undelay(struct hrtimer *timer) | |||
650 | } | 658 | } |
651 | 659 | ||
652 | sch->flags &= ~TCQ_F_THROTTLED; | 660 | sch->flags &= ~TCQ_F_THROTTLED; |
653 | __netif_schedule(sch); | 661 | __netif_schedule(qdisc_root(sch)); |
654 | return HRTIMER_NORESTART; | 662 | return HRTIMER_NORESTART; |
655 | } | 663 | } |
656 | 664 | ||
@@ -664,13 +672,15 @@ static int cbq_reshape_fail(struct sk_buff *skb, struct Qdisc *child) | |||
664 | q->rx_class = NULL; | 672 | q->rx_class = NULL; |
665 | 673 | ||
666 | if (cl && (cl = cbq_reclassify(skb, cl)) != NULL) { | 674 | if (cl && (cl = cbq_reclassify(skb, cl)) != NULL) { |
675 | int ret; | ||
667 | 676 | ||
668 | cbq_mark_toplevel(q, cl); | 677 | cbq_mark_toplevel(q, cl); |
669 | 678 | ||
670 | q->rx_class = cl; | 679 | q->rx_class = cl; |
671 | cl->q->__parent = sch; | 680 | cl->q->__parent = sch; |
672 | 681 | ||
673 | if (qdisc_enqueue(skb, cl->q) == 0) { | 682 | ret = qdisc_enqueue(skb, cl->q); |
683 | if (ret == NET_XMIT_SUCCESS) { | ||
674 | sch->q.qlen++; | 684 | sch->q.qlen++; |
675 | sch->bstats.packets++; | 685 | sch->bstats.packets++; |
676 | sch->bstats.bytes += qdisc_pkt_len(skb); | 686 | sch->bstats.bytes += qdisc_pkt_len(skb); |
@@ -678,7 +688,8 @@ static int cbq_reshape_fail(struct sk_buff *skb, struct Qdisc *child) | |||
678 | cbq_activate_class(cl); | 688 | cbq_activate_class(cl); |
679 | return 0; | 689 | return 0; |
680 | } | 690 | } |
681 | sch->qstats.drops++; | 691 | if (net_xmit_drop_count(ret)) |
692 | sch->qstats.drops++; | ||
682 | return 0; | 693 | return 0; |
683 | } | 694 | } |
684 | 695 | ||
@@ -1743,7 +1754,7 @@ static void cbq_put(struct Qdisc *sch, unsigned long arg) | |||
1743 | 1754 | ||
1744 | if (--cl->refcnt == 0) { | 1755 | if (--cl->refcnt == 0) { |
1745 | #ifdef CONFIG_NET_CLS_ACT | 1756 | #ifdef CONFIG_NET_CLS_ACT |
1746 | spinlock_t *root_lock = qdisc_root_lock(sch); | 1757 | spinlock_t *root_lock = qdisc_root_sleeping_lock(sch); |
1747 | struct cbq_sched_data *q = qdisc_priv(sch); | 1758 | struct cbq_sched_data *q = qdisc_priv(sch); |
1748 | 1759 | ||
1749 | spin_lock_bh(root_lock); | 1760 | spin_lock_bh(root_lock); |
@@ -1828,7 +1839,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t | |||
1828 | 1839 | ||
1829 | if (tca[TCA_RATE]) | 1840 | if (tca[TCA_RATE]) |
1830 | gen_replace_estimator(&cl->bstats, &cl->rate_est, | 1841 | gen_replace_estimator(&cl->bstats, &cl->rate_est, |
1831 | qdisc_root_lock(sch), | 1842 | qdisc_root_sleeping_lock(sch), |
1832 | tca[TCA_RATE]); | 1843 | tca[TCA_RATE]); |
1833 | return 0; | 1844 | return 0; |
1834 | } | 1845 | } |
@@ -1919,7 +1930,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t | |||
1919 | 1930 | ||
1920 | if (tca[TCA_RATE]) | 1931 | if (tca[TCA_RATE]) |
1921 | gen_new_estimator(&cl->bstats, &cl->rate_est, | 1932 | gen_new_estimator(&cl->bstats, &cl->rate_est, |
1922 | qdisc_root_lock(sch), tca[TCA_RATE]); | 1933 | qdisc_root_sleeping_lock(sch), tca[TCA_RATE]); |
1923 | 1934 | ||
1924 | *arg = (unsigned long)cl; | 1935 | *arg = (unsigned long)cl; |
1925 | return 0; | 1936 | return 0; |
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c index a935676987e2..edd1298f85f6 100644 --- a/net/sched/sch_dsmark.c +++ b/net/sched/sch_dsmark.c | |||
@@ -236,7 +236,7 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
236 | case TC_ACT_QUEUED: | 236 | case TC_ACT_QUEUED: |
237 | case TC_ACT_STOLEN: | 237 | case TC_ACT_STOLEN: |
238 | kfree_skb(skb); | 238 | kfree_skb(skb); |
239 | return NET_XMIT_SUCCESS; | 239 | return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
240 | 240 | ||
241 | case TC_ACT_SHOT: | 241 | case TC_ACT_SHOT: |
242 | goto drop; | 242 | goto drop; |
@@ -254,7 +254,8 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
254 | 254 | ||
255 | err = qdisc_enqueue(skb, p->q); | 255 | err = qdisc_enqueue(skb, p->q); |
256 | if (err != NET_XMIT_SUCCESS) { | 256 | if (err != NET_XMIT_SUCCESS) { |
257 | sch->qstats.drops++; | 257 | if (net_xmit_drop_count(err)) |
258 | sch->qstats.drops++; | ||
258 | return err; | 259 | return err; |
259 | } | 260 | } |
260 | 261 | ||
@@ -267,7 +268,7 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
267 | drop: | 268 | drop: |
268 | kfree_skb(skb); | 269 | kfree_skb(skb); |
269 | sch->qstats.drops++; | 270 | sch->qstats.drops++; |
270 | return NET_XMIT_BYPASS; | 271 | return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
271 | } | 272 | } |
272 | 273 | ||
273 | static struct sk_buff *dsmark_dequeue(struct Qdisc *sch) | 274 | static struct sk_buff *dsmark_dequeue(struct Qdisc *sch) |
@@ -321,7 +322,8 @@ static int dsmark_requeue(struct sk_buff *skb, struct Qdisc *sch) | |||
321 | 322 | ||
322 | err = p->q->ops->requeue(skb, p->q); | 323 | err = p->q->ops->requeue(skb, p->q); |
323 | if (err != NET_XMIT_SUCCESS) { | 324 | if (err != NET_XMIT_SUCCESS) { |
324 | sch->qstats.drops++; | 325 | if (net_xmit_drop_count(err)) |
326 | sch->qstats.drops++; | ||
325 | return err; | 327 | return err; |
326 | } | 328 | } |
327 | 329 | ||
diff --git a/net/sched/sch_generic.c b/net/sched/sch_generic.c index fd2a6cadb115..9634091ee2f0 100644 --- a/net/sched/sch_generic.c +++ b/net/sched/sch_generic.c | |||
@@ -29,7 +29,7 @@ | |||
29 | /* Main transmission queue. */ | 29 | /* Main transmission queue. */ |
30 | 30 | ||
31 | /* Modifications to data participating in scheduling must be protected with | 31 | /* Modifications to data participating in scheduling must be protected with |
32 | * qdisc_root_lock(qdisc) spinlock. | 32 | * qdisc_lock(qdisc) spinlock. |
33 | * | 33 | * |
34 | * The idea is the following: | 34 | * The idea is the following: |
35 | * - enqueue, dequeue are serialized via qdisc root lock | 35 | * - enqueue, dequeue are serialized via qdisc root lock |
@@ -126,7 +126,7 @@ static inline int qdisc_restart(struct Qdisc *q) | |||
126 | if (unlikely((skb = dequeue_skb(q)) == NULL)) | 126 | if (unlikely((skb = dequeue_skb(q)) == NULL)) |
127 | return 0; | 127 | return 0; |
128 | 128 | ||
129 | root_lock = qdisc_root_lock(q); | 129 | root_lock = qdisc_lock(q); |
130 | 130 | ||
131 | /* And release qdisc */ | 131 | /* And release qdisc */ |
132 | spin_unlock(root_lock); | 132 | spin_unlock(root_lock); |
@@ -135,7 +135,8 @@ static inline int qdisc_restart(struct Qdisc *q) | |||
135 | txq = netdev_get_tx_queue(dev, skb_get_queue_mapping(skb)); | 135 | txq = netdev_get_tx_queue(dev, skb_get_queue_mapping(skb)); |
136 | 136 | ||
137 | HARD_TX_LOCK(dev, txq, smp_processor_id()); | 137 | HARD_TX_LOCK(dev, txq, smp_processor_id()); |
138 | if (!netif_subqueue_stopped(dev, skb)) | 138 | if (!netif_tx_queue_stopped(txq) && |
139 | !netif_tx_queue_frozen(txq)) | ||
139 | ret = dev_hard_start_xmit(skb, dev, txq); | 140 | ret = dev_hard_start_xmit(skb, dev, txq); |
140 | HARD_TX_UNLOCK(dev, txq); | 141 | HARD_TX_UNLOCK(dev, txq); |
141 | 142 | ||
@@ -162,7 +163,8 @@ static inline int qdisc_restart(struct Qdisc *q) | |||
162 | break; | 163 | break; |
163 | } | 164 | } |
164 | 165 | ||
165 | if (ret && netif_tx_queue_stopped(txq)) | 166 | if (ret && (netif_tx_queue_stopped(txq) || |
167 | netif_tx_queue_frozen(txq))) | ||
166 | ret = 0; | 168 | ret = 0; |
167 | 169 | ||
168 | return ret; | 170 | return ret; |
@@ -505,7 +507,7 @@ errout: | |||
505 | } | 507 | } |
506 | EXPORT_SYMBOL(qdisc_create_dflt); | 508 | EXPORT_SYMBOL(qdisc_create_dflt); |
507 | 509 | ||
508 | /* Under qdisc_root_lock(qdisc) and BH! */ | 510 | /* Under qdisc_lock(qdisc) and BH! */ |
509 | 511 | ||
510 | void qdisc_reset(struct Qdisc *qdisc) | 512 | void qdisc_reset(struct Qdisc *qdisc) |
511 | { | 513 | { |
@@ -516,15 +518,17 @@ void qdisc_reset(struct Qdisc *qdisc) | |||
516 | } | 518 | } |
517 | EXPORT_SYMBOL(qdisc_reset); | 519 | EXPORT_SYMBOL(qdisc_reset); |
518 | 520 | ||
519 | /* this is the rcu callback function to clean up a qdisc when there | 521 | void qdisc_destroy(struct Qdisc *qdisc) |
520 | * are no further references to it */ | ||
521 | |||
522 | static void __qdisc_destroy(struct rcu_head *head) | ||
523 | { | 522 | { |
524 | struct Qdisc *qdisc = container_of(head, struct Qdisc, q_rcu); | ||
525 | const struct Qdisc_ops *ops = qdisc->ops; | 523 | const struct Qdisc_ops *ops = qdisc->ops; |
526 | 524 | ||
525 | if (qdisc->flags & TCQ_F_BUILTIN || | ||
526 | !atomic_dec_and_test(&qdisc->refcnt)) | ||
527 | return; | ||
528 | |||
527 | #ifdef CONFIG_NET_SCHED | 529 | #ifdef CONFIG_NET_SCHED |
530 | qdisc_list_del(qdisc); | ||
531 | |||
528 | qdisc_put_stab(qdisc->stab); | 532 | qdisc_put_stab(qdisc->stab); |
529 | #endif | 533 | #endif |
530 | gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est); | 534 | gen_kill_estimator(&qdisc->bstats, &qdisc->rate_est); |
@@ -540,20 +544,6 @@ static void __qdisc_destroy(struct rcu_head *head) | |||
540 | 544 | ||
541 | kfree((char *) qdisc - qdisc->padded); | 545 | kfree((char *) qdisc - qdisc->padded); |
542 | } | 546 | } |
543 | |||
544 | /* Under qdisc_root_lock(qdisc) and BH! */ | ||
545 | |||
546 | void qdisc_destroy(struct Qdisc *qdisc) | ||
547 | { | ||
548 | if (qdisc->flags & TCQ_F_BUILTIN || | ||
549 | !atomic_dec_and_test(&qdisc->refcnt)) | ||
550 | return; | ||
551 | |||
552 | if (qdisc->parent) | ||
553 | list_del(&qdisc->list); | ||
554 | |||
555 | call_rcu(&qdisc->q_rcu, __qdisc_destroy); | ||
556 | } | ||
557 | EXPORT_SYMBOL(qdisc_destroy); | 547 | EXPORT_SYMBOL(qdisc_destroy); |
558 | 548 | ||
559 | static bool dev_all_qdisc_sleeping_noop(struct net_device *dev) | 549 | static bool dev_all_qdisc_sleeping_noop(struct net_device *dev) |
@@ -595,8 +585,11 @@ static void transition_one_qdisc(struct net_device *dev, | |||
595 | struct Qdisc *new_qdisc = dev_queue->qdisc_sleeping; | 585 | struct Qdisc *new_qdisc = dev_queue->qdisc_sleeping; |
596 | int *need_watchdog_p = _need_watchdog; | 586 | int *need_watchdog_p = _need_watchdog; |
597 | 587 | ||
588 | if (!(new_qdisc->flags & TCQ_F_BUILTIN)) | ||
589 | clear_bit(__QDISC_STATE_DEACTIVATED, &new_qdisc->state); | ||
590 | |||
598 | rcu_assign_pointer(dev_queue->qdisc, new_qdisc); | 591 | rcu_assign_pointer(dev_queue->qdisc, new_qdisc); |
599 | if (new_qdisc != &noqueue_qdisc) | 592 | if (need_watchdog_p && new_qdisc != &noqueue_qdisc) |
600 | *need_watchdog_p = 1; | 593 | *need_watchdog_p = 1; |
601 | } | 594 | } |
602 | 595 | ||
@@ -619,6 +612,7 @@ void dev_activate(struct net_device *dev) | |||
619 | 612 | ||
620 | need_watchdog = 0; | 613 | need_watchdog = 0; |
621 | netdev_for_each_tx_queue(dev, transition_one_qdisc, &need_watchdog); | 614 | netdev_for_each_tx_queue(dev, transition_one_qdisc, &need_watchdog); |
615 | transition_one_qdisc(dev, &dev->rx_queue, NULL); | ||
622 | 616 | ||
623 | if (need_watchdog) { | 617 | if (need_watchdog) { |
624 | dev->trans_start = jiffies; | 618 | dev->trans_start = jiffies; |
@@ -637,14 +631,17 @@ static void dev_deactivate_queue(struct net_device *dev, | |||
637 | if (qdisc) { | 631 | if (qdisc) { |
638 | spin_lock_bh(qdisc_lock(qdisc)); | 632 | spin_lock_bh(qdisc_lock(qdisc)); |
639 | 633 | ||
640 | dev_queue->qdisc = qdisc_default; | 634 | if (!(qdisc->flags & TCQ_F_BUILTIN)) |
635 | set_bit(__QDISC_STATE_DEACTIVATED, &qdisc->state); | ||
636 | |||
637 | rcu_assign_pointer(dev_queue->qdisc, qdisc_default); | ||
641 | qdisc_reset(qdisc); | 638 | qdisc_reset(qdisc); |
642 | 639 | ||
643 | spin_unlock_bh(qdisc_lock(qdisc)); | 640 | spin_unlock_bh(qdisc_lock(qdisc)); |
644 | } | 641 | } |
645 | } | 642 | } |
646 | 643 | ||
647 | static bool some_qdisc_is_running(struct net_device *dev, int lock) | 644 | static bool some_qdisc_is_busy(struct net_device *dev) |
648 | { | 645 | { |
649 | unsigned int i; | 646 | unsigned int i; |
650 | 647 | ||
@@ -655,16 +652,15 @@ static bool some_qdisc_is_running(struct net_device *dev, int lock) | |||
655 | int val; | 652 | int val; |
656 | 653 | ||
657 | dev_queue = netdev_get_tx_queue(dev, i); | 654 | dev_queue = netdev_get_tx_queue(dev, i); |
658 | q = dev_queue->qdisc; | 655 | q = dev_queue->qdisc_sleeping; |
659 | root_lock = qdisc_root_lock(q); | 656 | root_lock = qdisc_lock(q); |
660 | 657 | ||
661 | if (lock) | 658 | spin_lock_bh(root_lock); |
662 | spin_lock_bh(root_lock); | ||
663 | 659 | ||
664 | val = test_bit(__QDISC_STATE_RUNNING, &q->state); | 660 | val = (test_bit(__QDISC_STATE_RUNNING, &q->state) || |
661 | test_bit(__QDISC_STATE_SCHED, &q->state)); | ||
665 | 662 | ||
666 | if (lock) | 663 | spin_unlock_bh(root_lock); |
667 | spin_unlock_bh(root_lock); | ||
668 | 664 | ||
669 | if (val) | 665 | if (val) |
670 | return true; | 666 | return true; |
@@ -674,9 +670,8 @@ static bool some_qdisc_is_running(struct net_device *dev, int lock) | |||
674 | 670 | ||
675 | void dev_deactivate(struct net_device *dev) | 671 | void dev_deactivate(struct net_device *dev) |
676 | { | 672 | { |
677 | bool running; | ||
678 | |||
679 | netdev_for_each_tx_queue(dev, dev_deactivate_queue, &noop_qdisc); | 673 | netdev_for_each_tx_queue(dev, dev_deactivate_queue, &noop_qdisc); |
674 | dev_deactivate_queue(dev, &dev->rx_queue, &noop_qdisc); | ||
680 | 675 | ||
681 | dev_watchdog_down(dev); | 676 | dev_watchdog_down(dev); |
682 | 677 | ||
@@ -684,25 +679,8 @@ void dev_deactivate(struct net_device *dev) | |||
684 | synchronize_rcu(); | 679 | synchronize_rcu(); |
685 | 680 | ||
686 | /* Wait for outstanding qdisc_run calls. */ | 681 | /* Wait for outstanding qdisc_run calls. */ |
687 | do { | 682 | while (some_qdisc_is_busy(dev)) |
688 | while (some_qdisc_is_running(dev, 0)) | 683 | yield(); |
689 | yield(); | ||
690 | |||
691 | /* | ||
692 | * Double-check inside queue lock to ensure that all effects | ||
693 | * of the queue run are visible when we return. | ||
694 | */ | ||
695 | running = some_qdisc_is_running(dev, 1); | ||
696 | |||
697 | /* | ||
698 | * The running flag should never be set at this point because | ||
699 | * we've already set dev->qdisc to noop_qdisc *inside* the same | ||
700 | * pair of spin locks. That is, if any qdisc_run starts after | ||
701 | * our initial test it should see the noop_qdisc and then | ||
702 | * clear the RUNNING bit before dropping the queue lock. So | ||
703 | * if it is set here then we've found a bug. | ||
704 | */ | ||
705 | } while (WARN_ON_ONCE(running)); | ||
706 | } | 684 | } |
707 | 685 | ||
708 | static void dev_init_scheduler_queue(struct net_device *dev, | 686 | static void dev_init_scheduler_queue(struct net_device *dev, |
@@ -718,7 +696,7 @@ static void dev_init_scheduler_queue(struct net_device *dev, | |||
718 | void dev_init_scheduler(struct net_device *dev) | 696 | void dev_init_scheduler(struct net_device *dev) |
719 | { | 697 | { |
720 | netdev_for_each_tx_queue(dev, dev_init_scheduler_queue, &noop_qdisc); | 698 | netdev_for_each_tx_queue(dev, dev_init_scheduler_queue, &noop_qdisc); |
721 | dev_init_scheduler_queue(dev, &dev->rx_queue, NULL); | 699 | dev_init_scheduler_queue(dev, &dev->rx_queue, &noop_qdisc); |
722 | 700 | ||
723 | setup_timer(&dev->watchdog_timer, dev_watchdog, (unsigned long)dev); | 701 | setup_timer(&dev->watchdog_timer, dev_watchdog, (unsigned long)dev); |
724 | } | 702 | } |
@@ -731,20 +709,16 @@ static void shutdown_scheduler_queue(struct net_device *dev, | |||
731 | struct Qdisc *qdisc_default = _qdisc_default; | 709 | struct Qdisc *qdisc_default = _qdisc_default; |
732 | 710 | ||
733 | if (qdisc) { | 711 | if (qdisc) { |
734 | spinlock_t *root_lock = qdisc_root_lock(qdisc); | 712 | rcu_assign_pointer(dev_queue->qdisc, qdisc_default); |
735 | |||
736 | dev_queue->qdisc = qdisc_default; | ||
737 | dev_queue->qdisc_sleeping = qdisc_default; | 713 | dev_queue->qdisc_sleeping = qdisc_default; |
738 | 714 | ||
739 | spin_lock_bh(root_lock); | ||
740 | qdisc_destroy(qdisc); | 715 | qdisc_destroy(qdisc); |
741 | spin_unlock_bh(root_lock); | ||
742 | } | 716 | } |
743 | } | 717 | } |
744 | 718 | ||
745 | void dev_shutdown(struct net_device *dev) | 719 | void dev_shutdown(struct net_device *dev) |
746 | { | 720 | { |
747 | netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc); | 721 | netdev_for_each_tx_queue(dev, shutdown_scheduler_queue, &noop_qdisc); |
748 | shutdown_scheduler_queue(dev, &dev->rx_queue, NULL); | 722 | shutdown_scheduler_queue(dev, &dev->rx_queue, &noop_qdisc); |
749 | WARN_ON(timer_pending(&dev->watchdog_timer)); | 723 | WARN_ON(timer_pending(&dev->watchdog_timer)); |
750 | } | 724 | } |
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 0ae7d19dcba8..c1e77da8cd09 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c | |||
@@ -1045,7 +1045,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, | |||
1045 | 1045 | ||
1046 | if (tca[TCA_RATE]) | 1046 | if (tca[TCA_RATE]) |
1047 | gen_replace_estimator(&cl->bstats, &cl->rate_est, | 1047 | gen_replace_estimator(&cl->bstats, &cl->rate_est, |
1048 | qdisc_root_lock(sch), | 1048 | qdisc_root_sleeping_lock(sch), |
1049 | tca[TCA_RATE]); | 1049 | tca[TCA_RATE]); |
1050 | return 0; | 1050 | return 0; |
1051 | } | 1051 | } |
@@ -1104,7 +1104,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid, | |||
1104 | 1104 | ||
1105 | if (tca[TCA_RATE]) | 1105 | if (tca[TCA_RATE]) |
1106 | gen_new_estimator(&cl->bstats, &cl->rate_est, | 1106 | gen_new_estimator(&cl->bstats, &cl->rate_est, |
1107 | qdisc_root_lock(sch), tca[TCA_RATE]); | 1107 | qdisc_root_sleeping_lock(sch), tca[TCA_RATE]); |
1108 | *arg = (unsigned long)cl; | 1108 | *arg = (unsigned long)cl; |
1109 | return 0; | 1109 | return 0; |
1110 | } | 1110 | } |
@@ -1159,14 +1159,14 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) | |||
1159 | if (cl->level == 0) | 1159 | if (cl->level == 0) |
1160 | return cl; | 1160 | return cl; |
1161 | 1161 | ||
1162 | *qerr = NET_XMIT_BYPASS; | 1162 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
1163 | tcf = q->root.filter_list; | 1163 | tcf = q->root.filter_list; |
1164 | while (tcf && (result = tc_classify(skb, tcf, &res)) >= 0) { | 1164 | while (tcf && (result = tc_classify(skb, tcf, &res)) >= 0) { |
1165 | #ifdef CONFIG_NET_CLS_ACT | 1165 | #ifdef CONFIG_NET_CLS_ACT |
1166 | switch (result) { | 1166 | switch (result) { |
1167 | case TC_ACT_QUEUED: | 1167 | case TC_ACT_QUEUED: |
1168 | case TC_ACT_STOLEN: | 1168 | case TC_ACT_STOLEN: |
1169 | *qerr = NET_XMIT_SUCCESS; | 1169 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
1170 | case TC_ACT_SHOT: | 1170 | case TC_ACT_SHOT: |
1171 | return NULL; | 1171 | return NULL; |
1172 | } | 1172 | } |
@@ -1578,7 +1578,7 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
1578 | 1578 | ||
1579 | cl = hfsc_classify(skb, sch, &err); | 1579 | cl = hfsc_classify(skb, sch, &err); |
1580 | if (cl == NULL) { | 1580 | if (cl == NULL) { |
1581 | if (err == NET_XMIT_BYPASS) | 1581 | if (err & __NET_XMIT_BYPASS) |
1582 | sch->qstats.drops++; | 1582 | sch->qstats.drops++; |
1583 | kfree_skb(skb); | 1583 | kfree_skb(skb); |
1584 | return err; | 1584 | return err; |
@@ -1586,8 +1586,10 @@ hfsc_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
1586 | 1586 | ||
1587 | err = qdisc_enqueue(skb, cl->qdisc); | 1587 | err = qdisc_enqueue(skb, cl->qdisc); |
1588 | if (unlikely(err != NET_XMIT_SUCCESS)) { | 1588 | if (unlikely(err != NET_XMIT_SUCCESS)) { |
1589 | cl->qstats.drops++; | 1589 | if (net_xmit_drop_count(err)) { |
1590 | sch->qstats.drops++; | 1590 | cl->qstats.drops++; |
1591 | sch->qstats.drops++; | ||
1592 | } | ||
1591 | return err; | 1593 | return err; |
1592 | } | 1594 | } |
1593 | 1595 | ||
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c index 75a40951c4f2..d14f02056ae6 100644 --- a/net/sched/sch_htb.c +++ b/net/sched/sch_htb.c | |||
@@ -214,14 +214,14 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch, | |||
214 | if ((cl = htb_find(skb->priority, sch)) != NULL && cl->level == 0) | 214 | if ((cl = htb_find(skb->priority, sch)) != NULL && cl->level == 0) |
215 | return cl; | 215 | return cl; |
216 | 216 | ||
217 | *qerr = NET_XMIT_BYPASS; | 217 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
218 | tcf = q->filter_list; | 218 | tcf = q->filter_list; |
219 | while (tcf && (result = tc_classify(skb, tcf, &res)) >= 0) { | 219 | while (tcf && (result = tc_classify(skb, tcf, &res)) >= 0) { |
220 | #ifdef CONFIG_NET_CLS_ACT | 220 | #ifdef CONFIG_NET_CLS_ACT |
221 | switch (result) { | 221 | switch (result) { |
222 | case TC_ACT_QUEUED: | 222 | case TC_ACT_QUEUED: |
223 | case TC_ACT_STOLEN: | 223 | case TC_ACT_STOLEN: |
224 | *qerr = NET_XMIT_SUCCESS; | 224 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
225 | case TC_ACT_SHOT: | 225 | case TC_ACT_SHOT: |
226 | return NULL; | 226 | return NULL; |
227 | } | 227 | } |
@@ -567,15 +567,17 @@ static int htb_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
567 | } | 567 | } |
568 | #ifdef CONFIG_NET_CLS_ACT | 568 | #ifdef CONFIG_NET_CLS_ACT |
569 | } else if (!cl) { | 569 | } else if (!cl) { |
570 | if (ret == NET_XMIT_BYPASS) | 570 | if (ret & __NET_XMIT_BYPASS) |
571 | sch->qstats.drops++; | 571 | sch->qstats.drops++; |
572 | kfree_skb(skb); | 572 | kfree_skb(skb); |
573 | return ret; | 573 | return ret; |
574 | #endif | 574 | #endif |
575 | } else if (qdisc_enqueue(skb, cl->un.leaf.q) != NET_XMIT_SUCCESS) { | 575 | } else if ((ret = qdisc_enqueue(skb, cl->un.leaf.q)) != NET_XMIT_SUCCESS) { |
576 | sch->qstats.drops++; | 576 | if (net_xmit_drop_count(ret)) { |
577 | cl->qstats.drops++; | 577 | sch->qstats.drops++; |
578 | return NET_XMIT_DROP; | 578 | cl->qstats.drops++; |
579 | } | ||
580 | return ret; | ||
579 | } else { | 581 | } else { |
580 | cl->bstats.packets += | 582 | cl->bstats.packets += |
581 | skb_is_gso(skb)?skb_shinfo(skb)->gso_segs:1; | 583 | skb_is_gso(skb)?skb_shinfo(skb)->gso_segs:1; |
@@ -610,16 +612,18 @@ static int htb_requeue(struct sk_buff *skb, struct Qdisc *sch) | |||
610 | } | 612 | } |
611 | #ifdef CONFIG_NET_CLS_ACT | 613 | #ifdef CONFIG_NET_CLS_ACT |
612 | } else if (!cl) { | 614 | } else if (!cl) { |
613 | if (ret == NET_XMIT_BYPASS) | 615 | if (ret & __NET_XMIT_BYPASS) |
614 | sch->qstats.drops++; | 616 | sch->qstats.drops++; |
615 | kfree_skb(skb); | 617 | kfree_skb(skb); |
616 | return ret; | 618 | return ret; |
617 | #endif | 619 | #endif |
618 | } else if (cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q) != | 620 | } else if ((ret = cl->un.leaf.q->ops->requeue(skb, cl->un.leaf.q)) != |
619 | NET_XMIT_SUCCESS) { | 621 | NET_XMIT_SUCCESS) { |
620 | sch->qstats.drops++; | 622 | if (net_xmit_drop_count(ret)) { |
621 | cl->qstats.drops++; | 623 | sch->qstats.drops++; |
622 | return NET_XMIT_DROP; | 624 | cl->qstats.drops++; |
625 | } | ||
626 | return ret; | ||
623 | } else | 627 | } else |
624 | htb_activate(q, cl); | 628 | htb_activate(q, cl); |
625 | 629 | ||
@@ -1039,7 +1043,7 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt) | |||
1039 | 1043 | ||
1040 | static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) | 1044 | static int htb_dump(struct Qdisc *sch, struct sk_buff *skb) |
1041 | { | 1045 | { |
1042 | spinlock_t *root_lock = qdisc_root_lock(sch); | 1046 | spinlock_t *root_lock = qdisc_root_sleeping_lock(sch); |
1043 | struct htb_sched *q = qdisc_priv(sch); | 1047 | struct htb_sched *q = qdisc_priv(sch); |
1044 | struct nlattr *nest; | 1048 | struct nlattr *nest; |
1045 | struct tc_htb_glob gopt; | 1049 | struct tc_htb_glob gopt; |
@@ -1071,7 +1075,7 @@ static int htb_dump_class(struct Qdisc *sch, unsigned long arg, | |||
1071 | struct sk_buff *skb, struct tcmsg *tcm) | 1075 | struct sk_buff *skb, struct tcmsg *tcm) |
1072 | { | 1076 | { |
1073 | struct htb_class *cl = (struct htb_class *)arg; | 1077 | struct htb_class *cl = (struct htb_class *)arg; |
1074 | spinlock_t *root_lock = qdisc_root_lock(sch); | 1078 | spinlock_t *root_lock = qdisc_root_sleeping_lock(sch); |
1075 | struct nlattr *nest; | 1079 | struct nlattr *nest; |
1076 | struct tc_htb_opt opt; | 1080 | struct tc_htb_opt opt; |
1077 | 1081 | ||
@@ -1275,7 +1279,8 @@ static int htb_delete(struct Qdisc *sch, unsigned long arg) | |||
1275 | 1279 | ||
1276 | /* delete from hash and active; remainder in destroy_class */ | 1280 | /* delete from hash and active; remainder in destroy_class */ |
1277 | qdisc_class_hash_remove(&q->clhash, &cl->common); | 1281 | qdisc_class_hash_remove(&q->clhash, &cl->common); |
1278 | cl->parent->children--; | 1282 | if (cl->parent) |
1283 | cl->parent->children--; | ||
1279 | 1284 | ||
1280 | if (cl->prio_activity) | 1285 | if (cl->prio_activity) |
1281 | htb_deactivate(q, cl); | 1286 | htb_deactivate(q, cl); |
@@ -1367,7 +1372,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1367 | goto failure; | 1372 | goto failure; |
1368 | 1373 | ||
1369 | gen_new_estimator(&cl->bstats, &cl->rate_est, | 1374 | gen_new_estimator(&cl->bstats, &cl->rate_est, |
1370 | qdisc_root_lock(sch), | 1375 | qdisc_root_sleeping_lock(sch), |
1371 | tca[TCA_RATE] ? : &est.nla); | 1376 | tca[TCA_RATE] ? : &est.nla); |
1372 | cl->refcnt = 1; | 1377 | cl->refcnt = 1; |
1373 | cl->children = 0; | 1378 | cl->children = 0; |
@@ -1422,7 +1427,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid, | |||
1422 | } else { | 1427 | } else { |
1423 | if (tca[TCA_RATE]) | 1428 | if (tca[TCA_RATE]) |
1424 | gen_replace_estimator(&cl->bstats, &cl->rate_est, | 1429 | gen_replace_estimator(&cl->bstats, &cl->rate_est, |
1425 | qdisc_root_lock(sch), | 1430 | qdisc_root_sleeping_lock(sch), |
1426 | tca[TCA_RATE]); | 1431 | tca[TCA_RATE]); |
1427 | sch_tree_lock(sch); | 1432 | sch_tree_lock(sch); |
1428 | } | 1433 | } |
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index a59085700678..3781e55046d0 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c | |||
@@ -176,7 +176,7 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
176 | if (count == 0) { | 176 | if (count == 0) { |
177 | sch->qstats.drops++; | 177 | sch->qstats.drops++; |
178 | kfree_skb(skb); | 178 | kfree_skb(skb); |
179 | return NET_XMIT_BYPASS; | 179 | return NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
180 | } | 180 | } |
181 | 181 | ||
182 | skb_orphan(skb); | 182 | skb_orphan(skb); |
@@ -240,8 +240,9 @@ static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
240 | sch->q.qlen++; | 240 | sch->q.qlen++; |
241 | sch->bstats.bytes += qdisc_pkt_len(skb); | 241 | sch->bstats.bytes += qdisc_pkt_len(skb); |
242 | sch->bstats.packets++; | 242 | sch->bstats.packets++; |
243 | } else | 243 | } else if (net_xmit_drop_count(ret)) { |
244 | sch->qstats.drops++; | 244 | sch->qstats.drops++; |
245 | } | ||
245 | 246 | ||
246 | pr_debug("netem: enqueue ret %d\n", ret); | 247 | pr_debug("netem: enqueue ret %d\n", ret); |
247 | return ret; | 248 | return ret; |
@@ -340,7 +341,7 @@ static int get_dist_table(struct Qdisc *sch, const struct nlattr *attr) | |||
340 | for (i = 0; i < n; i++) | 341 | for (i = 0; i < n; i++) |
341 | d->table[i] = data[i]; | 342 | d->table[i] = data[i]; |
342 | 343 | ||
343 | root_lock = qdisc_root_lock(sch); | 344 | root_lock = qdisc_root_sleeping_lock(sch); |
344 | 345 | ||
345 | spin_lock_bh(root_lock); | 346 | spin_lock_bh(root_lock); |
346 | d = xchg(&q->delay_dist, d); | 347 | d = xchg(&q->delay_dist, d); |
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c index f849243eb095..a6697c686c7f 100644 --- a/net/sched/sch_prio.c +++ b/net/sched/sch_prio.c | |||
@@ -38,14 +38,14 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) | |||
38 | struct tcf_result res; | 38 | struct tcf_result res; |
39 | int err; | 39 | int err; |
40 | 40 | ||
41 | *qerr = NET_XMIT_BYPASS; | 41 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
42 | if (TC_H_MAJ(skb->priority) != sch->handle) { | 42 | if (TC_H_MAJ(skb->priority) != sch->handle) { |
43 | err = tc_classify(skb, q->filter_list, &res); | 43 | err = tc_classify(skb, q->filter_list, &res); |
44 | #ifdef CONFIG_NET_CLS_ACT | 44 | #ifdef CONFIG_NET_CLS_ACT |
45 | switch (err) { | 45 | switch (err) { |
46 | case TC_ACT_STOLEN: | 46 | case TC_ACT_STOLEN: |
47 | case TC_ACT_QUEUED: | 47 | case TC_ACT_QUEUED: |
48 | *qerr = NET_XMIT_SUCCESS; | 48 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
49 | case TC_ACT_SHOT: | 49 | case TC_ACT_SHOT: |
50 | return NULL; | 50 | return NULL; |
51 | } | 51 | } |
@@ -74,7 +74,7 @@ prio_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
74 | #ifdef CONFIG_NET_CLS_ACT | 74 | #ifdef CONFIG_NET_CLS_ACT |
75 | if (qdisc == NULL) { | 75 | if (qdisc == NULL) { |
76 | 76 | ||
77 | if (ret == NET_XMIT_BYPASS) | 77 | if (ret & __NET_XMIT_BYPASS) |
78 | sch->qstats.drops++; | 78 | sch->qstats.drops++; |
79 | kfree_skb(skb); | 79 | kfree_skb(skb); |
80 | return ret; | 80 | return ret; |
@@ -88,7 +88,8 @@ prio_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
88 | sch->q.qlen++; | 88 | sch->q.qlen++; |
89 | return NET_XMIT_SUCCESS; | 89 | return NET_XMIT_SUCCESS; |
90 | } | 90 | } |
91 | sch->qstats.drops++; | 91 | if (net_xmit_drop_count(ret)) |
92 | sch->qstats.drops++; | ||
92 | return ret; | 93 | return ret; |
93 | } | 94 | } |
94 | 95 | ||
@@ -102,7 +103,7 @@ prio_requeue(struct sk_buff *skb, struct Qdisc* sch) | |||
102 | qdisc = prio_classify(skb, sch, &ret); | 103 | qdisc = prio_classify(skb, sch, &ret); |
103 | #ifdef CONFIG_NET_CLS_ACT | 104 | #ifdef CONFIG_NET_CLS_ACT |
104 | if (qdisc == NULL) { | 105 | if (qdisc == NULL) { |
105 | if (ret == NET_XMIT_BYPASS) | 106 | if (ret & __NET_XMIT_BYPASS) |
106 | sch->qstats.drops++; | 107 | sch->qstats.drops++; |
107 | kfree_skb(skb); | 108 | kfree_skb(skb); |
108 | return ret; | 109 | return ret; |
@@ -112,10 +113,11 @@ prio_requeue(struct sk_buff *skb, struct Qdisc* sch) | |||
112 | if ((ret = qdisc->ops->requeue(skb, qdisc)) == NET_XMIT_SUCCESS) { | 113 | if ((ret = qdisc->ops->requeue(skb, qdisc)) == NET_XMIT_SUCCESS) { |
113 | sch->q.qlen++; | 114 | sch->q.qlen++; |
114 | sch->qstats.requeues++; | 115 | sch->qstats.requeues++; |
115 | return 0; | 116 | return NET_XMIT_SUCCESS; |
116 | } | 117 | } |
117 | sch->qstats.drops++; | 118 | if (net_xmit_drop_count(ret)) |
118 | return NET_XMIT_DROP; | 119 | sch->qstats.drops++; |
120 | return ret; | ||
119 | } | 121 | } |
120 | 122 | ||
121 | 123 | ||
diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c index 3f2d1d7f3bbd..5da05839e225 100644 --- a/net/sched/sch_red.c +++ b/net/sched/sch_red.c | |||
@@ -97,7 +97,7 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc* sch) | |||
97 | sch->bstats.bytes += qdisc_pkt_len(skb); | 97 | sch->bstats.bytes += qdisc_pkt_len(skb); |
98 | sch->bstats.packets++; | 98 | sch->bstats.packets++; |
99 | sch->q.qlen++; | 99 | sch->q.qlen++; |
100 | } else { | 100 | } else if (net_xmit_drop_count(ret)) { |
101 | q->stats.pdrop++; | 101 | q->stats.pdrop++; |
102 | sch->qstats.drops++; | 102 | sch->qstats.drops++; |
103 | } | 103 | } |
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c index 8589da666568..6e041d10dbdb 100644 --- a/net/sched/sch_sfq.c +++ b/net/sched/sch_sfq.c | |||
@@ -171,14 +171,14 @@ static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch, | |||
171 | if (!q->filter_list) | 171 | if (!q->filter_list) |
172 | return sfq_hash(q, skb) + 1; | 172 | return sfq_hash(q, skb) + 1; |
173 | 173 | ||
174 | *qerr = NET_XMIT_BYPASS; | 174 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS; |
175 | result = tc_classify(skb, q->filter_list, &res); | 175 | result = tc_classify(skb, q->filter_list, &res); |
176 | if (result >= 0) { | 176 | if (result >= 0) { |
177 | #ifdef CONFIG_NET_CLS_ACT | 177 | #ifdef CONFIG_NET_CLS_ACT |
178 | switch (result) { | 178 | switch (result) { |
179 | case TC_ACT_STOLEN: | 179 | case TC_ACT_STOLEN: |
180 | case TC_ACT_QUEUED: | 180 | case TC_ACT_QUEUED: |
181 | *qerr = NET_XMIT_SUCCESS; | 181 | *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; |
182 | case TC_ACT_SHOT: | 182 | case TC_ACT_SHOT: |
183 | return 0; | 183 | return 0; |
184 | } | 184 | } |
@@ -285,7 +285,7 @@ sfq_enqueue(struct sk_buff *skb, struct Qdisc *sch) | |||
285 | 285 | ||
286 | hash = sfq_classify(skb, sch, &ret); | 286 | hash = sfq_classify(skb, sch, &ret); |
287 | if (hash == 0) { | 287 | if (hash == 0) { |
288 | if (ret == NET_XMIT_BYPASS) | 288 | if (ret & __NET_XMIT_BYPASS) |
289 | sch->qstats.drops++; | 289 | sch->qstats.drops++; |
290 | kfree_skb(skb); | 290 | kfree_skb(skb); |
291 | return ret; | 291 | return ret; |
@@ -339,7 +339,7 @@ sfq_requeue(struct sk_buff *skb, struct Qdisc *sch) | |||
339 | 339 | ||
340 | hash = sfq_classify(skb, sch, &ret); | 340 | hash = sfq_classify(skb, sch, &ret); |
341 | if (hash == 0) { | 341 | if (hash == 0) { |
342 | if (ret == NET_XMIT_BYPASS) | 342 | if (ret & __NET_XMIT_BYPASS) |
343 | sch->qstats.drops++; | 343 | sch->qstats.drops++; |
344 | kfree_skb(skb); | 344 | kfree_skb(skb); |
345 | return ret; | 345 | return ret; |
diff --git a/net/sched/sch_tbf.c b/net/sched/sch_tbf.c index b296672f7632..94c61598b86a 100644 --- a/net/sched/sch_tbf.c +++ b/net/sched/sch_tbf.c | |||
@@ -123,19 +123,13 @@ static int tbf_enqueue(struct sk_buff *skb, struct Qdisc* sch) | |||
123 | struct tbf_sched_data *q = qdisc_priv(sch); | 123 | struct tbf_sched_data *q = qdisc_priv(sch); |
124 | int ret; | 124 | int ret; |
125 | 125 | ||
126 | if (qdisc_pkt_len(skb) > q->max_size) { | 126 | if (qdisc_pkt_len(skb) > q->max_size) |
127 | sch->qstats.drops++; | 127 | return qdisc_reshape_fail(skb, sch); |
128 | #ifdef CONFIG_NET_CLS_ACT | ||
129 | if (sch->reshape_fail == NULL || sch->reshape_fail(skb, sch)) | ||
130 | #endif | ||
131 | kfree_skb(skb); | ||
132 | |||
133 | return NET_XMIT_DROP; | ||
134 | } | ||
135 | 128 | ||
136 | ret = qdisc_enqueue(skb, q->qdisc); | 129 | ret = qdisc_enqueue(skb, q->qdisc); |
137 | if (ret != 0) { | 130 | if (ret != 0) { |
138 | sch->qstats.drops++; | 131 | if (net_xmit_drop_count(ret)) |
132 | sch->qstats.drops++; | ||
139 | return ret; | 133 | return ret; |
140 | } | 134 | } |
141 | 135 | ||
diff --git a/net/sched/sch_teql.c b/net/sched/sch_teql.c index 537223642b6e..d35ef059abb1 100644 --- a/net/sched/sch_teql.c +++ b/net/sched/sch_teql.c | |||
@@ -161,7 +161,7 @@ teql_destroy(struct Qdisc* sch) | |||
161 | txq = netdev_get_tx_queue(master->dev, 0); | 161 | txq = netdev_get_tx_queue(master->dev, 0); |
162 | master->slaves = NULL; | 162 | master->slaves = NULL; |
163 | 163 | ||
164 | root_lock = qdisc_root_lock(txq->qdisc); | 164 | root_lock = qdisc_root_sleeping_lock(txq->qdisc); |
165 | spin_lock_bh(root_lock); | 165 | spin_lock_bh(root_lock); |
166 | qdisc_reset(txq->qdisc); | 166 | qdisc_reset(txq->qdisc); |
167 | spin_unlock_bh(root_lock); | 167 | spin_unlock_bh(root_lock); |
@@ -305,10 +305,11 @@ restart: | |||
305 | 305 | ||
306 | switch (teql_resolve(skb, skb_res, slave)) { | 306 | switch (teql_resolve(skb, skb_res, slave)) { |
307 | case 0: | 307 | case 0: |
308 | if (netif_tx_trylock(slave)) { | 308 | if (__netif_tx_trylock(slave_txq)) { |
309 | if (!__netif_subqueue_stopped(slave, subq) && | 309 | if (!netif_tx_queue_stopped(slave_txq) && |
310 | !netif_tx_queue_frozen(slave_txq) && | ||
310 | slave->hard_start_xmit(skb, slave) == 0) { | 311 | slave->hard_start_xmit(skb, slave) == 0) { |
311 | netif_tx_unlock(slave); | 312 | __netif_tx_unlock(slave_txq); |
312 | master->slaves = NEXT_SLAVE(q); | 313 | master->slaves = NEXT_SLAVE(q); |
313 | netif_wake_queue(dev); | 314 | netif_wake_queue(dev); |
314 | master->stats.tx_packets++; | 315 | master->stats.tx_packets++; |
@@ -316,7 +317,7 @@ restart: | |||
316 | qdisc_pkt_len(skb); | 317 | qdisc_pkt_len(skb); |
317 | return 0; | 318 | return 0; |
318 | } | 319 | } |
319 | netif_tx_unlock(slave); | 320 | __netif_tx_unlock(slave_txq); |
320 | } | 321 | } |
321 | if (netif_queue_stopped(dev)) | 322 | if (netif_queue_stopped(dev)) |
322 | busy = 1; | 323 | busy = 1; |
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 675a5c3e68a6..52db5f60daa0 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
@@ -80,6 +80,10 @@ static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp) | |||
80 | { | 80 | { |
81 | struct sctp_auth_bytes *key; | 81 | struct sctp_auth_bytes *key; |
82 | 82 | ||
83 | /* Verify that we are not going to overflow INT_MAX */ | ||
84 | if ((INT_MAX - key_len) < sizeof(struct sctp_auth_bytes)) | ||
85 | return NULL; | ||
86 | |||
83 | /* Allocate the shared key */ | 87 | /* Allocate the shared key */ |
84 | key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp); | 88 | key = kmalloc(sizeof(struct sctp_auth_bytes) + key_len, gfp); |
85 | if (!key) | 89 | if (!key) |
@@ -782,6 +786,9 @@ int sctp_auth_ep_set_hmacs(struct sctp_endpoint *ep, | |||
782 | for (i = 0; i < hmacs->shmac_num_idents; i++) { | 786 | for (i = 0; i < hmacs->shmac_num_idents; i++) { |
783 | id = hmacs->shmac_idents[i]; | 787 | id = hmacs->shmac_idents[i]; |
784 | 788 | ||
789 | if (id > SCTP_AUTH_HMAC_ID_MAX) | ||
790 | return -EOPNOTSUPP; | ||
791 | |||
785 | if (SCTP_AUTH_HMAC_ID_SHA1 == id) | 792 | if (SCTP_AUTH_HMAC_ID_SHA1 == id) |
786 | has_sha1 = 1; | 793 | has_sha1 = 1; |
787 | 794 | ||
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index e39a0cdef184..4c8d9f45ce09 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c | |||
@@ -103,6 +103,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
103 | 103 | ||
104 | /* Initialize the CHUNKS parameter */ | 104 | /* Initialize the CHUNKS parameter */ |
105 | auth_chunks->param_hdr.type = SCTP_PARAM_CHUNKS; | 105 | auth_chunks->param_hdr.type = SCTP_PARAM_CHUNKS; |
106 | auth_chunks->param_hdr.length = htons(sizeof(sctp_paramhdr_t)); | ||
106 | 107 | ||
107 | /* If the Add-IP functionality is enabled, we must | 108 | /* If the Add-IP functionality is enabled, we must |
108 | * authenticate, ASCONF and ASCONF-ACK chunks | 109 | * authenticate, ASCONF and ASCONF-ACK chunks |
@@ -110,8 +111,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
110 | if (sctp_addip_enable) { | 111 | if (sctp_addip_enable) { |
111 | auth_chunks->chunks[0] = SCTP_CID_ASCONF; | 112 | auth_chunks->chunks[0] = SCTP_CID_ASCONF; |
112 | auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; | 113 | auth_chunks->chunks[1] = SCTP_CID_ASCONF_ACK; |
113 | auth_chunks->param_hdr.length = | 114 | auth_chunks->param_hdr.length += htons(2); |
114 | htons(sizeof(sctp_paramhdr_t) + 2); | ||
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index a238d6834b33..47f91afa0211 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c | |||
@@ -195,8 +195,7 @@ out: | |||
195 | } | 195 | } |
196 | 196 | ||
197 | /* Based on tcp_v6_xmit() in tcp_ipv6.c. */ | 197 | /* Based on tcp_v6_xmit() in tcp_ipv6.c. */ |
198 | static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport, | 198 | static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport) |
199 | int ipfragok) | ||
200 | { | 199 | { |
201 | struct sock *sk = skb->sk; | 200 | struct sock *sk = skb->sk; |
202 | struct ipv6_pinfo *np = inet6_sk(sk); | 201 | struct ipv6_pinfo *np = inet6_sk(sk); |
@@ -231,7 +230,10 @@ static int sctp_v6_xmit(struct sk_buff *skb, struct sctp_transport *transport, | |||
231 | 230 | ||
232 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); | 231 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); |
233 | 232 | ||
234 | return ip6_xmit(sk, skb, &fl, np->opt, ipfragok); | 233 | if (!(transport->param_flags & SPP_PMTUD_ENABLE)) |
234 | skb->local_df = 1; | ||
235 | |||
236 | return ip6_xmit(sk, skb, &fl, np->opt, 0); | ||
235 | } | 237 | } |
236 | 238 | ||
237 | /* Returns the dst cache entry for the given source and destination ip | 239 | /* Returns the dst cache entry for the given source and destination ip |
@@ -317,7 +319,8 @@ static void sctp_v6_get_saddr(struct sctp_sock *sk, | |||
317 | __func__, asoc, dst, NIP6(daddr->v6.sin6_addr)); | 319 | __func__, asoc, dst, NIP6(daddr->v6.sin6_addr)); |
318 | 320 | ||
319 | if (!asoc) { | 321 | if (!asoc) { |
320 | ipv6_dev_get_saddr(dst ? ip6_dst_idev(dst)->dev : NULL, | 322 | ipv6_dev_get_saddr(sock_net(sctp_opt2sk(sk)), |
323 | dst ? ip6_dst_idev(dst)->dev : NULL, | ||
321 | &daddr->v6.sin6_addr, | 324 | &daddr->v6.sin6_addr, |
322 | inet6_sk(&sk->inet.sk)->srcprefs, | 325 | inet6_sk(&sk->inet.sk)->srcprefs, |
323 | &saddr->v6.sin6_addr); | 326 | &saddr->v6.sin6_addr); |
diff --git a/net/sctp/output.c b/net/sctp/output.c index 45684646b1db..0dc4a7dfb234 100644 --- a/net/sctp/output.c +++ b/net/sctp/output.c | |||
@@ -586,10 +586,8 @@ int sctp_packet_transmit(struct sctp_packet *packet) | |||
586 | SCTP_DEBUG_PRINTK("***sctp_transmit_packet*** skb len %d\n", | 586 | SCTP_DEBUG_PRINTK("***sctp_transmit_packet*** skb len %d\n", |
587 | nskb->len); | 587 | nskb->len); |
588 | 588 | ||
589 | if (tp->param_flags & SPP_PMTUD_ENABLE) | 589 | nskb->local_df = packet->ipfragok; |
590 | (*tp->af_specific->sctp_xmit)(nskb, tp, packet->ipfragok); | 590 | (*tp->af_specific->sctp_xmit)(nskb, tp); |
591 | else | ||
592 | (*tp->af_specific->sctp_xmit)(nskb, tp, 1); | ||
593 | 591 | ||
594 | out: | 592 | out: |
595 | packet->size = packet->overhead; | 593 | packet->size = packet->overhead; |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index a6e0818bcff5..0b65354aaf64 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -862,16 +862,21 @@ static int sctp_inet_supported_addrs(const struct sctp_sock *opt, | |||
862 | 862 | ||
863 | /* Wrapper routine that calls the ip transmit routine. */ | 863 | /* Wrapper routine that calls the ip transmit routine. */ |
864 | static inline int sctp_v4_xmit(struct sk_buff *skb, | 864 | static inline int sctp_v4_xmit(struct sk_buff *skb, |
865 | struct sctp_transport *transport, int ipfragok) | 865 | struct sctp_transport *transport) |
866 | { | 866 | { |
867 | struct inet_sock *inet = inet_sk(skb->sk); | ||
868 | |||
867 | SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, " | 869 | SCTP_DEBUG_PRINTK("%s: skb:%p, len:%d, " |
868 | "src:%u.%u.%u.%u, dst:%u.%u.%u.%u\n", | 870 | "src:%u.%u.%u.%u, dst:%u.%u.%u.%u\n", |
869 | __func__, skb, skb->len, | 871 | __func__, skb, skb->len, |
870 | NIPQUAD(skb->rtable->rt_src), | 872 | NIPQUAD(skb->rtable->rt_src), |
871 | NIPQUAD(skb->rtable->rt_dst)); | 873 | NIPQUAD(skb->rtable->rt_dst)); |
872 | 874 | ||
875 | inet->pmtudisc = transport->param_flags & SPP_PMTUD_ENABLE ? | ||
876 | IP_PMTUDISC_DO : IP_PMTUDISC_DONT; | ||
877 | |||
873 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); | 878 | SCTP_INC_STATS(SCTP_MIB_OUTSCTPPACKS); |
874 | return ip_queue_xmit(skb, ipfragok); | 879 | return ip_queue_xmit(skb, 0); |
875 | } | 880 | } |
876 | 881 | ||
877 | static struct sctp_af sctp_af_inet; | 882 | static struct sctp_af sctp_af_inet; |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index dbb79adf8f3c..5ffb9dec1c3f 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -3055,6 +3055,9 @@ static int sctp_setsockopt_auth_chunk(struct sock *sk, | |||
3055 | { | 3055 | { |
3056 | struct sctp_authchunk val; | 3056 | struct sctp_authchunk val; |
3057 | 3057 | ||
3058 | if (!sctp_auth_enable) | ||
3059 | return -EACCES; | ||
3060 | |||
3058 | if (optlen != sizeof(struct sctp_authchunk)) | 3061 | if (optlen != sizeof(struct sctp_authchunk)) |
3059 | return -EINVAL; | 3062 | return -EINVAL; |
3060 | if (copy_from_user(&val, optval, optlen)) | 3063 | if (copy_from_user(&val, optval, optlen)) |
@@ -3083,8 +3086,12 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, | |||
3083 | int optlen) | 3086 | int optlen) |
3084 | { | 3087 | { |
3085 | struct sctp_hmacalgo *hmacs; | 3088 | struct sctp_hmacalgo *hmacs; |
3089 | u32 idents; | ||
3086 | int err; | 3090 | int err; |
3087 | 3091 | ||
3092 | if (!sctp_auth_enable) | ||
3093 | return -EACCES; | ||
3094 | |||
3088 | if (optlen < sizeof(struct sctp_hmacalgo)) | 3095 | if (optlen < sizeof(struct sctp_hmacalgo)) |
3089 | return -EINVAL; | 3096 | return -EINVAL; |
3090 | 3097 | ||
@@ -3097,8 +3104,9 @@ static int sctp_setsockopt_hmac_ident(struct sock *sk, | |||
3097 | goto out; | 3104 | goto out; |
3098 | } | 3105 | } |
3099 | 3106 | ||
3100 | if (hmacs->shmac_num_idents == 0 || | 3107 | idents = hmacs->shmac_num_idents; |
3101 | hmacs->shmac_num_idents > SCTP_AUTH_NUM_HMACS) { | 3108 | if (idents == 0 || idents > SCTP_AUTH_NUM_HMACS || |
3109 | (idents * sizeof(u16)) > (optlen - sizeof(struct sctp_hmacalgo))) { | ||
3102 | err = -EINVAL; | 3110 | err = -EINVAL; |
3103 | goto out; | 3111 | goto out; |
3104 | } | 3112 | } |
@@ -3123,6 +3131,9 @@ static int sctp_setsockopt_auth_key(struct sock *sk, | |||
3123 | struct sctp_association *asoc; | 3131 | struct sctp_association *asoc; |
3124 | int ret; | 3132 | int ret; |
3125 | 3133 | ||
3134 | if (!sctp_auth_enable) | ||
3135 | return -EACCES; | ||
3136 | |||
3126 | if (optlen <= sizeof(struct sctp_authkey)) | 3137 | if (optlen <= sizeof(struct sctp_authkey)) |
3127 | return -EINVAL; | 3138 | return -EINVAL; |
3128 | 3139 | ||
@@ -3135,6 +3146,11 @@ static int sctp_setsockopt_auth_key(struct sock *sk, | |||
3135 | goto out; | 3146 | goto out; |
3136 | } | 3147 | } |
3137 | 3148 | ||
3149 | if (authkey->sca_keylength > optlen - sizeof(struct sctp_authkey)) { | ||
3150 | ret = -EINVAL; | ||
3151 | goto out; | ||
3152 | } | ||
3153 | |||
3138 | asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); | 3154 | asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); |
3139 | if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { | 3155 | if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { |
3140 | ret = -EINVAL; | 3156 | ret = -EINVAL; |
@@ -3160,6 +3176,9 @@ static int sctp_setsockopt_active_key(struct sock *sk, | |||
3160 | struct sctp_authkeyid val; | 3176 | struct sctp_authkeyid val; |
3161 | struct sctp_association *asoc; | 3177 | struct sctp_association *asoc; |
3162 | 3178 | ||
3179 | if (!sctp_auth_enable) | ||
3180 | return -EACCES; | ||
3181 | |||
3163 | if (optlen != sizeof(struct sctp_authkeyid)) | 3182 | if (optlen != sizeof(struct sctp_authkeyid)) |
3164 | return -EINVAL; | 3183 | return -EINVAL; |
3165 | if (copy_from_user(&val, optval, optlen)) | 3184 | if (copy_from_user(&val, optval, optlen)) |
@@ -3185,6 +3204,9 @@ static int sctp_setsockopt_del_key(struct sock *sk, | |||
3185 | struct sctp_authkeyid val; | 3204 | struct sctp_authkeyid val; |
3186 | struct sctp_association *asoc; | 3205 | struct sctp_association *asoc; |
3187 | 3206 | ||
3207 | if (!sctp_auth_enable) | ||
3208 | return -EACCES; | ||
3209 | |||
3188 | if (optlen != sizeof(struct sctp_authkeyid)) | 3210 | if (optlen != sizeof(struct sctp_authkeyid)) |
3189 | return -EINVAL; | 3211 | return -EINVAL; |
3190 | if (copy_from_user(&val, optval, optlen)) | 3212 | if (copy_from_user(&val, optval, optlen)) |
@@ -5197,19 +5219,29 @@ static int sctp_getsockopt_maxburst(struct sock *sk, int len, | |||
5197 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, | 5219 | static int sctp_getsockopt_hmac_ident(struct sock *sk, int len, |
5198 | char __user *optval, int __user *optlen) | 5220 | char __user *optval, int __user *optlen) |
5199 | { | 5221 | { |
5222 | struct sctp_hmacalgo __user *p = (void __user *)optval; | ||
5200 | struct sctp_hmac_algo_param *hmacs; | 5223 | struct sctp_hmac_algo_param *hmacs; |
5201 | __u16 param_len; | 5224 | __u16 data_len = 0; |
5225 | u32 num_idents; | ||
5226 | |||
5227 | if (!sctp_auth_enable) | ||
5228 | return -EACCES; | ||
5202 | 5229 | ||
5203 | hmacs = sctp_sk(sk)->ep->auth_hmacs_list; | 5230 | hmacs = sctp_sk(sk)->ep->auth_hmacs_list; |
5204 | param_len = ntohs(hmacs->param_hdr.length); | 5231 | data_len = ntohs(hmacs->param_hdr.length) - sizeof(sctp_paramhdr_t); |
5205 | 5232 | ||
5206 | if (len < param_len) | 5233 | if (len < sizeof(struct sctp_hmacalgo) + data_len) |
5207 | return -EINVAL; | 5234 | return -EINVAL; |
5235 | |||
5236 | len = sizeof(struct sctp_hmacalgo) + data_len; | ||
5237 | num_idents = data_len / sizeof(u16); | ||
5238 | |||
5208 | if (put_user(len, optlen)) | 5239 | if (put_user(len, optlen)) |
5209 | return -EFAULT; | 5240 | return -EFAULT; |
5210 | if (copy_to_user(optval, hmacs->hmac_ids, len)) | 5241 | if (put_user(num_idents, &p->shmac_num_idents)) |
5242 | return -EFAULT; | ||
5243 | if (copy_to_user(p->shmac_idents, hmacs->hmac_ids, data_len)) | ||
5211 | return -EFAULT; | 5244 | return -EFAULT; |
5212 | |||
5213 | return 0; | 5245 | return 0; |
5214 | } | 5246 | } |
5215 | 5247 | ||
@@ -5219,6 +5251,9 @@ static int sctp_getsockopt_active_key(struct sock *sk, int len, | |||
5219 | struct sctp_authkeyid val; | 5251 | struct sctp_authkeyid val; |
5220 | struct sctp_association *asoc; | 5252 | struct sctp_association *asoc; |
5221 | 5253 | ||
5254 | if (!sctp_auth_enable) | ||
5255 | return -EACCES; | ||
5256 | |||
5222 | if (len < sizeof(struct sctp_authkeyid)) | 5257 | if (len < sizeof(struct sctp_authkeyid)) |
5223 | return -EINVAL; | 5258 | return -EINVAL; |
5224 | if (copy_from_user(&val, optval, sizeof(struct sctp_authkeyid))) | 5259 | if (copy_from_user(&val, optval, sizeof(struct sctp_authkeyid))) |
@@ -5233,6 +5268,12 @@ static int sctp_getsockopt_active_key(struct sock *sk, int len, | |||
5233 | else | 5268 | else |
5234 | val.scact_keynumber = sctp_sk(sk)->ep->active_key_id; | 5269 | val.scact_keynumber = sctp_sk(sk)->ep->active_key_id; |
5235 | 5270 | ||
5271 | len = sizeof(struct sctp_authkeyid); | ||
5272 | if (put_user(len, optlen)) | ||
5273 | return -EFAULT; | ||
5274 | if (copy_to_user(optval, &val, len)) | ||
5275 | return -EFAULT; | ||
5276 | |||
5236 | return 0; | 5277 | return 0; |
5237 | } | 5278 | } |
5238 | 5279 | ||
@@ -5243,13 +5284,16 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, | |||
5243 | struct sctp_authchunks val; | 5284 | struct sctp_authchunks val; |
5244 | struct sctp_association *asoc; | 5285 | struct sctp_association *asoc; |
5245 | struct sctp_chunks_param *ch; | 5286 | struct sctp_chunks_param *ch; |
5246 | u32 num_chunks; | 5287 | u32 num_chunks = 0; |
5247 | char __user *to; | 5288 | char __user *to; |
5248 | 5289 | ||
5249 | if (len <= sizeof(struct sctp_authchunks)) | 5290 | if (!sctp_auth_enable) |
5291 | return -EACCES; | ||
5292 | |||
5293 | if (len < sizeof(struct sctp_authchunks)) | ||
5250 | return -EINVAL; | 5294 | return -EINVAL; |
5251 | 5295 | ||
5252 | if (copy_from_user(&val, p, sizeof(struct sctp_authchunks))) | 5296 | if (copy_from_user(&val, optval, sizeof(struct sctp_authchunks))) |
5253 | return -EFAULT; | 5297 | return -EFAULT; |
5254 | 5298 | ||
5255 | to = p->gauth_chunks; | 5299 | to = p->gauth_chunks; |
@@ -5258,20 +5302,21 @@ static int sctp_getsockopt_peer_auth_chunks(struct sock *sk, int len, | |||
5258 | return -EINVAL; | 5302 | return -EINVAL; |
5259 | 5303 | ||
5260 | ch = asoc->peer.peer_chunks; | 5304 | ch = asoc->peer.peer_chunks; |
5305 | if (!ch) | ||
5306 | goto num; | ||
5261 | 5307 | ||
5262 | /* See if the user provided enough room for all the data */ | 5308 | /* See if the user provided enough room for all the data */ |
5263 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); | 5309 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); |
5264 | if (len < num_chunks) | 5310 | if (len < num_chunks) |
5265 | return -EINVAL; | 5311 | return -EINVAL; |
5266 | 5312 | ||
5267 | len = num_chunks; | 5313 | if (copy_to_user(to, ch->chunks, num_chunks)) |
5268 | if (put_user(len, optlen)) | ||
5269 | return -EFAULT; | 5314 | return -EFAULT; |
5315 | num: | ||
5316 | len = sizeof(struct sctp_authchunks) + num_chunks; | ||
5317 | if (put_user(len, optlen)) return -EFAULT; | ||
5270 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) | 5318 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) |
5271 | return -EFAULT; | 5319 | return -EFAULT; |
5272 | if (copy_to_user(to, ch->chunks, len)) | ||
5273 | return -EFAULT; | ||
5274 | |||
5275 | return 0; | 5320 | return 0; |
5276 | } | 5321 | } |
5277 | 5322 | ||
@@ -5282,13 +5327,16 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, | |||
5282 | struct sctp_authchunks val; | 5327 | struct sctp_authchunks val; |
5283 | struct sctp_association *asoc; | 5328 | struct sctp_association *asoc; |
5284 | struct sctp_chunks_param *ch; | 5329 | struct sctp_chunks_param *ch; |
5285 | u32 num_chunks; | 5330 | u32 num_chunks = 0; |
5286 | char __user *to; | 5331 | char __user *to; |
5287 | 5332 | ||
5288 | if (len <= sizeof(struct sctp_authchunks)) | 5333 | if (!sctp_auth_enable) |
5334 | return -EACCES; | ||
5335 | |||
5336 | if (len < sizeof(struct sctp_authchunks)) | ||
5289 | return -EINVAL; | 5337 | return -EINVAL; |
5290 | 5338 | ||
5291 | if (copy_from_user(&val, p, sizeof(struct sctp_authchunks))) | 5339 | if (copy_from_user(&val, optval, sizeof(struct sctp_authchunks))) |
5292 | return -EFAULT; | 5340 | return -EFAULT; |
5293 | 5341 | ||
5294 | to = p->gauth_chunks; | 5342 | to = p->gauth_chunks; |
@@ -5301,17 +5349,21 @@ static int sctp_getsockopt_local_auth_chunks(struct sock *sk, int len, | |||
5301 | else | 5349 | else |
5302 | ch = sctp_sk(sk)->ep->auth_chunk_list; | 5350 | ch = sctp_sk(sk)->ep->auth_chunk_list; |
5303 | 5351 | ||
5352 | if (!ch) | ||
5353 | goto num; | ||
5354 | |||
5304 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); | 5355 | num_chunks = ntohs(ch->param_hdr.length) - sizeof(sctp_paramhdr_t); |
5305 | if (len < num_chunks) | 5356 | if (len < sizeof(struct sctp_authchunks) + num_chunks) |
5306 | return -EINVAL; | 5357 | return -EINVAL; |
5307 | 5358 | ||
5308 | len = num_chunks; | 5359 | if (copy_to_user(to, ch->chunks, num_chunks)) |
5360 | return -EFAULT; | ||
5361 | num: | ||
5362 | len = sizeof(struct sctp_authchunks) + num_chunks; | ||
5309 | if (put_user(len, optlen)) | 5363 | if (put_user(len, optlen)) |
5310 | return -EFAULT; | 5364 | return -EFAULT; |
5311 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) | 5365 | if (put_user(num_chunks, &p->gauth_number_of_chunks)) |
5312 | return -EFAULT; | 5366 | return -EFAULT; |
5313 | if (copy_to_user(to, ch->chunks, len)) | ||
5314 | return -EFAULT; | ||
5315 | 5367 | ||
5316 | return 0; | 5368 | return 0; |
5317 | } | 5369 | } |
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c index 0f8c439b848a..5231f7aaac0e 100644 --- a/net/sunrpc/sysctl.c +++ b/net/sunrpc/sysctl.c | |||
@@ -60,24 +60,14 @@ static int proc_do_xprt(ctl_table *table, int write, struct file *file, | |||
60 | void __user *buffer, size_t *lenp, loff_t *ppos) | 60 | void __user *buffer, size_t *lenp, loff_t *ppos) |
61 | { | 61 | { |
62 | char tmpbuf[256]; | 62 | char tmpbuf[256]; |
63 | int len; | 63 | size_t len; |
64 | |||
64 | if ((*ppos && !write) || !*lenp) { | 65 | if ((*ppos && !write) || !*lenp) { |
65 | *lenp = 0; | 66 | *lenp = 0; |
66 | return 0; | 67 | return 0; |
67 | } | 68 | } |
68 | if (write) | 69 | len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); |
69 | return -EINVAL; | 70 | return simple_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len); |
70 | else { | ||
71 | len = svc_print_xprts(tmpbuf, sizeof(tmpbuf)); | ||
72 | if (!access_ok(VERIFY_WRITE, buffer, len)) | ||
73 | return -EFAULT; | ||
74 | |||
75 | if (__copy_to_user(buffer, tmpbuf, len)) | ||
76 | return -EFAULT; | ||
77 | } | ||
78 | *lenp -= len; | ||
79 | *ppos += len; | ||
80 | return 0; | ||
81 | } | 71 | } |
82 | 72 | ||
83 | static int | 73 | static int |
diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c index b4b17f44cb29..74de31a06616 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c | |||
@@ -443,18 +443,18 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp) | |||
443 | 443 | ||
444 | dprintk("svcrdma: rqstp=%p\n", rqstp); | 444 | dprintk("svcrdma: rqstp=%p\n", rqstp); |
445 | 445 | ||
446 | spin_lock_bh(&rdma_xprt->sc_read_complete_lock); | 446 | spin_lock_bh(&rdma_xprt->sc_rq_dto_lock); |
447 | if (!list_empty(&rdma_xprt->sc_read_complete_q)) { | 447 | if (!list_empty(&rdma_xprt->sc_read_complete_q)) { |
448 | ctxt = list_entry(rdma_xprt->sc_read_complete_q.next, | 448 | ctxt = list_entry(rdma_xprt->sc_read_complete_q.next, |
449 | struct svc_rdma_op_ctxt, | 449 | struct svc_rdma_op_ctxt, |
450 | dto_q); | 450 | dto_q); |
451 | list_del_init(&ctxt->dto_q); | 451 | list_del_init(&ctxt->dto_q); |
452 | } | 452 | } |
453 | spin_unlock_bh(&rdma_xprt->sc_read_complete_lock); | 453 | if (ctxt) { |
454 | if (ctxt) | 454 | spin_unlock_bh(&rdma_xprt->sc_rq_dto_lock); |
455 | return rdma_read_complete(rqstp, ctxt); | 455 | return rdma_read_complete(rqstp, ctxt); |
456 | } | ||
456 | 457 | ||
457 | spin_lock_bh(&rdma_xprt->sc_rq_dto_lock); | ||
458 | if (!list_empty(&rdma_xprt->sc_rq_dto_q)) { | 458 | if (!list_empty(&rdma_xprt->sc_rq_dto_q)) { |
459 | ctxt = list_entry(rdma_xprt->sc_rq_dto_q.next, | 459 | ctxt = list_entry(rdma_xprt->sc_rq_dto_q.next, |
460 | struct svc_rdma_op_ctxt, | 460 | struct svc_rdma_op_ctxt, |
diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c index 19ddc382b777..900cb69728c6 100644 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c | |||
@@ -359,11 +359,11 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt) | |||
359 | if (test_bit(RDMACTXT_F_LAST_CTXT, &ctxt->flags)) { | 359 | if (test_bit(RDMACTXT_F_LAST_CTXT, &ctxt->flags)) { |
360 | struct svc_rdma_op_ctxt *read_hdr = ctxt->read_hdr; | 360 | struct svc_rdma_op_ctxt *read_hdr = ctxt->read_hdr; |
361 | BUG_ON(!read_hdr); | 361 | BUG_ON(!read_hdr); |
362 | spin_lock_bh(&xprt->sc_rq_dto_lock); | ||
362 | set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags); | 363 | set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags); |
363 | spin_lock_bh(&xprt->sc_read_complete_lock); | ||
364 | list_add_tail(&read_hdr->dto_q, | 364 | list_add_tail(&read_hdr->dto_q, |
365 | &xprt->sc_read_complete_q); | 365 | &xprt->sc_read_complete_q); |
366 | spin_unlock_bh(&xprt->sc_read_complete_lock); | 366 | spin_unlock_bh(&xprt->sc_rq_dto_lock); |
367 | svc_xprt_enqueue(&xprt->sc_xprt); | 367 | svc_xprt_enqueue(&xprt->sc_xprt); |
368 | } | 368 | } |
369 | svc_rdma_put_context(ctxt, 0); | 369 | svc_rdma_put_context(ctxt, 0); |
@@ -428,7 +428,6 @@ static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *serv, | |||
428 | init_waitqueue_head(&cma_xprt->sc_send_wait); | 428 | init_waitqueue_head(&cma_xprt->sc_send_wait); |
429 | 429 | ||
430 | spin_lock_init(&cma_xprt->sc_lock); | 430 | spin_lock_init(&cma_xprt->sc_lock); |
431 | spin_lock_init(&cma_xprt->sc_read_complete_lock); | ||
432 | spin_lock_init(&cma_xprt->sc_rq_dto_lock); | 431 | spin_lock_init(&cma_xprt->sc_rq_dto_lock); |
433 | 432 | ||
434 | cma_xprt->sc_ord = svcrdma_ord; | 433 | cma_xprt->sc_ord = svcrdma_ord; |
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index b1ff16aa4bdb..3ddaff42d1bb 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -96,8 +96,8 @@ struct bcbearer { | |||
96 | struct media media; | 96 | struct media media; |
97 | struct bcbearer_pair bpairs[MAX_BEARERS]; | 97 | struct bcbearer_pair bpairs[MAX_BEARERS]; |
98 | struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1]; | 98 | struct bcbearer_pair bpairs_temp[TIPC_MAX_LINK_PRI + 1]; |
99 | struct node_map remains; | 99 | struct tipc_node_map remains; |
100 | struct node_map remains_new; | 100 | struct tipc_node_map remains_new; |
101 | }; | 101 | }; |
102 | 102 | ||
103 | /** | 103 | /** |
@@ -110,7 +110,7 @@ struct bcbearer { | |||
110 | 110 | ||
111 | struct bclink { | 111 | struct bclink { |
112 | struct link link; | 112 | struct link link; |
113 | struct node node; | 113 | struct tipc_node node; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | 116 | ||
@@ -149,7 +149,7 @@ static void bcbuf_decr_acks(struct sk_buff *buf) | |||
149 | * Called with 'node' locked, bc_lock unlocked | 149 | * Called with 'node' locked, bc_lock unlocked |
150 | */ | 150 | */ |
151 | 151 | ||
152 | static void bclink_set_gap(struct node *n_ptr) | 152 | static void bclink_set_gap(struct tipc_node *n_ptr) |
153 | { | 153 | { |
154 | struct sk_buff *buf = n_ptr->bclink.deferred_head; | 154 | struct sk_buff *buf = n_ptr->bclink.deferred_head; |
155 | 155 | ||
@@ -202,7 +202,7 @@ static void bclink_retransmit_pkt(u32 after, u32 to) | |||
202 | * Node is locked, bc_lock unlocked. | 202 | * Node is locked, bc_lock unlocked. |
203 | */ | 203 | */ |
204 | 204 | ||
205 | void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked) | 205 | void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked) |
206 | { | 206 | { |
207 | struct sk_buff *crs; | 207 | struct sk_buff *crs; |
208 | struct sk_buff *next; | 208 | struct sk_buff *next; |
@@ -250,7 +250,7 @@ void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked) | |||
250 | * tipc_net_lock and node lock set | 250 | * tipc_net_lock and node lock set |
251 | */ | 251 | */ |
252 | 252 | ||
253 | static void bclink_send_ack(struct node *n_ptr) | 253 | static void bclink_send_ack(struct tipc_node *n_ptr) |
254 | { | 254 | { |
255 | struct link *l_ptr = n_ptr->active_links[n_ptr->addr & 1]; | 255 | struct link *l_ptr = n_ptr->active_links[n_ptr->addr & 1]; |
256 | 256 | ||
@@ -264,7 +264,7 @@ static void bclink_send_ack(struct node *n_ptr) | |||
264 | * tipc_net_lock and node lock set | 264 | * tipc_net_lock and node lock set |
265 | */ | 265 | */ |
266 | 266 | ||
267 | static void bclink_send_nack(struct node *n_ptr) | 267 | static void bclink_send_nack(struct tipc_node *n_ptr) |
268 | { | 268 | { |
269 | struct sk_buff *buf; | 269 | struct sk_buff *buf; |
270 | struct tipc_msg *msg; | 270 | struct tipc_msg *msg; |
@@ -308,7 +308,7 @@ static void bclink_send_nack(struct node *n_ptr) | |||
308 | * tipc_net_lock and node lock set | 308 | * tipc_net_lock and node lock set |
309 | */ | 309 | */ |
310 | 310 | ||
311 | void tipc_bclink_check_gap(struct node *n_ptr, u32 last_sent) | 311 | void tipc_bclink_check_gap(struct tipc_node *n_ptr, u32 last_sent) |
312 | { | 312 | { |
313 | if (!n_ptr->bclink.supported || | 313 | if (!n_ptr->bclink.supported || |
314 | less_eq(last_sent, mod(n_ptr->bclink.last_in))) | 314 | less_eq(last_sent, mod(n_ptr->bclink.last_in))) |
@@ -328,7 +328,7 @@ void tipc_bclink_check_gap(struct node *n_ptr, u32 last_sent) | |||
328 | 328 | ||
329 | static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 gap_to) | 329 | static void tipc_bclink_peek_nack(u32 dest, u32 sender_tag, u32 gap_after, u32 gap_to) |
330 | { | 330 | { |
331 | struct node *n_ptr = tipc_node_find(dest); | 331 | struct tipc_node *n_ptr = tipc_node_find(dest); |
332 | u32 my_after, my_to; | 332 | u32 my_after, my_to; |
333 | 333 | ||
334 | if (unlikely(!n_ptr || !tipc_node_is_up(n_ptr))) | 334 | if (unlikely(!n_ptr || !tipc_node_is_up(n_ptr))) |
@@ -418,7 +418,7 @@ void tipc_bclink_recv_pkt(struct sk_buff *buf) | |||
418 | static int rx_count = 0; | 418 | static int rx_count = 0; |
419 | #endif | 419 | #endif |
420 | struct tipc_msg *msg = buf_msg(buf); | 420 | struct tipc_msg *msg = buf_msg(buf); |
421 | struct node* node = tipc_node_find(msg_prevnode(msg)); | 421 | struct tipc_node* node = tipc_node_find(msg_prevnode(msg)); |
422 | u32 next_in; | 422 | u32 next_in; |
423 | u32 seqno; | 423 | u32 seqno; |
424 | struct sk_buff *deferred; | 424 | struct sk_buff *deferred; |
@@ -538,7 +538,7 @@ u32 tipc_bclink_get_last_sent(void) | |||
538 | return last_sent; | 538 | return last_sent; |
539 | } | 539 | } |
540 | 540 | ||
541 | u32 tipc_bclink_acks_missing(struct node *n_ptr) | 541 | u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr) |
542 | { | 542 | { |
543 | return (n_ptr->bclink.supported && | 543 | return (n_ptr->bclink.supported && |
544 | (tipc_bclink_get_last_sent() != n_ptr->bclink.acked)); | 544 | (tipc_bclink_get_last_sent() != n_ptr->bclink.acked)); |
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index a2416fa6b906..5aa024b99c55 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
@@ -41,12 +41,12 @@ | |||
41 | #define WSIZE 32 | 41 | #define WSIZE 32 |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * struct node_map - set of node identifiers | 44 | * struct tipc_node_map - set of node identifiers |
45 | * @count: # of nodes in set | 45 | * @count: # of nodes in set |
46 | * @map: bitmap of node identifiers that are in the set | 46 | * @map: bitmap of node identifiers that are in the set |
47 | */ | 47 | */ |
48 | 48 | ||
49 | struct node_map { | 49 | struct tipc_node_map { |
50 | u32 count; | 50 | u32 count; |
51 | u32 map[MAX_NODES / WSIZE]; | 51 | u32 map[MAX_NODES / WSIZE]; |
52 | }; | 52 | }; |
@@ -68,7 +68,7 @@ struct port_list { | |||
68 | }; | 68 | }; |
69 | 69 | ||
70 | 70 | ||
71 | struct node; | 71 | struct tipc_node; |
72 | 72 | ||
73 | extern char tipc_bclink_name[]; | 73 | extern char tipc_bclink_name[]; |
74 | 74 | ||
@@ -77,7 +77,7 @@ extern char tipc_bclink_name[]; | |||
77 | * nmap_add - add a node to a node map | 77 | * nmap_add - add a node to a node map |
78 | */ | 78 | */ |
79 | 79 | ||
80 | static inline void tipc_nmap_add(struct node_map *nm_ptr, u32 node) | 80 | static inline void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node) |
81 | { | 81 | { |
82 | int n = tipc_node(node); | 82 | int n = tipc_node(node); |
83 | int w = n / WSIZE; | 83 | int w = n / WSIZE; |
@@ -93,7 +93,7 @@ static inline void tipc_nmap_add(struct node_map *nm_ptr, u32 node) | |||
93 | * nmap_remove - remove a node from a node map | 93 | * nmap_remove - remove a node from a node map |
94 | */ | 94 | */ |
95 | 95 | ||
96 | static inline void tipc_nmap_remove(struct node_map *nm_ptr, u32 node) | 96 | static inline void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node) |
97 | { | 97 | { |
98 | int n = tipc_node(node); | 98 | int n = tipc_node(node); |
99 | int w = n / WSIZE; | 99 | int w = n / WSIZE; |
@@ -109,7 +109,7 @@ static inline void tipc_nmap_remove(struct node_map *nm_ptr, u32 node) | |||
109 | * nmap_equal - test for equality of node maps | 109 | * nmap_equal - test for equality of node maps |
110 | */ | 110 | */ |
111 | 111 | ||
112 | static inline int tipc_nmap_equal(struct node_map *nm_a, struct node_map *nm_b) | 112 | static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b) |
113 | { | 113 | { |
114 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); | 114 | return !memcmp(nm_a, nm_b, sizeof(*nm_a)); |
115 | } | 115 | } |
@@ -121,8 +121,8 @@ static inline int tipc_nmap_equal(struct node_map *nm_a, struct node_map *nm_b) | |||
121 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) | 121 | * @nm_diff: output node map A-B (i.e. nodes of A that are not in B) |
122 | */ | 122 | */ |
123 | 123 | ||
124 | static inline void tipc_nmap_diff(struct node_map *nm_a, struct node_map *nm_b, | 124 | static inline void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, |
125 | struct node_map *nm_diff) | 125 | struct tipc_node_map *nm_diff) |
126 | { | 126 | { |
127 | int stop = sizeof(nm_a->map) / sizeof(u32); | 127 | int stop = sizeof(nm_a->map) / sizeof(u32); |
128 | int w; | 128 | int w; |
@@ -195,12 +195,12 @@ static inline void tipc_port_list_free(struct port_list *pl_ptr) | |||
195 | 195 | ||
196 | int tipc_bclink_init(void); | 196 | int tipc_bclink_init(void); |
197 | void tipc_bclink_stop(void); | 197 | void tipc_bclink_stop(void); |
198 | void tipc_bclink_acknowledge(struct node *n_ptr, u32 acked); | 198 | void tipc_bclink_acknowledge(struct tipc_node *n_ptr, u32 acked); |
199 | int tipc_bclink_send_msg(struct sk_buff *buf); | 199 | int tipc_bclink_send_msg(struct sk_buff *buf); |
200 | void tipc_bclink_recv_pkt(struct sk_buff *buf); | 200 | void tipc_bclink_recv_pkt(struct sk_buff *buf); |
201 | u32 tipc_bclink_get_last_sent(void); | 201 | u32 tipc_bclink_get_last_sent(void); |
202 | u32 tipc_bclink_acks_missing(struct node *n_ptr); | 202 | u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr); |
203 | void tipc_bclink_check_gap(struct node *n_ptr, u32 seqno); | 203 | void tipc_bclink_check_gap(struct tipc_node *n_ptr, u32 seqno); |
204 | int tipc_bclink_stats(char *stats_buf, const u32 buf_size); | 204 | int tipc_bclink_stats(char *stats_buf, const u32 buf_size); |
205 | int tipc_bclink_reset_stats(void); | 205 | int tipc_bclink_reset_stats(void); |
206 | int tipc_bclink_set_queue_limits(u32 limit); | 206 | int tipc_bclink_set_queue_limits(u32 limit); |
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c index 6a9aba3edd08..a7a36779b9b3 100644 --- a/net/tipc/bearer.c +++ b/net/tipc/bearer.c | |||
@@ -599,7 +599,7 @@ int tipc_block_bearer(const char *name) | |||
599 | spin_lock_bh(&b_ptr->publ.lock); | 599 | spin_lock_bh(&b_ptr->publ.lock); |
600 | b_ptr->publ.blocked = 1; | 600 | b_ptr->publ.blocked = 1; |
601 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { | 601 | list_for_each_entry_safe(l_ptr, temp_l_ptr, &b_ptr->links, link_list) { |
602 | struct node *n_ptr = l_ptr->owner; | 602 | struct tipc_node *n_ptr = l_ptr->owner; |
603 | 603 | ||
604 | spin_lock_bh(&n_ptr->lock); | 604 | spin_lock_bh(&n_ptr->lock); |
605 | tipc_link_reset(l_ptr); | 605 | tipc_link_reset(l_ptr); |
diff --git a/net/tipc/bearer.h b/net/tipc/bearer.h index 6a36b6600e6c..ca5734892713 100644 --- a/net/tipc/bearer.h +++ b/net/tipc/bearer.h | |||
@@ -104,7 +104,7 @@ struct bearer { | |||
104 | u32 continue_count; | 104 | u32 continue_count; |
105 | int active; | 105 | int active; |
106 | char net_plane; | 106 | char net_plane; |
107 | struct node_map nodes; | 107 | struct tipc_node_map nodes; |
108 | }; | 108 | }; |
109 | 109 | ||
110 | struct bearer_name { | 110 | struct bearer_name { |
diff --git a/net/tipc/cluster.c b/net/tipc/cluster.c index 46ee6c58532d..689fdefe9d04 100644 --- a/net/tipc/cluster.c +++ b/net/tipc/cluster.c | |||
@@ -48,8 +48,8 @@ static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf, | |||
48 | u32 lower, u32 upper); | 48 | u32 lower, u32 upper); |
49 | static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest); | 49 | static struct sk_buff *tipc_cltr_prepare_routing_msg(u32 data_size, u32 dest); |
50 | 50 | ||
51 | struct node **tipc_local_nodes = NULL; | 51 | struct tipc_node **tipc_local_nodes = NULL; |
52 | struct node_map tipc_cltr_bcast_nodes = {0,{0,}}; | 52 | struct tipc_node_map tipc_cltr_bcast_nodes = {0,{0,}}; |
53 | u32 tipc_highest_allowed_slave = 0; | 53 | u32 tipc_highest_allowed_slave = 0; |
54 | 54 | ||
55 | struct cluster *tipc_cltr_create(u32 addr) | 55 | struct cluster *tipc_cltr_create(u32 addr) |
@@ -115,7 +115,7 @@ void tipc_cltr_delete(struct cluster *c_ptr) | |||
115 | 115 | ||
116 | u32 tipc_cltr_next_node(struct cluster *c_ptr, u32 addr) | 116 | u32 tipc_cltr_next_node(struct cluster *c_ptr, u32 addr) |
117 | { | 117 | { |
118 | struct node *n_ptr; | 118 | struct tipc_node *n_ptr; |
119 | u32 n_num = tipc_node(addr) + 1; | 119 | u32 n_num = tipc_node(addr) + 1; |
120 | 120 | ||
121 | if (!c_ptr) | 121 | if (!c_ptr) |
@@ -133,7 +133,7 @@ u32 tipc_cltr_next_node(struct cluster *c_ptr, u32 addr) | |||
133 | return 0; | 133 | return 0; |
134 | } | 134 | } |
135 | 135 | ||
136 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct node *n_ptr) | 136 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr) |
137 | { | 137 | { |
138 | u32 n_num = tipc_node(n_ptr->addr); | 138 | u32 n_num = tipc_node(n_ptr->addr); |
139 | u32 max_n_num = tipc_max_nodes; | 139 | u32 max_n_num = tipc_max_nodes; |
@@ -196,7 +196,7 @@ u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref) | |||
196 | * Uses deterministic and fair algorithm. | 196 | * Uses deterministic and fair algorithm. |
197 | */ | 197 | */ |
198 | 198 | ||
199 | struct node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector) | 199 | struct tipc_node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector) |
200 | { | 200 | { |
201 | u32 n_num; | 201 | u32 n_num; |
202 | u32 mask = tipc_max_nodes; | 202 | u32 mask = tipc_max_nodes; |
@@ -379,7 +379,7 @@ void tipc_cltr_recv_routing_table(struct sk_buff *buf) | |||
379 | { | 379 | { |
380 | struct tipc_msg *msg = buf_msg(buf); | 380 | struct tipc_msg *msg = buf_msg(buf); |
381 | struct cluster *c_ptr; | 381 | struct cluster *c_ptr; |
382 | struct node *n_ptr; | 382 | struct tipc_node *n_ptr; |
383 | unchar *node_table; | 383 | unchar *node_table; |
384 | u32 table_size; | 384 | u32 table_size; |
385 | u32 router; | 385 | u32 router; |
@@ -499,7 +499,7 @@ static void tipc_cltr_multicast(struct cluster *c_ptr, struct sk_buff *buf, | |||
499 | u32 lower, u32 upper) | 499 | u32 lower, u32 upper) |
500 | { | 500 | { |
501 | struct sk_buff *buf_copy; | 501 | struct sk_buff *buf_copy; |
502 | struct node *n_ptr; | 502 | struct tipc_node *n_ptr; |
503 | u32 n_num; | 503 | u32 n_num; |
504 | u32 tstop; | 504 | u32 tstop; |
505 | 505 | ||
@@ -534,7 +534,7 @@ void tipc_cltr_broadcast(struct sk_buff *buf) | |||
534 | { | 534 | { |
535 | struct sk_buff *buf_copy; | 535 | struct sk_buff *buf_copy; |
536 | struct cluster *c_ptr; | 536 | struct cluster *c_ptr; |
537 | struct node *n_ptr; | 537 | struct tipc_node *n_ptr; |
538 | u32 n_num; | 538 | u32 n_num; |
539 | u32 tstart; | 539 | u32 tstart; |
540 | u32 tstop; | 540 | u32 tstop; |
diff --git a/net/tipc/cluster.h b/net/tipc/cluster.h index 62df074afaec..333efb0b9c44 100644 --- a/net/tipc/cluster.h +++ b/net/tipc/cluster.h | |||
@@ -54,24 +54,24 @@ | |||
54 | struct cluster { | 54 | struct cluster { |
55 | u32 addr; | 55 | u32 addr; |
56 | struct _zone *owner; | 56 | struct _zone *owner; |
57 | struct node **nodes; | 57 | struct tipc_node **nodes; |
58 | u32 highest_node; | 58 | u32 highest_node; |
59 | u32 highest_slave; | 59 | u32 highest_slave; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | 62 | ||
63 | extern struct node **tipc_local_nodes; | 63 | extern struct tipc_node **tipc_local_nodes; |
64 | extern u32 tipc_highest_allowed_slave; | 64 | extern u32 tipc_highest_allowed_slave; |
65 | extern struct node_map tipc_cltr_bcast_nodes; | 65 | extern struct tipc_node_map tipc_cltr_bcast_nodes; |
66 | 66 | ||
67 | void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router); | 67 | void tipc_cltr_remove_as_router(struct cluster *c_ptr, u32 router); |
68 | void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest); | 68 | void tipc_cltr_send_ext_routes(struct cluster *c_ptr, u32 dest); |
69 | struct node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector); | 69 | struct tipc_node *tipc_cltr_select_node(struct cluster *c_ptr, u32 selector); |
70 | u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref); | 70 | u32 tipc_cltr_select_router(struct cluster *c_ptr, u32 ref); |
71 | void tipc_cltr_recv_routing_table(struct sk_buff *buf); | 71 | void tipc_cltr_recv_routing_table(struct sk_buff *buf); |
72 | struct cluster *tipc_cltr_create(u32 addr); | 72 | struct cluster *tipc_cltr_create(u32 addr); |
73 | void tipc_cltr_delete(struct cluster *c_ptr); | 73 | void tipc_cltr_delete(struct cluster *c_ptr); |
74 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct node *n_ptr); | 74 | void tipc_cltr_attach_node(struct cluster *c_ptr, struct tipc_node *n_ptr); |
75 | void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest); | 75 | void tipc_cltr_send_slave_routes(struct cluster *c_ptr, u32 dest); |
76 | void tipc_cltr_broadcast(struct sk_buff *buf); | 76 | void tipc_cltr_broadcast(struct sk_buff *buf); |
77 | int tipc_cltr_init(void); | 77 | int tipc_cltr_init(void); |
diff --git a/net/tipc/discover.c b/net/tipc/discover.c index 1657f0e795ff..74b7d1e28aec 100644 --- a/net/tipc/discover.c +++ b/net/tipc/discover.c | |||
@@ -193,7 +193,7 @@ void tipc_disc_recv_msg(struct sk_buff *buf, struct bearer *b_ptr) | |||
193 | /* Always accept link here */ | 193 | /* Always accept link here */ |
194 | struct sk_buff *rbuf; | 194 | struct sk_buff *rbuf; |
195 | struct tipc_media_addr *addr; | 195 | struct tipc_media_addr *addr; |
196 | struct node *n_ptr = tipc_node_find(orig); | 196 | struct tipc_node *n_ptr = tipc_node_find(orig); |
197 | int link_fully_up; | 197 | int link_fully_up; |
198 | 198 | ||
199 | dbg(" in own cluster\n"); | 199 | dbg(" in own cluster\n"); |
diff --git a/net/tipc/link.c b/net/tipc/link.c index d60113ba4b1b..dd4c18b9a35b 100644 --- a/net/tipc/link.c +++ b/net/tipc/link.c | |||
@@ -1155,7 +1155,7 @@ int tipc_link_send_buf(struct link *l_ptr, struct sk_buff *buf) | |||
1155 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) | 1155 | int tipc_link_send(struct sk_buff *buf, u32 dest, u32 selector) |
1156 | { | 1156 | { |
1157 | struct link *l_ptr; | 1157 | struct link *l_ptr; |
1158 | struct node *n_ptr; | 1158 | struct tipc_node *n_ptr; |
1159 | int res = -ELINKCONG; | 1159 | int res = -ELINKCONG; |
1160 | 1160 | ||
1161 | read_lock_bh(&tipc_net_lock); | 1161 | read_lock_bh(&tipc_net_lock); |
@@ -1226,7 +1226,7 @@ static int link_send_buf_fast(struct link *l_ptr, struct sk_buff *buf, | |||
1226 | int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) | 1226 | int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) |
1227 | { | 1227 | { |
1228 | struct link *l_ptr; | 1228 | struct link *l_ptr; |
1229 | struct node *n_ptr; | 1229 | struct tipc_node *n_ptr; |
1230 | int res; | 1230 | int res; |
1231 | u32 selector = msg_origport(buf_msg(buf)) & 1; | 1231 | u32 selector = msg_origport(buf_msg(buf)) & 1; |
1232 | u32 dummy; | 1232 | u32 dummy; |
@@ -1270,7 +1270,7 @@ int tipc_link_send_sections_fast(struct port *sender, | |||
1270 | struct tipc_msg *hdr = &sender->publ.phdr; | 1270 | struct tipc_msg *hdr = &sender->publ.phdr; |
1271 | struct link *l_ptr; | 1271 | struct link *l_ptr; |
1272 | struct sk_buff *buf; | 1272 | struct sk_buff *buf; |
1273 | struct node *node; | 1273 | struct tipc_node *node; |
1274 | int res; | 1274 | int res; |
1275 | u32 selector = msg_origport(hdr) & 1; | 1275 | u32 selector = msg_origport(hdr) & 1; |
1276 | 1276 | ||
@@ -1364,7 +1364,7 @@ static int link_send_sections_long(struct port *sender, | |||
1364 | u32 destaddr) | 1364 | u32 destaddr) |
1365 | { | 1365 | { |
1366 | struct link *l_ptr; | 1366 | struct link *l_ptr; |
1367 | struct node *node; | 1367 | struct tipc_node *node; |
1368 | struct tipc_msg *hdr = &sender->publ.phdr; | 1368 | struct tipc_msg *hdr = &sender->publ.phdr; |
1369 | u32 dsz = msg_data_sz(hdr); | 1369 | u32 dsz = msg_data_sz(hdr); |
1370 | u32 max_pkt,fragm_sz,rest; | 1370 | u32 max_pkt,fragm_sz,rest; |
@@ -1636,7 +1636,7 @@ void tipc_link_push_queue(struct link *l_ptr) | |||
1636 | 1636 | ||
1637 | static void link_reset_all(unsigned long addr) | 1637 | static void link_reset_all(unsigned long addr) |
1638 | { | 1638 | { |
1639 | struct node *n_ptr; | 1639 | struct tipc_node *n_ptr; |
1640 | char addr_string[16]; | 1640 | char addr_string[16]; |
1641 | u32 i; | 1641 | u32 i; |
1642 | 1642 | ||
@@ -1682,7 +1682,7 @@ static void link_retransmit_failure(struct link *l_ptr, struct sk_buff *buf) | |||
1682 | 1682 | ||
1683 | /* Handle failure on broadcast link */ | 1683 | /* Handle failure on broadcast link */ |
1684 | 1684 | ||
1685 | struct node *n_ptr; | 1685 | struct tipc_node *n_ptr; |
1686 | char addr_string[16]; | 1686 | char addr_string[16]; |
1687 | 1687 | ||
1688 | tipc_printf(TIPC_OUTPUT, "Msg seq number: %u, ", msg_seqno(msg)); | 1688 | tipc_printf(TIPC_OUTPUT, "Msg seq number: %u, ", msg_seqno(msg)); |
@@ -1843,7 +1843,7 @@ void tipc_recv_msg(struct sk_buff *head, struct tipc_bearer *tb_ptr) | |||
1843 | read_lock_bh(&tipc_net_lock); | 1843 | read_lock_bh(&tipc_net_lock); |
1844 | while (head) { | 1844 | while (head) { |
1845 | struct bearer *b_ptr = (struct bearer *)tb_ptr; | 1845 | struct bearer *b_ptr = (struct bearer *)tb_ptr; |
1846 | struct node *n_ptr; | 1846 | struct tipc_node *n_ptr; |
1847 | struct link *l_ptr; | 1847 | struct link *l_ptr; |
1848 | struct sk_buff *crs; | 1848 | struct sk_buff *crs; |
1849 | struct sk_buff *buf = head; | 1849 | struct sk_buff *buf = head; |
@@ -2935,7 +2935,7 @@ void tipc_link_set_queue_limits(struct link *l_ptr, u32 window) | |||
2935 | * Returns pointer to link (or 0 if invalid link name). | 2935 | * Returns pointer to link (or 0 if invalid link name). |
2936 | */ | 2936 | */ |
2937 | 2937 | ||
2938 | static struct link *link_find_link(const char *name, struct node **node) | 2938 | static struct link *link_find_link(const char *name, struct tipc_node **node) |
2939 | { | 2939 | { |
2940 | struct link_name link_name_parts; | 2940 | struct link_name link_name_parts; |
2941 | struct bearer *b_ptr; | 2941 | struct bearer *b_ptr; |
@@ -2965,7 +2965,7 @@ struct sk_buff *tipc_link_cmd_config(const void *req_tlv_area, int req_tlv_space | |||
2965 | struct tipc_link_config *args; | 2965 | struct tipc_link_config *args; |
2966 | u32 new_value; | 2966 | u32 new_value; |
2967 | struct link *l_ptr; | 2967 | struct link *l_ptr; |
2968 | struct node *node; | 2968 | struct tipc_node *node; |
2969 | int res; | 2969 | int res; |
2970 | 2970 | ||
2971 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) | 2971 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_CONFIG)) |
@@ -3043,7 +3043,7 @@ struct sk_buff *tipc_link_cmd_reset_stats(const void *req_tlv_area, int req_tlv_ | |||
3043 | { | 3043 | { |
3044 | char *link_name; | 3044 | char *link_name; |
3045 | struct link *l_ptr; | 3045 | struct link *l_ptr; |
3046 | struct node *node; | 3046 | struct tipc_node *node; |
3047 | 3047 | ||
3048 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) | 3048 | if (!TLV_CHECK(req_tlv_area, req_tlv_space, TIPC_TLV_LINK_NAME)) |
3049 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); | 3049 | return tipc_cfg_reply_error_string(TIPC_CFG_TLV_ERROR); |
@@ -3091,7 +3091,7 @@ static int tipc_link_stats(const char *name, char *buf, const u32 buf_size) | |||
3091 | { | 3091 | { |
3092 | struct print_buf pb; | 3092 | struct print_buf pb; |
3093 | struct link *l_ptr; | 3093 | struct link *l_ptr; |
3094 | struct node *node; | 3094 | struct tipc_node *node; |
3095 | char *status; | 3095 | char *status; |
3096 | u32 profile_total = 0; | 3096 | u32 profile_total = 0; |
3097 | 3097 | ||
@@ -3207,7 +3207,7 @@ int link_control(const char *name, u32 op, u32 val) | |||
3207 | int res = -EINVAL; | 3207 | int res = -EINVAL; |
3208 | struct link *l_ptr; | 3208 | struct link *l_ptr; |
3209 | u32 bearer_id; | 3209 | u32 bearer_id; |
3210 | struct node * node; | 3210 | struct tipc_node * node; |
3211 | u32 a; | 3211 | u32 a; |
3212 | 3212 | ||
3213 | a = link_name2addr(name, &bearer_id); | 3213 | a = link_name2addr(name, &bearer_id); |
@@ -3249,7 +3249,7 @@ int link_control(const char *name, u32 op, u32 val) | |||
3249 | 3249 | ||
3250 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) | 3250 | u32 tipc_link_get_max_pkt(u32 dest, u32 selector) |
3251 | { | 3251 | { |
3252 | struct node *n_ptr; | 3252 | struct tipc_node *n_ptr; |
3253 | struct link *l_ptr; | 3253 | struct link *l_ptr; |
3254 | u32 res = MAX_PKT_DEFAULT; | 3254 | u32 res = MAX_PKT_DEFAULT; |
3255 | 3255 | ||
diff --git a/net/tipc/link.h b/net/tipc/link.h index 52f3e7c1871f..6a51e38ad25c 100644 --- a/net/tipc/link.h +++ b/net/tipc/link.h | |||
@@ -116,7 +116,7 @@ struct link { | |||
116 | char name[TIPC_MAX_LINK_NAME]; | 116 | char name[TIPC_MAX_LINK_NAME]; |
117 | struct tipc_media_addr media_addr; | 117 | struct tipc_media_addr media_addr; |
118 | struct timer_list timer; | 118 | struct timer_list timer; |
119 | struct node *owner; | 119 | struct tipc_node *owner; |
120 | struct list_head link_list; | 120 | struct list_head link_list; |
121 | 121 | ||
122 | /* Management and link supervision data */ | 122 | /* Management and link supervision data */ |
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h index b9e7cd336d76..139882d4ed00 100644 --- a/net/tipc/name_table.h +++ b/net/tipc/name_table.h | |||
@@ -76,7 +76,7 @@ struct publication { | |||
76 | u32 node; | 76 | u32 node; |
77 | u32 ref; | 77 | u32 ref; |
78 | u32 key; | 78 | u32 key; |
79 | struct node_subscr subscr; | 79 | struct tipc_node_subscr subscr; |
80 | struct list_head local_list; | 80 | struct list_head local_list; |
81 | struct list_head pport_list; | 81 | struct list_head pport_list; |
82 | struct publication *node_list_next; | 82 | struct publication *node_list_next; |
diff --git a/net/tipc/net.c b/net/tipc/net.c index ec7b04fbdc43..7906608bf510 100644 --- a/net/tipc/net.c +++ b/net/tipc/net.c | |||
@@ -118,7 +118,7 @@ | |||
118 | DEFINE_RWLOCK(tipc_net_lock); | 118 | DEFINE_RWLOCK(tipc_net_lock); |
119 | struct network tipc_net = { NULL }; | 119 | struct network tipc_net = { NULL }; |
120 | 120 | ||
121 | struct node *tipc_net_select_remote_node(u32 addr, u32 ref) | 121 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref) |
122 | { | 122 | { |
123 | return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref); | 123 | return tipc_zone_select_remote_node(tipc_net.zones[tipc_zone(addr)], addr, ref); |
124 | } | 124 | } |
diff --git a/net/tipc/net.h b/net/tipc/net.h index d154ac2bda9a..de2b9ad8f646 100644 --- a/net/tipc/net.h +++ b/net/tipc/net.h | |||
@@ -55,7 +55,7 @@ extern rwlock_t tipc_net_lock; | |||
55 | void tipc_net_remove_as_router(u32 router); | 55 | void tipc_net_remove_as_router(u32 router); |
56 | void tipc_net_send_external_routes(u32 dest); | 56 | void tipc_net_send_external_routes(u32 dest); |
57 | void tipc_net_route_msg(struct sk_buff *buf); | 57 | void tipc_net_route_msg(struct sk_buff *buf); |
58 | struct node *tipc_net_select_remote_node(u32 addr, u32 ref); | 58 | struct tipc_node *tipc_net_select_remote_node(u32 addr, u32 ref); |
59 | u32 tipc_net_select_router(u32 addr, u32 ref); | 59 | u32 tipc_net_select_router(u32 addr, u32 ref); |
60 | 60 | ||
61 | int tipc_net_start(u32 addr); | 61 | int tipc_net_start(u32 addr); |
diff --git a/net/tipc/node.c b/net/tipc/node.c index ee952ad60218..20d98c56e152 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c | |||
@@ -46,11 +46,11 @@ | |||
46 | #include "bearer.h" | 46 | #include "bearer.h" |
47 | #include "name_distr.h" | 47 | #include "name_distr.h" |
48 | 48 | ||
49 | void node_print(struct print_buf *buf, struct node *n_ptr, char *str); | 49 | void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str); |
50 | static void node_lost_contact(struct node *n_ptr); | 50 | static void node_lost_contact(struct tipc_node *n_ptr); |
51 | static void node_established_contact(struct node *n_ptr); | 51 | static void node_established_contact(struct tipc_node *n_ptr); |
52 | 52 | ||
53 | struct node *tipc_nodes = NULL; /* sorted list of nodes within cluster */ | 53 | struct tipc_node *tipc_nodes = NULL; /* sorted list of nodes within cluster */ |
54 | 54 | ||
55 | static DEFINE_SPINLOCK(node_create_lock); | 55 | static DEFINE_SPINLOCK(node_create_lock); |
56 | 56 | ||
@@ -66,11 +66,11 @@ u32 tipc_own_tag = 0; | |||
66 | * but this is a non-trivial change.) | 66 | * but this is a non-trivial change.) |
67 | */ | 67 | */ |
68 | 68 | ||
69 | struct node *tipc_node_create(u32 addr) | 69 | struct tipc_node *tipc_node_create(u32 addr) |
70 | { | 70 | { |
71 | struct cluster *c_ptr; | 71 | struct cluster *c_ptr; |
72 | struct node *n_ptr; | 72 | struct tipc_node *n_ptr; |
73 | struct node **curr_node; | 73 | struct tipc_node **curr_node; |
74 | 74 | ||
75 | spin_lock_bh(&node_create_lock); | 75 | spin_lock_bh(&node_create_lock); |
76 | 76 | ||
@@ -120,7 +120,7 @@ struct node *tipc_node_create(u32 addr) | |||
120 | return n_ptr; | 120 | return n_ptr; |
121 | } | 121 | } |
122 | 122 | ||
123 | void tipc_node_delete(struct node *n_ptr) | 123 | void tipc_node_delete(struct tipc_node *n_ptr) |
124 | { | 124 | { |
125 | if (!n_ptr) | 125 | if (!n_ptr) |
126 | return; | 126 | return; |
@@ -146,7 +146,7 @@ void tipc_node_delete(struct node *n_ptr) | |||
146 | * Link becomes active (alone or shared) or standby, depending on its priority. | 146 | * Link becomes active (alone or shared) or standby, depending on its priority. |
147 | */ | 147 | */ |
148 | 148 | ||
149 | void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr) | 149 | void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr) |
150 | { | 150 | { |
151 | struct link **active = &n_ptr->active_links[0]; | 151 | struct link **active = &n_ptr->active_links[0]; |
152 | 152 | ||
@@ -180,7 +180,7 @@ void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr) | |||
180 | * node_select_active_links - select active link | 180 | * node_select_active_links - select active link |
181 | */ | 181 | */ |
182 | 182 | ||
183 | static void node_select_active_links(struct node *n_ptr) | 183 | static void node_select_active_links(struct tipc_node *n_ptr) |
184 | { | 184 | { |
185 | struct link **active = &n_ptr->active_links[0]; | 185 | struct link **active = &n_ptr->active_links[0]; |
186 | u32 i; | 186 | u32 i; |
@@ -208,7 +208,7 @@ static void node_select_active_links(struct node *n_ptr) | |||
208 | * tipc_node_link_down - handle loss of link | 208 | * tipc_node_link_down - handle loss of link |
209 | */ | 209 | */ |
210 | 210 | ||
211 | void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr) | 211 | void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr) |
212 | { | 212 | { |
213 | struct link **active; | 213 | struct link **active; |
214 | 214 | ||
@@ -235,30 +235,30 @@ void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr) | |||
235 | node_lost_contact(n_ptr); | 235 | node_lost_contact(n_ptr); |
236 | } | 236 | } |
237 | 237 | ||
238 | int tipc_node_has_active_links(struct node *n_ptr) | 238 | int tipc_node_has_active_links(struct tipc_node *n_ptr) |
239 | { | 239 | { |
240 | return (n_ptr && | 240 | return (n_ptr && |
241 | ((n_ptr->active_links[0]) || (n_ptr->active_links[1]))); | 241 | ((n_ptr->active_links[0]) || (n_ptr->active_links[1]))); |
242 | } | 242 | } |
243 | 243 | ||
244 | int tipc_node_has_redundant_links(struct node *n_ptr) | 244 | int tipc_node_has_redundant_links(struct tipc_node *n_ptr) |
245 | { | 245 | { |
246 | return (n_ptr->working_links > 1); | 246 | return (n_ptr->working_links > 1); |
247 | } | 247 | } |
248 | 248 | ||
249 | static int tipc_node_has_active_routes(struct node *n_ptr) | 249 | static int tipc_node_has_active_routes(struct tipc_node *n_ptr) |
250 | { | 250 | { |
251 | return (n_ptr && (n_ptr->last_router >= 0)); | 251 | return (n_ptr && (n_ptr->last_router >= 0)); |
252 | } | 252 | } |
253 | 253 | ||
254 | int tipc_node_is_up(struct node *n_ptr) | 254 | int tipc_node_is_up(struct tipc_node *n_ptr) |
255 | { | 255 | { |
256 | return (tipc_node_has_active_links(n_ptr) || tipc_node_has_active_routes(n_ptr)); | 256 | return (tipc_node_has_active_links(n_ptr) || tipc_node_has_active_routes(n_ptr)); |
257 | } | 257 | } |
258 | 258 | ||
259 | struct node *tipc_node_attach_link(struct link *l_ptr) | 259 | struct tipc_node *tipc_node_attach_link(struct link *l_ptr) |
260 | { | 260 | { |
261 | struct node *n_ptr = tipc_node_find(l_ptr->addr); | 261 | struct tipc_node *n_ptr = tipc_node_find(l_ptr->addr); |
262 | 262 | ||
263 | if (!n_ptr) | 263 | if (!n_ptr) |
264 | n_ptr = tipc_node_create(l_ptr->addr); | 264 | n_ptr = tipc_node_create(l_ptr->addr); |
@@ -285,7 +285,7 @@ struct node *tipc_node_attach_link(struct link *l_ptr) | |||
285 | return NULL; | 285 | return NULL; |
286 | } | 286 | } |
287 | 287 | ||
288 | void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr) | 288 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr) |
289 | { | 289 | { |
290 | n_ptr->links[l_ptr->b_ptr->identity] = NULL; | 290 | n_ptr->links[l_ptr->b_ptr->identity] = NULL; |
291 | tipc_net.zones[tipc_zone(l_ptr->addr)]->links--; | 291 | tipc_net.zones[tipc_zone(l_ptr->addr)]->links--; |
@@ -338,7 +338,7 @@ void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr) | |||
338 | * | 338 | * |
339 | */ | 339 | */ |
340 | 340 | ||
341 | static void node_established_contact(struct node *n_ptr) | 341 | static void node_established_contact(struct tipc_node *n_ptr) |
342 | { | 342 | { |
343 | struct cluster *c_ptr; | 343 | struct cluster *c_ptr; |
344 | 344 | ||
@@ -384,10 +384,10 @@ static void node_established_contact(struct node *n_ptr) | |||
384 | tipc_highest_allowed_slave); | 384 | tipc_highest_allowed_slave); |
385 | } | 385 | } |
386 | 386 | ||
387 | static void node_lost_contact(struct node *n_ptr) | 387 | static void node_lost_contact(struct tipc_node *n_ptr) |
388 | { | 388 | { |
389 | struct cluster *c_ptr; | 389 | struct cluster *c_ptr; |
390 | struct node_subscr *ns, *tns; | 390 | struct tipc_node_subscr *ns, *tns; |
391 | char addr_string[16]; | 391 | char addr_string[16]; |
392 | u32 i; | 392 | u32 i; |
393 | 393 | ||
@@ -466,9 +466,9 @@ static void node_lost_contact(struct node *n_ptr) | |||
466 | * Called by when cluster local lookup has failed. | 466 | * Called by when cluster local lookup has failed. |
467 | */ | 467 | */ |
468 | 468 | ||
469 | struct node *tipc_node_select_next_hop(u32 addr, u32 selector) | 469 | struct tipc_node *tipc_node_select_next_hop(u32 addr, u32 selector) |
470 | { | 470 | { |
471 | struct node *n_ptr; | 471 | struct tipc_node *n_ptr; |
472 | u32 router_addr; | 472 | u32 router_addr; |
473 | 473 | ||
474 | if (!tipc_addr_domain_valid(addr)) | 474 | if (!tipc_addr_domain_valid(addr)) |
@@ -513,7 +513,7 @@ struct node *tipc_node_select_next_hop(u32 addr, u32 selector) | |||
513 | * Uses a deterministic and fair algorithm for selecting router node. | 513 | * Uses a deterministic and fair algorithm for selecting router node. |
514 | */ | 514 | */ |
515 | 515 | ||
516 | u32 tipc_node_select_router(struct node *n_ptr, u32 ref) | 516 | u32 tipc_node_select_router(struct tipc_node *n_ptr, u32 ref) |
517 | { | 517 | { |
518 | u32 ulim; | 518 | u32 ulim; |
519 | u32 mask; | 519 | u32 mask; |
@@ -551,7 +551,7 @@ u32 tipc_node_select_router(struct node *n_ptr, u32 ref) | |||
551 | return tipc_addr(own_zone(), own_cluster(), r); | 551 | return tipc_addr(own_zone(), own_cluster(), r); |
552 | } | 552 | } |
553 | 553 | ||
554 | void tipc_node_add_router(struct node *n_ptr, u32 router) | 554 | void tipc_node_add_router(struct tipc_node *n_ptr, u32 router) |
555 | { | 555 | { |
556 | u32 r_num = tipc_node(router); | 556 | u32 r_num = tipc_node(router); |
557 | 557 | ||
@@ -562,7 +562,7 @@ void tipc_node_add_router(struct node *n_ptr, u32 router) | |||
562 | !n_ptr->routers[n_ptr->last_router]); | 562 | !n_ptr->routers[n_ptr->last_router]); |
563 | } | 563 | } |
564 | 564 | ||
565 | void tipc_node_remove_router(struct node *n_ptr, u32 router) | 565 | void tipc_node_remove_router(struct tipc_node *n_ptr, u32 router) |
566 | { | 566 | { |
567 | u32 r_num = tipc_node(router); | 567 | u32 r_num = tipc_node(router); |
568 | 568 | ||
@@ -580,7 +580,7 @@ void tipc_node_remove_router(struct node *n_ptr, u32 router) | |||
580 | } | 580 | } |
581 | 581 | ||
582 | #if 0 | 582 | #if 0 |
583 | void node_print(struct print_buf *buf, struct node *n_ptr, char *str) | 583 | void node_print(struct print_buf *buf, struct tipc_node *n_ptr, char *str) |
584 | { | 584 | { |
585 | u32 i; | 585 | u32 i; |
586 | 586 | ||
@@ -597,7 +597,7 @@ void node_print(struct print_buf *buf, struct node *n_ptr, char *str) | |||
597 | 597 | ||
598 | u32 tipc_available_nodes(const u32 domain) | 598 | u32 tipc_available_nodes(const u32 domain) |
599 | { | 599 | { |
600 | struct node *n_ptr; | 600 | struct tipc_node *n_ptr; |
601 | u32 cnt = 0; | 601 | u32 cnt = 0; |
602 | 602 | ||
603 | read_lock_bh(&tipc_net_lock); | 603 | read_lock_bh(&tipc_net_lock); |
@@ -615,7 +615,7 @@ struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space) | |||
615 | { | 615 | { |
616 | u32 domain; | 616 | u32 domain; |
617 | struct sk_buff *buf; | 617 | struct sk_buff *buf; |
618 | struct node *n_ptr; | 618 | struct tipc_node *n_ptr; |
619 | struct tipc_node_info node_info; | 619 | struct tipc_node_info node_info; |
620 | u32 payload_size; | 620 | u32 payload_size; |
621 | 621 | ||
@@ -667,7 +667,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space) | |||
667 | { | 667 | { |
668 | u32 domain; | 668 | u32 domain; |
669 | struct sk_buff *buf; | 669 | struct sk_buff *buf; |
670 | struct node *n_ptr; | 670 | struct tipc_node *n_ptr; |
671 | struct tipc_link_info link_info; | 671 | struct tipc_link_info link_info; |
672 | u32 payload_size; | 672 | u32 payload_size; |
673 | 673 | ||
diff --git a/net/tipc/node.h b/net/tipc/node.h index cd1882654bbb..6f990da5d143 100644 --- a/net/tipc/node.h +++ b/net/tipc/node.h | |||
@@ -43,7 +43,7 @@ | |||
43 | #include "bearer.h" | 43 | #include "bearer.h" |
44 | 44 | ||
45 | /** | 45 | /** |
46 | * struct node - TIPC node structure | 46 | * struct tipc_node - TIPC node structure |
47 | * @addr: network address of node | 47 | * @addr: network address of node |
48 | * @lock: spinlock governing access to structure | 48 | * @lock: spinlock governing access to structure |
49 | * @owner: pointer to cluster that node belongs to | 49 | * @owner: pointer to cluster that node belongs to |
@@ -68,11 +68,11 @@ | |||
68 | * @defragm: list of partially reassembled b'cast message fragments from node | 68 | * @defragm: list of partially reassembled b'cast message fragments from node |
69 | */ | 69 | */ |
70 | 70 | ||
71 | struct node { | 71 | struct tipc_node { |
72 | u32 addr; | 72 | u32 addr; |
73 | spinlock_t lock; | 73 | spinlock_t lock; |
74 | struct cluster *owner; | 74 | struct cluster *owner; |
75 | struct node *next; | 75 | struct tipc_node *next; |
76 | struct list_head nsub; | 76 | struct list_head nsub; |
77 | struct link *active_links[2]; | 77 | struct link *active_links[2]; |
78 | struct link *links[MAX_BEARERS]; | 78 | struct link *links[MAX_BEARERS]; |
@@ -94,26 +94,26 @@ struct node { | |||
94 | } bclink; | 94 | } bclink; |
95 | }; | 95 | }; |
96 | 96 | ||
97 | extern struct node *tipc_nodes; | 97 | extern struct tipc_node *tipc_nodes; |
98 | extern u32 tipc_own_tag; | 98 | extern u32 tipc_own_tag; |
99 | 99 | ||
100 | struct node *tipc_node_create(u32 addr); | 100 | struct tipc_node *tipc_node_create(u32 addr); |
101 | void tipc_node_delete(struct node *n_ptr); | 101 | void tipc_node_delete(struct tipc_node *n_ptr); |
102 | struct node *tipc_node_attach_link(struct link *l_ptr); | 102 | struct tipc_node *tipc_node_attach_link(struct link *l_ptr); |
103 | void tipc_node_detach_link(struct node *n_ptr, struct link *l_ptr); | 103 | void tipc_node_detach_link(struct tipc_node *n_ptr, struct link *l_ptr); |
104 | void tipc_node_link_down(struct node *n_ptr, struct link *l_ptr); | 104 | void tipc_node_link_down(struct tipc_node *n_ptr, struct link *l_ptr); |
105 | void tipc_node_link_up(struct node *n_ptr, struct link *l_ptr); | 105 | void tipc_node_link_up(struct tipc_node *n_ptr, struct link *l_ptr); |
106 | int tipc_node_has_active_links(struct node *n_ptr); | 106 | int tipc_node_has_active_links(struct tipc_node *n_ptr); |
107 | int tipc_node_has_redundant_links(struct node *n_ptr); | 107 | int tipc_node_has_redundant_links(struct tipc_node *n_ptr); |
108 | u32 tipc_node_select_router(struct node *n_ptr, u32 ref); | 108 | u32 tipc_node_select_router(struct tipc_node *n_ptr, u32 ref); |
109 | struct node *tipc_node_select_next_hop(u32 addr, u32 selector); | 109 | struct tipc_node *tipc_node_select_next_hop(u32 addr, u32 selector); |
110 | int tipc_node_is_up(struct node *n_ptr); | 110 | int tipc_node_is_up(struct tipc_node *n_ptr); |
111 | void tipc_node_add_router(struct node *n_ptr, u32 router); | 111 | void tipc_node_add_router(struct tipc_node *n_ptr, u32 router); |
112 | void tipc_node_remove_router(struct node *n_ptr, u32 router); | 112 | void tipc_node_remove_router(struct tipc_node *n_ptr, u32 router); |
113 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); | 113 | struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space); |
114 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); | 114 | struct sk_buff *tipc_node_get_nodes(const void *req_tlv_area, int req_tlv_space); |
115 | 115 | ||
116 | static inline struct node *tipc_node_find(u32 addr) | 116 | static inline struct tipc_node *tipc_node_find(u32 addr) |
117 | { | 117 | { |
118 | if (likely(in_own_cluster(addr))) | 118 | if (likely(in_own_cluster(addr))) |
119 | return tipc_local_nodes[tipc_node(addr)]; | 119 | return tipc_local_nodes[tipc_node(addr)]; |
@@ -126,19 +126,19 @@ static inline struct node *tipc_node_find(u32 addr) | |||
126 | return NULL; | 126 | return NULL; |
127 | } | 127 | } |
128 | 128 | ||
129 | static inline struct node *tipc_node_select(u32 addr, u32 selector) | 129 | static inline struct tipc_node *tipc_node_select(u32 addr, u32 selector) |
130 | { | 130 | { |
131 | if (likely(in_own_cluster(addr))) | 131 | if (likely(in_own_cluster(addr))) |
132 | return tipc_local_nodes[tipc_node(addr)]; | 132 | return tipc_local_nodes[tipc_node(addr)]; |
133 | return tipc_node_select_next_hop(addr, selector); | 133 | return tipc_node_select_next_hop(addr, selector); |
134 | } | 134 | } |
135 | 135 | ||
136 | static inline void tipc_node_lock(struct node *n_ptr) | 136 | static inline void tipc_node_lock(struct tipc_node *n_ptr) |
137 | { | 137 | { |
138 | spin_lock_bh(&n_ptr->lock); | 138 | spin_lock_bh(&n_ptr->lock); |
139 | } | 139 | } |
140 | 140 | ||
141 | static inline void tipc_node_unlock(struct node *n_ptr) | 141 | static inline void tipc_node_unlock(struct tipc_node *n_ptr) |
142 | { | 142 | { |
143 | spin_unlock_bh(&n_ptr->lock); | 143 | spin_unlock_bh(&n_ptr->lock); |
144 | } | 144 | } |
diff --git a/net/tipc/node_subscr.c b/net/tipc/node_subscr.c index 8ecbd0fb6103..19194d476a9e 100644 --- a/net/tipc/node_subscr.c +++ b/net/tipc/node_subscr.c | |||
@@ -44,7 +44,7 @@ | |||
44 | * tipc_nodesub_subscribe - create "node down" subscription for specified node | 44 | * tipc_nodesub_subscribe - create "node down" subscription for specified node |
45 | */ | 45 | */ |
46 | 46 | ||
47 | void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr, | 47 | void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr, |
48 | void *usr_handle, net_ev_handler handle_down) | 48 | void *usr_handle, net_ev_handler handle_down) |
49 | { | 49 | { |
50 | if (addr == tipc_own_addr) { | 50 | if (addr == tipc_own_addr) { |
@@ -69,7 +69,7 @@ void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr, | |||
69 | * tipc_nodesub_unsubscribe - cancel "node down" subscription (if any) | 69 | * tipc_nodesub_unsubscribe - cancel "node down" subscription (if any) |
70 | */ | 70 | */ |
71 | 71 | ||
72 | void tipc_nodesub_unsubscribe(struct node_subscr *node_sub) | 72 | void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub) |
73 | { | 73 | { |
74 | if (!node_sub->node) | 74 | if (!node_sub->node) |
75 | return; | 75 | return; |
diff --git a/net/tipc/node_subscr.h b/net/tipc/node_subscr.h index 5f3f5859b84c..006ed739f515 100644 --- a/net/tipc/node_subscr.h +++ b/net/tipc/node_subscr.h | |||
@@ -42,22 +42,22 @@ | |||
42 | typedef void (*net_ev_handler) (void *usr_handle); | 42 | typedef void (*net_ev_handler) (void *usr_handle); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * struct node_subscr - "node down" subscription entry | 45 | * struct tipc_node_subscr - "node down" subscription entry |
46 | * @node: ptr to node structure of interest (or NULL, if none) | 46 | * @node: ptr to node structure of interest (or NULL, if none) |
47 | * @handle_node_down: routine to invoke when node fails | 47 | * @handle_node_down: routine to invoke when node fails |
48 | * @usr_handle: argument to pass to routine when node fails | 48 | * @usr_handle: argument to pass to routine when node fails |
49 | * @nodesub_list: adjacent entries in list of subscriptions for the node | 49 | * @nodesub_list: adjacent entries in list of subscriptions for the node |
50 | */ | 50 | */ |
51 | 51 | ||
52 | struct node_subscr { | 52 | struct tipc_node_subscr { |
53 | struct node *node; | 53 | struct tipc_node *node; |
54 | net_ev_handler handle_node_down; | 54 | net_ev_handler handle_node_down; |
55 | void *usr_handle; | 55 | void *usr_handle; |
56 | struct list_head nodesub_list; | 56 | struct list_head nodesub_list; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | void tipc_nodesub_subscribe(struct node_subscr *node_sub, u32 addr, | 59 | void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr, |
60 | void *usr_handle, net_ev_handler handle_down); | 60 | void *usr_handle, net_ev_handler handle_down); |
61 | void tipc_nodesub_unsubscribe(struct node_subscr *node_sub); | 61 | void tipc_nodesub_unsubscribe(struct tipc_node_subscr *node_sub); |
62 | 62 | ||
63 | #endif | 63 | #endif |
diff --git a/net/tipc/port.h b/net/tipc/port.h index e5f8c16429bd..ff31ee4a1dc3 100644 --- a/net/tipc/port.h +++ b/net/tipc/port.h | |||
@@ -105,7 +105,7 @@ struct port { | |||
105 | u32 probing_interval; | 105 | u32 probing_interval; |
106 | u32 last_in_seqno; | 106 | u32 last_in_seqno; |
107 | struct timer_list timer; | 107 | struct timer_list timer; |
108 | struct node_subscr subscription; | 108 | struct tipc_node_subscr subscription; |
109 | }; | 109 | }; |
110 | 110 | ||
111 | extern spinlock_t tipc_port_list_lock; | 111 | extern spinlock_t tipc_port_list_lock; |
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 0326d3060bc7..0747d8a9232f 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c | |||
@@ -85,7 +85,7 @@ static struct top_srv topsrv = { 0 }; | |||
85 | 85 | ||
86 | static u32 htohl(u32 in, int swap) | 86 | static u32 htohl(u32 in, int swap) |
87 | { | 87 | { |
88 | return swap ? (u32)___constant_swab32(in) : in; | 88 | return swap ? swab32(in) : in; |
89 | } | 89 | } |
90 | 90 | ||
91 | /** | 91 | /** |
diff --git a/net/tipc/zone.c b/net/tipc/zone.c index 3506f8563441..2c01ba2d86bf 100644 --- a/net/tipc/zone.c +++ b/net/tipc/zone.c | |||
@@ -111,10 +111,10 @@ void tipc_zone_send_external_routes(struct _zone *z_ptr, u32 dest) | |||
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | struct node *tipc_zone_select_remote_node(struct _zone *z_ptr, u32 addr, u32 ref) | 114 | struct tipc_node *tipc_zone_select_remote_node(struct _zone *z_ptr, u32 addr, u32 ref) |
115 | { | 115 | { |
116 | struct cluster *c_ptr; | 116 | struct cluster *c_ptr; |
117 | struct node *n_ptr; | 117 | struct tipc_node *n_ptr; |
118 | u32 c_num; | 118 | u32 c_num; |
119 | 119 | ||
120 | if (!z_ptr) | 120 | if (!z_ptr) |
diff --git a/net/tipc/zone.h b/net/tipc/zone.h index 6e7a08df8af5..7bdc3406ba9b 100644 --- a/net/tipc/zone.h +++ b/net/tipc/zone.h | |||
@@ -54,7 +54,7 @@ struct _zone { | |||
54 | u32 links; | 54 | u32 links; |
55 | }; | 55 | }; |
56 | 56 | ||
57 | struct node *tipc_zone_select_remote_node(struct _zone *z_ptr, u32 addr, u32 ref); | 57 | struct tipc_node *tipc_zone_select_remote_node(struct _zone *z_ptr, u32 addr, u32 ref); |
58 | u32 tipc_zone_select_router(struct _zone *z_ptr, u32 addr, u32 ref); | 58 | u32 tipc_zone_select_router(struct _zone *z_ptr, u32 addr, u32 ref); |
59 | void tipc_zone_remove_as_router(struct _zone *z_ptr, u32 router); | 59 | void tipc_zone_remove_as_router(struct _zone *z_ptr, u32 router); |
60 | void tipc_zone_send_external_routes(struct _zone *z_ptr, u32 dest); | 60 | void tipc_zone_send_external_routes(struct _zone *z_ptr, u32 dest); |
diff --git a/net/wanrouter/wanmain.c b/net/wanrouter/wanmain.c index b210a88d0960..7f07152bc109 100644 --- a/net/wanrouter/wanmain.c +++ b/net/wanrouter/wanmain.c | |||
@@ -57,7 +57,6 @@ | |||
57 | #include <linux/vmalloc.h> /* vmalloc, vfree */ | 57 | #include <linux/vmalloc.h> /* vmalloc, vfree */ |
58 | #include <asm/uaccess.h> /* copy_to/from_user */ | 58 | #include <asm/uaccess.h> /* copy_to/from_user */ |
59 | #include <linux/init.h> /* __initfunc et al. */ | 59 | #include <linux/init.h> /* __initfunc et al. */ |
60 | #include <net/syncppp.h> | ||
61 | 60 | ||
62 | #define KMEM_SAFETYZONE 8 | 61 | #define KMEM_SAFETYZONE 8 |
63 | 62 | ||
@@ -567,9 +566,6 @@ static int wanrouter_device_new_if(struct wan_device *wandev, | |||
567 | { | 566 | { |
568 | wanif_conf_t *cnf; | 567 | wanif_conf_t *cnf; |
569 | struct net_device *dev = NULL; | 568 | struct net_device *dev = NULL; |
570 | #ifdef CONFIG_WANPIPE_MULTPPP | ||
571 | struct ppp_device *pppdev=NULL; | ||
572 | #endif | ||
573 | int err; | 569 | int err; |
574 | 570 | ||
575 | if ((wandev->state == WAN_UNCONFIGURED) || (wandev->new_if == NULL)) | 571 | if ((wandev->state == WAN_UNCONFIGURED) || (wandev->new_if == NULL)) |
@@ -588,25 +584,10 @@ static int wanrouter_device_new_if(struct wan_device *wandev, | |||
588 | goto out; | 584 | goto out; |
589 | 585 | ||
590 | if (cnf->config_id == WANCONFIG_MPPP) { | 586 | if (cnf->config_id == WANCONFIG_MPPP) { |
591 | #ifdef CONFIG_WANPIPE_MULTPPP | ||
592 | pppdev = kzalloc(sizeof(struct ppp_device), GFP_KERNEL); | ||
593 | err = -ENOBUFS; | ||
594 | if (pppdev == NULL) | ||
595 | goto out; | ||
596 | pppdev->dev = kzalloc(sizeof(struct net_device), GFP_KERNEL); | ||
597 | if (pppdev->dev == NULL) { | ||
598 | kfree(pppdev); | ||
599 | err = -ENOBUFS; | ||
600 | goto out; | ||
601 | } | ||
602 | err = wandev->new_if(wandev, (struct net_device *)pppdev, cnf); | ||
603 | dev = pppdev->dev; | ||
604 | #else | ||
605 | printk(KERN_INFO "%s: Wanpipe Mulit-Port PPP support has not been compiled in!\n", | 587 | printk(KERN_INFO "%s: Wanpipe Mulit-Port PPP support has not been compiled in!\n", |
606 | wandev->name); | 588 | wandev->name); |
607 | err = -EPROTONOSUPPORT; | 589 | err = -EPROTONOSUPPORT; |
608 | goto out; | 590 | goto out; |
609 | #endif | ||
610 | } else { | 591 | } else { |
611 | dev = kzalloc(sizeof(struct net_device), GFP_KERNEL); | 592 | dev = kzalloc(sizeof(struct net_device), GFP_KERNEL); |
612 | err = -ENOBUFS; | 593 | err = -ENOBUFS; |
@@ -661,17 +642,9 @@ static int wanrouter_device_new_if(struct wan_device *wandev, | |||
661 | kfree(dev->priv); | 642 | kfree(dev->priv); |
662 | dev->priv = NULL; | 643 | dev->priv = NULL; |
663 | 644 | ||
664 | #ifdef CONFIG_WANPIPE_MULTPPP | ||
665 | if (cnf->config_id == WANCONFIG_MPPP) | ||
666 | kfree(pppdev); | ||
667 | else | ||
668 | kfree(dev); | ||
669 | #else | ||
670 | /* Sync PPP is disabled */ | 645 | /* Sync PPP is disabled */ |
671 | if (cnf->config_id != WANCONFIG_MPPP) | 646 | if (cnf->config_id != WANCONFIG_MPPP) |
672 | kfree(dev); | 647 | kfree(dev); |
673 | #endif | ||
674 | |||
675 | out: | 648 | out: |
676 | kfree(cnf); | 649 | kfree(cnf); |
677 | return err; | 650 | return err; |
diff --git a/net/wireless/Kconfig b/net/wireless/Kconfig index ab015c62d561..833b024f8f66 100644 --- a/net/wireless/Kconfig +++ b/net/wireless/Kconfig | |||
@@ -39,4 +39,5 @@ config WIRELESS_EXT_SYSFS | |||
39 | files in /sys/class/net/*/wireless/. The same information | 39 | files in /sys/class/net/*/wireless/. The same information |
40 | is available via the ioctls as well. | 40 | is available via the ioctls as well. |
41 | 41 | ||
42 | Say Y if you have programs using it (we don't know of any). | 42 | Say Y if you have programs using it, like old versions of |
43 | hal. | ||
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b7fefffd2d0d..59eb2cf42e5f 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -29,16 +29,16 @@ static struct genl_family nl80211_fam = { | |||
29 | }; | 29 | }; |
30 | 30 | ||
31 | /* internal helper: get drv and dev */ | 31 | /* internal helper: get drv and dev */ |
32 | static int get_drv_dev_by_info_ifindex(struct genl_info *info, | 32 | static int get_drv_dev_by_info_ifindex(struct nlattr **attrs, |
33 | struct cfg80211_registered_device **drv, | 33 | struct cfg80211_registered_device **drv, |
34 | struct net_device **dev) | 34 | struct net_device **dev) |
35 | { | 35 | { |
36 | int ifindex; | 36 | int ifindex; |
37 | 37 | ||
38 | if (!info->attrs[NL80211_ATTR_IFINDEX]) | 38 | if (!attrs[NL80211_ATTR_IFINDEX]) |
39 | return -EINVAL; | 39 | return -EINVAL; |
40 | 40 | ||
41 | ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]); | 41 | ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]); |
42 | *dev = dev_get_by_index(&init_net, ifindex); | 42 | *dev = dev_get_by_index(&init_net, ifindex); |
43 | if (!*dev) | 43 | if (!*dev) |
44 | return -ENODEV; | 44 | return -ENODEV; |
@@ -291,21 +291,31 @@ static int nl80211_dump_interface(struct sk_buff *skb, struct netlink_callback * | |||
291 | 291 | ||
292 | mutex_lock(&cfg80211_drv_mutex); | 292 | mutex_lock(&cfg80211_drv_mutex); |
293 | list_for_each_entry(dev, &cfg80211_drv_list, list) { | 293 | list_for_each_entry(dev, &cfg80211_drv_list, list) { |
294 | if (++wp_idx < wp_start) | 294 | if (wp_idx < wp_start) { |
295 | wp_idx++; | ||
295 | continue; | 296 | continue; |
297 | } | ||
296 | if_idx = 0; | 298 | if_idx = 0; |
297 | 299 | ||
298 | mutex_lock(&dev->devlist_mtx); | 300 | mutex_lock(&dev->devlist_mtx); |
299 | list_for_each_entry(wdev, &dev->netdev_list, list) { | 301 | list_for_each_entry(wdev, &dev->netdev_list, list) { |
300 | if (++if_idx < if_start) | 302 | if (if_idx < if_start) { |
303 | if_idx++; | ||
301 | continue; | 304 | continue; |
305 | } | ||
302 | if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, | 306 | if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, |
303 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | 307 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
304 | wdev->netdev) < 0) | 308 | wdev->netdev) < 0) { |
305 | break; | 309 | mutex_unlock(&dev->devlist_mtx); |
310 | goto out; | ||
311 | } | ||
312 | if_idx++; | ||
306 | } | 313 | } |
307 | mutex_unlock(&dev->devlist_mtx); | 314 | mutex_unlock(&dev->devlist_mtx); |
315 | |||
316 | wp_idx++; | ||
308 | } | 317 | } |
318 | out: | ||
309 | mutex_unlock(&cfg80211_drv_mutex); | 319 | mutex_unlock(&cfg80211_drv_mutex); |
310 | 320 | ||
311 | cb->args[0] = wp_idx; | 321 | cb->args[0] = wp_idx; |
@@ -321,7 +331,7 @@ static int nl80211_get_interface(struct sk_buff *skb, struct genl_info *info) | |||
321 | struct net_device *netdev; | 331 | struct net_device *netdev; |
322 | int err; | 332 | int err; |
323 | 333 | ||
324 | err = get_drv_dev_by_info_ifindex(info, &dev, &netdev); | 334 | err = get_drv_dev_by_info_ifindex(info->attrs, &dev, &netdev); |
325 | if (err) | 335 | if (err) |
326 | return err; | 336 | return err; |
327 | 337 | ||
@@ -392,7 +402,7 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info) | |||
392 | } else | 402 | } else |
393 | return -EINVAL; | 403 | return -EINVAL; |
394 | 404 | ||
395 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 405 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
396 | if (err) | 406 | if (err) |
397 | return err; | 407 | return err; |
398 | ifindex = dev->ifindex; | 408 | ifindex = dev->ifindex; |
@@ -477,7 +487,7 @@ static int nl80211_del_interface(struct sk_buff *skb, struct genl_info *info) | |||
477 | int ifindex, err; | 487 | int ifindex, err; |
478 | struct net_device *dev; | 488 | struct net_device *dev; |
479 | 489 | ||
480 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 490 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
481 | if (err) | 491 | if (err) |
482 | return err; | 492 | return err; |
483 | ifindex = dev->ifindex; | 493 | ifindex = dev->ifindex; |
@@ -545,7 +555,7 @@ static int nl80211_get_key(struct sk_buff *skb, struct genl_info *info) | |||
545 | if (info->attrs[NL80211_ATTR_MAC]) | 555 | if (info->attrs[NL80211_ATTR_MAC]) |
546 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); | 556 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); |
547 | 557 | ||
548 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 558 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
549 | if (err) | 559 | if (err) |
550 | return err; | 560 | return err; |
551 | 561 | ||
@@ -618,7 +628,7 @@ static int nl80211_set_key(struct sk_buff *skb, struct genl_info *info) | |||
618 | if (!info->attrs[NL80211_ATTR_KEY_DEFAULT]) | 628 | if (!info->attrs[NL80211_ATTR_KEY_DEFAULT]) |
619 | return -EINVAL; | 629 | return -EINVAL; |
620 | 630 | ||
621 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 631 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
622 | if (err) | 632 | if (err) |
623 | return err; | 633 | return err; |
624 | 634 | ||
@@ -699,7 +709,7 @@ static int nl80211_new_key(struct sk_buff *skb, struct genl_info *info) | |||
699 | return -EINVAL; | 709 | return -EINVAL; |
700 | } | 710 | } |
701 | 711 | ||
702 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 712 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
703 | if (err) | 713 | if (err) |
704 | return err; | 714 | return err; |
705 | 715 | ||
@@ -735,7 +745,7 @@ static int nl80211_del_key(struct sk_buff *skb, struct genl_info *info) | |||
735 | if (info->attrs[NL80211_ATTR_MAC]) | 745 | if (info->attrs[NL80211_ATTR_MAC]) |
736 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); | 746 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); |
737 | 747 | ||
738 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 748 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
739 | if (err) | 749 | if (err) |
740 | return err; | 750 | return err; |
741 | 751 | ||
@@ -764,7 +774,7 @@ static int nl80211_addset_beacon(struct sk_buff *skb, struct genl_info *info) | |||
764 | struct beacon_parameters params; | 774 | struct beacon_parameters params; |
765 | int haveinfo = 0; | 775 | int haveinfo = 0; |
766 | 776 | ||
767 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 777 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
768 | if (err) | 778 | if (err) |
769 | return err; | 779 | return err; |
770 | 780 | ||
@@ -843,7 +853,7 @@ static int nl80211_del_beacon(struct sk_buff *skb, struct genl_info *info) | |||
843 | int err; | 853 | int err; |
844 | struct net_device *dev; | 854 | struct net_device *dev; |
845 | 855 | ||
846 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 856 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
847 | if (err) | 857 | if (err) |
848 | return err; | 858 | return err; |
849 | 859 | ||
@@ -937,67 +947,78 @@ static int nl80211_send_station(struct sk_buff *msg, u32 pid, u32 seq, | |||
937 | } | 947 | } |
938 | 948 | ||
939 | static int nl80211_dump_station(struct sk_buff *skb, | 949 | static int nl80211_dump_station(struct sk_buff *skb, |
940 | struct netlink_callback *cb) | 950 | struct netlink_callback *cb) |
941 | { | 951 | { |
942 | int wp_idx = 0; | ||
943 | int if_idx = 0; | ||
944 | int sta_idx = cb->args[2]; | ||
945 | int wp_start = cb->args[0]; | ||
946 | int if_start = cb->args[1]; | ||
947 | struct station_info sinfo; | 952 | struct station_info sinfo; |
948 | struct cfg80211_registered_device *dev; | 953 | struct cfg80211_registered_device *dev; |
949 | struct wireless_dev *wdev; | 954 | struct net_device *netdev; |
950 | u8 mac_addr[ETH_ALEN]; | 955 | u8 mac_addr[ETH_ALEN]; |
956 | int ifidx = cb->args[0]; | ||
957 | int sta_idx = cb->args[1]; | ||
951 | int err; | 958 | int err; |
952 | int exit = 0; | ||
953 | 959 | ||
954 | /* TODO: filter by device */ | 960 | if (!ifidx) { |
955 | mutex_lock(&cfg80211_drv_mutex); | 961 | err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, |
956 | list_for_each_entry(dev, &cfg80211_drv_list, list) { | 962 | nl80211_fam.attrbuf, nl80211_fam.maxattr, |
957 | if (exit) | 963 | nl80211_policy); |
964 | if (err) | ||
965 | return err; | ||
966 | |||
967 | if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]) | ||
968 | return -EINVAL; | ||
969 | |||
970 | ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]); | ||
971 | if (!ifidx) | ||
972 | return -EINVAL; | ||
973 | } | ||
974 | |||
975 | netdev = dev_get_by_index(&init_net, ifidx); | ||
976 | if (!netdev) | ||
977 | return -ENODEV; | ||
978 | |||
979 | dev = cfg80211_get_dev_from_ifindex(ifidx); | ||
980 | if (IS_ERR(dev)) { | ||
981 | err = PTR_ERR(dev); | ||
982 | goto out_put_netdev; | ||
983 | } | ||
984 | |||
985 | if (!dev->ops->dump_station) { | ||
986 | err = -ENOSYS; | ||
987 | goto out_err; | ||
988 | } | ||
989 | |||
990 | rtnl_lock(); | ||
991 | |||
992 | while (1) { | ||
993 | err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx, | ||
994 | mac_addr, &sinfo); | ||
995 | if (err == -ENOENT) | ||
958 | break; | 996 | break; |
959 | if (++wp_idx < wp_start) | 997 | if (err) |
960 | continue; | 998 | goto out_err_rtnl; |
961 | if_idx = 0; | ||
962 | 999 | ||
963 | mutex_lock(&dev->devlist_mtx); | 1000 | if (nl80211_send_station(skb, |
964 | list_for_each_entry(wdev, &dev->netdev_list, list) { | 1001 | NETLINK_CB(cb->skb).pid, |
965 | if (exit) | 1002 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
966 | break; | 1003 | netdev, mac_addr, |
967 | if (++if_idx < if_start) | 1004 | &sinfo) < 0) |
968 | continue; | 1005 | goto out; |
969 | if (!dev->ops->dump_station) | ||
970 | continue; | ||
971 | 1006 | ||
972 | for (;; ++sta_idx) { | 1007 | sta_idx++; |
973 | rtnl_lock(); | ||
974 | err = dev->ops->dump_station(&dev->wiphy, | ||
975 | wdev->netdev, sta_idx, mac_addr, | ||
976 | &sinfo); | ||
977 | rtnl_unlock(); | ||
978 | if (err) { | ||
979 | sta_idx = 0; | ||
980 | break; | ||
981 | } | ||
982 | if (nl80211_send_station(skb, | ||
983 | NETLINK_CB(cb->skb).pid, | ||
984 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | ||
985 | wdev->netdev, mac_addr, | ||
986 | &sinfo) < 0) { | ||
987 | exit = 1; | ||
988 | break; | ||
989 | } | ||
990 | } | ||
991 | } | ||
992 | mutex_unlock(&dev->devlist_mtx); | ||
993 | } | 1008 | } |
994 | mutex_unlock(&cfg80211_drv_mutex); | ||
995 | 1009 | ||
996 | cb->args[0] = wp_idx; | ||
997 | cb->args[1] = if_idx; | ||
998 | cb->args[2] = sta_idx; | ||
999 | 1010 | ||
1000 | return skb->len; | 1011 | out: |
1012 | cb->args[1] = sta_idx; | ||
1013 | err = skb->len; | ||
1014 | out_err_rtnl: | ||
1015 | rtnl_unlock(); | ||
1016 | out_err: | ||
1017 | cfg80211_put_dev(dev); | ||
1018 | out_put_netdev: | ||
1019 | dev_put(netdev); | ||
1020 | |||
1021 | return err; | ||
1001 | } | 1022 | } |
1002 | 1023 | ||
1003 | static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) | 1024 | static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) |
@@ -1016,7 +1037,7 @@ static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) | |||
1016 | 1037 | ||
1017 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); | 1038 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1018 | 1039 | ||
1019 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 1040 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
1020 | if (err) | 1041 | if (err) |
1021 | return err; | 1042 | return err; |
1022 | 1043 | ||
@@ -1112,7 +1133,7 @@ static int nl80211_set_station(struct sk_buff *skb, struct genl_info *info) | |||
1112 | params.plink_action = | 1133 | params.plink_action = |
1113 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); | 1134 | nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); |
1114 | 1135 | ||
1115 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 1136 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
1116 | if (err) | 1137 | if (err) |
1117 | return err; | 1138 | return err; |
1118 | 1139 | ||
@@ -1172,7 +1193,7 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info) | |||
1172 | ¶ms.station_flags)) | 1193 | ¶ms.station_flags)) |
1173 | return -EINVAL; | 1194 | return -EINVAL; |
1174 | 1195 | ||
1175 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 1196 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
1176 | if (err) | 1197 | if (err) |
1177 | return err; | 1198 | return err; |
1178 | 1199 | ||
@@ -1207,7 +1228,7 @@ static int nl80211_del_station(struct sk_buff *skb, struct genl_info *info) | |||
1207 | if (info->attrs[NL80211_ATTR_MAC]) | 1228 | if (info->attrs[NL80211_ATTR_MAC]) |
1208 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); | 1229 | mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1209 | 1230 | ||
1210 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 1231 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
1211 | if (err) | 1232 | if (err) |
1212 | return err; | 1233 | return err; |
1213 | 1234 | ||
@@ -1277,68 +1298,78 @@ static int nl80211_send_mpath(struct sk_buff *msg, u32 pid, u32 seq, | |||
1277 | } | 1298 | } |
1278 | 1299 | ||
1279 | static int nl80211_dump_mpath(struct sk_buff *skb, | 1300 | static int nl80211_dump_mpath(struct sk_buff *skb, |
1280 | struct netlink_callback *cb) | 1301 | struct netlink_callback *cb) |
1281 | { | 1302 | { |
1282 | int wp_idx = 0; | ||
1283 | int if_idx = 0; | ||
1284 | int sta_idx = cb->args[2]; | ||
1285 | int wp_start = cb->args[0]; | ||
1286 | int if_start = cb->args[1]; | ||
1287 | struct mpath_info pinfo; | 1303 | struct mpath_info pinfo; |
1288 | struct cfg80211_registered_device *dev; | 1304 | struct cfg80211_registered_device *dev; |
1289 | struct wireless_dev *wdev; | 1305 | struct net_device *netdev; |
1290 | u8 dst[ETH_ALEN]; | 1306 | u8 dst[ETH_ALEN]; |
1291 | u8 next_hop[ETH_ALEN]; | 1307 | u8 next_hop[ETH_ALEN]; |
1308 | int ifidx = cb->args[0]; | ||
1309 | int path_idx = cb->args[1]; | ||
1292 | int err; | 1310 | int err; |
1293 | int exit = 0; | ||
1294 | 1311 | ||
1295 | /* TODO: filter by device */ | 1312 | if (!ifidx) { |
1296 | mutex_lock(&cfg80211_drv_mutex); | 1313 | err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, |
1297 | list_for_each_entry(dev, &cfg80211_drv_list, list) { | 1314 | nl80211_fam.attrbuf, nl80211_fam.maxattr, |
1298 | if (exit) | 1315 | nl80211_policy); |
1316 | if (err) | ||
1317 | return err; | ||
1318 | |||
1319 | if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]) | ||
1320 | return -EINVAL; | ||
1321 | |||
1322 | ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]); | ||
1323 | if (!ifidx) | ||
1324 | return -EINVAL; | ||
1325 | } | ||
1326 | |||
1327 | netdev = dev_get_by_index(&init_net, ifidx); | ||
1328 | if (!netdev) | ||
1329 | return -ENODEV; | ||
1330 | |||
1331 | dev = cfg80211_get_dev_from_ifindex(ifidx); | ||
1332 | if (IS_ERR(dev)) { | ||
1333 | err = PTR_ERR(dev); | ||
1334 | goto out_put_netdev; | ||
1335 | } | ||
1336 | |||
1337 | if (!dev->ops->dump_mpath) { | ||
1338 | err = -ENOSYS; | ||
1339 | goto out_err; | ||
1340 | } | ||
1341 | |||
1342 | rtnl_lock(); | ||
1343 | |||
1344 | while (1) { | ||
1345 | err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx, | ||
1346 | dst, next_hop, &pinfo); | ||
1347 | if (err == -ENOENT) | ||
1299 | break; | 1348 | break; |
1300 | if (++wp_idx < wp_start) | 1349 | if (err) |
1301 | continue; | 1350 | goto out_err_rtnl; |
1302 | if_idx = 0; | ||
1303 | 1351 | ||
1304 | mutex_lock(&dev->devlist_mtx); | 1352 | if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid, |
1305 | list_for_each_entry(wdev, &dev->netdev_list, list) { | 1353 | cb->nlh->nlmsg_seq, NLM_F_MULTI, |
1306 | if (exit) | 1354 | netdev, dst, next_hop, |
1307 | break; | 1355 | &pinfo) < 0) |
1308 | if (++if_idx < if_start) | 1356 | goto out; |
1309 | continue; | ||
1310 | if (!dev->ops->dump_mpath) | ||
1311 | continue; | ||
1312 | 1357 | ||
1313 | for (;; ++sta_idx) { | 1358 | path_idx++; |
1314 | rtnl_lock(); | ||
1315 | err = dev->ops->dump_mpath(&dev->wiphy, | ||
1316 | wdev->netdev, sta_idx, dst, | ||
1317 | next_hop, &pinfo); | ||
1318 | rtnl_unlock(); | ||
1319 | if (err) { | ||
1320 | sta_idx = 0; | ||
1321 | break; | ||
1322 | } | ||
1323 | if (nl80211_send_mpath(skb, | ||
1324 | NETLINK_CB(cb->skb).pid, | ||
1325 | cb->nlh->nlmsg_seq, NLM_F_MULTI, | ||
1326 | wdev->netdev, dst, next_hop, | ||
1327 | &pinfo) < 0) { | ||
1328 | exit = 1; | ||
1329 | break; | ||
1330 | } | ||
1331 | } | ||
1332 | } | ||
1333 | mutex_unlock(&dev->devlist_mtx); | ||
1334 | } | 1359 | } |
1335 | mutex_unlock(&cfg80211_drv_mutex); | ||
1336 | 1360 | ||
1337 | cb->args[0] = wp_idx; | ||
1338 | cb->args[1] = if_idx; | ||
1339 | cb->args[2] = sta_idx; | ||
1340 | 1361 | ||
1341 | return skb->len; | 1362 | out: |
1363 | cb->args[1] = path_idx; | ||
1364 | err = skb->len; | ||
1365 | out_err_rtnl: | ||
1366 | rtnl_unlock(); | ||
1367 | out_err: | ||
1368 | cfg80211_put_dev(dev); | ||
1369 | out_put_netdev: | ||
1370 | dev_put(netdev); | ||
1371 | |||
1372 | return err; | ||
1342 | } | 1373 | } |
1343 | 1374 | ||
1344 | static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info) | 1375 | static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info) |
@@ -1358,7 +1389,7 @@ static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info) | |||
1358 | 1389 | ||
1359 | dst = nla_data(info->attrs[NL80211_ATTR_MAC]); | 1390 | dst = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1360 | 1391 | ||
1361 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 1392 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
1362 | if (err) | 1393 | if (err) |
1363 | return err; | 1394 | return err; |
1364 | 1395 | ||
@@ -1411,7 +1442,7 @@ static int nl80211_set_mpath(struct sk_buff *skb, struct genl_info *info) | |||
1411 | dst = nla_data(info->attrs[NL80211_ATTR_MAC]); | 1442 | dst = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1412 | next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]); | 1443 | next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]); |
1413 | 1444 | ||
1414 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 1445 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
1415 | if (err) | 1446 | if (err) |
1416 | return err; | 1447 | return err; |
1417 | 1448 | ||
@@ -1446,7 +1477,7 @@ static int nl80211_new_mpath(struct sk_buff *skb, struct genl_info *info) | |||
1446 | dst = nla_data(info->attrs[NL80211_ATTR_MAC]); | 1477 | dst = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1447 | next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]); | 1478 | next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]); |
1448 | 1479 | ||
1449 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 1480 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
1450 | if (err) | 1481 | if (err) |
1451 | return err; | 1482 | return err; |
1452 | 1483 | ||
@@ -1475,7 +1506,7 @@ static int nl80211_del_mpath(struct sk_buff *skb, struct genl_info *info) | |||
1475 | if (info->attrs[NL80211_ATTR_MAC]) | 1506 | if (info->attrs[NL80211_ATTR_MAC]) |
1476 | dst = nla_data(info->attrs[NL80211_ATTR_MAC]); | 1507 | dst = nla_data(info->attrs[NL80211_ATTR_MAC]); |
1477 | 1508 | ||
1478 | err = get_drv_dev_by_info_ifindex(info, &drv, &dev); | 1509 | err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); |
1479 | if (err) | 1510 | if (err) |
1480 | return err; | 1511 | return err; |
1481 | 1512 | ||
diff --git a/net/wireless/wext.c b/net/wireless/wext.c index df5b3886c36b..d98ffb75119a 100644 --- a/net/wireless/wext.c +++ b/net/wireless/wext.c | |||
@@ -1277,6 +1277,7 @@ static int rtnetlink_fill_iwinfo(struct sk_buff *skb, struct net_device *dev, | |||
1277 | r->ifi_flags = dev_get_flags(dev); | 1277 | r->ifi_flags = dev_get_flags(dev); |
1278 | r->ifi_change = 0; /* Wireless changes don't affect those flags */ | 1278 | r->ifi_change = 0; /* Wireless changes don't affect those flags */ |
1279 | 1279 | ||
1280 | NLA_PUT_STRING(skb, IFLA_IFNAME, dev->name); | ||
1280 | /* Add the wireless events in the netlink packet */ | 1281 | /* Add the wireless events in the netlink packet */ |
1281 | NLA_PUT(skb, IFLA_WIRELESS, event_len, event); | 1282 | NLA_PUT(skb, IFLA_WIRELESS, event_len, event); |
1282 | 1283 | ||
diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c index 3f964db908a7..ac25b4c0e982 100644 --- a/net/xfrm/xfrm_output.c +++ b/net/xfrm/xfrm_output.c | |||
@@ -112,16 +112,13 @@ error_nolock: | |||
112 | int xfrm_output_resume(struct sk_buff *skb, int err) | 112 | int xfrm_output_resume(struct sk_buff *skb, int err) |
113 | { | 113 | { |
114 | while (likely((err = xfrm_output_one(skb, err)) == 0)) { | 114 | while (likely((err = xfrm_output_one(skb, err)) == 0)) { |
115 | struct xfrm_state *x; | ||
116 | |||
117 | nf_reset(skb); | 115 | nf_reset(skb); |
118 | 116 | ||
119 | err = skb->dst->ops->local_out(skb); | 117 | err = skb->dst->ops->local_out(skb); |
120 | if (unlikely(err != 1)) | 118 | if (unlikely(err != 1)) |
121 | goto out; | 119 | goto out; |
122 | 120 | ||
123 | x = skb->dst->xfrm; | 121 | if (!skb->dst->xfrm) |
124 | if (!x) | ||
125 | return dst_output(skb); | 122 | return dst_output(skb); |
126 | 123 | ||
127 | err = nf_hook(skb->dst->ops->family, | 124 | err = nf_hook(skb->dst->ops->family, |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 841b32a2e680..b7754b1b73a4 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -1077,6 +1077,7 @@ static void __xfrm_policy_link(struct xfrm_policy *pol, int dir) | |||
1077 | struct hlist_head *chain = policy_hash_bysel(&pol->selector, | 1077 | struct hlist_head *chain = policy_hash_bysel(&pol->selector, |
1078 | pol->family, dir); | 1078 | pol->family, dir); |
1079 | 1079 | ||
1080 | list_add_tail(&pol->bytype, &xfrm_policy_bytype[pol->type]); | ||
1080 | hlist_add_head(&pol->bydst, chain); | 1081 | hlist_add_head(&pol->bydst, chain); |
1081 | hlist_add_head(&pol->byidx, xfrm_policy_byidx+idx_hash(pol->index)); | 1082 | hlist_add_head(&pol->byidx, xfrm_policy_byidx+idx_hash(pol->index)); |
1082 | xfrm_policy_count[dir]++; | 1083 | xfrm_policy_count[dir]++; |
@@ -1731,8 +1732,7 @@ restart: | |||
1731 | * We can't enlist stable bundles either. | 1732 | * We can't enlist stable bundles either. |
1732 | */ | 1733 | */ |
1733 | write_unlock_bh(&policy->lock); | 1734 | write_unlock_bh(&policy->lock); |
1734 | if (dst) | 1735 | dst_free(dst); |
1735 | dst_free(dst); | ||
1736 | 1736 | ||
1737 | if (pol_dead) | 1737 | if (pol_dead) |
1738 | XFRM_INC_STATS(LINUX_MIB_XFRMOUTPOLDEAD); | 1738 | XFRM_INC_STATS(LINUX_MIB_XFRMOUTPOLDEAD); |
@@ -1748,8 +1748,7 @@ restart: | |||
1748 | err = xfrm_dst_update_origin(dst, fl); | 1748 | err = xfrm_dst_update_origin(dst, fl); |
1749 | if (unlikely(err)) { | 1749 | if (unlikely(err)) { |
1750 | write_unlock_bh(&policy->lock); | 1750 | write_unlock_bh(&policy->lock); |
1751 | if (dst) | 1751 | dst_free(dst); |
1752 | dst_free(dst); | ||
1753 | XFRM_INC_STATS(LINUX_MIB_XFRMOUTBUNDLECHECKERROR); | 1752 | XFRM_INC_STATS(LINUX_MIB_XFRMOUTBUNDLECHECKERROR); |
1754 | goto error; | 1753 | goto error; |
1755 | } | 1754 | } |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 4c6914ef7d92..0a8f09c3144c 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -780,11 +780,13 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
780 | { | 780 | { |
781 | unsigned int h; | 781 | unsigned int h; |
782 | struct hlist_node *entry; | 782 | struct hlist_node *entry; |
783 | struct xfrm_state *x, *x0; | 783 | struct xfrm_state *x, *x0, *to_put; |
784 | int acquire_in_progress = 0; | 784 | int acquire_in_progress = 0; |
785 | int error = 0; | 785 | int error = 0; |
786 | struct xfrm_state *best = NULL; | 786 | struct xfrm_state *best = NULL; |
787 | 787 | ||
788 | to_put = NULL; | ||
789 | |||
788 | spin_lock_bh(&xfrm_state_lock); | 790 | spin_lock_bh(&xfrm_state_lock); |
789 | h = xfrm_dst_hash(daddr, saddr, tmpl->reqid, family); | 791 | h = xfrm_dst_hash(daddr, saddr, tmpl->reqid, family); |
790 | hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) { | 792 | hlist_for_each_entry(x, entry, xfrm_state_bydst+h, bydst) { |
@@ -833,7 +835,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
833 | if (tmpl->id.spi && | 835 | if (tmpl->id.spi && |
834 | (x0 = __xfrm_state_lookup(daddr, tmpl->id.spi, | 836 | (x0 = __xfrm_state_lookup(daddr, tmpl->id.spi, |
835 | tmpl->id.proto, family)) != NULL) { | 837 | tmpl->id.proto, family)) != NULL) { |
836 | xfrm_state_put(x0); | 838 | to_put = x0; |
837 | error = -EEXIST; | 839 | error = -EEXIST; |
838 | goto out; | 840 | goto out; |
839 | } | 841 | } |
@@ -849,13 +851,14 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
849 | error = security_xfrm_state_alloc_acquire(x, pol->security, fl->secid); | 851 | error = security_xfrm_state_alloc_acquire(x, pol->security, fl->secid); |
850 | if (error) { | 852 | if (error) { |
851 | x->km.state = XFRM_STATE_DEAD; | 853 | x->km.state = XFRM_STATE_DEAD; |
852 | xfrm_state_put(x); | 854 | to_put = x; |
853 | x = NULL; | 855 | x = NULL; |
854 | goto out; | 856 | goto out; |
855 | } | 857 | } |
856 | 858 | ||
857 | if (km_query(x, tmpl, pol) == 0) { | 859 | if (km_query(x, tmpl, pol) == 0) { |
858 | x->km.state = XFRM_STATE_ACQ; | 860 | x->km.state = XFRM_STATE_ACQ; |
861 | list_add_tail(&x->all, &xfrm_state_all); | ||
859 | hlist_add_head(&x->bydst, xfrm_state_bydst+h); | 862 | hlist_add_head(&x->bydst, xfrm_state_bydst+h); |
860 | h = xfrm_src_hash(daddr, saddr, family); | 863 | h = xfrm_src_hash(daddr, saddr, family); |
861 | hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); | 864 | hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); |
@@ -870,7 +873,7 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
870 | xfrm_hash_grow_check(x->bydst.next != NULL); | 873 | xfrm_hash_grow_check(x->bydst.next != NULL); |
871 | } else { | 874 | } else { |
872 | x->km.state = XFRM_STATE_DEAD; | 875 | x->km.state = XFRM_STATE_DEAD; |
873 | xfrm_state_put(x); | 876 | to_put = x; |
874 | x = NULL; | 877 | x = NULL; |
875 | error = -ESRCH; | 878 | error = -ESRCH; |
876 | } | 879 | } |
@@ -881,6 +884,8 @@ out: | |||
881 | else | 884 | else |
882 | *err = acquire_in_progress ? -EAGAIN : error; | 885 | *err = acquire_in_progress ? -EAGAIN : error; |
883 | spin_unlock_bh(&xfrm_state_lock); | 886 | spin_unlock_bh(&xfrm_state_lock); |
887 | if (to_put) | ||
888 | xfrm_state_put(to_put); | ||
884 | return x; | 889 | return x; |
885 | } | 890 | } |
886 | 891 | ||
@@ -1051,6 +1056,7 @@ static struct xfrm_state *__find_acq_core(unsigned short family, u8 mode, u32 re | |||
1051 | xfrm_state_hold(x); | 1056 | xfrm_state_hold(x); |
1052 | x->timer.expires = jiffies + sysctl_xfrm_acq_expires*HZ; | 1057 | x->timer.expires = jiffies + sysctl_xfrm_acq_expires*HZ; |
1053 | add_timer(&x->timer); | 1058 | add_timer(&x->timer); |
1059 | list_add_tail(&x->all, &xfrm_state_all); | ||
1054 | hlist_add_head(&x->bydst, xfrm_state_bydst+h); | 1060 | hlist_add_head(&x->bydst, xfrm_state_bydst+h); |
1055 | h = xfrm_src_hash(daddr, saddr, family); | 1061 | h = xfrm_src_hash(daddr, saddr, family); |
1056 | hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); | 1062 | hlist_add_head(&x->bysrc, xfrm_state_bysrc+h); |
@@ -1067,18 +1073,20 @@ static struct xfrm_state *__xfrm_find_acq_byseq(u32 seq); | |||
1067 | 1073 | ||
1068 | int xfrm_state_add(struct xfrm_state *x) | 1074 | int xfrm_state_add(struct xfrm_state *x) |
1069 | { | 1075 | { |
1070 | struct xfrm_state *x1; | 1076 | struct xfrm_state *x1, *to_put; |
1071 | int family; | 1077 | int family; |
1072 | int err; | 1078 | int err; |
1073 | int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY); | 1079 | int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY); |
1074 | 1080 | ||
1075 | family = x->props.family; | 1081 | family = x->props.family; |
1076 | 1082 | ||
1083 | to_put = NULL; | ||
1084 | |||
1077 | spin_lock_bh(&xfrm_state_lock); | 1085 | spin_lock_bh(&xfrm_state_lock); |
1078 | 1086 | ||
1079 | x1 = __xfrm_state_locate(x, use_spi, family); | 1087 | x1 = __xfrm_state_locate(x, use_spi, family); |
1080 | if (x1) { | 1088 | if (x1) { |
1081 | xfrm_state_put(x1); | 1089 | to_put = x1; |
1082 | x1 = NULL; | 1090 | x1 = NULL; |
1083 | err = -EEXIST; | 1091 | err = -EEXIST; |
1084 | goto out; | 1092 | goto out; |
@@ -1088,7 +1096,7 @@ int xfrm_state_add(struct xfrm_state *x) | |||
1088 | x1 = __xfrm_find_acq_byseq(x->km.seq); | 1096 | x1 = __xfrm_find_acq_byseq(x->km.seq); |
1089 | if (x1 && ((x1->id.proto != x->id.proto) || | 1097 | if (x1 && ((x1->id.proto != x->id.proto) || |
1090 | xfrm_addr_cmp(&x1->id.daddr, &x->id.daddr, family))) { | 1098 | xfrm_addr_cmp(&x1->id.daddr, &x->id.daddr, family))) { |
1091 | xfrm_state_put(x1); | 1099 | to_put = x1; |
1092 | x1 = NULL; | 1100 | x1 = NULL; |
1093 | } | 1101 | } |
1094 | } | 1102 | } |
@@ -1110,6 +1118,9 @@ out: | |||
1110 | xfrm_state_put(x1); | 1118 | xfrm_state_put(x1); |
1111 | } | 1119 | } |
1112 | 1120 | ||
1121 | if (to_put) | ||
1122 | xfrm_state_put(to_put); | ||
1123 | |||
1113 | return err; | 1124 | return err; |
1114 | } | 1125 | } |
1115 | EXPORT_SYMBOL(xfrm_state_add); | 1126 | EXPORT_SYMBOL(xfrm_state_add); |
@@ -1269,10 +1280,12 @@ EXPORT_SYMBOL(xfrm_state_migrate); | |||
1269 | 1280 | ||
1270 | int xfrm_state_update(struct xfrm_state *x) | 1281 | int xfrm_state_update(struct xfrm_state *x) |
1271 | { | 1282 | { |
1272 | struct xfrm_state *x1; | 1283 | struct xfrm_state *x1, *to_put; |
1273 | int err; | 1284 | int err; |
1274 | int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY); | 1285 | int use_spi = xfrm_id_proto_match(x->id.proto, IPSEC_PROTO_ANY); |
1275 | 1286 | ||
1287 | to_put = NULL; | ||
1288 | |||
1276 | spin_lock_bh(&xfrm_state_lock); | 1289 | spin_lock_bh(&xfrm_state_lock); |
1277 | x1 = __xfrm_state_locate(x, use_spi, x->props.family); | 1290 | x1 = __xfrm_state_locate(x, use_spi, x->props.family); |
1278 | 1291 | ||
@@ -1281,7 +1294,7 @@ int xfrm_state_update(struct xfrm_state *x) | |||
1281 | goto out; | 1294 | goto out; |
1282 | 1295 | ||
1283 | if (xfrm_state_kern(x1)) { | 1296 | if (xfrm_state_kern(x1)) { |
1284 | xfrm_state_put(x1); | 1297 | to_put = x1; |
1285 | err = -EEXIST; | 1298 | err = -EEXIST; |
1286 | goto out; | 1299 | goto out; |
1287 | } | 1300 | } |
@@ -1295,6 +1308,9 @@ int xfrm_state_update(struct xfrm_state *x) | |||
1295 | out: | 1308 | out: |
1296 | spin_unlock_bh(&xfrm_state_lock); | 1309 | spin_unlock_bh(&xfrm_state_lock); |
1297 | 1310 | ||
1311 | if (to_put) | ||
1312 | xfrm_state_put(to_put); | ||
1313 | |||
1298 | if (err) | 1314 | if (err) |
1299 | return err; | 1315 | return err; |
1300 | 1316 | ||