struct net { /* First cache line can be often dirtied. *Donotplacehereread-mostlyfields.
*/
refcount_t passive; /* To decide when the network *namespaceshouldbefreed.
*/
spinlock_t rules_mod_lock;
unsignedint dev_base_seq; /* protected by rtnl_mutex */
u32 ifindex;
spinlock_t nsid_lock;
atomic_t fnhe_genid;
struct list_head list; /* list of network namespaces */ struct list_head exit_list; /* To linked to call pernet exit *methodsondeadnet( *pernet_ops_rwsemreadlocked), *ortounregisterpernetops *(pernet_ops_rwsemwritelocked).
*/ struct llist_node defer_free_list; struct llist_node cleanup_list; /* namespaces on death row */
#ifdef CONFIG_NET_NS void __put_net(struct net *net);
/* Try using get_net_track() instead */ staticinlinestruct net *get_net(struct net *net)
{
refcount_inc(&net->ns.count); return net;
}
staticinlinestruct net *maybe_get_net(struct net *net)
{ /* Used when we know struct net exists but we *aren'tguaranteedapreviousreferencecount *exists.Ifthereferencecountiszerothis *functionfailsandreturnsNULL.
*/ if (!refcount_inc_not_zero(&net->ns.count))
net = NULL; return net;
}
/* Try using put_net_track() instead */ staticinlinevoid put_net(struct net *net)
{ if (refcount_dec_and_test(&net->ns.count))
__put_net(net);
}
staticinline int net_eq(conststruct net *net1, conststruct net *net2)
{ return net1 == net2;
}
staticinlineint check_net(conststruct net *net)
{ return refcount_read(&net->ns.count) != 0;
}
void net_drop_ns(void *); void net_passive_dec(struct net *net);
#else
staticinlinestruct net *get_net(struct net *net)
{ return net;
}
staticinlinevoid put_net(struct net *net)
{
}
staticinlinestruct net *maybe_get_net(struct net *net)
{ return net;
}
staticinline int net_eq(conststruct net *net1, conststruct net *net2)
{ return1;
}
staticinlineint check_net(conststruct net *net)
{ return1;
}
#define net_drop_ns NULL
staticinlinevoid net_passive_dec(struct net *net)
{
refcount_dec(&net->passive);
} #endif
staticinlinevoid net_passive_inc(struct net *net)
{
refcount_inc(&net->passive);
}
/* Returns true if the netns initialization is completed successfully */ staticinlinebool net_initialized(conststruct net *net)
{ return READ_ONCE(net->list.next);
}
int peernet2id_alloc(struct net *net, struct net *peer, gfp_t gfp); int peernet2id(conststruct net *net, struct net *peer); bool peernet_has_id(conststruct net *net, struct net *peer); struct net *get_net_ns_by_id(conststruct net *net, int id);
struct pernet_operations { struct list_head list; /* *Belowmethodsarecalledwithoutanyexclusivelocks. *Morethanonenetmaybeconstructedanddestructed *inparallelonseveralcpus.Everypernet_operations *havetokeepinmindallotherpernet_operationsand *tointroducealocking,iftheysharecommonresources. * *Theonlytimetheyarecalledwithexclusivelockis *fromregister_pernet_subsys(),unregister_pernet_subsys() *register_pernet_device()andunregister_pernet_device(). * *ExitmethodsusingblockingRCUprimitives,suchas *synchronize_rcu(),shouldbeimplementedviaexit_batch. *Then,destructionofagroupofnetrequiressingle *synchronize_rcu()relatedtothesepernet_operations, *insteadofseparatesynchronize_rcu()foreverynet. *Please,avoidsynchronize_rcu()atall,whereit'spossible. * *Notethatacombinationofpre_exit()andexit()can *beused,sinceasynchronize_rcu()isguaranteedbetween *thecalls.
*/ int (*init)(struct net *net); void (*pre_exit)(struct net *net); void (*exit)(struct net *net); void (*exit_batch)(struct list_head *net_exit_list); /* Following method is called with RTNL held. */ void (*exit_rtnl)(struct net *net, struct list_head *dev_kill_list); unsignedint * const id; const size_t size;
};
staticinlinevoid rt_genid_bump_ipv4(struct net *net)
{
atomic_inc(&net->ipv4.rt_genid);
}
externvoid (*__fib6_flush_trees)(struct net *net); staticinlinevoid rt_genid_bump_ipv6(struct net *net)
{ if (__fib6_flush_trees)
__fib6_flush_trees(net);
}
/* For callers who don't really care about whether it's IPv4 or IPv6 */ staticinlinevoid rt_genid_bump_all(struct net *net)
{
rt_genid_bump_ipv4(net);
rt_genid_bump_ipv6(net);
}
staticinlineint fnhe_genid(conststruct net *net)
{ return atomic_read(&net->fnhe_genid);
}
staticinlinevoid fnhe_genid_bump(struct net *net)
{
atomic_inc(&net->fnhe_genid);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.