2601/** 2602 * sock_unregister - remove a protocol handler 2603 * @family: protocol family to remove 2604 * 2605 * This function is called by a protocol handler that wants to 2606 * remove its address family, and have it unlinked from the 2607 * new socket creation. 2608 * 2609 * If protocol handler is a module, then it can use module reference 2610 * counts to protect against new references. If protocol handler is not 2611 * a module then it needs to provide its own protection in 2612 * the ops->create routine. 2613 */ 2614voidsock_unregister(int family) 2615 { 2616 BUG_ON(family < 0 || family >= NPROTO); 2617 2618 spin_lock(&net_family_lock); 2619 RCU_INIT_POINTER(net_families[family], NULL); 2620 spin_unlock(&net_family_lock); 2621 2622 synchronize_rcu(); 2623 2624 printk(KERN_INFO "NET: Unregistered protocol family %d\n", family); 2625 } 2626 EXPORT_SYMBOL(sock_unregister);
1243int __sock_create(struct net *net, int family, int type, int protocol, 1244struct socket **res, int kern) 1245 { ... 1291#ifdef CONFIG_MODULES 1292/* Attempt to load a protocol module if the find failed. 1293 * 1294 * 12/09/1996 Marcin: But! this makes REALLY only sense, if the user 1295 * requested real, full-featured networking support upon configuration. 1296 * Otherwise module support will break! 1297 */ 1298if (rcu_access_pointer(net_families[family]) == NULL) 1299 request_module("net-pf-%d", family); 1300#endif 1301 1302 rcu_read_lock(); 1303 pf = rcu_dereference(net_families[family]); 1304 err = -EAFNOSUPPORT; 1305if (!pf) 1306goto out_release; 1307 1308/* 1309 * We will call the ->create function, that possibly is in a loadable 1310 * module, so we have to bump that loadable module refcnt first. 1311 */ 1312if (!try_module_get(pf->owner)) 1313goto out_release; 1314 1315/* Now protected by module ref count */ 1316 rcu_read_unlock();