diff options
author | Jeff Garzik <jgarzik@pobox.com> | 2005-10-03 22:06:19 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@pobox.com> | 2005-10-03 22:06:19 -0400 |
commit | 3c8c7b2f32c52b259daa7564fefd582146799b23 (patch) | |
tree | 59ff1ad0d6b7821d474d8fccafd884703684b6d7 /net | |
parent | 7cb3cd090c2725b80561958a362c2ba15a7a8c86 (diff) | |
parent | 9123e0d78990246304fe681167b8d8097f1e02d7 (diff) |
Merge branch 'upstream-fixes'
Diffstat (limited to 'net')
85 files changed, 1246 insertions, 946 deletions
diff --git a/net/802/p8022.c b/net/802/p8022.c index b24817c63ca8..2530f35241cd 100644 --- a/net/802/p8022.c +++ b/net/802/p8022.c | |||
@@ -56,7 +56,7 @@ struct datalink_proto *register_8022_client(unsigned char type, | |||
56 | 56 | ||
57 | void unregister_8022_client(struct datalink_proto *proto) | 57 | void unregister_8022_client(struct datalink_proto *proto) |
58 | { | 58 | { |
59 | llc_sap_close(proto->sap); | 59 | llc_sap_put(proto->sap); |
60 | kfree(proto); | 60 | kfree(proto); |
61 | } | 61 | } |
62 | 62 | ||
diff --git a/net/802/psnap.c b/net/802/psnap.c index ab80b1fab53c..4d638944d933 100644 --- a/net/802/psnap.c +++ b/net/802/psnap.c | |||
@@ -106,7 +106,7 @@ module_init(snap_init); | |||
106 | 106 | ||
107 | static void __exit snap_exit(void) | 107 | static void __exit snap_exit(void) |
108 | { | 108 | { |
109 | llc_sap_close(snap_sap); | 109 | llc_sap_put(snap_sap); |
110 | } | 110 | } |
111 | 111 | ||
112 | module_exit(snap_exit); | 112 | module_exit(snap_exit); |
diff --git a/net/802/tr.c b/net/802/tr.c index 1bb7dc1b85cd..1eaa3d19d8bf 100644 --- a/net/802/tr.c +++ b/net/802/tr.c | |||
@@ -238,7 +238,7 @@ unsigned short tr_type_trans(struct sk_buff *skb, struct net_device *dev) | |||
238 | return trllc->ethertype; | 238 | return trllc->ethertype; |
239 | } | 239 | } |
240 | 240 | ||
241 | return ntohs(ETH_P_802_2); | 241 | return ntohs(ETH_P_TR_802_2); |
242 | } | 242 | } |
243 | 243 | ||
244 | /* | 244 | /* |
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 1d31b3a3f1e5..7982656b9c83 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
@@ -100,8 +100,7 @@ static struct sock *atalk_search_socket(struct sockaddr_at *to, | |||
100 | continue; | 100 | continue; |
101 | 101 | ||
102 | if (to->sat_addr.s_net == ATADDR_ANYNET && | 102 | if (to->sat_addr.s_net == ATADDR_ANYNET && |
103 | to->sat_addr.s_node == ATADDR_BCAST && | 103 | to->sat_addr.s_node == ATADDR_BCAST) |
104 | at->src_net == atif->address.s_net) | ||
105 | goto found; | 104 | goto found; |
106 | 105 | ||
107 | if (to->sat_addr.s_net == at->src_net && | 106 | if (to->sat_addr.s_net == at->src_net && |
@@ -1443,8 +1442,10 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, | |||
1443 | else | 1442 | else |
1444 | atif = atalk_find_interface(ddp->deh_dnet, ddp->deh_dnode); | 1443 | atif = atalk_find_interface(ddp->deh_dnet, ddp->deh_dnode); |
1445 | 1444 | ||
1446 | /* Not ours, so we route the packet via the correct AppleTalk iface */ | ||
1447 | if (!atif) { | 1445 | if (!atif) { |
1446 | /* Not ours, so we route the packet via the correct | ||
1447 | * AppleTalk iface | ||
1448 | */ | ||
1448 | atalk_route_packet(skb, dev, ddp, &ddphv, origlen); | 1449 | atalk_route_packet(skb, dev, ddp, &ddphv, origlen); |
1449 | goto out; | 1450 | goto out; |
1450 | } | 1451 | } |
@@ -1592,9 +1593,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr | |||
1592 | 1593 | ||
1593 | if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) { | 1594 | if (usat->sat_addr.s_net || usat->sat_addr.s_node == ATADDR_ANYNODE) { |
1594 | rt = atrtr_find(&usat->sat_addr); | 1595 | rt = atrtr_find(&usat->sat_addr); |
1595 | if (!rt) | ||
1596 | return -ENETUNREACH; | ||
1597 | |||
1598 | dev = rt->dev; | 1596 | dev = rt->dev; |
1599 | } else { | 1597 | } else { |
1600 | struct atalk_addr at_hint; | 1598 | struct atalk_addr at_hint; |
@@ -1603,11 +1601,12 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr | |||
1603 | at_hint.s_net = at->src_net; | 1601 | at_hint.s_net = at->src_net; |
1604 | 1602 | ||
1605 | rt = atrtr_find(&at_hint); | 1603 | rt = atrtr_find(&at_hint); |
1606 | if (!rt) | ||
1607 | return -ENETUNREACH; | ||
1608 | |||
1609 | dev = rt->dev; | 1604 | dev = rt->dev; |
1610 | } | 1605 | } |
1606 | if (!rt) | ||
1607 | return -ENETUNREACH; | ||
1608 | |||
1609 | dev = rt->dev; | ||
1611 | 1610 | ||
1612 | SOCK_DEBUG(sk, "SK %p: Size needed %d, device %s\n", | 1611 | SOCK_DEBUG(sk, "SK %p: Size needed %d, device %s\n", |
1613 | sk, size, dev->name); | 1612 | sk, size, dev->name); |
@@ -1677,6 +1676,20 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr | |||
1677 | SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk); | 1676 | SOCK_DEBUG(sk, "SK %p: Loop back.\n", sk); |
1678 | /* loop back */ | 1677 | /* loop back */ |
1679 | skb_orphan(skb); | 1678 | skb_orphan(skb); |
1679 | if (ddp->deh_dnode == ATADDR_BCAST) { | ||
1680 | struct atalk_addr at_lo; | ||
1681 | |||
1682 | at_lo.s_node = 0; | ||
1683 | at_lo.s_net = 0; | ||
1684 | |||
1685 | rt = atrtr_find(&at_lo); | ||
1686 | if (!rt) { | ||
1687 | kfree_skb(skb); | ||
1688 | return -ENETUNREACH; | ||
1689 | } | ||
1690 | dev = rt->dev; | ||
1691 | skb->dev = dev; | ||
1692 | } | ||
1680 | ddp_dl->request(ddp_dl, skb, dev->dev_addr); | 1693 | ddp_dl->request(ddp_dl, skb, dev->dev_addr); |
1681 | } else { | 1694 | } else { |
1682 | SOCK_DEBUG(sk, "SK %p: send out.\n", sk); | 1695 | SOCK_DEBUG(sk, "SK %p: send out.\n", sk); |
diff --git a/net/atm/addr.c b/net/atm/addr.c index 1c8867f7f54a..a30d0bf48063 100644 --- a/net/atm/addr.c +++ b/net/atm/addr.c | |||
@@ -50,8 +50,10 @@ void atm_reset_addr(struct atm_dev *dev) | |||
50 | struct atm_dev_addr *this, *p; | 50 | struct atm_dev_addr *this, *p; |
51 | 51 | ||
52 | spin_lock_irqsave(&dev->lock, flags); | 52 | spin_lock_irqsave(&dev->lock, flags); |
53 | list_for_each_entry_safe(this, p, &dev->local, entry) | 53 | list_for_each_entry_safe(this, p, &dev->local, entry) { |
54 | kfree(this); | 54 | list_del(&this->entry); |
55 | kfree(this); | ||
56 | } | ||
55 | spin_unlock_irqrestore(&dev->lock, flags); | 57 | spin_unlock_irqrestore(&dev->lock, flags); |
56 | notify_sigd(dev); | 58 | notify_sigd(dev); |
57 | } | 59 | } |
diff --git a/net/atm/clip.c b/net/atm/clip.c index 28dab55a4387..4f54c9a5e84a 100644 --- a/net/atm/clip.c +++ b/net/atm/clip.c | |||
@@ -310,7 +310,7 @@ static int clip_constructor(struct neighbour *neigh) | |||
310 | if (neigh->type != RTN_UNICAST) return -EINVAL; | 310 | if (neigh->type != RTN_UNICAST) return -EINVAL; |
311 | 311 | ||
312 | rcu_read_lock(); | 312 | rcu_read_lock(); |
313 | in_dev = rcu_dereference(__in_dev_get(dev)); | 313 | in_dev = __in_dev_get_rcu(dev); |
314 | if (!in_dev) { | 314 | if (!in_dev) { |
315 | rcu_read_unlock(); | 315 | rcu_read_unlock(); |
316 | return -EINVAL; | 316 | return -EINVAL; |
diff --git a/net/atm/common.c b/net/atm/common.c index e93e838069e8..63feea49fb13 100644 --- a/net/atm/common.c +++ b/net/atm/common.c | |||
@@ -46,7 +46,7 @@ static void __vcc_insert_socket(struct sock *sk) | |||
46 | struct atm_vcc *vcc = atm_sk(sk); | 46 | struct atm_vcc *vcc = atm_sk(sk); |
47 | struct hlist_head *head = &vcc_hash[vcc->vci & | 47 | struct hlist_head *head = &vcc_hash[vcc->vci & |
48 | (VCC_HTABLE_SIZE - 1)]; | 48 | (VCC_HTABLE_SIZE - 1)]; |
49 | sk->sk_hashent = vcc->vci & (VCC_HTABLE_SIZE - 1); | 49 | sk->sk_hash = vcc->vci & (VCC_HTABLE_SIZE - 1); |
50 | sk_add_node(sk, head); | 50 | sk_add_node(sk, head); |
51 | } | 51 | } |
52 | 52 | ||
@@ -178,8 +178,6 @@ static void vcc_destroy_socket(struct sock *sk) | |||
178 | if (vcc->push) | 178 | if (vcc->push) |
179 | vcc->push(vcc, NULL); /* atmarpd has no push */ | 179 | vcc->push(vcc, NULL); /* atmarpd has no push */ |
180 | 180 | ||
181 | vcc_remove_socket(sk); /* no more receive */ | ||
182 | |||
183 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { | 181 | while ((skb = skb_dequeue(&sk->sk_receive_queue)) != NULL) { |
184 | atm_return(vcc,skb->truesize); | 182 | atm_return(vcc,skb->truesize); |
185 | kfree_skb(skb); | 183 | kfree_skb(skb); |
@@ -188,6 +186,8 @@ static void vcc_destroy_socket(struct sock *sk) | |||
188 | module_put(vcc->dev->ops->owner); | 186 | module_put(vcc->dev->ops->owner); |
189 | atm_dev_put(vcc->dev); | 187 | atm_dev_put(vcc->dev); |
190 | } | 188 | } |
189 | |||
190 | vcc_remove_socket(sk); | ||
191 | } | 191 | } |
192 | 192 | ||
193 | 193 | ||
diff --git a/net/atm/ioctl.c b/net/atm/ioctl.c index d89056ec44d4..a150198b05a3 100644 --- a/net/atm/ioctl.c +++ b/net/atm/ioctl.c | |||
@@ -105,17 +105,35 @@ int vcc_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
105 | if (!error) | 105 | if (!error) |
106 | sock->state = SS_CONNECTED; | 106 | sock->state = SS_CONNECTED; |
107 | goto done; | 107 | goto done; |
108 | default: | 108 | case ATM_SETBACKEND: |
109 | case ATM_NEWBACKENDIF: | ||
110 | { | ||
111 | atm_backend_t backend; | ||
112 | error = get_user(backend, (atm_backend_t __user *) argp); | ||
113 | if (error) | ||
114 | goto done; | ||
115 | switch (backend) { | ||
116 | case ATM_BACKEND_PPP: | ||
117 | request_module("pppoatm"); | ||
118 | break; | ||
119 | case ATM_BACKEND_BR2684: | ||
120 | request_module("br2684"); | ||
121 | break; | ||
122 | } | ||
123 | } | ||
124 | break; | ||
125 | case ATMMPC_CTRL: | ||
126 | case ATMMPC_DATA: | ||
127 | request_module("mpoa"); | ||
128 | break; | ||
129 | case ATMARPD_CTRL: | ||
130 | request_module("clip"); | ||
131 | break; | ||
132 | case ATMLEC_CTRL: | ||
133 | request_module("lec"); | ||
109 | break; | 134 | break; |
110 | } | 135 | } |
111 | 136 | ||
112 | if (cmd == ATMMPC_CTRL || cmd == ATMMPC_DATA) | ||
113 | request_module("mpoa"); | ||
114 | if (cmd == ATMARPD_CTRL) | ||
115 | request_module("clip"); | ||
116 | if (cmd == ATMLEC_CTRL) | ||
117 | request_module("lec"); | ||
118 | |||
119 | error = -ENOIOCTLCMD; | 137 | error = -ENOIOCTLCMD; |
120 | 138 | ||
121 | down(&ioctl_mutex); | 139 | down(&ioctl_mutex); |
diff --git a/net/atm/lec.c b/net/atm/lec.c index a0752487026d..ad840b9afba8 100644 --- a/net/atm/lec.c +++ b/net/atm/lec.c | |||
@@ -686,9 +686,19 @@ static unsigned char lec_ctrl_magic[] = { | |||
686 | 0x01, | 686 | 0x01, |
687 | 0x01 }; | 687 | 0x01 }; |
688 | 688 | ||
689 | #define LEC_DATA_DIRECT_8023 2 | ||
690 | #define LEC_DATA_DIRECT_8025 3 | ||
691 | |||
692 | static int lec_is_data_direct(struct atm_vcc *vcc) | ||
693 | { | ||
694 | return ((vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8023) || | ||
695 | (vcc->sap.blli[0].l3.tr9577.snap[4] == LEC_DATA_DIRECT_8025)); | ||
696 | } | ||
697 | |||
689 | static void | 698 | static void |
690 | lec_push(struct atm_vcc *vcc, struct sk_buff *skb) | 699 | lec_push(struct atm_vcc *vcc, struct sk_buff *skb) |
691 | { | 700 | { |
701 | unsigned long flags; | ||
692 | struct net_device *dev = (struct net_device *)vcc->proto_data; | 702 | struct net_device *dev = (struct net_device *)vcc->proto_data; |
693 | struct lec_priv *priv = (struct lec_priv *)dev->priv; | 703 | struct lec_priv *priv = (struct lec_priv *)dev->priv; |
694 | 704 | ||
@@ -728,7 +738,8 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
728 | skb_queue_tail(&sk->sk_receive_queue, skb); | 738 | skb_queue_tail(&sk->sk_receive_queue, skb); |
729 | sk->sk_data_ready(sk, skb->len); | 739 | sk->sk_data_ready(sk, skb->len); |
730 | } else { /* Data frame, queue to protocol handlers */ | 740 | } else { /* Data frame, queue to protocol handlers */ |
731 | unsigned char *dst; | 741 | struct lec_arp_table *entry; |
742 | unsigned char *src, *dst; | ||
732 | 743 | ||
733 | atm_return(vcc,skb->truesize); | 744 | atm_return(vcc,skb->truesize); |
734 | if (*(uint16_t *)skb->data == htons(priv->lecid) || | 745 | if (*(uint16_t *)skb->data == htons(priv->lecid) || |
@@ -741,10 +752,30 @@ lec_push(struct atm_vcc *vcc, struct sk_buff *skb) | |||
741 | return; | 752 | return; |
742 | } | 753 | } |
743 | #ifdef CONFIG_TR | 754 | #ifdef CONFIG_TR |
744 | if (priv->is_trdev) dst = ((struct lecdatahdr_8025 *)skb->data)->h_dest; | 755 | if (priv->is_trdev) |
756 | dst = ((struct lecdatahdr_8025 *) skb->data)->h_dest; | ||
745 | else | 757 | else |
746 | #endif | 758 | #endif |
747 | dst = ((struct lecdatahdr_8023 *)skb->data)->h_dest; | 759 | dst = ((struct lecdatahdr_8023 *) skb->data)->h_dest; |
760 | |||
761 | /* If this is a Data Direct VCC, and the VCC does not match | ||
762 | * the LE_ARP cache entry, delete the LE_ARP cache entry. | ||
763 | */ | ||
764 | spin_lock_irqsave(&priv->lec_arp_lock, flags); | ||
765 | if (lec_is_data_direct(vcc)) { | ||
766 | #ifdef CONFIG_TR | ||
767 | if (priv->is_trdev) | ||
768 | src = ((struct lecdatahdr_8025 *) skb->data)->h_source; | ||
769 | else | ||
770 | #endif | ||
771 | src = ((struct lecdatahdr_8023 *) skb->data)->h_source; | ||
772 | entry = lec_arp_find(priv, src); | ||
773 | if (entry && entry->vcc != vcc) { | ||
774 | lec_arp_remove(priv, entry); | ||
775 | kfree(entry); | ||
776 | } | ||
777 | } | ||
778 | spin_unlock_irqrestore(&priv->lec_arp_lock, flags); | ||
748 | 779 | ||
749 | if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */ | 780 | if (!(dst[0]&0x01) && /* Never filter Multi/Broadcast */ |
750 | !priv->is_proxy && /* Proxy wants all the packets */ | 781 | !priv->is_proxy && /* Proxy wants all the packets */ |
@@ -1990,6 +2021,12 @@ lec_arp_resolve(struct lec_priv *priv, unsigned char *mac_to_find, | |||
1990 | found = entry->vcc; | 2021 | found = entry->vcc; |
1991 | goto out; | 2022 | goto out; |
1992 | } | 2023 | } |
2024 | /* If the LE_ARP cache entry is still pending, reset count to 0 | ||
2025 | * so another LE_ARP request can be made for this frame. | ||
2026 | */ | ||
2027 | if (entry->status == ESI_ARP_PENDING) { | ||
2028 | entry->no_tries = 0; | ||
2029 | } | ||
1993 | /* Data direct VC not yet set up, check to see if the unknown | 2030 | /* Data direct VC not yet set up, check to see if the unknown |
1994 | frame count is greater than the limit. If the limit has | 2031 | frame count is greater than the limit. If the limit has |
1995 | not been reached, allow the caller to send packet to | 2032 | not been reached, allow the caller to send packet to |
diff --git a/net/atm/signaling.c b/net/atm/signaling.c index f7c449ac1800..e7211a7f382c 100644 --- a/net/atm/signaling.c +++ b/net/atm/signaling.c | |||
@@ -217,8 +217,9 @@ void sigd_enq(struct atm_vcc *vcc,enum atmsvc_msg_type type, | |||
217 | static void purge_vcc(struct atm_vcc *vcc) | 217 | static void purge_vcc(struct atm_vcc *vcc) |
218 | { | 218 | { |
219 | if (sk_atm(vcc)->sk_family == PF_ATMSVC && | 219 | if (sk_atm(vcc)->sk_family == PF_ATMSVC && |
220 | !test_bit(ATM_VF_META,&vcc->flags)) { | 220 | !test_bit(ATM_VF_META, &vcc->flags)) { |
221 | set_bit(ATM_VF_RELEASED,&vcc->flags); | 221 | set_bit(ATM_VF_RELEASED, &vcc->flags); |
222 | clear_bit(ATM_VF_REGIS, &vcc->flags); | ||
222 | vcc_release_async(vcc, -EUNATCH); | 223 | vcc_release_async(vcc, -EUNATCH); |
223 | } | 224 | } |
224 | } | 225 | } |
@@ -243,8 +244,7 @@ static void sigd_close(struct atm_vcc *vcc) | |||
243 | sk_for_each(s, node, head) { | 244 | sk_for_each(s, node, head) { |
244 | struct atm_vcc *vcc = atm_sk(s); | 245 | struct atm_vcc *vcc = atm_sk(s); |
245 | 246 | ||
246 | if (vcc->dev) | 247 | purge_vcc(vcc); |
247 | purge_vcc(vcc); | ||
248 | } | 248 | } |
249 | } | 249 | } |
250 | read_unlock(&vcc_sklist_lock); | 250 | read_unlock(&vcc_sklist_lock); |
diff --git a/net/atm/svc.c b/net/atm/svc.c index 08e46052a3e4..d7b266136bf6 100644 --- a/net/atm/svc.c +++ b/net/atm/svc.c | |||
@@ -302,6 +302,7 @@ static int svc_listen(struct socket *sock,int backlog) | |||
302 | error = -EINVAL; | 302 | error = -EINVAL; |
303 | goto out; | 303 | goto out; |
304 | } | 304 | } |
305 | vcc_insert_socket(sk); | ||
305 | set_bit(ATM_VF_WAITING, &vcc->flags); | 306 | set_bit(ATM_VF_WAITING, &vcc->flags); |
306 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); | 307 | prepare_to_wait(sk->sk_sleep, &wait, TASK_UNINTERRUPTIBLE); |
307 | sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local); | 308 | sigd_enq(vcc,as_listen,NULL,NULL,&vcc->local); |
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c index 069253f830c1..2d24fb400e0c 100644 --- a/net/bridge/br_forward.c +++ b/net/bridge/br_forward.c | |||
@@ -31,7 +31,8 @@ static inline int should_deliver(const struct net_bridge_port *p, | |||
31 | 31 | ||
32 | int br_dev_queue_push_xmit(struct sk_buff *skb) | 32 | int br_dev_queue_push_xmit(struct sk_buff *skb) |
33 | { | 33 | { |
34 | if (skb->len > skb->dev->mtu) | 34 | /* drop mtu oversized packets except tso */ |
35 | if (skb->len > skb->dev->mtu && !skb_shinfo(skb)->tso_size) | ||
35 | kfree_skb(skb); | 36 | kfree_skb(skb); |
36 | else { | 37 | else { |
37 | #ifdef CONFIG_BRIDGE_NETFILTER | 38 | #ifdef CONFIG_BRIDGE_NETFILTER |
diff --git a/net/core/datagram.c b/net/core/datagram.c index da9bf71421a7..81987df536eb 100644 --- a/net/core/datagram.c +++ b/net/core/datagram.c | |||
@@ -211,74 +211,45 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb) | |||
211 | int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset, | 211 | int skb_copy_datagram_iovec(const struct sk_buff *skb, int offset, |
212 | struct iovec *to, int len) | 212 | struct iovec *to, int len) |
213 | { | 213 | { |
214 | int start = skb_headlen(skb); | 214 | int i, err, fraglen, end = 0; |
215 | int i, copy = start - offset; | 215 | struct sk_buff *next = skb_shinfo(skb)->frag_list; |
216 | 216 | next_skb: | |
217 | /* Copy header. */ | 217 | fraglen = skb_headlen(skb); |
218 | if (copy > 0) { | 218 | i = -1; |
219 | if (copy > len) | ||
220 | copy = len; | ||
221 | if (memcpy_toiovec(to, skb->data + offset, copy)) | ||
222 | goto fault; | ||
223 | if ((len -= copy) == 0) | ||
224 | return 0; | ||
225 | offset += copy; | ||
226 | } | ||
227 | 219 | ||
228 | /* Copy paged appendix. Hmm... why does this look so complicated? */ | 220 | while (1) { |
229 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 221 | int start = end; |
230 | int end; | ||
231 | |||
232 | BUG_TRAP(start <= offset + len); | ||
233 | 222 | ||
234 | end = start + skb_shinfo(skb)->frags[i].size; | 223 | if ((end += fraglen) > offset) { |
235 | if ((copy = end - offset) > 0) { | 224 | int copy = end - offset, o = offset - start; |
236 | int err; | ||
237 | u8 *vaddr; | ||
238 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; | ||
239 | struct page *page = frag->page; | ||
240 | 225 | ||
241 | if (copy > len) | 226 | if (copy > len) |
242 | copy = len; | 227 | copy = len; |
243 | vaddr = kmap(page); | 228 | if (i == -1) |
244 | err = memcpy_toiovec(to, vaddr + frag->page_offset + | 229 | err = memcpy_toiovec(to, skb->data + o, copy); |
245 | offset - start, copy); | 230 | else { |
246 | kunmap(page); | 231 | skb_frag_t *frag = &skb_shinfo(skb)->frags[i]; |
232 | struct page *page = frag->page; | ||
233 | void *p = kmap(page) + frag->page_offset + o; | ||
234 | err = memcpy_toiovec(to, p, copy); | ||
235 | kunmap(page); | ||
236 | } | ||
247 | if (err) | 237 | if (err) |
248 | goto fault; | 238 | goto fault; |
249 | if (!(len -= copy)) | 239 | if (!(len -= copy)) |
250 | return 0; | 240 | return 0; |
251 | offset += copy; | 241 | offset += copy; |
252 | } | 242 | } |
253 | start = end; | 243 | if (++i >= skb_shinfo(skb)->nr_frags) |
244 | break; | ||
245 | fraglen = skb_shinfo(skb)->frags[i].size; | ||
254 | } | 246 | } |
255 | 247 | if (next) { | |
256 | if (skb_shinfo(skb)->frag_list) { | 248 | skb = next; |
257 | struct sk_buff *list = skb_shinfo(skb)->frag_list; | 249 | BUG_ON(skb_shinfo(skb)->frag_list); |
258 | 250 | next = skb->next; | |
259 | for (; list; list = list->next) { | 251 | goto next_skb; |
260 | int end; | ||
261 | |||
262 | BUG_TRAP(start <= offset + len); | ||
263 | |||
264 | end = start + list->len; | ||
265 | if ((copy = end - offset) > 0) { | ||
266 | if (copy > len) | ||
267 | copy = len; | ||
268 | if (skb_copy_datagram_iovec(list, | ||
269 | offset - start, | ||
270 | to, copy)) | ||
271 | goto fault; | ||
272 | if ((len -= copy) == 0) | ||
273 | return 0; | ||
274 | offset += copy; | ||
275 | } | ||
276 | start = end; | ||
277 | } | ||
278 | } | 252 | } |
279 | if (!len) | ||
280 | return 0; | ||
281 | |||
282 | fault: | 253 | fault: |
283 | return -EFAULT; | 254 | return -EFAULT; |
284 | } | 255 | } |
diff --git a/net/core/dev.c b/net/core/dev.c index c01511e3d0c1..9066c874e273 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -574,6 +574,8 @@ struct net_device *dev_getbyhwaddr(unsigned short type, char *ha) | |||
574 | return dev; | 574 | return dev; |
575 | } | 575 | } |
576 | 576 | ||
577 | EXPORT_SYMBOL(dev_getbyhwaddr); | ||
578 | |||
577 | struct net_device *dev_getfirstbyhwtype(unsigned short type) | 579 | struct net_device *dev_getfirstbyhwtype(unsigned short type) |
578 | { | 580 | { |
579 | struct net_device *dev; | 581 | struct net_device *dev; |
@@ -1257,6 +1259,8 @@ int dev_queue_xmit(struct sk_buff *skb) | |||
1257 | if (skb_checksum_help(skb, 0)) | 1259 | if (skb_checksum_help(skb, 0)) |
1258 | goto out_kfree_skb; | 1260 | goto out_kfree_skb; |
1259 | 1261 | ||
1262 | spin_lock_prefetch(&dev->queue_lock); | ||
1263 | |||
1260 | /* Disable soft irqs for various locks below. Also | 1264 | /* Disable soft irqs for various locks below. Also |
1261 | * stops preemption for RCU. | 1265 | * stops preemption for RCU. |
1262 | */ | 1266 | */ |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 39fc55edf691..4128fc76ac3a 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
@@ -61,7 +61,9 @@ static int pneigh_ifdown(struct neigh_table *tbl, struct net_device *dev); | |||
61 | void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev); | 61 | void neigh_changeaddr(struct neigh_table *tbl, struct net_device *dev); |
62 | 62 | ||
63 | static struct neigh_table *neigh_tables; | 63 | static struct neigh_table *neigh_tables; |
64 | #ifdef CONFIG_PROC_FS | ||
64 | static struct file_operations neigh_stat_seq_fops; | 65 | static struct file_operations neigh_stat_seq_fops; |
66 | #endif | ||
65 | 67 | ||
66 | /* | 68 | /* |
67 | Neighbour hash table buckets are protected with rwlock tbl->lock. | 69 | Neighbour hash table buckets are protected with rwlock tbl->lock. |
@@ -725,6 +727,13 @@ static __inline__ int neigh_max_probes(struct neighbour *n) | |||
725 | p->ucast_probes + p->app_probes + p->mcast_probes); | 727 | p->ucast_probes + p->app_probes + p->mcast_probes); |
726 | } | 728 | } |
727 | 729 | ||
730 | static inline void neigh_add_timer(struct neighbour *n, unsigned long when) | ||
731 | { | ||
732 | if (unlikely(mod_timer(&n->timer, when))) { | ||
733 | printk("NEIGH: BUG, double timer add, state is %x\n", | ||
734 | n->nud_state); | ||
735 | } | ||
736 | } | ||
728 | 737 | ||
729 | /* Called when a timer expires for a neighbour entry. */ | 738 | /* Called when a timer expires for a neighbour entry. */ |
730 | 739 | ||
@@ -809,8 +818,7 @@ static void neigh_timer_handler(unsigned long arg) | |||
809 | neigh_hold(neigh); | 818 | neigh_hold(neigh); |
810 | if (time_before(next, jiffies + HZ/2)) | 819 | if (time_before(next, jiffies + HZ/2)) |
811 | next = jiffies + HZ/2; | 820 | next = jiffies + HZ/2; |
812 | neigh->timer.expires = next; | 821 | neigh_add_timer(neigh, next); |
813 | add_timer(&neigh->timer); | ||
814 | } | 822 | } |
815 | if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) { | 823 | if (neigh->nud_state & (NUD_INCOMPLETE | NUD_PROBE)) { |
816 | struct sk_buff *skb = skb_peek(&neigh->arp_queue); | 824 | struct sk_buff *skb = skb_peek(&neigh->arp_queue); |
@@ -852,8 +860,7 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) | |||
852 | atomic_set(&neigh->probes, neigh->parms->ucast_probes); | 860 | atomic_set(&neigh->probes, neigh->parms->ucast_probes); |
853 | neigh->nud_state = NUD_INCOMPLETE; | 861 | neigh->nud_state = NUD_INCOMPLETE; |
854 | neigh_hold(neigh); | 862 | neigh_hold(neigh); |
855 | neigh->timer.expires = now + 1; | 863 | neigh_add_timer(neigh, now + 1); |
856 | add_timer(&neigh->timer); | ||
857 | } else { | 864 | } else { |
858 | neigh->nud_state = NUD_FAILED; | 865 | neigh->nud_state = NUD_FAILED; |
859 | write_unlock_bh(&neigh->lock); | 866 | write_unlock_bh(&neigh->lock); |
@@ -866,8 +873,8 @@ int __neigh_event_send(struct neighbour *neigh, struct sk_buff *skb) | |||
866 | NEIGH_PRINTK2("neigh %p is delayed.\n", neigh); | 873 | NEIGH_PRINTK2("neigh %p is delayed.\n", neigh); |
867 | neigh_hold(neigh); | 874 | neigh_hold(neigh); |
868 | neigh->nud_state = NUD_DELAY; | 875 | neigh->nud_state = NUD_DELAY; |
869 | neigh->timer.expires = jiffies + neigh->parms->delay_probe_time; | 876 | neigh_add_timer(neigh, |
870 | add_timer(&neigh->timer); | 877 | jiffies + neigh->parms->delay_probe_time); |
871 | } | 878 | } |
872 | 879 | ||
873 | if (neigh->nud_state == NUD_INCOMPLETE) { | 880 | if (neigh->nud_state == NUD_INCOMPLETE) { |
@@ -1013,10 +1020,10 @@ int neigh_update(struct neighbour *neigh, const u8 *lladdr, u8 new, | |||
1013 | neigh_del_timer(neigh); | 1020 | neigh_del_timer(neigh); |
1014 | if (new & NUD_IN_TIMER) { | 1021 | if (new & NUD_IN_TIMER) { |
1015 | neigh_hold(neigh); | 1022 | neigh_hold(neigh); |
1016 | neigh->timer.expires = jiffies + | 1023 | neigh_add_timer(neigh, (jiffies + |
1017 | ((new & NUD_REACHABLE) ? | 1024 | ((new & NUD_REACHABLE) ? |
1018 | neigh->parms->reachable_time : 0); | 1025 | neigh->parms->reachable_time : |
1019 | add_timer(&neigh->timer); | 1026 | 0))); |
1020 | } | 1027 | } |
1021 | neigh->nud_state = new; | 1028 | neigh->nud_state = new; |
1022 | } | 1029 | } |
diff --git a/net/core/netpoll.c b/net/core/netpoll.c index 5265dfd69928..802fe11efad0 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c | |||
@@ -703,7 +703,7 @@ int netpoll_setup(struct netpoll *np) | |||
703 | 703 | ||
704 | if (!np->local_ip) { | 704 | if (!np->local_ip) { |
705 | rcu_read_lock(); | 705 | rcu_read_lock(); |
706 | in_dev = __in_dev_get(ndev); | 706 | in_dev = __in_dev_get_rcu(ndev); |
707 | 707 | ||
708 | if (!in_dev || !in_dev->ifa_list) { | 708 | if (!in_dev || !in_dev->ifa_list) { |
709 | rcu_read_unlock(); | 709 | rcu_read_unlock(); |
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index ef430b1e8e42..5f043d346694 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -186,7 +186,7 @@ | |||
186 | 186 | ||
187 | /* Used to help with determining the pkts on receive */ | 187 | /* Used to help with determining the pkts on receive */ |
188 | #define PKTGEN_MAGIC 0xbe9be955 | 188 | #define PKTGEN_MAGIC 0xbe9be955 |
189 | #define PG_PROC_DIR "pktgen" | 189 | #define PG_PROC_DIR "net/pktgen" |
190 | 190 | ||
191 | #define MAX_CFLOWS 65536 | 191 | #define MAX_CFLOWS 65536 |
192 | 192 | ||
@@ -1476,18 +1476,7 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer, | |||
1476 | 1476 | ||
1477 | static int create_proc_dir(void) | 1477 | static int create_proc_dir(void) |
1478 | { | 1478 | { |
1479 | int len; | 1479 | pg_proc_dir = proc_mkdir(PG_PROC_DIR, NULL); |
1480 | /* does proc_dir already exists */ | ||
1481 | len = strlen(PG_PROC_DIR); | ||
1482 | |||
1483 | for (pg_proc_dir = proc_net->subdir; pg_proc_dir; pg_proc_dir=pg_proc_dir->next) { | ||
1484 | if ((pg_proc_dir->namelen == len) && | ||
1485 | (! memcmp(pg_proc_dir->name, PG_PROC_DIR, len))) | ||
1486 | break; | ||
1487 | } | ||
1488 | |||
1489 | if (!pg_proc_dir) | ||
1490 | pg_proc_dir = create_proc_entry(PG_PROC_DIR, S_IFDIR, proc_net); | ||
1491 | 1480 | ||
1492 | if (!pg_proc_dir) | 1481 | if (!pg_proc_dir) |
1493 | return -ENODEV; | 1482 | return -ENODEV; |
@@ -1497,7 +1486,7 @@ static int create_proc_dir(void) | |||
1497 | 1486 | ||
1498 | static int remove_proc_dir(void) | 1487 | static int remove_proc_dir(void) |
1499 | { | 1488 | { |
1500 | remove_proc_entry(PG_PROC_DIR, proc_net); | 1489 | remove_proc_entry(PG_PROC_DIR, NULL); |
1501 | return 0; | 1490 | return 0; |
1502 | } | 1491 | } |
1503 | 1492 | ||
@@ -1678,13 +1667,12 @@ static void pktgen_setup_inject(struct pktgen_dev *pkt_dev) | |||
1678 | struct in_device *in_dev; | 1667 | struct in_device *in_dev; |
1679 | 1668 | ||
1680 | rcu_read_lock(); | 1669 | rcu_read_lock(); |
1681 | in_dev = __in_dev_get(pkt_dev->odev); | 1670 | in_dev = __in_dev_get_rcu(pkt_dev->odev); |
1682 | if (in_dev) { | 1671 | if (in_dev) { |
1683 | if (in_dev->ifa_list) { | 1672 | if (in_dev->ifa_list) { |
1684 | pkt_dev->saddr_min = in_dev->ifa_list->ifa_address; | 1673 | pkt_dev->saddr_min = in_dev->ifa_list->ifa_address; |
1685 | pkt_dev->saddr_max = pkt_dev->saddr_min; | 1674 | pkt_dev->saddr_max = pkt_dev->saddr_min; |
1686 | } | 1675 | } |
1687 | __in_dev_put(in_dev); | ||
1688 | } | 1676 | } |
1689 | rcu_read_unlock(); | 1677 | rcu_read_unlock(); |
1690 | } | 1678 | } |
@@ -2908,7 +2896,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char* ifname) | |||
2908 | pkt_dev->udp_dst_max = 9; | 2896 | pkt_dev->udp_dst_max = 9; |
2909 | 2897 | ||
2910 | strncpy(pkt_dev->ifname, ifname, 31); | 2898 | strncpy(pkt_dev->ifname, ifname, 31); |
2911 | sprintf(pkt_dev->fname, "net/%s/%s", PG_PROC_DIR, ifname); | 2899 | sprintf(pkt_dev->fname, "%s/%s", PG_PROC_DIR, ifname); |
2912 | 2900 | ||
2913 | if (! pktgen_setup_dev(pkt_dev)) { | 2901 | if (! pktgen_setup_dev(pkt_dev)) { |
2914 | printk("pktgen: ERROR: pktgen_setup_dev failed.\n"); | 2902 | printk("pktgen: ERROR: pktgen_setup_dev failed.\n"); |
@@ -2981,7 +2969,7 @@ static int pktgen_create_thread(const char* name, int cpu) | |||
2981 | spin_lock_init(&t->if_lock); | 2969 | spin_lock_init(&t->if_lock); |
2982 | t->cpu = cpu; | 2970 | t->cpu = cpu; |
2983 | 2971 | ||
2984 | sprintf(t->fname, "net/%s/%s", PG_PROC_DIR, t->name); | 2972 | sprintf(t->fname, "%s/%s", PG_PROC_DIR, t->name); |
2985 | t->proc_ent = create_proc_entry(t->fname, 0600, NULL); | 2973 | t->proc_ent = create_proc_entry(t->fname, 0600, NULL); |
2986 | if (!t->proc_ent) { | 2974 | if (!t->proc_ent) { |
2987 | printk("pktgen: cannot create %s procfs entry.\n", t->fname); | 2975 | printk("pktgen: cannot create %s procfs entry.\n", t->fname); |
@@ -3064,7 +3052,7 @@ static int __init pg_init(void) | |||
3064 | 3052 | ||
3065 | create_proc_dir(); | 3053 | create_proc_dir(); |
3066 | 3054 | ||
3067 | sprintf(module_fname, "net/%s/pgctrl", PG_PROC_DIR); | 3055 | sprintf(module_fname, "%s/pgctrl", PG_PROC_DIR); |
3068 | module_proc_ent = create_proc_entry(module_fname, 0600, NULL); | 3056 | module_proc_ent = create_proc_entry(module_fname, 0600, NULL); |
3069 | if (!module_proc_ent) { | 3057 | if (!module_proc_ent) { |
3070 | printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname); | 3058 | printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname); |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index f80a28785610..0e9431b59fb2 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -71,8 +71,6 @@ | |||
71 | static kmem_cache_t *skbuff_head_cache __read_mostly; | 71 | static kmem_cache_t *skbuff_head_cache __read_mostly; |
72 | static kmem_cache_t *skbuff_fclone_cache __read_mostly; | 72 | static kmem_cache_t *skbuff_fclone_cache __read_mostly; |
73 | 73 | ||
74 | struct timeval __read_mostly skb_tv_base; | ||
75 | |||
76 | /* | 74 | /* |
77 | * Keep out-of-line to prevent kernel bloat. | 75 | * Keep out-of-line to prevent kernel bloat. |
78 | * __builtin_return_address is not used because it is not always | 76 | * __builtin_return_address is not used because it is not always |
@@ -1708,8 +1706,6 @@ void __init skb_init(void) | |||
1708 | NULL, NULL); | 1706 | NULL, NULL); |
1709 | if (!skbuff_fclone_cache) | 1707 | if (!skbuff_fclone_cache) |
1710 | panic("cannot create skbuff cache"); | 1708 | panic("cannot create skbuff cache"); |
1711 | |||
1712 | do_gettimeofday(&skb_tv_base); | ||
1713 | } | 1709 | } |
1714 | 1710 | ||
1715 | EXPORT_SYMBOL(___pskb_trim); | 1711 | EXPORT_SYMBOL(___pskb_trim); |
@@ -1743,4 +1739,3 @@ EXPORT_SYMBOL(skb_prepare_seq_read); | |||
1743 | EXPORT_SYMBOL(skb_seq_read); | 1739 | EXPORT_SYMBOL(skb_seq_read); |
1744 | EXPORT_SYMBOL(skb_abort_seq_read); | 1740 | EXPORT_SYMBOL(skb_abort_seq_read); |
1745 | EXPORT_SYMBOL(skb_find_text); | 1741 | EXPORT_SYMBOL(skb_find_text); |
1746 | EXPORT_SYMBOL(skb_tv_base); | ||
diff --git a/net/core/sock.c b/net/core/sock.c index ac63b56e23b2..928d2a1d6d8e 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -660,16 +660,20 @@ struct sock *sk_alloc(int family, unsigned int __nocast priority, | |||
660 | sock_lock_init(sk); | 660 | sock_lock_init(sk); |
661 | } | 661 | } |
662 | 662 | ||
663 | if (security_sk_alloc(sk, family, priority)) { | 663 | if (security_sk_alloc(sk, family, priority)) |
664 | if (slab != NULL) | 664 | goto out_free; |
665 | kmem_cache_free(slab, sk); | 665 | |
666 | else | 666 | if (!try_module_get(prot->owner)) |
667 | kfree(sk); | 667 | goto out_free; |
668 | sk = NULL; | ||
669 | } else | ||
670 | __module_get(prot->owner); | ||
671 | } | 668 | } |
672 | return sk; | 669 | return sk; |
670 | |||
671 | out_free: | ||
672 | if (slab != NULL) | ||
673 | kmem_cache_free(slab, sk); | ||
674 | else | ||
675 | kfree(sk); | ||
676 | return NULL; | ||
673 | } | 677 | } |
674 | 678 | ||
675 | void sk_free(struct sock *sk) | 679 | void sk_free(struct sock *sk) |
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index 40fe6afacde6..ae088d1347af 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c | |||
@@ -62,27 +62,27 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport, | |||
62 | const int dif = sk->sk_bound_dev_if; | 62 | const int dif = sk->sk_bound_dev_if; |
63 | INET_ADDR_COOKIE(acookie, saddr, daddr) | 63 | INET_ADDR_COOKIE(acookie, saddr, daddr) |
64 | const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); | 64 | const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); |
65 | const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport, | 65 | unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); |
66 | dccp_hashinfo.ehash_size); | 66 | struct inet_ehash_bucket *head = inet_ehash_bucket(&dccp_hashinfo, hash); |
67 | struct inet_ehash_bucket *head = &dccp_hashinfo.ehash[hash]; | ||
68 | const struct sock *sk2; | 67 | const struct sock *sk2; |
69 | const struct hlist_node *node; | 68 | const struct hlist_node *node; |
70 | struct inet_timewait_sock *tw; | 69 | struct inet_timewait_sock *tw; |
71 | 70 | ||
71 | prefetch(head->chain.first); | ||
72 | write_lock(&head->lock); | 72 | write_lock(&head->lock); |
73 | 73 | ||
74 | /* Check TIME-WAIT sockets first. */ | 74 | /* Check TIME-WAIT sockets first. */ |
75 | sk_for_each(sk2, node, &(head + dccp_hashinfo.ehash_size)->chain) { | 75 | sk_for_each(sk2, node, &(head + dccp_hashinfo.ehash_size)->chain) { |
76 | tw = inet_twsk(sk2); | 76 | tw = inet_twsk(sk2); |
77 | 77 | ||
78 | if (INET_TW_MATCH(sk2, acookie, saddr, daddr, ports, dif)) | 78 | if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) |
79 | goto not_unique; | 79 | goto not_unique; |
80 | } | 80 | } |
81 | tw = NULL; | 81 | tw = NULL; |
82 | 82 | ||
83 | /* And established part... */ | 83 | /* And established part... */ |
84 | sk_for_each(sk2, node, &head->chain) { | 84 | sk_for_each(sk2, node, &head->chain) { |
85 | if (INET_MATCH(sk2, acookie, saddr, daddr, ports, dif)) | 85 | if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) |
86 | goto not_unique; | 86 | goto not_unique; |
87 | } | 87 | } |
88 | 88 | ||
@@ -90,7 +90,7 @@ static int __dccp_v4_check_established(struct sock *sk, const __u16 lport, | |||
90 | * in hash table socket with a funny identity. */ | 90 | * in hash table socket with a funny identity. */ |
91 | inet->num = lport; | 91 | inet->num = lport; |
92 | inet->sport = htons(lport); | 92 | inet->sport = htons(lport); |
93 | sk->sk_hashent = hash; | 93 | sk->sk_hash = hash; |
94 | BUG_TRAP(sk_unhashed(sk)); | 94 | BUG_TRAP(sk_unhashed(sk)); |
95 | __sk_add_node(sk, &head->chain); | 95 | __sk_add_node(sk, &head->chain); |
96 | sock_prot_inc_use(sk->sk_prot); | 96 | sock_prot_inc_use(sk->sk_prot); |
diff --git a/net/econet/af_econet.c b/net/econet/af_econet.c index 4a62093eb343..34fdac51df96 100644 --- a/net/econet/af_econet.c +++ b/net/econet/af_econet.c | |||
@@ -406,7 +406,7 @@ static int econet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
406 | unsigned long network = 0; | 406 | unsigned long network = 0; |
407 | 407 | ||
408 | rcu_read_lock(); | 408 | rcu_read_lock(); |
409 | idev = __in_dev_get(dev); | 409 | idev = __in_dev_get_rcu(dev); |
410 | if (idev) { | 410 | if (idev) { |
411 | if (idev->ifa_list) | 411 | if (idev->ifa_list) |
412 | network = ntohl(idev->ifa_list->ifa_address) & | 412 | network = ntohl(idev->ifa_list->ifa_address) & |
diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index 87a052a9a84f..68a5ca866442 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c | |||
@@ -146,6 +146,19 @@ int eth_rebuild_header(struct sk_buff *skb) | |||
146 | return 0; | 146 | return 0; |
147 | } | 147 | } |
148 | 148 | ||
149 | static inline unsigned int compare_eth_addr(const unsigned char *__a, const unsigned char *__b) | ||
150 | { | ||
151 | const unsigned short *dest = (unsigned short *) __a; | ||
152 | const unsigned short *devaddr = (unsigned short *) __b; | ||
153 | unsigned int res; | ||
154 | |||
155 | BUILD_BUG_ON(ETH_ALEN != 6); | ||
156 | res = ((dest[0] ^ devaddr[0]) | | ||
157 | (dest[1] ^ devaddr[1]) | | ||
158 | (dest[2] ^ devaddr[2])) != 0; | ||
159 | |||
160 | return res; | ||
161 | } | ||
149 | 162 | ||
150 | /* | 163 | /* |
151 | * Determine the packet's protocol ID. The rule here is that we | 164 | * Determine the packet's protocol ID. The rule here is that we |
@@ -158,16 +171,15 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) | |||
158 | struct ethhdr *eth; | 171 | struct ethhdr *eth; |
159 | unsigned char *rawp; | 172 | unsigned char *rawp; |
160 | 173 | ||
161 | skb->mac.raw=skb->data; | 174 | skb->mac.raw = skb->data; |
162 | skb_pull(skb,ETH_HLEN); | 175 | skb_pull(skb,ETH_HLEN); |
163 | eth = eth_hdr(skb); | 176 | eth = eth_hdr(skb); |
164 | 177 | ||
165 | if(*eth->h_dest&1) | 178 | if (*eth->h_dest&1) { |
166 | { | 179 | if (!compare_eth_addr(eth->h_dest, dev->broadcast)) |
167 | if(memcmp(eth->h_dest,dev->broadcast, ETH_ALEN)==0) | 180 | skb->pkt_type = PACKET_BROADCAST; |
168 | skb->pkt_type=PACKET_BROADCAST; | ||
169 | else | 181 | else |
170 | skb->pkt_type=PACKET_MULTICAST; | 182 | skb->pkt_type = PACKET_MULTICAST; |
171 | } | 183 | } |
172 | 184 | ||
173 | /* | 185 | /* |
@@ -178,10 +190,9 @@ __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev) | |||
178 | * seems to set IFF_PROMISC. | 190 | * seems to set IFF_PROMISC. |
179 | */ | 191 | */ |
180 | 192 | ||
181 | else if(1 /*dev->flags&IFF_PROMISC*/) | 193 | else if(1 /*dev->flags&IFF_PROMISC*/) { |
182 | { | 194 | if (unlikely(compare_eth_addr(eth->h_dest, dev->dev_addr))) |
183 | if(memcmp(eth->h_dest,dev->dev_addr, ETH_ALEN)) | 195 | skb->pkt_type = PACKET_OTHERHOST; |
184 | skb->pkt_type=PACKET_OTHERHOST; | ||
185 | } | 196 | } |
186 | 197 | ||
187 | if (ntohs(eth->h_proto) >= 1536) | 198 | if (ntohs(eth->h_proto) >= 1536) |
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c index 5714692e82b4..f66d792cd204 100644 --- a/net/ieee80211/ieee80211_module.c +++ b/net/ieee80211/ieee80211_module.c | |||
@@ -230,7 +230,7 @@ static int __init ieee80211_init(void) | |||
230 | struct proc_dir_entry *e; | 230 | struct proc_dir_entry *e; |
231 | 231 | ||
232 | ieee80211_debug_level = debug; | 232 | ieee80211_debug_level = debug; |
233 | ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net); | 233 | ieee80211_proc = proc_mkdir(DRV_NAME, proc_net); |
234 | if (ieee80211_proc == NULL) { | 234 | if (ieee80211_proc == NULL) { |
235 | IEEE80211_ERROR("Unable to create " DRV_NAME | 235 | IEEE80211_ERROR("Unable to create " DRV_NAME |
236 | " proc directory\n"); | 236 | " proc directory\n"); |
diff --git a/net/ieee80211/ieee80211_tx.c b/net/ieee80211/ieee80211_tx.c index 8d87897d7eb7..e860777ab8d3 100644 --- a/net/ieee80211/ieee80211_tx.c +++ b/net/ieee80211/ieee80211_tx.c | |||
@@ -187,7 +187,7 @@ void ieee80211_txb_free(struct ieee80211_txb *txb) | |||
187 | } | 187 | } |
188 | 188 | ||
189 | static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, | 189 | static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, |
190 | int gfp_mask) | 190 | unsigned int gfp_mask) |
191 | { | 191 | { |
192 | struct ieee80211_txb *txb; | 192 | struct ieee80211_txb *txb; |
193 | int i; | 193 | int i; |
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 8bf312bdea13..b425748f02d7 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c | |||
@@ -241,7 +241,7 @@ static int arp_constructor(struct neighbour *neigh) | |||
241 | neigh->type = inet_addr_type(addr); | 241 | neigh->type = inet_addr_type(addr); |
242 | 242 | ||
243 | rcu_read_lock(); | 243 | rcu_read_lock(); |
244 | in_dev = rcu_dereference(__in_dev_get(dev)); | 244 | in_dev = __in_dev_get_rcu(dev); |
245 | if (in_dev == NULL) { | 245 | if (in_dev == NULL) { |
246 | rcu_read_unlock(); | 246 | rcu_read_unlock(); |
247 | return -EINVAL; | 247 | return -EINVAL; |
@@ -697,12 +697,6 @@ void arp_send(int type, int ptype, u32 dest_ip, | |||
697 | arp_xmit(skb); | 697 | arp_xmit(skb); |
698 | } | 698 | } |
699 | 699 | ||
700 | static void parp_redo(struct sk_buff *skb) | ||
701 | { | ||
702 | nf_reset(skb); | ||
703 | arp_rcv(skb, skb->dev, NULL, skb->dev); | ||
704 | } | ||
705 | |||
706 | /* | 700 | /* |
707 | * Process an arp request. | 701 | * Process an arp request. |
708 | */ | 702 | */ |
@@ -922,6 +916,11 @@ out: | |||
922 | return 0; | 916 | return 0; |
923 | } | 917 | } |
924 | 918 | ||
919 | static void parp_redo(struct sk_buff *skb) | ||
920 | { | ||
921 | arp_process(skb); | ||
922 | } | ||
923 | |||
925 | 924 | ||
926 | /* | 925 | /* |
927 | * Receive an arp request from the device layer. | 926 | * Receive an arp request from the device layer. |
@@ -990,8 +989,8 @@ static int arp_req_set(struct arpreq *r, struct net_device * dev) | |||
990 | ipv4_devconf.proxy_arp = 1; | 989 | ipv4_devconf.proxy_arp = 1; |
991 | return 0; | 990 | return 0; |
992 | } | 991 | } |
993 | if (__in_dev_get(dev)) { | 992 | if (__in_dev_get_rtnl(dev)) { |
994 | __in_dev_get(dev)->cnf.proxy_arp = 1; | 993 | __in_dev_get_rtnl(dev)->cnf.proxy_arp = 1; |
995 | return 0; | 994 | return 0; |
996 | } | 995 | } |
997 | return -ENXIO; | 996 | return -ENXIO; |
@@ -1096,8 +1095,8 @@ static int arp_req_delete(struct arpreq *r, struct net_device * dev) | |||
1096 | ipv4_devconf.proxy_arp = 0; | 1095 | ipv4_devconf.proxy_arp = 0; |
1097 | return 0; | 1096 | return 0; |
1098 | } | 1097 | } |
1099 | if (__in_dev_get(dev)) { | 1098 | if (__in_dev_get_rtnl(dev)) { |
1100 | __in_dev_get(dev)->cnf.proxy_arp = 0; | 1099 | __in_dev_get_rtnl(dev)->cnf.proxy_arp = 0; |
1101 | return 0; | 1100 | return 0; |
1102 | } | 1101 | } |
1103 | return -ENXIO; | 1102 | return -ENXIO; |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index ba2895ae8151..74f2207e131a 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -351,7 +351,7 @@ static int inet_insert_ifa(struct in_ifaddr *ifa) | |||
351 | 351 | ||
352 | static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa) | 352 | static int inet_set_ifa(struct net_device *dev, struct in_ifaddr *ifa) |
353 | { | 353 | { |
354 | struct in_device *in_dev = __in_dev_get(dev); | 354 | struct in_device *in_dev = __in_dev_get_rtnl(dev); |
355 | 355 | ||
356 | ASSERT_RTNL(); | 356 | ASSERT_RTNL(); |
357 | 357 | ||
@@ -449,7 +449,7 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg | |||
449 | goto out; | 449 | goto out; |
450 | 450 | ||
451 | rc = -ENOBUFS; | 451 | rc = -ENOBUFS; |
452 | if ((in_dev = __in_dev_get(dev)) == NULL) { | 452 | if ((in_dev = __in_dev_get_rtnl(dev)) == NULL) { |
453 | in_dev = inetdev_init(dev); | 453 | in_dev = inetdev_init(dev); |
454 | if (!in_dev) | 454 | if (!in_dev) |
455 | goto out; | 455 | goto out; |
@@ -584,7 +584,7 @@ int devinet_ioctl(unsigned int cmd, void __user *arg) | |||
584 | if (colon) | 584 | if (colon) |
585 | *colon = ':'; | 585 | *colon = ':'; |
586 | 586 | ||
587 | if ((in_dev = __in_dev_get(dev)) != NULL) { | 587 | if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) { |
588 | if (tryaddrmatch) { | 588 | if (tryaddrmatch) { |
589 | /* Matthias Andree */ | 589 | /* Matthias Andree */ |
590 | /* compare label and address (4.4BSD style) */ | 590 | /* compare label and address (4.4BSD style) */ |
@@ -748,7 +748,7 @@ rarok: | |||
748 | 748 | ||
749 | static int inet_gifconf(struct net_device *dev, char __user *buf, int len) | 749 | static int inet_gifconf(struct net_device *dev, char __user *buf, int len) |
750 | { | 750 | { |
751 | struct in_device *in_dev = __in_dev_get(dev); | 751 | struct in_device *in_dev = __in_dev_get_rtnl(dev); |
752 | struct in_ifaddr *ifa; | 752 | struct in_ifaddr *ifa; |
753 | struct ifreq ifr; | 753 | struct ifreq ifr; |
754 | int done = 0; | 754 | int done = 0; |
@@ -791,7 +791,7 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope) | |||
791 | struct in_device *in_dev; | 791 | struct in_device *in_dev; |
792 | 792 | ||
793 | rcu_read_lock(); | 793 | rcu_read_lock(); |
794 | in_dev = __in_dev_get(dev); | 794 | in_dev = __in_dev_get_rcu(dev); |
795 | if (!in_dev) | 795 | if (!in_dev) |
796 | goto no_in_dev; | 796 | goto no_in_dev; |
797 | 797 | ||
@@ -818,7 +818,7 @@ no_in_dev: | |||
818 | read_lock(&dev_base_lock); | 818 | read_lock(&dev_base_lock); |
819 | rcu_read_lock(); | 819 | rcu_read_lock(); |
820 | for (dev = dev_base; dev; dev = dev->next) { | 820 | for (dev = dev_base; dev; dev = dev->next) { |
821 | if ((in_dev = __in_dev_get(dev)) == NULL) | 821 | if ((in_dev = __in_dev_get_rcu(dev)) == NULL) |
822 | continue; | 822 | continue; |
823 | 823 | ||
824 | for_primary_ifa(in_dev) { | 824 | for_primary_ifa(in_dev) { |
@@ -887,7 +887,7 @@ u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scop | |||
887 | 887 | ||
888 | if (dev) { | 888 | if (dev) { |
889 | rcu_read_lock(); | 889 | rcu_read_lock(); |
890 | if ((in_dev = __in_dev_get(dev))) | 890 | if ((in_dev = __in_dev_get_rcu(dev))) |
891 | addr = confirm_addr_indev(in_dev, dst, local, scope); | 891 | addr = confirm_addr_indev(in_dev, dst, local, scope); |
892 | rcu_read_unlock(); | 892 | rcu_read_unlock(); |
893 | 893 | ||
@@ -897,7 +897,7 @@ u32 inet_confirm_addr(const struct net_device *dev, u32 dst, u32 local, int scop | |||
897 | read_lock(&dev_base_lock); | 897 | read_lock(&dev_base_lock); |
898 | rcu_read_lock(); | 898 | rcu_read_lock(); |
899 | for (dev = dev_base; dev; dev = dev->next) { | 899 | for (dev = dev_base; dev; dev = dev->next) { |
900 | if ((in_dev = __in_dev_get(dev))) { | 900 | if ((in_dev = __in_dev_get_rcu(dev))) { |
901 | addr = confirm_addr_indev(in_dev, dst, local, scope); | 901 | addr = confirm_addr_indev(in_dev, dst, local, scope); |
902 | if (addr) | 902 | if (addr) |
903 | break; | 903 | break; |
@@ -957,7 +957,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
957 | void *ptr) | 957 | void *ptr) |
958 | { | 958 | { |
959 | struct net_device *dev = ptr; | 959 | struct net_device *dev = ptr; |
960 | struct in_device *in_dev = __in_dev_get(dev); | 960 | struct in_device *in_dev = __in_dev_get_rtnl(dev); |
961 | 961 | ||
962 | ASSERT_RTNL(); | 962 | ASSERT_RTNL(); |
963 | 963 | ||
@@ -1078,7 +1078,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb) | |||
1078 | if (idx > s_idx) | 1078 | if (idx > s_idx) |
1079 | s_ip_idx = 0; | 1079 | s_ip_idx = 0; |
1080 | rcu_read_lock(); | 1080 | rcu_read_lock(); |
1081 | if ((in_dev = __in_dev_get(dev)) == NULL) { | 1081 | if ((in_dev = __in_dev_get_rcu(dev)) == NULL) { |
1082 | rcu_read_unlock(); | 1082 | rcu_read_unlock(); |
1083 | continue; | 1083 | continue; |
1084 | } | 1084 | } |
@@ -1149,7 +1149,7 @@ void inet_forward_change(void) | |||
1149 | for (dev = dev_base; dev; dev = dev->next) { | 1149 | for (dev = dev_base; dev; dev = dev->next) { |
1150 | struct in_device *in_dev; | 1150 | struct in_device *in_dev; |
1151 | rcu_read_lock(); | 1151 | rcu_read_lock(); |
1152 | in_dev = __in_dev_get(dev); | 1152 | in_dev = __in_dev_get_rcu(dev); |
1153 | if (in_dev) | 1153 | if (in_dev) |
1154 | in_dev->cnf.forwarding = on; | 1154 | in_dev->cnf.forwarding = on; |
1155 | rcu_read_unlock(); | 1155 | rcu_read_unlock(); |
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 4e1379f71269..e61bc7177eb1 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
@@ -173,7 +173,7 @@ int fib_validate_source(u32 src, u32 dst, u8 tos, int oif, | |||
173 | 173 | ||
174 | no_addr = rpf = 0; | 174 | no_addr = rpf = 0; |
175 | rcu_read_lock(); | 175 | rcu_read_lock(); |
176 | in_dev = __in_dev_get(dev); | 176 | in_dev = __in_dev_get_rcu(dev); |
177 | if (in_dev) { | 177 | if (in_dev) { |
178 | no_addr = in_dev->ifa_list == NULL; | 178 | no_addr = in_dev->ifa_list == NULL; |
179 | rpf = IN_DEV_RPFILTER(in_dev); | 179 | rpf = IN_DEV_RPFILTER(in_dev); |
@@ -607,7 +607,7 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event, | |||
607 | static int fib_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) | 607 | static int fib_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) |
608 | { | 608 | { |
609 | struct net_device *dev = ptr; | 609 | struct net_device *dev = ptr; |
610 | struct in_device *in_dev = __in_dev_get(dev); | 610 | struct in_device *in_dev = __in_dev_get_rtnl(dev); |
611 | 611 | ||
612 | if (event == NETDEV_UNREGISTER) { | 612 | if (event == NETDEV_UNREGISTER) { |
613 | fib_disable_ip(dev, 2); | 613 | fib_disable_ip(dev, 2); |
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index d41219e8037c..186f20c4a45e 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
@@ -1087,7 +1087,7 @@ fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm, | |||
1087 | rta->rta_oif = &dev->ifindex; | 1087 | rta->rta_oif = &dev->ifindex; |
1088 | if (colon) { | 1088 | if (colon) { |
1089 | struct in_ifaddr *ifa; | 1089 | struct in_ifaddr *ifa; |
1090 | struct in_device *in_dev = __in_dev_get(dev); | 1090 | struct in_device *in_dev = __in_dev_get_rtnl(dev); |
1091 | if (!in_dev) | 1091 | if (!in_dev) |
1092 | return -ENODEV; | 1092 | return -ENODEV; |
1093 | *colon = ':'; | 1093 | *colon = ':'; |
@@ -1268,7 +1268,7 @@ int fib_sync_up(struct net_device *dev) | |||
1268 | } | 1268 | } |
1269 | if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP)) | 1269 | if (nh->nh_dev == NULL || !(nh->nh_dev->flags&IFF_UP)) |
1270 | continue; | 1270 | continue; |
1271 | if (nh->nh_dev != dev || __in_dev_get(dev) == NULL) | 1271 | if (nh->nh_dev != dev || !__in_dev_get_rtnl(dev)) |
1272 | continue; | 1272 | continue; |
1273 | alive++; | 1273 | alive++; |
1274 | spin_lock_bh(&fib_multipath_lock); | 1274 | spin_lock_bh(&fib_multipath_lock); |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 24eb56ae1b5a..90dca711ac9f 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -188,7 +188,7 @@ struct icmp_err icmp_err_convert[] = { | |||
188 | 188 | ||
189 | /* Control parameters for ECHO replies. */ | 189 | /* Control parameters for ECHO replies. */ |
190 | int sysctl_icmp_echo_ignore_all; | 190 | int sysctl_icmp_echo_ignore_all; |
191 | int sysctl_icmp_echo_ignore_broadcasts; | 191 | int sysctl_icmp_echo_ignore_broadcasts = 1; |
192 | 192 | ||
193 | /* Control parameter - ignore bogus broadcast responses? */ | 193 | /* Control parameter - ignore bogus broadcast responses? */ |
194 | int sysctl_icmp_ignore_bogus_error_responses; | 194 | int sysctl_icmp_ignore_bogus_error_responses; |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 70c44e4c3ceb..8b6d3939e1e6 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -1323,7 +1323,7 @@ static struct in_device * ip_mc_find_dev(struct ip_mreqn *imr) | |||
1323 | } | 1323 | } |
1324 | if (dev) { | 1324 | if (dev) { |
1325 | imr->imr_ifindex = dev->ifindex; | 1325 | imr->imr_ifindex = dev->ifindex; |
1326 | idev = __in_dev_get(dev); | 1326 | idev = __in_dev_get_rtnl(dev); |
1327 | } | 1327 | } |
1328 | return idev; | 1328 | return idev; |
1329 | } | 1329 | } |
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 4d1502a49852..f9076ef3a1a8 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
@@ -20,7 +20,7 @@ void __inet_twsk_kill(struct inet_timewait_sock *tw, struct inet_hashinfo *hashi | |||
20 | struct inet_bind_hashbucket *bhead; | 20 | struct inet_bind_hashbucket *bhead; |
21 | struct inet_bind_bucket *tb; | 21 | struct inet_bind_bucket *tb; |
22 | /* Unlink from established hashes. */ | 22 | /* Unlink from established hashes. */ |
23 | struct inet_ehash_bucket *ehead = &hashinfo->ehash[tw->tw_hashent]; | 23 | struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, tw->tw_hash); |
24 | 24 | ||
25 | write_lock(&ehead->lock); | 25 | write_lock(&ehead->lock); |
26 | if (hlist_unhashed(&tw->tw_node)) { | 26 | if (hlist_unhashed(&tw->tw_node)) { |
@@ -60,7 +60,7 @@ void __inet_twsk_hashdance(struct inet_timewait_sock *tw, struct sock *sk, | |||
60 | { | 60 | { |
61 | const struct inet_sock *inet = inet_sk(sk); | 61 | const struct inet_sock *inet = inet_sk(sk); |
62 | const struct inet_connection_sock *icsk = inet_csk(sk); | 62 | const struct inet_connection_sock *icsk = inet_csk(sk); |
63 | struct inet_ehash_bucket *ehead = &hashinfo->ehash[sk->sk_hashent]; | 63 | struct inet_ehash_bucket *ehead = inet_ehash_bucket(hashinfo, sk->sk_hash); |
64 | struct inet_bind_hashbucket *bhead; | 64 | struct inet_bind_hashbucket *bhead; |
65 | /* Step 1: Put TW into bind hash. Original socket stays there too. | 65 | /* Step 1: Put TW into bind hash. Original socket stays there too. |
66 | Note, that any socket with inet->num != 0 MUST be bound in | 66 | Note, that any socket with inet->num != 0 MUST be bound in |
@@ -106,7 +106,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat | |||
106 | tw->tw_dport = inet->dport; | 106 | tw->tw_dport = inet->dport; |
107 | tw->tw_family = sk->sk_family; | 107 | tw->tw_family = sk->sk_family; |
108 | tw->tw_reuse = sk->sk_reuse; | 108 | tw->tw_reuse = sk->sk_reuse; |
109 | tw->tw_hashent = sk->sk_hashent; | 109 | tw->tw_hash = sk->sk_hash; |
110 | tw->tw_ipv6only = 0; | 110 | tw->tw_ipv6only = 0; |
111 | tw->tw_prot = sk->sk_prot_creator; | 111 | tw->tw_prot = sk->sk_prot_creator; |
112 | atomic_set(&tw->tw_refcnt, 1); | 112 | atomic_set(&tw->tw_refcnt, 1); |
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index f0d5740d7e22..896ce3f8f53a 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -1104,10 +1104,10 @@ static int ipgre_open(struct net_device *dev) | |||
1104 | return -EADDRNOTAVAIL; | 1104 | return -EADDRNOTAVAIL; |
1105 | dev = rt->u.dst.dev; | 1105 | dev = rt->u.dst.dev; |
1106 | ip_rt_put(rt); | 1106 | ip_rt_put(rt); |
1107 | if (__in_dev_get(dev) == NULL) | 1107 | if (__in_dev_get_rtnl(dev) == NULL) |
1108 | return -EADDRNOTAVAIL; | 1108 | return -EADDRNOTAVAIL; |
1109 | t->mlink = dev->ifindex; | 1109 | t->mlink = dev->ifindex; |
1110 | ip_mc_inc_group(__in_dev_get(dev), t->parms.iph.daddr); | 1110 | ip_mc_inc_group(__in_dev_get_rtnl(dev), t->parms.iph.daddr); |
1111 | } | 1111 | } |
1112 | return 0; | 1112 | return 0; |
1113 | } | 1113 | } |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 9dbf5909f3a6..302b7eb507c9 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -149,7 +149,7 @@ struct net_device *ipmr_new_tunnel(struct vifctl *v) | |||
149 | if (err == 0 && (dev = __dev_get_by_name(p.name)) != NULL) { | 149 | if (err == 0 && (dev = __dev_get_by_name(p.name)) != NULL) { |
150 | dev->flags |= IFF_MULTICAST; | 150 | dev->flags |= IFF_MULTICAST; |
151 | 151 | ||
152 | in_dev = __in_dev_get(dev); | 152 | in_dev = __in_dev_get_rtnl(dev); |
153 | if (in_dev == NULL && (in_dev = inetdev_init(dev)) == NULL) | 153 | if (in_dev == NULL && (in_dev = inetdev_init(dev)) == NULL) |
154 | goto failure; | 154 | goto failure; |
155 | in_dev->cnf.rp_filter = 0; | 155 | in_dev->cnf.rp_filter = 0; |
@@ -278,7 +278,7 @@ static int vif_delete(int vifi) | |||
278 | 278 | ||
279 | dev_set_allmulti(dev, -1); | 279 | dev_set_allmulti(dev, -1); |
280 | 280 | ||
281 | if ((in_dev = __in_dev_get(dev)) != NULL) { | 281 | if ((in_dev = __in_dev_get_rtnl(dev)) != NULL) { |
282 | in_dev->cnf.mc_forwarding--; | 282 | in_dev->cnf.mc_forwarding--; |
283 | ip_rt_multicast_event(in_dev); | 283 | ip_rt_multicast_event(in_dev); |
284 | } | 284 | } |
@@ -421,7 +421,7 @@ static int vif_add(struct vifctl *vifc, int mrtsock) | |||
421 | return -EINVAL; | 421 | return -EINVAL; |
422 | } | 422 | } |
423 | 423 | ||
424 | if ((in_dev = __in_dev_get(dev)) == NULL) | 424 | if ((in_dev = __in_dev_get_rtnl(dev)) == NULL) |
425 | return -EADDRNOTAVAIL; | 425 | return -EADDRNOTAVAIL; |
426 | in_dev->cnf.mc_forwarding++; | 426 | in_dev->cnf.mc_forwarding++; |
427 | dev_set_allmulti(dev, +1); | 427 | dev_set_allmulti(dev, +1); |
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig index 3cf9b451675c..2cd7e7d1ac90 100644 --- a/net/ipv4/netfilter/Kconfig +++ b/net/ipv4/netfilter/Kconfig | |||
@@ -537,6 +537,17 @@ config IP_NF_TARGET_TCPMSS | |||
537 | 537 | ||
538 | To compile it as a module, choose M here. If unsure, say N. | 538 | To compile it as a module, choose M here. If unsure, say N. |
539 | 539 | ||
540 | config IP_NF_TARGET_NFQUEUE | ||
541 | tristate "NFQUEUE Target Support" | ||
542 | depends on IP_NF_IPTABLES | ||
543 | help | ||
544 | This Target replaced the old obsolete QUEUE target. | ||
545 | |||
546 | As opposed to QUEUE, it supports 65535 different queues, | ||
547 | not just one. | ||
548 | |||
549 | To compile it as a module, choose M here. If unsure, say N. | ||
550 | |||
540 | # NAT + specific targets | 551 | # NAT + specific targets |
541 | config IP_NF_NAT | 552 | config IP_NF_NAT |
542 | tristate "Full NAT" | 553 | tristate "Full NAT" |
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile index 3d45d3c0283c..dab4b58dd31e 100644 --- a/net/ipv4/netfilter/Makefile +++ b/net/ipv4/netfilter/Makefile | |||
@@ -4,7 +4,8 @@ | |||
4 | 4 | ||
5 | # objects for the standalone - connection tracking / NAT | 5 | # objects for the standalone - connection tracking / NAT |
6 | ip_conntrack-objs := ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o | 6 | ip_conntrack-objs := ip_conntrack_standalone.o ip_conntrack_core.o ip_conntrack_proto_generic.o ip_conntrack_proto_tcp.o ip_conntrack_proto_udp.o ip_conntrack_proto_icmp.o |
7 | iptable_nat-objs := ip_nat_standalone.o ip_nat_rule.o ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o | 7 | ip_nat-objs := ip_nat_core.o ip_nat_helper.o ip_nat_proto_unknown.o ip_nat_proto_tcp.o ip_nat_proto_udp.o ip_nat_proto_icmp.o |
8 | iptable_nat-objs := ip_nat_rule.o ip_nat_standalone.o | ||
8 | 9 | ||
9 | ip_conntrack_pptp-objs := ip_conntrack_helper_pptp.o ip_conntrack_proto_gre.o | 10 | ip_conntrack_pptp-objs := ip_conntrack_helper_pptp.o ip_conntrack_proto_gre.o |
10 | ip_nat_pptp-objs := ip_nat_helper_pptp.o ip_nat_proto_gre.o | 11 | ip_nat_pptp-objs := ip_nat_helper_pptp.o ip_nat_proto_gre.o |
@@ -40,7 +41,7 @@ obj-$(CONFIG_IP_NF_IPTABLES) += ip_tables.o | |||
40 | # the three instances of ip_tables | 41 | # the three instances of ip_tables |
41 | obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o | 42 | obj-$(CONFIG_IP_NF_FILTER) += iptable_filter.o |
42 | obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o | 43 | obj-$(CONFIG_IP_NF_MANGLE) += iptable_mangle.o |
43 | obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o | 44 | obj-$(CONFIG_IP_NF_NAT) += iptable_nat.o ip_nat.o |
44 | obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o | 45 | obj-$(CONFIG_IP_NF_RAW) += iptable_raw.o |
45 | 46 | ||
46 | # matches | 47 | # matches |
@@ -92,6 +93,7 @@ obj-$(CONFIG_IP_NF_TARGET_TCPMSS) += ipt_TCPMSS.o | |||
92 | obj-$(CONFIG_IP_NF_TARGET_NOTRACK) += ipt_NOTRACK.o | 93 | obj-$(CONFIG_IP_NF_TARGET_NOTRACK) += ipt_NOTRACK.o |
93 | obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o | 94 | obj-$(CONFIG_IP_NF_TARGET_CLUSTERIP) += ipt_CLUSTERIP.o |
94 | obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o | 95 | obj-$(CONFIG_IP_NF_TARGET_TTL) += ipt_TTL.o |
96 | obj-$(CONFIG_IP_NF_TARGET_NFQUEUE) += ipt_NFQUEUE.o | ||
95 | 97 | ||
96 | # generic ARP tables | 98 | # generic ARP tables |
97 | obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o | 99 | obj-$(CONFIG_IP_NF_ARPTABLES) += arp_tables.o |
@@ -101,4 +103,3 @@ obj-$(CONFIG_IP_NF_ARP_MANGLE) += arpt_mangle.o | |||
101 | obj-$(CONFIG_IP_NF_ARPFILTER) += arptable_filter.o | 103 | obj-$(CONFIG_IP_NF_ARPFILTER) += arptable_filter.o |
102 | 104 | ||
103 | obj-$(CONFIG_IP_NF_QUEUE) += ip_queue.o | 105 | obj-$(CONFIG_IP_NF_QUEUE) += ip_queue.o |
104 | obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += ipt_NFQUEUE.o | ||
diff --git a/net/ipv4/netfilter/ip_conntrack_amanda.c b/net/ipv4/netfilter/ip_conntrack_amanda.c index dc20881004bc..fa3f914117ec 100644 --- a/net/ipv4/netfilter/ip_conntrack_amanda.c +++ b/net/ipv4/netfilter/ip_conntrack_amanda.c | |||
@@ -65,7 +65,7 @@ static int help(struct sk_buff **pskb, | |||
65 | 65 | ||
66 | /* increase the UDP timeout of the master connection as replies from | 66 | /* increase the UDP timeout of the master connection as replies from |
67 | * Amanda clients to the server can be quite delayed */ | 67 | * Amanda clients to the server can be quite delayed */ |
68 | ip_ct_refresh_acct(ct, ctinfo, NULL, master_timeout * HZ); | 68 | ip_ct_refresh(ct, *pskb, master_timeout * HZ); |
69 | 69 | ||
70 | /* No data? */ | 70 | /* No data? */ |
71 | dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr); | 71 | dataoff = (*pskb)->nh.iph->ihl*4 + sizeof(struct udphdr); |
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c index c1f82e0c81cf..ea65dd3e517a 100644 --- a/net/ipv4/netfilter/ip_conntrack_core.c +++ b/net/ipv4/netfilter/ip_conntrack_core.c | |||
@@ -1112,45 +1112,46 @@ void ip_conntrack_helper_unregister(struct ip_conntrack_helper *me) | |||
1112 | synchronize_net(); | 1112 | synchronize_net(); |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | static inline void ct_add_counters(struct ip_conntrack *ct, | 1115 | /* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */ |
1116 | enum ip_conntrack_info ctinfo, | 1116 | void __ip_ct_refresh_acct(struct ip_conntrack *ct, |
1117 | const struct sk_buff *skb) | ||
1118 | { | ||
1119 | #ifdef CONFIG_IP_NF_CT_ACCT | ||
1120 | if (skb) { | ||
1121 | ct->counters[CTINFO2DIR(ctinfo)].packets++; | ||
1122 | ct->counters[CTINFO2DIR(ctinfo)].bytes += | ||
1123 | ntohs(skb->nh.iph->tot_len); | ||
1124 | } | ||
1125 | #endif | ||
1126 | } | ||
1127 | |||
1128 | /* Refresh conntrack for this many jiffies and do accounting (if skb != NULL) */ | ||
1129 | void ip_ct_refresh_acct(struct ip_conntrack *ct, | ||
1130 | enum ip_conntrack_info ctinfo, | 1117 | enum ip_conntrack_info ctinfo, |
1131 | const struct sk_buff *skb, | 1118 | const struct sk_buff *skb, |
1132 | unsigned long extra_jiffies) | 1119 | unsigned long extra_jiffies, |
1120 | int do_acct) | ||
1133 | { | 1121 | { |
1122 | int do_event = 0; | ||
1123 | |||
1134 | IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct); | 1124 | IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct); |
1125 | IP_NF_ASSERT(skb); | ||
1126 | |||
1127 | write_lock_bh(&ip_conntrack_lock); | ||
1135 | 1128 | ||
1136 | /* If not in hash table, timer will not be active yet */ | 1129 | /* If not in hash table, timer will not be active yet */ |
1137 | if (!is_confirmed(ct)) { | 1130 | if (!is_confirmed(ct)) { |
1138 | ct->timeout.expires = extra_jiffies; | 1131 | ct->timeout.expires = extra_jiffies; |
1139 | ct_add_counters(ct, ctinfo, skb); | 1132 | do_event = 1; |
1140 | } else { | 1133 | } else { |
1141 | write_lock_bh(&ip_conntrack_lock); | ||
1142 | /* Need del_timer for race avoidance (may already be dying). */ | 1134 | /* Need del_timer for race avoidance (may already be dying). */ |
1143 | if (del_timer(&ct->timeout)) { | 1135 | if (del_timer(&ct->timeout)) { |
1144 | ct->timeout.expires = jiffies + extra_jiffies; | 1136 | ct->timeout.expires = jiffies + extra_jiffies; |
1145 | add_timer(&ct->timeout); | 1137 | add_timer(&ct->timeout); |
1146 | /* FIXME: We loose some REFRESH events if this function | 1138 | do_event = 1; |
1147 | * is called without an skb. I'll fix this later -HW */ | ||
1148 | if (skb) | ||
1149 | ip_conntrack_event_cache(IPCT_REFRESH, skb); | ||
1150 | } | 1139 | } |
1151 | ct_add_counters(ct, ctinfo, skb); | ||
1152 | write_unlock_bh(&ip_conntrack_lock); | ||
1153 | } | 1140 | } |
1141 | |||
1142 | #ifdef CONFIG_IP_NF_CT_ACCT | ||
1143 | if (do_acct) { | ||
1144 | ct->counters[CTINFO2DIR(ctinfo)].packets++; | ||
1145 | ct->counters[CTINFO2DIR(ctinfo)].bytes += | ||
1146 | ntohs(skb->nh.iph->tot_len); | ||
1147 | } | ||
1148 | #endif | ||
1149 | |||
1150 | write_unlock_bh(&ip_conntrack_lock); | ||
1151 | |||
1152 | /* must be unlocked when calling event cache */ | ||
1153 | if (do_event) | ||
1154 | ip_conntrack_event_cache(IPCT_REFRESH, skb); | ||
1154 | } | 1155 | } |
1155 | 1156 | ||
1156 | #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ | 1157 | #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ |
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c index 79db5b70d5f6..926a6684643d 100644 --- a/net/ipv4/netfilter/ip_conntrack_helper_pptp.c +++ b/net/ipv4/netfilter/ip_conntrack_helper_pptp.c | |||
@@ -172,7 +172,6 @@ static int destroy_sibling_or_exp(const struct ip_conntrack_tuple *t) | |||
172 | DEBUGP("setting timeout of conntrack %p to 0\n", sibling); | 172 | DEBUGP("setting timeout of conntrack %p to 0\n", sibling); |
173 | sibling->proto.gre.timeout = 0; | 173 | sibling->proto.gre.timeout = 0; |
174 | sibling->proto.gre.stream_timeout = 0; | 174 | sibling->proto.gre.stream_timeout = 0; |
175 | /* refresh_acct will not modify counters if skb == NULL */ | ||
176 | if (del_timer(&sibling->timeout)) | 175 | if (del_timer(&sibling->timeout)) |
177 | sibling->timeout.function((unsigned long)sibling); | 176 | sibling->timeout.function((unsigned long)sibling); |
178 | ip_conntrack_put(sibling); | 177 | ip_conntrack_put(sibling); |
@@ -223,8 +222,8 @@ static void pptp_destroy_siblings(struct ip_conntrack *ct) | |||
223 | static inline int | 222 | static inline int |
224 | exp_gre(struct ip_conntrack *master, | 223 | exp_gre(struct ip_conntrack *master, |
225 | u_int32_t seq, | 224 | u_int32_t seq, |
226 | u_int16_t callid, | 225 | __be16 callid, |
227 | u_int16_t peer_callid) | 226 | __be16 peer_callid) |
228 | { | 227 | { |
229 | struct ip_conntrack_tuple inv_tuple; | 228 | struct ip_conntrack_tuple inv_tuple; |
230 | struct ip_conntrack_tuple exp_tuples[] = { | 229 | struct ip_conntrack_tuple exp_tuples[] = { |
@@ -263,7 +262,7 @@ exp_gre(struct ip_conntrack *master, | |||
263 | exp_orig->mask.src.ip = 0xffffffff; | 262 | exp_orig->mask.src.ip = 0xffffffff; |
264 | exp_orig->mask.src.u.all = 0; | 263 | exp_orig->mask.src.u.all = 0; |
265 | exp_orig->mask.dst.u.all = 0; | 264 | exp_orig->mask.dst.u.all = 0; |
266 | exp_orig->mask.dst.u.gre.key = 0xffff; | 265 | exp_orig->mask.dst.u.gre.key = htons(0xffff); |
267 | exp_orig->mask.dst.ip = 0xffffffff; | 266 | exp_orig->mask.dst.ip = 0xffffffff; |
268 | exp_orig->mask.dst.protonum = 0xff; | 267 | exp_orig->mask.dst.protonum = 0xff; |
269 | 268 | ||
@@ -340,7 +339,8 @@ pptp_inbound_pkt(struct sk_buff **pskb, | |||
340 | unsigned int reqlen; | 339 | unsigned int reqlen; |
341 | union pptp_ctrl_union _pptpReq, *pptpReq; | 340 | union pptp_ctrl_union _pptpReq, *pptpReq; |
342 | struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info; | 341 | struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info; |
343 | u_int16_t msg, *cid, *pcid; | 342 | u_int16_t msg; |
343 | __be16 *cid, *pcid; | ||
344 | u_int32_t seq; | 344 | u_int32_t seq; |
345 | 345 | ||
346 | ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh); | 346 | ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh); |
@@ -485,7 +485,7 @@ pptp_inbound_pkt(struct sk_buff **pskb, | |||
485 | 485 | ||
486 | if (info->pns_call_id != ntohs(*pcid)) { | 486 | if (info->pns_call_id != ntohs(*pcid)) { |
487 | DEBUGP("%s for unknown CallID %u\n", | 487 | DEBUGP("%s for unknown CallID %u\n", |
488 | pptp_msg_name[msg], ntohs(*cid)); | 488 | pptp_msg_name[msg], ntohs(*pcid)); |
489 | break; | 489 | break; |
490 | } | 490 | } |
491 | 491 | ||
@@ -551,7 +551,8 @@ pptp_outbound_pkt(struct sk_buff **pskb, | |||
551 | unsigned int reqlen; | 551 | unsigned int reqlen; |
552 | union pptp_ctrl_union _pptpReq, *pptpReq; | 552 | union pptp_ctrl_union _pptpReq, *pptpReq; |
553 | struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info; | 553 | struct ip_ct_pptp_master *info = &ct->help.ct_pptp_info; |
554 | u_int16_t msg, *cid, *pcid; | 554 | u_int16_t msg; |
555 | __be16 *cid, *pcid; | ||
555 | 556 | ||
556 | ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh); | 557 | ctlh = skb_header_pointer(*pskb, nexthdr_off, sizeof(_ctlh), &_ctlh); |
557 | if (!ctlh) | 558 | if (!ctlh) |
@@ -755,7 +756,7 @@ static struct ip_conntrack_helper pptp = { | |||
755 | } | 756 | } |
756 | }, | 757 | }, |
757 | .mask = { .src = { .ip = 0, | 758 | .mask = { .src = { .ip = 0, |
758 | .u = { .tcp = { .port = 0xffff } } | 759 | .u = { .tcp = { .port = __constant_htons(0xffff) } } |
759 | }, | 760 | }, |
760 | .dst = { .ip = 0, | 761 | .dst = { .ip = 0, |
761 | .u = { .all = 0 }, | 762 | .u = { .all = 0 }, |
diff --git a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c index 71ef19d126d0..186646eb249f 100644 --- a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c +++ b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c | |||
@@ -58,7 +58,7 @@ static int help(struct sk_buff **pskb, | |||
58 | goto out; | 58 | goto out; |
59 | 59 | ||
60 | rcu_read_lock(); | 60 | rcu_read_lock(); |
61 | in_dev = __in_dev_get(rt->u.dst.dev); | 61 | in_dev = __in_dev_get_rcu(rt->u.dst.dev); |
62 | if (in_dev != NULL) { | 62 | if (in_dev != NULL) { |
63 | for_primary_ifa(in_dev) { | 63 | for_primary_ifa(in_dev) { |
64 | if (ifa->ifa_broadcast == iph->daddr) { | 64 | if (ifa->ifa_broadcast == iph->daddr) { |
@@ -91,7 +91,7 @@ static int help(struct sk_buff **pskb, | |||
91 | ip_conntrack_expect_related(exp); | 91 | ip_conntrack_expect_related(exp); |
92 | ip_conntrack_expect_put(exp); | 92 | ip_conntrack_expect_put(exp); |
93 | 93 | ||
94 | ip_ct_refresh_acct(ct, ctinfo, NULL, timeout * HZ); | 94 | ip_ct_refresh(ct, *pskb, timeout * HZ); |
95 | out: | 95 | out: |
96 | return NF_ACCEPT; | 96 | return NF_ACCEPT; |
97 | } | 97 | } |
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_gre.c b/net/ipv4/netfilter/ip_conntrack_proto_gre.c index de3cb9db6f85..744abb9d377a 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_gre.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_gre.c | |||
@@ -247,6 +247,7 @@ static int gre_packet(struct ip_conntrack *ct, | |||
247 | ct->proto.gre.stream_timeout); | 247 | ct->proto.gre.stream_timeout); |
248 | /* Also, more likely to be important, and not a probe. */ | 248 | /* Also, more likely to be important, and not a probe. */ |
249 | set_bit(IPS_ASSURED_BIT, &ct->status); | 249 | set_bit(IPS_ASSURED_BIT, &ct->status); |
250 | ip_conntrack_event_cache(IPCT_STATUS, skb); | ||
250 | } else | 251 | } else |
251 | ip_ct_refresh_acct(ct, conntrackinfo, skb, | 252 | ip_ct_refresh_acct(ct, conntrackinfo, skb, |
252 | ct->proto.gre.timeout); | 253 | ct->proto.gre.timeout); |
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c index a875f35e576d..59a4a0111dd3 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_sctp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_sctp.c | |||
@@ -416,6 +416,7 @@ static int sctp_packet(struct ip_conntrack *conntrack, | |||
416 | && newconntrack == SCTP_CONNTRACK_ESTABLISHED) { | 416 | && newconntrack == SCTP_CONNTRACK_ESTABLISHED) { |
417 | DEBUGP("Setting assured bit\n"); | 417 | DEBUGP("Setting assured bit\n"); |
418 | set_bit(IPS_ASSURED_BIT, &conntrack->status); | 418 | set_bit(IPS_ASSURED_BIT, &conntrack->status); |
419 | ip_conntrack_event_cache(IPCT_STATUS, skb); | ||
419 | } | 420 | } |
420 | 421 | ||
421 | return NF_ACCEPT; | 422 | return NF_ACCEPT; |
diff --git a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c index 1985abc59d24..121760d6cc50 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c | |||
@@ -1014,7 +1014,8 @@ static int tcp_packet(struct ip_conntrack *conntrack, | |||
1014 | /* Set ASSURED if we see see valid ack in ESTABLISHED | 1014 | /* Set ASSURED if we see see valid ack in ESTABLISHED |
1015 | after SYN_RECV or a valid answer for a picked up | 1015 | after SYN_RECV or a valid answer for a picked up |
1016 | connection. */ | 1016 | connection. */ |
1017 | set_bit(IPS_ASSURED_BIT, &conntrack->status); | 1017 | set_bit(IPS_ASSURED_BIT, &conntrack->status); |
1018 | ip_conntrack_event_cache(IPCT_STATUS, skb); | ||
1018 | } | 1019 | } |
1019 | ip_ct_refresh_acct(conntrack, ctinfo, skb, timeout); | 1020 | ip_ct_refresh_acct(conntrack, ctinfo, skb, timeout); |
1020 | 1021 | ||
diff --git a/net/ipv4/netfilter/ip_conntrack_standalone.c b/net/ipv4/netfilter/ip_conntrack_standalone.c index d3c7808010ec..dd476b191f4b 100644 --- a/net/ipv4/netfilter/ip_conntrack_standalone.c +++ b/net/ipv4/netfilter/ip_conntrack_standalone.c | |||
@@ -989,7 +989,7 @@ EXPORT_SYMBOL(need_ip_conntrack); | |||
989 | EXPORT_SYMBOL(ip_conntrack_helper_register); | 989 | EXPORT_SYMBOL(ip_conntrack_helper_register); |
990 | EXPORT_SYMBOL(ip_conntrack_helper_unregister); | 990 | EXPORT_SYMBOL(ip_conntrack_helper_unregister); |
991 | EXPORT_SYMBOL(ip_ct_iterate_cleanup); | 991 | EXPORT_SYMBOL(ip_ct_iterate_cleanup); |
992 | EXPORT_SYMBOL(ip_ct_refresh_acct); | 992 | EXPORT_SYMBOL(__ip_ct_refresh_acct); |
993 | 993 | ||
994 | EXPORT_SYMBOL(ip_conntrack_expect_alloc); | 994 | EXPORT_SYMBOL(ip_conntrack_expect_alloc); |
995 | EXPORT_SYMBOL(ip_conntrack_expect_put); | 995 | EXPORT_SYMBOL(ip_conntrack_expect_put); |
diff --git a/net/ipv4/netfilter/ip_nat_core.c b/net/ipv4/netfilter/ip_nat_core.c index c3ea891d38e7..c5e3abd24672 100644 --- a/net/ipv4/netfilter/ip_nat_core.c +++ b/net/ipv4/netfilter/ip_nat_core.c | |||
@@ -74,12 +74,14 @@ ip_nat_proto_find_get(u_int8_t protonum) | |||
74 | 74 | ||
75 | return p; | 75 | return p; |
76 | } | 76 | } |
77 | EXPORT_SYMBOL_GPL(ip_nat_proto_find_get); | ||
77 | 78 | ||
78 | void | 79 | void |
79 | ip_nat_proto_put(struct ip_nat_protocol *p) | 80 | ip_nat_proto_put(struct ip_nat_protocol *p) |
80 | { | 81 | { |
81 | module_put(p->me); | 82 | module_put(p->me); |
82 | } | 83 | } |
84 | EXPORT_SYMBOL_GPL(ip_nat_proto_put); | ||
83 | 85 | ||
84 | /* We keep an extra hash for each conntrack, for fast searching. */ | 86 | /* We keep an extra hash for each conntrack, for fast searching. */ |
85 | static inline unsigned int | 87 | static inline unsigned int |
@@ -111,6 +113,7 @@ ip_nat_cheat_check(u_int32_t oldvalinv, u_int32_t newval, u_int16_t oldcheck) | |||
111 | return csum_fold(csum_partial((char *)diffs, sizeof(diffs), | 113 | return csum_fold(csum_partial((char *)diffs, sizeof(diffs), |
112 | oldcheck^0xFFFF)); | 114 | oldcheck^0xFFFF)); |
113 | } | 115 | } |
116 | EXPORT_SYMBOL(ip_nat_cheat_check); | ||
114 | 117 | ||
115 | /* Is this tuple already taken? (not by us) */ | 118 | /* Is this tuple already taken? (not by us) */ |
116 | int | 119 | int |
@@ -127,6 +130,7 @@ ip_nat_used_tuple(const struct ip_conntrack_tuple *tuple, | |||
127 | invert_tuplepr(&reply, tuple); | 130 | invert_tuplepr(&reply, tuple); |
128 | return ip_conntrack_tuple_taken(&reply, ignored_conntrack); | 131 | return ip_conntrack_tuple_taken(&reply, ignored_conntrack); |
129 | } | 132 | } |
133 | EXPORT_SYMBOL(ip_nat_used_tuple); | ||
130 | 134 | ||
131 | /* If we source map this tuple so reply looks like reply_tuple, will | 135 | /* If we source map this tuple so reply looks like reply_tuple, will |
132 | * that meet the constraints of range. */ | 136 | * that meet the constraints of range. */ |
@@ -347,6 +351,7 @@ ip_nat_setup_info(struct ip_conntrack *conntrack, | |||
347 | 351 | ||
348 | return NF_ACCEPT; | 352 | return NF_ACCEPT; |
349 | } | 353 | } |
354 | EXPORT_SYMBOL(ip_nat_setup_info); | ||
350 | 355 | ||
351 | /* Returns true if succeeded. */ | 356 | /* Returns true if succeeded. */ |
352 | static int | 357 | static int |
@@ -387,10 +392,10 @@ manip_pkt(u_int16_t proto, | |||
387 | } | 392 | } |
388 | 393 | ||
389 | /* Do packet manipulations according to ip_nat_setup_info. */ | 394 | /* Do packet manipulations according to ip_nat_setup_info. */ |
390 | unsigned int nat_packet(struct ip_conntrack *ct, | 395 | unsigned int ip_nat_packet(struct ip_conntrack *ct, |
391 | enum ip_conntrack_info ctinfo, | 396 | enum ip_conntrack_info ctinfo, |
392 | unsigned int hooknum, | 397 | unsigned int hooknum, |
393 | struct sk_buff **pskb) | 398 | struct sk_buff **pskb) |
394 | { | 399 | { |
395 | enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); | 400 | enum ip_conntrack_dir dir = CTINFO2DIR(ctinfo); |
396 | unsigned long statusbit; | 401 | unsigned long statusbit; |
@@ -417,12 +422,13 @@ unsigned int nat_packet(struct ip_conntrack *ct, | |||
417 | } | 422 | } |
418 | return NF_ACCEPT; | 423 | return NF_ACCEPT; |
419 | } | 424 | } |
425 | EXPORT_SYMBOL_GPL(ip_nat_packet); | ||
420 | 426 | ||
421 | /* Dir is direction ICMP is coming from (opposite to packet it contains) */ | 427 | /* Dir is direction ICMP is coming from (opposite to packet it contains) */ |
422 | int icmp_reply_translation(struct sk_buff **pskb, | 428 | int ip_nat_icmp_reply_translation(struct sk_buff **pskb, |
423 | struct ip_conntrack *ct, | 429 | struct ip_conntrack *ct, |
424 | enum ip_nat_manip_type manip, | 430 | enum ip_nat_manip_type manip, |
425 | enum ip_conntrack_dir dir) | 431 | enum ip_conntrack_dir dir) |
426 | { | 432 | { |
427 | struct { | 433 | struct { |
428 | struct icmphdr icmp; | 434 | struct icmphdr icmp; |
@@ -509,6 +515,7 @@ int icmp_reply_translation(struct sk_buff **pskb, | |||
509 | 515 | ||
510 | return 1; | 516 | return 1; |
511 | } | 517 | } |
518 | EXPORT_SYMBOL_GPL(ip_nat_icmp_reply_translation); | ||
512 | 519 | ||
513 | /* Protocol registration. */ | 520 | /* Protocol registration. */ |
514 | int ip_nat_protocol_register(struct ip_nat_protocol *proto) | 521 | int ip_nat_protocol_register(struct ip_nat_protocol *proto) |
@@ -525,6 +532,7 @@ int ip_nat_protocol_register(struct ip_nat_protocol *proto) | |||
525 | write_unlock_bh(&ip_nat_lock); | 532 | write_unlock_bh(&ip_nat_lock); |
526 | return ret; | 533 | return ret; |
527 | } | 534 | } |
535 | EXPORT_SYMBOL(ip_nat_protocol_register); | ||
528 | 536 | ||
529 | /* Noone stores the protocol anywhere; simply delete it. */ | 537 | /* Noone stores the protocol anywhere; simply delete it. */ |
530 | void ip_nat_protocol_unregister(struct ip_nat_protocol *proto) | 538 | void ip_nat_protocol_unregister(struct ip_nat_protocol *proto) |
@@ -536,6 +544,7 @@ void ip_nat_protocol_unregister(struct ip_nat_protocol *proto) | |||
536 | /* Someone could be still looking at the proto in a bh. */ | 544 | /* Someone could be still looking at the proto in a bh. */ |
537 | synchronize_net(); | 545 | synchronize_net(); |
538 | } | 546 | } |
547 | EXPORT_SYMBOL(ip_nat_protocol_unregister); | ||
539 | 548 | ||
540 | #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ | 549 | #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ |
541 | defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) | 550 | defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) |
@@ -582,7 +591,7 @@ EXPORT_SYMBOL_GPL(ip_nat_port_nfattr_to_range); | |||
582 | EXPORT_SYMBOL_GPL(ip_nat_port_range_to_nfattr); | 591 | EXPORT_SYMBOL_GPL(ip_nat_port_range_to_nfattr); |
583 | #endif | 592 | #endif |
584 | 593 | ||
585 | int __init ip_nat_init(void) | 594 | static int __init ip_nat_init(void) |
586 | { | 595 | { |
587 | size_t i; | 596 | size_t i; |
588 | 597 | ||
@@ -624,10 +633,14 @@ static int clean_nat(struct ip_conntrack *i, void *data) | |||
624 | return 0; | 633 | return 0; |
625 | } | 634 | } |
626 | 635 | ||
627 | /* Not __exit: called from ip_nat_standalone.c:init_or_cleanup() --RR */ | 636 | static void __exit ip_nat_cleanup(void) |
628 | void ip_nat_cleanup(void) | ||
629 | { | 637 | { |
630 | ip_ct_iterate_cleanup(&clean_nat, NULL); | 638 | ip_ct_iterate_cleanup(&clean_nat, NULL); |
631 | ip_conntrack_destroyed = NULL; | 639 | ip_conntrack_destroyed = NULL; |
632 | vfree(bysource); | 640 | vfree(bysource); |
633 | } | 641 | } |
642 | |||
643 | MODULE_LICENSE("GPL"); | ||
644 | |||
645 | module_init(ip_nat_init); | ||
646 | module_exit(ip_nat_cleanup); | ||
diff --git a/net/ipv4/netfilter/ip_nat_helper.c b/net/ipv4/netfilter/ip_nat_helper.c index d2dd5d313556..5d506e0564d5 100644 --- a/net/ipv4/netfilter/ip_nat_helper.c +++ b/net/ipv4/netfilter/ip_nat_helper.c | |||
@@ -199,6 +199,7 @@ ip_nat_mangle_tcp_packet(struct sk_buff **pskb, | |||
199 | } | 199 | } |
200 | return 1; | 200 | return 1; |
201 | } | 201 | } |
202 | EXPORT_SYMBOL(ip_nat_mangle_tcp_packet); | ||
202 | 203 | ||
203 | /* Generic function for mangling variable-length address changes inside | 204 | /* Generic function for mangling variable-length address changes inside |
204 | * NATed UDP connections (like the CONNECT DATA XXXXX MESG XXXXX INDEX XXXXX | 205 | * NATed UDP connections (like the CONNECT DATA XXXXX MESG XXXXX INDEX XXXXX |
@@ -256,6 +257,7 @@ ip_nat_mangle_udp_packet(struct sk_buff **pskb, | |||
256 | 257 | ||
257 | return 1; | 258 | return 1; |
258 | } | 259 | } |
260 | EXPORT_SYMBOL(ip_nat_mangle_udp_packet); | ||
259 | 261 | ||
260 | /* Adjust one found SACK option including checksum correction */ | 262 | /* Adjust one found SACK option including checksum correction */ |
261 | static void | 263 | static void |
@@ -399,6 +401,7 @@ ip_nat_seq_adjust(struct sk_buff **pskb, | |||
399 | 401 | ||
400 | return 1; | 402 | return 1; |
401 | } | 403 | } |
404 | EXPORT_SYMBOL(ip_nat_seq_adjust); | ||
402 | 405 | ||
403 | /* Setup NAT on this expected conntrack so it follows master. */ | 406 | /* Setup NAT on this expected conntrack so it follows master. */ |
404 | /* If we fail to get a free NAT slot, we'll get dropped on confirm */ | 407 | /* If we fail to get a free NAT slot, we'll get dropped on confirm */ |
@@ -425,3 +428,4 @@ void ip_nat_follow_master(struct ip_conntrack *ct, | |||
425 | /* hook doesn't matter, but it has to do destination manip */ | 428 | /* hook doesn't matter, but it has to do destination manip */ |
426 | ip_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING); | 429 | ip_nat_setup_info(ct, &range, NF_IP_PRE_ROUTING); |
427 | } | 430 | } |
431 | EXPORT_SYMBOL(ip_nat_follow_master); | ||
diff --git a/net/ipv4/netfilter/ip_nat_standalone.c b/net/ipv4/netfilter/ip_nat_standalone.c index 0ff368b131f6..30cd4e18c129 100644 --- a/net/ipv4/netfilter/ip_nat_standalone.c +++ b/net/ipv4/netfilter/ip_nat_standalone.c | |||
@@ -108,8 +108,8 @@ ip_nat_fn(unsigned int hooknum, | |||
108 | case IP_CT_RELATED: | 108 | case IP_CT_RELATED: |
109 | case IP_CT_RELATED+IP_CT_IS_REPLY: | 109 | case IP_CT_RELATED+IP_CT_IS_REPLY: |
110 | if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) { | 110 | if ((*pskb)->nh.iph->protocol == IPPROTO_ICMP) { |
111 | if (!icmp_reply_translation(pskb, ct, maniptype, | 111 | if (!ip_nat_icmp_reply_translation(pskb, ct, maniptype, |
112 | CTINFO2DIR(ctinfo))) | 112 | CTINFO2DIR(ctinfo))) |
113 | return NF_DROP; | 113 | return NF_DROP; |
114 | else | 114 | else |
115 | return NF_ACCEPT; | 115 | return NF_ACCEPT; |
@@ -152,7 +152,7 @@ ip_nat_fn(unsigned int hooknum, | |||
152 | } | 152 | } |
153 | 153 | ||
154 | IP_NF_ASSERT(info); | 154 | IP_NF_ASSERT(info); |
155 | return nat_packet(ct, ctinfo, hooknum, pskb); | 155 | return ip_nat_packet(ct, ctinfo, hooknum, pskb); |
156 | } | 156 | } |
157 | 157 | ||
158 | static unsigned int | 158 | static unsigned int |
@@ -325,15 +325,10 @@ static int init_or_cleanup(int init) | |||
325 | printk("ip_nat_init: can't setup rules.\n"); | 325 | printk("ip_nat_init: can't setup rules.\n"); |
326 | goto cleanup_nothing; | 326 | goto cleanup_nothing; |
327 | } | 327 | } |
328 | ret = ip_nat_init(); | ||
329 | if (ret < 0) { | ||
330 | printk("ip_nat_init: can't setup rules.\n"); | ||
331 | goto cleanup_rule_init; | ||
332 | } | ||
333 | ret = nf_register_hook(&ip_nat_in_ops); | 328 | ret = nf_register_hook(&ip_nat_in_ops); |
334 | if (ret < 0) { | 329 | if (ret < 0) { |
335 | printk("ip_nat_init: can't register in hook.\n"); | 330 | printk("ip_nat_init: can't register in hook.\n"); |
336 | goto cleanup_nat; | 331 | goto cleanup_rule_init; |
337 | } | 332 | } |
338 | ret = nf_register_hook(&ip_nat_out_ops); | 333 | ret = nf_register_hook(&ip_nat_out_ops); |
339 | if (ret < 0) { | 334 | if (ret < 0) { |
@@ -374,8 +369,6 @@ static int init_or_cleanup(int init) | |||
374 | nf_unregister_hook(&ip_nat_out_ops); | 369 | nf_unregister_hook(&ip_nat_out_ops); |
375 | cleanup_inops: | 370 | cleanup_inops: |
376 | nf_unregister_hook(&ip_nat_in_ops); | 371 | nf_unregister_hook(&ip_nat_in_ops); |
377 | cleanup_nat: | ||
378 | ip_nat_cleanup(); | ||
379 | cleanup_rule_init: | 372 | cleanup_rule_init: |
380 | ip_nat_rule_cleanup(); | 373 | ip_nat_rule_cleanup(); |
381 | cleanup_nothing: | 374 | cleanup_nothing: |
@@ -395,14 +388,4 @@ static void __exit fini(void) | |||
395 | module_init(init); | 388 | module_init(init); |
396 | module_exit(fini); | 389 | module_exit(fini); |
397 | 390 | ||
398 | EXPORT_SYMBOL(ip_nat_setup_info); | ||
399 | EXPORT_SYMBOL(ip_nat_protocol_register); | ||
400 | EXPORT_SYMBOL(ip_nat_protocol_unregister); | ||
401 | EXPORT_SYMBOL_GPL(ip_nat_proto_find_get); | ||
402 | EXPORT_SYMBOL_GPL(ip_nat_proto_put); | ||
403 | EXPORT_SYMBOL(ip_nat_cheat_check); | ||
404 | EXPORT_SYMBOL(ip_nat_mangle_tcp_packet); | ||
405 | EXPORT_SYMBOL(ip_nat_mangle_udp_packet); | ||
406 | EXPORT_SYMBOL(ip_nat_used_tuple); | ||
407 | EXPORT_SYMBOL(ip_nat_follow_master); | ||
408 | MODULE_LICENSE("GPL"); | 391 | MODULE_LICENSE("GPL"); |
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index d54f14d926f6..36339eb39e17 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c | |||
@@ -240,8 +240,8 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp) | |||
240 | 240 | ||
241 | pmsg->packet_id = (unsigned long )entry; | 241 | pmsg->packet_id = (unsigned long )entry; |
242 | pmsg->data_len = data_len; | 242 | pmsg->data_len = data_len; |
243 | pmsg->timestamp_sec = skb_tv_base.tv_sec + entry->skb->tstamp.off_sec; | 243 | pmsg->timestamp_sec = entry->skb->tstamp.off_sec; |
244 | pmsg->timestamp_usec = skb_tv_base.tv_usec + entry->skb->tstamp.off_usec; | 244 | pmsg->timestamp_usec = entry->skb->tstamp.off_usec; |
245 | pmsg->mark = entry->skb->nfmark; | 245 | pmsg->mark = entry->skb->nfmark; |
246 | pmsg->hook = entry->info->hook; | 246 | pmsg->hook = entry->info->hook; |
247 | pmsg->hw_protocol = entry->skb->protocol; | 247 | pmsg->hw_protocol = entry->skb->protocol; |
diff --git a/net/ipv4/netfilter/ipt_REDIRECT.c b/net/ipv4/netfilter/ipt_REDIRECT.c index 715cb613405c..5245bfd33d52 100644 --- a/net/ipv4/netfilter/ipt_REDIRECT.c +++ b/net/ipv4/netfilter/ipt_REDIRECT.c | |||
@@ -93,7 +93,7 @@ redirect_target(struct sk_buff **pskb, | |||
93 | newdst = 0; | 93 | newdst = 0; |
94 | 94 | ||
95 | rcu_read_lock(); | 95 | rcu_read_lock(); |
96 | indev = __in_dev_get((*pskb)->dev); | 96 | indev = __in_dev_get_rcu((*pskb)->dev); |
97 | if (indev && (ifa = indev->ifa_list)) | 97 | if (indev && (ifa = indev->ifa_list)) |
98 | newdst = ifa->ifa_local; | 98 | newdst = ifa->ifa_local; |
99 | rcu_read_unlock(); | 99 | rcu_read_unlock(); |
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c index e2c14f3cb2fc..2883ccd8a91d 100644 --- a/net/ipv4/netfilter/ipt_ULOG.c +++ b/net/ipv4/netfilter/ipt_ULOG.c | |||
@@ -225,8 +225,8 @@ static void ipt_ulog_packet(unsigned int hooknum, | |||
225 | 225 | ||
226 | /* copy hook, prefix, timestamp, payload, etc. */ | 226 | /* copy hook, prefix, timestamp, payload, etc. */ |
227 | pm->data_len = copy_len; | 227 | pm->data_len = copy_len; |
228 | pm->timestamp_sec = skb_tv_base.tv_sec + skb->tstamp.off_sec; | 228 | pm->timestamp_sec = skb->tstamp.off_sec; |
229 | pm->timestamp_usec = skb_tv_base.tv_usec + skb->tstamp.off_usec; | 229 | pm->timestamp_usec = skb->tstamp.off_usec; |
230 | pm->mark = skb->nfmark; | 230 | pm->mark = skb->nfmark; |
231 | pm->hook = hooknum; | 231 | pm->hook = hooknum; |
232 | if (prefix != NULL) | 232 | if (prefix != NULL) |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 8549f26e2495..381dd6a6aebb 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2128,7 +2128,7 @@ int ip_route_input(struct sk_buff *skb, u32 daddr, u32 saddr, | |||
2128 | struct in_device *in_dev; | 2128 | struct in_device *in_dev; |
2129 | 2129 | ||
2130 | rcu_read_lock(); | 2130 | rcu_read_lock(); |
2131 | if ((in_dev = __in_dev_get(dev)) != NULL) { | 2131 | if ((in_dev = __in_dev_get_rcu(dev)) != NULL) { |
2132 | int our = ip_check_mc(in_dev, daddr, saddr, | 2132 | int our = ip_check_mc(in_dev, daddr, saddr, |
2133 | skb->nh.iph->protocol); | 2133 | skb->nh.iph->protocol); |
2134 | if (our | 2134 | if (our |
@@ -2443,7 +2443,9 @@ static int ip_route_output_slow(struct rtable **rp, const struct flowi *oldflp) | |||
2443 | err = -ENODEV; | 2443 | err = -ENODEV; |
2444 | if (dev_out == NULL) | 2444 | if (dev_out == NULL) |
2445 | goto out; | 2445 | goto out; |
2446 | if (__in_dev_get(dev_out) == NULL) { | 2446 | |
2447 | /* RACE: Check return value of inet_select_addr instead. */ | ||
2448 | if (__in_dev_get_rtnl(dev_out) == NULL) { | ||
2447 | dev_put(dev_out); | 2449 | dev_put(dev_out); |
2448 | goto out; /* Wrong error code */ | 2450 | goto out; /* Wrong error code */ |
2449 | } | 2451 | } |
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index a7537c7bbd06..677419d0c9ad 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -355,8 +355,6 @@ static void tcp_clamp_window(struct sock *sk, struct tcp_sock *tp) | |||
355 | app_win -= icsk->icsk_ack.rcv_mss; | 355 | app_win -= icsk->icsk_ack.rcv_mss; |
356 | app_win = max(app_win, 2U*tp->advmss); | 356 | app_win = max(app_win, 2U*tp->advmss); |
357 | 357 | ||
358 | if (!ofo_win) | ||
359 | tp->window_clamp = min(tp->window_clamp, app_win); | ||
360 | tp->rcv_ssthresh = min(tp->window_clamp, 2U*tp->advmss); | 358 | tp->rcv_ssthresh = min(tp->window_clamp, 2U*tp->advmss); |
361 | } | 359 | } |
362 | } | 360 | } |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 13dfb391cdf1..c85819d8474b 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -130,19 +130,20 @@ static int __tcp_v4_check_established(struct sock *sk, __u16 lport, | |||
130 | int dif = sk->sk_bound_dev_if; | 130 | int dif = sk->sk_bound_dev_if; |
131 | INET_ADDR_COOKIE(acookie, saddr, daddr) | 131 | INET_ADDR_COOKIE(acookie, saddr, daddr) |
132 | const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); | 132 | const __u32 ports = INET_COMBINED_PORTS(inet->dport, lport); |
133 | const int hash = inet_ehashfn(daddr, lport, saddr, inet->dport, tcp_hashinfo.ehash_size); | 133 | unsigned int hash = inet_ehashfn(daddr, lport, saddr, inet->dport); |
134 | struct inet_ehash_bucket *head = &tcp_hashinfo.ehash[hash]; | 134 | struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash); |
135 | struct sock *sk2; | 135 | struct sock *sk2; |
136 | const struct hlist_node *node; | 136 | const struct hlist_node *node; |
137 | struct inet_timewait_sock *tw; | 137 | struct inet_timewait_sock *tw; |
138 | 138 | ||
139 | prefetch(head->chain.first); | ||
139 | write_lock(&head->lock); | 140 | write_lock(&head->lock); |
140 | 141 | ||
141 | /* Check TIME-WAIT sockets first. */ | 142 | /* Check TIME-WAIT sockets first. */ |
142 | sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) { | 143 | sk_for_each(sk2, node, &(head + tcp_hashinfo.ehash_size)->chain) { |
143 | tw = inet_twsk(sk2); | 144 | tw = inet_twsk(sk2); |
144 | 145 | ||
145 | if (INET_TW_MATCH(sk2, acookie, saddr, daddr, ports, dif)) { | 146 | if (INET_TW_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) { |
146 | const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2); | 147 | const struct tcp_timewait_sock *tcptw = tcp_twsk(sk2); |
147 | struct tcp_sock *tp = tcp_sk(sk); | 148 | struct tcp_sock *tp = tcp_sk(sk); |
148 | 149 | ||
@@ -179,7 +180,7 @@ static int __tcp_v4_check_established(struct sock *sk, __u16 lport, | |||
179 | 180 | ||
180 | /* And established part... */ | 181 | /* And established part... */ |
181 | sk_for_each(sk2, node, &head->chain) { | 182 | sk_for_each(sk2, node, &head->chain) { |
182 | if (INET_MATCH(sk2, acookie, saddr, daddr, ports, dif)) | 183 | if (INET_MATCH(sk2, hash, acookie, saddr, daddr, ports, dif)) |
183 | goto not_unique; | 184 | goto not_unique; |
184 | } | 185 | } |
185 | 186 | ||
@@ -188,7 +189,7 @@ unique: | |||
188 | * in hash table socket with a funny identity. */ | 189 | * in hash table socket with a funny identity. */ |
189 | inet->num = lport; | 190 | inet->num = lport; |
190 | inet->sport = htons(lport); | 191 | inet->sport = htons(lport); |
191 | sk->sk_hashent = hash; | 192 | sk->sk_hash = hash; |
192 | BUG_TRAP(sk_unhashed(sk)); | 193 | BUG_TRAP(sk_unhashed(sk)); |
193 | __sk_add_node(sk, &head->chain); | 194 | __sk_add_node(sk, &head->chain); |
194 | sock_prot_inc_use(sk->sk_prot); | 195 | sock_prot_inc_use(sk->sk_prot); |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 5dd6dd7d091e..c5b911f9b662 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -190,7 +190,7 @@ void tcp_select_initial_window(int __space, __u32 mss, | |||
190 | } | 190 | } |
191 | 191 | ||
192 | /* Set initial window to value enough for senders, | 192 | /* Set initial window to value enough for senders, |
193 | * following RFC1414. Senders, not following this RFC, | 193 | * following RFC2414. Senders, not following this RFC, |
194 | * will be satisfied with 2. | 194 | * will be satisfied with 2. |
195 | */ | 195 | */ |
196 | if (mss > (1<<*rcv_wscale)) { | 196 | if (mss > (1<<*rcv_wscale)) { |
@@ -509,7 +509,16 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss | |||
509 | tp->lost_out -= diff; | 509 | tp->lost_out -= diff; |
510 | tp->left_out -= diff; | 510 | tp->left_out -= diff; |
511 | } | 511 | } |
512 | |||
512 | if (diff > 0) { | 513 | if (diff > 0) { |
514 | /* Adjust Reno SACK estimate. */ | ||
515 | if (!tp->rx_opt.sack_ok) { | ||
516 | tp->sacked_out -= diff; | ||
517 | if ((int)tp->sacked_out < 0) | ||
518 | tp->sacked_out = 0; | ||
519 | tcp_sync_left_out(tp); | ||
520 | } | ||
521 | |||
513 | tp->fackets_out -= diff; | 522 | tp->fackets_out -= diff; |
514 | if ((int)tp->fackets_out < 0) | 523 | if ((int)tp->fackets_out < 0) |
515 | tp->fackets_out = 0; | 524 | tp->fackets_out = 0; |
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 2fea3f4402a0..a970b4727ce8 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c | |||
@@ -1806,7 +1806,7 @@ static void sit_add_v4_addrs(struct inet6_dev *idev) | |||
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | for (dev = dev_base; dev != NULL; dev = dev->next) { | 1808 | for (dev = dev_base; dev != NULL; dev = dev->next) { |
1809 | struct in_device * in_dev = __in_dev_get(dev); | 1809 | struct in_device * in_dev = __in_dev_get_rtnl(dev); |
1810 | if (in_dev && (dev->flags & IFF_UP)) { | 1810 | if (in_dev && (dev->flags & IFF_UP)) { |
1811 | struct in_ifaddr * ifa; | 1811 | struct in_ifaddr * ifa; |
1812 | 1812 | ||
@@ -3520,6 +3520,8 @@ int __init addrconf_init(void) | |||
3520 | if (err) | 3520 | if (err) |
3521 | return err; | 3521 | return err; |
3522 | 3522 | ||
3523 | ip6_null_entry.rt6i_idev = in6_dev_get(&loopback_dev); | ||
3524 | |||
3523 | register_netdevice_notifier(&ipv6_dev_notf); | 3525 | register_netdevice_notifier(&ipv6_dev_notf); |
3524 | 3526 | ||
3525 | #ifdef CONFIG_IPV6_PRIVACY | 3527 | #ifdef CONFIG_IPV6_PRIVACY |
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 2f589f24c093..563b442ffab8 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -666,7 +666,7 @@ slow_path: | |||
666 | */ | 666 | */ |
667 | fh->nexthdr = nexthdr; | 667 | fh->nexthdr = nexthdr; |
668 | fh->reserved = 0; | 668 | fh->reserved = 0; |
669 | if (frag_id) { | 669 | if (!frag_id) { |
670 | ipv6_select_ident(skb, fh); | 670 | ipv6_select_ident(skb, fh); |
671 | frag_id = fh->identification; | 671 | frag_id = fh->identification; |
672 | } else | 672 | } else |
diff --git a/net/ipv6/netfilter/Kconfig b/net/ipv6/netfilter/Kconfig index 216fbe1ac65c..bb7ccfe33f23 100644 --- a/net/ipv6/netfilter/Kconfig +++ b/net/ipv6/netfilter/Kconfig | |||
@@ -209,6 +209,17 @@ config IP6_NF_TARGET_REJECT | |||
209 | 209 | ||
210 | To compile it as a module, choose M here. If unsure, say N. | 210 | To compile it as a module, choose M here. If unsure, say N. |
211 | 211 | ||
212 | config IP6_NF_TARGET_NFQUEUE | ||
213 | tristate "NFQUEUE Target Support" | ||
214 | depends on IP_NF_IPTABLES | ||
215 | help | ||
216 | This Target replaced the old obsolete QUEUE target. | ||
217 | |||
218 | As opposed to QUEUE, it supports 65535 different queues, | ||
219 | not just one. | ||
220 | |||
221 | To compile it as a module, choose M here. If unsure, say N. | ||
222 | |||
212 | # if [ "$CONFIG_IP6_NF_FILTER" != "n" ]; then | 223 | # if [ "$CONFIG_IP6_NF_FILTER" != "n" ]; then |
213 | # dep_tristate ' REJECT target support' CONFIG_IP6_NF_TARGET_REJECT $CONFIG_IP6_NF_FILTER | 224 | # dep_tristate ' REJECT target support' CONFIG_IP6_NF_TARGET_REJECT $CONFIG_IP6_NF_FILTER |
214 | # if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then | 225 | # if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then |
diff --git a/net/ipv6/netfilter/Makefile b/net/ipv6/netfilter/Makefile index bd9a16a5cbba..2b2c370e8b1c 100644 --- a/net/ipv6/netfilter/Makefile +++ b/net/ipv6/netfilter/Makefile | |||
@@ -21,9 +21,9 @@ obj-$(CONFIG_IP6_NF_FILTER) += ip6table_filter.o | |||
21 | obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o | 21 | obj-$(CONFIG_IP6_NF_MANGLE) += ip6table_mangle.o |
22 | obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t_MARK.o | 22 | obj-$(CONFIG_IP6_NF_TARGET_MARK) += ip6t_MARK.o |
23 | obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o | 23 | obj-$(CONFIG_IP6_NF_TARGET_HL) += ip6t_HL.o |
24 | obj-$(CONFIG_IP6_NF_TARGET_NFQUEUE) += ip6t_NFQUEUE.o | ||
24 | obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o | 25 | obj-$(CONFIG_IP6_NF_QUEUE) += ip6_queue.o |
25 | obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o | 26 | obj-$(CONFIG_IP6_NF_TARGET_LOG) += ip6t_LOG.o |
26 | obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o | 27 | obj-$(CONFIG_IP6_NF_RAW) += ip6table_raw.o |
27 | obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o | 28 | obj-$(CONFIG_IP6_NF_MATCH_HL) += ip6t_hl.o |
28 | obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o | 29 | obj-$(CONFIG_IP6_NF_TARGET_REJECT) += ip6t_REJECT.o |
29 | obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += ip6t_NFQUEUE.o | ||
diff --git a/net/ipv6/netfilter/ip6_queue.c b/net/ipv6/netfilter/ip6_queue.c index aa11cf366efa..5027bbe6415e 100644 --- a/net/ipv6/netfilter/ip6_queue.c +++ b/net/ipv6/netfilter/ip6_queue.c | |||
@@ -238,8 +238,8 @@ ipq_build_packet_message(struct ipq_queue_entry *entry, int *errp) | |||
238 | 238 | ||
239 | pmsg->packet_id = (unsigned long )entry; | 239 | pmsg->packet_id = (unsigned long )entry; |
240 | pmsg->data_len = data_len; | 240 | pmsg->data_len = data_len; |
241 | pmsg->timestamp_sec = skb_tv_base.tv_sec + entry->skb->tstamp.off_sec; | 241 | pmsg->timestamp_sec = entry->skb->tstamp.off_sec; |
242 | pmsg->timestamp_usec = skb_tv_base.tv_usec + entry->skb->tstamp.off_usec; | 242 | pmsg->timestamp_usec = entry->skb->tstamp.off_usec; |
243 | pmsg->mark = entry->skb->nfmark; | 243 | pmsg->mark = entry->skb->nfmark; |
244 | pmsg->hook = entry->info->hook; | 244 | pmsg->hook = entry->info->hook; |
245 | pmsg->hw_protocol = entry->skb->protocol; | 245 | pmsg->hw_protocol = entry->skb->protocol; |
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 80643e6b346b..d693cb988b78 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c | |||
@@ -209,9 +209,11 @@ static __inline__ void __tcp_v6_hash(struct sock *sk) | |||
209 | lock = &tcp_hashinfo.lhash_lock; | 209 | lock = &tcp_hashinfo.lhash_lock; |
210 | inet_listen_wlock(&tcp_hashinfo); | 210 | inet_listen_wlock(&tcp_hashinfo); |
211 | } else { | 211 | } else { |
212 | sk->sk_hashent = inet6_sk_ehashfn(sk, tcp_hashinfo.ehash_size); | 212 | unsigned int hash; |
213 | list = &tcp_hashinfo.ehash[sk->sk_hashent].chain; | 213 | sk->sk_hash = hash = inet6_sk_ehashfn(sk); |
214 | lock = &tcp_hashinfo.ehash[sk->sk_hashent].lock; | 214 | hash &= (tcp_hashinfo.ehash_size - 1); |
215 | list = &tcp_hashinfo.ehash[hash].chain; | ||
216 | lock = &tcp_hashinfo.ehash[hash].lock; | ||
215 | write_lock(lock); | 217 | write_lock(lock); |
216 | } | 218 | } |
217 | 219 | ||
@@ -322,13 +324,13 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport, | |||
322 | const struct in6_addr *saddr = &np->daddr; | 324 | const struct in6_addr *saddr = &np->daddr; |
323 | const int dif = sk->sk_bound_dev_if; | 325 | const int dif = sk->sk_bound_dev_if; |
324 | const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); | 326 | const u32 ports = INET_COMBINED_PORTS(inet->dport, lport); |
325 | const int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport, | 327 | unsigned int hash = inet6_ehashfn(daddr, inet->num, saddr, inet->dport); |
326 | tcp_hashinfo.ehash_size); | 328 | struct inet_ehash_bucket *head = inet_ehash_bucket(&tcp_hashinfo, hash); |
327 | struct inet_ehash_bucket *head = &tcp_hashinfo.ehash[hash]; | ||
328 | struct sock *sk2; | 329 | struct sock *sk2; |
329 | const struct hlist_node *node; | 330 | const struct hlist_node *node; |
330 | struct inet_timewait_sock *tw; | 331 | struct inet_timewait_sock *tw; |
331 | 332 | ||
333 | prefetch(head->chain.first); | ||
332 | write_lock(&head->lock); | 334 | write_lock(&head->lock); |
333 | 335 | ||
334 | /* Check TIME-WAIT sockets first. */ | 336 | /* Check TIME-WAIT sockets first. */ |
@@ -365,14 +367,14 @@ static int __tcp_v6_check_established(struct sock *sk, const __u16 lport, | |||
365 | 367 | ||
366 | /* And established part... */ | 368 | /* And established part... */ |
367 | sk_for_each(sk2, node, &head->chain) { | 369 | sk_for_each(sk2, node, &head->chain) { |
368 | if (INET6_MATCH(sk2, saddr, daddr, ports, dif)) | 370 | if (INET6_MATCH(sk2, hash, saddr, daddr, ports, dif)) |
369 | goto not_unique; | 371 | goto not_unique; |
370 | } | 372 | } |
371 | 373 | ||
372 | unique: | 374 | unique: |
373 | BUG_TRAP(sk_unhashed(sk)); | 375 | BUG_TRAP(sk_unhashed(sk)); |
374 | __sk_add_node(sk, &head->chain); | 376 | __sk_add_node(sk, &head->chain); |
375 | sk->sk_hashent = hash; | 377 | sk->sk_hash = hash; |
376 | sock_prot_inc_use(sk->sk_prot); | 378 | sock_prot_inc_use(sk->sk_prot); |
377 | write_unlock(&head->lock); | 379 | write_unlock(&head->lock); |
378 | 380 | ||
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 6001948600f3..e4cad11f284a 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -852,10 +852,16 @@ do_append_data: | |||
852 | else if (!corkreq) | 852 | else if (!corkreq) |
853 | err = udp_v6_push_pending_frames(sk, up); | 853 | err = udp_v6_push_pending_frames(sk, up); |
854 | 854 | ||
855 | if (dst && connected) | 855 | if (dst) { |
856 | ip6_dst_store(sk, dst, | 856 | if (connected) { |
857 | ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ? | 857 | ip6_dst_store(sk, dst, |
858 | &np->daddr : NULL); | 858 | ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ? |
859 | &np->daddr : NULL); | ||
860 | } else { | ||
861 | dst_release(dst); | ||
862 | } | ||
863 | } | ||
864 | |||
859 | if (err > 0) | 865 | if (err > 0) |
860 | err = np->recverr ? net_xmit_errno(err) : 0; | 866 | err = np->recverr ? net_xmit_errno(err) : 0; |
861 | release_sock(sk); | 867 | release_sock(sk); |
diff --git a/net/irda/irlan/irlan_eth.c b/net/irda/irlan/irlan_eth.c index 071cd2cefd8a..953e255d2bc8 100644 --- a/net/irda/irlan/irlan_eth.c +++ b/net/irda/irlan/irlan_eth.c | |||
@@ -310,7 +310,7 @@ void irlan_eth_send_gratuitous_arp(struct net_device *dev) | |||
310 | #ifdef CONFIG_INET | 310 | #ifdef CONFIG_INET |
311 | IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n"); | 311 | IRDA_DEBUG(4, "IrLAN: Sending gratuitous ARP\n"); |
312 | rcu_read_lock(); | 312 | rcu_read_lock(); |
313 | in_dev = __in_dev_get(dev); | 313 | in_dev = __in_dev_get_rcu(dev); |
314 | if (in_dev == NULL) | 314 | if (in_dev == NULL) |
315 | goto out; | 315 | goto out; |
316 | if (in_dev->ifa_list) | 316 | if (in_dev->ifa_list) |
diff --git a/net/irda/irttp.c b/net/irda/irttp.c index 6602d901f8b1..8aff254cb418 100644 --- a/net/irda/irttp.c +++ b/net/irda/irttp.c | |||
@@ -38,7 +38,7 @@ | |||
38 | #include <net/irda/parameters.h> | 38 | #include <net/irda/parameters.h> |
39 | #include <net/irda/irttp.h> | 39 | #include <net/irda/irttp.h> |
40 | 40 | ||
41 | static struct irttp_cb *irttp = NULL; | 41 | static struct irttp_cb *irttp; |
42 | 42 | ||
43 | static void __irttp_close_tsap(struct tsap_cb *self); | 43 | static void __irttp_close_tsap(struct tsap_cb *self); |
44 | 44 | ||
@@ -86,12 +86,9 @@ static pi_param_info_t param_info = { pi_major_call_table, 1, 0x0f, 4 }; | |||
86 | */ | 86 | */ |
87 | int __init irttp_init(void) | 87 | int __init irttp_init(void) |
88 | { | 88 | { |
89 | /* Initialize the irttp structure. */ | 89 | irttp = kmalloc(sizeof(struct irttp_cb), GFP_KERNEL); |
90 | if (irttp == NULL) { | 90 | if (irttp == NULL) |
91 | irttp = kmalloc(sizeof(struct irttp_cb), GFP_KERNEL); | 91 | return -ENOMEM; |
92 | if (irttp == NULL) | ||
93 | return -ENOMEM; | ||
94 | } | ||
95 | memset(irttp, 0, sizeof(struct irttp_cb)); | 92 | memset(irttp, 0, sizeof(struct irttp_cb)); |
96 | 93 | ||
97 | irttp->magic = TTP_MAGIC; | 94 | irttp->magic = TTP_MAGIC; |
@@ -100,6 +97,7 @@ int __init irttp_init(void) | |||
100 | if (!irttp->tsaps) { | 97 | if (!irttp->tsaps) { |
101 | IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n", | 98 | IRDA_ERROR("%s: can't allocate IrTTP hashbin!\n", |
102 | __FUNCTION__); | 99 | __FUNCTION__); |
100 | kfree(irttp); | ||
103 | return -ENOMEM; | 101 | return -ENOMEM; |
104 | } | 102 | } |
105 | 103 | ||
@@ -115,7 +113,6 @@ int __init irttp_init(void) | |||
115 | void __exit irttp_cleanup(void) | 113 | void __exit irttp_cleanup(void) |
116 | { | 114 | { |
117 | /* Check for main structure */ | 115 | /* Check for main structure */ |
118 | IRDA_ASSERT(irttp != NULL, return;); | ||
119 | IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;); | 116 | IRDA_ASSERT(irttp->magic == TTP_MAGIC, return;); |
120 | 117 | ||
121 | /* | 118 | /* |
@@ -382,7 +379,6 @@ struct tsap_cb *irttp_open_tsap(__u8 stsap_sel, int credit, notify_t *notify) | |||
382 | struct lsap_cb *lsap; | 379 | struct lsap_cb *lsap; |
383 | notify_t ttp_notify; | 380 | notify_t ttp_notify; |
384 | 381 | ||
385 | IRDA_ASSERT(irttp != NULL, return NULL;); | ||
386 | IRDA_ASSERT(irttp->magic == TTP_MAGIC, return NULL;); | 382 | IRDA_ASSERT(irttp->magic == TTP_MAGIC, return NULL;); |
387 | 383 | ||
388 | /* The IrLMP spec (IrLMP 1.1 p10) says that we have the right to | 384 | /* The IrLMP spec (IrLMP 1.1 p10) says that we have the right to |
@@ -1880,8 +1876,6 @@ static int irttp_seq_open(struct inode *inode, struct file *file) | |||
1880 | struct seq_file *seq; | 1876 | struct seq_file *seq; |
1881 | int rc = -ENOMEM; | 1877 | int rc = -ENOMEM; |
1882 | struct irttp_iter_state *s; | 1878 | struct irttp_iter_state *s; |
1883 | |||
1884 | IRDA_ASSERT(irttp != NULL, return -EINVAL;); | ||
1885 | 1879 | ||
1886 | s = kmalloc(sizeof(*s), GFP_KERNEL); | 1880 | s = kmalloc(sizeof(*s), GFP_KERNEL); |
1887 | if (!s) | 1881 | if (!s) |
diff --git a/net/llc/Makefile b/net/llc/Makefile index 5ebd4ed2bd42..4e260cff3c5d 100644 --- a/net/llc/Makefile +++ b/net/llc/Makefile | |||
@@ -22,3 +22,4 @@ llc2-y := llc_if.o llc_c_ev.o llc_c_ac.o llc_conn.o llc_c_st.o llc_pdu.o \ | |||
22 | llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o | 22 | llc_sap.o llc_s_ac.o llc_s_ev.o llc_s_st.o af_llc.o llc_station.o |
23 | 23 | ||
24 | llc2-$(CONFIG_PROC_FS) += llc_proc.o | 24 | llc2-$(CONFIG_PROC_FS) += llc_proc.o |
25 | llc2-$(CONFIG_SYSCTL) += sysctl_net_llc.o | ||
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c index 66f55e514b56..59d02cbbeb9e 100644 --- a/net/llc/af_llc.c +++ b/net/llc/af_llc.c | |||
@@ -21,6 +21,7 @@ | |||
21 | * See the GNU General Public License for more details. | 21 | * See the GNU General Public License for more details. |
22 | */ | 22 | */ |
23 | #include <linux/config.h> | 23 | #include <linux/config.h> |
24 | #include <linux/compiler.h> | ||
24 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
25 | #include <linux/module.h> | 26 | #include <linux/module.h> |
26 | #include <linux/rtnetlink.h> | 27 | #include <linux/rtnetlink.h> |
@@ -37,10 +38,9 @@ static u16 llc_ui_sap_link_no_max[256]; | |||
37 | static struct sockaddr_llc llc_ui_addrnull; | 38 | static struct sockaddr_llc llc_ui_addrnull; |
38 | static struct proto_ops llc_ui_ops; | 39 | static struct proto_ops llc_ui_ops; |
39 | 40 | ||
40 | static int llc_ui_wait_for_conn(struct sock *sk, int timeout); | 41 | static int llc_ui_wait_for_conn(struct sock *sk, long timeout); |
41 | static int llc_ui_wait_for_disc(struct sock *sk, int timeout); | 42 | static int llc_ui_wait_for_disc(struct sock *sk, long timeout); |
42 | static int llc_ui_wait_for_data(struct sock *sk, int timeout); | 43 | static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout); |
43 | static int llc_ui_wait_for_busy_core(struct sock *sk, int timeout); | ||
44 | 44 | ||
45 | #if 0 | 45 | #if 0 |
46 | #define dprintk(args...) printk(KERN_DEBUG args) | 46 | #define dprintk(args...) printk(KERN_DEBUG args) |
@@ -116,12 +116,12 @@ static int llc_ui_send_data(struct sock* sk, struct sk_buff *skb, int noblock) | |||
116 | struct llc_sock* llc = llc_sk(sk); | 116 | struct llc_sock* llc = llc_sk(sk); |
117 | int rc = 0; | 117 | int rc = 0; |
118 | 118 | ||
119 | if (llc_data_accept_state(llc->state) || llc->p_flag) { | 119 | if (unlikely(llc_data_accept_state(llc->state) || llc->p_flag)) { |
120 | int timeout = sock_sndtimeo(sk, noblock); | 120 | long timeout = sock_sndtimeo(sk, noblock); |
121 | 121 | ||
122 | rc = llc_ui_wait_for_busy_core(sk, timeout); | 122 | rc = llc_ui_wait_for_busy_core(sk, timeout); |
123 | } | 123 | } |
124 | if (!rc) | 124 | if (unlikely(!rc)) |
125 | rc = llc_build_and_send_pkt(sk, skb); | 125 | rc = llc_build_and_send_pkt(sk, skb); |
126 | return rc; | 126 | return rc; |
127 | } | 127 | } |
@@ -155,7 +155,7 @@ static int llc_ui_create(struct socket *sock, int protocol) | |||
155 | struct sock *sk; | 155 | struct sock *sk; |
156 | int rc = -ESOCKTNOSUPPORT; | 156 | int rc = -ESOCKTNOSUPPORT; |
157 | 157 | ||
158 | if (sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM) { | 158 | if (likely(sock->type == SOCK_DGRAM || sock->type == SOCK_STREAM)) { |
159 | rc = -ENOMEM; | 159 | rc = -ENOMEM; |
160 | sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto); | 160 | sk = llc_sk_alloc(PF_LLC, GFP_KERNEL, &llc_proto); |
161 | if (sk) { | 161 | if (sk) { |
@@ -177,7 +177,7 @@ static int llc_ui_release(struct socket *sock) | |||
177 | struct sock *sk = sock->sk; | 177 | struct sock *sk = sock->sk; |
178 | struct llc_sock *llc; | 178 | struct llc_sock *llc; |
179 | 179 | ||
180 | if (!sk) | 180 | if (unlikely(sk == NULL)) |
181 | goto out; | 181 | goto out; |
182 | sock_hold(sk); | 182 | sock_hold(sk); |
183 | lock_sock(sk); | 183 | lock_sock(sk); |
@@ -189,10 +189,6 @@ static int llc_ui_release(struct socket *sock) | |||
189 | if (!sock_flag(sk, SOCK_ZAPPED)) | 189 | if (!sock_flag(sk, SOCK_ZAPPED)) |
190 | llc_sap_remove_socket(llc->sap, sk); | 190 | llc_sap_remove_socket(llc->sap, sk); |
191 | release_sock(sk); | 191 | release_sock(sk); |
192 | if (llc->sap && hlist_empty(&llc->sap->sk_list.list)) { | ||
193 | llc_release_sockets(llc->sap); | ||
194 | llc_sap_close(llc->sap); | ||
195 | } | ||
196 | if (llc->dev) | 192 | if (llc->dev) |
197 | dev_put(llc->dev); | 193 | dev_put(llc->dev); |
198 | sock_put(sk); | 194 | sock_put(sk); |
@@ -221,6 +217,7 @@ static int llc_ui_autoport(void) | |||
221 | llc_ui_sap_last_autoport = i + 2; | 217 | llc_ui_sap_last_autoport = i + 2; |
222 | goto out; | 218 | goto out; |
223 | } | 219 | } |
220 | llc_sap_put(sap); | ||
224 | } | 221 | } |
225 | llc_ui_sap_last_autoport = LLC_SAP_DYN_START; | 222 | llc_ui_sap_last_autoport = LLC_SAP_DYN_START; |
226 | tries++; | 223 | tries++; |
@@ -231,20 +228,13 @@ out: | |||
231 | } | 228 | } |
232 | 229 | ||
233 | /** | 230 | /** |
234 | * llc_ui_autobind - Bind a socket to a specific address. | 231 | * llc_ui_autobind - automatically bind a socket to a sap |
235 | * @sk: Socket to bind an address to. | 232 | * @sock: socket to bind |
236 | * @addr: Address the user wants the socket bound to. | 233 | * @addr: address to connect to |
234 | * | ||
235 | * Used by llc_ui_connect and llc_ui_sendmsg when the user hasn't | ||
236 | * specifically used llc_ui_bind to bind to an specific address/sap | ||
237 | * | 237 | * |
238 | * Bind a socket to a specific address. For llc a user is able to bind to | ||
239 | * a specific sap only or mac + sap. If the user only specifies a sap and | ||
240 | * a null dmac (all zeros) the user is attempting to bind to an entire | ||
241 | * sap. This will stop anyone else on the local system from using that | ||
242 | * sap. If someone else has a mac + sap open the bind to null + sap will | ||
243 | * fail. | ||
244 | * If the user desires to bind to a specific mac + sap, it is possible to | ||
245 | * have multiple sap connections via multiple macs. | ||
246 | * Bind and autobind for that matter must enforce the correct sap usage | ||
247 | * otherwise all hell will break loose. | ||
248 | * Returns: 0 upon success, negative otherwise. | 238 | * Returns: 0 upon success, negative otherwise. |
249 | */ | 239 | */ |
250 | static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) | 240 | static int llc_ui_autobind(struct socket *sock, struct sockaddr_llc *addr) |
@@ -285,11 +275,7 @@ out: | |||
285 | * @addrlen: Length of the uaddr structure. | 275 | * @addrlen: Length of the uaddr structure. |
286 | * | 276 | * |
287 | * Bind a socket to a specific address. For llc a user is able to bind to | 277 | * Bind a socket to a specific address. For llc a user is able to bind to |
288 | * a specific sap only or mac + sap. If the user only specifies a sap and | 278 | * a specific sap only or mac + sap. |
289 | * a null dmac (all zeros) the user is attempting to bind to an entire | ||
290 | * sap. This will stop anyone else on the local system from using that | ||
291 | * sap. If someone else has a mac + sap open the bind to null + sap will | ||
292 | * fail. | ||
293 | * If the user desires to bind to a specific mac + sap, it is possible to | 279 | * If the user desires to bind to a specific mac + sap, it is possible to |
294 | * have multiple sap connections via multiple macs. | 280 | * have multiple sap connections via multiple macs. |
295 | * Bind and autobind for that matter must enforce the correct sap usage | 281 | * Bind and autobind for that matter must enforce the correct sap usage |
@@ -305,10 +291,16 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
305 | int rc = -EINVAL; | 291 | int rc = -EINVAL; |
306 | 292 | ||
307 | dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap); | 293 | dprintk("%s: binding %02X\n", __FUNCTION__, addr->sllc_sap); |
308 | if (!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr)) | 294 | if (unlikely(!sock_flag(sk, SOCK_ZAPPED) || addrlen != sizeof(*addr))) |
309 | goto out; | 295 | goto out; |
310 | rc = -EAFNOSUPPORT; | 296 | rc = -EAFNOSUPPORT; |
311 | if (addr->sllc_family != AF_LLC) | 297 | if (unlikely(addr->sllc_family != AF_LLC)) |
298 | goto out; | ||
299 | rc = -ENODEV; | ||
300 | rtnl_lock(); | ||
301 | llc->dev = dev_getbyhwaddr(addr->sllc_arphrd, addr->sllc_mac); | ||
302 | rtnl_unlock(); | ||
303 | if (!llc->dev) | ||
312 | goto out; | 304 | goto out; |
313 | if (!addr->sllc_sap) { | 305 | if (!addr->sllc_sap) { |
314 | rc = -EUSERS; | 306 | rc = -EUSERS; |
@@ -322,6 +314,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
322 | rc = -EBUSY; /* some other network layer is using the sap */ | 314 | rc = -EBUSY; /* some other network layer is using the sap */ |
323 | if (!sap) | 315 | if (!sap) |
324 | goto out; | 316 | goto out; |
317 | llc_sap_hold(sap); | ||
325 | } else { | 318 | } else { |
326 | struct llc_addr laddr, daddr; | 319 | struct llc_addr laddr, daddr; |
327 | struct sock *ask; | 320 | struct sock *ask; |
@@ -338,7 +331,7 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
338 | ask = llc_lookup_established(sap, &daddr, &laddr); | 331 | ask = llc_lookup_established(sap, &daddr, &laddr); |
339 | if (ask) { | 332 | if (ask) { |
340 | sock_put(ask); | 333 | sock_put(ask); |
341 | goto out; | 334 | goto out_put; |
342 | } | 335 | } |
343 | } | 336 | } |
344 | llc->laddr.lsap = addr->sllc_sap; | 337 | llc->laddr.lsap = addr->sllc_sap; |
@@ -348,6 +341,8 @@ static int llc_ui_bind(struct socket *sock, struct sockaddr *uaddr, int addrlen) | |||
348 | llc_sap_add_socket(sap, sk); | 341 | llc_sap_add_socket(sap, sk); |
349 | sock_reset_flag(sk, SOCK_ZAPPED); | 342 | sock_reset_flag(sk, SOCK_ZAPPED); |
350 | rc = 0; | 343 | rc = 0; |
344 | out_put: | ||
345 | llc_sap_put(sap); | ||
351 | out: | 346 | out: |
352 | return rc; | 347 | return rc; |
353 | } | 348 | } |
@@ -369,7 +364,7 @@ static int llc_ui_shutdown(struct socket *sock, int how) | |||
369 | int rc = -ENOTCONN; | 364 | int rc = -ENOTCONN; |
370 | 365 | ||
371 | lock_sock(sk); | 366 | lock_sock(sk); |
372 | if (sk->sk_state != TCP_ESTABLISHED) | 367 | if (unlikely(sk->sk_state != TCP_ESTABLISHED)) |
373 | goto out; | 368 | goto out; |
374 | rc = -EINVAL; | 369 | rc = -EINVAL; |
375 | if (how != 2) | 370 | if (how != 2) |
@@ -404,14 +399,18 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr, | |||
404 | struct sock *sk = sock->sk; | 399 | struct sock *sk = sock->sk; |
405 | struct llc_sock *llc = llc_sk(sk); | 400 | struct llc_sock *llc = llc_sk(sk); |
406 | struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr; | 401 | struct sockaddr_llc *addr = (struct sockaddr_llc *)uaddr; |
407 | struct net_device *dev; | ||
408 | int rc = -EINVAL; | 402 | int rc = -EINVAL; |
409 | 403 | ||
410 | lock_sock(sk); | 404 | lock_sock(sk); |
411 | if (addrlen != sizeof(*addr)) | 405 | if (unlikely(addrlen != sizeof(*addr))) |
412 | goto out; | 406 | goto out; |
413 | rc = -EAFNOSUPPORT; | 407 | rc = -EAFNOSUPPORT; |
414 | if (addr->sllc_family != AF_LLC) | 408 | if (unlikely(addr->sllc_family != AF_LLC)) |
409 | goto out; | ||
410 | if (unlikely(sk->sk_type != SOCK_STREAM)) | ||
411 | goto out; | ||
412 | rc = -EALREADY; | ||
413 | if (unlikely(sock->state == SS_CONNECTING)) | ||
415 | goto out; | 414 | goto out; |
416 | /* bind connection to sap if user hasn't done it. */ | 415 | /* bind connection to sap if user hasn't done it. */ |
417 | if (sock_flag(sk, SOCK_ZAPPED)) { | 416 | if (sock_flag(sk, SOCK_ZAPPED)) { |
@@ -419,19 +418,13 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr, | |||
419 | rc = llc_ui_autobind(sock, addr); | 418 | rc = llc_ui_autobind(sock, addr); |
420 | if (rc) | 419 | if (rc) |
421 | goto out; | 420 | goto out; |
422 | llc->daddr.lsap = addr->sllc_sap; | ||
423 | memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN); | ||
424 | } | 421 | } |
425 | dev = llc->dev; | 422 | llc->daddr.lsap = addr->sllc_sap; |
426 | if (sk->sk_type != SOCK_STREAM) | 423 | memcpy(llc->daddr.mac, addr->sllc_mac, IFHWADDRLEN); |
427 | goto out; | ||
428 | rc = -EALREADY; | ||
429 | if (sock->state == SS_CONNECTING) | ||
430 | goto out; | ||
431 | sock->state = SS_CONNECTING; | 424 | sock->state = SS_CONNECTING; |
432 | sk->sk_state = TCP_SYN_SENT; | 425 | sk->sk_state = TCP_SYN_SENT; |
433 | llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap); | 426 | llc->link = llc_ui_next_link_no(llc->sap->laddr.lsap); |
434 | rc = llc_establish_connection(sk, dev->dev_addr, | 427 | rc = llc_establish_connection(sk, llc->dev->dev_addr, |
435 | addr->sllc_mac, addr->sllc_sap); | 428 | addr->sllc_mac, addr->sllc_sap); |
436 | if (rc) { | 429 | if (rc) { |
437 | dprintk("%s: llc_ui_send_conn failed :-(\n", __FUNCTION__); | 430 | dprintk("%s: llc_ui_send_conn failed :-(\n", __FUNCTION__); |
@@ -439,12 +432,30 @@ static int llc_ui_connect(struct socket *sock, struct sockaddr *uaddr, | |||
439 | sk->sk_state = TCP_CLOSE; | 432 | sk->sk_state = TCP_CLOSE; |
440 | goto out; | 433 | goto out; |
441 | } | 434 | } |
442 | rc = llc_ui_wait_for_conn(sk, sk->sk_rcvtimeo); | 435 | |
443 | if (rc) | 436 | if (sk->sk_state == TCP_SYN_SENT) { |
444 | dprintk("%s: llc_ui_wait_for_conn failed=%d\n", __FUNCTION__, rc); | 437 | const long timeo = sock_sndtimeo(sk, flags & O_NONBLOCK); |
438 | |||
439 | if (!timeo || !llc_ui_wait_for_conn(sk, timeo)) | ||
440 | goto out; | ||
441 | |||
442 | rc = sock_intr_errno(timeo); | ||
443 | if (signal_pending(current)) | ||
444 | goto out; | ||
445 | } | ||
446 | |||
447 | if (sk->sk_state == TCP_CLOSE) | ||
448 | goto sock_error; | ||
449 | |||
450 | sock->state = SS_CONNECTED; | ||
451 | rc = 0; | ||
445 | out: | 452 | out: |
446 | release_sock(sk); | 453 | release_sock(sk); |
447 | return rc; | 454 | return rc; |
455 | sock_error: | ||
456 | rc = sock_error(sk) ? : -ECONNABORTED; | ||
457 | sock->state = SS_UNCONNECTED; | ||
458 | goto out; | ||
448 | } | 459 | } |
449 | 460 | ||
450 | /** | 461 | /** |
@@ -461,10 +472,10 @@ static int llc_ui_listen(struct socket *sock, int backlog) | |||
461 | int rc = -EINVAL; | 472 | int rc = -EINVAL; |
462 | 473 | ||
463 | lock_sock(sk); | 474 | lock_sock(sk); |
464 | if (sock->state != SS_UNCONNECTED) | 475 | if (unlikely(sock->state != SS_UNCONNECTED)) |
465 | goto out; | 476 | goto out; |
466 | rc = -EOPNOTSUPP; | 477 | rc = -EOPNOTSUPP; |
467 | if (sk->sk_type != SOCK_STREAM) | 478 | if (unlikely(sk->sk_type != SOCK_STREAM)) |
468 | goto out; | 479 | goto out; |
469 | rc = -EAGAIN; | 480 | rc = -EAGAIN; |
470 | if (sock_flag(sk, SOCK_ZAPPED)) | 481 | if (sock_flag(sk, SOCK_ZAPPED)) |
@@ -483,20 +494,14 @@ out: | |||
483 | return rc; | 494 | return rc; |
484 | } | 495 | } |
485 | 496 | ||
486 | static int llc_ui_wait_for_disc(struct sock *sk, int timeout) | 497 | static int llc_ui_wait_for_disc(struct sock *sk, long timeout) |
487 | { | 498 | { |
488 | DECLARE_WAITQUEUE(wait, current); | 499 | DEFINE_WAIT(wait); |
489 | int rc; | 500 | int rc = 0; |
490 | 501 | ||
491 | add_wait_queue_exclusive(sk->sk_sleep, &wait); | 502 | while (1) { |
492 | for (;;) { | 503 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
493 | __set_current_state(TASK_INTERRUPTIBLE); | 504 | if (sk_wait_event(sk, &timeout, sk->sk_state == TCP_CLOSE)) |
494 | rc = 0; | ||
495 | if (sk->sk_state != TCP_CLOSE) { | ||
496 | release_sock(sk); | ||
497 | timeout = schedule_timeout(timeout); | ||
498 | lock_sock(sk); | ||
499 | } else | ||
500 | break; | 505 | break; |
501 | rc = -ERESTARTSYS; | 506 | rc = -ERESTARTSYS; |
502 | if (signal_pending(current)) | 507 | if (signal_pending(current)) |
@@ -504,65 +509,40 @@ static int llc_ui_wait_for_disc(struct sock *sk, int timeout) | |||
504 | rc = -EAGAIN; | 509 | rc = -EAGAIN; |
505 | if (!timeout) | 510 | if (!timeout) |
506 | break; | 511 | break; |
512 | rc = 0; | ||
507 | } | 513 | } |
508 | __set_current_state(TASK_RUNNING); | 514 | finish_wait(sk->sk_sleep, &wait); |
509 | remove_wait_queue(sk->sk_sleep, &wait); | ||
510 | return rc; | 515 | return rc; |
511 | } | 516 | } |
512 | 517 | ||
513 | static int llc_ui_wait_for_conn(struct sock *sk, int timeout) | 518 | static int llc_ui_wait_for_conn(struct sock *sk, long timeout) |
514 | { | 519 | { |
515 | DECLARE_WAITQUEUE(wait, current); | 520 | DEFINE_WAIT(wait); |
516 | int rc; | ||
517 | 521 | ||
518 | add_wait_queue_exclusive(sk->sk_sleep, &wait); | 522 | while (1) { |
519 | for (;;) { | 523 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
520 | __set_current_state(TASK_INTERRUPTIBLE); | 524 | if (sk_wait_event(sk, &timeout, sk->sk_state != TCP_SYN_SENT)) |
521 | rc = -EAGAIN; | ||
522 | if (sk->sk_state == TCP_CLOSE) | ||
523 | break; | ||
524 | rc = 0; | ||
525 | if (sk->sk_state != TCP_ESTABLISHED) { | ||
526 | release_sock(sk); | ||
527 | timeout = schedule_timeout(timeout); | ||
528 | lock_sock(sk); | ||
529 | } else | ||
530 | break; | 525 | break; |
531 | rc = -ERESTARTSYS; | 526 | if (signal_pending(current) || !timeout) |
532 | if (signal_pending(current)) | ||
533 | break; | ||
534 | rc = -EAGAIN; | ||
535 | if (!timeout) | ||
536 | break; | 527 | break; |
537 | } | 528 | } |
538 | __set_current_state(TASK_RUNNING); | 529 | finish_wait(sk->sk_sleep, &wait); |
539 | remove_wait_queue(sk->sk_sleep, &wait); | 530 | return timeout; |
540 | return rc; | ||
541 | } | 531 | } |
542 | 532 | ||
543 | static int llc_ui_wait_for_data(struct sock *sk, int timeout) | 533 | static int llc_ui_wait_for_busy_core(struct sock *sk, long timeout) |
544 | { | 534 | { |
545 | DECLARE_WAITQUEUE(wait, current); | 535 | DEFINE_WAIT(wait); |
546 | int rc = 0; | 536 | struct llc_sock *llc = llc_sk(sk); |
537 | int rc; | ||
547 | 538 | ||
548 | add_wait_queue_exclusive(sk->sk_sleep, &wait); | 539 | while (1) { |
549 | for (;;) { | 540 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); |
550 | __set_current_state(TASK_INTERRUPTIBLE); | ||
551 | if (sk->sk_shutdown & RCV_SHUTDOWN) | ||
552 | break; | ||
553 | /* | ||
554 | * Well, if we have backlog, try to process it now. | ||
555 | */ | ||
556 | if (sk->sk_backlog.tail) { | ||
557 | release_sock(sk); | ||
558 | lock_sock(sk); | ||
559 | } | ||
560 | rc = 0; | 541 | rc = 0; |
561 | if (skb_queue_empty(&sk->sk_receive_queue)) { | 542 | if (sk_wait_event(sk, &timeout, |
562 | release_sock(sk); | 543 | (sk->sk_shutdown & RCV_SHUTDOWN) || |
563 | timeout = schedule_timeout(timeout); | 544 | (!llc_data_accept_state(llc->state) && |
564 | lock_sock(sk); | 545 | !llc->p_flag))) |
565 | } else | ||
566 | break; | 546 | break; |
567 | rc = -ERESTARTSYS; | 547 | rc = -ERESTARTSYS; |
568 | if (signal_pending(current)) | 548 | if (signal_pending(current)) |
@@ -571,40 +551,35 @@ static int llc_ui_wait_for_data(struct sock *sk, int timeout) | |||
571 | if (!timeout) | 551 | if (!timeout) |
572 | break; | 552 | break; |
573 | } | 553 | } |
574 | __set_current_state(TASK_RUNNING); | 554 | finish_wait(sk->sk_sleep, &wait); |
575 | remove_wait_queue(sk->sk_sleep, &wait); | ||
576 | return rc; | 555 | return rc; |
577 | } | 556 | } |
578 | 557 | ||
579 | static int llc_ui_wait_for_busy_core(struct sock *sk, int timeout) | 558 | static int llc_wait_data(struct sock *sk, long timeo) |
580 | { | 559 | { |
581 | DECLARE_WAITQUEUE(wait, current); | ||
582 | struct llc_sock *llc = llc_sk(sk); | ||
583 | int rc; | 560 | int rc; |
584 | 561 | ||
585 | add_wait_queue_exclusive(sk->sk_sleep, &wait); | 562 | while (1) { |
586 | for (;;) { | 563 | /* |
587 | dprintk("%s: looping...\n", __FUNCTION__); | 564 | * POSIX 1003.1g mandates this order. |
588 | __set_current_state(TASK_INTERRUPTIBLE); | 565 | */ |
589 | rc = -ENOTCONN; | 566 | if (sk->sk_err) { |
590 | if (sk->sk_shutdown & RCV_SHUTDOWN) | 567 | rc = sock_error(sk); |
591 | break; | 568 | break; |
569 | } | ||
592 | rc = 0; | 570 | rc = 0; |
593 | if (llc_data_accept_state(llc->state) || llc->p_flag) { | 571 | if (sk->sk_shutdown & RCV_SHUTDOWN) |
594 | release_sock(sk); | ||
595 | timeout = schedule_timeout(timeout); | ||
596 | lock_sock(sk); | ||
597 | } else | ||
598 | break; | 572 | break; |
599 | rc = -ERESTARTSYS; | 573 | rc = -EAGAIN; |
574 | if (!timeo) | ||
575 | break; | ||
576 | rc = sock_intr_errno(timeo); | ||
600 | if (signal_pending(current)) | 577 | if (signal_pending(current)) |
601 | break; | 578 | break; |
602 | rc = -EAGAIN; | 579 | rc = 0; |
603 | if (!timeout) | 580 | if (sk_wait_data(sk, &timeo)) |
604 | break; | 581 | break; |
605 | } | 582 | } |
606 | __set_current_state(TASK_RUNNING); | ||
607 | remove_wait_queue(sk->sk_sleep, &wait); | ||
608 | return rc; | 583 | return rc; |
609 | } | 584 | } |
610 | 585 | ||
@@ -627,15 +602,18 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags) | |||
627 | dprintk("%s: accepting on %02X\n", __FUNCTION__, | 602 | dprintk("%s: accepting on %02X\n", __FUNCTION__, |
628 | llc_sk(sk)->laddr.lsap); | 603 | llc_sk(sk)->laddr.lsap); |
629 | lock_sock(sk); | 604 | lock_sock(sk); |
630 | if (sk->sk_type != SOCK_STREAM) | 605 | if (unlikely(sk->sk_type != SOCK_STREAM)) |
631 | goto out; | 606 | goto out; |
632 | rc = -EINVAL; | 607 | rc = -EINVAL; |
633 | if (sock->state != SS_UNCONNECTED || sk->sk_state != TCP_LISTEN) | 608 | if (unlikely(sock->state != SS_UNCONNECTED || |
609 | sk->sk_state != TCP_LISTEN)) | ||
634 | goto out; | 610 | goto out; |
635 | /* wait for a connection to arrive. */ | 611 | /* wait for a connection to arrive. */ |
636 | rc = llc_ui_wait_for_data(sk, sk->sk_rcvtimeo); | 612 | if (skb_queue_empty(&sk->sk_receive_queue)) { |
637 | if (rc) | 613 | rc = llc_wait_data(sk, sk->sk_rcvtimeo); |
638 | goto out; | 614 | if (rc) |
615 | goto out; | ||
616 | } | ||
639 | dprintk("%s: got a new connection on %02X\n", __FUNCTION__, | 617 | dprintk("%s: got a new connection on %02X\n", __FUNCTION__, |
640 | llc_sk(sk)->laddr.lsap); | 618 | llc_sk(sk)->laddr.lsap); |
641 | skb = skb_dequeue(&sk->sk_receive_queue); | 619 | skb = skb_dequeue(&sk->sk_receive_queue); |
@@ -657,7 +635,6 @@ static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags) | |||
657 | /* put original socket back into a clean listen state. */ | 635 | /* put original socket back into a clean listen state. */ |
658 | sk->sk_state = TCP_LISTEN; | 636 | sk->sk_state = TCP_LISTEN; |
659 | sk->sk_ack_backlog--; | 637 | sk->sk_ack_backlog--; |
660 | skb->sk = NULL; | ||
661 | dprintk("%s: ok success on %02X, client on %02X\n", __FUNCTION__, | 638 | dprintk("%s: ok success on %02X, client on %02X\n", __FUNCTION__, |
662 | llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap); | 639 | llc_sk(sk)->addr.sllc_sap, newllc->daddr.lsap); |
663 | frees: | 640 | frees: |
@@ -671,56 +648,167 @@ out: | |||
671 | * llc_ui_recvmsg - copy received data to the socket user. | 648 | * llc_ui_recvmsg - copy received data to the socket user. |
672 | * @sock: Socket to copy data from. | 649 | * @sock: Socket to copy data from. |
673 | * @msg: Various user space related information. | 650 | * @msg: Various user space related information. |
674 | * @size: Size of user buffer. | 651 | * @len: Size of user buffer. |
675 | * @flags: User specified flags. | 652 | * @flags: User specified flags. |
676 | * | 653 | * |
677 | * Copy received data to the socket user. | 654 | * Copy received data to the socket user. |
678 | * Returns non-negative upon success, negative otherwise. | 655 | * Returns non-negative upon success, negative otherwise. |
679 | */ | 656 | */ |
680 | static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, | 657 | static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock, |
681 | struct msghdr *msg, size_t size, int flags) | 658 | struct msghdr *msg, size_t len, int flags) |
682 | { | 659 | { |
683 | struct sock *sk = sock->sk; | ||
684 | struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name; | 660 | struct sockaddr_llc *uaddr = (struct sockaddr_llc *)msg->msg_name; |
685 | struct sk_buff *skb; | 661 | const int nonblock = flags & MSG_DONTWAIT; |
662 | struct sk_buff *skb = NULL; | ||
663 | struct sock *sk = sock->sk; | ||
664 | struct llc_sock *llc = llc_sk(sk); | ||
686 | size_t copied = 0; | 665 | size_t copied = 0; |
687 | int rc = -ENOMEM, timeout; | 666 | u32 peek_seq = 0; |
688 | int noblock = flags & MSG_DONTWAIT; | 667 | u32 *seq; |
668 | unsigned long used; | ||
669 | int target; /* Read at least this many bytes */ | ||
670 | long timeo; | ||
689 | 671 | ||
690 | dprintk("%s: receiving in %02X from %02X\n", __FUNCTION__, | ||
691 | llc_sk(sk)->laddr.lsap, llc_sk(sk)->daddr.lsap); | ||
692 | lock_sock(sk); | 672 | lock_sock(sk); |
693 | timeout = sock_rcvtimeo(sk, noblock); | 673 | copied = -ENOTCONN; |
694 | rc = llc_ui_wait_for_data(sk, timeout); | 674 | if (sk->sk_state == TCP_LISTEN) |
695 | if (rc) { | ||
696 | dprintk("%s: llc_ui_wait_for_data failed recv " | ||
697 | "in %02X from %02X\n", __FUNCTION__, | ||
698 | llc_sk(sk)->laddr.lsap, llc_sk(sk)->daddr.lsap); | ||
699 | goto out; | 675 | goto out; |
700 | } | 676 | |
701 | skb = skb_dequeue(&sk->sk_receive_queue); | 677 | timeo = sock_rcvtimeo(sk, nonblock); |
702 | if (!skb) /* shutdown */ | 678 | |
703 | goto out; | 679 | seq = &llc->copied_seq; |
704 | copied = skb->len; | 680 | if (flags & MSG_PEEK) { |
705 | if (copied > size) | 681 | peek_seq = llc->copied_seq; |
706 | copied = size; | 682 | seq = &peek_seq; |
707 | rc = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied); | 683 | } |
708 | if (rc) | 684 | |
709 | goto dgram_free; | 685 | target = sock_rcvlowat(sk, flags & MSG_WAITALL, len); |
710 | if (skb->len > copied) { | 686 | copied = 0; |
711 | skb_pull(skb, copied); | 687 | |
712 | skb_queue_head(&sk->sk_receive_queue, skb); | 688 | do { |
713 | } | 689 | u32 offset; |
714 | if (uaddr) | 690 | |
715 | memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr)); | 691 | /* |
716 | msg->msg_namelen = sizeof(*uaddr); | 692 | * We need to check signals first, to get correct SIGURG |
717 | if (!skb->next) { | 693 | * handling. FIXME: Need to check this doesn't impact 1003.1g |
718 | dgram_free: | 694 | * and move it down to the bottom of the loop |
719 | kfree_skb(skb); | 695 | */ |
720 | } | 696 | if (signal_pending(current)) { |
697 | if (copied) | ||
698 | break; | ||
699 | copied = timeo ? sock_intr_errno(timeo) : -EAGAIN; | ||
700 | break; | ||
701 | } | ||
702 | |||
703 | /* Next get a buffer. */ | ||
704 | |||
705 | skb = skb_peek(&sk->sk_receive_queue); | ||
706 | if (skb) { | ||
707 | offset = *seq; | ||
708 | goto found_ok_skb; | ||
709 | } | ||
710 | /* Well, if we have backlog, try to process it now yet. */ | ||
711 | |||
712 | if (copied >= target && !sk->sk_backlog.tail) | ||
713 | break; | ||
714 | |||
715 | if (copied) { | ||
716 | if (sk->sk_err || | ||
717 | sk->sk_state == TCP_CLOSE || | ||
718 | (sk->sk_shutdown & RCV_SHUTDOWN) || | ||
719 | !timeo || | ||
720 | (flags & MSG_PEEK)) | ||
721 | break; | ||
722 | } else { | ||
723 | if (sock_flag(sk, SOCK_DONE)) | ||
724 | break; | ||
725 | |||
726 | if (sk->sk_err) { | ||
727 | copied = sock_error(sk); | ||
728 | break; | ||
729 | } | ||
730 | if (sk->sk_shutdown & RCV_SHUTDOWN) | ||
731 | break; | ||
732 | |||
733 | if (sk->sk_state == TCP_CLOSE) { | ||
734 | if (!sock_flag(sk, SOCK_DONE)) { | ||
735 | /* | ||
736 | * This occurs when user tries to read | ||
737 | * from never connected socket. | ||
738 | */ | ||
739 | copied = -ENOTCONN; | ||
740 | break; | ||
741 | } | ||
742 | break; | ||
743 | } | ||
744 | if (!timeo) { | ||
745 | copied = -EAGAIN; | ||
746 | break; | ||
747 | } | ||
748 | } | ||
749 | |||
750 | if (copied >= target) { /* Do not sleep, just process backlog. */ | ||
751 | release_sock(sk); | ||
752 | lock_sock(sk); | ||
753 | } else | ||
754 | sk_wait_data(sk, &timeo); | ||
755 | |||
756 | if ((flags & MSG_PEEK) && peek_seq != llc->copied_seq) { | ||
757 | if (net_ratelimit()) | ||
758 | printk(KERN_DEBUG "LLC(%s:%d): Application " | ||
759 | "bug, race in MSG_PEEK.\n", | ||
760 | current->comm, current->pid); | ||
761 | peek_seq = llc->copied_seq; | ||
762 | } | ||
763 | continue; | ||
764 | found_ok_skb: | ||
765 | /* Ok so how much can we use? */ | ||
766 | used = skb->len - offset; | ||
767 | if (len < used) | ||
768 | used = len; | ||
769 | |||
770 | if (!(flags & MSG_TRUNC)) { | ||
771 | int rc = skb_copy_datagram_iovec(skb, offset, | ||
772 | msg->msg_iov, used); | ||
773 | if (rc) { | ||
774 | /* Exception. Bailout! */ | ||
775 | if (!copied) | ||
776 | copied = -EFAULT; | ||
777 | break; | ||
778 | } | ||
779 | } | ||
780 | |||
781 | *seq += used; | ||
782 | copied += used; | ||
783 | len -= used; | ||
784 | |||
785 | if (used + offset < skb->len) | ||
786 | continue; | ||
787 | |||
788 | if (!(flags & MSG_PEEK)) { | ||
789 | sk_eat_skb(sk, skb); | ||
790 | *seq = 0; | ||
791 | } | ||
792 | } while (len > 0); | ||
793 | |||
794 | /* | ||
795 | * According to UNIX98, msg_name/msg_namelen are ignored | ||
796 | * on connected socket. -ANK | ||
797 | * But... af_llc still doesn't have separate sets of methods for | ||
798 | * SOCK_DGRAM and SOCK_STREAM :-( So we have to do this test, will | ||
799 | * eventually fix this tho :-) -acme | ||
800 | */ | ||
801 | if (sk->sk_type == SOCK_DGRAM) | ||
802 | goto copy_uaddr; | ||
721 | out: | 803 | out: |
722 | release_sock(sk); | 804 | release_sock(sk); |
723 | return rc ? : copied; | 805 | return copied; |
806 | copy_uaddr: | ||
807 | if (uaddr != NULL && skb != NULL) { | ||
808 | memcpy(uaddr, llc_ui_skb_cb(skb), sizeof(*uaddr)); | ||
809 | msg->msg_namelen = sizeof(*uaddr); | ||
810 | } | ||
811 | goto out; | ||
724 | } | 812 | } |
725 | 813 | ||
726 | /** | 814 | /** |
@@ -740,7 +828,6 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
740 | struct sockaddr_llc *addr = (struct sockaddr_llc *)msg->msg_name; | 828 | struct sockaddr_llc *addr = (struct sockaddr_llc *)msg->msg_name; |
741 | int flags = msg->msg_flags; | 829 | int flags = msg->msg_flags; |
742 | int noblock = flags & MSG_DONTWAIT; | 830 | int noblock = flags & MSG_DONTWAIT; |
743 | struct net_device *dev; | ||
744 | struct sk_buff *skb; | 831 | struct sk_buff *skb; |
745 | size_t size = 0; | 832 | size_t size = 0; |
746 | int rc = -EINVAL, copied = 0, hdrlen; | 833 | int rc = -EINVAL, copied = 0, hdrlen; |
@@ -763,19 +850,17 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
763 | if (rc) | 850 | if (rc) |
764 | goto release; | 851 | goto release; |
765 | } | 852 | } |
766 | dev = llc->dev; | 853 | hdrlen = llc->dev->hard_header_len + llc_ui_header_len(sk, addr); |
767 | hdrlen = dev->hard_header_len + llc_ui_header_len(sk, addr); | ||
768 | size = hdrlen + len; | 854 | size = hdrlen + len; |
769 | if (size > dev->mtu) | 855 | if (size > llc->dev->mtu) |
770 | size = dev->mtu; | 856 | size = llc->dev->mtu; |
771 | copied = size - hdrlen; | 857 | copied = size - hdrlen; |
772 | release_sock(sk); | 858 | release_sock(sk); |
773 | skb = sock_alloc_send_skb(sk, size, noblock, &rc); | 859 | skb = sock_alloc_send_skb(sk, size, noblock, &rc); |
774 | lock_sock(sk); | 860 | lock_sock(sk); |
775 | if (!skb) | 861 | if (!skb) |
776 | goto release; | 862 | goto release; |
777 | skb->sk = sk; | 863 | skb->dev = llc->dev; |
778 | skb->dev = dev; | ||
779 | skb->protocol = llc_proto_type(addr->sllc_arphrd); | 864 | skb->protocol = llc_proto_type(addr->sllc_arphrd); |
780 | skb_reserve(skb, hdrlen); | 865 | skb_reserve(skb, hdrlen); |
781 | rc = memcpy_fromiovec(skb_put(skb, copied), msg->msg_iov, copied); | 866 | rc = memcpy_fromiovec(skb_put(skb, copied), msg->msg_iov, copied); |
@@ -800,15 +885,13 @@ static int llc_ui_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
800 | if (!(sk->sk_type == SOCK_STREAM && !addr->sllc_ua)) | 885 | if (!(sk->sk_type == SOCK_STREAM && !addr->sllc_ua)) |
801 | goto out; | 886 | goto out; |
802 | rc = llc_ui_send_data(sk, skb, noblock); | 887 | rc = llc_ui_send_data(sk, skb, noblock); |
803 | if (rc) | ||
804 | dprintk("%s: llc_ui_send_data failed: %d\n", __FUNCTION__, rc); | ||
805 | out: | 888 | out: |
806 | if (rc) | 889 | if (rc) { |
807 | kfree_skb(skb); | 890 | kfree_skb(skb); |
808 | release: | 891 | release: |
809 | if (rc) | ||
810 | dprintk("%s: failed sending from %02X to %02X: %d\n", | 892 | dprintk("%s: failed sending from %02X to %02X: %d\n", |
811 | __FUNCTION__, llc->laddr.lsap, llc->daddr.lsap, rc); | 893 | __FUNCTION__, llc->laddr.lsap, llc->daddr.lsap, rc); |
894 | } | ||
812 | release_sock(sk); | 895 | release_sock(sk); |
813 | return rc ? : copied; | 896 | return rc ? : copied; |
814 | } | 897 | } |
@@ -895,7 +978,7 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname, | |||
895 | int rc = -EINVAL, opt; | 978 | int rc = -EINVAL, opt; |
896 | 979 | ||
897 | lock_sock(sk); | 980 | lock_sock(sk); |
898 | if (level != SOL_LLC || optlen != sizeof(int)) | 981 | if (unlikely(level != SOL_LLC || optlen != sizeof(int))) |
899 | goto out; | 982 | goto out; |
900 | rc = get_user(opt, (int __user *)optval); | 983 | rc = get_user(opt, (int __user *)optval); |
901 | if (rc) | 984 | if (rc) |
@@ -915,22 +998,22 @@ static int llc_ui_setsockopt(struct socket *sock, int level, int optname, | |||
915 | case LLC_OPT_ACK_TMR_EXP: | 998 | case LLC_OPT_ACK_TMR_EXP: |
916 | if (opt > LLC_OPT_MAX_ACK_TMR_EXP) | 999 | if (opt > LLC_OPT_MAX_ACK_TMR_EXP) |
917 | goto out; | 1000 | goto out; |
918 | llc->ack_timer.expire = opt; | 1001 | llc->ack_timer.expire = opt * HZ; |
919 | break; | 1002 | break; |
920 | case LLC_OPT_P_TMR_EXP: | 1003 | case LLC_OPT_P_TMR_EXP: |
921 | if (opt > LLC_OPT_MAX_P_TMR_EXP) | 1004 | if (opt > LLC_OPT_MAX_P_TMR_EXP) |
922 | goto out; | 1005 | goto out; |
923 | llc->pf_cycle_timer.expire = opt; | 1006 | llc->pf_cycle_timer.expire = opt * HZ; |
924 | break; | 1007 | break; |
925 | case LLC_OPT_REJ_TMR_EXP: | 1008 | case LLC_OPT_REJ_TMR_EXP: |
926 | if (opt > LLC_OPT_MAX_REJ_TMR_EXP) | 1009 | if (opt > LLC_OPT_MAX_REJ_TMR_EXP) |
927 | goto out; | 1010 | goto out; |
928 | llc->rej_sent_timer.expire = opt; | 1011 | llc->rej_sent_timer.expire = opt * HZ; |
929 | break; | 1012 | break; |
930 | case LLC_OPT_BUSY_TMR_EXP: | 1013 | case LLC_OPT_BUSY_TMR_EXP: |
931 | if (opt > LLC_OPT_MAX_BUSY_TMR_EXP) | 1014 | if (opt > LLC_OPT_MAX_BUSY_TMR_EXP) |
932 | goto out; | 1015 | goto out; |
933 | llc->busy_state_timer.expire = opt; | 1016 | llc->busy_state_timer.expire = opt * HZ; |
934 | break; | 1017 | break; |
935 | case LLC_OPT_TX_WIN: | 1018 | case LLC_OPT_TX_WIN: |
936 | if (opt > LLC_OPT_MAX_WIN) | 1019 | if (opt > LLC_OPT_MAX_WIN) |
@@ -970,7 +1053,7 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname, | |||
970 | int val = 0, len = 0, rc = -EINVAL; | 1053 | int val = 0, len = 0, rc = -EINVAL; |
971 | 1054 | ||
972 | lock_sock(sk); | 1055 | lock_sock(sk); |
973 | if (level != SOL_LLC) | 1056 | if (unlikely(level != SOL_LLC)) |
974 | goto out; | 1057 | goto out; |
975 | rc = get_user(len, optlen); | 1058 | rc = get_user(len, optlen); |
976 | if (rc) | 1059 | if (rc) |
@@ -980,17 +1063,17 @@ static int llc_ui_getsockopt(struct socket *sock, int level, int optname, | |||
980 | goto out; | 1063 | goto out; |
981 | switch (optname) { | 1064 | switch (optname) { |
982 | case LLC_OPT_RETRY: | 1065 | case LLC_OPT_RETRY: |
983 | val = llc->n2; break; | 1066 | val = llc->n2; break; |
984 | case LLC_OPT_SIZE: | 1067 | case LLC_OPT_SIZE: |
985 | val = llc->n1; break; | 1068 | val = llc->n1; break; |
986 | case LLC_OPT_ACK_TMR_EXP: | 1069 | case LLC_OPT_ACK_TMR_EXP: |
987 | val = llc->ack_timer.expire; break; | 1070 | val = llc->ack_timer.expire / HZ; break; |
988 | case LLC_OPT_P_TMR_EXP: | 1071 | case LLC_OPT_P_TMR_EXP: |
989 | val = llc->pf_cycle_timer.expire; break; | 1072 | val = llc->pf_cycle_timer.expire / HZ; break; |
990 | case LLC_OPT_REJ_TMR_EXP: | 1073 | case LLC_OPT_REJ_TMR_EXP: |
991 | val = llc->rej_sent_timer.expire; break; | 1074 | val = llc->rej_sent_timer.expire / HZ; break; |
992 | case LLC_OPT_BUSY_TMR_EXP: | 1075 | case LLC_OPT_BUSY_TMR_EXP: |
993 | val = llc->busy_state_timer.expire; break; | 1076 | val = llc->busy_state_timer.expire / HZ; break; |
994 | case LLC_OPT_TX_WIN: | 1077 | case LLC_OPT_TX_WIN: |
995 | val = llc->k; break; | 1078 | val = llc->k; break; |
996 | case LLC_OPT_RX_WIN: | 1079 | case LLC_OPT_RX_WIN: |
@@ -1034,8 +1117,12 @@ static struct proto_ops llc_ui_ops = { | |||
1034 | .sendpage = sock_no_sendpage, | 1117 | .sendpage = sock_no_sendpage, |
1035 | }; | 1118 | }; |
1036 | 1119 | ||
1037 | extern void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb); | 1120 | static char llc_proc_err_msg[] __initdata = |
1038 | extern void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb); | 1121 | KERN_CRIT "LLC: Unable to register the proc_fs entries\n"; |
1122 | static char llc_sysctl_err_msg[] __initdata = | ||
1123 | KERN_CRIT "LLC: Unable to register the sysctl entries\n"; | ||
1124 | static char llc_sock_err_msg[] __initdata = | ||
1125 | KERN_CRIT "LLC: Unable to register the network family\n"; | ||
1039 | 1126 | ||
1040 | static int __init llc2_init(void) | 1127 | static int __init llc2_init(void) |
1041 | { | 1128 | { |
@@ -1048,13 +1135,28 @@ static int __init llc2_init(void) | |||
1048 | llc_station_init(); | 1135 | llc_station_init(); |
1049 | llc_ui_sap_last_autoport = LLC_SAP_DYN_START; | 1136 | llc_ui_sap_last_autoport = LLC_SAP_DYN_START; |
1050 | rc = llc_proc_init(); | 1137 | rc = llc_proc_init(); |
1051 | if (rc != 0) | 1138 | if (rc != 0) { |
1139 | printk(llc_proc_err_msg); | ||
1052 | goto out_unregister_llc_proto; | 1140 | goto out_unregister_llc_proto; |
1053 | sock_register(&llc_ui_family_ops); | 1141 | } |
1142 | rc = llc_sysctl_init(); | ||
1143 | if (rc) { | ||
1144 | printk(llc_sysctl_err_msg); | ||
1145 | goto out_proc; | ||
1146 | } | ||
1147 | rc = sock_register(&llc_ui_family_ops); | ||
1148 | if (rc) { | ||
1149 | printk(llc_sock_err_msg); | ||
1150 | goto out_sysctl; | ||
1151 | } | ||
1054 | llc_add_pack(LLC_DEST_SAP, llc_sap_handler); | 1152 | llc_add_pack(LLC_DEST_SAP, llc_sap_handler); |
1055 | llc_add_pack(LLC_DEST_CONN, llc_conn_handler); | 1153 | llc_add_pack(LLC_DEST_CONN, llc_conn_handler); |
1056 | out: | 1154 | out: |
1057 | return rc; | 1155 | return rc; |
1156 | out_sysctl: | ||
1157 | llc_sysctl_exit(); | ||
1158 | out_proc: | ||
1159 | llc_proc_exit(); | ||
1058 | out_unregister_llc_proto: | 1160 | out_unregister_llc_proto: |
1059 | proto_unregister(&llc_proto); | 1161 | proto_unregister(&llc_proto); |
1060 | goto out; | 1162 | goto out; |
@@ -1067,6 +1169,7 @@ static void __exit llc2_exit(void) | |||
1067 | llc_remove_pack(LLC_DEST_CONN); | 1169 | llc_remove_pack(LLC_DEST_CONN); |
1068 | sock_unregister(PF_LLC); | 1170 | sock_unregister(PF_LLC); |
1069 | llc_proc_exit(); | 1171 | llc_proc_exit(); |
1172 | llc_sysctl_exit(); | ||
1070 | proto_unregister(&llc_proto); | 1173 | proto_unregister(&llc_proto); |
1071 | } | 1174 | } |
1072 | 1175 | ||
diff --git a/net/llc/llc_c_ac.c b/net/llc/llc_c_ac.c index b218be4c10ec..b0bcfb1f12dd 100644 --- a/net/llc/llc_c_ac.c +++ b/net/llc/llc_c_ac.c | |||
@@ -60,23 +60,10 @@ int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb) | |||
60 | 60 | ||
61 | int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb) | 61 | int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb) |
62 | { | 62 | { |
63 | int rc = -ENOTCONN; | 63 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
64 | u8 dsap; | ||
65 | struct llc_sap *sap; | ||
66 | |||
67 | llc_pdu_decode_dsap(skb, &dsap); | ||
68 | sap = llc_sap_find(dsap); | ||
69 | if (sap) { | ||
70 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | ||
71 | struct llc_sock *llc = llc_sk(sk); | ||
72 | 64 | ||
73 | llc_pdu_decode_sa(skb, llc->daddr.mac); | 65 | ev->ind_prim = LLC_CONN_PRIM; |
74 | llc_pdu_decode_da(skb, llc->laddr.mac); | 66 | return 0; |
75 | llc->dev = skb->dev; | ||
76 | ev->ind_prim = LLC_CONN_PRIM; | ||
77 | rc = 0; | ||
78 | } | ||
79 | return rc; | ||
80 | } | 67 | } |
81 | 68 | ||
82 | int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb) | 69 | int llc_conn_ac_conn_confirm(struct sock *sk, struct sk_buff *skb) |
@@ -120,10 +107,8 @@ int llc_conn_ac_disc_ind(struct sock *sk, struct sk_buff *skb) | |||
120 | reason = LLC_DISC_REASON_RX_DISC_CMD_PDU; | 107 | reason = LLC_DISC_REASON_RX_DISC_CMD_PDU; |
121 | } else if (ev->type == LLC_CONN_EV_TYPE_ACK_TMR) | 108 | } else if (ev->type == LLC_CONN_EV_TYPE_ACK_TMR) |
122 | reason = LLC_DISC_REASON_ACK_TMR_EXP; | 109 | reason = LLC_DISC_REASON_ACK_TMR_EXP; |
123 | else { | 110 | else |
124 | reason = 0; | ||
125 | rc = -EINVAL; | 111 | rc = -EINVAL; |
126 | } | ||
127 | if (!rc) { | 112 | if (!rc) { |
128 | ev->reason = reason; | 113 | ev->reason = reason; |
129 | ev->ind_prim = LLC_DISC_PRIM; | 114 | ev->ind_prim = LLC_DISC_PRIM; |
@@ -160,9 +145,6 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb) | |||
160 | LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME) { | 145 | LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME) { |
161 | reason = LLC_RESET_REASON_REMOTE; | 146 | reason = LLC_RESET_REASON_REMOTE; |
162 | rc = 0; | 147 | rc = 0; |
163 | } else { | ||
164 | reason = 0; | ||
165 | rc = 1; | ||
166 | } | 148 | } |
167 | break; | 149 | break; |
168 | case LLC_CONN_EV_TYPE_ACK_TMR: | 150 | case LLC_CONN_EV_TYPE_ACK_TMR: |
@@ -172,8 +154,7 @@ int llc_conn_ac_rst_ind(struct sock *sk, struct sk_buff *skb) | |||
172 | if (llc->retry_count > llc->n2) { | 154 | if (llc->retry_count > llc->n2) { |
173 | reason = LLC_RESET_REASON_LOCAL; | 155 | reason = LLC_RESET_REASON_LOCAL; |
174 | rc = 0; | 156 | rc = 0; |
175 | } else | 157 | } |
176 | rc = 1; | ||
177 | break; | 158 | break; |
178 | } | 159 | } |
179 | if (!rc) { | 160 | if (!rc) { |
@@ -217,18 +198,17 @@ int llc_conn_ac_stop_rej_tmr_if_data_flag_eq_2(struct sock *sk, | |||
217 | int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) | 198 | int llc_conn_ac_send_disc_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) |
218 | { | 199 | { |
219 | int rc = -ENOBUFS; | 200 | int rc = -ENOBUFS; |
220 | struct sk_buff *nskb = llc_alloc_frame(); | 201 | struct llc_sock *llc = llc_sk(sk); |
202 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
221 | 203 | ||
222 | if (nskb) { | 204 | if (nskb) { |
223 | struct llc_sock *llc = llc_sk(sk); | ||
224 | struct llc_sap *sap = llc->sap; | 205 | struct llc_sap *sap = llc->sap; |
225 | 206 | ||
226 | nskb->dev = llc->dev; | ||
227 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, | 207 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, |
228 | llc->daddr.lsap, LLC_PDU_CMD); | 208 | llc->daddr.lsap, LLC_PDU_CMD); |
229 | llc_pdu_init_as_disc_cmd(nskb, 1); | 209 | llc_pdu_init_as_disc_cmd(nskb, 1); |
230 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 210 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
231 | if (rc) | 211 | if (unlikely(rc)) |
232 | goto free; | 212 | goto free; |
233 | llc_conn_send_pdu(sk, nskb); | 213 | llc_conn_send_pdu(sk, nskb); |
234 | llc_conn_ac_set_p_flag_1(sk, skb); | 214 | llc_conn_ac_set_p_flag_1(sk, skb); |
@@ -243,20 +223,19 @@ free: | |||
243 | int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) | 223 | int llc_conn_ac_send_dm_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) |
244 | { | 224 | { |
245 | int rc = -ENOBUFS; | 225 | int rc = -ENOBUFS; |
246 | struct sk_buff *nskb = llc_alloc_frame(); | 226 | struct llc_sock *llc = llc_sk(sk); |
227 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
247 | 228 | ||
248 | if (nskb) { | 229 | if (nskb) { |
249 | struct llc_sock *llc = llc_sk(sk); | ||
250 | struct llc_sap *sap = llc->sap; | 230 | struct llc_sap *sap = llc->sap; |
251 | u8 f_bit; | 231 | u8 f_bit; |
252 | 232 | ||
253 | nskb->dev = llc->dev; | ||
254 | llc_pdu_decode_pf_bit(skb, &f_bit); | 233 | llc_pdu_decode_pf_bit(skb, &f_bit); |
255 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, | 234 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, |
256 | llc->daddr.lsap, LLC_PDU_RSP); | 235 | llc->daddr.lsap, LLC_PDU_RSP); |
257 | llc_pdu_init_as_dm_rsp(nskb, f_bit); | 236 | llc_pdu_init_as_dm_rsp(nskb, f_bit); |
258 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 237 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
259 | if (rc) | 238 | if (unlikely(rc)) |
260 | goto free; | 239 | goto free; |
261 | llc_conn_send_pdu(sk, nskb); | 240 | llc_conn_send_pdu(sk, nskb); |
262 | } | 241 | } |
@@ -270,19 +249,17 @@ free: | |||
270 | int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) | 249 | int llc_conn_ac_send_dm_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) |
271 | { | 250 | { |
272 | int rc = -ENOBUFS; | 251 | int rc = -ENOBUFS; |
273 | struct sk_buff *nskb = llc_alloc_frame(); | 252 | struct llc_sock *llc = llc_sk(sk); |
253 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
274 | 254 | ||
275 | if (nskb) { | 255 | if (nskb) { |
276 | struct llc_sock *llc = llc_sk(sk); | ||
277 | struct llc_sap *sap = llc->sap; | 256 | struct llc_sap *sap = llc->sap; |
278 | u8 f_bit = 1; | ||
279 | 257 | ||
280 | nskb->dev = llc->dev; | ||
281 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, | 258 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, |
282 | llc->daddr.lsap, LLC_PDU_RSP); | 259 | llc->daddr.lsap, LLC_PDU_RSP); |
283 | llc_pdu_init_as_dm_rsp(nskb, f_bit); | 260 | llc_pdu_init_as_dm_rsp(nskb, 1); |
284 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 261 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
285 | if (rc) | 262 | if (unlikely(rc)) |
286 | goto free; | 263 | goto free; |
287 | llc_conn_send_pdu(sk, nskb); | 264 | llc_conn_send_pdu(sk, nskb); |
288 | } | 265 | } |
@@ -306,17 +283,16 @@ int llc_conn_ac_send_frmr_rsp_f_set_x(struct sock *sk, struct sk_buff *skb) | |||
306 | llc_pdu_decode_pf_bit(skb, &f_bit); | 283 | llc_pdu_decode_pf_bit(skb, &f_bit); |
307 | else | 284 | else |
308 | f_bit = 0; | 285 | f_bit = 0; |
309 | nskb = llc_alloc_frame(); | 286 | nskb = llc_alloc_frame(sk, llc->dev); |
310 | if (nskb) { | 287 | if (nskb) { |
311 | struct llc_sap *sap = llc->sap; | 288 | struct llc_sap *sap = llc->sap; |
312 | 289 | ||
313 | nskb->dev = llc->dev; | ||
314 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, | 290 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, |
315 | llc->daddr.lsap, LLC_PDU_RSP); | 291 | llc->daddr.lsap, LLC_PDU_RSP); |
316 | llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS, | 292 | llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS, |
317 | llc->vR, INCORRECT); | 293 | llc->vR, INCORRECT); |
318 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 294 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
319 | if (rc) | 295 | if (unlikely(rc)) |
320 | goto free; | 296 | goto free; |
321 | llc_conn_send_pdu(sk, nskb); | 297 | llc_conn_send_pdu(sk, nskb); |
322 | } | 298 | } |
@@ -330,21 +306,19 @@ free: | |||
330 | int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb) | 306 | int llc_conn_ac_resend_frmr_rsp_f_set_0(struct sock *sk, struct sk_buff *skb) |
331 | { | 307 | { |
332 | int rc = -ENOBUFS; | 308 | int rc = -ENOBUFS; |
333 | struct sk_buff *nskb = llc_alloc_frame(); | 309 | struct llc_sock *llc = llc_sk(sk); |
310 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
334 | 311 | ||
335 | if (nskb) { | 312 | if (nskb) { |
336 | u8 f_bit = 0; | ||
337 | struct llc_sock *llc = llc_sk(sk); | ||
338 | struct llc_sap *sap = llc->sap; | 313 | struct llc_sap *sap = llc->sap; |
339 | struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr; | 314 | struct llc_pdu_sn *pdu = (struct llc_pdu_sn *)&llc->rx_pdu_hdr; |
340 | 315 | ||
341 | nskb->dev = llc->dev; | ||
342 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, | 316 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, |
343 | llc->daddr.lsap, LLC_PDU_RSP); | 317 | llc->daddr.lsap, LLC_PDU_RSP); |
344 | llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS, | 318 | llc_pdu_init_as_frmr_rsp(nskb, pdu, 0, llc->vS, |
345 | llc->vR, INCORRECT); | 319 | llc->vR, INCORRECT); |
346 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 320 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
347 | if (rc) | 321 | if (unlikely(rc)) |
348 | goto free; | 322 | goto free; |
349 | llc_conn_send_pdu(sk, nskb); | 323 | llc_conn_send_pdu(sk, nskb); |
350 | } | 324 | } |
@@ -360,21 +334,20 @@ int llc_conn_ac_resend_frmr_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) | |||
360 | u8 f_bit; | 334 | u8 f_bit; |
361 | int rc = -ENOBUFS; | 335 | int rc = -ENOBUFS; |
362 | struct sk_buff *nskb; | 336 | struct sk_buff *nskb; |
337 | struct llc_sock *llc = llc_sk(sk); | ||
363 | 338 | ||
364 | llc_pdu_decode_pf_bit(skb, &f_bit); | 339 | llc_pdu_decode_pf_bit(skb, &f_bit); |
365 | nskb = llc_alloc_frame(); | 340 | nskb = llc_alloc_frame(sk, llc->dev); |
366 | if (nskb) { | 341 | if (nskb) { |
367 | struct llc_sock *llc = llc_sk(sk); | ||
368 | struct llc_sap *sap = llc->sap; | 342 | struct llc_sap *sap = llc->sap; |
369 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 343 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
370 | 344 | ||
371 | nskb->dev = llc->dev; | ||
372 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, | 345 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, |
373 | llc->daddr.lsap, LLC_PDU_RSP); | 346 | llc->daddr.lsap, LLC_PDU_RSP); |
374 | llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS, | 347 | llc_pdu_init_as_frmr_rsp(nskb, pdu, f_bit, llc->vS, |
375 | llc->vR, INCORRECT); | 348 | llc->vR, INCORRECT); |
376 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 349 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
377 | if (rc) | 350 | if (unlikely(rc)) |
378 | goto free; | 351 | goto free; |
379 | llc_conn_send_pdu(sk, nskb); | 352 | llc_conn_send_pdu(sk, nskb); |
380 | } | 353 | } |
@@ -395,7 +368,7 @@ int llc_conn_ac_send_i_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) | |||
395 | llc->daddr.lsap, LLC_PDU_CMD); | 368 | llc->daddr.lsap, LLC_PDU_CMD); |
396 | llc_pdu_init_as_i_cmd(skb, 1, llc->vS, llc->vR); | 369 | llc_pdu_init_as_i_cmd(skb, 1, llc->vS, llc->vR); |
397 | rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); | 370 | rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); |
398 | if (!rc) { | 371 | if (likely(!rc)) { |
399 | llc_conn_send_pdu(sk, skb); | 372 | llc_conn_send_pdu(sk, skb); |
400 | llc_conn_ac_inc_vs_by_1(sk, skb); | 373 | llc_conn_ac_inc_vs_by_1(sk, skb); |
401 | } | 374 | } |
@@ -412,7 +385,7 @@ static int llc_conn_ac_send_i_cmd_p_set_0(struct sock *sk, struct sk_buff *skb) | |||
412 | llc->daddr.lsap, LLC_PDU_CMD); | 385 | llc->daddr.lsap, LLC_PDU_CMD); |
413 | llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR); | 386 | llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR); |
414 | rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); | 387 | rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); |
415 | if (!rc) { | 388 | if (likely(!rc)) { |
416 | llc_conn_send_pdu(sk, skb); | 389 | llc_conn_send_pdu(sk, skb); |
417 | llc_conn_ac_inc_vs_by_1(sk, skb); | 390 | llc_conn_ac_inc_vs_by_1(sk, skb); |
418 | } | 391 | } |
@@ -429,7 +402,7 @@ int llc_conn_ac_send_i_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) | |||
429 | llc->daddr.lsap, LLC_PDU_CMD); | 402 | llc->daddr.lsap, LLC_PDU_CMD); |
430 | llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR); | 403 | llc_pdu_init_as_i_cmd(skb, 0, llc->vS, llc->vR); |
431 | rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); | 404 | rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); |
432 | if (!rc) { | 405 | if (likely(!rc)) { |
433 | llc_conn_send_pdu(sk, skb); | 406 | llc_conn_send_pdu(sk, skb); |
434 | llc_conn_ac_inc_vs_by_1(sk, skb); | 407 | llc_conn_ac_inc_vs_by_1(sk, skb); |
435 | } | 408 | } |
@@ -451,18 +424,17 @@ int llc_conn_ac_resend_i_xxx_x_set_0_or_send_rr(struct sock *sk, | |||
451 | u8 nr; | 424 | u8 nr; |
452 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 425 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
453 | int rc = -ENOBUFS; | 426 | int rc = -ENOBUFS; |
454 | struct sk_buff *nskb = llc_alloc_frame(); | 427 | struct llc_sock *llc = llc_sk(sk); |
428 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
455 | 429 | ||
456 | if (nskb) { | 430 | if (nskb) { |
457 | struct llc_sock *llc = llc_sk(sk); | ||
458 | struct llc_sap *sap = llc->sap; | 431 | struct llc_sap *sap = llc->sap; |
459 | 432 | ||
460 | nskb->dev = llc->dev; | ||
461 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, | 433 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, |
462 | llc->daddr.lsap, LLC_PDU_RSP); | 434 | llc->daddr.lsap, LLC_PDU_RSP); |
463 | llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); | 435 | llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); |
464 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 436 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
465 | if (!rc) | 437 | if (likely(!rc)) |
466 | llc_conn_send_pdu(sk, nskb); | 438 | llc_conn_send_pdu(sk, nskb); |
467 | else | 439 | else |
468 | kfree_skb(skb); | 440 | kfree_skb(skb); |
@@ -487,18 +459,17 @@ int llc_conn_ac_resend_i_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) | |||
487 | int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) | 459 | int llc_conn_ac_send_rej_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) |
488 | { | 460 | { |
489 | int rc = -ENOBUFS; | 461 | int rc = -ENOBUFS; |
490 | struct sk_buff *nskb = llc_alloc_frame(); | 462 | struct llc_sock *llc = llc_sk(sk); |
463 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
491 | 464 | ||
492 | if (nskb) { | 465 | if (nskb) { |
493 | struct llc_sock *llc = llc_sk(sk); | ||
494 | struct llc_sap *sap = llc->sap; | 466 | struct llc_sap *sap = llc->sap; |
495 | 467 | ||
496 | nskb->dev = llc->dev; | ||
497 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 468 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
498 | llc->daddr.lsap, LLC_PDU_CMD); | 469 | llc->daddr.lsap, LLC_PDU_CMD); |
499 | llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR); | 470 | llc_pdu_init_as_rej_cmd(nskb, 1, llc->vR); |
500 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 471 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
501 | if (rc) | 472 | if (unlikely(rc)) |
502 | goto free; | 473 | goto free; |
503 | llc_conn_send_pdu(sk, nskb); | 474 | llc_conn_send_pdu(sk, nskb); |
504 | } | 475 | } |
@@ -512,19 +483,17 @@ free: | |||
512 | int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) | 483 | int llc_conn_ac_send_rej_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) |
513 | { | 484 | { |
514 | int rc = -ENOBUFS; | 485 | int rc = -ENOBUFS; |
515 | struct sk_buff *nskb = llc_alloc_frame(); | 486 | struct llc_sock *llc = llc_sk(sk); |
487 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
516 | 488 | ||
517 | if (nskb) { | 489 | if (nskb) { |
518 | u8 f_bit = 1; | ||
519 | struct llc_sock *llc = llc_sk(sk); | ||
520 | struct llc_sap *sap = llc->sap; | 490 | struct llc_sap *sap = llc->sap; |
521 | 491 | ||
522 | nskb->dev = llc->dev; | ||
523 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 492 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
524 | llc->daddr.lsap, LLC_PDU_RSP); | 493 | llc->daddr.lsap, LLC_PDU_RSP); |
525 | llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR); | 494 | llc_pdu_init_as_rej_rsp(nskb, 1, llc->vR); |
526 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 495 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
527 | if (rc) | 496 | if (unlikely(rc)) |
528 | goto free; | 497 | goto free; |
529 | llc_conn_send_pdu(sk, nskb); | 498 | llc_conn_send_pdu(sk, nskb); |
530 | } | 499 | } |
@@ -538,19 +507,17 @@ free: | |||
538 | int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) | 507 | int llc_conn_ac_send_rej_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) |
539 | { | 508 | { |
540 | int rc = -ENOBUFS; | 509 | int rc = -ENOBUFS; |
541 | struct sk_buff *nskb = llc_alloc_frame(); | 510 | struct llc_sock *llc = llc_sk(sk); |
511 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
542 | 512 | ||
543 | if (nskb) { | 513 | if (nskb) { |
544 | struct llc_sock *llc = llc_sk(sk); | ||
545 | struct llc_sap *sap = llc->sap; | 514 | struct llc_sap *sap = llc->sap; |
546 | u8 f_bit = 0; | ||
547 | 515 | ||
548 | nskb->dev = llc->dev; | ||
549 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 516 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
550 | llc->daddr.lsap, LLC_PDU_RSP); | 517 | llc->daddr.lsap, LLC_PDU_RSP); |
551 | llc_pdu_init_as_rej_rsp(nskb, f_bit, llc->vR); | 518 | llc_pdu_init_as_rej_rsp(nskb, 0, llc->vR); |
552 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 519 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
553 | if (rc) | 520 | if (unlikely(rc)) |
554 | goto free; | 521 | goto free; |
555 | llc_conn_send_pdu(sk, nskb); | 522 | llc_conn_send_pdu(sk, nskb); |
556 | } | 523 | } |
@@ -564,18 +531,17 @@ free: | |||
564 | int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) | 531 | int llc_conn_ac_send_rnr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) |
565 | { | 532 | { |
566 | int rc = -ENOBUFS; | 533 | int rc = -ENOBUFS; |
567 | struct sk_buff *nskb = llc_alloc_frame(); | 534 | struct llc_sock *llc = llc_sk(sk); |
535 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
568 | 536 | ||
569 | if (nskb) { | 537 | if (nskb) { |
570 | struct llc_sock *llc = llc_sk(sk); | ||
571 | struct llc_sap *sap = llc->sap; | 538 | struct llc_sap *sap = llc->sap; |
572 | 539 | ||
573 | nskb->dev = llc->dev; | ||
574 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 540 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
575 | llc->daddr.lsap, LLC_PDU_CMD); | 541 | llc->daddr.lsap, LLC_PDU_CMD); |
576 | llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR); | 542 | llc_pdu_init_as_rnr_cmd(nskb, 1, llc->vR); |
577 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 543 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
578 | if (rc) | 544 | if (unlikely(rc)) |
579 | goto free; | 545 | goto free; |
580 | llc_conn_send_pdu(sk, nskb); | 546 | llc_conn_send_pdu(sk, nskb); |
581 | } | 547 | } |
@@ -589,19 +555,17 @@ free: | |||
589 | int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) | 555 | int llc_conn_ac_send_rnr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) |
590 | { | 556 | { |
591 | int rc = -ENOBUFS; | 557 | int rc = -ENOBUFS; |
592 | struct sk_buff *nskb = llc_alloc_frame(); | 558 | struct llc_sock *llc = llc_sk(sk); |
559 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
593 | 560 | ||
594 | if (nskb) { | 561 | if (nskb) { |
595 | struct llc_sock *llc = llc_sk(sk); | ||
596 | struct llc_sap *sap = llc->sap; | 562 | struct llc_sap *sap = llc->sap; |
597 | u8 f_bit = 1; | ||
598 | 563 | ||
599 | nskb->dev = llc->dev; | ||
600 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 564 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
601 | llc->daddr.lsap, LLC_PDU_RSP); | 565 | llc->daddr.lsap, LLC_PDU_RSP); |
602 | llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR); | 566 | llc_pdu_init_as_rnr_rsp(nskb, 1, llc->vR); |
603 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 567 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
604 | if (rc) | 568 | if (unlikely(rc)) |
605 | goto free; | 569 | goto free; |
606 | llc_conn_send_pdu(sk, nskb); | 570 | llc_conn_send_pdu(sk, nskb); |
607 | } | 571 | } |
@@ -615,19 +579,17 @@ free: | |||
615 | int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) | 579 | int llc_conn_ac_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) |
616 | { | 580 | { |
617 | int rc = -ENOBUFS; | 581 | int rc = -ENOBUFS; |
618 | struct sk_buff *nskb = llc_alloc_frame(); | 582 | struct llc_sock *llc = llc_sk(sk); |
583 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
619 | 584 | ||
620 | if (nskb) { | 585 | if (nskb) { |
621 | u8 f_bit = 0; | ||
622 | struct llc_sock *llc = llc_sk(sk); | ||
623 | struct llc_sap *sap = llc->sap; | 586 | struct llc_sap *sap = llc->sap; |
624 | 587 | ||
625 | nskb->dev = llc->dev; | ||
626 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 588 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
627 | llc->daddr.lsap, LLC_PDU_RSP); | 589 | llc->daddr.lsap, LLC_PDU_RSP); |
628 | llc_pdu_init_as_rnr_rsp(nskb, f_bit, llc->vR); | 590 | llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR); |
629 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 591 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
630 | if (rc) | 592 | if (unlikely(rc)) |
631 | goto free; | 593 | goto free; |
632 | llc_conn_send_pdu(sk, nskb); | 594 | llc_conn_send_pdu(sk, nskb); |
633 | } | 595 | } |
@@ -645,7 +607,7 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb) | |||
645 | if (!llc->remote_busy_flag) { | 607 | if (!llc->remote_busy_flag) { |
646 | llc->remote_busy_flag = 1; | 608 | llc->remote_busy_flag = 1; |
647 | mod_timer(&llc->busy_state_timer.timer, | 609 | mod_timer(&llc->busy_state_timer.timer, |
648 | jiffies + llc->busy_state_timer.expire * HZ); | 610 | jiffies + llc->busy_state_timer.expire); |
649 | } | 611 | } |
650 | return 0; | 612 | return 0; |
651 | } | 613 | } |
@@ -653,18 +615,17 @@ int llc_conn_ac_set_remote_busy(struct sock *sk, struct sk_buff *skb) | |||
653 | int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) | 615 | int llc_conn_ac_opt_send_rnr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) |
654 | { | 616 | { |
655 | int rc = -ENOBUFS; | 617 | int rc = -ENOBUFS; |
656 | struct sk_buff *nskb = llc_alloc_frame(); | 618 | struct llc_sock *llc = llc_sk(sk); |
619 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
657 | 620 | ||
658 | if (nskb) { | 621 | if (nskb) { |
659 | struct llc_sock *llc = llc_sk(sk); | ||
660 | struct llc_sap *sap = llc->sap; | 622 | struct llc_sap *sap = llc->sap; |
661 | 623 | ||
662 | nskb->dev = llc->dev; | ||
663 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 624 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
664 | llc->daddr.lsap, LLC_PDU_RSP); | 625 | llc->daddr.lsap, LLC_PDU_RSP); |
665 | llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR); | 626 | llc_pdu_init_as_rnr_rsp(nskb, 0, llc->vR); |
666 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 627 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
667 | if (rc) | 628 | if (unlikely(rc)) |
668 | goto free; | 629 | goto free; |
669 | llc_conn_send_pdu(sk, nskb); | 630 | llc_conn_send_pdu(sk, nskb); |
670 | } | 631 | } |
@@ -678,18 +639,17 @@ free: | |||
678 | int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) | 639 | int llc_conn_ac_send_rr_cmd_p_set_1(struct sock *sk, struct sk_buff *skb) |
679 | { | 640 | { |
680 | int rc = -ENOBUFS; | 641 | int rc = -ENOBUFS; |
681 | struct sk_buff *nskb = llc_alloc_frame(); | 642 | struct llc_sock *llc = llc_sk(sk); |
643 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
682 | 644 | ||
683 | if (nskb) { | 645 | if (nskb) { |
684 | struct llc_sock *llc = llc_sk(sk); | ||
685 | struct llc_sap *sap = llc->sap; | 646 | struct llc_sap *sap = llc->sap; |
686 | 647 | ||
687 | nskb->dev = llc->dev; | ||
688 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 648 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
689 | llc->daddr.lsap, LLC_PDU_CMD); | 649 | llc->daddr.lsap, LLC_PDU_CMD); |
690 | llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR); | 650 | llc_pdu_init_as_rr_cmd(nskb, 1, llc->vR); |
691 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 651 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
692 | if (rc) | 652 | if (unlikely(rc)) |
693 | goto free; | 653 | goto free; |
694 | llc_conn_send_pdu(sk, nskb); | 654 | llc_conn_send_pdu(sk, nskb); |
695 | } | 655 | } |
@@ -703,19 +663,18 @@ free: | |||
703 | int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) | 663 | int llc_conn_ac_send_rr_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) |
704 | { | 664 | { |
705 | int rc = -ENOBUFS; | 665 | int rc = -ENOBUFS; |
706 | struct sk_buff *nskb = llc_alloc_frame(); | 666 | struct llc_sock *llc = llc_sk(sk); |
667 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
707 | 668 | ||
708 | if (nskb) { | 669 | if (nskb) { |
709 | struct llc_sock *llc = llc_sk(sk); | ||
710 | struct llc_sap *sap = llc->sap; | 670 | struct llc_sap *sap = llc->sap; |
711 | u8 f_bit = 1; | 671 | u8 f_bit = 1; |
712 | 672 | ||
713 | nskb->dev = llc->dev; | ||
714 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 673 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
715 | llc->daddr.lsap, LLC_PDU_RSP); | 674 | llc->daddr.lsap, LLC_PDU_RSP); |
716 | llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR); | 675 | llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR); |
717 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 676 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
718 | if (rc) | 677 | if (unlikely(rc)) |
719 | goto free; | 678 | goto free; |
720 | llc_conn_send_pdu(sk, nskb); | 679 | llc_conn_send_pdu(sk, nskb); |
721 | } | 680 | } |
@@ -729,19 +688,17 @@ free: | |||
729 | int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) | 688 | int llc_conn_ac_send_ack_rsp_f_set_1(struct sock *sk, struct sk_buff *skb) |
730 | { | 689 | { |
731 | int rc = -ENOBUFS; | 690 | int rc = -ENOBUFS; |
732 | struct sk_buff *nskb = llc_alloc_frame(); | 691 | struct llc_sock *llc = llc_sk(sk); |
692 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
733 | 693 | ||
734 | if (nskb) { | 694 | if (nskb) { |
735 | struct llc_sock *llc = llc_sk(sk); | ||
736 | struct llc_sap *sap = llc->sap; | 695 | struct llc_sap *sap = llc->sap; |
737 | u8 f_bit = 1; | ||
738 | 696 | ||
739 | nskb->dev = llc->dev; | ||
740 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 697 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
741 | llc->daddr.lsap, LLC_PDU_RSP); | 698 | llc->daddr.lsap, LLC_PDU_RSP); |
742 | llc_pdu_init_as_rr_rsp(nskb, f_bit, llc->vR); | 699 | llc_pdu_init_as_rr_rsp(nskb, 1, llc->vR); |
743 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 700 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
744 | if (rc) | 701 | if (unlikely(rc)) |
745 | goto free; | 702 | goto free; |
746 | llc_conn_send_pdu(sk, nskb); | 703 | llc_conn_send_pdu(sk, nskb); |
747 | } | 704 | } |
@@ -755,18 +712,17 @@ free: | |||
755 | int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) | 712 | int llc_conn_ac_send_rr_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) |
756 | { | 713 | { |
757 | int rc = -ENOBUFS; | 714 | int rc = -ENOBUFS; |
758 | struct sk_buff *nskb = llc_alloc_frame(); | 715 | struct llc_sock *llc = llc_sk(sk); |
716 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
759 | 717 | ||
760 | if (nskb) { | 718 | if (nskb) { |
761 | struct llc_sock *llc = llc_sk(sk); | ||
762 | struct llc_sap *sap = llc->sap; | 719 | struct llc_sap *sap = llc->sap; |
763 | 720 | ||
764 | nskb->dev = llc->dev; | ||
765 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 721 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
766 | llc->daddr.lsap, LLC_PDU_RSP); | 722 | llc->daddr.lsap, LLC_PDU_RSP); |
767 | llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); | 723 | llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); |
768 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 724 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
769 | if (rc) | 725 | if (unlikely(rc)) |
770 | goto free; | 726 | goto free; |
771 | llc_conn_send_pdu(sk, nskb); | 727 | llc_conn_send_pdu(sk, nskb); |
772 | } | 728 | } |
@@ -780,18 +736,17 @@ free: | |||
780 | int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) | 736 | int llc_conn_ac_send_ack_xxx_x_set_0(struct sock *sk, struct sk_buff *skb) |
781 | { | 737 | { |
782 | int rc = -ENOBUFS; | 738 | int rc = -ENOBUFS; |
783 | struct sk_buff *nskb = llc_alloc_frame(); | 739 | struct llc_sock *llc = llc_sk(sk); |
740 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
784 | 741 | ||
785 | if (nskb) { | 742 | if (nskb) { |
786 | struct llc_sock *llc = llc_sk(sk); | ||
787 | struct llc_sap *sap = llc->sap; | 743 | struct llc_sap *sap = llc->sap; |
788 | 744 | ||
789 | nskb->dev = llc->dev; | ||
790 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 745 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
791 | llc->daddr.lsap, LLC_PDU_RSP); | 746 | llc->daddr.lsap, LLC_PDU_RSP); |
792 | llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); | 747 | llc_pdu_init_as_rr_rsp(nskb, 0, llc->vR); |
793 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 748 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
794 | if (rc) | 749 | if (unlikely(rc)) |
795 | goto free; | 750 | goto free; |
796 | llc_conn_send_pdu(sk, nskb); | 751 | llc_conn_send_pdu(sk, nskb); |
797 | } | 752 | } |
@@ -815,8 +770,8 @@ void llc_conn_set_p_flag(struct sock *sk, u8 value) | |||
815 | int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) | 770 | int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) |
816 | { | 771 | { |
817 | int rc = -ENOBUFS; | 772 | int rc = -ENOBUFS; |
818 | struct sk_buff *nskb = llc_alloc_frame(); | ||
819 | struct llc_sock *llc = llc_sk(sk); | 773 | struct llc_sock *llc = llc_sk(sk); |
774 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
820 | 775 | ||
821 | if (nskb) { | 776 | if (nskb) { |
822 | struct llc_sap *sap = llc->sap; | 777 | struct llc_sap *sap = llc->sap; |
@@ -824,12 +779,11 @@ int llc_conn_ac_send_sabme_cmd_p_set_x(struct sock *sk, struct sk_buff *skb) | |||
824 | 779 | ||
825 | if (llc->dev->flags & IFF_LOOPBACK) | 780 | if (llc->dev->flags & IFF_LOOPBACK) |
826 | dmac = llc->dev->dev_addr; | 781 | dmac = llc->dev->dev_addr; |
827 | nskb->dev = llc->dev; | ||
828 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, | 782 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, |
829 | llc->daddr.lsap, LLC_PDU_CMD); | 783 | llc->daddr.lsap, LLC_PDU_CMD); |
830 | llc_pdu_init_as_sabme_cmd(nskb, 1); | 784 | llc_pdu_init_as_sabme_cmd(nskb, 1); |
831 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, dmac); | 785 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, dmac); |
832 | if (rc) | 786 | if (unlikely(rc)) |
833 | goto free; | 787 | goto free; |
834 | llc_conn_send_pdu(sk, nskb); | 788 | llc_conn_send_pdu(sk, nskb); |
835 | llc_conn_set_p_flag(sk, 1); | 789 | llc_conn_set_p_flag(sk, 1); |
@@ -845,11 +799,11 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) | |||
845 | { | 799 | { |
846 | u8 f_bit; | 800 | u8 f_bit; |
847 | int rc = -ENOBUFS; | 801 | int rc = -ENOBUFS; |
848 | struct sk_buff *nskb = llc_alloc_frame(); | 802 | struct llc_sock *llc = llc_sk(sk); |
803 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
849 | 804 | ||
850 | llc_pdu_decode_pf_bit(skb, &f_bit); | 805 | llc_pdu_decode_pf_bit(skb, &f_bit); |
851 | if (nskb) { | 806 | if (nskb) { |
852 | struct llc_sock *llc = llc_sk(sk); | ||
853 | struct llc_sap *sap = llc->sap; | 807 | struct llc_sap *sap = llc->sap; |
854 | 808 | ||
855 | nskb->dev = llc->dev; | 809 | nskb->dev = llc->dev; |
@@ -857,7 +811,7 @@ int llc_conn_ac_send_ua_rsp_f_set_p(struct sock *sk, struct sk_buff *skb) | |||
857 | llc->daddr.lsap, LLC_PDU_RSP); | 811 | llc->daddr.lsap, LLC_PDU_RSP); |
858 | llc_pdu_init_as_ua_rsp(nskb, f_bit); | 812 | llc_pdu_init_as_ua_rsp(nskb, f_bit); |
859 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 813 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
860 | if (rc) | 814 | if (unlikely(rc)) |
861 | goto free; | 815 | goto free; |
862 | llc_conn_send_pdu(sk, nskb); | 816 | llc_conn_send_pdu(sk, nskb); |
863 | } | 817 | } |
@@ -886,7 +840,7 @@ int llc_conn_ac_start_p_timer(struct sock *sk, struct sk_buff *skb) | |||
886 | 840 | ||
887 | llc_conn_set_p_flag(sk, 1); | 841 | llc_conn_set_p_flag(sk, 1); |
888 | mod_timer(&llc->pf_cycle_timer.timer, | 842 | mod_timer(&llc->pf_cycle_timer.timer, |
889 | jiffies + llc->pf_cycle_timer.expire * HZ); | 843 | jiffies + llc->pf_cycle_timer.expire); |
890 | return 0; | 844 | return 0; |
891 | } | 845 | } |
892 | 846 | ||
@@ -957,7 +911,7 @@ static int llc_conn_ac_send_i_rsp_f_set_ackpf(struct sock *sk, | |||
957 | llc->daddr.lsap, LLC_PDU_RSP); | 911 | llc->daddr.lsap, LLC_PDU_RSP); |
958 | llc_pdu_init_as_i_cmd(skb, llc->ack_pf, llc->vS, llc->vR); | 912 | llc_pdu_init_as_i_cmd(skb, llc->ack_pf, llc->vS, llc->vR); |
959 | rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); | 913 | rc = llc_mac_hdr_init(skb, llc->dev->dev_addr, llc->daddr.mac); |
960 | if (!rc) { | 914 | if (likely(!rc)) { |
961 | llc_conn_send_pdu(sk, skb); | 915 | llc_conn_send_pdu(sk, skb); |
962 | llc_conn_ac_inc_vs_by_1(sk, skb); | 916 | llc_conn_ac_inc_vs_by_1(sk, skb); |
963 | } | 917 | } |
@@ -1001,18 +955,17 @@ static int llc_conn_ac_send_rr_rsp_f_set_ackpf(struct sock *sk, | |||
1001 | struct sk_buff *skb) | 955 | struct sk_buff *skb) |
1002 | { | 956 | { |
1003 | int rc = -ENOBUFS; | 957 | int rc = -ENOBUFS; |
1004 | struct sk_buff *nskb = llc_alloc_frame(); | 958 | struct llc_sock *llc = llc_sk(sk); |
959 | struct sk_buff *nskb = llc_alloc_frame(sk, llc->dev); | ||
1005 | 960 | ||
1006 | if (nskb) { | 961 | if (nskb) { |
1007 | struct llc_sock *llc = llc_sk(sk); | ||
1008 | struct llc_sap *sap = llc->sap; | 962 | struct llc_sap *sap = llc->sap; |
1009 | 963 | ||
1010 | nskb->dev = llc->dev; | ||
1011 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, | 964 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_S, sap->laddr.lsap, |
1012 | llc->daddr.lsap, LLC_PDU_RSP); | 965 | llc->daddr.lsap, LLC_PDU_RSP); |
1013 | llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR); | 966 | llc_pdu_init_as_rr_rsp(nskb, llc->ack_pf, llc->vR); |
1014 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); | 967 | rc = llc_mac_hdr_init(nskb, llc->dev->dev_addr, llc->daddr.mac); |
1015 | if (rc) | 968 | if (unlikely(rc)) |
1016 | goto free; | 969 | goto free; |
1017 | llc_conn_send_pdu(sk, nskb); | 970 | llc_conn_send_pdu(sk, nskb); |
1018 | } | 971 | } |
@@ -1165,7 +1118,7 @@ int llc_conn_ac_start_ack_timer(struct sock *sk, struct sk_buff *skb) | |||
1165 | { | 1118 | { |
1166 | struct llc_sock *llc = llc_sk(sk); | 1119 | struct llc_sock *llc = llc_sk(sk); |
1167 | 1120 | ||
1168 | mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire * HZ); | 1121 | mod_timer(&llc->ack_timer.timer, jiffies + llc->ack_timer.expire); |
1169 | return 0; | 1122 | return 0; |
1170 | } | 1123 | } |
1171 | 1124 | ||
@@ -1174,7 +1127,7 @@ int llc_conn_ac_start_rej_timer(struct sock *sk, struct sk_buff *skb) | |||
1174 | struct llc_sock *llc = llc_sk(sk); | 1127 | struct llc_sock *llc = llc_sk(sk); |
1175 | 1128 | ||
1176 | mod_timer(&llc->rej_sent_timer.timer, | 1129 | mod_timer(&llc->rej_sent_timer.timer, |
1177 | jiffies + llc->rej_sent_timer.expire * HZ); | 1130 | jiffies + llc->rej_sent_timer.expire); |
1178 | return 0; | 1131 | return 0; |
1179 | } | 1132 | } |
1180 | 1133 | ||
@@ -1185,7 +1138,7 @@ int llc_conn_ac_start_ack_tmr_if_not_running(struct sock *sk, | |||
1185 | 1138 | ||
1186 | if (!timer_pending(&llc->ack_timer.timer)) | 1139 | if (!timer_pending(&llc->ack_timer.timer)) |
1187 | mod_timer(&llc->ack_timer.timer, | 1140 | mod_timer(&llc->ack_timer.timer, |
1188 | jiffies + llc->ack_timer.expire * HZ); | 1141 | jiffies + llc->ack_timer.expire); |
1189 | return 0; | 1142 | return 0; |
1190 | } | 1143 | } |
1191 | 1144 | ||
@@ -1233,7 +1186,7 @@ int llc_conn_ac_upd_nr_received(struct sock *sk, struct sk_buff *skb) | |||
1233 | } | 1186 | } |
1234 | if (unacked) | 1187 | if (unacked) |
1235 | mod_timer(&llc->ack_timer.timer, | 1188 | mod_timer(&llc->ack_timer.timer, |
1236 | jiffies + llc->ack_timer.expire * HZ); | 1189 | jiffies + llc->ack_timer.expire); |
1237 | } else if (llc->failed_data_req) { | 1190 | } else if (llc->failed_data_req) { |
1238 | u8 f_bit; | 1191 | u8 f_bit; |
1239 | 1192 | ||
@@ -1354,13 +1307,13 @@ int llc_conn_ac_set_vs_nr(struct sock *sk, struct sk_buff *skb) | |||
1354 | return 0; | 1307 | return 0; |
1355 | } | 1308 | } |
1356 | 1309 | ||
1357 | int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb) | 1310 | static int llc_conn_ac_inc_vs_by_1(struct sock *sk, struct sk_buff *skb) |
1358 | { | 1311 | { |
1359 | llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % 128; | 1312 | llc_sk(sk)->vS = (llc_sk(sk)->vS + 1) % 128; |
1360 | return 0; | 1313 | return 0; |
1361 | } | 1314 | } |
1362 | 1315 | ||
1363 | void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data) | 1316 | static void llc_conn_tmr_common_cb(unsigned long timeout_data, u8 type) |
1364 | { | 1317 | { |
1365 | struct sock *sk = (struct sock *)timeout_data; | 1318 | struct sock *sk = (struct sock *)timeout_data; |
1366 | struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC); | 1319 | struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC); |
@@ -1369,59 +1322,31 @@ void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data) | |||
1369 | if (skb) { | 1322 | if (skb) { |
1370 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 1323 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
1371 | 1324 | ||
1372 | skb->sk = sk; | 1325 | skb_set_owner_r(skb, sk); |
1373 | ev->type = LLC_CONN_EV_TYPE_P_TMR; | 1326 | ev->type = type; |
1374 | llc_process_tmr_ev(sk, skb); | 1327 | llc_process_tmr_ev(sk, skb); |
1375 | } | 1328 | } |
1376 | bh_unlock_sock(sk); | 1329 | bh_unlock_sock(sk); |
1377 | } | 1330 | } |
1378 | 1331 | ||
1379 | void llc_conn_busy_tmr_cb(unsigned long timeout_data) | 1332 | void llc_conn_pf_cycle_tmr_cb(unsigned long timeout_data) |
1380 | { | 1333 | { |
1381 | struct sock *sk = (struct sock *)timeout_data; | 1334 | llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_P_TMR); |
1382 | struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC); | 1335 | } |
1383 | |||
1384 | bh_lock_sock(sk); | ||
1385 | if (skb) { | ||
1386 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | ||
1387 | 1336 | ||
1388 | skb->sk = sk; | 1337 | void llc_conn_busy_tmr_cb(unsigned long timeout_data) |
1389 | ev->type = LLC_CONN_EV_TYPE_BUSY_TMR; | 1338 | { |
1390 | llc_process_tmr_ev(sk, skb); | 1339 | llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_BUSY_TMR); |
1391 | } | ||
1392 | bh_unlock_sock(sk); | ||
1393 | } | 1340 | } |
1394 | 1341 | ||
1395 | void llc_conn_ack_tmr_cb(unsigned long timeout_data) | 1342 | void llc_conn_ack_tmr_cb(unsigned long timeout_data) |
1396 | { | 1343 | { |
1397 | struct sock* sk = (struct sock *)timeout_data; | 1344 | llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_ACK_TMR); |
1398 | struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC); | ||
1399 | |||
1400 | bh_lock_sock(sk); | ||
1401 | if (skb) { | ||
1402 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | ||
1403 | |||
1404 | skb->sk = sk; | ||
1405 | ev->type = LLC_CONN_EV_TYPE_ACK_TMR; | ||
1406 | llc_process_tmr_ev(sk, skb); | ||
1407 | } | ||
1408 | bh_unlock_sock(sk); | ||
1409 | } | 1345 | } |
1410 | 1346 | ||
1411 | void llc_conn_rej_tmr_cb(unsigned long timeout_data) | 1347 | void llc_conn_rej_tmr_cb(unsigned long timeout_data) |
1412 | { | 1348 | { |
1413 | struct sock *sk = (struct sock *)timeout_data; | 1349 | llc_conn_tmr_common_cb(timeout_data, LLC_CONN_EV_TYPE_REJ_TMR); |
1414 | struct sk_buff *skb = alloc_skb(0, GFP_ATOMIC); | ||
1415 | |||
1416 | bh_lock_sock(sk); | ||
1417 | if (skb) { | ||
1418 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | ||
1419 | |||
1420 | skb->sk = sk; | ||
1421 | ev->type = LLC_CONN_EV_TYPE_REJ_TMR; | ||
1422 | llc_process_tmr_ev(sk, skb); | ||
1423 | } | ||
1424 | bh_unlock_sock(sk); | ||
1425 | } | 1350 | } |
1426 | 1351 | ||
1427 | int llc_conn_ac_rst_vs(struct sock *sk, struct sk_buff *skb) | 1352 | int llc_conn_ac_rst_vs(struct sock *sk, struct sk_buff *skb) |
diff --git a/net/llc/llc_c_ev.c b/net/llc/llc_c_ev.c index d5bdb53a348f..c5deda246614 100644 --- a/net/llc/llc_c_ev.c +++ b/net/llc/llc_c_ev.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <net/llc_conn.h> | 37 | #include <net/llc_conn.h> |
38 | #include <net/llc_sap.h> | 38 | #include <net/llc_sap.h> |
39 | #include <net/sock.h> | 39 | #include <net/sock.h> |
40 | #include <net/llc_c_ac.h> | ||
40 | #include <net/llc_c_ev.h> | 41 | #include <net/llc_c_ev.h> |
41 | #include <net/llc_pdu.h> | 42 | #include <net/llc_pdu.h> |
42 | 43 | ||
@@ -46,8 +47,6 @@ | |||
46 | #define dprintk(args...) | 47 | #define dprintk(args...) |
47 | #endif | 48 | #endif |
48 | 49 | ||
49 | extern u16 llc_circular_between(u8 a, u8 b, u8 c); | ||
50 | |||
51 | /** | 50 | /** |
52 | * llc_util_ns_inside_rx_window - check if sequence number is in rx window | 51 | * llc_util_ns_inside_rx_window - check if sequence number is in rx window |
53 | * @ns: sequence number of received pdu. | 52 | * @ns: sequence number of received pdu. |
@@ -99,7 +98,7 @@ out: | |||
99 | 98 | ||
100 | int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb) | 99 | int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb) |
101 | { | 100 | { |
102 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 101 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
103 | 102 | ||
104 | return ev->prim == LLC_CONN_PRIM && | 103 | return ev->prim == LLC_CONN_PRIM && |
105 | ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; | 104 | ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; |
@@ -107,7 +106,7 @@ int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb) | |||
107 | 106 | ||
108 | int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb) | 107 | int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb) |
109 | { | 108 | { |
110 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 109 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
111 | 110 | ||
112 | return ev->prim == LLC_DATA_PRIM && | 111 | return ev->prim == LLC_DATA_PRIM && |
113 | ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; | 112 | ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; |
@@ -115,7 +114,7 @@ int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb) | |||
115 | 114 | ||
116 | int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb) | 115 | int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb) |
117 | { | 116 | { |
118 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 117 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
119 | 118 | ||
120 | return ev->prim == LLC_DISC_PRIM && | 119 | return ev->prim == LLC_DISC_PRIM && |
121 | ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; | 120 | ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; |
@@ -123,7 +122,7 @@ int llc_conn_ev_disc_req(struct sock *sk, struct sk_buff *skb) | |||
123 | 122 | ||
124 | int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb) | 123 | int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb) |
125 | { | 124 | { |
126 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 125 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
127 | 126 | ||
128 | return ev->prim == LLC_RESET_PRIM && | 127 | return ev->prim == LLC_RESET_PRIM && |
129 | ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; | 128 | ev->prim_type == LLC_PRIM_TYPE_REQ ? 0 : 1; |
@@ -131,7 +130,7 @@ int llc_conn_ev_rst_req(struct sock *sk, struct sk_buff *skb) | |||
131 | 130 | ||
132 | int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb) | 131 | int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb) |
133 | { | 132 | { |
134 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 133 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
135 | 134 | ||
136 | return ev->type == LLC_CONN_EV_TYPE_SIMPLE && | 135 | return ev->type == LLC_CONN_EV_TYPE_SIMPLE && |
137 | ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_DETECTED ? 0 : 1; | 136 | ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_DETECTED ? 0 : 1; |
@@ -139,7 +138,7 @@ int llc_conn_ev_local_busy_detected(struct sock *sk, struct sk_buff *skb) | |||
139 | 138 | ||
140 | int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb) | 139 | int llc_conn_ev_local_busy_cleared(struct sock *sk, struct sk_buff *skb) |
141 | { | 140 | { |
142 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 141 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
143 | 142 | ||
144 | return ev->type == LLC_CONN_EV_TYPE_SIMPLE && | 143 | return ev->type == LLC_CONN_EV_TYPE_SIMPLE && |
145 | ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_CLEARED ? 0 : 1; | 144 | ev->prim_type == LLC_CONN_EV_LOCAL_BUSY_CLEARED ? 0 : 1; |
@@ -152,7 +151,7 @@ int llc_conn_ev_rx_bad_pdu(struct sock *sk, struct sk_buff *skb) | |||
152 | 151 | ||
153 | int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) | 152 | int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) |
154 | { | 153 | { |
155 | struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); | 154 | const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); |
156 | 155 | ||
157 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) && | 156 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) && |
158 | LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC ? 0 : 1; | 157 | LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_DISC ? 0 : 1; |
@@ -160,7 +159,7 @@ int llc_conn_ev_rx_disc_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) | |||
160 | 159 | ||
161 | int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | 160 | int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) |
162 | { | 161 | { |
163 | struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); | 162 | const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); |
164 | 163 | ||
165 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && | 164 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && |
166 | LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM ? 0 : 1; | 165 | LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_DM ? 0 : 1; |
@@ -168,7 +167,7 @@ int llc_conn_ev_rx_dm_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | |||
168 | 167 | ||
169 | int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | 168 | int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) |
170 | { | 169 | { |
171 | struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); | 170 | const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); |
172 | 171 | ||
173 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && | 172 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_U(pdu) && |
174 | LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR ? 0 : 1; | 173 | LLC_U_PDU_RSP(pdu) == LLC_2_PDU_RSP_FRMR ? 0 : 1; |
@@ -176,7 +175,7 @@ int llc_conn_ev_rx_frmr_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | |||
176 | 175 | ||
177 | int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) | 176 | int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) |
178 | { | 177 | { |
179 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 178 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
180 | 179 | ||
181 | return llc_conn_space(sk, skb) && | 180 | return llc_conn_space(sk, skb) && |
182 | LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 181 | LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
@@ -186,7 +185,7 @@ int llc_conn_ev_rx_i_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) | |||
186 | 185 | ||
187 | int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | 186 | int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) |
188 | { | 187 | { |
189 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 188 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
190 | 189 | ||
191 | return llc_conn_space(sk, skb) && | 190 | return llc_conn_space(sk, skb) && |
192 | LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 191 | LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
@@ -197,9 +196,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
197 | int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk, | 196 | int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk, |
198 | struct sk_buff *skb) | 197 | struct sk_buff *skb) |
199 | { | 198 | { |
200 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 199 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
201 | u8 vr = llc_sk(sk)->vR; | 200 | const u8 vr = llc_sk(sk)->vR; |
202 | u8 ns = LLC_I_GET_NS(pdu); | 201 | const u8 ns = LLC_I_GET_NS(pdu); |
203 | 202 | ||
204 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 203 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
205 | LLC_I_PF_IS_0(pdu) && ns != vr && | 204 | LLC_I_PF_IS_0(pdu) && ns != vr && |
@@ -209,9 +208,9 @@ int llc_conn_ev_rx_i_cmd_pbit_set_0_unexpd_ns(struct sock *sk, | |||
209 | int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk, | 208 | int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk, |
210 | struct sk_buff *skb) | 209 | struct sk_buff *skb) |
211 | { | 210 | { |
212 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 211 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
213 | u8 vr = llc_sk(sk)->vR; | 212 | const u8 vr = llc_sk(sk)->vR; |
214 | u8 ns = LLC_I_GET_NS(pdu); | 213 | const u8 ns = LLC_I_GET_NS(pdu); |
215 | 214 | ||
216 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 215 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
217 | LLC_I_PF_IS_1(pdu) && ns != vr && | 216 | LLC_I_PF_IS_1(pdu) && ns != vr && |
@@ -221,10 +220,11 @@ int llc_conn_ev_rx_i_cmd_pbit_set_1_unexpd_ns(struct sock *sk, | |||
221 | int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk, | 220 | int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk, |
222 | struct sk_buff *skb) | 221 | struct sk_buff *skb) |
223 | { | 222 | { |
224 | struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(skb); | 223 | const struct llc_pdu_sn * pdu = llc_pdu_sn_hdr(skb); |
225 | u8 vr = llc_sk(sk)->vR; | 224 | const u8 vr = llc_sk(sk)->vR; |
226 | u8 ns = LLC_I_GET_NS(pdu); | 225 | const u8 ns = LLC_I_GET_NS(pdu); |
227 | u16 rc = LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && | 226 | const u16 rc = LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
227 | ns != vr && | ||
228 | llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; | 228 | llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; |
229 | if (!rc) | 229 | if (!rc) |
230 | dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", | 230 | dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", |
@@ -234,7 +234,7 @@ int llc_conn_ev_rx_i_cmd_pbit_set_x_inval_ns(struct sock *sk, | |||
234 | 234 | ||
235 | int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) | 235 | int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) |
236 | { | 236 | { |
237 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 237 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
238 | 238 | ||
239 | return llc_conn_space(sk, skb) && | 239 | return llc_conn_space(sk, skb) && |
240 | LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 240 | LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
@@ -244,7 +244,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) | |||
244 | 244 | ||
245 | int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | 245 | int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) |
246 | { | 246 | { |
247 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 247 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
248 | 248 | ||
249 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 249 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
250 | LLC_I_PF_IS_1(pdu) && | 250 | LLC_I_PF_IS_1(pdu) && |
@@ -253,7 +253,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
253 | 253 | ||
254 | int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | 254 | int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) |
255 | { | 255 | { |
256 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 256 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
257 | 257 | ||
258 | return llc_conn_space(sk, skb) && | 258 | return llc_conn_space(sk, skb) && |
259 | LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 259 | LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
@@ -263,9 +263,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | |||
263 | int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk, | 263 | int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk, |
264 | struct sk_buff *skb) | 264 | struct sk_buff *skb) |
265 | { | 265 | { |
266 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 266 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
267 | u8 vr = llc_sk(sk)->vR; | 267 | const u8 vr = llc_sk(sk)->vR; |
268 | u8 ns = LLC_I_GET_NS(pdu); | 268 | const u8 ns = LLC_I_GET_NS(pdu); |
269 | 269 | ||
270 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 270 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
271 | LLC_I_PF_IS_0(pdu) && ns != vr && | 271 | LLC_I_PF_IS_0(pdu) && ns != vr && |
@@ -275,9 +275,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_0_unexpd_ns(struct sock *sk, | |||
275 | int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk, | 275 | int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk, |
276 | struct sk_buff *skb) | 276 | struct sk_buff *skb) |
277 | { | 277 | { |
278 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 278 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
279 | u8 vr = llc_sk(sk)->vR; | 279 | const u8 vr = llc_sk(sk)->vR; |
280 | u8 ns = LLC_I_GET_NS(pdu); | 280 | const u8 ns = LLC_I_GET_NS(pdu); |
281 | 281 | ||
282 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && | 282 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
283 | LLC_I_PF_IS_1(pdu) && ns != vr && | 283 | LLC_I_PF_IS_1(pdu) && ns != vr && |
@@ -287,9 +287,9 @@ int llc_conn_ev_rx_i_rsp_fbit_set_1_unexpd_ns(struct sock *sk, | |||
287 | int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk, | 287 | int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk, |
288 | struct sk_buff *skb) | 288 | struct sk_buff *skb) |
289 | { | 289 | { |
290 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 290 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
291 | u8 vr = llc_sk(sk)->vR; | 291 | const u8 vr = llc_sk(sk)->vR; |
292 | u8 ns = LLC_I_GET_NS(pdu); | 292 | const u8 ns = LLC_I_GET_NS(pdu); |
293 | 293 | ||
294 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && | 294 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && |
295 | !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; | 295 | !llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; |
@@ -298,10 +298,11 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_unexpd_ns(struct sock *sk, | |||
298 | int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk, | 298 | int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk, |
299 | struct sk_buff *skb) | 299 | struct sk_buff *skb) |
300 | { | 300 | { |
301 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 301 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
302 | u8 vr = llc_sk(sk)->vR; | 302 | const u8 vr = llc_sk(sk)->vR; |
303 | u8 ns = LLC_I_GET_NS(pdu); | 303 | const u8 ns = LLC_I_GET_NS(pdu); |
304 | u16 rc = LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && ns != vr && | 304 | const u16 rc = LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_I(pdu) && |
305 | ns != vr && | ||
305 | llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; | 306 | llc_util_ns_inside_rx_window(ns, vr, llc_sk(sk)->rw) ? 0 : 1; |
306 | if (!rc) | 307 | if (!rc) |
307 | dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", | 308 | dprintk("%s: matched, state=%d, ns=%d, vr=%d\n", |
@@ -311,7 +312,7 @@ int llc_conn_ev_rx_i_rsp_fbit_set_x_inval_ns(struct sock *sk, | |||
311 | 312 | ||
312 | int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) | 313 | int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) |
313 | { | 314 | { |
314 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 315 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
315 | 316 | ||
316 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 317 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
317 | LLC_S_PF_IS_0(pdu) && | 318 | LLC_S_PF_IS_0(pdu) && |
@@ -320,7 +321,7 @@ int llc_conn_ev_rx_rej_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) | |||
320 | 321 | ||
321 | int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | 322 | int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) |
322 | { | 323 | { |
323 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 324 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
324 | 325 | ||
325 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 326 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
326 | LLC_S_PF_IS_1(pdu) && | 327 | LLC_S_PF_IS_1(pdu) && |
@@ -329,7 +330,7 @@ int llc_conn_ev_rx_rej_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
329 | 330 | ||
330 | int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) | 331 | int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) |
331 | { | 332 | { |
332 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 333 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
333 | 334 | ||
334 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 335 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
335 | LLC_S_PF_IS_0(pdu) && | 336 | LLC_S_PF_IS_0(pdu) && |
@@ -338,7 +339,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) | |||
338 | 339 | ||
339 | int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | 340 | int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) |
340 | { | 341 | { |
341 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 342 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
342 | 343 | ||
343 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 344 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
344 | LLC_S_PF_IS_1(pdu) && | 345 | LLC_S_PF_IS_1(pdu) && |
@@ -347,7 +348,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
347 | 348 | ||
348 | int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | 349 | int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) |
349 | { | 350 | { |
350 | struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); | 351 | const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); |
351 | 352 | ||
352 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 353 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
353 | LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1; | 354 | LLC_S_PDU_RSP(pdu) == LLC_2_PDU_RSP_REJ ? 0 : 1; |
@@ -355,7 +356,7 @@ int llc_conn_ev_rx_rej_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | |||
355 | 356 | ||
356 | int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) | 357 | int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) |
357 | { | 358 | { |
358 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 359 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
359 | 360 | ||
360 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 361 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
361 | LLC_S_PF_IS_0(pdu) && | 362 | LLC_S_PF_IS_0(pdu) && |
@@ -364,7 +365,7 @@ int llc_conn_ev_rx_rnr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) | |||
364 | 365 | ||
365 | int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | 366 | int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) |
366 | { | 367 | { |
367 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 368 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
368 | 369 | ||
369 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 370 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
370 | LLC_S_PF_IS_1(pdu) && | 371 | LLC_S_PF_IS_1(pdu) && |
@@ -373,7 +374,7 @@ int llc_conn_ev_rx_rnr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
373 | 374 | ||
374 | int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) | 375 | int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) |
375 | { | 376 | { |
376 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 377 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
377 | 378 | ||
378 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 379 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
379 | LLC_S_PF_IS_0(pdu) && | 380 | LLC_S_PF_IS_0(pdu) && |
@@ -382,7 +383,7 @@ int llc_conn_ev_rx_rnr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) | |||
382 | 383 | ||
383 | int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | 384 | int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) |
384 | { | 385 | { |
385 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 386 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
386 | 387 | ||
387 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 388 | return LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
388 | LLC_S_PF_IS_1(pdu) && | 389 | LLC_S_PF_IS_1(pdu) && |
@@ -391,7 +392,7 @@ int llc_conn_ev_rx_rnr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
391 | 392 | ||
392 | int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) | 393 | int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) |
393 | { | 394 | { |
394 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 395 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
395 | 396 | ||
396 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 397 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
397 | LLC_S_PF_IS_0(pdu) && | 398 | LLC_S_PF_IS_0(pdu) && |
@@ -400,7 +401,7 @@ int llc_conn_ev_rx_rr_cmd_pbit_set_0(struct sock *sk, struct sk_buff *skb) | |||
400 | 401 | ||
401 | int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | 402 | int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) |
402 | { | 403 | { |
403 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 404 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
404 | 405 | ||
405 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 406 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
406 | LLC_S_PF_IS_1(pdu) && | 407 | LLC_S_PF_IS_1(pdu) && |
@@ -409,7 +410,7 @@ int llc_conn_ev_rx_rr_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
409 | 410 | ||
410 | int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) | 411 | int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) |
411 | { | 412 | { |
412 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 413 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
413 | 414 | ||
414 | return llc_conn_space(sk, skb) && | 415 | return llc_conn_space(sk, skb) && |
415 | LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 416 | LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
@@ -419,7 +420,7 @@ int llc_conn_ev_rx_rr_rsp_fbit_set_0(struct sock *sk, struct sk_buff *skb) | |||
419 | 420 | ||
420 | int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | 421 | int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) |
421 | { | 422 | { |
422 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 423 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
423 | 424 | ||
424 | return llc_conn_space(sk, skb) && | 425 | return llc_conn_space(sk, skb) && |
425 | LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && | 426 | LLC_PDU_IS_RSP(pdu) && LLC_PDU_TYPE_IS_S(pdu) && |
@@ -429,7 +430,7 @@ int llc_conn_ev_rx_rr_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
429 | 430 | ||
430 | int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) | 431 | int llc_conn_ev_rx_sabme_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) |
431 | { | 432 | { |
432 | struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); | 433 | const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); |
433 | 434 | ||
434 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) && | 435 | return LLC_PDU_IS_CMD(pdu) && LLC_PDU_TYPE_IS_U(pdu) && |
435 | LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME ? 0 : 1; | 436 | LLC_U_PDU_CMD(pdu) == LLC_2_PDU_CMD_SABME ? 0 : 1; |
@@ -446,7 +447,7 @@ int llc_conn_ev_rx_ua_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | |||
446 | int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | 447 | int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) |
447 | { | 448 | { |
448 | u16 rc = 1; | 449 | u16 rc = 1; |
449 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 450 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
450 | 451 | ||
451 | if (LLC_PDU_IS_CMD(pdu)) { | 452 | if (LLC_PDU_IS_CMD(pdu)) { |
452 | if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) { | 453 | if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) { |
@@ -461,7 +462,7 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_1(struct sock *sk, struct sk_buff *skb) | |||
461 | int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) | 462 | int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) |
462 | { | 463 | { |
463 | u16 rc = 1; | 464 | u16 rc = 1; |
464 | struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); | 465 | const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); |
465 | 466 | ||
466 | if (LLC_PDU_IS_CMD(pdu)) { | 467 | if (LLC_PDU_IS_CMD(pdu)) { |
467 | if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) | 468 | if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) |
@@ -477,32 +478,10 @@ int llc_conn_ev_rx_xxx_cmd_pbit_set_x(struct sock *sk, struct sk_buff *skb) | |||
477 | return rc; | 478 | return rc; |
478 | } | 479 | } |
479 | 480 | ||
480 | int llc_conn_ev_rx_xxx_rsp_fbit_set_1(struct sock *sk, struct sk_buff *skb) | ||
481 | { | ||
482 | u16 rc = 1; | ||
483 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | ||
484 | |||
485 | if (LLC_PDU_IS_RSP(pdu)) { | ||
486 | if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) { | ||
487 | if (LLC_I_PF_IS_1(pdu)) | ||
488 | rc = 0; | ||
489 | } else if (LLC_PDU_TYPE_IS_U(pdu)) | ||
490 | switch (LLC_U_PDU_RSP(pdu)) { | ||
491 | case LLC_2_PDU_RSP_UA: | ||
492 | case LLC_2_PDU_RSP_DM: | ||
493 | case LLC_2_PDU_RSP_FRMR: | ||
494 | if (LLC_U_PF_IS_1(pdu)) | ||
495 | rc = 0; | ||
496 | break; | ||
497 | } | ||
498 | } | ||
499 | return rc; | ||
500 | } | ||
501 | |||
502 | int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) | 481 | int llc_conn_ev_rx_xxx_rsp_fbit_set_x(struct sock *sk, struct sk_buff *skb) |
503 | { | 482 | { |
504 | u16 rc = 1; | 483 | u16 rc = 1; |
505 | struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); | 484 | const struct llc_pdu_un *pdu = llc_pdu_un_hdr(skb); |
506 | 485 | ||
507 | if (LLC_PDU_IS_RSP(pdu)) { | 486 | if (LLC_PDU_IS_RSP(pdu)) { |
508 | if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) | 487 | if (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) |
@@ -524,9 +503,9 @@ int llc_conn_ev_rx_zzz_cmd_pbit_set_x_inval_nr(struct sock *sk, | |||
524 | struct sk_buff *skb) | 503 | struct sk_buff *skb) |
525 | { | 504 | { |
526 | u16 rc = 1; | 505 | u16 rc = 1; |
527 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 506 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
528 | u8 vs = llc_sk(sk)->vS; | 507 | const u8 vs = llc_sk(sk)->vS; |
529 | u8 nr = LLC_I_GET_NR(pdu); | 508 | const u8 nr = LLC_I_GET_NR(pdu); |
530 | 509 | ||
531 | if (LLC_PDU_IS_CMD(pdu) && | 510 | if (LLC_PDU_IS_CMD(pdu) && |
532 | (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) && | 511 | (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) && |
@@ -542,9 +521,9 @@ int llc_conn_ev_rx_zzz_rsp_fbit_set_x_inval_nr(struct sock *sk, | |||
542 | struct sk_buff *skb) | 521 | struct sk_buff *skb) |
543 | { | 522 | { |
544 | u16 rc = 1; | 523 | u16 rc = 1; |
545 | struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); | 524 | const struct llc_pdu_sn *pdu = llc_pdu_sn_hdr(skb); |
546 | u8 vs = llc_sk(sk)->vS; | 525 | const u8 vs = llc_sk(sk)->vS; |
547 | u8 nr = LLC_I_GET_NR(pdu); | 526 | const u8 nr = LLC_I_GET_NR(pdu); |
548 | 527 | ||
549 | if (LLC_PDU_IS_RSP(pdu) && | 528 | if (LLC_PDU_IS_RSP(pdu) && |
550 | (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) && | 529 | (LLC_PDU_TYPE_IS_I(pdu) || LLC_PDU_TYPE_IS_S(pdu)) && |
@@ -563,28 +542,28 @@ int llc_conn_ev_rx_any_frame(struct sock *sk, struct sk_buff *skb) | |||
563 | 542 | ||
564 | int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb) | 543 | int llc_conn_ev_p_tmr_exp(struct sock *sk, struct sk_buff *skb) |
565 | { | 544 | { |
566 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 545 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
567 | 546 | ||
568 | return ev->type != LLC_CONN_EV_TYPE_P_TMR; | 547 | return ev->type != LLC_CONN_EV_TYPE_P_TMR; |
569 | } | 548 | } |
570 | 549 | ||
571 | int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb) | 550 | int llc_conn_ev_ack_tmr_exp(struct sock *sk, struct sk_buff *skb) |
572 | { | 551 | { |
573 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 552 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
574 | 553 | ||
575 | return ev->type != LLC_CONN_EV_TYPE_ACK_TMR; | 554 | return ev->type != LLC_CONN_EV_TYPE_ACK_TMR; |
576 | } | 555 | } |
577 | 556 | ||
578 | int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb) | 557 | int llc_conn_ev_rej_tmr_exp(struct sock *sk, struct sk_buff *skb) |
579 | { | 558 | { |
580 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 559 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
581 | 560 | ||
582 | return ev->type != LLC_CONN_EV_TYPE_REJ_TMR; | 561 | return ev->type != LLC_CONN_EV_TYPE_REJ_TMR; |
583 | } | 562 | } |
584 | 563 | ||
585 | int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb) | 564 | int llc_conn_ev_busy_tmr_exp(struct sock *sk, struct sk_buff *skb) |
586 | { | 565 | { |
587 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 566 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
588 | 567 | ||
589 | return ev->type != LLC_CONN_EV_TYPE_BUSY_TMR; | 568 | return ev->type != LLC_CONN_EV_TYPE_BUSY_TMR; |
590 | } | 569 | } |
@@ -596,7 +575,7 @@ int llc_conn_ev_init_p_f_cycle(struct sock *sk, struct sk_buff *skb) | |||
596 | 575 | ||
597 | int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb) | 576 | int llc_conn_ev_tx_buffer_full(struct sock *sk, struct sk_buff *skb) |
598 | { | 577 | { |
599 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 578 | const struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
600 | 579 | ||
601 | return ev->type == LLC_CONN_EV_TYPE_SIMPLE && | 580 | return ev->type == LLC_CONN_EV_TYPE_SIMPLE && |
602 | ev->prim_type == LLC_CONN_EV_TX_BUFF_FULL ? 0 : 1; | 581 | ev->prim_type == LLC_CONN_EV_TX_BUFF_FULL ? 0 : 1; |
diff --git a/net/llc/llc_conn.c b/net/llc/llc_conn.c index 4c644bc70eae..042b24a8ca4c 100644 --- a/net/llc/llc_conn.c +++ b/net/llc/llc_conn.c | |||
@@ -40,6 +40,11 @@ static struct llc_conn_state_trans *llc_qualify_conn_ev(struct sock *sk, | |||
40 | /* Offset table on connection states transition diagram */ | 40 | /* Offset table on connection states transition diagram */ |
41 | static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; | 41 | static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; |
42 | 42 | ||
43 | int sysctl_llc2_ack_timeout = LLC2_ACK_TIME * HZ; | ||
44 | int sysctl_llc2_p_timeout = LLC2_P_TIME * HZ; | ||
45 | int sysctl_llc2_rej_timeout = LLC2_REJ_TIME * HZ; | ||
46 | int sysctl_llc2_busy_timeout = LLC2_BUSY_TIME * HZ; | ||
47 | |||
43 | /** | 48 | /** |
44 | * llc_conn_state_process - sends event to connection state machine | 49 | * llc_conn_state_process - sends event to connection state machine |
45 | * @sk: connection | 50 | * @sk: connection |
@@ -53,7 +58,7 @@ static int llc_offset_table[NBR_CONN_STATES][NBR_CONN_EV]; | |||
53 | int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) | 58 | int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) |
54 | { | 59 | { |
55 | int rc; | 60 | int rc; |
56 | struct llc_sock *llc = llc_sk(sk); | 61 | struct llc_sock *llc = llc_sk(skb->sk); |
57 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 62 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
58 | 63 | ||
59 | /* | 64 | /* |
@@ -63,13 +68,16 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) | |||
63 | */ | 68 | */ |
64 | skb_get(skb); | 69 | skb_get(skb); |
65 | ev->ind_prim = ev->cfm_prim = 0; | 70 | ev->ind_prim = ev->cfm_prim = 0; |
66 | rc = llc_conn_service(sk, skb); /* sending event to state machine */ | 71 | /* |
67 | if (rc) { | 72 | * Send event to state machine |
73 | */ | ||
74 | rc = llc_conn_service(skb->sk, skb); | ||
75 | if (unlikely(rc != 0)) { | ||
68 | printk(KERN_ERR "%s: llc_conn_service failed\n", __FUNCTION__); | 76 | printk(KERN_ERR "%s: llc_conn_service failed\n", __FUNCTION__); |
69 | goto out_kfree_skb; | 77 | goto out_kfree_skb; |
70 | } | 78 | } |
71 | 79 | ||
72 | if (!ev->ind_prim && !ev->cfm_prim) { | 80 | if (unlikely(!ev->ind_prim && !ev->cfm_prim)) { |
73 | /* indicate or confirm not required */ | 81 | /* indicate or confirm not required */ |
74 | /* XXX this is not very pretty, perhaps we should store | 82 | /* XXX this is not very pretty, perhaps we should store |
75 | * XXX indicate/confirm-needed state in the llc_conn_state_ev | 83 | * XXX indicate/confirm-needed state in the llc_conn_state_ev |
@@ -80,13 +88,13 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) | |||
80 | goto out_skb_put; | 88 | goto out_skb_put; |
81 | } | 89 | } |
82 | 90 | ||
83 | if (ev->ind_prim && ev->cfm_prim) /* Paranoia */ | 91 | if (unlikely(ev->ind_prim && ev->cfm_prim)) /* Paranoia */ |
84 | skb_get(skb); | 92 | skb_get(skb); |
85 | 93 | ||
86 | switch (ev->ind_prim) { | 94 | switch (ev->ind_prim) { |
87 | case LLC_DATA_PRIM: | 95 | case LLC_DATA_PRIM: |
88 | llc_save_primitive(skb, LLC_DATA_PRIM); | 96 | llc_save_primitive(sk, skb, LLC_DATA_PRIM); |
89 | if (sock_queue_rcv_skb(sk, skb)) { | 97 | if (unlikely(sock_queue_rcv_skb(sk, skb))) { |
90 | /* | 98 | /* |
91 | * shouldn't happen | 99 | * shouldn't happen |
92 | */ | 100 | */ |
@@ -95,13 +103,14 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) | |||
95 | kfree_skb(skb); | 103 | kfree_skb(skb); |
96 | } | 104 | } |
97 | break; | 105 | break; |
98 | case LLC_CONN_PRIM: { | 106 | case LLC_CONN_PRIM: |
99 | struct sock *parent = skb->sk; | 107 | /* |
100 | 108 | * Can't be sock_queue_rcv_skb, because we have to leave the | |
101 | skb->sk = sk; | 109 | * skb->sk pointing to the newly created struct sock in |
102 | skb_queue_tail(&parent->sk_receive_queue, skb); | 110 | * llc_conn_handler. -acme |
103 | sk->sk_state_change(parent); | 111 | */ |
104 | } | 112 | skb_queue_tail(&sk->sk_receive_queue, skb); |
113 | sk->sk_state_change(sk); | ||
105 | break; | 114 | break; |
106 | case LLC_DISC_PRIM: | 115 | case LLC_DISC_PRIM: |
107 | sock_hold(sk); | 116 | sock_hold(sk); |
@@ -111,8 +120,8 @@ int llc_conn_state_process(struct sock *sk, struct sk_buff *skb) | |||
111 | sk->sk_socket->state = SS_UNCONNECTED; | 120 | sk->sk_socket->state = SS_UNCONNECTED; |
112 | sk->sk_state = TCP_CLOSE; | 121 | sk->sk_state = TCP_CLOSE; |
113 | if (!sock_flag(sk, SOCK_DEAD)) { | 122 | if (!sock_flag(sk, SOCK_DEAD)) { |
114 | sk->sk_state_change(sk); | ||
115 | sock_set_flag(sk, SOCK_DEAD); | 123 | sock_set_flag(sk, SOCK_DEAD); |
124 | sk->sk_state_change(sk); | ||
116 | } | 125 | } |
117 | } | 126 | } |
118 | kfree_skb(skb); | 127 | kfree_skb(skb); |
@@ -465,7 +474,7 @@ static int llc_exec_conn_trans_actions(struct sock *sk, | |||
465 | } | 474 | } |
466 | 475 | ||
467 | /** | 476 | /** |
468 | * llc_lookup_established - Finds connection for the remote/local sap/mac | 477 | * __llc_lookup_established - Finds connection for the remote/local sap/mac |
469 | * @sap: SAP | 478 | * @sap: SAP |
470 | * @daddr: address of remote LLC (MAC + SAP) | 479 | * @daddr: address of remote LLC (MAC + SAP) |
471 | * @laddr: address of local LLC (MAC + SAP) | 480 | * @laddr: address of local LLC (MAC + SAP) |
@@ -473,14 +482,16 @@ static int llc_exec_conn_trans_actions(struct sock *sk, | |||
473 | * Search connection list of the SAP and finds connection using the remote | 482 | * Search connection list of the SAP and finds connection using the remote |
474 | * mac, remote sap, local mac, and local sap. Returns pointer for | 483 | * mac, remote sap, local mac, and local sap. Returns pointer for |
475 | * connection found, %NULL otherwise. | 484 | * connection found, %NULL otherwise. |
485 | * Caller has to make sure local_bh is disabled. | ||
476 | */ | 486 | */ |
477 | struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr, | 487 | static struct sock *__llc_lookup_established(struct llc_sap *sap, |
478 | struct llc_addr *laddr) | 488 | struct llc_addr *daddr, |
489 | struct llc_addr *laddr) | ||
479 | { | 490 | { |
480 | struct sock *rc; | 491 | struct sock *rc; |
481 | struct hlist_node *node; | 492 | struct hlist_node *node; |
482 | 493 | ||
483 | read_lock_bh(&sap->sk_list.lock); | 494 | read_lock(&sap->sk_list.lock); |
484 | sk_for_each(rc, node, &sap->sk_list.list) { | 495 | sk_for_each(rc, node, &sap->sk_list.list) { |
485 | struct llc_sock *llc = llc_sk(rc); | 496 | struct llc_sock *llc = llc_sk(rc); |
486 | 497 | ||
@@ -494,10 +505,22 @@ struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr, | |||
494 | } | 505 | } |
495 | rc = NULL; | 506 | rc = NULL; |
496 | found: | 507 | found: |
497 | read_unlock_bh(&sap->sk_list.lock); | 508 | read_unlock(&sap->sk_list.lock); |
498 | return rc; | 509 | return rc; |
499 | } | 510 | } |
500 | 511 | ||
512 | struct sock *llc_lookup_established(struct llc_sap *sap, | ||
513 | struct llc_addr *daddr, | ||
514 | struct llc_addr *laddr) | ||
515 | { | ||
516 | struct sock *sk; | ||
517 | |||
518 | local_bh_disable(); | ||
519 | sk = __llc_lookup_established(sap, daddr, laddr); | ||
520 | local_bh_enable(); | ||
521 | return sk; | ||
522 | } | ||
523 | |||
501 | /** | 524 | /** |
502 | * llc_lookup_listener - Finds listener for local MAC + SAP | 525 | * llc_lookup_listener - Finds listener for local MAC + SAP |
503 | * @sap: SAP | 526 | * @sap: SAP |
@@ -506,6 +529,7 @@ found: | |||
506 | * Search connection list of the SAP and finds connection listening on | 529 | * Search connection list of the SAP and finds connection listening on |
507 | * local mac, and local sap. Returns pointer for parent socket found, | 530 | * local mac, and local sap. Returns pointer for parent socket found, |
508 | * %NULL otherwise. | 531 | * %NULL otherwise. |
532 | * Caller has to make sure local_bh is disabled. | ||
509 | */ | 533 | */ |
510 | static struct sock *llc_lookup_listener(struct llc_sap *sap, | 534 | static struct sock *llc_lookup_listener(struct llc_sap *sap, |
511 | struct llc_addr *laddr) | 535 | struct llc_addr *laddr) |
@@ -513,7 +537,7 @@ static struct sock *llc_lookup_listener(struct llc_sap *sap, | |||
513 | struct sock *rc; | 537 | struct sock *rc; |
514 | struct hlist_node *node; | 538 | struct hlist_node *node; |
515 | 539 | ||
516 | read_lock_bh(&sap->sk_list.lock); | 540 | read_lock(&sap->sk_list.lock); |
517 | sk_for_each(rc, node, &sap->sk_list.list) { | 541 | sk_for_each(rc, node, &sap->sk_list.list) { |
518 | struct llc_sock *llc = llc_sk(rc); | 542 | struct llc_sock *llc = llc_sk(rc); |
519 | 543 | ||
@@ -527,10 +551,19 @@ static struct sock *llc_lookup_listener(struct llc_sap *sap, | |||
527 | } | 551 | } |
528 | rc = NULL; | 552 | rc = NULL; |
529 | found: | 553 | found: |
530 | read_unlock_bh(&sap->sk_list.lock); | 554 | read_unlock(&sap->sk_list.lock); |
531 | return rc; | 555 | return rc; |
532 | } | 556 | } |
533 | 557 | ||
558 | static struct sock *__llc_lookup(struct llc_sap *sap, | ||
559 | struct llc_addr *daddr, | ||
560 | struct llc_addr *laddr) | ||
561 | { | ||
562 | struct sock *sk = __llc_lookup_established(sap, daddr, laddr); | ||
563 | |||
564 | return sk ? : llc_lookup_listener(sap, laddr); | ||
565 | } | ||
566 | |||
534 | /** | 567 | /** |
535 | * llc_data_accept_state - designates if in this state data can be sent. | 568 | * llc_data_accept_state - designates if in this state data can be sent. |
536 | * @state: state of connection. | 569 | * @state: state of connection. |
@@ -544,14 +577,14 @@ u8 llc_data_accept_state(u8 state) | |||
544 | } | 577 | } |
545 | 578 | ||
546 | /** | 579 | /** |
547 | * find_next_offset - finds offset for next category of transitions | 580 | * llc_find_next_offset - finds offset for next category of transitions |
548 | * @state: state table. | 581 | * @state: state table. |
549 | * @offset: start offset. | 582 | * @offset: start offset. |
550 | * | 583 | * |
551 | * Finds offset of next category of transitions in transition table. | 584 | * Finds offset of next category of transitions in transition table. |
552 | * Returns the start index of next category. | 585 | * Returns the start index of next category. |
553 | */ | 586 | */ |
554 | static u16 find_next_offset(struct llc_conn_state *state, u16 offset) | 587 | static u16 __init llc_find_next_offset(struct llc_conn_state *state, u16 offset) |
555 | { | 588 | { |
556 | u16 cnt = 0; | 589 | u16 cnt = 0; |
557 | struct llc_conn_state_trans **next_trans; | 590 | struct llc_conn_state_trans **next_trans; |
@@ -578,8 +611,8 @@ void __init llc_build_offset_table(void) | |||
578 | next_offset = 0; | 611 | next_offset = 0; |
579 | for (ev_type = 0; ev_type < NBR_CONN_EV; ev_type++) { | 612 | for (ev_type = 0; ev_type < NBR_CONN_EV; ev_type++) { |
580 | llc_offset_table[state][ev_type] = next_offset; | 613 | llc_offset_table[state][ev_type] = next_offset; |
581 | next_offset += find_next_offset(curr_state, | 614 | next_offset += llc_find_next_offset(curr_state, |
582 | next_offset) + 1; | 615 | next_offset) + 1; |
583 | } | 616 | } |
584 | } | 617 | } |
585 | } | 618 | } |
@@ -623,6 +656,7 @@ static int llc_find_offset(int state, int ev_type) | |||
623 | */ | 656 | */ |
624 | void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) | 657 | void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk) |
625 | { | 658 | { |
659 | llc_sap_hold(sap); | ||
626 | write_lock_bh(&sap->sk_list.lock); | 660 | write_lock_bh(&sap->sk_list.lock); |
627 | llc_sk(sk)->sap = sap; | 661 | llc_sk(sk)->sap = sap; |
628 | sk_add_node(sk, &sap->sk_list.list); | 662 | sk_add_node(sk, &sap->sk_list.list); |
@@ -642,6 +676,7 @@ void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk) | |||
642 | write_lock_bh(&sap->sk_list.lock); | 676 | write_lock_bh(&sap->sk_list.lock); |
643 | sk_del_node_init(sk); | 677 | sk_del_node_init(sk); |
644 | write_unlock_bh(&sap->sk_list.lock); | 678 | write_unlock_bh(&sap->sk_list.lock); |
679 | llc_sap_put(sap); | ||
645 | } | 680 | } |
646 | 681 | ||
647 | /** | 682 | /** |
@@ -654,15 +689,34 @@ void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk) | |||
654 | static int llc_conn_rcv(struct sock* sk, struct sk_buff *skb) | 689 | static int llc_conn_rcv(struct sock* sk, struct sk_buff *skb) |
655 | { | 690 | { |
656 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); | 691 | struct llc_conn_state_ev *ev = llc_conn_ev(skb); |
657 | struct llc_sock *llc = llc_sk(sk); | ||
658 | 692 | ||
659 | if (!llc->dev) | ||
660 | llc->dev = skb->dev; | ||
661 | ev->type = LLC_CONN_EV_TYPE_PDU; | 693 | ev->type = LLC_CONN_EV_TYPE_PDU; |
662 | ev->reason = 0; | 694 | ev->reason = 0; |
663 | return llc_conn_state_process(sk, skb); | 695 | return llc_conn_state_process(sk, skb); |
664 | } | 696 | } |
665 | 697 | ||
698 | static struct sock *llc_create_incoming_sock(struct sock *sk, | ||
699 | struct net_device *dev, | ||
700 | struct llc_addr *saddr, | ||
701 | struct llc_addr *daddr) | ||
702 | { | ||
703 | struct sock *newsk = llc_sk_alloc(sk->sk_family, GFP_ATOMIC, | ||
704 | sk->sk_prot); | ||
705 | struct llc_sock *newllc, *llc = llc_sk(sk); | ||
706 | |||
707 | if (!newsk) | ||
708 | goto out; | ||
709 | newllc = llc_sk(newsk); | ||
710 | memcpy(&newllc->laddr, daddr, sizeof(newllc->laddr)); | ||
711 | memcpy(&newllc->daddr, saddr, sizeof(newllc->daddr)); | ||
712 | newllc->dev = dev; | ||
713 | dev_hold(dev); | ||
714 | llc_sap_add_socket(llc->sap, newsk); | ||
715 | llc_sap_hold(llc->sap); | ||
716 | out: | ||
717 | return newsk; | ||
718 | } | ||
719 | |||
666 | void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb) | 720 | void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb) |
667 | { | 721 | { |
668 | struct llc_addr saddr, daddr; | 722 | struct llc_addr saddr, daddr; |
@@ -673,35 +727,35 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb) | |||
673 | llc_pdu_decode_da(skb, daddr.mac); | 727 | llc_pdu_decode_da(skb, daddr.mac); |
674 | llc_pdu_decode_dsap(skb, &daddr.lsap); | 728 | llc_pdu_decode_dsap(skb, &daddr.lsap); |
675 | 729 | ||
676 | sk = llc_lookup_established(sap, &saddr, &daddr); | 730 | sk = __llc_lookup(sap, &saddr, &daddr); |
677 | if (!sk) { | 731 | if (!sk) |
732 | goto drop; | ||
733 | |||
734 | bh_lock_sock(sk); | ||
735 | /* | ||
736 | * This has to be done here and not at the upper layer ->accept | ||
737 | * method because of the way the PROCOM state machine works: | ||
738 | * it needs to set several state variables (see, for instance, | ||
739 | * llc_adm_actions_2 in net/llc/llc_c_st.c) and send a packet to | ||
740 | * the originator of the new connection, and this state has to be | ||
741 | * in the newly created struct sock private area. -acme | ||
742 | */ | ||
743 | if (unlikely(sk->sk_state == TCP_LISTEN)) { | ||
744 | struct sock *newsk = llc_create_incoming_sock(sk, skb->dev, | ||
745 | &saddr, &daddr); | ||
746 | if (!newsk) | ||
747 | goto drop_unlock; | ||
748 | skb_set_owner_r(skb, newsk); | ||
749 | } else { | ||
678 | /* | 750 | /* |
679 | * Didn't find an active connection; verify if there | 751 | * Can't be skb_set_owner_r, this will be done at the |
680 | * is a listening socket for this llc addr | 752 | * llc_conn_state_process function, later on, when we will use |
753 | * skb_queue_rcv_skb to send it to upper layers, this is | ||
754 | * another trick required to cope with how the PROCOM state | ||
755 | * machine works. -acme | ||
681 | */ | 756 | */ |
682 | struct llc_sock *llc; | ||
683 | struct sock *parent = llc_lookup_listener(sap, &daddr); | ||
684 | |||
685 | if (!parent) { | ||
686 | dprintk("llc_lookup_listener failed!\n"); | ||
687 | goto drop; | ||
688 | } | ||
689 | |||
690 | sk = llc_sk_alloc(parent->sk_family, GFP_ATOMIC, parent->sk_prot); | ||
691 | if (!sk) { | ||
692 | sock_put(parent); | ||
693 | goto drop; | ||
694 | } | ||
695 | llc = llc_sk(sk); | ||
696 | memcpy(&llc->laddr, &daddr, sizeof(llc->laddr)); | ||
697 | memcpy(&llc->daddr, &saddr, sizeof(llc->daddr)); | ||
698 | llc_sap_add_socket(sap, sk); | ||
699 | sock_hold(sk); | ||
700 | sock_put(parent); | ||
701 | skb->sk = parent; | ||
702 | } else | ||
703 | skb->sk = sk; | 757 | skb->sk = sk; |
704 | bh_lock_sock(sk); | 758 | } |
705 | if (!sock_owned_by_user(sk)) | 759 | if (!sock_owned_by_user(sk)) |
706 | llc_conn_rcv(sk, skb); | 760 | llc_conn_rcv(sk, skb); |
707 | else { | 761 | else { |
@@ -709,11 +763,16 @@ void llc_conn_handler(struct llc_sap *sap, struct sk_buff *skb) | |||
709 | llc_set_backlog_type(skb, LLC_PACKET); | 763 | llc_set_backlog_type(skb, LLC_PACKET); |
710 | sk_add_backlog(sk, skb); | 764 | sk_add_backlog(sk, skb); |
711 | } | 765 | } |
766 | out: | ||
712 | bh_unlock_sock(sk); | 767 | bh_unlock_sock(sk); |
713 | sock_put(sk); | 768 | sock_put(sk); |
714 | return; | 769 | return; |
715 | drop: | 770 | drop: |
716 | kfree_skb(skb); | 771 | kfree_skb(skb); |
772 | return; | ||
773 | drop_unlock: | ||
774 | kfree_skb(skb); | ||
775 | goto out; | ||
717 | } | 776 | } |
718 | 777 | ||
719 | #undef LLC_REFCNT_DEBUG | 778 | #undef LLC_REFCNT_DEBUG |
@@ -722,32 +781,6 @@ static atomic_t llc_sock_nr; | |||
722 | #endif | 781 | #endif |
723 | 782 | ||
724 | /** | 783 | /** |
725 | * llc_release_sockets - releases all sockets in a sap | ||
726 | * @sap: sap to release its sockets | ||
727 | * | ||
728 | * Releases all connections of a sap. Returns 0 if all actions complete | ||
729 | * successfully, nonzero otherwise | ||
730 | */ | ||
731 | int llc_release_sockets(struct llc_sap *sap) | ||
732 | { | ||
733 | int rc = 0; | ||
734 | struct sock *sk; | ||
735 | struct hlist_node *node; | ||
736 | |||
737 | write_lock_bh(&sap->sk_list.lock); | ||
738 | |||
739 | sk_for_each(sk, node, &sap->sk_list.list) { | ||
740 | llc_sk(sk)->state = LLC_CONN_STATE_TEMP; | ||
741 | |||
742 | if (llc_send_disc(sk)) | ||
743 | rc = 1; | ||
744 | } | ||
745 | |||
746 | write_unlock_bh(&sap->sk_list.lock); | ||
747 | return rc; | ||
748 | } | ||
749 | |||
750 | /** | ||
751 | * llc_backlog_rcv - Processes rx frames and expired timers. | 784 | * llc_backlog_rcv - Processes rx frames and expired timers. |
752 | * @sk: LLC sock (p8022 connection) | 785 | * @sk: LLC sock (p8022 connection) |
753 | * @skb: queued rx frame or event | 786 | * @skb: queued rx frame or event |
@@ -762,14 +795,14 @@ static int llc_backlog_rcv(struct sock *sk, struct sk_buff *skb) | |||
762 | int rc = 0; | 795 | int rc = 0; |
763 | struct llc_sock *llc = llc_sk(sk); | 796 | struct llc_sock *llc = llc_sk(sk); |
764 | 797 | ||
765 | if (llc_backlog_type(skb) == LLC_PACKET) { | 798 | if (likely(llc_backlog_type(skb) == LLC_PACKET)) { |
766 | if (llc->state > 1) /* not closed */ | 799 | if (likely(llc->state > 1)) /* not closed */ |
767 | rc = llc_conn_rcv(sk, skb); | 800 | rc = llc_conn_rcv(sk, skb); |
768 | else | 801 | else |
769 | goto out_kfree_skb; | 802 | goto out_kfree_skb; |
770 | } else if (llc_backlog_type(skb) == LLC_EVENT) { | 803 | } else if (llc_backlog_type(skb) == LLC_EVENT) { |
771 | /* timer expiration event */ | 804 | /* timer expiration event */ |
772 | if (llc->state > 1) /* not closed */ | 805 | if (likely(llc->state > 1)) /* not closed */ |
773 | rc = llc_conn_state_process(sk, skb); | 806 | rc = llc_conn_state_process(sk, skb); |
774 | else | 807 | else |
775 | goto out_kfree_skb; | 808 | goto out_kfree_skb; |
@@ -799,22 +832,22 @@ static void llc_sk_init(struct sock* sk) | |||
799 | llc->dec_step = llc->connect_step = 1; | 832 | llc->dec_step = llc->connect_step = 1; |
800 | 833 | ||
801 | init_timer(&llc->ack_timer.timer); | 834 | init_timer(&llc->ack_timer.timer); |
802 | llc->ack_timer.expire = LLC_ACK_TIME; | 835 | llc->ack_timer.expire = sysctl_llc2_ack_timeout; |
803 | llc->ack_timer.timer.data = (unsigned long)sk; | 836 | llc->ack_timer.timer.data = (unsigned long)sk; |
804 | llc->ack_timer.timer.function = llc_conn_ack_tmr_cb; | 837 | llc->ack_timer.timer.function = llc_conn_ack_tmr_cb; |
805 | 838 | ||
806 | init_timer(&llc->pf_cycle_timer.timer); | 839 | init_timer(&llc->pf_cycle_timer.timer); |
807 | llc->pf_cycle_timer.expire = LLC_P_TIME; | 840 | llc->pf_cycle_timer.expire = sysctl_llc2_p_timeout; |
808 | llc->pf_cycle_timer.timer.data = (unsigned long)sk; | 841 | llc->pf_cycle_timer.timer.data = (unsigned long)sk; |
809 | llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb; | 842 | llc->pf_cycle_timer.timer.function = llc_conn_pf_cycle_tmr_cb; |
810 | 843 | ||
811 | init_timer(&llc->rej_sent_timer.timer); | 844 | init_timer(&llc->rej_sent_timer.timer); |
812 | llc->rej_sent_timer.expire = LLC_REJ_TIME; | 845 | llc->rej_sent_timer.expire = sysctl_llc2_rej_timeout; |
813 | llc->rej_sent_timer.timer.data = (unsigned long)sk; | 846 | llc->rej_sent_timer.timer.data = (unsigned long)sk; |
814 | llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb; | 847 | llc->rej_sent_timer.timer.function = llc_conn_rej_tmr_cb; |
815 | 848 | ||
816 | init_timer(&llc->busy_state_timer.timer); | 849 | init_timer(&llc->busy_state_timer.timer); |
817 | llc->busy_state_timer.expire = LLC_BUSY_TIME; | 850 | llc->busy_state_timer.expire = sysctl_llc2_busy_timeout; |
818 | llc->busy_state_timer.timer.data = (unsigned long)sk; | 851 | llc->busy_state_timer.timer.data = (unsigned long)sk; |
819 | llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb; | 852 | llc->busy_state_timer.timer.function = llc_conn_busy_tmr_cb; |
820 | 853 | ||
@@ -834,7 +867,8 @@ static void llc_sk_init(struct sock* sk) | |||
834 | * Allocates a LLC sock and initializes it. Returns the new LLC sock | 867 | * Allocates a LLC sock and initializes it. Returns the new LLC sock |
835 | * or %NULL if there's no memory available for one | 868 | * or %NULL if there's no memory available for one |
836 | */ | 869 | */ |
837 | struct sock *llc_sk_alloc(int family, int priority, struct proto *prot) | 870 | struct sock *llc_sk_alloc(int family, unsigned int __nocast priority, |
871 | struct proto *prot) | ||
838 | { | 872 | { |
839 | struct sock *sk = sk_alloc(family, priority, prot, 1); | 873 | struct sock *sk = sk_alloc(family, priority, prot, 1); |
840 | 874 | ||
diff --git a/net/llc/llc_core.c b/net/llc/llc_core.c index 9727455bf0e7..ab0fcd32fd84 100644 --- a/net/llc/llc_core.c +++ b/net/llc/llc_core.c | |||
@@ -40,6 +40,7 @@ static struct llc_sap *llc_sap_alloc(void) | |||
40 | sap->state = LLC_SAP_STATE_ACTIVE; | 40 | sap->state = LLC_SAP_STATE_ACTIVE; |
41 | memcpy(sap->laddr.mac, llc_station_mac_sa, ETH_ALEN); | 41 | memcpy(sap->laddr.mac, llc_station_mac_sa, ETH_ALEN); |
42 | rwlock_init(&sap->sk_list.lock); | 42 | rwlock_init(&sap->sk_list.lock); |
43 | atomic_set(&sap->refcnt, 1); | ||
43 | } | 44 | } |
44 | return sap; | 45 | return sap; |
45 | } | 46 | } |
@@ -52,9 +53,7 @@ static struct llc_sap *llc_sap_alloc(void) | |||
52 | */ | 53 | */ |
53 | static void llc_add_sap(struct llc_sap *sap) | 54 | static void llc_add_sap(struct llc_sap *sap) |
54 | { | 55 | { |
55 | write_lock_bh(&llc_sap_list_lock); | ||
56 | list_add_tail(&sap->node, &llc_sap_list); | 56 | list_add_tail(&sap->node, &llc_sap_list); |
57 | write_unlock_bh(&llc_sap_list_lock); | ||
58 | } | 57 | } |
59 | 58 | ||
60 | /** | 59 | /** |
@@ -70,11 +69,25 @@ static void llc_del_sap(struct llc_sap *sap) | |||
70 | write_unlock_bh(&llc_sap_list_lock); | 69 | write_unlock_bh(&llc_sap_list_lock); |
71 | } | 70 | } |
72 | 71 | ||
72 | static struct llc_sap *__llc_sap_find(unsigned char sap_value) | ||
73 | { | ||
74 | struct llc_sap* sap; | ||
75 | |||
76 | list_for_each_entry(sap, &llc_sap_list, node) | ||
77 | if (sap->laddr.lsap == sap_value) | ||
78 | goto out; | ||
79 | sap = NULL; | ||
80 | out: | ||
81 | return sap; | ||
82 | } | ||
83 | |||
73 | /** | 84 | /** |
74 | * llc_sap_find - searchs a SAP in station | 85 | * llc_sap_find - searchs a SAP in station |
75 | * @sap_value: sap to be found | 86 | * @sap_value: sap to be found |
76 | * | 87 | * |
77 | * Searchs for a sap in the sap list of the LLC's station upon the sap ID. | 88 | * Searchs for a sap in the sap list of the LLC's station upon the sap ID. |
89 | * If the sap is found it will be refcounted and the user will have to do | ||
90 | * a llc_sap_put after use. | ||
78 | * Returns the sap or %NULL if not found. | 91 | * Returns the sap or %NULL if not found. |
79 | */ | 92 | */ |
80 | struct llc_sap *llc_sap_find(unsigned char sap_value) | 93 | struct llc_sap *llc_sap_find(unsigned char sap_value) |
@@ -82,11 +95,9 @@ struct llc_sap *llc_sap_find(unsigned char sap_value) | |||
82 | struct llc_sap* sap; | 95 | struct llc_sap* sap; |
83 | 96 | ||
84 | read_lock_bh(&llc_sap_list_lock); | 97 | read_lock_bh(&llc_sap_list_lock); |
85 | list_for_each_entry(sap, &llc_sap_list, node) | 98 | sap = __llc_sap_find(sap_value); |
86 | if (sap->laddr.lsap == sap_value) | 99 | if (sap) |
87 | goto out; | 100 | llc_sap_hold(sap); |
88 | sap = NULL; | ||
89 | out: | ||
90 | read_unlock_bh(&llc_sap_list_lock); | 101 | read_unlock_bh(&llc_sap_list_lock); |
91 | return sap; | 102 | return sap; |
92 | } | 103 | } |
@@ -106,19 +117,20 @@ struct llc_sap *llc_sap_open(unsigned char lsap, | |||
106 | struct packet_type *pt, | 117 | struct packet_type *pt, |
107 | struct net_device *orig_dev)) | 118 | struct net_device *orig_dev)) |
108 | { | 119 | { |
109 | struct llc_sap *sap = llc_sap_find(lsap); | 120 | struct llc_sap *sap = NULL; |
110 | 121 | ||
111 | if (sap) { /* SAP already exists */ | 122 | write_lock_bh(&llc_sap_list_lock); |
112 | sap = NULL; | 123 | if (__llc_sap_find(lsap)) /* SAP already exists */ |
113 | goto out; | 124 | goto out; |
114 | } | ||
115 | sap = llc_sap_alloc(); | 125 | sap = llc_sap_alloc(); |
116 | if (!sap) | 126 | if (!sap) |
117 | goto out; | 127 | goto out; |
118 | sap->laddr.lsap = lsap; | 128 | sap->laddr.lsap = lsap; |
119 | sap->rcv_func = func; | 129 | sap->rcv_func = func; |
130 | llc_sap_hold(sap); | ||
120 | llc_add_sap(sap); | 131 | llc_add_sap(sap); |
121 | out: | 132 | out: |
133 | write_unlock_bh(&llc_sap_list_lock); | ||
122 | return sap; | 134 | return sap; |
123 | } | 135 | } |
124 | 136 | ||
diff --git a/net/llc/llc_if.c b/net/llc/llc_if.c index 0f84f66018e4..ba90f7f0801a 100644 --- a/net/llc/llc_if.c +++ b/net/llc/llc_if.c | |||
@@ -47,14 +47,11 @@ int llc_build_and_send_pkt(struct sock *sk, struct sk_buff *skb) | |||
47 | int rc = -ECONNABORTED; | 47 | int rc = -ECONNABORTED; |
48 | struct llc_sock *llc = llc_sk(sk); | 48 | struct llc_sock *llc = llc_sk(sk); |
49 | 49 | ||
50 | if (llc->state == LLC_CONN_STATE_ADM) | 50 | if (unlikely(llc->state == LLC_CONN_STATE_ADM)) |
51 | goto out; | 51 | goto out; |
52 | rc = -EBUSY; | 52 | rc = -EBUSY; |
53 | if (llc_data_accept_state(llc->state)) { /* data_conn_refuse */ | 53 | if (unlikely(llc_data_accept_state(llc->state) || /* data_conn_refuse */ |
54 | llc->failed_data_req = 1; | 54 | llc->p_flag)) { |
55 | goto out; | ||
56 | } | ||
57 | if (llc->p_flag) { | ||
58 | llc->failed_data_req = 1; | 55 | llc->failed_data_req = 1; |
59 | goto out; | 56 | goto out; |
60 | } | 57 | } |
@@ -110,6 +107,7 @@ int llc_establish_connection(struct sock *sk, u8 *lmac, u8 *dmac, u8 dsap) | |||
110 | ev->type = LLC_CONN_EV_TYPE_PRIM; | 107 | ev->type = LLC_CONN_EV_TYPE_PRIM; |
111 | ev->prim = LLC_CONN_PRIM; | 108 | ev->prim = LLC_CONN_PRIM; |
112 | ev->prim_type = LLC_PRIM_TYPE_REQ; | 109 | ev->prim_type = LLC_PRIM_TYPE_REQ; |
110 | skb_set_owner_w(skb, sk); | ||
113 | rc = llc_conn_state_process(sk, skb); | 111 | rc = llc_conn_state_process(sk, skb); |
114 | } | 112 | } |
115 | out_put: | 113 | out_put: |
@@ -144,6 +142,7 @@ int llc_send_disc(struct sock *sk) | |||
144 | skb = alloc_skb(0, GFP_ATOMIC); | 142 | skb = alloc_skb(0, GFP_ATOMIC); |
145 | if (!skb) | 143 | if (!skb) |
146 | goto out; | 144 | goto out; |
145 | skb_set_owner_w(skb, sk); | ||
147 | sk->sk_state = TCP_CLOSING; | 146 | sk->sk_state = TCP_CLOSING; |
148 | ev = llc_conn_ev(skb); | 147 | ev = llc_conn_ev(skb); |
149 | ev->type = LLC_CONN_EV_TYPE_PRIM; | 148 | ev->type = LLC_CONN_EV_TYPE_PRIM; |
diff --git a/net/llc/llc_input.c b/net/llc/llc_input.c index 13b46240b7a1..8f3addf0724c 100644 --- a/net/llc/llc_input.c +++ b/net/llc/llc_input.c | |||
@@ -99,15 +99,19 @@ out: | |||
99 | static inline int llc_fixup_skb(struct sk_buff *skb) | 99 | static inline int llc_fixup_skb(struct sk_buff *skb) |
100 | { | 100 | { |
101 | u8 llc_len = 2; | 101 | u8 llc_len = 2; |
102 | struct llc_pdu_sn *pdu; | 102 | struct llc_pdu_un *pdu; |
103 | 103 | ||
104 | if (!pskb_may_pull(skb, sizeof(*pdu))) | 104 | if (unlikely(!pskb_may_pull(skb, sizeof(*pdu)))) |
105 | return 0; | 105 | return 0; |
106 | 106 | ||
107 | pdu = (struct llc_pdu_sn *)skb->data; | 107 | pdu = (struct llc_pdu_un *)skb->data; |
108 | if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) == LLC_PDU_TYPE_U) | 108 | if ((pdu->ctrl_1 & LLC_PDU_TYPE_MASK) == LLC_PDU_TYPE_U) |
109 | llc_len = 1; | 109 | llc_len = 1; |
110 | llc_len += 2; | 110 | llc_len += 2; |
111 | |||
112 | if (unlikely(!pskb_may_pull(skb, llc_len))) | ||
113 | return 0; | ||
114 | |||
111 | skb->h.raw += llc_len; | 115 | skb->h.raw += llc_len; |
112 | skb_pull(skb, llc_len); | 116 | skb_pull(skb, llc_len); |
113 | if (skb->protocol == htons(ETH_P_802_2)) { | 117 | if (skb->protocol == htons(ETH_P_802_2)) { |
@@ -166,17 +170,22 @@ int llc_rcv(struct sk_buff *skb, struct net_device *dev, | |||
166 | */ | 170 | */ |
167 | if (sap->rcv_func) { | 171 | if (sap->rcv_func) { |
168 | sap->rcv_func(skb, dev, pt, orig_dev); | 172 | sap->rcv_func(skb, dev, pt, orig_dev); |
169 | goto out; | 173 | goto out_put; |
170 | } | 174 | } |
171 | dest = llc_pdu_type(skb); | 175 | dest = llc_pdu_type(skb); |
172 | if (unlikely(!dest || !llc_type_handlers[dest - 1])) | 176 | if (unlikely(!dest || !llc_type_handlers[dest - 1])) |
173 | goto drop; | 177 | goto drop_put; |
174 | llc_type_handlers[dest - 1](sap, skb); | 178 | llc_type_handlers[dest - 1](sap, skb); |
179 | out_put: | ||
180 | llc_sap_put(sap); | ||
175 | out: | 181 | out: |
176 | return 0; | 182 | return 0; |
177 | drop: | 183 | drop: |
178 | kfree_skb(skb); | 184 | kfree_skb(skb); |
179 | goto out; | 185 | goto out; |
186 | drop_put: | ||
187 | kfree_skb(skb); | ||
188 | goto out_put; | ||
180 | handle_station: | 189 | handle_station: |
181 | if (!llc_station_handler) | 190 | if (!llc_station_handler) |
182 | goto drop; | 191 | goto drop; |
diff --git a/net/llc/llc_output.c b/net/llc/llc_output.c index ab5784cf163e..b4d55b6abb67 100644 --- a/net/llc/llc_output.c +++ b/net/llc/llc_output.c | |||
@@ -98,7 +98,7 @@ int llc_build_and_send_ui_pkt(struct llc_sap *sap, struct sk_buff *skb, | |||
98 | dsap, LLC_PDU_CMD); | 98 | dsap, LLC_PDU_CMD); |
99 | llc_pdu_init_as_ui_cmd(skb); | 99 | llc_pdu_init_as_ui_cmd(skb); |
100 | rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac); | 100 | rc = llc_mac_hdr_init(skb, skb->dev->dev_addr, dmac); |
101 | if (!rc) | 101 | if (likely(!rc)) |
102 | rc = dev_queue_xmit(skb); | 102 | rc = dev_queue_xmit(skb); |
103 | return rc; | 103 | return rc; |
104 | } | 104 | } |
diff --git a/net/llc/llc_proc.c b/net/llc/llc_proc.c index 36e8db3fa1a2..bd531cb235a7 100644 --- a/net/llc/llc_proc.c +++ b/net/llc/llc_proc.c | |||
@@ -134,7 +134,7 @@ static int llc_seq_socket_show(struct seq_file *seq, void *v) | |||
134 | llc_ui_format_mac(seq, llc->daddr.mac); | 134 | llc_ui_format_mac(seq, llc->daddr.mac); |
135 | seq_printf(seq, "@%02X %8d %8d %2d %3d %4d\n", llc->daddr.lsap, | 135 | seq_printf(seq, "@%02X %8d %8d %2d %3d %4d\n", llc->daddr.lsap, |
136 | atomic_read(&sk->sk_wmem_alloc), | 136 | atomic_read(&sk->sk_wmem_alloc), |
137 | atomic_read(&sk->sk_rmem_alloc), | 137 | atomic_read(&sk->sk_rmem_alloc) - llc->copied_seq, |
138 | sk->sk_state, | 138 | sk->sk_state, |
139 | sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : -1, | 139 | sk->sk_socket ? SOCK_INODE(sk->sk_socket)->i_uid : -1, |
140 | llc->link); | 140 | llc->link); |
diff --git a/net/llc/llc_s_ac.c b/net/llc/llc_s_ac.c index ed8ba7de6122..bb3580fb8cfe 100644 --- a/net/llc/llc_s_ac.c +++ b/net/llc/llc_s_ac.c | |||
@@ -58,7 +58,7 @@ int llc_sap_action_send_ui(struct llc_sap *sap, struct sk_buff *skb) | |||
58 | ev->daddr.lsap, LLC_PDU_CMD); | 58 | ev->daddr.lsap, LLC_PDU_CMD); |
59 | llc_pdu_init_as_ui_cmd(skb); | 59 | llc_pdu_init_as_ui_cmd(skb); |
60 | rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); | 60 | rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); |
61 | if (!rc) | 61 | if (likely(!rc)) |
62 | rc = dev_queue_xmit(skb); | 62 | rc = dev_queue_xmit(skb); |
63 | return rc; | 63 | return rc; |
64 | } | 64 | } |
@@ -81,7 +81,7 @@ int llc_sap_action_send_xid_c(struct llc_sap *sap, struct sk_buff *skb) | |||
81 | ev->daddr.lsap, LLC_PDU_CMD); | 81 | ev->daddr.lsap, LLC_PDU_CMD); |
82 | llc_pdu_init_as_xid_cmd(skb, LLC_XID_NULL_CLASS_2, 0); | 82 | llc_pdu_init_as_xid_cmd(skb, LLC_XID_NULL_CLASS_2, 0); |
83 | rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); | 83 | rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); |
84 | if (!rc) | 84 | if (likely(!rc)) |
85 | rc = dev_queue_xmit(skb); | 85 | rc = dev_queue_xmit(skb); |
86 | return rc; | 86 | return rc; |
87 | } | 87 | } |
@@ -103,15 +103,14 @@ int llc_sap_action_send_xid_r(struct llc_sap *sap, struct sk_buff *skb) | |||
103 | llc_pdu_decode_sa(skb, mac_da); | 103 | llc_pdu_decode_sa(skb, mac_da); |
104 | llc_pdu_decode_da(skb, mac_sa); | 104 | llc_pdu_decode_da(skb, mac_sa); |
105 | llc_pdu_decode_ssap(skb, &dsap); | 105 | llc_pdu_decode_ssap(skb, &dsap); |
106 | nskb = llc_alloc_frame(); | 106 | nskb = llc_alloc_frame(NULL, skb->dev); |
107 | if (!nskb) | 107 | if (!nskb) |
108 | goto out; | 108 | goto out; |
109 | nskb->dev = skb->dev; | ||
110 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap, | 109 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap, |
111 | LLC_PDU_RSP); | 110 | LLC_PDU_RSP); |
112 | llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0); | 111 | llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 0); |
113 | rc = llc_mac_hdr_init(nskb, mac_sa, mac_da); | 112 | rc = llc_mac_hdr_init(nskb, mac_sa, mac_da); |
114 | if (!rc) | 113 | if (likely(!rc)) |
115 | rc = dev_queue_xmit(nskb); | 114 | rc = dev_queue_xmit(nskb); |
116 | out: | 115 | out: |
117 | return rc; | 116 | return rc; |
@@ -135,7 +134,7 @@ int llc_sap_action_send_test_c(struct llc_sap *sap, struct sk_buff *skb) | |||
135 | ev->daddr.lsap, LLC_PDU_CMD); | 134 | ev->daddr.lsap, LLC_PDU_CMD); |
136 | llc_pdu_init_as_test_cmd(skb); | 135 | llc_pdu_init_as_test_cmd(skb); |
137 | rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); | 136 | rc = llc_mac_hdr_init(skb, ev->saddr.mac, ev->daddr.mac); |
138 | if (!rc) | 137 | if (likely(!rc)) |
139 | rc = dev_queue_xmit(skb); | 138 | rc = dev_queue_xmit(skb); |
140 | return rc; | 139 | return rc; |
141 | } | 140 | } |
@@ -149,15 +148,14 @@ int llc_sap_action_send_test_r(struct llc_sap *sap, struct sk_buff *skb) | |||
149 | llc_pdu_decode_sa(skb, mac_da); | 148 | llc_pdu_decode_sa(skb, mac_da); |
150 | llc_pdu_decode_da(skb, mac_sa); | 149 | llc_pdu_decode_da(skb, mac_sa); |
151 | llc_pdu_decode_ssap(skb, &dsap); | 150 | llc_pdu_decode_ssap(skb, &dsap); |
152 | nskb = llc_alloc_frame(); | 151 | nskb = llc_alloc_frame(NULL, skb->dev); |
153 | if (!nskb) | 152 | if (!nskb) |
154 | goto out; | 153 | goto out; |
155 | nskb->dev = skb->dev; | ||
156 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap, | 154 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, sap->laddr.lsap, dsap, |
157 | LLC_PDU_RSP); | 155 | LLC_PDU_RSP); |
158 | llc_pdu_init_as_test_rsp(nskb, skb); | 156 | llc_pdu_init_as_test_rsp(nskb, skb); |
159 | rc = llc_mac_hdr_init(nskb, mac_sa, mac_da); | 157 | rc = llc_mac_hdr_init(nskb, mac_sa, mac_da); |
160 | if (!rc) | 158 | if (likely(!rc)) |
161 | rc = dev_queue_xmit(nskb); | 159 | rc = dev_queue_xmit(nskb); |
162 | out: | 160 | out: |
163 | return rc; | 161 | return rc; |
diff --git a/net/llc/llc_sap.c b/net/llc/llc_sap.c index 34228ef14985..4029ceee9b91 100644 --- a/net/llc/llc_sap.c +++ b/net/llc/llc_sap.c | |||
@@ -26,11 +26,12 @@ | |||
26 | 26 | ||
27 | /** | 27 | /** |
28 | * llc_alloc_frame - allocates sk_buff for frame | 28 | * llc_alloc_frame - allocates sk_buff for frame |
29 | * @dev: network device this skb will be sent over | ||
29 | * | 30 | * |
30 | * Allocates an sk_buff for frame and initializes sk_buff fields. | 31 | * Allocates an sk_buff for frame and initializes sk_buff fields. |
31 | * Returns allocated skb or %NULL when out of memory. | 32 | * Returns allocated skb or %NULL when out of memory. |
32 | */ | 33 | */ |
33 | struct sk_buff *llc_alloc_frame(void) | 34 | struct sk_buff *llc_alloc_frame(struct sock *sk, struct net_device *dev) |
34 | { | 35 | { |
35 | struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC); | 36 | struct sk_buff *skb = alloc_skb(128, GFP_ATOMIC); |
36 | 37 | ||
@@ -38,18 +39,23 @@ struct sk_buff *llc_alloc_frame(void) | |||
38 | skb_reserve(skb, 50); | 39 | skb_reserve(skb, 50); |
39 | skb->nh.raw = skb->h.raw = skb->data; | 40 | skb->nh.raw = skb->h.raw = skb->data; |
40 | skb->protocol = htons(ETH_P_802_2); | 41 | skb->protocol = htons(ETH_P_802_2); |
41 | skb->dev = dev_base->next; | 42 | skb->dev = dev; |
42 | skb->mac.raw = skb->head; | 43 | skb->mac.raw = skb->head; |
44 | if (sk != NULL) | ||
45 | skb_set_owner_w(skb, sk); | ||
43 | } | 46 | } |
44 | return skb; | 47 | return skb; |
45 | } | 48 | } |
46 | 49 | ||
47 | void llc_save_primitive(struct sk_buff* skb, u8 prim) | 50 | void llc_save_primitive(struct sock *sk, struct sk_buff* skb, u8 prim) |
48 | { | 51 | { |
49 | struct sockaddr_llc *addr = llc_ui_skb_cb(skb); | 52 | struct sockaddr_llc *addr; |
50 | 53 | ||
54 | if (skb->sk->sk_type == SOCK_STREAM) /* See UNIX98 */ | ||
55 | return; | ||
51 | /* save primitive for use by the user. */ | 56 | /* save primitive for use by the user. */ |
52 | addr->sllc_family = skb->sk->sk_family; | 57 | addr = llc_ui_skb_cb(skb); |
58 | addr->sllc_family = sk->sk_family; | ||
53 | addr->sllc_arphrd = skb->dev->type; | 59 | addr->sllc_arphrd = skb->dev->type; |
54 | addr->sllc_test = prim == LLC_TEST_PRIM; | 60 | addr->sllc_test = prim == LLC_TEST_PRIM; |
55 | addr->sllc_xid = prim == LLC_XID_PRIM; | 61 | addr->sllc_xid = prim == LLC_XID_PRIM; |
@@ -189,7 +195,7 @@ static void llc_sap_state_process(struct llc_sap *sap, struct sk_buff *skb) | |||
189 | if (skb->sk->sk_state == TCP_LISTEN) | 195 | if (skb->sk->sk_state == TCP_LISTEN) |
190 | kfree_skb(skb); | 196 | kfree_skb(skb); |
191 | else { | 197 | else { |
192 | llc_save_primitive(skb, ev->prim); | 198 | llc_save_primitive(skb->sk, skb, ev->prim); |
193 | 199 | ||
194 | /* queue skb to the user. */ | 200 | /* queue skb to the user. */ |
195 | if (sock_queue_rcv_skb(skb->sk, skb)) | 201 | if (sock_queue_rcv_skb(skb->sk, skb)) |
@@ -308,7 +314,7 @@ void llc_sap_handler(struct llc_sap *sap, struct sk_buff *skb) | |||
308 | 314 | ||
309 | sk = llc_lookup_dgram(sap, &laddr); | 315 | sk = llc_lookup_dgram(sap, &laddr); |
310 | if (sk) { | 316 | if (sk) { |
311 | skb->sk = sk; | 317 | skb_set_owner_r(skb, sk); |
312 | llc_sap_rcv(sap, skb); | 318 | llc_sap_rcv(sap, skb); |
313 | sock_put(sk); | 319 | sock_put(sk); |
314 | } else | 320 | } else |
diff --git a/net/llc/llc_station.c b/net/llc/llc_station.c index 8fe48a24bad5..f37dbf8ef126 100644 --- a/net/llc/llc_station.c +++ b/net/llc/llc_station.c | |||
@@ -50,6 +50,10 @@ struct llc_station { | |||
50 | struct sk_buff_head mac_pdu_q; | 50 | struct sk_buff_head mac_pdu_q; |
51 | }; | 51 | }; |
52 | 52 | ||
53 | #define LLC_STATION_ACK_TIME (3 * HZ) | ||
54 | |||
55 | int sysctl_llc_station_ack_timeout = LLC_STATION_ACK_TIME; | ||
56 | |||
53 | /* Types of events (possible values in 'ev->type') */ | 57 | /* Types of events (possible values in 'ev->type') */ |
54 | #define LLC_STATION_EV_TYPE_SIMPLE 1 | 58 | #define LLC_STATION_EV_TYPE_SIMPLE 1 |
55 | #define LLC_STATION_EV_TYPE_CONDITION 2 | 59 | #define LLC_STATION_EV_TYPE_CONDITION 2 |
@@ -218,7 +222,8 @@ static void llc_station_send_pdu(struct sk_buff *skb) | |||
218 | 222 | ||
219 | static int llc_station_ac_start_ack_timer(struct sk_buff *skb) | 223 | static int llc_station_ac_start_ack_timer(struct sk_buff *skb) |
220 | { | 224 | { |
221 | mod_timer(&llc_main_station.ack_timer, jiffies + LLC_ACK_TIME * HZ); | 225 | mod_timer(&llc_main_station.ack_timer, |
226 | jiffies + sysctl_llc_station_ack_timeout); | ||
222 | return 0; | 227 | return 0; |
223 | } | 228 | } |
224 | 229 | ||
@@ -249,14 +254,14 @@ static int llc_station_ac_inc_xid_r_cnt_by_1(struct sk_buff *skb) | |||
249 | static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff *skb) | 254 | static int llc_station_ac_send_null_dsap_xid_c(struct sk_buff *skb) |
250 | { | 255 | { |
251 | int rc = 1; | 256 | int rc = 1; |
252 | struct sk_buff *nskb = llc_alloc_frame(); | 257 | struct sk_buff *nskb = llc_alloc_frame(NULL, skb->dev); |
253 | 258 | ||
254 | if (!nskb) | 259 | if (!nskb) |
255 | goto out; | 260 | goto out; |
256 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, 0, LLC_PDU_CMD); | 261 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, 0, LLC_PDU_CMD); |
257 | llc_pdu_init_as_xid_cmd(nskb, LLC_XID_NULL_CLASS_2, 127); | 262 | llc_pdu_init_as_xid_cmd(nskb, LLC_XID_NULL_CLASS_2, 127); |
258 | rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, llc_station_mac_sa); | 263 | rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, llc_station_mac_sa); |
259 | if (rc) | 264 | if (unlikely(rc)) |
260 | goto free; | 265 | goto free; |
261 | llc_station_send_pdu(nskb); | 266 | llc_station_send_pdu(nskb); |
262 | out: | 267 | out: |
@@ -270,18 +275,17 @@ static int llc_station_ac_send_xid_r(struct sk_buff *skb) | |||
270 | { | 275 | { |
271 | u8 mac_da[ETH_ALEN], dsap; | 276 | u8 mac_da[ETH_ALEN], dsap; |
272 | int rc = 1; | 277 | int rc = 1; |
273 | struct sk_buff* nskb = llc_alloc_frame(); | 278 | struct sk_buff* nskb = llc_alloc_frame(NULL, skb->dev); |
274 | 279 | ||
275 | if (!nskb) | 280 | if (!nskb) |
276 | goto out; | 281 | goto out; |
277 | rc = 0; | 282 | rc = 0; |
278 | nskb->dev = skb->dev; | ||
279 | llc_pdu_decode_sa(skb, mac_da); | 283 | llc_pdu_decode_sa(skb, mac_da); |
280 | llc_pdu_decode_ssap(skb, &dsap); | 284 | llc_pdu_decode_ssap(skb, &dsap); |
281 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP); | 285 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP); |
282 | llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 127); | 286 | llc_pdu_init_as_xid_rsp(nskb, LLC_XID_NULL_CLASS_2, 127); |
283 | rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da); | 287 | rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da); |
284 | if (rc) | 288 | if (unlikely(rc)) |
285 | goto free; | 289 | goto free; |
286 | llc_station_send_pdu(nskb); | 290 | llc_station_send_pdu(nskb); |
287 | out: | 291 | out: |
@@ -295,18 +299,17 @@ static int llc_station_ac_send_test_r(struct sk_buff *skb) | |||
295 | { | 299 | { |
296 | u8 mac_da[ETH_ALEN], dsap; | 300 | u8 mac_da[ETH_ALEN], dsap; |
297 | int rc = 1; | 301 | int rc = 1; |
298 | struct sk_buff *nskb = llc_alloc_frame(); | 302 | struct sk_buff *nskb = llc_alloc_frame(NULL, skb->dev); |
299 | 303 | ||
300 | if (!nskb) | 304 | if (!nskb) |
301 | goto out; | 305 | goto out; |
302 | rc = 0; | 306 | rc = 0; |
303 | nskb->dev = skb->dev; | ||
304 | llc_pdu_decode_sa(skb, mac_da); | 307 | llc_pdu_decode_sa(skb, mac_da); |
305 | llc_pdu_decode_ssap(skb, &dsap); | 308 | llc_pdu_decode_ssap(skb, &dsap); |
306 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP); | 309 | llc_pdu_header_init(nskb, LLC_PDU_TYPE_U, 0, dsap, LLC_PDU_RSP); |
307 | llc_pdu_init_as_test_rsp(nskb, skb); | 310 | llc_pdu_init_as_test_rsp(nskb, skb); |
308 | rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da); | 311 | rc = llc_mac_hdr_init(nskb, llc_station_mac_sa, mac_da); |
309 | if (rc) | 312 | if (unlikely(rc)) |
310 | goto free; | 313 | goto free; |
311 | llc_station_send_pdu(nskb); | 314 | llc_station_send_pdu(nskb); |
312 | out: | 315 | out: |
@@ -689,7 +692,8 @@ int __init llc_station_init(void) | |||
689 | init_timer(&llc_main_station.ack_timer); | 692 | init_timer(&llc_main_station.ack_timer); |
690 | llc_main_station.ack_timer.data = (unsigned long)&llc_main_station; | 693 | llc_main_station.ack_timer.data = (unsigned long)&llc_main_station; |
691 | llc_main_station.ack_timer.function = llc_station_ack_tmr_cb; | 694 | llc_main_station.ack_timer.function = llc_station_ack_tmr_cb; |
692 | 695 | llc_main_station.ack_timer.expires = jiffies + | |
696 | sysctl_llc_station_ack_timeout; | ||
693 | skb = alloc_skb(0, GFP_ATOMIC); | 697 | skb = alloc_skb(0, GFP_ATOMIC); |
694 | if (!skb) | 698 | if (!skb) |
695 | goto out; | 699 | goto out; |
@@ -697,7 +701,6 @@ int __init llc_station_init(void) | |||
697 | llc_set_station_handler(llc_station_rcv); | 701 | llc_set_station_handler(llc_station_rcv); |
698 | ev = llc_station_ev(skb); | 702 | ev = llc_station_ev(skb); |
699 | memset(ev, 0, sizeof(*ev)); | 703 | memset(ev, 0, sizeof(*ev)); |
700 | llc_main_station.ack_timer.expires = jiffies + 3 * HZ; | ||
701 | llc_main_station.maximum_retry = 1; | 704 | llc_main_station.maximum_retry = 1; |
702 | llc_main_station.state = LLC_STATION_STATE_DOWN; | 705 | llc_main_station.state = LLC_STATION_STATE_DOWN; |
703 | ev->type = LLC_STATION_EV_TYPE_SIMPLE; | 706 | ev->type = LLC_STATION_EV_TYPE_SIMPLE; |
diff --git a/net/llc/sysctl_net_llc.c b/net/llc/sysctl_net_llc.c new file mode 100644 index 000000000000..d1eaddb13633 --- /dev/null +++ b/net/llc/sysctl_net_llc.c | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | * sysctl_net_llc.c: sysctl interface to LLC net subsystem. | ||
3 | * | ||
4 | * Arnaldo Carvalho de Melo <acme@conectiva.com.br> | ||
5 | */ | ||
6 | |||
7 | #include <linux/config.h> | ||
8 | #include <linux/mm.h> | ||
9 | #include <linux/init.h> | ||
10 | #include <linux/sysctl.h> | ||
11 | #include <net/llc.h> | ||
12 | |||
13 | #ifndef CONFIG_SYSCTL | ||
14 | #error This file should not be compiled without CONFIG_SYSCTL defined | ||
15 | #endif | ||
16 | |||
17 | static struct ctl_table llc2_timeout_table[] = { | ||
18 | { | ||
19 | .ctl_name = NET_LLC2_ACK_TIMEOUT, | ||
20 | .procname = "ack", | ||
21 | .data = &sysctl_llc2_ack_timeout, | ||
22 | .maxlen = sizeof(long), | ||
23 | .mode = 0644, | ||
24 | .proc_handler = &proc_dointvec_jiffies, | ||
25 | .strategy = &sysctl_jiffies, | ||
26 | }, | ||
27 | { | ||
28 | .ctl_name = NET_LLC2_BUSY_TIMEOUT, | ||
29 | .procname = "busy", | ||
30 | .data = &sysctl_llc2_busy_timeout, | ||
31 | .maxlen = sizeof(long), | ||
32 | .mode = 0644, | ||
33 | .proc_handler = &proc_dointvec_jiffies, | ||
34 | .strategy = &sysctl_jiffies, | ||
35 | }, | ||
36 | { | ||
37 | .ctl_name = NET_LLC2_P_TIMEOUT, | ||
38 | .procname = "p", | ||
39 | .data = &sysctl_llc2_p_timeout, | ||
40 | .maxlen = sizeof(long), | ||
41 | .mode = 0644, | ||
42 | .proc_handler = &proc_dointvec_jiffies, | ||
43 | .strategy = &sysctl_jiffies, | ||
44 | }, | ||
45 | { | ||
46 | .ctl_name = NET_LLC2_REJ_TIMEOUT, | ||
47 | .procname = "rej", | ||
48 | .data = &sysctl_llc2_rej_timeout, | ||
49 | .maxlen = sizeof(long), | ||
50 | .mode = 0644, | ||
51 | .proc_handler = &proc_dointvec_jiffies, | ||
52 | .strategy = &sysctl_jiffies, | ||
53 | }, | ||
54 | { 0 }, | ||
55 | }; | ||
56 | |||
57 | static struct ctl_table llc_station_table[] = { | ||
58 | { | ||
59 | .ctl_name = NET_LLC_STATION_ACK_TIMEOUT, | ||
60 | .procname = "ack_timeout", | ||
61 | .data = &sysctl_llc_station_ack_timeout, | ||
62 | .maxlen = sizeof(long), | ||
63 | .mode = 0644, | ||
64 | .proc_handler = &proc_dointvec_jiffies, | ||
65 | .strategy = &sysctl_jiffies, | ||
66 | }, | ||
67 | { 0 }, | ||
68 | }; | ||
69 | |||
70 | static struct ctl_table llc2_dir_timeout_table[] = { | ||
71 | { | ||
72 | .ctl_name = NET_LLC2, | ||
73 | .procname = "timeout", | ||
74 | .mode = 0555, | ||
75 | .child = llc2_timeout_table, | ||
76 | }, | ||
77 | { 0 }, | ||
78 | }; | ||
79 | |||
80 | static struct ctl_table llc_table[] = { | ||
81 | { | ||
82 | .ctl_name = NET_LLC2, | ||
83 | .procname = "llc2", | ||
84 | .mode = 0555, | ||
85 | .child = llc2_dir_timeout_table, | ||
86 | }, | ||
87 | { | ||
88 | .ctl_name = NET_LLC_STATION, | ||
89 | .procname = "station", | ||
90 | .mode = 0555, | ||
91 | .child = llc_station_table, | ||
92 | }, | ||
93 | { 0 }, | ||
94 | }; | ||
95 | |||
96 | static struct ctl_table llc_dir_table[] = { | ||
97 | { | ||
98 | .ctl_name = NET_LLC, | ||
99 | .procname = "llc", | ||
100 | .mode = 0555, | ||
101 | .child = llc_table, | ||
102 | }, | ||
103 | { 0 }, | ||
104 | }; | ||
105 | |||
106 | static struct ctl_table llc_root_table[] = { | ||
107 | { | ||
108 | .ctl_name = CTL_NET, | ||
109 | .procname = "net", | ||
110 | .mode = 0555, | ||
111 | .child = llc_dir_table, | ||
112 | }, | ||
113 | { 0 }, | ||
114 | }; | ||
115 | |||
116 | static struct ctl_table_header *llc_table_header; | ||
117 | |||
118 | int __init llc_sysctl_init(void) | ||
119 | { | ||
120 | llc_table_header = register_sysctl_table(llc_root_table, 1); | ||
121 | |||
122 | return llc_table_header ? 0 : -ENOMEM; | ||
123 | } | ||
124 | |||
125 | void llc_sysctl_exit(void) | ||
126 | { | ||
127 | if (llc_table_header) { | ||
128 | unregister_sysctl_table(llc_table_header); | ||
129 | llc_table_header = NULL; | ||
130 | } | ||
131 | } | ||
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c index ff5601ceedcb..efcd10f996ba 100644 --- a/net/netfilter/nfnetlink_log.c +++ b/net/netfilter/nfnetlink_log.c | |||
@@ -494,8 +494,8 @@ __build_packet_message(struct nfulnl_instance *inst, | |||
494 | if (skb->tstamp.off_sec) { | 494 | if (skb->tstamp.off_sec) { |
495 | struct nfulnl_msg_packet_timestamp ts; | 495 | struct nfulnl_msg_packet_timestamp ts; |
496 | 496 | ||
497 | ts.sec = cpu_to_be64(skb_tv_base.tv_sec + skb->tstamp.off_sec); | 497 | ts.sec = cpu_to_be64(skb->tstamp.off_sec); |
498 | ts.usec = cpu_to_be64(skb_tv_base.tv_usec + skb->tstamp.off_usec); | 498 | ts.usec = cpu_to_be64(skb->tstamp.off_usec); |
499 | 499 | ||
500 | NFA_PUT(inst->skb, NFULA_TIMESTAMP, sizeof(ts), &ts); | 500 | NFA_PUT(inst->skb, NFULA_TIMESTAMP, sizeof(ts), &ts); |
501 | } | 501 | } |
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c index f81fe8c52e99..eaa44c49567b 100644 --- a/net/netfilter/nfnetlink_queue.c +++ b/net/netfilter/nfnetlink_queue.c | |||
@@ -492,8 +492,8 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue, | |||
492 | if (entry->skb->tstamp.off_sec) { | 492 | if (entry->skb->tstamp.off_sec) { |
493 | struct nfqnl_msg_packet_timestamp ts; | 493 | struct nfqnl_msg_packet_timestamp ts; |
494 | 494 | ||
495 | ts.sec = cpu_to_be64(skb_tv_base.tv_sec + entry->skb->tstamp.off_sec); | 495 | ts.sec = cpu_to_be64(entry->skb->tstamp.off_sec); |
496 | ts.usec = cpu_to_be64(skb_tv_base.tv_usec + entry->skb->tstamp.off_usec); | 496 | ts.usec = cpu_to_be64(entry->skb->tstamp.off_usec); |
497 | 497 | ||
498 | NFA_PUT(skb, NFQA_TIMESTAMP, sizeof(ts), &ts); | 498 | NFA_PUT(skb, NFQA_TIMESTAMP, sizeof(ts), &ts); |
499 | } | 499 | } |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index ee865d88183b..499ae3df4a44 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
@@ -654,8 +654,8 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe | |||
654 | __net_timestamp(skb); | 654 | __net_timestamp(skb); |
655 | sock_enable_timestamp(sk); | 655 | sock_enable_timestamp(sk); |
656 | } | 656 | } |
657 | h->tp_sec = skb_tv_base.tv_sec + skb->tstamp.off_sec; | 657 | h->tp_sec = skb->tstamp.off_sec; |
658 | h->tp_usec = skb_tv_base.tv_usec + skb->tstamp.off_usec; | 658 | h->tp_usec = skb->tstamp.off_usec; |
659 | 659 | ||
660 | sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h))); | 660 | sll = (struct sockaddr_ll*)((u8*)h + TPACKET_ALIGN(sizeof(*h))); |
661 | sll->sll_halen = 0; | 661 | sll->sll_halen = 0; |
@@ -761,12 +761,6 @@ static int packet_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
761 | if (dev->hard_header) { | 761 | if (dev->hard_header) { |
762 | int res; | 762 | int res; |
763 | err = -EINVAL; | 763 | err = -EINVAL; |
764 | if (saddr) { | ||
765 | if (saddr->sll_halen != dev->addr_len) | ||
766 | goto out_free; | ||
767 | if (saddr->sll_hatype != dev->type) | ||
768 | goto out_free; | ||
769 | } | ||
770 | res = dev->hard_header(skb, dev, ntohs(proto), addr, NULL, len); | 764 | res = dev->hard_header(skb, dev, ntohs(proto), addr, NULL, len); |
771 | if (sock->type != SOCK_DGRAM) { | 765 | if (sock->type != SOCK_DGRAM) { |
772 | skb->tail = skb->data; | 766 | skb->tail = skb->data; |
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 5acb1680524a..829fdbc4400b 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -1472,22 +1472,25 @@ static const char banner[] = KERN_INFO "F6FBB/G4KLX ROSE for Linux. Version 0.62 | |||
1472 | static int __init rose_proto_init(void) | 1472 | static int __init rose_proto_init(void) |
1473 | { | 1473 | { |
1474 | int i; | 1474 | int i; |
1475 | int rc = proto_register(&rose_proto, 0); | 1475 | int rc; |
1476 | 1476 | ||
1477 | if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) { | ||
1478 | printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n"); | ||
1479 | rc = -EINVAL; | ||
1480 | goto out; | ||
1481 | } | ||
1482 | |||
1483 | rc = proto_register(&rose_proto, 0); | ||
1477 | if (rc != 0) | 1484 | if (rc != 0) |
1478 | goto out; | 1485 | goto out; |
1479 | 1486 | ||
1480 | rose_callsign = null_ax25_address; | 1487 | rose_callsign = null_ax25_address; |
1481 | 1488 | ||
1482 | if (rose_ndevs > 0x7FFFFFFF/sizeof(struct net_device *)) { | ||
1483 | printk(KERN_ERR "ROSE: rose_proto_init - rose_ndevs parameter to large\n"); | ||
1484 | return -1; | ||
1485 | } | ||
1486 | |||
1487 | dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL); | 1489 | dev_rose = kmalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL); |
1488 | if (dev_rose == NULL) { | 1490 | if (dev_rose == NULL) { |
1489 | printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n"); | 1491 | printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n"); |
1490 | return -1; | 1492 | rc = -ENOMEM; |
1493 | goto out_proto_unregister; | ||
1491 | } | 1494 | } |
1492 | 1495 | ||
1493 | memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*)); | 1496 | memset(dev_rose, 0x00, rose_ndevs * sizeof(struct net_device*)); |
@@ -1500,10 +1503,12 @@ static int __init rose_proto_init(void) | |||
1500 | name, rose_setup); | 1503 | name, rose_setup); |
1501 | if (!dev) { | 1504 | if (!dev) { |
1502 | printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n"); | 1505 | printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate memory\n"); |
1506 | rc = -ENOMEM; | ||
1503 | goto fail; | 1507 | goto fail; |
1504 | } | 1508 | } |
1505 | if (register_netdev(dev)) { | 1509 | rc = register_netdev(dev); |
1506 | printk(KERN_ERR "ROSE: netdevice regeistration failed\n"); | 1510 | if (rc) { |
1511 | printk(KERN_ERR "ROSE: netdevice registration failed\n"); | ||
1507 | free_netdev(dev); | 1512 | free_netdev(dev); |
1508 | goto fail; | 1513 | goto fail; |
1509 | } | 1514 | } |
@@ -1536,8 +1541,9 @@ fail: | |||
1536 | free_netdev(dev_rose[i]); | 1541 | free_netdev(dev_rose[i]); |
1537 | } | 1542 | } |
1538 | kfree(dev_rose); | 1543 | kfree(dev_rose); |
1544 | out_proto_unregister: | ||
1539 | proto_unregister(&rose_proto); | 1545 | proto_unregister(&rose_proto); |
1540 | return -ENOMEM; | 1546 | goto out; |
1541 | } | 1547 | } |
1542 | module_init(rose_proto_init); | 1548 | module_init(rose_proto_init); |
1543 | 1549 | ||
diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index 00eae5f9a01a..cf68a59fdc5a 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c | |||
@@ -393,10 +393,10 @@ META_COLLECTOR(int_sk_route_caps) | |||
393 | dst->value = skb->sk->sk_route_caps; | 393 | dst->value = skb->sk->sk_route_caps; |
394 | } | 394 | } |
395 | 395 | ||
396 | META_COLLECTOR(int_sk_hashent) | 396 | META_COLLECTOR(int_sk_hash) |
397 | { | 397 | { |
398 | SKIP_NONLOCAL(skb); | 398 | SKIP_NONLOCAL(skb); |
399 | dst->value = skb->sk->sk_hashent; | 399 | dst->value = skb->sk->sk_hash; |
400 | } | 400 | } |
401 | 401 | ||
402 | META_COLLECTOR(int_sk_lingertime) | 402 | META_COLLECTOR(int_sk_lingertime) |
@@ -515,7 +515,7 @@ static struct meta_ops __meta_ops[TCF_META_TYPE_MAX+1][TCF_META_ID_MAX+1] = { | |||
515 | [META_ID(SK_FORWARD_ALLOCS)] = META_FUNC(int_sk_fwd_alloc), | 515 | [META_ID(SK_FORWARD_ALLOCS)] = META_FUNC(int_sk_fwd_alloc), |
516 | [META_ID(SK_ALLOCS)] = META_FUNC(int_sk_alloc), | 516 | [META_ID(SK_ALLOCS)] = META_FUNC(int_sk_alloc), |
517 | [META_ID(SK_ROUTE_CAPS)] = META_FUNC(int_sk_route_caps), | 517 | [META_ID(SK_ROUTE_CAPS)] = META_FUNC(int_sk_route_caps), |
518 | [META_ID(SK_HASHENT)] = META_FUNC(int_sk_hashent), | 518 | [META_ID(SK_HASH)] = META_FUNC(int_sk_hash), |
519 | [META_ID(SK_LINGERTIME)] = META_FUNC(int_sk_lingertime), | 519 | [META_ID(SK_LINGERTIME)] = META_FUNC(int_sk_lingertime), |
520 | [META_ID(SK_ACK_BACKLOG)] = META_FUNC(int_sk_ack_bl), | 520 | [META_ID(SK_ACK_BACKLOG)] = META_FUNC(int_sk_ack_bl), |
521 | [META_ID(SK_MAX_ACK_BACKLOG)] = META_FUNC(int_sk_max_ack_bl), | 521 | [META_ID(SK_MAX_ACK_BACKLOG)] = META_FUNC(int_sk_max_ack_bl), |
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index e7025be77691..f01d1c9002a1 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
@@ -147,7 +147,7 @@ static void sctp_v4_copy_addrlist(struct list_head *addrlist, | |||
147 | struct sctp_sockaddr_entry *addr; | 147 | struct sctp_sockaddr_entry *addr; |
148 | 148 | ||
149 | rcu_read_lock(); | 149 | rcu_read_lock(); |
150 | if ((in_dev = __in_dev_get(dev)) == NULL) { | 150 | if ((in_dev = __in_dev_get_rcu(dev)) == NULL) { |
151 | rcu_read_unlock(); | 151 | rcu_read_unlock(); |
152 | return; | 152 | return; |
153 | } | 153 | } |
diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c index 86073df418f5..505c7de10c50 100644 --- a/net/sctp/sm_statefuns.c +++ b/net/sctp/sm_statefuns.c | |||
@@ -2414,6 +2414,17 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | |||
2414 | skb_pull(chunk->skb, sizeof(sctp_shutdownhdr_t)); | 2414 | skb_pull(chunk->skb, sizeof(sctp_shutdownhdr_t)); |
2415 | chunk->subh.shutdown_hdr = sdh; | 2415 | chunk->subh.shutdown_hdr = sdh; |
2416 | 2416 | ||
2417 | /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT | ||
2418 | * When a peer sends a SHUTDOWN, SCTP delivers this notification to | ||
2419 | * inform the application that it should cease sending data. | ||
2420 | */ | ||
2421 | ev = sctp_ulpevent_make_shutdown_event(asoc, 0, GFP_ATOMIC); | ||
2422 | if (!ev) { | ||
2423 | disposition = SCTP_DISPOSITION_NOMEM; | ||
2424 | goto out; | ||
2425 | } | ||
2426 | sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); | ||
2427 | |||
2417 | /* Upon the reception of the SHUTDOWN, the peer endpoint shall | 2428 | /* Upon the reception of the SHUTDOWN, the peer endpoint shall |
2418 | * - enter the SHUTDOWN-RECEIVED state, | 2429 | * - enter the SHUTDOWN-RECEIVED state, |
2419 | * - stop accepting new data from its SCTP user | 2430 | * - stop accepting new data from its SCTP user |
@@ -2439,17 +2450,6 @@ sctp_disposition_t sctp_sf_do_9_2_shutdown(const struct sctp_endpoint *ep, | |||
2439 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN, | 2450 | sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN, |
2440 | SCTP_U32(chunk->subh.shutdown_hdr->cum_tsn_ack)); | 2451 | SCTP_U32(chunk->subh.shutdown_hdr->cum_tsn_ack)); |
2441 | 2452 | ||
2442 | /* API 5.3.1.5 SCTP_SHUTDOWN_EVENT | ||
2443 | * When a peer sends a SHUTDOWN, SCTP delivers this notification to | ||
2444 | * inform the application that it should cease sending data. | ||
2445 | */ | ||
2446 | ev = sctp_ulpevent_make_shutdown_event(asoc, 0, GFP_ATOMIC); | ||
2447 | if (!ev) { | ||
2448 | disposition = SCTP_DISPOSITION_NOMEM; | ||
2449 | goto out; | ||
2450 | } | ||
2451 | sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); | ||
2452 | |||
2453 | out: | 2453 | out: |
2454 | return disposition; | 2454 | return disposition; |
2455 | } | 2455 | } |
diff --git a/net/socket.c b/net/socket.c index f9264472377f..3145103cdf54 100644 --- a/net/socket.c +++ b/net/socket.c | |||
@@ -1145,8 +1145,11 @@ static int __sock_create(int family, int type, int protocol, struct socket **res | |||
1145 | if (!try_module_get(net_families[family]->owner)) | 1145 | if (!try_module_get(net_families[family]->owner)) |
1146 | goto out_release; | 1146 | goto out_release; |
1147 | 1147 | ||
1148 | if ((err = net_families[family]->create(sock, protocol)) < 0) | 1148 | if ((err = net_families[family]->create(sock, protocol)) < 0) { |
1149 | sock->ops = NULL; | ||
1149 | goto out_module_put; | 1150 | goto out_module_put; |
1151 | } | ||
1152 | |||
1150 | /* | 1153 | /* |
1151 | * Now to bump the refcnt of the [loadable] module that owns this | 1154 | * Now to bump the refcnt of the [loadable] module that owns this |
1152 | * socket at sock_release time we decrement its refcnt. | 1155 | * socket at sock_release time we decrement its refcnt. |
@@ -1360,16 +1363,16 @@ asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, int _ | |||
1360 | newsock->type = sock->type; | 1363 | newsock->type = sock->type; |
1361 | newsock->ops = sock->ops; | 1364 | newsock->ops = sock->ops; |
1362 | 1365 | ||
1363 | err = security_socket_accept(sock, newsock); | ||
1364 | if (err) | ||
1365 | goto out_release; | ||
1366 | |||
1367 | /* | 1366 | /* |
1368 | * We don't need try_module_get here, as the listening socket (sock) | 1367 | * We don't need try_module_get here, as the listening socket (sock) |
1369 | * has the protocol module (sock->ops->owner) held. | 1368 | * has the protocol module (sock->ops->owner) held. |
1370 | */ | 1369 | */ |
1371 | __module_get(newsock->ops->owner); | 1370 | __module_get(newsock->ops->owner); |
1372 | 1371 | ||
1372 | err = security_socket_accept(sock, newsock); | ||
1373 | if (err) | ||
1374 | goto out_release; | ||
1375 | |||
1373 | err = sock->ops->accept(sock, newsock, sock->file->f_flags); | 1376 | err = sock->ops->accept(sock, newsock, sock->file->f_flags); |
1374 | if (err < 0) | 1377 | if (err < 0) |
1375 | goto out_release; | 1378 | goto out_release; |
@@ -1700,7 +1703,9 @@ asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags) | |||
1700 | struct socket *sock; | 1703 | struct socket *sock; |
1701 | char address[MAX_SOCK_ADDR]; | 1704 | char address[MAX_SOCK_ADDR]; |
1702 | struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; | 1705 | struct iovec iovstack[UIO_FASTIOV], *iov = iovstack; |
1703 | unsigned char ctl[sizeof(struct cmsghdr) + 20]; /* 20 is size of ipv6_pktinfo */ | 1706 | unsigned char ctl[sizeof(struct cmsghdr) + 20] |
1707 | __attribute__ ((aligned (sizeof(__kernel_size_t)))); | ||
1708 | /* 20 is size of ipv6_pktinfo */ | ||
1704 | unsigned char *ctl_buf = ctl; | 1709 | unsigned char *ctl_buf = ctl; |
1705 | struct msghdr msg_sys; | 1710 | struct msghdr msg_sys; |
1706 | int err, ctl_len, iov_size, total_len; | 1711 | int err, ctl_len, iov_size, total_len; |
diff --git a/net/sysctl_net.c b/net/sysctl_net.c index c5241fcbb966..55538f6b60ff 100644 --- a/net/sysctl_net.c +++ b/net/sysctl_net.c | |||
@@ -16,6 +16,8 @@ | |||
16 | #include <linux/mm.h> | 16 | #include <linux/mm.h> |
17 | #include <linux/sysctl.h> | 17 | #include <linux/sysctl.h> |
18 | 18 | ||
19 | #include <net/sock.h> | ||
20 | |||
19 | #ifdef CONFIG_INET | 21 | #ifdef CONFIG_INET |
20 | #include <net/ip.h> | 22 | #include <net/ip.h> |
21 | #endif | 23 | #endif |