diff options
Diffstat (limited to 'net/ipv4')
57 files changed, 688 insertions, 520 deletions
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 1b745d412cf6..1b5096a9875a 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
| @@ -466,8 +466,13 @@ int inet_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) | |||
| 466 | goto out; | 466 | goto out; |
| 467 | 467 | ||
| 468 | if (addr->sin_family != AF_INET) { | 468 | if (addr->sin_family != AF_INET) { |
| 469 | /* Compatibility games : accept AF_UNSPEC (mapped to AF_INET) | ||
| 470 | * only if s_addr is INADDR_ANY. | ||
| 471 | */ | ||
| 469 | err = -EAFNOSUPPORT; | 472 | err = -EAFNOSUPPORT; |
| 470 | goto out; | 473 | if (addr->sin_family != AF_UNSPEC || |
| 474 | addr->sin_addr.s_addr != htonl(INADDR_ANY)) | ||
| 475 | goto out; | ||
| 471 | } | 476 | } |
| 472 | 477 | ||
| 473 | chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); | 478 | chk_addr_ret = inet_addr_type(sock_net(sk), addr->sin_addr.s_addr); |
| @@ -888,7 +893,7 @@ int inet_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
| 888 | EXPORT_SYMBOL(inet_ioctl); | 893 | EXPORT_SYMBOL(inet_ioctl); |
| 889 | 894 | ||
| 890 | #ifdef CONFIG_COMPAT | 895 | #ifdef CONFIG_COMPAT |
| 891 | 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) |
| 892 | { | 897 | { |
| 893 | struct sock *sk = sock->sk; | 898 | struct sock *sk = sock->sk; |
| 894 | int err = -ENOIOCTLCMD; | 899 | int err = -ENOIOCTLCMD; |
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c index c1f4154552fc..36d14406261e 100644 --- a/net/ipv4/ah4.c +++ b/net/ipv4/ah4.c | |||
| @@ -136,8 +136,6 @@ static void ah_output_done(struct crypto_async_request *base, int err) | |||
| 136 | memcpy(top_iph+1, iph+1, top_iph->ihl*4 - sizeof(struct iphdr)); | 136 | memcpy(top_iph+1, iph+1, top_iph->ihl*4 - sizeof(struct iphdr)); |
| 137 | } | 137 | } |
| 138 | 138 | ||
| 139 | err = ah->nexthdr; | ||
| 140 | |||
| 141 | kfree(AH_SKB_CB(skb)->tmp); | 139 | kfree(AH_SKB_CB(skb)->tmp); |
| 142 | xfrm_output_resume(skb, err); | 140 | xfrm_output_resume(skb, err); |
| 143 | } | 141 | } |
| @@ -264,12 +262,12 @@ static void ah_input_done(struct crypto_async_request *base, int err) | |||
| 264 | if (err) | 262 | if (err) |
| 265 | goto out; | 263 | goto out; |
| 266 | 264 | ||
| 265 | err = ah->nexthdr; | ||
| 266 | |||
| 267 | skb->network_header += ah_hlen; | 267 | skb->network_header += ah_hlen; |
| 268 | memcpy(skb_network_header(skb), work_iph, ihl); | 268 | memcpy(skb_network_header(skb), work_iph, ihl); |
| 269 | __skb_pull(skb, ah_hlen + ihl); | 269 | __skb_pull(skb, ah_hlen + ihl); |
| 270 | skb_set_transport_header(skb, -ihl); | 270 | skb_set_transport_header(skb, -ihl); |
| 271 | |||
| 272 | err = ah->nexthdr; | ||
| 273 | out: | 271 | out: |
| 274 | kfree(AH_SKB_CB(skb)->tmp); | 272 | kfree(AH_SKB_CB(skb)->tmp); |
| 275 | xfrm_input_resume(skb, err); | 273 | xfrm_input_resume(skb, err); |
| @@ -371,8 +369,6 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb) | |||
| 371 | if (err == -EINPROGRESS) | 369 | if (err == -EINPROGRESS) |
| 372 | goto out; | 370 | goto out; |
| 373 | 371 | ||
| 374 | if (err == -EBUSY) | ||
| 375 | err = NET_XMIT_DROP; | ||
| 376 | goto out_free; | 372 | goto out_free; |
| 377 | } | 373 | } |
| 378 | 374 | ||
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_rules.c b/net/ipv4/fib_rules.c index a53bb1b5b118..46339ba7a2d3 100644 --- a/net/ipv4/fib_rules.c +++ b/net/ipv4/fib_rules.c | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include <linux/init.h> | 26 | #include <linux/init.h> |
| 27 | #include <linux/list.h> | 27 | #include <linux/list.h> |
| 28 | #include <linux/rcupdate.h> | 28 | #include <linux/rcupdate.h> |
| 29 | #include <linux/export.h> | ||
| 29 | #include <net/ip.h> | 30 | #include <net/ip.h> |
| 30 | #include <net/route.h> | 31 | #include <net/route.h> |
| 31 | #include <net/tcp.h> | 32 | #include <net/tcp.h> |
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c index 33e2c35b74b7..80106d89d548 100644 --- a/net/ipv4/fib_semantics.c +++ b/net/ipv4/fib_semantics.c | |||
| @@ -142,6 +142,14 @@ const struct fib_prop fib_props[RTN_MAX + 1] = { | |||
| 142 | }; | 142 | }; |
| 143 | 143 | ||
| 144 | /* Release a nexthop info record */ | 144 | /* Release a nexthop info record */ |
| 145 | static void free_fib_info_rcu(struct rcu_head *head) | ||
| 146 | { | ||
| 147 | struct fib_info *fi = container_of(head, struct fib_info, rcu); | ||
| 148 | |||
| 149 | if (fi->fib_metrics != (u32 *) dst_default_metrics) | ||
| 150 | kfree(fi->fib_metrics); | ||
| 151 | kfree(fi); | ||
| 152 | } | ||
| 145 | 153 | ||
| 146 | void free_fib_info(struct fib_info *fi) | 154 | void free_fib_info(struct fib_info *fi) |
| 147 | { | 155 | { |
| @@ -156,7 +164,7 @@ void free_fib_info(struct fib_info *fi) | |||
| 156 | } endfor_nexthops(fi); | 164 | } endfor_nexthops(fi); |
| 157 | fib_info_cnt--; | 165 | fib_info_cnt--; |
| 158 | release_net(fi->fib_net); | 166 | release_net(fi->fib_net); |
| 159 | kfree_rcu(fi, rcu); | 167 | call_rcu(&fi->rcu, free_fib_info_rcu); |
| 160 | } | 168 | } |
| 161 | 169 | ||
| 162 | void fib_release_info(struct fib_info *fi) | 170 | void fib_release_info(struct fib_info *fi) |
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index de9e2978476f..37b671185c81 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
| @@ -73,6 +73,7 @@ | |||
| 73 | #include <linux/list.h> | 73 | #include <linux/list.h> |
| 74 | #include <linux/slab.h> | 74 | #include <linux/slab.h> |
| 75 | #include <linux/prefetch.h> | 75 | #include <linux/prefetch.h> |
| 76 | #include <linux/export.h> | ||
| 76 | #include <net/net_namespace.h> | 77 | #include <net/net_namespace.h> |
| 77 | #include <net/ip.h> | 78 | #include <net/ip.h> |
| 78 | #include <net/protocol.h> | 79 | #include <net/protocol.h> |
| @@ -204,7 +205,7 @@ static inline struct tnode *node_parent_rcu(const struct rt_trie_node *node) | |||
| 204 | return (struct tnode *)(parent & ~NODE_TYPE_MASK); | 205 | return (struct tnode *)(parent & ~NODE_TYPE_MASK); |
| 205 | } | 206 | } |
| 206 | 207 | ||
| 207 | /* Same as rcu_assign_pointer | 208 | /* Same as RCU_INIT_POINTER |
| 208 | * but that macro() assumes that value is a pointer. | 209 | * but that macro() assumes that value is a pointer. |
| 209 | */ | 210 | */ |
| 210 | static inline void node_set_parent(struct rt_trie_node *node, struct tnode *ptr) | 211 | static inline void node_set_parent(struct rt_trie_node *node, struct tnode *ptr) |
| @@ -528,7 +529,7 @@ static void tnode_put_child_reorg(struct tnode *tn, int i, struct rt_trie_node * | |||
| 528 | if (n) | 529 | if (n) |
| 529 | node_set_parent(n, tn); | 530 | node_set_parent(n, tn); |
| 530 | 531 | ||
| 531 | rcu_assign_pointer(tn->child[i], n); | 532 | RCU_INIT_POINTER(tn->child[i], n); |
| 532 | } | 533 | } |
| 533 | 534 | ||
| 534 | #define MAX_WORK 10 | 535 | #define MAX_WORK 10 |
| @@ -1014,7 +1015,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn) | |||
| 1014 | 1015 | ||
| 1015 | tp = node_parent((struct rt_trie_node *) tn); | 1016 | tp = node_parent((struct rt_trie_node *) tn); |
| 1016 | if (!tp) | 1017 | if (!tp) |
| 1017 | rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); | 1018 | RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); |
| 1018 | 1019 | ||
| 1019 | tnode_free_flush(); | 1020 | tnode_free_flush(); |
| 1020 | if (!tp) | 1021 | if (!tp) |
| @@ -1026,7 +1027,7 @@ static void trie_rebalance(struct trie *t, struct tnode *tn) | |||
| 1026 | if (IS_TNODE(tn)) | 1027 | if (IS_TNODE(tn)) |
| 1027 | tn = (struct tnode *)resize(t, (struct tnode *)tn); | 1028 | tn = (struct tnode *)resize(t, (struct tnode *)tn); |
| 1028 | 1029 | ||
| 1029 | rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); | 1030 | RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); |
| 1030 | tnode_free_flush(); | 1031 | tnode_free_flush(); |
| 1031 | } | 1032 | } |
| 1032 | 1033 | ||
| @@ -1163,7 +1164,7 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen) | |||
| 1163 | put_child(t, (struct tnode *)tp, cindex, | 1164 | put_child(t, (struct tnode *)tp, cindex, |
| 1164 | (struct rt_trie_node *)tn); | 1165 | (struct rt_trie_node *)tn); |
| 1165 | } else { | 1166 | } else { |
| 1166 | rcu_assign_pointer(t->trie, (struct rt_trie_node *)tn); | 1167 | RCU_INIT_POINTER(t->trie, (struct rt_trie_node *)tn); |
| 1167 | tp = tn; | 1168 | tp = tn; |
| 1168 | } | 1169 | } |
| 1169 | } | 1170 | } |
| @@ -1621,7 +1622,7 @@ static void trie_leaf_remove(struct trie *t, struct leaf *l) | |||
| 1621 | put_child(t, (struct tnode *)tp, cindex, NULL); | 1622 | put_child(t, (struct tnode *)tp, cindex, NULL); |
| 1622 | trie_rebalance(t, tp); | 1623 | trie_rebalance(t, tp); |
| 1623 | } else | 1624 | } else |
| 1624 | rcu_assign_pointer(t->trie, NULL); | 1625 | RCU_INIT_POINTER(t->trie, NULL); |
| 1625 | 1626 | ||
| 1626 | free_leaf(l); | 1627 | free_leaf(l); |
| 1627 | } | 1628 | } |
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 283c0a26e03f..c7472eff2d51 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
| @@ -767,7 +767,7 @@ static int igmp_xmarksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs) | |||
| 767 | break; | 767 | break; |
| 768 | for (i=0; i<nsrcs; i++) { | 768 | for (i=0; i<nsrcs; i++) { |
| 769 | /* skip inactive filters */ | 769 | /* skip inactive filters */ |
| 770 | if (pmc->sfcount[MCAST_INCLUDE] || | 770 | if (psf->sf_count[MCAST_INCLUDE] || |
| 771 | pmc->sfcount[MCAST_EXCLUDE] != | 771 | pmc->sfcount[MCAST_EXCLUDE] != |
| 772 | psf->sf_count[MCAST_EXCLUDE]) | 772 | psf->sf_count[MCAST_EXCLUDE]) |
| 773 | continue; | 773 | continue; |
| @@ -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..68e8ac514383 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_TCLASS - 1))) | ||
| 137 | RTA_PUT_U8(skb, INET_DIAG_TCLASS, 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..89168c6351ff 100644 --- a/net/ipv4/inet_timewait_sock.c +++ b/net/ipv4/inet_timewait_sock.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
| 12 | #include <linux/kmemcheck.h> | 12 | #include <linux/kmemcheck.h> |
| 13 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
| 14 | #include <linux/module.h> | ||
| 14 | #include <net/inet_hashtables.h> | 15 | #include <net/inet_hashtables.h> |
| 15 | #include <net/inet_timewait_sock.h> | 16 | #include <net/inet_timewait_sock.h> |
| 16 | #include <net/ip.h> | 17 | #include <net/ip.h> |
| @@ -183,6 +184,7 @@ struct inet_timewait_sock *inet_twsk_alloc(const struct sock *sk, const int stat | |||
| 183 | tw->tw_daddr = inet->inet_daddr; | 184 | tw->tw_daddr = inet->inet_daddr; |
| 184 | tw->tw_rcv_saddr = inet->inet_rcv_saddr; | 185 | tw->tw_rcv_saddr = inet->inet_rcv_saddr; |
| 185 | tw->tw_bound_dev_if = sk->sk_bound_dev_if; | 186 | tw->tw_bound_dev_if = sk->sk_bound_dev_if; |
| 187 | tw->tw_tos = inet->tos; | ||
| 186 | tw->tw_num = inet->inet_num; | 188 | tw->tw_num = inet->inet_num; |
| 187 | tw->tw_state = TCP_TIME_WAIT; | 189 | tw->tw_state = TCP_TIME_WAIT; |
| 188 | tw->tw_substate = state; | 190 | 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_options.c b/net/ipv4/ip_options.c index ec93335901dd..05d20cca9d66 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c | |||
| @@ -640,6 +640,7 @@ int ip_options_rcv_srr(struct sk_buff *skb) | |||
| 640 | } | 640 | } |
| 641 | if (srrptr <= srrspace) { | 641 | if (srrptr <= srrspace) { |
| 642 | opt->srr_is_hit = 1; | 642 | opt->srr_is_hit = 1; |
| 643 | iph->daddr = nexthop; | ||
| 643 | opt->is_changed = 1; | 644 | opt->is_changed = 1; |
| 644 | } | 645 | } |
| 645 | return 0; | 646 | return 0; |
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/ipconfig.c b/net/ipv4/ipconfig.c index 472a8c4f1dc0..0da2afc97f32 100644 --- a/net/ipv4/ipconfig.c +++ b/net/ipv4/ipconfig.c | |||
| @@ -54,6 +54,7 @@ | |||
| 54 | #include <linux/delay.h> | 54 | #include <linux/delay.h> |
| 55 | #include <linux/nfs_fs.h> | 55 | #include <linux/nfs_fs.h> |
| 56 | #include <linux/slab.h> | 56 | #include <linux/slab.h> |
| 57 | #include <linux/export.h> | ||
| 57 | #include <net/net_namespace.h> | 58 | #include <net/net_namespace.h> |
| 58 | #include <net/arp.h> | 59 | #include <net/arp.h> |
| 59 | #include <net/ip.h> | 60 | #include <net/ip.h> |
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..76a7f07b38b6 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
| @@ -61,6 +61,7 @@ | |||
| 61 | #include <linux/if_arp.h> | 61 | #include <linux/if_arp.h> |
| 62 | #include <linux/netfilter_ipv4.h> | 62 | #include <linux/netfilter_ipv4.h> |
| 63 | #include <linux/compat.h> | 63 | #include <linux/compat.h> |
| 64 | #include <linux/export.h> | ||
| 64 | #include <net/ipip.h> | 65 | #include <net/ipip.h> |
| 65 | #include <net/checksum.h> | 66 | #include <net/checksum.h> |
| 66 | #include <net/netlink.h> | 67 | #include <net/netlink.h> |
| @@ -1176,7 +1177,7 @@ static void mrtsock_destruct(struct sock *sk) | |||
| 1176 | ipmr_for_each_table(mrt, net) { | 1177 | ipmr_for_each_table(mrt, net) { |
| 1177 | if (sk == rtnl_dereference(mrt->mroute_sk)) { | 1178 | if (sk == rtnl_dereference(mrt->mroute_sk)) { |
| 1178 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)--; | 1179 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)--; |
| 1179 | rcu_assign_pointer(mrt->mroute_sk, NULL); | 1180 | RCU_INIT_POINTER(mrt->mroute_sk, NULL); |
| 1180 | mroute_clean_tables(mrt); | 1181 | mroute_clean_tables(mrt); |
| 1181 | } | 1182 | } |
| 1182 | } | 1183 | } |
| @@ -1203,7 +1204,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsi | |||
| 1203 | return -ENOENT; | 1204 | return -ENOENT; |
| 1204 | 1205 | ||
| 1205 | if (optname != MRT_INIT) { | 1206 | if (optname != MRT_INIT) { |
| 1206 | if (sk != rcu_dereference_raw(mrt->mroute_sk) && | 1207 | if (sk != rcu_access_pointer(mrt->mroute_sk) && |
| 1207 | !capable(CAP_NET_ADMIN)) | 1208 | !capable(CAP_NET_ADMIN)) |
| 1208 | return -EACCES; | 1209 | return -EACCES; |
| 1209 | } | 1210 | } |
| @@ -1224,13 +1225,13 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, unsi | |||
| 1224 | 1225 | ||
| 1225 | ret = ip_ra_control(sk, 1, mrtsock_destruct); | 1226 | ret = ip_ra_control(sk, 1, mrtsock_destruct); |
| 1226 | if (ret == 0) { | 1227 | if (ret == 0) { |
| 1227 | rcu_assign_pointer(mrt->mroute_sk, sk); | 1228 | RCU_INIT_POINTER(mrt->mroute_sk, sk); |
| 1228 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)++; | 1229 | IPV4_DEVCONF_ALL(net, MC_FORWARDING)++; |
| 1229 | } | 1230 | } |
| 1230 | rtnl_unlock(); | 1231 | rtnl_unlock(); |
| 1231 | return ret; | 1232 | return ret; |
| 1232 | case MRT_DONE: | 1233 | case MRT_DONE: |
| 1233 | if (sk != rcu_dereference_raw(mrt->mroute_sk)) | 1234 | if (sk != rcu_access_pointer(mrt->mroute_sk)) |
| 1234 | return -EACCES; | 1235 | return -EACCES; |
| 1235 | return ip_ra_control(sk, 0, NULL); | 1236 | return ip_ra_control(sk, 0, NULL); |
| 1236 | case MRT_ADD_VIF: | 1237 | case MRT_ADD_VIF: |
diff --git a/net/ipv4/netfilter.c b/net/ipv4/netfilter.c index 929b27bdeb79..9899619ab9b8 100644 --- a/net/ipv4/netfilter.c +++ b/net/ipv4/netfilter.c | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <linux/ip.h> | 5 | #include <linux/ip.h> |
| 6 | #include <linux/skbuff.h> | 6 | #include <linux/skbuff.h> |
| 7 | #include <linux/gfp.h> | 7 | #include <linux/gfp.h> |
| 8 | #include <linux/export.h> | ||
| 8 | #include <net/route.h> | 9 | #include <net/route.h> |
| 9 | #include <net/xfrm.h> | 10 | #include <net/xfrm.h> |
| 10 | #include <net/ip.h> | 11 | #include <net/ip.h> |
diff --git a/net/ipv4/netfilter/ip_queue.c b/net/ipv4/netfilter/ip_queue.c index 5c9b9d963918..e59aabd0eae4 100644 --- a/net/ipv4/netfilter/ip_queue.c +++ b/net/ipv4/netfilter/ip_queue.c | |||
| @@ -218,6 +218,7 @@ ipq_build_packet_message(struct nf_queue_entry *entry, int *errp) | |||
| 218 | return skb; | 218 | return skb; |
| 219 | 219 | ||
| 220 | nlmsg_failure: | 220 | nlmsg_failure: |
| 221 | kfree_skb(skb); | ||
| 221 | *errp = -EINVAL; | 222 | *errp = -EINVAL; |
| 222 | printk(KERN_ERR "ip_queue: error creating packet message\n"); | 223 | printk(KERN_ERR "ip_queue: error creating packet message\n"); |
| 223 | return NULL; | 224 | return NULL; |
| @@ -313,7 +314,7 @@ ipq_set_verdict(struct ipq_verdict_msg *vmsg, unsigned int len) | |||
| 313 | { | 314 | { |
| 314 | struct nf_queue_entry *entry; | 315 | struct nf_queue_entry *entry; |
| 315 | 316 | ||
| 316 | if (vmsg->value > NF_MAX_VERDICT) | 317 | if (vmsg->value > NF_MAX_VERDICT || vmsg->value == NF_STOLEN) |
| 317 | return -EINVAL; | 318 | return -EINVAL; |
| 318 | 319 | ||
| 319 | entry = ipq_find_dequeue_entry(vmsg->id); | 320 | entry = ipq_find_dequeue_entry(vmsg->id); |
| @@ -358,12 +359,9 @@ ipq_receive_peer(struct ipq_peer_msg *pmsg, | |||
| 358 | break; | 359 | break; |
| 359 | 360 | ||
| 360 | case IPQM_VERDICT: | 361 | case IPQM_VERDICT: |
| 361 | if (pmsg->msg.verdict.value > NF_MAX_VERDICT) | 362 | status = ipq_set_verdict(&pmsg->msg.verdict, |
| 362 | status = -EINVAL; | 363 | len - sizeof(*pmsg)); |
| 363 | else | 364 | break; |
| 364 | status = ipq_set_verdict(&pmsg->msg.verdict, | ||
| 365 | len - sizeof(*pmsg)); | ||
| 366 | break; | ||
| 367 | default: | 365 | default: |
| 368 | status = -EINVAL; | 366 | status = -EINVAL; |
| 369 | } | 367 | } |
diff --git a/net/ipv4/netfilter/ipt_CLUSTERIP.c b/net/ipv4/netfilter/ipt_CLUSTERIP.c index db8d22db425f..a639967eb727 100644 --- a/net/ipv4/netfilter/ipt_CLUSTERIP.c +++ b/net/ipv4/netfilter/ipt_CLUSTERIP.c | |||
| @@ -395,7 +395,6 @@ static int clusterip_tg_check(const struct xt_tgchk_param *par) | |||
| 395 | config = clusterip_config_init(cipinfo, | 395 | config = clusterip_config_init(cipinfo, |
| 396 | e->ip.dst.s_addr, dev); | 396 | e->ip.dst.s_addr, dev); |
| 397 | if (!config) { | 397 | if (!config) { |
| 398 | pr_info("cannot allocate config\n"); | ||
| 399 | dev_put(dev); | 398 | dev_put(dev); |
| 400 | return -ENOMEM; | 399 | return -ENOMEM; |
| 401 | } | 400 | } |
diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c index 446e0f467a17..b5508151e547 100644 --- a/net/ipv4/netfilter/ipt_ULOG.c +++ b/net/ipv4/netfilter/ipt_ULOG.c | |||
| @@ -135,10 +135,8 @@ static struct sk_buff *ulog_alloc_skb(unsigned int size) | |||
| 135 | * due to slab allocator restrictions */ | 135 | * due to slab allocator restrictions */ |
| 136 | 136 | ||
| 137 | n = max(size, nlbufsiz); | 137 | n = max(size, nlbufsiz); |
| 138 | skb = alloc_skb(n, GFP_ATOMIC); | 138 | skb = alloc_skb(n, GFP_ATOMIC | __GFP_NOWARN); |
| 139 | if (!skb) { | 139 | if (!skb) { |
| 140 | pr_debug("cannot alloc whole buffer %ub!\n", n); | ||
| 141 | |||
| 142 | if (n > size) { | 140 | if (n > size) { |
| 143 | /* try to allocate only as much as we need for | 141 | /* try to allocate only as much as we need for |
| 144 | * current packet */ | 142 | * current packet */ |
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c index 5585980fce2e..9682b36df38c 100644 --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <net/netfilter/nf_conntrack_expect.h> | 21 | #include <net/netfilter/nf_conntrack_expect.h> |
| 22 | #include <net/netfilter/nf_conntrack_acct.h> | 22 | #include <net/netfilter/nf_conntrack_acct.h> |
| 23 | #include <linux/rculist_nulls.h> | 23 | #include <linux/rculist_nulls.h> |
| 24 | #include <linux/export.h> | ||
| 24 | 25 | ||
| 25 | struct ct_iter_state { | 26 | struct ct_iter_state { |
| 26 | struct seq_net_private p; | 27 | struct seq_net_private p; |
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_proto_common.c b/net/ipv4/netfilter/nf_nat_proto_common.c index f52d41ea0690..a3d997618602 100644 --- a/net/ipv4/netfilter/nf_nat_proto_common.c +++ b/net/ipv4/netfilter/nf_nat_proto_common.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <linux/ip.h> | 12 | #include <linux/ip.h> |
| 13 | 13 | ||
| 14 | #include <linux/netfilter.h> | 14 | #include <linux/netfilter.h> |
| 15 | #include <linux/export.h> | ||
| 15 | #include <net/secure_seq.h> | 16 | #include <net/secure_seq.h> |
| 16 | #include <net/netfilter/nf_nat.h> | 17 | #include <net/netfilter/nf_nat.h> |
| 17 | #include <net/netfilter/nf_nat_core.h> | 18 | #include <net/netfilter/nf_nat_core.h> |
diff --git a/net/ipv4/netfilter/nf_nat_proto_icmp.c b/net/ipv4/netfilter/nf_nat_proto_icmp.c index 5744c3ec847c..9f4dc1235dc7 100644 --- a/net/ipv4/netfilter/nf_nat_proto_icmp.c +++ b/net/ipv4/netfilter/nf_nat_proto_icmp.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
| 10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
| 11 | #include <linux/export.h> | ||
| 11 | #include <linux/ip.h> | 12 | #include <linux/ip.h> |
| 12 | #include <linux/icmp.h> | 13 | #include <linux/icmp.h> |
| 13 | 14 | ||
diff --git a/net/ipv4/netfilter/nf_nat_proto_sctp.c b/net/ipv4/netfilter/nf_nat_proto_sctp.c index 756331d42661..bd5a80a62a5b 100644 --- a/net/ipv4/netfilter/nf_nat_proto_sctp.c +++ b/net/ipv4/netfilter/nf_nat_proto_sctp.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
| 11 | #include <linux/ip.h> | 11 | #include <linux/ip.h> |
| 12 | #include <linux/sctp.h> | 12 | #include <linux/sctp.h> |
| 13 | #include <linux/module.h> | ||
| 13 | #include <net/sctp/checksum.h> | 14 | #include <net/sctp/checksum.h> |
| 14 | 15 | ||
| 15 | #include <net/netfilter/nf_nat_protocol.h> | 16 | #include <net/netfilter/nf_nat_protocol.h> |
diff --git a/net/ipv4/netfilter/nf_nat_proto_tcp.c b/net/ipv4/netfilter/nf_nat_proto_tcp.c index aa460a595d5d..0d67bb80130f 100644 --- a/net/ipv4/netfilter/nf_nat_proto_tcp.c +++ b/net/ipv4/netfilter/nf_nat_proto_tcp.c | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
| 10 | #include <linux/init.h> | 10 | #include <linux/init.h> |
| 11 | #include <linux/export.h> | ||
| 11 | #include <linux/ip.h> | 12 | #include <linux/ip.h> |
| 12 | #include <linux/tcp.h> | 13 | #include <linux/tcp.h> |
| 13 | 14 | ||
diff --git a/net/ipv4/netfilter/nf_nat_proto_udp.c b/net/ipv4/netfilter/nf_nat_proto_udp.c index dfe65c7e2925..0b1b8601cba7 100644 --- a/net/ipv4/netfilter/nf_nat_proto_udp.c +++ b/net/ipv4/netfilter/nf_nat_proto_udp.c | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <linux/types.h> | 9 | #include <linux/types.h> |
| 10 | #include <linux/export.h> | ||
| 10 | #include <linux/init.h> | 11 | #include <linux/init.h> |
| 11 | #include <linux/ip.h> | 12 | #include <linux/ip.h> |
| 12 | #include <linux/udp.h> | 13 | #include <linux/udp.h> |
diff --git a/net/ipv4/netfilter/nf_nat_proto_udplite.c b/net/ipv4/netfilter/nf_nat_proto_udplite.c index 3cc8c8af39ef..f83ef23e2ab7 100644 --- a/net/ipv4/netfilter/nf_nat_proto_udplite.c +++ b/net/ipv4/netfilter/nf_nat_proto_udplite.c | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include <linux/udp.h> | 13 | #include <linux/udp.h> |
| 14 | 14 | ||
| 15 | #include <linux/netfilter.h> | 15 | #include <linux/netfilter.h> |
| 16 | #include <linux/module.h> | ||
| 16 | #include <net/netfilter/nf_nat.h> | 17 | #include <net/netfilter/nf_nat.h> |
| 17 | #include <net/netfilter/nf_nat_protocol.h> | 18 | #include <net/netfilter/nf_nat_protocol.h> |
| 18 | 19 | ||
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..2133c30a4a5f 100644 --- a/net/ipv4/netfilter/nf_nat_snmp_basic.c +++ b/net/ipv4/netfilter/nf_nat_snmp_basic.c | |||
| @@ -400,11 +400,8 @@ static unsigned char asn1_octets_decode(struct asn1_ctx *ctx, | |||
| 400 | *len = 0; | 400 | *len = 0; |
| 401 | 401 | ||
| 402 | *octets = kmalloc(eoc - ctx->pointer, GFP_ATOMIC); | 402 | *octets = kmalloc(eoc - ctx->pointer, GFP_ATOMIC); |
| 403 | if (*octets == NULL) { | 403 | if (*octets == NULL) |
| 404 | if (net_ratelimit()) | ||
| 405 | pr_notice("OOM in bsalg (%d)\n", __LINE__); | ||
| 406 | return 0; | 404 | return 0; |
| 407 | } | ||
| 408 | 405 | ||
| 409 | ptr = *octets; | 406 | ptr = *octets; |
| 410 | while (ctx->pointer < eoc) { | 407 | while (ctx->pointer < eoc) { |
| @@ -451,11 +448,8 @@ static unsigned char asn1_oid_decode(struct asn1_ctx *ctx, | |||
| 451 | return 0; | 448 | return 0; |
| 452 | 449 | ||
| 453 | *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); | 450 | *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); |
| 454 | if (*oid == NULL) { | 451 | if (*oid == NULL) |
| 455 | if (net_ratelimit()) | ||
| 456 | pr_notice("OOM in bsalg (%d)\n", __LINE__); | ||
| 457 | return 0; | 452 | return 0; |
| 458 | } | ||
| 459 | 453 | ||
| 460 | optr = *oid; | 454 | optr = *oid; |
| 461 | 455 | ||
| @@ -728,8 +722,6 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx, | |||
| 728 | *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); | 722 | *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); |
| 729 | if (*obj == NULL) { | 723 | if (*obj == NULL) { |
| 730 | kfree(id); | 724 | kfree(id); |
| 731 | if (net_ratelimit()) | ||
| 732 | pr_notice("OOM in bsalg (%d)\n", __LINE__); | ||
| 733 | return 0; | 725 | return 0; |
| 734 | } | 726 | } |
| 735 | (*obj)->syntax.l[0] = l; | 727 | (*obj)->syntax.l[0] = l; |
| @@ -744,8 +736,6 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx, | |||
| 744 | if (*obj == NULL) { | 736 | if (*obj == NULL) { |
| 745 | kfree(p); | 737 | kfree(p); |
| 746 | kfree(id); | 738 | kfree(id); |
| 747 | if (net_ratelimit()) | ||
| 748 | pr_notice("OOM in bsalg (%d)\n", __LINE__); | ||
| 749 | return 0; | 739 | return 0; |
| 750 | } | 740 | } |
| 751 | memcpy((*obj)->syntax.c, p, len); | 741 | memcpy((*obj)->syntax.c, p, len); |
| @@ -759,8 +749,6 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx, | |||
| 759 | *obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC); | 749 | *obj = kmalloc(sizeof(struct snmp_object), GFP_ATOMIC); |
| 760 | if (*obj == NULL) { | 750 | if (*obj == NULL) { |
| 761 | kfree(id); | 751 | kfree(id); |
| 762 | if (net_ratelimit()) | ||
| 763 | pr_notice("OOM in bsalg (%d)\n", __LINE__); | ||
| 764 | return 0; | 752 | return 0; |
| 765 | } | 753 | } |
| 766 | if (!asn1_null_decode(ctx, end)) { | 754 | if (!asn1_null_decode(ctx, end)) { |
| @@ -780,8 +768,6 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx, | |||
| 780 | if (*obj == NULL) { | 768 | if (*obj == NULL) { |
| 781 | kfree(lp); | 769 | kfree(lp); |
| 782 | kfree(id); | 770 | kfree(id); |
| 783 | if (net_ratelimit()) | ||
| 784 | pr_notice("OOM in bsalg (%d)\n", __LINE__); | ||
| 785 | return 0; | 771 | return 0; |
| 786 | } | 772 | } |
| 787 | memcpy((*obj)->syntax.ul, lp, len); | 773 | memcpy((*obj)->syntax.ul, lp, len); |
| @@ -801,8 +787,6 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx, | |||
| 801 | if (*obj == NULL) { | 787 | if (*obj == NULL) { |
| 802 | kfree(p); | 788 | kfree(p); |
| 803 | kfree(id); | 789 | kfree(id); |
| 804 | if (net_ratelimit()) | ||
| 805 | pr_notice("OOM in bsalg (%d)\n", __LINE__); | ||
| 806 | return 0; | 790 | return 0; |
| 807 | } | 791 | } |
| 808 | memcpy((*obj)->syntax.uc, p, len); | 792 | memcpy((*obj)->syntax.uc, p, len); |
| @@ -819,8 +803,6 @@ static unsigned char snmp_object_decode(struct asn1_ctx *ctx, | |||
| 819 | *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); | 803 | *obj = kmalloc(sizeof(struct snmp_object) + len, GFP_ATOMIC); |
| 820 | if (*obj == NULL) { | 804 | if (*obj == NULL) { |
| 821 | kfree(id); | 805 | kfree(id); |
| 822 | if (net_ratelimit()) | ||
| 823 | pr_notice("OOM in bsalg (%d)\n", __LINE__); | ||
| 824 | return 0; | 806 | return 0; |
| 825 | } | 807 | } |
| 826 | (*obj)->syntax.ul[0] = ul; | 808 | (*obj)->syntax.ul[0] = ul; |
| @@ -1310,7 +1292,7 @@ static int __init nf_nat_snmp_basic_init(void) | |||
| 1310 | int ret = 0; | 1292 | int ret = 0; |
| 1311 | 1293 | ||
| 1312 | BUG_ON(nf_nat_snmp_hook != NULL); | 1294 | BUG_ON(nf_nat_snmp_hook != NULL); |
| 1313 | rcu_assign_pointer(nf_nat_snmp_hook, help); | 1295 | RCU_INIT_POINTER(nf_nat_snmp_hook, help); |
| 1314 | 1296 | ||
| 1315 | ret = nf_conntrack_helper_register(&snmp_trap_helper); | 1297 | ret = nf_conntrack_helper_register(&snmp_trap_helper); |
| 1316 | if (ret < 0) { | 1298 | if (ret < 0) { |
| @@ -1322,7 +1304,7 @@ static int __init nf_nat_snmp_basic_init(void) | |||
| 1322 | 1304 | ||
| 1323 | static void __exit nf_nat_snmp_basic_fini(void) | 1305 | static void __exit nf_nat_snmp_basic_fini(void) |
| 1324 | { | 1306 | { |
| 1325 | rcu_assign_pointer(nf_nat_snmp_hook, NULL); | 1307 | RCU_INIT_POINTER(nf_nat_snmp_hook, NULL); |
| 1326 | nf_conntrack_helper_unregister(&snmp_trap_helper); | 1308 | nf_conntrack_helper_unregister(&snmp_trap_helper); |
| 1327 | } | 1309 | } |
| 1328 | 1310 | ||
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/ping.c b/net/ipv4/ping.c index 39b403f854c6..43d4c3b22369 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c | |||
| @@ -39,6 +39,7 @@ | |||
| 39 | #include <net/protocol.h> | 39 | #include <net/protocol.h> |
| 40 | #include <linux/skbuff.h> | 40 | #include <linux/skbuff.h> |
| 41 | #include <linux/proc_fs.h> | 41 | #include <linux/proc_fs.h> |
| 42 | #include <linux/export.h> | ||
| 42 | #include <net/sock.h> | 43 | #include <net/sock.h> |
| 43 | #include <net/ping.h> | 44 | #include <net/ping.h> |
| 44 | #include <net/udp.h> | 45 | #include <net/udp.h> |
| @@ -338,7 +339,6 @@ void ping_err(struct sk_buff *skb, u32 info) | |||
| 338 | sk = ping_v4_lookup(net, iph->daddr, iph->saddr, | 339 | sk = ping_v4_lookup(net, iph->daddr, iph->saddr, |
| 339 | ntohs(icmph->un.echo.id), skb->dev->ifindex); | 340 | ntohs(icmph->un.echo.id), skb->dev->ifindex); |
| 340 | if (sk == NULL) { | 341 | if (sk == NULL) { |
| 341 | ICMP_INC_STATS_BH(net, ICMP_MIB_INERRORS); | ||
| 342 | pr_debug("no socket, dropping\n"); | 342 | pr_debug("no socket, dropping\n"); |
| 343 | return; /* No socket for error */ | 343 | return; /* No socket for error */ |
| 344 | } | 344 | } |
| @@ -678,7 +678,6 @@ static int ping_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 678 | pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", | 678 | pr_debug("ping_queue_rcv_skb(sk=%p,sk->num=%d,skb=%p)\n", |
| 679 | inet_sk(sk), inet_sk(sk)->inet_num, skb); | 679 | inet_sk(sk), inet_sk(sk)->inet_num, skb); |
| 680 | if (sock_queue_rcv_skb(sk, skb) < 0) { | 680 | if (sock_queue_rcv_skb(sk, skb) < 0) { |
| 681 | ICMP_INC_STATS_BH(sock_net(sk), ICMP_MIB_INERRORS); | ||
| 682 | kfree_skb(skb); | 681 | kfree_skb(skb); |
| 683 | pr_debug("ping_queue_rcv_skb -> failed\n"); | 682 | pr_debug("ping_queue_rcv_skb -> failed\n"); |
| 684 | return -1; | 683 | return -1; |
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index b14ec7d03b6e..466ea8bb7a4d 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #include <linux/inetdevice.h> | 42 | #include <linux/inetdevice.h> |
| 43 | #include <linux/proc_fs.h> | 43 | #include <linux/proc_fs.h> |
| 44 | #include <linux/seq_file.h> | 44 | #include <linux/seq_file.h> |
| 45 | #include <linux/export.h> | ||
| 45 | #include <net/sock.h> | 46 | #include <net/sock.h> |
| 46 | #include <net/raw.h> | 47 | #include <net/raw.h> |
| 47 | 48 | ||
| @@ -254,6 +255,8 @@ static const struct snmp_mib snmp4_net_list[] = { | |||
| 254 | SNMP_MIB_ITEM("TCPDeferAcceptDrop", LINUX_MIB_TCPDEFERACCEPTDROP), | 255 | SNMP_MIB_ITEM("TCPDeferAcceptDrop", LINUX_MIB_TCPDEFERACCEPTDROP), |
| 255 | SNMP_MIB_ITEM("IPReversePathFilter", LINUX_MIB_IPRPFILTER), | 256 | SNMP_MIB_ITEM("IPReversePathFilter", LINUX_MIB_IPRPFILTER), |
| 256 | SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW), | 257 | SNMP_MIB_ITEM("TCPTimeWaitOverflow", LINUX_MIB_TCPTIMEWAITOVERFLOW), |
| 258 | SNMP_MIB_ITEM("TCPReqQFullDoCookies", LINUX_MIB_TCPREQQFULLDOCOOKIES), | ||
| 259 | SNMP_MIB_ITEM("TCPReqQFullDrop", LINUX_MIB_TCPREQQFULLDROP), | ||
| 257 | SNMP_MIB_SENTINEL | 260 | SNMP_MIB_SENTINEL |
| 258 | }; | 261 | }; |
| 259 | 262 | ||
diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c index 61714bd52925..007e2eb769d3 100644 --- a/net/ipv4/raw.c +++ b/net/ipv4/raw.c | |||
| @@ -48,6 +48,7 @@ | |||
| 48 | #include <linux/errno.h> | 48 | #include <linux/errno.h> |
| 49 | #include <linux/aio.h> | 49 | #include <linux/aio.h> |
| 50 | #include <linux/kernel.h> | 50 | #include <linux/kernel.h> |
| 51 | #include <linux/export.h> | ||
| 51 | #include <linux/spinlock.h> | 52 | #include <linux/spinlock.h> |
| 52 | #include <linux/sockios.h> | 53 | #include <linux/sockios.h> |
| 53 | #include <linux/socket.h> | 54 | #include <linux/socket.h> |
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 075212e41b83..0c74da8a0473 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 | ||
| @@ -1305,11 +1304,42 @@ static void rt_del(unsigned hash, struct rtable *rt) | |||
| 1305 | spin_unlock_bh(rt_hash_lock_addr(hash)); | 1304 | spin_unlock_bh(rt_hash_lock_addr(hash)); |
| 1306 | } | 1305 | } |
| 1307 | 1306 | ||
| 1307 | static int check_peer_redir(struct dst_entry *dst, struct inet_peer *peer) | ||
| 1308 | { | ||
| 1309 | struct rtable *rt = (struct rtable *) dst; | ||
| 1310 | __be32 orig_gw = rt->rt_gateway; | ||
| 1311 | struct neighbour *n, *old_n; | ||
| 1312 | |||
| 1313 | dst_confirm(&rt->dst); | ||
| 1314 | |||
| 1315 | rt->rt_gateway = peer->redirect_learned.a4; | ||
| 1316 | |||
| 1317 | n = ipv4_neigh_lookup(&rt->dst, &rt->rt_gateway); | ||
| 1318 | if (IS_ERR(n)) | ||
| 1319 | return PTR_ERR(n); | ||
| 1320 | old_n = xchg(&rt->dst._neighbour, n); | ||
| 1321 | if (old_n) | ||
| 1322 | neigh_release(old_n); | ||
| 1323 | if (!n || !(n->nud_state & NUD_VALID)) { | ||
| 1324 | if (n) | ||
| 1325 | neigh_event_send(n, NULL); | ||
| 1326 | rt->rt_gateway = orig_gw; | ||
| 1327 | return -EAGAIN; | ||
| 1328 | } else { | ||
| 1329 | rt->rt_flags |= RTCF_REDIRECTED; | ||
| 1330 | call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, n); | ||
| 1331 | } | ||
| 1332 | return 0; | ||
| 1333 | } | ||
| 1334 | |||
| 1308 | /* called in rcu_read_lock() section */ | 1335 | /* called in rcu_read_lock() section */ |
| 1309 | void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, | 1336 | void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, |
| 1310 | __be32 saddr, struct net_device *dev) | 1337 | __be32 saddr, struct net_device *dev) |
| 1311 | { | 1338 | { |
| 1339 | int s, i; | ||
| 1312 | struct in_device *in_dev = __in_dev_get_rcu(dev); | 1340 | struct in_device *in_dev = __in_dev_get_rcu(dev); |
| 1341 | __be32 skeys[2] = { saddr, 0 }; | ||
| 1342 | int ikeys[2] = { dev->ifindex, 0 }; | ||
| 1313 | struct inet_peer *peer; | 1343 | struct inet_peer *peer; |
| 1314 | struct net *net; | 1344 | struct net *net; |
| 1315 | 1345 | ||
| @@ -1332,13 +1362,43 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw, | |||
| 1332 | goto reject_redirect; | 1362 | goto reject_redirect; |
| 1333 | } | 1363 | } |
| 1334 | 1364 | ||
| 1335 | peer = inet_getpeer_v4(daddr, 1); | 1365 | for (s = 0; s < 2; s++) { |
| 1336 | if (peer) { | 1366 | for (i = 0; i < 2; i++) { |
| 1337 | peer->redirect_learned.a4 = new_gw; | 1367 | unsigned int hash; |
| 1368 | struct rtable __rcu **rthp; | ||
| 1369 | struct rtable *rt; | ||
| 1338 | 1370 | ||
| 1339 | inet_putpeer(peer); | 1371 | hash = rt_hash(daddr, skeys[s], ikeys[i], rt_genid(net)); |
| 1372 | |||
| 1373 | rthp = &rt_hash_table[hash].chain; | ||
| 1340 | 1374 | ||
| 1341 | atomic_inc(&__rt_peer_genid); | 1375 | while ((rt = rcu_dereference(*rthp)) != NULL) { |
| 1376 | rthp = &rt->dst.rt_next; | ||
| 1377 | |||
| 1378 | if (rt->rt_key_dst != daddr || | ||
| 1379 | rt->rt_key_src != skeys[s] || | ||
| 1380 | rt->rt_oif != ikeys[i] || | ||
| 1381 | rt_is_input_route(rt) || | ||
| 1382 | rt_is_expired(rt) || | ||
| 1383 | !net_eq(dev_net(rt->dst.dev), net) || | ||
| 1384 | rt->dst.error || | ||
| 1385 | rt->dst.dev != dev || | ||
| 1386 | rt->rt_gateway != old_gw) | ||
| 1387 | continue; | ||
| 1388 | |||
| 1389 | if (!rt->peer) | ||
| 1390 | rt_bind_peer(rt, rt->rt_dst, 1); | ||
| 1391 | |||
| 1392 | peer = rt->peer; | ||
| 1393 | if (peer) { | ||
| 1394 | if (peer->redirect_learned.a4 != new_gw) { | ||
| 1395 | peer->redirect_learned.a4 = new_gw; | ||
| 1396 | atomic_inc(&__rt_peer_genid); | ||
| 1397 | } | ||
| 1398 | check_peer_redir(&rt->dst, peer); | ||
| 1399 | } | ||
| 1400 | } | ||
| 1401 | } | ||
| 1342 | } | 1402 | } |
| 1343 | return; | 1403 | return; |
| 1344 | 1404 | ||
| @@ -1568,11 +1628,10 @@ unsigned short ip_rt_frag_needed(struct net *net, const struct iphdr *iph, | |||
| 1568 | est_mtu = mtu; | 1628 | est_mtu = mtu; |
| 1569 | peer->pmtu_learned = mtu; | 1629 | peer->pmtu_learned = mtu; |
| 1570 | peer->pmtu_expires = pmtu_expires; | 1630 | peer->pmtu_expires = pmtu_expires; |
| 1631 | atomic_inc(&__rt_peer_genid); | ||
| 1571 | } | 1632 | } |
| 1572 | 1633 | ||
| 1573 | inet_putpeer(peer); | 1634 | inet_putpeer(peer); |
| 1574 | |||
| 1575 | atomic_inc(&__rt_peer_genid); | ||
| 1576 | } | 1635 | } |
| 1577 | return est_mtu ? : new_mtu; | 1636 | return est_mtu ? : new_mtu; |
| 1578 | } | 1637 | } |
| @@ -1625,33 +1684,6 @@ static void ip_rt_update_pmtu(struct dst_entry *dst, u32 mtu) | |||
| 1625 | } | 1684 | } |
| 1626 | } | 1685 | } |
| 1627 | 1686 | ||
| 1628 | static int check_peer_redir(struct dst_entry *dst, struct inet_peer *peer) | ||
| 1629 | { | ||
| 1630 | struct rtable *rt = (struct rtable *) dst; | ||
| 1631 | __be32 orig_gw = rt->rt_gateway; | ||
| 1632 | struct neighbour *n, *old_n; | ||
| 1633 | |||
| 1634 | dst_confirm(&rt->dst); | ||
| 1635 | |||
| 1636 | rt->rt_gateway = peer->redirect_learned.a4; | ||
| 1637 | |||
| 1638 | n = ipv4_neigh_lookup(&rt->dst, &rt->rt_gateway); | ||
| 1639 | if (IS_ERR(n)) | ||
| 1640 | return PTR_ERR(n); | ||
| 1641 | old_n = xchg(&rt->dst._neighbour, n); | ||
| 1642 | if (old_n) | ||
| 1643 | neigh_release(old_n); | ||
| 1644 | if (!n || !(n->nud_state & NUD_VALID)) { | ||
| 1645 | if (n) | ||
| 1646 | neigh_event_send(n, NULL); | ||
| 1647 | rt->rt_gateway = orig_gw; | ||
| 1648 | return -EAGAIN; | ||
| 1649 | } else { | ||
| 1650 | rt->rt_flags |= RTCF_REDIRECTED; | ||
| 1651 | call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, n); | ||
| 1652 | } | ||
| 1653 | return 0; | ||
| 1654 | } | ||
| 1655 | 1687 | ||
| 1656 | static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie) | 1688 | static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie) |
| 1657 | { | 1689 | { |
| @@ -2821,7 +2853,7 @@ static int rt_fill_info(struct net *net, | |||
| 2821 | struct rtable *rt = skb_rtable(skb); | 2853 | struct rtable *rt = skb_rtable(skb); |
| 2822 | struct rtmsg *r; | 2854 | struct rtmsg *r; |
| 2823 | struct nlmsghdr *nlh; | 2855 | struct nlmsghdr *nlh; |
| 2824 | long expires = 0; | 2856 | unsigned long expires = 0; |
| 2825 | const struct inet_peer *peer = rt->peer; | 2857 | const struct inet_peer *peer = rt->peer; |
| 2826 | u32 id = 0, ts = 0, tsage = 0, error; | 2858 | u32 id = 0, ts = 0, tsage = 0, error; |
| 2827 | 2859 | ||
| @@ -2878,8 +2910,12 @@ static int rt_fill_info(struct net *net, | |||
| 2878 | tsage = get_seconds() - peer->tcp_ts_stamp; | 2910 | tsage = get_seconds() - peer->tcp_ts_stamp; |
| 2879 | } | 2911 | } |
| 2880 | expires = ACCESS_ONCE(peer->pmtu_expires); | 2912 | expires = ACCESS_ONCE(peer->pmtu_expires); |
| 2881 | if (expires) | 2913 | if (expires) { |
| 2882 | expires -= jiffies; | 2914 | if (time_before(jiffies, expires)) |
| 2915 | expires -= jiffies; | ||
| 2916 | else | ||
| 2917 | expires = 0; | ||
| 2918 | } | ||
| 2883 | } | 2919 | } |
| 2884 | 2920 | ||
| 2885 | if (rt_is_input_route(rt)) { | 2921 | if (rt_is_input_route(rt)) { |
| @@ -3121,13 +3157,6 @@ static ctl_table ipv4_route_table[] = { | |||
| 3121 | .proc_handler = proc_dointvec_jiffies, | 3157 | .proc_handler = proc_dointvec_jiffies, |
| 3122 | }, | 3158 | }, |
| 3123 | { | 3159 | { |
| 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", | 3160 | .procname = "redirect_load", |
| 3132 | .data = &ip_rt_redirect_load, | 3161 | .data = &ip_rt_redirect_load, |
| 3133 | .maxlen = sizeof(int), | 3162 | .maxlen = sizeof(int), |
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c index 3bc5c8f7c71b..90f6544c13e2 100644 --- a/net/ipv4/syncookies.c +++ b/net/ipv4/syncookies.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/random.h> | 15 | #include <linux/random.h> |
| 16 | #include <linux/cryptohash.h> | 16 | #include <linux/cryptohash.h> |
| 17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/export.h> | ||
| 18 | #include <net/tcp.h> | 19 | #include <net/tcp.h> |
| 19 | #include <net/route.h> | 20 | #include <net/route.h> |
| 20 | 21 | ||
| @@ -265,7 +266,7 @@ struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, | |||
| 265 | struct ip_options *opt) | 266 | struct ip_options *opt) |
| 266 | { | 267 | { |
| 267 | struct tcp_options_received tcp_opt; | 268 | struct tcp_options_received tcp_opt; |
| 268 | u8 *hash_location; | 269 | const u8 *hash_location; |
| 269 | struct inet_request_sock *ireq; | 270 | struct inet_request_sock *ireq; |
| 270 | struct tcp_request_sock *treq; | 271 | struct tcp_request_sock *treq; |
| 271 | struct tcp_sock *tp = tcp_sk(sk); | 272 | 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 ea0d2183df4b..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 | ||
| @@ -1124,7 +1136,7 @@ static int tcp_is_sackblock_valid(struct tcp_sock *tp, int is_dsack, | |||
| 1124 | return 0; | 1136 | return 0; |
| 1125 | 1137 | ||
| 1126 | /* ...Then it's D-SACK, and must reside below snd_una completely */ | 1138 | /* ...Then it's D-SACK, and must reside below snd_una completely */ |
| 1127 | if (!after(end_seq, tp->snd_una)) | 1139 | if (after(end_seq, tp->snd_una)) |
| 1128 | return 0; | 1140 | return 0; |
| 1129 | 1141 | ||
| 1130 | if (!before(start_seq, tp->undo_marker)) | 1142 | if (!before(start_seq, tp->undo_marker)) |
| @@ -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 | { |
| @@ -1389,9 +1401,7 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | |||
| 1389 | 1401 | ||
| 1390 | BUG_ON(!pcount); | 1402 | BUG_ON(!pcount); |
| 1391 | 1403 | ||
| 1392 | /* Tweak before seqno plays */ | 1404 | if (skb == tp->lost_skb_hint) |
| 1393 | if (!tcp_is_fack(tp) && tcp_is_sack(tp) && tp->lost_skb_hint && | ||
| 1394 | !before(TCP_SKB_CB(tp->lost_skb_hint)->seq, TCP_SKB_CB(skb)->seq)) | ||
| 1395 | tp->lost_cnt_hint += pcount; | 1405 | tp->lost_cnt_hint += pcount; |
| 1396 | 1406 | ||
| 1397 | TCP_SKB_CB(prev)->end_seq += shifted; | 1407 | TCP_SKB_CB(prev)->end_seq += shifted; |
| @@ -1440,7 +1450,7 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | |||
| 1440 | tp->lost_cnt_hint -= tcp_skb_pcount(prev); | 1450 | tp->lost_cnt_hint -= tcp_skb_pcount(prev); |
| 1441 | } | 1451 | } |
| 1442 | 1452 | ||
| 1443 | TCP_SKB_CB(skb)->flags |= TCP_SKB_CB(prev)->flags; | 1453 | TCP_SKB_CB(skb)->tcp_flags |= TCP_SKB_CB(prev)->tcp_flags; |
| 1444 | if (skb == tcp_highest_sack(sk)) | 1454 | if (skb == tcp_highest_sack(sk)) |
| 1445 | tcp_advance_highest_sack(sk, skb); | 1455 | tcp_advance_highest_sack(sk, skb); |
| 1446 | 1456 | ||
| @@ -1455,13 +1465,13 @@ static int tcp_shifted_skb(struct sock *sk, struct sk_buff *skb, | |||
| 1455 | /* 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 |
| 1456 | * something-or-zero which complicates things | 1466 | * something-or-zero which complicates things |
| 1457 | */ | 1467 | */ |
| 1458 | static int tcp_skb_seglen(struct sk_buff *skb) | 1468 | static int tcp_skb_seglen(const struct sk_buff *skb) |
| 1459 | { | 1469 | { |
| 1460 | 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); |
| 1461 | } | 1471 | } |
| 1462 | 1472 | ||
| 1463 | /* Shifting pages past head area doesn't work */ | 1473 | /* Shifting pages past head area doesn't work */ |
| 1464 | static int skb_can_shift(struct sk_buff *skb) | 1474 | static int skb_can_shift(const struct sk_buff *skb) |
| 1465 | { | 1475 | { |
| 1466 | return !skb_headlen(skb) && skb_is_nonlinear(skb); | 1476 | return !skb_headlen(skb) && skb_is_nonlinear(skb); |
| 1467 | } | 1477 | } |
| @@ -1710,19 +1720,19 @@ static struct sk_buff *tcp_maybe_skipping_dsack(struct sk_buff *skb, | |||
| 1710 | return skb; | 1720 | return skb; |
| 1711 | } | 1721 | } |
| 1712 | 1722 | ||
| 1713 | 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) |
| 1714 | { | 1724 | { |
| 1715 | 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); |
| 1716 | } | 1726 | } |
| 1717 | 1727 | ||
| 1718 | static int | 1728 | static int |
| 1719 | 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, |
| 1720 | u32 prior_snd_una) | 1730 | u32 prior_snd_una) |
| 1721 | { | 1731 | { |
| 1722 | const struct inet_connection_sock *icsk = inet_csk(sk); | 1732 | const struct inet_connection_sock *icsk = inet_csk(sk); |
| 1723 | struct tcp_sock *tp = tcp_sk(sk); | 1733 | struct tcp_sock *tp = tcp_sk(sk); |
| 1724 | unsigned char *ptr = (skb_transport_header(ack_skb) + | 1734 | const unsigned char *ptr = (skb_transport_header(ack_skb) + |
| 1725 | TCP_SKB_CB(ack_skb)->sacked); | 1735 | TCP_SKB_CB(ack_skb)->sacked); |
| 1726 | 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); |
| 1727 | struct tcp_sack_block sp[TCP_NUM_SACKS]; | 1737 | struct tcp_sack_block sp[TCP_NUM_SACKS]; |
| 1728 | struct tcp_sack_block *cache; | 1738 | struct tcp_sack_block *cache; |
| @@ -2286,7 +2296,7 @@ static int tcp_check_sack_reneging(struct sock *sk, int flag) | |||
| 2286 | return 0; | 2296 | return 0; |
| 2287 | } | 2297 | } |
| 2288 | 2298 | ||
| 2289 | static inline int tcp_fackets_out(struct tcp_sock *tp) | 2299 | static inline int tcp_fackets_out(const struct tcp_sock *tp) |
| 2290 | { | 2300 | { |
| 2291 | 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; |
| 2292 | } | 2302 | } |
| @@ -2306,19 +2316,20 @@ static inline int tcp_fackets_out(struct tcp_sock *tp) | |||
| 2306 | * they differ. Since neither occurs due to loss, TCP should really | 2316 | * they differ. Since neither occurs due to loss, TCP should really |
| 2307 | * ignore them. | 2317 | * ignore them. |
| 2308 | */ | 2318 | */ |
| 2309 | static inline int tcp_dupack_heuristics(struct tcp_sock *tp) | 2319 | static inline int tcp_dupack_heuristics(const struct tcp_sock *tp) |
| 2310 | { | 2320 | { |
| 2311 | 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; |
| 2312 | } | 2322 | } |
| 2313 | 2323 | ||
| 2314 | 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) | ||
| 2315 | { | 2326 | { |
| 2316 | 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; |
| 2317 | } | 2328 | } |
| 2318 | 2329 | ||
| 2319 | static inline int tcp_head_timedout(struct sock *sk) | 2330 | static inline int tcp_head_timedout(const struct sock *sk) |
| 2320 | { | 2331 | { |
| 2321 | struct tcp_sock *tp = tcp_sk(sk); | 2332 | const struct tcp_sock *tp = tcp_sk(sk); |
| 2322 | 2333 | ||
| 2323 | return tp->packets_out && | 2334 | return tp->packets_out && |
| 2324 | tcp_skb_timedout(sk, tcp_write_queue_head(sk)); | 2335 | tcp_skb_timedout(sk, tcp_write_queue_head(sk)); |
| @@ -2629,7 +2640,7 @@ static void tcp_cwnd_down(struct sock *sk, int flag) | |||
| 2629 | /* Nothing was retransmitted or returned timestamp is less | 2640 | /* Nothing was retransmitted or returned timestamp is less |
| 2630 | * than timestamp of the first retransmission. | 2641 | * than timestamp of the first retransmission. |
| 2631 | */ | 2642 | */ |
| 2632 | static inline int tcp_packet_delayed(struct tcp_sock *tp) | 2643 | static inline int tcp_packet_delayed(const struct tcp_sock *tp) |
| 2633 | { | 2644 | { |
| 2634 | return !tp->retrans_stamp || | 2645 | return !tp->retrans_stamp || |
| 2635 | (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && | 2646 | (tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && |
| @@ -2690,7 +2701,7 @@ static void tcp_undo_cwr(struct sock *sk, const bool undo_ssthresh) | |||
| 2690 | tp->snd_cwnd_stamp = tcp_time_stamp; | 2701 | tp->snd_cwnd_stamp = tcp_time_stamp; |
| 2691 | } | 2702 | } |
| 2692 | 2703 | ||
| 2693 | static inline int tcp_may_undo(struct tcp_sock *tp) | 2704 | static inline int tcp_may_undo(const struct tcp_sock *tp) |
| 2694 | { | 2705 | { |
| 2695 | return tp->undo_marker && (!tp->undo_retrans || tcp_packet_delayed(tp)); | 2706 | return tp->undo_marker && (!tp->undo_retrans || tcp_packet_delayed(tp)); |
| 2696 | } | 2707 | } |
| @@ -2754,9 +2765,9 @@ static void tcp_try_undo_dsack(struct sock *sk) | |||
| 2754 | * that successive retransmissions of a segment must not advance | 2765 | * that successive retransmissions of a segment must not advance |
| 2755 | * retrans_stamp under any conditions. | 2766 | * retrans_stamp under any conditions. |
| 2756 | */ | 2767 | */ |
| 2757 | static int tcp_any_retrans_done(struct sock *sk) | 2768 | static int tcp_any_retrans_done(const struct sock *sk) |
| 2758 | { | 2769 | { |
| 2759 | struct tcp_sock *tp = tcp_sk(sk); | 2770 | const struct tcp_sock *tp = tcp_sk(sk); |
| 2760 | struct sk_buff *skb; | 2771 | struct sk_buff *skb; |
| 2761 | 2772 | ||
| 2762 | if (tp->retrans_out) | 2773 | if (tp->retrans_out) |
| @@ -2830,9 +2841,13 @@ static int tcp_try_undo_loss(struct sock *sk) | |||
| 2830 | static inline void tcp_complete_cwr(struct sock *sk) | 2841 | static inline void tcp_complete_cwr(struct sock *sk) |
| 2831 | { | 2842 | { |
| 2832 | struct tcp_sock *tp = tcp_sk(sk); | 2843 | struct tcp_sock *tp = tcp_sk(sk); |
| 2833 | /* Do not moderate cwnd if it's already undone in cwr or recovery */ | 2844 | |
| 2834 | if (tp->undo_marker && tp->snd_cwnd > tp->snd_ssthresh) { | 2845 | /* Do not moderate cwnd if it's already undone in cwr or recovery. */ |
| 2835 | 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; | ||
| 2836 | tp->snd_cwnd_stamp = tcp_time_stamp; | 2851 | tp->snd_cwnd_stamp = tcp_time_stamp; |
| 2837 | } | 2852 | } |
| 2838 | tcp_ca_event(sk, CA_EVENT_COMPLETE_CWR); | 2853 | tcp_ca_event(sk, CA_EVENT_COMPLETE_CWR); |
| @@ -2950,6 +2965,38 @@ void tcp_simple_retransmit(struct sock *sk) | |||
| 2950 | } | 2965 | } |
| 2951 | EXPORT_SYMBOL(tcp_simple_retransmit); | 2966 | EXPORT_SYMBOL(tcp_simple_retransmit); |
| 2952 | 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 | |||
| 2953 | /* Process an event, which can update packets-in-flight not trivially. | 3000 | /* Process an event, which can update packets-in-flight not trivially. |
| 2954 | * 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, |
| 2955 | * taking into account both packets sitting in receiver's buffer and | 3002 | * taking into account both packets sitting in receiver's buffer and |
| @@ -2961,7 +3008,8 @@ EXPORT_SYMBOL(tcp_simple_retransmit); | |||
| 2961 | * 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 |
| 2962 | * tcp_xmit_retransmit_queue(). | 3009 | * tcp_xmit_retransmit_queue(). |
| 2963 | */ | 3010 | */ |
| 2964 | 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) | ||
| 2965 | { | 3013 | { |
| 2966 | struct inet_connection_sock *icsk = inet_csk(sk); | 3014 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 2967 | struct tcp_sock *tp = tcp_sk(sk); | 3015 | struct tcp_sock *tp = tcp_sk(sk); |
| @@ -3111,13 +3159,17 @@ static void tcp_fastretrans_alert(struct sock *sk, int pkts_acked, int flag) | |||
| 3111 | 3159 | ||
| 3112 | tp->bytes_acked = 0; | 3160 | tp->bytes_acked = 0; |
| 3113 | 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; | ||
| 3114 | tcp_set_ca_state(sk, TCP_CA_Recovery); | 3165 | tcp_set_ca_state(sk, TCP_CA_Recovery); |
| 3115 | fast_rexmit = 1; | 3166 | fast_rexmit = 1; |
| 3116 | } | 3167 | } |
| 3117 | 3168 | ||
| 3118 | if (do_lost || (tcp_is_fack(tp) && tcp_head_timedout(sk))) | 3169 | if (do_lost || (tcp_is_fack(tp) && tcp_head_timedout(sk))) |
| 3119 | tcp_update_scoreboard(sk, fast_rexmit); | 3170 | tcp_update_scoreboard(sk, fast_rexmit); |
| 3120 | 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); | ||
| 3121 | tcp_xmit_retransmit_queue(sk); | 3173 | tcp_xmit_retransmit_queue(sk); |
| 3122 | } | 3174 | } |
| 3123 | 3175 | ||
| @@ -3194,7 +3246,7 @@ static void tcp_cong_avoid(struct sock *sk, u32 ack, u32 in_flight) | |||
| 3194 | */ | 3246 | */ |
| 3195 | static void tcp_rearm_rto(struct sock *sk) | 3247 | static void tcp_rearm_rto(struct sock *sk) |
| 3196 | { | 3248 | { |
| 3197 | struct tcp_sock *tp = tcp_sk(sk); | 3249 | const struct tcp_sock *tp = tcp_sk(sk); |
| 3198 | 3250 | ||
| 3199 | if (!tp->packets_out) { | 3251 | if (!tp->packets_out) { |
| 3200 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); | 3252 | inet_csk_clear_xmit_timer(sk, ICSK_TIME_RETRANS); |
| @@ -3298,7 +3350,7 @@ static int tcp_clean_rtx_queue(struct sock *sk, int prior_fackets, | |||
| 3298 | * connection startup slow start one packet too | 3350 | * connection startup slow start one packet too |
| 3299 | * quickly. This is severely frowned upon behavior. | 3351 | * quickly. This is severely frowned upon behavior. |
| 3300 | */ | 3352 | */ |
| 3301 | if (!(scb->flags & TCPHDR_SYN)) { | 3353 | if (!(scb->tcp_flags & TCPHDR_SYN)) { |
| 3302 | flag |= FLAG_DATA_ACKED; | 3354 | flag |= FLAG_DATA_ACKED; |
| 3303 | } else { | 3355 | } else { |
| 3304 | flag |= FLAG_SYN_ACKED; | 3356 | flag |= FLAG_SYN_ACKED; |
| @@ -3446,7 +3498,7 @@ static inline int tcp_may_update_window(const struct tcp_sock *tp, | |||
| 3446 | * 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 |
| 3447 | * and in FreeBSD. NetBSD's one is even worse.) is wrong. | 3499 | * and in FreeBSD. NetBSD's one is even worse.) is wrong. |
| 3448 | */ | 3500 | */ |
| 3449 | 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, |
| 3450 | u32 ack_seq) | 3502 | u32 ack_seq) |
| 3451 | { | 3503 | { |
| 3452 | struct tcp_sock *tp = tcp_sk(sk); | 3504 | struct tcp_sock *tp = tcp_sk(sk); |
| @@ -3622,7 +3674,7 @@ static int tcp_process_frto(struct sock *sk, int flag) | |||
| 3622 | } | 3674 | } |
| 3623 | 3675 | ||
| 3624 | /* This routine deals with incoming acks, but not outgoing ones. */ | 3676 | /* This routine deals with incoming acks, but not outgoing ones. */ |
| 3625 | 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) |
| 3626 | { | 3678 | { |
| 3627 | struct inet_connection_sock *icsk = inet_csk(sk); | 3679 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 3628 | struct tcp_sock *tp = tcp_sk(sk); | 3680 | struct tcp_sock *tp = tcp_sk(sk); |
| @@ -3632,6 +3684,8 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
| 3632 | u32 prior_in_flight; | 3684 | u32 prior_in_flight; |
| 3633 | u32 prior_fackets; | 3685 | u32 prior_fackets; |
| 3634 | int prior_packets; | 3686 | int prior_packets; |
| 3687 | int prior_sacked = tp->sacked_out; | ||
| 3688 | int newly_acked_sacked = 0; | ||
| 3635 | int frto_cwnd = 0; | 3689 | int frto_cwnd = 0; |
| 3636 | 3690 | ||
| 3637 | /* If the ack is older than previous acks | 3691 | /* If the ack is older than previous acks |
| @@ -3703,6 +3757,9 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
| 3703 | /* See if we can take anything off of the retransmit queue. */ | 3757 | /* See if we can take anything off of the retransmit queue. */ |
| 3704 | flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una); | 3758 | flag |= tcp_clean_rtx_queue(sk, prior_fackets, prior_snd_una); |
| 3705 | 3759 | ||
| 3760 | newly_acked_sacked = (prior_packets - prior_sacked) - | ||
| 3761 | (tp->packets_out - tp->sacked_out); | ||
| 3762 | |||
| 3706 | if (tp->frto_counter) | 3763 | if (tp->frto_counter) |
| 3707 | frto_cwnd = tcp_process_frto(sk, flag); | 3764 | frto_cwnd = tcp_process_frto(sk, flag); |
| 3708 | /* Guarantee sacktag reordering detection against wrap-arounds */ | 3765 | /* Guarantee sacktag reordering detection against wrap-arounds */ |
| @@ -3715,7 +3772,7 @@ static int tcp_ack(struct sock *sk, struct sk_buff *skb, int flag) | |||
| 3715 | tcp_may_raise_cwnd(sk, flag)) | 3772 | tcp_may_raise_cwnd(sk, flag)) |
| 3716 | tcp_cong_avoid(sk, ack, prior_in_flight); | 3773 | tcp_cong_avoid(sk, ack, prior_in_flight); |
| 3717 | tcp_fastretrans_alert(sk, prior_packets - tp->packets_out, | 3774 | tcp_fastretrans_alert(sk, prior_packets - tp->packets_out, |
| 3718 | flag); | 3775 | newly_acked_sacked, flag); |
| 3719 | } else { | 3776 | } else { |
| 3720 | if ((flag & FLAG_DATA_ACKED) && !frto_cwnd) | 3777 | if ((flag & FLAG_DATA_ACKED) && !frto_cwnd) |
| 3721 | tcp_cong_avoid(sk, ack, prior_in_flight); | 3778 | tcp_cong_avoid(sk, ack, prior_in_flight); |
| @@ -3754,14 +3811,14 @@ old_ack: | |||
| 3754 | * 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 |
| 3755 | * the fast version below fails. | 3812 | * the fast version below fails. |
| 3756 | */ | 3813 | */ |
| 3757 | 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, |
| 3758 | u8 **hvpp, int estab) | 3815 | const u8 **hvpp, int estab) |
| 3759 | { | 3816 | { |
| 3760 | unsigned char *ptr; | 3817 | const unsigned char *ptr; |
| 3761 | struct tcphdr *th = tcp_hdr(skb); | 3818 | const struct tcphdr *th = tcp_hdr(skb); |
| 3762 | int length = (th->doff * 4) - sizeof(struct tcphdr); | 3819 | int length = (th->doff * 4) - sizeof(struct tcphdr); |
| 3763 | 3820 | ||
| 3764 | ptr = (unsigned char *)(th + 1); | 3821 | ptr = (const unsigned char *)(th + 1); |
| 3765 | opt_rx->saw_tstamp = 0; | 3822 | opt_rx->saw_tstamp = 0; |
| 3766 | 3823 | ||
| 3767 | while (length > 0) { | 3824 | while (length > 0) { |
| @@ -3872,9 +3929,9 @@ void tcp_parse_options(struct sk_buff *skb, struct tcp_options_received *opt_rx, | |||
| 3872 | } | 3929 | } |
| 3873 | EXPORT_SYMBOL(tcp_parse_options); | 3930 | EXPORT_SYMBOL(tcp_parse_options); |
| 3874 | 3931 | ||
| 3875 | 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) |
| 3876 | { | 3933 | { |
| 3877 | __be32 *ptr = (__be32 *)(th + 1); | 3934 | const __be32 *ptr = (const __be32 *)(th + 1); |
| 3878 | 3935 | ||
| 3879 | if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) | 3936 | if (*ptr == htonl((TCPOPT_NOP << 24) | (TCPOPT_NOP << 16) |
| 3880 | | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { | 3937 | | (TCPOPT_TIMESTAMP << 8) | TCPOLEN_TIMESTAMP)) { |
| @@ -3891,8 +3948,9 @@ static int tcp_parse_aligned_timestamp(struct tcp_sock *tp, struct tcphdr *th) | |||
| 3891 | /* Fast parse options. This hopes to only see timestamps. | 3948 | /* Fast parse options. This hopes to only see timestamps. |
| 3892 | * If it is wrong it falls back on tcp_parse_options(). | 3949 | * If it is wrong it falls back on tcp_parse_options(). |
| 3893 | */ | 3950 | */ |
| 3894 | 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, |
| 3895 | struct tcp_sock *tp, u8 **hvpp) | 3952 | const struct tcphdr *th, |
| 3953 | struct tcp_sock *tp, const u8 **hvpp) | ||
| 3896 | { | 3954 | { |
| 3897 | /* In the spirit of fast parsing, compare doff directly to constant | 3955 | /* In the spirit of fast parsing, compare doff directly to constant |
| 3898 | * values. Because equality is used, short doff can be ignored here. | 3956 | * values. Because equality is used, short doff can be ignored here. |
| @@ -3913,10 +3971,10 @@ static int tcp_fast_parse_options(struct sk_buff *skb, struct tcphdr *th, | |||
| 3913 | /* | 3971 | /* |
| 3914 | * Parse MD5 Signature option | 3972 | * Parse MD5 Signature option |
| 3915 | */ | 3973 | */ |
| 3916 | u8 *tcp_parse_md5sig_option(struct tcphdr *th) | 3974 | const u8 *tcp_parse_md5sig_option(const struct tcphdr *th) |
| 3917 | { | 3975 | { |
| 3918 | int length = (th->doff << 2) - sizeof (*th); | 3976 | int length = (th->doff << 2) - sizeof(*th); |
| 3919 | u8 *ptr = (u8*)(th + 1); | 3977 | const u8 *ptr = (const u8 *)(th + 1); |
| 3920 | 3978 | ||
| 3921 | /* If the TCP option is too short, we can short cut */ | 3979 | /* If the TCP option is too short, we can short cut */ |
| 3922 | if (length < TCPOLEN_MD5SIG) | 3980 | if (length < TCPOLEN_MD5SIG) |
| @@ -3993,8 +4051,8 @@ static inline void tcp_replace_ts_recent(struct tcp_sock *tp, u32 seq) | |||
| 3993 | 4051 | ||
| 3994 | 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) |
| 3995 | { | 4053 | { |
| 3996 | struct tcp_sock *tp = tcp_sk(sk); | 4054 | const struct tcp_sock *tp = tcp_sk(sk); |
| 3997 | struct tcphdr *th = tcp_hdr(skb); | 4055 | const struct tcphdr *th = tcp_hdr(skb); |
| 3998 | u32 seq = TCP_SKB_CB(skb)->seq; | 4056 | u32 seq = TCP_SKB_CB(skb)->seq; |
| 3999 | u32 ack = TCP_SKB_CB(skb)->ack_seq; | 4057 | u32 ack = TCP_SKB_CB(skb)->ack_seq; |
| 4000 | 4058 | ||
| @@ -4033,7 +4091,7 @@ static inline int tcp_paws_discard(const struct sock *sk, | |||
| 4033 | * (borrowed from freebsd) | 4091 | * (borrowed from freebsd) |
| 4034 | */ | 4092 | */ |
| 4035 | 4093 | ||
| 4036 | 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) |
| 4037 | { | 4095 | { |
| 4038 | return !before(end_seq, tp->rcv_wup) && | 4096 | return !before(end_seq, tp->rcv_wup) && |
| 4039 | !after(seq, tp->rcv_nxt + tcp_receive_window(tp)); | 4097 | !after(seq, tp->rcv_nxt + tcp_receive_window(tp)); |
| @@ -4078,7 +4136,7 @@ static void tcp_reset(struct sock *sk) | |||
| 4078 | * | 4136 | * |
| 4079 | * 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. |
| 4080 | */ | 4138 | */ |
| 4081 | static void tcp_fin(struct sk_buff *skb, struct sock *sk, struct tcphdr *th) | 4139 | static void tcp_fin(struct sock *sk) |
| 4082 | { | 4140 | { |
| 4083 | struct tcp_sock *tp = tcp_sk(sk); | 4141 | struct tcp_sock *tp = tcp_sk(sk); |
| 4084 | 4142 | ||
| @@ -4190,7 +4248,7 @@ static void tcp_dsack_extend(struct sock *sk, u32 seq, u32 end_seq) | |||
| 4190 | tcp_sack_extend(tp->duplicate_sack, seq, end_seq); | 4248 | tcp_sack_extend(tp->duplicate_sack, seq, end_seq); |
| 4191 | } | 4249 | } |
| 4192 | 4250 | ||
| 4193 | 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) |
| 4194 | { | 4252 | { |
| 4195 | struct tcp_sock *tp = tcp_sk(sk); | 4253 | struct tcp_sock *tp = tcp_sk(sk); |
| 4196 | 4254 | ||
| @@ -4349,7 +4407,7 @@ static void tcp_ofo_queue(struct sock *sk) | |||
| 4349 | __skb_queue_tail(&sk->sk_receive_queue, skb); | 4407 | __skb_queue_tail(&sk->sk_receive_queue, skb); |
| 4350 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; | 4408 | tp->rcv_nxt = TCP_SKB_CB(skb)->end_seq; |
| 4351 | if (tcp_hdr(skb)->fin) | 4409 | if (tcp_hdr(skb)->fin) |
| 4352 | tcp_fin(skb, sk, tcp_hdr(skb)); | 4410 | tcp_fin(sk); |
| 4353 | } | 4411 | } |
| 4354 | } | 4412 | } |
| 4355 | 4413 | ||
| @@ -4377,7 +4435,7 @@ static inline int tcp_try_rmem_schedule(struct sock *sk, unsigned int size) | |||
| 4377 | 4435 | ||
| 4378 | 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) |
| 4379 | { | 4437 | { |
| 4380 | struct tcphdr *th = tcp_hdr(skb); | 4438 | const struct tcphdr *th = tcp_hdr(skb); |
| 4381 | struct tcp_sock *tp = tcp_sk(sk); | 4439 | struct tcp_sock *tp = tcp_sk(sk); |
| 4382 | int eaten = -1; | 4440 | int eaten = -1; |
| 4383 | 4441 | ||
| @@ -4431,7 +4489,7 @@ queue_and_out: | |||
| 4431 | if (skb->len) | 4489 | if (skb->len) |
| 4432 | tcp_event_data_recv(sk, skb); | 4490 | tcp_event_data_recv(sk, skb); |
| 4433 | if (th->fin) | 4491 | if (th->fin) |
| 4434 | tcp_fin(skb, sk, th); | 4492 | tcp_fin(sk); |
| 4435 | 4493 | ||
| 4436 | if (!skb_queue_empty(&tp->out_of_order_queue)) { | 4494 | if (!skb_queue_empty(&tp->out_of_order_queue)) { |
| 4437 | tcp_ofo_queue(sk); | 4495 | tcp_ofo_queue(sk); |
| @@ -4861,9 +4919,9 @@ void tcp_cwnd_application_limited(struct sock *sk) | |||
| 4861 | tp->snd_cwnd_stamp = tcp_time_stamp; | 4919 | tp->snd_cwnd_stamp = tcp_time_stamp; |
| 4862 | } | 4920 | } |
| 4863 | 4921 | ||
| 4864 | static int tcp_should_expand_sndbuf(struct sock *sk) | 4922 | static int tcp_should_expand_sndbuf(const struct sock *sk) |
| 4865 | { | 4923 | { |
| 4866 | struct tcp_sock *tp = tcp_sk(sk); | 4924 | const struct tcp_sock *tp = tcp_sk(sk); |
| 4867 | 4925 | ||
| 4868 | /* If the user specified a specific send buffer setting, do | 4926 | /* If the user specified a specific send buffer setting, do |
| 4869 | * not modify it. | 4927 | * not modify it. |
| @@ -4897,8 +4955,10 @@ static void tcp_new_space(struct sock *sk) | |||
| 4897 | struct tcp_sock *tp = tcp_sk(sk); | 4955 | struct tcp_sock *tp = tcp_sk(sk); |
| 4898 | 4956 | ||
| 4899 | if (tcp_should_expand_sndbuf(sk)) { | 4957 | if (tcp_should_expand_sndbuf(sk)) { |
| 4900 | int sndmem = max_t(u32, tp->rx_opt.mss_clamp, tp->mss_cache) + | 4958 | int sndmem = SKB_TRUESIZE(max_t(u32, |
| 4901 | MAX_TCP_HEADER + 16 + sizeof(struct sk_buff); | 4959 | tp->rx_opt.mss_clamp, |
| 4960 | tp->mss_cache) + | ||
| 4961 | MAX_TCP_HEADER); | ||
| 4902 | int demanded = max_t(unsigned int, tp->snd_cwnd, | 4962 | int demanded = max_t(unsigned int, tp->snd_cwnd, |
| 4903 | tp->reordering + 1); | 4963 | tp->reordering + 1); |
| 4904 | sndmem *= 2 * demanded; | 4964 | sndmem *= 2 * demanded; |
| @@ -4970,7 +5030,7 @@ static inline void tcp_ack_snd_check(struct sock *sk) | |||
| 4970 | * either form (or just set the sysctl tcp_stdurg). | 5030 | * either form (or just set the sysctl tcp_stdurg). |
| 4971 | */ | 5031 | */ |
| 4972 | 5032 | ||
| 4973 | static void tcp_check_urg(struct sock *sk, struct tcphdr *th) | 5033 | static void tcp_check_urg(struct sock *sk, const struct tcphdr *th) |
| 4974 | { | 5034 | { |
| 4975 | struct tcp_sock *tp = tcp_sk(sk); | 5035 | struct tcp_sock *tp = tcp_sk(sk); |
| 4976 | u32 ptr = ntohs(th->urg_ptr); | 5036 | u32 ptr = ntohs(th->urg_ptr); |
| @@ -5036,7 +5096,7 @@ static void tcp_check_urg(struct sock *sk, struct tcphdr *th) | |||
| 5036 | } | 5096 | } |
| 5037 | 5097 | ||
| 5038 | /* This is the 'fast' part of urgent handling. */ | 5098 | /* This is the 'fast' part of urgent handling. */ |
| 5039 | 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) |
| 5040 | { | 5100 | { |
| 5041 | struct tcp_sock *tp = tcp_sk(sk); | 5101 | struct tcp_sock *tp = tcp_sk(sk); |
| 5042 | 5102 | ||
| @@ -5157,9 +5217,9 @@ out: | |||
| 5157 | * play significant role here. | 5217 | * play significant role here. |
| 5158 | */ | 5218 | */ |
| 5159 | 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, |
| 5160 | struct tcphdr *th, int syn_inerr) | 5220 | const struct tcphdr *th, int syn_inerr) |
| 5161 | { | 5221 | { |
| 5162 | u8 *hash_location; | 5222 | const u8 *hash_location; |
| 5163 | struct tcp_sock *tp = tcp_sk(sk); | 5223 | struct tcp_sock *tp = tcp_sk(sk); |
| 5164 | 5224 | ||
| 5165 | /* RFC1323: H1. Apply PAWS check first. */ | 5225 | /* RFC1323: H1. Apply PAWS check first. */ |
| @@ -5240,7 +5300,7 @@ discard: | |||
| 5240 | * tcp_data_queue when everything is OK. | 5300 | * tcp_data_queue when everything is OK. |
| 5241 | */ | 5301 | */ |
| 5242 | int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, | 5302 | int tcp_rcv_established(struct sock *sk, struct sk_buff *skb, |
| 5243 | struct tcphdr *th, unsigned len) | 5303 | const struct tcphdr *th, unsigned int len) |
| 5244 | { | 5304 | { |
| 5245 | struct tcp_sock *tp = tcp_sk(sk); | 5305 | struct tcp_sock *tp = tcp_sk(sk); |
| 5246 | int res; | 5306 | int res; |
| @@ -5451,9 +5511,9 @@ discard: | |||
| 5451 | EXPORT_SYMBOL(tcp_rcv_established); | 5511 | EXPORT_SYMBOL(tcp_rcv_established); |
| 5452 | 5512 | ||
| 5453 | 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, |
| 5454 | struct tcphdr *th, unsigned len) | 5514 | const struct tcphdr *th, unsigned int len) |
| 5455 | { | 5515 | { |
| 5456 | u8 *hash_location; | 5516 | const u8 *hash_location; |
| 5457 | struct inet_connection_sock *icsk = inet_csk(sk); | 5517 | struct inet_connection_sock *icsk = inet_csk(sk); |
| 5458 | struct tcp_sock *tp = tcp_sk(sk); | 5518 | struct tcp_sock *tp = tcp_sk(sk); |
| 5459 | struct tcp_cookie_values *cvp = tp->cookie_values; | 5519 | struct tcp_cookie_values *cvp = tp->cookie_values; |
| @@ -5728,7 +5788,7 @@ reset_and_undo: | |||
| 5728 | */ | 5788 | */ |
| 5729 | 5789 | ||
| 5730 | 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, |
| 5731 | struct tcphdr *th, unsigned len) | 5791 | const struct tcphdr *th, unsigned int len) |
| 5732 | { | 5792 | { |
| 5733 | struct tcp_sock *tp = tcp_sk(sk); | 5793 | struct tcp_sock *tp = tcp_sk(sk); |
| 5734 | 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 1c12b8ec849d..a9db4b1a2215 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 | /* |
| @@ -808,20 +811,38 @@ static void tcp_v4_reqsk_destructor(struct request_sock *req) | |||
| 808 | kfree(inet_rsk(req)->opt); | 811 | kfree(inet_rsk(req)->opt); |
| 809 | } | 812 | } |
| 810 | 813 | ||
| 811 | static void syn_flood_warning(const struct sk_buff *skb) | 814 | /* |
| 815 | * Return 1 if a syncookie should be sent | ||
| 816 | */ | ||
| 817 | int tcp_syn_flood_action(struct sock *sk, | ||
| 818 | const struct sk_buff *skb, | ||
| 819 | const char *proto) | ||
| 812 | { | 820 | { |
| 813 | const char *msg; | 821 | const char *msg = "Dropping request"; |
| 822 | int want_cookie = 0; | ||
| 823 | struct listen_sock *lopt; | ||
| 824 | |||
| 825 | |||
| 814 | 826 | ||
| 815 | #ifdef CONFIG_SYN_COOKIES | 827 | #ifdef CONFIG_SYN_COOKIES |
| 816 | if (sysctl_tcp_syncookies) | 828 | if (sysctl_tcp_syncookies) { |
| 817 | msg = "Sending cookies"; | 829 | msg = "Sending cookies"; |
| 818 | else | 830 | want_cookie = 1; |
| 831 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDOCOOKIES); | ||
| 832 | } else | ||
| 819 | #endif | 833 | #endif |
| 820 | msg = "Dropping request"; | 834 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPREQQFULLDROP); |
| 821 | 835 | ||
| 822 | pr_info("TCP: Possible SYN flooding on port %d. %s.\n", | 836 | lopt = inet_csk(sk)->icsk_accept_queue.listen_opt; |
| 823 | ntohs(tcp_hdr(skb)->dest), msg); | 837 | if (!lopt->synflood_warned) { |
| 838 | lopt->synflood_warned = 1; | ||
| 839 | pr_info("%s: Possible SYN flooding on port %d. %s. " | ||
| 840 | " Check SNMP counters.\n", | ||
| 841 | proto, ntohs(tcp_hdr(skb)->dest), msg); | ||
| 842 | } | ||
| 843 | return want_cookie; | ||
| 824 | } | 844 | } |
| 845 | EXPORT_SYMBOL(tcp_syn_flood_action); | ||
| 825 | 846 | ||
| 826 | /* | 847 | /* |
| 827 | * Save and compile IPv4 options into the request_sock if needed. | 848 | * Save and compile IPv4 options into the request_sock if needed. |
| @@ -909,18 +930,21 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, | |||
| 909 | } | 930 | } |
| 910 | sk_nocaps_add(sk, NETIF_F_GSO_MASK); | 931 | sk_nocaps_add(sk, NETIF_F_GSO_MASK); |
| 911 | } | 932 | } |
| 912 | if (tcp_alloc_md5sig_pool(sk) == NULL) { | 933 | |
| 934 | md5sig = tp->md5sig_info; | ||
| 935 | if (md5sig->entries4 == 0 && | ||
| 936 | tcp_alloc_md5sig_pool(sk) == NULL) { | ||
| 913 | kfree(newkey); | 937 | kfree(newkey); |
| 914 | return -ENOMEM; | 938 | return -ENOMEM; |
| 915 | } | 939 | } |
| 916 | md5sig = tp->md5sig_info; | ||
| 917 | 940 | ||
| 918 | if (md5sig->alloced4 == md5sig->entries4) { | 941 | if (md5sig->alloced4 == md5sig->entries4) { |
| 919 | keys = kmalloc((sizeof(*keys) * | 942 | keys = kmalloc((sizeof(*keys) * |
| 920 | (md5sig->entries4 + 1)), GFP_ATOMIC); | 943 | (md5sig->entries4 + 1)), GFP_ATOMIC); |
| 921 | if (!keys) { | 944 | if (!keys) { |
| 922 | kfree(newkey); | 945 | kfree(newkey); |
| 923 | tcp_free_md5sig_pool(); | 946 | if (md5sig->entries4 == 0) |
| 947 | tcp_free_md5sig_pool(); | ||
| 924 | return -ENOMEM; | 948 | return -ENOMEM; |
| 925 | } | 949 | } |
| 926 | 950 | ||
| @@ -964,6 +988,7 @@ int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) | |||
| 964 | kfree(tp->md5sig_info->keys4); | 988 | kfree(tp->md5sig_info->keys4); |
| 965 | tp->md5sig_info->keys4 = NULL; | 989 | tp->md5sig_info->keys4 = NULL; |
| 966 | tp->md5sig_info->alloced4 = 0; | 990 | tp->md5sig_info->alloced4 = 0; |
| 991 | tcp_free_md5sig_pool(); | ||
| 967 | } else if (tp->md5sig_info->entries4 != i) { | 992 | } else if (tp->md5sig_info->entries4 != i) { |
| 968 | /* Need to do some manipulation */ | 993 | /* Need to do some manipulation */ |
| 969 | memmove(&tp->md5sig_info->keys4[i], | 994 | memmove(&tp->md5sig_info->keys4[i], |
| @@ -971,7 +996,6 @@ int tcp_v4_md5_do_del(struct sock *sk, __be32 addr) | |||
| 971 | (tp->md5sig_info->entries4 - i) * | 996 | (tp->md5sig_info->entries4 - i) * |
| 972 | sizeof(struct tcp4_md5sig_key)); | 997 | sizeof(struct tcp4_md5sig_key)); |
| 973 | } | 998 | } |
| 974 | tcp_free_md5sig_pool(); | ||
| 975 | return 0; | 999 | return 0; |
| 976 | } | 1000 | } |
| 977 | } | 1001 | } |
| @@ -1069,7 +1093,7 @@ static int tcp_v4_md5_hash_pseudoheader(struct tcp_md5sig_pool *hp, | |||
| 1069 | } | 1093 | } |
| 1070 | 1094 | ||
| 1071 | 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, |
| 1072 | __be32 daddr, __be32 saddr, struct tcphdr *th) | 1096 | __be32 daddr, __be32 saddr, const struct tcphdr *th) |
| 1073 | { | 1097 | { |
| 1074 | struct tcp_md5sig_pool *hp; | 1098 | struct tcp_md5sig_pool *hp; |
| 1075 | struct hash_desc *desc; | 1099 | struct hash_desc *desc; |
| @@ -1101,12 +1125,12 @@ clear_hash_noput: | |||
| 1101 | } | 1125 | } |
| 1102 | 1126 | ||
| 1103 | 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, |
| 1104 | struct sock *sk, struct request_sock *req, | 1128 | const struct sock *sk, const struct request_sock *req, |
| 1105 | struct sk_buff *skb) | 1129 | const struct sk_buff *skb) |
| 1106 | { | 1130 | { |
| 1107 | struct tcp_md5sig_pool *hp; | 1131 | struct tcp_md5sig_pool *hp; |
| 1108 | struct hash_desc *desc; | 1132 | struct hash_desc *desc; |
| 1109 | struct tcphdr *th = tcp_hdr(skb); | 1133 | const struct tcphdr *th = tcp_hdr(skb); |
| 1110 | __be32 saddr, daddr; | 1134 | __be32 saddr, daddr; |
| 1111 | 1135 | ||
| 1112 | if (sk) { | 1136 | if (sk) { |
| @@ -1151,7 +1175,7 @@ clear_hash_noput: | |||
| 1151 | } | 1175 | } |
| 1152 | EXPORT_SYMBOL(tcp_v4_md5_hash_skb); | 1176 | EXPORT_SYMBOL(tcp_v4_md5_hash_skb); |
| 1153 | 1177 | ||
| 1154 | 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) |
| 1155 | { | 1179 | { |
| 1156 | /* | 1180 | /* |
| 1157 | * This gets called for each TCP segment that arrives | 1181 | * This gets called for each TCP segment that arrives |
| @@ -1161,10 +1185,10 @@ static int tcp_v4_inbound_md5_hash(struct sock *sk, struct sk_buff *skb) | |||
| 1161 | * o MD5 hash and we're not expecting one. | 1185 | * o MD5 hash and we're not expecting one. |
| 1162 | * o MD5 hash and its wrong. | 1186 | * o MD5 hash and its wrong. |
| 1163 | */ | 1187 | */ |
| 1164 | __u8 *hash_location = NULL; | 1188 | const __u8 *hash_location = NULL; |
| 1165 | struct tcp_md5sig_key *hash_expected; | 1189 | struct tcp_md5sig_key *hash_expected; |
| 1166 | const struct iphdr *iph = ip_hdr(skb); | 1190 | const struct iphdr *iph = ip_hdr(skb); |
| 1167 | struct tcphdr *th = tcp_hdr(skb); | 1191 | const struct tcphdr *th = tcp_hdr(skb); |
| 1168 | int genhash; | 1192 | int genhash; |
| 1169 | unsigned char newhash[16]; | 1193 | unsigned char newhash[16]; |
| 1170 | 1194 | ||
| @@ -1227,7 +1251,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1227 | { | 1251 | { |
| 1228 | struct tcp_extend_values tmp_ext; | 1252 | struct tcp_extend_values tmp_ext; |
| 1229 | struct tcp_options_received tmp_opt; | 1253 | struct tcp_options_received tmp_opt; |
| 1230 | u8 *hash_location; | 1254 | const u8 *hash_location; |
| 1231 | struct request_sock *req; | 1255 | struct request_sock *req; |
| 1232 | struct inet_request_sock *ireq; | 1256 | struct inet_request_sock *ireq; |
| 1233 | struct tcp_sock *tp = tcp_sk(sk); | 1257 | struct tcp_sock *tp = tcp_sk(sk); |
| @@ -1235,11 +1259,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1235 | __be32 saddr = ip_hdr(skb)->saddr; | 1259 | __be32 saddr = ip_hdr(skb)->saddr; |
| 1236 | __be32 daddr = ip_hdr(skb)->daddr; | 1260 | __be32 daddr = ip_hdr(skb)->daddr; |
| 1237 | __u32 isn = TCP_SKB_CB(skb)->when; | 1261 | __u32 isn = TCP_SKB_CB(skb)->when; |
| 1238 | #ifdef CONFIG_SYN_COOKIES | ||
| 1239 | int want_cookie = 0; | 1262 | int want_cookie = 0; |
| 1240 | #else | ||
| 1241 | #define want_cookie 0 /* Argh, why doesn't gcc optimize this :( */ | ||
| 1242 | #endif | ||
| 1243 | 1263 | ||
| 1244 | /* Never answer to SYNs send to broadcast or multicast */ | 1264 | /* Never answer to SYNs send to broadcast or multicast */ |
| 1245 | if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) | 1265 | if (skb_rtable(skb)->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST)) |
| @@ -1250,14 +1270,9 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1250 | * evidently real one. | 1270 | * evidently real one. |
| 1251 | */ | 1271 | */ |
| 1252 | if (inet_csk_reqsk_queue_is_full(sk) && !isn) { | 1272 | if (inet_csk_reqsk_queue_is_full(sk) && !isn) { |
| 1253 | if (net_ratelimit()) | 1273 | want_cookie = tcp_syn_flood_action(sk, skb, "TCP"); |
| 1254 | syn_flood_warning(skb); | 1274 | if (!want_cookie) |
| 1255 | #ifdef CONFIG_SYN_COOKIES | 1275 | goto drop; |
| 1256 | if (sysctl_tcp_syncookies) { | ||
| 1257 | want_cookie = 1; | ||
| 1258 | } else | ||
| 1259 | #endif | ||
| 1260 | goto drop; | ||
| 1261 | } | 1276 | } |
| 1262 | 1277 | ||
| 1263 | /* Accept backlog is full. If we have already queued enough | 1278 | /* Accept backlog is full. If we have already queued enough |
| @@ -1303,9 +1318,7 @@ int tcp_v4_conn_request(struct sock *sk, struct sk_buff *skb) | |||
| 1303 | while (l-- > 0) | 1318 | while (l-- > 0) |
| 1304 | *c++ ^= *hash_location++; | 1319 | *c++ ^= *hash_location++; |
| 1305 | 1320 | ||
| 1306 | #ifdef CONFIG_SYN_COOKIES | ||
| 1307 | want_cookie = 0; /* not our kind of cookie */ | 1321 | want_cookie = 0; /* not our kind of cookie */ |
| 1308 | #endif | ||
| 1309 | tmp_ext.cookie_out_never = 0; /* false */ | 1322 | tmp_ext.cookie_out_never = 0; /* false */ |
| 1310 | tmp_ext.cookie_plus = tmp_opt.cookie_plus; | 1323 | tmp_ext.cookie_plus = tmp_opt.cookie_plus; |
| 1311 | } else if (!tp->rx_opt.cookie_in_always) { | 1324 | } else if (!tp->rx_opt.cookie_in_always) { |
| @@ -1497,6 +1510,8 @@ exit: | |||
| 1497 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS); | 1510 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_LISTENDROPS); |
| 1498 | return NULL; | 1511 | return NULL; |
| 1499 | put_and_exit: | 1512 | put_and_exit: |
| 1513 | tcp_clear_xmit_timers(newsk); | ||
| 1514 | bh_unlock_sock(newsk); | ||
| 1500 | sock_put(newsk); | 1515 | sock_put(newsk); |
| 1501 | goto exit; | 1516 | goto exit; |
| 1502 | } | 1517 | } |
| @@ -1578,7 +1593,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 1578 | #endif | 1593 | #endif |
| 1579 | 1594 | ||
| 1580 | if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ | 1595 | if (sk->sk_state == TCP_ESTABLISHED) { /* Fast path */ |
| 1581 | sock_rps_save_rxhash(sk, skb->rxhash); | 1596 | sock_rps_save_rxhash(sk, skb); |
| 1582 | if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len)) { | 1597 | if (tcp_rcv_established(sk, skb, tcp_hdr(skb), skb->len)) { |
| 1583 | rsk = sk; | 1598 | rsk = sk; |
| 1584 | goto reset; | 1599 | goto reset; |
| @@ -1595,7 +1610,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 1595 | goto discard; | 1610 | goto discard; |
| 1596 | 1611 | ||
| 1597 | if (nsk != sk) { | 1612 | if (nsk != sk) { |
| 1598 | sock_rps_save_rxhash(nsk, skb->rxhash); | 1613 | sock_rps_save_rxhash(nsk, skb); |
| 1599 | if (tcp_child_process(sk, nsk, skb)) { | 1614 | if (tcp_child_process(sk, nsk, skb)) { |
| 1600 | rsk = nsk; | 1615 | rsk = nsk; |
| 1601 | goto reset; | 1616 | goto reset; |
| @@ -1603,7 +1618,7 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
| 1603 | return 0; | 1618 | return 0; |
| 1604 | } | 1619 | } |
| 1605 | } else | 1620 | } else |
| 1606 | sock_rps_save_rxhash(sk, skb->rxhash); | 1621 | sock_rps_save_rxhash(sk, skb); |
| 1607 | 1622 | ||
| 1608 | if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len)) { | 1623 | if (tcp_rcv_state_process(sk, skb, tcp_hdr(skb), skb->len)) { |
| 1609 | rsk = sk; | 1624 | rsk = sk; |
| @@ -1635,7 +1650,7 @@ EXPORT_SYMBOL(tcp_v4_do_rcv); | |||
| 1635 | int tcp_v4_rcv(struct sk_buff *skb) | 1650 | int tcp_v4_rcv(struct sk_buff *skb) |
| 1636 | { | 1651 | { |
| 1637 | const struct iphdr *iph; | 1652 | const struct iphdr *iph; |
| 1638 | struct tcphdr *th; | 1653 | const struct tcphdr *th; |
| 1639 | struct sock *sk; | 1654 | struct sock *sk; |
| 1640 | int ret; | 1655 | int ret; |
| 1641 | struct net *net = dev_net(skb->dev); | 1656 | struct net *net = dev_net(skb->dev); |
| @@ -1670,7 +1685,7 @@ int tcp_v4_rcv(struct sk_buff *skb) | |||
| 1670 | skb->len - th->doff * 4); | 1685 | skb->len - th->doff * 4); |
| 1671 | TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); | 1686 | TCP_SKB_CB(skb)->ack_seq = ntohl(th->ack_seq); |
| 1672 | TCP_SKB_CB(skb)->when = 0; | 1687 | TCP_SKB_CB(skb)->when = 0; |
| 1673 | TCP_SKB_CB(skb)->flags = iph->tos; | 1688 | TCP_SKB_CB(skb)->ip_dsfield = ipv4_get_dsfield(iph); |
| 1674 | TCP_SKB_CB(skb)->sacked = 0; | 1689 | TCP_SKB_CB(skb)->sacked = 0; |
| 1675 | 1690 | ||
| 1676 | sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest); | 1691 | sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest); |
| @@ -1799,7 +1814,7 @@ EXPORT_SYMBOL(tcp_v4_get_peer); | |||
| 1799 | 1814 | ||
| 1800 | void *tcp_v4_tw_get_peer(struct sock *sk) | 1815 | void *tcp_v4_tw_get_peer(struct sock *sk) |
| 1801 | { | 1816 | { |
| 1802 | struct inet_timewait_sock *tw = inet_twsk(sk); | 1817 | const struct inet_timewait_sock *tw = inet_twsk(sk); |
| 1803 | 1818 | ||
| 1804 | return inet_getpeer_v4(tw->tw_daddr, 1); | 1819 | return inet_getpeer_v4(tw->tw_daddr, 1); |
| 1805 | } | 1820 | } |
| @@ -2326,7 +2341,7 @@ static void tcp_seq_stop(struct seq_file *seq, void *v) | |||
| 2326 | } | 2341 | } |
| 2327 | } | 2342 | } |
| 2328 | 2343 | ||
| 2329 | static int tcp_seq_open(struct inode *inode, struct file *file) | 2344 | int tcp_seq_open(struct inode *inode, struct file *file) |
| 2330 | { | 2345 | { |
| 2331 | struct tcp_seq_afinfo *afinfo = PDE(inode)->data; | 2346 | struct tcp_seq_afinfo *afinfo = PDE(inode)->data; |
| 2332 | struct tcp_iter_state *s; | 2347 | struct tcp_iter_state *s; |
| @@ -2342,23 +2357,19 @@ static int tcp_seq_open(struct inode *inode, struct file *file) | |||
| 2342 | s->last_pos = 0; | 2357 | s->last_pos = 0; |
| 2343 | return 0; | 2358 | return 0; |
| 2344 | } | 2359 | } |
| 2360 | EXPORT_SYMBOL(tcp_seq_open); | ||
| 2345 | 2361 | ||
| 2346 | int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo) | 2362 | int tcp_proc_register(struct net *net, struct tcp_seq_afinfo *afinfo) |
| 2347 | { | 2363 | { |
| 2348 | int rc = 0; | 2364 | int rc = 0; |
| 2349 | struct proc_dir_entry *p; | 2365 | struct proc_dir_entry *p; |
| 2350 | 2366 | ||
| 2351 | afinfo->seq_fops.open = tcp_seq_open; | ||
| 2352 | afinfo->seq_fops.read = seq_read; | ||
| 2353 | afinfo->seq_fops.llseek = seq_lseek; | ||
| 2354 | afinfo->seq_fops.release = seq_release_net; | ||
| 2355 | |||
| 2356 | afinfo->seq_ops.start = tcp_seq_start; | 2367 | afinfo->seq_ops.start = tcp_seq_start; |
| 2357 | afinfo->seq_ops.next = tcp_seq_next; | 2368 | afinfo->seq_ops.next = tcp_seq_next; |
| 2358 | afinfo->seq_ops.stop = tcp_seq_stop; | 2369 | afinfo->seq_ops.stop = tcp_seq_stop; |
| 2359 | 2370 | ||
| 2360 | p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net, | 2371 | p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net, |
| 2361 | &afinfo->seq_fops, afinfo); | 2372 | afinfo->seq_fops, afinfo); |
| 2362 | if (!p) | 2373 | if (!p) |
| 2363 | rc = -ENOMEM; | 2374 | rc = -ENOMEM; |
| 2364 | return rc; | 2375 | return rc; |
| @@ -2371,7 +2382,7 @@ void tcp_proc_unregister(struct net *net, struct tcp_seq_afinfo *afinfo) | |||
| 2371 | } | 2382 | } |
| 2372 | EXPORT_SYMBOL(tcp_proc_unregister); | 2383 | EXPORT_SYMBOL(tcp_proc_unregister); |
| 2373 | 2384 | ||
| 2374 | static void get_openreq4(struct sock *sk, struct request_sock *req, | 2385 | static void get_openreq4(const struct sock *sk, const struct request_sock *req, |
| 2375 | struct seq_file *f, int i, int uid, int *len) | 2386 | struct seq_file *f, int i, int uid, int *len) |
| 2376 | { | 2387 | { |
| 2377 | const struct inet_request_sock *ireq = inet_rsk(req); | 2388 | const struct inet_request_sock *ireq = inet_rsk(req); |
| @@ -2401,9 +2412,9 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len) | |||
| 2401 | { | 2412 | { |
| 2402 | int timer_active; | 2413 | int timer_active; |
| 2403 | unsigned long timer_expires; | 2414 | unsigned long timer_expires; |
| 2404 | struct tcp_sock *tp = tcp_sk(sk); | 2415 | const struct tcp_sock *tp = tcp_sk(sk); |
| 2405 | const struct inet_connection_sock *icsk = inet_csk(sk); | 2416 | const struct inet_connection_sock *icsk = inet_csk(sk); |
| 2406 | struct inet_sock *inet = inet_sk(sk); | 2417 | const struct inet_sock *inet = inet_sk(sk); |
| 2407 | __be32 dest = inet->inet_daddr; | 2418 | __be32 dest = inet->inet_daddr; |
| 2408 | __be32 src = inet->inet_rcv_saddr; | 2419 | __be32 src = inet->inet_rcv_saddr; |
| 2409 | __u16 destp = ntohs(inet->inet_dport); | 2420 | __u16 destp = ntohs(inet->inet_dport); |
| @@ -2452,7 +2463,7 @@ static void get_tcp4_sock(struct sock *sk, struct seq_file *f, int i, int *len) | |||
| 2452 | len); | 2463 | len); |
| 2453 | } | 2464 | } |
| 2454 | 2465 | ||
| 2455 | static void get_timewait4_sock(struct inet_timewait_sock *tw, | 2466 | static void get_timewait4_sock(const struct inet_timewait_sock *tw, |
| 2456 | struct seq_file *f, int i, int *len) | 2467 | struct seq_file *f, int i, int *len) |
| 2457 | { | 2468 | { |
| 2458 | __be32 dest, src; | 2469 | __be32 dest, src; |
| @@ -2507,12 +2518,18 @@ out: | |||
| 2507 | return 0; | 2518 | return 0; |
| 2508 | } | 2519 | } |
| 2509 | 2520 | ||
| 2521 | static const struct file_operations tcp_afinfo_seq_fops = { | ||
| 2522 | .owner = THIS_MODULE, | ||
| 2523 | .open = tcp_seq_open, | ||
| 2524 | .read = seq_read, | ||
| 2525 | .llseek = seq_lseek, | ||
| 2526 | .release = seq_release_net | ||
| 2527 | }; | ||
| 2528 | |||
| 2510 | static struct tcp_seq_afinfo tcp4_seq_afinfo = { | 2529 | static struct tcp_seq_afinfo tcp4_seq_afinfo = { |
| 2511 | .name = "tcp", | 2530 | .name = "tcp", |
| 2512 | .family = AF_INET, | 2531 | .family = AF_INET, |
| 2513 | .seq_fops = { | 2532 | .seq_fops = &tcp_afinfo_seq_fops, |
| 2514 | .owner = THIS_MODULE, | ||
| 2515 | }, | ||
| 2516 | .seq_ops = { | 2533 | .seq_ops = { |
| 2517 | .show = tcp4_seq_show, | 2534 | .show = tcp4_seq_show, |
| 2518 | }, | 2535 | }, |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index d2fe4e06b472..66363b689ad6 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 | ||
| @@ -328,6 +328,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) | |||
| 328 | struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); | 328 | struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); |
| 329 | const int rto = (icsk->icsk_rto << 2) - (icsk->icsk_rto >> 1); | 329 | const int rto = (icsk->icsk_rto << 2) - (icsk->icsk_rto >> 1); |
| 330 | 330 | ||
| 331 | tw->tw_transparent = inet_sk(sk)->transparent; | ||
| 331 | tw->tw_rcv_wscale = tp->rx_opt.rcv_wscale; | 332 | tw->tw_rcv_wscale = tp->rx_opt.rcv_wscale; |
| 332 | tcptw->tw_rcv_nxt = tp->rcv_nxt; | 333 | tcptw->tw_rcv_nxt = tp->rcv_nxt; |
| 333 | tcptw->tw_snd_nxt = tp->snd_nxt; | 334 | tcptw->tw_snd_nxt = tp->snd_nxt; |
| @@ -344,6 +345,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) | |||
| 344 | tw6 = inet6_twsk((struct sock *)tw); | 345 | tw6 = inet6_twsk((struct sock *)tw); |
| 345 | ipv6_addr_copy(&tw6->tw_v6_daddr, &np->daddr); | 346 | ipv6_addr_copy(&tw6->tw_v6_daddr, &np->daddr); |
| 346 | ipv6_addr_copy(&tw6->tw_v6_rcv_saddr, &np->rcv_saddr); | 347 | ipv6_addr_copy(&tw6->tw_v6_rcv_saddr, &np->rcv_saddr); |
| 348 | tw->tw_tclass = np->tclass; | ||
| 347 | tw->tw_ipv6only = np->ipv6only; | 349 | tw->tw_ipv6only = np->ipv6only; |
| 348 | } | 350 | } |
| 349 | #endif | 351 | #endif |
| @@ -566,7 +568,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, | |||
| 566 | struct request_sock **prev) | 568 | struct request_sock **prev) |
| 567 | { | 569 | { |
| 568 | struct tcp_options_received tmp_opt; | 570 | struct tcp_options_received tmp_opt; |
| 569 | u8 *hash_location; | 571 | const u8 *hash_location; |
| 570 | struct sock *child; | 572 | struct sock *child; |
| 571 | const struct tcphdr *th = tcp_hdr(skb); | 573 | const struct tcphdr *th = tcp_hdr(skb); |
| 572 | __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); | 574 | __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..63170e297540 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); |
| @@ -1377,7 +1382,7 @@ static inline int tcp_minshall_check(const struct tcp_sock *tp) | |||
| 1377 | /* Return 0, if packet can be sent now without violation Nagle's rules: | 1382 | /* Return 0, if packet can be sent now without violation Nagle's rules: |
| 1378 | * 1. It is full sized. | 1383 | * 1. It is full sized. |
| 1379 | * 2. Or it contains FIN. (already checked by caller) | 1384 | * 2. Or it contains FIN. (already checked by caller) |
| 1380 | * 3. Or TCP_NODELAY was set. | 1385 | * 3. Or TCP_CORK is not set, and TCP_NODELAY is set. |
| 1381 | * 4. Or TCP_CORK is not set, and all sent packets are ACKed. | 1386 | * 4. Or TCP_CORK is not set, and all sent packets are ACKed. |
| 1382 | * With Minshall's modification: all sent small packets are ACKed. | 1387 | * With Minshall's modification: all sent small packets are ACKed. |
| 1383 | */ | 1388 | */ |
| @@ -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..ab0966df1e2a 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) { |
| @@ -1397,6 +1397,8 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 1397 | nf_reset(skb); | 1397 | nf_reset(skb); |
| 1398 | 1398 | ||
| 1399 | if (up->encap_type) { | 1399 | if (up->encap_type) { |
| 1400 | int (*encap_rcv)(struct sock *sk, struct sk_buff *skb); | ||
| 1401 | |||
| 1400 | /* | 1402 | /* |
| 1401 | * This is an encapsulation socket so pass the skb to | 1403 | * This is an encapsulation socket so pass the skb to |
| 1402 | * the socket's udp_encap_rcv() hook. Otherwise, just | 1404 | * the socket's udp_encap_rcv() hook. Otherwise, just |
| @@ -1409,11 +1411,11 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 1409 | */ | 1411 | */ |
| 1410 | 1412 | ||
| 1411 | /* if we're overly short, let UDP handle it */ | 1413 | /* if we're overly short, let UDP handle it */ |
| 1412 | if (skb->len > sizeof(struct udphdr) && | 1414 | encap_rcv = ACCESS_ONCE(up->encap_rcv); |
| 1413 | up->encap_rcv != NULL) { | 1415 | if (skb->len > sizeof(struct udphdr) && encap_rcv != NULL) { |
| 1414 | int ret; | 1416 | int ret; |
| 1415 | 1417 | ||
| 1416 | ret = (*up->encap_rcv)(sk, skb); | 1418 | ret = encap_rcv(sk, skb); |
| 1417 | if (ret <= 0) { | 1419 | if (ret <= 0) { |
| 1418 | UDP_INC_STATS_BH(sock_net(sk), | 1420 | UDP_INC_STATS_BH(sock_net(sk), |
| 1419 | UDP_MIB_INDATAGRAMS, | 1421 | UDP_MIB_INDATAGRAMS, |
| @@ -1461,10 +1463,9 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 1461 | } | 1463 | } |
| 1462 | } | 1464 | } |
| 1463 | 1465 | ||
| 1464 | if (rcu_dereference_raw(sk->sk_filter)) { | 1466 | if (rcu_access_pointer(sk->sk_filter) && |
| 1465 | if (udp_lib_checksum_complete(skb)) | 1467 | udp_lib_checksum_complete(skb)) |
| 1466 | goto drop; | 1468 | goto drop; |
| 1467 | } | ||
| 1468 | 1469 | ||
| 1469 | 1470 | ||
| 1470 | if (sk_rcvqueues_full(sk, skb)) | 1471 | if (sk_rcvqueues_full(sk, skb)) |
| @@ -2038,7 +2039,7 @@ static void udp_seq_stop(struct seq_file *seq, void *v) | |||
| 2038 | spin_unlock_bh(&state->udp_table->hash[state->bucket].lock); | 2039 | spin_unlock_bh(&state->udp_table->hash[state->bucket].lock); |
| 2039 | } | 2040 | } |
| 2040 | 2041 | ||
| 2041 | static int udp_seq_open(struct inode *inode, struct file *file) | 2042 | int udp_seq_open(struct inode *inode, struct file *file) |
| 2042 | { | 2043 | { |
| 2043 | struct udp_seq_afinfo *afinfo = PDE(inode)->data; | 2044 | struct udp_seq_afinfo *afinfo = PDE(inode)->data; |
| 2044 | struct udp_iter_state *s; | 2045 | struct udp_iter_state *s; |
| @@ -2054,6 +2055,7 @@ static int udp_seq_open(struct inode *inode, struct file *file) | |||
| 2054 | s->udp_table = afinfo->udp_table; | 2055 | s->udp_table = afinfo->udp_table; |
| 2055 | return err; | 2056 | return err; |
| 2056 | } | 2057 | } |
| 2058 | EXPORT_SYMBOL(udp_seq_open); | ||
| 2057 | 2059 | ||
| 2058 | /* ------------------------------------------------------------------------ */ | 2060 | /* ------------------------------------------------------------------------ */ |
| 2059 | int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo) | 2061 | int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo) |
| @@ -2061,17 +2063,12 @@ int udp_proc_register(struct net *net, struct udp_seq_afinfo *afinfo) | |||
| 2061 | struct proc_dir_entry *p; | 2063 | struct proc_dir_entry *p; |
| 2062 | int rc = 0; | 2064 | int rc = 0; |
| 2063 | 2065 | ||
| 2064 | afinfo->seq_fops.open = udp_seq_open; | ||
| 2065 | afinfo->seq_fops.read = seq_read; | ||
| 2066 | afinfo->seq_fops.llseek = seq_lseek; | ||
| 2067 | afinfo->seq_fops.release = seq_release_net; | ||
| 2068 | |||
| 2069 | afinfo->seq_ops.start = udp_seq_start; | 2066 | afinfo->seq_ops.start = udp_seq_start; |
| 2070 | afinfo->seq_ops.next = udp_seq_next; | 2067 | afinfo->seq_ops.next = udp_seq_next; |
| 2071 | afinfo->seq_ops.stop = udp_seq_stop; | 2068 | afinfo->seq_ops.stop = udp_seq_stop; |
| 2072 | 2069 | ||
| 2073 | p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net, | 2070 | p = proc_create_data(afinfo->name, S_IRUGO, net->proc_net, |
| 2074 | &afinfo->seq_fops, afinfo); | 2071 | afinfo->seq_fops, afinfo); |
| 2075 | if (!p) | 2072 | if (!p) |
| 2076 | rc = -ENOMEM; | 2073 | rc = -ENOMEM; |
| 2077 | return rc; | 2074 | return rc; |
| @@ -2121,14 +2118,20 @@ int udp4_seq_show(struct seq_file *seq, void *v) | |||
| 2121 | return 0; | 2118 | return 0; |
| 2122 | } | 2119 | } |
| 2123 | 2120 | ||
| 2121 | static const struct file_operations udp_afinfo_seq_fops = { | ||
| 2122 | .owner = THIS_MODULE, | ||
| 2123 | .open = udp_seq_open, | ||
| 2124 | .read = seq_read, | ||
| 2125 | .llseek = seq_lseek, | ||
| 2126 | .release = seq_release_net | ||
| 2127 | }; | ||
| 2128 | |||
| 2124 | /* ------------------------------------------------------------------------ */ | 2129 | /* ------------------------------------------------------------------------ */ |
| 2125 | static struct udp_seq_afinfo udp4_seq_afinfo = { | 2130 | static struct udp_seq_afinfo udp4_seq_afinfo = { |
| 2126 | .name = "udp", | 2131 | .name = "udp", |
| 2127 | .family = AF_INET, | 2132 | .family = AF_INET, |
| 2128 | .udp_table = &udp_table, | 2133 | .udp_table = &udp_table, |
| 2129 | .seq_fops = { | 2134 | .seq_fops = &udp_afinfo_seq_fops, |
| 2130 | .owner = THIS_MODULE, | ||
| 2131 | }, | ||
| 2132 | .seq_ops = { | 2135 | .seq_ops = { |
| 2133 | .show = udp4_seq_show, | 2136 | .show = udp4_seq_show, |
| 2134 | }, | 2137 | }, |
diff --git a/net/ipv4/udplite.c b/net/ipv4/udplite.c index aee9963f7f5a..12e9499a1a6c 100644 --- a/net/ipv4/udplite.c +++ b/net/ipv4/udplite.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | * as published by the Free Software Foundation; either version | 10 | * as published by the Free Software Foundation; either version |
| 11 | * 2 of the License, or (at your option) any later version. | 11 | * 2 of the License, or (at your option) any later version. |
| 12 | */ | 12 | */ |
| 13 | #include <linux/export.h> | ||
| 13 | #include "udp_impl.h" | 14 | #include "udp_impl.h" |
| 14 | 15 | ||
| 15 | struct udp_table udplite_table __read_mostly; | 16 | struct udp_table udplite_table __read_mostly; |
| @@ -71,13 +72,20 @@ static struct inet_protosw udplite4_protosw = { | |||
| 71 | }; | 72 | }; |
| 72 | 73 | ||
| 73 | #ifdef CONFIG_PROC_FS | 74 | #ifdef CONFIG_PROC_FS |
| 75 | |||
| 76 | static const struct file_operations udplite_afinfo_seq_fops = { | ||
| 77 | .owner = THIS_MODULE, | ||
| 78 | .open = udp_seq_open, | ||
| 79 | .read = seq_read, | ||
| 80 | .llseek = seq_lseek, | ||
| 81 | .release = seq_release_net | ||
| 82 | }; | ||
| 83 | |||
| 74 | static struct udp_seq_afinfo udplite4_seq_afinfo = { | 84 | static struct udp_seq_afinfo udplite4_seq_afinfo = { |
| 75 | .name = "udplite", | 85 | .name = "udplite", |
| 76 | .family = AF_INET, | 86 | .family = AF_INET, |
| 77 | .udp_table = &udplite_table, | 87 | .udp_table = &udplite_table, |
| 78 | .seq_fops = { | 88 | .seq_fops = &udplite_afinfo_seq_fops, |
| 79 | .owner = THIS_MODULE, | ||
| 80 | }, | ||
| 81 | .seq_ops = { | 89 | .seq_ops = { |
| 82 | .show = udp4_seq_show, | 90 | .show = udp4_seq_show, |
| 83 | }, | 91 | }, |
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); |
diff --git a/net/ipv4/xfrm4_state.c b/net/ipv4/xfrm4_state.c index d9ac0a0058b5..9258e751baba 100644 --- a/net/ipv4/xfrm4_state.c +++ b/net/ipv4/xfrm4_state.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <linux/pfkeyv2.h> | 12 | #include <linux/pfkeyv2.h> |
| 13 | #include <linux/ipsec.h> | 13 | #include <linux/ipsec.h> |
| 14 | #include <linux/netfilter_ipv4.h> | 14 | #include <linux/netfilter_ipv4.h> |
| 15 | #include <linux/export.h> | ||
| 15 | 16 | ||
| 16 | static int xfrm4_init_flags(struct xfrm_state *x) | 17 | static int xfrm4_init_flags(struct xfrm_state *x) |
| 17 | { | 18 | { |
