Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net

+77 -107
+1 -1
drivers/net/dsa/dsa_loop.c
··· 352 352 353 353 mdio_driver_unregister(&dsa_loop_drv); 354 354 for (i = 0; i < NUM_FIXED_PHYS; i++) 355 - if (phydevs[i]) 355 + if (!IS_ERR(phydevs[i])) 356 356 fixed_phy_unregister(phydevs[i]); 357 357 } 358 358 module_exit(dsa_loop_exit);
+9 -26
include/net/inet_frag.h
··· 1 1 #ifndef __NET_FRAG_H__ 2 2 #define __NET_FRAG_H__ 3 3 4 - #include <linux/percpu_counter.h> 5 - 6 4 struct netns_frags { 7 - /* The percpu_counter "mem" need to be cacheline aligned. 8 - * mem.count must not share cacheline with other writers 9 - */ 10 - struct percpu_counter mem ____cacheline_aligned_in_smp; 11 - 5 + /* Keep atomic mem on separate cachelines in structs that include it */ 6 + atomic_t mem ____cacheline_aligned_in_smp; 12 7 /* sysctls */ 13 8 int timeout; 14 9 int high_thresh; ··· 103 108 int inet_frags_init(struct inet_frags *); 104 109 void inet_frags_fini(struct inet_frags *); 105 110 106 - static inline int inet_frags_init_net(struct netns_frags *nf) 111 + static inline void inet_frags_init_net(struct netns_frags *nf) 107 112 { 108 - return percpu_counter_init(&nf->mem, 0, GFP_KERNEL); 113 + atomic_set(&nf->mem, 0); 109 114 } 110 - static inline void inet_frags_uninit_net(struct netns_frags *nf) 111 - { 112 - percpu_counter_destroy(&nf->mem); 113 - } 114 - 115 115 void inet_frags_exit_net(struct netns_frags *nf, struct inet_frags *f); 116 116 117 117 void inet_frag_kill(struct inet_frag_queue *q, struct inet_frags *f); ··· 130 140 131 141 /* Memory Tracking Functions. */ 132 142 133 - /* The default percpu_counter batch size is not big enough to scale to 134 - * fragmentation mem acct sizes. 135 - * The mem size of a 64K fragment is approx: 136 - * (44 fragments * 2944 truesize) + frag_queue struct(200) = 129736 bytes 137 - */ 138 - static unsigned int frag_percpu_counter_batch = 130000; 139 - 140 143 static inline int frag_mem_limit(struct netns_frags *nf) 141 144 { 142 - return percpu_counter_read(&nf->mem); 145 + return atomic_read(&nf->mem); 143 146 } 144 147 145 148 static inline void sub_frag_mem_limit(struct netns_frags *nf, int i) 146 149 { 147 - percpu_counter_add_batch(&nf->mem, -i, frag_percpu_counter_batch); 150 + atomic_sub(i, &nf->mem); 148 151 } 149 152 150 153 static inline void add_frag_mem_limit(struct netns_frags *nf, int i) 151 154 { 152 - percpu_counter_add_batch(&nf->mem, i, frag_percpu_counter_batch); 155 + atomic_add(i, &nf->mem); 153 156 } 154 157 155 - static inline unsigned int sum_frag_mem_limit(struct netns_frags *nf) 158 + static inline int sum_frag_mem_limit(struct netns_frags *nf) 156 159 { 157 - return percpu_counter_sum_positive(&nf->mem); 160 + return atomic_read(&nf->mem); 158 161 } 159 162 160 163 /* RFC 3168 support :
+4 -3
include/net/route.h
··· 189 189 190 190 rcu_read_lock(); 191 191 err = ip_route_input_noref(skb, dst, src, tos, devin); 192 - if (!err) 192 + if (!err) { 193 193 skb_dst_force_safe(skb); 194 - if (!skb_dst(skb)) 195 - err = -EINVAL; 194 + if (!skb_dst(skb)) 195 + err = -EINVAL; 196 + } 196 197 rcu_read_unlock(); 197 198 198 199 return err;
+3 -8
net/ieee802154/6lowpan/reassembly.c
··· 580 580 { 581 581 struct netns_ieee802154_lowpan *ieee802154_lowpan = 582 582 net_ieee802154_lowpan(net); 583 - int res; 584 583 585 584 ieee802154_lowpan->frags.high_thresh = IPV6_FRAG_HIGH_THRESH; 586 585 ieee802154_lowpan->frags.low_thresh = IPV6_FRAG_LOW_THRESH; 587 586 ieee802154_lowpan->frags.timeout = IPV6_FRAG_TIMEOUT; 588 587 589 - res = inet_frags_init_net(&ieee802154_lowpan->frags); 590 - if (res) 591 - return res; 592 - res = lowpan_frags_ns_sysctl_register(net); 593 - if (res) 594 - inet_frags_uninit_net(&ieee802154_lowpan->frags); 595 - return res; 588 + inet_frags_init_net(&ieee802154_lowpan->frags); 589 + 590 + return lowpan_frags_ns_sysctl_register(net); 596 591 } 597 592 598 593 static void __net_exit lowpan_frags_exit_net(struct net *net)
+1 -3
net/ipv4/inet_fragment.c
··· 234 234 cond_resched(); 235 235 236 236 if (read_seqretry(&f->rnd_seqlock, seq) || 237 - percpu_counter_sum(&nf->mem)) 237 + sum_frag_mem_limit(nf)) 238 238 goto evict_again; 239 - 240 - percpu_counter_destroy(&nf->mem); 241 239 } 242 240 EXPORT_SYMBOL(inet_frags_exit_net); 243 241
+3 -9
net/ipv4/ip_fragment.c
··· 844 844 845 845 static int __net_init ipv4_frags_init_net(struct net *net) 846 846 { 847 - int res; 848 - 849 847 /* Fragment cache limits. 850 848 * 851 849 * The fragment memory accounting code, (tries to) account for ··· 869 871 870 872 net->ipv4.frags.max_dist = 64; 871 873 872 - res = inet_frags_init_net(&net->ipv4.frags); 873 - if (res) 874 - return res; 875 - res = ip4_frags_ns_ctl_register(net); 876 - if (res) 877 - inet_frags_uninit_net(&net->ipv4.frags); 878 - return res; 874 + inet_frags_init_net(&net->ipv4.frags); 875 + 876 + return ip4_frags_ns_ctl_register(net); 879 877 } 880 878 881 879 static void __net_exit ipv4_frags_exit_net(struct net *net)
+3 -9
net/ipv6/netfilter/nf_conntrack_reasm.c
··· 622 622 623 623 static int nf_ct_net_init(struct net *net) 624 624 { 625 - int res; 626 - 627 625 net->nf_frag.frags.high_thresh = IPV6_FRAG_HIGH_THRESH; 628 626 net->nf_frag.frags.low_thresh = IPV6_FRAG_LOW_THRESH; 629 627 net->nf_frag.frags.timeout = IPV6_FRAG_TIMEOUT; 630 - res = inet_frags_init_net(&net->nf_frag.frags); 631 - if (res) 632 - return res; 633 - res = nf_ct_frag6_sysctl_register(net); 634 - if (res) 635 - inet_frags_uninit_net(&net->nf_frag.frags); 636 - return res; 628 + inet_frags_init_net(&net->nf_frag.frags); 629 + 630 + return nf_ct_frag6_sysctl_register(net); 637 631 } 638 632 639 633 static void nf_ct_net_exit(struct net *net)
+3 -9
net/ipv6/reassembly.c
··· 714 714 715 715 static int __net_init ipv6_frags_init_net(struct net *net) 716 716 { 717 - int res; 718 - 719 717 net->ipv6.frags.high_thresh = IPV6_FRAG_HIGH_THRESH; 720 718 net->ipv6.frags.low_thresh = IPV6_FRAG_LOW_THRESH; 721 719 net->ipv6.frags.timeout = IPV6_FRAG_TIMEOUT; 722 720 723 - res = inet_frags_init_net(&net->ipv6.frags); 724 - if (res) 725 - return res; 726 - res = ip6_frags_ns_sysctl_register(net); 727 - if (res) 728 - inet_frags_uninit_net(&net->ipv6.frags); 729 - return res; 721 + inet_frags_init_net(&net->ipv6.frags); 722 + 723 + return ip6_frags_ns_sysctl_register(net); 730 724 } 731 725 732 726 static void __net_exit ipv6_frags_exit_net(struct net *net)
+29 -14
net/l2tp/l2tp_core.c
··· 329 329 struct hlist_head *g_head; 330 330 struct hlist_head *head; 331 331 struct l2tp_net *pn; 332 + int err; 332 333 333 334 head = l2tp_session_id_hash(tunnel, session->session_id); 334 335 335 336 write_lock_bh(&tunnel->hlist_lock); 337 + if (!tunnel->acpt_newsess) { 338 + err = -ENODEV; 339 + goto err_tlock; 340 + } 341 + 336 342 hlist_for_each_entry(session_walk, head, hlist) 337 - if (session_walk->session_id == session->session_id) 338 - goto exist; 343 + if (session_walk->session_id == session->session_id) { 344 + err = -EEXIST; 345 + goto err_tlock; 346 + } 339 347 340 348 if (tunnel->version == L2TP_HDR_VER_3) { 341 349 pn = l2tp_pernet(tunnel->l2tp_net); ··· 351 343 session->session_id); 352 344 353 345 spin_lock_bh(&pn->l2tp_session_hlist_lock); 354 - hlist_for_each_entry(session_walk, g_head, global_hlist) 355 - if (session_walk->session_id == session->session_id) 356 - goto exist_glob; 357 346 347 + hlist_for_each_entry(session_walk, g_head, global_hlist) 348 + if (session_walk->session_id == session->session_id) { 349 + err = -EEXIST; 350 + goto err_tlock_pnlock; 351 + } 352 + 353 + l2tp_tunnel_inc_refcount(tunnel); 354 + sock_hold(tunnel->sock); 358 355 hlist_add_head_rcu(&session->global_hlist, g_head); 356 + 359 357 spin_unlock_bh(&pn->l2tp_session_hlist_lock); 358 + } else { 359 + l2tp_tunnel_inc_refcount(tunnel); 360 + sock_hold(tunnel->sock); 360 361 } 361 362 362 363 hlist_add_head(&session->hlist, head); ··· 373 356 374 357 return 0; 375 358 376 - exist_glob: 359 + err_tlock_pnlock: 377 360 spin_unlock_bh(&pn->l2tp_session_hlist_lock); 378 - exist: 361 + err_tlock: 379 362 write_unlock_bh(&tunnel->hlist_lock); 380 363 381 - return -EEXIST; 364 + return err; 382 365 } 383 366 384 367 /* Lookup a tunnel by id ··· 1268 1251 /* Remove hooks into tunnel socket */ 1269 1252 sk->sk_destruct = tunnel->old_sk_destruct; 1270 1253 sk->sk_user_data = NULL; 1271 - tunnel->sock = NULL; 1272 1254 1273 1255 /* Remove the tunnel struct from the tunnel list */ 1274 1256 pn = l2tp_pernet(tunnel->l2tp_net); ··· 1277 1261 atomic_dec(&l2tp_tunnel_count); 1278 1262 1279 1263 l2tp_tunnel_closeall(tunnel); 1264 + 1265 + tunnel->sock = NULL; 1280 1266 l2tp_tunnel_dec_refcount(tunnel); 1281 1267 1282 1268 /* Call the original destructor */ ··· 1303 1285 tunnel->name); 1304 1286 1305 1287 write_lock_bh(&tunnel->hlist_lock); 1288 + tunnel->acpt_newsess = false; 1306 1289 for (hash = 0; hash < L2TP_HASH_SIZE; hash++) { 1307 1290 again: 1308 1291 hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) { ··· 1600 1581 tunnel->magic = L2TP_TUNNEL_MAGIC; 1601 1582 sprintf(&tunnel->name[0], "tunl %u", tunnel_id); 1602 1583 rwlock_init(&tunnel->hlist_lock); 1584 + tunnel->acpt_newsess = true; 1603 1585 1604 1586 /* The net we belong to */ 1605 1587 tunnel->l2tp_net = net; ··· 1848 1828 1849 1829 return ERR_PTR(err); 1850 1830 } 1851 - 1852 - l2tp_tunnel_inc_refcount(tunnel); 1853 - 1854 - /* Ensure tunnel socket isn't deleted */ 1855 - sock_hold(tunnel->sock); 1856 1831 1857 1832 /* Ignore management session in session count value */ 1858 1833 if (session->session_id != 0)
+7 -1
net/l2tp/l2tp_core.h
··· 162 162 int magic; /* Should be L2TP_TUNNEL_MAGIC */ 163 163 struct rcu_head rcu; 164 164 rwlock_t hlist_lock; /* protect session_hlist */ 165 + bool acpt_newsess; /* Indicates whether this 166 + * tunnel accepts new sessions. 167 + * Protected by hlist_lock. 168 + */ 165 169 struct hlist_head session_hlist[L2TP_HASH_SIZE]; 166 170 /* hashed list of sessions, 167 171 * hashed by id */ ··· 201 197 }; 202 198 203 199 struct l2tp_nl_cmd_ops { 204 - int (*session_create)(struct net *net, u32 tunnel_id, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg); 200 + int (*session_create)(struct net *net, struct l2tp_tunnel *tunnel, 201 + u32 session_id, u32 peer_session_id, 202 + struct l2tp_session_cfg *cfg); 205 203 int (*session_delete)(struct l2tp_session *session); 206 204 }; 207 205
+3 -8
net/l2tp/l2tp_eth.c
··· 262 262 dev->needed_headroom += session->hdr_len; 263 263 } 264 264 265 - static int l2tp_eth_create(struct net *net, u32 tunnel_id, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg) 265 + static int l2tp_eth_create(struct net *net, struct l2tp_tunnel *tunnel, 266 + u32 session_id, u32 peer_session_id, 267 + struct l2tp_session_cfg *cfg) 266 268 { 267 269 unsigned char name_assign_type; 268 270 struct net_device *dev; 269 271 char name[IFNAMSIZ]; 270 - struct l2tp_tunnel *tunnel; 271 272 struct l2tp_session *session; 272 273 struct l2tp_eth *priv; 273 274 struct l2tp_eth_sess *spriv; 274 275 int rc; 275 276 struct l2tp_eth_net *pn; 276 - 277 - tunnel = l2tp_tunnel_find(net, tunnel_id); 278 - if (!tunnel) { 279 - rc = -ENODEV; 280 - goto out; 281 - } 282 277 283 278 if (cfg->ifname) { 284 279 strlcpy(name, cfg->ifname, IFNAMSIZ);
+4 -4
net/l2tp/l2tp_netlink.c
··· 643 643 break; 644 644 } 645 645 646 - ret = -EPROTONOSUPPORT; 647 - if (l2tp_nl_cmd_ops[cfg.pw_type]->session_create) 648 - ret = (*l2tp_nl_cmd_ops[cfg.pw_type]->session_create)(net, tunnel_id, 649 - session_id, peer_session_id, &cfg); 646 + ret = l2tp_nl_cmd_ops[cfg.pw_type]->session_create(net, tunnel, 647 + session_id, 648 + peer_session_id, 649 + &cfg); 650 650 651 651 if (ret >= 0) { 652 652 session = l2tp_session_get(net, tunnel, session_id, false);
+7 -12
net/l2tp/l2tp_ppp.c
··· 788 788 789 789 #ifdef CONFIG_L2TP_V3 790 790 791 - /* Called when creating sessions via the netlink interface. 792 - */ 793 - static int pppol2tp_session_create(struct net *net, u32 tunnel_id, u32 session_id, u32 peer_session_id, struct l2tp_session_cfg *cfg) 791 + /* Called when creating sessions via the netlink interface. */ 792 + static int pppol2tp_session_create(struct net *net, struct l2tp_tunnel *tunnel, 793 + u32 session_id, u32 peer_session_id, 794 + struct l2tp_session_cfg *cfg) 794 795 { 795 796 int error; 796 - struct l2tp_tunnel *tunnel; 797 797 struct l2tp_session *session; 798 798 struct pppol2tp_session *ps; 799 799 800 - tunnel = l2tp_tunnel_find(net, tunnel_id); 801 - 802 - /* Error if we can't find the tunnel */ 803 - error = -ENOENT; 804 - if (tunnel == NULL) 805 - goto out; 806 - 807 800 /* Error if tunnel socket is not prepped */ 808 - if (tunnel->sock == NULL) 801 + if (!tunnel->sock) { 802 + error = -ENOENT; 809 803 goto out; 804 + } 810 805 811 806 /* Default MTU values. */ 812 807 if (cfg->mtu == 0)