diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-10-18 16:50:52 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2005-10-18 16:50:52 -0400 |
commit | cff6bf970965c98c62007fc8a36527fd147fe233 (patch) | |
tree | 2791f2208b54ade86625af416ff5342f11282f0c /net | |
parent | 6cd7525a00f3b926e8bd2e402954ed3e09a8e924 (diff) | |
parent | 39ca371c45b04cd50d0974030ae051906fc516b6 (diff) |
Merge /home/trondmy/scm/kernel/git/torvalds/linux-2.6
Diffstat (limited to 'net')
133 files changed, 1787 insertions, 1119 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..3060fd0ba4b9 100644 --- a/net/atm/addr.c +++ b/net/atm/addr.c | |||
@@ -44,29 +44,43 @@ static void notify_sigd(struct atm_dev *dev) | |||
44 | sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL); | 44 | sigd_enq(NULL, as_itf_notify, NULL, &pvc, NULL); |
45 | } | 45 | } |
46 | 46 | ||
47 | void atm_reset_addr(struct atm_dev *dev) | 47 | void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t atype) |
48 | { | 48 | { |
49 | unsigned long flags; | 49 | unsigned long flags; |
50 | struct atm_dev_addr *this, *p; | 50 | struct atm_dev_addr *this, *p; |
51 | struct list_head *head; | ||
51 | 52 | ||
52 | spin_lock_irqsave(&dev->lock, flags); | 53 | spin_lock_irqsave(&dev->lock, flags); |
53 | list_for_each_entry_safe(this, p, &dev->local, entry) | 54 | if (atype == ATM_ADDR_LECS) |
54 | kfree(this); | 55 | head = &dev->lecs; |
56 | else | ||
57 | head = &dev->local; | ||
58 | list_for_each_entry_safe(this, p, head, entry) { | ||
59 | list_del(&this->entry); | ||
60 | kfree(this); | ||
61 | } | ||
55 | spin_unlock_irqrestore(&dev->lock, flags); | 62 | spin_unlock_irqrestore(&dev->lock, flags); |
56 | notify_sigd(dev); | 63 | if (head == &dev->local) |
64 | notify_sigd(dev); | ||
57 | } | 65 | } |
58 | 66 | ||
59 | int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) | 67 | int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr, |
68 | enum atm_addr_type_t atype) | ||
60 | { | 69 | { |
61 | unsigned long flags; | 70 | unsigned long flags; |
62 | struct atm_dev_addr *this; | 71 | struct atm_dev_addr *this; |
72 | struct list_head *head; | ||
63 | int error; | 73 | int error; |
64 | 74 | ||
65 | error = check_addr(addr); | 75 | error = check_addr(addr); |
66 | if (error) | 76 | if (error) |
67 | return error; | 77 | return error; |
68 | spin_lock_irqsave(&dev->lock, flags); | 78 | spin_lock_irqsave(&dev->lock, flags); |
69 | list_for_each_entry(this, &dev->local, entry) { | 79 | if (atype == ATM_ADDR_LECS) |
80 | head = &dev->lecs; | ||
81 | else | ||
82 | head = &dev->local; | ||
83 | list_for_each_entry(this, head, entry) { | ||
70 | if (identical(&this->addr, addr)) { | 84 | if (identical(&this->addr, addr)) { |
71 | spin_unlock_irqrestore(&dev->lock, flags); | 85 | spin_unlock_irqrestore(&dev->lock, flags); |
72 | return -EEXIST; | 86 | return -EEXIST; |
@@ -78,28 +92,36 @@ int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) | |||
78 | return -ENOMEM; | 92 | return -ENOMEM; |
79 | } | 93 | } |
80 | this->addr = *addr; | 94 | this->addr = *addr; |
81 | list_add(&this->entry, &dev->local); | 95 | list_add(&this->entry, head); |
82 | spin_unlock_irqrestore(&dev->lock, flags); | 96 | spin_unlock_irqrestore(&dev->lock, flags); |
83 | notify_sigd(dev); | 97 | if (head == &dev->local) |
98 | notify_sigd(dev); | ||
84 | return 0; | 99 | return 0; |
85 | } | 100 | } |
86 | 101 | ||
87 | int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) | 102 | int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr, |
103 | enum atm_addr_type_t atype) | ||
88 | { | 104 | { |
89 | unsigned long flags; | 105 | unsigned long flags; |
90 | struct atm_dev_addr *this; | 106 | struct atm_dev_addr *this; |
107 | struct list_head *head; | ||
91 | int error; | 108 | int error; |
92 | 109 | ||
93 | error = check_addr(addr); | 110 | error = check_addr(addr); |
94 | if (error) | 111 | if (error) |
95 | return error; | 112 | return error; |
96 | spin_lock_irqsave(&dev->lock, flags); | 113 | spin_lock_irqsave(&dev->lock, flags); |
97 | list_for_each_entry(this, &dev->local, entry) { | 114 | if (atype == ATM_ADDR_LECS) |
115 | head = &dev->lecs; | ||
116 | else | ||
117 | head = &dev->local; | ||
118 | list_for_each_entry(this, head, entry) { | ||
98 | if (identical(&this->addr, addr)) { | 119 | if (identical(&this->addr, addr)) { |
99 | list_del(&this->entry); | 120 | list_del(&this->entry); |
100 | spin_unlock_irqrestore(&dev->lock, flags); | 121 | spin_unlock_irqrestore(&dev->lock, flags); |
101 | kfree(this); | 122 | kfree(this); |
102 | notify_sigd(dev); | 123 | if (head == &dev->local) |
124 | notify_sigd(dev); | ||
103 | return 0; | 125 | return 0; |
104 | } | 126 | } |
105 | } | 127 | } |
@@ -108,22 +130,27 @@ int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr) | |||
108 | } | 130 | } |
109 | 131 | ||
110 | int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf, | 132 | int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user * buf, |
111 | size_t size) | 133 | size_t size, enum atm_addr_type_t atype) |
112 | { | 134 | { |
113 | unsigned long flags; | 135 | unsigned long flags; |
114 | struct atm_dev_addr *this; | 136 | struct atm_dev_addr *this; |
137 | struct list_head *head; | ||
115 | int total = 0, error; | 138 | int total = 0, error; |
116 | struct sockaddr_atmsvc *tmp_buf, *tmp_bufp; | 139 | struct sockaddr_atmsvc *tmp_buf, *tmp_bufp; |
117 | 140 | ||
118 | spin_lock_irqsave(&dev->lock, flags); | 141 | spin_lock_irqsave(&dev->lock, flags); |
119 | list_for_each_entry(this, &dev->local, entry) | 142 | if (atype == ATM_ADDR_LECS) |
143 | head = &dev->lecs; | ||
144 | else | ||
145 | head = &dev->local; | ||
146 | list_for_each_entry(this, head, entry) | ||
120 | total += sizeof(struct sockaddr_atmsvc); | 147 | total += sizeof(struct sockaddr_atmsvc); |
121 | tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC); | 148 | tmp_buf = tmp_bufp = kmalloc(total, GFP_ATOMIC); |
122 | if (!tmp_buf) { | 149 | if (!tmp_buf) { |
123 | spin_unlock_irqrestore(&dev->lock, flags); | 150 | spin_unlock_irqrestore(&dev->lock, flags); |
124 | return -ENOMEM; | 151 | return -ENOMEM; |
125 | } | 152 | } |
126 | list_for_each_entry(this, &dev->local, entry) | 153 | list_for_each_entry(this, head, entry) |
127 | memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc)); | 154 | memcpy(tmp_bufp++, &this->addr, sizeof(struct sockaddr_atmsvc)); |
128 | spin_unlock_irqrestore(&dev->lock, flags); | 155 | spin_unlock_irqrestore(&dev->lock, flags); |
129 | error = total > size ? -E2BIG : total; | 156 | error = total > size ? -E2BIG : total; |
diff --git a/net/atm/addr.h b/net/atm/addr.h index 3099d21feeaa..f39433ad45da 100644 --- a/net/atm/addr.h +++ b/net/atm/addr.h | |||
@@ -9,10 +9,12 @@ | |||
9 | #include <linux/atm.h> | 9 | #include <linux/atm.h> |
10 | #include <linux/atmdev.h> | 10 | #include <linux/atmdev.h> |
11 | 11 | ||
12 | 12 | void atm_reset_addr(struct atm_dev *dev, enum atm_addr_type_t type); | |
13 | void atm_reset_addr(struct atm_dev *dev); | 13 | int atm_add_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr, |
14 | int atm_add_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr); | 14 | enum atm_addr_type_t type); |
15 | int atm_del_addr(struct atm_dev *dev,struct sockaddr_atmsvc *addr); | 15 | int atm_del_addr(struct atm_dev *dev, struct sockaddr_atmsvc *addr, |
16 | int atm_get_addr(struct atm_dev *dev,struct sockaddr_atmsvc __user *buf,size_t size); | 16 | enum atm_addr_type_t type); |
17 | int atm_get_addr(struct atm_dev *dev, struct sockaddr_atmsvc __user *buf, | ||
18 | size_t size, enum atm_addr_type_t type); | ||
17 | 19 | ||
18 | #endif | 20 | #endif |
diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c index b2113c3454ae..223c7ad5bd0f 100644 --- a/net/atm/atm_misc.c +++ b/net/atm/atm_misc.c | |||
@@ -25,7 +25,7 @@ int atm_charge(struct atm_vcc *vcc,int truesize) | |||
25 | 25 | ||
26 | 26 | ||
27 | struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, | 27 | struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc,int pdu_size, |
28 | int gfp_flags) | 28 | gfp_t gfp_flags) |
29 | { | 29 | { |
30 | struct sock *sk = sk_atm(vcc); | 30 | struct sock *sk = sk_atm(vcc); |
31 | int guess = atm_guess_pdu2truesize(pdu_size); | 31 | int guess = atm_guess_pdu2truesize(pdu_size); |
diff --git a/net/atm/br2684.c b/net/atm/br2684.c index 289956c4dd3e..72f3f7b8de80 100644 --- a/net/atm/br2684.c +++ b/net/atm/br2684.c | |||
@@ -220,7 +220,7 @@ static int br2684_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
220 | /* netif_stop_queue(dev); */ | 220 | /* netif_stop_queue(dev); */ |
221 | dev_kfree_skb(skb); | 221 | dev_kfree_skb(skb); |
222 | read_unlock(&devs_lock); | 222 | read_unlock(&devs_lock); |
223 | return -EUNATCH; | 223 | return 0; |
224 | } | 224 | } |
225 | if (!br2684_xmit_vcc(skb, brdev, brvcc)) { | 225 | if (!br2684_xmit_vcc(skb, brdev, brvcc)) { |
226 | /* | 226 | /* |
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/resources.c b/net/atm/resources.c index a57a9268bd24..415d2615d475 100644 --- a/net/atm/resources.c +++ b/net/atm/resources.c | |||
@@ -40,6 +40,7 @@ static struct atm_dev *__alloc_atm_dev(const char *type) | |||
40 | dev->link_rate = ATM_OC3_PCR; | 40 | dev->link_rate = ATM_OC3_PCR; |
41 | spin_lock_init(&dev->lock); | 41 | spin_lock_init(&dev->lock); |
42 | INIT_LIST_HEAD(&dev->local); | 42 | INIT_LIST_HEAD(&dev->local); |
43 | INIT_LIST_HEAD(&dev->lecs); | ||
43 | 44 | ||
44 | return dev; | 45 | return dev; |
45 | } | 46 | } |
@@ -320,10 +321,12 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg) | |||
320 | error = -EPERM; | 321 | error = -EPERM; |
321 | goto done; | 322 | goto done; |
322 | } | 323 | } |
323 | atm_reset_addr(dev); | 324 | atm_reset_addr(dev, ATM_ADDR_LOCAL); |
324 | break; | 325 | break; |
325 | case ATM_ADDADDR: | 326 | case ATM_ADDADDR: |
326 | case ATM_DELADDR: | 327 | case ATM_DELADDR: |
328 | case ATM_ADDLECSADDR: | ||
329 | case ATM_DELLECSADDR: | ||
327 | if (!capable(CAP_NET_ADMIN)) { | 330 | if (!capable(CAP_NET_ADMIN)) { |
328 | error = -EPERM; | 331 | error = -EPERM; |
329 | goto done; | 332 | goto done; |
@@ -335,14 +338,21 @@ int atm_dev_ioctl(unsigned int cmd, void __user *arg) | |||
335 | error = -EFAULT; | 338 | error = -EFAULT; |
336 | goto done; | 339 | goto done; |
337 | } | 340 | } |
338 | if (cmd == ATM_ADDADDR) | 341 | if (cmd == ATM_ADDADDR || cmd == ATM_ADDLECSADDR) |
339 | error = atm_add_addr(dev, &addr); | 342 | error = atm_add_addr(dev, &addr, |
343 | (cmd == ATM_ADDADDR ? | ||
344 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); | ||
340 | else | 345 | else |
341 | error = atm_del_addr(dev, &addr); | 346 | error = atm_del_addr(dev, &addr, |
347 | (cmd == ATM_DELADDR ? | ||
348 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); | ||
342 | goto done; | 349 | goto done; |
343 | } | 350 | } |
344 | case ATM_GETADDR: | 351 | case ATM_GETADDR: |
345 | error = atm_get_addr(dev, buf, len); | 352 | case ATM_GETLECSADDR: |
353 | error = atm_get_addr(dev, buf, len, | ||
354 | (cmd == ATM_GETADDR ? | ||
355 | ATM_ADDR_LOCAL : ATM_ADDR_LECS)); | ||
346 | if (error < 0) | 356 | if (error < 0) |
347 | goto done; | 357 | goto done; |
348 | size = error; | 358 | size = error; |
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/ax25/ax25_in.c b/net/ax25/ax25_in.c index 810c9c76c2e0..73cfc3411c46 100644 --- a/net/ax25/ax25_in.c +++ b/net/ax25/ax25_in.c | |||
@@ -123,7 +123,7 @@ int ax25_rx_iframe(ax25_cb *ax25, struct sk_buff *skb) | |||
123 | } | 123 | } |
124 | 124 | ||
125 | skb_pull(skb, 1); /* Remove PID */ | 125 | skb_pull(skb, 1); /* Remove PID */ |
126 | skb->h.raw = skb->data; | 126 | skb->mac.raw = skb->nh.raw; |
127 | skb->nh.raw = skb->data; | 127 | skb->nh.raw = skb->data; |
128 | skb->dev = ax25->ax25_dev->dev; | 128 | skb->dev = ax25->ax25_dev->dev; |
129 | skb->pkt_type = PACKET_HOST; | 129 | skb->pkt_type = PACKET_HOST; |
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c index d3d6bc547212..59b2dd36baa7 100644 --- a/net/bluetooth/l2cap.c +++ b/net/bluetooth/l2cap.c | |||
@@ -372,7 +372,7 @@ static struct proto l2cap_proto = { | |||
372 | .obj_size = sizeof(struct l2cap_pinfo) | 372 | .obj_size = sizeof(struct l2cap_pinfo) |
373 | }; | 373 | }; |
374 | 374 | ||
375 | static struct sock *l2cap_sock_alloc(struct socket *sock, int proto, unsigned int __nocast prio) | 375 | static struct sock *l2cap_sock_alloc(struct socket *sock, int proto, gfp_t prio) |
376 | { | 376 | { |
377 | struct sock *sk; | 377 | struct sock *sk; |
378 | 378 | ||
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c index 173f46e8cdae..35adce6482b6 100644 --- a/net/bluetooth/rfcomm/core.c +++ b/net/bluetooth/rfcomm/core.c | |||
@@ -229,7 +229,7 @@ static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d) | |||
229 | d->rx_credits = RFCOMM_DEFAULT_CREDITS; | 229 | d->rx_credits = RFCOMM_DEFAULT_CREDITS; |
230 | } | 230 | } |
231 | 231 | ||
232 | struct rfcomm_dlc *rfcomm_dlc_alloc(unsigned int __nocast prio) | 232 | struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio) |
233 | { | 233 | { |
234 | struct rfcomm_dlc *d = kmalloc(sizeof(*d), prio); | 234 | struct rfcomm_dlc *d = kmalloc(sizeof(*d), prio); |
235 | if (!d) | 235 | if (!d) |
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c index f49e7e938bfb..a2b30f0aedb7 100644 --- a/net/bluetooth/rfcomm/sock.c +++ b/net/bluetooth/rfcomm/sock.c | |||
@@ -284,7 +284,7 @@ static struct proto rfcomm_proto = { | |||
284 | .obj_size = sizeof(struct rfcomm_pinfo) | 284 | .obj_size = sizeof(struct rfcomm_pinfo) |
285 | }; | 285 | }; |
286 | 286 | ||
287 | static struct sock *rfcomm_sock_alloc(struct socket *sock, int proto, unsigned int __nocast prio) | 287 | static struct sock *rfcomm_sock_alloc(struct socket *sock, int proto, gfp_t prio) |
288 | { | 288 | { |
289 | struct rfcomm_dlc *d; | 289 | struct rfcomm_dlc *d; |
290 | struct sock *sk; | 290 | struct sock *sk; |
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c index 1bca860a6109..158a9c46d863 100644 --- a/net/bluetooth/rfcomm/tty.c +++ b/net/bluetooth/rfcomm/tty.c | |||
@@ -286,7 +286,7 @@ static inline void rfcomm_set_owner_w(struct sk_buff *skb, struct rfcomm_dev *de | |||
286 | skb->destructor = rfcomm_wfree; | 286 | skb->destructor = rfcomm_wfree; |
287 | } | 287 | } |
288 | 288 | ||
289 | static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, unsigned int __nocast priority) | 289 | static struct sk_buff *rfcomm_wmalloc(struct rfcomm_dev *dev, unsigned long size, gfp_t priority) |
290 | { | 290 | { |
291 | if (atomic_read(&dev->wmem_alloc) < rfcomm_room(dev->dlc)) { | 291 | if (atomic_read(&dev->wmem_alloc) < rfcomm_room(dev->dlc)) { |
292 | struct sk_buff *skb = alloc_skb(size, priority); | 292 | struct sk_buff *skb = alloc_skb(size, priority); |
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c index ce7ab7dfa0b2..997e42df115c 100644 --- a/net/bluetooth/sco.c +++ b/net/bluetooth/sco.c | |||
@@ -418,7 +418,7 @@ static struct proto sco_proto = { | |||
418 | .obj_size = sizeof(struct sco_pinfo) | 418 | .obj_size = sizeof(struct sco_pinfo) |
419 | }; | 419 | }; |
420 | 420 | ||
421 | static struct sock *sco_sock_alloc(struct socket *sock, int proto, unsigned int __nocast prio) | 421 | static struct sock *sco_sock_alloc(struct socket *sock, int proto, gfp_t prio) |
422 | { | 422 | { |
423 | struct sock *sk; | 423 | struct sock *sk; |
424 | 424 | ||
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index 91bb895375f4..defcf6a8607c 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c | |||
@@ -79,7 +79,6 @@ static void destroy_nbp(struct net_bridge_port *p) | |||
79 | { | 79 | { |
80 | struct net_device *dev = p->dev; | 80 | struct net_device *dev = p->dev; |
81 | 81 | ||
82 | dev->br_port = NULL; | ||
83 | p->br = NULL; | 82 | p->br = NULL; |
84 | p->dev = NULL; | 83 | p->dev = NULL; |
85 | dev_put(dev); | 84 | dev_put(dev); |
@@ -100,6 +99,7 @@ static void del_nbp(struct net_bridge_port *p) | |||
100 | struct net_bridge *br = p->br; | 99 | struct net_bridge *br = p->br; |
101 | struct net_device *dev = p->dev; | 100 | struct net_device *dev = p->dev; |
102 | 101 | ||
102 | dev->br_port = NULL; | ||
103 | dev_set_promiscuity(dev, -1); | 103 | dev_set_promiscuity(dev, -1); |
104 | 104 | ||
105 | spin_lock_bh(&br->lock); | 105 | spin_lock_bh(&br->lock); |
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index c4540144f0f4..f8ffbf6e2333 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/spinlock.h> | 26 | #include <linux/spinlock.h> |
27 | #include <asm/uaccess.h> | 27 | #include <asm/uaccess.h> |
28 | #include <linux/smp.h> | 28 | #include <linux/smp.h> |
29 | #include <linux/cpumask.h> | ||
29 | #include <net/sock.h> | 30 | #include <net/sock.h> |
30 | /* needed for logical [in,out]-dev filtering */ | 31 | /* needed for logical [in,out]-dev filtering */ |
31 | #include "../br_private.h" | 32 | #include "../br_private.h" |
@@ -823,10 +824,11 @@ static int translate_table(struct ebt_replace *repl, | |||
823 | /* this will get free'd in do_replace()/ebt_register_table() | 824 | /* this will get free'd in do_replace()/ebt_register_table() |
824 | if an error occurs */ | 825 | if an error occurs */ |
825 | newinfo->chainstack = (struct ebt_chainstack **) | 826 | newinfo->chainstack = (struct ebt_chainstack **) |
826 | vmalloc(num_possible_cpus() * sizeof(struct ebt_chainstack)); | 827 | vmalloc((highest_possible_processor_id()+1) |
828 | * sizeof(struct ebt_chainstack)); | ||
827 | if (!newinfo->chainstack) | 829 | if (!newinfo->chainstack) |
828 | return -ENOMEM; | 830 | return -ENOMEM; |
829 | for (i = 0; i < num_possible_cpus(); i++) { | 831 | for_each_cpu(i) { |
830 | newinfo->chainstack[i] = | 832 | newinfo->chainstack[i] = |
831 | vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); | 833 | vmalloc(udc_cnt * sizeof(struct ebt_chainstack)); |
832 | if (!newinfo->chainstack[i]) { | 834 | if (!newinfo->chainstack[i]) { |
@@ -895,9 +897,12 @@ static void get_counters(struct ebt_counter *oldcounters, | |||
895 | 897 | ||
896 | /* counters of cpu 0 */ | 898 | /* counters of cpu 0 */ |
897 | memcpy(counters, oldcounters, | 899 | memcpy(counters, oldcounters, |
898 | sizeof(struct ebt_counter) * nentries); | 900 | sizeof(struct ebt_counter) * nentries); |
901 | |||
899 | /* add other counters to those of cpu 0 */ | 902 | /* add other counters to those of cpu 0 */ |
900 | for (cpu = 1; cpu < num_possible_cpus(); cpu++) { | 903 | for_each_cpu(cpu) { |
904 | if (cpu == 0) | ||
905 | continue; | ||
901 | counter_base = COUNTER_BASE(oldcounters, nentries, cpu); | 906 | counter_base = COUNTER_BASE(oldcounters, nentries, cpu); |
902 | for (i = 0; i < nentries; i++) { | 907 | for (i = 0; i < nentries; i++) { |
903 | counters[i].pcnt += counter_base[i].pcnt; | 908 | counters[i].pcnt += counter_base[i].pcnt; |
@@ -929,7 +934,8 @@ static int do_replace(void __user *user, unsigned int len) | |||
929 | BUGPRINT("Entries_size never zero\n"); | 934 | BUGPRINT("Entries_size never zero\n"); |
930 | return -EINVAL; | 935 | return -EINVAL; |
931 | } | 936 | } |
932 | countersize = COUNTER_OFFSET(tmp.nentries) * num_possible_cpus(); | 937 | countersize = COUNTER_OFFSET(tmp.nentries) * |
938 | (highest_possible_processor_id()+1); | ||
933 | newinfo = (struct ebt_table_info *) | 939 | newinfo = (struct ebt_table_info *) |
934 | vmalloc(sizeof(struct ebt_table_info) + countersize); | 940 | vmalloc(sizeof(struct ebt_table_info) + countersize); |
935 | if (!newinfo) | 941 | if (!newinfo) |
@@ -1022,7 +1028,7 @@ static int do_replace(void __user *user, unsigned int len) | |||
1022 | 1028 | ||
1023 | vfree(table->entries); | 1029 | vfree(table->entries); |
1024 | if (table->chainstack) { | 1030 | if (table->chainstack) { |
1025 | for (i = 0; i < num_possible_cpus(); i++) | 1031 | for_each_cpu(i) |
1026 | vfree(table->chainstack[i]); | 1032 | vfree(table->chainstack[i]); |
1027 | vfree(table->chainstack); | 1033 | vfree(table->chainstack); |
1028 | } | 1034 | } |
@@ -1040,7 +1046,7 @@ free_counterstmp: | |||
1040 | vfree(counterstmp); | 1046 | vfree(counterstmp); |
1041 | /* can be initialized in translate_table() */ | 1047 | /* can be initialized in translate_table() */ |
1042 | if (newinfo->chainstack) { | 1048 | if (newinfo->chainstack) { |
1043 | for (i = 0; i < num_possible_cpus(); i++) | 1049 | for_each_cpu(i) |
1044 | vfree(newinfo->chainstack[i]); | 1050 | vfree(newinfo->chainstack[i]); |
1045 | vfree(newinfo->chainstack); | 1051 | vfree(newinfo->chainstack); |
1046 | } | 1052 | } |
@@ -1132,7 +1138,8 @@ int ebt_register_table(struct ebt_table *table) | |||
1132 | return -EINVAL; | 1138 | return -EINVAL; |
1133 | } | 1139 | } |
1134 | 1140 | ||
1135 | countersize = COUNTER_OFFSET(table->table->nentries) * num_possible_cpus(); | 1141 | countersize = COUNTER_OFFSET(table->table->nentries) * |
1142 | (highest_possible_processor_id()+1); | ||
1136 | newinfo = (struct ebt_table_info *) | 1143 | newinfo = (struct ebt_table_info *) |
1137 | vmalloc(sizeof(struct ebt_table_info) + countersize); | 1144 | vmalloc(sizeof(struct ebt_table_info) + countersize); |
1138 | ret = -ENOMEM; | 1145 | ret = -ENOMEM; |
@@ -1186,7 +1193,7 @@ free_unlock: | |||
1186 | up(&ebt_mutex); | 1193 | up(&ebt_mutex); |
1187 | free_chainstack: | 1194 | free_chainstack: |
1188 | if (newinfo->chainstack) { | 1195 | if (newinfo->chainstack) { |
1189 | for (i = 0; i < num_possible_cpus(); i++) | 1196 | for_each_cpu(i) |
1190 | vfree(newinfo->chainstack[i]); | 1197 | vfree(newinfo->chainstack[i]); |
1191 | vfree(newinfo->chainstack); | 1198 | vfree(newinfo->chainstack); |
1192 | } | 1199 | } |
@@ -1209,7 +1216,7 @@ void ebt_unregister_table(struct ebt_table *table) | |||
1209 | up(&ebt_mutex); | 1216 | up(&ebt_mutex); |
1210 | vfree(table->private->entries); | 1217 | vfree(table->private->entries); |
1211 | if (table->private->chainstack) { | 1218 | if (table->private->chainstack) { |
1212 | for (i = 0; i < num_possible_cpus(); i++) | 1219 | for_each_cpu(i) |
1213 | vfree(table->private->chainstack[i]); | 1220 | vfree(table->private->chainstack[i]); |
1214 | vfree(table->private->chainstack); | 1221 | vfree(table->private->chainstack); |
1215 | } | 1222 | } |
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..a44eeef24edf 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; |
@@ -1130,7 +1132,7 @@ static inline int illegal_highdma(struct net_device *dev, struct sk_buff *skb) | |||
1130 | #endif | 1132 | #endif |
1131 | 1133 | ||
1132 | /* Keep head the same: replace data */ | 1134 | /* Keep head the same: replace data */ |
1133 | int __skb_linearize(struct sk_buff *skb, unsigned int __nocast gfp_mask) | 1135 | int __skb_linearize(struct sk_buff *skb, gfp_t gfp_mask) |
1134 | { | 1136 | { |
1135 | unsigned int size; | 1137 | unsigned int size; |
1136 | u8 *data; | 1138 | u8 *data; |
@@ -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..af9b1516e21f 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 |
@@ -132,7 +130,7 @@ void skb_under_panic(struct sk_buff *skb, int sz, void *here) | |||
132 | * Buffers may only be allocated from interrupts using a @gfp_mask of | 130 | * Buffers may only be allocated from interrupts using a @gfp_mask of |
133 | * %GFP_ATOMIC. | 131 | * %GFP_ATOMIC. |
134 | */ | 132 | */ |
135 | struct sk_buff *__alloc_skb(unsigned int size, unsigned int __nocast gfp_mask, | 133 | struct sk_buff *__alloc_skb(unsigned int size, gfp_t gfp_mask, |
136 | int fclone) | 134 | int fclone) |
137 | { | 135 | { |
138 | struct sk_buff *skb; | 136 | struct sk_buff *skb; |
@@ -200,7 +198,7 @@ nodata: | |||
200 | */ | 198 | */ |
201 | struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, | 199 | struct sk_buff *alloc_skb_from_cache(kmem_cache_t *cp, |
202 | unsigned int size, | 200 | unsigned int size, |
203 | unsigned int __nocast gfp_mask) | 201 | gfp_t gfp_mask) |
204 | { | 202 | { |
205 | struct sk_buff *skb; | 203 | struct sk_buff *skb; |
206 | u8 *data; | 204 | u8 *data; |
@@ -363,7 +361,7 @@ void __kfree_skb(struct sk_buff *skb) | |||
363 | * %GFP_ATOMIC. | 361 | * %GFP_ATOMIC. |
364 | */ | 362 | */ |
365 | 363 | ||
366 | struct sk_buff *skb_clone(struct sk_buff *skb, unsigned int __nocast gfp_mask) | 364 | struct sk_buff *skb_clone(struct sk_buff *skb, gfp_t gfp_mask) |
367 | { | 365 | { |
368 | struct sk_buff *n; | 366 | struct sk_buff *n; |
369 | 367 | ||
@@ -502,7 +500,7 @@ static void copy_skb_header(struct sk_buff *new, const struct sk_buff *old) | |||
502 | * header is going to be modified. Use pskb_copy() instead. | 500 | * header is going to be modified. Use pskb_copy() instead. |
503 | */ | 501 | */ |
504 | 502 | ||
505 | struct sk_buff *skb_copy(const struct sk_buff *skb, unsigned int __nocast gfp_mask) | 503 | struct sk_buff *skb_copy(const struct sk_buff *skb, gfp_t gfp_mask) |
506 | { | 504 | { |
507 | int headerlen = skb->data - skb->head; | 505 | int headerlen = skb->data - skb->head; |
508 | /* | 506 | /* |
@@ -541,7 +539,7 @@ struct sk_buff *skb_copy(const struct sk_buff *skb, unsigned int __nocast gfp_ma | |||
541 | * The returned buffer has a reference count of 1. | 539 | * The returned buffer has a reference count of 1. |
542 | */ | 540 | */ |
543 | 541 | ||
544 | struct sk_buff *pskb_copy(struct sk_buff *skb, unsigned int __nocast gfp_mask) | 542 | struct sk_buff *pskb_copy(struct sk_buff *skb, gfp_t gfp_mask) |
545 | { | 543 | { |
546 | /* | 544 | /* |
547 | * Allocate the copy buffer | 545 | * Allocate the copy buffer |
@@ -600,7 +598,7 @@ out: | |||
600 | */ | 598 | */ |
601 | 599 | ||
602 | int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, | 600 | int pskb_expand_head(struct sk_buff *skb, int nhead, int ntail, |
603 | unsigned int __nocast gfp_mask) | 601 | gfp_t gfp_mask) |
604 | { | 602 | { |
605 | int i; | 603 | int i; |
606 | u8 *data; | 604 | u8 *data; |
@@ -691,7 +689,7 @@ struct sk_buff *skb_realloc_headroom(struct sk_buff *skb, unsigned int headroom) | |||
691 | */ | 689 | */ |
692 | struct sk_buff *skb_copy_expand(const struct sk_buff *skb, | 690 | struct sk_buff *skb_copy_expand(const struct sk_buff *skb, |
693 | int newheadroom, int newtailroom, | 691 | int newheadroom, int newtailroom, |
694 | unsigned int __nocast gfp_mask) | 692 | gfp_t gfp_mask) |
695 | { | 693 | { |
696 | /* | 694 | /* |
697 | * Allocate the copy buffer | 695 | * Allocate the copy buffer |
@@ -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..1c52fe809eda 100644 --- a/net/core/sock.c +++ b/net/core/sock.c | |||
@@ -637,7 +637,7 @@ lenout: | |||
637 | * @prot: struct proto associated with this new sock instance | 637 | * @prot: struct proto associated with this new sock instance |
638 | * @zero_it: if we should zero the newly allocated sock | 638 | * @zero_it: if we should zero the newly allocated sock |
639 | */ | 639 | */ |
640 | struct sock *sk_alloc(int family, unsigned int __nocast priority, | 640 | struct sock *sk_alloc(int family, gfp_t priority, |
641 | struct proto *prot, int zero_it) | 641 | struct proto *prot, int zero_it) |
642 | { | 642 | { |
643 | struct sock *sk = NULL; | 643 | struct sock *sk = NULL; |
@@ -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) |
@@ -700,7 +704,7 @@ void sk_free(struct sock *sk) | |||
700 | module_put(owner); | 704 | module_put(owner); |
701 | } | 705 | } |
702 | 706 | ||
703 | struct sock *sk_clone(const struct sock *sk, const unsigned int __nocast priority) | 707 | struct sock *sk_clone(const struct sock *sk, const gfp_t priority) |
704 | { | 708 | { |
705 | struct sock *newsk = sk_alloc(sk->sk_family, priority, sk->sk_prot, 0); | 709 | struct sock *newsk = sk_alloc(sk->sk_family, priority, sk->sk_prot, 0); |
706 | 710 | ||
@@ -841,7 +845,7 @@ unsigned long sock_i_ino(struct sock *sk) | |||
841 | * Allocate a skb from the socket's send buffer. | 845 | * Allocate a skb from the socket's send buffer. |
842 | */ | 846 | */ |
843 | struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, | 847 | struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, |
844 | unsigned int __nocast priority) | 848 | gfp_t priority) |
845 | { | 849 | { |
846 | if (force || atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) { | 850 | if (force || atomic_read(&sk->sk_wmem_alloc) < sk->sk_sndbuf) { |
847 | struct sk_buff * skb = alloc_skb(size, priority); | 851 | struct sk_buff * skb = alloc_skb(size, priority); |
@@ -857,7 +861,7 @@ struct sk_buff *sock_wmalloc(struct sock *sk, unsigned long size, int force, | |||
857 | * Allocate a skb from the socket's receive buffer. | 861 | * Allocate a skb from the socket's receive buffer. |
858 | */ | 862 | */ |
859 | struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force, | 863 | struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force, |
860 | unsigned int __nocast priority) | 864 | gfp_t priority) |
861 | { | 865 | { |
862 | if (force || atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { | 866 | if (force || atomic_read(&sk->sk_rmem_alloc) < sk->sk_rcvbuf) { |
863 | struct sk_buff *skb = alloc_skb(size, priority); | 867 | struct sk_buff *skb = alloc_skb(size, priority); |
@@ -872,7 +876,7 @@ struct sk_buff *sock_rmalloc(struct sock *sk, unsigned long size, int force, | |||
872 | /* | 876 | /* |
873 | * Allocate a memory block from the socket's option memory buffer. | 877 | * Allocate a memory block from the socket's option memory buffer. |
874 | */ | 878 | */ |
875 | void *sock_kmalloc(struct sock *sk, int size, unsigned int __nocast priority) | 879 | void *sock_kmalloc(struct sock *sk, int size, gfp_t priority) |
876 | { | 880 | { |
877 | if ((unsigned)size <= sysctl_optmem_max && | 881 | if ((unsigned)size <= sysctl_optmem_max && |
878 | atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { | 882 | atomic_read(&sk->sk_omem_alloc) + size < sysctl_optmem_max) { |
diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c index 6530283eafca..c9a62cca22fc 100644 --- a/net/dccp/ackvec.c +++ b/net/dccp/ackvec.c | |||
@@ -91,7 +91,7 @@ int dccp_insert_option_ackvec(struct sock *sk, struct sk_buff *skb) | |||
91 | } | 91 | } |
92 | 92 | ||
93 | struct dccp_ackvec *dccp_ackvec_alloc(const unsigned int len, | 93 | struct dccp_ackvec *dccp_ackvec_alloc(const unsigned int len, |
94 | const unsigned int __nocast priority) | 94 | const gfp_t priority) |
95 | { | 95 | { |
96 | struct dccp_ackvec *av = kmalloc(sizeof(*av) + len, priority); | 96 | struct dccp_ackvec *av = kmalloc(sizeof(*av) + len, priority); |
97 | 97 | ||
diff --git a/net/dccp/ackvec.h b/net/dccp/ackvec.h index 8ca51c9191f7..d0fd6c60c574 100644 --- a/net/dccp/ackvec.h +++ b/net/dccp/ackvec.h | |||
@@ -74,7 +74,7 @@ struct sk_buff; | |||
74 | 74 | ||
75 | #ifdef CONFIG_IP_DCCP_ACKVEC | 75 | #ifdef CONFIG_IP_DCCP_ACKVEC |
76 | extern struct dccp_ackvec *dccp_ackvec_alloc(unsigned int len, | 76 | extern struct dccp_ackvec *dccp_ackvec_alloc(unsigned int len, |
77 | const unsigned int __nocast priority); | 77 | const gfp_t priority); |
78 | extern void dccp_ackvec_free(struct dccp_ackvec *av); | 78 | extern void dccp_ackvec_free(struct dccp_ackvec *av); |
79 | 79 | ||
80 | extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, | 80 | extern int dccp_ackvec_add(struct dccp_ackvec *av, const struct sock *sk, |
@@ -93,7 +93,7 @@ static inline int dccp_ackvec_pending(const struct dccp_ackvec *av) | |||
93 | } | 93 | } |
94 | #else /* CONFIG_IP_DCCP_ACKVEC */ | 94 | #else /* CONFIG_IP_DCCP_ACKVEC */ |
95 | static inline struct dccp_ackvec *dccp_ackvec_alloc(unsigned int len, | 95 | static inline struct dccp_ackvec *dccp_ackvec_alloc(unsigned int len, |
96 | const unsigned int __nocast priority) | 96 | const gfp_t priority) |
97 | { | 97 | { |
98 | return NULL; | 98 | return NULL; |
99 | } | 99 | } |
diff --git a/net/dccp/ccid.h b/net/dccp/ccid.h index 21e55142dcd3..c37eeeaf5c6e 100644 --- a/net/dccp/ccid.h +++ b/net/dccp/ccid.h | |||
@@ -110,14 +110,14 @@ static inline int ccid_hc_tx_init(struct ccid *ccid, struct sock *sk) | |||
110 | 110 | ||
111 | static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk) | 111 | static inline void ccid_hc_rx_exit(struct ccid *ccid, struct sock *sk) |
112 | { | 112 | { |
113 | if (ccid->ccid_hc_rx_exit != NULL && | 113 | if (ccid != NULL && ccid->ccid_hc_rx_exit != NULL && |
114 | dccp_sk(sk)->dccps_hc_rx_ccid_private != NULL) | 114 | dccp_sk(sk)->dccps_hc_rx_ccid_private != NULL) |
115 | ccid->ccid_hc_rx_exit(sk); | 115 | ccid->ccid_hc_rx_exit(sk); |
116 | } | 116 | } |
117 | 117 | ||
118 | static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk) | 118 | static inline void ccid_hc_tx_exit(struct ccid *ccid, struct sock *sk) |
119 | { | 119 | { |
120 | if (ccid->ccid_hc_tx_exit != NULL && | 120 | if (ccid != NULL && ccid->ccid_hc_tx_exit != NULL && |
121 | dccp_sk(sk)->dccps_hc_tx_ccid_private != NULL) | 121 | dccp_sk(sk)->dccps_hc_tx_ccid_private != NULL) |
122 | ccid->ccid_hc_tx_exit(sk); | 122 | ccid->ccid_hc_tx_exit(sk); |
123 | } | 123 | } |
diff --git a/net/dccp/ccids/lib/loss_interval.h b/net/dccp/ccids/lib/loss_interval.h index 13ad47ba1420..417d9d82df3e 100644 --- a/net/dccp/ccids/lib/loss_interval.h +++ b/net/dccp/ccids/lib/loss_interval.h | |||
@@ -36,7 +36,7 @@ struct dccp_li_hist_entry { | |||
36 | 36 | ||
37 | static inline struct dccp_li_hist_entry * | 37 | static inline struct dccp_li_hist_entry * |
38 | dccp_li_hist_entry_new(struct dccp_li_hist *hist, | 38 | dccp_li_hist_entry_new(struct dccp_li_hist *hist, |
39 | const unsigned int __nocast prio) | 39 | const gfp_t prio) |
40 | { | 40 | { |
41 | return kmem_cache_alloc(hist->dccplih_slab, prio); | 41 | return kmem_cache_alloc(hist->dccplih_slab, prio); |
42 | } | 42 | } |
diff --git a/net/dccp/ccids/lib/packet_history.h b/net/dccp/ccids/lib/packet_history.h index b375ebdb7dcf..122e96737ff6 100644 --- a/net/dccp/ccids/lib/packet_history.h +++ b/net/dccp/ccids/lib/packet_history.h | |||
@@ -86,7 +86,7 @@ extern struct dccp_rx_hist_entry * | |||
86 | 86 | ||
87 | static inline struct dccp_tx_hist_entry * | 87 | static inline struct dccp_tx_hist_entry * |
88 | dccp_tx_hist_entry_new(struct dccp_tx_hist *hist, | 88 | dccp_tx_hist_entry_new(struct dccp_tx_hist *hist, |
89 | const unsigned int __nocast prio) | 89 | const gfp_t prio) |
90 | { | 90 | { |
91 | struct dccp_tx_hist_entry *entry = kmem_cache_alloc(hist->dccptxh_slab, | 91 | struct dccp_tx_hist_entry *entry = kmem_cache_alloc(hist->dccptxh_slab, |
92 | prio); | 92 | prio); |
@@ -137,7 +137,7 @@ static inline struct dccp_rx_hist_entry * | |||
137 | const struct sock *sk, | 137 | const struct sock *sk, |
138 | const u32 ndp, | 138 | const u32 ndp, |
139 | const struct sk_buff *skb, | 139 | const struct sk_buff *skb, |
140 | const unsigned int __nocast prio) | 140 | const gfp_t prio) |
141 | { | 141 | { |
142 | struct dccp_rx_hist_entry *entry = kmem_cache_alloc(hist->dccprxh_slab, | 142 | struct dccp_rx_hist_entry *entry = kmem_cache_alloc(hist->dccprxh_slab, |
143 | prio); | 143 | prio); |
diff --git a/net/dccp/input.c b/net/dccp/input.c index 1b6b2cb12376..3454d5941900 100644 --- a/net/dccp/input.c +++ b/net/dccp/input.c | |||
@@ -375,6 +375,9 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk, | |||
375 | case DCCP_PKT_RESET: | 375 | case DCCP_PKT_RESET: |
376 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); | 376 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_DACK); |
377 | break; | 377 | break; |
378 | case DCCP_PKT_DATA: | ||
379 | if (sk->sk_state == DCCP_RESPOND) | ||
380 | break; | ||
378 | case DCCP_PKT_DATAACK: | 381 | case DCCP_PKT_DATAACK: |
379 | case DCCP_PKT_ACK: | 382 | case DCCP_PKT_ACK: |
380 | /* | 383 | /* |
@@ -393,7 +396,8 @@ static int dccp_rcv_respond_partopen_state_process(struct sock *sk, | |||
393 | dccp_sk(sk)->dccps_osr = DCCP_SKB_CB(skb)->dccpd_seq; | 396 | dccp_sk(sk)->dccps_osr = DCCP_SKB_CB(skb)->dccpd_seq; |
394 | dccp_set_state(sk, DCCP_OPEN); | 397 | dccp_set_state(sk, DCCP_OPEN); |
395 | 398 | ||
396 | if (dh->dccph_type == DCCP_PKT_DATAACK) { | 399 | if (dh->dccph_type == DCCP_PKT_DATAACK || |
400 | dh->dccph_type == DCCP_PKT_DATA) { | ||
397 | dccp_rcv_established(sk, skb, dh, len); | 401 | dccp_rcv_established(sk, skb, dh, len); |
398 | queued = 1; /* packet was queued | 402 | queued = 1; /* packet was queued |
399 | (by dccp_rcv_established) */ | 403 | (by dccp_rcv_established) */ |
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/decnet/af_decnet.c b/net/decnet/af_decnet.c index 348f36b529f7..1186dc44cdff 100644 --- a/net/decnet/af_decnet.c +++ b/net/decnet/af_decnet.c | |||
@@ -452,7 +452,7 @@ static struct proto dn_proto = { | |||
452 | .obj_size = sizeof(struct dn_sock), | 452 | .obj_size = sizeof(struct dn_sock), |
453 | }; | 453 | }; |
454 | 454 | ||
455 | static struct sock *dn_alloc_sock(struct socket *sock, int gfp) | 455 | static struct sock *dn_alloc_sock(struct socket *sock, gfp_t gfp) |
456 | { | 456 | { |
457 | struct dn_scp *scp; | 457 | struct dn_scp *scp; |
458 | struct sock *sk = sk_alloc(PF_DECnet, gfp, &dn_proto, 1); | 458 | struct sock *sk = sk_alloc(PF_DECnet, gfp, &dn_proto, 1); |
@@ -804,7 +804,7 @@ static int dn_auto_bind(struct socket *sock) | |||
804 | return rv; | 804 | return rv; |
805 | } | 805 | } |
806 | 806 | ||
807 | static int dn_confirm_accept(struct sock *sk, long *timeo, int allocation) | 807 | static int dn_confirm_accept(struct sock *sk, long *timeo, gfp_t allocation) |
808 | { | 808 | { |
809 | struct dn_scp *scp = DN_SK(sk); | 809 | struct dn_scp *scp = DN_SK(sk); |
810 | DEFINE_WAIT(wait); | 810 | DEFINE_WAIT(wait); |
diff --git a/net/decnet/dn_nsp_out.c b/net/decnet/dn_nsp_out.c index 53633d352868..c96c767b1f74 100644 --- a/net/decnet/dn_nsp_out.c +++ b/net/decnet/dn_nsp_out.c | |||
@@ -117,7 +117,7 @@ try_again: | |||
117 | * The eventual aim is for each socket to have a cached header size | 117 | * The eventual aim is for each socket to have a cached header size |
118 | * for its outgoing packets, and to set hdr from this when sk != NULL. | 118 | * for its outgoing packets, and to set hdr from this when sk != NULL. |
119 | */ | 119 | */ |
120 | struct sk_buff *dn_alloc_skb(struct sock *sk, int size, int pri) | 120 | struct sk_buff *dn_alloc_skb(struct sock *sk, int size, gfp_t pri) |
121 | { | 121 | { |
122 | struct sk_buff *skb; | 122 | struct sk_buff *skb; |
123 | int hdr = 64; | 123 | int hdr = 64; |
@@ -210,7 +210,8 @@ static void dn_nsp_rtt(struct sock *sk, long rtt) | |||
210 | * | 210 | * |
211 | * Returns: The number of times the packet has been sent previously | 211 | * Returns: The number of times the packet has been sent previously |
212 | */ | 212 | */ |
213 | static inline unsigned dn_nsp_clone_and_send(struct sk_buff *skb, int gfp) | 213 | static inline unsigned dn_nsp_clone_and_send(struct sk_buff *skb, |
214 | gfp_t gfp) | ||
214 | { | 215 | { |
215 | struct dn_skb_cb *cb = DN_SKB_CB(skb); | 216 | struct dn_skb_cb *cb = DN_SKB_CB(skb); |
216 | struct sk_buff *skb2; | 217 | struct sk_buff *skb2; |
@@ -350,7 +351,8 @@ static unsigned short *dn_nsp_mk_data_header(struct sock *sk, struct sk_buff *sk | |||
350 | return ptr; | 351 | return ptr; |
351 | } | 352 | } |
352 | 353 | ||
353 | void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, int gfp, int oth) | 354 | void dn_nsp_queue_xmit(struct sock *sk, struct sk_buff *skb, |
355 | gfp_t gfp, int oth) | ||
354 | { | 356 | { |
355 | struct dn_scp *scp = DN_SK(sk); | 357 | struct dn_scp *scp = DN_SK(sk); |
356 | struct dn_skb_cb *cb = DN_SKB_CB(skb); | 358 | struct dn_skb_cb *cb = DN_SKB_CB(skb); |
@@ -517,7 +519,7 @@ static int dn_nsp_retrans_conn_conf(struct sock *sk) | |||
517 | return 0; | 519 | return 0; |
518 | } | 520 | } |
519 | 521 | ||
520 | void dn_send_conn_conf(struct sock *sk, int gfp) | 522 | void dn_send_conn_conf(struct sock *sk, gfp_t gfp) |
521 | { | 523 | { |
522 | struct dn_scp *scp = DN_SK(sk); | 524 | struct dn_scp *scp = DN_SK(sk); |
523 | struct sk_buff *skb = NULL; | 525 | struct sk_buff *skb = NULL; |
@@ -549,7 +551,8 @@ void dn_send_conn_conf(struct sock *sk, int gfp) | |||
549 | 551 | ||
550 | 552 | ||
551 | static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, | 553 | static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, |
552 | unsigned short reason, int gfp, struct dst_entry *dst, | 554 | unsigned short reason, gfp_t gfp, |
555 | struct dst_entry *dst, | ||
553 | int ddl, unsigned char *dd, __u16 rem, __u16 loc) | 556 | int ddl, unsigned char *dd, __u16 rem, __u16 loc) |
554 | { | 557 | { |
555 | struct sk_buff *skb = NULL; | 558 | struct sk_buff *skb = NULL; |
@@ -591,7 +594,7 @@ static __inline__ void dn_nsp_do_disc(struct sock *sk, unsigned char msgflg, | |||
591 | 594 | ||
592 | 595 | ||
593 | void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg, | 596 | void dn_nsp_send_disc(struct sock *sk, unsigned char msgflg, |
594 | unsigned short reason, int gfp) | 597 | unsigned short reason, gfp_t gfp) |
595 | { | 598 | { |
596 | struct dn_scp *scp = DN_SK(sk); | 599 | struct dn_scp *scp = DN_SK(sk); |
597 | int ddl = 0; | 600 | int ddl = 0; |
@@ -612,7 +615,7 @@ void dn_nsp_return_disc(struct sk_buff *skb, unsigned char msgflg, | |||
612 | { | 615 | { |
613 | struct dn_skb_cb *cb = DN_SKB_CB(skb); | 616 | struct dn_skb_cb *cb = DN_SKB_CB(skb); |
614 | int ddl = 0; | 617 | int ddl = 0; |
615 | int gfp = GFP_ATOMIC; | 618 | gfp_t gfp = GFP_ATOMIC; |
616 | 619 | ||
617 | dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb->dst, ddl, | 620 | dn_nsp_do_disc(NULL, msgflg, reason, gfp, skb->dst, ddl, |
618 | NULL, cb->src_port, cb->dst_port); | 621 | NULL, cb->src_port, cb->dst_port); |
@@ -624,7 +627,7 @@ void dn_nsp_send_link(struct sock *sk, unsigned char lsflags, char fcval) | |||
624 | struct dn_scp *scp = DN_SK(sk); | 627 | struct dn_scp *scp = DN_SK(sk); |
625 | struct sk_buff *skb; | 628 | struct sk_buff *skb; |
626 | unsigned char *ptr; | 629 | unsigned char *ptr; |
627 | int gfp = GFP_ATOMIC; | 630 | gfp_t gfp = GFP_ATOMIC; |
628 | 631 | ||
629 | if ((skb = dn_alloc_skb(sk, DN_MAX_NSP_DATA_HEADER + 2, gfp)) == NULL) | 632 | if ((skb = dn_alloc_skb(sk, DN_MAX_NSP_DATA_HEADER + 2, gfp)) == NULL) |
630 | return; | 633 | return; |
@@ -659,7 +662,7 @@ void dn_nsp_send_conninit(struct sock *sk, unsigned char msgflg) | |||
659 | unsigned char menuver; | 662 | unsigned char menuver; |
660 | struct dn_skb_cb *cb; | 663 | struct dn_skb_cb *cb; |
661 | unsigned char type = 1; | 664 | unsigned char type = 1; |
662 | int allocation = (msgflg == NSP_CI) ? sk->sk_allocation : GFP_ATOMIC; | 665 | gfp_t allocation = (msgflg == NSP_CI) ? sk->sk_allocation : GFP_ATOMIC; |
663 | struct sk_buff *skb = dn_alloc_skb(sk, 200, allocation); | 666 | struct sk_buff *skb = dn_alloc_skb(sk, 200, allocation); |
664 | 667 | ||
665 | if (!skb) | 668 | if (!skb) |
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 03a47343ddc7..6059e9e37123 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 c9aaff3fea1e..eed07bbbe6b6 100644 --- a/net/ieee80211/ieee80211_tx.c +++ b/net/ieee80211/ieee80211_tx.c | |||
@@ -207,7 +207,7 @@ void ieee80211_txb_free(struct ieee80211_txb *txb) | |||
207 | } | 207 | } |
208 | 208 | ||
209 | static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, | 209 | static struct ieee80211_txb *ieee80211_alloc_txb(int nr_frags, int txb_size, |
210 | int gfp_mask) | 210 | gfp_t gfp_mask) |
211 | { | 211 | { |
212 | struct ieee80211_txb *txb; | 212 | struct ieee80211_txb *txb; |
213 | int i; | 213 | 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/esp4.c b/net/ipv4/esp4.c index 1b5a09d1b90b..1b18ce66e7b7 100644 --- a/net/ipv4/esp4.c +++ b/net/ipv4/esp4.c | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <net/esp.h> | 5 | #include <net/esp.h> |
6 | #include <asm/scatterlist.h> | 6 | #include <asm/scatterlist.h> |
7 | #include <linux/crypto.h> | 7 | #include <linux/crypto.h> |
8 | #include <linux/kernel.h> | ||
8 | #include <linux/pfkeyv2.h> | 9 | #include <linux/pfkeyv2.h> |
9 | #include <linux/random.h> | 10 | #include <linux/random.h> |
10 | #include <net/icmp.h> | 11 | #include <net/icmp.h> |
@@ -42,10 +43,10 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb) | |||
42 | esp = x->data; | 43 | esp = x->data; |
43 | alen = esp->auth.icv_trunc_len; | 44 | alen = esp->auth.icv_trunc_len; |
44 | tfm = esp->conf.tfm; | 45 | tfm = esp->conf.tfm; |
45 | blksize = (crypto_tfm_alg_blocksize(tfm) + 3) & ~3; | 46 | blksize = ALIGN(crypto_tfm_alg_blocksize(tfm), 4); |
46 | clen = (clen + 2 + blksize-1)&~(blksize-1); | 47 | clen = ALIGN(clen + 2, blksize); |
47 | if (esp->conf.padlen) | 48 | if (esp->conf.padlen) |
48 | clen = (clen + esp->conf.padlen-1)&~(esp->conf.padlen-1); | 49 | clen = ALIGN(clen, esp->conf.padlen); |
49 | 50 | ||
50 | if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) | 51 | if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) |
51 | goto error; | 52 | goto error; |
@@ -143,7 +144,7 @@ static int esp_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struc | |||
143 | struct ip_esp_hdr *esph; | 144 | struct ip_esp_hdr *esph; |
144 | struct esp_data *esp = x->data; | 145 | struct esp_data *esp = x->data; |
145 | struct sk_buff *trailer; | 146 | struct sk_buff *trailer; |
146 | int blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); | 147 | int blksize = ALIGN(crypto_tfm_alg_blocksize(esp->conf.tfm), 4); |
147 | int alen = esp->auth.icv_trunc_len; | 148 | int alen = esp->auth.icv_trunc_len; |
148 | int elen = skb->len - sizeof(struct ip_esp_hdr) - esp->conf.ivlen - alen; | 149 | int elen = skb->len - sizeof(struct ip_esp_hdr) - esp->conf.ivlen - alen; |
149 | int nfrags; | 150 | int nfrags; |
@@ -304,16 +305,16 @@ static int esp_post_input(struct xfrm_state *x, struct xfrm_decap_state *decap, | |||
304 | static u32 esp4_get_max_size(struct xfrm_state *x, int mtu) | 305 | static u32 esp4_get_max_size(struct xfrm_state *x, int mtu) |
305 | { | 306 | { |
306 | struct esp_data *esp = x->data; | 307 | struct esp_data *esp = x->data; |
307 | u32 blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); | 308 | u32 blksize = ALIGN(crypto_tfm_alg_blocksize(esp->conf.tfm), 4); |
308 | 309 | ||
309 | if (x->props.mode) { | 310 | if (x->props.mode) { |
310 | mtu = (mtu + 2 + blksize-1)&~(blksize-1); | 311 | mtu = ALIGN(mtu + 2, blksize); |
311 | } else { | 312 | } else { |
312 | /* The worst case. */ | 313 | /* The worst case. */ |
313 | mtu += 2 + blksize; | 314 | mtu = ALIGN(mtu + 2, 4) + blksize - 4; |
314 | } | 315 | } |
315 | if (esp->conf.padlen) | 316 | if (esp->conf.padlen) |
316 | mtu = (mtu + esp->conf.padlen-1)&~(esp->conf.padlen-1); | 317 | mtu = ALIGN(mtu, esp->conf.padlen); |
317 | 318 | ||
318 | return mtu + x->props.header_len + esp->auth.icv_trunc_len; | 319 | return mtu + x->props.header_len + esp->auth.icv_trunc_len; |
319 | } | 320 | } |
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/fib_trie.c b/net/ipv4/fib_trie.c index 50c0519cd70d..0093ea08c7f5 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -286,6 +286,8 @@ static inline void check_tnode(const struct tnode *tn) | |||
286 | 286 | ||
287 | static int halve_threshold = 25; | 287 | static int halve_threshold = 25; |
288 | static int inflate_threshold = 50; | 288 | static int inflate_threshold = 50; |
289 | static int halve_threshold_root = 15; | ||
290 | static int inflate_threshold_root = 25; | ||
289 | 291 | ||
290 | 292 | ||
291 | static void __alias_free_mem(struct rcu_head *head) | 293 | static void __alias_free_mem(struct rcu_head *head) |
@@ -449,6 +451,8 @@ static struct node *resize(struct trie *t, struct tnode *tn) | |||
449 | int i; | 451 | int i; |
450 | int err = 0; | 452 | int err = 0; |
451 | struct tnode *old_tn; | 453 | struct tnode *old_tn; |
454 | int inflate_threshold_use; | ||
455 | int halve_threshold_use; | ||
452 | 456 | ||
453 | if (!tn) | 457 | if (!tn) |
454 | return NULL; | 458 | return NULL; |
@@ -541,10 +545,17 @@ static struct node *resize(struct trie *t, struct tnode *tn) | |||
541 | 545 | ||
542 | check_tnode(tn); | 546 | check_tnode(tn); |
543 | 547 | ||
548 | /* Keep root node larger */ | ||
549 | |||
550 | if(!tn->parent) | ||
551 | inflate_threshold_use = inflate_threshold_root; | ||
552 | else | ||
553 | inflate_threshold_use = inflate_threshold; | ||
554 | |||
544 | err = 0; | 555 | err = 0; |
545 | while ((tn->full_children > 0 && | 556 | while ((tn->full_children > 0 && |
546 | 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >= | 557 | 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >= |
547 | inflate_threshold * tnode_child_length(tn))) { | 558 | inflate_threshold_use * tnode_child_length(tn))) { |
548 | 559 | ||
549 | old_tn = tn; | 560 | old_tn = tn; |
550 | tn = inflate(t, tn); | 561 | tn = inflate(t, tn); |
@@ -564,10 +575,18 @@ static struct node *resize(struct trie *t, struct tnode *tn) | |||
564 | * node is above threshold. | 575 | * node is above threshold. |
565 | */ | 576 | */ |
566 | 577 | ||
578 | |||
579 | /* Keep root node larger */ | ||
580 | |||
581 | if(!tn->parent) | ||
582 | halve_threshold_use = halve_threshold_root; | ||
583 | else | ||
584 | halve_threshold_use = halve_threshold; | ||
585 | |||
567 | err = 0; | 586 | err = 0; |
568 | while (tn->bits > 1 && | 587 | while (tn->bits > 1 && |
569 | 100 * (tnode_child_length(tn) - tn->empty_children) < | 588 | 100 * (tnode_child_length(tn) - tn->empty_children) < |
570 | halve_threshold * tnode_child_length(tn)) { | 589 | halve_threshold_use * tnode_child_length(tn)) { |
571 | 590 | ||
572 | old_tn = tn; | 591 | old_tn = tn; |
573 | tn = halve(t, tn); | 592 | tn = halve(t, tn); |
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_connection_sock.c b/net/ipv4/inet_connection_sock.c index fe3c6d3d0c91..94468a76c5b4 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c | |||
@@ -494,7 +494,7 @@ void inet_csk_reqsk_queue_prune(struct sock *parent, | |||
494 | EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_prune); | 494 | EXPORT_SYMBOL_GPL(inet_csk_reqsk_queue_prune); |
495 | 495 | ||
496 | struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req, | 496 | struct sock *inet_csk_clone(struct sock *sk, const struct request_sock *req, |
497 | const unsigned int __nocast priority) | 497 | const gfp_t priority) |
498 | { | 498 | { |
499 | struct sock *newsk = sk_clone(sk, priority); | 499 | struct sock *newsk = sk_clone(sk, priority); |
500 | 500 | ||
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 4d1502a49852..a010e9a68811 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,11 +106,12 @@ 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); |
113 | inet_twsk_dead_node_init(tw); | 113 | inet_twsk_dead_node_init(tw); |
114 | __module_get(tw->tw_prot->owner); | ||
114 | } | 115 | } |
115 | 116 | ||
116 | return tw; | 117 | return tw; |
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/ipvs/ip_vs_app.c b/net/ipv4/ipvs/ip_vs_app.c index 6e092dadb388..fc6f95aaa969 100644 --- a/net/ipv4/ipvs/ip_vs_app.c +++ b/net/ipv4/ipvs/ip_vs_app.c | |||
@@ -604,7 +604,7 @@ static struct file_operations ip_vs_app_fops = { | |||
604 | /* | 604 | /* |
605 | * Replace a segment of data with a new segment | 605 | * Replace a segment of data with a new segment |
606 | */ | 606 | */ |
607 | int ip_vs_skb_replace(struct sk_buff *skb, int pri, | 607 | int ip_vs_skb_replace(struct sk_buff *skb, gfp_t pri, |
608 | char *o_buf, int o_len, char *n_buf, int n_len) | 608 | char *o_buf, int o_len, char *n_buf, int n_len) |
609 | { | 609 | { |
610 | struct iphdr *iph; | 610 | struct iphdr *iph; |
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig index 3cf9b451675c..7d917e4ce1d9 100644 --- a/net/ipv4/netfilter/Kconfig +++ b/net/ipv4/netfilter/Kconfig | |||
@@ -139,9 +139,10 @@ config IP_NF_AMANDA | |||
139 | 139 | ||
140 | config IP_NF_PPTP | 140 | config IP_NF_PPTP |
141 | tristate 'PPTP protocol support' | 141 | tristate 'PPTP protocol support' |
142 | depends on IP_NF_CONNTRACK | ||
142 | help | 143 | help |
143 | This module adds support for PPTP (Point to Point Tunnelling | 144 | This module adds support for PPTP (Point to Point Tunnelling |
144 | Protocol, RFC2637) conncection tracking and NAT. | 145 | Protocol, RFC2637) connection tracking and NAT. |
145 | 146 | ||
146 | If you are running PPTP sessions over a stateful firewall or NAT | 147 | If you are running PPTP sessions over a stateful firewall or NAT |
147 | box, you may want to enable this feature. | 148 | box, you may want to enable this feature. |
@@ -498,9 +499,14 @@ config IP_NF_TARGET_LOG | |||
498 | To compile it as a module, choose M here. If unsure, say N. | 499 | To compile it as a module, choose M here. If unsure, say N. |
499 | 500 | ||
500 | config IP_NF_TARGET_ULOG | 501 | config IP_NF_TARGET_ULOG |
501 | tristate "ULOG target support" | 502 | tristate "ULOG target support (OBSOLETE)" |
502 | depends on IP_NF_IPTABLES | 503 | depends on IP_NF_IPTABLES |
503 | ---help--- | 504 | ---help--- |
505 | |||
506 | This option enables the old IPv4-only "ipt_ULOG" implementation | ||
507 | which has been obsoleted by the new "nfnetlink_log" code (see | ||
508 | CONFIG_NETFILTER_NETLINK_LOG). | ||
509 | |||
504 | This option adds a `ULOG' target, which allows you to create rules in | 510 | This option adds a `ULOG' target, which allows you to create rules in |
505 | any iptables table. The packet is passed to a userspace logging | 511 | any iptables table. The packet is passed to a userspace logging |
506 | daemon using netlink multicast sockets; unlike the LOG target | 512 | daemon using netlink multicast sockets; unlike the LOG target |
@@ -537,6 +543,17 @@ config IP_NF_TARGET_TCPMSS | |||
537 | 543 | ||
538 | To compile it as a module, choose M here. If unsure, say N. | 544 | To compile it as a module, choose M here. If unsure, say N. |
539 | 545 | ||
546 | config IP_NF_TARGET_NFQUEUE | ||
547 | tristate "NFQUEUE Target Support" | ||
548 | depends on IP_NF_IPTABLES | ||
549 | help | ||
550 | This Target replaced the old obsolete QUEUE target. | ||
551 | |||
552 | As opposed to QUEUE, it supports 65535 different queues, | ||
553 | not just one. | ||
554 | |||
555 | To compile it as a module, choose M here. If unsure, say N. | ||
556 | |||
540 | # NAT + specific targets | 557 | # NAT + specific targets |
541 | config IP_NF_NAT | 558 | config IP_NF_NAT |
542 | tristate "Full NAT" | 559 | 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/arp_tables.c b/net/ipv4/netfilter/arp_tables.c index fa1634256680..a7969286e6e7 100644 --- a/net/ipv4/netfilter/arp_tables.c +++ b/net/ipv4/netfilter/arp_tables.c | |||
@@ -716,8 +716,10 @@ static int translate_table(const char *name, | |||
716 | } | 716 | } |
717 | 717 | ||
718 | /* And one copy for every other CPU */ | 718 | /* And one copy for every other CPU */ |
719 | for (i = 1; i < num_possible_cpus(); i++) { | 719 | for_each_cpu(i) { |
720 | memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i, | 720 | if (i == 0) |
721 | continue; | ||
722 | memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i, | ||
721 | newinfo->entries, | 723 | newinfo->entries, |
722 | SMP_ALIGN(newinfo->size)); | 724 | SMP_ALIGN(newinfo->size)); |
723 | } | 725 | } |
@@ -767,7 +769,7 @@ static void get_counters(const struct arpt_table_info *t, | |||
767 | unsigned int cpu; | 769 | unsigned int cpu; |
768 | unsigned int i; | 770 | unsigned int i; |
769 | 771 | ||
770 | for (cpu = 0; cpu < num_possible_cpus(); cpu++) { | 772 | for_each_cpu(cpu) { |
771 | i = 0; | 773 | i = 0; |
772 | ARPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), | 774 | ARPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), |
773 | t->size, | 775 | t->size, |
@@ -885,7 +887,8 @@ static int do_replace(void __user *user, unsigned int len) | |||
885 | return -ENOMEM; | 887 | return -ENOMEM; |
886 | 888 | ||
887 | newinfo = vmalloc(sizeof(struct arpt_table_info) | 889 | newinfo = vmalloc(sizeof(struct arpt_table_info) |
888 | + SMP_ALIGN(tmp.size) * num_possible_cpus()); | 890 | + SMP_ALIGN(tmp.size) * |
891 | (highest_possible_processor_id()+1)); | ||
889 | if (!newinfo) | 892 | if (!newinfo) |
890 | return -ENOMEM; | 893 | return -ENOMEM; |
891 | 894 | ||
@@ -1158,7 +1161,8 @@ int arpt_register_table(struct arpt_table *table, | |||
1158 | = { 0, 0, 0, { 0 }, { 0 }, { } }; | 1161 | = { 0, 0, 0, { 0 }, { 0 }, { } }; |
1159 | 1162 | ||
1160 | newinfo = vmalloc(sizeof(struct arpt_table_info) | 1163 | newinfo = vmalloc(sizeof(struct arpt_table_info) |
1161 | + SMP_ALIGN(repl->size) * num_possible_cpus()); | 1164 | + SMP_ALIGN(repl->size) * |
1165 | (highest_possible_processor_id()+1)); | ||
1162 | if (!newinfo) { | 1166 | if (!newinfo) { |
1163 | ret = -ENOMEM; | 1167 | ret = -ENOMEM; |
1164 | return ret; | 1168 | return ret; |
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c index ea65dd3e517a..07a80b56e8dc 100644 --- a/net/ipv4/netfilter/ip_conntrack_core.c +++ b/net/ipv4/netfilter/ip_conntrack_core.c | |||
@@ -1119,7 +1119,7 @@ void __ip_ct_refresh_acct(struct ip_conntrack *ct, | |||
1119 | unsigned long extra_jiffies, | 1119 | unsigned long extra_jiffies, |
1120 | int do_acct) | 1120 | int do_acct) |
1121 | { | 1121 | { |
1122 | int do_event = 0; | 1122 | int event = 0; |
1123 | 1123 | ||
1124 | IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct); | 1124 | IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct); |
1125 | IP_NF_ASSERT(skb); | 1125 | IP_NF_ASSERT(skb); |
@@ -1129,13 +1129,13 @@ void __ip_ct_refresh_acct(struct ip_conntrack *ct, | |||
1129 | /* If not in hash table, timer will not be active yet */ | 1129 | /* If not in hash table, timer will not be active yet */ |
1130 | if (!is_confirmed(ct)) { | 1130 | if (!is_confirmed(ct)) { |
1131 | ct->timeout.expires = extra_jiffies; | 1131 | ct->timeout.expires = extra_jiffies; |
1132 | do_event = 1; | 1132 | event = IPCT_REFRESH; |
1133 | } else { | 1133 | } else { |
1134 | /* Need del_timer for race avoidance (may already be dying). */ | 1134 | /* Need del_timer for race avoidance (may already be dying). */ |
1135 | if (del_timer(&ct->timeout)) { | 1135 | if (del_timer(&ct->timeout)) { |
1136 | ct->timeout.expires = jiffies + extra_jiffies; | 1136 | ct->timeout.expires = jiffies + extra_jiffies; |
1137 | add_timer(&ct->timeout); | 1137 | add_timer(&ct->timeout); |
1138 | do_event = 1; | 1138 | event = IPCT_REFRESH; |
1139 | } | 1139 | } |
1140 | } | 1140 | } |
1141 | 1141 | ||
@@ -1144,14 +1144,17 @@ void __ip_ct_refresh_acct(struct ip_conntrack *ct, | |||
1144 | ct->counters[CTINFO2DIR(ctinfo)].packets++; | 1144 | ct->counters[CTINFO2DIR(ctinfo)].packets++; |
1145 | ct->counters[CTINFO2DIR(ctinfo)].bytes += | 1145 | ct->counters[CTINFO2DIR(ctinfo)].bytes += |
1146 | ntohs(skb->nh.iph->tot_len); | 1146 | ntohs(skb->nh.iph->tot_len); |
1147 | if ((ct->counters[CTINFO2DIR(ctinfo)].packets & 0x80000000) | ||
1148 | || (ct->counters[CTINFO2DIR(ctinfo)].bytes & 0x80000000)) | ||
1149 | event |= IPCT_COUNTER_FILLING; | ||
1147 | } | 1150 | } |
1148 | #endif | 1151 | #endif |
1149 | 1152 | ||
1150 | write_unlock_bh(&ip_conntrack_lock); | 1153 | write_unlock_bh(&ip_conntrack_lock); |
1151 | 1154 | ||
1152 | /* must be unlocked when calling event cache */ | 1155 | /* must be unlocked when calling event cache */ |
1153 | if (do_event) | 1156 | if (event) |
1154 | ip_conntrack_event_cache(IPCT_REFRESH, skb); | 1157 | ip_conntrack_event_cache(event, skb); |
1155 | } | 1158 | } |
1156 | 1159 | ||
1157 | #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ | 1160 | #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ |
diff --git a/net/ipv4/netfilter/ip_conntrack_netbios_ns.c b/net/ipv4/netfilter/ip_conntrack_netbios_ns.c index 577bac22dcc6..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) { |
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c index b08a432efcf8..166e6069f121 100644 --- a/net/ipv4/netfilter/ip_conntrack_netlink.c +++ b/net/ipv4/netfilter/ip_conntrack_netlink.c | |||
@@ -177,11 +177,11 @@ ctnetlink_dump_counters(struct sk_buff *skb, const struct ip_conntrack *ct, | |||
177 | struct nfattr *nest_count = NFA_NEST(skb, type); | 177 | struct nfattr *nest_count = NFA_NEST(skb, type); |
178 | u_int64_t tmp; | 178 | u_int64_t tmp; |
179 | 179 | ||
180 | tmp = cpu_to_be64(ct->counters[dir].packets); | 180 | tmp = htonl(ct->counters[dir].packets); |
181 | NFA_PUT(skb, CTA_COUNTERS_PACKETS, sizeof(u_int64_t), &tmp); | 181 | NFA_PUT(skb, CTA_COUNTERS32_PACKETS, sizeof(u_int32_t), &tmp); |
182 | 182 | ||
183 | tmp = cpu_to_be64(ct->counters[dir].bytes); | 183 | tmp = htonl(ct->counters[dir].bytes); |
184 | NFA_PUT(skb, CTA_COUNTERS_BYTES, sizeof(u_int64_t), &tmp); | 184 | NFA_PUT(skb, CTA_COUNTERS32_BYTES, sizeof(u_int32_t), &tmp); |
185 | 185 | ||
186 | NFA_NEST_END(skb, nest_count); | 186 | NFA_NEST_END(skb, nest_count); |
187 | 187 | ||
@@ -833,7 +833,8 @@ out: | |||
833 | static inline int | 833 | static inline int |
834 | ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[]) | 834 | ctnetlink_change_status(struct ip_conntrack *ct, struct nfattr *cda[]) |
835 | { | 835 | { |
836 | unsigned long d, status = *(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1]); | 836 | unsigned long d; |
837 | unsigned status = ntohl(*(u_int32_t *)NFA_DATA(cda[CTA_STATUS-1])); | ||
837 | d = ct->status ^ status; | 838 | d = ct->status ^ status; |
838 | 839 | ||
839 | if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING)) | 840 | if (d & (IPS_EXPECTED|IPS_CONFIRMED|IPS_DYING)) |
@@ -948,6 +949,31 @@ ctnetlink_change_timeout(struct ip_conntrack *ct, struct nfattr *cda[]) | |||
948 | return 0; | 949 | return 0; |
949 | } | 950 | } |
950 | 951 | ||
952 | static inline int | ||
953 | ctnetlink_change_protoinfo(struct ip_conntrack *ct, struct nfattr *cda[]) | ||
954 | { | ||
955 | struct nfattr *tb[CTA_PROTOINFO_MAX], *attr = cda[CTA_PROTOINFO-1]; | ||
956 | struct ip_conntrack_protocol *proto; | ||
957 | u_int16_t npt = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum; | ||
958 | int err = 0; | ||
959 | |||
960 | if (nfattr_parse_nested(tb, CTA_PROTOINFO_MAX, attr) < 0) | ||
961 | goto nfattr_failure; | ||
962 | |||
963 | proto = ip_conntrack_proto_find_get(npt); | ||
964 | if (!proto) | ||
965 | return -EINVAL; | ||
966 | |||
967 | if (proto->from_nfattr) | ||
968 | err = proto->from_nfattr(tb, ct); | ||
969 | ip_conntrack_proto_put(proto); | ||
970 | |||
971 | return err; | ||
972 | |||
973 | nfattr_failure: | ||
974 | return -ENOMEM; | ||
975 | } | ||
976 | |||
951 | static int | 977 | static int |
952 | ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[]) | 978 | ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[]) |
953 | { | 979 | { |
@@ -973,6 +999,12 @@ ctnetlink_change_conntrack(struct ip_conntrack *ct, struct nfattr *cda[]) | |||
973 | return err; | 999 | return err; |
974 | } | 1000 | } |
975 | 1001 | ||
1002 | if (cda[CTA_PROTOINFO-1]) { | ||
1003 | err = ctnetlink_change_protoinfo(ct, cda); | ||
1004 | if (err < 0) | ||
1005 | return err; | ||
1006 | } | ||
1007 | |||
976 | DEBUGP("all done\n"); | 1008 | DEBUGP("all done\n"); |
977 | return 0; | 1009 | return 0; |
978 | } | 1010 | } |
@@ -1002,6 +1034,12 @@ ctnetlink_create_conntrack(struct nfattr *cda[], | |||
1002 | if (err < 0) | 1034 | if (err < 0) |
1003 | goto err; | 1035 | goto err; |
1004 | 1036 | ||
1037 | if (cda[CTA_PROTOINFO-1]) { | ||
1038 | err = ctnetlink_change_protoinfo(ct, cda); | ||
1039 | if (err < 0) | ||
1040 | return err; | ||
1041 | } | ||
1042 | |||
1005 | ct->helper = ip_conntrack_helper_find_get(rtuple); | 1043 | ct->helper = ip_conntrack_helper_find_get(rtuple); |
1006 | 1044 | ||
1007 | add_timer(&ct->timeout); | 1045 | add_timer(&ct->timeout); |
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_icmp.c b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c index 838d1d69b36e..98f0015dd255 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_icmp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_icmp.c | |||
@@ -296,8 +296,7 @@ static int icmp_nfattr_to_tuple(struct nfattr *tb[], | |||
296 | struct ip_conntrack_tuple *tuple) | 296 | struct ip_conntrack_tuple *tuple) |
297 | { | 297 | { |
298 | if (!tb[CTA_PROTO_ICMP_TYPE-1] | 298 | if (!tb[CTA_PROTO_ICMP_TYPE-1] |
299 | || !tb[CTA_PROTO_ICMP_CODE-1] | 299 | || !tb[CTA_PROTO_ICMP_CODE-1]) |
300 | || !tb[CTA_PROTO_ICMP_ID-1]) | ||
301 | return -1; | 300 | return -1; |
302 | 301 | ||
303 | tuple->dst.u.icmp.type = | 302 | tuple->dst.u.icmp.type = |
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..d6701cafbcc2 100644 --- a/net/ipv4/netfilter/ip_conntrack_proto_tcp.c +++ b/net/ipv4/netfilter/ip_conntrack_proto_tcp.c | |||
@@ -341,17 +341,43 @@ static int tcp_print_conntrack(struct seq_file *s, | |||
341 | static int tcp_to_nfattr(struct sk_buff *skb, struct nfattr *nfa, | 341 | static int tcp_to_nfattr(struct sk_buff *skb, struct nfattr *nfa, |
342 | const struct ip_conntrack *ct) | 342 | const struct ip_conntrack *ct) |
343 | { | 343 | { |
344 | struct nfattr *nest_parms = NFA_NEST(skb, CTA_PROTOINFO_TCP); | ||
345 | |||
344 | read_lock_bh(&tcp_lock); | 346 | read_lock_bh(&tcp_lock); |
345 | NFA_PUT(skb, CTA_PROTOINFO_TCP_STATE, sizeof(u_int8_t), | 347 | NFA_PUT(skb, CTA_PROTOINFO_TCP_STATE, sizeof(u_int8_t), |
346 | &ct->proto.tcp.state); | 348 | &ct->proto.tcp.state); |
347 | read_unlock_bh(&tcp_lock); | 349 | read_unlock_bh(&tcp_lock); |
348 | 350 | ||
351 | NFA_NEST_END(skb, nest_parms); | ||
352 | |||
349 | return 0; | 353 | return 0; |
350 | 354 | ||
351 | nfattr_failure: | 355 | nfattr_failure: |
352 | read_unlock_bh(&tcp_lock); | 356 | read_unlock_bh(&tcp_lock); |
353 | return -1; | 357 | return -1; |
354 | } | 358 | } |
359 | |||
360 | static int nfattr_to_tcp(struct nfattr *cda[], struct ip_conntrack *ct) | ||
361 | { | ||
362 | struct nfattr *attr = cda[CTA_PROTOINFO_TCP-1]; | ||
363 | struct nfattr *tb[CTA_PROTOINFO_TCP_MAX]; | ||
364 | |||
365 | if (nfattr_parse_nested(tb, CTA_PROTOINFO_TCP_MAX, attr) < 0) | ||
366 | goto nfattr_failure; | ||
367 | |||
368 | if (!tb[CTA_PROTOINFO_TCP_STATE-1]) | ||
369 | return -EINVAL; | ||
370 | |||
371 | write_lock_bh(&tcp_lock); | ||
372 | ct->proto.tcp.state = | ||
373 | *(u_int8_t *)NFA_DATA(tb[CTA_PROTOINFO_TCP_STATE-1]); | ||
374 | write_unlock_bh(&tcp_lock); | ||
375 | |||
376 | return 0; | ||
377 | |||
378 | nfattr_failure: | ||
379 | return -1; | ||
380 | } | ||
355 | #endif | 381 | #endif |
356 | 382 | ||
357 | static unsigned int get_conntrack_index(const struct tcphdr *tcph) | 383 | static unsigned int get_conntrack_index(const struct tcphdr *tcph) |
@@ -1014,7 +1040,8 @@ static int tcp_packet(struct ip_conntrack *conntrack, | |||
1014 | /* Set ASSURED if we see see valid ack in ESTABLISHED | 1040 | /* Set ASSURED if we see see valid ack in ESTABLISHED |
1015 | after SYN_RECV or a valid answer for a picked up | 1041 | after SYN_RECV or a valid answer for a picked up |
1016 | connection. */ | 1042 | connection. */ |
1017 | set_bit(IPS_ASSURED_BIT, &conntrack->status); | 1043 | set_bit(IPS_ASSURED_BIT, &conntrack->status); |
1044 | ip_conntrack_event_cache(IPCT_STATUS, skb); | ||
1018 | } | 1045 | } |
1019 | ip_ct_refresh_acct(conntrack, ctinfo, skb, timeout); | 1046 | ip_ct_refresh_acct(conntrack, ctinfo, skb, timeout); |
1020 | 1047 | ||
@@ -1122,6 +1149,7 @@ struct ip_conntrack_protocol ip_conntrack_protocol_tcp = | |||
1122 | #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ | 1149 | #if defined(CONFIG_IP_NF_CONNTRACK_NETLINK) || \ |
1123 | defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) | 1150 | defined(CONFIG_IP_NF_CONNTRACK_NETLINK_MODULE) |
1124 | .to_nfattr = tcp_to_nfattr, | 1151 | .to_nfattr = tcp_to_nfattr, |
1152 | .from_nfattr = nfattr_to_tcp, | ||
1125 | .tuple_to_nfattr = ip_ct_port_tuple_to_nfattr, | 1153 | .tuple_to_nfattr = ip_ct_port_tuple_to_nfattr, |
1126 | .nfattr_to_tuple = ip_ct_port_nfattr_to_tuple, | 1154 | .nfattr_to_tuple = ip_ct_port_nfattr_to_tuple, |
1127 | #endif | 1155 | #endif |
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/ip_tables.c b/net/ipv4/netfilter/ip_tables.c index eef99a1b5de6..75c27e92f6ab 100644 --- a/net/ipv4/netfilter/ip_tables.c +++ b/net/ipv4/netfilter/ip_tables.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <asm/semaphore.h> | 27 | #include <asm/semaphore.h> |
28 | #include <linux/proc_fs.h> | 28 | #include <linux/proc_fs.h> |
29 | #include <linux/err.h> | 29 | #include <linux/err.h> |
30 | #include <linux/cpumask.h> | ||
30 | 31 | ||
31 | #include <linux/netfilter_ipv4/ip_tables.h> | 32 | #include <linux/netfilter_ipv4/ip_tables.h> |
32 | 33 | ||
@@ -921,8 +922,10 @@ translate_table(const char *name, | |||
921 | } | 922 | } |
922 | 923 | ||
923 | /* And one copy for every other CPU */ | 924 | /* And one copy for every other CPU */ |
924 | for (i = 1; i < num_possible_cpus(); i++) { | 925 | for_each_cpu(i) { |
925 | memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i, | 926 | if (i == 0) |
927 | continue; | ||
928 | memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i, | ||
926 | newinfo->entries, | 929 | newinfo->entries, |
927 | SMP_ALIGN(newinfo->size)); | 930 | SMP_ALIGN(newinfo->size)); |
928 | } | 931 | } |
@@ -943,7 +946,7 @@ replace_table(struct ipt_table *table, | |||
943 | struct ipt_entry *table_base; | 946 | struct ipt_entry *table_base; |
944 | unsigned int i; | 947 | unsigned int i; |
945 | 948 | ||
946 | for (i = 0; i < num_possible_cpus(); i++) { | 949 | for_each_cpu(i) { |
947 | table_base = | 950 | table_base = |
948 | (void *)newinfo->entries | 951 | (void *)newinfo->entries |
949 | + TABLE_OFFSET(newinfo, i); | 952 | + TABLE_OFFSET(newinfo, i); |
@@ -990,7 +993,7 @@ get_counters(const struct ipt_table_info *t, | |||
990 | unsigned int cpu; | 993 | unsigned int cpu; |
991 | unsigned int i; | 994 | unsigned int i; |
992 | 995 | ||
993 | for (cpu = 0; cpu < num_possible_cpus(); cpu++) { | 996 | for_each_cpu(cpu) { |
994 | i = 0; | 997 | i = 0; |
995 | IPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), | 998 | IPT_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), |
996 | t->size, | 999 | t->size, |
@@ -1128,7 +1131,8 @@ do_replace(void __user *user, unsigned int len) | |||
1128 | return -ENOMEM; | 1131 | return -ENOMEM; |
1129 | 1132 | ||
1130 | newinfo = vmalloc(sizeof(struct ipt_table_info) | 1133 | newinfo = vmalloc(sizeof(struct ipt_table_info) |
1131 | + SMP_ALIGN(tmp.size) * num_possible_cpus()); | 1134 | + SMP_ALIGN(tmp.size) * |
1135 | (highest_possible_processor_id()+1)); | ||
1132 | if (!newinfo) | 1136 | if (!newinfo) |
1133 | return -ENOMEM; | 1137 | return -ENOMEM; |
1134 | 1138 | ||
@@ -1458,7 +1462,8 @@ int ipt_register_table(struct ipt_table *table, const struct ipt_replace *repl) | |||
1458 | = { 0, 0, 0, { 0 }, { 0 }, { } }; | 1462 | = { 0, 0, 0, { 0 }, { 0 }, { } }; |
1459 | 1463 | ||
1460 | newinfo = vmalloc(sizeof(struct ipt_table_info) | 1464 | newinfo = vmalloc(sizeof(struct ipt_table_info) |
1461 | + SMP_ALIGN(repl->size) * num_possible_cpus()); | 1465 | + SMP_ALIGN(repl->size) * |
1466 | (highest_possible_processor_id()+1)); | ||
1462 | if (!newinfo) | 1467 | if (!newinfo) |
1463 | return -ENOMEM; | 1468 | return -ENOMEM; |
1464 | 1469 | ||
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_bic.c b/net/ipv4/tcp_bic.c index b940346de4e7..6d80e063c187 100644 --- a/net/ipv4/tcp_bic.c +++ b/net/ipv4/tcp_bic.c | |||
@@ -136,7 +136,7 @@ static inline void bictcp_update(struct bictcp *ca, u32 cwnd) | |||
136 | else if (cwnd < ca->last_max_cwnd + max_increment*(BICTCP_B-1)) | 136 | else if (cwnd < ca->last_max_cwnd + max_increment*(BICTCP_B-1)) |
137 | /* slow start */ | 137 | /* slow start */ |
138 | ca->cnt = (cwnd * (BICTCP_B-1)) | 138 | ca->cnt = (cwnd * (BICTCP_B-1)) |
139 | / cwnd-ca->last_max_cwnd; | 139 | / (cwnd - ca->last_max_cwnd); |
140 | else | 140 | else |
141 | /* linear increase */ | 141 | /* linear increase */ |
142 | ca->cnt = cwnd / max_increment; | 142 | ca->cnt = cwnd / max_increment; |
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 d6e3d269e906..7114031fdc70 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)) { |
@@ -435,7 +435,16 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, unsigned int mss | |||
435 | int nsize, old_factor; | 435 | int nsize, old_factor; |
436 | u16 flags; | 436 | u16 flags; |
437 | 437 | ||
438 | BUG_ON(len >= skb->len); | 438 | if (unlikely(len >= skb->len)) { |
439 | if (net_ratelimit()) { | ||
440 | printk(KERN_DEBUG "TCP: seg_size=%u, mss=%u, seq=%u, " | ||
441 | "end_seq=%u, skb->len=%u.\n", len, mss_now, | ||
442 | TCP_SKB_CB(skb)->seq, TCP_SKB_CB(skb)->end_seq, | ||
443 | skb->len); | ||
444 | WARN_ON(1); | ||
445 | } | ||
446 | return 0; | ||
447 | } | ||
439 | 448 | ||
440 | nsize = skb_headlen(skb) - len; | 449 | nsize = skb_headlen(skb) - len; |
441 | if (nsize < 0) | 450 | if (nsize < 0) |
@@ -1610,7 +1619,7 @@ void tcp_send_fin(struct sock *sk) | |||
1610 | * was unread data in the receive queue. This behavior is recommended | 1619 | * was unread data in the receive queue. This behavior is recommended |
1611 | * by draft-ietf-tcpimpl-prob-03.txt section 3.10. -DaveM | 1620 | * by draft-ietf-tcpimpl-prob-03.txt section 3.10. -DaveM |
1612 | */ | 1621 | */ |
1613 | void tcp_send_active_reset(struct sock *sk, unsigned int __nocast priority) | 1622 | void tcp_send_active_reset(struct sock *sk, gfp_t priority) |
1614 | { | 1623 | { |
1615 | struct tcp_sock *tp = tcp_sk(sk); | 1624 | struct tcp_sock *tp = tcp_sk(sk); |
1616 | struct sk_buff *skb; | 1625 | struct sk_buff *skb; |
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/esp6.c b/net/ipv6/esp6.c index 9b27460f0cc7..40d9a1935ab5 100644 --- a/net/ipv6/esp6.c +++ b/net/ipv6/esp6.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include <net/esp.h> | 31 | #include <net/esp.h> |
32 | #include <asm/scatterlist.h> | 32 | #include <asm/scatterlist.h> |
33 | #include <linux/crypto.h> | 33 | #include <linux/crypto.h> |
34 | #include <linux/kernel.h> | ||
34 | #include <linux/pfkeyv2.h> | 35 | #include <linux/pfkeyv2.h> |
35 | #include <linux/random.h> | 36 | #include <linux/random.h> |
36 | #include <net/icmp.h> | 37 | #include <net/icmp.h> |
@@ -66,10 +67,10 @@ static int esp6_output(struct xfrm_state *x, struct sk_buff *skb) | |||
66 | 67 | ||
67 | alen = esp->auth.icv_trunc_len; | 68 | alen = esp->auth.icv_trunc_len; |
68 | tfm = esp->conf.tfm; | 69 | tfm = esp->conf.tfm; |
69 | blksize = (crypto_tfm_alg_blocksize(tfm) + 3) & ~3; | 70 | blksize = ALIGN(crypto_tfm_alg_blocksize(tfm), 4); |
70 | clen = (clen + 2 + blksize-1)&~(blksize-1); | 71 | clen = ALIGN(clen + 2, blksize); |
71 | if (esp->conf.padlen) | 72 | if (esp->conf.padlen) |
72 | clen = (clen + esp->conf.padlen-1)&~(esp->conf.padlen-1); | 73 | clen = ALIGN(clen, esp->conf.padlen); |
73 | 74 | ||
74 | if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) { | 75 | if ((nfrags = skb_cow_data(skb, clen-skb->len+alen, &trailer)) < 0) { |
75 | goto error; | 76 | goto error; |
@@ -133,7 +134,7 @@ static int esp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, stru | |||
133 | struct ipv6_esp_hdr *esph; | 134 | struct ipv6_esp_hdr *esph; |
134 | struct esp_data *esp = x->data; | 135 | struct esp_data *esp = x->data; |
135 | struct sk_buff *trailer; | 136 | struct sk_buff *trailer; |
136 | int blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); | 137 | int blksize = ALIGN(crypto_tfm_alg_blocksize(esp->conf.tfm), 4); |
137 | int alen = esp->auth.icv_trunc_len; | 138 | int alen = esp->auth.icv_trunc_len; |
138 | int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen; | 139 | int elen = skb->len - sizeof(struct ipv6_esp_hdr) - esp->conf.ivlen - alen; |
139 | 140 | ||
@@ -235,16 +236,17 @@ out_nofree: | |||
235 | static u32 esp6_get_max_size(struct xfrm_state *x, int mtu) | 236 | static u32 esp6_get_max_size(struct xfrm_state *x, int mtu) |
236 | { | 237 | { |
237 | struct esp_data *esp = x->data; | 238 | struct esp_data *esp = x->data; |
238 | u32 blksize = crypto_tfm_alg_blocksize(esp->conf.tfm); | 239 | u32 blksize = ALIGN(crypto_tfm_alg_blocksize(esp->conf.tfm), 4); |
239 | 240 | ||
240 | if (x->props.mode) { | 241 | if (x->props.mode) { |
241 | mtu = (mtu + 2 + blksize-1)&~(blksize-1); | 242 | mtu = ALIGN(mtu + 2, blksize); |
242 | } else { | 243 | } else { |
243 | /* The worst case. */ | 244 | /* The worst case. */ |
244 | mtu += 2 + blksize; | 245 | u32 padsize = ((blksize - 1) & 7) + 1; |
246 | mtu = ALIGN(mtu + 2, padsize) + blksize - padsize; | ||
245 | } | 247 | } |
246 | if (esp->conf.padlen) | 248 | if (esp->conf.padlen) |
247 | mtu = (mtu + esp->conf.padlen-1)&~(esp->conf.padlen-1); | 249 | mtu = ALIGN(mtu, esp->conf.padlen); |
248 | 250 | ||
249 | return mtu + x->props.header_len + esp->auth.icv_full_len; | 251 | return mtu + x->props.header_len + esp->auth.icv_full_len; |
250 | } | 252 | } |
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/mcast.c b/net/ipv6/mcast.c index 519899fb11d5..39a96c768102 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
@@ -1393,7 +1393,7 @@ static void mld_sendpack(struct sk_buff *skb) | |||
1393 | 1393 | ||
1394 | static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel) | 1394 | static int grec_size(struct ifmcaddr6 *pmc, int type, int gdel, int sdel) |
1395 | { | 1395 | { |
1396 | return sizeof(struct mld2_grec) + 4*mld_scount(pmc,type,gdel,sdel); | 1396 | return sizeof(struct mld2_grec) + 16 * mld_scount(pmc,type,gdel,sdel); |
1397 | } | 1397 | } |
1398 | 1398 | ||
1399 | static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc, | 1399 | static struct sk_buff *add_grhead(struct sk_buff *skb, struct ifmcaddr6 *pmc, |
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c index 555a31347eda..305d9ee6d7db 100644 --- a/net/ipv6/ndisc.c +++ b/net/ipv6/ndisc.c | |||
@@ -1450,7 +1450,7 @@ void ndisc_send_redirect(struct sk_buff *skb, struct neighbour *neigh, | |||
1450 | 1450 | ||
1451 | static void pndisc_redo(struct sk_buff *skb) | 1451 | static void pndisc_redo(struct sk_buff *skb) |
1452 | { | 1452 | { |
1453 | ndisc_rcv(skb); | 1453 | ndisc_recv_ns(skb); |
1454 | kfree_skb(skb); | 1454 | kfree_skb(skb); |
1455 | } | 1455 | } |
1456 | 1456 | ||
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/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c index 2da514b16d95..21deec25a12b 100644 --- a/net/ipv6/netfilter/ip6_tables.c +++ b/net/ipv6/netfilter/ip6_tables.c | |||
@@ -28,6 +28,7 @@ | |||
28 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
29 | #include <asm/semaphore.h> | 29 | #include <asm/semaphore.h> |
30 | #include <linux/proc_fs.h> | 30 | #include <linux/proc_fs.h> |
31 | #include <linux/cpumask.h> | ||
31 | 32 | ||
32 | #include <linux/netfilter_ipv6/ip6_tables.h> | 33 | #include <linux/netfilter_ipv6/ip6_tables.h> |
33 | 34 | ||
@@ -950,8 +951,10 @@ translate_table(const char *name, | |||
950 | } | 951 | } |
951 | 952 | ||
952 | /* And one copy for every other CPU */ | 953 | /* And one copy for every other CPU */ |
953 | for (i = 1; i < num_possible_cpus(); i++) { | 954 | for_each_cpu(i) { |
954 | memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i, | 955 | if (i == 0) |
956 | continue; | ||
957 | memcpy(newinfo->entries + SMP_ALIGN(newinfo->size) * i, | ||
955 | newinfo->entries, | 958 | newinfo->entries, |
956 | SMP_ALIGN(newinfo->size)); | 959 | SMP_ALIGN(newinfo->size)); |
957 | } | 960 | } |
@@ -972,7 +975,7 @@ replace_table(struct ip6t_table *table, | |||
972 | struct ip6t_entry *table_base; | 975 | struct ip6t_entry *table_base; |
973 | unsigned int i; | 976 | unsigned int i; |
974 | 977 | ||
975 | for (i = 0; i < num_possible_cpus(); i++) { | 978 | for_each_cpu(i) { |
976 | table_base = | 979 | table_base = |
977 | (void *)newinfo->entries | 980 | (void *)newinfo->entries |
978 | + TABLE_OFFSET(newinfo, i); | 981 | + TABLE_OFFSET(newinfo, i); |
@@ -1019,7 +1022,7 @@ get_counters(const struct ip6t_table_info *t, | |||
1019 | unsigned int cpu; | 1022 | unsigned int cpu; |
1020 | unsigned int i; | 1023 | unsigned int i; |
1021 | 1024 | ||
1022 | for (cpu = 0; cpu < num_possible_cpus(); cpu++) { | 1025 | for_each_cpu(cpu) { |
1023 | i = 0; | 1026 | i = 0; |
1024 | IP6T_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), | 1027 | IP6T_ENTRY_ITERATE(t->entries + TABLE_OFFSET(t, cpu), |
1025 | t->size, | 1028 | t->size, |
@@ -1153,7 +1156,8 @@ do_replace(void __user *user, unsigned int len) | |||
1153 | return -ENOMEM; | 1156 | return -ENOMEM; |
1154 | 1157 | ||
1155 | newinfo = vmalloc(sizeof(struct ip6t_table_info) | 1158 | newinfo = vmalloc(sizeof(struct ip6t_table_info) |
1156 | + SMP_ALIGN(tmp.size) * num_possible_cpus()); | 1159 | + SMP_ALIGN(tmp.size) * |
1160 | (highest_possible_processor_id()+1)); | ||
1157 | if (!newinfo) | 1161 | if (!newinfo) |
1158 | return -ENOMEM; | 1162 | return -ENOMEM; |
1159 | 1163 | ||
@@ -1467,7 +1471,8 @@ int ip6t_register_table(struct ip6t_table *table, | |||
1467 | = { 0, 0, 0, { 0 }, { 0 }, { } }; | 1471 | = { 0, 0, 0, { 0 }, { 0 }, { } }; |
1468 | 1472 | ||
1469 | newinfo = vmalloc(sizeof(struct ip6t_table_info) | 1473 | newinfo = vmalloc(sizeof(struct ip6t_table_info) |
1470 | + SMP_ALIGN(repl->size) * num_possible_cpus()); | 1474 | + SMP_ALIGN(repl->size) * |
1475 | (highest_possible_processor_id()+1)); | ||
1471 | if (!newinfo) | 1476 | if (!newinfo) |
1472 | return -ENOMEM; | 1477 | return -ENOMEM; |
1473 | 1478 | ||
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..bf9519341fd3 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -99,7 +99,7 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum) | |||
99 | next:; | 99 | next:; |
100 | } | 100 | } |
101 | result = best; | 101 | result = best; |
102 | for(;; result += UDP_HTABLE_SIZE) { | 102 | for(i = 0; i < (1 << 16) / UDP_HTABLE_SIZE; i++, result += UDP_HTABLE_SIZE) { |
103 | if (result > sysctl_local_port_range[1]) | 103 | if (result > sysctl_local_port_range[1]) |
104 | result = sysctl_local_port_range[0] | 104 | result = sysctl_local_port_range[0] |
105 | + ((result - sysctl_local_port_range[0]) & | 105 | + ((result - sysctl_local_port_range[0]) & |
@@ -107,6 +107,8 @@ static int udp_v6_get_port(struct sock *sk, unsigned short snum) | |||
107 | if (!udp_lport_inuse(result)) | 107 | if (!udp_lport_inuse(result)) |
108 | break; | 108 | break; |
109 | } | 109 | } |
110 | if (i >= (1 << 16) / UDP_HTABLE_SIZE) | ||
111 | goto fail; | ||
110 | gotit: | 112 | gotit: |
111 | udp_port_rover = snum = result; | 113 | udp_port_rover = snum = result; |
112 | } else { | 114 | } else { |
@@ -852,10 +854,16 @@ do_append_data: | |||
852 | else if (!corkreq) | 854 | else if (!corkreq) |
853 | err = udp_v6_push_pending_frames(sk, up); | 855 | err = udp_v6_push_pending_frames(sk, up); |
854 | 856 | ||
855 | if (dst && connected) | 857 | if (dst) { |
856 | ip6_dst_store(sk, dst, | 858 | if (connected) { |
857 | ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ? | 859 | ip6_dst_store(sk, dst, |
858 | &np->daddr : NULL); | 860 | ipv6_addr_equal(&fl->fl6_dst, &np->daddr) ? |
861 | &np->daddr : NULL); | ||
862 | } else { | ||
863 | dst_release(dst); | ||
864 | } | ||
865 | } | ||
866 | |||
859 | if (err > 0) | 867 | if (err > 0) |
860 | err = np->recverr ? net_xmit_errno(err) : 0; | 868 | err = np->recverr ? net_xmit_errno(err) : 0; |
861 | release_sock(sk); | 869 | 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/key/af_key.c b/net/key/af_key.c index 4879743b945a..39031684b65c 100644 --- a/net/key/af_key.c +++ b/net/key/af_key.c | |||
@@ -185,7 +185,7 @@ static int pfkey_release(struct socket *sock) | |||
185 | } | 185 | } |
186 | 186 | ||
187 | static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2, | 187 | static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2, |
188 | int allocation, struct sock *sk) | 188 | gfp_t allocation, struct sock *sk) |
189 | { | 189 | { |
190 | int err = -ENOBUFS; | 190 | int err = -ENOBUFS; |
191 | 191 | ||
@@ -217,7 +217,7 @@ static int pfkey_broadcast_one(struct sk_buff *skb, struct sk_buff **skb2, | |||
217 | #define BROADCAST_ONE 1 | 217 | #define BROADCAST_ONE 1 |
218 | #define BROADCAST_REGISTERED 2 | 218 | #define BROADCAST_REGISTERED 2 |
219 | #define BROADCAST_PROMISC_ONLY 4 | 219 | #define BROADCAST_PROMISC_ONLY 4 |
220 | static int pfkey_broadcast(struct sk_buff *skb, int allocation, | 220 | static int pfkey_broadcast(struct sk_buff *skb, gfp_t allocation, |
221 | int broadcast_flags, struct sock *one_sk) | 221 | int broadcast_flags, struct sock *one_sk) |
222 | { | 222 | { |
223 | struct sock *sk; | 223 | struct sock *sk; |
@@ -1416,7 +1416,8 @@ static int pfkey_get(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, | |||
1416 | return 0; | 1416 | return 0; |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig, int allocation) | 1419 | static struct sk_buff *compose_sadb_supported(struct sadb_msg *orig, |
1420 | gfp_t allocation) | ||
1420 | { | 1421 | { |
1421 | struct sk_buff *skb; | 1422 | struct sk_buff *skb; |
1422 | struct sadb_msg *hdr; | 1423 | struct sadb_msg *hdr; |
@@ -2153,6 +2154,7 @@ out: | |||
2153 | 2154 | ||
2154 | static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs) | 2155 | static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *hdr, void **ext_hdrs) |
2155 | { | 2156 | { |
2157 | unsigned int dir; | ||
2156 | int err; | 2158 | int err; |
2157 | struct sadb_x_policy *pol; | 2159 | struct sadb_x_policy *pol; |
2158 | struct xfrm_policy *xp; | 2160 | struct xfrm_policy *xp; |
@@ -2161,7 +2163,11 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h | |||
2161 | if ((pol = ext_hdrs[SADB_X_EXT_POLICY-1]) == NULL) | 2163 | if ((pol = ext_hdrs[SADB_X_EXT_POLICY-1]) == NULL) |
2162 | return -EINVAL; | 2164 | return -EINVAL; |
2163 | 2165 | ||
2164 | xp = xfrm_policy_byid(0, pol->sadb_x_policy_id, | 2166 | dir = xfrm_policy_id2dir(pol->sadb_x_policy_id); |
2167 | if (dir >= XFRM_POLICY_MAX) | ||
2168 | return -EINVAL; | ||
2169 | |||
2170 | xp = xfrm_policy_byid(dir, pol->sadb_x_policy_id, | ||
2165 | hdr->sadb_msg_type == SADB_X_SPDDELETE2); | 2171 | hdr->sadb_msg_type == SADB_X_SPDDELETE2); |
2166 | if (xp == NULL) | 2172 | if (xp == NULL) |
2167 | return -ENOENT; | 2173 | return -ENOENT; |
@@ -2173,9 +2179,9 @@ static int pfkey_spdget(struct sock *sk, struct sk_buff *skb, struct sadb_msg *h | |||
2173 | if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) { | 2179 | if (hdr->sadb_msg_type == SADB_X_SPDDELETE2) { |
2174 | c.data.byid = 1; | 2180 | c.data.byid = 1; |
2175 | c.event = XFRM_MSG_DELPOLICY; | 2181 | c.event = XFRM_MSG_DELPOLICY; |
2176 | km_policy_notify(xp, pol->sadb_x_policy_dir-1, &c); | 2182 | km_policy_notify(xp, dir, &c); |
2177 | } else { | 2183 | } else { |
2178 | err = key_pol_get_resp(sk, xp, hdr, pol->sadb_x_policy_dir-1); | 2184 | err = key_pol_get_resp(sk, xp, hdr, dir); |
2179 | } | 2185 | } |
2180 | 2186 | ||
2181 | xfrm_pol_put(xp); | 2187 | xfrm_pol_put(xp); |
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..c761c15da421 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,7 @@ 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, gfp_t priority, struct proto *prot) |
838 | { | 871 | { |
839 | struct sock *sk = sk_alloc(family, priority, prot, 1); | 872 | struct sock *sk = sk_alloc(family, priority, prot, 1); |
840 | 873 | ||
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.c b/net/netfilter/nfnetlink.c index 49a3900e3d32..4bc27a6334c1 100644 --- a/net/netfilter/nfnetlink.c +++ b/net/netfilter/nfnetlink.c | |||
@@ -133,7 +133,7 @@ int nfattr_parse(struct nfattr *tb[], int maxattr, struct nfattr *nfa, int len) | |||
133 | memset(tb, 0, sizeof(struct nfattr *) * maxattr); | 133 | memset(tb, 0, sizeof(struct nfattr *) * maxattr); |
134 | 134 | ||
135 | while (NFA_OK(nfa, len)) { | 135 | while (NFA_OK(nfa, len)) { |
136 | unsigned flavor = nfa->nfa_type; | 136 | unsigned flavor = NFA_TYPE(nfa); |
137 | if (flavor && flavor <= maxattr) | 137 | if (flavor && flavor <= maxattr) |
138 | tb[flavor-1] = nfa; | 138 | tb[flavor-1] = nfa; |
139 | nfa = NFA_NEXT(nfa, len); | 139 | nfa = NFA_NEXT(nfa, len); |
@@ -177,7 +177,7 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys, | |||
177 | int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len); | 177 | int attrlen = nlh->nlmsg_len - NLMSG_ALIGN(min_len); |
178 | 178 | ||
179 | while (NFA_OK(attr, attrlen)) { | 179 | while (NFA_OK(attr, attrlen)) { |
180 | unsigned flavor = attr->nfa_type; | 180 | unsigned flavor = NFA_TYPE(attr); |
181 | if (flavor) { | 181 | if (flavor) { |
182 | if (flavor > attr_count) | 182 | if (flavor > attr_count) |
183 | return -EINVAL; | 183 | return -EINVAL; |
@@ -195,7 +195,7 @@ nfnetlink_check_attributes(struct nfnetlink_subsystem *subsys, | |||
195 | 195 | ||
196 | int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo) | 196 | int nfnetlink_send(struct sk_buff *skb, u32 pid, unsigned group, int echo) |
197 | { | 197 | { |
198 | int allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; | 198 | gfp_t allocation = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; |
199 | int err = 0; | 199 | int err = 0; |
200 | 200 | ||
201 | NETLINK_CB(skb).dst_group = group; | 201 | NETLINK_CB(skb).dst_group = group; |
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/netlink/af_netlink.c b/net/netlink/af_netlink.c index a64e1d5ce3ca..678c3f2c0d0b 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -758,7 +758,7 @@ void netlink_detachskb(struct sock *sk, struct sk_buff *skb) | |||
758 | } | 758 | } |
759 | 759 | ||
760 | static inline struct sk_buff *netlink_trim(struct sk_buff *skb, | 760 | static inline struct sk_buff *netlink_trim(struct sk_buff *skb, |
761 | unsigned int __nocast allocation) | 761 | gfp_t allocation) |
762 | { | 762 | { |
763 | int delta; | 763 | int delta; |
764 | 764 | ||
@@ -880,7 +880,7 @@ out: | |||
880 | } | 880 | } |
881 | 881 | ||
882 | int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, | 882 | int netlink_broadcast(struct sock *ssk, struct sk_buff *skb, u32 pid, |
883 | u32 group, unsigned int __nocast allocation) | 883 | u32 group, gfp_t allocation) |
884 | { | 884 | { |
885 | struct netlink_broadcast_data info; | 885 | struct netlink_broadcast_data info; |
886 | struct hlist_node *node; | 886 | struct hlist_node *node; |
diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c index 4e66eef9a034..509afddae569 100644 --- a/net/netrom/nr_dev.c +++ b/net/netrom/nr_dev.c | |||
@@ -58,7 +58,7 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev) | |||
58 | 58 | ||
59 | /* Spoof incoming device */ | 59 | /* Spoof incoming device */ |
60 | skb->dev = dev; | 60 | skb->dev = dev; |
61 | skb->h.raw = skb->data; | 61 | skb->mac.raw = skb->nh.raw; |
62 | skb->nh.raw = skb->data; | 62 | skb->nh.raw = skb->data; |
63 | skb->pkt_type = PACKET_HOST; | 63 | skb->pkt_type = PACKET_HOST; |
64 | 64 | ||
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/rxrpc/call.c b/net/rxrpc/call.c index 5cfd4cadee42..c4aeb7d40266 100644 --- a/net/rxrpc/call.c +++ b/net/rxrpc/call.c | |||
@@ -1923,7 +1923,7 @@ int rxrpc_call_write_data(struct rxrpc_call *call, | |||
1923 | size_t sioc, | 1923 | size_t sioc, |
1924 | struct kvec *siov, | 1924 | struct kvec *siov, |
1925 | u8 rxhdr_flags, | 1925 | u8 rxhdr_flags, |
1926 | int alloc_flags, | 1926 | gfp_t alloc_flags, |
1927 | int dup_data, | 1927 | int dup_data, |
1928 | size_t *size_sent) | 1928 | size_t *size_sent) |
1929 | { | 1929 | { |
diff --git a/net/rxrpc/connection.c b/net/rxrpc/connection.c index 61463c74f8cc..2ba14a75dbbe 100644 --- a/net/rxrpc/connection.c +++ b/net/rxrpc/connection.c | |||
@@ -522,7 +522,7 @@ int rxrpc_conn_newmsg(struct rxrpc_connection *conn, | |||
522 | uint8_t type, | 522 | uint8_t type, |
523 | int dcount, | 523 | int dcount, |
524 | struct kvec diov[], | 524 | struct kvec diov[], |
525 | int alloc_flags, | 525 | gfp_t alloc_flags, |
526 | struct rxrpc_message **_msg) | 526 | struct rxrpc_message **_msg) |
527 | { | 527 | { |
528 | struct rxrpc_message *msg; | 528 | struct rxrpc_message *msg; |
diff --git a/net/sched/Kconfig b/net/sched/Kconfig index 45d3bc0812c8..81510da31792 100644 --- a/net/sched/Kconfig +++ b/net/sched/Kconfig | |||
@@ -72,9 +72,11 @@ config NET_SCH_CLK_GETTIMEOFDAY | |||
72 | Choose this if you need a high resolution clock source but can't use | 72 | Choose this if you need a high resolution clock source but can't use |
73 | the CPU's cycle counter. | 73 | the CPU's cycle counter. |
74 | 74 | ||
75 | # don't allow on SMP x86 because they can have unsynchronized TSCs. | ||
76 | # gettimeofday is a good alternative | ||
75 | config NET_SCH_CLK_CPU | 77 | config NET_SCH_CLK_CPU |
76 | bool "CPU cycle counter" | 78 | bool "CPU cycle counter" |
77 | depends on X86_TSC || X86_64 || ALPHA || SPARC64 || PPC64 || IA64 | 79 | depends on ((X86_TSC || X86_64) && !SMP) || ALPHA || SPARC64 || PPC64 || IA64 |
78 | help | 80 | help |
79 | Say Y here if you want to use the CPU's cycle counter as clock source. | 81 | Say Y here if you want to use the CPU's cycle counter as clock source. |
80 | This is a cheap and high resolution clock source, but on some | 82 | This is a cheap and high resolution clock source, but on some |
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/associola.c b/net/sctp/associola.c index 5b24ae0650d3..12b0f582a66b 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
@@ -71,7 +71,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a | |||
71 | const struct sctp_endpoint *ep, | 71 | const struct sctp_endpoint *ep, |
72 | const struct sock *sk, | 72 | const struct sock *sk, |
73 | sctp_scope_t scope, | 73 | sctp_scope_t scope, |
74 | unsigned int __nocast gfp) | 74 | gfp_t gfp) |
75 | { | 75 | { |
76 | struct sctp_sock *sp; | 76 | struct sctp_sock *sp; |
77 | int i; | 77 | int i; |
@@ -273,7 +273,7 @@ fail_init: | |||
273 | struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep, | 273 | struct sctp_association *sctp_association_new(const struct sctp_endpoint *ep, |
274 | const struct sock *sk, | 274 | const struct sock *sk, |
275 | sctp_scope_t scope, | 275 | sctp_scope_t scope, |
276 | unsigned int __nocast gfp) | 276 | gfp_t gfp) |
277 | { | 277 | { |
278 | struct sctp_association *asoc; | 278 | struct sctp_association *asoc; |
279 | 279 | ||
@@ -479,7 +479,7 @@ void sctp_assoc_rm_peer(struct sctp_association *asoc, | |||
479 | /* Add a transport address to an association. */ | 479 | /* Add a transport address to an association. */ |
480 | struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, | 480 | struct sctp_transport *sctp_assoc_add_peer(struct sctp_association *asoc, |
481 | const union sctp_addr *addr, | 481 | const union sctp_addr *addr, |
482 | const unsigned int __nocast gfp, | 482 | const gfp_t gfp, |
483 | const int peer_state) | 483 | const int peer_state) |
484 | { | 484 | { |
485 | struct sctp_transport *peer; | 485 | struct sctp_transport *peer; |
@@ -1231,7 +1231,7 @@ void sctp_assoc_rwnd_decrease(struct sctp_association *asoc, unsigned len) | |||
1231 | * local endpoint and the remote peer. | 1231 | * local endpoint and the remote peer. |
1232 | */ | 1232 | */ |
1233 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, | 1233 | int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, |
1234 | unsigned int __nocast gfp) | 1234 | gfp_t gfp) |
1235 | { | 1235 | { |
1236 | sctp_scope_t scope; | 1236 | sctp_scope_t scope; |
1237 | int flags; | 1237 | int flags; |
@@ -1254,7 +1254,7 @@ int sctp_assoc_set_bind_addr_from_ep(struct sctp_association *asoc, | |||
1254 | /* Build the association's bind address list from the cookie. */ | 1254 | /* Build the association's bind address list from the cookie. */ |
1255 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc, | 1255 | int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc, |
1256 | struct sctp_cookie *cookie, | 1256 | struct sctp_cookie *cookie, |
1257 | unsigned int __nocast gfp) | 1257 | gfp_t gfp) |
1258 | { | 1258 | { |
1259 | int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length); | 1259 | int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length); |
1260 | int var_size3 = cookie->raw_addr_list_len; | 1260 | int var_size3 = cookie->raw_addr_list_len; |
diff --git a/net/sctp/bind_addr.c b/net/sctp/bind_addr.c index f71549710f2e..2b962627f631 100644 --- a/net/sctp/bind_addr.c +++ b/net/sctp/bind_addr.c | |||
@@ -53,7 +53,7 @@ | |||
53 | 53 | ||
54 | /* Forward declarations for internal helpers. */ | 54 | /* Forward declarations for internal helpers. */ |
55 | static int sctp_copy_one_addr(struct sctp_bind_addr *, union sctp_addr *, | 55 | static int sctp_copy_one_addr(struct sctp_bind_addr *, union sctp_addr *, |
56 | sctp_scope_t scope, unsigned int __nocast gfp, | 56 | sctp_scope_t scope, gfp_t gfp, |
57 | int flags); | 57 | int flags); |
58 | static void sctp_bind_addr_clean(struct sctp_bind_addr *); | 58 | static void sctp_bind_addr_clean(struct sctp_bind_addr *); |
59 | 59 | ||
@@ -64,7 +64,7 @@ static void sctp_bind_addr_clean(struct sctp_bind_addr *); | |||
64 | */ | 64 | */ |
65 | int sctp_bind_addr_copy(struct sctp_bind_addr *dest, | 65 | int sctp_bind_addr_copy(struct sctp_bind_addr *dest, |
66 | const struct sctp_bind_addr *src, | 66 | const struct sctp_bind_addr *src, |
67 | sctp_scope_t scope, unsigned int __nocast gfp, | 67 | sctp_scope_t scope, gfp_t gfp, |
68 | int flags) | 68 | int flags) |
69 | { | 69 | { |
70 | struct sctp_sockaddr_entry *addr; | 70 | struct sctp_sockaddr_entry *addr; |
@@ -146,7 +146,7 @@ void sctp_bind_addr_free(struct sctp_bind_addr *bp) | |||
146 | 146 | ||
147 | /* Add an address to the bind address list in the SCTP_bind_addr structure. */ | 147 | /* Add an address to the bind address list in the SCTP_bind_addr structure. */ |
148 | int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new, | 148 | int sctp_add_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *new, |
149 | unsigned int __nocast gfp) | 149 | gfp_t gfp) |
150 | { | 150 | { |
151 | struct sctp_sockaddr_entry *addr; | 151 | struct sctp_sockaddr_entry *addr; |
152 | 152 | ||
@@ -200,7 +200,7 @@ int sctp_del_bind_addr(struct sctp_bind_addr *bp, union sctp_addr *del_addr) | |||
200 | */ | 200 | */ |
201 | union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, | 201 | union sctp_params sctp_bind_addrs_to_raw(const struct sctp_bind_addr *bp, |
202 | int *addrs_len, | 202 | int *addrs_len, |
203 | unsigned int __nocast gfp) | 203 | gfp_t gfp) |
204 | { | 204 | { |
205 | union sctp_params addrparms; | 205 | union sctp_params addrparms; |
206 | union sctp_params retval; | 206 | union sctp_params retval; |
@@ -252,7 +252,7 @@ end_raw: | |||
252 | * address parameters). | 252 | * address parameters). |
253 | */ | 253 | */ |
254 | int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list, | 254 | int sctp_raw_to_bind_addrs(struct sctp_bind_addr *bp, __u8 *raw_addr_list, |
255 | int addrs_len, __u16 port, unsigned int __nocast gfp) | 255 | int addrs_len, __u16 port, gfp_t gfp) |
256 | { | 256 | { |
257 | union sctp_addr_param *rawaddr; | 257 | union sctp_addr_param *rawaddr; |
258 | struct sctp_paramhdr *param; | 258 | struct sctp_paramhdr *param; |
@@ -350,7 +350,7 @@ union sctp_addr *sctp_find_unmatch_addr(struct sctp_bind_addr *bp, | |||
350 | /* Copy out addresses from the global local address list. */ | 350 | /* Copy out addresses from the global local address list. */ |
351 | static int sctp_copy_one_addr(struct sctp_bind_addr *dest, | 351 | static int sctp_copy_one_addr(struct sctp_bind_addr *dest, |
352 | union sctp_addr *addr, | 352 | union sctp_addr *addr, |
353 | sctp_scope_t scope, unsigned int __nocast gfp, | 353 | sctp_scope_t scope, gfp_t gfp, |
354 | int flags) | 354 | int flags) |
355 | { | 355 | { |
356 | int error = 0; | 356 | int error = 0; |
diff --git a/net/sctp/chunk.c b/net/sctp/chunk.c index 61da2937e641..83ef411772f4 100644 --- a/net/sctp/chunk.c +++ b/net/sctp/chunk.c | |||
@@ -62,7 +62,7 @@ static void sctp_datamsg_init(struct sctp_datamsg *msg) | |||
62 | } | 62 | } |
63 | 63 | ||
64 | /* Allocate and initialize datamsg. */ | 64 | /* Allocate and initialize datamsg. */ |
65 | SCTP_STATIC struct sctp_datamsg *sctp_datamsg_new(unsigned int __nocast gfp) | 65 | SCTP_STATIC struct sctp_datamsg *sctp_datamsg_new(gfp_t gfp) |
66 | { | 66 | { |
67 | struct sctp_datamsg *msg; | 67 | struct sctp_datamsg *msg; |
68 | msg = kmalloc(sizeof(struct sctp_datamsg), gfp); | 68 | msg = kmalloc(sizeof(struct sctp_datamsg), gfp); |
diff --git a/net/sctp/endpointola.c b/net/sctp/endpointola.c index e22ccd655965..96984f7a2d69 100644 --- a/net/sctp/endpointola.c +++ b/net/sctp/endpointola.c | |||
@@ -68,7 +68,7 @@ static void sctp_endpoint_bh_rcv(struct sctp_endpoint *ep); | |||
68 | */ | 68 | */ |
69 | static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | 69 | static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, |
70 | struct sock *sk, | 70 | struct sock *sk, |
71 | unsigned int __nocast gfp) | 71 | gfp_t gfp) |
72 | { | 72 | { |
73 | struct sctp_sock *sp = sctp_sk(sk); | 73 | struct sctp_sock *sp = sctp_sk(sk); |
74 | memset(ep, 0, sizeof(struct sctp_endpoint)); | 74 | memset(ep, 0, sizeof(struct sctp_endpoint)); |
@@ -138,8 +138,7 @@ static struct sctp_endpoint *sctp_endpoint_init(struct sctp_endpoint *ep, | |||
138 | /* Create a sctp_endpoint with all that boring stuff initialized. | 138 | /* Create a sctp_endpoint with all that boring stuff initialized. |
139 | * Returns NULL if there isn't enough memory. | 139 | * Returns NULL if there isn't enough memory. |
140 | */ | 140 | */ |
141 | struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, | 141 | struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, gfp_t gfp) |
142 | unsigned int __nocast gfp) | ||
143 | { | 142 | { |
144 | struct sctp_endpoint *ep; | 143 | struct sctp_endpoint *ep; |
145 | 144 | ||
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index e7025be77691..26de4d3e1bd9 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 | } |
@@ -219,7 +219,7 @@ static void sctp_free_local_addr_list(void) | |||
219 | 219 | ||
220 | /* Copy the local addresses which are valid for 'scope' into 'bp'. */ | 220 | /* Copy the local addresses which are valid for 'scope' into 'bp'. */ |
221 | int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope, | 221 | int sctp_copy_local_addr_list(struct sctp_bind_addr *bp, sctp_scope_t scope, |
222 | unsigned int __nocast gfp, int copy_flags) | 222 | gfp_t gfp, int copy_flags) |
223 | { | 223 | { |
224 | struct sctp_sockaddr_entry *addr; | 224 | struct sctp_sockaddr_entry *addr; |
225 | int error = 0; | 225 | int error = 0; |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index 3868a8d70cc0..10e82ec2ebd3 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -78,7 +78,7 @@ static sctp_cookie_param_t *sctp_pack_cookie(const struct sctp_endpoint *ep, | |||
78 | static int sctp_process_param(struct sctp_association *asoc, | 78 | static int sctp_process_param(struct sctp_association *asoc, |
79 | union sctp_params param, | 79 | union sctp_params param, |
80 | const union sctp_addr *peer_addr, | 80 | const union sctp_addr *peer_addr, |
81 | unsigned int __nocast gfp); | 81 | gfp_t gfp); |
82 | 82 | ||
83 | /* What was the inbound interface for this chunk? */ | 83 | /* What was the inbound interface for this chunk? */ |
84 | int sctp_chunk_iif(const struct sctp_chunk *chunk) | 84 | int sctp_chunk_iif(const struct sctp_chunk *chunk) |
@@ -174,7 +174,7 @@ void sctp_init_cause(struct sctp_chunk *chunk, __u16 cause_code, | |||
174 | */ | 174 | */ |
175 | struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, | 175 | struct sctp_chunk *sctp_make_init(const struct sctp_association *asoc, |
176 | const struct sctp_bind_addr *bp, | 176 | const struct sctp_bind_addr *bp, |
177 | unsigned int __nocast gfp, int vparam_len) | 177 | gfp_t gfp, int vparam_len) |
178 | { | 178 | { |
179 | sctp_inithdr_t init; | 179 | sctp_inithdr_t init; |
180 | union sctp_params addrs; | 180 | union sctp_params addrs; |
@@ -261,7 +261,7 @@ nodata: | |||
261 | 261 | ||
262 | struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, | 262 | struct sctp_chunk *sctp_make_init_ack(const struct sctp_association *asoc, |
263 | const struct sctp_chunk *chunk, | 263 | const struct sctp_chunk *chunk, |
264 | unsigned int __nocast gfp, int unkparam_len) | 264 | gfp_t gfp, int unkparam_len) |
265 | { | 265 | { |
266 | sctp_inithdr_t initack; | 266 | sctp_inithdr_t initack; |
267 | struct sctp_chunk *retval; | 267 | struct sctp_chunk *retval; |
@@ -1234,7 +1234,7 @@ void sctp_chunk_assign_tsn(struct sctp_chunk *chunk) | |||
1234 | /* Create a CLOSED association to use with an incoming packet. */ | 1234 | /* Create a CLOSED association to use with an incoming packet. */ |
1235 | struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *ep, | 1235 | struct sctp_association *sctp_make_temp_asoc(const struct sctp_endpoint *ep, |
1236 | struct sctp_chunk *chunk, | 1236 | struct sctp_chunk *chunk, |
1237 | unsigned int __nocast gfp) | 1237 | gfp_t gfp) |
1238 | { | 1238 | { |
1239 | struct sctp_association *asoc; | 1239 | struct sctp_association *asoc; |
1240 | struct sk_buff *skb; | 1240 | struct sk_buff *skb; |
@@ -1349,7 +1349,7 @@ nodata: | |||
1349 | struct sctp_association *sctp_unpack_cookie( | 1349 | struct sctp_association *sctp_unpack_cookie( |
1350 | const struct sctp_endpoint *ep, | 1350 | const struct sctp_endpoint *ep, |
1351 | const struct sctp_association *asoc, | 1351 | const struct sctp_association *asoc, |
1352 | struct sctp_chunk *chunk, unsigned int __nocast gfp, | 1352 | struct sctp_chunk *chunk, gfp_t gfp, |
1353 | int *error, struct sctp_chunk **errp) | 1353 | int *error, struct sctp_chunk **errp) |
1354 | { | 1354 | { |
1355 | struct sctp_association *retval = NULL; | 1355 | struct sctp_association *retval = NULL; |
@@ -1814,7 +1814,7 @@ int sctp_verify_init(const struct sctp_association *asoc, | |||
1814 | */ | 1814 | */ |
1815 | int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, | 1815 | int sctp_process_init(struct sctp_association *asoc, sctp_cid_t cid, |
1816 | const union sctp_addr *peer_addr, | 1816 | const union sctp_addr *peer_addr, |
1817 | sctp_init_chunk_t *peer_init, unsigned int __nocast gfp) | 1817 | sctp_init_chunk_t *peer_init, gfp_t gfp) |
1818 | { | 1818 | { |
1819 | union sctp_params param; | 1819 | union sctp_params param; |
1820 | struct sctp_transport *transport; | 1820 | struct sctp_transport *transport; |
@@ -1985,7 +1985,7 @@ nomem: | |||
1985 | static int sctp_process_param(struct sctp_association *asoc, | 1985 | static int sctp_process_param(struct sctp_association *asoc, |
1986 | union sctp_params param, | 1986 | union sctp_params param, |
1987 | const union sctp_addr *peer_addr, | 1987 | const union sctp_addr *peer_addr, |
1988 | unsigned int __nocast gfp) | 1988 | gfp_t gfp) |
1989 | { | 1989 | { |
1990 | union sctp_addr addr; | 1990 | union sctp_addr addr; |
1991 | int i; | 1991 | int i; |
diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c index 39c970b5b198..f84173ea8ec1 100644 --- a/net/sctp/sm_sideeffect.c +++ b/net/sctp/sm_sideeffect.c | |||
@@ -63,7 +63,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
63 | void *event_arg, | 63 | void *event_arg, |
64 | sctp_disposition_t status, | 64 | sctp_disposition_t status, |
65 | sctp_cmd_seq_t *commands, | 65 | sctp_cmd_seq_t *commands, |
66 | unsigned int __nocast gfp); | 66 | gfp_t gfp); |
67 | static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype, | 67 | static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype, |
68 | sctp_state_t state, | 68 | sctp_state_t state, |
69 | struct sctp_endpoint *ep, | 69 | struct sctp_endpoint *ep, |
@@ -71,7 +71,7 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype, | |||
71 | void *event_arg, | 71 | void *event_arg, |
72 | sctp_disposition_t status, | 72 | sctp_disposition_t status, |
73 | sctp_cmd_seq_t *commands, | 73 | sctp_cmd_seq_t *commands, |
74 | unsigned int __nocast gfp); | 74 | gfp_t gfp); |
75 | 75 | ||
76 | /******************************************************************** | 76 | /******************************************************************** |
77 | * Helper functions | 77 | * Helper functions |
@@ -498,7 +498,7 @@ static int sctp_cmd_process_init(sctp_cmd_seq_t *commands, | |||
498 | struct sctp_association *asoc, | 498 | struct sctp_association *asoc, |
499 | struct sctp_chunk *chunk, | 499 | struct sctp_chunk *chunk, |
500 | sctp_init_chunk_t *peer_init, | 500 | sctp_init_chunk_t *peer_init, |
501 | unsigned int __nocast gfp) | 501 | gfp_t gfp) |
502 | { | 502 | { |
503 | int error; | 503 | int error; |
504 | 504 | ||
@@ -853,7 +853,7 @@ int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype, | |||
853 | struct sctp_endpoint *ep, | 853 | struct sctp_endpoint *ep, |
854 | struct sctp_association *asoc, | 854 | struct sctp_association *asoc, |
855 | void *event_arg, | 855 | void *event_arg, |
856 | unsigned int __nocast gfp) | 856 | gfp_t gfp) |
857 | { | 857 | { |
858 | sctp_cmd_seq_t commands; | 858 | sctp_cmd_seq_t commands; |
859 | const sctp_sm_table_entry_t *state_fn; | 859 | const sctp_sm_table_entry_t *state_fn; |
@@ -898,7 +898,7 @@ static int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype, | |||
898 | void *event_arg, | 898 | void *event_arg, |
899 | sctp_disposition_t status, | 899 | sctp_disposition_t status, |
900 | sctp_cmd_seq_t *commands, | 900 | sctp_cmd_seq_t *commands, |
901 | unsigned int __nocast gfp) | 901 | gfp_t gfp) |
902 | { | 902 | { |
903 | int error; | 903 | int error; |
904 | 904 | ||
@@ -986,7 +986,7 @@ static int sctp_cmd_interpreter(sctp_event_t event_type, | |||
986 | void *event_arg, | 986 | void *event_arg, |
987 | sctp_disposition_t status, | 987 | sctp_disposition_t status, |
988 | sctp_cmd_seq_t *commands, | 988 | sctp_cmd_seq_t *commands, |
989 | unsigned int __nocast gfp) | 989 | gfp_t gfp) |
990 | { | 990 | { |
991 | int error = 0; | 991 | int error = 0; |
992 | int force; | 992 | int force; |
diff --git a/net/sctp/socket.c b/net/sctp/socket.c index 91ec8c936913..02e068d3450d 100644 --- a/net/sctp/socket.c +++ b/net/sctp/socket.c | |||
@@ -3159,8 +3159,9 @@ static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval | |||
3159 | return 0; | 3159 | return 0; |
3160 | } | 3160 | } |
3161 | 3161 | ||
3162 | static int sctp_getsockopt_peer_addrs_num(struct sock *sk, int len, | 3162 | static int sctp_getsockopt_peer_addrs_num_old(struct sock *sk, int len, |
3163 | char __user *optval, int __user *optlen) | 3163 | char __user *optval, |
3164 | int __user *optlen) | ||
3164 | { | 3165 | { |
3165 | sctp_assoc_t id; | 3166 | sctp_assoc_t id; |
3166 | struct sctp_association *asoc; | 3167 | struct sctp_association *asoc; |
@@ -3185,23 +3186,28 @@ static int sctp_getsockopt_peer_addrs_num(struct sock *sk, int len, | |||
3185 | return cnt; | 3186 | return cnt; |
3186 | } | 3187 | } |
3187 | 3188 | ||
3188 | static int sctp_getsockopt_peer_addrs(struct sock *sk, int len, | 3189 | /* |
3189 | char __user *optval, int __user *optlen) | 3190 | * Old API for getting list of peer addresses. Does not work for 32-bit |
3191 | * programs running on a 64-bit kernel | ||
3192 | */ | ||
3193 | static int sctp_getsockopt_peer_addrs_old(struct sock *sk, int len, | ||
3194 | char __user *optval, | ||
3195 | int __user *optlen) | ||
3190 | { | 3196 | { |
3191 | struct sctp_association *asoc; | 3197 | struct sctp_association *asoc; |
3192 | struct list_head *pos; | 3198 | struct list_head *pos; |
3193 | int cnt = 0; | 3199 | int cnt = 0; |
3194 | struct sctp_getaddrs getaddrs; | 3200 | struct sctp_getaddrs_old getaddrs; |
3195 | struct sctp_transport *from; | 3201 | struct sctp_transport *from; |
3196 | void __user *to; | 3202 | void __user *to; |
3197 | union sctp_addr temp; | 3203 | union sctp_addr temp; |
3198 | struct sctp_sock *sp = sctp_sk(sk); | 3204 | struct sctp_sock *sp = sctp_sk(sk); |
3199 | int addrlen; | 3205 | int addrlen; |
3200 | 3206 | ||
3201 | if (len != sizeof(struct sctp_getaddrs)) | 3207 | if (len != sizeof(struct sctp_getaddrs_old)) |
3202 | return -EINVAL; | 3208 | return -EINVAL; |
3203 | 3209 | ||
3204 | if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs))) | 3210 | if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs_old))) |
3205 | return -EFAULT; | 3211 | return -EFAULT; |
3206 | 3212 | ||
3207 | if (getaddrs.addr_num <= 0) return -EINVAL; | 3213 | if (getaddrs.addr_num <= 0) return -EINVAL; |
@@ -3225,15 +3231,69 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len, | |||
3225 | if (cnt >= getaddrs.addr_num) break; | 3231 | if (cnt >= getaddrs.addr_num) break; |
3226 | } | 3232 | } |
3227 | getaddrs.addr_num = cnt; | 3233 | getaddrs.addr_num = cnt; |
3228 | if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs))) | 3234 | if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs_old))) |
3235 | return -EFAULT; | ||
3236 | |||
3237 | return 0; | ||
3238 | } | ||
3239 | |||
3240 | static int sctp_getsockopt_peer_addrs(struct sock *sk, int len, | ||
3241 | char __user *optval, int __user *optlen) | ||
3242 | { | ||
3243 | struct sctp_association *asoc; | ||
3244 | struct list_head *pos; | ||
3245 | int cnt = 0; | ||
3246 | struct sctp_getaddrs getaddrs; | ||
3247 | struct sctp_transport *from; | ||
3248 | void __user *to; | ||
3249 | union sctp_addr temp; | ||
3250 | struct sctp_sock *sp = sctp_sk(sk); | ||
3251 | int addrlen; | ||
3252 | size_t space_left; | ||
3253 | int bytes_copied; | ||
3254 | |||
3255 | if (len < sizeof(struct sctp_getaddrs)) | ||
3256 | return -EINVAL; | ||
3257 | |||
3258 | if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs))) | ||
3259 | return -EFAULT; | ||
3260 | |||
3261 | /* For UDP-style sockets, id specifies the association to query. */ | ||
3262 | asoc = sctp_id2assoc(sk, getaddrs.assoc_id); | ||
3263 | if (!asoc) | ||
3264 | return -EINVAL; | ||
3265 | |||
3266 | to = optval + offsetof(struct sctp_getaddrs,addrs); | ||
3267 | space_left = len - sizeof(struct sctp_getaddrs) - | ||
3268 | offsetof(struct sctp_getaddrs,addrs); | ||
3269 | |||
3270 | list_for_each(pos, &asoc->peer.transport_addr_list) { | ||
3271 | from = list_entry(pos, struct sctp_transport, transports); | ||
3272 | memcpy(&temp, &from->ipaddr, sizeof(temp)); | ||
3273 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); | ||
3274 | addrlen = sctp_get_af_specific(sk->sk_family)->sockaddr_len; | ||
3275 | if(space_left < addrlen) | ||
3276 | return -ENOMEM; | ||
3277 | temp.v4.sin_port = htons(temp.v4.sin_port); | ||
3278 | if (copy_to_user(to, &temp, addrlen)) | ||
3279 | return -EFAULT; | ||
3280 | to += addrlen; | ||
3281 | cnt++; | ||
3282 | space_left -= addrlen; | ||
3283 | } | ||
3284 | |||
3285 | if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) | ||
3286 | return -EFAULT; | ||
3287 | bytes_copied = ((char __user *)to) - optval; | ||
3288 | if (put_user(bytes_copied, optlen)) | ||
3229 | return -EFAULT; | 3289 | return -EFAULT; |
3230 | 3290 | ||
3231 | return 0; | 3291 | return 0; |
3232 | } | 3292 | } |
3233 | 3293 | ||
3234 | static int sctp_getsockopt_local_addrs_num(struct sock *sk, int len, | 3294 | static int sctp_getsockopt_local_addrs_num_old(struct sock *sk, int len, |
3235 | char __user *optval, | 3295 | char __user *optval, |
3236 | int __user *optlen) | 3296 | int __user *optlen) |
3237 | { | 3297 | { |
3238 | sctp_assoc_t id; | 3298 | sctp_assoc_t id; |
3239 | struct sctp_bind_addr *bp; | 3299 | struct sctp_bind_addr *bp; |
@@ -3306,8 +3366,8 @@ done: | |||
3306 | /* Helper function that copies local addresses to user and returns the number | 3366 | /* Helper function that copies local addresses to user and returns the number |
3307 | * of addresses copied. | 3367 | * of addresses copied. |
3308 | */ | 3368 | */ |
3309 | static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, int max_addrs, | 3369 | static int sctp_copy_laddrs_to_user_old(struct sock *sk, __u16 port, int max_addrs, |
3310 | void __user *to) | 3370 | void __user *to) |
3311 | { | 3371 | { |
3312 | struct list_head *pos; | 3372 | struct list_head *pos; |
3313 | struct sctp_sockaddr_entry *addr; | 3373 | struct sctp_sockaddr_entry *addr; |
@@ -3341,14 +3401,54 @@ static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, int max_addrs, | |||
3341 | return cnt; | 3401 | return cnt; |
3342 | } | 3402 | } |
3343 | 3403 | ||
3344 | static int sctp_getsockopt_local_addrs(struct sock *sk, int len, | 3404 | static int sctp_copy_laddrs_to_user(struct sock *sk, __u16 port, |
3345 | char __user *optval, int __user *optlen) | 3405 | void * __user *to, size_t space_left) |
3406 | { | ||
3407 | struct list_head *pos; | ||
3408 | struct sctp_sockaddr_entry *addr; | ||
3409 | unsigned long flags; | ||
3410 | union sctp_addr temp; | ||
3411 | int cnt = 0; | ||
3412 | int addrlen; | ||
3413 | |||
3414 | sctp_spin_lock_irqsave(&sctp_local_addr_lock, flags); | ||
3415 | list_for_each(pos, &sctp_local_addr_list) { | ||
3416 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); | ||
3417 | if ((PF_INET == sk->sk_family) && | ||
3418 | (AF_INET6 == addr->a.sa.sa_family)) | ||
3419 | continue; | ||
3420 | memcpy(&temp, &addr->a, sizeof(temp)); | ||
3421 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sctp_sk(sk), | ||
3422 | &temp); | ||
3423 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; | ||
3424 | if(space_left<addrlen) | ||
3425 | return -ENOMEM; | ||
3426 | temp.v4.sin_port = htons(port); | ||
3427 | if (copy_to_user(*to, &temp, addrlen)) { | ||
3428 | sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, | ||
3429 | flags); | ||
3430 | return -EFAULT; | ||
3431 | } | ||
3432 | *to += addrlen; | ||
3433 | cnt ++; | ||
3434 | space_left -= addrlen; | ||
3435 | } | ||
3436 | sctp_spin_unlock_irqrestore(&sctp_local_addr_lock, flags); | ||
3437 | |||
3438 | return cnt; | ||
3439 | } | ||
3440 | |||
3441 | /* Old API for getting list of local addresses. Does not work for 32-bit | ||
3442 | * programs running on a 64-bit kernel | ||
3443 | */ | ||
3444 | static int sctp_getsockopt_local_addrs_old(struct sock *sk, int len, | ||
3445 | char __user *optval, int __user *optlen) | ||
3346 | { | 3446 | { |
3347 | struct sctp_bind_addr *bp; | 3447 | struct sctp_bind_addr *bp; |
3348 | struct sctp_association *asoc; | 3448 | struct sctp_association *asoc; |
3349 | struct list_head *pos; | 3449 | struct list_head *pos; |
3350 | int cnt = 0; | 3450 | int cnt = 0; |
3351 | struct sctp_getaddrs getaddrs; | 3451 | struct sctp_getaddrs_old getaddrs; |
3352 | struct sctp_sockaddr_entry *addr; | 3452 | struct sctp_sockaddr_entry *addr; |
3353 | void __user *to; | 3453 | void __user *to; |
3354 | union sctp_addr temp; | 3454 | union sctp_addr temp; |
@@ -3357,10 +3457,10 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, | |||
3357 | rwlock_t *addr_lock; | 3457 | rwlock_t *addr_lock; |
3358 | int err = 0; | 3458 | int err = 0; |
3359 | 3459 | ||
3360 | if (len != sizeof(struct sctp_getaddrs)) | 3460 | if (len != sizeof(struct sctp_getaddrs_old)) |
3361 | return -EINVAL; | 3461 | return -EINVAL; |
3362 | 3462 | ||
3363 | if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs))) | 3463 | if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs_old))) |
3364 | return -EFAULT; | 3464 | return -EFAULT; |
3365 | 3465 | ||
3366 | if (getaddrs.addr_num <= 0) return -EINVAL; | 3466 | if (getaddrs.addr_num <= 0) return -EINVAL; |
@@ -3392,8 +3492,9 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, | |||
3392 | addr = list_entry(bp->address_list.next, | 3492 | addr = list_entry(bp->address_list.next, |
3393 | struct sctp_sockaddr_entry, list); | 3493 | struct sctp_sockaddr_entry, list); |
3394 | if (sctp_is_any(&addr->a)) { | 3494 | if (sctp_is_any(&addr->a)) { |
3395 | cnt = sctp_copy_laddrs_to_user(sk, bp->port, | 3495 | cnt = sctp_copy_laddrs_to_user_old(sk, bp->port, |
3396 | getaddrs.addr_num, to); | 3496 | getaddrs.addr_num, |
3497 | to); | ||
3397 | if (cnt < 0) { | 3498 | if (cnt < 0) { |
3398 | err = cnt; | 3499 | err = cnt; |
3399 | goto unlock; | 3500 | goto unlock; |
@@ -3419,7 +3520,7 @@ static int sctp_getsockopt_local_addrs(struct sock *sk, int len, | |||
3419 | 3520 | ||
3420 | copy_getaddrs: | 3521 | copy_getaddrs: |
3421 | getaddrs.addr_num = cnt; | 3522 | getaddrs.addr_num = cnt; |
3422 | if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs))) | 3523 | if (copy_to_user(optval, &getaddrs, sizeof(struct sctp_getaddrs_old))) |
3423 | err = -EFAULT; | 3524 | err = -EFAULT; |
3424 | 3525 | ||
3425 | unlock: | 3526 | unlock: |
@@ -3427,6 +3528,99 @@ unlock: | |||
3427 | return err; | 3528 | return err; |
3428 | } | 3529 | } |
3429 | 3530 | ||
3531 | static int sctp_getsockopt_local_addrs(struct sock *sk, int len, | ||
3532 | char __user *optval, int __user *optlen) | ||
3533 | { | ||
3534 | struct sctp_bind_addr *bp; | ||
3535 | struct sctp_association *asoc; | ||
3536 | struct list_head *pos; | ||
3537 | int cnt = 0; | ||
3538 | struct sctp_getaddrs getaddrs; | ||
3539 | struct sctp_sockaddr_entry *addr; | ||
3540 | void __user *to; | ||
3541 | union sctp_addr temp; | ||
3542 | struct sctp_sock *sp = sctp_sk(sk); | ||
3543 | int addrlen; | ||
3544 | rwlock_t *addr_lock; | ||
3545 | int err = 0; | ||
3546 | size_t space_left; | ||
3547 | int bytes_copied; | ||
3548 | |||
3549 | if (len <= sizeof(struct sctp_getaddrs)) | ||
3550 | return -EINVAL; | ||
3551 | |||
3552 | if (copy_from_user(&getaddrs, optval, sizeof(struct sctp_getaddrs))) | ||
3553 | return -EFAULT; | ||
3554 | |||
3555 | /* | ||
3556 | * For UDP-style sockets, id specifies the association to query. | ||
3557 | * If the id field is set to the value '0' then the locally bound | ||
3558 | * addresses are returned without regard to any particular | ||
3559 | * association. | ||
3560 | */ | ||
3561 | if (0 == getaddrs.assoc_id) { | ||
3562 | bp = &sctp_sk(sk)->ep->base.bind_addr; | ||
3563 | addr_lock = &sctp_sk(sk)->ep->base.addr_lock; | ||
3564 | } else { | ||
3565 | asoc = sctp_id2assoc(sk, getaddrs.assoc_id); | ||
3566 | if (!asoc) | ||
3567 | return -EINVAL; | ||
3568 | bp = &asoc->base.bind_addr; | ||
3569 | addr_lock = &asoc->base.addr_lock; | ||
3570 | } | ||
3571 | |||
3572 | to = optval + offsetof(struct sctp_getaddrs,addrs); | ||
3573 | space_left = len - sizeof(struct sctp_getaddrs) - | ||
3574 | offsetof(struct sctp_getaddrs,addrs); | ||
3575 | |||
3576 | sctp_read_lock(addr_lock); | ||
3577 | |||
3578 | /* If the endpoint is bound to 0.0.0.0 or ::0, get the valid | ||
3579 | * addresses from the global local address list. | ||
3580 | */ | ||
3581 | if (sctp_list_single_entry(&bp->address_list)) { | ||
3582 | addr = list_entry(bp->address_list.next, | ||
3583 | struct sctp_sockaddr_entry, list); | ||
3584 | if (sctp_is_any(&addr->a)) { | ||
3585 | cnt = sctp_copy_laddrs_to_user(sk, bp->port, | ||
3586 | &to, space_left); | ||
3587 | if (cnt < 0) { | ||
3588 | err = cnt; | ||
3589 | goto unlock; | ||
3590 | } | ||
3591 | goto copy_getaddrs; | ||
3592 | } | ||
3593 | } | ||
3594 | |||
3595 | list_for_each(pos, &bp->address_list) { | ||
3596 | addr = list_entry(pos, struct sctp_sockaddr_entry, list); | ||
3597 | memcpy(&temp, &addr->a, sizeof(temp)); | ||
3598 | sctp_get_pf_specific(sk->sk_family)->addr_v4map(sp, &temp); | ||
3599 | addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len; | ||
3600 | if(space_left < addrlen) | ||
3601 | return -ENOMEM; /*fixme: right error?*/ | ||
3602 | temp.v4.sin_port = htons(temp.v4.sin_port); | ||
3603 | if (copy_to_user(to, &temp, addrlen)) { | ||
3604 | err = -EFAULT; | ||
3605 | goto unlock; | ||
3606 | } | ||
3607 | to += addrlen; | ||
3608 | cnt ++; | ||
3609 | space_left -= addrlen; | ||
3610 | } | ||
3611 | |||
3612 | copy_getaddrs: | ||
3613 | if (put_user(cnt, &((struct sctp_getaddrs __user *)optval)->addr_num)) | ||
3614 | return -EFAULT; | ||
3615 | bytes_copied = ((char __user *)to) - optval; | ||
3616 | if (put_user(bytes_copied, optlen)) | ||
3617 | return -EFAULT; | ||
3618 | |||
3619 | unlock: | ||
3620 | sctp_read_unlock(addr_lock); | ||
3621 | return err; | ||
3622 | } | ||
3623 | |||
3430 | /* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR) | 3624 | /* 7.1.10 Set Primary Address (SCTP_PRIMARY_ADDR) |
3431 | * | 3625 | * |
3432 | * Requests that the local SCTP stack use the enclosed peer address as | 3626 | * Requests that the local SCTP stack use the enclosed peer address as |
@@ -3807,12 +4001,20 @@ SCTP_STATIC int sctp_getsockopt(struct sock *sk, int level, int optname, | |||
3807 | case SCTP_INITMSG: | 4001 | case SCTP_INITMSG: |
3808 | retval = sctp_getsockopt_initmsg(sk, len, optval, optlen); | 4002 | retval = sctp_getsockopt_initmsg(sk, len, optval, optlen); |
3809 | break; | 4003 | break; |
3810 | case SCTP_GET_PEER_ADDRS_NUM: | 4004 | case SCTP_GET_PEER_ADDRS_NUM_OLD: |
3811 | retval = sctp_getsockopt_peer_addrs_num(sk, len, optval, | 4005 | retval = sctp_getsockopt_peer_addrs_num_old(sk, len, optval, |
4006 | optlen); | ||
4007 | break; | ||
4008 | case SCTP_GET_LOCAL_ADDRS_NUM_OLD: | ||
4009 | retval = sctp_getsockopt_local_addrs_num_old(sk, len, optval, | ||
4010 | optlen); | ||
4011 | break; | ||
4012 | case SCTP_GET_PEER_ADDRS_OLD: | ||
4013 | retval = sctp_getsockopt_peer_addrs_old(sk, len, optval, | ||
3812 | optlen); | 4014 | optlen); |
3813 | break; | 4015 | break; |
3814 | case SCTP_GET_LOCAL_ADDRS_NUM: | 4016 | case SCTP_GET_LOCAL_ADDRS_OLD: |
3815 | retval = sctp_getsockopt_local_addrs_num(sk, len, optval, | 4017 | retval = sctp_getsockopt_local_addrs_old(sk, len, optval, |
3816 | optlen); | 4018 | optlen); |
3817 | break; | 4019 | break; |
3818 | case SCTP_GET_PEER_ADDRS: | 4020 | case SCTP_GET_PEER_ADDRS: |
diff --git a/net/sctp/ssnmap.c b/net/sctp/ssnmap.c index 25037daf3fa0..cbe2513d2822 100644 --- a/net/sctp/ssnmap.c +++ b/net/sctp/ssnmap.c | |||
@@ -58,7 +58,7 @@ static inline size_t sctp_ssnmap_size(__u16 in, __u16 out) | |||
58 | * Allocate room to store at least 'len' contiguous TSNs. | 58 | * Allocate room to store at least 'len' contiguous TSNs. |
59 | */ | 59 | */ |
60 | struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, | 60 | struct sctp_ssnmap *sctp_ssnmap_new(__u16 in, __u16 out, |
61 | unsigned int __nocast gfp) | 61 | gfp_t gfp) |
62 | { | 62 | { |
63 | struct sctp_ssnmap *retval; | 63 | struct sctp_ssnmap *retval; |
64 | int size; | 64 | int size; |
diff --git a/net/sctp/transport.c b/net/sctp/transport.c index d2f04ebe5081..6bc27200e6ca 100644 --- a/net/sctp/transport.c +++ b/net/sctp/transport.c | |||
@@ -57,7 +57,7 @@ | |||
57 | /* Initialize a new transport from provided memory. */ | 57 | /* Initialize a new transport from provided memory. */ |
58 | static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | 58 | static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, |
59 | const union sctp_addr *addr, | 59 | const union sctp_addr *addr, |
60 | unsigned int __nocast gfp) | 60 | gfp_t gfp) |
61 | { | 61 | { |
62 | /* Copy in the address. */ | 62 | /* Copy in the address. */ |
63 | peer->ipaddr = *addr; | 63 | peer->ipaddr = *addr; |
@@ -122,7 +122,7 @@ static struct sctp_transport *sctp_transport_init(struct sctp_transport *peer, | |||
122 | 122 | ||
123 | /* Allocate and initialize a new transport. */ | 123 | /* Allocate and initialize a new transport. */ |
124 | struct sctp_transport *sctp_transport_new(const union sctp_addr *addr, | 124 | struct sctp_transport *sctp_transport_new(const union sctp_addr *addr, |
125 | unsigned int __nocast gfp) | 125 | gfp_t gfp) |
126 | { | 126 | { |
127 | struct sctp_transport *transport; | 127 | struct sctp_transport *transport; |
128 | 128 | ||
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c index 0abd5101107c..057e7fac3af0 100644 --- a/net/sctp/ulpevent.c +++ b/net/sctp/ulpevent.c | |||
@@ -74,7 +74,7 @@ SCTP_STATIC void sctp_ulpevent_init(struct sctp_ulpevent *event, int msg_flags) | |||
74 | 74 | ||
75 | /* Create a new sctp_ulpevent. */ | 75 | /* Create a new sctp_ulpevent. */ |
76 | SCTP_STATIC struct sctp_ulpevent *sctp_ulpevent_new(int size, int msg_flags, | 76 | SCTP_STATIC struct sctp_ulpevent *sctp_ulpevent_new(int size, int msg_flags, |
77 | unsigned int __nocast gfp) | 77 | gfp_t gfp) |
78 | { | 78 | { |
79 | struct sctp_ulpevent *event; | 79 | struct sctp_ulpevent *event; |
80 | struct sk_buff *skb; | 80 | struct sk_buff *skb; |
@@ -136,7 +136,7 @@ static inline void sctp_ulpevent_release_owner(struct sctp_ulpevent *event) | |||
136 | struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( | 136 | struct sctp_ulpevent *sctp_ulpevent_make_assoc_change( |
137 | const struct sctp_association *asoc, | 137 | const struct sctp_association *asoc, |
138 | __u16 flags, __u16 state, __u16 error, __u16 outbound, | 138 | __u16 flags, __u16 state, __u16 error, __u16 outbound, |
139 | __u16 inbound, unsigned int __nocast gfp) | 139 | __u16 inbound, gfp_t gfp) |
140 | { | 140 | { |
141 | struct sctp_ulpevent *event; | 141 | struct sctp_ulpevent *event; |
142 | struct sctp_assoc_change *sac; | 142 | struct sctp_assoc_change *sac; |
@@ -237,7 +237,7 @@ fail: | |||
237 | struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( | 237 | struct sctp_ulpevent *sctp_ulpevent_make_peer_addr_change( |
238 | const struct sctp_association *asoc, | 238 | const struct sctp_association *asoc, |
239 | const struct sockaddr_storage *aaddr, | 239 | const struct sockaddr_storage *aaddr, |
240 | int flags, int state, int error, unsigned int __nocast gfp) | 240 | int flags, int state, int error, gfp_t gfp) |
241 | { | 241 | { |
242 | struct sctp_ulpevent *event; | 242 | struct sctp_ulpevent *event; |
243 | struct sctp_paddr_change *spc; | 243 | struct sctp_paddr_change *spc; |
@@ -350,7 +350,7 @@ fail: | |||
350 | */ | 350 | */ |
351 | struct sctp_ulpevent *sctp_ulpevent_make_remote_error( | 351 | struct sctp_ulpevent *sctp_ulpevent_make_remote_error( |
352 | const struct sctp_association *asoc, struct sctp_chunk *chunk, | 352 | const struct sctp_association *asoc, struct sctp_chunk *chunk, |
353 | __u16 flags, unsigned int __nocast gfp) | 353 | __u16 flags, gfp_t gfp) |
354 | { | 354 | { |
355 | struct sctp_ulpevent *event; | 355 | struct sctp_ulpevent *event; |
356 | struct sctp_remote_error *sre; | 356 | struct sctp_remote_error *sre; |
@@ -448,7 +448,7 @@ fail: | |||
448 | */ | 448 | */ |
449 | struct sctp_ulpevent *sctp_ulpevent_make_send_failed( | 449 | struct sctp_ulpevent *sctp_ulpevent_make_send_failed( |
450 | const struct sctp_association *asoc, struct sctp_chunk *chunk, | 450 | const struct sctp_association *asoc, struct sctp_chunk *chunk, |
451 | __u16 flags, __u32 error, unsigned int __nocast gfp) | 451 | __u16 flags, __u32 error, gfp_t gfp) |
452 | { | 452 | { |
453 | struct sctp_ulpevent *event; | 453 | struct sctp_ulpevent *event; |
454 | struct sctp_send_failed *ssf; | 454 | struct sctp_send_failed *ssf; |
@@ -557,7 +557,7 @@ fail: | |||
557 | */ | 557 | */ |
558 | struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event( | 558 | struct sctp_ulpevent *sctp_ulpevent_make_shutdown_event( |
559 | const struct sctp_association *asoc, | 559 | const struct sctp_association *asoc, |
560 | __u16 flags, unsigned int __nocast gfp) | 560 | __u16 flags, gfp_t gfp) |
561 | { | 561 | { |
562 | struct sctp_ulpevent *event; | 562 | struct sctp_ulpevent *event; |
563 | struct sctp_shutdown_event *sse; | 563 | struct sctp_shutdown_event *sse; |
@@ -620,7 +620,7 @@ fail: | |||
620 | * 5.3.1.6 SCTP_ADAPTION_INDICATION | 620 | * 5.3.1.6 SCTP_ADAPTION_INDICATION |
621 | */ | 621 | */ |
622 | struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication( | 622 | struct sctp_ulpevent *sctp_ulpevent_make_adaption_indication( |
623 | const struct sctp_association *asoc, unsigned int __nocast gfp) | 623 | const struct sctp_association *asoc, gfp_t gfp) |
624 | { | 624 | { |
625 | struct sctp_ulpevent *event; | 625 | struct sctp_ulpevent *event; |
626 | struct sctp_adaption_event *sai; | 626 | struct sctp_adaption_event *sai; |
@@ -657,7 +657,7 @@ fail: | |||
657 | */ | 657 | */ |
658 | struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, | 658 | struct sctp_ulpevent *sctp_ulpevent_make_rcvmsg(struct sctp_association *asoc, |
659 | struct sctp_chunk *chunk, | 659 | struct sctp_chunk *chunk, |
660 | unsigned int __nocast gfp) | 660 | gfp_t gfp) |
661 | { | 661 | { |
662 | struct sctp_ulpevent *event = NULL; | 662 | struct sctp_ulpevent *event = NULL; |
663 | struct sk_buff *skb; | 663 | struct sk_buff *skb; |
@@ -719,7 +719,7 @@ fail: | |||
719 | */ | 719 | */ |
720 | struct sctp_ulpevent *sctp_ulpevent_make_pdapi( | 720 | struct sctp_ulpevent *sctp_ulpevent_make_pdapi( |
721 | const struct sctp_association *asoc, __u32 indication, | 721 | const struct sctp_association *asoc, __u32 indication, |
722 | unsigned int __nocast gfp) | 722 | gfp_t gfp) |
723 | { | 723 | { |
724 | struct sctp_ulpevent *event; | 724 | struct sctp_ulpevent *event; |
725 | struct sctp_pdapi_event *pd; | 725 | struct sctp_pdapi_event *pd; |
diff --git a/net/sctp/ulpqueue.c b/net/sctp/ulpqueue.c index ec2c857eae7f..2080b2d28c98 100644 --- a/net/sctp/ulpqueue.c +++ b/net/sctp/ulpqueue.c | |||
@@ -100,7 +100,7 @@ void sctp_ulpq_free(struct sctp_ulpq *ulpq) | |||
100 | 100 | ||
101 | /* Process an incoming DATA chunk. */ | 101 | /* Process an incoming DATA chunk. */ |
102 | int sctp_ulpq_tail_data(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, | 102 | int sctp_ulpq_tail_data(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, |
103 | unsigned int __nocast gfp) | 103 | gfp_t gfp) |
104 | { | 104 | { |
105 | struct sk_buff_head temp; | 105 | struct sk_buff_head temp; |
106 | sctp_data_chunk_t *hdr; | 106 | sctp_data_chunk_t *hdr; |
@@ -792,7 +792,7 @@ static __u16 sctp_ulpq_renege_frags(struct sctp_ulpq *ulpq, __u16 needed) | |||
792 | /* Partial deliver the first message as there is pressure on rwnd. */ | 792 | /* Partial deliver the first message as there is pressure on rwnd. */ |
793 | void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq, | 793 | void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq, |
794 | struct sctp_chunk *chunk, | 794 | struct sctp_chunk *chunk, |
795 | unsigned int __nocast gfp) | 795 | gfp_t gfp) |
796 | { | 796 | { |
797 | struct sctp_ulpevent *event; | 797 | struct sctp_ulpevent *event; |
798 | struct sctp_association *asoc; | 798 | struct sctp_association *asoc; |
@@ -816,7 +816,7 @@ void sctp_ulpq_partial_delivery(struct sctp_ulpq *ulpq, | |||
816 | 816 | ||
817 | /* Renege some packets to make room for an incoming chunk. */ | 817 | /* Renege some packets to make room for an incoming chunk. */ |
818 | void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, | 818 | void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, |
819 | unsigned int __nocast gfp) | 819 | gfp_t gfp) |
820 | { | 820 | { |
821 | struct sctp_association *asoc; | 821 | struct sctp_association *asoc; |
822 | __u16 needed, freed; | 822 | __u16 needed, freed; |
@@ -855,7 +855,7 @@ void sctp_ulpq_renege(struct sctp_ulpq *ulpq, struct sctp_chunk *chunk, | |||
855 | /* Notify the application if an association is aborted and in | 855 | /* Notify the application if an association is aborted and in |
856 | * partial delivery mode. Send up any pending received messages. | 856 | * partial delivery mode. Send up any pending received messages. |
857 | */ | 857 | */ |
858 | void sctp_ulpq_abort_pd(struct sctp_ulpq *ulpq, unsigned int __nocast gfp) | 858 | void sctp_ulpq_abort_pd(struct sctp_ulpq *ulpq, gfp_t gfp) |
859 | { | 859 | { |
860 | struct sctp_ulpevent *ev = NULL; | 860 | struct sctp_ulpevent *ev = NULL; |
861 | struct sock *sk; | 861 | struct sock *sk; |
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/sunrpc/sched.c b/net/sunrpc/sched.c index f3104035e35d..54e60a657500 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -719,7 +719,7 @@ static void rpc_async_schedule(void *arg) | |||
719 | void * | 719 | void * |
720 | rpc_malloc(struct rpc_task *task, size_t size) | 720 | rpc_malloc(struct rpc_task *task, size_t size) |
721 | { | 721 | { |
722 | int gfp; | 722 | gfp_t gfp; |
723 | 723 | ||
724 | if (task->tk_flags & RPC_TASK_SWAPPER) | 724 | if (task->tk_flags & RPC_TASK_SWAPPER) |
725 | gfp = GFP_ATOMIC; | 725 | gfp = GFP_ATOMIC; |
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 |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index fda737d77edc..cbb0ba34a600 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -163,7 +163,7 @@ static void xfrm_policy_timer(unsigned long data) | |||
163 | if (xp->dead) | 163 | if (xp->dead) |
164 | goto out; | 164 | goto out; |
165 | 165 | ||
166 | dir = xp->index & 7; | 166 | dir = xfrm_policy_id2dir(xp->index); |
167 | 167 | ||
168 | if (xp->lft.hard_add_expires_seconds) { | 168 | if (xp->lft.hard_add_expires_seconds) { |
169 | long tmo = xp->lft.hard_add_expires_seconds + | 169 | long tmo = xp->lft.hard_add_expires_seconds + |
@@ -225,7 +225,7 @@ expired: | |||
225 | * SPD calls. | 225 | * SPD calls. |
226 | */ | 226 | */ |
227 | 227 | ||
228 | struct xfrm_policy *xfrm_policy_alloc(int gfp) | 228 | struct xfrm_policy *xfrm_policy_alloc(gfp_t gfp) |
229 | { | 229 | { |
230 | struct xfrm_policy *policy; | 230 | struct xfrm_policy *policy; |
231 | 231 | ||
@@ -417,7 +417,7 @@ struct xfrm_policy *xfrm_policy_byid(int dir, u32 id, int delete) | |||
417 | struct xfrm_policy *pol, **p; | 417 | struct xfrm_policy *pol, **p; |
418 | 418 | ||
419 | write_lock_bh(&xfrm_policy_lock); | 419 | write_lock_bh(&xfrm_policy_lock); |
420 | for (p = &xfrm_policy_list[id & 7]; (pol=*p)!=NULL; p = &pol->next) { | 420 | for (p = &xfrm_policy_list[dir]; (pol=*p)!=NULL; p = &pol->next) { |
421 | if (pol->index == id) { | 421 | if (pol->index == id) { |
422 | xfrm_pol_hold(pol); | 422 | xfrm_pol_hold(pol); |
423 | if (delete) | 423 | if (delete) |