diff options
Diffstat (limited to 'net/ipv4')
36 files changed, 517 insertions, 392 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index dd2b9478ddd1..1b5096a9875a 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -893,7 +893,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
893 | EXPORT_SYMBOL(inet_ioctl); | 893 | EXPORT_SYMBOL(inet_ioctl); |
894 | 894 | ||
895 | #ifdef CONFIG_COMPAT | 895 | #ifdef CONFIG_COMPAT |
896 | int inet_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | 896 | static int inet_compat_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) |
897 | { | 897 | { |
898 | struct sock *sk = sock->sk; | 898 | struct sock *sk = sock->sk; |
899 | int err = -ENOIOCTLCMD; | 899 | int err = -ENOIOCTLCMD; |
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c index 2c2a98e402e7..86f3b885b4f3 100644 --- a/net/ipv4/cipso_ipv4.c +++ b/net/ipv4/cipso_ipv4.c | |||
@@ -476,7 +476,7 @@ int cipso_v4_doi_add(struct cipso_v4_doi *doi_def, | |||
476 | doi = doi_def->doi; | 476 | doi = doi_def->doi; |
477 | doi_type = doi_def->type; | 477 | doi_type = doi_def->type; |
478 | 478 | ||
479 | if (doi_def == NULL || doi_def->doi == CIPSO_V4_DOI_UNKNOWN) | 479 | if (doi_def->doi == CIPSO_V4_DOI_UNKNOWN) |
480 | goto doi_add_return; | 480 | goto doi_add_return; |
481 | for (iter = 0; iter < CIPSO_V4_TAG_MAXCNT; iter++) { | 481 | for (iter = 0; iter < CIPSO_V4_TAG_MAXCNT; iter++) { |
482 | switch (doi_def->tags[iter]) { | 482 | switch (doi_def->tags[iter]) { |
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c index bc19bd06dd00..c6b5092f29a1 100644 --- a/net/ipv4/devinet.c +++ b/net/ipv4/devinet.c | |||
@@ -258,7 +258,7 @@ static struct in_device *inetdev_init(struct net_device *dev) | |||
258 | ip_mc_up(in_dev); | 258 | ip_mc_up(in_dev); |
259 | 259 | ||
260 | /* we can receive as soon as ip_ptr is set -- do this last */ | 260 | /* we can receive as soon as ip_ptr is set -- do this last */ |
261 | rcu_assign_pointer(dev->ip_ptr, in_dev); | 261 | RCU_INIT_POINTER(dev->ip_ptr, in_dev); |
262 | out: | 262 | out: |
263 | return in_dev; | 263 | return in_dev; |
264 | out_kfree: | 264 | out_kfree: |
@@ -291,7 +291,7 @@ static void inetdev_destroy(struct in_device *in_dev) | |||
291 | inet_free_ifa(ifa); | 291 | inet_free_ifa(ifa); |
292 | } | 292 | } |
293 | 293 | ||
294 | rcu_assign_pointer(dev->ip_ptr, NULL); | 294 | RCU_INIT_POINTER(dev->ip_ptr, NULL); |
295 | 295 | ||
296 | devinet_sysctl_unregister(in_dev); | 296 | devinet_sysctl_unregister(in_dev); |
297 | neigh_parms_release(&arp_tbl, in_dev->arp_parms); | 297 | neigh_parms_release(&arp_tbl, in_dev->arp_parms); |
@@ -1175,7 +1175,7 @@ static int inetdev_event(struct notifier_block *this, unsigned long event, | |||
1175 | switch (event) { | 1175 | switch (event) { |
1176 | case NETDEV_REGISTER: | 1176 | case NETDEV_REGISTER: |
1177 | printk(KERN_DEBUG "inetdev_event: bug\n"); | 1177 | printk(KERN_DEBUG "inetdev_event: bug\n"); |
1178 | rcu_assign_pointer(dev->ip_ptr, NULL); | 1178 | RCU_INIT_POINTER(dev->ip_ptr, NULL); |
1179 | break; | 1179 | break; |
1180 | case NETDEV_UP: | 1180 | case NETDEV_UP: |
1181 | if (!inetdev_valid_mtu(dev->mtu)) | 1181 | if (!inetdev_valid_mtu(dev->mtu)) |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index de9e2978476f..89d6f71a6a99 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -204,7 +204,7 @@ static inline struct tnode *node_parent_rcu(const struct rt_trie_node *node) | |||
204 | return (struct tnode *)(parent & ~NODE_TYPE_MASK); | 204 | return (struct tnode *)(parent & ~NODE_TYPE_MASK); |
205 | } | 205 | } |
206 | 206 | ||
207 | /* Same as rcu_assign_pointer | 207 | /* Same as RCU_INIT_POINTER |
208 | * but that macro() assumes that value is a pointer. | 208 | * but that macro() assumes that value is a pointer. |
209 | */ | 209 | */ |
210 | static inline void node_set_parent(struct rt_trie_node *node, struct tnode *ptr) | 210 | static inline void node_set_parent(struct rt_trie_node *node, struct tnode *ptr) |
@@ -528,7 +528,7 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct rt_trie_node * | |||
528 | if (n) | 528 | if (n) |
529 | node_set_parent(n, tn); | 529 | node_set_parent(n, tn); |
530 | 530 | ||
531 | rcu_assign_pointer(tn->child[i], n); | 531 | RCU_INIT_POINTER(tn->child[i], n); |
532 | } | 532 | } |
533 | 533 | ||
534 | #define MAX_WORK 10 | 534 | #define MAX_WORK 10 |
@@ -1014,7 +1014,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn) | |||
1014 | 1014 | ||
1015 | tp = node_parent((struct rt_trie_node *) tn); | 1015 | tp = node_parent((struct rt_trie_node *) tn); |
1016 | if (!tp) | 1016 | if (!tp) |
1017 | rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); | 1017 | RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); |
1018 | 1018 | ||
1019 | tnode_free_flush(); | 1019 | tnode_free_flush(); |
1020 | if (!tp) | 1020 | if (!tp) |
@@ -1026,7 +1026,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn) | |||
1026 | if (IS_TNODE(tn)) | 1026 | if (IS_TNODE(tn)) |
1027 | tn = (struct tnode *)resize(t, (struct tnode *)tn); | 1027 | tn = (struct tnode *)resize(t, (struct tnode *)tn); |
1028 | 1028 | ||
1029 | rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); | 1029 | RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); |
1030 | tnode_free_flush(); | 1030 | tnode_free_flush(); |
1031 | } | 1031 | } |
1032 | 1032 | ||
@@ -1163,7 +1163,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen) | |||
1163 | put_child(t, (struct tnode *)tp, cindex, | 1163 | put_child(t, (struct tnode *)tp, cindex, |
1164 | (struct rt_trie_node *)tn); | 1164 | (struct rt_trie_node *)tn); |
1165 | } else { | 1165 | } else { |
1166 | rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); | 1166 | RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); |
1167 | tp = tn; | 1167 | tp = tn; |
1168 | } | 1168 | } |
1169 | } | 1169 | } |
@@ -1621,7 +1621,7 @@ static void trie_leaf_remove(struct trie *t, struct leaf *l) | |||
1621 | put_child(t, (struct tnode *)tp, cindex, NULL); | 1621 | put_child(t, (struct tnode *)tp, cindex, NULL); |
1622 | trie_rebalance(t, tp); | 1622 | trie_rebalance(t, tp); |
1623 | } else | 1623 | } else |
1624 | rcu_assign_pointer(t->trie, NULL); | 1624 | RCU_INIT_POINTER(t->trie, NULL); |
1625 | 1625 | ||
1626 | free_leaf(l); | 1626 | free_leaf(l); |
1627 | } | 1627 | } |
diff --git a/net/ipv4/gre.c b/net/ipv4/gre.c index dbfc21de3479..8cb1ebb7cd74 100644 --- a/net/ipv4/gre.c +++ b/net/ipv4/gre.c | |||
@@ -34,7 +34,7 @@ int gre_add_protocol(const struct gre_protocol *proto, u8 version) | |||
34 | if (gre_proto[version]) | 34 | if (gre_proto[version]) |
35 | goto err_out_unlock; | 35 | goto err_out_unlock; |
36 | 36 | ||
37 | rcu_assign_pointer(gre_proto[version], proto); | 37 | RCU_INIT_POINTER(gre_proto[version], proto); |
38 | spin_unlock(&gre_proto_lock); | 38 | spin_unlock(&gre_proto_lock); |
39 | return 0; | 39 | return 0; |
40 | 40 | ||
@@ -54,7 +54,7 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version) | |||
54 | if (rcu_dereference_protected(gre_proto[version], | 54 | if (rcu_dereference_protected(gre_proto[version], |
55 | lockdep_is_held(&gre_proto_lock)) != proto) | 55 | lockdep_is_held(&gre_proto_lock)) != proto) |
56 | goto err_out_unlock; | 56 | goto err_out_unlock; |
57 | rcu_assign_pointer(gre_proto[version], NULL); | 57 | RCU_INIT_POINTER(gre_proto[version], NULL); |
58 | spin_unlock(&gre_proto_lock); | 58 | spin_unlock(&gre_proto_lock); |
59 | synchronize_rcu(); | 59 | synchronize_rcu(); |
60 | return 0; | 60 | return 0; |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 23ef31baa1af..ab188ae12fd9 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
@@ -1152,10 +1152,9 @@ static int __net_init icmp_sk_init(struct net *net) | |||
1152 | net->ipv4.icmp_sk[i] = sk; | 1152 | net->ipv4.icmp_sk[i] = sk; |
1153 | 1153 | ||
1154 | /* Enough space for 2 64K ICMP packets, including | 1154 | /* Enough space for 2 64K ICMP packets, including |
1155 | * sk_buff struct overhead. | 1155 | * sk_buff/skb_shared_info struct overhead. |
1156 | */ | 1156 | */ |
1157 | sk->sk_sndbuf = | 1157 | sk->sk_sndbuf = 2 * SKB_TRUESIZE(64 * 1024); |
1158 | (2 * ((64 * 1024) + sizeof(struct sk_buff))); | ||
1159 | 1158 | ||
1160 | /* | 1159 | /* |
1161 | * Speedup sock_wfree() | 1160 | * Speedup sock_wfree() |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index d577199eabd5..c7472eff2d51 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
@@ -1009,7 +1009,7 @@ static void ip_mc_filter_add(struct in_device *in_dev, __be32 addr) | |||
1009 | 1009 | ||
1010 | /* Checking for IFF_MULTICAST here is WRONG-WRONG-WRONG. | 1010 | /* Checking for IFF_MULTICAST here is WRONG-WRONG-WRONG. |
1011 | We will get multicast token leakage, when IFF_MULTICAST | 1011 | We will get multicast token leakage, when IFF_MULTICAST |
1012 | is changed. This check should be done in dev->set_multicast_list | 1012 | is changed. This check should be done in ndo_set_rx_mode |
1013 | routine. Something sort of: | 1013 | routine. Something sort of: |
1014 | if (dev->mc_list && dev->flags&IFF_MULTICAST) { do it; } | 1014 | if (dev->mc_list && dev->flags&IFF_MULTICAST) { do it; } |
1015 | --ANK | 1015 | --ANK |
@@ -1242,7 +1242,7 @@ void ip_mc_inc_group(struct in_device *in_dev, __be32 addr) | |||
1242 | 1242 | ||
1243 | im->next_rcu = in_dev->mc_list; | 1243 | im->next_rcu = in_dev->mc_list; |
1244 | in_dev->mc_count++; | 1244 | in_dev->mc_count++; |
1245 | rcu_assign_pointer(in_dev->mc_list, im); | 1245 | RCU_INIT_POINTER(in_dev->mc_list, im); |
1246 | 1246 | ||
1247 | #ifdef CONFIG_IP_MULTICAST | 1247 | #ifdef CONFIG_IP_MULTICAST |
1248 | igmpv3_del_delrec(in_dev, im->multiaddr); | 1248 | igmpv3_del_delrec(in_dev, im->multiaddr); |
@@ -1813,7 +1813,7 @@ int ip_mc_join_group(struct sock *sk , struct ip_mreqn *imr) | |||
1813 | iml->next_rcu = inet->mc_list; | 1813 | iml->next_rcu = inet->mc_list; |
1814 | iml->sflist = NULL; | 1814 | iml->sflist = NULL; |
1815 | iml->sfmode = MCAST_EXCLUDE; | 1815 | iml->sfmode = MCAST_EXCLUDE; |
1816 | rcu_assign_pointer(inet->mc_list, iml); | 1816 | RCU_INIT_POINTER(inet->mc_list, iml); |
1817 | ip_mc_inc_group(in_dev, addr); | 1817 | ip_mc_inc_group(in_dev, addr); |
1818 | err = 0; | 1818 | err = 0; |
1819 | done: | 1819 | done: |
@@ -1835,7 +1835,7 @@ static int ip_mc_leave_src(struct sock *sk, struct ip_mc_socklist *iml, | |||
1835 | } | 1835 | } |
1836 | err = ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr, | 1836 | err = ip_mc_del_src(in_dev, &iml->multi.imr_multiaddr.s_addr, |
1837 | iml->sfmode, psf->sl_count, psf->sl_addr, 0); | 1837 | iml->sfmode, psf->sl_count, psf->sl_addr, 0); |
1838 | rcu_assign_pointer(iml->sflist, NULL); | 1838 | RCU_INIT_POINTER(iml->sflist, NULL); |
1839 | /* decrease mem now to avoid the memleak warning */ | 1839 | /* decrease mem now to avoid the memleak warning */ |
1840 | atomic_sub(IP_SFLSIZE(psf->sl_max), &sk->sk_omem_alloc); | 1840 | atomic_sub(IP_SFLSIZE(psf->sl_max), &sk->sk_omem_alloc); |
1841 | kfree_rcu(psf, rcu); | 1841 | kfree_rcu(psf, rcu); |
@@ -2000,7 +2000,7 @@ int ip_mc_source(int add, int omode, struct sock *sk, struct | |||
2000 | atomic_sub(IP_SFLSIZE(psl->sl_max), &sk->sk_omem_alloc); | 2000 | atomic_sub(IP_SFLSIZE(psl->sl_max), &sk->sk_omem_alloc); |
2001 | kfree_rcu(psl, rcu); | 2001 | kfree_rcu(psl, rcu); |
2002 | } | 2002 | } |
2003 | rcu_assign_pointer(pmc->sflist, newpsl); | 2003 | RCU_INIT_POINTER(pmc->sflist, newpsl); |
2004 | psl = newpsl; | 2004 | psl = newpsl; |
2005 | } | 2005 | } |
2006 | rv = 1; /* > 0 for insert logic below if sl_count is 0 */ | 2006 | rv = 1; /* > 0 for insert logic below if sl_count is 0 */ |
@@ -2103,7 +2103,7 @@ int ip_mc_msfilter(struct sock *sk, struct ip_msfilter *msf, int ifindex) | |||
2103 | } else | 2103 | } else |
2104 | (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode, | 2104 | (void) ip_mc_del_src(in_dev, &msf->imsf_multiaddr, pmc->sfmode, |
2105 | 0, NULL, 0); | 2105 | 0, NULL, 0); |
2106 | rcu_assign_pointer(pmc->sflist, newpsl); | 2106 | RCU_INIT_POINTER(pmc->sflist, newpsl); |
2107 | pmc->sfmode = msf->imsf_fmode; | 2107 | pmc->sfmode = msf->imsf_fmode; |
2108 | err = 0; | 2108 | err = 0; |
2109 | done: | 2109 | done: |
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c index 389a2e6a17fd..f5e2bdaef949 100644 --- a/net/ipv4/inet_diag.c +++ b/net/ipv4/inet_diag.c | |||
@@ -108,6 +108,9 @@ static int inet_csk_diag_fill(struct sock *sk, | |||
108 | icsk->icsk_ca_ops->name); | 108 | icsk->icsk_ca_ops->name); |
109 | } | 109 | } |
110 | 110 | ||
111 | if ((ext & (1 << (INET_DIAG_TOS - 1))) && (sk->sk_family != AF_INET6)) | ||
112 | RTA_PUT_U8(skb, INET_DIAG_TOS, inet->tos); | ||
113 | |||
111 | r->idiag_family = sk->sk_family; | 114 | r->idiag_family = sk->sk_family; |
112 | r->idiag_state = sk->sk_state; | 115 | r->idiag_state = sk->sk_state; |
113 | r->idiag_timer = 0; | 116 | r->idiag_timer = 0; |
@@ -130,6 +133,8 @@ static int inet_csk_diag_fill(struct sock *sk, | |||
130 | &np->rcv_saddr); | 133 | &np->rcv_saddr); |
131 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, | 134 | ipv6_addr_copy((struct in6_addr *)r->id.idiag_dst, |
132 | &np->daddr); | 135 | &np->daddr); |
136 | if (ext & (1 << (INET_DIAG_TOS - 1))) | ||
137 | RTA_PUT_U8(skb, INET_DIAG_TOS, np->tclass); | ||
133 | } | 138 | } |
134 | #endif | 139 | #endif |
135 | 140 | ||
diff --git a/net/ipv4/inet_lro.c b/net/ipv4/inet_lro.c index ef7ae6049a51..cc280a3f4f96 100644 --- a/net/ipv4/inet_lro.c +++ b/net/ipv4/inet_lro.c | |||
@@ -244,11 +244,11 @@ static void lro_add_frags(struct net_lro_desc *lro_desc, | |||
244 | skb->truesize += truesize; | 244 | skb->truesize += truesize; |
245 | 245 | ||
246 | skb_frags[0].page_offset += hlen; | 246 | skb_frags[0].page_offset += hlen; |
247 | skb_frags[0].size -= hlen; | 247 | skb_frag_size_sub(&skb_frags[0], hlen); |
248 | 248 | ||
249 | while (tcp_data_len > 0) { | 249 | while (tcp_data_len > 0) { |
250 | *(lro_desc->next_frag) = *skb_frags; | 250 | *(lro_desc->next_frag) = *skb_frags; |
251 | tcp_data_len -= skb_frags->size; | 251 | tcp_data_len -= skb_frag_size(skb_frags); |
252 | lro_desc->next_frag++; | 252 | lro_desc->next_frag++; |
253 | skb_frags++; | 253 | skb_frags++; |
254 | skb_shinfo(skb)->nr_frags++; | 254 | skb_shinfo(skb)->nr_frags++; |
@@ -400,14 +400,14 @@ static struct sk_buff *lro_gen_skb(struct net_lro_mgr *lro_mgr, | |||
400 | skb_frags = skb_shinfo(skb)->frags; | 400 | skb_frags = skb_shinfo(skb)->frags; |
401 | while (data_len > 0) { | 401 | while (data_len > 0) { |
402 | *skb_frags = *frags; | 402 | *skb_frags = *frags; |
403 | data_len -= frags->size; | 403 | data_len -= skb_frag_size(frags); |
404 | skb_frags++; | 404 | skb_frags++; |
405 | frags++; | 405 | frags++; |
406 | skb_shinfo(skb)->nr_frags++; | 406 | skb_shinfo(skb)->nr_frags++; |
407 | } | 407 | } |
408 | 408 | ||
409 | skb_shinfo(skb)->frags[0].page_offset += hdr_len; | 409 | skb_shinfo(skb)->frags[0].page_offset += hdr_len; |
410 | skb_shinfo(skb)->frags[0].size -= hdr_len; | 410 | skb_frag_size_sub(&skb_shinfo(skb)->frags[0], hdr_len); |
411 | 411 | ||
412 | skb->ip_summed = ip_summed; | 412 | skb->ip_summed = ip_summed; |
413 | skb->csum = sum; | 413 | skb->csum = sum; |
@@ -433,7 +433,7 @@ static struct sk_buff *__lro_proc_segment(struct net_lro_mgr *lro_mgr, | |||
433 | if (!lro_mgr->get_frag_header || | 433 | if (!lro_mgr->get_frag_header || |
434 | lro_mgr->get_frag_header(frags, (void *)&mac_hdr, (void *)&iph, | 434 | lro_mgr->get_frag_header(frags, (void *)&mac_hdr, (void *)&iph, |
435 | (void *)&tcph, &flags, priv)) { | 435 | (void *)&tcph, &flags, priv)) { |
436 | mac_hdr = page_address(frags->page) + frags->page_offset; | 436 | mac_hdr = skb_frag_address(frags); |
437 | goto out1; | 437 | goto out1; |
438 | } | 438 | } |
439 | 439 | ||
diff --git a/net/ipv4/inet_timewait_sock.c b/net/ipv4/inet_timewait_sock.c index 3c8dfa16614d..44d65d546e30 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
@@ -183,6 +183,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat | |||
183 | tw->tw_daddr = inet->inet_daddr; | 183 | tw->tw_daddr = inet->inet_daddr; |
184 | tw->tw_rcv_saddr = inet->inet_rcv_saddr; | 184 | tw->tw_rcv_saddr = inet->inet_rcv_saddr; |
185 | tw->tw_bound_dev_if = sk->sk_bound_dev_if; | 185 | tw->tw_bound_dev_if = sk->sk_bound_dev_if; |
186 | tw->tw_tos = inet->tos; | ||
186 | tw->tw_num = inet->inet_num; | 187 | tw->tw_num = inet->inet_num; |
187 | tw->tw_state = TCP_TIME_WAIT; | 188 | tw->tw_state = TCP_TIME_WAIT; |
188 | tw->tw_substate = state; | 189 | tw->tw_substate = state; |
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 0e0ab98abc6f..fdaabf2f2b68 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c | |||
@@ -599,8 +599,8 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev, | |||
599 | head->next = clone; | 599 | head->next = clone; |
600 | skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list; | 600 | skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list; |
601 | skb_frag_list_init(head); | 601 | skb_frag_list_init(head); |
602 | for (i=0; i<skb_shinfo(head)->nr_frags; i++) | 602 | for (i = 0; i < skb_shinfo(head)->nr_frags; i++) |
603 | plen += skb_shinfo(head)->frags[i].size; | 603 | plen += skb_frag_size(&skb_shinfo(head)->frags[i]); |
604 | clone->len = clone->data_len = head->data_len - plen; | 604 | clone->len = clone->data_len = head->data_len - plen; |
605 | head->data_len -= clone->len; | 605 | head->data_len -= clone->len; |
606 | head->len -= clone->len; | 606 | head->len -= clone->len; |
@@ -682,6 +682,42 @@ int ip_defrag(struct sk_buff *skb, u32 user) | |||
682 | } | 682 | } |
683 | EXPORT_SYMBOL(ip_defrag); | 683 | EXPORT_SYMBOL(ip_defrag); |
684 | 684 | ||
685 | struct sk_buff *ip_check_defrag(struct sk_buff *skb, u32 user) | ||
686 | { | ||
687 | const struct iphdr *iph; | ||
688 | u32 len; | ||
689 | |||
690 | if (skb->protocol != htons(ETH_P_IP)) | ||
691 | return skb; | ||
692 | |||
693 | if (!pskb_may_pull(skb, sizeof(struct iphdr))) | ||
694 | return skb; | ||
695 | |||
696 | iph = ip_hdr(skb); | ||
697 | if (iph->ihl < 5 || iph->version != 4) | ||
698 | return skb; | ||
699 | if (!pskb_may_pull(skb, iph->ihl*4)) | ||
700 | return skb; | ||
701 | iph = ip_hdr(skb); | ||
702 | len = ntohs(iph->tot_len); | ||
703 | if (skb->len < len || len < (iph->ihl * 4)) | ||
704 | return skb; | ||
705 | |||
706 | if (ip_is_fragment(ip_hdr(skb))) { | ||
707 | skb = skb_share_check(skb, GFP_ATOMIC); | ||
708 | if (skb) { | ||
709 | if (pskb_trim_rcsum(skb, len)) | ||
710 | return skb; | ||
711 | memset(IPCB(skb), 0, sizeof(struct inet_skb_parm)); | ||
712 | if (ip_defrag(skb, user)) | ||
713 | return NULL; | ||
714 | skb->rxhash = 0; | ||
715 | } | ||
716 | } | ||
717 | return skb; | ||
718 | } | ||
719 | EXPORT_SYMBOL(ip_check_defrag); | ||
720 | |||
685 | #ifdef CONFIG_SYSCTL | 721 | #ifdef CONFIG_SYSCTL |
686 | static int zero; | 722 | static int zero; |
687 | 723 | ||
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c index d7bb94c48345..d55110e93120 100644 --- a/net/ipv4/ip_gre.c +++ b/net/ipv4/ip_gre.c | |||
@@ -835,8 +835,6 @@ static netdev_tx_t ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev | |||
835 | if (skb_headroom(skb) < max_headroom || skb_shared(skb)|| | 835 | if (skb_headroom(skb) < max_headroom || skb_shared(skb)|| |
836 | (skb_cloned(skb) && !skb_clone_writable(skb, 0))) { | 836 | (skb_cloned(skb) && !skb_clone_writable(skb, 0))) { |
837 | struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); | 837 | struct sk_buff *new_skb = skb_realloc_headroom(skb, max_headroom); |
838 | if (max_headroom > dev->needed_headroom) | ||
839 | dev->needed_headroom = max_headroom; | ||
840 | if (!new_skb) { | 838 | if (!new_skb) { |
841 | ip_rt_put(rt); | 839 | ip_rt_put(rt); |
842 | dev->stats.tx_dropped++; | 840 | dev->stats.tx_dropped++; |
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 8c6563361ab5..0bc95f3977d2 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c | |||
@@ -989,13 +989,13 @@ alloc_new_skb: | |||
989 | if (page && (left = PAGE_SIZE - off) > 0) { | 989 | if (page && (left = PAGE_SIZE - off) > 0) { |
990 | if (copy >= left) | 990 | if (copy >= left) |
991 | copy = left; | 991 | copy = left; |
992 | if (page != frag->page) { | 992 | if (page != skb_frag_page(frag)) { |
993 | if (i == MAX_SKB_FRAGS) { | 993 | if (i == MAX_SKB_FRAGS) { |
994 | err = -EMSGSIZE; | 994 | err = -EMSGSIZE; |
995 | goto error; | 995 | goto error; |
996 | } | 996 | } |
997 | get_page(page); | ||
998 | skb_fill_page_desc(skb, i, page, off, 0); | 997 | skb_fill_page_desc(skb, i, page, off, 0); |
998 | skb_frag_ref(skb, i); | ||
999 | frag = &skb_shinfo(skb)->frags[i]; | 999 | frag = &skb_shinfo(skb)->frags[i]; |
1000 | } | 1000 | } |
1001 | } else if (i < MAX_SKB_FRAGS) { | 1001 | } else if (i < MAX_SKB_FRAGS) { |
@@ -1015,12 +1015,13 @@ alloc_new_skb: | |||
1015 | err = -EMSGSIZE; | 1015 | err = -EMSGSIZE; |
1016 | goto error; | 1016 | goto error; |
1017 | } | 1017 | } |
1018 | if (getfrag(from, page_address(frag->page)+frag->page_offset+frag->size, offset, copy, skb->len, skb) < 0) { | 1018 | if (getfrag(from, skb_frag_address(frag)+skb_frag_size(frag), |
1019 | offset, copy, skb->len, skb) < 0) { | ||
1019 | err = -EFAULT; | 1020 | err = -EFAULT; |
1020 | goto error; | 1021 | goto error; |
1021 | } | 1022 | } |
1022 | cork->off += copy; | 1023 | cork->off += copy; |
1023 | frag->size += copy; | 1024 | skb_frag_size_add(frag, copy); |
1024 | skb->len += copy; | 1025 | skb->len += copy; |
1025 | skb->data_len += copy; | 1026 | skb->data_len += copy; |
1026 | skb->truesize += copy; | 1027 | skb->truesize += copy; |
@@ -1229,7 +1230,7 @@ ssize_t ip_append_page(struct sock *sk, struct flowi4 *fl4, struct page *page, | |||
1229 | if (len > size) | 1230 | if (len > size) |
1230 | len = size; | 1231 | len = size; |
1231 | if (skb_can_coalesce(skb, i, page, offset)) { | 1232 | if (skb_can_coalesce(skb, i, page, offset)) { |
1232 | skb_shinfo(skb)->frags[i-1].size += len; | 1233 | skb_frag_size_add(&skb_shinfo(skb)->frags[i-1], len); |
1233 | } else if (i < MAX_SKB_FRAGS) { | 1234 | } else if (i < MAX_SKB_FRAGS) { |
1234 | get_page(page); | 1235 | get_page(page); |
1235 | skb_fill_page_desc(skb, i, page, offset, len); | 1236 | skb_fill_page_desc(skb, i, page, offset, len); |
@@ -1465,7 +1466,7 @@ static int ip_reply_glue_bits(void *dptr, char *to, int offset, | |||
1465 | * structure to pass arguments. | 1466 | * structure to pass arguments. |
1466 | */ | 1467 | */ |
1467 | void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr, | 1468 | void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr, |
1468 | struct ip_reply_arg *arg, unsigned int len) | 1469 | const struct ip_reply_arg *arg, unsigned int len) |
1469 | { | 1470 | { |
1470 | struct inet_sock *inet = inet_sk(sk); | 1471 | struct inet_sock *inet = inet_sk(sk); |
1471 | struct ip_options_data replyopts; | 1472 | struct ip_options_data replyopts; |
@@ -1488,7 +1489,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr, | |||
1488 | } | 1489 | } |
1489 | 1490 | ||
1490 | flowi4_init_output(&fl4, arg->bound_dev_if, 0, | 1491 | flowi4_init_output(&fl4, arg->bound_dev_if, 0, |
1491 | RT_TOS(ip_hdr(skb)->tos), | 1492 | RT_TOS(arg->tos), |
1492 | RT_SCOPE_UNIVERSE, sk->sk_protocol, | 1493 | RT_SCOPE_UNIVERSE, sk->sk_protocol, |
1493 | ip_reply_arg_flowi_flags(arg), | 1494 | ip_reply_arg_flowi_flags(arg), |
1494 | daddr, rt->rt_spec_dst, | 1495 | daddr, rt->rt_spec_dst, |
@@ -1505,7 +1506,7 @@ void ip_send_reply(struct sock *sk, struct sk_buff *skb, __be32 daddr, | |||
1505 | with locally disabled BH and that sk cannot be already spinlocked. | 1506 | with locally disabled BH and that sk cannot be already spinlocked. |
1506 | */ | 1507 | */ |
1507 | bh_lock_sock(sk); | 1508 | bh_lock_sock(sk); |
1508 | inet->tos = ip_hdr(skb)->tos; | 1509 | inet->tos = arg->tos; |
1509 | sk->sk_priority = skb->priority; | 1510 | sk->sk_priority = skb->priority; |
1510 | sk->sk_protocol = ip_hdr(skb)->protocol; | 1511 | sk->sk_protocol = ip_hdr(skb)->protocol; |
1511 | sk->sk_bound_dev_if = arg->bound_dev_if; | 1512 | sk->sk_bound_dev_if = arg->bound_dev_if; |
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 8905e92f896a..09ff51bf16a4 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/netfilter.h> | 33 | #include <linux/netfilter.h> |
34 | #include <linux/route.h> | 34 | #include <linux/route.h> |
35 | #include <linux/mroute.h> | 35 | #include <linux/mroute.h> |
36 | #include <net/inet_ecn.h> | ||
36 | #include <net/route.h> | 37 | #include <net/route.h> |
37 | #include <net/xfrm.h> | 38 | #include <net/xfrm.h> |
38 | #include <net/compat.h> | 39 | #include <net/compat.h> |
@@ -578,8 +579,8 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
578 | break; | 579 | break; |
579 | case IP_TOS: /* This sets both TOS and Precedence */ | 580 | case IP_TOS: /* This sets both TOS and Precedence */ |
580 | if (sk->sk_type == SOCK_STREAM) { | 581 | if (sk->sk_type == SOCK_STREAM) { |
581 | val &= ~3; | 582 | val &= ~INET_ECN_MASK; |
582 | val |= inet->tos & 3; | 583 | val |= inet->tos & INET_ECN_MASK; |
583 | } | 584 | } |
584 | if (inet->tos != val) { | 585 | if (inet->tos != val) { |
585 | inet->tos = val; | 586 | inet->tos = val; |
@@ -961,7 +962,7 @@ mc_msf_out: | |||
961 | break; | 962 | break; |
962 | 963 | ||
963 | case IP_TRANSPARENT: | 964 | case IP_TRANSPARENT: |
964 | if (!capable(CAP_NET_ADMIN)) { | 965 | if (!!val && !capable(CAP_NET_RAW) && !capable(CAP_NET_ADMIN)) { |
965 | err = -EPERM; | 966 | err = -EPERM; |
966 | break; | 967 | break; |
967 | } | 968 | } |
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c index 378b20b7ca6e..065effd8349a 100644 --- a/net/ipv4/ipip.c +++ b/net/ipv4/ipip.c | |||
@@ -231,7 +231,7 @@ static void ipip_tunnel_unlink(struct ipip_net *ipn, struct ip_tunnel *t) | |||
231 | (iter = rtnl_dereference(*tp)) != NULL; | 231 | (iter = rtnl_dereference(*tp)) != NULL; |
232 | tp = &iter->next) { | 232 | tp = &iter->next) { |
233 | if (t == iter) { | 233 | if (t == iter) { |
234 | rcu_assign_pointer(*tp, t->next); | 234 | RCU_INIT_POINTER(*tp, t->next); |
235 | break; | 235 | break; |
236 | } | 236 | } |
237 | } | 237 | } |
@@ -241,8 +241,8 @@ static void ipip_tunnel_link(struct ipip_net *ipn, struct ip_tunnel *t) | |||
241 | { | 241 | { |
242 | struct ip_tunnel __rcu **tp = ipip_bucket(ipn, t); | 242 | struct ip_tunnel __rcu **tp = ipip_bucket(ipn, t); |
243 | 243 | ||
244 | rcu_assign_pointer(t->next, rtnl_dereference(*tp)); | 244 | RCU_INIT_POINTER(t->next, rtnl_dereference(*tp)); |
245 | rcu_assign_pointer(*tp, t); | 245 | RCU_INIT_POINTER(*tp, t); |
246 | } | 246 | } |
247 | 247 | ||
248 | static struct ip_tunnel * ipip_tunnel_locate(struct net *net, | 248 | static struct ip_tunnel * ipip_tunnel_locate(struct net *net, |
@@ -301,7 +301,7 @@ static void ipip_tunnel_uninit(struct net_device *dev) | |||
301 | struct ipip_net *ipn = net_generic(net, ipip_net_id); | 301 | struct ipip_net *ipn = net_generic(net, ipip_net_id); |
302 | 302 | ||
303 | if (dev == ipn->fb_tunnel_dev) | 303 | if (dev == ipn->fb_tunnel_dev) |
304 | rcu_assign_pointer(ipn->tunnels_wc[0], NULL); | 304 | RCU_INIT_POINTER(ipn->tunnels_wc[0], NULL); |
305 | else | 305 | else |
306 | ipip_tunnel_unlink(ipn, netdev_priv(dev)); | 306 | ipip_tunnel_unlink(ipn, netdev_priv(dev)); |
307 | dev_put(dev); | 307 | dev_put(dev); |
@@ -791,7 +791,7 @@ static int __net_init ipip_fb_tunnel_init(struct net_device *dev) | |||
791 | return -ENOMEM; | 791 | return -ENOMEM; |
792 | 792 | ||
793 | dev_hold(dev); | 793 | dev_hold(dev); |
794 | rcu_assign_pointer(ipn->tunnels_wc[0], tunnel); | 794 | RCU_INIT_POINTER(ipn->tunnels_wc[0], tunnel); |
795 | return 0; | 795 | return 0; |
796 | } | 796 | } |
797 | 797 | ||
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 58e879157976..6164e982e0ef 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -1176,7 +1176,7 @@ static void mrtsock_destruct(struct sock *sk) | |||
1176 | ipmr_for_each_table(mrt, net) { | 1176 | ipmr_for_each_table(mrt, net) { |
1177 | if (sk == rtnl_dereference(mrt->mroute_sk)) { | 1177 | if (sk == rtnl_dereference(mrt->mroute_sk)) { |
1178 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)--; | 1178 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)--; |
1179 | rcu_assign_pointer(mrt->mroute_sk, NULL); | 1179 | RCU_INIT_POINTER(mrt->mroute_sk, NULL); |
1180 | mroute_clean_tables(mrt); | 1180 | mroute_clean_tables(mrt); |
1181 | } | 1181 | } |
1182 | } | 1182 | } |
@@ -1203,7 +1203,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsi | |||
1203 | return -ENOENT; | 1203 | return -ENOENT; |
1204 | 1204 | ||
1205 | if (optname != MRT_INIT) { | 1205 | if (optname != MRT_INIT) { |
1206 | if (sk != rcu_dereference_raw(mrt->mroute_sk) && | 1206 | if (sk != rcu_access_pointer(mrt->mroute_sk) && |
1207 | !capable(CAP_NET_ADMIN)) | 1207 | !capable(CAP_NET_ADMIN)) |
1208 | return -EACCES; | 1208 | return -EACCES; |
1209 | } | 1209 | } |
@@ -1224,13 +1224,13 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsi | |||
1224 | 1224 | ||
1225 | ret = ip_ra_control(sk, 1, mrtsock_destruct); | 1225 | ret = ip_ra_control(sk, 1, mrtsock_destruct); |
1226 | if (ret == 0) { | 1226 | if (ret == 0) { |
1227 | rcu_assign_pointer(mrt->mroute_sk, sk); | 1227 | RCU_INIT_POINTER(mrt->mroute_sk, sk); |
1228 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)++; | 1228 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)++; |
1229 | } | 1229 | } |
1230 | rtnl_unlock(); | 1230 | rtnl_unlock(); |
1231 | return ret; | 1231 | return ret; |
1232 | case MRT_DONE: | 1232 | case MRT_DONE: |
1233 | if (sk != rcu_dereference_raw(mrt->mroute_sk)) | 1233 | if (sk != rcu_access_pointer(mrt->mroute_sk)) |
1234 | return -EACCES; | 1234 | return -EACCES; |
1235 | return ip_ra_control(sk, 0, NULL); | 1235 | return ip_ra_control(sk, 0, NULL); |
1236 | case MRT_ADD_VIF: | 1236 | case MRT_ADD_VIF: |
diff --git a/net/ipv4/netfilter/nf_nat_amanda.c b/net/ipv4/netfilter/nf_nat_amanda.c index 703f366fd235..7b22382ff0e9 100644 --- a/net/ipv4/netfilter/nf_nat_amanda.c +++ b/net/ipv4/netfilter/nf_nat_amanda.c | |||
@@ -70,14 +70,14 @@ static unsigned int help(struct sk_buff *skb, | |||
70 | 70 | ||
71 | static void __exit nf_nat_amanda_fini(void) | 71 | static void __exit nf_nat_amanda_fini(void) |
72 | { | 72 | { |
73 | rcu_assign_pointer(nf_nat_amanda_hook, NULL); | 73 | RCU_INIT_POINTER(nf_nat_amanda_hook, NULL); |
74 | synchronize_rcu(); | 74 | synchronize_rcu(); |
75 | } | 75 | } |
76 | 76 | ||
77 | static int __init nf_nat_amanda_init(void) | 77 | static int __init nf_nat_amanda_init(void) |
78 | { | 78 | { |
79 | BUG_ON(nf_nat_amanda_hook != NULL); | 79 | BUG_ON(nf_nat_amanda_hook != NULL); |
80 | rcu_assign_pointer(nf_nat_amanda_hook, help); | 80 | RCU_INIT_POINTER(nf_nat_amanda_hook, help); |
81 | return 0; | 81 | return 0; |
82 | } | 82 | } |
83 | 83 | ||
diff --git a/net/ipv4/netfilter/nf_nat_core.c b/net/ipv4/netfilter/nf_nat_core.c index 3346de5d94d0..447bc5cfdc6c 100644 --- a/net/ipv4/netfilter/nf_nat_core.c +++ b/net/ipv4/netfilter/nf_nat_core.c | |||
@@ -514,7 +514,7 @@ int nf_nat_protocol_register(const struct nf_nat_protocol *proto) | |||
514 | ret = -EBUSY; | 514 | ret = -EBUSY; |
515 | goto out; | 515 | goto out; |
516 | } | 516 | } |
517 | rcu_assign_pointer(nf_nat_protos[proto->protonum], proto); | 517 | RCU_INIT_POINTER(nf_nat_protos[proto->protonum], proto); |
518 | out: | 518 | out: |
519 | spin_unlock_bh(&nf_nat_lock); | 519 | spin_unlock_bh(&nf_nat_lock); |
520 | return ret; | 520 | return ret; |
@@ -525,7 +525,7 @@ EXPORT_SYMBOL(nf_nat_protocol_register); | |||
525 | void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto) | 525 | void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto) |
526 | { | 526 | { |
527 | spin_lock_bh(&nf_nat_lock); | 527 | spin_lock_bh(&nf_nat_lock); |
528 | rcu_assign_pointer(nf_nat_protos[proto->protonum], | 528 | RCU_INIT_POINTER(nf_nat_protos[proto->protonum], |
529 | &nf_nat_unknown_protocol); | 529 | &nf_nat_unknown_protocol); |
530 | spin_unlock_bh(&nf_nat_lock); | 530 | spin_unlock_bh(&nf_nat_lock); |
531 | synchronize_rcu(); | 531 | synchronize_rcu(); |
@@ -736,10 +736,10 @@ static int __init nf_nat_init(void) | |||
736 | /* Sew in builtin protocols. */ | 736 | /* Sew in builtin protocols. */ |
737 | spin_lock_bh(&nf_nat_lock); | 737 | spin_lock_bh(&nf_nat_lock); |
738 | for (i = 0; i < MAX_IP_NAT_PROTO; i++) | 738 | for (i = 0; i < MAX_IP_NAT_PROTO; i++) |
739 | rcu_assign_pointer(nf_nat_protos[i], &nf_nat_unknown_protocol); | 739 | RCU_INIT_POINTER(nf_nat_protos[i], &nf_nat_unknown_protocol); |
740 | rcu_assign_pointer(nf_nat_protos[IPPROTO_TCP], &nf_nat_protocol_tcp); | 740 | RCU_INIT_POINTER(nf_nat_protos[IPPROTO_TCP], &nf_nat_protocol_tcp); |
741 | rcu_assign_pointer(nf_nat_protos[IPPROTO_UDP], &nf_nat_protocol_udp); | 741 | RCU_INIT_POINTER(nf_nat_protos[IPPROTO_UDP], &nf_nat_protocol_udp); |
742 | rcu_assign_pointer(nf_nat_protos[IPPROTO_ICMP], &nf_nat_protocol_icmp); | 742 | RCU_INIT_POINTER(nf_nat_protos[IPPROTO_ICMP], &nf_nat_protocol_icmp); |
743 | spin_unlock_bh(&nf_nat_lock); | 743 | spin_unlock_bh(&nf_nat_lock); |
744 | 744 | ||
745 | /* Initialize fake conntrack so that NAT will skip it */ | 745 | /* Initialize fake conntrack so that NAT will skip it */ |
@@ -748,12 +748,12 @@ static int __init nf_nat_init(void) | |||
748 | l3proto = nf_ct_l3proto_find_get((u_int16_t)AF_INET); | 748 | l3proto = nf_ct_l3proto_find_get((u_int16_t)AF_INET); |
749 | 749 | ||
750 | BUG_ON(nf_nat_seq_adjust_hook != NULL); | 750 | BUG_ON(nf_nat_seq_adjust_hook != NULL); |
751 | rcu_assign_pointer(nf_nat_seq_adjust_hook, nf_nat_seq_adjust); | 751 | RCU_INIT_POINTER(nf_nat_seq_adjust_hook, nf_nat_seq_adjust); |
752 | BUG_ON(nfnetlink_parse_nat_setup_hook != NULL); | 752 | BUG_ON(nfnetlink_parse_nat_setup_hook != NULL); |
753 | rcu_assign_pointer(nfnetlink_parse_nat_setup_hook, | 753 | RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, |
754 | nfnetlink_parse_nat_setup); | 754 | nfnetlink_parse_nat_setup); |
755 | BUG_ON(nf_ct_nat_offset != NULL); | 755 | BUG_ON(nf_ct_nat_offset != NULL); |
756 | rcu_assign_pointer(nf_ct_nat_offset, nf_nat_get_offset); | 756 | RCU_INIT_POINTER(nf_ct_nat_offset, nf_nat_get_offset); |
757 | return 0; | 757 | return 0; |
758 | 758 | ||
759 | cleanup_extend: | 759 | cleanup_extend: |
@@ -766,9 +766,9 @@ static void __exit nf_nat_cleanup(void) | |||
766 | unregister_pernet_subsys(&nf_nat_net_ops); | 766 | unregister_pernet_subsys(&nf_nat_net_ops); |
767 | nf_ct_l3proto_put(l3proto); | 767 | nf_ct_l3proto_put(l3proto); |
768 | nf_ct_extend_unregister(&nat_extend); | 768 | nf_ct_extend_unregister(&nat_extend); |
769 | rcu_assign_pointer(nf_nat_seq_adjust_hook, NULL); | 769 | RCU_INIT_POINTER(nf_nat_seq_adjust_hook, NULL); |
770 | rcu_assign_pointer(nfnetlink_parse_nat_setup_hook, NULL); | 770 | RCU_INIT_POINTER(nfnetlink_parse_nat_setup_hook, NULL); |
771 | rcu_assign_pointer(nf_ct_nat_offset, NULL); | 771 | RCU_INIT_POINTER(nf_ct_nat_offset, NULL); |
772 | synchronize_net(); | 772 | synchronize_net(); |
773 | } | 773 | } |
774 | 774 | ||
diff --git a/net/ipv4/netfilter/nf_nat_ftp.c b/net/ipv4/netfilter/nf_nat_ftp.c index dc73abb3fe27..e462a957d080 100644 --- a/net/ipv4/netfilter/nf_nat_ftp.c +++ b/net/ipv4/netfilter/nf_nat_ftp.c | |||
@@ -113,14 +113,14 @@ out: | |||
113 | 113 | ||
114 | static void __exit nf_nat_ftp_fini(void) | 114 | static void __exit nf_nat_ftp_fini(void) |
115 | { | 115 | { |
116 | rcu_assign_pointer(nf_nat_ftp_hook, NULL); | 116 | RCU_INIT_POINTER(nf_nat_ftp_hook, NULL); |
117 | synchronize_rcu(); | 117 | synchronize_rcu(); |
118 | } | 118 | } |
119 | 119 | ||
120 | static int __init nf_nat_ftp_init(void) | 120 | static int __init nf_nat_ftp_init(void) |
121 | { | 121 | { |
122 | BUG_ON(nf_nat_ftp_hook != NULL); | 122 | BUG_ON(nf_nat_ftp_hook != NULL); |
123 | rcu_assign_pointer(nf_nat_ftp_hook, nf_nat_ftp); | 123 | RCU_INIT_POINTER(nf_nat_ftp_hook, nf_nat_ftp); |
124 | return 0; | 124 | return 0; |
125 | } | 125 | } |
126 | 126 | ||
diff --git a/net/ipv4/netfilter/nf_nat_h323.c b/net/ipv4/netfilter/nf_nat_h323.c index 790f3160e012..b9a1136addbd 100644 --- a/net/ipv4/netfilter/nf_nat_h323.c +++ b/net/ipv4/netfilter/nf_nat_h323.c | |||
@@ -581,30 +581,30 @@ static int __init init(void) | |||
581 | BUG_ON(nat_callforwarding_hook != NULL); | 581 | BUG_ON(nat_callforwarding_hook != NULL); |
582 | BUG_ON(nat_q931_hook != NULL); | 582 | BUG_ON(nat_q931_hook != NULL); |
583 | 583 | ||
584 | rcu_assign_pointer(set_h245_addr_hook, set_h245_addr); | 584 | RCU_INIT_POINTER(set_h245_addr_hook, set_h245_addr); |
585 | rcu_assign_pointer(set_h225_addr_hook, set_h225_addr); | 585 | RCU_INIT_POINTER(set_h225_addr_hook, set_h225_addr); |
586 | rcu_assign_pointer(set_sig_addr_hook, set_sig_addr); | 586 | RCU_INIT_POINTER(set_sig_addr_hook, set_sig_addr); |
587 | rcu_assign_pointer(set_ras_addr_hook, set_ras_addr); | 587 | RCU_INIT_POINTER(set_ras_addr_hook, set_ras_addr); |
588 | rcu_assign_pointer(nat_rtp_rtcp_hook, nat_rtp_rtcp); | 588 | RCU_INIT_POINTER(nat_rtp_rtcp_hook, nat_rtp_rtcp); |
589 | rcu_assign_pointer(nat_t120_hook, nat_t120); | 589 | RCU_INIT_POINTER(nat_t120_hook, nat_t120); |
590 | rcu_assign_pointer(nat_h245_hook, nat_h245); | 590 | RCU_INIT_POINTER(nat_h245_hook, nat_h245); |
591 | rcu_assign_pointer(nat_callforwarding_hook, nat_callforwarding); | 591 | RCU_INIT_POINTER(nat_callforwarding_hook, nat_callforwarding); |
592 | rcu_assign_pointer(nat_q931_hook, nat_q931); | 592 | RCU_INIT_POINTER(nat_q931_hook, nat_q931); |
593 | return 0; | 593 | return 0; |
594 | } | 594 | } |
595 | 595 | ||
596 | /****************************************************************************/ | 596 | /****************************************************************************/ |
597 | static void __exit fini(void) | 597 | static void __exit fini(void) |
598 | { | 598 | { |
599 | rcu_assign_pointer(set_h245_addr_hook, NULL); | 599 | RCU_INIT_POINTER(set_h245_addr_hook, NULL); |
600 | rcu_assign_pointer(set_h225_addr_hook, NULL); | 600 | RCU_INIT_POINTER(set_h225_addr_hook, NULL); |
601 | rcu_assign_pointer(set_sig_addr_hook, NULL); | 601 | RCU_INIT_POINTER(set_sig_addr_hook, NULL); |
602 | rcu_assign_pointer(set_ras_addr_hook, NULL); | 602 | RCU_INIT_POINTER(set_ras_addr_hook, NULL); |
603 | rcu_assign_pointer(nat_rtp_rtcp_hook, NULL); | 603 | RCU_INIT_POINTER(nat_rtp_rtcp_hook, NULL); |
604 | rcu_assign_pointer(nat_t120_hook, NULL); | 604 | RCU_INIT_POINTER(nat_t120_hook, NULL); |
605 | rcu_assign_pointer(nat_h245_hook, NULL); | 605 | RCU_INIT_POINTER(nat_h245_hook, NULL); |
606 | rcu_assign_pointer(nat_callforwarding_hook, NULL); | 606 | RCU_INIT_POINTER(nat_callforwarding_hook, NULL); |
607 | rcu_assign_pointer(nat_q931_hook, NULL); | 607 | RCU_INIT_POINTER(nat_q931_hook, NULL); |
608 | synchronize_rcu(); | 608 | synchronize_rcu(); |
609 | } | 609 | } |
610 | 610 | ||
diff --git a/net/ipv4/netfilter/nf_nat_irc.c b/net/ipv4/netfilter/nf_nat_irc.c index 535e1a802356..979ae165f4ef 100644 --- a/net/ipv4/netfilter/nf_nat_irc.c +++ b/net/ipv4/netfilter/nf_nat_irc.c | |||
@@ -75,14 +75,14 @@ static unsigned int help(struct sk_buff *skb, | |||
75 | 75 | ||
76 | static void __exit nf_nat_irc_fini(void) | 76 | static void __exit nf_nat_irc_fini(void) |
77 | { | 77 | { |
78 | rcu_assign_pointer(nf_nat_irc_hook, NULL); | 78 | RCU_INIT_POINTER(nf_nat_irc_hook, NULL); |
79 | synchronize_rcu(); | 79 | synchronize_rcu(); |
80 | } | 80 | } |
81 | 81 | ||
82 | static int __init nf_nat_irc_init(void) | 82 | static int __init nf_nat_irc_init(void) |
83 | { | 83 | { |
84 | BUG_ON(nf_nat_irc_hook != NULL); | 84 | BUG_ON(nf_nat_irc_hook != NULL); |
85 | rcu_assign_pointer(nf_nat_irc_hook, help); | 85 | RCU_INIT_POINTER(nf_nat_irc_hook, help); |
86 | return 0; | 86 | return 0; |
87 | } | 87 | } |
88 | 88 | ||
diff --git a/net/ipv4/netfilter/nf_nat_pptp.c b/net/ipv4/netfilter/nf_nat_pptp.c index 4c060038d29f..3e8284ba46b8 100644 --- a/net/ipv4/netfilter/nf_nat_pptp.c +++ b/net/ipv4/netfilter/nf_nat_pptp.c | |||
@@ -282,25 +282,25 @@ static int __init nf_nat_helper_pptp_init(void) | |||
282 | nf_nat_need_gre(); | 282 | nf_nat_need_gre(); |
283 | 283 | ||
284 | BUG_ON(nf_nat_pptp_hook_outbound != NULL); | 284 | BUG_ON(nf_nat_pptp_hook_outbound != NULL); |
285 | rcu_assign_pointer(nf_nat_pptp_hook_outbound, pptp_outbound_pkt); | 285 | RCU_INIT_POINTER(nf_nat_pptp_hook_outbound, pptp_outbound_pkt); |
286 | 286 | ||
287 | BUG_ON(nf_nat_pptp_hook_inbound != NULL); | 287 | BUG_ON(nf_nat_pptp_hook_inbound != NULL); |
288 | rcu_assign_pointer(nf_nat_pptp_hook_inbound, pptp_inbound_pkt); | 288 | RCU_INIT_POINTER(nf_nat_pptp_hook_inbound, pptp_inbound_pkt); |
289 | 289 | ||
290 | BUG_ON(nf_nat_pptp_hook_exp_gre != NULL); | 290 | BUG_ON(nf_nat_pptp_hook_exp_gre != NULL); |
291 | rcu_assign_pointer(nf_nat_pptp_hook_exp_gre, pptp_exp_gre); | 291 | RCU_INIT_POINTER(nf_nat_pptp_hook_exp_gre, pptp_exp_gre); |
292 | 292 | ||
293 | BUG_ON(nf_nat_pptp_hook_expectfn != NULL); | 293 | BUG_ON(nf_nat_pptp_hook_expectfn != NULL); |
294 | rcu_assign_pointer(nf_nat_pptp_hook_expectfn, pptp_nat_expected); | 294 | RCU_INIT_POINTER(nf_nat_pptp_hook_expectfn, pptp_nat_expected); |
295 | return 0; | 295 | return 0; |
296 | } | 296 | } |
297 | 297 | ||
298 | static void __exit nf_nat_helper_pptp_fini(void) | 298 | static void __exit nf_nat_helper_pptp_fini(void) |
299 | { | 299 | { |
300 | rcu_assign_pointer(nf_nat_pptp_hook_expectfn, NULL); | 300 | RCU_INIT_POINTER(nf_nat_pptp_hook_expectfn, NULL); |
301 | rcu_assign_pointer(nf_nat_pptp_hook_exp_gre, NULL); | 301 | RCU_INIT_POINTER(nf_nat_pptp_hook_exp_gre, NULL); |
302 | rcu_assign_pointer(nf_nat_pptp_hook_inbound, NULL); | 302 | RCU_INIT_POINTER(nf_nat_pptp_hook_inbound, NULL); |
303 | rcu_assign_pointer(nf_nat_pptp_hook_outbound, NULL); | 303 | RCU_INIT_POINTER(nf_nat_pptp_hook_outbound, NULL); |
304 | synchronize_rcu(); | 304 | synchronize_rcu(); |
305 | } | 305 | } |
306 | 306 | ||
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c index e40cf7816fdb..78844d9208f1 100644 --- a/net/ipv4/netfilter/nf_nat_sip.c +++ b/net/ipv4/netfilter/nf_nat_sip.c | |||
@@ -528,13 +528,13 @@ err1: | |||
528 | 528 | ||
529 | static void __exit nf_nat_sip_fini(void) | 529 | static void __exit nf_nat_sip_fini(void) |
530 | { | 530 | { |
531 | rcu_assign_pointer(nf_nat_sip_hook, NULL); | 531 | RCU_INIT_POINTER(nf_nat_sip_hook, NULL); |
532 | rcu_assign_pointer(nf_nat_sip_seq_adjust_hook, NULL); | 532 | RCU_INIT_POINTER(nf_nat_sip_seq_adjust_hook, NULL); |
533 | rcu_assign_pointer(nf_nat_sip_expect_hook, NULL); | 533 | RCU_INIT_POINTER(nf_nat_sip_expect_hook, NULL); |
534 | rcu_assign_pointer(nf_nat_sdp_addr_hook, NULL); | 534 | RCU_INIT_POINTER(nf_nat_sdp_addr_hook, NULL); |
535 | rcu_assign_pointer(nf_nat_sdp_port_hook, NULL); | 535 | RCU_INIT_POINTER(nf_nat_sdp_port_hook, NULL); |
536 | rcu_assign_pointer(nf_nat_sdp_session_hook, NULL); | 536 | RCU_INIT_POINTER(nf_nat_sdp_session_hook, NULL); |
537 | rcu_assign_pointer(nf_nat_sdp_media_hook, NULL); | 537 | RCU_INIT_POINTER(nf_nat_sdp_media_hook, NULL); |
538 | synchronize_rcu(); | 538 | synchronize_rcu(); |
539 | } | 539 | } |
540 | 540 | ||
@@ -547,13 +547,13 @@ static int __init nf_nat_sip_init(void) | |||
547 | BUG_ON(nf_nat_sdp_port_hook != NULL); | 547 | BUG_ON(nf_nat_sdp_port_hook != NULL); |
548 | BUG_ON(nf_nat_sdp_session_hook != NULL); | 548 | BUG_ON(nf_nat_sdp_session_hook != NULL); |
549 | BUG_ON(nf_nat_sdp_media_hook != NULL); | 549 | BUG_ON(nf_nat_sdp_media_hook != NULL); |
550 | rcu_assign_pointer(nf_nat_sip_hook, ip_nat_sip); | 550 | RCU_INIT_POINTER(nf_nat_sip_hook, ip_nat_sip); |
551 | rcu_assign_pointer(nf_nat_sip_seq_adjust_hook, ip_nat_sip_seq_adjust); | 551 | RCU_INIT_POINTER(nf_nat_sip_seq_adjust_hook, ip_nat_sip_seq_adjust); |
552 | rcu_assign_pointer(nf_nat_sip_expect_hook, ip_nat_sip_expect); | 552 | RCU_INIT_POINTER(nf_nat_sip_expect_hook, ip_nat_sip_expect); |
553 | rcu_assign_pointer(nf_nat_sdp_addr_hook, ip_nat_sdp_addr); | 553 | RCU_INIT_POINTER(nf_nat_sdp_addr_hook, ip_nat_sdp_addr); |
554 | rcu_assign_pointer(nf_nat_sdp_port_hook, ip_nat_sdp_port); | 554 | RCU_INIT_POINTER(nf_nat_sdp_port_hook, ip_nat_sdp_port); |
555 | rcu_assign_pointer(nf_nat_sdp_session_hook, ip_nat_sdp_session); | 555 | RCU_INIT_POINTER(nf_nat_sdp_session_hook, ip_nat_sdp_session); |
556 | rcu_assign_pointer(nf_nat_sdp_media_hook, ip_nat_sdp_media); | 556 | RCU_INIT_POINTER(nf_nat_sdp_media_hook, ip_nat_sdp_media); |
557 | return 0; | 557 | return 0; |
558 | } | 558 | } |
559 | 559 | ||
diff --git a/net/ipv4/netfilter/nf_nat_snmp_basic.c b/net/ipv4/netfilter/nf_nat_snmp_basic.c index 076b7c8c4aa4..d1cb412c18e0 100644 --- a/net/ipv4/netfilter/nf_nat_snmp_basic.c +++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c | |||
@@ -1310,7 +1310,7 @@ static int __init nf_nat_snmp_basic_init(void) | |||
1310 | int ret = 0; | 1310 | int ret = 0; |
1311 | 1311 | ||
1312 | BUG_ON(nf_nat_snmp_hook != NULL); | 1312 | BUG_ON(nf_nat_snmp_hook != NULL); |
1313 | rcu_assign_pointer(nf_nat_snmp_hook, help); | 1313 | RCU_INIT_POINTER(nf_nat_snmp_hook, help); |
1314 | 1314 | ||
1315 | ret = nf_conntrack_helper_register(&snmp_trap_helper); | 1315 | ret = nf_conntrack_helper_register(&snmp_trap_helper); |
1316 | if (ret < 0) { | 1316 | if (ret < 0) { |
@@ -1322,7 +1322,7 @@ static int __init nf_nat_snmp_basic_init(void) | |||
1322 | 1322 | ||
1323 | static void __exit nf_nat_snmp_basic_fini(void) | 1323 | static void __exit nf_nat_snmp_basic_fini(void) |
1324 | { | 1324 | { |
1325 | rcu_assign_pointer(nf_nat_snmp_hook, NULL); | 1325 | RCU_INIT_POINTER(nf_nat_snmp_hook, NULL); |
1326 | nf_conntrack_helper_unregister(&snmp_trap_helper); | 1326 | nf_conntrack_helper_unregister(&snmp_trap_helper); |
1327 | } | 1327 | } |
1328 | 1328 | ||
diff --git a/net/ipv4/netfilter/nf_nat_standalone.c b/net/ipv4/netfilter/nf_nat_standalone.c index a6e606e84820..92900482edea 100644 --- a/net/ipv4/netfilter/nf_nat_standalone.c +++ b/net/ipv4/netfilter/nf_nat_standalone.c | |||
@@ -284,7 +284,7 @@ static int __init nf_nat_standalone_init(void) | |||
284 | 284 | ||
285 | #ifdef CONFIG_XFRM | 285 | #ifdef CONFIG_XFRM |
286 | BUG_ON(ip_nat_decode_session != NULL); | 286 | BUG_ON(ip_nat_decode_session != NULL); |
287 | rcu_assign_pointer(ip_nat_decode_session, nat_decode_session); | 287 | RCU_INIT_POINTER(ip_nat_decode_session, nat_decode_session); |
288 | #endif | 288 | #endif |
289 | ret = nf_nat_rule_init(); | 289 | ret = nf_nat_rule_init(); |
290 | if (ret < 0) { | 290 | if (ret < 0) { |
@@ -302,7 +302,7 @@ static int __init nf_nat_standalone_init(void) | |||
302 | nf_nat_rule_cleanup(); | 302 | nf_nat_rule_cleanup(); |
303 | cleanup_decode_session: | 303 | cleanup_decode_session: |
304 | #ifdef CONFIG_XFRM | 304 | #ifdef CONFIG_XFRM |
305 | rcu_assign_pointer(ip_nat_decode_session, NULL); | 305 | RCU_INIT_POINTER(ip_nat_decode_session, NULL); |
306 | synchronize_net(); | 306 | synchronize_net(); |
307 | #endif | 307 | #endif |
308 | return ret; | 308 | return ret; |
@@ -313,7 +313,7 @@ static void __exit nf_nat_standalone_fini(void) | |||
313 | nf_unregister_hooks(nf_nat_ops, ARRAY_SIZE(nf_nat_ops)); | 313 | nf_unregister_hooks(nf_nat_ops, ARRAY_SIZE(nf_nat_ops)); |
314 | nf_nat_rule_cleanup(); | 314 | nf_nat_rule_cleanup(); |
315 | #ifdef CONFIG_XFRM | 315 | #ifdef CONFIG_XFRM |
316 | rcu_assign_pointer(ip_nat_decode_session, NULL); | 316 | RCU_INIT_POINTER(ip_nat_decode_session, NULL); |
317 | synchronize_net(); | 317 | synchronize_net(); |
318 | #endif | 318 | #endif |
319 | /* Conntrack caches are unregistered in nf_conntrack_cleanup */ | 319 | /* Conntrack caches are unregistered in nf_conntrack_cleanup */ |
diff --git a/net/ipv4/netfilter/nf_nat_tftp.c b/net/ipv4/netfilter/nf_nat_tftp.c index 7274a43c7a12..a2901bf829c0 100644 --- a/net/ipv4/netfilter/nf_nat_tftp.c +++ b/net/ipv4/netfilter/nf_nat_tftp.c | |||
@@ -36,14 +36,14 @@ static unsigned int help(struct sk_buff *skb, | |||
36 | 36 | ||
37 | static void __exit nf_nat_tftp_fini(void) | 37 | static void __exit nf_nat_tftp_fini(void) |
38 | { | 38 | { |
39 | rcu_assign_pointer(nf_nat_tftp_hook, NULL); | 39 | RCU_INIT_POINTER(nf_nat_tftp_hook, NULL); |
40 | synchronize_rcu(); | 40 | synchronize_rcu(); |
41 | } | 41 | } |
42 | 42 | ||
43 | static int __init nf_nat_tftp_init(void) | 43 | static int __init nf_nat_tftp_init(void) |
44 | { | 44 | { |
45 | BUG_ON(nf_nat_tftp_hook != NULL); | 45 | BUG_ON(nf_nat_tftp_hook != NULL); |
46 | rcu_assign_pointer(nf_nat_tftp_hook, help); | 46 | RCU_INIT_POINTER(nf_nat_tftp_hook, help); |
47 | return 0; | 47 | return 0; |
48 | } | 48 | } |
49 | 49 | ||
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 075212e41b83..155138d8ec8b 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -120,7 +120,6 @@ | |||
120 | 120 | ||
121 | static int ip_rt_max_size; | 121 | static int ip_rt_max_size; |
122 | static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT; | 122 | static int ip_rt_gc_timeout __read_mostly = RT_GC_TIMEOUT; |
123 | static int ip_rt_gc_interval __read_mostly = 60 * HZ; | ||
124 | static int ip_rt_gc_min_interval __read_mostly = HZ / 2; | 123 | static int ip_rt_gc_min_interval __read_mostly = HZ / 2; |
125 | static int ip_rt_redirect_number __read_mostly = 9; | 124 | static int ip_rt_redirect_number __read_mostly = 9; |
126 | static int ip_rt_redirect_load __read_mostly = HZ / 50; | 125 | static int ip_rt_redirect_load __read_mostly = HZ / 50; |
@@ -324,7 +323,7 @@ static struct rtable *rt_cache_get_first(struct seq_file *seq) | |||
324 | struct rtable *r = NULL; | 323 | struct rtable *r = NULL; |
325 | 324 | ||
326 | for (st->bucket = rt_hash_mask; st->bucket >= 0; --st->bucket) { | 325 | for (st->bucket = rt_hash_mask; st->bucket >= 0; --st->bucket) { |
327 | if (!rcu_dereference_raw(rt_hash_table[st->bucket].chain)) | 326 | if (!rcu_access_pointer(rt_hash_table[st->bucket].chain)) |
328 | continue; | 327 | continue; |
329 | rcu_read_lock_bh(); | 328 | rcu_read_lock_bh(); |
330 | r = rcu_dereference_bh(rt_hash_table[st->bucket].chain); | 329 | r = rcu_dereference_bh(rt_hash_table[st->bucket].chain); |
@@ -350,7 +349,7 @@ static struct rtable *__rt_cache_get_next(struct seq_file *seq, | |||
350 | do { | 349 | do { |
351 | if (--st->bucket < 0) | 350 | if (--st->bucket < 0) |
352 | return NULL; | 351 | return NULL; |
353 | } while (!rcu_dereference_raw(rt_hash_table[st->bucket].chain)); | 352 | } while (!rcu_access_pointer(rt_hash_table[st->bucket].chain)); |
354 | rcu_read_lock_bh(); | 353 | rcu_read_lock_bh(); |
355 | r = rcu_dereference_bh(rt_hash_table[st->bucket].chain); | 354 | r = rcu_dereference_bh(rt_hash_table[st->bucket].chain); |
356 | } | 355 | } |
@@ -761,7 +760,7 @@ static void rt_do_flush(struct net *net, int process_context) | |||
761 | 760 | ||
762 | if (process_context && need_resched()) | 761 | if (process_context && need_resched()) |
763 | cond_resched(); | 762 | cond_resched(); |
764 | rth = rcu_dereference_raw(rt_hash_table[i].chain); | 763 | rth = rcu_access_pointer(rt_hash_table[i].chain); |
765 | if (!rth) | 764 | if (!rth) |
766 | continue; | 765 | continue; |
767 | 766 | ||
@@ -1309,7 +1308,12 @@ static void rt_del(unsigned hash, struct rtable *rt) | |||
1309 | void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, | 1308 | void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, |
1310 | __be32 saddr, struct net_device *dev) | 1309 | __be32 saddr, struct net_device *dev) |
1311 | { | 1310 | { |
1311 | int s, i; | ||
1312 | struct in_device *in_dev = __in_dev_get_rcu(dev); | 1312 | struct in_device *in_dev = __in_dev_get_rcu(dev); |
1313 | struct rtable *rt; | ||
1314 | __be32 skeys[2] = { saddr, 0 }; | ||
1315 | int ikeys[2] = { dev->ifindex, 0 }; | ||
1316 | struct flowi4 fl4; | ||
1313 | struct inet_peer *peer; | 1317 | struct inet_peer *peer; |
1314 | struct net *net; | 1318 | struct net *net; |
1315 | 1319 | ||
@@ -1332,13 +1336,34 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, | |||
1332 | goto reject_redirect; | 1336 | goto reject_redirect; |
1333 | } | 1337 | } |
1334 | 1338 | ||
1335 | peer = inet_getpeer_v4(daddr, 1); | 1339 | memset(&fl4, 0, sizeof(fl4)); |
1336 | if (peer) { | 1340 | fl4.daddr = daddr; |
1337 | peer->redirect_learned.a4 = new_gw; | 1341 | for (s = 0; s < 2; s++) { |
1342 | for (i = 0; i < 2; i++) { | ||
1343 | fl4.flowi4_oif = ikeys[i]; | ||
1344 | fl4.saddr = skeys[s]; | ||
1345 | rt = __ip_route_output_key(net, &fl4); | ||
1346 | if (IS_ERR(rt)) | ||
1347 | continue; | ||
1338 | 1348 | ||
1339 | inet_putpeer(peer); | 1349 | if (rt->dst.error || rt->dst.dev != dev || |
1350 | rt->rt_gateway != old_gw) { | ||
1351 | ip_rt_put(rt); | ||
1352 | continue; | ||
1353 | } | ||
1354 | |||
1355 | if (!rt->peer) | ||
1356 | rt_bind_peer(rt, rt->rt_dst, 1); | ||
1357 | |||
1358 | peer = rt->peer; | ||
1359 | if (peer) { | ||
1360 | peer->redirect_learned.a4 = new_gw; | ||
1361 | atomic_inc(&__rt_peer_genid); | ||
1362 | } | ||
1340 | 1363 | ||
1341 | atomic_inc(&__rt_peer_genid); | 1364 | ip_rt_put(rt); |
1365 | return; | ||
1366 | } | ||
1342 | } | 1367 | } |
1343 | return; | 1368 | return; |
1344 | 1369 | ||
@@ -1568,11 +1593,10 @@ unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph, | |||
1568 | est_mtu = mtu; | 1593 | est_mtu = mtu; |
1569 | peer->pmtu_learned = mtu; | 1594 | peer->pmtu_learned = mtu; |
1570 | peer->pmtu_expires = pmtu_expires; | 1595 | peer->pmtu_expires = pmtu_expires; |
1596 | atomic_inc(&__rt_peer_genid); | ||
1571 | } | 1597 | } |
1572 | 1598 | ||
1573 | inet_putpeer(peer); | 1599 | inet_putpeer(peer); |
1574 | |||
1575 | atomic_inc(&__rt_peer_genid); | ||
1576 | } | 1600 | } |
1577 | return est_mtu ? : new_mtu; | 1601 | return est_mtu ? : new_mtu; |
1578 | } | 1602 | } |
@@ -3121,13 +3145,6 @@ static ctl_table ipv4_route_table[] = { | |||
3121 | .proc_handler = proc_dointvec_jiffies, | 3145 | .proc_handler = proc_dointvec_jiffies, |
3122 | }, | 3146 | }, |
3123 | { | 3147 | { |
3124 | .procname = "gc_interval", | ||
3125 | .data = &ip_rt_gc_interval, | ||
3126 | .maxlen = sizeof(int), | ||
3127 | .mode = 0644, | ||
3128 | .proc_handler = proc_dointvec_jiffies, | ||
3129 | }, | ||
3130 | { | ||
3131 | .procname = "redirect_load", | 3148 | .procname = "redirect_load", |
3132 | .data = &ip_rt_redirect_load, | 3149 | .data = &ip_rt_redirect_load, |
3133 | .maxlen = sizeof(int), | 3150 | .maxlen = sizeof(int), |
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 3bc5c8f7c71b..d7b89b12f6d8 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
@@ -265,7 +265,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
265 | struct ip_options *opt) | 265 | struct ip_options *opt) |
266 | { | 266 | { |
267 | struct tcp_options_received tcp_opt; | 267 | struct tcp_options_received tcp_opt; |
268 | u8 *hash_location; | 268 | const u8 *hash_location; |
269 | struct inet_request_sock *ireq; | 269 | struct inet_request_sock *ireq; |
270 | struct tcp_request_sock *treq; | 270 | struct tcp_request_sock *treq; |
271 | struct tcp_sock *tp = tcp_sk(sk); | 271 | struct tcp_sock *tp = tcp_sk(sk); |
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 46febcacb729..34f5db1e1c8b 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -374,7 +374,7 @@ unsigned int tcp_poll(struct file *file, struct socket *sock, poll_table *wait) | |||
374 | { | 374 | { |
375 | unsigned int mask; | 375 | unsigned int mask; |
376 | struct sock *sk = sock->sk; | 376 | struct sock *sk = sock->sk; |
377 | struct tcp_sock *tp = tcp_sk(sk); | 377 | const struct tcp_sock *tp = tcp_sk(sk); |
378 | 378 | ||
379 | sock_poll_wait(file, sk_sleep(sk), wait); | 379 | sock_poll_wait(file, sk_sleep(sk), wait); |
380 | if (sk->sk_state == TCP_LISTEN) | 380 | if (sk->sk_state == TCP_LISTEN) |
@@ -524,11 +524,11 @@ EXPORT_SYMBOL(tcp_ioctl); | |||
524 | 524 | ||
525 | static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb) | 525 | static inline void tcp_mark_push(struct tcp_sock *tp, struct sk_buff *skb) |
526 | { | 526 | { |
527 | TCP_SKB_CB(skb)->flags |= TCPHDR_PSH; | 527 | TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH; |
528 | tp->pushed_seq = tp->write_seq; | 528 | tp->pushed_seq = tp->write_seq; |
529 | } | 529 | } |
530 | 530 | ||
531 | static inline int forced_push(struct tcp_sock *tp) | 531 | static inline int forced_push(const struct tcp_sock *tp) |
532 | { | 532 | { |
533 | return after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1)); | 533 | return after(tp->write_seq, tp->pushed_seq + (tp->max_window >> 1)); |
534 | } | 534 | } |
@@ -540,7 +540,7 @@ static inline void skb_entail(struct sock *sk, struct sk_buff *skb) | |||
540 | 540 | ||
541 | skb->csum = 0; | 541 | skb->csum = 0; |
542 | tcb->seq = tcb->end_seq = tp->write_seq; | 542 | tcb->seq = tcb->end_seq = tp->write_seq; |
543 | tcb->flags = TCPHDR_ACK; | 543 | tcb->tcp_flags = TCPHDR_ACK; |
544 | tcb->sacked = 0; | 544 | tcb->sacked = 0; |
545 | skb_header_release(skb); | 545 | skb_header_release(skb); |
546 | tcp_add_write_queue_tail(sk, skb); | 546 | tcp_add_write_queue_tail(sk, skb); |
@@ -813,7 +813,7 @@ new_segment: | |||
813 | goto wait_for_memory; | 813 | goto wait_for_memory; |
814 | 814 | ||
815 | if (can_coalesce) { | 815 | if (can_coalesce) { |
816 | skb_shinfo(skb)->frags[i - 1].size += copy; | 816 | skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); |
817 | } else { | 817 | } else { |
818 | get_page(page); | 818 | get_page(page); |
819 | skb_fill_page_desc(skb, i, page, offset, copy); | 819 | skb_fill_page_desc(skb, i, page, offset, copy); |
@@ -830,7 +830,7 @@ new_segment: | |||
830 | skb_shinfo(skb)->gso_segs = 0; | 830 | skb_shinfo(skb)->gso_segs = 0; |
831 | 831 | ||
832 | if (!copied) | 832 | if (!copied) |
833 | TCP_SKB_CB(skb)->flags &= ~TCPHDR_PSH; | 833 | TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH; |
834 | 834 | ||
835 | copied += copy; | 835 | copied += copy; |
836 | poffset += copy; | 836 | poffset += copy; |
@@ -891,9 +891,9 @@ EXPORT_SYMBOL(tcp_sendpage); | |||
891 | #define TCP_PAGE(sk) (sk->sk_sndmsg_page) | 891 | #define TCP_PAGE(sk) (sk->sk_sndmsg_page) |
892 | #define TCP_OFF(sk) (sk->sk_sndmsg_off) | 892 | #define TCP_OFF(sk) (sk->sk_sndmsg_off) |
893 | 893 | ||
894 | static inline int select_size(struct sock *sk, int sg) | 894 | static inline int select_size(const struct sock *sk, int sg) |
895 | { | 895 | { |
896 | struct tcp_sock *tp = tcp_sk(sk); | 896 | const struct tcp_sock *tp = tcp_sk(sk); |
897 | int tmp = tp->mss_cache; | 897 | int tmp = tp->mss_cache; |
898 | 898 | ||
899 | if (sg) { | 899 | if (sg) { |
@@ -1058,8 +1058,7 @@ new_segment: | |||
1058 | 1058 | ||
1059 | /* Update the skb. */ | 1059 | /* Update the skb. */ |
1060 | if (merge) { | 1060 | if (merge) { |
1061 | skb_shinfo(skb)->frags[i - 1].size += | 1061 | skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); |
1062 | copy; | ||
1063 | } else { | 1062 | } else { |
1064 | skb_fill_page_desc(skb, i, page, off, copy); | 1063 | skb_fill_page_desc(skb, i, page, off, copy); |
1065 | if (TCP_PAGE(sk)) { | 1064 | if (TCP_PAGE(sk)) { |
@@ -1074,7 +1073,7 @@ new_segment: | |||
1074 | } | 1073 | } |
1075 | 1074 | ||
1076 | if (!copied) | 1075 | if (!copied) |
1077 | TCP_SKB_CB(skb)->flags &= ~TCPHDR_PSH; | 1076 | TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_PSH; |
1078 | 1077 | ||
1079 | tp->write_seq += copy; | 1078 | tp->write_seq += copy; |
1080 | TCP_SKB_CB(skb)->end_seq += copy; | 1079 | TCP_SKB_CB(skb)->end_seq += copy; |
@@ -1194,13 +1193,11 @@ void tcp_cleanup_rbuf(struct sock *sk, int copied) | |||
1194 | struct tcp_sock *tp = tcp_sk(sk); | 1193 | struct tcp_sock *tp = tcp_sk(sk); |
1195 | int time_to_ack = 0; | 1194 | int time_to_ack = 0; |
1196 | 1195 | ||
1197 | #if TCP_DEBUG | ||
1198 | struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); | 1196 | struct sk_buff *skb = skb_peek(&sk->sk_receive_queue); |
1199 | 1197 | ||
1200 | WARN(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq), | 1198 | WARN(skb && !before(tp->copied_seq, TCP_SKB_CB(skb)->end_seq), |
1201 | "cleanup rbuf bug: copied %X seq %X rcvnxt %X\n", | 1199 | "cleanup rbuf bug: copied %X seq %X rcvnxt %X\n", |
1202 | tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt); | 1200 | tp->copied_seq, TCP_SKB_CB(skb)->end_seq, tp->rcv_nxt); |
1203 | #endif | ||
1204 | 1201 | ||
1205 | if (inet_csk_ack_scheduled(sk)) { | 1202 | if (inet_csk_ack_scheduled(sk)) { |
1206 | const struct inet_connection_sock *icsk = inet_csk(sk); | 1203 | const struct inet_connection_sock *icsk = inet_csk(sk); |
@@ -2409,7 +2406,7 @@ static int do_tcp_setsockopt(struct sock *sk, int level, | |||
2409 | int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, | 2406 | int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval, |
2410 | unsigned int optlen) | 2407 | unsigned int optlen) |
2411 | { | 2408 | { |
2412 | struct inet_connection_sock *icsk = inet_csk(sk); | 2409 | const struct inet_connection_sock *icsk = inet_csk(sk); |
2413 | 2410 | ||
2414 | if (level != SOL_TCP) | 2411 | if (level != SOL_TCP) |
2415 | return icsk->icsk_af_ops->setsockopt(sk, level, optname, | 2412 | return icsk->icsk_af_ops->setsockopt(sk, level, optname, |
@@ -2431,9 +2428,9 @@ EXPORT_SYMBOL(compat_tcp_setsockopt); | |||
2431 | #endif | 2428 | #endif |
2432 | 2429 | ||
2433 | /* Return information about state of tcp endpoint in API format. */ | 2430 | /* Return information about state of tcp endpoint in API format. */ |
2434 | void tcp_get_info(struct sock *sk, struct tcp_info *info) | 2431 | void tcp_get_info(const struct sock *sk, struct tcp_info *info) |
2435 | { | 2432 | { |
2436 | struct tcp_sock *tp = tcp_sk(sk); | 2433 | const struct tcp_sock *tp = tcp_sk(sk); |
2437 | const struct inet_connection_sock *icsk = inet_csk(sk); | 2434 | const struct inet_connection_sock *icsk = inet_csk(sk); |
2438 | u32 now = tcp_time_stamp; | 2435 | u32 now = tcp_time_stamp; |
2439 | 2436 | ||
@@ -2455,8 +2452,10 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) | |||
2455 | info->tcpi_rcv_wscale = tp->rx_opt.rcv_wscale; | 2452 | info->tcpi_rcv_wscale = tp->rx_opt.rcv_wscale; |
2456 | } | 2453 | } |
2457 | 2454 | ||
2458 | if (tp->ecn_flags&TCP_ECN_OK) | 2455 | if (tp->ecn_flags & TCP_ECN_OK) |
2459 | info->tcpi_options |= TCPI_OPT_ECN; | 2456 | info->tcpi_options |= TCPI_OPT_ECN; |
2457 | if (tp->ecn_flags & TCP_ECN_SEEN) | ||
2458 | info->tcpi_options |= TCPI_OPT_ECN_SEEN; | ||
2460 | 2459 | ||
2461 | info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto); | 2460 | info->tcpi_rto = jiffies_to_usecs(icsk->icsk_rto); |
2462 | info->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato); | 2461 | info->tcpi_ato = jiffies_to_usecs(icsk->icsk_ack.ato); |
@@ -2857,26 +2856,25 @@ EXPORT_SYMBOL(tcp_gro_complete); | |||
2857 | 2856 | ||
2858 | #ifdef CONFIG_TCP_MD5SIG | 2857 | #ifdef CONFIG_TCP_MD5SIG |
2859 | static unsigned long tcp_md5sig_users; | 2858 | static unsigned long tcp_md5sig_users; |
2860 | static struct tcp_md5sig_pool * __percpu *tcp_md5sig_pool; | 2859 | static struct tcp_md5sig_pool __percpu *tcp_md5sig_pool; |
2861 | static DEFINE_SPINLOCK(tcp_md5sig_pool_lock); | 2860 | static DEFINE_SPINLOCK(tcp_md5sig_pool_lock); |
2862 | 2861 | ||
2863 | static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool * __percpu *pool) | 2862 | static void __tcp_free_md5sig_pool(struct tcp_md5sig_pool __percpu *pool) |
2864 | { | 2863 | { |
2865 | int cpu; | 2864 | int cpu; |
2865 | |||
2866 | for_each_possible_cpu(cpu) { | 2866 | for_each_possible_cpu(cpu) { |
2867 | struct tcp_md5sig_pool *p = *per_cpu_ptr(pool, cpu); | 2867 | struct tcp_md5sig_pool *p = per_cpu_ptr(pool, cpu); |
2868 | if (p) { | 2868 | |
2869 | if (p->md5_desc.tfm) | 2869 | if (p->md5_desc.tfm) |
2870 | crypto_free_hash(p->md5_desc.tfm); | 2870 | crypto_free_hash(p->md5_desc.tfm); |
2871 | kfree(p); | ||
2872 | } | ||
2873 | } | 2871 | } |
2874 | free_percpu(pool); | 2872 | free_percpu(pool); |
2875 | } | 2873 | } |
2876 | 2874 | ||
2877 | void tcp_free_md5sig_pool(void) | 2875 | void tcp_free_md5sig_pool(void) |
2878 | { | 2876 | { |
2879 | struct tcp_md5sig_pool * __percpu *pool = NULL; | 2877 | struct tcp_md5sig_pool __percpu *pool = NULL; |
2880 | 2878 | ||
2881 | spin_lock_bh(&tcp_md5sig_pool_lock); | 2879 | spin_lock_bh(&tcp_md5sig_pool_lock); |
2882 | if (--tcp_md5sig_users == 0) { | 2880 | if (--tcp_md5sig_users == 0) { |
@@ -2889,30 +2887,24 @@ void tcp_free_md5sig_pool(void) | |||
2889 | } | 2887 | } |
2890 | EXPORT_SYMBOL(tcp_free_md5sig_pool); | 2888 | EXPORT_SYMBOL(tcp_free_md5sig_pool); |
2891 | 2889 | ||
2892 | static struct tcp_md5sig_pool * __percpu * | 2890 | static struct tcp_md5sig_pool __percpu * |
2893 | __tcp_alloc_md5sig_pool(struct sock *sk) | 2891 | __tcp_alloc_md5sig_pool(struct sock *sk) |
2894 | { | 2892 | { |
2895 | int cpu; | 2893 | int cpu; |
2896 | struct tcp_md5sig_pool * __percpu *pool; | 2894 | struct tcp_md5sig_pool __percpu *pool; |
2897 | 2895 | ||
2898 | pool = alloc_percpu(struct tcp_md5sig_pool *); | 2896 | pool = alloc_percpu(struct tcp_md5sig_pool); |
2899 | if (!pool) | 2897 | if (!pool) |
2900 | return NULL; | 2898 | return NULL; |
2901 | 2899 | ||
2902 | for_each_possible_cpu(cpu) { | 2900 | for_each_possible_cpu(cpu) { |
2903 | struct tcp_md5sig_pool *p; | ||
2904 | struct crypto_hash *hash; | 2901 | struct crypto_hash *hash; |
2905 | 2902 | ||
2906 | p = kzalloc(sizeof(*p), sk->sk_allocation); | ||
2907 | if (!p) | ||
2908 | goto out_free; | ||
2909 | *per_cpu_ptr(pool, cpu) = p; | ||
2910 | |||
2911 | hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); | 2903 | hash = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); |
2912 | if (!hash || IS_ERR(hash)) | 2904 | if (!hash || IS_ERR(hash)) |
2913 | goto out_free; | 2905 | goto out_free; |
2914 | 2906 | ||
2915 | p->md5_desc.tfm = hash; | 2907 | per_cpu_ptr(pool, cpu)->md5_desc.tfm = hash; |
2916 | } | 2908 | } |
2917 | return pool; | 2909 | return pool; |
2918 | out_free: | 2910 | out_free: |
@@ -2920,9 +2912,9 @@ out_free: | |||
2920 | return NULL; | 2912 | return NULL; |
2921 | } | 2913 | } |
2922 | 2914 | ||
2923 | struct tcp_md5sig_pool * __percpu *tcp_alloc_md5sig_pool(struct sock *sk) | 2915 | struct tcp_md5sig_pool __percpu *tcp_alloc_md5sig_pool(struct sock *sk) |
2924 | { | 2916 | { |
2925 | struct tcp_md5sig_pool * __percpu *pool; | 2917 | struct tcp_md5sig_pool __percpu *pool; |
2926 | int alloc = 0; | 2918 | int alloc = 0; |
2927 | 2919 | ||
2928 | retry: | 2920 | retry: |
@@ -2941,7 +2933,7 @@ retry: | |||
2941 | 2933 | ||
2942 | if (alloc) { | 2934 | if (alloc) { |
2943 | /* we cannot hold spinlock here because this may sleep. */ | 2935 | /* we cannot hold spinlock here because this may sleep. */ |
2944 | struct tcp_md5sig_pool * __percpu *p; | 2936 | struct tcp_md5sig_pool __percpu *p; |
2945 | 2937 | ||
2946 | p = __tcp_alloc_md5sig_pool(sk); | 2938 | p = __tcp_alloc_md5sig_pool(sk); |
2947 | spin_lock_bh(&tcp_md5sig_pool_lock); | 2939 | spin_lock_bh(&tcp_md5sig_pool_lock); |
@@ -2974,7 +2966,7 @@ EXPORT_SYMBOL(tcp_alloc_md5sig_pool); | |||
2974 | */ | 2966 | */ |
2975 | struct tcp_md5sig_pool *tcp_get_md5sig_pool(void) | 2967 | struct tcp_md5sig_pool *tcp_get_md5sig_pool(void) |
2976 | { | 2968 | { |
2977 | struct tcp_md5sig_pool * __percpu *p; | 2969 | struct tcp_md5sig_pool __percpu *p; |
2978 | 2970 | ||
2979 | local_bh_disable(); | 2971 | local_bh_disable(); |
2980 | 2972 | ||
@@ -2985,7 +2977,7 @@ struct tcp_md5sig_pool *tcp_get_md5sig_pool(void) | |||
2985 | spin_unlock(&tcp_md5sig_pool_lock); | 2977 | spin_unlock(&tcp_md5sig_pool_lock); |
2986 | 2978 | ||
2987 | if (p) | 2979 | if (p) |
2988 | return *this_cpu_ptr(p); | 2980 | return this_cpu_ptr(p); |
2989 | 2981 | ||
2990 | local_bh_enable(); | 2982 | local_bh_enable(); |
2991 | return NULL; | 2983 | return NULL; |
@@ -3000,23 +2992,25 @@ void tcp_put_md5sig_pool(void) | |||
3000 | EXPORT_SYMBOL(tcp_put_md5sig_pool); | 2992 | EXPORT_SYMBOL(tcp_put_md5sig_pool); |
3001 | 2993 | ||
3002 | int tcp_md5_hash_header(struct tcp_md5sig_pool *hp, | 2994 | int tcp_md5_hash_header(struct tcp_md5sig_pool *hp, |
3003 | struct tcphdr *th) | 2995 | const struct tcphdr *th) |
3004 | { | 2996 | { |
3005 | struct scatterlist sg; | 2997 | struct scatterlist sg; |
2998 | struct tcphdr hdr; | ||
3006 | int err; | 2999 | int err; |
3007 | 3000 | ||
3008 | __sum16 old_checksum = th->check; | 3001 | /* We are not allowed to change tcphdr, make a local copy */ |
3009 | th->check = 0; | 3002 | memcpy(&hdr, th, sizeof(hdr)); |
3003 | hdr.check = 0; | ||
3004 | |||
3010 | /* options aren't included in the hash */ | 3005 | /* options aren't included in the hash */ |
3011 | sg_init_one(&sg, th, sizeof(struct tcphdr)); | 3006 | sg_init_one(&sg, &hdr, sizeof(hdr)); |
3012 | err = crypto_hash_update(&hp->md5_desc, &sg, sizeof(struct tcphdr)); | 3007 | err = crypto_hash_update(&hp->md5_desc, &sg, sizeof(hdr)); |
3013 | th->check = old_checksum; | ||
3014 | return err; | 3008 | return err; |
3015 | } | 3009 | } |
3016 | EXPORT_SYMBOL(tcp_md5_hash_header); | 3010 | EXPORT_SYMBOL(tcp_md5_hash_header); |
3017 | 3011 | ||
3018 | int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp, | 3012 | int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp, |
3019 | struct sk_buff *skb, unsigned header_len) | 3013 | const struct sk_buff *skb, unsigned int header_len) |
3020 | { | 3014 | { |
3021 | struct scatterlist sg; | 3015 | struct scatterlist sg; |
3022 | const struct tcphdr *tp = tcp_hdr(skb); | 3016 | const struct tcphdr *tp = tcp_hdr(skb); |
@@ -3035,8 +3029,9 @@ int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp, | |||
3035 | 3029 | ||
3036 | for (i = 0; i < shi->nr_frags; ++i) { | 3030 | for (i = 0; i < shi->nr_frags; ++i) { |
3037 | const struct skb_frag_struct *f = &shi->frags[i]; | 3031 | const struct skb_frag_struct *f = &shi->frags[i]; |
3038 | sg_set_page(&sg, f->page, f->size, f->page_offset); | 3032 | struct page *page = skb_frag_page(f); |
3039 | if (crypto_hash_update(desc, &sg, f->size)) | 3033 | sg_set_page(&sg, page, skb_frag_size(f), f->page_offset); |
3034 | if (crypto_hash_update(desc, &sg, skb_frag_size(f))) | ||
3040 | return 1; | 3035 | return 1; |
3041 | } | 3036 | } |
3042 | 3037 | ||
@@ -3048,7 +3043,7 @@ int tcp_md5_hash_skb_data(struct tcp_md5sig_pool *hp, | |||
3048 | } | 3043 | } |
3049 | EXPORT_SYMBOL(tcp_md5_hash_skb_data); | 3044 | EXPORT_SYMBOL(tcp_md5_hash_skb_data); |
3050 | 3045 | ||
3051 | int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, struct tcp_md5sig_key *key) | 3046 | int tcp_md5_hash_key(struct tcp_md5sig_pool *hp, const struct tcp_md5sig_key *key) |
3052 | { | 3047 | { |
3053 | struct scatterlist sg; | 3048 | struct scatterlist sg; |
3054 | 3049 | ||
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index d73aab3fbfc0..52b5c2d0ecd0 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
@@ -206,7 +206,7 @@ static inline void TCP_ECN_queue_cwr(struct tcp_sock *tp) | |||
206 | tp->ecn_flags |= TCP_ECN_QUEUE_CWR; | 206 | tp->ecn_flags |= TCP_ECN_QUEUE_CWR; |
207 | } | 207 | } |
208 | 208 | ||
209 | static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, struct sk_buff *skb) | 209 | static inline void TCP_ECN_accept_cwr(struct tcp_sock *tp, const struct sk_buff *skb) |
210 | { | 210 | { |
211 | if (tcp_hdr(skb)->cwr) | 211 | if (tcp_hdr(skb)->cwr) |
212 | tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; | 212 | tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; |
@@ -217,32 +217,41 @@ static inline void TCP_ECN_withdraw_cwr(struct tcp_sock *tp) | |||
217 | tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; | 217 | tp->ecn_flags &= ~TCP_ECN_DEMAND_CWR; |
218 | } | 218 | } |
219 | 219 | ||
220 | static inline void TCP_ECN_check_ce(struct tcp_sock *tp, struct sk_buff *skb) | 220 | static inline void TCP_ECN_check_ce(struct tcp_sock *tp, const struct sk_buff *skb) |
221 | { | 221 | { |
222 | if (tp->ecn_flags & TCP_ECN_OK) { | 222 | if (!(tp->ecn_flags & TCP_ECN_OK)) |
223 | if (INET_ECN_is_ce(TCP_SKB_CB(skb)->flags)) | 223 | return; |
224 | tp->ecn_flags |= TCP_ECN_DEMAND_CWR; | 224 | |
225 | switch (TCP_SKB_CB(skb)->ip_dsfield & INET_ECN_MASK) { | ||
226 | case INET_ECN_NOT_ECT: | ||
225 | /* Funny extension: if ECT is not set on a segment, | 227 | /* Funny extension: if ECT is not set on a segment, |
226 | * it is surely retransmit. It is not in ECN RFC, | 228 | * and we already seen ECT on a previous segment, |
227 | * but Linux follows this rule. */ | 229 | * it is probably a retransmit. |
228 | else if (INET_ECN_is_not_ect((TCP_SKB_CB(skb)->flags))) | 230 | */ |
231 | if (tp->ecn_flags & TCP_ECN_SEEN) | ||
229 | tcp_enter_quickack_mode((struct sock *)tp); | 232 | tcp_enter_quickack_mode((struct sock *)tp); |
233 | break; | ||
234 | case INET_ECN_CE: | ||
235 | tp->ecn_flags |= TCP_ECN_DEMAND_CWR; | ||
236 | /* fallinto */ | ||
237 | default: | ||
238 | tp->ecn_flags |= TCP_ECN_SEEN; | ||
230 | } | 239 | } |
231 | } | 240 | } |
232 | 241 | ||
233 | static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, struct tcphdr *th) | 242 | static inline void TCP_ECN_rcv_synack(struct tcp_sock *tp, const struct tcphdr *th) |
234 | { | 243 | { |
235 | if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || th->cwr)) | 244 | if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || th->cwr)) |
236 | tp->ecn_flags &= ~TCP_ECN_OK; | 245 | tp->ecn_flags &= ~TCP_ECN_OK; |
237 | } | 246 | } |
238 | 247 | ||
239 | static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, struct tcphdr *th) | 248 | static inline void TCP_ECN_rcv_syn(struct tcp_sock *tp, const struct tcphdr *th) |
240 | { | 249 | { |
241 | if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || !th->cwr)) | 250 | if ((tp->ecn_flags & TCP_ECN_OK) && (!th->ece || !th->cwr)) |
242 | tp->ecn_flags &= ~TCP_ECN_OK; | 251 | tp->ecn_flags &= ~TCP_ECN_OK; |
243 | } | 252 | } |
244 | 253 | ||
245 | static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th) | 254 | static inline int TCP_ECN_rcv_ecn_echo(const struct tcp_sock *tp, const struct tcphdr *th) |
246 | { | 255 | { |
247 | if (th->ece && !th->syn && (tp->ecn_flags & TCP_ECN_OK)) | 256 | if (th->ece && !th->syn && (tp->ecn_flags & TCP_ECN_OK)) |
248 | return 1; | 257 | return 1; |
@@ -256,14 +265,11 @@ static inline int TCP_ECN_rcv_ecn_echo(struct tcp_sock *tp, struct tcphdr *th) | |||
256 | 265 | ||
257 | static void tcp_fixup_sndbuf(struct sock *sk) | 266 | static void tcp_fixup_sndbuf(struct sock *sk) |
258 | { | 267 | { |
259 | int sndmem = tcp_sk(sk)->rx_opt.mss_clamp + MAX_TCP_HEADER + 16 + | 268 | int sndmem = SKB_TRUESIZE(tcp_sk(sk)->rx_opt.mss_clamp + MAX_TCP_HEADER); |
260 | sizeof(struct sk_buff); | ||
261 | 269 | ||
262 | if (sk->sk_sndbuf < 3 * sndmem) { | 270 | sndmem *= TCP_INIT_CWND; |
263 | sk->sk_sndbuf = 3 * sndmem; | 271 | if (sk->sk_sndbuf < sndmem) |
264 | if (sk->sk_sndbuf > sysctl_tcp_wmem[2]) | 272 | sk->sk_sndbuf = min(sndmem, sysctl_tcp_wmem[2]); |
265 | sk->sk_sndbuf = sysctl_tcp_wmem[2]; | ||
266 | } | ||
267 | } | 273 | } |
268 | 274 | ||
269 | /* 2. Tuning advertised window (window_clamp, rcv_ssthresh) | 275 | /* 2. Tuning advertised window (window_clamp, rcv_ssthresh) |
@@ -309,7 +315,7 @@ static int __tcp_grow_window(const struct sock *sk, const struct sk_buff *skb) | |||
309 | return 0; | 315 | return 0; |
310 | } | 316 | } |
311 | 317 | ||
312 | static void tcp_grow_window(struct sock *sk, struct sk_buff *skb) | 318 | static void tcp_grow_window(struct sock *sk, const struct sk_buff *skb) |
313 | { | 319 | { |
314 | struct tcp_sock *tp = tcp_sk(sk); | 320 | struct tcp_sock *tp = tcp_sk(sk); |
315 | 321 | ||
@@ -339,17 +345,24 @@ static void tcp_grow_window(struct sock *sk, struct sk_buff *skb) | |||
339 | 345 | ||
340 | static void tcp_fixup_rcvbuf(struct sock *sk) | 346 | static void tcp_fixup_rcvbuf(struct sock *sk) |
341 | { | 347 | { |
342 | struct tcp_sock *tp = tcp_sk(sk); | 348 | u32 mss = tcp_sk(sk)->advmss; |
343 | int rcvmem = tp->advmss + MAX_TCP_HEADER + 16 + sizeof(struct sk_buff); | 349 | u32 icwnd = TCP_DEFAULT_INIT_RCVWND; |
350 | int rcvmem; | ||
344 | 351 | ||
345 | /* Try to select rcvbuf so that 4 mss-sized segments | 352 | /* Limit to 10 segments if mss <= 1460, |
346 | * will fit to window and corresponding skbs will fit to our rcvbuf. | 353 | * or 14600/mss segments, with a minimum of two segments. |
347 | * (was 3; 4 is minimum to allow fast retransmit to work.) | ||
348 | */ | 354 | */ |
349 | while (tcp_win_from_space(rcvmem) < tp->advmss) | 355 | if (mss > 1460) |
356 | icwnd = max_t(u32, (1460 * TCP_DEFAULT_INIT_RCVWND) / mss, 2); | ||
357 | |||
358 | rcvmem = SKB_TRUESIZE(mss + MAX_TCP_HEADER); | ||
359 | while (tcp_win_from_space(rcvmem) < mss) | ||
350 | rcvmem += 128; | 360 | rcvmem += 128; |
351 | if (sk->sk_rcvbuf < 4 * rcvmem) | 361 | |
352 | sk->sk_rcvbuf = min(4 * rcvmem, sysctl_tcp_rmem[2]); | 362 | rcvmem *= icwnd; |
363 | |||
364 | if (sk->sk_rcvbuf < rcvmem) | ||
365 | sk->sk_rcvbuf = min(rcvmem, sysctl_tcp_rmem[2]); | ||
353 | } | 366 | } |
354 | 367 | ||
355 | /* 4. Try to fixup all. It is made immediately after connection enters | 368 | /* 4. Try to fixup all. It is made immediately after connection enters |
@@ -416,7 +429,7 @@ static void tcp_clamp_window(struct sock *sk) | |||
416 | */ | 429 | */ |
417 | void tcp_initialize_rcv_mss(struct sock *sk) | 430 | void tcp_initialize_rcv_mss(struct sock *sk) |
418 | { | 431 | { |
419 | struct tcp_sock *tp = tcp_sk(sk); | 432 | const struct tcp_sock *tp = tcp_sk(sk); |
420 | unsigned int hint = min_t(unsigned int, tp->advmss, tp->mss_cache); | 433 | unsigned int hint = min_t(unsigned int, tp->advmss, tp->mss_cache); |
421 | 434 | ||
422 | hint = min(hint, tp->rcv_wnd / 2); | 435 | hint = min(hint, tp->rcv_wnd / 2); |
@@ -531,8 +544,7 @@ void tcp_rcv_space_adjust(struct sock *sk) | |||
531 | space /= tp->advmss; | 544 | space /= tp->advmss; |
532 | if (!space) | 545 | if (!space) |
533 | space = 1; | 546 | space = 1; |
534 | rcvmem = (tp->advmss + MAX_TCP_HEADER + | 547 | rcvmem = SKB_TRUESIZE(tp->advmss + MAX_TCP_HEADER); |
535 | 16 + sizeof(struct sk_buff)); | ||
536 | while (tcp_win_from_space(rcvmem) < tp->advmss) | 548 | while (tcp_win_from_space(rcvmem) < tp->advmss) |
537 | rcvmem += 128; | 549 | rcvmem += 128; |
538 | space *= rcvmem; | 550 | space *= rcvmem; |
@@ -812,7 +824,7 @@ void tcp_update_metrics(struct sock *sk) | |||
812 | } | 824 | } |
813 | } | 825 | } |
814 | 826 | ||
815 | __u32 tcp_init_cwnd(struct tcp_sock *tp, struct dst_entry *dst) | 827 | __u32 tcp_init_cwnd(const struct tcp_sock *tp, const struct dst_entry *dst) |
816 | { | 828 | { |
817 | __u32 cwnd = (dst ? dst_metric(dst, RTAX_INITCWND) : 0); | 829 | __u32 cwnd = (dst ? dst_metric(dst, RTAX_INITCWND) : 0); |
818 | 830 | ||
@@ -1204,7 +1216,7 @@ static void tcp_mark_lost_retrans(struct sock *sk) | |||
1204 | tp->lost_retrans_low = new_low_seq; | 1216 | tp->lost_retrans_low = new_low_seq; |
1205 | } | 1217 | } |
1206 | 1218 | ||
1207 | static int tcp_check_dsack(struct sock *sk, struct sk_buff *ack_skb, | 1219 | static int tcp_check_dsack(struct sock *sk, const struct sk_buff *ack_skb, |
1208 | struct tcp_sack_block_wire *sp, int num_sacks, | 1220 | struct tcp_sack_block_wire *sp, int num_sacks, |
1209 | u32 prior_snd_una) | 1221 | u32 prior_snd_una) |
1210 | { | 1222 | { |
@@ -1298,7 +1310,7 @@ static int tcp_match_skb_to_sack(struct sock *sk, struct sk_buff *skb, | |||
1298 | return in_sack; | 1310 | return in_sack; |
1299 | } | 1311 | } |
1300 | 1312 | ||
1301 | static u8 tcp_sacktag_one(struct sk_buff *skb, struct sock *sk, | 1313 | static u8 tcp_sacktag_one(const struct sk_buff *skb, struct sock *sk, |
1302 | struct tcp_sacktag_state *state, | 1314 | struct tcp_sacktag_state *state, |
1303 | int dup_sack, int pcount) | 1315 | int dup_sack, int pcount) |
1304 | { | 1316 | { |
@@ -1438,7 +1450,7 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | |||
1438 | tp->lost_cnt_hint -= tcp_skb_pcount(prev); | 1450 | tp->lost_cnt_hint -= tcp_skb_pcount(prev); |
1439 | } | 1451 | } |
1440 | 1452 | ||
1441 | TCP_SKB_CB(skb)->flags |= TCP_SKB_CB(prev)->flags; | 1453 | TCP_SKB_CB(skb)->tcp_flags |= TCP_SKB_CB(prev)->tcp_flags; |
1442 | if (skb == tcp_highest_sack(sk)) | 1454 | if (skb == tcp_highest_sack(sk)) |
1443 | tcp_advance_highest_sack(sk, skb); | 1455 | tcp_advance_highest_sack(sk, skb); |
1444 | 1456 | ||
@@ -1453,13 +1465,13 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | |||
1453 | /* I wish gso_size would have a bit more sane initialization than | 1465 | /* I wish gso_size would have a bit more sane initialization than |
1454 | * something-or-zero which complicates things | 1466 | * something-or-zero which complicates things |
1455 | */ | 1467 | */ |
1456 | static int tcp_skb_seglen(struct sk_buff *skb) | 1468 | static int tcp_skb_seglen(const struct sk_buff *skb) |
1457 | { | 1469 | { |
1458 | return tcp_skb_pcount(skb) == 1 ? skb->len : tcp_skb_mss(skb); | 1470 | return tcp_skb_pcount(skb) == 1 ? skb->len : tcp_skb_mss(skb); |
1459 | } | 1471 | } |
1460 | 1472 | ||
1461 | /* Shifting pages past head area doesn't work */ | 1473 | /* Shifting pages past head area doesn't work */ |
1462 | static int skb_can_shift(struct sk_buff *skb) | 1474 | static int skb_can_shift(const struct sk_buff *skb) |
1463 | { | 1475 | { |
1464 | return !skb_headlen(skb) && skb_is_nonlinear(skb); | 1476 | return !skb_headlen(skb) && skb_is_nonlinear(skb); |
1465 | } | 1477 | } |
@@ -1708,19 +1720,19 @@ static struct sk_buff *tcp_maybe_skipping_dsack(struct sk_buff *skb, | |||
1708 | return skb; | 1720 | return skb; |
1709 | } | 1721 | } |
1710 | 1722 | ||
1711 | static int tcp_sack_cache_ok(struct tcp_sock *tp, struct tcp_sack_block *cache) | 1723 | static int tcp_sack_cache_ok(const struct tcp_sock *tp, const struct tcp_sack_block *cache) |
1712 | { | 1724 | { |
1713 | return cache < tp->recv_sack_cache + ARRAY_SIZE(tp->recv_sack_cache); | 1725 | return cache < tp->recv_sack_cache + ARRAY_SIZE(tp->recv_sack_cache); |
1714 | } | 1726 | } |
1715 | 1727 | ||
1716 | static int | 1728 | static int |
1717 | tcp_sacktag_write_queue(struct sock *sk, struct sk_buff *ack_skb, | 1729 | tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb, |
1718 | u32 prior_snd_una) | 1730 | u32 prior_snd_una) |
1719 | { | 1731 | { |
1720 | const struct inet_connection_sock *icsk = inet_csk(sk); | 1732 | const struct inet_connection_sock *icsk = inet_csk(sk); |
1721 | struct tcp_sock *tp = tcp_sk(sk); | 1733 | struct tcp_sock *tp = tcp_sk(sk); |
1722 | unsigned char *ptr = (skb_transport_header(ack_skb) + | 1734 | const unsigned char *ptr = (skb_transport_header(ack_skb) + |
1723 | TCP_SKB_CB(ack_skb)->sacked); | 1735 | TCP_SKB_CB(ack_skb)->sacked); |
1724 | struct tcp_sack_block_wire *sp_wire = (struct tcp_sack_block_wire *)(ptr+2); | 1736 | struct tcp_sack_block_wire *sp_wire = (struct tcp_sack_block_wire *)(ptr+2); |
1725 | struct tcp_sack_block sp[TCP_NUM_SACKS]; | 1737 | struct tcp_sack_block sp[TCP_NUM_SACKS]; |
1726 | struct tcp_sack_block *cache; | 1738 | struct tcp_sack_block *cache; |
@@ -2284,7 +2296,7 @@ static int tcp_check_sack_reneging(struct sock *sk, int flag) | |||
2284 | return 0; | 2296 | return 0; |
2285 | } | 2297 | } |
2286 | 2298 | ||
2287 | static inline int tcp_fackets_out(struct tcp_sock *tp) | 2299 | static inline int tcp_fackets_out(const struct tcp_sock *tp) |
2288 | { | 2300 | { |
2289 | return tcp_is_reno(tp) ? tp->sacked_out + 1 : tp->fackets_out; | 2301 | return tcp_is_reno(tp) ? tp->sacked_out + 1 : tp->fackets_out; |
2290 | } | 2302 | } |
@@ -2304,19 +2316,20 @@ static inline int tcp_fackets_out(struct tcp_sock *tp) | |||
2304 | * they differ. Since neither occurs due to loss, TCP should really | 2316 | * they differ. Since neither occurs due to loss, TCP should really |
2305 | * ignore them. | 2317 | * ignore them. |
2306 | */ | 2318 | */ |
2307 | static inline int tcp_dupack_heuristics(struct tcp_sock *tp) | 2319 | static inline int tcp_dupack_heuristics(const struct tcp_sock *tp) |
2308 | { | 2320 | { |
2309 | return tcp_is_fack(tp) ? tp->fackets_out : tp->sacked_out + 1; | 2321 | return tcp_is_fack(tp) ? tp->fackets_out : tp->sacked_out + 1; |
2310 | } | 2322 | } |
2311 | 2323 | ||
2312 | static inline int tcp_skb_timedout(struct sock *sk, struct sk_buff *skb) | 2324 | static inline int tcp_skb_timedout(const struct sock *sk, |
2325 | const struct sk_buff *skb) | ||
2313 | { | 2326 | { |
2314 | return tcp_time_stamp - TCP_SKB_CB(skb)->when > inet_csk(sk)->icsk_rto; | 2327 | return tcp_time_stamp - TCP_SKB_CB(skb)->when > inet_csk(sk)->icsk_rto; |
2315 | } | 2328 | } |
2316 | 2329 | ||
2317 | static inline int tcp_head_timedout(struct sock *sk) | 2330 | static inline int tcp_head_timedout(const struct sock *sk) |
2318 | { | 2331 | { |
2319 | struct tcp_sock *tp = tcp_sk(sk); | 2332 | const struct tcp_sock *tp = tcp_sk(sk); |
2320 | 2333 | ||
2321 | return tp->packets_out && | 2334 | return tp->packets_out && |
2322 | tcp_skb_timedout(sk, tcp_write_queue_head(sk)); | 2335 | tcp_skb_timedout(sk, tcp_write_queue_head(sk)); |
@@ -2627,7 +2640,7 @@ static void tcp_cwnd_down(struct sock *sk, int flag) | |||
2627 | /* Nothing was retransmitted or returned timestamp is less | 2640 | /* Nothing was retransmitted or returned timestamp is less |
2628 | * than timestamp of the first retransmission. | 2641 | * than timestamp of the first retransmission. |
2629 | */ | 2642 | */ |
2630 | static inline int tcp_packet_delayed(struct tcp_sock *tp) | 2643 | static inline int tcp_packet_delayed(const struct tcp_sock *tp) |
2631 | { | 2644 | { |
2632 | return !tp->retrans_stamp || | 2645 | return !tp->retrans_stamp || |
2633 | (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && | 2646 | (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && |
@@ -2688,7 +2701,7 @@ static void tcp_undo_cwr(struct sock *sk, const bool undo_ssthresh) | |||
2688 | tp->snd_cwnd_stamp = tcp_time_stamp; | 2701 | tp->snd_cwnd_stamp = tcp_time_stamp; |
2689 | } | 2702 | } |
2690 | 2703 | ||
2691 | static inline int tcp_may_undo(struct tcp_sock *tp) | 2704 | static inline int tcp_may_undo(const struct tcp_sock *tp) |
2692 | { | 2705 | { |
2693 | return tp->undo_marker && (!tp->undo_retrans || tcp_packet_delayed(tp)); | 2706 | return tp->undo_marker && (!tp->undo_retrans || tcp_packet_delayed(tp)); |
2694 | } | 2707 | } |
@@ -2752,9 +2765,9 @@ static void tcp_try_undo_dsack(struct sock *sk) | |||
2752 | * that successive retransmissions of a segment must not advance | 2765 | * that successive retransmissions of a segment must not advance |
2753 | * retrans_stamp under any conditions. | 2766 | * retrans_stamp under any conditions. |
2754 | */ | 2767 | */ |
2755 | static int tcp_any_retrans_done(struct sock *sk) | 2768 | static int tcp_any_retrans_done(const struct sock *sk) |
2756 | { | 2769 | { |
2757 | struct tcp_sock *tp = tcp_sk(sk); | 2770 | const struct tcp_sock *tp = tcp_sk(sk); |
2758 | struct sk_buff *skb; | 2771 | struct sk_buff *skb; |
2759 | 2772 | ||
2760 | if (tp->retrans_out) | 2773 | if (tp->retrans_out) |
@@ -2828,9 +2841,13 @@ static int tcp_try_undo_loss(struct sock *sk) | |||
2828 | static inline void tcp_complete_cwr(struct sock *sk) | 2841 | static inline void tcp_complete_cwr(struct sock *sk) |
2829 | { | 2842 | { |
2830 | struct tcp_sock *tp = tcp_sk(sk); | 2843 | struct tcp_sock *tp = tcp_sk(sk); |
2831 | /* Do not moderate cwnd if it's already undone in cwr or recovery */ | 2844 | |
2832 | if (tp->undo_marker && tp->snd_cwnd > tp->snd_ssthresh) { | 2845 | /* Do not moderate cwnd if it's already undone in cwr or recovery. */ |
2833 | tp->snd_cwnd = tp->snd_ssthresh; | 2846 | if (tp->undo_marker) { |
2847 | if (inet_csk(sk)->icsk_ca_state == TCP_CA_CWR) | ||
2848 | tp->snd_cwnd = min(tp->snd_cwnd, tp->snd_ssthresh); | ||
2849 | else /* PRR */ | ||
2850 | tp->snd_cwnd = tp->snd_ssthresh; | ||
2834 | tp->snd_cwnd_stamp = tcp_time_stamp; | 2851 | tp->snd_cwnd_stamp = tcp_time_stamp; |
2835 | } | 2852 | } |
2836 | tcp_ca_event(sk, CA_EVENT_COMPLETE_CWR); | 2853 | tcp_ca_event(sk, CA_EVENT_COMPLETE_CWR); |
@@ -2948,6 +2965,38 @@ void tcp_simple_retransmit(struct sock *sk) | |||
2948 | } | 2965 | } |
2949 | EXPORT_SYMBOL(tcp_simple_retransmit); | 2966 | EXPORT_SYMBOL(tcp_simple_retransmit); |
2950 | 2967 | ||
2968 | /* This function implements the PRR algorithm, specifcally the PRR-SSRB | ||
2969 | * (proportional rate reduction with slow start reduction bound) as described in | ||
2970 | * http://www.ietf.org/id/draft-mathis-tcpm-proportional-rate-reduction-01.txt. | ||
2971 | * It computes the number of packets to send (sndcnt) based on packets newly | ||
2972 | * delivered: | ||
2973 | * 1) If the packets in flight is larger than ssthresh, PRR spreads the | ||
2974 | * cwnd reductions across a full RTT. | ||
2975 | * 2) If packets in flight is lower than ssthresh (such as due to excess | ||
2976 | * losses and/or application stalls), do not perform any further cwnd | ||
2977 | * reductions, but instead slow start up to ssthresh. | ||
2978 | */ | ||
2979 | static void tcp_update_cwnd_in_recovery(struct sock *sk, int newly_acked_sacked, | ||
2980 | int fast_rexmit, int flag) | ||
2981 | { | ||
2982 | struct tcp_sock *tp = tcp_sk(sk); | ||
2983 | int sndcnt = 0; | ||
2984 | int delta = tp->snd_ssthresh - tcp_packets_in_flight(tp); | ||
2985 | |||
2986 | if (tcp_packets_in_flight(tp) > tp->snd_ssthresh) { | ||
2987 | u64 dividend = (u64)tp->snd_ssthresh * tp->prr_delivered + | ||
2988 | tp->prior_cwnd - 1; | ||
2989 | sndcnt = div_u64(dividend, tp->prior_cwnd) - tp->prr_out; | ||
2990 | } else { | ||
2991 | sndcnt = min_t(int, delta, | ||
2992 | max_t(int, tp->prr_delivered - tp->prr_out, | ||
2993 | newly_acked_sacked) + 1); | ||
2994 | } | ||
2995 | |||
2996 | sndcnt = max(sndcnt, (fast_rexmit ? 1 : 0)); | ||
2997 | tp->snd_cwnd = tcp_packets_in_flight(tp) + sndcnt; | ||
2998 | } | ||
2999 | |||
2951 | /* Process an event, which can update packets-in-flight not trivially. | 3000 | /* Process an event, which can update packets-in-flight not trivially. |
2952 | * Main goal of this function is to calculate new estimate for left_out, | 3001 | * Main goal of this function is to calculate new estimate for left_out, |
2953 | * taking into account both packets sitting in receiver's buffer and | 3002 | * taking into account both packets sitting in receiver's buffer and |
@@ -2959,7 +3008,8 @@ EXPORT_SYMBOL(tcp_simple_retransmit); | |||
2959 | * It does _not_ decide what to send, it is made in function | 3008 | * It does _not_ decide what to send, it is made in function |
2960 | * tcp_xmit_retransmit_queue(). | 3009 | * tcp_xmit_retransmit_queue(). |
2961 | */ | 3010 | */ |
2962 | static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, int flag) | 3011 | static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, |
3012 | int newly_acked_sacked, int flag) | ||
2963 | { | 3013 | { |
2964 | struct inet_connection_sock *icsk = inet_csk(sk); | 3014 | struct inet_connection_sock *icsk = inet_csk(sk); |
2965 | struct tcp_sock *tp = tcp_sk(sk); | 3015 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -3109,13 +3159,17 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, int flag) | |||
3109 | 3159 | ||
3110 | tp->bytes_acked = 0; | 3160 | tp->bytes_acked = 0; |
3111 | tp->snd_cwnd_cnt = 0; | 3161 | tp->snd_cwnd_cnt = 0; |
3162 | tp->prior_cwnd = tp->snd_cwnd; | ||
3163 | tp->prr_delivered = 0; | ||
3164 | tp->prr_out = 0; | ||
3112 | tcp_set_ca_state(sk, TCP_CA_Recovery); | 3165 | tcp_set_ca_state(sk, TCP_CA_Recovery); |
3113 | fast_rexmit = 1; | 3166 | fast_rexmit = 1; |
3114 | } | 3167 | } |
3115 | 3168 | ||
3116 | if (do_lost || (tcp_is_fack(tp) && tcp_head_timedout(sk))) | 3169 | if (do_lost || (tcp_is_fack(tp) && tcp_head_timedout(sk))) |
3117 | tcp_update_scoreboard(sk, fast_rexmit); | 3170 | tcp_update_scoreboard(sk, fast_rexmit); |
3118 | tcp_cwnd_down(sk, flag); | 3171 | tp->prr_delivered += newly_acked_sacked; |
3172 | tcp_update_cwnd_in_recovery(sk, newly_acked_sacked, fast_rexmit, flag); | ||
3119 | tcp_xmit_retransmit_queue(sk); | 3173 | tcp_xmit_retransmit_queue(sk); |
3120 | } | 3174 | } |
3121 | 3175 | ||
@@ -3192,7 +3246,7 @@ static void tcp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight) | |||
3192 | */ | 3246 | */ |
3193 | static void tcp_rearm_rto(struct sock *sk) | 3247 | static void tcp_rearm_rto(struct sock *sk) |
3194 | { | 3248 | { |
3195 | struct tcp_sock *tp = tcp_sk(sk); | 3249 | const struct tcp_sock *tp = tcp_sk(sk); |
3196 | 3250 | ||
3197 | if (!tp->packets_out) { | 3251 | if (!tp->packets_out) { |
3198 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); | 3252 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); |
@@ -3296,7 +3350,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, | |||
3296 | * connection startup slow start one packet too | 3350 | * connection startup slow start one packet too |
3297 | * quickly. This is severely frowned upon behavior. | 3351 | * quickly. This is severely frowned upon behavior. |
3298 | */ | 3352 | */ |
3299 | if (!(scb->flags & TCPHDR_SYN)) { | 3353 | if (!(scb->tcp_flags & TCPHDR_SYN)) { |
3300 | flag |= FLAG_DATA_ACKED; | 3354 | flag |= FLAG_DATA_ACKED; |
3301 | } else { | 3355 | } else { |
3302 | flag |= FLAG_SYN_ACKED; | 3356 | flag |= FLAG_SYN_ACKED; |
@@ -3444,7 +3498,7 @@ static inline int tcp_may_update_window(const struct tcp_sock *tp, | |||
3444 | * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2 | 3498 | * Window update algorithm, described in RFC793/RFC1122 (used in linux-2.2 |
3445 | * and in FreeBSD. NetBSD's one is even worse.) is wrong. | 3499 | * and in FreeBSD. NetBSD's one is even worse.) is wrong. |
3446 | */ | 3500 | */ |
3447 | static int tcp_ack_update_window(struct sock *sk, struct sk_buff *skb, u32 ack, | 3501 | static int tcp_ack_update_window(struct sock *sk, const struct sk_buff *skb, u32 ack, |
3448 | u32 ack_seq) | 3502 | u32 ack_seq) |
3449 | { | 3503 | { |
3450 | struct tcp_sock *tp = tcp_sk(sk); | 3504 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -3620,7 +3674,7 @@ static int tcp_process_frto(struct sock *sk, int flag) | |||
3620 | } | 3674 | } |
3621 | 3675 | ||
3622 | /* This routine deals with incoming acks, but not outgoing ones. */ | 3676 | /* This routine deals with incoming acks, but not outgoing ones. */ |
3623 | static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | 3677 | static int tcp_ack(struct sock *sk, const struct sk_buff *skb, int flag) |
3624 | { | 3678 | { |
3625 | struct inet_connection_sock *icsk = inet_csk(sk); | 3679 | struct inet_connection_sock *icsk = inet_csk(sk); |
3626 | struct tcp_sock *tp = tcp_sk(sk); | 3680 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -3630,6 +3684,8 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3630 | u32 prior_in_flight; | 3684 | u32 prior_in_flight; |
3631 | u32 prior_fackets; | 3685 | u32 prior_fackets; |
3632 | int prior_packets; | 3686 | int prior_packets; |
3687 | int prior_sacked = tp->sacked_out; | ||
3688 | int newly_acked_sacked = 0; | ||
3633 | int frto_cwnd = 0; | 3689 | int frto_cwnd = 0; |
3634 | 3690 | ||
3635 | /* If the ack is older than previous acks | 3691 | /* If the ack is older than previous acks |
@@ -3701,6 +3757,9 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3701 | /* See if we can take anything off of the retransmit queue. */ | 3757 | /* See if we can take anything off of the retransmit queue. */ |
3702 | flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una); | 3758 | flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una); |
3703 | 3759 | ||
3760 | newly_acked_sacked = (prior_packets - prior_sacked) - | ||
3761 | (tp->packets_out - tp->sacked_out); | ||
3762 | |||
3704 | if (tp->frto_counter) | 3763 | if (tp->frto_counter) |
3705 | frto_cwnd = tcp_process_frto(sk, flag); | 3764 | frto_cwnd = tcp_process_frto(sk, flag); |
3706 | /* Guarantee sacktag reordering detection against wrap-arounds */ | 3765 | /* Guarantee sacktag reordering detection against wrap-arounds */ |
@@ -3713,7 +3772,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
3713 | tcp_may_raise_cwnd(sk, flag)) | 3772 | tcp_may_raise_cwnd(sk, flag)) |
3714 | tcp_cong_avoid(sk, ack, prior_in_flight); | 3773 | tcp_cong_avoid(sk, ack, prior_in_flight); |
3715 | tcp_fastretrans_alert(sk, prior_packets - tp->packets_out, | 3774 | tcp_fastretrans_alert(sk, prior_packets - tp->packets_out, |
3716 | flag); | 3775 | newly_acked_sacked, flag); |
3717 | } else { | 3776 | } else { |
3718 | if ((flag & FLAG_DATA_ACKED) && !frto_cwnd) | 3777 | if ((flag & FLAG_DATA_ACKED) && !frto_cwnd) |
3719 | tcp_cong_avoid(sk, ack, prior_in_flight); | 3778 | tcp_cong_avoid(sk, ack, prior_in_flight); |
@@ -3752,14 +3811,14 @@ old_ack: | |||
3752 | * But, this can also be called on packets in the established flow when | 3811 | * But, this can also be called on packets in the established flow when |
3753 | * the fast version below fails. | 3812 | * the fast version below fails. |
3754 | */ | 3813 | */ |
3755 | void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, | 3814 | void tcp_parse_options(const struct sk_buff *skb, struct tcp_options_received *opt_rx, |
3756 | u8 **hvpp, int estab) | 3815 | const u8 **hvpp, int estab) |
3757 | { | 3816 | { |
3758 | unsigned char *ptr; | 3817 | const unsigned char *ptr; |
3759 | struct tcphdr *th = tcp_hdr(skb); | 3818 | const struct tcphdr *th = tcp_hdr(skb); |
3760 | int length = (th->doff * 4) - sizeof(struct tcphdr); | 3819 | int length = (th->doff * 4) - sizeof(struct tcphdr); |
3761 | 3820 | ||
3762 | ptr = (unsigned char *)(th + 1); | 3821 | ptr = (const unsigned char *)(th + 1); |
3763 | opt_rx->saw_tstamp = 0; | 3822 | opt_rx->saw_tstamp = 0; |
3764 | 3823 | ||
3765 | while (length > 0) { | 3824 | while (length > 0) { |
@@ -3870,9 +3929,9 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, | |||
3870 | } | 3929 | } |
3871 | EXPORT_SYMBOL(tcp_parse_options); | 3930 | EXPORT_SYMBOL(tcp_parse_options); |
3872 | 3931 | ||
3873 | static int tcp_parse_aligned_timestamp(struct tcp_sock *tp, struct tcphdr *th) | 3932 | static int tcp_parse_aligned_timestamp(struct tcp_sock *tp, const struct tcphdr *th) |
3874 | { | 3933 | { |
3875 | __be32 *ptr = (__be32 *)(th + 1); | 3934 | const __be32 *ptr = (const __be32 *)(th + 1); |
3876 | 3935 | ||
3877 | if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | 3936 | if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
3878 | | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { | 3937 | | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { |
@@ -3889,8 +3948,9 @@ static int tcp_parse_aligned_timestamp(struct tcp_sock *tp, struct tcphdr *th) | |||
3889 | /* Fast parse options. This hopes to only see timestamps. | 3948 | /* Fast parse options. This hopes to only see timestamps. |
3890 | * If it is wrong it falls back on tcp_parse_options(). | 3949 | * If it is wrong it falls back on tcp_parse_options(). |
3891 | */ | 3950 | */ |
3892 | static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th, | 3951 | static int tcp_fast_parse_options(const struct sk_buff *skb, |
3893 | struct tcp_sock *tp, u8 **hvpp) | 3952 | const struct tcphdr *th, |
3953 | struct tcp_sock *tp, const u8 **hvpp) | ||
3894 | { | 3954 | { |
3895 | /* In the spirit of fast parsing, compare doff directly to constant | 3955 | /* In the spirit of fast parsing, compare doff directly to constant |
3896 | * values. Because equality is used, short doff can be ignored here. | 3956 | * values. Because equality is used, short doff can be ignored here. |
@@ -3911,10 +3971,10 @@ static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th, | |||
3911 | /* | 3971 | /* |
3912 | * Parse MD5 Signature option | 3972 | * Parse MD5 Signature option |
3913 | */ | 3973 | */ |
3914 | u8 *tcp_parse_md5sig_option(struct tcphdr *th) | 3974 | const u8 *tcp_parse_md5sig_option(const struct tcphdr *th) |
3915 | { | 3975 | { |
3916 | int length = (th->doff << 2) - sizeof (*th); | 3976 | int length = (th->doff << 2) - sizeof(*th); |
3917 | u8 *ptr = (u8*)(th + 1); | 3977 | const u8 *ptr = (const u8 *)(th + 1); |
3918 | 3978 | ||
3919 | /* If the TCP option is too short, we can short cut */ | 3979 | /* If the TCP option is too short, we can short cut */ |
3920 | if (length < TCPOLEN_MD5SIG) | 3980 | if (length < TCPOLEN_MD5SIG) |
@@ -3991,8 +4051,8 @@ static inline void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) | |||
3991 | 4051 | ||
3992 | static int tcp_disordered_ack(const struct sock *sk, const struct sk_buff *skb) | 4052 | static int tcp_disordered_ack(const struct sock *sk, const struct sk_buff *skb) |
3993 | { | 4053 | { |
3994 | struct tcp_sock *tp = tcp_sk(sk); | 4054 | const struct tcp_sock *tp = tcp_sk(sk); |
3995 | struct tcphdr *th = tcp_hdr(skb); | 4055 | const struct tcphdr *th = tcp_hdr(skb); |
3996 | u32 seq = TCP_SKB_CB(skb)->seq; | 4056 | u32 seq = TCP_SKB_CB(skb)->seq; |
3997 | u32 ack = TCP_SKB_CB(skb)->ack_seq; | 4057 | u32 ack = TCP_SKB_CB(skb)->ack_seq; |
3998 | 4058 | ||
@@ -4031,7 +4091,7 @@ static inline int tcp_paws_discard(const struct sock *sk, | |||
4031 | * (borrowed from freebsd) | 4091 | * (borrowed from freebsd) |
4032 | */ | 4092 | */ |
4033 | 4093 | ||
4034 | static inline int tcp_sequence(struct tcp_sock *tp, u32 seq, u32 end_seq) | 4094 | static inline int tcp_sequence(const struct tcp_sock *tp, u32 seq, u32 end_seq) |
4035 | { | 4095 | { |
4036 | return !before(end_seq, tp->rcv_wup) && | 4096 | return !before(end_seq, tp->rcv_wup) && |
4037 | !after(seq, tp->rcv_nxt + tcp_receive_window(tp)); | 4097 | !after(seq, tp->rcv_nxt + tcp_receive_window(tp)); |
@@ -4076,7 +4136,7 @@ static void tcp_reset(struct sock *sk) | |||
4076 | * | 4136 | * |
4077 | * If we are in FINWAIT-2, a received FIN moves us to TIME-WAIT. | 4137 | * If we are in FINWAIT-2, a received FIN moves us to TIME-WAIT. |
4078 | */ | 4138 | */ |
4079 | static void tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th) | 4139 | static void tcp_fin(struct sock *sk) |
4080 | { | 4140 | { |
4081 | struct tcp_sock *tp = tcp_sk(sk); | 4141 | struct tcp_sock *tp = tcp_sk(sk); |
4082 | 4142 | ||
@@ -4188,7 +4248,7 @@ static void tcp_dsack_extend(struct sock *sk, u32 seq, u32 end_seq) | |||
4188 | tcp_sack_extend(tp->duplicate_sack, seq, end_seq); | 4248 | tcp_sack_extend(tp->duplicate_sack, seq, end_seq); |
4189 | } | 4249 | } |
4190 | 4250 | ||
4191 | static void tcp_send_dupack(struct sock *sk, struct sk_buff *skb) | 4251 | static void tcp_send_dupack(struct sock *sk, const struct sk_buff *skb) |
4192 | { | 4252 | { |
4193 | struct tcp_sock *tp = tcp_sk(sk); | 4253 | struct tcp_sock *tp = tcp_sk(sk); |
4194 | 4254 | ||
@@ -4347,7 +4407,7 @@ static void tcp_ofo_queue(struct sock *sk) | |||
4347 | __skb_queue_tail(&sk->sk_receive_queue, skb); | 4407 | __skb_queue_tail(&sk->sk_receive_queue, skb); |
4348 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; | 4408 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; |
4349 | if (tcp_hdr(skb)->fin) | 4409 | if (tcp_hdr(skb)->fin) |
4350 | tcp_fin(skb, sk, tcp_hdr(skb)); | 4410 | tcp_fin(sk); |
4351 | } | 4411 | } |
4352 | } | 4412 | } |
4353 | 4413 | ||
@@ -4375,7 +4435,7 @@ static inline int tcp_try_rmem_schedule(struct sock *sk, unsigned int size) | |||
4375 | 4435 | ||
4376 | static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) | 4436 | static void tcp_data_queue(struct sock *sk, struct sk_buff *skb) |
4377 | { | 4437 | { |
4378 | struct tcphdr *th = tcp_hdr(skb); | 4438 | const struct tcphdr *th = tcp_hdr(skb); |
4379 | struct tcp_sock *tp = tcp_sk(sk); | 4439 | struct tcp_sock *tp = tcp_sk(sk); |
4380 | int eaten = -1; | 4440 | int eaten = -1; |
4381 | 4441 | ||
@@ -4429,7 +4489,7 @@ queue_and_out: | |||
4429 | if (skb->len) | 4489 | if (skb->len) |
4430 | tcp_event_data_recv(sk, skb); | 4490 | tcp_event_data_recv(sk, skb); |
4431 | if (th->fin) | 4491 | if (th->fin) |
4432 | tcp_fin(skb, sk, th); | 4492 | tcp_fin(sk); |
4433 | 4493 | ||
4434 | if (!skb_queue_empty(&tp->out_of_order_queue)) { | 4494 | if (!skb_queue_empty(&tp->out_of_order_queue)) { |
4435 | tcp_ofo_queue(sk); | 4495 | tcp_ofo_queue(sk); |
@@ -4859,9 +4919,9 @@ void tcp_cwnd_application_limited(struct sock *sk) | |||
4859 | tp->snd_cwnd_stamp = tcp_time_stamp; | 4919 | tp->snd_cwnd_stamp = tcp_time_stamp; |
4860 | } | 4920 | } |
4861 | 4921 | ||
4862 | static int tcp_should_expand_sndbuf(struct sock *sk) | 4922 | static int tcp_should_expand_sndbuf(const struct sock *sk) |
4863 | { | 4923 | { |
4864 | struct tcp_sock *tp = tcp_sk(sk); | 4924 | const struct tcp_sock *tp = tcp_sk(sk); |
4865 | 4925 | ||
4866 | /* If the user specified a specific send buffer setting, do | 4926 | /* If the user specified a specific send buffer setting, do |
4867 | * not modify it. | 4927 | * not modify it. |
@@ -4895,8 +4955,10 @@ static void tcp_new_space(struct sock *sk) | |||
4895 | struct tcp_sock *tp = tcp_sk(sk); | 4955 | struct tcp_sock *tp = tcp_sk(sk); |
4896 | 4956 | ||
4897 | if (tcp_should_expand_sndbuf(sk)) { | 4957 | if (tcp_should_expand_sndbuf(sk)) { |
4898 | int sndmem = max_t(u32, tp->rx_opt.mss_clamp, tp->mss_cache) + | 4958 | int sndmem = SKB_TRUESIZE(max_t(u32, |
4899 | MAX_TCP_HEADER + 16 + sizeof(struct sk_buff); | 4959 | tp->rx_opt.mss_clamp, |
4960 | tp->mss_cache) + | ||
4961 | MAX_TCP_HEADER); | ||
4900 | int demanded = max_t(unsigned int, tp->snd_cwnd, | 4962 | int demanded = max_t(unsigned int, tp->snd_cwnd, |
4901 | tp->reordering + 1); | 4963 | tp->reordering + 1); |
4902 | sndmem *= 2 * demanded; | 4964 | sndmem *= 2 * demanded; |
@@ -4968,7 +5030,7 @@ static inline void tcp_ack_snd_check(struct sock *sk) | |||
4968 | * either form (or just set the sysctl tcp_stdurg). | 5030 | * either form (or just set the sysctl tcp_stdurg). |
4969 | */ | 5031 | */ |
4970 | 5032 | ||
4971 | static void tcp_check_urg(struct sock *sk, struct tcphdr *th) | 5033 | static void tcp_check_urg(struct sock *sk, const struct tcphdr *th) |
4972 | { | 5034 | { |
4973 | struct tcp_sock *tp = tcp_sk(sk); | 5035 | struct tcp_sock *tp = tcp_sk(sk); |
4974 | u32 ptr = ntohs(th->urg_ptr); | 5036 | u32 ptr = ntohs(th->urg_ptr); |
@@ -5034,7 +5096,7 @@ static void tcp_check_urg(struct sock *sk, struct tcphdr *th) | |||
5034 | } | 5096 | } |
5035 | 5097 | ||
5036 | /* This is the 'fast' part of urgent handling. */ | 5098 | /* This is the 'fast' part of urgent handling. */ |
5037 | static void tcp_urg(struct sock *sk, struct sk_buff *skb, struct tcphdr *th) | 5099 | static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *th) |
5038 | { | 5100 | { |
5039 | struct tcp_sock *tp = tcp_sk(sk); | 5101 | struct tcp_sock *tp = tcp_sk(sk); |
5040 | 5102 | ||
@@ -5155,9 +5217,9 @@ out: | |||
5155 | * play significant role here. | 5217 | * play significant role here. |
5156 | */ | 5218 | */ |
5157 | static int tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, | 5219 | static int tcp_validate_incoming(struct sock *sk, struct sk_buff *skb, |
5158 | struct tcphdr *th, int syn_inerr) | 5220 | const struct tcphdr *th, int syn_inerr) |
5159 | { | 5221 | { |
5160 | u8 *hash_location; | 5222 | const u8 *hash_location; |
5161 | struct tcp_sock *tp = tcp_sk(sk); | 5223 | struct tcp_sock *tp = tcp_sk(sk); |
5162 | 5224 | ||
5163 | /* RFC1323: H1. Apply PAWS check first. */ | 5225 | /* RFC1323: H1. Apply PAWS check first. */ |
@@ -5238,7 +5300,7 @@ discard: | |||
5238 | * tcp_data_queue when everything is OK. | 5300 | * tcp_data_queue when everything is OK. |
5239 | */ | 5301 | */ |
5240 | int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | 5302 | int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, |
5241 | struct tcphdr *th, unsigned len) | 5303 | const struct tcphdr *th, unsigned int len) |
5242 | { | 5304 | { |
5243 | struct tcp_sock *tp = tcp_sk(sk); | 5305 | struct tcp_sock *tp = tcp_sk(sk); |
5244 | int res; | 5306 | int res; |
@@ -5449,9 +5511,9 @@ discard: | |||
5449 | EXPORT_SYMBOL(tcp_rcv_established); | 5511 | EXPORT_SYMBOL(tcp_rcv_established); |
5450 | 5512 | ||
5451 | static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, | 5513 | static int tcp_rcv_synsent_state_process(struct sock *sk, struct sk_buff *skb, |
5452 | struct tcphdr *th, unsigned len) | 5514 | const struct tcphdr *th, unsigned int len) |
5453 | { | 5515 | { |
5454 | u8 *hash_location; | 5516 | const u8 *hash_location; |
5455 | struct inet_connection_sock *icsk = inet_csk(sk); | 5517 | struct inet_connection_sock *icsk = inet_csk(sk); |
5456 | struct tcp_sock *tp = tcp_sk(sk); | 5518 | struct tcp_sock *tp = tcp_sk(sk); |
5457 | struct tcp_cookie_values *cvp = tp->cookie_values; | 5519 | struct tcp_cookie_values *cvp = tp->cookie_values; |
@@ -5726,7 +5788,7 @@ reset_and_undo: | |||
5726 | */ | 5788 | */ |
5727 | 5789 | ||
5728 | int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, | 5790 | int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb, |
5729 | struct tcphdr *th, unsigned len) | 5791 | const struct tcphdr *th, unsigned int len) |
5730 | { | 5792 | { |
5731 | struct tcp_sock *tp = tcp_sk(sk); | 5793 | struct tcp_sock *tp = tcp_sk(sk); |
5732 | struct inet_connection_sock *icsk = inet_csk(sk); | 5794 | struct inet_connection_sock *icsk = inet_csk(sk); |
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 7963e03f1068..0ea10eefa60f 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c | |||
@@ -92,7 +92,7 @@ EXPORT_SYMBOL(sysctl_tcp_low_latency); | |||
92 | static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, | 92 | static struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, |
93 | __be32 addr); | 93 | __be32 addr); |
94 | static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, | 94 | static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, |
95 | __be32 daddr, __be32 saddr, struct tcphdr *th); | 95 | __be32 daddr, __be32 saddr, const struct tcphdr *th); |
96 | #else | 96 | #else |
97 | static inline | 97 | static inline |
98 | struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) | 98 | struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) |
@@ -104,7 +104,7 @@ struct tcp_md5sig_key *tcp_v4_md5_do_lookup(struct sock *sk, __be32 addr) | |||
104 | struct inet_hashinfo tcp_hashinfo; | 104 | struct inet_hashinfo tcp_hashinfo; |
105 | EXPORT_SYMBOL(tcp_hashinfo); | 105 | EXPORT_SYMBOL(tcp_hashinfo); |
106 | 106 | ||
107 | static inline __u32 tcp_v4_init_sequence(struct sk_buff *skb) | 107 | static inline __u32 tcp_v4_init_sequence(const struct sk_buff *skb) |
108 | { | 108 | { |
109 | return secure_tcp_sequence_number(ip_hdr(skb)->daddr, | 109 | return secure_tcp_sequence_number(ip_hdr(skb)->daddr, |
110 | ip_hdr(skb)->saddr, | 110 | ip_hdr(skb)->saddr, |
@@ -552,7 +552,7 @@ static void __tcp_v4_send_check(struct sk_buff *skb, | |||
552 | /* This routine computes an IPv4 TCP checksum. */ | 552 | /* This routine computes an IPv4 TCP checksum. */ |
553 | void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb) | 553 | void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb) |
554 | { | 554 | { |
555 | struct inet_sock *inet = inet_sk(sk); | 555 | const struct inet_sock *inet = inet_sk(sk); |
556 | 556 | ||
557 | __tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr); | 557 | __tcp_v4_send_check(skb, inet->inet_saddr, inet->inet_daddr); |
558 | } | 558 | } |
@@ -590,7 +590,7 @@ int tcp_v4_gso_send_check(struct sk_buff *skb) | |||
590 | 590 | ||
591 | static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) | 591 | static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) |
592 | { | 592 | { |
593 | struct tcphdr *th = tcp_hdr(skb); | 593 | const struct tcphdr *th = tcp_hdr(skb); |
594 | struct { | 594 | struct { |
595 | struct tcphdr th; | 595 | struct tcphdr th; |
596 | #ifdef CONFIG_TCP_MD5SIG | 596 | #ifdef CONFIG_TCP_MD5SIG |
@@ -652,6 +652,7 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) | |||
652 | arg.flags = (sk && inet_sk(sk)->transparent) ? IP_REPLY_ARG_NOSRCCHECK : 0; | 652 | arg.flags = (sk && inet_sk(sk)->transparent) ? IP_REPLY_ARG_NOSRCCHECK : 0; |
653 | 653 | ||
654 | net = dev_net(skb_dst(skb)->dev); | 654 | net = dev_net(skb_dst(skb)->dev); |
655 | arg.tos = ip_hdr(skb)->tos; | ||
655 | ip_send_reply(net->ipv4.tcp_sock, skb, ip_hdr(skb)->saddr, | 656 | ip_send_reply(net->ipv4.tcp_sock, skb, ip_hdr(skb)->saddr, |
656 | &arg, arg.iov[0].iov_len); | 657 | &arg, arg.iov[0].iov_len); |
657 | 658 | ||
@@ -666,9 +667,9 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb) | |||
666 | static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, | 667 | static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, |
667 | u32 win, u32 ts, int oif, | 668 | u32 win, u32 ts, int oif, |
668 | struct tcp_md5sig_key *key, | 669 | struct tcp_md5sig_key *key, |
669 | int reply_flags) | 670 | int reply_flags, u8 tos) |
670 | { | 671 | { |
671 | struct tcphdr *th = tcp_hdr(skb); | 672 | const struct tcphdr *th = tcp_hdr(skb); |
672 | struct { | 673 | struct { |
673 | struct tcphdr th; | 674 | struct tcphdr th; |
674 | __be32 opt[(TCPOLEN_TSTAMP_ALIGNED >> 2) | 675 | __be32 opt[(TCPOLEN_TSTAMP_ALIGNED >> 2) |
@@ -726,7 +727,7 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack, | |||
726 | arg.csumoffset = offsetof(struct tcphdr, check) / 2; | 727 | arg.csumoffset = offsetof(struct tcphdr, check) / 2; |
727 | if (oif) | 728 | if (oif) |
728 | arg.bound_dev_if = oif; | 729 | arg.bound_dev_if = oif; |
729 | 730 | arg.tos = tos; | |
730 | ip_send_reply(net->ipv4.tcp_sock, skb, ip_hdr(skb)->saddr, | 731 | ip_send_reply(net->ipv4.tcp_sock, skb, ip_hdr(skb)->saddr, |
731 | &arg, arg.iov[0].iov_len); | 732 | &arg, arg.iov[0].iov_len); |
732 | 733 | ||
@@ -743,7 +744,8 @@ static void tcp_v4_timewait_ack(struct sock *sk, struct sk_buff *skb) | |||
743 | tcptw->tw_ts_recent, | 744 | tcptw->tw_ts_recent, |
744 | tw->tw_bound_dev_if, | 745 | tw->tw_bound_dev_if, |
745 | tcp_twsk_md5_key(tcptw), | 746 | tcp_twsk_md5_key(tcptw), |
746 | tw->tw_transparent ? IP_REPLY_ARG_NOSRCCHECK : 0 | 747 | tw->tw_transparent ? IP_REPLY_ARG_NOSRCCHECK : 0, |
748 | tw->tw_tos | ||
747 | ); | 749 | ); |
748 | 750 | ||
749 | inet_twsk_put(tw); | 751 | inet_twsk_put(tw); |
@@ -757,7 +759,8 @@ static void tcp_v4_reqsk_send_ack(struct sock *sk, struct sk_buff *skb, | |||
757 | req->ts_recent, | 759 | req->ts_recent, |
758 | 0, | 760 | 0, |
759 | tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr), | 761 | tcp_v4_md5_do_lookup(sk, ip_hdr(skb)->daddr), |
760 | inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0); | 762 | inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, |
763 | ip_hdr(skb)->tos); | ||
761 | } | 764 | } |
762 | 765 | ||
763 | /* | 766 | /* |
@@ -1090,7 +1093,7 @@ static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, | |||
1090 | } | 1093 | } |
1091 | 1094 | ||
1092 | static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, | 1095 | static int tcp_v4_md5_hash_hdr(char *md5_hash, struct tcp_md5sig_key *key, |
1093 | __be32 daddr, __be32 saddr, struct tcphdr *th) | 1096 | __be32 daddr, __be32 saddr, const struct tcphdr *th) |
1094 | { | 1097 | { |
1095 | struct tcp_md5sig_pool *hp; | 1098 | struct tcp_md5sig_pool *hp; |
1096 | struct hash_desc *desc; | 1099 | struct hash_desc *desc; |
@@ -1122,12 +1125,12 @@ clear_hash_noput: | |||
1122 | } | 1125 | } |
1123 | 1126 | ||
1124 | int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, | 1127 | int tcp_v4_md5_hash_skb(char *md5_hash, struct tcp_md5sig_key *key, |
1125 | struct sock *sk, struct request_sock *req, | 1128 | const struct sock *sk, const struct request_sock *req, |
1126 | struct sk_buff *skb) | 1129 | const struct sk_buff *skb) |
1127 | { | 1130 | { |
1128 | struct tcp_md5sig_pool *hp; | 1131 | struct tcp_md5sig_pool *hp; |
1129 | struct hash_desc *desc; | 1132 | struct hash_desc *desc; |
1130 | struct tcphdr *th = tcp_hdr(skb); | 1133 | const struct tcphdr *th = tcp_hdr(skb); |
1131 | __be32 saddr, daddr; | 1134 | __be32 saddr, daddr; |
1132 | 1135 | ||
1133 | if (sk) { | 1136 | if (sk) { |
@@ -1172,7 +1175,7 @@ clear_hash_noput: | |||
1172 | } | 1175 | } |
1173 | EXPORT_SYMBOL(tcp_v4_md5_hash_skb); | 1176 | EXPORT_SYMBOL(tcp_v4_md5_hash_skb); |
1174 | 1177 | ||
1175 | static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb) | 1178 | static int tcp_v4_inbound_md5_hash(struct sock *sk, const struct sk_buff *skb) |
1176 | { | 1179 | { |
1177 | /* | 1180 | /* |
1178 | * This gets called for each TCP segment that arrives | 1181 | * This gets called for each TCP segment that arrives |
@@ -1182,10 +1185,10 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb) | |||
1182 | * o MD5 hash and we're not expecting one. | 1185 | * o MD5 hash and we're not expecting one. |
1183 | * o MD5 hash and its wrong. | 1186 | * o MD5 hash and its wrong. |
1184 | */ | 1187 | */ |
1185 | __u8 *hash_location = NULL; | 1188 | const __u8 *hash_location = NULL; |
1186 | struct tcp_md5sig_key *hash_expected; | 1189 | struct tcp_md5sig_key *hash_expected; |
1187 | const struct iphdr *iph = ip_hdr(skb); | 1190 | const struct iphdr *iph = ip_hdr(skb); |
1188 | struct tcphdr *th = tcp_hdr(skb); | 1191 | const struct tcphdr *th = tcp_hdr(skb); |
1189 | int genhash; | 1192 | int genhash; |
1190 | unsigned char newhash[16]; | 1193 | unsigned char newhash[16]; |
1191 | 1194 | ||
@@ -1248,7 +1251,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
1248 | { | 1251 | { |
1249 | struct tcp_extend_values tmp_ext; | 1252 | struct tcp_extend_values tmp_ext; |
1250 | struct tcp_options_received tmp_opt; | 1253 | struct tcp_options_received tmp_opt; |
1251 | u8 *hash_location; | 1254 | const u8 *hash_location; |
1252 | struct request_sock *req; | 1255 | struct request_sock *req; |
1253 | struct inet_request_sock *ireq; | 1256 | struct inet_request_sock *ireq; |
1254 | struct tcp_sock *tp = tcp_sk(sk); | 1257 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -1588,7 +1591,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
1588 | #endif | 1591 | #endif |
1589 | 1592 | ||
1590 | if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ | 1593 | if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ |
1591 | sock_rps_save_rxhash(sk, skb->rxhash); | 1594 | sock_rps_save_rxhash(sk, skb); |
1592 | if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len)) { | 1595 | if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len)) { |
1593 | rsk = sk; | 1596 | rsk = sk; |
1594 | goto reset; | 1597 | goto reset; |
@@ -1605,7 +1608,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
1605 | goto discard; | 1608 | goto discard; |
1606 | 1609 | ||
1607 | if (nsk != sk) { | 1610 | if (nsk != sk) { |
1608 | sock_rps_save_rxhash(nsk, skb->rxhash); | 1611 | sock_rps_save_rxhash(nsk, skb); |
1609 | if (tcp_child_process(sk, nsk, skb)) { | 1612 | if (tcp_child_process(sk, nsk, skb)) { |
1610 | rsk = nsk; | 1613 | rsk = nsk; |
1611 | goto reset; | 1614 | goto reset; |
@@ -1613,7 +1616,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
1613 | return 0; | 1616 | return 0; |
1614 | } | 1617 | } |
1615 | } else | 1618 | } else |
1616 | sock_rps_save_rxhash(sk, skb->rxhash); | 1619 | sock_rps_save_rxhash(sk, skb); |
1617 | 1620 | ||
1618 | if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len)) { | 1621 | if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len)) { |
1619 | rsk = sk; | 1622 | rsk = sk; |
@@ -1645,7 +1648,7 @@ EXPORT_SYMBOL(tcp_v4_do_rcv); | |||
1645 | int tcp_v4_rcv(struct sk_buff *skb) | 1648 | int tcp_v4_rcv(struct sk_buff *skb) |
1646 | { | 1649 | { |
1647 | const struct iphdr *iph; | 1650 | const struct iphdr *iph; |
1648 | struct tcphdr *th; | 1651 | const struct tcphdr *th; |
1649 | struct sock *sk; | 1652 | struct sock *sk; |
1650 | int ret; | 1653 | int ret; |
1651 | struct net *net = dev_net(skb->dev); | 1654 | struct net *net = dev_net(skb->dev); |
@@ -1680,7 +1683,7 @@ int tcp_v4_rcv(struct sk_buff *skb) | |||
1680 | skb->len - th->doff * 4); | 1683 | skb->len - th->doff * 4); |
1681 | TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); | 1684 | TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); |
1682 | TCP_SKB_CB(skb)->when = 0; | 1685 | TCP_SKB_CB(skb)->when = 0; |
1683 | TCP_SKB_CB(skb)->flags = iph->tos; | 1686 | TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph); |
1684 | TCP_SKB_CB(skb)->sacked = 0; | 1687 | TCP_SKB_CB(skb)->sacked = 0; |
1685 | 1688 | ||
1686 | sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest); | 1689 | sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest); |
@@ -1809,7 +1812,7 @@ EXPORT_SYMBOL(tcp_v4_get_peer); | |||
1809 | 1812 | ||
1810 | void *tcp_v4_tw_get_peer(struct sock *sk) | 1813 | void *tcp_v4_tw_get_peer(struct sock *sk) |
1811 | { | 1814 | { |
1812 | struct inet_timewait_sock *tw = inet_twsk(sk); | 1815 | const struct inet_timewait_sock *tw = inet_twsk(sk); |
1813 | 1816 | ||
1814 | return inet_getpeer_v4(tw->tw_daddr, 1); | 1817 | return inet_getpeer_v4(tw->tw_daddr, 1); |
1815 | } | 1818 | } |
@@ -2381,7 +2384,7 @@ void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo) | |||
2381 | } | 2384 | } |
2382 | EXPORT_SYMBOL(tcp_proc_unregister); | 2385 | EXPORT_SYMBOL(tcp_proc_unregister); |
2383 | 2386 | ||
2384 | static void get_openreq4(struct sock *sk, struct request_sock *req, | 2387 | static void get_openreq4(const struct sock *sk, const struct request_sock *req, |
2385 | struct seq_file *f, int i, int uid, int *len) | 2388 | struct seq_file *f, int i, int uid, int *len) |
2386 | { | 2389 | { |
2387 | const struct inet_request_sock *ireq = inet_rsk(req); | 2390 | const struct inet_request_sock *ireq = inet_rsk(req); |
@@ -2411,9 +2414,9 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len) | |||
2411 | { | 2414 | { |
2412 | int timer_active; | 2415 | int timer_active; |
2413 | unsigned long timer_expires; | 2416 | unsigned long timer_expires; |
2414 | struct tcp_sock *tp = tcp_sk(sk); | 2417 | const struct tcp_sock *tp = tcp_sk(sk); |
2415 | const struct inet_connection_sock *icsk = inet_csk(sk); | 2418 | const struct inet_connection_sock *icsk = inet_csk(sk); |
2416 | struct inet_sock *inet = inet_sk(sk); | 2419 | const struct inet_sock *inet = inet_sk(sk); |
2417 | __be32 dest = inet->inet_daddr; | 2420 | __be32 dest = inet->inet_daddr; |
2418 | __be32 src = inet->inet_rcv_saddr; | 2421 | __be32 src = inet->inet_rcv_saddr; |
2419 | __u16 destp = ntohs(inet->inet_dport); | 2422 | __u16 destp = ntohs(inet->inet_dport); |
@@ -2462,7 +2465,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len) | |||
2462 | len); | 2465 | len); |
2463 | } | 2466 | } |
2464 | 2467 | ||
2465 | static void get_timewait4_sock(struct inet_timewait_sock *tw, | 2468 | static void get_timewait4_sock(const struct inet_timewait_sock *tw, |
2466 | struct seq_file *f, int i, int *len) | 2469 | struct seq_file *f, int i, int *len) |
2467 | { | 2470 | { |
2468 | __be32 dest, src; | 2471 | __be32 dest, src; |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index 0ce3d06dce60..85a2fbebd7ef 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -141,7 +141,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb, | |||
141 | const struct tcphdr *th) | 141 | const struct tcphdr *th) |
142 | { | 142 | { |
143 | struct tcp_options_received tmp_opt; | 143 | struct tcp_options_received tmp_opt; |
144 | u8 *hash_location; | 144 | const u8 *hash_location; |
145 | struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); | 145 | struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); |
146 | int paws_reject = 0; | 146 | int paws_reject = 0; |
147 | 147 | ||
@@ -567,7 +567,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, | |||
567 | struct request_sock **prev) | 567 | struct request_sock **prev) |
568 | { | 568 | { |
569 | struct tcp_options_received tmp_opt; | 569 | struct tcp_options_received tmp_opt; |
570 | u8 *hash_location; | 570 | const u8 *hash_location; |
571 | struct sock *child; | 571 | struct sock *child; |
572 | const struct tcphdr *th = tcp_hdr(skb); | 572 | const struct tcphdr *th = tcp_hdr(skb); |
573 | __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); | 573 | __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index 882e0b0964d0..980b98f6288c 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
@@ -65,7 +65,7 @@ EXPORT_SYMBOL_GPL(sysctl_tcp_cookie_size); | |||
65 | 65 | ||
66 | 66 | ||
67 | /* Account for new data that has been sent to the network. */ | 67 | /* Account for new data that has been sent to the network. */ |
68 | static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb) | 68 | static void tcp_event_new_data_sent(struct sock *sk, const struct sk_buff *skb) |
69 | { | 69 | { |
70 | struct tcp_sock *tp = tcp_sk(sk); | 70 | struct tcp_sock *tp = tcp_sk(sk); |
71 | unsigned int prior_packets = tp->packets_out; | 71 | unsigned int prior_packets = tp->packets_out; |
@@ -89,9 +89,9 @@ static void tcp_event_new_data_sent(struct sock *sk, struct sk_buff *skb) | |||
89 | * Anything in between SND.UNA...SND.UNA+SND.WND also can be already | 89 | * Anything in between SND.UNA...SND.UNA+SND.WND also can be already |
90 | * invalid. OK, let's make this for now: | 90 | * invalid. OK, let's make this for now: |
91 | */ | 91 | */ |
92 | static inline __u32 tcp_acceptable_seq(struct sock *sk) | 92 | static inline __u32 tcp_acceptable_seq(const struct sock *sk) |
93 | { | 93 | { |
94 | struct tcp_sock *tp = tcp_sk(sk); | 94 | const struct tcp_sock *tp = tcp_sk(sk); |
95 | 95 | ||
96 | if (!before(tcp_wnd_end(tp), tp->snd_nxt)) | 96 | if (!before(tcp_wnd_end(tp), tp->snd_nxt)) |
97 | return tp->snd_nxt; | 97 | return tp->snd_nxt; |
@@ -116,7 +116,7 @@ static inline __u32 tcp_acceptable_seq(struct sock *sk) | |||
116 | static __u16 tcp_advertise_mss(struct sock *sk) | 116 | static __u16 tcp_advertise_mss(struct sock *sk) |
117 | { | 117 | { |
118 | struct tcp_sock *tp = tcp_sk(sk); | 118 | struct tcp_sock *tp = tcp_sk(sk); |
119 | struct dst_entry *dst = __sk_dst_get(sk); | 119 | const struct dst_entry *dst = __sk_dst_get(sk); |
120 | int mss = tp->advmss; | 120 | int mss = tp->advmss; |
121 | 121 | ||
122 | if (dst) { | 122 | if (dst) { |
@@ -133,7 +133,7 @@ static __u16 tcp_advertise_mss(struct sock *sk) | |||
133 | 133 | ||
134 | /* RFC2861. Reset CWND after idle period longer RTO to "restart window". | 134 | /* RFC2861. Reset CWND after idle period longer RTO to "restart window". |
135 | * This is the first part of cwnd validation mechanism. */ | 135 | * This is the first part of cwnd validation mechanism. */ |
136 | static void tcp_cwnd_restart(struct sock *sk, struct dst_entry *dst) | 136 | static void tcp_cwnd_restart(struct sock *sk, const struct dst_entry *dst) |
137 | { | 137 | { |
138 | struct tcp_sock *tp = tcp_sk(sk); | 138 | struct tcp_sock *tp = tcp_sk(sk); |
139 | s32 delta = tcp_time_stamp - tp->lsndtime; | 139 | s32 delta = tcp_time_stamp - tp->lsndtime; |
@@ -154,7 +154,7 @@ static void tcp_cwnd_restart(struct sock *sk, struct dst_entry *dst) | |||
154 | 154 | ||
155 | /* Congestion state accounting after a packet has been sent. */ | 155 | /* Congestion state accounting after a packet has been sent. */ |
156 | static void tcp_event_data_sent(struct tcp_sock *tp, | 156 | static void tcp_event_data_sent(struct tcp_sock *tp, |
157 | struct sk_buff *skb, struct sock *sk) | 157 | struct sock *sk) |
158 | { | 158 | { |
159 | struct inet_connection_sock *icsk = inet_csk(sk); | 159 | struct inet_connection_sock *icsk = inet_csk(sk); |
160 | const u32 now = tcp_time_stamp; | 160 | const u32 now = tcp_time_stamp; |
@@ -295,11 +295,11 @@ static u16 tcp_select_window(struct sock *sk) | |||
295 | } | 295 | } |
296 | 296 | ||
297 | /* Packet ECN state for a SYN-ACK */ | 297 | /* Packet ECN state for a SYN-ACK */ |
298 | static inline void TCP_ECN_send_synack(struct tcp_sock *tp, struct sk_buff *skb) | 298 | static inline void TCP_ECN_send_synack(const struct tcp_sock *tp, struct sk_buff *skb) |
299 | { | 299 | { |
300 | TCP_SKB_CB(skb)->flags &= ~TCPHDR_CWR; | 300 | TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_CWR; |
301 | if (!(tp->ecn_flags & TCP_ECN_OK)) | 301 | if (!(tp->ecn_flags & TCP_ECN_OK)) |
302 | TCP_SKB_CB(skb)->flags &= ~TCPHDR_ECE; | 302 | TCP_SKB_CB(skb)->tcp_flags &= ~TCPHDR_ECE; |
303 | } | 303 | } |
304 | 304 | ||
305 | /* Packet ECN state for a SYN. */ | 305 | /* Packet ECN state for a SYN. */ |
@@ -309,13 +309,13 @@ static inline void TCP_ECN_send_syn(struct sock *sk, struct sk_buff *skb) | |||
309 | 309 | ||
310 | tp->ecn_flags = 0; | 310 | tp->ecn_flags = 0; |
311 | if (sysctl_tcp_ecn == 1) { | 311 | if (sysctl_tcp_ecn == 1) { |
312 | TCP_SKB_CB(skb)->flags |= TCPHDR_ECE | TCPHDR_CWR; | 312 | TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ECE | TCPHDR_CWR; |
313 | tp->ecn_flags = TCP_ECN_OK; | 313 | tp->ecn_flags = TCP_ECN_OK; |
314 | } | 314 | } |
315 | } | 315 | } |
316 | 316 | ||
317 | static __inline__ void | 317 | static __inline__ void |
318 | TCP_ECN_make_synack(struct request_sock *req, struct tcphdr *th) | 318 | TCP_ECN_make_synack(const struct request_sock *req, struct tcphdr *th) |
319 | { | 319 | { |
320 | if (inet_rsk(req)->ecn_ok) | 320 | if (inet_rsk(req)->ecn_ok) |
321 | th->ece = 1; | 321 | th->ece = 1; |
@@ -356,7 +356,7 @@ static void tcp_init_nondata_skb(struct sk_buff *skb, u32 seq, u8 flags) | |||
356 | skb->ip_summed = CHECKSUM_PARTIAL; | 356 | skb->ip_summed = CHECKSUM_PARTIAL; |
357 | skb->csum = 0; | 357 | skb->csum = 0; |
358 | 358 | ||
359 | TCP_SKB_CB(skb)->flags = flags; | 359 | TCP_SKB_CB(skb)->tcp_flags = flags; |
360 | TCP_SKB_CB(skb)->sacked = 0; | 360 | TCP_SKB_CB(skb)->sacked = 0; |
361 | 361 | ||
362 | skb_shinfo(skb)->gso_segs = 1; | 362 | skb_shinfo(skb)->gso_segs = 1; |
@@ -565,7 +565,8 @@ static void tcp_options_write(__be32 *ptr, struct tcp_sock *tp, | |||
565 | */ | 565 | */ |
566 | static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, | 566 | static unsigned tcp_syn_options(struct sock *sk, struct sk_buff *skb, |
567 | struct tcp_out_options *opts, | 567 | struct tcp_out_options *opts, |
568 | struct tcp_md5sig_key **md5) { | 568 | struct tcp_md5sig_key **md5) |
569 | { | ||
569 | struct tcp_sock *tp = tcp_sk(sk); | 570 | struct tcp_sock *tp = tcp_sk(sk); |
570 | struct tcp_cookie_values *cvp = tp->cookie_values; | 571 | struct tcp_cookie_values *cvp = tp->cookie_values; |
571 | unsigned remaining = MAX_TCP_OPTION_SPACE; | 572 | unsigned remaining = MAX_TCP_OPTION_SPACE; |
@@ -743,7 +744,8 @@ static unsigned tcp_synack_options(struct sock *sk, | |||
743 | */ | 744 | */ |
744 | static unsigned tcp_established_options(struct sock *sk, struct sk_buff *skb, | 745 | static unsigned tcp_established_options(struct sock *sk, struct sk_buff *skb, |
745 | struct tcp_out_options *opts, | 746 | struct tcp_out_options *opts, |
746 | struct tcp_md5sig_key **md5) { | 747 | struct tcp_md5sig_key **md5) |
748 | { | ||
747 | struct tcp_skb_cb *tcb = skb ? TCP_SKB_CB(skb) : NULL; | 749 | struct tcp_skb_cb *tcb = skb ? TCP_SKB_CB(skb) : NULL; |
748 | struct tcp_sock *tp = tcp_sk(sk); | 750 | struct tcp_sock *tp = tcp_sk(sk); |
749 | unsigned size = 0; | 751 | unsigned size = 0; |
@@ -826,7 +828,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, | |||
826 | tcb = TCP_SKB_CB(skb); | 828 | tcb = TCP_SKB_CB(skb); |
827 | memset(&opts, 0, sizeof(opts)); | 829 | memset(&opts, 0, sizeof(opts)); |
828 | 830 | ||
829 | if (unlikely(tcb->flags & TCPHDR_SYN)) | 831 | if (unlikely(tcb->tcp_flags & TCPHDR_SYN)) |
830 | tcp_options_size = tcp_syn_options(sk, skb, &opts, &md5); | 832 | tcp_options_size = tcp_syn_options(sk, skb, &opts, &md5); |
831 | else | 833 | else |
832 | tcp_options_size = tcp_established_options(sk, skb, &opts, | 834 | tcp_options_size = tcp_established_options(sk, skb, &opts, |
@@ -850,9 +852,9 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, | |||
850 | th->seq = htonl(tcb->seq); | 852 | th->seq = htonl(tcb->seq); |
851 | th->ack_seq = htonl(tp->rcv_nxt); | 853 | th->ack_seq = htonl(tp->rcv_nxt); |
852 | *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | | 854 | *(((__be16 *)th) + 6) = htons(((tcp_header_size >> 2) << 12) | |
853 | tcb->flags); | 855 | tcb->tcp_flags); |
854 | 856 | ||
855 | if (unlikely(tcb->flags & TCPHDR_SYN)) { | 857 | if (unlikely(tcb->tcp_flags & TCPHDR_SYN)) { |
856 | /* RFC1323: The window in SYN & SYN/ACK segments | 858 | /* RFC1323: The window in SYN & SYN/ACK segments |
857 | * is never scaled. | 859 | * is never scaled. |
858 | */ | 860 | */ |
@@ -875,7 +877,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, | |||
875 | } | 877 | } |
876 | 878 | ||
877 | tcp_options_write((__be32 *)(th + 1), tp, &opts); | 879 | tcp_options_write((__be32 *)(th + 1), tp, &opts); |
878 | if (likely((tcb->flags & TCPHDR_SYN) == 0)) | 880 | if (likely((tcb->tcp_flags & TCPHDR_SYN) == 0)) |
879 | TCP_ECN_send(sk, skb, tcp_header_size); | 881 | TCP_ECN_send(sk, skb, tcp_header_size); |
880 | 882 | ||
881 | #ifdef CONFIG_TCP_MD5SIG | 883 | #ifdef CONFIG_TCP_MD5SIG |
@@ -889,11 +891,11 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, | |||
889 | 891 | ||
890 | icsk->icsk_af_ops->send_check(sk, skb); | 892 | icsk->icsk_af_ops->send_check(sk, skb); |
891 | 893 | ||
892 | if (likely(tcb->flags & TCPHDR_ACK)) | 894 | if (likely(tcb->tcp_flags & TCPHDR_ACK)) |
893 | tcp_event_ack_sent(sk, tcp_skb_pcount(skb)); | 895 | tcp_event_ack_sent(sk, tcp_skb_pcount(skb)); |
894 | 896 | ||
895 | if (skb->len != tcp_header_size) | 897 | if (skb->len != tcp_header_size) |
896 | tcp_event_data_sent(tp, skb, sk); | 898 | tcp_event_data_sent(tp, sk); |
897 | 899 | ||
898 | if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq) | 900 | if (after(tcb->end_seq, tp->snd_nxt) || tcb->seq == tcb->end_seq) |
899 | TCP_ADD_STATS(sock_net(sk), TCP_MIB_OUTSEGS, | 901 | TCP_ADD_STATS(sock_net(sk), TCP_MIB_OUTSEGS, |
@@ -926,7 +928,7 @@ static void tcp_queue_skb(struct sock *sk, struct sk_buff *skb) | |||
926 | } | 928 | } |
927 | 929 | ||
928 | /* Initialize TSO segments for a packet. */ | 930 | /* Initialize TSO segments for a packet. */ |
929 | static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, | 931 | static void tcp_set_skb_tso_segs(const struct sock *sk, struct sk_buff *skb, |
930 | unsigned int mss_now) | 932 | unsigned int mss_now) |
931 | { | 933 | { |
932 | if (skb->len <= mss_now || !sk_can_gso(sk) || | 934 | if (skb->len <= mss_now || !sk_can_gso(sk) || |
@@ -947,7 +949,7 @@ static void tcp_set_skb_tso_segs(struct sock *sk, struct sk_buff *skb, | |||
947 | /* When a modification to fackets out becomes necessary, we need to check | 949 | /* When a modification to fackets out becomes necessary, we need to check |
948 | * skb is counted to fackets_out or not. | 950 | * skb is counted to fackets_out or not. |
949 | */ | 951 | */ |
950 | static void tcp_adjust_fackets_out(struct sock *sk, struct sk_buff *skb, | 952 | static void tcp_adjust_fackets_out(struct sock *sk, const struct sk_buff *skb, |
951 | int decr) | 953 | int decr) |
952 | { | 954 | { |
953 | struct tcp_sock *tp = tcp_sk(sk); | 955 | struct tcp_sock *tp = tcp_sk(sk); |
@@ -962,7 +964,7 @@ static void tcp_adjust_fackets_out(struct sock *sk, struct sk_buff *skb, | |||
962 | /* Pcount in the middle of the write queue got changed, we need to do various | 964 | /* Pcount in the middle of the write queue got changed, we need to do various |
963 | * tweaks to fix counters | 965 | * tweaks to fix counters |
964 | */ | 966 | */ |
965 | static void tcp_adjust_pcount(struct sock *sk, struct sk_buff *skb, int decr) | 967 | static void tcp_adjust_pcount(struct sock *sk, const struct sk_buff *skb, int decr) |
966 | { | 968 | { |
967 | struct tcp_sock *tp = tcp_sk(sk); | 969 | struct tcp_sock *tp = tcp_sk(sk); |
968 | 970 | ||
@@ -1032,9 +1034,9 @@ int tcp_fragment(struct sock *sk, struct sk_buff *skb, u32 len, | |||
1032 | TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq; | 1034 | TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq; |
1033 | 1035 | ||
1034 | /* PSH and FIN should only be set in the second packet. */ | 1036 | /* PSH and FIN should only be set in the second packet. */ |
1035 | flags = TCP_SKB_CB(skb)->flags; | 1037 | flags = TCP_SKB_CB(skb)->tcp_flags; |
1036 | TCP_SKB_CB(skb)->flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH); | 1038 | TCP_SKB_CB(skb)->tcp_flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH); |
1037 | TCP_SKB_CB(buff)->flags = flags; | 1039 | TCP_SKB_CB(buff)->tcp_flags = flags; |
1038 | TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked; | 1040 | TCP_SKB_CB(buff)->sacked = TCP_SKB_CB(skb)->sacked; |
1039 | 1041 | ||
1040 | if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_PARTIAL) { | 1042 | if (!skb_shinfo(skb)->nr_frags && skb->ip_summed != CHECKSUM_PARTIAL) { |
@@ -1094,14 +1096,16 @@ static void __pskb_trim_head(struct sk_buff *skb, int len) | |||
1094 | eat = len; | 1096 | eat = len; |
1095 | k = 0; | 1097 | k = 0; |
1096 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { | 1098 | for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { |
1097 | if (skb_shinfo(skb)->frags[i].size <= eat) { | 1099 | int size = skb_frag_size(&skb_shinfo(skb)->frags[i]); |
1098 | put_page(skb_shinfo(skb)->frags[i].page); | 1100 | |
1099 | eat -= skb_shinfo(skb)->frags[i].size; | 1101 | if (size <= eat) { |
1102 | skb_frag_unref(skb, i); | ||
1103 | eat -= size; | ||
1100 | } else { | 1104 | } else { |
1101 | skb_shinfo(skb)->frags[k] = skb_shinfo(skb)->frags[i]; | 1105 | skb_shinfo(skb)->frags[k] = skb_shinfo(skb)->frags[i]; |
1102 | if (eat) { | 1106 | if (eat) { |
1103 | skb_shinfo(skb)->frags[k].page_offset += eat; | 1107 | skb_shinfo(skb)->frags[k].page_offset += eat; |
1104 | skb_shinfo(skb)->frags[k].size -= eat; | 1108 | skb_frag_size_sub(&skb_shinfo(skb)->frags[k], eat); |
1105 | eat = 0; | 1109 | eat = 0; |
1106 | } | 1110 | } |
1107 | k++; | 1111 | k++; |
@@ -1144,10 +1148,10 @@ int tcp_trim_head(struct sock *sk, struct sk_buff *skb, u32 len) | |||
1144 | } | 1148 | } |
1145 | 1149 | ||
1146 | /* Calculate MSS. Not accounting for SACKs here. */ | 1150 | /* Calculate MSS. Not accounting for SACKs here. */ |
1147 | int tcp_mtu_to_mss(struct sock *sk, int pmtu) | 1151 | int tcp_mtu_to_mss(const struct sock *sk, int pmtu) |
1148 | { | 1152 | { |
1149 | struct tcp_sock *tp = tcp_sk(sk); | 1153 | const struct tcp_sock *tp = tcp_sk(sk); |
1150 | struct inet_connection_sock *icsk = inet_csk(sk); | 1154 | const struct inet_connection_sock *icsk = inet_csk(sk); |
1151 | int mss_now; | 1155 | int mss_now; |
1152 | 1156 | ||
1153 | /* Calculate base mss without TCP options: | 1157 | /* Calculate base mss without TCP options: |
@@ -1173,10 +1177,10 @@ int tcp_mtu_to_mss(struct sock *sk, int pmtu) | |||
1173 | } | 1177 | } |
1174 | 1178 | ||
1175 | /* Inverse of above */ | 1179 | /* Inverse of above */ |
1176 | int tcp_mss_to_mtu(struct sock *sk, int mss) | 1180 | int tcp_mss_to_mtu(const struct sock *sk, int mss) |
1177 | { | 1181 | { |
1178 | struct tcp_sock *tp = tcp_sk(sk); | 1182 | const struct tcp_sock *tp = tcp_sk(sk); |
1179 | struct inet_connection_sock *icsk = inet_csk(sk); | 1183 | const struct inet_connection_sock *icsk = inet_csk(sk); |
1180 | int mtu; | 1184 | int mtu; |
1181 | 1185 | ||
1182 | mtu = mss + | 1186 | mtu = mss + |
@@ -1250,8 +1254,8 @@ EXPORT_SYMBOL(tcp_sync_mss); | |||
1250 | */ | 1254 | */ |
1251 | unsigned int tcp_current_mss(struct sock *sk) | 1255 | unsigned int tcp_current_mss(struct sock *sk) |
1252 | { | 1256 | { |
1253 | struct tcp_sock *tp = tcp_sk(sk); | 1257 | const struct tcp_sock *tp = tcp_sk(sk); |
1254 | struct dst_entry *dst = __sk_dst_get(sk); | 1258 | const struct dst_entry *dst = __sk_dst_get(sk); |
1255 | u32 mss_now; | 1259 | u32 mss_now; |
1256 | unsigned header_len; | 1260 | unsigned header_len; |
1257 | struct tcp_out_options opts; | 1261 | struct tcp_out_options opts; |
@@ -1311,10 +1315,10 @@ static void tcp_cwnd_validate(struct sock *sk) | |||
1311 | * modulo only when the receiver window alone is the limiting factor or | 1315 | * modulo only when the receiver window alone is the limiting factor or |
1312 | * when we would be allowed to send the split-due-to-Nagle skb fully. | 1316 | * when we would be allowed to send the split-due-to-Nagle skb fully. |
1313 | */ | 1317 | */ |
1314 | static unsigned int tcp_mss_split_point(struct sock *sk, struct sk_buff *skb, | 1318 | static unsigned int tcp_mss_split_point(const struct sock *sk, const struct sk_buff *skb, |
1315 | unsigned int mss_now, unsigned int cwnd) | 1319 | unsigned int mss_now, unsigned int cwnd) |
1316 | { | 1320 | { |
1317 | struct tcp_sock *tp = tcp_sk(sk); | 1321 | const struct tcp_sock *tp = tcp_sk(sk); |
1318 | u32 needed, window, cwnd_len; | 1322 | u32 needed, window, cwnd_len; |
1319 | 1323 | ||
1320 | window = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; | 1324 | window = tcp_wnd_end(tp) - TCP_SKB_CB(skb)->seq; |
@@ -1334,13 +1338,14 @@ static unsigned int tcp_mss_split_point(struct sock *sk, struct sk_buff *skb, | |||
1334 | /* Can at least one segment of SKB be sent right now, according to the | 1338 | /* Can at least one segment of SKB be sent right now, according to the |
1335 | * congestion window rules? If so, return how many segments are allowed. | 1339 | * congestion window rules? If so, return how many segments are allowed. |
1336 | */ | 1340 | */ |
1337 | static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, | 1341 | static inline unsigned int tcp_cwnd_test(const struct tcp_sock *tp, |
1338 | struct sk_buff *skb) | 1342 | const struct sk_buff *skb) |
1339 | { | 1343 | { |
1340 | u32 in_flight, cwnd; | 1344 | u32 in_flight, cwnd; |
1341 | 1345 | ||
1342 | /* Don't be strict about the congestion window for the final FIN. */ | 1346 | /* Don't be strict about the congestion window for the final FIN. */ |
1343 | if ((TCP_SKB_CB(skb)->flags & TCPHDR_FIN) && tcp_skb_pcount(skb) == 1) | 1347 | if ((TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) && |
1348 | tcp_skb_pcount(skb) == 1) | ||
1344 | return 1; | 1349 | return 1; |
1345 | 1350 | ||
1346 | in_flight = tcp_packets_in_flight(tp); | 1351 | in_flight = tcp_packets_in_flight(tp); |
@@ -1355,7 +1360,7 @@ static inline unsigned int tcp_cwnd_test(struct tcp_sock *tp, | |||
1355 | * This must be invoked the first time we consider transmitting | 1360 | * This must be invoked the first time we consider transmitting |
1356 | * SKB onto the wire. | 1361 | * SKB onto the wire. |
1357 | */ | 1362 | */ |
1358 | static int tcp_init_tso_segs(struct sock *sk, struct sk_buff *skb, | 1363 | static int tcp_init_tso_segs(const struct sock *sk, struct sk_buff *skb, |
1359 | unsigned int mss_now) | 1364 | unsigned int mss_now) |
1360 | { | 1365 | { |
1361 | int tso_segs = tcp_skb_pcount(skb); | 1366 | int tso_segs = tcp_skb_pcount(skb); |
@@ -1393,7 +1398,7 @@ static inline int tcp_nagle_check(const struct tcp_sock *tp, | |||
1393 | /* Return non-zero if the Nagle test allows this packet to be | 1398 | /* Return non-zero if the Nagle test allows this packet to be |
1394 | * sent now. | 1399 | * sent now. |
1395 | */ | 1400 | */ |
1396 | static inline int tcp_nagle_test(struct tcp_sock *tp, struct sk_buff *skb, | 1401 | static inline int tcp_nagle_test(const struct tcp_sock *tp, const struct sk_buff *skb, |
1397 | unsigned int cur_mss, int nonagle) | 1402 | unsigned int cur_mss, int nonagle) |
1398 | { | 1403 | { |
1399 | /* Nagle rule does not apply to frames, which sit in the middle of the | 1404 | /* Nagle rule does not apply to frames, which sit in the middle of the |
@@ -1409,7 +1414,7 @@ static inline int tcp_nagle_test(struct tcp_sock *tp, struct sk_buff *skb, | |||
1409 | * Nagle can be ignored during F-RTO too (see RFC4138). | 1414 | * Nagle can be ignored during F-RTO too (see RFC4138). |
1410 | */ | 1415 | */ |
1411 | if (tcp_urg_mode(tp) || (tp->frto_counter == 2) || | 1416 | if (tcp_urg_mode(tp) || (tp->frto_counter == 2) || |
1412 | (TCP_SKB_CB(skb)->flags & TCPHDR_FIN)) | 1417 | (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)) |
1413 | return 1; | 1418 | return 1; |
1414 | 1419 | ||
1415 | if (!tcp_nagle_check(tp, skb, cur_mss, nonagle)) | 1420 | if (!tcp_nagle_check(tp, skb, cur_mss, nonagle)) |
@@ -1419,7 +1424,7 @@ static inline int tcp_nagle_test(struct tcp_sock *tp, struct sk_buff *skb, | |||
1419 | } | 1424 | } |
1420 | 1425 | ||
1421 | /* Does at least the first segment of SKB fit into the send window? */ | 1426 | /* Does at least the first segment of SKB fit into the send window? */ |
1422 | static inline int tcp_snd_wnd_test(struct tcp_sock *tp, struct sk_buff *skb, | 1427 | static inline int tcp_snd_wnd_test(const struct tcp_sock *tp, const struct sk_buff *skb, |
1423 | unsigned int cur_mss) | 1428 | unsigned int cur_mss) |
1424 | { | 1429 | { |
1425 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; | 1430 | u32 end_seq = TCP_SKB_CB(skb)->end_seq; |
@@ -1434,10 +1439,10 @@ static inline int tcp_snd_wnd_test(struct tcp_sock *tp, struct sk_buff *skb, | |||
1434 | * should be put on the wire right now. If so, it returns the number of | 1439 | * should be put on the wire right now. If so, it returns the number of |
1435 | * packets allowed by the congestion window. | 1440 | * packets allowed by the congestion window. |
1436 | */ | 1441 | */ |
1437 | static unsigned int tcp_snd_test(struct sock *sk, struct sk_buff *skb, | 1442 | static unsigned int tcp_snd_test(const struct sock *sk, struct sk_buff *skb, |
1438 | unsigned int cur_mss, int nonagle) | 1443 | unsigned int cur_mss, int nonagle) |
1439 | { | 1444 | { |
1440 | struct tcp_sock *tp = tcp_sk(sk); | 1445 | const struct tcp_sock *tp = tcp_sk(sk); |
1441 | unsigned int cwnd_quota; | 1446 | unsigned int cwnd_quota; |
1442 | 1447 | ||
1443 | tcp_init_tso_segs(sk, skb, cur_mss); | 1448 | tcp_init_tso_segs(sk, skb, cur_mss); |
@@ -1455,7 +1460,7 @@ static unsigned int tcp_snd_test(struct sock *sk, struct sk_buff *skb, | |||
1455 | /* Test if sending is allowed right now. */ | 1460 | /* Test if sending is allowed right now. */ |
1456 | int tcp_may_send_now(struct sock *sk) | 1461 | int tcp_may_send_now(struct sock *sk) |
1457 | { | 1462 | { |
1458 | struct tcp_sock *tp = tcp_sk(sk); | 1463 | const struct tcp_sock *tp = tcp_sk(sk); |
1459 | struct sk_buff *skb = tcp_send_head(sk); | 1464 | struct sk_buff *skb = tcp_send_head(sk); |
1460 | 1465 | ||
1461 | return skb && | 1466 | return skb && |
@@ -1497,9 +1502,9 @@ static int tso_fragment(struct sock *sk, struct sk_buff *skb, unsigned int len, | |||
1497 | TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq; | 1502 | TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(buff)->seq; |
1498 | 1503 | ||
1499 | /* PSH and FIN should only be set in the second packet. */ | 1504 | /* PSH and FIN should only be set in the second packet. */ |
1500 | flags = TCP_SKB_CB(skb)->flags; | 1505 | flags = TCP_SKB_CB(skb)->tcp_flags; |
1501 | TCP_SKB_CB(skb)->flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH); | 1506 | TCP_SKB_CB(skb)->tcp_flags = flags & ~(TCPHDR_FIN | TCPHDR_PSH); |
1502 | TCP_SKB_CB(buff)->flags = flags; | 1507 | TCP_SKB_CB(buff)->tcp_flags = flags; |
1503 | 1508 | ||
1504 | /* This packet was never sent out yet, so no SACK bits. */ | 1509 | /* This packet was never sent out yet, so no SACK bits. */ |
1505 | TCP_SKB_CB(buff)->sacked = 0; | 1510 | TCP_SKB_CB(buff)->sacked = 0; |
@@ -1530,7 +1535,7 @@ static int tcp_tso_should_defer(struct sock *sk, struct sk_buff *skb) | |||
1530 | u32 send_win, cong_win, limit, in_flight; | 1535 | u32 send_win, cong_win, limit, in_flight; |
1531 | int win_divisor; | 1536 | int win_divisor; |
1532 | 1537 | ||
1533 | if (TCP_SKB_CB(skb)->flags & TCPHDR_FIN) | 1538 | if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) |
1534 | goto send_now; | 1539 | goto send_now; |
1535 | 1540 | ||
1536 | if (icsk->icsk_ca_state != TCP_CA_Open) | 1541 | if (icsk->icsk_ca_state != TCP_CA_Open) |
@@ -1657,7 +1662,7 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1657 | 1662 | ||
1658 | TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq; | 1663 | TCP_SKB_CB(nskb)->seq = TCP_SKB_CB(skb)->seq; |
1659 | TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size; | 1664 | TCP_SKB_CB(nskb)->end_seq = TCP_SKB_CB(skb)->seq + probe_size; |
1660 | TCP_SKB_CB(nskb)->flags = TCPHDR_ACK; | 1665 | TCP_SKB_CB(nskb)->tcp_flags = TCPHDR_ACK; |
1661 | TCP_SKB_CB(nskb)->sacked = 0; | 1666 | TCP_SKB_CB(nskb)->sacked = 0; |
1662 | nskb->csum = 0; | 1667 | nskb->csum = 0; |
1663 | nskb->ip_summed = skb->ip_summed; | 1668 | nskb->ip_summed = skb->ip_summed; |
@@ -1677,11 +1682,11 @@ static int tcp_mtu_probe(struct sock *sk) | |||
1677 | if (skb->len <= copy) { | 1682 | if (skb->len <= copy) { |
1678 | /* We've eaten all the data from this skb. | 1683 | /* We've eaten all the data from this skb. |
1679 | * Throw it away. */ | 1684 | * Throw it away. */ |
1680 | TCP_SKB_CB(nskb)->flags |= TCP_SKB_CB(skb)->flags; | 1685 | TCP_SKB_CB(nskb)->tcp_flags |= TCP_SKB_CB(skb)->tcp_flags; |
1681 | tcp_unlink_write_queue(skb, sk); | 1686 | tcp_unlink_write_queue(skb, sk); |
1682 | sk_wmem_free_skb(sk, skb); | 1687 | sk_wmem_free_skb(sk, skb); |
1683 | } else { | 1688 | } else { |
1684 | TCP_SKB_CB(nskb)->flags |= TCP_SKB_CB(skb)->flags & | 1689 | TCP_SKB_CB(nskb)->tcp_flags |= TCP_SKB_CB(skb)->tcp_flags & |
1685 | ~(TCPHDR_FIN|TCPHDR_PSH); | 1690 | ~(TCPHDR_FIN|TCPHDR_PSH); |
1686 | if (!skb_shinfo(skb)->nr_frags) { | 1691 | if (!skb_shinfo(skb)->nr_frags) { |
1687 | skb_pull(skb, copy); | 1692 | skb_pull(skb, copy); |
@@ -1796,11 +1801,13 @@ static int tcp_write_xmit(struct sock *sk, unsigned int mss_now, int nonagle, | |||
1796 | tcp_event_new_data_sent(sk, skb); | 1801 | tcp_event_new_data_sent(sk, skb); |
1797 | 1802 | ||
1798 | tcp_minshall_update(tp, mss_now, skb); | 1803 | tcp_minshall_update(tp, mss_now, skb); |
1799 | sent_pkts++; | 1804 | sent_pkts += tcp_skb_pcount(skb); |
1800 | 1805 | ||
1801 | if (push_one) | 1806 | if (push_one) |
1802 | break; | 1807 | break; |
1803 | } | 1808 | } |
1809 | if (inet_csk(sk)->icsk_ca_state == TCP_CA_Recovery) | ||
1810 | tp->prr_out += sent_pkts; | ||
1804 | 1811 | ||
1805 | if (likely(sent_pkts)) { | 1812 | if (likely(sent_pkts)) { |
1806 | tcp_cwnd_validate(sk); | 1813 | tcp_cwnd_validate(sk); |
@@ -1985,7 +1992,7 @@ static void tcp_collapse_retrans(struct sock *sk, struct sk_buff *skb) | |||
1985 | TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(next_skb)->end_seq; | 1992 | TCP_SKB_CB(skb)->end_seq = TCP_SKB_CB(next_skb)->end_seq; |
1986 | 1993 | ||
1987 | /* Merge over control information. This moves PSH/FIN etc. over */ | 1994 | /* Merge over control information. This moves PSH/FIN etc. over */ |
1988 | TCP_SKB_CB(skb)->flags |= TCP_SKB_CB(next_skb)->flags; | 1995 | TCP_SKB_CB(skb)->tcp_flags |= TCP_SKB_CB(next_skb)->tcp_flags; |
1989 | 1996 | ||
1990 | /* All done, get rid of second SKB and account for it so | 1997 | /* All done, get rid of second SKB and account for it so |
1991 | * packet counting does not break. | 1998 | * packet counting does not break. |
@@ -2003,7 +2010,7 @@ static void tcp_collapse_retrans(struct sock *sk, struct sk_buff *skb) | |||
2003 | } | 2010 | } |
2004 | 2011 | ||
2005 | /* Check if coalescing SKBs is legal. */ | 2012 | /* Check if coalescing SKBs is legal. */ |
2006 | static int tcp_can_collapse(struct sock *sk, struct sk_buff *skb) | 2013 | static int tcp_can_collapse(const struct sock *sk, const struct sk_buff *skb) |
2007 | { | 2014 | { |
2008 | if (tcp_skb_pcount(skb) > 1) | 2015 | if (tcp_skb_pcount(skb) > 1) |
2009 | return 0; | 2016 | return 0; |
@@ -2033,7 +2040,7 @@ static void tcp_retrans_try_collapse(struct sock *sk, struct sk_buff *to, | |||
2033 | 2040 | ||
2034 | if (!sysctl_tcp_retrans_collapse) | 2041 | if (!sysctl_tcp_retrans_collapse) |
2035 | return; | 2042 | return; |
2036 | if (TCP_SKB_CB(skb)->flags & TCPHDR_SYN) | 2043 | if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN) |
2037 | return; | 2044 | return; |
2038 | 2045 | ||
2039 | tcp_for_write_queue_from_safe(skb, tmp, sk) { | 2046 | tcp_for_write_queue_from_safe(skb, tmp, sk) { |
@@ -2125,12 +2132,12 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) | |||
2125 | * since it is cheap to do so and saves bytes on the network. | 2132 | * since it is cheap to do so and saves bytes on the network. |
2126 | */ | 2133 | */ |
2127 | if (skb->len > 0 && | 2134 | if (skb->len > 0 && |
2128 | (TCP_SKB_CB(skb)->flags & TCPHDR_FIN) && | 2135 | (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) && |
2129 | tp->snd_una == (TCP_SKB_CB(skb)->end_seq - 1)) { | 2136 | tp->snd_una == (TCP_SKB_CB(skb)->end_seq - 1)) { |
2130 | if (!pskb_trim(skb, 0)) { | 2137 | if (!pskb_trim(skb, 0)) { |
2131 | /* Reuse, even though it does some unnecessary work */ | 2138 | /* Reuse, even though it does some unnecessary work */ |
2132 | tcp_init_nondata_skb(skb, TCP_SKB_CB(skb)->end_seq - 1, | 2139 | tcp_init_nondata_skb(skb, TCP_SKB_CB(skb)->end_seq - 1, |
2133 | TCP_SKB_CB(skb)->flags); | 2140 | TCP_SKB_CB(skb)->tcp_flags); |
2134 | skb->ip_summed = CHECKSUM_NONE; | 2141 | skb->ip_summed = CHECKSUM_NONE; |
2135 | } | 2142 | } |
2136 | } | 2143 | } |
@@ -2179,7 +2186,7 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) | |||
2179 | static int tcp_can_forward_retransmit(struct sock *sk) | 2186 | static int tcp_can_forward_retransmit(struct sock *sk) |
2180 | { | 2187 | { |
2181 | const struct inet_connection_sock *icsk = inet_csk(sk); | 2188 | const struct inet_connection_sock *icsk = inet_csk(sk); |
2182 | struct tcp_sock *tp = tcp_sk(sk); | 2189 | const struct tcp_sock *tp = tcp_sk(sk); |
2183 | 2190 | ||
2184 | /* Forward retransmissions are possible only during Recovery. */ | 2191 | /* Forward retransmissions are possible only during Recovery. */ |
2185 | if (icsk->icsk_ca_state != TCP_CA_Recovery) | 2192 | if (icsk->icsk_ca_state != TCP_CA_Recovery) |
@@ -2294,6 +2301,9 @@ begin_fwd: | |||
2294 | return; | 2301 | return; |
2295 | NET_INC_STATS_BH(sock_net(sk), mib_idx); | 2302 | NET_INC_STATS_BH(sock_net(sk), mib_idx); |
2296 | 2303 | ||
2304 | if (inet_csk(sk)->icsk_ca_state == TCP_CA_Recovery) | ||
2305 | tp->prr_out += tcp_skb_pcount(skb); | ||
2306 | |||
2297 | if (skb == tcp_write_queue_head(sk)) | 2307 | if (skb == tcp_write_queue_head(sk)) |
2298 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, | 2308 | inet_csk_reset_xmit_timer(sk, ICSK_TIME_RETRANS, |
2299 | inet_csk(sk)->icsk_rto, | 2309 | inet_csk(sk)->icsk_rto, |
@@ -2317,7 +2327,7 @@ void tcp_send_fin(struct sock *sk) | |||
2317 | mss_now = tcp_current_mss(sk); | 2327 | mss_now = tcp_current_mss(sk); |
2318 | 2328 | ||
2319 | if (tcp_send_head(sk) != NULL) { | 2329 | if (tcp_send_head(sk) != NULL) { |
2320 | TCP_SKB_CB(skb)->flags |= TCPHDR_FIN; | 2330 | TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_FIN; |
2321 | TCP_SKB_CB(skb)->end_seq++; | 2331 | TCP_SKB_CB(skb)->end_seq++; |
2322 | tp->write_seq++; | 2332 | tp->write_seq++; |
2323 | } else { | 2333 | } else { |
@@ -2379,11 +2389,11 @@ int tcp_send_synack(struct sock *sk) | |||
2379 | struct sk_buff *skb; | 2389 | struct sk_buff *skb; |
2380 | 2390 | ||
2381 | skb = tcp_write_queue_head(sk); | 2391 | skb = tcp_write_queue_head(sk); |
2382 | if (skb == NULL || !(TCP_SKB_CB(skb)->flags & TCPHDR_SYN)) { | 2392 | if (skb == NULL || !(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN)) { |
2383 | printk(KERN_DEBUG "tcp_send_synack: wrong queue state\n"); | 2393 | printk(KERN_DEBUG "tcp_send_synack: wrong queue state\n"); |
2384 | return -EFAULT; | 2394 | return -EFAULT; |
2385 | } | 2395 | } |
2386 | if (!(TCP_SKB_CB(skb)->flags & TCPHDR_ACK)) { | 2396 | if (!(TCP_SKB_CB(skb)->tcp_flags & TCPHDR_ACK)) { |
2387 | if (skb_cloned(skb)) { | 2397 | if (skb_cloned(skb)) { |
2388 | struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC); | 2398 | struct sk_buff *nskb = skb_copy(skb, GFP_ATOMIC); |
2389 | if (nskb == NULL) | 2399 | if (nskb == NULL) |
@@ -2397,7 +2407,7 @@ int tcp_send_synack(struct sock *sk) | |||
2397 | skb = nskb; | 2407 | skb = nskb; |
2398 | } | 2408 | } |
2399 | 2409 | ||
2400 | TCP_SKB_CB(skb)->flags |= TCPHDR_ACK; | 2410 | TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_ACK; |
2401 | TCP_ECN_send_synack(tcp_sk(sk), skb); | 2411 | TCP_ECN_send_synack(tcp_sk(sk), skb); |
2402 | } | 2412 | } |
2403 | TCP_SKB_CB(skb)->when = tcp_time_stamp; | 2413 | TCP_SKB_CB(skb)->when = tcp_time_stamp; |
@@ -2542,7 +2552,7 @@ EXPORT_SYMBOL(tcp_make_synack); | |||
2542 | /* Do all connect socket setups that can be done AF independent. */ | 2552 | /* Do all connect socket setups that can be done AF independent. */ |
2543 | static void tcp_connect_init(struct sock *sk) | 2553 | static void tcp_connect_init(struct sock *sk) |
2544 | { | 2554 | { |
2545 | struct dst_entry *dst = __sk_dst_get(sk); | 2555 | const struct dst_entry *dst = __sk_dst_get(sk); |
2546 | struct tcp_sock *tp = tcp_sk(sk); | 2556 | struct tcp_sock *tp = tcp_sk(sk); |
2547 | __u8 rcv_wscale; | 2557 | __u8 rcv_wscale; |
2548 | 2558 | ||
@@ -2794,13 +2804,13 @@ int tcp_write_wakeup(struct sock *sk) | |||
2794 | if (seg_size < TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq || | 2804 | if (seg_size < TCP_SKB_CB(skb)->end_seq - TCP_SKB_CB(skb)->seq || |
2795 | skb->len > mss) { | 2805 | skb->len > mss) { |
2796 | seg_size = min(seg_size, mss); | 2806 | seg_size = min(seg_size, mss); |
2797 | TCP_SKB_CB(skb)->flags |= TCPHDR_PSH; | 2807 | TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH; |
2798 | if (tcp_fragment(sk, skb, seg_size, mss)) | 2808 | if (tcp_fragment(sk, skb, seg_size, mss)) |
2799 | return -1; | 2809 | return -1; |
2800 | } else if (!tcp_skb_pcount(skb)) | 2810 | } else if (!tcp_skb_pcount(skb)) |
2801 | tcp_set_skb_tso_segs(sk, skb, mss); | 2811 | tcp_set_skb_tso_segs(sk, skb, mss); |
2802 | 2812 | ||
2803 | TCP_SKB_CB(skb)->flags |= TCPHDR_PSH; | 2813 | TCP_SKB_CB(skb)->tcp_flags |= TCPHDR_PSH; |
2804 | TCP_SKB_CB(skb)->when = tcp_time_stamp; | 2814 | TCP_SKB_CB(skb)->when = tcp_time_stamp; |
2805 | err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC); | 2815 | err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC); |
2806 | if (!err) | 2816 | if (!err) |
diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c index ecd44b0c45f1..2e0f0af76c19 100644 --- a/net/ipv4/tcp_timer.c +++ b/net/ipv4/tcp_timer.c | |||
@@ -334,7 +334,6 @@ void tcp_retransmit_timer(struct sock *sk) | |||
334 | * connection. If the socket is an orphan, time it out, | 334 | * connection. If the socket is an orphan, time it out, |
335 | * we cannot allow such beasts to hang infinitely. | 335 | * we cannot allow such beasts to hang infinitely. |
336 | */ | 336 | */ |
337 | #ifdef TCP_DEBUG | ||
338 | struct inet_sock *inet = inet_sk(sk); | 337 | struct inet_sock *inet = inet_sk(sk); |
339 | if (sk->sk_family == AF_INET) { | 338 | if (sk->sk_family == AF_INET) { |
340 | LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", | 339 | LIMIT_NETDEBUG(KERN_DEBUG "TCP: Peer %pI4:%u/%u unexpectedly shrunk window %u:%u (repaired)\n", |
@@ -349,7 +348,6 @@ void tcp_retransmit_timer(struct sock *sk) | |||
349 | inet->inet_num, tp->snd_una, tp->snd_nxt); | 348 | inet->inet_num, tp->snd_una, tp->snd_nxt); |
350 | } | 349 | } |
351 | #endif | 350 | #endif |
352 | #endif | ||
353 | if (tcp_time_stamp - tp->rcv_tstamp > TCP_RTO_MAX) { | 351 | if (tcp_time_stamp - tp->rcv_tstamp > TCP_RTO_MAX) { |
354 | tcp_write_err(sk); | 352 | tcp_write_err(sk); |
355 | goto out; | 353 | goto out; |
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index 1b5a19340a95..ebaa96bd3464 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1267,7 +1267,7 @@ int udp_disconnect(struct sock *sk, int flags) | |||
1267 | sk->sk_state = TCP_CLOSE; | 1267 | sk->sk_state = TCP_CLOSE; |
1268 | inet->inet_daddr = 0; | 1268 | inet->inet_daddr = 0; |
1269 | inet->inet_dport = 0; | 1269 | inet->inet_dport = 0; |
1270 | sock_rps_save_rxhash(sk, 0); | 1270 | sock_rps_reset_rxhash(sk); |
1271 | sk->sk_bound_dev_if = 0; | 1271 | sk->sk_bound_dev_if = 0; |
1272 | if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) | 1272 | if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) |
1273 | inet_reset_saddr(sk); | 1273 | inet_reset_saddr(sk); |
@@ -1355,7 +1355,7 @@ static int __udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
1355 | int rc; | 1355 | int rc; |
1356 | 1356 | ||
1357 | if (inet_sk(sk)->inet_daddr) | 1357 | if (inet_sk(sk)->inet_daddr) |
1358 | sock_rps_save_rxhash(sk, skb->rxhash); | 1358 | sock_rps_save_rxhash(sk, skb); |
1359 | 1359 | ||
1360 | rc = ip_queue_rcv_skb(sk, skb); | 1360 | rc = ip_queue_rcv_skb(sk, skb); |
1361 | if (rc < 0) { | 1361 | if (rc < 0) { |
@@ -1461,10 +1461,9 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
1461 | } | 1461 | } |
1462 | } | 1462 | } |
1463 | 1463 | ||
1464 | if (rcu_dereference_raw(sk->sk_filter)) { | 1464 | if (rcu_access_pointer(sk->sk_filter) && |
1465 | if (udp_lib_checksum_complete(skb)) | 1465 | udp_lib_checksum_complete(skb)) |
1466 | goto drop; | 1466 | goto drop; |
1467 | } | ||
1468 | 1467 | ||
1469 | 1468 | ||
1470 | if (sk_rcvqueues_full(sk, skb)) | 1469 | if (sk_rcvqueues_full(sk, skb)) |
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c index fc5368ad2b0d..a0b4c5da8d43 100644 --- a/net/ipv4/xfrm4_policy.c +++ b/net/ipv4/xfrm4_policy.c | |||
@@ -79,13 +79,13 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev, | |||
79 | struct rtable *rt = (struct rtable *)xdst->route; | 79 | struct rtable *rt = (struct rtable *)xdst->route; |
80 | const struct flowi4 *fl4 = &fl->u.ip4; | 80 | const struct flowi4 *fl4 = &fl->u.ip4; |
81 | 81 | ||
82 | rt->rt_key_dst = fl4->daddr; | 82 | xdst->u.rt.rt_key_dst = fl4->daddr; |
83 | rt->rt_key_src = fl4->saddr; | 83 | xdst->u.rt.rt_key_src = fl4->saddr; |
84 | rt->rt_key_tos = fl4->flowi4_tos; | 84 | xdst->u.rt.rt_key_tos = fl4->flowi4_tos; |
85 | rt->rt_route_iif = fl4->flowi4_iif; | 85 | xdst->u.rt.rt_route_iif = fl4->flowi4_iif; |
86 | rt->rt_iif = fl4->flowi4_iif; | 86 | xdst->u.rt.rt_iif = fl4->flowi4_iif; |
87 | rt->rt_oif = fl4->flowi4_oif; | 87 | xdst->u.rt.rt_oif = fl4->flowi4_oif; |
88 | rt->rt_mark = fl4->flowi4_mark; | 88 | xdst->u.rt.rt_mark = fl4->flowi4_mark; |
89 | 89 | ||
90 | xdst->u.dst.dev = dev; | 90 | xdst->u.dst.dev = dev; |
91 | dev_hold(dev); | 91 | dev_hold(dev); |