diff options
Diffstat (limited to 'net')
49 files changed, 339 insertions, 212 deletions
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c index 01ddb0472f86..0eb96f7e44be 100644 --- a/net/8021q/vlan_core.c +++ b/net/8021q/vlan_core.c | |||
| @@ -24,8 +24,11 @@ int __vlan_hwaccel_rx(struct sk_buff *skb, struct vlan_group *grp, | |||
| 24 | 24 | ||
| 25 | if (vlan_dev) | 25 | if (vlan_dev) |
| 26 | skb->dev = vlan_dev; | 26 | skb->dev = vlan_dev; |
| 27 | else if (vlan_id) | 27 | else if (vlan_id) { |
| 28 | goto drop; | 28 | if (!(skb->dev->flags & IFF_PROMISC)) |
| 29 | goto drop; | ||
| 30 | skb->pkt_type = PACKET_OTHERHOST; | ||
| 31 | } | ||
| 29 | 32 | ||
| 30 | return (polling ? netif_receive_skb(skb) : netif_rx(skb)); | 33 | return (polling ? netif_receive_skb(skb) : netif_rx(skb)); |
| 31 | 34 | ||
| @@ -102,8 +105,11 @@ vlan_gro_common(struct napi_struct *napi, struct vlan_group *grp, | |||
| 102 | 105 | ||
| 103 | if (vlan_dev) | 106 | if (vlan_dev) |
| 104 | skb->dev = vlan_dev; | 107 | skb->dev = vlan_dev; |
| 105 | else if (vlan_id) | 108 | else if (vlan_id) { |
| 106 | goto drop; | 109 | if (!(skb->dev->flags & IFF_PROMISC)) |
| 110 | goto drop; | ||
| 111 | skb->pkt_type = PACKET_OTHERHOST; | ||
| 112 | } | ||
| 107 | 113 | ||
| 108 | for (p = napi->gro_list; p; p = p->next) { | 114 | for (p = napi->gro_list; p; p = p->next) { |
| 109 | NAPI_GRO_CB(p)->same_flow = | 115 | NAPI_GRO_CB(p)->same_flow = |
diff --git a/net/9p/trans_rdma.c b/net/9p/trans_rdma.c index 0ea20c30466c..17c5ba7551a5 100644 --- a/net/9p/trans_rdma.c +++ b/net/9p/trans_rdma.c | |||
| @@ -426,8 +426,10 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) | |||
| 426 | 426 | ||
| 427 | /* Allocate an fcall for the reply */ | 427 | /* Allocate an fcall for the reply */ |
| 428 | rpl_context = kmalloc(sizeof *rpl_context, GFP_KERNEL); | 428 | rpl_context = kmalloc(sizeof *rpl_context, GFP_KERNEL); |
| 429 | if (!rpl_context) | 429 | if (!rpl_context) { |
| 430 | err = -ENOMEM; | ||
| 430 | goto err_close; | 431 | goto err_close; |
| 432 | } | ||
| 431 | 433 | ||
| 432 | /* | 434 | /* |
| 433 | * If the request has a buffer, steal it, otherwise | 435 | * If the request has a buffer, steal it, otherwise |
| @@ -445,8 +447,8 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) | |||
| 445 | } | 447 | } |
| 446 | rpl_context->rc = req->rc; | 448 | rpl_context->rc = req->rc; |
| 447 | if (!rpl_context->rc) { | 449 | if (!rpl_context->rc) { |
| 448 | kfree(rpl_context); | 450 | err = -ENOMEM; |
| 449 | goto err_close; | 451 | goto err_free2; |
| 450 | } | 452 | } |
| 451 | 453 | ||
| 452 | /* | 454 | /* |
| @@ -458,11 +460,8 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) | |||
| 458 | */ | 460 | */ |
| 459 | if (atomic_inc_return(&rdma->rq_count) <= rdma->rq_depth) { | 461 | if (atomic_inc_return(&rdma->rq_count) <= rdma->rq_depth) { |
| 460 | err = post_recv(client, rpl_context); | 462 | err = post_recv(client, rpl_context); |
| 461 | if (err) { | 463 | if (err) |
| 462 | kfree(rpl_context->rc); | 464 | goto err_free1; |
| 463 | kfree(rpl_context); | ||
| 464 | goto err_close; | ||
| 465 | } | ||
| 466 | } else | 465 | } else |
| 467 | atomic_dec(&rdma->rq_count); | 466 | atomic_dec(&rdma->rq_count); |
| 468 | 467 | ||
| @@ -471,8 +470,10 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) | |||
| 471 | 470 | ||
| 472 | /* Post the request */ | 471 | /* Post the request */ |
| 473 | c = kmalloc(sizeof *c, GFP_KERNEL); | 472 | c = kmalloc(sizeof *c, GFP_KERNEL); |
| 474 | if (!c) | 473 | if (!c) { |
| 475 | goto err_close; | 474 | err = -ENOMEM; |
| 475 | goto err_free1; | ||
| 476 | } | ||
| 476 | c->req = req; | 477 | c->req = req; |
| 477 | 478 | ||
| 478 | c->busa = ib_dma_map_single(rdma->cm_id->device, | 479 | c->busa = ib_dma_map_single(rdma->cm_id->device, |
| @@ -499,9 +500,15 @@ static int rdma_request(struct p9_client *client, struct p9_req_t *req) | |||
| 499 | return ib_post_send(rdma->qp, &wr, &bad_wr); | 500 | return ib_post_send(rdma->qp, &wr, &bad_wr); |
| 500 | 501 | ||
| 501 | error: | 502 | error: |
| 503 | kfree(c); | ||
| 504 | kfree(rpl_context->rc); | ||
| 505 | kfree(rpl_context); | ||
| 502 | P9_DPRINTK(P9_DEBUG_ERROR, "EIO\n"); | 506 | P9_DPRINTK(P9_DEBUG_ERROR, "EIO\n"); |
| 503 | return -EIO; | 507 | return -EIO; |
| 504 | 508 | err_free1: | |
| 509 | kfree(rpl_context->rc); | ||
| 510 | err_free2: | ||
| 511 | kfree(rpl_context); | ||
| 505 | err_close: | 512 | err_close: |
| 506 | spin_lock_irqsave(&rdma->req_lock, flags); | 513 | spin_lock_irqsave(&rdma->req_lock, flags); |
| 507 | if (rdma->state < P9_RDMA_CLOSING) { | 514 | if (rdma->state < P9_RDMA_CLOSING) { |
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index dcfbe99ff81c..b88515936e4b 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
| @@ -329,7 +329,8 @@ p9_virtio_create(struct p9_client *client, const char *devname, char *args) | |||
| 329 | 329 | ||
| 330 | mutex_lock(&virtio_9p_lock); | 330 | mutex_lock(&virtio_9p_lock); |
| 331 | list_for_each_entry(chan, &virtio_chan_list, chan_list) { | 331 | list_for_each_entry(chan, &virtio_chan_list, chan_list) { |
| 332 | if (!strncmp(devname, chan->tag, chan->tag_len)) { | 332 | if (!strncmp(devname, chan->tag, chan->tag_len) && |
| 333 | strlen(devname) == chan->tag_len) { | ||
| 333 | if (!chan->inuse) { | 334 | if (!chan->inuse) { |
| 334 | chan->inuse = true; | 335 | chan->inuse = true; |
| 335 | found = 1; | 336 | found = 1; |
diff --git a/net/atm/br2684.c b/net/atm/br2684.c index 651babdfab38..ad2b232a2055 100644 --- a/net/atm/br2684.c +++ b/net/atm/br2684.c | |||
| @@ -399,12 +399,6 @@ static void br2684_push(struct atm_vcc *atmvcc, struct sk_buff *skb) | |||
| 399 | unregister_netdev(net_dev); | 399 | unregister_netdev(net_dev); |
| 400 | free_netdev(net_dev); | 400 | free_netdev(net_dev); |
| 401 | } | 401 | } |
| 402 | read_lock_irq(&devs_lock); | ||
| 403 | if (list_empty(&br2684_devs)) { | ||
| 404 | /* last br2684 device */ | ||
| 405 | unregister_atmdevice_notifier(&atm_dev_notifier); | ||
| 406 | } | ||
| 407 | read_unlock_irq(&devs_lock); | ||
| 408 | return; | 402 | return; |
| 409 | } | 403 | } |
| 410 | 404 | ||
| @@ -675,7 +669,6 @@ static int br2684_create(void __user *arg) | |||
| 675 | 669 | ||
| 676 | if (list_empty(&br2684_devs)) { | 670 | if (list_empty(&br2684_devs)) { |
| 677 | /* 1st br2684 device */ | 671 | /* 1st br2684 device */ |
| 678 | register_atmdevice_notifier(&atm_dev_notifier); | ||
| 679 | brdev->number = 1; | 672 | brdev->number = 1; |
| 680 | } else | 673 | } else |
| 681 | brdev->number = BRPRIV(list_entry_brdev(br2684_devs.prev))->number + 1; | 674 | brdev->number = BRPRIV(list_entry_brdev(br2684_devs.prev))->number + 1; |
| @@ -815,6 +808,7 @@ static int __init br2684_init(void) | |||
| 815 | return -ENOMEM; | 808 | return -ENOMEM; |
| 816 | #endif | 809 | #endif |
| 817 | register_atm_ioctl(&br2684_ioctl_ops); | 810 | register_atm_ioctl(&br2684_ioctl_ops); |
| 811 | register_atmdevice_notifier(&atm_dev_notifier); | ||
| 818 | return 0; | 812 | return 0; |
| 819 | } | 813 | } |
| 820 | 814 | ||
| @@ -830,9 +824,7 @@ static void __exit br2684_exit(void) | |||
| 830 | #endif | 824 | #endif |
| 831 | 825 | ||
| 832 | 826 | ||
| 833 | /* if not already empty */ | 827 | unregister_atmdevice_notifier(&atm_dev_notifier); |
| 834 | if (!list_empty(&br2684_devs)) | ||
| 835 | unregister_atmdevice_notifier(&atm_dev_notifier); | ||
| 836 | 828 | ||
| 837 | while (!list_empty(&br2684_devs)) { | 829 | while (!list_empty(&br2684_devs)) { |
| 838 | net_dev = list_entry_brdev(br2684_devs.next); | 830 | net_dev = list_entry_brdev(br2684_devs.next); |
diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 622b471e14e0..74bcc662c3dd 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c | |||
| @@ -778,7 +778,7 @@ static void mpc_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
| 778 | eg->packets_rcvd++; | 778 | eg->packets_rcvd++; |
| 779 | mpc->eg_ops->put(eg); | 779 | mpc->eg_ops->put(eg); |
| 780 | 780 | ||
| 781 | memset(ATM_SKB(skb), 0, sizeof(struct atm_skb_data)); | 781 | memset(ATM_SKB(new_skb), 0, sizeof(struct atm_skb_data)); |
| 782 | netif_rx(new_skb); | 782 | netif_rx(new_skb); |
| 783 | } | 783 | } |
| 784 | 784 | ||
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index fadf26b4ed7c..0b54b7dd8401 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
| @@ -1441,33 +1441,23 @@ static inline void l2cap_do_send(struct sock *sk, struct sk_buff *skb) | |||
| 1441 | 1441 | ||
| 1442 | static void l2cap_streaming_send(struct sock *sk) | 1442 | static void l2cap_streaming_send(struct sock *sk) |
| 1443 | { | 1443 | { |
| 1444 | struct sk_buff *skb, *tx_skb; | 1444 | struct sk_buff *skb; |
| 1445 | struct l2cap_pinfo *pi = l2cap_pi(sk); | 1445 | struct l2cap_pinfo *pi = l2cap_pi(sk); |
| 1446 | u16 control, fcs; | 1446 | u16 control, fcs; |
| 1447 | 1447 | ||
| 1448 | while ((skb = sk->sk_send_head)) { | 1448 | while ((skb = skb_dequeue(TX_QUEUE(sk)))) { |
| 1449 | tx_skb = skb_clone(skb, GFP_ATOMIC); | 1449 | control = get_unaligned_le16(skb->data + L2CAP_HDR_SIZE); |
| 1450 | |||
| 1451 | control = get_unaligned_le16(tx_skb->data + L2CAP_HDR_SIZE); | ||
| 1452 | control |= pi->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; | 1450 | control |= pi->next_tx_seq << L2CAP_CTRL_TXSEQ_SHIFT; |
| 1453 | put_unaligned_le16(control, tx_skb->data + L2CAP_HDR_SIZE); | 1451 | put_unaligned_le16(control, skb->data + L2CAP_HDR_SIZE); |
| 1454 | 1452 | ||
| 1455 | if (pi->fcs == L2CAP_FCS_CRC16) { | 1453 | if (pi->fcs == L2CAP_FCS_CRC16) { |
| 1456 | fcs = crc16(0, (u8 *)tx_skb->data, tx_skb->len - 2); | 1454 | fcs = crc16(0, (u8 *)skb->data, skb->len - 2); |
| 1457 | put_unaligned_le16(fcs, tx_skb->data + tx_skb->len - 2); | 1455 | put_unaligned_le16(fcs, skb->data + skb->len - 2); |
| 1458 | } | 1456 | } |
| 1459 | 1457 | ||
| 1460 | l2cap_do_send(sk, tx_skb); | 1458 | l2cap_do_send(sk, skb); |
| 1461 | 1459 | ||
| 1462 | pi->next_tx_seq = (pi->next_tx_seq + 1) % 64; | 1460 | pi->next_tx_seq = (pi->next_tx_seq + 1) % 64; |
| 1463 | |||
| 1464 | if (skb_queue_is_last(TX_QUEUE(sk), skb)) | ||
| 1465 | sk->sk_send_head = NULL; | ||
| 1466 | else | ||
| 1467 | sk->sk_send_head = skb_queue_next(TX_QUEUE(sk), skb); | ||
| 1468 | |||
| 1469 | skb = skb_dequeue(TX_QUEUE(sk)); | ||
| 1470 | kfree_skb(skb); | ||
| 1471 | } | 1461 | } |
| 1472 | } | 1462 | } |
| 1473 | 1463 | ||
| @@ -1960,6 +1950,11 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us | |||
| 1960 | 1950 | ||
| 1961 | switch (optname) { | 1951 | switch (optname) { |
| 1962 | case L2CAP_OPTIONS: | 1952 | case L2CAP_OPTIONS: |
| 1953 | if (sk->sk_state == BT_CONNECTED) { | ||
| 1954 | err = -EINVAL; | ||
| 1955 | break; | ||
| 1956 | } | ||
| 1957 | |||
| 1963 | opts.imtu = l2cap_pi(sk)->imtu; | 1958 | opts.imtu = l2cap_pi(sk)->imtu; |
| 1964 | opts.omtu = l2cap_pi(sk)->omtu; | 1959 | opts.omtu = l2cap_pi(sk)->omtu; |
| 1965 | opts.flush_to = l2cap_pi(sk)->flush_to; | 1960 | opts.flush_to = l2cap_pi(sk)->flush_to; |
| @@ -2771,10 +2766,10 @@ static int l2cap_parse_conf_rsp(struct sock *sk, void *rsp, int len, void *data, | |||
| 2771 | case L2CAP_CONF_MTU: | 2766 | case L2CAP_CONF_MTU: |
| 2772 | if (val < L2CAP_DEFAULT_MIN_MTU) { | 2767 | if (val < L2CAP_DEFAULT_MIN_MTU) { |
| 2773 | *result = L2CAP_CONF_UNACCEPT; | 2768 | *result = L2CAP_CONF_UNACCEPT; |
| 2774 | pi->omtu = L2CAP_DEFAULT_MIN_MTU; | 2769 | pi->imtu = L2CAP_DEFAULT_MIN_MTU; |
| 2775 | } else | 2770 | } else |
| 2776 | pi->omtu = val; | 2771 | pi->imtu = val; |
| 2777 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->omtu); | 2772 | l2cap_add_conf_opt(&ptr, L2CAP_CONF_MTU, 2, pi->imtu); |
| 2778 | break; | 2773 | break; |
| 2779 | 2774 | ||
| 2780 | case L2CAP_CONF_FLUSH_TO: | 2775 | case L2CAP_CONF_FLUSH_TO: |
| @@ -3071,6 +3066,17 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd | |||
| 3071 | return 0; | 3066 | return 0; |
| 3072 | } | 3067 | } |
| 3073 | 3068 | ||
| 3069 | static inline void set_default_fcs(struct l2cap_pinfo *pi) | ||
| 3070 | { | ||
| 3071 | /* FCS is enabled only in ERTM or streaming mode, if one or both | ||
| 3072 | * sides request it. | ||
| 3073 | */ | ||
| 3074 | if (pi->mode != L2CAP_MODE_ERTM && pi->mode != L2CAP_MODE_STREAMING) | ||
| 3075 | pi->fcs = L2CAP_FCS_NONE; | ||
| 3076 | else if (!(pi->conf_state & L2CAP_CONF_NO_FCS_RECV)) | ||
| 3077 | pi->fcs = L2CAP_FCS_CRC16; | ||
| 3078 | } | ||
| 3079 | |||
| 3074 | static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) | 3080 | static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data) |
| 3075 | { | 3081 | { |
| 3076 | struct l2cap_conf_req *req = (struct l2cap_conf_req *) data; | 3082 | struct l2cap_conf_req *req = (struct l2cap_conf_req *) data; |
| @@ -3088,14 +3094,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
| 3088 | if (!sk) | 3094 | if (!sk) |
| 3089 | return -ENOENT; | 3095 | return -ENOENT; |
| 3090 | 3096 | ||
| 3091 | if (sk->sk_state != BT_CONFIG) { | 3097 | if (sk->sk_state == BT_DISCONN) |
| 3092 | struct l2cap_cmd_rej rej; | ||
| 3093 | |||
| 3094 | rej.reason = cpu_to_le16(0x0002); | ||
| 3095 | l2cap_send_cmd(conn, cmd->ident, L2CAP_COMMAND_REJ, | ||
| 3096 | sizeof(rej), &rej); | ||
| 3097 | goto unlock; | 3098 | goto unlock; |
| 3098 | } | ||
| 3099 | 3099 | ||
| 3100 | /* Reject if config buffer is too small. */ | 3100 | /* Reject if config buffer is too small. */ |
| 3101 | len = cmd_len - sizeof(*req); | 3101 | len = cmd_len - sizeof(*req); |
| @@ -3135,9 +3135,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
| 3135 | goto unlock; | 3135 | goto unlock; |
| 3136 | 3136 | ||
| 3137 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE) { | 3137 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_INPUT_DONE) { |
| 3138 | if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_NO_FCS_RECV) || | 3138 | set_default_fcs(l2cap_pi(sk)); |
| 3139 | l2cap_pi(sk)->fcs != L2CAP_FCS_NONE) | ||
| 3140 | l2cap_pi(sk)->fcs = L2CAP_FCS_CRC16; | ||
| 3141 | 3139 | ||
| 3142 | sk->sk_state = BT_CONNECTED; | 3140 | sk->sk_state = BT_CONNECTED; |
| 3143 | 3141 | ||
| @@ -3225,9 +3223,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr | |||
| 3225 | l2cap_pi(sk)->conf_state |= L2CAP_CONF_INPUT_DONE; | 3223 | l2cap_pi(sk)->conf_state |= L2CAP_CONF_INPUT_DONE; |
| 3226 | 3224 | ||
| 3227 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE) { | 3225 | if (l2cap_pi(sk)->conf_state & L2CAP_CONF_OUTPUT_DONE) { |
| 3228 | if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_NO_FCS_RECV) || | 3226 | set_default_fcs(l2cap_pi(sk)); |
| 3229 | l2cap_pi(sk)->fcs != L2CAP_FCS_NONE) | ||
| 3230 | l2cap_pi(sk)->fcs = L2CAP_FCS_CRC16; | ||
| 3231 | 3227 | ||
| 3232 | sk->sk_state = BT_CONNECTED; | 3228 | sk->sk_state = BT_CONNECTED; |
| 3233 | l2cap_pi(sk)->next_tx_seq = 0; | 3229 | l2cap_pi(sk)->next_tx_seq = 0; |
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index 44a623275951..194b3a04cfd3 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
| @@ -82,11 +82,14 @@ static void rfcomm_sk_data_ready(struct rfcomm_dlc *d, struct sk_buff *skb) | |||
| 82 | static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err) | 82 | static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err) |
| 83 | { | 83 | { |
| 84 | struct sock *sk = d->owner, *parent; | 84 | struct sock *sk = d->owner, *parent; |
| 85 | unsigned long flags; | ||
| 86 | |||
| 85 | if (!sk) | 87 | if (!sk) |
| 86 | return; | 88 | return; |
| 87 | 89 | ||
| 88 | BT_DBG("dlc %p state %ld err %d", d, d->state, err); | 90 | BT_DBG("dlc %p state %ld err %d", d, d->state, err); |
| 89 | 91 | ||
| 92 | local_irq_save(flags); | ||
| 90 | bh_lock_sock(sk); | 93 | bh_lock_sock(sk); |
| 91 | 94 | ||
| 92 | if (err) | 95 | if (err) |
| @@ -108,6 +111,7 @@ static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err) | |||
| 108 | } | 111 | } |
| 109 | 112 | ||
| 110 | bh_unlock_sock(sk); | 113 | bh_unlock_sock(sk); |
| 114 | local_irq_restore(flags); | ||
| 111 | 115 | ||
| 112 | if (parent && sock_flag(sk, SOCK_ZAPPED)) { | 116 | if (parent && sock_flag(sk, SOCK_ZAPPED)) { |
| 113 | /* We have to drop DLC lock here, otherwise | 117 | /* We have to drop DLC lock here, otherwise |
diff --git a/net/caif/caif_socket.c b/net/caif/caif_socket.c index 8ce904786116..4bf28f25f368 100644 --- a/net/caif/caif_socket.c +++ b/net/caif/caif_socket.c | |||
| @@ -827,6 +827,7 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr, | |||
| 827 | long timeo; | 827 | long timeo; |
| 828 | int err; | 828 | int err; |
| 829 | int ifindex, headroom, tailroom; | 829 | int ifindex, headroom, tailroom; |
| 830 | unsigned int mtu; | ||
| 830 | struct net_device *dev; | 831 | struct net_device *dev; |
| 831 | 832 | ||
| 832 | lock_sock(sk); | 833 | lock_sock(sk); |
| @@ -896,15 +897,23 @@ static int caif_connect(struct socket *sock, struct sockaddr *uaddr, | |||
| 896 | cf_sk->sk.sk_state = CAIF_DISCONNECTED; | 897 | cf_sk->sk.sk_state = CAIF_DISCONNECTED; |
| 897 | goto out; | 898 | goto out; |
| 898 | } | 899 | } |
| 899 | dev = dev_get_by_index(sock_net(sk), ifindex); | 900 | |
| 901 | err = -ENODEV; | ||
| 902 | rcu_read_lock(); | ||
| 903 | dev = dev_get_by_index_rcu(sock_net(sk), ifindex); | ||
| 904 | if (!dev) { | ||
| 905 | rcu_read_unlock(); | ||
| 906 | goto out; | ||
| 907 | } | ||
| 900 | cf_sk->headroom = LL_RESERVED_SPACE_EXTRA(dev, headroom); | 908 | cf_sk->headroom = LL_RESERVED_SPACE_EXTRA(dev, headroom); |
| 909 | mtu = dev->mtu; | ||
| 910 | rcu_read_unlock(); | ||
| 911 | |||
| 901 | cf_sk->tailroom = tailroom; | 912 | cf_sk->tailroom = tailroom; |
| 902 | cf_sk->maxframe = dev->mtu - (headroom + tailroom); | 913 | cf_sk->maxframe = mtu - (headroom + tailroom); |
| 903 | dev_put(dev); | ||
| 904 | if (cf_sk->maxframe < 1) { | 914 | if (cf_sk->maxframe < 1) { |
| 905 | pr_warning("CAIF: %s(): CAIF Interface MTU too small (%d)\n", | 915 | pr_warning("CAIF: %s(): CAIF Interface MTU too small (%u)\n", |
| 906 | __func__, dev->mtu); | 916 | __func__, mtu); |
| 907 | err = -ENODEV; | ||
| 908 | goto out; | 917 | goto out; |
| 909 | } | 918 | } |
| 910 | 919 | ||
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 7a85367b3c2f..8451ab481095 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
| @@ -348,7 +348,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev, | |||
| 348 | if (info.cmd == ETHTOOL_GRXCLSRLALL) { | 348 | if (info.cmd == ETHTOOL_GRXCLSRLALL) { |
| 349 | if (info.rule_cnt > 0) { | 349 | if (info.rule_cnt > 0) { |
| 350 | if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32)) | 350 | if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32)) |
| 351 | rule_buf = kmalloc(info.rule_cnt * sizeof(u32), | 351 | rule_buf = kzalloc(info.rule_cnt * sizeof(u32), |
| 352 | GFP_USER); | 352 | GFP_USER); |
| 353 | if (!rule_buf) | 353 | if (!rule_buf) |
| 354 | return -ENOMEM; | 354 | return -ENOMEM; |
| @@ -397,7 +397,7 @@ static noinline_for_stack int ethtool_get_rxfh_indir(struct net_device *dev, | |||
| 397 | (KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index)) | 397 | (KMALLOC_MAX_SIZE - sizeof(*indir)) / sizeof(*indir->ring_index)) |
| 398 | return -ENOMEM; | 398 | return -ENOMEM; |
| 399 | full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size; | 399 | full_size = sizeof(*indir) + sizeof(*indir->ring_index) * table_size; |
| 400 | indir = kmalloc(full_size, GFP_USER); | 400 | indir = kzalloc(full_size, GFP_USER); |
| 401 | if (!indir) | 401 | if (!indir) |
| 402 | return -ENOMEM; | 402 | return -ENOMEM; |
| 403 | 403 | ||
| @@ -538,7 +538,7 @@ static int ethtool_get_rx_ntuple(struct net_device *dev, void __user *useraddr) | |||
| 538 | 538 | ||
| 539 | gstrings.len = ret; | 539 | gstrings.len = ret; |
| 540 | 540 | ||
| 541 | data = kmalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER); | 541 | data = kzalloc(gstrings.len * ETH_GSTRING_LEN, GFP_USER); |
| 542 | if (!data) | 542 | if (!data) |
| 543 | return -ENOMEM; | 543 | return -ENOMEM; |
| 544 | 544 | ||
| @@ -775,7 +775,7 @@ static int ethtool_get_regs(struct net_device *dev, char __user *useraddr) | |||
| 775 | if (regs.len > reglen) | 775 | if (regs.len > reglen) |
| 776 | regs.len = reglen; | 776 | regs.len = reglen; |
| 777 | 777 | ||
| 778 | regbuf = kmalloc(reglen, GFP_USER); | 778 | regbuf = kzalloc(reglen, GFP_USER); |
| 779 | if (!regbuf) | 779 | if (!regbuf) |
| 780 | return -ENOMEM; | 780 | return -ENOMEM; |
| 781 | 781 | ||
diff --git a/net/core/iovec.c b/net/core/iovec.c index 1cd98df412df..e6b133b77ccb 100644 --- a/net/core/iovec.c +++ b/net/core/iovec.c | |||
| @@ -35,9 +35,10 @@ | |||
| 35 | * in any case. | 35 | * in any case. |
| 36 | */ | 36 | */ |
| 37 | 37 | ||
| 38 | int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode) | 38 | long verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode) |
| 39 | { | 39 | { |
| 40 | int size, err, ct; | 40 | int size, ct; |
| 41 | long err; | ||
| 41 | 42 | ||
| 42 | if (m->msg_namelen) { | 43 | if (m->msg_namelen) { |
| 43 | if (mode == VERIFY_READ) { | 44 | if (mode == VERIFY_READ) { |
diff --git a/net/core/sock.c b/net/core/sock.c index b05b9b6ddb87..ef30e9d286e7 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
| @@ -1351,9 +1351,9 @@ int sock_i_uid(struct sock *sk) | |||
| 1351 | { | 1351 | { |
| 1352 | int uid; | 1352 | int uid; |
| 1353 | 1353 | ||
| 1354 | read_lock(&sk->sk_callback_lock); | 1354 | read_lock_bh(&sk->sk_callback_lock); |
| 1355 | uid = sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : 0; | 1355 | uid = sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : 0; |
| 1356 | read_unlock(&sk->sk_callback_lock); | 1356 | read_unlock_bh(&sk->sk_callback_lock); |
| 1357 | return uid; | 1357 | return uid; |
| 1358 | } | 1358 | } |
| 1359 | EXPORT_SYMBOL(sock_i_uid); | 1359 | EXPORT_SYMBOL(sock_i_uid); |
| @@ -1362,9 +1362,9 @@ unsigned long sock_i_ino(struct sock *sk) | |||
| 1362 | { | 1362 | { |
| 1363 | unsigned long ino; | 1363 | unsigned long ino; |
| 1364 | 1364 | ||
| 1365 | read_lock(&sk->sk_callback_lock); | 1365 | read_lock_bh(&sk->sk_callback_lock); |
| 1366 | ino = sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_ino : 0; | 1366 | ino = sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_ino : 0; |
| 1367 | read_unlock(&sk->sk_callback_lock); | 1367 | read_unlock_bh(&sk->sk_callback_lock); |
| 1368 | return ino; | 1368 | return ino; |
| 1369 | } | 1369 | } |
| 1370 | EXPORT_SYMBOL(sock_i_ino); | 1370 | EXPORT_SYMBOL(sock_i_ino); |
diff --git a/net/core/stream.c b/net/core/stream.c index d959e0f41528..f5df85dcd20b 100644 --- a/net/core/stream.c +++ b/net/core/stream.c | |||
| @@ -141,10 +141,10 @@ int sk_stream_wait_memory(struct sock *sk, long *timeo_p) | |||
| 141 | 141 | ||
| 142 | set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); | 142 | set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); |
| 143 | sk->sk_write_pending++; | 143 | sk->sk_write_pending++; |
| 144 | sk_wait_event(sk, ¤t_timeo, !sk->sk_err && | 144 | sk_wait_event(sk, ¤t_timeo, sk->sk_err || |
| 145 | !(sk->sk_shutdown & SEND_SHUTDOWN) && | 145 | (sk->sk_shutdown & SEND_SHUTDOWN) || |
| 146 | sk_stream_memory_free(sk) && | 146 | (sk_stream_memory_free(sk) && |
| 147 | vm_wait); | 147 | !vm_wait)); |
| 148 | sk->sk_write_pending--; | 148 | sk->sk_write_pending--; |
| 149 | 149 | ||
| 150 | if (vm_wait) { | 150 | if (vm_wait) { |
diff --git a/net/ipv4/Kconfig b/net/ipv4/Kconfig index 571f8950ed06..7cd7760144f7 100644 --- a/net/ipv4/Kconfig +++ b/net/ipv4/Kconfig | |||
| @@ -217,6 +217,7 @@ config NET_IPIP | |||
| 217 | 217 | ||
| 218 | config NET_IPGRE | 218 | config NET_IPGRE |
| 219 | tristate "IP: GRE tunnels over IP" | 219 | tristate "IP: GRE tunnels over IP" |
| 220 | depends on IPV6 || IPV6=n | ||
| 220 | help | 221 | help |
| 221 | Tunneling means encapsulating data of one protocol type within | 222 | Tunneling means encapsulating data of one protocol type within |
| 222 | another protocol and sending it over a channel that understands the | 223 | another protocol and sending it over a channel that understands the |
| @@ -412,7 +413,7 @@ config INET_XFRM_MODE_BEET | |||
| 412 | If unsure, say Y. | 413 | If unsure, say Y. |
| 413 | 414 | ||
| 414 | config INET_LRO | 415 | config INET_LRO |
| 415 | bool "Large Receive Offload (ipv4/tcp)" | 416 | tristate "Large Receive Offload (ipv4/tcp)" |
| 416 | default y | 417 | default y |
| 417 | ---help--- | 418 | ---help--- |
| 418 | Support for Large Receive Offload (ipv4/tcp). | 419 | Support for Large Receive Offload (ipv4/tcp). |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 1fdcacd36ce7..2a4bb76f2132 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
| @@ -834,7 +834,7 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, | |||
| 834 | int mark = 0; | 834 | int mark = 0; |
| 835 | 835 | ||
| 836 | 836 | ||
| 837 | if (len == 8 || IGMP_V2_SEEN(in_dev)) { | 837 | if (len == 8) { |
| 838 | if (ih->code == 0) { | 838 | if (ih->code == 0) { |
| 839 | /* Alas, old v1 router presents here. */ | 839 | /* Alas, old v1 router presents here. */ |
| 840 | 840 | ||
| @@ -856,6 +856,18 @@ static void igmp_heard_query(struct in_device *in_dev, struct sk_buff *skb, | |||
| 856 | igmpv3_clear_delrec(in_dev); | 856 | igmpv3_clear_delrec(in_dev); |
| 857 | } else if (len < 12) { | 857 | } else if (len < 12) { |
| 858 | return; /* ignore bogus packet; freed by caller */ | 858 | return; /* ignore bogus packet; freed by caller */ |
| 859 | } else if (IGMP_V1_SEEN(in_dev)) { | ||
| 860 | /* This is a v3 query with v1 queriers present */ | ||
| 861 | max_delay = IGMP_Query_Response_Interval; | ||
| 862 | group = 0; | ||
| 863 | } else if (IGMP_V2_SEEN(in_dev)) { | ||
| 864 | /* this is a v3 query with v2 queriers present; | ||
| 865 | * Interpretation of the max_delay code is problematic here. | ||
| 866 | * A real v2 host would use ih_code directly, while v3 has a | ||
| 867 | * different encoding. We use the v3 encoding as more likely | ||
| 868 | * to be intended in a v3 query. | ||
| 869 | */ | ||
| 870 | max_delay = IGMPV3_MRC(ih3->code)*(HZ/IGMP_TIMER_SCALE); | ||
| 859 | } else { /* v3 */ | 871 | } else { /* v3 */ |
| 860 | if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) | 872 | if (!pskb_may_pull(skb, sizeof(struct igmpv3_query))) |
| 861 | return; | 873 | return; |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index 945b20a5ad50..35c93e8b6a46 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
| @@ -45,7 +45,7 @@ | |||
| 45 | #include <net/netns/generic.h> | 45 | #include <net/netns/generic.h> |
| 46 | #include <net/rtnetlink.h> | 46 | #include <net/rtnetlink.h> |
| 47 | 47 | ||
| 48 | #ifdef CONFIG_IPV6 | 48 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 49 | #include <net/ipv6.h> | 49 | #include <net/ipv6.h> |
| 50 | #include <net/ip6_fib.h> | 50 | #include <net/ip6_fib.h> |
| 51 | #include <net/ip6_route.h> | 51 | #include <net/ip6_route.h> |
| @@ -699,7 +699,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev | |||
| 699 | if ((dst = rt->rt_gateway) == 0) | 699 | if ((dst = rt->rt_gateway) == 0) |
| 700 | goto tx_error_icmp; | 700 | goto tx_error_icmp; |
| 701 | } | 701 | } |
| 702 | #ifdef CONFIG_IPV6 | 702 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 703 | else if (skb->protocol == htons(ETH_P_IPV6)) { | 703 | else if (skb->protocol == htons(ETH_P_IPV6)) { |
| 704 | struct in6_addr *addr6; | 704 | struct in6_addr *addr6; |
| 705 | int addr_type; | 705 | int addr_type; |
| @@ -774,7 +774,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev | |||
| 774 | goto tx_error; | 774 | goto tx_error; |
| 775 | } | 775 | } |
| 776 | } | 776 | } |
| 777 | #ifdef CONFIG_IPV6 | 777 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 778 | else if (skb->protocol == htons(ETH_P_IPV6)) { | 778 | else if (skb->protocol == htons(ETH_P_IPV6)) { |
| 779 | struct rt6_info *rt6 = (struct rt6_info *)skb_dst(skb); | 779 | struct rt6_info *rt6 = (struct rt6_info *)skb_dst(skb); |
| 780 | 780 | ||
| @@ -850,7 +850,7 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev | |||
| 850 | if ((iph->ttl = tiph->ttl) == 0) { | 850 | if ((iph->ttl = tiph->ttl) == 0) { |
| 851 | if (skb->protocol == htons(ETH_P_IP)) | 851 | if (skb->protocol == htons(ETH_P_IP)) |
| 852 | iph->ttl = old_iph->ttl; | 852 | iph->ttl = old_iph->ttl; |
| 853 | #ifdef CONFIG_IPV6 | 853 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
| 854 | else if (skb->protocol == htons(ETH_P_IPV6)) | 854 | else if (skb->protocol == htons(ETH_P_IPV6)) |
| 855 | iph->ttl = ((struct ipv6hdr *)old_iph)->hop_limit; | 855 | iph->ttl = ((struct ipv6hdr *)old_iph)->hop_limit; |
| 856 | #endif | 856 | #endif |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 04b69896df5f..7649d7750075 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
| @@ -488,9 +488,8 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 488 | * we can switch to copy when see the first bad fragment. | 488 | * we can switch to copy when see the first bad fragment. |
| 489 | */ | 489 | */ |
| 490 | if (skb_has_frags(skb)) { | 490 | if (skb_has_frags(skb)) { |
| 491 | struct sk_buff *frag; | 491 | struct sk_buff *frag, *frag2; |
| 492 | int first_len = skb_pagelen(skb); | 492 | int first_len = skb_pagelen(skb); |
| 493 | int truesizes = 0; | ||
| 494 | 493 | ||
| 495 | if (first_len - hlen > mtu || | 494 | if (first_len - hlen > mtu || |
| 496 | ((first_len - hlen) & 7) || | 495 | ((first_len - hlen) & 7) || |
| @@ -503,18 +502,18 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 503 | if (frag->len > mtu || | 502 | if (frag->len > mtu || |
| 504 | ((frag->len & 7) && frag->next) || | 503 | ((frag->len & 7) && frag->next) || |
| 505 | skb_headroom(frag) < hlen) | 504 | skb_headroom(frag) < hlen) |
| 506 | goto slow_path; | 505 | goto slow_path_clean; |
| 507 | 506 | ||
| 508 | /* Partially cloned skb? */ | 507 | /* Partially cloned skb? */ |
| 509 | if (skb_shared(frag)) | 508 | if (skb_shared(frag)) |
| 510 | goto slow_path; | 509 | goto slow_path_clean; |
| 511 | 510 | ||
| 512 | BUG_ON(frag->sk); | 511 | BUG_ON(frag->sk); |
| 513 | if (skb->sk) { | 512 | if (skb->sk) { |
| 514 | frag->sk = skb->sk; | 513 | frag->sk = skb->sk; |
| 515 | frag->destructor = sock_wfree; | 514 | frag->destructor = sock_wfree; |
| 516 | } | 515 | } |
| 517 | truesizes += frag->truesize; | 516 | skb->truesize -= frag->truesize; |
| 518 | } | 517 | } |
| 519 | 518 | ||
| 520 | /* Everything is OK. Generate! */ | 519 | /* Everything is OK. Generate! */ |
| @@ -524,7 +523,6 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 524 | frag = skb_shinfo(skb)->frag_list; | 523 | frag = skb_shinfo(skb)->frag_list; |
| 525 | skb_frag_list_init(skb); | 524 | skb_frag_list_init(skb); |
| 526 | skb->data_len = first_len - skb_headlen(skb); | 525 | skb->data_len = first_len - skb_headlen(skb); |
| 527 | skb->truesize -= truesizes; | ||
| 528 | skb->len = first_len; | 526 | skb->len = first_len; |
| 529 | iph->tot_len = htons(first_len); | 527 | iph->tot_len = htons(first_len); |
| 530 | iph->frag_off = htons(IP_MF); | 528 | iph->frag_off = htons(IP_MF); |
| @@ -576,6 +574,15 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 576 | } | 574 | } |
| 577 | IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); | 575 | IP_INC_STATS(dev_net(dev), IPSTATS_MIB_FRAGFAILS); |
| 578 | return err; | 576 | return err; |
| 577 | |||
| 578 | slow_path_clean: | ||
| 579 | skb_walk_frags(skb, frag2) { | ||
| 580 | if (frag2 == frag) | ||
| 581 | break; | ||
| 582 | frag2->sk = NULL; | ||
| 583 | frag2->destructor = NULL; | ||
| 584 | skb->truesize += frag2->truesize; | ||
| 585 | } | ||
| 579 | } | 586 | } |
| 580 | 587 | ||
| 581 | slow_path: | 588 | slow_path: |
diff --git a/net/ipv4/netfilter/ipt_REJECT.c b/net/ipv4/netfilter/ipt_REJECT.c index b254dafaf429..43eec80c0e7c 100644 --- a/net/ipv4/netfilter/ipt_REJECT.c +++ b/net/ipv4/netfilter/ipt_REJECT.c | |||
| @@ -112,6 +112,7 @@ static void send_reset(struct sk_buff *oldskb, int hook) | |||
| 112 | /* ip_route_me_harder expects skb->dst to be set */ | 112 | /* ip_route_me_harder expects skb->dst to be set */ |
| 113 | skb_dst_set_noref(nskb, skb_dst(oldskb)); | 113 | skb_dst_set_noref(nskb, skb_dst(oldskb)); |
| 114 | 114 | ||
| 115 | nskb->protocol = htons(ETH_P_IP); | ||
| 115 | if (ip_route_me_harder(nskb, addr_type)) | 116 | if (ip_route_me_harder(nskb, addr_type)) |
| 116 | goto free_nskb; | 117 | goto free_nskb; |
| 117 | 118 | ||
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c index eab8de32f200..f3a9b42b16c6 100644 --- a/net/ipv4/netfilter/nf_defrag_ipv4.c +++ b/net/ipv4/netfilter/nf_defrag_ipv4.c | |||
| @@ -66,9 +66,11 @@ static unsigned int ipv4_conntrack_defrag(unsigned int hooknum, | |||
| 66 | const struct net_device *out, | 66 | const struct net_device *out, |
| 67 | int (*okfn)(struct sk_buff *)) | 67 | int (*okfn)(struct sk_buff *)) |
| 68 | { | 68 | { |
| 69 | struct sock *sk = skb->sk; | ||
| 69 | struct inet_sock *inet = inet_sk(skb->sk); | 70 | struct inet_sock *inet = inet_sk(skb->sk); |
| 70 | 71 | ||
| 71 | if (inet && inet->nodefrag) | 72 | if (sk && (sk->sk_family == PF_INET) && |
| 73 | inet->nodefrag) | ||
| 72 | return NF_ACCEPT; | 74 | return NF_ACCEPT; |
| 73 | 75 | ||
| 74 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 76 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
diff --git a/net/ipv4/netfilter/nf_nat_snmp_basic.c b/net/ipv4/netfilter/nf_nat_snmp_basic.c index 1679e2c0963d..ee5f419d0a56 100644 --- a/net/ipv4/netfilter/nf_nat_snmp_basic.c +++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c | |||
| @@ -893,13 +893,15 @@ static void fast_csum(__sum16 *csum, | |||
| 893 | unsigned char s[4]; | 893 | unsigned char s[4]; |
| 894 | 894 | ||
| 895 | if (offset & 1) { | 895 | if (offset & 1) { |
| 896 | s[0] = s[2] = 0; | 896 | s[0] = ~0; |
| 897 | s[1] = ~*optr; | 897 | s[1] = ~*optr; |
| 898 | s[2] = 0; | ||
| 898 | s[3] = *nptr; | 899 | s[3] = *nptr; |
| 899 | } else { | 900 | } else { |
| 900 | s[1] = s[3] = 0; | ||
| 901 | s[0] = ~*optr; | 901 | s[0] = ~*optr; |
| 902 | s[1] = ~0; | ||
| 902 | s[2] = *nptr; | 903 | s[2] = *nptr; |
| 904 | s[3] = 0; | ||
| 903 | } | 905 | } |
| 904 | 906 | ||
| 905 | *csum = csum_fold(csum_partial(s, 4, ~csum_unfold(*csum))); | 907 | *csum = csum_fold(csum_partial(s, 4, ~csum_unfold(*csum))); |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 6298f75d5e93..ac6559cb54f9 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -1231,7 +1231,7 @@ restart: | |||
| 1231 | } | 1231 | } |
| 1232 | 1232 | ||
| 1233 | if (net_ratelimit()) | 1233 | if (net_ratelimit()) |
| 1234 | printk(KERN_WARNING "Neighbour table overflow.\n"); | 1234 | printk(KERN_WARNING "ipv4: Neighbour table overflow.\n"); |
| 1235 | rt_drop(rt); | 1235 | rt_drop(rt); |
| 1236 | return -ENOBUFS; | 1236 | return -ENOBUFS; |
| 1237 | } | 1237 | } |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 3fb1428e526e..f115ea68a4ef 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
| @@ -386,8 +386,6 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
| 386 | */ | 386 | */ |
| 387 | 387 | ||
| 388 | mask = 0; | 388 | mask = 0; |
| 389 | if (sk->sk_err) | ||
| 390 | mask = POLLERR; | ||
| 391 | 389 | ||
| 392 | /* | 390 | /* |
| 393 | * POLLHUP is certainly not done right. But poll() doesn't | 391 | * POLLHUP is certainly not done right. But poll() doesn't |
| @@ -457,6 +455,11 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
| 457 | if (tp->urg_data & TCP_URG_VALID) | 455 | if (tp->urg_data & TCP_URG_VALID) |
| 458 | mask |= POLLPRI; | 456 | mask |= POLLPRI; |
| 459 | } | 457 | } |
| 458 | /* This barrier is coupled with smp_wmb() in tcp_reset() */ | ||
| 459 | smp_rmb(); | ||
| 460 | if (sk->sk_err) | ||
| 461 | mask |= POLLERR; | ||
| 462 | |||
| 460 | return mask; | 463 | return mask; |
| 461 | } | 464 | } |
| 462 | EXPORT_SYMBOL(tcp_poll); | 465 | EXPORT_SYMBOL(tcp_poll); |
| @@ -940,7 +943,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
| 940 | sg = sk->sk_route_caps & NETIF_F_SG; | 943 | sg = sk->sk_route_caps & NETIF_F_SG; |
| 941 | 944 | ||
| 942 | while (--iovlen >= 0) { | 945 | while (--iovlen >= 0) { |
| 943 | int seglen = iov->iov_len; | 946 | size_t seglen = iov->iov_len; |
| 944 | unsigned char __user *from = iov->iov_base; | 947 | unsigned char __user *from = iov->iov_base; |
| 945 | 948 | ||
| 946 | iov++; | 949 | iov++; |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index e663b78a2ef6..b55f60f6fcbe 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
| @@ -2545,7 +2545,8 @@ static void tcp_mark_head_lost(struct sock *sk, int packets) | |||
| 2545 | cnt += tcp_skb_pcount(skb); | 2545 | cnt += tcp_skb_pcount(skb); |
| 2546 | 2546 | ||
| 2547 | if (cnt > packets) { | 2547 | if (cnt > packets) { |
| 2548 | if (tcp_is_sack(tp) || (oldcnt >= packets)) | 2548 | if ((tcp_is_sack(tp) && !tcp_is_fack(tp)) || |
| 2549 | (oldcnt >= packets)) | ||
| 2549 | break; | 2550 | break; |
| 2550 | 2551 | ||
| 2551 | mss = skb_shinfo(skb)->gso_size; | 2552 | mss = skb_shinfo(skb)->gso_size; |
| @@ -4048,6 +4049,8 @@ static void tcp_reset(struct sock *sk) | |||
| 4048 | default: | 4049 | default: |
| 4049 | sk->sk_err = ECONNRESET; | 4050 | sk->sk_err = ECONNRESET; |
| 4050 | } | 4051 | } |
| 4052 | /* This barrier is coupled with smp_rmb() in tcp_poll() */ | ||
| 4053 | smp_wmb(); | ||
| 4051 | 4054 | ||
| 4052 | if (!sock_flag(sk, SOCK_DEAD)) | 4055 | if (!sock_flag(sk, SOCK_DEAD)) |
| 4053 | sk->sk_error_report(sk); | 4056 | sk->sk_error_report(sk); |
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index c35b469e851c..74c54b30600f 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
| @@ -135,13 +135,16 @@ static void tcp_mtu_probing(struct inet_connection_sock *icsk, struct sock *sk) | |||
| 135 | 135 | ||
| 136 | /* This function calculates a "timeout" which is equivalent to the timeout of a | 136 | /* This function calculates a "timeout" which is equivalent to the timeout of a |
| 137 | * TCP connection after "boundary" unsuccessful, exponentially backed-off | 137 | * TCP connection after "boundary" unsuccessful, exponentially backed-off |
| 138 | * retransmissions with an initial RTO of TCP_RTO_MIN. | 138 | * retransmissions with an initial RTO of TCP_RTO_MIN or TCP_TIMEOUT_INIT if |
| 139 | * syn_set flag is set. | ||
| 139 | */ | 140 | */ |
| 140 | static bool retransmits_timed_out(struct sock *sk, | 141 | static bool retransmits_timed_out(struct sock *sk, |
| 141 | unsigned int boundary) | 142 | unsigned int boundary, |
| 143 | bool syn_set) | ||
| 142 | { | 144 | { |
| 143 | unsigned int timeout, linear_backoff_thresh; | 145 | unsigned int timeout, linear_backoff_thresh; |
| 144 | unsigned int start_ts; | 146 | unsigned int start_ts; |
| 147 | unsigned int rto_base = syn_set ? TCP_TIMEOUT_INIT : TCP_RTO_MIN; | ||
| 145 | 148 | ||
| 146 | if (!inet_csk(sk)->icsk_retransmits) | 149 | if (!inet_csk(sk)->icsk_retransmits) |
| 147 | return false; | 150 | return false; |
| @@ -151,12 +154,12 @@ static bool retransmits_timed_out(struct sock *sk, | |||
| 151 | else | 154 | else |
| 152 | start_ts = tcp_sk(sk)->retrans_stamp; | 155 | start_ts = tcp_sk(sk)->retrans_stamp; |
| 153 | 156 | ||
| 154 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/TCP_RTO_MIN); | 157 | linear_backoff_thresh = ilog2(TCP_RTO_MAX/rto_base); |
| 155 | 158 | ||
| 156 | if (boundary <= linear_backoff_thresh) | 159 | if (boundary <= linear_backoff_thresh) |
| 157 | timeout = ((2 << boundary) - 1) * TCP_RTO_MIN; | 160 | timeout = ((2 << boundary) - 1) * rto_base; |
| 158 | else | 161 | else |
| 159 | timeout = ((2 << linear_backoff_thresh) - 1) * TCP_RTO_MIN + | 162 | timeout = ((2 << linear_backoff_thresh) - 1) * rto_base + |
| 160 | (boundary - linear_backoff_thresh) * TCP_RTO_MAX; | 163 | (boundary - linear_backoff_thresh) * TCP_RTO_MAX; |
| 161 | 164 | ||
| 162 | return (tcp_time_stamp - start_ts) >= timeout; | 165 | return (tcp_time_stamp - start_ts) >= timeout; |
| @@ -167,14 +170,15 @@ static int tcp_write_timeout(struct sock *sk) | |||
| 167 | { | 170 | { |
| 168 | struct inet_connection_sock *icsk = inet_csk(sk); | 171 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 169 | int retry_until; | 172 | int retry_until; |
| 170 | bool do_reset; | 173 | bool do_reset, syn_set = 0; |
| 171 | 174 | ||
| 172 | if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { | 175 | if ((1 << sk->sk_state) & (TCPF_SYN_SENT | TCPF_SYN_RECV)) { |
| 173 | if (icsk->icsk_retransmits) | 176 | if (icsk->icsk_retransmits) |
| 174 | dst_negative_advice(sk); | 177 | dst_negative_advice(sk); |
| 175 | retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; | 178 | retry_until = icsk->icsk_syn_retries ? : sysctl_tcp_syn_retries; |
| 179 | syn_set = 1; | ||
| 176 | } else { | 180 | } else { |
| 177 | if (retransmits_timed_out(sk, sysctl_tcp_retries1)) { | 181 | if (retransmits_timed_out(sk, sysctl_tcp_retries1, 0)) { |
| 178 | /* Black hole detection */ | 182 | /* Black hole detection */ |
| 179 | tcp_mtu_probing(icsk, sk); | 183 | tcp_mtu_probing(icsk, sk); |
| 180 | 184 | ||
| @@ -187,14 +191,14 @@ static int tcp_write_timeout(struct sock *sk) | |||
| 187 | 191 | ||
| 188 | retry_until = tcp_orphan_retries(sk, alive); | 192 | retry_until = tcp_orphan_retries(sk, alive); |
| 189 | do_reset = alive || | 193 | do_reset = alive || |
| 190 | !retransmits_timed_out(sk, retry_until); | 194 | !retransmits_timed_out(sk, retry_until, 0); |
| 191 | 195 | ||
| 192 | if (tcp_out_of_resources(sk, do_reset)) | 196 | if (tcp_out_of_resources(sk, do_reset)) |
| 193 | return 1; | 197 | return 1; |
| 194 | } | 198 | } |
| 195 | } | 199 | } |
| 196 | 200 | ||
| 197 | if (retransmits_timed_out(sk, retry_until)) { | 201 | if (retransmits_timed_out(sk, retry_until, syn_set)) { |
| 198 | /* Has it gone just too far? */ | 202 | /* Has it gone just too far? */ |
| 199 | tcp_write_err(sk); | 203 | tcp_write_err(sk); |
| 200 | return 1; | 204 | return 1; |
| @@ -436,7 +440,7 @@ out_reset_timer: | |||
| 436 | icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); | 440 | icsk->icsk_rto = min(icsk->icsk_rto << 1, TCP_RTO_MAX); |
| 437 | } | 441 | } |
| 438 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); | 442 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, icsk->icsk_rto, TCP_RTO_MAX); |
| 439 | if (retransmits_timed_out(sk, sysctl_tcp_retries1 + 1)) | 443 | if (retransmits_timed_out(sk, sysctl_tcp_retries1 + 1, 0)) |
| 440 | __sk_dst_reset(sk); | 444 | __sk_dst_reset(sk); |
| 441 | 445 | ||
| 442 | out:; | 446 | out:; |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index 869078d4eeb9..a580349f0b8a 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
| @@ -61,7 +61,7 @@ static int xfrm4_get_saddr(struct net *net, | |||
| 61 | 61 | ||
| 62 | static int xfrm4_get_tos(struct flowi *fl) | 62 | static int xfrm4_get_tos(struct flowi *fl) |
| 63 | { | 63 | { |
| 64 | return fl->fl4_tos; | 64 | return IPTOS_RT_MASK & fl->fl4_tos; /* Strip ECN bits */ |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | static int xfrm4_init_path(struct xfrm_dst *path, struct dst_entry *dst, | 67 | static int xfrm4_init_path(struct xfrm_dst *path, struct dst_entry *dst, |
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c index 1ef1366a0a03..47947624eccc 100644 --- a/net/ipv4/xfrm4_state.c +++ b/net/ipv4/xfrm4_state.c | |||
| @@ -21,21 +21,25 @@ static int xfrm4_init_flags(struct xfrm_state *x) | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | static void | 23 | static void |
| 24 | __xfrm4_init_tempsel(struct xfrm_state *x, struct flowi *fl, | 24 | __xfrm4_init_tempsel(struct xfrm_selector *sel, struct flowi *fl) |
| 25 | struct xfrm_tmpl *tmpl, | 25 | { |
| 26 | xfrm_address_t *daddr, xfrm_address_t *saddr) | 26 | sel->daddr.a4 = fl->fl4_dst; |
| 27 | sel->saddr.a4 = fl->fl4_src; | ||
| 28 | sel->dport = xfrm_flowi_dport(fl); | ||
| 29 | sel->dport_mask = htons(0xffff); | ||
| 30 | sel->sport = xfrm_flowi_sport(fl); | ||
| 31 | sel->sport_mask = htons(0xffff); | ||
| 32 | sel->family = AF_INET; | ||
| 33 | sel->prefixlen_d = 32; | ||
| 34 | sel->prefixlen_s = 32; | ||
| 35 | sel->proto = fl->proto; | ||
| 36 | sel->ifindex = fl->oif; | ||
| 37 | } | ||
| 38 | |||
| 39 | static void | ||
| 40 | xfrm4_init_temprop(struct xfrm_state *x, struct xfrm_tmpl *tmpl, | ||
| 41 | xfrm_address_t *daddr, xfrm_address_t *saddr) | ||
| 27 | { | 42 | { |
| 28 | x->sel.daddr.a4 = fl->fl4_dst; | ||
| 29 | x->sel.saddr.a4 = fl->fl4_src; | ||
| 30 | x->sel.dport = xfrm_flowi_dport(fl); | ||
| 31 | x->sel.dport_mask = htons(0xffff); | ||
| 32 | x->sel.sport = xfrm_flowi_sport(fl); | ||
| 33 | x->sel.sport_mask = htons(0xffff); | ||
| 34 | x->sel.family = AF_INET; | ||
| 35 | x->sel.prefixlen_d = 32; | ||
| 36 | x->sel.prefixlen_s = 32; | ||
| 37 | x->sel.proto = fl->proto; | ||
| 38 | x->sel.ifindex = fl->oif; | ||
| 39 | x->id = tmpl->id; | 43 | x->id = tmpl->id; |
| 40 | if (x->id.daddr.a4 == 0) | 44 | if (x->id.daddr.a4 == 0) |
| 41 | x->id.daddr.a4 = daddr->a4; | 45 | x->id.daddr.a4 = daddr->a4; |
| @@ -70,6 +74,7 @@ static struct xfrm_state_afinfo xfrm4_state_afinfo = { | |||
| 70 | .owner = THIS_MODULE, | 74 | .owner = THIS_MODULE, |
| 71 | .init_flags = xfrm4_init_flags, | 75 | .init_flags = xfrm4_init_flags, |
| 72 | .init_tempsel = __xfrm4_init_tempsel, | 76 | .init_tempsel = __xfrm4_init_tempsel, |
| 77 | .init_temprop = xfrm4_init_temprop, | ||
| 73 | .output = xfrm4_output, | 78 | .output = xfrm4_output, |
| 74 | .extract_input = xfrm4_extract_input, | 79 | .extract_input = xfrm4_extract_input, |
| 75 | .extract_output = xfrm4_extract_output, | 80 | .extract_output = xfrm4_extract_output, |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index ab70a3fbcafa..324fac3b6c16 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
| @@ -4637,10 +4637,12 @@ int __init addrconf_init(void) | |||
| 4637 | if (err < 0) { | 4637 | if (err < 0) { |
| 4638 | printk(KERN_CRIT "IPv6 Addrconf:" | 4638 | printk(KERN_CRIT "IPv6 Addrconf:" |
| 4639 | " cannot initialize default policy table: %d.\n", err); | 4639 | " cannot initialize default policy table: %d.\n", err); |
| 4640 | return err; | 4640 | goto out; |
| 4641 | } | 4641 | } |
| 4642 | 4642 | ||
| 4643 | register_pernet_subsys(&addrconf_ops); | 4643 | err = register_pernet_subsys(&addrconf_ops); |
| 4644 | if (err < 0) | ||
| 4645 | goto out_addrlabel; | ||
| 4644 | 4646 | ||
| 4645 | /* The addrconf netdev notifier requires that loopback_dev | 4647 | /* The addrconf netdev notifier requires that loopback_dev |
| 4646 | * has it's ipv6 private information allocated and setup | 4648 | * has it's ipv6 private information allocated and setup |
| @@ -4692,7 +4694,9 @@ errout: | |||
| 4692 | unregister_netdevice_notifier(&ipv6_dev_notf); | 4694 | unregister_netdevice_notifier(&ipv6_dev_notf); |
| 4693 | errlo: | 4695 | errlo: |
| 4694 | unregister_pernet_subsys(&addrconf_ops); | 4696 | unregister_pernet_subsys(&addrconf_ops); |
| 4695 | 4697 | out_addrlabel: | |
| 4698 | ipv6_addr_label_cleanup(); | ||
| 4699 | out: | ||
| 4696 | return err; | 4700 | return err; |
| 4697 | } | 4701 | } |
| 4698 | 4702 | ||
| @@ -4703,6 +4707,7 @@ void addrconf_cleanup(void) | |||
| 4703 | 4707 | ||
| 4704 | unregister_netdevice_notifier(&ipv6_dev_notf); | 4708 | unregister_netdevice_notifier(&ipv6_dev_notf); |
| 4705 | unregister_pernet_subsys(&addrconf_ops); | 4709 | unregister_pernet_subsys(&addrconf_ops); |
| 4710 | ipv6_addr_label_cleanup(); | ||
| 4706 | 4711 | ||
| 4707 | rtnl_lock(); | 4712 | rtnl_lock(); |
| 4708 | 4713 | ||
diff --git a/net/ipv6/addrlabel.c b/net/ipv6/addrlabel.c index f0e774cea386..8175f802651b 100644 --- a/net/ipv6/addrlabel.c +++ b/net/ipv6/addrlabel.c | |||
| @@ -393,6 +393,11 @@ int __init ipv6_addr_label_init(void) | |||
| 393 | return register_pernet_subsys(&ipv6_addr_label_ops); | 393 | return register_pernet_subsys(&ipv6_addr_label_ops); |
| 394 | } | 394 | } |
| 395 | 395 | ||
| 396 | void ipv6_addr_label_cleanup(void) | ||
| 397 | { | ||
| 398 | unregister_pernet_subsys(&ipv6_addr_label_ops); | ||
| 399 | } | ||
| 400 | |||
| 396 | static const struct nla_policy ifal_policy[IFAL_MAX+1] = { | 401 | static const struct nla_policy ifal_policy[IFAL_MAX+1] = { |
| 397 | [IFAL_ADDRESS] = { .len = sizeof(struct in6_addr), }, | 402 | [IFAL_ADDRESS] = { .len = sizeof(struct in6_addr), }, |
| 398 | [IFAL_LABEL] = { .len = sizeof(u32), }, | 403 | [IFAL_LABEL] = { .len = sizeof(u32), }, |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index d40b330c0ee6..980912ed7a38 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
| @@ -639,7 +639,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 639 | 639 | ||
| 640 | if (skb_has_frags(skb)) { | 640 | if (skb_has_frags(skb)) { |
| 641 | int first_len = skb_pagelen(skb); | 641 | int first_len = skb_pagelen(skb); |
| 642 | int truesizes = 0; | 642 | struct sk_buff *frag2; |
| 643 | 643 | ||
| 644 | if (first_len - hlen > mtu || | 644 | if (first_len - hlen > mtu || |
| 645 | ((first_len - hlen) & 7) || | 645 | ((first_len - hlen) & 7) || |
| @@ -651,18 +651,18 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 651 | if (frag->len > mtu || | 651 | if (frag->len > mtu || |
| 652 | ((frag->len & 7) && frag->next) || | 652 | ((frag->len & 7) && frag->next) || |
| 653 | skb_headroom(frag) < hlen) | 653 | skb_headroom(frag) < hlen) |
| 654 | goto slow_path; | 654 | goto slow_path_clean; |
| 655 | 655 | ||
| 656 | /* Partially cloned skb? */ | 656 | /* Partially cloned skb? */ |
| 657 | if (skb_shared(frag)) | 657 | if (skb_shared(frag)) |
| 658 | goto slow_path; | 658 | goto slow_path_clean; |
| 659 | 659 | ||
| 660 | BUG_ON(frag->sk); | 660 | BUG_ON(frag->sk); |
| 661 | if (skb->sk) { | 661 | if (skb->sk) { |
| 662 | frag->sk = skb->sk; | 662 | frag->sk = skb->sk; |
| 663 | frag->destructor = sock_wfree; | 663 | frag->destructor = sock_wfree; |
| 664 | truesizes += frag->truesize; | ||
| 665 | } | 664 | } |
| 665 | skb->truesize -= frag->truesize; | ||
| 666 | } | 666 | } |
| 667 | 667 | ||
| 668 | err = 0; | 668 | err = 0; |
| @@ -693,7 +693,6 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 693 | 693 | ||
| 694 | first_len = skb_pagelen(skb); | 694 | first_len = skb_pagelen(skb); |
| 695 | skb->data_len = first_len - skb_headlen(skb); | 695 | skb->data_len = first_len - skb_headlen(skb); |
| 696 | skb->truesize -= truesizes; | ||
| 697 | skb->len = first_len; | 696 | skb->len = first_len; |
| 698 | ipv6_hdr(skb)->payload_len = htons(first_len - | 697 | ipv6_hdr(skb)->payload_len = htons(first_len - |
| 699 | sizeof(struct ipv6hdr)); | 698 | sizeof(struct ipv6hdr)); |
| @@ -756,6 +755,15 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *)) | |||
| 756 | IPSTATS_MIB_FRAGFAILS); | 755 | IPSTATS_MIB_FRAGFAILS); |
| 757 | dst_release(&rt->dst); | 756 | dst_release(&rt->dst); |
| 758 | return err; | 757 | return err; |
| 758 | |||
| 759 | slow_path_clean: | ||
| 760 | skb_walk_frags(skb, frag2) { | ||
| 761 | if (frag2 == frag) | ||
| 762 | break; | ||
| 763 | frag2->sk = NULL; | ||
| 764 | frag2->destructor = NULL; | ||
| 765 | skb->truesize += frag2->truesize; | ||
| 766 | } | ||
| 759 | } | 767 | } |
| 760 | 768 | ||
| 761 | slow_path: | 769 | slow_path: |
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index d126365ac046..a275c6e1e25c 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
| @@ -670,7 +670,7 @@ static struct rt6_info *rt6_alloc_cow(struct rt6_info *ort, struct in6_addr *dad | |||
| 670 | 670 | ||
| 671 | if (net_ratelimit()) | 671 | if (net_ratelimit()) |
| 672 | printk(KERN_WARNING | 672 | printk(KERN_WARNING |
| 673 | "Neighbour table overflow.\n"); | 673 | "ipv6: Neighbour table overflow.\n"); |
| 674 | dst_free(&rt->dst); | 674 | dst_free(&rt->dst); |
| 675 | return NULL; | 675 | return NULL; |
| 676 | } | 676 | } |
| @@ -1556,14 +1556,13 @@ out: | |||
| 1556 | * i.e. Path MTU discovery | 1556 | * i.e. Path MTU discovery |
| 1557 | */ | 1557 | */ |
| 1558 | 1558 | ||
| 1559 | void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr, | 1559 | static void rt6_do_pmtu_disc(struct in6_addr *daddr, struct in6_addr *saddr, |
| 1560 | struct net_device *dev, u32 pmtu) | 1560 | struct net *net, u32 pmtu, int ifindex) |
| 1561 | { | 1561 | { |
| 1562 | struct rt6_info *rt, *nrt; | 1562 | struct rt6_info *rt, *nrt; |
| 1563 | struct net *net = dev_net(dev); | ||
| 1564 | int allfrag = 0; | 1563 | int allfrag = 0; |
| 1565 | 1564 | ||
| 1566 | rt = rt6_lookup(net, daddr, saddr, dev->ifindex, 0); | 1565 | rt = rt6_lookup(net, daddr, saddr, ifindex, 0); |
| 1567 | if (rt == NULL) | 1566 | if (rt == NULL) |
| 1568 | return; | 1567 | return; |
| 1569 | 1568 | ||
| @@ -1631,6 +1630,27 @@ out: | |||
| 1631 | dst_release(&rt->dst); | 1630 | dst_release(&rt->dst); |
| 1632 | } | 1631 | } |
| 1633 | 1632 | ||
| 1633 | void rt6_pmtu_discovery(struct in6_addr *daddr, struct in6_addr *saddr, | ||
| 1634 | struct net_device *dev, u32 pmtu) | ||
| 1635 | { | ||
| 1636 | struct net *net = dev_net(dev); | ||
| 1637 | |||
| 1638 | /* | ||
| 1639 | * RFC 1981 states that a node "MUST reduce the size of the packets it | ||
| 1640 | * is sending along the path" that caused the Packet Too Big message. | ||
| 1641 | * Since it's not possible in the general case to determine which | ||
| 1642 | * interface was used to send the original packet, we update the MTU | ||
| 1643 | * on the interface that will be used to send future packets. We also | ||
| 1644 | * update the MTU on the interface that received the Packet Too Big in | ||
| 1645 | * case the original packet was forced out that interface with | ||
| 1646 | * SO_BINDTODEVICE or similar. This is the next best thing to the | ||
| 1647 | * correct behaviour, which would be to update the MTU on all | ||
| 1648 | * interfaces. | ||
| 1649 | */ | ||
| 1650 | rt6_do_pmtu_disc(daddr, saddr, net, pmtu, 0); | ||
| 1651 | rt6_do_pmtu_disc(daddr, saddr, net, pmtu, dev->ifindex); | ||
| 1652 | } | ||
| 1653 | |||
| 1634 | /* | 1654 | /* |
| 1635 | * Misc support functions | 1655 | * Misc support functions |
| 1636 | */ | 1656 | */ |
diff --git a/net/ipv6/xfrm6_state.c b/net/ipv6/xfrm6_state.c index f417b77fa0e1..a67575d472a3 100644 --- a/net/ipv6/xfrm6_state.c +++ b/net/ipv6/xfrm6_state.c | |||
| @@ -20,23 +20,27 @@ | |||
| 20 | #include <net/addrconf.h> | 20 | #include <net/addrconf.h> |
| 21 | 21 | ||
| 22 | static void | 22 | static void |
| 23 | __xfrm6_init_tempsel(struct xfrm_state *x, struct flowi *fl, | 23 | __xfrm6_init_tempsel(struct xfrm_selector *sel, struct flowi *fl) |
| 24 | struct xfrm_tmpl *tmpl, | ||
| 25 | xfrm_address_t *daddr, xfrm_address_t *saddr) | ||
| 26 | { | 24 | { |
| 27 | /* Initialize temporary selector matching only | 25 | /* Initialize temporary selector matching only |
| 28 | * to current session. */ | 26 | * to current session. */ |
| 29 | ipv6_addr_copy((struct in6_addr *)&x->sel.daddr, &fl->fl6_dst); | 27 | ipv6_addr_copy((struct in6_addr *)&sel->daddr, &fl->fl6_dst); |
| 30 | ipv6_addr_copy((struct in6_addr *)&x->sel.saddr, &fl->fl6_src); | 28 | ipv6_addr_copy((struct in6_addr *)&sel->saddr, &fl->fl6_src); |
| 31 | x->sel.dport = xfrm_flowi_dport(fl); | 29 | sel->dport = xfrm_flowi_dport(fl); |
| 32 | x->sel.dport_mask = htons(0xffff); | 30 | sel->dport_mask = htons(0xffff); |
| 33 | x->sel.sport = xfrm_flowi_sport(fl); | 31 | sel->sport = xfrm_flowi_sport(fl); |
| 34 | x->sel.sport_mask = htons(0xffff); | 32 | sel->sport_mask = htons(0xffff); |
| 35 | x->sel.family = AF_INET6; | 33 | sel->family = AF_INET6; |
| 36 | x->sel.prefixlen_d = 128; | 34 | sel->prefixlen_d = 128; |
| 37 | x->sel.prefixlen_s = 128; | 35 | sel->prefixlen_s = 128; |
| 38 | x->sel.proto = fl->proto; | 36 | sel->proto = fl->proto; |
| 39 | x->sel.ifindex = fl->oif; | 37 | sel->ifindex = fl->oif; |
| 38 | } | ||
| 39 | |||
| 40 | static void | ||
| 41 | xfrm6_init_temprop(struct xfrm_state *x, struct xfrm_tmpl *tmpl, | ||
| 42 | xfrm_address_t *daddr, xfrm_address_t *saddr) | ||
| 43 | { | ||
| 40 | x->id = tmpl->id; | 44 | x->id = tmpl->id; |
| 41 | if (ipv6_addr_any((struct in6_addr*)&x->id.daddr)) | 45 | if (ipv6_addr_any((struct in6_addr*)&x->id.daddr)) |
| 42 | memcpy(&x->id.daddr, daddr, sizeof(x->sel.daddr)); | 46 | memcpy(&x->id.daddr, daddr, sizeof(x->sel.daddr)); |
| @@ -168,6 +172,7 @@ static struct xfrm_state_afinfo xfrm6_state_afinfo = { | |||
| 168 | .eth_proto = htons(ETH_P_IPV6), | 172 | .eth_proto = htons(ETH_P_IPV6), |
| 169 | .owner = THIS_MODULE, | 173 | .owner = THIS_MODULE, |
| 170 | .init_tempsel = __xfrm6_init_tempsel, | 174 | .init_tempsel = __xfrm6_init_tempsel, |
| 175 | .init_temprop = xfrm6_init_temprop, | ||
| 171 | .tmpl_sort = __xfrm6_tmpl_sort, | 176 | .tmpl_sort = __xfrm6_tmpl_sort, |
| 172 | .state_sort = __xfrm6_state_sort, | 177 | .state_sort = __xfrm6_state_sort, |
| 173 | .output = xfrm6_output, | 178 | .output = xfrm6_output, |
diff --git a/net/mac80211/agg-tx.c b/net/mac80211/agg-tx.c index c893f236acea..8f23401832b7 100644 --- a/net/mac80211/agg-tx.c +++ b/net/mac80211/agg-tx.c | |||
| @@ -175,6 +175,8 @@ int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid, | |||
| 175 | 175 | ||
| 176 | set_bit(HT_AGG_STATE_STOPPING, &tid_tx->state); | 176 | set_bit(HT_AGG_STATE_STOPPING, &tid_tx->state); |
| 177 | 177 | ||
| 178 | del_timer_sync(&tid_tx->addba_resp_timer); | ||
| 179 | |||
| 178 | /* | 180 | /* |
| 179 | * After this packets are no longer handed right through | 181 | * After this packets are no longer handed right through |
| 180 | * to the driver but are put onto tid_tx->pending instead, | 182 | * to the driver but are put onto tid_tx->pending instead, |
diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index fa0f37e4afe4..28624282c5f3 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c | |||
| @@ -2199,9 +2199,6 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, | |||
| 2199 | struct net_device *prev_dev = NULL; | 2199 | struct net_device *prev_dev = NULL; |
| 2200 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); | 2200 | struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); |
| 2201 | 2201 | ||
| 2202 | if (status->flag & RX_FLAG_INTERNAL_CMTR) | ||
| 2203 | goto out_free_skb; | ||
| 2204 | |||
| 2205 | if (skb_headroom(skb) < sizeof(*rthdr) && | 2202 | if (skb_headroom(skb) < sizeof(*rthdr) && |
| 2206 | pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC)) | 2203 | pskb_expand_head(skb, sizeof(*rthdr), 0, GFP_ATOMIC)) |
| 2207 | goto out_free_skb; | 2204 | goto out_free_skb; |
| @@ -2260,7 +2257,6 @@ static void ieee80211_rx_cooked_monitor(struct ieee80211_rx_data *rx, | |||
| 2260 | } else | 2257 | } else |
| 2261 | goto out_free_skb; | 2258 | goto out_free_skb; |
| 2262 | 2259 | ||
| 2263 | status->flag |= RX_FLAG_INTERNAL_CMTR; | ||
| 2264 | return; | 2260 | return; |
| 2265 | 2261 | ||
| 2266 | out_free_skb: | 2262 | out_free_skb: |
diff --git a/net/mac80211/status.c b/net/mac80211/status.c index 10caec5ea8fa..34da67995d94 100644 --- a/net/mac80211/status.c +++ b/net/mac80211/status.c | |||
| @@ -377,7 +377,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
| 377 | skb2 = skb_clone(skb, GFP_ATOMIC); | 377 | skb2 = skb_clone(skb, GFP_ATOMIC); |
| 378 | if (skb2) { | 378 | if (skb2) { |
| 379 | skb2->dev = prev_dev; | 379 | skb2->dev = prev_dev; |
| 380 | netif_receive_skb(skb2); | 380 | netif_rx(skb2); |
| 381 | } | 381 | } |
| 382 | } | 382 | } |
| 383 | 383 | ||
| @@ -386,7 +386,7 @@ void ieee80211_tx_status(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
| 386 | } | 386 | } |
| 387 | if (prev_dev) { | 387 | if (prev_dev) { |
| 388 | skb->dev = prev_dev; | 388 | skb->dev = prev_dev; |
| 389 | netif_receive_skb(skb); | 389 | netif_rx(skb); |
| 390 | skb = NULL; | 390 | skb = NULL; |
| 391 | } | 391 | } |
| 392 | rcu_read_unlock(); | 392 | rcu_read_unlock(); |
diff --git a/net/netfilter/nf_conntrack_extend.c b/net/netfilter/nf_conntrack_extend.c index 7dcf7a404190..8d9e4c949b96 100644 --- a/net/netfilter/nf_conntrack_extend.c +++ b/net/netfilter/nf_conntrack_extend.c | |||
| @@ -48,15 +48,17 @@ nf_ct_ext_create(struct nf_ct_ext **ext, enum nf_ct_ext_id id, gfp_t gfp) | |||
| 48 | { | 48 | { |
| 49 | unsigned int off, len; | 49 | unsigned int off, len; |
| 50 | struct nf_ct_ext_type *t; | 50 | struct nf_ct_ext_type *t; |
| 51 | size_t alloc_size; | ||
| 51 | 52 | ||
| 52 | rcu_read_lock(); | 53 | rcu_read_lock(); |
| 53 | t = rcu_dereference(nf_ct_ext_types[id]); | 54 | t = rcu_dereference(nf_ct_ext_types[id]); |
| 54 | BUG_ON(t == NULL); | 55 | BUG_ON(t == NULL); |
| 55 | off = ALIGN(sizeof(struct nf_ct_ext), t->align); | 56 | off = ALIGN(sizeof(struct nf_ct_ext), t->align); |
| 56 | len = off + t->len; | 57 | len = off + t->len; |
| 58 | alloc_size = t->alloc_size; | ||
| 57 | rcu_read_unlock(); | 59 | rcu_read_unlock(); |
| 58 | 60 | ||
| 59 | *ext = kzalloc(t->alloc_size, gfp); | 61 | *ext = kzalloc(alloc_size, gfp); |
| 60 | if (!*ext) | 62 | if (!*ext) |
| 61 | return NULL; | 63 | return NULL; |
| 62 | 64 | ||
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c index 53d892210a04..f64de9544866 100644 --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c | |||
| @@ -1376,7 +1376,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff, | |||
| 1376 | unsigned int msglen, origlen; | 1376 | unsigned int msglen, origlen; |
| 1377 | const char *dptr, *end; | 1377 | const char *dptr, *end; |
| 1378 | s16 diff, tdiff = 0; | 1378 | s16 diff, tdiff = 0; |
| 1379 | int ret; | 1379 | int ret = NF_ACCEPT; |
| 1380 | typeof(nf_nat_sip_seq_adjust_hook) nf_nat_sip_seq_adjust; | 1380 | typeof(nf_nat_sip_seq_adjust_hook) nf_nat_sip_seq_adjust; |
| 1381 | 1381 | ||
| 1382 | if (ctinfo != IP_CT_ESTABLISHED && | 1382 | if (ctinfo != IP_CT_ESTABLISHED && |
diff --git a/net/netfilter/nf_tproxy_core.c b/net/netfilter/nf_tproxy_core.c index 5490fc37c92d..daab8c4a903c 100644 --- a/net/netfilter/nf_tproxy_core.c +++ b/net/netfilter/nf_tproxy_core.c | |||
| @@ -70,7 +70,11 @@ nf_tproxy_destructor(struct sk_buff *skb) | |||
| 70 | int | 70 | int |
| 71 | nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk) | 71 | nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk) |
| 72 | { | 72 | { |
| 73 | if (inet_sk(sk)->transparent) { | 73 | bool transparent = (sk->sk_state == TCP_TIME_WAIT) ? |
| 74 | inet_twsk(sk)->tw_transparent : | ||
| 75 | inet_sk(sk)->transparent; | ||
| 76 | |||
| 77 | if (transparent) { | ||
| 74 | skb_orphan(skb); | 78 | skb_orphan(skb); |
| 75 | skb->sk = sk; | 79 | skb->sk = sk; |
| 76 | skb->destructor = nf_tproxy_destructor; | 80 | skb->destructor = nf_tproxy_destructor; |
diff --git a/net/phonet/pep.c b/net/phonet/pep.c index b2a3ae6cad78..15003021f4f0 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c | |||
| @@ -225,12 +225,13 @@ static void pipe_grant_credits(struct sock *sk) | |||
| 225 | static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb) | 225 | static int pipe_rcv_status(struct sock *sk, struct sk_buff *skb) |
| 226 | { | 226 | { |
| 227 | struct pep_sock *pn = pep_sk(sk); | 227 | struct pep_sock *pn = pep_sk(sk); |
| 228 | struct pnpipehdr *hdr = pnp_hdr(skb); | 228 | struct pnpipehdr *hdr; |
| 229 | int wake = 0; | 229 | int wake = 0; |
| 230 | 230 | ||
| 231 | if (!pskb_may_pull(skb, sizeof(*hdr) + 4)) | 231 | if (!pskb_may_pull(skb, sizeof(*hdr) + 4)) |
| 232 | return -EINVAL; | 232 | return -EINVAL; |
| 233 | 233 | ||
| 234 | hdr = pnp_hdr(skb); | ||
| 234 | if (hdr->data[0] != PN_PEP_TYPE_COMMON) { | 235 | if (hdr->data[0] != PN_PEP_TYPE_COMMON) { |
| 235 | LIMIT_NETDEBUG(KERN_DEBUG"Phonet unknown PEP type: %u\n", | 236 | LIMIT_NETDEBUG(KERN_DEBUG"Phonet unknown PEP type: %u\n", |
| 236 | (unsigned)hdr->data[0]); | 237 | (unsigned)hdr->data[0]); |
diff --git a/net/rds/tcp_connect.c b/net/rds/tcp_connect.c index c397524c039c..c519939e8da9 100644 --- a/net/rds/tcp_connect.c +++ b/net/rds/tcp_connect.c | |||
| @@ -43,7 +43,7 @@ void rds_tcp_state_change(struct sock *sk) | |||
| 43 | struct rds_connection *conn; | 43 | struct rds_connection *conn; |
| 44 | struct rds_tcp_connection *tc; | 44 | struct rds_tcp_connection *tc; |
| 45 | 45 | ||
| 46 | read_lock(&sk->sk_callback_lock); | 46 | read_lock_bh(&sk->sk_callback_lock); |
| 47 | conn = sk->sk_user_data; | 47 | conn = sk->sk_user_data; |
| 48 | if (conn == NULL) { | 48 | if (conn == NULL) { |
| 49 | state_change = sk->sk_state_change; | 49 | state_change = sk->sk_state_change; |
| @@ -68,7 +68,7 @@ void rds_tcp_state_change(struct sock *sk) | |||
| 68 | break; | 68 | break; |
| 69 | } | 69 | } |
| 70 | out: | 70 | out: |
| 71 | read_unlock(&sk->sk_callback_lock); | 71 | read_unlock_bh(&sk->sk_callback_lock); |
| 72 | state_change(sk); | 72 | state_change(sk); |
| 73 | } | 73 | } |
| 74 | 74 | ||
diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c index 975183fe6950..27844f231d10 100644 --- a/net/rds/tcp_listen.c +++ b/net/rds/tcp_listen.c | |||
| @@ -114,7 +114,7 @@ void rds_tcp_listen_data_ready(struct sock *sk, int bytes) | |||
| 114 | 114 | ||
| 115 | rdsdebug("listen data ready sk %p\n", sk); | 115 | rdsdebug("listen data ready sk %p\n", sk); |
| 116 | 116 | ||
| 117 | read_lock(&sk->sk_callback_lock); | 117 | read_lock_bh(&sk->sk_callback_lock); |
| 118 | ready = sk->sk_user_data; | 118 | ready = sk->sk_user_data; |
| 119 | if (ready == NULL) { /* check for teardown race */ | 119 | if (ready == NULL) { /* check for teardown race */ |
| 120 | ready = sk->sk_data_ready; | 120 | ready = sk->sk_data_ready; |
| @@ -131,7 +131,7 @@ void rds_tcp_listen_data_ready(struct sock *sk, int bytes) | |||
| 131 | queue_work(rds_wq, &rds_tcp_listen_work); | 131 | queue_work(rds_wq, &rds_tcp_listen_work); |
| 132 | 132 | ||
| 133 | out: | 133 | out: |
| 134 | read_unlock(&sk->sk_callback_lock); | 134 | read_unlock_bh(&sk->sk_callback_lock); |
| 135 | ready(sk, bytes); | 135 | ready(sk, bytes); |
| 136 | } | 136 | } |
| 137 | 137 | ||
diff --git a/net/rds/tcp_recv.c b/net/rds/tcp_recv.c index 1aba6878fa5d..e43797404102 100644 --- a/net/rds/tcp_recv.c +++ b/net/rds/tcp_recv.c | |||
| @@ -324,7 +324,7 @@ void rds_tcp_data_ready(struct sock *sk, int bytes) | |||
| 324 | 324 | ||
| 325 | rdsdebug("data ready sk %p bytes %d\n", sk, bytes); | 325 | rdsdebug("data ready sk %p bytes %d\n", sk, bytes); |
| 326 | 326 | ||
| 327 | read_lock(&sk->sk_callback_lock); | 327 | read_lock_bh(&sk->sk_callback_lock); |
| 328 | conn = sk->sk_user_data; | 328 | conn = sk->sk_user_data; |
| 329 | if (conn == NULL) { /* check for teardown race */ | 329 | if (conn == NULL) { /* check for teardown race */ |
| 330 | ready = sk->sk_data_ready; | 330 | ready = sk->sk_data_ready; |
| @@ -338,7 +338,7 @@ void rds_tcp_data_ready(struct sock *sk, int bytes) | |||
| 338 | if (rds_tcp_read_sock(conn, GFP_ATOMIC, KM_SOFTIRQ0) == -ENOMEM) | 338 | if (rds_tcp_read_sock(conn, GFP_ATOMIC, KM_SOFTIRQ0) == -ENOMEM) |
| 339 | queue_delayed_work(rds_wq, &conn->c_recv_w, 0); | 339 | queue_delayed_work(rds_wq, &conn->c_recv_w, 0); |
| 340 | out: | 340 | out: |
| 341 | read_unlock(&sk->sk_callback_lock); | 341 | read_unlock_bh(&sk->sk_callback_lock); |
| 342 | ready(sk, bytes); | 342 | ready(sk, bytes); |
| 343 | } | 343 | } |
| 344 | 344 | ||
diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c index a28b895ff0d1..2f012a07d94d 100644 --- a/net/rds/tcp_send.c +++ b/net/rds/tcp_send.c | |||
| @@ -224,7 +224,7 @@ void rds_tcp_write_space(struct sock *sk) | |||
| 224 | struct rds_connection *conn; | 224 | struct rds_connection *conn; |
| 225 | struct rds_tcp_connection *tc; | 225 | struct rds_tcp_connection *tc; |
| 226 | 226 | ||
| 227 | read_lock(&sk->sk_callback_lock); | 227 | read_lock_bh(&sk->sk_callback_lock); |
| 228 | conn = sk->sk_user_data; | 228 | conn = sk->sk_user_data; |
| 229 | if (conn == NULL) { | 229 | if (conn == NULL) { |
| 230 | write_space = sk->sk_write_space; | 230 | write_space = sk->sk_write_space; |
| @@ -244,7 +244,7 @@ void rds_tcp_write_space(struct sock *sk) | |||
| 244 | queue_delayed_work(rds_wq, &conn->c_send_w, 0); | 244 | queue_delayed_work(rds_wq, &conn->c_send_w, 0); |
| 245 | 245 | ||
| 246 | out: | 246 | out: |
| 247 | read_unlock(&sk->sk_callback_lock); | 247 | read_unlock_bh(&sk->sk_callback_lock); |
| 248 | 248 | ||
| 249 | /* | 249 | /* |
| 250 | * write_space is only called when data leaves tcp's send queue if | 250 | * write_space is only called when data leaves tcp's send queue if |
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 8e45e76a95f5..d952e7eac188 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
| @@ -679,7 +679,7 @@ static int rose_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 679 | if (addr_len == sizeof(struct sockaddr_rose) && addr->srose_ndigis > 1) | 679 | if (addr_len == sizeof(struct sockaddr_rose) && addr->srose_ndigis > 1) |
| 680 | return -EINVAL; | 680 | return -EINVAL; |
| 681 | 681 | ||
| 682 | if (addr->srose_ndigis > ROSE_MAX_DIGIS) | 682 | if ((unsigned int) addr->srose_ndigis > ROSE_MAX_DIGIS) |
| 683 | return -EINVAL; | 683 | return -EINVAL; |
| 684 | 684 | ||
| 685 | if ((dev = rose_dev_get(&addr->srose_addr)) == NULL) { | 685 | if ((dev = rose_dev_get(&addr->srose_addr)) == NULL) { |
| @@ -739,7 +739,7 @@ static int rose_connect(struct socket *sock, struct sockaddr *uaddr, int addr_le | |||
| 739 | if (addr_len == sizeof(struct sockaddr_rose) && addr->srose_ndigis > 1) | 739 | if (addr_len == sizeof(struct sockaddr_rose) && addr->srose_ndigis > 1) |
| 740 | return -EINVAL; | 740 | return -EINVAL; |
| 741 | 741 | ||
| 742 | if (addr->srose_ndigis > ROSE_MAX_DIGIS) | 742 | if ((unsigned int) addr->srose_ndigis > ROSE_MAX_DIGIS) |
| 743 | return -EINVAL; | 743 | return -EINVAL; |
| 744 | 744 | ||
| 745 | /* Source + Destination digis should not exceed ROSE_MAX_DIGIS */ | 745 | /* Source + Destination digis should not exceed ROSE_MAX_DIGIS */ |
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index 7416a5c73b2a..b0c2a82178af 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
| @@ -137,7 +137,7 @@ next_knode: | |||
| 137 | int toff = off + key->off + (off2 & key->offmask); | 137 | int toff = off + key->off + (off2 & key->offmask); |
| 138 | __be32 *data, _data; | 138 | __be32 *data, _data; |
| 139 | 139 | ||
| 140 | if (skb_headroom(skb) + toff < 0) | 140 | if (skb_headroom(skb) + toff > INT_MAX) |
| 141 | goto out; | 141 | goto out; |
| 142 | 142 | ||
| 143 | data = skb_header_pointer(skb, toff, 4, &_data); | 143 | data = skb_header_pointer(skb, toff, 4, &_data); |
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 86366390038a..ddbbf7c81fa1 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
| @@ -543,16 +543,20 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc) | |||
| 543 | id = ntohs(hmacs->hmac_ids[i]); | 543 | id = ntohs(hmacs->hmac_ids[i]); |
| 544 | 544 | ||
| 545 | /* Check the id is in the supported range */ | 545 | /* Check the id is in the supported range */ |
| 546 | if (id > SCTP_AUTH_HMAC_ID_MAX) | 546 | if (id > SCTP_AUTH_HMAC_ID_MAX) { |
| 547 | id = 0; | ||
| 547 | continue; | 548 | continue; |
| 549 | } | ||
| 548 | 550 | ||
| 549 | /* See is we support the id. Supported IDs have name and | 551 | /* See is we support the id. Supported IDs have name and |
| 550 | * length fields set, so that we can allocated and use | 552 | * length fields set, so that we can allocated and use |
| 551 | * them. We can safely just check for name, for without the | 553 | * them. We can safely just check for name, for without the |
| 552 | * name, we can't allocate the TFM. | 554 | * name, we can't allocate the TFM. |
| 553 | */ | 555 | */ |
| 554 | if (!sctp_hmac_list[id].hmac_name) | 556 | if (!sctp_hmac_list[id].hmac_name) { |
| 557 | id = 0; | ||
| 555 | continue; | 558 | continue; |
| 559 | } | ||
| 556 | 560 | ||
| 557 | break; | 561 | break; |
| 558 | } | 562 | } |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index ca44917872d2..fbb70770ad05 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
| @@ -916,6 +916,11 @@ SCTP_STATIC int sctp_setsockopt_bindx(struct sock* sk, | |||
| 916 | /* Walk through the addrs buffer and count the number of addresses. */ | 916 | /* Walk through the addrs buffer and count the number of addresses. */ |
| 917 | addr_buf = kaddrs; | 917 | addr_buf = kaddrs; |
| 918 | while (walk_size < addrs_size) { | 918 | while (walk_size < addrs_size) { |
| 919 | if (walk_size + sizeof(sa_family_t) > addrs_size) { | ||
| 920 | kfree(kaddrs); | ||
| 921 | return -EINVAL; | ||
| 922 | } | ||
| 923 | |||
| 919 | sa_addr = (struct sockaddr *)addr_buf; | 924 | sa_addr = (struct sockaddr *)addr_buf; |
| 920 | af = sctp_get_af_specific(sa_addr->sa_family); | 925 | af = sctp_get_af_specific(sa_addr->sa_family); |
| 921 | 926 | ||
| @@ -1002,9 +1007,13 @@ static int __sctp_connect(struct sock* sk, | |||
| 1002 | /* Walk through the addrs buffer and count the number of addresses. */ | 1007 | /* Walk through the addrs buffer and count the number of addresses. */ |
| 1003 | addr_buf = kaddrs; | 1008 | addr_buf = kaddrs; |
| 1004 | while (walk_size < addrs_size) { | 1009 | while (walk_size < addrs_size) { |
| 1010 | if (walk_size + sizeof(sa_family_t) > addrs_size) { | ||
| 1011 | err = -EINVAL; | ||
| 1012 | goto out_free; | ||
| 1013 | } | ||
| 1014 | |||
| 1005 | sa_addr = (union sctp_addr *)addr_buf; | 1015 | sa_addr = (union sctp_addr *)addr_buf; |
| 1006 | af = sctp_get_af_specific(sa_addr->sa.sa_family); | 1016 | af = sctp_get_af_specific(sa_addr->sa.sa_family); |
| 1007 | port = ntohs(sa_addr->v4.sin_port); | ||
| 1008 | 1017 | ||
| 1009 | /* If the address family is not supported or if this address | 1018 | /* If the address family is not supported or if this address |
| 1010 | * causes the address buffer to overflow return EINVAL. | 1019 | * causes the address buffer to overflow return EINVAL. |
| @@ -1014,6 +1023,8 @@ static int __sctp_connect(struct sock* sk, | |||
| 1014 | goto out_free; | 1023 | goto out_free; |
| 1015 | } | 1024 | } |
| 1016 | 1025 | ||
| 1026 | port = ntohs(sa_addr->v4.sin_port); | ||
| 1027 | |||
| 1017 | /* Save current address so we can work with it */ | 1028 | /* Save current address so we can work with it */ |
| 1018 | memcpy(&to, sa_addr, af->sockaddr_len); | 1029 | memcpy(&to, sa_addr, af->sockaddr_len); |
| 1019 | 1030 | ||
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index b6309db56226..fe9306bf10cc 100644 --- a/net/sunrpc/xprtsock.c +++ b/net/sunrpc/xprtsock.c | |||
| @@ -800,7 +800,7 @@ static void xs_udp_data_ready(struct sock *sk, int len) | |||
| 800 | u32 _xid; | 800 | u32 _xid; |
| 801 | __be32 *xp; | 801 | __be32 *xp; |
| 802 | 802 | ||
| 803 | read_lock(&sk->sk_callback_lock); | 803 | read_lock_bh(&sk->sk_callback_lock); |
| 804 | dprintk("RPC: xs_udp_data_ready...\n"); | 804 | dprintk("RPC: xs_udp_data_ready...\n"); |
| 805 | if (!(xprt = xprt_from_sock(sk))) | 805 | if (!(xprt = xprt_from_sock(sk))) |
| 806 | goto out; | 806 | goto out; |
| @@ -852,7 +852,7 @@ static void xs_udp_data_ready(struct sock *sk, int len) | |||
| 852 | dropit: | 852 | dropit: |
| 853 | skb_free_datagram(sk, skb); | 853 | skb_free_datagram(sk, skb); |
| 854 | out: | 854 | out: |
| 855 | read_unlock(&sk->sk_callback_lock); | 855 | read_unlock_bh(&sk->sk_callback_lock); |
| 856 | } | 856 | } |
| 857 | 857 | ||
| 858 | static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_reader *desc) | 858 | static inline void xs_tcp_read_fraghdr(struct rpc_xprt *xprt, struct xdr_skb_reader *desc) |
| @@ -1229,7 +1229,7 @@ static void xs_tcp_data_ready(struct sock *sk, int bytes) | |||
| 1229 | 1229 | ||
| 1230 | dprintk("RPC: xs_tcp_data_ready...\n"); | 1230 | dprintk("RPC: xs_tcp_data_ready...\n"); |
| 1231 | 1231 | ||
| 1232 | read_lock(&sk->sk_callback_lock); | 1232 | read_lock_bh(&sk->sk_callback_lock); |
| 1233 | if (!(xprt = xprt_from_sock(sk))) | 1233 | if (!(xprt = xprt_from_sock(sk))) |
| 1234 | goto out; | 1234 | goto out; |
| 1235 | if (xprt->shutdown) | 1235 | if (xprt->shutdown) |
| @@ -1248,7 +1248,7 @@ static void xs_tcp_data_ready(struct sock *sk, int bytes) | |||
| 1248 | read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv); | 1248 | read = tcp_read_sock(sk, &rd_desc, xs_tcp_data_recv); |
| 1249 | } while (read > 0); | 1249 | } while (read > 0); |
| 1250 | out: | 1250 | out: |
| 1251 | read_unlock(&sk->sk_callback_lock); | 1251 | read_unlock_bh(&sk->sk_callback_lock); |
| 1252 | } | 1252 | } |
| 1253 | 1253 | ||
| 1254 | /* | 1254 | /* |
| @@ -1301,7 +1301,7 @@ static void xs_tcp_state_change(struct sock *sk) | |||
| 1301 | { | 1301 | { |
| 1302 | struct rpc_xprt *xprt; | 1302 | struct rpc_xprt *xprt; |
| 1303 | 1303 | ||
| 1304 | read_lock(&sk->sk_callback_lock); | 1304 | read_lock_bh(&sk->sk_callback_lock); |
| 1305 | if (!(xprt = xprt_from_sock(sk))) | 1305 | if (!(xprt = xprt_from_sock(sk))) |
| 1306 | goto out; | 1306 | goto out; |
| 1307 | dprintk("RPC: xs_tcp_state_change client %p...\n", xprt); | 1307 | dprintk("RPC: xs_tcp_state_change client %p...\n", xprt); |
| @@ -1313,7 +1313,7 @@ static void xs_tcp_state_change(struct sock *sk) | |||
| 1313 | 1313 | ||
| 1314 | switch (sk->sk_state) { | 1314 | switch (sk->sk_state) { |
| 1315 | case TCP_ESTABLISHED: | 1315 | case TCP_ESTABLISHED: |
| 1316 | spin_lock_bh(&xprt->transport_lock); | 1316 | spin_lock(&xprt->transport_lock); |
| 1317 | if (!xprt_test_and_set_connected(xprt)) { | 1317 | if (!xprt_test_and_set_connected(xprt)) { |
| 1318 | struct sock_xprt *transport = container_of(xprt, | 1318 | struct sock_xprt *transport = container_of(xprt, |
| 1319 | struct sock_xprt, xprt); | 1319 | struct sock_xprt, xprt); |
| @@ -1327,7 +1327,7 @@ static void xs_tcp_state_change(struct sock *sk) | |||
| 1327 | 1327 | ||
| 1328 | xprt_wake_pending_tasks(xprt, -EAGAIN); | 1328 | xprt_wake_pending_tasks(xprt, -EAGAIN); |
| 1329 | } | 1329 | } |
| 1330 | spin_unlock_bh(&xprt->transport_lock); | 1330 | spin_unlock(&xprt->transport_lock); |
| 1331 | break; | 1331 | break; |
| 1332 | case TCP_FIN_WAIT1: | 1332 | case TCP_FIN_WAIT1: |
| 1333 | /* The client initiated a shutdown of the socket */ | 1333 | /* The client initiated a shutdown of the socket */ |
| @@ -1365,7 +1365,7 @@ static void xs_tcp_state_change(struct sock *sk) | |||
| 1365 | xs_sock_mark_closed(xprt); | 1365 | xs_sock_mark_closed(xprt); |
| 1366 | } | 1366 | } |
| 1367 | out: | 1367 | out: |
| 1368 | read_unlock(&sk->sk_callback_lock); | 1368 | read_unlock_bh(&sk->sk_callback_lock); |
| 1369 | } | 1369 | } |
| 1370 | 1370 | ||
| 1371 | /** | 1371 | /** |
| @@ -1376,7 +1376,7 @@ static void xs_error_report(struct sock *sk) | |||
| 1376 | { | 1376 | { |
| 1377 | struct rpc_xprt *xprt; | 1377 | struct rpc_xprt *xprt; |
| 1378 | 1378 | ||
| 1379 | read_lock(&sk->sk_callback_lock); | 1379 | read_lock_bh(&sk->sk_callback_lock); |
| 1380 | if (!(xprt = xprt_from_sock(sk))) | 1380 | if (!(xprt = xprt_from_sock(sk))) |
| 1381 | goto out; | 1381 | goto out; |
| 1382 | dprintk("RPC: %s client %p...\n" | 1382 | dprintk("RPC: %s client %p...\n" |
| @@ -1384,7 +1384,7 @@ static void xs_error_report(struct sock *sk) | |||
| 1384 | __func__, xprt, sk->sk_err); | 1384 | __func__, xprt, sk->sk_err); |
| 1385 | xprt_wake_pending_tasks(xprt, -EAGAIN); | 1385 | xprt_wake_pending_tasks(xprt, -EAGAIN); |
| 1386 | out: | 1386 | out: |
| 1387 | read_unlock(&sk->sk_callback_lock); | 1387 | read_unlock_bh(&sk->sk_callback_lock); |
| 1388 | } | 1388 | } |
| 1389 | 1389 | ||
| 1390 | static void xs_write_space(struct sock *sk) | 1390 | static void xs_write_space(struct sock *sk) |
| @@ -1416,13 +1416,13 @@ static void xs_write_space(struct sock *sk) | |||
| 1416 | */ | 1416 | */ |
| 1417 | static void xs_udp_write_space(struct sock *sk) | 1417 | static void xs_udp_write_space(struct sock *sk) |
| 1418 | { | 1418 | { |
| 1419 | read_lock(&sk->sk_callback_lock); | 1419 | read_lock_bh(&sk->sk_callback_lock); |
| 1420 | 1420 | ||
| 1421 | /* from net/core/sock.c:sock_def_write_space */ | 1421 | /* from net/core/sock.c:sock_def_write_space */ |
| 1422 | if (sock_writeable(sk)) | 1422 | if (sock_writeable(sk)) |
| 1423 | xs_write_space(sk); | 1423 | xs_write_space(sk); |
| 1424 | 1424 | ||
| 1425 | read_unlock(&sk->sk_callback_lock); | 1425 | read_unlock_bh(&sk->sk_callback_lock); |
| 1426 | } | 1426 | } |
| 1427 | 1427 | ||
| 1428 | /** | 1428 | /** |
| @@ -1437,13 +1437,13 @@ static void xs_udp_write_space(struct sock *sk) | |||
| 1437 | */ | 1437 | */ |
| 1438 | static void xs_tcp_write_space(struct sock *sk) | 1438 | static void xs_tcp_write_space(struct sock *sk) |
| 1439 | { | 1439 | { |
| 1440 | read_lock(&sk->sk_callback_lock); | 1440 | read_lock_bh(&sk->sk_callback_lock); |
| 1441 | 1441 | ||
| 1442 | /* from net/core/stream.c:sk_stream_write_space */ | 1442 | /* from net/core/stream.c:sk_stream_write_space */ |
| 1443 | if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) | 1443 | if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk)) |
| 1444 | xs_write_space(sk); | 1444 | xs_write_space(sk); |
| 1445 | 1445 | ||
| 1446 | read_unlock(&sk->sk_callback_lock); | 1446 | read_unlock_bh(&sk->sk_callback_lock); |
| 1447 | } | 1447 | } |
| 1448 | 1448 | ||
| 1449 | static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt) | 1449 | static void xs_udp_do_set_buffer_size(struct rpc_xprt *xprt) |
diff --git a/net/wireless/wext-priv.c b/net/wireless/wext-priv.c index 3feb28e41c53..674d426a9d24 100644 --- a/net/wireless/wext-priv.c +++ b/net/wireless/wext-priv.c | |||
| @@ -152,7 +152,7 @@ static int ioctl_private_iw_point(struct iw_point *iwp, unsigned int cmd, | |||
| 152 | } else if (!iwp->pointer) | 152 | } else if (!iwp->pointer) |
| 153 | return -EFAULT; | 153 | return -EFAULT; |
| 154 | 154 | ||
| 155 | extra = kmalloc(extra_size, GFP_KERNEL); | 155 | extra = kzalloc(extra_size, GFP_KERNEL); |
| 156 | if (!extra) | 156 | if (!extra) |
| 157 | return -ENOMEM; | 157 | return -ENOMEM; |
| 158 | 158 | ||
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index 2b3ed7ad4933..cbab6e1a8c9c 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
| @@ -1175,9 +1175,8 @@ xfrm_tmpl_resolve_one(struct xfrm_policy *policy, struct flowi *fl, | |||
| 1175 | tmpl->mode == XFRM_MODE_BEET) { | 1175 | tmpl->mode == XFRM_MODE_BEET) { |
| 1176 | remote = &tmpl->id.daddr; | 1176 | remote = &tmpl->id.daddr; |
| 1177 | local = &tmpl->saddr; | 1177 | local = &tmpl->saddr; |
| 1178 | family = tmpl->encap_family; | 1178 | if (xfrm_addr_any(local, tmpl->encap_family)) { |
| 1179 | if (xfrm_addr_any(local, family)) { | 1179 | error = xfrm_get_saddr(net, &tmp, remote, tmpl->encap_family); |
| 1180 | error = xfrm_get_saddr(net, &tmp, remote, family); | ||
| 1181 | if (error) | 1180 | if (error) |
| 1182 | goto fail; | 1181 | goto fail; |
| 1183 | local = &tmp; | 1182 | local = &tmp; |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index 5208b12fbfb4..eb96ce52f178 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
| @@ -656,15 +656,23 @@ void xfrm_sad_getinfo(struct net *net, struct xfrmk_sadinfo *si) | |||
| 656 | EXPORT_SYMBOL(xfrm_sad_getinfo); | 656 | EXPORT_SYMBOL(xfrm_sad_getinfo); |
| 657 | 657 | ||
| 658 | static int | 658 | static int |
| 659 | xfrm_init_tempsel(struct xfrm_state *x, struct flowi *fl, | 659 | xfrm_init_tempstate(struct xfrm_state *x, struct flowi *fl, |
| 660 | struct xfrm_tmpl *tmpl, | 660 | struct xfrm_tmpl *tmpl, |
| 661 | xfrm_address_t *daddr, xfrm_address_t *saddr, | 661 | xfrm_address_t *daddr, xfrm_address_t *saddr, |
| 662 | unsigned short family) | 662 | unsigned short family) |
| 663 | { | 663 | { |
| 664 | struct xfrm_state_afinfo *afinfo = xfrm_state_get_afinfo(family); | 664 | struct xfrm_state_afinfo *afinfo = xfrm_state_get_afinfo(family); |
| 665 | if (!afinfo) | 665 | if (!afinfo) |
| 666 | return -1; | 666 | return -1; |
| 667 | afinfo->init_tempsel(x, fl, tmpl, daddr, saddr); | 667 | afinfo->init_tempsel(&x->sel, fl); |
| 668 | |||
| 669 | if (family != tmpl->encap_family) { | ||
| 670 | xfrm_state_put_afinfo(afinfo); | ||
| 671 | afinfo = xfrm_state_get_afinfo(tmpl->encap_family); | ||
| 672 | if (!afinfo) | ||
| 673 | return -1; | ||
| 674 | } | ||
| 675 | afinfo->init_temprop(x, tmpl, daddr, saddr); | ||
| 668 | xfrm_state_put_afinfo(afinfo); | 676 | xfrm_state_put_afinfo(afinfo); |
| 669 | return 0; | 677 | return 0; |
| 670 | } | 678 | } |
| @@ -790,37 +798,38 @@ xfrm_state_find(xfrm_address_t *daddr, xfrm_address_t *saddr, | |||
| 790 | int error = 0; | 798 | int error = 0; |
| 791 | struct xfrm_state *best = NULL; | 799 | struct xfrm_state *best = NULL; |
| 792 | u32 mark = pol->mark.v & pol->mark.m; | 800 | u32 mark = pol->mark.v & pol->mark.m; |
| 801 | unsigned short encap_family = tmpl->encap_family; | ||
| 793 | 802 | ||
| 794 | to_put = NULL; | 803 | to_put = NULL; |
| 795 | 804 | ||
| 796 | spin_lock_bh(&xfrm_state_lock); | 805 | spin_lock_bh(&xfrm_state_lock); |
| 797 | h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, family); | 806 | h = xfrm_dst_hash(net, daddr, saddr, tmpl->reqid, encap_family); |
| 798 | hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h, bydst) { | 807 | hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h, bydst) { |
| 799 | if (x->props.family == family && | 808 | if (x->props.family == encap_family && |
| 800 | x->props.reqid == tmpl->reqid && | 809 | x->props.reqid == tmpl->reqid && |
| 801 | (mark & x->mark.m) == x->mark.v && | 810 | (mark & x->mark.m) == x->mark.v && |
| 802 | !(x->props.flags & XFRM_STATE_WILDRECV) && | 811 | !(x->props.flags & XFRM_STATE_WILDRECV) && |
| 803 | xfrm_state_addr_check(x, daddr, saddr, family) && | 812 | xfrm_state_addr_check(x, daddr, saddr, encap_family) && |
| 804 | tmpl->mode == x->props.mode && | 813 | tmpl->mode == x->props.mode && |
| 805 | tmpl->id.proto == x->id.proto && | 814 | tmpl->id.proto == x->id.proto && |
| 806 | (tmpl->id.spi == x->id.spi || !tmpl->id.spi)) | 815 | (tmpl->id.spi == x->id.spi || !tmpl->id.spi)) |
| 807 | xfrm_state_look_at(pol, x, fl, family, daddr, saddr, | 816 | xfrm_state_look_at(pol, x, fl, encap_family, daddr, saddr, |
| 808 | &best, &acquire_in_progress, &error); | 817 | &best, &acquire_in_progress, &error); |
| 809 | } | 818 | } |
| 810 | if (best) | 819 | if (best) |
| 811 | goto found; | 820 | goto found; |
| 812 | 821 | ||
| 813 | h_wildcard = xfrm_dst_hash(net, daddr, &saddr_wildcard, tmpl->reqid, family); | 822 | h_wildcard = xfrm_dst_hash(net, daddr, &saddr_wildcard, tmpl->reqid, encap_family); |
| 814 | hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h_wildcard, bydst) { | 823 | hlist_for_each_entry(x, entry, net->xfrm.state_bydst+h_wildcard, bydst) { |
| 815 | if (x->props.family == family && | 824 | if (x->props.family == encap_family && |
| 816 | x->props.reqid == tmpl->reqid && | 825 | x->props.reqid == tmpl->reqid && |
| 817 | (mark & x->mark.m) == x->mark.v && | 826 | (mark & x->mark.m) == x->mark.v && |
| 818 | !(x->props.flags & XFRM_STATE_WILDRECV) && | 827 | !(x->props.flags & XFRM_STATE_WILDRECV) && |
| 819 | xfrm_state_addr_check(x, daddr, saddr, family) && | 828 | xfrm_state_addr_check(x, daddr, saddr, encap_family) && |
| 820 | tmpl->mode == x->props.mode && | 829 | tmpl->mode == x->props.mode && |
| 821 | tmpl->id.proto == x->id.proto && | 830 | tmpl->id.proto == x->id.proto && |
| 822 | (tmpl->id.spi == x->id.spi || !tmpl->id.spi)) | 831 | (tmpl->id.spi == x->id.spi || !tmpl->id.spi)) |
| 823 | xfrm_state_look_at(pol, x, fl, family, daddr, saddr, | 832 | xfrm_state_look_at(pol, x, fl, encap_family, daddr, saddr, |
| 824 | &best, &acquire_in_progress, &error); | 833 | &best, &acquire_in_progress, &error); |
| 825 | } | 834 | } |
| 826 | 835 | ||
| @@ -829,7 +838,7 @@ found: | |||
| 829 | if (!x && !error && !acquire_in_progress) { | 838 | if (!x && !error && !acquire_in_progress) { |
| 830 | if (tmpl->id.spi && | 839 | if (tmpl->id.spi && |
| 831 | (x0 = __xfrm_state_lookup(net, mark, daddr, tmpl->id.spi, | 840 | (x0 = __xfrm_state_lookup(net, mark, daddr, tmpl->id.spi, |
| 832 | tmpl->id.proto, family)) != NULL) { | 841 | tmpl->id.proto, encap_family)) != NULL) { |
| 833 | to_put = x0; | 842 | to_put = x0; |
| 834 | error = -EEXIST; | 843 | error = -EEXIST; |
| 835 | goto out; | 844 | goto out; |
| @@ -839,9 +848,9 @@ found: | |||
| 839 | error = -ENOMEM; | 848 | error = -ENOMEM; |
| 840 | goto out; | 849 | goto out; |
| 841 | } | 850 | } |
| 842 | /* Initialize temporary selector matching only | 851 | /* Initialize temporary state matching only |
| 843 | * to current session. */ | 852 | * to current session. */ |
| 844 | xfrm_init_tempsel(x, fl, tmpl, daddr, saddr, family); | 853 | xfrm_init_tempstate(x, fl, tmpl, daddr, saddr, family); |
| 845 | memcpy(&x->mark, &pol->mark, sizeof(x->mark)); | 854 | memcpy(&x->mark, &pol->mark, sizeof(x->mark)); |
| 846 | 855 | ||
| 847 | error = security_xfrm_state_alloc_acquire(x, pol->security, fl->secid); | 856 | error = security_xfrm_state_alloc_acquire(x, pol->security, fl->secid); |
| @@ -856,10 +865,10 @@ found: | |||
| 856 | x->km.state = XFRM_STATE_ACQ; | 865 | x->km.state = XFRM_STATE_ACQ; |
| 857 | list_add(&x->km.all, &net->xfrm.state_all); | 866 | list_add(&x->km.all, &net->xfrm.state_all); |
| 858 | hlist_add_head(&x->bydst, net->xfrm.state_bydst+h); | 867 | hlist_add_head(&x->bydst, net->xfrm.state_bydst+h); |
| 859 | h = xfrm_src_hash(net, daddr, saddr, family); | 868 | h = xfrm_src_hash(net, daddr, saddr, encap_family); |
| 860 | hlist_add_head(&x->bysrc, net->xfrm.state_bysrc+h); | 869 | hlist_add_head(&x->bysrc, net->xfrm.state_bysrc+h); |
| 861 | if (x->id.spi) { | 870 | if (x->id.spi) { |
| 862 | h = xfrm_spi_hash(net, &x->id.daddr, x->id.spi, x->id.proto, family); | 871 | h = xfrm_spi_hash(net, &x->id.daddr, x->id.spi, x->id.proto, encap_family); |
| 863 | hlist_add_head(&x->byspi, net->xfrm.state_byspi+h); | 872 | hlist_add_head(&x->byspi, net->xfrm.state_byspi+h); |
| 864 | } | 873 | } |
| 865 | x->lft.hard_add_expires_seconds = net->xfrm.sysctl_acq_expires; | 874 | x->lft.hard_add_expires_seconds = net->xfrm.sysctl_acq_expires; |
